[Scummvm-cvs-logs] SF.net SVN: scummvm: [26553] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sat Apr 21 14:51:41 CEST 2007


Revision: 26553
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26553&view=rev
Author:   peres001
Date:     2007-04-21 05:51:40 -0700 (Sat, 21 Apr 2007)

Log Message:
-----------
- Implemented Amiga halfbrite mode in palette code, though usage is limited to displayItemComment() for the moment.
- Some changes to palette routines to make them fit with the new scheme.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/callables.cpp
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/parallaction/graphics.h
    scummvm/trunk/engines/parallaction/location.cpp
    scummvm/trunk/engines/parallaction/menu.cpp
    scummvm/trunk/engines/parallaction/zone.cpp

Modified: scummvm/trunk/engines/parallaction/callables.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables.cpp	2007-04-20 11:44:51 UTC (rev 26552)
+++ scummvm/trunk/engines/parallaction/callables.cpp	2007-04-21 12:51:40 UTC (rev 26553)
@@ -362,7 +362,7 @@
 	cleanInventory();
 	refreshInventory(_vm->_characterName);
 
-	_vm->_gfx->extendPalette(_vm->_gfx->_palette);
+	_vm->_gfx->setPalette(_vm->_gfx->_palette);
 
 	if (gameCompleted) {
 		_vm->_gfx->setFont(kFontMenu);

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2007-04-20 11:44:51 UTC (rev 26552)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2007-04-21 12:51:40 UTC (rev 26553)
@@ -119,19 +119,44 @@
 void Gfx::setPalette(Palette pal, uint32 first, uint32 num) {
 //	printf("setPalette(%i, %i)\n", first, num);
 
-	if (first + num > PALETTE_COLORS)
+	if (first + num > BASE_PALETTE_COLORS)
 		error("wrong parameters for setPalette()");
 
-	byte syspal[PALETTE_COLORS*4];
+	byte sysBasePal[EHB_PALETTE_COLORS*4];
+	byte sysExtraPal[BASE_PALETTE_COLORS*4];
 
+	byte r, g, b;
+	uint32 j = 0;
 	for (uint32 i = first; i < first+num; i++) {
-		syspal[i*4]   = (pal[i*3] << 2) | (pal[i*3] >> 4);
-		syspal[i*4+1] = (pal[i*3+1] << 2) | (pal[i*3+1] >> 4);
-		syspal[i*4+2] = (pal[i*3+2] << 2) | (pal[i*3+2] >> 4);
-		syspal[i*4+3] = 0;
+		r = (pal[i*3] << 2) | (pal[i*3] >> 4);
+		g = (pal[i*3+1] << 2) | (pal[i*3+1] >> 4);
+		b = (pal[i*3+2] << 2) | (pal[i*3+2] >> 4);
+
+		sysBasePal[j*4]   = r;
+		sysBasePal[j*4+1] = g;
+		sysBasePal[j*4+2] = b;
+		sysBasePal[j*4+3] = 0;
+
+		if (_vm->getPlatform() == Common::kPlatformAmiga) {
+			sysExtraPal[j*4]   = r >> 1;
+			sysExtraPal[j*4+1] = g >> 1;
+			sysExtraPal[j*4+2] = b >> 1;
+			sysExtraPal[j*4+3] = 0;
+		} else {
+			sysExtraPal[j*4]   = 0;
+			sysExtraPal[j*4+1] = 0;
+			sysExtraPal[j*4+2] = 0;
+			sysExtraPal[j*4+3] = 0;
+		}
+
+		j++;
 	}
 
-	g_system->setPalette(syspal, first, num);
+	g_system->setPalette(sysBasePal, first, num);
+
+	if (_vm->getPlatform() == Common::kPlatformAmiga)
+		g_system->setPalette(sysExtraPal, first+FIRST_EHB_COLOR, num);
+
 	g_system->updateScreen();
 
 	return;
@@ -197,7 +222,7 @@
 }
 
 void Gfx::fadePalette(Palette pal) {
-	for (uint16 i = 0; i < PALETTE_SIZE; i++)
+	for (uint16 i = 0; i < BASE_PALETTE_COLORS * 3; i++)
 		if (pal[i] < _palette[i]) pal[i]++;
 
 	return;
@@ -221,7 +246,7 @@
 
 void Gfx::quickFadePalette(Palette pal) {
 
-	for (uint16 i = 0; i < PALETTE_SIZE; i++) {
+	for (uint16 i = 0; i < BASE_PALETTE_COLORS * 3; i++) {
 		if (pal[i] == _palette[i]) continue;
 		pal[i] += (pal[i] < _palette[i] ? 4 : -4);
 	}
@@ -229,19 +254,22 @@
 	return;
 }
 
-void Gfx::extendPalette(Palette pal) {
+void Gfx::setHalfbriteMode(bool enable) {
+	if (_vm->getPlatform() != Common::kPlatformAmiga) return;
+	if (enable == _halfbrite) return;
 
-	for (uint16 i = 0; i < BASE_PALETTE_COLORS; i++) {
-		pal[(i+FIRST_EHB_COLOR)*3] = pal[i*3] / 2;
-		pal[(i+FIRST_EHB_COLOR)*3+1] = pal[i*3+1] / 2;
-		pal[(i+FIRST_EHB_COLOR)*3+2] = pal[i*3+2] / 2;
-	}
+	byte *buf = _buffers[kBitBack];
+	for (uint32 i = 0; i < SCREEN_SIZE; i++)
+		*buf++ ^= 0x20;
 
-	setPalette(pal);
+	buf = _buffers[kBitFront];
+	for (uint32 i = 0; i < SCREEN_SIZE; i++)
+		*buf++ ^= 0x20;
+
+	_halfbrite = !_halfbrite;
 }
 
 
-
 void Gfx::updateScreen() {
 //	  printf("Gfx::updateScreen()\n");
 	g_system->copyRectToScreen(_buffers[kBitFront], SCREEN_WIDTH, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
@@ -804,6 +832,8 @@
 	initMouse( 0 );
 	initFonts();
 
+	_halfbrite = false;
+
 	_font = NULL;
 
 	return;

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2007-04-20 11:44:51 UTC (rev 26552)
+++ scummvm/trunk/engines/parallaction/graphics.h	2007-04-21 12:51:40 UTC (rev 26553)
@@ -201,14 +201,16 @@
 	void blitCnv(StaticCnv *cnv, int16 x, int16 y, uint16 z, Gfx::Buffers buffer);
 
 	// palette
-	void setPalette(Palette palette, uint32 first = FIRST_BASE_COLOR, uint32 num = PALETTE_COLORS);
+	void setPalette(Palette palette, uint32 first = FIRST_BASE_COLOR, uint32 num = BASE_PALETTE_COLORS);
 	void setBlackPalette();
 	void animatePalette();
 	void fadePalette(Palette palette);
 	void buildBWPalette(Palette palette);
 	void quickFadePalette(Palette palette);
-	void extendPalette(Palette palette);
 
+	// amiga specific
+	void setHalfbriteMode(bool enable);
+
 	// init
 	Gfx(Parallaction* vm);
 	virtual ~Gfx();
@@ -232,6 +234,7 @@
 	StaticCnv			*_mouseComposedArrow;
 	Font				*_font;
 	Font				*_fonts[3];
+	bool				_halfbrite;
 
 protected:
 	byte mapChar(byte c);

Modified: scummvm/trunk/engines/parallaction/location.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/location.cpp	2007-04-20 11:44:51 UTC (rev 26552)
+++ scummvm/trunk/engines/parallaction/location.cpp	2007-04-21 12:51:40 UTC (rev 26553)
@@ -252,7 +252,7 @@
 			_si += 3;
 		}
 
-		_gfx->extendPalette(pal);
+		_gfx->setPalette(pal);
 	}
 
 	_disk->loadScenery(background, mask);
@@ -267,7 +267,7 @@
 void Parallaction::showSlide(const char *name) {
 
 	_disk->loadSlide(name);
-	_gfx->extendPalette(_gfx->_palette);
+	_gfx->setPalette(_gfx->_palette);
 	_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
 
 	debugC(1, kDebugLocation, "changeLocation: new background set");
@@ -385,7 +385,7 @@
 
 	byte palette[PALETTE_SIZE];
 	for (uint16 _si = 0; _si < PALETTE_SIZE; _si++) palette[_si] = 0;
-	_gfx->extendPalette(palette);
+	_gfx->setPalette(palette);
 	_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
 
 	if (_location._commands.size() > 0) {
@@ -404,7 +404,7 @@
 	runJobs();
 	_gfx->swapBuffers();
 
-	_gfx->extendPalette(_gfx->_palette);
+	_gfx->setPalette(_gfx->_palette);
 	if (_location._aCommands.size() > 0) {
 		runCommands(_location._aCommands);
 		debugC(1, kDebugLocation, "changeLocation: location acommands run");
@@ -432,7 +432,7 @@
 
 	byte pal[PALETTE_SIZE];
 	_gfx->buildBWPalette(pal);
-	_gfx->setPalette(pal, FIRST_BASE_COLOR, BASE_PALETTE_COLORS);
+	_gfx->setPalette(pal);
 
 	jobRunScripts(NULL, NULL);
 	jobEraseAnimations(NULL, NULL);

Modified: scummvm/trunk/engines/parallaction/menu.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/menu.cpp	2007-04-20 11:44:51 UTC (rev 26552)
+++ scummvm/trunk/engines/parallaction/menu.cpp	2007-04-21 12:51:40 UTC (rev 26553)
@@ -108,12 +108,12 @@
 	_vm->_gfx->_proportionalFont = false;
 
 	_vm->_disk->loadSlide("intro");
-	_vm->_gfx->extendPalette(_vm->_gfx->_palette);
+	_vm->_gfx->setPalette(_vm->_gfx->_palette);
 	_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
 	g_system->delayMillis(2000);
 
 	_vm->_disk->loadSlide("minintro");
-	_vm->_gfx->extendPalette(_vm->_gfx->_palette);
+	_vm->_gfx->setPalette(_vm->_gfx->_palette);
 	_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
 	g_system->delayMillis(2000);
 
@@ -121,7 +121,7 @@
 		_vm->_gfx->setFont(kFontMenu);
 
 		_vm->_disk->loadSlide("lingua");
-		_vm->_gfx->extendPalette(_vm->_gfx->_palette);
+		_vm->_gfx->setPalette(_vm->_gfx->_palette);
 		_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
 
 		_vm->_gfx->displayString(60, 30, "SELECT LANGUAGE");
@@ -147,7 +147,7 @@
 	const char **v14 = introMsg3;
 
 	_vm->_disk->loadScenery("test", NULL);
-	_vm->_gfx->extendPalette(_vm->_gfx->_palette);
+	_vm->_gfx->setPalette(_vm->_gfx->_palette);
 	_vm->_gfx->swapBuffers();
 
 	uint16 _ax = (SCREEN_WIDTH - _vm->_gfx->getStringWidth(v14[0])) / 2;
@@ -221,7 +221,7 @@
 
 
 	_vm->_disk->loadSlide("restore");
-	_vm->_gfx->extendPalette(_vm->_gfx->_palette);
+	_vm->_gfx->setPalette(_vm->_gfx->_palette);
 	_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
 
 	_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBit2);
@@ -302,7 +302,7 @@
 
 	_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);	//
 	_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBit2);		//
-	_vm->_gfx->extendPalette(_vm->_gfx->_palette);
+	_vm->_gfx->setPalette(_vm->_gfx->_palette);
 
 	while (askPassword == true) {
 

Modified: scummvm/trunk/engines/parallaction/zone.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/zone.cpp	2007-04-20 11:44:51 UTC (rev 26552)
+++ scummvm/trunk/engines/parallaction/zone.cpp	2007-04-21 12:51:40 UTC (rev 26553)
@@ -336,6 +336,8 @@
 
 	if (data->_description == NULL) return;
 
+	_gfx->setHalfbriteMode(true);
+
 	char v68[PATH_LEN];
 	strcpy(v68, data->_filename);
 	data->_cnv = _disk->loadStatic(v68);
@@ -357,6 +359,8 @@
 	_gfx->updateScreen();
 
 	waitUntilLeftClick();
+
+	_gfx->setHalfbriteMode(false);
 	_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
 
 	return;


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