[Scummvm-cvs-logs] CVS: scummvm gfx.cpp,1.40,1.41 gui.cpp,1.9,1.10 gui.h,1.5,1.6 insane.cpp,1.3,1.4 object.cpp,1.35,1.36 resource.cpp,1.46,1.47 saveload.cpp,1.29,1.30 script.cpp,1.29,1.30 script_v1.cpp,1.38,1.39 script_v2.cpp,1.33,1.34 scummvm.cpp,1.66,1.67

James Brown ender at users.sourceforge.net
Fri Mar 8 00:43:02 CET 2002


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

Modified Files:
	gfx.cpp gui.cpp gui.h insane.cpp object.cpp resource.cpp 
	saveload.cpp script.cpp script_v1.cpp script_v2.cpp 
	scummvm.cpp 
Log Message:
Yet more cleanups. Remove 'index' (reserved keyword), and remove 'res' shadowing.



Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gfx.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** gfx.cpp	6 Mar 2002 12:24:56 -0000	1.40
--- gfx.cpp	8 Mar 2002 08:42:10 -0000	1.41
***************
*** 2019,2027 ****
  }
  
! void Scumm::setPalColor(int index, int r, int g, int b) {
! 	_currentPalette[index*3+0] = r;
! 	_currentPalette[index*3+1] = g;
! 	_currentPalette[index*3+2] = b;
! 	setDirtyColors(index,index);
  }
  
--- 2019,2027 ----
  }
  
! void Scumm::setPalColor(int idx, int r, int g, int b) {
! 	_currentPalette[idx*3+0] = r;
! 	_currentPalette[idx*3+1] = g;
! 	_currentPalette[idx*3+2] = b;
! 	setDirtyColors(idx,idx);
  }
  
***************
*** 2089,2093 ****
  }
  
! byte *Scumm::findPalInPals(byte *pal, int index) {
  	byte *offs;
  	uint32 size;	
--- 2089,2093 ----
  }
  
! byte *Scumm::findPalInPals(byte *pal, int idx) {
  	byte *offs;
  	uint32 size;	
***************
*** 2103,2110 ****
  	size = getResourceDataSize(offs) >> 2;
  	
! 	if ((uint32)index >= (uint32)size)
  		return NULL;
  
! 	return offs + READ_LE_UINT32(offs + index * sizeof(uint32));
  }
  
--- 2103,2110 ----
  	size = getResourceDataSize(offs) >> 2;
  	
! 	if ((uint32)idx >= (uint32)size)
  		return NULL;
  
! 	return offs + READ_LE_UINT32(offs + idx * sizeof(uint32));
  }
  
***************
*** 2253,2257 ****
  };
  
! void Scumm::decompressDefaultCursor(int index) {
  	int i;
  	byte color;
--- 2253,2257 ----
  };
  
! void Scumm::decompressDefaultCursor(int idx) {
  	int i;
  	byte color;
***************
*** 2263,2267 ****
  	_cursorHotspotY = 7;
  
! 	color = default_cursor_colors[index];
  	
  	for(i=0; i<16; i++) {
--- 2263,2267 ----
  	_cursorHotspotY = 7;
  
! 	color = default_cursor_colors[idx];
  	
  	for(i=0; i<16; i++) {

Index: gui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** gui.cpp	6 Mar 2002 00:18:22 -0000	1.9
--- gui.cpp	8 Mar 2002 08:42:10 -0000	1.10
***************
*** 270,279 ****
  	{GUI_TEXT,0x04,GWF_BUTTON,200,45,54,16,8,9}, /* Ok */
  	{GUI_TEXT,0x04,GWF_BUTTON,200,65,54,16,7,7}, /* Cancel */
! 	{0}
  };
  
  const GuiWidget pause_dialog[] = {
  	{GUI_TEXT,0x01,GWF_DEFAULT,50,80,220,16,0,10},
! 	{0},
  };
  
--- 270,279 ----
  	{GUI_TEXT,0x04,GWF_BUTTON,200,45,54,16,8,9}, /* Ok */
  	{GUI_TEXT,0x04,GWF_BUTTON,200,65,54,16,7,7}, /* Cancel */
! 	{0,0,0,0,0,0,0,0,0}
  };
  
  const GuiWidget pause_dialog[] = {
  	{GUI_TEXT,0x01,GWF_DEFAULT,50,80,220,16,0,10},
! 	{0,0,0,0,0,0,0,0,0}
  };
  

Index: gui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** gui.h	2 Feb 2002 19:07:10 -0000	1.5
--- gui.h	8 Mar 2002 08:42:10 -0000	1.6
***************
*** 6,10 ****
  	GUI_TEXT = 1,
  	GUI_IMAGE = 2,
! 	GUI_STAT = 3,
  };
  
--- 6,10 ----
  	GUI_TEXT = 1,
  	GUI_IMAGE = 2,
! 	GUI_STAT = 3
  };
  
***************
*** 15,19 ****
  	GWF_DELAY = 8,
  	GWF_DEFAULT = GWF_BORDER|GWF_CLEARBG,
! 	GWF_BUTTON = GWF_BORDER|GWF_CLEARBG|GWF_DELAY,
  
  };
--- 15,19 ----
  	GWF_DELAY = 8,
  	GWF_DEFAULT = GWF_BORDER|GWF_CLEARBG,
! 	GWF_BUTTON = GWF_BORDER|GWF_CLEARBG|GWF_DELAY
  
  };

