[Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.287,1.288 actor.h,1.64,1.65 akos.cpp,1.173,1.174 gfx.cpp,2.304,2.305 gfx.h,1.68,1.69 palette.cpp,2.16,2.17 script_v7he.cpp,2.93,2.94 scumm.cpp,1.207,1.208 scumm.h,1.481,1.482

Gregory Montoir cyx at users.sourceforge.net
Fri Sep 17 17:37:23 CEST 2004


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

Modified Files:
	actor.cpp actor.h akos.cpp gfx.cpp gfx.h palette.cpp 
	script_v7he.cpp scumm.cpp scumm.h 
Log Message:
preliminar AuxQueue support (freddemo intro), some glitches though

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.287
retrieving revision 1.288
diff -u -d -r1.287 -r1.288
--- actor.cpp	12 Sep 2004 02:05:12 -0000	1.287
+++ actor.cpp	18 Sep 2004 00:36:14 -0000	1.288
@@ -137,6 +137,8 @@
 
 	clipOverride = _vm->_actorClipOverride;
 
+	auxBlock.visible = false;
+
 	_vm->_classData[number] = (_vm->_version >= 7) ? _vm->_classData[0] : 0;
 }
 
@@ -492,8 +494,10 @@
 			// Causes Zak to lose his body in several scenes, see bug #771508
 			if (_vm->_version >= 3 && f == initFrame)
 				cost.reset();
-			if (_vm->_features & GF_NEW_COSTUMES)
+			if (_vm->_features & GF_NEW_COSTUMES) {
+				auxBlock.visible = false;
 				_vm->akos_decodeData(this, f, (uint) - 1);
+			}
 			else
 				_vm->cost_decodeData(this, f, (uint) - 1);
 			frame = f;
