]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/blitter.cpp
1.0.7 update
[virtualjaguar] / src / blitter.cpp
index 9a03a2555413f040e3b5d467786a30d8de4bdbcb..9ecba6f9ddf819c199f14f0ebe45719d35c08dc0 100644 (file)
@@ -340,6 +340,8 @@ if (specialLog)
 {
        WriteLog("  A1_X/Y = %08X/%08X, A2_X/Y = %08X/%08X\n", a1_x, a1_y, a2_x, a2_y);
 }
+               uint32 a1_start = a1_x, a2_start = a2_x;
+
                inner_loop = n_pixels;
                while (inner_loop--)
                {
@@ -702,26 +704,45 @@ Blit! (000B8250 <- 0012C3A0) count: 16 x 1, A1/2_FLAGS: 00014420/00012000 [cmd:
                        // Bump the pointer to the next phrase boundary
                        // Even though it works, this is crappy... Clean it up!
                        uint32 size = 64 / a1_psize;
+
+                       // Crappy kludge... ('aligning' source to destination)
+                       if (a2_phrase_mode && DSTA2)
+                       {
+                               uint32 extra = (a2_start >> 16) % size;
+                               a1_x += extra << 16;
+                       }
+
                        uint32 newx = (a1_x >> 16) / size;
                        uint32 newxrem = (a1_x >> 16) % size;
                        a1_x &= 0x0000FFFF;
                        a1_x |= (((newx + (newxrem == 0 ? 0 : 1)) * size) & 0xFFFF) << 16;
                }
+
                if (a2_phrase_mode)
                {
                        // Bump the pointer to the next phrase boundary
                        // Even though it works, this is crappy... Clean it up!
-                       uint32 size = 64 / a1_psize;
+                       uint32 size = 64 / a2_psize;
+
+                       // Crappy kludge... ('aligning' source to destination)
+                       // Prolly should do this for A1 channel as well...
+                       if (a1_phrase_mode && !DSTA2)
+                       {
+                               uint32 extra = (a1_start >> 16) % size;
+                               a2_x += extra << 16;
+                       }
+
                        uint32 newx = (a2_x >> 16) / size;
                        uint32 newxrem = (a2_x >> 16) % size;
                        a2_x &= 0x0000FFFF;
-                       a2_x |= (((newx + (newxrem == 0 ? 0 : 1)) * size) & 0xFFFF) << 16;
+                       a2_x |= (((newx + (newxrem == 0 ? 0 : 1) /*+ extra*/) * size) & 0xFFFF) << 16;
                }
 
+               //Not entirely: This still mucks things up... !!! FIX !!!
                a1_x += a1_step_x;
                a1_y += a1_step_y;
                a2_x += a2_step_x;
-               a2_y += a2_step_y;
+               a2_y += a2_step_y;//*/
 
 /*             if (a2_phrase_mode)
                {
@@ -838,6 +859,20 @@ void blitter_blit(uint32 cmd)
                a1_yadd = (REG(A1_INC) & 0xFFFF0000) | (REG(A1_FINC) >> 16);
                break;
        }
+
+
+//Blit! (0011D000 -> 000B9600) count: 228 x 1, A1/2_FLAGS: 00073820/00064220 [cmd: 41802801]
+//  A1 -> pitch: 1 phrases, depth: 16bpp, z-off: 0, width: 128 (1C), addctl: XADDINC YADD1 XSIGNADD YSIGNADD
+//  A2 -> pitch: 1 phrases, depth: 16bpp, z-off: 0, width: 320 (21), addctl: XADD0 YADD1 XSIGNADD YSIGNADD
+//if (YADD1_A1 && YADD1_A2 && xadd_a2_control == XADD0 && xadd_a1_control == XADDINC)// &&
+//     UINT32 a1f = REG(A1_FLAGS), a2f = REG(A2_FLAGS);
+//Ok, so this ISN'T it... Prolly the XADDPHR code above that's doing it...
+//if (REG(A1_FLAGS) == 0x00073820 && REG(A2_FLAGS) == 0x00064220 && cmd == 0x41802801)
+//        A1 x/y: 14368/7, A2 x/y: 150/36
+//This is it... The problem...
+//if ((a1_x >> 16) == 14368) // 14368 = $3820
+//     return; //Lesse what we got...
+
        if (XSIGNSUB_A1)
                a1_xadd = -a1_xadd;
 
@@ -871,6 +906,7 @@ WriteLog("BLIT: Asked to use invalid bit combo (XADDINC) for A2...\n");
 //             a2_xadd = 1 << 16;
                break;
        }
+
        if (XSIGNSUB_A2)
                a2_xadd = -a2_xadd;
 
@@ -1128,6 +1164,7 @@ Also fixed!
 More (not sure this is a blitter problem as much as it's a GPU problem):
 All but the "M" are trashed...
 This does *NOT* look like a blitter problem, as it's rendering properly...
+Actually, if you look at the A1 step values, there IS a discrepancy!
 
 ; D
 
@@ -1262,14 +1299,21 @@ uint8 BlitterReadByte(uint32 offset, uint32 who/*=UNKNOWN*/)
        if (offset == (0x38 + 3))
                return 0x01;    // always idle
 
