Merge pull request #8 from tjboldt/multipage-firmware

Add multi-page firmware support
This commit is contained in:
Terence Boldt 2021-03-28 10:55:04 -04:00 committed by GitHub
commit 4d2c8f39b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 1002 additions and 48 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
*-bak *-bak
node_modules *.o
*.DS_Store

144
Apple2/CommandFirmware.asm Normal file
View File

@ -0,0 +1,144 @@
;ProDOS Zero Page
Command = $42 ;ProDOS Command
Unit = $43 ;ProDOS unit (SDDD0000)
BufferLo = $44
BufferHi = $45
BlockLo = $46
BlockHi = $47
; ProDOS Error Codes
IOError = $27
NoDevice = $28
WriteProtect = $2B
InputByte = $c08e+SLOT*$10
OutputByte = $c08d+SLOT*$10
InputFlags = $c08b+SLOT*$10
OutputFlags = $c087+SLOT*$10
ReadBlockCommand = $01
WriteBlockCommand = $02
GetTimeCommand = $03
ChangeDriveCommand = $04
ExecCommand = $05
LoadFileCommand = $06
SaveFileCommand = $07
.org SLOT*$100 + $C000
;ID bytes for booting and drive detection
cpx #$20 ;ID bytes for ProDOS and the
cpx #$00 ; Apple Autostart ROM
cpx #$03 ;
ldx #SLOT*$10
stx $2b
stx Unit
;force EPROM to second page on boot
lda #$3f ;set all flags high and page 3 of EPROM for menu
PageJump:
sta OutputFlags
jmp Start ;this jump is only called if coming in from PageJump with A=$2f
;entry points for ProDOS
DriverEntry:
lda #$0f ;set all flags high and page 0 of EPROM
sta OutputFlags
Start:
lda $33
pha
lda #$a4
sta $33
GetCommand:
jsr $fd6a
lda $0200
cmp #$8d ;stop when return found
beq ExitApp
jsr DumpOutput
clc
bcc GetCommand
ExitApp:
pla
sta $33
lda #$00
sty $34
rts
DumpOutput:
ldx #$50
lda #$05 ;send command 5 = exec
jsr SendByte
ldy #$00
getInput:
lda $0200,y
cmp #$8d
beq sendNullTerminator
and #$7f
jsr SendByte
iny
bne getInput
sendNullTerminator:
lda #$00
jsr SendByte
getOutput:
jsr GetByte
cmp #$00
beq endOutput
jsr $fded
clc
bcc getOutput
endOutput:
rts
SendByte:
pha
waitWrite:
lda InputFlags
rol
rol
bcs waitWrite
pla
sta OutputByte
lda #$0e ; set bit 0 low to indicate write started
sta OutputFlags
finishWrite:
lda InputFlags
rol
rol
bcc finishWrite
lda #$0f
sta OutputFlags
rts
GetByte:
lda #$0d ;set read flag low
sta OutputFlags
waitRead:
lda InputFlags
rol
bcs waitRead
lda InputByte
pha
lda #$0f ;set all flags high
sta OutputFlags
finishRead:
lda InputFlags
rol
bcc finishRead
pla
end:
rts
.repeat 251-<end
.byte 0
.endrepeat
.byte 0,0 ;0000 blocks = check status
.byte 7 ;bit set(0=status 1=read 2=write) unset(3=format, 4/5=number of volumes, 6=interruptable, 7=removable)
.byte DriverEntry&$00FF ;low byte of entry
;Translation of code written in mini-assembler on Apple //e
;Currently only works if card is in slot 5
.org $1000

151
Apple2/CommandFirmware.lst Normal file
View File

