From 8cef2ea33b107ed661be392655df433d6c5df9f9 Mon Sep 17 00:00:00 2001 From: VitorMM Date: Wed, 5 Feb 2025 17:53:29 -0300 Subject: [PATCH] Floor level area should only be cropped on bug sectors --- src/plugins/Plugin.cpp | 4 +- src/plugins/PluginKingdomHeartsReCoded.cpp | 11 ++++ src/plugins/PluginKingdomHeartsReCoded.h | 1 + ...nKingdomHeartsReCoded_GPU_OpenGL_shaders.h | 66 ++++++++++--------- 4 files changed, 49 insertions(+), 33 deletions(-) diff --git a/src/plugins/Plugin.cpp b/src/plugins/Plugin.cpp index 7f10c97c95..f6540d23bf 100644 --- a/src/plugins/Plugin.cpp +++ b/src/plugins/Plugin.cpp @@ -8,8 +8,8 @@ #define RAM_SEARCH_ENABLED true #define RAM_SEARCH_SIZE 32 #define RAM_SEARCH_LIMIT_MIN 0 -#define RAM_SEARCH_LIMIT_MAX 0x3FFFFF -// #define RAM_SEARCH_LIMIT_MAX 0x19FFFF +// #define RAM_SEARCH_LIMIT_MAX 0x3FFFFF +#define RAM_SEARCH_LIMIT_MAX 0x19FFFF #define RAM_SEARCH_INTERVAL_MARGIN 0x050 // #define RAM_SEARCH_EXACT_VALUE 0x05B07E00 diff --git a/src/plugins/PluginKingdomHeartsReCoded.cpp b/src/plugins/PluginKingdomHeartsReCoded.cpp index 09989aeedf..789d5d7348 100644 --- a/src/plugins/PluginKingdomHeartsReCoded.cpp +++ b/src/plugins/PluginKingdomHeartsReCoded.cpp @@ -47,6 +47,10 @@ u32 PluginKingdomHeartsReCoded::jpGamecode = 1245268802; #define IS_PLAYABLE_AREA_EU 0x0205a8c0 #define IS_PLAYABLE_AREA_JP 0x0205a6e0 +#define FLOOR_LEVEL_ADDRESS_US 0x02060867 +#define FLOOR_LEVEL_ADDRESS_EU 0x02060867 // TODO: KH +#define FLOOR_LEVEL_ADDRESS_JP 0x02060687 // TODO: KH + #define TYPE_OF_BATTLE_ADDRESS_US 0x020b5608 // or 0x020b5620 #define TYPE_OF_BATTLE_ADDRESS_EU 0x020b5608 // TODO: KH #define TYPE_OF_BATTLE_ADDRESS_JP 0x020b5608 // TODO: KH @@ -348,6 +352,7 @@ void PluginKingdomHeartsReCoded::gpuOpenGL_FS_initVariables(GLuint CompShader) { CompGpuLoc[CompShader][6] = glGetUniformLocation(CompShader, "MinimapCenterY"); CompGpuLoc[CompShader][7] = glGetUniformLocation(CompShader, "HideAllHUD"); CompGpuLoc[CompShader][8] = glGetUniformLocation(CompShader, "DSCutsceneState"); + CompGpuLoc[CompShader][9] = glGetUniformLocation(CompShader, "IsBugSector"); } void PluginKingdomHeartsReCoded::gpuOpenGL_FS_updateVariables(GLuint CompShader) { @@ -364,6 +369,7 @@ void PluginKingdomHeartsReCoded::gpuOpenGL_FS_updateVariables(GLuint CompShader) glUniform1i(CompGpuLoc[CompShader][6], MinimapCenterY); glUniform1i(CompGpuLoc[CompShader][7], HideAllHUD ? 1 : 0); glUniform1i(CompGpuLoc[CompShader][8], dsCutsceneState); + glUniform1i(CompGpuLoc[CompShader][9], getFloorLevel() == 0 ? false : true); } const char* PluginKingdomHeartsReCoded::gpu3DOpenGLClassic_VS_Z() { @@ -1215,6 +1221,11 @@ std::string PluginKingdomHeartsReCoded::localizationFilePath(std::string languag return ""; } +u8 PluginKingdomHeartsReCoded::getFloorLevel() +{ + return nds->ARM7Read8(getU32ByCart(FLOOR_LEVEL_ADDRESS_US, FLOOR_LEVEL_ADDRESS_EU, FLOOR_LEVEL_ADDRESS_JP)); +} + u32 PluginKingdomHeartsReCoded::getCurrentMission() { return 0; diff --git a/src/plugins/PluginKingdomHeartsReCoded.h b/src/plugins/PluginKingdomHeartsReCoded.h index e35d2fc3c6..8a00f5966e 100644 --- a/src/plugins/PluginKingdomHeartsReCoded.h +++ b/src/plugins/PluginKingdomHeartsReCoded.h @@ -113,6 +113,7 @@ class PluginKingdomHeartsReCoded : public Plugin bool didMobiCutsceneEnded(); bool canReturnToGameAfterReplacementCutscene(); + u8 getFloorLevel(); u32 getCurrentMission(); u32 getCurrentMap(); bool isSaveLoaded(); diff --git a/src/plugins/PluginKingdomHeartsReCoded_GPU_OpenGL_shaders.h b/src/plugins/PluginKingdomHeartsReCoded_GPU_OpenGL_shaders.h index b4f4165b6b..ee1cbbdd1a 100644 --- a/src/plugins/PluginKingdomHeartsReCoded_GPU_OpenGL_shaders.h +++ b/src/plugins/PluginKingdomHeartsReCoded_GPU_OpenGL_shaders.h @@ -32,6 +32,7 @@ uniform int MinimapCenterX; uniform int MinimapCenterY; uniform bool HideAllHUD; uniform int DSCutsceneState; +uniform bool IsBugSector; uniform usampler2D ScreenTex; uniform sampler2D _3DTex; @@ -437,38 +438,41 @@ vec2 getIngameHudTextureCoordinates(float xpos, float ypos) vec2(0, 192.0) + vec2(bottomMinimapLeftMargin + finalMinimapCenterX - 128, bottomMinimapTopMargin + finalMinimapCenterY - 96); } - // floor label - float bottomLabelWidth = 50.0; - float bottomLabelHeight = 15.0; - float increaseLabelSize = 1.8; - float labelWidth = (bottomLabelWidth/increaseLabelSize)*heightScale; - float labelHeight = (bottomLabelHeight/increaseLabelSize); - float labelRightMargin = 12.0; - float labelTopMargin = 90.0; - float labelLeftMargin = 256.0*iuTexScale - labelWidth - labelRightMargin; - if (texPosition3d.x >= labelLeftMargin && - texPosition3d.x < (256.0*iuTexScale - labelRightMargin) && - texPosition3d.y <= labelHeight + labelTopMargin && - texPosition3d.y >= labelTopMargin) { - return increaseLabelSize*fixStretch*(texPosition3d - vec2(labelLeftMargin, labelTopMargin)) + vec2(0, 192.0); - } + if (IsBugSector) + { + // floor label + float bottomLabelWidth = 50.0; + float bottomLabelHeight = 15.0; + float increaseLabelSize = 1.8; + float labelWidth = (bottomLabelWidth/increaseLabelSize)*heightScale; + float labelHeight = (bottomLabelHeight/increaseLabelSize); + float labelRightMargin = 12.0; + float labelTopMargin = 90.0; + float labelLeftMargin = 256.0*iuTexScale - labelWidth - labelRightMargin; + if (texPosition3d.x >= labelLeftMargin && + texPosition3d.x < (256.0*iuTexScale - labelRightMargin) && + texPosition3d.y <= labelHeight + labelTopMargin && + texPosition3d.y >= labelTopMargin) { + return increaseLabelSize*fixStretch*(texPosition3d - vec2(labelLeftMargin, labelTopMargin)) + vec2(0, 192.0); + } - // floor value - float bottomFloorWidth = 82.0; - float bottomFloorHeight = 15.0; - float increaseFloorSize = 1.8; - float floorWidth = (bottomFloorWidth/increaseFloorSize)*heightScale; - float floorHeight = (bottomFloorHeight/increaseFloorSize); - float floorRightMargin = 12.0; - float floorTopMargin = 98.0; - float floorLeftMargin = 256.0*iuTexScale - floorWidth - floorRightMargin; - float bottomFloorLeftMargin = 50.0; - if (texPosition3d.x >= floorLeftMargin && - texPosition3d.x < (256.0*iuTexScale - floorRightMargin) && - texPosition3d.y <= floorHeight + floorTopMargin && - texPosition3d.y >= floorTopMargin) { - return increaseFloorSize*fixStretch*(texPosition3d - vec2(floorLeftMargin, floorTopMargin)) + - vec2(0, 192.0) + vec2(bottomFloorLeftMargin, 0); + // floor value + float bottomFloorWidth = 82.0; + float bottomFloorHeight = 15.0; + float increaseFloorSize = 1.8; + float floorWidth = (bottomFloorWidth/increaseFloorSize)*heightScale; + float floorHeight = (bottomFloorHeight/increaseFloorSize); + float floorRightMargin = 12.0; + float floorTopMargin = 98.0; + float floorLeftMargin = 256.0*iuTexScale - floorWidth - floorRightMargin; + float bottomFloorLeftMargin = 50.0; + if (texPosition3d.x >= floorLeftMargin && + texPosition3d.x < (256.0*iuTexScale - floorRightMargin) && + texPosition3d.y <= floorHeight + floorTopMargin && + texPosition3d.y >= floorTopMargin) { + return increaseFloorSize*fixStretch*(texPosition3d - vec2(floorLeftMargin, floorTopMargin)) + + vec2(0, 192.0) + vec2(bottomFloorLeftMargin, 0); + } } }