@@ -602,6 +606,12 @@
 			}
 			adjustActorPos();
 		} else {
+			if (_vm->_heversion >= 72) {
+				if (auxBlock.visible) {
+					_vm->queueAuxBlock(this);
+					auxBlock.visible = false;
+				}
+			}
 			hideActor();
 		}
 	} else {
@@ -1356,6 +1366,12 @@
 		memset(animVariable, 0, sizeof(animVariable));
 		costume = c;
 		
+		if (_vm->_heversion >= 72) {
+			if (auxBlock.visible) {
+				_vm->queueAuxBlock(this);
+			}
+		}
+		
 		if (visible) {
 			if (costume) {
 				_vm->ensureResourceLoaded(rtCostume, costume);
@@ -1869,6 +1885,101 @@
 	return condMask & (1 << (slot - 1));
 }
 
+void ScummEngine::preProcessAuxQueue() {
+	if (!_skipProcessActors) {
+		for (int i = 0; i < _auxBlocksNum; ++i) {
+			AuxBlock *ab = &_auxBlocks[i];
+			assert(ab->r.top <= ab->r.bottom);
+			if (ab->visible) {
+				gdi.copyVirtScreenBuffers(ab->r);
+			}
+		}
+	}
+	_auxBlocksNum = 0;
+}
+
+void ScummEngine::postProcessAuxQueue() {
+	if (!_skipProcessActors) {
+		for (int i = 0; i < _auxEntriesNum; ++i) {
+			AuxEntry *ae = &_auxEntries[i];
+			if (ae->actorNum != -1) {
+				Actor *a = derefActor(ae->actorNum, "postProcessAuxQueue");
+				const uint8 *cost = getResourceAddress(rtCostume, a->costume);
+				
+				int dy = a->offs_y + a->_pos.y - a->getElevation();
+				int dx = a->offs_x + a->_pos.x;
+
+				const uint8 *akax = findResource(MKID('AKAX'), cost);
+				if (!akax) {
+					error("No AKAX block for actor %d", ae->actorNum);
+				}
+				const uint8 *auxd = findPalInPals(akax, ae->subIndex) - _resourceHeaderSize;
+				if (!auxd) {
+					error("No AUXD block for actor %d", ae->actorNum);
+				}
+				const uint8 *axfd = findResourceData(MKID('AXFD'), auxd);
+				if (!axfd) {
+					error("No AXFD block for actor %d", ae->actorNum);
+				} else {
+					uint16 comp = READ_LE_UINT16(axfd);
+					if (comp == 1 || comp == 16) {
+						int x1 = (int16)READ_LE_UINT16(axfd + 2) + dx;
+						int y1 = (int16)READ_LE_UINT16(axfd + 4) + dy;
+						int x2 = (int16)READ_LE_UINT16(axfd + 6);
+						int y2 = (int16)READ_LE_UINT16(axfd + 8);
+						VirtScreen *pvs = &virtscr[kMainVirtScreen];
+						uint8 *dst1 = pvs->getPixels(0, 0);
+						uint8 *dst2 = pvs->getBackPixels(0, 0);
+						switch (comp) {
+						case 1:
+							gdi.copyAuxImage(dst1, dst2, axfd + 10, pvs->w, pvs->h, x1, y1, x2, y2, 0);
+							break;
+						default:
+							warning("unimplemented compression type %d", comp);
+							break;
+						}
+					}
+				}
+				const uint8 *axur = findResourceData(MKID('AXUR'), auxd);
+				if (axur) {
+					uint16 n = READ_LE_UINT16(axur); axur += 2;
+					while (n--) {
+						int x = (int16)READ_LE_UINT16(axur + 0) + dx;
+						int y = (int16)READ_LE_UINT16(axur + 2) + dy;
+						int w = (int16)READ_LE_UINT16(axur + 4) + dx;
+						int h = (int16)READ_LE_UINT16(axur + 6) + dy;
+						markRectAsDirty(kMainVirtScreen, x, w, y, h);
+						axur += 8;
+					}
+				}
+				const uint8 *axer = findResourceData(MKID('AXER'), auxd);
+				if (axer) {
+					a->auxBlock.visible  = true;
+					a->auxBlock.r.left   = (int16)READ_LE_UINT16(axer + 0) + dx;
+					a->auxBlock.r.top    = (int16)READ_LE_UINT16(axer + 2) + dy;
+					a->auxBlock.r.right  = (int16)READ_LE_UINT16(axer + 4) + dx;
+					a->auxBlock.r.bottom = (int16)READ_LE_UINT16(axer + 6) + dy;
+				}
+			}
+		}
+	}
+	_auxEntriesNum = 0;
+}
+
+void ScummEngine::queueAuxBlock(Actor *a) {
+	assert(_auxBlocksNum < ARRAYSIZE(_auxBlocks));
+	_auxBlocks[_auxBlocksNum] = a->auxBlock;
+	++_auxBlocksNum;
+}
+
+void ScummEngine::queueAuxEntry(int actorNum, int subIndex) {
+	assert(_auxEntriesNum < ARRAYSIZE(_auxEntries));
+	AuxEntry *ae = &_auxEntries[_auxEntriesNum];
+	ae->actorNum = actorNum;
+	ae->subIndex = subIndex;
+	++_auxEntriesNum;
+}
+
 
 const SaveLoadEntry *Actor::getSaveLoadEntries() {
 	static const SaveLoadEntry actorEntries[] = {

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.h,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- actor.h	11 Sep 2004 12:22:06 -0000	1.64
+++ actor.h	18 Sep 2004 00:36:14 -0000	1.65
@@ -125,6 +125,7 @@
 	CostumeData cost;
 	uint32 condMask;
 	bool talkUnk;
+	AuxBlock auxBlock;
 protected:
 	byte palette[256];
 	int elevation;

Index: akos.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/akos.cpp,v
retrieving revision 1.173
retrieving revision 1.174
diff -u -d -r1.173 -r1.174
--- akos.cpp	15 Sep 2004 23:47:54 -0000	1.173
+++ akos.cpp	18 Sep 2004 00:36:14 -0000	1.174
@@ -1245,7 +1245,7 @@
 	if (_draw_bottom < dst.bottom)
 		_draw_bottom = dst.bottom;
 
-	_vm->gdi.decompressImageHE(_outptr, _outwidth, &dst, _srcptr, &src);
+	_vm->gdi.decompressWizImage(_outptr, _outwidth, &dst, _srcptr, &src);
 	return 0;
 }
 
@@ -1381,7 +1381,7 @@
 				curpos += aksq[curpos + 2];
 				break;
 			case AKC_C08E:
-				//akos_queCommand(7, a, GB(2), 0);
+				akos_queCommand(7, a, GW(2), 0);
 				curpos += 4;
 				break;
 			default:
@@ -1674,7 +1674,9 @@
 			a->offs_y = param_2;
 			break;
 		case 7:
-			if (param_1 != 0) {
+			if (_heversion >= 72) {
+				queueAuxEntry(a->number, param_1);
+			} else if (param_1 != 0) {
 				if (_imuseDigital) {
 					_imuseDigital->setVolume(param_1, param_2);
 				}

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.304
retrieving revision 2.305
diff -u -d -r2.304 -r2.305
--- gfx.cpp	12 Sep 2004 14:18:44 -0000	2.304
+++ gfx.cpp	18 Sep 2004 00:36:15 -0000	2.305
@@ -1481,11 +1481,11 @@
 		r2.bottom -= diff;
 	}
 	if (r1.isValidRect() && r2.isValidRect()) {
-		decompressImageHE(dst, dst_w, &r2, src, &r1);
+		decompressWizImage(dst, dst_w, &r2, src, &r1);
 	}
 }
 
-void Gdi::decompressImageHE(uint8 *dst, int dstWidth, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect) {
+void Gdi::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect) {
 	const uint8 *dataPtr, *dataPtrNext;
 	uint8 *dstPtr, *dstPtrNext;
 	uint32 code;
@@ -1493,7 +1493,7 @@
 	int h, w, xoff;
 	uint16 off;
 	
-	dstPtr = dst + dstRect->left + dstRect->top * dstWidth;
+	dstPtr = dst + dstRect->left + dstRect->top * dstPitch;
 	dataPtr = src;
 	h = srcRect->top;
 	while (h--) {
@@ -1513,7 +1513,7 @@
 		xoff = srcRect->left;
 		off = READ_LE_UINT16(dataPtr);
 		w = srcRect->right - srcRect->left + 1;
-		dstPtrNext = dstWidth + dstPtr;
+		dstPtrNext = dstPitch + dstPtr;
 		dataPtrNext = off + 2 + dataPtr;
 		dataPtr += 2;	
 		if (off == 0) goto dec_next;
@@ -1589,6 +1589,141 @@
 	}
 }
 
+void Gdi::copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, Common::Rect *rect) {
+	Common::Rect r1(0, 0, srcw - 1, srch - 1);
+	Common::Rect r2(srcx, srcy, srcx + srcw - 1, srcy + srch - 1);
+	Common::Rect r3;
+	int diff;
+
+	if (rect) {
+		r3 = *rect;
+		Common::Rect r4(0, 0, dstw - 1, dsth - 1);
+		if (!r3.intersects(r4)) {
+			return;
+		}
+	} else {
+		r3 = Common::Rect(0, 0, dstw - 1, dsth - 1);
+	}
+	diff = r2.left - r3.left;
+	if (diff < 0) {
+		r1.left -= diff;
+		r2.left -= diff;
+	}
+	diff = r2.right - r3.right;
+	if (diff > 0) {
+		r1.right -= diff;
+		r2.right -= diff;
+	}
+	diff = r2.top - r3.top;
+	if (diff < 0) {
+		r1.top -= diff;
+		r2.top -= diff;
+	}
+	diff = r2.bottom - r3.bottom;
+	if (diff > 0) {
+		r1.bottom -= diff;
+		r2.bottom -= diff;
+	}
+	if (r1.isValidRect() && r2.isValidRect()) {
+		decompressAuxImage(dst1, dst2, dstw, &r2, src, &r1);
+	}
+}
+
+void Gdi::decompressAuxImage(uint8 *dst1, uint8 *dst2, int dstPitch, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect) {
+  	uint8 *dstCur2, *dstCur1;
+  	const uint8 *srcCur;
+  	uint8 code;
+  
+  	int w = srcRect->right - srcRect->left + 1;
+  	int h = srcRect->bottom - srcRect->top + 1;
+  	int off = dstRect->top * dstPitch + dstRect->left;
+
+  	dst1 += off;
+  	dst2 += off;
+
+  	int n = srcRect->top;
+  	while (n--) {
+		src += READ_LE_UINT16(src) + 2;
+  	}
+
+  	while (h--) {
+  		uint16 var_8 = READ_LE_UINT16(src);
+  		if (var_8) {
+  			int rw = w;
+  			int xoff = srcRect->left;
+  			srcCur = src + 2;
+  			dstCur1 = dst1;
+  			dstCur2 = dst2;
+  			while (xoff > 0) {
+				code = *srcCur++;
+				if (code & 1) {
+					code >>= 1;
+					if (code > xoff) {
+						code -= xoff;
+						goto dec_sub1;
+					}
+					xoff -= code;
+				} else if (code & 2) {
+					code = (code >> 2) + 1;
+					if (code > xoff) {
+						code -= xoff;
+						goto dec_sub2;
+					}
+					xoff -= code;
+					++srcCur;
+				} else {
+					code = (code >> 2) + 1;
+					if (code > xoff) {
+						code -= xoff;
+						srcCur += xoff;
+						goto dec_sub3;
+					}
+					xoff -= code;
+					srcCur += code;
+				}
+  			}
+			while (rw > 0) {
+				code = *srcCur++;
+				if (code & 1) {
+					code >>= 1;
+dec_sub1:			dstCur1 += code;
+					dstCur2 += code;
+					rw -= code;					
+				} else if (code & 2) {
+					code = (code >> 2) + 1;
+dec_sub2:			rw -= code;
+					if (rw >= 0) {
+						memset(dstCur1, *srcCur++, code);
+						dstCur1 += code;
+						dstCur2 += code;
+					} else {
+						code += rw;
+						memset(dstCur1, *srcCur, code);
+					}
+				} else {
+					code = (code >> 2) + 1;
+dec_sub3:			rw -= code;
+					if (rw >= 0) {
+						memcpy(dstCur1, dstCur2, code);
+						dstCur1 += code;
+						dstCur2 += code;
+					} else {
+						code += rw;
+						memcpy(dstCur1, dstCur2, code);
+					}								
+				}
+			}
+			src += var_8 + 2;
+			dst1 += dstPitch;
+			dst2 += dstPitch;
+		} else {
+			src += 2;
+			dst1 += dstPitch;
+			dst2 += dstPitch;
+		}
+	}
+}
+
 void Gdi::copyVirtScreenBuffers(Common::Rect rect) {
 	int rw = rect.right - rect.left + 1;
 	int rh = rect.bottom - rect.top + 1;

Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- gfx.h	5 Sep 2004 17:39:52 -0000	1.68
+++ gfx.h	18 Sep 2004 00:36:16 -0000	1.69
@@ -275,8 +275,10 @@
 	StripTable *generateStripTable(const byte *src, int width, int height, StripTable *table);
 	void drawBMAPBg(const byte *ptr, VirtScreen *vs, int startstrip, int width);
 	void drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, int w, int h);
-	void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, Common::Rect *pr);
-	void decompressImageHE(uint8 *dst, int dstWidth, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect);
+	void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, Common::Rect *rect);
+	void decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect);
+	void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, Common::Rect *rect);
+	void decompressAuxImage(uint8 *dst1, uint8 *dst2, int dstPitch, const Common::Rect *dstRect, const uint8 *src, const Common::Rect *srcRect);
 	void copyVirtScreenBuffers(Common::Rect rect);
 
 	void disableZBuffer() { _zbufferDisabled = true; }

