The draw opcode is what makes the Chip8 tick. As I recall, it uses one register to point into memory at a byte, and some other registers to represent an x,y coordinate onscreen. To perform the draw, you *xor* the screen at that location for every 1 bit in the byte referenced. In other words, if the bit pattern for the byte you're drawing is:
10101010
then you're going to change the value of 4 pixels. Remember, this is an LCD screen, you get on or off only for your pixels. Importantly, and most game logic takes advantage of this, that opcode should also store a flag representing whether or not it "hit" something while it was drawing. In other words, if when inverting your pixels for this opcode any pixel turns *off*, it needs to set a flag. Games will often use this feature to "test" an area of the screen. For example, in a pong game, I could increment the ball position by 1 in both directions each time, and then use this flag to tell me if I hit a wall or a paddle. It's basic collision detection usually, although how its handled is largely up to the game logic.
I can't compile for mac or I would take a look at your code, but I wrote a similar project like this myself. I never got it finished (I was having some weird opcode handling bugs) but I got it working well enough that a bunch of the demo games would play just fine. I should actually try doing it again now that I think about it.
Good luck, and may the force be with you. If nothing else, this will at least teach you that emulation is not to be taken lightly. ^_^ Chip8 is as simple as it gets.
-gamefreak
10101010
then you're going to change the value of 4 pixels. Remember, this is an LCD screen, you get on or off only for your pixels. Importantly, and most game logic takes advantage of this, that opcode should also store a flag representing whether or not it "hit" something while it was drawing. In other words, if when inverting your pixels for this opcode any pixel turns *off*, it needs to set a flag. Games will often use this feature to "test" an area of the screen. For example, in a pong game, I could increment the ball position by 1 in both directions each time, and then use this flag to tell me if I hit a wall or a paddle. It's basic collision detection usually, although how its handled is largely up to the game logic.
I can't compile for mac or I would take a look at your code, but I wrote a similar project like this myself. I never got it finished (I was having some weird opcode handling bugs) but I got it working well enough that a bunch of the demo games would play just fine. I should actually try doing it again now that I think about it.
Good luck, and may the force be with you. If nothing else, this will at least teach you that emulation is not to be taken lightly. ^_^ Chip8 is as simple as it gets.
-gamefreak
The only good zombie is a live zombie.
