[Scummvm-cvs-logs] CVS: scummvm/sword2/driver animation.cpp,1.21.2.6,1.21.2.7 animation.h,1.18.2.3,1.18.2.4

James Brown ender at users.sourceforge.net
Sun Mar 14 06:00:00 CET 2004


Update of /cvsroot/scummvm/scummvm/sword2/driver
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3406/sword2/driver

Modified Files:
      Tag: branch-0-6-0
	animation.cpp animation.h 
Log Message:
Rebuild BS lookup tables on screen change events. Switch .pal format to binary, and use File class.


Index: animation.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/animation.cpp,v
retrieving revision 1.21.2.6
retrieving revision 1.21.2.7
diff -u -d -r1.21.2.6 -r1.21.2.7
--- animation.cpp	4 Mar 2004 18:56:39 -0000	1.21.2.6
+++ animation.cpp	14 Mar 2004 13:50:38 -0000	1.21.2.7
@@ -65,48 +65,44 @@
 	bgSoundStream = NULL;
 
 #ifdef BACKEND_8BIT
-
 	uint i, p;
 
 	// Load lookup palettes
-	// TODO: Binary format so we can use File class
-	sprintf(tempFile, "%s/%s.pal", _vm->getGameDataPath(), name);
-	FILE *f = fopen(tempFile, "r");
+	File f;
 
-	if (!f) {
+	sprintf(tempFile, "%s.pal", name);
+	if (!f.open(tempFile)) {
 		warning("Cutscene: %s.pal palette missing", name);
 		return false;
 	}
-
+        
 	p = 0;
-	while (!feof(f)) {
-		int end, cnt;
+	while (1) {
+		int end = f.readUint16LE();
+		int cnt = f.readUint16LE();
 
-		if (fscanf(f, "%i %i", &end, &cnt) != 2)
+		if (f.ioFailed())
 			break;
-
-		palettes[p].end = (uint) end;
-		palettes[p].cnt = (uint) cnt;
-
-		for (i = 0; i < palettes[p].cnt; i++) {
-			int r, g, b;
-			fscanf(f, "%i", &r);
-			fscanf(f, "%i", &g);
-			fscanf(f, "%i", &b);
-			palettes[p].pal[4 * i] = r;
-			palettes[p].pal[4 * i + 1] = g;
-			palettes[p].pal[4 * i + 2] = b;
+	
+		for (i = 0; i < cnt; i++) {
+			palettes[p].pal[4 * i] = f.readByte();
+			palettes[p].pal[4 * i + 1] = f.readByte();
+			palettes[p].pal[4 * i + 2] = f.readByte();
 			palettes[p].pal[4 * i + 3] = 0;
 		}
+
 		for (; i < 256; i++) {
 			palettes[p].pal[4 * i] = 0;
 			palettes[p].pal[4 * i + 1] = 0;
 			palettes[p].pal[4 * i + 2] = 0;
 			palettes[p].pal[4 * i + 3] = 0;
 		}
+		palettes[p].end = end;
+		palettes[p].cnt = cnt;
+
 		p++;
 	}
-	fclose(f);
+	f.close();
 
 	palnum = 0;
 	maxPalnum = p;
@@ -241,6 +237,15 @@
 
 NewGuiColor *AnimationState::lookup = 0;
 
+void AnimationState::invalidateLookup() {
+	// TODO: Add heuristic to check if rebuilding the lookup table is
+	// actually necessary. If the screen format remains the same, then the
+	// current lookup table should be fine.
+	free(lookup);
+	lookup = 0;
+	buildLookup();
+}
+
 void AnimationState::buildLookup() {
 	if (lookup)
 		return;
@@ -528,7 +533,7 @@
 	if (i == ARRAYSIZE(_movies))
 		warning("Unknown movie, '%s'", filename);
 
-	while (anim->decodeFrame()) {
+	while (!skipCutscene && anim->decodeFrame()) {
 		if (text && text[textCounter]) {
 			if (frameCounter == text[textCounter]->startFrame) {
 				openTextObject(text[textCounter]);
@@ -558,27 +563,42 @@
 		if (frameCounter == leadOutFrame && musicOut)
 			_vm->_sound->playFx(0, musicOut, 0, 0, RDSE_FXLEADOUT);
 
-#ifdef BACKEND_8BIT
-		_vm->_graphics->updateDisplay(true);
-#else
-		anim->updateDisplay();
-		_vm->_graphics->updateDisplay(false);
-#endif
+		#ifdef BACKEND_8BIT
+			_vm->_graphics->updateDisplay(true);
+		#else
+                	anim->updateDisplay();
+			_vm->_graphics->updateDisplay(false);
+		#endif
 
-		KeyboardEvent ke;
+//		_vm->_system->update_screen();
 
-		if ((_vm->_input->readKey(&ke) == RD_OK && ke.keycode == 27) || _vm->_quit) {
-			_vm->_mixer->stopHandle(handle);
-			skipCutscene = true;
-			break;
+		OSystem::Event event;
+		while (_vm->_system->poll_event(&event)) {
+			switch (event.event_code) {
+#ifndef BACKEND_8BIT
+			case OSystem::EVENT_SCREEN_CHANGED:
+				anim->invalidateLookup();
+				break;
+#endif
+			case OSystem::EVENT_KEYDOWN:
+				if (event.kbd.keycode == 27)
+					skipCutscene = true;
+				break;
+			case OSystem::EVENT_QUIT:
+				_vm->closeGame();
+				skipCutscene = true;
+				break;
+			default:
+				break;
+			}
 		}
-
 	}
 
 	if (!skipCutscene) {
 		// Sleep for one frame so that the last frame is displayed.
 		_vm->_system->delay_msecs(1000 / 12);
-	}
+	} else
+		_vm->_mixer->stopHandle(handle);
 
 #ifndef BACKEND_8BIT
 	// Most movies fade to black on their own, but not all of them. Since
@@ -603,7 +623,7 @@
 #ifndef BACKEND_8BIT
 	anim->updateDisplay();
 #else
-	_vm->_graphics->updateDisplay(true);
+	_vm->_graphics->updateDisplay();
 #endif
 
 	// Wait for the voice to stop playing. This is to make sure

Index: animation.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/animation.h,v
retrieving revision 1.18.2.3
retrieving revision 1.18.2.4
diff -u -d -r1.18.2.3 -r1.18.2.4
--- animation.h	4 Mar 2004 18:56:39 -0000	1.18.2.3
+++ animation.h	14 Mar 2004 13:50:38 -0000	1.18.2.4
@@ -21,7 +21,6 @@
 
 #ifndef ANIMATION_H
 #define ANIMATION_H
-
 #include "sound/mixer.h"
 
 // Uncomment this if you are using libmpeg2 0.3.1.
@@ -122,6 +121,7 @@
 	void drawTextObject(SpriteInfo *s, uint8 *src);
 	void clearDisplay();
 	void updateDisplay(void);
+	void invalidateLookup();
 #endif
 
 private:





More information about the Scummvm-git-logs mailing list