[Scummvm-cvs-logs] SF.net SVN: scummvm: [25860] scummvm/trunk/engines/queen

cyx at users.sourceforge.net cyx at users.sourceforge.net
Sun Feb 25 20:02:00 CET 2007


Revision: 25860
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25860&view=rev
Author:   cyx
Date:     2007-02-25 11:01:59 -0800 (Sun, 25 Feb 2007)

Log Message:
-----------
added AmigaSound::playRandomPatternJungle, minor cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/queen/display.cpp
    scummvm/trunk/engines/queen/graphics.cpp
    scummvm/trunk/engines/queen/logic.cpp
    scummvm/trunk/engines/queen/resource.cpp
    scummvm/trunk/engines/queen/sound.cpp
    scummvm/trunk/engines/queen/sound.h

Modified: scummvm/trunk/engines/queen/display.cpp
===================================================================
--- scummvm/trunk/engines/queen/display.cpp	2007-02-25 18:35:51 UTC (rev 25859)
+++ scummvm/trunk/engines/queen/display.cpp	2007-02-25 19:01:59 UTC (rev 25860)
@@ -286,7 +286,7 @@
 			palSetAmigaColor(30, 0x600);
 			break;
 		case 29:
-			palSetAmigaColor(27, 0X58B);
+			palSetAmigaColor(27, 0x58B);
 			palSetAmigaColor(28, 0x369);
 			palSetAmigaColor(29, 0x158);
 			palSetAmigaColor(30, 0x046);
