Register | Login | |||||
Main
| Memberlist
| Active users
| Calendar
| Chat
| Online users Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album |
| |
0 users currently in SMW Hacking. |
User | Post |
BMF54123 Posts: 260/876 |
Originally posted by HyperMackerelI suppose, though it's filled with #$25, which isn't good if your code expects flags not to be set when you enter a level. |
HyperHacker Posts: 1596/5072 |
Originally posted by BMF54123 Hm, so does that mean $7EFF00-$7EFFFF is safe too? |
SnifflySquirrel Posts: 7/80 |
Originally posted by Glyph Phoenix Unfortunately, if I do that, my code only runs if I enter the level from the overworld. If I go through a pipe (for example) and warp to the level, it doesn't run, and I need it to. Fortunately, I think I've devised a workaround (which I'll post, in case anyone cares ). Being new to this as I am, the only code I know of that's guaranteed to run every time a level is loaded is the routine that makes LevelASM possible in the first place--the one installed by levelnum.ips. I relocated the routine (adding a JSL to it at the old location) and tacked my own initialization code onto the end of it. I tested it out, and it works just as I'd hoped. Hurray for me. |
Glyphodon Posts: 121/536 |
LevelASM is not the right tool for the job. The whole point of LevelASM is so you have an easy way to run code every frame in a specific level. If that's not what you're aiming for, you shouldn't be using it.
At x213B8 there should be a snippet of code that is focused on initializing variables. If you put your own jump statement in to relocate this code somewhere where you have more room, you can put whatever you want there and it will only run once and only at the very beginning of the level. If you wanted it to run only in a certain level, you'd have to put in your own compare and branch statements so it doesn't initialize the variable in every level. But, if most levels don't use that spot in RAM at all, you might not even need a branch statement. |
BMF54123 Posts: 259/876 |
All RAM between $7EC800-$7EFFFF and $7FC800-$7FFFFF is cleared between levels, though the vast majority of that holds the current level layout. You should be safe storing a flag between $7FFF00-$7FFFFF (even the largest possible Layer 2 level never touches it), though a few people have already used the space for their own ASM hacks, so beware.
The safest thing to do (which I've implemented in my own hack) would be to hack the RAM-clearing routine to also clear another small area of memory, and use that instead. There are 1792 bytes of uninitialized RAM between $7EC100-$7EC7FF. |
1169 Posts: 18/36 |
It really depends on the nature of the value. The logical way to do it would be to set a flag and use a branch based on the flag in your routine so the guts of your routine doesn't fire if the flag is set.
The problem with this is that as far as I know LevelASM doesn't allow you to put code in the 'exiting' code of a level which means you have no way of reseting the flag via LevelASM . . . you could always find the code that executes when you leave a level an manually insert it. |
SnifflySquirrel Posts: 6/80 |
I need a portion of a LevelASM routine I'm writing to execute only on the very first frame of the level (to initialize some values). Is there any sure way to do this besides putting the initialization routine in a separate level? |