diff options
author | Eugene Sandulenko | 2006-11-08 21:46:57 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2006-11-08 21:46:57 +0000 |
commit | 5e5bba4397c7440dd04b559e00328e1732f1b971 (patch) | |
tree | 7b92c10f6e54b91dd9a160f7d751f44531503f6e /engines/cine | |
parent | ff14e19552e7fb1406071c785dbe3fd4cd40b95e (diff) | |
download | scummvm-rg350-5e5bba4397c7440dd04b559e00328e1732f1b971.tar.gz scummvm-rg350-5e5bba4397c7440dd04b559e00328e1732f1b971.tar.bz2 scummvm-rg350-5e5bba4397c7440dd04b559e00328e1732f1b971.zip |
Fix bug #1579776: "FW: Save does not work properly"
svn-id: r24659
Diffstat (limited to 'engines/cine')
-rw-r--r-- | engines/cine/bg_list.cpp | 147 | ||||
-rw-r--r-- | engines/cine/bg_list.h | 24 | ||||
-rw-r--r-- | engines/cine/cine.cpp | 3 | ||||
-rw-r--r-- | engines/cine/main_loop.cpp | 5 | ||||
-rw-r--r-- | engines/cine/script.cpp | 35 | ||||
-rw-r--r-- | engines/cine/various.cpp | 40 | ||||
-rw-r--r-- | engines/cine/various.h | 2 |
7 files changed, 194 insertions, 62 deletions
diff --git a/engines/cine/bg_list.cpp b/engines/cine/bg_list.cpp index 3b2026e7cf..8f46994aa3 100644 --- a/engines/cine/bg_list.cpp +++ b/engines/cine/bg_list.cpp @@ -22,32 +22,155 @@ * */ -#include "cine/bg_list.h" -#include "cine/gfx.h" +#include "common/stdafx.h" +#include "common/endian.h" +#include "common/stream.h" + +#include "cine/cine.h" +#include "cine/main_loop.h" #include "cine/object.h" -#include "cine/part.h" +#include "cine/various.h" +#include "cine/bg_list.h" namespace Cine { -void createVar9Element(int16 objIdx, int16 param); +uint32 var8; +BGIncrustList *bgIncrustList; -void addSpriteFilledToBGList(int16 idx) { +void addToBGList(int16 objIdx, bool addList) { int16 x; int16 y; int16 width; int16 height; + int16 part; + + x = objectTable[objIdx].x; + y = objectTable[objIdx].y; + + width = animDataTable[objectTable[objIdx].frame].var1; + height = animDataTable[objectTable[objIdx].frame].height; + + part = objectTable[objIdx].part; + + if (g_cine->getGameType() == GType_OS) { + drawSpriteRaw2(animDataTable[objectTable[objIdx].frame].ptr1, objectTable[objIdx].part, width, height, page2Raw, x, y); + } else { + drawSpriteRaw(animDataTable[objectTable[objIdx].frame].ptr1, animDataTable[objectTable[objIdx].frame].ptr2, width, height, page2Raw, x, y); + } + + if (addList) + createBgIncrustListElement(objIdx, 0); +} + +void addSpriteFilledToBGList(int16 objIdx, bool addList) { + int16 x; + int16 y; + int16 width; + int16 height; + + x = objectTable[objIdx].x; + y = objectTable[objIdx].y; + + width = animDataTable[objectTable[objIdx].frame].width; + height = animDataTable[objectTable[objIdx].frame].height; + + if (animDataTable[objectTable[objIdx].frame].ptr1) { + gfxFillSprite(animDataTable[objectTable[objIdx].frame].ptr1, width / 2, height, page2Raw, x, y); + } - x = objectTable[idx].x; - y = objectTable[idx].y; + if (addList) + createBgIncrustListElement(objIdx, 1); +} + +void createBgIncrustListElement(int16 objIdx, int16 param) { + BGIncrustList *bgIncrustPtr = bgIncrustList; + BGIncrustList *bgIncrustPtrP = 0; + + // Find first empty element + while (bgIncrustPtr) { + bgIncrustPtrP = bgIncrustPtr; + bgIncrustPtr = bgIncrustPtr->next; + } + + bgIncrustPtr = (BGIncrustList *)malloc(sizeof(BGIncrustList)); + if (bgIncrustPtrP) + bgIncrustPtrP->next = bgIncrustPtr; + else + bgIncrustList = bgIncrustPtr; - width = animDataTable[objectTable[idx].frame].width; - height = animDataTable[objectTable[idx].frame].height; + bgIncrustPtr->next = 0; - if (animDataTable[objectTable[idx].frame].ptr1) { - gfxFillSprite(animDataTable[objectTable[idx].frame].ptr1, width / 2, height, page2Raw, x, y); + bgIncrustPtr->objIdx = objIdx; + bgIncrustPtr->param = param; + bgIncrustPtr->x = objectTable[objIdx].x; + bgIncrustPtr->y = objectTable[objIdx].y; + bgIncrustPtr->frame = objectTable[objIdx].frame; + bgIncrustPtr->part = objectTable[objIdx].part; +} + +void freeBgIncrustList(void) { + BGIncrustList *bgIncrustPtr = bgIncrustList; + BGIncrustList *bgIncrustPtrN; + + while (bgIncrustPtr) { + bgIncrustPtrN = bgIncrustPtr->next; + free(bgIncrustPtr); + bgIncrustPtr = bgIncrustPtrN; } +} + +void resetBgIncrustList(void) { + bgIncrustList = NULL; + var8 = 0; +} + +void loadBgIncrustFromSave(Common::InSaveFile *fHandle) { + BGIncrustList *bgIncrustPtr = bgIncrustList; + BGIncrustList *bgIncrustPtrP = 0; + + // Find first empty element + while (bgIncrustPtr) { + bgIncrustPtrP = bgIncrustPtr; + bgIncrustPtr = bgIncrustPtr->next; + } + + bgIncrustPtr = (BGIncrustList *)malloc(sizeof(BGIncrustList)); + if (bgIncrustPtrP) + bgIncrustPtrP->next = bgIncrustPtr; + else + bgIncrustList = bgIncrustPtr; + + bgIncrustPtr->next = 0; + + fHandle->readUint32BE(); + fHandle->readUint32BE(); + + bgIncrustPtr->objIdx = fHandle->readUint16BE(); + bgIncrustPtr->param = fHandle->readUint16BE(); + bgIncrustPtr->x = fHandle->readUint16BE(); + bgIncrustPtr->y = fHandle->readUint16BE(); + bgIncrustPtr->frame = fHandle->readUint16BE(); + bgIncrustPtr->part = fHandle->readUint16BE(); +} + +void reincrustAllBg(void) { + BGIncrustList *bgIncrustPtr = bgIncrustList; + + while (bgIncrustPtr) { +#if 0 + objectTable[bgIncrustPtr->objIdx].x = bgIncrustPtr->x; + objectTable[bgIncrustPtr->objIdx].y = bgIncrustPtr->y; + objectTable[bgIncrustPtr->objIdx].frame = bgIncrustPtr->frame; + objectTable[bgIncrustPtr->objIdx].part = bgIncrustPtr->part; +#endif + if (bgIncrustPtr->param == 0) { + addToBGList(bgIncrustPtr->objIdx, false); + } else { + addSpriteFilledToBGList(bgIncrustPtr->objIdx, false); + } - createVar9Element(idx, 1); + bgIncrustPtr = bgIncrustPtr->next; + } } } // End of namespace Cine diff --git a/engines/cine/bg_list.h b/engines/cine/bg_list.h index 662a1b003b..0bc6431c30 100644 --- a/engines/cine/bg_list.h +++ b/engines/cine/bg_list.h @@ -27,10 +27,32 @@ #include "common/stdafx.h" #include "common/scummsys.h" +#include "common/savefile.h" namespace Cine { -void addSpriteFilledToBGList(int16 idx); +struct BGIncrustList { + struct BGIncrustList *next; + byte *unkPtr; + int16 objIdx; + int16 param; + int16 x; + int16 y; + int16 frame; + int16 part; +}; + +extern BGIncrustList *bgIncrustList; +extern uint32 var8; + +void addToBGList(int16 objIdx, bool addList = true); +void addSpriteFilledToBGList(int16 idx, bool addList = true); + +void createBgIncrustListElement(int16 objIdx, int16 param); +void freeBgIncrustList(void); +void resetBgIncrustList(void); +void loadBgIncrustFromSave(Common::InSaveFile *fHandle); +void reincrustAllBg(void); } // End of namespace Cine diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp index 58c957e77d..1b094af523 100644 --- a/engines/cine/cine.cpp +++ b/engines/cine/cine.cpp @@ -35,6 +35,7 @@ #include "sound/mixer.h" #include "cine/cine.h" +#include "cine/bg_list.h" #include "cine/main_loop.h" #include "cine/object.h" #include "cine/sfx_player.h" @@ -177,7 +178,7 @@ static void initialize() { overlayHead.previous = NULL; var8 = 0; - var9 = NULL; + bgIncrustList = NULL; objScriptList.next = NULL; globalScriptsHead.next = NULL; diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp index d35bfaa766..c437033e6f 100644 --- a/engines/cine/main_loop.cpp +++ b/engines/cine/main_loop.cpp @@ -30,6 +30,7 @@ #include "cine/object.h" #include "cine/sfx_player.h" #include "cine/various.h" +#include "cine/bg_list.h" namespace Cine { @@ -166,7 +167,7 @@ void mainLoop(int bootScriptIdx) { resetSeqList(); resetglobalScriptsHead(); resetObjectScriptHead(); - mainLoopSub1(); + resetBgIncrustList(); setTextWindow(0, 0, 20, 200); @@ -307,7 +308,7 @@ void mainLoop(int bootScriptIdx) { // if (g_cine->getGameType() == Cine::GType_OS) { // freeUnkList(); // } - closeEngine7(); + freeBgIncrustList(); closePart(); } diff --git a/engines/cine/script.cpp b/engines/cine/script.cpp index c26d1b165e..44b8f56435 100644 --- a/engines/cine/script.cpp +++ b/engines/cine/script.cpp @@ -523,33 +523,6 @@ uint16 isSeqRunning(uint16 param1, uint16 param2, uint16 param3) { scriptStruct scriptTable[NUM_MAX_SCRIPT]; -void createVar9Element(int16 objIdx, int16 param) { -} - -void addToBGList(int16 objIdx) { - int16 x; - int16 y; - int16 width; - int16 height; - int16 part; - - x = objectTable[objIdx].x; - y = objectTable[objIdx].y; - - width = animDataTable[objectTable[objIdx].frame].var1; - height = animDataTable[objectTable[objIdx].frame].height; - - part = objectTable[objIdx].part; - - if (g_cine->getGameType() == Cine::GType_OS) { - drawSpriteRaw2(animDataTable[objectTable[objIdx].frame].ptr1, objectTable[objIdx].part, width, height, page2Raw, x, y); - } else { - drawSpriteRaw(animDataTable[objectTable[objIdx].frame].ptr1, animDataTable[objectTable[objIdx].frame].ptr2, width, height, page2Raw, x, y); - } - - createVar9Element(objIdx, 0); -} - void stopGlobalScript(uint16 scriptIdx) { prcLinkedListStruct *currentHead = &globalScriptsHead; prcLinkedListStruct *tempHead = currentHead; @@ -1307,8 +1280,8 @@ void o1_addSpriteFilledToBgList() { } void o1_op1B() { - debugC(5, kCineDebugScript, "Line: %d: closeEngine7", _currentLine); - closeEngine7(); + debugC(5, kCineDebugScript, "Line: %d: freeBgIncrustList", _currentLine); + freeBgIncrustList(); } void o1_label() { @@ -1460,7 +1433,7 @@ void o1_loadBg() { debugC(5, kCineDebugScript, "Line: %d: loadBg(\"%s\")", _currentLine, param); loadBg(param); - closeEngine7(); + freeBgIncrustList(); bgVar0 = 0; } @@ -2756,7 +2729,7 @@ void decompileScript(byte *scriptPtr, int16 *stackPtr, uint16 scriptSize, uint16 } case 0x1B: { - sprintf(lineBuffer, "closeEngine7()\n"); + sprintf(lineBuffer, "freeBgIncrustList()\n"); break; } case 0x1D: diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp index 73602be214..0814dfbcbd 100644 --- a/engines/cine/various.cpp +++ b/engines/cine/various.cpp @@ -31,6 +31,7 @@ #include "cine/main_loop.h" #include "cine/object.h" #include "cine/sfx_player.h" +#include "cine/bg_list.h" #include "cine/various.h" namespace Cine { @@ -44,8 +45,6 @@ int16 commandVar2; unk1Struct messageTable[NUM_MAX_MESSAGE]; uint32 var6; -uint32 var8; -byte *var9; uint16 var2; uint16 var3; @@ -69,9 +68,6 @@ void waitPlayerInput(void) { void freeAnimDataTable(void) { } -void mainLoopSub1(void) { -} - void setTextWindow(uint16 param1, uint16 param2, uint16 param3, uint16 param4) { } @@ -606,7 +602,7 @@ int16 makeLoad(char *saveName) { // } freePrcLinkedList(); releaseObjectScripts(); - closeEngine7(); + freeBgIncrustList(); closePart(); for (i = 0; i < NUM_MAX_REL; i++) { @@ -780,8 +776,9 @@ int16 makeLoad(char *saveName) { } size = fHandle->readSint16BE(); + debug(0, "%d entries", size); for (i = 0; i < size; i++) { - // loadBgIncrustFromSave(fHandle); + loadBgIncrustFromSave(fHandle); } delete fHandle; @@ -815,7 +812,7 @@ int16 makeLoad(char *saveName) { } loadResourcesFromSave(); - //reincrustAllBg(); + reincrustAllBg(); setMouseCursor(MOUSE_CURSOR_NORMAL); @@ -1021,8 +1018,28 @@ void makeSave(char *saveFileName) { } } - // This corresponds to the loadBgIncrustFromSave() handling, I think. - fHandle->writeUint16BE(0); + int numBgIncrustList = 0; + BGIncrustList *bgIncrustPtr = bgIncrustList; + + while (bgIncrustPtr) { + numBgIncrustList++; + bgIncrustPtr = bgIncrustPtr->next; + } + + fHandle->writeUint16BE(numBgIncrustList); + bgIncrustPtr = bgIncrustList; + while (bgIncrustPtr) { + fHandle->writeUint32BE(0); // next + fHandle->writeUint32BE(0); // unkPtr + fHandle->writeUint16BE(bgIncrustPtr->objIdx); + fHandle->writeUint16BE(bgIncrustPtr->param); + fHandle->writeUint16BE(bgIncrustPtr->x); + fHandle->writeUint16BE(bgIncrustPtr->y); + fHandle->writeUint16BE(bgIncrustPtr->frame); + fHandle->writeUint16BE(bgIncrustPtr->part); + + bgIncrustPtr = bgIncrustPtr->next; + } delete fHandle; @@ -2884,9 +2901,6 @@ uint16 exitEngine; void hideMouse(void) { } -void closeEngine7(void) { -} - void removeExtention(char *dest, const char *source) { byte *ptr; diff --git a/engines/cine/various.h b/engines/cine/various.h index 6b21d285a2..7cd7e37a52 100644 --- a/engines/cine/various.h +++ b/engines/cine/various.h @@ -75,7 +75,6 @@ extern SeqListElement seqList; extern uint32 var6; extern uint32 var8; -extern byte *var9; extern uint16 var2; extern uint16 var3; @@ -152,7 +151,6 @@ void checkForPendingDataLoad(void); extern uint16 exitEngine; void hideMouse(void); -void closeEngine7(void); extern uint16 var22; |