Skip to content

Commit

Permalink
Floor level area should only be cropped on bug sectors
Browse files Browse the repository at this point in the history
  • Loading branch information
vitor251093 committed Feb 5, 2025
1 parent 0fba57c commit 8cef2ea
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/plugins/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/plugins/PluginKingdomHeartsReCoded.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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() {
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/plugins/PluginKingdomHeartsReCoded.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class PluginKingdomHeartsReCoded : public Plugin
bool didMobiCutsceneEnded();
bool canReturnToGameAfterReplacementCutscene();

u8 getFloorLevel();
u32 getCurrentMission();
u32 getCurrentMap();
bool isSaveLoaded();
Expand Down
66 changes: 35 additions & 31 deletions src/plugins/PluginKingdomHeartsReCoded_GPU_OpenGL_shaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 8cef2ea

Please sign in to comment.