]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/blitter.cpp
Extensive changes to remove gcc 4.x warnings, general code cleanup
[virtualjaguar] / src / blitter.cpp
index 80fe781fa17237c4c15ec5076622d6a591a931b5..c767e5b045c4a2f9ac30d32d0a4714d1ccb11630 100644 (file)
@@ -8,11 +8,17 @@
 // to Curt. ;-) Without that excellent documentation which shows *exactly*
 // what's going on inside the TOM chip, we'd all still be guessing as to how
 // the wily blitter and other pieces of the Jaguar puzzle actually work.
+// Now how about those JERRY ASIC nets gentlemen...? ;-)
 //
 
-#include "jaguar.h"
 #include "blitter.h"
 
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "jaguar.h"
+#include "log.h"
+
 // Various conditional compilation goodies...
 
 //#define USE_ORIGINAL_BLITTER
@@ -47,39 +53,39 @@ void BlitterMidsummer2(void);
 
 // Blitter registers (offsets from F02200)
 
-#define A1_BASE                        ((UINT32)0x00)
-#define A1_FLAGS               ((UINT32)0x04)
-#define A1_CLIP                        ((UINT32)0x08)  // Height and width values for clipping
-#define A1_PIXEL               ((UINT32)0x0C)  // Integer part of the pixel (Y.i and X.i)
-#define A1_STEP                        ((UINT32)0x10)  // Integer part of the step
-#define A1_FSTEP               ((UINT32)0x14)  // Fractional part of the step
-#define A1_FPIXEL              ((UINT32)0x18)  // Fractional part of the pixel (Y.f and X.f)
-#define A1_INC                 ((UINT32)0x1C)  // Integer part of the increment
-#define A1_FINC                        ((UINT32)0x20)  // Fractional part of the increment
-#define A2_BASE                        ((UINT32)0x24)
-#define A2_FLAGS               ((UINT32)0x28)
-#define A2_MASK                        ((UINT32)0x2C)  // Modulo values for x and y (M.y  and M.x)
-#define A2_PIXEL               ((UINT32)0x30)  // Integer part of the pixel (no fractional part for A2)
-#define A2_STEP                        ((UINT32)0x34)  // Integer part of the step (no fractional part for A2)
-#define COMMAND                        ((UINT32)0x38)
-#define PIXLINECOUNTER ((UINT32)0x3C)  // Inner & outer loop values
-#define SRCDATA                        ((UINT32)0x40)
-#define DSTDATA                        ((UINT32)0x48)
-#define DSTZ                   ((UINT32)0x50)
-#define SRCZINT                        ((UINT32)0x58)
-#define SRCZFRAC               ((UINT32)0x60)
-#define PATTERNDATA            ((UINT32)0x68)
-#define INTENSITYINC   ((UINT32)0x70)
-#define ZINC                   ((UINT32)0x74)
-#define COLLISIONCTRL  ((UINT32)0x78)
-#define PHRASEINT0             ((UINT32)0x7C)
-#define PHRASEINT1             ((UINT32)0x80)
-#define PHRASEINT2             ((UINT32)0x84)
-#define PHRASEINT3             ((UINT32)0x88)
-#define PHRASEZ0               ((UINT32)0x8C)
-#define PHRASEZ1               ((UINT32)0x90)
-#define PHRASEZ2               ((UINT32)0x94)
-#define PHRASEZ3               ((UINT32)0x98)
+#define A1_BASE                        ((uint32)0x00)
+#define A1_FLAGS               ((uint32)0x04)
+#define A1_CLIP                        ((uint32)0x08)  // Height and width values for clipping
+#define A1_PIXEL               ((uint32)0x0C)  // Integer part of the pixel (Y.i and X.i)
+#define A1_STEP                        ((uint32)0x10)  // Integer part of the step
+#define A1_FSTEP               ((uint32)0x14)  // Fractional part of the step
+#define A1_FPIXEL              ((uint32)0x18)  // Fractional part of the pixel (Y.f and X.f)
+#define A1_INC                 ((uint32)0x1C)  // Integer part of the increment
+#define A1_FINC                        ((uint32)0x20)  // Fractional part of the increment
+#define A2_BASE                        ((uint32)0x24)
+#define A2_FLAGS               ((uint32)0x28)
+#define A2_MASK                        ((uint32)0x2C)  // Modulo values for x and y (M.y  and M.x)
+#define A2_PIXEL               ((uint32)0x30)  // Integer part of the pixel (no fractional part for A2)
+#define A2_STEP                        ((uint32)0x34)  // Integer part of the step (no fractional part for A2)
+#define COMMAND                        ((uint32)0x38)
+#define PIXLINECOUNTER ((uint32)0x3C)  // Inner & outer loop values
+#define SRCDATA                        ((uint32)0x40)
+#define DSTDATA                        ((uint32)0x48)
+#define DSTZ                   ((uint32)0x50)
+#define SRCZINT                        ((uint32)0x58)
+#define SRCZFRAC               ((uint32)0x60)
+#define PATTERNDATA            ((uint32)0x68)
+#define INTENSITYINC   ((uint32)0x70)
+#define ZINC                   ((uint32)0x74)
+#define COLLISIONCTRL  ((uint32)0x78)
+#define PHRASEINT0             ((uint32)0x7C)
+#define PHRASEINT1             ((uint32)0x80)
+#define PHRASEINT2             ((uint32)0x84)
+#define PHRASEINT3             ((uint32)0x88)
+#define PHRASEZ0               ((uint32)0x8C)
+#define PHRASEZ1               ((uint32)0x90)
+#define PHRASEZ2               ((uint32)0x94)
+#define PHRASEZ3               ((uint32)0x98)
 
 // Blitter command bits
 
@@ -142,34 +148,34 @@ void BlitterMidsummer2(void);
 //Put 'em back, once we fix the problem!!! [KO]
 // 1 bpp pixel read
 #define PIXEL_SHIFT_1(a)      (((~a##_x) >> 16) & 7)
-#define PIXEL_OFFSET_1(a)     (((((UINT32)a##_y >> 16) * a##_width / 8) + (((UINT32)a##_x >> 19) & ~7)) * (1 + a##_pitch) + (((UINT32)a##_x >> 19) & 7))
+#define PIXEL_OFFSET_1(a)     (((((uint32)a##_y >> 16) * a##_width / 8) + (((uint32)a##_x >> 19) & ~7)) * (1 + a##_pitch) + (((uint32)a##_x >> 19) & 7))
 #define READ_PIXEL_1(a)       ((JaguarReadByte(a##_addr+PIXEL_OFFSET_1(a), BLITTER) >> PIXEL_SHIFT_1(a)) & 0x01)
 //#define READ_PIXEL_1(a)       ((JaguarReadByte(a##_addr+PIXEL_OFFSET_1(a)) >> PIXEL_SHIFT_1(a)) & 0x01)
 
 // 2 bpp pixel read
 #define PIXEL_SHIFT_2(a)      (((~a##_x) >> 15) & 6)
