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

yazoo at users.sourceforge.net yazoo at users.sourceforge.net
Fri Apr 27 22:31:44 CEST 2007


Revision: 26624
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26624&view=rev
Author:   yazoo
Date:     2007-04-27 13:31:43 -0700 (Fri, 27 Apr 2007)

Log Message:
-----------
Cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/cruise/actor.cpp
    scummvm/trunk/engines/cruise/actor.h
    scummvm/trunk/engines/cruise/cruise_main.cpp
    scummvm/trunk/engines/cruise/cruise_main.h
    scummvm/trunk/engines/cruise/decompiler.cpp
    scummvm/trunk/engines/cruise/function.cpp
    scummvm/trunk/engines/cruise/function.h
    scummvm/trunk/engines/cruise/mainDraw.cpp
    scummvm/trunk/engines/cruise/mainDraw.h
    scummvm/trunk/engines/cruise/object.cpp
    scummvm/trunk/engines/cruise/object.h
    scummvm/trunk/engines/cruise/perso.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

Added Paths:
-----------
    scummvm/trunk/engines/cruise/cell.cpp
    scummvm/trunk/engines/cruise/cell.h
    scummvm/trunk/engines/cruise/saveload.cpp
    scummvm/trunk/engines/cruise/saveload.h

Removed Paths:
-------------
    scummvm/trunk/engines/cruise/loadSave.cpp
    scummvm/trunk/engines/cruise/loadSave.h

Modified: scummvm/trunk/engines/cruise/actor.cpp
===================================================================
--- scummvm/trunk/engines/cruise/actor.cpp	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/actor.cpp	2007-04-27 20:31:43 UTC (rev 26624)
@@ -32,15 +32,15 @@
 
   while(pCurrentEntry)
   {
-    if( (pCurrentEntry->overlayNumber == overlayIdx || overlayIdx == -1) &&
-        (pCurrentEntry->var4 == param1 || param1 == -1) &&
-        (pCurrentEntry->type == param2 || param2 == -1) &&
-        (pCurrentEntry->pathId != -2))
-    {
-      return 0;
-    }
-    
-    pCurrentEntry = pCurrentEntry->next;
+	if( (pCurrentEntry->overlayNumber == overlayIdx || overlayIdx == -1) &&
+		(pCurrentEntry->idx == param1 || param1 == -1) &&
+		(pCurrentEntry->type == param2 || param2 == -1) &&
+		(pCurrentEntry->pathId != -2))
+	{
+	  return 0;
+	}
+	
+	pCurrentEntry = pCurrentEntry->next;
   }
 
   return 1;
@@ -52,14 +52,14 @@
 
   while(pCurrentEntry)
   {
-    if( (pCurrentEntry->overlayNumber == overlayIdx || overlayIdx == -1) &&
-        (pCurrentEntry->var4 == param1 || param1 == -1) &&
-        (pCurrentEntry->type == param2 || param2 == -1) )
-    {
-      return pCurrentEntry;
-    }
-    
-    pCurrentEntry = pCurrentEntry->next;
+	if( (pCurrentEntry->overlayNumber == overlayIdx || overlayIdx == -1) &&
+		(pCurrentEntry->idx == param1 || param1 == -1) &&
+		(pCurrentEntry->type == param2 || param2 == -1) )
+	{
+	  return pCurrentEntry;
+	}
+	
+	pCurrentEntry = pCurrentEntry->next;
   }
 
   return NULL;
@@ -79,34 +79,34 @@
 
   while ( polygone->field_0 != (ctpVar19Struct*)-1)
   {
-    tableau = &polygone->subStruct;
+	tableau = &polygone->subStruct;
 
-    x_min = tableau->minX;
-    x_max = tableau->maxX;
-    y_min = tableau->minY;
-    y_max = tableau->maxY;
+	x_min = tableau->minX;
+	x_max = tableau->maxX;
+	y_min = tableau->minY;
+	y_max = tableau->maxY;
 
-    computedVar14 = tableau->boxIdx;	/* numero polygone	*/
+	computedVar14 = tableau->boxIdx;	/* numero polygone	*/
 
-    if ( walkboxChange[computedVar14]==0 && ((x>=x_min && x<=x_max) && (y>=y_min && y<=y_max)) )
-    {
-      // click was in given box
-    /*  u = y-y_min;
+	if ( walkboxChange[computedVar14]==0 && ((x>=x_min && x<=x_max) && (y>=y_min && y<=y_max)) )
+	{
+	  // click was in given box
+	/*  u = y-y_min;
 
-      //tableau+=u;
-      tableau = &polygone[u].subStruct;
+	  //tableau+=u;
+	  tableau = &polygone[u].subStruct;
 
-      x_min = tableau->minX;
-      x_max = tableau->maxX;
+	  x_min = tableau->minX;
+	  x_max = tableau->maxX;
 
-      if ( (x>=x_min && x<=x_max) ) */
-      {		
-        flag_obstacle=walkboxType[computedVar14];	/* sa couleur */
+	  if ( (x>=x_min && x<=x_max) ) */
+	  {		
+		flag_obstacle=walkboxType[computedVar14];	/* sa couleur */
 
-        return;
-      }
-    }
-    polygone = polygone->field_0;
+		return;
+	  }
+	}
+	polygone = polygone->field_0;
   }
 
   flag_obstacle=0;
@@ -153,31 +153,31 @@
 
   if(dx<0)
   {
-    dx = -dx;
-    mD0 = -1;
+	dx = -dx;
+	mD0 = -1;
   }
 
   if(dy<0)
   {
-    dy = -dy;
-    mD1 = -1;
+	dy = -dy;
+	mD1 = -1;
   }
 
   if(dx<dy)
   {
-    mA0 = 0;
-    bp = dx;
-    cx = dy;
+	mA0 = 0;
+	bp = dx;
+	cx = dy;
 
-    mA1 = mD1;
+	mA1 = mD1;
   }
   else
   {
-    mA1 = 0;
-    bp = dy;
-    cx = dx;
+	mA1 = 0;
+	bp = dy;
+	cx = dx;
 
-    mA0 = mD0;
+	mA0 = mD0;
   }
 
   bp=bp*2;
@@ -194,35 +194,35 @@
 
   if(flag_obstacle==0)
   {
-    flag_obstacle = 1;
-    return;
+	flag_obstacle = 1;
+	return;
   }
 
   while(--cx)
   {
-    if(dx>0)
-    {
-      ax+=mD0;
-      bx+=mD1;
-      dx+=si;
-    }
-    else
-    {
-      ax+=mA0;
-      bx+=mA1;
-      dx+=bp;
-    }
+	if(dx>0)
+	{
+	  ax+=mD0;
+	  bx+=mD1;
+	  dx+=si;
+	}
+	else
+	{
+	  ax+=mA0;
+	  bx+=mA1;
+	  dx+=bp;
+	}
 
-    getPixel(ax, bx);
+	getPixel(ax, bx);
 
-    X = ax;
-    Y = bx;
+	X = ax;
+	Y = bx;
 
-    if(flag_obstacle==0)
-    {
-      flag_obstacle = 1;
-      return;
-    }
+	if(flag_obstacle==0)
+	{
+	  flag_obstacle = 1;
+	  return;
+	}
   }
 
   flag_obstacle = 0;
@@ -256,31 +256,31 @@
 
   if(dx<0)
   {
-    dx = -dx;
-    mD0 = -1;
+	dx = -dx;
+	mD0 = -1;
   }
 
   if(dy<0)
   {
-    dy = -dy;
-    mD1 = -1;
+	dy = -dy;
+	mD1 = -1;
   }
 
   if(dx<dy)
   {
-    mA0 = 0;
-    bp = dx;
-    cx = dy;
+	mA0 = 0;
+	bp = dx;
+	cx = dy;
 
-    mA1 = mD1;
+	mA1 = mD1;
   }
   else
   {
-    mA1 = 0;
-    bp = dy;
-    cx = dx;
+	mA1 = 0;
+	bp = dy;
+	cx = dx;
 
-    mA0 = mD0;
+	mA0 = mD0;
   }
 
   bp=bp*2;
@@ -297,35 +297,35 @@
 
   if(flag_obstacle!=0)
   {
-    flag_obstacle = 1;
-    return;
+	flag_obstacle = 1;
+	return;
   }
 
   while(--cx)
   {
-    if(dx>0)
-    {
-      ax+=mD0;
-      bx+=mD1;
-      dx+=si;
-    }
-    else
-    {
-      ax+=mA0;
-      bx+=mA1;
-      dx+=bp;
-    }
+	if(dx>0)
+	{
+	  ax+=mD0;
+	  bx+=mD1;
+	  dx+=si;
+	}
+	else
+	{
+	  ax+=mA0;
+	  bx+=mA1;
+	  dx+=bp;
+	}
 
-    getPixel(ax, bx);
+	getPixel(ax, bx);
 
-    X = ax;
-    Y = bx;
+	X = ax;
+	Y = bx;
 
-    if(flag_obstacle!=0)
-    {
-      flag_obstacle = 1;
-      return;
-    }
+	if(flag_obstacle!=0)
+	{
+	  flag_obstacle = 1;
+	  return;
+	}
   }
 
   flag_obstacle = 0;
@@ -340,57 +340,57 @@
 
   if ( nclick_noeud == 1 )
   {
-    x  = x_mouse;
-    y  = y_mouse;
-    x1 = table_ptselect[0][0];
-    y1 = table_ptselect[0][1];
+	x  = x_mouse;
+	y  = y_mouse;
+	x1 = table_ptselect[0][0];
+	y1 = table_ptselect[0][1];
 
-    ctpVar19 = ctpVar15;
+	ctpVar19 = ctpVar15;
 
-    getPixel( x, y );
+	getPixel( x, y );
 
-    if ( !flag_obstacle )
-    {	
-      ctpVar19 = ctpVar11;
+	if ( !flag_obstacle )
+	{	
+	  ctpVar19 = ctpVar11;
 
-      getPixel( x, y );
+	  getPixel( x, y );
 
-      if ( flag_obstacle )
-      {
-        polydroite( x1, y1, x, y );
-      }
-      ctpVar19 = ctpVar15;
-    }
-    if ( !flag_obstacle )	/* dans flag_obstacle --> couleur du point */
-    {
-      x1 = table_ptselect[0][0];
-      y1 = table_ptselect[0][1];
+	  if ( flag_obstacle )
+	  {
+		polydroite( x1, y1, x, y );
+	  }
+	  ctpVar19 = ctpVar15;
+	}
+	if ( !flag_obstacle )	/* dans flag_obstacle --> couleur du point */
+	{
+	  x1 = table_ptselect[0][0];
+	  y1 = table_ptselect[0][1];
 
-      poly2( x, y, x1, y1 );
+	  poly2( x, y, x1, y1 );
 
-      x_mouse = X;
-      y_mouse = Y;
-    } 
+	  x_mouse = X;
+	  y_mouse = Y;
+	} 
   }
   ctpVar19 = ctpVar11;
   
   p = -1;
   for ( i=0; i < ctp_routeCoordCount; i++ )
   {
-    x = table[i][0];
-    y = table[i][1];
+	x = table[i][0];
+	y = table[i][1];
 
-    ctpProc2( x_mouse, y_mouse, x, y );
-    if ( ctpVar14 < d1 )
-    {
-      polydroite( x_mouse, y_mouse, x, y );
+	ctpProc2( x_mouse, y_mouse, x, y );
+	if ( ctpVar14 < d1 )
+	{
+	  polydroite( x_mouse, y_mouse, x, y );
 
-      if ( !flag_obstacle && ctp_routes[i][0] > 0 )
-      {
-        d1 = ctpVar14;
-        p  = i;
-      }
-    }
+	  if ( !flag_obstacle && ctp_routes[i][0] > 0 )
+	  {
+		d1 = ctpVar14;
+		p  = i;
+	  }
+	}
   }
 
   return ( p );
@@ -532,11 +532,11 @@
 		flag_aff_chemin=1;
 		ctpVar19=ctpVar15;
 
-    // can we go there directly ?
+	// can we go there directly ?
 		polydroite(x1,y1,x2,y2);
-    ////////////////
-    flag_obstacle = 0;
-    ////////////////
+	////////////////
+	flag_obstacle = 0;
+	////////////////
 		if (!flag_obstacle)
 		{
 			solution0[0][0]=x1;
@@ -557,7 +557,7 @@
 		}
 		else	
 		{
-      // no, we take the fastest way
+	  // no, we take the fastest way
 			solution[0]=-1;
 			if (ctp_routes[select_noeud[0]][0]>0) 
 				chemin0(table[0],table[1]);
@@ -647,47 +647,47 @@
 
   if(!polyStruct)
   {
-    pSolution[0] = -1;
-    pSolution[1] = -1;
+	pSolution[0] = -1;
+	pSolution[1] = -1;
 
-    return -1;
+	return -1;
   }
 
   if(oldPathId >= 0)
   {
-    if(persoTable[oldPathId])
-    {
-      freePerso(oldPathId);
-    }
+	if(persoTable[oldPathId])
+	{
+	  freePerso(oldPathId);
+	}
   }
 
   if(!flagCt)
   {
-    int i;
-    int16* ptr;
+	int i;
+	int16* ptr;
 
-    for(i=0;i<10;i++) // 10 = num perso
-    {
-      if(!persoTable[i])
-      {
-        break;
-      }
-    }
+	for(i=0;i<10;i++) // 10 = num perso
+	{
+	  if(!persoTable[i])
+	  {
+		break;
+	  }
+	}
 
-    if(i == 10)
-    {
-      pSolution[0] = -1;
-      pSolution[1] = -1;
+	if(i == 10)
+	{
+	  pSolution[0] = -1;
+	  pSolution[1] = -1;
 
-      return -1;
-    }
+	  return -1;
+	}
 
-    perso = persoTable[i] = (persoStruct*)malloc(sizeof(persoStruct));
+	perso = persoTable[i] = (persoStruct*)malloc(sizeof(persoStruct));
 
-    ptr = perso->solution[0];
+	ptr = perso->solution[0];
 
-    perso->inc_jo1 = stepX;
-    perso->inc_jo2 = stepY;
+	perso->inc_jo1 = stepX;
+	perso->inc_jo2 = stepY;
 
     *(ptr++) = _X;
     *(ptr++) = _Y;
@@ -695,12 +695,12 @@
     *(ptr++) = pSolution[1] = destY;
     *(ptr++) = -1;
 
-    pSolution[4] = computedVar14;
+	pSolution[4] = computedVar14;
 
-    perso->inc_droite = 0;
-    perso->inc_chemin = 0;
+	perso->inc_droite = 0;
+	perso->inc_chemin = 0;
 
-    return i;
+	return i;
   }
 
   nclick_noeud=0;
@@ -783,7 +783,7 @@
 
 	newf = abs(mat)-1;
 
-	zoom = subOp22(y);
+	zoom = computeZoom(y);
 	if (mat<0) zoom=-zoom;
 
 	setObjectPosition(ovl,obj,0, x);
@@ -827,183 +827,184 @@
 
 };
 