Index: insane.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/insane.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** insane.cpp	6 Mar 2002 21:22:56 -0000	1.3
--- insane.cpp	8 Mar 2002 08:42:10 -0000	1.4
***************
*** 1,573 ****
! // insane.cpp : Defines the entry point for the console application.
! //
! 
! #define NEED_SDL_HEADERS
! 
! #include "stdafx.h"
! #include "scumm.h"
! 
! #define SWAP2(a) ((((a)>>24)&0xFF) | (((a)>>8)&0xFF00) | (((a)<<8)&0xFF0000) | (((a)<<24)&0xFF000000))
! 
[...1690 lines suppressed...]
! 		updateScreen(sm);
! 
! 
! 
! 		waitForTimer(sm,20);
! 
! 
! 
! 		if(sm->_keyPressed == sm->_vars[sm->VAR_CUTSCENEEXIT_KEY])
! 
! 			return;
! 
! 
! 
! 	} while (1);
! 
! }
! 
! 
! 

Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/object.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** object.cpp	6 Mar 2002 12:24:56 -0000	1.35
--- object.cpp	8 Mar 2002 08:42:10 -0000	1.36
***************
*** 944,952 ****
  }
  
! int Scumm::findInventory(int owner, int index) {
  	int count = 1, i, obj;
  	for (i=0; i!=_maxInventoryItems; i++) {
  		obj = _inventory[i];
! 		if (obj && getOwner(obj)==owner && count++ == index)
  			return obj;
  	}
--- 944,952 ----
  }
  
! int Scumm::findInventory(int owner, int idx) {
  	int count = 1, i, obj;
  	for (i=0; i!=_maxInventoryItems; i++) {
  		obj = _inventory[i];
! 		if (obj && getOwner(obj)==owner && count++ == idx)
  			return obj;
  	}
***************
*** 1131,1135 ****
  	byte *roomptr,*bomp;
  	byte *ptr;
! 	int index;
  	ObjectData *od;
  
--- 1131,1135 ----
  	byte *roomptr,*bomp;
  	byte *ptr;
! 	int idx;
  	ObjectData *od;
  
***************
*** 1142,1148 ****
  	if (eo->l==0) {
  		roomptr = getResourceAddress(1, _roomResource);
! 		index = getObjectIndex(eo->a);
! 		assert(index != -1);
! 		ptr = roomptr + _objs[index].offs_obim_to_room;
  	} else if (eo->a!=0) {
  		od = &_objs[getObjectIndex(eo->a)];
--- 1142,1148 ----
  	if (eo->l==0) {
  		roomptr = getResourceAddress(1, _roomResource);
! 		idx = getObjectIndex(eo->a);
! 		assert(idx != -1);
! 		ptr = roomptr + _objs[idx].offs_obim_to_room;
  	} else if (eo->a!=0) {
  		od = &_objs[getObjectIndex(eo->a)];

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/resource.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** resource.cpp	6 Mar 2002 00:18:22 -0000	1.46
--- resource.cpp	8 Mar 2002 08:42:10 -0000	1.47
***************
*** 570,589 ****
  }
  
! int Scumm::loadResource(int type, int index) {
  	int roomNr, i;
  	uint32 fileOffs;
  	uint32 size, tag;
  	
! //	debug(1, "loadResource(%d,%d)", type,index);
  
          if(type == rtCharset && (_features & GF_SMALL_HEADER)){
!                 loadCharset(index);
                  return(1);
          }
  
! 	roomNr = getResourceRoomNr(type, index);
! 	if (roomNr == 0 || index >= res.num[type]) {
  		error("%s %d undefined", 
! 			res.name[type],index);
  	}
  
--- 570,589 ----
  }
  
! int Scumm::loadResource(int type, int idx) {
  	int roomNr, i;
  	uint32 fileOffs;
  	uint32 size, tag;
  	
! //	debug(1, "loadResource(%d,%d)", type,idx);
  
          if(type == rtCharset && (_features & GF_SMALL_HEADER)){
!                 loadCharset(idx);
                  return(1);
          }
  
! 	roomNr = getResourceRoomNr(type, idx);
! 	if (roomNr == 0 || idx >= res.num[type]) {
  		error("%s %d undefined", 
! 			res.name[type],idx);
  	}
  
***************
*** 591,595 ****
  		fileOffs = 0;
  	} else {
! 		fileOffs = res.roomoffs[type][index];
  		if (fileOffs==0xFFFFFFFF)
  			return 0;
--- 591,595 ----
  		fileOffs = 0;
  	} else {
! 		fileOffs = res.roomoffs[type][idx];
  		if (fileOffs==0xFFFFFFFF)
  			return 0;
***************
*** 612,616 ****
                                          fileReadDwordLE();
                                          fileReadDwordLE();
!                                         return readSoundResource(type, index);
                                  }
  			
--- 612,616 ----
                                          fileReadDwordLE();
                                          fileReadDwordLE();
!                                         return readSoundResource(type, idx);
                                  }
  			
***************
*** 625,634 ****
                                  fileSeek(_fileHandle, -8, SEEK_CUR);
                          }
! 			fileRead(_fileHandle, createResource(type, index, size), size);
  
                   /* dump the resource */
  #ifdef DUMP_SCRIPTS
  			if(type==rtScript) {
! 				dumpResource("script-", index, getResourceAddress(rtScript, index));
  			}
  #endif
--- 625,634 ----
                                  fileSeek(_fileHandle, -8, SEEK_CUR);
                          }
