[Scummvm-cvs-logs] SF.net SVN: scummvm: [22062] scummvm/trunk/engines/simon

kirben at users.sourceforge.net kirben at users.sourceforge.net
Thu Apr 20 17:19:02 CEST 2006


Revision: 22062
Author:   kirben
Date:     2006-04-20 17:18:23 -0700 (Thu, 20 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22062&view=rev

Log Message:
-----------
Add some code for PanEvent in FF and cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/simon/icons.cpp
    scummvm/trunk/engines/simon/items.cpp
    scummvm/trunk/engines/simon/res.cpp
    scummvm/trunk/engines/simon/simon.cpp
    scummvm/trunk/engines/simon/simon.h
    scummvm/trunk/engines/simon/string.cpp
    scummvm/trunk/engines/simon/verb.cpp
    scummvm/trunk/engines/simon/vga.cpp
Modified: scummvm/trunk/engines/simon/icons.cpp
===================================================================
--- scummvm/trunk/engines/simon/icons.cpp	2006-04-20 14:55:27 UTC (rev 22061)
+++ scummvm/trunk/engines/simon/icons.cpp	2006-04-21 00:18:23 UTC (rev 22062)
@@ -491,7 +491,7 @@
 		ha->window = window;
 		ha->verb = 1;
 
-		kill_sprite_simon1(128);
+		stopAnimateSimon1(128);
 		loadSprite(0, 1, 128, 0, 0, 14);
 	}
 }
@@ -575,7 +575,7 @@
 }
 
 void SimonEngine::removeArrows(WindowBlock *window, uint num) {
-	kill_sprite_simon1(128);
+	stopAnimateSimon1(128);
 }
 
 } // End of namespace Simon

Modified: scummvm/trunk/engines/simon/items.cpp
===================================================================
--- scummvm/trunk/engines/simon/items.cpp	2006-04-20 14:55:27 UTC (rev 22061)
+++ scummvm/trunk/engines/simon/items.cpp	2006-04-21 00:18:23 UTC (rev 22062)
@@ -1311,7 +1311,7 @@
 	if (_speech && speechId != 0)
 		playSpeech(speechId, vgaSpriteId);
 	if ((getGameType() == GType_SIMON2) && (getFeatures() & GF_TALKIE) && speechId == 0)
-		kill_sprite_simon2(2, vgaSpriteId + 2);
+		stopAnimateSimon2(2, vgaSpriteId + 2);
 
 	if (string_ptr != NULL && (speechId == 0 || _subtitles))
 		printScreenText(vgaSpriteId, color, (const char *)string_ptr, tl->x, tl->y, tl->width);
@@ -1549,7 +1549,7 @@
 
 void SimonEngine::o1_stopAnimate() {
 	// 99: kill sprite
-	kill_sprite_simon1(getVarOrWord());
+	stopAnimateSimon1(getVarOrWord());
 }
 
 void SimonEngine::o1_playTune() {
@@ -1583,7 +1583,7 @@
 	if (_beardLoaded == false) {
 		_beardLoaded = true;
 		_lockWord |= 0x8000;
-		read_vga_from_datfile_1(328);
+		loadSimonVGAFile(328);
 		_lockWord &= ~0x8000;
 	}
 }
@@ -1593,7 +1593,7 @@
 	if (_beardLoaded == true) {
 		_beardLoaded = false;
 		_lockWord |= 0x8000;
-		read_vga_from_datfile_1(23);
+		loadSimonVGAFile(23);
 		_lockWord &= ~0x8000;
 	}
 }
@@ -1654,7 +1654,7 @@
 	// 99: kill sprite
 	uint a = getVarOrWord();
 	uint b = getVarOrWord();
-	kill_sprite_simon2(a, b);
+	stopAnimateSimon2(a, b);
 }
 
 void SimonEngine::o2_playTune() {
@@ -2274,7 +2274,7 @@
 	window->text_color = color;
 }
 
