]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/objectp.cpp
Initial file reading thread implementation
[virtualjaguar] / src / objectp.cpp
index fc1c64829ebd1eb556bbe0c9b7b396d7b80988c3..38631648d250d048c38384bc175e46b39c184d8a 100644 (file)
@@ -4,12 +4,25 @@
 // Original source by David Raingeard (Cal2)
 // GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
 // Extensive cleanups/fixes/rewrites 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 ;-)
 //
 
-//#include <stdio.h>
+#include "objectp.h"
+
 #include <stdlib.h>
 #include <string.h>
+#include "gpu.h"
 #include "jaguar.h"
+#include "log.h"
+#include "m68k.h"
+#include "memory.h"
+#include "tom.h"
 
 //#define OP_DEBUG
 //#define OP_DEBUG_BMP
@@ -40,16 +53,18 @@ void OPProcessFixedBitmap(uint64 p0, uint64 p1, bool render);
 void OPProcessScaledBitmap(uint64 p0, uint64 p1, uint64 p2, bool render);
 void DumpScaledObject(uint64 p0, uint64 p1, uint64 p2);
 void DumpFixedObject(uint64 p0, uint64 p1);
-uint64 op_load_phrase(uint32 offset);
+uint64 OPLoadPhrase(uint32 offset);
 
 // Local global variables
 
-static uint8 * op_blend_y;
-static uint8 * op_blend_cr;
+// Blend tables (64K each)
+static uint8 op_blend_y[0x10000];
+static uint8 op_blend_cr[0x10000];
 // There may be a problem with this "RAM" overlapping (and thus being independent of)
 // some of the regular TOM RAM...
-static uint8 objectp_ram[0x40];                        // This is based at $F00000
-uint8 objectp_running;
+//#warning objectp_ram is separated from TOM RAM--need to fix that!
+//static uint8 objectp_ram[0x40];                      // This is based at $F00000
+uint8 objectp_running = 0;
 //bool objectp_stop_reading_list;
 
 static uint8 op_bitmap_bit_depth[8] = { 1, 2, 4, 8, 16, 24, 32, 0 };
@@ -64,23 +79,19 @@ int32 phraseWidthToPixels[8] = { 64, 32, 16, 8, 4, 2, 0, 0 };
 //
 // Object Processor initialization
 //
-void op_init(void)
+void OPInit(void)
 {
-       // Blend tables (64K each)
-       memory_malloc_secure((void **)&op_blend_y, 0x10000, "Jaguar Object processor Y blend lookup table");
-       memory_malloc_secure((void **)&op_blend_cr, 0x10000, "Jaguar Object processor CR blend lookup table");
-
        // Here we calculate the saturating blend of a signed 4-bit value and an
        // existing Cyan/Red value as well as a signed 8-bit value and an existing intensity...
        // Note: CRY is 4 bits Cyan, 4 bits Red, 16 bits intensitY
        for(int i=0; i<256*256; i++)
        {
                int y = (i >> 8) & 0xFF;
-               int dy = (INT8)i;                                       // Sign extend the Y index
+               int dy = (int8)i;                                       // Sign extend the Y index
                int c1 = (i >> 8) & 0x0F;
-               int dc1 = (INT8)(i << 4) >> 4;          // Sign extend the R index
+               int dc1 = (int8)(i << 4) >> 4;          // Sign extend the R index
                int c2 = (i >> 12) & 0x0F;
-               int dc2 = (INT8)(i & 0xF0) >> 4;        // Sign extend the C index
+               int dc2 = (int8)(i & 0xF0) >> 4;        // Sign extend the C index
 
                y += dy;
 
@@ -108,26 +119,26 @@ void op_init(void)
                op_blend_cr[i] = (c2 << 4) | c1;
        }
 
-       op_reset();
+       OPReset();
 }
 
 //
 // Object Processor reset
 //
-void op_reset(void)
+void OPReset(void)
 {
-       memset(objectp_ram, 0x00, 0x40);
+//     memset(objectp_ram, 0x00, 0x40);
        objectp_running = 0;
 }
 
