Check card status in ProDOS commands
This commit is contained in:
parent
c3d693f268
commit
71428384cc
Binary file not shown.
Binary file not shown.
|
@ -57,7 +57,7 @@ SS0 = $01 ; SS register
|
||||||
SDHC = $10
|
SDHC = $10
|
||||||
WP = $20
|
WP = $20
|
||||||
CD = $40
|
CD = $40
|
||||||
INITED = $80
|
CARD_INIT = $80
|
||||||
|
|
||||||
SMDRIVERVER = $120B ; Version 1.2 Beta
|
SMDRIVERVER = $120B ; Version 1.2 Beta
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,15 @@
|
||||||
;
|
;
|
||||||
;*******************************
|
;*******************************
|
||||||
|
|
||||||
|
.export INIT
|
||||||
|
|
||||||
.import PRODOS
|
.import PRODOS
|
||||||
.import SMARTPORT
|
.import SMARTPORT
|
||||||
.import GETR1
|
.import GETR1
|
||||||
.import GETR3
|
.import GETR3
|
||||||
.import SDCMD
|
.import SDCMD
|
||||||
.import CARDDET
|
.import CARDDET
|
||||||
|
.import INITED
|
||||||
.import READ
|
.import READ
|
||||||
|
|
||||||
.include "AppleIISd.inc"
|
.include "AppleIISd.inc"
|
||||||
|
@ -158,14 +161,8 @@ DRIVER: CLC ; ProDOS entry
|
||||||
STA SLOT16 ; $s0
|
STA SLOT16 ; $s0
|
||||||
TAX ; X holds now SLOT16
|
TAX ; X holds now SLOT16
|
||||||
|
|
||||||
JSR CARDDET
|
JSR INITED ; check for init
|
||||||
BCC @INITED
|
BCC @DISP
|
||||||
LDA #ERR_OFFLINE; no card inserted
|
|
||||||
BRA @END
|
|
||||||
|
|
||||||
@INITED: LDA #INITED ; check for init
|
|
||||||
BIT SS,X
|
|
||||||
BNE @DISP
|
|
||||||
JSR INIT
|
JSR INIT
|
||||||
BCS @END ; Init failed
|
BCS @END ; Init failed
|
||||||
|
|
||||||
|
@ -339,7 +336,7 @@ INIT: STZ CTRL,X ; reset SPI controller
|
||||||
BNE @IOERROR ; error!
|
BNE @IOERROR ; error!
|
||||||
|
|
||||||
@END: LDA SS,X
|
@END: LDA SS,X
|
||||||
ORA #INITED ; initialized
|
ORA #CARD_INIT ; initialized
|
||||||
STA SS,X
|
STA SS,X
|
||||||
LDA CTRL,X
|
LDA CTRL,X
|
||||||
ORA #ECE ; enable 7MHz
|
ORA #ECE ; enable 7MHz
|
||||||
|
|
|
@ -1,23 +1,25 @@
|
||||||
;*******************************
|
;*******************************
|
||||||
;
|
;
|
||||||
; Apple][Sd Firmware
|
; Apple][Sd Firmware
|
||||||
; Version 1.2
|
; Version 1.2.2
|
||||||
; Helper functions
|
; Helper functions
|
||||||
;
|
;
|
||||||
; (c) Florian Reitz, 2017 - 2018
|
; (c) Florian Reitz, 2017 - 2020
|
||||||
;
|
;
|
||||||
; X register usually contains SLOT16
|
; X register usually contains SLOT16
|
||||||
; Y register is used for counting or SLOT
|
; Y register is used for counting or SLOT
|
||||||
;
|
;
|
||||||
;*******************************
|
;*******************************
|
||||||
|
|
||||||
.export COMMAND
|
|
||||||
.export SDCMD
|
.export SDCMD
|
||||||
.export GETBLOCK
|
|
||||||
.export CARDDET
|
|
||||||
.export WRPROT
|
|
||||||
.export GETR1
|
.export GETR1
|
||||||
.export GETR3
|
.export GETR3
|
||||||
|
.export GETBLOCK
|
||||||
|
.export COMMAND
|
||||||
|
.export CARDDET
|
||||||
|
.export WRPROT
|
||||||
|
.export INITED
|
||||||
|
|
||||||
|
|
||||||
.include "AppleIISd.inc"
|
.include "AppleIISd.inc"
|
||||||
.segment "EXTROM"
|
.segment "EXTROM"
|
||||||
|
@ -212,3 +214,23 @@ WRPROT: PHA
|
||||||
SEC
|
SEC
|
||||||
@DONE: PLA
|
@DONE: PLA
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
|
||||||
|
;*******************************
|
||||||
|
;
|
||||||
|
; Check if card is initialized
|
||||||
|
; X must contain SLOT16
|
||||||
|
;
|
||||||
|
; C Clear - card initialized
|
||||||
|
; Set - card not initialized
|
||||||
|
;
|
||||||
|
;*******************************
|
||||||
|
|
||||||
|
INITED: PHA
|
||||||
|
LDA #CARD_INIT ; 0: card not initialized
|
||||||
|
BIT SS,X ; 1: card initialized
|
||||||
|
CLC
|
||||||
|
BNE @DONE
|
||||||
|
SEC
|
||||||
|
@DONE: PLA
|
||||||
|
RTS
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
;*******************************
|
;*******************************
|
||||||
;
|
;
|
||||||
; Apple][Sd Firmware
|
; Apple][Sd Firmware
|
||||||
; Version 1.2
|
; Version 1.2.2
|
||||||
; ProDOS functions
|
; ProDOS functions
|
||||||
;
|
;
|
||||||
; (c) Florian Reitz, 2017 - 2018
|
; (c) Florian Reitz, 2017 - 2020
|
||||||
;
|
;
|
||||||
; X register usually contains SLOT16
|
; X register usually contains SLOT16
|
||||||
; Y register is used for counting or SLOT
|
; Y register is used for counting or SLOT
|
||||||
|
@ -19,6 +19,9 @@
|
||||||
.import COMMAND
|
.import COMMAND
|
||||||
.import SDCMD
|
.import SDCMD
|
||||||
.import GETBLOCK
|
.import GETBLOCK
|
||||||
|
.import CARDDET
|
||||||
|
.import INITED
|
||||||
|
.import INIT
|
||||||
.import WRPROT
|
.import WRPROT
|
||||||
.import GETR1
|
.import GETR1
|
||||||
.import GETR3
|
.import GETR3
|
||||||
|
@ -67,6 +70,7 @@ PRODOS: LDA DCMD ; get command
|
||||||
; C Clear - No error
|
; C Clear - No error
|
||||||
; Set - Error
|
; Set - Error
|
||||||
; A $00 - No error
|
; A $00 - No error
|
||||||
|
; $28 - No card inserted
|
||||||
; $2B - Card write protected
|
; $2B - Card write protected
|
||||||
; X - Blocks avail (low byte)
|
; X - Blocks avail (low byte)
|
||||||
; Y - Blocks avail (high byte)
|
; Y - Blocks avail (high byte)
|
||||||
|
@ -74,7 +78,12 @@ PRODOS: LDA DCMD ; get command
|
||||||
;*******************************
|
;*******************************
|
||||||
|
|
||||||
STATUS: LDA #NO_ERR ; Thanks for this one, Antoine!
|
STATUS: LDA #NO_ERR ; Thanks for this one, Antoine!
|
||||||
JSR WRPROT
|
JSR CARDDET
|
||||||
|
BCC @WRPROT
|
||||||
|
LDA #ERR_NODRIVE; no card inserted
|
||||||
|
BNE @DONE
|
||||||
|
|
||||||
|
@WRPROT: JSR WRPROT
|
||||||
BCC @DONE
|
BCC @DONE
|
||||||
LDA #ERR_NOWRITE; card write protected
|
LDA #ERR_NOWRITE; card write protected
|
||||||
|
|
||||||
|
@ -94,10 +103,20 @@ STATUS: LDA #NO_ERR ; Thanks for this one, Antoine!
|
||||||
; Set - Error
|
; Set - Error
|
||||||
; A $00 - No error
|
; A $00 - No error
|
||||||
; $27 - Bad block number
|
; $27 - Bad block number
|
||||||
|
; $28 - No card inserted
|
||||||
;
|
;
|
||||||
;*******************************
|
;*******************************
|
||||||
|
|
||||||
READ: JSR GETBLOCK ; calc block address
|
READ: JSR CARDDET ; check for card
|
||||||
|
BCS @NDERROR ; no card
|
||||||
|
|
||||||
|
JSR INITED ; check for initialization
|
||||||
|
BCC @GETBLOCK
|
||||||
|
|
||||||
|
JSR INIT ; initialize card
|
||||||
|
BCS @NDERROR ; init failed
|
||||||
|
|
||||||
|
@GETBLOCK: JSR GETBLOCK ; calc block address
|
||||||
|
|
||||||
LDA SS,X ; enable /CS
|
LDA SS,X ; enable /CS
|
||||||
AND #<~SS0
|
AND #<~SS0
|
||||||
|
@ -105,7 +124,7 @@ READ: JSR GETBLOCK ; calc block address
|
||||||
LDA #$51 ; send CMD17
|
LDA #$51 ; send CMD17
|
||||||
JSR COMMAND ; send command
|
JSR COMMAND ; send command
|
||||||
CMP #0
|
CMP #0
|
||||||
BNE @ERROR ; check for error
|
BNE @IOERROR ; check for error
|
||||||
|
|
||||||
@GETTOK: LDA #DUMMY ; get data token
|
@GETTOK: LDA #DUMMY ; get data token
|
||||||
STA DATA,X
|
STA DATA,X
|
||||||
|
@ -150,10 +169,14 @@ READ: JSR GETBLOCK ; calc block address
|
||||||
PLP
|
PLP
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@ERROR: SEC ; an error occured
|
@IOERROR: SEC ; an error occured
|
||||||
LDA #ERR_IOERR
|
LDA #ERR_IOERR
|
||||||
BRA @DONE
|
BRA @DONE
|
||||||
|
|
||||||
|
@NDERROR: SEC ; an error occured
|
||||||
|
LDA #ERR_NODRIVE
|
||||||
|
BRA @DONE
|
||||||
|
|
||||||
|
|
||||||
;*******************************
|
;*******************************
|
||||||
;
|
;
|
||||||
|
|
Loading…
Reference in New Issue