[Scummvm-cvs-logs] CVS: scummvm/scumm floodfill_he.cpp,2.4,2.5 resource.cpp,1.357,1.358 script_v100he.cpp,2.189,2.190 script_v7he.cpp,2.178,2.179 scumm.h,1.674,1.675 wiz_he.cpp,2.108,2.109 wiz_he.h,2.37,2.38

kirben kirben at users.sourceforge.net
Thu Jan 26 16:29:01 CET 2006


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22175/scumm

Modified Files:
	floodfill_he.cpp resource.cpp script_v100he.cpp 
	script_v7he.cpp scumm.h wiz_he.cpp wiz_he.h 
Log Message:

Make resource management of modified wizImages closer to original games.
Fixes many errors in Backyard Sports titles.


Index: floodfill_he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/floodfill_he.cpp,v
retrieving revision 2.4
retrieving revision 2.5
diff -u -d -r2.4 -r2.5
--- floodfill_he.cpp	18 Jan 2006 17:39:40 -0000	2.4
+++ floodfill_he.cpp	27 Jan 2006 00:27:57 -0000	2.5
@@ -22,9 +22,10 @@
 
 #include "common/stdafx.h"
 
+#include "scumm/floodfill_he.h"
 #include "scumm/intern.h"
+#include "scumm/resource.h"
 #include "scumm/scumm.h"
-#include "scumm/floodfill_he.h"
 
 namespace Scumm {
 	
@@ -285,6 +286,7 @@
 			}
 		}
 	}
+	_vm->res.setModified(rtImage, params->img.resNum);
 }
 
 } // End of namespace Scumm

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.357
retrieving revision 1.358
diff -u -d -r1.357 -r1.358
--- resource.cpp	21 Jan 2006 13:01:19 -0000	1.357
+++ resource.cpp	27 Jan 2006 00:27:57 -0000	1.358
@@ -40,7 +40,9 @@
 enum {
 	RF_LOCK = 0x80,
 	RF_USAGE = 0x7F,
-	RF_USAGE_MAX = RF_USAGE
+	RF_USAGE_MAX = RF_USAGE,
+
+	RS_MODIFIED = 0x10
 };
 
 
@@ -623,6 +625,7 @@
 	res.name[id] = name;
 	res.address[id] = (byte **)calloc(num, sizeof(void *));
 	res.flags[id] = (byte *)calloc(num, sizeof(byte));
+	res.status[id] = (byte *)calloc(num, sizeof(byte));
 
 	if (mode) {
 		res.roomno[id] = (byte *)calloc(num, sizeof(byte));
@@ -1000,6 +1003,8 @@
 		return _sound->isSoundInUse(i);
 	case rtCharset:
 		return _charset->getCurID() == i;
+	case rtImage:
+		return res.isModified(type, i) != 0;
 	case rtSpoolBuffer:
 		return _sound->isSoundRunning(10000 + i) != 0;
 	default:
@@ -1007,6 +1012,24 @@
 	}
 }
 
+void ResourceManager::setModified(int type, int i) {
+	if (!validateResource("Modified", type, i))
+		return;
+	status[type][i] |= RS_MODIFIED;
+}
+
+void ResourceManager::setUnModified(int type, int i) {
+	if (!validateResource("Modified", type, i))
+		return;
+	status[type][i] &= ~RS_MODIFIED;
+}
+
+bool ResourceManager::isModified(int type, int i) const {
+	if (!validateResource("isModified", type, i))
+		return false;
+	return (status[type][i] & RS_MODIFIED) != 0;
+}
+
 void ResourceManager::expireResources(uint32 size) {
 	int i, j;
 	byte flag;
@@ -1059,6 +1082,7 @@
 		}
 		free(address[i]);
 		free(flags[i]);
+		free(status[i]);
 		free(roomno[i]);
 		free(roomoffs[i]);
 

