NESmaker is a nifty piece of software, enabling beginning developers to create a game for the NES. It’s not without its culprits though. For example, some of the UI elements are no longer supported by the accompanying Assembly scripts. Luckily, there’s a sizable community helping each other out getting the most out of NESmaker. The Enhance! series on this website will help you using NESmaker to its full potential, by re-enabling deprecated scripts, fixing bugs and optimizing core code. This article explains how to enable the user screen bytes in the NESmaker UI.
The original post to this enhancement can be found on the NESmaker forum, by the brilliant mind that is Chronicler of Legends. Go over there and show him and his NES game Nix: The Paradox Relic some love! I found myself coming back to this post multiple times and I think it’s an essential enhancement for any NESmaker developer.
In the NESmaker UI, on the Screen Info for any overworld screen, you’ll find eight input fields called user screen bytes. These fields can hold eight bits of additional data per screen in your game. Unfortunately, upon initial installation of NESmaker, you can’t use these bytes, as they are not referenced in the scripts. Luckily, Chronicler of Legends has found a way to enable usage of user screen bytes, in two relatively easy steps.
1. Add user variables
First, you’ll need to add the variables through the UI, so NESmaker knows how to access the user screen bytes. To do this, open up your Project Settings, click the User Variables tab and then click the Add button. You can name these whatever you like, although I’d suggest you give them names which represent what they are:
userScreenByte0 userScreenByte1 userScreenByte2 userScreenByte3 userScreenByte4 userScreenByte5 userScreenByte6 userScreenByte7
Now the UI is ready to use the new variables. All we have to do now, is actually load them in at the correct positions in assembly code.
2. Modify the code
Now it’s time to dive into the code. You’ll have to modify the code for a subroutine called doLoadScreenData. As always when modifying existing code, make sure you either backup the original script file, or create a copy and refer to the new copy in your code; whichever you’re more comfortable with.
The file you’re looking for is the following file in your NESmaker installation folder:
GameEngineData\Routines\BASE_4_5\Game\Subroutines\doLoadScreenData.asm
Find the lines of code that say the following (it should be on line number 167 if you haven’t modified the file before):
;; 131
LDY #182
LDA (collisionPointer),y
STA ScreenFlags01
Right underneath these lines, paste the following code snippet:
;; Load the userScreenBytes
;; userScreenByte0
LDY #187
LDA (collisionPointer),y
STA userScreenByte0
INY
LDA (collisionPointer),y
STA userScreenByte1
INY
LDA (collisionPointer),y
STA userScreenByte2
INY
LDA (collisionPointer),y
STA userScreenByte3
INY
LDA (collisionPointer),y
STA userScreenByte4
INY
LDA (collisionPointer),y
STA userScreenByte5
INY
LDA (collisionPointer),y
STA userScreenByte6
INY
LDA (collisionPointer),y
STA userScreenByte7
Save the script and you’re all set! You can now use these variables in your game. All you have to do now, is think of a way how to use these, and add them in your custom game code! Taking an example from my game Mooooo!, I use userScreenByte0 to keep track of how many moves the player has left. Whenever the player takes a step, the following code is being executed:
;; Subtract one from the number of moves left LDA userScreenByte0 SEC SBC #1 ;; Check if there are moves left BNE + JMP +noMovesLeft +
But you can use these bytes in whichever way is appropriate for your game. Now go forth and create something awesome, with extra bytes!