Hello again. Back after some time now, still coding and hacking.
So I found a patch some time ago that turns your SMB (n)rom into a mapper 1 rom complete with a bank switch routine. It is really nice for large scale hacks and whatever experiments to try.
Tired of painfully entering hex values inside fceux, I figured : "Hey let's import this thing into ConText and get a much simpler way of adding things in!"
After some basic setup code, I managed to add my own routines in hardwired memory at $f300 and onward. So, cool.
Now, here is what I am trying to do:
Switch upper bank (simple) and continiue my own code, now starting at $8000. With a lot of trickery I found that incbin-ing first 16k block and adding code would put whatever routine I am working on in the correct place without org $8000, however this messes up the code allocation and forces me to calculate my jmps and jsrs by hand. Also, I need to pad nop's.. a lot of them.
What I would have wanted is something like this:
Any ideas?
So I found a patch some time ago that turns your SMB (n)rom into a mapper 1 rom complete with a bank switch routine. It is really nice for large scale hacks and whatever experiments to try.
Tired of painfully entering hex values inside fceux, I figured : "Hey let's import this thing into ConText and get a much simpler way of adding things in!"
After some basic setup code, I managed to add my own routines in hardwired memory at $f300 and onward. So, cool.
Code:
; Lets start with some basic defines
controller equ $06fc
mariosize equ $0754
mariofire equ $0756
incbin "smbSxROM.nes" , $00 , $01ad ; Include a patched version of SMB rom file from start to $01ad (430 bytes)
; This will replace the good old startbutton routine with..
pipeline:
jsr main ; Our hack!
incbin "smbSxROM.nes" , $01b0, $f310-$01b0 ; All code now will start at $f300 in bank 3 (always mapped)
org $f300 ; To give the compiler correct adress
; This will provide 3263 bytes. Not bad.
main: ; Here we go.
lda controller
and #$20 ; select
bne +
rts
+
lda mariosize
beq small
lda #$00
sta mariosize
rts
small:
lda #$01
sta mariosize
rts
enddummy:
pad $ffbf, $ea ; Pad with nop's
rts ; Safety rts for catching any misstake
incbin "smbSxROM.nes" , $ffd0 ; Include the ROM once more and fill rest of memory
;EOF
controller equ $06fc
mariosize equ $0754
mariofire equ $0756
incbin "smbSxROM.nes" , $00 , $01ad ; Include a patched version of SMB rom file from start to $01ad (430 bytes)
; This will replace the good old startbutton routine with..
pipeline:
jsr main ; Our hack!
incbin "smbSxROM.nes" , $01b0, $f310-$01b0 ; All code now will start at $f300 in bank 3 (always mapped)
org $f300 ; To give the compiler correct adress
; This will provide 3263 bytes. Not bad.
main: ; Here we go.
lda controller
and #$20 ; select
bne +
rts
+
lda mariosize
beq small
lda #$00
sta mariosize
rts
small:
lda #$01
sta mariosize
rts
enddummy:
pad $ffbf, $ea ; Pad with nop's
rts ; Safety rts for catching any misstake
incbin "smbSxROM.nes" , $ffd0 ; Include the ROM once more and fill rest of memory
;EOF
Now, here is what I am trying to do:
Switch upper bank (simple) and continiue my own code, now starting at $8000. With a lot of trickery I found that incbin-ing first 16k block and adding code would put whatever routine I am working on in the correct place without org $8000, however this messes up the code allocation and forces me to calculate my jmps and jsrs by hand. Also, I need to pad nop's.. a lot of them.
What I would have wanted is something like this:
Code:
; Imaginary assembler code
org $f300
(do stuff)
switch upper bank and tell my assembler to now "work" in bank #1/2/3
org $8000
(continue with the routine here)
org $f300
(do stuff)
switch upper bank and tell my assembler to now "work" in bank #1/2/3
org $8000
(continue with the routine here)
Any ideas?