Index: palette.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/palette.cpp,v
retrieving revision 2.16
retrieving revision 2.17
diff -u -d -r2.16 -r2.17
--- palette.cpp	3 Sep 2004 17:27:40 -0000	2.16
+++ palette.cpp	18 Sep 2004 00:36:16 -0000	2.17
@@ -785,7 +785,6 @@
 		return NULL;
 
 	size = getResourceDataSize(offs) / 4;
-
 	if ((uint32)idx >= (uint32)size)
 		return NULL;
 

Index: script_v7he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v7he.cpp,v
retrieving revision 2.93
retrieving revision 2.94
diff -u -d -r2.93 -r2.94
--- script_v7he.cpp	17 Sep 2004 03:18:00 -0000	2.93
+++ script_v7he.cpp	18 Sep 2004 00:36:16 -0000	2.94
@@ -745,8 +745,9 @@
 		// Fatty Bear's Birthday Surprise
 		virtScreenLoad(args[1], args[2], args[3], args[4], args[5]);
 		break;
-	case 20:
-		// erase aux animation actor?
+	case 20: // HE72+
+		a = derefActor(args[1], "o7_kernelSetFunctions: 20");
+		queueAuxBlock(a);
 		break;
 	case 21:
 		_skipDrawObject = 1;
@@ -759,19 +760,11 @@
 		_fullRedraw = 1;
 		break;
 	case 24:
