conversion to cc65

This commit is contained in:
mgcaret 2017-03-18 20:00:43 -07:00
parent 42499b5891
commit 3ac2b9d74f
23 changed files with 195 additions and 174 deletions

3
.gitignore vendored
View File

@ -3,5 +3,8 @@
*.bin *.bin
*.swp *.swp
*.zip *.zip
*.o
*.lst
*.b
copyrom.sh copyrom.sh

View File

@ -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. 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). Finally you will need [Ruby](https://www.ruby-lang.org/en/) and [Rake](https://github.com/ruby/rake).

View File

@ -1,14 +1,14 @@
#include "iic.defs" .psc02
.code
.text .include "iic.defs"
* = $c552 .org $c552
jsr setnorm jsr setnorm
jsr init jsr init
bra cbtfail bra cbtfail
.dsb coma-*,$ea .res coma-*,$ea
bra coma ; Make sure coma routine exists bra coma ; Make sure coma routine exists
.db 0 ; rom4x present .byte 0 ; rom4x present
cbtfail jsr setvid cbtfail: jsr setvid
jsr setkbd jsr setkbd
lda #>(nbtfail-1) lda #>(nbtfail-1)
pha pha

View File

@ -1,6 +1,6 @@
#include "iic.defs" .code
.text .include "iic.defs"
* = gorst4x .org gorst4x
sta rombank ; gorst4x sta rombank ; gorst4x
jmp rst4xrtn ; in other bank jmp reset4x jmp rst4xrtn ; in other bank jmp reset4x
sta rombank ; gobt4x sta rombank ; gobt4x

View File

@ -1,7 +1,6 @@
; patch PWRUP to call boot4x ; patch PWRUP to call boot4x
.code
#include "iic.defs" .include "iic.defs"
.text .org $fab4
* = $fab4
nop nop
jmp gobt4x jmp gobt4x

View File

@ -1,7 +1,6 @@
; patch RESET.X to call reset4x ; patch RESET.X to call reset4x
.code
#include "iic.defs" .include "iic.defs"
.text .org $fac8
* = $fac8
jmp gorst4x jmp gorst4x

View File

@ -1,6 +1,6 @@
#include "iic.defs" .code
.text .include "iic.defs"
* = gorst4x .org gorst4x
sta rombank ; gorst4x sta rombank ; gorst4x
jmp reset4x ; in other bank jmp rstxrtn jmp reset4x ; in other bank jmp rstxrtn
sta rombank ; gobt4x sta rombank ; gobt4x

View File

@ -1,15 +1,16 @@
#include "iic.defs" .psc02
.text .code
* = reset4x .include "iic.defs"
.org reset4x
stz power2 + rx_mslot ; action = normal boot stz power2 + rx_mslot ; action = normal boot
asl butn1 ; closed apple asl butn1 ; closed apple
bcs ckdiag bcs ckdiag
exitrst jmp gorst4x ; return to RESET.X exitrst: jmp gorst4x ; return to RESET.X
; check to see if both apples are down ; check to see if both apples are down
ckdiag bit butn0 ; open apple ckdiag: bit butn0 ; open apple
bmi exitrst ; return to RESET.X bmi exitrst ; return to RESET.X
; present menu because only closed apple is down ; present menu because only closed apple is down
menu4x jsr gobanner ; "Apple //c" menu4x: jsr gobanner ; "Apple //c"
ldx #$00 ; menu start ldx #$00 ; menu start
jsr disp ; show it jsr disp ; show it
jsr gtkey jsr gtkey
@ -22,13 +23,13 @@ menu4x jsr gobanner ; "Apple //c"
lda #<(monitor-1) lda #<(monitor-1)
pha pha
jmp swrts2 ; rts to enter monitor jmp swrts2 ; rts to enter monitor
ckkey1 cmp #$b2 ; "2" ckkey1: cmp #$b2 ; "2"
beq doconf beq doconf
cmp #$b4 ; "4" cmp #$b4 ; "4"
bne ckkey2 bne ckkey2
doconf jsr confirm doconf: jsr confirm
bne menu4x ; go back to menu4x bne menu4x ; go back to menu4x
ckkey2 sec ckkey2: sec
sbc #$b0 ; ascii->number sbc #$b0 ; ascii->number
bmi menu4x ; < 0 not valid bmi menu4x ; < 0 not valid
cmp #$08 cmp #$08
@ -37,35 +38,35 @@ ckkey2 sec
stz softev + 1 ; deinit coldstart stz softev + 1 ; deinit coldstart
stz pwerdup ; ditto stz pwerdup ; ditto
bra exitrst bra exitrst
gtkey lda #$60 gtkey: lda #$60
sta ($0),y ; cursor sta ($0),y ; cursor
sta kbdstrb ; clr keyboard sta kbdstrb ; clr keyboard
kbdin lda kbd ; get key kbdin: lda kbd ; get key
bpl kbdin bpl kbdin
sta kbdstrb ; clear keyboard sta kbdstrb ; clear keyboard
sta ($0),y ; put it on screen sta ($0),y ; put it on screen
rts rts
; display message, input x = message start relative to msg1 ; 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 lda #$04
sta $1 sta $1
ldy #$0 ; needs to be zero 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 bne disp1 ; proceed if nonzero
rts ; exit if 0 rts ; exit if 0
disp1 inx ; next byte either way disp1: inx ; next byte either way
cmp #$20 ; ' ' cmp #$20 ; ' '
bcc disp2 ; start of ptr if < 20 bcc disp2 ; start of ptr if < 20
eor #$80 ; invert high bit eor #$80 ; invert high bit
sta ($0),y ; write to mem sta ($0),y ; write to mem
inc $0 ; inc address low byte inc $0 ; inc address low byte
bra disp0 ; back to the beginning bra disp0 ; back to the beginning
disp2 sta $1 ; write address high disp2: sta $1 ; write address high
lda msg1,x ; get it lda msg1,x ; get it
sta $0 ; write address low sta $0 ; write address low
inx ; set next msg byte inx ; set next msg byte
bra disp0 ; back to the beginning bra disp0 ; back to the beginning
confirm pha confirm: pha
ldx #(msg3-msg1) ; ask confirm ldx #(msg3-msg1) ; ask confirm
jsr disp jsr disp
jsr gtkey jsr gtkey
@ -82,20 +83,20 @@ confirm pha
; else are characters to display and will have their ; else are characters to display and will have their
; upper bit inverted before being written to the screen. ; upper bit inverted before being written to the screen.
msg1 = * msg1 = *
.db $05,$06,"0 Monitor" .byte $05,$06,"0 Monitor"
.db $05,$86,"1 Reboot" .byte $05,$86,"1 Reboot"
.db $06,$06,"2 Zero RAM Card and Reboot" .byte $06,$06,"2 Zero RAM Card and Reboot"
.db $06,$86,"3 Diagnostics" .byte $06,$86,"3 Diagnostics"
.db $07,$06,"4 RAM Card Diagnostics" .byte $07,$06,"4 RAM Card Diagnostics"
.db $07,$86,"5 Boot SmartPort" .byte $07,$86,"5 Boot SmartPort"
.db $04,$2e,"6 Boot Int. 5.25" .byte $04,$2e,"6 Boot Int. 5.25"
.db $04,$ae,"7 Boot Ext. 5.25" .byte $04,$ae,"7 Boot Ext. 5.25"
.db $07,$5f,"By M.G." .byte $07,$5f,"By M.G."
msg2 .db $07,$db,"ROM 4X 01/01/17" msg2: .byte $07,$db,"ROM 4X 01/01/17"
.db $05,$ae,$00 ; cursor pos in menu .byte $05,$ae,$00 ; cursor pos in menu
msg3 .db $05,$b0,"SURE? ",$00 msg3: .byte $05,$b0,"SURE? ",$00
.dsb boot4x - *, 0 .res boot4x - *, 0
* = boot4x .org boot4x
jsr gobanner ; "Apple //c" jsr gobanner ; "Apple //c"
jsr rdrecov ; try to recover ramdisk jsr rdrecov ; try to recover ramdisk
lda power2 + rx_mslot ; get action saved by reset4x 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 ldx #(msg2-msg1) ; short banner offset
jsr disp ; display it jsr disp ; display it
lda power2 + rx_mslot ; boot selection lda power2 + rx_mslot ; boot selection
btc2 cmp #$02 ; clear ramcard btc2: cmp #$02 ; clear ramcard
bne btc3 bne btc3
jsr rdclear ; do clear jsr rdclear ; do clear
bra boot4 bra boot4
btc3 cmp #$03 ; Diags btc3: cmp #$03 ; Diags
bne btc4 bne btc4
jmp $c7c4 jmp $c7c4
btc4 cmp #$04 ; RX diags btc4: cmp #$04 ; RX diags
bne btc5 bne btc5
ldx #$ff ldx #$ff
txs ; reset stack txs ; reset stack
@ -124,33 +125,33 @@ btc4 cmp #$04 ; RX diags
lda numbanks,y ; get the card size in banks lda numbanks,y ; get the card size in banks
bne dordiag ; do diag if memory present bne dordiag ; do diag if memory present
jmp swrts2 ; otherwise jump to monitor jmp swrts2 ; otherwise jump to monitor
dordiag jmp $db3a ; diags dordiag: jmp $db3a ; diags
;bra boot4 ;bra boot4
btc5 cmp #$05 ; boot smartport btc5: cmp #$05 ; boot smartport
beq boot5 beq boot5
btc6 cmp #$06 ; boot int drive btc6: cmp #$06 ; boot int drive
beq boot6 beq boot6
btc7 cmp #$07 ; boot ext drive btc7: cmp #$07 ; boot ext drive
bne boot4 ; none of the above bne boot4 ; none of the above
; copy small routine to $800 to boot ; copy small routine to $800 to boot
; external 5.25 ; external 5.25
ldy #(bt4xend-bootext+1) ldy #(bt4xend-bootext+1)
btc7lp lda bootext,y btc7lp: lda bootext,y
sta $800,y sta $800,y
dey dey
bpl btc7lp bpl btc7lp
lda #$08 ; copy done lda #$08 ; copy done
bra bootsl bra bootsl
boot4 lda #rx_mslot ; boot slot 4 boot4: lda #rx_mslot ; boot slot 4
bra bootsl bra bootsl
boot5 lda #$c5 ; boot slot 5 boot5: lda #$c5 ; boot slot 5
bra bootsl bra bootsl
boot6 lda #$c6 ; boot slot 6 boot6: lda #$c6 ; boot slot 6
bootsl ldx #$00 ; low byte of slot bootsl: ldx #$00 ; low byte of slot
bootadr stx $0 ; store address bootadr: stx $0 ; store address
sta $1 ; return to bank 0 does jmp (0) sta $1 ; return to bank 0 does jmp (0)
endbt4x jmp gobt4x ; continue boot endbt4x: jmp gobt4x ; continue boot
rdrecov jsr rdinit ; init ramcard rdrecov: jsr rdinit ; init ramcard
lda pwrup,y ; get power up flag lda pwrup,y ; get power up flag
cmp #pwrbyte ; already initialized? cmp #pwrbyte ; already initialized?
beq recovdn ; exit if initialized beq recovdn ; exit if initialized
@ -169,11 +170,11 @@ rdrecov jsr rdinit ; init ramcard
beq recovdn ; not bootable beq recovdn ; not bootable
lda #pwrbyte lda #pwrbyte
sta pwrup,y ; set power byte sta pwrup,y ; set power byte
lda #"R" ; tell user lda #'R' ; tell user
sta $7d0 ; on screen sta $7d0 ; on screen
recovdn rts recovdn: rts
; zero ram card space ; zero ram card space
rdclear jsr rdinit ; init ramcard rdclear: jsr rdinit ; init ramcard
jsr testsize ; get size jsr testsize ; get size
lda numbanks,y ; # of 64Ks to write lda numbanks,y ; # of 64Ks to write
beq clrdone ; no memory beq clrdone ; no memory
@ -182,10 +183,10 @@ rdclear jsr rdinit ; init ramcard
stz addrl,x ; slinky address 0 stz addrl,x ; slinky address 0
stz addrm,x stz addrm,x
stz addrh,x stz addrh,x
clbnklp inc $400 ; poor mans progress meter clbnklp: inc $400 ; poor mans progress meter
ldy #$00 ldy #$00
cl64klp ldx #$00 ; loop for all pages in bank cl64klp: ldx #$00 ; loop for all pages in bank
cl256lp txa ; loop for all bytes in page cl256lp: txa ; loop for all bytes in page
ldx #rx_devno ldx #rx_devno
stz data,x ; write a zero to card stz data,x ; write a zero to card
tax tax
@ -196,17 +197,17 @@ cl256lp txa ; loop for all bytes in page
ldx #rx_mslot ldx #rx_mslot
dec numbanks,x dec numbanks,x
bne clbnklp ; if more banks bne clbnklp ; if more banks
clrdone ldx #rx_mslot clrdone: ldx #rx_mslot
stz pwrup,x ; zero powerup byte stz pwrup,x ; zero powerup byte
lda #$a0 ; ' ' lda #$a0 ; ' '
sta $400 ; clear progress sta $400 ; clear progress
rts rts
rdinit bit rx_mslot*$100 ; activate registers rdinit: bit rx_mslot*$100 ; activate registers
ldy #rx_mslot ; slot offset ldy #rx_mslot ; slot offset
ldx #rx_devno ; register offset ldx #rx_devno ; register offset
rts rts
; next is snippet of code to boot external 5.25 ; next is snippet of code to boot external 5.25
bootext lda #$e0 bootext: lda #$e0
ldy #$01 ldy #$01
ldx #$60 ldx #$60
jmp $c60b jmp $c60b

View File

@ -1,8 +1,8 @@
#include "iic.defs" .code
.text .include "iic.defs"
* = nbtfail .org nbtfail
ldx #msglen ldx #msglen
lp1 lda bootmsg,x lp1: lda bootmsg,x
ora #$80 ora #$80
sta $7d0+19-msglen/2,x sta $7d0+19-msglen/2,x
dex dex
@ -14,6 +14,6 @@ lp1 lda bootmsg,x
lda #<(basic-1) lda #<(basic-1)
pha pha
jmp swrts2 jmp swrts2
bootmsg .db "No bootable device." bootmsg: .byte "No bootable device."
msglen = * - bootmsg - 1 msglen = * - bootmsg - 1

View File

@ -12,33 +12,43 @@ end
desc "Clean object files" desc "Clean object files"
task :clean do task :clean do
sh "rm -f #{dest_rom}" sh "rm -f #{dest_rom}"
sh "rm -f *.o65" sh "rm -f sf512_#{dest_rom}"
sh "rm -f *.o65.lbl" sh "rm -f *.o"
sh "rm -f *.lst"
sh "rm -f *.b"
end end
desc "Assemble all source files" desc "Assemble all source files"
task :assemble => source_files.ext('.o65') task :assemble => source_files.ext('.b')
rule ".o65" => ".s" do |t| rule ".o" => ".s" do |t|
sh "xa -c -o #{t.name} -l #{t.name}.lbl #{t.source}" sh "ca65 -l #{t.name}.lst #{t.source}"
end
rule ".b" => ".o" do |t|
sh "ld65 -t none -o #{t.name} #{t.source}"
end end
desc "Build ROM" desc "Build ROM"
task :build_rom => [:assemble] do task :build_rom => [:assemble] do
puts "Building ROM image..." puts "Building ROM image..."
obj_files = Rake::FileList.new('*.o65') obj_files = Rake::FileList.new('*.b')
rom = File.read(source_rom) rom = File.read(source_rom)
obj_files.each do |t| obj_files.each do |t|
if t =~ /B(\h)_(\h{4})/ if t =~ /B(\h)_(\h{4})/
bnum = $1.to_i(16) bnum = $1.to_i(16)
badd = $2.to_i(16) badd = $2.to_i(16)
addr = bnum * 16384 + badd - rom_base 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) 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| fc.each_byte do |b|
nzc += 1 if rom.getbyte(addr) != 0 && rom.getbyte(addr) != b
rom.setbyte(addr, b) rom.setbyte(addr, b)
addr += 1 addr += 1
end end
puts "\tNote: patched pver #{nzc} nonzero bytes!" if nzc > 0
else else
puts "I dont know where to load #{t}" puts "I dont know where to load #{t}"
end end