@ -0,0 +1,151 @@
ca65 V2.18 - N/A
Main file : CommandFirmware.asm
Current file: CommandFirmware.asm
000000r 1 ;ProDOS Zero Page
000000r 1 Command = $42 ;ProDOS Command
000000r 1 Unit = $43 ;ProDOS unit (SDDD0000)
000000r 1 BufferLo = $44
000000r 1 BufferHi = $45
000000r 1 BlockLo = $46
000000r 1 BlockHi = $47
000000r 1
000000r 1 ; ProDOS Error Codes
000000r 1 IOError = $27
000000r 1 NoDevice = $28
000000r 1 WriteProtect = $2B
000000r 1
000000r 1 InputByte = $c08e+SLOT*$10
000000r 1 OutputByte = $c08d+SLOT*$10
000000r 1 InputFlags = $c08b+SLOT*$10
000000r 1 OutputFlags = $c087+SLOT*$10
000000r 1
000000r 1 ReadBlockCommand = $01
000000r 1 WriteBlockCommand = $02
000000r 1 GetTimeCommand = $03
000000r 1 ChangeDriveCommand = $04
000000r 1 ExecCommand = $05
000000r 1 LoadFileCommand = $06
000000r 1 SaveFileCommand = $07
000000r 1
000000r 1 .org SLOT*$100 + $C000
00C500 1 ;ID bytes for booting and drive detection
00C500 1 E0 20 cpx #$20 ;ID bytes for ProDOS and the
00C502 1 E0 00 cpx #$00 ; Apple Autostart ROM
00C504 1 E0 03 cpx #$03 ;
00C506 1
00C506 1 A2 50 ldx #SLOT*$10
00C508 1 86 2B stx $2b
00C50A 1 86 43 stx Unit
00C50C 1
00C50C 1 ;force EPROM to second page on boot
00C50C 1 A9 3F lda #$3f ;set all flags high and page 3 of EPROM for menu
00C50E 1 PageJump:
00C50E 1 8D D7 C0 sta OutputFlags
00C511 1 4C 19 C5 jmp Start ;this jump is only called if coming in from PageJump with A=$2f
00C514 1
00C514 1 ;entry points for ProDOS
00C514 1 DriverEntry:
00C514 1 A9 0F lda #$0f ;set all flags high and page 0 of EPROM
00C516 1 8D D7 C0 sta OutputFlags
00C519 1
00C519 1 Start:
00C519 1 A5 33 lda $33
00C51B 1 48 pha
00C51C 1 A9 A4 lda #$a4
00C51E 1 85 33 sta $33
00C520 1 GetCommand:
00C520 1 20 6A FD jsr $fd6a
00C523 1 AD 00 02 lda $0200
00C526 1 C9 8D cmp #$8d ;stop when return found
00C528 1 F0 06 beq ExitApp
00C52A 1 20 38 C5 jsr DumpOutput
00C52D 1 18 clc
00C52E 1 90 F0 bcc GetCommand
00C530 1 ExitApp:
00C530 1 68 pla
00C531 1 85 33 sta $33
00C533 1 A9 00 lda #$00
00C535 1 84 34 sty $34
00C537 1 60 rts
00C538 1
00C538 1 DumpOutput:
00C538 1 A2 50 ldx #$50
00C53A 1 A9 05 lda #$05 ;send command 5 = exec
00C53C 1 20 63 C5 jsr SendByte
00C53F 1 A0 00 ldy #$00
00C541 1 getInput:
00C541 1 B9 00 02 lda $0200,y
00C544 1 C9 8D cmp #$8d
00C546 1 F0 08 beq sendNullTerminator
00C548 1 29 7F and #$7f
00C54A 1 20 63 C5 jsr SendByte
00C54D 1 C8 iny
00C54E 1 D0 F1 bne getInput
00C550 1 sendNullTerminator:
00C550 1 A9 00 lda #$00
00C552 1 20 63 C5 jsr SendByte
00C555 1 getOutput:
00C555 1 20 81 C5 jsr GetByte
00C558 1 C9 00 cmp #$00
00C55A 1 F0 06 beq endOutput
00C55C 1 20 ED FD jsr $fded
00C55F 1 18 clc
00C560 1 90 F3 bcc getOutput
00C562 1 endOutput:
00C562 1 60 rts
00C563 1
00C563 1 SendByte:
00C563 1 48 pha
00C564 1 waitWrite:
00C564 1 AD DB C0 lda InputFlags
00C567 1 2A rol
00C568 1 2A rol
00C569 1 B0 F9 bcs waitWrite
00C56B 1 68 pla
00C56C 1 8D DD C0 sta OutputByte
00C56F 1 A9 0E lda #$0e ; set bit 0 low to indicate write started
00C571 1 8D D7 C0 sta OutputFlags
00C574 1 finishWrite:
00C574 1 AD DB C0 lda InputFlags
00C577 1 2A rol
00C578 1 2A rol
00C579 1 90 F9 bcc finishWrite
00C57B 1 A9 0F lda #$0f
00C57D 1 8D D7 C0 sta OutputFlags
00C580 1 60 rts
00C581 1
00C581 1 GetByte:
00C581 1 A9 0D lda #$0d ;set read flag low
00C583 1 8D D7 C0 sta OutputFlags
00C586 1 waitRead:
00C586 1 AD DB C0 lda InputFlags
00C589 1 2A rol
00C58A 1 B0 FA bcs waitRead
00C58C 1 AD DE C0 lda InputByte
00C58F 1 48 pha
00C590 1 A9 0F lda #$0f ;set all flags high
00C592 1 8D D7 C0 sta OutputFlags
00C595 1 finishRead:
00C595 1 AD DB C0 lda InputFlags
00C598 1 2A rol
00C599 1 90 FA bcc finishRead
00C59B 1 68 pla
00C59C 1 end:
00C59C 1 60 rts
00C59D 1
00C59D 1 00 00 00 00 .repeat 251-<end
00C5A1 1 00 00 00 00
00C5A5 1 00 00 00 00
00C5FC 1 .byte 0
00C5FC 1 .endrepeat
00C5FC 1 00 00 .byte 0,0 ;0000 blocks = check status
00C5FE 1 07 .byte 7 ;bit set(0=status 1=read 2=write) unset(3=format, 4/5=number of volumes, 6=interruptable, 7=removable)
00C5FF 1 14 .byte DriverEntry&$00FF ;low byte of entry
00C600 1
00C600 1 ;Translation of code written in mini-assembler on Apple //e
00C600 1 ;Currently only works if card is in slot 5
00C600 1
00C600 1 .org $1000
001000 1
001000 1

View File

