3434#include " Flc.h"
3535#include " Logger.h"
3636#include " Exception.h"
37+ #include " Zoom.h"
3738
3839namespace OpenXcom
3940{
@@ -118,6 +119,7 @@ int FlcCheckHeader(const char *filename)
118119 if ((flc.HeaderCheck ==0x0AF12 ) || (flc.HeaderCheck ==0x0AF11 )) {
119120 flc.screen_w =flc.HeaderWidth ;
120121 flc.screen_h =flc.HeaderHeight ;
122+ Log (LOG_INFO ) << " Playing flx, " << flc.screen_w << " x" << flc.screen_h ;
121123 flc.screen_depth =8 ;
122124 if (flc.HeaderCheck ==0x0AF11 ) {
123125 flc.HeaderSpeed *=1000 /70 ;
@@ -176,8 +178,9 @@ void COLORS256()
176178 flc.colors [i].b =*(pSrc++);
177179 i++;
178180 }
179- // SDL_SetColors(flc.mainscreen, flc.colors, NumColorsSkip, i);
180- flc.mainscreen ->setPalette (flc.colors , NumColorsSkip, i);
181+ flc.realscreen ->setPalette (flc.colors , NumColorsSkip, i);
182+ SDL_SetColors (flc.mainscreen , flc.colors , NumColorsSkip, i);
183+ flc.realscreen ->getSurface (); // force palette update to really happen
181184 }
182185} /* COLORS256 */
183186
@@ -188,7 +191,7 @@ void SS2()
188191 Uint16 Lines, Count;
189192
190193 pSrc=flc.pChunk +6 ;
191- pDst=(Uint8*)flc.mainscreen ->getSurface ()-> getSurface ()-> pixels ;
194+ pDst=(Uint8*)flc.mainscreen ->pixels ;
192195 ReadU16 (&Lines, pSrc);
193196 pSrc+=2 ;
194197 while (Lines--) {
@@ -199,7 +202,7 @@ void SS2()
199202/* Upper bits 11 - Lines skip
200203*/
201204 if ((Count & 0xc000 )==0xc000 ) { // 0xc000h = 1100000000000000
202- pDst+=(0x10000 -Count)*flc.mainscreen ->getSurface ()-> getSurface ()-> pitch ;
205+ pDst+=(0x10000 -Count)*flc.mainscreen ->pitch ;
203206 }
204207
205208 if ((Count & 0xc000 )==0x4000 ) { // 0x4000h = 0100000000000000
@@ -236,7 +239,7 @@ void SS2()
236239 }
237240 }
238241 }
239- pDst+=flc.mainscreen ->getSurface ()-> getSurface ()-> pitch ;
242+ pDst+=flc.mainscreen ->pitch ;
240243 }
241244 }
242245} /* SS2 */
@@ -248,7 +251,7 @@ void DECODE_BRUN()
248251
249252 HeightCount=flc.HeaderHeight ;
250253 pSrc=flc.pChunk +6 ;
251- pDst=(Uint8*)flc.mainscreen ->getSurface ()-> getSurface ()-> pixels ;
254+ pDst=(Uint8*)flc.mainscreen ->pixels ;
252255 while (HeightCount--) {
253256 pTmpDst=pDst;
254257 PacketsCount=*(pSrc++);
@@ -268,7 +271,7 @@ void DECODE_BRUN()
268271 }
269272 }
270273 }
271- pDst+=flc.mainscreen ->getSurface ()-> getSurface ()-> pitch ;
274+ pDst+=flc.mainscreen ->pitch ;
272275 }
273276} /* DECODE_BRUN */
274277
@@ -282,11 +285,11 @@ void DECODE_LC()
282285 int PacketsCount;
283286
284287 pSrc=flc.pChunk +6 ;
285- pDst=(Uint8*)flc.mainscreen ->getSurface ()-> getSurface ()-> pixels ;
288+ pDst=(Uint8*)flc.mainscreen ->pixels ;
286289
287290 ReadU16 (&tmp, pSrc);
288291 pSrc+=2 ;
289- pDst+=tmp*flc.mainscreen ->getSurface ()-> getSurface ()-> pitch ;
292+ pDst+=tmp*flc.mainscreen ->pitch ;
290293 ReadU16 (&Lines, pSrc);
291294 pSrc+=2 ;
292295 while (Lines--) {
@@ -310,7 +313,7 @@ void DECODE_LC()
310313 }
311314 }
312315 }
313- pDst+=flc.mainscreen ->getSurface ()-> getSurface ()-> pitch ;
316+ pDst+=flc.mainscreen ->pitch ;
314317 }
315318} /* DECODE_LC */
316319
@@ -335,7 +338,7 @@ void DECODE_COLOR()
335338 flc.colors [i].b =*(pSrc++)<<2 ;
336339 i++;
337340 }
338- SDL_SetColors (flc.mainscreen -> getSurface ()-> getSurface () , flc.colors , NumColorsSkip, i);
341+ SDL_SetColors (flc.mainscreen , flc.colors , NumColorsSkip, i);
339342 }
340343} /* DECODE_COLOR */
341344
@@ -344,21 +347,21 @@ void DECODE_COPY()
344347{ Uint8 *pSrc, *pDst;
345348 int Lines = flc.screen_h ;
346349 pSrc=flc.pChunk +6 ;
347- pDst=(Uint8*)flc.mainscreen ->getSurface ()-> getSurface ()-> pixels ;
350+ pDst=(Uint8*)flc.mainscreen ->pixels ;
348351 while (Lines-- > 0 ) {
349352 memcpy (pDst, pSrc, flc.screen_w );
350353 pSrc+=flc.screen_w ;
351- pDst+=flc.mainscreen ->getSurface ()-> getSurface ()-> pitch ;
354+ pDst+=flc.mainscreen ->pitch ;
352355 }
353356} /* DECODE_COPY */
354357
355358void BLACK ()
356359{ Uint8 *pDst;
357360 int Lines = flc.screen_h ;
358- pDst=(Uint8*)flc.mainscreen ->getSurface ()-> getSurface ()-> pixels ;
361+ pDst=(Uint8*)flc.mainscreen ->pixels ;
359362 while (Lines-- > 0 ) {
360363 memset (pDst, 0 , flc.screen_w );
361- pDst+=flc.mainscreen ->getSurface ()-> getSurface ()-> pitch ;
364+ pDst+=flc.mainscreen ->pitch ;
362365 }
363366} /* BLACK */
364367
@@ -367,7 +370,7 @@ void FlcDoOneFrame()
367370{ int ChunkCount;
368371 ChunkCount=flc.FrameChunks ;
369372 flc.pChunk =flc.pMembuf ;
370- if ( SDL_LockSurface (flc.mainscreen -> getSurface ()-> getSurface () ) < 0 )
373+ if ( SDL_LockSurface (flc.mainscreen ) < 0 )
371374 return ;
372375 while (ChunkCount--) {
373376 ReadU32 (&flc.ChunkSize , flc.pChunk +0 );
@@ -410,7 +413,7 @@ void FlcDoOneFrame()
410413 }
411414 flc.pChunk +=flc.ChunkSize ;
412415 }
413- SDL_UnlockSurface (flc.mainscreen -> getSurface ()-> getSurface () );
416+ SDL_UnlockSurface (flc.mainscreen );
414417} /* FlcDoOneFrame */
415418
416419void SDLWaitFrame (void )
@@ -443,15 +446,26 @@ int FlcInit(const char *filename)
443446 if (FlcCheckHeader (filename)) {
444447 Log (LOG_ERROR ) << " Flx file failed header check." ;
445448 // exit(1);
446- return -1 ;
449+ return -1 ;
447450 }
448- return 0 ;
451+ #if 0
452+ if (flc.realscreen->getSurface()->getSurface()->format->BitsPerPixel == 8)
453+ {
454+ flc.mainscreen = flc.realscreen->getSurface()->getSurface();
455+ } else
456+ {
457+ #endif
458+ flc.mainscreen = SDL_AllocSurface (SDL_SWSURFACE , flc.screen_w , flc.screen_h , 8 , 0 , 0 , 0 , 0 );
459+ // }
460+ return 0 ;
449461 // SDLInit(filename);
450462} /* FlcInit */
451463
452464void FlcDeInit ()
453- { fclose (flc.file );
454- free (flc.pMembuf );
465+ {
466+ if (flc.mainscreen != flc.realscreen ->getSurface ()->getSurface ()) SDL_FreeSurface (flc.mainscreen );
467+ fclose (flc.file );
468+ free (flc.pMembuf );
455469} /* FlcDeInit */
456470
457471void FlcMain ()
@@ -482,17 +496,19 @@ void FlcMain()
482496 FlcDoOneFrame ();
483497 SDLWaitFrame ();
484498 /* TODO: Track which rectangles have really changed */
485- // SDL_UpdateRect(flc.mainscreen->getSurface()->getSurface(), 0, 0, 0, 0);
486- flc.mainscreen ->flip ();
499+ // SDL_UpdateRect(flc.mainscreen, 0, 0, 0, 0);
500+ if (flc.mainscreen != flc.realscreen ->getSurface ()->getSurface ()) SDL_BlitSurface (flc.mainscreen , 0 , flc.realscreen ->getSurface ()->getSurface (), 0 );
501+ flc.realscreen ->flip ();
487502 }
488503
489504 while (SDL_PollEvent (&event)) {
490505 switch (event.type ) {
506+ case SDL_MOUSEBUTTONDOWN :
491507 case SDL_KEYDOWN :
492508 quit=1 ;
493509 break ;
494510 case SDL_QUIT :
495- quit= 1 ;
511+ exit ( 0 ) ;
496512 default :
497513 break ;
498514 }
0 commit comments