View File

@ -5,9 +5,9 @@
; load the command $EA and proceed the same way. ; load the command $EA and proceed the same way.
; thus we get two dispatch codes in 6 bytes. ; thus we get two dispatch codes in 6 bytes.
#include "iic+.defs" .include "iic+.defs"
.text .code
* = $cff9 ; 7 bytes available here, but don't count on $CFFF .org $cff9 ; 7 bytes available here, but don't count on $CFFF
lda #$a9 ; lda opcode lda #$a9 ; lda opcode
nop ; jmp/jsr $cffa does lda #$ea nop ; jmp/jsr $cffa does lda #$ea
jmp $fbdf ; jump to bell1 hijack jmp $fbdf ; jump to bell1 hijack

View File

@ -1,7 +1,7 @@
; patch PWRUP to call boot5x ; patch PWRUP to call boot5x
#include "iic+.defs" .include "iic+.defs"
.text .code
* = $fab4 .org $fab4
nop nop
jmp gobt5x jmp gobt5x

View File

@ -1,7 +1,7 @@
; patch RESET.X to call reset5x ; patch RESET.X to call reset5x
#include "iic+.defs" .include "iic+.defs"
.text .code
* = $fac8 .org $fac8
jmp gorst5x jmp gorst5x

View File

@ -3,6 +3,6 @@
; then displayed it two characters to the *right* rather than one ; then displayed it two characters to the *right* rather than one
; or to to the left. It's a major ; or to to the left. It's a major
; pet peeve of mine, more so than the beep. ; pet peeve of mine, more so than the beep.
.text .code
sta $040d,y sta $040d,y