-		if (_heversion <= 72) {
-			_skipProcessActors = 1;
-		} else {
-			//Pause aux animation
-		}
+		_skipProcessActors = 1;
 		_fullRedraw = 1;
 		break;
 	case 25:
-		if (_heversion <= 72) {
-			_skipProcessActors = 0;
-		} else {
-			//Resume aux animation
-		}
+		_skipProcessActors = 0;
 		_fullRedraw = 1;
 		break;
 	case 30:

Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.207
retrieving revision 1.208
diff -u -d -r1.207 -r1.208
--- scumm.cpp	17 Sep 2004 05:43:37 -0000	1.207
+++ scumm.cpp	18 Sep 2004 00:36:16 -0000	1.208
@@ -691,6 +691,10 @@
 
 	_skipDrawObject = 0;
 	_skipProcessActors = 0;
+	_auxBlocksNum = 0;
+	memset(_auxBlocks, 0, sizeof(_auxBlocks));
+	_auxEntriesNum = 0;
+	memset(_auxEntries, 0, sizeof(_auxEntries));
 	_heSndSoundId = 0;
 	_heSndOffset = 0;
 	_heSndChannel = 0;
@@ -1820,8 +1824,14 @@
 			drawFlashlight();
 			setActorRedrawFlags();
 		}