+//Attempted fix for AvP:
+       if (offset >= 0x04 && offset <= 0x07)
+               return (offset > 0x05 ? blitter_ram[PIXLINECOUNTER + offset - 0x04] : 0x00);
+//             return 0x00;    // WO register! What does it expect to see here???
+
        return blitter_ram[offset];
 }
 
+//Crappy!
 uint16 BlitterReadWord(uint32 offset, uint32 who/*=UNKNOWN*/)
 {
        return ((uint16)BlitterReadByte(offset, who) << 8) | (uint16)BlitterReadByte(offset+1, who);
 }
 
+//Crappy!
 uint32 BlitterReadLong(uint32 offset, uint32 who/*=UNKNOWN*/)
 {
        return (BlitterReadWord(offset, who) << 16) | BlitterReadWord(offset+2, who);
@@ -1316,6 +1360,21 @@ void BlitterWriteByte(uint32 offset, uint8 data, uint32 who/*=UNKNOWN*/)
 
 void BlitterWriteWord(uint32 offset, uint16 data, uint32 who/*=UNKNOWN*/)
 {
+//#if 1
+/*     if (offset & 0xFF == A1_PIXEL && data == 14368)
+       {
+               WriteLog("\n1\nA1_PIXEL written by %s (%u)...\n\n\n", whoName[who], data);
+extern bool doGPUDis;
+doGPUDis = true;
+       }
+       if ((offset & 0xFF) == (A1_PIXEL + 2) && data == 14368)
+       {
+               WriteLog("\n2\nA1_PIXEL written by %s (%u)...\n\n\n", whoName[who], data);
+extern bool doGPUDis;
+doGPUDis = true;
+       }//*/
+//#endif
+
        BlitterWriteByte(offset+0, (data>>8) & 0xFF, who);
        BlitterWriteByte(offset+1, data & 0xFF, who);
 
@@ -1323,14 +1382,20 @@ void BlitterWriteWord(uint32 offset, uint16 data, uint32 who/*=UNKNOWN*/)
        // I.e., the second write of 32-bit value--not convinced this is the best way to do this!
        // But then again, according to the Jaguar docs, this is correct...!
                blitter_blit(GET32(blitter_ram, 0x38));
-// Testing purposes only!
-//This does the clipping correctly, but not the Gouraud shading...
-//             blitter2_exec(GET32(blitter_ram, 0x38));
 }
 //F02278,9,A,B
 
 void BlitterWriteLong(uint32 offset, uint32 data, uint32 who/*=UNKNOWN*/)
 {
+//#if 1
+/*     if ((offset & 0xFF) == A1_PIXEL && (data & 0xFFFF) == 14368)
+       {
+               WriteLog("\n3\nA1_PIXEL written by %s (%u)...\n\n\n", whoName[who], data);
+extern bool doGPUDis;
+doGPUDis = true;
+       }//*/
+//#endif
+
        BlitterWriteWord(offset, data >> 16, who);
        BlitterWriteWord(offset+2, data & 0xFFFF, who);
 }