annotate level1/modules/ccdisk.asm @ 1570:a4b6825eeb72

ccdisk renamed to rb1773, added CC3 driver into source
author boisy
date Tue, 18 May 2004 01:26:19 +0000
parents 4a4ff4d844ef
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
1 *****************************************************************
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
2 * NewDisk -- copyright 1985 by Dave Lewis.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
3 * Released to public domain January, 1986
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
4 * Permission granted to copy and redistribute provided this
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
5 * header is included with all copies.
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
6 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
7 * This program is intended to replace the CCDisk module in the
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
8 * OS9Boot file on the OS-9 system disk. It is far more
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
9 * versatile than the disk driver provided with Color Computer
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
10 * OS-9, and is also slightly smaller (20 bytes or so).
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
11 * Some of its features are:
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
12 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
13 * -Uses the device descriptor to set head step rate. Original
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
14 * had 30mS hard-coded in.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
15 * -Handles double-sided disks.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
16 * -Gets its track and side information from the disk so you
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
17 * can read and write disks in any format the drive can
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
18 * physically handle. You can use 40-track double sided disks
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
19 * and still read/write 35-track single side disks.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
20 * -Performs some tests before attempting to use the disk.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
21 * The original CCDisk would hang the system if you tried to
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
22 * access a drive without a disk in it (I know, I know - you
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
23 * don't have to say `DUMMY!' - but it happens). You can
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
24 * hang this one too but not as easily.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
25 * -An 80-track double sided disk holds 720Kbytes of data.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
26 * That's four and a half 35-track single siders.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
27 * -All of this stuff is completely transparent once NewDisk is
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
28 * installed. NewDisk automatically senses the disk format
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
29 * and conforms to it. (within limits -- don't use non-OS9
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
30 * formats)
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
31 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
32 * One problem -- this program is not complete in itself. If you
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
33 * want to boot from a double-sided disk you will need my
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
34 * version of OS9Gen which will generate a double-sided system
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
35 * disk. Don't try it with the stock version; you'll have to
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
36 * reformat the disk to clean it up afterwards.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
37 *****************************************************************
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
38 * Copyright 1985 by Dave Lewis.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
39 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
40 * UUCP address is loral!dml; in S. Cal. use ihnp4!sdcc3!loral
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
41 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
42 * I'm releasing this program to public domain. Copy it, share
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
43 * it, but don't you DARE sell it! I worked hard on it. Include
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
44 * this header with all copies.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
45 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
46 * If you like this program, send me 5 bucks to encourage me to
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
47 * write more stuff - or at least to release it. If you send
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
48 * me 10 bucks I'll send you a good (Dysan) double side disk
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
49 * formatted 35 track single side with both sourcecode and
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
50 * executable binary files of the following:
1287
10957d54bf16 Made all modules rev 0
boisy
parents: 1198
diff changeset
51 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
52 * - NewDisk -- single or double sided disks, any number of
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
53 * tracks within reason, step rate set in device descriptor
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
54 * - OS9Gen -- rewritten version that automatically senses for
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
55 * single/double sided disk and puts all the boot data in
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
56 * the right places. Also enters the kernel file in the
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
57 * root directory, which makes Dcheck happy.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
58 * - Separate -- breaks up your bootfile into its component
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
59 * modules for modification. Replace or remove any module
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
60 * individually.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
61 * - Diskdescr -- sourcecode for an OS-9 disk device descriptor
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
62 * with EQUates at the beginning for step rate, #tracks,
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
63 * and single or double sided.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
64 * - Documentation and procedure files for installing all of
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
65 * the above in most common system configurations.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
66 * - Other stuff I've written that you may find useful.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
67 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
68 * Send to:
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
69 * Dave Lewis
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
70 * 4417 Idaho Apt. 4
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
71 * San Diego CA 92116
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
72 *****************************************************************
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
73 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
74 NAM NewDisk
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
75 TTL Improved OS-9 disk device driver module
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
76 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
77 * Copyright 1985 by Dave Lewis
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
78 * 4417 Idaho apt. 4
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
79 * San Diego, CA 92116
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
80 * Released to public domain January, 1986
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
81 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
82 USE defsfile
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
83 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
84 REV EQU 1
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
85 TYPE EQU DRIVR+OBJCT
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
86 ATTR EQU REENT+REV
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
87 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
88 N.DRIVES EQU 3 Number of drives supported
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
89 DISKRUN EQU $70 Disk run time after access
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
90 NMIVECT EQU $109 NMI jump vector in RAM
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
91 COMDREG EQU $FF48 1793 Command register (write)
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
92 STATREG EQU $FF48 1793 Status register (read)
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
93 TRAKREG EQU $FF49 1793 Track register
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
94 SECTREG EQU $FF4A 1793 Sector register
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
95 DATAREG EQU $FF4B 1793 Data register
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
96 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
97 MOD SIZE,NAME,TYPE,ATTR,EXEC,STORG
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
98 FCB $FF Mode byte -- all modes
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
99 NAME FCS 'CCDisk' Still the same module name
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
100 FCB 4 Version number
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
101 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
102 RMB DRVBEG Storage common to all drives
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
103 TABL.ORG RMB DRVMEM Drive 0 parameter table
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
104 RMB DRVMEM Drive 1 parameter table
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
105 RMB DRVMEM Drive 2 parameter table
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
106 DRV.ACT RMB 2 Active drive's table origin
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
107 DPRT.IMG RMB 1 Drive control port image byte
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
108 DRVS.RDY RMB 1 Drive ready flags
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
109 Q.SEEK RMB 1 Same drive/track flag
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
110 STORG EQU . Total storage required
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
111 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
112 * Function dispatch vectors
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
113 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
114 EXEC LBRA INIT Initialize variables
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
115 LBRA READ Read one sector
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
116 LBRA WRITE Write one sector
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
117 LBRA RETNOERR GETSTA call is not used
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
118 LBRA SETSTA Two oddball calls
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
119 LBRA RETNOERR TERM call is not used
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
120 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
121 INIT CLR >D.DSKTMR Zero disk rundown timer
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
122 LDA #$D0 `Force interrupt' command
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
123 STA >COMDREG
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
124 LDA #$FF
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
125 LDB #N.DRIVES Number of drives
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
126 STB V.NDRV,U
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
127 LEAX TABL.ORG,U Origin of first drive table
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
128 INI.TBL STA DD.TOT+1,X Make total sectors nonzero
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
129 STA V.TRAK,X Force first seek to track 0
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
130 CLR DD.FMT,X Make it see a 1-sided disk
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
131 LEAX DRVMEM,X Go to next drive table
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
132 DECB Test for last table done
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
133 BNE INI.TBL Loop if not finished
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
134 LEAX NMI.SVC,PCR Get address of NMI routine
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
135 STX >NMIVECT+1 NMI Jump vector operand
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
136 LDA #$7E Jump opcode
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
137 STA >NMIVECT NMI Jump vector opcode
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
138 LDA >STATREG Clear interrupt condition
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
139 RETNOERR CLRB
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
140 RTS
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
141 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
142 ERR.WPRT COMB Set carry flag
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
143 LDB #E$WP Set error code
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
144 RTS
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
145 ERR.SEEK COMB Set carry flag
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
146 LDB #E$SEEK Set error code
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
147 RTS
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
148 ERR.CRC COMB Set carry flag
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
149 LDB #E$CRC Set error code
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
150 RTS
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
151 ERR.READ COMB Set carry flag
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
152 LDB #E$READ Set error code
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
153 RTS
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
154 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
155 * All disk controller commands exit via NMI. The service routine
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
156 * returns control to the address on top of stack after registers
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
157 * have been dumped off.
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
158 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
159 NMI.SVC LEAS R$SIZE,S Dump registers off stack
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
160 LDA >STATREG Get status condition
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
161 STAT.TST LSLA Test status register bit 7
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
162 LBCS ERR.NRDY Status = Not Ready if set
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
163 LSLA Test bit 6
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
164 BCS ERR.WPRT Status = Write Protect if set
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
165 LSLA Test bit 5
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
166 LBCS ERR.WRT Status = Write Fault if set
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
167 LSLA Test bit 4
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
168 BCS ERR.SEEK Status = Record Not Found
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
169 LSLA Test bit 3
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
170 BCS ERR.CRC Status = CRC Error if set
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
171 LSLA Test bit 2
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
172 BCS ERR.READ Status = Lost Data if set
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
173 CLRB No error if all 0
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
174 RETURN1 RTS
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
175 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
176 READ TSTB If LSN is greater than 65,536
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
177 BNE ERR.SECT return a sector error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
178 LDA #$A4 Set retry control byte
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
179 CMPX #0 Is it sector 0?
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
180 BNE READ2 If not, just read the data
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
181 BSR READ2 If sector 0, read it and
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
182 BCS RETURN1 update drive table
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
183 PSHS Y,X Save X and Y
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
184 LDX PD.BUF,Y Point to data buffer
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
185 LDY DRV.ACT,U Point to active drive's table
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
186 LDB #DD.RES+1 Counter and offset pointer
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
187 SEC0LOOP LDA B,X Get byte from buffer
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
188 STA B,Y Store in drive table
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
189 DECB Decrement loop index
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
190 BPL SEC0LOOP Loop until B < 0
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
191 CLRB No error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
192 PULS X,Y,PC Pull and return
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
193 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
194 WRITE TSTB If LSN is greater than 65,536
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
195 BNE ERR.SECT return a sector error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
196 LDA #$A4 Set retry control byte
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
197 PSHS X,A,CC Save registers
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
198 LBSR DSKSTART Start and select drive
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
199 BCS EXIT.ERR Exit if error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
200 REWRITE LDX 2,S Get LSN off stack
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
201 LBSR SEEK Position head at sector
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
202 BCS RETRY.WR Try again if seek error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
203 BSR WRITE2 Write the sector
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
204 BCS RETRY.WR Try again if write error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
205 TST PD.VFY,Y Check verify flag
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
206 BNE EXIT.NER Exit without verify if off
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
207 BSR VERIFY Verify sector just written
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
208 BCC EXIT.NER Exit if no error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
209 RETRY.WR LDA 1,S Get retry control byte
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
210 LSRA Indicate another try
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
211 STA 1,S Put updated byte back
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
212 BEQ EXIT.ERR If zero, no more chances
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
213 BCC REWRITE If bit 0 was 0, don't home
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
214 BSR HOME Home and start all over
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
215 BCC REWRITE If it homed OK, try again
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
216 EXIT.ERR PULS CC Restore interrupt masks
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
217 COMA Set carry for error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
218 BRA CCDEXIT Finish exit
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
219 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
220 EXIT.NER PULS CC Restore interrupt masks
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
221 CLRB Clear carry -- no error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
222 CCDEXIT LDA #8 Spindle motor control bit
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
223 STA >DPORT Deselect disk drive
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
224 PULS A,X,PC Pull and return
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
225 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
226 ERR.SECT COMB Set carry flag for error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
227 LDB #E$SECT Set error code
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
228 RTS
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
229 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
230 READ2 PSHS X,A,CC CC is on top of stack
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
231 LBSR DSKSTART Start drives and test
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
232 BCS EXIT.ERR Abort if not ready
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
233 REREAD LDX 2,S Recover LSN from stack
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
234 LBSR SEEK Position head at sector
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
235 BCS RETRY.RD Try again if seek error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
236 BSR READ3 Read the sector
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
237 BCC EXIT.NER Read OK, return data
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
238 RETRY.RD LDA 1,S Get retry control byte
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
239 LSRA Indicate another try
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
240 STA 1,S Put updated byte back
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
241 BEQ EXIT.ERR If it was all 0, quit
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
242 BCC REREAD If bit 0 was 0, don't home
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
243 BSR HOME Home and start all over
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
244 BCC REREAD If it won't home, quit now
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
245 BRA EXIT.ERR Exit with an error
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
246 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
247 WRITE2 LDA #$A2 `Write sector' command
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
248 BSR RWCMDX Execute command
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
249 WAITWDRQ BITA >STATREG Wait until controller is
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
250 BEQ WAITWDRQ ready to transfer data
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
251 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
252 WRTLOOP LDA ,X+ Get byte from data buffer
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
253 STA >DATAREG Put it in data register
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
254 STB >DPORT Activate DRQ halt function
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
255 BRA WRTLOOP Loop until interrupted
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
256 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
257 VERIFY LDA #$82 `Read sector' command
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
258 BSR RWCMDX Execute command
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
259 WAITVDRQ BITA >STATREG Wait until controller is
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
260 BEQ WAITVDRQ ready to transfer data
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
261 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
262 VFYLOOP LDA >DATAREG Get read data byte
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
263 STB >DPORT Activate DRQ halt function
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
264 CMPA ,X+ Compare to source data
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
265 BEQ VFYLOOP Loop until interrupt if equal
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
266 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
267 ANDB #$7F Mask off DRQ halt bit
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
268 STB >DPORT Disable DRQ halt function
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
269 LBSR KILLCOMD Abort read command
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
270 ERR.WRT COMB Set carry flag
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
271 LDB #E$WRITE Set error code
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
272 RTS
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
273 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
274 SS.HOME PSHS X,A,CC Set up stack for exit
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
275 BSR HOME Home drive
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
276 BRA SS.EXIT Skip to empty-stack exit
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
277 SS.EXIT4 LEAS 2,S Exit w/4 bytes on stack
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
278 SS.EXIT2 LEAS 2,S Exit w/2 bytes on stack
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
279 SS.EXIT BCS EXIT.ERR Exit with error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
280 BRA EXIT.NER Exit with no error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
281 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
282 HOME LBSR DSKSTART Start and select drive
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
283 BCS RETURN2 Return if error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
284 LDX DRV.ACT,U Point to active drive's table
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
285 CLR V.TRAK,X Set track number to zero
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
286 LDD #$43C Home, verify, allow 3 seconds
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
287 LBSR STEPEX Execute stepping command
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
288 RETURN2 RTS
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
289 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
290 SETSTA LDX PD.RGS,Y Point to caller's stack
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
291 LDB R$B,X Get stacked B register
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
292 CMPB #SS.RESET `Home' call
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
293 BEQ SS.HOME Execute Home sequence
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
294 CMPB #SS.WTRK `Write track' call, used by
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
295 BEQ WRT.TRAK the Format utility
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
296 COMB If not one of those, it's an
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
297 LDB #E$UNKSVC illegal setsta call
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
298 RTS
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
299 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
300 READ3 LDA #$82 Read sector command
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
301 BSR RWCMDX Set up for sector read
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
302 WAITRDRQ BITA >STATREG Wait for controller to find
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
303 BEQ WAITRDRQ sector and start reading
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
304 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
305 READLOOP LDA >DATAREG Get data from controller
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
306 STA ,X+ Store in sector buffer
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
307 STB >DPORT Activate DRQ halt function
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
308 BRA READLOOP Loop until interrupted
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
309 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
310 RWCMDX LDX PD.BUF,Y Point to sector buffer
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
311 LDB DPRT.IMG,U Do a side verify using the
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
312 BITB #$40 DPORT image byte as a side
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
313 BEQ WTKCMDX select indicator
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
314 ORA #8 Compare for side 1
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
315 WTKCMDX STA >COMDREG Issue command to controller
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
316 LDB #$A8 Set up DRQ halt function
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
317 ORB DPRT.IMG,U OR in select bits
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
318 LDA #2 DRQ bit in status register
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
319 RTS
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
320 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
321 * Write an entire track -- used by Format
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
322 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
323 WRT.TRAK PSHS X,A,CC Set up stack for exit
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
324 LDA R$U+1,X Get track number
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
325 LDB R$Y+1,X Get side select bit
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
326 LDX R$X,X Get track buffer address
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
327 PSHS X,D Save 'em
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
328 LBSR DSKSTART Start and select drive
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
329 BCS SS.EXIT4 Exit if error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
330 PULS D Get track number and side
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
331 LDX DRV.ACT,U Get drive table address
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
332 BSR SID.PCMP Get drive ready to go
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
333 TST Q.SEEK,U Different drive/track?
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
334 BNE WRT.TRK2 If not, no need to seek
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
335 LDD #$103C Seek, allow 3 seconds
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
336 LBSR STEPEX Execute stepping command
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
337 BCS SS.EXIT2 Exit if error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
338 WRT.TRK2 PULS X Retrieve track buffer address
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
339 LDA #$F0 `Write track' command
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
340 BSR WTKCMDX Execute write track command
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
341 LBSR WAITWDRQ Just like a Write Sector
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
342 LBRA SS.EXIT Return to caller
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
343 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
344 SID.PCMP LSRB Bit 0 of B is set for
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
345 BCC SIDE.ONE side 2 of disk
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
346 LDB DPRT.IMG,U Get drive control image byte
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
347 ORB #$40 Side 2 select bit
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
348 STB DPRT.IMG,U Activate side 2 select
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
349 SIDE.ONE CMPA PD.CYL+1,Y If track number exceeds #
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
350 LBHI ERR.SECT of tracks, return error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
351 SD.PCMP2 LDB PD.DNS,Y Check track density of drive
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
352 LSRB Shift bit 1 (TPI bit) into
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
353 LSRB carry flag (1 = 96 TPI)
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
354 LDB #20 Precomp starts at track 21
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
355 BCC FORTYTKS on 48 TPI drives, track 41
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
356 LSLB on 96 TPI drives
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
357 FORTYTKS PSHS B Put B where it can be used
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
358 CMPA ,S+ Does it need precomp?
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
359 BLS NOPRECMP No, skip next step
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
360 LDB DPRT.IMG,U Get drive control image byte
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
361 ORB #$10 Write precompensation bit
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
362 STB DPRT.IMG,U Activate precompensation
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
363 NOPRECMP LDB V.TRAK,X Get current track number
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
364 STB >TRAKREG Update disk controller
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
365 CMPA V.TRAK,X Same track as last access?
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
366 BEQ SAMETRAK If so, leave flag set
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
367 CLR Q.SEEK,U Clear same drive/track flag
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
368 SAMETRAK STA V.TRAK,X Update track number
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
369 STA >DATAREG Set destination track
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
370 LDB DPRT.IMG,U Get disk control byte
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
371 STB >DPORT Update control port
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
372 RTS
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
373 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
374 * Translate logical sector number (LSN) to physical side, track
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
375 * and sector, activate write precompensation if necessary,
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
376 * and execute seek command. If any error occurs, return error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
377 * number to calling routine.
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
378 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
379 SEEK LDD PD.SCT,Y Get #sectors per track
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
380 PSHS X,D Put LSN and sec/trk on stack
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
381 LDD 2,S Get LSN off stack
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
382 CLR 2,S Set up track counter
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
383 FINDTRAK INC 2,S Increment track counter
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
384 SUBD ,S Subtract sectors in one track
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
385 BPL FINDTRAK Loop if LSN still positive
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
386 ADDD ,S++ Restore sector number
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
387 INCB Sector numbers start at 1
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
388 STB 1,S Save sector number
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
389 PULS A Get track number
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
390 DECA Compensate for extra count
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
391 LDX DRV.ACT,U Get active table address
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
392 LDB DD.FMT,X See if disk is double sided
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
393 BITB #1 Test #sides bit
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
394 BEQ SEEK2 If one-sided, skip next step
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
395 LSRA Divide track number by 2
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
396 ROLB Put remainder in B bit 0
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
397 SEEK2 BSR SID.PCMP Set up precomp and side sel
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
398 PULS B Get sector number
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
399 STB >SECTREG Set destination sector
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
400 TST Q.SEEK,U Same drive/track?
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
401 BNE COMDEXIT If so, no need to seek
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
402 LDD #$143C Seek with verify, allow 3 sec
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
403 BRA STEPEX Execute stepping command
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
404 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
405 * Execute command in A and wait for it to finish. If it runs
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
406 * normally or aborts with an error it will exit through NMI;
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
407 * if it takes an unreasonable amount of time this routine
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
408 * will abort it and set the carry flag. If the command
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
409 * involves head movement, use STEPEX to set step rate.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
410 * On entry, A contains command code and B contains time limit
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
411 * in 50-millisecond increments.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
412 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
413 STEPEX PSHS A Put raw command on stack
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
414 LDA PD.STP,Y Get step rate code
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
415 EORA #3 Convert to 1793's format
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
416 ORA ,S+ Combine with raw command
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
417 COMDEX STA >COMDREG Execute command in A
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
418 CLRA Clear carry flag
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
419 BSR WAIT50MS Wait while command runs
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
420 BCC COMDEXIT Exit if no error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
421 CMPB #E$NOTRDY Test for the three valid
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
422 BEQ KCEXIT error codes for a Type 1
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
423 CMPB #E$SEEK disk controller command --
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
424 BEQ KCEXIT home, seek or force int-
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
425 CMPB #E$CRC errupt -- and return the
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
426 BEQ KCEXIT errors
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
427 COMDEXIT CLRB No error, clear carry
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
428 RTS
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
429 *
1558
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
430 WAIT50MS LDX #$15D8 Almost exactly 50 mSec delay
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
431 WAITIMER LEAX -1,X Wait specified time for disk
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
432 BNE WAITIMER controller to issue NMI
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
433 DECB signaling command completed
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
434 BNE WAIT50MS or aborted with error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
435 KILLCOMD LDA #$D0 Force interrupt, NMI disabled
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
436 STA >COMDREG Abort command in progress
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
437 ERR.NRDY LDB #E$NOTRDY Set error code
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
438 KCEXIT COMA Set carry to flag error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
439 RTS
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
440 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
441 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
442 * Get selected drive ready to read or write. If spindle motors are
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
443 * stopped, start them and wait until they're up to operating
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
444 * speed. Check drive number and select drive if number is valid.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
445 * Monitor index pulses to ensure door is closed, disk inserted
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
446 * and turning, etc. Return appropriate error code if any of
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
447 * these conditions can't be met.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
448 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
449 DSKSTART TST >D.DSKTMR Are drives already running?
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
450 BNE SPINRDY If so, no need to wait
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
451 CLR DRVS.RDY,U No drives are ready
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
452 LDD #$80B Motor on, wait 550 mSec
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
453 STA >DPORT Start spindle motors
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
454 BSR WAIT50MS Wait for motors to start
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
455 SPINRDY LDA PD.DRV,Y Get drive number
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
456 CMPA V.NDRV,U Test for valid drive #
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
457 BHS ERR.UNIT Return error if not
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
458 LEAX TABL.ORG,U Compute address of active
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
459 LDB #DRVMEM drive's parameter table
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
460 MUL TABL.ORG + (D# * tablesize)
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
461 LEAX D,X Add computed offset to origin
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
462 LDA PD.DRV,Y Get drive number again
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
463 LSLA Set corresponding drv select
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
464 BNE NOTDRV0 bit -- 1 for D1, 2 for D2
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
465 INCA Set bit 0 for drive 0
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
466 NOTDRV0 TFR A,B Copy select bit
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
467 ORB #$28 Enable double density
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
468 ORCC #INTMASKS Disable IRQ and FIRQ
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
469 STB >DPORT Enable drive
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
470 STB DPRT.IMG,U Set image byte
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
471 CLR Q.SEEK,U Clear same drive/track flag
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
472 CMPX DRV.ACT,U Is this the same drive?
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
473 BNE NEWDRIVE If not, leave flag zeroed
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
474 LDB #$FF Indicate successive accesses
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
475 STB Q.SEEK,U to the same drive.
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
476 NEWDRIVE STX DRV.ACT,U Store table address
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
477 BITA DRVS.RDY,U Has this drive been ready
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
478 BNE DRVRDY since the motors started?
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
479 PSHS A Save drive select bit
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
480 LDD #$D405 Force int, allow 250 mSec
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
481 BSR COMDEX Look for index pulse
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
482 PSHS CC Save carry flag condition
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
483 BSR KILLCOMD Clear index-pulse NMI state
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
484 PULS CC,A Restore carry flag and A
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
485 BCS RETURN3 Error if no index pulse
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
486 DRVRDY ORA DRVS.RDY,U Set corresponding drive
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
487 STA DRVS.RDY,U ready flag
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
488 LDA #DISKRUN Restart disk rundown timer
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
489 STA >D.DSKTMR
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
490 LDA >STATREG Clear interrupt condition
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
491 CLRB Return no error
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
492 RETURN3 RTS
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
493 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
494 ERR.UNIT COMB Set carry flag
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
495 LDB E$UNIT Set error code
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
496 RTS
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
497 *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
498 EMOD CRC bytes
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
499 SIZE EQU *
4a4ff4d844ef ccdisk.asm: this is "newdisk" found on google, replaces old ccdisk which
boisy
parents: 1533
diff changeset
500 END