]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/tom.cpp
Added logfile logging, ZIP file fishing
[virtualjaguar] / src / tom.cpp
index 36f3d8bbe6c3f1ec6767a60cf66e193e854b5d26..b3882a09f3fbe645e4b1b17ba6d6c2aaf21f9483 100644 (file)
@@ -4,6 +4,14 @@
 // Originally by David Raingeard (cal2)
 // GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
 // Cleanups and endian wrongness amelioration by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -------------------------------------------------------------
+// JLH  01/16/2010  Created this log ;-)
+//
 // Note: Endian wrongness probably stems from the MAME origins of this emu and
 //       the braindead way in which MAME handles memory. :-)
 //
 #include "jaguar.h"
 #include "log.h"
 #include "m68k.h"
+//#include "memory.h"
 #include "objectp.h"
 #include "settings.h"
 #include "video.h"
@@ -548,6 +557,7 @@ uint32 RGB16ToRGB32[0x10000];
 uint32 CRY16ToRGB32[0x10000];
 uint32 MIX16ToRGB32[0x10000];
 
+#warning "This is not endian-safe. !!! FIX !!!"
 void TOMFillLookupTables(void)
 {
        for(uint32 i=0; i<0x10000; i++)
@@ -568,12 +578,12 @@ void TOMFillLookupTables(void)
                        b = (((uint32)bluecv[chrm][chrl]) * y) >> 8;
 
                CRY16ToRGB32[i] = 0xFF000000 | (b << 16) | (g << 8) | r;
-               MIX16ToRGB32[i] = CRY16ToRGB32[i];
+               MIX16ToRGB32[i] = (i & 0x01 ? RGB16ToRGB32[i] : CRY16ToRGB32[i]);
        }
 
-       for(uint32 i=0; i<0x10000; i++)
-               if (i & 0x01)
-                       MIX16ToRGB32[i] = RGB16ToRGB32[i];
+//     for(uint32 i=0; i<0x10000; i++)
+//             if (i & 0x01)
+//                     MIX16ToRGB32[i] = RGB16ToRGB32[i];
 }
 
 void TOMSetPendingJERRYInt(void)
@@ -613,10 +623,9 @@ uint8 TOMGetVideoMode(void)
 }
 
 //Used in only one place (and for debug purposes): OBJECTP.CPP
+#warning "Used in only one place (and for debug purposes): OBJECTP.CPP !!! FIX !!!"
 uint16 TOMGetVDB(void)
 {
-// This in NOT VDB!!!
-//     return GET16(tomRam8, VBE);
        return GET16(tomRam8, VDB);
 }
 
@@ -937,7 +946,7 @@ void TOMExecScanline(uint16 scanline, bool render)
                if (inActiveDisplayArea)
                {
 //NOTE: The following doesn't put BORDER color on the sides... !!! FIX !!!
-#warning The following doesn't put BORDER color on the sides... !!! FIX !!!
+#warning "The following doesn't put BORDER color on the sides... !!! FIX !!!"
                        if (vjs.renderType == RT_NORMAL)
                                scanline_render[TOMGetVideoMode()](TOMBackbuffer);
                        else//TV type render
@@ -1195,9 +1204,9 @@ void TOMReset(void)
        tom_gpu_int_pending = 0;
        tom_video_int_pending = 0;
 
-       tom_timer_prescaler = 0;                                        // TOM PIT is disabled
-       tom_timer_divider = 0;
-       tom_timer_counter = 0;
+       tomTimerPrescaler = 0;                                  // TOM PIT is disabled
+       tomTimerDivider = 0;
+       tomTimerCounter = 0;
        memcpy(scanline_render, scanline_render_normal, sizeof(scanline_render));
 }
 
@@ -1225,13 +1234,13 @@ uint8 TOMReadByte(uint32 offset, uint32 who/*=UNKNOWN*/)
        else if ((offset >= 0xF02200) && (offset < 0xF022A0))
                return BlitterReadByte(offset, who);
        else if (offset == 0xF00050)
-               return tom_timer_prescaler >> 8;
+               return tomTimerPrescaler >> 8;
        else if (offset == 0xF00051)
-               return tom_timer_prescaler & 0xFF;
+               return tomTimerPrescaler & 0xFF;
        else if (offset == 0xF00052)
-               return tom_timer_divider >> 8;
+               return tomTimerDivider >> 8;
        else if (offset == 0xF00053)
