-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtap2mic.asm
More file actions
232 lines (225 loc) · 2.75 KB
/
tap2mic.asm
File metadata and controls
232 lines (225 loc) · 2.75 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
START equ 16384
org 8192
ld a,h ; 8192
or l ; 8193
jr nz,Lab8202 ; 8194
Lab8196
ld hl,Usage
BucPrintMsg
ld a,(hl)
or a
ret z
rst 10h
inc hl
jr BucPrintMsg
Lab8202
call zero
ld hl, buffer
ld a,42 ; 8216
ld b,1 ; 8218
rst 8 ; 8220
sbc a,d ; open file ; 8221
ret c ; 8222
ld (handle),a ; 8223
jr nc, loop
get_out: ; 8231
ld a,(handle) ; 8234
rst 8 ; 8237
sbc a,e ; close ; 8238
rst 0
;ret ; 8239
;Lab8240
; ld bc,(Lab8468) ; 8241
; ld de,(Lab8470) ; 8245
loop
ld hl,LabLength
ld bc,2
ld a,(handle)
rst 8
sbc a,l ; read
jr c, get_out
ld a,b
or c
cp 2
jr nz, get_out
ld hl,START
ld bc,(LabLength)
push bc
ld a,(handle)
rst 8
sbc a,l ; read
pop de
dec de
dec de
ld ix, START + 1
ld a, (START)
or a
call z, delay
call sa_bytes
jr nc, get_out
jr loop
delay ; around 1 second
ld b, 3
delay_inner
ld hl, 44872
delay_inner_2
dec hl
ld a,h
or l
jr nz,delay_inner_2
djnz delay_inner
xor a
ret
sa_bytes
ld hl, sa_ld_ret
push hl
ld hl, 0x1f80
bit 7,a
jr z, sa_flag
ld hl, 0xc98
sa_flag
ex af,af'
inc de
dec ix
di
ld a,2
ld b,a
sa_leader
djnz sa_leader
out (254),a
xor 0xf
ld b, 0xa4
dec l
jr nz, sa_leader
dec b
dec h
jp p, sa_leader
ld b,0x2f
sa_sync_1
djnz sa_sync_1
out (254),a
ld a, 0xd
ld b, 0x37
sa_sync_2
djnz sa_sync_2
out (254),a
ld bc, 0x3B0E
ex af, af'
ld l, a
jp sa_start
sa_loop
ld a, d
or e
jr z, sa_parity
ld l, (ix+0)
sa_loop_p
ld a,h
xor l
sa_start
ld h,a
ld a, 1
scf
jp sa_8_bits
sa_parity
ld l,h
jr sa_loop_p
sa_bit_2
ld a,c
bit 7,b
sa_bit_1
djnz sa_bit_1
jr nc, sa_out
ld b,0x42
sa_set
djnz sa_set
sa_out
out (254),a
ld b, 0x3e
jr nz, sa_bit_2
dec b
xor a
inc a
sa_8_bits
rl l
jp nz, sa_bit_1
dec de
inc ix
ld b,0x31
ld a,0x7f
in a,(254)
rra
ret nc
ld a,d
inc a
jp nz, sa_loop
ld b, 0x3b
sa_delay
djnz sa_delay
ret
sa_ld_ret
push af
ld a,(23624)
and 0x38
rrca
rrca
rrca
out (254),a
ld a, 0x7f
in a, (254)
rra
ei
jr c, sa_ld_end
report_d
rst 8
defb 0xc
sa_ld_end
pop af
ret
zero
ld b, 255
ld d, h
ld e, l
ld hl, buffer
zero_p
ld a,(de)
ld (hl), a
or a
ret z
cp 13
jr nz, colon
zeruj
xor a
ld (hl), a
ret
colon
cp ':'
jr z, zeruj
inc de
inc hl
djnz zero_p
ret
Usage
db " tap2mic file.tap",13,13
db "Plays a tape file to MIC",13
db "Similar to SAVE on a real Spectrum.",13
db "It restarts the machine at the end.",13,0
handle
defb 0; handle
Lab8461 nop ;drive
Lab8462 nop ;device
Lab8463 nop; attr
Lab8464 nop ; date
nop
nop
nop
Lab8468 ; size
nop
nop
nop
nop
LabLength nop
nop
Lab8472 nop
nop
buffer
nop