-
-		processActors();
+		if (_heversion >= 72) {
+			preProcessAuxQueue();
+			processActors();
+			postProcessAuxQueue();
+		} else {
+			processActors();
+		}
+		
 		_fullRedraw = false;
 		if (_version >= 4 && _heversion <= 60)
 			cyclePalette();
@@ -2329,9 +2339,8 @@
 		stopCycle(0);
 	_sound->processSoundQues();
 
-	if (_heversion >= 70 && _WizPolygons) {
-		for (i = 0; i < _WizNumPolygons; i++)
-			memset(&_WizPolygons[i], 0, sizeof(WizPolygon));
+	if (_heversion >= 70 && _WizPolygons) {		
+		memset(_WizPolygons, 0, _WizNumPolygons * sizeof(WizPolygon));
 	}
 
 	for (i = 0; i < _numRoomVariables; i++)

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.481
retrieving revision 1.482
diff -u -d -r1.481 -r1.482
--- scumm.h	17 Sep 2004 05:43:37 -0000	1.481
+++ scumm.h	18 Sep 2004 00:36:17 -0000	1.482
@@ -329,6 +329,16 @@
 	bool flag;
 };
 
+struct AuxBlock {
+	bool visible;
+	Common::Rect r;
+};
+	
+struct AuxEntry {
+	int actorNum;
+	int subIndex;
+};
+
 class ScummEngine : public Engine {
 	friend class ScummDebugger;
 	friend class SmushPlayer;
@@ -839,6 +849,18 @@
 	bool isCostumeInUse(int i) const;
 
 public:
+	/* Actor AuxQueue stuff (HE) */	
+	AuxBlock _auxBlocks[16];
+	uint16 _auxBlocksNum;
+	AuxEntry _auxEntries[16];
+	uint16 _auxEntriesNum;
+
+	void preProcessAuxQueue();
+	void postProcessAuxQueue();
+	void queueAuxBlock(Actor *a);
+	void queueAuxEntry(int actorNum, int subIndex);
+
+public:
 	/* Actor talking stuff */
 	byte _actorToPrintStrFor, _V1_talkingActor;
 	int _sentenceNum;





More information about the Scummvm-git-logs mailing list