]>
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 | org bios | |
32 | nsects: equ ($-ccp)/128 ;warm start sector count | |
33 | ||
34 | jp boot | |
35 | wboote: | |
36 | jp wboot | |
37 | jp const | |
38 | jp conin | |
39 | jp conout | |
40 | jp list | |
41 | jp punch | |
42 | jp reader | |
43 | jp home | |
44 | jp seldsk | |
45 | jp settrk | |
46 | jp setsec | |
47 | jp setdma | |
48 | jp read | |
49 | jp write | |
50 | jp listst | |
51 | jp sectran | |
52 | ||
53 | signon: | |
54 | db cr,lf | |
55 | db msize/10+'0' | |
56 | db msize - (msize/10)*10 + '0' ;modulo doesn't work? | |
57 | db "k cp/m vers 2.2" | |
58 | db cr,lf,0 | |
59 | ||
60 | boot: | |
61 | ld sp,buff | |
62 | ld hl,signon | |
63 | call prmsg | |
64 | xor a | |
65 | ld (iobyte),a | |
66 | ld (cdisk),a | |
67 | jp gocpm | |
68 | ||
69 | wboot: ;re-load CP/M | |
70 | ld sp,buff | |
71 | ld c,0 | |
72 | call seldsk | |
73 | call home | |
74 | ld b,nsects | |
75 | ld c,0 ;track | |
76 | ld d,1 ;sektor (0 based) | |
77 | ld hl,ccp | |
78 | load1: | |
79 | push bc | |
80 | push de | |
81 | push hl | |
82 | ld c,d | |
83 | call setsec | |
84 | pop bc | |
85 | push bc | |
86 | call setdma | |
87 | call read | |
88 | cp 0 ;read error? | |
89 | jp nz,wboot | |
90 | ||
91 | pop hl | |
92 | ld de,128 | |
93 | add hl,de | |
94 | pop de | |
95 | pop bc | |
96 | dec b | |
97 | jp z,gocpm | |
98 | ||
99 | inc d | |
100 | ld a,d | |
101 | cp 26 ;if sector >= 26 then change tracks | |
102 | jp c,load1 | |
103 | ||
104 | ld d,0 | |
105 | inc c | |
106 | push bc | |
107 | push de | |
108 | push hl | |
109 | call settrk | |
110 | pop hl | |
111 | pop de | |
112 | pop bc | |
113 | jp load1 | |
114 | ||
115 | gocpm: | |
116 | ld a,0c3h | |
117 | ld (0),a | |
118 | ld hl,wboote | |
119 | ld (1),hl | |
120 | ld (5),a | |
121 | ld hl,bdos | |
122 | ld (6),hl | |
123 | ||
124 | ld bc,buff | |
125 | call setdma | |
126 | ld a,(cdisk) | |
127 | ld c,a | |
128 | jp ccp | |
129 | ||
130 | const: | |
131 | in a,(0) | |
132 | ret | |
133 | ||
134 | conin: | |
135 | in a,(0) | |
136 | cp $ff | |
137 | jp nz,conin | |
138 | ||
139 | in a,(1) | |
140 | ret | |
141 | ||
142 | conout: | |
143 | ld a,c | |
144 | out (2),a | |
145 | ret | |
146 | ||
147 | list: | |
148 | ret | |
149 | ||
150 | listst: | |
151 | ld a,0 | |
152 | ret | |
153 | ||
154 | punch: | |
155 | ret | |
156 | ||
157 | reader: | |
158 | ld a,$1F | |
159 | ret | |
160 | ||
161 | home: | |
162 | push af | |
163 | ld a,0 | |
164 | out (16),a | |
165 | pop af | |
166 | ret | |
167 | ||
168 | seldsk: | |
169 | push af | |
170 | ld a,c | |
171 | cp 0 | |
172 | jp nz,seldsk_na | |
173 | ld hl,dph | |
174 | pop af | |
175 | ret | |
176 | seldsk_na: | |
177 | ld hl,0 | |
178 | pop af | |
179 | ret | |
180 | ||
181 | settrk: | |
182 | push af | |
183 | ld a,c | |
184 | out (16),a | |
185 | pop af | |
186 | ret | |
187 | ||
188 | setsec: | |
189 | push af | |
190 | ld a,c | |
191 | out (18),a | |
192 | pop af | |
193 | ret | |
194 | ||
195 | setdma: | |
196 | push af | |
197 | ld a,c | |
198 | out (20),a | |
199 | ld a,b | |
200 | out (21),a | |
201 | pop af | |
202 | ret | |
203 | ||
204 | read: | |
205 | ld a,1 | |
206 | out (22),a | |
207 | ld a,0 | |
208 | ret | |
209 | ||
210 | write: | |
211 | ld a,2 | |
212 | out (22),a | |
213 | ld a,0 | |
214 | ret | |
215 | ||
216 | sectran: | |
217 | ;translate sector bc using table at de, res into hl | |
218 | ;not implemented :) | |
219 | ld h,b | |
220 | ld l,c | |
221 | ret | |
222 | ||
223 | prmsg: | |
224 | ld a,(hl) | |
225 | or a | |
226 | ret z | |
227 | push hl | |
228 | ld c,a | |
229 | call conout | |
230 | pop hl | |
231 | inc hl | |
232 | jp prmsg | |
233 | ||
234 | ||
235 | ;Disk Parameter Header | |
236 | dph: | |
237 | dw trans ;XLT: Address of translation table | |
238 | dw 0 ;000: Scratchpad | |
239 | dw 0 ;000: Scratchpad | |
240 | dw 0 ;000: Scratchpad | |
241 | dw dirbuf ;DIRBUF: Address of a dirbuff scratchpad | |
242 | dw dpb ;DPB: Address of a disk parameter block | |
243 | dw chk ;CSV: Address of scratchpad area for changed disks | |
244 | dw all ;ALV: Address of an allocation info sratchpad | |
245 | ||
246 | dpb: | |
247 | dw 26 ;SPT: sectors per track | |
248 | db 3 ;BSH: data allocation block shift factor | |
249 | db 7 ;BLM: Data Allocation Mask | |
250 | db 0 ;Extent mask | |
251 | dw 242 ;DSM: Disk storage capacity | |
252 | dw 63 ;DRM, no of directory entries | |
253 | db 192 ;AL0 | |
254 | db 0 ;AL1 | |
255 | dw 16 ;CKS, size of dir check vector | |
256 | dw 2 ;OFF, no of reserved tracks | |
257 | ||
258 | trans: | |
259 | db 0,1,2,3,4,5,6,7,8,9 | |
260 | db 10,11,12,13,14,15,16,17,18,19 | |
261 | db 19,20,21,22,23,24,25,26 | |
262 | ||
263 | dirbuf: | |
264 | ds 128 | |
265 | ||
266 | chk: | |
267 | ds 16 | |
268 | ||
269 | all: | |
270 | ds 31 | |
271 | ||
272 | end |