]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/jerry.cpp
Extensive changes to remove gcc 4.x warnings, general code cleanup
[virtualjaguar] / src / jerry.cpp
index 07be4d2c8663e7800582b2b4119183cf410108cc..742cfb255cb5466fba345846b35f194e98d7b961 100644 (file)
 //     F1DE00          R     xxxxxxxx xxxxxxxx   ROM_NOISE - white noise
 //     ------------------------------------------------------------
 
+#include "jerry.h"
+
+#include <string.h>                                                            // For memcpy
 //#include <math.h>
 #include "jaguar.h"
 #include "wavetable.h"
-#include "jerry.h"
 #include "clock.h"
+#include "dsp.h"
+#include "dac.h"
+#include "joystick.h"
+#include "eeprom.h"
+#include "log.h"
+#include "cdrom.h"
 
 //Note that 44100 Hz requires samples every 22.675737 usec.
 #define NEW_TIMER_SYSTEM
 //#define JERRY_DEBUG
 
-/*static*/ uint8 * jerry_ram_8;
+/*static*/ uint8 jerry_ram_8[0x10000];
 
 //#define JERRY_CONFIG 0x4002                                          // ??? What's this ???
 
@@ -185,6 +193,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
@@ -345,6 +356,7 @@ void JERRYI2SCallback(void)
 {
        // Why is it called this? Instead of SCLK? Shouldn't this be read from DAC.CPP???
 //Yes, it should. !!! FIX !!!
+#warning Yes, it should. !!! FIX !!!
        jerry_i2s_interrupt_divide &= 0xFF;
        // We don't have to divide the RISC clock rate by this--the reason is a bit
        // convoluted. Will put explanation here later...
@@ -386,6 +398,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);
        }
 }
 
@@ -398,7 +419,7 @@ void jerry_init(void)
        DACInit();
 //This should be handled with the cart initialization...
 //     eeprom_init();
-       memory_malloc_secure((void **)&jerry_ram_8, 0x10000, "JERRY RAM/ROM");
+//     memory_malloc_secure((void **)&jerry_ram_8, 0x10000, "JERRY RAM/ROM");
        memcpy(&jerry_ram_8[0xD000], wave_table, 0x1000);
 
        JERRYPIT1Prescaler = 0xFFFF;
@@ -428,7 +449,7 @@ void jerry_reset(void)
 void jerry_done(void)
 {
        WriteLog("JERRY: M68K Interrupt control ($F10020) = %04X\n", GET16(jerry_ram_8, 0x20));
-       memory_free(jerry_ram_8);
+//     memory_free(jerry_ram_8);
 //     clock_done();
 //     anajoy_done();
        joystick_done();
@@ -628,7 +649,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...)
@@ -739,7 +765,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;