From 9fdd88ae4724145d90c8ac5ba82a519a6c9e0d71 Mon Sep 17 00:00:00 2001 From: Jerome Duval Date: Sun, 12 May 2019 13:04:42 +0200 Subject: Patch from http://downloads.sourceforge.net/allegator/alex4_beos_src.zip diff --git a/src/actor.c b/src/actor.c index c6348c2..e9d31f8 100644 --- a/src/actor.c +++ b/src/actor.c @@ -43,23 +43,23 @@ void draw_actor(BITMAP *bmp, Tactor *a, int x, int y) { if (a->status == AC_NORM) { // normal drawing, just select direction if (a->direction) - draw_sprite_h_flip(bmp, a->data[a->frames[a->frame] + (a->is_hit ? a->hit_offset : 0)].dat, x, y - a->h - a->oy); + draw_sprite_h_flip(bmp, (BITMAP*)a->data[a->frames[a->frame] + (a->is_hit ? a->hit_offset : 0)].dat, x, y - a->h - a->oy); else - draw_sprite(bmp, a->data[a->frames[a->frame] + (a->is_hit ? a->hit_offset : 0)].dat, x, y - a->h - a->oy); + draw_sprite(bmp, (BITMAP*)a->data[a->frames[a->frame] + (a->is_hit ? a->hit_offset : 0)].dat, x, y - a->h - a->oy); } else if (a->status == AC_DEAD) { // draw dead frame, check for direction if (a->direction) - draw_sprite_vh_flip(bmp, a->data[a->frames[a->frame]].dat, x, y - a->h - a->oy); + draw_sprite_vh_flip(bmp, (BITMAP*)a->data[a->frames[a->frame]].dat, x, y - a->h - a->oy); else - draw_sprite_v_flip(bmp, a->data[a->frames[a->frame]].dat, x, y - a->h - a->oy); + draw_sprite_v_flip(bmp, (BITMAP*)a->data[a->frames[a->frame]].dat, x, y - a->h - a->oy); } else if (a->status == AC_FLAT) { // draw flat frame, check for direction if (a->direction) - draw_sprite_h_flip(bmp, a->data[a->flat_frame].dat, x, y - a->h - a->oy); + draw_sprite_h_flip(bmp, (BITMAP*)a->data[a->flat_frame].dat, x, y - a->h - a->oy); else - draw_sprite(bmp, a->data[a->flat_frame].dat, x, y - a->h - a->oy); + draw_sprite(bmp, (BITMAP*)a->data[a->flat_frame].dat, x, y - a->h - a->oy); } } @@ -271,7 +271,7 @@ void update_actor_with_map(Tactor *a, Tmap *m) { Tbullet *b = get_free_bullet(bullet, MAX_BULLETS); if (b != NULL) { int diff = (player.actor->x + 8) - (a->x + 8); - set_bullet(b, a->x + (diff > 0 ? 8 : -12), a->y - 16, (diff > 0 ? 3 : -3), 0, data[ENEMY6].dat, 1); + set_bullet(b, a->x + (diff > 0 ? 8 : -12), a->y - 16, (diff > 0 ? 3 : -3), 0, (BITMAP*)data[ENEMY6].dat, 1); create_burst(particle, a->x + (diff > 0 ? 18 : -2), a->y - 8, 8, 8, 25, PARTICLE_DUST); a->mode = 0; play_sound_id(SMPL_SHOOT); @@ -422,9 +422,9 @@ void update_actor_with_map(Tactor *a, Tmap *m) { for(i = 0; i < 3; i ++) { b = get_free_bullet(bullet, MAX_BULLETS); if (b != NULL) { - set_bullet(b, a->x + 16, a->y - 32, rand()%5 - 2, -(rand()%5 + 2), data[BULLET_1].dat, 1); + set_bullet(b, a->x + 16, a->y - 32, rand()%5 - 2, -(rand()%5 + 2), (BITMAP*)data[BULLET_1].dat, 1); b->animate = b->gravity = 1; - b->bmp2 = data[BULLET_2].dat; + b->bmp2 = (BITMAP*)data[BULLET_2].dat; } } a->mode ++; diff --git a/src/actor.h b/src/actor.h index 5ab9458..8e14fff 100644 --- a/src/actor.h +++ b/src/actor.h @@ -91,4 +91,4 @@ void update_actor_with_map(Tactor *a, Tmap *m); void kill_actor(Tactor *a); -#endif \ No newline at end of file +#endif diff --git a/src/bullet.c b/src/bullet.c index d389a51..4d65906 100644 --- a/src/bullet.c +++ b/src/bullet.c @@ -26,6 +26,8 @@ #include "timer.h" #include "../data/data.h" +// the bullets themselves +Tbullet bullet[MAX_BULLETS]; // sets values on a bullet void set_bullet(Tbullet *b, int x, int y, double dx, double dy, BITMAP *bmp, int bad) { @@ -44,8 +46,8 @@ void set_bullet(Tbullet *b, int x, int y, double dx, double dy, BITMAP *bmp, int // draws the bukllet on specified bitmap // pass along the map offset to get it right void draw_bullet(BITMAP *bmp, Tbullet *b, int ox, int oy) { - int x = b->x - ox; - int y = b->y - oy; + int x = (int)(b->x - ox); + int y = (int)(b->y - oy); // is the bullet inside the screen if (x < -b->bmp->w || x > bmp->w + b->bmp->w || y < -b->bmp->h || y > bmp->h + b->bmp->h) return; diff --git a/src/bullet.h b/src/bullet.h index c5d1ead..53bcbc6 100644 --- a/src/bullet.h +++ b/src/bullet.h @@ -27,7 +27,7 @@ #include "particle.h" // the bullet struct -typedef struct { +typedef struct Tbullet { double x, y; double dx, dy; int exist; @@ -36,13 +36,13 @@ typedef struct { int bad; int animate; int gravity; -} Tbullet; +}; // max bullets at any time #define MAX_BULLETS 64 // the bullets themselves -Tbullet bullet[MAX_BULLETS]; +extern Tbullet bullet[MAX_BULLETS]; // functions void reset_bullets(Tbullet *b, int max); @@ -52,4 +52,4 @@ void draw_bullet(BITMAP *bmp, Tbullet *b, int ox, int oy); void update_bullet(Tbullet *b); void update_bullet_with_map(Tbullet *b, Tmap *m); -#endif \ No newline at end of file +#endif diff --git a/src/edit.c b/src/edit.c index c87fa03..8c66cb5 100644 --- a/src/edit.c +++ b/src/edit.c @@ -33,8 +33,7 @@ int edit_tile = 0; // path to current map char edit_path_and_file[1024]; -// datafile to use -DATAFILE *data; + // current edit mode int edit_mode; @@ -64,28 +63,28 @@ void draw_edit_mode(BITMAP *bmp, Tmap *map, int mx, int my) { // blit mouse tile if (tx < map->width && ty < map->height) { - if (edit_tile) draw_sprite(bmp, data[TILE000 + edit_tile - 1].dat, (tx << 4) - map->offset_x, ty << 4); + if (edit_tile) draw_sprite(bmp, (BITMAP*)data[TILE000 + edit_tile - 1].dat, (tx << 4) - map->offset_x, ty << 4); rect(bmp, (tx << 4) - map->offset_x - 1, (ty << 4) - 1, (tx << 4)+16 - map->offset_x, (ty << 4)+16, gui_bg_color); } - + // show stuff - textprintf(bmp, data[THE_FONT].dat, 1, 1, 0, "TILE: %d,%d", tx, ty); - textprintf(bmp, data[THE_FONT].dat, 1, 11, 0, "SIZE: %d,%d", map->width, map->height); + textprintf(bmp, (FONT*)data[THE_FONT].dat, 1, 1, 0, "TILE: %d,%d", tx, ty); + textprintf(bmp, (FONT*)data[THE_FONT].dat, 1, 11, 0, "SIZE: %d,%d", map->width, map->height); // show start pos x = (ABS(map->start_x) << 4) - map->offset_x; y = (map->start_y << 4) - map->offset_y; rect(bmp, x+5, y+5, x+10, y+10, gui_bg_color); line(bmp, x+8, y+8, x+8+SGN(map->start_x)*6, y+8, gui_bg_color); - + // draw status bar rectfill(bmp, 0, 110, 159, 119, 1); - textprintf(bmp, data[THE_FONT].dat, 1, 111, 4, "EDITING: %s", get_filename(edit_path_and_file)); + textprintf(bmp, (FONT*)data[THE_FONT].dat, 1, 111, 4, "EDITING: %s", get_filename(edit_path_and_file)); } else if (edit_mode == EDIT_MODE_SELECT) { // draw tile palette // calculate offset depending on mouse pointer - int ox = (32.0 * mx) / 160.0; - int oy = ( 8.0 * my) / 120.0; + int ox = (int)((32.0 * mx) / 160.0); + int oy = (int)((8.0 * my) / 120.0); int tx = (mx + ox) / 16; int ty = (my + oy) / 16; @@ -93,7 +92,7 @@ void draw_edit_mode(BITMAP *bmp, Tmap *map, int mx, int my) { clear_to_color(bmp, gui_bg_color); for(y = 0; y < 8; y ++) { for(x = 0; x < 12; x ++) { - draw_sprite(bmp, data[TILE000 + x + y * 12].dat, x * 16 - ox, y * 16 - oy); + draw_sprite(bmp, (BITMAP*)data[TILE000 + x + y * 12].dat, x * 16 - ox, y * 16 - oy); } } @@ -104,16 +103,16 @@ void draw_edit_mode(BITMAP *bmp, Tmap *map, int mx, int my) { else if (edit_mode == EDIT_MODE_STATS) { // draw map properties int ty = 16; clear_to_color(bmp, 3); - textprintf(bmp, data[THE_FONT].dat, 1, 1, 1, "%s (props)", get_filename(edit_path_and_file)); + textprintf(bmp, (FONT*)data[THE_FONT].dat, 1, 1, 1, "%s (props)", get_filename(edit_path_and_file)); line(bmp, 0, 10, 159, 10, 1); - textprintf(bmp, data[THE_FONT].dat, 1, ty+=10, 1, "Win by:"); - textprintf(bmp, data[THE_FONT].dat, 1, ty+=10, 1, " 1) reach exit (%s)", (map->win_conditions & MAP_WIN_EXIT ? "X" : " ")); - textprintf(bmp, data[THE_FONT].dat, 1, ty+=10, 1, " 2) kill boss (%s)", (map->win_conditions & MAP_WIN_KILL_GUARDIAN ? "X" : " ")); - textprintf(bmp, data[THE_FONT].dat, 1, ty+=10, 1, " 3) kill all (%s)", (map->win_conditions & MAP_WIN_KILL_ALL ? "X" : " ")); - textprintf(bmp, data[THE_FONT].dat, 1, ty+=10, 1, "4) Boss level: (%s)", (map->boss_level ? "X" : " ")); - textprintf(bmp, data[THE_FONT].dat, 1, ty+=10, 1, "5) Name: %s", map->name); + textprintf(bmp, (FONT*)data[THE_FONT].dat, 1, ty+=10, 1, "Win by:"); + textprintf(bmp, (FONT*)data[THE_FONT].dat, 1, ty+=10, 1, " 1) reach exit (%s)", (map->win_conditions & MAP_WIN_EXIT ? "X" : " ")); + textprintf(bmp, (FONT*)data[THE_FONT].dat, 1, ty+=10, 1, " 2) kill boss (%s)", (map->win_conditions & MAP_WIN_KILL_GUARDIAN ? "X" : " ")); + textprintf(bmp, (FONT*)data[THE_FONT].dat, 1, ty+=10, 1, " 3) kill all (%s)", (map->win_conditions & MAP_WIN_KILL_ALL ? "X" : " ")); + textprintf(bmp, (FONT*)data[THE_FONT].dat, 1, ty+=10, 1, "4) Boss level: (%s)", (map->boss_level ? "X" : " ")); + textprintf(bmp, (FONT*)data[THE_FONT].dat, 1, ty+=10, 1, "5) Name: %s", map->name); - textprintf(bmp, data[THE_FONT].dat, 1, 110, 1, "F1: back to editor"); + textprintf(bmp, (FONT*)data[THE_FONT].dat, 1, 110, 1, "F1: back to editor"); } if (edit_mode != EDIT_MODE_STATS) { @@ -342,8 +341,8 @@ void update_edit_mode(Tmap *map, BITMAP *bmp, int mx, int my, int mb) { } else if (edit_mode == EDIT_MODE_SELECT) { - int ox = (32.0 * mx) / 160.0; - int oy = ( 8.0 * my) / 120.0; + int ox = (int)((32.0 * mx) / 160.0); + int oy = (int)((8.0 * my) / 120.0); int tx = (mx + ox) / 16; int ty = (my + oy) / 16; @@ -364,7 +363,7 @@ void update_edit_mode(Tmap *map, BITMAP *bmp, int mx, int my, int mb) { if (kb == '3') map->win_conditions ^= MAP_WIN_KILL_ALL; if (kb == '4') map->boss_level ^= 1; - if (kb == '5') get_string(bmp, map->name, 32, data[THE_FONT].dat, 8, 90, gui_fg_color, NULL); + if (kb == '5') get_string(bmp, map->name, 32, (FONT*)data[THE_FONT].dat, 8, 90, gui_fg_color, NULL); } if (key[KEY_F1]) { diff --git a/src/edit.h b/src/edit.h index 7bbcacf..c9d739e 100644 --- a/src/edit.h +++ b/src/edit.h @@ -37,4 +37,4 @@ void set_edit_path_and_file(char *str); void draw_edit_mode(BITMAP *bmp, Tmap *map, int mx, int my); void update_edit_mode(Tmap *map, BITMAP *bmp, int mx, int my, int mb); -#endif \ No newline at end of file +#endif diff --git a/src/hisc.c b/src/hisc.c index b8a4452..cef0aca 100644 --- a/src/hisc.c +++ b/src/hisc.c @@ -28,7 +28,7 @@ Thisc* make_hisc_table() { Thisc *tmp; - tmp = malloc(MAX_SCORES*sizeof(Thisc)); + tmp = (Thisc*)malloc(MAX_SCORES*sizeof(Thisc)); if (!tmp) return NULL; return tmp; diff --git a/src/hisc.h b/src/hisc.h index c4e9c07..962f4ed 100644 --- a/src/hisc.h +++ b/src/hisc.h @@ -48,4 +48,4 @@ void save_hisc_table(Thisc *table, PACKFILE *fp); void draw_hisc_post(Thisc *table, BITMAP *bmp, FONT *fnt, int x, int y, int color, int show_level); void draw_hisc_table(Thisc *table, BITMAP *bmp, FONT *fnt, int x, int y, int color, int show_level); -#endif \ No newline at end of file +#endif diff --git a/src/main.c b/src/main.c index 8c29ccc..cec8bc6 100644 --- a/src/main.c +++ b/src/main.c @@ -132,12 +132,12 @@ int init_ok = 0; // returns pointer to the game over bitmap BITMAP *get_gameover_sign() { - return data[GAME_OVER].dat; + return (BITMAP*)data[GAME_OVER].dat; } // returns pointer to the lets go bitmap BITMAP *get_letsgo_sign() { - return data[LETSGO].dat; + return (BITMAP*)data[LETSGO].dat; } // returns pointer to the space highscore table @@ -225,7 +225,7 @@ void play_sound_id(int id) { // plays a sample using user settings void play_sound_ex(SAMPLE *s, int vol, int freq, int loop) { if (got_sound && s != NULL) { - int v = (get_config_int("sound", "sample_volume", 100) * (float)(vol))/100.0; + int v = (int)((get_config_int("sound", "sample_volume", 100) * (float)(vol))/100.0); play_sample(s, v, 128, freq, loop); } } @@ -245,7 +245,7 @@ void stop_sound_id(int id) { void adjust_sound_id_ex(int id, int x) { if (got_sound) { int vol = MAX(100 - ABS(player.actor->x - x) / 2, 0); - int v = get_config_int("sound", "sample_volume", 100) * (float)(vol)/100.0; + int v = (int)(get_config_int("sound", "sample_volume", 100) * (float)(vol)/100.0); int pan = MID(0, 128 + x - player.actor->x, 255); if (sfx[id] != NULL) { adjust_sample(sfx[id], v, pan, 1000, 1); @@ -496,16 +496,16 @@ void draw_status_bar(BITMAP *bmp, int y) { int i; rectfill(bmp, 0, y, 159, y+9, 1); - draw_sprite_h_flip(bmp, data[HERO_NORM].dat, 0, y+1); - textprintf(bmp, data[THE_FONT].dat, 9, y+1, 4, " :%d", player.lives); + draw_sprite_h_flip(bmp, (BITMAP*)data[HERO_NORM].dat, 0, y+1); + textprintf(bmp, (FONT*)data[THE_FONT].dat, 9, y+1, 4, " :%d", player.lives); for(i = 0; i < player.health; i ++) - draw_sprite(bmp, data[HEART2].dat, 40 + 10 * i, y-3); + draw_sprite(bmp, (BITMAP*)data[HEART2].dat, 40 + 10 * i, y-3); - draw_sprite(bmp, data[EGG].dat, 80, y-5); - textprintf(bmp, data[THE_FONT].dat, 85, y+1, 4, " :%d", player.ammo); + draw_sprite(bmp, (BITMAP*)data[EGG].dat, 80, y-5); + textprintf(bmp, (FONT*)data[THE_FONT].dat, 85, y+1, 4, " :%d", player.ammo); - textprintf_right(bmp, data[THE_FONT].dat, 158, y+1, 4, "%d", player.score); + textprintf_right(bmp, (FONT*)data[THE_FONT].dat, 158, y+1, 4, "%d", player.score); } @@ -521,12 +521,12 @@ void draw_frame(BITMAP *bmp, int _status_bar) { x2 = (-ox % 320) >> 1; // draw backgrounds - blit(data[BG0].dat, bmp, 0, 0, x0, 0, 160, 120); - blit(data[BG0].dat, bmp, 0, 0, x0 + 160, 0, 160, 120); - draw_sprite(bmp, data[BG1].dat, x1, 120 - ((BITMAP *)data[BG1].dat)->h); - draw_sprite(bmp, data[BG1].dat, x1 + 160, 120 - ((BITMAP *)data[BG1].dat)->h); - draw_sprite(bmp, data[BG2].dat, x2, 120 - ((BITMAP *)data[BG2].dat)->h); - draw_sprite(bmp, data[BG2].dat, x2 + 160, 120 - ((BITMAP *)data[BG2].dat)->h); + blit((BITMAP*)data[BG0].dat, bmp, 0, 0, x0, 0, 160, 120); + blit((BITMAP*)data[BG0].dat, bmp, 0, 0, x0 + 160, 0, 160, 120); + draw_sprite(bmp, (BITMAP*)data[BG1].dat, x1, 120 - ((BITMAP *)data[BG1].dat)->h); + draw_sprite(bmp, (BITMAP*)data[BG1].dat, x1 + 160, 120 - ((BITMAP *)data[BG1].dat)->h); + draw_sprite(bmp, (BITMAP*)data[BG2].dat, x2, 120 - ((BITMAP *)data[BG2].dat)->h); + draw_sprite(bmp, (BITMAP*)data[BG2].dat, x2 + 160, 120 - ((BITMAP *)data[BG2].dat)->h); // draw frame draw_map(bmp, map, 0, 0, 160, 120, editing); @@ -536,16 +536,16 @@ void draw_frame(BITMAP *bmp, int _status_bar) { for(i = 1; i < MAX_ACTORS; i ++) if (actor[i].active) draw_actor(bmp, &actor[i], actor[i].x - ox, actor[i].y); - + // draw particles - for(i = 0; i < MAX_PARTICLES; i ++) + for(i = 0; i < MAX_PARTICLES; i ++) if (particle[i].life) draw_particle(bmp, &particle[i], ox, 0); } // draw player draw_player(bmp, &player, player.actor->x - ox, player.actor->y); - + // draw bullets for(i = 0; i < MAX_BULLETS; i ++) if (bullet[i].exist) @@ -555,11 +555,10 @@ void draw_frame(BITMAP *bmp, int _status_bar) { if (!editing) { if (_status_bar) draw_status_bar(bmp, 110); else rectfill(bmp, 0, 110, 159, 119, 1); - } else { /////////////// EDIT stats - int mx = mouse_x / (SCREEN_W / 160); - int my = mouse_y / (SCREEN_H / 120); + int mx = (int)(mouse_x / (SCREEN_W / 160)); + int my = (int)(mouse_y / (SCREEN_H / 120)); draw_edit_mode(bmp, map, mx, my); } } @@ -759,12 +758,12 @@ int init_game(const char *map_file) { ((RGB *)data[0].dat)[0].g = 0; ((RGB *)data[0].dat)[0].b = 0; fix_gui_colors(); - set_palette(data[0].dat); + set_palette((RGB*)data[0].dat); // show splash screen clear_to_color(swap_screen, 3); - bmp = data[FLD_LOGO].dat; + bmp = (BITMAP*)data[FLD_LOGO].dat; draw_character(swap_screen, bmp, 80 - bmp->w / 2 + 0, 50 + 1, 1); draw_character(swap_screen, bmp, 80 - bmp->w / 2, 50, 4); @@ -841,6 +840,10 @@ int init_game(const char *map_file) { log2file(" DIGI_AUTODETECT selected (%d)", i); break; case 2: + i = DIGI_BEOS; + log2file(" DIGI_BEOS selected (%d)",i); + break; +/* case 2: i = DIGI_DIRECTX(0); log2file(" DIGI_DIRECTX(0) selected (%d)", i); break; @@ -848,7 +851,7 @@ int init_game(const char *map_file) { i = DIGI_DIRECTAMX(0); log2file(" DIGI_DIRECTAMX(0) selected (%d)", i); break; - default: +*/ default: i = -770405; // dummy number got_sound = 0; log2file(" NO_SOUND selected"); @@ -889,31 +892,31 @@ int init_game(const char *map_file) { if (!s) log2file(" sfx_22.dat will be used"); // assign samples - sfx[SMPL_CHERRY] = sfx_data[0].dat; - sfx[SMPL_CHOPPER] = sfx_data[1].dat; - sfx[SMPL_CRUSH] = sfx_data[2].dat; - sfx[SMPL_A_DIE] = sfx_data[3].dat; - sfx[SMPL_EAT] = sfx_data[4].dat; - sfx[SMPL_BEAM] = sfx_data[5].dat; - sfx[SMPL_ENGINE] = sfx_data[6].dat; - sfx[SMPL_HEART] = sfx_data[7].dat; - sfx[SMPL_HIT] = sfx_data[8].dat; - sfx[SMPL_HURT] = sfx_data[9].dat; - sfx[SMPL_CRUSH_LAND] = sfx_data[10].dat; - sfx[SMPL_JUMP] = sfx_data[11].dat; - sfx[SMPL_E_DIE] = sfx_data[12].dat; - sfx[SMPL_MENU] = sfx_data[13].dat; - sfx[SMPL_PAUSE] = sfx_data[14].dat; - sfx[SMPL_POINT] = sfx_data[15].dat; - sfx[SMPL_SHIP] = sfx_data[16].dat; - sfx[SMPL_SHOOT] = sfx_data[17].dat; - sfx[SMPL_SPIT] = sfx_data[18].dat; - sfx[SMPL_STAR] = sfx_data[19].dat; - sfx[SMPL_STARTUP] = sfx_data[20].dat; - sfx[SMPL_MASH] = sfx_data[21].dat; - sfx[SMPL_TALK] = sfx_data[22].dat; - sfx[SMPL_SPIN] = sfx_data[23].dat; - sfx[SMPL_XTRALIFE] = sfx_data[24].dat; + sfx[SMPL_CHERRY] = (SAMPLE*)sfx_data[0].dat; + sfx[SMPL_CHOPPER] = (SAMPLE*)sfx_data[1].dat; + sfx[SMPL_CRUSH] = (SAMPLE*)sfx_data[2].dat; + sfx[SMPL_A_DIE] = (SAMPLE*)sfx_data[3].dat; + sfx[SMPL_EAT] = (SAMPLE*)sfx_data[4].dat; + sfx[SMPL_BEAM] = (SAMPLE*)sfx_data[5].dat; + sfx[SMPL_ENGINE] = (SAMPLE*)sfx_data[6].dat; + sfx[SMPL_HEART] = (SAMPLE*)sfx_data[7].dat; + sfx[SMPL_HIT] = (SAMPLE*)sfx_data[8].dat; + sfx[SMPL_HURT] = (SAMPLE*)sfx_data[9].dat; + sfx[SMPL_CRUSH_LAND] = (SAMPLE*)sfx_data[10].dat; + sfx[SMPL_JUMP] = (SAMPLE*)sfx_data[11].dat; + sfx[SMPL_E_DIE] = (SAMPLE*)sfx_data[12].dat; + sfx[SMPL_MENU] = (SAMPLE*)sfx_data[13].dat; + sfx[SMPL_PAUSE] = (SAMPLE*)sfx_data[14].dat; + sfx[SMPL_POINT] = (SAMPLE*)sfx_data[15].dat; + sfx[SMPL_SHIP] = (SAMPLE*)sfx_data[16].dat; + sfx[SMPL_SHOOT] = (SAMPLE*)sfx_data[17].dat; + sfx[SMPL_SPIT] = (SAMPLE*)sfx_data[18].dat; + sfx[SMPL_STAR] = (SAMPLE*)sfx_data[19].dat; + sfx[SMPL_STARTUP] = (SAMPLE*)sfx_data[20].dat; + sfx[SMPL_MASH] = (SAMPLE*)sfx_data[21].dat; + sfx[SMPL_TALK] = (SAMPLE*)sfx_data[22].dat; + sfx[SMPL_SPIN] = (SAMPLE*)sfx_data[23].dat; + sfx[SMPL_XTRALIFE] = (SAMPLE*)sfx_data[24].dat; } } else { @@ -950,7 +953,7 @@ int init_game(const char *map_file) { // misc log2file(" initializing scroller"); - init_scroller(&hscroll, data[THE_FONT].dat, scroller_message, 160, 10, TRUE); + init_scroller(&hscroll, (FONT*)data[THE_FONT].dat, scroller_message, 160, 10, TRUE); options.use_vsync = get_config_int("graphics", "vsync", 0); log2file(" vsync set to %s", (options.use_vsync ? "ON" : "OFF")); @@ -1046,17 +1049,17 @@ void init_player(Tplayer *p, Tmap *m) { // draws text with an outline void textout_outline(BITMAP *bmp, const char *txt, int x, int y) { - textout(bmp, data[THE_FONT].dat, txt, x+1, y, 1); - textout(bmp, data[THE_FONT].dat, txt, x-1, y, 1); - textout(bmp, data[THE_FONT].dat, txt, x, y+1, 1); - textout(bmp, data[THE_FONT].dat, txt, x, y-1, 1); - textout(bmp, data[THE_FONT].dat, txt, x, y, 4); + textout(bmp, (FONT*)data[THE_FONT].dat, txt, x+1, y, 1); + textout(bmp, (FONT*)data[THE_FONT].dat, txt, x-1, y, 1); + textout(bmp, (FONT*)data[THE_FONT].dat, txt, x, y+1, 1); + textout(bmp, (FONT*)data[THE_FONT].dat, txt, x, y-1, 1); + textout(bmp, (FONT*)data[THE_FONT].dat, txt, x, y, 4); } // draws centered text with an outline void textout_outline_center(BITMAP *bmp, const char *txt, int cx, int y) { - int x = cx - text_length(data[THE_FONT].dat, txt) / 2; + int x = cx - text_length((FONT*)data[THE_FONT].dat, txt) / 2; textout_outline(bmp, txt, x, y); } @@ -1064,7 +1067,7 @@ void textout_outline_center(BITMAP *bmp, const char *txt, int cx, int y) { // plays the let's go sequence void show_lets_go() { - BITMAP *go = data[LETSGO].dat; + BITMAP *go = (BITMAP*)data[LETSGO].dat; int x = -go->w; int mode = 0; int wait = 0; @@ -1112,7 +1115,7 @@ void show_lets_go() { // shows the game over sign sequence void show_game_over() { - BITMAP *go = data[GAME_OVER].dat; + BITMAP *go = (BITMAP*)data[GAME_OVER].dat; int x = -go->w; int mode = 0; @@ -1154,16 +1157,16 @@ void show_game_over() { // show_custom_ending() void draw_custom_ending(BITMAP *bmp) { int i, r; - BITMAP *head = data[FLD_HEAD].dat; + BITMAP *head = (BITMAP*)data[FLD_HEAD].dat; - blit(data[INTRO_BG].dat, bmp, 0, 0, 0, 0, 160, 120); + blit((BITMAP*)data[INTRO_BG].dat, bmp, 0, 0, 0, 0, 160, 120); r = 70 + fixtoi(20 * fcos(itofix(game_count >> 1)) + 20 * fsin(itofix((int)(game_count / 2.7))) ); for(i = 0; i < 256; i += 32) draw_sprite(bmp, head, 80 - head->w/2 + fixtoi(r * fcos(itofix(game_count + i))), 60 - head->h/2 + fixtoi(r * fsin(itofix(game_count + i)))); - draw_sprite_h_flip(bmp, data[ALEX].dat, 60, 40); - draw_sprite(bmp, data[LOLA].dat, 84, 40); + draw_sprite_h_flip(bmp, (BITMAP*)data[ALEX].dat, 60, 40); + draw_sprite(bmp, (BITMAP*)data[LOLA].dat, 84, 40); textout_outline_center(bmp, "Congratulations!", 80, 60); textout_outline_center(bmp, "A winner is you!", 80, 80); @@ -1229,7 +1232,7 @@ void transform_bitmap(BITMAP *bmp, int steps) { // draws the scoring sequence at end of level // used by show_cutscene(..) void draw_cutscene(BITMAP *bmp, int org_level, int _level, int _lives, int _stars, int _cherries) { - BITMAP *go = data[LEVELCOMPLETE].dat; + BITMAP *go = (BITMAP*)data[LEVELCOMPLETE].dat; char buf[80]; clear_bitmap(bmp); @@ -1346,14 +1349,14 @@ void show_scores(int space, Thisc *table) { df = load_datafile_object("data/a45.dat", "BG1"); packfile_password(NULL); if (df != NULL) { - bg = df->dat; + bg = (BITMAP*)df->dat; } else msg_box("ooga"); } if (bg == NULL || !space) - blit(data[INTRO_BG].dat, swap_screen, 0, 0, 0, 0, 160, 120); + blit((BITMAP*)data[INTRO_BG].dat, swap_screen, 0, 0, 0, 0, 160, 120); else { clear_to_color(swap_screen, 1); blit(bg, swap_screen, 0, 0, 0, 0, 160, 120); @@ -1362,7 +1365,7 @@ void show_scores(int space, Thisc *table) { textout_outline_center(swap_screen, "High scores", 80, 8); textout_outline_center(swap_screen, "Press any key", 80, 100); - draw_hisc_table(table, swap_screen, data[THE_FONT].dat, 10, 30, (space ? 4 : 1), !space); + draw_hisc_table(table, swap_screen, (FONT*)data[THE_FONT].dat, 10, 30, (space ? 4 : 1), !space); blit_to_screen(swap_screen); fade_in_pal(100); @@ -1388,30 +1391,30 @@ void draw_select_starting_level(BITMAP *bmp, int level, int min, int max) { char buf[80]; int xpos = 2; - blit(data[ALEX_BG].dat, bmp, 0, 0, 0, 0, 160, 112); + blit((BITMAP*)data[ALEX_BG].dat, bmp, 0, 0, 0, 0, 160, 112); rectfill(bmp, 0, 112, 160, 120, 2); sprintf(buf, "%s %d %s", (level > min ? "<" : " "), level, (level < max ? ">" : " ")); clear_bitmap(stuff); - textout_centre(stuff, data[THE_FONT].dat, buf, stuff->w/2 + 1, 1, 2); - textout_centre(stuff, data[THE_FONT].dat, buf, stuff->w/2, 0, 1); + textout_centre(stuff, (FONT*)data[THE_FONT].dat, buf, stuff->w/2 + 1, 1, 2); + textout_centre(stuff, (FONT*)data[THE_FONT].dat, buf, stuff->w/2, 0, 1); stretch_sprite(bmp, stuff, 80 - 4*stuff->w/2, 30, 4*stuff->w, 4*stuff->h); - textout_centre(bmp, data[THE_FONT].dat, "SELECT START LEVEL", 80, 90, 1); - textout_centre(bmp, data[THE_FONT].dat, "SELECT START LEVEL", 79, 89, 4); + textout_centre(bmp, (FONT*)data[THE_FONT].dat, "SELECT START LEVEL", 80, 90, 1); + textout_centre(bmp, (FONT*)data[THE_FONT].dat, "SELECT START LEVEL", 79, 89, 4); if (options.one_hundred) { - if (game_count & 32 || game_count & 16) draw_sprite(bmp, data[SHIP100].dat, xpos, 2); + if (game_count & 32 || game_count & 16) draw_sprite(bmp, (BITMAP*)data[SHIP100].dat, xpos, 2); } else { if (options.stars[level - 1]) { - draw_sprite(bmp, data[STAR].dat, xpos, 2); - draw_sprite(bmp, data[ALL100].dat, xpos + 4, 14); + draw_sprite(bmp, (BITMAP*)data[STAR].dat, xpos, 2); + draw_sprite(bmp, (BITMAP*)data[ALL100].dat, xpos + 4, 14); xpos += 20; } if (options.cherries[level - 1]) { - draw_sprite(bmp, data[CHERRY].dat, xpos, 2); - draw_sprite(bmp, data[ALL100].dat, xpos + 4, 14); + draw_sprite(bmp, (BITMAP*)data[CHERRY].dat, xpos, 2); + draw_sprite(bmp, (BITMAP*)data[ALL100].dat, xpos + 4, 14); } } @@ -1773,7 +1776,7 @@ void update_player() { if (player.ammo) { Tbullet *b = get_free_bullet(bullet, MAX_BULLETS); if (b != NULL) { - set_bullet(b, (int)player.actor->x + 7, (int)player.actor->y - 14, (player.actor->direction ? 4 : -4), 0, data[EGG2].dat, 0); + set_bullet(b, (int)player.actor->x + 7, (int)player.actor->y - 14, (player.actor->direction ? 4 : -4), 0, (BITMAP*)data[EGG2].dat, 0); player.ammo --; play_sound(sfx[SMPL_SPIT]); } @@ -2149,7 +2152,7 @@ void check_alex_with_enemies() { // calculates camera pos for map m considering player p void calculate_camera_pos(Tplayer *p, Tmap *m) { - static camera_type = 1; + static int camera_type = 1; if (p->actor->status == AC_BALL) { camera_type = 2; @@ -2459,33 +2462,33 @@ void draw_title(BITMAP *bmp, int tick) { if (!playing_original_game) strcpy(start_string, "CUSTOM GAME"); - blit(data[ALEX_BG].dat, bmp, 0, 0, 0, 0, 160, 112); + blit((BITMAP*)data[ALEX_BG].dat, bmp, 0, 0, 0, 0, 160, 112); rectfill(bmp, 0, 112, 160, 120, 2); w = ((BITMAP *)data[ALEX_LOGO].dat)->w; h = ((BITMAP *)data[ALEX_LOGO].dat)->h; - draw_sprite(bmp, data[ALEX_LOGO].dat, 80 - w/2, 30 - h/2); + draw_sprite(bmp, (BITMAP*)data[ALEX_LOGO].dat, 80 - w/2, 30 - h/2); draw_scroller(&hscroll, bmp, 0, 110); y = 60; x = 50; - textout(bmp, data[THE_FONT].dat, start_string, x+1, y+1, 1); - textout(bmp, data[THE_FONT].dat, start_string, x, y, 4); + textout(bmp, (FONT*)data[THE_FONT].dat, start_string, x+1, y+1, 1); + textout(bmp, (FONT*)data[THE_FONT].dat, start_string, x, y, 4); y += step; - textout(bmp, data[THE_FONT].dat, "HIGH SCORES", x+1, y+1, 1); - textout(bmp, data[THE_FONT].dat, "HIGH SCORES", x, y, 4); + textout(bmp, (FONT*)data[THE_FONT].dat, "HIGH SCORES", x+1, y+1, 1); + textout(bmp, (FONT*)data[THE_FONT].dat, "HIGH SCORES", x, y, 4); y += step; - textout(bmp, data[THE_FONT].dat, "EDITOR", x+1, y+1, 1); - textout(bmp, data[THE_FONT].dat, "EDITOR", x, y, 4); + textout(bmp, (FONT*)data[THE_FONT].dat, "EDITOR", x+1, y+1, 1); + textout(bmp, (FONT*)data[THE_FONT].dat, "EDITOR", x, y, 4); y += step; - textout(bmp, data[THE_FONT].dat, "QUIT", x+1, y+1, 1); - textout(bmp, data[THE_FONT].dat, "QUIT", x, y, 4); + textout(bmp, (FONT*)data[THE_FONT].dat, "QUIT", x+1, y+1, 1); + textout(bmp, (FONT*)data[THE_FONT].dat, "QUIT", x, y, 4); - draw_sprite(bmp, data[POINTER].dat, x - 25 + fixtoi(3 * fcos(itofix(tick << 2))), 44 + menu_choice * step); + draw_sprite(bmp, (BITMAP*)data[POINTER].dat, x - 25 + fixtoi(3 * fcos(itofix(tick << 2))), 44 + menu_choice * step); } @@ -2508,7 +2511,7 @@ void switch_gfx_mode(int mode, int w, int h) { } } - set_palette(data[0].dat); + set_palette((RGB*)data[0].dat); } @@ -2612,7 +2615,7 @@ int get_string(BITMAP *bmp, char *string, int max_size, FONT *f, int pos_x, int // lets the player enter a name for highscore use (or what ever) void get_player_name(char *name) { - blit(data[INTRO_BG].dat, swap_screen, 0, 0, 0, 0, 160, 120); + blit((BITMAP*)data[INTRO_BG].dat, swap_screen, 0, 0, 0, 0, 160, 120); transform_bitmap(swap_screen, -1); textout_outline_center(swap_screen, "Congratulations,", 80, 8); textout_outline_center(swap_screen, "You've got", 80, 19); @@ -2620,7 +2623,7 @@ void get_player_name(char *name) { textout_outline_center(swap_screen, "Enter your name:", 80, 55); blit_to_screen(swap_screen); fade_in_pal(100); - get_string(swap_screen, name, 10, data[THE_FONT].dat, 50, 80, 4, &ctrl); + get_string(swap_screen, name, 10, (FONT*)data[THE_FONT].dat, 50, 80, 4, &ctrl); } @@ -2756,7 +2759,7 @@ int do_main_menu() { set_edit_mode(EDIT_MODE_DRAW); set_edit_path_and_file("new.map"); - draw_frame(swap_screen, 1); + draw_frame(swap_screen, 1);printf("drawed frame\n"); blit_to_screen(swap_screen); fade_in_pal(100); status = play(-1); @@ -2946,7 +2949,7 @@ int do_main_menu() { stop_music(); fade_out_pal(100); // show bye bye screen - blit(data[INTRO_BG].dat, swap_screen, 0, 0, 0, 0, 160, 120); + blit((BITMAP*)data[INTRO_BG].dat, swap_screen, 0, 0, 0, 0, 160, 120); transform_bitmap(swap_screen, -1); textout_outline_center(swap_screen, "Thanks for playing!", 80, 20); textout_outline_center(swap_screen, "Design, Code, GFX:", 80, 48); diff --git a/src/main.h b/src/main.h index 290a453..2082430 100644 --- a/src/main.h +++ b/src/main.h @@ -59,6 +59,7 @@ #define SMPL_TALK 24 #define SMPL_BEAM 25 +extern DATAFILE *data; // functions char *get_init_string(); @@ -90,8 +91,6 @@ void poll_music(); // a little bounding box quickie -#define check_bb_collision(x1,y1,w1,h1,x2,y2,w2,h2) (!( ((x1)>=(x2)+(w2)) || ((x2)>=(x1)+(w1)) || \ - ((y1)>=(y2)+(h2)) || ((y2)>=(y1)+(h1)) )) +#define check_bb_collision(x1,y1,w1,h1,x2,y2,w2,h2) (!( ((x1)>=(x2)+(w2)) || ((x2)>=(x1)+(w1)) || ((y1)>=(y2)+(h2)) || ((y2)>=(y1)+(h1)) )) - -#endif \ No newline at end of file +#endif diff --git a/src/map.c b/src/map.c index 284445a..5d10c23 100644 --- a/src/map.c +++ b/src/map.c @@ -35,7 +35,7 @@ Tmap *create_map(int w, int h) { Tmap *m; - m = malloc(sizeof(Tmap)); + m = (Tmap*)malloc(sizeof(Tmap)); if (m == NULL) return NULL; strcpy(m->name, "noname"); @@ -52,7 +52,7 @@ Tmap *create_map(int w, int h) { m->offset_y = 0; m->width = w; m->height = h; - m->dat = malloc(w * h * sizeof(Tmappos)); + m->dat = (Tmappos*)malloc(w * h * sizeof(Tmappos)); if (m->dat == NULL) { free(m); @@ -86,7 +86,7 @@ Tmap *load_map(char *fname) { } // get memory - m = malloc(sizeof(Tmap)); + m = (Tmap*)malloc(sizeof(Tmap)); if (m == NULL) { fclose(fp); return NULL; @@ -96,7 +96,7 @@ Tmap *load_map(char *fname) { fread(m, sizeof(Tmap), 1, fp); // read map data - m->dat = malloc(m->width * m->height * sizeof(Tmappos)); + m->dat = (Tmappos*)malloc(m->width * m->height * sizeof(Tmappos)); if (m->dat == NULL) { free(m); return NULL; @@ -130,7 +130,7 @@ Tmap *load_map_from_memory(void *mem) { c += 6; // get memory - m = malloc(sizeof(Tmap)); + m = (Tmap*)malloc(sizeof(Tmap)); if (m == NULL) { //fclose(fp); return NULL; @@ -142,7 +142,7 @@ Tmap *load_map_from_memory(void *mem) { c += sizeof(Tmap); // read map data - m->dat = malloc(m->width * m->height * sizeof(Tmappos)); + m->dat = (Tmappos*)malloc(m->width * m->height * sizeof(Tmappos)); if (m->dat == NULL) { free(m); return NULL; @@ -164,7 +164,7 @@ Tmap *load_map_from_memory(void *mem) { // saves a map to file int save_map(Tmap *m, char *fname) { FILE *fp; - char header[6] = "AX4MAP"; + char header[7] = "AX4MAP"; // open file fp = fopen(fname, "wb"); @@ -222,41 +222,41 @@ void draw_map(BITMAP *bmp, Tmap *sm, int dx, int dy, int w, int h, int edit) { pos = tx + ty * sm->width; if (sm->dat[pos].tile) { - draw_sprite(bmp, sm->data[sm->dat[pos].tile + TILE000 - 1].dat, dx + x*16 + ax, dy + y*16 + ay); + draw_sprite(bmp, (BITMAP*)sm->data[sm->dat[pos].tile + TILE000 - 1].dat, dx + x*16 + ax, dy + y*16 + ay); } if (sm->dat[pos].item) { if (sm->dat[pos].item == MAP_EGG) { - draw_sprite(bmp, sm->data[EGG].dat, dx + x*16 + ax, dy + y*16 + ay); + draw_sprite(bmp, (BITMAP*)sm->data[EGG].dat, dx + x*16 + ax, dy + y*16 + ay); } else if (sm->dat[pos].item == MAP_1UP) { - draw_sprite(bmp, sm->data[ONEUP].dat, dx + x*16 + ax, dy + y*16 + ay); + draw_sprite(bmp, (BITMAP*)sm->data[ONEUP].dat, dx + x*16 + ax, dy + y*16 + ay); } else if (sm->dat[pos].item == MAP_STAR) { - draw_sprite(bmp, sm->data[STAR].dat, dx + x*16 + ax, dy + y*16 + ay); + draw_sprite(bmp, (BITMAP*)sm->data[STAR].dat, dx + x*16 + ax, dy + y*16 + ay); } else if (sm->dat[pos].item == MAP_HEART) { - draw_sprite(bmp, sm->data[HEART].dat, dx + x*16 + ax, dy + y*16 + ay); + draw_sprite(bmp, (BITMAP*)sm->data[HEART].dat, dx + x*16 + ax, dy + y*16 + ay); } else if (sm->dat[pos].item == MAP_CHERRY) { - draw_sprite(bmp, sm->data[CHERRY].dat, dx + x*16 + ax, dy + y*16 + ay); + draw_sprite(bmp, (BITMAP*)sm->data[CHERRY].dat, dx + x*16 + ax, dy + y*16 + ay); } else if (sm->dat[pos].item == MAP_LOLA) { - draw_sprite(bmp, sm->data[LOLA].dat, dx + x*16 + ax, dy + y*16 + ay); + draw_sprite(bmp, (BITMAP*)sm->data[LOLA].dat, dx + x*16 + ax, dy + y*16 + ay); } } if (sm->dat[pos].type) { if (sm->dat[pos].type == MAP_SPIN) { - draw_sprite(bmp, sm->data[SPIN1 + ((ABS(game_count) >> 2) % 4)].dat, dx + x*16 + ax, dy + y*16 + ay); + draw_sprite(bmp, (BITMAP*)sm->data[SPIN1 + ((ABS(game_count) >> 2) % 4)].dat, dx + x*16 + ax, dy + y*16 + ay); } if (sm->dat[pos].type == MAP_WATER) { - blit(sm->data[WATER].dat, bmp, ((ABS(game_count) >> 2) % 4) << 4, 0, dx + x*16 + ax, dy + y*16 + ay, 16, 16); + blit((BITMAP*)sm->data[WATER].dat, bmp, ((ABS(game_count) >> 2) % 4) << 4, 0, dx + x*16 + ax, dy + y*16 + ay, 16, 16); } if (sm->dat[pos].type == MAP_SURFACE) { - masked_blit(sm->data[WATER_SURFACE].dat, bmp, ((ABS(game_count) >> 2) % 8) << 4, 0, dx + x*16 + ax, dy + y*16 + ay, 16, 16); + masked_blit((BITMAP*)sm->data[WATER_SURFACE].dat, bmp, ((ABS(game_count) >> 2) % 8) << 4, 0, dx + x*16 + ax, dy + y*16 + ay, 16, 16); } } @@ -271,28 +271,28 @@ void draw_map(BITMAP *bmp, Tmap *sm, int dx, int dy, int w, int h, int edit) { textout(bmp, font, "GL", dx + x*16 + ax, dy + y*16 + ay, 255); } if (sm->dat[pos].type == MAP_ENEMY1) { - draw_sprite(bmp, sm->data[ENEMY1_01 + ((ABS(game_count) >> 3) % 4)].dat, dx + x*16 + ax, dy + y*16 + ay); + draw_sprite(bmp, (BITMAP*)sm->data[ENEMY1_01 + ((ABS(game_count) >> 3) % 4)].dat, dx + x*16 + ax, dy + y*16 + ay); } if (sm->dat[pos].type == MAP_ENEMY2) { - draw_sprite(bmp, sm->data[ENEMY2_01 + ((ABS(game_count) >> 3) % 4)].dat, dx + x*16 + ax, dy + y*16 + ay - 8); + draw_sprite(bmp, (BITMAP*)sm->data[ENEMY2_01 + ((ABS(game_count) >> 3) % 4)].dat, dx + x*16 + ax, dy + y*16 + ay - 8); } if (sm->dat[pos].type == MAP_ENEMY3) { - draw_sprite(bmp, sm->data[ENEMY3].dat, dx + x*16 + ax, dy + y*16 + ay - 96); + draw_sprite(bmp, (BITMAP*)sm->data[ENEMY3].dat, dx + x*16 + ax, dy + y*16 + ay - 96); } if (sm->dat[pos].type == MAP_ENEMY4) { - draw_sprite(bmp, sm->data[ENEMY4].dat, dx + x*16 + ax, dy + y*16 + ay); + draw_sprite(bmp, (BITMAP*)sm->data[ENEMY4].dat, dx + x*16 + ax, dy + y*16 + ay); } if (sm->dat[pos].type == MAP_ENEMY5) { - draw_sprite(bmp, sm->data[ENEMY5_01].dat, dx + x*16 + ax, dy + y*16 + ay); + draw_sprite(bmp, (BITMAP*)sm->data[ENEMY5_01].dat, dx + x*16 + ax, dy + y*16 + ay); } if (sm->dat[pos].type == MAP_ENEMY6) { - draw_sprite(bmp, sm->data[ENEMY6].dat, dx + x*16 + ax, dy + y*16 + ay); + draw_sprite(bmp, (BITMAP*)sm->data[ENEMY6].dat, dx + x*16 + ax, dy + y*16 + ay); } if (sm->dat[pos].type == MAP_GUARD1) { - draw_sprite(bmp, sm->data[GUARD1_1].dat, dx + x*16 + ax, dy + y*16 + ay - 16); + draw_sprite(bmp, (BITMAP*)sm->data[GUARD1_1].dat, dx + x*16 + ax, dy + y*16 + ay - 16); } if (sm->dat[pos].type == MAP_GUARD2) { - draw_sprite(bmp, sm->data[GUARD2_1a].dat, dx + x*16 + ax, dy + y*16 + ay - 32); + draw_sprite(bmp, (BITMAP*)sm->data[GUARD2_1a].dat, dx + x*16 + ax, dy + y*16 + ay - 32); } } } @@ -339,7 +339,7 @@ void change_map_size(Tmap *sm, int dw, int dh, int dir_flags) { tsm.width = sm->width; tsm.height = sm->height; sm->height += dh; - sm->dat = malloc(sm->width * sm->height * sizeof(Tmappos)); + sm->dat = (Tmappos*)malloc(sm->width * sm->height * sizeof(Tmappos)); for(i=0;iwidth*sm->height;i++) sm->dat[i].tile = sm->dat[i].mask = sm->dat[i].type = sm->dat[i].item = 0; // copy relevant parts @@ -361,7 +361,7 @@ void change_map_size(Tmap *sm, int dw, int dh, int dir_flags) { tsm.width = sm->width; tsm.height = sm->height; sm->width += dw; - sm->dat = malloc(sm->width * sm->height * sizeof(Tmappos)); + sm->dat = (Tmappos*)malloc(sm->width * sm->height * sizeof(Tmappos)); for(i=0;iwidth*sm->height;i++) sm->dat[i].tile = sm->dat[i].mask = sm->dat[i].type = sm->dat[i].item = 0; // copy relevant parts diff --git a/src/map.h b/src/map.h index 5dfb974..b204cc6 100644 --- a/src/map.h +++ b/src/map.h @@ -72,7 +72,7 @@ typedef struct { } Tmappos; // map header (overall stuff) -typedef struct { +typedef struct Tmap { char name[32]; char dummy[27]; char map_data_needs_to_be_destroyed; @@ -87,7 +87,7 @@ typedef struct { DATAFILE *data; int start_x; int start_y; -} Tmap; +}; // functions @@ -111,4 +111,4 @@ int adjust_xpos (Tmap *m, int x, int y, int ground, int dx); -#endif \ No newline at end of file +#endif diff --git a/src/options.h b/src/options.h index b1e3c55..83041af 100644 --- a/src/options.h +++ b/src/options.h @@ -43,4 +43,4 @@ void save_options(Toptions *o, PACKFILE *fp); void load_options(Toptions *o, PACKFILE *fp); void reset_options(Toptions *o); -#endif \ No newline at end of file +#endif diff --git a/src/particle.c b/src/particle.c index 5435d58..1e28c5e 100644 --- a/src/particle.c +++ b/src/particle.c @@ -20,18 +20,11 @@ - +#include "main.h" #include "particle.h" -// pointer to datafile -DATAFILE *data; - - -// set datafile to use -void set_datafile(DATAFILE *d) { - data = d; -} - +// the particles themselves +Tparticle particle[MAX_PARTICLES]; // inits variables in a particle void set_particle(Tparticle *p, int x, int y, double dx, double dy, int color, int life, int bmp) { @@ -47,8 +40,8 @@ void set_particle(Tparticle *p, int x, int y, double dx, double dy, int color, i // draws particle depending on map offset (ox and oy) void draw_particle(BITMAP *bmp, Tparticle*p, int ox, int oy) { - int x = p->x - ox; - int y = p->y - oy; + int x = (int)(p->x - ox); + int y = (int)(p->y - oy); // is the particle inside the screen if (x < -16 || x > bmp->w + 16 || y < -16 || y > bmp->h +16) return; @@ -57,12 +50,12 @@ void draw_particle(BITMAP *bmp, Tparticle*p, int ox, int oy) { if (p->bmp == -1) putpixel(bmp, x, y, p->color); else { - BITMAP *b = data[p->bmp + (p->color == -1 ? p->count>>1 : 0)].dat; + BITMAP *b = (BITMAP*)data[p->bmp + (p->color == -1 ? p->count>>1 : 0)].dat; draw_sprite(bmp, b, x - b->w/2, y - b->h/2); } } -// updates the particle data (position etc) +// updates the particle particledata (position etc) void update_particle(Tparticle* p) { p->x += p->dx; p->y += p->dy; diff --git a/src/particle.h b/src/particle.h index f81ee87..9e27a5b 100644 --- a/src/particle.h +++ b/src/particle.h @@ -31,21 +31,20 @@ // the particle struct -typedef struct { +typedef struct Tparticle { double x, y; double dx, dy; int color; int life; int count; int bmp; -} Tparticle; +}; // the particles themselves -Tparticle particle[MAX_PARTICLES]; +extern Tparticle particle[MAX_PARTICLES]; // functions -void set_datafile(DATAFILE *d); void reset_particles(Tparticle *p, int max); Tparticle *get_free_particle(Tparticle *p, int max); void set_particle(Tparticle *p, int x, int y, double dx, double dy, int color, int life, int bmp); @@ -54,4 +53,4 @@ void update_particle(Tparticle *p); void update_particle_with_map(Tparticle *p, Tmap *m); void create_burst(Tparticle *ps, int x, int y, int spread, int num, int life, int bmp); -#endif \ No newline at end of file +#endif diff --git a/src/player.c b/src/player.c index a608281..edd1671 100644 --- a/src/player.c +++ b/src/player.c @@ -25,6 +25,8 @@ #include "timer.h" #include "../data/data.h" +Tplayer player; + // draws the player depending on his state void draw_player(BITMAP *bmp, Tplayer *p, int x, int y) { BITMAP *head, *body; @@ -33,26 +35,26 @@ void draw_player(BITMAP *bmp, Tplayer *p, int x, int y) { if (p->wounded && (game_count % 2)) return; if (p->actor->status == AC_DEAD) { - head = p->actor->data[HERO_NORM].dat; - body = p->actor->data[HERO_JUMP].dat; + head = (BITMAP*)p->actor->data[HERO_NORM].dat; + body = (BITMAP*)p->actor->data[HERO_JUMP].dat; draw_sprite_v_flip(bmp, body, x, y - 32); draw_sprite_v_flip(bmp, head, x, y - 16); } else if (p->actor->status == AC_BALL) { if (!p->actor->direction) - rotate_sprite(bmp, p->actor->data[HERO_BALL].dat, x, y-16, itofix(p->angle)); + rotate_sprite(bmp, (BITMAP*)p->actor->data[HERO_BALL].dat, x, y-16, itofix(p->angle)); else - rotate_sprite_v_flip(bmp, p->actor->data[HERO_BALL].dat, x, y-16, itofix(p->angle + 128)); + rotate_sprite_v_flip(bmp, (BITMAP*)p->actor->data[HERO_BALL].dat, x, y-16, itofix(p->angle + 128)); } else if (p->actor->status != AC_EAT) { - if (p->actor->status == AC_FULL) head = p->actor->data[HERO_FULL].dat; - else if (p->actor->status == AC_SPIT) head = p->actor->data[HERO_SPIT].dat; - else head = p->actor->data[HERO_NORM].dat; + if (p->actor->status == AC_FULL) head = (BITMAP*)p->actor->data[HERO_FULL].dat; + else if (p->actor->status == AC_SPIT) head = (BITMAP*)p->actor->data[HERO_SPIT].dat; + else head = (BITMAP*)p->actor->data[HERO_NORM].dat; if (p->jumping) - body = p->actor->data[HERO_JUMP].dat; + body = (BITMAP*)p->actor->data[HERO_JUMP].dat; else - body = p->actor->data[p->actor->frames[p->actor->frame]].dat; + body = (BITMAP*)p->actor->data[p->actor->frames[p->actor->frame]].dat; if (p->actor->direction) { draw_sprite_h_flip(bmp, body, x, y - 16); @@ -66,15 +68,15 @@ void draw_player(BITMAP *bmp, Tplayer *p, int x, int y) { else { if (!p->jumping) { if (p->actor->direction) { - draw_sprite_h_flip(bmp, p->actor->data[HERO_EAT].dat, x, y - 16); + draw_sprite_h_flip(bmp, (BITMAP*)p->actor->data[HERO_EAT].dat, x, y - 16); } else { - draw_sprite(bmp, p->actor->data[HERO_EAT].dat, x - 16, y - 16); + draw_sprite(bmp, (BITMAP*)p->actor->data[HERO_EAT].dat, x - 16, y - 16); } } else { - head = p->actor->data[HERO_SPIT].dat; - body = p->actor->data[HERO_JUMP].dat; + head = (BITMAP*)p->actor->data[HERO_SPIT].dat; + body = (BITMAP*)p->actor->data[HERO_JUMP].dat; if (p->actor->direction) { draw_sprite_h_flip(bmp, body, x, y - 16); draw_sprite_h_flip(bmp, head, x, y - 16); diff --git a/src/player.h b/src/player.h index 0f19f95..cccb21d 100644 --- a/src/player.h +++ b/src/player.h @@ -26,7 +26,7 @@ // struct for the player -typedef struct { +typedef struct Tplayer { Tactor *actor; int score; @@ -49,15 +49,14 @@ typedef struct { int stars; int cherries_taken; int stars_taken; -} Tplayer; - +}; // the player -Tplayer player; +extern Tplayer player; // functions void draw_player(BITMAP *bmp, Tplayer *p, int x, int y); void wound_player(Tplayer *p); void kill_player(Tplayer *p); -#endif \ No newline at end of file +#endif diff --git a/src/script.c b/src/script.c index 5efb139..8ef1d51 100644 --- a/src/script.c +++ b/src/script.c @@ -33,9 +33,11 @@ // silly value #define NO_CHANGE -3249587 +// array holding the sounds ids +int active_sounds[MAX_SCRIPT_SOUNDS]; -// datafile to use -DATAFILE *data; +// scriptdatafile to use +DATAFILE *scriptdata; // internal buffers BITMAP *buffer; BITMAP *swap_buffer; @@ -55,7 +57,7 @@ void draw_speak_bulb(BITMAP *bmp, DATAFILE *d, int src_x, int src_y, int up, int // get max text length for(i = 0; i < lines; i ++) { - int len = text_length(d[THE_FONT].dat, rows[i]); + int len = text_length((FONT*)d[THE_FONT].dat, rows[i]); if (max_w < len) max_w = len; } @@ -80,16 +82,16 @@ void draw_speak_bulb(BITMAP *bmp, DATAFILE *d, int src_x, int src_y, int up, int line(bmp, x1 + 4, y2, x2 - 4, y2, 1); line(bmp, x2+1, y1 + 4, x2+1, y2 - 4, 1); line(bmp, x1 + 4, y2+1, x2 - 4, y2+1, 1); - draw_sprite(bmp, d[BULB_TL].dat, x1, y1); - draw_sprite(bmp, d[BULB_BL].dat, x1, y2 - 5); - draw_sprite(bmp, d[BULB_TR].dat, x2 - 5, y1); - draw_sprite(bmp, d[BULB_BR].dat, x2 - 5, y2 - 5); + draw_sprite(bmp, (BITMAP*)d[BULB_TL].dat, x1, y1); + draw_sprite(bmp, (BITMAP*)d[BULB_BL].dat, x1, y2 - 5); + draw_sprite(bmp, (BITMAP*)d[BULB_TR].dat, x2 - 5, y1); + draw_sprite(bmp, (BITMAP*)d[BULB_BR].dat, x2 - 5, y2 - 5); if (arrow) - draw_sprite(bmp, d[(left ? (up ? BULBA_TL : BULBA_BL) : (up ? BULBA_TR : BULBA_BR))].dat, xa, ya); + draw_sprite(bmp, (BITMAP*)d[(left ? (up ? BULBA_TL : BULBA_BL) : (up ? BULBA_TR : BULBA_BR))].dat, xa, ya); // draw text for(i = 0; i < lines; i ++) { - textout(bmp, d[THE_FONT].dat, rows[i], x1 + 4, y1 + 5 + i * 9, 1); + textout(bmp, (FONT*)d[THE_FONT].dat, rows[i], x1 + 4, y1 + 5 + i * 9, 1); } } @@ -144,7 +146,7 @@ int set_object(char *name, int x, int y, int dir) { // create new if not found if (o == NULL) { - o = malloc(sizeof(Tscript_object)); + o = (Tscript_object*)malloc(sizeof(Tscript_object)); if (o == NULL) return 0; new_object = 1; o->x = 0; @@ -162,31 +164,31 @@ int set_object(char *name, int x, int y, int dir) { // set bitmap if (!stricmp(name, "helicopter")) { - o->bmp[0] = data[CHOPPER1].dat; - o->bmp[1] = data[CHOPPER2].dat; - o->bmp[2] = data[CHOPPER3].dat; - o->bmp[3] = data[CHOPPER4].dat; + o->bmp[0] = (BITMAP*)scriptdata[CHOPPER1].dat; + o->bmp[1] = (BITMAP*)scriptdata[CHOPPER2].dat; + o->bmp[2] = (BITMAP*)scriptdata[CHOPPER3].dat; + o->bmp[3] = (BITMAP*)scriptdata[CHOPPER4].dat; o->frames = 4; } - else if (!stricmp(name, "cage1")) o->bmp[0] = data[CAGE_SML1].dat; - else if (!stricmp(name, "cage2")) o->bmp[0] = data[CAGE_BIG].dat; - else if (!stricmp(name, "cage3")) o->bmp[0] = data[CAGE_SML2].dat; - else if (!stricmp(name, "chain")) o->bmp[0] = data[CHAIN].dat; - else if (!stricmp(name, "lola")) o->bmp[0] = data[LOLA].dat; - else if (!stricmp(name, "alex")) o->bmp[0] = data[ALEX].dat; - else if (!stricmp(name, "ufo")) o->bmp[0] = data[UFO_BIG].dat; - else if (!stricmp(name, "ufo0")) o->bmp[0] = data[UFO0].dat; - else if (!stricmp(name, "ufo1")) o->bmp[0] = data[UFO1].dat; - else if (!stricmp(name, "beam")) o->bmp[0] = data[UFOBEAM].dat; - else if (!stricmp(name, "ship0")) o->bmp[0] = data[SHIP0].dat; - else if (!stricmp(name, "ship1")) o->bmp[0] = data[SHIP1].dat; - else if (!stricmp(name, "ball")) o->bmp[0] = data[HERO_BALL].dat; - else if (!strncmp(name, "drumcan", 7)) o->bmp[0] = data[DRUMCAN].dat; + else if (!stricmp(name, "cage1")) o->bmp[0] = (BITMAP*)scriptdata[CAGE_SML1].dat; + else if (!stricmp(name, "cage2")) o->bmp[0] = (BITMAP*)scriptdata[CAGE_BIG].dat; + else if (!stricmp(name, "cage3")) o->bmp[0] = (BITMAP*)scriptdata[CAGE_SML2].dat; + else if (!stricmp(name, "chain")) o->bmp[0] = (BITMAP*)scriptdata[CHAIN].dat; + else if (!stricmp(name, "lola")) o->bmp[0] = (BITMAP*)scriptdata[LOLA].dat; + else if (!stricmp(name, "alex")) o->bmp[0] = (BITMAP*)scriptdata[ALEX].dat; + else if (!stricmp(name, "ufo")) o->bmp[0] = (BITMAP*)scriptdata[UFO_BIG].dat; + else if (!stricmp(name, "ufo0")) o->bmp[0] = (BITMAP*)scriptdata[UFO0].dat; + else if (!stricmp(name, "ufo1")) o->bmp[0] = (BITMAP*)scriptdata[UFO1].dat; + else if (!stricmp(name, "beam")) o->bmp[0] = (BITMAP*)scriptdata[UFOBEAM].dat; + else if (!stricmp(name, "ship0")) o->bmp[0] = (BITMAP*)scriptdata[SHIP0].dat; + else if (!stricmp(name, "ship1")) o->bmp[0] = (BITMAP*)scriptdata[SHIP1].dat; + else if (!stricmp(name, "ball")) o->bmp[0] = (BITMAP*)scriptdata[HERO_BALL].dat; + else if (!strncmp(name, "drumcan", 7)) o->bmp[0] = (BITMAP*)scriptdata[DRUMCAN].dat; else o->bmp[0] = NULL; // rearrange pointers if (new_object) { - o->next = (struct Tscript_object *)objects; + o->next = (Tscript_object *)objects; objects = o; } @@ -202,7 +204,7 @@ int set_line(char *name, Tscript_object *src, int sx, int sy, Tscript_object *ds // create new if not found if (o == NULL) { - o = malloc(sizeof(Tscript_object)); + o = (Tscript_object*)malloc(sizeof(Tscript_object)); if (o == NULL) return 0; new_object = 1; o->line = 1; @@ -289,7 +291,7 @@ void cmd_showbmp(char *name) { blit(buffer, swap_buffer, 0, 0, 0, 0, 160, 120); } else if (!stricmp(name, "treetops")) { - blit(data[INTRO_BG].dat, swap_buffer, 0, 0, 0, 0, 160, 120); + blit((BITMAP*)scriptdata[INTRO_BG].dat, swap_buffer, 0, 0, 0, 0, 160, 120); } else if (!stricmp(name, "darkness")) { clear_to_color(swap_buffer, 2); @@ -340,7 +342,7 @@ void cmd_speak(Ttoken *t, int arrow) { t = (Ttoken *)t->next; } - draw_speak_bulb(swap_buffer, data, sx, sy, up, left, lines, rows, arrow); + draw_speak_bulb(swap_buffer, scriptdata, sx, sy, up, left, lines, rows, arrow); } @@ -581,8 +583,8 @@ int run_script(char *script, DATAFILE *d) { Ttoken *token; int i; - // set datafile - data = d; + // set scriptdatafile + scriptdata = d; clear_keybuf(); diff --git a/src/script.h b/src/script.h index d025b6c..b1d1d0e 100644 --- a/src/script.h +++ b/src/script.h @@ -26,7 +26,7 @@ // struct holding script data -typedef struct { +typedef struct Tscript_object { char name[16]; int x, y, vx, vy; // position and velocity BITMAP *bmp[4]; @@ -37,12 +37,12 @@ typedef struct { struct Tscript_object *line_to; struct Tscript_object *next; -} Tscript_object; +}; // max number of sounds played by the script #define MAX_SCRIPT_SOUNDS 16 // array holding the sounds ids -int active_sounds[MAX_SCRIPT_SOUNDS]; +extern int active_sounds[MAX_SCRIPT_SOUNDS]; // functions @@ -51,4 +51,4 @@ void draw_speak_bulb(BITMAP *bmp, DATAFILE *d, int src_x, int src_y, int up, int -#endif \ No newline at end of file +#endif diff --git a/src/scroller.h b/src/scroller.h index b31e521..b5144f7 100644 --- a/src/scroller.h +++ b/src/scroller.h @@ -51,4 +51,4 @@ void restart_scroller(Tscroller *sc); -#endif \ No newline at end of file +#endif diff --git a/src/shooter.c b/src/shooter.c index 3193d5d..e906823 100644 --- a/src/shooter.c +++ b/src/shooter.c @@ -239,8 +239,7 @@ Tshooter_event s_level[] = { // PIXEL PERFECT COLLISION ROUTINES COURTESY OF IVAN BALDO'S PPCOL -#define pp_check_bb_collision_general(x1,y1,w1,h1,x2,y2,w2,h2) (!( ((x1)>=(x2)+(w2)) || ((x2)>=(x1)+(w1)) || \ - ((y1)>=(y2)+(h2)) || ((y2)>=(y1)+(h1)) )) +#define pp_check_bb_collision_general(x1,y1,w1,h1,x2,y2,w2,h2) (!( ((x1)>=(x2)+(w2)) || ((x2)>=(x1)+(w1)) || ((y1)>=(y2)+(h2)) || ((y2)>=(y1)+(h1)) )) #define pp_check_bb_collision(mask1,mask2,x1,y1,x2,y2) pp_check_bb_collision_general(x1,y1,mask1->w,mask1->h,x2,y2,mask2->w,mask2->h) int s_check_pp_collision(BITMAP *spr1, BITMAP *spr2, int x1, int y1, int x2, int y2) { @@ -339,9 +338,9 @@ static void s_start_music(int startorder) { void s_draw_object(BITMAP *bmp, Tspace_object *o) { if (o->type != SO_EXPLOSION) { if (!o->hit || o->type == SO_PLAYER_BULLET) - draw_sprite(bmp, s_data[o->image].dat, (int)o->x, (int)o->y); + draw_sprite(bmp, (BITMAP*)s_data[o->image].dat, (int)o->x, (int)o->y); else - draw_character(bmp, s_data[o->image].dat, (int)o->x, (int)o->y, 4); + draw_character(bmp, (BITMAP*)s_data[o->image].dat, (int)o->x, (int)o->y, 4); } else { int c = (o->energy + 8) >> 3; @@ -362,15 +361,15 @@ void s_draw_status_bar(BITMAP *bmp, int x, int y) { int padding; // draw bar - blit(s_data[STATUSBAR].dat, bmp, 0, 0, 0, 109, 160, 11); + blit((BITMAP*)s_data[STATUSBAR].dat, bmp, 0, 0, 0, 109, 160, 11); // draw lives for(i = 0; i < s_var.lives; i ++) - draw_sprite(bmp, s_data[ST_LIFE].dat, x + 3 + i * 8, y + 3); + draw_sprite(bmp, (BITMAP*)s_data[ST_LIFE].dat, x + 3 + i * 8, y + 3); // draw stars for(i = 0; i < 5; i ++) - draw_sprite(bmp, s_data[(i < s_var.power_gauge ? ST_STAR_ON : ST_STAR_OFF)].dat, x + 36 + i * 8, y + 3); + draw_sprite(bmp, (BITMAP*)s_data[(i < s_var.power_gauge ? ST_STAR_ON : ST_STAR_OFF)].dat, x + 36 + i * 8, y + 3); // draw score sprintf(score_str, "%d", s_var.show_score); @@ -379,8 +378,8 @@ void s_draw_status_bar(BITMAP *bmp, int x, int y) { padding_str[i] = '0'; padding_str[i] = '\0'; strcat(padding_str, score_str); - textprintf_right(bmp, s_data[SPACE_FONT].dat, x + 160, y + 2, 3, "%s", padding_str); - if (s_var.score) textprintf_right(bmp, s_data[SPACE_FONT].dat, x + 160, y + 2, 4, "%s", score_str); + textprintf_right(bmp, (FONT*)s_data[SPACE_FONT].dat, x + 160, y + 2, 3, "%s", padding_str); + if (s_var.score) textprintf_right(bmp, (FONT*)s_data[SPACE_FONT].dat, x + 160, y + 2, 4, "%s", score_str); } @@ -388,8 +387,8 @@ void s_draw_frame(BITMAP *bmp) { int i; // blit bg - blit(s_data[BG1].dat, bmp, 0, 0, -(game_count % 160), 0, 160, 120); - blit(s_data[BG1].dat, bmp, 0, 0, 160 - (game_count % 160), 0, 160, 120); + blit((BITMAP*)s_data[BG1].dat, bmp, 0, 0, -(game_count % 160), 0, 160, 120); + blit((BITMAP*)s_data[BG1].dat, bmp, 0, 0, 160 - (game_count % 160), 0, 160, 120); // draw stars for(i = 0; i < 64; i ++) @@ -512,8 +511,8 @@ void s_update_object(Tspace_object *o) { if (o->x > o->d1) { o->x += o->vx; o->t = 0; - o->ty = o->y; - o->tx = o->x; + o->ty = (int)o->y; + o->tx = (int)o->x; } else { o->y = o->ty + fixtoi(fmul(ftofix(o->vy), fsin(itofix(o->t)))); @@ -826,7 +825,7 @@ void s_check_collision(Tspace_object *array_a, int num_a, Tspace_object *array_b for(b = 0; b < num_b; b ++) { if (array_b[b].alive && !array_b[b].hit) { // do bb collision - if (s_check_pp_collision(s_data[array_a[a].image].dat, s_data[array_b[b].image].dat, + if (s_check_pp_collision((BITMAP*)s_data[array_a[a].image].dat, (BITMAP*)s_data[array_b[b].image].dat, (int)array_a[a].x, (int)array_a[a].y, (int)array_b[b].x, (int)array_b[b].y)) { @@ -1097,14 +1096,14 @@ void s_activate_sign(int game_over, double vy) { // the player can enter his/hers name void s_get_player_name(char *name) { clear_to_color(s_buffer, 1); - blit(s_data[BG1].dat, s_buffer, 0, 0, 0, 0, 160, 120); + blit((BITMAP*)s_data[BG1].dat, s_buffer, 0, 0, 0, 0, 160, 120); textout_outline_center(s_buffer, "Congratulations,", 80, 8); textout_outline_center(s_buffer, "You've got", 80, 19); textout_outline_center(s_buffer, "a high score!", 80, 30); textout_outline_center(s_buffer, "Enter your name:", 80, 55); blit_to_screen(s_buffer); fade_in_pal_black(100, s_dp); - get_string(s_buffer, name, 10, s_data[SPACE_FONT].dat, 50, 80, 4, s_var.ctrl); + get_string(s_buffer, name, 10, (FONT*)s_data[SPACE_FONT].dat, 50, 80, 4, s_var.ctrl); } // runs the shooter diff --git a/src/shooter.h b/src/shooter.h index 41a07a6..b8025bf 100644 --- a/src/shooter.h +++ b/src/shooter.h @@ -118,4 +118,4 @@ typedef struct { int start_shooter(Tcontrol *c, int with_sound); -#endif \ No newline at end of file +#endif diff --git a/src/timer.c b/src/timer.c index 8bade02..bad6514 100644 --- a/src/timer.c +++ b/src/timer.c @@ -23,6 +23,13 @@ #include "allegro.h" #include "timer.h" +volatile int frame_count; +volatile int fps; +volatile int logic_count; +volatile int lps; +volatile int cycle_count; +volatile int game_count; + // keeps track of frames each second void fps_counter(void) { fps = frame_count; @@ -60,4 +67,4 @@ int install_timers() { game_count ++; return TRUE; -} \ No newline at end of file +} diff --git a/src/timer.h b/src/timer.h index 4fcc481..5bf7ab5 100644 --- a/src/timer.h +++ b/src/timer.h @@ -24,12 +24,12 @@ #define _TIMERS_H_ // the variables used by the timers -volatile int frame_count; -volatile int fps; -volatile int logic_count; -volatile int lps; -volatile int cycle_count; -volatile int game_count; +extern volatile int frame_count; +extern volatile int fps; +extern volatile int logic_count; +extern volatile int lps; +extern volatile int cycle_count; +extern volatile int game_count; // functions @@ -37,4 +37,4 @@ int install_timers(); void fps_counter(void); void cycle_counter(void); -#endif \ No newline at end of file +#endif diff --git a/src/token.c b/src/token.c index 1d95975..e2528d7 100644 --- a/src/token.c +++ b/src/token.c @@ -33,7 +33,7 @@ // creates a new token Ttoken *create_token(char *word) { - Ttoken *tok = malloc(sizeof(Ttoken)); + Ttoken *tok = (Ttoken*)malloc(sizeof(Ttoken)); if (tok != NULL) { tok->word = strdup(word); tok->next = NULL; diff --git a/src/token.h b/src/token.h index d8634f1..707855e 100644 --- a/src/token.h +++ b/src/token.h @@ -25,7 +25,7 @@ // the struct for a token -typedef struct { +typedef struct Ttoken { char *word; struct Ttoken *next; } Ttoken; @@ -41,4 +41,4 @@ char *get_next_word(Ttoken *t); Ttoken *tokenize(char *str); -#endif \ No newline at end of file +#endif -- 2.21.0 From 773d561c9d3d89448631ae6f853bb67cc28c34e3 Mon Sep 17 00:00:00 2001 From: Jerome Duval Date: Sun, 12 May 2019 15:14:44 +0200 Subject: replace fsin,fmul,fcos with fixsin,fixmul,fixcos diff --git a/src/main.c b/src/main.c index cec8bc6..662f9d1 100644 --- a/src/main.c +++ b/src/main.c @@ -1161,9 +1161,9 @@ void draw_custom_ending(BITMAP *bmp) { blit((BITMAP*)data[INTRO_BG].dat, bmp, 0, 0, 0, 0, 160, 120); - r = 70 + fixtoi(20 * fcos(itofix(game_count >> 1)) + 20 * fsin(itofix((int)(game_count / 2.7))) ); + r = 70 + fixtoi(20 * fixcos(itofix(game_count >> 1)) + 20 * fixsin(itofix((int)(game_count / 2.7))) ); for(i = 0; i < 256; i += 32) - draw_sprite(bmp, head, 80 - head->w/2 + fixtoi(r * fcos(itofix(game_count + i))), 60 - head->h/2 + fixtoi(r * fsin(itofix(game_count + i)))); + draw_sprite(bmp, head, 80 - head->w/2 + fixtoi(r * fixcos(itofix(game_count + i))), 60 - head->h/2 + fixtoi(r * fixsin(itofix(game_count + i)))); draw_sprite_h_flip(bmp, (BITMAP*)data[ALEX].dat, 60, 40); draw_sprite(bmp, (BITMAP*)data[LOLA].dat, 84, 40); @@ -2488,7 +2488,7 @@ void draw_title(BITMAP *bmp, int tick) { textout(bmp, (FONT*)data[THE_FONT].dat, "QUIT", x+1, y+1, 1); textout(bmp, (FONT*)data[THE_FONT].dat, "QUIT", x, y, 4); - draw_sprite(bmp, (BITMAP*)data[POINTER].dat, x - 25 + fixtoi(3 * fcos(itofix(tick << 2))), 44 + menu_choice * step); + draw_sprite(bmp, (BITMAP*)data[POINTER].dat, x - 25 + fixtoi(3 * fixcos(itofix(tick << 2))), 44 + menu_choice * step); } diff --git a/src/shooter.c b/src/shooter.c index e906823..6005406 100644 --- a/src/shooter.c +++ b/src/shooter.c @@ -499,12 +499,12 @@ void s_update_object(Tspace_object *o) { break; case SM_SIN_WAVE: o->x += o->vx; - o->y = o->d2 + fixtoi(fmul(ftofix(o->vy), fsin(itofix(o->t)))); + o->y = o->d2 + fixtoi(fixmul(ftofix(o->vy), fixsin(itofix(o->t)))); o->t += o->d1; break; case SM_COS_WAVE: o->x += o->vx; - o->y = o->d2 + fixtoi(fmul(ftofix(o->vy), fcos(itofix(o->t)))); + o->y = o->d2 + fixtoi(fixmul(ftofix(o->vy), fixcos(itofix(o->t)))); o->t += o->d1; break; case SM_BOSS_1: @@ -515,8 +515,8 @@ void s_update_object(Tspace_object *o) { o->tx = (int)o->x; } else { - o->y = o->ty + fixtoi(fmul(ftofix(o->vy), fsin(itofix(o->t)))); - o->x = o->tx - fixtoi(10 * fsin(itofix(o->t >> 1))); + o->y = o->ty + fixtoi(fixmul(ftofix(o->vy), fixsin(itofix(o->t)))); + o->x = o->tx - fixtoi(10 * fixsin(itofix(o->t >> 1))); o->t ++; } break; @@ -572,7 +572,7 @@ void s_update_object(Tspace_object *o) { else if (o->image == ENEMY15) { int i; for(i = 0; i < 256; i += 32) - s_make_enemy_bullet((int)o->x + o->bw / 2, (int)o->y + o->bh, fixtof(1 * fcos(itofix(i - 6))), fixtof(1 * fsin(itofix(i - 6)))); + s_make_enemy_bullet((int)o->x + o->bw / 2, (int)o->y + o->bh, fixtof(1 * fixcos(itofix(i - 6))), fixtof(1 * fixsin(itofix(i - 6)))); o->fire_counter = 200 + rand()%50; } -- 2.21.0