Fixed sf64 clear screen buffer for widescreen

This commit is contained in:
KiritoDv
2024-05-27 15:27:19 -06:00
committed by Sonic Dreamcaster
parent 4ca3aebc7f
commit 93e6d673e6
4 changed files with 63 additions and 8 deletions
+2 -1
View File
@@ -7,7 +7,8 @@
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#define SCREEN_MARGIN 8
// This should be part of a CVar
#define SCREEN_MARGIN 0
#define TIME_IN_SECONDS(x) (x * 30);
+10 -7
View File
@@ -154,16 +154,19 @@ bool Game_ChangeScene(void) {
return false;
}
#define LEFT_MARGIN OTRGetRectDimensionFromLeftEdge(SCREEN_MARGIN)
#define RIGHT_MARGIN OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH - SCREEN_MARGIN)
void Game_InitMasterDL(Gfx** dList) {
gSPDisplayList((*dList)++, gRcpInitDL);
gDPSetScissor((*dList)++, G_SC_NON_INTERLACE, SCREEN_MARGIN, SCREEN_MARGIN, SCREEN_WIDTH - SCREEN_MARGIN,
SCREEN_HEIGHT - SCREEN_MARGIN);
gDPSetDepthImage((*dList)++, &gZBuffer);
gDPSetColorImage((*dList)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, &gZBuffer);
gDPSetColorImage((*dList)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, RIGHT_MARGIN, &gZBuffer);
gDPSetFillColor((*dList)++, FILL_COLOR(GPACK_ZDZ(G_MAXFBZ, 0)));
gDPFillRectangle((*dList)++, SCREEN_MARGIN, SCREEN_MARGIN, SCREEN_WIDTH - SCREEN_MARGIN - 1,
SCREEN_HEIGHT - SCREEN_MARGIN - 1);
gDPSetColorImage((*dList)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, gFrameBuffer);
gDPFillWideRectangle((*dList)++, LEFT_MARGIN, SCREEN_MARGIN, RIGHT_MARGIN,
SCREEN_HEIGHT - SCREEN_MARGIN);
gDPSetColorImage((*dList)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, RIGHT_MARGIN, gFrameBuffer);
if (gBlurAlpha < 255) {
gDPPipeSync((*dList)++);
@@ -175,7 +178,7 @@ void Game_InitMasterDL(Gfx** dList) {
} else {
gDPSetFillColor((*dList)++, FILL_COLOR(gBgColor | 1));
}
gDPFillRectangle((*dList)++, SCREEN_MARGIN, SCREEN_MARGIN, SCREEN_WIDTH - SCREEN_MARGIN - 1,
gDPFillWideRectangle((*dList)++, LEFT_MARGIN, SCREEN_MARGIN, RIGHT_MARGIN,
SCREEN_HEIGHT - SCREEN_MARGIN);
gDPPipeSync((*dList)++);
gDPSetColorDither((*dList)++, G_CD_MAGICSQ);
@@ -185,8 +188,8 @@ void Game_InitStandbyDL(Gfx** dList) {
gSPDisplayList((*dList)++, gRcpInitDL);
gDPSetScissor((*dList)++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT * 3);
gDPSetFillColor((*dList)++, FILL_COLOR(0x0001));
gDPSetColorImage((*dList)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, gFrameBuffers[0].data);
gDPFillRectangle((*dList)++, 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT * 3 - 1);
gDPSetColorImage((*dList)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, RIGHT_MARGIN, gFrameBuffers[0].data);
gDPFillWideRectangle((*dList)++, OTRGetDimensionFromLeftEdge(0), 0, OTRGetRectDimensionFromRightEdge(0), SCREEN_HEIGHT * 3 - 1);
gDPPipeSync((*dList)++);
gDPSetColorDither((*dList)++, G_CD_MAGICSQ);
}
+41
View File
@@ -250,3 +250,44 @@ extern "C" void Timer_Update() {
}
}
}
// Gets the width of the main ImGui window
extern "C" uint32_t OTRGetCurrentWidth() {
return GameEngine::Instance->context->GetWindow()->GetWidth();
}
// Gets the height of the main ImGui window
extern "C" uint32_t OTRGetCurrentHeight() {
return GameEngine::Instance->context->GetWindow()->GetHeight();
}
extern "C" float OTRGetAspectRatio() {
return gfx_current_dimensions.aspect_ratio;
}
extern "C" float OTRGetDimensionFromLeftEdge(float v) {
return (gfx_native_dimensions.width / 2 - gfx_native_dimensions.height / 2 * OTRGetAspectRatio() + (v));
}
extern "C" float OTRGetDimensionFromRightEdge(float v) {
return (gfx_native_dimensions.width / 2 + gfx_native_dimensions.height / 2 * OTRGetAspectRatio() -
(gfx_native_dimensions.width - v));
}
// Gets the width of the current render target area
extern "C" uint32_t OTRGetGameRenderWidth() {
return gfx_current_dimensions.width;
}
// Gets the height of the current render target area
extern "C" uint32_t OTRGetGameRenderHeight() {
return gfx_current_dimensions.height;
}
extern "C" int16_t OTRGetRectDimensionFromLeftEdge(float v) {
return ((int)floorf(OTRGetDimensionFromLeftEdge(v)));
}
extern "C" int16_t OTRGetRectDimensionFromRightEdge(float v) {
return ((int)ceilf(OTRGetDimensionFromRightEdge(v)));
}
+10
View File
@@ -32,4 +32,14 @@ class GameEngine {
void GameEngine_ProcessGfxCommands(Gfx* commands);
float GameEngine_GetAspectRatio();
uint8_t GameEngine_OTRSigCheck(char* imgData);
uint32_t OTRGetCurrentWidth(void);
uint32_t OTRGetCurrentHeight(void);
float OTRGetAspectRatio(void);
int32_t OTRConvertHUDXToScreenX(int32_t v);
float OTRGetDimensionFromLeftEdge(float v);
float OTRGetDimensionFromRightEdge(float v);
int16_t OTRGetRectDimensionFromLeftEdge(float v);
int16_t OTRGetRectDimensionFromRightEdge(float v);
uint32_t OTRGetGameRenderWidth();
uint32_t OTRGetGameRenderHeight();
#endif