summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-09-15 23:39:54 +0200
committerTreeki <treeki@gmail.com>2012-09-15 23:39:54 +0200
commitcb5dcc681f1f41322d3b649902e90133d277c857 (patch)
tree2255a7aa424af66b023b9698dd41e1506442e3cf
parentd03b7871950f89623f1f90facde2f5df89e9e136 (diff)
downloadkamek-cb5dcc681f1f41322d3b649902e90133d277c857.tar.gz
kamek-cb5dcc681f1f41322d3b649902e90133d277c857.zip
added unfinished PalaceDude
-rw-r--r--src/msgbox.cpp45
-rw-r--r--src/msgbox.h50
-rw-r--r--src/palaceDude.cpp50
-rw-r--r--switchblock.yaml15
-rw-r--r--tools/UsedProfileAndSpriteList.txt3
5 files changed, 117 insertions, 46 deletions
diff --git a/src/msgbox.cpp b/src/msgbox.cpp
index adbeb24..9a5fb25 100644
--- a/src/msgbox.cpp
+++ b/src/msgbox.cpp
@@ -1,52 +1,9 @@
#include <common.h>
#include <game.h>
+#include "msgbox.h"
// Replaces: EN_LIFT_ROTATION_HALF (Sprite 107; Profile ID 481 @ 80AF96F8)
-class dMsgBoxManager_c : public dStageActor_c {
- public:
- void showMessage(int id);
-
- dMsgBoxManager_c() : state(this, &StateID_LoadRes) { }
-
- int onCreate();
- int onDelete();
- int onExecute();
- int onDraw();
-
- int beforeExecute() { return true; }
- int afterExecute(int) { return true; }
-
- m2d::EmbedLayout_c layout;
- dDvdLoader_c msgDataLoader;
-
- bool layoutLoaded;
- bool visible;
-
- dStateWrapper_c<dMsgBoxManager_c> state;
-
- USING_STATES(dMsgBoxManager_c);
- DECLARE_STATE(LoadRes);
- DECLARE_STATE(Wait);
- DECLARE_STATE(BoxAppearWait);
- DECLARE_STATE(ShownWait);
- DECLARE_STATE(BoxDisappearWait);
-
- static dMsgBoxManager_c *instance;
- static dMsgBoxManager_c *build();
-
- private:
- struct entry_s {
- u32 id;
- u32 titleOffset;
- u32 msgOffset;
- };
-
- struct header_s {
- u32 count;
- entry_s entry[1];
- };
-};
dMsgBoxManager_c *dMsgBoxManager_c::instance = 0;
dMsgBoxManager_c *dMsgBoxManager_c::build() {
diff --git a/src/msgbox.h b/src/msgbox.h
new file mode 100644
index 0000000..032b5c8
--- /dev/null
+++ b/src/msgbox.h
@@ -0,0 +1,50 @@
+#ifndef MSGBOX_H
+#define MSGBOX_H
+#include <common.h>
+#include <game.h>
+
+class dMsgBoxManager_c : public dStageActor_c {
+ public:
+ void showMessage(int id);
+
+ dMsgBoxManager_c() : state(this, &StateID_LoadRes) { }
+
+ int onCreate();
+ int onDelete();
+ int onExecute();
+ int onDraw();
+
+ int beforeExecute() { return true; }
+ int afterExecute(int) { return true; }
+
+ m2d::EmbedLayout_c layout;
+ dDvdLoader_c msgDataLoader;
+
+ bool layoutLoaded;
+ bool visible;
+
+ dStateWrapper_c<dMsgBoxManager_c> state;
+
+ USING_STATES(dMsgBoxManager_c);
+ DECLARE_STATE(LoadRes);
+ DECLARE_STATE(Wait);
+ DECLARE_STATE(BoxAppearWait);
+ DECLARE_STATE(ShownWait);
+ DECLARE_STATE(BoxDisappearWait);
+
+ static dMsgBoxManager_c *instance;
+ static dMsgBoxManager_c *build();
+
+ private:
+ struct entry_s {
+ u32 id;
+ u32 titleOffset;
+ u32 msgOffset;
+ };
+
+ struct header_s {
+ u32 count;
+ entry_s entry[1];
+ };
+};
+#endif /* MSGBOX_H */
diff --git a/src/palaceDude.cpp b/src/palaceDude.cpp
new file mode 100644
index 0000000..eff3299
--- /dev/null
+++ b/src/palaceDude.cpp
@@ -0,0 +1,50 @@
+#include <game.h>
+#include <stage.h>
+#include "msgbox.h"
+
+class dPalaceDude_c : public dStageActor_c {
+ public:
+ static dPalaceDude_c *build();
+
+ bool hasBeenActivated;
+ bool hasExitedStage;
+ int onExecute();
+};
+
+/*****************************************************************************/
+// Glue Code
+dPalaceDude_c *dPalaceDude_c::build() {
+ void *buffer = AllocFromGameHeap1(sizeof(dPalaceDude_c));
+ dPalaceDude_c *c = new(buffer) dPalaceDude_c;
+ return c;
+}
+
+
+int dPalaceDude_c::onExecute() {
+ if (dFlagMgr_c::instance->flags & spriteFlagMask) {
+ if (hasBeenActivated)
+ return true;
+ //OSReport("Activating Palace Dude\n");
+ hasBeenActivated = true;
+
+ dMsgBoxManager_c::instance->showMessage(settings & 0xFFFFFFF);
+
+ SaveBlock *save = GetSaveFile()->GetBlock(-1);
+ save->switch_on |= (1 << (settings >> 28));
+ }
+
+ if (hasBeenActivated) {
+ if (hasExitedStage)
+ return true;
+ //OSReport("Palace Dude is activated, %d\n", dMsgBoxManager_c::instance->visible);
+ if (!dMsgBoxManager_c::instance->visible) {
+ ExitStage(WORLD_MAP, 0, BEAT_LEVEL, MARIO_WIPE);
+ hasExitedStage = true;
+ }
+ }
+
+ return true;
+
+}
+
+
diff --git a/switchblock.yaml b/switchblock.yaml
index 6f142b2..e18fda8 100644
--- a/switchblock.yaml
+++ b/switchblock.yaml
@@ -1,5 +1,5 @@
---
-source_files: [../src/switchblock.S]
+source_files: [../src/switchblock.S, ../src/palaceDude.cpp]
hooks:
- name: PrepareReplay_SwitchPatch
type: patch
@@ -30,3 +30,16 @@ hooks:
target_func: 'CheckBehaviourOverride_EndPatch'
+
+ - name: BuildPalaceDude
+ type: add_func_pointer
+ src_addr_pal: 0x809838E4
+ target_func: 'dPalaceDude_c::build(void)'
+
+ - name: PalaceDudeSpriteInfo
+ type: patch
+ addr_pal: 0x8030CDE8
+ # Orig 02EB 0000 00000000 00000000 00000000 00000000 00000100 00000100 0000 0000 0000 0000 0800 0000'
+ data: '02A7 0000 00000010 00000010 00000000 00000000 00000200 00000200 0000 0000 0200 0200 0000 0000'
+ # 0x8030A340 + sprite num * 0x28 == offset
+
diff --git a/tools/UsedProfileAndSpriteList.txt b/tools/UsedProfileAndSpriteList.txt
index 7f2a7ec..8011339 100644
--- a/tools/UsedProfileAndSpriteList.txt
+++ b/tools/UsedProfileAndSpriteList.txt
@@ -37,6 +37,7 @@
246 : TAG_THUNDER : Level Special
250 : KAWANAGARE : Electric Line
251 : SLOW_QUICK_TAG : Topman Boss
+273 : WM_KINOBALLOON : Palace Activator
282 : EN_WALLINSECT : Mr Sun
283 : WALLINSECT_MGR : Fuzzy Bear
290 : EN_IWAO : Ramboo
@@ -89,6 +90,7 @@ WM_DANCE_PAKKUN
WM_GHOST
WM_KILLER
WM_KILLERBULLET
+WM_KINOBALLOON
WM_KINOKO_STAR
WM_KOOPA_CASTLE
WM_KURIBO
@@ -130,7 +132,6 @@ WM_HANACHAN
WM_IBARA
WM_ISLAND
WM_JUGEM
-WM_KINOBALLOON
WM_KINOKO_1UP
WM_KINOKO_BASE
WM_KINOKO_RED