! 			fileRead(_fileHandle, createResource(type, idx, size), size);
  
                   /* dump the resource */
  #ifdef DUMP_SCRIPTS
  			if(type==rtScript) {
! 				dumpResource("script-", idx, getResourceAddress(rtScript, idx));
  			}
  #endif
***************
*** 638,642 ****
  			}
  
! 			nukeResource(type, index);
  		}
  
--- 638,642 ----
  			}
  
! 			nukeResource(type, idx);
  		}
  
***************
*** 645,654 ****
  }
  
! int Scumm::readSoundResource(int type, int index) {
  	uint32 pos, total_size, size, tag,basetag;
  	int pri, best_pri;
  	uint32 best_size, best_offs;
  
! 	debug(9, "readSoundResource(%d,%d)", type, index);
  
  	pos = 0;
--- 645,654 ----
  }
  
! int Scumm::readSoundResource(int type, int idx) {
  	uint32 pos, total_size, size, tag,basetag;
  	int pri, best_pri;
  	uint32 best_size, best_offs;
  
! 	debug(9, "readSoundResource(%d,%d)", type, idx);
  
  	pos = 0;
***************
*** 660,664 ****
  		if (basetag == MKID('MIDI')) {
  			fileSeek(_fileHandle, -8, SEEK_CUR);
! 			fileRead(_fileHandle,createResource(type, index, total_size+8), total_size+8);
  			return 1;
          	}
--- 660,664 ----
  		if (basetag == MKID('MIDI')) {
  			fileSeek(_fileHandle, -8, SEEK_CUR);
! 			fileRead(_fileHandle,createResource(type, idx, total_size+8), total_size+8);
  			return 1;
          	}
***************
*** 691,727 ****
  		if (best_pri != -1) {
  			fileSeek(_fileHandle, best_offs - 8, SEEK_SET);
! 			fileRead(_fileHandle,createResource(type, index, best_size), best_size);
  			return 1;
  		}
  
  	}
! 	res.roomoffs[type][index] = 0xFFFFFFFF;
  	return 0;
  }
  
! int Scumm::getResourceRoomNr(int type, int index) {
  	if (type==rtRoom)
! 		return index;
! 	return res.roomno[type][index];
  }
  
! byte *Scumm::getResourceAddress(int type, int index) {
  	byte *ptr;
  
! 	debug(9, "getResourceAddress(%d,%d)", type, index);
  
  	CHECK_HEAP
  
! 	validateResource("getResourceAddress", type, index);
  	
! 	if (res.mode[type] && !res.address[type][index]) {
! 		ensureResourceLoaded(type, index);
  	}	
  
! 	ptr=(byte*)res.address[type][index];
  	if (!ptr)
  		return NULL;
  
! 	setResourceCounter(type, index, 1);
  
  	return ptr + sizeof(MemBlkHeader);
--- 691,727 ----
  		if (best_pri != -1) {
  			fileSeek(_fileHandle, best_offs - 8, SEEK_SET);
! 			fileRead(_fileHandle,createResource(type, idx, best_size), best_size);
  			return 1;
  		}
  
  	}
! 	res.roomoffs[type][idx] = 0xFFFFFFFF;
  	return 0;
  }
  
! int Scumm::getResourceRoomNr(int type, int idx) {
  	if (type==rtRoom)
! 		return idx;
! 	return res.roomno[type][idx];
  }
  
! byte *Scumm::getResourceAddress(int type, int idx) {
  	byte *ptr;
  
! 	debug(9, "getResourceAddress(%d,%d)", type, idx);
  
  	CHECK_HEAP
  
! 	validateResource("getResourceAddress", type, idx);
  	
! 	if (res.mode[type] && !res.address[type][idx]) {
! 		ensureResourceLoaded(type, idx);
  	}	
  
! 	ptr=(byte*)res.address[type][idx];
  	if (!ptr)
  		return NULL;
  
! 	setResourceCounter(type, idx, 1);
  
  	return ptr + sizeof(MemBlkHeader);
***************
*** 738,744 ****
  }
  
! void Scumm::setResourceCounter(int type, int index, byte flag) {
! 	res.flags[type][index] &= ~RF_USAGE;
! 	res.flags[type][index] |= flag;
  }
  
--- 738,744 ----
  }
  
! void Scumm::setResourceCounter(int type, int idx, byte flag) {
! 	res.flags[type][idx] &= ~RF_USAGE;
! 	res.flags[type][idx] |= flag;
  }
  
***************
*** 746,761 ****
  #define SAFETY_AREA 2
  
