-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdetecttype.inc
384 lines (382 loc) · 6.63 KB
/
detecttype.inc
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
;-----------------------------------------------------------
; Filename: detecttype.inc
; Long name: Variable type detection
; Authors: Kerm Martian aka Christopher Mitchell
; Last Update: Unknown
;
; DetectType Routine
; Inputs:
; hl = VAT entry pointer
; Outputs:
; a = ProgFlag (a=$ff means invalid)
; ix = Program icon
;
;Please consult license.txt for the fair use agreement
;implicitly binding by you continuing to read past this
;point. Close and delete this file if you do not agree
;to the terms of the agreement.
;-----------------------------------------------------------
DetectType:
ld a,(hl)
cp $06
jr nz,DetectTypeNoLockSet
set 0,(iy+dcsProgFlags)
DetectTypeNoLockSet:
dec hl
#ifdef Folders
ld a,(hl)
ld (LastClick),a ;store folder of this program in LastClick
#endif
dec hl
dec hl
push hl ;save point to DAL
dec hl
dec hl
ld a,(hl) ;get page
ld (CurROMPage),a ;save the ROM Page (0=in RAM)
or a
jr z,DetectTypeNoArcSet
set 7,(iy+dcsProgFlags)
DetectTypeNoArcSet:
pop hl ;recall pointer to DAL
push hl ;save pointer to DAL again
dec hl
dec hl
dec hl
dec hl
ld a,(hl) ;first prog name byte
cp $23
jp z,VATInvalid
cp $21
jp z,VATInvalid
pop hl
push hl
#ifdef Folders
push af ;save possible '%' name char
#endif
ld a,(hl)
dec hl
ld h,(hl)
ld l,a
call SetUpROM
call GetArcProgByte ;ldhlind->de for ram or rom
ld e,a ;e...
inc hl
call GetArcProgByte
ld d,a ;...d = prog length
inc hl
call GetArcProgByte ;Get type
ld b,a
;-------------------------------------
#ifdef Folders
ld a,(CurFldr)
or a
jr z,DetectTypeIgnoreFlds ;if running from a hook or runprog, ignore this
push bc
ld b,a
ld a,(LastClick)
cp b
pop bc
jp nz,VATIgnorePop
DetectTypeIgnoreFlds:
#endif
;--------------------------------------
ld a,b
cp $AB
jp z,VATIgnorePop
#ifdef AnsHide
cp $72
jp z,VATIgnorePop
#endif
#ifdef Folders
pop af
cp '%'
jp z,VATValidFld
#endif
;---------------------------------------------
push hl
call GetArcProgByte
cp $BB
jp nz,VATValid6
inc hl
call GetArcProgByte
cp $6D
jp nz,VATValid6
inc hl
call GetArcProgByte
pop hl
VATValid2:
cp $C9 ;Ion Proprietary
jp nz,VATValid3
VATValid2b:
push hl
inc hl
inc hl
inc hl
call GetArcProgByte
pop hl
cp $30
jr nz,VATValidMOS
VATValidIon:
ld a,(iy+dcsProgFlags)
or %00100100
ld ix,PIconIon
jp DetectTypeFinish
VATValidMOS:
cp $31
jr z,VATValidDCSAP
ld de,IconSpace32b
push de
pop ix
ld bc,32-2
inc hl
inc hl
inc hl
inc hl
call ldirROMRAM ;fixed for ROM
ld hl,IconSpace32b+32-2
ld (hl),0
inc hl
ld (hl),0
ld a,(iy+dcsProgFlags)
or %00111110
jp DetectTypeFinish
VATValidDCSAP:
inc hl
inc hl
inc hl
inc hl
call GetArcProgByte
cp $80
jr nz,VATValidIon
inc hl
call GetArcProgByte
ld b,a
push bc
inc hl
call GetArcProgByte
pop bc
ld c,a
push bc
inc hl
call GetArcProgByte
ld d,a
pop bc
ld a,(CurROMPage)
push af
call DCSAPGetType ;should return name in Op1
jr z,VATValidAPUnknown
bcall(_chkfindsym)
ld a,b
ld (CurROMPage),a
ex de,hl
call SetUpROM
push hl
ld de,12
add hl,de
call GetArcProgWord
or a
ld de,$9d91
sbc hl,de
pop de
ex de,hl
add hl,de
ld de,32
add hl,de
ld de,IconSpace32b
push de
ld bc,32
call ldirROMRAM
pop ix
VATValidAPUnknown1:
pop af
ld (CurROMPage),a
ld a,(iy+dcsProgFlags)
or %00001010
jp DetectTypeFinish
VATValidAPUnknown:
ld ix,CrashIcon
jr VATValidAPUnknown1
VATValid3:
cp $AF
jp z,VATValid2b ;Ion non-p
VATValid4:
#ifdef AnsHide
cp $72
jr z,VatIgnore
#endif
cp $AB ;ignored prog
jr nz,VATValid5
jr VatIgnore
VATIgnorePop:
#ifdef Folders
pop af
#endif
VatIgnore:
; previously pop'ed de and dec'ed it 6 bytes
VATInvalid:
ld a,(ProgsToDo)
inc a
ld (ProgsToDo),a
ld a,(ScratchVar)
dec a
ld (ScratchVar),a
pop hl
ld a,$ff ;invalid mask
ret ;in VATProcessEntry, this will drop to VATValidSkip
VATValid5:
cp $aa ;=xor d (dcsASM)
jr nz,VATValid5b
push de
push hl
pop bc
ld de,8
add hl,de
push hl
call GetArcProgWord ;get dcs version intended
ld a,l ;stored BIG ENDIAN! High byte in l!
pop hl
pop de
cp 8
jr nc,VATIgnore
inc hl
inc hl
call GetArcProgWord ;start icon init
ld a,h
or l
jr z,VATValid5NoIcon
ld de,-$9D95+2
add hl,de
add hl,bc
ld de,IconSpace32b
push de
pop ix
ld bc,32
call ldirROMRAM ;fixed for ROM
jr VATValid5Icon
VATValid5NoIcon:
ld ix,PIconDCSasm
VATValid5Icon:
ld a,(iy+dcsProgFlags)
or %00101010
jp DetectTypeFinish
VATValid5b:
cp $AB
jr z,VATIgnore
#ifdef AnsHide
cp $72
jr z,VATIgnore
#endif
VATValid5NoSkip:
ld ix,PIconASMos
ld a,(iy+dcsProgFlags)
or %00001000
jp DetectTypeFinish
VATValid6:
pop hl
ex de,hl
VATValid6Loopback:
ld hl,dcsBASICtxt
ld b,4
VATValid6Loop:
call GetArcProgByteDE
cp (hl)
jr nz,VATValid7
inc hl
inc de
djnz VATValid6Loop
ex de,hl
call GetArcProgByte
inc hl
cp '6'
jr z,VATValid6HighRes
cp $3F
jr nz,VATValid7
;hl=16 byte icon code
call GetArcProgByte
cp $2a
call nz,DCS5BASICAutoUpgrade
inc hl
ld bc,8
ld de,IconSpace8b
call dcsSquish
ld hl,IconSpace8b
ld de,IconSpace32b
push de
call dcsEnlarge
pop ix
jr VATValid6Continue
VATValid6HighRes:
inc hl
call GetArcProgByte
cp $2a
call nz,DCS5BASICAutoUpgrade
inc hl
ld de,IconSpace32b
push de
ld bc,32
call dcsSquish
pop ix
VATValid6Continue:
ld a,(iy+dcsProgFlags)
or %00000010
jr DetectTypeFinish
#ifdef Folders
VATValidFld:
ld ix,FolderIcon
ld a,(iy+dcsProgFlags)
or %01001000
jr DetectTypeFinish
#endif
VATValid7:
ld a,(hl)
cp 'D'
jr nz,VATValid7_AxeSrcCheck ;check if it's an Axe source file
VATValid7Search:
inc de
call GetArcProgByteDE
cp $3f
jr nz,VATValid7Search
inc de
call GetArcProgByteDE
cp $3e
jr nz,VATValid71
inc de
call GetArcProgByteDE
cp 'D'
dec de
jp z,VATValid6Loopback
inc de
cp $2a
jr nz,VATValid71
inc de
ld hl,IconSpace32b
push hl
ex de,hl
ld bc,32
call dcsSquish
pop ix
jr VATValid72
VATValid71:
ld ix,PIconBASICos
VATValid72:
ld a,(iy+dcsProgFlags)
jr DetectTypeFinish
VATValid7_AxeSrcCheck:
call GetArcProgByteDE
cp $3A ;the '.' symbol in TI tokens
jr nz,VATValid71
inc de
call GetArcProgByteDE
cp '0'
jr c,VATValid7_IsAxeSrc
cp '9'+1
jr c,VATValid71
VATValid7_IsAxeSrc:
ld ix,PIconBASICaxesrc
jr VATValid72
DetectTypeFinishPopHL:
pop hl
DetectTypeFinish:
pop hl
ret