-
Notifications
You must be signed in to change notification settings - Fork 1
/
CASH_V2.asm
394 lines (386 loc) · 4.99 KB
/
CASH_V2.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
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
385
386
387
388
389
390
391
392
393
394
ORG #8000
;FONT "153"
DI
XOR A
OUT (#FE),A
LD HL,#4000
LD DE,#4001
LD BC,#1AFF
LD (HL),A
LDIR
CALL PRI64
DEFB #16,0,0,#FF,5
DEFB "Cash-RAM verify utility ver2.0 "
DEFB "(C) Written by (R)soft 1996-98",#0D
DEFB "Support 2,4,8,16Kb CASH MEMORY!",#0D
DEFB #FF,3,"Select Cash-RAM by IN A,(#FB) & "
DEFB "ROM by IN A,(#7B).",#0D,#0D
DEFB #FF,5,"Warning! This program destroyed "
DEFB "information in Cash-RAM.",13
DEFB "Save info to disk and continue.",#0D
DEFB #FF,6,"Save CASH? (Y/N) ",0
CILK
LD A,#DF
IN A,(#FE)
BIT 4,A
JR Z,SAVEINF
LD A,#7F
IN A,(#FE)
BIT 3,A
JR Z,NOSAVE
JR CILK
SAVEINF
IN A,(#FB)
LD HL,0
LD DE,#C000
LD BC,#4000
LDIR
IN A,(#7B)
CALL PRI64
DEFB "Yes.",#0D,"Save info.",#0D,0
LD HL,NAME
LD DE,23773
LD BC,9
LDIR
LD C,#0B
LD HL,#C000
LD DE,#4000
CALL #3D13
DI
JR CONTIO
NOSAVE
CALL PRI64
DEFB "No.",#0D,0
CONTIO
;-----------------------
CALL PRI64
DEFB #0D,#FF,7,"Cash-RAM: ",0
CALL TST_CASH
LD A,H
AND A
JP Z,NOCASH
;----- HL = ŠŽ‹-‚Ž ’…‘’. €‰’ -------
LD (LENCASH),HL
CALL PRI64
DEFB #FF,7
DEFB "Detected ",0
LD A,(LENCASH+1)
LD HL,TXT2
CP 7
JR Z,PRIKIL
LD HL,TXT4
CP #0F
JR Z,PRIKIL
LD HL,TXT8
CP #1F
JR Z,PRIKIL
LD HL,TXT16
PRIKIL
LD DE,FOKIL
LDI
LDI
CALL PRI64
FOKIL DEFB " Kb memory. Wait!",#0D
DEFB #FF,3,"Pass:",0
XOR A
CICL
PUSH AF
PUSH AF
PUSH AF
CALL PRI64
DEFB #16,9,5,0
POP AF
CALL PRIHB
POP AF
ADD A,A
LD HL,TABLES
LD D,0
LD E,A
ADD HL,DE
LD A,(HL)
INC HL
LD H,(HL)
LD L,A
CALL TEST
JP C,ERRORC
POP AF
CP #1F
JR Z,OK
INC A
JR CICL
OK
CALL PRI64
DEFB #0D,#FF,7,"OK.",#0D,0
ENDTEST
CALL PRI64
DEFB #0D,"End test.",#0D,0
IN A,(#7B)
EI
RST 8
DEFB #FF
RET
TST_CASH
IN A,(#FB) ;!!!
LD HL,0
LD DE,1
LD BC,#3FFF
LD (HL),L
LDIR
LD HL,#00FF
LD B,#40
ML1
LD (HL),H
INC H
DJNZ ML1
LD H,0 ;!!! 0
LD A,(55)
AND A
RET NZ ;HL=0 - No Cash
LD E,#3F
LD HL,#07FF
LD A,(HL)
CP E
RET Z ;HL=07FF
LD H,#0F
LD A,(HL)
CP E
RET Z ;HL=0FFF
LD H,#1F
LD A,(HL)
CP E
RET Z ;HL=1FFF
LD H,#3F
RET ;HL=3FFF
TXT2 DEFB " 2"
TXT4 DEFB " 4"
TXT8 DEFB " 8"
TXT16 DEFB "16"
NAME DEFB "CASHINFOC"
ERRORC
LD B,(HL)
LD (B1ERR),A
LD A,B
LD (B2ERR),A
LD (FOER),HL
IN A,(#7B)
POP AF
CALL PRI64
DEFB #0D,"Error at Address:#",0
LD HL,0
FOER EQU $-2
CALL PRIHEX
CALL PRI64
DEFB " Have:#",0
LD A,0
B2ERR EQU $-1
CALL PRIHB
CALL PRI64
DEFB " -- Have been:#",0
LD A,0
B1ERR EQU $-1
CALL PRIHB
CALL PRI64
DEFB ".",#0D,0
JP ENDTEST
NOCASH
CALL PRI64
DEFB #FF,6
DEFB "Not detected.",#0D,0
JP ENDTEST
TABLES DEFW #1111,#3333,#7777,#FFFF
DEFW #5555,#AAAA,#55AA,#AA55
DEFW #0F0F,#F0F0,#FF00,#00FF
DEFW #1234,#5678,#9ABC,#DEF0
DEFW #3838,#2677,#A5A5,#5A5A
DEFW #AFAF,#F5F5,#FF55,#AAFF
DEFW #5F5F,#FA50,#0FA5,#FAAF
DEFW #EEEE,#CCCC,#8888,#0000
TEST
LD BC,0
LENCASH EQU $-2
DEC BC
LD A,H
LD DE,0
LD (DE),A
LD (TST1),A
INC DE
LD A,L
LD (DE),A
LD (TST2),A
INC DE
LD HL,0
PUSH HL
PUSH BC
LDIR
POP BC
POP HL
TEST2
LD A,0
TST1 EQU $-1
CPI
JR NZ,ERRO
LD A,0
TST2 EQU $-1
CPI
JR NZ,ERRO
LD A,C
OR B
JP NZ,TEST2
AND A
RET
ERRO
DEC HL
SCF
RET
;----------------------
PRIHEX LD A,H
PUSH HL
CALL PRIHB
POP HL
LD A,L
PRIHB PUSH AF
RRCA
RRCA
RRCA
RRCA
CALL PRITET
POP AF
PRITET AND #0F
ADD A,#90
DAA
ADC A,#40
DAA
JP PRIA
PRI64 POP HL
CALL LL73EF
JP (HL)
LL73EF LD A,(HL)
INC HL
OR A
RET Z
CP #16
JR Z,LL7409
CP #FF
JR Z,LL7402
EXX
CALL LL7425
EXX
JR LL73EF
LL7402 LD A,(HL)
INC HL
LD (LL7440),A
JR LL73EF
LL7409 LD D,(HL)
INC HL
LD E,(HL)
INC HL
PUSH HL
LD (LL6012),DE
CALL SODA2
POP HL
JR LL73EF
LLSPACE LD A," "
LL7425 CP #0D
JR Z,LL746A
PRIA
LD (LL7454),A
LD A,(LL6012)
LD B,A
SRL A
LD C,A
LD HL,0
LL743A EQU $-2
LD A,L
ADD A,C
LD L,A
LD (HL),7
LL7440 EQU $-1
LD DE,0
LL7442 EQU $-2
LD A,E
ADD A,C
LD E,A
LD A,B
RRA
SBC A,A
XOR #F0
LD (LL745A),A
CPL
LD (LL745E),A
LD HL,FONT
LL7454 EQU $-2
LD B,8
LL7458 LD A,(HL)
AND 0
LL745A EQU $-1
LD C,A
LD A,(DE)
AND 0
LL745E EQU $-1
OR C
LD (DE),A
INC H
INC D
DJNZ LL7458
LD HL,LL6012
INC (HL)
LD A,(HL)
CP 64
JR NC,LL746A
RET
LL746A
LD HL,LL6012
LD (HL),0
INC HL
LD A,(HL)
INC A
CP 24
JR NC,SDVIG
LD (HL),A
JR SD2
SDVIG
LD A,23
LD (HL),A
LD B,0
CALL #DFE
SD2
LD DE,(LL6012)
SODA2
LD E,0
CALL LL6D3D ;ADR SCR
LD (LL7442),HL
CALL LL6D4C ;ADR ATR
LD (LL743A),HL
RET
LL6D3D LD A,D
AND #18
ADD A,#40
LD H,A
LD A,D
AND 7
RRCA
RRCA
RRCA
ADD A,E
LD L,A
RET
LL6D4C LD H,0
LD L,D
ADD HL,HL
ADD HL,HL
ADD HL,HL
ADD HL,HL
ADD HL,HL
LD A,L
ADD A,E
LD L,A
LD A,#58
ADD A,H
LD H,A
RET
LL6012 DEFW 0
EOF
ORG #8500
FONT
INCBIN "153"
ORG #8000