Before you read this article, I just want to clarify that this article is only for educational purposes. I don’t hack games to cheat, I do it cause I like it. and since NES games are not online multiplayer games, I can hack these and learn many more things. In this article, we will get to know how we can run 8-bit games in Linux and how you can hack it. By the way, you can play it online at https://www.8bit.com/.
If you have an understanding of the architecture of micro-controllers, you may already know that there are data buses and address buses that carry data and addresses accordingly in the NES hardware. For example, if you talk about 8-bit games, there are 8 buttons on the console. is there a logic behind it or it is just a coincidence? actually, there is a simple logic behind it. Try to think why do we call it an 8-bit game? well, the buses can only accept 8 bits. there are exactly 8 lines in buses to travel data from one component to another. and here that one component is your console and another one is CPU or ALU (something I am not sure about.)
It is quite hard to learn these architectures and it is not even necessary in case you aren’t totally a nerd about system architecture. I can provide you with this PDF which explains the working of super NES. you can download it from here.
There is an emulator for NES games which is available for Windows as well as for Linux. you can visit its GitHub repo since it is an open-source project. If you are wondering what is an emulator, it is what you have used in order to play PSP games on your android or PC. You guys must have heard of PPSSPP. By the way, it is also an open-source project. If you are using KaliLinux, you can install it with this command:
apt install fceux
And you can always build it for your system using its source files. Its GitHub page provides a deb package file. I don’t think I will need to explain fceux installation in windows. Now we need some ROMs to play in fceux. you can find NES games here or you can find more on Google.
For demonstration purposes, I am playing the MegaMan2 (quite famous) game on NES. Download the zip file, unzip it, open fceux and you can load the ROM from the file system (file>OPEN ROM>*select*).
Its default keys are Arrow keys and S,D,F, ENTER. it feels so nostalgic to hear those 8-bit sounds again. It reminds me of my summer vacations. Anyway, give it a try and try to place without cheat first. after that, we will move on to hacking.
There are a lot of options there in the top menu of fceux. first comes the debugger. it shows all the instructions required to run the game.
you can edit those only if you know what that instruction is doing. for example, if you have found that at the address XXXX the instruction is jumping if the character dies, maybe you can make it not jump there and your character may never die. but the question how will you find that address? well, for that we have a tool RAM Search (tools>RAm Search) built within fceux.
It is really easy to use. on one side, you can see the addresses and on another side the values. there are two more sections previous and Changes. considering you are playing the MegaMan2 on fceux, you will see that values are changing. well, that’s what is supposed to happen after you press a button, cause you are making your character jump and in order to do that you will have to change the value (for example 0 -> 1) at a specific memory address. the previous index shows the previous values at that memory address and the changes index shows the count of changes at that memory address.
For example, if you want to find out where the health of the player is stored in memory you will filter out results by saying get me all those memory addresses at which the values are equal to previous values because you haven’t gotten single damage. And after getting damaged, you are looking for values which are less than their previous values. this is similar to CheatEngine in Windows. there are more options to filter your memory address. Data size is to select the size of the value. and Data type is to find signed(negative&positive), unsigned(positive) and hex values in the memory addresses.
you can configure the fceux according to you. you use a console with it. and even if you are using a keyboard to play, you can change the keys.
One more thing, there is an Insert Coin option, which really works, cause I have tried it myself.