View File

@ -15,7 +15,7 @@
; Obviously, $40 should beep the speaker, anything ; Obviously, $40 should beep the speaker, anything
; else can do whatever we want. ; else can do whatever we want.
.text .code
* = $fbdf .org $fbdf
sta $c028 sta $c028

View File

@ -5,8 +5,8 @@
; calculates the checksum. It returns with carry set = error and ; calculates the checksum. It returns with carry set = error and
; carry clear = OK. So we just patch the JSR to always clear the ; carry clear = OK. So we just patch the JSR to always clear the
; carry. For now. ; carry. For now.
* = $C53D .code
.text .org $C53D
nop nop
nop nop
clc clc

View File

@ -1,20 +1,21 @@
#include "iic+.defs" .code
.text .psc02
* = boot5x ; 234 bytes available, code assembles to 231 .include "iic+.defs"
.org boot5x ; 234 bytes available, code assembles to 231
jsr titl5x ; "Apple IIc +" jsr titl5x ; "Apple IIc +"
jsr rdrecov ; try to recover ramdisk jsr rdrecov ; try to recover ramdisk
lda power2 + rx_mslot ; get action saved by reset5x lda power2 + rx_mslot ; get action saved by reset5x
beq boot4 ; if zero, continue boot beq boot4 ; if zero, continue boot
jsr bann5x ; display ROM 5X footer jsr bann5x ; display ROM 5X footer
lda power2 + rx_mslot ; boot selection lda power2 + rx_mslot ; boot selection
btc2 cmp #$02 ; clear ramcard btc2: cmp #$02 ; clear ramcard
bne btc3 bne btc3
jsr rdclear ; do clear jsr rdclear ; do clear
bra boot4 bra boot4
btc3 cmp #$03 ; Diags btc3: cmp #$03 ; Diags
bne btc4 bne btc4
jmp $c7c4 jmp $c7c4
btc4 cmp #$04 ; RX diags btc4: cmp #$04 ; RX diags
bne btc5 bne btc5
ldx #$ff ldx #$ff
txs ; reset stack txs ; reset stack
@ -28,25 +29,25 @@ btc4 cmp #$04 ; RX diags
lda numbanks,y ; get the card size in banks lda numbanks,y ; get the card size in banks
bne dordiag ; do diag if memory present bne dordiag ; do diag if memory present
jmp swrts2 ; otherwise jump to monitor jmp swrts2 ; otherwise jump to monitor
dordiag jmp $db3a ; diags dordiag: jmp $db3a ; diags
btc5 cmp #$05 ; boot smartport btc5: cmp #$05 ; boot smartport
beq boot5 beq boot5
; fall through if none of the above ; fall through if none of the above
boot4 lda #rx_mslot ; boot slot 4 boot4: lda #rx_mslot ; boot slot 4
bra bootsl bra bootsl
boot5 lda #$c5 ; boot slot 5 boot5: lda #$c5 ; boot slot 5
bra bootsl bra bootsl
boot6 lda #$c6 ; boot slot 6 boot6: lda #$c6 ; boot slot 6
bootsl ldx #$00 ; low byte of slot bootsl: ldx #$00 ; low byte of slot
bootadr stx $0 ; store address bootadr: stx $0 ; store address
sta $1 ; return to bank 0 does jmp (0) sta $1 ; return to bank 0 does jmp (0)
endbt4x lda #>(bt5xrtn-1) endbt4x: lda #>(bt5xrtn-1)
pha pha
lda #<(bt5xrtn-1) lda #<(bt5xrtn-1)
pha pha
lda $1 lda $1
jmp swrts2 jmp swrts2
rdrecov jsr rdinit ; init ramcard rdrecov: jsr rdinit ; init ramcard
lda pwrup,y ; get power up flag lda pwrup,y ; get power up flag
cmp #pwrbyte ; already initialized? cmp #pwrbyte ; already initialized?
beq recovdn ; exit if initialized beq recovdn ; exit if initialized
@ -65,11 +66,11 @@ rdrecov jsr rdinit ; init ramcard
beq recovdn ; not bootable beq recovdn ; not bootable
lda #pwrbyte lda #pwrbyte
sta pwrup,y ; set power byte sta pwrup,y ; set power byte
lda #"R" ; tell user lda #'R' ; tell user
sta $7d0 ; on screen sta $7d0 ; on screen
recovdn rts recovdn: rts
; zero ram card space ; zero ram card space
rdclear jsr rdinit ; init ramcard rdclear: jsr rdinit ; init ramcard
jsr testsize ; get size jsr testsize ; get size
lda numbanks,y ; # of 64Ks to write lda numbanks,y ; # of 64Ks to write
beq clrdone ; no memory beq clrdone ; no memory
@ -78,10 +79,10 @@ rdclear jsr rdinit ; init ramcard
stz addrl,x ; slinky address 0 stz addrl,x ; slinky address 0
stz addrm,x stz addrm,x
stz addrh,x stz addrh,x
clbnklp inc $400 ; poor mans progress meter clbnklp: inc $400 ; poor mans progress meter
ldy #$00 ldy #$00
cl64klp ldx #$00 ; loop for all pages in bank cl64klp: ldx #$00 ; loop for all pages in bank
cl256lp txa ; loop for all bytes in page cl256lp: txa ; loop for all bytes in page
ldx #rx_devno ldx #rx_devno
stz data,x ; write a zero to card stz data,x ; write a zero to card
tax tax
@ -92,17 +93,17 @@ cl256lp txa ; loop for all bytes in page
ldx #rx_mslot ldx #rx_mslot
dec numbanks,x dec numbanks,x
bne clbnklp ; if more banks bne clbnklp ; if more banks
clrdone ldx #rx_mslot clrdone: ldx #rx_mslot
stz pwrup,x ; zero powerup byte stz pwrup,x ; zero powerup byte
lda #$a0 ; ' ' lda #$a0 ; ' '
sta $400 ; clear progress sta $400 ; clear progress
rts rts
rdinit bit rx_mslot*$100 ; activate registers rdinit: bit rx_mslot*$100 ; activate registers
ldy #rx_mslot ; slot offset ldy #rx_mslot ; slot offset
ldx #rx_devno ; register offset ldx #rx_devno ; register offset
rts rts
; next is snippet of code to boot external 5.25 ; next is snippet of code to boot external 5.25
bootext lda #$e0 bootext: lda #$e0
ldy #$01 ldy #$01
ldx #$60 ldx #$60
jmp $c60b jmp $c60b

