Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,481,214
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 04-25-24 10:06 AM
Guest: Register | Login

0 users currently in ROM Hacking | 2 guests

Main - ROM Hacking - *sigh* Need some help with this bank switching New thread | New reply


RetroRain
Posted on 04-04-08 02:42 AM Link | Quote | ID: 81458


Fuzz Ball
Level: 66

Posts: 74/994
EXP: 2437980
Next: 23871

Since: 09-30-07

Last post: 1934 days
Last view: 956 days
The game is SMB3. What I want to do, is use one of my free PRG-banks specifically for my extra animation code, because using the space that I'm using near the original animation code, is glitching up my game. However, I have some questions concerning the bank switching code:

1. Can I swap a free bank into $8000-$9FFF, and then swap it back to the original bank, while the level is running? I've been trying to do this, but to no success, thats why I want to know if it is possible?

2. If you do a bank switch, does it start reading the code from the very beginning of the bank, or from the address that you switched the new bank in?

3. If you switch to the new bank, and you switch back, and it does start reading the code from the top, how do you bypass the Bank swap code? You obviously want the rest of the code to be read.

SMB3 Tile Animation Code:

$8E35:AC 1A 07 LDY $071A
$8E38:C0 6A CPY #$6A
$8E3A:F0 21 BEQ $8E5D
$8E3C:A5 15 LDA $15
$8E3E:29 03 AND #$03
$8E40: D0 1B BNE $8E5D
$8E42:C8 INY
$8E43:C8 INY
$8E44:C0 76 CPY #$76
$8E46: D0 02 BNE $8E4A
$8E48:A0 70 LDY #$70
$8E4A:8C 1A 07 STY $071A
$8E4D: D0 0E BNE $8E5D
$8E4F:A5 15 LDA $15

$8E51:29 18 AND #$18
$8E53:4A LSR
$8E54:4A LSR
$8E55:4A LSR
$8E56:AA TAX
$8E57: BD FC 83 LDA $83FC,X
$8E5A:8D 1A 07 STA $071A

My Code:

$8E48:A0 70 LDY #$70
$8E4A:8C 1A 07 STY $071A
$8E4D:A9 06 LDA #$06
$8E4F:8D 00 80 STA $8000
$8E52:A9 1E LDA #$1E
$8E54:8D 01 80 STA $8001
$8E57: D0 0E BNE $8E5D
$8E59: A5 15 LDA $15


I squeezed my bank swap code in here, but all it does is lock up my game, and it doesn't swap the bank in. Or if it does swap it, I can't see it in the debugger. Could use a little help here. I just want to swap a free bank in temporarily, have it run my code, and then put the original bank back. Thanks for any help you can give me.

____________________
My YouTube Channel

never-obsolete
Posted on 04-04-08 03:24 AM (rev. 6 of 04-04-08 03:28 AM) Link | Quote | ID: 81459


Rat
Level: 24

Posts: 18/96
EXP: 74489
Next: 3636

Since: 02-22-07
From: Phoenix, AZ

Last post: 2595 days
Last view: 2595 days
here's some code i used in tecmo super bowl, another mmc3 game. you'll need to write a six to MMC3_CTRL instead.


; this is an anchor point for calling functions outside their needed banks
; Y=funciton index
SubCallFunc_PRG01:
tya ; set function address
asl ;
tay ;
lda bankswitch_func_ptr_table, Y ;
sta $FD ;
lda bankswitch_func_ptr_table + 1, Y ;
sta $FE ;
lda #07 ; swap banks (8K @ $A000)
sta MMC3_CTRL ;
lda #02 ; (prg1-low)
sta MMC3_DATA ;
jsr _func_indirectJump ; do some shit
lda #07 ; swap back
sta MMC3_CTRL ;
lda #$11 ;
sta MMC3_DATA ;
rts ; return

_func_indirectJump: jmp ($00FD) ; software: JSR ($nnnn)

bankswitch_func_ptr_table:
.dw SubWriteNewAttTable, SubDecProBowlIndex, SubIncProBowlIndex, Sub_SwapTeams


1. yes
2. no the PC drops to the next instruction unless you change it. switching out whatever bank that the PC points to is not a good idea either.

hope that helps

Main - ROM Hacking - *sigh* Need some help with this bank switching New thread | New reply

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.018 seconds. (341KB of memory used)
MySQL - queries: 42, rows: 63/64, time: 0.015 seconds.