Arbitrary Bankswitch

JamesNES

Well-known member
I made this macro to switch from one bank to another and come back, so if you're in say 1A and want to call your playerHurt subroutine which is in 1C, you can do:

Code:
SuperSwitch #$1C, #<playerHurt, #>playerHurt

from 1A and it'll work just fine.

Just include doSuperSwitch.asm in your LoadAllSubroutines.asm and put the SuperSwitch.asm file in your macros.

I've used it a lot so far with no problems.

Edit: just to clarify, it has to go to a subroutine, ie with an RTS at the end.
 

Attachments

  • SuperSwitch.zip
    649 bytes · Views: 24
Last edited:

3DPLABox

Member
This has saved me so much effort in my sprite draw code, you have no idea. I've had issues trying to get bank switching to work for sprites, but now I have all of my custom draw codes in #$1D and it works flawlessly from what I've seen so far!
 

JamesNES

Well-known member
This has saved me so much effort in my sprite draw code, you have no idea. I've had issues trying to get bank switching to work for sprites, but now I have all of my custom draw codes in #$1D and it works flawlessly from what I've seen so far!
I've kept using it too and it hasn't broken anything yet, I think I got it right!
 
Top Bottom