@ -11,38 +11,46 @@ IOError = $27
NoDevice = $28 NoDevice = $28
WriteProtect = $2B WriteProtect = $2B
InputByte = $c08e InputByte = $c08e+SLOT*$10
OutputByte = $c08d OutputByte = $c08d+SLOT*$10
InputFlags = $c08b InputFlags = $c08b+SLOT*$10
OutputFlags = $c087 OutputFlags = $c087+SLOT*$10
ReadBlockCommand = $01 ReadBlockCommand = $01
WriteBlockCommand = $02 WriteBlockCommand = $02
GetTimeCommand = $03 GetTimeCommand = $03
NibbleStorage = $1d ChangeDriveCommand = $04
ExecCommand = $05
LoadFileCommand = $06
SaveFileCommand = $07
.org STARTSLOT .org SLOT*$100 + $C000
;ID bytes for booting and drive detection ;ID bytes for booting and drive detection
cpx #$20 ;ID bytes for ProDOS and the cpx #$20 ;ID bytes for ProDOS and the
cpx #$00 ; Apple Autostart ROM cpx #$00 ; Apple Autostart ROM
cpx #$03 ; cpx #$03 ;
cpx #$3C ;this one for older II's
ldx #SLOT*$10
stx $2b
stx Unit
;force EPROM to second page on boot
lda #$3f ;set all flags high and page 3 of EPROM for menu
PageJump:
sta OutputFlags
jmp Start ;this jump is only called if coming in from PageJump with A=$0f
;entry points for ProDOS
DriverEntry:
lda #$0f ;set all flags high and page 0 of EPROM
sta OutputFlags
jmp Driver
;load first two blocks and execute to boot ;load first two blocks and execute to boot
Boot: Start:
lda #$01 ;set read command lda #$01 ;set read command
sta Command sta Command
jsr $ff58
tsx
lda $0100,x
asl
asl
asl
asl
sta $2b
sta Unit
tax
lda #$00 ;block 0 lda #$00 ;block 0
sta BlockLo sta BlockLo
sta BlockHi sta BlockHi
@ -53,7 +61,6 @@ Boot:
jmp $801 ;execute the block jmp $801 ;execute the block
;;
; ProDOS Driver code ; ProDOS Driver code
; First check that this is the right drive ; First check that this is the right drive
Driver: Driver:
@ -136,36 +143,36 @@ write256:
SendByte: SendByte:
pha pha
waitWrite: waitWrite:
lda InputFlags,x lda InputFlags
rol rol
rol rol
bcs waitWrite bcs waitWrite
pla pla
sta OutputByte,x sta OutputByte
lda #$0e ; set bit 0 low to indicate write started lda #$0e ; set bit 0 low to indicate write started
sta OutputFlags,x sta OutputFlags
finishWrite: finishWrite:
lda InputFlags,x lda InputFlags
rol rol
rol rol
bcc finishWrite bcc finishWrite
lda #$0f lda #$0f
sta OutputFlags,x sta OutputFlags
rts rts
GetByte: GetByte:
lda #$0d ;set read flag low lda #$0d ;set read flag low
sta OutputFlags,x sta OutputFlags
waitRead: waitRead:
lda InputFlags,x lda InputFlags
rol rol
bcs waitRead bcs waitRead
lda InputByte,x lda InputByte
pha pha
lda #$0f ;set all flags high lda #$0f ;set all flags high
sta OutputFlags,x sta OutputFlags
finishRead: finishRead:
lda InputFlags,x lda InputFlags
rol rol
bcc finishRead bcc finishRead
pla pla
@ -177,5 +184,5 @@ end:
.endrepeat .endrepeat
.byte 0,0 ;0000 blocks = check status .byte 0,0 ;0000 blocks = check status
.byte 7 ;bit set(0=status 1=read 2=write) unset(3=format, 4/5=number of volumes, 6=interruptable, 7=removable) .byte 7 ;bit set(0=status 1=read 2=write) unset(3=format, 4/5=number of volumes, 6=interruptable, 7=removable)
.byte Driver&$00FF ;low byte of entry .byte DriverEntry&$00FF ;low byte of entry

195
Apple2/DriveFirmware.lst Normal file
View File