! byte *Scumm::createResource(int type, int index, uint32 size) {
  	byte *ptr;
  
  	CHECK_HEAP
  
! 	debug(9, "createResource(%d,%d,%d)", type, index,size);
  
  	if (size > 65536*4+37856)
  		warning("Probably invalid size allocating %d", size);
  
! 	validateResource("allocating", type, index);
! 	nukeResource(type, index);
  
  	expireResources(size);
--- 746,761 ----
  #define SAFETY_AREA 2
  
! byte *Scumm::createResource(int type, int idx, uint32 size) {
  	byte *ptr;
  
  	CHECK_HEAP
  
! 	debug(9, "createResource(%d,%d,%d)", type, idx,size);
  
  	if (size > 65536*4+37856)
  		warning("Probably invalid size allocating %d", size);
  
! 	validateResource("allocating", type, idx);
! 	nukeResource(type, idx);
  
  	expireResources(size);
***************
*** 770,797 ****
  	_allocatedSize += size;
  
! 	res.address[type][index] = ptr;
  	((MemBlkHeader*)ptr)->size = size;
! 	setResourceCounter(type, index, 1);
  	return ptr + sizeof(MemBlkHeader); /* skip header */
  }
  
! void Scumm::validateResource(const char *str, int type, int index) {
! 	if (type<rtFirst || type>rtLast || (uint)index >= (uint)res.num[type]) {
! 		error("%s Illegal Glob type %d num %d", str, type, index);
  	}
  }
  
! void Scumm::nukeResource(int type, int index) {
  	byte *ptr;
  
! 	debug(9, "nukeResource(%d,%d)", type, index);
  
  	CHECK_HEAP
  	assert( res.address[type] );
! 	assert( index>=0 && index < res.num[type]);
  
! 	if ((ptr = res.address[type][index]) != NULL) {
! 		res.address[type][index] = 0;
! 		res.flags[type][index] = 0;
  		_allocatedSize -= ((MemBlkHeader*)ptr)->size;
  		free(ptr);
--- 770,797 ----
  	_allocatedSize += size;
  
! 	res.address[type][idx] = ptr;
  	((MemBlkHeader*)ptr)->size = size;
! 	setResourceCounter(type, idx, 1);
  	return ptr + sizeof(MemBlkHeader); /* skip header */
  }
  
! void Scumm::validateResource(const char *str, int type, int idx) {
! 	if (type<rtFirst || type>rtLast || (uint)idx >= (uint)res.num[type]) {
! 		error("%s Illegal Glob type %d num %d", str, type, idx);
  	}
  }
  
! void Scumm::nukeResource(int type, int idx) {
  	byte *ptr;
  
! 	debug(9, "nukeResource(%d,%d)", type, idx);
  
  	CHECK_HEAP
  	assert( res.address[type] );
! 	assert( idx>=0 && idx < res.num[type]);
  
! 	if ((ptr = res.address[type][idx]) != NULL) {
! 		res.address[type][idx] = 0;
! 		res.flags[type][idx] = 0;
  		_allocatedSize -= ((MemBlkHeader*)ptr)->size;
  		free(ptr);
***************
*** 888,892 ****
  }
  
! byte *findResource(uint32 tag, byte *searchin, int index) {
  	uint32 curpos,totalsize,size;
  
--- 888,892 ----
  }
  
! byte *findResource(uint32 tag, byte *searchin, int idx) {
  	uint32 curpos,totalsize,size;
  
***************
*** 899,903 ****
  
  	while (curpos<totalsize) {
! 		if (READ_UINT32_UNALIGNED(searchin)==tag && !index--)
  			return searchin;
  
--- 899,903 ----
  
  	while (curpos<totalsize) {
! 		if (READ_UINT32_UNALIGNED(searchin)==tag && !idx--)
  			return searchin;
  
***************
*** 918,922 ****
  }
  
! byte *findResourceSmall(uint32 tag, byte *searchin, int index) {
          uint32 curpos,totalsize,size;
          uint16 smallTag;
--- 918,922 ----
  }
  
! byte *findResourceSmall(uint32 tag, byte *searchin, int idx) {
          uint32 curpos,totalsize,size;
          uint16 smallTag;
***************
*** 933,937 ****
                  size = READ_LE_UINT32(searchin);
  
!                 if (READ_LE_UINT16(searchin+4)==smallTag && !index--)
                         return searchin;
  
--- 933,937 ----
                  size = READ_LE_UINT32(searchin);
  
!                 if (READ_LE_UINT16(searchin+4)==smallTag && !idx--)
                         return searchin;
  
***************
*** 1077,1083 ****
  }
  
! bool Scumm::isResourceLoaded(int type, int index) {
! 	validateResource("isLoaded", type, index);
! 	return res.address[type][index] != NULL;
  }
  
--- 1077,1083 ----
  }
  
! bool Scumm::isResourceLoaded(int type, int idx) {
! 	validateResource("isLoaded", type, idx);
! 	return res.address[type][idx] != NULL;
  }
  

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saveload.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** saveload.cpp	5 Mar 2002 23:41:41 -0000	1.29
--- saveload.cpp	8 Mar 2002 08:42:11 -0000	1.30
***************
*** 525,529 ****
  }
  
! void Scumm::saveLoadResource(Serializer *ser, int type, int index) {
  	byte *ptr;
  	uint32 size;
--- 525,529 ----
  }
  
! void Scumm::saveLoadResource(Serializer *ser, int type, int idx) {
  	byte *ptr;
  	uint32 size;
***************
*** 534,538 ****
  
  	if (ser->isSaving()) {
! 		ptr = res.address[type][index];
  		if (ptr==NULL) {
  			ser->saveUint32(0);
--- 534,538 ----
  
  	if (ser->isSaving()) {
! 		ptr = res.address[type][idx];
  		if (ptr==NULL) {
  			ser->saveUint32(0);
***************
*** 546,558 ****
  
  		if (type==rtInventory) {
! 			ser->saveWord(_inventory[index]);
  		}
  	} else {
  		size = ser->loadUint32();
  		if (size) {
! 			createResource(type, index, size);
! 			ser->saveLoadBytes(getResourceAddress(type, index), size);
  			if (type==rtInventory) {
! 				_inventory[index] = ser->loadWord();
  			}
  		}
--- 546,558 ----
  
  		if (type==rtInventory) {
! 			ser->saveWord(_inventory[idx]);
  		}
  	} else {
  		size = ser->loadUint32();
  		if (size) {
! 			createResource(type, idx, size);
! 			ser->saveLoadBytes(getResourceAddress(type, idx), size);
  			if (type==rtInventory) {
! 				_inventory[idx] = ser->loadWord();
  			}
  		}

Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/script.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** script.cpp	6 Mar 2002 15:55:31 -0000	1.29
--- script.cpp	8 Mar 2002 08:42:11 -0000	1.30
***************
*** 208,212 ****
  void Scumm::getScriptBaseAddress() {
  	ScriptSlot *ss;
! 	int index;
  
  	if (_currentScript == 0xFF)
--- 208,212 ----
  void Scumm::getScriptBaseAddress() {
  	ScriptSlot *ss;
! 	int idx;
  
  	if (_currentScript == 0xFF)
***************
*** 216,222 ****
  	switch(ss->where) {
  	case WIO_INVENTORY: /* inventory script **/
! 		index = getObjectIndex(ss->number);
! 		_scriptOrgPointer = getResourceAddress(rtInventory, index);
! 		_lastCodePtr = &_baseInventoryItems[index];
  		break;
  
--- 216,222 ----
  	switch(ss->where) {
  	case WIO_INVENTORY: /* inventory script **/
! 		idx = getObjectIndex(ss->number);
! 		_scriptOrgPointer = getResourceAddress(rtInventory, idx);
! 		_lastCodePtr = &_baseInventoryItems[idx];
  		break;
  
***************
*** 233,238 ****
  
  	case WIO_FLOBJECT: /* flobject script */
! 		index = getObjectIndex(ss->number);
! 		_scriptOrgPointer = getResourceAddress(rtFlObject,_objs[index].fl_object_index);
  		_lastCodePtr = &_baseFLObject[ss->number];
  		break;
--- 233,238 ----
  
  	case WIO_FLOBJECT: /* flobject script */
! 		idx = getObjectIndex(ss->number);
! 		_scriptOrgPointer = getResourceAddress(rtFlObject,_objs[idx].fl_object_index);
  		_lastCodePtr = &_baseFLObject[ss->number];
  		break;
***************
*** 882,895 ****
  
  void Scumm::beginOverride() {
! 	int index;
  	uint32 *ptr;
  
! 	index = vm.cutSceneStackPointer;
! 	ptr = &vm.cutScenePtr[index];
  	if (!*ptr) {
  		vm.slot[_currentScript].cutsceneOverride++;
  	}
  	*ptr = _scriptPointer - _scriptOrgPointer;
! 	vm.cutSceneScript[index] = _currentScript;
  
  	fetchScriptByte();
--- 882,895 ----
  
  void Scumm::beginOverride() {
! 	int idx;
  	uint32 *ptr;
  
! 	idx = vm.cutSceneStackPointer;
! 	ptr = &vm.cutScenePtr[idx];
  	if (!*ptr) {
  		vm.slot[_currentScript].cutsceneOverride++;
  	}
  	*ptr = _scriptPointer - _scriptOrgPointer;
! 	vm.cutSceneScript[idx] = _currentScript;
  
  	fetchScriptByte();
***************
*** 899,912 ****
  
  void Scumm::endOverride() {
! 	int index;
  	uint32 *ptr;
  
! 	index = vm.cutSceneStackPointer;
! 	ptr = &vm.cutScenePtr[index];
  	if (*ptr) {
  		vm.slot[_currentScript].cutsceneOverride--;
  	}
  	*ptr = 0;
! 	vm.cutSceneScript[index] = 0;
  	_vars[VAR_OVERRIDE] = 0;
  }
--- 899,912 ----
  
  void Scumm::endOverride() {
! 	int idx;
  	uint32 *ptr;
  
! 	idx = vm.cutSceneStackPointer;
! 	ptr = &vm.cutScenePtr[idx];
  	if (*ptr) {
  		vm.slot[_currentScript].cutsceneOverride--;
  	}
  	*ptr = 0;
! 	vm.cutSceneScript[idx] = 0;
  	_vars[VAR_OVERRIDE] = 0;
  }

Index: script_v1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/script_v1.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** script_v1.cpp	5 Mar 2002 23:41:41 -0000	1.38
--- script_v1.cpp	8 Mar 2002 08:42:11 -0000	1.39
***************
*** 1025,1029 ****
  
  void Scumm::o5_drawObject() {
! 	int state,obj,index,i;
  	ObjectData *od;
  	uint16 x,y,w,h;
--- 1025,1029 ----
  
  void Scumm::o5_drawObject() {
! 	int state,obj,idx,i;
  	ObjectData *od;
  	uint16 x,y,w,h;
***************
*** 1038,1045 ****
                  int room = getVarOrDirectWord(0x20);
   
!                 index = getObjectIndex(obj);
!                 if(index==-1)
                          return;
!                 od = &_objs[index];
                  xpos = ypos = 255;
                  if (temp!=0xFF) {
--- 1038,1045 ----
                  int room = getVarOrDirectWord(0x20);
   
!                 idx = getObjectIndex(obj);
!                 if(idx==-1)
                          return;
!                 od = &_objs[idx];
                  xpos = ypos = 255;
                  if (temp!=0xFF) {
***************
*** 1049,1053 ****
                          od->y_pos = ypos<<3;
                  }
!                 addObjectToDrawQue(index);
   
                  x = od->x_pos;
--- 1049,1053 ----
                          od->y_pos = ypos<<3;
                  }
!                 addObjectToDrawQue(idx);
   
                  x = od->x_pos;
***************
*** 1080,1087 ****
  	}
  
! 	index = getObjectIndex(obj);
! 	if (index==-1)
  		return;
! 	od = &_objs[index];
  	if (xpos!=0xFF) {
  		od->walk_x += (xpos<<3) - od->x_pos;
--- 1080,1087 ----
  	}
  
! 	idx = getObjectIndex(obj);
! 	if (idx==-1)
  		return;
! 	od = &_objs[idx];
  	if (xpos!=0xFF) {
  		od->walk_x += (xpos<<3) - od->x_pos;
***************
*** 1090,1094 ****
  		od->y_pos = ypos<<3;
  	}
! 	addObjectToDrawQue(index);
  
  	x = od->x_pos;
--- 1090,1094 ----
  		od->y_pos = ypos<<3;
  	}
! 	addObjectToDrawQue(idx);
  
  	x = od->x_pos;
***************
*** 1630,1699 ****
  
  void Scumm::o5_resourceRoutines() {
! 	int res;
  
  	_opcode = fetchScriptByte();
  	if (_opcode != 17)
! 		res = getVarOrDirectByte(0x80);
  	if(_features & GF_OLD256) /*FIXME: find a better way to implement this */
  		_opcode&=0x3F;
  	switch(_opcode&0x1F) {
  	case 1: /* load script */
! 		ensureResourceLoaded(rtScript, res);
  		break;
  	case 2: /* load sound */
! 		ensureResourceLoaded(rtSound, res);
  		break;
  	case 3: /* load costume */
! 		ensureResourceLoaded(rtCostume, res);
  		break;
  	case 4: /* load room */
  		if(_features & GF_OLD256)
! 			ensureResourceLoaded(rtScript, res & 0x7F); /*FIXME: missing stuff...*/
  		else
! 			ensureResourceLoaded(rtRoom, res);
  		break;
  	case 5: /* nuke script */
! 		setResourceCounter(rtScript, res, 0x7F);
  		break;
  	case 6: /* nuke sound */
! 		setResourceCounter(rtSound, res, 0x7F);
  		break;
  	case 7: /* nuke costume */
! 		setResourceCounter(rtCostume, res, 0x7F);
  		break;
  	case 8: /* nuke room */
! 		setResourceCounter(rtRoom, res, 0x7F);
  		break;
  	case 9:  /* lock script */
! 		if (res >= _numGlobalScripts)
  			break;
! 		lock(rtScript,res);
  		break;
  	case 10:/* lock sound */
! 		lock(rtSound,res);
  		break;
  	case 11:/* lock costume */
! 		lock(rtCostume,res);
  		break;
  	case 12:/* lock room */
! 		if (res > 0x7F)
! 			res = _resourceMapper[res&0x7F];
! 		lock(rtRoom,res);
  		break;
  	case 13:/* unlock script */
! 		if (res >= _numGlobalScripts)
  			break;
! 		unlock(rtScript,res);
  		break;
  	case 14:/* unlock sound */
! 		unlock(rtSound,res);
  		break;
  	case 15:/* unlock costume */
! 		unlock(rtCostume,res);
  		break;
  	case 16:/* unlock room */
! 		if (res > 0x7F)
! 			res = _resourceMapper[res&0x7F];
! 		unlock(rtRoom,res);
  		break;
  	case 17:/* clear heap */
--- 1630,1699 ----
  
  void Scumm::o5_resourceRoutines() {
! 	int resid;
  
  	_opcode = fetchScriptByte();
  	if (_opcode != 17)
! 		resid = getVarOrDirectByte(0x80);
  	if(_features & GF_OLD256) /*FIXME: find a better way to implement this */
  		_opcode&=0x3F;
  	switch(_opcode&0x1F) {
  	case 1: /* load script */
! 		ensureResourceLoaded(rtScript, resid);
  		break;
  	case 2: /* load sound */
! 		ensureResourceLoaded(rtSound, resid);
  		break;
  	case 3: /* load costume */
! 		ensureResourceLoaded(rtCostume, resid);
  		break;
  	case 4: /* load room */
  		if(_features & GF_OLD256)
! 			ensureResourceLoaded(rtScript, resid & 0x7F); /*FIXME: missing stuff...*/
  		else
! 			ensureResourceLoaded(rtRoom, resid);
  		break;
  	case 5: /* nuke script */
! 		setResourceCounter(rtScript, resid, 0x7F);
  		break;
  	case 6: /* nuke sound */
! 		setResourceCounter(rtSound, resid, 0x7F);
  		break;
  	case 7: /* nuke costume */
! 		setResourceCounter(rtCostume, resid, 0x7F);
  		break;
  	case 8: /* nuke room */
! 		setResourceCounter(rtRoom, resid, 0x7F);
  		break;
  	case 9:  /* lock script */
! 		if (resid >= _numGlobalScripts)
  			break;
! 		lock(rtScript,resid);
  		break;
  	case 10:/* lock sound */
! 		lock(rtSound,resid);
  		break;
  	case 11:/* lock costume */
! 		lock(rtCostume,resid);
  		break;
  	case 12:/* lock room */
! 		if (resid > 0x7F)
! 			resid = _resourceMapper[resid&0x7F];
! 		lock(rtRoom,resid);
  		break;
  	case 13:/* unlock script */
! 		if (resid >= _numGlobalScripts)
  			break;
! 		unlock(rtScript,resid);
  		break;
  	case 14:/* unlock sound */
! 		unlock(rtSound,resid);
  		break;
  	case 15:/* unlock costume */
! 		unlock(rtCostume,resid);
  		break;
  	case 16:/* unlock room */
! 		if (resid > 0x7F)
! 			resid = _resourceMapper[resid&0x7F];
! 		unlock(rtRoom,resid);
  		break;
  	case 17:/* clear heap */
***************
*** 1702,1712 ****
  		break;
  	case 18:/* load charset */
! 		loadCharset(res);
  		break;
  	case 19:/* nuke charset */
! 		nukeCharset(res);
  		break;
  	case 20:/* load fl object */
! 		loadFlObject(getVarOrDirectWord(0x40), res);
  		break;
          default:
--- 1702,1712 ----
  		break;
  	case 18:/* load charset */
! 		loadCharset(resid);
  		break;
  	case 19:/* nuke charset */
! 		nukeCharset(resid);
  		break;
  	case 20:/* load fl object */
! 		loadFlObject(getVarOrDirectWord(0x40), resid);
  		break;
          default:

Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/script_v2.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** script_v2.cpp	7 Mar 2002 05:41:53 -0000	1.33
--- script_v2.cpp	8 Mar 2002 08:42:11 -0000	1.34
***************
*** 701,705 ****
  
  
! int Scumm::readArray(int array, int index, int base) {
  	ArrayHeader *ah = (ArrayHeader*)getResourceAddress(rtString, readVar(array));
  
--- 701,705 ----
  
  
! int Scumm::readArray(int array, int idx, int base) {
  	ArrayHeader *ah = (ArrayHeader*)getResourceAddress(rtString, readVar(array));
  
***************
*** 708,712 ****
  	}
  
! 	base += index*ah->dim1_size;
  
  	assert(base>=0 && base < ah->dim1_size*ah->dim2_size);
--- 708,712 ----
  	}
  
! 	base += idx*ah->dim1_size;
  
  	assert(base>=0 && base < ah->dim1_size*ah->dim2_size);
***************
*** 719,726 ****
  }
  
! void Scumm::writeArray(int array, int index, int base, int value) {
  	ArrayHeader *ah = (ArrayHeader*)getResourceAddress(rtString, readVar(array));
  	assert(ah);
! 	base += index*ah->dim1_size;
  
  	assert(base>=0 && base < ah->dim1_size*ah->dim2_size);
--- 719,726 ----
  }
  
! void Scumm::writeArray(int array, int idx, int base, int value) {
  	ArrayHeader *ah = (ArrayHeader*)getResourceAddress(rtString, readVar(array));
  	assert(ah);
! 	base += idx*ah->dim1_size;
  
  	assert(base>=0 && base < ah->dim1_size*ah->dim2_size);
***************
*** 784,795 ****
  void Scumm::o6_byteArrayIndexedRead() {
  	int base = pop();
! 	int index = pop();
! 	push(readArray(fetchScriptByte(), index, base));
  }
  
  void Scumm::o6_wordArrayIndexedRead() {
  	int base = pop();
! 	int index = pop();
! 	push(readArray(fetchScriptWord(), index, base));
  }
  
--- 784,795 ----
  void Scumm::o6_byteArrayIndexedRead() {
  	int base = pop();
! 	int idx = pop();
! 	push(readArray(fetchScriptByte(), idx, base));
  }
  
  void Scumm::o6_wordArrayIndexedRead() {
  	int base = pop();
! 	int idx = pop();
! 	push(readArray(fetchScriptWord(), idx, base));
  }
  
***************
*** 1464,1470 ****
  
  void Scumm::o6_findInventory() {
! 	int index = pop();
  	int owner = pop();
! 	push(findInventory(owner,index));
  }
  
--- 1464,1470 ----
  
  void Scumm::o6_findInventory() {
! 	int idx = pop();
  	int owner = pop();
! 	push(findInventory(owner,idx));
  }
  
***************
*** 1544,1628 ****
  
  void Scumm::o6_resourceRoutines() {
! 	int res;
  
  	switch(fetchScriptByte()) {
  	case 100: /* load script */
! 		res = pop();
  		if(_features & GF_AFTER_V7)
! 			if (res >= _numGlobalScripts)
  				break;
! 		ensureResourceLoaded(rtScript, res);
  		break;
  	case 101: /* load sound */
! 		res = pop();
! 		ensureResourceLoaded(rtSound, res);
  		break;
  	case 102: /* load costume */
! 		res = pop();
! 		ensureResourceLoaded(rtCostume, res);
  		break;
  	case 103: /* load room */
! 		res = pop();
! 		ensureResourceLoaded(rtRoom, res);
  		break;
  	case 104: /* nuke script */
! 		res = pop();
  		if(_features & GF_AFTER_V7)
! 			if (res >= _numGlobalScripts)
  				break;
! 		setResourceCounter(rtScript, res, 0x7F);
! 		debug(5, "nuke script %d", res);
  		break;
  	case 105: /* nuke sound */
! 		res = pop();
! 		setResourceCounter(rtSound, res, 0x7F);
  		break;
  	case 106: /* nuke costume */
! 		res = pop();
! 		setResourceCounter(rtCostume, res, 0x7F);
  		break;
  	case 107: /* nuke room */
! 		res = pop();
! 		setResourceCounter(rtRoom, res, 0x7F);
  		break;
  	case 108:  /* lock script */
! 		res = pop();
! 		if (res >= _numGlobalScripts)
  			break;
! 		lock(rtScript,res);
  		break;
  	case 109:/* lock sound */
! 		res = pop();
! 		lock(rtSound,res);
  		break;
  	case 110:/* lock costume */
! 		res = pop();
! 		lock(rtCostume,res);
  		break;
  	case 111:/* lock room */
! 		res = pop();
! 		if (res > 0x7F)
! 			res = _resourceMapper[res&0x7F];
! 		lock(rtRoom,res);
  		break;
  	case 112:/* unlock script */
! 		res = pop();
! 		if (res >= _numGlobalScripts)
  			break;
! 		unlock(rtScript,res);
  		break;
  	case 113:/* unlock sound */
! 		res = pop();
! 		unlock(rtSound,res);
  		break;
  	case 114:/* unlock costume */
! 		res = pop();
! 		unlock(rtCostume,res);
  		break;
  	case 115:/* unlock room */
! 		res = pop();
! 		if (res > 0x7F)
! 			res = _resourceMapper[res&0x7F];
! 		unlock(rtRoom,res);
  		break;
  	case 116:/* clear heap */
--- 1544,1628 ----
  
  void Scumm::o6_resourceRoutines() {
! 	int resid;
  
  	switch(fetchScriptByte()) {
  	case 100: /* load script */
! 		resid = pop();
  		if(_features & GF_AFTER_V7)
! 			if (resid >= _numGlobalScripts)
  				break;
! 		ensureResourceLoaded(rtScript, resid);
  		break;
  	case 101: /* load sound */
! 		resid = pop();
! 		ensureResourceLoaded(rtSound, resid);
  		break;
  	case 102: /* load costume */
! 		resid = pop();
! 		ensureResourceLoaded(rtCostume, resid);
  		break;
  	case 103: /* load room */
! 		resid = pop();
! 		ensureResourceLoaded(rtRoom, resid);
  		break;
  	case 104: /* nuke script */
! 		resid = pop();
  		if(_features & GF_AFTER_V7)
! 			if (resid >= _numGlobalScripts)
  				break;
! 		setResourceCounter(rtScript, resid, 0x7F);
! 		debug(5, "nuke script %d", resid);
  		break;
  	case 105: /* nuke sound */
! 		resid = pop();
! 		setResourceCounter(rtSound, resid, 0x7F);
  		break;
  	case 106: /* nuke costume */
! 		resid = pop();
! 		setResourceCounter(rtCostume, resid, 0x7F);
  		break;
  	case 107: /* nuke room */
! 		resid = pop();
! 		setResourceCounter(rtRoom, resid, 0x7F);
  		break;
  	case 108:  /* lock script */
! 		resid = pop();
! 		if (resid >= _numGlobalScripts)
  			break;
! 		lock(rtScript,resid);
  		break;
  	case 109:/* lock sound */
! 		resid = pop();
! 		lock(rtSound,resid);
  		break;
  	case 110:/* lock costume */
! 		resid = pop();
! 		lock(rtCostume,resid);
  		break;
  	case 111:/* lock room */
! 		resid = pop();
! 		if (resid > 0x7F)
! 			resid = _resourceMapper[resid&0x7F];
! 		lock(rtRoom,resid);
  		break;
  	case 112:/* unlock script */
! 		resid = pop();
! 		if (resid >= _numGlobalScripts)
  			break;
! 		unlock(rtScript,resid);
  		break;
  	case 113:/* unlock sound */
! 		resid = pop();
! 		unlock(rtSound,resid);
  		break;
  	case 114:/* unlock costume */
! 		resid = pop();
! 		unlock(rtCostume,resid);
  		break;
  	case 115:/* unlock room */
! 		resid = pop();
! 		if (resid > 0x7F)
! 			resid = _resourceMapper[resid&0x7F];
! 		unlock(rtRoom,resid);
  		break;
  	case 116:/* clear heap */
***************
*** 1631,1641 ****
  		break;
  	case 117:/* load charset */
! 		res = pop();
! 		loadCharset(res);
  		break;
  	case 118:/* nuke charset */
  		warning("popping extra argument in nukeCharset");
! 		res = pop();
! 		nukeCharset(res);
  		break;
  	case 119: {/* load fl object */
--- 1631,1641 ----
  		break;
  	case 117:/* load charset */
! 		resid = pop();
! 		loadCharset(resid);
  		break;
  	case 118:/* nuke charset */
  		warning("popping extra argument in nukeCharset");
! 		resid = pop();
! 		nukeCharset(resid);
  		break;
  	case 119: {/* load fl object */

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scummvm.cpp,v
retrieving revision 1.66
retrieving revision 1.67
diff -C2 -d -r1.66 -r1.67
*** scummvm.cpp	8 Mar 2002 08:27:45 -0000	1.66
--- scummvm.cpp	8 Mar 2002 08:42:11 -0000	1.67
***************
*** 944,948 ****
  }
  
! void Scumm::dumpResource(char *tag, int index, byte *ptr) {
  	char buf[256];
  	FILE *out;
--- 944,948 ----
  }
  
! void Scumm::dumpResource(char *tag, int idx, byte *ptr) {
  	char buf[256];
  	FILE *out;
***************
*** 954,958 ****
                  size = READ_BE_UINT32_UNALIGNED(ptr+4);
  
! 	sprintf(buf, "dumps/%s%d.dmp", tag,index);
  
  	out = fopen(buf,"rb");
--- 954,958 ----
                  size = READ_BE_UINT32_UNALIGNED(ptr+4);
  
! 	sprintf(buf, "dumps/%s%d.dmp", tag,idx);
  
  	out = fopen(buf,"rb");





More information about the Scummvm-git-logs mailing list