summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Noga <Tempus@chronometry.ca>2012-11-25 15:35:13 -0600
committerColin Noga <Tempus@chronometry.ca>2012-11-25 15:35:13 -0600
commitdb34c0af338b8cf04f50b4ade98668869fd303e1 (patch)
treee373abe027205c0e8414cf6146ded59112b0ab72
parent72b9b71b5b7fb5757849d19af3dfae21d0ab9c92 (diff)
parent1609b49c5c1777e663909b1936b2f8921677f230 (diff)
downloadkamek-db34c0af338b8cf04f50b4ade98668869fd303e1.tar.gz
kamek-db34c0af338b8cf04f50b4ade98668869fd303e1.zip
Merge branch 'level-select' of ssh://treeki.rustedlogic.net:30000/Kamek into level-select
-rw-r--r--NewerProjectKP.yaml1
-rw-r--r--bugfixes.yaml2
-rwxr-xr-xinclude/game.h2
-rw-r--r--kamek_pal.x4
-rw-r--r--koopatlas.yaml7
-rw-r--r--layouthax.yaml10
-rw-r--r--src/bossTopman.cpp2
-rw-r--r--src/cutScene.cpp2
-rw-r--r--src/fileselect.S2
-rw-r--r--src/koopatlas/core.cpp62
-rw-r--r--src/koopatlas/core.h9
-rw-r--r--src/koopatlas/map.cpp8
-rw-r--r--src/koopatlas/mapmusic.cpp146
-rw-r--r--src/koopatlas/mapmusic.h11
-rw-r--r--src/koopatlas/pathmanager.cpp35
-rw-r--r--src/koopatlas/player.cpp69
-rw-r--r--src/koopatlas/player.h18
-rw-r--r--src/koopatlas/subplayer.cpp116
-rw-r--r--src/koopatlas/subplayer.h38
-rw-r--r--src/layouthax.cpp8
-rw-r--r--src/pregame.cpp28
-rw-r--r--src/randomcrap.S20
-rw-r--r--src/topman.cpp2
-rw-r--r--tools/UsedProfileAndSpriteList.txt3
24 files changed, 263 insertions, 342 deletions
diff --git a/NewerProjectKP.yaml b/NewerProjectKP.yaml
index 024e6cb..2aad64b 100644
--- a/NewerProjectKP.yaml
+++ b/NewerProjectKP.yaml
@@ -13,6 +13,7 @@ modules:
- processed/bugfixes.yaml
- processed/koopatlas.yaml
- processed/pregame.yaml
+ - processed/layouthax.yaml
- processed/animtiles.yaml
- processed/soundPlayer.yaml
- processed/bowserKey.yaml
diff --git a/bugfixes.yaml b/bugfixes.yaml
index af1ea6e..57dce7f 100644
--- a/bugfixes.yaml
+++ b/bugfixes.yaml
@@ -221,6 +221,8 @@ hooks:
src_addr_pal: 0x80B00234
target_func: 'ReturnNone'
+ - {name: PowEvent1, type: branch_insn, branch_type: b, src_addr_pal: 0x80892DFC, target_func: 'PowEvent'}
+ - {name: PowEvent2, type: branch_insn, branch_type: b, src_addr_pal: 0x80893044, target_func: 'PowEvent'}
- {name: AlwaysDrawPictureFontWhite, type: branch_insn, branch_type: b, src_addr_pal: 0x800E596C, target_func: 'TextWriterCrap'}
- {name: DebugSCM, type: branch_insn, branch_type: b, src_addr_pal: 0x8006A6C4, target_func: 'EndSCM'}
diff --git a/include/game.h b/include/game.h
index 5dd8aa5..8afb80b 100755
--- a/include/game.h
+++ b/include/game.h
@@ -3392,6 +3392,8 @@ namespace nw4r {
bool Exists() { return (data != 0); }
void Stop(int unk) { Stop__Q44nw4r3snd6detail10BasicSoundFi(data, unk); }
+ void *GetSound() const { return data; }
+
void DetachSound();
};
diff --git a/kamek_pal.x b/kamek_pal.x
index 0438488..ef3947b 100644
--- a/kamek_pal.x
+++ b/kamek_pal.x
@@ -7,6 +7,9 @@ SECTIONS {
_8042A788 = 0x8042A788;
somethingAboutSound__FPv = 0x8019CB30;
+ AxVoice_SetADPCM = 0x80262FD0;
+ Voice_SetADPCMLoop = 0x80281A90;
+
DetachSound__Q34nw4r3snd11SoundHandleFv = 0x8027A340;
Stop__Q44nw4r3snd6detail10BasicSoundFi = 0x80266390;
StrmSound_SetTrackVolume = 0x8027F9D0;
@@ -1079,6 +1082,7 @@ SECTIONS {
DVDFastOpen__FiP9DVDHandle = 0x801CAAD0;
DVDReadPrio__FP9DVDHandlePviii = 0x801CAC60;
DVDClose__FP9DVDHandle = 0x801CAB40;
+ DVDCancel = 0x801CF510;
DVDConvertPathToEntrynum = 0x801CA7C0;
diff --git a/koopatlas.yaml b/koopatlas.yaml
index ca0cd63..d4c04cf 100644
--- a/koopatlas.yaml
+++ b/koopatlas.yaml
@@ -7,7 +7,6 @@ source_files:
- ../src/levelinfo.cpp
- ../src/koopatlas/core.cpp
- ../src/koopatlas/player.cpp
- - ../src/koopatlas/subplayer.cpp
- ../src/koopatlas/hud.cpp
- ../src/koopatlas/camera.cpp
- ../src/koopatlas/map.cpp
@@ -15,6 +14,7 @@ source_files:
- ../src/koopatlas/pathmanager.cpp
- ../src/koopatlas/shop.cpp
- ../src/koopatlas/starcoin.cpp
+ - ../src/koopatlas/mapmusic.cpp
- ../src/texmapcolouriser.cpp
hooks:
@@ -28,11 +28,6 @@ hooks:
src_addr_pal: 0x80988DDC
target_func: 'daWMPlayer_c::build(void)'
- - name: BuildWMSubPlayer # WM_SUBPLAYER
- type: add_func_pointer
- src_addr_pal: 0x8098586C
- target_func: 'daWMSubPlayer_c::build(void)'
-
- name: BuildWMHud # WM_DANCE_PAKKUN
type: add_func_pointer
src_addr_pal: 0x80982844
diff --git a/layouthax.yaml b/layouthax.yaml
new file mode 100644
index 0000000..1c49950
--- /dev/null
+++ b/layouthax.yaml
@@ -0,0 +1,10 @@
+---
+source_files: [../src/layouthax.cpp]
+hooks:
+ - name: InsertPauseWindowText
+ src_addr_pal: 0x8015AC60
+ type: branch_insn
+ branch_type: b
+ target_func: 'InsertPauseWindowText'
+
+
diff --git a/src/bossTopman.cpp b/src/bossTopman.cpp
index bed9104..d014d57 100644
--- a/src/bossTopman.cpp
+++ b/src/bossTopman.cpp
@@ -309,7 +309,7 @@ int daDreidel::onCreate() {
// Model creation
allocator.link(-1, GameHeaps[0], 0, 0x20);
- this->resFile.data = getResource("ben", "g3d/begoman_spike.brres");
+ this->resFile.data = getResource("topman", "g3d/begoman_spike.brres");
nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("begoman");
bodyModel.setup(mdl, &allocator, 0x224, 1, 0);
SetupTextures_Map(&bodyModel, 0);
diff --git a/src/cutScene.cpp b/src/cutScene.cpp
index 70b2006..32f4eb3 100644
--- a/src/cutScene.cpp
+++ b/src/cutScene.cpp
@@ -93,7 +93,7 @@ int dScCutScene_c::onExecute() {
if ((currentScene + 1) == data->sceneCount) {
// we're TOTALLY done!
OSReport("playback complete\n");
- DoSceneChange(WORLD_MAP, 0, 0);
+ DoSceneChange(WORLD_MAP, 0x80000000, 0);
} else {
nextScene = currentScene + 1;
OSReport("switching to scene %d\n", nextScene);
diff --git a/src/fileselect.S b/src/fileselect.S
index 38874cc..a853e76 100644
--- a/src/fileselect.S
+++ b/src/fileselect.S
@@ -354,7 +354,7 @@ DefaultSavefileInfoData:
.long 0xFFFF99FF,0x1FB423FF
.short 0x75
.byte 0x2E,0xB
-.byte 0,1
+.byte 1,1
.byte 0,10
DefaultSavefileInfoDataEnd:
diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp
index 5734300..fd6eace 100644
--- a/src/koopatlas/core.cpp
+++ b/src/koopatlas/core.cpp
@@ -1,7 +1,6 @@
#include "koopatlas/core.h"
#include "koopatlas/camera.h"
#include "koopatlas/player.h"
-#include "koopatlas/subplayer.h"
#include "music.h"
extern "C" void LoadMapScene();
@@ -194,7 +193,7 @@ bool WMInit_LoadResources2(void *ptr) {
}
if (wm->mapData.load(wm->mapPath)) {
- wm->playBGM();
+ dKPMusic::play(GetSaveFile()->GetBlock(-1)->currentMapMusic);
return true;
} else
return false;
@@ -253,12 +252,6 @@ bool WMInit_SetupExtra(void *ptr) {
wm->player->modelHandler->mdlClass->setPowerup(Player_Powerup[0]);
wm->player->modelHandler->mdlClass->startAnimation(0, 1.2f, 10.0f, 0.0f);
- for (int i = 0; i < 3; i++) {
- wm->subPlayer[i] = (daWMSubPlayer_c*)CreateParentedObject(WM_SUBPLAYER, wm, i+1, 2);
- wm->subPlayer[i]->modelHandler->mdlClass->setPowerup(Player_Powerup[i+1]);
- wm->subPlayer[i]->modelHandler->mdlClass->startAnimation(0, 1.2f, 10.0f, 0.0f);
- }
-
// since we've got all the resources, set up the path data too
SpammyReport("preparing path manager\n");
wm->pathManager.setup();
@@ -266,8 +259,6 @@ bool WMInit_SetupExtra(void *ptr) {
// and put the player into position
dKPNode_s *cNode = wm->pathManager.currentNode;
wm->player->pos = (Vec){cNode->x, -cNode->y, wm->player->pos.z};
- for (int i = 0; i < 3; i++)
- wm->subPlayer[i]->pos = (Vec){cNode->x, -cNode->y, wm->subPlayer[i]->pos.z};
// is last param correct? must check :/
SpammyReport("creating MAP\n");
@@ -421,52 +412,9 @@ int dScKoopatlas_c::onCreate() {
extern "C" void PlaySoundWithFunctionB4(void *spc, nw4r::snd::SoundHandle *handle, int id, int unk);
-void dScKoopatlas_c::playBGM() {
- char cleanName[40];
- // find the end
- const char *mapPathEnd = mapPath;
- while (*mapPathEnd)
- mapPathEnd++;
-
- // it now points to the zero
- const char *findSlash = mapPathEnd;
- while (findSlash > mapPath && *findSlash != '/')
- findSlash--;
-
- // it now points to the slash
- strcpy(cleanName, "Map_");
- strncpy(&cleanName[4], findSlash+1, 36);
-
- // nuke everything up to the point
- for (int i = 4; i < 40; i++)
- if (cleanName[i] == '.')
- cleanName[i] = 0;
-
- int realStreamID;
- OSReport("I'm going to play %s!\n", cleanName);
- hijackMusicWithSongName(cleanName, -1, false, 16, 8, &realStreamID);
- OSReport("Real Stream ID: %d\n", realStreamID);
- PlaySoundWithFunctionB4(SoundRelatedClass, &bgm, realStreamID, 1);
-
- currentBGMTrack = GetSaveFile()->GetBlock(-1)->currentMapMusic;
- OSReport("Enabling track %d by setting bitfield 0x%x to volume 1.0f and bitfield 0x%x to volume 0.0f; both over 0 frames\n", currentBGMTrack, 1 << currentBGMTrack, 0xFF ^ (1 << currentBGMTrack));
- bgm.SetTrackVolume(0xFF ^ (1 << currentBGMTrack), 0, 0.0f);
- bgm.SetTrackVolume(1 << currentBGMTrack, 0, 1.0f);
-}
-
-void dScKoopatlas_c::setBGMTrack(int trackID) {
- if (currentBGMTrack == trackID)
- return;
-
- OSReport("Enabling track %d and disabling track %d by setting bitfield 0x%x to volume 1.0f and bitfield 0x%x to volume 0.0f; both over 30 frames\n", trackID, currentBGMTrack, 1 << trackID, 1 << currentBGMTrack);
- bgm.SetTrackVolume(1 << currentBGMTrack, 30, 0.0f);
- bgm.SetTrackVolume(1 << trackID, 30, 1.0f);
- currentBGMTrack = trackID;
-}
-
int dScKoopatlas_c::onDelete() {
- if (bgm.Exists())
- bgm.Stop(0);
+ if (!keepMusicPlaying)
+ dKPMusic::stop();
FreeScene(0);
FreeScene(1);
@@ -506,6 +454,7 @@ bool dScKoopatlas_c::mapIsRunning() {
int dScKoopatlas_c::onExecute() {
+ dKPMusic::execute();
if (!canDoStuff()) return true;
//SpammyReport("Executing state: %s\n", state.getCurrentState()->getName());
@@ -751,9 +700,6 @@ void dScKoopatlas_c::executeState_PowerupsWait() {
if (!STKI_SHOW(this->stockItem)) {
player->modelHandler->mdlClass->setPowerup(Player_Powerup[0]);
- for (int i = 0; i < 3; i++)
- subPlayer[i]->modelHandler->mdlClass->setPowerup(Player_Powerup[i+1]);
-
state.setState(&StateID_Normal);
}
diff --git a/src/koopatlas/core.h b/src/koopatlas/core.h
index 3f795cc..651b628 100644
--- a/src/koopatlas/core.h
+++ b/src/koopatlas/core.h
@@ -16,6 +16,7 @@
#include "koopatlas/starcoin.h"
#include "koopatlas/hud.h"
#include "koopatlas/pathmanager.h"
+#include "koopatlas/mapmusic.h"
#define WM_DEBUGGING
//#define WM_SPAMMY_DEBUGGING
@@ -39,7 +40,6 @@ void NewerMapDrawFunc();
#define WM_STARCOIN WM_GHOST
class daWMPlayer_c;
-class daWMSubPlayer_c;
class dWMMap_c;
class dWMHud_c;
class dWMShop_c;
@@ -100,7 +100,6 @@ class dScKoopatlas_c : public dScene_c {
daWMPlayer_c *player;
- daWMSubPlayer_c *subPlayer[3];
dWMHud_c *hud;
dWMMap_c *map;
dWMShop_c *shop;
@@ -117,8 +116,6 @@ class dScKoopatlas_c : public dScene_c {
const char *getMapNameForIndex(int index);
int getIndexForMapName(const char *name);
- nw4r::snd::StrmSoundHandle bgm;
-
void startLevel(dLevelInfo_c::entry_s *level);
bool canDoStuff();
@@ -126,9 +123,7 @@ class dScKoopatlas_c : public dScene_c {
void showSaveWindow();
- void playBGM();
- void setBGMTrack(int trackID);
- int currentBGMTrack;
+ bool keepMusicPlaying;
};
extern void *_8042A788;
diff --git a/src/koopatlas/map.cpp b/src/koopatlas/map.cpp
index ff28e19..c2cb13e 100644
--- a/src/koopatlas/map.cpp
+++ b/src/koopatlas/map.cpp
@@ -114,14 +114,20 @@ void dWMMap_c::renderer_c::drawXlu() {
void dWMMap_c::renderer_c::drawLayers() {
- dKPMapData_c *dataCls = &dScKoopatlas_c::instance->mapData;
+ dScKoopatlas_c *wm = dScKoopatlas_c::instance;
+ dKPMapData_c *dataCls = &wm->mapData;
dKPMapFile_s *data = dataCls->data;
baseZ = -100.0f - (2 * data->layerCount);
+ bool skipFirstLayer = (wm->currentMapID == 0) && !(wm->settings & 0x80000000);
+
beginRendering();
for (int iLayer = data->layerCount - 1; iLayer >= 0; iLayer--) {
+ if (skipFirstLayer && iLayer == 0)
+ continue;
+
dKPLayer_s *layer = data->layers[iLayer];
renderMtx[2][3] += 2.0f;
diff --git a/src/koopatlas/mapmusic.cpp b/src/koopatlas/mapmusic.cpp
new file mode 100644
index 0000000..1ccd775
--- /dev/null
+++ b/src/koopatlas/mapmusic.cpp
@@ -0,0 +1,146 @@
+#include <game.h>
+#include "koopatlas/mapmusic.h"
+#include "music.h"
+
+extern "C" void PlaySoundWithFunctionB4(void *spc, nw4r::snd::SoundHandle *handle, int id, int unk);
+
+static nw4r::snd::StrmSoundHandle s_handle;
+static bool s_playing = false;
+static int s_song = -1;
+static int s_nextSong = -1;
+
+static int s_countdownToSwitch = -1;
+static int s_countdownToFadeIn = -1;
+
+static dDvdLoader_c s_adpcmInfoLoader;
+static bool s_adpcmInfoLoaded = false;
+
+#define FADE_OUT_LEN 30
+#define FADE_IN_LEN 30
+#define BUFFER_CLEAR_DELAY 60
+
+u8 hijackMusicWithSongName(const char *songName, int themeID, bool hasFast, int channelCount, int trackCount, int *wantRealStreamID);
+
+void dKPMusic::play(int id) {
+ if (s_playing) {
+ // Switch track
+ OSReport("Trying to switch to song %d (Current one is %d)...\n", id, s_song);
+ if (s_song == id || s_nextSong == id)
+ return;
+ if (s_countdownToSwitch >= 0 || s_countdownToFadeIn >= 0)
+ return;
+ OSReport("Will switch; Fading out current track 2 over %d frames\n", FADE_OUT_LEN);
+
+ s_handle.SetTrackVolume(1<<1, FADE_OUT_LEN, 0.0f);
+ s_nextSong = id;
+ s_countdownToSwitch = FADE_OUT_LEN;
+
+ } else {
+ // New track
+ OSReport("Playing song %d from the start.\n", id);
+
+ int realStreamID;
+ char brstmName[8];
+ sprintf(brstmName, "map%d", id);
+ hijackMusicWithSongName(brstmName, -1, false, 4, 2, &realStreamID);
+
+ PlaySoundWithFunctionB4(SoundRelatedClass, &s_handle, realStreamID, 1);
+
+ s_playing = true;
+ s_song = id;
+ }
+}
+
+// crap.
+#include "fileload.h"
+
+extern "C" void DVDCancel(void *crap);
+
+extern "C" void AxVoice_SetADPCM(void *axVoice, void *adpcm);
+extern "C" void Voice_SetADPCMLoop(void *voice, int channel, void *adpcmLoop);
+
+void dKPMusic::execute() {
+ if (!s_adpcmInfoLoaded) {
+ if (s_adpcmInfoLoader.load("/NewerRes/MapADPCMInfo.bin"))
+ s_adpcmInfoLoaded = true;
+ }
+
+ if (!s_playing)
+ return;
+
+ if (s_countdownToSwitch >= 0) {
+ s_countdownToSwitch--;
+ if (s_countdownToSwitch == 0) {
+ OSReport("Switching brstm files to song %d.\n", s_nextSong);
+
+ s_countdownToFadeIn = BUFFER_CLEAR_DELAY;
+
+ char brstmPath[48];
+ sprintf(brstmPath, "/Sound/new/map%d.er", s_nextSong);
+
+ u8 *sound = (u8*)(s_handle.GetSound());
+ u8 *player = sound+0x110;
+ u8 **fileStreamPointer = (u8**)(player+0x808);
+ u8 *fileStream = *fileStreamPointer;
+ DVDHandle *fileInfo = (DVDHandle*)(fileStream+0x28);
+ DVDCancel(fileInfo);
+ bool result = DVDFastOpen(DVDConvertPathToEntrynum(brstmPath), fileInfo);
+
+ OSReport("StrmSound is at %p, StrmPlayer is at %p, FileStream pointer is at %p, FileStream is at %p, FileInfo is at %p\n", sound, player, fileStreamPointer, fileStream, fileInfo);
+ OSReport("Changed to name %s. FastOpen returned: %d\n", brstmPath, result);
+
+ u8 *trackArray = player+0xB58;
+ u8 *track = (trackArray + (0x38 * 1));
+ u8 **voicePointer = (u8**)(track+4);
+ u8 *voice = *voicePointer;
+ OSReport("Track Array: %p; Track: %p; Voice Pointer: %p; Voice: %p\n", trackArray, track, voicePointer, voice);
+
+ for (int i = 0; i < 2; i++) {
+ int sourceBlockID = (s_nextSong*2)+i;
+ u8 *sourceData = ((u8*)(s_adpcmInfoLoader.buffer)) + (0x30*sourceBlockID);
+ OSReport("Using ADPCM data for channel %d from block %d, data at %p\n", i, sourceBlockID, sourceData);
+
+ Voice_SetADPCMLoop(voice, i, sourceData+0x28);
+
+ // loop through all axVoices
+ for (int j = 0; j < 4; j++) {
+ int axVoiceID = (i*4) + j;
+ u8 **axVoicePointer = (u8**)(voice + 0xC + (axVoiceID*4));
+ u8 *axVoice = *axVoicePointer;
+ OSReport("Setting AxVoice ID %d, with pointer at %p, located at %p\n", axVoiceID, axVoicePointer, axVoice);
+
+ if (axVoice)
+ AxVoice_SetADPCM(axVoice, sourceData);
+ }
+ }
+
+ OSReport("All done\n");
+
+ s_song = s_nextSong;
+ s_nextSong = -1;
+ }
+
+ } else if (s_countdownToFadeIn >= 0) {
+ s_countdownToFadeIn--;
+ if (s_countdownToFadeIn == 0) {
+ OSReport("Going to fade in the second track now!\n");
+ s_handle.SetTrackVolume(1<<1, FADE_IN_LEN, 1.0f);
+ }
+ }
+}
+
+void dKPMusic::stop() {
+ if (!s_playing)
+ return;
+
+ OSReport("Stopping song\n");
+
+ s_playing = false;
+ s_song = -1;
+ s_nextSong = -1;
+ s_countdownToSwitch = -1;
+ s_countdownToFadeIn = -1;
+
+ if (s_handle.Exists())
+ s_handle.Stop(30);
+}
diff --git a/src/koopatlas/mapmusic.h b/src/koopatlas/mapmusic.h
new file mode 100644
index 0000000..785f870
--- /dev/null
+++ b/src/koopatlas/mapmusic.h
@@ -0,0 +1,11 @@
+#ifndef MAPMUSIC_H
+#define MAPMUSIC_H
+
+class dKPMusic {
+ public:
+ static void play(int id);
+ static void execute();
+ static void stop();
+};
+
+#endif /* MAPMUSIC_H */
diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp
index 002b400..a5e4294 100644
--- a/src/koopatlas/pathmanager.cpp
+++ b/src/koopatlas/pathmanager.cpp
@@ -10,6 +10,8 @@ extern "C" void PlaySoundWithFunctionB4(void *spc, nw4r::snd::SoundHandle *handl
static u8 MaybeFinishingLevel[2] = {0xFF,0xFF};
void dWMPathManager_c::setup() {
+ dScKoopatlas_c *wm = dScKoopatlas_c::instance;
+
isMoving = false;
isJumping = false;
scaleAnimProgress = -1;
@@ -17,7 +19,7 @@ void dWMPathManager_c::setup() {
currentPath = 0;
reverseThroughPath = false;
- pathLayer = dScKoopatlas_c::instance->mapData.pathLayer;
+ pathLayer = wm->mapData.pathLayer;
SpammyReport("setting up PathManager\n");
SaveBlock *save = GetSaveFile()->GetBlock(-1);
@@ -29,11 +31,6 @@ void dWMPathManager_c::setup() {
levelStartWait = -1;
unlockPaths();
- if (!countdownToFadeIn)
- waitAtStart = 50;
- else
- waitAtStart = -1;
-
waitForAfterDeathAnim = -1;
mustPlayAfterDeathAnim = false;
if (LastPowerupStoreType == LOSE_LEVEL) {
@@ -45,9 +42,9 @@ void dWMPathManager_c::setup() {
SpammyReport("done\n");
// Figure out what path node to start at
- if (dScKoopatlas_c::instance->settings & 0x10000000) {
+ if (wm->settings & 0x10000000) {
// Start off from a "Change"
- u8 changeID = (dScKoopatlas_c::instance->settings >> 20) & 0xFF;
+ u8 changeID = (wm->settings >> 20) & 0xFF;
SpammyReport("entering at Change ID %d\n", changeID);
SpammyReport("Path layer: %p\n", pathLayer);
SpammyReport("Node count: %d\n", pathLayer->nodeCount);
@@ -112,7 +109,16 @@ void dWMPathManager_c::setup() {
mustComplainToMapCreator = true;
}
+ waitAtStart = -1;
} else {
+ if (!countdownToFadeIn)
+ waitAtStart = 50;
+ else
+ waitAtStart = -1;
+
+ if (wm->currentMapID == 0 && wm->settings & 0x80000000)
+ waitAtStart = 280;
+
SpammyReport("saved path node: %d\n", save->current_path_node);
if (save->current_path_node >= pathLayer->nodeCount) {
SpammyReport("out of bounds (%d), using node 0\n", pathLayer->nodeCount);
@@ -232,7 +238,6 @@ void dWMPathManager_c::unlockPaths() {
if (node->type == node->LEVEL && node->isUnlocked() && node->levelNumber[1] != 99) {
save->completions[node->levelNumber[0]-1][node->levelNumber[1]-1] |= COND_UNLOCKED;
- OSReport("beets: %d-%d\n", node->levelNumber[0], node->levelNumber[1]);
}
}
@@ -590,13 +595,11 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) {
if (Animations[id].initialEffect) {
SpawnEffect(Animations[id].initialEffect, 0, &player->pos, 0, &player->scale);
- daWMPlayer_c::instance->nextNowEffect = Animations[id].initialEffect;
}
if (Animations[id].initialSound != SE_NULL) {
nw4r::snd::SoundHandle something;
PlaySoundWithFunctionB4(SoundRelatedClass, &something, Animations[id].initialSound, 1);
- daWMPlayer_c::instance->nextNowSound = Animations[id].initialSound;
if (Animations[id].initialSound == SE_PLY_JUMP) {
nw4r::snd::SoundHandle something2;
@@ -735,10 +738,12 @@ void dWMPathManager_c::moveThroughPath() {
if (visiblyChange && dWMHud_c::instance)
dWMHud_c::instance->showFooter();
- dScKoopatlas_c::instance->setBGMTrack(world->trackID);
+ dKPMusic::play(world->trackID);
} else if (to->worldID == 0) {
OSReport("No world\n");
+ save->currentMapMusic = 0;
+ dKPMusic::play(0);
save->newerWorldName[0] = 0;
if (dWMHud_c::instance)
dWMHud_c::instance->hideFooter();
@@ -765,6 +770,7 @@ void dWMPathManager_c::moveThroughPath() {
SpammyReport("Change to map ID %d (%s), entrance ID %d\n", save->current_world, to->destMap, to->foreignID);
+ dScKoopatlas_c::instance->keepMusicPlaying = true;
ActivateWipe(to->transition);
DoSceneChange(WORLD_MAP, 0x10000000 | (to->foreignID << 20), 0);
@@ -828,10 +834,7 @@ void dWMPathManager_c::activatePoint() {
levelStartWait = 40;
enteredLevel = dLevelInfo_c::s_info.searchBySlot(w, l);
- if (dScKoopatlas_c::instance->bgm.Exists()) {
- dScKoopatlas_c::instance->bgm.Stop(50);
- dScKoopatlas_c::instance->bgm.DetachSound();
- }
+ dKPMusic::stop();
}
}
diff --git a/src/koopatlas/player.cpp b/src/koopatlas/player.cpp
index 3a736b4..abfb329 100644
--- a/src/koopatlas/player.cpp
+++ b/src/koopatlas/player.cpp
@@ -1,5 +1,4 @@
#include "koopatlas/player.h"
-#include "koopatlas/subplayer.h"
daWMPlayer_c *daWMPlayer_c::instance;
@@ -42,38 +41,6 @@ int daWMPlayer_c::onExecute() {
dScKoopatlas_c::instance->pathManager.execute();
- // work out the Z positions first of all
- struct ySortThing_s {
- float y; int id;
- };
- ySortThing_s sorts[4];
- sorts[0].y = pos.y;
- sorts[0].id = 0;
- for (int i = 1; i < 4; i++) {
- sorts[i].y = stateHistory[i * SUBPLAYER_DISTANCE].pos.y;
- sorts[i].id = i;
- }
-
- // bubble sort it with an algorithm from wikipedia
- bool swapped;
- do {
- swapped = false;
- for (int i = 1; i < 4; i++) {
- if (sorts[i-1].y > sorts[i].y) {
- ySortThing_s forSwap = sorts[i-1];
- sorts[i-1] = sorts[i];
- sorts[i] = forSwap;
- swapped = true;
- }
- }
- } while (swapped);
-
- // then put together the positions
- float chosenZPositions[4];
- for (int i = 0; i < 4; i++)
- chosenZPositions[sorts[i].id] = 3100.0f - (i * 25.0f);
- pos.z = chosenZPositions[0];
-
this->modelHandler->update();
mMtx myMatrix;
@@ -101,42 +68,6 @@ int daWMPlayer_c::onExecute() {
if (timer > 12) { timer = 0; }
}
- if (stateHistoryBuilt) {
- for (int i = STATE_COUNT - 1; i >= 1; i--)
- stateHistory[i] = stateHistory[i - 1];
- }
-
- state_s *st = &stateHistory[0];
- st->pos = pos;
- st->scale = scale;
- st->rot = rot;
- st->repeatedEffect = (hasEffect ? effectName : 0);
- st->nowEffect = nextNowEffect;
- st->repeatedSound = (hasSound ? soundName : 0);
- st->nowSound = nextNowSound;
- st->jumpOffset = jumpOffset;
- st->anim = currentAnim;
- st->animFrame = currentFrame;
- st->animUnk = currentUnk;
- st->animUpdateRate = currentUpdateRate;
-
- if (!stateHistoryBuilt) {
- for (int i = 1; i < STATE_COUNT; i++)
- stateHistory[i] = stateHistory[0];
- stateHistoryBuilt = true;
- }
-
- nextNowEffect = 0;
- nextNowSound = 0;
-
- for (int i = 0; i < 3; i++) {
- daWMSubPlayer_c *sp = dScKoopatlas_c::instance->subPlayer[i];
-
- state_s *st = &stateHistory[(i+1) * SUBPLAYER_DISTANCE];
- st->pos.z = chosenZPositions[i+1];
- sp->update(st);
- }
-
return true;
}
diff --git a/src/koopatlas/player.h b/src/koopatlas/player.h
index 70d6bf5..db9b16a 100644
--- a/src/koopatlas/player.h
+++ b/src/koopatlas/player.h
@@ -37,24 +37,6 @@ class daWMPlayer_c : public dActor_c {
static daWMPlayer_c *build();
static daWMPlayer_c *instance;
-
- struct state_s {
- Vec pos, scale;
- S16Vec rot;
- const char *repeatedEffect, *nowEffect;
- int repeatedSound, nowSound;
- int anim;
- float animFrame, animUnk, animUpdateRate;
- float jumpOffset;
- };
-
- bool stateHistoryBuilt;
- static const int SUBPLAYER_DISTANCE = 15;
- static const int STATE_COUNT = (SUBPLAYER_DISTANCE * 3) + 1;
- state_s stateHistory[STATE_COUNT];
-
- int nextNowSound;
- const char *nextNowEffect;
};
#endif
diff --git a/src/koopatlas/subplayer.cpp b/src/koopatlas/subplayer.cpp
deleted file mode 100644
index 8f70299..0000000
--- a/src/koopatlas/subplayer.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-#include "koopatlas/player.h"
-#include "koopatlas/subplayer.h"
-
-daWMSubPlayer_c *daWMSubPlayer_c::instance;
-
-int daWMSubPlayer_c::onCreate() {
-
- this->modelHandler = new dPlayerModelHandler_c(settings);
- // loadModel(u8 player_id, int powerup_id, int unk);
- this->modelHandler->loadModel(settings, 3, 2);
- this->modelHandler->mdlClass->startAnimation(0, 1.2, 10.0, 0.0);
- this->modelHandler->setSRT((Vec){0.0,100.0,-100.0}, (S16Vec){0,0,0}, (Vec){2.0,2.0,2.0});
- this->modelHandler->draw();
-
- hammerSuit.setup(this->modelHandler);
-
- pos = (Vec){0.0f,0.0f,3000.0f};
- rot = (S16Vec){0x1800,0,0};
- scale = (Vec){1.6f,1.6f,1.6f};
-
- step = false;
- timer = 0;
-
- return true;
-}
-
-int daWMSubPlayer_c::onDelete() {
- delete modelHandler;
-
- return true;
-}
-
-
-void daWMSubPlayer_c::update(daWMPlayer_c::state_s *st) {
- this->modelHandler->update();
-
- startAnimation(st->anim, st->animFrame, st->animUnk, st->animUpdateRate);
-
- pos = st->pos;
- scale = st->scale;
- rot = st->rot;
-
- mMtx myMatrix;
- myMatrix.scale(scale.x, scale.y, scale.z);
- myMatrix.applyTranslation(pos.x, pos.y + st->jumpOffset, pos.z);
- myMatrix.applyRotationX(&rot.x);
- myMatrix.applyRotationY(&rot.y);
- // Z is unused for now
- modelHandler->setMatrix(myMatrix);
-
- if (st->repeatedEffect) {
- Vec effPos = {pos.x, pos.y, 3300.0f};
- effect.spawn(st->repeatedEffect, 0, &effPos, &rot, &scale);
- }
-
- if (st->repeatedSound) {
- timer++;
-
- if (timer == 12) {
- if (step) { MapSoundPlayer(SoundRelatedClass, st->repeatedSound, 1); step = false; }
- else { MapSoundPlayer(SoundRelatedClass, st->repeatedSound+1, 1); step = true; }
- timer = 0;
- }
-
- if (timer > 12) { timer = 0; }
- }
-
- if (st->nowEffect) {
- SpawnEffect(st->nowEffect, 0, &pos, 0, &scale);
- }
-
- if (st->nowSound != SE_NULL) {
- nw4r::snd::SoundHandle something;
- PlaySoundWithFunctionB4(SoundRelatedClass, &something, st->nowSound, 1);
-
- if (st->nowSound == SE_PLY_JUMP) {
- nw4r::snd::SoundHandle something2;
- PlaySoundWithFunctionB4(SoundRelatedClass, &something2, SE_VOC_MA_CS_JUMP, 1);
- }
- }
-}
-
-int daWMSubPlayer_c::onDraw() {
- if (!visible)
- return true;
-
- this->modelHandler->draw();
- hammerSuit.draw();
-
- return true;
-}
-
-
-void daWMSubPlayer_c::startAnimation(int id, float frame, float unk, float updateRate) {
- if (id == currentAnim && frame == currentFrame && unk == currentUnk && updateRate == currentUpdateRate)
- return;
-
- currentAnim = id;
- currentFrame = frame;
- currentUnk = unk;
- currentUpdateRate = updateRate;
- this->modelHandler->mdlClass->startAnimation(id, frame, unk, updateRate);
-}
-
-
-
-daWMSubPlayer_c *daWMSubPlayer_c::build() {
-
- void *buffer = AllocFromGameHeap1(sizeof(daWMSubPlayer_c));
- daWMSubPlayer_c *c = new(buffer) daWMSubPlayer_c;
-
-
- instance = c;
- return c;
-}
-
diff --git a/src/koopatlas/subplayer.h b/src/koopatlas/subplayer.h
deleted file mode 100644
index d9b1b20..0000000
--- a/src/koopatlas/subplayer.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef __KOOPATLAS_SUBPLAYER_H
-#define __KOOPATLAS_SUBPLAYER_H
-
-#include "koopatlas/core.h"
-#include "poweruphax.h"
-#include <playerAnim.h>
-
-
-class daWMSubPlayer_c : public dActor_c {
- public:
- dPlayerModelHandler_c *modelHandler;
-
- int onCreate();
- int onDelete();
- int onDraw();
-
- void update(daWMPlayer_c::state_s *st);
-
- int currentAnim;
- float currentFrame;
- float currentUnk;
- float currentUpdateRate;
-
- bool step;
-
- int timer;
-
- mEf::es2 effect;
- dHammerSuitRenderer_c hammerSuit;
-
- void startAnimation(int id, float frame, float unk, float updateRate);
-
- static daWMSubPlayer_c *build();
- static daWMSubPlayer_c *instance;
-};
-
-#endif
-
diff --git a/src/layouthax.cpp b/src/layouthax.cpp
new file mode 100644
index 0000000..5e68f48
--- /dev/null
+++ b/src/layouthax.cpp
@@ -0,0 +1,8 @@
+#include <game.h>
+
+void LoadPregameStyleNameAndNumber(m2d::EmbedLayout_c *layout);
+extern "C" void InsertPauseWindowText(void *thing) {
+ m2d::EmbedLayout_c *el = (m2d::EmbedLayout_c*)(((u8*)thing)+0x70);
+ LoadPregameStyleNameAndNumber(el);
+}
+
diff --git a/src/pregame.cpp b/src/pregame.cpp
index 3a2e89c..6ac04de 100644
--- a/src/pregame.cpp
+++ b/src/pregame.cpp
@@ -53,16 +53,15 @@ class PregameLytHandler {
extern char CurrentLevel;
extern char CurrentWorld;
-#include "fileload.h"
-void PregameLytHandler::hijack_loadLevelNumber() {
+void LoadPregameStyleNameAndNumber(m2d::EmbedLayout_c *layout) {
nw4r::lyt::TextBox
*LevelNumShadow, *LevelNum,
*LevelNameShadow, *LevelName;
- LevelNumShadow = layout.findTextBoxByName("LevelNumShadow");
- LevelNum = layout.findTextBoxByName("LevelNum");
- LevelNameShadow = layout.findTextBoxByName("LevelNameShadow");
- LevelName = layout.findTextBoxByName("LevelName");
+ LevelNumShadow = layout->findTextBoxByName("LevelNumShadow");
+ LevelNum = layout->findTextBoxByName("LevelNum");
+ LevelNameShadow = layout->findTextBoxByName("LevelNameShadow");
+ LevelName = layout->findTextBoxByName("LevelName");
// work out the thing now
dLevelInfo_c::entry_s *level = dLevelInfo_c::s_info.searchBySlot(CurrentWorld, CurrentLevel);
@@ -82,13 +81,28 @@ void PregameLytHandler::hijack_loadLevelNumber() {
wcscpy(levelNumber, L"World ");
getNewerLevelNumberString(level->displayWorld, level->displayLevel, &levelNumber[6]);
- LevelNumShadow->SetString(levelNumber);
LevelNum->SetString(levelNumber);
+ // make the picture shadowy
+ int sidx = 0;
+ while (levelNumber[sidx]) {
+ if (levelNumber[sidx] == 11) {
+ levelNumber[sidx+1] = 0x200 | (levelNumber[sidx+1]&0xFF);
+ sidx += 2;
+ }
+ sidx++;
+ }
+ LevelNumShadow->SetString(levelNumber);
+
} else {
LevelNameShadow->SetString(L"Not found in LevelInfo!");
LevelName->SetString(L"Not found in LevelInfo!");
}
+}
+
+#include "fileload.h"
+void PregameLytHandler::hijack_loadLevelNumber() {
+ LoadPregameStyleNameAndNumber(&layout);
nw4r::lyt::Picture *LevelSample;
LevelSample = layout.findPictureByName("LevelSample");
diff --git a/src/randomcrap.S b/src/randomcrap.S
index d3a0388..edf5fef 100644
--- a/src/randomcrap.S
+++ b/src/randomcrap.S
@@ -237,6 +237,26 @@ EndSCM:
addi r1, r1, 0x10
blr
+.global PowEvent
+PowEvent:
+ subi r3, r3, 0x4CC
+ lwz r3, 4(r3)
+ clrlwi. r3, r3, 24
+ beqlr
+ subi r4, r3, 1
+ lis r3, instance__10dFlagMgr_c@h
+ ori r3, r3, instance__10dFlagMgr_c@l
+ lwz r3, 0(r3)
+ li r5, 0
+ li r6, 1
+ li r7, 0
+ li r8, 0
+ li r9, 0
+ b set__10dFlagMgr_cFUcibbbUi
+
+.extern set__10dFlagMgr_cFUcibbbUi
+.extern instance__10dFlagMgr_c
+
#AllocLog:
# stwu r1, -0x20(r1)
# mflr r0
diff --git a/src/topman.cpp b/src/topman.cpp
index 5a313ae..56493da 100644
--- a/src/topman.cpp
+++ b/src/topman.cpp
@@ -349,7 +349,7 @@ int daTopman::onCreate() {
// These structs tell stupid collider what to collide with - these are from koopa troopa
static const u8 one[16] = {0,0,0,1, 0,0,0xC0,0, 0,0,0x40,0, 0,0,0,0};
static const u8 two[12] = {0,0,0,0, 0,0,0,0, 0,0,0xC0,0};
- static const u8 three[16] = {0,0,0,1, 0,0,0x60,0, 0,0,0x90,0, 0,0,0x60,0};
+ static const u8 three[16] = {0,0,0,1, 0,0,0x60,0, 0,0,0x90,0, 0,0,0xE0,0};
collMgr.Init(this, one, two, three);
collMgr.execute();
diff --git a/tools/UsedProfileAndSpriteList.txt b/tools/UsedProfileAndSpriteList.txt
index ef22308..1b4ba12 100644
--- a/tools/UsedProfileAndSpriteList.txt
+++ b/tools/UsedProfileAndSpriteList.txt
@@ -7,7 +7,6 @@
--- : WM_PLAYER : Player
--- : WM_SINKSHIP : Song Prize
--- : WM_SMALLCLOUD : Bridge Bowser: Dropped Bomb
---- : WM_SUBPLAYER : SubPlayer
--- : WM_TOGEZO : Shop
--- : WORLD_CAMERA : World Camera
--- : WORLD_MAP : Koopatlas
@@ -102,7 +101,6 @@ WM_PUKU
WM_PUKU
WM_SINKSHIP
WM_SMALLCLOUD
-WM_SUBPLAYER
WM_TOGEZO
WORLD_CAMERA
WORLD_MAP
@@ -148,6 +146,7 @@ WM_PEACH_CASTLE
WM_SANDPILLAR
WM_START
WM_STOP
+WM_SUBPLAYER
WM_SURRENDER
WM_SWITCH
WM_TERESA