-#define PIXEL_OFFSET_2(a)     (((((UINT32)a##_y >> 16) * a##_width / 4) + (((UINT32)a##_x >> 18) & ~7)) * (1 + a##_pitch) + (((UINT32)a##_x >> 18) & 7))
+#define PIXEL_OFFSET_2(a)     (((((uint32)a##_y >> 16) * a##_width / 4) + (((uint32)a##_x >> 18) & ~7)) * (1 + a##_pitch) + (((uint32)a##_x >> 18) & 7))
 #define READ_PIXEL_2(a)       ((JaguarReadByte(a##_addr+PIXEL_OFFSET_2(a), BLITTER) >> PIXEL_SHIFT_2(a)) & 0x03)
 //#define READ_PIXEL_2(a)       ((JaguarReadByte(a##_addr+PIXEL_OFFSET_2(a)) >> PIXEL_SHIFT_2(a)) & 0x03)
 
 // 4 bpp pixel read
 #define PIXEL_SHIFT_4(a)      (((~a##_x) >> 14) & 4)
-#define PIXEL_OFFSET_4(a)     (((((UINT32)a##_y >> 16) * (a##_width/2)) + (((UINT32)a##_x >> 17) & ~7)) * (1 + a##_pitch) + (((UINT32)a##_x >> 17) & 7))
+#define PIXEL_OFFSET_4(a)     (((((uint32)a##_y >> 16) * (a##_width/2)) + (((uint32)a##_x >> 17) & ~7)) * (1 + a##_pitch) + (((uint32)a##_x >> 17) & 7))
 #define READ_PIXEL_4(a)       ((JaguarReadByte(a##_addr+PIXEL_OFFSET_4(a), BLITTER) >> PIXEL_SHIFT_4(a)) & 0x0f)
 //#define READ_PIXEL_4(a)       ((JaguarReadByte(a##_addr+PIXEL_OFFSET_4(a)) >> PIXEL_SHIFT_4(a)) & 0x0f)
 
 // 8 bpp pixel read
-#define PIXEL_OFFSET_8(a)     (((((UINT32)a##_y >> 16) * a##_width) + (((UINT32)a##_x >> 16) & ~7)) * (1 + a##_pitch) + (((UINT32)a##_x >> 16) & 7))
+#define PIXEL_OFFSET_8(a)     (((((uint32)a##_y >> 16) * a##_width) + (((uint32)a##_x >> 16) & ~7)) * (1 + a##_pitch) + (((uint32)a##_x >> 16) & 7))
 #define READ_PIXEL_8(a)       (JaguarReadByte(a##_addr+PIXEL_OFFSET_8(a), BLITTER))
 //#define READ_PIXEL_8(a)       (JaguarReadByte(a##_addr+PIXEL_OFFSET_8(a)))
 
 // 16 bpp pixel read
-#define PIXEL_OFFSET_16(a)    (((((UINT32)a##_y >> 16) * a##_width) + (((UINT32)a##_x >> 16) & ~3)) * (1 + a##_pitch) + (((UINT32)a##_x >> 16) & 3))
+#define PIXEL_OFFSET_16(a)    (((((uint32)a##_y >> 16) * a##_width) + (((uint32)a##_x >> 16) & ~3)) * (1 + a##_pitch) + (((uint32)a##_x >> 16) & 3))
 #define READ_PIXEL_16(a)       (JaguarReadWord(a##_addr+(PIXEL_OFFSET_16(a)<<1), BLITTER))
 //#define READ_PIXEL_16(a)       (JaguarReadWord(a##_addr+(PIXEL_OFFSET_16(a)<<1)))
 
 // 32 bpp pixel read
-#define PIXEL_OFFSET_32(a)    (((((UINT32)a##_y >> 16) * a##_width) + (((UINT32)a##_x >> 16) & ~1)) * (1 + a##_pitch) + (((UINT32)a##_x >> 16) & 1))
+#define PIXEL_OFFSET_32(a)    (((((uint32)a##_y >> 16) * a##_width) + (((uint32)a##_x >> 16) & ~1)) * (1 + a##_pitch) + (((uint32)a##_x >> 16) & 1))
 #define READ_PIXEL_32(a)      (JaguarReadLong(a##_addr+(PIXEL_OFFSET_32(a)<<2), BLITTER))
 //#define READ_PIXEL_32(a)      (JaguarReadLong(a##_addr+(PIXEL_OFFSET_32(a)<<2)))
 
@@ -198,22 +204,22 @@ void BlitterMidsummer2(void);
 #define WRITE_ZDATA(a,f,d) WRITE_ZDATA_16(a,d); 
 
 // 1 bpp r data read
-#define READ_RDATA_1(r,a,p)  ((p) ?  ((REG(r+(((UINT32)a##_x >> 19) & 0x04))) >> (((UINT32)a##_x >> 16) & 0x1F)) & 0x0001 : (REG(r) & 0x0001))
+#define READ_RDATA_1(r,a,p)  ((p) ?  ((REG(r+(((uint32)a##_x >> 19) & 0x04))) >> (((uint32)a##_x >> 16) & 0x1F)) & 0x0001 : (REG(r) & 0x0001))
 
 // 2 bpp r data read
-#define READ_RDATA_2(r,a,p)  ((p) ?  ((REG(r+(((UINT32)a##_x >> 18) & 0x04))) >> (((UINT32)a##_x >> 15) & 0x3E)) & 0x0003 : (REG(r) & 0x0003))
+#define READ_RDATA_2(r,a,p)  ((p) ?  ((REG(r+(((uint32)a##_x >> 18) & 0x04))) >> (((uint32)a##_x >> 15) & 0x3E)) & 0x0003 : (REG(r) & 0x0003))
 
 // 4 bpp r data read
-#define READ_RDATA_4(r,a,p)  ((p) ?  ((REG(r+(((UINT32)a##_x >> 17) & 0x04))) >> (((UINT32)a##_x >> 14) & 0x28)) & 0x000F : (REG(r) & 0x000F))
+#define READ_RDATA_4(r,a,p)  ((p) ?  ((REG(r+(((uint32)a##_x >> 17) & 0x04))) >> (((uint32)a##_x >> 14) & 0x28)) & 0x000F : (REG(r) & 0x000F))
 
 // 8 bpp r data read
-#define READ_RDATA_8(r,a,p)  ((p) ?  ((REG(r+(((UINT32)a##_x >> 16) & 0x04))) >> (((UINT32)a##_x >> 13) & 0x18)) & 0x00FF : (REG(r) & 0x00FF))
+#define READ_RDATA_8(r,a,p)  ((p) ?  ((REG(r+(((uint32)a##_x >> 16) & 0x04))) >> (((uint32)a##_x >> 13) & 0x18)) & 0x00FF : (REG(r) & 0x00FF))
 
 // 16 bpp r data read
