More accurate internal bus behavior
This commit is contained in:
parent
4e27558ac2
commit
97c758ba75
@ -482,6 +482,11 @@ static inline uint8_t oam_read(GB_gameboy_t *gb, uint8_t addr)
|
||||
|
||||
static void add_object_from_index(GB_gameboy_t *gb, unsigned index)
|
||||
{
|
||||
if (likely(!GB_is_dma_active(gb) || gb->halted || gb->stopped)) {
|
||||
gb->mode2_y_bus = oam_read(gb, index * 4);
|
||||
gb->mode2_x_bus = oam_read(gb, index * 4 + 1);
|
||||
}
|
||||
|
||||
if (gb->n_visible_objs == 10) return;
|
||||
|
||||
/* TODO: It appears that DMA blocks PPU access to OAM, but it needs verification. */
|
||||
@ -498,11 +503,7 @@ static void add_object_from_index(GB_gameboy_t *gb, unsigned index)
|
||||
if (unlikely(gb->oam_ppu_blocked)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (likely(!GB_is_dma_active(gb) || gb->halted || gb->stopped)) {
|
||||
gb->mode2_y_bus = oam_read(gb, index * 4);
|
||||
gb->mode2_x_bus = oam_read(gb, index * 4 + 1);
|
||||
}
|
||||
|
||||
bool height_16 = (gb->io_registers[GB_IO_LCDC] & 4) != 0;
|
||||
signed y = gb->mode2_y_bus - 16;
|
||||
/* This reverse sorts the visible objects by location and priority */
|
||||
@ -1657,7 +1658,7 @@ void GB_display_run(GB_gameboy_t *gb, unsigned cycles, bool force)
|
||||
dma_sync(gb, &cycles);
|
||||
gb->object_low_line_address = get_object_line_address(gb,
|
||||
gb->objects_y[gb->n_visible_objs - 1],
|
||||
oam_read(gb, gb->visible_objs[gb->n_visible_objs - 1] * 4 + 2),
|
||||
gb->mode2_y_bus = oam_read(gb, gb->visible_objs[gb->n_visible_objs - 1] * 4 + 2),
|
||||
gb->object_flags = oam_read(gb, gb->visible_objs[gb->n_visible_objs - 1] * 4 + 3)
|
||||
);
|
||||
|
||||
|
@ -597,7 +597,12 @@ struct GB_gameboy_internal_s {
|
||||
uint8_t objects_x[10];
|
||||
uint8_t objects_y[10];
|
||||
uint8_t object_tile_data[2];
|
||||
uint8_t object_flags;
|
||||
uint8_t mode2_y_bus;
|
||||
// They're the same bus
|
||||
union {
|
||||
uint8_t mode2_x_bus;
|
||||
uint8_t object_flags;
|
||||
};
|
||||
uint8_t n_visible_objs;
|
||||
uint8_t oam_search_index;
|
||||
uint8_t accessed_oam_row;
|
||||
@ -621,8 +626,6 @@ struct GB_gameboy_internal_s {
|
||||
uint16_t last_tile_index_address;
|
||||
bool cgb_repeated_a_frame;
|
||||
uint8_t data_for_sel_glitch;
|
||||
uint8_t mode2_y_bus;
|
||||
uint8_t mode2_x_bus;
|
||||
)
|
||||
|
||||
/* Unsaved data. This includes all pointers, as well as everything that shouldn't be on a save state */
|
||||
|
Loading…
Reference in New Issue
Block a user