Skip to content

Commit

Permalink
[Core/VDP] improved DMA fill timing accuracy (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekeeke committed Mar 2, 2024
1 parent 5af254c commit 8c72ba0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Binary file modified builds/genesis_plus_gx_libretro.dll
Binary file not shown.
Binary file modified builds/genplus_cube.dol
Binary file not shown.
Binary file modified builds/genplus_wii.dol
Binary file not shown.
16 changes: 11 additions & 5 deletions core/vdp_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ int vdp_context_load(uint8 *state)

void vdp_dma_update(unsigned int cycles)
{
unsigned int dma_cycles, dma_bytes;
int dma_cycles, dma_bytes;

/* DMA transfer rate (bytes per line)
Expand Down Expand Up @@ -630,6 +630,12 @@ void vdp_dma_update(unsigned int cycles)
else if (rate == 204) rate = 198; /* 6 refresh slots per line in H40 mode when display is off */
}

/* Adjust DMA start cycle for DMA fill to take in account intial data port write */
else if (dmafill)
{
cycles += (2 * (MCYCLES_PER_LINE / rate));
}

/* Available DMA cycles */
if (status & 8)
{
Expand Down Expand Up @@ -692,7 +698,7 @@ void vdp_dma_update(unsigned int cycles)
}

/* Process DMA */
if (dma_bytes)
if (dma_bytes > 0)
{
/* Update DMA length */
dma_length -= dma_bytes;
Expand Down Expand Up @@ -2452,9 +2458,6 @@ static void vdp_68k_data_w_m5(unsigned int data)
/* Check if DMA Fill is pending */
if (dmafill)
{
/* Clear DMA Fill pending flag */
dmafill = 0;

/* DMA length */
dma_length = (reg[20] << 8) | reg[19];

Expand All @@ -2466,6 +2469,9 @@ static void vdp_68k_data_w_m5(unsigned int data)

/* Trigger DMA */
vdp_dma_update(m68k.cycles);

/* Clear DMA Fill pending flag */
dmafill = 0;
}
}

Expand Down

0 comments on commit 8c72ba0

Please sign in to comment.