View File

@ -1,44 +1,45 @@
#include "iic+.defs" .code
.text .psc02
* = misc5x ; max 306 bytes .include "iic+.defs"
.org misc5x ; max 306 bytes
bra domenu ; Display menu bra domenu ; Display menu
bra dobann ; Display banner (title + By MG) bra dobann ; Display banner (title + By MG)
bra gtkey ; get a key bra gtkey ; get a key
bra confirm ; ask SURE? bra confirm ; ask SURE?
bra ntitle ; display "Apple IIc +" bra ntitle ; display "Apple IIc +"
dobann jsr ntitle dobann: jsr ntitle
ldx #(msg2-msg1) ; msg display entry point ldx #(msg2-msg1) ; msg display entry point
jmp disp jmp disp
domenu jsr ntitle ; "Apple ||c +" domenu: jsr ntitle ; "Apple ||c +"
ldx #$00 ; menu start ldx #$00 ; menu start
jsr disp ; show it jsr disp ; show it
rts rts
gtkey lda #$60 gtkey: lda #$60
sta ($0),y ; cursor sta ($0),y ; cursor
sta kbdstrb ; clr keyboard sta kbdstrb ; clr keyboard
kbdin lda kbd ; get key kbdin: lda kbd ; get key
bpl kbdin bpl kbdin
sta kbdstrb ; clear keyboard sta kbdstrb ; clear keyboard
sta ($0),y ; put it on screen sta ($0),y ; put it on screen
rts rts
; display message, input x = message start relative to msg1 ; display message, input x = message start relative to msg1
disp ldy #$0 ; needs to be zero disp: 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 bne disp1 ; proceed if nonzero
rts ; exit if 0 rts ; exit if 0
disp1 inx ; next byte either way disp1: inx ; next byte either way
cmp #$20 ; ' ' cmp #$20 ; ' '
bcc disp2 ; start of ptr if < 20 bcc disp2 ; start of ptr if < 20
eor #$80 ; invert high bit eor #$80 ; invert high bit
sta ($0),y ; write to mem sta ($0),y ; write to mem
inc $0 ; inc address low byte inc $0 ; inc address low byte
bra disp0 ; back to the beginning bra disp0 ; back to the beginning
disp2 sta $1 ; write address high disp2: sta $1 ; write address high
lda msg1,x ; get it lda msg1,x ; get it
sta $0 ; write address low sta $0 ; write address low
inx ; set next msg byte inx ; set next msg byte
bra disp0 ; back to the beginning bra disp0 ; back to the beginning
confirm pha confirm: pha
ldx #(msg3-msg1) ; ask confirm ldx #(msg3-msg1) ; ask confirm
jsr disp jsr disp
jsr gtkey jsr gtkey
@ -55,7 +56,7 @@ confirm pha
; we then jump to swrts2 which switches banks and RTS to ; we then jump to swrts2 which switches banks and RTS to
; display "Apple IIc +", which then RTS to swrts, which ; display "Apple IIc +", which then RTS to swrts, which
; switches banks back to here and RTS to our caller. ; 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 pha
lda #<(swrts2-1) lda #<(swrts2-1)
pha 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 ; else are characters to display and will have their
; upper bit inverted before being written to the screen. ; upper bit inverted before being written to the screen.
msg1 = * msg1 = *
.db $05,$06,"0 Monitor" .byte $05,$06,"0 Monitor"
.db $05,$86,"1 Reboot" .byte $05,$86,"1 Reboot"
.db $06,$06,"2 Zero RAM Card" .byte $06,$06,"2 Zero RAM Card"
.db $06,$86,"3 Sys Diags" .byte $06,$86,"3 Sys Diags"
.db $07,$06,"4 RAM Card Diags" .byte $07,$06,"4 RAM Card Diags"
.db $07,$86,"5 Boot 3.5/SmartPort" .byte $07,$86,"5 Boot 3.5/SmartPort"
.db $04,$2e,"6 Boot 5.25" .byte $04,$2e,"6 Boot 5.25"
; .db $04,$ae,"7 Accelerator" ; .byte $04,$ae,"7 Accelerator"
.db $07,$5f,"By M.G." .byte $07,$5f,"By M.G."
msg2 .db $07,$db,"ROM 5X 02/10/17" msg2: .byte $07,$db,"ROM 5X 02/10/17"
.db $05,$ae,$00 ; cursor pos in menu .byte $05,$ae,$00 ; cursor pos in menu
msg3 .db $05,$b0,"SURE? ",$00 msg3: .byte $05,$b0,"SURE? ",$00

