Banner
Views: 852,658,908
Time:
7 users online: Counterfeit, crm0622, Green Jerry,  MarioFanGamer, OEO6, syd27, Zidan3 - Guests: 44 - Bots: 78 Users: 47,015 (2,516 active)
Latest: smallroguefish
Tip: Layer 3 backgrounds and tides disappear when you hit a message box, so plan your level around that. For example, you can add a sublevel without layer 3 at the start/midpoint, and include your message there.Not logged in.
Can I use SRAM like this? Why does it work? How to effectively store values?
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - Can I use SRAM like this? Why does it work? How to effectively store values?
Pages: « 1 »
I just started learning asm yesterday (out of necessity) and I would love some help and explanations.

So I use the SRAM addresses of the switch palace activation flags to store some info about if the player has passed a certain area. I use $1F27 for this. According to the SRAM map that is a flag used for the first save file only. However, my code works on all 3 save files independently. (I expected all to read from the save file 1 flag)

Does smw just handle this automatically? I don't understand why this works.

According to the SRAM map $1F27 has a lenght of 4 bytes. How can I use them effectively? Currently I just set $1F27 to #$1 if I want to set the flag. But I should be able to set 32 (4*8) flags in just this address, right?

Is this generally a good way to go about things? (I don't want to use SA-1) Or will this method fail me somehow later? (I don't need the vanilla switches)
Originally posted by ageVerrly
So I use the SRAM addresses of the switch palace activation flags to store some info about if the player has passed a certain area. I use $1F27 for this. According to the SRAM map that is a flag used for the first save file only. However, my code works on all 3 save files independently. (I expected all to read from the save file 1 flag)

First off: No, $1F27 is not SRAM. Instead, $1F27 is part of the WRAM which is transferred to SRAM when you save the current file (hence why it's saved to the current savefile only). The $0000-$1FFF area is hardcoded to WRAM (at least on banks $00-$3F). If a mapping includes SRAM mirrors, it's located at $6000-$7FFF (such as on BW-RAM on SA-1 which replaces SRAM).

Originally posted by ageVerrly
According to the SRAM map $1F27 has a lenght of 4 bytes. How can I use them effectively? Currently I just set $1F27 to #$1 if I want to set the flag. But I should be able to set 32 (4*8) flags in just this address, right?

$1F27 is four bytes, one byte for each !-block colour. Which means using them as freeRAM is a bad example unless you don't use !-blocks and their switches. Aside from their function in general, SMW uses them in the object code to determine their Map16 number high byte (so a value of 0 means page 0, a value of 1 means page 1 but a value of 0x80 is the non-existant page 0x80).
You might want to use $1F2B which is entirely unused in SMW but also backed up to SRAM. Want to back up more RAM? Use SRAM Plus!
You are otherwise correct that you can use them with individual bits.

You are correct that you can use them as flags, though.

--------------------
Okay, my layout looks ugly.
Thank you. That cleared up a lot of misunderstanding.
Pages: « 1 »
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - Can I use SRAM like this? Why does it work? How to effectively store values?

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2020 - SMW Central
Legal Information - Privacy Policy - Link To Us


Menu

Follow Us On

  • YouTube
  • Twitch
  • Twitter

Affiliates

  • Super Mario Bros. X Community
  • ROMhacking.net
  • Mario Fan Games Galaxy