-void SimonEngine::kill_sprite_simon1(uint a) {
+void SimonEngine::stopAnimateSimon1(uint a) {
 	uint16 b = to16Wrapper(a);
 	_lockWord |= 0x8000;
 	_vcPtr = (byte *)&b;
@@ -2282,7 +2282,7 @@
 	_lockWord &= ~0x8000;
 }
 
-void SimonEngine::kill_sprite_simon2(uint a, uint b) {
+void SimonEngine::stopAnimateSimon2(uint a, uint b) {
 	uint16 items[2];
 
 	items[0] = to16Wrapper(a);

Modified: scummvm/trunk/engines/simon/res.cpp
===================================================================
--- scummvm/trunk/engines/simon/res.cpp	2006-04-20 14:55:27 UTC (rev 22061)
+++ scummvm/trunk/engines/simon/res.cpp	2006-04-21 00:18:23 UTC (rev 22062)
@@ -439,6 +439,44 @@
 	}
 }
 
+void SimonEngine::openGameFile() {
+	if (!(getFeatures() & GF_OLD_BUNDLE)) {
+		_gameFile = new File();
+		_gameFile->open(gss->gme_filename);
+
+		if (_gameFile->isOpen() == false)
+			error("Can't open game file '%s'", gss->gme_filename);
+
+		uint32 size = _gameFile->readUint32LE();
+
+		_gameOffsetsPtr = (uint32 *)malloc(size);
+		if (_gameOffsetsPtr == NULL)
+			error("out of memory, game offsets");
+
+		readGameFile(_gameOffsetsPtr, 0, size);
+#if defined(SCUMM_BIG_ENDIAN)
+		for (uint r = 0; r < size / 4; r++)
+			_gameOffsetsPtr[r] = FROM_LE_32(_gameOffsetsPtr[r]);
+#endif
+	}
+
+	if (getGameType() == GType_FF)
+		loadIconData();
+	else
+		loadIconFile();
+
+	vc34_setMouseOff();
+
+	runSubroutine101();
+	permitInput();
+}
+
+void SimonEngine::readGameFile(void *dst, uint32 offs, uint32 size) {
+	_gameFile->seek(offs, SEEK_SET);
+	if (_gameFile->read(dst, size) != size)
+		error("readGameFile(%d,%d) read failed", offs, size);
+}
+
 // Thanks to Stuart Caie for providing the original
 // C conversion upon which this decruncher is based.
 
@@ -556,7 +594,7 @@
 #undef SD_TYPE_LITERAL
 #undef SD_TYPE_MATCH
 
-void SimonEngine::read_vga_from_datfile_1(uint vga_id) {
+void SimonEngine::loadSimonVGAFile(uint vga_id) {
 	uint32 offs, size;
 
 	if (getFeatures() & GF_OLD_BUNDLE) {
@@ -578,25 +616,25 @@
 
 		in.open(filename);
 		if (in.isOpen() == false)
-			error("read_vga_from_datfile_1: can't open %s", filename);
+			error("loadSimonVGAFile: can't open %s", filename);
 
 		size = in.size();
 		if (getFeatures() & GF_CRUNCHED) {
 			byte *srcBuffer = (byte *)malloc(size);
 			if (in.read(srcBuffer, size) != size)
-				error("read_vga_from_datfile_1: read failed");
+				error("loadSimonVGAFile: read failed");
 			decrunchFile(srcBuffer, _vgaBufferPointers[11].vgaFile2, size);
 			free(srcBuffer);
 		} else {
 			if (in.read(_vgaBufferPointers[11].vgaFile2, size) != size)
-				error("read_vga_from_datfile_1: read failed");
+				error("loadSimonVGAFile: read failed");
 		}
 		in.close();
 	} else {
 		offs = _gameOffsetsPtr[vga_id];
 
 		size = _gameOffsetsPtr[vga_id + 1] - offs;
-		resfile_read(_vgaBufferPointers[11].vgaFile2, offs, size);
+		readGameFile(_vgaBufferPointers[11].vgaFile2, offs, size);
 	}
 }
 
@@ -668,19 +706,13 @@
 
 		dstSize = _gameOffsetsPtr[id + 1] - offs;
 		dst = allocBlock(dstSize + extraBuffer);
-		resfile_read(dst, offs, dstSize);
+		readGameFile(dst, offs, dstSize);
 	}
 
 	dstSize += extraBuffer;
 	return dst;
 }
 
-void SimonEngine::resfile_read(void *dst, uint32 offs, uint32 size) {
-	_gameFile->seek(offs, SEEK_SET);
-	if (_gameFile->read(dst, size) != size)
-		error("resfile_read(%d,%d) read failed", offs, size);
-}
-
 void SimonEngine::loadSound(uint sound, uint pan, uint vol, uint type) {
 	byte *dst;
 

Modified: scummvm/trunk/engines/simon/simon.cpp
===================================================================
--- scummvm/trunk/engines/simon/simon.cpp	2006-04-20 14:55:27 UTC (rev 22061)
+++ scummvm/trunk/engines/simon/simon.cpp	2006-04-21 00:18:23 UTC (rev 22062)
@@ -1339,7 +1339,7 @@
 	offs = _gameOffsetsPtr[res];
 	size = _gameOffsetsPtr[res + 1] - offs;
 
-	resfile_read(dst, offs, size);
+	readGameFile(dst, offs, size);
 
 	return size;
 }
@@ -1796,7 +1796,7 @@
 		ha = _hitAreas;
 		count = ARRAYSIZE(_hitAreas);
 
-		timer_vga_sprites();
+		animateSprites();
 
 		do {
 			if (ha->id != 0 && ha->flags & kBFBoxInUse && !(ha->flags & kBFBoxDead)) {
@@ -1866,7 +1866,7 @@
 
 		dx_update_screen_and_palette();
 		delay(100);
-		timer_vga_sprites();
+		animateSprites();
 		dx_update_screen_and_palette();
 		delay(100);
 	}
@@ -1979,7 +1979,6 @@
 	}
 }
 