Index: script_v100he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v100he.cpp,v
retrieving revision 2.189
retrieving revision 2.190
diff -u -d -r2.189 -r2.190
--- script_v100he.cpp	18 Jan 2006 17:39:46 -0000	2.189
+++ script_v100he.cpp	27 Jan 2006 00:27:57 -0000	2.190
@@ -1119,10 +1119,12 @@
 		}
 		break;
 	case 133:
-		if (_heResType == rtCharset)
+		if (_heResType == rtCharset) {
 			nukeCharset(_heResId);
-		else
+		} else {
+			res.setUnModified(_heResType, _heResId);
 			res.nukeResource(_heResType, _heResId);
+		}
 		break;
 	case 134:
 	case 135:

Index: script_v7he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v7he.cpp,v
retrieving revision 2.178
retrieving revision 2.179
diff -u -d -r2.178 -r2.179
--- script_v7he.cpp	18 Jan 2006 17:39:47 -0000	2.178
+++ script_v7he.cpp	27 Jan 2006 00:27:57 -0000	2.179
@@ -631,6 +631,7 @@
 		break;
 	case 192:
 		resid = pop();
+		res.setUnModified(rtImage, resid);
 		res.nukeResource(rtImage, resid);
 		break;
 	case 201:

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.674
retrieving revision 1.675
diff -u -d -r1.674 -r1.675
--- scumm.h	25 Jan 2006 15:06:42 -0000	1.674
+++ scumm.h	27 Jan 2006 00:27:57 -0000	1.675
@@ -327,6 +327,7 @@
 	byte **address[rtNumTypes];
 protected:
 	byte *flags[rtNumTypes];
+	byte *status[rtNumTypes];
 public:
 	byte *roomno[rtNumTypes];
 	uint32 *roomoffs[rtNumTypes];
@@ -350,6 +351,10 @@
 	void unlock(int type, int i);
 	bool isLocked(int type, int i) const;
 
+	void setModified(int type, int i);
+	void setUnModified(int type, int i);
+	bool isModified(int type, int i) const;
+
 	void setResourceCounter(int type, int index, byte flag);
 	void increaseResourceCounter();
 

Index: wiz_he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.cpp,v
retrieving revision 2.108
retrieving revision 2.109
diff -u -d -r2.108 -r2.109
--- wiz_he.cpp	18 Jan 2006 17:39:47 -0000	2.108
+++ wiz_he.cpp	27 Jan 2006 00:27:57 -0000	2.109
@@ -918,6 +918,7 @@
 			break;
 		}
 	}
+	_vm->res.setModified(rtImage, resNum);
 }
 
 void Wiz::getWizImageDim(int resNum, int state, int32 &w, int32 &h) {
@@ -1441,18 +1442,7 @@
 		dstResNum = params->dstResNum;
 	}
 	if (params->processFlags & kWPFRemapPalette) {
-		int st = (params->processFlags & kWPFNewState) ? params->img.state : 0;
-		int num = params->remapNum;
-		const uint8 *index = params->remapIndex;
-		uint8 *iwiz = _vm->getResourceAddress(rtImage, params->img.resNum);
-		assert(iwiz);
-		uint8 *rmap = _vm->findWrappedBlock(MKID('RMAP'), iwiz, st, 0) ;
-		assert(rmap);
-		WRITE_BE_UINT32(rmap, 0x01234567);
-		while (num--) {
-			uint8 idx = *index++;
-			rmap[4 + idx] = params->remapColor[idx];
-		}
+		remapWizImagePal(params);
 		flags |= kWIFRemapPalette;
 	}
 
@@ -1556,6 +1546,7 @@
 		WRITE_BE_UINT32(res_data, 'WIZD'); res_data += 4;
 		WRITE_BE_UINT32(res_data, 8 + img_w * img_h); res_data += 4;
 	}
+	_vm->res.setModified(rtImage, params->img.resNum);
 }
 
 void Wiz::fillWizRect(const WizParameters *params) {
@@ -1600,6 +1591,7 @@
 			}
 		}
 	}
