[Scummvm-cvs-logs] CVS: scummvm actor.cpp,1.17,1.18 gfx.cpp,1.23,1.24 resource.cpp,1.26,1.27 saveload.cpp,1.19,1.20 script.cpp,1.15,1.16 scumm.h,1.34,1.35 sdl.cpp,1.25,1.26 windows.cpp,1.21,1.22

Ludvig Strigeus strigeus at users.sourceforge.net
Tue Dec 11 05:35:04 CET 2001


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

Modified Files:
	actor.cpp gfx.cpp resource.cpp saveload.cpp script.cpp scumm.h 
	sdl.cpp windows.cpp 
Log Message:
converted internal representation of palette from 6-bit to 8-bit
yazoo implemented remapActor

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/actor.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** actor.cpp	2001/12/01 17:06:12	1.17
--- actor.cpp	2001/12/11 13:34:15	1.18
***************
*** 1046,1050 ****
  }
  
! 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);
  }
--- 1046,1101 ----
  }
  
! void Scumm::remapActor(Actor *a, int r_fact, int g_fact, int b_fact, int threshold) {
! 	byte *akos, *rgbs,*akpl;
! 	int akpl_size, i;
! 	int r,g,b;
! 	byte akpl_color;
! 
! 	if (a->room != _currentRoom) {
! 		warning("Remap actor %d not in current room",a->number);
! 		return;
! 	}
! 
! 	if (a->costume < 1 || a->costume >= _numCostumes-1){
! 		warning("Remap actor %d invalid costume",a->number,a->costume);
! 		return;
! 	}
! 
! 	akos = getResourceAddress(rtCostume, a->costume);
! 	akpl = findResource(MKID('AKPL'), akos);
! 	
! 	//get num palette entries
! 	akpl_size=RES_SIZE(akpl) - 8;
! 
! 	//skip resource header
! 	akpl = RES_DATA(akpl);
! 	
! 	rgbs = findResource(MKID('RGBS'), akos);
! 
! 	if (!rgbs) {
! 		warning("Can't remap actor %d costume %d doesn't contain an RGB block",a->number,a->costume);
! 		return;
! 	}
! 	// skip resource header
! 	rgbs = RES_DATA(rgbs);
! 	
! 	for(i=0; i<akpl_size; i++) {
! 		r=*rgbs++;
! 		g=*rgbs++;
! 		b=*rgbs++;
! 
! 		akpl_color=*akpl++;
! 
! 		// allow remap of generic palette entry?
! 		if (!a->unk1 || akpl_color>=16) {
! 			if (r_fact!=256) r = (r*r_fact) >> 8;
! 			if (r_fact!=256) g = (g*g_fact) >> 8;
! 			if (r_fact!=256) b = (b*b_fact) >> 8;
! 			a->palette[i]=remapPaletteColor(r,g,b,threshold);
! 		}
! 	}
! }
! 
! void Scumm::setupShadowPalette(int slot,int rfact,int gfact,int bfact,int from,int to) {
! 	warning("stub setupShadowPalette(%d,%d,%d,%d,%d,%d)", slot,rfact,gfact,bfact,from,to);
  }

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gfx.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** gfx.cpp	2001/11/27 17:56:04	1.23
--- gfx.cpp	2001/12/11 13:34:15	1.24
***************
*** 344,350 ****
  		b = *ptr++;
  		if (i<=15 || r<252 || g<252 || b<252) {
! 			*dest++ = r>>2;
! 			*dest++ = g>>2;
! 			*dest++ = b>>2;
  		} else {
  			dest += 3;
--- 344,350 ----
  		b = *ptr++;
  		if (i<=15 || r<252 || g<252 || b<252) {
! 			*dest++ = r;
! 			*dest++ = g;
! 			*dest++ = b;
  		} else {
  			dest += 3;
***************
*** 352,365 ****
  	}
  
- #if 0
- 	if (_videoMode==0xE) {
- 		epal = getResourceAddress(rtRoom, _roomResource) + _EPAL_offs + 8;
- 		for (i=0; i<256; i++,epal++) {
- 			_currentPalette[i] = *epal&0xF;
- 			_currentPalette[i+256] = *epal>>4;
- 		}
- 	}
- #endif
- 
  	setDirtyColors(0, numcolor-1);
  }
--- 352,355 ----
***************
*** 1690,1696 ****
  
  void Scumm::setPalColor(int index, int r, int g, int b) {
! 	_currentPalette[index*3+0] = r>>2;
! 	_currentPalette[index*3+1] = g>>2;
! 	_currentPalette[index*3+2] = b>>2;
  	setDirtyColors(index,index);
  }
--- 1680,1686 ----
  
  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);
  }
***************
*** 1797,1801 ****
  	byte *cptr, *cur;
  	int num;
! 	byte color;
  
  	cptr = getPalettePtr();
--- 1787,1791 ----
  	byte *cptr, *cur;
  	int num;
! 	int color;
  
  	cptr = getPalettePtr();
