annotate 3rdparty/booters/boot_mmc.asm @ 1168:3be7fce1a56b

Added Jim Hathaway's MMC booter, made other source changes
author boisy
date Mon, 19 May 2003 11:22:34 +0000
parents
children 481618f41f1d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1168
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
1 ********************************************************************
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
2 * Boot - MMC Boot Module
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
3 *
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
4 * $Id$
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
5 *
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
6 * This module allows booting from MMC devices using Jim Hathaway's
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
7 * MMC Interface for the Color Computer.
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
8 *
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
9 * This booter was created on May 17th, 2003 by Jim Hathaway and Boisy Pitre
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
10 * at the 12th Annual "Last" Chicago CoCoFEST! in Elgin, Illinois at the
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
11 * Cloud-9 booth.
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
12 *
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
13 * Ed. Comments Who YY/MM/DD
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
14 * ------------------------------------------------------------------
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
15 * 1 Created JH 03/05/17
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
16
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
17 nam Boot
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
18 ttl MMC Boot Module
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
19
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
20 ifp1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
21 use defsfile
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
22 endc
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
23
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
24 tylg set Systm+Objct
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
25 atrv set ReEnt+rev
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
26 rev set 2
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
27 edition set 1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
28
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
29 mod eom,name,tylg,atrv,start,size
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
30
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
31 blockloc rmb 2 pointer to memory requested
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
32 blockimg rmb 2 duplicate of the above
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
33 bootloc rmb 3 sector pointer; not byte pointer
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
34 bootsize rmb 2 size in bytes
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
35 size equ .
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
36
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
37 name fcs /Boot/
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
38 fcb edition
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
39
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
40 start clra
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
41 ldb #size
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
42 clean pshs a
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
43 decb
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
44 bne clean
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
45 tfr s,u get pointer to data area
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
46 pshs u save pointer to data area
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
47
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
48 lda #$d0 forced interrupt; kill floppy activity
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
49 sta $FF48 command register
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
50
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
51 clrb
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
52 pause decb
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
53 bne pause
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
54 lda $FF48 clear controller
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
55 clr $FF40 make sure motors are turned off
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
56
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
57 * Init hardware
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
58 lbsr INITCRD
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
59 bcs error
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
60
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
61 * Request memory for LSN0
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
62 ldd #1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
63 os9 F$SRqMem request one page of RAM
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
64 bcs error
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
65 bsr getpntr
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
66
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
67 * Get LSN0 into memory
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
68 clrb MSB sector
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
69 ldx #0 LSW sector
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
70 bsr mread
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
71 bcs error
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
72 ldd bootsize,u
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
73 bcs error
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
74 pshs d
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
75
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
76 * Return memory
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
77 ldd #$100
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
78 ldu blockloc,u
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
79 os9 F$SRtMem
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
80 puls d
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
81 ifgt Level-1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
82 os9 F$BtMem
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
83 else
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
84 os9 F$SRqMem
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
85 endc
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
86 bcs error
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
87 bsr getpntr
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
88 std blockimg,u
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
89
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
90 * Get os9boot into memory
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
91 ldd bootsize,u
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
92 leas -2,s same as a PSHS D
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
93 getboot std ,s
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
94 ldb bootloc,u MSB sector location
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
95 ldx bootloc+1,u LSW sector location
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
96 bsr mread
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
97 ldd bootloc+1,u update sector location by one to 24bit word
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
98 addd #1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
99 std bootloc+1,u
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
100 ldb bootloc,u
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
101 adcb #0
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
102 stb bootloc,u
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
103 inc blockloc,u update memory pointer for upload
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
104 ldd ,s update size of file left to read
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
105 subd #$100 file read one sector at a time
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
106 bhi getboot
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
107
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
108 leas 4+size,s reset the stack same as PULS U,D
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
109 ldd bootsize,u
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
110 ldx blockimg,u pointer to start of os9boot in memory
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
111 andcc #^Carry clear carry
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
112 rts back to os9p1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
113
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
114 error leas 2+size,s
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
115 rts
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
116
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
117 getpntr tfr u,d save pointer to requested memory
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
118 ldu 2,s recover pointer to data stack
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
119 std blockloc,u
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
120 rts
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
121
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
122 mread tstb
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
123 bne hwread
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
124 cmpx #0
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
125 bne hwread
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
126 bsr hwread
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
127 bcc readlsn0
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
128 rts
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
129
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
130 readlsn0 pshs a,x,y
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
131 ldy blockloc,u
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
132 lda DD.Bt,y os9boot pointer
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
133 ldx DD.Bt+1,y LSW of 24 bit address
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
134 sta bootloc,u
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
135 stx bootloc+1,u
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
136 ldx DD.BSZ,y os9boot size in bytes
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
137 stx bootsize,u
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
138 clrb
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
139 puls a,x,y,pc
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
140
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
141 * Generic read
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
142 hwread pshs x
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
143 lbsr READ
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
144 puls x,pc
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
145
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
146
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
147 CMDREAD equ $51 Command to read a single block
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
148 MMCCSB equ $80 MMC control register slow clock bit
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
149 MMCCRO equ 1 MMC control register offset from data port
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
150 MMCDPR equ $FF7A MMC Data port register
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
151
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
152
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
153
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
154 ********************************
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
155 * Command bytes storage area
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
156 ********************************
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
157 CMD0 fcb $40,0,0,0
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
158 CMD1 fcb $41,0,0,0
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
159 CMD171 fcb $50,0,0,1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
160
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
161 ***************************************************************
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
162 * Send a command string to the MMC (6 bytes) 4 user 2 hard code
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
163 * Entry: y= Pointer to command string to send
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
164 * x= MMC data register
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
165 * b= Not used
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
166 * a= Used to copy data
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
167 ***************************************************************
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
168 SNDC lda ,y Get cmd byte 1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
169 sta ,x Send command byte
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
170 lbsr DLYSTRT Call our delay routine
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
171 lda 1,y Get cmd byte 2
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
172 sta ,x Send command byte
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
173 lbsr DLYSTRT Call our delay routine
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
174 lda 2,y Get cmd byte 3
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
175 sta ,x Send command byte
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
176 lbsr DLYSTRT Call our delay routine
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
177 lda 3,y Get cmd byte 4
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
178 sta ,x Send command byte
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
179 lbsr DLYSTRT Call our delay routine
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
180 lda #0 Get cmd byte 5
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
181 sta ,x Send command byte
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
182 lbsr DLYSTRT Call our delay routine
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
183 lda #$95 Get cmd byte 6
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
184 sta ,x Send command byte
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
185 lbsr DLYSTRT Call our delay routine
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
186 rts Complete sending command return
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
187
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
188 ***********************************************************
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
189 * CHKR - Check card response
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
190 * Used to check response from a card
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
191 * Entry: a= Expected Response byte code
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
192 * b= used for loop / set on exit to flag error/no error
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
193 ***********************************************************
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
194 CHKR pshs b Save reg b
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
195 clrb Use for loop counter
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
196 CHKRL1 bsr DLYSTRT Call our delay routine
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
197 cmpa ,x Check for response
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
198 beq CHKRG Response is good, exit without error
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
199 decb Keep looping?
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
200 bne CHKRL1 Done yet?
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
201 CHKRB comb Set error state
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
202 puls b,pc Return
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
203 CHKRG clrb Set no error
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
204 puls b,pc Return
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
205 * End CHKR routine
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
206
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
207 *********************************************************************
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
208 * DLYSTRT: Delay routine for use as a delay for sending commands
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
209 * or clock pulses as the slower spi rate.
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
210 * Delay is hard coded at $14
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
211 * All registers perserved
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
212 *********************************************************************
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
213 DLYSTRT pshs b Save b register for return
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
214 ldb #$14 Default delay needed
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
215 DLYLP1 decb Start of delay loop
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
216 bne DLYLP1 End of delay loop
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
217 puls b,pc Get value of b register back
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
218 * End delay routine
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
219
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
220 ************************************************************
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
221 * INITCRD: Init a single card, no register values needed,
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
222 * all preserved
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
223 * Entry: y = Used, and not preserved
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
224 * x = Address to MMC data port
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
225 ************************************************************
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
226 INITCRD ldx #MMCDPR Address to MMC
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
227 lda #MMCCSB Select no cards and slow speed
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
228 sta MMCCRO,x Store to control register
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
229 lda #$0A A= 10 clocks
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
230 CLKPL1 tst ,x Pulse the clock 80 times to init all cards
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
231 bsr DLYSTRT Call our delay routine
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
232 deca Loop counter
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
233 bne CLKPL1 Keep looping till we send 80 clocks
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
234
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
235 lda #$81 Select crd 1 @ slow speed
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
236 sta MMCCRO,x Write to MMC control register slow speed
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
237 leay CMD0,pcr Load address into y for cmd0
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
238 lbsr SNDC Go send the command (cmd0)
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
239
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
240 lda #$01 Expected response
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
241 lbsr CHKR Go check for response bit
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
242 lbcs INITCE1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
243
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
244 ldb #20 Number of times to send CMD1 before error
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
245
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
246 leay CMD1,pcr Load address into y for cmd1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
247 INCMD1L lbsr SNDC Go send the command (cmd1)
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
248
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
249 lda #$00 Expected response
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
250 lbsr CHKR Go check for response bit
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
251 bcc INC1C We got our response, continue
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
252
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
253 decb Loop counter
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
254 bne INCMD1L Keep trying to get a response of 0
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
255 lbcc INC1C
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
256 lda #81
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
257 lbra INITCE1 This card is not ready exit
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
258
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
259 INC1C lda #$01 Get card number, always use card 0
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
260 sta MMCCRO,x Write to MMC control register full speed
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
261 leay CMD171,pcr Get command to change sector to 256 bytes
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
262 lbsr SNDC Go send the command (cmd17-1)
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
263
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
264 lda #0 Expected response
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
265 lbsr CHKR Go check for response byte
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
266 bcs INITCE1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
267
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
268 clrb No error
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
269 puls pc Clean exit
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
270
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
271 INITCE1 comb Error, we could not init card
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
272 tfr a,b
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
273 puls pc
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
274 * End of INITCRD
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
275
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
276 *****************************************************************
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
277 * READ - Read a single 256 byte sector.
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
278 * y= Location to store data to
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
279 * b,x= LSN number
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
280 * x not preserved
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
281 *****************************************************************
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
282 READ pshs d,x Save LSN
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
283 ldy blockloc,u
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
284 lda #$1 Get drive #1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
285 sta MMCCRO+MMCDPR Select card 1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
286 lda MMCDPR Burn a byte - bug fix
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
287
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
288 lda #CMDREAD Read cmd byte 1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
289 sta MMCDPR Save read command
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
290 nop Delay
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
291 stb MMCDPR Save cmd byte 2
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
292 tfr x,d Move the rest of the LSN
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
293 sta MMCDPR Save cmd byte 3
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
294 ldx #MMCDPR Get MMC address and delay
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
295 stb ,x Save cmd byte 4
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
296 lda #$0 Cmd byte 5
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
297 sta ,x Save cmd byte 5
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
298 lda #$95 Cmd byte 6 CRC
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
299 sta ,x Save cmd byte 6
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
300
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
301 RDN2 lda #$FE Expected response
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
302 lbsr CHKR Check for response
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
303 bcs RDEEX1 Card should have read sector, read error!
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
304
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
305 clra Number of loops 256
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
306 RDLP1 ldb ,x Get byte from MMC
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
307 stb ,y+ Save byte
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
308 deca Loop counter
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
309 bne RDLP1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
310
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
311 ldd ,x Get CRC Byte 1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
312 lda ,x Get CRC Byte 2
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
313
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
314 RDEX1 clr MMCCRO,x Deselect any cards in use
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
315 clrb Set no errors
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
316 puls d,x,pc Read complete with no errors
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
317 RDEEX1 clr MMCCRO,x Deselect any cards in use
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
318 comb Error reading sector
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
319 puls d,x,pc Return with error
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
320 * End of READ
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
321
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
322
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
323 ifgt Level-1
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
324 * Fillers to get to $1D0
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
325 Pad fill $39,$1D0-3-*
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
326 endc
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
327
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
328 emod
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
329 eom equ *
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
330 end
3be7fce1a56b Added Jim Hathaway's MMC booter, made other source changes
boisy
parents:
diff changeset
331