@ -0,0 +1,195 @@
ca65 V2.18 - N/A
Main file : DriveFirmware.asm
Current file: DriveFirmware.asm
000000r 1 ;ProDOS Zero Page
000000r 1 Command = $42 ;ProDOS Command
000000r 1 Unit = $43 ;ProDOS unit (SDDD0000)
000000r 1 BufferLo = $44
000000r 1 BufferHi = $45
000000r 1 BlockLo = $46
000000r 1 BlockHi = $47
000000r 1
000000r 1 ; ProDOS Error Codes
000000r 1 IOError = $27
000000r 1 NoDevice = $28
000000r 1 WriteProtect = $2B
000000r 1
000000r 1 InputByte = $c08e+SLOT*$10
000000r 1 OutputByte = $c08d+SLOT*$10
000000r 1 InputFlags = $c08b+SLOT*$10
000000r 1 OutputFlags = $c087+SLOT*$10
000000r 1
000000r 1 ReadBlockCommand = $01
000000r 1 WriteBlockCommand = $02
000000r 1 GetTimeCommand = $03
000000r 1 ChangeDriveCommand = $04
000000r 1 ExecCommand = $05
000000r 1 LoadFileCommand = $06
000000r 1 SaveFileCommand = $07
000000r 1
000000r 1 .org SLOT*$100 + $C000
00C500 1 ;ID bytes for booting and drive detection
00C500 1 E0 20 cpx #$20 ;ID bytes for ProDOS and the
00C502 1 E0 00 cpx #$00 ; Apple Autostart ROM
00C504 1 E0 03 cpx #$03 ;
00C506 1
00C506 1 A2 50 ldx #SLOT*$10
00C508 1 86 2B stx $2b
00C50A 1 86 43 stx Unit
00C50C 1
00C50C 1 ;force EPROM to second page on boot
00C50C 1 A9 3F lda #$3f ;set all flags high and page 3 of EPROM for menu
00C50E 1 PageJump:
00C50E 1 8D D7 C0 sta OutputFlags
00C511 1 4C 1C C5 jmp Start ;this jump is only called if coming in from PageJump with A=$0f
00C514 1
00C514 1 ;entry points for ProDOS
00C514 1 DriverEntry:
00C514 1 A9 0F lda #$0f ;set all flags high and page 0 of EPROM
00C516 1 8D D7 C0 sta OutputFlags
00C519 1 4C 32 C5 jmp Driver
00C51C 1
00C51C 1 ;load first two blocks and execute to boot
00C51C 1 Start:
00C51C 1 A9 01 lda #$01 ;set read command
00C51E 1 85 42 sta Command
00C520 1
00C520 1 A9 00 lda #$00 ;block 0
00C522 1 85 46 sta BlockLo
00C524 1 85 47 sta BlockHi
00C526 1 85 44 sta BufferLo ;buffer at $800
00C528 1 A9 08 lda #$08
00C52A 1 85 45 sta BufferHi
00C52C 1 20 32 C5 jsr Driver ;get the block
00C52F 1
00C52F 1 4C 01 08 jmp $801 ;execute the block
00C532 1
00C532 1 ; ProDOS Driver code
00C532 1 ; First check that this is the right drive
00C532 1 Driver:
00C532 1 A6 43 ldx Unit
00C534 1 A5 42 lda Command; Check which command is being requested
00C536 1 F0 0C beq GetStatus ;0 = Status command
00C538 1 C9 01 cmp #ReadBlockCommand
00C53A 1 F0 10 beq ReadBlock
00C53C 1 C9 02 cmp #WriteBlockCommand
00C53E 1 F0 46 beq WriteBlock
00C540 1 38 sec ;set carry as we don't support any other commands
00C541 1 A9 53 lda #$53 ;Invalid parameter error
00C543 1 60 rts
00C544 1
00C544 1 ; ProDOS Status Command Handler
00C544 1 GetStatus:
00C544 1 A2 FF ldx #$ff ;low byte number of blocks
00C546 1 A0 FF ldy #$ff ;high byte number of blocks
00C548 1 A9 00 lda #$0 ;zero accumulator and clear carry for success
00C54A 1 18 clc
00C54B 1 60 rts
00C54C 1
00C54C 1 ; ProDOS Read Block Command
00C54C 1 ReadBlock:
00C54C 1 A0 00 ldy #$00 ;Get the current time on each block read for now
00C54E 1 A9 03 lda #GetTimeCommand
00C550 1 20 AE C5 jsr SendByte
00C553 1 getTimeByte:
00C553 1 20 CC C5 jsr GetByte
00C556 1 99 90 BF sta $bf90,y
00C559 1 C8 iny
00C55A 1 C0 04 cpy #$04
00C55C 1 D0 F5 bne getTimeByte
00C55E 1 A9 01 lda #ReadBlockCommand ;read the block after setting the clock
00C560 1 20 AE C5 jsr SendByte
00C563 1 A5 46 lda BlockLo
00C565 1 20 AE C5 jsr SendByte
00C568 1 A5 47 lda BlockHi
00C56A 1 20 AE C5 jsr SendByte
00C56D 1 A0 00 ldy #$0
00C56F 1 20 7D C5 jsr read256
00C572 1 E6 45 inc BufferHi
00C574 1 20 7D C5 jsr read256
00C577 1 C6 45 dec BufferHi
00C579 1 A9 00 lda #$0 ;zero accumulator and clear carry for success
00C57B 1 18 clc
00C57C 1 60 rts
00C57D 1
00C57D 1 read256:
00C57D 1 20 CC C5 jsr GetByte
00C580 1 91 44 sta (BufferLo),y
00C582 1 C8 iny
00C583 1 D0 F8 bne read256
00C585 1 60 rts
00C586 1
00C586 1 ; ProDOS Write Block Command
00C586 1 WriteBlock:
00C586 1 A9 02 lda #WriteBlockCommand
00C588 1 20 AE C5 jsr SendByte
00C58B 1 A5 46 lda BlockLo
00C58D 1 20 AE C5 jsr SendByte
00C590 1 A5 47 lda BlockHi
00C592 1 20 AE C5 jsr SendByte
00C595 1 A0 00 ldy #$0
00C597 1 20 A5 C5 jsr write256
00C59A 1 E6 45 inc BufferHi
00C59C 1 20 A5 C5 jsr write256
00C59F 1 C6 45 dec BufferHi
00C5A1 1 A9 00 lda #$0 ;zero accumulator and clear carry for success
00C5A3 1 18 clc
00C5A4 1 60 rts
00C5A5 1
00C5A5 1 write256:
00C5A5 1 B1 44 lda (BufferLo),y
00C5A7 1 20 AE C5 jsr SendByte
00C5AA 1 C8 iny
00C5AB 1 D0 F8 bne write256
00C5AD 1 60 rts
00C5AE 1
00C5AE 1 SendByte:
00C5AE 1 48 pha
00C5AF 1 waitWrite:
00C5AF 1 AD DB C0 lda InputFlags
00C5B2 1 2A rol
00C5B3 1 2A rol
00C5B4 1 B0 F9 bcs waitWrite
00C5B6 1 68 pla
00C5B7 1 8D DD C0 sta OutputByte
00C5BA 1 A9 0E lda #$0e ; set bit 0 low to indicate write started
00C5BC 1 8D D7 C0 sta OutputFlags
00C5BF 1 finishWrite:
00C5BF 1 AD DB C0 lda InputFlags
00C5C2 1 2A rol
00C5C3 1 2A rol
00C5C4 1 90 F9 bcc finishWrite
00C5C6 1 A9 0F lda #$0f
00C5C8 1 8D D7 C0 sta OutputFlags
00C5CB 1 60 rts
00C5CC 1
00C5CC 1 GetByte:
00C5CC 1 A9 0D lda #$0d ;set read flag low
00C5CE 1 8D D7 C0 sta OutputFlags
00C5D1 1 waitRead:
00C5D1 1 AD DB C0 lda InputFlags
00C5D4 1 2A rol
00C5D5 1 B0 FA bcs waitRead
00C5D7 1 AD DE C0 lda InputByte
00C5DA 1 48 pha
00C5DB 1 A9 0F lda #$0f ;set all flags high
00C5DD 1 8D D7 C0 sta OutputFlags
00C5E0 1 finishRead:
00C5E0 1 AD DB C0 lda InputFlags
00C5E3 1 2A rol
00C5E4 1 90 FA bcc finishRead
00C5E6 1 68 pla
00C5E7 1 end:
00C5E7 1 60 rts
00C5E8 1
00C5E8 1 00 00 00 00 .repeat 251-<end
00C5EC 1 00 00 00 00
00C5F0 1 00 00 00 00
00C5FC 1 .byte 0
00C5FC 1 .endrepeat
00C5FC 1 00 00 .byte 0,0 ;0000 blocks = check status
00C5FE 1 07 .byte 7 ;bit set(0=status 1=read 2=write) unset(3=format, 4/5=number of volumes, 6=interruptable, 7=removable)
00C5FF 1 14 .byte DriverEntry&$00FF ;low byte of entry
00C600 1
00C600 1

