

#ifdef __SW_OD

/////////////////////////
//#define MONO
#undef DEBUG
#define DEBUG
/////////////////////////

#ifdef MONO
//#define MONODEBUG
#endif
#endif

#ifdef __cplusplus
extern "C" {
#endif

#ifdef DEBUG
#define NOMUS
#endif
//#define NOMUS //WIN32TODO

extern int cval;

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// demo stuff

extern int nosnd;
extern int fxon;
extern void initfx();
extern void closefx();
extern int fxkeys();

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// demo1

extern void putpixel(int x,int y,int c);

extern void compose(void *dest, void *src, void *table);

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// general stuff

extern LONG findcol(SLONG r,SLONG g,SLONG b);
extern void computefade(unsigned char *fname);
extern void readfade(unsigned char *fname);
extern void computeghost(unsigned char *fname, SLONG alpha, SLONG beta);
extern void readghost(unsigned char *fname);

extern UBYTE zmaptab1[256];
extern UBYTE zmaptab2[256];
extern UBYTE zmaptab3[256];

extern UBYTE *screenbuf;
extern UBYTE *zbuf;
extern UBYTE *multab;
extern SLONG reciptab[2049];

extern SLONG edgebuf[200][2];

extern UBYTE *tex[8];
extern UBYTE *texptr;
extern UBYTE *fadeptr;
extern UBYTE *ghostptr;

extern UBYTE mypal[256][3];

extern void	monow(int ofs, unsigned char *str);

extern void addedge(int x1, int y1, int x2, int y2);
extern int flattri(void *dest, void *pts, int col); // returns the cval
extern int flatquad(void *dest, void *pts, int col); // returns the cval
extern int flatfill(void *dest, int col);	// returns the cval
extern int checkfill(void *dest, int col);	// returns # pixels drawn
extern void gouraudfill(void *dest, void *col, void *pts);
extern void texgoufill(void *dest, void *col, void *pts);
extern void resetedges();

extern int miny,maxy;

//extern void xcopy(void *dest, void *src, int y);
//extern void xcopy2(void *dest, void *src, void *src2);

extern void swapscreens(void *src=screenbuf, void *src2=NULL);
extern void swapscreens2(void *src=screenbuf);
extern void swapscreens3(void *src=screenbuf);


extern void unclippedline(int x1,int y1,int x2,int y2);
extern void calcsums();
extern void blurproc(void *dest, void *src);
extern void blendproc(void *dest, void *zbuf, void *src);
typedef struct
{
	SLONG u,v,col;
} PIN;

extern PIN pin[41][41];
extern void ghostcopy(void *dest, void *src);
extern void blurfade(void*dest, void *src);
extern void scalespr(SLONG x1, SLONG y1, SLONG x2, SLONG y2, void *dest,
					 SLONG bmpwid, SLONG bmphgt, UBYTE *bmpptr, int col);


extern int prev_int[2];

extern void drawpinmap48(void *srctex, void *dest);
extern void drawpinmap(void *srctex, void *dest);
extern void drawpinmapns(void *srctex, void *dest);
extern void drawpinmaptex(void *srctex, void *dest);

// utils.c

typedef void (*TIMERFN)();

extern SLONG fprocrate;	// frames per second
extern int dofproc(int pal=0);
extern void addfproc(TIMERFN p, int pal=0);
extern void removefproc(TIMERFN p);
extern void resetfproc();

extern void calcfocus(float f, float blurfactor);
extern void initdemo();
extern void closedemo();
extern void vidmode(int x);
extern void tweak(int tweak, int lines400);
extern BYTE getvidmode();

extern int mxv,myv,mx,my,mb;
extern void	GetMouseV();
extern void	GetMouse();

#define NOISETABSIZE 4096
extern unsigned char noisetab[NOISETABSIZE+16];
extern unsigned char noisetab2[NOISETABSIZE+16];
extern void noisefade(void *destsrc, unsigned char *yshades, int seed);
extern void quantum(void *dest, void*src,int seed);


// file stuff
typedef struct
{
	FILE *fi;
	UBYTE *buf;
	SLONG len;
} LFILE;
extern          SLONG   asmexpand(void *buf, SLONG amount);
#define BITS                       15
#define MAX_CODE                   ( ( 1 << BITS ) - 1 )
#define TABLE_SIZE                 35023L
#define END_OF_STREAM              256
#define BUMP_CODE                  257
#define FLUSH_CODE                 258
#define FIRST_CODE                 259
#define UNUSED                     -1
extern unsigned char decode_stack[ TABLE_SIZE ];
extern ULONG next_code;
extern SLONG current_code_bits;
extern ULONG next_bump_code;
extern ULONG new_code;
extern ULONG old_code;
extern LONG character;
extern BYTE *RAMPtr,RAMRack,RAMMask;
extern LONG numdecode;
typedef struct {
    unsigned char character;
    SLONG code_value;
    SLONG parent_code;

} DICTIONARY;
extern DICTIONARY *dict;
extern void InitializeDictionary();
extern void InitializeStorage();
extern void FreeStorage();
extern	LFILE*	openf(unsigned char *fname);
extern	LFILE*	openflzw(unsigned char *fname);
extern	void	closef(LFILE *fi);
extern	SLONG	readf(LFILE *fi, void *buf, SLONG count);
extern	SLONG	seekf(LFILE *fi, SLONG pos);
extern  void	resetlzw(LFILE *f);
extern  SLONG	seeklzw(LFILE *f, SLONG pos);
extern	SLONG	readflzw(LFILE *fi, void *buf, SLONG count);
extern	void	closelibf();
extern	SLONG	openlibf(unsigned char *fname);
extern	void	InitialiseStorage();
extern	void	FreeStorage();
extern	void	InitializeDictionary();
extern	LONG	RAMReadBits(LONG n);

extern void beep();
extern void beepon();
extern void beepoff();

//#ifdef DEBUG

#define free MYFREE
#define malloc MYMALLOC
#define calloc MYCALLOC
#define realloc MYREALLOC

extern void *MYCALLOC( size_t num, size_t size );
extern void *MYMALLOC( size_t size );
extern void *MYREALLOC( void *memblock, size_t size );
extern void MYFREE( void *memblock );
extern void *testmalloc( size_t size );
extern SLONG curalloc,maxalloc;
//#endif

extern void error(unsigned char *s);


#ifdef __cplusplus
}
#endif

