Exemplo n.º 1
0
void mode0RenderLine(MixColorType *lineMix, GBALCD &lcd, const GBAMem::IoMem &ioMem)
{
#ifdef GBALCD_TEMP_LINE_BUFFER
	u32 lcd.line0[240];
	//gfxClearArray(lcd.line0);
	u32 lcd.line1[240];
	//gfxClearArray(lcd.line1);
	u32 lcd.line2[240];
	//gfxClearArray(lcd.line2);
	u32 lcd.line3[240];
	//gfxClearArray(lcd.line3);
	u32 lcd.lineOBJ[240];
#endif
  const u16 *palette = (u16 *)lcd.paletteRAM;
  const auto BLDMOD = ioMem.BLDMOD;
  const auto COLEV = ioMem.COLEV;
  const auto COLY = ioMem.COLY;
  const auto VCOUNT = ioMem.VCOUNT;
  const auto MOSAIC = ioMem.MOSAIC;
  const auto DISPCNT = ioMem.DISPCNT;

  if(lcd.layerEnable & 0x0100) {
    gfxDrawTextScreen(lcd.vram, ioMem.BG0CNT, ioMem.BG0HOFS, ioMem.BG0VOFS, lcd.line0, VCOUNT, MOSAIC, palette);
  }

  if(lcd.layerEnable & 0x0200) {
    gfxDrawTextScreen(lcd.vram, ioMem.BG1CNT, ioMem.BG1HOFS, ioMem.BG1VOFS, lcd.line1, VCOUNT, MOSAIC, palette);
  }

  if(lcd.layerEnable & 0x0400) {
    gfxDrawTextScreen(lcd.vram, ioMem.BG2CNT, ioMem.BG2HOFS, ioMem.BG2VOFS, lcd.line2, VCOUNT, MOSAIC, palette);
  }

  if(lcd.layerEnable & 0x0800) {
    gfxDrawTextScreen(lcd.vram, ioMem.BG3CNT, ioMem.BG3HOFS, ioMem.BG3VOFS, lcd.line3, VCOUNT, MOSAIC, palette);
  }

  gfxDrawSprites(lcd, lcd.lineOBJ, VCOUNT, MOSAIC, DISPCNT);

  u32 backdrop;
  if(customBackdropColor == -1) {
    backdrop = (READ16LE(&palette[0]) | 0x30000000);
  } else {
    backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
  }

  for(int x = 0; x < 240; x++) {
    u32 color = backdrop;
    u8 top = 0x20;

    if(lcd.line0[x] < color) {
      color = lcd.line0[x];
      top = 0x01;
    }

    if((u8)(lcd.line1[x]>>24) < (u8)(color >> 24)) {
      color = lcd.line1[x];
      top = 0x02;
    }

    if((u8)(lcd.line2[x]>>24) < (u8)(color >> 24)) {
      color = lcd.line2[x];
      top = 0x04;
    }

    if((u8)(lcd.line3[x]>>24) < (u8)(color >> 24)) {
      color = lcd.line3[x];
      top = 0x08;
    }

    if((u8)(lcd.lineOBJ[x]>>24) < (u8)(color >> 24)) {
      color = lcd.lineOBJ[x];
      top = 0x10;
    }

    if((top & 0x10) && (color & 0x00010000)) {
      // semi-transparent OBJ
      u32 back = backdrop;
      u8 top2 = 0x20;

      if((u8)(lcd.line0[x]>>24) < (u8)(back >> 24)) {
        back = lcd.line0[x];
        top2 = 0x01;
      }

      if((u8)(lcd.line1[x]>>24) < (u8)(back >> 24)) {
        back = lcd.line1[x];
        top2 = 0x02;
      }

      if((u8)(lcd.line2[x]>>24) < (u8)(back >> 24)) {
        back = lcd.line2[x];
        top2 = 0x04;
      }

      if((u8)(lcd.line3[x]>>24) < (u8)(back >> 24)) {
        back = lcd.line3[x];
        top2 = 0x08;
      }

      if(top2 & (BLDMOD>>8))
        color = gfxAlphaBlend(color, back,
                              coeff[COLEV & 0x1F],
                              coeff[(COLEV >> 8) & 0x1F]);
      else {
        switch((BLDMOD >> 6) & 3) {
        case 2:
          if(BLDMOD & top)
            color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
          break;
        case 3:
          if(BLDMOD & top)
            color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
          break;
        }
      }
    }
Exemplo n.º 2
0
void mode1RenderLine()
{
  u16 *palette = (u16 *)paletteRAM;

  if(DISPCNT & 0x80)
    {
      for(int x = 0; x < 240; x++)
        {
          lineMix[x] = 0x7fff;
        }
      gfxLastVCOUNT = VCOUNT;
      return;
    }

  if(layerEnable & 0x0100)
    {
      gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
    }

  if(layerEnable & 0x0200)
    {
      gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
    }

  if(layerEnable & 0x0400)
    {
      int changed = gfxBG2Changed;
      if(gfxLastVCOUNT > VCOUNT)
        changed = 3;
      gfxDrawRotScreen(BG2CNT, BG2X_L, BG2X_H, BG2Y_L, BG2Y_H,
                       BG2PA, BG2PB, BG2PC, BG2PD,
                       gfxBG2X, gfxBG2Y, changed, line2);
    }

  gfxDrawSprites(lineOBJ);

  u32 backdrop = (READ16LE(&palette[0]) | 0x30000000);

  for(int x = 0; x < 240; x++)
    {
      u32 color = backdrop;
      u8 top = 0x20;

      if(line0[x] < color)
        {
          color = line0[x];
          top = 0x01;
        }

      if((u8)(line1[x]>>24) < (u8)(color >> 24))
        {
          color = line1[x];
          top = 0x02;
        }

      if((u8)(line2[x]>>24) < (u8)(color >> 24))
        {
          color = line2[x];
          top = 0x04;
        }

      if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24))
        {
          color = lineOBJ[x];
          top = 0x10;
        }

      if((top & 0x10) && (color & 0x00010000))
        {
          // semi-transparent OBJ
          u32 back = backdrop;
          u8 top2 = 0x20;

          if((u8)(line0[x]>>24) < (u8)(back >> 24))
            {
              back = line0[x];
              top2 = 0x01;
            }

          if((u8)(line1[x]>>24) < (u8)(back >> 24))
            {
              back = line1[x];
              top2 = 0x02;
            }

          if((u8)(line2[x]>>24) < (u8)(back >> 24))
            {
              back = line2[x];
              top2 = 0x04;
            }

          if(top2 & (BLDMOD>>8))
            color = gfxAlphaBlend(color, back,
                                  coeff[COLEV & 0x1F],
                                  coeff[(COLEV >> 8) & 0x1F]);
          else
            {
              switch((BLDMOD >> 6) & 3)
                {
                case 2:
                  if(BLDMOD & top)
                    color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
                  break;
                case 3:
                  if(BLDMOD & top)
                    color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
                  break;
                }
            }
        }
Exemplo n.º 3
0
void mode0RenderLine()
{
  u16 *palette = (u16 *)paletteRAM;

  if(DISPCNT & 0x80) {
    for(int x = 0; x < 240; x++) {
      lineMix[x] = 0x7fff;
    }
    return;
  }

  if(layerEnable & 0x0100) {
    gfxDrawTextScreen(BG0CNT, BG0HOFS, BG0VOFS, line0);
  }

  if(layerEnable & 0x0200) {
    gfxDrawTextScreen(BG1CNT, BG1HOFS, BG1VOFS, line1);
  }

  if(layerEnable & 0x0400) {
    gfxDrawTextScreen(BG2CNT, BG2HOFS, BG2VOFS, line2);
  }

  if(layerEnable & 0x0800) {
    gfxDrawTextScreen(BG3CNT, BG3HOFS, BG3VOFS, line3);
  }

  gfxDrawSprites(lineOBJ);

  u32 backdrop;
  if(customBackdropColor == -1) {
    backdrop = (READ16LE(&palette[0]) | 0x30000000);
  } else {
    backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
  }

  for(int x = 0; x < 240; x++) {
    u32 color = backdrop;
    u8 top = 0x20;

    if(line0[x] < color) {
      color = line0[x];
      top = 0x01;
    }

    if((u8)(line1[x]>>24) < (u8)(color >> 24)) {
      color = line1[x];
      top = 0x02;
    }

    if((u8)(line2[x]>>24) < (u8)(color >> 24)) {
      color = line2[x];
      top = 0x04;
    }

    if((u8)(line3[x]>>24) < (u8)(color >> 24)) {
      color = line3[x];
      top = 0x08;
    }

    if((u8)(lineOBJ[x]>>24) < (u8)(color >> 24)) {
      color = lineOBJ[x];
      top = 0x10;
    }

    if((top & 0x10) && (color & 0x00010000)) {
      // semi-transparent OBJ
      u32 back = backdrop;
      u8 top2 = 0x20;

      if((u8)(line0[x]>>24) < (u8)(back >> 24)) {
        back = line0[x];
        top2 = 0x01;
      }

      if((u8)(line1[x]>>24) < (u8)(back >> 24)) {
        back = line1[x];
        top2 = 0x02;
      }

      if((u8)(line2[x]>>24) < (u8)(back >> 24)) {
        back = line2[x];
        top2 = 0x04;
      }

      if((u8)(line3[x]>>24) < (u8)(back >> 24)) {
        back = line3[x];
        top2 = 0x08;
      }

      if(top2 & (BLDMOD>>8))
        color = gfxAlphaBlend(color, back,
                              coeff[COLEV & 0x1F],
                              coeff[(COLEV >> 8) & 0x1F]);
      else {
        switch((BLDMOD >> 6) & 3) {
        case 2:
          if(BLDMOD & top)
            color = gfxIncreaseBrightness(color, coeff[COLY & 0x1F]);
          break;
        case 3:
          if(BLDMOD & top)
            color = gfxDecreaseBrightness(color, coeff[COLY & 0x1F]);
          break;
        }
      }
    }