summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-09-01 05:09:47 +0200
committerTreeki <treeki@gmail.com>2012-09-01 05:09:47 +0200
commitf1d937694dc9d9f9637af8c72293dab9edeaf7a2 (patch)
treed02dca08e9077b77f3ce85516689110f3825dce8 /src
parentfbcd0d0d86409976ab22caeea25dc934486345a1 (diff)
downloadkamek-f1d937694dc9d9f9637af8c72293dab9edeaf7a2.tar.gz
kamek-f1d937694dc9d9f9637af8c72293dab9edeaf7a2.zip
the beginnings of a working cutscene player
Diffstat (limited to 'src')
-rw-r--r--src/cutScene.cpp130
-rw-r--r--src/cutScene.h31
2 files changed, 159 insertions, 2 deletions
diff --git a/src/cutScene.cpp b/src/cutScene.cpp
index 27fbafc..f60122f 100644
--- a/src/cutScene.cpp
+++ b/src/cutScene.cpp
@@ -11,26 +11,152 @@ dScCutScene_c *dScCutScene_c::build() {
return c;
}
-dScCutScene_c::dScCutScene_c() : state(this) {
+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;
- return true;
+ 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?
+ int loadBegin, loadEnd;
+ if (nextScene == 0) {
+ loadBegin = 0;
+ loadEnd = 1;
+ } else {
+ loadBegin = ((currentScene + 1) > nextScene) ? (currentScene + 1) : nextScene;
+ loadEnd = data->sceneCount;
+ }
+
+ for (int i = loadBegin; i < loadEnd; i++) {
+ sceneLoaders[i].load(data->scenes[i]->sceneName);
+ }
+
+
+
+ // now, do all other processing
+
+ if (currentScene >= 0) {
+ if (!layout->isAnyAnimOn()) {
+ // we're at the end
+ // what now?
+
+ if ((currentScene + 1) == data->sceneCount) {
+ // we're TOTALLY done!
+ OSReport("playback complete\n");
+ } else {
+ nextScene = currentScene + 1;
+ OSReport("switching to scene %d\n", nextScene);
+ }
+
+ sceneLoaders[currentScene].unload();
+ currentScene = -1;
+ 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 (IsWideScreen()) {
+ layout->clippingEnabled = true;
+ layout->clipX = 66;
+ layout->clipY = 0;
+ layout->clipWidth = 508;
+ layout->clipHeight = 456;
+ layout->layout.rootPane->scale.x = 0.794f;
+ }
+
+ OSReport("Loaded scene %d\n", currentScene);
+
+ nextScene = -1;
+ }
+ }
+
return true;
}
int dScCutScene_c::onDraw() {
+ if (currentScene >= 0)
+ layout->scheduleForDrawing();
+
return true;
}
diff --git a/src/cutScene.h b/src/cutScene.h
index e875822..5845a86 100644
--- a/src/cutScene.h
+++ b/src/cutScene.h
@@ -8,18 +8,49 @@
void CutSceneDrawFunc();
+struct dMovieData_s;
+
class dScCutScene_c : public dScene_c {
public:
dScCutScene_c();
+ ~dScCutScene_c();
int onCreate();
int onDelete();
int onExecute();
int onDraw();
+ int currentScene;
+ int nextScene;
+
+ dMovieData_s *data;
+
+ dDvdLoader_c settingsLoader;
+ dDvdLoader_c *sceneLoaders;
+
+ m2d::EmbedLayout_c *layout;
+
static dScCutScene_c *build();
static dScCutScene_c *instance;
};
+
+struct dMovieSound_s {
+ u32 delay;
+ u32 soundID;
+};
+
+struct dMovieScene_s {
+ char *sceneName;
+ u32 soundCount;
+ dMovieSound_s sounds[1];
+};
+
+struct dMovieData_s {
+ u32 magic;
+ u32 sceneCount;
+ dMovieScene_s *scenes[1];
+};
+
#endif