-// Simon 2 specific
 void SimonEngine::hitarea_stuff_helper_2() {
 	uint subr_id;
 	Subroutine *sub;
@@ -2334,7 +2333,7 @@
 	}
 
 	//dump_vga_script(_vcPtr, num, vga_res_id);
-	run_vga_script();
+	runVgaScript();
 	_vcPtr = vc_ptr_org;
 
 
@@ -2399,9 +2398,36 @@
 	memcpy(_palette, _videoBuf1, 1024);
 }
 
-void SimonEngine::delete_vga_timer(VgaTimerEntry * vte) {
+void SimonEngine::addVgaEvent(uint16 num, const byte *code_ptr, uint16 cur_sprite, uint16 curZoneNum, int32 param) {
+	VgaTimerEntry *vte;
+
+	// When Simon talks to the Golum about stew in French version of
+	// Simon the Sorcerer 1 the code_ptr is at wrong location for
+	// sprite 200. This  was a bug in the original game, which
+	// caused several glitches in this scene.
+	// We work around the problem by correcting the code_ptr for sprite
+	// 200 in this scene, if it is wrong.
+	if (getGameType() == GType_SIMON1 && _language == Common::FR_FRA &&
+		(code_ptr - _vgaBufferPointers[curZoneNum].vgaFile1 == 4) && (cur_sprite == 200) && (curZoneNum == 2))
+		code_ptr += 0x66;
+
 	_lockWord |= 1;
 
+	for (vte = _vgaTimerList; vte->delay; vte++) {
+	}
+
+	vte->delay = num;
+	vte->script_pointer = code_ptr;
+	vte->sprite_id = cur_sprite;
+	vte->cur_vga_file = curZoneNum;
+	vte->param = param;
+
+	_lockWord &= ~1;
+}
+
+void SimonEngine::deleteVgaEvent(VgaTimerEntry * vte) {
+	_lockWord |= 1;
+
 	if (vte + 1 <= _nextVgaTimerToProcess) {
 		_nextVgaTimerToProcess--;
 	}
@@ -2414,7 +2440,7 @@
 	_lockWord &= ~1;
 }
 
-void SimonEngine::expire_vga_timers() {
+void SimonEngine::processVgaEvents() {
 	VgaTimerEntry *vte = _vgaTimerList;
 	uint timer = (getGameType() == GType_FF) ? 5 : 1;
 
@@ -2423,18 +2449,20 @@
 	while (vte->delay) {
 		vte->delay -= timer;
 		if (vte->delay <= 0) {
-			uint16 cur_file = vte->cur_vga_file;
+			uint16 curZoneNum = vte->cur_vga_file;
 			uint16 cur_sprite = vte->sprite_id;
 			const byte *script_ptr = vte->script_pointer;
+			int32 param = vte->param;
 
 			_nextVgaTimerToProcess = vte + 1;
-			delete_vga_timer(vte);
+			deleteVgaEvent(vte);
 
-			if ((getGameType() == GType_SIMON2) && script_ptr == NULL) {
-				// special scroll timer
-				scroll_timeout();
+			if (getGameType() == GType_FF && script_ptr == NULL) {
+				panEvent(curZoneNum, cur_sprite, param);
+			} else if (getGameType() == GType_SIMON2 && script_ptr == NULL) {
+				scrollEvent();
 			} else {
-				vcResumeSprite(script_ptr, cur_file, cur_sprite);
+				animateEvent(script_ptr, curZoneNum, cur_sprite);
 			}
 			vte = _nextVgaTimerToProcess;
 		} else {
@@ -2443,8 +2471,46 @@
 	}
 }
 
-// Simon2 specific
-void SimonEngine::scroll_timeout() {
+void SimonEngine::animateEvent(const byte *code_ptr, uint16 curZoneNum, uint16 cur_sprite) {
+	VgaPointersEntry *vpe;
+
+	_vgaCurSpriteId = cur_sprite;
+
+	_vgaCurZoneNum = curZoneNum;
+	_zoneNumber = curZoneNum;
+	vpe = &_vgaBufferPointers[curZoneNum];
+
+	_curVgaFile1 = vpe->vgaFile1;
+	_curVgaFile2 = vpe->vgaFile2;
+	_curSfxFile = vpe->sfxFile;
+
+	_vcPtr = code_ptr;
+
+	runVgaScript();
+}
+
+void SimonEngine::panEvent(uint16 curZoneNum, uint16 cur_sprite, int32 param) {
+	_vgaCurSpriteId = cur_sprite;
+	_vgaCurZoneNum = curZoneNum;
+
+	VgaSprite *vsp = findCurSprite();
+
+	param &= 0x10;
+
+	int32 pan = (vsp->x - _scrollX + param) * 8 - 2560;
+	if (pan < -10000)
+		pan = -10000;
+	if (pan > 10000)
+		pan = 10000;
+
+	//setSfxPan(param, pan);
+
+	if (pan != 0)
+		addVgaEvent(10, NULL, _vgaCurSpriteId, _vgaCurZoneNum); /* pan event */
+	debug(0, "panEvent: param %d pan %d", param, pan);
+}
+
+void SimonEngine::scrollEvent() {
 	if (_scrollCount == 0)
 		return;
 
@@ -2475,54 +2541,10 @@
 			}
 		}
 
-		add_vga_timer(6, NULL, 0, 0);
+		addVgaEvent(6, NULL, 0, 0); /* scroll event */
 	}
 }
 
-void SimonEngine::vcResumeSprite(const byte *code_ptr, uint16 cur_file, uint16 cur_sprite) {
-	VgaPointersEntry *vpe;
-
-	_vgaCurSpriteId = cur_sprite;
-
-	_vgaCurZoneNum = cur_file;
-	_zoneNumber = cur_file;
-	vpe = &_vgaBufferPointers[cur_file];
-
-	_curVgaFile1 = vpe->vgaFile1;
-	_curVgaFile2 = vpe->vgaFile2;
-	_curSfxFile = vpe->sfxFile;
-
-	_vcPtr = code_ptr;
-
-	run_vga_script();
-}
-
-void SimonEngine::add_vga_timer(uint num, const byte *code_ptr, uint cur_sprite, uint cur_file) {
-	VgaTimerEntry *vte;
-
-	// When Simon talks to the Golum about stew in French version of
-	// Simon the Sorcerer 1 the code_ptr is at wrong location for
-	// sprite 200. This  was a bug in the original game, which
-	// caused several glitches in this scene.
-	// We work around the problem by correcting the code_ptr for sprite
-	// 200 in this scene, if it is wrong.
-	if (getGameType() == GType_SIMON1 && _language == Common::FR_FRA &&
-		(code_ptr - _vgaBufferPointers[cur_file].vgaFile1 == 4) && (cur_sprite == 200) && (cur_file == 2))
-		code_ptr += 0x66;
-
-	_lockWord |= 1;
-
-	for (vte = _vgaTimerList; vte->delay; vte++) {
-	}
-
-	vte->delay = num;
-	vte->script_pointer = code_ptr;
-	vte->sprite_id = cur_sprite;
-	vte->cur_vga_file = cur_file;
-
-	_lockWord &= ~1;
-}
-
 void SimonEngine::waitForSync(uint a) {
 	const uint maxCount = (getGameType() == GType_SIMON1) ? 500 : 1000;
 
@@ -2562,17 +2584,17 @@
 			_variableArray[103] = 5;
 			loadSprite(4, 2, 13, 0, 0, 0);
 			waitForSync(213);
-			kill_sprite_simon2(2, 1);
+			stopAnimateSimon2(2, 1);
 		} else {
 			_variableArray[100] = 5;
 			loadSprite(4, 1, 30, 0, 0, 0);
 			waitForSync(130);
-			kill_sprite_simon2(2, 1);
+			stopAnimateSimon2(2, 1);
 		}
 	}
 }
 
