Emulator Complete!
I am proud to write that I have finished my emulator and it is now fully public on GitHub and has a downloadable binary for MacOS.
Since the last devlog I have:
- Fixed various bugs with opcodes not working correctly
- Added memory out of bonds read/write protection using a genius snippet of code with the help of someone from the EmuDev discord!
- Fixed all quirks and made it so that they can be toggled
- Added a setting menu that can be toggled with backtick that uses Dear ImGui and allows you to change quirks, ipf, and the colours!
Out of all of this, the biggest challenge (although it was minor, it was very annoying) was figuring out a way to map the colour picker in Dear ImGui to the actual colours drawn in SDL3. The frame buffer expected a 32 bit integer representing the RGBA hex code of the colour, while ImGui wanted a float array with each colour being from 0.0-1.0. I tried to use methods like ImGui::ColorConvertFloat4ToU32, but it ended up all using types native to ImGui that SDL does not support, so I ended up using a standard float array and then writing a simple function to multiply the values by 255 and shift the bits to turn it in to the value SDL expects. Here’s the code: (I know I could’ve only had the bit shifting logic once but why have DRY code when it can be wet 🤣)
int Config::getColor(bool fg){
if(fg){
return static_cast<int>(fgColor[0] * 255) << 24 | static_cast<int>(fgColor[1] * 255) << 16 | static_cast<int>(fgColor[2] * 255) << 8 | 0xFF;
}
return static_cast<int>(bgColor[0] * 255) << 24 | static_cast<int>(bgColor[1] * 255) << 16 | static_cast<int>(bgColor[2] * 255) << 8 | 0xFF;
}
Attached is a picture of the emulator running a ROM that is essentially a backport of the chrome dino game. This was a really fun project and a perfect stepping stone to eventually making a Gameboy emulator!!
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.