How does Sonic2 sync music update on z80?
Moderator: BigEvilCorporation
How does Sonic2 sync music update on z80?
I'm having a hard time tracking down a problem in my genesis emulator which is making music playback in Sonic2 be a bit slow and it also sporadically slows down and speeds up.
At first I thought it was bad implementation of ym2612 timers, but setting breakpoints, Sonic2 never enables them or tests the timer overflow bits. Can anyone confrim this for Sonic2?
Adding diagnostics it looks like z80 vbl interrupt is disabled during ym2612 DAC playback (z80 sits in a tight loop feeding the DAC data register). Listening carefully, it almost sounds like when DAC drum sounds are played, the music time syncing is paused during that time.
So I'm curious does anyone know what the z80 music driver is using to keep music tempo constant? Is there some timer register in z80 that's being read that I haven't implemented perhaps?
One thing I haven't implemented yet which could be part of the problem is that I'm not emulating freezing the 68k during VDP dmas. Does anyone know the side effects of this?
cheers,
Steve.
At first I thought it was bad implementation of ym2612 timers, but setting breakpoints, Sonic2 never enables them or tests the timer overflow bits. Can anyone confrim this for Sonic2?
Adding diagnostics it looks like z80 vbl interrupt is disabled during ym2612 DAC playback (z80 sits in a tight loop feeding the DAC data register). Listening carefully, it almost sounds like when DAC drum sounds are played, the music time syncing is paused during that time.
So I'm curious does anyone know what the z80 music driver is using to keep music tempo constant? Is there some timer register in z80 that's being read that I haven't implemented perhaps?
One thing I haven't implemented yet which could be part of the problem is that I'm not emulating freezing the 68k during VDP dmas. Does anyone know the side effects of this?
cheers,
Steve.
Does it also happen in Sonic 3 and Sonic 3D?
EDIT:
Also how are you running the Z80?
EDIT2:
Ah...I remember slightly now. Z80 interrupts lasts a certain length which needs to be emulated correctly. Now I can't remember how long was that.
EDIT3:
Okay....remembering some more . The interrupt length is a frame and a scanline.
EDIT:
Also how are you running the Z80?
EDIT2:
Ah...I remember slightly now. Z80 interrupts lasts a certain length which needs to be emulated correctly. Now I can't remember how long was that.
EDIT3:
Okay....remembering some more . The interrupt length is a frame and a scanline.
it's not really one frame and a line:
it means z80 interrupt occurs once per frame (on line 224) and remains active during one full line if not acknowledged by Z80
once the exception is processed on z80 side, interrupt is cleared until next frame
if Z80 interrupt is masked, interrupt remains pending for one line and should be processed if unmasked during this period
it means z80 interrupt occurs once per frame (on line 224) and remains active during one full line if not acknowledged by Z80
once the exception is processed on z80 side, interrupt is cleared until next frame
if Z80 interrupt is masked, interrupt remains pending for one line and should be processed if unmasked during this period