After getting things functioning well in the browser, I wanted to move onto the actual emulator bit of the project.
Firstly, I looked at a bunch of examples and info, mostly compiled from gbdev.io. At first, I followed both the development blog of Cinoop and the guide DMG-01.
I used these guides to first write the register struct, which is basically just a struct of bytes (in char form as I’m using C), as well as the flags register, which I took inspiration from DMG-01 by making it primarily a struct of 4 bools rather than a binary value, for easier setting. I also wrote functions for converting this into binary though so that I didn’t lose compatibility.
Next, I used Decoding Gameboy Z80 Opcodes to write an algorithmic way to decide which instruction correlates to an opcode, instead of a large switch case (although admittedly it does have a lot of nested switch cases).
Finally, I added in the “alu” table instructions as the first few instructions, which also happened to be quite simple as they were basically just addition, subtraction and some bitwise operations.
Next, I plan to fill in the remaining instructions, add them all to the algorithm and get started on the actual control flow for the CPU
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.