Skip to content

Commit f536991

Browse files
committed
hax?
1 parent 9568f77 commit f536991

5 files changed

Lines changed: 29 additions & 13 deletions

File tree

src/Engine/Flc.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ int FlcCheckHeader(const char *filename)
114114
printf("flc.HeaderWidth: %d\n", flc.HeaderWidth);
115115
printf("flc.HeaderHeight: %d\n", flc.HeaderHeight);
116116
printf("flc.HeaderDepth: %d\n", flc.HeaderDepth);
117-
printf("flc.HeaderSpeed: %d\n", flc.HeaderSpeed);
117+
printf("flc.HeaderSpeed: %lf\n", flc.HeaderSpeed);
118118
#endif
119119

120120
if((flc.HeaderCheck==0x0AF12) || (flc.HeaderCheck==0x0AF11)) {
@@ -123,9 +123,7 @@ int FlcCheckHeader(const char *filename)
123123
Log(LOG_INFO) << "Playing flx, " << flc.screen_w << "x" << flc.screen_h << ", " << flc.HeaderFrames << " frames";
124124
flc.screen_depth=8;
125125
if(flc.HeaderCheck==0x0AF11) {
126-
flc.HeaderSpeed*=1000/70;
127-
// gross hack, let's set the framespeed to something not expressed in 1s/70 "jiffies"
128-
flc.HeaderSpeed = 1000/10; // 10FPS makes the end of the intro sync up perfectly! shame about the middle though?
126+
flc.HeaderSpeed*=1000.0/70.0;
129127
}
130128
return(0);
131129
}
@@ -137,18 +135,22 @@ int FlcCheckFrame()
137135
ReadU32(&flc.FrameSize, flc.pFrame+0);
138136
ReadU16(&flc.FrameCheck, flc.pFrame+4);
139137
ReadU16(&flc.FrameChunks, flc.pFrame+6);
138+
ReadU16(&flc.DelayOverride, flc.pFrame+8); // not actually used in UFOINT.FLI, it turns out
140139

141140
#ifdef DEBUG
142141
printf("flc.FrameSize: %d\n", flc.FrameSize);
143142
printf("flc.FrameCheck: %d\n", flc.FrameCheck);
144143
printf("flc.FrameChunks: %d\n", flc.FrameChunks);
144+
printf("flc.DelayOverride: %d\n", flc.DelayOverride);
145145
#endif
146146

147147
flc.pFrame+=16;
148148
if(flc.FrameCheck==0x0f1fa) {
149149
return(0);
150150
}
151151

