Language…
8 users online: CroNo486, Klug, neidoodle, ShirleyVAga, SweatyNoodle, unknownperson123, UTF, Zavok - Guests: 74 - Bots: 95
Users: 69,207 (2,359 active)
Latest user: lapakspin99

Byte to Level Mapping in Overworld Level Setting flags

I know that in the SRAM for SMW each level has one byte in
"$700000 96 bytes Mario A Overworld level setting flags. Mirrored at $7E1EA2," but I am not sure which byte has the flags for level XYZ. If someone would give me a formula for calculating what index is the byte for ZYX level, I would be very grateful.

Thank you so much!
As the entry for the mirror, $1EA2, says, the table is indexed by the format of RAM address $13BF. This means the first 37 bytes correspond to levels 000-024 in Lunar Magic (so $700000 would be the flags for level 0, $700001 for level 1, and so on) whereas the other 59 bytes are for levels 101-13B so, for example, $700025 would correspond to level 101, and so on and so forth.
Assuming you're coding a resource which needs it, if you know the level number is loaded to $13BF when writing code, you can index the SRAM address like so:
Code
LDX $13BF
LDA $700000,x

If you just want to check an address for a level directly, you could do:
Code
; place this around the top, with the rest of your defines
!level = $012    ;   the level number in lm
assert or(!level < $25, and(!level > $100, !level <= $13B)), "Invalid level number!"
if !level > $24
    !level #= !level-$DC
endif
;---

; somewhere in your code do
LDA.l $700000+!level
; or you could check the mirror:
LDA.w $1EA2+!level
Please check out BOWSIE!
better days coming for sure
Thank you! I'm using this for a SMW SRAM editor.