-
Notifications
You must be signed in to change notification settings - Fork 1
/
commands.asm
344 lines (292 loc) · 6.91 KB
/
commands.asm
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
;
; Slowdos Source Code
;
;
; $Id: commands.asm,v 1.2 2003/06/15 20:26:24 dom Exp $
; $Author: dom $
; $Date: 2003/06/15 20:26:24 $
;
; Main entry point for Slowdos
MODULE entry
INCLUDE "slowdos.def"
EXTERN syntax
EXTERN readbyte
EXTERN rout24
EXTERN mslog
EXTERN hook_rdopen
EXTERN hook_wropen
EXTERN hook_erase
EXTERN hook_mscat
EXTERN hook_catmem
EXTERN rdbyte
EXTERN rdblok
EXTERN wrblok
EXTERN wrbyte
EXTERN wrclos
EXTERN snpcnt
EXTERN movsdie
EXTERN dcheat ; Cheating bit in dodos
EXTERN dodos
EXTERN format
EXTERN erase
EXTERN load
EXTERN merge
EXTERN save
EXTERN verify
EXTERN poke
EXTERN cat
EXTERN copy
EXTERN move
PUBLIC rom3
PUBLIC errorn
PUBLIC synexe
PUBLIC runexe
PUBLIC r_hxfer
PUBLIC SFAIL0
PUBLIC SFAIL2
PUBLIC SFAIL2
org 49152
jp init ; This is address 49152
jp hkent ; This is address 49155
spstor: defw 0 ; VARIABLE
; Copy our structures over to the printer buffer area. We intercept
; the various error routines that pass between the ROMS
init: ld hl,errpat
ld de,23354
ld bc,24
ldir
ld a,201 ;ret
ld (dcheat),a ;Nobble the dodos return so we don't get an err
xor a
ld iy,334 ;??? vector
call dodos
ld a,216 ;ret c
ld (dcheat),a
ret
;
; Code that is copied down to the printer buffer area
;
errpat: di ;1
ex af,af' ;1
exx ;1
ld hl,23354 ;3
push hl ;1
ld a,23 ;2
ld bc,32765 ;3
out (c),a ;1
jp intro ;3
out (c),e ;1 - +17
exx ;1
ei ;1
SFAIL0: jp 9530
defm "SLOWDOS v2.5 (C) 15.06.2003 D.J.MORRIS"
intro: ld hl,23388
ld b,(hl)
ld (hl),a
ld a,b
ld (page),a
ld (spstor),sp
ld sp,(23402)
ld hl,flags
res 0,(hl)
ei
call scan
intro0: ld (23354+22),hl
intro1: di
xor a
ld (23390),a
ld a,0
ld bc,8189
out (c),a
ld (23399),a
set 4,a
ld bc,32765
ld (23388),a
ld e,a
ld sp,(spstor)
ld hl,flags
bit 0,(hl)
jr z,intro2
pop hl
intro2: jp 23354+17
;ROM 3 caller..
rom3: exx
ex af,af'
ld hl,routca
ld de,23420
ld bc,25
ldir
ld hl,flags
set 7,(hl)
pop hl
ld a,(hl)
inc hl
inc hl
ld (retadd+1),hl
dec hl
ld h,(hl)
ld l,a
ld (23420+6),hl
di
ld bc,32765
ld a,16
ld (23388),a
ld (dossp),sp
ld sp,(spstor)
jp 23420
routi1: ld sp,(dossp)
ld (23388),a
retadd: ld hl,0
push hl
ld hl,flags
res 7,(hl)
ex af,af'
exx
ei
ret
dossp: defw 23552 ; VARIABLE alternate stack pointer
routca: out (c),a
ex af,af'
exx
ei
call 0
routc1: di
exx
ex af,af'
ld a,23
ld bc,32765
out (c),a
jp routi1
;
; Entry point for hook codes
;
hkent: ld (hkent+1),sp ; save the current stack
push hl
exx
ld hl,flags3
set 5,(hl)
ld hl,hkext0
ex (sp),hl
ld a,h
ld (page),a
ld a,l
cp 15
jr nc,hkext
ld h,0
; pop hl
add hl,hl
ld de,hktabl
add hl,de
ld e,(hl)
inc hl
ld d,(hl)
push de
; ld hl,10072
exx
ret
hkext0: scf
hkext: ld hl,flags3
res 5,(hl)
res 7,(hl)
ld (iy+0),255
hkent1: ld sp,0
ret
hktabl: defw mslog
defw r_getpar
defw hook_rdopen
defw rdbyte
defw rdblok ;de=addr, bc=length
defw hook_wropen
defw wrbyte
defw wrblok
defw wrclos
defw hook_erase
defw snpcnt
defw hook_mscat
defw hook_catmem
defw movsdie ;de=start of text, bc=lengt
r_getpar: ld de,temphd
ret
r_hxfer: push ix
pop hl
ld de,ufia
push de
ld bc,22
ldir
pop ix
ret
errorn: pop hl
ld a,(hl)
ld (iy+0),a
jr scan1
scan: ld hl,flags
bit 7,(hl)
jr nz,scan0
ld a,(iy+0)
cp 11
jp z,write
cp 1
jp z,write
scan0: ld hl,flags
res 7,(hl)
set 0,(hl)
SFAIL1: ld hl,9530
ret
;Error return - also for non recognized command
;Check to see if executing system call
scan1: ld hl,flags3
and a
bit 5,(hl)
jp nz,hkext
call syntax
jr nz,scan12
ld hl,(23645)
ld (23647),hl
scan12: ld hl,flags
set 0,(hl)
SFAIL2: ld hl,9530
jp intro0
;Exit when running program
runexe: ld hl,4145
ret
;Syntax exit
synexe: ld hl,4280
;this pop needed to dump the return to runexe
pop bc
ret
;Main syntax loop
write: set 7,(iy+48)
bit 7,(iy+1)
jr nz,writ01
res 7,(iy+48)
writ01: ld hl,(23645)
write0: dec hl
call readbyte
cp 206
jr c,write0
ld (23645),hl
call rout24
ld hl,runexe
push hl
cp 207
jp z,cat
cp 208
jp z,format
cp 209
jp z,move
cp 210
jp z,erase
cp 213
jp z,merge
cp 214
jp z,verify
cp 239
jp z,load
cp 244
jp z,poke
cp 248
jp z,save
cp 255
jp z,copy
pop hl
jp scan1