X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fjerry.cpp;h=bc1541f835c7bdf6a9b669e040b2a1df6d80bcd9;hb=052683d4a971ffe736252957be2144afddaddb3a;hp=d569dad7b5a95faafe2f475386c8fb37d0a42dcf;hpb=3580a9ef98432ed54f065f2d537d588fdc083592;p=virtualjaguar diff --git a/src/jerry.cpp b/src/jerry.cpp index d569dad..bc1541f 100644 --- a/src/jerry.cpp +++ b/src/jerry.cpp @@ -185,6 +185,9 @@ void JERRYI2SCallback(void); //This approach is probably wrong, since the timer is continuously counting down, though //it might only be a problem if the # of interrupts generated is greater than 1--the M68K's //timeslice should be running during that phase... (The DSP needs to be aware of this!) + +//This is only used by the old system, so once the new timer system is working this +//should be safe to nuke. void jerry_i2s_exec(uint32 cycles) { #ifndef NEW_TIMER_SYSTEM @@ -245,6 +248,7 @@ void jerry_i2s_exec(uint32 cycles) #endif } +//NOTE: This is only used by the old execution core. Safe to nuke once it's stable. void JERRYExecPIT(uint32 cycles) { //This is wrong too: Counters are *always* spinning! !!! FIX !!! [DONE] @@ -294,8 +298,12 @@ void JERRYResetPIT1(void) #else RemoveCallback(JERRYPIT1Callback); - double usecs = (float)(JERRYPIT1Prescaler + 1) * (float)(JERRYPIT1Divider + 1) * RISC_CYCLE_IN_USEC; - SetCallbackTime(JERRYPIT1Callback, usecs); + + if (JERRYPIT1Prescaler | JERRYPIT1Divider) + { + double usecs = (float)(JERRYPIT1Prescaler + 1) * (float)(JERRYPIT1Divider + 1) * RISC_CYCLE_IN_USEC; + SetCallbackTime(JERRYPIT1Callback, usecs); + } #endif } @@ -315,8 +323,12 @@ void JERRYResetPIT2(void) #else RemoveCallback(JERRYPIT2Callback); - double usecs = (float)(JERRYPIT2Prescaler + 1) * (float)(JERRYPIT2Divider + 1) * RISC_CYCLE_IN_USEC; - SetCallbackTime(JERRYPIT2Callback, usecs); + + if (JERRYPIT1Prescaler | JERRYPIT1Divider) + { + double usecs = (float)(JERRYPIT2Prescaler + 1) * (float)(JERRYPIT2Divider + 1) * RISC_CYCLE_IN_USEC; + SetCallbackTime(JERRYPIT2Callback, usecs); + } #endif } @@ -377,6 +389,15 @@ void JERRYI2SCallback(void) } 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); } } @@ -502,6 +523,7 @@ uint8 JERRYReadByte(uint32 offset, uint32 who/*=UNKNOWN*/) return counter2Lo & 0xFF; } #else +WriteLog("JERRY: Unhandled timer read (BYTE) at %08X...\n", offset); #endif } // else if (offset >= 0xF10010 && offset <= 0xF10015) @@ -542,6 +564,7 @@ uint16 JERRYReadWord(uint32 offset, uint32 who/*=UNKNOWN*/) //in the jerry_timer_n_counter variables... !!! FIX !!! [DONE] else if ((offset >= 0xF10036) && (offset <= 0xF1003D)) { +#ifndef NEW_TIMER_SYSTEM // jerry_timer_1_counter = (JERRYPIT1Prescaler + 1) * (JERRYPIT1Divider + 1); uint32 counter1Hi = (jerry_timer_1_counter / (JERRYPIT1Divider + 1)) - 1; uint32 counter1Lo = (jerry_timer_1_counter % (JERRYPIT1Divider + 1)) - 1; @@ -564,6 +587,9 @@ uint16 JERRYReadWord(uint32 offset, uint32 who/*=UNKNOWN*/) return counter2Lo; } // Unaligned word reads??? +#else +WriteLog("JERRY: Unhandled timer read (WORD) at %08X...\n", offset); +#endif } // else if ((offset >= 0xF10010) && (offset <= 0xF10015)) // return clock_word_read(offset); @@ -614,7 +640,12 @@ void JERRYWriteByte(uint32 offset, uint8 data, uint32 who/*=UNKNOWN*/) jerry_i2s_interrupt_divide = (jerry_i2s_interrupt_divide & 0xFF00) | (uint32)data; jerry_i2s_interrupt_timer = -1; +#ifndef NEW_TIMER_SYSTEM jerry_i2s_exec(0); +#else + RemoveCallback(JERRYI2SCallback); + JERRYI2SCallback(); +#endif // return; } // LTXD/RTXD/SCLK/SMODE $F1A148/4C/50/54 (really 16-bit registers...) @@ -625,6 +656,7 @@ void JERRYWriteByte(uint32 offset, uint8 data, uint32 who/*=UNKNOWN*/) } else if (offset >= 0xF10000 && offset <= 0xF10007) { +#ifndef NEW_TIMER_SYSTEM switch (offset & 0x07) { case 0: @@ -659,6 +691,9 @@ void JERRYWriteByte(uint32 offset, uint8 data, uint32 who/*=UNKNOWN*/) JERRYPIT2Divider = (JERRYPIT2Divider & 0xFF00) | data; JERRYResetPIT2(); } +#else +WriteLog("JERRY: Unhandled timer write (BYTE) at %08X...\n", offset); +#endif return; } /* else if ((offset >= 0xF10010) && (offset <= 0xF10015)) @@ -721,7 +756,12 @@ void JERRYWriteWord(uint32 offset, uint16 data, uint32 who/*=UNKNOWN*/) //This should *only* be enabled when SMODE has its INTERNAL bit set! !!! FIX !!! jerry_i2s_interrupt_divide = (uint8)data; jerry_i2s_interrupt_timer = -1; +#ifndef NEW_TIMER_SYSTEM jerry_i2s_exec(0); +#else + RemoveCallback(JERRYI2SCallback); + JERRYI2SCallback(); +#endif DACWriteWord(offset, data, who); return; @@ -734,6 +774,8 @@ void JERRYWriteWord(uint32 offset, uint16 data, uint32 who/*=UNKNOWN*/) } else if (offset >= 0xF10000 && offset <= 0xF10007) { +//#ifndef NEW_TIMER_SYSTEM +#if 1 switch(offset & 0x07) { case 0: @@ -753,6 +795,9 @@ void JERRYWriteWord(uint32 offset, uint16 data, uint32 who/*=UNKNOWN*/) JERRYResetPIT2(); } // Need to handle (unaligned) cases??? +#else +WriteLog("JERRY: Unhandled timer write %04X (WORD) at %08X by %s...\n", data, offset, whoName[who]); +#endif return; } /* else if (offset >= 0xF10010 && offset < 0xF10016)