/* Coded by Sol/Trauma (aka Jari Komppa), public domain.
*
* "new style" txtfli - works better on non-80x50 flics.
*/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <i86.h>
#include <math.h>
#include "textfx2.h"
#include "fliflc.h"
int * textpalette;
int * framebuffer;
void waitframes(int numframes) {
for (;numframes;numframes--)
vrc();
}
void fli_frame2text(FLIDATA *flidata) {
int x,y,fbufpos,fli_ypos;
int xpos,ypos,xstep,ystep;
xstep=(flidata->x_size*(1<<16))/160;
ystep=(flidata->y_size*(1<<16))/100;
fbufpos=0;
for (y=0,ypos=0,fli_ypos=0;y<100;y++,ypos+=ystep,fli_ypos=(ypos>>16)*flidata->x_size)
for (x=0,xpos=0;x<160;x++,xpos+=xstep,fbufpos++)
*(framebuffer+fbufpos)=textpalette[*(flidata->framebuffer+fli_ypos+(xpos>>16))];
dump_160x(0,50,framebuffer);
}
void main(int argc,char **argv) {
FLIDATA * flic;
int a;
int speed;
if (argc<2) {
cprintf("------------------------------------------------------------------------------\r\n"
"TXTFLI_N - 80x50 Textmode Fli/Flc player by Sol_HSA aka Sol/Trauma.Version 1.2\r\n"
"<mailto:solar@compart.fi>\r\n"
"Usage: TXTFLI_N <.fli/flc file of any size> <speed>\r\n"
"(speed = retraces to wait before next frame, default 2)\r\n"
"------------------------------------------------------------------------------\r\n");
return;
}
build_colormap(1);
framebuffer=malloc(160*100*sizeof(int));
memset(framebuffer,0,160*100*sizeof(int));
flic=fli_open(argv[1],0);
speed=2;
if (argc>2)
speed=strtol(argv[2],0,10);
set80x50();
textpalette=malloc(sizeof(int)*256);
memset(textpalette,0,sizeof(int)*256);
while (!kbhit()) {
fli_renderframe(flic);
if (!flic->looped)
if (flic->palette_change) {
for (a=0;a<256;a++)
textpalette[a]=(*(flic->palette+a*3+2)<<18)+
(*(flic->palette+a*3+1)<<10)+
(*(flic->palette+a*3+0)<<2);
flic->palette_change=0;
}
fli_frame2text(flic);
waitframes(speed);
}
fli_zap(flic);
set80x25();
cprintf("Remember: EVERYTHING looks good while viewed from 20 meters in free fall.\r\n");
}