+static void gfx_do(unsigned int func, unsigned short *stamp_base, unsigned int H_Dot)
+{
+ unsigned int eax, ebx, ecx, edx, esi, edi, pixel;
+ unsigned int XD, Buffer_Adr;
+ int DYXS;
+
+ XD = _rot_comp.Reg_60 & 7;
+ Buffer_Adr = ((_rot_comp.Reg_5E & 0xfff8) + _rot_comp.YD) << 2;
+ ecx = *(unsigned int *)(Pico_mcd->word_ram2M + _rot_comp.Vector_Adr);
+ edx = ecx >> 16;
+ ecx = (ecx & 0xffff) << 8;
+ edx <<= 8;
+ DYXS = *(int *)(Pico_mcd->word_ram2M + _rot_comp.Vector_Adr + 4);
+ _rot_comp.Vector_Adr += 8;
+
+ // MAKE_IMAGE_LINE
+ while (H_Dot)
+ {
+ // MAKE_IMAGE_PIXEL
+ if (!(func & 1)) // NOT TILED
+ {
+ int mask = (func & 4) ? 0x00800000 : 0x00f80000;
+ if ((ecx | edx) & mask)
+ {
+ if (func & 0x18) goto Next_Pixel;
+ pixel = 0;
+ goto Pixel_Out;
+ }
+ }
+
+ if (func & 2) // mode 32x32 dot
+ {
+ if (func & 4) // 16x16 screen
+ {
+ ebx = ((ecx >> (11+5)) & 0x007f) |
+ ((edx >> (11-2)) & 0x3f80);
+ }
+ else // 1x1 screen
+ {
+ ebx = ((ecx >> (11+5)) & 0x07) |
+ ((edx >> (11+2)) & 0x38);
+ }
+ }
+ else // mode 16x16 dot
+ {
+ if (func & 4) // 16x16 screen
+ {
+ ebx = ((ecx >> (11+4)) & 0x00ff) |
+ ((edx >> (11-4)) & 0xff00);
+ }
+ else // 1x1 screen
+ {
+ ebx = ((ecx >> (11+4)) & 0x0f) |
+ ((edx >> (11+0)) & 0xf0);
+ }
+ }
+
+ edi = stamp_base[ebx];
+ esi = (edi & 0x7ff) << 7;
+ if (!esi) { pixel = 0; goto Pixel_Out; }
+ edi >>= (11+1);
+ edi &= (0x1c>>1);
+ eax = ecx;
+ ebx = edx;
+ if (func & 2) edi |= 1; // 32 dots?
+ switch (edi)
+ {
+ case 0x00: // No_Flip_0, 16x16 dots
+ ebx = (ebx >> 9) & 0x3c;
+ ebx += esi;
+ edi = (eax & 0x3800) ^ 0x1000; // bswap
+ eax = ((eax >> 8) & 0x40) + ebx;
+ break;
+ case 0x01: // No_Flip_0, 32x32 dots
+ ebx = (ebx >> 9) & 0x7c;
+ ebx += esi;
+ edi = (eax & 0x3800) ^ 0x1000; // bswap
+ eax = ((eax >> 7) & 0x180) + ebx;
+ break;
+ case 0x02: // No_Flip_90, 16x16 dots
+ eax = (eax >> 9) & 0x3c;
+ eax += esi;
+ edi = (ebx & 0x3800) ^ 0x2800; // bswap
+ eax += ((ebx >> 8) & 0x40) ^ 0x40;
+ break;
+ case 0x03: // No_Flip_90, 32x32 dots
+ eax = (eax >> 9) & 0x7c;
+ eax += esi;
+ edi = (ebx & 0x3800) ^ 0x2800; // bswap
+ eax += ((ebx >> 7) & 0x180) ^ 0x180;
+ break;
+ case 0x04: // No_Flip_180, 16x16 dots
+ ebx = ((ebx >> 9) & 0x3c) ^ 0x3c;
+ ebx += esi;
+ edi = (eax & 0x3800) ^ 0x2800; // bswap and flip
+ eax = (((eax >> 8) & 0x40) ^ 0x40) + ebx;
+ break;
+ case 0x05: // No_Flip_180, 32x32 dots
+ ebx = ((ebx >> 9) & 0x7c) ^ 0x7c;
+ ebx += esi;
+ edi = (eax & 0x3800) ^ 0x2800; // bswap and flip
+ eax = (((eax >> 7) & 0x180) ^ 0x180) + ebx;
+ break;
+ case 0x06: // No_Flip_270, 16x16 dots
+ eax = ((eax >> 9) & 0x3c) ^ 0x3c;
+ eax += esi;
+ edi = (ebx & 0x3800) ^ 0x1000; // bswap
+ eax += (ebx >> 8) & 0x40;
+ break;
+ case 0x07: // No_Flip_270, 32x32 dots
+ eax = ((eax >> 9) & 0x7c) ^ 0x7c;
+ eax += esi;
+ edi = (ebx & 0x3800) ^ 0x1000; // bswap
+ eax += (ebx >> 7) & 0x180;
+ break;
+ case 0x08: // Flip_0, 16x16 dots
+ ebx = (ebx >> 9) & 0x3c;
+ ebx += esi;
+ edi = (eax & 0x3800) ^ 0x2800; // bswap, flip
+ eax = (((eax >> 8) & 0x40) ^ 0x40) + ebx;
+ break;
+ case 0x09: // Flip_0, 32x32 dots
+ ebx = (ebx >> 9) & 0x7c;
+ ebx += esi;
+ edi = (eax & 0x3800) ^ 0x2800; // bswap, flip
+ eax = (((eax >> 7) & 0x180) ^ 0x180) + ebx;
+ break;
+ case 0x0a: // Flip_90, 16x16 dots
+ eax = ((eax >> 9) & 0x3c) ^ 0x3c;
+ eax += esi;
+ edi = (ebx & 0x3800) ^ 0x2800; // bswap, flip
+ eax += ((ebx >> 8) & 0x40) ^ 0x40;
+ break;
+ case 0x0b: // Flip_90, 32x32 dots
+ eax = ((eax >> 9) & 0x7c) ^ 0x7c;
+ eax += esi;
+ edi = (ebx & 0x3800) ^ 0x2800; // bswap, flip
+ eax += ((ebx >> 7) & 0x180) ^ 0x180;
+ break;
+ case 0x0c: // Flip_180, 16x16 dots
+ ebx = ((ebx >> 9) & 0x3c) ^ 0x3c;
+ ebx += esi;
+ edi = (eax & 0x3800) ^ 0x1000; // bswap
+ eax = ((eax >> 8) & 0x40) + ebx;
+ break;
+ case 0x0d: // Flip_180, 32x32 dots
+ ebx = ((ebx >> 9) & 0x7c) ^ 0x7c;
+ ebx += esi;
+ edi = (eax & 0x3800) ^ 0x1000; // bswap
+ eax = ((eax >> 7) & 0x180) + ebx;
+ break;
+ case 0x0e: // Flip_270, 16x16 dots
+ eax = (eax >> 9) & 0x3c;
+ eax += esi;
+ edi = (ebx & 0x3800) ^ 0x1000; // bswap, flip
+ eax += (ebx >> 8) & 0x40;
+ break;
+ case 0x0f: // Flip_270, 32x32 dots
+ eax = (eax >> 9) & 0x7c;
+ eax += esi;
+ edi = (ebx & 0x3800) ^ 0x1000; // bswap, flip
+ eax += (ebx >> 7) & 0x180;
+ break;
+ }
+
+ pixel = *(Pico_mcd->word_ram2M + (edi >> 12) + eax);
+ if (!(edi & 0x800)) pixel >>= 4;
+ else pixel &= 0x0f;
+
+Pixel_Out:
+ if (!pixel && (func & 0x18)) goto Next_Pixel;
+ esi = Buffer_Adr + ((XD>>1)^1); // pixel addr
+ eax = *(Pico_mcd->word_ram2M + esi); // old pixel
+ if (XD & 1)
+ {
+ if ((eax & 0x0f) && (func & 0x18) == 0x08) goto Next_Pixel; // underwrite
+ *(Pico_mcd->word_ram2M + esi) = pixel | (eax & 0xf0);
+ }
+ else
+ {
+ if ((eax & 0xf0) && (func & 0x18) == 0x08) goto Next_Pixel; // underwrite
+ *(Pico_mcd->word_ram2M + esi) = (pixel << 4) | (eax & 0xf);
+ }
+
+
+Next_Pixel:
+ ecx += (DYXS << 16) >> 16; // _rot_comp.DXS;
+ edx += DYXS >> 16; // _rot_comp.DYS;
+ XD++;
+ if (XD >= 8)
+ {
+ Buffer_Adr += ((_rot_comp.Reg_5C & 0x1f) + 1) << 5;
+ XD = 0;
+ }
+ H_Dot--;
+ }
+ // end while
+
+
+// nothing_to_draw:
+ _rot_comp.YD++;
+ // _rot_comp.V_Dot--; // will be done by caller
+}