-void processActors(void)
+void processAnimation(void)
 {
   objectParamsQuery params;
   int16 returnVar2[5];
   actorStruct* currentActor = &actorHead;
+  actorStruct* nextActor;
 
-  while(currentActor->next)
+  while(currentActor)
   {
-    currentActor = currentActor->next;
+	nextActor = currentActor->next;
 
-    if(!currentActor->freeze && ((currentActor->type == 0) || (currentActor->type == 1)))
-    {
-      getMultipleObjectParam(currentActor->overlayNumber,currentActor->var4,&params);
+	if(!currentActor->freeze && ((currentActor->type == 0) || (currentActor->type == 1)))
+	{
+	  getMultipleObjectParam(currentActor->overlayNumber,currentActor->idx,&params);
 
-      if(((animationStart && !currentActor->flag) || (!animationStart && currentActor->x_dest != -1 && currentActor->y_dest != -1)) && (currentActor->type == 0))
-      {
-        // mouse animation
-        if(!animationStart)
-        {
-          var34 = currentActor->x_dest;
-          var35 = currentActor->y_dest;
+	  if(((animationStart && !currentActor->flag) || (!animationStart && currentActor->x_dest != -1 && currentActor->y_dest != -1)) && (currentActor->type == 0))
+	  {
+		// mouse animation
+		if(!animationStart)
+		{
+		  var34 = currentActor->x_dest;
+		  var35 = currentActor->y_dest;
 
-          currentActor->x_dest = -1;
-          currentActor->y_dest = -1;
+		  currentActor->x_dest = -1;
+		  currentActor->y_dest = -1;
 
-          currentActor->flag = 1;
-        }
+		  currentActor->flag = 1;
+		}
 
-        currentActor->pathId = computePathfinding(returnVar2, params.X, params.Y, var34, var35, currentActor->stepX, currentActor->stepY, currentActor->pathId);
+		currentActor->pathId = computePathfinding(returnVar2, params.X, params.Y, var34, var35, currentActor->stepX, currentActor->stepY, currentActor->pathId);
 
-        if(currentActor->pathId == -1)
-        {
-          if((currentActor->endDirection != -1) && (currentActor->endDirection != currentActor->startDirection))
-          {
-            currentActor->phase = ANIM_PHASE_STATIC_END;
-            currentActor->nextDirection = currentActor->endDirection;
-            currentActor->endDirection = -1;
-            currentActor->counter = 0;
-          }
-          else
-          {
-            currentActor->pathId = -2;
-            currentActor->flag = 0;
-            currentActor->endDirection = -1;
-            currentActor->phase = ANIM_PHASE_WAIT;
-          }
-        }
-        else
-        {
-          currentActor->phase = ANIM_PHASE_STATIC;
-          currentActor->counter = -1;
-        }
-      }
-      else
-      if((currentActor->type == 1) && (currentActor->x_dest != -1) && (currentActor->y_dest != -1))
-      {
-        // track animation
-        currentActor->pathId = computePathfinding(returnVar2, params.X, params.Y, currentActor->x_dest, currentActor->y_dest, currentActor->stepX, currentActor->stepY, currentActor->pathId);
+		if(currentActor->pathId == -1)
+		{
+		  if((currentActor->endDirection != -1) && (currentActor->endDirection != currentActor->startDirection))
+		  {
+			currentActor->phase = ANIM_PHASE_STATIC_END;
+			currentActor->nextDirection = currentActor->endDirection;
+			currentActor->endDirection = -1;
+			currentActor->counter = 0;
+		  }
+		  else
+		  {
+			currentActor->pathId = -2;
+			currentActor->flag = 0;
+			currentActor->endDirection = -1;
+			currentActor->phase = ANIM_PHASE_WAIT;
+		  }
+		}
+		else
+		{
+		  currentActor->phase = ANIM_PHASE_STATIC;
+		  currentActor->counter = -1;
+		}
+	  }
+	  else
+	  if((currentActor->type == 1) && (currentActor->x_dest != -1) && (currentActor->y_dest != -1))
+	  {
+		// track animation
+		currentActor->pathId = computePathfinding(returnVar2, params.X, params.Y, currentActor->x_dest, currentActor->y_dest, currentActor->stepX, currentActor->stepY, currentActor->pathId);
 
-        currentActor->x_dest = -1;
-        currentActor->y_dest = -1;
+		currentActor->x_dest = -1;
+		currentActor->y_dest = -1;
 
-        if(currentActor->pathId == -1)
-        {
-          if((currentActor->endDirection != -1) && (currentActor->endDirection != currentActor->startDirection))
-          {
-            currentActor->phase = ANIM_PHASE_STATIC_END;
-            currentActor->nextDirection = currentActor->endDirection;
-            currentActor->endDirection = -1;
-            currentActor->counter = 0;
-          }
-          else
-          {
-            currentActor->pathId = -2;
-            currentActor->flag = 0;
-            currentActor->endDirection = -1;
-            currentActor->phase = ANIM_PHASE_WAIT;
-          }
-        }
-        else
-        {
-          currentActor->phase = ANIM_PHASE_STATIC;
-          currentActor->counter = -1;
-        }
-      }
+		if(currentActor->pathId == -1)
+		{
+		  if((currentActor->endDirection != -1) && (currentActor->endDirection != currentActor->startDirection))
+		  {
+			currentActor->phase = ANIM_PHASE_STATIC_END;
+			currentActor->nextDirection = currentActor->endDirection;
+			currentActor->endDirection = -1;
+			currentActor->counter = 0;
+		  }
+		  else
+		  {
+			currentActor->pathId = -2;
+			currentActor->flag = 0;
+			currentActor->endDirection = -1;
+			currentActor->phase = ANIM_PHASE_WAIT;
+		  }
+		}
+		else
+		{
+		  currentActor->phase = ANIM_PHASE_STATIC;
+		  currentActor->counter = -1;
+		}
+	  }
 
-      animationStart = 0;
+	  animationStart = false;
 
-      if(currentActor->pathId >= 0 || currentActor->phase == ANIM_PHASE_STATIC_END)
-      {
-        switch(currentActor->phase)
-        {
-        case ANIM_PHASE_STATIC_END:
-        case ANIM_PHASE_STATIC:
-          {
-            if(currentActor->counter == -1 && currentActor->phase == ANIM_PHASE_STATIC)
-            {
-              affiche_chemin(currentActor->pathId, returnVar2);
+	  if(currentActor->pathId >= 0 || currentActor->phase == ANIM_PHASE_STATIC_END)
+	  {
+		switch(currentActor->phase)
+		{
+		case ANIM_PHASE_STATIC_END:
+		case ANIM_PHASE_STATIC:
+		  {
+			if(currentActor->counter == -1 && currentActor->phase == ANIM_PHASE_STATIC)
+			{
+			  affiche_chemin(currentActor->pathId, returnVar2);
 
-              if(returnVar2[0] == -1)
-              {
-                currentActor->pathId = -2;
-                currentActor->flag = 0;
-                currentActor->endDirection = -1;
-                currentActor->phase = ANIM_PHASE_WAIT;
-                break;
-              }
+			  if(returnVar2[0] == -1)
+			  {
+				currentActor->pathId = -2;
+				currentActor->flag = 0;
+				currentActor->endDirection = -1;
+				currentActor->phase = ANIM_PHASE_WAIT;
+				break;
+			  }
 
 							currentActor->x = returnVar2[0];
 							currentActor->y = returnVar2[1];
 							currentActor->nextDirection = returnVar2[2];	
 							currentActor->poly = returnVar2[4];
-              currentActor->counter = 0;
+			  currentActor->counter = 0;
 
-              if (currentActor->startDirection == currentActor->nextDirection)
-                currentActor->phase = ANIM_PHASE_MOVE;
-            }
+			  if (currentActor->startDirection == currentActor->nextDirection)
+				currentActor->phase = ANIM_PHASE_MOVE;
+			}
 
-            if ((currentActor->counter>=0) && ((currentActor->phase==ANIM_PHASE_STATIC_END) || (currentActor->phase==ANIM_PHASE_STATIC)))
-            {
-              int newA;
+			if ((currentActor->counter>=0) && ((currentActor->phase==ANIM_PHASE_STATIC_END) || (currentActor->phase==ANIM_PHASE_STATIC)))
+			{
+			  int newA;
 							int inc = 1;
-              int t_inc = currentActor->startDirection-1;
+			  int t_inc = currentActor->startDirection-1;
 
 							if (t_inc<0)
-                t_inc=3;
+				t_inc=3;
 
-              if (currentActor->nextDirection==t_inc)
-                inc=-1;
+			  if (currentActor->nextDirection==t_inc)
+				inc=-1;
 
 							if (inc>0)
-                newA = raoul_stat[currentActor->startDirection][currentActor->counter++];
+				newA = raoul_stat[currentActor->startDirection][currentActor->counter++];
 							else
-                newA = raoul_invstat[currentActor->startDirection][currentActor->counter++];
+				newA = raoul_invstat[currentActor->startDirection][currentActor->counter++];
 
 							if (newA==0)	
 							{
 								currentActor->startDirection = currentActor->startDirection+inc;
 
 								if (currentActor->startDirection>3)
-                  currentActor->startDirection=0;
+				  currentActor->startDirection=0;
 
 								if (currentActor->startDirection<0)
-                  currentActor->startDirection=3;
+				  currentActor->startDirection=3;
 
 								currentActor->counter=0;
 
 								if (currentActor->startDirection==currentActor->nextDirection)	
 								{
 									if (currentActor->phase == ANIM_PHASE_STATIC)
-                    currentActor->phase = ANIM_PHASE_MOVE;
+					currentActor->phase = ANIM_PHASE_MOVE;
 									else
-                    currentActor->phase = ANIM_PHASE_END;
+					currentActor->phase = ANIM_PHASE_END;
 								}
 								else
 								{	
 									newA = raoul_stat[currentActor->startDirection][currentActor->counter++];
 
 									if (inc==-1)
-                    newA=-newA;
+										newA=-newA;
 
-									set_anim(currentActor->overlayNumber,currentActor->var4,currentActor->start,params.X,params.Y,newA,currentActor->poly);
+									set_anim(currentActor->overlayNumber,currentActor->idx,currentActor->start,params.X,params.Y,newA,currentActor->poly);
 									break;
 								}
 							}
 							else 
 							{
-								set_anim(currentActor->overlayNumber,currentActor->var4,currentActor->start,params.X,params.Y,newA,currentActor->poly);
+								set_anim(currentActor->overlayNumber,currentActor->idx,currentActor->start,params.X,params.Y,newA,currentActor->poly);
 								break;
 							}
-            }
-            break;
-          }
-        case ANIM_PHASE_MOVE:
-          {
-            if (currentActor->counter>=1)
-            {
+			}
+			break;
+		  }
+		case ANIM_PHASE_MOVE:
+		  {
+			if (currentActor->counter>=1)
+			{
 								affiche_chemin(currentActor->pathId,returnVar2);
 								if (returnVar2[0]==-1) 
 								{ 
@@ -1035,46 +1036,47 @@
 									}
 									*/
 								}
-            }
+			}
 
-            if (currentActor->phase==ANIM_PHASE_MOVE)
-            {	
-              int newA;
+			if (currentActor->phase==ANIM_PHASE_MOVE)
+			{	
+			  int newA;
 
-              currentActor->startDirection = currentActor->nextDirection;
+			  currentActor->startDirection = currentActor->nextDirection;
 
-              newA = raoul_move[currentActor->startDirection][currentActor->counter++];
-              if (!newA) 
-              {
-                currentActor->counter=0;
-                newA = raoul_move[currentActor->startDirection][currentActor->counter++];
-              }
-              set_anim(currentActor->overlayNumber,currentActor->var4,currentActor->start,currentActor->x,currentActor->y,newA,currentActor->poly);
-              break;
-            }
+			  newA = raoul_move[currentActor->startDirection][currentActor->counter++];
+			  if (!newA) 
+			  {
+				currentActor->counter=0;
+				newA = raoul_move[currentActor->startDirection][currentActor->counter++];
+			  }
+			  set_anim(currentActor->overlayNumber,currentActor->idx,currentActor->start,currentActor->x,currentActor->y,newA,currentActor->poly);
+			  break;
+			}
 
-            break;
-          }
-        case ANIM_PHASE_END:
-          {
-            int newA = raoul_end[currentActor->startDirection][0];
+			break;
+		  }
+		case ANIM_PHASE_END:
+		  {
+			int newA = raoul_end[currentActor->startDirection][0];
 
-			set_anim(currentActor->overlayNumber,currentActor->var4,currentActor->start,currentActor->x,currentActor->y,newA,currentActor->poly);
+			set_anim(currentActor->overlayNumber,currentActor->idx,currentActor->start,currentActor->x,currentActor->y,newA,currentActor->poly);
 
 			currentActor->pathId = -2; 
 			currentActor->phase=ANIM_PHASE_WAIT;
 			currentActor->flag=0;	
 			currentActor->endDirection=-1;	
-            break;
-          }
-        default:
-          {
-            printf("Unimplemented currentActor->phase=%d in processActors()\n", currentActor->phase);
-           // exit(1);
-          }
-        }
-      }
-    }
+			break;
+		  }
+		default:
+		  {
+			printf("Unimplemented currentActor->phase=%d in processAnimation()\n", currentActor->phase);
+		   // exit(1);
+		  }
+		}
+	  }
+	}
+	currentActor = nextActor;
   }
 }
 } // End of namespace Cruise

Modified: scummvm/trunk/engines/cruise/actor.h
===================================================================
--- scummvm/trunk/engines/cruise/actor.h	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/actor.h	2007-04-27 20:31:43 UTC (rev 26624)
@@ -42,32 +42,32 @@
 	struct actorStruct* next;
 	struct actorStruct* prev;
 
-  int16 var4;
-  int16 type;
-  int16 overlayNumber;
-  int16 x_dest;
-  int16 y_dest;
-  int16 x;
-  int16 y;
-  int16 startDirection;
-  int16 nextDirection;
-  int16 endDirection;
-  int16 stepX;
-  int16 stepY;
-  int16 pathId;
-  animPhase phase;
-  int16 counter;
-  int16 poly;
-  int16 flag;
-  int16 start;
-  int16 freeze;
+	int16 idx;
+	int16 type;
+	int16 overlayNumber;
+	int16 x_dest;
+	int16 y_dest;
+	int16 x;
+	int16 y;
+	int16 startDirection;
+	int16 nextDirection;
+	int16 endDirection;
+	int16 stepX;
+	int16 stepY;
+	int16 pathId;
+	animPhase phase;
+	int16 counter;
+	int16 poly;
+	int16 flag;
+	int16 start;
+	int16 freeze;
 };
 
 typedef struct actorStruct actorStruct;
 
 int16 mainProc13(int overlayIdx, int param1, actorStruct* pStartEntry, int param2);
 actorStruct* findActor(int overlayIdx, int param1, actorStruct* pStartEntry, int param2);
-void processActors(void);
+void processAnimation(void);
 void getPixel(int x, int y);
 } // End of namespace Cruise
 

Added: scummvm/trunk/engines/cruise/cell.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cell.cpp	                        (rev 0)
+++ scummvm/trunk/engines/cruise/cell.cpp	2007-04-27 20:31:43 UTC (rev 26624)
@@ -0,0 +1,159 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2006 The ScummVM project
+ *
+ * cinE Engine is (C) 2004-2005 by CinE Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "cruise/cell.h"
+#include "cruise/cruise_main.h"
+
+namespace Cruise {
+
+void resetPtr(cellStruct* ptr)
+{
+  ptr->next = NULL;
+  ptr->prev = NULL;
+}
+
+void loadSavegameDataSub2(FILE * f)
+{
+  unsigned short int n_chunks;
+  int i;
+  cellStruct *p;
+  cellStruct *t;
+
+  cellHead.next = NULL; // Not in ASM code, but I guess the variable is defaulted
+                          // to this value in the .exe
+
+  fread(&n_chunks, 2, 1, f);
+  // BIG ENDIAN MACHINES, PLEASE SWAP IT
+
+  p = &cellHead;
+
+  for (i = 0; i < n_chunks; i++)
+  {
+    t = (cellStruct *) mallocAndZero(sizeof(cellStruct));
+
+    fseek(f, 4, SEEK_CUR);
+    fread(&t->idx, 1, 0x30, f);
+
+    t->next = NULL;
+		p->next = t;
+    t->prev = cellHead.prev;
+    cellHead.prev = t;
+    p = t;
+  }
+}
+
+cellStruct* addCell(int16 overlayIdx,int16 param2,cellStruct* pHead,int16 scriptType,int16 scriptNumber,int16 scriptOverlay, int16 param3, int16 param4)
+{
+  int16 var;
+
+  cellStruct* newElement;
+  cellStruct* currentHead = pHead;
+  cellStruct* currentHead2;
+  cellStruct* currentHead3;
+
+  if(getSingleObjectParam(overlayIdx,param2,2,&var)<0)
+  {
+    return 0;
+  }
+
+  currentHead3 = currentHead;
+  currentHead2 = currentHead->next;
+
+  while(currentHead2)
+  {
+    if(currentHead2->type == 3)
+    {
+      break;
+    }
+
+    if(currentHead2->type != 5)
+    {
+      int16 lvar2;
+
+      getSingleObjectParam(currentHead2->overlay,currentHead2->idx,2,&lvar2);
+
+      if(lvar2 > var)
+        break;
+    }
+
+    currentHead3 = currentHead2;
+    currentHead2 = currentHead2->next;
+  }
+
+  if(currentHead2)
+  {
+    if( (currentHead2->overlay == overlayIdx) &&
+        (currentHead2->backgroundPlane == param3) &&
+        (currentHead2->idx == param2) &&
+        (currentHead2->type == param4))
+
+    return NULL;
+  }
+
+  currentHead = currentHead2;
+
+  newElement = (cellStruct*)mallocAndZero(sizeof(cellStruct));
+
+  if(!newElement)
+    return 0;
+
+  newElement->next = currentHead3->next;
+  currentHead3->next = newElement;
+
+  newElement->idx = param2;
+  newElement->type = param4;
+  newElement->backgroundPlane = param3;
+  newElement->overlay = overlayIdx;
+  newElement->freeze = 0;
+  newElement->field_16 = scriptNumber;
+  newElement->field_18 = scriptOverlay;
+  newElement->gfxPtr = NULL;
+  newElement->followObjectIdx = param2;
+  newElement->followObjectOverlayIdx = overlayIdx;
+  newElement->field_1A = scriptType;
+  newElement->field_20 = 0;
+  newElement->field_22 = 0;
+  newElement->nextAnimDelay = 0;
+  newElement->field_2C = 0;
+  newElement->currentAnimDelay = 0;
+  newElement->field_2A = 0;
+  newElement->animStep = 0;
+  newElement->field_30 = 0;
+
+  if(currentHead)
+  {
+    newElement->prev = currentHead->prev;
+    currentHead->prev = newElement;
+  }
+  else
+  {
+    newElement->prev = pHead->prev;
+    pHead->prev = newElement;
+  }
+  
+  return newElement;
+}
+
+
+}
\ No newline at end of file


