Commit 947aa7ae authored by alistert's avatar alistert

Simplified Scene animation loading.

parent 9a3017d7
...@@ -381,7 +381,8 @@ int Scene::play () { ...@@ -381,7 +381,8 @@ int Scene::play () {
} else if (pages[sceneIndex].animIndex != -1) { } else if (pages[sceneIndex].animIndex != -1) {
if(currentFrame == NULL) { if (currentFrame == NULL) {
animation = animations; animation = animations;
while (animation && (animation->id != pages[sceneIndex].animIndex)) while (animation && (animation->id != pages[sceneIndex].animIndex))
...@@ -391,32 +392,38 @@ int Scene::play () { ...@@ -391,32 +392,38 @@ int Scene::play () {
dst.x = (canvasW - SW) >> 1; dst.x = (canvasW - SW) >> 1;
dst.y = (canvasH - SH) >> 1; dst.y = (canvasH - SH) >> 1;
frameDelay = 1000/(pages[sceneIndex].animSpeed>>8); frameDelay = 1000 / (pages[sceneIndex].animSpeed >> 8);
SDL_BlitSurface(animation->background, NULL, canvas, &dst); SDL_BlitSurface(animation->background, NULL, canvas, &dst);
currentFrame = animation->sceneFrames; currentFrame = animation->sceneFrames;
SDL_Delay(frameDelay); SDL_Delay(frameDelay);
} }
}
else { } else {
// Upload pixel data to the surface // Upload pixel data to the surface
if (SDL_MUSTLOCK(animation->background)) SDL_LockSurface(animation->background); if (SDL_MUSTLOCK(animation->background)) SDL_LockSurface(animation->background);
switch(currentFrame->frameType) switch (currentFrame->frameType) {
{
case ESquareAniHeader: case ESquareAniHeader:
{
loadCompactedMem(currentFrame->frameSize, currentFrame->frameData,(unsigned char*) animation->background->pixels, SW, SH); loadCompactedMem(currentFrame->frameSize, currentFrame->frameData, (unsigned char*)animation->background->pixels, SW, SH);
}
break; break;
case EFFAniHeader: case EFFAniHeader:
{
unsigned char* data = currentFrame->frameData; loadFFMem(currentFrame->frameSize, currentFrame->frameData, (unsigned char*)animation->background->pixels);
int size = currentFrame->frameSize;
loadFFMem(size, currentFrame->frameData, (unsigned char*) animation->background->pixels); break;
}break;
default: default:
LOG("Scene::Play unknown type", currentFrame->frameType); LOG("Scene::Play unknown type", currentFrame->frameType);
break; break;
} }
if (SDL_MUSTLOCK(animation->background)) SDL_UnlockSurface(animation->background); if (SDL_MUSTLOCK(animation->background)) SDL_UnlockSurface(animation->background);
...@@ -425,39 +432,45 @@ int Scene::play () { ...@@ -425,39 +432,45 @@ int Scene::play () {
dst.y = (canvasH - SH) >> 1; dst.y = (canvasH - SH) >> 1;
SDL_BlitSurface(animation->background, NULL, canvas, &dst); SDL_BlitSurface(animation->background, NULL, canvas, &dst);
if(currentFrame->soundId != -1 && animation->noSounds > 0) { if (currentFrame->soundId != -1 && animation->noSounds > 0) {
LOG("PLAY SOUND NAME",animation->soundNames[currentFrame->soundId-1]); LOG("PLAY SOUND NAME",animation->soundNames[currentFrame->soundId-1]);
// Search for matching sound // Search for matching sound
for (int y = 0; y < nSounds ; y++) { for (int y = 0; y < nSounds ; y++) {
if (!strcmp(animation->soundNames[currentFrame->soundId-1], sounds[y].name)) { if (!strcmp(animation->soundNames[currentFrame->soundId-1], sounds[y].name)) {
playSound(y); playSound(y);
break; break;
} }
} }
} }
lastFrame = currentFrame; lastFrame = currentFrame;
if(prevFrame) { if (prevFrame) currentFrame = currentFrame->prev;
currentFrame = currentFrame->prev; else currentFrame = currentFrame->next;
}
else {
currentFrame = currentFrame->next;
}
SDL_Delay(frameDelay); SDL_Delay(frameDelay);
if(currentFrame == NULL && animation->reverseAnimation) {
/*prevFrame = 1-prevFrame;
/*if(prevFrame) { if (currentFrame == NULL && animation->reverseAnimation) {
currentFrame = lastFrame->prev;
} //prevFrame = 1 - prevFrame;
else {
currentFrame = lastFrame->next; /*if(prevFrame) currentFrame = lastFrame->prev;
}*/ else currentFrame = lastFrame->next;*/
currentFrame = NULL;//animation->sceneFrames; currentFrame = NULL;//animation->sceneFrames;
}
else if(currentFrame == NULL && !pageTime && !pages[sceneIndex].askForYesNo && pages[sceneIndex].nextPageAfterAnim) { } else if (currentFrame == NULL && !pageTime && !pages[sceneIndex].askForYesNo && pages[sceneIndex].nextPageAfterAnim) {
continueToNextPage = 1; continueToNextPage = 1;
} }
} }
} else clearScreen(0); } else clearScreen(0);
......
...@@ -234,9 +234,10 @@ class Scene { ...@@ -234,9 +234,10 @@ class Scene {
void loadScripts (File* f); void loadScripts (File* f);
void loadData (File* f); void loadData (File* f);
void loadAni (File* f, int dataIndex); void loadAni (File* f, int dataIndex);
void loadCompacted(int size, File* f, unsigned char* pixdata, int width, int height); void loadCompactedMem (int size, unsigned char* frameData, unsigned char* pixdata, int width, int height);
void loadCompactedMem(int size, unsigned char* frameData, unsigned char* pixdata, int width, int height); void loadFFMem (int size, unsigned char* frameData, unsigned char* pixdata);
void loadFFMem(int size, unsigned char* frameData, unsigned char* pixdata); unsigned short int loadShortMem (unsigned char **data);
public: public:
Scene (const char* fileName); Scene (const char* fileName);
~Scene (); ~Scene ();
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment