Code Porting

I haven’t gotten as much work done on this project lately due to a variety of reasons, but one of the bigger ones was a realization that I need to change how I wanted to run the code. My initial plan was to have the program run on a computer and communicate with an Arduino to read/write from the cartridges. After having some problems with the communication itself and some thinking, I decided I would rather have the program run solely on the Arduino and have it be a standalone device.

This means I had to change the code from being in C# to being in C++. The languages are similar, ish, but still was a massive overhaul. This put a damper on how much I actually wanted to work on this and I put it off for quite a while. When I was working on it, none of the progress was really that interesting for an update here. But yesterday, I finally got the code to compile for Arduino C++! Now, for a bit of background before this image, one of my major concerns for putting the entire program on the Arduino itself was how much space I would have for program code. I am using an Arduino Leonardo, which has 32k bytes for program space. Now, that isn’t a ton, but it isn’t nothing. But I am pretty inexperienced with writing code for Arduinos, so that doesn’t mean much to me either.

Unfortunately, until I get the code to compile, I will have no idea how large it will be and how much space will be left on the Arduino. Thankfully, when I got to compile, I saw it would fit! But… just barely.

99% of the program space is being used… not much room for error

Another concern was how much RAM I would have to work with. After seeing I would only have 955 bytes to work with, I started getting even more worried and started doing some math. If a generation 3 Pokemon uses 100 bytes in the games themselves to be stored, and an entire box loaded at once for transfer would take 3k bytes. That is a little bit more than 955. So now my next plan is to rework the process so that it transfers one Pokemon at a time rather than loading the entire box. Operating in this fashion should be much more memory efficient with minimal change on execution time.

I also need to make sure this new code actually operates as intended as well. Hopefully the form it is in currently works, or is very close to functional, and any tweaks I need to make cut down on overall program size rather than increasing it. That may end up still being an issue as the program currently only supports English games as well, and I am expecting adding more language support will also increase program size.

Getting the code to compile now though is likely more beneficial for my desire to work on it than negative, so expect more updates soon!

Leave a Reply

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