Update firmware to add menu

This commit is contained in:
Terence Boldt 2021-03-27 10:25:42 -04:00
parent 3f14ea9510
commit 786617fb03
7 changed files with 438 additions and 33 deletions

View File

@ -15,34 +15,42 @@ InputByte = $c08e
OutputByte = $c08d
InputFlags = $c08b
OutputFlags = $c087
ReadBlockCommand = $01
WriteBlockCommand = $02
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
cpx #$20 ;ID bytes for ProDOS and the
cpx #$00 ; Apple Autostart ROM
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 #$1f ;set all flags high and page 1 of EPROM
PageJump:
sta OutputFlags,x
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,x
jmp Driver
;load first two blocks and execute to boot
Boot:
Start:
lda #$01 ;set read command
sta Command
jsr $ff58
tsx
lda $0100,x
asl
asl
asl
asl
sta $2b
sta Unit
tax
lda #$00 ;block 0
sta BlockLo
sta BlockHi
@ -53,7 +61,6 @@ Boot:
jmp $801 ;execute the block
;;
; ProDOS Driver code
; First check that this is the right drive
Driver:
@ -177,5 +184,5 @@ end:
.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 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
000000r 1 OutputByte = $c08d
000000r 1 InputFlags = $c08b
000000r 1 OutputFlags = $c087
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 1F lda #$1f ;set all flags high and page 1 of EPROM
00C50E 1 PageJump:
00C50E 1 9D 87 C0 sta OutputFlags,x
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 9D 87 C0 sta OutputFlags,x
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 BD 8B C0 lda InputFlags,x
00C5B2 1 2A rol
00C5B3 1 2A rol
00C5B4 1 B0 F9 bcs waitWrite
00C5B6 1 68 pla
00C5B7 1 9D 8D C0 sta OutputByte,x
00C5BA 1 A9 0E lda #$0e ; set bit 0 low to indicate write started
00C5BC 1 9D 87 C0 sta OutputFlags,x
00C5BF 1 finishWrite:
00C5BF 1 BD 8B C0 lda InputFlags,x
00C5C2 1 2A rol
00C5C3 1 2A rol
00C5C4 1 90 F9 bcc finishWrite
00C5C6 1 A9 0F lda #$0f
00C5C8 1 9D 87 C0 sta OutputFlags,x
00C5CB 1 60 rts
00C5CC 1
00C5CC 1 GetByte:
00C5CC 1 A9 0D lda #$0d ;set read flag low
00C5CE 1 9D 87 C0 sta OutputFlags,x
00C5D1 1 waitRead:
00C5D1 1 BD 8B C0 lda InputFlags,x
00C5D4 1 2A rol
00C5D5 1 B0 FA bcs waitRead
00C5D7 1 BD 8E C0 lda InputByte,x
00C5DA 1 48 pha
00C5DB 1 A9 0F lda #$0f ;set all flags high
00C5DD 1 9D 87 C0 sta OutputFlags,x
00C5E0 1 finishRead:
00C5E0 1 BD 8B C0 lda InputFlags,x
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

Binary file not shown.

Binary file not shown.

87
Apple2/MenuFirmware.asm Normal file
View File

@ -0,0 +1,87 @@
;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
OutputByte = $c08d
InputFlags = $c08b
OutputFlags = $c087
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 #$1f ;set all flags high and page 1 of EPROMi
PageJump:
sta OutputFlags,x
jmp Start
;entry points for ProDOS
DriverEntry:
lda #$0f ;set all flags high and page 0 of EPROM
sta OutputFlags,x
;since the firmware page changes to 0, this falls through to the driver
Start:
jsr $fc58
ldy #$00
PrintString:
lda Text,y
ora #$80
beq GetChar
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 "1. Boot",$8d
.byte "2. Set Clock",$8d
.byte "3. Command Line",$8d
.byte "4. File Access",$8d
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

101
Apple2/MenuFirmware.lst Normal file
View File