View File

@ -0,0 +1,101 @@
;ProDOS Zero Page
Command = $42 ;ProDOS Command
Unit = $43 ;ProDOS unit (SDDD0000)
BufferLo = $44
BufferHi = $45
BlockLo = $46
BlockHi = $47
; ProDOS Error Codes
IOError = $27
NoDevice = $28
WriteProtect = $2B
InputByte = $c08e+SLOT*$10
OutputByte = $c08d+SLOT*$10
InputFlags = $c08b+SLOT*$10
OutputFlags = $c087+SLOT*$10
ReadBlockCommand = $01
WriteBlockCommand = $02
GetTimeCommand = $03
ChangeDriveCommand = $04
ExecCommand = $05
LoadFileCommand = $06
SaveFileCommand = $07
.org SLOT*$100 + $C000
;ID bytes for booting and drive detection
cpx #$20 ;ID bytes for ProDOS and the
cpx #$00 ; Apple Autostart ROM
cpx #$03 ;
ldx #SLOT*$10
stx $2b
stx Unit
;force EPROM to second page on boot
lda #$3f ;set all flags high and page 3 of EPROM for menu
PageJump:
sta OutputFlags
jmp Start ;this jump is only called if coming in from PageJump with A=$2f
;entry points for ProDOS
DriverEntry:
lda #$0f ;set all flags high and page 0 of EPROM
sta OutputFlags
Start:
; Put command firmware here
;
;
;
rts
SendByte:
pha
waitWrite:
lda InputFlags
rol
rol
bcs waitWrite
pla
sta OutputByte
lda #$0e ; set bit 0 low to indicate write started
sta OutputFlags
finishWrite:
lda InputFlags
rol
rol
bcc finishWrite
lda #$0f
sta OutputFlags
rts
GetByte:
lda #$0d ;set read flag low
sta OutputFlags
waitRead:
lda InputFlags
rol
bcs waitRead
lda InputByte
pha
lda #$0f ;set all flags high
sta OutputFlags
finishRead:
lda InputFlags
rol
bcc finishRead
pla
end:
rts
.repeat 251-<end
.byte 0
.endrepeat
.byte 0,0 ;0000 blocks = check status
.byte 7 ;bit set(0=status 1=read 2=write) unset(3=format, 4/5=number of volumes, 6=interruptable, 7=removable)
.byte DriverEntry&$00FF ;low byte of entry

View File

@ -0,0 +1,108 @@
ca65 V2.18 - N/A
Main file : FileAccessFirmware.asm
Current file: FileAccessFirmware.asm
000000r 1 ;ProDOS Zero Page
000000r 1 Command = $42 ;ProDOS Command
000000r 1 Unit = $43 ;ProDOS unit (SDDD0000)
000000r 1 BufferLo = $44
000000r 1 BufferHi = $45
000000r 1 BlockLo = $46
000000r 1 BlockHi = $47
000000r 1
000000r 1 ; ProDOS Error Codes
000000r 1 IOError = $27
000000r 1 NoDevice = $28
000000r 1 WriteProtect = $2B
000000r 1
000000r 1 InputByte = $c08e+SLOT*$10
000000r 1 OutputByte = $c08d+SLOT*$10
000000r 1 InputFlags = $c08b+SLOT*$10
000000r 1 OutputFlags = $c087+SLOT*$10
000000r 1
000000r 1 ReadBlockCommand = $01
000000r 1 WriteBlockCommand = $02
000000r 1 GetTimeCommand = $03
000000r 1 ChangeDriveCommand = $04
000000r 1 ExecCommand = $05
000000r 1 LoadFileCommand = $06
000000r 1 SaveFileCommand = $07
000000r 1
000000r 1 .org SLOT*$100 + $C000
00C500 1 ;ID bytes for booting and drive detection
00C500 1 E0 20 cpx #$20 ;ID bytes for ProDOS and the
00C502 1 E0 00 cpx #$00 ; Apple Autostart ROM
00C504 1 E0 03 cpx #$03 ;
00C506 1
00C506 1 A2 50 ldx #SLOT*$10
00C508 1 86 2B stx $2b
00C50A 1 86 43 stx Unit
00C50C 1
00C50C 1 ;force EPROM to second page on boot
00C50C 1 A9 3F lda #$3f ;set all flags high and page 3 of EPROM for menu
00C50E 1 PageJump:
00C50E 1 8D D7 C0 sta OutputFlags
00C511 1 4C 19 C5 jmp Start ;this jump is only called if coming in from PageJump with A=$2f
00C514 1
00C514 1 ;entry points for ProDOS
00C514 1 DriverEntry:
00C514 1 A9 0F lda #$0f ;set all flags high and page 0 of EPROM
00C516 1 8D D7 C0 sta OutputFlags
00C519 1
00C519 1 Start:
00C519 1
00C519 1 ; Put command firmware here
00C519 1 ;
00C519 1 ;
00C519 1 ;
00C519 1 60 rts
00C51A 1
00C51A 1 SendByte:
00C51A 1 48 pha
00C51B 1 waitWrite:
00C51B 1 AD DB C0 lda InputFlags
00C51E 1 2A rol
00C51F 1 2A rol
00C520 1 B0 F9 bcs waitWrite
00C522 1 68 pla
00C523 1 8D DD C0 sta OutputByte
00C526 1 A9 0E lda #$0e ; set bit 0 low to indicate write started
00C528 1 8D D7 C0 sta OutputFlags
00C52B 1 finishWrite:
00C52B 1 AD DB C0 lda InputFlags
00C52E 1 2A rol
00C52F 1 2A rol
00C530 1 90 F9 bcc finishWrite
00C532 1 A9 0F lda #$0f
00C534 1 8D D7 C0 sta OutputFlags
00C537 1 60 rts
00C538 1
00C538 1 GetByte:
00C538 1 A9 0D lda #$0d ;set read flag low
00C53A 1 8D D7 C0 sta OutputFlags
00C53D 1 waitRead:
00C53D 1 AD DB C0 lda InputFlags
00C540 1 2A rol
00C541 1 B0 FA bcs waitRead
00C543 1 AD DE C0 lda InputByte
00C546 1 48 pha
00C547 1 A9 0F lda #$0f ;set all flags high
00C549 1 8D D7 C0 sta OutputFlags
00C54C 1 finishRead:
00C54C 1 AD DB C0 lda InputFlags
00C54F 1 2A rol
00C550 1 90 FA bcc finishRead
00C552 1 68 pla
00C553 1 end:
00C553 1 60 rts
00C554 1
00C554 1 00 00 00 00 .repeat 251-<end
00C558 1 00 00 00 00
00C55C 1 00 00 00 00
00C5FC 1 .byte 0
00C5FC 1 .endrepeat
00C5FC 1 00 00 .byte 0,0 ;0000 blocks = check status
00C5FE 1 07 .byte 7 ;bit set(0=status 1=read 2=write) unset(3=format, 4/5=number of volumes, 6=interruptable, 7=removable)
00C5FF 1 14 .byte DriverEntry&$00FF ;low byte of entry
00C600 1
00C600 1

