lay base for hi-res rendering

IT'S A PILE OF HACKS
This commit is contained in:
Arisotura 2019-05-03 19:28:15 +02:00
parent dc68842db4
commit 83331bc7e5
4 changed files with 62 additions and 17 deletions

View File

@ -71,7 +71,9 @@ u32 VRAMMap_TexPal[8];
u32 VRAMMap_ARM7[2];
u32 Framebuffer[256*192*2];
u32* Framebuffer;
int FBScale;
int FBScreenStride;
GPU2D* GPU2D_A;
GPU2D* GPU2D_B;
@ -83,6 +85,9 @@ bool Init()
GPU2D_B = new GPU2D(1);
if (!GPU3D::Init()) return false;
//SetFramebufferScale(1);
SetFramebufferScale(2);
return true;
}
@ -91,6 +96,8 @@ void DeInit()
delete GPU2D_A;
delete GPU2D_B;
GPU3D::DeInit();
if (Framebuffer) delete[] Framebuffer;
}
void Reset()
@ -147,13 +154,13 @@ void Reset()
GPU2D_B->Reset();
GPU3D::Reset();
GPU2D_A->SetFramebuffer(&Framebuffer[256*192]);
GPU2D_B->SetFramebuffer(&Framebuffer[256*0]);
GPU2D_A->SetFramebuffer(&Framebuffer[FBScreenStride]);
GPU2D_B->SetFramebuffer(&Framebuffer[0]);
}
void Stop()
{
memset(Framebuffer, 0, 256*192*2*4);
memset(Framebuffer, 0, FBScreenStride*2*sizeof(u32));
}
void DoSavestate(Savestate* file)
@ -208,6 +215,15 @@ void DoSavestate(Savestate* file)
GPU3D::DoSavestate(file);
}
void SetFramebufferScale(int scale)
{
FBScale = scale;
FBScreenStride = (256*scale) * (192*scale);
if (Framebuffer) delete[] Framebuffer;
Framebuffer = new u32[FBScreenStride * 2];
}
// VRAM mapping notes
//
@ -668,13 +684,13 @@ void SetPowerCnt(u32 val)
if (val & (1<<15))
{
GPU2D_A->SetFramebuffer(&Framebuffer[256*0]);
GPU2D_B->SetFramebuffer(&Framebuffer[256*192]);
GPU2D_A->SetFramebuffer(&Framebuffer[0]);
GPU2D_B->SetFramebuffer(&Framebuffer[FBScreenStride]);
}
else
{
GPU2D_A->SetFramebuffer(&Framebuffer[256*192]);
GPU2D_B->SetFramebuffer(&Framebuffer[256*0]);
GPU2D_A->SetFramebuffer(&Framebuffer[FBScreenStride]);
GPU2D_B->SetFramebuffer(&Framebuffer[0]);
}
}

View File

@ -61,7 +61,7 @@ extern u32 VRAMMap_Texture[4];
extern u32 VRAMMap_TexPal[8];
extern u32 VRAMMap_ARM7[2];
extern u32 Framebuffer[256*192*2];
extern u32* Framebuffer;
extern GPU2D* GPU2D_A;
extern GPU2D* GPU2D_B;
@ -74,6 +74,8 @@ void Stop();
void DoSavestate(Savestate* file);
void SetFramebufferScale(int scale);
void MapVRAM_AB(u32 bank, u8 cnt);
void MapVRAM_CD(u32 bank, u8 cnt);

View File

@ -551,7 +551,7 @@ void GPU2D::Write32(u32 addr, u32 val)
void GPU2D::DrawScanline(u32 line)
{
u32* dst = &Framebuffer[256*line];
u32* dst = &Framebuffer[256*4*line];
u32 mode1gfx[256];
// request each 3D scanline in advance
@ -725,6 +725,17 @@ void GPU2D::DrawScanline(u32 line)
dst[i] = c | ((c & 0x00C0C0C0) >> 6) | 0xFF000000;
}
// hax
for (int i = 255; i >= 0; i--)
{
u32 c = dst[i];
dst[i*2] = c;
dst[i*2+1] = c;
dst[i*2+512] = c;
dst[i*2+513] = c;
}
}
void GPU2D::VBlank()

