News:

11 March 2016 - Forum Rules

Main Menu

Jumping from one bank to another in Rockman 2?

Started by cschifani, October 21, 2022, 08:27:23 PM

Previous topic - Next topic

cschifani

I'm working on a hack of Rockman 2, and I know that the 8 Robot Master AI is in the 2c block. I have the AI that I want, but I don't have enough space to put it in the standard ROM's code. My question is, if I'm using a ROM that has been expanded to the MMc3 mapper, how do I jump from the 2c block to say, 40010 or a later location and then back to the 2c block if I need to. I understand that 4c can do direct addressing, and I've seen 6c 08 80 execute even larger jumps, but I'm not sure how the latter works in practice. Any information you might be able to share about how to precisely tell a ROM how to jump somewhere outside of the main bank would be greatly appreciated.

Cyneprepou4uk

#1
The difference between 4C and 6C jumps is their addressing mode, not jumping distance (which is 0000-FFFF for both of them). 4C is an absolute jump with a preset address, while 6C is indirect (you can configure its destination by changing bytes at specified RAM addresses). Well, technically 4C can also be somewhat indirect if you execute it from RAM, but that's a different story.

In order to swap banks in MMC3, you need to execute bankswitching code from a fixed C000-FFFF bank. First write 06 (to swap 8000-9FFF) or 07 (to swap A000-BFFF) to 8000 register, then write bank id to 8001 register. Corresponding CPU area will be swapped immediately, and you can do whatever the hell you want with it. If you need to swap banks back, do it from a fixed bank as well.

A couple of tips here
https://www.romhacking.net/forum/index.php?topic=34711.msg428829#msg428829

cschifani

What you say is helpful, but I still don't quite understand what the jump code would look like in practice. If I want to take the code from 20c5d-20cf2 and move it to 40010, how do I know what the jump codes would look like? Specifically, I don't understand what you mean when you say "write bank id to the 8001 register." What does that look like? Thank you again for taking the time to educate me!

Cyneprepou4uk

Something like this

; C000-FFFF
LDA #$07  ; A000-BFFF
STA $8000
LDA #$20  ; 0x40010-0x4200F
STA $8001
JSR $A000 ; 0x40010