***************
*** 1806,1831 ****
  
  		do {
! 			if (c != 0xFF) {
! 				color = *cptr++ * (c>>2) / 0xFF;
! 			} else {
! 				color = *cptr++ >> 2;
! 			}
! 			if(color>63) color = 63;
  			*cur++=color;
  
! 			if (d != 0xFF) {
! 				color = *cptr++ * (d>>2) / 0xFF;
! 			} else {
! 				color = *cptr++ >> 2;
! 			}
! 			if(color>63) color = 63;
  			*cur++=color;
  
! 			if (e != 0xFF) {
! 				color = *cptr++ * (e>>2) / 0xFF;
! 			} else {
! 				color = *cptr++ >> 2;
! 			}
! 			if(color>63) color = 63;
  			*cur++=color;
  		} while (--num);
--- 1796,1815 ----
  
  		do {
! 			color = *cptr++;
! 			if (c != 0xFF)
! 				color = color * c / 0xFF;
! 			if(color>255) color = 255;
  			*cur++=color;
  
! 			color = *cptr++;
! 			if (d != 0xFF)
! 				color = color * d / 0xFF;
! 			if(color>255) color = 255;
  			*cur++=color;
  
! 			color = *cptr++;
! 			if (e != 0xFF)
! 				color = color * e / 0xFF;
! 			if(color>255) color = 255;
  			*cur++=color;
  		} while (--num);
***************
*** 1952,1961 ****
  
  
! 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;
  
--- 1936,1949 ----
  
  
! int Scumm::remapPaletteColor(int r, int g, int b, uint threshold) {
  	int i;
! 	int ar,ag,ab;
  	uint sum,j,bestsum,bestitem;
  	byte *pal = _currentPalette;
  
+ 	if (r>255) r=255;
+ 	if (g>255) g=255;
+ 	if (b>255) b=255;
+ 
  	bestsum = (uint)-1;
  
***************
*** 1971,1980 ****
  			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) {
--- 1959,1968 ----
  			return i;
  
! 		j=abs(ar-r);
! 		sum = j*j*3;
! 		j=abs(ag-g);
! 		sum += j*j*6;
! 		j=abs(ab-b);
! 		sum += j*j*2;
  
  		if (sum < bestsum) {
***************
*** 1984,1988 ****
  	}
  
! 	if (threshold != -1 && bestsum > threshold*threshold*(2+3+6)) {
  		pal = _currentPalette + (256-2)*3;
  		for(i=254; i>48; i--,pal-=3) {
--- 1972,1976 ----
  	}
  
! 	if (threshold != (uint)-1 && bestsum > threshold*threshold*(2+3+6)) {
  		pal = _currentPalette + (256-2)*3;
  		for(i=254; i>48; i--,pal-=3) {
***************
*** 1995,2002 ****
  
  	return bestitem;
- }
- 
- void Scumm::setupShadowPalette(int slot,int rfact,int gfact,int bfact,int from,int to) {
- 	
  }
  
--- 1983,1986 ----

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/resource.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** resource.cpp	2001/12/04 10:44:33	1.26
--- resource.cpp	2001/12/11 13:34:15	1.27
***************
*** 538,542 ****
  	setResourceCounter(type, index, 1);
  
! 	return ptr + sizeof(ResHeader);
  }
  
--- 538,542 ----
  	setResourceCounter(type, index, 1);
  
! 	return ptr + sizeof(MemBlkHeader);
  }
  
***************
*** 576,580 ****
  	CHECK_HEAP
  	
! 	ptr = (byte*)alloc(size + sizeof(ResHeader) + SAFETY_AREA);
  	if (ptr==NULL) {
  		error("Out of memory while allocating %d", size);
--- 576,580 ----
  	CHECK_HEAP
  	
! 	ptr = (byte*)alloc(size + sizeof(MemBlkHeader) + SAFETY_AREA);
  	if (ptr==NULL) {
  		error("Out of memory while allocating %d", size);
***************
*** 584,590 ****
  
  	res.address[type][index] = ptr;
! 	((ResHeader*)ptr)->size = size;
  	setResourceCounter(type, index, 1);
! 	return ptr + sizeof(ResHeader); /* skip header */
  }
  
--- 584,590 ----
  
  	res.address[type][index] = ptr;
! 	((MemBlkHeader*)ptr)->size = size;
  	setResourceCounter(type, index, 1);
! 	return ptr + sizeof(MemBlkHeader); /* skip header */
  }
  
***************
*** 607,611 ****
  		res.address[type][index] = 0;
  		res.flags[type][index] = 0;
! 		_allocatedSize -= ((ResHeader*)ptr)->size;
  		free(ptr);
  	}
--- 607,611 ----
  		res.address[type][index] = 0;
  		res.flags[type][index] = 0;
! 		_allocatedSize -= ((MemBlkHeader*)ptr)->size;
  		free(ptr);
  	}
***************
*** 824,828 ****
  			flag = res.flags[i][j];
  			if (flag&0x80 && res.address[i][j]) {
! 				lockedSize += ((ResHeader*)res.address[i][j])->size;
  				lockedNum++;
  			}
