Welcome to Emulationworld

Forum Index | FAQ | New User | Login | Search

Make a New PostPrevious ThreadView All ThreadsNext ThreadShow in Flat Mode*


SubjectRe: Genesis - no sound in some games Reply to this message
Posted byChris.S
Posted on01/18/07 10:07 AM



Finally, I managed to understand why this strange thing happened. In fact, debugging the Z80, I've noticed that it was kept in a loop, reading the FM Register.

On read, the emulator returns the FM status, which contains, in his 2 first bits, the status of the 2 FM timers , TimerA & Timer B (a bit set to 1 means that the Timer has overflowed). It seems also that those games use this to synchronise the Z80, so I investigated further.

These timers are updated externally by Genesis Plus (at each frame to be precise, that means each 64us) and can be controlled by the Z80 or 68000 programm with FM writes.

So, Genesis Plus need to interprate this special write (YM2612 0x27 register, see Techncal Doc) in order to manage the Timers correctly. The available command are:

- Start or Stop TimerA or Timer B
- Enable or Disable Timer Overflow to set the FM status TimerA or TimerB flag
- Reset the FM status TimerA or TimerB flag

At this point, I made a test whith letting the FM core managing the Timers and the FM status himself (set FM_INTERNAL_TIMER to 1 in fm.h) and noticed that sound playback was finally here, but unfortunately, the tempo was not good and some new games had problem with music playback that weren't before.

In fact, this was due to the way the FM core update the Timers value, which is not correct beacuse it has no idea about the real emulator timing.

So, I came back to external timer, managed by Genesis Plus himself and finally found were the probleme was:

In fact, when it recognizes a FM register writing which want to start or stop a timer, Genesis Plus acted like this:

In reply to:


/* LOAD */
timer[0].running = (data >> 0) & 1;
if(timer[0].running) timer[0].count = 0;
timer[1].running = (data >> 1) & 1;
if(timer[1].running) timer[1].count = 0;
[\quote]

This is not correct because the timers count have to be reinitialized (set to 0) ONLY if the timer was previously STOPPED. Doing like this, made the timers repeat infinitely each time the LOAD bit is set to 1 (which the Z80 program effectively do each time it want to access this register and don't want to stop the timer)

So, I changed the code with this:

[quote]
/* LOAD */
if(!timer[0].running && (data & 1 )) timer[0].count = 0;
timer[0].running = (data & 1);

if(!timer[1].running && (data & 2 )) timer[1].count = 0;
timer[1].running = (data & 2);



.. and now we have sound !

By the way, It makes some other games which previously hangs (games were 68000 is waiting for the Z80, looping forever) to work fine (Undead Line for example).





-
Entire Thread
Subject  Posted byPosted On
*Genesis - no sound in some games  Chris.S05/22/06 11:38 AM
.*Re: Genesis - no sound in some games  Bart T.05/22/06 06:41 PM
..*Re: Genesis - no sound in some games  _Stef_07/10/06 06:12 AM
..*Re: Genesis - no sound in some games  Chris.S05/23/06 04:32 AM
...*Re: Genesis - no sound in some games  Bart T.05/25/06 12:33 PM
....*Re: Genesis - no sound in some games  Chris.S01/09/07 09:44 AM
......Re: Genesis - no sound in some games  Chris.S01/18/07 10:07 AM
....*Re: Genesis - no sound in some games  smf05/31/06 03:47 PM
.....*Re: Genesis - no sound in some games  AaronGiles05/31/06 07:28 PM
......*Re: Genesis - no sound in some games  smf06/10/06 03:37 PM