Starting to add CGB-C support
This commit is contained in:
parent
47a74cb6c3
commit
a7aabca618
15
Core/gb.c
15
Core/gb.c
@ -473,6 +473,21 @@ static void reset_ram(GB_gameboy_t *gb)
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case GB_MODEL_CGB_C:
|
||||
for (unsigned i = 0; i < gb->ram_size; i++) {
|
||||
if ((i & 0x808) == 0x800 || (i & 0x808) == 0x008) {
|
||||
gb->ram[i] = 0;
|
||||
}
|
||||
else {
|
||||
gb->ram[i] = (random() | random() | random() | random()) & 0xFF;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < sizeof(gb->extra_oam); i++) {
|
||||
gb->extra_oam[i] = (random() & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ typedef enum {
|
||||
// GB_MODEL_CGB_0 = 0x200,
|
||||
// GB_MODEL_CGB_A = 0x201,
|
||||
// GB_MODEL_CGB_B = 0x202,
|
||||
// GB_MODEL_CGB_C = 0x203,
|
||||
GB_MODEL_CGB_C = 0x203,
|
||||
// GB_MODEL_CGB_D = 0x204,
|
||||
GB_MODEL_CGB_E = 0x205,
|
||||
GB_MODEL_AGB = 0x206,
|
||||
@ -301,6 +301,7 @@ struct GB_gameboy_internal_s {
|
||||
/* Misc state */
|
||||
bool infrared_input;
|
||||
GB_printer_t printer;
|
||||
uint8_t extra_oam[0xff00 - 0xfea0];
|
||||
);
|
||||
|
||||
/* DMA and HDMA */
|
||||
|
@ -244,13 +244,21 @@ static uint8_t read_high_memory(GB_gameboy_t *gb, uint16_t addr)
|
||||
return gb->oam[addr & 0xFF];
|
||||
}
|
||||
|
||||
/* Unusable. CGB results are verified, but DMG results were tested on a SGB2 */
|
||||
/* Also, writes to this area are not emulated */
|
||||
if ((gb->io_registers[GB_IO_STAT] & 0x3) >= 2) { /* Seems to be disabled in Modes 2 and 3 */
|
||||
if (gb->oam_read_blocked) {
|
||||
return 0xFF;
|
||||
}
|
||||
if (GB_is_cgb(gb)) {
|
||||
return (addr & 0xF0) | ((addr >> 4) & 0xF);
|
||||
|
||||
switch (gb->model) {
|
||||
case GB_MODEL_CGB_E:
|
||||
case GB_MODEL_AGB:
|
||||
return (addr & 0xF0) | ((addr >> 4) & 0xF);
|
||||
|
||||
case GB_MODEL_CGB_C:
|
||||
addr &= ~0x18;
|
||||
return gb->extra_oam[addr - 0xfea0];
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@ -535,10 +543,17 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
|
||||
if (addr < 0xFEA0) {
|
||||
gb->oam[addr & 0xFF] = value;
|
||||
}
|
||||
switch (gb->model) {
|
||||
case GB_MODEL_CGB_C:
|
||||
addr &= ~0x18;
|
||||
gb->extra_oam[addr - 0xfea0] = value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Todo: This is writable, but glitchy, on CGB-B and CGB-D. */
|
||||
if (addr < 0xFEA0) {
|
||||
if (gb->accessed_oam_row == 0xa0) {
|
||||
for (unsigned i = 0; i < 8; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user