@ -0,0 +1,101 @@
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
000000r 1 OutputByte = $c08d
000000r 1 InputFlags = $c08b
000000r 1 OutputFlags = $c087
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 1F lda #$1f ;set all flags high and page 1 of EPROMi
00C50E 1 PageJump:
00C50E 1 9D 87 C0 sta OutputFlags,x
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 9D 87 C0 sta OutputFlags,x
00C519 1 ;since the firmware page changes to 0, this falls through to the driver
00C519 1
00C519 1 Start:
00C519 1 20 58 FC jsr $fc58
00C51C 1 A0 00 ldy #$00
00C51E 1 PrintString:
00C51E 1 B9 3A C5 lda Text,y
00C521 1 09 80 ora #$80
00C523 1 F0 06 beq GetChar
00C525 1 20 ED FD jsr $fded
00C528 1 C8 iny
00C529 1 D0 F3 bne PrintString
00C52B 1
00C52B 1 GetChar:
00C52B 1 20 1B FD jsr $fd1b
00C52E 1 38 sec ;subtract ascii "1" to get 0 - 3 from "1" to "4"
00C52F 1 E9 B1 sbc #$b1
00C531 1 0A asl ;put in top nibble as EPROM page
00C532 1 0A asl
00C533 1 0A asl
00C534 1 0A asl
00C535 1 09 0F ora #$0f ;set all flags high
00C537 1 4C 0E C5 jmp PageJump
00C53A 1
00C53A 1 Text:
00C53A 1
00C53A 1 31 2E 20 42 .byte "1. Boot",$8d
00C53E 1 6F 6F 74 8D
00C542 1 32 2E 20 53 .byte "2. Set Clock",$8d
00C546 1 65 74 20 43
00C54A 1 6C 6F 63 6B
00C54F 1 33 2E 20 43 .byte "3. Command Line",$8d
00C553 1 6F 6D 6D 61
00C557 1 6E 64 20 4C
00C55F 1 34 2E 20 46 .byte "4. File Access",$8d
00C563 1 69 6C 65 20
00C567 1 41 63 63 65
00C56E 1
00C56E 1 end:
00C56E 1 60 rts
00C56F 1
00C56F 1 00 00 00 00 .repeat 251-<end
00C573 1 00 00 00 00
00C577 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,37 @@
#!/bin/sh
ca65 DriveFirmware.asm -D STARTSLOT=\$c000 -o Slot0.o
ca65 DriveFirmware.asm -D STARTSLOT=\$c100 -o Slot1.o
ca65 DriveFirmware.asm -D STARTSLOT=\$c200 -o Slot2.o
ca65 DriveFirmware.asm -D STARTSLOT=\$c300 -o Slot3.o
ca65 DriveFirmware.asm -D STARTSLOT=\$c400 -o Slot4.o
ca65 DriveFirmware.asm -D STARTSLOT=\$c500 -o Slot5.o
ca65 DriveFirmware.asm -D STARTSLOT=\$c600 -o Slot6.o
ca65 DriveFirmware.asm -D STARTSLOT=\$c700 -o Slot7.o
ld65 Slot0.o Slot1.o Slot2.o Slot3.o Slot4.o Slot5.o Slot6.o Slot7.o -o DriveFirmware.bin -t none
ca65 DriveFirmware.asm -D SLOT=0 -o DriveSlot0.o
ca65 DriveFirmware.asm -D SLOT=1 -o DriveSlot1.o
ca65 DriveFirmware.asm -D SLOT=2 -o DriveSlot2.o
ca65 DriveFirmware.asm -D SLOT=3 -o DriveSlot3.o
ca65 DriveFirmware.asm -D SLOT=4 -o DriveSlot4.o
ca65 DriveFirmware.asm -D SLOT=5 -o DriveSlot5.o --listing DriveFirmware.lst
ca65 DriveFirmware.asm -D SLOT=6 -o DriveSlot6.o
ca65 DriveFirmware.asm -D SLOT=7 -o DriveSlot7.o
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
cat \
DriveFirmware.bin DriveFirmware.bin DriveFirmware.bin DriveFirmware.bin \
DriveFirmware.bin DriveFirmware.bin DriveFirmware.bin DriveFirmware.bin \
DriveFirmware.bin DriveFirmware.bin DriveFirmware.bin DriveFirmware.bin \
DriveFirmware.bin DriveFirmware.bin DriveFirmware.bin DriveFirmware.bin \
DriveFirmware.bin MenuFirmware.bin DriveFirmware.bin DriveFirmware.bin \
DriveFirmware.bin MenuFirmware.bin DriveFirmware.bin DriveFirmware.bin \
DriveFirmware.bin MenuFirmware.bin DriveFirmware.bin DriveFirmware.bin \
DriveFirmware.bin MenuFirmware.bin DriveFirmware.bin DriveFirmware.bin \
> Firmware_27256_EPROM.bin
rm Slot*.o
rm DriveFirmware.bin
cat \
DriveFirmware.bin MenuFirmware.bin DriveFirmware.bin DriveFirmware.bin \
> Firmware_AT28C64B_EEPROM.bin
ca65 Rpi.Command.asm -o Rpi.Command.o
ld65 Rpi.Command.o -o Rpi.Command.bin -t none
rm Rpi.Command.o
rm *.o
rm DriveFirmware.bin
rm MenuFirmware.bin