mirror of
https://github.com/dschmenk/apple2pi.git
synced 2024-12-23 08:29:34 +00:00
f683d6a051
Apple 3 PiDrive driver. Apple2 PiDrive driver can mount under Linux
249 lines
3.1 KiB
ArmAsm
Executable File
249 lines
3.1 KiB
ArmAsm
Executable File
.DEFINE EQU =
|
|
.DEFINE DB .BYTE
|
|
.DEFINE DW .WORD
|
|
.CODE
|
|
PISLOT EQU $00
|
|
;*
|
|
;* ACIA REGISTERS
|
|
;*
|
|
ACIADR EQU $C088+PISLOT*16
|
|
ACIASR EQU $C089+PISLOT*16
|
|
ACIACR EQU $C08A+PISLOT*16
|
|
ACIAMR EQU $C08B+PISLOT*16
|
|
;*
|
|
;* APPLE I/O LOCATIONS
|
|
;*
|
|
KEYBD EQU $C000
|
|
STROBE EQU $C010
|
|
;*
|
|
;* UTIL ROUTINES
|
|
;*
|
|
WAIT EQU $FCA8
|
|
COUT EQU $FDED
|
|
CROUT EQU $FD8E
|
|
PRBYTE EQU $FDDA
|
|
PRHEX EQU $FDE3
|
|
PRNTAX EQU $F941
|
|
RDKEY EQU $FD0C
|
|
RDCHAR EQU $FD35
|
|
GETLN EQU $FD6A
|
|
;*
|
|
;* ZERO PAGE PARAMETERS
|
|
;*
|
|
PDCMD EQU $42
|
|
PDUNIT EQU $43
|
|
PDBUFF EQU $44
|
|
PDBUFL EQU $44
|
|
PDBUFH EQU $45
|
|
PDBLKL EQU $46
|
|
PDBLKH EQU $47
|
|
;*
|
|
;* SLOT INDEX = SLOT # * 16
|
|
;*
|
|
SLOTIDX EQU $0300
|
|
;*
|
|
;* DRIVER SCRATCHPAD
|
|
;*
|
|
TMP EQU $0478+PISLOT
|
|
PAD0 EQU $0478+PISLOT
|
|
PAD1 EQU $04F8+PISLOT
|
|
PAD2 EQU $0578+PISLOT
|
|
PAD3 EQU $05F8+PISLOT
|
|
PAD4 EQU $0678+PISLOT
|
|
PAD5 EQU $06F8+PISLOT
|
|
PAD6 EQU $0778+PISLOT
|
|
PAD7 EQU $07F8+PISLOT
|
|
;*
|
|
;* PRODOS COMMANDS
|
|
;*
|
|
PDSTAT EQU 0
|
|
PDREAD EQU 1
|
|
PDWRITE EQU 2
|
|
PDFORMT EQU 3
|
|
;*
|
|
;* PRODOS ERRORS
|
|
;*
|
|
PDNOERR EQU $00
|
|
PDIOERR EQU $27
|
|
PDNODEV EQU $28
|
|
PDWRPRT EQU $2B
|
|
;*
|
|
;* PRODOS GLOBAL PAGE LOCATIONS
|
|
;*
|
|
CLKJMP EQU $BF06
|
|
DEV1L EQU $BF10
|
|
DEV1H EQU $BF11
|
|
DEV2L EQU $BF20
|
|
DEV2H EQU $BF21
|
|
DEVCNT EQU $BF31
|
|
DEVLST EQU $BF32
|
|
PDTIME EQU $BF90
|
|
;*
|
|
;* ZERO PAGE LOCATIONS FOR LOADER
|
|
;*
|
|
DSTPTR EQU $06
|
|
DSTL EQU $06
|
|
DSTH EQU $07
|
|
SRCPTR EQU $08
|
|
SRCL EQU $08
|
|
SRCH EQU $09
|
|
;*
|
|
;* DRIVER LOADER
|
|
;*
|
|
DRVRDST EQU $D742
|
|
DRVRLEN EQU 125
|
|
LDA #$4C
|
|
STA CLKJMP ; HOOK CLOCK DRIVER (WITH JMP)
|
|
LDA #<DRVRELOC
|
|
STA SRCL
|
|
LDA #>DRVRELOC
|
|
STA SRCH
|
|
LDA #<DRVRDST
|
|
STA DSTL
|
|
LDA #>DRVRDST
|
|
STA DSTH
|
|
LDY #DRVRLEN-1
|
|
BIT $C08B ; ENABLE LCRAM & WRITE
|
|
BIT $C08B
|
|
CPYLP: LDA (SRCPTR),Y
|
|
STA (DSTPTR),Y
|
|
DEY
|
|
BPL CPYLP
|
|
INY
|
|
LDX #SFIXUPTBL-IFIXUPTBL-1
|
|
IFIXLP: LDA IFIXUPTBL,X
|
|
STA DSTH
|
|
DEX
|
|
LDA IFIXUPTBL,X
|
|
STA DSTL
|
|
LDA (DSTPTR),Y
|
|
ORA SLOTIDX
|
|
STA (DSTPTR),Y
|
|
DEX
|
|
BPL IFIXLP
|
|
LDX #DRVRELOC-SFIXUPTBL-1
|
|
SFIXLP: LDA SFIXUPTBL,X
|
|
STA DSTH
|
|
DEX
|
|
LDA SFIXUPTBL,X
|
|
STA DSTL
|
|
LDA SLOTIDX
|
|
LSR
|
|
LSR
|
|
LSR
|
|
LSR
|
|
CLC
|
|
ADC (DSTPTR),Y
|
|
STA (DSTPTR),Y
|
|
DEX
|
|
BPL SFIXLP
|
|
BIT $C08A ; EBABLE ROM
|
|
LDA SLOTIDX
|
|
LSR
|
|
LSR
|
|
LSR
|
|
TAX
|
|
LDA DEV1H,X
|
|
CMP #$DE ; GNODEV
|
|
BNE INSDEV2
|
|
LDA #<DRVRDST
|
|
STA DEV1L,X
|
|
LDA #>DRVRDST
|
|
STA DEV1H,X
|
|
INY
|
|
INSDEV2:
|
|
LDA DEV2H,X
|
|
CMP #$DE
|
|
BNE INCDEV1
|
|
LDA #<DRVRDST
|
|
STA DEV2L,X
|
|
LDA #>DRVRDST
|
|
STA DEV2H,X
|
|
INY
|
|
INCDEV1:
|
|
CPY #$00
|
|
BEQ EXIT ; NOTHING TO BE DONE HERE
|
|
LDX #$00
|
|
DEV1LP: LDA DEVLST,X
|
|
BNE NXTDEV1
|
|
LDA SLOTIDX
|
|
ORA #$01
|
|
STA DEVLST,X
|
|
INC DEVCNT
|
|
BNE INCDEV2
|
|
NXTDEV1:
|
|
INX
|
|
CPX #14
|
|
BNE DEV1LP
|
|
INCDEV2:
|
|
LDX #$00
|
|
DEV2LP: LDA DEVLST,X
|
|
BNE NXTDEV2
|
|
LDA SLOTIDX
|
|
ORA #$81
|
|
STA DEVLST,X
|
|
INC DEVCNT
|
|
BNE EXIT
|
|
NXTDEV2:
|
|
INX
|
|
CPX #14
|
|
BNE DEV2LP
|
|
EXIT: RTS
|
|
;*
|
|
;* FIXUP TABLE
|
|
;*
|
|
IFIXUPTBL:
|
|
DW FIXUP1+1
|
|
DW FIXUP2+1
|
|
DW FIXUP3+1
|
|
DW FIXUP4+1
|
|
SFIXUPTBL:
|
|
DW FIXUP5+1
|
|
DW FIXUP6+1
|
|
DRVRELOC:
|
|
;*
|
|
;* PRODOS CLOCK ROUTINE
|
|
;*
|
|
.ORG DRVRDST
|
|
DOCLK: LDA #$AC
|
|
PHP
|
|
FIXUP5: STA PAD0
|
|
SEI
|
|
JSR SENDACC
|
|
TXA
|
|
JSR SENDACC
|
|
TYA
|
|
JSR SENDACC
|
|
CHKACK: JSR RECVACC
|
|
TAX
|
|
DEX
|
|
FIXUP6: CPX PAD0
|
|
BNE CHKACK
|
|
LDY #$00
|
|
CLKLP: JSR RECVACC
|
|
STA PDTIME,Y
|
|
INY
|
|
CPY #$04
|
|
BNE CLKLP
|
|
PLP
|
|
RTS
|
|
;*
|
|
;* ACIA I/O ROUTINES
|
|
;*
|
|
SENDACC:
|
|
PHA
|
|
FIXUP1:
|
|
SENDWT: LDA ACIASR
|
|
AND #$10
|
|
BEQ SENDWT
|
|
PLA
|
|
FIXUP2: STA ACIADR
|
|
RTS
|
|
RECVACC:
|
|
FIXUP3:
|
|
RECVWT: LDA ACIASR
|
|
AND #$08
|
|
BEQ RECVWT
|
|
FIXUP4: LDA ACIADR
|
|
RTS
|