View File

@ -1,6 +1,7 @@
#include "iic+.defs" .code
.text .psc02
* = reset5x ; max 157 bytes .include "iic+.defs"
.org reset5x ; max 157 bytes
stz power2 + rx_mslot ; action = normal reset stz power2 + rx_mslot ; action = normal reset
lda #>(rst5xrtn-1) ; common case lda #>(rst5xrtn-1) ; common case
pha pha
@ -8,12 +9,12 @@
pha ; note that this stays on stack pha ; note that this stays on stack
asl butn1 ; option (closed apple) asl butn1 ; option (closed apple)
bcs ckdiag bcs ckdiag
exitrst jmp swrts2 exitrst: jmp swrts2
; check to see if cmd_option (both apples) are down ; 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 bmi exitrst ; return to RESET.X
; present menu because only closed apple is down ; present menu because only closed apple is down
menu jsr menu5x ; display menu menu: jsr menu5x ; display menu
jsr gkey5x jsr gkey5x
cmp #$b0 ; "0" cmp #$b0 ; "0"
bne ckkey1 bne ckkey1
@ -24,13 +25,13 @@ menu jsr menu5x ; display menu
lda #<(monitor-1) lda #<(monitor-1)
pha pha
jmp swrts2 ; rts to enter monitor jmp swrts2 ; rts to enter monitor
ckkey1 cmp #$b2 ; "2" ckkey1: cmp #$b2 ; "2"
beq doconf beq doconf
cmp #$b4 ; "4" cmp #$b4 ; "4"
bne ckkey2 bne ckkey2
doconf jsr conf5x doconf: jsr conf5x
bne menu ; go back to menu4x bne menu ; go back to menu4x
ckkey2 sec ckkey2: sec
sbc #$b0 ; ascii->number sbc #$b0 ; ascii->number
bmi menu ; < 0 not valid bmi menu ; < 0 not valid
cmp #$07 ; we will use 7 for accelerator later cmp #$07 ; we will use 7 for accelerator later