-void SimonEngine::timer_vga_sprites() {
+void SimonEngine::animateSprites() {
 	VgaSprite *vsp;
 	VgaPointersEntry *vpe;
 	const byte *vc_ptr_org = _vcPtr;
@@ -2582,10 +2604,10 @@
 		_paletteFlag = 1;
 
 	if (getGameType() == GType_FF && _scrollCount) {
-		scroll_timeout();
+		scrollEvent();
 	}
 	if (getGameType() == GType_SIMON2 && _scrollFlag) {
-		scrollEvent();
+		scrollScreen();
 	}
 
 	if (getGameType() == GType_FF && getBitFlag(84)) {
@@ -2606,6 +2628,9 @@
 		_vgaCurSpriteId = vsp->id;
 		_vgaCurSpritePriority = vsp->priority;
 
+		if (_drawImagesDebug && vsp->image)
+			fprintf(_dumpFile, "id:%5d image:%3d base-color:%3d x:%3d y:%3d flags:%x\n",
+							vsp->id, vsp->image, vsp->palette, vsp->x, vsp->y, vsp->flags);
 		params[0] = readUint16Wrapper(&vsp->image);
 		params[1] = readUint16Wrapper(&vsp->palette);
 		params[2] = readUint16Wrapper(&vsp->x);
@@ -2630,7 +2655,7 @@
 	_vcPtr = vc_ptr_org;
 }
 
-void SimonEngine::scrollEvent() {
+void SimonEngine::scrollScreen() {
 	byte *dst = getFrontBuf();
 	const byte *src;
 	uint x, y;
@@ -2686,44 +2711,6 @@
 	_scrollFlag = 0;
 }
 
-void SimonEngine::timer_vga_sprites_2() {
-	VgaSprite *vsp;
-	VgaPointersEntry *vpe;
-	const byte *vc_ptr_org = _vcPtr;
-	uint16 params[5];							// parameters to vc10_draw
-
-	if (_paletteFlag == 2)
-		_paletteFlag = 1;
-
-	vsp = _vgaSprites;
-	while (vsp->id != 0) {
-		vsp->windowNum &= 0x7FFF;
-
-		vpe = &_vgaBufferPointers[vsp->zoneNum];
-		_curVgaFile1 = vpe->vgaFile1;
-		_curVgaFile2 = vpe->vgaFile2;
-		_curSfxFile = vpe->sfxFile;
-		_windowNum = vsp->windowNum;
-		_vgaCurSpriteId = vsp->id;
-
-		if (vsp->image)
-			fprintf(_dumpFile, "id:%5d image:%3d base-color:%3d x:%3d y:%3d flags:%x\n",
-							vsp->id, vsp->image, vsp->palette, vsp->x, vsp->y, vsp->flags);
-		params[0] = readUint16Wrapper(&vsp->image);
-		params[1] = readUint16Wrapper(&vsp->palette);
-		params[2] = readUint16Wrapper(&vsp->x);
-		params[3] = readUint16Wrapper(&vsp->y);
-		params[4] = readUint16Wrapper(&vsp->flags);
-		_vcPtr = (const byte *)params;
-		vc10_draw();
-
-		vsp++;
-	}
-
-	_updateScreen++;
-	_vcPtr = vc_ptr_org;
-}
-
 void SimonEngine::timer_proc1() {
 	_timer4++;
 
@@ -2739,14 +2726,14 @@
 			_syncFlag2 ^= 1;
 
 			if (!_syncFlag2)
-				expire_vga_timers();
+				processVgaEvents();
 		} else {
-			expire_vga_timers();
-			expire_vga_timers();
+			processVgaEvents();
+			processVgaEvents();
 			_syncFlag2 ^= 1;
 			_cepeFlag ^= 1;
 			if (!_cepeFlag)
-				expire_vga_timers();
+				processVgaEvents();
 
 			if (_mouseHideCount != 0 && _syncFlag2) {
 				_lockWord &= ~2;
@@ -2755,16 +2742,13 @@
 		}
 	}
 
-	timer_vga_sprites();
-	if (_drawImagesDebug)
-		timer_vga_sprites_2();
+	animateSprites();
 
 	if (_copyPartialMode == 1) {
 		fillBackFromFront(80, 46, 208 - 80, 94 - 46);
 	}
 
 	if (_copyPartialMode == 2) {
-		// copy partial from attached to 2
 		fillFrontFromBack(176, 61, _screenWidth - 176, 134 - 61);
 		_copyPartialMode = 0;
 	}
@@ -3222,7 +3206,7 @@
 				if (_startVgaScript)
 					dump_vga_script(pp + READ_LE_UINT16(&((AnimationHeader_Feeble*)p)->scriptOffs), zoneNum, vgaSpriteId);
 
-				add_vga_timer(VGA_DELAY_BASE, pp + READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->scriptOffs), vgaSpriteId, zoneNum);
+				addVgaEvent(VGA_DELAY_BASE, pp + READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->scriptOffs), vgaSpriteId, zoneNum);
 				break;
 			}
 			p += sizeof(AnimationHeader_Feeble);
