Skip to content

Commit

Permalink
More work to avoid multiple definitions on recent gcc (for #21)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Sep 12, 2021
1 parent 29cdf17 commit e112bdb
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 44 deletions.
32 changes: 32 additions & 0 deletions src/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,39 @@ char musicStrings[9][14] = { "midi/main01",
"midi/main04",
"midi/main06" };

int collisionTiles[16][12];
PHL_Surface images[15];
PHL_Sound sounds[43];
PHL_Music bgmMusic;
PHL_Music bgmSecret;
PHL_Music bgmGameover;
Object* objects[MAX_OBJECTS];
Effect* effects[MAX_EFFECTS];
Weapon* weapons[MAX_WEAPONS];
Enemy* enemies[MAX_ENEMIES];
Platform* platforms[MAX_PLATFORMS];

int secretTimer;
unsigned long playTime;

Door* lastDoor;
int quakeTimer;
int bellFlag;
int bossFlag;
int bossDefeatedFlag;
int roomSecret;
char roomDarkness;

int itemGotX;
int itemGotY;

PHL_Background background, foreground;

unsigned char hasWeapon[5];
unsigned char hasItem[28];
unsigned char hasKey[8];

unsigned char flags[60];

double cutInTimer = 240;
int transitionTimer = 0;
Expand Down
58 changes: 29 additions & 29 deletions src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,63 +57,63 @@
#define CHN_ENEMIES 4
#define CHN_EFFECTS 5

Door* lastDoor;
extern Door* lastDoor;

int secretTimer;
int levelStartTimer;
int saveTimer;
extern int secretTimer;
extern int levelStartTimer;
extern int saveTimer;

int quakeTimer;
extern int quakeTimer;

int bellFlag;
int bossFlag;
int bossDefeatedFlag;
extern int bellFlag;
extern int bossFlag;
extern int bossDefeatedFlag;

char roomDarkness;
extern char roomDarkness;

//Used for item get message
int itemGotX;
int itemGotY;
extern int itemGotX;
extern int itemGotY;

int roomSecret;
extern int roomSecret;

int collisionTiles[16][12];
extern int collisionTiles[16][12];

//Playtime in frames. At 60 frames per second can hold ~828 1/2 days worth of playtime if my math isn't shit
unsigned long playTime;
extern unsigned long playTime;

//Inventory
unsigned char hasWeapon[5];
unsigned char hasItem[28];
unsigned char hasKey[8];
extern unsigned char hasWeapon[5];
extern unsigned char hasItem[28];
extern unsigned char hasKey[8];

//Save data flags
unsigned char flags[60];
extern unsigned char flags[60];

PHL_Background background,
extern PHL_Background background,
foreground;

//Game assets
PHL_Surface images[15];
PHL_Music bgmMusic;
PHL_Music bgmSecret;
PHL_Music bgmGameover;
PHL_Sound sounds[43];
extern PHL_Surface images[15];
extern PHL_Music bgmMusic;
extern PHL_Music bgmSecret;
extern PHL_Music bgmGameover;
extern PHL_Sound sounds[43];

#define MAX_WEAPONS 5
Weapon* weapons[MAX_WEAPONS];
extern Weapon* weapons[MAX_WEAPONS];

#define MAX_OBJECTS 40
Object* objects[MAX_OBJECTS];
extern Object* objects[MAX_OBJECTS];

#define MAX_ENEMIES 20
Enemy* enemies[MAX_ENEMIES];
extern Enemy* enemies[MAX_ENEMIES];

#define MAX_EFFECTS 30
Effect* effects[MAX_EFFECTS];
extern Effect* effects[MAX_EFFECTS];

#define MAX_PLATFORMS 10
Platform* platforms[MAX_PLATFORMS];
extern Platform* platforms[MAX_PLATFORMS];

//Graphic names
#define imgTiles 0
Expand Down
8 changes: 8 additions & 0 deletions src/hero.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ const char QUAKE = 9;

int state;

double herox, heroy;
double herohp, maxhp;
int heroAmmo, maxAmmo;
int heroWeapon;

Mask heroMask;
Mask shieldMask;

void updateMask();
void heroChangeScreen(int dx, int dy);

Expand Down
12 changes: 6 additions & 6 deletions src/hero.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
#include "PHL.h"
#include "collision.h"

double herox, heroy;
double herohp, maxhp;
int heroAmmo, maxAmmo;
int heroWeapon;
extern double herox, heroy;
extern double herohp, maxhp;
extern int heroAmmo, maxAmmo;
extern int heroWeapon;

Mask heroMask;
Mask shieldMask;
extern Mask heroMask;
extern Mask shieldMask;

void heroSetup();
void heroCleanup();
Expand Down
1 change: 1 addition & 0 deletions src/qda.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "amigaos.h"
#endif

QDAHeader headers[29];
//Load headers for each image
//Returns: 0 = file not found | 1 = success | 2 = Invalid file
int initQDA()
Expand Down
2 changes: 1 addition & 1 deletion src/qda.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ typedef struct {
unsigned char* fileName[256];
} QDAHeader;

QDAHeader headers[29]; //names, offsets, and sizes of each sheet
extern QDAHeader headers[29]; //names, offsets, and sizes of each sheet
int initQDA();

#endif
2 changes: 1 addition & 1 deletion src/stagedata.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef STAGEDATA_H
#define STAGEDATA_H

int stage[9][96];
extern int stage[9][96];

#endif
8 changes: 8 additions & 0 deletions src/text.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
#include "PHL.h"
#include "game.h"

char gameLanguage;
Message* saving;
Message* saveError[3];
Message* itemName[41];
Message* found;
Message* itemDescription[28];
Message* dungeon[8];

void loadMessage(Message* m, FILE* f);
void trimMessage(Message* m);

Expand Down
14 changes: 7 additions & 7 deletions src/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
#define JAPANESE 0
#define ENGLISH 1

char gameLanguage;
extern char gameLanguage;

typedef struct {
unsigned char x[32];
unsigned char y[32];
char length;
} Message;

Message* saving;
Message* saveError[3];
Message* itemName[41];
Message* found;
Message* itemDescription[28];
Message* dungeon[8];
extern Message* saving;
extern Message* saveError[3];
extern Message* itemName[41];
extern Message* found;
extern Message* itemDescription[28];
extern Message* dungeon[8];

void textInit();
void textFree();
Expand Down

0 comments on commit e112bdb

Please sign in to comment.