-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunit.asm
More file actions
310 lines (252 loc) · 6 KB
/
unit.asm
File metadata and controls
310 lines (252 loc) · 6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
;By Samuel Stearley copyright 2004
;-----This is the code for the unit menu replacement------
PossiblyNewUnitMenu:
cmp.w #$710,(a2) ;check here if not in the home app
bne PassItOn
ifd ti89
cmp.w #4147,10(a2) ;is it the units?
bne PassItOn
endc
ifd ti92plus
cmp.w #8272,10(a2)
bne PassItOn
endc
;-----The following code is executed if it the unit menu is executed
DefinitelyUnitMenu:
move.w #$700,(a2) ;make it command idle
move.b menuIndic(pc),d0
beq.s NotSeen
bsr RemoveMenu
lea menuIndic(pc),a0
clr.b (a0)
NotSeen:
;----Allocate memory----------
move.l 200,a6
bsr AllocateMem
;------Now To actually do the unit menu-------
NewUnitMenu2:
;----Set certain variables----
moveq #0,d7
NewUnitMenu3:
lea unitIndic(pc),a0
st.b (a0)
lea unitReplacementIndic(pc),a0
st.b (a0)
move.w offsetTableIndex(pc),d2
cmp.w #NUMBER_OF_UNIT_MENUS,d2
bcs NotVariablePage
moveq #0,d2
lea offsetTableIndex(pc),a0
move.w d2,(a0)
NotVariablePage:
cmp.w #NUMBER_OF_UNIT_MENUS-2,d2
bne KeepUnitMenu
move.l externalDb(pc),a0
move.w (a0),d1
lea 2(a0,d1.w),a0 ;point to the system variable strings
bra UseSystemVariables
KeepUnitMenu
move.l externalDb(pc),a0
move.w 2(a0),d0
lea 0(a0,d0.w),a0 ;point to the offset table
move.w 0(a0,d2.w),d0
lea 2(a0,d0.w),a0 ;point to the data item, the '2' is to get past the
UseSystemVariables: ; indexed flag.
DoShortcutMenu:
move.w (a0)+,d1
bne ThereIsExternal
sub.l a5,a5
bra KeepA52
ThereIsExternal:
lea -4(a0,d1.w),a5
KeepA52:
move.w (a0)+,d1
move.w (a0)+,d2
lea title(pc),a1
move.l a0,(a1) ;new title for the menu.
move.l ptr(pc),a3
moveq #NUMBER_OF_MATCHES,d0;max number of items in the list
tst.w d2
bne NoCompensate
Adver
tst.b (a0)+
bne Adver
NoCompensate:
;----Advance a0 past the title----
Advances:
tst.b (a0)+
bne.s Advances
;----put pointers to the list---
move.l a0,(a3)+ ;add to the list
addq.l #3,a0
subq.w #1,d0 ;decrease the number of remaining
dbeq d1,Advances ;add pointers to all the strings
;----Add external data items to the list----
tst.w d7
bne NoExternal
lea charBuffer(pc),a0
move.w #$0100,(a0) ;let in everything with out question
;----Set up for the call to add to the list from an external---
cmp.w #NUMBER_OF_UNIT_MENUS-2,d2;system vars?
beq NoExternal
move.l a5,a0
bsr AddFromExternal
;----Display the menu---
NoExternal
and.w #%111,d0
ZeroThem:
clr.l (a3)+ ;zero the rest of them
dbra d0,ZeroThem
lea listBufferIndex(pc),a0
clr.l (a0)
ReDoMenu2:
ifd ti89
moveq #4,d5 ;x of menu
endc
ifd ti92plus
moveq #10,d5
endc
lea menuX(pc),a0
move.w d5,(a0) ;for when the menu is gotten rid of
move.l d7,-(a7)
bsr DisplayMenu
move.l (a7)+,d7
;----Idle and process keys-----
CanNotScroll2:
clr.l -(a7)
clr.w -(a7)
move.l 1528(a6),a0
jsr (a0)
addq.l #6,a7
lea listBufferIndex(pc),a0
move.w (a0),d1
moveq #32,d2
ifd ti89
cmp.w #337,d0 ;up?
beq.s ScrollUp2
cmp.w #340,d0 ;down?
bne.s NotVerticalArrows2
endc
ifd ti92plus
cmp.w #338,d0
beq.s ScrollUp2
cmp.w #344,d0
bne.s NotVerticalArrows2
endc
;----Code to scroll down----------------
move.l ptr(pc),a1
tst.l 32(a1,d1) ;is the first adress of the next page a zero?
beq CanNotScroll2
add.w d2,d1
move.w d1,(a0)
bra ReDoMenu2
;----Code to scroll up------------------
ScrollUp2:
tst.w d1 ;are we still on the first page?
beq CanNotScroll2
sub.w d2,d1
move.w d1,(a0)
bra ReDoMenu2
NotVerticalArrows2:
;----maybe a shortcut table---------
lea offsetTableIndex(pc),a0
ifd ti89
moveq #56,d1
cmp.w #277,d0 ;home?
beq PutIt
moveq #28,d1
cmp.w #258,d0 ;store? (p)
beq PutIt
endc
cmp.w #256,d0 ;a char?
bcc NotShortcut
lea shortcutTable(pc),a4
lea shortcutOffsets-2(pc),a1
SearchTable:
addq.l #2,a1
tst.b (a4)
beq NotShortcut
cmp.b (a4)+,d0
bne SearchTable
move.w (a1),d1
PutIt:
move.w d1,(a0)
bra NewUnitMenu2
NotShortcut:
tst.w d7 ;any other key results in the previous menu being displayed
bne NewUnitMenu2
;----is it apps?------------
cmp.w #265,d0
bne NotApps
moveq #1,d7
NeedShortcuts:
lea unitIndic(pc),a0
clr.b (a0) ;no help
move.l externalDb(pc),a0
move.w 2(a0),d0
lea 0(a0,d0.w),a0 ;point to the offset table
move.w -2(a0),d0
lea 2(a0,d0.w),a0 ;point to the data base
bra DoShortcutMenu
;----Is it escape?---------
NotApps:
cmp.w #264,d0
beq RestoreTheScreenAndRestartBuffer
;----Now For right and left arrows-----------
moveq #2,d1 ;increment
move.w (a0),d2
ifd ti89
cmp.w #4440,d0 ;2nd + right?
beq.s ScrollMuchRight2
cmp.w #338,d0 ;left?
beq.s ScrollLeft3
cmp.w #344,d0 ;right?
bne.s NotHorizontalArrows2
endc
ifd ti92plus
cmp.w #4436,d0
beq.s ScrollMuchRight2
cmp.w #337,d0
beq.s ScrollLeft3
cmp.w #340,d0
bne.s NotHorizontalArrows2
endc
;----code to scroll right---------------
cmp.w #NUMBER_OF_UNIT_MENUS-2,d2;are we already as far left as possible?
bne.s NoWrapToLeftSide2 ;then we can not scroll it
moveq #-2,d2
NoWrapToLeftSide2:
add.w d1,d2
move.w d2,(a0)
bra NewUnitMenu2
;----code to scroll left---------------
ScrollLeft3:
sub.w d1,d2
bcc.s NoWrapToRightSide2
moveq #NUMBER_OF_UNIT_MENUS-2,d2
NoWrapToRightSide2:
move.w d2,(a0)
bra NewUnitMenu2
;----code to scroll much right-----------
ScrollMuchRight2:
add.w #14,d2
cmp.w #NUMBER_OF_UNIT_MENUS,d2
bcs.s SkipWrapping3
sub.w #NUMBER_OF_UNIT_MENUS,d2
SkipWrapping3:
move.w d2,(a0)
bra NewUnitMenu2
NotHorizontalArrows2:
;----Now for the function keys------------
move.w d0,d1
sub.w #268,d1
bcs CanNotScroll2
cmp.w #8,d1
bcc CanNotScroll2
lsl.w #2,d1
move.w listBufferIndex(pc),d2
add.w d1,d2
move.l ptr(pc),a0
move.l 0(a0,d2),d0
beq CanNotScroll2
bra PasteString