Merge branch 'fixes'

This commit is contained in:
Florian Reitz 2021-02-05 17:40:05 +01:00
commit 996f8555de
7 changed files with 74 additions and 36 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,10 +1,10 @@
;*******************************
;
; Apple][Sd Firmware
; Version 1.2
; Version 1.2.2
; Defines
;
; (c) Florian Reitz, 2017 - 2018
; (c) Florian Reitz, 2017 - 2020
;
; X register usually contains SLOT16
; Y register is used for counting or SLOT
@ -44,7 +44,6 @@ DRVNUM := $0678
CURSLOT := $07F8 ; $Cs
; Rom equates
KNOWNRTS := $FF58
OAPPLE := $C061 ; open apple key
DATA := $C080
CTRL := DATA+1
@ -58,7 +57,7 @@ SS0 = $01 ; SS register
SDHC = $10
WP = $20
CD = $40
INITED = $80
CARD_INIT = $80
SMDRIVERVER = $120B ; Version 1.2 Beta

View File

@ -11,12 +11,15 @@
;
;*******************************
.export INIT
.import PRODOS
.import SMARTPORT
.import GETR1
.import GETR3
.import SDCMD
.import CARDDET
.import INITED
.import READ
.include "AppleIISd.inc"
@ -54,25 +57,23 @@
LDX #$00
LDX #$03
LDX #$00 ; is Smartport controller
;LDX #$3C ; is a disk controller
SEI ; find slot
LDA #$60 ; opcode for RTS
STA SLOT
JSR SLOT
BIT $CFFF
JSR KNOWNRTS
TSX
LDA $0100,X
CLI
STA CURSLOT ; $Cs
AND #$0F
STA SLOT ; $0s
TAY ; Y holds now SLOT
ASL A
ASL A
ASL A
ASL A
STA SLOT16 ; $s0
TAX ; X holds now SLOT16
BIT $CFFF
LDY #0 ; display copyright message
@DRAW: LDA TEXT,Y
@ -95,7 +96,6 @@
JMP (CMDLO)
@INIT: JSR INIT
CMP #NO_ERR
BNE @NEXTSLOT ; init not successful
;*******************************
@ -145,9 +145,8 @@ DRIVER: CLC ; ProDOS entry
; Has this to be done every time this gets called or only on boot???
SEI
LDA #$60 ; opcode for RTS
STA SLOT
JSR SLOT
BIT $CFFF
JSR KNOWNRTS
TSX
LDA $0100,X
CLI
@ -161,16 +160,9 @@ DRIVER: CLC ; ProDOS entry
ASL A
STA SLOT16 ; $s0
TAX ; X holds now SLOT16
BIT $CFFF
JSR CARDDET
BCC @INITED
LDA #ERR_OFFLINE; no card inserted
BRA @END
@INITED: LDA #INITED ; check for init
BIT SS,X
BNE @DISP
JSR INITED ; check for init
BCC @DISP
JSR INIT
BCS @END ; Init failed
@ -344,7 +336,7 @@ INIT: STZ CTRL,X ; reset SPI controller
BNE @IOERROR ; error!
@END: LDA SS,X
ORA #INITED ; initialized
ORA #CARD_INIT ; initialized
STA SS,X
LDA CTRL,X
ORA #ECE ; enable 7MHz
@ -359,7 +351,7 @@ INIT: STZ CTRL,X ; reset SPI controller
ORA #SS0
STA SS,X
TYA ; retval in A
RTS
KNOWNRTS: RTS
TEXT: .asciiz " Apple][Sd v1.2.2 (c)2020 Florian Reitz"

View File

@ -1,23 +1,25 @@
;*******************************
;
; Apple][Sd Firmware
; Version 1.2
; Version 1.2.2
; Helper functions
;
; (c) Florian Reitz, 2017 - 2018
; (c) Florian Reitz, 2017 - 2020
;
; X register usually contains SLOT16
; Y register is used for counting or SLOT
;
;*******************************
.export COMMAND
.export SDCMD
.export GETBLOCK
.export CARDDET
.export WRPROT
.export GETR1
.export GETR3
.export GETBLOCK
.export COMMAND
.export CARDDET
.export WRPROT
.export INITED
.include "AppleIISd.inc"
.segment "EXTROM"
@ -212,3 +214,23 @@ WRPROT: PHA
SEC
@DONE: PLA
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

View File

@ -1,10 +1,10 @@
;*******************************
;
; Apple][Sd Firmware
; Version 1.2
; Version 1.2.2
; ProDOS functions
;
; (c) Florian Reitz, 2017 - 2018
; (c) Florian Reitz, 2017 - 2020
;
; X register usually contains SLOT16
; Y register is used for counting or SLOT
@ -19,6 +19,9 @@
.import COMMAND
.import SDCMD
.import GETBLOCK
.import CARDDET
.import INITED
.import INIT
.import WRPROT
.import GETR1
.import GETR3
@ -67,6 +70,7 @@ PRODOS: LDA DCMD ; get command
; C Clear - No error
; Set - Error
; A $00 - No error
; $28 - No card inserted
; $2B - Card write protected
; X - Blocks avail (low byte)
; Y - Blocks avail (high byte)
@ -74,7 +78,12 @@ PRODOS: LDA DCMD ; get command
;*******************************
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
LDA #ERR_NOWRITE; card write protected
@ -94,10 +103,20 @@ STATUS: LDA #NO_ERR ; Thanks for this one, Antoine!
; Set - Error
; A $00 - No error
; $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
AND #<~SS0
@ -105,7 +124,7 @@ READ: JSR GETBLOCK ; calc block address
LDA #$51 ; send CMD17
JSR COMMAND ; send command
CMP #0
BNE @ERROR ; check for error
BNE @IOERROR ; check for error
@GETTOK: LDA #DUMMY ; get data token
STA DATA,X
@ -150,10 +169,14 @@ READ: JSR GETBLOCK ; calc block address
PLP
RTS
@ERROR: SEC ; an error occured
@IOERROR: SEC ; an error occured
LDA #ERR_IOERR
BRA @DONE
@NDERROR: SEC ; an error occured
LDA #ERR_NODRIVE
BRA @DONE
;*******************************
;

View File

@ -95,8 +95,10 @@ SMARTPORT: LDY #SMZPSIZE-1 ; save zeropage area for Smarport
BCC @RESTZP
TXA
;warum feste anzahl an bytes für return wert?
LDY #2 ; highbyte of # bytes transferred
LDX #0 ; low byte of # bytes transferred
;warum wird mit #1 verglichen?
CMP #1 ; C=1 if A != NO_ERR
RTS