-void op_done(void)
+void OPDone(void)
 {
-       char * opType[8] =
+       const char * opType[8] =
        { "(BITMAP)", "(SCALED BITMAP)", "(GPU INT)", "(BRANCH)", "(STOP)", "???", "???", "???" };
-       char * ccType[8] =
+       const char * ccType[8] =
                { "\"==\"", "\"<\"", "\">\"", "(opflag set)", "(second half line)", "?", "?", "?" };
 
-       uint32 olp = op_get_list_pointer();
+       uint32 olp = OPGetListPointer();
        WriteLog("OP: OLP = %08X\n", olp);
        WriteLog("OP: Phrase dump\n    ----------\n");
        for(uint32 i=0; i<0x100; i+=8)
@@ -143,14 +154,14 @@ void op_done(void)
                }
                WriteLog("\n");
                if ((lo & 0x07) == 0)
-                       DumpFixedObject(op_load_phrase(olp+i), op_load_phrase(olp+i+8));
+                       DumpFixedObject(OPLoadPhrase(olp+i), OPLoadPhrase(olp+i+8));
                if ((lo & 0x07) == 1)
-                       DumpScaledObject(op_load_phrase(olp+i), op_load_phrase(olp+i+8), op_load_phrase(olp+i+16));
+                       DumpScaledObject(OPLoadPhrase(olp+i), OPLoadPhrase(olp+i+8), OPLoadPhrase(olp+i+16));
        }
        WriteLog("\n");
 
-       memory_free(op_blend_y);
-       memory_free(op_blend_cr);
+//     memory_free(op_blend_y);
+//     memory_free(op_blend_cr);
 }
 
 //
@@ -162,6 +173,7 @@ void op_done(void)
 //     F00026            W   -------- -------x   OBF - object processor flag
 //
 
+#if 0
 uint8 OPReadByte(uint32 offset, uint32 who/*=UNKNOWN*/)
 {
        offset &= 0x3F;
@@ -190,36 +202,30 @@ WriteLog("OP: Setting lo list pointer: %04X\n", data);
 if (offset == 0x22)
 WriteLog("OP: Setting hi list pointer: %04X\n", data);//*/
 }
+#endif
 
-uint32 op_get_list_pointer(void)
+uint32 OPGetListPointer(void)
 {
        // Note: This register is LO / HI WORD, hence the funky look of this...
-//     return (objectp_ram[0x22] << 24) | (objectp_ram[0x23] << 16) | (objectp_ram[0x20] << 8) | objectp_ram[0x21];
-       return GET16(objectp_ram, 0x20) | (GET16(objectp_ram, 0x22) << 16);
+       return GET16(tomRam8, 0x20) | (GET16(tomRam8, 0x22) << 16);
 }
 
 // This is WRONG, since the OBF is only 16 bits wide!!! [FIXED]
 
-uint32 op_get_status_register(void)
+uint32 OPGetStatusRegister(void)
 {
-//     return (objectp_ram[0x26] << 24) | (objectp_ram[0x27] << 16) | (objectp_ram[0x28] << 8) | objectp_ram[0x29];
-//     return GET32(objectp_ram, 0x26);
-       return GET16(objectp_ram, 0x26);
+       return GET16(tomRam8, 0x26);
 }
 
 // This is WRONG, since the OBF is only 16 bits wide!!! [FIXED]
 
-void op_set_status_register(uint32 data)
+void OPSetStatusRegister(uint32 data)
 {
-/*     objectp_ram[0x26] = (data & 0xFF000000) >> 24;
-       objectp_ram[0x27] = (data & 0x00FF0000) >> 16;
-       objectp_ram[0x28] = (data & 0x0000FF00) >> 8;
-       objectp_ram[0x29] |= (data & 0xFE);*/
-       objectp_ram[0x26] = (data & 0x0000FF00) >> 8;
-       objectp_ram[0x27] |= (data & 0xFE);
+       tomRam8[0x26] = (data & 0x0000FF00) >> 8;
+       tomRam8[0x27] |= (data & 0xFE);
 }
 
