Randomize object palettes. Slightly more accurate emulation of FF4C.

This commit is contained in:
Lior Halphon 2018-07-20 23:23:47 +03:00
parent 538038e49c
commit b7426f93c0
2 changed files with 19 additions and 1 deletions

View File

@ -344,7 +344,13 @@ void GB_set_rgb_encode_callback(GB_gameboy_t *gb, GB_rgb_encode_callback_t callb
gb->sprite_palettes_rgb[7] = gb->sprite_palettes_rgb[3] = gb->background_palettes_rgb[3] = gb->sprite_palettes_rgb[7] = gb->sprite_palettes_rgb[3] = gb->background_palettes_rgb[3] =
callback(gb, 0, 0, 0); callback(gb, 0, 0, 0);
} }
gb->rgb_encode_callback = callback; gb->rgb_encode_callback = callback;
for (unsigned i = 0; i < 32; i++) {
GB_palette_changed(gb, true, i * 2);
GB_palette_changed(gb, false, i * 2);
}
} }
void GB_set_infrared_callback(GB_gameboy_t *gb, GB_infrared_callback_t callback) void GB_set_infrared_callback(GB_gameboy_t *gb, GB_infrared_callback_t callback)
@ -489,6 +495,17 @@ static void reset_ram(GB_gameboy_t *gb)
for (unsigned i = 0; i < sizeof(gb->extra_oam); i++) { for (unsigned i = 0; i < sizeof(gb->extra_oam); i++) {
gb->extra_oam[i] = (random() & 0xFF); gb->extra_oam[i] = (random() & 0xFF);
} }
if (GB_is_cgb(gb)) {
for (unsigned i = 0; i < 64; i++) {
gb->background_palettes_data[i] = random() & 0xFF; /* Doesn't really matter as the boot ROM overrides it anyway*/
gb->sprite_palettes_data[i] = random() & 0xFF;
}
for (unsigned i = 0; i < 32; i++) {
GB_palette_changed(gb, true, i * 2);
GB_palette_changed(gb, false, i * 2);
}
}
} }
void GB_reset(GB_gameboy_t *gb) void GB_reset(GB_gameboy_t *gb)

View File

@ -734,8 +734,9 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
return; return;
case GB_IO_DMG_EMULATION: case GB_IO_DMG_EMULATION:
GB_log(gb, "4c = %x\n", value);
if (GB_is_cgb(gb) && !gb->boot_rom_finished) { if (GB_is_cgb(gb) && !gb->boot_rom_finished) {
gb->cgb_mode = value != 4; /* The real "contents" of this register aren't quite known yet. */ gb->cgb_mode = !(value & 0xC); /* The real "contents" of this register aren't quite known yet. */
} }
return; return;