I'm having an issue where WLA DX (9.10a) is generating incorrect memory addresses and I want to make sure I'm not doing anything incorrect.
Here is the issue I am seeing in the assembly and .SYM file:
00:c044 gModeTitleScreen
00:c044 gModeTitleScreen.ScreenFSM
00:c044 gModeTitleScreen.ScreenFSM.CurrentState
00:c046 gModeTitleScreen.Controller1DebounceModule
00:c046 gModeTitleScreen.Controller1DebounceModule.DebounceFSM
00:c046 gModeTitleScreen.Controller1DebounceModule.DebounceFSM.CurrentState
00:c048 gModeTitleScreen.Controller1DebounceModule.DebounceParams
00:c048 gModeTitleScreen.Controller1DebounceModule.CurrentVal
00:c048 gModeTitleScreen.FadeUp
00:c048 gModeTitleScreen.FadeUp.TimingCounter
00:c049 gModeTitleScreen.FadeUp.CharsRemaining
00:c048 gModeTitleScreen.AwaitInput
00:c048 gModeTitleScreen.AwaitInput.BlinkTimer
00:c049 gModeTitleScreen.AwaitInput.IsOn
00:c04a gModeTitleScreen.AwaitInput.ButtonReleased
Note that multiple objects are sharing 0xC048. This is incorrect. Here are the structs that are defining this:
.STRUCT TitleScreen
; FSM governing the screen's state transitions.
ScreenFSM INSTANCEOF FSM
; Module used to ensure the player releases buttons before we accept input from them.
Controller1DebounceModule INSTANCEOF DebounceModule_Instance
; Independent variables unique to each state.
.UNION FadeUp
TimingCounter DB ; Current counter value
CharsRemaining DB ; How many characters are left?
.NEXTU AwaitInput
BlinkTimer DB ; How long before we blink?
IsOn DB ; Are we currently displayed, or no?
ButtonReleased DB ; Have we seen a button released yet?
.ENDU
.ENDST
The debounce module, which seems to be at the heart of the problem, is defined here:
; The parameters that drive debounce logic. Can be in ROM or RAM.
.STRUCT DebounceModule_Parameters
DesiredVal .DB ; What value are we looking for to know when we're done?
Mask .DB ; Current val is AND'd against this
.ENDST
; Maintains the state of a debounce module. Must be in RAM.
.STRUCT DebounceModule_Instance
DebounceFSM INSTANCEOF FSM
DebounceParams .DW ; Pointer to parameters
CurrentVal .DB ; Current value to be tested against
.ENDST
Where it's most unsettling is right here:
00:c048 gModeTitleScreen.Controller1DebounceModule.DebounceParams
00:c048 gModeTitleScreen.Controller1DebounceModule.CurrentVal
00:c048 gModeTitleScreen.FadeUp
00:c048 gModeTitleScreen.FadeUp.TimingCounter
DebounceParams is a .DW, and should take up C048 and C049, with CurrentVal taking up C04A. However, this isn't the case, as everyone is taking up C048.
I thought at first it might be an issue with the UNION, but even after removing it, I'm still seeing the same issue.
Here is how the TitleScreen struct is instantiated:
.RAMSECTION "Mode - Title Screen Context" SLOT 3
gModeTitleScreen INSTANCEOF TitleScreen
.ENDS