[Scummvm-cvs-logs] CVS: scummvm akos.cpp,NONE,1.1 actor.cpp,1.13,1.14 boxes.cpp,1.4,1.5 costume.cpp,1.10,1.11 debug.cpp,1.9,1.10 gfx.cpp,1.21,1.22 gui.cpp,1.4,1.5 object.cpp,1.14,1.15 resource.cpp,1.21,1.22 saveload.cpp,1.16,1.17 script.cpp,1.11,1.12 script_v1.cpp,1.14,1.15 script_v2.cpp,1.12,1.13 scumm.h,1.29,1.30 scummvm.cpp,1.27,1.28 scummvm.dsp,1.13,1.14 sound.cpp,1.8,1.9 string.cpp,1.10,1.11 verbs.cpp,1.10,1.11 windows.cpp,1.18,1.19

Ludvig Strigeus strigeus at users.sourceforge.net
Mon Nov 26 12:05:03 CET 2001


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv3114

Modified Files:
	actor.cpp boxes.cpp costume.cpp debug.cpp gfx.cpp gui.cpp 
	object.cpp resource.cpp saveload.cpp script.cpp script_v1.cpp 
	script_v2.cpp scumm.h scummvm.cpp scummvm.dsp sound.cpp 
	string.cpp verbs.cpp windows.cpp 
Added Files:
	akos.cpp 
Log Message:
very simple full throttle support, use the FULL_THROTTLE define. (will fix later)
modified some actor parts to work better with full throttle (most likely new bugs because of that).
directions are now stored as angles instead of left/right/up/down
implemented loadFlObject (flobjects are currently saved in the savestate, will fix that also)






--- NEW FILE: akos.cpp ---
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2001  Ludvig Strigeus
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header: /cvsroot/scummvm/scummvm/akos.cpp,v 1.1 2001/11/26 19:57:57 strigeus Exp $
 *
[...1001 lines suppressed...]
	case 1: return a!=b;
	case 2: return a<b;
	case 3: return a<=b;
	case 4: return a>b;
	default: return a>=b;
	}
}

int Scumm::getAnimVar(Actor *a, byte var) {
	assert(var>=0 && var<=15);
	return a->animVariable[var];
}

void Scumm::setAnimVar(Actor *a, byte var, int value) {
	assert(var>=0 && var<=15);
	a->animVariable[var] = value;
}


#endif
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/actor.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** actor.cpp	2001/11/14 18:37:38	1.13
--- actor.cpp	2001/11/26 19:57:57	1.14
***************
*** 29,35 ****
  		a->x = 0;
  		a->y = 0;
! 		a->facing = 2;
  	} else if (mode==2) {
! 		a->facing = 2;
  	}
  
--- 29,35 ----
  		a->x = 0;
  		a->y = 0;
[...1078 lines suppressed...]
  	a->walkdata.destdir = dir;
  	a->moving = (a->moving&2)|1;
- 	a->walkdata.curbox = a->walkbox;
  }
  
--- 1025,1028 ----
***************
*** 977,979 ****
  
  	return false;
! }
\ No newline at end of file
--- 1046,1052 ----
  
  	return false;
! }
! 
! void Scumm::remapActor(Actor *a, int b, int c, int d, int e) {
! 	warning("stub remapActor(%d,%d,%d,%d,%d)", a->number, b, c, d, e);
! }

