This post is a bit out of the ordinary, because although it touches upon assembly and NESmaker games, it doesn’t really fit in any category. But I thought it was too much fun to leave out of the blog! In the following post, you’ll learn how to use the Game Genie in your NESmaker game. Not only we’ll find codes that work for your game, but you’ll even be able to add custom codes and handle those in your game in any way you’d like!
What’s a Game Genie?
On the off-chance you have not heard of this device yet: the Game Genie is a video game cheat cartridge, designed by Codemasters and sold by Galoob. To use it, you insert the game you want to play in the Game Genie, and then insert the two in the NES console. The Game Genie then allows the user to input up to four cheat codes, which manipulate and modify the inner workings of the game. This allows, for example, the player to get unlimited lives, become invincible, start the game at a different level or modify the speed of enemies. Depending on which code(s) you choose, this can make the game easier or harder.
How does a Game Genie code work?
I won’t deep dive into this – here’s a site that explains it in full technical detail – but basically a Game Genie code manipulates the value of an address in CPU memory. There’s two types of Game Genie codes:
- Six-character codes, which look up an address and hardcode its value to a byte of choice, and
- Eight-character codes, which do the same, but only if said address initially had a certain byte value.
A six-character code may be used to give the player unlimited lives, for example. Let’s say the player’s number of lives is stored in zero page address $00AB
. You can use a Game Genie code to force this value to be anything you want, for example #05
. This way the player will always have five lives: whether he picks up a 1-up or loses a life, the actual number of lives will not change because the Game Genie has the value basically locked. Note: the Game Genie code to give address $00AB
a forced value of #05
, is IEZELA
. This site will convert values to codes and vice versa.
An example of an eight-character code may be to change the number of lines you need to clear in B-type Tetris. The number of lines needed is stored in RAM (addres $075C
). If the value of this address is equal to #$25
, we’ll have the Game Genie overwrite that with a value of #$10
. The extra check an eight-character code does over a six-character code, is needed in this case because otherwise the number of lines cannot be decremented (since the Game Genie forces it back to 10 every time), so you won’t be able to ever clear the game. The code that does this, is APSEGYIZ
.
How can I find Game Genie codes for my NESmaker game?
The easiest way to test and create Game Genie codes for your own NESmaker games, is by looking into the generated demo.txt
file to see which address is used for which value. For example, you can look for myHealth and see which address that variable belongs to. You may find something like this:
000CA myHealth .dsb 1
This means that myHealth is stored in address $00CA
(addresses are 16-bit in the NES so you can ignore the first zero). Let’s say you want to force this value to be five, so your player is basically invincible. Visit this site, enter 00CA
for the address and 5
for the value, and voila: there’s your Game Genie code (IEGEZA
).
More fun with Game Genie codes
Now that you know how to find a Game Genie code, we can have some more fun with this! For this example, we’ll take a Game Genie code and implement that in our game, so when someone enters the code, the game warps to a secret screen. First, we’ll think of a fun code which we could use. Here is a list of human-readable Game Genie codes which manipulate ROM data in the $8000-$FFF9 address range. Let’s go with SKUNKY for now.
SKUNKY : Set CPU address $ffbc to a value of #$c5
To add this Game Genie code to our game, we need to:
- make sure the value at address $ffbc is not #$c5 by default,
- check if $ffbc is equal to #$c5, and
- if so, do something fun with it.
The first step is not too hard. Open the file BASE_4_5\System\vectors.asm
and at the beginning of that file, add:
.org $ffbc .db $00
This writes a value of zero to $ffbc
, therefore ensuring that it’s not #$c5
. Please note that this would overwrite whatever was written at $ffbc
before, so if this memory address has executable assembly code, this will corrupt and break your game! This is something you’ll need to test and adjust, either by changing your code so that address $ffbc
does not contain executable code, or by using a different Game Genie code that doesn’t use this address.
For steps two and three, open up the script where you want to check the value. This could be your warp tile, a script that handles your “start game” script, the script that warps to the game over screen, wherever you want to have the secret code do something. This script will check the value of the address, and if it indicates that the Game Genie code is active, it warps to an arbitrary secret screen:
;; Check if GG code "SKUNKY" is active LDA $ffbc CMP #$c5 BNE +notGGcode +ggCodeActive: ;; Game Genie code active - do whatever you want to ;; do when the secret is activated. In this example, ;; we'll warp to a secret screen (0,0 in the ;; underworld). WarpToScreen #1, #$00, #1 JMP +doneGGcode +notGGcode: ;; Game Genie code not active. Do stuff here that ;; shouldn't be done if the GG code is active, ;; for example warp to the actual game over screen, ;; which is in (0,2) of the underworld. WarpToScreen #1, #$02, #1 +doneGGcode: ;; Here we continue script execution, whether the ;; GG code is active or not.
Now you’ve successfully added some kind of “hook” that you can switch on with the Game Genie code!