-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreprocs.asm
More file actions
356 lines (294 loc) · 7.64 KB
/
preprocs.asm
File metadata and controls
356 lines (294 loc) · 7.64 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
;Copyright 2004 by Samuel Stearley
;This code in this file does the pre-processing of the stuff
;already typed in the entry line.
lea charBufferIndex(pc),a5
move.w (a5),d5
move.w d0,d3
lea charBuffer(pc),a4
move.l a4,a0
;----Backspace response-----
cmp.w #257,d0
bne NoBackSpace
lea folderWasCompleted(pc),a3
clr.w (a3)
bra BackSpaceIt
NoBackSpace:
;----see if it is a character and if it is maybe modify it for case
;----insensitive searching. And In some circumstances we always pre-process
cmp.w #256,d3 ;is it a character?
bcc NotCharacter
move.b shortcutTableInView(pc),d1
bne MaybeRespondToShortctKey
cmp.b #13,d0 ;enter key
beq RestoreTheScreenAndRestartBuffer
cmp.b #':',d3
beq RestoreTheScreenAndRestartBuffer
cmp.b #' ',d3
beq HandleIt
cmp.b #'\',d3
beq HandleIt
cmp.b #'.',d3
beq HandleIt
cmp.b #'_',d3
beq HandleIt
cmp.b #18,d3
beq HandleIt
cmp.b #91,d3
bcc.s NotUpper1
cmp.b #65,d3
bcs.s NotUpper1
add.b #32,d3 ;make it lower case
NotUpper1:
move.b menuIndic(pc),d0
bne PutTheNewChar
BackSpaceIt:
HandleIt:
lea oneThingAllowed(pc),a3 ;disable paste and highlight
st.b (a3)
;----Just in case text is highlighted I send it as an event----
lea activatedFlag(pc),a3
st.b (a3)
move.l a2,-(a7)
move.w #-2,-(a7)
move.l 824(a6),a0
jsr (a0)
addq.l #6,a7
move.w #$700,(a2) ;CM_idle
clr.b (a3)
checkTrashing 'G'
;----Now consider already entered keys----
moveOpcode4:
move.w $1234,-(a7) ;handle on entry line text
move.l 600(a6),a0 ;dereference call
jsr (a0)
addq.l #2,a7
moveOpcode5:
move.w $1234,d0 ;cursor position
beq RestoreTheScreenAndRestartBuffer
move.w d0,d4
lea seperationCharacters(pc),a1
moveq #0,d6 ;folder indicator/flash app notation indic
checkTrashing 'H'
;----Find First Occurence of a Seperation Character----
FindLowerSeperationChar
subq.w #1,d0
bcs DoneWithFindingSeperationChars
move.b 0(a0,d0),d2
;----variables in other folder support---
cmp.b #'\',d2 ;folder?
bne NotFolderIndic
tst.w d6
bne RestoreTheScreenAndRestartBuffer
move.w d0,d6 ;put the position it was found into d6
NotFolderIndic:
;----Flash app notation support---------
cmp.b #'.',d2
bne NotFlashAppNotation
move.b 1(a0,d0),d1 ;if character right after is a number then it is a
cmp.b #'0',d1 ;seperation character
bcs NotANumber9
cmp.b #':',d1
bcs DotIsASeperationChar
NotANumber9:
tst.w d6
bne NotFlashAppNotation
move.w d0,d6
;----Degree char is not a seperation char if previous char is an underscore-----
NotFlashAppNotation:
cmp.b #176,d2
bne NotDegree
tst.w d0 ;is there anything before
beq RestoreTheScreenAndRestartBuffer
cmp.b #'_',-1(a0,d0)
bne DoneWithFindingSeperationChars
;----Try to find it in the table of seperation characters---
NotDegree:
move.l a1,a3
moveq #(afterSepChars-seperationCharacters)-1,d1
FindCharsInTableLoop:
cmp.b (a3)+,d2
dbeq d1,FindCharsInTableLoop
bne FindLowerSeperationChar
;----Now That we have the lower seperation character, we bypass the numbers
;----immediately after it because they are for implied multiplication.
DoneWithFindingSeperationChars:
DotIsASeperationChar:
addq.w #1,d0
lea 0(a0,d0),a1
sub.w d0,d4 ;counter
bne NoWorry
move.b -(a1),d3 ;Support for a seperation character as the first
moveq #0,d5 ; character.
move.l a4,a0
bra PutTheNewChar
NoWorry:
cmp.w #600,d4
bcc RestoreTheScreenAndRestartBuffer
moveq #46,d5 ;'.'
moveq #48,d7 ;'0'
moveq #58,d0 ;':'
;---consider if it is a some other base----
cmp.b (a1)+,d7
bne NotABase
move.b (a1),d1
beq NotABase
cmp.b #'h',d1
beq HexBase
cmp.b #'H',d1
beq HexBase
cmp.b #'B',d1
beq BinaryBase
cmp.b #'b',d1
bne NotABase
;----Bypass the bin number imediately after the seperation character----
BinaryBase:
subq.w #2,d4
bls RestoreTheScreenAndRestartBuffer
addq.l #1,a1
FindNextNotNumberLoop3:
move.b (a1)+,d1
sub.b d7,d1
subq.b #1,d1
bhi NotANumber
subq.w #1,d4
beq RestoreTheScreenAndRestartBuffer
bra FindNextNotNumberLoop3
;----Bypass the hex number immediately after the seperation character----
HexBase:
subq.w #2,d4
bls RestoreTheScreenAndRestartBuffer
addq.l #1,a1
FindNextNotNumberLoop2:
move.b (a1)+,d1
cmp.b #'A',d1
bcs NotL1
cmp.b #'G',d1
bcs BypassHexChar
NotL1:
cmp.b #'a',d1
bcs NotL2
cmp.b #'g',d1
bcs BypassHexChar
NotL2:
cmp.b d7,d1
bcs NotANumber
cmp.b d0,d1
bcc NotANumber
BypassHexChar:
subq.w #1,d4
beq RestoreTheScreenAndRestartBuffer
bra FindNextNotNumberLoop2
;---So bypass the number---
NotABase:
subq.l #1,a1
FindNextNotNumberLoop:
move.b (a1)+,d1
cmp.b d5,d1 ;dot?
beq BypassDecimal
cmp.b d7,d1 ;0?
bcs NotANumber
cmp.b d0,d1 ;upper limit on a number
bcc NotANumber
BypassDecimal:
subq.w #1,d4
beq RestoreTheScreenAndRestartBuffer
bra FindNextNotNumberLoop
NotANumber:
cmp.b #'\',-(a1)
beq RestoreTheScreenAndRestartBuffer
;----If the first thing after the numbers/seperaration chars is an underscore
;----then subsequent underscores imply multiplication.
cmp.b #'_',(a1)
seq d7
;----If we bypassed a decimal place when bypassing the number after
;----the seperation character then check if it was the same decimal
;----place that indicates flash app notation.
lea 0(a0,d6),a0
cmp.l a0,a1
scs d6
;----So copy the characters to the internal buffer----
PutTheSeperationChar:
moveq #0,d5
move.l a4,a0
subq.w #1,d4
tst.b d6
beq NoLoadFlashApp
;----In case a folder or flash app notation we first copy to a different
;----buffer.
lea currentFolderName(pc),a4
lea title(pc),a0 ;title of the menu
move.l a4,(a0)
moveq #0,d7
;----Now The Copy Loop, it promotes upper case to lower case and if
;----a folder is already entered it first copies the folder to it's
;----own buffer and then the name afterwards to its own buffer.
NoLoadFlashApp:
moveq #92,d1 ;'\'
moveq #46,d2 ;'.'
moveq #91,d3
moveq #0,d0
lea 95,a3 ;underscore
CLoop2:
move.b (a1)+,d0
tst.b d7
beq NoWorryAboutImpliedUnitMultiplication
cmp.w a3,d0
bne NoWorryAboutImpliedUnitMultiplication
;----if it is implied unit multiplication then we start over----
lea charBuffer(pc),a4
move.l a4,a0
moveq #0,d5
bra StoreIt
NoWorryAboutImpliedUnitMultiplication:
;----Now folder support--------
cmp.b d1,d0
bne NotEndOfFolder
clr.b (a4)
lea zeroTerminator(pc),a3
move.l a4,(a3)
lea folderWasCompleted(pc),a4
bra CarryOn
NotEndOfFolder:
;----Now flash app support--------
cmp.b d2,d0
bne NotEndOfAppNotation
clr.b (a4)
lea zeroTerminator(pc),a3
move.l a4,(a3)
lea flashAppIndic(pc),a4
CarryOn:
st.b (a4)
lea oneThingAllowed(pc),a0
st.b (a0)
lea charBuffer(pc),a4
move.l a4,a0
moveq #0,d5
bra TheDBRA
NotEndOfAppNotation:
cmp.b d3,d0
bcc.s NotUpper5
cmp.w #65,d0
bcs.s NotUpper5
add.b #32,d0 ;make it lower case
NotUpper5:
StoreIt:
move.b d0,(a4)+
addq.l #1,d5
cmp.w #9,d5 ;do not go over the boundaries
beq PassItOn
TheDBRA:
dbra d4,CLoop2
bra OnlyPlaceMarkers
;----Jump here if no preprocessing is to be done b/c the menu
;----is already visible. It will also jump here if a seperation
;----character was typed.
PutTheNewChar:
move.b d3,0(a0,d5)
addq.w #1,d5
OnlyPlaceMarkers:
cmp.w #9,d5
bcc RestoreTheScreenAndRestartBuffer
move.b #1,0(a0,d5)
clr.b 1(a0,d5)
move.w d5,(a5)
;----And flow back into complete.asm---