Skip to main content
1 of 3
Basic
  • 1.2k
  • 9
  • 25

What exactly do you want to replicate from a Game Genie code?

The format of the original can be found in the docs here, but fundamentally they identified a part of the memory to change and the type of change to make.

Most commonly, that was "Fix the value in memory to always be X", but other operations were supported (like XOR-ing the value found in memory).

Whilst that doesn't map 1:1 to javascript, the core concepts are still valid.

At its most primitive, your "JSGenie" code could be playerLives:fix:100

Then on every frame, run through all the codes in use, extract the variable names and set the variables as appropriate.

If you want something a bit more game-genie-feeling with letters/numbers that aren't so human-readable, you've got a few different ways you can implement that.

Fundamentally, you'll want some way of mapping from "short alphanumeric code" (let's call it a key) to variable name.

Then your genie code becomes something like a3c1:fix:100. Of course, we can replace fix with a value to indicate the operation (let's sat "fix" is 0)... a3c1:0:100

There's really no limit to how you can format/pack the data. If you don't want to use colons, make the fields fixed-width, or bit pack them, or ... (you could also use hexadecimal (or any subsitition) for the value itself, so it's not obviously 100)

It depends entirely on how you want the code to look/work.

So ... How do we get the keys for the variable names?

Again, it depends on how you want it to work.

At its simplest, you could have a hand-curated list of variables and their associated keys.

This is easy to control, but somewhat limited and a bit error-prone.

At the other end of the spectrum, you can get Javascript to tell you all currently defined variables, then hash their names in some way to get a key.

The benefit of this approach is that it's self-maintaining and the codes can change literally any value in the runtime.

The downside is that they can change literally ANY value in the runtime.

(Much like the original Game Genie).

Basic
  • 1.2k
  • 9
  • 25