+ jerryI2SCycles = 32 * (2 * (jerry_i2s_interrupt_divide + 1));
+ }
+
+ 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 !!!
+ DSPSetIRQLine(DSPIRQ_SSI, ASSERT_LINE);
+ jerry_i2s_interrupt_timer += jerryI2SCycles;
+#ifdef JERRY_DEBUG
+ if (jerry_i2s_interrupt_timer < 0)
+ WriteLog("JERRY: Missed generating an interrupt (missed %u)!\n", (-jerry_i2s_interrupt_timer / jerryI2SCycles) + 1);
+#endif
+ }
+ }
+ else // JERRY is slave to external word clock
+ {
+ // 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;
+ }
+ }
+#else
+ RemoveCallback(JERRYI2SCallback);
+ JERRYI2SCallback();
+#endif
+}
+
+void JERRYExecPIT(uint32 cycles)
+{
+//This is wrong too: Counters are *always* spinning! !!! FIX !!! [DONE]
+// if (jerry_timer_1_counter)
+ jerry_timer_1_counter -= cycles;
+
+ if (jerry_timer_1_counter <= 0)
+ {
+//Also, it can generate a CPU interrupt as well... !!! FIX !!! or does it? Maybe it goes Timer->GPU->CPU?
+ DSPSetIRQLine(DSPIRQ_TIMER0, ASSERT_LINE); // This does the 'IRQ enabled' checking...
+// JERRYResetPIT1();
+ jerry_timer_1_counter += (JERRYPIT1Prescaler + 1) * (JERRYPIT1Divider + 1);