for(int i = 0; i < 240; i+=2) { for(int m = 1; m < mosaicX; m++) { line[i] = line[i-1]; i++;
if(mosaicX > 1) { int m = 1; for(int i = 0; i < 239; i++) { line[i+1] = line[i]; m++; if(m == mosaicX) { m = 1; i++; }
inline void gfxDrawRotScreen(u16 control,                              u16 x_l, u16 x_h,                             u16 y_l, u16 y_h,                             u16 pa,  u16 pb,                             u16 pc,  u16 pd,                             int& currentX, int& currentY,                             int changed,                             u32 *line){  u16 *palette = (u16 *)paletteRAM;  u8 *charBase = &vram[((control >> 2) & 0x03) * 0x4000];  u8 *screenBase = (u8 *)&vram[((control >> 8) & 0x1f) * 0x800];  int prio = ((control & 3) << 25) + 0x1000000;  int sizeX = 128;  int sizeY = 128;  switch((control >> 14) & 3) {  case 0:    break;  case 1:    sizeX = sizeY = 256;    break;  case 2:    sizeX = sizeY = 512;    break;  case 3:    sizeX = sizeY = 1024;    break;  }  int dx = pa & 0x7FFF;  if(pa & 0x8000)    dx |= 0xFFFF8000;  int dmx = pb & 0x7FFF;  if(pb & 0x8000)    dmx |= 0xFFFF8000;  int dy = pc & 0x7FFF;  if(pc & 0x8000)    dy |= 0xFFFF8000;  int dmy = pd & 0x7FFFF;  if(pd & 0x8000)    dmy |= 0xFFFF8000;  if(VCOUNT == 0)    changed = 3;  if(changed & 1) {    currentX = (x_l) | ((x_h & 0x07FF)<<16);    if(x_h & 0x0800)      currentX |= 0xF8000000;  } else {    currentX += dmx;  }  if(changed & 2) {    currentY = (y_l) | ((y_h & 0x07FF)<<16);    if(y_h & 0x0800)      currentY |= 0xF8000000;  } else {    currentY += dmy;  }      int realX = currentX;  int realY = currentY;  if(control & 0x40) {    int mosaicY = ((MOSAIC & 0xF0)>>4) + 1;    int y = (VCOUNT % mosaicY);    realX -= y*dmx;    realY -= y*dmy;  }    int xxx = (realX >> 8);  int yyy = (realY >> 8);    if(control & 0x2000) {    xxx %= sizeX;    yyy %= sizeY;    if(xxx < 0)      xxx += sizeX;    if(yyy < 0)      yyy += sizeY;  }    if(control & 0x80) {    for(int x = 0; x < 240; x++) {      if(xxx < 0 ||         yyy < 0 ||         xxx >= sizeX ||         yyy >= sizeY) {        line[x] = 0x80000000;      } else {        int tile = screenBase[(xxx>>3) + (yyy>>3)*(sizeX>>3)];                int tileX = (xxx & 7);        int tileY = yyy & 7;                u8 color = charBase[(tile<<6) + (tileY<<3) + tileX];                  line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000;      }      realX += dx;      realY += dy;            xxx = (realX >> 8);      yyy = (realY >> 8);            if(control & 0x2000) {        xxx %= sizeX;        yyy %= sizeY;        if(xxx < 0)          xxx += sizeX;        if(yyy < 0)          yyy += sizeY;      }    }  } else {    for(int x = 0; x < 240; x++) {      if(xxx < 0 ||         yyy < 0 ||         xxx >= sizeX ||         yyy >= sizeY) {        line[x] = 0x80000000;      } else {        int tile = screenBase[(xxx>>3) + (yyy>>3)*(sizeX>>3)];                int tileX = (xxx & 7);        int tileY = yyy & 7;                u8 color = charBase[(tile<<6) + (tileY<<3) + tileX];                  line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000;      }      realX += dx;      realY += dy;            xxx = (realX >> 8);      yyy = (realY >> 8);            if(control & 0x2000) {        xxx %= sizeX;        yyy %= sizeY;        if(xxx < 0)          xxx += sizeX;        if(yyy < 0)          yyy += sizeY;      }    }      }  if(control & 0x40) {        int mosaicX = (MOSAIC & 0xF) + 1;    for(int i = 0; i < 240; i+=2) {      for(int m = 1; m < mosaicX; m++) {        line[i] = line[i-1]; i++;      }    }  }  }