diff options
author | Treeki <treeki@gmail.com> | 2011-03-23 21:39:58 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-03-23 21:39:58 +0100 |
commit | f7e7a1eea2e66ea507fc5a2b0813ec02493133a9 (patch) | |
tree | ea7fba70961c0969d0b59d5ff280662dbecd57df /src | |
parent | a830e87d71ffece4b0a6285d4bd0336686e7f446 (diff) | |
download | kamek-f7e7a1eea2e66ea507fc5a2b0813ec02493133a9.tar.gz kamek-f7e7a1eea2e66ea507fc5a2b0813ec02493133a9.zip |
added HUD support and some more debug stuff
Diffstat (limited to '')
-rw-r--r-- | src/scene.S | 68 | ||||
-rw-r--r-- | src/wm_hud.cpp | 57 | ||||
-rw-r--r-- | src/wm_map.cpp | 19 | ||||
-rw-r--r-- | src/wm_player.cpp | 49 | ||||
-rw-r--r-- | src/worldmap.cpp | 52 | ||||
-rw-r--r-- | src/worldmap.h | 27 |
6 files changed, 218 insertions, 54 deletions
diff --git a/src/scene.S b/src/scene.S index 8a8404c..d4e1ac8 100644 --- a/src/scene.S +++ b/src/scene.S @@ -8,6 +8,7 @@ .extern AssignAnmScnToLightInfo .extern LoadBlight .extern LoadBlmap +.extern OSReport .text @@ -22,8 +23,16 @@ LoadMapScene: stw r0, 0x34(sp) stw r31, 0x2C(sp) + stw r30, 0x28(sp) + stw r29, 0x24(sp) + lis r30, m_str@h + ori r30, r30, m_str@l + mr r3, r30 + li r4, 1 + crclr 4*cr1+eq + bl OSReport lis r3, currentHeap@h ori r3, r3, currentHeap@l @@ -37,6 +46,10 @@ LoadMapScene: bl MakeScene + mr r3, r30 + li r4, 2 + crclr 4*cr1+eq + bl OSReport # Now make the actual scene! # Get light info @@ -44,9 +57,15 @@ LoadMapScene: bl GetSceneLightInfo mr r31, r3 + mr r3, r30 + li r4, 3 + crclr 4*cr1+eq + bl OSReport + # Get scene/scene.brres lis r3, DVDClass@h ori r3, r3, DVDClass@l + lwz r3, 0(r3) addi r3, r3, 4 lis r4, EnvWorld@h @@ -60,17 +79,32 @@ LoadMapScene: # Got that, now get the AnmScn we want (MainSelect) stw r3, 0x0C(sp) #ResFile + mr r3, r30 + li r4, 4 + crclr 4*cr1+eq + bl OSReport + addi r3, sp, 0xC lis r4, MainSelect@h ori r4, r4, MainSelect@l bl GetAnmScn stw r3, 0x10(sp) + mr r3, r30 + li r4, 5 + crclr 4*cr1+eq + bl OSReport + # Bind it addi r3, sp, 0x10 addi r4, sp, 0x10 bl BindAnmScn + mr r3, r30 + li r4, 6 + crclr 4*cr1+eq + bl OSReport + # Add it to lightinfo mr r3, r31 #This addi r4, sp, 0x10 #AnmScn pointer @@ -83,11 +117,16 @@ LoadMapScene: bl AssignAnmScnToLightInfo + mr r3, r30 + li r4, 7 + crclr 4*cr1+eq + bl OSReport # Now set up the rest of the scene # Get blight lis r3, DVDClass@h ori r3, r3, DVDClass@l + lwz r3, 0(r3) addi r3, r3, 4 lis r4, EnvWorld@h @@ -97,17 +136,28 @@ LoadMapScene: ori r5, r5, BlightW1@l bl GetRes + mr r29, r3 + + mr r3, r30 + li r4, 8 + crclr 4*cr1+eq + bl OSReport # Load it into lightinfo - mr r4, r3 mr r3, r31 + mr r4, r29 bl LoadBlight + mr r3, r30 + li r4, 9 + crclr 4*cr1+eq + bl OSReport # Do the same for blmap lis r3, DVDClass@h ori r3, r3, DVDClass@l + lwz r3, 0(r3) addi r3, r3, 4 lis r4, EnvWorld@h @@ -117,14 +167,26 @@ LoadMapScene: ori r5, r5, BlmapW1@l bl GetRes + mr r29, r3 + + mr r3, r30 + li r4, 10 + crclr 4*cr1+eq + bl OSReport # Load it into its class - mr r4, r3 lwz r3, 0x14(r31) + mr r4, r29 bl LoadBlmap + mr r3, r30 + li r4, 11 + crclr 4*cr1+eq + bl OSReport # DONE!! + lwz r29, 0x24(sp) + lwz r30, 0x28(sp) lwz r31, 0x2C(sp) lwz r0, 0x34(sp) @@ -145,5 +207,7 @@ Zero: .float 0.0 BlightW1: .string "light/W8.blight" BlmapW1: .string "light/W8.blmap" +m_str: .string "LMS:%d\n" + .align 4 diff --git a/src/wm_hud.cpp b/src/wm_hud.cpp new file mode 100644 index 0000000..670683c --- /dev/null +++ b/src/wm_hud.cpp @@ -0,0 +1,57 @@ +#include "worldmap.h" + +dWMHud_c *dWMHud_c::instance = 0; + +dWMHud_c *dWMHud_c::build() { + OSReport("Creating WM_Hud\n"); + + void *buffer = AllocFromGameHeap1(sizeof(dWMHud_c)); + dWMHud_c *c = new(buffer) dWMHud_c; + + OSReport("Created WM_Hud @ %p\n", c); + + instance = c; + return c; +} + + + +dWMHud_c::dWMHud_c() { + layoutLoaded = false; +} + + +int dWMHud_c::onCreate() { + if (!layoutLoaded) { + bool gotFile = layout.loadArc("maphud.arc", false); + if (!gotFile) + return false; + + layout.build("banner.brlyt"); + + layoutLoaded = true; + } + + return true; +} + + +int dWMHud_c::onDelete() { + return layout.free(); +} + + +int dWMHud_c::onExecute() { + layout.execAnimations(); + layout.update(); + + return true; +} + + +int dWMHud_c::onDraw() { + layout.scheduleForDrawing(); + + return true; +} + diff --git a/src/wm_map.cpp b/src/wm_map.cpp index 83ed637..ad3500d 100644 --- a/src/wm_map.cpp +++ b/src/wm_map.cpp @@ -16,8 +16,9 @@ dWMMap_c *dWMMap_c::build() { - int dWMMap_c::onCreate() { + SpammyReport("dWMMap_c::onCreate() called\n"); + // Get the resource void *scnRes = dScNewerWorldMap_c::instance->resMng['SCN0']; if (scnRes == 0) { @@ -25,12 +26,17 @@ int dWMMap_c::onCreate() { return false; } + testID++; + data = (WMSceneDataHeader*)scnRes; + SpammyReport("Loaded resource: %d nodes\n", data->nodeCount); // load up all the nodes, and fix up all the name offsets while we're at it + SpammyReport("Allocating node array\n"); nodes = new WMSceneNode[data->nodeCount]; // link the mHeapAllocator so it can be used for models + SpammyReport("Linking allocator\n"); allocator.link(-1, GameHeaps[0], 0, 0x20); for (int i = 0; i < data->nodeCount; i++) { @@ -41,8 +47,10 @@ int dWMMap_c::onCreate() { node->loadFrom(nodeData, &allocator); } + SpammyReport("Unlinking allocator\n"); allocator.unlink(); + SpammyReport("dWMMap_c::onCreate() completed\n"); return true; } @@ -60,10 +68,14 @@ int dWMMap_c::onExecute() { int dWMMap_c::onDraw() { + SpammyReport("dWMMap_c::onDraw() called\n"); + for (int i = 0; i < data->nodeCount; i++) { + SpammyReport("Drawing node %d\n", i); nodes[i].draw(); } + SpammyReport("dWMMap_c::onDraw() completed\n"); return true; } @@ -88,12 +100,17 @@ void WMSceneNode::loadFrom(WMSceneDataNode *data, mHeapAllocator_c *allocator) { MapReport(model.setup(&mdl, allocator, 0, 1, 0) ? "Success\n" : "Fail\n"); // todo: more types + SpammyReport("Setting up lightmaps\n"); + if (data->lmType == 0) SetupTextures_Map(&model, 1); else if (data->lmType == 1) SetupTextures_MapObj(&model, 1); + SpammyReport("Lightmaps done\n"); + model.setDrawMatrix(data->matrix); + SpammyReport("Node is ready\n"); } diff --git a/src/wm_player.cpp b/src/wm_player.cpp index ef838a2..a7c150a 100644 --- a/src/wm_player.cpp +++ b/src/wm_player.cpp @@ -19,51 +19,6 @@ int daWMPlayer_c::onCreate() { current_param = 0; - /*//#define BRRES_NAME "fruits_kusa_gake" - //#define MODEL_NAME "fruits_kusa_gake_S" - - #define BRRES_NAME "bgB_4502" - #define MODEL_NAME BRRES_NAME - - OSReport("Loading nw4r model\n"); - //LoadFile(&this->nw4rMdlFH, "/Object/" BRRES_NAME ".arc"); - LoadFile(&this->nw4rMdlFH, "/Object/CrapMap.arc"); - OSReport("Loaded. Reading arc\n"); - ARCHandle arc; - ARCFileInfo keyinfo; - ARCInitHandle(this->nw4rMdlFH.filePtr, &arc); - //bool arcres = ARCOpen(&arc, "g3d/" BRRES_NAME ".brres", &keyinfo); - bool arcres = ARCOpen(&arc, "g3d/model.brres", &keyinfo); - OSReport(arcres ? "Success\n" : "Fail\n"); - - OSReport("Getting nw4r model\n"); - //void *brres = DVD_GetFile(GetDVDClass2(), "fruits_kusa_gake", "g3d/fruits_kusa_gake.brres"); - - OSReport("Done. Constructing model\n"); - void *brres = ARCGetStartAddrInMem(&keyinfo); - OSReport("brres @ %p\n", brres); - nw4r::g3d::ResFile resfile(brres); - OSReport(resfile.CheckRevision() ? "Success\n" : "Fail\n"); - resfile.Init(); - OSReport(resfile.Bind(resfile) ? "Success\n" : "Fail\n"); - //void *mdl = resfile.GetResMdl(MODEL_NAME); - void *mdl = resfile.GetResMdl("CrapMap"); - OSReport("MDL @ %p, %d\n", mdl, 1099); - //this->nw4rMdlTest = nw4r::g3d::ConstructScnMdl(mdl, 0x20, 1); - //this->nw4rMdlTest = nw4r::g3d::ConstructScnMdlSimple(mdl, 1); - OSReport(this->allocator.link(-1, GameHeaps[0], 0, 0x20) ? "Success\n" : "Fail\n"); - OSReport(this->nw4rMdl.setup(&mdl, &this->allocator, 0, 1, 0) ? "Success\n" : "Fail\n"); - //this->nw4rMdl.sub_80064BF0(); - //this->nw4rMdl.oneSetupType(); - OSReport("Unlink returned %d\n", this->allocator.unlink()); - OSReport("Done!\n"); - - Mtx asdf; - MTXIdentity(asdf); - this->nw4rMdl.setDrawMatrix(asdf); - - ARCClose(&keyinfo);*/ - return true; } @@ -157,10 +112,6 @@ int daWMPlayer_c::onExecute() { int daWMPlayer_c::onDraw() { this->modelHandler->draw(); - //OSReport("Adding to scene\n"); - //this->nw4rMdl.scheduleForDrawing(); - //OSReport("done\n"); - return true; } diff --git a/src/worldmap.cpp b/src/worldmap.cpp index 12c3486..4f8b0c5 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -97,11 +97,15 @@ dScNewerWorldMap_c::dScNewerWorldMap_c() { #define CONT_UNK3(cont) (*((bool*)(((u32)(cont))+0x2E0)))
bool WMInit_StartLoading(void *ptr) {
+ SpammyReport("WMInit_StartLoading called\n");
+
DVD_Start();
return true;
}
bool WMInit_LoadSIAnims(void *ptr) {
+ SpammyReport("WMInit_LoadSIAnims called\n");
+
DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_kinoko", 0);
DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_fireflower", 0);
DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_iceflower", 0);
@@ -112,19 +116,28 @@ bool WMInit_LoadSIAnims(void *ptr) { }
bool WMInit_EndLoading(void *ptr) {
- if (DVD_StillLoading(GetDVDClass2()))
+ SpammyReport("WMInit_EndLoading called\n");
+
+ if (DVD_StillLoading(GetDVDClass2())) {
+ SpammyReport("WMInit_EndLoading returning false\n");
return false;
+ }
DVD_End();
+ SpammyReport("WMInit_EndLoading returning true\n");
return true;
}
bool WMInit_LoadResources(void *ptr) {
+ SpammyReport("WMInit_LoadResources returning true\n");
+
dScNewerWorldMap_c *wm = (dScNewerWorldMap_c*)ptr;
return wm->resMng.loadSet("MMFullWorld");
}
bool WMInit_SetupWait(void *ptr) {
+ SpammyReport("WMInit_SetupWait called\n");
+
dScNewerWorldMap_c *wm = (dScNewerWorldMap_c*)ptr;
bool success = true;
@@ -142,6 +155,8 @@ bool WMInit_SetupWait(void *ptr) { }
bool WMInit_SetupExtra(void *ptr) {
+ SpammyReport("WMInit_SetupExtra called\n");
+
// ok, now we can set up other required shit
dScNewerWorldMap_c *wm = (dScNewerWorldMap_c*)ptr;
@@ -176,16 +191,22 @@ bool WMInit_SetupExtra(void *ptr) { // is last param correct? must check :/
wm->map = (dWMMap_c*)CreateParentedObject(WM_MAP, wm, 0, 0);
+ wm->hud = (dWMHud_c*)CreateParentedObject(WM_HUD, wm, 0, 0);
return true;
}
bool WMInit_SetupWipe(void *ptr) {
+ SpammyReport("WMInit_SetupWipe called\n");
+
dScNewerWorldMap_c *wm = (dScNewerWorldMap_c*)ptr;
- if (wm->hasUninitialisedProcesses())
+ if (wm->hasUninitialisedProcesses()) {
+ SpammyReport("WMInit_SetupWipe returning false\n");
return false;
+ }
+ SpammyReport("WMInit_SetupWipe returning true\n");
return true;
}
@@ -255,19 +276,35 @@ void dScNewerWorldMap_c::StartLevel(LevelInfo::Entry *entry) { int dScNewerWorldMap_c::onCreate() {
+ SpammyReport("onCreate() called\n");
+
+ SpammyReport("LoadMapScene()\n");
LoadMapScene();
+
+ SpammyReport("GameSetup__LoadScene(0)\n");
GameSetup__LoadScene(0); // lol, stolen from GAME_SETUP
+ SpammyReport("select cursor\n");
this->selectCursor = CreateParentedObject(SELECT_CURSOR, this, 0, 0);
+
+ SpammyReport("cs menu\n");
this->csMenu = CreateParentedObject(COURSE_SELECT_MENU, this, 0, 0);
+
+ SpammyReport("yes no window\n");
this->yesNoWindow = CreateParentedObject(YES_NO_WINDOW, this, 0, 0);
+
+ SpammyReport("number of people change\n");
this->numPeopleChange = CreateParentedObject(NUMBER_OF_PEOPLE_CHANGE, this, 0, 0);
for (int i = 0; i < 4; i++) {
+ SpammyReport("ccsb %d\n", i);
void *ccsb = CreateParentedObject(CHARACTER_CHANGE_SELECT_BASE, this, i, 0);
+ SpammyReport("ccsc %d\n", i);
void *ccsc = CreateParentedObject(CHARACTER_CHANGE_SELECT_CONTENTS, this, i, 0);
+ SpammyReport("ccsa %d\n", i);
void *ccsa = CreateParentedObject(CHARACTER_CHANGE_SELECT_ARROW, this, i, 0);
+ SpammyReport("ccsi %d\n", i);
void *cci = CreateParentedObject(CHARACTER_CHANGE_INDICATOR, this, i, 0);
NPCHG_CCSB(this->numPeopleChange, i) = ccsb;
@@ -276,32 +313,43 @@ int dScNewerWorldMap_c::onCreate() { NPCHG_CCI(this->numPeopleChange, i) = cci;
}
+ SpammyReport("continue\n");
this->continueObj = CreateParentedObject(CONTINUE, this, 0, 0);
// check if we need to handle Continue
if (CheckIfContinueShouldBeActivated()) {
+ SpammyReport("continue is activated\n");
this->state = STATE_CONTINUE_WAIT;
CONT_UNK1(this->continueObj) = true;
CONT_UNK2(this->continueObj) = true;
CONT_UNK3(this->continueObj) = false;
} else {
+ SpammyReport("continue is not activated\n");
this->state = STATE_NORMAL;
}
+ SpammyReport("stock item\n");
this->stockItem = CreateParentedObject(STOCK_ITEM, this, 0, 0);
+ SpammyReport("stock item shadow\n");
this->stockItemShadow = CreateParentedObject(STOCK_ITEM_SHADOW, this, 0, 0);
STKI_SHADOW(this->stockItem) = this->stockItemShadow;
+ SpammyReport("easy pairing\n");
this->easyPairing = CreateParentedObject(EASY_PAIRING, this, 0, 0);
+ SpammyReport("world camera\n");
CreateParentedObject(WORLD_CAMERA, this, 0, 0);
+ SpammyReport("setting NewerMapDrawFunc\n");
*CurrentDrawFunc = NewerMapDrawFunc;
// level info
+ SpammyReport("loading level info file\n");
levelInfoFile.open("/NewerRes/LevelInfo.bin");
+ SpammyReport("preparing level info\n");
levelInfo.load(levelInfoFile.ptr());
+ SpammyReport("onCreate() completed\n");
return true;
}
diff --git a/src/worldmap.h b/src/worldmap.h index 5378c73..553abdd 100644 --- a/src/worldmap.h +++ b/src/worldmap.h @@ -12,6 +12,7 @@ #define __NEWER_WORLDMAP_H
#define WM_DEBUGGING
+#define WM_SPAMMY_DEBUGGING
#include <common.h>
#include <game.h>
@@ -36,9 +37,34 @@ enum WMDirection { inline void MapReport(const char *str, ...) { }
#endif
+#ifdef WM_SPAMMY_DEBUGGING
+#define SpammyReport OSReport
+#else
+inline void SpammyReport(const char *str, ...) { }
+#endif
+
void NewerMapDrawFunc();
+// Replacing some process IDs
+#define WM_HUD WM_ANTLION
+
+
+class dWMHud_c : public dBase_c {
+public:
+ dWMHud_c();
+
+ int onCreate();
+ int onDelete();
+ int onExecute();
+ int onDraw();
+
+ bool layoutLoaded;
+ m2d::EmbedLayout_c layout;
+
+ static dWMHud_c *build();
+ static dWMHud_c *instance;
+};
class dWorldCamera_c : public dBase_c {
@@ -108,6 +134,7 @@ public: daWMPlayer_c *player;
dWMMap_c *map;
+ dWMHud_c *hud;
bool isMoving;
WMPathPoint *currentPoint;
|