Smartport dispatcher added

This commit is contained in:
Florian Reitz 2018-05-23 20:51:44 +02:00
parent 457e8bff9c
commit 0910ca3db0
3 changed files with 130 additions and 23 deletions

View File

@ -28,17 +28,16 @@ BLOCKNUM := $46 ; block number
; Smartport
SMPARAM := $48 ; parameter count
SMUNIT := $49 ; unit number
SMBUFF := $4A ; buffer pointer
SMSTAT := $4B ; status / control code
SMBLOCK := $4C ; block number
SMCOUNT := $4D ; byte count
SMADDR := $4E ; address for read
SMPARAMLIST := $48 ; parameter list
SMCMDLIST := $4A ; command list
SMCSCODE := $AC
SMZPAREA = SMPARAMLIST
SMZPSIZE = SMCSCODE-SMZPAREA+1
SMCMD = DCMD
; Ram equates
; Ram equates, access with SLOT offset
R30 := $0478
R31 := $04F8
R32 := $0578

View File

@ -36,7 +36,7 @@
.segment "SLOTID"
.byt $0 ; not extended, no SCSI, no RAM
.dbyt $0 ; use status call
.word $0000 ; use status call
.byt $97 ; Status bits
.byt <DRIVER ; LSB of driver
@ -53,8 +53,8 @@
LDX #$20
LDX #$00
LDX #$03
; LDX #$00 ; is Smartport controller
LDX #$3C
LDX #$00 ; is Smartport controller
; LDX #$3C
SEI ; find slot
JSR KNOWNRTS
@ -82,6 +82,9 @@
; INY
; BPL @DRAW
; LDA #197
; JSR $FCA8 ; wait for 100 ms
@OAPPLE: BIT OAPPLE ; check for OA key
BPL @INIT ; and skip boot if pressed

View File

@ -20,21 +20,126 @@
;*******************************
;
; Status request
; $43 Unit number DSSS000
; $44-45 Unused
; $46-47 Unused
; Smartport command dispatcher
;
; $42-$47 MLI input locations
; X Slot*16
; Y Slot
;
; C Clear - No error
; Set - Error
; A $00 - No error
; $2B - Card write protected
; $2F - No card inserted
; X - Blocks avail (low byte)
; Y - Blocks avail (high byte)
; $01 - Unknown command
;
;*******************************
SMARTPORT: PLA ; pull return address
TAY
SMARTPORT: LDY #SMZPSIZE-1 ; save zeropage area for Smarport
@SAVEZP: LDA SMZPAREA,Y
PHA
DEY
BPL @SAVEZP
TSX ; get parameter list pointer
LDA $101+SMZPSIZE,X
STA SMPARAMLIST
CLC
ADC #3 ; adjust return address
STA $101+SMZPSIZE,X
LDA $102+SMZPSIZE,X
STA SMPARAMLIST+1
ADC #0
STA $102+SMZPSIZE,X
LDY #1 ; get command code
LDA (SMPARAMLIST),Y
STA SMCMD
INY
LDA (SMPARAMLIST),Y
TAX
INY
LDA (SMPARAMLIST),Y
STA SMPARAMLIST+1 ; TODO: why overwrite, again?
STX SMPARAMLIST
LDA #ERR_BADCMD ; suspect bad command
LDX SMCMD
CPX #$09+1 ; command too large
BCS @END
LDA (SMPARAMLIST) ; parameter count
CMP REQPARAMCOUNT,X
BNE @COUNTMISMATCH
LDY #1 ; get drive number
LDA (SMPARAMLIST),Y
LDY SLOT
STA DRVNUM,Y
TXA
ASL A ; shift for use or word addresses
TAX
JSR @JMPSPCOMMAND
BCS @END ; jump on error
LDA #NO_ERR
@END: TAX ; save retval
LDY #0 ; restore zeropage
@RESTZP: PLA
STA SMZPAREA,Y
INY
CPY #SMZPSIZE
BCC @RESTZP
TXA
LDY #2 ; highbyte of # bytes transferred
LDY #0 ; low byte of # bytes transferred
CMP #1 ; C=1 if A != NO_ERR
RTS
@COUNTMISMATCH:
LDA #ERR_BADPCNT
BRA @END
@JMPSPCOMMAND: ; use offset from cmd*2
JMP (SPDISPATCH,X)
; Required parameter counts for the commands
REQPARAMCOUNT:
.byt 3 ; 0 = status
.byt 3 ; 1 = read block
.byt 3 ; 2 = write block
.byt 1 ; 3 = format
.byt 3 ; 4 = control
.byt 1 ; 5 = init
.byt 1 ; 6 = open
.byt 1 ; 7 = close
.byt 4 ; 8 = read char
.byt 4 ; 9 = write char
; Command jump table
SPDISPATCH:
.word SMSTATUS
.word SMREADBLOCK
.word SMWRITEBLOCK
.word SMFORMAT
.word SMCONTROL
.word SMINIT
.word SMOPEN
.word SMCLOSE
.word SMREADCHAR
.word SMWRITECHAR
SMSTATUS:
SMREADBLOCK:
SMWRITEBLOCK:
SMFORMAT:
SMCONTROL:
SMINIT:
SMOPEN:
SMCLOSE:
SMREADCHAR:
SMWRITECHAR: