It appears that OAM DMA blocks PPU access to OAM

This commit is contained in:
Lior Halphon 2018-04-07 13:59:36 +03:00
parent 0725b008be
commit 5be2b3db29

View File

@ -306,6 +306,11 @@ static void add_object_from_index(GB_gameboy_t *gb, unsigned index)
{ {
if (gb->n_visible_objs == 10) return; if (gb->n_visible_objs == 10) return;
/* TODO: It appears that DMA blocks PPU access to OAM, but it needs verification. */
if (gb->dma_steps_left && (gb->dma_cycles >= 0 || gb->is_dma_restarting)) {
return;
}
/* This reverse sorts the visible objects by location and priority */ /* This reverse sorts the visible objects by location and priority */
GB_object_t *objects = (GB_object_t *) &gb->oam; GB_object_t *objects = (GB_object_t *) &gb->oam;
bool height_16 = (gb->io_registers[GB_IO_LCDC] & 4) != 0; bool height_16 = (gb->io_registers[GB_IO_LCDC] & 4) != 0;
@ -729,7 +734,9 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
gb->cycles_for_line += 6; gb->cycles_for_line += 6;
GB_SLEEP(gb, display, 20, 6); GB_SLEEP(gb, display, 20, 6);
/* TODO: what does the PPU read if DMA is active? */
GB_object_t *object = &objects[gb->visible_objs[gb->n_visible_objs - 1]]; GB_object_t *object = &objects[gb->visible_objs[gb->n_visible_objs - 1]];
bool height_16 = (gb->io_registers[GB_IO_LCDC] & 4) != 0; /* Todo: Which T-cycle actually reads this? */ bool height_16 = (gb->io_registers[GB_IO_LCDC] & 4) != 0; /* Todo: Which T-cycle actually reads this? */
uint8_t tile_y = (gb->current_line - object->y) & (height_16? 0xF : 7); uint8_t tile_y = (gb->current_line - object->y) & (height_16? 0xF : 7);