]>
Commit | Line | Data |
---|---|---|
1 | SECTION "wee",HOME[$0] | |
2 | ld hl, $D000 | |
3 | ld sp, hl | |
4 | ||
5 | xor a | |
6 | ld [$FF60], a | |
7 | ld [$FF61], a | |
8 | ld [$FF62], a | |
9 | ||
10 | ld a, $50 ; Clear SR | |
11 | ld [$FF65], a | |
12 | ||
13 | call unlock+$D800 | |
14 | xor a | |
15 | ld d, a | |
16 | ld e, a | |
17 | call erase+$D800 | |
18 | ||
19 | xor a | |
20 | ld d, a | |
21 | ld e, a | |
22 | ||
23 | loop: ld a, $04 | |
24 | cp d | |
25 | jr z,done | |
26 | ||
27 | xor a | |
28 | ld c, a ; Count | |
29 | ||
30 | ifl: call program+$D800 | |
31 | xor a | |
32 | cp c | |
33 | jr nz, ifl | |
34 | ifldone: | |
35 | ||
36 | ld a, $70 | |
37 | ld [$FF65], a | |
38 | ld a, [$FF65] ; Load from the status register | |
39 | call puthex+$D800 | |
40 | ||
41 | ; ld a, $2E ;. | |
42 | ; call putc+$D800 | |
43 | ||
44 | inc de | |
45 | jr loop | |
46 | done: | |
47 | rst $00 | |
48 | ||
49 | putc: | |
50 | push af | |
51 | .wport: | |
52 | ld a,[$FF53] | |
53 | and $01 | |
54 | jr nz,.wport | |
55 | pop af | |
56 | ld [$FF52],a | |
57 | ret | |
58 | ||
59 | puthex: | |
60 | push hl | |
61 | ld hl, hexdig+$D800 | |
62 | push hl | |
63 | push af | |
64 | swap a | |
65 | and $0F | |
66 | add l | |
67 | ld l, a | |
68 | ld a, [hl] | |
69 | call putc+$D800 | |
70 | pop af | |
71 | and $0F | |
72 | pop hl | |
73 | add l | |
74 | ld l, a | |
75 | ld a, [hl] | |
76 | pop hl | |
77 | jr putc | |
78 | ||
79 | hexdig: | |
80 | db "0123456789ABCDEF" | |
81 | ||
82 | unlock: | |
83 | ld a, $55 | |
84 | call putc+$D800 | |
85 | ld a, $60 ; Unlock the device | |
86 | ld [$FF65], a | |
87 | ld a, $D0 | |
88 | ld [$FF65], a | |
89 | call waitrdy+$D800 | |
90 | ld a, [$FF65] | |
91 | call puthex+$D800 | |
92 | ret | |
93 | ||
94 | erase: | |
95 | ld a, $45 | |
96 | call putc+$D800 | |
97 | ld a, d | |
98 | ld [$FF60], a | |
99 | ld a, e | |
100 | ld [$FF61], a | |
101 | xor a | |
102 | ld [$FF62], a | |
103 | ld a, $20 ; Unlock the device | |
104 | ld [$FF65], a | |
105 | ld a, $D0 | |
106 | ld [$FF65], a | |
107 | call waitrdy+$D800 | |
108 | ld a, [$FF65] | |
109 | call puthex+$D800 | |
110 | ret | |
111 | ||
112 | ; need to save d, e, and c | |
113 | program: | |
114 | ld a, d | |
115 | ld [$FF60], a | |
116 | ld a, e | |
117 | ld [$FF61], a | |
118 | ld a, c | |
119 | ld [$FF62], a | |
120 | ld a, $40 | |
121 | ld [$FF65], a | |
122 | ld a, d | |
123 | ld [$FF60], a | |
124 | ld a, e | |
125 | ld [$FF61], a | |
126 | ld a, c | |
127 | ld [$FF62], a | |
128 | ld a, [$FF63] | |
129 | ld b, a | |
130 | ld a, d | |
131 | ld [$FF60], a | |
132 | ld a, e | |
133 | ld [$FF61], a | |
134 | ld a, c | |
135 | ld [$FF62], a | |
136 | ld a, b | |
137 | ld [$FF65], a | |
138 | call waitrdy+$D800 | |
139 | inc c | |
140 | ret | |
141 | ||
142 | waitrdy: | |
143 | ld a, $70 ; Wait status register. | |
144 | ld [$FF65], a | |
145 | .wrl: ld a, [$FF65] ; Wait for bit 7 to come back on again. | |
146 | bit 7,a | |
147 | jr z, .wrl | |
148 | ret | |
149 | ||
150 | section "a", HOME[$FF] | |
151 | nop |