Binary file not shown.

Binary file not shown.

94
Apple2/MenuFirmware.asm Normal file
View File

@ -0,0 +1,94 @@
;ProDOS Zero Page
Command = $42 ;ProDOS Command
Unit = $43 ;ProDOS unit (SDDD0000)
BufferLo = $44
BufferHi = $45
BlockLo = $46
BlockHi = $47
; ProDOS Error Codes
IOError = $27
NoDevice = $28
WriteProtect = $2B
InputByte = $c08e+SLOT*$10
OutputByte = $c08d+SLOT*$10
InputFlags = $c08b+SLOT*$10
OutputFlags = $c087+SLOT*$10
ReadBlockCommand = $01
WriteBlockCommand = $02
GetTimeCommand = $03
ChangeDriveCommand = $04
ExecCommand = $05
LoadFileCommand = $06
SaveFileCommand = $07
.org SLOT*$100 + $C000
;ID bytes for booting and drive detection
cpx #$20 ;ID bytes for ProDOS and the
cpx #$00 ; Apple Autostart ROM
cpx #$03 ;
ldx #SLOT*$10
stx $2b
stx Unit
;force EPROM to second page on boot
lda #$3f ;set all flags high and page 1 of EPROMi
PageJump:
sta OutputFlags
jmp Start
;entry points for ProDOS
DriverEntry:
lda #$0f ;set all flags high and page 0 of EPROM
sta OutputFlags
;since the firmware page changes to 0, this falls through to the driver
Start:
lda #$f0 ;restore COUT after PR# called
sta $36
lda #$fd
sta $37
jsr $fc58 ;clear screen and show menu options
ldy #$00
PrintString:
lda Text,y
beq GetChar
ora #$80
jsr $fded
iny
bne PrintString
GetChar:
jsr $fd1b
sec ;subtract ascii "1" to get 0 - 3 from "1" to "4"
sbc #$b1
asl ;put in top nibble as EPROM page
asl
asl
asl
ora #$0f ;set all flags high
jmp PageJump
Text:
.byte "Apple2-IO-RPi",$8d
.byte "(c)2020-2021 Terence J. Boldt",$8d,$8d
.byte "1. Boot",$8d
.byte "2. File Access",$8d
.byte "3. Command Line",$8d,$8d
.byte "May take 45 seconds for RPi to start",$8d
.byte "after intial power-on...",$00
end:
rts
.repeat 251-<end
.byte 0
.endrepeat
.byte 0,0 ;0000 blocks = check status
.byte 7 ;bit set(0=status 1=read 2=write) unset(3=format, 4/5=number of volumes, 6=interruptable, 7=removable)
.byte DriverEntry&$00FF ;low byte of entry

114
Apple2/MenuFirmware.lst Normal file
View File

