Understanding User Variable Space

I have been using user variables so far without any issue, but I have heard on multiple occasions that the space we have for them is very limited.

For someone who understands the memory layout better, is there any way I can check how much more room I have for user variables?

I'm actually concerned that I may have already gone over the limit and haven't noticed the effects yet.
Here is my user variable space from demo.txt:

Code:
006F9                           ;; *************** User Defined Vars ***************
006F9                           projectileLimit	.dsb 1
006FA                           plrAbility	.dsb 1
006FB                           abilityTimer	.dsb 1
006FC                           bossSetup	.dsb 1
006FD                           monstersSpawned	.dsb 1
006FE                           enemiesKilledScreen	.dsb 1
006FF                           isPaused	.dsb 1
00700                           screenPrizeCounter	.dsb 1
00701                           screenChange	.dsb 1
00702                           autotextEnable	.dsb 1
00703                           	.ende
 

Kasumi

New member
Userspace variables are from $0600-$06FF, so yes you are going over.

That said, whether that matters technically depends on your module. $0700 is defined as FlashRamPage or CollisionRam2. I believe the non scrolling modules don't use that RAM. (I have seen non scrolling games that have activity in that area, but they may just be non scrolling games made with the scrolling module >_> )
 

FrankenGraphics

New member
i enumerate my custom vars in the pc stack ($100) in addition to the few "user" vars i have; right before the music engine. Right now i'm keeping 48 bytes in there; and could go higher without risk.

You need to be a bit careful though; eventually, music ram and stack pointers will be in conflict (on the other hand that should fail spectacularily which ought to be a clear signal) if you put too many vars in the stack.
 
Kasumi said:
Userspace variables are from $0600-$06FF, so yes you are going over.

That said, whether that matters technically depends on your module. $0700 is defined as FlashRamPage or CollisionRam2. I believe the non scrolling modules don't use that RAM. (I have seen non scrolling games that have activity in that area, but they may just be non scrolling games made with the scrolling module >_> )

That may be why I haven't noticed anything.

When I started my game, I thought I wanted scrolling. It caused so many issues though, that I eventually removed most of the scrolling code. There are probably some remnants around, but its all disabled.

Since I am not using scrolling, do you think its safe to still add a few variables to that space? Or do I need to try and move where the user variables are located?
If the variables start to overwrite whatever is in the next space, is it more likely that I will start seeing wierd behavior or just a straight up crash?
 

FrankenGraphics

New member
Before filling in your own functions, you can make sure using the debugger feature of fceux and mesen.

Add a breakpoint specifying the range you want to watch, press run, and look for anything beside the first initialization. the program will pause whenever the condition is met. you want to be on the lookout for writes, especially.
 
Top Bottom