-               return tom_timer_divider & 0xFF;
+               return tomTimerDivider & 0xFF;
 
        return tomRam8[offset & 0x3FFF];
 }
@@ -1284,9 +1293,9 @@ if (offset >= 0xF02000 && offset <= 0xF020FF)
        else if ((offset >= 0xF02200) && (offset < 0xF022A0))
                return BlitterReadWord(offset, who);
        else if (offset == 0xF00050)
-               return tom_timer_prescaler;
+               return tomTimerPrescaler;
        else if (offset == 0xF00052)
-               return tom_timer_divider;
+               return tomTimerDivider;
 
        offset &= 0x3FFF;
        return (TOMReadByte(offset, who) << 8) | TOMReadByte(offset + 1, who);
@@ -1327,25 +1336,25 @@ void TOMWriteByte(uint32 offset, uint8 data, uint32 who/*=UNKNOWN*/)
        }
        else if (offset == 0xF00050)
        {
-               tom_timer_prescaler = (tom_timer_prescaler & 0x00FF) | (data << 8);
+               tomTimerPrescaler = (tomTimerPrescaler & 0x00FF) | (data << 8);
                TOMResetPIT();
                return;
        }
        else if (offset == 0xF00051)
        {
-               tom_timer_prescaler = (tom_timer_prescaler & 0xFF00) | data;
+               tomTimerPrescaler = (tomTimerPrescaler & 0xFF00) | data;
                TOMResetPIT();
                return;
        }
        else if (offset == 0xF00052)
        {
-               tom_timer_divider = (tom_timer_divider & 0x00FF) | (data << 8);
+               tomTimerDivider = (tomTimerDivider & 0x00FF) | (data << 8);
                TOMResetPIT();
                return;
        }
        else if (offset == 0xF00053)
        {
-               tom_timer_divider = (tom_timer_divider & 0xFF00) | data;
+               tomTimerDivider = (tomTimerDivider & 0xFF00) | data;
                TOMResetPIT();
                return;
        }
@@ -1400,13 +1409,13 @@ if (offset >= 0xF02000 && offset <= 0xF020FF)
        }*/
        else if (offset == 0xF00050)
        {
-               tom_timer_prescaler = data;
+               tomTimerPrescaler = data;
                TOMResetPIT();
                return;
        }
        else if (offset == 0xF00052)
        {
-               tom_timer_divider = data;
+               tomTimerDivider = data;
                TOMResetPIT();
                return;
        }
@@ -1441,7 +1450,7 @@ if (offset >= 0xF02000 && offset <= 0xF020FF)
        offset &= 0x3FFF;
        if (offset == 0x28)                     // VMODE (Why? Why not OBF?)
 //Actually, we should check to see if the Enable bit of VMODE is set before doing this... !!! FIX !!!
-#warning Actually, we should check to see if the Enable bit of VMODE is set before doing this... !!! FIX !!!
+#warning "Actually, we should check to see if the Enable bit of VMODE is set before doing this... !!! FIX !!!"
                objectp_running = 1;
 
        if (offset >= 0x30 && offset <= 0x4E)
@@ -1536,9 +1545,9 @@ void TOMResetPIT(void)
        // Need to remove previous timer from the queue, if it exists...
        RemoveCallback(TOMPITCallback);
 
-       if (tom_timer_prescaler)
+       if (tomTimerPrescaler)
        {
-               double usecs = (float)(tom_timer_prescaler + 1) * (float)(tom_timer_divider + 1) * RISC_CYCLE_IN_USEC;
+               double usecs = (float)(tomTimerPrescaler + 1) * (float)(tomTimerDivider + 1) * RISC_CYCLE_IN_USEC;
                SetCallbackTime(TOMPITCallback, usecs);
        }
 #endif
@@ -1552,11 +1561,11 @@ void TOMResetPIT(void)
 //      once the timer system is stable.
 void TOMExecPIT(uint32 cycles)
 {
-       if (tom_timer_prescaler)
+       if (tomTimerPrescaler)
        {
-               tom_timer_counter -= cycles;
+               tomTimerCounter -= cycles;
 
-               if (tom_timer_counter <= 0)
+               if (tomTimerCounter <= 0)
                {
                        TOMSetPendingTimerInt();
                        GPUSetIRQLine(GPUIRQ_TIMER, ASSERT_LINE);       // GPUSetIRQLine does the 'IRQ enabled' checking