#include <stdio.h>
#include "swis.h"
#include <kernel.h>
#include <time.h>
#include "Sound.h"
#include "Graphics.h"

// SWI Registers
_kernel_swi_regs inreg;
_kernel_swi_regs outreg;

// Sprite buffer
unsigned char *buffer;
extern int screen;
extern struct CompositionElement composition[128];
extern int current_element;
int lastprofile = 0;

int tick = 0;
int lasttick = 0;
extern int screen;

extern int game1_tick();
extern void game1_setup();

int game_hitbox_collide(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
{
    if((x1 + w1) >= x2)
      if(x1 <= (x2 + w2))
        if((y1 + h1) >= y2)
          if(y1 <= (y2 + h2))
            return 1;

  return 0;
}

int main(int argc, char *argv[])
{
  int lastoutcome = 0;
  sound_on();

  // Set initial display mode
  display_mode(DISPLAY_MODE);
  screen_clear();

  // Load sprite library
  load_sprites("Spr");

  // Intro titles + music
  intro();

  screen_clear();

  // Mission 1
  game1_setup();
  while(!lastoutcome)
  {
    lastoutcome = game1_tick();
  }

  free(buffer);

  return 0;
}