-void op_set_current_object(uint64 object)
+void OPSetCurrentObject(uint64 object)
 {
 //Not sure this is right... Wouldn't it just be stored 64 bit BE?
        // Stored as least significant 32 bits first, ms32 last in big endian
@@ -233,18 +239,18 @@ void op_set_current_object(uint64 object)
        objectp_ram[0x15] = object & 0xFF; object >>= 8;
        objectp_ram[0x14] = object & 0xFF;*/
 // Let's try regular good old big endian...
-       objectp_ram[0x17] = object & 0xFF; object >>= 8;
-       objectp_ram[0x16] = object & 0xFF; object >>= 8;
-       objectp_ram[0x15] = object & 0xFF; object >>= 8;
-       objectp_ram[0x14] = object & 0xFF; object >>= 8;
-
-       objectp_ram[0x13] = object & 0xFF; object >>= 8;
-       objectp_ram[0x12] = object & 0xFF; object >>= 8;
-       objectp_ram[0x11] = object & 0xFF; object >>= 8;
-       objectp_ram[0x10] = object & 0xFF;
+       tomRam8[0x17] = object & 0xFF; object >>= 8;
+       tomRam8[0x16] = object & 0xFF; object >>= 8;
+       tomRam8[0x15] = object & 0xFF; object >>= 8;
+       tomRam8[0x14] = object & 0xFF; object >>= 8;
+
+       tomRam8[0x13] = object & 0xFF; object >>= 8;
+       tomRam8[0x12] = object & 0xFF; object >>= 8;
+       tomRam8[0x11] = object & 0xFF; object >>= 8;
+       tomRam8[0x10] = object & 0xFF;
 }
 
-uint64 op_load_phrase(uint32 offset)
+uint64 OPLoadPhrase(uint32 offset)
 {
        offset &= ~0x07;                                                // 8 byte alignment
        return ((uint64)JaguarReadLong(offset, OP) << 32) | (uint64)JaguarReadLong(offset+4, OP);
@@ -314,13 +320,14 @@ void DumpFixedObject(uint64 p0, uint64 p1)
 //
 //Need to fix this so that when an GPU object IRQ happens, we can pick up OP processing
 //where we left off. !!! FIX !!!
+#warning "Need to fix this so that when an GPU object IRQ happens, we can pick up OP processing where we left off. !!! FIX !!!"
 void OPProcessList(int scanline, bool render)
 {
 extern int op_start_log;
 //     char * condition_to_str[8] =
 //             { "==", "<", ">", "(opflag set)", "(second half line)", "?", "?", "?" };
 
-       op_pointer = op_get_list_pointer();
+       op_pointer = OPGetListPointer();
 
 //     objectp_stop_reading_list = false;
 
@@ -348,11 +355,11 @@ else
 // *** END OP PROCESSOR TESTING ONLY ***
 //             if (objectp_stop_reading_list)
 //                     return;
-                       
-               uint64 p0 = op_load_phrase(op_pointer);
+
+               uint64 p0 = OPLoadPhrase(op_pointer);
 //WriteLog("\t%08X type %i\n", op_pointer, (uint8)p0 & 0x07);
                op_pointer += 8;
-if (scanline == tom_get_vdb() && op_start_log)
+if (scanline == TOMGetVDB() && op_start_log)
 //if (scanline == 215 && op_start_log)
 //if (scanline == 28 && op_start_log)
 {
@@ -360,7 +367,7 @@ WriteLog("%08X --> phrase %08X %08X", op_pointer - 8, (int)(p0>>32), (int)(p0&0x
 if ((p0 & 0x07) == OBJECT_TYPE_BITMAP)
 {
 WriteLog(" (BITMAP) ");
-uint64 p1 = op_load_phrase(op_pointer);
+uint64 p1 = OPLoadPhrase(op_pointer);
 WriteLog("\n%08X --> phrase %08X %08X ", op_pointer, (int)(p1>>32), (int)(p1&0xFFFFFFFF));
        uint8 bitdepth = (p1 >> 12) & 0x07;
 //WAS: int16 ypos = ((p0 >> 3) & 0x3FF);                       // ??? What if not interlaced (/2)?
@@ -382,7 +389,7 @@ WriteLog("\n    [%u (%u) x %u @ (%i, %u) (%u bpp), l: %08X, p: %08X fp: %02X, fl
 if ((p0 & 0x07) == OBJECT_TYPE_SCALE)
 {
 WriteLog(" (SCALED BITMAP)");
-uint64 p1 = op_load_phrase(op_pointer), p2 = op_load_phrase(op_pointer+8);
+uint64 p1 = OPLoadPhrase(op_pointer), p2 = OPLoadPhrase(op_pointer+8);
 WriteLog("\n%08X --> phrase %08X %08X ", op_pointer, (int)(p1>>32), (int)(p1&0xFFFFFFFF));
 WriteLog("\n%08X --> phrase %08X %08X ", op_pointer+8, (int)(p2>>32), (int)(p2&0xFFFFFFFF));
        uint8 bitdepth = (p1 >> 12) & 0x07;
@@ -411,16 +418,16 @@ WriteLog(" (GPU)\n");
 if ((p0 & 0x07) == OBJECT_TYPE_BRANCH)
 {
 WriteLog(" (BRANCH)\n");
-uint8 * jaguar_mainRam = GetRamPtr();
+uint8 * jaguarMainRam = GetRamPtr();
 WriteLog("[RAM] --> ");
 for(int k=0; k<8; k++)
-       WriteLog("%02X ", jaguar_mainRam[op_pointer-8 + k]);
+       WriteLog("%02X ", jaguarMainRam[op_pointer-8 + k]);
 WriteLog("\n");
 }
 if ((p0 & 0x07) == OBJECT_TYPE_STOP)
 WriteLog("    --> List end\n");
 }//*/
-               
+
                switch ((uint8)p0 & 0x07)
                {
                case OBJECT_TYPE_BITMAP:
@@ -448,7 +455,7 @@ if (!inhibit)       // For OP testing only!
 // *** END OP PROCESSOR TESTING ONLY ***
                        if (scanline >= ypos && height > 0)
                        {
-                               uint64 p1 = op_load_phrase(op_pointer);
+                               uint64 p1 = OPLoadPhrase(op_pointer);
                                op_pointer += 8;
 //WriteLog("OP: Writing scanline %d with ypos == %d...\n", scanline, ypos);
 //WriteLog("--> Writing %u BPP bitmap...\n", op_bitmap_bit_depth[(p1 >> 12) & 0x07]);
@@ -460,8 +467,8 @@ if (!inhibit)       // For OP testing only!
 //???Does this really happen??? Doesn't seem to work if you do this...!
 //Probably not. Must be a bug in the documentation...!
 //                             uint32 link = (p0 & 0x7FFFF000000) >> 21;
-//                             SET16(objectp_ram, 0x20, link & 0xFFFF);        // OLP
-//                             SET16(objectp_ram, 0x22, link >> 16);
+//                             SET16(tom_ram_8, 0x20, link & 0xFFFF);  // OLP
+//                             SET16(tom_ram_8, 0x22, link >> 16);
 /*                             uint32 height = (p0 & 0xFFC000) >> 14;
                                if (height - 1 > 0)
                                        height--;*/
@@ -501,16 +508,16 @@ if (!inhibit)     // For OP testing only!
 if (inhibit && op_start_log)
 {
        WriteLog("!!! ^^^ This object is INHIBITED! ^^^ !!! (scanline=%u, ypos=%u, height=%u)\n", scanline, ypos, height);
-       DumpScaledObject(p0, op_load_phrase(op_pointer), op_load_phrase(op_pointer+8));
+       DumpScaledObject(p0, OPLoadPhrase(op_pointer), OPLoadPhrase(op_pointer+8));
 }
 bitmapCounter++;
 if (!inhibit)  // For OP testing only!
 // *** END OP PROCESSOR TESTING ONLY ***
                        if (scanline >= ypos && height > 0)
                        {
-                               uint64 p1 = op_load_phrase(op_pointer);
+                               uint64 p1 = OPLoadPhrase(op_pointer);
                                op_pointer += 8;
-                               uint64 p2 = op_load_phrase(op_pointer);
+                               uint64 p2 = OPLoadPhrase(op_pointer);
                                op_pointer += 8;
 //WriteLog("OP: %08X (%d) %08X%08X %08X%08X %08X%08X\n", oldOPP, scanline, (uint32)(p0>>32), (uint32)(p0&0xFFFFFFFF), (uint32)(p1>>32), (uint32)(p1&0xFFFFFFFF), (uint32)(p2>>32), (uint32)(p2&0xFFFFFFFF));
                                OPProcessScaledBitmap(p0, p1, p2, render);
@@ -521,7 +528,7 @@ if (!inhibit)       // For OP testing only!
 //Actually, we should skip this object if it has a vscale of zero.
 //Or do we? Not sure... Atari Karts has a few lines that look like:
 // (SCALED BITMAP)
-//000E8268 --> phrase 00010000 7000B00D 
+//000E8268 --> phrase 00010000 7000B00D
 //    [7 (0) x 1 @ (13, 0) (8 bpp), l: 000E82A0, p: 000E0FC0 fp: 00, fl:RELEASE, idx:00, pt:01]
 //    [hsc: 9A, vsc: 00, rem: 00]
 // Could it be the vscale is overridden if the DWIDTH is zero? Hmm...
@@ -618,7 +625,8 @@ OP: Scaled bitmap 4x? 4bpp at 34,? hscale=80 fpix=0 data=000756E8 pitch 1 hflipp
                case OBJECT_TYPE_GPU:
                {
 //WriteLog("OP: Asserting GPU IRQ #3...\n");
-                       op_set_current_object(p0);
+#warning "Need to fix OP GPU IRQ handling! !!! FIX !!!"
+                       OPSetCurrentObject(p0);
                        GPUSetIRQLine(3, ASSERT_LINE);
 //Also, OP processing is suspended from this point until OBF (F00026) is written to...
 // !!! FIX !!!
@@ -634,7 +642,7 @@ OP: Scaled bitmap 4x? 4bpp at 34,? hscale=80 fpix=0 data=000756E8 pitch 1 hflipp
                        uint16 ypos = (p0 >> 3) & 0x7FF;
                        uint8  cc   = (p0 >> 14) & 0x03;
                        uint32 link = (p0 >> 21) & 0x3FFFF8;
-                       
+
 //                     if ((ypos!=507)&&(ypos!=25))
 //                             WriteLog("\t%i%s%i link=0x%.8x\n",scanline,condition_to_str[cc],ypos>>1,link);
                        switch (cc)
@@ -652,13 +660,14 @@ OP: Scaled bitmap 4x? 4bpp at 34,? hscale=80 fpix=0 data=000756E8 pitch 1 hflipp
                                        op_pointer = link;
                                break;
                        case CONDITION_OP_FLAG_SET:
-                               if (op_get_status_register() & 0x01)
+                               if (OPGetStatusRegister() & 0x01)
                                        op_pointer = link;
                                break;
                        case CONDITION_SECOND_HALF_LINE:
                                // This basically means branch if bit 10 of HC is set
+#warning "Unhandled condition code causes emulator to crash... !!! FIX !!!"
                                WriteLog("OP: Unexpected CONDITION_SECOND_HALF_LINE in BRANCH object\nOP: shuting down\n");
-                               fclose(log_get());
+                               LogDone();
                                exit(0);
                                break;
                        default:
@@ -673,12 +682,12 @@ OP: Scaled bitmap 4x? 4bpp at 34,? hscale=80 fpix=0 data=000756E8 pitch 1 hflipp
 //WriteLog("OP: --> STOP\n");
 //                     op_set_status_register(((p0>>3) & 0xFFFFFFFF));
 //This seems more likely...
-                       op_set_current_object(p0);
-                       
+                       OPSetCurrentObject(p0);
+
                        if (p0 & 0x08)
                        {
-                               tom_set_pending_object_int();
-                               if (tom_irq_enabled(IRQ_OPFLAG))// && jaguar_interrupt_handler_is_valid(64))
+                               TOMSetPendingObjectInt();
+                               if (TOMIRQEnabled(IRQ_OPFLAG))// && jaguar_interrupt_handler_is_valid(64))
                                        m68k_set_irq(7);                                // Cause an NMI to occur...
                        }
 
@@ -686,13 +695,14 @@ OP: Scaled bitmap 4x? 4bpp at 34,? hscale=80 fpix=0 data=000756E8 pitch 1 hflipp
 //                     break;
                }
                default:
-                       WriteLog("op: unknown object type %i\n", ((uint8)p0 & 0x07)); 
+                       WriteLog("op: unknown object type %i\n", ((uint8)p0 & 0x07));
                        return;
                }
 
                // Here is a little sanity check to keep the OP from locking up the machine
                // when fed bad data. Better would be to count how many actual cycles it used
                // and bail out/reenter to properly simulate an overloaded OP... !!! FIX !!!
+#warning "Better would be to count how many actual cycles it used and bail out/reenter to properly simulate an overloaded OP... !!! FIX !!!"
                opCyclesToRun--;
                if (!opCyclesToRun)
                        return;
@@ -730,8 +740,8 @@ void OPProcessFixedBitmap(uint64 p0, uint64 p1, bool render)
        pitch <<= 3;                                                                    // Optimization: Multiply pitch by 8
 
 //     int16 scanlineWidth = tom_getVideoModeWidth();
-       uint8 * tom_ram_8 = tom_get_ram_pointer();
-       uint8 * paletteRAM = &tom_ram_8[0x400];
+       uint8 * tomRam8 = TOMGetRamPointer();
+       uint8 * paletteRAM = &tomRam8[0x400];
        // This is OK as long as it's used correctly: For 16-bit RAM to RAM direct copies--NOT
        // for use when using endian-corrected data (i.e., any of the *_word_read functions!)
        uint16 * paletteRAM16 = (uint16 *)paletteRAM;
@@ -758,7 +768,7 @@ void OPProcessFixedBitmap(uint64 p0, uint64 p1, bool render)
                (!flagREFLECT ? (phraseWidthToPixels[depth] * iwidth) - 1
                : -((phraseWidthToPixels[depth] * iwidth) + 1));
        uint32 clippedWidth = 0, phraseClippedWidth = 0, dataClippedWidth = 0;//, phrasePixel = 0;
-       bool in24BPPMode = (((GET16(tom_ram_8, 0x0028) >> 1) & 0x03) == 1 ? true : false);      // VMODE
+       bool in24BPPMode = (((GET16(tomRam8, 0x0028) >> 1) & 0x03) == 1 ? true : false);        // VMODE
        // Not sure if this is Jaguar Two only location or what...
        // From the docs, it is... If we want to limit here we should think of something else.
 //     int32 limit = GET16(tom_ram_8, 0x0008);                 // LIMIT
@@ -856,7 +866,7 @@ if (depth > 5)
 //Why does this work right when multiplying startPos by 2 (instead of 4) for 24 BPP mode?
 //Is this a bug in the OP?
        uint32 lbufAddress = 0x1800 + (!in24BPPMode ? startPos * 2 : startPos * 2);
-       uint8 * currentLineBuffer = &tom_ram_8[lbufAddress];
+       uint8 * currentLineBuffer = &tomRam8[lbufAddress];
 
        // Render.
 
@@ -894,9 +904,9 @@ if (depth > 5)
                                                // (i.e., mem-to-mem direct copying)!
                                                *(uint16 *)currentLineBuffer = paletteRAM16[index | bit];
                                        else
-                                               *currentLineBuffer = 
+                                               *currentLineBuffer =
                                                        BLEND_CR(*currentLineBuffer, paletteRAM[(index | bit) << 1]),
-                                               *(currentLineBuffer + 1) = 
+                                               *(currentLineBuffer + 1) =
                                                        BLEND_Y(*(currentLineBuffer + 1), paletteRAM[((index | bit) << 1) + 1]);
                                }
 
@@ -938,9 +948,9 @@ if (firstPix)
                                        if (!flagRMW)
                                                *(uint16 *)currentLineBuffer = paletteRAM16[index | bits];
                                        else
-                                               *currentLineBuffer = 
+                                               *currentLineBuffer =
                                                        BLEND_CR(*currentLineBuffer, paletteRAM[(index | bits) << 1]),
-                                               *(currentLineBuffer + 1) = 
+                                               *(currentLineBuffer + 1) =
                                                        BLEND_Y(*(currentLineBuffer + 1), paletteRAM[((index | bits) << 1) + 1]);
                                }
 
@@ -978,9 +988,9 @@ if (firstPix)
                                        if (!flagRMW)
                                                *(uint16 *)currentLineBuffer = paletteRAM16[index | bits];
                                        else
-                                               *currentLineBuffer = 
+                                               *currentLineBuffer =
                                                        BLEND_CR(*currentLineBuffer, paletteRAM[(index | bits) << 1]),
-                                               *(currentLineBuffer + 1) = 
+                                               *(currentLineBuffer + 1) =
                                                        BLEND_Y(*(currentLineBuffer + 1), paletteRAM[((index | bits) << 1) + 1]);
                                }
 
@@ -1019,9 +1029,9 @@ if (firstPix)
                                        if (!flagRMW)
                                                *(uint16 *)currentLineBuffer = paletteRAM16[bits];
                                        else
-                                               *currentLineBuffer = 
+                                               *currentLineBuffer =
                                                        BLEND_CR(*currentLineBuffer, paletteRAM[bits << 1]),
-                                               *(currentLineBuffer + 1) = 
+                                               *(currentLineBuffer + 1) =
                                                        BLEND_Y(*(currentLineBuffer + 1), paletteRAM[(bits << 1) + 1]);
                                }
 
@@ -1063,9 +1073,9 @@ if (firstPix)
                                                *currentLineBuffer = bitsHi,
                                                *(currentLineBuffer + 1) = bitsLo;
                                        else
-                                               *currentLineBuffer = 
+                                               *currentLineBuffer =
                                                        BLEND_CR(*currentLineBuffer, bitsHi),
-                                               *(currentLineBuffer + 1) = 
+                                               *(currentLineBuffer + 1) =
                                                        BLEND_Y(*(currentLineBuffer + 1), bitsLo);
                                }
 
@@ -1141,8 +1151,8 @@ if (firstPix)
        uint8 index = (p1 >> 37) & 0xFE;                                // CLUT index offset (upper pix, 1-4 bpp)
        uint32 pitch = (p1 >> 15) & 0x07;                               // Phrase pitch
 
-       uint8 * tom_ram_8 = tom_get_ram_pointer();
-       uint8 * paletteRAM = &tom_ram_8[0x400];
+       uint8 * tomRam8 = TOMGetRamPointer();
+       uint8 * paletteRAM = &tomRam8[0x400];
        // This is OK as long as it's used correctly: For 16-bit RAM to RAM direct copies--NOT
        // for use when using endian-corrected data (i.e., any of the *ReadWord functions!)
        uint16 * paletteRAM16 = (uint16 *)paletteRAM;
@@ -1175,7 +1185,7 @@ if (start_logging)
        int32 startPos = xpos, endPos = xpos +
                (!flagREFLECT ? scaledWidthInPixels - 1 : -(scaledWidthInPixels + 1));
        uint32 clippedWidth = 0, phraseClippedWidth = 0, dataClippedWidth = 0;
-       bool in24BPPMode = (((GET16(tom_ram_8, 0x0028) >> 1) & 0x03) == 1 ? true : false);      // VMODE
+       bool in24BPPMode = (((GET16(tomRam8, 0x0028) >> 1) & 0x03) == 1 ? true : false);        // VMODE
        // Not sure if this is Jaguar Two only location or what...
        // From the docs, it is... If we want to limit here we should think of something else.
 //     int32 limit = GET16(tom_ram_8, 0x0008);                 // LIMIT
@@ -1321,7 +1331,7 @@ if (op_start_log && startPos == 13)
 //     uint32 lbufAddress = 0x1800 + (!in24BPPMode ? leftMargin * 2 : leftMargin * 4);
 //     uint32 lbufAddress = 0x1800 + (!in24BPPMode ? startPos * 2 : startPos * 4);
        uint32 lbufAddress = 0x1800 + startPos * 2;
-       uint8 * currentLineBuffer = &tom_ram_8[lbufAddress];
+       uint8 * currentLineBuffer = &tomRam8[lbufAddress];
 //uint8 * lineBufferLowerLimit = &tom_ram_8[0x1800],
 //     * lineBufferUpperLimit = &tom_ram_8[0x1800 + 719];
 
@@ -1356,9 +1366,9 @@ if (firstPix != 0)
                                        // (i.e., mem-to-mem direct copying)!
                                        *(uint16 *)currentLineBuffer = paletteRAM16[index | bits];
                                else
-                                       *currentLineBuffer = 
+                                       *currentLineBuffer =
                                                BLEND_CR(*currentLineBuffer, paletteRAM[(index | bits) << 1]),
-                                       *(currentLineBuffer + 1) = 
+                                       *(currentLineBuffer + 1) =
                                                BLEND_Y(*(currentLineBuffer + 1), paletteRAM[((index | bits) << 1) + 1]);
                        }
 
@@ -1415,9 +1425,9 @@ if (firstPix != 0)
                                        // (i.e., mem-to-mem direct copying)!
                                        *(uint16 *)currentLineBuffer = paletteRAM16[index | bits];
                                else
-                                       *currentLineBuffer = 
+                                       *currentLineBuffer =
                                                BLEND_CR(*currentLineBuffer, paletteRAM[(index | bits) << 1]),
-                                       *(currentLineBuffer + 1) = 
+                                       *(currentLineBuffer + 1) =
                                                BLEND_Y(*(currentLineBuffer + 1), paletteRAM[((index | bits) << 1) + 1]);
                        }
 
@@ -1474,9 +1484,9 @@ if (firstPix != 0)
                                        // (i.e., mem-to-mem direct copying)!
                                        *(uint16 *)currentLineBuffer = paletteRAM16[index | bits];
                                else
-                                       *currentLineBuffer = 
+                                       *currentLineBuffer =
                                                BLEND_CR(*currentLineBuffer, paletteRAM[(index | bits) << 1]),
-                                       *(currentLineBuffer + 1) = 
+                                       *(currentLineBuffer + 1) =
                                                BLEND_Y(*(currentLineBuffer + 1), paletteRAM[((index | bits) << 1) + 1]);
                        }
 
@@ -1536,9 +1546,9 @@ if (firstPix)
                                                *(uint16 *)currentLineBuffer = paletteRAM16[bits];
                                }*/
                                else
-                                       *currentLineBuffer = 
+                                       *currentLineBuffer =
                                                BLEND_CR(*currentLineBuffer, paletteRAM[bits << 1]),
-                                       *(currentLineBuffer + 1) = 
+                                       *(currentLineBuffer + 1) =
                                                BLEND_Y(*(currentLineBuffer + 1), paletteRAM[(bits << 1) + 1]);
                        }
 
@@ -1586,9 +1596,9 @@ if (firstPix != 0)
                                        *currentLineBuffer = bitsHi,
                                        *(currentLineBuffer + 1) = bitsLo;
                                else
-                                       *currentLineBuffer = 
+                                       *currentLineBuffer =
                                                BLEND_CR(*currentLineBuffer, bitsHi),
-                                       *(currentLineBuffer + 1) = 
+                                       *(currentLineBuffer + 1) =
                                                BLEND_Y(*(currentLineBuffer + 1), bitsLo);
                        }