Going through this door to Boom Boom...
Takes you back to the first room of the fortress.
Going through the spike room door in the world 2 fortress also does the same thing, takes you back to the first room of the fortress. The only thing either of these rooms have in common is both rooms scroll.
I updated the HUD code to support 3-digit coin numbers. If I don't include the updated HUD, the doors work fine. That leads me to believe my HUD code is broken in some fashion:
LDA $1D80,X ; with indexing, it should be at $1DA2 for mario
BCC _ThirdCoin ; first logic check, making sure a third digit is incremented!
; so now we need to do display stuff, essentially just adding in support to increment the third digit
JSL $3BF400 ; update coins
padbyte $00 : pad $29E72F
PHA ; save upper A before it gets destroyed, just in case it's needed
CMP #$03E8 ; 1000 coins?
BCC not_maxed_out ; this branch will generally always be taken
; but if for some reason it's not, let's do max numbers
PLA ; restore A
STA $1F60 ; store it away for now
LDA #$03 ; 3 loops
PHY ; preserve Y, we likely need it
STA $1F63 ; for math
STZ $1F65 ; and more math
LDA $1F60 ; load our original value
SBC $1F63 ; and subtract our LUTs value, either 100, 10, or 1
BCC mathloop2 ; if carry is clear, we wrapped
STA $1F60 ; effectively restoring our original value
; now that all of the conversions are done, we need to get them to display
STA $1F48 ; ten's digit
STA $1F49 ; one's digit
STA $1F30 ; hundred's digit
I've used different values for my math, including scratch DP and other locations in ram that don't look like they're used. I've run comparison traces from original and this hack, and no appreciable differences have been spotted. This HUD is updated every frame, but doesn't execute while Mario is in the process of going through a door. The stack is still stable, correct bank is still in play, and register sizes are what they should be.
My best guesses are either I've triggered some goofy copy-protection, or my code is just too slow. If it's too slow, it's only by a matter of cycles, since the vanilla game uses a rather sloppy method to do 2-digit coin display.
Would anyone be willing to take a look at it and see what could be wrong?