-
Notifications
You must be signed in to change notification settings - Fork 1
/
msmove.asm
343 lines (295 loc) · 9.78 KB
/
msmove.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: msmove.asm,v 1.1 2003/06/15 20:26:26 dom Exp $
; $Author: dom $
; $Date: 2003/06/15 20:26:26 $
;
; Some supposedly simple commands
MODULE move
INCLUDE "slowdos.def"
INCLUDE "syntaxdefs.def"
INCLUDE "printing.def"
;; Errors that we
EXTERN errorn
EXTERN error_filetype
EXTERN error_notfound
;; Other things
EXTERN settapn
EXTERN settap
EXTERN clufia
EXTERN clfilen
EXTERN ckext
EXTERN ckwild
EXTERN ckwild_length
EXTERN rdopen
EXTERN rdbyte
EXTERN wropen
EXTERN wrclos
EXTERN discan
EXTERN mslog
PUBLIC move
PUBLIC movsdie
PUBLIC tapnam ; export the .TAP name
; Move command
;
; Supported syntax:
;
; MOVE Pdd"f" TO #ss - copy file f to stream ss
; MOVE TO Pdd"f" - change directory to f
; MOVE TO Tdd"f" [IN] - enter a .TAP file (reading)
; MOVE TO Tdd"f" OUT - create a .TAP file writing
; MOVE TO Tdd - exit the current .TAP file
move: call rout32
cp 204 ;TO - i.e. .TAP/Directory reading
jp z,tread
call getdrv1 ; Moving to subdirectory, get the drive
call cksemi ; We want a semi-colon
call exptex ; Now we expect a string
cp 204 ; TO - copying to streams
jp nz,error_nonsense ; No TO, Nonsense in BASIC
call rout32 ; Get next character
cp '#' ; Must be a #, otherwise its nonsense
jp nz,error_nonsense
call e32_1n ; Now we expect a number
call ckend ; And the end of the statement
; Execution of the routine proper
call getnum ; Get the stream number
ld a,b ; Odd stuff with streams > 255?
and a
jr nz,move1
set 7,c
move1: ld a,c ; Select the channel
ld (chanel),a
ld a,1
call settap ; Some weird flag nonse
call clufia ; Clear the filename within ufia, hl = ufia+2
call getstr ; Get the string and place it within ufia
ld ix,ufia ; Open the file
call rdopen
ld a,(chanel) ; Open the channel
call setchan
ld bc,(temphd+1) ; Pick up the file length
move2: call rdbyte ; Read a byte from the file
cp 13
jr z,move8 ; If LF then display it
cp 32 ; Otherwise if < 32 replace with ' '
jr nc,move8
ld a,32
move8: call print ; Print the character out
move3: dec bc ; And loop around
ld a,b
or c
jr nz,move2
ret ; All done
;Select a TAP file/directory...
tread: call rout32 ; Find out if it's a P or a T
and 223
cp 'P' ; It's a subdirectory
jp z,movsdi
cp 'T'
jp nz,error_nonsense ; Not a .TAP, so Nonsense in BASIC
; .TAP file handling
call getdrv2 ; Skip over the drive specifier
call ckenqu ; Check for statement end
jr nz,tread1 ; Not end, we must be entering .TAP file
call ckend ; Check for end/syntax
; Close the currently open .TAP file
tapend: ld hl,flags2 ; Reset .TAP indicator
res 6,(hl)
inc hl ; Skips to flags3
bit 1,(hl) ; Were we writing to .TAP file
ret z ; No we weren't
res 1,(hl) ; Reset writing indicator
call mslog ; Check the disc
jp wrclos ; And write out the file
; Entering a .TAP file
tread1: call cksemi ; We want a semicolon
call exptex ; And then some text
call rout24 ; No we need to check for IN/OUT
cp 223 ; OUT
jr nz,tread11
;Okay, trying to save into .TAP
call rout32
call syntax ; If we're in syntax mode then don't set flags
jr z,tread11
ld hl,flags3 ; Set writing .TAP if not in syntax mode
set 1,(hl)
tread11: cp 191 ; IN
jr nz,tread19
ld hl,flags3 ; If we're already writing then we can't have IN
bit 1,(hl)
jp nz,error_nonsense ; So Nonsense in BASIC
call rout32
tread19: call ckend ; IT really is the end
; We have some shared parameter reading
ld hl,flags2 ; Reset in .TAP file flag
res 6,(hl)
call clufia ; Clear ufia+2, exit hl = ufia+2
call getstr ; Get the string
jp nz,error_filename ; Returned a wild card, can't have that!
tread2: ld de,ufia+11 ; Check for .TAP suffix
ld hl,tapiden
call ckext
jp nz,error_filetype ; Not there, so bad filetype
; Now try to open the .TAP file on disc
ld ix,ufia
ld hl,flags3 ; Check for writing
bit 1,(hl)
jr nz,tread3 ; We're writing, don't want to read it
call rdopen
ld hl,ufia+2 ; Save the .TAP filename
ld de,tapnam
ld bc,8
ldir
ld hl,flags2 ; Indicate that we're in a .TAP file
set 6,(hl)
ret
; We want to write to a .TAP file
tread3: res 1,(hl) ; hl = flags3
push hl
dec hl
dec hl ; hl = flags
set 5,(hl) ; Indicate we want headerless file
call wropen ; open the file
pop hl
set 1,(hl) ; Indicate that we're writing to a .TAP file
ret
tapnam: defs 8,0 ;VARIABLE
tapiden: defm "TAP"
;Move into a subdirectory..
movsdi: call getdrv2 ; Pick up the drive
call ckenqu ; Check for end
jr nz,movsdi1 ; Not end, must be subdir attached
call ckend ; End of statement
; No name provided, move back to the root directory
movsdi0: ld hl,0 ; Set subdirectory cluster number to 0
ld (sdclus),hl
ld hl,flags3
res 3,(hl) ; Reset in subdir flag
dec hl ; hl=flags2
res 6,(hl) ; Reset in .TAP file flag
ret
; Moving into a subdirectory
movsdi1: call cksemi ; We want a semicolon/separator
call exptex ; Now we want a string
call ckend ; End of statement please
call clfilen ; Clear the filename, hl = filen
call rom3 ; Get address of string
defw getin1 ; Leaves de = address, bc = length
movsdie: ld a,c ; Length is 0, go back to the root dir
or b
jr z,movsdi0
ex de,hl ; hl =address
movsdi3: exx ; hl'=address, bc'=length
ld de,filen ; Get 8 characters into filen
ld b,8
movsdi2: push de
push bc
exx
call movgch ; Returns z = end or dir separator
exx
pop bc
pop de
ld (de),a
jr z,movsdi4 ;it's our bit
inc de
djnz movsdi2
movsdi4: cp '/' ; Last character was a '/'
jr nz,movsdi9 ; So replace it with a ' '
ld a,32
ld (de),a
movsdi9: ld a,b ; If its longer than 8 characters then its wrong
sub 8
ret z
ld hl,filen ; filen is where dirname is kept
ld b,8
call ckwild_length ; Check to see if its wild
ld hl,flags
bit 1,(hl)
jp nz,error_filename ; We don't like wildcard directories
exx
push hl ; Save the address and length of string
push bc
exx
call discan ; Scan the disc for the filename hl=dir entry
jp nc,error_notfound ; File doesn't exist
movsdi5: ld bc,11 ; Skip to the file type
add hl,bc
bit 4,(hl) ; Check for subdir flag
jp z,error_filetype ; Not set, so bad filename
ld c,15
add hl,bc ; Skip to cluster start
ld e,(hl) ; Pick up cluster
inc hl
ld d,(hl)
ld hl,flags3 ; If this is a subdir i.e. cluster != 0 then
res 3,(hl) ; we set subdir flag
ld a,d
or e
jr z,movsdi6
set 3,(hl)
movsdi6: ld (sdclus),de ; Save subdirectory cluster
exx ; And loop back for the next bit of the path
pop bc
pop hl
ld a,b
or c
ret z
jr movsdi3
;Get a character....
;Entry: hl= addy of string
; bc = number of characters needed
;Exit: hl = hl + 1
; bc = bc - 1
; a = character picked up
; z = end of current thing
movgch: call readbyte ; Get character from BASIC
inc hl ; Increment address
dec bc ; Decrement counter
ld e,a
cp '/' ; Check for directory separater
ret z
ld a,b ; Test bc = 0
or c
ld a,e ; Restore the character
ret
;READ # command -set +3 USER area
;uread: call rout32
; cp '#'
; jp nz,error_nonsense
;Change +3 user area
;uread0: call e32_1n
; call ckend
; call rom3
; dw fnint2
; ld a,b
; and a
; jr z,uread2
;uread1: call errorn
; db 45 ;bad parameters
;uread2: ld a,c
; cp 16
; jr nc,uread1
; ld iy,304
; jp dodos
;Fun cls routine
;cls: call rout32
; cp '#'
; jp nz,error_nonsense
; call rout32
; call ckend
; ld hl,56
; ld (23693),hl
; ld (23695),hl
; ld (iy+14),l
; ld (iy+87),h
; ld a,2
; call rom3
; dw 5633
; call rom3
; dw 3435
; ld a,7
; out (254),a
; ret