Property changes on: scummvm/trunk/engines/cruise/cell.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Added: scummvm/trunk/engines/cruise/cell.h
===================================================================
--- scummvm/trunk/engines/cruise/cell.h	                        (rev 0)
+++ scummvm/trunk/engines/cruise/cell.h	2007-04-27 20:31:43 UTC (rev 26624)
@@ -0,0 +1,73 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2006 The ScummVM project
+ *
+ * cinE Engine is (C) 2004-2005 by CinE Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef _CELL_H_
+#define _CELL_H_
+
+#include "common/stdafx.h"
+#include "common/scummsys.h"
+
+namespace Cruise {
+
+struct gfxEntryStruct;
+
+struct cellStruct
+{
+	struct cellStruct* next;
+	struct cellStruct* prev;
+	int16 idx;
+	int16 type;
+	int16 overlay ;
+	int16 field_A ;
+	int16 field_C ;
+	int16 spriteIdx ;
+	int16 field_10;
+	int16 backgroundPlane;
+	int16 freeze;
+	int16 field_16;
+	int16 field_18;
+	int16 field_1A;
+	int16 followObjectOverlayIdx;
+	int16 followObjectIdx;
+	int16 field_20;
+	int16 field_22;
+	int16 nextAnimDelay;
+	int16 animStep;
+	int16 field_28;
+	int16 field_2A;
+	int16 field_2C;
+	int16 currentAnimDelay;
+	int16 field_30;
+	gfxEntryStruct* gfxPtr;
+};
+
+extern cellStruct cellHead;
+
+void resetPtr(cellStruct* ptr);
+void loadSavegameDataSub2(FILE * f);
+cellStruct* addCell(int16 overlayIdx,int16 param2,cellStruct* pHead,int16 scriptType,int16 scriptNumber,int16 scriptOverlay, int16 param3, int16 param4);
+
+}
+
+#endif
\ No newline at end of file


Property changes on: scummvm/trunk/engines/cruise/cell.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/trunk/engines/cruise/cruise_main.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cruise_main.cpp	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/cruise_main.cpp	2007-04-27 20:31:43 UTC (rev 26624)
@@ -26,7 +26,7 @@
 #include "common/events.h"
 
 #include "cruise/cruise_main.h"
-#include <time.h>
+#include "cruise/cell.h"
 
 namespace Cruise {
 
@@ -221,12 +221,6 @@
   ptr->scriptNumber = -1;
 }
 
-void resetPtr(objectStruct* ptr)
-{
-  ptr->next = NULL;
-  ptr->prev = NULL;
-}
-
 void resetActorPtr(actorStruct* ptr)
 {
   ptr->next = NULL;
@@ -540,7 +534,7 @@
   resetPtr2(&scriptHandle2);
   resetPtr2(&scriptHandle1);
 
-  resetPtr(&objectHead);
+  resetPtr(&cellHead);
 
   resetActorPtr(&actorHead);
   resetBackgroundIncrustList(&backgroundIncrustHead);
@@ -699,7 +693,7 @@
 
   char objectName[80];
 
-  objectStruct* currentObject = objectHead.prev;
+  cellStruct* currentObject = cellHead.prev;
 
   while(currentObject)
   {
@@ -713,7 +707,7 @@
 
           if(strlen(objectName))
           {
-            if(currentObject->hide == 0)
+            if(currentObject->freeze == 0)
             {
               var_2 = currentObject->idx;
               var_4 = currentObject->overlay;
@@ -1520,11 +1514,11 @@
       removeFinishedScripts(&scriptHandle1);
       removeFinishedScripts(&scriptHandle2);
 
-      processActors();
+      processAnimation();
 
       if(var0)
       {
-        ASSERT(0);
+       // ASSERT(0);
     /*    main3 = 0;
         var24 = 0;
         var23 = 0;

Modified: scummvm/trunk/engines/cruise/cruise_main.h
===================================================================
--- scummvm/trunk/engines/cruise/cruise_main.h	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/cruise_main.h	2007-04-27 20:31:43 UTC (rev 26624)
@@ -45,7 +45,7 @@
 #include "cruise/various.h"
 #include "cruise/stringSupport.h"
 #include "cruise/function.h"
-#include "cruise/loadSave.h"
+#include "cruise/saveload.h"
 #include "cruise/linker.h"
 #include "cruise/mouse.h"
 #include "cruise/gfxModule.h"
@@ -89,7 +89,6 @@
 void removeExtention(const char* name, char* buffer);
 void resetRaster(uint8* rasterPtr, int32 rasterSize);
 void changeCursor(uint16 cursorType);
-void resetPtr(objectStruct* ptr);
 void resetPtr2(scriptInstanceStruct* ptr);
 void getFileExtention(const char* name,char* buffer);
 void *allocAndZero(int size);

Modified: scummvm/trunk/engines/cruise/decompiler.cpp
===================================================================
--- scummvm/trunk/engines/cruise/decompiler.cpp	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/decompiler.cpp	2007-04-27 20:31:43 UTC (rev 26624)
@@ -787,7 +787,7 @@
       }
     case 0x5:
       {
-        sprintf(tempbuffer,"_addObject(%s,%s,%s)",popDecomp(),popDecomp(),popDecomp());
+        sprintf(tempbuffer,"_addCell(%s,%s,%s)",popDecomp(),popDecomp(),popDecomp());
         pushDecomp(tempbuffer);
         break;
       }
@@ -905,7 +905,7 @@
       }
     case 0x16:
       {
-        sprintf(tempbuffer,"_op_16(%s,%s,%s,%s,%s,%s)",popDecomp(),popDecomp(),popDecomp(),popDecomp(),popDecomp(),popDecomp());
+        sprintf(tempbuffer,"_Op_FreezeCell(%s,%s,%s,%s,%s,%s)",popDecomp(),popDecomp(),popDecomp(),popDecomp(),popDecomp(),popDecomp());
         pushDecomp(tempbuffer);
         break;
       }
@@ -917,13 +917,13 @@
       }
     case 0x18:
       {
-        sprintf(tempbuffer,"_op_18(%s,%s,%s,%s,%s,%s,%s)",popDecomp(),popDecomp(),popDecomp(),popDecomp(),popDecomp(),popDecomp(),popDecomp());
+        sprintf(tempbuffer,"_Op_AddAnimation(%s,%s,%s,%s,%s,%s,%s)",popDecomp(),popDecomp(),popDecomp(),popDecomp(),popDecomp(),popDecomp(),popDecomp());
         pushDecomp(tempbuffer);
         break;
       }
     case 0x19:
       {
-        sprintf(tempbuffer,"_op_19(%s,%s,%s)",popDecomp(),popDecomp(),popDecomp());
+        sprintf(tempbuffer,"_Op_RemoveAnimation(%s,%s,%s)",popDecomp(),popDecomp(),popDecomp());
         pushDecomp(tempbuffer);
         break;
       }
@@ -1140,13 +1140,13 @@
       }
     case 0x5C:
       {
-        sprintf(tempbuffer,"_op_5C(%s,%s)",popDecomp(),popDecomp());
+        sprintf(tempbuffer,"_Op_AddCellC(%s,%s)",popDecomp(),popDecomp());
         pushDecomp(tempbuffer);
         break;
       }
     case 0x5E:
       {
-        sprintf(tempbuffer,"_op_5E(%s)",popDecomp());
+        sprintf(tempbuffer,"_Op_AddCellE(%s)",popDecomp());
         pushDecomp(tempbuffer);
         break;
       }
@@ -1307,19 +1307,19 @@
       }
     case 0x76:
       {
-        sprintf(tempbuffer,"_op_76(%s,%s)",popDecomp(),popDecomp());
+        sprintf(tempbuffer,"_Op_InitializeState6(%s,%s)",popDecomp(),popDecomp());
         pushDecomp(tempbuffer);
         break;
       }
     case 0x77:
       {
-        sprintf(tempbuffer,"_op_77(%s)",popDecomp());
+        sprintf(tempbuffer,"_Op_InitializeState7(%s)",popDecomp());
         pushDecomp(tempbuffer);
         break;
       }
     case 0x78:
       {
-        sprintf(tempbuffer,"_op_78(%s)",popDecomp());
+        sprintf(tempbuffer,"_Op_InitializeState8(%s)",popDecomp());
         pushDecomp(tempbuffer);
         break;
       }
@@ -1331,13 +1331,13 @@
       }
     case 0x7B:
       {
-        sprintf(tempbuffer,"_op_7B(%s)",popDecomp());
+        sprintf(tempbuffer,"_Op_InitializeStateB(%s)",popDecomp());
         pushDecomp(tempbuffer);
         break;
       }
     case 0x7C:
       {
-        sprintf(tempbuffer,"_op_7C(%s)",popDecomp());
+        sprintf(tempbuffer,"_Op_InitializeStateC(%s)",popDecomp());
         pushDecomp(tempbuffer);
         break;
       }

Modified: scummvm/trunk/engines/cruise/function.cpp
===================================================================
--- scummvm/trunk/engines/cruise/function.cpp	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/function.cpp	2007-04-27 20:31:43 UTC (rev 26624)
@@ -23,6 +23,7 @@
  */
 
 #include "cruise/cruise_main.h"
+#include "cruise/cell.h"
 
 namespace Cruise {
 
@@ -50,7 +51,7 @@
   }
 };
 
-int16 Op_loadOverlay(void)
+int16 Op_LoadOverlay(void)
 {
   uint8* originalScriptName;
   uint8 scriptName[38];
@@ -151,7 +152,7 @@
   return(0);
 }
 
-int16 Op_startObject(void)
+int16 Op_AddProc(void)
 {
   int pop1 = popVar();
   int pop2;
@@ -234,14 +235,14 @@
   return(rand()%var);
 }
 
-int16 Op_E(void) // TODO: implement
+int16 Op_PlayFX(void) // TODO: implement
 {
   popVar();
   popVar();
   popVar();
   popVar();
 
- // printf("Op_E, implement (sound related)\n");
+ // printf("Op_PlayFX, implement (sound related)\n");
 
   return(0);
 }
@@ -252,16 +253,16 @@
   return(0);
 }
 
-void freeObjectList(objectStruct* pListHead)
+void freeObjectList(cellStruct* pListHead)
 {
   int var_2 = 0;
-  objectStruct* pCurrent = pListHead->next;
+  cellStruct* pCurrent = pListHead->next;
 
   while(pCurrent)
   {
-    objectStruct* pNext = pCurrent->next;
+    cellStruct* pNext = pCurrent->next;
 
-    if(pCurrent->hide == 0)
+    if(pCurrent->freeze == 0)
     {
       free(pCurrent->gfxPtr);
       free(pCurrent);
@@ -278,9 +279,9 @@
   }
 }
 
-int16 Op_freeObjectList(void)
+int16 Op_FreeCell(void)
 {
-  freeObjectList(&objectHead);
+  freeObjectList(&cellHead);
   return(0);
 }
 
@@ -307,7 +308,7 @@
   return(0);
 }
 
-int16 Op_14(void)
+int16 Op_RemoveMessage(void)
 {
   int idx;
   int overlay;
@@ -320,7 +321,7 @@
     overlay = currentScriptPtr->overlayNumber;
   }
 
-  removeObjectFromList(overlay, idx, &objectHead, currentActiveBackgroundPlane, 5);
+  removeObjectFromList(overlay, idx, &cellHead, currentActiveBackgroundPlane, 5);
   
   return(0);
 }
@@ -352,7 +353,7 @@
   return -1;
 }
 
-int16 Op_resetFilesEntries(void)
+int16 Op_RemoveFrame(void)
 {
   //int var1;
   //int var2;
@@ -376,7 +377,7 @@
   return(0);
 }
 
-int16 Op_removeScript(void)
+int16 Op_RemoveProc(void)
 {
   int idx;
   int overlay;
@@ -394,7 +395,7 @@
   return(0);
 }
 
-int16 Op_releaseScript2(void)
+int16 Op_FreeOverlay(void)
 {
   uint8 localName[36] = "";
   uint8* namePtr;
@@ -435,7 +436,7 @@
   return 0;
 }
 
-int16 Op_EnterPlayerMenu(void)
+int16 Op_PlayFXnterPlayerMenu(void)
 {
   int oldValue = entrerMenuJoueur;
   entrerMenuJoueur = popVar();
@@ -484,7 +485,7 @@
   return 0;
 }
 
-int16 Op_loadBackground(void)
+int16 Op_LoadBackground(void)
 {
   int result = 0;
   uint8 bgName[36] = "";
@@ -565,7 +566,7 @@
   return 0;
 }
 
-int16 Op_loadFullBundle(void)
+int16 Op_LoadAbs(void)
 {
   int param1;
 //  int param2;
@@ -594,7 +595,7 @@
   return result;
 }
 
-int16 Op_7(void)
+int16 Op_InitializeState(void)
 {
   int param1 = popVar();
   int objIdx = popVar();
@@ -603,7 +604,7 @@
   if(!ovlIdx)
     ovlIdx = currentScriptPtr->overlayNumber;
 
-  Op_7Sub(ovlIdx,objIdx,param1);
+  Op_InitializeStateSub(ovlIdx,objIdx,param1);
 
   return(0);
 }
@@ -613,9 +614,9 @@
   return initVar1;
 }
 
-int16 Op_prepareFadeOut(void)
+int16 Op_FadeOut(void)
 {
-  printf("Op_prepareFadeOut dummy\n");
+  printf("Op_FadeOut dummy\n");
   return 0;
 }
 
@@ -634,7 +635,7 @@
   return 0;
 }
 
-int16 Op_isOverlayLoaded(void)
+int16 Op_FindOverlay(void)
 {
   uint8 name[36] = "";
   uint8* ptr;
@@ -662,7 +663,7 @@
   return returnParam;
 }
 
-int16 Op_setMain5(void)
+int16 Op_FadeIn(void)
 {
   main5 = 1;
   return 0;
@@ -682,7 +683,7 @@
   return 0;
 }
 
