apple2pi/pidrive/rom.s

220 lines
3.0 KiB
ArmAsm
Raw Normal View History

2014-02-15 05:06:12 +00:00
.DEFINE EQU =
.DEFINE DB .BYTE
.DEFINE DW .WORD
.DEFINE PAGE .ALIGN 256
.DEFINE ORG .ORG
2014-02-10 00:37:46 +00:00
.CODE
2014-02-15 05:06:12 +00:00
ROMSLOT EQU $07
PISLOT EQU $02 ; ROMSLOT
BOOTDEV EQU ROMSLOT*16
ORG $C000+ROMSLOT*256
2014-02-10 00:37:46 +00: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
;*
2014-02-15 05:06:12 +00:00
INDCTR EQU $0400
2014-02-10 00:37:46 +00:00
KEYBD EQU $C000
STROBE EQU $C010
;*
2014-02-15 05:06:12 +00:00
;* DRIVER SCRATCHPAD
;*
PAD0 EQU $0478+ROMSLOT
PAD1 EQU $04F8+ROMSLOT
PAD2 EQU $0578+ROMSLOT
PAD3 EQU $05F8+ROMSLOT
PAD4 EQU $0678+ROMSLOT
PAD5 EQU $06F8+ROMSLOT
PAD6 EQU $0778+ROMSLOT
PAD7 EQU $07F8+ROMSLOT
;*
2014-02-10 00:37:46 +00:00
;* 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
;*
;* 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
;*
;* AUTOSTART BOOT SIGNATURE
;*
LDX #$20
LDY #$00
LDX #$03
STX $3C
;*
;* INIT ACIA
;*
2014-02-16 03:53:09 +00:00
STY PAD1 ; CLEAR SYNCED FLAG
2014-02-10 00:37:46 +00:00
STY ACIASR ; RESET STATUS REGISTER
2014-02-16 03:53:09 +00:00
LDA #$0B
STA ACIACR ; SET CONTROL REGISTER
LDA #$10
STA ACIAMR ; SET COMMAND REGISTER (115K BAUD)
;*
;* CREATE COMMAND BUFFER FOR BOOT BLOCK
;*
STY PDUNIT
STY PDBUFL
STY PDBLKL
STY PDBLKH
INY ; LDY #PDREAD
STY PDCMD
LDY #$08
STY PDBUFH
JSR DOCMD
BCC BOOT
LDA $00
BEQ CONT
RTS
CONT: JMP $FABA ; JUMP BACK TO AUTOSTART BOOT SCANNER ROM
BOOT: LDX #BOOTDEV
STX PDUNIT
JMP $801
;*
;* PRODOS INTELLIGENT DEVICE ENTRYPOINT
;*
DOCMD: PHP
SEI
LDA PAD1
CMP #$81
BEQ SNDCMD
2014-02-10 00:37:46 +00:00
;*
;* SYNC WITH HOST
;*
SYNC: LDA #$80
STA ACIADR
2014-02-16 03:53:09 +00:00
LDA INDCTR
PHA
2014-02-15 05:06:12 +00:00
INX
TXA
AND #$07
TAX
LDA SPIN,X
STA INDCTR
2014-02-10 00:37:46 +00:00
LDA #$FF
JSR WAIT
2014-02-16 03:53:09 +00:00
PLA
2014-02-15 05:06:12 +00:00
STA INDCTR
2014-02-10 00:37:46 +00:00
LDA KEYBD
2014-02-16 03:53:09 +00:00
BPL CHKRSP
STA STROBE
BMI IOERR
SPIN: DB $A1, $AF, $AD, $DC, $A1, $AF, $AD, $DC
CHKRSP: LDA ACIASR
2014-02-10 00:37:46 +00:00
AND #$08
BEQ SYNC
2014-02-16 03:53:09 +00:00
LDA ACIADR
CMP #$81
2014-02-10 00:37:46 +00:00
BNE SYNC
2014-02-16 03:53:09 +00:00
STA PAD1
SNDCMD: LDA PDUNIT
2014-02-10 00:37:46 +00:00
ASL
LDA PDCMD
ROL
ASL
2014-02-15 05:06:12 +00:00
ORA #$A0
STA PAD0
2014-02-10 00:37:46 +00:00
JSR SENDACC
LDA PDBLKL
JSR SENDACC
LDA PDBLKH
JSR SENDACC
CHKACK: JSR RECVACC
TAX
DEX
2014-02-15 05:06:12 +00:00
CPX PAD0
2014-02-10 00:37:46 +00:00
BNE CHKACK
2014-02-15 05:06:12 +00:00
LDY PDCMD
BEQ STATUS
LDX #$02 ; # OF PAGES TO XFER
DEY ; CPY #PDREAD
2014-02-10 00:37:46 +00:00
BEQ RDBLK
2014-02-15 05:06:12 +00:00
DEY ; CMP #PDWRITE
2014-02-10 00:37:46 +00:00
BEQ WRBLK
2014-02-15 05:06:12 +00:00
IOERR: LDA #PDIOERR
2014-02-10 00:37:46 +00:00
CMDERR: PLP
SEC
RTS
2014-02-15 05:06:12 +00:00
RDBLK: JSR RECVACC
STA (PDBUFF),Y
INY
BNE RDBLK
INC PDBUFH
DEX
BNE RDBLK
STATUS: LDX #$FF
DEY ; LDY #$FF
2014-02-10 00:37:46 +00:00
CMDEX: JSR RECVACC
BNE CMDERR
PLP
CLC
RTS
2014-02-15 05:06:12 +00:00
WRBLK: LDA (PDBUFF),Y
2014-02-10 00:37:46 +00:00
JSR SENDACC
INY
2014-02-15 05:06:12 +00:00
BNE WRBLK
2014-02-10 00:37:46 +00:00
INC PDBUFH
2014-02-15 05:06:12 +00:00
DEX
BNE WRBLK
2014-02-10 00:37:46 +00:00
BEQ CMDEX
2014-02-15 05:06:12 +00:00
;*
;* ACIA I/O ROUTINES
;*
2014-02-10 00:37:46 +00:00
SENDACC:
PHA
SENDWT: LDA ACIASR
AND #$10
BEQ SENDWT
PLA
STA ACIADR
RTS
RECVACC:
RECVWT: LDA ACIASR
AND #$08
BEQ RECVWT
LDA ACIADR
2014-02-15 05:06:12 +00:00
RTS
2014-02-16 03:53:09 +00:00
ENDCMD:
2014-02-15 05:06:12 +00:00
.REPEAT $C000+ROMSLOT*256+250-*
DB $FF
.ENDREP
DB "Pi"
DW 0
2014-02-16 03:53:09 +00:00
DB $97
2014-02-15 05:06:12 +00:00
DB <DOCMD
2014-02-16 03:53:09 +00:00
.ASSERT * = $C000+(ROMSLOT+1)*256, error, "Code not page size"