diff options
| author | gbc dev <gbc@localhost> | 2026-07-17 00:27:06 +0200 |
|---|---|---|
| committer | gbc dev <gbc@localhost> | 2026-07-17 00:27:06 +0200 |
| commit | 9a48db9bbc913171c62c86ff8649467474533e2d (patch) | |
| tree | af6d600dc188e43698d17693229265d367d89e48 /src/gb.h | |
| parent | main/gb: --keys button-script harness + serial_no_eof for OSK testing (diff) | |
| download | sl0pboy-9a48db9bbc913171c62c86ff8649467474533e2d.tar.gz sl0pboy-9a48db9bbc913171c62c86ff8649467474533e2d.tar.xz sl0pboy-9a48db9bbc913171c62c86ff8649467474533e2d.zip | |
gb: boot ROM (BIOS) support
Add optional boot ROM emulation. When a boot ROM image is loaded, gb_reset
starts execution at PC=0 with power-on register state instead of the
documented post-boot state; the ROM overlays low memory (with the CGB
0x0100-0x01FF header hole showing the cartridge through) until the game
writes 0xFF50 to hand off. gb_load_bootrom() accepts 256-byte (DMG) or
2304-byte (CGB) images.
Diffstat (limited to 'src/gb.h')
| -rw-r--r-- | src/gb.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -118,10 +118,20 @@ struct GB { int serial_out_fd; // if >=0, transmitted serial bytes written here (stdout) int serial_in_fd; // if >=0, received serial bytes read here (stdin), else 0xFF bool poweroff; // set by the $ED opcode: request a clean emulator exit + + // Boot ROM (BIOS). When boot_rom is non-NULL, gb_reset starts execution + // inside it (PC=0) with power-on register state; the ROM maps over low + // memory until the game writes 0xFF50 to hand control to the cartridge. + u8 *boot_rom; + int boot_rom_len; // 0x100 = DMG boot rom, 0x900 = CGB boot rom + bool boot_rom_active; // true while the boot ROM is still mapped in }; void gb_init(GB *gb); void gb_reset(GB *gb); +// Load a boot ROM (BIOS) image so the next gb_reset boots through it. Returns +// 0 on success. 256-byte images boot as DMG; 2304-byte images as CGB. +int gb_load_bootrom(GB *gb, const char *path); // Run one full CPU instruction (advancing all subsystems). Returns T-cycles. int gb_step(GB *gb); void gb_run_frame(GB *gb); |
