In article <
[email protected]>,
TomCh <
[email protected]> wrote:
On Sunday, 16 August 2020 19:38:35 UTC+1, Kent Dickey wrote:
I'm wondering if there are any Mockingboard/Phasor experts who can answer
some very low-level questions. I've read the AY-8913 and AY-8910 datasheet, >> so I think I know what it says.
[ Moved my questions to later where I answer them]
I can't really help answer your specific questions, as for AppleWin I
just spliced in GPL open-source code from another project (Fuse, a
Spectrum 128 emulator).
You can inspect the code here >(https://github.com/AppleWin/AppleWin/blob/master/source/AY8910.cpp), or >alternatively the MAME code should be a good source (which Apple in PC
uses - see: https://github.com/sosaria7/appleinpc).
Brendan Roberts may be able to help, as (IIRC) he wrote his own AY8913 >emulation code for Jace: https://github.com/badvision/jace
Tom
Tom, your pointers were very helpful. I spent a bunch of time reading
the Fuse source code at:
http://fuse-emulator.sourceforge.net.
From it, I can see MAME is considered the gold standard--the MAME code
was based on measurements of real chips, as well as some reverse engineering from some decap photographs. The MAME code is at:
https://github.com/mamedev/mame, and the AY8910 code is mostly in src/devices/sound/ay8910.cpp. (I'm not convinced of the reliability of
some of this info, but some basic stuff seems reasonable). A lot was
collected by volunteers, and they did not measure what I would like measured--I'd like measurements at the line output jack, or at the speaker
if necessary, since all the circuitry after the chip can have a significant impact on the sound. Honestly, simple recordings of known sounds would be
fine with me, as long as some effort was put into reducing noise.
So here are the answers as I understand them:
1) How should noise and tones be mixed together? My interpretation of
the mixer spec is that the tone is a simple square wave (of 0 and 1)
and similarly for the noise. So for one channel, should I just "xor" >> them together, and then scale by the amplitude?
MAME and FUSE use this formula:
out = (ToneOn | ToneDisable) & (NoiseOn | NoiseDisable);
where out is the 1-bit output for this channel. So 'xor' is not correct.
To my ear, listening to songs which have drums, 'xor' sounds much clearer,
but I'll match what the AY8910 chip is thought to do.
2) Envelope reset. If the envelope is not repeating (HOLD=1 or CONTINUE=0), >> then what actions "reset" the envelope generator, so it can start
fresh again?
MAME thinks the only thing that changes the envelope is a write to the
envelope shape register, and then all it does is reset the hidden "hold" bit. The envelope will continue to walk through its steps as before. However,
once the envelope is in a holding mode, the step is frozen, and so the
write to the shape register starts a new envelope waveform right away. I was getting this very wrong (on any write to the envelope shape register, I was resetting the step), so I'll match this behavior.
And these are lower priority:
3) Idle. The documentation says a channel is running unless the amplitude >> control is set to 0. Does this mean the hidden counters counting
tones stop when the amplitude register is 0? Does anything "reset"
the internal tone counters? (The visible registers are the "reload"
values, there must be internal counters counting separately, using
the visible register as the "limit"). This only affects restarting
a channel that was stopped when amplitude=0 and whether the "old"
note finishing one period before using the new period.
Based on MAME/FUSE, the counters all keep counting even if the channels
are not enabled or have 0 amplitude. I'm deciding how important it is
to model this behavior. It's difficult for me to see how anything could
care or even detect this behavior, and it's a pain to get these cases
right.
4) Manual amplitude control. If the tone and noise generators are disabled >> for a channel, what does the amplitude control do? Can software
write a pattern like 0, 0xf, 0, 0xf, 0, etc to the amplitude
control and create a manual waveform, even if the tone and noise
generators are off in the mixer control register? Or is the
effective tone/noise output==0, so there's nothing to amplify?
This is done by some ZX81 Spectrum code (on that system, it's much simpler
for software to write to the AY8910 chip, so it can be faster). It's
unclear if there is any Apple II software which does so. I'll punt on trying to emulate this until I have a way to test it.
MAME has some very complex code to deal with mixing the 3 channels of
sound together. There's not enough comments for me to figure out what they
are trying to do. I'll probably stick with summing the sounds together
for now, and decide if it's noticeable when running some examples.
My current plan is to make KEGS match MAME on the French Touch Pure Noise
Demo:
http://fr3nch.t0uch.free.fr/PNO/PNO.html
They have other demos, but they tend to not run on an Apple IIgs (their code checks for a IIgs and hangs). If anyone has some suggested "stress tests"
for Mockingboard, I'm interested in them.
Kent
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)