
#include "includes.h"
#include "File.H"
#include "Objects.H"


char    Textbuff [256*256+1024];
char    Buffer  [320*200];

char    MoveDatOri [320*200][2];

long    MoveDatBuf [320*200];
long    MorphDatBuf [320*200];

long   *MoveDat [320*200];
long   *MorphDat [320*200];



long StartTime,EndTime,Frames=0;
FILE *fp;
int i,x,y,n;
long e,f;

void main(int argc,char *argv[])

{


  fp=fopen("star1.bin","rb");
  if (fp!=NULL)
  {
   fread(&MoveDatOri,1,320*200*2,fp);
   fclose(fp);
  };

  fp=fopen("palpic.mix","rb");
  if (fp!=NULL)
  {
   fread(&Palette,1,768,fp);
   fclose(fp);
  };


    *MoveDat=&MoveDatBuf;
    *MorphDat=&MorphDatBuf;

    Screen=(long)&Buffer;
    Texture=(long)&Textbuff;

// Init Morphingdat

    i=0;
    for (y=0;y<200;y++ )
    {
    e=0;
    f=256*256/320;
      for ( x=0;x<320;x++ )
      {
        MorphDatBuf[i]=((y*256)-( MoveDatOri[i][0]*256))/210+(((e)-(MoveDatOri[i][1]*256))/210)*0x10000;

//        MoveDatBuf[i]=(e+y*65536*256)&0xff00ff00;
        MoveDatBuf[i]=(( (unsigned long) (MoveDatOri[i][0]) )*256)+( ( (unsigned long) (MoveDatOri[i][1]) )*256*65536);

        e+=f;
        i++;
      }
    }


    Texture=(long)LoadPCX("palpic.pcx");


    ASM_InitView ();

    InitSinusTab();

    installKbdInt();
    StartTime=clock();


    while (!kbd_matrix[KBDSC_ESC])
    {
     if (Frames<211 ) ASM_MakeWorldView ();
     ASM_UpdateGFX_V();

     Frames++;
    }

    EndTime=clock();

    ASM_Shutdown ();

    uninstallKbdInt();

    printf("\nFrames: %ld\nFrames/sec: %2.1f\n",(Frames),(float)Frames/((EndTime-StartTime)/CLOCKS_PER_SEC));

};
