2021-12-23 13:25:28 +00:00
|
|
|
;i/o ports to write to
|
|
|
|
writeLatchHigh = $C081
|
|
|
|
writeLatchLow = $C080
|
2019-05-13 13:11:26 +00:00
|
|
|
|
2021-12-12 15:31:01 +00:00
|
|
|
;ProDOS defines
|
2021-12-22 14:37:54 +00:00
|
|
|
command = $42 ;ProDOS command
|
|
|
|
unit = $43 ;7=drive 6-4=slot 3-0=not used
|
|
|
|
buflo = $44 ;low address of buffer
|
|
|
|
bufhi = $45 ;hi address of buffer
|
|
|
|
blklo = $46 ;low block
|
|
|
|
blkhi = $47 ;hi block
|
|
|
|
ioerr = $27 ;I/O error code
|
|
|
|
nodev = $28 ;no device connected
|
|
|
|
wperr = $2B ;write protect error
|
2020-12-01 02:36:10 +00:00
|
|
|
|
2022-07-12 22:32:24 +00:00
|
|
|
;for relocatable code
|
|
|
|
ioAddressLo = $FA
|
|
|
|
ioAddressHi = $FB
|
|
|
|
tempY = $FC
|
|
|
|
blockHalfCounter = $FD
|
|
|
|
lowLatch = $FE
|
|
|
|
highLatch = $FF
|
|
|
|
knownRts = $FF58
|
2021-12-12 15:31:01 +00:00
|
|
|
|
2022-11-02 22:10:17 +00:00
|
|
|
;autostart ROM next card
|
|
|
|
sloop = $FABA
|
|
|
|
keyboard = $C000
|
|
|
|
clearKeyboard = $C010
|
|
|
|
|
2022-07-12 22:32:24 +00:00
|
|
|
.org $C700
|
2021-12-22 14:37:54 +00:00
|
|
|
;code is relocatable
|
|
|
|
; but set to $c700 for
|
|
|
|
; readability
|
2019-05-13 13:11:26 +00:00
|
|
|
|
|
|
|
;ID bytes for booting and drive detection
|
2022-07-12 22:32:24 +00:00
|
|
|
cpx #$20 ;ID bytes for ProDOS and the
|
|
|
|
ldy #$00 ; Apple Autostart ROM
|
|
|
|
cpx #$03 ;
|
|
|
|
cpx #$3C ;this one for older II's
|
2019-05-13 13:11:26 +00:00
|
|
|
|
2022-11-02 22:10:17 +00:00
|
|
|
;check for ESC key and if so, jump to next slot in autostart
|
|
|
|
lda keyboard
|
|
|
|
cmp #$9B
|
|
|
|
bne start
|
|
|
|
jmp sloop
|
|
|
|
|
2021-12-12 15:31:01 +00:00
|
|
|
;zero out block numbers and buffer address
|
2022-11-02 22:10:17 +00:00
|
|
|
start:
|
2022-07-12 22:32:24 +00:00
|
|
|
sty buflo
|
|
|
|
sty blklo
|
|
|
|
sty blkhi
|
|
|
|
iny ;set command = 1 for read block
|
|
|
|
sty command
|
|
|
|
jsr knownRts ;jump to known RTS to get our address from the stack
|
|
|
|
tsx
|
2021-12-22 14:37:54 +00:00
|
|
|
lda $0100,x ;this for example would be $C7 in slot 7
|
|
|
|
sta bufhi ;keep the slot here
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
2022-07-12 22:32:24 +00:00
|
|
|
sta unit
|
2021-12-12 15:31:01 +00:00
|
|
|
|
2019-05-13 13:11:26 +00:00
|
|
|
;display copyright message
|
2021-12-22 14:37:54 +00:00
|
|
|
ldy #<text
|
|
|
|
drawtxt:
|
|
|
|
lda (buflo),y
|
2021-12-24 04:55:37 +00:00
|
|
|
beq boot
|
2022-07-12 22:32:24 +00:00
|
|
|
sta $07D0-<text,y ;put text on last line
|
|
|
|
iny
|
|
|
|
bne drawtxt
|
2021-12-12 15:31:01 +00:00
|
|
|
|
|
|
|
;load block 0000 at $0800
|
2021-12-24 04:55:37 +00:00
|
|
|
boot:
|
2022-07-12 22:32:24 +00:00
|
|
|
lda #$08 ;push $0800 onto the stack so an RTS will run at $0801
|
|
|
|
sta bufhi
|
|
|
|
pha
|
|
|
|
lda #$00
|
|
|
|
pha
|
2019-05-13 13:11:26 +00:00
|
|
|
;This is the ProDOS entry point for this card
|
2021-12-12 15:31:01 +00:00
|
|
|
entry:
|
2022-07-12 22:32:24 +00:00
|
|
|
ldx unit ;make sure it's drive 1
|
|
|
|
bpl docmd ;yep, do command
|
|
|
|
sec ;nope, set device not connected
|
|
|
|
lda #nodev
|
|
|
|
rts ;go back to ProDOS
|
2019-05-13 13:11:26 +00:00
|
|
|
|
2021-12-12 15:31:01 +00:00
|
|
|
docmd:
|
2022-07-12 22:32:24 +00:00
|
|
|
lda command
|
|
|
|
beq getstat ;command 0 is GetStatus
|
|
|
|
cmp #$01
|
|
|
|
beq readblk ;command 1 is ReadBlock
|
|
|
|
sec ;Format/Write not permitted
|
|
|
|
lda #wperr ;write protect error
|
|
|
|
rts ;go back to ProDOS
|
2019-05-13 13:11:26 +00:00
|
|
|
|
2021-12-12 15:31:01 +00:00
|
|
|
getstat:
|
2022-07-12 22:32:24 +00:00
|
|
|
clc ;send back status
|
|
|
|
lda #$00 ;good status
|
|
|
|
ldx #$00 ;1024 blocks
|
|
|
|
ldy #$04 ;
|
|
|
|
rts
|
2019-05-13 13:11:26 +00:00
|
|
|
|
2021-12-12 15:31:01 +00:00
|
|
|
readblk:
|
2022-11-02 22:10:17 +00:00
|
|
|
saveVars:
|
|
|
|
ldy #ioAddressLo
|
|
|
|
varLoop:
|
|
|
|
lda $00,y
|
2022-07-12 22:32:24 +00:00
|
|
|
pha
|
2022-11-02 22:10:17 +00:00
|
|
|
iny
|
|
|
|
bne varLoop
|
2022-07-12 22:32:24 +00:00
|
|
|
|
|
|
|
lda blkhi ;get hi block
|
|
|
|
asl a ;shift up to top 3 bits
|
|
|
|
asl a ;since that's all the high
|
|
|
|
asl a ;blocks we can handle
|
|
|
|
asl a ;
|
|
|
|
asl a ;
|
|
|
|
sta highLatch
|
|
|
|
lda blklo ;get low block
|
|
|
|
lsr a ;shift so we get the top 5
|
|
|
|
lsr a ;bits - this also goes in
|
|
|
|
lsr a ;the high latch
|
|
|
|
ora highLatch ;add it to those top 3 bits
|
2021-12-22 14:37:54 +00:00
|
|
|
sta highLatch ;save it back in scratch ram
|
2022-07-12 22:32:24 +00:00
|
|
|
sta writeLatchHigh,x ;set high latch for card
|
|
|
|
lda blklo ;get low block
|
|
|
|
asl a ;shift it to top 3 bits
|
|
|
|
asl a ;
|
|
|
|
asl a ;
|
|
|
|
asl a ;
|
|
|
|
asl a ;
|
|
|
|
sta lowLatch
|
|
|
|
lda #$02
|
|
|
|
sta blockHalfCounter
|
|
|
|
lda #$C0
|
|
|
|
sta ioAddressHi
|
2019-05-13 13:11:26 +00:00
|
|
|
|
2021-12-12 15:31:01 +00:00
|
|
|
;This gets 256 bytes from the ROM card
|
2019-05-13 13:11:26 +00:00
|
|
|
|
2021-12-12 15:31:01 +00:00
|
|
|
read256:
|
2022-07-12 22:32:24 +00:00
|
|
|
ldy #$00
|
2021-12-12 15:31:01 +00:00
|
|
|
loop256:
|
2022-07-12 22:32:24 +00:00
|
|
|
lda lowLatch
|
|
|
|
sta writeLatchLow,x
|
|
|
|
txa
|
|
|
|
ora #$80
|
|
|
|
sta ioAddressLo
|
|
|
|
|
2021-12-12 15:31:01 +00:00
|
|
|
loop16:
|
2022-07-12 22:32:24 +00:00
|
|
|
sty tempY
|
|
|
|
ldy #$00
|
|
|
|
lda (ioAddressLo),y
|
|
|
|
ldy tempY
|
|
|
|
sta (buflo),y
|
|
|
|
iny
|
|
|
|
inc ioAddressLo
|
|
|
|
lda ioAddressLo
|
|
|
|
and #$0F
|
|
|
|
bne loop16
|
|
|
|
|
|
|
|
continue256:
|
|
|
|
inc lowLatch
|
|
|
|
cpy #$00
|
|
|
|
bne loop256
|
|
|
|
dec blockHalfCounter
|
|
|
|
bne readnext256
|
|
|
|
|
|
|
|
finish:
|
|
|
|
pla
|
|
|
|
sta highLatch
|
|
|
|
pla
|
|
|
|
sta lowLatch
|
|
|
|
pla
|
|
|
|
sta blockHalfCounter
|
|
|
|
pla
|
|
|
|
sta tempY
|
|
|
|
pla
|
|
|
|
sta ioAddressHi
|
|
|
|
pla
|
|
|
|
sta ioAddressLo
|
|
|
|
|
|
|
|
dec bufhi
|
|
|
|
clc ;clear error code for success
|
|
|
|
lda #$00
|
|
|
|
rts
|
2019-05-13 13:11:26 +00:00
|
|
|
|
2021-12-12 15:31:01 +00:00
|
|
|
readnext256:
|
2022-07-12 22:32:24 +00:00
|
|
|
inc bufhi ; set buffer to receive next 256 bytes
|
|
|
|
clc ; effectively a branch always
|
2021-12-22 14:37:54 +00:00
|
|
|
bcc read256
|
2019-05-13 13:11:26 +00:00
|
|
|
|
2021-12-12 15:31:01 +00:00
|
|
|
;macro for string with high-bit set
|
|
|
|
.macro aschi str
|
|
|
|
.repeat .strlen (str), c
|
|
|
|
.byte .strat (str, c) | $80
|
|
|
|
.endrep
|
|
|
|
.endmacro
|
2019-05-13 13:11:26 +00:00
|
|
|
|
2022-03-19 16:02:30 +00:00
|
|
|
text: aschi "ROM-Drive (c)1998-2022 Terence J. Boldt"
|
2021-04-01 01:51:39 +00:00
|
|
|
end:
|
2021-12-22 14:37:54 +00:00
|
|
|
.byte 0
|
2019-05-13 13:11:26 +00:00
|
|
|
|
2020-12-01 02:36:10 +00:00
|
|
|
; These bytes need to be at the top of the 256 byte firmware as ProDOS
|
|
|
|
; uses these to find the entry point and drive capabilities
|
|
|
|
|
2021-04-01 01:51:39 +00:00
|
|
|
.repeat 251-<end
|
|
|
|
.byte 0
|
|
|
|
.endrepeat
|
2020-12-01 02:36:10 +00:00
|
|
|
|
2021-12-22 14:37:54 +00:00
|
|
|
.byte 0,0 ;0000 blocks = check status
|
|
|
|
.byte 3 ;bit 0=read 1=status
|
|
|
|
.byte <entry ;low byte of entry
|