@@ -3231,7 +3215,7 @@
 				if (_startVgaScript)
 					dump_vga_script(pp + READ_BE_UINT16(&((AnimationHeader_Simon*)p)->scriptOffs), zoneNum, vgaSpriteId);
 
-				add_vga_timer(VGA_DELAY_BASE, pp + READ_BE_UINT16(&((AnimationHeader_Simon *) p)->scriptOffs), vgaSpriteId, zoneNum);
+				addVgaEvent(VGA_DELAY_BASE, pp + READ_BE_UINT16(&((AnimationHeader_Simon *) p)->scriptOffs), vgaSpriteId, zoneNum);
 				break;
 			}
 			p += sizeof(AnimationHeader_Simon);
@@ -3262,9 +3246,9 @@
 			if (_subtitles && _scriptVar2) {
 				loadSprite(4, 2, 204, 0, 0, 0);
 				waitForSync(204);
-				kill_sprite_simon1(204);
+				stopAnimateSimon1(204);
 			}
-			kill_sprite_simon1(vgaSpriteId + 201);
+			stopAnimateSimon1(vgaSpriteId + 201);
 			loadVoice(speech_id);
 			loadSprite(4, 2, vgaSpriteId + 201, 0, 0, 0);
 		}
@@ -3288,48 +3272,16 @@
 			if (_subtitles && _scriptVar2) {
 				loadSprite(4, 2, 5, 0, 0, 0);
 				waitForSync(205);
-				kill_sprite_simon2(2,5);
+				stopAnimateSimon2(2,5);
 			}
 
-			kill_sprite_simon2(2, vgaSpriteId + 2);
+			stopAnimateSimon2(2, vgaSpriteId + 2);
 			loadVoice(speech_id);
 			loadSprite(4, 2, vgaSpriteId + 2, 0, 0, 0);
 		}
 	}
 }
 
