[hatari-devel] I'm lucky ;) K.prg is working
Laurent Sallafranque
laurent.sallafranque at free.fr
Tue Feb 23 19:30:20 CET 2010
> Even on a real ST, the sound interrupt can't interrupt an instruction
while it's being executed, the interrupt will be delayed after the
current cpu intruction.
> So this can't be the reason why the sound would be good on a real
falcon and not in hatari, except if some instructions don't have the
correct cycles count under hatari when compared to a real falcon.
We're not speaking of the same thing (or I don't understand anything ;)
I think you speak about timer A, B, C or D.
My timer is an internal Hatari cycint.c timer I use to synchronize
sound with DSP, DMA , microphone and DAC.
I thought that a 68x00 instruction was about 20 cycles maximum. And as
this is the base counter for all chipsets emulated, it was a good time
counter for my needs in crossbar (and for my DSP clock).
> I don't understand your number to transform 44kHz into 80 cycles.
What is
> the formula ?
It's in crossbar.c
This formula gives the number of CPU cycles needed between 2 crossbar
actions.
The internal falcon clocks for sound are 25 or 32 Mhz (the same than in
Videl).
The problem is that crossbar must feed DSP at regular moments, else, we
won't be accurate at all.
DSP would become totally unsynchronized and sound would be noisy. (it
may be what append).
/* Calculate 25 Mhz clock cycles */
cyclesClk = ((double)CPU_FREQ / Crossbar_DetectSampleRate(25)) /
(double)(crossbar.playTracks) / 2.0;
crossbar.clock25_cycles = (int)(cyclesClk);
crossbar.clock25_cycles_decimal = (int)((cyclesClk -
(double)(crossbar.clock25_cycles)) * (double)DECIMAL_PRECISION);
/* Calculate 32 Mhz clock cycles */
cyclesClk = ((double)CPU_FREQ / Crossbar_DetectSampleRate(32)) /
(double)(crossbar.playTracks) / 2.0;
crossbar.clock32_cycles = (int)(cyclesClk);
crossbar.clock32_cycles_decimal = (int)((cyclesClk -
(double)(crossbar.clock32_cycles)) * (double)DECIMAL_PRECISION);
These formulas give me correct sound frequencies for both clocks and for
the " Falcon STE" clock.
Only sound quality is noisy.
Here, if cycles = 250, I'll start one crossbar "interrupt" but I've lost 2.
DSP will execute 500 cycles instructions at once, but if it needs some
values, it'll wait or be not synchro.
Perhaps it's the DSP unsynchronized message we get with falcamp or
Aniplayer.
Regards
Laurent
npomarede at corp.free.fr a écrit :
> On Tue, 23 Feb 2010, Laurent Sallafranque wrote:
>
>> I've returned to the original code, and I've tried this :
>>
>> if (regs.spcflags) {
>> do_specialties();
>> // return;
>> }
>>
>>
>> It doesn't work. (And I think I can't use "F12" or close Hatari's
>> window, it doesn't react anymore).
>
> That's why I said I would have a look this evening, this part of the
> code is very sensitive :)
>
>>
>> I've kept this patch and I've then activated : "Patch Timer D" and
>> rebooted.
>>
>> K.PRG works, but sound is sometimes crashing completely and becomes
>> correct again after 1-2 seconds.
>>
>
>> I think there's another problem : some cpu instruction can take up to
>> 258 cycles (perhaps more).
>> Many takes more than 50 cycles.
>>
>> But at 44Khz, the sound interrupt needs 80 cycles.
>> That's probably why sound becomes noisy sometimes (There's a lost of
>> 2 samples in the worst case).
>
> Even on a real ST, the sound interrupt can't interrupt an instruction
> while it's being executed, the interrupt will be delayed after the
> current cpu intruction.
>
> So this can't be the reason why the sound would be good on a real
> falcon and not in hatari, except if some instructions don't have the
> correct cycles count under hatari when compared to a real falcon.
>
> That's why I suggested you to print the OpcodeFamily to see what is
> this instruction that takes so many cycles (I think it's 1 instruction
> + 1 exception in fact)
>
> I don't understand your number to transform 44kHz into 80 cycles. What is
> the formula ?
>
>
>>
>> Example with a GT2 player :
>> 25 Mhz : 81 Cycles decimal : 31495
>> 32 Mhz : 64 Cycles decimal : 6710
>>
>> Regards,
>>
>> Laurent
>>
More information about the hatari-devel
mailing list