What is it?

This project is an exploration of the concept of cartridge swapping on the Game Boy. This is achieved by copying a program into RAM, and then telling the player to swap the cartridge. Once this is done, the program in RAM is run. The program can now interact with the new cartridge.
For this project, I wanted to see what I could do with the concept of cartridge swapping with the Game Boy. Aside from a flashcart, the only cartridge I owned was a Pokemon Red repro cart. So, I decided that I would attempt the following: launching into the game from the ram program, editing the save so that the player name changed, and using the games graphics functions to display a Pokemon.

Who did what?

The font used
The disassembly used
Everything else in the project was done by myself

When was it worked on?

Work started on the project around July of 2020 and finished at the start of September

What are the controls?

Up and down move the arrow on the menu, and A is used to select an option. The bindings for these inputs are set by the emulator.

What went right/wrong during development?

One of the things that went right in this project was the readability of the code. With my last project for the Game Boy, as I was still new to writing assembly code, the code isn't particularly readable in some areas. However, since then I have improved a lot. As a result, the code was significantly more readable this time. Additionally, code was split between files much better than last time.
Another thing that went right was fixing issues as they arose. During this project, I ran into a strange problem with launching the game from my program. When I ran it in an emulator, it all worked fine. However, when I tested it with my repro cart, the save data wouldn't load correctly. After asking around about this, I found out that this was because repro carts use flash storage and they patch the game so that it writes/loads to and from flash. To confirm this (and to find where in the ROM this was stored), I wrote a simple memory viewer, looked at 0x0100 (the entrypoint for Game Boy programs) and converted the bytes into instructions. Normally, there would be a nop here followed by a jump to 0x0150. However, instead there was a jump to some code which loaded the save from flash, followed by a jump to 0x0150. After seeing how the repro cart handled this, I was able to update my program to work for both original cartridges and for repro cartridges.
One of the things that went wrong in this project was functions. In a normal program, you would define the functions you want to use, and then you would call them. However, that doesn't work here, as once the cartridge is swapped, the program no longer has access to those functions. The solution I came up with was to simply use macros, that way a function definition would be copied into the code whenever it was used. While this did work, it it a messy solution.

Where can I access the source code?

The source code can be found on my github account. Alternatively, you can click here to go straight to the github page. Additionally, if you want to read the writeup I did about this, you can click here.

Screenshots