aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Hamm2007-04-27 20:31:43 +0000
committerVincent Hamm2007-04-27 20:31:43 +0000
commit0d07a51acf775b638b1112e707cc615041a2e938 (patch)
tree2da102abe89fa59d1569e93dac7faa11f98a0afd
parentfbc2f89b08db6c336741b984fd4b9708fcd15c3e (diff)
downloadscummvm-rg350-0d07a51acf775b638b1112e707cc615041a2e938.tar.gz
scummvm-rg350-0d07a51acf775b638b1112e707cc615041a2e938.tar.bz2
scummvm-rg350-0d07a51acf775b638b1112e707cc615041a2e938.zip
Cleanup
svn-id: r26624
-rw-r--r--engines/cruise/actor.cpp690
-rw-r--r--engines/cruise/actor.h40
-rw-r--r--engines/cruise/cell.cpp159
-rw-r--r--engines/cruise/cell.h73
-rw-r--r--engines/cruise/cruise_main.cpp18
-rw-r--r--engines/cruise/cruise_main.h3
-rw-r--r--engines/cruise/decompiler.cpp22
-rw-r--r--engines/cruise/function.cpp460
-rw-r--r--engines/cruise/function.h2
-rw-r--r--engines/cruise/mainDraw.cpp128
-rw-r--r--engines/cruise/mainDraw.h2
-rw-r--r--engines/cruise/object.cpp117
-rw-r--r--engines/cruise/object.h33
-rw-r--r--engines/cruise/perso.cpp2
-rw-r--r--engines/cruise/saveload.cpp (renamed from engines/cruise/loadSave.cpp)52
-rw-r--r--engines/cruise/saveload.h (renamed from engines/cruise/loadSave.h)0
-rw-r--r--engines/cruise/various.cpp30
-rw-r--r--engines/cruise/various.h9
-rw-r--r--engines/cruise/vars.cpp4
-rw-r--r--engines/cruise/vars.h4
20 files changed, 954 insertions, 894 deletions
diff --git a/engines/cruise/actor.cpp b/engines/cruise/actor.cpp
index 4c38fa9492..2e953b72df 100644
--- a/engines/cruise/actor.cpp
+++ b/engines/cruise/actor.cpp
@@ -32,15 +32,15 @@ int16 mainProc13(int overlayIdx, int param1, actorStruct* pStartEntry, int param
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 @@ actorStruct* findActor(int overlayIdx, int param1, actorStruct* pStartEntry, int
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 @@ void getPixel(int x, int y)
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 @@ void polydroite(int x1, int y1, int x2, int y2)
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 @@ void polydroite(int x1, int y1, int x2, int y2)
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;
- }
-
- getPixel(ax, bx);
-
- X = ax;
- Y = bx;
-
- if(flag_obstacle==0)
- {
- flag_obstacle = 1;
- return;
- }
+ if(dx>0)
+ {
+ ax+=mD0;
+ bx+=mD1;
+ dx+=si;
+ }
+ else
+ {
+ ax+=mA0;
+ bx+=mA1;
+ dx+=bp;
+ }
+
+ getPixel(ax, bx);
+
+ X = ax;
+ Y = bx;
+
+ if(flag_obstacle==0)
+ {
+ flag_obstacle = 1;
+ return;
+ }
}
flag_obstacle = 0;
@@ -256,31 +256,31 @@ void poly2(int x1, int y1, int x2, int y2)
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 @@ void poly2(int x1, int y1, int x2, int y2)
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;
- }
-
- getPixel(ax, bx);
-
- X = ax;
- Y = bx;
-
- if(flag_obstacle!=0)
- {
- flag_obstacle = 1;
- return;
- }
+ if(dx>0)
+ {
+ ax+=mD0;
+ bx+=mD1;
+ dx+=si;
+ }
+ else
+ {
+ ax+=mA0;
+ bx+=mA1;
+ dx+=bp;
+ }
+
+ getPixel(ax, bx);
+
+ X = ax;
+ Y = bx;
+
+ if(flag_obstacle!=0)
+ {
+ flag_obstacle = 1;
+ return;
+ }
}
flag_obstacle = 0;
@@ -340,57 +340,57 @@ int point_proche( int16 table[][2] )
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];
-
- 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;
- }
- }
+ 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 );
+
+ if ( !flag_obstacle && ctp_routes[i][0] > 0 )
+ {
+ d1 = ctpVar14;
+ p = i;
+ }
+ }
}
return ( p );
@@ -532,11 +532,11 @@ void valide_noeud( int16 table[], int16 p, int *nclick, int16 solution0[20+3][2]
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 @@ void valide_noeud( int16 table[], int16 p, int *nclick, int16 solution0[20+3][2]
}
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 @@ int16 computePathfinding(int16* pSolution, int16 _X, int16 _Y, int16 destX, int1
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 @@ int16 computePathfinding(int16* pSolution, int16 _X, int16 _Y, int16 destX, int1
*(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 @@ void set_anim( int ovl, int obj, int start, int x, int y, int mat, int state )
newf = abs(mat)-1;
- zoom = subOp22(y);
+ zoom = computeZoom(y);
if (mat<0) zoom=-zoom;
setObjectPosition(ovl,obj,0, x);
@@ -827,183 +827,184 @@ int raoul_invstat[][13]=
};
-void processActors(void)
+void processAnimation(void)
{
objectParamsQuery params;
int16 returnVar2[5];
actorStruct* currentActor = &actorHead;
+ actorStruct* nextActor;
- while(currentActor->next)
+ while(currentActor)
{
- currentActor = currentActor->next;
-
- if(!currentActor->freeze && ((currentActor->type == 0) || (currentActor->type == 1)))
- {
- getMultipleObjectParam(currentActor->overlayNumber,currentActor->var4,&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;
-
- currentActor->x_dest = -1;
- currentActor->y_dest = -1;
-
- currentActor->flag = 1;
- }
-
- 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);
-
- 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;
- }
- }
-
- animationStart = 0;
-
- 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;
- }
+ nextActor = currentActor->next;
+
+ 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;
+
+ currentActor->x_dest = -1;
+ currentActor->y_dest = -1;
+
+ currentActor->flag = 1;
+ }
+
+ 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);
+
+ 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;
+ }
+ }
+
+ 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(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 @@ void processActors(void)
}
*/
}
- }
+ }
- 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
diff --git a/engines/cruise/actor.h b/engines/cruise/actor.h
index 750d2a8282..3c2f2a5037 100644
--- a/engines/cruise/actor.h
+++ b/engines/cruise/actor.h
@@ -42,32 +42,32 @@ struct actorStruct {
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
diff --git a/engines/cruise/cell.cpp b/engines/cruise/cell.cpp
new file mode 100644
index 0000000000..1789996274
--- /dev/null
+++ b/engines/cruise/cell.cpp
@@ -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
diff --git a/engines/cruise/cell.h b/engines/cruise/cell.h
new file mode 100644
index 0000000000..e35d1cf2de
--- /dev/null
+++ b/engines/cruise/cell.h
@@ -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
diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp
index a0dafea669..9353a2d61f 100644
--- a/engines/cruise/cruise_main.cpp
+++ b/engines/cruise/cruise_main.cpp
@@ -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 @@ void resetPtr2(scriptInstanceStruct* ptr)
ptr->scriptNumber = -1;
}
-void resetPtr(objectStruct* ptr)
-{
- ptr->next = NULL;
- ptr->prev = NULL;
-}
-
void resetActorPtr(actorStruct* ptr)
{
ptr->next = NULL;
@@ -540,7 +534,7 @@ int initAllData(void)
resetPtr2(&scriptHandle2);
resetPtr2(&scriptHandle1);
- resetPtr(&objectHead);
+ resetPtr(&cellHead);
resetActorPtr(&actorHead);
resetBackgroundIncrustList(&backgroundIncrustHead);
@@ -699,7 +693,7 @@ int getCursorFromObject(int mouseX, int mouseY, int* outX, int* outY)
char objectName[80];
- objectStruct* currentObject = objectHead.prev;
+ cellStruct* currentObject = cellHead.prev;
while(currentObject)
{
@@ -713,7 +707,7 @@ int getCursorFromObject(int mouseX, int mouseY, int* outX, int* outY)
if(strlen(objectName))
{
- if(currentObject->hide == 0)
+ if(currentObject->freeze == 0)
{
var_2 = currentObject->idx;
var_4 = currentObject->overlay;
@@ -1520,11 +1514,11 @@ void mainLoop(void)
removeFinishedScripts(&scriptHandle1);
removeFinishedScripts(&scriptHandle2);
- processActors();
+ processAnimation();
if(var0)
{
- ASSERT(0);
+ // ASSERT(0);
/* main3 = 0;
var24 = 0;
var23 = 0;
diff --git a/engines/cruise/cruise_main.h b/engines/cruise/cruise_main.h
index 2512e71eab..bea26ed79a 100644
--- a/engines/cruise/cruise_main.h
+++ b/engines/cruise/cruise_main.h
@@ -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 @@ int32 prepareWordRender(int32 param, int32 var1,int16* out2, uint8* ptr3,uint8*
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);
diff --git a/engines/cruise/decompiler.cpp b/engines/cruise/decompiler.cpp
index bb0c4af816..5e32374e3d 100644
--- a/engines/cruise/decompiler.cpp
+++ b/engines/cruise/decompiler.cpp
@@ -787,7 +787,7 @@ int decompFunction(void)
}
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 @@ int decompFunction(void)
}
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 @@ int decompFunction(void)
}
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 @@ int decompFunction(void)
}
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 @@ int decompFunction(void)
}
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 @@ int decompFunction(void)
}
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;
}
diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp
index e35b680f26..eb40ca13e7 100644
--- a/engines/cruise/function.cpp
+++ b/engines/cruise/function.cpp
@@ -23,6 +23,7 @@
*/
#include "cruise/cruise_main.h"
+#include "cruise/cell.h"
namespace Cruise {
@@ -50,7 +51,7 @@ actorTableStruct actorTable1[] = {
}
};
-int16 Op_loadOverlay(void)
+int16 Op_LoadOverlay(void)
{
uint8* originalScriptName;
uint8 scriptName[38];
@@ -151,7 +152,7 @@ int16 Op_startScript(void)
return(0);
}
-int16 Op_startObject(void)
+int16 Op_AddProc(void)
{
int pop1 = popVar();
int pop2;
@@ -234,14 +235,14 @@ int16 Op_rand(void) // TODO: implement
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 @@ int16 Op_freeAllPerso(void)
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 @@ void freeObjectList(objectStruct* pListHead)
}
}
-int16 Op_freeObjectList(void)
+int16 Op_FreeCell(void)
{
- freeObjectList(&objectHead);
+ freeObjectList(&cellHead);
return(0);
}
@@ -307,7 +308,7 @@ int16 Op_freeMediumVar(void)
return(0);
}
-int16 Op_14(void)
+int16 Op_RemoveMessage(void)
{
int idx;
int overlay;
@@ -320,7 +321,7 @@ int16 Op_14(void)
overlay = currentScriptPtr->overlayNumber;
}
- removeObjectFromList(overlay, idx, &objectHead, currentActiveBackgroundPlane, 5);
+ removeObjectFromList(overlay, idx, &cellHead, currentActiveBackgroundPlane, 5);
return(0);
}
@@ -352,7 +353,7 @@ int16 Op_isFileLoaded(void)
return -1;
}
-int16 Op_resetFilesEntries(void)
+int16 Op_RemoveFrame(void)
{
//int var1;
//int var2;
@@ -376,7 +377,7 @@ int16 Op_comment(void)
return(0);
}
-int16 Op_removeScript(void)
+int16 Op_RemoveProc(void)
{
int idx;
int overlay;
@@ -394,7 +395,7 @@ int16 Op_removeScript(void)
return(0);
}
-int16 Op_releaseScript2(void)
+int16 Op_FreeOverlay(void)
{
uint8 localName[36] = "";
uint8* namePtr;
@@ -435,7 +436,7 @@ int16 Op_freeAllMenu(void)
return 0;
}
-int16 Op_EnterPlayerMenu(void)
+int16 Op_PlayFXnterPlayerMenu(void)
{
int oldValue = entrerMenuJoueur;
entrerMenuJoueur = popVar();
@@ -484,7 +485,7 @@ int16 Op_62(void)
return 0;
}
-int16 Op_loadBackground(void)
+int16 Op_LoadBackground(void)
{
int result = 0;
uint8 bgName[36] = "";
@@ -565,7 +566,7 @@ int16 Op_loadFile(void)
return 0;
}
-int16 Op_loadFullBundle(void)
+int16 Op_LoadAbs(void)
{
int param1;
// int param2;
@@ -594,7 +595,7 @@ int16 Op_loadFullBundle(void)
return result;
}
-int16 Op_7(void)
+int16 Op_InitializeState(void)
{
int param1 = popVar();
int objIdx = popVar();
@@ -603,7 +604,7 @@ int16 Op_7(void)
if(!ovlIdx)
ovlIdx = currentScriptPtr->overlayNumber;
- Op_7Sub(ovlIdx,objIdx,param1);
+ Op_InitializeStateSub(ovlIdx,objIdx,param1);
return(0);
}
@@ -613,9 +614,9 @@ int16 Op_GetInitVar1(void)
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 @@ int16 isOverlayLoaded(uint8* name)
return 0;
}
-int16 Op_isOverlayLoaded(void)
+int16 Op_FindOverlay(void)
{
uint8 name[36] = "";
uint8* ptr;
@@ -662,7 +663,7 @@ int16 Op_2C(void)
return returnParam;
}
-int16 Op_setMain5(void)
+int16 Op_FadeIn(void)
{
main5 = 1;
return 0;
@@ -682,7 +683,7 @@ int16 Op_GetMouseClick3(void)
return 0;
}
-int16 Op_5(void)
+int16 Op_AddCell(void)
{
int16 param1 = popVar();
int16 param2 = popVar();
@@ -691,7 +692,7 @@ int16 Op_5(void)
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 @@ int16 Op_2F(void)
return 0;
}
-int16 Op_8(void)
+int16 Op_RemoveCell(void)
{
var1 = popVar();
int objectIdx = popVar();
@@ -722,7 +723,7 @@ int16 Op_8(void)
ovlNumber = currentScriptPtr->overlayNumber;
}
- removeObjectFromList(ovlNumber, objectIdx, &objectHead, currentActiveBackgroundPlane, var1);
+ removeObjectFromList(ovlNumber, objectIdx, &cellHead, currentActiveBackgroundPlane, var1);
return 0;
}
@@ -753,7 +754,7 @@ int16 Op_63(void)
int16 op7CVar = 0;
-int16 Op_7C(void)
+int16 Op_InitializeStateC(void)
{
int16 temp = op7CVar;
int16 newVar;
@@ -766,7 +767,7 @@ int16 Op_7C(void)
return temp;
}
-int16 Op_message(void)
+int16 Op_AddMessage(void)
{
int16 color = popVar();
int16 var_2 = popVar();
@@ -792,7 +793,7 @@ int16 Op_message(void)
}
}
- 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 @@ int16 Op_loadAudioResource(void)
return 0;
}
-int16 Op_loadCtp(void)
+int16 Op_LoadCt(void)
{
return loadCtp((uint8*)popPtr());
}
@@ -828,7 +829,7 @@ int16 Op_21(void)
return mainProc13(overlay, param2, &actorHead, param1);
}
-int16 Op_76(void)
+int16 Op_InitializeState6(void)
{
popPtr();
popVar();
@@ -836,38 +837,39 @@ int16 Op_76(void)
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 @@ int16 Op_65(void)
}
}
- 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 @@ int16 Op_6A(void)
int op7BVar = 0;
-int16 Op_7B(void)
+int16 Op_InitializeStateB(void)
{
int di = popVar();
int si = 1 - op7BVar;
@@ -1045,7 +1047,7 @@ int16 Op_removeBackgroundIncrust(void)
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 @@ int16 Op_D(void) // TODO: palette manipulation
return 0;
}
-int16 Op_78(void)
+int16 Op_InitializeState8(void)
{
int si = var41;
@@ -1084,7 +1086,7 @@ int16 Op_releaseOverlay(void)
return 0;
}
-int16 Op_drawLine(void)
+int16 Op_SetColorrawLine(void)
{
/*
int di = popVar();
@@ -1124,7 +1126,7 @@ int16 Op_1A(void)
return 0;
}
-int16 subOp22(int param)
+int16 computeZoom(int param)
{
return (((param - var46)*(var39-var42))/(var45 - var46))+var42;
}
@@ -1144,66 +1146,54 @@ int16 Op_23(void)
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 @@ void checkCollisionWithWalkBoxesBoundingBoxes(int x, int y)
}
// 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 @@ int16 Op_18(void)
{
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 @@ int16 Op_1E(void) // setup actor position
return 1;
}
- animationStart = 0;
+ animationStart = false;
pActor->x_dest = actorX;
pActor->y_dest = actorY;
@@ -1369,7 +1369,7 @@ int16 Op_45(void)
return 0;
}
-int16 Op_5C(void)
+int16 Op_AddCellC(void)
{
popPtr();
popVar();
@@ -1379,7 +1379,7 @@ int16 Op_5C(void)
return 0;
}
-int16 Op_5E(void)
+int16 Op_AddCellE(void)
{
popVar();
@@ -1429,17 +1429,6 @@ int16 Op_40(void)
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 @@ int16 Op_6C(void)
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 @@ void configureAllObjects(int overlayIdx, objectStruct* pObject, int _var4, int _
{
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 @@ void configureAllObjects(int overlayIdx, objectStruct* pObject, int _var4, int _
}
}
-int16 Op_16(void)
+int16 Op_FreezeCell(void)
{
/*
int var0;
@@ -1508,7 +1497,7 @@ int16 Op_16(void)
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 @@ int16 Op_6E(void)
return 0;
}
-int16 Op_72(void)
+int16 Op_InitializeState2(void)
{
var0 = popVar();
char* ptr = (char*)popPtr();
@@ -1620,89 +1609,92 @@ void setupOpcodeTable(void)
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)
diff --git a/engines/cruise/function.h b/engines/cruise/function.h
index c30bd18fb5..c71ef6bbea 100644
--- a/engines/cruise/function.h
+++ b/engines/cruise/function.h
@@ -30,7 +30,7 @@ namespace Cruise {
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
diff --git a/engines/cruise/mainDraw.cpp b/engines/cruise/mainDraw.cpp
index d90bff9b64..ae189dd8aa 100644
--- a/engines/cruise/mainDraw.cpp
+++ b/engines/cruise/mainDraw.cpp
@@ -36,7 +36,7 @@ struct drawVar1Struct
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 @@ void mainDraw6(void)
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 @@ void buildPolyModel(int positionX, int positionY, int scale, char* ptr2, char* d
}
// 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 @@ void mainDrawPolygons(int fileIndex, objectStruct* pObject, int X, int scale, in
if(pObject)
{
- objectStruct* pCurrentObject = pObject;
+ cellStruct* pCurrentObject = pObject;
do
{
@@ -701,7 +701,7 @@ void mainSprite(int globalX, int globalY, gfxEntryStruct* pGfxPtr, uint8* ouputP
}
}
-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 mainDrawSub4(int objX1, int var_6, objectStruct* currentObjPtr, char* data1
}
}
-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 @@ int getValueFromObjectQuerry(objectParamsQuery* params, int idx)
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 @@ void mainDraw(int16 param)
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 @@ void mainDraw(int16 param)
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 @@ void mainDraw(int16 param)
{
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 @@ void mainDraw(int16 param)
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 @@ void mainDraw(int16 param)
//-------------------------------------------------- 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;
diff --git a/engines/cruise/mainDraw.h b/engines/cruise/mainDraw.h
index eb3c5b64e8..be26cc7cb2 100644
--- a/engines/cruise/mainDraw.h
+++ b/engines/cruise/mainDraw.h
@@ -39,7 +39,7 @@ void mainDraw(int16 param);
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
diff --git a/engines/cruise/object.cpp b/engines/cruise/object.cpp
index 6770bae57d..8f4b0eda47 100644
--- a/engines/cruise/object.cpp
+++ b/engines/cruise/object.cpp
@@ -118,99 +118,6 @@ int16 getMultipleObjectParam(int16 overlayIdx,int16 objectIdx,objectParamsQuery*
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 setObjectPosition(int16 param1,int16 objIdx,int16 param3,int16 param4)
}
}
-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 @@ void Op_7Sub1(int16 param1, int16 param2, objectStruct* objPtr)
if(match)
{
- objectStruct* temp;
+ cellStruct* temp;
temp = var8_->next;
@@ -383,7 +290,7 @@ void Op_7Sub1(int16 param1, int16 param2, objectStruct* objPtr)
}
}
-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 @@ int16 Op_7Sub(int ovlIdx,int objIdx,int param2)
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 @@ int16 Op_7Sub(int ovlIdx,int objIdx,int param2)
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);
}
}
diff --git a/engines/cruise/object.h b/engines/cruise/object.h
index 256ab81cb7..ca736143a2 100644
--- a/engines/cruise/object.h
+++ b/engines/cruise/object.h
@@ -38,37 +38,7 @@ struct gfxEntryStruct
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;
-};
-
-typedef struct objectStruct objectStruct;
+#define OBJ_SPRITE 4
struct objectParamsQuery
{
@@ -84,7 +54,6 @@ struct objectParamsQuery
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);
diff --git a/engines/cruise/perso.cpp b/engines/cruise/perso.cpp
index 5bc6c783d4..6f9c2d54f3 100644
--- a/engines/cruise/perso.cpp
+++ b/engines/cruise/perso.cpp
@@ -230,7 +230,7 @@ void processActorWalk(int16 resx_y[4], int16* inc_droite, int16* inc_droite0, in
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;
diff --git a/engines/cruise/loadSave.cpp b/engines/cruise/saveload.cpp
index 3c9c069da9..fc5c07bca4 100644
--- a/engines/cruise/loadSave.cpp
+++ b/engines/cruise/saveload.cpp
@@ -96,36 +96,6 @@ void loadScriptsFromSave(FILE* fileHandle,scriptInstanceStruct* entry)
}
}
-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;
@@ -140,7 +110,7 @@ void loadSavegameActor(FILE* fileHandle)
{
actorStruct* current = (actorStruct*)mallocAndZero(sizeof(actorStruct));
fseek(fileHandle, 4, SEEK_CUR);
- fread(&current->var4,0x26,1,fileHandle);
+ fread(current,0x26,1,fileHandle);
current->next = NULL;
ptr->next = current;
@@ -209,7 +179,7 @@ int loadSavegameData(int saveGameIdx)
char saveIdentBuffer[6];
int j;
int initVar1Save;
- objectStruct* currentObjectHead;
+ cellStruct* currentcellHead;
sprintf(buffer,"CR.%d",saveGameIdx);
@@ -268,7 +238,9 @@ int loadSavegameData(int saveGameIdx)
fread(&var31,2,1,fileHandle);
fread(&var34,2,1,fileHandle);
fread(&var35,2,1,fileHandle);
- fread(&animationStart,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);
@@ -413,28 +385,28 @@ int loadSavegameData(int saveGameIdx)
saveVar6[0] = 0;
- currentObjectHead = objectHead.next;
+ currentcellHead = cellHead.next;
- while(currentObjectHead)
+ while(currentcellHead)
{
- if(currentObjectHead->type == 5)
+ if(currentcellHead->type == 5)
{
- uint8* ptr = mainProc14(currentObjectHead->overlay,currentObjectHead->idx);
+ uint8* ptr = mainProc14(currentcellHead->overlay,currentcellHead->idx);
ASSERT(0);
if(ptr)
{
ASSERT(0);
- //*(int16*)(currentobjectHead->datas+0x2E) = getSprite(ptr,*(int16*)(currentobjectHead->datas+0xE));
+ //*(int16*)(currentcellHead->datas+0x2E) = getSprite(ptr,*(int16*)(currentcellHead->datas+0xE));
}
else
{
- //*(int16*)(currentobjectHead->datas+0x2E) = 0;
+ //*(int16*)(currentcellHead->datas+0x2E) = 0;
}
}
- currentObjectHead = currentObjectHead->next;
+ currentcellHead = currentcellHead->next;
}
//TODO: here, restart music
diff --git a/engines/cruise/loadSave.h b/engines/cruise/saveload.h
index 8acacaf36e..8acacaf36e 100644
--- a/engines/cruise/loadSave.h
+++ b/engines/cruise/saveload.h
diff --git a/engines/cruise/various.cpp b/engines/cruise/various.cpp
index 883623b549..a6d33c1030 100644
--- a/engines/cruise/various.cpp
+++ b/engines/cruise/various.cpp
@@ -40,7 +40,7 @@ int16 readB16(void* ptr)
return temp;
}
-void freeObject(objectStruct* objPtr)
+void freeObject(cellStruct* objPtr)
{
if(objPtr)
{
@@ -51,14 +51,14 @@ void freeObject(objectStruct* objPtr)
}
}
-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 @@ void removeObjectFromList(int ovlNumber, int objectIdx, objectStruct* objPtr, in
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 @@ char* getText(int textIndex, int overlayIndex)
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 @@ void createTextObject(int overlayIdx, int oldVar8, objectStruct *pObject, int sc
var_2 = si;
- pNewElement = (objectStruct*)malloc(sizeof(objectStruct));
+ pNewElement = (cellStruct*)malloc(sizeof(cellStruct));
pNewElement->next = pObject->next;
pObject->next = pNewElement;
@@ -156,7 +156,7 @@ void createTextObject(int overlayIdx, int oldVar8, objectStruct *pObject, int sc
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;
diff --git a/engines/cruise/various.h b/engines/cruise/various.h
index e91e2a87ae..437967b135 100644
--- a/engines/cruise/various.h
+++ b/engines/cruise/various.h
@@ -25,6 +25,8 @@
#ifndef _VARIOUS_H_
#define _VARIOUS_H_
+#include "cruise/cell.h"
+
namespace Cruise {
extern uint16 var0;
@@ -33,10 +35,9 @@ extern uint16 main15;
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
diff --git a/engines/cruise/vars.cpp b/engines/cruise/vars.cpp
index eab348e3d0..5ca64055fb 100644
--- a/engines/cruise/vars.cpp
+++ b/engines/cruise/vars.cpp
@@ -85,7 +85,7 @@ int16 bootOverlayNumber;
int16 initVar5[12];
-objectStruct objectHead;
+cellStruct cellHead;
opcodeTypeFunction opcodeTypeTable[64];
@@ -128,7 +128,7 @@ int16 var24;
int16 automaticMode;
int16 var34;
int16 var35;
-int16 animationStart;
+bool animationStart;
int16 main17;
int16 var39;
diff --git a/engines/cruise/vars.h b/engines/cruise/vars.h
index 091f1c23e3..8ed5e88494 100644
--- a/engines/cruise/vars.h
+++ b/engines/cruise/vars.h
@@ -225,8 +225,6 @@ extern int16 bootOverlayNumber;
extern int16 initVar5[12];
-extern objectStruct objectHead;
-
extern opcodeTypeFunction opcodeTypeTable[64];
extern int16 positionInStack;
@@ -265,7 +263,7 @@ extern int16 var24;
extern int16 automaticMode;
extern int16 var34;
extern int16 var35;
-extern int16 animationStart;
+extern bool animationStart;
extern int16 main17;
extern int16 var39;