#include "cutScene.h" dScCutScene_c *dScCutScene_c::instance = 0; dScCutScene_c *dScCutScene_c::build() { // return new dScCutScene_c; void *buffer = AllocFromGameHeap1(sizeof(dScCutScene_c)); dScCutScene_c *c = new(buffer) dScCutScene_c; instance = c; return c; } dScCutScene_c::dScCutScene_c() { data = 0; layout = 0; sceneLoaders = 0; } dScCutScene_c::~dScCutScene_c() { if (layout) delete layout; if (sceneLoaders) delete[] sceneLoaders; } static const char *CutsceneNames[] = { "/CS/Opening.cs", "/CS/Kamek.cs", "/CS/Ending.cs" }; int dScCutScene_c::onCreate() { *CurrentDrawFunc = CutSceneDrawFunc; currentScene = -1; int csNumber = settings >> 28; if (settingsLoader.load(CutsceneNames[csNumber])) { // only deal with this once! if (data) return 1; data = (dMovieData_s*)settingsLoader.buffer; // fix up the settings for (int i = 0; i < data->sceneCount; i++) { data->scenes[i] = (dMovieScene_s*)((u32)data + (u32)data->scenes[i]); data->scenes[i]->sceneName = (char*)((u32)data + (u32)data->scenes[i]->sceneName); } sceneLoaders = new dDvdLoader_c[data->sceneCount]; nextScene = 0; return 1; } return 0; } int dScCutScene_c::onDelete() { if (layout) return layout->free(); return true; } int dScCutScene_c::onExecute() { // deal with loading first // what do we want to load? if (currentScene >= 0 || nextScene >= 0) { int whatToLoad = (nextScene >= 0) ? nextScene : (currentScene + 1); sceneLoaders[whatToLoad].load(data->scenes[whatToLoad]->sceneName); } // now, do all other processing if (currentScene >= 0) { int nowPressed = Remocon_GetPressed(GetActiveRemocon()); if (!layout->isAnyAnimOn() || nowPressed & WPAD_TWO) { // we're at the end // what now? if ((currentScene + 1) == data->sceneCount) { // we're TOTALLY done! OSReport("playback complete\n"); DoSceneChange(WORLD_MAP, 0x80000000, 0); } else { nextScene = currentScene + 1; OSReport("switching to scene %d\n", nextScene); } sceneLoaders[currentScene].unload(); currentScene = -1; layout->loader.buffer = 0; layout->free(); delete layout; layout = 0; return true; } layout->execAnimations(); layout->update(); } if (nextScene >= 0) { // is this scene loaded yet? if (sceneLoaders[nextScene].buffer) { currentScene = nextScene; OSReport("Loading scene %d\n", currentScene); layout = new m2d::EmbedLayout_c; layout->loader.buffer = sceneLoaders[nextScene].buffer; layout->loader.attachArc(layout->loader.buffer, "arc"); layout->resAccPtr = &layout->loader; bool result = layout->build("cutscene.brlyt"); OSReport("Result: %d\n", result); layout->loadAnimations((const char *[1]){"cutscene.brlan"}, 1); layout->loadGroups((const char *[1]){"cutscene"}, (int[1]){0}, 1); layout->disableAllAnimations(); layout->enableNonLoopAnim(0); if (data->scenes[nextScene]->widescreenFlag) { // Native on 16:9, letterboxed on 4:3 if (!IsWideScreen()) { layout->clippingEnabled = true; layout->clipX = 0; layout->clipY = 52; layout->clipWidth = 640; layout->clipHeight = 352; layout->layout.rootPane->scale.x = 0.7711f; layout->layout.rootPane->scale.y = 0.7711f; } } else { // Native on 4:3, black bars on 16:9 if (IsWideScreen()) { layout->clippingEnabled = true; layout->clipX = 66; layout->clipY = 0; layout->clipWidth = 508; layout->clipHeight = 456; layout->layout.rootPane->scale.x = 0.794f; } } layout->execAnimations(); layout->update(); OSReport("Loaded scene %d\n", currentScene); nextScene = -1; } } return true; } int dScCutScene_c::onDraw() { if (currentScene >= 0) layout->scheduleForDrawing(); return true; } void CutSceneDrawFunc() { Reset3DState(); SetupLYTDrawing(); DrawAllLayoutsBeforeX(0x81); RenderEffects(0, 3); RenderEffects(0, 2); GXDrawDone(); RemoveAllFromScnRoot(); Reset3DState(); SetCurrentCameraID(1); DoSpecialDrawing1(); SetCurrentCameraID(0); for (int i = 0; i < 4; i++) RenderEffects(0, 0xB+i); for (int i = 0; i < 4; i++) RenderEffects(0, 7+i); GXDrawDone(); // Leaving out some stuff here DrawAllLayoutsAfterX(0x80); ClearLayoutDrawList(); SetCurrentCameraID(0); }