Fix for non-SDHC SDV2

This commit is contained in:
Unknown 2017-12-16 10:57:31 +01:00 committed by Florian Reitz
parent 0b33b5d385
commit 4cd6a76790
3 changed files with 100 additions and 67 deletions

Binary file not shown.

View File

@ -1,71 +1,71 @@
:10000000A220A200A203A23C0878A960853D203D61
:1000100000BABD00018DF807290F28853D0A0A0A9C
:100020000A852BAA2CFFCFA000B9B7CAF008098017
:10003000995007C810F32C61C0300520B7C9900B48
:100020000A852BAA2CFFCFA000B9DECAF0080980F0
:10003000995007C810F32C61C0300520DEC9900B21
:10004000ADF8073A854164406C40002000C8A90122
:100050008542A62B8643A9088545644464476446C7
:100060002CFFCF20DDC9A9018542A62B8643A90A12
:10007000854564446447A90185462CFFCF20DDC92E
:100060002CFFCF2004CAA9018542A62B8643A90AEA
:10007000854564446447A90185462CFFCF2004CA06
:10008000A62B4C0108D848A52B48A53D48A54048BB
:10009000A541480878A960853D203D00BABD000112
:1000A0008DF807290F28853D0A0A0A0A852BAA2CF4
:1000B000FFCF20B7C99004A92F802CA9803C83C012
:1000B000FFCF20DEC99004A92F802CA9803C83C0EB
:1000C000F020A542F00DC901F00EC902F00FA90100
:1000D00038801420CFC9800F20DDC9800A2046CA8D
:1000D00038801420F6C9800F2004CA800A206DCA17
:1000E00080052000C890DBBA9D05016885416885C0
:1000F0004068853D68852B6860000000FFFF97859C
:10010000A9039D81C0BD83C009019D83C0A9079D2E
:1001100082C0A00AA9FF9D80C03C81C010FB88D08E
:10012000F5BD83C029FE9D83C0A9DE8540A9CA858F
:100130004120F2C82006C9C901D041A9EA8540A9D9
:10014000CA854120F2C8201FC9C901D032A9F6854D
:1001500040A9CA854120F2C82006C9A9FC8540A94A
:10016000CA854120F2C82006C9C901F0E0C900D003
:100170000BBD83C009109D83C04CB9C84CE0C8A911
:10018000F68540A9CA854120F2C8A9028540A9CBBD
:10019000854120F2C82006C9C901F0E3C900D00397
:1001A0004CB9C8A9E48540A9CA854120F2C82006F7
:1001B000C9C901F0F6C900D027A9F08540A9CA85B0
:1001C0004120F2C82006C9C900D015BD83C00980EE
:1001D0009D83C0BD81C009049D81C018A00090030B
:1001E00038A027BD83C009019D83C0A9009D82C09E
:1001F00098605AA000B1409D80C03C81C010FBC8EF
:10020000C00690F17A60A9FF9D80C03C81C010FBC0
:10021000BD80C08980D0EF48A9FF9D80C068602064
:1002200006C9485AA004A9FF9D80C03C81C010FBAC
:10023000BD80C04888D0EFA43D6899F805689978DA
:10024000056899F804689978047AA9FF9D80C068C8
:1002500060DA5A8AA8A63DA5469DF805A5479D786F
:1002600005A9009DF8049D7804A9802543F005A9FF
:10027000019DF804A9103983C0D011A0091EF8050A
:100280003E78053EF8043E780488D0F17AFA605A48
:10029000A43D9D80C0B978049D80C0B9F8049D80BC
:1002A000C0B978059D80C0B9F8059D80C0A9FF9DA3
:1002B00080C02006C97A6048A9403C83C018F0017C
:1002C00038686048A9203C83C018F001386860A9EC
:1002D0000020C3C99002A92BA2FFA0FF602051C932
:1002E000BD83C029FE9D83C0A951208FC9C900D0FC
:1002F00050A9FF9D80C0BD80C0C9FED0F4BD81C0A3
:1003000009109D81C0A9FF9D80C0A000BD80C09143
:1003100044C8D0F8E645BD80C09144C8D0F8C64571
:10032000BD80C0BD80C0BD80C0BD81C029EF9D81A2
:10033000C018A9000848BD83C009019D83C0682872
:100340006038A92780EE20C3C9B0672051C9BD839A
:10035000C029FE9D83C0A958208FC9C900D04EA9CD
:10036000FF9D80C0A9FE9D80C0A000B1449D80C0BB
:10037000C8D0F8E645B1449D80C0C8D0F8C645A9AC
:10038000FF9D80C09D80C09D80C0BD80C0291FC9C9
:1003900005D01A18A9000848A9FF9D80C0BD80C0DB
:1003A000F0F6BD83C009019D83C068286038A92785
:1003B00080E438A92B80DF20204170706C655D5B84
:1003C00053642076312E3020286329323031372093
:1003D000466C6F7269616E20526569747A004000E4
:1003E000000000954100000000F948000001AA87C4
:1003F0005000000200FF7700000000656940000027
:1004000000776900000000FF00000000000000000D
:1004100000000000000000000000000000000000DC
:1004200000000000000000000000000000000000CC
:1004300000000000000000000000000000000000BC
:10012000F5BD83C029FE9D83C0A9058540A9CB8567
:10013000412016C9202AC9C901D065A9118540A945
:10014000CB85412016C92043C9C901D056A43DB969
:10015000F805C9AAD04AA91D8540A9CB854120161A
:10016000C9202AC9A9298540A9CB85412016C920C3
:100170002AC9C901F0E0C900D026A9238540A9CB2E
:1001800085412016C92043C9C900D014A43DB978BF
:10019000042940F048BD83C009109D83C04CEFC8BE
:1001A0004C04C9A91D8540A9CB85412016C9A92F9A
:1001B0008540A9CB85412016C9202AC9C901F0E391
:1001C000C900D0034CDDC8A90B8540A9CB854120CF
:1001D00016C9202AC9C901F0F6C900D027A9178578
:1001E00040A9CB85412016C9202AC9C900D015BD18
:1001F00083C009809D83C0BD81C009049D81C01852
:10020000A000900338A027BD83C009019D83C0A929
:10021000009D82C098605AA000B1409D80C03C8182
:10022000C010FBC8C00690F17A60A9FF9D80C03C59
:1002300081C010FBBD80C08980D0EF48A9FF9D80A0
:10024000C06860202AC9485AA0044C52C9A9FF9D21
:1002500080C03C81C010FBBD80C04888D0EFA43D69
:100260006899F805689978056899F8046899780498
:100270007AA9FF9D80C06860DA5A8AA8A63DA54683
:100280009DF805A5479D7805A9009DF8049D780473
:10029000A9802543F005A9019DF804A9103983C060
:1002A000D011A0091EF8053E78053EF8043E7804FA
:1002B00088D0F17AFA605AA43D9D80C0B978049D37
:1002C00080C0B9F8049D80C0B978059D80C0B9F898
:1002D000059D80C0A9FF9D80C0202AC97A6048A9D9
:1002E000403C83C018F00138686048A9203C83C0B6
:1002F00018F001386860A90020EAC99002A92BA271
:10030000FFA0FF602078C9BD83C029FE9D83C0A9DE
:100310005120B6C9C900D050A9FF9D80C0BD80C082
:10032000C9FED0F4BD81C009109D81C0A9FF9D8088
:10033000C0A000BD80C09144C8D0F8E645BD80C0D3
:100340009144C8D0F8C645BD80C0BD80C0BD80C046
:10035000BD81C029EF9D81C018A9000848BD83C098
:1003600009019D83C068286038A92780EE20EAC96A
:10037000B0672078C9BD83C029FE9D83C0A95820DD
:10038000B6C9C900D04EA9FF9D80C0A9FE9D80C0FE
:10039000A000B1449D80C0C8D0F8E645B1449D801E
:1003A000C0C8D0F8C645A9FF9D80C09D80C09D8073
:1003B000C0BD80C0291FC905D01A18A9000848A9C6
:1003C000FF9D80C0BD80C0F0F6BD83C009019D8344
:1003D000C068286038A92780E438A92B80DF202056
:1003E0004170706C655D5B53642076312E3120283E
:1003F00063293230313720466C6F7269616E20524A
:100400006569747A0040000000009541000000001A
:10041000F948000001AA875000000200FF770000A1
:100420000000FF7A00000000FF69400000007769CB
:1004300000000000FF0000000000000000000000BD
:1004400000000000000000000000000000000000AC
:10045000000000000000000000000000000000009C
:10046000000000000000000000000000000000008C

