-
Notifications
You must be signed in to change notification settings - Fork 6
/
RAMDISK.ASM
243 lines (222 loc) · 3.67 KB
/
RAMDISK.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
10 ORG 100H
20 JP MAIN
30PUTSTR EQU 0BFF1H
40INKEY EQU 0BE53H
50PUTCHR EQU 0BE62H
60WAITK EQU 0BFCDH
70RPTCHR EQU 0BFEEH
80GPF EQU 0BFD0H
90LDPSTR EQU 0BD00H
100PSN: DB 0
110ADDR: DW 0
120RAMBUF: DEFS 128
130TEMP: DW 0
140BANK0 EQU 50H
150BANK1 EQU 60H
160BANK: DB BANK0 ; BY DEFAULT
170SRMON0: DB 'RAMON '
180SRMON1: DB 0,0,0,0,' ADDR '
190SADDR0: DB 0,0,0,0,0
200SRMOF0: DB 'RAMOFF '
210SRMOF1: DB 0,0,0,0,' BANK '
220SPSN0: DB 0,0,0,0,0
230SRMBF0: DB 'RAMBUF '
240STEMP0: DB 0,0,0,0,' TEMP '
250STEMP1: DB 0,0,0,0,0
260B2R00: DB 'BANK2R '
270B2R01: DB 0,0,0,0,' R2BANK '
280R2B00: DB 0,0,0,0,0
290DONE: DB '- THE END -',0
300MAIN: CALL CLS
310 LD HL,SRMON1
320 LD DE,RAMON
330 LD A,D
340 CALL BYTE
350 LD A,E
360 CALL BYTE
370 LD HL,SADDR0
380 LD DE,ADDR
390 LD A,D
400 CALL BYTE
410 LD A,E
420 CALL BYTE
430 LD HL,SRMON0
440 LD DE,0000H
450 CALL STRLN
460 CALL PUTSTR
470 LD HL,SRMOF1
480 LD DE,RAMOFF
490 LD A,D
500 CALL BYTE
510 LD A,E
520 CALL BYTE
530 LD HL,SPSN0
540 LD DE,BANK
550 LD A,D
560 CALL BYTE
570 LD A,E
580 CALL BYTE
590 LD HL,SRMOF0
600 LD DE,0100H
610 CALL STRLN
620 CALL PUTSTR
630 LD HL,STEMP0
640 LD DE,RAMBUF
650 LD A,D
660 CALL BYTE
670 LD A,E
680 CALL BYTE
690 LD HL,STEMP1
700 LD DE,TEMP
710 LD A,D
720 CALL BYTE
730 LD A,E
740 CALL BYTE
750 LD HL,SRMBF0
760 LD DE,0200H
770 CALL STRLN
780 CALL PUTSTR
790 LD HL,DONE
800 LD DE,0400H
810 CALL STRLN
820 CALL PUTSTR
830 LD HL,B2R01
840 LD DE,BANK2R
850 LD A,D
860 CALL BYTE
870 LD A,E
880 CALL BYTE
890 LD HL,R2B00
900 LD DE,R2BANK
910 LD A,D
920 CALL BYTE
930 LD A,E
940 CALL BYTE
950 LD HL,B2R00
960 LD DE,0300H
970 CALL STRLN
980 CALL PUTSTR
990 LD HL,DONE
1000 LD DE,0400H
1010 CALL STRLN
1020 CALL PUTSTR
1030 CALL WAITK
1040 RET
5000CLS: LD B,144
5010 LD DE,0
5020CLS0: LD A,32
5030 CALL RPTCHR
5040 RET
5050CLLN: LD B,24
5060 LD E,0
5070 JP CLS0
5080BYTE: PUSH AF
5090 AND 0F0H
5100 RRCA
5110 RRCA
5120 RRCA
5130 RRCA
5140 CALL NIBBLE
5150 INC HL
5160 POP AF
5170 AND 15
5180 CALL NIBBLE
5190 INC HL
5200 RET
5210NIBBLE: SUB 10
5220 JP M,ZERO9
5230 ADD A,7
5240ZERO9: ADD A,58
5250 LD (HL),A
5260 RET
5270STRLN: LD B,0
5280 PUSH HL ;preserve HL
5290STRLN0: LD A,(HL)
5300 CP 0
5310 JP Z,STRLN1
5320 INC HL
5330 INC B
5340 JP STRLN0
5350STRLN1: POP HL ;restore HL
5360 RET
5370PUTBNR: CALL STRLN
5380 LD A,24
5390 SUB B
5400 RRCA
5410 LD E,A
5420 CALL PUTSTR
5430 RET
5440MX2KEY: LD B,0
5450 LD C,A ;A IS KEY INDEX
5460 LD HL,MATRIX
5470 ADD HL,BC
5480 LD A,(HL)
5490 RET
5500HEX2N: LD A,(HL)
5510 CALL HEX1
5520 ADD A,A
5530 ADD A,A
5540 ADD A,A
5550 ADD A,A
5560 LD B,A
5570 INC HL
5580 LD A,(HL)
5590 CALL HEX1
5600 OR B
5610 RET
5620HEX1: SUB '0'
5630 CP 10
5640 RET C
5650 SUB 7 ;'A'-'0'-10
5660 RET
5670MATRIX: DB 0,0FFH
5680 DB 'QWERTYUASDFGHJKZXCVBNM,'
5690 DB 0FFH,0FFH,0FFH,0FFH,9,32,10,11,14,15 ;LEFT RIGHT UP DOWN
5700 DB 0FFH,'0.=+',13,'L;',0FFH,'123-'
5710 DB 0FFH,'IO',0FFH,'456*',0FFH,'P',8,0FFH,'789/)'
5720 DB 0FFH,0FFH,0FFH,0FFH,'(',0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
5730 DB 0,12,0FFH
5740RAMON: DI
5750 IN A,(17H)
5760 LD (V19A),A
5770 LD A,0
5780 OUT (17H),A ;disable periph. interrupts
5790 IN A,(19H)
5800 LD (V19B),A
5810 LD A,(BANK)
5820 LD B,A
5830 LD A,(V19B)
5840 OR B
5850 OUT (19H),A ;enable ext. ram to 0x8000-0xC0000
5860 RET
5870RAMOFF: LD A,(V19B)
5880 OUT (19H),A
5890 LD A,(V19A)
5900 OUT (17H),A ;re-enable ROM
5910 EI
5920 RET
5930V19A: DB 0
5940V19B: DB 0
5950BANK2R: LD HL,(ADDR)
5960 LD DE,RAMBUF
5970 LD B,24
5980 CALL RAMON
5990LOOP00: LD A,(HL)
6000 LD (DE),A
6010 INC HL
6020 INC DE
6030 DJNZ LOOP00
6040 CALL RAMOFF
6050 RET
6060R2BANK: LD HL,RAMBUF
6070 LD DE,(ADDR)
6080 LD B,24
6090 CALL RAMON
6100LOOP01: LD A,(HL)
6110 LD (DE),A
6120 INC HL
6130 INC DE
6140 DJNZ LOOP01
6150 CALL RAMOFF
6160 RET