Explorar el Código

Support for videos in 16 bpp. Minor fixes.

Michał W. Urbańczyk hace 15 años
padre
commit
afe84deb03
Se han modificado 2 ficheros con 33 adiciones y 10 borrados
  1. 2 2
      hch/CObjectHandler.cpp
  2. 31 8
      hch/CVideoHandler.cpp

+ 2 - 2
hch/CObjectHandler.cpp

@@ -2202,7 +2202,7 @@ ui8 CGTownInstance::getPassableness() const
 	if ( tempOwner == 255 )//neutral guarded - noone can visit
 		return 0;
 		
-	ui8 mask;
+	ui8 mask = 0;
 	TeamState * ts = cb->gameState()->getPlayerTeam(tempOwner);
 	BOOST_FOREACH(ui8 it, ts->players)
 		mask |= 1<<it;//allies - add to possible visitors
@@ -5287,7 +5287,7 @@ ui8 CGGarrison::getPassableness() const
 	if ( tempOwner == 255 )//neutral guarded - noone can visit
 		return 0;
 		
-	ui8 mask;
+	ui8 mask = 0;
 	TeamState * ts = cb->gameState()->getPlayerTeam(tempOwner);
 	BOOST_FOREACH(ui8 it, ts->players)
 		mask |= 1<<it;//allies - add to possible visitors

+ 31 - 8
hch/CVideoHandler.cpp

@@ -188,6 +188,9 @@ void CBIKHandler::show( int x, int y, SDL_Surface *dst, bool update )
 
 	switch(Bpp)
 	{
+	case 2:
+		mode = 3; //565, mode 2 is 555 probably
+		break;
 	case 3:
 		mode = 0;
 		break;
@@ -351,18 +354,38 @@ void CSmackPlayer::redraw( int x, int y, SDL_Surface *dst, bool update )
 
 	// draw the frame
 	Uint16* addr = (Uint16*) (buffer+w*(h-1)*2-2);
-	for( int j=0; j<h-1; j++)	// why -1 ?
+	if(dst->format->BytesPerPixel >= 3)
 	{
-		for ( int i=w-1; i>=0; i--)
+		for( int j=0; j<h-1; j++)	// why -1 ?
 		{
-			Uint16 pixel = *addr;
+			for ( int i=w-1; i>=0; i--)
+			{
+				Uint16 pixel = *addr;
 
-			Uint8 *p = (Uint8 *)dst->pixels + (j+y) * dst->pitch + (i + x) * dst->format->BytesPerPixel;
-			p[2] = ((pixel & 0x7c00) >> 10) * 8;
-			p[1] = ((pixel & 0x3e0) >> 5) * 8;
-			p[0] = ((pixel & 0x1F)) * 8;
+				Uint8 *p = (Uint8 *)dst->pixels + (j+y) * dst->pitch + (i + x) * dst->format->BytesPerPixel;
+				p[2] = ((pixel & 0x7c00) >> 10) * 8;
+				p[1] = ((pixel & 0x3e0) >> 5) * 8;
+				p[0] = ((pixel & 0x1F)) * 8;
 
-			addr--;
+				addr--;
+			}
+		}
+	}
+	else if(dst->format->BytesPerPixel == 2)
+	{
+		for( int j=0; j<h-1; j++)	// why -1 ?
+		{
+			for ( int i=w-1; i>=0; i--)
+			{
+				//convert rgb 555 to 565
+				Uint16 pixel = *addr;
+				Uint16 *p = (Uint16 *)((Uint8 *)dst->pixels + (j+y) * dst->pitch + (i + x) * dst->format->BytesPerPixel);
+				*p =	(pixel & 0x1F) 
+					  +	((pixel & 0x3e0) << 1)
+					  +	((pixel & 0x7c00) << 1);
+
+				addr--;
+			}
 		}
 	}