View File

@ -95,7 +95,9 @@ bool SavestateLoaded;
bool ScreenDrawInited = false;
uiDrawBitmap* ScreenBitmap = NULL;
u32 ScreenBuffer[256*384];
u32* ScreenBuffer;
int ScreenScale;
int ScreenGap = 0;
int ScreenLayout = 0;
@ -396,6 +398,8 @@ int EmuThreadFunc(void* burp)
uiGLMakeContextCurrent(GLContext);
NDS::Init();
ScreenBuffer = new u32[(256*ScreenScale) * (384*ScreenScale)];
MainScreenPos[0] = 0;
MainScreenPos[1] = 0;
MainScreenPos[2] = 0;
@ -550,7 +554,7 @@ int EmuThreadFunc(void* burp)
}
}
memcpy(ScreenBuffer, GPU::Framebuffer, 256*384*4);
memcpy(ScreenBuffer, GPU::Framebuffer, (256*ScreenScale)*(384*ScreenScale)*4);
uiAreaQueueRedrawAll(MainDrawArea);
// framerate limiter based off SDL2_gfx
@ -616,6 +620,8 @@ int EmuThreadFunc(void* burp)
if (joybuttons) delete[] joybuttons;
delete[] ScreenBuffer;
NDS::DeInit();
Platform::LAN_DeInit();
@ -625,16 +631,17 @@ int EmuThreadFunc(void* burp)
void OnAreaDraw(uiAreaHandler* handler, uiArea* area, uiAreaDrawParams* params)
{
// TODO: recreate bitmap if screen scale changed
if (!ScreenDrawInited)
{
ScreenDrawInited = true;
ScreenBitmap = uiDrawNewBitmap(params->Context, 256, 384);
ScreenBitmap = uiDrawNewBitmap(params->Context, 256*ScreenScale, 384*ScreenScale);
}
if (!ScreenBitmap) return;
uiRect top = {0, 0, 256, 192};
uiRect bot = {0, 192, 256, 192};
uiRect top = {0, 0, 256*ScreenScale, 192*ScreenScale};
uiRect bot = {0, 192*ScreenScale, 256*ScreenScale, 192*ScreenScale};
uiDrawBitmapUpdate(ScreenBitmap, ScreenBuffer);
@ -817,6 +824,9 @@ void SetupScreenRects(int width, int height)
screenH = 192;
}
screenW *= ScreenScale;
screenH *= ScreenScale;
uiRect *topscreen, *bottomscreen;
if (ScreenRotation == 1 || ScreenRotation == 2)
{
@ -1010,6 +1020,9 @@ void SetMinSize(int w, int h)
int cw, ch;
uiWindowContentSize(MainWindow, &cw, &ch);
w *= ScreenScale;
h *= ScreenScale;
uiControlSetMinSize(uiControl(MainDrawArea), w, h);
if ((cw < w) || (ch < h))
{
@ -1535,8 +1548,8 @@ void OnSetScreenSize(uiMenuItem* item, uiWindow* window, void* param)
int factor = *(int*)param;
bool isHori = (ScreenRotation == 1 || ScreenRotation == 3);
int w = 256*factor;
int h = 192*factor;
int w = 256*factor * ScreenScale;
int h = 192*factor * ScreenScale;
if (ScreenLayout == 0) // natural
{
@ -1947,6 +1960,9 @@ int main(int argc, char** argv)
WindowWidth = w;
WindowHeight = h;
//ScreenScale = 1;
ScreenScale = 2; // HAW HAW HAW
MainWindow = uiNewWindow("melonDS " MELONDS_VERSION, w, h, Config::WindowMaximized, 1, 1);
uiWindowOnClosing(MainWindow, OnCloseWindow, NULL);