-int16 Op_5(void)
+int16 Op_AddCell(void)
 {
   int16 param1 = popVar();
   int16 param2 = popVar();
@@ -691,7 +692,7 @@
   if(!overlayIdx)
     overlayIdx = currentScriptPtr->overlayNumber;
 
-  addObject(overlayIdx,param2,&objectHead,currentScriptPtr->type,currentScriptPtr->scriptNumber,currentScriptPtr->overlayNumber,currentActiveBackgroundPlane,param1);
+  addCell(overlayIdx,param2,&cellHead,currentScriptPtr->type,currentScriptPtr->scriptNumber,currentScriptPtr->overlayNumber,currentActiveBackgroundPlane,param1);
 
   return 0;
 }
@@ -711,7 +712,7 @@
   return 0;
 }
 
-int16 Op_8(void)
+int16 Op_RemoveCell(void)
 {
   var1 = popVar();
   int objectIdx = popVar();
@@ -722,7 +723,7 @@
     ovlNumber = currentScriptPtr->overlayNumber;
   }
 
-  removeObjectFromList(ovlNumber, objectIdx, &objectHead, currentActiveBackgroundPlane, var1);
+  removeObjectFromList(ovlNumber, objectIdx, &cellHead, currentActiveBackgroundPlane, var1);
 
   return 0;
 }
@@ -753,7 +754,7 @@
 
 int16 op7CVar = 0;
 
-int16 Op_7C(void)
+int16 Op_InitializeStateC(void)
 {
 	int16 temp = op7CVar;
 	int16 newVar;
@@ -766,7 +767,7 @@
 	return temp;
 }
 
-int16 Op_message(void)
+int16 Op_AddMessage(void)
 {
   int16 color = popVar();
   int16 var_2 = popVar();
@@ -792,7 +793,7 @@
     }
   }
 
-  createTextObject(overlayIdx, var_8, &objectHead, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, currentActiveBackgroundPlane, color, var_2, var_4, var_6);
+  createTextObject(overlayIdx, var_8, &cellHead, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, currentActiveBackgroundPlane, color, var_2, var_4, var_6);
 
   return 0;
 }
@@ -805,7 +806,7 @@
   return 0;
 }
 
-int16 Op_loadCtp(void)
+int16 Op_LoadCt(void)
 {
   return loadCtp((uint8*)popPtr());
 }
@@ -828,7 +829,7 @@
   return mainProc13(overlay, param2, &actorHead, param1);
 }
 
-int16 Op_76(void)
+int16 Op_InitializeState6(void)
 {
   popPtr();
   popVar();
@@ -836,38 +837,39 @@
   return 0;
 }
 
