From 048d1df99a4dfb6f54218cc541318e9a8e47c06f Mon Sep 17 00:00:00 2001 From: Florian Reitz Date: Sun, 13 May 2018 17:58:02 +0200 Subject: [PATCH] Error codes added --- src/AppleIISd.inc | 20 +++++++++++++++++--- src/AppleIISd.s | 17 +++++++++-------- src/Helper.s | 6 +++--- src/ProDOS.s | 17 ++++++++--------- src/Smartport.s | 2 +- 5 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/AppleIISd.inc b/src/AppleIISd.inc index 24fea4b..5c7312d 100644 --- a/src/AppleIISd.inc +++ b/src/AppleIISd.inc @@ -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 diff --git a/src/AppleIISd.s b/src/AppleIISd.s index 2a43f02..bbfff56 100644 --- a/src/AppleIISd.s +++ b/src/AppleIISd.s @@ -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 diff --git a/src/Helper.s b/src/Helper.s index d08dd0a..3915b5e 100644 --- a/src/Helper.s +++ b/src/Helper.s @@ -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? diff --git a/src/ProDOS.s b/src/ProDOS.s index e85bfd4..7d045d0 100644 --- a/src/ProDOS.s +++ b/src/ProDOS.s @@ -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 diff --git a/src/Smartport.s b/src/Smartport.s index 5f621c5..4d10ec1 100644 --- a/src/Smartport.s +++ b/src/Smartport.s @@ -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