Up down up down up down

I was watching Retro Game Mechanics Explained. It was a video about the Game Genie and how it’s codes worked. It was interesting.

I have a project I’ve been working on, at least in concept. It’s a computer based around the 65816 processor (I’m calling the computer the Neutron), and one of the things it will have is a cartridge port. These cartridges can be up to half a megabyte large without the need for banking hardware. So, I was thinking about how a Game Genie-like device could work for that project.

The 8-letter code entered (yes it had to be 8) would encode 1) a 24-bit address and 2) an 8 bit value. For the 24-bit address, the first 8 bits would tell which 64K bank was going to be accessed. Cartridge space runs from bank F4 to bank FB, so the first two letters would have to encode the hex digits F and 4-B.

As for the letters? It’s kind of simple. Here’s what I came up with:

  • A = 0000
  • Z = 0001
  • B = 0010
  • Y = 0011
  • C = 0100
  • X = 0101
  • D = 0110
  • W = 0111
  • E = 1000
  • V = 1001
  • F = 1010
  • U = 1011
  • G = 1100
  • T = 1101
  • H = 1110
  • S = 1111

Basically, the even numbers are assigned to A through H, while the odd numbers are assigned to Z through S. Simple!

Now for how those letters (and their assigned bits) are mapped to the address and value. For each set of 4 bits, we’ll say the first two will be represented by uppercase letters and the last two will be represented by lowercase letters. The 8 letters will be labeled A through H.

To map each letter’s bits to the address and value, take each pair of letters, say A and B, with bits AAaa and BBbb. The upper case bits (AA and BB) are unchanged. If the mapped address and value are below the bits for the letters, we’ll say that AA and BB go straight down. For the lower case bits, swap the pairs. You’ll end up with AAbb and BBaa. Do this for all other pairs of letters, with the addition that with every other pair of letters, invert the lowercase bits. (I.e CCcc and DDdd become CCdd and DDcc, with italics indicating an inverse bit). Then, take the pairs of sets of four bits (called nibbles), and going from the outside in, swap the first nibbles. So, if you start out with the bits AAaa BBbb CCcc DDdd EEee FFff GGgg HHhh, you will end with the bits GGhh BBaa EEff DDcc CCdd FFee AAbb HHgg. Using those bits, the first six nibbles make up the 24-bit memory address and the final two nibbles make up the 8-bit value that should be returned when that address is accessed.


Ashton Snapp

20-something year old autistic nerd. Interested in tech, gaming, and languages (including constructed languages). Values privacy and respect. Believes in solving things diplomatically when possible. Favorite programming language is Rust, but I also know TypeScript, Python, Lua, Java, and am interested in Nim, Zig, Haskell, and really any programming language. Currently working on the Rouge programming language (https://github.com/AshtonSnapp/rouge) and the Homebrew Assembler (https://github.com/AshtonSnapp/hasm)

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: