]>
Commit | Line | Data |
---|---|---|
1 | ; CP/M BIOS for avrcpm | |
2 | ; Copyright (C) 2010 Sprite_tm | |
3 | ; | |
4 | ; This program is free software: you can redistribute it and/or modify | |
5 | ; it under the terms of the GNU General Public License as published by | |
6 | ; the Free Software Foundation, either version 3 of the License, or | |
7 | ; (at your option) any later version. | |
8 | ; | |
9 | ; This program is distributed in the hope that it will be useful, | |
10 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | ; GNU General Public License for more details. | |
13 | ; | |
14 | ; You should have received a copy of the GNU General Public License | |
15 | ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | ||
17 | msize: equ 62 ;size of available RAM in k | |
18 | ||
19 | bias: equ (msize-20) * 1024 | |
20 | ccp: equ $3400+bias ;base of cpm ccp | |
21 | bdos: equ ccp+$806 ;base of bdos | |
22 | bios: equ ccp+$1600 ;base of bios | |
23 | cdisk: equ $0004 ;current disk number (0 ... 15) | |
24 | iobyte: equ $0003 ;intel iobyte | |
25 | buff: equ $0080 ;default buffer address | |
26 | retry: equ 3 ;max retries on disk i/o before error | |
27 | ||
28 | cr: equ 13 | |
29 | lf: equ 10 | |
30 | ||
31 | READ_FUNC: equ 7 | |
32 | WRITE_FUNC: equ 6 | |
33 | BOOT_FUNC: equ 5 | |
34 | HOME_FUNC: equ 4 | |
35 | ||
36 | org bios | |
37 | nsects: equ ($-ccp)/128 ;warm start sector count | |
38 | ||
39 | jp boot | |
40 | wboote: | |
41 | jp wboot | |
42 | jp const | |
43 | jp conin | |
44 | jp conout | |
45 | jp list | |
46 | jp punch | |
47 | jp reader | |
48 | jp home | |
49 | jp seldsk | |
50 | jp settrk | |
51 | jp setsec | |
52 | jp setdma | |
53 | jp read | |
54 | jp write | |
55 | jp listst | |
56 | jp sectran | |
57 | ||
58 | signon: | |
59 | db cr,lf | |
60 | db msize/10+'0' | |
61 | db msize - (msize/10)*10 + '0' ;modulo doesn't work? | |
62 | db "k cp/m vers 2.2" | |
63 | db cr,lf,0 | |
64 | ||
65 | boot: | |
66 | ld sp,buff | |
67 | ld hl,signon | |
68 | call prmsg | |
69 | xor a | |
70 | ld (iobyte),a | |
71 | ld (cdisk),a | |
72 | jp gocpm | |
73 | ||
74 | wboot: ;re-load CP/M | |
75 | ld sp,buff | |
76 | ld a,1<<BOOT_FUNC | |
77 | out (22),a | |
78 | ld c,0 | |
79 | call seldsk | |
80 | call home | |
81 | ld b,nsects | |
82 | ld c,0 ;track | |
83 | ld d,1 ;sektor (0 based) | |
84 | ld hl,ccp | |
85 | load1: | |
86 | push bc | |
87 | push de | |
88 | push hl | |
89 | ld c,d | |
90 | ld b,0 | |
91 | call setsec | |
92 | pop bc | |
93 | push bc | |
94 | call setdma | |
95 | call read | |
96 | cp 0 ;read error? | |
97 | jp nz,wboot | |
98 | ||
99 | pop hl | |
100 | ld de,128 | |
101 | add hl,de | |
102 | pop de | |
103 | pop bc | |
104 | dec b | |
105 | jp z,gocpm | |
106 | ||
107 | inc d | |
108 | ld a,d | |
109 | cp 26 ;if sector >= 26 then change tracks | |
110 | jp c,load1 | |
111 | ||
112 | ld d,0 | |
113 | inc c | |
114 | push bc | |
115 | push de | |
116 | push hl | |
117 | ld b,0 | |
118 | call settrk | |
119 | pop hl | |
120 | pop de | |
121 | pop bc | |
122 | jp load1 | |
123 | ||
124 | gocpm: | |
125 | ld a,0c3h | |
126 | ld (0),a | |
127 | ld hl,wboote | |
128 | ld (1),hl | |
129 | ld (5),a | |
130 | ld hl,bdos | |
131 | ld (6),hl | |
132 | ||
133 | ld bc,buff | |
134 | call setdma | |
135 | ld a,(cdisk) | |
136 | ld c,a | |
137 | jp ccp | |
138 | ||
139 | const: | |
140 | in a,(0) | |
141 | ret | |
142 | ||
143 | conin: | |
144 | in a,(0) | |
145 | cp $ff | |
146 | jp nz,conin | |
147 | ||
148 | in a,(1) | |
149 | ret | |
150 | ||
151 | conout: | |
152 | ld a,c | |
153 | out (2),a | |
154 | ret | |
155 | ||
156 | list: | |
157 | ret | |
158 | ||
159 | listst: | |
160 | ld a,0 | |
161 | ret | |
162 | ||
163 | punch: | |
164 | ret | |
165 | ||
166 | reader: | |
167 | ld a,$1F | |
168 | ret | |
169 | ||
170 | seldsk: | |
171 | ld hl,0 ;error return code | |
172 | ld a,c | |
173 | out (15),a | |
174 | cp 0 ;only one disk supportet | |
175 | jp nz,seldsk_na | |
176 | ld hl,dph ;return disk parameter header address | |
177 | seldsk_na: | |
178 | ret | |
179 | ||
180 | home: | |
181 | ld a,1<<HOME_FUNC | |
182 | out (22),a | |
183 | ||
184 | ld bc,0 ; same as seek to track 0 | |
185 | settrk: | |
186 | ld a,c | |
187 | out (16),a | |
188 | ld a,b | |
189 | out (17),a | |
190 | ret | |
191 | ||
192 | setsec: | |
193 | ld a,c | |
194 | out (18),a | |
195 | ret | |
196 | ||
197 | setdma: | |
198 | ld a,c | |
199 | out (20),a | |
200 | ld a,b | |
201 | out (21),a | |
202 | ret | |
203 | ||
204 | read: | |
205 | ld a,1<<READ_FUNC | |
206 | out (22),a | |
207 | ld a,0 | |
208 | ret | |
209 | ||
210 | write: | |
211 | ld a,1<<WRITE_FUNC | |
212 | or c ;merge write type in c | |
213 | out (22),a | |
214 | ld a,0 | |
215 | ret | |
216 | ||
217 | sectran: | |
218 | ;translate sector bc using table at de, res into hl | |
219 | ld h,b | |
220 | ld l,c | |
221 | ld a,d | |
222 | or e | |
223 | ret z | |
224 | ex de,hl | |
225 | add hl,bc | |
226 | ld l,(hl) | |
227 | ld h,0 | |
228 | ret | |
229 | ||
230 | prmsg: | |
231 | ld a,(hl) | |
232 | or a | |
233 | ret z | |
234 | push hl | |
235 | ld c,a | |
236 | call conout | |
237 | pop hl | |
238 | inc hl | |
239 | jp prmsg | |
240 | ||
241 | ||
242 | ;Disk Parameter Header | |
243 | dph: | |
244 | dw 0 ;XLT: No sector translation table | |
245 | dw 0 ;000: Scratchpad | |
246 | dw 0 ;000: Scratchpad | |
247 | dw 0 ;000: Scratchpad | |
248 | dw dirbuf ;DIRBUF: Address of a dirbuff scratchpad | |
249 | dw dpb ;DPB: Address of a disk parameter block | |
250 | dw chk ;CSV: Address of scratchpad area for changed disks | |
251 | dw all ;ALV: Address of an allocation info sratchpad | |
252 | ||
253 | dpb: | |
254 | dw 26 ;SPT: sectors per track | |
255 | db 3 ;BSH: data allocation block shift factor | |
256 | db 7 ;BLM: Data Allocation Mask | |
257 | db 0 ;Extent mask | |
258 | dw 242 ;DSM: Disk storage capacity | |
259 | dw 63 ;DRM, no of directory entries | |
260 | db 192 ;AL0 | |
261 | db 0 ;AL1 | |
262 | dw 16 ;CKS, size of dir check vector | |
263 | dw 2 ;OFF, no of reserved tracks | |
264 | ||
265 | ||
266 | dirbuf: | |
267 | ds 128 | |
268 | ||
269 | chk: | |
270 | ds 16 | |
271 | ||
272 | all: | |
273 | ds 31 | |
274 | end | |
275 |