aboutsummaryrefslogtreecommitdiff
path: root/src/GPU2D_Soft.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/GPU2D_Soft.cpp')
-rw-r--r--src/GPU2D_Soft.cpp71
1 files changed, 5 insertions, 66 deletions
diff --git a/src/GPU2D_Soft.cpp b/src/GPU2D_Soft.cpp
index 9e7d849..6d0252c 100644
--- a/src/GPU2D_Soft.cpp
+++ b/src/GPU2D_Soft.cpp
@@ -27,68 +27,7 @@ namespace GPU2D
SoftRenderer::SoftRenderer(melonDS::GPU& gpu)
: Renderer2D(), GPU(gpu)
{
- // initialize mosaic table
- for (int m = 0; m < 16; m++)
- {
- for (int x = 0; x < 256; x++)
- {
- int offset = x % (m+1);
- MosaicTable[m][x] = offset;
- }
- }
-}
-
-u32 SoftRenderer::ColorBlend4(u32 val1, u32 val2, u32 eva, u32 evb)
-{
- u32 r = (((val1 & 0x00003F) * eva) + ((val2 & 0x00003F) * evb) + 0x000008) >> 4;
- u32 g = ((((val1 & 0x003F00) * eva) + ((val2 & 0x003F00) * evb) + 0x000800) >> 4) & 0x007F00;
- u32 b = ((((val1 & 0x3F0000) * eva) + ((val2 & 0x3F0000) * evb) + 0x080000) >> 4) & 0x7F0000;
-
- if (r > 0x00003F) r = 0x00003F;
- if (g > 0x003F00) g = 0x003F00;
- if (b > 0x3F0000) b = 0x3F0000;
-
- return r | g | b | 0xFF000000;
-}
-
-u32 SoftRenderer::ColorBlend5(u32 val1, u32 val2)
-{
- u32 eva = ((val1 >> 24) & 0x1F) + 1;
- u32 evb = 32 - eva;
-
- if (eva == 32) return val1;
-
- u32 r = (((val1 & 0x00003F) * eva) + ((val2 & 0x00003F) * evb) + 0x000010) >> 5;
- u32 g = ((((val1 & 0x003F00) * eva) + ((val2 & 0x003F00) * evb) + 0x001000) >> 5) & 0x007F00;
- u32 b = ((((val1 & 0x3F0000) * eva) + ((val2 & 0x3F0000) * evb) + 0x100000) >> 5) & 0x7F0000;
-
- if (r > 0x00003F) r = 0x00003F;
- if (g > 0x003F00) g = 0x003F00;
- if (b > 0x3F0000) b = 0x3F0000;
-
- return r | g | b | 0xFF000000;
-}
-
-u32 SoftRenderer::ColorBrightnessUp(u32 val, u32 factor, u32 bias)
-{
- u32 rb = val & 0x3F003F;
- u32 g = val & 0x003F00;
-
- rb += (((((0x3F003F - rb) * factor) + (bias*0x010001)) >> 4) & 0x3F003F);
- g += (((((0x003F00 - g ) * factor) + (bias*0x000100)) >> 4) & 0x003F00);
-
- return rb | g | 0xFF000000;
-}
-
-u32 SoftRenderer::ColorBrightnessDown(u32 val, u32 factor, u32 bias)
-{
- u32 rb = val & 0x3F003F;
- u32 g = val & 0x003F00;
-
- rb -= ((((rb * factor) + (bias*0x010001)) >> 4) & 0x3F003F);
- g -= ((((g * factor) + (bias*0x000100)) >> 4) & 0x003F00);
-
- return rb | g | 0xFF000000;
+ // mosaic table is initialized at compile-time
}
u32 SoftRenderer::ColorComposite(int i, u32 val1, u32 val2)
@@ -365,11 +304,11 @@ void SoftRenderer::DrawScanline(u32 line, Unit* unit)
void SoftRenderer::VBlankEnd(Unit* unitA, Unit* unitB)
{
#ifdef OGLRENDERER_ENABLED
- if (GPU.GPU3D.IsRendererAccelerated())
+ if (Renderer3D& renderer3d = GPU.GPU3D.GetCurrentRenderer(); renderer3d.Accelerated)
{
if ((unitA->CaptureCnt & (1<<31)) && (((unitA->CaptureCnt >> 29) & 0x3) != 1))
{
- reinterpret_cast<GLRenderer*>(GPU.GPU3D.GetCurrentRenderer())->PrepareCaptureFrame();
+ renderer3d.PrepareCaptureFrame();
}
}
#endif
@@ -779,7 +718,7 @@ void SoftRenderer::DrawScanline_BGOBJ(u32 line)
memset(WindowMask, 0xFF, 256);
ApplySpriteMosaicX();
- CurBGXMosaicTable = MosaicTable[CurUnit->BGMosaicSize[0]];
+ CurBGXMosaicTable = MosaicTable[CurUnit->BGMosaicSize[0]].data();
switch (CurUnit->DispCnt & 0x7)
{
@@ -1564,7 +1503,7 @@ void SoftRenderer::ApplySpriteMosaicX()
u32* objLine = OBJLine[CurUnit->Num];
- u8* curOBJXMosaicTable = MosaicTable[CurUnit->OBJMosaicSize[1]];
+ u8* curOBJXMosaicTable = MosaicTable[CurUnit->OBJMosaicSize[1]].data();
u32 lastcolor = objLine[0];