-void SimonEngine::openGameFile() {
-	if (!(getFeatures() & GF_OLD_BUNDLE)) {
-		_gameFile = new File();
-		_gameFile->open(gss->gme_filename);
-
-		if (_gameFile->isOpen() == false)
-			error("Can't open game file '%s'", gss->gme_filename);
-
-		uint32 size = _gameFile->readUint32LE();
-
-		_gameOffsetsPtr = (uint32 *)malloc(size);
-		if (_gameOffsetsPtr == NULL)
-			error("out of memory, game offsets");
-
-		resfile_read(_gameOffsetsPtr, 0, size);
-#if defined(SCUMM_BIG_ENDIAN)
-		for (uint r = 0; r < size / 4; r++)
-			_gameOffsetsPtr[r] = FROM_LE_32(_gameOffsetsPtr[r]);
-#endif
-	}
-
-	if (getGameType() == GType_FF)
-		loadIconData();
-	else
-		loadIconFile();
-
-	vc34_setMouseOff();
-
-	runSubroutine101();
-	permitInput();
-}
-
 void SimonEngine::runSubroutine101() {
 	Subroutine *sub;
 
@@ -3419,7 +3371,7 @@
 	memcpy(_backBuf, _frontBuf, _screenWidth * _screenHeight);
 
 	if (getGameType() == GType_FF && _scrollFlag) {
-		scrollEvent();
+		scrollScreen();
 	}
 
 	if (_paletteColorCount != 0) {

Modified: scummvm/trunk/engines/simon/simon.h
===================================================================
--- scummvm/trunk/engines/simon/simon.h	2006-04-20 14:55:27 UTC (rev 22061)
+++ scummvm/trunk/engines/simon/simon.h	2006-04-21 00:18:23 UTC (rev 22062)
@@ -107,6 +107,7 @@
 	const byte *script_pointer;
 	uint16 sprite_id;
 	uint16 cur_vga_file;
+	int32 param;
 	VgaTimerEntry() { memset(this, 0, sizeof(*this)); }
 };
 
@@ -561,11 +562,12 @@
 	void unlinkItem(Item *item);
 	void linkItem(Item *item, Item *parent);
 
-	void kill_sprite_simon1(uint a);
-	void kill_sprite_simon2(uint a, uint b);
+	void stopAnimateSimon1(uint a);
+	void stopAnimateSimon2(uint a, uint b);
 
 	void changeWindow(uint a);
 	void closeWindow(uint a);
+
 	void enableBox(uint hitarea);
 	void disableBox(uint hitarea);
 	void moveBox(uint hitarea, int x, int y);
@@ -573,6 +575,7 @@
 	void undefineBox(uint hitarea);
 	void defineBox(int id, int x, int y, int width, int height, int flags, int verb, Item *item_ptr);
 	HitArea *findEmptyHitArea();
+
 	void resetVerbs();
 	void setVerb(HitArea * ha);
 	void hitarea_leave(HitArea * ha, bool state = false);
@@ -631,7 +634,6 @@
 	void invokeTimeEvent(TimeEvent *te);
 	bool kickoffTimeEvents();
 
-	void clearName();
 	void endCutscene();
 	void runSubroutine101();
 
@@ -649,11 +651,10 @@
 	void clearWindow(WindowBlock *window);
 	void video_toggle_colors(HitArea * ha, byte a, byte b, byte c, byte d);
 
-	void read_vga_from_datfile_1(uint vga_id);
-
 	uint getWindowNum(WindowBlock *window);
 
 	void boxController(uint x, uint y, uint mode);
+	void clearName();
 	void displayName(HitArea * ha);
 	void displayBoxStars();
 	void hitarea_stuff();
@@ -677,6 +678,7 @@
 
 	void loadIconData();	
 	void loadIconFile();
+
 	void processSpecialKeys();
 	void hitarea_stuff_helper();
 
@@ -713,7 +715,7 @@
 
 	void setup_vga_file_buf_pointers();
 
-	void run_vga_script();
+	void runVgaScript();
 
 public:
 	bool getBitFlag(uint bit);
@@ -1007,8 +1009,6 @@
 	void horizontalScroll(VC10_state *state);
 	void verticalScroll(VC10_state *state);
 
-	void delete_vga_timer(VgaTimerEntry * vte);
-	void vcResumeSprite(const byte *code_ptr, uint16 cur_file, uint16 cur_sprite);
 	int vcReadVarOrWord();
 	uint vcReadNextWord();
 	uint vcReadNextByte();
@@ -1025,11 +1025,15 @@
 	bool itemIsParentOf(uint16 a, uint16 b);
 	bool vc_maybe_skip_proc_1(uint16 a, int16 b);
 
-	void add_vga_timer(uint num, const byte *code_ptr, uint cur_sprite, uint cur_file);
+	void addVgaEvent(uint16 num, const byte *code_ptr, uint16 cur_sprite, uint16 curZoneNum, int32 param = 0);
+	void deleteVgaEvent(VgaTimerEntry * vte);
+	void processVgaEvents();
+	void animateEvent(const byte *code_ptr, uint16 curZoneNum, uint16 cur_sprite);
+	void panEvent(uint16 curZoneNum, uint16 cur_sprite, int32 param);
+	void scrollEvent();
+
 	VgaSprite *findCurSprite();
 
-	void expire_vga_timers();
-
 	bool isSpriteLoaded(uint16 id, uint16 zoneNum);
 
 	void resetWindow(WindowBlock *window);
@@ -1048,18 +1052,18 @@
 	byte *getScaleBuf();
 
 	byte *loadVGAFile(uint id, uint type, uint &dstSize);
+	void loadSimonVGAFile(uint vga_id);
 
-	void resfile_read(void *dst, uint32 offs, uint32 size);
-
 	int init();
 	int go();
+
 	void openGameFile();
+	void readGameFile(void *dst, uint32 offs, uint32 size);
 
 	void timer_callback();
 	void timer_proc1();
 
-	void timer_vga_sprites();
-	void timer_vga_sprites_2();
+	void animateSprites();
 
 	void dx_clear_surfaces(uint num_lines);
 	void dx_update_screen_and_palette();
@@ -1103,11 +1107,10 @@
 	void pause();
 
 	void waitForMark(uint i);
-	void scrollEvent();
+	void scrollScreen();
 
 	void decodeColumn(byte *dst, const byte *src, int height);
 	void decodeRow(byte *dst, const byte *src, int width);
-	void scroll_timeout();
 	void hitarea_stuff_helper_2();
 	void fastFadeIn();
 	void slowFadeIn();

Modified: scummvm/trunk/engines/simon/string.cpp
===================================================================
--- scummvm/trunk/engines/simon/string.cpp	2006-04-20 14:55:27 UTC (rev 22061)
+++ scummvm/trunk/engines/simon/string.cpp	2006-04-21 00:18:23 UTC (rev 22062)
@@ -172,7 +172,7 @@
 	_variableArray[53] = w;
 	_variableArray[54] = height;
 
-	kill_sprite_simon2(2, num + 6);
+	stopAnimateSimon2(2, num + 6);
 	renderString(num, 0, w, height, convertedString);
 	loadSprite(4, 2, num + 6, x, _interactY, 12);
 
@@ -294,9 +294,9 @@
 	}
 
 	if (getGameType() == GType_SIMON1)
