Skip to content

Commit

Permalink
Improving minimap detection
Browse files Browse the repository at this point in the history
  • Loading branch information
vitor251093 committed Nov 19, 2024
1 parent a455417 commit 66420f3
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions src/plugins/PluginKingdomHeartsReCoded.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ u32 PluginKingdomHeartsReCoded::jpGamecode = 1245268802;
#define CUTSCENE_ADDRESS_EU 0x020b7e08
#define CUTSCENE_ADDRESS_JP 0x020b7858

#define MINIMAP_CENTER_X_ADDRESS_US 0x023d8054
#define MINIMAP_CENTER_X_ADDRESS_EU 0x023d8054 // TODO: KH
#define MINIMAP_CENTER_X_ADDRESS_JP 0x023d8054 // TODO: KH
#define MINIMAP_1_CENTER_X_ADDRESS_US 0x023d8054
#define MINIMAP_1_CENTER_X_ADDRESS_EU 0x023d8054 // TODO: KH
#define MINIMAP_1_CENTER_X_ADDRESS_JP 0x023d8054 // TODO: KH

#define MINIMAP_CENTER_Y_ADDRESS_US 0x023d8058
#define MINIMAP_CENTER_Y_ADDRESS_EU 0x023d8058 // TODO: KH
#define MINIMAP_CENTER_Y_ADDRESS_JP 0x023d8058 // TODO: KH
#define MINIMAP_1_CENTER_Y_ADDRESS_US 0x023d8058
#define MINIMAP_1_CENTER_Y_ADDRESS_EU 0x023d8058 // TODO: KH
#define MINIMAP_1_CENTER_Y_ADDRESS_JP 0x023d8058 // TODO: KH

#define MINIMAP_2_CENTER_X_ADDRESS_US 0x023d6c68
#define MINIMAP_2_CENTER_X_ADDRESS_EU 0x023d6c68 // TODO: KH
Expand All @@ -70,6 +70,14 @@ u32 PluginKingdomHeartsReCoded::jpGamecode = 1245268802;
#define MINIMAP_3_CENTER_Y_ADDRESS_EU 0x023d8085 // TODO: KH
#define MINIMAP_3_CENTER_Y_ADDRESS_JP 0x023d8085 // TODO: KH

#define MINIMAP_4_CENTER_X_ADDRESS_US 0x023c6a94
#define MINIMAP_4_CENTER_X_ADDRESS_EU 0x023c6a94 // TODO: KH
#define MINIMAP_4_CENTER_X_ADDRESS_JP 0x023c6a94 // TODO: KH

#define MINIMAP_4_CENTER_Y_ADDRESS_US 0x023c6a98
#define MINIMAP_4_CENTER_Y_ADDRESS_EU 0x023c6a98 // TODO: KH
#define MINIMAP_4_CENTER_Y_ADDRESS_JP 0x023c6a98 // TODO: KH

#define INGAME_MENU_COMMAND_LIST_SETTING_ADDRESS_US 0x02198311
#define INGAME_MENU_COMMAND_LIST_SETTING_ADDRESS_EU 0x02198311 // TODO: KH
#define INGAME_MENU_COMMAND_LIST_SETTING_ADDRESS_JP 0x02198311 // TODO: KH
Expand Down Expand Up @@ -564,8 +572,8 @@ int PluginKingdomHeartsReCoded::detectGameScene()
bool isUnplayableArea = gameState2 == 0x02;
bool isWorldSelection = gameState2 == 0x03;

u32 minimapCenterXAddress = getAddressByCart(MINIMAP_CENTER_X_ADDRESS_US, MINIMAP_CENTER_X_ADDRESS_EU, MINIMAP_CENTER_X_ADDRESS_JP);
u32 minimapCenterYAddress = getAddressByCart(MINIMAP_CENTER_Y_ADDRESS_US, MINIMAP_CENTER_Y_ADDRESS_EU, MINIMAP_CENTER_Y_ADDRESS_JP);
u32 minimapCenterXAddress = getAddressByCart(MINIMAP_1_CENTER_X_ADDRESS_US, MINIMAP_1_CENTER_X_ADDRESS_EU, MINIMAP_1_CENTER_X_ADDRESS_JP);
u32 minimapCenterYAddress = getAddressByCart(MINIMAP_1_CENTER_Y_ADDRESS_US, MINIMAP_1_CENTER_Y_ADDRESS_EU, MINIMAP_1_CENTER_Y_ADDRESS_JP);
u32 newMinimapCenterX = nds->ARM7Read32(minimapCenterXAddress) >> 3*4;
u32 newMinimapCenterY = nds->ARM7Read32(minimapCenterYAddress) >> 3*4;
if (newMinimapCenterX < 256 && newMinimapCenterX > 0 && newMinimapCenterY < 192 && newMinimapCenterY > 0) {
Expand All @@ -586,8 +594,18 @@ int PluginKingdomHeartsReCoded::detectGameScene()
minimapCenterYAddress = getAddressByCart(MINIMAP_3_CENTER_Y_ADDRESS_US, MINIMAP_3_CENTER_Y_ADDRESS_EU, MINIMAP_3_CENTER_Y_ADDRESS_JP);
newMinimapCenterX = nds->ARM7Read32(minimapCenterXAddress) >> 3*4;
newMinimapCenterY = nds->ARM7Read32(minimapCenterYAddress) >> 3*4;
MinimapCenterX = newMinimapCenterX;
MinimapCenterY = newMinimapCenterY;
if (newMinimapCenterX < 256 && newMinimapCenterX > 0 && newMinimapCenterY < 192 && newMinimapCenterY > 0) {
MinimapCenterX = newMinimapCenterX;
MinimapCenterY = newMinimapCenterY;
}
else {
minimapCenterXAddress = getAddressByCart(MINIMAP_4_CENTER_X_ADDRESS_US, MINIMAP_4_CENTER_X_ADDRESS_EU, MINIMAP_4_CENTER_X_ADDRESS_JP);
minimapCenterYAddress = getAddressByCart(MINIMAP_4_CENTER_Y_ADDRESS_US, MINIMAP_4_CENTER_Y_ADDRESS_EU, MINIMAP_4_CENTER_Y_ADDRESS_JP);
newMinimapCenterX = nds->ARM7Read32(minimapCenterXAddress) >> 3*4;
newMinimapCenterY = nds->ARM7Read32(minimapCenterYAddress) >> 3*4;
MinimapCenterX = newMinimapCenterX;
MinimapCenterY = newMinimapCenterY;
}
}
}

Expand Down

0 comments on commit 66420f3

Please sign in to comment.