#pragma once


enum
{
	SCENEID0,
	SCENEID1,
	XFADE,
	VINEAMOUNT,
	TREEAMOUNT,
	HUMAN,
	TITLEFADE,
	TITLEPOS,
	TITLENOISE,
	TITLEWIPE,
	FACELEVEL,
	FACEBAL,
	FACEALPHA,
	FACEPULSEPROB,
	FACEBEND,
	SUNLEVEL,
	
	TALKWET,
	TALKDELAY,
	TALKFB,
	TALKTS,
	TALKPITCH,


	TALKNOJUMP,

	CENTRO,
	RAINFALL,
	STARFADE,
	STARWIPE,

	CREDALPHA,

	TRIGGER,

	OVERALLVOL,
	
	LASTCHAN
};

void InitFilmOut();
void InitFilm();
void CloseFilm();

#define MAXFRAME (160*25)


#define AVIFPS 25
#define MBLURFAC 4
#define FPS (AVIFPS*MBLURFAC)
#define DT (1.f/FPS)

/*

*/
//#define CUTOFF 3820

//#define STARTPOS (3600/4)
//#define CUTOFF 3819

#define STARTPOS 0
#define CUTOFF 0

#define FULLXRES 720
#define FULLYRES 540

//#define AUDIOVIDEO
#define FINAL
#ifndef FINAL
#define SHITE
#ifdef SHITE
#define TOPNTAIL ((576-540)/8)
#define XRES (720/4)
#define YRES (540/4)
#define HALFMODE 2
#else
#define TOPNTAIL ((576-540)/4)
#define XRES (720/2)
#define YRES (540/2)
#define HALFMODE 1
#endif
#else
#define TOPNTAIL ((576-540)/2)
#define XRES 720
#define YRES (540)
#define HALFMODE 0             

#endif

#define RES(x) (((x)*XRES)/(512))


struct stereo
{
	short l,r;
};

struct fstereo
{
	float l,r;
};

class CThingDoc;

//typedef int CALLBACK RenderProc(float time, float dt, fstereo *audio, CThingDoc *doc);

struct RenderThing
{
	virtual int Do(float time, float dt, stereo *audio, CThingDoc *doc) = 0;

	RenderThing() {}
	virtual ~RenderThing() {}
};

extern RenderThing *audioproc;
extern RenderThing *videoproc;

#include "soundout.h"

void InitFilm(CThingDoc *doc, int realt);
void CloseFilm();
void RenderFrame();

void __cdecl Report3D(const char *pFormat,... );

typedef Surface surf;

extern v3 maxp,minp,mulp;
extern surf *backbuf;
extern RenderThing *audioproc;
extern RenderThing *videoproc;
extern int realtime;
extern CThingDoc *thedoc;
extern SoundOut *soundout;
extern stereo AudioBlock[BLOCKSIZE];
extern stereo TempAudioBlock[BLOCKSIZE];
extern int finited;

typedef std::pair<int,int> IntPair;

typedef std::set<IntPair> IntPairSet;
typedef std::vector<Vector3> PointList;


enum CLASSY
{
	COINCIDENT,
	INBACK,
	INFRONT,
	SPANNING,
};

#define EPS 0.0001f

#include "thingdoc.h"
#include "d3d.h"



