Mercurial > hg > Members > kono > nitros9-code
comparison level1/modules/rb1773.asm @ 1574:e9c2b4be14f6
With faith, this too shall pass.
author | boisy |
---|---|
date | Tue, 18 May 2004 02:50:09 +0000 |
parents | a4b6825eeb72 |
children | d58915e348d1 |
comparison
equal
deleted
inserted
replaced
1573:55a157abdbd1 | 1574:e9c2b4be14f6 |
---|---|
33 | 33 |
34 tylg set Drivr+Objct | 34 tylg set Drivr+Objct |
35 atrv set ReEnt+rev | 35 atrv set ReEnt+rev |
36 rev set $01 | 36 rev set $01 |
37 edition set 11 | 37 edition set 11 |
38 | |
39 IFGT Level-1 | |
40 | 38 |
41 * Configuration Settings | 39 * Configuration Settings |
42 N.Drives equ 4 number of drives to support | 40 N.Drives equ 4 number of drives to support |
43 TC9 equ 0 Set to 1 for TC9 special slowdowns | 41 TC9 equ 0 Set to 1 for TC9 special slowdowns |
44 PRECOMP equ 0 Set to 1 to turn on write precompensation | 42 PRECOMP equ 0 Set to 1 to turn on write precompensation |
70 u00B8 rmb 1 PCDOS (512 byte sector) sector # | 68 u00B8 rmb 1 PCDOS (512 byte sector) sector # |
71 size equ . | 69 size equ . |
72 | 70 |
73 fcb DIR.+SHARE.+PEXEC.+PWRIT.+PREAD.+EXEC.+UPDAT. | 71 fcb DIR.+SHARE.+PEXEC.+PWRIT.+PREAD.+EXEC.+UPDAT. |
74 | 72 |
75 name equ * | 73 name fcs /rb1773/ |
76 IFEQ Level-1 | |
77 fcs /CCDisk/ | |
78 ELSE | |
79 fcs /rb1773/ | |
80 ENDC | |
81 fcb edition | 74 fcb edition |
82 | 75 |
83 VIRQCnt fdb $00F0 Initial count for VIRQ (240) | 76 VIRQCnt fdb $00F0 Initial count for VIRQ (240) |
84 | 77 |
85 IRQPkt fcb $00 Normal bits (flip byte) | 78 IRQPkt fcb $00 Normal bits (flip byte) |
1009 ora ,s+ Merge with density settings | 1002 ora ,s+ Merge with density settings |
1010 sta <DD.FMT,x Save in device table | 1003 sta <DD.FMT,x Save in device table |
1011 clrb No error? | 1004 clrb No error? |
1012 puls pc,x Restore original LSN & return | 1005 puls pc,x Restore original LSN & return |
1013 | 1006 |
1014 ELSE | |
1015 | |
1016 ***************************************************************** | |
1017 * NewDisk -- copyright 1985 by Dave Lewis. | |
1018 * Released to public domain January, 1986 | |
1019 * Permission granted to copy and redistribute provided this | |
1020 * header is included with all copies. | |
1021 * | |
1022 * This program is intended to replace the CCDisk module in the | |
1023 * OS9Boot file on the OS-9 system disk. It is far more | |
1024 * versatile than the disk driver provided with Color Computer | |
1025 * OS-9, and is also slightly smaller (20 bytes or so). | |
1026 * Some of its features are: | |
1027 * | |
1028 * -Uses the device descriptor to set head step rate. Original | |
1029 * had 30mS hard-coded in. | |
1030 * -Handles double-sided disks. | |
1031 * -Gets its track and side information from the disk so you | |
1032 * can read and write disks in any format the drive can | |
1033 * physically handle. You can use 40-track double sided disks | |
1034 * and still read/write 35-track single side disks. | |
1035 * -Performs some tests before attempting to use the disk. | |
1036 * The original CCDisk would hang the system if you tried to | |
1037 * access a drive without a disk in it (I know, I know - you | |
1038 * don't have to say `DUMMY!' - but it happens). You can | |
1039 * hang this one too but not as easily. | |
1040 * -An 80-track double sided disk holds 720Kbytes of data. | |
1041 * That's four and a half 35-track single siders. | |
1042 * -All of this stuff is completely transparent once NewDisk is | |
1043 * installed. NewDisk automatically senses the disk format | |
1044 * and conforms to it. (within limits -- don't use non-OS9 | |
1045 * formats) | |
1046 * | |
1047 * One problem -- this program is not complete in itself. If you | |
1048 * want to boot from a double-sided disk you will need my | |
1049 * version of OS9Gen which will generate a double-sided system | |
1050 * disk. Don't try it with the stock version; you'll have to | |
1051 * reformat the disk to clean it up afterwards. | |
1052 ***************************************************************** | |
1053 * Copyright 1985 by Dave Lewis. | |
1054 * | |
1055 * UUCP address is loral!dml; in S. Cal. use ihnp4!sdcc3!loral | |
1056 * | |
1057 * I'm releasing this program to public domain. Copy it, share | |
1058 * it, but don't you DARE sell it! I worked hard on it. Include | |
1059 * this header with all copies. | |
1060 * | |
1061 * If you like this program, send me 5 bucks to encourage me to | |
1062 * write more stuff - or at least to release it. If you send | |
1063 * me 10 bucks I'll send you a good (Dysan) double side disk | |
1064 * formatted 35 track single side with both sourcecode and | |
1065 * executable binary files of the following: | |
1066 * | |
1067 * - NewDisk -- single or double sided disks, any number of | |
1068 * tracks within reason, step rate set in device descriptor | |
1069 * - OS9Gen -- rewritten version that automatically senses for | |
1070 * single/double sided disk and puts all the boot data in | |
1071 * the right places. Also enters the kernel file in the | |
1072 * root directory, which makes Dcheck happy. | |
1073 * - Separate -- breaks up your bootfile into its component | |
1074 * modules for modification. Replace or remove any module | |
1075 * individually. | |
1076 * - Diskdescr -- sourcecode for an OS-9 disk device descriptor | |
1077 * with EQUates at the beginning for step rate, #tracks, | |
1078 * and single or double sided. | |
1079 * - Documentation and procedure files for installing all of | |
1080 * the above in most common system configurations. | |
1081 * - Other stuff I've written that you may find useful. | |
1082 * | |
1083 * Send to: | |
1084 * Dave Lewis | |
1085 * 4417 Idaho Apt. 4 | |
1086 * San Diego CA 92116 | |
1087 ***************************************************************** | |
1088 * | |
1089 * | |
1090 * Copyright 1985 by Dave Lewis | |
1091 * 4417 Idaho apt. 4 | |
1092 * San Diego, CA 92116 | |
1093 * Released to public domain January, 1986 | |
1094 * | |
1095 * | |
1096 * | |
1097 N.DRIVES EQU 3 Number of drives supported | |
1098 DISKRUN EQU $70 Disk run time after access | |
1099 NMIVECT EQU $109 NMI jump vector in RAM | |
1100 COMDREG EQU $FF48 1793 Command register (write) | |
1101 STATREG EQU $FF48 1793 Status register (read) | |
1102 TRAKREG EQU $FF49 1793 Track register | |
1103 SECTREG EQU $FF4A 1793 Sector register | |
1104 DATAREG EQU $FF4B 1793 Data register | |
1105 * | |
1106 MOD eom,NAME,tylg,atrv,EXEC,STORG | |
1107 FCB $FF Mode byte -- all modes | |
1108 NAME FCS 'rb1773' | |
1109 FCB 4 Version number | |
1110 * | |
1111 RMB DRVBEG Storage common to all drives | |
1112 TABL.ORG RMB DRVMEM Drive 0 parameter table | |
1113 RMB DRVMEM Drive 1 parameter table | |
1114 RMB DRVMEM Drive 2 parameter table | |
1115 DRV.ACT RMB 2 Active drive's table origin | |
1116 DPRT.IMG RMB 1 Drive control port image byte | |
1117 DRVS.RDY RMB 1 Drive ready flags | |
1118 Q.SEEK RMB 1 Same drive/track flag | |
1119 STORG EQU . Total storage required | |
1120 * | |
1121 * Function dispatch vectors | |
1122 * | |
1123 EXEC LBRA INIT Initialize variables | |
1124 LBRA READ Read one sector | |
1125 LBRA WRITE Write one sector | |
1126 LBRA RETNOERR GETSTA call is not used | |
1127 LBRA SETSTA Two oddball calls | |
1128 LBRA RETNOERR TERM call is not used | |
1129 * | |
1130 INIT CLR >D.DSKTMR Zero disk rundown timer | |
1131 LDA #$D0 `Force interrupt' command | |
1132 STA >COMDREG | |
1133 LDA #$FF | |
1134 LDB #N.DRIVES Number of drives | |
1135 STB V.NDRV,U | |
1136 LEAX TABL.ORG,U Origin of first drive table | |
1137 INI.TBL STA DD.TOT+1,X Make total sectors nonzero | |
1138 STA V.TRAK,X Force first seek to track 0 | |
1139 CLR DD.FMT,X Make it see a 1-sided disk | |
1140 LEAX DRVMEM,X Go to next drive table | |
1141 DECB Test for last table done | |
1142 BNE INI.TBL Loop if not finished | |
1143 LEAX NMI.SVC,PCR Get address of NMI routine | |
1144 STX >NMIVECT+1 NMI Jump vector operand | |
1145 LDA #$7E Jump opcode | |
1146 STA >NMIVECT NMI Jump vector opcode | |
1147 LDA >STATREG Clear interrupt condition | |
1148 RETNOERR CLRB | |
1149 RTS | |
1150 * | |
1151 ERR.WPRT COMB Set carry flag | |
1152 LDB #E$WP Set error code | |
1153 RTS | |
1154 ERR.SEEK COMB Set carry flag | |
1155 LDB #E$SEEK Set error code | |
1156 RTS | |
1157 ERR.CRC COMB Set carry flag | |
1158 LDB #E$CRC Set error code | |
1159 RTS | |
1160 ERR.READ COMB Set carry flag | |
1161 LDB #E$READ Set error code | |
1162 RTS | |
1163 * | |
1164 * All disk controller commands exit via NMI. The service routine | |
1165 * returns control to the address on top of stack after registers | |
1166 * have been dumped off. | |
1167 * | |
1168 NMI.SVC LEAS R$SIZE,S Dump registers off stack | |
1169 LDA >STATREG Get status condition | |
1170 STAT.TST LSLA Test status register bit 7 | |
1171 LBCS ERR.NRDY Status = Not Ready if set | |
1172 LSLA Test bit 6 | |
1173 BCS ERR.WPRT Status = Write Protect if set | |
1174 LSLA Test bit 5 | |
1175 LBCS ERR.WRT Status = Write Fault if set | |
1176 LSLA Test bit 4 | |
1177 BCS ERR.SEEK Status = Record Not Found | |
1178 LSLA Test bit 3 | |
1179 BCS ERR.CRC Status = CRC Error if set | |
1180 LSLA Test bit 2 | |
1181 BCS ERR.READ Status = Lost Data if set | |
1182 CLRB No error if all 0 | |
1183 RETURN1 RTS | |
1184 * | |
1185 READ TSTB If LSN is greater than 65,536 | |
1186 BNE ERR.SECT return a sector error | |
1187 LDA #$A4 Set retry control byte | |
1188 CMPX #0 Is it sector 0? | |
1189 BNE READ2 If not, just read the data | |
1190 BSR READ2 If sector 0, read it and | |
1191 BCS RETURN1 update drive table | |
1192 PSHS Y,X Save X and Y | |
1193 LDX PD.BUF,Y Point to data buffer | |
1194 LDY DRV.ACT,U Point to active drive's table | |
1195 LDB #DD.RES+1 Counter and offset pointer | |
1196 SEC0LOOP LDA B,X Get byte from buffer | |
1197 STA B,Y Store in drive table | |
1198 DECB Decrement loop index | |
1199 BPL SEC0LOOP Loop until B < 0 | |
1200 CLRB No error | |
1201 PULS X,Y,PC Pull and return | |
1202 * | |
1203 WRITE TSTB If LSN is greater than 65,536 | |
1204 BNE ERR.SECT return a sector error | |
1205 LDA #$A4 Set retry control byte | |
1206 PSHS X,A,CC Save registers | |
1207 LBSR DSKSTART Start and select drive | |
1208 BCS EXIT.ERR Exit if error | |
1209 REWRITE LDX 2,S Get LSN off stack | |
1210 LBSR SEEK Position head at sector | |
1211 BCS RETRY.WR Try again if seek error | |
1212 BSR WRITE2 Write the sector | |
1213 BCS RETRY.WR Try again if write error | |
1214 TST PD.VFY,Y Check verify flag | |
1215 BNE EXIT.NER Exit without verify if off | |
1216 BSR VERIFY Verify sector just written | |
1217 BCC EXIT.NER Exit if no error | |
1218 RETRY.WR LDA 1,S Get retry control byte | |
1219 LSRA Indicate another try | |
1220 STA 1,S Put updated byte back | |
1221 BEQ EXIT.ERR If zero, no more chances | |
1222 BCC REWRITE If bit 0 was 0, don't home | |
1223 BSR HOME Home and start all over | |
1224 BCC REWRITE If it homed OK, try again | |
1225 EXIT.ERR PULS CC Restore interrupt masks | |
1226 COMA Set carry for error | |
1227 BRA CCDEXIT Finish exit | |
1228 * | |
1229 EXIT.NER PULS CC Restore interrupt masks | |
1230 CLRB Clear carry -- no error | |
1231 CCDEXIT LDA #8 Spindle motor control bit | |
1232 STA >DPORT Deselect disk drive | |
1233 PULS A,X,PC Pull and return | |
1234 * | |
1235 ERR.SECT COMB Set carry flag for error | |
1236 LDB #E$SECT Set error code | |
1237 RTS | |
1238 * | |
1239 READ2 PSHS X,A,CC CC is on top of stack | |
1240 LBSR DSKSTART Start drives and test | |
1241 BCS EXIT.ERR Abort if not ready | |
1242 REREAD LDX 2,S Recover LSN from stack | |
1243 LBSR SEEK Position head at sector | |
1244 BCS RETRY.RD Try again if seek error | |
1245 BSR READ3 Read the sector | |
1246 BCC EXIT.NER Read OK, return data | |
1247 RETRY.RD LDA 1,S Get retry control byte | |
1248 LSRA Indicate another try | |
1249 STA 1,S Put updated byte back | |
1250 BEQ EXIT.ERR If it was all 0, quit | |
1251 BCC REREAD If bit 0 was 0, don't home | |
1252 BSR HOME Home and start all over | |
1253 BCC REREAD If it won't home, quit now | |
1254 BRA EXIT.ERR Exit with an error | |
1255 * | |
1256 WRITE2 LDA #$A2 `Write sector' command | |
1257 BSR RWCMDX Execute command | |
1258 WAITWDRQ BITA >STATREG Wait until controller is | |
1259 BEQ WAITWDRQ ready to transfer data | |
1260 * | |
1261 WRTLOOP LDA ,X+ Get byte from data buffer | |
1262 STA >DATAREG Put it in data register | |
1263 STB >DPORT Activate DRQ halt function | |
1264 BRA WRTLOOP Loop until interrupted | |
1265 * | |
1266 VERIFY LDA #$82 `Read sector' command | |
1267 BSR RWCMDX Execute command | |
1268 WAITVDRQ BITA >STATREG Wait until controller is | |
1269 BEQ WAITVDRQ ready to transfer data | |
1270 * | |
1271 VFYLOOP LDA >DATAREG Get read data byte | |
1272 STB >DPORT Activate DRQ halt function | |
1273 CMPA ,X+ Compare to source data | |
1274 BEQ VFYLOOP Loop until interrupt if equal | |
1275 * | |
1276 ANDB #$7F Mask off DRQ halt bit | |
1277 STB >DPORT Disable DRQ halt function | |
1278 LBSR KILLCOMD Abort read command | |
1279 ERR.WRT COMB Set carry flag | |
1280 LDB #E$WRITE Set error code | |
1281 RTS | |
1282 * | |
1283 SS.HOME PSHS X,A,CC Set up stack for exit | |
1284 BSR HOME Home drive | |
1285 BRA SS.EXIT Skip to empty-stack exit | |
1286 SS.EXIT4 LEAS 2,S Exit w/4 bytes on stack | |
1287 SS.EXIT2 LEAS 2,S Exit w/2 bytes on stack | |
1288 SS.EXIT BCS EXIT.ERR Exit with error | |
1289 BRA EXIT.NER Exit with no error | |
1290 * | |
1291 HOME LBSR DSKSTART Start and select drive | |
1292 BCS RETURN2 Return if error | |
1293 LDX DRV.ACT,U Point to active drive's table | |
1294 CLR V.TRAK,X Set track number to zero | |
1295 LDD #$43C Home, verify, allow 3 seconds | |
1296 LBSR STEPEX Execute stepping command | |
1297 RETURN2 RTS | |
1298 * | |
1299 SETSTA LDX PD.RGS,Y Point to caller's stack | |
1300 LDB R$B,X Get stacked B register | |
1301 CMPB #SS.RESET `Home' call | |
1302 BEQ SS.HOME Execute Home sequence | |
1303 CMPB #SS.WTRK `Write track' call, used by | |
1304 BEQ WRT.TRAK the Format utility | |
1305 COMB If not one of those, it's an | |
1306 LDB #E$UNKSVC illegal setsta call | |
1307 RTS | |
1308 * | |
1309 READ3 LDA #$82 Read sector command | |
1310 BSR RWCMDX Set up for sector read | |
1311 WAITRDRQ BITA >STATREG Wait for controller to find | |
1312 BEQ WAITRDRQ sector and start reading | |
1313 * | |
1314 READLOOP LDA >DATAREG Get data from controller | |
1315 STA ,X+ Store in sector buffer | |
1316 STB >DPORT Activate DRQ halt function | |
1317 BRA READLOOP Loop until interrupted | |
1318 * | |
1319 RWCMDX LDX PD.BUF,Y Point to sector buffer | |
1320 LDB DPRT.IMG,U Do a side verify using the | |
1321 BITB #$40 DPORT image byte as a side | |
1322 BEQ WTKCMDX select indicator | |
1323 ORA #8 Compare for side 1 | |
1324 WTKCMDX STA >COMDREG Issue command to controller | |
1325 LDB #$A8 Set up DRQ halt function | |
1326 ORB DPRT.IMG,U OR in select bits | |
1327 LDA #2 DRQ bit in status register | |
1328 RTS | |
1329 * | |
1330 * Write an entire track -- used by Format | |
1331 * | |
1332 WRT.TRAK PSHS X,A,CC Set up stack for exit | |
1333 LDA R$U+1,X Get track number | |
1334 LDB R$Y+1,X Get side select bit | |
1335 LDX R$X,X Get track buffer address | |
1336 PSHS X,D Save 'em | |
1337 LBSR DSKSTART Start and select drive | |
1338 BCS SS.EXIT4 Exit if error | |
1339 PULS D Get track number and side | |
1340 LDX DRV.ACT,U Get drive table address | |
1341 BSR SID.PCMP Get drive ready to go | |
1342 TST Q.SEEK,U Different drive/track? | |
1343 BNE WRT.TRK2 If not, no need to seek | |
1344 LDD #$103C Seek, allow 3 seconds | |
1345 LBSR STEPEX Execute stepping command | |
1346 BCS SS.EXIT2 Exit if error | |
1347 WRT.TRK2 PULS X Retrieve track buffer address | |
1348 LDA #$F0 `Write track' command | |
1349 BSR WTKCMDX Execute write track command | |
1350 LBSR WAITWDRQ Just like a Write Sector | |
1351 LBRA SS.EXIT Return to caller | |
1352 * | |
1353 SID.PCMP LSRB Bit 0 of B is set for | |
1354 BCC SIDE.ONE side 2 of disk | |
1355 LDB DPRT.IMG,U Get drive control image byte | |
1356 ORB #$40 Side 2 select bit | |
1357 STB DPRT.IMG,U Activate side 2 select | |
1358 SIDE.ONE CMPA PD.CYL+1,Y If track number exceeds # | |
1359 LBHI ERR.SECT of tracks, return error | |
1360 SD.PCMP2 LDB PD.DNS,Y Check track density of drive | |
1361 LSRB Shift bit 1 (TPI bit) into | |
1362 LSRB carry flag (1 = 96 TPI) | |
1363 LDB #20 Precomp starts at track 21 | |
1364 BCC FORTYTKS on 48 TPI drives, track 41 | |
1365 LSLB on 96 TPI drives | |
1366 FORTYTKS PSHS B Put B where it can be used | |
1367 CMPA ,S+ Does it need precomp? | |
1368 BLS NOPRECMP No, skip next step | |
1369 LDB DPRT.IMG,U Get drive control image byte | |
1370 ORB #$10 Write precompensation bit | |
1371 STB DPRT.IMG,U Activate precompensation | |
1372 NOPRECMP LDB V.TRAK,X Get current track number | |
1373 STB >TRAKREG Update disk controller | |
1374 CMPA V.TRAK,X Same track as last access? | |
1375 BEQ SAMETRAK If so, leave flag set | |
1376 CLR Q.SEEK,U Clear same drive/track flag | |
1377 SAMETRAK STA V.TRAK,X Update track number | |
1378 STA >DATAREG Set destination track | |
1379 LDB DPRT.IMG,U Get disk control byte | |
1380 STB >DPORT Update control port | |
1381 RTS | |
1382 * | |
1383 * Translate logical sector number (LSN) to physical side, track | |
1384 * and sector, activate write precompensation if necessary, | |
1385 * and execute seek command. If any error occurs, return error | |
1386 * number to calling routine. | |
1387 * | |
1388 SEEK LDD PD.SCT,Y Get #sectors per track | |
1389 PSHS X,D Put LSN and sec/trk on stack | |
1390 LDD 2,S Get LSN off stack | |
1391 CLR 2,S Set up track counter | |
1392 FINDTRAK INC 2,S Increment track counter | |
1393 SUBD ,S Subtract sectors in one track | |
1394 BPL FINDTRAK Loop if LSN still positive | |
1395 ADDD ,S++ Restore sector number | |
1396 INCB Sector numbers start at 1 | |
1397 STB 1,S Save sector number | |
1398 PULS A Get track number | |
1399 DECA Compensate for extra count | |
1400 LDX DRV.ACT,U Get active table address | |
1401 LDB DD.FMT,X See if disk is double sided | |
1402 BITB #1 Test #sides bit | |
1403 BEQ SEEK2 If one-sided, skip next step | |
1404 LSRA Divide track number by 2 | |
1405 ROLB Put remainder in B bit 0 | |
1406 SEEK2 BSR SID.PCMP Set up precomp and side sel | |
1407 PULS B Get sector number | |
1408 STB >SECTREG Set destination sector | |
1409 TST Q.SEEK,U Same drive/track? | |
1410 BNE COMDEXIT If so, no need to seek | |
1411 LDD #$143C Seek with verify, allow 3 sec | |
1412 BRA STEPEX Execute stepping command | |
1413 * | |
1414 * Execute command in A and wait for it to finish. If it runs | |
1415 * normally or aborts with an error it will exit through NMI; | |
1416 * if it takes an unreasonable amount of time this routine | |
1417 * will abort it and set the carry flag. If the command | |
1418 * involves head movement, use STEPEX to set step rate. | |
1419 * On entry, A contains command code and B contains time limit | |
1420 * in 50-millisecond increments. | |
1421 * | |
1422 STEPEX PSHS A Put raw command on stack | |
1423 LDA PD.STP,Y Get step rate code | |
1424 EORA #3 Convert to 1793's format | |
1425 ORA ,S+ Combine with raw command | |
1426 COMDEX STA >COMDREG Execute command in A | |
1427 CLRA Clear carry flag | |
1428 BSR WAIT50MS Wait while command runs | |
1429 BCC COMDEXIT Exit if no error | |
1430 CMPB #E$NOTRDY Test for the three valid | |
1431 BEQ KCEXIT error codes for a Type 1 | |
1432 CMPB #E$SEEK disk controller command -- | |
1433 BEQ KCEXIT home, seek or force int- | |
1434 CMPB #E$CRC errupt -- and return the | |
1435 BEQ KCEXIT errors | |
1436 COMDEXIT CLRB No error, clear carry | |
1437 RTS | |
1438 * | |
1439 WAIT50MS LDX #$15D8 Almost exactly 50 mSec delay | |
1440 WAITIMER LEAX -1,X Wait specified time for disk | |
1441 BNE WAITIMER controller to issue NMI | |
1442 DECB signaling command completed | |
1443 BNE WAIT50MS or aborted with error | |
1444 KILLCOMD LDA #$D0 Force interrupt, NMI disabled | |
1445 STA >COMDREG Abort command in progress | |
1446 ERR.NRDY LDB #E$NOTRDY Set error code | |
1447 KCEXIT COMA Set carry to flag error | |
1448 RTS | |
1449 * | |
1450 * | |
1451 * Get selected drive ready to read or write. If spindle motors are | |
1452 * stopped, start them and wait until they're up to operating | |
1453 * speed. Check drive number and select drive if number is valid. | |
1454 * Monitor index pulses to ensure door is closed, disk inserted | |
1455 * and turning, etc. Return appropriate error code if any of | |
1456 * these conditions can't be met. | |
1457 * | |
1458 DSKSTART TST >D.DSKTMR Are drives already running? | |
1459 BNE SPINRDY If so, no need to wait | |
1460 CLR DRVS.RDY,U No drives are ready | |
1461 LDD #$80B Motor on, wait 550 mSec | |
1462 STA >DPORT Start spindle motors | |
1463 BSR WAIT50MS Wait for motors to start | |
1464 SPINRDY LDA PD.DRV,Y Get drive number | |
1465 CMPA V.NDRV,U Test for valid drive # | |
1466 BHS ERR.UNIT Return error if not | |
1467 LEAX TABL.ORG,U Compute address of active | |
1468 LDB #DRVMEM drive's parameter table | |
1469 MUL TABL.ORG + (D# * tablesize) | |
1470 LEAX D,X Add computed offset to origin | |
1471 LDA PD.DRV,Y Get drive number again | |
1472 LSLA Set corresponding drv select | |
1473 BNE NOTDRV0 bit -- 1 for D1, 2 for D2 | |
1474 INCA Set bit 0 for drive 0 | |
1475 NOTDRV0 TFR A,B Copy select bit | |
1476 ORB #$28 Enable double density | |
1477 ORCC #INTMASKS Disable IRQ and FIRQ | |
1478 STB >DPORT Enable drive | |
1479 STB DPRT.IMG,U Set image byte | |
1480 CLR Q.SEEK,U Clear same drive/track flag | |
1481 CMPX DRV.ACT,U Is this the same drive? | |
1482 BNE NEWDRIVE If not, leave flag zeroed | |
1483 LDB #$FF Indicate successive accesses | |
1484 STB Q.SEEK,U to the same drive. | |
1485 NEWDRIVE STX DRV.ACT,U Store table address | |
1486 BITA DRVS.RDY,U Has this drive been ready | |
1487 BNE DRVRDY since the motors started? | |
1488 PSHS A Save drive select bit | |
1489 LDD #$D405 Force int, allow 250 mSec | |
1490 BSR COMDEX Look for index pulse | |
1491 PSHS CC Save carry flag condition | |
1492 BSR KILLCOMD Clear index-pulse NMI state | |
1493 PULS CC,A Restore carry flag and A | |
1494 BCS RETURN3 Error if no index pulse | |
1495 DRVRDY ORA DRVS.RDY,U Set corresponding drive | |
1496 STA DRVS.RDY,U ready flag | |
1497 LDA #DISKRUN Restart disk rundown timer | |
1498 STA >D.DSKTMR | |
1499 LDA >STATREG Clear interrupt condition | |
1500 CLRB Return no error | |
1501 RETURN3 RTS | |
1502 * | |
1503 ERR.UNIT COMB Set carry flag | |
1504 LDB E$UNIT Set error code | |
1505 RTS | |
1506 * | |
1507 ENDC | |
1508 | |
1509 emod | 1007 emod |
1510 eom equ * | 1008 eom equ * |
1511 end | 1009 end |