Any good place I can declare variables that aren't GUI-related?

darkhog

New member
Wasting user variables which seems to be closely tied to HUD variables seems a bit off to me when the data I want to store has nothing to do with displaying stuff on HUD. Any good place where I can declare custom variables? By good, I mean one that won't be overwritten by code generation.
 

Atarath

Member
Does this still hold true? I noticed everything in the script as been commented out.

Also, I see that user vars create through the project settings are declared in GameEngineData\GameData\Variables\UserVariables.asm
Does declaring a variable elsewhere change where it is stored in memory? I've noticed tile glitches when I declare more user vars the normal way.
 

dale_coop

Moderator
Staff member
With NESMaker 4.1.X, you go to « Project Settings > User Variables » to add and set the initial value of your new variable.
Same for constants in « Project settings > User constants ».
 

Mugi

Member
what i did was looked up where the file is loaded into the code that the GUI uses to load the variables, then just did ".include myownuservars.asm"
i just use that for variables and leave the default variable file and the GUI list empty.
it will still automagically shovel you the default HUD variables there if you leave the default file in, but you can just delete them and run test.bat to compile your game instead of the test and compile button of the UI that loves overwriting hand-made changes :p

alternatively, you can simply comment out the original uservars file to ensure the default variables wont be returning.

also, when you do this, you will have to make sure you also initialize the variables (set their default values) correctly.

by default, user variables are stored on GameEngineData\GameData\Variables\UserVariables.asm
and the Initialization file is stored on GameEngineData\GameData\InitializationScripts\hudVarInits.asm

hudvarInits.asm is included in InitLoads.asm that's located in GameEngineData\Routines\Basic\InitializationScripts\InitLoads.asm
UserVariables.ams is included in MemoryMap.asm located in GameEngineData\Routines\Basic\System\MemoryMap.asm
 

Atarath

Member
Awesome, thank you! What is the benefit of declaring variables this way? Does it keep things from getting overwritten? Because I've noticed specific graphical glitches the more user vars I've created.
 

Mugi

Member
it has no extra benefit really.
only reason i do this is to get rid of the predefined user variables which are for the HUD.
i dont use the hud so for me those are just 7 bytes of wasted space, and the UI restores them to the default assembly files whenever you compile the game.
by doing it with adding your own file instead, the UI will still restore the default variables to the default file, but your game wont use the default file anymore.

and yeah, there are no checks in place or a counter on the UI to keep track of how much space you have for user variables (it's not much) and it starts overwriting other gamedata once youfill the space up.
 

Atarath

Member
That has to be what is happening. How much space do user constants take up? And do they share the same resources as user vars, so that I could delete some constants and have more variables available?
 
Top Bottom