Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - [SOLVED] WLA DX calculating same memory addresses for different variables.

Reply to topic
Author Message
  • Joined: 23 Aug 2009
  • Posts: 75
  • Location: Seattle, WA
Reply with quote
[SOLVED] WLA DX calculating same memory addresses for different variables.
Post Posted: Mon Nov 04, 2019 12:24 am
Last edited by SavagePencil on Mon Nov 04, 2019 4:51 pm; edited 3 times in total
UPDATE. WLA DX will not advance the memory address in a struct, union, or enum if the variable is declared with a dot before the size type. Per the documentation:


.ENUM $C000 DESC EXPORT
bigapple_h db
bigapple_l db
bigapple:  .dw
.ENDE


...will alias the bigapple and bigapple_h to the same address, with bigapple_l to one byte lower.

Thanks Colindro for pointing this out.

END UPDATE



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

[/code][/b]
  View user's profile Send private message
  • Joined: 14 Apr 2013
  • Posts: 481
Reply with quote
Post Posted: Mon Nov 04, 2019 5:23 am
SavagePencil wrote
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


It's because of the dot you put before the sizes (e.g. .db). It tells WLA to not increase the address counter.
  View user's profile Send private message Visit poster's website
  • Joined: 23 Aug 2009
  • Posts: 75
  • Location: Seattle, WA
Reply with quote
Post Posted: Mon Nov 04, 2019 5:33 am
holy Christmas how did I miss that

Thank you!
  View user's profile Send private message
  • Joined: 14 Apr 2013
  • Posts: 481
Reply with quote
Post Posted: Mon Nov 04, 2019 5:53 am
SavagePencil wrote
holy Christmas how did I miss that

Thank you!

The forum tells me it's your birthday today. In case it's correct: Happy Birthday! :)
  View user's profile Send private message Visit poster's website
  • Joined: 23 Aug 2009
  • Posts: 75
  • Location: Seattle, WA
Reply with quote
Post Posted: Mon Nov 04, 2019 2:04 pm
Well yours is the best gift I’ve gotten so far!
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!