-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.asm
More file actions
503 lines (415 loc) · 9.58 KB
/
menu.asm
File metadata and controls
503 lines (415 loc) · 9.58 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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
;Copyright 2004 Samuel Stearley
;----Inputs---------------------------------------------
;d5.w -> x cordinate, in bytes of where to draw the
; menu.
;----Outputs--------------------------------------------
;The menu is drawn. It is 11 bytes wide.
;Text might be placed in the help line.
;Flags might get set or reset.
;
;In essence, pretty much all graphical stuff is done
;here.
;
;Text also might be pasted and highlighted.
;-------------------------------------------------------
DisplayMenu:
checkTrashing 'f'
;----First see if there is only one item in the menu and if so
;----place it and highlight it.
lea oneThingAllowed(pc),a1 ;backspace indicator
tst.b (a1)
bne StillShowMenu
move.b unitIndic(pc),d0
bne StillShowMenu
move.l ptr(pc),a0
tst.l 4(a0)
bne StillShowMenu
tst.l (a0)
bmi StillShowMenu ;is the one thing a folder name?
;----So it can be pasted----
move.l 60(a7),a2 ;get event structure
move.l (a0),a0
move.w charBufferIndex(pc),d3
ext.l d3
sub.l d3,a0
move.l a0,d0
moveq #0,d2 ;no special file types
bsr IsSpecialString2
add.l d3,d0
move.l d0,a3
lea activatedFlag(pc),a5
st.b (a5)
move.l a2,-(a7)
move.w #-2,-(a7)
move.l 824(a6),a0
jsr (a0) ;it has not been displayed so send the event
; if it had been displayed at the beginning
; then it would have been turned into command
; idle
checkTrashing 'A'
move.w #$700,(a2) ;make it command idle
;----make sure no ':' char is in it-------
move.l a3,d0
bsr RemoveComments
move.l d0,a3
PasteString2:
;----Put the text to the entry line-------
lea pasteEvent(pc),a0
move.w #$723,(a0) ;make sure it is a paste event
move.l a0,-(a7)
move.w #-2,-(a7)
move.l a3,8(a0) ;put pointer to the event
move.l 824(a6),a4 ;get ev send event
jsr (a4) ;send it, if the menu is visible it is deleted
checkTrashing 'B'
;----Highlight the pasted text---
moveq #-2,d3
CounterLoop:
addq.l #1,d3
tst.b (a3)+
bne CounterLoop
lea shiftBackEvent(pc),a0
move.l a0,2(a7)
HighLightLoop:
jsr (a4)
dbra d3,HighLightLoop
lea 16(a7),a7
clr.b (a5)
bra RestoreTheScreenAndRestartBuffer
;--------------------------------------------
;DO THE MENU LIKE NORMAL
;--------------------------------------------
StillShowMenu:
move.w mode(pc),d6
clr.b (a1) ;clear the One thing allowed flag
moveq #1,d0 ;set low bit and clear the rest
moveq #-128,d1 ;set the high bit of the byte
moveq #-1,d2 ;set all the bits
moveq #20,d4 ;increment
ifd ti89
lea LCD_MEM+30*40,a1 ;the y of where my menu is in video memory
endc
ifd ti92plus
lea LCD_MEM+30*48,a1
endc
tst.w d6
beq LeaveA1Alone
ifd ti89
lea LCD_MEM+30*26,a1
endc
ifd ti92plus
lea LCD_MEM+30*28,a1
endc
LeaveA1Alone:
checkTrashing 'g'
lea menuIndic(pc),a5
tst.b (a5)
bne.s SkipBackup
move.l ptr(pc),a0
add.l #(NUMBER_OF_MATCHES+1)*4,a0 ;pointer to the backup
lea 0(a1,d5),a3 ;copy to alter
moveq #40,d3
tst.w d6
beq LeavD3Alone
moveq #52,d3
LeavD3Alone:
BackupLoop:
move.b (a3)+,(a0)+
move.b (a3)+,(a0)+
move.b (a3)+,(a0)+
move.b (a3)+,(a0)+
move.b (a3)+,(a0)+
move.b (a3)+,(a0)+
move.b (a3)+,(a0)+
move.b (a3)+,(a0)+
move.b (a3)+,(a0)+
move.b (a3)+,(a0)+
move.b (a3),(a0)+
add.l d4,a3 ;move down 1 line
dbra d3,BackupLoop ;save all of it.
SkipBackup:
lea 0(a1,d5),a1
lea windowPointer(pc),a0
move.l a1,(a0) ;save pointer to the window
;---Top line------
move.b d2,(a1)+
move.b d2,(a1)+
move.b d2,(a1)+
move.b d2,(a1)+
move.b d2,(a1)+
move.b d2,(a1)+
move.b d2,(a1)+
move.b d2,(a1)+ ;upper line
move.b d2,(a1)+
move.b d2,(a1)+
move.b d2,(a1)
add.l d4,a1 ;move down a line
;---Sides and clear inner-----
moveq #38,d3 ;counter
tst.w d6
beq LeaveD3Alone2
moveq #50,d3
LeaveD3Alone2:
DrawMostOfIt:
move.b d1,(a1)+ ;make the left border
clr.b (a1)+
clr.b (a1)+
clr.b (a1)+
clr.b (a1)+
clr.b (a1)+ ;clear the inner part
clr.b (a1)+
clr.b (a1)+
clr.b (a1)+
clr.b (a1)+
move.b d0,(a1) ;right border
add.l d4,a1
dbra d3,DrawMostOfIt ;do all of it
;----Now for the bottom line----
move.b d2,(a1)+
move.b d2,(a1)+
move.b d2,(a1)+
move.b d2,(a1)+
move.b d2,(a1)+
move.b d2,(a1)+
move.b d2,(a1)+
move.b d2,(a1)+
move.b d2,(a1)+
move.b d2,(a1)+
move.b d2,(a1)
st.b (a5) ;indicate that the menu is drawn
;----Now for the line dividing the title from the rest----
ifd ti89
lea LCD_MEM+30*48,a0
endc
ifd ti92plus
lea LCD_MEM+30*56,a0
endc
tst.w d6
beq LeaveA0Alone3
ifd ti89
lea LCD_MEM+30*36,a0
endc
ifd ti92plus
lea LCD_MEM+30*38,a0
endc
LeaveA0Alone3:
lea 0(a0,d5),a0
move.b d2,(a0)+
move.b d2,(a0)+
move.b d2,(a0)+
move.b d2,(a0)+
move.b d2,(a0)+
move.b d2,(a0)+
move.b d2,(a0)+
move.b d2,(a0)+
move.b d2,(a0)+
move.b d2,(a0)+
move.b d2,(a0)+ ;the division line
;----Now for the title part of my menu----
checkTrashing 'p'
lsl.w #3,d5 ;multiply x in bytes by 8
move.l 1596(a6),a0 ;set font rom call
move.w d6,-(a7) ;want the small or large font
jsr (a0)
checkTrashing 'C'
move.w #4,-(a7)
move.l title(pc),a0
tst.w d6
beq NoTruncating
lea buffer(pc),a1
moveq #13,d0
TruncateLoop:
move.b (a0)+,(a1)+
dbeq d0,TruncateLoop
clr.b (a1)
lea buffer(pc),a0
NoTruncating:
move.l a0,-(a7)
checkTrashing 'D'
ifd ti89
move.w #42,-(a7) ;cordnates of the title
endc
ifd ti92plus
move.w #50,-(a7)
endc
tst.w d6
beq LeaveYAlone
ifd ti89
move.w #28,(a7)
endc
ifd ti92plus
move.w #30,(a7)
endc
LeaveYAlone:
addq.w #1,d5
move.w d5,-(a7)
move.l 1700(a6),a5 ;text display rom call
jsr (a5)
checkTrashing 'E'
;----Now for the right arrow that indicates if names or variables were
;----Added so it can be scrolled right.
move.b foldersAndVarsIndic(pc),d0
beq.s NoRightArrow
move.b pageIndic(pc),d0 ;indicates vars are in the list
bne.s NoRightArrow
move.b folderWasCompleted(pc),d0
bne.s NoRightArrow
move.b unitIndic(pc),d0
bne.s NoRightArrow
lea rightArrow(pc),a0
move.l a0,4(a7)
add.w #79,(a7) ;alter x
jsr (a5)
;----Now for the function key label part of my menu----
NoRightArrow:
addq.l #8,a7
lea functionString(pc),a4
move.l a4,-(a7)
move.b #'1',(a4)
ifd ti89
move.w #50,-(a7) ;y cordinate
endc
ifd ti92plus
move.w #58,-(a7)
endc
moveq #6,d4
tst.w d6
beq LeaveYAlone2
moveq #8,d4
ifd ti89
move.w #38,(a7)
endc
ifd ti92plus
move.w #40,(a7)
endc
LeaveYAlone2:
move.w d5,-(a7) ;x
moveq #4,d7 ;counter - function keys
DrawFunctionKeyLoop:
jsr (a5) ;display it
add.w d4,2(a7) ;alter y
addq.b #1,(a4) ;change it from '1' to '2' ...
dbra.s d7,DrawFunctionKeyLoop
lea 12(a7),a7
;----Now for the up arrow to indicate that the menu can be
;----scrolled up, if it can't then nothing is displayed
move.w #4,-(a7)
pea upArrow(pc)
ifd ti89
move.w #50,-(a7)
endc
ifd ti92plus
move.w #58,-(a7)
endc
tst.w d6
beq LeaveYAlone3
ifd ti89
move.w #38,(a7)
endc
ifd ti92plus
move.w #40,(a7)
endc
addq.w #2,d5
LeaveYAlone3:
addq.w #4,d5
move.w d5,-(a7) ;x
move.l ptr(pc),a3
move.w listBufferIndex(pc),d3
beq.s NoUpArrowNeeded
jsr (a5)
;----Now for the strings behind each of the function labels just
;----displayed above.
NoUpArrowNeeded:
lea 0(a3,d3),a3
addq.w #7,(a7)
tst.b d6
bne hop45
subq.w #2,(a7)
hop45
moveq #4,d7
DrawOptionLoop:
move.l (a3)+,d0
beq.s DoneDrawingMenu
moveq #0,d1
move.w charBufferIndex(pc),d1
sub.l d1,d0
moveq #1,d2
bsr IsSpecialString1 ;see if it needs to have a "\" or a "(" appended
move.l d0,4(a7)
jsr (a5)
add.w d4,2(a7)
dbra.s d7,DrawOptionLoop
;----see if the down arrow is needed to indicate that
;----it can be scrolled down.
tst.l (a3)
beq.s DoneDrawingMenu
lea downArrow(pc),a0
move.l a0,4(a7)
subq.w #7,(a7)
tst.b d6
bne hop412
addq.w #2,(a7)
hop412
sub.w d4,2(a7)
jsr (a5)
DoneDrawingMenu:
lea 10(a7),a7
;----Now add the help line of upcoming units-------
move.b unitIndic(pc),d0
beq.s NoHelp
move.b shortcutTableInView(pc),d0
bne NoHelp
;---Loop setup----
ifd ti89
moveq #4,d1
endc
ifd ti92plus
moveq #6,d1
endc
lea nextUnitsBuffer(pc),a0
move.l a0,-(a7)
move.w offsetTableIndex(pc),d2
move.l externalDb(pc),a1
move.w 2(a1),d0
lea 0(a1,d0.w),a1
moveq #5,d0 ;six titles to add
moveq #NUMBER_OF_UNIT_MENUS+2,d4
move.b unitReplacementIndic(pc),d3
beq KeepD4
subq.w #2,d4
KeepD4:
;---add the titles to the list----
AddTitlesLoop:
addq.w #2,d2
cmp.w d4,d2
bne.s SkipWrapping
moveq #0,d2
SkipWrapping:
move.b unitReplacementIndic(pc),d3
beq NotSystemVarsInUnitMenu
cmp.w #NUMBER_OF_UNIT_MENUS-2,d2
bne NotSystemVarsInUnitMenu
moveq #-2,d2
lea systemVariableText(pc),a3 ;point to title
bra UseSystemTitle
NotSystemVarsInUnitMenu:
move.w 0(a1,d2),d3
lea 8(a1,d3),a3 ;point to the title
UseSystemTitle:
move.w d1,d3
CopyPartOfTitle:
move.b (a3)+,(a0)+
dbeq d3,CopyPartOfTitle
bne.s SkipDecrement
subq.l #1,a0 ;point to the zero
SkipDecrement:
move.b #',',(a0)+
move.b #' ',(a0)+
dbra d0,AddTitlesLoop
clr.b -2(a0) ;zero terminate/ clear comma
;----Display the list----------
move.l 920(a6),a0 ;get help display
jsr (a0)
addq.l #4,a7
NoHelp:
rts