Hacking questions:MMC1 expansion of Super Mario Bros + Asm 6

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
mikaelmoizt
Posts: 120
Joined: Sat Apr 12, 2014 12:11 pm
Location: Gothenburg, Sweden

Hacking questions:MMC1 expansion of Super Mario Bros + Asm 6

Post by mikaelmoizt »

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.

Code: Select all

; 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
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: Select all

; 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)
Any ideas?
I´ve got %01100011 problems but the BITs aint one.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Hacking questions:MMC1 expansion of Super Mario Bros + A

Post by tokumaru »

I believe you're looking for the .base directive. Look it up in ASM6's manual. It basically changes the PC to whatever value you want.
mikaelmoizt
Posts: 120
Joined: Sat Apr 12, 2014 12:11 pm
Location: Gothenburg, Sweden

Re: Hacking questions:MMC1 expansion of Super Mario Bros + A

Post by mikaelmoizt »

Ah.. yes. I finally figured it out. The reason why I could not get the correct adress is because I include too much of the rom to overlap the correct orientation of my code. Lesson learned - chunks must be separated.

So

Code: Select all

incbin "smbSxROM.nes" , $00, $4010 ; prg block 1
  base $8000 ; Tokumaru - you rock 
  rts ; Random test crap
  nop
  rts
  nop
  rts
  pad $c000, $ea
  incbin "smbSxROM.nes", $8010


will replace 16k of $FF and allow me to carry on code at $8000. Thanks a lot!
I´ve got %01100011 problems but the BITs aint one.
Post Reply