+	_vm->res.setModified(rtImage, params->img.resNum);
 }
 
 void Wiz::fillWizLine(const WizParameters *params) {
@@ -1691,6 +1683,7 @@
 			}
 		}
 	}
+	_vm->res.setModified(rtImage, params->img.resNum);
 }
 
 void Wiz::fillWizPixel(const WizParameters *params) {
@@ -1727,6 +1720,23 @@
 			}
 		}
 	}
+	_vm->res.setModified(rtImage, params->img.resNum);
+}
+
+void Wiz::remapWizImagePal(const WizParameters *params) {
+	int st = (params->processFlags & kWPFNewState) ? params->img.state : 0;
+	int num = params->remapNum;
+	const uint8 *index = params->remapIndex;
+	uint8 *iwiz = _vm->getResourceAddress(rtImage, params->img.resNum);
+	assert(iwiz);
+	uint8 *rmap = _vm->findWrappedBlock(MKID('RMAP'), iwiz, st, 0) ;
+	assert(rmap);
+	WRITE_BE_UINT32(rmap, 0x01234567);
+	while (num--) {
+		uint8 idx = *index++;
+		rmap[4 + idx] = params->remapColor[idx];
+	}
+	_vm->res.setModified(rtImage, params->img.resNum);
 }
 
 void Wiz::processWizImage(const WizParameters *params) {
@@ -1767,7 +1777,7 @@
 						_vm->VAR(_vm->VAR_GAME_LOADED) = -2;
 						_vm->VAR(119) = -2;
 					} else {
-						_vm->res.lock(rtImage, params->img.resNum);
+						_vm->res.setModified(rtImage, params->img.resNum);
 						_vm->VAR(_vm->VAR_GAME_LOADED) = 0;
 						_vm->VAR(119) = 0;
 					}
@@ -1824,24 +1834,14 @@
 		break;
 	case 6:
 		if (params->processFlags & kWPFRemapPalette) {
-			int state = (params->processFlags & kWPFNewState) ? params->img.state : 0;
-			int num = params->remapNum;
-			const uint8 *index = params->remapIndex;
-			uint8 *iwiz = _vm->getResourceAddress(rtImage, params->img.resNum);
-			assert(iwiz);
-			uint8 *rmap = _vm->findWrappedBlock(MKID('RMAP'), iwiz, state, 0) ;
-			assert(rmap);
-			WRITE_BE_UINT32(rmap, 0x01234567);
-			while (num--) {
-				uint8 idx = *index++;
-				rmap[4 + idx] = params->remapColor[idx];
-			}
+			remapWizImagePal(params);
 		}
 		break;
 	// HE 99+
 	case 7:
 		// Used in PuttsFunShop/SamsFunShop/soccer2004
 		// TODO: Capture polygon
+		_vm->res.setModified(rtImage, params->img.resNum);
 		break;
 	case 8:
 		createWizEmptyImage(params);
@@ -1877,6 +1877,7 @@
 	case 17:
 		// Used in to draw circles in FreddisFunShop/PuttsFunShop/SamsFunShop
 		// TODO: Ellipse
+		_vm->res.setModified(rtImage, params->img.resNum);
 		break;
 	default:
 		error("Unhandled processWizImage mode %d", params->processMode);

Index: wiz_he.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.h,v
retrieving revision 2.37
retrieving revision 2.38
diff -u -d -r2.37 -r2.38
--- wiz_he.h	18 Jan 2006 17:39:47 -0000	2.37
+++ wiz_he.h	27 Jan 2006 00:27:57 -0000	2.38
@@ -166,6 +166,7 @@
 	void fillWizLine(const WizParameters *params);
 	void fillWizPixel(const WizParameters *params);
 	void fillWizFlood(const WizParameters *params);
+	void remapWizImagePal(const WizParameters *params);
 
 	void getWizImageDim(int resNum, int state, int32 &w, int32 &h);
 	int getWizImageStates(int resnum);





More information about the Scummvm-git-logs mailing list