[Scummvm-cvs-logs] SF.net SVN: scummvm: [29901] scummvm/trunk/engines/cruise

yazoo at users.sourceforge.net yazoo at users.sourceforge.net
Tue Dec 18 21:12:42 CET 2007


Revision: 29901
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29901&view=rev
Author:   yazoo
Date:     2007-12-18 12:12:42 -0800 (Tue, 18 Dec 2007)

Log Message:
-----------
Fix loading savegame from original interpreter

Modified Paths:
--------------
    scummvm/trunk/engines/cruise/background.cpp
    scummvm/trunk/engines/cruise/cruise.cpp
    scummvm/trunk/engines/cruise/cruise_main.cpp
    scummvm/trunk/engines/cruise/cruise_main.h
    scummvm/trunk/engines/cruise/decompiler.cpp
    scummvm/trunk/engines/cruise/font.cpp
    scummvm/trunk/engines/cruise/font.h
    scummvm/trunk/engines/cruise/function.cpp
    scummvm/trunk/engines/cruise/function.h
    scummvm/trunk/engines/cruise/mainDraw.cpp
    scummvm/trunk/engines/cruise/menu.cpp
    scummvm/trunk/engines/cruise/perso.cpp
    scummvm/trunk/engines/cruise/perso.h
    scummvm/trunk/engines/cruise/saveload.cpp
    scummvm/trunk/engines/cruise/saveload.h
    scummvm/trunk/engines/cruise/script.cpp
    scummvm/trunk/engines/cruise/various.cpp
    scummvm/trunk/engines/cruise/various.h
    scummvm/trunk/engines/cruise/vars.cpp
    scummvm/trunk/engines/cruise/vars.h
    scummvm/trunk/engines/cruise/volume.cpp
    scummvm/trunk/engines/cruise/volume.h

Modified: scummvm/trunk/engines/cruise/background.cpp
===================================================================
--- scummvm/trunk/engines/cruise/background.cpp	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/background.cpp	2007-12-18 20:12:42 UTC (rev 29901)
@@ -46,10 +46,10 @@
 	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;
 

Modified: scummvm/trunk/engines/cruise/cruise.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cruise.cpp	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/cruise.cpp	2007-12-18 20:12:42 UTC (rev 29901)
@@ -108,7 +108,7 @@
 
 	// video init stuff
 
-	loadSystemFont();
+	initSystem();
 
 	// another bit of video init
 

Modified: scummvm/trunk/engines/cruise/cruise_main.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cruise_main.cpp	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/cruise_main.cpp	2007-12-18 20:12:42 UTC (rev 29901)
@@ -63,7 +63,7 @@
 	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 @@
 	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 @@
 									int color;
 
 									if(objectState2==-2)
-										color = colorOfSelectedSaveDrive;
+										color = subColor;
 									else
 										color = -1;
 
