diff options
Diffstat (limited to '')
-rwxr-xr-x | include/game.h | 2 | ||||
-rw-r--r-- | src/cutScene.cpp | 195 | ||||
-rw-r--r-- | src/cutScene.h | 16 |
3 files changed, 175 insertions, 38 deletions
diff --git a/include/game.h b/include/game.h index cd6c639..6cdc4f6 100755 --- a/include/game.h +++ b/include/game.h @@ -3722,6 +3722,7 @@ bool FreeBreft(int efNum); // a bad hack
+extern "C" void Pause__Q44nw4r3snd6detail10BasicSoundFbi(void *_this, bool pause, int count);
extern "C" void Stop__Q44nw4r3snd6detail10BasicSoundFi(void *_this, int unk);
extern "C" void StrmSound_SetTrackVolume(void *_this, u32 mask, int count, float value);
extern "C" void SetPitch__Q44nw4r3snd6detail10BasicSoundFf(void *_this, float value);
@@ -3739,6 +3740,7 @@ namespace nw4r { void Stop(int unk) { Stop__Q44nw4r3snd6detail10BasicSoundFi(data, unk); }
void SetPitch(float value) { SetPitch__Q44nw4r3snd6detail10BasicSoundFf(data, value); }
+ void Pause(bool pause, int count) { Pause__Q44nw4r3snd6detail10BasicSoundFbi(data, pause, count); }
void *GetSound() const { return data; }
diff --git a/src/cutScene.cpp b/src/cutScene.cpp index 6cb1e3b..7b14ccb 100644 --- a/src/cutScene.cpp +++ b/src/cutScene.cpp @@ -15,6 +15,9 @@ dScCutScene_c::dScCutScene_c() { data = 0; layout = 0; sceneLoaders = 0; + + yesNoWindow = (dYesNoWindow_c*)CreateParentedObject(YES_NO_WINDOW, this, 0, 0); + CreateParentedObject(SELECT_CURSOR, this, 0, 0); } dScCutScene_c::~dScCutScene_c() { @@ -32,6 +35,12 @@ static const char *CutsceneNames[] = { "/CS/Ending.cs" }; +static const char *WideCutsceneNames[] = { + "/CS/WideOpening.cs", + "/CS/Kamek.cs", + "/CS/Ending.cs" +}; + int dScCutScene_c::onCreate() { *CurrentDrawFunc = CutSceneDrawFunc; @@ -39,7 +48,10 @@ int dScCutScene_c::onCreate() { currentScene = -1; int csNumber = settings >> 28; - if (settingsLoader.load(CutsceneNames[csNumber])) { + const char *csName = IsWideScreen() ? + WideCutsceneNames[csNumber] : CutsceneNames[csNumber]; + + if (settingsLoader.load(csName)) { // only deal with this once! if (data) return 1; @@ -72,8 +84,70 @@ int dScCutScene_c::onDelete() { } int dScCutScene_c::onExecute() { + int nowPressed = Remocon_GetPressed(GetActiveRemocon()); + + switch (yesNoStage) { + case 1: + // Opening + if (!yesNoWindow->animationActive) + yesNoStage = 2; + return true; + case 2: + // Opened + if (nowPressed & WPAD_LEFT) + yesNoWindow->current = 1; + else if (nowPressed & WPAD_RIGHT) + yesNoWindow->current = 0; + else if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) { + yesNoWindow->close = true; + + if (yesNoWindow->current != 1) + yesNoWindow->hasBG = true; + yesNoStage = 3; + + } else { + // Cancel using B or 1 + if (CheckIfMenuShouldBeCancelledForSpecifiedWiimote(0)) { + yesNoWindow->cancelled = true; + yesNoWindow->current = 1; + yesNoStage = 3; + } + } + return true; + case 3: + // Closing + if (!yesNoWindow->visible) { + if (yesNoWindow->current == 1) { + yesNoStage = 0; + for (int i = 0; i < 40; i++) + if (handles[i].Exists()) { + handles[i].Pause(false, 3); + } + } else { + yesNoStage = 4; + goToNextScene(); + } + } + return true; + case 4: + // Waiting for exit transition + return true; + } + + if (yesNoWindow->layoutLoaded && (nowPressed & WPAD_PLUS)) { + yesNoStage = 1; + yesNoWindow->type = 3; + yesNoWindow->visible = true; + + for (int i = 0; i < 40; i++) + if (handles[i].Exists()) { + handles[i].Pause(true, 3); + } + return true; + } + // deal with loading first - + // what do we want to load? if (currentScene >= 0 || nextScene >= 0) { int whatToLoad = (nextScene >= 0) ? nextScene : (currentScene + 1); @@ -85,37 +159,12 @@ int dScCutScene_c::onExecute() { // now, do all other processing if (currentScene >= 0) { - int nowPressed = Remocon_GetPressed(GetActiveRemocon()); - if (!layout->isAnyAnimOn() || nowPressed & WPAD_TWO) { + if (!layout->isAnyAnimOn()) { // we're at the end // what now? if ((currentScene + 1) == data->sceneCount) { - // we're TOTALLY done! - OSReport("playback complete\n"); - int nsmbwMovieType = settings & 3; - int newerMovieType = settings >> 28; - - switch (newerMovieType) { - case 0: - // OPENING - switch (nsmbwMovieType) { - case 0: - SaveGame(0, false); - DoSceneChange(WORLD_MAP, 0x80000000, 0); - break; - case 1: - StartTitleScreenStage(false, 0); - break; - } - break; - - case 1: - // KAMEK (W7 => W8) - ActivateWipe(WIPE_MARIO); - DoSceneChange(WORLD_MAP, 0x40000000, 0); - break; - } + goToNextScene(); } else { nextScene = currentScene + 1; OSReport("switching to scene %d\n", nextScene); @@ -132,6 +181,56 @@ int dScCutScene_c::onExecute() { frameOffset++; + // check if we gotta do anything + dMovieScene_s *scene = data->scenes[currentScene]; + int cmdsParsed = 0; + int cmdOffset = 0; + while (cmdsParsed < scene->commandCount) { + u32 cmdType = scene->command[cmdOffset++]; + cmdsParsed++; + + switch (cmdType) { + case 1: + { + u32 delay = scene->command[cmdOffset++]; + u32 soundID = scene->command[cmdOffset++]; + if (delay != frameOffset) + continue; + + nw4r::snd::SoundHandle *handle = 0; + for (int i = 20; i < 40; i++) { + if (!handles[i].Exists()) { + handle = &handles[i]; + break; + } + } + if (handle) + PlaySoundWithFunctionB4(SoundRelatedClass, handle, soundID, 1); + } break; + case 2: + { + u32 handleID = scene->command[cmdOffset++]; + u32 delay = scene->command[cmdOffset++]; + u32 soundID = scene->command[cmdOffset++]; + if (delay != frameOffset) + continue; + + PlaySoundWithFunctionB4(SoundRelatedClass, &handles[handleID], soundID, 1); + } break; + case 3: + { + u32 handleID = scene->command[cmdOffset++]; + u32 delay = scene->command[cmdOffset++]; + u32 frameCount = scene->command[cmdOffset++]; + if (delay != frameOffset) + continue; + + handles[handleID].Stop(frameCount); + handles[handleID].DetachSound(); + } break; + } + } + if (nowPressed & WPAD_ONE) { OSReport("Currently: Scene %d; Frame %d\n", currentScene, frameOffset); } @@ -159,7 +258,8 @@ int dScCutScene_c::onExecute() { layout->disableAllAnimations(); layout->enableNonLoopAnim(0); - if (data->scenes[nextScene]->widescreenFlag) { + u8 widescreenFlag = data->scenes[nextScene]->widescreenFlag; + if (widescreenFlag == 1) { // Native on 16:9, letterboxed on 4:3 if (!IsWideScreen()) { layout->clippingEnabled = true; @@ -170,7 +270,7 @@ int dScCutScene_c::onExecute() { layout->layout.rootPane->scale.x = 0.7711f; layout->layout.rootPane->scale.y = 0.7711f; } - } else { + } else if (widescreenFlag == 0) { // Native on 4:3, black bars on 16:9 if (IsWideScreen()) { layout->clippingEnabled = true; @@ -225,3 +325,36 @@ void CutSceneDrawFunc() { SetCurrentCameraID(0); } + +void dScCutScene_c::goToNextScene() { + // we're TOTALLY done! + OSReport("playback complete\n"); + int nsmbwMovieType = settings & 3; + int newerMovieType = settings >> 28; + + for (int i = 0; i < 40; i++) + if (handles[i].Exists()) + handles[i].Stop(5); + + switch (newerMovieType) { + case 0: + // OPENING + switch (nsmbwMovieType) { + case 0: + SaveGame(0, false); + DoSceneChange(WORLD_MAP, 0x80000000, 0); + break; + case 1: + StartTitleScreenStage(false, 0); + break; + } + break; + + case 1: + // KAMEK (W7 => W8) + ActivateWipe(WIPE_MARIO); + DoSceneChange(WORLD_MAP, 0x40000000, 0); + break; + } +} + diff --git a/src/cutScene.h b/src/cutScene.h index 07c665e..ce1ab0d 100644 --- a/src/cutScene.h +++ b/src/cutScene.h @@ -20,10 +20,14 @@ class dScCutScene_c : public dScene_c { int onExecute(); int onDraw(); + void goToNextScene(); + int currentScene; int nextScene; int frameOffset; + nw4r::snd::SoundHandle handles[40]; + dMovieData_s *data; dDvdLoader_c settingsLoader; @@ -31,21 +35,19 @@ class dScCutScene_c : public dScene_c { m2d::EmbedLayout_c *layout; + dYesNoWindow_c *yesNoWindow; + int yesNoStage; + static dScCutScene_c *build(); static dScCutScene_c *instance; }; -struct dMovieSound_s { - u32 delay; - u32 soundID; -}; - struct dMovieScene_s { char *sceneName; u8 widescreenFlag; - u32 soundCount; - dMovieSound_s sounds[1]; + u32 commandCount; + u32 command[1]; }; struct dMovieData_s { |