Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For the CHIP-8 emulator in particular, this is a good starting point:

http://www.multigesture.net/articles/how-to-write-an-emulato...

Or you could just read the documentation directly here:

http://devernay.free.fr/hacks/chip8/C8TECH10.HTM

CHIP8 was itself an interpreted bit of hardware, so it's reeeeally loose with things like timing requirements. Just run a couple dozen instructions per "frame" in your game loop, then draw the screen somewhere, and you'll come close to playability for most of the sample games if your interpreter is bug free. It's the kind of project that with enough motivation you could complete in a week or so, which is why it's usually recommended for a first emulator project.

Once you have CHIP8 working somewhat, think about how you had to structure your code to make that work. Wouldn't the z80 CPU in a gameboy, or the 6502 CPU in an NES, also have opcodes just like the CHIP8 interpreter did? Surely you wrote a function for each CHIP8 opcode, so why not write a function for each z80 opcode, figure out how to read the gameboy's cartridge header, and see if your new CPU can run some instructions from Tetris? Once you get the code writing to VRAM, can you draw the tiles? What about the background? Build the emulator up piece by piece, and suddenly your game library is just chok full of little puzzle boxes, waiting to be tackled one by one.

It's very difficult to do all of this accurately, but don't focus on that right away. Just get it working, and learn about the system as you go.



It's really pervasive that the CPU in the Gameboy is a Z80. It's not. It's got a few instructions from the Z80 but it's closer to the 8080 overall.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: