X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fobjectp.cpp;h=fc1c64829ebd1eb556bbe0c9b7b396d7b80988c3;hb=14156207e8d43ebee364b73a804b5357613ce0c5;hp=cee49356ccdd92889d84d60e7398e291343c8686;hpb=5be21f57bdb7fca0e5bbd2c90de302827e5d8d3a;p=virtualjaguar diff --git a/src/objectp.cpp b/src/objectp.cpp index cee4935..fc1c648 100644 --- a/src/objectp.cpp +++ b/src/objectp.cpp @@ -1,12 +1,12 @@ // // Object Processor // -// Original source by Cal2 +// 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 // -#include +//#include #include #include #include "jaguar.h" @@ -17,11 +17,11 @@ #define BLEND_Y(dst, src) op_blend_y[(((uint16)dst<<8)) | ((uint16)(src))] #define BLEND_CR(dst, src) op_blend_cr[(((uint16)dst)<<8) | ((uint16)(src))] -#define OBJECT_TYPE_BITMAP 0 // 000 -#define OBJECT_TYPE_SCALE 1 // 001 -#define OBJECT_TYPE_GPU 2 // 010 -#define OBJECT_TYPE_BRANCH 3 // 011 -#define OBJECT_TYPE_STOP 4 // 100 +#define OBJECT_TYPE_BITMAP 0 // 000 +#define OBJECT_TYPE_SCALE 1 // 001 +#define OBJECT_TYPE_GPU 2 // 010 +#define OBJECT_TYPE_BRANCH 3 // 011 +#define OBJECT_TYPE_STOP 4 // 100 #define CONDITION_EQUAL 0 #define CONDITION_LESS_THAN 1 @@ -29,10 +29,10 @@ #define CONDITION_OP_FLAG_SET 3 #define CONDITION_SECOND_HALF_LINE 4 -#define OPFLAG_RELEASE 8 // Bus release bit -#define OPFLAG_TRANS 4 // Transparency bit -#define OPFLAG_RMW 2 // Read-Modify-Write bit -#define OPFLAG_REFLECT 1 // Horizontal mirror bit +#define OPFLAG_RELEASE 8 // Bus release bit +#define OPFLAG_TRANS 4 // Transparency bit +#define OPFLAG_RMW 2 // Read-Modify-Write bit +#define OPFLAG_REFLECT 1 // Horizontal mirror bit // Private function prototypes @@ -83,23 +83,28 @@ void op_init(void) int dc2 = (INT8)(i & 0xF0) >> 4; // Sign extend the C index y += dy; + if (y < 0) y = 0; else if (y > 0xFF) y = 0xFF; + op_blend_y[i] = y; c1 += dc1; + if (c1 < 0) c1 = 0; else if (c1 > 0x0F) c1 = 0x0F; + c2 += dc2; if (c2 < 0) c2 = 0; else if (c2 > 0x0F) c2 = 0x0F; + op_blend_cr[i] = (c2 << 4) | c1; } @@ -143,6 +148,9 @@ void op_done(void) DumpScaledObject(op_load_phrase(olp+i), op_load_phrase(olp+i+8), op_load_phrase(olp+i+16)); } WriteLog("\n"); + + memory_free(op_blend_y); + memory_free(op_blend_cr); } // @@ -327,6 +335,8 @@ bool inhibit; int bitmapCounter = 0; // *** END OP PROCESSOR TESTING ONLY *** + uint32 opCyclesToRun = 10000; // This is a pulled-out-of-the-air value (will need to be fixed, obviously!) + // if (op_pointer) WriteLog(" new op list at 0x%.8x scanline %i\n",op_pointer,scanline); while (op_pointer) { @@ -344,6 +354,7 @@ else op_pointer += 8; if (scanline == tom_get_vdb() && op_start_log) //if (scanline == 215 && op_start_log) +//if (scanline == 28 && op_start_log) { WriteLog("%08X --> phrase %08X %08X", op_pointer - 8, (int)(p0>>32), (int)(p0&0xFFFFFFFF)); if ((p0 & 0x07) == OBJECT_TYPE_BITMAP) @@ -472,8 +483,9 @@ if (!inhibit) // For OP testing only! //Temp, for testing... //No doubt, this type of check will break all kinds of stuff... !!! FIX !!! //And it does! !!! FIX !!! - if (op_pointer > ((p0 & 0x000007FFFF000000LL) >> 21)) - return; +//Let's remove this "fix" since it screws up more than it fixes. +/* if (op_pointer > ((p0 & 0x000007FFFF000000LL) >> 21)) + return;*/ op_pointer = (p0 & 0x000007FFFF000000LL) >> 21; //WriteLog("New OP: %08X\n", op_pointer); @@ -677,6 +689,13 @@ OP: Scaled bitmap 4x? 4bpp at 34,? hscale=80 fpix=0 data=000756E8 pitch 1 hflipp 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 !!! + opCyclesToRun--; + if (!opCyclesToRun) + return; } } @@ -1129,8 +1148,10 @@ if (firstPix) uint16 * paletteRAM16 = (uint16 *)paletteRAM; uint8 hscale = p2 & 0xFF; -// uint8 horizontalRemainder = hscale; // Not sure if it starts full, but seems reasonable [It's not!] - uint8 horizontalRemainder = 0; // Let's try zero! Seems to work! Yay! +// Hmm. It seems that fixing the horizontal scale necessitated re-fixing this. Not sure why, +// but seems to be consistent with the vertical scaling now (and it may turn out to be wrong!)... + uint8 horizontalRemainder = hscale; // Not sure if it starts full, but seems reasonable [It's not!] +// uint8 horizontalRemainder = 0; // Let's try zero! Seems to work! Yay! [No, it doesn't!] int32 scaledWidthInPixels = (iwidth * phraseWidthToPixels[depth] * hscale) >> 5; uint32 scaledPhrasePixels = (phraseWidthToPixels[depth] * hscale) >> 5; @@ -1587,7 +1608,7 @@ if (firstPix != 0) pixels <<= 16; } horizontalRemainder -= 0x20; // Subtract 1.0f in [3.5] fixed point format - +//*/ if (pixCount > 3) { int phrasesToSkip = pixCount / 4, pixelShift = pixCount % 4;