Pac-mania music issue

Discuss ADFFS development and download test releases
Post Reply
JonAbbott
Posts: 2938
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex
Contact:

Pac-mania music issue

Post by JonAbbott »

Having now looked into this to see if it's a wider issue that needs resolving, it's a problem with the way the game music handler was coded:
  1. The original Pac-mania (F10507) uses Event 4 (VSync) to schedule the music and effects. That's fine for the effects as they're based on game play, but it's not correct for music - and goes against Acorn guidelines in the PRM
  2. The Learning Curve version (F10447) corrects the issue above by switching the code to be called via CallEvery at 1/50th second. This in itself isn't particularly good practice as CallEvery isn't guaranteed (for a guaranteed call at 1/50th sec it should be using TickerV), but does meet PRM guidelines
  3. As the music scheduler isn't hanging off the OS_Sound Scheduler and is also separate from the Voice Generators it introduces a potential timing issue...if the music scheduler isn't scheduling the samples on time you get an audio silence when the Voice Generator is called. This also makes it very dependent on the order IRQ's are generated (although I don't believe this to be an issue as ADFFS generates them in the same order as IOC) and means the Voice Generators can stall
It's the later issue that's causing the problem. With the game code as-is, you get random silence whenever the Voice Generators get ahead of the music scheduler. Switching the music scheduler to use either Device 3 (VSync) or Device 9 (Sound System Buffer Change) improves timing in that the silence is no longer random, but regular, but obviously doesn't resolve the problem.

This poses several questions:
  1. Why wasn't this an issue in some of the earlier ADFFS releases
  2. How can the problem be resolved on IOC / IOMD
  3. How can the problem be resolved on the Pi, where there's the potential the Voice Generators are called more than once to ensure the audio buffer is full
JonAbbott
Posts: 2938
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex
Contact:

Re: Pac-mania music issue

Post by JonAbbott »

JonAbbott wrote:How can the problem be resolved on IOC / IOMD
A potential fix on IOMD is to prevent the OS_Claim for the music code and instead call it from the Fill entry of Voice Generator 1. This appears to resolve the problem under StrongARM emulation, but will need testing on physical to confirm its reliable.
JonAbbott
Posts: 2938
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex
Contact:

Re: Pac-mania music issue

Post by JonAbbott »

The latest obey.zip hopefully now fixes the music issue on both the original release and the Learning Curve release on IOMD and 32bit.

As mentioned in the previous post, the Fill entry of Voice Generator 1 now calls the music schedule. I've tested under emulation and on the Pi @ 50Hz.
Post Reply