@@ -755,7 +755,7 @@
 	if (data != NULL) {
 		if (_vm->resource()->getPlatform() == Common::kPlatformAmiga) {
 			uint8 *dst = _panelBuf + y * PANEL_W + x;
-			while (h--) {
+			for (int j = 0; j < h; ++j) {
 				for (int i = 0; i < w; ++i) {
 					dst[i] = 144 + *data++;
 				}
@@ -932,19 +932,14 @@
 
 void Display::setDirtyBlock(uint16 x, uint16 y, uint16 w, uint16 h) {
 	if (_fullRefresh < 2) {
+		assert(x + w <= SCREEN_W && y + h <= SCREEN_H);
 		uint16 ex = (x + w - 1) / D_BLOCK_W;
 		uint16 ey = (y + h - 1) / D_BLOCK_H;
 		x /= D_BLOCK_W;
 		y /= D_BLOCK_H;
-		uint16 cy = ey - y + 1;
-		uint16 cx = ex - x + 1;
-		if (cy >= _dirtyBlocksHeight) cy = _dirtyBlocksHeight - 1;
-		if (cx >= _dirtyBlocksWidth)  cx = _dirtyBlocksWidth  - 1;
 		uint8 *p = _dirtyBlocks + _dirtyBlocksWidth * y + x;
-		while (cy--) {
-			for (uint16 i = 0; i < cx; ++i) {
-				p[i] = 2;
-			}
+		for (; y <= ey; ++y) {
+			memset(p, 2, ex - x + 1);
 			p += _dirtyBlocksWidth;
 		}
 	}

Modified: scummvm/trunk/engines/queen/graphics.cpp
===================================================================
--- scummvm/trunk/engines/queen/graphics.cpp	2007-02-25 18:35:51 UTC (rev 25859)
+++ scummvm/trunk/engines/queen/graphics.cpp	2007-02-25 19:01:59 UTC (rev 25860)
@@ -303,13 +303,13 @@
 				const uint16 mask = (1 << (15 - b));
 				uint8 color = 0;
 				if (READ_BE_UINT16(src + 0) & mask) {
-					color |= 1;
+					color |= 2;
 				}
 				if (READ_BE_UINT16(src + 2) & mask) {
-					color |= 2;
+					color |= 1;
 				}
 				if (color != 0) {
-					cursorData[i] = 0x90 + color;
+					cursorData[i] = 0x90 + color - 1;
 				}
 				++i;
 			}
@@ -488,7 +488,7 @@
 }
 
 BobSlot *Graphics::bob(int index) {
-	assert(index < MAX_BOBS_NUMBER);
+	assert(index >= 0 && index < MAX_BOBS_NUMBER);
 	return &_bobs[index];
 }
 

Modified: scummvm/trunk/engines/queen/logic.cpp
===================================================================
--- scummvm/trunk/engines/queen/logic.cpp	2007-02-25 18:35:51 UTC (rev 25859)
+++ scummvm/trunk/engines/queen/logic.cpp	2007-02-25 19:01:59 UTC (rev 25860)
@@ -908,9 +908,7 @@
 	for (int i = 0; i < 4; ++i) {
 		uint16 itemNum = _inventoryItem[i];
 		if (itemNum != 0) {
-			// 1st object in inventory uses frame 9,
-			// whereas 2nd, 3rd and 4th uses frame 8
-			uint16 dstFrame = (itemNum != 0) ? 8 : 9;
+			uint16 dstFrame = (i == 0) ? 8 : 9;
 			// unpack frame for object and draw it
 			_vm->bankMan()->unpack(_itemData[itemNum].frame, dstFrame, 14);
 			_vm->graphics()->drawInventoryItem(dstFrame, x, 14);
@@ -1578,7 +1576,7 @@
 		for (int i = 300; i >= 200; i -= 5) {
 			bobFrank->y = i;
 			_vm->update();
-		}		
+		}
 	} else {
 		bobFrank->curPos(160, 200);
 		for (int i = 10; i <= 100; i += 4) {
@@ -1608,7 +1606,7 @@
 		for (int i = 350; i >= 200; i -= 5) {
 			bobRobot->y = i;
 			_vm->update();
-		}		
+		}
 	} else {
 		bobRobot->curPos(160, 200);
 		for (int i = 10; i <= 100; i += 4) {
@@ -1799,7 +1797,7 @@
 			bobJoe->x -= 2;
 		}
 		_vm->update();
-	}	
+	}
 }
 
 void Logic::asmMakeLightningHitPlane() {

Modified: scummvm/trunk/engines/queen/resource.cpp
===================================================================
--- scummvm/trunk/engines/queen/resource.cpp	2007-02-25 18:35:51 UTC (rev 25859)
+++ scummvm/trunk/engines/queen/resource.cpp	2007-02-25 19:01:59 UTC (rev 25860)
@@ -296,7 +296,7 @@
 }
 
 Common::File *Resource::findSound(const char *filename, uint32 *size) {
-	assert(strstr(filename, ".SB") != NULL || strstr(filename, ".AMR") != NULL);
+	assert(strstr(filename, ".SB") != NULL || strstr(filename, ".AMR") != NULL || strstr(filename, ".INS") != NULL);
 	ResourceEntry *re = resourceEntry(filename);
 	if (re) {
 		*size = re->size;

Modified: scummvm/trunk/engines/queen/sound.cpp
===================================================================
--- scummvm/trunk/engines/queen/sound.cpp	2007-02-25 18:35:51 UTC (rev 25859)
+++ scummvm/trunk/engines/queen/sound.cpp	2007-02-25 19:01:59 UTC (rev 25860)
@@ -292,12 +292,12 @@
 void AmigaSound::playSong(int16 song) {
 	debug(2, "Sound::playSong %d override %d", song, _lastOverride);
 
-  if (song < 0) {
-  	stopSong();
-  	return;
-  }
+	if (song < 0) {
+		stopSong();
+		return;
+	}
 
-  // remap song numbers for the Amiga
+	// remap song numbers for the Amiga
 	switch (song) {
 	case 1:
 	case 2:
@@ -539,7 +539,7 @@
 	if (_fluteCount > 0 && (_lastOverride == 40 || _lastOverride == 3)) {
 		--_fluteCount;
 		if (_fluteCount == 0) {
-//			playPattern(3, 5 + (getRandomNumber() & 7));
+			playRandomPatternJungle();
 			_fluteCount = 100;
 		}
 	}
@@ -590,6 +590,23 @@
 	_fanfareCount = 0;
 }
 
+void AmigaSound::playRandomPatternJungle() {
+	static const uint16 patOffset[] = { 2, 1416, 2722, 2242, 11046, 11046 };
+	static const uint16 patSize[] = { 1056, 826, 8100, 8580, 15808, 15808 };
+	uint32 soundSize;
+	Common::File *f = _vm->resource()->findSound("JUNG.INS", &soundSize);
+	if (f) {
+		const int i = _rnd.getRandomNumber(5);
+		uint8 *soundData = (uint8 *)malloc(patSize[i]);
+		if (soundData) {
+			f->seek(patOffset[i], SEEK_CUR);
+			f->read(soundData, patSize[i]);
+			byte flags = Audio::Mixer::FLAG_AUTOFREE;
+			_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, soundData, patSize[i], 9000, flags);
+		}
+	}
+}
+
 bool AmigaSound::playSpecialSfx(int16 sfx) {
 	switch (sfx) {
 	case 5: // normal volume

Modified: scummvm/trunk/engines/queen/sound.h
===================================================================
--- scummvm/trunk/engines/queen/sound.h	2007-02-25 18:35:51 UTC (rev 25859)
+++ scummvm/trunk/engines/queen/sound.h	2007-02-25 19:01:59 UTC (rev 25860)
@@ -178,12 +178,14 @@
 
 	void playSound(const char *base);
 	void playModule(const char *base, int song);
+	void playRandomPatternJungle();
 	bool playSpecialSfx(int16 sfx);
 
 	int16 _fanfareRestore;
 	int _fanfareCount, _fluteCount;
 	Audio::SoundHandle _modHandle;
 	Audio::SoundHandle _sfxHandle;
+	Common::RandomSource _rnd;
 };
 
 } // End of namespace Queen


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