-int16 Op_65(void)
+int16 Op_AutoCell(void)
 {
-  objectStruct* pObject;
-  int var_C = popVar();
-  int var_E = popVar();
-  int var_4 = popVar();
-  int var_10 = popVar();
-  int var_12 = popVar();
-  int di = popVar();
-  int var_8 = popVar();
-  int var_2 = popVar();
-  int var_6 = popVar();
+  cellStruct* pObject;
+
+  int signal = popVar();
+  int loop = popVar();
+  int wait = popVar();
+  int animStep = popVar();
+  int end = popVar();
+  int start = popVar();
+  int type = popVar();
+  int change = popVar();
+  int obj = popVar();
   int overlay = popVar();
 
   if(!overlay)
     overlay = currentScriptPtr->overlayNumber;
 
-  pObject = addObject(overlay, var_6, &objectHead, currentScriptPtr->type, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, currentActiveBackgroundPlane, 4);
+  pObject = addCell(overlay, obj, &cellHead, currentScriptPtr->type, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, currentActiveBackgroundPlane, 4);
 
   if(!pObject)
     return 0;
 
-  pObject->field_2C = var_C;
-  pObject->field_30 = var_E;
-  pObject->nextAnimDelay = var_4;
-  pObject->field_26 = var_10;
-  pObject->field_22 = var_12;
-  pObject->field_20 = di;
-  pObject->field_2A = var_8;
-  pObject->field_28 = var_2;
+  pObject->field_2C = signal;
+  pObject->field_30 = loop;
+  pObject->nextAnimDelay = wait;
+  pObject->animStep = animStep;
+  pObject->field_22 = end;
+  pObject->field_20 = start;
+  pObject->field_2A = type;
+  pObject->field_28 = change;
 
-  if(var_8)
+  if(type)
   {
     if(currentScriptPtr->type == 20)
     {
@@ -880,21 +882,21 @@
     }
   }
 
-  if(var_2 == 5)
+  if(change == 5)
   {
-    Op_7Sub(pObject->overlay, pObject->idx, di);
+    Op_InitializeStateSub(pObject->overlay, pObject->idx, start);
   }
   else
   {
-    setObjectPosition(pObject->overlay, pObject->idx, pObject->field_28, di);
+    setObjectPosition(pObject->overlay, pObject->idx, pObject->field_28, start);
   }
 
-  if(var_4 < 0)
+  if(wait < 0)
   {
     objectParamsQuery params;
 
-    getMultipleObjectParam(overlay, var_6, &params);
-    pObject->currentAnimDelay = params.var6;
+    getMultipleObjectParam(overlay, obj, &params);
+    pObject->currentAnimDelay = params.var6-1;
   }
 
   return 0;
@@ -941,7 +943,7 @@
 
 int op7BVar = 0;
 
-int16 Op_7B(void)
+int16 Op_InitializeStateB(void)
 {
   int di = popVar();
   int si = 1 - op7BVar;
@@ -1045,7 +1047,7 @@
   return 0;
 }
 
-int16 Op_D(void) // TODO: palette manipulation
+int16 Op_SetColor(void) // TODO: palette manipulation
 {
   //var_4 = popVar();
   //var_6 = popVar();
@@ -1061,7 +1063,7 @@
   return 0;
 }
 
-int16 Op_78(void)
+int16 Op_InitializeState8(void)
 {
   int si = var41;
 
@@ -1084,7 +1086,7 @@
   return 0;
 }
 
-int16 Op_drawLine(void)
+int16 Op_SetColorrawLine(void)
 {
   /*
   int di = popVar();
@@ -1124,7 +1126,7 @@
   return 0;
 }
 
-int16 subOp22(int param)
+int16 computeZoom(int param)
 {
   return (((param - var46)*(var39-var42))/(var45 - var46))+var42;
 }
@@ -1144,66 +1146,54 @@
 
 int16 Op_22(void)
 {
-  return(subOp22(popVar()));
+  return(computeZoom(popVar()));
 }
 
-actorStruct* addAnimation(int overlay, int idx, actorStruct* pHead2, int param, int param2)
+actorStruct* addAnimation(actorStruct* pHead, int overlay, int objIdx, int param, int param2)
 {
-  actorStruct* pCurrent;
-  actorStruct* pHead = pHead2;
-  actorStruct* si = pHead->next;
-  actorStruct* bx = pHead;
-  actorStruct* pNewElement;
+	actorStruct* pPrevious = pHead;
+	actorStruct* pCurrent = pHead->next;
 
-  if(si)
-  {
-    do
-    {
-      bx = si;
-      si = bx->next;
-    }while(si);
-  }
+	// go to the end of the list
+	while(pCurrent)
+	{
+		pPrevious = pCurrent;
+		pCurrent = pPrevious->next;
+	}
 
-  pHead = bx;
-  pCurrent = si;
+	if(pCurrent && (pCurrent->overlayNumber == overlay) && (pCurrent->idx == objIdx) && (pCurrent->type == param2))
+	{
+		return NULL;
+	}
 
-  if(pCurrent && (pCurrent->overlayNumber == overlay) && (pCurrent->var4 == idx) && (pCurrent->type == param2))
-  {
-    return NULL;
-  }
-  else 
-  {
-    actorStruct* cx;
+	actorStruct* pNewElement = (actorStruct*)malloc(sizeof(actorStruct));
+	if(!pNewElement)
+		return NULL;
 
-    si = pNewElement = (actorStruct*)malloc(sizeof(actorStruct));
+	pNewElement->next = pPrevious->next;
+	pPrevious->next = pNewElement;
 
-    pNewElement->next = pHead->next;
-    pHead->next = pNewElement;
+	if(!pCurrent)
+	{
+	  pCurrent = pHead;
+	}
 
-    cx = pCurrent;
+	pNewElement->prev = pCurrent->prev;
+	pCurrent->prev = pNewElement;
 
-    if(!pCurrent)
-    {
-      cx = pHead;
-    }
+	pNewElement->idx = objIdx;
+	pNewElement->type = param2;
+	pNewElement->pathId = -1;
+	pNewElement->overlayNumber = overlay;
+	pNewElement->startDirection = param;
+	pNewElement->nextDirection = -1;
+	pNewElement->stepX = 5;
+	pNewElement->stepY = 2;
+	pNewElement->phase = ANIM_PHASE_WAIT;
+	pNewElement->flag = 0;
+	pNewElement->freeze = 0;
 
-    bx = cx;
-    si->prev = bx->prev;
-    bx->prev = si;
-    si->var4 = idx;
-    si->type = param2;
-    si->pathId = -1;
-    si->overlayNumber = overlay;
-    si->startDirection = param;
-    si->nextDirection = -1;
-    si->stepX = 5;
-    si->stepY = 2;
-	si->phase = ANIM_PHASE_WAIT;
-    si->flag = 0;
-    si->freeze = 0;
-    
-    return si;
-  }
+	return pNewElement;
 }
 
 int flag_obstacle;			// computedVar14Bis
@@ -1252,14 +1242,14 @@
 }
 
 // add animation
-int16 Op_18(void)
+int16 Op_AddAnimation(void)
 {
-  int var_C = popVar();
-  int var_E = popVar();
+  int stepY = popVar();
+  int stepX = popVar();
   int direction = popVar();
-  int var_8 = popVar();
-  int var_A = popVar();
-  int var_2 = popVar();
+  int start = popVar();
+  int type = popVar();
+  int obj = popVar();
   int overlay = popVar();
 
   if(!overlay)
@@ -1271,46 +1261,56 @@
   {
     actorStruct* si;
 
-    si = addAnimation(overlay, var_2, &actorHead, direction, var_A);
+    si = addAnimation(&actorHead, overlay, obj, direction, type);
 
     if(si)
     {
-      int var_4;
       objectParamsQuery params;
 
-      getMultipleObjectParam(overlay, var_2, &params);
+      getMultipleObjectParam(overlay, obj, &params);
 
       si->x = params.X;
       si->y = params.Y;
       si->x_dest = -1;
       si->y_dest = -1;
       si->endDirection = -1;
-      si->start = var_8;
-      si->stepX = var_E;
-      si->stepY = var_C;
+      si->start = start;
+      si->stepX = stepX;
+      si->stepY = stepY;
 
-      var_A = abs(actorTable1[direction].data[0]) - 1;
+      int newFrame = abs(actorTable1[direction].data[0]) - 1;
 
-      var_4 = subOp22(params.Y);
+      int zoom = computeZoom(params.Y);
 
       if(actorTable1[direction].data[0] < 0)
       {
-        var_4 = - var_4;
+        zoom = -zoom;
       }
 
       checkCollisionWithWalkBoxesBoundingBoxes(params.X, params.Y);
 
-      setObjectPosition(overlay, var_2, 3, var_8 + var_A);
-      setObjectPosition(overlay, var_2, 4, var_4);
-      setObjectPosition(overlay, var_2, 5, computedVar14);
+      setObjectPosition(overlay, obj, 3, newFrame + start);
+      setObjectPosition(overlay, obj, 4, zoom);
+      setObjectPosition(overlay, obj, 5, computedVar14);
 
-      animationStart = 0;
+      animationStart = false;
     }
   }
 
   return 0;
 }
 
+int16 Op_RemoveAnimation(void)
+{
+  popVar();
+  popVar();
+  popVar();
+
+  printf("Partial op 19 (remove actor)\n");
+
+  return 0;
+}
+
 int16 Op_regenerateBackgroundIncrust(void)
 {
   regenerateBackgroundIncrust(&backgroundIncrustHead);
@@ -1352,7 +1352,7 @@
     return 1;
   }
 
-  animationStart = 0;
+  animationStart = false;
 
   pActor->x_dest = actorX;
   pActor->y_dest = actorY;
@@ -1369,7 +1369,7 @@
   return 0;
 }
 
-int16 Op_5C(void)
+int16 Op_AddCellC(void)
 {
   popPtr();
   popVar();
@@ -1379,7 +1379,7 @@
   return 0;
 }
 
-int16 Op_5E(void)
+int16 Op_AddCellE(void)
 {
   popVar();
 
@@ -1429,17 +1429,6 @@
   return 0;
 }
 
-int16 Op_19(void)
-{
-  popVar();
-  popVar();
-  popVar();
-
-  printf("Partial op 19 (remove actor)\n");
-
-  return 0;
-}
-
 int16 Op_6C(void)
 {
   //int var0;
@@ -1460,7 +1449,7 @@
   return temp;
 }
 
-void configureAllObjects(int overlayIdx, objectStruct* pObject, int _var4, int _var0, int _var1, int _var2, int _var3)
+void configureAllObjects(int overlayIdx, cellStruct* pObject, int _var4, int var0, int var1, int _var2, int _var3)
 {
   while(pObject)
   {
@@ -1472,9 +1461,9 @@
         {
           if((pObject->backgroundPlane == _var2) || (_var2 == -1))
           {
-            if((pObject->hide == _var1) || (_var1 == -1))
+            if((pObject->freeze == var1) || (var1 == -1))
             {
-              pObject->hide = _var0;
+              pObject->freeze = var0;
             }
           }
         }
@@ -1485,7 +1474,7 @@
   }
 }
 
-int16 Op_16(void)
+int16 Op_FreezeCell(void)
 {
   /*
   int var0;
@@ -1508,7 +1497,7 @@
     var5 = currentScriptPtr->overlayNumber;
   }
 
-  configureAllObjects(var5, &objectHead, var4, var0, var1, var2, var3);
+  configureAllObjects(var5, &cellHead, var4, var0, var1, var2, var3);
 
   return 0;
 }
@@ -1578,7 +1567,7 @@
   return 0;
 }
 
-int16 Op_72(void)
+int16 Op_InitializeState2(void)
 {
   var0 = popVar();
   char* ptr = (char*)popPtr();
@@ -1620,89 +1609,92 @@
     opcodeTablePtr[i] = NULL;
   }
 
-  opcodeTablePtr[0x1] = Op_setMain5;
-  opcodeTablePtr[0x2] = Op_prepareFadeOut;
-  opcodeTablePtr[0x3] = Op_loadBackground;
-  opcodeTablePtr[0x4] = Op_loadFullBundle;
-  opcodeTablePtr[0x5] = Op_5;
-  opcodeTablePtr[0x6] = Op_startObject;
-  opcodeTablePtr[0x7] = Op_7;
-  opcodeTablePtr[0x8] = Op_8;
-  opcodeTablePtr[0x9] = Op_freeObjectList;
-  opcodeTablePtr[0xA] = Op_removeScript;
-  opcodeTablePtr[0xB] = Op_resetFilesEntries;
-  opcodeTablePtr[0xC] = Op_loadOverlay;
-  opcodeTablePtr[0xD] = Op_D;
-  opcodeTablePtr[0xE] = Op_E;
-  opcodeTablePtr[0x10] = Op_releaseScript2;
-  opcodeTablePtr[0x11] = Op_isOverlayLoaded;
-  opcodeTablePtr[0x13] = Op_message;
-  opcodeTablePtr[0x14] = Op_14;
-  opcodeTablePtr[0x16] = Op_16;
-  opcodeTablePtr[0x17] = Op_loadCtp;
-  opcodeTablePtr[0x18] = Op_18;
-  opcodeTablePtr[0x19] = Op_19;
-  opcodeTablePtr[0x1A] = Op_1A;
-  opcodeTablePtr[0x1E] = Op_1E;
-  opcodeTablePtr[0x21] = Op_21;
-  opcodeTablePtr[0x22] = Op_22;
-  opcodeTablePtr[0x24] = Op_SetStringColors;
-  opcodeTablePtr[0x28] = Op_ChangeSaveAllowedState;
-  opcodeTablePtr[0x29] = Op_freeAllPerso;
-  opcodeTablePtr[0x2A] = Op_2A;
-  opcodeTablePtr[0x2B] = Op_2B;
-  opcodeTablePtr[0x2C] = Op_2C;
-  opcodeTablePtr[0x2E] = Op_releaseOverlay;
-  opcodeTablePtr[0x2F] = Op_2F;
-  opcodeTablePtr[0x30] = Op_removeBackgroundIncrust;
-  opcodeTablePtr[0x32] = Op_freeBackgroundInscrustList;
-  opcodeTablePtr[0x37] = Op_37;
-  opcodeTablePtr[0x38] = Op_removeBackground;
-  opcodeTablePtr[0x39] = Op_SetActiveBackgroundPlane;
-  opcodeTablePtr[0x3A] = Op_3A;
-  opcodeTablePtr[0x3B] = Op_3B;
-  opcodeTablePtr[0x3C] = Op_rand;
-  opcodeTablePtr[0x3D] = Op_loadMusic;
-  opcodeTablePtr[0x3E] = Op_3E;
-  opcodeTablePtr[0x3F] = Op_3F;
-  opcodeTablePtr[0x40] = Op_40;
-  opcodeTablePtr[0x41] = Op_isFileLoaded2;
-  opcodeTablePtr[0x45] = Op_45;
+	opcodeTablePtr[0x1] = Op_FadeIn;
+	opcodeTablePtr[0x2] = Op_FadeOut;
+	opcodeTablePtr[0x3] = Op_LoadBackground;
+	opcodeTablePtr[0x4] = Op_LoadAbs;
+	opcodeTablePtr[0x5] = Op_AddCell;
+	opcodeTablePtr[0x6] = Op_AddProc;
+	opcodeTablePtr[0x7] = Op_InitializeState;
+	opcodeTablePtr[0x8] = Op_RemoveCell;
+	opcodeTablePtr[0x9] = Op_FreeCell;
+	opcodeTablePtr[0xA] = Op_RemoveProc;
+	opcodeTablePtr[0xB] = Op_RemoveFrame;
+	opcodeTablePtr[0xC] = Op_LoadOverlay;
+	opcodeTablePtr[0xD] = Op_SetColor;
+	opcodeTablePtr[0xE] = Op_PlayFX;
+	opcodeTablePtr[0xF] = NULL; // used to be debug
+	opcodeTablePtr[0x10] = Op_FreeOverlay;
+	opcodeTablePtr[0x11] = Op_FindOverlay;
+	opcodeTablePtr[0x12] = NULL; // used to be exec debug
+	opcodeTablePtr[0x13] = Op_AddMessage;
+	opcodeTablePtr[0x14] = Op_RemoveMessage;
+	opcodeTablePtr[0x15] = NULL; // user wait
+	opcodeTablePtr[0x16] = Op_FreezeCell;
+	opcodeTablePtr[0x17] = Op_LoadCt;
+	opcodeTablePtr[0x18] = Op_AddAnimation;
+	opcodeTablePtr[0x19] = Op_RemoveAnimation;
+	opcodeTablePtr[0x1A] = Op_1A;
+	opcodeTablePtr[0x1E] = Op_1E;
+	opcodeTablePtr[0x21] = Op_21;
+	opcodeTablePtr[0x22] = Op_22;
+	opcodeTablePtr[0x24] = Op_SetStringColors;
+	opcodeTablePtr[0x28] = Op_ChangeSaveAllowedState;
+	opcodeTablePtr[0x29] = Op_freeAllPerso;
+	opcodeTablePtr[0x2A] = Op_2A;
+	opcodeTablePtr[0x2B] = Op_2B;
+	opcodeTablePtr[0x2C] = Op_2C;
+	opcodeTablePtr[0x2E] = Op_releaseOverlay;
+	opcodeTablePtr[0x2F] = Op_2F;
+	opcodeTablePtr[0x30] = Op_removeBackgroundIncrust;
+	opcodeTablePtr[0x32] = Op_freeBackgroundInscrustList;
+	opcodeTablePtr[0x37] = Op_37;
+	opcodeTablePtr[0x38] = Op_removeBackground;
+	opcodeTablePtr[0x39] = Op_SetActiveBackgroundPlane;
+	opcodeTablePtr[0x3A] = Op_3A;
+	opcodeTablePtr[0x3B] = Op_3B;
+	opcodeTablePtr[0x3C] = Op_rand;
+	opcodeTablePtr[0x3D] = Op_loadMusic;
+	opcodeTablePtr[0x3E] = Op_3E;
+	opcodeTablePtr[0x3F] = Op_3F;
+	opcodeTablePtr[0x40] = Op_40;
+	opcodeTablePtr[0x41] = Op_isFileLoaded2;
+	opcodeTablePtr[0x45] = Op_45;
 	opcodeTablePtr[0x54] = Op_SetFontFileIndex;
-  opcodeTablePtr[0x56] = Op_changeCutSceneState;
-  opcodeTablePtr[0x57] = Op_GetMouseX;
-  opcodeTablePtr[0x58] = Op_GetMouseY;
-  opcodeTablePtr[0x59] = Op_GetMouseClick3;
-  opcodeTablePtr[0x5A] = Op_isFileLoaded;
-  opcodeTablePtr[0x5B] = Op_regenerateBackgroundIncrust;
-  opcodeTablePtr[0x5C] = Op_5C;
-  opcodeTablePtr[0x5E] = Op_5E;
-  opcodeTablePtr[0x60] = Op_60;
-  opcodeTablePtr[0x61] = Op_61;
-  opcodeTablePtr[0x62] = Op_62;
-  opcodeTablePtr[0x63] = Op_63;
+	opcodeTablePtr[0x56] = Op_changeCutSceneState;
+	opcodeTablePtr[0x57] = Op_GetMouseX;
+	opcodeTablePtr[0x58] = Op_GetMouseY;
+	opcodeTablePtr[0x59] = Op_GetMouseClick3;
+	opcodeTablePtr[0x5A] = Op_isFileLoaded;
+	opcodeTablePtr[0x5B] = Op_regenerateBackgroundIncrust;
+	opcodeTablePtr[0x5C] = Op_AddCellC;
+	opcodeTablePtr[0x5E] = Op_AddCellE;
+	opcodeTablePtr[0x60] = Op_60;
+	opcodeTablePtr[0x61] = Op_61;
+	opcodeTablePtr[0x62] = Op_62;
+	opcodeTablePtr[0x63] = Op_63;
 	opcodeTablePtr[0x64] = Op_startScript;
-  opcodeTablePtr[0x65] = Op_65;
-  opcodeTablePtr[0x66] = Op_66;
-  opcodeTablePtr[0x67] = Op_loadAudioResource;
-  opcodeTablePtr[0x68] = Op_freeMediumVar;
-  opcodeTablePtr[0x6A] = Op_6A;
-  opcodeTablePtr[0x6B] = Op_loadFile;
-  opcodeTablePtr[0x6C] = Op_6C;
-  opcodeTablePtr[0x6D] = Op_strcpy;
-  opcodeTablePtr[0x6E] = Op_6E;
-  opcodeTablePtr[0x6F] = Op_6F;
-  opcodeTablePtr[0x70] = Op_comment;
-  opcodeTablePtr[0x71] = Op_drawLine;
-  opcodeTablePtr[0x72] = Op_72;
-  opcodeTablePtr[0x74] = Op_GetInitVar1;
-  opcodeTablePtr[0x76] = Op_76;
-  opcodeTablePtr[0x79] = Op_EnterPlayerMenu;
-  opcodeTablePtr[0x78] = Op_78;
-  opcodeTablePtr[0x7B] = Op_7B;
-	opcodeTablePtr[0x7C] = Op_7C;
-  opcodeTablePtr[0x7D] = Op_freeAllMenu;
-  // TODO: copy the opcodes here
+	opcodeTablePtr[0x65] = Op_AutoCell;
+	opcodeTablePtr[0x66] = Op_66;
+	opcodeTablePtr[0x67] = Op_loadAudioResource;
+	opcodeTablePtr[0x68] = Op_freeMediumVar;
+	opcodeTablePtr[0x6A] = Op_6A;
+	opcodeTablePtr[0x6B] = Op_loadFile;
+	opcodeTablePtr[0x6C] = Op_6C;
+	opcodeTablePtr[0x6D] = Op_strcpy;
+	opcodeTablePtr[0x6E] = Op_6E;
+	opcodeTablePtr[0x6F] = Op_6F;
+	opcodeTablePtr[0x70] = Op_comment;
+	opcodeTablePtr[0x71] = Op_SetColorrawLine;
+	opcodeTablePtr[0x72] = Op_InitializeState2;
+	opcodeTablePtr[0x74] = Op_GetInitVar1;
+	opcodeTablePtr[0x76] = Op_InitializeState6;
+	opcodeTablePtr[0x79] = Op_PlayFXnterPlayerMenu;
+	opcodeTablePtr[0x78] = Op_InitializeState8;
+	opcodeTablePtr[0x7B] = Op_InitializeStateB;
+	opcodeTablePtr[0x7C] = Op_InitializeStateC;
+	opcodeTablePtr[0x7D] = Op_freeAllMenu;
+	// TODO: copy the opcodes here
 }
 
 int32 opcodeType8(void)

Modified: scummvm/trunk/engines/cruise/function.h
===================================================================
--- scummvm/trunk/engines/cruise/function.h	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/function.h	2007-04-27 20:31:43 UTC (rev 26624)
@@ -30,7 +30,7 @@
 extern int flag_obstacle;
 void setupOpcodeTable(void);
 int32 opcodeType8(void);
-int16 subOp22(int param);
+int16 computeZoom(int param);
 int16 subOp23(int param1, int param2);
 
 } // End of namespace Cruise

Deleted: scummvm/trunk/engines/cruise/loadSave.cpp
===================================================================
--- scummvm/trunk/engines/cruise/loadSave.cpp	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/loadSave.cpp	2007-04-27 20:31:43 UTC (rev 26624)
@@ -1,471 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2006 The ScummVM project
- *
- * cinE Engine is (C) 2004-2005 by CinE Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "cruise/cruise_main.h"
-
-namespace Cruise {
-
-void loadSavegameDataSub1(FILE* fileHandle)
-{
-  int i;
-
-  for(i=1;i<numOfLoadedOverlay;i++)
-  {
-    filesData[i].field_4 = NULL;
-    filesData[i].field_0 = NULL;
-    filesData2[i].field_0 = 0;
-
-    if(overlayTable[i].alreadyLoaded)
-    {
-      fread(&filesData2[i].field_0,2,1,fileHandle);
-
-      if(filesData2[i].field_0)
-      {
-        filesData[i].field_0 = (uint8*)mallocAndZero(filesData2[i].field_0);
-        if(filesData[i].field_0)
-        {
-          fread(filesData[i].field_0,filesData2[i].field_0,1,fileHandle);
-        }
-      }
-
-      fread(&filesData2[i].field_2,2,1,fileHandle);
-
-      if(filesData2[i].field_2)
-      {
-        filesData[i].field_4 = (uint8*)mallocAndZero(filesData2[i].field_2*12);
-        if(filesData[i].field_4)
-        {
-          fread(filesData[i].field_4,filesData2[i].field_2*12,1,fileHandle);
-        }
-      }
-    }
-  }
-}
-
-void loadScriptsFromSave(FILE* fileHandle,scriptInstanceStruct* entry)
-{
-  short int numScripts;
-  int i;
-
-  fread(&numScripts,2,1,fileHandle);
-
-  for(i=0;i<numScripts;i++)
-  {
-    scriptInstanceStruct* ptr = (scriptInstanceStruct*)mallocAndZero(sizeof(scriptInstanceStruct));
-
-    fread(ptr,0x1C,1,fileHandle); // use 0x1C as our scriptInstanceStruct is bigger than in original because of cross platform problems
-
-    fread(&ptr->varA,2,1,fileHandle);
-
-    if(ptr->varA)
-    {
-      ptr->var6 = (uint8*)mallocAndZero(ptr->varA);
-
-      fread(ptr->var6,ptr->varA,1,fileHandle);
-    }
-
-    /////////
-    ptr->bitMask = *((int16*)ptr+1);
-    /////////
-
-    ptr->nextScriptPtr = 0;
-
-    entry->nextScriptPtr = ptr;
-    entry = ptr;
-  }
-}
-
-void loadSavegameDataSub2(FILE * f)
-{
-  unsigned short int n_chunks;
-  int i;
-  objectStruct *p;
-  objectStruct *t;
-
-  objectHead.next = NULL; // Not in ASM code, but I guess the variable is defaulted
-                          // to this value in the .exe
-
-  fread(&n_chunks, 2, 1, f);
-  // BIG ENDIAN MACHINES, PLEASE SWAP IT
-
-  p = &objectHead;
-
-  for (i = 0; i < n_chunks; i++)
-  {
-    t = (objectStruct *) mallocAndZero(sizeof(objectStruct));
-
-    fseek(f, 4, SEEK_CUR);
-    fread(&t->idx, 1, 0x30, f);
-
-    t->next = NULL;
-		p->next = t;
-    t->prev = objectHead.prev;
-    objectHead.prev = t;
-    p = t;
-  }
-}
-
-void loadSavegameActor(FILE* fileHandle)
-{
-  short int numEntry;
-  actorStruct* ptr;
-  int i;
-
-  fread(&numEntry,2,1,fileHandle);
-
-  ptr = &actorHead;
-
-  for(i=0;i<numEntry;i++)
-  {
-    actorStruct* current = (actorStruct*)mallocAndZero(sizeof(actorStruct));
-    fseek(fileHandle, 4, SEEK_CUR);
-    fread(&current->var4,0x26,1,fileHandle);
-
-    current->next = NULL;
-    ptr->next = current;
-    current->prev = actorHead.prev;
-    actorHead.prev = current;
-    ptr = current->next;
-  }
-}
-
-void loadSavegameDataSub5(FILE* fileHandle)
-{
-  if(var1)
-  {
-    fread(&saveVar1,1,1,fileHandle);
-
-    if(saveVar1)
-    {
-      fread(saveVar2,saveVar1,1,fileHandle);
-    }
-  }
-  else
-  {
-    fread(&saveVar1,1,1,fileHandle);
-  }
-
-}
-
-void loadSavegameDataSub6(FILE* fileHandle)
-{
-  int32 var;
-
-  fread(&var,4,1,fileHandle);
-  flipLong(&var);
-
-  if(var)
-  {
-    int i;
-    
-    fread(&numberOfWalkboxes, 2, 1, fileHandle);
-
-    if(numberOfWalkboxes)
-    {
-      fread(walkboxType, numberOfWalkboxes * 2, 1, fileHandle);
-      fread(walkboxType, numberOfWalkboxes * 2, 1, fileHandle);
-    }
-
-    for(i=0;i<10;i++)
-    {
-      fread(&persoTable[i],4,1,fileHandle);
-
-      if(persoTable[i])
-      {
-        assert(sizeof(persoStruct) == 0x6AA);
-        persoTable[i] = (persoStruct*)mallocAndZero(sizeof(persoStruct));
-        fread(persoTable[i],0x6AA,1,fileHandle);
-      }
-    }
-  }
-}
-
-
-int loadSavegameData(int saveGameIdx)
-{
-  char buffer[256];
-  FILE* fileHandle;
-  char saveIdentBuffer[6];
-  int j;
-  int initVar1Save;
-  objectStruct* currentObjectHead;
-
-  sprintf(buffer,"CR.%d",saveGameIdx);
-
-  fileHandle = fopen(buffer,"rb");
-
-  if(!fileHandle)
-  {
-    printInfoBlackBox("Sauvegarde non trouv\xE9e...");
-    waitForPlayerInput();
-    return(-1);
-  }
-
-  printInfoBlackBox("Chargement en cours...");
-
-  fread(saveIdentBuffer,6,1,fileHandle);
-
-  if(strcmp(saveIdentBuffer,"SAVPC"))
-  {
-    fclose(fileHandle);
-    return(-1);
-  }
-
-  //initVars();
-
-  fread(&var1,2,1,fileHandle);
-  fread(&var2,2,1,fileHandle);
-  fread(&var3,2,1,fileHandle);
-  fread(&var4,2,1,fileHandle);
-  fread(&userEnabled,2,1,fileHandle);
-  fread(&var6,2,1,fileHandle);
-  fread(&var7,2,1,fileHandle);
-  fread(&var8,2,1,fileHandle);
-  fread(&userDelay,2,1,fileHandle);
-  fread(&sysKey,2,1,fileHandle);
-  fread(&var11,2,1,fileHandle);
-  fread(&var12,2,1,fileHandle);
-  fread(&var13,2,1,fileHandle);
-  fread(&var14,2,1,fileHandle);
-  fread(&affichePasMenuJoueur,2,1,fileHandle);
-  fread(&var20,2,1,fileHandle);
-  fread(&var22,2,1,fileHandle);
-  fread(&var23,2,1,fileHandle);
-  fread(&var24,2,1,fileHandle);
-  fread(&automaticMode,2,1,fileHandle);
-
-  // video param (not loaded in EGA mode)
-
-  fread(&video4,2,1,fileHandle);
-  fread(&video2,2,1,fileHandle);
-  fread(&video3,2,1,fileHandle);
-  fread(&colorOfSelectedSaveDrive,2,1,fileHandle);
-
-  //
-
-  fread(&var30,2,1,fileHandle);
-  fread(&var31,2,1,fileHandle);
-  fread(&var34,2,1,fileHandle);
-  fread(&var35,2,1,fileHandle);
-  fread(&animationStart,2,1,fileHandle);
-  fread(&currentActiveBackgroundPlane,2,1,fileHandle);
-  fread(&initVar3,2,1,fileHandle);
-  fread(&initVar2,2,1,fileHandle);
-  fread(&var22,2,1,fileHandle);
-  fread(&main5,2,1,fileHandle);
-  fread(&numOfLoadedOverlay,2,1,fileHandle);
-  fread(&setup1,2,1,fileHandle);
-  fread(&fontFileIndex,2,1,fileHandle);
-  fread(&currentActiveMenu,2,1,fileHandle);
-  fread(&main7,2,1,fileHandle); // ok
-  fread(&main17,2,1,fileHandle);
-  fread(&main14,2,1,fileHandle);
-  fread(&main8,2,1,fileHandle);
-  fread(&var39,2,1,fileHandle);
-  fread(&var42,2,1,fileHandle);
-  fread(&var45,2,1,fileHandle);
-  fread(&var46,2,1,fileHandle);
-  fread(&var47,2,1,fileHandle);
-  fread(&var48,2,1,fileHandle);
-  fread(&flagCt,2,1,fileHandle);
-  fread(&var41,2,1,fileHandle);
-  fread(&entrerMenuJoueur,2,1,fileHandle);
-
-  fread(var50,64,1,fileHandle);
-  fread(var50,64,1,fileHandle); // Hu ? why 2 times ?
-  fread(&systemStrings,sizeof(systemStrings),1,fileHandle); // ok
-  fread(currentCtpName,40,1,fileHandle);
-  fread(backgroundTable,120,1,fileHandle);
-  fread(palette,256,2,fileHandle); // ok
-  fread(initVar5,24,1,fileHandle);
-  fread(globalVars,setup1*2,1,fileHandle);
-  fread(filesDatabase,9766,1,fileHandle);
-  fread(overlayTable,40*numOfLoadedOverlay,1,fileHandle); // ok
-  fread(mediumVar,0x880,1,fileHandle);
-
-  loadSavegameDataSub1(fileHandle);
-  loadScriptsFromSave(fileHandle,&scriptHandle2);
-  loadScriptsFromSave(fileHandle,&scriptHandle1);
-
-  loadSavegameDataSub2(fileHandle);
-  loadBackgroundIncrustFromSave(fileHandle);
-  loadSavegameActor(fileHandle);
-  loadSavegameDataSub5(fileHandle);
-  loadSavegameDataSub6(fileHandle);
-
-  fclose(fileHandle); // finished with loading !!!!! Yatta !
-
-  for(j=0;j<64;j++)
-  {
-    mediumVar[j].ptr=NULL;
-  }
-
-  for(j=1;j<numOfLoadedOverlay;j++)
-  {
-    if(overlayTable[j].alreadyLoaded)
-    {
-      overlayTable[j].alreadyLoaded = 0;
-      loadOverlay((uint8*)overlayTable[j].overlayName);
-
-      if(overlayTable[j].alreadyLoaded)
-      {
-        ovlDataStruct* ovlData = overlayTable[j].ovlData;
-
-        if(filesData[j].field_0)
-        {
-          if(ovlData->data4Ptr)
-          {
-            free(ovlData->data4Ptr);
-          }
-
-          ovlData->data4Ptr = (uint8*)filesData[j].field_0;
-          ovlData->sizeOfData4 = filesData2[j].field_0;
-        }
-
-        if(filesData[j].field_4)
-        {
-          if(ovlData->objData2WorkTable)
-          {
-            free(ovlData->objData2WorkTable);
-          }
-
-          ovlData->objData2WorkTable = (objectParams*)filesData[j].field_4; // TODO: fix !
-          ovlData->size9 = filesData2[j].field_2;
-        }
-
-      }
-    }
-  }
-
-  updateAllScriptsImports();
-
-  saveVar6[0] = 0;
-
-  initVar1Save = initVar1;
-
-  for(j=0;j<257;j++)
-  {
-    if(filesDatabase[j].subData.ptr)
-    {
-      int i;
-      int k;
-
-      for(i=j+1;i<257;i++)
-      {
-        if(filesDatabase[i].subData.ptr)
-        {
-          if(strcmpuint8(filesDatabase[j].subData.name,filesDatabase[i].subData.name))
-          {
-            break;
-          }
-        }
-        else
-        {
-          break;
-        }
-      }
-
-      for(k=j;k<i;k++)
-      {
-        if(filesDatabase[k].subData.ptr2)
-          initVar1 = 0;
-
-        filesDatabase[k].subData.ptr = NULL;
-        filesDatabase[k].subData.ptr2 = NULL;
-      }
-
-      if(i<2)
-      {
-        printf("Unsupported mono file load!\n");
-        exit(1);
-        //loadFileMode1(filesDatabase[j].subData.name,filesDatabase[j].subData.var4);
-      }
-      else
-      {
-        loadFileMode2((uint8*)filesDatabase[j].subData.name,filesDatabase[j].subData.index, j, i-j);
-        j = i-1;
-      }
-
-      initVar1 = initVar1Save;
-    }
-  }
-
-  saveVar6[0] = 0;
-
-  currentObjectHead = objectHead.next;
-
-  while(currentObjectHead)
-  {
-    if(currentObjectHead->type == 5)
-    {
-      uint8* ptr = mainProc14(currentObjectHead->overlay,currentObjectHead->idx);
-
-      ASSERT(0);
-
-      if(ptr)
-      {
-        ASSERT(0);
-        //*(int16*)(currentobjectHead->datas+0x2E) = getSprite(ptr,*(int16*)(currentobjectHead->datas+0xE));
-      }
-      else
-      {
-        //*(int16*)(currentobjectHead->datas+0x2E) = 0;
-      }
-    }
-
-    currentObjectHead = currentObjectHead->next;
-  }
-
-  //TODO: here, restart music
-  
-  if(strlen((char*)currentCtpName))
-  {
-    ctpVar1 = 1;
-    loadCtp(currentCtpName);
-    ctpVar1 = 0;
-  }
-
-  //prepareFadeOut();
-  //gfxModuleData.gfxFunction8();
-
-  for(j=0;j<8;j++)
-  {
-    if(strlen((char*)backgroundTable[j].name))
-    {
-      loadBackground(backgroundTable[j].name,j);
-    }
-  }
-
-  regenerateBackgroundIncrust(&backgroundIncrustHead);
-
-  // to finish
-
-  changeCursor(0);
-  mainDraw(1);
-  flipScreen();
-
-  return(0);
-}
-
-} // End of namespace Cruise

Deleted: scummvm/trunk/engines/cruise/loadSave.h
===================================================================
--- scummvm/trunk/engines/cruise/loadSave.h	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/loadSave.h	2007-04-27 20:31:43 UTC (rev 26624)
@@ -1,34 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2006 The ScummVM project
- *
- * cinE Engine is (C) 2004-2005 by CinE Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef _LOADSAVE_H_
-#define _LOADSAVE_H_
-
-namespace Cruise {
-
-int loadSavegameData(int saveGameIdx);
-
-} // End of namespace Cruise
-
-#endif

Modified: scummvm/trunk/engines/cruise/mainDraw.cpp
===================================================================
--- scummvm/trunk/engines/cruise/mainDraw.cpp	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/mainDraw.cpp	2007-04-27 20:31:43 UTC (rev 26624)
@@ -36,7 +36,7 @@
 	short int field_4;
 	short int field_6;
 	short int field_8;
-	objectStruct* field_A;
+	cellStruct* field_A;
 };
 
 typedef struct drawVar1Struct drawVar1Struct;
@@ -54,7 +54,7 @@
 
 		if(pCurrent->field_6 == 5)
 		{
-			Op_7Sub(pCurrent->field_2, pCurrent->field_4, pCurrent->field_8);
+			Op_InitializeStateSub(pCurrent->field_2, pCurrent->field_4, pCurrent->field_8);
 		}
 		else
 		{
@@ -563,7 +563,7 @@
 }
 
 // draw poly sprite (OLD: mainDrawSub1)
-void mainDrawPolygons(int fileIndex, objectStruct* pObject, int X, int scale, int Y, char* destBuffer, char* dataPtr)
+void mainDrawPolygons(int fileIndex, cellStruct* pObject, int X, int scale, int Y, char* destBuffer, char* dataPtr)
 {
 	int   newX;
 	int   newY;
@@ -625,7 +625,7 @@
 
 	if(pObject)
 	{
-		objectStruct* pCurrentObject = pObject;
+		cellStruct* pCurrentObject = pObject;
 
 		do
 		{
@@ -701,7 +701,7 @@
 	}
 }
 
-void mainDrawSub4(int objX1, int var_6, objectStruct* currentObjPtr, char* data1, int objY2, int objX2, char* output, char* data2)
+void mainDrawSub4(int objX1, int var_6, cellStruct* currentObjPtr, char* data1, int objY2, int objX2, char* output, char* data2)
 {
 	int x = 0;
 	int y = 0;
@@ -724,7 +724,7 @@
 	}
 }
 
-void mainDraw5(int overlayIdx, int idx, int field_28, objectStruct* pObject, int newVal)
+void mainDraw5(int overlayIdx, int idx, int field_28, cellStruct* pObject, int newVal)
 {
 	drawVar1Struct* pNewEntry;
 
@@ -916,13 +916,14 @@
 void mainDraw(int16 param)
 {
 	uint8* bgPtr;
-	objectStruct* currentObjPtr;
+	cellStruct* currentObjPtr;
 	int16 currentObjIdx;
 	int16 objX1 = 0;
 	int16 objY1 = 0;
 	int16 objZ1 = 0;
 	int16 objX2;
 	int16 objY2;
+	int16 objZ2;
 	int16 spriteHeight;
 
 
@@ -940,31 +941,24 @@
 
 	drawVar1.next = NULL;
 
-	currentObjPtr = objectHead.next;
+	currentObjPtr = cellHead.next;
 
 #ifdef _DEBUG
-	polyOutputBuffer = (char*)bgPtr;
-	drawCtp();
+/*	polyOutputBuffer = (char*)bgPtr;
+	drawCtp(); */
 #endif
 
-	//-------------------------------------------------- DRAW OBJECTS TYPE 4 -----------------------------------------//
+	//-------------------------------------------------- PROCESS SPRITES -----------------------------------------//
 
 	while(currentObjPtr)
 	{
-		if((currentActiveBackgroundPlane == currentObjPtr->backgroundPlane) && (currentObjPtr->hide == 0) && (currentObjPtr->type == 4))
+		if((currentActiveBackgroundPlane == currentObjPtr->backgroundPlane) && (currentObjPtr->freeze == 0) && (currentObjPtr->type == OBJ_SPRITE))
 		{
-			int16 fileIdx;
 			objectParamsQuery params;
 
 			currentObjIdx = currentObjPtr->idx;
 
-			if((currentObjPtr->followObjectOverlayIdx == currentObjPtr->overlay) && (currentObjPtr->followObjectIdx == currentObjPtr->idx))
-			{
-				objX1 = 0;
-				objY1 = 0;
-				objZ1 = 0;
-			}
-			else
+			if((currentObjPtr->followObjectOverlayIdx != currentObjPtr->overlay) || (currentObjPtr->followObjectIdx != currentObjPtr->idx))
 			{	
 				// Declaring this twice ?
 				// objectParamsQuery params;
@@ -975,73 +969,75 @@
 				objY1 = params.Y;
 				objZ1 = params.fileIdx;
 			}
+			else
+			{
+				objX1 = 0;
+				objY1 = 0;
+				objZ1 = 0;
+			}
 
 			getMultipleObjectParam(currentObjPtr->overlay, currentObjIdx, &params);
 
 			objX2 = objX1 + params.X;
 			objY2 = objY1 + params.Y;
+			objZ2 = params.fileIdx;
 
-			fileIdx = params.fileIdx;
-
-			if(fileIdx >= 0)
+			if(objZ2 >= 0)
 			{
-				fileIdx += objZ1;
+				objZ2 += objZ1;
 			}
 
-			if((params.var5 >= 0) && (fileIdx >= 0) && filesDatabase[fileIdx].subData.ptr)
+			if((params.var5 >= 0) && (objZ2 >= 0) && filesDatabase[objZ2].subData.ptr)
 			{
-				if(filesDatabase[fileIdx].subData.resourceType == 8)
+				if(filesDatabase[objZ2].subData.resourceType == 8) // Poly
 				{
-					mainDrawPolygons(fileIdx, currentObjPtr, objX2, params.scale, objY2, (char*)gfxModuleData.pPage10, (char*)filesDatabase[fileIdx].subData.ptr); // poly
+					mainDrawPolygons(objZ2, currentObjPtr, objX2, params.scale, objY2, (char*)gfxModuleData.pPage10, (char*)filesDatabase[objZ2].subData.ptr); // poly
 				}
-				else if(filesDatabase[fileIdx].subData.resourceType == 6)
+				else if(filesDatabase[objZ2].subData.resourceType == 6) // sound
 				{
 				}
-				else if(filesDatabase[fileIdx].resType == 1)
+				else if(filesDatabase[objZ2].resType == 1) //(num plan == 1)
 				{
 				}
-				else if(filesDatabase[fileIdx].subData.resourceType == 4)
+				else if(filesDatabase[objZ2].subData.resourceType == 4)
 				{
-					objX1        = filesDatabase[fileIdx].width;	// width
-					spriteHeight = filesDatabase[fileIdx].height;	// height
+					objX1        = filesDatabase[objZ2].width;	// width
+					spriteHeight = filesDatabase[objZ2].height;	// height
 
-					if(filesDatabase[fileIdx].subData.ptr)
+					if(filesDatabase[objZ2].subData.ptr)
 					{
-						currentTransparent = filesDatabase[fileIdx].subData.transparency;
+						currentTransparent = filesDatabase[objZ2].subData.transparency;
 
-						mainDrawSub4(objX1, spriteHeight, currentObjPtr, (char*)filesDatabase[fileIdx].subData.ptr, objY2, objX2, (char*)gfxModuleData.pPage10, (char*)filesDatabase[fileIdx].subData.ptr);
+						mainDrawSub4(objX1, spriteHeight, currentObjPtr, (char*)filesDatabase[objZ2].subData.ptr, objY2, objX2, (char*)gfxModuleData.pPage10, (char*)filesDatabase[objZ2].subData.ptr);
 					}
 				}
 			}
 
-			if((currentObjPtr->field_26 != 0) && (param == 0))
+			if((currentObjPtr->animStep != 0) && (param == 0))
 			{
 				if(currentObjPtr->currentAnimDelay <= 0) 
 				{
 					int newVal;
-					objX1 = 1;
+					bool change = true;
 
-					newVal = getValueFromObjectQuerry(&params,currentObjPtr->field_28) + currentObjPtr->field_26;
+					newVal = getValueFromObjectQuerry(&params,currentObjPtr->field_28) + currentObjPtr->animStep;
 
-					if(currentObjPtr->field_26 > 0)
+					if(currentObjPtr->animStep > 0)
 					{
-						if(currentObjPtr->field_22 < newVal)
-						{
-							if(currentObjPtr->field_30 >= 0)
+						if(newVal > currentObjPtr->field_22)
+						{			
+							if(currentObjPtr->field_30)
 							{
-								int16 data2;
-
 								newVal = currentObjPtr->field_20;
-
-								if(currentObjPtr->field_30 > 0)
-								{
-									currentObjPtr->field_30--;
-								}
-
+								currentObjPtr->field_30--;
+							}
+							else
+							{
+								int16 data2;
 								data2 = currentObjPtr->field_20;
 
-								objX1 = 0;
-								currentObjPtr->field_26 = 0;
+								change = false;
+								currentObjPtr->animStep = 0;
 
 								if(currentObjPtr->field_2A) // should we resume the script ?
 								{
@@ -1049,11 +1045,10 @@
 									{
 										changeScriptParamInList(currentObjPtr->field_18, currentObjPtr->field_16, &scriptHandle2, 0, -1);
 									}
-									else
-										if(currentObjPtr->field_1A == 30)
-										{
-											changeScriptParamInList(currentObjPtr->field_18, currentObjPtr->field_16, &scriptHandle1, 0, -1);
-										}
+									else if(currentObjPtr->field_1A == 30)
+									{
+										changeScriptParamInList(currentObjPtr->field_18, currentObjPtr->field_16, &scriptHandle1, 0, -1);
+									}
 								}
 								newVal = data2;
 							}
@@ -1072,22 +1067,21 @@
 						currentObjPtr->currentAnimDelay = currentObjPtr->nextAnimDelay;
 					}
 
-					if(currentObjPtr->field_2C >= 0 && (currentObjPtr->field_2C == newVal) && currentObjPtr->field_2A != 0)
+					if((currentObjPtr->field_2C >= 0) && (currentObjPtr->field_2C == newVal) && (currentObjPtr->field_2A != 0))
 					{
 						if(currentObjPtr->field_1A == 20)
 						{
 							changeScriptParamInList(currentObjPtr->field_18, currentObjPtr->field_16, &scriptHandle2, 0, -1);
 						}
-						else
-							if(currentObjPtr->field_1A == 30)
-							{
-								changeScriptParamInList(currentObjPtr->field_18, currentObjPtr->field_16, &scriptHandle1, 0, -1);
-							}
+						else if(currentObjPtr->field_1A == 30)
+						{
+							changeScriptParamInList(currentObjPtr->field_18, currentObjPtr->field_16, &scriptHandle1, 0, -1);
+						}
 
-							currentObjPtr->field_2A = 0;
+						currentObjPtr->field_2A = 0;
 					}
 
-					if(objX1)
+					if(change)
 					{
 						mainDraw5(currentObjPtr->overlay, currentObjPtr->idx, currentObjPtr->field_28, currentObjPtr, newVal);
 					}
@@ -1109,11 +1103,11 @@
 
 	//-------------------------------------------------- DRAW OBJECTS TYPE 5 -----------------------------------------//
 
-	currentObjPtr = objectHead.next;
+	currentObjPtr = cellHead.next;
 
 	while(currentObjPtr)
 	{
-		if(currentObjPtr->type == 5 && currentObjPtr->hide == 0)
+		if(currentObjPtr->type == 5 && currentObjPtr->freeze == 0)
 		{
 			mainSprite(currentObjPtr->field_A, currentObjPtr->field_C, currentObjPtr->gfxPtr, gfxModuleData.pPage10, currentObjPtr->field_10, currentObjPtr->spriteIdx);
 			var20 = 1;

Modified: scummvm/trunk/engines/cruise/mainDraw.h
===================================================================
--- scummvm/trunk/engines/cruise/mainDraw.h	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/mainDraw.h	2007-04-27 20:31:43 UTC (rev 26624)
@@ -39,7 +39,7 @@
 void flipScreen(void);
 void buildPolyModel(int X, int Y, int scale, char* ptr2, char* destBuffer, char* dataPtr);
 void getPolyData(int fileIndex, int X, int Y, int *newScale, int *newY, int *newX, char **newDataPtr, int scale, char* dataPtr);
-void mainDrawSub4(int objX1, int var_6, objectStruct* currentObjPtr, char* data1, int objY2, int objX2, char* output, char* data2);
+void mainDrawSub4(int objX1, int var_6, cellStruct* currentObjPtr, char* data1, int objY2, int objX2, char* output, char* data2);
 char* drawPolyMode2(char* si, int cx);
 
 } // End of namespace Cruise

Modified: scummvm/trunk/engines/cruise/object.cpp
===================================================================
--- scummvm/trunk/engines/cruise/object.cpp	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/object.cpp	2007-04-27 20:31:43 UTC (rev 26624)
@@ -118,99 +118,6 @@
   return 0;
 }
 
-objectStruct* addObject(int16 overlayIdx,int16 param2,objectStruct* pHead,int16 scriptType,int16 scriptNumber,int16 scriptOverlay, int16 param3, int16 param4)
-{
-  int16 var;
-
-  objectStruct* newElement;
-  objectStruct* currentHead = pHead;
-  objectStruct* currentHead2;
-  objectStruct* currentHead3;
-
-  if(getSingleObjectParam(overlayIdx,param2,2,&var)<0)
-  {
-    return 0;
-  }
-
-  currentHead3 = currentHead;
-  currentHead2 = currentHead->next;
-
-  while(currentHead2)
-  {
-    if(currentHead2->type == 3)
-    {
-      break;
-    }
-
-    if(currentHead2->type != 5)
-    {
-      int16 lvar2;
-
-      getSingleObjectParam(currentHead2->overlay,currentHead2->idx,2,&lvar2);
-
-      if(lvar2 > var)
-        break;
-    }
-
-    currentHead3 = currentHead2;
-    currentHead2 = currentHead2->next;
-  }
-
-  if(currentHead2)
-  {
-    if( (currentHead2->overlay == overlayIdx) &&
-        (currentHead2->backgroundPlane == param3) &&
-        (currentHead2->idx == param2) &&
-        (currentHead2->type == param4))
-
-    return NULL;
-  }
-
-  currentHead = currentHead2;
-
-  newElement = (objectStruct*)mallocAndZero(sizeof(objectStruct));
-
-  if(!newElement)
-    return 0;
-
-  newElement->next = currentHead3->next;
-  currentHead3->next = newElement;
-
-  newElement->idx = param2;
-  newElement->type = param4;
-  newElement->backgroundPlane = param3;
-  newElement->overlay = overlayIdx;
-  newElement->hide = 0;
-  newElement->field_16 = scriptNumber;
-  newElement->field_18 = scriptOverlay;
-  newElement->gfxPtr = NULL;
-  newElement->followObjectIdx = param2;
-  newElement->followObjectOverlayIdx = overlayIdx;
-  newElement->field_1A = scriptType;
-  newElement->field_20 = 0;
-  newElement->field_22 = 0;
-  newElement->nextAnimDelay = 0;
-  newElement->field_2C = 0;
-  newElement->currentAnimDelay = 0;
-  newElement->field_2A = 0;
-  newElement->field_26 = 0;
-  newElement->field_30 = 0;
-
-  if(currentHead)
-  {
-    newElement->prev = currentHead->prev;
-    currentHead->prev = newElement;
-  }
-  else
-  {
-    newElement->prev = pHead->prev;
-    pHead->prev = newElement;
-  }
-  
-
-  return newElement;
-}
-
 void setObjectPosition(int16 param1,int16 objIdx,int16 param3,int16 param4)
 {
 	objDataStruct* ptr;
@@ -279,15 +186,15 @@
 	}
 }
 
-void Op_7Sub1(int16 param1, int16 param2, objectStruct* objPtr)
+void Op_InitializeStateSub1(int16 param1, int16 param2, cellStruct* objPtr)
 {
   int16 var;
-  objectStruct* var8_;
-  objectStruct* var40;
-  objectStruct* var3E;
-  objectStruct* currentObjPtrPrevious;
-  objectStruct* currentObjPtr2;
-  objectStruct* match;
+  cellStruct* var8_;
+  cellStruct* var40;
+  cellStruct* var3E;
+  cellStruct* currentObjPtrPrevious;
+  cellStruct* currentObjPtr2;
+  cellStruct* match;
 
   getSingleObjectParam(param1,param2,2,&var);
 
@@ -362,7 +269,7 @@
 
   if(match)
   {
-    objectStruct* temp;
+    cellStruct* temp;
 
     temp = var8_->next;
 
@@ -383,7 +290,7 @@
   }
 }
 
-int16 Op_7Sub(int ovlIdx,int objIdx,int param2)
+int16 Op_InitializeStateSub(int ovlIdx,int objIdx,int param2)
 {
   objDataStruct* ptr;
 //  uint16 param;
@@ -401,7 +308,7 @@
   case 0:
     {
       globalVars[overlayTable[ovlIdx].field_14 + ptr->var6] = param2;
-      Op_7Sub1(ovlIdx,param2,&objectHead);
+      Op_InitializeStateSub1(ovlIdx,param2,&cellHead);
       break;
     }
   case 1:
@@ -421,12 +328,12 @@
 
       destEntry->var5 = param2;
 
-      Op_7Sub1(ovlIdx,param2,&objectHead);
+      Op_InitializeStateSub1(ovlIdx,param2,&cellHead);
       break;
     }
   default:
     {
-      printf("Unsupported param = %d in Op_7Sub\n",ptr->var1);
+      printf("Unsupported param = %d in Op_InitializeStateSub\n",ptr->var1);
      // exit(1);
     }
   }

Modified: scummvm/trunk/engines/cruise/object.h
===================================================================
--- scummvm/trunk/engines/cruise/object.h	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/object.h	2007-04-27 20:31:43 UTC (rev 26624)
@@ -38,38 +38,8 @@
 
 typedef struct gfxEntryStruct gfxEntryStruct;
 
-struct objectStruct
-{
-  struct objectStruct* next;
-  struct objectStruct* prev;
-  int16 idx;
-  int16 type;
-  int16 overlay ;
-  int16 field_A ;
-  int16 field_C ;
-  int16 spriteIdx ;
-  int16 field_10;
-  int16 backgroundPlane;
-  int16 hide;
-  int16 field_16;
-  int16 field_18;
-  int16 field_1A;
-  int16 followObjectOverlayIdx;
-  int16 followObjectIdx;
-  int16 field_20;
-  int16 field_22;
-  int16 nextAnimDelay;
-  int16 field_26;
-  int16 field_28;
-  int16 field_2A;
-  int16 field_2C;
-  int16 currentAnimDelay;
-  int16 field_30;
-  gfxEntryStruct* gfxPtr;
-};
+#define	OBJ_SPRITE 4
 
-typedef struct objectStruct objectStruct;
-
 struct objectParamsQuery
 {
 	int16 X;
@@ -84,7 +54,6 @@
 
 typedef struct objectParamsQuery objectParamsQuery;
 
-objectStruct* addObject(int16 overlayIdx,int16 param2,objectStruct* pHead,int16 scriptType,int16 scriptNumber,int16 scriptOverlay, int16 param3, int16 param4);
 objDataStruct* getObjectDataFromOverlay(int ovlIdx,int objIdx);
 int16 getSingleObjectParam(int16 overlayIdx,int16 param2,int16 param3,int16* returnParam);
 int16 getMultipleObjectParam(int16 overlayIdx,int16 objectIdx,objectParamsQuery* returnParam);

Modified: scummvm/trunk/engines/cruise/perso.cpp
===================================================================
--- scummvm/trunk/engines/cruise/perso.cpp	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/perso.cpp	2007-04-27 20:31:43 UTC (rev 26624)
@@ -230,7 +230,7 @@
 	resx_y[0]=cor_joueur[*inc_droite][0];
 	resx_y[1]=cor_joueur[*inc_droite][1];
 	resx_y[2]=*dir_perso;
-	resx_y[3]=subOp22(resx_y[1]);
+	resx_y[3]=computeZoom(resx_y[1]);
 
 	getPixel(resx_y[0],resx_y[1]);
 	resx_y[4]=computedVar14;

Copied: scummvm/trunk/engines/cruise/saveload.cpp (from rev 26605, scummvm/trunk/engines/cruise/loadSave.cpp)
===================================================================
--- scummvm/trunk/engines/cruise/saveload.cpp	                        (rev 0)
+++ scummvm/trunk/engines/cruise/saveload.cpp	2007-04-27 20:31:43 UTC (rev 26624)
@@ -0,0 +1,443 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2006 The ScummVM project
+ *
+ * cinE Engine is (C) 2004-2005 by CinE Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "cruise/cruise_main.h"
+
+namespace Cruise {
+
+void loadSavegameDataSub1(FILE* fileHandle)
+{
+  int i;
+
+  for(i=1;i<numOfLoadedOverlay;i++)
+  {
+    filesData[i].field_4 = NULL;
+    filesData[i].field_0 = NULL;
+    filesData2[i].field_0 = 0;
+
+    if(overlayTable[i].alreadyLoaded)
+    {
+      fread(&filesData2[i].field_0,2,1,fileHandle);
+
+      if(filesData2[i].field_0)
+      {
+        filesData[i].field_0 = (uint8*)mallocAndZero(filesData2[i].field_0);
+        if(filesData[i].field_0)
+        {
+          fread(filesData[i].field_0,filesData2[i].field_0,1,fileHandle);
+        }
+      }
+
+      fread(&filesData2[i].field_2,2,1,fileHandle);
+
+      if(filesData2[i].field_2)
+      {
+        filesData[i].field_4 = (uint8*)mallocAndZero(filesData2[i].field_2*12);
+        if(filesData[i].field_4)
+        {
+          fread(filesData[i].field_4,filesData2[i].field_2*12,1,fileHandle);
+        }
+      }
+    }
+  }
+}
+
+void loadScriptsFromSave(FILE* fileHandle,scriptInstanceStruct* entry)
+{
+  short int numScripts;
+  int i;
+
+  fread(&numScripts,2,1,fileHandle);
+
+  for(i=0;i<numScripts;i++)
+  {
+    scriptInstanceStruct* ptr = (scriptInstanceStruct*)mallocAndZero(sizeof(scriptInstanceStruct));
+
+    fread(ptr,0x1C,1,fileHandle); // use 0x1C as our scriptInstanceStruct is bigger than in original because of cross platform problems
+
+    fread(&ptr->varA,2,1,fileHandle);
+
+    if(ptr->varA)
+    {
+      ptr->var6 = (uint8*)mallocAndZero(ptr->varA);
+
+      fread(ptr->var6,ptr->varA,1,fileHandle);
+    }
+
+    /////////
+    ptr->bitMask = *((int16*)ptr+1);
+    /////////
+
+    ptr->nextScriptPtr = 0;
+
+    entry->nextScriptPtr = ptr;
+    entry = ptr;
+  }
+}
+
+void loadSavegameActor(FILE* fileHandle)
+{
+  short int numEntry;
+  actorStruct* ptr;
+  int i;
+
+  fread(&numEntry,2,1,fileHandle);
+
+  ptr = &actorHead;
+
+  for(i=0;i<numEntry;i++)
+  {
+    actorStruct* current = (actorStruct*)mallocAndZero(sizeof(actorStruct));
+    fseek(fileHandle, 4, SEEK_CUR);
+    fread(current,0x26,1,fileHandle);
+
+    current->next = NULL;
+    ptr->next = current;
+    current->prev = actorHead.prev;
+    actorHead.prev = current;
+    ptr = current->next;
+  }
+}
+
+void loadSavegameDataSub5(FILE* fileHandle)
+{
+  if(var1)
+  {
+    fread(&saveVar1,1,1,fileHandle);
+
+    if(saveVar1)
+    {
+      fread(saveVar2,saveVar1,1,fileHandle);
+    }
+  }
+  else
+  {
+    fread(&saveVar1,1,1,fileHandle);
+  }
+
+}
+
+void loadSavegameDataSub6(FILE* fileHandle)
+{
+  int32 var;
+
+  fread(&var,4,1,fileHandle);
+  flipLong(&var);
+
+  if(var)
+  {
+    int i;
+    
+    fread(&numberOfWalkboxes, 2, 1, fileHandle);
+
+    if(numberOfWalkboxes)
+    {
+      fread(walkboxType, numberOfWalkboxes * 2, 1, fileHandle);
+      fread(walkboxType, numberOfWalkboxes * 2, 1, fileHandle);
+    }
+
+    for(i=0;i<10;i++)
+    {
+      fread(&persoTable[i],4,1,fileHandle);
+
+      if(persoTable[i])
+      {
+        assert(sizeof(persoStruct) == 0x6AA);
+        persoTable[i] = (persoStruct*)mallocAndZero(sizeof(persoStruct));
+        fread(persoTable[i],0x6AA,1,fileHandle);
+      }
+    }
+  }
+}
+
+
+int loadSavegameData(int saveGameIdx)
+{
+  char buffer[256];
+  FILE* fileHandle;
+  char saveIdentBuffer[6];
+  int j;
+  int initVar1Save;
+  cellStruct* currentcellHead;
+
+  sprintf(buffer,"CR.%d",saveGameIdx);
+
+  fileHandle = fopen(buffer,"rb");
+
+  if(!fileHandle)
+  {
+    printInfoBlackBox("Sauvegarde non trouv\xE9e...");
+    waitForPlayerInput();
+    return(-1);
+  }
+
+  printInfoBlackBox("Chargement en cours...");
+
+  fread(saveIdentBuffer,6,1,fileHandle);
+
+  if(strcmp(saveIdentBuffer,"SAVPC"))
+  {
+    fclose(fileHandle);
+    return(-1);
+  }
+
+  //initVars();
+
+  fread(&var1,2,1,fileHandle);
+  fread(&var2,2,1,fileHandle);
+  fread(&var3,2,1,fileHandle);
+  fread(&var4,2,1,fileHandle);
+  fread(&userEnabled,2,1,fileHandle);
+  fread(&var6,2,1,fileHandle);
+  fread(&var7,2,1,fileHandle);
+  fread(&var8,2,1,fileHandle);
+  fread(&userDelay,2,1,fileHandle);
+  fread(&sysKey,2,1,fileHandle);
+  fread(&var11,2,1,fileHandle);
+  fread(&var12,2,1,fileHandle);
+  fread(&var13,2,1,fileHandle);
+  fread(&var14,2,1,fileHandle);
+  fread(&affichePasMenuJoueur,2,1,fileHandle);
+  fread(&var20,2,1,fileHandle);
+  fread(&var22,2,1,fileHandle);
+  fread(&var23,2,1,fileHandle);
+  fread(&var24,2,1,fileHandle);
+  fread(&automaticMode,2,1,fileHandle);
+
+  // video param (not loaded in EGA mode)
+
+  fread(&video4,2,1,fileHandle);
+  fread(&video2,2,1,fileHandle);
+  fread(&video3,2,1,fileHandle);
+  fread(&colorOfSelectedSaveDrive,2,1,fileHandle);
+
+  //
+
+  fread(&var30,2,1,fileHandle);
+  fread(&var31,2,1,fileHandle);
+  fread(&var34,2,1,fileHandle);
+  fread(&var35,2,1,fileHandle);
+  int16 bTemp;
+  fread(&bTemp,2,1,fileHandle);
+  animationStart = bTemp;
+  fread(&currentActiveBackgroundPlane,2,1,fileHandle);
+  fread(&initVar3,2,1,fileHandle);
+  fread(&initVar2,2,1,fileHandle);
+  fread(&var22,2,1,fileHandle);
+  fread(&main5,2,1,fileHandle);
+  fread(&numOfLoadedOverlay,2,1,fileHandle);
+  fread(&setup1,2,1,fileHandle);
+  fread(&fontFileIndex,2,1,fileHandle);
+  fread(&currentActiveMenu,2,1,fileHandle);
+  fread(&main7,2,1,fileHandle); // ok
+  fread(&main17,2,1,fileHandle);
+  fread(&main14,2,1,fileHandle);
+  fread(&main8,2,1,fileHandle);
+  fread(&var39,2,1,fileHandle);
+  fread(&var42,2,1,fileHandle);
+  fread(&var45,2,1,fileHandle);
+  fread(&var46,2,1,fileHandle);
+  fread(&var47,2,1,fileHandle);
+  fread(&var48,2,1,fileHandle);
+  fread(&flagCt,2,1,fileHandle);
+  fread(&var41,2,1,fileHandle);
+  fread(&entrerMenuJoueur,2,1,fileHandle);
+
+  fread(var50,64,1,fileHandle);
+  fread(var50,64,1,fileHandle); // Hu ? why 2 times ?
+  fread(&systemStrings,sizeof(systemStrings),1,fileHandle); // ok
+  fread(currentCtpName,40,1,fileHandle);
+  fread(backgroundTable,120,1,fileHandle);
+  fread(palette,256,2,fileHandle); // ok
+  fread(initVar5,24,1,fileHandle);
+  fread(globalVars,setup1*2,1,fileHandle);
+  fread(filesDatabase,9766,1,fileHandle);
+  fread(overlayTable,40*numOfLoadedOverlay,1,fileHandle); // ok
+  fread(mediumVar,0x880,1,fileHandle);
+
+  loadSavegameDataSub1(fileHandle);
+  loadScriptsFromSave(fileHandle,&scriptHandle2);
+  loadScriptsFromSave(fileHandle,&scriptHandle1);
+
+  loadSavegameDataSub2(fileHandle);
+  loadBackgroundIncrustFromSave(fileHandle);
+  loadSavegameActor(fileHandle);
+  loadSavegameDataSub5(fileHandle);
+  loadSavegameDataSub6(fileHandle);
+
+  fclose(fileHandle); // finished with loading !!!!! Yatta !
+
+  for(j=0;j<64;j++)
+  {
+    mediumVar[j].ptr=NULL;
+  }
+
+  for(j=1;j<numOfLoadedOverlay;j++)
+  {
+    if(overlayTable[j].alreadyLoaded)
+    {
+      overlayTable[j].alreadyLoaded = 0;
+      loadOverlay((uint8*)overlayTable[j].overlayName);
+
+      if(overlayTable[j].alreadyLoaded)
+      {
+        ovlDataStruct* ovlData = overlayTable[j].ovlData;
+
+        if(filesData[j].field_0)
+        {
+          if(ovlData->data4Ptr)
+          {
+            free(ovlData->data4Ptr);
+          }
+
+          ovlData->data4Ptr = (uint8*)filesData[j].field_0;
+          ovlData->sizeOfData4 = filesData2[j].field_0;
+        }
+
+        if(filesData[j].field_4)
+        {
+          if(ovlData->objData2WorkTable)
+          {
+            free(ovlData->objData2WorkTable);
+          }
+
+          ovlData->objData2WorkTable = (objectParams*)filesData[j].field_4; // TODO: fix !
+          ovlData->size9 = filesData2[j].field_2;
+        }
+
+      }
+    }
+  }
+
+  updateAllScriptsImports();
+
+  saveVar6[0] = 0;
+
+  initVar1Save = initVar1;
+
+  for(j=0;j<257;j++)
+  {
+    if(filesDatabase[j].subData.ptr)
+    {
+      int i;
+      int k;
+
+      for(i=j+1;i<257;i++)
+      {
+        if(filesDatabase[i].subData.ptr)
+        {
+          if(strcmpuint8(filesDatabase[j].subData.name,filesDatabase[i].subData.name))
+          {
+            break;
+          }
+        }
+        else
+        {
+          break;
+        }
+      }
+
+      for(k=j;k<i;k++)
+      {
+        if(filesDatabase[k].subData.ptr2)
+          initVar1 = 0;
+
+        filesDatabase[k].subData.ptr = NULL;
+        filesDatabase[k].subData.ptr2 = NULL;
+      }
+
+      if(i<2)
+      {
+        printf("Unsupported mono file load!\n");
+        exit(1);
+        //loadFileMode1(filesDatabase[j].subData.name,filesDatabase[j].subData.var4);
+      }
+      else
+      {
+        loadFileMode2((uint8*)filesDatabase[j].subData.name,filesDatabase[j].subData.index, j, i-j);
+        j = i-1;
+      }
+
+      initVar1 = initVar1Save;
+    }
+  }
+
+  saveVar6[0] = 0;
+
+  currentcellHead = cellHead.next;
+
+  while(currentcellHead)
+  {
+    if(currentcellHead->type == 5)
+    {
+      uint8* ptr = mainProc14(currentcellHead->overlay,currentcellHead->idx);
+
+      ASSERT(0);
+
+      if(ptr)
+      {
+        ASSERT(0);
+        //*(int16*)(currentcellHead->datas+0x2E) = getSprite(ptr,*(int16*)(currentcellHead->datas+0xE));
+      }
+      else
+      {
+        //*(int16*)(currentcellHead->datas+0x2E) = 0;
+      }
+    }
+
+    currentcellHead = currentcellHead->next;
+  }
+
+  //TODO: here, restart music
+  
+  if(strlen((char*)currentCtpName))
+  {
+    ctpVar1 = 1;
+    loadCtp(currentCtpName);
+    ctpVar1 = 0;
+  }
+
+  //prepareFadeOut();
+  //gfxModuleData.gfxFunction8();
+
+  for(j=0;j<8;j++)
+  {
+    if(strlen((char*)backgroundTable[j].name))
+    {
+      loadBackground(backgroundTable[j].name,j);
+    }
+  }
+
+  regenerateBackgroundIncrust(&backgroundIncrustHead);
+
+  // to finish
+
+  changeCursor(0);
+  mainDraw(1);
+  flipScreen();
+
+  return(0);
+}
+
+} // End of namespace Cruise

Copied: scummvm/trunk/engines/cruise/saveload.h (from rev 26605, scummvm/trunk/engines/cruise/loadSave.h)
===================================================================
--- scummvm/trunk/engines/cruise/saveload.h	                        (rev 0)
+++ scummvm/trunk/engines/cruise/saveload.h	2007-04-27 20:31:43 UTC (rev 26624)
@@ -0,0 +1,34 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2006 The ScummVM project
+ *
+ * cinE Engine is (C) 2004-2005 by CinE Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef _LOADSAVE_H_
+#define _LOADSAVE_H_
+
+namespace Cruise {
+
+int loadSavegameData(int saveGameIdx);
+
+} // End of namespace Cruise
+
+#endif

Modified: scummvm/trunk/engines/cruise/various.cpp
===================================================================
--- scummvm/trunk/engines/cruise/various.cpp	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/various.cpp	2007-04-27 20:31:43 UTC (rev 26624)
@@ -40,7 +40,7 @@
 	return temp;
 }
 
-void freeObject(objectStruct* objPtr)
+void freeObject(cellStruct* objPtr)
 {
   if(objPtr)
   {
@@ -51,14 +51,14 @@
   }
 }
 
-void removeObjectFromList(int ovlNumber, int objectIdx, objectStruct* objPtr, int backgroundPlane, int arg)
+void removeObjectFromList(int ovlNumber, int objectIdx, cellStruct* objPtr, int backgroundPlane, int arg)
 {
-  objectStruct* currentObj = objPtr->next;
-  objectStruct* previous;
+  cellStruct* currentObj = objPtr->next;
+  cellStruct* previous;
 
   while(currentObj)
   {
-    objectStruct* si;
+    cellStruct* si;
 
     si = currentObj;
 
@@ -78,13 +78,13 @@
 
   while(currentObj)
   {
-    objectStruct* si;
+    cellStruct* si;
 
     si = currentObj;
 
     if(si->type == -1)
     {
-      objectStruct* dx;
+      cellStruct* dx;
       previous->next = si->next;
 
       dx = si->next;
@@ -125,15 +125,15 @@
   return overlayTable[overlayIndex].ovlData->stringTable[textIndex].string;
 }
 
-void createTextObject(int overlayIdx, int oldVar8, objectStruct *pObject, int scriptNumber, int scriptOverlayNumber, int backgroundPlane, int16 color, int oldVar2, int oldVar4, int oldVar6)
+void createTextObject(int overlayIdx, int oldVar8, cellStruct *pObject, int scriptNumber, int scriptOverlayNumber, int backgroundPlane, int16 color, int oldVar2, int oldVar4, int oldVar6)
 {
   char* ax;
-  objectStruct* savePObject = pObject;
-  objectStruct* cx;
+  cellStruct* savePObject = pObject;
+  cellStruct* cx;
 
-  objectStruct* pNewElement;
-  objectStruct* si = pObject->next;
-  objectStruct* var_2;
+  cellStruct* pNewElement;
+  cellStruct* si = pObject->next;
+  cellStruct* var_2;
 
   while(si)
   {
@@ -143,7 +143,7 @@
 
   var_2 = si;
 
-  pNewElement = (objectStruct*)malloc(sizeof(objectStruct));
+  pNewElement = (cellStruct*)malloc(sizeof(cellStruct));
 
   pNewElement->next = pObject->next;
   pObject->next = pNewElement;
@@ -156,7 +156,7 @@
   pNewElement->field_C = oldVar4;
   pNewElement->spriteIdx = oldVar2;
   pNewElement->field_10 = color;
-  pNewElement->hide = 0;
+  pNewElement->freeze = 0;
   pNewElement->field_16 = scriptNumber;
   pNewElement->field_18 = scriptOverlayNumber;
   pNewElement->gfxPtr = NULL;

Modified: scummvm/trunk/engines/cruise/various.h
===================================================================
--- scummvm/trunk/engines/cruise/various.h	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/various.h	2007-04-27 20:31:43 UTC (rev 26624)
@@ -25,6 +25,8 @@
 #ifndef _VARIOUS_H_
 #define _VARIOUS_H_
 
+#include "cruise/cell.h"
+
 namespace Cruise {
 
 extern uint16 var0;
@@ -33,10 +35,9 @@
 
 int16 readB16(void* ptr);
 
-void createTextObject(int overlayIdx, int oldVar8, objectStruct *pObject, int scriptNumber, int scriptOverlayNumber, int backgroundPlane, int16 color, int oldVar2, int oldVar4, int oldVar6);
-void removeObjectFromList(int ovlNumber, int objectIdx, objectStruct* objPtr, int backgroundPlane, int arg);
-objectStruct* addObject(int16 overlayIdx,int16 param2,objectStruct* pHead,int16 scriptType,int16 scriptNumber,int16 scriptOverlay, int16 param3, int16 param4);
-int16 Op_7Sub(int ovlIdx,int param1,int param2);
+void createTextObject(int overlayIdx, int oldVar8, cellStruct *pObject, int scriptNumber, int scriptOverlayNumber, int backgroundPlane, int16 color, int oldVar2, int oldVar4, int oldVar6);
+void removeObjectFromList(int ovlNumber, int objectIdx, cellStruct* objPtr, int backgroundPlane, int arg);
+int16 Op_InitializeStateSub(int ovlIdx,int param1,int param2);
 
 } // End of namespace Cruise
 

Modified: scummvm/trunk/engines/cruise/vars.cpp
===================================================================
--- scummvm/trunk/engines/cruise/vars.cpp	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/vars.cpp	2007-04-27 20:31:43 UTC (rev 26624)
@@ -85,7 +85,7 @@
 
 int16 initVar5[12];
 
-objectStruct objectHead;
+cellStruct cellHead;
 
 opcodeTypeFunction opcodeTypeTable[64];
 
@@ -128,7 +128,7 @@
 int16 automaticMode;
 int16 var34;
 int16 var35;
-int16 animationStart;
+bool animationStart;
 
 int16 main17;
 int16 var39;

Modified: scummvm/trunk/engines/cruise/vars.h
===================================================================
--- scummvm/trunk/engines/cruise/vars.h	2007-04-27 20:26:54 UTC (rev 26623)
+++ scummvm/trunk/engines/cruise/vars.h	2007-04-27 20:31:43 UTC (rev 26624)
@@ -225,8 +225,6 @@
 
 extern int16 initVar5[12];
 
-extern objectStruct objectHead;
-
 extern opcodeTypeFunction opcodeTypeTable[64];
 
 extern int16 positionInStack;
@@ -265,7 +263,7 @@
 extern int16 automaticMode;
 extern int16 var34;
 extern int16 var35;

@@ Diff output truncated at 100000 characters. @@

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