aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorVincent Hamm2007-12-18 20:12:42 +0000
committerVincent Hamm2007-12-18 20:12:42 +0000
commitaa62d6355a3d4729d3f013d5ec11a15b52ac227f (patch)
tree438d81747130674688a8bd3257cb0b0f39d681ca /engines
parent550aea90ff5a5c73c231c69a6f478522c61e374a (diff)
downloadscummvm-rg350-aa62d6355a3d4729d3f013d5ec11a15b52ac227f.tar.gz
scummvm-rg350-aa62d6355a3d4729d3f013d5ec11a15b52ac227f.tar.bz2
scummvm-rg350-aa62d6355a3d4729d3f013d5ec11a15b52ac227f.zip
Fix loading savegame from original interpreter
svn-id: r29901
Diffstat (limited to 'engines')
-rw-r--r--engines/cruise/background.cpp8
-rw-r--r--engines/cruise/cruise.cpp2
-rw-r--r--engines/cruise/cruise_main.cpp34
-rw-r--r--engines/cruise/cruise_main.h9
-rw-r--r--engines/cruise/decompiler.cpp4
-rw-r--r--engines/cruise/font.cpp30
-rw-r--r--engines/cruise/font.h2
-rw-r--r--engines/cruise/function.cpp61
-rw-r--r--engines/cruise/function.h3
-rw-r--r--engines/cruise/mainDraw.cpp10
-rw-r--r--engines/cruise/menu.cpp71
-rw-r--r--engines/cruise/perso.cpp5
-rw-r--r--engines/cruise/perso.h2
-rw-r--r--engines/cruise/saveload.cpp214
-rw-r--r--engines/cruise/saveload.h1
-rw-r--r--engines/cruise/script.cpp8
-rw-r--r--engines/cruise/various.cpp2
-rw-r--r--engines/cruise/various.h2
-rw-r--r--engines/cruise/vars.cpp40
-rw-r--r--engines/cruise/vars.h42
-rw-r--r--engines/cruise/volume.cpp58
-rw-r--r--engines/cruise/volume.h3
22 files changed, 418 insertions, 193 deletions
diff --git a/engines/cruise/background.cpp b/engines/cruise/background.cpp
index 2dd434b180..c346512ab2 100644
--- a/engines/cruise/background.cpp
+++ b/engines/cruise/background.cpp
@@ -46,10 +46,10 @@ int loadMEN(uint8 **ptr) {
if (!strcmp(localPtr, "MEN")) {
localPtr += 4;
- video4 = *(localPtr++);
- video3 = *(localPtr++);
- video2 = *(localPtr++);
- colorOfSelectedSaveDrive = *(localPtr++);
+ titleColor = *(localPtr++);
+ selectColor = *(localPtr++);
+ itemColor = *(localPtr++);
+ subColor = *(localPtr++);
*ptr = (uint8 *) localPtr;
diff --git a/engines/cruise/cruise.cpp b/engines/cruise/cruise.cpp
index 8252877046..8d6c04968e 100644
--- a/engines/cruise/cruise.cpp
+++ b/engines/cruise/cruise.cpp
@@ -108,7 +108,7 @@ void CruiseEngine::initialize() {
// video init stuff
- loadSystemFont();
+ initSystem();
// another bit of video init
diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp
index 49d131497f..50da94a9c9 100644
--- a/engines/cruise/cruise_main.cpp
+++ b/engines/cruise/cruise_main.cpp
@@ -63,7 +63,7 @@ void drawInfoStringSmallBlackBox(uint8 *string) {
gfxModuleData_gfxWaitVSync();
drawBlackSolidBoxSmall();
- drawString(10, 100, string, gfxModuleData.pPage10, video4, 300);
+ drawString(10, 100, string, gfxModuleData.pPage10, titleColor, 300);
gfxModuleData_flip();
@@ -337,8 +337,8 @@ int loadFileSub1(uint8 **ptr, const char *name, uint8 *ptr2) {
uint8 *unpackedBuffer;
for (i = 0; i < 64; i++) {
- if (mediumVar[i].ptr) {
- if (!strcmp(mediumVar[i].name, name)) {
+ if (preloadData[i].ptr) {
+ if (!strcmp(preloadData[i].name, name)) {
printf("Unsupported code in loadFIleSub1 !\n");
exit(1);
}
@@ -951,7 +951,7 @@ bool createDialog(int objOvl, int objIdx, int x, int y) {
int color;
if(objectState2==-2)
- color = colorOfSelectedSaveDrive;
+ color = subColor;
else
color = -1;
@@ -1078,11 +1078,8 @@ int processInventory(void) {
menuElementSubStruct *pMenuElementSub = getSelectedEntryInMenu(menuTable[1]);
if (pMenuElementSub) {
- //int var2;
- //int var4;
-
- var2 = pMenuElementSub->ovlIdx;
- var4 = pMenuElementSub->header;
+ int var2 = pMenuElementSub->ovlIdx;
+ int var4 = pMenuElementSub->header;
freeMenu(menuTable[1]);
menuTable[1] = NULL;
@@ -1743,7 +1740,7 @@ void mainLoop(void) {
strcpy(currentOverlay, "");
systemStrings.bootScriptName[0] = 0;
- initVar4[0] = 0;
+ cmdLine[0] = 0;
currentActiveMenu = -1;
autoMsg = -1;
linkedRelation = 0;
@@ -1755,9 +1752,6 @@ void mainLoop(void) {
initAllData();
- // debug code: automaticaly load savegame 0 at startup
-// loadSavegameData(0);
-
{
int playerDontAskQuit = 1;
int quitValue2 = 1;
@@ -1783,7 +1777,7 @@ void mainLoop(void) {
processAnimation();
- if (var0) {
+ if (remdo) {
// ASSERT(0);
/* main3 = 0;
* var24 = 0;
@@ -1792,17 +1786,17 @@ void mainLoop(void) {
* freeStuff2(); */
}
- if (initVar4[0]) {
+ if (cmdLine[0]) {
ASSERT(0);
-/* redrawStrings(0,&initVar4,8);
+/* redrawStrings(0,&cmdLine,8);
waitForPlayerInput();
- initVar4 = 0; */
+ cmdLine = 0; */
}
- if (affichePasMenuJoueur) {
- if (main5)
+ if (displayOn) {
+ if (doFade)
fadeVar = 0;
/*if (fadeVar)
@@ -1940,7 +1934,7 @@ int oldmain(int argc, char *argv[]) {
// video init stuff
- loadSystemFont();
+ initSystem();
// another bit of video init
diff --git a/engines/cruise/cruise_main.h b/engines/cruise/cruise_main.h
index 7e58bda57a..0eee835284 100644
--- a/engines/cruise/cruise_main.h
+++ b/engines/cruise/cruise_main.h
@@ -80,6 +80,10 @@ namespace Cruise {
extern gfxEntryStruct* linkedMsgList;
+extern int buttonDown;
+extern int selectDown;
+extern int menuDown;
+
bool delphineUnpack(byte *dst, const byte *src, int len);
int findHighColor();
ovlData3Struct *getOvlData3Entry(int32 scriptNumber, int32 param);
@@ -109,6 +113,11 @@ const char *getObjectName(int index, const char * string);
void mainLoop(void);
void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton, int16 *pMouseY);
bool testMask(int x, int y, unsigned char* pData, int stride);
+menuElementSubStruct *getSelectedEntryInMenu(menuStruct *pMenu);
+void closeAllMenu(void);
+int removeFinishedScripts(scriptInstanceStruct *ptrHandle);
+void initBigVar3(void);
+void resetActorPtr(actorStruct *ptr);
} // End of namespace Cruise
diff --git a/engines/cruise/decompiler.cpp b/engines/cruise/decompiler.cpp
index 09e70935ad..05c537daa6 100644
--- a/engines/cruise/decompiler.cpp
+++ b/engines/cruise/decompiler.cpp
@@ -750,7 +750,7 @@ int decompFunction(void) {
switch (currentScriptOpcodeType) {
case 0x1:
{
- pushDecomp("_setMain5()");
+ pushDecomp("_setdoFade()");
break;
}
case 0x2:
@@ -1344,7 +1344,7 @@ int decompFunction(void) {
}
case 0x74:
{
- sprintf(tempbuffer, "_getInitVar1()");
+ sprintf(tempbuffer, "_getlowMemory()");
pushDecomp(tempbuffer);
break;
}
diff --git a/engines/cruise/font.cpp b/engines/cruise/font.cpp
index 561d750509..38ef0e9f89 100644
--- a/engines/cruise/font.cpp
+++ b/engines/cruise/font.cpp
@@ -166,29 +166,31 @@ void loadFNT(const char *fileName) {
fontFileHandle.close();
}
-void loadSystemFont(void) {
+void initSystem(void) {
int32 i;
- video2 = 15;
- video4 = 9;
- video3 = 13;
- colorOfSelectedSaveDrive = 10;
+ itemColor = 15;
+ titleColor = 9;
+ selectColor = 13;
+ subColor = 10;
for (i = 0; i < 64; i++) {
- mediumVar[i].ptr = NULL;
- mediumVar[i].nofree = 0;
+ strcpy(preloadData[i].name, "");
+ preloadData[i].ptr = NULL;
+ preloadData[i].nofree = 0;
}
- initVar1 = 0;
- main5 = 0;
- var22 = 0;
- initVar2 = 0;
+ lowMemory = 0;
+
+ doFade = 0;
+ fadeFlag = 0;
+ scroll = 0;
switchPal = 0;
currentActiveBackgroundPlane = 0;
- //changeCursor();
+ changeCursor(CURSOR_NORMAL);
- initVar4[0] = 0;
+ strcpy(cmdLine, "");
loadFNT("system.fnt");
}
@@ -438,7 +440,7 @@ void drawString(int32 x, int32 y, uint8 *string, uint8 *buffer, uint8 color,
if (character) {
if (character == ' ' || character == 0x7D) {
- drawPosPixel_X += var1 + 5;
+ drawPosPixel_X += wordSpacingWidth + 5;
} else {
if (data) {
short int *si =
diff --git a/engines/cruise/font.h b/engines/cruise/font.h
index b6cb324ba3..26d73cb64a 100644
--- a/engines/cruise/font.h
+++ b/engines/cruise/font.h
@@ -29,7 +29,7 @@
namespace Cruise {
void loadFNT(const char *fileName);
-void loadSystemFont(void);
+void initSystem(void);
//////////////////////////////////////////////////
void flipShort(int16 * var);
diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp
index eb8d84760e..320b38afc8 100644
--- a/engines/cruise/function.cpp
+++ b/engines/cruise/function.cpp
@@ -205,7 +205,7 @@ int16 Op_PlayFX(void) { // TODO: implement
}
int16 Op_freeAllPerso(void) {
- freeAllPerso();
+ freeCTP();
return (0);
}
@@ -301,11 +301,8 @@ int16 Op_isFileLoaded(void) {
}
int16 Op_RemoveFrame(void) {
- //int var1;
- //int var2;
-
- var1 = popVar();
- var2 = popVar();
+ int var1 = popVar();
+ int var2 = popVar();
resetFileEntryRange(var2, var1);
@@ -394,11 +391,11 @@ int16 Op_ChangeSaveAllowedState(void) {
}
int16 Op_changeCutSceneState(void) {
- int oldValue = affichePasMenuJoueur;
+ int oldValue = displayOn;
int newValue = popVar();
if (newValue != -1) {
- affichePasMenuJoueur = newValue;
+ displayOn = newValue;
}
return oldValue;
@@ -532,8 +529,8 @@ int16 Op_InitializeState(void) {
return (0);
}
-int16 Op_GetInitVar1(void) {
- return initVar1;
+int16 Op_GetlowMemory(void) {
+ return lowMemory;
}
int16 Op_FadeOut(void) {
@@ -580,7 +577,7 @@ int16 Op_2C(void) {
}
int16 Op_FadeIn(void) {
- main5 = 1;
+ doFade = 1;
return 0;
}
@@ -829,10 +826,10 @@ int16 Op_removeBackground(void) {
return (0);
}
-int op6AVar;
+int vblLimit;
int16 Op_6A(void) {
- op6AVar = popVar();
+ vblLimit = popVar();
return 0;
}
@@ -1194,10 +1191,10 @@ int16 Op_regenerateBackgroundIncrust(void) {
int16 Op_SetStringColors(void) {
// TODO: here ignore if low color mode
- colorOfSelectedSaveDrive = (uint8) popVar();
- video2 = (uint8) popVar();
- video3 = (uint8) popVar();
- video4 = (uint8) popVar();
+ subColor = (uint8) popVar();
+ itemColor = (uint8) popVar();
+ selectColor = (uint8) popVar();
+ titleColor = (uint8) popVar();
return 0;
}
@@ -1205,11 +1202,11 @@ int16 Op_SetStringColors(void) {
int16 Op_1E(void) { // setup actor position
actorStruct *pActor;
- var0 = popVar();
+ int var0 = popVar();
int actorY = popVar();
int actorX = popVar();
- var1 = popVar();
- var2 = popVar();
+ int var1 = popVar();
+ int var2 = popVar();
int overlay = popVar();
if (!overlay) {
@@ -1285,8 +1282,8 @@ int16 Op_40(void) {
//freeStuff1();
freeStuff2();
- var24 = 0;
- var23 = 0;
+ playMusic2 = 0;
+ playMusic = 0;
return 0;
}
@@ -1295,8 +1292,8 @@ int16 Op_6C(void) {
//int var1;
int temp;
- var0 = popVar();
- var1 = popVar();
+ int var0 = popVar();
+ int var1 = popVar();
if (!var1) {
var1 = currentScriptPtr->overlayNumber;
@@ -1344,11 +1341,11 @@ int16 Op_60(void) {
* int var4;
*/
- var0 = popVar();
- var1 = popVar();
- var2 = popVar();
- var3 = popVar();
- var4 = popVar();
+ int var0 = popVar();
+ int var1 = popVar();
+ int var2 = popVar();
+ int var3 = popVar();
+ int var4 = popVar();
if (!var4) {
var4 = currentScriptPtr->overlayNumber;
@@ -1405,9 +1402,9 @@ int16 Op_6E(void) {
}
int16 Op_InitializeState2(void) {
- var0 = popVar();
+ int var0 = popVar();
char *ptr = (char *)popPtr();
- var1 = popVar();
+ int var1 = popVar();
if (!var1)
var1 = currentScriptPtr->overlayNumber;
@@ -1671,7 +1668,7 @@ void setupOpcodeTable(void) {
opcodeTablePtr[0x71] = Op_SetColorrawLine;
opcodeTablePtr[0x72] = Op_InitializeState2;
opcodeTablePtr[0x73] = Op_SetXDial;
- opcodeTablePtr[0x74] = Op_GetInitVar1;
+ opcodeTablePtr[0x74] = Op_GetlowMemory;
opcodeTablePtr[0x76] = Op_InitializeState6;
opcodeTablePtr[0x79] = Op_PlayFXnterPlayerMenu;
opcodeTablePtr[0x78] = Op_InitializeState8;
diff --git a/engines/cruise/function.h b/engines/cruise/function.h
index 13eb21ea1f..826f99abc8 100644
--- a/engines/cruise/function.h
+++ b/engines/cruise/function.h
@@ -29,10 +29,13 @@
namespace Cruise {
extern int flag_obstacle;
+extern int vblLimit;
void setupOpcodeTable(void);
int32 opcodeType8(void);
int16 computeZoom(int param);
int16 subOp23(int param1, int param2);
+void freeObjectList(cellStruct *pListHead);
+int removeAnimation(actorStruct * pHead, int overlay, int objIdx, int objType);
} // End of namespace Cruise
diff --git a/engines/cruise/mainDraw.cpp b/engines/cruise/mainDraw.cpp
index 3e4c6644af..4fa4f7bc2e 100644
--- a/engines/cruise/mainDraw.cpp
+++ b/engines/cruise/mainDraw.cpp
@@ -1263,7 +1263,7 @@ void drawMenu(menuStruct *pMenu) {
int wx = x + (nbcol - 1) * (160/2);
if (wx <= 320 - 160) {
- drawMessage(pMenu->gfx, wx, y - hline, 160, video4, gfxModuleData.pPage10);
+ drawMessage(pMenu->gfx, wx, y - hline, 160, titleColor, gfxModuleData.pPage10);
}
wx = x;
@@ -1281,12 +1281,12 @@ void drawMenu(menuStruct *pMenu) {
int color;
if (p1->varC) {
- color = video3;
+ color = selectColor;
} else {
if (p1->color != 255) {
color = p1->color;
} else {
- color = video2;
+ color = itemColor;
}
}
@@ -1494,7 +1494,7 @@ void mainDraw(int16 param) {
//----------------------------------------------------------------------------------------------------------------//
freeAutoCell();
- var20 = 0;
+ isMessage = 0;
//-------------------------------------------------- DRAW OBJECTS TYPE 5 (MSG)-----------------------------------------//
@@ -1503,7 +1503,7 @@ void mainDraw(int16 param) {
while (currentObjPtr) {
if (currentObjPtr->type == OBJ_TYPE_MSG && currentObjPtr->freeze == 0) {
drawMessage(currentObjPtr->gfxPtr, currentObjPtr->x, currentObjPtr->field_C, currentObjPtr->spriteIdx, currentObjPtr->color, gfxModuleData.pPage10);
- var20 = 1;
+ isMessage = 1;
}
currentObjPtr = currentObjPtr->next;
}
diff --git a/engines/cruise/menu.cpp b/engines/cruise/menu.cpp
index 324c17d023..f95fa20d89 100644
--- a/engines/cruise/menu.cpp
+++ b/engines/cruise/menu.cpp
@@ -125,23 +125,16 @@ void updateMenuMouse(int mouseX, int mouseY, menuStruct *pMenu) {
if (pMenu->gfx) {
int height = pMenu->gfx->height; // rustine
int var_2 = 0;
- menuElementStruct *pCurrentEntry =
- pMenu->ptrNextElement;
+ menuElementStruct *pCurrentEntry = pMenu->ptrNextElement;
while (pCurrentEntry) {
pCurrentEntry->varC = 0;
if (var_2 == 0) {
- if ((mouseX > pCurrentEntry->x)
- && ((pCurrentEntry->x + 160) >=
- mouseX)) {
- if ((mouseY > pCurrentEntry->y)
- && ((pCurrentEntry->y +
- height) >=
- mouseY)) {
+ if ((mouseX > pCurrentEntry->x) && ((pCurrentEntry->x + 160) >= mouseX)) {
+ if ((mouseY > pCurrentEntry->y) && ((pCurrentEntry->y + height) >= mouseY)) {
var_2 = 1;
- pCurrentEntry->varC =
- 1;
+ pCurrentEntry->varC = 1;
}
}
}
@@ -194,18 +187,29 @@ int processMenu(menuStruct *pMenu) {
mainDraw(1);
flipScreen();
- return 0;
+ if( mouseButton & 1) {
+ menuElementSubStruct* pSelectedEntry = getSelectedEntryInMenu(pMenu);
+
+ if(pSelectedEntry) {
+ return pSelectedEntry->header;
+ }
+ else {
+ return -1;
+ }
+ }
+
+ return -1;
}
int playerMenu(int menuX, int menuY) {
int retourMenu;
//int restartGame = 0;
- if (entrerMenuJoueur && affichePasMenuJoueur) {
- if (var0) {
+ if (entrerMenuJoueur && displayOn) {
+ if (remdo) {
systemStrings.param = 0;
- var24 = 0;
- var23 = 0;
+ playMusic2 = 0;
+ playMusic = 0;
freeStuff2();
}
/*
@@ -236,20 +240,35 @@ int playerMenu(int menuX, int menuY) {
menuTable[0] = createMenu(menuX, menuY, "Menu Joueur");
ASSERT(menuTable[0]);
- addSelectableMenuEntry(0, 3, menuTable[0], 1, -1,
- "Lecteur de Sauvegarde");
+ //addSelectableMenuEntry(0, 3, menuTable[0], 1, -1, "Lecteur de Sauvegarde");
if (userEnabled) {
- addSelectableMenuEntry(0, 4, menuTable[0], 1, -1,
- "Sauvegarde");
+ addSelectableMenuEntry(0, 4, menuTable[0], 1, -1, "Sauvegarde");
}
- addSelectableMenuEntry(0, 5, menuTable[0], 1, -1,
- "Chargement");
- addSelectableMenuEntry(0, 6, menuTable[0], 1, -1,
- "Recommencer le jeu");
- addSelectableMenuEntry(0, 7, menuTable[0], 1, -1,
- "Chargement");
+ addSelectableMenuEntry(0, 5, menuTable[0], 1, -1, "Chargement");
+ addSelectableMenuEntry(0, 6, menuTable[0], 1, -1, "Recommencer le jeu");
+ addSelectableMenuEntry(0, 7, menuTable[0], 1, -1, "Quitter");
retourMenu = processMenu(menuTable[0]);
+
+ freeMenu(menuTable[0]);
+ menuTable[0] = NULL;
+
+ switch(retourMenu)
+ {
+ case 3: // select save drive
+ break;
+ case 4: // save
+ saveSavegameData(0);
+ break;
+ case 5: // load
+ loadSavegameData(0);
+ break;
+ case 6: // restart
+ break;
+ case 7: // exit
+ exit(0);
+ break;
+ }
}
return 0;
diff --git a/engines/cruise/perso.cpp b/engines/cruise/perso.cpp
index e0cd85f2fe..cd7da978f4 100644
--- a/engines/cruise/perso.cpp
+++ b/engines/cruise/perso.cpp
@@ -39,10 +39,9 @@ void freePerso(int persoIdx) {
}
}
-void freeAllPerso(void) {
- int i;
+void freeCTP(void) {
- for (i = 0; i < NUM_PERSONS; i++) {
+ for (unsigned long int i = 0; i < NUM_PERSONS; i++) {
freePerso(i);
}
diff --git a/engines/cruise/perso.h b/engines/cruise/perso.h
index d77697378b..4f336a1849 100644
--- a/engines/cruise/perso.h
+++ b/engines/cruise/perso.h
@@ -49,7 +49,7 @@ extern persoStruct *persoTable[NUM_PERSONS];
extern int16 computedVar14;
void freePerso(int persoIdx);
-void freeAllPerso(void);
+void freeCTP(void);
void affiche_chemin(int16 persoIdx, int16 * returnVar);
int direction(int x1, int y1, int x2, int y2, int inc_jo1, int inc_jo2);
diff --git a/engines/cruise/saveload.cpp b/engines/cruise/saveload.cpp
index 310545e02f..9160fb1024 100644
--- a/engines/cruise/saveload.cpp
+++ b/engines/cruise/saveload.cpp
@@ -36,6 +36,154 @@ struct overlayRestoreTemporary {
overlayRestoreTemporary ovlRestoreData[90];
+void resetPreload()
+{
+ for(unsigned long int i=0; i<64; i++)
+ {
+ if(strlen(preloadData[i].name))
+ {
+ if(preloadData[i].ptr)
+ {
+ free(preloadData[i].ptr);
+ preloadData[i].ptr = NULL;
+ }
+ strcpy(preloadData[i].name, "");
+ preloadData[i].nofree = 0;
+ }
+ }
+}
+
+void unloadOverlay(const char*name, int overlayNumber)
+{
+ releaseOverlay(name);
+
+ strcpy(overlayTable[overlayNumber].overlayName, "");
+ overlayTable[overlayNumber].ovlData = NULL;
+ overlayTable[overlayNumber].alreadyLoaded = 0;
+}
+
+void initVars(void)
+{
+ closeAllMenu();
+ resetFileEntryRange( 0, 257 );
+
+ resetPreload();
+ freeCTP();
+
+ freezeCell(&cellHead, -1, -1, -1, -1, -1, 0);
+ // TODO: unfreeze anims
+
+ freeObjectList(&cellHead);
+ removeAnimation(&actorHead, -1, -1, -1);
+
+ changeScriptParamInList(-1, -1, &procHead, -1, 0);
+ removeFinishedScripts(&procHead);
+
+ changeScriptParamInList(-1, -1, &relHead, -1, 0);
+ removeFinishedScripts(&relHead);
+
+ for(unsigned long int i=0; i<90; i++)
+ {
+ if(strlen(overlayTable[i].overlayName) && overlayTable[i].alreadyLoaded)
+ {
+ unloadOverlay(overlayTable[i].overlayName, i);
+ }
+ }
+
+ // TODO:
+ // stopSound();
+ // removeSound();
+
+ closeBase();
+ closeCnf();
+
+ initOverlayTable();
+
+ stateID = 0;
+ currentActiveBackgroundPlane = 0;
+
+ freeDisk();
+
+ initVar5[0] = -1;
+ initVar5[3] = -1;
+ initVar5[6] = -1;
+ initVar5[9] = -1;
+
+ for (unsigned long int i = 0; i < 8; i++) {
+ menuTable[i] = NULL;
+ }
+
+ for (unsigned long int i = 0; i < 2000; i++) {
+ globalVars[i] = 0;
+ }
+
+ for (unsigned long int i = 0; i < 8; i++) {
+ backgroundTable[i].name[0] = 0;
+ }
+
+ for (unsigned long int i = 0; i < 257; i++) {
+ filesDatabase[i].subData.ptr = NULL;
+ filesDatabase[i].subData.ptrMask = NULL;
+ }
+
+ initBigVar3();
+
+ resetPtr2(&procHead);
+ resetPtr2(&relHead);
+
+ resetPtr(&cellHead);
+
+ resetActorPtr(&actorHead);
+ resetBackgroundIncrustList(&backgroundIncrustHead);
+
+ vblLimit = 0;
+ remdo = 0;
+ songLoaded = 0;
+ songPlayed = 0;
+ songLoop = 1;
+ activeMouse = 0;
+ userEnabled = 1;
+ dialogueEnabled = 0;
+ dialogueOvl = 0;
+ dialogueObj = 0;
+ userDelay = 0;
+ sysKey = -1;
+ sysX = 0;
+ sysY = 0;
+ automoveInc = 0;
+ automoveMax = 0;
+ displayOn = true;
+
+ // here used to init clip
+
+ isMessage = 0;
+ fadeFlag = 0;
+ playMusic = 0;
+ playMusic2 = 0;
+ automaticMode = 0;
+
+ // video param (vga and mcga mode)
+
+ titleColor = 2;
+ itemColor = 1;
+ selectColor = 3;
+ subColor = 5;
+
+ //
+
+ narratorOvl = 0;
+ narratorIdx = 0;
+ aniX = 0;
+ aniY = 0;
+ animationStart = false;
+ selectDown = 0;
+ menuDown = 0;
+ buttonDown = 0;
+ var41 = 0;
+ entrerMenuJoueur = 0;
+ fadeVar = 0;
+}
+
void loadSavegameDataSub1(Common::File& currentSaveFile) {
int i;
@@ -156,7 +304,7 @@ void loadSavegameActor(Common::File& currentSaveFile) {
}
void loadSavegameDataSub5(Common::File& currentSaveFile) {
- if (var1) {
+ if (songLoaded) {
saveVar1 = currentSaveFile.readByte();
if (saveVar1) {
@@ -196,10 +344,14 @@ void loadSavegameDataSub6(Common::File& currentSaveFile) {
}
}
+int saveSavegameData(int saveGameIdx) {
+ return 0;
+}
+
int loadSavegameData(int saveGameIdx) {
char buffer[256];
char saveIdentBuffer[6];
- int initVar1Save;
+ int lowMemorySave;
cellStruct *currentcellHead;
sprintf(buffer, "CR.%d", saveGameIdx);
@@ -221,12 +373,12 @@ int loadSavegameData(int saveGameIdx) {
currentSaveFile.close();
return (-1);
}
- //initVars();
+ initVars();
- var1 = currentSaveFile.readSint16LE();
- var2 = currentSaveFile.readSint16LE();
- var3 = currentSaveFile.readSint16LE();
- var4 = currentSaveFile.readSint16LE();
+ songLoaded = currentSaveFile.readSint16LE();
+ songPlayed = currentSaveFile.readSint16LE();
+ songLoop = currentSaveFile.readSint16LE();
+ activeMouse = currentSaveFile.readSint16LE();
userEnabled = currentSaveFile.readSint16LE();
dialogueEnabled = currentSaveFile.readSint16LE();
@@ -236,21 +388,21 @@ int loadSavegameData(int saveGameIdx) {
sysKey = currentSaveFile.readSint16LE();
sysX = currentSaveFile.readSint16LE();
sysY = currentSaveFile.readSint16LE();
- var13 = currentSaveFile.readSint16LE();
- var14 = currentSaveFile.readSint16LE();
- affichePasMenuJoueur = currentSaveFile.readSint16LE();
- var20 = currentSaveFile.readSint16LE();
- var22 = currentSaveFile.readSint16LE();
- var23 = currentSaveFile.readSint16LE();
- var24 = currentSaveFile.readSint16LE();
+ automoveInc = currentSaveFile.readSint16LE();
+ automoveMax = currentSaveFile.readSint16LE();
+ displayOn = currentSaveFile.readSint16LE();
+ isMessage = currentSaveFile.readSint16LE();
+ fadeFlag = currentSaveFile.readSint16LE();
+ playMusic = currentSaveFile.readSint16LE();
+ playMusic2 = currentSaveFile.readSint16LE();
automaticMode = currentSaveFile.readSint16LE();
// video param (not loaded in EGA mode)
- video4 = currentSaveFile.readSint16LE();
- video2 = currentSaveFile.readSint16LE();
- video3 = currentSaveFile.readSint16LE();
- colorOfSelectedSaveDrive = currentSaveFile.readSint16LE();
+ titleColor = currentSaveFile.readSint16LE();
+ itemColor = currentSaveFile.readSint16LE();
+ selectColor = currentSaveFile.readSint16LE();
+ subColor = currentSaveFile.readSint16LE();
//
@@ -266,9 +418,9 @@ int loadSavegameData(int saveGameIdx) {
currentActiveBackgroundPlane = currentSaveFile.readSint16LE();
switchPal = currentSaveFile.readSint16LE();
- initVar2 = currentSaveFile.readSint16LE();
- var22 = currentSaveFile.readSint16LE();
- main5 = currentSaveFile.readSint16LE();
+ scroll = currentSaveFile.readSint16LE();
+ fadeFlag = currentSaveFile.readSint16LE();
+ doFade = currentSaveFile.readSint16LE();
numOfLoadedOverlay = currentSaveFile.readSint16LE();
stateID = currentSaveFile.readSint16LE();
fontFileIndex = currentSaveFile.readSint16LE();
@@ -338,14 +490,14 @@ int loadSavegameData(int saveGameIdx) {
for(int i=0; i<64; i++)
{
- currentSaveFile.read(mediumVar[i].name, 15);
+ currentSaveFile.read(preloadData[i].name, 15);
currentSaveFile.skip(1);
- mediumVar[i].size = currentSaveFile.readSint32LE();
- mediumVar[i].sourceSize = currentSaveFile.readSint32LE();
+ preloadData[i].size = currentSaveFile.readSint32LE();
+ preloadData[i].sourceSize = currentSaveFile.readSint32LE();
currentSaveFile.skip(4);
- mediumVar[i].nofree = currentSaveFile.readSint16LE();
- mediumVar[i].protect = currentSaveFile.readSint16LE();
- mediumVar[i].ovl = currentSaveFile.readSint16LE();
+ preloadData[i].nofree = currentSaveFile.readSint16LE();
+ preloadData[i].protect = currentSaveFile.readSint16LE();
+ preloadData[i].ovl = currentSaveFile.readSint16LE();
}
loadSavegameDataSub1(currentSaveFile);
@@ -361,7 +513,7 @@ int loadSavegameData(int saveGameIdx) {
currentSaveFile.close();
for (int j = 0; j < 64; j++) {
- mediumVar[j].ptr = NULL;
+ preloadData[j].ptr = NULL;
}
for (int j = 1; j < numOfLoadedOverlay; j++) {
@@ -402,7 +554,7 @@ int loadSavegameData(int saveGameIdx) {
lastAni[0] = 0;
- initVar1Save = initVar1;
+ lowMemorySave = lowMemory;
for (int i = 0; i < 257; i++) {
if (filesDatabase[i].subData.ptr) {
@@ -413,7 +565,7 @@ int loadSavegameData(int saveGameIdx) {
for (k = i; k < j; k++) {
if (filesDatabase[k].subData.ptrMask)
- initVar1 = 0;
+ lowMemory = 0;
filesDatabase[k].subData.ptr = NULL;
filesDatabase[k].subData.ptrMask = NULL;
@@ -428,7 +580,7 @@ int loadSavegameData(int saveGameIdx) {
i = j - 1;
}
- initVar1 = initVar1Save;
+ lowMemory = lowMemorySave;
}
}
diff --git a/engines/cruise/saveload.h b/engines/cruise/saveload.h
index 5a719066c5..276100bdb2 100644
--- a/engines/cruise/saveload.h
+++ b/engines/cruise/saveload.h
@@ -28,6 +28,7 @@
namespace Cruise {
+int saveSavegameData(int saveGameIdx);
int loadSavegameData(int saveGameIdx);
} // End of namespace Cruise
diff --git a/engines/cruise/script.cpp b/engines/cruise/script.cpp
index a187b5daba..20411165bc 100644
--- a/engines/cruise/script.cpp
+++ b/engines/cruise/script.cpp
@@ -361,8 +361,8 @@ int32 opcodeType11(void) { // break
int32 opcodeType4(void) { // test
int boolVar = 0;
- var1 = popVar();
- var2 = popVar();
+ int var1 = popVar();
+ int var2 = popVar();
switch (currentScriptOpcodeType) {
case 0:
@@ -431,8 +431,8 @@ int32 opcodeType6(void) {
}
int32 opcodeType7(void) {
- var1 = popVar();
- var2 = popVar();
+ int var1 = popVar();
+ int var2 = popVar();
pushVar(var1);
pushVar(var2);
diff --git a/engines/cruise/various.cpp b/engines/cruise/various.cpp
index e38d17e601..cf52fdb4ec 100644
--- a/engines/cruise/various.cpp
+++ b/engines/cruise/various.cpp
@@ -27,7 +27,7 @@
namespace Cruise {
-uint16 var0 = 0;
+uint16 remdo = 0;
uint16 fadeVar;
int16 readB16(void *ptr) {
diff --git a/engines/cruise/various.h b/engines/cruise/various.h
index 47f0d0c69e..99b16f8c66 100644
--- a/engines/cruise/various.h
+++ b/engines/cruise/various.h
@@ -30,7 +30,7 @@
namespace Cruise {
-extern uint16 var0;
+extern uint16 remdo;
extern uint16 fadeVar;
int16 readB16(void *ptr);
diff --git a/engines/cruise/vars.cpp b/engines/cruise/vars.cpp
index 34a67d34b8..a60b60a9fd 100644
--- a/engines/cruise/vars.cpp
+++ b/engines/cruise/vars.cpp
@@ -29,21 +29,21 @@ namespace Cruise {
uint8 *_systemFNT;
-uint8 video2 = 1;
-uint8 video3 = 3;
-uint8 video4 = 2;
-uint8 colorOfSelectedSaveDrive = 5;
+uint8 itemColor = 1;
+uint8 selectColor = 3;
+uint8 titleColor = 2;
+uint8 subColor = 5;
-int16 initVar1;
-int16 initVar2;
+int16 lowMemory;
+int16 scroll;
int16 switchPal;
-uint8 initVar4[90];
+char cmdLine[90];
int16 currentActiveBackgroundPlane;
-int16 main5;
-int16 var22 = 0;
+int16 doFade;
+int16 fadeFlag = 0;
-mediumVarStruct mediumVar[64];
+preloadStruct preloadData[64];
volumeDataStruct volumeData[20];
@@ -75,7 +75,7 @@ uint32 volumeFileDescriptorSize;
int16 volumeSizeOfEntry;
int16 volumeNumberOfEntry;
-int16 affichePasMenuJoueur = 1;
+int16 displayOn = 1;
int16 globalVars[2000];
@@ -104,10 +104,10 @@ int16 saveOpcodeVar;
int16 narratorOvl = 0;
int16 narratorIdx = 0;
-int16 var1;
-int16 var2;
-int16 var3;
-int16 var4;
+int16 songLoaded;
+int16 songPlayed;
+int16 songLoop;
+int16 activeMouse;
int16 userEnabled;
int16 var5;
int16 dialogueEnabled;
@@ -119,11 +119,11 @@ int16 sysKey = -1;
int16 sysX = 0;
int16 sysY = 0;
-int16 var13;
-int16 var14;
-int16 var20;
-int16 var23;
-int16 var24;
+int16 automoveInc;
+int16 automoveMax;
+int16 isMessage;
+int16 playMusic;
+int16 playMusic2;
int16 automaticMode;
int16 aniX;
int16 aniY;
diff --git a/engines/cruise/vars.h b/engines/cruise/vars.h
index 6bebf75101..8ca13902e0 100644
--- a/engines/cruise/vars.h
+++ b/engines/cruise/vars.h
@@ -54,21 +54,21 @@ typedef int16(*opcodeFunction) (void);
extern uint8 *_systemFNT;
extern int16 fontFileIndex;
-extern uint8 video2;
-extern uint8 video3;
-extern uint8 video4;
-extern uint8 colorOfSelectedSaveDrive;
+extern uint8 itemColor;
+extern uint8 selectColor;
+extern uint8 titleColor;
+extern uint8 subColor;
-extern int16 initVar1;
-extern int16 initVar2;
+extern int16 lowMemory;
+extern int16 scroll;
extern int16 switchPal;
-extern uint8 initVar4[90];
+extern char cmdLine[90];
extern int16 currentActiveBackgroundPlane;
-extern int16 main5;
-extern int16 var22;
+extern int16 doFade;
+extern int16 fadeFlag;
-struct mediumVarStruct {
+struct preloadStruct {
char name[15];
int32 size;
int32 sourceSize;
@@ -137,7 +137,7 @@ struct systemStringsStruct {
char bootScriptName[8];
};
-extern mediumVarStruct mediumVar[64];
+extern preloadStruct preloadData[64];
extern volumeDataStruct volumeData[20];
@@ -170,7 +170,7 @@ extern uint32 volumeFileDescriptorSize;
extern int16 volumeSizeOfEntry;
extern int16 volumeNumberOfEntry;
-extern int16 affichePasMenuJoueur;
+extern int16 displayOn;
extern int16 globalVars[2000];
extern dataFileEntry filesDatabase[257];
@@ -197,10 +197,10 @@ extern int16 saveOpcodeVar;
extern int16 narratorOvl;
extern int16 narratorIdx;
-extern int16 var1;
-extern int16 var2;
-extern int16 var3;
-extern int16 var4;
+extern int16 songLoaded;
+extern int16 songPlayed;
+extern int16 songLoop;
+extern int16 activeMouse;
extern int16 userEnabled;
extern int16 var5;
extern int16 dialogueEnabled;
@@ -210,11 +210,11 @@ extern int16 userDelay;
extern int16 sysKey;
extern int16 sysX;
extern int16 sysY;
-extern int16 var13;
-extern int16 var14;
-extern int16 var20;
-extern int16 var23;
-extern int16 var24;
+extern int16 automoveInc;
+extern int16 automoveMax;
+extern int16 isMessage;
+extern int16 playMusic;
+extern int16 playMusic2;
extern int16 automaticMode;
extern int16 aniX;
extern int16 aniY;
diff --git a/engines/cruise/volume.cpp b/engines/cruise/volume.cpp
index 01f39878ad..324aac303d 100644
--- a/engines/cruise/volume.cpp
+++ b/engines/cruise/volume.cpp
@@ -33,6 +33,8 @@ uint8 *PAL_ptr = NULL;
int16 numLoadedPal;
int16 fileData2;
+char currentBaseName[15] = "";
+
void loadPal(volumeDataStruct *entry) {
char name[20];
@@ -56,6 +58,38 @@ void loadPal(volumeDataStruct *entry) {
PAL_ptr = (uint8 *) malloc(numLoadedPal * fileData2);
}
+void closePal(void)
+{
+ if(PAL_fileHandle)
+ {
+ fclose(PAL_fileHandle);
+
+ free(PAL_ptr);
+ PAL_ptr = NULL;
+
+ numLoadedPal = 0;
+ fileData2 = 0;
+ }
+}
+
+int closeBase(void)
+{
+ if(currentVolumeFile.isOpen())
+ {
+ currentVolumeFile.close();
+
+ free(volumePtrToFileDescriptor);
+
+ strcpy(currentBaseName, "");
+ }
+
+ if(PAL_fileHandle) {
+ closePal();
+ }
+
+ return 0;
+}
+
int getVolumeDataEntry(volumeDataStruct *entry) {
char buffer[256];
int i;
@@ -89,8 +123,7 @@ int getVolumeDataEntry(volumeDataStruct *entry) {
assert(volumeSizeOfEntry == 14 + 4 + 4 + 4 + 4);
- volumePtrToFileDescriptor =
- (fileEntry *) mallocAndZero(sizeof(fileEntry) * volumeNumEntry);
+ volumePtrToFileDescriptor = (fileEntry *) mallocAndZero(sizeof(fileEntry) * volumeNumEntry);
for (i = 0; i < volumeNumEntry; i++) {
volumePtrToFileDescriptor[i].name[0] = 0;
@@ -102,11 +135,9 @@ int getVolumeDataEntry(volumeDataStruct *entry) {
for (i = 0; i < volumeNumEntry; i++) {
currentVolumeFile.read(&volumePtrToFileDescriptor[i].name, 14);
- currentVolumeFile.read(&volumePtrToFileDescriptor[i].offset,
- 4);
+ currentVolumeFile.read(&volumePtrToFileDescriptor[i].offset, 4);
currentVolumeFile.read(&volumePtrToFileDescriptor[i].size, 4);
- currentVolumeFile.read(&volumePtrToFileDescriptor[i].extSize,
- 4);
+ currentVolumeFile.read(&volumePtrToFileDescriptor[i].extSize, 4);
currentVolumeFile.read(&volumePtrToFileDescriptor[i].unk3, 4);
}
@@ -116,6 +147,8 @@ int getVolumeDataEntry(volumeDataStruct *entry) {
flipLong(&volumePtrToFileDescriptor[i].extSize);
}
+ strcpy(currentBaseName, entry->ident);
+
loadPal(entry);
return 0;
@@ -309,6 +342,19 @@ int16 findFileInDisks(char *fileName) {
}
}
+int closeCnf(void) {
+ for(long int i=0; i<numOfDisks; i++) {
+ if(volumeData[i].ptr) {
+ free(volumeData[i].ptr);
+ volumeData[i].ptr = NULL;
+ }
+ }
+
+ volumeDataLoaded = 0;
+
+ return 0;
+}
+
int16 readVolCnf(void) {
int i;
Common::File fileHandle;
diff --git a/engines/cruise/volume.h b/engines/cruise/volume.h
index 24b58a76e3..d42ecd57cc 100644
--- a/engines/cruise/volume.h
+++ b/engines/cruise/volume.h
@@ -29,6 +29,7 @@
namespace Cruise {
int16 readVolCnf(void);
+int closeCnf(void);
int16 findFileInDisks(char * fileName);
void freeDisk(void);
int16 findFileInList(const char * fileName);
@@ -40,6 +41,8 @@ void drawMsgString(const char * string);
void askDisk(int16 discNumber);
void setObjectPosition(int16 param1, int16 param2, int16 param3, int16 param4);
+int closeBase(void);
+
} // End of namespace Cruise
#endif