Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ bin/
*.exe
opentitus
*.dge
*.swp
tags
4 changes: 2 additions & 2 deletions include/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
//#include "SDL/SDL_mixer.h"

int initaudio();
int freeaudio();
void freeaudio();
int SELECT_MUSIC(int song_number);
int WAIT_SONG();
int FX_START(int fx_number);
int RETURN_MUSIC();
int startmusic();
int refreshaudio();
void refreshaudio();


/*
Expand Down
4 changes: 2 additions & 2 deletions include/backbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include "SDL/SDL.h"

SDL_Surface *screen; //Backbuffer
SDL_Surface *tilescreen; //Tile screen
extern SDL_Surface *screen; //Backbuffer
extern SDL_Surface *tilescreen; //Tile screen

#endif
1 change: 1 addition & 0 deletions include/draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ int view_password(TITUS_level *level, uint8 level_index);
int loadpixelformat(SDL_PixelFormat **pixelformat);
int loadpixelformat_font(SDL_PixelFormat **pixelformat);
int freepixelformat(SDL_PixelFormat **pixelformat);
void DISPLAY_SPRITES(TITUS_level *level);

#endif

2 changes: 2 additions & 0 deletions include/enemies.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
#include "SDL/SDL.h"
#include "level.h"

extern uint8 INVULNERABLE_FLAG; //When non-zero, boss is invulnerable

int MOVE_NMI(TITUS_level *level);
int SET_NMI(TITUS_level *level);
int MOVE_TRASH(TITUS_level *level);
int updateenemysprite(TITUS_level *level, TITUS_enemy *enemy, int16 number, bool clearflags);

#endif
3 changes: 3 additions & 0 deletions include/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@

#include "SDL/SDL.h"

extern bool GAMEOVER_FLAG; //triggers a game over
extern uint16 IMAGE_COUNTER; //Increased every loop in game loop (0 to 0x0FFF)

int playtitus(int firstlevel);

#endif
Expand Down
3 changes: 0 additions & 3 deletions include/fonts.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ struct _TITUS_font {
void *sub[256]; //May be malloced
};

TITUS_font *font; //Malloced
SDL_Surface *font_undefined; //Pointer

int loadfonts(void);
int freefonts(void);

Expand Down
2 changes: 2 additions & 0 deletions include/gates.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "SDL/SDL.h"
#include "level.h"

extern int16 XLIMIT; //The engine will not scroll past this tile before the player have crossed the line (X)

int CROSSING_GATE(TITUS_level *level); //Check and handle level completion, and if the player does a kneestand on a secret entrance
int CLOSE_SCREEN();
int OPEN_SCREEN();
Expand Down
83 changes: 13 additions & 70 deletions include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,88 +149,31 @@
#define int16 signed short int


uint8 RESETLEVEL_FLAG;
bool GAMEOVER_FLAG; //triggers a game over
uint8 BAR_FLAG; //timer for health bar
bool X_FLAG; //true if left or right key is pressed
bool Y_FLAG; //true if up or down key is pressed
uint8 CHOC_FLAG; //headache timer
uint8 action; //player sprite array
uint8 KICK_FLAG; //hit/burn timer
bool GRANDBRULE_FLAG; //If set, player will be "burned" when hit (fireballs)
bool LADDER_FLAG; //True if in a ladder
bool PRIER_FLAG; //True if player is forced into kneestanding because of low ceiling
uint8 SAUT_FLAG; //6 if free fall or in the middle of a jump, decremented if on solid surface. Must be 0 to initiate a jump.
uint8 LAST_ORDER; //Last action (kneestand + jump = silent walk)
uint8 FURTIF_FLAG; //Silent walk timer
bool DROP_FLAG; //True if an object is throwed forward
bool DROPREADY_FLAG;
bool CARRY_FLAG; //true if carrying something (add 16 to player sprite)
bool POSEREADY_FLAG;
uint8 ACTION_TIMER; //Frames since last action change
//TITUS_sprite sprite; //Player sprite
//TITUS_sprite sprite2; //Secondary player sprite (throwed objects, "hit" when object hits an enemy, smoke when object hits the floor)
uint8 INVULNERABLE_FLAG; //When non-zero, boss is invulnerable
uint8 TAPISFLY_FLAG; //When non-zero, the flying carpet is flying
uint8 CROSS_FLAG; //When non-zero, fall through certain floors (after key down)
uint8 GRAVITY_FLAG; //When zero, skip object gravity function
uint8 FUME_FLAG; //Smoke when object hits the floor
Uint8 *keystate; //Keyboard state
uint8 LIFE; //Lives
uint8 YFALL;
bool POCKET_FLAG;
bool PERMUT_FLAG; //If false, there are no animated tiles on the screen?
uint8 loop_cycle; //Increased every loop in game loop
uint8 tile_anim; //Current tile animation (0-1-2), changed every 4th game loop cycle
uint8 BITMAP_X; //Screen offset (X) in tiles
uint8 BITMAP_XM; //Point to the left tile in the tile screen (0 to 19)
uint8 BITMAP_Y; //Screen offset (Y) in tiles
uint8 BITMAP_YM; //Point to the top tile in the tile screen (0 to 11)
bool XSCROLL_CENTER; //If true, the screen will scroll in X
int16 XLIMIT_SCROLL; //If scrolling: scroll until player is in this tile (X)
int16 XLIMIT; //The engine will not scroll past this tile before the player have crossed the line (X)
bool YSCROLL_CENTER; //If true, the screen will scroll in Y
uint8 YLIMIT_SCROLL; //If scrolling: scroll until player is in this tile (Y)
uint8 ALTITUDE_ZERO; //The engine will not scroll below this tile before the player have gone below (Y)
int LAST_CLOCK; //Used for fixed framerate
uint16 IMAGE_COUNTER; //Increased every loop in game loop (0 to 0x0FFF)
int8 SENSX; //1: walk right, 0: stand still, -1: walk left, triggers the ACTION_TIMER if it changes
uint8 SAUT_COUNT; //Incremented from 0 to 3 when accelerating while jumping, stop acceleration upwards if >= 3
bool NOSCROLL_FLAG;
bool NEWLEVEL_FLAG; //Finish a level
uint8 BIGNMI_NBR; //Number of bosses that needs to be killed to finish
uint8 TAUPE_FLAG; //Used for enemies walking and popping up
uint8 TAPISWAIT_FLAG; //Flying carpet state
uint8 SEECHOC_FLAG; //Counter when hit
bool NFC_FLAG; //Skip NO_FAST_CPU
uint8 BIGNMI_POWER; //Lives of the boss
bool boss_alive; //True if the boss is alive
uint8 AUDIOMODE;

bool GODMODE; //If true, the player will not interfere with the enemies
bool NOCLIP; //If true, the player will move noclip
bool DISPLAYLOOPTIME; //If true, display loop time in milliseconds
uint8 LOOPTIME; //Loop time
uint8 SUBTIME[16]; //Sub time
uint16 FPS; //Frames pr second
uint16 FPS_LAST; //Frames pr second
uint16 LAST_CLOCK_CORR; //Correction to LAST_CLOCK
extern bool NOSCROLL_FLAG;
extern uint8 TAUPE_FLAG; //Used for enemies walking and popping up
extern uint8 TAPISWAIT_FLAG; //Flying carpet state
extern uint8 SEECHOC_FLAG; //Counter when hit
extern uint8 BIGNMI_POWER; //Lives of the boss
extern bool boss_alive; //True if the boss is alive
extern uint8 AUDIOMODE;

extern bool GODMODE; //If true, the player will not interfere with the enemies
extern bool NOCLIP; //If true, the player will move noclip
extern bool DISPLAYLOOPTIME; //If true, display loop time in milliseconds

typedef struct {
bool enabled;
uint16 NUM;
} SPRITE;

SPRITE sprites[256];
//SPRITE sprites[256];

typedef struct {
bool enabled;
uint16 NUM;
} SPRITEDATA;

SPRITEDATA spritedata[256];

uint16 level_code[16];
//SPRITEDATA spritedata[256];

#endif

2 changes: 2 additions & 0 deletions include/level.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ struct _TITUS_level {

};

extern uint8 ALTITUDE_ZERO; //The engine will not scroll below this tile before the player have gone below (Y)

int loadlevel(TITUS_level *level, unsigned char *leveldata, int leveldatasize, TITUS_spritedata **spritedata, TITUS_spritecache *spritecache, TITUS_objectdata **objectdata);
int freelevel(TITUS_level *level);
uint8 get_horizflag(TITUS_level *level, int16 tileY, int16 tileX);
Expand Down
5 changes: 4 additions & 1 deletion include/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
#include "SDL/SDL.h"
#include "level.h"

int move_objects(TITUS_level *level);
extern uint8 TAPISFLY_FLAG; //When non-zero, the flying carpet is flying
extern uint8 GRAVITY_FLAG; //When zero, skip object gravity function

void move_objects(TITUS_level *level);
bool SPRITES_VS_SPRITES (TITUS_level *level, TITUS_sprite *sprite1, TITUS_sprite *sprite1ref, TITUS_object **object2); //check if there is an object below that can support the input object
int updateobjectsprite(TITUS_level *level, TITUS_object *obj, int16 number, bool clearflags);
int loadobjects(TITUS_objectdata ***objects, uint16 *count);
Expand Down
46 changes: 23 additions & 23 deletions include/original.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,32 @@
int initoriginal();
int16 getlevelid(int16 levelnumber);

SDL_Color orig_palette_colour[16];
SDL_Color orig_palette_level_colour[16];
SDL_Color orig_palette_font_colour[16];
extern SDL_Color orig_palette_colour[16];
extern SDL_Color orig_palette_level_colour[16];
extern SDL_Color orig_palette_font_colour[16];

uint8 spritewidth[SPRITECOUNT];
uint8 spriteheight[SPRITECOUNT];
uint8 spritecollwidth[SPRITECOUNT];
uint8 spritecollheight[SPRITECOUNT];
uint8 spriterefwidth[SPRITECOUNT];
uint8 spriterefheight[SPRITECOUNT];
extern uint8 spritewidth[SPRITECOUNT];
extern uint8 spriteheight[SPRITECOUNT];
extern uint8 spritecollwidth[SPRITECOUNT];
extern uint8 spritecollheight[SPRITECOUNT];
extern uint8 spriterefwidth[SPRITECOUNT];
extern uint8 spriterefheight[SPRITECOUNT];

int16 anim_player[ANIM_PLAYER_COUNT][ANIM_PLAYER_MAX];
int16 anim_enemy[NMI_ANIM_TABLE_COUNT];
uint8 NMI_POWER[ORIG_LEVEL_COUNT];
uint8 LEVEL_MUSIC[ORIG_LEVEL_COUNT];
extern int16 anim_player[ANIM_PLAYER_COUNT][ANIM_PLAYER_MAX];
extern int16 anim_enemy[NMI_ANIM_TABLE_COUNT];
extern uint8 NMI_POWER[ORIG_LEVEL_COUNT];
extern uint8 LEVEL_MUSIC[ORIG_LEVEL_COUNT];

int16 anim_zoubida[ORIG_ANIM_MAX];
int16 anim_moktar[ORIG_ANIM_MAX];
int16 anim_smoke[ORIG_ANIM_MAX];
int16 COEUR_POS[ORIG_ANIM_MAX * 2];
extern int16 anim_zoubida[ORIG_ANIM_MAX];
extern int16 anim_moktar[ORIG_ANIM_MAX];
extern int16 anim_smoke[ORIG_ANIM_MAX];
extern int16 COEUR_POS[ORIG_ANIM_MAX * 2];

uint8 object_maxspeedY[ORIG_OBJECT_COUNT];
bool object_support[ORIG_OBJECT_COUNT]; //not support/support
bool object_bounce[ORIG_OBJECT_COUNT]; //not bounce/bounce against floor + player bounces (ball, all spring, yellow stone, squeezed ball, skateboard)
bool object_gravity[ORIG_OBJECT_COUNT]; //no gravity on throw/gravity (ball, all carpet, trolley, squeezed ball, garbage, grey stone, scooter, yellow bricks between the statues, skateboard, cage)
bool object_droptobottom[ORIG_OBJECT_COUNT]; //on drop, lands on ground/continue below ground(cave spikes, rolling rock, ambolt, safe, dead man with helicopter)
bool object_no_damage[ORIG_OBJECT_COUNT]; //weapon/not weapon(cage)
extern uint8 object_maxspeedY[ORIG_OBJECT_COUNT];
extern bool object_support[ORIG_OBJECT_COUNT]; //not support/support
extern bool object_bounce[ORIG_OBJECT_COUNT]; //not bounce/bounce against floor + player bounces (ball, all spring, yellow stone, squeezed ball, skateboard)
extern bool object_gravity[ORIG_OBJECT_COUNT]; //no gravity on throw/gravity (ball, all carpet, trolley, squeezed ball, garbage, grey stone, scooter, yellow bricks between the statues, skateboard, cage)
extern bool object_droptobottom[ORIG_OBJECT_COUNT]; //on drop, lands on ground/continue below ground(cave spikes, rolling rock, ambolt, safe, dead man with helicopter)
extern bool object_no_damage[ORIG_OBJECT_COUNT]; //weapon/not weapon(cage)

#endif
28 changes: 27 additions & 1 deletion include/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,35 @@
#include "SDL/SDL.h"
#include "level.h"

extern uint8 RESETLEVEL_FLAG;
extern uint8 BAR_FLAG; //timer for health bar
extern bool X_FLAG; //true if left or right key is pressed
extern bool Y_FLAG; //true if up or down key is pressed
extern uint8 CHOC_FLAG; //headache timer
extern uint8 action; //player sprite array
extern uint8 KICK_FLAG; //hit/burn timer
extern bool GRANDBRULE_FLAG; //If set, player will be "burned" when hit (fireballs)
extern bool LADDER_FLAG; //True if in a ladder
extern bool PRIER_FLAG; //True if player is forced into kneestanding because of low ceiling
extern uint8 SAUT_FLAG; //6 if free fall or in the middle of a jump, decremented if on solid surface. Must be 0 to initiate a jump.
extern uint8 LAST_ORDER; //Last action (kneestand + jump = silent walk)
extern uint8 FURTIF_FLAG; //Silent walk timer
extern bool DROP_FLAG; //True if an object is throwed forward
extern bool DROPREADY_FLAG;
extern bool CARRY_FLAG; //true if carrying something (add 16 to player sprite)
extern bool POSEREADY_FLAG;
extern uint8 ACTION_TIMER; //Frames since last action change
extern uint8 CROSS_FLAG; //When non-zero, fall through certain floors (after key down)
extern uint8 FUME_FLAG; //Smoke when object hits the floor
extern Uint8 *keystate; //Keyboard state
extern uint8 YFALL;
extern bool POCKET_FLAG;
extern int8 SENSX; //1: walk right, 0: stand still, -1: walk left, triggers the ACTION_TIMER if it changes
extern uint8 SAUT_COUNT; //Incremented from 0 to 3 when accelerating while jumping, stop acceleration upwards if >= 3

int move_player(TITUS_level *level);
TITUS_object *FORCE_POSE(TITUS_level *level);

void DEC_ENERGY(TITUS_level *level);

#endif

3 changes: 3 additions & 0 deletions include/reset.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
#include "SDL/SDL.h"
#include "level.h"

extern bool NEWLEVEL_FLAG;

int INIT_SCREENM(TITUS_level *level);
int CLEAR_DATA(TITUS_level *level);
uint8 RESET_LEVEL(TITUS_level *level);

#endif

16 changes: 16 additions & 0 deletions include/scroll.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,24 @@

#include "SDL/SDL.h"

extern bool PERMUT_FLAG; //If false, there are no animated tiles on the screen?
extern uint8 loop_cycle; //Increased every loop in game loop
extern uint8 tile_anim; //Current tile animation (0-1-2), changed every 4th game loop cycle
extern uint8 BITMAP_X; //Screen offset (X) in tiles
extern uint8 BITMAP_XM; //Point to the left tile in the tile screen (0 to 19)
extern uint8 BITMAP_Y; //Screen offset (Y) in tiles
extern uint8 BITMAP_YM; //Point to the top tile in the tile screen (0 to 11)
extern bool XSCROLL_CENTER; //If true, the screen will scroll in X
extern int16 XLIMIT_SCROLL; //If scrolling: scroll until player is in this tile (X)
extern bool YSCROLL_CENTER; //If true, the screen will scroll in Y
extern uint8 YLIMIT_SCROLL; //If scrolling: scroll until player is in this tile (Y)

int scroll(TITUS_level *level);
int DISPLAY_CHAR(TITUS_level *level, uint8 tile, uint8 y, uint8 x);
bool L_SCROLL(TITUS_level *level);
bool R_SCROLL(TITUS_level *level);
bool U_SCROLL(TITUS_level *level);
bool D_SCROLL(TITUS_level *level);

#endif

Loading