-		kill_sprite_simon1(vgaSpriteId + 199);
+		stopAnimateSimon1(vgaSpriteId + 199);
 	else
-		kill_sprite_simon2(2, vgaSpriteId);
+		stopAnimateSimon2(2, vgaSpriteId);
 
 	if (getGameType() == GType_FF) {
 		renderString(1, color, width, height, convertedString);

Modified: scummvm/trunk/engines/simon/verb.cpp
===================================================================
--- scummvm/trunk/engines/simon/verb.cpp	2006-04-20 14:55:27 UTC (rev 22061)
+++ scummvm/trunk/engines/simon/verb.cpp	2006-04-21 00:18:23 UTC (rev 22062)
@@ -193,7 +193,7 @@
 	HitArea *ha;
 
 	if (getGameType() == GType_FF) {
-		kill_sprite_simon2(2, 6);
+		stopAnimateSimon2(2, 6);
 		_lastNameOn = NULL;
 		_animatePointer = 0;
 		_mouseAnim = 1;

Modified: scummvm/trunk/engines/simon/vga.cpp
===================================================================
--- scummvm/trunk/engines/simon/vga.cpp	2006-04-20 14:55:27 UTC (rev 22061)
+++ scummvm/trunk/engines/simon/vga.cpp	2006-04-21 00:18:23 UTC (rev 22062)
@@ -124,7 +124,7 @@
 }
 
 // Script parser
-void SimonEngine::run_vga_script() {
+void SimonEngine::runVgaScript() {
 	for (;;) {
 		uint opcode;
 
@@ -295,7 +295,7 @@
 	}
 
 	//dump_vga_script(_vcPtr, res, num);
-	run_vga_script();
+	runVgaScript();
 
 	_curVgaFile1 = old_file_1;
 	_curVgaFile2 = old_file_2;
@@ -402,9 +402,9 @@
 	}
 
 	if (getGameType() == GType_FF) {
-		add_vga_timer(VGA_DELAY_BASE, _curVgaFile1 + READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->scriptOffs), vgaSpriteId, res);
+		addVgaEvent(VGA_DELAY_BASE, _curVgaFile1 + READ_LE_UINT16(&((AnimationHeader_Feeble *) p)->scriptOffs), vgaSpriteId, res);
 	} else {
-		add_vga_timer(VGA_DELAY_BASE, _curVgaFile1 + READ_BE_UINT16(&((AnimationHeader_Simon *) p)->scriptOffs), vgaSpriteId, res);
+		addVgaEvent(VGA_DELAY_BASE, _curVgaFile1 + READ_BE_UINT16(&((AnimationHeader_Simon *) p)->scriptOffs), vgaSpriteId, res);
 	}
 
 	_curVgaFile1 = old_file_1;
@@ -1436,7 +1436,7 @@
 	else
 		num += VGA_DELAY_BASE;
 
-	add_vga_timer(num, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum);
+	addVgaEvent(num, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum);
 	_vcPtr = (byte *)&_vc_get_out_of_code;
 }
 