View File

@ -1,6 +1,7 @@
#include "iic+.defs" .code
.text .psc02
* = $fb3c ; ~165 bytes free here .include "iic+.defs"
.org $fb3c ; ~165 bytes free here
cmp #$a9 ; reset patch cmp #$a9 ; reset patch
bne chk2 bne chk2
jmp reset5x jmp reset5x

View File

@ -1,5 +1,5 @@
#include "iic+.defs" .code
.text .include "iic+.defs"
* = $fbe2 ; ~29 bytes free here .org $fbe2 ; ~29 bytes free here
jmp $fb3c jmp $fb3c

View File

@ -13,21 +13,26 @@ desc "Clean object files"
task :clean do task :clean do
sh "rm -f #{dest_rom}" sh "rm -f #{dest_rom}"
sh "rm -f sf512_#{dest_rom}" sh "rm -f sf512_#{dest_rom}"
sh "rm -f *.o65" sh "rm -f *.o"
sh "rm -f *.o65.lbl" sh "rm -f *.lst"
sh "rm -f *.b"
end end
desc "Assemble all source files" desc "Assemble all source files"
task :assemble => source_files.ext('.o65') task :assemble => source_files.ext('.b')
rule ".o65" => ".s" do |t| rule ".o" => ".s" do |t|
sh "xa -c -o #{t.name} -l #{t.name}.lbl #{t.source}" sh "ca65 -l #{t.name}.lst #{t.source}"
end
rule ".b" => ".o" do |t|
sh "ld65 -t none -o #{t.name} #{t.source}"
end end
desc "Build ROM" desc "Build ROM"
task :build_rom => [:assemble] do task :build_rom => [:assemble] do
puts "Building ROM image..." puts "Building ROM image..."
obj_files = Rake::FileList.new('*.o65') obj_files = Rake::FileList.new('*.b')
rom = File.read(source_rom) rom = File.read(source_rom)
obj_files.each do |t| obj_files.each do |t|
if t =~ /B(\h)_(\h{4})/ if t =~ /B(\h)_(\h{4})/

View File

@ -5,7 +5,7 @@
; This patch was inspired by Quinn Dunki's functionally equivalent ; This patch was inspired by Quinn Dunki's functionally equivalent
; firmware mod found here: http://quinndunki.com/blondihacks/?p=2546 ; firmware mod found here: http://quinndunki.com/blondihacks/?p=2546
.text .code
* = $fdd5 .org $fdd5
.byte $f0 .byte $f0