@@ -1078,12 +1078,9 @@
 		menuElementSubStruct *pMenuElementSub = getSelectedEntryInMenu(menuTable[1]);
 
 		if (pMenuElementSub) {
-			//int var2;
-			//int var4;
+			int var2 = pMenuElementSub->ovlIdx;
+			int var4 = pMenuElementSub->header;
 
-			var2 = pMenuElementSub->ovlIdx;
-			var4 = pMenuElementSub->header;
-
 			freeMenu(menuTable[1]);
 			menuTable[1] = NULL;
 
@@ -1743,7 +1740,7 @@
 
 	strcpy(currentOverlay, "");
 	systemStrings.bootScriptName[0] = 0;
-	initVar4[0] = 0;
+	cmdLine[0] = 0;
 	currentActiveMenu = -1;
 	autoMsg = -1;
 	linkedRelation = 0;
@@ -1755,9 +1752,6 @@
 
 	initAllData();
 
-	// debug code: automaticaly load savegame 0 at startup
-//	loadSavegameData(0);
-
 	{
 		int playerDontAskQuit = 1;
 		int quitValue2 = 1;
@@ -1783,7 +1777,7 @@
 
 			processAnimation();
 
-			if (var0) {
+			if (remdo) {
 				// ASSERT(0);
 				/*    main3 = 0;
 				 * var24 = 0;
@@ -1792,17 +1786,17 @@
 				 * 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 @@
 
 	// video init stuff
 
-	loadSystemFont();
+	initSystem();
 
 	// another bit of video init
 

Modified: scummvm/trunk/engines/cruise/cruise_main.h
===================================================================
--- scummvm/trunk/engines/cruise/cruise_main.h	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/cruise_main.h	2007-12-18 20:12:42 UTC (rev 29901)
@@ -80,6 +80,10 @@
 
 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 @@
 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
 

Modified: scummvm/trunk/engines/cruise/decompiler.cpp
===================================================================
--- scummvm/trunk/engines/cruise/decompiler.cpp	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/decompiler.cpp	2007-12-18 20:12:42 UTC (rev 29901)
@@ -750,7 +750,7 @@
 	switch (currentScriptOpcodeType) {
 	case 0x1:
 		{
-			pushDecomp("_setMain5()");
+			pushDecomp("_setdoFade()");
 			break;
 		}
 	case 0x2:
@@ -1344,7 +1344,7 @@
 		}
 	case 0x74:
 		{
-			sprintf(tempbuffer, "_getInitVar1()");
+			sprintf(tempbuffer, "_getlowMemory()");
 			pushDecomp(tempbuffer);
 			break;
 		}

Modified: scummvm/trunk/engines/cruise/font.cpp
===================================================================
--- scummvm/trunk/engines/cruise/font.cpp	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/font.cpp	2007-12-18 20:12:42 UTC (rev 29901)
@@ -166,29 +166,31 @@
 	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 @@
 
 			if (character) {
 				if (character == ' ' || character == 0x7D) {
-					drawPosPixel_X += var1 + 5;
+					drawPosPixel_X += wordSpacingWidth + 5;
 				} else {
 					if (data) {
 						short int *si =

Modified: scummvm/trunk/engines/cruise/font.h
===================================================================
--- scummvm/trunk/engines/cruise/font.h	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/font.h	2007-12-18 20:12:42 UTC (rev 29901)
@@ -29,7 +29,7 @@
 namespace Cruise {
 
 void loadFNT(const char *fileName);
-void loadSystemFont(void);
+void initSystem(void);
 
 //////////////////////////////////////////////////
 void flipShort(int16 * var);

Modified: scummvm/trunk/engines/cruise/function.cpp
===================================================================
--- scummvm/trunk/engines/cruise/function.cpp	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/function.cpp	2007-12-18 20:12:42 UTC (rev 29901)
@@ -205,7 +205,7 @@
 }
 
 int16 Op_freeAllPerso(void) {
-	freeAllPerso();
+	freeCTP();
 	return (0);
 }
 
@@ -301,12 +301,9 @@
 }
 
 int16 Op_RemoveFrame(void) {
-	//int var1;
-	//int var2;
+	int var1 = popVar();
+	int var2 = popVar();
 
-	var1 = popVar();
-	var2 = popVar();
-
 	resetFileEntryRange(var2, var1);
 
 	return (0);
@@ -394,11 +391,11 @@
 }
 
 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 @@
 	return (0);
 }
 
-int16 Op_GetInitVar1(void) {
-	return initVar1;
+int16 Op_GetlowMemory(void) {
+	return lowMemory;
 }
 
 int16 Op_FadeOut(void) {
@@ -580,7 +577,7 @@
 }
 
 int16 Op_FadeIn(void) {
-	main5 = 1;
+	doFade = 1;
 	return 0;
 }
 
@@ -829,10 +826,10 @@
 	return (0);
 }
 
-int op6AVar;
+int vblLimit;
 
 int16 Op_6A(void) {
-	op6AVar = popVar();
+	vblLimit = popVar();
 	return 0;
 }
 
@@ -1194,10 +1191,10 @@
 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_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 @@
 	//freeStuff1();
 	freeStuff2();
 
-	var24 = 0;
-	var23 = 0;
+	playMusic2 = 0;
+	playMusic = 0;
 	return 0;
 }
 
@@ -1295,8 +1292,8 @@
 	//int var1;
 	int temp;
 
-	var0 = popVar();
-	var1 = popVar();
+	int var0 = popVar();
+	int var1 = popVar();
 
 	if (!var1) {
 		var1 = currentScriptPtr->overlayNumber;
@@ -1344,11 +1341,11 @@
 	 * 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_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 @@
 	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;

Modified: scummvm/trunk/engines/cruise/function.h
===================================================================
--- scummvm/trunk/engines/cruise/function.h	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/function.h	2007-12-18 20:12:42 UTC (rev 29901)
@@ -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
 

Modified: scummvm/trunk/engines/cruise/mainDraw.cpp
===================================================================
--- scummvm/trunk/engines/cruise/mainDraw.cpp	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/mainDraw.cpp	2007-12-18 20:12:42 UTC (rev 29901)
@@ -1263,7 +1263,7 @@
 	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 @@
 		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 @@
 	//----------------------------------------------------------------------------------------------------------------//
 
 	freeAutoCell();
-	var20 = 0;
+	isMessage = 0;
 
 	//-------------------------------------------------- DRAW OBJECTS TYPE 5 (MSG)-----------------------------------------//
 
@@ -1503,7 +1503,7 @@
 	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;
 	}

Modified: scummvm/trunk/engines/cruise/menu.cpp
===================================================================
--- scummvm/trunk/engines/cruise/menu.cpp	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/menu.cpp	2007-12-18 20:12:42 UTC (rev 29901)
@@ -125,23 +125,16 @@
 		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 @@
 	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 @@
 		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;

Modified: scummvm/trunk/engines/cruise/perso.cpp
===================================================================
--- scummvm/trunk/engines/cruise/perso.cpp	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/perso.cpp	2007-12-18 20:12:42 UTC (rev 29901)
@@ -39,10 +39,9 @@
 	}
 }
 
-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);
 	}
 

Modified: scummvm/trunk/engines/cruise/perso.h
===================================================================
--- scummvm/trunk/engines/cruise/perso.h	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/perso.h	2007-12-18 20:12:42 UTC (rev 29901)
@@ -49,7 +49,7 @@
 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);
 

Modified: scummvm/trunk/engines/cruise/saveload.cpp
===================================================================
--- scummvm/trunk/engines/cruise/saveload.cpp	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/saveload.cpp	2007-12-18 20:12:42 UTC (rev 29901)
@@ -36,6 +36,154 @@
 
 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 loadSavegameDataSub5(Common::File& currentSaveFile) {
-	if (var1) {
+	if (songLoaded) {
 		saveVar1 = currentSaveFile.readByte();
 
 		if (saveVar1) {
@@ -196,10 +344,14 @@
 	}
 }
 
+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 @@
 		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 @@
 	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 @@
 
 	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 @@
 
 	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 @@
 	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 @@
 
 	lastAni[0] = 0;
 
-	initVar1Save = initVar1;
+	lowMemorySave = lowMemory;
 
 	for (int i = 0; i < 257; i++) {
 		if (filesDatabase[i].subData.ptr) {
@@ -413,7 +565,7 @@
 
 			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 @@
 				i = j - 1;
 			}
 
-			initVar1 = initVar1Save;
+			lowMemory = lowMemorySave;
 		}
 	}
 

Modified: scummvm/trunk/engines/cruise/saveload.h
===================================================================
--- scummvm/trunk/engines/cruise/saveload.h	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/saveload.h	2007-12-18 20:12:42 UTC (rev 29901)
@@ -28,6 +28,7 @@
 
 namespace Cruise {
 
+int saveSavegameData(int saveGameIdx);
 int loadSavegameData(int saveGameIdx);
 
 } // End of namespace Cruise

Modified: scummvm/trunk/engines/cruise/script.cpp
===================================================================
--- scummvm/trunk/engines/cruise/script.cpp	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/script.cpp	2007-12-18 20:12:42 UTC (rev 29901)
@@ -361,8 +361,8 @@
 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 opcodeType7(void) {
-	var1 = popVar();
-	var2 = popVar();
+	int var1 = popVar();
+	int var2 = popVar();
 
 	pushVar(var1);
 	pushVar(var2);

Modified: scummvm/trunk/engines/cruise/various.cpp
===================================================================
--- scummvm/trunk/engines/cruise/various.cpp	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/various.cpp	2007-12-18 20:12:42 UTC (rev 29901)
@@ -27,7 +27,7 @@
 
 namespace Cruise {
 
-uint16 var0 = 0;
+uint16 remdo = 0;
 uint16 fadeVar;
 
 int16 readB16(void *ptr) {

Modified: scummvm/trunk/engines/cruise/various.h
===================================================================
--- scummvm/trunk/engines/cruise/various.h	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/various.h	2007-12-18 20:12:42 UTC (rev 29901)
@@ -30,7 +30,7 @@
 
 namespace Cruise {
 
-extern uint16 var0;
+extern uint16 remdo;
 extern uint16 fadeVar;
 
 int16 readB16(void *ptr);

Modified: scummvm/trunk/engines/cruise/vars.cpp
===================================================================
--- scummvm/trunk/engines/cruise/vars.cpp	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/vars.cpp	2007-12-18 20:12:42 UTC (rev 29901)
@@ -29,21 +29,21 @@
 
 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 @@
 int16 volumeSizeOfEntry;
 int16 volumeNumberOfEntry;
 
-int16 affichePasMenuJoueur = 1;
+int16 displayOn = 1;
 
 int16 globalVars[2000];
 
@@ -104,10 +104,10 @@
 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 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;

Modified: scummvm/trunk/engines/cruise/vars.h
===================================================================
--- scummvm/trunk/engines/cruise/vars.h	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/vars.h	2007-12-18 20:12:42 UTC (rev 29901)
@@ -54,21 +54,21 @@
 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 @@
 	char bootScriptName[8];
 };
 
-extern mediumVarStruct mediumVar[64];
+extern preloadStruct preloadData[64];
 
 extern volumeDataStruct volumeData[20];
 
@@ -170,7 +170,7 @@
 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 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 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;

Modified: scummvm/trunk/engines/cruise/volume.cpp
===================================================================
--- scummvm/trunk/engines/cruise/volume.cpp	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/volume.cpp	2007-12-18 20:12:42 UTC (rev 29901)
@@ -33,6 +33,8 @@
 int16 numLoadedPal;
 int16 fileData2;
 
+char currentBaseName[15] = "";
+
 void loadPal(volumeDataStruct *entry) {
 	char name[20];
 
@@ -56,6 +58,38 @@
 	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 @@
 
 	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 @@
 
 	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 @@
 		flipLong(&volumePtrToFileDescriptor[i].extSize);
 	}
 
+	strcpy(currentBaseName, entry->ident);
+
 	loadPal(entry);
 
 	return 0;
@@ -309,6 +342,19 @@
 	}
 }
 
+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;

Modified: scummvm/trunk/engines/cruise/volume.h
===================================================================
--- scummvm/trunk/engines/cruise/volume.h	2007-12-18 08:05:19 UTC (rev 29900)
+++ scummvm/trunk/engines/cruise/volume.h	2007-12-18 20:12:42 UTC (rev 29901)
@@ -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 askDisk(int16 discNumber);
 void setObjectPosition(int16 param1, int16 param2, int16 param3, int16 param4);
 
+int closeBase(void);
+
 } // End of namespace Cruise
 
 #endif


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list