CFLAGS = $(OPTIONS) $(ANALYZE) $(SYS_CFLAGS) $(EXTRA_CFLAGS) $(CONFIG)
LDFLAGS = $(ANALYZE) $(SYS_LDFLAGS) $(EXTRA_LDFLAGS)
-# !!! DEPENDENCY TO GLIB SHOULD BE REMOVED AGAIN !!!
-GLIB_CFLAGS := $(shell pkg-config --cflags glib-2.0)
-GLIB_LDFLAGS := $(shell pkg-config --libs glib-2.0)
-
-CFLAGS := $(CFLAGS) $(GLIB_CFLAGS)
-LDFLAGS := $(LDFLAGS) $(GLIB_LDFLAGS)
-# !!! DEPENDENCY TO GLIB SHOULD BE REMOVED AGAIN !!!
-
SRCS = main.c \
conf_gfx.c \
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <glib.h>
-#include <glib/gi18n.h>
-
#include <errno.h>
#include "main_bd.h"
return FALSE;
}
-static boolean struct_set_property(gpointer str, const GdStructDescriptor *prop_desc,
+static boolean struct_set_property(void *str, const GdStructDescriptor *prop_desc,
const char *attrib, const char *param, int ratio)
{
char **params;
if (strcasecmp(prop_desc[i].identifier, attrib) == 0)
{
/* found the identifier */
- gpointer value = G_STRUCT_MEMBER_P(str, prop_desc[i].offset);
+ void *value = STRUCT_MEMBER_P(str, prop_desc[i].offset);
/* these point to the same, but to avoid the awkward cast syntax */
int *ivalue = value;
for (j = 0; j < prop_desc[i].count && params[paramindex] != NULL; j++)
{
boolean success = FALSE;
- gdouble res;
+ double res;
switch (prop_desc[i].type)
{
}
/* report all remaining tags; called after the above function. */
-static void replay_report_unknown_tags_func(const char *attrib, const char *param, gpointer data)
+static void replay_report_unknown_tags_func(const char *attrib, const char *param, void *data)
{
Warn("unknown replay tag '%s'", attrib);
}
}
/* report all remaining tags; called after the above function. */
-static void cave_report_and_copy_unknown_tags_func(char *attrib, char *param, gpointer data)
+static void cave_report_and_copy_unknown_tags_func(char *attrib, char *param, void *data)
{
GdCave *cave = (GdCave *)data;
strcasecmp(params[0], gd_cave_properties[i].identifier) == 0)
{
/* found identifier */
- gpointer value = G_STRUCT_MEMBER_P (cave, gd_cave_properties[i].offset);
+ void *value = STRUCT_MEMBER_P (cave, gd_cave_properties[i].offset);
*((GdElement *) value) = gd_get_element_from_string (params[1]);
break;
#ifndef BD_BDCFF_H
#define BD_BDCFF_H
-#include <glib.h>
-
boolean gd_caveset_load_from_bdcff(const char *contents);
-void gd_caveset_save_to_bdcff(GPtrArray *out);
#endif // BD_BDCFF_H
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <glib.h>
-#include <glib/gi18n.h>
-
#include "main_bd.h"
return perm;
}
-static GdElement bd1_import(guint8 c, int i)
+static GdElement bd1_import(byte c, int i)
{
- if (c < G_N_ELEMENTS(bd1_import_table))
+ if (c < ARRAY_SIZE(bd1_import_table))
return bd1_import_table[c];
Warn("Invalid BD1 element in imported file at cave data %d: %d", i, c);
}
/* deluxe caves 1 contained a special element, non-sloped brick. */
-static GdElement deluxecaves_1_import(guint8 c, int i)
+static GdElement deluxecaves_1_import(byte c, int i)
{
GdElement e = bd1_import(c, i);
return e;
}
-static GdElement firstboulder_import(guint8 c, int i)
+static GdElement firstboulder_import(byte c, int i)
{
- if (c < G_N_ELEMENTS(firstboulder_import_table))
+ if (c < ARRAY_SIZE(firstboulder_import_table))
return firstboulder_import_table[c];
Warn("Invalid 1stB element in imported file at cave data %d: %d", i, c);
return O_UNKNOWN;
}
-static GdElement crazylight_import(guint8 c, int i)
+static GdElement crazylight_import(byte c, int i)
{
- if (c < G_N_ELEMENTS(gd_crazylight_import_table))
+ if (c < ARRAY_SIZE(gd_crazylight_import_table))
return gd_crazylight_import_table[c] & O_MASK; /* & O_MASK: do not import "scanned" flag */
Warn("Invalid CrLi element in imported file at cave data %d: %d", i, c);
*/
/* import bd1 cave data into our format. */
-static int cave_copy_from_bd1(GdCave *cave, const guint8 *data, int remaining_bytes,
+static int cave_copy_from_bd1(GdCave *cave, const byte *data, int remaining_bytes,
GdCavefileFormat format)
{
int length, direction;
int index;
int level;
int x1, y1, x2, y2;
- guint8 code;
+ byte code;
GdElement elem;
- GdElement (* import_func) (guint8 c, int i);
+ GdElement (* import_func) (byte c, int i);
int i;
/* cant be shorted than this: header + no objects + delimiter */
case 1: /* 01: LINE */
x1 = data[index + 1];
y1 = data[index + 2] - 2;
- length = (gint8)data[index + 3] - 1;
+ length = (byte)data[index + 3] - 1;
direction = data[index + 4];
if (length < 0)
/* import bd2 cave data into our format. return number of bytes if pointer passed.
this is pretty much the same as above, only the encoding was different. */
-static int cave_copy_from_bd2(GdCave *cave, const guint8 *data, int remaining_bytes,
+static int cave_copy_from_bd2(GdCave *cave, const byte *data, int remaining_bytes,
GdCavefileFormat format)
{
int index;
/* import plck cave data into our format.
length is always 512 bytes, and contains if it is an intermission cave. */
-static int cave_copy_from_plck(GdCave *cave, const guint8 *data,
+static int cave_copy_from_plck(GdCave *cave, const byte *data,
int remaining_bytes, GdCavefileFormat format)
{
/* i don't really think that all this table is needed, but included to be complete. */
}
/* no one's delight boulder dash essentially: rle compressed plck maps. */
-static int cave_copy_from_dlb(GdCave *cave, const guint8 *data, int remaining_bytes)
+static int cave_copy_from_dlb(GdCave *cave, const byte *data, int remaining_bytes)
{
- guint8 decomp[512];
+ byte decomp[512];
enum
{
START, /* initial state */
NORMAL /* normal, copy bytes till separator */
} state;
int pos, cavepos, i, x, y;
- guint8 byte, separator;
+ byte byte, separator;
gd_cave_set_engine_defaults(cave, GD_ENGINE_PLCK); /* essentially the plck engine */
}
/* import plck cave data into our format. */
-static int cave_copy_from_1stb(GdCave *cave, const guint8 *data, int remaining_bytes)
+static int cave_copy_from_1stb(GdCave *cave, const byte *data, int remaining_bytes)
{
int i;
int x, y;
}
/* crazy dream 7 */
-static int cave_copy_from_crdr_7(GdCave *cave, const guint8 *data, int remaining_bytes)
+static int cave_copy_from_crdr_7(GdCave *cave, const byte *data, int remaining_bytes)
{
int i, index;
- guint8 checksum;
+ byte checksum;
/* if we have name, convert */
gd_strcpy(cave->name, " ");
return 15 + 0x49 + index;
}
-static void crazy_dream_9_add_specials(GdCave *cave, const guint8 *buf, const int length)
+static void crazy_dream_9_add_specials(GdCave *cave, const byte *buf, const int length)
{
- guint8 checksum;
+ byte checksum;
int i;
/* crazy dream 9 hack */
if (strEqual(cave->name, "Rockfall") && checksum == 134)
{
GdElement rand[4] = { O_DIAMOND, O_STONE, O_ACID, O_DIRT };
- gint32 prob[4] = { 37, 32, 2, 0 };
- gint32 seeds[5] = { -1, -1, -1, -1, -1 };
+ int prob[4] = { 37, 32, 2, 0 };
+ int seeds[5] = { -1, -1, -1, -1, -1 };
cave->objects = list_append(cave->objects, gd_object_new_random_fill(GD_OBJECT_LEVEL_ALL, 0, 0, 39, 21, seeds, O_DIRT, rand, prob, O_BLADDER_SPENDER, FALSE));
}
if (strEqual(cave->name, "Roll dice now!") && checksum == 235)
{
GdElement rand[4] = { O_STONE, O_BUTTER_3, O_DIRT, O_DIRT };
- gint32 prob[4] = { 0x18, 0x08, 0, 0 };
- gint32 seeds[5] = { -1, -1, -1, -1, -1 };
+ int prob[4] = { 0x18, 0x08, 0, 0 };
+ int seeds[5] = { -1, -1, -1, -1, -1 };
cave->objects = list_append(cave->objects, gd_object_new_random_fill(GD_OBJECT_LEVEL_ALL, 0, 0, 39, 21, seeds, O_DIRT, rand, prob, O_BLADDER_SPENDER, FALSE));
}
if (strEqual(cave->name, "Random maze") && checksum == 24)
{
- gint32 seeds[5] = { -1, -1, -1, -1, -1 };
+ int seeds[5] = { -1, -1, -1, -1, -1 };
cave->objects = list_append(cave->objects, gd_object_new_maze(GD_OBJECT_LEVEL_ALL, 1, 4, 35, 20, 1, 1, O_NONE, O_DIRT, 50, seeds));
}
if (strEqual(cave->name, "Metamorphosis") && checksum == 53)
{
- gint32 seeds[5] = { -1, -1, -1, -1, -1 };
+ int seeds[5] = { -1, -1, -1, -1, -1 };
GdElement rand[4] = { O_STONE, O_DIRT, O_DIRT, O_DIRT };
- gint32 prob[4] = { 0x18, 0, 0, 0 };
+ int prob[4] = { 0x18, 0, 0, 0 };
cave->objects = list_append(cave->objects, gd_object_new_maze(GD_OBJECT_LEVEL_ALL, 4, 1, 38, 19, 1, 3, O_NONE, O_BLADDER_SPENDER, 50, seeds));
cave->objects = list_append(cave->objects, gd_object_new_random_fill(GD_OBJECT_LEVEL_ALL, 4, 1, 38, 19, seeds, O_DIRT, rand, prob, O_BLADDER_SPENDER, FALSE));
if (strEqual(cave->name, "All the way") && checksum == 33)
{
- gint32 seeds[5] = { -1, -1, -1, -1, -1 };
+ int seeds[5] = { -1, -1, -1, -1, -1 };
cave->objects = list_append(cave->objects, gd_object_new_maze_unicursal(GD_OBJECT_LEVEL_ALL, 1, 1, 35, 19, 1, 1, O_BRICK, O_PRE_DIA_1, 50, seeds));
}
/* crazy light contruction kit */
-static int cave_copy_from_crli(GdCave *cave, const guint8 *data, int remaining_bytes)
+static int cave_copy_from_crli(GdCave *cave, const byte *data, int remaining_bytes)
{
- guint8 uncompressed[1024];
+ byte uncompressed[1024];
int datapos, cavepos, i, x, y;
boolean cavefile;
const char *versions[] = { "V2.2", "V2.6", "V3.0" };
V2_6,
V3_0
} version = none;
- GdElement (*import) (guint8 c, int i) = NULL; /* import function */
+ GdElement (*import) (byte c, int i) = NULL; /* import function */
gd_cave_set_engine_defaults(cave, GD_ENGINE_CRLI);
}
/* check crli version */
- for (i = 0; i < G_N_ELEMENTS(versions); i++)
+ for (i = 0; i < ARRAY_SIZE(versions); i++)
if (memcmp((char *)uncompressed + 0x3a0, versions[i], 4) == 0)
version = i + 1;
return datapos;
}
-GdCavefileFormat gd_caveset_imported_get_format(const guint8 *buf)
+GdCavefileFormat gd_caveset_imported_get_format(const byte *buf)
{
const char *s_bd1 = "GDashBD1";
const char *s_bd1_atari = "GDashB1A";
Loads the caveset from a memory buffer.
returns: List * of caves.
*/
-List *gd_caveset_import_from_buffer (const guint8 *buf, gsize length)
+List *gd_caveset_import_from_buffer (const byte *buf, size_t length)
{
boolean numbering;
int cavenum, intermissionnum, num;
int cavelength, bufp;
List *caveset = NULL, *iter;
- guint32 encodedlength;
+ unsigned int encodedlength;
GdCavefileFormat format;
if (length != -1 && length < 12)
return NULL;
}
- encodedlength = GUINT32_FROM_LE(*((guint32 *)(buf + 8)));
+ encodedlength = (unsigned int)(*((unsigned int *)(buf + 8)));
if (length != -1 && encodedlength != length - 12)
{
Warn("file length and data size mismatch in GDash datafile");
#ifndef BD_CAVEIMPORT_H
#define BD_CAVEIMPORT_H
-#include <glib.h>
-
#include "bd_cave.h"
extern const char *gd_engines[];
-GdCavefileFormat gd_caveset_imported_get_format(const guint8 *buf);
-List* gd_caveset_import_from_buffer (const guint8 *buf, gsize length);
+GdCavefileFormat gd_caveset_imported_get_format(const unsigned char *buf);
+List* gd_caveset_import_from_buffer (const unsigned char *buf, size_t length);
void gd_cave_set_engine_defaults(GdCave *cave, GdEngine engine);
GdEngine gd_cave_get_engine_from_string(const char *param);
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <glib.h>
-#include <glib/gi18n.h>
-
#include "main_bd.h"
{
int i;
- for (i = 1; i<G_N_ELEMENTS(direction_filename); i++)
+ for (i = 1; i < ARRAY_SIZE(direction_filename); i++)
if (strcasecmp(str, direction_filename[i]) == 0)
return (GdDirection) i;
{
int i;
- for (i = 0; i < G_N_ELEMENTS(scheduling_filename); i++)
+ for (i = 0; i < ARRAY_SIZE(scheduling_filename); i++)
if (strcasecmp(str, scheduling_filename[i]) == 0)
return (GdScheduling) i;
"properties" describes the structure and its pointers,
"defaults" are the pieces of data which will be copied to str.
*/
-void gd_struct_set_defaults_from_array(gpointer str,
+void gd_struct_set_defaults_from_array(void *str,
const GdStructDescriptor *properties,
GdPropertyDefault *defaults)
{
for (i = 0; defaults[i].offset != -1; i++)
{
- gpointer pvalue = G_STRUCT_MEMBER_P(str, defaults[i].offset);
+ void *pvalue = STRUCT_MEMBER_P(str, defaults[i].offset);
/* these point to the same, but to avoid the awkward cast syntax */
int *ivalue = pvalue;
GdElement *evalue = pvalue;
int i;
/* fill all with unknown */
- for (i = 0; i < G_N_ELEMENTS(gd_char_to_element); i++)
+ for (i = 0; i < ARRAY_SIZE(gd_char_to_element); i++)
gd_char_to_element[i] = O_UNKNOWN;
/* then set fixed characters */
}
/* search the element database for the specified character, and return the element. */
-GdElement gd_get_element_from_character (guint8 character)
+GdElement gd_get_element_from_character (byte character)
{
if (gd_char_to_element[character] != O_UNKNOWN)
return gd_char_to_element[character];
}
/* for quicksort. compares two highscores. */
-int gd_highscore_compare(gconstpointer a, gconstpointer b)
+int gd_highscore_compare(const void *a, const void *b)
{
const GdHighScore *ha = a;
const GdHighScore *hb = b;
allocate a cave map-like array, and initialize to zero.
one cell is cell_size bytes long.
*/
-gpointer gd_cave_map_new_for_cave(const GdCave *cave, const int cell_size)
+void *gd_cave_map_new_for_cave(const GdCave *cave, const int cell_size)
{
- gpointer *rows; /* this is void**, pointer to array of ... */
+ void **rows; /* this is void**, pointer to array of ... */
int y;
- rows = checked_malloc((cave->h) * sizeof(gpointer));
+ rows = checked_malloc((cave->h) * sizeof(void *));
rows[0] = checked_calloc(cell_size * cave->w * cave->h);
for (y = 1; y < cave->h; y++)
if map is null, this also returns null.
*/
-gpointer gd_cave_map_dup_size(const GdCave *cave, const gpointer map, const int cell_size)
+void *gd_cave_map_dup_size(const GdCave *cave, const void *map, const int cell_size)
{
- gpointer *rows;
- gpointer *maplines = (gpointer *)map;
+ void **rows;
+ void **maplines = (void **)map;
int y;
if (!map)
return NULL;
- rows = checked_malloc((cave->h) * sizeof(gpointer));
+ rows = checked_malloc((cave->h) * sizeof(void *));
rows[0] = get_memcpy (maplines[0], cell_size * cave->w * cave->h);
for (y = 1; y < cave->h; y++)
return rows;
}
-void gd_cave_map_free(gpointer map)
+void gd_cave_map_free(void *map)
{
- gpointer *maplines = (gpointer *) map;
+ void **maplines = (void **) map;
if (!map)
return;
/* free strings */
for (i = 0; gd_cave_properties[i].identifier != NULL; i++)
if (gd_cave_properties[i].type == GD_TYPE_LONGSTRING)
- checked_free(G_STRUCT_MEMBER(char *, cave, gd_cave_properties[i].offset));
+ checked_free(STRUCT_MEMBER(char *, cave, gd_cave_properties[i].offset));
/* map */
gd_cave_map_free(cave->map);
/* for longstrings */
for (i = 0; gd_cave_properties[i].identifier != NULL; i++)
if (gd_cave_properties[i].type == GD_TYPE_LONGSTRING)
- G_STRUCT_MEMBER(char *, dest, gd_cave_properties[i].offset) =
- getStringCopy(G_STRUCT_MEMBER(char *, src, gd_cave_properties[i].offset));
+ STRUCT_MEMBER(char *, dest, gd_cave_properties[i].offset) =
+ getStringCopy(STRUCT_MEMBER(char *, src, gd_cave_properties[i].offset));
/* no reason to copy this */
dest->objects_order = NULL;
void gd_replay_store_movement(GdReplay *replay, GdDirection player_move,
boolean player_fire, boolean suicide)
{
- guint8 data[1];
+ byte data[1];
data[0] = ((player_move) |
(player_fire ? GD_REPLAY_FIRE_MASK : 0) |
}
/* calculate adler checksum for a rendered cave; this can be used for more caves. */
-void gd_cave_adler_checksum_more(GdCave *cave, guint32 *a, guint32 *b)
+void gd_cave_adler_checksum_more(GdCave *cave, unsigned int *a, unsigned int *b)
{
int x, y;
}
/* calculate adler checksum for a single rendered cave. */
-guint32
-gd_cave_adler_checksum(GdCave *cave)
+unsigned int gd_cave_adler_checksum(GdCave *cave)
{
- guint32 a = 1;
- guint32 b = 0;
+ unsigned int a = 1;
+ unsigned int b = 0;
gd_cave_adler_checksum_more(cave, &a, &b);
return (b << 16) + a;
#ifndef BD_CAVE_H
#define BD_CAVE_H
-#include <glib.h>
-
#include "bd_elements.h"
#include "bd_random.h"
// colors
-typedef guint32 GdColor;
+typedef unsigned int GdColor;
/* color internal:
XXRRGGBB;
} GdPropertyDefault;
-void gd_struct_set_defaults_from_array(gpointer str, const GdStructDescriptor *properties, GdPropertyDefault *defaults);
+void gd_struct_set_defaults_from_array(void *str, const GdStructDescriptor *properties, GdPropertyDefault *defaults);
/* these define the number of the cells in the png file */
#define GD_NUM_OF_CELLS_X 8
typedef struct _gd_cave_replay
{
int level; /* replay for level n */
- guint32 seed; /* seed the cave is to be rendered with */
+ unsigned int seed; /* seed the cave is to be rendered with */
boolean saved; /* also store it in the saved bdcff */
GdString recorded_with; /* recorded with - application name and version */
int score; /* score collected */
int duration; /* number of seconds played */
boolean success; /* successful playing of cave? */
- guint32 checksum; /* checksum of the rendered cave. */
+ unsigned int checksum; /* checksum of the rendered cave. */
boolean wrong_checksum;
GdReplayMovements *movements;
boolean hatched; /* hatching has happened. (timers may run, ...) */
boolean gate_open; /* self-explaining */
- guint32 render_seed; /* the seed value, which was used to render the cave, is saved here. will be used by record&playback */
+ unsigned int render_seed; /* the seed value, which was used to render the cave, is saved here. will be used by record&playback */
GdRand *random; /* random number generator of rendered cave */
int rendered; /* if not zero, rendered at level x */
int timing_factor; /* number of "milliseconds" in each second :) 1000 for ntsc, 1200 for pal. */
- gpointer **objects_order; /* two-dimensional map of cave; each cell is a pointer to the drawing object, which created this element. NULL if map or random. */
+ void ***objects_order; /* two-dimensional map of cave; each cell is a pointer to the drawing object, which created this element. NULL if map or random. */
int **hammered_reappear; /* integer map of cave; if non-zero, a brick wall will appear there */
int speed; /* Time between game cycles in ms */
extern GdElement gd_char_to_element[];
void gd_create_char_to_element_table(void);
-GdElement gd_get_element_from_character(guint8 character);
+GdElement gd_get_element_from_character(unsigned char character);
GdElement gd_get_element_from_string(const char *string);
/* init cave engine */
unsigned int gd_str_case_hash(void *v);
/* cave highscore functions */
-int gd_highscore_compare(gconstpointer a, gconstpointer b);
+int gd_highscore_compare(const void *a, const void *b);
boolean gd_is_highscore(GdHighScore *scores, int score);
int gd_add_highscore(GdHighScore *highscores, const char *name, int score);
void gd_clear_highscore(GdHighScore *hs);
void gd_cave_c64_random_set_seed(GdCave *cave, int seed1, int seed2);
/* support */
-gpointer gd_cave_map_new_for_cave(const GdCave *cave, const int cell_size);
-gpointer gd_cave_map_dup_size(const GdCave * cave, const gpointer map, const int cell_size);
+void *gd_cave_map_new_for_cave(const GdCave *cave, const int cell_size);
+void *gd_cave_map_dup_size(const GdCave * cave, const void *map, const int cell_size);
#define gd_cave_map_new(CAVE, TYPE) ((TYPE **)gd_cave_map_new_for_cave((CAVE), sizeof(TYPE)))
-#define gd_cave_map_dup(CAVE, MAP) ((gpointer)gd_cave_map_dup_size((CAVE), (gpointer *)(CAVE)->MAP, sizeof((CAVE)->MAP[0][0])))
-void gd_cave_map_free(gpointer map);
+#define gd_cave_map_dup(CAVE, MAP) ((void *)gd_cave_map_dup_size((CAVE), (void **)(CAVE)->MAP, sizeof((CAVE)->MAP[0][0])))
+void gd_cave_map_free(void *map);
void gd_cave_store_rc(GdCave * cave, int x, int y, const GdElement element, const void* order);
GdElement gd_cave_get_rc (const GdCave *cave, int x, int y);
void gd_replay_free(GdReplay *replay);
void gd_replay_store_movement(GdReplay *replay, GdDirection player_move, boolean player_fire, boolean suicide);
-guint32 gd_cave_adler_checksum(GdCave *cave);
-void gd_cave_adler_checksum_more(GdCave *cave, guint32 *a, guint32 *b);
+unsigned int gd_cave_adler_checksum(GdCave *cave);
+void gd_cave_adler_checksum_more(GdCave *cave, unsigned int *a, unsigned int *b);
GdColor gd_c64_color(int);
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <glib.h>
-#include <glib/gi18n.h>
-
#include "main_bd.h"
#ifndef BD_CAVEDB_H
#define BD_CAVEDB_H
-#include <glib.h>
-
#include "bd_cave.h"
* The player_get function will also behave for lava as it does for space.
*/
-#include <glib.h>
-
#include "main_bd.h"
int i;
GdElement made_sound_of = O_NONE;
- for (i = 0; i < G_N_ELEMENTS (biter_try); i++)
+ for (i = 0; i < ARRAY_SIZE (biter_try); i++)
{
if (is_element_dir(cave, x, y, biter_move[dir], biter_try[i]))
{
}
}
- if (i == G_N_ELEMENTS(biter_try))
+ if (i == ARRAY_SIZE(biter_try))
/* i = number of elements in array: could not move, so just turn */
store(cave, x, y, O_BITER_1 + dirp);
else if (biter_try[i] == O_STONE)
};
GdDirection random_dir;
- random_dir = dirs[gd_rand_int_range(cave->random, 0, G_N_ELEMENTS(dirs))];
+ random_dir = dirs[gd_rand_int_range(cave->random, 0, ARRAY_SIZE(dirs))];
if (is_space_dir(cave, x, y, random_dir))
{
move(cave, x, y, random_dir, O_GHOST);
O_WAITING_STONE, O_BITER_1
};
- store(cave, x, y, ghost_explode[gd_rand_int_range(cave->random, 0, G_N_ELEMENTS(ghost_explode))]);
+ store(cave, x, y, ghost_explode[gd_rand_int_range(cave->random, 0, ARRAY_SIZE(ghost_explode))]);
}
break;
}
/* record coordinates of player for chasing stone */
- for (i = 0; i < G_N_ELEMENTS(cave->px) - 1; i++)
+ for (i = 0; i < ARRAY_SIZE(cave->px) - 1; i++)
{
cave->px[i] = cave->px[i + 1];
cave->py[i] = cave->py[i + 1];
}
- cave->px[G_N_ELEMENTS(cave->px) - 1] = cave->player_x;
- cave->py[G_N_ELEMENTS(cave->py) - 1] = cave->player_y;
+ cave->px[ARRAY_SIZE(cave->px) - 1] = cave->player_x;
+ cave->py[ARRAY_SIZE(cave->py) - 1] = cave->player_y;
/* SCHEDULING */
#ifndef BD_CAVEENGINE_H
#define BD_CAVEENGINE_H
-#include <glib.h>
-
#include "bd_cave.h"
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <glib.h>
-#include <glib/gi18n.h>
-
#include "main_bd.h"
GdObject *gd_object_new_maze(GdObjectLevels levels, int x1, int y1, int x2, int y2,
int wall_w, int path_w, GdElement wall_e, GdElement path_e,
- int horiz_percent, const gint32 seed[5])
+ int horiz_percent, const int seed[5])
{
int i;
GdObject *newobj = checked_calloc(sizeof(GdObject));
GdObject *gd_object_new_maze_unicursal(GdObjectLevels levels, int x1, int y1, int x2, int y2,
int wall_w, int path_w, GdElement wall_e, GdElement path_e,
- int horiz_percent, const gint32 seed[5])
+ int horiz_percent, const int seed[5])
{
int i;
GdObject *newobj = checked_calloc(sizeof(GdObject));
GdObject *gd_object_new_maze_braid(GdObjectLevels levels, int x1, int y1, int x2, int y2,
int wall_w, int path_w, GdElement wall_e, GdElement path_e,
- int horiz_percent, const gint32 seed[5])
+ int horiz_percent, const int seed[5])
{
int i;
GdObject *newobj = checked_calloc(sizeof(GdObject));
}
GdObject *gd_object_new_random_fill(GdObjectLevels levels, int x1, int y1, int x2, int y2,
- const gint32 seed[5], GdElement initial,
- const GdElement random[4], const gint32 prob[4],
+ const int seed[5], GdElement initial,
+ const GdElement random[4], const int prob[4],
GdElement replace_only, boolean c64)
{
int i;
int y2 = object->y2;
GdRand *rand;
GdC64RandomGenerator c64_rand;
- guint32 seed;
+ unsigned int seed;
/* -1 means that it should be different every time played. */
if (object->seed[level] == -1)
}
/* load cave to play... also can be called rendering the cave elements */
-GdCave *gd_cave_new_rendered(const GdCave *data, const int level, const guint32 seed)
+GdCave *gd_cave_new_rendered(const GdCave *data, const int level, const unsigned int seed)
{
GdCave *cave;
GdElement element;
cave->random = gd_rand_new_with_seed(cave->render_seed);
/* maps needed during drawing and gameplay */
- cave->objects_order = gd_cave_map_new(cave, gpointer);
+ cave->objects_order = gd_cave_map_new(cave, void *);
cave->time = data->level_time[level];
cave->timevalue = data->level_timevalue[level];
#ifndef BD_CAVEOBJECT_H
#define BD_CAVEOBJECT_H
-#include <glib.h>
-
#include "bd_cave.h"
int dx, dy; /* distance of elements for raster or join */
GdElement element, fill_element; /* element type */
- gint32 seed[5]; /* for maze and random fill */
+ int seed[5]; /* for maze and random fill */
int horiz; /* for maze */
boolean mirror, flip; /* for copy */
GdObject *gd_object_new_join(GdObjectLevels levels, int dx, int dy, GdElement search, GdElement replace);
GdObject *gd_object_new_floodfill_border(GdObjectLevels levels, int x1, int y1, GdElement fill, GdElement border);
GdObject *gd_object_new_floodfill_replace(GdObjectLevels levels, int x1, int y1, GdElement fill, GdElement to_replace);
-GdObject *gd_object_new_maze(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, int horiz_percent, const gint32 seed[5]);
-GdObject *gd_object_new_maze_unicursal(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, int horiz_percent, const gint32 seed[5]);
-GdObject *gd_object_new_maze_braid(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, int horiz_percent, const gint32 seed[5]);
-GdObject *gd_object_new_random_fill(GdObjectLevels levels, int x1, int y1, int x2, int y2, const gint32 seed[5], GdElement initial, const GdElement random[4], const gint32 prob[4], GdElement replace_only, boolean c64);
+GdObject *gd_object_new_maze(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, int horiz_percent, const int seed[5]);
+GdObject *gd_object_new_maze_unicursal(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, int horiz_percent, const int seed[5]);
+GdObject *gd_object_new_maze_braid(GdObjectLevels levels, int x1, int y1, int x2, int y2, int wall_w, int path_w, GdElement wall_e, GdElement path_e, int horiz_percent, const int seed[5]);
+GdObject *gd_object_new_random_fill(GdObjectLevels levels, int x1, int y1, int x2, int y2, const int seed[5], GdElement initial, const GdElement random[4], const int prob[4], GdElement replace_only, boolean c64);
GdObject *gd_object_new_copy_paste(GdObjectLevels levels, int x1, int y1, int x2, int y2, int dx, int dy, boolean mirror, boolean flip);
void gd_cave_draw_object(GdCave *cave, const GdObject *object, int level);
GdObject *gd_object_new_from_string(char *str);
-GdCave *gd_cave_new_rendered(const GdCave *data, const int level, guint32 seed);
+GdCave *gd_cave_new_rendered(const GdCave *data, const int level, unsigned int seed);
void gd_flatten_cave(GdCave *cave, const int level);
#endif // BD_CAVEOBJECT_H
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <glib.h>
-#include <glib/gi18n.h>
-#include <glib/gstdio.h>
+#include <sys/stat.h>
#include "main_bd.h"
/* free strings */
for (i = 0; gd_caveset_properties[i].identifier != NULL; i++)
if (gd_caveset_properties[i].type == GD_TYPE_LONGSTRING)
- checked_free(G_STRUCT_MEMBER(char *, data, gd_caveset_properties[i].offset));
+ checked_free(STRUCT_MEMBER(char *, data, gd_caveset_properties[i].offset));
free(data);
}
0x3526ff,
};
-static GdElement brc_effect(guint8 byt)
+static GdElement brc_effect(byte byt)
{
- if (byt >= G_N_ELEMENTS(brc_effect_table))
+ if (byt >= ARRAY_SIZE(brc_effect_table))
{
Warn("invalid element identifier for brc effect: %02x", byt);
return brc_effect_table[byt];
}
-static void brc_import(guint8 *data)
+static void brc_import(byte *data)
{
int x, y;
int level;
{
for (x = 0; x < cave->w; x++)
{
- guint8 import;
+ byte import;
import = data[y + level * 24 + cavenum * 24 * 5 + x * 24 * 5 * 20];
// if (i == printcave) g_print("%2x", import);
- if (import < G_N_ELEMENTS(brc_import_table))
+ if (import < ARRAY_SIZE(brc_import_table))
cave->map[y][x] = brc_import_table[import];
else
cave->map[y][x] = O_UNKNOWN;
cave->intermission = (cavenum >= 16 || data[14 * c + datapos + 1] != 0);
/* colors */
- colind = data[31 * c + datapos] % G_N_ELEMENTS(brc_color_table);
+ colind = data[31 * c + datapos] % ARRAY_SIZE(brc_color_table);
cave->colorb = 0x000000; /* fixed rgb black */
cave->color0 = 0x000000; /* fixed rgb black */
cave->color1 = brc_color_table[colind];
*/
boolean gd_caveset_load_from_file(char *filename)
{
- gsize length;
+ size_t length;
char *buf;
List *new_caveset;
struct stat st;
if (strSuffix(filename, ".brc") ||
strSuffix(filename, "*.BRC"))
{
- brc_import((guint8 *) buf);
+ brc_import((byte *) buf);
gd_caveset_edited = FALSE; /* newly loaded cave is not edited */
gd_caveset_last_selected = caveset_first_selectable_cave_index();
gd_caveset_last_selected_level = 0;
}
/* BDCFF */
- if (gd_caveset_imported_get_format((guint8 *) buf) == GD_FORMAT_UNKNOWN)
+ if (gd_caveset_imported_get_format((byte *) buf) == GD_FORMAT_UNKNOWN)
{
/* try to load as bdcff */
boolean result;
}
/* try to load as a binary file, as we know the format */
- new_caveset = gd_caveset_import_from_buffer ((guint8 *) buf, length);
+ new_caveset = gd_caveset_import_from_buffer ((byte *) buf, length);
free(buf);
/* if unable to load, exit here. error was reported by import_from_buffer() */
while (riter != NULL)
{
GdReplay *replay = (GdReplay *)riter->data;
- guint32 checksum;
+ unsigned int checksum;
GdCave *rendered;
List *next = riter->next;
#ifndef BD_CAVESET_H
#define BD_CAVESET_H
-#include <glib.h>
-
#include "main_bd.h"
/* #included cavesets; configdir passed to look for .hsc file */
boolean gd_caveset_load_from_internal(int caveset, const char *configdir);
-const gchar **gd_caveset_get_internal_game_names(void);
+const char **gd_caveset_get_internal_game_names(void);
/* caveset load from file */
boolean gd_caveset_load_from_file(char *filename);
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <glib.h>
-#include <glib/gi18n.h>
-
#include "main_bd.h"
#ifndef BD_GAMEPLAY_H
#define BD_GAMEPLAY_H
-#include <glib.h>
-
#include "bd_cave.h"
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <glib.h>
-
#include "main_bd.h"
/* quit, global variable which is set to true if the application should quit */
boolean gd_quit = FALSE;
-const guint8 *gd_keystate;
+const byte *gd_keystate;
static int cell_size = 0;
#ifndef BD_GRAPHICS_H
#define BD_GRAPHICS_H
-#include <SDL.h>
-
#include "bd_cave.h"
#include "bd_gameplay.h"
extern Bitmap *gd_screen_bitmap;
-extern const Uint8 *gd_keystate;
+extern const unsigned char *gd_keystate;
-typedef guint32 GdColor;
+typedef unsigned int GdColor;
void set_cell_size(int s);
void set_play_area(int w, int h);
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
+#include <time.h>
#if defined(PLATFORM_WINDOWS)
#include <process.h> /* for getpid() */
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <glib.h>
-
#include "main_bd.h"
int i;
/* stop all sounds. */
- for (i = 0; i < G_N_ELEMENTS(snd_playing); i++)
+ for (i = 0; i < ARRAY_SIZE(snd_playing); i++)
halt_channel(i);
}
#define SXSIZE (SCR_FIELDX * TILEX)
#define SYSIZE (SCR_FIELDY * TILEY)
+/* compatibility macros */
+
+#define gettext(String) (String)
+#define N_(String) (String)
+#define _(String) (String)
+
+#define STRUCT_MEMBER_P(struct_p, struct_offset) \
+ ((void *) ((byte *) (struct_p) + (long) (struct_offset)))
+#define STRUCT_MEMBER(member_type, struct_p, struct_offset) \
+ (*(member_type*) STRUCT_MEMBER_P ((struct_p), (struct_offset)))
+
// ----------------------------------------------------------------------------
// data structure definitions