From 72b2cb8e1bcb9970136efc8dc57b20b95ff7d082 Mon Sep 17 00:00:00 2001 From: Treeki Date: Sun, 13 Mar 2011 02:34:58 +0100 Subject: compiles now! untested, though. also did some work on dWMResourceMng_c --- include/game.h | 2 +- kamek_ntsc.x | 8 ++++++++ kamek_ntsc2.x | 8 ++++++++ kamek_pal.x | 8 ++++++++ kamek_pal2.x | 8 ++++++++ src/wmresourcemng.cpp | 33 ++++++++++++++++++++++++++++++++- src/worldmap.cpp | 14 +++++++++++--- src/worldmap.h | 4 ++++ tools/mapfile_tool.py | 2 -- 9 files changed, 80 insertions(+), 7 deletions(-) diff --git a/include/game.h b/include/game.h index cb567f3..6df656f 100755 --- a/include/game.h +++ b/include/game.h @@ -1081,7 +1081,7 @@ public: dDvdLoader_c(); // 8008F140 virtual ~dDvdLoader_c(); // 8008F170 - void *load(const char *filename, u8 unk = 0); // 8008F1B0 + void *load(const char *filename, u8 unk = 0, void *heap = 0); // 8008F1B0 bool close(); // 8008F2B0 -- Frees command, DON'T USE THIS unless you free the buffer yourself bool unload(); // 8008F310 -- Frees command and buffer, USE THIS diff --git a/kamek_ntsc.x b/kamek_ntsc.x index 45f1063..272affd 100644 --- a/kamek_ntsc.x +++ b/kamek_ntsc.x @@ -86,6 +86,9 @@ SECTIONS { __nw__FUl = 0x802B9210; __dl__FPv = 0x802B9280; + __construct_new_array = 0x802DC7E0; + __destroy_new_array = 0x802DCB10; + willBeDeleted__7fBase_cFv = 0x801622D0; moreHeapShit__7fBase_cFUiPv = 0x801625F0; @@ -275,6 +278,11 @@ SECTIONS { DVD_End__Fv = 0x8006A760; DVD_GetFile__FPvPCcPCc = 0x800DF180; + __ct__12dDvdLoader_cFv = 0x8008F140; + __dt__12dDvdLoader_cFv = 0x8008F170; + load__12dDvdLoader_cFPCcUcPv = 0x8008F1B0; + unload__12dDvdLoader_cFv = 0x8008F310; + _Z22BgTexMng__LoadAnimTilePvisPcS0_c = 0x80087B60; /* same for ntsc */ BgTexMng__LoadAnimTile__FPvisPcPcc = 0x80087B60; /* same for ntsc */ diff --git a/kamek_ntsc2.x b/kamek_ntsc2.x index 50d951e..e89820e 100644 --- a/kamek_ntsc2.x +++ b/kamek_ntsc2.x @@ -86,6 +86,9 @@ SECTIONS { __nw__FUl = 0x802B9210; __dl__FPv = 0x802B9280; + __construct_new_array = 0x802DC7E0; + __destroy_new_array = 0x802DCB10; + willBeDeleted__7fBase_cFv = 0x801622D0; moreHeapShit__7fBase_cFUiPv = 0x801625F0; @@ -275,6 +278,11 @@ SECTIONS { DVD_End__Fv = 0x8006A760; DVD_GetFile__FPvPCcPCc = 0x800DF180; + __ct__12dDvdLoader_cFv = 0x8008F140; + __dt__12dDvdLoader_cFv = 0x8008F170; + load__12dDvdLoader_cFPCcUcPv = 0x8008F1B0; + unload__12dDvdLoader_cFv = 0x8008F310; + _Z22BgTexMng__LoadAnimTilePvisPcS0_c = 0x80087B60; /* same for ntsc */ BgTexMng__LoadAnimTile__FPvisPcPcc = 0x80087B60; /* same for ntsc */ diff --git a/kamek_pal.x b/kamek_pal.x index cbfa970..92fd6ab 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -86,6 +86,9 @@ SECTIONS { __nw__FUl = 0x802B9350; __dl__FPv = 0x802B93C0; + __construct_new_array = 0x802DCAD0; + __destroy_new_array = 0x802DCE00; + willBeDeleted__7fBase_cFv = 0x80162410; moreHeapShit__7fBase_cFUiPv = 0x80162730; @@ -275,6 +278,11 @@ SECTIONS { DVD_End__Fv = 0x8006A760; DVD_GetFile__FPvPCcPCc = 0x800DF270; + __ct__12dDvdLoader_cFv = 0x8008F140; + __dt__12dDvdLoader_cFv = 0x8008F170; + load__12dDvdLoader_cFPCcUcPv = 0x8008F1B0; + unload__12dDvdLoader_cFv = 0x8008F310; + _Z22BgTexMng__LoadAnimTilePvisPcS0_c = 0x80087B60; /* same for ntsc */ BgTexMng__LoadAnimTile__FPvisPcPcc = 0x80087B60; /* same for ntsc */ diff --git a/kamek_pal2.x b/kamek_pal2.x index 684d968..28f0135 100644 --- a/kamek_pal2.x +++ b/kamek_pal2.x @@ -86,6 +86,9 @@ SECTIONS { __nw__FUl = 0xDEADBEEF; __dl__FPv = 0xDEADBEEF; + __construct_new_array = 0xDEADBEEF; + __destroy_new_array = 0xDEADBEEF; + willBeDeleted__7fBase_cFv = 0xDEADBEEF; moreHeapShit__7fBase_cFUiPv = 0xDEADBEEF; @@ -275,6 +278,11 @@ SECTIONS { DVD_End__Fv = 0xDEADBEEF; DVD_GetFile__FPvPCcPCc = 0xDEADBEEF; + __ct__12dDvdLoader_cFv = 0xDEADBEEF; + __dt__12dDvdLoader_cFv = 0xDEADBEEF; + load__12dDvdLoader_cFPCcUcPv = 0xDEADBEEF; + unload__12dDvdLoader_cFv = 0xDEADBEEF; + _Z22BgTexMng__LoadAnimTilePvisPcS0_c = 0xDEADBEEF; /* same for ntsc */ BgTexMng__LoadAnimTile__FPvisPcPcc = 0xDEADBEEF; /* same for ntsc */ diff --git a/src/wmresourcemng.cpp b/src/wmresourcemng.cpp index 4a71753..241dff3 100644 --- a/src/wmresourcemng.cpp +++ b/src/wmresourcemng.cpp @@ -59,7 +59,11 @@ bool dWMResourceMng_c::loadSet(const char *setName) { isLoadingComplete &= (resLoaders[i].load(setData->getName(i)) != 0); } - // if they are ALL loaded, then we'll return true! + // if they are ALL loaded, then this will be true + if (isLoadingComplete) { + prepareResources(); + } + return isLoadingComplete; } @@ -76,3 +80,30 @@ void *dWMResourceMng_c::operator[](u32 key) { return 0; } + +void dWMResourceMng_c::prepareResources() { + // first off, initialise every brres file used + for (int i = 0; i < resCount(); i++) { + if ((keyForIndex(i) >> 16) == '3D') { + nw4r::g3d::ResFile resFile(dataForIndex(i)); + resFile.CheckRevision(); + resFile.Init(); + } + } + + // now that they're all initialised, loop through the brres files and bind + // them to every other file ... because I don't think it's a good idea to + // bind them before they've been initialised + for (int i = 0; i < resCount(); i++) { + if ((keyForIndex(i) >> 16) == '3D') { + nw4r::g3d::ResFile firstFile(dataForIndex(i)); + + for (int j = 0; j < resCount(); j++) { + nw4r::g3d::ResFile secondFile(dataForIndex(j)); + + firstFile.Bind(secondFile); + } + } + } +} + diff --git a/src/worldmap.cpp b/src/worldmap.cpp index e0e3d58..45d3d24 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -249,15 +249,23 @@ int dScNewerWorldMap_c::onExecute() { /**********************************************************************/ // STATE_END_DVD : Wait for files to load, end DVD - case STATE_END_DVD: + // Also, load the WM Set files + case STATE_END_DVD: { + + bool didEndDVD = false, didWMSetLoad = false; if (!DVD_StillLoading(GetDVDClass2())) { if (DVD_End()) { - this->state = STATE_SETUP_WAIT; + didEndDVD = true; } } - break; + didWMSetLoad = resMng.loadSet("SMGoldwood"); + + if (didEndDVD && didWMSetLoad) + this->state = STATE_SETUP_WAIT; + + } break; /**********************************************************************/ // STATE_SETUP_WAIT : Waiting for the world map managers to be set up diff --git a/src/worldmap.h b/src/worldmap.h index a1d5b12..d30d907 100644 --- a/src/worldmap.h +++ b/src/worldmap.h @@ -61,6 +61,8 @@ private: WMResSetHeader *setData; + void prepareResources(); + public: dWMResourceMng_c(); ~dWMResourceMng_c(); @@ -150,6 +152,8 @@ public: void *levelInfo; FileHandle levelInfoFH; + dWMResourceMng_c resMng; + mHeapAllocator_c allocator; File modelFile; m3d::mdl_c model; diff --git a/tools/mapfile_tool.py b/tools/mapfile_tool.py index 4ebd288..f4f5d66 100755 --- a/tools/mapfile_tool.py +++ b/tools/mapfile_tool.py @@ -266,8 +266,6 @@ def main(): do_project('NewerProject.yaml') - do_module('anotherhax.yaml', 'processed/anotherhax.yaml') - if __name__ == '__main__': main() -- cgit v1.2.3