if(gbCgbMode && !gbSgbMode) {
if(gbCgbMode) {
void gbDrawSpriteTile(int tile, int x,int y,int t, int flags,                      int size,int spriteNumber){  u8 * bank0;  u8 * bank1;  if(gbCgbMode) {    if(register_VBK & 1) {      bank0 = &gbVram[0x0000];      bank1 = &gbVram[0x2000];    } else {      bank0 = &gbVram[0x0000];      bank1 = &gbVram[0x2000];    }  } else {    bank0 = &gbMemory[0x8000];    bank1 = NULL;  }    int init = 0x0000;  //  int yLine = (y+gbBorderRowSkip) * gbBorderLineSkip;  u8 *pal = gbObp0;  int flipx = (flags & 0x20);  int flipy = (flags & 0x40);    if((flags & 0x10))    pal = gbObp1;  if(flipy) {    t = (size ? 15 : 7) - t;  }  int prio =  flags & 0x80;    int address = init + tile * 16 + 2*t;  int a = 0;  int b = 0;  if(gbCgbMode && flags & 0x08) {    a = bank1[address++];    b = bank1[address++];  } else {    a = bank0[address++];    b = bank0[address++];  }    for(int xx = 0; xx < 8; xx++) {    u8 mask = 1 << (7-xx);    u8 c = 0;    if( (a & mask))      c++;    if( (b & mask))      c+=2;        if(c==0) continue;    int xxx = xx+x;    if(flipx)      xxx = (7-xx+x);    if(xxx < 0 || xxx > 159)      continue;    u16 color = gbLineBuffer[xxx];        if(prio) {      if(color < 0x200 && ((color & 0xFF) != 0))        continue;    }    if(color >= 0x300 && color != 0x300)      continue;    else if(color >= 0x200 && color < 0x300) {      int sprite = color & 0xff;      int spriteX = gbMemory[0xfe00 + 4 * sprite + 1] - 8;      if(spriteX == x) {        if(sprite < spriteNumber)          continue;      } else {        if(gbCgbMode) {          if(sprite < spriteNumber)            continue;        } else {          if(spriteX < x)            continue;        }      }    }         gbLineBuffer[xxx] = 0x200 + spriteNumber;    // make sure that sprites will work even in CGB mode    if(gbCgbMode && !gbSgbMode) {      c = c + (flags & 0x07)*4 + 32;    } else {      c = pal[c];      if(gbSgbMode && !gbCgbMode) {        int dx = xxx >> 3;        int dy = y >> 3;                int palette = gbSgbATF[dy * 20 + dx];                if(c == 0)          palette = 0;                c = c + 4*palette;                    } else {        c += 4;      }    }    gbLineMix[xxx] = gbColorOption ? gbColorFilter[gbPalette[c]] :      gbPalette[c];  }}