Improve Atari Lynx Mikey timer and audio accuracy - #157
Conversation
|
Changed to draft to add more fixes, as I'm finding some more bugs, sorry about that. |
|
There were indeed many issues with the current implementation. Now it's ready. |
| mikey_audio_sample_t sample; | ||
|
|
||
| if ( i >= samples ) | ||
| return; |
There was a problem hiding this comment.
Are you sure about the return here?
In that case, it will pop a queue action and then discard it without any further processing.
I'd expect the code to instead compare against the front of the queue (without popping) and only pop when the item gets processed.
There was a problem hiding this comment.
My bad.
mikey_action_queue_pop is misnamed: it doesn't remove or modify the selected entry.
It only scans mTab and returns the earliest timestamp and its stage.
If the output buffer is full, the return leaves the queue unchanged, so the next mikey_update() selects the same action again. The entry is only replaced after mikey_pimpl_fireStage() processes it.
The check is before generating another sample so that an event reached by the final sample in the block can still be processed before returning.
I can rename it to mikey_action_queue_peek and make the queue pointer const.
There was a problem hiding this comment.
Please do that to reduce confusion. Thanks :)
Improve Mikey timer and audio behavior in the Atari Lynx audio core.
Changes
RESET DONEas a level, so it clearsTIMER DONEwhile set.TIMER DONEis cleared.CTLBsoftware clocks and expose borrow, last-clock and timer-done status.$80.These changes make timer state, linked clocks and audio output follow Lynx hardware behavior more closely.
This work is based on extensive hardware tests: https://github.com/drhelius/lynx-tests
There is a player implementation already using these changes here: https://www.drhelius.com/yawvgmp/