proof of concept that only really works in one specific case

This commit is contained in:
Arisotura 2020-11-02 18:56:22 +01:00
parent 254105adf7
commit 00bdb0fd15
3 changed files with 115 additions and 14 deletions

View File

@ -1509,7 +1509,8 @@ void GPU2D::DrawScanline_BGOBJ(u32 line)
}
else
{
if (Num == 0)
//if (Num == 0)
if (true)
{
for (int i = 0; i < 256; i++)
{
@ -1538,7 +1539,7 @@ void GPU2D::DrawScanline_BGOBJ(u32 line)
BGOBJLine[i] = val2;
BGOBJLine[256+i] = ColorComposite(i, val2, val3);
BGOBJLine[512+i] = 0x04000000 | (val1 & 0xFF);
BGOBJLine[512+i] = 0x04000000 | (val1 & 0xFF) | ((val1 & 0xFF0000) << 8);
}
else if ((flag1 & 0xC0) == 0x40)
{
@ -1550,7 +1551,7 @@ void GPU2D::DrawScanline_BGOBJ(u32 line)
BGOBJLine[i] = val2;
BGOBJLine[256+i] = ColorComposite(i, val2, val3);
BGOBJLine[512+i] = (bldcnteffect << 24) | (EVY << 8) | (val1 & 0xFF);
BGOBJLine[512+i] = (bldcnteffect << 24) | (EVY << 8) | (val1 & 0xFF) | ((val1 & 0xFF0000) << 8);
}
else if (((flag2 & 0xC0) == 0x40) && ((BlendCnt & 0x01C0) == 0x0140))
{
@ -1573,7 +1574,7 @@ void GPU2D::DrawScanline_BGOBJ(u32 line)
BGOBJLine[i] = val1;
BGOBJLine[256+i] = ColorComposite(i, val1, val3);
BGOBJLine[512+i] = (bldcnteffect << 24) | (EVB << 16) | (EVA << 8) | (val2 & 0xFF);
BGOBJLine[512+i] = (bldcnteffect << 24) | (EVB << 16) | (EVA << 8) | (val2 & 0xFF) | ((val2 & 0xFF0000) << 8);
}
else
{
@ -2001,6 +2002,44 @@ void GPU2D::DrawBG_Extended(u32 line, u32 bgnum)
{
// direct color bitmap
if (Accelerated && yshift<=8)
{
if (true) // TODO insert condition here!!
{
for (int i = 0; i < 256; i++)
{
if (WindowMask[i] & (1<<bgnum))
{
/*s32 finalX, finalY;
if (mosaic)
{
int im = CurBGXMosaicTable[i];
finalX = rotX - (im * rotA);
finalY = rotY - (im * rotC);
}
else
{
finalX = rotX;
finalY = rotY;
}
if (!(finalX & ofxmask) && !(finalY & ofymask))*/
{
BGOBJLine[i+512] = BGOBJLine[i+256];
BGOBJLine[i+256] = BGOBJLine[i];
BGOBJLine[i] = 0x40800000 | i; // placeholder
//BGOBJLine[i] = 0x40100000 | ((finalX >> 8) & 0xFF) | (finalY & 0xFF00); // placeholder
}
}
}
BGXRefInternal[bgnum-2] += rotB;
BGYRefInternal[bgnum-2] += rotD;
return;
}
}
u16 color;
for (int i = 0; i < 256; i++)

View File

@ -45,8 +45,10 @@ GLuint CompScreenInputTex;
GLuint CompScreenOutputTex;
GLuint CompScreenOutputFB;
GLuint CaptureTex[2][4];
GLuint CaptureFB[2][4];
GLuint CaptureTex[4][2];
GLuint CaptureFB[4][2];
int CaptureSet[4];
u32 CaptureCnt;
bool Init()
@ -73,6 +75,8 @@ bool Init()
glUniform1i(uni_id, 0);
uni_id = glGetUniformLocation(CompShader[i][2], "_3DTex");
glUniform1i(uni_id, 1);
uni_id = glGetUniformLocation(CompShader[i][2], "CaptureTex");
glUniform1i(uni_id, 2);
}
#define SETVERTEX(i, x, y) \
@ -128,7 +132,7 @@ bool Init()
glGenTextures(8, &CaptureTex[0][0]);
for (int i = 0; i < 8; i++)
{
glBindTexture(GL_TEXTURE_2D, CaptureTex[i>>2][i&0x3]);
glBindTexture(GL_TEXTURE_2D, CaptureTex[i>>1][i&0x1]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
@ -158,6 +162,10 @@ void DeInit()
void Reset()
{
for (int i = 0; i < 4; i++)
CaptureSet[i] = 0;
CaptureCnt = 0;
}
@ -179,11 +187,11 @@ void SetRenderSettings(RenderSettings& settings)
for (int i = 0; i < 8; i++)
{
glBindTexture(GL_TEXTURE_2D, CaptureTex[i>>2][i&0x3]);
glBindTexture(GL_TEXTURE_2D, CaptureTex[i>>1][i&0x1]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ScreenW, ScreenW, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glBindFramebuffer(GL_FRAMEBUFFER, CaptureFB[i>>2][i&0x3]);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, CaptureTex[i>>2][i&0x3], 0);
glBindFramebuffer(GL_FRAMEBUFFER, CaptureFB[i>>1][i&0x1]);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, CaptureTex[i>>1][i&0x1], 0);
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
@ -204,7 +212,7 @@ void DoCapture(u32 capcnt)
return;
}
// COMPLETE ME!
CaptureCnt = capcnt;
}
void RenderFrame()
@ -238,10 +246,48 @@ void RenderFrame()
glActiveTexture(GL_TEXTURE1);
GPU3D::GLRenderer::SetupAccelFrame();
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, CaptureTex[3][CaptureSet[3]]);
glBindBuffer(GL_ARRAY_BUFFER, CompVertexBufferID);
glBindVertexArray(CompVertexArrayID);
glDrawArrays(GL_TRIANGLES, 0, 4*3);
// take care of capture as needed
if (CaptureCnt & (1<<31))
{
u32 dstvram = (CaptureCnt >> 16) & 0x3;
CaptureSet[dstvram] ^= 1;
int cset = CaptureSet[dstvram];
u32 capwidth, capheight;
switch ((CaptureCnt >> 20) & 0x3)
{
case 0: capwidth = 128; capheight = 128; break;
case 1: capwidth = 256; capheight = 64; break;
case 2: capwidth = 256; capheight = 128; break;
case 3: capwidth = 256; capheight = 192; break;
}
u32 yoffset = ((CaptureCnt >> 18) & 0x3) * 64;
capwidth *= Scale;
capheight *= Scale;
yoffset *= Scale;
// TODO: other sources!!
glBindFramebuffer(GL_READ_FRAMEBUFFER, CompScreenOutputFB);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, CaptureFB[dstvram][cset]);
glReadBuffer(GL_COLOR_ATTACHMENT0);
glDrawBuffer(GL_COLOR_ATTACHMENT0);
// TODO: offset and shit!
glBlitFramebuffer(0, 192*Scale, capwidth, 192*Scale+capheight, 0, 0, capwidth, capheight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
CaptureCnt = 0;
}
glFlush();
}

View File

@ -43,6 +43,7 @@ uniform uint u3DScale;
uniform usampler2D ScreenTex;
uniform sampler2D _3DTex;
uniform sampler2D CaptureTex;
smooth in vec2 fTexcoord;
@ -70,7 +71,12 @@ void main()
float xpos = val3.r + fract(fTexcoord.x);
float ypos = mod(fTexcoord.y, 192);
ivec4 _3dpix = ivec4(texelFetch(_3DTex, ivec2(vec2(xpos, ypos)*u3DScale), 0).bgra
ivec4 _3dpix;
if ((val3.a & 0x80) == 0x80)
_3dpix = ivec4(texelFetch(CaptureTex, ivec2(vec2(xpos, ypos)*u3DScale), 0).bgra
* vec4(63,63,63,31));
else
_3dpix = ivec4(texelFetch(_3DTex, ivec2(vec2(xpos, ypos)*u3DScale), 0).bgra
* vec4(63,63,63,31));
if (_3dpix.a > 0)
@ -91,7 +97,12 @@ void main()
float xpos = val3.r + fract(fTexcoord.x);
float ypos = mod(fTexcoord.y, 192);
ivec4 _3dpix = ivec4(texelFetch(_3DTex, ivec2(vec2(xpos, ypos)*u3DScale), 0).bgra
ivec4 _3dpix;
if ((val3.a & 0x80) == 0x80)
_3dpix = ivec4(texelFetch(CaptureTex, ivec2(vec2(xpos, ypos)*u3DScale), 0).bgra
* vec4(63,63,63,31));
else
_3dpix = ivec4(texelFetch(_3DTex, ivec2(vec2(xpos, ypos)*u3DScale), 0).bgra
* vec4(63,63,63,31));
if (_3dpix.a > 0)
@ -111,7 +122,12 @@ void main()
float xpos = val3.r + fract(fTexcoord.x);
float ypos = mod(fTexcoord.y, 192);
ivec4 _3dpix = ivec4(texelFetch(_3DTex, ivec2(vec2(xpos, ypos)*u3DScale), 0).bgra
ivec4 _3dpix;
if ((val3.a & 0x80) == 0x80)
_3dpix = ivec4(texelFetch(CaptureTex, ivec2(vec2(xpos, ypos)*u3DScale), 0).bgra
* vec4(63,63,63,31));
else
_3dpix = ivec4(texelFetch(_3DTex, ivec2(vec2(xpos, ypos)*u3DScale), 0).bgra
* vec4(63,63,63,31));
if (_3dpix.a > 0)