@ -0,0 +1,114 @@
ca65 V2.18 - N/A
Main file : MenuFirmware.asm
Current file: MenuFirmware.asm
000000r 1 ;ProDOS Zero Page
000000r 1 Command = $42 ;ProDOS Command
000000r 1 Unit = $43 ;ProDOS unit (SDDD0000)
000000r 1 BufferLo = $44
000000r 1 BufferHi = $45
000000r 1 BlockLo = $46
000000r 1 BlockHi = $47
000000r 1
000000r 1 ; ProDOS Error Codes
000000r 1 IOError = $27
000000r 1 NoDevice = $28
000000r 1 WriteProtect = $2B
000000r 1
000000r 1 InputByte = $c08e+SLOT*$10
000000r 1 OutputByte = $c08d+SLOT*$10
000000r 1 InputFlags = $c08b+SLOT*$10
000000r 1 OutputFlags = $c087+SLOT*$10
000000r 1
000000r 1 ReadBlockCommand = $01
000000r 1 WriteBlockCommand = $02
000000r 1 GetTimeCommand = $03
000000r 1 ChangeDriveCommand = $04
000000r 1 ExecCommand = $05
000000r 1 LoadFileCommand = $06
000000r 1 SaveFileCommand = $07
000000r 1
000000r 1 .org SLOT*$100 + $C000
00C500 1 ;ID bytes for booting and drive detection
00C500 1 E0 20 cpx #$20 ;ID bytes for ProDOS and the
00C502 1 E0 00 cpx #$00 ; Apple Autostart ROM
00C504 1 E0 03 cpx #$03 ;
00C506 1
00C506 1 A2 50 ldx #SLOT*$10
00C508 1 86 2B stx $2b
00C50A 1 86 43 stx Unit
00C50C 1
00C50C 1 ;force EPROM to second page on boot
00C50C 1 A9 3F lda #$3f ;set all flags high and page 1 of EPROMi
00C50E 1 PageJump:
00C50E 1 8D D7 C0 sta OutputFlags
00C511 1 4C 19 C5 jmp Start
00C514 1
00C514 1 ;entry points for ProDOS
00C514 1 DriverEntry:
00C514 1 A9 0F lda #$0f ;set all flags high and page 0 of EPROM
00C516 1 8D D7 C0 sta OutputFlags
00C519 1 ;since the firmware page changes to 0, this falls through to the driver
00C519 1
00C519 1 Start:
00C519 1 A9 F0 lda #$f0 ;restore COUT after PR# called
00C51B 1 85 36 sta $36
00C51D 1 A9 FD lda #$fd
00C51F 1 85 37 sta $37
00C521 1 20 58 FC jsr $fc58 ;clear screen and show menu options
00C524 1 A0 00 ldy #$00
00C526 1 PrintString:
00C526 1 B9 42 C5 lda Text,y
00C529 1 F0 08 beq GetChar
00C52B 1 09 80 ora #$80
00C52D 1 20 ED FD jsr $fded
00C530 1 C8 iny
00C531 1 D0 F3 bne PrintString
00C533 1
00C533 1 GetChar:
00C533 1 20 1B FD jsr $fd1b
00C536 1 38 sec ;subtract ascii "1" to get 0 - 3 from "1" to "4"
00C537 1 E9 B1 sbc #$b1
00C539 1 0A asl ;put in top nibble as EPROM page
00C53A 1 0A asl
00C53B 1 0A asl
00C53C 1 0A asl
00C53D 1 09 0F ora #$0f ;set all flags high
00C53F 1 4C 0E C5 jmp PageJump
00C542 1
00C542 1 Text:
00C542 1
00C542 1 41 70 70 6C .byte "Apple2-IO-RPi",$8d
00C546 1 65 32 2D 49
00C54A 1 4F 2D 52 50
00C550 1 28 63 29 32 .byte "(c)2020-2021 Terence J. Boldt",$8d,$8d
00C554 1 30 32 30 2D
00C558 1 32 30 32 31
00C56F 1 31 2E 20 42 .byte "1. Boot",$8d
00C573 1 6F 6F 74 8D
00C577 1 32 2E 20 46 .byte "2. File Access",$8d
00C57B 1 69 6C 65 20
00C57F 1 41 63 63 65
00C586 1 33 2E 20 43 .byte "3. Command Line",$8d,$8d
00C58A 1 6F 6D 6D 61
00C58E 1 6E 64 20 4C
00C597 1 4D 61 79 20 .byte "May take 45 seconds for RPi to start",$8d
00C59B 1 74 61 6B 65
00C59F 1 20 34 35 20
00C5BC 1 61 66 74 65 .byte "after intial power-on...",$00
00C5C0 1 72 20 69 6E
00C5C4 1 74 69 61 6C
00C5D5 1
00C5D5 1 end:
00C5D5 1 60 rts
00C5D6 1
00C5D6 1 00 00 00 00 .repeat 251-<end
00C5DA 1 00 00 00 00
00C5DE 1 00 00 00 00
00C5FC 1 .byte 0
00C5FC 1 .endrepeat
00C5FC 1 00 00 .byte 0,0 ;0000 blocks = check status
00C5FE 1 07 .byte 7 ;bit set(0=status 1=read 2=write) unset(3=format, 4/5=number of volumes, 6=interruptable, 7=removable)
00C5FF 1 14 .byte DriverEntry&$00FF ;low byte of entry
00C600 1
00C600 1

View File

