MDSDRV
MDSDRV copied to clipboard
[PCM] smarter DMA protection
Read vcounter after each buffer run, and during the idle loop.
If there is less than n
samples before vblank, set z_min_buffer
to the lowest possible value to ensure we don't enter a new buffer run before or at the vblank.
Based on my calculations, we should stop buffering at 28~35 before vblank. The vblank will last for 32~42 samples (NTSC) or 75~100 (PAL V28) or 61~82 (PAL V30).
The vcounter should not be read during vblank as it requires a 68k bus request (and hence, it will cause the Z80 to be halted by the VDP if DMA is in progress)