Under the Microscope: Three Dirty Dwarves
32bits.substack.com
32bits.substack.com
However, the Saturn surprisingly has really good tools for reverse engineering. There is a very good save state loader for Ghidra, and the Mednafen debugger allows for on-the-fly memory editing.
With these methods I also found a cheat code for Clockwork Knight 2 that grants access to the entire first game! Somehow that was secret for decades.
I’m thinking things like the code itself is interpreted as a memory address/jump and most do nothing or crash …
Better might be to use a Key Derivation Function (e.g. bcrypt) and treat cheat codes like passwords. This wouldn't obfuscate what the set of available cheat codes do, but finding the actual code would be hard if they are sufficiently long and random.
Code is AES-GCM encrypted, and the encrypted blob is stored on the web server. The "cheat code" to activate the Easter egg is the decryption key (the passphrase used with a key derivation function, to be precise). Entering the cheat code triggers an attempt to decrypt the blob. If the password is correct and the code decrypts successfully, the decrypted code is run with eval. If the passphrase is incorrect, nothing happens.
Thus, nobody inspecting the code can know what the cheat code is or what it does without breaking the crypto. But someone who knows it can enter it and trigger the magical cheat behavior.
Note that it's important to use authenticated encryption so that the user's browser doesn't try to execute garbled text when decryption fails.
To their credit, I couldn't figure it out!