[4.5.9] User Variables vs Zero Page RAM vs Overflow RAM

Zikifer

Member
What is the difference between the three variable tabs? User Variables and Zero Page RAM combine together, and the only difference seems to be that a User Variable can be initialized to non-zero while a Zero Page RAM can be multiple bytes wide. And then Overflow RAM is a separate memory block where variables can be multiple bytes wide but cannot be initialized (except in code). So is the only reason to use User Variables over Zero Page RAM the fact that they can be initialized to non-zero? Are there any performance considerations? What about performance between Zero Page and Overflow? Or any other considerations when choosing Zero Page vs. Overflow?
 

mileco

Active member
What is the difference between the three variable tabs? User Variables and Zero Page RAM combine together, and the only difference seems to be that a User Variable can be initialized to non-zero while a Zero Page RAM can be multiple bytes wide. And then Overflow RAM is a separate memory block where variables can be multiple bytes wide but cannot be initialized (except in code). So is the only reason to use User Variables over Zero Page RAM the fact that they can be initialized to non-zero? Are there any performance considerations? What about performance between Zero Page and Overflow? Or any other considerations when choosing Zero Page vs. Overflow?
I'd like to know too.
 

Zikifer

Member
One thing I've read is that zero page is faster to access than (what we call) overflow RAM. (Although it's interesting that the camX and camY variables are all in Overflow and some of those are read during NMI, which I would think we would want to be fast.)

I also wonder if there is a difference when calling a macro. I have been trying to get the following to work:
Code:
WarpToScreen warpMap, prevNametable, #$02
But it is not warping to the screen I want. If I instead do this, it works:
Code:
LDA warpMap
STA temp
LDA prevNametable
STA temp2
WarpToScreen temp, temp2, #$02
warpMap and prevNametable are both in Overflow, while temp and temp2 are on Zero Page.
 

NightMusic

Active member
What is the difference between the three variable tabs? User Variables and Zero Page RAM combine together, and the only difference seems to be that a User Variable can be initialized to non-zero while a Zero Page RAM can be multiple bytes wide. And then Overflow RAM is a separate memory block where variables can be multiple bytes wide but cannot be initialized (except in code). So is the only reason to use User Variables over Zero Page RAM the fact that they can be initialized to non-zero? Are there any performance considerations? What about performance between Zero Page and Overflow? Or any other considerations when choosing Zero Page vs. Overflow?
Hopefully someone or Joe makes a primer on this topic.
 

mileco

Active member
Hopefully someone or Joe makes a primer on this topic.
I'm a follower of your YouTube channel (you have saved me with the arcade tuts) and now I'm toying with the adventure module. Will you continue with your Adventure module tutorials?
 

JayJayHux

Member
I would love to know the differences between User Variables, User Constants, Object Variables, Zero Page RAM and Overflow RAM.
I understand some differences but overall I have a weak understanding. I am about to run out of User Variables but have many spaces free in all other areas.
Any simple breakdown of all of them would be very helpful.
 

smilehero65

Active member
I would love to know the differences between User Variables, User Constants, Object Variables, Zero Page RAM and Overflow RAM.
I understand some differences but overall I have a weak understanding. I am about to run out of User Variables but have many spaces free in all other areas.
Any simple breakdown of all of them would be very helpful.
I am curious to know about the others, but I know that UserConstants are static numbers that don't take space from memory.
 

dale_coop

Moderator
Staff member
@JayJayHux @smilehero65

Basically, Zero RAM variables are faster and cost fewer CPU cycles than Overflow RAM variables. For each variable, you can define its size (1 byte by default).
As for User Variables, this is NESmaker terminology. They are simply 1-byte Zero RAM variables for which you can specify a default value that is set during Initialization.
Object Variables are variables whose total size is defined by Total Max Objects. In practice, you can think of them as an array of variables, with one entry per object.

For each of them (Zero RAM + User Variables, Overflow RAM, and Object Variables), the total size must not exceed 255 bytes. If it does, data will be read from or written to memory addresses that are already used by other variables or by parts of the code.


Note: There are a LOT of Zero RAM and Overflow variables that are not actually used by the engine. You can safely remove dozens of them.
To find them, one method is to go through the variables one by one and search for them in the demo.txt file (located in the GameEngineData folder). Make sure they are not used anywhere other than their declaration and not just in comments.
If a variable is not used, you can remove it and then Export & Test to make sure everything is fine (If the variable was actually used, the compilation will fail and report an error)
 
Last edited:

smilehero65

Active member
@JayJayHux @smilehero65

Basically, Zero RAM variables are faster and cost fewer CPU cycles than Overflow RAM variables. For each variable, you can define its size (1 byte by default).
As for User Variables, this is NESmaker terminology. They are simply 1-byte Zero RAM variables for which you can specify a default value that is set during Initialization.
Object Variables are variables whose total size is defined by Total Max Objects. In practice, you can think of them as an array of variables, with one entry per object.

For each of them (Zero RAM + User Variables, Overflow RAM, and Object Variables), the total size must not exceed 255 bytes. If it does, data will be read from or written to memory addresses that are already used by other variables or by parts of the code.


Note: There are a LOT of Zero RAM and Overflow variables that are not actually used by the engine. You can safely remove dozens of them.
To find them, one method is to go through the variables one by one and search for them in the demo.txt file (located in the GameEngineData folder). Make sure they are not used anywhere other than their declaration and not just in comments.
If a variable is not used, you can remove it and then Export & Test to make sure everything is fine (If the variable was actually used, the compilation will fail and report an error)
Thanks for the explanation, Dale!
 

JayJayHux

