[hatari-devel] I'm lucky ;) K.prg is working

npomarede at corp.free.fr npomarede at corp.free.fr
Thu Feb 25 10:27:50 CET 2010


On Thu, 25 Feb 2010, Laurent Sallafranque wrote:

> Hello,
>
> After some more tests, I arrive to this conclusion : K.prg is not related to 
> a cycles timing problem but to a do_specialties() problem.
>
> Just to help, I've added the different tests I realized with some comments.
>
> K.PRG uses the Graoumpf tracker code to play a GT2 module (on the screen 
> where we have the crash).
> Graoumpf Tracker uses a special level 6 interrupt from DSP to COMBEL in real 
> falcon, MFP in hatari.

Hello,

I'm afraid that your tests 3 and 5 are wrong, at least the part where
cycles != save_cycles because cycles is a local variable to m68k_run_1, so 
it's normal that do_specialties doesn't change the value of cycles.
But it will call M68000_AddCycles which is the correct counter to track 
all cycles for this instruction.

It's possible that my latest patch (using Cycles_GetCounter(CYCLES_COUNTER_CPU)
breaks some programs that worked before, but it's really the correct way 
to count how many cpu cycles where used since the latest instruction 
(including time to process exceptions).

If you move the dsp before do_specialties, you will never count the cycles 
taken to procsss the exceptions, which means the DSP will not be run for 
as long as it should to stay in synch with the 68020+ clock.

You should adapt DSP_Run as we discussed by mail to consider the input 
number of cycles is "scaled" to a 8 MHz cpu (when using nCpuFreqShift to 
emulate 16 or 32 MHz) and to convert this in a number of cycle for a dsp 
running at 32 MHz.

Then, maybe there's a problem in do_specialties, but we would need some 
traces to see where k.prg is stuck to have the context of the previous 
instructions/exceptions, without very detailled traces at this level, it 
will be hard to find the cause of the problem and to fix it.


Nicolas


>
> Extract of MFP code :
>
> /**
> * Check 'pending' registers to see if any MFP interrupts need servicing.
> * Request interrupt if necessary.
> * @return true if at least one MFP interrupt was allowed, else return false.
> */
> bool MFP_CheckPendingInterrupts(void)
> {
>   int    InterruptPossible;
>
>   /* Handle Falcon DSP interrupt. Note: This interrupt is not wired to
>    * the MFP on a real Falcon, we just handle it with the SPCFLAG_MFP
>    * to avoid taking care of another special flag in the CPU core! */
>   if (bDspHostInterruptPending && regs.intmask < 6)
>   {
>       M68000_Exception(IoMem_ReadByte(0xffa203)*4, M68000_EXC_SRC_INT_DSP);
>       bDspHostInterruptPending = false;
>       return true;
>   }
>
>
> Now the tests :
>
> TEST 1 :
>
> I've returned to version N-1 (before latest Nicolas' patch). K.PRG doesn't 
> run.
>
>   if (regs.spcflags) {
>       if (do_specialties ())
>           return;
>   }
>
>   /* Run DSP 56k code if necessary */
>   if (bDspEnabled) {
>       DSP_Run( cycles );
>   }
>
>
> TEST 2 :
>
> If I invert the 2 blocks, it runs well :
>
>   /* Run DSP 56k code if necessary */
>   if (bDspEnabled) {
>       DSP_Run( cycles );
>   }
>
>   if (regs.spcflags) {
>       if (do_specialties ())
>           return;
>   }
>
>
>
> TEST 3 :
>
> If I save cycles before calling (do_specialties(), K.PRG doesn't run.
>
>   save_cycles = cycles;
>
>   if (regs.spcflags) {
>       if (do_specialties ())
>           return;
>   }
>
>   /* Run DSP 56k code if necessary */
>   if (bDspEnabled) {
>       DSP_Run( save_cycles );
>   }
>
>
>
> TEST 4 :
>
> I've added a printf before the return.
> Code never goes to the return, except when I quit Hatari.
> The problem is not here.
>
>    if (regs.spcflags) {
>       if (do_specialties ()) {
>           fprintf(stderr, "RETURN \n");
>           return;
>       }
>   }
>
>
> TEST 5 :
>
> I've added a test if cycles != save_cycles.
> It never happens.
>
> ===> do_specialties() doesn't change the cycles value.
>
>   save_cycles = cycles;
>
>   if (regs.spcflags) {
>       if (do_specialties ())
>           return;
>   }
>
>   /* Run DSP 56k code if necessary */
>   if (bDspEnabled) {
>       if (save_cycles != cycles)
>           fprintf (stderr, "Before : %d\t\t After : %d\n", cycCounter, 
> cycles);
>
>       DSP_Run( save_cycles );
>   }
>
>
> TEST 6 : (to get some more infos)
>
> I've added a printf  regs.spcflags.
> I get Only these values :
>
> During falcon boot :
> 256
> 512
> 516
> 768
> 4
>
> On the falcon desktop:
> 768 -> when I move the mouse, or after a certain time
>
> When I launch K.prg
> 256
> 512
> 768
> 4  ---> only once
>
> When I quit hatari:
> 16 --> only once.
>
>
>
> Hope this helps to understand the problem.
>
> Regards
>
> Laurent
>
>
>
>



More information about the hatari-devel mailing list