Error codes added

This commit is contained in:
Florian Reitz 2018-05-13 17:58:02 +02:00
parent 2daaa107a0
commit 048d1df99a
5 changed files with 38 additions and 24 deletions

View File

@ -1,10 +1,10 @@
;*******************************
;
; Apple][Sd Firmware
; Version 1.1
; Version 1.2
; Defines
;
; (c) Florian Reitz, 2017
; (c) Florian Reitz, 2017 - 2018
;
; X register usually contains SLOT16
; Y register is used for counting or SLOT
@ -19,7 +19,7 @@ CMDHI := $41
; ProDOS equates
DCMD := $42 ; Command code
DNUMBER := $43 ; drive number
DSNUMBER := $43 ; drive / slot number
BUFFER := $44 ; buffer pointer
BLOCK := $46 ; block number
@ -55,3 +55,17 @@ SDHC = $10
WP = $20
CD = $40
INITED = $80
; Error codes
NO_ERR = $00
ERR_BAD_CMD = $01
ERR_BAD_PCNT = $04
ERR_BUS_ERR = $06
ERR_BAD_UNIT = $11
ERR_BAD_CTL = $21
ERR_BAD_CTL_PARM = $22
ERR_IO_ERR = $27
ERR_NO_DRIVE = $28
ERR_NO_WRITE = $2B
ERR_BAD_BLOCK = $2D
ERR_OFF_LINE = $2F

View File

@ -4,7 +4,7 @@
; Version 1.2
; Main source
;
; (c) Florian Reitz, 2017
; (c) Florian Reitz, 2017 - 2018
;
; X register usually contains SLOT16
; Y register is used for counting or SLOT
@ -96,7 +96,7 @@ PRODOS:
LDA #$01 ; READ
STA DCMD ; load command
STX $43 ; slot number
STX DSNUMBER ; slot number
LDA #$0A
STA BUFFER+1 ; buffer hi
STZ BUFFER ; buffer lo
@ -149,20 +149,21 @@ DRIVER: BRA @SAVEZP ; jump to ProDOS entry
BIT $CFFF
JSR CARDDET
BCC @INITED
LDA #$2F ; no card inserted
LDA ERR_OFF_LINE; no card inserted
BRA @RESTZP
@INITED: LDA #INITED ; check for init
BIT SS,X
BEQ @INIT
; TODO use jump table
@CMD: LDA DCMD ; get command
BEQ @STATUS ; branch if cmd is 0
CMP #1
BEQ @READ
CMP #2
BEQ @WRITE
LDA #1 ; unknown command
LDA ERR_BAD_CMD ; unknown command
SEC
BRA @RESTZP
@ -210,7 +211,7 @@ INIT: LDA #$03 ; set SPI mode 3
LDA SS,X
ORA #SS0 ; set CS high
STA SS,X
LDA #7
LDA #7 ; set 400 kHz
STA DIV,X
LDY #10
LDA #DUMMY
@ -331,11 +332,11 @@ INIT: LDA #$03 ; set SPI mode 3
ORA #ECE ; enable 7MHz
STA CTRL,X
CLC ; all ok
LDY #0
LDY NO_ERR
BCC @END1
@IOERROR: SEC
LDY #$27 ; init error
LDY ERR_IO_ERR ; init error
@END1: LDA SS,X ; set CS high
ORA #SS0
STA SS,X
@ -345,7 +346,7 @@ INIT: LDA #$03 ; set SPI mode 3
RTS
TEXT: .asciiz " Apple][Sd v1.2 (c)2017 Florian Reitz"
TEXT: .asciiz " Apple][Sd v1.2 (c)2018 Florian Reitz"
CMD0: .byt $40, $00, $00
.byt $00, $00, $95

View File

@ -4,7 +4,7 @@
; Version 1.2
; Helper functions
;
; (c) Florian Reitz, 2017
; (c) Florian Reitz, 2017 - 2018
;
; X register usually contains SLOT16
; Y register is used for counting or SLOT
@ -122,7 +122,7 @@ GETBLOCK: PHX ; save X
STZ R30,X
LDA #$80 ; drive number
AND DNUMBER
AND DSNUMBER
BEQ @SLOT ; D1
LDA #1 ; D2
STA R31,X
@ -130,7 +130,7 @@ GETBLOCK: PHX ; save X
@SLOT: LDA SLOT
PHA ; save SLOT
LDA #$70 ; slot number * 16
AND DNUMBER
AND DSNUMBER
STA SLOT
CPY SLOT
BEQ @RESTORE ; slot number = real slot?

View File

@ -4,7 +4,7 @@
; Version 1.2
; ProDOS functions
;
; (c) Florian Reitz, 2017
; (c) Florian Reitz, 2017 - 2018
;
; X register usually contains SLOT16
; Y register is used for counting or SLOT
@ -37,16 +37,15 @@
; Set - Error
; A $00 - No error
; $2B - Card write protected
; $2F - No card inserted
; X - Blocks avail (low byte)
; Y - Blocks avail (high byte)
;
;*******************************
STATUS: LDA #0 ; no error
STATUS: LDA NO_ERR ; no error
JSR WRPROT
BCC @DONE
LDA #$2B ; card write protected
LDA ERR_NO_WRITE; card write protected
@DONE: LDX #$FF ; 32 MB partition
LDY #$FF
@ -109,7 +108,7 @@ READ: JSR GETBLOCK ; calc block address
AND #<~FRX
STA CTRL,X
CLC ; no error
LDA #0
LDA NO_ERR
@DONE: PHP
PHA
@ -121,7 +120,7 @@ READ: JSR GETBLOCK ; calc block address
RTS
@ERROR: SEC ; an error occured
LDA #$27
LDA ERR_IO_ERR
BRA @DONE
@ -180,7 +179,7 @@ WRITE: JSR WRPROT
CMP #$05
BNE @IOERROR ; check for write error
CLC ; no error
LDA #0
LDA NO_ERR
@DONE: PHP
PHA
@ -197,9 +196,9 @@ WRITE: JSR WRPROT
RTS
@IOERROR: SEC ; an error occured
LDA #$27
LDA ERR_IO_ERR
BRA @DONE
@WPERROR: SEC
LDA #$2B
LDA ERR_NO_WRITE
BRA @DONE

View File

@ -4,7 +4,7 @@
; Version 1.2
; Smartport functions
;
; (c) Florian Reitz, 2017
; (c) Florian Reitz, 2017 - 2018
;
; X register usually contains SLOT16
; Y register is used for counting or SLOT