Esempio n. 1
0
void JERRYI2SCallback(void)
{
	// We don't have to divide the RISC clock rate by this--the reason is a bit
	// convoluted. Will put explanation here later...
// What's needed here is to find the ratio of the frequency to the number of
// clock cycles  in one second. For example, if the sample rate is 44100, we
// divide the clock rate by this: 26590906 / 44100 = 602 cycles.
// Which means, every 602 cycles that go by we have to generate an interrupt.
	jerryI2SCycles = 32 * (2 * (sclk + 1));
//This makes audio faster, but not enough and the pitch is wrong besides
//	jerryI2SCycles = 32 * (2 * (sclk - 1));

	// If INTERNAL flag is set, then JERRY's SCLK is master
	if (smode & SMODE_INTERNAL)
	{
		// This does the 'IRQ enabled' checking...
		DSPSetIRQLine(DSPIRQ_SSI, ASSERT_LINE);
//		double usecs = (float)jerryI2SCycles * RISC_CYCLE_IN_USEC;
//this fix is almost enough to fix timings in tripper, but not quite enough...
		double usecs = (float)jerryI2SCycles * (vjs.hardwareTypeNTSC ? RISC_CYCLE_IN_USEC : RISC_CYCLE_PAL_IN_USEC);
		SetCallbackTime(JERRYI2SCallback, usecs, EVENT_JERRY);
	}
	else
	{
// This is handled in the BUTCH handler, where it should be...
#if 0
		// JERRY is slave to external word clock

//Note that 44100 Hz requires samples every 22.675737 usec.
//When JERRY is slave to the word clock, we need to do interrupts either at
//44.1K sample rate or at a 88.2K sample rate (11.332... usec).
/*		// This is just a temporary kludge to see if the CD bus mastering works
		// I.e., this is totally faked...!
// The whole interrupt system is pretty much borked and is need of an overhaul.
// What we need is a way of handling these interrupts when they happen instead
// of scanline boundaries the way it is now.
		jerry_i2s_interrupt_timer -= cycles;
		if (jerry_i2s_interrupt_timer <= 0)
		{
//This is probably wrong as well (i.e., need to check enable lines)... !!! FIX !!! [DONE]
			if (ButchIsReadyToSend())//Not sure this is right spot to check...
			{
//	return GetWordFromButchSSI(offset, who);
				SetSSIWordsXmittedFromButch();
				DSPSetIRQLine(DSPIRQ_SSI, ASSERT_LINE);
			}
			jerry_i2s_interrupt_timer += 602;
		}*/

		if (ButchIsReadyToSend())//Not sure this is right spot to check...
		{
//	return GetWordFromButchSSI(offset, who);
			SetSSIWordsXmittedFromButch();
			DSPSetIRQLine(DSPIRQ_SSI, ASSERT_LINE);
		}

		SetCallbackTime(JERRYI2SCallback, 22.675737, EVENT_JERRY);
#endif
	}
}
Esempio n. 2
0
void JERRYI2SCallback(void)
{
   // We don't have to divide the RISC clock rate by this--the reason is a bit
   // convoluted. Will put explanation here later...
   // What's needed here is to find the ratio of the frequency to the number of clock cycles
   // in one second. For example, if the sample rate is 44100, we divide the clock rate by
   // this: 26590906 / 44100 = 602 cycles.
   // Which means, every 602 cycles that go by we have to generate an interrupt.
   jerryI2SCycles = 32 * (2 * (*sclk + 1));

   // If INTERNAL flag is set, then JERRY's SCLK is master
   if (*smode & SMODE_INTERNAL)
   {
      double usecs;

      // This does the 'IRQ enabled' checking...
      DSPSetIRQLine(DSPIRQ_SSI, ASSERT_LINE);
      //		double usecs = (float)jerryI2SCycles * RISC_CYCLE_IN_USEC;
      //this fix is almost enough to fix timings in tripper, but not quite enough...
      usecs = (float)jerryI2SCycles * (vjs.hardwareTypeNTSC ? RISC_CYCLE_IN_USEC : RISC_CYCLE_PAL_IN_USEC);
      SetCallbackTime(JERRYI2SCallback, usecs, EVENT_JERRY);
   }
   else
   {
      // JERRY is slave to external word clock

      //Note that 44100 Hz requires samples every 22.675737 usec.
      //When JERRY is slave to the word clock, we need to do interrupts either at 44.1K
      //sample rate or at a 88.2K sample rate (11.332... usec).

      if (ButchIsReadyToSend())//Not sure this is right spot to check...
      {
         //	return GetWordFromButchSSI(offset, who);
         SetSSIWordsXmittedFromButch();
         DSPSetIRQLine(DSPIRQ_SSI, ASSERT_LINE);
      }

      SetCallbackTime(JERRYI2SCallback, 22.675737, EVENT_JERRY);
   }
}
Esempio n. 3
0
void JERRYPIT2Callback(void)
{
   if (TOMIRQEnabled(IRQ_DSP))
   {
      if (jerryInterruptMask & IRQ2_TIMER2)		// CPU Timer 2 IRQ
      {
         jerryPendingInterrupt |= IRQ2_TIMER2;
         m68k_set_irq(2);						// Generate 68K IPL 2
      }
   }

   DSPSetIRQLine(DSPIRQ_TIMER1, ASSERT_LINE);	// This does the 'IRQ enabled' checking...
   JERRYResetPIT2();
}
Esempio n. 4
0
// This is the cause of the regressions in Cybermorph and Missile Command 3D...
// Solution: Probably have to check the DSP enable bit before sending these thru.
void JERRYPIT1Callback(void)
{
   if (TOMIRQEnabled(IRQ_DSP))
   {
      if (jerryInterruptMask & IRQ2_TIMER1)		// CPU Timer 1 IRQ
      {
         // Not sure, but I think we don't generate another IRQ if one's already going...
         // But this seems to work... :-/
         jerryPendingInterrupt |= IRQ2_TIMER1;
         m68k_set_irq(2);						// Generate 68K IPL 2
      }
   }

   DSPSetIRQLine(DSPIRQ_TIMER0, ASSERT_LINE);	// This does the 'IRQ enabled' checking...
   JERRYResetPIT1();
}
Esempio n. 5
0
void JERRYPIT2Callback(void)
{
#ifndef JERRY_NO_IRQS
	if (TOMIRQEnabled(IRQ_DSP))
	{
//WriteLog("JERRY: In PIT2 callback, IRQM=$%04X\n", jerryInterruptMask);
		if (jerryInterruptMask & IRQ2_TIMER2)		// CPU Timer 2 IRQ
		{
			jerryPendingInterrupt |= IRQ2_TIMER2;
			m68k_set_irq(2);						// Generate 68K IPL 2
		}
	}
#endif

	DSPSetIRQLine(DSPIRQ_TIMER1, ASSERT_LINE);	// This does the 'IRQ enabled' checking...
	JERRYResetPIT2();
}