Live data from Hacker News

Show HN: Simple Gameboy Emulator

github.com

1–10 of 24 posts

Re: Show HN: Simple Gameboy Emulator

#5
post #2

I know nothing about emulators, so it would be nice if the README provided instructions for how to build and run the emulator. Here is some inspiration: https://github.com/dolphin-emu/dolphin

You're right, I should've included that from the get-go. Included one now, hope it helps :)

Re: Show HN: Simple Gameboy Emulator

#6
Making a Gameboy emulator was one of my favorite and most instructive personal projects.

It's worth noting that there was actual extra hardware built into the carts, so you need to implement certain features like extra RAM based on the cart ID in the ROM file.

Re: Show HN: Simple Gameboy Emulator

#9
post #6

Making a Gameboy emulator was one of my favorite and most instructive personal projects. It's worth noting that there was actual extra hardware built into the carts, so you need to implement certain features like extra RAM based on the cart ID in the ROM file.

Not the cart ID, you're looking in the cart header at byte 0147 for the actual hardware (MBC1, MBC2, MMM01, etc) functionality in conjunction with bytes 0148 (ROM size) and 0149 (RAM size) for specific bank sizing/mapping.

Re: Show HN: Simple Gameboy Emulator

#10

Great! The CPU.c code is quite instructive since I'm writing a toy VM in my free time. Starring this :)

They're using a relatively simple opcode map, but most instructions are logically redundant as can be seen here:

http://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html

The next step in emudev, with most compiled/systems languages at least, would be to create macros (such as OP_LD or OP_ADD) that generates static instructions at compilation. Another, cleanish method, in C is to generate a 256-length function pointer (void*) based static array and map those generated functions to that, to make the dispatch step simpler. Small trade off, performance-wise, but rarely matters for 8-bit CPU's (where you would usually use an opcode table over an instruction decoder).

Post reply on HN