summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-10-17 18:20:36 +0200
committerTreeki <treeki@gmail.com>2012-10-17 18:20:36 +0200
commit3ef1114c2bebd29b55fc53986b3c942a55b8b642 (patch)
tree692a5f41998f072c95d643a7d4f049492235d4bc /src
parent5de76d2cb171b57cb9f4592c4404d208fde7cc81 (diff)
downloadkamek-3ef1114c2bebd29b55fc53986b3c942a55b8b642.tar.gz
kamek-3ef1114c2bebd29b55fc53986b3c942a55b8b642.zip
pushing my current star coins stuff
Diffstat (limited to '')
-rw-r--r--src/koopatlas/core.cpp59
-rw-r--r--src/koopatlas/core.h9
-rw-r--r--src/koopatlas/starcoin.cpp432
-rw-r--r--src/koopatlas/starcoin.h55
-rw-r--r--src/randomcrap.S14
5 files changed, 157 insertions, 412 deletions
diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp
index 8584ee9..462b995 100644
--- a/src/koopatlas/core.cpp
+++ b/src/koopatlas/core.cpp
@@ -269,10 +269,10 @@ bool WMInit_SetupExtra(void *ptr) {
// it is created in dScKoopatlas_c::onCreate
SpammyReport("creating SHOP\n");
- wm->shop = (dWMShop_c*)CreateParentedObject(WM_SHOP, wm, 0, 2);
+ wm->shop = (dWMShop_c*)CreateParentedObject(WM_SHOP, wm, 0, 0);
SpammyReport("creating Star Coin Menu\n");
- wm->coins = (dWMStarCoin*)CreateParentedObject(WM_STARCOIN, wm, 0, 2);
+ wm->coins = (dWMStarCoin_c*)CreateParentedObject(WM_STARCOIN, wm, 0, 0);
SpammyReport("SetupExtra done\n");
@@ -333,6 +333,8 @@ DoStartLevel(GetGameMgr(), &sl);
int dScKoopatlas_c::onCreate() {
+ OSReport("KP scene settings: %08x\n", settings);
+
SpammyReport("onCreate() called\n");
SpammyReport("LoadMapScene()\n");
@@ -401,6 +403,8 @@ int dScKoopatlas_c::onCreate() {
SaveBlock *save = GetSaveFile()->GetBlock(-1);
currentMapID = save->current_world;
+ somethingAboutSound(_8042A788);
+
return true;
}
@@ -541,30 +545,31 @@ void dScKoopatlas_c::executeState_CSMenu() {
switch (CSMENU_CURRENT(this->csMenu)) {
case 0:
// Star Coins
- if (pathManager.currentNode->type == dKPNode_s::LEVEL) {
- int w = pathManager.currentNode->levelNumber[0];
- if (w == 9) {
- int l = pathManager.currentNode->levelNumber[1];
-
- if ((l < 6) || (l == 33) || (l == 34))
- coins->LoadCoinsForWorld(9);
- else if ((l < 11) || (l == 35) || (l == 36))
- coins->LoadCoinsForWorld(10);
- else if ((l < 16) || (l == 37) || (l == 38) || (l == 31) )
- coins->LoadCoinsForWorld(11);
- else if ((l < 19) || (l == 39) || (l == 40))
- coins->LoadCoinsForWorld(12);
- else
- coins->LoadCoinsForWorld(13);
-
- state.setState(&StateID_CoinsWait);
- }
- else {
- coins->LoadCoinsForWorld(w-1);
- state.setState(&StateID_CoinsWait);
- }
- }
- else { MapSoundPlayer(SoundRelatedClass, SE_SYS_INVALID, 1); }
+// if (pathManager.currentNode->type == dKPNode_s::LEVEL) {
+// int w = pathManager.currentNode->levelNumber[0];
+// if (w == 9) {
+// int l = pathManager.currentNode->levelNumber[1];
+//
+// if ((l < 6) || (l == 33) || (l == 34))
+// coins->LoadCoinsForWorld(9);
+// else if ((l < 11) || (l == 35) || (l == 36))
+// coins->LoadCoinsForWorld(10);
+// else if ((l < 16) || (l == 37) || (l == 38) || (l == 31) )
+// coins->LoadCoinsForWorld(11);
+// else if ((l < 19) || (l == 39) || (l == 40))
+// coins->LoadCoinsForWorld(12);
+// else
+// coins->LoadCoinsForWorld(13);
+//
+// state.setState(&StateID_CoinsWait);
+// }
+// else {
+// coins->LoadCoinsForWorld(w-1);
+// }
+// }
+// else { MapSoundPlayer(SoundRelatedClass, SE_SYS_INVALID, 1); }
+ coins->show();
+ state.setState(&StateID_CoinsWait);
break;
case 1:
@@ -758,7 +763,7 @@ void dScKoopatlas_c::executeState_ShopWait() {
// STATE_StarCoin : Wait for the user to exit the Star Coin screen.
void dScKoopatlas_c::executeState_CoinsWait() {
- if (coins->isHidden) {
+ if (!coins->visible) {
state.setState(&StateID_Normal);
}
diff --git a/src/koopatlas/core.h b/src/koopatlas/core.h
index 7e86d72..0f7c3a3 100644
--- a/src/koopatlas/core.h
+++ b/src/koopatlas/core.h
@@ -40,12 +40,8 @@ void NewerMapDrawFunc();
#define WM_STARCOIN WM_GHOST
class daWMPlayer_c;
-class dWMHud_c;
class dWMMap_c;
-class dWMShop_c;
-class dWMStarCoin;
class dWorldCamera_c;
-class dWMPathManager_c;
class dScKoopatlas_c : public dScene_c {
public:
@@ -104,7 +100,7 @@ class dScKoopatlas_c : public dScene_c {
dWMHud_c *hud;
dWMMap_c *map;
dWMShop_c *shop;
- dWMStarCoin *coins;
+ dWMStarCoin_c *coins;
int currentMapID;
const char *mapPath;
@@ -128,5 +124,8 @@ class dScKoopatlas_c : public dScene_c {
void showSaveWindow();
};
+extern void *_8042A788;
+void somethingAboutSound(void *beef);
+
#endif
diff --git a/src/koopatlas/starcoin.cpp b/src/koopatlas/starcoin.cpp
index 4366895..7b7db51 100644
--- a/src/koopatlas/starcoin.cpp
+++ b/src/koopatlas/starcoin.cpp
@@ -1,42 +1,34 @@
#include "koopatlas/starcoin.h"
#include <game.h>
-/*****************************************************************************/
-// Starcoin Layout
-//
+dWMStarCoin_c *dWMStarCoin_c::instance = 0;
-
-dWMStarCoin *dWMStarCoin::instance = 0;
-
-dWMStarCoin *dWMStarCoin::build() {
- void *buffer = AllocFromGameHeap1(sizeof(dWMStarCoin));
- dWMStarCoin *c = new(buffer) dWMStarCoin;
+dWMStarCoin_c *dWMStarCoin_c::build() {
+ void *buffer = AllocFromGameHeap1(sizeof(dWMStarCoin_c));
+ dWMStarCoin_c *c = new(buffer) dWMStarCoin_c;
instance = c;
return c;
}
-dWMStarCoin::dWMStarCoin() {
+dWMStarCoin_c::dWMStarCoin_c() {
layoutLoaded = false;
- isHidden = true;
+ visible = false;
}
-int dWMStarCoin::onCreate() {
+int dWMStarCoin_c::onCreate() {
if (!layoutLoaded) {
- bool gotFile = layout.loadArc("coin.arc", false);
+ bool gotFile = layout.loadArc("StarCoins.arc", false);
if (!gotFile)
return false;
- static const char *brlanNames[2] = {"coin_inWindow.brlan", "coin_outWindow.brlan"};
- static const char *groupNames[2] = {"A00_Window", "A00_Window"};
-
- bool output = layout.build("coin.brlyt");
-
- // nw4r::lyt::Pane *red = layout.findPictureByName("red");
- // red->alpha = 0;
+ bool output = layout.build("StarCoins.brlyt");
- if (!IsWideScreen()) {
+ layout.layout.rootPane->trans.x = -112.0f;
+ if (IsWideScreen()) {
+ layout.layout.rootPane->scale.x = 0.735f;
+ } else {
layout.clippingEnabled = true;
layout.clipX = 0;
layout.clipY = 52;
@@ -46,11 +38,54 @@ int dWMStarCoin::onCreate() {
layout.layout.rootPane->scale.y = 0.7711f;
}
- layout.loadAnimations(brlanNames, 2);
- layout.loadGroups(groupNames, (int[2]){0, 1}, 2);
+ static const char *brlanNames[] = {
+ "StarCoins_Show.brlan",
+ "StarCoins_ShowSection.brlan",
+ "StarCoins_HideSection.brlan",
+ "StarCoins_ShowArrow.brlan",
+ "StarCoins_HideArrow.brlan",
+ };
+ static const char *groupNames[] = {
+ "base", "section", "section", "leftArrow", "leftArrow", "rightArrow", "rightArrow"
+ };
+
+ layout.loadAnimations(brlanNames, 5);
+ layout.loadGroups(groupNames, (int[7]){0, 1, 2, 3, 4, 3, 4}, 7);
layout.disableAllAnimations();
- layout.drawOrder = 0x01;
+ layout.drawOrder = 1;
+
+ for (int col = 0; col < COLUMN_COUNT; col++) {
+ for (int shine = 0; shine < SHINE_COUNT; shine++) {
+ char name[8];
+ sprintf(name, "Shine%d%d", col, shine);
+ Shine[col][shine] = layout.findPictureByName(name);
+ }
+
+ for (int row = 0; row < ROW_COUNT; row++) {
+ char lname[12];
+ sprintf(lname, "LevelName%d%d", col, row);
+ LevelName[col][row] = layout.findTextBoxByName(lname);
+
+ char coname[16], cname[8];
+ for (int i = 0; i < 3; i++) {
+ sprintf(coname, "CoinOutline%d%d%d", col, row, i);
+ CoinOutline[col][row][i] = layout.findPictureByName(coname);
+
+ sprintf(cname, "Coin%d%d%d", col, row, i);
+ Coin[col][row][i] = layout.findPictureByName(cname);
+ }
+ }
+ }
+
+ static const char *tbNames[] = {
+ "LeftTitle", "RightTitle", "TotalCoinCount", "UnspentCoinCount",
+ "EarnedCoinCount", "EarnedCoinMax", "BtnWorldSelText", "BtnBackText",
+ };
+ layout.getTextBoxes(tbNames, &LeftTitle, 8);
+
+ WriteBMGToTextBox(BtnBackText, GetBMG(), 3, 1, 0);
+ WriteBMGToTextBox(BtnWorldSelText, GetBMG(), 4, 11, 0);
layoutLoaded = true;
}
@@ -59,22 +94,27 @@ int dWMStarCoin::onCreate() {
}
-int dWMStarCoin::onDelete() {
+int dWMStarCoin_c::onDelete() {
return layout.free();
}
-int dWMStarCoin::onExecute() {
- layout.execAnimations();
- layout.update();
+void dWMStarCoin_c::show() {
+ visible = true;
+ layout.enableNonLoopAnim(SHOW_ALL);
+}
+
+
+int dWMStarCoin_c::onExecute() {
+ if (visible) {
+ layout.execAnimations();
+ layout.update();
- if (!isHidden) {
int nowPressed = Remocon_GetPressed(GetActiveRemocon());
if (!layout.isAnyAnimOn()) {
if (nowPressed & WPAD_B) {
MapSoundPlayer(SoundRelatedClass, SE_SYS_DIALOGUE_OUT_AUTO, 1);
- isHidden = true;
layout.enableNonLoopAnim(1);
}
}
@@ -83,338 +123,10 @@ int dWMStarCoin::onExecute() {
return true;
}
-int dWMStarCoin::onDraw() {
- if (isHidden) {
- if (layout.isAnimOn(1)) { layout.scheduleForDrawing(); }
- }
-
- if (!isHidden) {
+int dWMStarCoin_c::onDraw() {
+ if (visible)
layout.scheduleForDrawing();
- }
return true;
}
-void dWMStarCoin::specialDraw1() {
- if (!isHidden) {
- Vec pos = {420.0f, 194.0f, -1000.0f};
- S16Vec rot = {0,rotation,0};
- Vec scale = {2.0f, 2.0f, 2.0f};
- matrix.translation(pos.x, pos.y, pos.z);
- matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z);
-
- shopkeep.setDrawMatrix(matrix);
- shopkeep.setScale(&scale);
- shopkeep.calcWorld(false);
- shopkeep.scheduleForDrawing();
-
- rotation += 0x100;
- }
- return;
-}
-
-
-void dWMStarCoin::LoadCoinsForWorld(int world) {
- if (!isHidden) {
- return; }
-
- int levelArray[14][2][8] = {
- {
- {1,2,3,4,15},
- {5,6,7,8,25,38}
- },
-
- {
- {1,2,3,4,15},
- {5,6,7,8,9,10,25,38}
- },
-
- {
- {1,2,3,4,15},
- {5,6,7,25,38}
- },
-
- {
- {1,2,3,4,15},
- {5,6,7,8,25,38}
- },
-
- {
- {1,2,3,4,5,15},
- {6,7,8,9,10,25,38}
- },
-
- {
- {1,2,3,4,15},
- {5,6,7,8,9,25,38}
- },
-
- {
- {1,2,3,4},
- {5,15,6,7,8,9,25,38}
- },
-
- {
- {1,2,3,15,4,25,5},
- {6,7,16,8,9,10,26}
- },
-
- {
- {1,2,3,4,5},
- {6,7,8,9,10}
- },
-
- {
- {1,2,3,4,5},
- {}
- },
-
- {
- {6,7,8,9,10},
- {}
- },
-
- {
- {11,12,13,14,15},
- {}
- },
-
- {
- {16,17,18},
- {}
- },
-
- {
- {19,22,23,24,25},
- {}
- }
- };
-
- // Handle showing it
- MapSoundPlayer(SoundRelatedClass, SE_SYS_DIALOGUE_IN, 1);
- isHidden = false;
- layout.enableNonLoopAnim(0);
-
- // Model creation
- allocator.link(-1, GameHeaps[0], 0, 0x20);
-
- res.data = getResource("star_coin", "g3d/star_coin.brres");
- nw4r::g3d::ResMdl mdl = res.GetResMdl("star_coinA");
- shopkeep.setup(mdl, &allocator, 0x224, 1, 0);
- SetupTextures_MapObj(&shopkeep, 1);
-
- allocator.unlink();
-
-
- // Display Total Star Coin Count
- int myCoins = getStarCoinCount();
-
- char myCoinsStr [4];
- sprintf(myCoinsStr, "%03d", myCoins);
-
- setText(myCoinsStr, "T_overall_01");
-
-
- // Display World Name
- setWorldName(world);
-
-
- // Display Per level coins
- int totalCoins = 0;
- int currentCoins = 0;
-
- int i = 0;
- int j = 1;
-
- SaveBlock *save = GetSaveFile()->GetBlock(-1);
- for (int l = 0; l < 2; l++) {
- for (int i = 0; i < 8; i++) {
-
- int levelNum = levelArray[world][l][i];
-
- char levelPane[11];
- sprintf(levelPane, "T_level_%02d", i+j);
-
- if (levelArray[world][l][i]) {
- levelNum--;
- dLevelInfo_c *li = &dScKoopatlas_c::instance->levelInfo;
- dLevelInfo_c::entry_s *entry = li->searchBySlot(world, levelNum);
-
- setText(li->getNameForLevel(entry), levelPane);
- totalCoins += 3;
- }
- else {
- setText(" ", levelPane);
- }
-
- bool collect;
- u32 conds = save->GetLevelCondition(world, i+j);
-
- collect = conds & COND_COIN1;
- setCoin(collect, 1, i+j);
- if (collect) { currentCoins++; }
-
- collect = conds & COND_COIN2;
- setCoin(collect, 2, i+j);
- if (collect) { currentCoins++; }
-
- collect = conds & COND_COIN3;
- setCoin(collect, 3, i+j);
- if (collect) { currentCoins++; }
-
- }
- j += 8;
- i = 0;
- }
-
- // Display per-world Count
- char tcStr [3];
- sprintf(tcStr, "%02d", totalCoins);
-
- setText(tcStr, "T_total_01");
-
- char ccStr [3];
- sprintf(ccStr, "%02d", currentCoins);
-
- setText(ccStr, "T_collected_01");
-}
-
-
-void dWMStarCoin::setCoin(bool on, int coin, int slot) {
-
- char coinOn[16];
- char coinOff[16];
- if (coin == 1) {
- sprintf(coinOn, "P_first_on_%02d", slot);
- sprintf(coinOff, "P_first_off_%02d", slot);
- } else if (coin == 2) {
- sprintf(coinOn, "P_second_on_%02d", slot);
- sprintf(coinOff, "P_second_off_%02d", slot);
- } else if (coin == 3) {
- sprintf(coinOn, "P_third_on_%02d", slot);
- sprintf(coinOff, "P_third_off_%02d", slot);
- } else { return; }
-
- nw4r::lyt::Pane *picOn = layout.findPictureByName(coinOn);
- nw4r::lyt::Pane *picOff = layout.findPictureByName(coinOff);
-
- if (on) {
- picOn->alpha = 0xFF;
- picOff->alpha = 0;
- }
- else {
- picOn->alpha = 0;
- picOff->alpha = 0xFF;
- }
-}
-
-void dWMStarCoin::setText(const char *str, const char *name) {
-
- int length = strlen(str);
- wchar_t newString[128];
-
- int i;
- for (i = 0; i < length && i < 128; i++) {
- newString[i] = str[i];
- }
- newString[i] = 0;
-
- int wlength = wcslen(newString);
-
- nw4r::lyt::TextBox *box = layout.findTextBoxByName(name);
-
- nw4r::ut::TextWriter tw;
- tw.font = box->font;
- tw.SetFontSize(box->fontSizeX, box->fontSizeY);
- tw.lineSpace = box->lineSpace;
- tw.charSpace = box->charSpace;
- if (box->tagProc != 0)
- tw.tagProcessor = box->tagProc;
-
- float width = tw.CalcStringWidth(newString, wlength);
- SpammyReport("Text width: %f\n", width);
-
- OSReport("Setting text: %s", newString);
- box->SetString(newString);
-}
-
-void dWMStarCoin::setWorldName(int world) {
-
- switch (world+1) {
- case 1:
- setText("Yoshi's Island", "T_lefttitle_01");
- setText("Yoshi's Island", "T_righttitle_01");
- break;
-
- case 2:
- setText("Soggy Sewers", "T_lefttitle_01");
- setText("Rubble Ruins", "T_righttitle_01");
- break;
-
- case 3:
- setText("Mushroom Peaks", "T_lefttitle_01");
- setText("Mushroom Peaks", "T_righttitle_01");
- break;
-
- case 4:
- setText("Sakura Village", "T_lefttitle_01");
- setText("Sakura Village", "T_righttitle_01");
- break;
-
- case 5:
- setText("FreezeFlame Valley", "T_lefttitle_01");
- setText("FreezeFlame Volcano", "T_righttitle_01");
- break;
-
- case 6:
- setText("Pumpkin Boneyard", "T_lefttitle_01");
- setText("Pumpkin Boneyard", "T_righttitle_01");
- break;
-
- case 7:
- setText("Sky Mountain", "T_lefttitle_01");
- setText("Starry Skies", "T_righttitle_01");
- break;
-
- case 8:
- setText("Koopa Planet", "T_lefttitle_01");
- setText("Koopa Core", "T_righttitle_01");
- break;
-
- case 9:
- setText("Bonus Land", "T_lefttitle_01");
- setText("Bonus Land", "T_righttitle_01");
- break;
-
- case 10:
- setText("Goldwood Forest", "T_lefttitle_01");
- setText(" ", "T_righttitle_01");
- break;
-
- case 11:
- setText("Mini-Mega Island", "T_lefttitle_01");
- setText(" ", "T_righttitle_01");
- break;
-
- case 12:
- setText("Crystal Caves", "T_lefttitle_01");
- setText(" ", "T_righttitle_01");
- break;
-
- case 13:
- setText("Bombard Cliffs", "T_lefttitle_01");
- setText(" ", "T_righttitle_01");
- break;
-
- case 14:
- setText("Sky City", "T_lefttitle_01");
- setText(" ", "T_righttitle_01");
- break;
-
- default:
- setText("Unknown World", "T_lefttitle_01");
- setText("Unknown World", "T_righttitle_01");
- break;
- }
-
-}
diff --git a/src/koopatlas/starcoin.h b/src/koopatlas/starcoin.h
index 844b1ef..c4e9cbf 100644
--- a/src/koopatlas/starcoin.h
+++ b/src/koopatlas/starcoin.h
@@ -3,37 +3,52 @@
#include "koopatlas/core.h"
-class dWMStarCoin : public dActor_c {
+class dWMStarCoin_c : public dActor_c {
public:
- dWMStarCoin();
+ dWMStarCoin_c();
int onCreate();
int onDelete();
int onExecute();
int onDraw();
- void specialDraw1();
-
- mHeapAllocator_c allocator;
- nw4r::g3d::ResFile res;
- m3d::mdl_c shopkeep;
- mMtx matrix;
bool layoutLoaded;
m2d::EmbedLayout_c layout;
- bool isHidden;
- s16 rotation;
-
- void LoadCoinsForWorld(int world);
- void setCoin(bool On, int coin, int slot);
- void setText(const char *str, const char *name);
- void setWorldName(int world);
-
- static dWMStarCoin *build();
- static dWMStarCoin *instance;
+ bool visible;
+ void show();
+
+ static dWMStarCoin_c *build();
+ static dWMStarCoin_c *instance;
+
+ enum Animation {
+ SHOW_ALL = 0,
+ SHOW_SECTION,
+ HIDE_SECTION,
+ SHOW_LEFT_ARROW,
+ HIDE_LEFT_ARROW,
+ SHOW_RIGHT_ARROW,
+ HIDE_RIGHT_ARROW
+ };
+
+ enum _Constants {
+ ROW_COUNT = 9,
+ COLUMN_COUNT = 2,
+ SHINE_COUNT = 5,
+ };
+
+ nw4r::lyt::Picture
+ *Shine[COLUMN_COUNT][SHINE_COUNT],
+ *CoinOutline[COLUMN_COUNT][ROW_COUNT][3],
+ *Coin[COLUMN_COUNT][ROW_COUNT][3];
+
+ nw4r::lyt::TextBox
+ *LevelName[COLUMN_COUNT][ROW_COUNT],
+ *LeftTitle, *RightTitle,
+ *TotalCoinCount, *UnspentCoinCount,
+ *EarnedCoinCount, *EarnedCoinMax,
+ *BtnWorldSelText, *BtnBackText;
- private:
- bool isPointBarShown;
};
#endif
diff --git a/src/randomcrap.S b/src/randomcrap.S
index 0983763..d3a0388 100644
--- a/src/randomcrap.S
+++ b/src/randomcrap.S
@@ -223,6 +223,19 @@ UniversalFunctionLog:
addi r1, r1, 0x10
blr
+.global EndSCM
+EndSCM:
+ lis r3, SCMs@h
+ ori r3, r3, SCMs@l
+ mr r4, r31
+ crclr 4*cr1+eq
+ bl OSReport
+
+ lwz r31, 0xC(r1)
+ lwz r0, 0x14(r1)
+ mtlr r0
+ addi r1, r1, 0x10
+ blr
#AllocLog:
# stwu r1, -0x20(r1)
@@ -361,3 +374,4 @@ UniLogStr: .string "[ULog] returning %8x to: %x > %x > %x > %x > %x > %x\n"
#Alloced: .string "[AH] Allocated %p\n"
#WillFree: .string "[AH] Freeing %p which is %x bytes\n"
+SCMs: .string "Setting music to %d\n"