Improved accuracy of mid-line SCX writes
This commit is contained in:
parent
d4999fbbdb
commit
c05c3c2abd
@ -632,7 +632,7 @@ static void advance_fetcher_state_machine(GB_gameboy_t *gb)
|
|||||||
GB_FETCHER_SLEEP,
|
GB_FETCHER_SLEEP,
|
||||||
} fetcher_step_t;
|
} fetcher_step_t;
|
||||||
|
|
||||||
fetcher_step_t fetcher_state_machine [8] = {
|
static const fetcher_step_t fetcher_state_machine [8] = {
|
||||||
GB_FETCHER_SLEEP,
|
GB_FETCHER_SLEEP,
|
||||||
GB_FETCHER_GET_TILE,
|
GB_FETCHER_GET_TILE,
|
||||||
GB_FETCHER_SLEEP,
|
GB_FETCHER_SLEEP,
|
||||||
@ -666,7 +666,10 @@ static void advance_fetcher_state_machine(GB_gameboy_t *gb)
|
|||||||
x = gb->window_tile_x;
|
x = gb->window_tile_x;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
x = ((gb->io_registers[GB_IO_SCX] / 8) + gb->fetcher_x) & 0x1F;
|
/* TODO: There is some CGB timing error around here.
|
||||||
|
Adjusting SCX by 7 or less shouldn't have an effect on a CGB,
|
||||||
|
but SameBoy is affected by a change of both 7 and 6 (but not less). */
|
||||||
|
x = ((gb->io_registers[GB_IO_SCX] + gb->position_in_line + 8) / 8) & 0x1F;
|
||||||
}
|
}
|
||||||
if (gb->model > GB_MODEL_CGB_C) {
|
if (gb->model > GB_MODEL_CGB_C) {
|
||||||
/* This value is cached on the CGB-D and newer, so it cannot be used to mix tiles together */
|
/* This value is cached on the CGB-D and newer, so it cannot be used to mix tiles together */
|
||||||
@ -777,12 +780,6 @@ static void advance_fetcher_state_machine(GB_gameboy_t *gb)
|
|||||||
|
|
||||||
// fallthrough
|
// fallthrough
|
||||||
case GB_FETCHER_PUSH: {
|
case GB_FETCHER_PUSH: {
|
||||||
if (gb->fetcher_state == 6) {
|
|
||||||
/* The background map index increase at this specific point. If this state is not reached,
|
|
||||||
it will simply not increase. */
|
|
||||||
gb->fetcher_x++;
|
|
||||||
gb->fetcher_x &= 0x1f;
|
|
||||||
}
|
|
||||||
if (gb->fetcher_state < 7) {
|
if (gb->fetcher_state < 7) {
|
||||||
gb->fetcher_state++;
|
gb->fetcher_state++;
|
||||||
}
|
}
|
||||||
@ -1049,7 +1046,6 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
|
|||||||
gb->position_in_line = - (gb->io_registers[GB_IO_SCX] & 7) - 8;
|
gb->position_in_line = - (gb->io_registers[GB_IO_SCX] & 7) - 8;
|
||||||
gb->lcd_x = 0;
|
gb->lcd_x = 0;
|
||||||
|
|
||||||
gb->fetcher_x = 0;
|
|
||||||
gb->extra_penalty_for_sprite_at_0 = (gb->io_registers[GB_IO_SCX] & 7);
|
gb->extra_penalty_for_sprite_at_0 = (gb->io_registers[GB_IO_SCX] & 7);
|
||||||
|
|
||||||
|
|
||||||
|
@ -581,7 +581,7 @@ struct GB_gameboy_internal_s {
|
|||||||
uint8_t current_line;
|
uint8_t current_line;
|
||||||
uint16_t ly_for_comparison;
|
uint16_t ly_for_comparison;
|
||||||
GB_fifo_t bg_fifo, oam_fifo;
|
GB_fifo_t bg_fifo, oam_fifo;
|
||||||
uint8_t fetcher_x;
|
GB_PADDING(uint8_t, fetcher_x);
|
||||||
uint8_t fetcher_y;
|
uint8_t fetcher_y;
|
||||||
uint16_t cycles_for_line;
|
uint16_t cycles_for_line;
|
||||||
uint8_t current_tile;
|
uint8_t current_tile;
|
||||||
|
@ -348,7 +348,6 @@ static void sanitize_state(GB_gameboy_t *gb)
|
|||||||
gb->oam_fifo.read_end &= 0xF;
|
gb->oam_fifo.read_end &= 0xF;
|
||||||
gb->oam_fifo.write_end &= 0xF;
|
gb->oam_fifo.write_end &= 0xF;
|
||||||
gb->object_low_line_address &= gb->vram_size & ~1;
|
gb->object_low_line_address &= gb->vram_size & ~1;
|
||||||
gb->fetcher_x &= 0x1f;
|
|
||||||
if (gb->lcd_x > gb->position_in_line) {
|
if (gb->lcd_x > gb->position_in_line) {
|
||||||
gb->lcd_x = gb->position_in_line;
|
gb->lcd_x = gb->position_in_line;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,8 @@ static const GB_conflict_t cgb_conflict_map[0x80] = {
|
|||||||
[GB_IO_OBP0] = GB_CONFLICT_PALETTE_CGB,
|
[GB_IO_OBP0] = GB_CONFLICT_PALETTE_CGB,
|
||||||
[GB_IO_OBP1] = GB_CONFLICT_PALETTE_CGB,
|
[GB_IO_OBP1] = GB_CONFLICT_PALETTE_CGB,
|
||||||
[GB_IO_NR10] = GB_CONFLICT_NR10,
|
[GB_IO_NR10] = GB_CONFLICT_NR10,
|
||||||
|
[GB_IO_SCX] = GB_CONFLICT_WRITE_CPU, // TODO: Similar to BGP, there's some time travelling involved
|
||||||
|
|
||||||
/* Todo: most values not verified, and probably differ between revisions */
|
/* Todo: most values not verified, and probably differ between revisions */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user