From 9667fda1e422c8d066f81ff5aa42f8f9dc70783c Mon Sep 17 00:00:00 2001 From: Terence Boldt Date: Mon, 30 Nov 2020 21:36:10 -0500 Subject: [PATCH] Update assembler code to work with modern version of cc65 tools --- Firmware/Firmware.asm | 133 ++++++++++++++++++++++++------------------ Firmware/Firmware.bin | Bin 0 -> 2048 bytes Firmware/Warning.asm | 1 + Firmware/assemble.sh | 10 ++++ 4 files changed, 87 insertions(+), 57 deletions(-) create mode 100644 Firmware/Firmware.bin create mode 100644 Firmware/Warning.asm create mode 100755 Firmware/assemble.sh diff --git a/Firmware/Firmware.asm b/Firmware/Firmware.asm index 1fec06e..fb6beee 100644 --- a/Firmware/Firmware.asm +++ b/Firmware/Firmware.asm @@ -3,59 +3,69 @@ ;This allows the card to work in any slot without ;having to write space consuming relocatable code. +;Install cc65 (on Ubuntu this is: sudo apt install cc65) +;Execute the following commands to generate the binary: +;ca65 Firmware.asm -D SLOT1 -o slot1.o +;ca65 Firmware.asm -D SLOT2 -o slot2.o +;ca65 Firmware.asm -D SLOT3 -o slot3.o +;ca65 Firmware.asm -D SLOT4 -o slot4.o +;ca65 Firmware.asm -D SLOT5 -o slot5.o +;ca65 Firmware.asm -D SLOT6 -o slot6.o +;ca65 Firmware.asm -D SLOT7 -o slot7.o +;ld65 -t none slot1.o slot2.o slot3.o slot4.o slot5.o slot6.o slot7.o -o Firmware.bin ;Determine which slot we want by command-line define - if SLOT1 -slot equ $01 - endif - if SLOT2 -slot equ $02 - endif - if SLOT3 -slot equ $03 - endif - if SLOT4 -slot equ $04 - endif - if SLOT5 -slot equ $05 - endif - if SLOT6 -slot equ $06 - endif - if SLOT7 -slot equ $07 - endif + .ifdef SLOT1 + slot = $01 + .endif + .ifdef SLOT2 + slot = $02 + .endif + .ifdef SLOT3 + slot = $03 + .endif + .ifdef SLOT4 + slot = $04 + .endif + .ifdef SLOT5 + slot = $05 + .endif + .ifdef SLOT6 + slot = $06 + .endif + .ifdef SLOT7 + slot = $07 + .endif ;Calculate I/O addresses for this slot -slotwh equ $C081+slot*$10 -slotwl equ $C080+slot*$10 -slotrd equ $C080+slot*$10 -sdrive equ slot*$10 + slotwh = $C081+slot*$10 + slotwl = $C080+slot*$10 + slotrd = $C080+slot*$10 + sdrive = slot*$10 -sram0 equ $478+slot -sram1 equ $4F8+slot -sram2 equ $578+slot -sram3 equ $5F8+slot -sram4 equ $678+slot -sram5 equ $6F8+slot -sram6 equ $778+slot -sram7 equ $7F8+slot + sram0 = $478+slot + sram1 = $4F8+slot + sram2 = $578+slot + sram3 = $5F8+slot + sram4 = $678+slot + sram5 = $6F8+slot + sram6 = $778+slot + sram7 = $7F8+slot ;ProDOS defines -command equ $42 ;ProDOS command -unit equ $43 ;7=drive 6-4=slot 3-0=not used -buflo equ $44 ;low address of buffer -bufhi equ $45 ;hi address of buffer -blklo equ $46 ;low block -blkhi equ $47 ;hi block -ioerr equ $27 ;I/O error code -nodev equ $28 ;no device connected -wperr equ $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 - org $C000+slot*$100 + .org $C000+slot*$100 ;code is non-relocatable ; but duplicated seven times, ; once for each slot @@ -68,7 +78,7 @@ wperr equ $2B ;write protect error ;display copyright message ldy #$00 -drawtxt lda text,y +drawtxt: lda text,y beq boot ;check for NULL ora #$80 ;make it visible to the Apple sta $07D0,y ;put text on last line @@ -76,7 +86,7 @@ drawtxt lda text,y bpl drawtxt ;load first two blocks and execute to boot -boot lda #$01 ;set read command +boot: lda #$01 ;set read command sta command lda #sdrive ;set slot and unit sta unit @@ -101,14 +111,14 @@ boot lda #$01 ;set read command jmp $801 ;execute the block ;This is the ProDOS entry point for this card -entry lda #sdrive ;unit number is $n0 - n = slot +entry: lda #sdrive ;unit number is $n0 - n = slot cmp 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 ;get ProDOS command +docmd: lda command ;get ProDOS command beq getstat ;command 0 is GetStatus cmp #$01 ; beq readblk ;command 1 is ReadBlock @@ -116,13 +126,13 @@ docmd lda command ;get ProDOS command lda #wperr ;write protect error rts ;go back to ProDOS -getstat clc ;send back status +getstat: clc ;send back status lda #$00 ;good status ldx #$00 ;1024 blocks ldy #$04 ; rts -readblk lda blkhi ;get hi block +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 @@ -165,15 +175,15 @@ readblk lda blkhi ;get hi block ;This gets 256 bytes from the ROM card ;assuming high latch value is in sram0 ;and low latch value is in sram1 -get256 ldy #$00 ;clear buffer counter +get256: ldy #$00 ;clear buffer counter lda sram0 ;get high latch value sta slotwh ;set high latch for card -loop256 ldx #$00 ;clear port counter +loop256: ldx #$00 ;clear port counter lda sram1 ;get low latch value sta slotwl ;set low latch -loop16 lda slotrd,x ;get a byte +loop16: lda slotrd,x ;get a byte sta (buflo),y ;write into the buffer iny inx @@ -186,10 +196,19 @@ loop16 lda slotrd,x ;get a byte rts -text db "ROM-Drive (c)1998-2019 Terence J. Boldt", 0 +text: .byte "ROM-Drive (c)1998-2019 Terence J. Boldt", 0 - org $C0FC+slot*$100 - db 0,0 ;0000 blocks = check status - db 3 ;bit 0=read 1=status - db entry&$00FF ;low byte of entry +; 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 + +; In 1998, cc65 used to allow this but now with ld65 removes the padded bytes +; .org $C0FC+slot*$100 + +; CAUTION: These are padding bytes entered manually, add or remove +; to match if changing code. Firmware must be 256 bytes + .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + .byte 0,0 ;0000 blocks = check status + .byte 3 ;bit 0=read 1=status + .byte entry&$00FF ;low byte of entry diff --git a/Firmware/Firmware.bin b/Firmware/Firmware.bin new file mode 100644 index 0000000000000000000000000000000000000000..1ed8ea82af98b345994167017a3a01763542fa19 GIT binary patch literal 2048 zcmcJ~&ubGw6bJAv9WWM!96i2ci>9W9))qXJG;Jj)7U>_bn`B}Z)7`MywxmD3e}VLqd+&GlIwCfgPMv z3eg(WxY~5>X`1`=Iahbxefz$8=i2?tm`eE!cWT|>Qk$u*l;3crHo%t~v@=$#yPr?F z40mb0PF9Rr{?b=>eVMA?TQMH;4-8J{(uBXMwR1CjZeIAWzt`N=-#;3}zQ6r>haa5&{HQ;#1M|Z;{=>fikZ7#5{Y~`eGfmsy zwEX#jACn)Lze%*TnN1J<%}MzS4!_swFO2#Nx|jLAuFUM!(BGPrzv%F8ziau+13xCeF@Kk6 zH8Wcq`n!|zR~-Jh(_b0&SM)gZ$H(!X_5Ei=W2Noyp}&&p+5Vp8uMGT{{K@=1qSei8 KedzD~PyZk6_|3Zj literal 0 HcmV?d00001 diff --git a/Firmware/Warning.asm b/Firmware/Warning.asm new file mode 100644 index 0000000..69207ba --- /dev/null +++ b/Firmware/Warning.asm @@ -0,0 +1 @@ + .byte "Do not overwrite any of blocks after this point as it is used for the firmware. There are 7 copies of the 256 byte firmware, one for each slot due to 6502 code being non-relocatable. Have fun and feel free to improve on the hardware / sofware. --- Terence" diff --git a/Firmware/assemble.sh b/Firmware/assemble.sh new file mode 100755 index 0000000..f3be44d --- /dev/null +++ b/Firmware/assemble.sh @@ -0,0 +1,10 @@ +#!/bin/sh +ca65 Warning.asm -o warning.o +ca65 Firmware.asm -D SLOT1 -o slot1.o +ca65 Firmware.asm -D SLOT2 -o slot2.o +ca65 Firmware.asm -D SLOT3 -o slot3.o +ca65 Firmware.asm -D SLOT4 -o slot4.o +ca65 Firmware.asm -D SLOT5 -o slot5.o +ca65 Firmware.asm -D SLOT6 -o slot6.o +ca65 Firmware.asm -D SLOT7 -o slot7.o +ld65 -t none warning.o slot1.o slot2.o slot3.o slot4.o slot5.o slot6.o slot7.o -o Firmware.bin