diff --git a/Firmware/BlankDriveWithFirmware.po b/Firmware/BlankDriveWithFirmware.po index 9c2d72b..f9aae6c 100644 Binary files a/Firmware/BlankDriveWithFirmware.po and b/Firmware/BlankDriveWithFirmware.po differ diff --git a/Firmware/Firmware.asm b/Firmware/Firmware.asm index f36b279..6ddf450 100644 --- a/Firmware/Firmware.asm +++ b/Firmware/Firmware.asm @@ -8,166 +8,167 @@ blockHalfCounter = $FF ;ProDOS defines - 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 + 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 ;for relocatable code, address to jump to instead of JSR absolute + RTS jumpAddressLo = $FA jumpAddressHi = $FB ioAddressLo = $FC ioAddressHi = $FD - knownRts = $FF58 + knownRts = $FF58 - .org $C700 - ;code is relocatable - ; but set to $c700 for - ; readability + .org $C700 + ;code is relocatable + ; but set to $c700 for + ; readability ;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 + cpx #$20 ;ID bytes for ProDOS and the + ldy #$00 ; Apple Autostart ROM + cpx #$03 ; + cpx #$3C ;this one for older II's ;zero out block numbers and buffer address - sty buflo - sty blklo - sty blkhi + sty buflo + sty blklo + sty blkhi iny ;set command = 1 for read block - sty command - sty jumpAddressLo ;$01 of $0801 where boot code starts - jsr knownRts ;jump to known RTS to get our address from the stack + sty command + sty jumpAddressLo ;$01 of $0801 where boot code starts + jsr knownRts ;jump to known RTS to get our address from the stack tsx - lda $0100,x ;this for example would be $C7 in slot 7 - sta bufhi ;keep the slot here - asl - asl - asl - asl - tax + lda $0100,x ;this for example would be $C7 in slot 7 + sta bufhi ;keep the slot here + asl + asl + asl + asl + tax ;display copyright message - ldy #knownRts - sta jumpAddressHi + lda #knownRts + sta jumpAddressHi start: - lda #$C0 - sta ioAddressHi - jsr knownRts + lda #$C0 + sta ioAddressHi + jsr knownRts tsx - lda $0100,x - asl a - asl a - asl a - asl a + lda $0100,x + asl a + asl a + asl a + asl a tax - cpx unit ;make sure same as ProDOS - beq docmd ;yep, do command - sec ;nope, set device not connected - lda #nodev - rts ;go back to ProDOS + cpx unit ;make sure same as ProDOS + beq docmd ;yep, do command + sec ;nope, set device not connected + lda #nodev + rts ;go back to ProDOS docmd: 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 + 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 getstat: - clc ;send back status - lda #$00 ;good status - ldx #$00 ;1024 blocks - ldy #$04 ; + clc ;send back status + lda #$00 ;good status + ldx #$00 ;1024 blocks + ldy #$04 ; rts readblk: - 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 ;save it in scratch ram 0 + 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 ;save it in scratch ram 0 ;so we can stuff it in the ;high latch later - 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 - sta highLatch ;save it back in scratch ram - 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 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 + sta highLatch ;save it back in scratch ram + 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 ;This gets 256 bytes from the ROM card read256: - ldy #$00 - lda highLatch ;get high latch value - sta writeLatchHigh,x ;set high latch for card + ldy #$00 + lda highLatch ;get high latch value + sta writeLatchHigh,x ;set high latch for card loop256: - lda lowLatch - sta writeLatchLow,x + lda lowLatch + sta writeLatchLow,x txa - ora #$80 - sta ioAddressLo + ora #$80 + sta ioAddressLo loop16: - sty tempY - ldy #$00 - lda (ioAddressLo),y - ldy tempY - sta (buflo),y + sty tempY + ldy #$00 + lda (ioAddressLo),y + ldy tempY + sta (buflo),y iny - inc ioAddressLo - lda ioAddressLo - and #$0F - bne loop16 - inc lowLatch - cpy #$00 - bne loop256 - dec blockHalfCounter - bne readnext256 - dec bufhi - clc ;clear error code for success - lda #$00 - rts ;return to ProDOS + inc ioAddressLo + lda ioAddressLo + and #$0F + bne loop16 + inc lowLatch + cpy #$00 + bne loop256 + dec blockHalfCounter + bne readnext256 + dec bufhi + clc ;clear error code for success + lda #$00 + jmp (jumpAddressLo) readnext256: - inc bufhi - clc - bcc read256 + inc bufhi + clc + bcc read256 ;macro for string with high-bit set .macro aschi str @@ -176,9 +177,9 @@ readnext256: .endrep .endmacro -text: aschi "ROM-Drive (c)1998-2021 Terence J. Boldt" +text: aschi "ROM-Drive (c)1998-2021 Terence J. Boldt" end: - .byte 0 +.byte 0 ; 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 @@ -187,7 +188,7 @@ end: .byte 0 .endrepeat - .byte 0,0 ;0000 blocks = check status - .byte 3 ;bit 0=read 1=status - .byte entry&$00FF ;low byte of entry +.byte 0,0 ;0000 blocks = check status +.byte 3 ;bit 0=read 1=status +.byte knownRts -00C73B 1 85 FB sta jumpAddressHi +00C735 1 A9 58 lda #knownRts +00C73B 1 85 FB sta jumpAddressHi 00C73D 1 start: -00C73D 1 A9 C0 lda #$C0 -00C73F 1 85 FD sta ioAddressHi -00C741 1 20 58 FF jsr knownRts +00C73D 1 A9 C0 lda #$C0 +00C73F 1 85 FD sta ioAddressHi +00C741 1 20 58 FF jsr knownRts 00C744 1 BA tsx -00C745 1 BD 00 01 lda $0100,x -00C748 1 0A asl a -00C749 1 0A asl a -00C74A 1 0A asl a -00C74B 1 0A asl a +00C745 1 BD 00 01 lda $0100,x +00C748 1 0A asl a +00C749 1 0A asl a +00C74A 1 0A asl a +00C74B 1 0A asl a 00C74C 1 AA tax -00C74D 1 E4 43 cpx unit ;make sure same as ProDOS -00C74F 1 F0 04 beq docmd ;yep, do command -00C751 1 38 sec ;nope, set device not connected -00C752 1 A9 28 lda #nodev -00C754 1 60 rts ;go back to ProDOS +00C74D 1 E4 43 cpx unit ;make sure same as ProDOS +00C74F 1 F0 04 beq docmd ;yep, do command +00C751 1 38 sec ;nope, set device not connected +00C752 1 A9 28 lda #nodev +00C754 1 60 rts ;go back to ProDOS 00C755 1 00C755 1 docmd: 00C755 1 A5 42 lda command -00C757 1 F0 08 beq getstat ;command 0 is GetStatus -00C759 1 C9 01 cmp #$01 -00C75B 1 F0 0C beq readblk ;command 1 is ReadBlock -00C75D 1 38 sec ;Format/Write not permitted -00C75E 1 A9 2B lda #wperr ;write protect error -00C760 1 60 rts ;go back to ProDOS +00C757 1 F0 08 beq getstat ;command 0 is GetStatus +00C759 1 C9 01 cmp #$01 +00C75B 1 F0 0C beq readblk ;command 1 is ReadBlock +00C75D 1 38 sec ;Format/Write not permitted +00C75E 1 A9 2B lda #wperr ;write protect error +00C760 1 60 rts ;go back to ProDOS 00C761 1 00C761 1 getstat: -00C761 1 18 clc ;send back status -00C762 1 A9 00 lda #$00 ;good status -00C764 1 A2 00 ldx #$00 ;1024 blocks -00C766 1 A0 04 ldy #$04 ; +00C761 1 18 clc ;send back status +00C762 1 A9 00 lda #$00 ;good status +00C764 1 A2 00 ldx #$00 ;1024 blocks +00C766 1 A0 04 ldy #$04 ; 00C768 1 60 rts 00C769 1 00C769 1 readblk: -00C769 1 A5 47 lda blkhi ;get hi block -00C76B 1 0A asl a ;shift up to top 3 bits -00C76C 1 0A asl a ;since that's all the high -00C76D 1 0A asl a ;blocks we can handle -00C76E 1 0A asl a ; -00C76F 1 0A asl a ; -00C770 1 85 F8 sta highLatch ;save it in scratch ram 0 +00C769 1 A5 47 lda blkhi ;get hi block +00C76B 1 0A asl a ;shift up to top 3 bits +00C76C 1 0A asl a ;since that's all the high +00C76D 1 0A asl a ;blocks we can handle +00C76E 1 0A asl a ; +00C76F 1 0A asl a ; +00C770 1 85 F8 sta highLatch ;save it in scratch ram 0 00C772 1 ;so we can stuff it in the 00C772 1 ;high latch later -00C772 1 A5 46 lda blklo ;get low block -00C774 1 4A lsr a ;shift so we get the top 5 -00C775 1 4A lsr a ;bits - this also goes in -00C776 1 4A lsr a ;the high latch -00C777 1 05 F8 ora highLatch ;add it to those top 3 bits -00C779 1 85 F8 sta highLatch ;save it back in scratch ram -00C77B 1 A5 46 lda blklo ;get low block -00C77D 1 0A asl a ;shift it to top 3 bits -00C77E 1 0A asl a ; -00C77F 1 0A asl a ; -00C780 1 0A asl a ; -00C781 1 0A asl a ; -00C782 1 85 F9 sta lowLatch -00C784 1 A9 02 lda #$02 -00C786 1 85 FF sta blockHalfCounter +00C772 1 A5 46 lda blklo ;get low block +00C774 1 4A lsr a ;shift so we get the top 5 +00C775 1 4A lsr a ;bits - this also goes in +00C776 1 4A lsr a ;the high latch +00C777 1 05 F8 ora highLatch ;add it to those top 3 bits +00C779 1 85 F8 sta highLatch ;save it back in scratch ram +00C77B 1 A5 46 lda blklo ;get low block +00C77D 1 0A asl a ;shift it to top 3 bits +00C77E 1 0A asl a ; +00C77F 1 0A asl a ; +00C780 1 0A asl a ; +00C781 1 0A asl a ; +00C782 1 85 F9 sta lowLatch +00C784 1 A9 02 lda #$02 +00C786 1 85 FF sta blockHalfCounter 00C788 1 00C788 1 ;This gets 256 bytes from the ROM card 00C788 1 00C788 1 read256: -00C788 1 A0 00 ldy #$00 -00C78A 1 A5 F8 lda highLatch ;get high latch value -00C78C 1 9D 81 C0 sta writeLatchHigh,x ;set high latch for card +00C788 1 A0 00 ldy #$00 +00C78A 1 A5 F8 lda highLatch ;get high latch value +00C78C 1 9D 81 C0 sta writeLatchHigh,x ;set high latch for card 00C78F 1 loop256: -00C78F 1 A5 F9 lda lowLatch -00C791 1 9D 80 C0 sta writeLatchLow,x +00C78F 1 A5 F9 lda lowLatch +00C791 1 9D 80 C0 sta writeLatchLow,x 00C794 1 8A txa -00C795 1 09 80 ora #$80 -00C797 1 85 FC sta ioAddressLo +00C795 1 09 80 ora #$80 +00C797 1 85 FC sta ioAddressLo 00C799 1 loop16: -00C799 1 84 FE sty tempY -00C79B 1 A0 00 ldy #$00 -00C79D 1 B1 FC lda (ioAddressLo),y -00C79F 1 A4 FE ldy tempY -00C7A1 1 91 44 sta (buflo),y +00C799 1 84 FE sty tempY +00C79B 1 A0 00 ldy #$00 +00C79D 1 B1 FC lda (ioAddressLo),y +00C79F 1 A4 FE ldy tempY +00C7A1 1 91 44 sta (buflo),y 00C7A3 1 C8 iny -00C7A4 1 E6 FC inc ioAddressLo -00C7A6 1 A5 FC lda ioAddressLo -00C7A8 1 29 0F and #$0F -00C7AA 1 D0 ED bne loop16 -00C7AC 1 E6 F9 inc lowLatch -00C7AE 1 C0 00 cpy #$00 -00C7B0 1 D0 DD bne loop256 -00C7B2 1 C6 FF dec blockHalfCounter -00C7B4 1 D0 06 bne readnext256 -00C7B6 1 C6 45 dec bufhi -00C7B8 1 18 clc ;clear error code for success -00C7B9 1 A9 00 lda #$00 -00C7BB 1 60 rts ;return to ProDOS -00C7BC 1 -00C7BC 1 readnext256: -00C7BC 1 E6 45 inc bufhi -00C7BE 1 18 clc -00C7BF 1 90 C7 bcc read256 -00C7C1 1 -00C7C1 1 ;macro for string with high-bit set -00C7C1 1 .macro aschi str -00C7C1 1 .repeat .strlen (str), c -00C7C1 1 .byte .strat (str, c) | $80 -00C7C1 1 .endrep -00C7C1 1 .endmacro -00C7C1 1 -00C7C1 1 D2 CF CD AD text: aschi "ROM-Drive (c)1998-2021 Terence J. Boldt" -00C7C5 1 C4 F2 E9 F6 -00C7C9 1 E5 A0 A8 E3 -00C7E8 1 end: -00C7E8 1 00 .byte 0 -00C7E9 1 -00C7E9 1 ; These bytes need to be at the top of the 256 byte firmware as ProDOS -00C7E9 1 ; uses these to find the entry point and drive capabilities -00C7E9 1 -00C7E9 1 00 00 00 00 .repeat 251-