diff options
Diffstat (limited to '')
-rw-r--r-- | NewerProjectKP.yaml | 2 | ||||
-rwxr-xr-x | include/game.h | 3 | ||||
-rw-r--r-- | include/newer.h | 2 | ||||
-rw-r--r-- | kamek_pal.x | 2 | ||||
-rw-r--r-- | koopatlas.yaml | 1 | ||||
-rw-r--r-- | pregame.yaml | 34 | ||||
-rw-r--r-- | src/koopatlas/hud.cpp | 47 | ||||
-rw-r--r-- | src/newer.cpp | 44 | ||||
-rw-r--r-- | src/pregame.S | 10 | ||||
-rw-r--r-- | src/pregame.cpp | 126 | ||||
-rw-r--r-- | src/randtiles.cpp | 6 |
11 files changed, 229 insertions, 48 deletions
diff --git a/NewerProjectKP.yaml b/NewerProjectKP.yaml index 4da75e1..5058432 100644 --- a/NewerProjectKP.yaml +++ b/NewerProjectKP.yaml @@ -11,7 +11,7 @@ modules: - processed/bonepiece.yaml - processed/bugfixes.yaml - processed/koopatlas.yaml - - processed/levelnames.yaml + - processed/pregame.yaml - processed/animtiles.yaml - processed/soundPlayer.yaml - processed/bowserKey.yaml diff --git a/include/game.h b/include/game.h index 661038a..08c2a49 100755 --- a/include/game.h +++ b/include/game.h @@ -8,6 +8,7 @@ #include <rvl/GXEnum.h>
#include <rvl/vifuncs.h>
#include <rvl/arc.h>
+#include <rvl/tpl.h>
#define offsetof(type, member) ((u32) &(((type *) 0)->member))
#include <g3dhax.h>
@@ -720,6 +721,8 @@ namespace lyt { u32 anisotropy: 2;
u32 paletteFormat: 2;
} mBits;
+
+ void ReplaceImage(TPLPalette *tpl, unsigned long id);
};
class Material {
diff --git a/include/newer.h b/include/newer.h index cf21cbb..a687073 100644 --- a/include/newer.h +++ b/include/newer.h @@ -2,5 +2,7 @@ #define NEWER_H int getStarCoinCount(); +void getNewerLevelNumberString(int world, int level, wchar_t *dest); + #endif /* NEWER_H */ diff --git a/kamek_pal.x b/kamek_pal.x index bf1b8a1..f4472a4 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -1037,6 +1037,8 @@ SECTIONS { _Z15lyt__Layout__dtPvi = 0x802ACCC0; _Z18lyt__Layout__BuildPvPKvS_ = 0x802ACDF0; + ReplaceImage__Q34nw4r3lyt6TexMapFP10TPLPaletteUl = 0x802B4DA0; + _Z47nsmbw__ArcResourceAccessor__ArcResourceAccessorPv = 0x802B6760; _Z30nsmbw__ArcResourceAccessor__dtPvi = 0x80006930; _Z31nsmbw__ArcResourceAccessor__SetPvS_PKc = 0x802B67C0; diff --git a/koopatlas.yaml b/koopatlas.yaml index 268ee12..4d65ffb 100644 --- a/koopatlas.yaml +++ b/koopatlas.yaml @@ -4,7 +4,6 @@ source_files: - ../src/fileload.cpp - ../src/scene.S - ../src/levelinfo.cpp - - ../src/levelinfo_old.cpp # backwards compatibility for LevelNames - ../src/koopatlas/core.cpp - ../src/koopatlas/player.cpp - ../src/koopatlas/hud.cpp diff --git a/pregame.yaml b/pregame.yaml new file mode 100644 index 0000000..a3ad7e4 --- /dev/null +++ b/pregame.yaml @@ -0,0 +1,34 @@ +--- +source_files: [../src/pregame.S, ../src/pregame.cpp] +hooks: + - name: PGLH_loadLevelNumber + type: branch_insn + branch_type: b + src_addr_pal: 0x80B6BDD0 + target_func: 'PregameLytHandler::hijack_loadLevelNumber(void)' + + - {name: CRSIN_makeLonger,type: patch,addr_pal: 0x8091F144,data: '380000B4'} + + - {name: PGLH_dis1,type: patch,addr_pal: 0x80b6c1cc,data: '48000238'} + - {name: PGLH_dis2,type: patch,addr_pal: 0x80b6c404,data: '7F83E378'} + + - {name: PGLH_tbGetFix0, type: add_func_pointer, src_addr_pal: 0x80B88658, target_func: 'T_x_00'} + - {name: PGLH_tbGetFix1, type: add_func_pointer, src_addr_pal: 0x80B8865C, target_func: 'T_x_00'} + - {name: PGLH_tbGetFix2, type: add_func_pointer, src_addr_pal: 0x80B88660, target_func: 'T_x_00'} + - {name: PGLH_tbGetFix3, type: add_func_pointer, src_addr_pal: 0x80B88664, target_func: 'T_x_00'} + - {name: PGLH_tbGetFix4, type: add_func_pointer, src_addr_pal: 0x80B88668, target_func: 'T_x_00'} + - {name: PGLH_tbGetFix5, type: add_func_pointer, src_addr_pal: 0x80B886BC, target_func: 'T_x_00'} + + - {name: PGLH_picGetFix0, type: add_func_pointer, src_addr_pal: 0x80B88850, target_func: 'P_bat_00'} + - {name: PGLH_picGetFix1, type: add_func_pointer, src_addr_pal: 0x80B88854, target_func: 'P_bat_00'} + - {name: PGLH_picGetFix2, type: add_func_pointer, src_addr_pal: 0x80B88858, target_func: 'P_bat_00'} + - {name: PGLH_picGetFix3, type: add_func_pointer, src_addr_pal: 0x80B8885C, target_func: 'P_bat_00'} + - {name: PGLH_picGetFix4, type: add_func_pointer, src_addr_pal: 0x80B88860, target_func: 'P_bat_00'} + - {name: PGLH_picGetFix5, type: add_func_pointer, src_addr_pal: 0x80B88864, target_func: 'P_bat_00'} + - {name: PGLH_picGetFix6, type: add_func_pointer, src_addr_pal: 0x80B88868, target_func: 'P_bat_00'} + - {name: PGLH_picGetFix7, type: add_func_pointer, src_addr_pal: 0x80B8886C, target_func: 'P_bat_00'} + - {name: PGLH_picGetFix8, type: add_func_pointer, src_addr_pal: 0x80B88870, target_func: 'P_bat_00'} + - {name: PGLH_picGetFix9, type: add_func_pointer, src_addr_pal: 0x80B88874, target_func: 'P_bat_00'} + - {name: PGLH_picGetFix10, type: add_func_pointer, src_addr_pal: 0x80B88878, target_func: 'P_bat_00'} + - {name: PGLH_picGetFix11, type: add_func_pointer, src_addr_pal: 0x80B888D4, target_func: 'P_bat_00'} + diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index 701053e..a32d32a 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -1,4 +1,5 @@ #include "koopatlas/hud.h" +#include <newer.h> dTexMapColouriser_c::dTexMapColouriser_c() { @@ -351,52 +352,8 @@ void dWMHud_c::loadHeaderInfo() { LevelName->size.x = LevelNameS->size.x = 400.0f; // LEVEL NUMBER - static const wchar_t *numberKinds[] = { - // 0-19 are handled by code - // To insert a picturefont character: - // \x0B\x01YY\xZZZZ - // YY is the character code, ZZZZ is ignored - L"A", // 20, alternate - L"\x0B\x0148\xBEEF", // 21, tower - L"\x0B\x0148\xBEEF" L"2", // 22, tower 2 - L"\x0B\x012E\xBEEF", // 23, castle - L"\x0B\x012F\xBEEF", // 24, fortress - L"\x0B\x013D\xBEEF", // 25, final castle - L"\x0B\x014D\xBEEF", // 26, train - L"\x0B\x0132\xBEEF", // 27, airship - L"Palace", // 28, switch palace - L"\x0B\x0147\xBEEF", // 29, yoshi's house - L"\x0B\x014E\xBEEF" L"1", // 30, key 1 - L"\x0B\x014E\xBEEF" L"2", // 31, key 2 - L"\x0B\x014E\xBEEF" L"3", // 32, key 3 - L"\x0B\x014E\xBEEF" L"4", // 33, key 4 - L"\x0B\x014E\xBEEF" L"5", // 34, key 5 - L"\x0B\x014E\xBEEF" L"6", // 35, key 6 - L"\x0B\x0138\xBEEF", // 36, music house - L"\x0B\x0133\xBEEF", // 37, shop - L"\x0B\x0139\xBEEF", // 38, challenge house - L"\x0B\x0151\xBEEF", // 39, red switch palace - L"\x0B\x0152\xBEEF", // 40, blue switch palace - L"\x0B\x0153\xBEEF", // 41, yellow switch palace - L"\x0B\x0154\xBEEF", // 42, green switch palace - }; - - int origWN = infEntry->displayWorld; - int origWL = infEntry->displayLevel; - wchar_t levelNumber[16]; - levelNumber[0] = (origWN >= 10) ? (origWN-10+'A') : (origWN+'0'); - levelNumber[1] = '-'; - if (origWL >= 20) { - wcscpy(&levelNumber[2], numberKinds[origWL-20]); - } else if (origWL >= 10) { - levelNumber[2] = '1'; - levelNumber[3] = ('0' - 10) + origWL; - levelNumber[4] = 0; - } else { - levelNumber[2] = '0' + origWL; - levelNumber[3] = 0; - } + getNewerLevelNumberString(infEntry->displayWorld, infEntry->displayLevel, levelNumber); LevelNumber->SetString(levelNumber); diff --git a/src/newer.cpp b/src/newer.cpp index 0b53fa6..d1894ba 100644 --- a/src/newer.cpp +++ b/src/newer.cpp @@ -1,6 +1,50 @@ #include <newer.h> #include <game.h> +void getNewerLevelNumberString(int world, int level, wchar_t *dest) { + static const wchar_t *numberKinds[] = { + // 0-19 are handled by code + // To insert a picturefont character: + // \x0B\x01YY\xZZZZ + // YY is the character code, ZZZZ is ignored + L"A", // 20, alternate + L"\x0B\x0148\xBEEF", // 21, tower + L"\x0B\x0148\xBEEF" L"2", // 22, tower 2 + L"\x0B\x012E\xBEEF", // 23, castle + L"\x0B\x012F\xBEEF", // 24, fortress + L"\x0B\x013D\xBEEF", // 25, final castle + L"\x0B\x014D\xBEEF", // 26, train + L"\x0B\x0132\xBEEF", // 27, airship + L"Palace", // 28, switch palace + L"\x0B\x0147\xBEEF", // 29, yoshi's house + L"\x0B\x014E\xBEEF" L"1", // 30, key 1 + L"\x0B\x014E\xBEEF" L"2", // 31, key 2 + L"\x0B\x014E\xBEEF" L"3", // 32, key 3 + L"\x0B\x014E\xBEEF" L"4", // 33, key 4 + L"\x0B\x014E\xBEEF" L"5", // 34, key 5 + L"\x0B\x014E\xBEEF" L"6", // 35, key 6 + L"\x0B\x0138\xBEEF", // 36, music house + L"\x0B\x0133\xBEEF", // 37, shop + L"\x0B\x0139\xBEEF", // 38, challenge house + L"\x0B\x0151\xBEEF", // 39, red switch palace + L"\x0B\x0152\xBEEF", // 40, blue switch palace + L"\x0B\x0153\xBEEF", // 41, yellow switch palace + L"\x0B\x0154\xBEEF", // 42, green switch palace + }; + + dest[0] = (world >= 10) ? (world-10+'A') : (world+'0'); + dest[1] = '-'; + if (level >= 20) { + wcscpy(&dest[2], numberKinds[level-20]); + } else if (level >= 10) { + dest[2] = '1'; + dest[3] = ('0' - 10) + level; + dest[4] = 0; + } else { + dest[2] = '0' + level; + dest[3] = 0; + } +} int getStarCoinCount() { SaveBlock *save = GetSaveFile()->GetBlock(-1); diff --git a/src/pregame.S b/src/pregame.S new file mode 100644 index 0000000..f0e9877 --- /dev/null +++ b/src/pregame.S @@ -0,0 +1,10 @@ +.set sp,1 +.set rtoc,2 + +.text + +.data +.global T_x_00 +T_x_00: .string "T_x_00" +.global P_bat_00 +P_bat_00: .string "P_bat_00" diff --git a/src/pregame.cpp b/src/pregame.cpp new file mode 100644 index 0000000..7600902 --- /dev/null +++ b/src/pregame.cpp @@ -0,0 +1,126 @@ +#include <game.h> +#include "levelinfo.h" +#include <newer.h> + +dDvdLoader_c s_levelInfoLoader; +dLevelInfo_c s_levelInfo; +bool s_levelInfoLoaded = false; + +// TODO: refactor this a tiny bit +bool LoadLevelInfo() { + if (s_levelInfoLoaded) + return true; + + void *data = s_levelInfoLoader.load("/NewerRes/LevelInfo.bin"); + if (data) { + s_levelInfo.load(data); + s_levelInfoLoaded = true; + return true; + } + + return false; +} + +class PregameLytHandler { + public: + m2d::EmbedLayout_c layout; + + nw4r::lyt::Pane *rootPane; + + nw4r::lyt::TextBox + *T_minus_00, *T_world_00, *T_worldNum_00, + *T_pictureFont_00, *T_corseNum_00, + *T_remainder_00, *T_remainder_01, *T_remainder_02, *T_remainder_03, + *T_remainder_10, *T_remainder_11, *T_remainder_12, *T_remainder_13, + *T_x_00, *T_x_01, *T_x_02, *T_x_03, *T_x_10, *T_x_11, *T_x_12, *T_x_13, + *T_x_00_o, *T_x_10_o, + *T_otasukePlay_00, *T_otasukePlay_01, + *T_recommend_00, *T_remainder_00_o, *T_remainder_10_o; + + nw4r::lyt::Picture + *P_Wx_00[9], *P_coin_00, *P_free_00, + *P_batB_0x[4], *P_bat_00, + *P_batB_1x[4], *P_bat_01, + *P_batB_2x[4], *P_bat_02, + *P_batB_3x[4], *P_bat_03, + *P_luijiIcon_00_o, *P_luijiIcon_10_o, *P_coinStage_00; + + nw4r::lyt::Pane + *N_mario_00, *N_luiji_00, *N_kinoB_01, *N_kinoY_00, + *N_zankiPos_x[4], *N_zanki_00, + *Null_battPosxP[4], *N_batt_x[4], + *N_batt, *N_otasukePlay_00; + + u8 layoutLoaded, somethingHasBeenDone, isVisible, hasShownLuigiThing_orSomething; + + u32 currentStateID; + + u32 _2E8; + + u32 countdownToEndabilityCopy, activePlayerCountMultBy4_maybe; + u32 batteryLevels[4]; + u32 pgCountdown; + + void hijack_loadLevelNumber(); // replaces 80B6BDD0 +}; + +// Notes: +// Deleted; P_coinStage_00, T_recommend_00, T_worldNum_00, +// T_-_00, T_pictureFont_00, T_corseNum_00, T_world_00 +// P_Wx_00, P_coin_00, P_free_00 + +extern char CurrentLevel; +extern char CurrentWorld; + +#include "fileload.h" +void PregameLytHandler::hijack_loadLevelNumber() { + nw4r::lyt::TextBox + *LevelNumShadow, *LevelNum, + *LevelNameShadow, *LevelName; + + LevelNumShadow = layout.findTextBoxByName("LevelNumShadow"); + LevelNum = layout.findTextBoxByName("LevelNum"); + LevelNameShadow = layout.findTextBoxByName("LevelNameShadow"); + LevelName = layout.findTextBoxByName("LevelName"); + + // work out the thing now + dLevelInfo_c::entry_s *level = s_levelInfo.searchBySlot(CurrentWorld, CurrentLevel); + if (level) { + wchar_t convLevelName[160]; + const char *srcLevelName = s_levelInfo.getNameForLevel(level); + int i = 0; + while (i < 159 && srcLevelName[i]) { + convLevelName[i] = srcLevelName[i]; + i++; + } + convLevelName[i] = 0; + LevelNameShadow->SetString(convLevelName); + LevelName->SetString(convLevelName); + + wchar_t levelNumber[32]; + wcscpy(levelNumber, L"World "); + getNewerLevelNumberString(level->displayWorld, level->displayLevel, &levelNumber[6]); + + LevelNumShadow->SetString(levelNumber); + LevelNum->SetString(levelNumber); + + } else { + LevelNameShadow->SetString(L"Not found in LevelInfo!"); + LevelName->SetString(L"Not found in LevelInfo!"); + } + + nw4r::lyt::Picture *LevelSample; + LevelSample = layout.findPictureByName("LevelSample"); + + // this is not the greatest way to read a file but I suppose it works in a pinch + char tplName[64]; + sprintf(tplName, "/LevelSamples/%02d-%02d.tpl", CurrentWorld+1, CurrentLevel+1); + static File tpl; + if (tpl.open(tplName)) { + LevelSample->material->texMaps[0].ReplaceImage((TPLPalette*)tpl.ptr(), 0); + } +} + + + + diff --git a/src/randtiles.cpp b/src/randtiles.cpp index da86a92..f1b2392 100644 --- a/src/randtiles.cpp +++ b/src/randtiles.cpp @@ -93,16 +93,20 @@ RandomTileData *RandomTileData::instance = 0; dDvdLoader_c RandTileLoader;
+// This is a bit hacky but I'm lazy
+bool LoadLevelInfo();
+
extern "C" bool RandTileLoadHook() {
// OSReport("Trying to load...");
void *buf = RandTileLoader.load("/NewerRes/RandTiles.bin");
+ bool LIresult = LoadLevelInfo();
if (buf == 0) {
// OSReport("Failed.\n");
return false;
} else {
// OSReport("Successfully loaded RandTiles.bin [%p].\n", buf);
RandomTileData::instance = (RandomTileData*)buf;
- return true;
+ return LIresult;
}
}
|