#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "globals.h"

volatile int ticks=0;
volatile int think=0;
volatile int race_ticks=0;
BITMAP *drawable;
DATAFILE *data;
int nships=2;
int nplayers=1;
int width=640;
int height=480;
int depth=16;
Map *map;
char *track="29.pcx";
Ship **ships;
volatile int fps=0;
volatile int frames=0;
int *voices;
int horz=1;
int joystick=0;
BITMAP *bg;
PALETTE palette;
int water=1;
BITMAP *water1;
BITMAP *water2;
MIDI *midi=NULL;
int ass_level=1;
int wind=1;
int trans=1;
int marker=0;
int clockmode=0;
int scores[4];
int showfps=0;
int training=0;
int nosound=0;
int nomusic=0;
int wait_vsync=0;

#ifdef DEBUG
int Log(char *msg,...)
{
  va_list ap;
  FILE *f=fopen("log.txt","a+t");
  va_start(ap,msg);
  vfprintf(f,msg,ap);
  fclose(f);
  va_end(ap);
  return 1;
}
#endif

void DoError(char *msg,...)
{
  va_list ap;
  static char outmsg[4000];
  va_start(ap,msg);
  vsprintf(outmsg,msg,ap);
  va_end(ap);
  strcat(outmsg,"\007\n");
  set_gfx_mode(GFX_TEXT,80,25,0,0);
  allegro_message(outmsg);
  exit(1);
}

int CheckCollision(
  int x1,int y1,int w1,int h1,int x2,int y2,int w2,int h2
)
{
  if (x1+w1-1<x2) return 0;
  if (x2+w2-1<x1) return 0;
  if (y1+h1-1<y2) return 0;
  if (h2+y2-1<y1) return 0;
  return 1;
}

