summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/switchblock.S4
-rw-r--r--src/worldmap.cpp26
-rw-r--r--src/worldmap.h1
3 files changed, 28 insertions, 3 deletions
diff --git a/src/switchblock.S b/src/switchblock.S
index f219ee4..fd192df 100644
--- a/src/switchblock.S
+++ b/src/switchblock.S
@@ -31,7 +31,7 @@ ProcessTileNum_EndPatch:
ori r5, r5, BG_GM_ptr@l
lwz r5, 0(r5)
addis r5, r5, 9
- lbz r5, 0xAA8(r3)
+ lbz r5, 0xAA8(r5)
cmplwi r30, 0x58
bne not_red
@@ -67,6 +67,6 @@ ptnReturn:
lwz r31, 0xC(r1)
lwz r30, 0x8(r1)
mtlr r0
- addi sp, sp, 0x10
+ addi r1, r1, 0x10
blr
diff --git a/src/worldmap.cpp b/src/worldmap.cpp
index 7bfa461..d7f73d0 100644
--- a/src/worldmap.cpp
+++ b/src/worldmap.cpp
@@ -71,6 +71,14 @@ dScNewerWorldMap_c *dScNewerWorldMap_c::build() {
#define CONT_DONE(cont) (*((bool*)(((u32)(cont))+0x2D7)))
#define CONT_UNK3(cont) (*((bool*)(((u32)(cont))+0x2E0)))
+inline u8 GetSwitchStatus() {
+ return *((u8*)(((u32)GameMgr)+0x380));
+}
+
+inline void SetSwitchStatus(u8 stat) {
+ *((u8*)(((u32)GameMgr)+0x380)) = stat;
+}
+
#define STATE_START_DVD 0
#define STATE_LOAD_RES 1
#define STATE_END_DVD 2
@@ -157,7 +165,7 @@ void dScNewerWorldMap_c::StartLevel(LevelInfo_Entry *entry) {
}
void dScNewerWorldMap_c::SetTitle(const char *text) {
- unsigned short conv_buf[0x1FF];
+ unsigned short conv_buf[0x200];
int length = strlen(text);
if (length > 0x1FF)
length = 0x1FF;
@@ -165,11 +173,22 @@ void dScNewerWorldMap_c::SetTitle(const char *text) {
for (int i = 0; i < length; i++) {
conv_buf[i] = text[i];
}
+ conv_buf[length] = 0;
void *textBox = EmbeddedLayout_FindTextBoxByName(this->layout, "ScreenTitle");
TextBox_SetString(textBox, conv_buf, 0);
}
+void dScNewerWorldMap_c::GenSBTitle() {
+ char buf[0x100];
+ sprintf(buf, "Switches: R:%s; G:%s; Y:%s; B:%s",
+ ((GetSwitchStatus() & 1) != 0) ? "On" : "Off",
+ ((GetSwitchStatus() & 2) != 0) ? "On" : "Off",
+ ((GetSwitchStatus() & 4) != 0) ? "On" : "Off",
+ ((GetSwitchStatus() & 8) != 0) ? "On" : "Off");
+ this->SetTitle(buf);
+}
+
void dScNewerWorldMap_c::GenText() {
char buf[0x1FF];
char paneNameBuf[0x20];
@@ -339,6 +358,7 @@ int dScNewerWorldMap_c::onCreate() {
OSReport("23:Make text\n");
this->GenText();
+ this->GenSBTitle();
OSReport("24:onCreate complete\n");
return true;
@@ -497,6 +517,10 @@ int dScNewerWorldMap_c::onExecute() {
this->state = STATE_CSMENU;
}
+ if (nowPressed & WPAD_B) {
+ SetSwitchStatus((GetSwitchStatus() + 1) & 15);
+ this->GenSBTitle();
+ }
// Change the current level
if ((nowPressed & WPAD_UP) && currentSelection > 0) {
diff --git a/src/worldmap.h b/src/worldmap.h
index 5966352..0cf567e 100644
--- a/src/worldmap.h
+++ b/src/worldmap.h
@@ -49,6 +49,7 @@ public:
void StartLevel();
void GenText();
+ void GenSBTitle();
void SetTitle(const char *text);
int onCreate();