View File

@ -1,7 +1,7 @@
;*******************************
;
; Apple][Sd Firmware
; Version 1.0
; Version 1.1
;
; (c) Florian Reitz, 2017
;
@ -162,6 +162,8 @@ INITED = $80
;*******************************
.else
;@BOOT: CMP #0
; BNE @NEXTSLOT ; init not successful
@BOOT: LDA #$01
STA DCMD ; load command
LDX SLOT16
@ -288,13 +290,24 @@ DRIVER: CLD
RTS
;*******************************
;
; Signature bytes
;
; 65535 blocks
; Removable media
; Non-interruptable
; 2 drives
; Read, write and status allowed
;
;*******************************
.segment "SLOTID"
.dbyt $FFFF ; 65535 blocks
.byt $97 ; Status bits
.byt <DRIVER ; LSB of driver
;*******************************
;
; Initialize SD card
@ -341,18 +354,22 @@ INIT: LDA #$03 ; set SPI mode 3
LDA #>CMD8
STA CMDHI
JSR SDCMD
JSR GETR3
JSR GETR3 ; R7 is also 1+4 bytes
CMP #$01
BNE @SDV1 ; may be SD Ver. 1
; check for $01aa match!
LDY SLOT ; check for $aa in R33
LDA R33,Y
CMP #$AA
BNE @ERROR1 ; error!
@SDV2: LDA #<CMD55
STA CMDLO
LDA #>CMD55
STA CMDHI
JSR SDCMD
JSR GETR1
LDA #<ACMD4140
LDA #<ACMD4140 ; enable SDHC support
STA CMDLO
LDA #>ACMD4140
STA CMDHI
@ -362,12 +379,25 @@ INIT: LDA #$03 ; set SPI mode 3
BEQ @SDV2 ; wait for ready
CMP #0
BNE @ERROR1 ; error!
; send CMD58
; SD Ver. 2 initialized!
LDA SS,X
LDA #<CMD58 ; check for SDHC
STA CMDLO
LDA #>CMD58
STA CMDHI
JSR SDCMD
JSR GETR3
CMP #0
BNE @ERROR1 ; error!
LDY SLOT
LDA R30,Y
AND #$40 ; check CCS
BEQ @BLOCKSZ
LDA SS,X ; card is SDHC
ORA #SDHC
STA SS,X
JMP @BLOCKSZ
JMP @END
@ERROR1: JMP @IOERROR ; needed for far jump
@ -473,7 +503,7 @@ GETR1: LDA #DUMMY
;*******************************
;
; Get R3
; Get R3 or R7
; R1 is in A
; R3 is in scratchpad ram
;
@ -483,6 +513,7 @@ GETR3: JSR GETR1 ; get R1 first
PHA ; save R1
PHY ; save Y
LDY #04 ; load counter
JMP @WAIT ; first byte is already there
@LOOP: LDA #DUMMY ; send dummy
STA DATA,X
@WAIT: BIT CTRL,X
@ -499,7 +530,7 @@ GETR3: JSR GETR1 ; get R1 first
PLA
STA R31,Y
PLA
STA R30,Y
STA R30,Y ; R30 is MSB
PLY ; restore Y
LDA #DUMMY
STA DATA,X ; send another dummy
@ -869,7 +900,7 @@ TEST: LDA SLOT16
.endif
TEXT: .asciiz " Apple][Sd v1.0 (c)2017 Florian Reitz"
TEXT: .asciiz " Apple][Sd v1.1 (c)2017 Florian Reitz"
CMD0: .byt $40, $00, $00
.byt $00, $00, $95
@ -880,7 +911,9 @@ CMD8: .byt $48, $00, $00
CMD16: .byt $50, $00, $00
.byt $02, $00, $FF
CMD55: .byt $77, $00, $00
.byt $00, $00, $65
.byt $00, $00, $FF
CMD58: .byt $7A, $00, $00
.byt $00, $00, $FF
ACMD4140: .byt $69, $40, $00
.byt $00, $00, $77
ACMD410: .byt $69, $00, $00