@ -1,22 +1,59 @@
#!/bin/sh #!/bin/sh
ca65 DriveFirmware.asm -D STARTSLOT=\$c000 -o Slot0.o ca65 DriveFirmware.asm -D SLOT=0 -o DriveSlot0.o
ca65 DriveFirmware.asm -D STARTSLOT=\$c100 -o Slot1.o ca65 DriveFirmware.asm -D SLOT=1 -o DriveSlot1.o
ca65 DriveFirmware.asm -D STARTSLOT=\$c200 -o Slot2.o ca65 DriveFirmware.asm -D SLOT=2 -o DriveSlot2.o
ca65 DriveFirmware.asm -D STARTSLOT=\$c300 -o Slot3.o ca65 DriveFirmware.asm -D SLOT=3 -o DriveSlot3.o
ca65 DriveFirmware.asm -D STARTSLOT=\$c400 -o Slot4.o ca65 DriveFirmware.asm -D SLOT=4 -o DriveSlot4.o
ca65 DriveFirmware.asm -D STARTSLOT=\$c500 -o Slot5.o ca65 DriveFirmware.asm -D SLOT=5 -o DriveSlot5.o --listing DriveFirmware.lst
ca65 DriveFirmware.asm -D STARTSLOT=\$c600 -o Slot6.o ca65 DriveFirmware.asm -D SLOT=6 -o DriveSlot6.o
ca65 DriveFirmware.asm -D STARTSLOT=\$c700 -o Slot7.o ca65 DriveFirmware.asm -D SLOT=7 -o DriveSlot7.o
ld65 Slot0.o Slot1.o Slot2.o Slot3.o Slot4.o Slot5.o Slot6.o Slot7.o -o DriveFirmware.bin -t none ld65 DriveSlot0.o DriveSlot1.o DriveSlot2.o DriveSlot3.o DriveSlot4.o DriveSlot5.o DriveSlot6.o DriveSlot7.o -o DriveFirmware.bin -t none
ca65 MenuFirmware.asm -D SLOT=0 -o MenuSlot0.o
ca65 MenuFirmware.asm -D SLOT=1 -o MenuSlot1.o
ca65 MenuFirmware.asm -D SLOT=2 -o MenuSlot2.o
ca65 MenuFirmware.asm -D SLOT=3 -o MenuSlot3.o
ca65 MenuFirmware.asm -D SLOT=4 -o MenuSlot4.o
ca65 MenuFirmware.asm -D SLOT=5 -o MenuSlot5.o --listing MenuFirmware.lst
ca65 MenuFirmware.asm -D SLOT=6 -o MenuSlot6.o
ca65 MenuFirmware.asm -D SLOT=7 -o MenuSlot7.o
ld65 MenuSlot0.o MenuSlot1.o MenuSlot2.o MenuSlot3.o MenuSlot4.o MenuSlot5.o MenuSlot6.o MenuSlot7.o -o MenuFirmware.bin -t none
ca65 CommandFirmware.asm -D SLOT=0 -o CommandSlot0.o
ca65 CommandFirmware.asm -D SLOT=1 -o CommandSlot1.o
ca65 CommandFirmware.asm -D SLOT=2 -o CommandSlot2.o
ca65 CommandFirmware.asm -D SLOT=3 -o CommandSlot3.o
ca65 CommandFirmware.asm -D SLOT=4 -o CommandSlot4.o
ca65 CommandFirmware.asm -D SLOT=5 -o CommandSlot5.o --listing CommandFirmware.lst
ca65 CommandFirmware.asm -D SLOT=6 -o CommandSlot6.o
ca65 CommandFirmware.asm -D SLOT=7 -o CommandSlot7.o
ld65 CommandSlot0.o CommandSlot1.o CommandSlot2.o CommandSlot3.o CommandSlot4.o CommandSlot5.o CommandSlot6.o CommandSlot7.o -o CommandFirmware.bin -t none
ca65 FileAccessFirmware.asm -D SLOT=0 -o FileAccessSlot0.o
ca65 FileAccessFirmware.asm -D SLOT=1 -o FileAccessSlot1.o
ca65 FileAccessFirmware.asm -D SLOT=2 -o FileAccessSlot2.o
ca65 FileAccessFirmware.asm -D SLOT=3 -o FileAccessSlot3.o
ca65 FileAccessFirmware.asm -D SLOT=4 -o FileAccessSlot4.o
ca65 FileAccessFirmware.asm -D SLOT=5 -o FileAccessSlot5.o --listing FileAccessFirmware.lst
ca65 FileAccessFirmware.asm -D SLOT=6 -o FileAccessSlot6.o
ca65 FileAccessFirmware.asm -D SLOT=7 -o FileAccessSlot7.o
ld65 FileAccessSlot0.o FileAccessSlot1.o FileAccessSlot2.o FileAccessSlot3.o FileAccessSlot4.o FileAccessSlot5.o FileAccessSlot6.o FileAccessSlot7.o -o FileAccessFirmware.bin -t none
cat \ cat \
DriveFirmware.bin DriveFirmware.bin DriveFirmware.bin DriveFirmware.bin \ DriveFirmware.bin CommandFirmware.bin FileAccessFirmware.bin MenuFirmware.bin \
DriveFirmware.bin DriveFirmware.bin DriveFirmware.bin DriveFirmware.bin \ DriveFirmware.bin CommandFirmware.bin FileAccessFirmware.bin MenuFirmware.bin \
DriveFirmware.bin DriveFirmware.bin DriveFirmware.bin DriveFirmware.bin \ DriveFirmware.bin CommandFirmware.bin FileAccessFirmware.bin MenuFirmware.bin \
DriveFirmware.bin DriveFirmware.bin DriveFirmware.bin DriveFirmware.bin \ DriveFirmware.bin CommandFirmware.bin FileAccessFirmware.bin MenuFirmware.bin \
> Firmware_27256_EPROM.bin > Firmware_27256_EPROM.bin
rm Slot*.o cat \
rm DriveFirmware.bin DriveFirmware.bin CommandFirmware.bin FileAccessFirmware.bin MenuFirmware.bin \
> Firmware_AT28C64B_EEPROM.bin
ca65 Rpi.Command.asm -o Rpi.Command.o ca65 Rpi.Command.asm -o Rpi.Command.o
ld65 Rpi.Command.o -o Rpi.Command.bin -t none ld65 Rpi.Command.o -o Rpi.Command.bin -t none
rm Rpi.Command.o
rm *.o
rm DriveFirmware.bin
rm MenuFirmware.bin
rm CommandFirmware.bin
rm FileAccessFirmware.bin

View File

@ -45,6 +45,8 @@ const WriteBlockCommand = 2
const GetTimeCommand = 3 const GetTimeCommand = 3
const ChangeDriveCommand = 4 const ChangeDriveCommand = 4
const ExecCommand = 5 const ExecCommand = 5
const LoadFileCommand = 6
const SaveFileCommand = 7
var debug bool = false var debug bool = false