@@ -1457,7 +1457,7 @@
 	uint16 id = vcReadNextWord();
 	while (vfs->ident != 0) {
 		if (vfs->ident == id) {
-			add_vga_timer(VGA_DELAY_BASE, vfs->code_ptr, vfs->sprite_id, vfs->cur_vga_file);
+			addVgaEvent(VGA_DELAY_BASE, vfs->code_ptr, vfs->sprite_id, vfs->cur_vga_file);
 			vfs_tmp = vfs;
 			do {
 				memcpy(vfs_tmp, vfs_tmp + 1, sizeof(VgaSleepStruct));
@@ -1780,7 +1780,7 @@
 			tmp = _scrollXMax - _scrollX;
 			if (tmp < 20)
 				_scrollCount = tmp;
-			add_vga_timer(6, NULL, 0, 0);	/* special timer */
+			addVgaEvent(6, NULL, 0, 0);	 /* scroll event */
 		}
 	}
 no_scroll:;
@@ -1806,7 +1806,7 @@
 			_scrollCount = -20;
 			if (_scrollX < 20)
 				_scrollCount = -_scrollX;
-			add_vga_timer(6, NULL, 0, 0);	/* special timer */
+			addVgaEvent(6, NULL, 0, 0);	 /* scroll event */
 		}
 	}
 no_scroll:;
@@ -1818,7 +1818,7 @@
 	uint val = vcReadVar(vcReadNextWord());
 	if (val != vcReadNextWord()) {
 
-		add_vga_timer(_frameRate + 1, _vcPtr - 4, _vgaCurSpriteId, _vgaCurZoneNum);
+		addVgaEvent(_frameRate + 1, _vcPtr - 4, _vgaCurSpriteId, _vgaCurZoneNum);
 		_vcPtr = (byte *)&_vc_get_out_of_code;
 	}
 }
@@ -1984,11 +1984,26 @@
 }
 
 void SimonEngine::vc53_panSFX() {
-	// Start sound effect, panning it with the animation
-	int snd = vcReadNextWord();
-	int xoffs = vcReadNextWord();
-	int vol = vcReadNextWord();
-	debug(0, "STUB: vc53_panSFX: snd %d xoffs %d vol %d", snd, xoffs, vol);
+	VgaSprite *vsp = findCurSprite();
+	int32 pan;
+
+	uint16 sound = vcReadNextWord();
+	int16 xoffs = vcReadNextWord();
+	uint16 vol = vcReadNextWord();
+
+	pan = (vsp->x - _scrollX + xoffs) * 8 - 2560;
+	if (pan < -10000)
+		pan = -10000;
+	if (pan > 10000)
+		pan = 10000;
+
+	loadSound(sound, 0, vol, 1);
+
+	if (xoffs != 2)
+		xoffs |= 0x10;
+
+	addVgaEvent(10, NULL, _vgaCurSpriteId, _vgaCurZoneNum, xoffs); /* pan event */
+	debug(0, "vc53_panSFX: snd %d xoffs %d vol %d", sound, xoffs, vol);
 }
 
 void SimonEngine::vc54_no_op() {
@@ -2020,7 +2035,7 @@
 void SimonEngine::vc56_delay() {
 	uint num = vcReadVarOrWord() * _frameRate;
 
-	add_vga_timer(num + VGA_DELAY_BASE, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum);
+	addVgaEvent(num + VGA_DELAY_BASE, _vcPtr, _vgaCurSpriteId, _vgaCurZoneNum);
 	_vcPtr = (byte *)&_vc_get_out_of_code;
 }
 
@@ -2096,7 +2111,7 @@
 		vte = _vgaTimerList;
 		while (vte->delay != 0) {
 			if (vte->sprite_id == _vgaCurSpriteId && ((getGameType() == GType_SIMON1) || vte->cur_vga_file == _vgaCurZoneNum)) {
-				delete_vga_timer(vte);
+				deleteVgaEvent(vte);
 				break;
 			}
 			vte++;
@@ -2109,15 +2124,15 @@
 }
 
 void SimonEngine::vc60_killSprite() {
-	uint file;
+	uint zoneNum;
 
 	if (getGameType() == GType_SIMON1) {
-		file = _vgaCurZoneNum;
+		zoneNum = _vgaCurZoneNum;
 	} else {
-		file = vcReadNextWord();
+		zoneNum = vcReadNextWord();
 	}
 	uint sprite = vcReadNextWord();
-	vc_kill_sprite(file, sprite);
+	vc_kill_sprite(zoneNum, sprite);
 }
 
 void SimonEngine::vc61_setMaskImage() {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list