Member
@JayJayHux @smilehero65

Basically, Zero RAM variables are faster and cost fewer CPU cycles than Overflow RAM variables. For each variable, you can define its size (1 byte by default).
As for User Variables, this is NESmaker terminology. They are simply 1-byte Zero RAM variables for which you can specify a default value that is set during Initialization.
Object Variables are variables whose total size is defined by Total Max Objects. In practice, you can think of them as an array of variables, with one entry per object.

For each of them (Zero RAM + User Variables, Overflow RAM, and Object Variables), the total size must not exceed 255 bytes. If it does, data will be read from or written to memory addresses that are already used by other variables or by parts of the code.


Note: There are a LOT of Zero RAM and Overflow variables that are not actually used by the engine. You can safely remove dozens of them.
To find them, one method is to go through the variables one by one and search for them in the demo.txt file (located in the GameEngineData folder). Make sure they are not used anywhere other than their declaration and not just in comments.
If a variable is not used, you can remove it and then Export & Test to make sure everything is fine (If the variable was actually used, the compilation will fail and report an error)
Great explanation. That is very helpful.
Thanks Dale.
 

jmotten

Member
@JayJayHux @smilehero65

Basically, Zero RAM variables are faster and cost fewer CPU cycles than Overflow RAM variables. For each variable, you can define its size (1 byte by default).
As for User Variables, this is NESmaker terminology. They are simply 1-byte Zero RAM variables for which you can specify a default value that is set during Initialization.
Object Variables are variables whose total size is defined by Total Max Objects. In practice, you can think of them as an array of variables, with one entry per object.

For each of them (Zero RAM + User Variables, Overflow RAM, and Object Variables), the total size must not exceed 255 bytes. If it does, data will be read from or written to memory addresses that are already used by other variables or by parts of the code.


Note: There are a LOT of Zero RAM and Overflow variables that are not actually used by the engine. You can safely remove dozens of them.
To find them, one method is to go through the variables one by one and search for them in the demo.txt file (located in the GameEngineData folder). Make sure they are not used anywhere other than their declaration and not just in comments.
If a variable is not used, you can remove it and then Export & Test to make sure everything is fine (If the variable was actually used, the compilation will fail and report an error)
I want to make sure I understand 100 percent. Between user variables, and zero page variables I can have 255? And then another 255 for Overflow and object variables? Or is it 255 for all 4 sets of variables? Thanks, I just want to make sure I understand it correctly.
 

JayJayHux

Member
I want to make sure I understand 100 percent. Between user variables, and zero page variables I can have 255? And then another 255 for Overflow and object variables? Or is it 255 for all 4 sets of variables? Thanks, I just want to make sure I understand it correctly.
Im sure someone else will give you a better answer for the rest but user variables and zero page RAM share 255. If you look at the bottom of zero page RAM in script settings you will see they are added together.
Skärmbild 2026-02-06 095752.png
 

JayJayHux

Member
@JayJayHux @smilehero65

Basically, Zero RAM variables are faster and cost fewer CPU cycles than Overflow RAM variables. For each variable, you can define its size (1 byte by default).
As for User Variables, this is NESmaker terminology. They are simply 1-byte Zero RAM variables for which you can specify a default value that is set during Initialization.
Object Variables are variables whose total size is defined by Total Max Objects. In practice, you can think of them as an array of variables, with one entry per object.

For each of them (Zero RAM + User Variables, Overflow RAM, and Object Variables), the total size must not exceed 255 bytes. If it does, data will be read from or written to memory addresses that are already used by other variables or by parts of the code.


Note: There are a LOT of Zero RAM and Overflow variables that are not actually used by the engine. You can safely remove dozens of them.
To find them, one method is to go through the variables one by one and search for them in the demo.txt file (located in the GameEngineData folder). Make sure they are not used anywhere other than their declaration and not just in comments.
If a variable is not used, you can remove it and then Export & Test to make sure everything is fine (If the variable was actually used, the compilation will fail and report an error)
I removed 29 unused variables from Zero Page RAM alone!!
Awesome tip Dale.
 

dale_coop

Moderator
Staff member
@jmotten
Im sure someone else will give you a better answer for the rest but user variables and zero page RAM share 255. If you look at the bottom of zero page RAM in script settings you will see they are added together.
View attachment 9333
Yes, you need to check the Object Variables, Zero Page RAM and Overflow RAM tabs in the Project Settings... for each of them, the total amount of bytes used is calculated.
Make sure each of them doesn't go over 255. And you're safe.

2026-02-06 08_49_34-Project Settings.png 2026-02-06 08_49_54-Project Settings.png 2026-02-06 08_50_12-Project Settings.png
 

JayJayHux

Member
Did you by chance document the variables you removed? I could really use that info! Thanks in advance! If not, no worries......
Damn, no sorry. I was thinking I should do that. The best I can offer is if you send screenshots of zero page ram and overflow I can point you in the right direktion with the ones I remember.
 

JayJayHux

Member
Did you by chance document the variables you removed? I could really use that info! Thanks in advance! If not, no worries......
I just thought of something. I have attached screenshots of my current zero page RAM variable list so whatever is missing compared to your list should be what your after. There might be some you cant remove though for example I have removed alot of path related variables because I have commented out alot of path code. So, im sure you know anyway but just incase if you accidentally remove an inuse variable you need to re include it and remember the exact spelling and byte size. I almost got myself into trouble with that.
Skärmbild 2026-02-08 073010.pngSkärmbild 2026-02-08 073025.pngSkärmbild 2026-02-08 073048.pngSkärmbild 2026-02-08 073102.png
 
Top Bottom