152+
flc.DelayOverride = 0; // not FRAME_TYPE means the value we read wasn't a delay at all
153+
152154
if(flc.FrameCheck==0x0f100) {
153155
#ifdef DEBUG
154156
printf("Ani info!!!\n");
@@ -377,13 +379,15 @@ void FlcDoOneFrame()
377379
flc.pChunk=flc.pMembuf;
378380
if ( SDL_LockSurface(flc.mainscreen) < 0 )
379381
return;
382+
// if (!ChunkCount) printf("Empty frame! %d\n", flc.FrameCount); // this is normal and used for delays
380383
while(ChunkCount--) {
381384
ReadU32(&flc.ChunkSize, flc.pChunk+0);
382385
ReadU16(&flc.ChunkType, flc.pChunk+4);
383386

384387
#ifdef DEBUG
385388
printf("flc.ChunkSize: %d\n", flc.ChunkSize);
386-
printf("flc.ChunkType: %d\n", flc.ChunkType);
389+
printf("flc.ChunkType: %d aka %x\n", flc.ChunkType, flc.ChunkType);
390+
if (flc.DelayOverride) printf("DelayOverride: %d\n", flc.DelayOverride);
387391
#endif
388392

389393
switch(flc.ChunkType) {
@@ -422,20 +426,22 @@ void FlcDoOneFrame()
422426
} /* FlcDoOneFrame */
423427

424428
void SDLWaitFrame(void)
425-
{ static Uint32 oldTick=0.0;
429+
{ static double oldTick=0.0;
426430
Uint32 currentTick;
427-
int waitTicks;
431+
double waitTicks;
432+
double delay = flc.DelayOverride ? flc.DelayOverride : flc.HeaderSpeed;
428433

429434
if (oldTick == 0.0) oldTick = SDL_GetTicks();
430435

431436
currentTick=SDL_GetTicks();
432-
waitTicks=(oldTick+=(flc.HeaderSpeed))-currentTick;
437+
waitTicks=(oldTick+=(delay))-currentTick;
433438

434439

435440
do {
436-
waitTicks = (oldTick + flc.HeaderSpeed - SDL_GetTicks());
441+
waitTicks = (oldTick + delay - SDL_GetTicks());
437442

438443
if(waitTicks > 0.0) {
444+
//SDL_Delay(floor(waitTicks + 0.5)); // biased rounding? mehhh?
439445
SDL_Delay(1);
440446
}
441447
} while (waitTicks > 0.0);
@@ -536,14 +542,16 @@ void FlcMain(void (*frameCallBack)())
536542
}
537543
} /* FlcMain */
538544

545+
546+
#if 0
539547
void FlxplayHelp()
540548
{ printf("FLX player (%s) with SDL output (jasper@il.fontys.nl)\n", version);
541549
printf("View readme file for more information\n\n");
542550
printf("flxplay [-l] [filename]\n");
543551
exit(1);
544552
} /* FlxplayHelp */
545553

546-
#if 0
554+
547555
main(int argc, char **argv)
548556
{ int c;
549557

src/Engine/Flc.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,18 @@ struct Flc_t {
4545
Uint16 HeaderWidth; /* Fli width */
4646
Uint16 HeaderHeight; /* Fli heigth */
4747
Uint16 HeaderDepth; /* Color depth */
48-
Uint32 HeaderSpeed; /* Number of video ticks between frame */
48+
double HeaderSpeed; /* Number of video ticks between frame */
4949
Uint32 FrameSize; /* Frame size in bytes */
5050
Uint16 FrameCheck; /* Frame check */
5151
Uint16 FrameChunks; /* Number of chunks in frame */
5252
Uint32 ChunkSize; /* Size of chunk */
5353
Uint16 ChunkType; /* Type of chunk */
5454
/*
5555
*/
56+
// FRAME_TYPE extension, see http://www.compuphase.com/flic.htm
57+
Uint16 DelayOverride;
58+
//
59+
5660
SDL_Surface *mainscreen;
5761
Screen *realscreen;
5862
SDL_Color colors[256];

src/Engine/Screen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void Screen::flip()
155155
{
156156
if (_screen->format->BitsPerPixel == 8 && SDL_SetColors(_screen, &(deferredPalette[_firstColor]), _firstColor, _numColors) == 0)
157157
{
158-
Log(LOG_ERROR) << "Display palette doesn't match requested palette";
158+
Log(LOG_DEBUG) << "Display palette doesn't match requested palette";
159159
}
160160
_numColors = 0;
161161
_pushPalette = false;

src/Menu/StartState.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,17 +312,21 @@ static struct AudioSequence
312312
switch(Flc::flc.FrameCount)
313313
{
314314
case 0:
315+
Log(LOG_DEBUG) << "Playing gmintro1";
315316
m = rp->getMusic("GMINTRO1");
316317
m->play();
317318
break;
318319
case 180:
320+
Log(LOG_DEBUG) << "Playing gmintro2";
319321
m = rp->getMusic("GMINTRO2");
320322
m->play();
321323
break;
322324
case 382:
325+
Log(LOG_DEBUG) << "Playing gmintro3";
323326
m = rp->getMusic("GMINTRO3");
324327
m->play();
325328
Mix_HookMusicFinished(musicDone);
329+
Flc::flc.HeaderSpeed = 1000/10; // last part only syncs well at this fps or something; it is a mystery so far
326330
break;
327331
}
328332

src/OpenXcom.2010.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,4 +720,4 @@
720720
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
721721
<ImportGroup Label="ExtensionTargets">
722722
</ImportGroup>
723-
</Project>
723+
</Project>

0 commit comments

Comments
 (0)