mirror of
https://github.com/stevenhowes/CTheEscape.git
synced 2026-05-27 00:03:27 +01:00
125 lines
2.0 KiB
C
125 lines
2.0 KiB
C
#include <stdio.h>
|
|
#include "swis.h"
|
|
#include <kernel.h>
|
|
#include <time.h>
|
|
#include "Sound.h"
|
|
#include "Graphics.h"
|
|
|
|
#define SKIP_INTRO
|
|
#define SKIP_MISSION1
|
|
//#define SKIP_MISSION2
|
|
|
|
// SWI Registers
|
|
_kernel_swi_regs inreg;
|
|
_kernel_swi_regs outreg;
|
|
|
|
// Sprite buffer
|
|
unsigned char *buffer;
|
|
unsigned char *fontbuffer;
|
|
unsigned char *tilebuffer;
|
|
|
|
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();
|
|
extern void screen_nobuffer();
|
|
|
|
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;
|
|
}
|
|
|
|
void exitfunc () {
|
|
screen_flipbuffer();
|
|
screen_clear();
|
|
screen_flipbuffer();
|
|
screen_clear();
|
|
screen_nobuffer();
|
|
free(buffer);
|
|
free(fontbuffer);
|
|
free(tilebuffer);
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int lastoutcome = 1;
|
|
int outcome = 0;
|
|
|
|
atexit(exitfunc);
|
|
|
|
sound_on();
|
|
|
|
// Set initial display mode
|
|
display_mode(DISPLAY_MODE);
|
|
screen_clear();
|
|
|
|
// Load sprite library
|
|
load_sprites("Spr",&buffer);
|
|
load_sprites("Font",&fontbuffer);
|
|
|
|
#ifndef SKIP_INTRO
|
|
// Intro titles + music
|
|
intro();
|
|
#endif
|
|
|
|
// Clear both buffers or we get gibberish
|
|
screen_flipbuffer();
|
|
screen_clear();
|
|
screen_flipbuffer();
|
|
screen_clear();
|
|
|
|
#ifndef SKIP_MISSION1
|
|
// Mission 1
|
|
while(lastoutcome == 1)
|
|
{
|
|
outcome = 0;
|
|
game1_briefing();
|
|
screen_clear();
|
|
game1_setup();
|
|
while(!outcome)
|
|
{
|
|
outcome = game1_tick();
|
|
}
|
|
lastoutcome = outcome;
|
|
}
|
|
game1_victory();
|
|
#endif
|
|
|
|
#ifndef SKIP_MISSION2
|
|
lastoutcome = 1;
|
|
|
|
load_sprites("Tiles",&tilebuffer);
|
|
|
|
// Mission 2
|
|
while(lastoutcome == 1)
|
|
{
|
|
outcome = 0;
|
|
game2_briefing();
|
|
screen_clear();
|
|
game2_setup();
|
|
while(!outcome)
|
|
{
|
|
outcome = game2_tick();
|
|
}
|
|
lastoutcome = outcome;
|
|
}
|
|
#endif
|
|
|
|
free(buffer);
|
|
|
|
return 0;
|
|
}
|