-#define READ_RDATA_16(r,a,p)  ((p) ? ((REG(r+(((UINT32)a##_x >> 15) & 0x04))) >> (((UINT32)a##_x >> 12) & 0x10)) & 0xFFFF : (REG(r) & 0xFFFF))
+#define READ_RDATA_16(r,a,p)  ((p) ? ((REG(r+(((uint32)a##_x >> 15) & 0x04))) >> (((uint32)a##_x >> 12) & 0x10)) & 0xFFFF : (REG(r) & 0xFFFF))
 
 // 32 bpp r data read
-#define READ_RDATA_32(r,a,p)  ((p) ? REG(r+(((UINT32)a##_x >> 14) & 0x04)) : REG(r))
+#define READ_RDATA_32(r,a,p)  ((p) ? REG(r+(((uint32)a##_x >> 14) & 0x04)) : REG(r))
 
 // register data read
 #define READ_RDATA(r,a,f,p) (\
@@ -705,7 +711,7 @@ Blit! (00098D90 <- 0081DDC0) count: 320 x 287, A1/2_FLAGS: 00004220/00004020 [cm
 /*if (((REG(A1_FLAGS) >> 3) & 0x07) == 5)
 {
        uint32 offset = a1_addr+(PIXEL_OFFSET_32(a1)<<2);
-// (((((UINT32)a##_y >> 16) * a##_width) + (((UINT32)a##_x >> 16) & ~1)) * (1 + a##_pitch) + (((UINT32)a##_x >> 16) & 1))
+// (((((uint32)a##_y >> 16) * a##_width) + (((uint32)a##_x >> 16) & ~1)) * (1 + a##_pitch) + (((uint32)a##_x >> 16) & 1))
        if ((offset >= 0x1FF020 && offset <= 0x1FF03F) || (offset >= 0x1FF820 && offset <= 0x1FF83F))
                WriteLog("32bpp pixel write: A1 Phrase mode --> ");
 }//*/
@@ -861,7 +867,7 @@ Blit! (00098D90 <- 0081DDC0) count: 320 x 287, A1/2_FLAGS: 00004220/00004020 [cm
 /*if (logGo)
 {
        uint32 offset = a2_addr+(PIXEL_OFFSET_16(a2)<<1);
-// (((((UINT32)a##_y >> 16) * a##_width) + (((UINT32)a##_x >> 16) & ~1)) * (1 + a##_pitch) + (((UINT32)a##_x >> 16) & 1))
+// (((((uint32)a##_y >> 16) * a##_width) + (((uint32)a##_x >> 16) & ~1)) * (1 + a##_pitch) + (((uint32)a##_x >> 16) & 1))
        WriteLog("[%08X:%04X] ", offset, writedata);
 }//*/
                                        // write to the destination
@@ -1107,7 +1113,7 @@ void blitter_blit(uint32 cmd)
 //     a1_width = blitter_scanline_width[((REG(A1_FLAGS) & 0x00007E00) >> 9)];
 // According to JTRM, this must give a *whole number* of phrases in the current
 // pixel size (this means the lookup above is WRONG)... !!! FIX !!!
-       UINT32 m = (REG(A1_FLAGS) >> 9) & 0x03, e = (REG(A1_FLAGS) >> 11) & 0x0F;
+       uint32 m = (REG(A1_FLAGS) >> 9) & 0x03, e = (REG(A1_FLAGS) >> 11) & 0x0F;
        a1_width = ((0x04 | m) << e) >> 2;//*/
 
        a2_x = (REG(A2_PIXEL) & 0x0000FFFF) << 16;
@@ -1170,7 +1176,7 @@ void blitter_blit(uint32 cmd)
 //  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);
+//     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
@@ -1458,14 +1464,14 @@ if (blit_start_log)
        uint32 /*src = cmd & 0x07, dst = (cmd >> 3) & 0x07, misc = (cmd >> 6) & 0x03,
                a1ctl = (cmd >> 8) & 0x07,*/ mode = (cmd >> 11) & 0x07/*, ity = (cmd >> 14) & 0x0F,
                zop = (cmd >> 18) & 0x07, op = (cmd >> 21) & 0x0F, ctrl = (cmd >> 25) & 0x3F*/;
-       UINT32 a1f = REG(A1_FLAGS), a2f = REG(A2_FLAGS);
+       uint32 a1f = REG(A1_FLAGS), a2f = REG(A2_FLAGS);
        uint32 p1 = a1f & 0x07, p2 = a2f & 0x07,
                d1 = (a1f >> 3) & 0x07, d2 = (a2f >> 3) & 0x07,
                zo1 = (a1f >> 6) & 0x07, zo2 = (a2f >> 6) & 0x07,
                w1 = (a1f >> 9) & 0x3F, w2 = (a2f >> 9) & 0x3F,
                ac1 = (a1f >> 16) & 0x1F, ac2 = (a2f >> 16) & 0x1F;
-       UINT32 iw1 = ((0x04 | (w1 & 0x03)) << ((w1 & 0x3C) >> 2)) >> 2;
-       UINT32 iw2 = ((0x04 | (w2 & 0x03)) << ((w2 & 0x3C) >> 2)) >> 2;
+       uint32 iw1 = ((0x04 | (w1 & 0x03)) << ((w1 & 0x3C) >> 2)) >> 2;
+       uint32 iw2 = ((0x04 | (w2 & 0x03)) << ((w2 & 0x3C) >> 2)) >> 2;
        WriteLog("Blit! (%08X %s %08X) count: %d x %d, A1/2_FLAGS: %08X/%08X [cmd: %08X]\n", a1_addr, (mode&0x01 ? "->" : "<-"), a2_addr, n_pixels, n_lines, a1f, a2f, cmd);
 //     WriteLog(" CMD -> src: %d, dst: %d, misc: %d, a1ctl: %d, mode: %d, ity: %1X, z-op: %d, op: %1X, ctrl: %02X\n", src, dst, misc, a1ctl, mode, ity, zop, op, ctrl);
 
@@ -1724,13 +1730,13 @@ doGPUDis = true;
 
 void LogBlit(void)
 {
-       char * opStr[16] = { "LFU_CLEAR", "LFU_NSAND", "LFU_NSAD", "LFU_NOTS", "LFU_SAND", "LFU_NOTD", "LFU_N_SXORD", "LFU_NSORND",
+       const char * opStr[16] = { "LFU_CLEAR", "LFU_NSAND", "LFU_NSAD", "LFU_NOTS", "LFU_SAND", "LFU_NOTD", "LFU_N_SXORD", "LFU_NSORND",
                "LFU_SAD", "LFU_XOR", "LFU_D", "LFU_NSORD", "LFU_REPLACE", "LFU_SORND", "LFU_SORD", "LFU_ONE" };
        uint32 cmd = GET32(blitter_ram, 0x38);
-       UINT32 m = (REG(A1_FLAGS) >> 9) & 0x03, e = (REG(A1_FLAGS) >> 11) & 0x0F;
-       UINT32 a1_width = ((0x04 | m) << e) >> 2;
+       uint32 m = (REG(A1_FLAGS) >> 9) & 0x03, e = (REG(A1_FLAGS) >> 11) & 0x0F;
+       uint32 a1_width = ((0x04 | m) << e) >> 2;
        m = (REG(A2_FLAGS) >> 9) & 0x03, e = (REG(A2_FLAGS) >> 11) & 0x0F;
-       UINT32 a2_width = ((0x04 | m) << e) >> 2;
+       uint32 a2_width = ((0x04 | m) << e) >> 2;
 
        WriteLog("Blit!\n");
        WriteLog("  COMMAND  = %08X\n", cmd);
@@ -1846,7 +1852,7 @@ uint8 a1_phrase_mode, a2_phrase_mode;
        a2_addr = REG(A2_BASE) & 0xFFFFFFF8;
        a1_x = (REG(A1_PIXEL) << 16) | (REG(A1_FPIXEL) & 0xFFFF);
        a1_y = (REG(A1_PIXEL) & 0xFFFF0000) | (REG(A1_FPIXEL) >> 16);
-       UINT32 m = (REG(A1_FLAGS) >> 9) & 0x03, e = (REG(A1_FLAGS) >> 11) & 0x0F;
+       uint32 m = (REG(A1_FLAGS) >> 9) & 0x03, e = (REG(A1_FLAGS) >> 11) & 0x0F;
        a1_width = ((0x04 | m) << e) >> 2;//*/
        a2_x = (REG(A2_PIXEL) & 0x0000FFFF) << 16;
        a2_y = (REG(A2_PIXEL) & 0xFFFF0000);
@@ -2475,10 +2481,10 @@ a1fupdate    A1 step fraction is added to A1 pointer fraction
 goto a1update
 */
 /*
-#define A1_PIXEL               ((UINT32)0x0C)  // Integer part of the pixel (Y.i and X.i)
-#define A1_STEP                        ((UINT32)0x10)  // Integer part of the step
-#define A1_FSTEP               ((UINT32)0x14)  // Fractional part of the step
-#define A1_FPIXEL              ((UINT32)0x18)  // Fractional part of the pixel (Y.f and X.f)
+#define A1_PIXEL               ((uint32)0x0C)  // Integer part of the pixel (Y.i and X.i)
+#define A1_STEP                        ((uint32)0x10)  // Integer part of the step
+#define A1_FSTEP               ((uint32)0x14)  // Fractional part of the step
+#define A1_FPIXEL              ((uint32)0x18)  // Fractional part of the pixel (Y.f and X.f)
 */
 
 // This is all kinda murky. All we have are the Midsummer docs to give us any guidance,
@@ -2666,7 +2672,7 @@ void BlitterMidsummer2(void)
 logBlit = false;
 if (
        cmd != 0x00010200 &&    // PATDSEL
-       cmd != 0x01800001
+       cmd != 0x01800001               // SRCEN LFUFUNC=C
        && cmd != 0x01800005
 //Boot ROM ATARI letters:
        && cmd != 0x00011008    // DSTEN GOURD PATDSEL
@@ -2681,7 +2687,7 @@ if (
 //Static pic on title screen:
        && cmd != 0x01800601    // SRCEN UPDA1 UPDA2 LFUFUNC=C
 //Turning letters on Cybermorph intro screen:
-       && cmd != 0x09800F41    // SRCEN CLIP_A1 UPDA1 UPDA1F UPDA2 DSTA2 LFUFUNC=C DCOMPEN
+//     && cmd != 0x09800F41    // SRCEN CLIP_A1 UPDA1 UPDA1F UPDA2 DSTA2 LFUFUNC=C DCOMPEN
        && cmd != 0x00113078    // DSTEN DSTENZ DSTWRZ CLIP_A1 GOURD GOURZ PATDSEL ZMODE=4
        && cmd != 0x09900F39    // SRCEN DSTEN DSTENZ DSTWRZ UPDA1 UPDA1F UPDA2 DSTA2 ZMODE=4 LFUFUNC=C DCOMPEN
        && cmd != 0x09800209    // SRCEN DSTEN UPDA1 LFUFUNC=C DCOMPEN
@@ -2691,7 +2697,7 @@ if (
 //Hover Strike text:
        && cmd != 0x1401060C    // SRCENX DSTEN UPDA1 UPDA2 PATDSEL BCOMPEN BKGWREN
 //Hover Strike 3D stuff
-//     && cmd != 0x01902839    // SRCEN DSTEN DSTENZ DSTWRZ DSTA2 GOURZ ZMODE=4 LFUFUNC=C
+       && cmd != 0x01902839    // SRCEN DSTEN DSTENZ DSTWRZ DSTA2 GOURZ ZMODE=4 LFUFUNC=C
 //Hover Strike darkening on intro to play (briefing) screen
        && cmd != 0x00020208    // DSTEN UPDA1 ADDDSEL
 //Trevor McFur stuff:
@@ -2700,6 +2706,12 @@ if (
 //T2K:
        && cmd != 0x00011000    // GOURD PATDSEL
        && cmd != 0x00011040    // CLIP_A1 GOURD PATDSEL
+//Checkered flag:
+       && cmd != 0x01800000    // LFUFUNC=C
+       && cmd != 0x01800401    // 
+       && cmd != 0x01800040    // 
+       && cmd != 0x00020008    // 
+//     && cmd != 0x09800F41    // SRCEN CLIP_A1 UPDA1 UPDA1F UPDA2 DSTA2 LFUFUNC=C DCOMPEN
        )
        logBlit = true;//*/
 //logBlit = true;
@@ -2712,8 +2724,17 @@ logBlit = F, cmd = 00011000
 logBlit = F, cmd = 00011040
 logBlit = F, cmd = 01800005 *
 logBlit = F, cmd = 09800741 *
+
 Hover Strike mission selection screen:
 Blit! (CMD = 01902839) // SRCEN DSTEN DSTENZ DSTWRZ DSTA2 GOURZ ZMODE=4 LFUFUNC=C
+
+Checkered Flag blits in the screw up zone:
+Blit! (CMD = 01800001) // SRCEN LFUFUNC=C
+Blit! (CMD = 01800000) // LFUFUNC=C
+Blit! (CMD = 00010000) // PATDSEL
+
+Wolfenstein 3D in the fuckup zone:
+Blit! (CMD = 01800000) // LFUFUNC=C
 */
 
 //printf("logBlit = %s, cmd = %08X\n", (logBlit ? "T" : "F"), cmd);
@@ -3025,7 +3046,9 @@ fflush(stdout);
 #endif
                        idlei = true;
 
-                       return;
+//Instead of a return, let's try breaking out of the loop...
+break;
+//                     return;
                }
                else
                        idlei = false;
@@ -4065,6 +4088,11 @@ uint64 srcd = (srcd2 << (64 - srcshift)) | (srcd1 >> srcshift);
 if (srcshift == 0)
        srcd = srcd1;
 
+//NOTE: This only works with pixel sizes less than 8BPP...
+//DOUBLE NOTE: Still need to do regression testing to ensure that this doesn't break other stuff... !!! CHECK !!!
+if (!phrase_mode && srcshift != 0)
+       srcd = ((srcd2 & 0xFF) << (8 - srcshift)) | ((srcd1 & 0xFF) >> srcshift);
+
 //Z DATA() stuff done here... And it has to be done before any Z shifting...
 //Note that we need to have phrase mode start/end support here... (Not since we moved it from dzwrite...!)
 /*
@@ -4090,7 +4118,7 @@ void ADDARRAY(uint16 * addq, uint8 daddasel, uint8 daddbsel, uint8 daddmode,
        ADDARRAY(addq, 6/*daddasel*/, 7/*daddbsel*/, 1/*daddmode*/, 0, 0, initcin, 0, 0, 0, 0, 0, srcz1, srcz2, zinc, 0);
        srcz1 = ((uint64)addq[3] << 48) | ((uint64)addq[2] << 32) | ((uint64)addq[1] << 16) | (uint64)addq[0];
 
-#ifdef VERBOSE_BLITTER_LOGGING
+#if 0//def VERBOSE_BLITTER_LOGGING
 if (logBlit)
 {
        printf("\n[srcz1=%08X%08X, srcz2=%08X%08X, zinc=%08X",
@@ -4107,7 +4135,7 @@ srcz = (srcz2 << (64 - zSrcShift)) | (srcz1 >> zSrcShift);
 if (zSrcShift == 0)
        srcz = srcz1;
 
-#ifdef VERBOSE_BLITTER_LOGGING
+#if 0//def VERBOSE_BLITTER_LOGGING
 if (logBlit)
 {
        printf(" srcz=%08X%08X]\n", (uint32)(srcz >> 32), (uint32)(srcz & 0xFFFFFFFF));
@@ -4264,7 +4292,7 @@ if (!winhibit)
 #ifdef VERBOSE_BLITTER_LOGGING
 if (logBlit)
 {
-       printf(" [%08X%08X]", (uint32)(wdata >> 32), (uint32)(wdata & 0xFFFFFFFF));
+       printf(" [%08X%08X]%s", (uint32)(wdata >> 32), (uint32)(wdata & 0xFFFFFFFF), (winhibit ? "[X]" : ""));
        printf(" (icount=%04X, inc=%u)\n", icount, (uint16)inc);
        printf("    [dstart=%X dend=%X pwidth=%X srcshift=%X]", dstart, dend, pwidth, srcshift);
        printf("[daas=%X dabs=%X dam=%X ds=%X daq=%s]\n", daddasel, daddbsel, daddmode, data_sel, (daddq_sel ? "T" : "F"));
@@ -4322,6 +4350,66 @@ if (logBlit)
 #endif
                                }
 
+/*
+This is because the address generator was using only 15 bits of the X when it should have
+used 16!
+
+There's a slight problem here: The X pointer isn't wrapping like it should when it hits
+the edge of the window... Notice how the X isn't reset at the edge of the window:
+
+Blit! (CMD = 00010000)
+Flags: PATDSEL
+  count = 160 x 261
+  a1_base = 000E8008, a2_base = 0001FA68
+  a1_x = 0000, a1_y = 0000, a1_frac_x = 0000, a1_frac_y = 0000, a2_x = 0000, a2_y = 0000
+  a1_step_x = 0000, a1_step_y = 0000, a1_stepf_x = 0000, a1_stepf_y = 0000, a2_step_x = 0000, a2_step_y = 0000
+  a1_inc_x = 0000, a1_inc_y = 0000, a1_incf_x = 0000, a1_incf_y = 0000
+  a1_win_x = 0000, a1_win_y = 0000, a2_mask_x = 0000, a2_mask_y = 0000
+  a2_mask=F a1add=+phr/+0 a2add=+phr/+0
+  a1_pixsize = 5, a2_pixsize = 5
+   srcd=7717771777177717  dstd=0000000000000000 patd=7730773077307730 iinc=00000000
+  srcz1=0000000000000000 srcz2=0000000000000000 dstz=0000000000000000 zinc=00000000, coll=0
+  Phrase mode is ON
+  [in=T a1f=F a1=F zf=F z=F a2=F iif=F iii=F izf=F izi=F]
+  Entering INNER state...
+  Entering DWRITE state...     Dest write address/pix address: 000E8008/0 [7730773077307730] (icount=009E, inc=2)
+ srcz=0000000000000000][dcomp=AA zcomp=00 dbinh=00]
+[srcz=0000000000000000 dstz=0000000000000000 zwdata=0000000000000000 mask=7FFF]
+    [dstart=0 dend=40 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=0 daq=F]
+  Entering A1_ADD state [a1_x=0000, a1_y=0000, addasel=0, addbsel=0, modx=1, addareg=F, adda_xconst=1, adda_yconst=0]...
+  Entering DWRITE state...     Dest write address/pix address: 000E8018/0 [7730773077307730] (icount=009C, inc=2)
+ srcz=0000000000000000][dcomp=AA zcomp=00 dbinh=00]
+[srcz=0000000000000000 dstz=0000000000000000 zwdata=0000000000000000 mask=7FFF]
+    [dstart=0 dend=40 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=0 daq=F]
+  Entering A1_ADD state [a1_x=0002, a1_y=0000, addasel=0, addbsel=0, modx=1, addareg=F, adda_xconst=1, adda_yconst=0]...
+
+...
+
+  Entering A1_ADD state [a1_x=009C, a1_y=0000, addasel=0, addbsel=0, modx=1, addareg=F, adda_xconst=1, adda_yconst=0]...
+  Entering DWRITE state...     Dest write address/pix address: 000E84F8/0 [7730773077307730] (icount=0000, inc=2)
+ srcz=0000000000000000][dcomp=AA zcomp=00 dbinh=00]
+[srcz=0000000000000000 dstz=0000000000000000 zwdata=0000000000000000 mask=7FFF]
+    [dstart=0 dend=40 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=0 daq=F]
+  Entering A1_ADD state [a1_x=009E, a1_y=0000, addasel=0, addbsel=0, modx=1, addareg=F, adda_xconst=1, adda_yconst=0]...
+  Entering IDLE_INNER state...
+
+  Leaving INNER state... (ocount=0104)
+  [in=T a1f=F a1=F zf=F z=F a2=F iif=F iii=F izf=F izi=F]
+
+  Entering INNER state...
+  Entering DWRITE state...     Dest write address/pix address: 000E8508/0 [7730773077307730] (icount=009E, inc=2)
+ srcz=0000000000000000][dcomp=AA zcomp=00 dbinh=00]
+[srcz=0000000000000000 dstz=0000000000000000 zwdata=0000000000000000 mask=7FFF]
+    [dstart=0 dend=40 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=0 daq=F]
+  Entering A1_ADD state [a1_x=00A0, a1_y=0000, addasel=0, addbsel=0, modx=1, addareg=F, adda_xconst=1, adda_yconst=0]...
+  Entering DWRITE state...     Dest write address/pix address: 000E8518/0 [7730773077307730] (icount=009C, inc=2)
+ srcz=0000000000000000][dcomp=AA zcomp=00 dbinh=00]
+[srcz=0000000000000000 dstz=0000000000000000 zwdata=0000000000000000 mask=7FFF]
+    [dstart=0 dend=40 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=0 daq=F]
+  Entering A1_ADD state [a1_x=00A2, a1_y=0000, addasel=0, addbsel=0, modx=1, addareg=F, adda_xconst=1, adda_yconst=0]...
+
+*/
+
                                if (a1_add)
                                {
 #ifdef VERBOSE_BLITTER_LOGGING
@@ -4551,122 +4639,86 @@ fflush(stdout);
                }
        }
 
+// We never get here! !!! FIX !!!
+
+#ifdef VERBOSE_BLITTER_LOGGING
+if (logBlit)
+{
+       printf("Done!\na1_x=%04X a1_y=%04X a1_frac_x=%04X a1_frac_y=%04X a2_x=%04X a2_y%04X\n", 
+               GET16(blitter_ram, A1_PIXEL + 2),
+               GET16(blitter_ram, A1_PIXEL + 0),
+               GET16(blitter_ram, A1_FPIXEL + 2),
+               GET16(blitter_ram, A1_FPIXEL + 0),
+               GET16(blitter_ram, A2_PIXEL + 2),
+               GET16(blitter_ram, A2_PIXEL + 0));
+       fflush(stdout);
+}
+#endif
+
        // Write values back to registers (in real blitter, these are continuously updated)
-       SET16(blitter_ram, A1_PIXEL + 0, a1_y);
        SET16(blitter_ram, A1_PIXEL + 2, a1_x);
-       SET16(blitter_ram, A1_FPIXEL + 0, a1_frac_y);
+       SET16(blitter_ram, A1_PIXEL + 0, a1_y);
        SET16(blitter_ram, A1_FPIXEL + 2, a1_frac_x);
-       SET16(blitter_ram, A2_PIXEL + 0, a2_y);
+       SET16(blitter_ram, A1_FPIXEL + 0, a1_frac_y);
        SET16(blitter_ram, A2_PIXEL + 2, a2_x);
-}
+       SET16(blitter_ram, A2_PIXEL + 0, a2_y);
 
+#ifdef VERBOSE_BLITTER_LOGGING
+if (logBlit)
+{
+       printf("Writeback!\na1_x=%04X a1_y=%04X a1_frac_x=%04X a1_frac_y=%04X a2_x=%04X a2_y%04X\n", 
+               GET16(blitter_ram, A1_PIXEL + 2),
+               GET16(blitter_ram, A1_PIXEL + 0),
+               GET16(blitter_ram, A1_FPIXEL + 2),
+               GET16(blitter_ram, A1_FPIXEL + 0),
+               GET16(blitter_ram, A2_PIXEL + 2),
+               GET16(blitter_ram, A2_PIXEL + 0));
+       fflush(stdout);
+}
+#endif
+}
 
 /*
-The latest that doesn't work properly:
-
-Blit! (CMD = 09800741)
-Flags: SRCEN CLIP_A1 UPDA1 UPDA1F UPDA2 LFUFUNC=C DCOMPEN
-  count = 15 x 18
-  a1_base = 00050000, a2_base = 0083F400
-  a1_x = 003D, a1_y = 00AD, a1_frac_x = 8000, a1_frac_y = 0000, a2_x = 0027, a2_y = 00A4
-  a1_step_x = FFF1, a1_step_y = 0001, a1_stepf_x = 0000, a1_stepf_y = 0000, a2_step_x = FFF1, a2_step_y = 0001
-  a1_inc_x = 0001, a1_inc_y = 0000, a1_incf_x = 0000, a1_incf_y = 0000
-  a1_win_x = 0180, a1_win_y = 0118, a2_mask_x = 0000, a2_mask_y = 0000
-  a2_mask=F a1add=+inc/+0 a2add=+1/+0
-  a1_pixsize = 4, a2_pixsize = 4
-   srcd=0000000000000000  dstd=0000000000000000 patd=0000000000000000 iinc=00FFF000
-  srcz1=0000000000000000 srcz2=0000000000000000 dstz=0000000000000000 zinc=00000000, col=2
-  Phrase mode is off
-  [in=T a1f=F a1=F zf=F z=F a2=F iif=F iii=F izf=F izi=F]
-  Entering INNER state...
-  Entering SREAD state...    Source read address/pix address: 00858E4E/0 [0000000000000000]
-  Entering A2_ADD state [a2_x=0027, a2_y=00A4, addasel=0, addbsel=1, modx=0, addareg=F, adda_xconst=0, adda_yconst=0]...
-  Entering DWRITE state...
-     Dest write address/pix address: 0007077A/0 [dstart=0 dend=10 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=1 daq=F] [0000000000000000] (icount=000E, inc=1)
-  Entering A1_ADD state [a1_x=003D, a1_y=00AD, addasel=3, addbsel=2, modx=0, addareg=T, adda_xconst=7, adda_yconst=0]...
-  Entering SREAD state...    Source read address/pix address: 00858E50/0 [0000000000000000]
-  Entering A2_ADD state [a2_x=0028, a2_y=00A4, addasel=0, addbsel=1, modx=0, addareg=F, adda_xconst=0, adda_yconst=0]...
-  Entering DWRITE state...
-     Dest write address/pix address: 0007077C/0 [dstart=0 dend=10 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=1 daq=F] [0000000000000000] (icount=000D, inc=1)
-  Entering A1_ADD state [a1_x=003E, a1_y=00AD, addasel=3, addbsel=2, modx=0, addareg=T, adda_xconst=7, adda_yconst=0]...
-  Entering SREAD state...    Source read address/pix address: 00858E52/0 [0000000000000000]
-  Entering A2_ADD state [a2_x=0029, a2_y=00A4, addasel=0, addbsel=1, modx=0, addareg=F, adda_xconst=0, adda_yconst=0]...
-  Entering DWRITE state...
-     Dest write address/pix address: 0007077E/0 [dstart=0 dend=10 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=1 daq=F] [0000000000000000] (icount=000C, inc=1)
-  Entering A1_ADD state [a1_x=003F, a1_y=00AD, addasel=3, addbsel=2, modx=0, addareg=T, adda_xconst=7, adda_yconst=0]...
-  Entering SREAD state...    Source read address/pix address: 00858E54/0 [000000000000014A]
-  Entering A2_ADD state [a2_x=002A, a2_y=00A4, addasel=0, addbsel=1, modx=0, addareg=F, adda_xconst=0, adda_yconst=0]...
-  Entering DWRITE state...
-     Dest write address/pix address: 00070780/0 [dstart=0 dend=10 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=1 daq=F] [000000000000014A] (icount=000B, inc=1)
-  Entering A1_ADD state [a1_x=0040, a1_y=00AD, addasel=3, addbsel=2, modx=0, addareg=T, adda_xconst=7, adda_yconst=0]...
-  Entering SREAD state...    Source read address/pix address: 00858E56/0 [000000000000014A]
-  Entering A2_ADD state [a2_x=002B, a2_y=00A4, addasel=0, addbsel=1, modx=0, addareg=F, adda_xconst=0, adda_yconst=0]...
-  Entering DWRITE state...
-     Dest write address/pix address: 00070782/0 [dstart=0 dend=10 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=1 daq=F] [000000000000014A] (icount=000A, inc=1)
-  Entering A1_ADD state [a1_x=0041, a1_y=00AD, addasel=3, addbsel=2, modx=0, addareg=T, adda_xconst=7, adda_yconst=0]...
-  Entering SREAD state...    Source read address/pix address: 00858E58/0 [000000000000014A]
-  Entering A2_ADD state [a2_x=002C, a2_y=00A4, addasel=0, addbsel=1, modx=0, addareg=F, adda_xconst=0, adda_yconst=0]...
-  Entering DWRITE state...
-     Dest write address/pix address: 00070784/0 [dstart=0 dend=10 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=1 daq=F] [000000000000014A] (icount=0009, inc=1)
-  Entering A1_ADD state [a1_x=0042, a1_y=00AD, addasel=3, addbsel=2, modx=0, addareg=T, adda_xconst=7, adda_yconst=0]...
-  Entering SREAD state...    Source read address/pix address: 00858E5A/0 [000000000000014A]
-  Entering A2_ADD state [a2_x=002D, a2_y=00A4, addasel=0, addbsel=1, modx=0, addareg=F, adda_xconst=0, adda_yconst=0]...
-  Entering DWRITE state...
-     Dest write address/pix address: 00070786/0 [dstart=0 dend=10 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=1 daq=F] [000000000000014A] (icount=0008, inc=1)
-  Entering A1_ADD state [a1_x=0043, a1_y=00AD, addasel=3, addbsel=2, modx=0, addareg=T, adda_xconst=7, adda_yconst=0]...
-  Entering SREAD state...    Source read address/pix address: 00858E5C/0 [000000000000014A]
-  Entering A2_ADD state [a2_x=002E, a2_y=00A4, addasel=0, addbsel=1, modx=0, addareg=F, adda_xconst=0, adda_yconst=0]...
-  Entering DWRITE state...
-     Dest write address/pix address: 00070788/0 [dstart=0 dend=10 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=1 daq=F] [000000000000014A] (icount=0007, inc=1)
-  Entering A1_ADD state [a1_x=0044, a1_y=00AD, addasel=3, addbsel=2, modx=0, addareg=T, adda_xconst=7, adda_yconst=0]...
-  Entering SREAD state...    Source read address/pix address: 00858E5E/0 [000000000000014A]
-  Entering A2_ADD state [a2_x=002F, a2_y=00A4, addasel=0, addbsel=1, modx=0, addareg=F, adda_xconst=0, adda_yconst=0]...
-  Entering DWRITE state...
-     Dest write address/pix address: 0007078A/0 [dstart=0 dend=10 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=1 daq=F] [000000000000014A] (icount=0006, inc=1)
-  Entering A1_ADD state [a1_x=0045, a1_y=00AD, addasel=3, addbsel=2, modx=0, addareg=T, adda_xconst=7, adda_yconst=0]...
-  Entering SREAD state...    Source read address/pix address: 00858E60/0 [000000000000014A]
-  Entering A2_ADD state [a2_x=0030, a2_y=00A4, addasel=0, addbsel=1, modx=0, addareg=F, adda_xconst=0, adda_yconst=0]...
-  Entering DWRITE state...
-     Dest write address/pix address: 0007078C/0 [dstart=0 dend=10 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=1 daq=F] [000000000000014A] (icount=0005, inc=1)
-  Entering A1_ADD state [a1_x=0046, a1_y=00AD, addasel=3, addbsel=2, modx=0, addareg=T, adda_xconst=7, adda_yconst=0]...
-  Entering SREAD state...    Source read address/pix address: 00858E62/0 [000000000000014A]
-  Entering A2_ADD state [a2_x=0031, a2_y=00A4, addasel=0, addbsel=1, modx=0, addareg=F, adda_xconst=0, adda_yconst=0]...
-  Entering DWRITE state...
-     Dest write address/pix address: 0007078E/0 [dstart=0 dend=10 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=1 daq=F] [000000000000014A] (icount=0004, inc=1)
-  Entering A1_ADD state [a1_x=0047, a1_y=00AD, addasel=3, addbsel=2, modx=0, addareg=T, adda_xconst=7, adda_yconst=0]...
-  Entering SREAD state...    Source read address/pix address: 00858E64/0 [000000000000014A]
-  Entering A2_ADD state [a2_x=0032, a2_y=00A4, addasel=0, addbsel=1, modx=0, addareg=F, adda_xconst=0, adda_yconst=0]...
-  Entering DWRITE state...
-     Dest write address/pix address: 00070790/0 [dstart=0 dend=10 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=1 daq=F] [000000000000014A] (icount=0003, inc=1)
-  Entering A1_ADD state [a1_x=0048, a1_y=00AD, addasel=3, addbsel=2, modx=0, addareg=T, adda_xconst=7, adda_yconst=0]...
-  Entering SREAD state...    Source read address/pix address: 00858E66/0 [0000000000000000]
-  Entering A2_ADD state [a2_x=0033, a2_y=00A4, addasel=0, addbsel=1, modx=0, addareg=F, adda_xconst=0, adda_yconst=0]...
-  Entering DWRITE state...
-     Dest write address/pix address: 00070792/0 [dstart=0 dend=10 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=1 daq=F] [0000000000000000] (icount=0002, inc=1)
-  Entering A1_ADD state [a1_x=0049, a1_y=00AD, addasel=3, addbsel=2, modx=0, addareg=T, adda_xconst=7, adda_yconst=0]...
-  Entering SREAD state...    Source read address/pix address: 00858E68/0 [0000000000000000]
-  Entering A2_ADD state [a2_x=0034, a2_y=00A4, addasel=0, addbsel=1, modx=0, addareg=F, adda_xconst=0, adda_yconst=0]...
-  Entering DWRITE state...
-     Dest write address/pix address: 00070794/0 [dstart=0 dend=10 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=1 daq=F] [0000000000000000] (icount=0001, inc=1)
-  Entering A1_ADD state [a1_x=004A, a1_y=00AD, addasel=3, addbsel=2, modx=0, addareg=T, adda_xconst=7, adda_yconst=0]...
-  Entering SREAD state...    Source read address/pix address: 00858E6A/0 [0000000000000000]
-  Entering A2_ADD state [a2_x=0035, a2_y=00A4, addasel=0, addbsel=1, modx=0, addareg=F, adda_xconst=0, adda_yconst=0]...
-  Entering DWRITE state...
-     Dest write address/pix address: 00070796/0 [dstart=0 dend=10 pwidth=8 srcshift=0][daas=0 dabs=0 dam=7 ds=1 daq=F] [0000000000000000] (icount=0000, inc=1)
-  Entering A1_ADD state [a1_x=004B, a1_y=00AD, addasel=3, addbsel=2, modx=0, addareg=T, adda_xconst=7, adda_yconst=0]...
-  Entering IDLE_INNER state...
-  Leaving INNER state... (ocount=0011)
-  [in=F a1f=T a1=F zf=F z=F a2=F iif=F iii=F izf=F izi=F]
-  Entering A1FUPDATE state...
-  [in=F a1f=F a1=T zf=F z=F a2=F iif=F iii=F izf=F izi=F]
-  Entering A1UPDATE state... (76/173 -> 61/174)
-  [in=F a1f=F a1=F zf=F z=F a2=T iif=F iii=F izf=F izi=F]
-  Entering A2UPDATE state... (54/164 -> 39/165)
-  [in=T a1f=F a1=F zf=F z=F a2=F iif=F iii=F izf=F izi=F]
-  Entering INNER state...
+       int16 a1_x = (int16)GET16(blitter_ram, A1_PIXEL + 2);
+       int16 a1_y = (int16)GET16(blitter_ram, A1_PIXEL + 0);
+       uint16 a1_frac_x = GET16(blitter_ram, A1_FPIXEL + 2);
+       uint16 a1_frac_y = GET16(blitter_ram, A1_FPIXEL + 0);
+       int16 a2_x = (int16)GET16(blitter_ram, A2_PIXEL + 2);
+       int16 a2_y = (int16)GET16(blitter_ram, A2_PIXEL + 0);
+
+Seems that the ending a1_x should be written between blits, but it doesn't seem to be...
+
+Blit! (CMD = 01800000)
+Flags: LFUFUNC=C
+  count = 28672 x 1
+  a1_base = 00050000, a2_base = 00070000
+  a1_x = 0000, a1_y = 0000, a1_frac_x = 49CD, a1_frac_y = 0000, a2_x = 0033, a2_y = 0001
+  a1_step_x = 0000, a1_step_y = 0000, a1_stepf_x = 939A, a1_stepf_y = 0000, a2_step_x = 0000, a2_step_y = 0000
+  a1_inc_x = 0000, a1_inc_y = 0000, a1_incf_x = 0000, a1_incf_y = 0000
+  a1_win_x = 0100, a1_win_y = 0020, a2_mask_x = 0000, a2_mask_y = 0000
+  a2_mask=F a1add=+phr/+0 a2add=+phr/+0
+  a1_pixsize = 4, a2_pixsize = 3
+   srcd=DEDEDEDEDEDEDEDE  dstd=0000000000000000 patd=0000000000000000 iinc=00000000
+  srcz1=0000000000000000 srcz2=0000000000000000 dstz=0000000000000000 zinc=00000000, coll=0
+  Phrase mode is ON
+
+Blit! (CMD = 01800000)
+Flags: LFUFUNC=C
+  count = 28672 x 1
+  a1_base = 00050000, a2_base = 00070000
+  a1_x = 0000, a1_y = 0000, a1_frac_x = 49CD, a1_frac_y = 0000, a2_x = 0033, a2_y = 0001
+  a1_step_x = 0000, a1_step_y = 0000, a1_stepf_x = 939A, a1_stepf_y = 0000, a2_step_x = 0000, a2_step_y = 0000
+  a1_inc_x = 0000, a1_inc_y = 0000, a1_incf_x = 0000, a1_incf_y = 0000
+  a1_win_x = 0100, a1_win_y = 0020, a2_mask_x = 0000, a2_mask_y = 0000
+  a2_mask=F a1add=+phr/+0 a2add=+phr/+0
+  a1_pixsize = 4, a2_pixsize = 3
+   srcd=D6D6D6D6D6D6D6D6  dstd=0000000000000000 patd=0000000000000000 iinc=00000000
+  srcz1=0000000000000000 srcz2=0000000000000000 dstz=0000000000000000 zinc=00000000, coll=0
+  Phrase mode is ON
 */
 
 
+
 // Various pieces of the blitter puzzle are teased out here...
 
 
@@ -4701,7 +4753,8 @@ void ADDRGEN(uint32 &address, uint32 &pixa, bool gena2, bool zaddr,
        uint16 a1_x, uint16 a1_y, uint32 a1_base, uint8 a1_pitch, uint8 a1_pixsize, uint8 a1_width, uint8 a1_zoffset,
        uint16 a2_x, uint16 a2_y, uint32 a2_base, uint8 a2_pitch, uint8 a2_pixsize, uint8 a2_width, uint8 a2_zoffset)
 {
-       uint16 x = (gena2 ? a2_x : a1_x) & 0x7FFF;
+//     uint16 x = (gena2 ? a2_x : a1_x) & 0x7FFF;
+       uint16 x = (gena2 ? a2_x : a1_x) & 0xFFFF;      // Actually uses all 16 bits to generate address...!
        uint16 y = (gena2 ? a2_y : a1_y) & 0x0FFF;
        uint8 width = (gena2 ? a2_width : a1_width);
        uint8 pixsize = (gena2 ? a2_pixsize : a1_pixsize);
@@ -6162,4 +6215,9 @@ if (logBlit)
 ////////////////////////////////////// C++ CODE //////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////////////
 
+// !!! TESTING !!! TESTING !!! TESTING !!! TESTING !!! TESTING !!! TESTING !!! TESTING !!!
+// !!! TESTING !!! TESTING !!! TESTING !!! TESTING !!! TESTING !!! TESTING !!! TESTING !!!
+// !!! TESTING !!! TESTING !!! TESTING !!! TESTING !!! TESTING !!! TESTING !!! TESTING !!!
+
 #endif
+