Index: boxes.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/boxes.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** boxes.cpp	2001/11/06 20:00:47	1.4
--- boxes.cpp	2001/11/26 19:57:57	1.5
***************
*** 50,85 ****
  
  bool Scumm::checkXYInBoxBounds(int b, int x, int y) {
  	if (b==0)
  		return 0;
  
! 	getBoxCoordinates(b);
  
! 	if (x < box.upperLeftX && x < box.upperRightX &&
! 		x < box.lowerLeftX && x < box.lowerRightX)
  			return 0;
  	
! 	if (x > box.upperLeftX && x > box.upperRightX &&
! 		x > box.lowerLeftX && x > box.lowerRightX)
  			return 0;
  	
! 	if (y < box.upperLeftY && y < box.upperRightY &&
! 		y < box.lowerLeftY && y < box.lowerRightY)
  			return 0;
  
! 	if (y > box.upperLeftY && y > box.upperRightY &&
! 		y > box.lowerLeftY && y > box.lowerRightY)
  			return 0;
  	
! 	if (box.upperLeftX == box.upperRightX &&
! 		box.upperLeftY == box.upperRightY &&
! 		box.lowerLeftX == box.lowerRightX &&
! 		box.lowerLeftY == box.lowerRightY ||
! 		box.upperLeftX == box.lowerRightX &&
! 		box.upperLeftY == box.lowerRightY &&
! 		box.upperRightX== box.lowerLeftX &&
! 		box.upperRightY== box.lowerLeftY) {
  
  		Point pt;
! 		pt = closestPtOnLine(box.upperLeftX, box.upperLeftY, box.lowerLeftX, box.lowerLeftY, x, y);
  		if (distanceFromPt(x, y, pt.x,pt.y) <= 4)
  			return 1;
--- 50,87 ----
  
  bool Scumm::checkXYInBoxBounds(int b, int x, int y) {
+ 	BoxCoords box;
+ 
  	if (b==0)
  		return 0;
  
! 	getBoxCoordinates(b, &box);
  
! 	if (x < box.ul.x && x < box.ur.x &&
! 		x < box.ll.x && x < box.lr.x)
  			return 0;
  	
! 	if (x > box.ul.x && x > box.ur.x &&
! 		x > box.ll.x && x > box.lr.x)
  			return 0;
  	
! 	if (y < box.ul.y && y < box.ur.y &&
! 		y < box.ll.y && y < box.lr.y)
  			return 0;
  
! 	if (y > box.ul.y && y > box.ur.y &&
! 		y > box.ll.y && y > box.lr.y)
  			return 0;
  	
! 	if (box.ul.x == box.ur.x &&
! 		box.ul.y == box.ur.y &&
! 		box.ll.x == box.lr.x &&
! 		box.ll.y == box.lr.y ||
! 		box.ul.x == box.lr.x &&
! 		box.ul.y == box.lr.y &&
! 		box.ur.x== box.ll.x &&
! 		box.ur.y== box.ll.y) {
  
  		Point pt;
! 		pt = closestPtOnLine(box.ul.x, box.ul.y, box.ll.x, box.ll.y, x, y);
  		if (distanceFromPt(x, y, pt.x,pt.y) <= 4)
  			return 1;
***************
*** 87,103 ****
  	
  	if (!getSideOfLine(
! 		box.upperLeftX, box.upperLeftY, box.upperRightX, box.upperRightY, x,y,b))
  			return 0;
  	
  	if (!getSideOfLine(
! 		box.upperRightX, box.upperRightY, box.lowerLeftX, box.lowerLeftY, x,y,b))
  			return 0;
  
  	if (!getSideOfLine(
! 		box.lowerLeftX, box.lowerLeftY, box.lowerRightX, box.lowerRightY, x,y,b))
  			return 0;
  
  	if (!getSideOfLine(
! 		box.lowerRightX, box.lowerRightY, box.upperLeftX, box.upperLeftY, x,y,b))
  			return 0;
  
--- 89,105 ----
  	
  	if (!getSideOfLine(
! 		box.ul.x, box.ul.y, box.ur.x, box.ur.y, x,y,b))
  			return 0;
  	
  	if (!getSideOfLine(
! 		box.ur.x, box.ur.y, box.ll.x, box.ll.y, x,y,b))
  			return 0;
  
  	if (!getSideOfLine(
! 		box.ll.x, box.ll.y, box.lr.x, box.lr.y, x,y,b))
  			return 0;
  
  	if (!getSideOfLine(
! 		box.lr.x, box.lr.y, box.ul.x, box.ul.y, x,y,b))
  			return 0;
  
***************
*** 105,118 ****
  }
  
! void Scumm::getBoxCoordinates(int b) {
! 	Box *bp = getBoxBaseAddr(b);
! 	box.upperLeftX = (int16)FROM_LE_16(bp->ulx);
! 	box.upperRightX = (int16)FROM_LE_16(bp->urx);
! 	box.lowerLeftX = (int16)FROM_LE_16(bp->llx);
! 	box.lowerRightX = (int16)FROM_LE_16(bp->lrx);
! 	box.upperLeftY = (int16)FROM_LE_16(bp->uly);
! 	box.upperRightY = (int16)FROM_LE_16(bp->ury);
! 	box.lowerLeftY = (int16)FROM_LE_16(bp->lly);
! 	box.lowerRightY = (int16)FROM_LE_16(bp->lry);
  }
  
--- 107,120 ----
  }
  
! void Scumm::getBoxCoordinates(int boxnum, BoxCoords *box) {
! 	Box *bp = getBoxBaseAddr(boxnum);
! 	box->ul.x = (int16)FROM_LE_16(bp->ulx);
! 	box->ul.y = (int16)FROM_LE_16(bp->uly);
! 	box->ur.x = (int16)FROM_LE_16(bp->urx);
! 	box->ur.y = (int16)FROM_LE_16(bp->ury);
! 	box->ll.x = (int16)FROM_LE_16(bp->llx);
! 	box->ll.y = (int16)FROM_LE_16(bp->lly);
! 	box->lr.x = (int16)FROM_LE_16(bp->lrx);
! 	box->lr.y = (int16)FROM_LE_16(bp->lry);
  }
  
***************
*** 213,218 ****
  bool Scumm::inBoxQuickReject(int b, int x, int y, int threshold) {
  	int t;
  
! 	getBoxCoordinates(b);
  
  	if (threshold==0)
--- 215,221 ----
  bool Scumm::inBoxQuickReject(int b, int x, int y, int threshold) {
  	int t;
+ 	BoxCoords box;
  
! 	getBoxCoordinates(b, &box);
  
  	if (threshold==0)
***************
*** 220,240 ****
  	
  	t = x - threshold;
! 	if (t > box.upperLeftX && t > box.upperRightX &&
! 		t > box.lowerLeftX && t > box.lowerRightX)
  			return 0;
  	
  	t = x + threshold;
! 	if (t < box.upperLeftX && t < box.upperRightX &&
! 		t < box.lowerLeftX && t < box.lowerRightX)
  			return 0;
  	
  	t = y - threshold;
! 	if (t > box.upperLeftY && t > box.upperRightY &&
! 		t > box.lowerLeftY && t > box.lowerRightY)
  			return 0;
  	
  	t = y + threshold;
! 	if (t < box.upperLeftY && t < box.upperRightY &&
! 			t < box.lowerLeftY && t < box.lowerRightY)
  			return 0;
  
--- 223,243 ----
  	
  	t = x - threshold;
! 	if (t > box.ul.x && t > box.ur.x &&
! 		t > box.ll.x && t > box.lr.x)
  			return 0;
  	
  	t = x + threshold;
! 	if (t < box.ul.x && t < box.ur.x &&
! 		t < box.ll.x && t < box.lr.x)
  			return 0;
  	
  	t = y - threshold;
! 	if (t > box.ul.y && t > box.ur.y &&
! 		t > box.ll.y && t > box.lr.y)
  			return 0;
  	
  	t = y + threshold;
! 	if (t < box.ul.y && t < box.ur.y &&
! 			t < box.ll.y && t < box.lr.y)
  			return 0;
  
***************
*** 247,254 ****
  	uint dist;
  	uint bestdist = (uint)0xFFFF;
  
! 	getBoxCoordinates(b);
  
! 	pt = closestPtOnLine(box.upperLeftX,box.upperLeftY,box.upperRightX,box.upperRightY,x,y);
  	dist = distanceFromPt(x, y, pt.x, pt.y);
  	if (dist < bestdist) {
--- 250,258 ----
  	uint dist;
  	uint bestdist = (uint)0xFFFF;
+ 	BoxCoords box;
  
! 	getBoxCoordinates(b, &box);
  
! 	pt = closestPtOnLine(box.ul.x,box.ul.y,box.ur.x,box.ur.y,x,y);
  	dist = distanceFromPt(x, y, pt.x, pt.y);
  	if (dist < bestdist) {
***************
*** 258,262 ****
  	}
  
! 	pt = closestPtOnLine(box.upperRightX,box.upperRightY,box.lowerLeftX,box.lowerLeftY,x,y);
  	dist = distanceFromPt(x, y, pt.x, pt.y);
  	if (dist < bestdist) {
--- 262,266 ----
  	}
  
! 	pt = closestPtOnLine(box.ur.x,box.ur.y,box.ll.x,box.ll.y,x,y);
  	dist = distanceFromPt(x, y, pt.x, pt.y);
  	if (dist < bestdist) {
***************
*** 266,270 ****
  	}
  
! 	pt = closestPtOnLine(box.lowerLeftX,box.lowerLeftY,box.lowerRightX,box.lowerRightY,x,y);
  	dist = distanceFromPt(x, y, pt.x, pt.y);
  	if (dist < bestdist) {
--- 270,274 ----
  	}
  
! 	pt = closestPtOnLine(box.ll.x,box.ll.y,box.lr.x,box.lr.y,x,y);
  	dist = distanceFromPt(x, y, pt.x, pt.y);
  	if (dist < bestdist) {
***************
*** 274,278 ****
  	}
  
! 	pt = closestPtOnLine(box.lowerRightX,box.lowerRightY,box.upperLeftX,box.upperLeftY,x,y);
  	dist = distanceFromPt(x, y, pt.x, pt.y);
  	if (dist < bestdist) {
--- 278,282 ----
  	}
  
! 	pt = closestPtOnLine(box.lr.x,box.lr.y,box.ul.x,box.ul.y,x,y);
  	dist = distanceFromPt(x, y, pt.x, pt.y);
  	if (dist < bestdist) {
***************
*** 292,298 ****
  }
  
! int Scumm::getPathToDestBox(int from, int to) {
  	byte *boxm;
! 	int i;
  
  	if (from==to)
--- 296,302 ----
  }
  
! int Scumm::getPathToDestBox(byte from, byte to) {
  	byte *boxm;
! 	byte i;
  
  	if (from==to)
***************
*** 317,485 ****
  }
  
! int Scumm::findPathTowards(Actor *a, int box1, int box2, int box3) {
! 	int upperLeftX, upperLeftY;
! 	int upperRightX, upperRightY;
! 	int lowerLeftX, lowerLeftY;
! 	int lowerRightX, lowerRightY;
! 	int i,j,m,n,p,q,r;
! 	int tmp_x, tmp_y;
! 	int tmp;
! 	
! 	getBoxCoordinates(box1);
! 	upperLeftX = box.upperLeftX;
! 	upperLeftY = box.upperLeftY;
! 	upperRightX = box.upperRightX;
! 	upperRightY = box.upperRightY;
! 	lowerLeftX = box.lowerLeftX;
! 	lowerLeftY = box.lowerLeftY;
! 	lowerRightX = box.lowerRightX;
! 	lowerRightY = box.lowerRightY;
! 	getBoxCoordinates(box2);
  
! 	i = 0;
! 	do {
! 		if (i >= 4) goto ExitPos;
! 		for (j=0; j<4; j++) {
! 			if (upperRightX==upperLeftX &&
! 					box.upperLeftX==upperLeftX &&
! 					box.upperRightX==upperRightX) {
! 				
! ExitPos:;
! 				n = m = 0;
! 				if (upperRightY < upperLeftY) {
! 					m = 1;
! 					SWAP(upperRightY, upperLeftY);
  				}
! 				if (box.upperRightY < box.upperLeftY) {
! 					n = 1;
! 					SWAP(box.upperRightY, box.upperLeftY);
  				}
! 				if (box.upperRightY >= upperLeftY &&
! 						box.upperLeftY <= upperRightY &&
! 						(box.upperLeftY != upperRightY &&
! 						 box.upperRightY!= upperLeftY ||
! 						 upperRightY==upperLeftY ||
! 						 box.upperRightY==box.upperLeftY)) {
! 					if (box2==box3) {
! 						m = a->walkdata.destx - a->x;
! 						p = a->walkdata.desty - a->y;
! 						tmp = upperLeftX - a->x;
! 						i = a->y;
! 						if (m) {
! 							q = tmp * p;
! 							r = q/m;
! 							if (r==0 && (q<=0 || m<=0) && (q>=0 || m>=0)) {
! 								r = -1;
! 							}
! 							i += r;
  						}
  					} else {
! 						i = a->y;
  					}
! 					q = i;
! 					if (q < box.upperLeftY)
! 						q = box.upperLeftY;
! 					if (q > box.upperRightY)
! 						q = box.upperRightY;
! 					if (q < upperLeftY)
! 						q = upperLeftY;
! 					if (q > upperRightY)
! 						q = upperRightY;
! 					if (q==i && box2==box3)
  						return 1;
- 					_foundPathX = upperLeftX;
  					_foundPathY = q;
  					return 0;
- 				} else {
- 					if (m) {
- 						SWAP(upperRightY, upperLeftY);
- 					}
- 					if (n) {
- 						SWAP(box.upperRightY, box.upperLeftY);
- 					}
  				}
  			}
! 			if (upperLeftY==upperRightY &&
! 					box.upperLeftY==upperLeftY &&
! 					box.upperRightY==upperRightY) {
! 				n = m = 0;
! 				if(upperRightX < upperLeftX) {
! 					m = 1;
! 					SWAP(upperRightX, upperLeftX);
  				}
! 				if (box.upperRightX < box.upperLeftX) {
! 					n = 1;
! 					SWAP(box.upperRightX, box.upperLeftX);
  				}
! 				if (box.upperRightX >= upperLeftX &&
! 						box.upperLeftX <= upperRightX &&
! 						(box.upperLeftX != upperRightX &&
! 						 box.upperRightX!= upperLeftX ||
! 						 upperRightX==upperLeftX ||
! 						 box.upperRightX==box.upperLeftX)) {
! 					if (box2==box3) {
! 						m = a->walkdata.destx - a->x;
! 						p = a->walkdata.desty - a->y;
! 						i = upperLeftY - a->y;
! 						tmp = a->x;
! 						if (p) {
! 							tmp += i * m / p;
  						}
  					} else {
! 						tmp = a->x;
  					}
! 					q = tmp;
! 					if (q < box.upperLeftX)
! 						q = box.upperLeftX;
! 					if (q > box.upperRightX)
! 						q = box.upperRightX;
! 					if (q < upperLeftX)
! 						q = upperLeftX;
! 					if (q > upperRightX)
! 						q = upperRightX;
! 					if (tmp==q && box2==box3)
  						return 1;
  					_foundPathX = q;
! 					_foundPathY = upperLeftY;
  					return 0;
- 				} else {
- 					if (m != 0) {
- 						SWAP(upperRightX, upperLeftX);
- 					}
- 					if (n != 0) {
- 						SWAP(box.upperRightX, box.upperLeftX);
- 					}
  				}
  			}
! 			tmp_x = upperLeftX;
! 			tmp_y = upperLeftY;
! 			upperLeftX = upperRightX;
! 			upperLeftY = upperRightY;
! 			upperRightX = lowerLeftX;
! 			upperRightY = lowerLeftY;
! 			lowerLeftX = lowerRightX;
! 			lowerLeftY = lowerRightY;
! 			lowerRightX = tmp_x;
! 			lowerRightY = tmp_y;
  		}
! 
! 		tmp_x = box.upperLeftX;
! 		tmp_y = box.upperLeftY;
! 		box.upperLeftX = box.upperRightX;
! 		box.upperLeftY = box.upperRightY;
! 		box.upperRightX = box.lowerLeftX;
! 		box.upperRightY = box.lowerLeftY;
! 		box.lowerLeftX = box.lowerRightX;
! 		box.lowerLeftY = box.lowerRightY;
! 		box.lowerRightX = tmp_x;
! 		box.lowerRightY = tmp_y;
! 		i++;		
! 	} while (1);
  }
- 
- 
  void Scumm::setBoxFlags(int box, int val) {
! 	Box *b = getBoxBaseAddr(box);
! 	b->flags = val;
  }
  
--- 321,471 ----
  }
  
! int Scumm::findPathTowards(Actor *a, byte box1nr, byte box2nr, byte box3nr) {
! 	BoxCoords box1;
! 	BoxCoords box2;
! 	Point tmp;
! 	int i,j;
! 	int flag;
! 	int q,pos;
  
! 	getBoxCoordinates(box1nr,&box1);
! 	getBoxCoordinates(box2nr,&box2);
! 
! 	for(i=0; i<4; i++) {
! 		for(j=0; j<4; j++) {
! 			if (box1.ul.x==box1.ur.x &&
! 					box1.ul.x==box2.ul.x &&
! 					box1.ul.x==box2.ur.x) {
! 				flag = 0;
! 				if (box1.ul.y > box1.ur.y) {
! 					SWAP(box1.ul.y, box1.ur.y);
! 					flag |= 1;
  				}
! 
! 				if (box2.ul.y > box2.ur.y) {
! 					SWAP(box2.ul.y, box2.ur.y);
! 					flag |= 2;
  				}
! 
! 				if (box1.ul.y > box2.ur.y || box2.ul.y > box1.ur.y ||
! 						(box1.ur.y==box2.ul.y || box2.ur.y==box1.ul.y) &&
! 						box1.ul.y!=box1.ur.y && box2.ul.y!=box2.ur.y) {
! 					if (flag&1)
! 						SWAP(box1.ul.y, box1.ur.y);
! 					if (flag&2)
! 						SWAP(box2.ul.y, box2.ur.y);
! 				} else {
! 					if (box2nr == box3nr) {
! 						int diffX = a->walkdata.destx - a->x;
! 						int diffY = a->walkdata.desty - a->y;
! 						int boxDiffX = box1.ul.x - a->x;
! 						
! 						if (diffX!=0) {
! 							int t;
! 
! 							diffY *= boxDiffX;
! 							t = diffY / diffX;
! 							if (t==0 && (diffY<=0 || diffX<=0) && (diffY>=0 || diffX>=0))
! 								t = -1;
! 							pos = a->y + t;
! 						} else {
! 							pos = a->y;
  						}
  					} else {
! 						pos = a->y;
  					}
! 
! 					q = pos;
! 					if (q < box2.ul.y)
! 					q = box2.ul.y;
! 					if (q > box2.ur.y)
! 						q = box2.ur.y;
! 					if (q < box1.ul.y)
! 						q = box1.ul.y;
! 					if (q > box1.ur.y)
! 						q = box1.ur.y;
! 					if (q==pos && box2nr==box3nr)
  						return 1;
  					_foundPathY = q;
+ 					_foundPathX = box1.ul.x;
  					return 0;
  				}
  			}
! 
! 			if (box1.ul.y==box1.ur.y &&
! 					box1.ul.y==box2.ul.y &&
! 					box1.ul.y==box2.ur.y) {
! 				flag = 0;
! 				if (box1.ul.x > box1.ur.x) {
! 					SWAP(box1.ul.x, box1.ur.x);
! 					flag |= 1;
  				}
! 
! 				if (box2.ul.x > box2.ur.x) {
! 					SWAP(box2.ul.x, box2.ur.x);
! 					flag |= 2;
  				}
! 
! 				if (box1.ul.x > box2.ur.x || box2.ul.x > box1.ur.x ||
! 						(box1.ur.x==box2.ul.x || box2.ur.x==box1.ul.x) &&
! 						box1.ul.x!=box1.ur.x && box2.ul.x!=box2.ur.x) {
! 					if (flag&1)
! 						SWAP(box1.ul.x, box1.ur.x);
! 					if (flag&2)
! 						SWAP(box2.ul.x, box2.ur.x);
! 				} else {
! 
! 					if (box2nr == box3nr) {
! 						int diffX = a->walkdata.destx - a->x;
! 						int diffY = a->walkdata.desty - a->y;
! 						int boxDiffY = box1.ul.y - a->y;
! 						
! 						pos = a->x;
! 						if (diffY!=0) {
! 							pos += diffX * boxDiffY / diffY;
  						}
  					} else {
! 						pos = a->x;
  					}
! 
! 					q = pos;
! 					if (q < box2.ul.x)
! 						q = box2.ul.x;
! 					if (q > box2.ur.x)
! 						q = box2.ur.x;
! 					if (q < box1.ul.x)
! 						q = box1.ul.x;
! 					if (q > box1.ur.x)
! 						q = box1.ur.x;
! 					if (q==pos && box2nr==box3nr)
  						return 1;
  					_foundPathX = q;
! 					_foundPathY = box1.ul.y;
  					return 0;
  				}
  			}
! 			tmp = box1.ul;
! 			box1.ul = box1.ur;
! 			box1.ur = box1.ll;
! 			box1.ll = box1.lr;
! 			box1.lr = tmp;
  		}
! 		tmp = box2.ul;
! 		box2.ul = box2.ur;
! 		box2.ur = box2.ll;
! 		box2.ll = box2.lr;
! 		box2.lr = tmp;
! 	}
! 	error("findPathTowards: default");
  }
  void Scumm::setBoxFlags(int box, int val) {
! 	/* FULL_THROTTLE stuff */
! 	if (val & 0xC000) {
! 		assert(box>=0 && box<65);
! 		_extraBoxFlags[box] = val;
! 	} else {
! 		Box *b = getBoxBaseAddr(box);
! 		b->flags = val;
! 	}
  }
  
***************
*** 674,701 ****
  
  /* Check if two boxes are neighbours */
! bool Scumm::areBoxesNeighbours(int box1, int box2) {
! 	int upperLeftX, upperLeftY;
! 	int upperRightX, upperRightY;
! 	int lowerLeftX, lowerLeftY;
! 	int lowerRightX, lowerRightY;
  	int j,k,m,n;
  	int tmp_x, tmp_y;
  	bool result;
  
! 	if (getBoxFlags(box1)&0x80 || getBoxFlags(box2)&0x80)
  		return false;
- 
- 	getBoxCoordinates(box1);
- 
- 	upperLeftX = box.upperLeftX;
- 	upperLeftY = box.upperLeftY;
- 	upperRightX = box.upperRightX;
- 	upperRightY = box.upperRightY;
- 	lowerLeftX = box.lowerLeftX;
- 	lowerLeftY = box.lowerLeftY;
- 	lowerRightX = box.lowerRightX;
- 	lowerRightY = box.lowerRightY;
  
! 	getBoxCoordinates(box2);
  	
  	result = false;
--- 660,675 ----
  
  /* Check if two boxes are neighbours */
! bool Scumm::areBoxesNeighbours(int box1nr, int box2nr) {
  	int j,k,m,n;
  	int tmp_x, tmp_y;
  	bool result;
+ 	BoxCoords box;
+ 	BoxCoords box2;
  
! 	if (getBoxFlags(box1nr)&0x80 || getBoxFlags(box2nr)&0x80)
  		return false;
  
! 	getBoxCoordinates(box1nr, &box2);
! 	getBoxCoordinates(box2nr, &box);
  	
  	result = false;
***************
*** 705,738 ****
  		k = 4;
  		do {
! 			if (upperRightX == upperLeftX &&
! 				  box.upperLeftX == upperLeftX &&
! 					box.upperRightX == upperRightX) {
  				n = m = 0;
! 				if (upperRightY < upperLeftY) {
  					n = 1;
! 					SWAP(upperRightY, upperLeftY);
  				}
! 				if (box.upperRightY < box.upperLeftY) {
  					m = 1;
! 					SWAP(box.upperRightY, box.upperLeftY);
  				}
! 				if (box.upperRightY < upperLeftY ||
! 					  box.upperLeftY > upperRightY ||
! 						(box.upperLeftY == upperRightY ||
! 						 box.upperRightY==upperLeftY) &&
! 						 upperRightY != upperLeftY &&
! 						 box.upperLeftY!=box.upperRightY) {
  					if (n) {
! 						SWAP(upperRightY, upperLeftY);
  					}
  					if (m) {
! 						SWAP(box.upperRightY, box.upperLeftY);
  					}
  				} else {
  					if (n) {
! 						SWAP(upperRightY, upperLeftY);
  					}
  					if (m) {
! 						SWAP(box.upperRightY, box.upperLeftY);
  					}
  					result = true;
--- 679,712 ----
  		k = 4;
  		do {
! 			if (box2.ur.x == box2.ul.x &&
! 				  box.ul.x == box2.ul.x &&
! 					box.ur.x == box2.ur.x) {
  				n = m = 0;
! 				if (box2.ur.y < box2.ul.y) {
  					n = 1;
! 					SWAP(box2.ur.y, box2.ul.y);
  				}
! 				if (box.ur.y < box.ul.y) {
  					m = 1;
! 					SWAP(box.ur.y, box.ul.y);
  				}
! 				if (box.ur.y < box2.ul.y ||
! 					  box.ul.y > box2.ur.y ||
! 						(box.ul.y == box2.ur.y ||
! 						 box.ur.y==box2.ul.y) &&
! 						 box2.ur.y != box2.ul.y &&
! 						 box.ul.y!=box.ur.y) {
  					if (n) {
! 						SWAP(box2.ur.y, box2.ul.y);
  					}
  					if (m) {
! 						SWAP(box.ur.y, box.ul.y);
  					}
  				} else {
  					if (n) {
! 						SWAP(box2.ur.y, box2.ul.y);
  					}
  					if (m) {
! 						SWAP(box.ur.y, box.ul.y);
  					}
  					result = true;
***************
*** 740,774 ****
  			}
  
! 			if (upperRightY == upperLeftY && 
! 					box.upperLeftY == upperLeftY &&
! 					box.upperRightY == upperRightY) {
  				n = m = 0;
! 				if (upperRightX < upperLeftX) {
  					n = 1;
! 					SWAP(upperRightX, upperLeftX);
  				}
! 				if (box.upperRightX < box.upperLeftX) {
  					m = 1;
! 					SWAP(box.upperRightX, box.upperLeftX);
  				}
! 				if (box.upperRightX < upperLeftX ||
! 					  box.upperLeftX > upperRightX ||
! 						(box.upperLeftX == upperRightX ||
! 						 box.upperRightX==upperLeftX) &&
! 						 upperRightX != upperLeftX &&
! 						 box.upperLeftX!=box.upperRightX) {
  
  					if (n) {
! 						SWAP(upperRightX, upperLeftX);
  					}
  					if (m) {
! 						SWAP(box.upperRightX, box.upperLeftX);
  					}
  				} else {
  					if (n) {
! 						SWAP(upperRightX, upperLeftX);
  					}
  					if (m) {
! 						SWAP(box.upperRightX, box.upperLeftX);
  					}
  					result = true;
--- 714,748 ----
  			}
  
! 			if (box2.ur.y == box2.ul.y && 
! 					box.ul.y == box2.ul.y &&
! 					box.ur.y == box2.ur.y) {
  				n = m = 0;
! 				if (box2.ur.x < box2.ul.x) {
  					n = 1;
! 					SWAP(box2.ur.x, box2.ul.x);
  				}
! 				if (box.ur.x < box.ul.x) {
  					m = 1;
! 					SWAP(box.ur.x, box.ul.x);
  				}
! 				if (box.ur.x < box2.ul.x ||
! 					  box.ul.x > box2.ur.x ||
! 						(box.ul.x == box2.ur.x ||
! 						 box.ur.x==box2.ul.x) &&
! 						 box2.ur.x != box2.ul.x &&
! 						 box.ul.x!=box.ur.x) {
  
  					if (n) {
! 						SWAP(box2.ur.x, box2.ul.x);
  					}
  					if (m) {
! 						SWAP(box.ur.x, box.ul.x);
  					}
  				} else {
  					if (n) {
! 						SWAP(box2.ur.x, box2.ul.x);
  					}
  					if (m) {
! 						SWAP(box.ur.x, box.ul.x);
  					}
  					result = true;
***************
*** 776,801 ****
  			}
  			
! 			tmp_x = upperLeftX;
! 			tmp_y = upperLeftY;
! 			upperLeftX = upperRightX;
! 			upperLeftY = upperRightY;
! 			upperRightX = lowerLeftX;
! 			upperRightY = lowerLeftY;
! 			lowerLeftX = lowerRightX;
! 			lowerLeftY = lowerRightY;
! 			lowerRightX = tmp_x;
! 			lowerRightY = tmp_y;
  		} while (--k);
  		
! 		tmp_x = box.upperLeftX;
! 		tmp_y = box.upperLeftY;
! 		box.upperLeftX = box.upperRightX;
! 		box.upperLeftY = box.upperRightY;
! 		box.upperRightX = box.lowerLeftX;
! 		box.upperRightY = box.lowerLeftY;
! 		box.lowerLeftX = box.lowerRightX;
! 		box.lowerLeftY = box.lowerRightY;
! 		box.lowerRightX = tmp_x;
! 		box.lowerRightY = tmp_y;
  	} while (--j);
  
--- 750,775 ----
  			}
  			
! 			tmp_x = box2.ul.x;
! 			tmp_y = box2.ul.y;
! 			box2.ul.x = box2.ur.x;
! 			box2.ul.y = box2.ur.y;
! 			box2.ur.x = box2.ll.x;
! 			box2.ur.y = box2.ll.y;
! 			box2.ll.x = box2.lr.x;
! 			box2.ll.y = box2.lr.y;
! 			box2.lr.x = tmp_x;
! 			box2.lr.y = tmp_y;
  		} while (--k);
  		
! 		tmp_x = box.ul.x;
! 		tmp_y = box.ul.y;
! 		box.ul.x = box.ur.x;
! 		box.ul.y = box.ur.y;
! 		box.ur.x = box.ll.x;
! 		box.ur.y = box.ll.y;
! 		box.ll.x = box.lr.x;
! 		box.ll.y = box.lr.y;
! 		box.lr.x = tmp_x;
! 		box.lr.y = tmp_y;
  	} while (--j);
  

Index: costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/costume.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** costume.cpp	2001/11/14 20:09:39	1.10
--- costume.cpp	2001/11/26 19:57:57	1.11
***************
*** 293,298 ****
  	CHECK_HEAP
  
! 	if (a->data8) {
! 		proc_special(a->data8);
  		return b;
  	}
--- 293,298 ----
  	CHECK_HEAP
  
! 	if (a->unk1) {
! 		proc_special(a->unk1);
  		return b;
  	}
***************
*** 673,677 ****
  	_ptr = _vm->getResourceAddress(rtCostume, id);
  	
! 	if (_vm->_majorScummVersion == 6) {
  		_ptr += 8;
  	} else {
--- 673,677 ----
  	_ptr = _vm->getResourceAddress(rtCostume, id);
  	
! 	if (_vm->_features&GF_AFTER_V6) {
  		_ptr += 8;
  	} else {
***************
*** 699,713 ****
  }
  
  byte CostumeRenderer::drawOneSlot(Actor *a, int slot) {
  	int i;
  	int code;
  	CostumeData *cd = &a->cost;
  
! 	if (cd->a[slot]==0xFFFF || cd->hdr & (1<<slot))
  		return 0;
  	
! 	i = cd->a[slot]&0x7FFF;
  	_frameptr = _ptr + READ_LE_UINT16(_ptr + _numColors + slot*2 + 10);
  	code = _dataptr[i]&0x7F;
  	_srcptr = _ptr + READ_LE_UINT16(_frameptr + code*2);
  
--- 699,726 ----
  }
  
+ void Scumm::initActorCostumeData(Actor *a) {
+ 	CostumeData *cd = &a->cost;
+ 	int i;
+ 
+ 	cd->stopped = 0;
+ 	for (i=0; i<16; i++) {
+ 		cd->active[i] = 0;
+ 		cd->curpos[i] = cd->start[i] = cd->end[i] = cd->frame[i] = 0xFFFF;
+ 	}
+ }
+ 
  byte CostumeRenderer::drawOneSlot(Actor *a, int slot) {
+ #if !defined(FULL_THROTTLE)
  	int i;
  	int code;
  	CostumeData *cd = &a->cost;
  
! 	if (cd->curpos[slot]==0xFFFF || cd->stopped & (1<<slot))
  		return 0;
  	
! 	i = cd->curpos[slot]&0x7FFF;
  	_frameptr = _ptr + READ_LE_UINT16(_ptr + _numColors + slot*2 + 10);
  	code = _dataptr[i]&0x7F;
+ 
  	_srcptr = _ptr + READ_LE_UINT16(_frameptr + code*2);
  
***************
*** 715,720 ****
--- 728,735 ----
  		return mainRoutine(a, slot, code);
  	}
+ #endif
  
  	return 0;
+ 
  }
  
***************
*** 734,743 ****
  	byte code,nc;
  
! 	if (a->cost.a[slot]==0xFFFF)
  		return 0;
  
! 	highflag = a->cost.a[slot]&0x8000;
! 	i = a->cost.a[slot]&0x7FFF;
! 	end = a->cost.c[slot];
  	code=_dataptr[i]&0x7F;
  
--- 749,758 ----
  	byte code,nc;
  
! 	if (a->cost.curpos[slot]==0xFFFF)
  		return 0;
  
! 	highflag = a->cost.curpos[slot]&0x8000;
! 	i = a->cost.curpos[slot]&0x7FFF;
! 	end = a->cost.end[slot];
  	code=_dataptr[i]&0x7F;
  
***************
*** 745,749 ****
  		if (!highflag) {
  			if (i++ >= end)
! 				i = a->cost.b[slot];
  		} else {
  			if (i != end)
--- 760,764 ----
  		if (!highflag) {
  			if (i++ >= end)
! 				i = a->cost.start[slot];
  		} else {
  			if (i != end)
***************
*** 755,765 ****
  		if (nc==0x7C) {
  			a->cost.animCounter1++;
! 			if(a->cost.b[slot] != end)
  				continue;
  		} else {
! 			if (_vm->_majorScummVersion == 6) {
  				if (nc>=0x71 && nc<=0x78) {
  					_vm->addSoundToQueue2(a->sound[nc-0x71]);
! 					if(a->cost.b[slot] != end)
  						continue;
  				}
--- 770,780 ----
  		if (nc==0x7C) {
  			a->cost.animCounter1++;
! 			if(a->cost.start[slot] != end)
  				continue;
  		} else {
! 			if (_vm->_features&GF_AFTER_V6) {
  				if (nc>=0x71 && nc<=0x78) {
  					_vm->addSoundToQueue2(a->sound[nc-0x71]);
! 					if(a->cost.start[slot] != end)
  						continue;
  				}
***************
*** 767,771 ****
  				if (nc==0x78) {
  					a->cost.animCounter2++;
! 					if(a->cost.b[slot] != end)
  						continue;
  				}
--- 782,786 ----
  				if (nc==0x78) {
  					a->cost.animCounter2++;
! 					if(a->cost.start[slot] != end)
  						continue;
  				}
***************
*** 773,777 ****
  		}
  
! 		a->cost.a[slot] = i|highflag;
  		return (_dataptr[i]&0x7F) != code;
  	} while(1);
--- 788,792 ----
  		}
  
! 		a->cost.curpos[slot] = i|highflag;
  		return (_dataptr[i]&0x7F) != code;
  	} while(1);
***************
*** 782,790 ****
  	byte r = 0;
  
  	for (i=0; i<16; i++) {
! 		if(a->cost.a[i]!=0xFFFF)
  			r+=animateOneSlot(a, i);
  	}
  	return r;
  }
  
--- 797,870 ----
  	byte r = 0;
  
+ #if !defined(FULL_THROTTLE)
  	for (i=0; i<16; i++) {
! 		if(a->cost.curpos[i]!=0xFFFF)
  			r+=animateOneSlot(a, i);
  	}
+ #endif
  	return r;
  }
  
+ int Scumm::cost_frameToAnim(Actor *a, int frame) {
+ 	return newDirToOldDir(a->facing) + frame * 4;
+ }
+ 
+ void Scumm::decodeCostData(Actor *a, int frame, uint usemask) {
+ 	byte *p,*r;
+ 	uint mask,j;
+ 	int i;
+ 	byte extra,cmd;
+ 	byte *dataptr;
+ 	int anim;
+ 
+ 	anim = cost_frameToAnim(a, frame);
+ 	
+ 	p = cost._ptr;
+ 	if (anim > p[6]) {
+ 		return;
+ 	}
+ 
+ 	r = p + READ_LE_UINT16(p + anim*2 + cost._numColors + 42);
+ 	if (r==p) {
+ 		return;
+ 	}
+ 
+ 	dataptr = p + READ_LE_UINT16(p + cost._numColors + 8);
+ 
+ 	mask = READ_LE_UINT16(r);
+ 	r+=2;
+ 	i = 0;
+ 	do {
+ 		if (mask&0x8000) {
+ 			j = READ_LE_UINT16(r);
+ 			r+=2;
+ 			if (usemask&0x8000) {
+ 				if (j==0xFFFF) {
+ 					a->cost.curpos[i] = 0xFFFF;
+ 					a->cost.start[i] = 0;
+ 					a->cost.frame[i] = frame;
+ 				} else {
+ 					extra = *r++;
+ 					cmd = dataptr[j];
+ 					if (cmd==0x7A) {
+ 						a->cost.stopped &= ~(1<<i);
+ 					} else if (cmd==0x79) {
+ 						a->cost.stopped |= (1<<i);
+ 					} else {
+ 						a->cost.curpos[i] = a->cost.start[i] = j;
+ 						a->cost.end[i] = j + (extra&0x7F);
+ 						if (extra&0x80)
+ 							a->cost.curpos[i] |= 0x8000;
+ 						a->cost.frame[i] = frame;
+ 					}
+ 				}
+ 			} else {
+ 				if (j!=0xFFFF)
+ 					r++;
+ 			}
+ 		}
+ 		i++;
+ 		usemask <<= 1;
+ 		mask <<= 1;
+ 	} while ((uint16)mask);
+ }

Index: debug.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/debug.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** debug.cpp	2001/11/19 00:04:34	1.9
--- debug.cpp	2001/11/26 19:57:57	1.10
***************
*** 199,203 ****
  			if (a->visible)
  				printf("|%2d|%4d|%3d  %3d|%4d|%3d|%5d|%3d|%3d|%2d|%5d|%5d|%3d|%3d|\n",
! 					i,a->room,a->x,a->y,a->elevation,a->costume,a->width,a->walkbox,a->moving,a->neverZClip,a->animIndex,a->scalex,a->speedx,a->facing);
  		}
  	}
--- 199,203 ----
  			if (a->visible)
  				printf("|%2d|%4d|%3d  %3d|%4d|%3d|%5d|%3d|%3d|%2d|%5d|%5d|%3d|%3d|\n",
! 					i,a->room,a->x,a->y,a->elevation,a->costume,a->width,a->walkbox,a->moving,a->neverZClip,a->frame,a->scalex,a->speedx,a->facing);
  		}
  	}

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gfx.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** gfx.cpp	2001/11/14 20:09:39	1.21
--- gfx.cpp	2001/11/26 19:57:57	1.22
***************
*** 261,272 ****
  	cd->_destPos = dest;
  
! 	t = _vars[VAR_CAMERA_MIN];
  	if (cd->_curPos < t) cd->_curPos = t;
  
! 	t = _vars[VAR_CAMERA_MAX];
  	if (cd->_curPos > t) cd->_curPos = t;
  
  	if (_vars[VAR_SCROLL_SCRIPT]) {
! 		_vars[VAR_CAMERA_CUR_POS] = cd->_curPos;
  		runScript(_vars[VAR_SCROLL_SCRIPT], 0, 0, 0);
  	}
--- 261,272 ----
  	cd->_destPos = dest;
  
! 	t = _vars[VAR_CAMERA_MIN_X];
  	if (cd->_curPos < t) cd->_curPos = t;
  
! 	t = _vars[VAR_CAMERA_MAX_X];
  	if (cd->_curPos > t) cd->_curPos = t;
  
  	if (_vars[VAR_SCROLL_SCRIPT]) {
! 		_vars[VAR_CAMERA_POS_X] = cd->_curPos;
  		runScript(_vars[VAR_SCROLL_SCRIPT], 0, 0, 0);
  	}
***************
*** 310,314 ****
  	room = getResourceAddress(rtRoom, _roomResource);
  
! 	ptr = findResource(MKID('RMIH'), findResource(MKID('RMIM'), room, 0), 0);
  
  	gdi._numZBuffer = READ_LE_UINT16(ptr+8) + 1;
--- 310,314 ----
  	room = getResourceAddress(rtRoom, _roomResource);
  
! 	ptr = findResource(MKID('RMIH'), findResource(MKID('RMIM'), room));
  
  	gdi._numZBuffer = READ_LE_UINT16(ptr+8) + 1;
***************
*** 382,389 ****
  	int i, j;
  	ColorCycle *cycl;
- 
- 	for (i=0,cycl=_colorCycle; i<16; i++,cycl++)
- 		cycl->delay = 0;
  
  	while ((j=*ptr++) != 0) {
  		if (j<1 || j>16) {
--- 382,388 ----
  	int i, j;
  	ColorCycle *cycl;
  
+ 	memset(_colorCycle, 0, sizeof(_colorCycle));
+ 	
  	while ((j=*ptr++) != 0) {
  		if (j<1 || j>16) {
***************
*** 538,544 ****
  	val = 0;
  
! 	if (_fullRedraw==0 && _BgNeedsRedraw) {
  		for (i=0; i<40; i++) {
! 			if (actorDrawBits[_screenStartStrip + i]&0x8000) {
  				redrawBGStrip(i, 1);
  			}
--- 537,543 ----
  	val = 0;
  
! 	if (!_fullRedraw && _BgNeedsRedraw) {
  		for (i=0; i<40; i++) {
! 			if (gfxUsageBits[_screenStartStrip + i]&0x80000000) {
  				redrawBGStrip(i, 1);
  			}
***************
*** 553,562 ****
  		redrawBGStrip(0, 1);
  	} else if (_fullRedraw!=0 || cd->_curPos != cd->_lastPos) {
! 		_BgNeedsRedraw = 0;
  		redrawBGStrip(0, 40);
  	}
  
  	drawRoomObjects(val);
! 	_BgNeedsRedraw = 0;
  }
  
--- 552,561 ----
  		redrawBGStrip(0, 1);
  	} else if (_fullRedraw!=0 || cd->_curPos != cd->_lastPos) {
! 		_BgNeedsRedraw = false;
  		redrawBGStrip(0, 40);
  	}
  
  	drawRoomObjects(val);
! 	_BgNeedsRedraw = false;
  }
  
***************
*** 568,572 ****
  };
  
! void Gdi::drawBitmap(byte *ptr, VirtScreen *vs, int x, int y, int h, int stripnr, int numstrip, bool flag) {
  	byte *smap_ptr,*where_draw_ptr;
  	int i;
--- 567,571 ----
  };
  
! void Gdi::drawBitmap(byte *ptr, VirtScreen *vs, int x, int y, int h, int stripnr, int numstrip, byte flag) {
  	byte *smap_ptr,*where_draw_ptr;
  	int i;
***************
*** 579,583 ****
  	CHECK_HEAP
  
! 	smap_ptr = findResource(MKID('SMAP'), ptr, 0);
  
  	assert(smap_ptr);
--- 578,582 ----
  	CHECK_HEAP
  
! 	smap_ptr = findResource(MKID('SMAP'), ptr);
  
  	assert(smap_ptr);
***************
*** 586,590 ****
  
  	for(i=1; i<numzbuf; i++) {
! 		zplane_list[i] = findResource(zplane_tags[i], ptr, 0);
  	}
  
--- 585,589 ----
  
  	for(i=1; i<numzbuf; i++) {
! 		zplane_list[i] = findResource(zplane_tags[i], ptr);
  	}
  
***************
*** 634,650 ****
  			
  			if (_vm->hasCharsetMask(sx<<3, y, (sx+1)<<3, bottom)) {
! 				if (_vm->_vars[VAR_V5_DRAWFLAGS]&2)
! 					draw8ColWithMasking();
! 				else
  					clear8ColWithMasking();
- 			} else {
- 				if (_vm->_vars[VAR_V5_DRAWFLAGS]&2)
- 					blit(_backbuff_ptr, _bgbak_ptr, 8, h);
  				else
  					clear8Col();
  			}
  		}
  		CHECK_HEAP
  
  		for (i=1; i<numzbuf; i++) {
  			if (!zplane_list[i])
--- 633,658 ----
  			
  			if (_vm->hasCharsetMask(sx<<3, y, (sx+1)<<3, bottom)) {
! 				if (flag&dbClear)
  					clear8ColWithMasking();
  				else
+ 					draw8ColWithMasking();
+ 			} else {
+ 				if (flag&dbClear)
  					clear8Col();
+ 				else
+ 					blit(_backbuff_ptr, _bgbak_ptr, 8, h);
  			}
  		}
  		CHECK_HEAP
  
+ 		if (flag & dbDrawMaskOnBoth) {
+ 			_z_plane_ptr = zplane_list[1] + READ_LE_UINT16(zplane_list[1] + stripnr*2 + 8);
+ 			_mask_ptr_dest = _vm->getResourceAddress(rtBuffer, 9) + y*40 + x;
+ 			if (_useOrDecompress && flag&dbAllowMaskOr)
+ 				decompressMaskImgOr();
+ 			else
+ 				decompressMaskImg();
+ 		}
+ 
  		for (i=1; i<numzbuf; i++) {
  			if (!zplane_list[i])
***************
*** 652,656 ****
  			_z_plane_ptr = zplane_list[i] + READ_LE_UINT16(zplane_list[i] + stripnr*2 + 8);
  			_mask_ptr_dest = _vm->getResourceAddress(rtBuffer, 9) + y*40 + x + _imgBufOffs[i];
! 			if (_useOrDecompress && flag)
  				decompressMaskImgOr();
  			else
--- 660,664 ----
  			_z_plane_ptr = zplane_list[i] + READ_LE_UINT16(zplane_list[i] + stripnr*2 + 8);
  			_mask_ptr_dest = _vm->getResourceAddress(rtBuffer, 9) + y*40 + x + _imgBufOffs[i];
! 			if (_useOrDecompress && flag&dbAllowMaskOr)
  				decompressMaskImgOr();
  			else
***************
*** 870,878 ****
  	int s = _screenStartStrip + start;
  
! 	assert(s>=0 && s<sizeof(actorDrawBits)/sizeof(actorDrawBits[0]));
  
  	_curVirtScreen = &virtscr[0];
  
! 	actorDrawBits[s]|=0x8000;
  	if (_curVirtScreen->height > _scrHeight) {
  		error("Screen Y size %d < Room height %d",
--- 878,886 ----
  	int s = _screenStartStrip + start;
  
! 	assert(s>=0 && s<sizeof(gfxUsageBits)/sizeof(gfxUsageBits[0]));
  
  	_curVirtScreen = &virtscr[0];
  
! 	gfxUsageBits[s]|=0x80000000;
  	if (_curVirtScreen->height > _scrHeight) {
  		error("Screen Y size %d < Room height %d",
***************
*** 1209,1213 ****
  		bottom=height;
  
! 	updateDirtyRect(vs->number, left, right, top-topline,bottom-topline, 0x4000);
  
  	height = (top-topline) * 320 + vs->xstart + left;
--- 1217,1221 ----
  		bottom=height;
  
! 	updateDirtyRect(vs->number, left, right, top-topline,bottom-topline, 0x40000000);
  
  	height = (top-topline) * 320 + vs->xstart + left;
***************
*** 1224,1228 ****
  	widthmod = (width >> 2) + 2;
  
! 	if (vs->alloctwobuffers && _currentRoom!=0 && _vars[VAR_V5_DRAWFLAGS]&2) {
  		blit(backbuff, bgbak, width, height);
  		if (vs->number==0 && charset._hasMask && height) {
--- 1232,1236 ----
  	widthmod = (width >> 2) + 2;
  
! 	if (vs->alloctwobuffers && _currentRoom!=0 /*&& _vars[VAR_V5_DRAWFLAGS]&2*/) {
  		blit(backbuff, bgbak, width, height);
  		if (vs->number==0 && charset._hasMask && height) {
***************
*** 1242,1249 ****
  }
  
! void Scumm::updateDirtyRect(int virt, int left, int right, int top, int bottom, uint16 dirtybits) {
  	VirtScreen *vs = &virtscr[virt];
  	int lp,rp;
! 	uint16 *sp;
  	int num;
  
--- 1250,1257 ----
  }
  
! void Scumm::updateDirtyRect(int virt, int left, int right, int top, int bottom, uint32 dirtybits) {
  	VirtScreen *vs = &virtscr[virt];
  	int lp,rp;
! 	uint32 *sp;
  	int num;
  
***************
*** 1264,1268 ****
  		if (lp <= rp) {
  			num = rp - lp + 1;
! 			sp = &actorDrawBits[lp];
  			do {
  				*sp++ |= dirtybits;
--- 1272,1276 ----
  		if (lp <= rp) {
  			num = rp - lp + 1;
! 			sp = &gfxUsageBits[lp];
  			do {
  				*sp++ |= dirtybits;
***************
*** 1436,1442 ****
  	cd->_curPos &= 0xFFF8;
  
! 	if (cd->_curPos < _vars[VAR_CAMERA_MIN]) {
! 		if (_vars[VAR_CAMERA_FAST])
! 			cd->_curPos = _vars[VAR_CAMERA_MIN];
  		else
  			cd->_curPos += 8;
--- 1444,1450 ----
  	cd->_curPos &= 0xFFF8;
  
! 	if (cd->_curPos < _vars[VAR_CAMERA_MIN_X]) {
! 		if (_vars[VAR_CAMERA_FAST_X])
! 			cd->_curPos = _vars[VAR_CAMERA_MIN_X];
  		else
  			cd->_curPos += 8;
***************
*** 1445,1451 ****
  	}
  
! 	if (cd->_curPos > _vars[VAR_CAMERA_MAX]) {
! 		if (_vars[VAR_CAMERA_FAST])
! 			cd->_curPos = _vars[VAR_CAMERA_MAX];
  		else
  			cd->_curPos-=8;
--- 1453,1459 ----
  	}
  
! 	if (cd->_curPos > _vars[VAR_CAMERA_MAX_X]) {
! 		if (_vars[VAR_CAMERA_FAST_X])
! 			cd->_curPos = _vars[VAR_CAMERA_MAX_X];
  		else
  			cd->_curPos-=8;
***************
*** 1461,1465 ****
  		
  		if (t < cd->_leftTrigger || t > cd->_rightTrigger) {
! 			if (_vars[VAR_CAMERA_FAST]) {
  				if (t > 35)
  					cd->_destPos = actorx + 80;
--- 1469,1473 ----
  		
  		if (t < cd->_leftTrigger || t > cd->_rightTrigger) {
! 			if (_vars[VAR_CAMERA_FAST_X]) {
  				if (t > 35)
  					cd->_destPos = actorx + 80;
***************
*** 1476,1486 ****
  	}
  
! 	if (cd->_destPos < _vars[VAR_CAMERA_MIN])
! 		cd->_destPos = _vars[VAR_CAMERA_MIN];
  
! 	if (cd->_destPos > _vars[VAR_CAMERA_MAX])
! 		cd->_destPos = _vars[VAR_CAMERA_MAX];
  
! 	if (_vars[VAR_CAMERA_FAST]) {
  		cd->_curPos = cd->_destPos;
  	} else {
--- 1484,1494 ----
  	}
  
! 	if (cd->_destPos < _vars[VAR_CAMERA_MIN_X])
! 		cd->_destPos = _vars[VAR_CAMERA_MIN_X];
  
! 	if (cd->_destPos > _vars[VAR_CAMERA_MAX_X])
! 		cd->_destPos = _vars[VAR_CAMERA_MAX_X];
  
! 	if (_vars[VAR_CAMERA_FAST_X]) {
  		cd->_curPos = cd->_destPos;
  	} else {
***************
*** 1499,1503 ****
  
  	if (pos != cd->_curPos && _vars[VAR_SCROLL_SCRIPT]) {
! 		_vars[VAR_CAMERA_CUR_POS] = cd->_curPos;
  		runScript(_vars[VAR_SCROLL_SCRIPT], 0, 0, 0);
  	}
--- 1507,1511 ----
  
  	if (pos != cd->_curPos && _vars[VAR_SCROLL_SCRIPT]) {
! 		_vars[VAR_CAMERA_POS_X] = cd->_curPos;
  		runScript(_vars[VAR_SCROLL_SCRIPT], 0, 0, 0);
  	}
***************
*** 1628,1638 ****
  void Scumm::resetActorBgs() {
  	Actor *a;
! 	int i,bitpos;
! 	int top,bottom;
! 	uint16 onlyActorFlags;
  	int offs;
  	
  	for(i=0; i<40; i++) {
! 		onlyActorFlags = (actorDrawBits[_screenStartStrip + i]&=0x3FFF);
  		a = getFirstActor();
  		bitpos = 1;
--- 1636,1645 ----
  void Scumm::resetActorBgs() {
  	Actor *a;
! 	int i;
! 	uint32 onlyActorFlags,bitpos;
  	int offs;
  	
  	for(i=0; i<40; i++) {
! 		onlyActorFlags = (gfxUsageBits[_screenStartStrip + i]&=0x3FFFFFFF);
  		a = getFirstActor();
  		bitpos = 1;
***************
*** 1640,1648 ****
  		while (onlyActorFlags) {
  			if(onlyActorFlags&1 && a->top!=0xFF && a->needBgReset) {
! 				top = a->top;
! 				bottom = a->bottom;
! 				actorDrawBits[_screenStartStrip + i] ^= bitpos;
  				gdi.resetBackground(a->top, a->bottom, i);
- 
  			}
  			bitpos<<=1;
--- 1647,1652 ----
  		while (onlyActorFlags) {
  			if(onlyActorFlags&1 && a->top!=0xFF && a->needBgReset) {
! 				gfxUsageBits[_screenStartStrip + i] ^= bitpos;
  				gdi.resetBackground(a->top, a->bottom, i);
  			}
  			bitpos<<=1;
***************
*** 1674,1678 ****
  	_numLinesToProcess = bottom - top;
  	if (_numLinesToProcess) {
! 		if (_vm->_vars[VAR_V5_DRAWFLAGS]&2) {
  			if(_vm->hasCharsetMask(strip<<3, top, (strip+1)<<3, bottom))
  				draw8ColWithMasking();
--- 1678,1682 ----
  	_numLinesToProcess = bottom - top;
  	if (_numLinesToProcess) {
! 		if (1/*_vm->_vars[VAR_V5_DRAWFLAGS]&2*/) {
  			if(_vm->hasCharsetMask(strip<<3, top, (strip+1)<<3, bottom))
  				draw8ColWithMasking();
***************
*** 1762,1770 ****
  	uint32 size;	
  
! 	pal = findResource(MKID('WRAP'), pal, 0);
  	if (pal==NULL)
  		return NULL;
  
! 	offs = findResource(MKID('OFFS'),pal, 0);
  	if (offs==NULL)
  		return NULL;
--- 1766,1774 ----
  	uint32 size;	
  
! 	pal = findResource(MKID('WRAP'), pal);
  	if (pal==NULL)
  		return NULL;
  
! 	offs = findResource(MKID('OFFS'),pal);
  	if (offs==NULL)
  		return NULL;
***************
*** 1946,1947 ****
--- 1950,2001 ----
  	}
  }
+ 
+ 
+ int Scumm::remapPaletteColor(byte r, byte g, byte b, uint threshold) {
+ 	int i;
+ 	byte ar,ag,ab;
+ 	uint sum,j,bestsum,bestitem;
+ 	byte *pal = _currentPalette;
+ 
+ 	bestsum = (uint)-1;
+ 
+ 	r &= ~3;
+ 	g &= ~3;
+ 	b &= ~3;
+ 
+ 	for(i=0; i<256; i++,pal+=3) {
+ 		ar = pal[0]&~3;
+ 		ag = pal[1]&~3;
+ 		ab = pal[2]&~3;
+ 		if (ar==r && ag==g && ab==b)
+ 			return i;
+ 
+ 		j=abs(ar-r)*3;
+ 		sum = j*j;
+ 		j=abs(ag-g)*6;
+ 		sum += j*j;
+ 		j=abs(ab-b)*2;
+ 		sum += j*j;
+ 
+ 		if (sum < bestsum) {
+ 			bestsum = sum;
+ 			bestitem = i;
+ 		}
+ 	}
+ 
+ 	if (threshold != -1 && bestsum > threshold*threshold*(2+3+6)) {
+ 		pal = _currentPalette + (256-2)*3;
+ 		for(i=254; i>48; i--,pal-=3) {
+ 			if (pal[0]>=252 && pal[1]>=252 && pal[2]>=252) {
+ 				setPalColor(i, r, g, b);
+ 				return i;
+ 			}
+ 		}
+ 	}
+ 
+ 	return bestitem;
+ }
+ 
+ void Scumm::setupShadowPalette(int slot,int rfact,int gfact,int bfact,int from,int to) {
+ 	
+ }
\ No newline at end of file

Index: gui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** gui.cpp	2001/11/14 20:09:39	1.4
--- gui.cpp	2001/11/26 19:57:57	1.5
***************
*** 367,371 ****
  	}
  
! 	if (_s->_majorScummVersion==6) {
  		string = _s->_vars[string_map_table_v6[string-1]];
  	} else {
--- 367,371 ----
  	}
  
! 	if (_s->_features&GF_AFTER_V6) {
  		string = _s->_vars[string_map_table_v6[string-1]];
  	} else {
***************
*** 438,442 ****
  
  byte Gui::getDefaultColor(int color) {
! 	if (_s->_majorScummVersion == 6) {
  		if (color==8) color=1;
  		return _s->readArray(110, 0, color);
--- 438,445 ----
  
  byte Gui::getDefaultColor(int color) {
! #if defined(FULL_THROTTLE)
! 	return 0;
! #else
! 	if (_s->_features&GF_AFTER_V6) {
  		if (color==8) color=1;
  		return _s->readArray(110, 0, color);
***************
*** 444,447 ****
--- 447,451 ----
  		return _s->getStringAddress(21)[color];
  	}
+ #endif
  }
  

Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/object.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** object.cpp	2001/11/12 20:50:36	1.14
--- object.cpp	2001/11/26 19:57:57	1.15
***************
*** 46,74 ****
  int Scumm::getOwner(int obj) {
  	checkRange(_numGlobalObjects-1, 0, obj, "Object %d out of range in getOwner");
! 	return _objectFlagTable[obj]&OF_OWNER_MASK;
  }
  
  void Scumm::putOwner(int act, int owner) {
  	checkRange(_numGlobalObjects-1, 0, act, "Object %d out of range in putOwner");
! 	checkRange(15, 0, owner, "Owner %d out of range in putOwner");
! 	_objectFlagTable[act] = (_objectFlagTable[act]&~OF_OWNER_MASK) | owner;
  }
[...1114 lines suppressed...]
+ 	obim_size = READ_BE_UINT32(foir.obim + 4);
+ 	flob_size = obcd_size + obim_size + 8;
+ 
+ 	/* Allocate slot & memory for floating object */
+ 	slot = findFlObjectSlot();
+ 	createResource(rtFlObject, slot, flob_size);
+ 
+ 	/* Copy object code + object image to floating object */
+ 	roomptr = getResourceAddress(rtRoom, room);
+ 	flob = getResourceAddress(rtFlObject, slot);
+ 	((uint32*)flob)[0] = MKID('FLOB');
+ 	((uint32*)flob)[1] = TO_BE_32(flob_size);
+ 	memcpy(flob + 8, roomptr - foir.roomptr + foir.obcd, obcd_size);
+ 	memcpy(flob + 8 + obcd_size, roomptr - foir.roomptr + foir.obim, obim_size);
+ 
+ 	/* Setup local object flags */
+ 	setupRoomObject(od, flob);
+ 
+ 	od->fl_object_index = slot;
+ }

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/resource.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** resource.cpp	2001/11/14 20:09:39	1.21
--- resource.cpp	2001/11/26 19:57:57	1.22
***************
*** 59,66 ****
  			return;
  		}
  		sprintf(buf, "%s.%.3d", _exe_name, 
  			room==0 ? 0 : res.roomno[rtRoom][room]);
! 
! 		_encbyte = 0x69;
  		if (openResourceFile(buf)) {
  			if (room==0)
--- 59,70 ----
  			return;
  		}
+ #if defined(FULL_THROTTLE)
+ 		sprintf(buf, "%s.la%d", _exe_name, 
+ 			room==0 ? 0 : res.roomno[rtRoom][room]);
+ #else
  		sprintf(buf, "%s.%.3d", _exe_name, 
  			room==0 ? 0 : res.roomno[rtRoom][room]);
! #endif
! 		_encbyte = (_features & GF_USE_KEY) ? 0x69 : 0;
  		if (openResourceFile(buf)) {
  			if (room==0)
***************
*** 153,258 ****
  }
  
! void Scumm::readIndexFileV5(int mode) {
  	uint32 blocktype,itemsize;
  	int numblock = 0;
! #if defined(SCUMM_BIG_ENDIAN)
! 	int i;
! #endif
  
! 	debug(9, "readIndexFile(%d)",mode);
  
  	openRoom(-1);
  	openRoom(0);
- 	
- 	while (1) {
- 		blocktype = fileReadDword();
  
! 		if (fileReadFailed(_fileHandle))
! 			break;
! 		itemsize = fileReadDwordBE();
  
! 		numblock++;
  
! 		switch(blocktype) {
! 		case MKID('DCHR'):
! 			readResTypeList(rtCharset,MKID('CHAR'),"charset");
! 			break;
  
! 		case MKID('DOBJ'):
! 			_numGlobalObjects = fileReadWordLE();
! 			_objectFlagTable = (byte*)alloc(_numGlobalObjects);
! 			if (mode==1) {
! 				fileSeek(_fileHandle, itemsize - 10, 1);
  				break;
  			}
! 
! 			_classData = (uint32*)alloc(_numGlobalObjects * sizeof(uint32));
! 			fileRead(_fileHandle, _objectFlagTable, _numGlobalObjects);
! 			fileRead(_fileHandle, _classData, _numGlobalObjects * sizeof(uint32));
! #if defined(SCUMM_BIG_ENDIAN)
! 			for (i=0; i<_numGlobalObjects; i++)
! 				_classData[i] = FROM_LE_32(_classData[i]);
! #endif
! 			break;
! 
! 		case MKID('RNAM'):
! 			fileSeek(_fileHandle, itemsize-8,1);
! 			break;
! 
! 		case MKID('DROO'):
! 			readResTypeList(rtRoom,MKID('ROOM'),"room");
! 			break;
! 
! 		case MKID('DSCR'):
! 			readResTypeList(rtScript,MKID('SCRP'),"script");
! 			break;
! 
! 		case MKID('DCOS'):
! 			readResTypeList(rtCostume,MKID('COST'),"costume");
! 			break;
! 
! 		case MKID('MAXS'):
! 			fileReadWordLE();
! 			fileReadWordLE();
! 			fileReadWordLE();
! 			fileReadWordLE();
! 			fileReadWordLE();
! 			fileReadWordLE();
! 			fileReadWordLE();
! 			fileReadWordLE();
! 			fileReadWordLE();
! 			break;
! 
! 		case MKID('DSOU'):
! 			readResTypeList(rtSound,MKID('SOUN'),"sound");
! 			break;
! 
! 		default:
! 			error("Bad ID %c%c%c%c found in directory!", blocktype&0xFF, blocktype>>8, blocktype>>16, blocktype>>24);
! 			return;
  		}
  	}
  
- 	clearFileReadFailed(_fileHandle);
- 
- 	if (numblock!=8)
- 		error("Not enough blocks read from directory");
- 
- 	openRoom(-1);
- 	
- 	_numGlobalScripts = _maxScripts;
- 	_dynamicRoomOffsets = true;
- }
- 
- void Scumm::readIndexFileV6() {
- 	uint32 blocktype,itemsize;
- 	int numblock = 0;
- 	int num, i;
- 
- 	debug(9, "readIndexFile()");
- 
- 	openRoom(-1);
- 	openRoom(0);
- 	
  	while (1) {
  		blocktype = fileReadDword();
--- 157,208 ----
  }
  
! void Scumm::readIndexFile() {
  	uint32 blocktype,itemsize;
  	int numblock = 0;
! 	int num, i;
  
! 	debug(9, "readIndexFile()");
  
  	openRoom(-1);
  	openRoom(0);
  
! 	if (!(_features & GF_AFTER_V6)) {
! 		/* Figure out the sizes of various resources */
! 		while (!fileEof(_fileHandle)) {
! 			blocktype = fileReadDword();
! 			itemsize = fileReadDwordBE();
! 			if (fileReadFailed(_fileHandle))
! 				break;
! 			switch(blocktype) {
! 			case MKID('DOBJ'):
! 				_numGlobalObjects = fileReadWordLE();
! 				itemsize-=2;
! 				break;
! 			case MKID('DROO'):
! 				_numRooms = fileReadWordLE();
! 				itemsize-=2;
! 				break;
  
! 			case MKID('DSCR'):
! 				_numScripts = fileReadWordLE();
! 				itemsize-=2;
! 				break;
  
! 			case MKID('DCOS'):
! 				_numCostumes = fileReadWordLE();
! 				itemsize-=2;
! 				break;
  
! 			case MKID('DSOU'):
! 				_numSounds = fileReadWordLE();
! 				itemsize-=2;
  				break;
  			}
! 			fileSeek(_fileHandle, itemsize-8,SEEK_CUR);
  		}
+ 		clearFileReadFailed(_fileHandle);
+ 		fileSeek(_fileHandle, 0, SEEK_SET);
  	}
  
  	while (1) {
  		blocktype = fileReadDword();
***************
*** 264,268 ****
  		numblock++;
  
! 			switch(blocktype) {
  		case MKID('DCHR'):
  			readResTypeList(rtCharset,MKID('CHAR'),"charset");
--- 214,218 ----
  		numblock++;
  
! 		switch(blocktype) {
  		case MKID('DCHR'):
  			readResTypeList(rtCharset,MKID('CHAR'),"charset");
***************
*** 270,285 ****
  
  		case MKID('DOBJ'):
! 			 num = fileReadWordLE();
! 			 assert(num == _numGlobalObjects);
! 			fileRead(_fileHandle, _objectFlagTable, num);
  			fileRead(_fileHandle, _classData, num * sizeof(uint32));
  #if defined(SCUMM_BIG_ENDIAN)
! 			for (i=0; i<_numGlobalObjects; i++)
  				_classData[i] = FROM_LE_32(_classData[i]);
  #endif
  			break;
  
  		case MKID('RNAM'):
! 			fileSeek(_fileHandle, itemsize-8,1);
  			break;
  
--- 220,250 ----
  
  		case MKID('DOBJ'):
! 			num = fileReadWordLE();
! 			assert(num == _numGlobalObjects);
! 			
! 			if (_features & GF_AFTER_V7) {
! 				fileRead(_fileHandle, _objectStateTable, num);
! 				fileRead(_fileHandle, _objectRoomTable, num);
! 				memset(_objectOwnerTable, 0xFF, num);
! 				
! 			} else {
! 				fileRead(_fileHandle, _objectOwnerTable, num);
! 				for (i=0; i<num; i++) {
! 					_objectStateTable[i] = _objectOwnerTable[i]>>OF_STATE_SHL;
! 					_objectOwnerTable[i] &= OF_OWNER_MASK;
! 				}
! 			}
  			fileRead(_fileHandle, _classData, num * sizeof(uint32));
+ 			
  #if defined(SCUMM_BIG_ENDIAN)
! 			for (i=0; i<num; i++) {
  				_classData[i] = FROM_LE_32(_classData[i]);
+ 			}
  #endif
  			break;
  
  		case MKID('RNAM'):
! 		case MKID('ANAM'):
! 			fileSeek(_fileHandle, itemsize-8,SEEK_CUR);
  			break;
  
***************
*** 313,321 ****
  		}
  	}
- 
- 	clearFileReadFailed(_fileHandle);
  
! 	if (numblock!=9)
! 		error("Not enough blocks read from directory");
  
  	openRoom(-1);
--- 278,284 ----
  		}
  	}
  
! //	if (numblock!=9)
! //		error("Not enough blocks read from directory");
  
  	openRoom(-1);
***************
*** 346,350 ****
  	num = fileReadWordLE();
  
! 	if (_majorScummVersion == 6) {
  		if (num != res.num[id]) {
  			error("Invalid number of %ss (%d) in directory", name, num);	
--- 309,313 ----
  	num = fileReadWordLE();
  
! 	if (1 || _features&GF_AFTER_V6) {
  		if (num != res.num[id]) {
  			error("Invalid number of %ss (%d) in directory", name, num);	
***************
*** 371,375 ****
  	assert(id>=0 && id<sizeof(res.mode)/sizeof(res.mode[0]));
  
! 	if (num>=512) {
  		error("Too many %ss (%d) in directory", name, num);
  	}
--- 334,338 ----
  	assert(id>=0 && id<sizeof(res.mode)/sizeof(res.mode[0]));
  
! 	if (num>=2000) {
  		error("Too many %ss (%d) in directory", name, num);
  	}
***************
*** 426,431 ****
--- 389,396 ----
  	loadResource(type, i);
  
+ #if !defined(FULL_THROTTLE)
  	if (type==rtRoom && i==_roomResource)
  		_vars[VAR_ROOM_FLAG] = 1;
+ #endif
  }
  
***************
*** 435,439 ****
  	uint32 size, tag;
  	
! 	debug(9, "loadResource(%d,%d)", type,index);
  
  	roomNr = getResourceRoomNr(type, index);
--- 400,404 ----
  	uint32 size, tag;
  	
! //	debug(1, "loadResource(%d,%d)", type,index);
  
  	roomNr = getResourceRoomNr(type, index);
***************
*** 504,508 ****
  	size = fileReadDwordBE();
  
! #ifdef SAMNMAX
  	if (basetag == MKID('MIDI')) {
  		fileSeek(_fileHandle, -8, SEEK_CUR);
--- 469,473 ----
  	size = fileReadDwordBE();
  
! #if defined(SAMNMAX) || defined(FULL_THROTTLE)
  	if (basetag == MKID('MIDI')) {
  		fileSeek(_fileHandle, -8, SEEK_CUR);
***************
*** 566,570 ****
  		return b;
  	
! 	if (_majorScummVersion==6)
  		return ((ArrayHeader*)b)->data;
  	return b;
--- 531,535 ----
  		return b;
  	
! 	if (_features & GF_NEW_OPCODES)
  		return ((ArrayHeader*)b)->data;
  	return b;
***************
*** 587,591 ****
  
  	if (size > 65536*4+37856)
! 		error("Invalid size allocating");
  
  	validateResource("allocating", type, index);
--- 552,556 ----
  
  	if (size > 65536*4+37856)
! 		warning("Probably invalid size allocating");
  
  	validateResource("allocating", type, index);
***************
*** 632,635 ****
--- 597,641 ----
  }
  
+ byte *Scumm::findResourceData(uint32 tag, byte *ptr) {
+ 	ptr = findResource(tag,ptr);
+ 	if (ptr==NULL)
+ 		return NULL;
+ 	return ptr + 8;
+ }
+ 
+ struct FindResourceState {
+ 	uint32 size,pos;
+ 	byte *ptr;
+ };
+ 
+ /* just O(N) complexity when iterating with this function */
+ byte *findResource(uint32 tag, byte *searchin) {
+ 	uint32 size;
+ 	static FindResourceState frs;
+ 	FindResourceState *f = &frs; /* easier to make it thread safe like this */
+ 
+ 	if (searchin) {
+ 		f->size = READ_BE_UINT32_UNALIGNED(searchin+4);
+ 		f->pos = 8;
+ 		f->ptr = searchin+8;
+ 		goto StartScan;
+ 	}
+ 
+ 	do {
+ 		size = READ_BE_UINT32_UNALIGNED(f->ptr+4);
+ 		if ((int32)size <= 0)
+ 			return NULL;
+ 
+ 		f->pos += size;
+ 		f->ptr += size;
+ 		
+ StartScan:
+ 		if (f->pos >= f->size)
+ 			return NULL;
+ 	} while (READ_UINT32_UNALIGNED(f->ptr) != tag);
+ 
+ 	return f->ptr;
+ }
+ 
  byte *findResource(uint32 tag, byte *searchin, int index) {
  	uint32 maxsize,curpos,totalsize,size;
***************
*** 713,716 ****
--- 719,724 ----
  	uint32 oldAllocatedSize;
  
+ 	return;
+ 
  	if (_expire_counter != 0xFF) {
  		_expire_counter = 0xFF;
***************
*** 818,861 ****
  } 
  
- void Scumm::loadFlObject(int a, int b) {
- 	warning("loadFlObject(%d,%d):not implemented", a, b);
- }
- 
  void Scumm::readMAXS() {
! 	_numVariables = fileReadWordLE();
! 	fileReadWordLE();
! 	_numBitVariables = fileReadWordLE();
! 	_numLocalObjects = fileReadWordLE();
! 	_numArray = fileReadWordLE();
! 	fileReadWordLE();
! 	_numVerbs = fileReadWordLE();
! 	_numFlObject = fileReadWordLE();
! 	_numInventory = fileReadWordLE();
! 	_numRooms = fileReadWordLE();
! 	_numScripts = fileReadWordLE();
! 	_numSounds = fileReadWordLE();
! 	_numCharsets = fileReadWordLE();
! 	_numCostumes = fileReadWordLE();
! 	_numGlobalObjects = fileReadWordLE();
  
! 	allocResTypeData(rtCostume, MKID('COST'), _numCostumes, "costume", 1);
! 	allocResTypeData(rtRoom, MKID('ROOM'), _numRooms, "room", 1);
! 	allocResTypeData(rtSound, MKID('SOUN'), _numSounds, "sound", 1);
! 	allocResTypeData(rtScript, MKID('SCRP'), _numScripts, "script", 1);
! 	allocResTypeData(rtCharset, MKID('CHAR'), _numCharsets, "charset", 1);
! 	allocResTypeData(rtObjectName, MKID('NONE'),50,"new name", 0);
! 	
! 	allocateArrays();
  
! 	_objectFlagTable = (byte*)alloc(_numGlobalObjects);
! 	_arrays = (byte*)alloc(_numArray);
! 	_newNames = (uint16*)alloc(50 * sizeof(uint16));
! 	_classData = (uint32*)alloc(_numGlobalObjects * sizeof(uint32));
  
! 	_numGlobalScripts = 200;
  	_dynamicRoomOffsets = 1;
  }
  
  void Scumm::allocateArrays() {
  	_inventory = (uint16*)alloc(_numInventory * sizeof(uint16));
  	_verbs = (VerbSlot*)alloc(_numVerbs * sizeof(VerbSlot));
--- 826,900 ----
  } 
  
  void Scumm::readMAXS() {
! 	if (_features & GF_AFTER_V7) {
! 		fileSeek(_fileHandle, 50+50, SEEK_CUR);
! 		_numVariables = fileReadWordLE();
! 		_numBitVariables = fileReadWordLE();
! 		fileReadWordLE();
! 		_numGlobalObjects = fileReadWordLE();
! 		_numLocalObjects = fileReadWordLE();
! 		_numNewNames = fileReadWordLE();
! 		_numVerbs = fileReadWordLE();
! 		_numFlObject = fileReadWordLE();
! 		_numInventory = fileReadWordLE();
! 		_numArray = fileReadWordLE();
! 		_numRooms = fileReadWordLE();
! 		_numScripts = fileReadWordLE();
! 		_numSounds = fileReadWordLE();
! 		_numCharsets = fileReadWordLE();
! 		_numCostumes = fileReadWordLE();
  
! 		_objectRoomTable = (byte*)alloc(_numGlobalObjects);
! 		_numGlobalScripts = 2000;
! 	} else if (_features & GF_AFTER_V6) {
! 		_numVariables = fileReadWordLE();
! 		fileReadWordLE();
! 		_numBitVariables = fileReadWordLE();
! 		_numLocalObjects = fileReadWordLE();
! 		_numArray = fileReadWordLE();
! 		fileReadWordLE();
! 		_numVerbs = fileReadWordLE();
! 		_numFlObject = fileReadWordLE();
! 		_numInventory = fileReadWordLE();
! 		_numRooms = fileReadWordLE();
! 		_numScripts = fileReadWordLE();
! 		_numSounds = fileReadWordLE();
! 		_numCharsets = fileReadWordLE();
! 		_numCostumes = fileReadWordLE();
! 		_numGlobalObjects = fileReadWordLE();
! 		_numNewNames = 50;
  
! 		_objectRoomTable = NULL;
! 		_numGlobalScripts = 200;
! 	} else {
! 		_numVariables = fileReadWordLE(); /* 800 */
! 		fileReadWordLE(); /* 16 */
! 		_numBitVariables = fileReadWordLE(); /* 2048 */
! 		_numLocalObjects = fileReadWordLE(); /* 200 */
! 		_numArray = 50;
! 		_numVerbs = 100;
! 		_numNewNames = 0;
! 		_objectRoomTable = NULL;
  
! 		fileReadWordLE(); /* 50 */
! 		_numCharsets = fileReadWordLE(); /* 9 */
! 		fileReadWordLE(); /* 100 */
! 		fileReadWordLE(); /* 50 */
! 		_numInventory = fileReadWordLE(); /* 80 */
! 		_numGlobalScripts = 200;
! 	}
! 
! 	
! 	allocateArrays();
  	_dynamicRoomOffsets = 1;
  }
  
  void Scumm::allocateArrays() {
+ 	_objectOwnerTable = (byte*)alloc(_numGlobalObjects);
+ 	_objectStateTable = (byte*)alloc(_numGlobalObjects);
+ 	_classData = (uint32*)alloc(_numGlobalObjects * sizeof(uint32));
+ 	_arrays = (byte*)alloc(_numArray);
+ 	_newNames = (uint16*)alloc(_numNewNames * sizeof(uint16));
+ 	
  	_inventory = (uint16*)alloc(_numInventory * sizeof(uint16));
  	_verbs = (VerbSlot*)alloc(_numVerbs * sizeof(VerbSlot));
***************
*** 864,867 ****
--- 903,916 ----
  	_bitVars = (byte*)alloc(_numBitVariables >> 3);
  
+ #if defined(FULL_THROTTLE)
+ 	allocResTypeData(rtCostume, MKID('AKOS'), _numCostumes, "costume", 1);
+ #else
+ 	allocResTypeData(rtCostume, MKID('COST'), _numCostumes, "costume", 1);
+ #endif
+ 	allocResTypeData(rtRoom, MKID('ROOM'), _numRooms, "room", 1);
+ 	allocResTypeData(rtSound, MKID('SOUN'), _numSounds, "sound", 1);
+ 	allocResTypeData(rtScript, MKID('SCRP'), _numScripts, "script", 1);
+ 	allocResTypeData(rtCharset, MKID('CHAR'), _numCharsets, "charset", 1);
+ 	allocResTypeData(rtObjectName, MKID('NONE'),_numNewNames,"new name", 0);
  	allocResTypeData(rtInventory, MKID('NONE'),	_numInventory, "inventory", 0);
  	allocResTypeData(rtTemp,MKID('NONE'),10, "temp", 0);

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saveload.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** saveload.cpp	2001/11/14 20:09:39	1.16
--- saveload.cpp	2001/11/26 19:57:57	1.17
***************
*** 139,142 ****
--- 139,143 ----
  	debug(1,"State loaded from '%s'", filename);
  
+ 
  	pauseSounds(false);
  
***************
*** 194,205 ****
  		MKLINE(ObjectData,x_pos,sleInt16),
  		MKLINE(ObjectData,y_pos,sleInt16),
! 		MKLINE(ObjectData,numstrips,sleUint16),
  		MKLINE(ObjectData,height,sleUint16),
  		MKLINE(ObjectData,actordir,sleByte),
  		MKLINE(ObjectData,parentstate,sleByte),
  		MKLINE(ObjectData,parent,sleByte),
! 		MKLINE(ObjectData,ownerstate,sleByte),
  		MKLINE(ObjectData,fl_object_index,sleByte),
- 		MKLINE(ObjectData,unk_3,sleByte),
  		MKEND()
  	};
--- 195,205 ----
  		MKLINE(ObjectData,x_pos,sleInt16),
  		MKLINE(ObjectData,y_pos,sleInt16),
! 		MKLINE(ObjectData,width,sleUint16),
  		MKLINE(ObjectData,height,sleUint16),
  		MKLINE(ObjectData,actordir,sleByte),
  		MKLINE(ObjectData,parentstate,sleByte),
  		MKLINE(ObjectData,parent,sleByte),
! 		MKLINE(ObjectData,state,sleByte),
  		MKLINE(ObjectData,fl_object_index,sleByte),
  		MKEND()
  	};
***************
*** 212,216 ****
  		MKLINE(Actor,elevation,sleInt16),
  		MKLINE(Actor,width,sleUint16),
! 		MKLINE(Actor,facing,sleByte),
  		MKLINE(Actor,costume,sleUint16),
  		MKLINE(Actor,room,sleByte),
--- 212,216 ----
  		MKLINE(Actor,elevation,sleInt16),
  		MKLINE(Actor,width,sleUint16),
! 		MKLINE(Actor,facing,sleUint16),
  		MKLINE(Actor,costume,sleUint16),
  		MKLINE(Actor,room,sleByte),
***************
*** 220,224 ****
  		MKLINE(Actor,charset,sleByte),
  		MKARRAY(Actor,sound[0],sleByte, 8),
! 		MKLINE(Actor,newDirection,sleByte),
  		MKLINE(Actor,moving,sleByte),
  		MKLINE(Actor,ignoreBoxes,sleByte),
--- 220,225 ----
  		MKLINE(Actor,charset,sleByte),
  		MKARRAY(Actor,sound[0],sleByte, 8),
! 		MKARRAY(Actor,animVariable[0],sleUint16, 8),
! 		MKLINE(Actor,newDirection,sleUint16),
  		MKLINE(Actor,moving,sleByte),
  		MKLINE(Actor,ignoreBoxes,sleByte),
***************
*** 233,240 ****
  		MKLINE(Actor,cost.animCounter1,sleUint16),
  		MKLINE(Actor,cost.animCounter2,sleByte),
! 		MKARRAY(Actor,palette[0],sleByte,32),
  		MKLINE(Actor,mask,sleByte),
  		MKLINE(Actor,visible,sleByte),
! 		MKLINE(Actor,animIndex,sleByte),
  		MKLINE(Actor,animSpeed,sleByte),
  		MKLINE(Actor,animProgress,sleByte),
--- 234,242 ----
  		MKLINE(Actor,cost.animCounter1,sleUint16),
  		MKLINE(Actor,cost.animCounter2,sleByte),
! 		MKARRAY(Actor,palette[0],sleByte,64),
  		MKLINE(Actor,mask,sleByte),
+ 		MKLINE(Actor,unk1,sleByte),
  		MKLINE(Actor,visible,sleByte),
! 		MKLINE(Actor,frame,sleByte),
  		MKLINE(Actor,animSpeed,sleByte),
  		MKLINE(Actor,animProgress,sleByte),
***************
*** 248,257 ****
  		MKLINE(Actor,new_3,sleByte),
  
  		MKLINE(Actor,walkdata.destx,sleInt16),
  		MKLINE(Actor,walkdata.desty,sleInt16),
  		MKLINE(Actor,walkdata.destbox,sleByte),
! 		MKLINE(Actor,walkdata.destdir,sleByte),
  		MKLINE(Actor,walkdata.curbox,sleByte),
- 		MKLINE(Actor,walkdata.field_7,sleByte),
  		MKLINE(Actor,walkdata.x,sleInt16),
  		MKLINE(Actor,walkdata.y,sleInt16),
--- 250,261 ----
  		MKLINE(Actor,new_3,sleByte),
  
+ 		MKLINE(Actor,talk_script,sleUint16),
+ 		MKLINE(Actor,walk_script,sleUint16),
+ 
  		MKLINE(Actor,walkdata.destx,sleInt16),
  		MKLINE(Actor,walkdata.desty,sleInt16),
  		MKLINE(Actor,walkdata.destbox,sleByte),
! 		MKLINE(Actor,walkdata.destdir,sleUint16),
  		MKLINE(Actor,walkdata.curbox,sleByte),
  		MKLINE(Actor,walkdata.x,sleInt16),
  		MKLINE(Actor,walkdata.y,sleInt16),
***************
*** 263,271 ****
  		MKLINE(Actor,walkdata.yfrac,sleUint16),
  
! 		MKLINE(Actor,cost.hdr,sleUint16),
! 		MKARRAY(Actor,cost.a[0],sleUint16,16),
! 		MKARRAY(Actor,cost.b[0],sleUint16,16),
! 		MKARRAY(Actor,cost.c[0],sleUint16,16),
! 		MKARRAY(Actor,cost.d[0],sleUint16,16),
  		MKEND()
  	};
--- 267,276 ----
  		MKLINE(Actor,walkdata.yfrac,sleUint16),
  
! 		MKARRAY(Actor,cost.active[0],sleByte,16),
! 		MKLINE(Actor,cost.stopped,sleUint16),
! 		MKARRAY(Actor,cost.curpos[0],sleUint16,16),
! 		MKARRAY(Actor,cost.start[0],sleUint16,16),
! 		MKARRAY(Actor,cost.end[0],sleUint16,16),
! 		MKARRAY(Actor,cost.frame[0],sleUint16,16),
  		MKEND()
  	};
***************
*** 310,314 ****
  		MKLINE(Scumm,_numObjectsInRoom,sleByte),
  		MKLINE(Scumm,_currentScript,sleByte),
! 		MKARRAY(Scumm,_localScriptList[0],sleUint32,0x39),
  		MKARRAY(Scumm,vm.localvar[0][0],sleUint16,NUM_SCRIPT_SLOT*17),
  		MKARRAY(Scumm,_resourceMapper[0],sleByte,128),
--- 315,319 ----
  		MKLINE(Scumm,_numObjectsInRoom,sleByte),
  		MKLINE(Scumm,_currentScript,sleByte),
! 		MKARRAY(Scumm,_localScriptList[0],sleUint32,NUM_LOCALSCRIPT),
  		MKARRAY(Scumm,vm.localvar[0][0],sleUint16,NUM_SCRIPT_SLOT*17),
  		MKARRAY(Scumm,_resourceMapper[0],sleByte,128),
***************
*** 337,341 ****
  		MKLINE(Scumm,_defaultTalkDelay,sleInt16),
  		MKLINE(Scumm,_numInMsgStack,sleInt16),
! 		MKLINE(Scumm,_sentenceIndex,sleByte),
  
  		MKLINE(Scumm,vm.cutSceneStackPointer,sleByte),
--- 342,346 ----
  		MKLINE(Scumm,_defaultTalkDelay,sleInt16),
  		MKLINE(Scumm,_numInMsgStack,sleInt16),
! 		MKLINE(Scumm,_sentenceNum,sleByte),
  
  		MKLINE(Scumm,vm.cutSceneStackPointer,sleByte),
***************
*** 358,362 ****
  		MKLINE(Scumm,_BgNeedsRedraw,sleByte),
  
! 		MKARRAY(Scumm,actorDrawBits[0],sleUint16,200),
  		MKLINE(Scumm,gdi._transparency,sleByte),
  		MKARRAY(Scumm,_currentPalette[0],sleByte,768),
--- 363,367 ----
  		MKLINE(Scumm,_BgNeedsRedraw,sleByte),
  
! 		MKARRAY(Scumm,gfxUsageBits[0],sleUint32,200),
  		MKLINE(Scumm,gdi._transparency,sleByte),
  		MKARRAY(Scumm,_currentPalette[0],sleByte,768),
***************
*** 452,456 ****
  	s->saveLoadEntries(this,mainEntries);
  
! 	s->saveLoadArrayOf(actor+1, 12, sizeof(actor[0]), actorEntries);
  	s->saveLoadArrayOf(vm.slot, NUM_SCRIPT_SLOT, sizeof(vm.slot[0]), scriptSlotEntries);
  	s->saveLoadArrayOf(_objs, _numLocalObjects, sizeof(_objs[0]), objectEntries);
--- 457,461 ----
  	s->saveLoadEntries(this,mainEntries);
  
! 	s->saveLoadArrayOf(actor, NUM_ACTORS, sizeof(actor[0]), actorEntries);
  	s->saveLoadArrayOf(vm.slot, NUM_SCRIPT_SLOT, sizeof(vm.slot[0]), scriptSlotEntries);
  	s->saveLoadArrayOf(_objs, _numLocalObjects, sizeof(_objs[0]), objectEntries);
***************
*** 466,470 ****
  				saveLoadResource(s,i,j);
  
! 	s->saveLoadArrayOf(_objectFlagTable, _numGlobalObjects, sizeof(_objectFlagTable[0]), sleByte);
  	s->saveLoadArrayOf(_classData, _numGlobalObjects, sizeof(_classData[0]), sleUint32);
  	s->saveLoadArrayOf(_vars, _numVariables, sizeof(_vars[0]), sleInt16);
--- 471,482 ----
  				saveLoadResource(s,i,j);
  
! 	s->saveLoadArrayOf(_objectOwnerTable, _numGlobalObjects, sizeof(_objectOwnerTable[0]), sleByte);
! 	s->saveLoadArrayOf(_objectStateTable, _numGlobalObjects, sizeof(_objectStateTable[0]), sleByte);
! 	if (_objectRoomTable)
! 		s->saveLoadArrayOf(_objectRoomTable, _numGlobalObjects, sizeof(_objectRoomTable[0]), sleByte);
! 
! 	if (_shadowPalette)
! 		s->saveLoadArrayOf(_shadowPalette, NUM_SHADOW_PALETTE * 256, 1, sleByte);
! 
  	s->saveLoadArrayOf(_classData, _numGlobalObjects, sizeof(_classData[0]), sleUint32);
  	s->saveLoadArrayOf(_vars, _numVariables, sizeof(_vars[0]), sleInt16);
***************
*** 490,493 ****
--- 502,506 ----
  	if (_soundDriver)
  		((SoundEngine*)_soundDriver)->save_or_load(s);
+ 
  }
  
***************
*** 498,502 ****
  
  	/* don't save/load these resource types */
! 	if (type==rtFlObject || type==rtTemp || type==rtBuffer || res.mode[type])
  		return;
  
--- 511,515 ----
  
  	/* don't save/load these resource types */
! 	if (/*type==rtFlObject ||*/ type==rtTemp || type==rtBuffer || res.mode[type])
  		return;
  

Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/script.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** script.cpp	2001/11/12 20:50:36	1.11
--- script.cpp	2001/11/26 19:57:57	1.12
***************
*** 51,55 ****
  		if (scriptOffs == 0)
  			error("Local script %d is not in room %d", script, _roomResource);
- 		scriptOffs += 9;
  		scriptType = WIO_LOCAL;
  	}
--- 51,54 ----
***************
*** 299,303 ****
  	}
  
! 	if (var&0x2000 && _majorScummVersion==5) {
  		a = fetchScriptWord();
  		if (a&0x2000)
--- 298,302 ----
  	}
  
! 	if (var&0x2000 && !(_features&GF_NEW_OPCODES)) {
  		a = fetchScriptWord();
  		if (a&0x2000)
***************
*** 452,455 ****
--- 451,455 ----
  }
  
+ 
  void Scumm::runHook(int i) {
  	int16 tmp[16];
***************
*** 576,582 ****
  	/* Nuke local object names */
  	if (_newNames) {
! 		for (i=0; i<50; i++) {
  			int j = _newNames[i];
! 			if (j && (getOwner(j)&OF_OWNER_MASK) == 0) {
  				_newNames[i] = 0;
  				nukeResource(rtObjectName, i);
--- 576,582 ----
  	/* Nuke local object names */
  	if (_newNames) {
! 		for (i=0; i<_numNewNames; i++) {
  			int j = _newNames[i];
! 			if (j && getOwner(j) == 0) {
  				_newNames[i] = 0;
  				nukeResource(rtObjectName, i);
***************
*** 598,614 ****
  	}
  
! 	if (_sentenceIndex > 0x7F || sentence[_sentenceIndex].unk)
  		return;
! 	
! 	if (sentence[_sentenceIndex].unk2 && 
! 		sentence[_sentenceIndex].unk3==sentence[_sentenceIndex].unk4) {
! 		_sentenceIndex--;
  		return;
! 	}
  
! 	_localParamList[0] = sentence[_sentenceIndex].unk5;
! 	_localParamList[1] = sentence[_sentenceIndex].unk4;
! 	_localParamList[2] = sentence[_sentenceIndex].unk3;
! 	_sentenceIndex--;
  	_currentScript = 0xFF;
  	if (_vars[VAR_SENTENCE_SCRIPT])
--- 598,615 ----
  	}
  
! 	if (!_sentenceNum || sentence[_sentenceNum-1].unk)
  		return;
! 
! 	_sentenceNum--;
! 
! #if !defined(FULL_THROTTLE)
! 	if (sentence[_sentenceNum].unk2 && 
! 		sentence[_sentenceNum].unk3==sentence[_sentenceNum].unk4)
  		return;
! #endif
  
! 	_localParamList[0] = sentence[_sentenceNum].unk5;
! 	_localParamList[1] = sentence[_sentenceNum].unk4;
! 	_localParamList[2] = sentence[_sentenceNum].unk3;
  	_currentScript = 0xFF;
  	if (_vars[VAR_SENTENCE_SCRIPT])
***************
*** 617,626 ****
  
  void Scumm::runInputScript(int a, int cmd, int mode) {
! 	memset(_localParamList, 0, sizeof(_localParamList));
! 	_localParamList[0] = a;
! 	_localParamList[1] = cmd;
! 	_localParamList[2] = mode;
  	if (_vars[VAR_VERB_SCRIPT])
! 		runScript(_vars[VAR_VERB_SCRIPT], 0, 0, _localParamList);
  }
  
--- 618,628 ----
  
  void Scumm::runInputScript(int a, int cmd, int mode) {
! 	int16 args[16];
! 	memset(args, 0, sizeof(args));
! 	args[0] = a;
! 	args[1] = cmd;
! 	args[2] = mode;
  	if (_vars[VAR_VERB_SCRIPT])
! 		runScript(_vars[VAR_VERB_SCRIPT], 0, 0, args);
  }
  
***************
*** 696,700 ****
  	assert(objptr);
  
! 	verbptr = findResource(MKID('VERB'), objptr, 0);
  	if (verbptr==NULL)
  		error("No verb block in object %d", obj);
--- 698,702 ----
  	assert(objptr);
  
! 	verbptr = findResource(MKID('VERB'), objptr);
  	if (verbptr==NULL)
  		error("No verb block in object %d", obj);
***************
*** 778,827 ****
  		return;
  
! 	dir = (_xPos > x) ? 1 : 0;
  	turnToDirection(derefActorSafe(act, "faceActorToObj"), dir);
  }
  
  void Scumm::animateActor(int act, int anim) {
! 	int shr,dir;
! 	bool inRoom;
  	Actor *a;
  
  	a = derefActorSafe(act, "animateActor");
  
! 	shr = anim>>2;
! 	dir = anim&3;
  
! 	inRoom = (a->room == _currentRoom);
  
! 	if (shr == 0x3F) {
! 		if (inRoom) {
! 			startAnimActor(a, a->standFrame, a->facing);
! 			a->moving = 0;
! 		}
! 		return;
! 	}
  
! 	if (shr == 0x3E) {
! 		if (inRoom) {
! 			startAnimActor(a, 0x3E, dir);
! 			a->moving &= ~4;
! 		}
! 		a->facing = dir;
! 		return;
  	}
  
! 	if (shr == 0x3D) {
! 		if (inRoom) {
! 			turnToDirection(a, dir);
! 		} else {
! 			a->facing = dir;
! 		}
! 		return;
  	}
  
! 	startAnimActor(a, anim, a->facing);
  }
  
! int Scumm::getScriptRunning(int script) {
  	int i;
  	ScriptSlot *ss = vm.slot;
--- 780,849 ----
  		return;
  
! 	dir = (_xPos > x) ? 90 : 270;
  	turnToDirection(derefActorSafe(act, "faceActorToObj"), dir);
  }
  
  void Scumm::animateActor(int act, int anim) {
! #if defined(FULL_THROTTLE)
! 	int cmd,dir;
  	Actor *a;
  
  	a = derefActorSafe(act, "animateActor");
  
! 	if (anim==0xFF)
! 		anim = 2000;
  
! 	cmd  = anim / 1000;
! 	dir = anim % 1000;
  
! 	/* temporary code */
! //	dir = newDirToOldDir(dir);
  
! 	switch(cmd) {
! 	case 2:
! 		stopActorMoving(a);
! 		startAnimActor(a, a->standFrame);
! 		break;
! 	case 3:
! 		a->moving &= ~4;
! 		fixActorDirection(a, dir);
! 		break;
! 	case 4:
! 		turnToDirection(a, dir);
! 		break;
! 	default:
! 		startAnimActor(a, anim);
  	}
  
! 
! #else
! 	int shr,dir;
! 	bool inRoom;
! 	Actor *a;
! 
! 	a = derefActorSafe(act, "animateActor");
! 
! 	dir = anim&3;
! 
! 	switch(anim>>2) {
! 	case 0x3F:
! 		stopActorMoving(a);
! 		startAnimActor(a, a->standFrame);
! 		break;
! 	case 0x3E:
! 		a->moving &= ~4;
! 		fixActorDirection(a, oldDirToNewDir(dir));
! 		break;
! 	case 0x3D:
! 		turnToDirection(a, oldDirToNewDir(dir));
! 		break;
! 	default:
! 		startAnimActor(a, anim);
  	}
  
! #endif
  }
  
! bool Scumm::isScriptRunning(int script) {
  	int i;
  	ScriptSlot *ss = vm.slot;
***************
*** 829,836 ****
  		if (ss->number==script && (ss->where==WIO_GLOBAL || 
  			  ss->where==WIO_LOCAL) && ss->status)
! 			return 1;
! 	return 0;
  }
  
  void Scumm::beginOverride() {
  	int index;
--- 851,870 ----
  		if (ss->number==script && (ss->where==WIO_GLOBAL || 
  			  ss->where==WIO_LOCAL) && ss->status)
! 			return true;
! 	return false;
! }
! 
! bool Scumm::isRoomScriptRunning(int script) {
! 	int i;
! 	ScriptSlot *ss = vm.slot;
! 	for (i=0; i<NUM_SCRIPT_SLOT; i++,ss++)
! 		if (ss->number==script && ss->where==WIO_ROOM && ss->status)
! 			return true;
! 	return false;
! 
  }
  
+ 
+ 
  void Scumm::beginOverride() {
  	int index;
***************
*** 971,973 ****
  		vm.cutScenePtr[vm.cutSceneStackPointer] = 0;
  	}
! }
\ No newline at end of file
--- 1005,1050 ----
  		vm.cutScenePtr[vm.cutSceneStackPointer] = 0;
  	}
! }
! #if defined(FULL_THROTTLE)
! void Scumm::doSentence(int c, int b, int a) {
! 	SentenceTab *st;
! 	
! 	if (b==a)
! 		return;
! 
! 	st = &sentence[_sentenceNum-1];
! 
! 	if (_sentenceNum &&
! 		st->unk5 == c && st->unk4==b && st->unk3==a)
! 			return;
! 
! 	_sentenceNum++;
! 	st++;
! 
! 	st->unk5 = c;
! 	st->unk4 = b;
! 	st->unk3 = a;
! 	st->unk = 0;
! 	
! 	warning("dosentence(%d,%d,%d)", c, b, a);
! 
! }
! 
! #else
! void Scumm::doSentence(int c, int b, int a) {
! 	SentenceTab *st;
! 
! 	st = &sentence[_sentenceNum++];
! 
! 	st->unk5 = c;
! 	st->unk4 = b;
! 	st->unk3 = a;
! 
! 	if (!(st->unk3&0xFF00))
! 		st->unk2 = 0;
! 	else
! 		st->unk2 = 1;
! 
! 	st->unk = 0;
! }
! #endif
\ No newline at end of file

Index: script_v1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/script_v1.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** script_v1.cpp	2001/11/14 20:09:39	1.14
--- script_v1.cpp	2001/11/26 19:57:57	1.15
***************
*** 462,466 ****
  			break;
  		case 23: /* unk2 */
! 			a->data8 = getVarOrDirectByte(0x80); /* unused */
  			break;
  		default:
--- 462,466 ----
  			break;
  		case 23: /* unk2 */
! 			a->unk1 = getVarOrDirectByte(0x80); /* unused? */
  			break;
  		default:
***************
*** 579,583 ****
  		i = getVarOrDirectByte(0x80);
  		j = getVarOrDirectByte(0x40);
! 		setCursorImg(i, j);
  		break;
  	case 11: /* set cursor hotspot */
--- 579,583 ----
  		i = getVarOrDirectByte(0x80);
  		j = getVarOrDirectByte(0x40);
! 		setCursorImg(i, j, 1);
  		break;
  	case 11: /* set cursor hotspot */
***************
*** 654,662 ****
  	SentenceTab *st;
  
- 	_sentenceIndex++;
- 
  	a = getVarOrDirectByte(0x80);
  	if (a==0xFE) {
! 		_sentenceIndex = 0xFF;
  		stopScriptNr(_vars[VAR_SENTENCE_SCRIPT]);
  		clearClickedStatus();
--- 654,660 ----
  	SentenceTab *st;
  
  	a = getVarOrDirectByte(0x80);
  	if (a==0xFE) {
! 		_sentenceNum = 0;
  		stopScriptNr(_vars[VAR_SENTENCE_SCRIPT]);
  		clearClickedStatus();
***************
*** 664,668 ****
  	}
  
! 	st = &sentence[_sentenceIndex];
  
  	st->unk5 = a;
--- 662,666 ----
  	}
  
! 	st = &sentence[_sentenceNum++];
  
  	st->unk5 = a;
***************
*** 694,707 ****
  	int state,obj,index,i;
  	ObjectData *od;
! 	byte x,y,w,h;
  
  	state = 1;
! 	_xPos = _yPos = 255;
  	obj = getVarOrDirectWord(0x80);
  
  	switch((_opcode = fetchScriptByte())&0x1F) {
  	case 1: /* draw at */
! 		_xPos = getVarOrDirectWord(0x80);
! 		_yPos = getVarOrDirectWord(0x40);
  		break;
  	case 2: /* set state */
--- 692,706 ----
  	int state,obj,index,i;
  	ObjectData *od;
! 	uint16 x,y,w,h;
! 	int xpos, ypos;
  
  	state = 1;
! 	xpos = ypos = 255;
  	obj = getVarOrDirectWord(0x80);
  
  	switch((_opcode = fetchScriptByte())&0x1F) {
  	case 1: /* draw at */
! 		xpos = getVarOrDirectWord(0x80);
! 		ypos = getVarOrDirectWord(0x40);
  		break;
  	case 2: /* set state */
***************
*** 718,726 ****
  		return;
  	od = &_objs[index];
! 	if (_xPos!=0xFF) {
! 		od->walk_x += (_xPos - od->x_pos)<<3;
! 		od->x_pos = _xPos;
! 		od->walk_y += (_yPos - od->y_pos)<<3;
! 		od->y_pos = _yPos;
  	}
  	addObjectToDrawQue(index);
--- 717,725 ----
  		return;
  	od = &_objs[index];
! 	if (xpos!=0xFF) {
! 		od->walk_x += (xpos<<3) - od->x_pos;
! 		od->x_pos = xpos<<3;
! 		od->walk_y += (ypos<<3) - od->y_pos;
! 		od->y_pos = ypos<<3;
  	}
  	addObjectToDrawQue(index);
***************
*** 728,732 ****
  	x = od->x_pos;
  	y = od->y_pos;
! 	w = od->numstrips;
  	h = od->height;
  
--- 727,731 ----
  	x = od->x_pos;
  	y = od->y_pos;
! 	w = od->width;
  	h = od->height;
  
***************
*** 734,738 ****
  	do {
  		if (_objs[i].x_pos == x && _objs[i].y_pos == y
! 			&& _objs[i].numstrips == w && _objs[i].height==h) 
  			putState(_objs[i].obj_nr, 0);
  	} while (--i);
--- 733,737 ----
  	do {
  		if (_objs[i].x_pos == x && _objs[i].y_pos == y
! 			&& _objs[i].width == w && _objs[i].height==h) 
  			putState(_objs[i].obj_nr, 0);
  	} while (--i);
***************
*** 830,834 ****
  void Scumm::o5_getActorFacing() {
  	getResultPos();
! 	setResult(derefActorSafe(getVarOrDirectByte(0x80),"o5_getActorFacing")->facing);
  }
  
--- 829,833 ----
  void Scumm::o5_getActorFacing() {
  	getResultPos();
! 	setResult(newDirToOldDir(derefActorSafe(getVarOrDirectByte(0x80),"o5_getActorFacing")->facing));
  }
  
***************
*** 925,929 ****
  void Scumm::o5_getScriptRunning() {
  	getResultPos();
! 	setResult(getScriptRunning(getVarOrDirectByte(0x80)));
  }
  
--- 924,928 ----
  void Scumm::o5_getScriptRunning() {
  	getResultPos();
! 	setResult(isScriptRunning(getVarOrDirectByte(0x80)));
  }
  
***************
*** 1047,1055 ****
  	c = fetchScriptByte();
  
! 	if (c==0)
  		_vars[VAR_V5_DRAWFLAGS] = a;
! 	else if (c==1) {
  		warning("o5_lights: lights not implemented");
! 	}
  	_fullRedraw=1;
  }
--- 1046,1054 ----
  	c = fetchScriptByte();
  
! /*	if (c==0)
  		_vars[VAR_V5_DRAWFLAGS] = a;
! 	else if (c==1) {*/
  		warning("o5_lights: lights not implemented");
! //	}
  	_fullRedraw=1;
  }
***************
*** 1070,1075 ****
  	a = derefActorSafe(_vars[VAR_EGO], "o5_loadRoomWithEgo");
  
! 	/* Warning: uses _xPos, _yPos from a previous update of those */
! 	putActor(a, _xPos, _yPos, room);
  
  	x = (int16)fetchScriptWord();
--- 1069,1074 ----
  	a = derefActorSafe(_vars[VAR_EGO], "o5_loadRoomWithEgo");
  
! 	/* Warning: used previously _xPos, _yPos from a previous update of those */
! 	putActor(a, a->x, a->y, room);
  
  	x = (int16)fetchScriptWord();
***************
*** 1088,1092 ****
  
  	if (x != -1) {
! 		startWalkActor(a, x, y, 0xFF);
  	}
  }
--- 1087,1091 ----
  
  	if (x != -1) {
! 		startWalkActor(a, x, y, -1);
  	}
  }
***************
*** 1328,1333 ****
  		if (b < 160) b=160;
  		if (b > ((_scrWidthIn8Unit-20)<<3)) b=((_scrWidthIn8Unit-20)<<3);
! 		_vars[VAR_CAMERA_MIN] = a;
! 		_vars[VAR_CAMERA_MAX] = b;
  		break;
  	case 2: /* room color */
--- 1327,1332 ----
  		if (b < 160) b=160;
  		if (b > ((_scrWidthIn8Unit-20)<<3)) b=((_scrWidthIn8Unit-20)<<3);
! 		_vars[VAR_CAMERA_MIN_X] = a;
! 		_vars[VAR_CAMERA_MAX_X] = b;
  		break;
  	case 2: /* room color */
***************
*** 1487,1491 ****
  	int i;
  
! 	if (act <= _vars[VAR_NUM_ACTOR])
  		error("Can't set actor %d name with new-name-of", act);
  
--- 1486,1490 ----
  	int i;
  
! 	if (act < NUM_ACTORS)
  		error("Can't set actor %d name with new-name-of", act);
  
***************
*** 1813,1818 ****
  		return;
  	case 4: /* wait for sentence */
! 		if (_sentenceIndex!=0xFF) {
! 			if (sentence[_sentenceIndex].unk &&
  				!isScriptInUse(_vars[VAR_SENTENCE_SCRIPT]) )
  				return;
--- 1812,1817 ----
  		return;
  	case 4: /* wait for sentence */
! 		if (_sentenceNum) {
! 			if (sentence[_sentenceNum-1].unk &&
  				!isScriptInUse(_vars[VAR_SENTENCE_SCRIPT]) )
  				return;
***************
*** 1837,1841 ****
  	x = getVarOrDirectWord(0x40);
  	y = getVarOrDirectWord(0x20);
! 	startWalkActor(a, x, y, 0xFF);
  }
  
--- 1836,1840 ----
  	x = getVarOrDirectWord(0x40);
  	y = getVarOrDirectWord(0x20);
! 	startWalkActor(a, x, y, -1);
  }
  
***************
*** 1876,1880 ****
  		x -= b;
  	
! 	startWalkActor(a, x, y, 0xFF);
  }
  
--- 1875,1879 ----
  		x -= b;
  	
! 	startWalkActor(a, x, y, -1);
  }
  

Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/script_v2.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** script_v2.cpp	2001/11/14 20:09:39	1.12
--- script_v2.cpp	2001/11/26 19:57:57	1.13
***************
*** 277,281 ****
  	&Scumm::o6_distPtPt,
  	/* C8 */
! 	&Scumm::o6_invalid,
  	&Scumm::o6_miscOps,
  	&Scumm::o6_breakMaybe,
--- 277,281 ----
  	&Scumm::o6_distPtPt,
  	/* C8 */
! 	&Scumm::o6_kernelFunction,
  	&Scumm::o6_miscOps,
  	&Scumm::o6_breakMaybe,
***************
*** 292,301 ****
  	&Scumm::o6_invalid,
  	/* D4 */	
- 	&Scumm::o6_invalid,
  	&Scumm::o6_invalid,
  	&Scumm::o6_invalid,
  	&Scumm::o6_invalid,
  	/* D8 */	
! 	&Scumm::o6_invalid,
  	&Scumm::o6_invalid,
  	&Scumm::o6_invalid,
--- 292,301 ----
  	&Scumm::o6_invalid,
  	/* D4 */	
  	&Scumm::o6_invalid,
+ 	&Scumm::o6_jumpToScript,
  	&Scumm::o6_invalid,
  	&Scumm::o6_invalid,
  	/* D8 */	
! 	&Scumm::o6_isRoomScriptRunning,
  	&Scumm::o6_invalid,
  	&Scumm::o6_invalid,
***************
*** 354,358 ****
  	ArrayHeader *ah = (ArrayHeader*)getResourceAddress(rtString, readVar(array));
  
! 	assert(ah);
  
  	base += index*ah->dim1_size;
--- 354,360 ----
  	ArrayHeader *ah = (ArrayHeader*)getResourceAddress(rtString, readVar(array));
  
! 	if (ah==NULL) {
! 		error("readArray: invalid array %d (%d)", array, readVar(array));	
! 	}
  
  	base += index*ah->dim1_size;
***************
*** 618,621 ****
--- 620,634 ----
  }
  
+ void Scumm::o6_jumpToScript() {
+ 	int16 args[16];
+ 	int script,flags;
+ 
+ 	getStackList(args,sizeof(args)/sizeof(args[0]));
+ 	script = pop();
+ 	flags = pop();
+ 	o6_stopObjectCode();
+ 	runScript(script, flags&1, flags&2, args);
+ }
+ 
  void Scumm::o6_startScript() {
  	int16 args[16];
***************
*** 639,644 ****
  void Scumm::o6_setObjectState() {
  	int a = pop();
  	if (a==0) a=1;
! 	setObjectState(pop(), a, -1, -1);
  }
  
--- 652,660 ----
  void Scumm::o6_setObjectState() {
  	int a = pop();
+ 	int b = pop();
  	if (a==0) a=1;
! // 	debug(1, "setObjectState(%d,%d)", a, b);
! 	
! 	setObjectState(b, a, -1, -1);
  }
  
***************
*** 646,650 ****
  	int y = pop();
  	int x = pop();
! 	setObjectState(pop(), 1, x, y);
  }
  
--- 662,668 ----
  	int y = pop();
  	int x = pop();
! 	int obj = pop();
! //	debug(1, "setObjectXY(%d,%d,%d)", obj, x, y);
! 	setObjectState(obj, 1, x, y);
  }
  
***************
*** 712,716 ****
  	case 0x99:
  		a = pop();
! 		setCursorImg(a, pop());
  		break;
  	case 0x9A:
--- 730,734 ----
  	case 0x99:
  		a = pop();
! 		setCursorImg(a, pop(), 1);
  		break;
  	case 0x9A:
***************
*** 729,732 ****
--- 747,752 ----
  		makeCursorColorTransparent(pop());
  		break;
+ 	default:
+ 		error("o6_cursorCommand: default case");
  	}
  
***************
*** 784,787 ****
--- 804,809 ----
  	int obj = pop();
  
+ //	debug(1, "setState(%d,%d)", obj, state);
+ 
  	putState(obj, state);
  	removeObjectFromRoom(obj);
***************
*** 852,856 ****
  	a = derefActorSafe(pop(), "o6_walkActorToObj");
  
! 	if (obj >= 17) {
  		if (whereIsObject(obj)==WIO_NOT_FOUND)
  			return;
--- 874,878 ----
  	a = derefActorSafe(pop(), "o6_walkActorToObj");
  
! 	if (obj >= NUM_ACTORS) {
  		if (whereIsObject(obj)==WIO_NOT_FOUND)
  			return;
***************
*** 871,875 ****
  		else
  			x -= dist;
! 		startWalkActor(a, x, a2->y, 0xFF);
  	}
  }
--- 893,897 ----
  		else
  			x -= dist;
! 		startWalkActor(a, x, a2->y, -1);
  	}
  }
***************
*** 879,883 ****
  	y = pop();
  	x = pop();
! 	startWalkActor(derefActorSafe(pop(), "o6_walkActorTo"), x, y, 0xFF);
  }
  
--- 901,905 ----
  	y = pop();
  	x = pop();
! 	startWalkActor(derefActorSafe(pop(), "o6_walkActorTo"), x, y, -1);
  }
  
***************
*** 890,893 ****
--- 912,916 ----
  	x = pop();
  	a = derefActorSafe(pop(), "o6_putActorInRoom");
+ 
  	if (room==0xFF) {
  		room = a->room;
***************
*** 906,911 ****
  	Actor *a;
  
! 	room = pop();
! 	obj = pop();
  
  	a = derefActorSafe(pop(), "o6_putActorAtObject");
--- 929,939 ----
  	Actor *a;
  
! 	if (_features & GF_HAS_ROOMTABLE) {
! 		obj = pop();
! 		room = getObjectRoom(obj);
! 	} else {
! 		room = pop();
! 		obj = pop();
! 	}
  
  	a = derefActorSafe(pop(), "o6_putActorAtObject");
***************
*** 944,948 ****
  void Scumm::o6_doSentence() {
  	int a,b,c;
- 	SentenceTab *st;
  
  	a = pop();
--- 972,975 ----
***************
*** 951,976 ****
  	c = pop();
  
! 	st = &sentence[++_sentenceIndex];
! 
! 	st->unk5 = c;
! 	st->unk4 = b;
! 	st->unk3 = a;
! 
! 	if (!(st->unk3&0xFF00))
! 		st->unk2 = 0;
! 	else
! 		st->unk2 = 1;
! 
! 	st->unk = 0;
  }
  
  void Scumm::o6_pickupObject() {
  	int obj, room;
  
! 	room = pop();
! 	obj = pop();
  	
- 	if (room==0)
- 		room = _roomResource;
  	addObjectToInventory(obj, room);
  	putOwner(obj, _vars[VAR_EGO]);
--- 978,1006 ----
  	c = pop();
  
! 	doSentence(c,b,a);
  }
  
  void Scumm::o6_pickupObject() {
  	int obj, room;
+ 	int i;
  
! 	if (_features & GF_HAS_ROOMTABLE) {
! 		obj = pop();
! 		room = getObjectRoom(obj);
! 	} else {
! 		room = pop();
! 		obj = pop();
! 		if (room==0)
! 			room = _roomResource;
! 	}
! 
! 	for(i=1; i<_maxInventoryItems; i++) {
! 		if (_inventory[i] == (uint16)obj) {
! 			putOwner(obj, _vars[VAR_EGO]);
! 			runHook(obj);
! 			return;
! 		}
! 	}
  	
  	addObjectToInventory(obj, room);
  	putOwner(obj, _vars[VAR_EGO]);
***************
*** 988,994 ****
  	y = pop();
  	x = pop();
! 	room = pop();
! 	obj = pop();
! 
  	a = derefActorSafe(_vars[VAR_EGO], "o_loadRoomWithEgo");
  
--- 1018,1030 ----
  	y = pop();
  	x = pop();
! 	
! 	if (_features & GF_HAS_ROOMTABLE) {
! 		obj = pop();
! 		room = getObjectRoom(obj);
! 	} else {
! 		room = pop();
! 		obj = pop();
! 	}
! 	
  	a = derefActorSafe(_vars[VAR_EGO], "o_loadRoomWithEgo");
  
***************
*** 1005,1009 ****
  	_fullRedraw=1;
  	if (x != -1) {
! 		startWalkActor(a, x, y, 0xFF);
  	}
  }
--- 1041,1045 ----
  	_fullRedraw=1;
  	if (x != -1) {
! 		startWalkActor(a, x, y, -1);
  	}
  }
***************
*** 1029,1033 ****
  
  void Scumm::o6_getScriptRunning() {
! 	push(getScriptRunning(pop()));
  }
  
--- 1065,1073 ----
  
  void Scumm::o6_getScriptRunning() {
! 	push(isScriptRunning(pop()));
! }
! 
! void Scumm::o6_isRoomScriptRunning() {
! 	push(isRoomScriptRunning(pop()));
  }
  
***************
*** 1045,1053 ****
  
  void Scumm::o6_getObjectDir() {
! 	push(getObjDir(pop()));
  }
  
  void Scumm::o6_getActorWalkBox() {
! 	push(derefActorSafe(pop(),"o6_getActorWalkBox")->walkbox);
  }
  
--- 1085,1100 ----
  
  void Scumm::o6_getObjectDir() {
! 	int dir = getObjDir(pop());
! 
! 	if (_features & GF_USE_ANGLES) {
! 		dir = oldDirToNewDir(dir);
! 	}
! 
! 	push(dir);
  }
  
  void Scumm::o6_getActorWalkBox() {
! 	Actor *a = derefActorSafe(pop(),"o6_getActorWalkBox");
! 	push(a->ignoreBoxes ? 0 : a->walkbox);
  }
  
***************
*** 1087,1091 ****
  	int i;
  
! 	if (obj <= _vars[VAR_NUM_ACTOR])
  		error("Can't set actor %d name with new-name-of", obj);
  
--- 1134,1138 ----
  	int i;
  
! 	if (obj < NUM_ACTORS)
  		error("Can't set actor %d name with new-name-of", obj);
  
***************
*** 1138,1141 ****
--- 1185,1189 ----
  void Scumm::o6_resourceRoutines() {
  	int res;
+ 	int obj,room;
  
  	switch(fetchScriptByte()) {
***************
*** 1227,1232 ****
  		break;
  	case 119:/* load fl object */
! 		res = pop();
! 		loadFlObject(pop(), res);
  		break;
  	default:
--- 1275,1279 ----
  		break;
  	case 119:/* load fl object */
! 		loadFlObject(pop(), (_features & GF_HAS_ROOMTABLE) ? -1 : pop());
  		break;
  	default:
***************
*** 1246,1251 ****
  		if (b < 160) b=160;
  		if (b > ((_scrWidthIn8Unit-20)<<3)) b=((_scrWidthIn8Unit-20)<<3);
! 		_vars[VAR_CAMERA_MIN] = a;
! 		_vars[VAR_CAMERA_MAX] = b;
  		break;
  
--- 1293,1298 ----
  		if (b < 160) b=160;
  		if (b > ((_scrWidthIn8Unit-20)<<3)) b=((_scrWidthIn8Unit-20)<<3);
! 		_vars[VAR_CAMERA_MIN_X] = a;
! 		_vars[VAR_CAMERA_MAX_X] = b;
  		break;
  
***************
*** 1431,1434 ****
--- 1478,1482 ----
  		a->neverZClip = 0;
  		break;
+ 	case 225:
  	case 94:
  		a->neverZClip = pop();
***************
*** 1449,1454 ****
  		a->animProgress = 0;
  		break;
! 	case 98: /* set data8 */
! 		a->data8 = pop();
  		break;
  	case 99:
--- 1497,1502 ----
  		a->animProgress = 0;
  		break;
! 	case 98:
! 		a->unk1 = pop();
  		break;
  	case 99:
***************
*** 1464,1470 ****
  	case 217:
  		initActor(a, 2);
! 		break;	
  	default:
! 		error("o6_actorset: default case");
  	}
  }
--- 1512,1531 ----
  	case 217:
  		initActor(a, 2);
! 		break;
! 	case 235: /* talk_script */
! 		a->talk_script = pop();
! 		break;
! 	
! 	case 198: /* set anim variable */
! 	case 227: /* actor_unk2 */
! 	case 228: /* actor script */
! 	case 229: /* stand */
! 	case 230: /* turn? */
! 	case 231: /* turn? */
! 	case 233: /* ? */
! 	case 234: /* ? */
! 
  	default:
! 		error("o6_actorset: default case %d", b);
  	}
  }
***************
*** 1743,1748 ****
  		return;
  	case 171:
! 		if (_sentenceIndex!=0xFF) {
! 			if (sentence[_sentenceIndex].unk &&
  				!isScriptInUse(_vars[VAR_SENTENCE_SCRIPT]) )
  				return;
--- 1804,1809 ----
  		return;
  	case 171:
! 		if (_sentenceNum) {
! 			if (sentence[_sentenceNum-1].unk &&
  				!isScriptInUse(_vars[VAR_SENTENCE_SCRIPT]) )
  				return;
***************
*** 1833,1837 ****
  
  void Scumm::o6_stopSentence() {
! 	_sentenceIndex = 0xFF;
  	stopScriptNr(_vars[VAR_SENTENCE_SCRIPT]);
  	clearClickedStatus();
--- 1894,1898 ----
  
  void Scumm::o6_stopSentence() {
! 	_sentenceNum = 0;
  	stopScriptNr(_vars[VAR_SENTENCE_SCRIPT]);
  	clearClickedStatus();
***************
*** 1993,1997 ****
--- 2054,2130 ----
  
  	getStackList(args,sizeof(args)/sizeof(args[0]));
+ 
+ #if defined(FULL_THROTTLE)
  	switch(args[0]) {
+ 	case 4:
+ 		grabCursor(args[1], args[2], args[3], args[4]);
+ 		break;
+ 	case 6:
+ 		warning("o6_miscOps: startVideo(%d,%s)", args[1], getStringAddress(_vars[0xf6/2]));
+ 		break;
+ 	case 7:
+ 		warning("o6_miscOps: stub7()");
+ 		break;
+ 	case 10:
+ 		warning("o6_miscOps: stub10(%d,%d,%d,%d)",args[1],args[2],args[3],args[4]);
+ 		break;
+ 	case 11:
+ 		warning("o6_miscOps: stub11(%d)", args[1]);
+ 		break;
+ 	case 12:
+ 		setCursorImg(args[1], -1, args[2]);
+ 		break;
+ 	case 13:
+ 		warning("o6_miscOps: stub13(%d,%d,%d,%d)",args[1],args[2],args[3],args[4]);
+ 		break;
+ 	case 14:
+ 		remapActor(derefActorSafe(args[1], "o6_miscOps:14"), args[2],args[3],args[4],args[5]);
+ 		break;
+ 	case 15:
+ 		warning("o6_miscOps: stub15(%d)", args[1]);
+ 		break;
+ 	case 16:
+ 		warning("o6_miscOps: stub16(%d,%d,%d,%d)",args[1],args[2],args[3],args[4]);
+ 		break;
+ 	case 17:
+ 		warning("o6_miscOps: stub17(%d,%d,%d,%d)",args[1],args[2],args[3],args[4]);
+ 		break;
+ 	case 18:
+ 		warning("o6_miscOps: stub18(%d,%d)", args[1], args[2]);
+ 		break;
+ 	case 107:
+ 		a = derefActorSafe(args[1], "o6_miscops: 107");
+ 		a->scalex = args[2];
+ 		a->needBgReset = true;
+ 		a->needRedraw = true;
+ 		break;
+ 	case 108:
+ 		setupShadowPalette(args[1],args[2],args[3],args[4],args[5],args[6]);
+ 		break;
+ 	case 109:
+ 		setupShadowPalette(0, args[1],args[2],args[3],args[4],args[5]);
+ 		break;
+ 	case 114:
+ 		warning("o6_miscOps: stub114()");
+ 		break;
+ 	case 117:
+ 		warning("o6_miscOps: stub117()");
+ 		break;
+ 	case 118:
+ 		warning("o6_miscOps: stub118(%d,%d,%d,%d,%d,%d,%d,%d)",args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]);
+ 		break;
+ 	case 119:
+ 		warning("o6_miscOps: stub119(%d,%d,%d,%d,%d,%d,%d,%d)",args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]);
+ 		break;
+ 	case 120:
+ 		warning("o6_miscOps: stub120(%d,%d)", args[1], args[2]);
+ 		break;
+ 	case 124:
+ 		warning("o6_miscOps: stub124(%d)", args[1]);
+ 		break;
+ 	}
+ 
+ #else
+ 	switch(args[0]) {
  	case 3:
  		warning("o6_miscOps: nothing in 3");
***************
*** 2050,2054 ****
  	case 111:
  		a = derefActorSafe(args[1], "o6_miscops: 111");
! 		a->data8 = args[2] + args[3];
  		break;
  
--- 2183,2187 ----
  	case 111:
  		a = derefActorSafe(args[1], "o6_miscops: 111");
! 		a->unk1 = args[2] + args[3];
  		break;
  
***************
*** 2100,2103 ****
--- 2233,2284 ----
  		error("o6_miscOps: default case %d", args[0]);
  	}
+ #endif
+ }
+ 
+ void Scumm::o6_kernelFunction() {
+ 	int16 args[30];
+ 	int i;
+ 	Actor *a;
+ 
+ 	getStackList(args,sizeof(args)/sizeof(args[0]));
+ 
+ 	switch(args[0]) {
+ 	case 115:
+ 		warning("o6_kernelFunction: stub115(%d,%d)", args[1], args[2]);
+ 		push(0);
+ 		break;
+ 	case 116:
+ 		push(checkXYInBoxBounds(args[3], args[1], args[2]));
+ 		break;
+ 	case 206:
+ 		push(remapPaletteColor(args[1],args[2],args[3],(uint)-1));
+ 		break;
+ 	case 207:
+ 		i = getObjectIndex(pop());
+ 		push(_objs[i].x_pos);
+ 		break;
+ 	case 208:
+ 		i = getObjectIndex(pop());
+ 		push(_objs[i].y_pos);
+ 		break;
+ 	case 209:
+ 		i = getObjectIndex(pop());
+ 		push(_objs[i].width);
+ 		break;
+ 	case 210:
+ 		i = getObjectIndex(pop());
+ 		push(_objs[i].height);
+ 		break;
+ 	case 211:
+ 		warning("o6_kernelFunction: stub211(%d)", args[1]);
+ 		push(0);
+ 		break;
+ 	case 212:
+ 		a = derefActorSafe(args[1], "o6_kernelFunction:212");
+ 		push(a->frame);
+ 		break;
+ 	default:
+ 		error("o6_kernelFunction: default case %d", args[0]);
+ 	}
  }
  
***************
*** 2180,2184 ****
  		case 0: actorTalk(); break;
  		case 1: drawString(1); break;
! 		case 2: unkMessage1(); break;
  		case 3: unkMessage2(); break;
  		}
--- 2361,2366 ----
  		case 0: actorTalk(); break;
  		case 1: drawString(1); break;
! 
! 	case 2: unkMessage1(); break;
  		case 3: unkMessage2(); break;
  		}

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** scumm.h	2001/11/14 20:09:39	1.29
--- scumm.h	2001/11/26 19:57:57	1.30
***************
*** 35,46 ****
  	NUM_MIXER = 4,
  	NUM_SCRIPT_SLOT = 25,
  	NUM_ACTORS = 13
  };
  
  struct Point {
  	int x,y;
  };
  
- 
[...1012 lines suppressed...]
--- 2111,2115 ----
  };
  
+ extern const uint32 IMxx_tags[];
  
  void outputdisplay2(Scumm *s, int disp);
***************
*** 1766,1770 ****
  void drawMouse(Scumm *s, int x, int y, int w, int h, byte *buf, bool visible);
  void blit(byte *dst, byte *src, int w, int h);
! byte *findResource(uint32 id, byte *searchin, int index);
  void playSfxSound(void *sound, uint32 size, uint rate);
  bool isSfxFinished();
--- 2131,2136 ----
  void drawMouse(Scumm *s, int x, int y, int w, int h, byte *buf, bool visible);
  void blit(byte *dst, byte *src, int w, int h);
! byte *findResource(uint32 tag, byte *searchin, int index);
! byte *findResource(uint32 tag, byte *searchin);
  void playSfxSound(void *sound, uint32 size, uint rate);
  bool isSfxFinished();

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scummvm.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** scummvm.cpp	2001/11/14 20:09:39	1.27
--- scummvm.cpp	2001/11/26 19:57:57	1.28
***************
*** 24,52 ****
  #include "gui.h"
  
- void Scumm::initThingsV5() {
- 	readIndexFileV5(1);
- 
- 	_numVariables = 800;
- 	_numBitVariables = 2048;
- 	_numLocalObjects = 200;
- 	_numVerbs = 100;
- 	_numInventory = 80;
- 	_numVerbs = 100;
- 	_numArray = 0x32;
- 	_numFlObject = 0x32;
- 	
- 	allocateArrays();
- 	
- 	readIndexFileV5(2);
- 	initRandSeeds();
- 
- 	setupOpcodes();
- }
- 
- void Scumm::initThingsV6() {
- 	setupOpcodes2();
- 	readIndexFileV6();
- }
- 
  void Scumm::initRandSeeds() {
  	_randSeed1 = 0xA943DE35;
--- 24,27 ----
***************
*** 61,64 ****
--- 36,44 ----
  }
  
+ uint Scumm::getRandomNumberRng(uint min, uint max) {
+ 	return getRandomNumber(max-min+1)+min;
+ }
+ 
+ 
  void Scumm::scummInit() {
  	int i;
***************
*** 66,70 ****
  
  	debug(9, "scummInit");
! //	readIndexFile(3);
  	loadCharset(1);
  	initScreens(0, 16, 320, 144);
--- 46,50 ----
  
  	debug(9, "scummInit");
! 
  	loadCharset(1);
  	initScreens(0, 16, 320, 144);
***************
*** 108,114 ****
  	virtscr[0].xstart = 0;
  
  	_vars[VAR_V5_DRAWFLAGS] = 11;
- 
  	_vars[VAR_59] = 3;
  
  	mouse.x = 104;
--- 88,95 ----
  	virtscr[0].xstart = 0;
  
+ #if !defined(FULL_THROTTLE)
  	_vars[VAR_V5_DRAWFLAGS] = 11;
  	_vars[VAR_59] = 3;
+ #endif
  
  	mouse.x = 104;
***************
*** 119,123 ****
  
  	_currentScript = 0xFF;
! 	_sentenceIndex = 0xFF;
  
  	_currentRoom = 0;
--- 100,104 ----
  
  	_currentScript = 0xFF;
! 	_sentenceNum = 0;
  
  	_currentRoom = 0;
***************
*** 158,162 ****
  	initScummVars();
  
! 	if (_majorScummVersion==5)
  		_vars[VAR_V5_TALK_STRING_Y] = -0x50;
  
--- 139,143 ----
  	initScummVars();
  
! 	if (!(_features&GF_AFTER_V6))
  		_vars[VAR_V5_TALK_STRING_Y] = -0x50;
  
***************
*** 166,169 ****
--- 147,151 ----
  
  void Scumm::initScummVars() {
+ #if !defined(FULL_THROTTLE)
  	_vars[VAR_CURRENTDRIVE] = _currentDrive;
  	_vars[VAR_FIXEDDISK] = checkFixedDisk();
***************
*** 175,180 ****
  	_vars[VAR_SOUNDPARAM2] = _soundParam2;
  	_vars[VAR_SOUNDPARAM3] = _soundParam3;
! 	if (_majorScummVersion==6)
  		_vars[VAR_V6_EMSSPACE] = 10000;
  }
  
--- 157,163 ----
  	_vars[VAR_SOUNDPARAM2] = _soundParam2;
  	_vars[VAR_SOUNDPARAM3] = _soundParam3;
! 	if (_features&GF_AFTER_V6)
  		_vars[VAR_V6_EMSSPACE] = 10000;
+ #endif
  }
  
***************
*** 207,211 ****
  	if (!detectGame()) {
  		warning("Game detection failed. Using default settings");
! 		_majorScummVersion = 5;
  	}
  
--- 190,194 ----
  	if (!detectGame()) {
  		warning("Game detection failed. Using default settings");
! 		_features = GF_DEFAULT;
  	}
  
***************
*** 218,232 ****
  	}
  
- 
  	initGraphics(this, _fullScreen);
  
! 	if (_majorScummVersion==6)
! 		initThingsV6();
  	else
! 		initThingsV5();
  
  	scummInit();
  
  	_vars[VAR_VERSION] = 21; 
  	_vars[VAR_DEBUGMODE] = _debugMode;
  
--- 201,220 ----
  	}
  
  	initGraphics(this, _fullScreen);
  
! 	readIndexFile();
! 	
! 	initRandSeeds();
! 
! 	if (_features & GF_NEW_OPCODES) 
! 		setupOpcodes2();
  	else
! 		setupOpcodes();
  
  	scummInit();
  
+ #if !defined(FULL_THROTTLE)
  	_vars[VAR_VERSION] = 21; 
+ #endif
  	_vars[VAR_DEBUGMODE] = _debugMode;
  
***************
*** 260,264 ****
  	processKbd();
  
! 	_vars[VAR_CAMERA_CUR_POS] = camera._curPos;
  	_vars[VAR_HAVE_MSG] = _haveMsg;
  	_vars[VAR_VIRT_MOUSE_X] = _virtual_mouse_x;
--- 248,252 ----
  	processKbd();
  
! 	_vars[VAR_CAMERA_POS_X] = camera._curPos;
  	_vars[VAR_HAVE_MSG] = _haveMsg;
  	_vars[VAR_VIRT_MOUSE_X] = _virtual_mouse_x;
***************
*** 319,327 ****
  		resetActorBgs();
  
! 		if (!(_vars[VAR_V5_DRAWFLAGS]&2) && _vars[VAR_V5_DRAWFLAGS]&4) {
! 			error("Flashlight not implemented in this version");
! 		}
  
! 		processActors(); /* process actors makes the heap invalid */
  		clear_fullRedraw();
  		cyclePalette();
--- 307,315 ----
  		resetActorBgs();
  
! //		if (!(_vars[VAR_V5_DRAWFLAGS]&2) && _vars[VAR_V5_DRAWFLAGS]&4) {
! //			error("Flashlight not implemented in this version");
! //		}
  
! 		processActors();
  		clear_fullRedraw();
  		cyclePalette();
***************
*** 344,348 ****
  		removeEnqueuedObjects();
  
! 		if (_majorScummVersion==5)
  			playActorSounds();
  
--- 332,336 ----
  		removeEnqueuedObjects();
  
! 		if (!(_features&GF_AFTER_V6))
  			playActorSounds();
  
***************
*** 360,374 ****
  }
  
- #if 0
- void Scumm::scummMain(int argc, char **argv) {
- 
- 	do {
- 		updateScreen(this);
- 
- 
- 	} while (1);
- }
- #endif
- 
  void Scumm::parseCommandLine(int argc, char **argv) {
  	int i;
--- 348,351 ----
***************
*** 416,430 ****
  	const char *gamename;
  	byte id,major,middle,minor;
  };
  
  static const VersionSettings version_settings[] = {
! 	{"monkey", "Monkey Island 1", GID_MONKEY, 5, 2, 2},
! 	{"monkey2", "Monkey Island 2: LeChuck's revenge", GID_MONKEY2, 5, 2, 2},
! 	{"atlantis", "Indiana Jones 4 and the Fate of Atlantis", GID_INDY4, 5, 5, 0},
! 	{"playfate", "Indiana Jones 4 and the Fate of Atlantis (Demo)", GID_INDY4, 5, 5, 0},
! 	{"tentacle", "Day Of The Tentacle", GID_TENTACLE, 6, 4, 2},
! 	{"dottdemo", "Day Of The Tentacle (Demo)", GID_TENTACLE, 6, 3, 2},
! 	{"samnmax", "Sam & Max", GID_SAMNMAX, 6, 4, 2},
! 	{"snmdemo", "Sam & Max (Demo)", GID_SAMNMAX, 6, 3, 0},
  	{NULL,NULL}
  };
--- 393,418 ----
  	const char *gamename;
  	byte id,major,middle,minor;
+ 	uint32 features;
  };
  
  static const VersionSettings version_settings[] = {
! 	{"monkey", "Monkey Island 1", GID_MONKEY, 5, 2, 2, 
! 		GF_USE_KEY},
! 	{"monkey2", "Monkey Island 2: LeChuck's revenge", GID_MONKEY2, 5, 2, 2, 
! 		GF_USE_KEY},
! 	{"atlantis", "Indiana Jones 4 and the Fate of Atlantis", GID_INDY4, 5, 5, 0,
! 		GF_USE_KEY},
! 	{"playfate", "Indiana Jones 4 and the Fate of Atlantis (Demo)", GID_INDY4, 5, 5, 0,
! 		GF_USE_KEY},
! 	{"tentacle", "Day Of The Tentacle", GID_TENTACLE, 6, 4, 2, 
! 		GF_NEW_OPCODES|GF_AFTER_V6|GF_USE_KEY},
! 	{"dottdemo", "Day Of The Tentacle (Demo)", GID_TENTACLE, 6, 3, 2,
! 		GF_NEW_OPCODES|GF_AFTER_V6|GF_USE_KEY},
! 	{"samnmax", "Sam & Max", GID_SAMNMAX, 6, 4, 2, 
! 		GF_NEW_OPCODES|GF_AFTER_V6|GF_USE_KEY},
! 	{"snmdemo", "Sam & Max (Demo)", GID_SAMNMAX, 6, 3, 0, 
! 		GF_NEW_OPCODES|GF_AFTER_V6|GF_USE_KEY},
! 	{"ft", "Full Throttle", GID_SAMNMAX, 7, 3, 0, 
! 		GF_NEW_OPCODES|GF_AFTER_V6|GF_AFTER_V7},
  	{NULL,NULL}
  };
***************
*** 438,444 ****
  		if (!scumm_stricmp(_exe_name, gnl->filename)) {
  			_gameId = gnl->id;
! 			_majorScummVersion = gnl->major;
! 			_middleScummVersion = gnl->middle;
! 			_minorScummVersion = gnl->minor;
  			_gameText = gnl->gamename;
  			debug(1, "Detected game '%s', version %d.%d.%d", 
--- 426,433 ----
  		if (!scumm_stricmp(_exe_name, gnl->filename)) {
  			_gameId = gnl->id;
! //			_majorScummVersion = gnl->major;
! //			_middleScummVersion = gnl->middle;
! //			_minorScummVersion = gnl->minor;
! 			_features = gnl->features;
  			_gameText = gnl->gamename;
  			debug(1, "Detected game '%s', version %d.%d.%d", 
***************
*** 536,540 ****
  	camera._curPos = camera._destPos = 160;
  
! 	if (_majorScummVersion==6) {
  		_vars[VAR_V6_SCREEN_WIDTH] = _scrWidthIn8Unit<<3;
  		_vars[VAR_V6_SCREEN_HEIGHT] = _scrHeight;
--- 525,529 ----
  	camera._curPos = camera._destPos = 160;
  
! 	if (_features&GF_AFTER_V6) {
  		_vars[VAR_V6_SCREEN_WIDTH] = _scrWidthIn8Unit<<3;
  		_vars[VAR_V6_SCREEN_HEIGHT] = _scrHeight;
***************
*** 544,551 ****
  		return;
  
! 	_vars[VAR_CAMERA_MAX] = (_scrWidthIn8Unit<<3) - 160;
! 	_vars[VAR_CAMERA_MIN] = 160;
  
! 	memset(actorDrawBits, 0, sizeof(actorDrawBits));
  
  	if (a) {
--- 533,540 ----
  		return;
  
! 	_vars[VAR_CAMERA_MAX_X] = (_scrWidthIn8Unit<<3) - 160;
! 	_vars[VAR_CAMERA_MIN_X] = 160;
  
! 	memset(gfxUsageBits, 0, sizeof(gfxUsageBits));
  
  	if (a) {
***************
*** 555,559 ****
  		getObjectXYPos(objectNr);
  		putActor(a, _xPos, _yPos, _currentRoom);
! 		startAnimActor(a, 0x3E, _dir^1);
  		a->moving = 0;
  	}
--- 544,548 ----
  		getObjectXYPos(objectNr);
  		putActor(a, _xPos, _yPos, _currentRoom);
! 		fixActorDirection(a, _dir + 180);
  		a->moving = 0;
  	}
***************
*** 577,581 ****
  	int i,offs;
  	byte *ptr;
! 	byte *roomptr;
  
  	_ENCD_offs = 0;
--- 566,570 ----
  	int i,offs;
  	byte *ptr;
! 	byte *roomptr,*searchptr;
  
  	_ENCD_offs = 0;
***************
*** 592,603 ****
  	roomptr = getResourceAddress(rtRoom, _roomResource);
  	
! 	ptr = findResource(MKID('RMHD'), roomptr, 0);
  	_scrWidthIn8Unit = READ_LE_UINT16(&((RoomHeader*)ptr)->width) >> 3;
  	_scrHeight = READ_LE_UINT16(&((RoomHeader*)ptr)->height);
  
! 	_IM00_offs = findResource(MKID('IM00'), findResource(MKID('RMIM'), roomptr, 0), 0) - 
! 		roomptr;
  	
! 	ptr = findResource(MKID('EXCD'), roomptr, 0);
  	if (ptr) {
  		_EXCD_offs = ptr - roomptr;
--- 581,592 ----
  	roomptr = getResourceAddress(rtRoom, _roomResource);
  	
! 	ptr = findResource(MKID('RMHD'), roomptr);
  	_scrWidthIn8Unit = READ_LE_UINT16(&((RoomHeader*)ptr)->width) >> 3;
  	_scrHeight = READ_LE_UINT16(&((RoomHeader*)ptr)->height);
  
! 	_IM00_offs = findResource(MKID('IM00'), findResource(MKID('RMIM'), roomptr))
! 		- roomptr;
  	
! 	ptr = findResource(MKID('EXCD'), roomptr);
  	if (ptr) {
  		_EXCD_offs = ptr - roomptr;
***************
*** 607,611 ****
  	}
  
! 	ptr = findResource(MKID('ENCD'), roomptr, 0);
  	if (ptr) {
  		_ENCD_offs = ptr - roomptr;
--- 596,600 ----
  	}
  
! 	ptr = findResource(MKID('ENCD'), roomptr);
  	if (ptr) {
  		_ENCD_offs = ptr - roomptr;
***************
*** 615,637 ****
  	}
  	
! 	ptr = findResource(MKID('BOXD'), roomptr, 0);
  	if (ptr) {
  		int size = READ_BE_UINT32_UNALIGNED(ptr+4);
  		createResource(rtMatrix, 2, size);
  		roomptr = getResourceAddress(rtRoom, _roomResource);
! 		ptr = findResource(MKID('BOXD'), roomptr, 0);
  		memcpy(getResourceAddress(rtMatrix, 2), ptr, size);
  	}
  
! 	ptr = findResource(MKID('BOXM'), roomptr, 0);
  	if (ptr) {
  		int size = READ_BE_UINT32_UNALIGNED(ptr+4);
  		createResource(rtMatrix, 1, size);
  		roomptr = getResourceAddress(rtRoom, _roomResource);
! 		ptr = findResource(MKID('BOXM'), roomptr, 0);
  		memcpy(getResourceAddress(rtMatrix, 1), ptr, size);
  	}
  
! 	ptr = findResource(MKID('SCAL'), roomptr, 0);
  	if (ptr) {
  		offs = ptr - roomptr;
--- 604,626 ----
  	}
  	
! 	ptr = findResource(MKID('BOXD'), roomptr);
  	if (ptr) {
  		int size = READ_BE_UINT32_UNALIGNED(ptr+4);
  		createResource(rtMatrix, 2, size);
  		roomptr = getResourceAddress(rtRoom, _roomResource);
! 		ptr = findResource(MKID('BOXD'), roomptr);
  		memcpy(getResourceAddress(rtMatrix, 2), ptr, size);
  	}
  
! 	ptr = findResource(MKID('BOXM'), roomptr);
  	if (ptr) {
  		int size = READ_BE_UINT32_UNALIGNED(ptr+4);
  		createResource(rtMatrix, 1, size);
  		roomptr = getResourceAddress(rtRoom, _roomResource);
! 		ptr = findResource(MKID('BOXM'), roomptr);
  		memcpy(getResourceAddress(rtMatrix, 1), ptr, size);
  	}
  
! 	ptr = findResource(MKID('SCAL'), roomptr);
  	if (ptr) {
  		offs = ptr - roomptr;
***************
*** 647,670 ****
  		}
  	}
! 	memset(_localScriptList, 0, (0x100 - _numGlobalScripts) * 4);
  
! 	roomptr = getResourceAddress(rtRoom, _roomResource);
! 	for (i=0; ptr = findResource(MKID('LSCR'), roomptr, i++) ;) {
! 		_localScriptList[ptr[8] - _numGlobalScripts] = ptr - roomptr;
  #ifdef DUMP_SCRIPTS
  		do {
  			char buf[32];
  			sprintf(buf,"room-%d-",_roomResource);
! 			dumpResource(buf, ptr[8], ptr);
  		} while (0);
  #endif
  	}
  	
  
! 	ptr = findResource(MKID('EPAL'), roomptr, 0);
  	if (ptr)
  		_EPAL_offs = ptr - roomptr;
  	
! 	ptr = findResource(MKID('CLUT'), roomptr, 0);
  	if (ptr) {
  		_CLUT_offs = ptr - roomptr;
--- 636,668 ----
  		}
  	}
! 	memset(_localScriptList, 0, sizeof(_localScriptList));
  
! 	searchptr = roomptr = getResourceAddress(rtRoom, _roomResource);
! 	while( (ptr = findResource(MKID('LSCR'), searchptr)) != NULL ) {
! 		int id;
! #ifdef FULL_THROTTLE
! 		id = READ_LE_UINT16(ptr + 8);
! 		checkRange(2050, 2000, id, "Invalid local script %d");
! 		_localScriptList[id - _numGlobalScripts] = ptr + 10 - roomptr;
! #else
! 		id = ptr[8];
! 		_localScriptList[id - _numGlobalScripts] = ptr + 9 - roomptr;
! #endif
  #ifdef DUMP_SCRIPTS
  		do {
  			char buf[32];
  			sprintf(buf,"room-%d-",_roomResource);
! 			dumpResource(buf, id, ptr);
  		} while (0);
  #endif
+ 		searchptr = NULL;
  	}
  	
  
! 	ptr = findResource(MKID('EPAL'), roomptr);
  	if (ptr)
  		_EPAL_offs = ptr - roomptr;
  	
! 	ptr = findResource(MKID('CLUT'), roomptr);
  	if (ptr) {
  		_CLUT_offs = ptr - roomptr;
***************
*** 672,677 ****
  	}
  
! 	if (_majorScummVersion==6) {
! 		ptr = findResource(MKID('PALS'), roomptr, 0);
  		if (ptr) {
  			_PALS_offs = ptr - roomptr;
--- 670,675 ----
  	}
  
! 	if (_features&GF_AFTER_V6) {
! 		ptr = findResource(MKID('PALS'), roomptr);
  		if (ptr) {
  			_PALS_offs = ptr - roomptr;
***************
*** 680,686 ****
  	}
  	
! 	initCycl(findResource(MKID('CYCL'), roomptr, 0) + 8);
  
! 	ptr = findResource(MKID('TRNS'), roomptr, 0);
  	if (ptr)
  		gdi._transparency = ptr[8];
--- 678,684 ----
  	}
  	
! 	initCycl(findResource(MKID('CYCL'), roomptr) + 8);
  
! 	ptr = findResource(MKID('TRNS'), roomptr);
  	if (ptr)
  		gdi._transparency = ptr[8];
***************
*** 689,692 ****
--- 687,692 ----
  
  	initBGBuffers();
+ 
+ 	memset(_extraBoxFlags, 0, sizeof(_extraBoxFlags));
  }
  
***************
*** 884,888 ****
  	freeResources();
  
! 	free(_objectFlagTable);
  	free(_inventory);
  	free(_arrays);
--- 884,890 ----
  	freeResources();
  
! 	free(_objectStateTable);
! 	free(_objectRoomTable);
! 	free(_objectOwnerTable);
  	free(_inventory);
  	free(_arrays);
***************
*** 895,898 ****
--- 897,939 ----
  }
  
+ int Scumm::newDirToOldDir(int dir) {
+ 	if (dir>=71 && dir<=109)
+ 		return 1;
+ 	if (dir>=109 && dir<=251)
+ 		return 2;
+ 	if (dir>=251 && dir<=289)
+ 		return 0;
+ 	return 3;
+ }
+ 
+ const int new_dir_table[4] = {
+ 	270,
+ 	90,
+ 	180,
+ 	0,
+ };
+ 
+ int Scumm::oldDirToNewDir(int dir) {
+ 	return new_dir_table[dir];
+ }
+ 
+ int Scumm::toSimpleDir(int dir) {
+ 	if (dir>=71 && dir<=109)
+ 		return 1;
+ 	if (dir>=109 && dir<=251)
+ 		return 2;
+ 	if (dir>=251 && dir<=289)
+ 		return 3;
+ 	return 0;
+ }
+ 
+ int Scumm::fromSimpleDir(int dir) {
+ 	return dir * 90;
+ }
+ 
+ 
+ int Scumm::normalizeAngle(int angle) {
+ 	return (angle+360)%360;
+ }
  
  extern Scumm scumm;

Index: scummvm.dsp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scummvm.dsp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** scummvm.dsp	2001/11/14 18:37:38	1.13
--- scummvm.dsp	2001/11/26 19:57:57	1.14
***************
*** 67,71 ****
  # PROP Target_Dir ""
  # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
! # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
  # SUBTRACT CPP /Fr
  # ADD BASE RSC /l 0x41d /d "_DEBUG"
--- 67,71 ----
  # PROP Target_Dir ""
  # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
! # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "ALLOW_GDI" /Yu"stdafx.h" /FD /GZ /c
  # SUBTRACT CPP /Fr
  # ADD BASE RSC /l 0x41d /d "_DEBUG"
***************
*** 102,105 ****
--- 102,109 ----
  # Begin Source File
  
+ SOURCE=.\akos.cpp
+ # End Source File
+ # Begin Source File
+ 
  SOURCE=.\boxes.cpp
  
***************
*** 116,128 ****
  
  SOURCE=.\costume.cpp
- 
- !IF  "$(CFG)" == "scummvm - Win32 Release"
- 
- # ADD CPP /Gd
- 
- !ELSEIF  "$(CFG)" == "scummvm - Win32 Debug"
- 
- !ENDIF 
- 
  # End Source File
  # Begin Source File
--- 120,123 ----
***************
*** 253,260 ****
  # Begin Source File
  
- SOURCE=.\sdl.cpp
- # End Source File
- # Begin Source File
- 
  SOURCE=.\sound.cpp
  
--- 248,251 ----
***************
*** 321,324 ****
--- 312,319 ----
  !ENDIF 
  
+ # End Source File
+ # Begin Source File
+ 
+ SOURCE=.\windows.cpp
  # End Source File
  # End Group

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** sound.cpp	2001/11/14 19:33:10	1.8
--- sound.cpp	2001/11/26 19:57:57	1.9
***************
*** 25,31 ****
--- 25,33 ----
  
  void Scumm::addSoundToQueue(int sound) {
+ #if !defined(FULL_THROTTLE)
  	_vars[VAR_LAST_SOUND] = sound;
  	ensureResourceLoaded(rtSound, sound);
  	addSoundToQueue2(sound);
+ #endif
  }
  
***************
*** 78,83 ****
--- 80,87 ----
  				);
  #endif
+ #if !defined(FULL_THROTTLE)
  			if (se) 
  				_vars[VAR_SOUNDRESULT] = se->do_command(data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]);
+ #endif
  		}
  	}
***************
*** 115,119 ****
  				if (_mouthSyncMode != b) {
  					_mouthSyncMode = b;
! 					startAnimActor(a, b ? a->talkFrame2 : a->talkFrame1, a->facing);
  				}
  			}
--- 119,123 ----
  				if (_mouthSyncMode != b) {
  					_mouthSyncMode = b;
! 					startAnimActor(a, b ? a->talkFrame2 : a->talkFrame1);
  				}
  			}
***************
*** 134,137 ****
--- 138,143 ----
  	byte file_byte,file_byte_2;
  	uint16 elem;
+ 
+ 	return;
  
  	if (!_sfxFile) {

Index: string.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/string.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** string.cpp	2001/11/14 18:37:38	1.10
--- string.cpp	2001/11/26 19:57:57	1.11
***************
*** 187,191 ****
  
  	if (a && string[0].overhead!=0) {
! 		if (_majorScummVersion==5) {
  			string[0].xpos = a->x - camera._curPos + 160;
  
--- 187,191 ----
  
  	if (a && string[0].overhead!=0) {
! 		if (!(_features & GF_AFTER_V6)) {
  			string[0].xpos = a->x - camera._curPos + 160;
  
***************
*** 251,255 ****
  
  	if (a && !string[0].no_talk_anim) {
! 		startAnimActor(a, a->talkFrame1, a->facing);
  		_useTalkAnims = true;
  	}
--- 251,255 ----
  
  	if (a && !string[0].no_talk_anim) {
! 		startAnimActor(a, a->talkFrame1);
  		_useTalkAnims = true;
  	}
***************
*** 307,311 ****
  			charset._top = charset._ypos2;
  			
! 			if (_majorScummVersion==5) {
  				if (!_vars[VAR_V5_CHARFLAG]) {
  					charset.printChar(c);
--- 307,311 ----
  			charset._top = charset._ypos2;
  			
! 			if (!(_features&GF_AFTER_V6)) {
  				if (!_vars[VAR_V5_CHARFLAG]) {
  					charset.printChar(c);
***************
*** 337,341 ****
  			frme |= *buffer++<<8;
  			if (a)
! 				startAnimActor(a, frme, a->facing);
  		} else if (c==10) {
  			uint32 a,b;
--- 337,341 ----
  			frme |= *buffer++<<8;
  			if (a)
! 				startAnimActor(a, frme);
  		} else if (c==10) {
  			uint32 a,b;
***************
*** 457,461 ****
  			}
  		} else {
! 			if (a==1 && _majorScummVersion==6)
  				charset._blitAlso = true;
  			charset.printChar(chr);
--- 457,461 ----
  			}
  		} else {
! 			if (a==1 && (_features&GF_AFTER_V6))
  				charset._blitAlso = true;
  			charset.printChar(chr);
***************
*** 604,608 ****
  	byte *ptr;
  
! 	if (_majorScummVersion==6)
  		var = readVar(var);
  	
--- 604,608 ----
  	byte *ptr;
  
! 	if (_features&GF_AFTER_V6)
  		var = readVar(var);
  	

Index: verbs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/verbs.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** verbs.cpp	2001/11/14 20:09:39	1.10
--- verbs.cpp	2001/11/26 19:57:57	1.11
***************
*** 186,195 ****
  
  	obim = getResourceAddress(rtVerb, vrb);
! 	IMHD_ptr = findResource(MKID('IMHD'), obim, 0);
  
  	imgw = READ_LE_UINT16(IMHD_ptr+0x14) >> 3;
  	imgh = READ_LE_UINT16(IMHD_ptr+0x16) >> 3;
  	
! 	imptr = findResource(MKID('IM01'), obim, 0);
  	if (!imptr)
  		error("No image for verb %d", vrb);
--- 186,195 ----
  
  	obim = getResourceAddress(rtVerb, vrb);
! 	IMHD_ptr = findResource(MKID('IMHD'), obim);
  
  	imgw = READ_LE_UINT16(IMHD_ptr+0x14) >> 3;
  	imgh = READ_LE_UINT16(IMHD_ptr+0x16) >> 3;
  	
! 	imptr = findResource(MKID('IM01'), obim);
  	if (!imptr)
  		error("No image for verb %d", vrb);
***************
*** 244,281 ****
  
  void Scumm::setVerbObject(uint room, uint object, uint verb) {
- 	int numobj, i;
  	byte  *obimptr;
! 	uint32 imoffs,size;
! 	byte *roomptr;
! 	ImageHeader *imhd;
! 	RoomHeader *roomhdr;
  
  	if (whereIsObject(object) == WIO_FLOBJECT)
  		error("Can't grab verb image from flobject");
- 
- 	ensureResourceLoaded(rtRoom,room);
- 	roomptr = getResourceAddress(rtRoom, room);
- 	roomhdr = (RoomHeader*)findResource(MKID('RMHD'), roomptr, 0);
- 
- 	numobj = READ_LE_UINT16(&roomhdr->numObjects);
- 	if (numobj==0)
- 		error("No images found in room %d", room);
- 	if (numobj > _numLocalObjects)
- 		error("More (%d) than %d objects in room %d", numobj, _numLocalObjects, room);
  
! 	for (i=0; i<numobj; i++) {
! 		obimptr = findResource(MKID('OBIM'), roomptr, i);
! 		if (obimptr==NULL)
! 			error("Not enough image blocks in room %d", room);
! 		imhd = (ImageHeader*)findResource(MKID('IMHD'), obimptr, 0);
! 		if ( READ_LE_UINT16(&imhd->obj_id) == object) {
! 			imoffs = obimptr - roomptr;
! 			size = READ_BE_UINT32_UNALIGNED(obimptr+4);
! 			createResource(rtVerb, verb, size);
! 			obimptr = getResourceAddress(rtRoom, room) + imoffs;
! 			memcpy(getResourceAddress(rtVerb, verb), obimptr, size);
! 			return;
! 		}
! 	}
! 	error("Image %d not found in room %d", object, room);
  }
--- 244,258 ----
  
  void Scumm::setVerbObject(uint room, uint object, uint verb) {
  	byte  *obimptr;
! 	uint32 size;
! 	FindObjectInRoom foir;
  
  	if (whereIsObject(object) == WIO_FLOBJECT)
  		error("Can't grab verb image from flobject");
  
! 	findObjectInRoom(&foir, foImageHeader, object, room);
! 	size = READ_BE_UINT32_UNALIGNED(foir.obim+4);
! 	createResource(rtVerb, verb, size);
! 	obimptr = getResourceAddress(rtRoom, room) - foir.roomptr + foir.obim;
! 	memcpy(getResourceAddress(rtVerb, verb), obimptr, size);
  }

Index: windows.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/windows.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** windows.cpp	2001/11/14 18:37:38	1.18
--- windows.cpp	2001/11/26 19:57:57	1.19
***************
*** 770,779 ****
  		wm->_vgabuf = buf;
  		memcpy(buf, wm->_vgabuf, 64000);
! 		memcpy(buf+320*144,s->getResourceAddress(rtBuffer, 7),320*56);
  		break;
  	case 1:
  		wm->_vgabuf = buf;
  		memcpy(buf, wm->_vgabuf, 64000);
! 		memcpy(buf+320*144,s->getResourceAddress(rtBuffer, 3),320*56);
  		break;
  	case 2:
--- 770,779 ----
  		wm->_vgabuf = buf;
  		memcpy(buf, wm->_vgabuf, 64000);
! 		memcpy(buf,s->getResourceAddress(rtBuffer, 5),320*144);
  		break;
  	case 1:
  		wm->_vgabuf = buf;
  		memcpy(buf, wm->_vgabuf, 64000);
! 		memcpy(buf,s->getResourceAddress(rtBuffer, 1),320*144);
  		break;
  	case 2:
***************
*** 783,795 ****
  	case 3:
  		wm->_vgabuf = NULL;
! 		decompressMask(wm->dib.buf, s->getResourceAddress(rtBuffer, 9)+5920+s->_screenStartStrip);
  		break;
  	case 4:
  		wm->_vgabuf = NULL;
! 		decompressMask(wm->dib.buf, s->getResourceAddress(rtBuffer, 9)+5920*2+s->_screenStartStrip);
  		break;
  	case 5:
  		wm->_vgabuf = NULL;
! 		decompressMask(wm->dib.buf, s->getResourceAddress(rtBuffer, 9)+5920*3+s->_screenStartStrip);
  		break;
  	}
--- 783,795 ----
  	case 3:
  		wm->_vgabuf = NULL;
! 		decompressMask(wm->dib.buf, s->getResourceAddress(rtBuffer, 9)+8160+s->_screenStartStrip);
  		break;
  	case 4:
  		wm->_vgabuf = NULL;
! 		decompressMask(wm->dib.buf, s->getResourceAddress(rtBuffer, 9)+8160*2+s->_screenStartStrip);
  		break;
  	case 5:
  		wm->_vgabuf = NULL;
! 		decompressMask(wm->dib.buf, s->getResourceAddress(rtBuffer, 9)+8160*3+s->_screenStartStrip);
  		break;
  	}
***************
*** 829,832 ****
--- 829,834 ----
  	if (!veryFastMode) {
  		assert(delay<5000);
+ 		if (s->_fastMode)
+ 			delay=10;
  		Sleep(delay);
  	} 
***************
*** 871,876 ****
  	wfx.nBlockAlign = BITS_PER_SAMPLE * 1 / 8;
  
! 	CreateThread(NULL, 0, (unsigned long (__stdcall *)(void *))&sound_thread, this, 0, &_threadId);
! 	SetThreadPriority((void*)_threadId, THREAD_PRIORITY_HIGHEST);
  
  	_event = CreateEvent(NULL, false, false, NULL);
--- 873,878 ----
  	wfx.nBlockAlign = BITS_PER_SAMPLE * 1 / 8;
  
! //	CreateThread(NULL, 0, (unsigned long (__stdcall *)(void *))&sound_thread, this, 0, &_threadId);
! //	SetThreadPriority((void*)_threadId, THREAD_PRIORITY_HIGHEST);
  
  	_event = CreateEvent(NULL, false, false, NULL);
***************
*** 889,892 ****
--- 891,896 ----
  	int time = GetTickCount(), cur;
  
+ 	return 0;
+ 
  	while (1) {
  		cur = GetTickCount();
***************
*** 914,918 ****
  int main(int argc, char* argv[]) {
  	int delta;
- 	int tmp;
  
  	wm->init();
--- 918,921 ----
***************
*** 932,947 ****
  		updateScreen(&scumm);
  
! 		waitForTimer(&scumm, tmp*10);
  
  		if (gui._active) {
  			gui.loop();
! 			tmp = 5;
  		} else {
! 			tmp = delta = scumm.scummLoop(delta);
! 
! 			tmp += tmp>>1;
! 			
! 			if (scumm._fastMode)
! 				tmp=1;
  		}
  	} while(1);
--- 935,945 ----
  		updateScreen(&scumm);
  
! 		waitForTimer(&scumm, delta*15);
  
  		if (gui._active) {
  			gui.loop();
! 			delta = 3;
  		} else {
! 			delta = scumm.scummLoop(delta);
  		}
  	} while(1);





More information about the Scummvm-git-logs mailing list