--- 824,828 ----
  			flag = res.flags[i][j];
  			if (flag&0x80 && res.address[i][j]) {
! 				lockedSize += ((MemBlkHeader*)res.address[i][j])->size;
  				lockedNum++;
  			}

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saveload.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** saveload.cpp	2001/12/01 17:06:13	1.19
--- saveload.cpp	2001/12/11 13:34:15	1.20
***************
*** 521,528 ****
  		}
  
! 		size = ((ResHeader*)ptr)->size;
  
  		ser->saveUint32(size);
! 		ser->saveLoadBytes(ptr+sizeof(ResHeader),size);
  
  		if (type==rtInventory) {
--- 521,528 ----
  		}
  
! 		size = ((MemBlkHeader*)ptr)->size;
  
  		ser->saveUint32(size);
! 		ser->saveLoadBytes(ptr+sizeof(MemBlkHeader),size);
  
  		if (type==rtInventory) {

Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/script.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** script.cpp	2001/12/04 10:44:33	1.15
--- script.cpp	2001/12/11 13:34:15	1.16
***************
*** 267,271 ****
  
  byte Scumm::fetchScriptByte() {
! 	if (*_lastCodePtr + sizeof(ResHeader) != _scriptOrgPointer) {
  		uint32 oldoffs = _scriptPointer - _scriptOrgPointer;
  		getScriptBaseAddress();
--- 267,271 ----
  
  byte Scumm::fetchScriptByte() {
! 	if (*_lastCodePtr + sizeof(MemBlkHeader) != _scriptOrgPointer) {
  		uint32 oldoffs = _scriptPointer - _scriptOrgPointer;
  		getScriptBaseAddress();
***************
*** 277,281 ****
  int Scumm::fetchScriptWord() {
  	int a;
! 	if (*_lastCodePtr + sizeof(ResHeader) != _scriptOrgPointer) {
  		uint32 oldoffs = _scriptPointer - _scriptOrgPointer;
  		getScriptBaseAddress();
--- 277,281 ----
  int Scumm::fetchScriptWord() {
  	int a;
! 	if (*_lastCodePtr + sizeof(MemBlkHeader) != _scriptOrgPointer) {
  		uint32 oldoffs = _scriptPointer - _scriptOrgPointer;
  		getScriptBaseAddress();

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** scumm.h	2001/12/04 21:44:41	1.34
--- scumm.h	2001/12/11 13:34:15	1.35
***************
*** 50,53 ****
--- 50,58 ----
  };
  
+ struct MemBlkHeader {
+ 	uint32 size;
+ };
+ 
+ 
  #pragma START_PACK_STRUCTS
  	
***************
*** 63,70 ****
  } GCC_PACK;
  
! struct ResHeader {
! 	uint32 size;
  } GCC_PACK;
  
  struct RoomHeader {
  	uint32 tag, size;
--- 68,79 ----
  } GCC_PACK;
  
! struct ResHdr {
! 	uint32 tag, size;
  } GCC_PACK;
  
+ #define RES_DATA(x) (((byte*)x) + sizeof(ResHdr))
+ #define RES_SIZE(x) ( READ_BE_UINT32(&((ResHdr*)x)->size) )
+ 
+ 
  struct RoomHeader {
  	uint32 tag, size;
***************
*** 1961,1965 ****
  	void runTalkScript(int frame);
  
! 	int remapPaletteColor(byte r, byte g, byte b, uint threshold);
  	void remapActor(Actor *a, int b, int c, int d, int e);
  
--- 1970,1974 ----
  	void runTalkScript(int frame);
  
! 	int remapPaletteColor(int r, int g, int b, uint threshold);
  	void remapActor(Actor *a, int b, int c, int d, int e);
  

Index: sdl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sdl.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** sdl.cpp	2001/12/03 22:11:53	1.25
--- sdl.cpp	2001/12/11 13:34:15	1.26
***************
*** 51,57 ****
  	data += first*3;
  	for (i=0; i<num; i++,data+=3) {
! 		colors[i].r = data[0]<<2;
! 		colors[i].g = data[1]<<2;
! 		colors[i].b = data[2]<<2;
  		colors[i].unused = 0;
  	}
--- 51,57 ----
  	data += first*3;
  	for (i=0; i<num; i++,data+=3) {
! 		colors[i].r = data[0];
! 		colors[i].g = data[1];
! 		colors[i].b = data[2];
  		colors[i].unused = 0;
  	}

Index: windows.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/windows.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** windows.cpp	2001/12/01 17:06:13	1.21
--- windows.cpp	2001/12/11 13:34:15	1.22
***************
*** 332,338 ****
  #if 1
  	for (i=0; i<256; i++) {
! 		dib.pal[i].rgbRed = ctab[i*3+0]<<2;
! 		dib.pal[i].rgbGreen = ctab[i*3+1]<<2;
! 		dib.pal[i].rgbBlue = ctab[i*3+2]<<2;
  	}
  #else
--- 332,338 ----
  #if 1
  	for (i=0; i<256; i++) {
! 		dib.pal[i].rgbRed = ctab[i*3+0];
! 		dib.pal[i].rgbGreen = ctab[i*3+1];
! 		dib.pal[i].rgbBlue = ctab[i*3+2];
  	}
  #else





More information about the Scummvm-git-logs mailing list