From 3ac2b9d74f8395bdc2bdd561c2856e1199cc7bb0 Mon Sep 17 00:00:00 2001 From: mgcaret Date: Sat, 18 Mar 2017 20:00:43 -0700 Subject: [PATCH] conversion to cc65 --- .gitignore | 3 + README.md | 2 +- rom4x/B0_C552_patch_bootfail.s | 14 +-- rom4x/B0_C763_switcher.s | 6 +- rom4x/B0_FAB4_patch_pwrup.s | 7 +- rom4x/B0_FAC8_patch_reset.s | 7 +- rom4x/B1_C763_switcher.s | 6 +- rom4x/B1_E000_rom4x.s | 109 +++++++++--------- rom4x/B1_E300_new_bootfail.s | 10 +- rom4x/Rakefile | 24 ++-- rom5x/B0_CFF9_switch_cmd.s | 6 +- rom5x/B0_FAB4_patch_pwrup.s | 6 +- rom5x/B0_FAC8_patch_reset.s | 6 +- rom5x/B0_FB68_center_title.s | 2 +- rom5x/B0_FBDF_bell1_hijack.s | 4 +- rom5x/B1_C53D_patch_out_rom_cksum.s | 4 +- rom5x/B1_D516_boot5x.s | 49 ++++---- rom5x/B1_D6CE_rom5x_misc.s | 51 ++++---- rom5x/B1_DB63_reset5x.s | 19 +-- rom5x/B1_FB3C_rom5x_dispatch.s | 7 +- rom5x/B1_FBE2_bell1_hijack_b1.s | 6 +- rom5x/Rakefile | 17 ++- .../accel_reverse/B1_FDD5_accel_reverse.s | 4 +- 23 files changed, 195 insertions(+), 174 deletions(-) diff --git a/.gitignore b/.gitignore index 9e69fdd..de2e1f0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,8 @@ *.bin *.swp *.zip +*.o +*.lst +*.b copyrom.sh diff --git a/README.md b/README.md index 64655f3..3e3f8da 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ It may work with other ROM dumps, it will *not* work with any other ROM version, Place the ROM dump in the directory with the other files and name it `iic_rom4.bin` for ROM 4X and `iic+_rom5.bin` for ROM 5X. -Now you will need a 65C02 cross assembler. The code was developed using [xa](http://www.floodgap.com/retrotech/xa/), mainly because it was available as a prebuilt binary in my preferred Linux distro's package repositories and supported the 65C02 opcodes. +Now you will need a 65C02 cross assembler. The current codebase is developed using ca65 from the [cc65](http://www.cc65.org/) project. (Note: The code was developed originally using [xa](http://www.floodgap.com/retrotech/xa/)). Finally you will need [Ruby](https://www.ruby-lang.org/en/) and [Rake](https://github.com/ruby/rake). diff --git a/rom4x/B0_C552_patch_bootfail.s b/rom4x/B0_C552_patch_bootfail.s index 5b63898..4c9b504 100644 --- a/rom4x/B0_C552_patch_bootfail.s +++ b/rom4x/B0_C552_patch_bootfail.s @@ -1,14 +1,14 @@ -#include "iic.defs" - -.text -* = $c552 +.psc02 +.code +.include "iic.defs" + .org $c552 jsr setnorm jsr init bra cbtfail - .dsb coma-*,$ea + .res coma-*,$ea bra coma ; Make sure coma routine exists - .db 0 ; rom4x present -cbtfail jsr setvid + .byte 0 ; rom4x present +cbtfail: jsr setvid jsr setkbd lda #>(nbtfail-1) pha diff --git a/rom4x/B0_C763_switcher.s b/rom4x/B0_C763_switcher.s index fc61f20..f821047 100644 --- a/rom4x/B0_C763_switcher.s +++ b/rom4x/B0_C763_switcher.s @@ -1,6 +1,6 @@ -#include "iic.defs" -.text -* = gorst4x +.code +.include "iic.defs" + .org gorst4x sta rombank ; gorst4x jmp rst4xrtn ; in other bank jmp reset4x sta rombank ; gobt4x diff --git a/rom4x/B0_FAB4_patch_pwrup.s b/rom4x/B0_FAB4_patch_pwrup.s index 3b76299..0e7c852 100644 --- a/rom4x/B0_FAB4_patch_pwrup.s +++ b/rom4x/B0_FAB4_patch_pwrup.s @@ -1,7 +1,6 @@ ; patch PWRUP to call boot4x - -#include "iic.defs" -.text -* = $fab4 +.code +.include "iic.defs" + .org $fab4 nop jmp gobt4x diff --git a/rom4x/B0_FAC8_patch_reset.s b/rom4x/B0_FAC8_patch_reset.s index 3bfd4cf..ce27568 100644 --- a/rom4x/B0_FAC8_patch_reset.s +++ b/rom4x/B0_FAC8_patch_reset.s @@ -1,7 +1,6 @@ ; patch RESET.X to call reset4x - -#include "iic.defs" -.text -* = $fac8 +.code +.include "iic.defs" + .org $fac8 jmp gorst4x diff --git a/rom4x/B1_C763_switcher.s b/rom4x/B1_C763_switcher.s index 149ecee..93b8d43 100644 --- a/rom4x/B1_C763_switcher.s +++ b/rom4x/B1_C763_switcher.s @@ -1,6 +1,6 @@ -#include "iic.defs" -.text -* = gorst4x +.code +.include "iic.defs" + .org gorst4x sta rombank ; gorst4x jmp reset4x ; in other bank jmp rstxrtn sta rombank ; gobt4x diff --git a/rom4x/B1_E000_rom4x.s b/rom4x/B1_E000_rom4x.s index 7e4daa7..7bac439 100644 --- a/rom4x/B1_E000_rom4x.s +++ b/rom4x/B1_E000_rom4x.s @@ -1,15 +1,16 @@ -#include "iic.defs" -.text -* = reset4x +.psc02 +.code +.include "iic.defs" + .org reset4x stz power2 + rx_mslot ; action = normal boot asl butn1 ; closed apple bcs ckdiag -exitrst jmp gorst4x ; return to RESET.X +exitrst: jmp gorst4x ; return to RESET.X ; check to see if both apples are down -ckdiag bit butn0 ; open apple +ckdiag: bit butn0 ; open apple bmi exitrst ; return to RESET.X ; present menu because only closed apple is down -menu4x jsr gobanner ; "Apple //c" +menu4x: jsr gobanner ; "Apple //c" ldx #$00 ; menu start jsr disp ; show it jsr gtkey @@ -22,13 +23,13 @@ menu4x jsr gobanner ; "Apple //c" lda #<(monitor-1) pha jmp swrts2 ; rts to enter monitor -ckkey1 cmp #$b2 ; "2" +ckkey1: cmp #$b2 ; "2" beq doconf cmp #$b4 ; "4" bne ckkey2 -doconf jsr confirm +doconf: jsr confirm bne menu4x ; go back to menu4x -ckkey2 sec +ckkey2: sec sbc #$b0 ; ascii->number bmi menu4x ; < 0 not valid cmp #$08 @@ -37,35 +38,35 @@ ckkey2 sec stz softev + 1 ; deinit coldstart stz pwerdup ; ditto bra exitrst -gtkey lda #$60 +gtkey: lda #$60 sta ($0),y ; cursor sta kbdstrb ; clr keyboard -kbdin lda kbd ; get key +kbdin: lda kbd ; get key bpl kbdin sta kbdstrb ; clear keyboard sta ($0),y ; put it on screen rts ; display message, input x = message start relative to msg1 -disp stz $0 ; load some safe defaults +disp: stz $0 ; load some safe defaults lda #$04 sta $1 ldy #$0 ; needs to be zero -disp0 lda msg1,x ; get message byte +disp0: lda msg1,x ; get message byte bne disp1 ; proceed if nonzero rts ; exit if 0 -disp1 inx ; next byte either way +disp1: inx ; next byte either way cmp #$20 ; ' ' bcc disp2 ; start of ptr if < 20 eor #$80 ; invert high bit sta ($0),y ; write to mem inc $0 ; inc address low byte bra disp0 ; back to the beginning -disp2 sta $1 ; write address high +disp2: sta $1 ; write address high lda msg1,x ; get it sta $0 ; write address low inx ; set next msg byte bra disp0 ; back to the beginning -confirm pha +confirm: pha ldx #(msg3-msg1) ; ask confirm jsr disp jsr gtkey @@ -82,20 +83,20 @@ confirm pha ; else are characters to display and will have their ; upper bit inverted before being written to the screen. msg1 = * - .db $05,$06,"0 Monitor" - .db $05,$86,"1 Reboot" - .db $06,$06,"2 Zero RAM Card and Reboot" - .db $06,$86,"3 Diagnostics" - .db $07,$06,"4 RAM Card Diagnostics" - .db $07,$86,"5 Boot SmartPort" - .db $04,$2e,"6 Boot Int. 5.25" - .db $04,$ae,"7 Boot Ext. 5.25" - .db $07,$5f,"By M.G." -msg2 .db $07,$db,"ROM 4X 01/01/17" - .db $05,$ae,$00 ; cursor pos in menu -msg3 .db $05,$b0,"SURE? ",$00 - .dsb boot4x - *, 0 -* = boot4x + .byte $05,$06,"0 Monitor" + .byte $05,$86,"1 Reboot" + .byte $06,$06,"2 Zero RAM Card and Reboot" + .byte $06,$86,"3 Diagnostics" + .byte $07,$06,"4 RAM Card Diagnostics" + .byte $07,$86,"5 Boot SmartPort" + .byte $04,$2e,"6 Boot Int. 5.25" + .byte $04,$ae,"7 Boot Ext. 5.25" + .byte $07,$5f,"By M.G." +msg2: .byte $07,$db,"ROM 4X 01/01/17" + .byte $05,$ae,$00 ; cursor pos in menu +msg3: .byte $05,$b0,"SURE? ",$00 + .res boot4x - *, 0 + .org boot4x jsr gobanner ; "Apple //c" jsr rdrecov ; try to recover ramdisk lda power2 + rx_mslot ; get action saved by reset4x @@ -103,14 +104,14 @@ msg3 .db $05,$b0,"SURE? ",$00 ldx #(msg2-msg1) ; short banner offset jsr disp ; display it lda power2 + rx_mslot ; boot selection -btc2 cmp #$02 ; clear ramcard +btc2: cmp #$02 ; clear ramcard bne btc3 jsr rdclear ; do clear bra boot4 -btc3 cmp #$03 ; Diags +btc3: cmp #$03 ; Diags bne btc4 jmp $c7c4 -btc4 cmp #$04 ; RX diags +btc4: cmp #$04 ; RX diags bne btc5 ldx #$ff txs ; reset stack @@ -124,33 +125,33 @@ btc4 cmp #$04 ; RX diags lda numbanks,y ; get the card size in banks bne dordiag ; do diag if memory present jmp swrts2 ; otherwise jump to monitor -dordiag jmp $db3a ; diags +dordiag: jmp $db3a ; diags ;bra boot4 -btc5 cmp #$05 ; boot smartport +btc5: cmp #$05 ; boot smartport beq boot5 -btc6 cmp #$06 ; boot int drive +btc6: cmp #$06 ; boot int drive beq boot6 -btc7 cmp #$07 ; boot ext drive +btc7: cmp #$07 ; boot ext drive bne boot4 ; none of the above ; copy small routine to $800 to boot ; external 5.25 ldy #(bt4xend-bootext+1) -btc7lp lda bootext,y +btc7lp: lda bootext,y sta $800,y dey bpl btc7lp lda #$08 ; copy done bra bootsl -boot4 lda #rx_mslot ; boot slot 4 +boot4: lda #rx_mslot ; boot slot 4 bra bootsl -boot5 lda #$c5 ; boot slot 5 +boot5: lda #$c5 ; boot slot 5 bra bootsl -boot6 lda #$c6 ; boot slot 6 -bootsl ldx #$00 ; low byte of slot -bootadr stx $0 ; store address +boot6: lda #$c6 ; boot slot 6 +bootsl: ldx #$00 ; low byte of slot +bootadr: stx $0 ; store address sta $1 ; return to bank 0 does jmp (0) -endbt4x jmp gobt4x ; continue boot -rdrecov jsr rdinit ; init ramcard +endbt4x: jmp gobt4x ; continue boot +rdrecov: jsr rdinit ; init ramcard lda pwrup,y ; get power up flag cmp #pwrbyte ; already initialized? beq recovdn ; exit if initialized @@ -169,11 +170,11 @@ rdrecov jsr rdinit ; init ramcard beq recovdn ; not bootable lda #pwrbyte sta pwrup,y ; set power byte - lda #"R" ; tell user + lda #'R' ; tell user sta $7d0 ; on screen -recovdn rts +recovdn: rts ; zero ram card space -rdclear jsr rdinit ; init ramcard +rdclear: jsr rdinit ; init ramcard jsr testsize ; get size lda numbanks,y ; # of 64Ks to write beq clrdone ; no memory @@ -182,10 +183,10 @@ rdclear jsr rdinit ; init ramcard stz addrl,x ; slinky address 0 stz addrm,x stz addrh,x -clbnklp inc $400 ; poor mans progress meter +clbnklp: inc $400 ; poor mans progress meter ldy #$00 -cl64klp ldx #$00 ; loop for all pages in bank -cl256lp txa ; loop for all bytes in page +cl64klp: ldx #$00 ; loop for all pages in bank +cl256lp: txa ; loop for all bytes in page ldx #rx_devno stz data,x ; write a zero to card tax @@ -196,17 +197,17 @@ cl256lp txa ; loop for all bytes in page ldx #rx_mslot dec numbanks,x bne clbnklp ; if more banks -clrdone ldx #rx_mslot +clrdone: ldx #rx_mslot stz pwrup,x ; zero powerup byte lda #$a0 ; ' ' sta $400 ; clear progress rts -rdinit bit rx_mslot*$100 ; activate registers +rdinit: bit rx_mslot*$100 ; activate registers ldy #rx_mslot ; slot offset ldx #rx_devno ; register offset rts ; next is snippet of code to boot external 5.25 -bootext lda #$e0 +bootext: lda #$e0 ldy #$01 ldx #$60 jmp $c60b diff --git a/rom4x/B1_E300_new_bootfail.s b/rom4x/B1_E300_new_bootfail.s index a10bed2..34e6316 100644 --- a/rom4x/B1_E300_new_bootfail.s +++ b/rom4x/B1_E300_new_bootfail.s @@ -1,8 +1,8 @@ -#include "iic.defs" -.text -* = nbtfail +.code +.include "iic.defs" + .org nbtfail ldx #msglen -lp1 lda bootmsg,x +lp1: lda bootmsg,x ora #$80 sta $7d0+19-msglen/2,x dex @@ -14,6 +14,6 @@ lp1 lda bootmsg,x lda #<(basic-1) pha jmp swrts2 -bootmsg .db "No bootable device." +bootmsg: .byte "No bootable device." msglen = * - bootmsg - 1 diff --git a/rom4x/Rakefile b/rom4x/Rakefile index 192e076..241e416 100644 --- a/rom4x/Rakefile +++ b/rom4x/Rakefile @@ -12,33 +12,43 @@ end desc "Clean object files" task :clean do sh "rm -f #{dest_rom}" - sh "rm -f *.o65" - sh "rm -f *.o65.lbl" + sh "rm -f sf512_#{dest_rom}" + sh "rm -f *.o" + sh "rm -f *.lst" + sh "rm -f *.b" end desc "Assemble all source files" -task :assemble => source_files.ext('.o65') +task :assemble => source_files.ext('.b') -rule ".o65" => ".s" do |t| - sh "xa -c -o #{t.name} -l #{t.name}.lbl #{t.source}" +rule ".o" => ".s" do |t| + sh "ca65 -l #{t.name}.lst #{t.source}" +end + +rule ".b" => ".o" do |t| + sh "ld65 -t none -o #{t.name} #{t.source}" end desc "Build ROM" task :build_rom => [:assemble] do puts "Building ROM image..." - obj_files = Rake::FileList.new('*.o65') + obj_files = Rake::FileList.new('*.b') rom = File.read(source_rom) obj_files.each do |t| if t =~ /B(\h)_(\h{4})/ bnum = $1.to_i(16) badd = $2.to_i(16) addr = bnum * 16384 + badd - rom_base - puts "Loading #{t} into bank #{bnum} @ #{badd.to_s(16)}, file addr #{addr.to_s(16)}" fc = File.read(t) + fl = fc.bytes.count + puts "Loading #{t} into bank #{bnum} @ #{badd.to_s(16)}, file addr $#{addr.to_s(16)}, len $#{fl.to_s(16)} (#{fl})" + nzc = 0 fc.each_byte do |b| + nzc += 1 if rom.getbyte(addr) != 0 && rom.getbyte(addr) != b rom.setbyte(addr, b) addr += 1 end + puts "\tNote: patched pver #{nzc} nonzero bytes!" if nzc > 0 else puts "I dont know where to load #{t}" end diff --git a/rom5x/B0_CFF9_switch_cmd.s b/rom5x/B0_CFF9_switch_cmd.s index 62bfa5d..ad43e16 100644 --- a/rom5x/B0_CFF9_switch_cmd.s +++ b/rom5x/B0_CFF9_switch_cmd.s @@ -5,9 +5,9 @@ ; load the command $EA and proceed the same way. ; thus we get two dispatch codes in 6 bytes. -#include "iic+.defs" -.text -* = $cff9 ; 7 bytes available here, but don't count on $CFFF +.include "iic+.defs" +.code + .org $cff9 ; 7 bytes available here, but don't count on $CFFF lda #$a9 ; lda opcode nop ; jmp/jsr $cffa does lda #$ea jmp $fbdf ; jump to bell1 hijack diff --git a/rom5x/B0_FAB4_patch_pwrup.s b/rom5x/B0_FAB4_patch_pwrup.s index 428fa8f..80a8ca8 100644 --- a/rom5x/B0_FAB4_patch_pwrup.s +++ b/rom5x/B0_FAB4_patch_pwrup.s @@ -1,7 +1,7 @@ ; patch PWRUP to call boot5x -#include "iic+.defs" -.text -* = $fab4 +.include "iic+.defs" +.code + .org $fab4 nop jmp gobt5x diff --git a/rom5x/B0_FAC8_patch_reset.s b/rom5x/B0_FAC8_patch_reset.s index cbb9912..6cc7e44 100644 --- a/rom5x/B0_FAC8_patch_reset.s +++ b/rom5x/B0_FAC8_patch_reset.s @@ -1,7 +1,7 @@ ; patch RESET.X to call reset5x -#include "iic+.defs" -.text -* = $fac8 +.include "iic+.defs" +.code + .org $fac8 jmp gorst5x diff --git a/rom5x/B0_FB68_center_title.s b/rom5x/B0_FB68_center_title.s index c3f59f3..04bf8e9 100644 --- a/rom5x/B0_FB68_center_title.s +++ b/rom5x/B0_FB68_center_title.s @@ -3,6 +3,6 @@ ; then displayed it two characters to the *right* rather than one ; or to to the left. It's a major ; pet peeve of mine, more so than the beep. -.text +.code sta $040d,y diff --git a/rom5x/B0_FBDF_bell1_hijack.s b/rom5x/B0_FBDF_bell1_hijack.s index 853b4d7..2db5a33 100644 --- a/rom5x/B0_FBDF_bell1_hijack.s +++ b/rom5x/B0_FBDF_bell1_hijack.s @@ -15,7 +15,7 @@ ; Obviously, $40 should beep the speaker, anything ; else can do whatever we want. -.text -* = $fbdf +.code + .org $fbdf sta $c028 diff --git a/rom5x/B1_C53D_patch_out_rom_cksum.s b/rom5x/B1_C53D_patch_out_rom_cksum.s index ed7be8c..e2f8557 100644 --- a/rom5x/B1_C53D_patch_out_rom_cksum.s +++ b/rom5x/B1_C53D_patch_out_rom_cksum.s @@ -5,8 +5,8 @@ ; calculates the checksum. It returns with carry set = error and ; carry clear = OK. So we just patch the JSR to always clear the ; carry. For now. -* = $C53D -.text +.code + .org $C53D nop nop clc diff --git a/rom5x/B1_D516_boot5x.s b/rom5x/B1_D516_boot5x.s index 1f25091..49a1de3 100644 --- a/rom5x/B1_D516_boot5x.s +++ b/rom5x/B1_D516_boot5x.s @@ -1,20 +1,21 @@ -#include "iic+.defs" -.text -* = boot5x ; 234 bytes available, code assembles to 231 +.code +.psc02 +.include "iic+.defs" + .org boot5x ; 234 bytes available, code assembles to 231 jsr titl5x ; "Apple IIc +" jsr rdrecov ; try to recover ramdisk lda power2 + rx_mslot ; get action saved by reset5x beq boot4 ; if zero, continue boot jsr bann5x ; display ROM 5X footer lda power2 + rx_mslot ; boot selection -btc2 cmp #$02 ; clear ramcard +btc2: cmp #$02 ; clear ramcard bne btc3 jsr rdclear ; do clear bra boot4 -btc3 cmp #$03 ; Diags +btc3: cmp #$03 ; Diags bne btc4 jmp $c7c4 -btc4 cmp #$04 ; RX diags +btc4: cmp #$04 ; RX diags bne btc5 ldx #$ff txs ; reset stack @@ -28,25 +29,25 @@ btc4 cmp #$04 ; RX diags lda numbanks,y ; get the card size in banks bne dordiag ; do diag if memory present jmp swrts2 ; otherwise jump to monitor -dordiag jmp $db3a ; diags -btc5 cmp #$05 ; boot smartport +dordiag: jmp $db3a ; diags +btc5: cmp #$05 ; boot smartport beq boot5 ; fall through if none of the above -boot4 lda #rx_mslot ; boot slot 4 +boot4: lda #rx_mslot ; boot slot 4 bra bootsl -boot5 lda #$c5 ; boot slot 5 +boot5: lda #$c5 ; boot slot 5 bra bootsl -boot6 lda #$c6 ; boot slot 6 -bootsl ldx #$00 ; low byte of slot -bootadr stx $0 ; store address +boot6: lda #$c6 ; boot slot 6 +bootsl: ldx #$00 ; low byte of slot +bootadr: stx $0 ; store address sta $1 ; return to bank 0 does jmp (0) -endbt4x lda #>(bt5xrtn-1) +endbt4x: lda #>(bt5xrtn-1) pha lda #<(bt5xrtn-1) pha lda $1 jmp swrts2 -rdrecov jsr rdinit ; init ramcard +rdrecov: jsr rdinit ; init ramcard lda pwrup,y ; get power up flag cmp #pwrbyte ; already initialized? beq recovdn ; exit if initialized @@ -65,11 +66,11 @@ rdrecov jsr rdinit ; init ramcard beq recovdn ; not bootable lda #pwrbyte sta pwrup,y ; set power byte - lda #"R" ; tell user + lda #'R' ; tell user sta $7d0 ; on screen -recovdn rts +recovdn: rts ; zero ram card space -rdclear jsr rdinit ; init ramcard +rdclear: jsr rdinit ; init ramcard jsr testsize ; get size lda numbanks,y ; # of 64Ks to write beq clrdone ; no memory @@ -78,10 +79,10 @@ rdclear jsr rdinit ; init ramcard stz addrl,x ; slinky address 0 stz addrm,x stz addrh,x -clbnklp inc $400 ; poor mans progress meter +clbnklp: inc $400 ; poor mans progress meter ldy #$00 -cl64klp ldx #$00 ; loop for all pages in bank -cl256lp txa ; loop for all bytes in page +cl64klp: ldx #$00 ; loop for all pages in bank +cl256lp: txa ; loop for all bytes in page ldx #rx_devno stz data,x ; write a zero to card tax @@ -92,17 +93,17 @@ cl256lp txa ; loop for all bytes in page ldx #rx_mslot dec numbanks,x bne clbnklp ; if more banks -clrdone ldx #rx_mslot +clrdone: ldx #rx_mslot stz pwrup,x ; zero powerup byte lda #$a0 ; ' ' sta $400 ; clear progress rts -rdinit bit rx_mslot*$100 ; activate registers +rdinit: bit rx_mslot*$100 ; activate registers ldy #rx_mslot ; slot offset ldx #rx_devno ; register offset rts ; next is snippet of code to boot external 5.25 -bootext lda #$e0 +bootext: lda #$e0 ldy #$01 ldx #$60 jmp $c60b diff --git a/rom5x/B1_D6CE_rom5x_misc.s b/rom5x/B1_D6CE_rom5x_misc.s index 17f6ec1..6f24940 100644 --- a/rom5x/B1_D6CE_rom5x_misc.s +++ b/rom5x/B1_D6CE_rom5x_misc.s @@ -1,44 +1,45 @@ -#include "iic+.defs" -.text -* = misc5x ; max 306 bytes +.code +.psc02 +.include "iic+.defs" + .org misc5x ; max 306 bytes bra domenu ; Display menu bra dobann ; Display banner (title + By MG) bra gtkey ; get a key bra confirm ; ask SURE? bra ntitle ; display "Apple IIc +" -dobann jsr ntitle +dobann: jsr ntitle ldx #(msg2-msg1) ; msg display entry point jmp disp -domenu jsr ntitle ; "Apple ||c +" +domenu: jsr ntitle ; "Apple ||c +" ldx #$00 ; menu start jsr disp ; show it rts -gtkey lda #$60 +gtkey: lda #$60 sta ($0),y ; cursor sta kbdstrb ; clr keyboard -kbdin lda kbd ; get key +kbdin: lda kbd ; get key bpl kbdin sta kbdstrb ; clear keyboard sta ($0),y ; put it on screen rts ; display message, input x = message start relative to msg1 -disp ldy #$0 ; needs to be zero -disp0 lda msg1,x ; get message byte +disp: ldy #$0 ; needs to be zero +disp0: lda msg1,x ; get message byte bne disp1 ; proceed if nonzero rts ; exit if 0 -disp1 inx ; next byte either way +disp1: inx ; next byte either way cmp #$20 ; ' ' bcc disp2 ; start of ptr if < 20 eor #$80 ; invert high bit sta ($0),y ; write to mem inc $0 ; inc address low byte bra disp0 ; back to the beginning -disp2 sta $1 ; write address high +disp2: sta $1 ; write address high lda msg1,x ; get it sta $0 ; write address low inx ; set next msg byte bra disp0 ; back to the beginning -confirm pha +confirm: pha ldx #(msg3-msg1) ; ask confirm jsr disp jsr gtkey @@ -55,7 +56,7 @@ confirm pha ; we then jump to swrts2 which switches banks and RTS to ; display "Apple IIc +", which then RTS to swrts, which ; switches banks back to here and RTS to our caller. -ntitle lda #>(swrts2-1) ; put return addr of swrts/swrts2 on stack +ntitle: lda #>(swrts2-1) ; put return addr of swrts/swrts2 on stack pha lda #<(swrts2-1) pha @@ -70,16 +71,16 @@ ntitle lda #>(swrts2-1) ; put return addr of swrts/swrts2 on stack ; else are characters to display and will have their ; upper bit inverted before being written to the screen. msg1 = * - .db $05,$06,"0 Monitor" - .db $05,$86,"1 Reboot" - .db $06,$06,"2 Zero RAM Card" - .db $06,$86,"3 Sys Diags" - .db $07,$06,"4 RAM Card Diags" - .db $07,$86,"5 Boot 3.5/SmartPort" - .db $04,$2e,"6 Boot 5.25" -; .db $04,$ae,"7 Accelerator" - .db $07,$5f,"By M.G." -msg2 .db $07,$db,"ROM 5X 02/10/17" - .db $05,$ae,$00 ; cursor pos in menu -msg3 .db $05,$b0,"SURE? ",$00 + .byte $05,$06,"0 Monitor" + .byte $05,$86,"1 Reboot" + .byte $06,$06,"2 Zero RAM Card" + .byte $06,$86,"3 Sys Diags" + .byte $07,$06,"4 RAM Card Diags" + .byte $07,$86,"5 Boot 3.5/SmartPort" + .byte $04,$2e,"6 Boot 5.25" +; .byte $04,$ae,"7 Accelerator" + .byte $07,$5f,"By M.G." +msg2: .byte $07,$db,"ROM 5X 02/10/17" + .byte $05,$ae,$00 ; cursor pos in menu +msg3: .byte $05,$b0,"SURE? ",$00 diff --git a/rom5x/B1_DB63_reset5x.s b/rom5x/B1_DB63_reset5x.s index a570a7d..4e7a4dd 100644 --- a/rom5x/B1_DB63_reset5x.s +++ b/rom5x/B1_DB63_reset5x.s @@ -1,6 +1,7 @@ -#include "iic+.defs" -.text -* = reset5x ; max 157 bytes +.code +.psc02 +.include "iic+.defs" + .org reset5x ; max 157 bytes stz power2 + rx_mslot ; action = normal reset lda #>(rst5xrtn-1) ; common case pha @@ -8,12 +9,12 @@ pha ; note that this stays on stack asl butn1 ; option (closed apple) bcs ckdiag -exitrst jmp swrts2 +exitrst: jmp swrts2 ; check to see if cmd_option (both apples) are down -ckdiag bit butn0 ; command (open apple) +ckdiag: bit butn0 ; command (open apple) bmi exitrst ; return to RESET.X ; present menu because only closed apple is down -menu jsr menu5x ; display menu +menu: jsr menu5x ; display menu jsr gkey5x cmp #$b0 ; "0" bne ckkey1 @@ -24,13 +25,13 @@ menu jsr menu5x ; display menu lda #<(monitor-1) pha jmp swrts2 ; rts to enter monitor -ckkey1 cmp #$b2 ; "2" +ckkey1: cmp #$b2 ; "2" beq doconf cmp #$b4 ; "4" bne ckkey2 -doconf jsr conf5x +doconf: jsr conf5x bne menu ; go back to menu4x -ckkey2 sec +ckkey2: sec sbc #$b0 ; ascii->number bmi menu ; < 0 not valid cmp #$07 ; we will use 7 for accelerator later diff --git a/rom5x/B1_FB3C_rom5x_dispatch.s b/rom5x/B1_FB3C_rom5x_dispatch.s index c25e0a7..03bdf97 100644 --- a/rom5x/B1_FB3C_rom5x_dispatch.s +++ b/rom5x/B1_FB3C_rom5x_dispatch.s @@ -1,6 +1,7 @@ -#include "iic+.defs" -.text -* = $fb3c ; ~165 bytes free here +.code +.psc02 +.include "iic+.defs" + .org $fb3c ; ~165 bytes free here cmp #$a9 ; reset patch bne chk2 jmp reset5x diff --git a/rom5x/B1_FBE2_bell1_hijack_b1.s b/rom5x/B1_FBE2_bell1_hijack_b1.s index 8fe7472..9df31dd 100644 --- a/rom5x/B1_FBE2_bell1_hijack_b1.s +++ b/rom5x/B1_FBE2_bell1_hijack_b1.s @@ -1,5 +1,5 @@ -#include "iic+.defs" -.text -* = $fbe2 ; ~29 bytes free here +.code +.include "iic+.defs" + .org $fbe2 ; ~29 bytes free here jmp $fb3c diff --git a/rom5x/Rakefile b/rom5x/Rakefile index 00148f1..66dcccd 100644 --- a/rom5x/Rakefile +++ b/rom5x/Rakefile @@ -13,21 +13,26 @@ desc "Clean object files" task :clean do sh "rm -f #{dest_rom}" sh "rm -f sf512_#{dest_rom}" - sh "rm -f *.o65" - sh "rm -f *.o65.lbl" + sh "rm -f *.o" + sh "rm -f *.lst" + sh "rm -f *.b" end desc "Assemble all source files" -task :assemble => source_files.ext('.o65') +task :assemble => source_files.ext('.b') -rule ".o65" => ".s" do |t| - sh "xa -c -o #{t.name} -l #{t.name}.lbl #{t.source}" +rule ".o" => ".s" do |t| + sh "ca65 -l #{t.name}.lst #{t.source}" +end + +rule ".b" => ".o" do |t| + sh "ld65 -t none -o #{t.name} #{t.source}" end desc "Build ROM" task :build_rom => [:assemble] do puts "Building ROM image..." - obj_files = Rake::FileList.new('*.o65') + obj_files = Rake::FileList.new('*.b') rom = File.read(source_rom) obj_files.each do |t| if t =~ /B(\h)_(\h{4})/ diff --git a/rom5x/options/accel_reverse/B1_FDD5_accel_reverse.s b/rom5x/options/accel_reverse/B1_FDD5_accel_reverse.s index c346779..46eb0ac 100644 --- a/rom5x/options/accel_reverse/B1_FDD5_accel_reverse.s +++ b/rom5x/options/accel_reverse/B1_FDD5_accel_reverse.s @@ -5,7 +5,7 @@ ; This patch was inspired by Quinn Dunki's functionally equivalent ; firmware mod found here: http://quinndunki.com/blondihacks/?p=2546 -.text -* = $fdd5 +.code + .org $fdd5 .byte $f0