#ifndef GRV_H #define GRV_H 1 #include #include #include #include #include #include #include "graphics.h" #ifdef SDL_SUBDIR # include "SDL/SDL.h" # include "SDL/SDL_keyboard.h" #else # include "SDL.h" # include "SDL_keyboard.h" #endif #define min(x,y) ((x)<(y)?(x):(y)) #define max(x,y) ((x)>(y)?(x):(y)) /* Get random bytes from the system */ int get_random_bytes(void *, int); void randomize(void); /* Get a random floating-point number between 0 and 1 */ extern void init_genrand(unsigned long); extern double genrand_res53(void); extern unsigned long genrand_int32(void); extern void init_by_array(const unsigned long *, unsigned long); #define rnd() genrand_res53() #define irnd(n) ((int)(genrand_int32() % (n))) /* Command-line options */ struct opts { int nonet; /* Don't access the network server */ int window; /* Run in a window */ int debug; /* No parachute mode (for debugging) */ }; extern struct opts opt; #define ELev 75 /* Ending level */ struct xy { int x, y; }; struct gameparams { /* Yes, score can be negative, although it's highly unlikely */ int64_t Sc; /* Score */ int64_t StScore; /* Score at start of level */ int64_t SBs; /* Total points in Super Bonus */ int Life; /* Lives left */ int Lvf; int GkCh; int Level; /* Current level */ int MLev; /* Max level achieved */ int ZLevel; int KulSpr; int Bon; /* Bonus available right now */ int TF; /* double? */ int FS; /* Ghost speed (1 normal, -1 scared, 0 frozen) */ int x, y; /* Player coordinates */ int XWk, YWk; /* Player movement */ int Hyp; int ChBd; int Bar; /* Number of cherries on screen */ int OrigBar; /* Cherries at level start */ int Bombs; /* Number of bombs on the level */ int c; /* Main level color */ int c2; /* Alternate level color */ int Cheat; /* Cheat codes used */ int InfLife; /* Infinite life cheat */ int EOLWait; /* Standard death/end of level pause? */ int TZero; /* Time at start of level (ms) */ int Speed; /* Desired game speed ms/game round */ double Tid; /* Time since level start (float s) */ enum { Status_Live, /* Player alive */ Status_Dead, /* Player dead */ Status_Done, /* Player done with level */ Status_Quit, /* Level exit (treasure) */ } Status; int nwhite; /* Number of white cherries */ int nextwhite; /* Next white cherry (if any) */ struct xy whitecherrylist[190]; uint64_t gameid; /* (Hopefully) unique ID for high score list */ int have_id; /* Is ID frozen yet? */ }; extern struct gameparams gp; enum actions { act_none, /* No action */ act_apple, /* Apple fall */ act_bomb, /* Bomb goes off */ act_bonus_on, /* BONUS light on */ act_bonus_off, /* BONUS light off */ act_smash, /* "Smash" */ act_toolate, /* Time expired */ act_droplevel, /* Drop one level (finale level) */ act_door, /* Open door */ act_ghost_thaw, /* Thaw frozen ghosts */ act_ghost_normal, /* Return ghosts to normal */ }; struct monster { int x, y; int dead; }; #define MAXGHOST 5 extern struct monster ghost[MAXGHOST]; /* Keyboard handling */ #define NKEYS 11 extern SDLKey kbd_keys[NKEYS]; /* User-defined SDL event types */ enum user_event { event_next_round, /* Next game round */ event_blink, /* Handle blinking */ event_sleep, /* Sleep expired */ }; /* Character symbols */ #define SYM_PLAYER 0x01 #define SYM_GHOST 0x02 #define SYM_ROCK 0x04 #define SYM_CLUSTER 0x0f #define SYM_NOTHING ' ' #define SYM_DIAMOND '*' #define SYM_MYSTERY '?' #define SYM_POROUS_WALL 0xb0 #define SYM_WALL 0xb1 #define SYM_CHERRY 0xeb #define SYM_BOMB 0xe5 #define SYM_SHOT 0xec #define SYM_BONUS 0xf9 #define SYM_APPLE 0xfe /* All possible doors */ #define DOORS "\xb9\xba\xbb\xbc\xc8\xc9\xca\xcb\xcc\xcd\xce" /* utils.c */ int fg(int r, int c); int bg(int r, int c); int busy(int r, int c); Uint32 post_periodic(Uint32 interval, void *param); Uint32 post_oneshot(Uint32 interval, void *param); void mymssleep(int ms); char *format_time(double t); /* drawlevel.c */ void drawlevel(void); void levelscreen(void); /* grv.c */ void initscreen(int w); void update_score(void); void update_shots(void); void update_power(void); void update_jump(void); void message(int col, const char *fmt, ...); /* play.c */ void white2black(void); void play(void); void fall_rock(int x, int y); void fall_apple(int x, int y); void kill_ghost(int x, int y); void take_cherry(void); void take_diamond(void); /* keyboard.c */ void push_key(SDL_KeyboardEvent *ke); SDL_KeyboardEvent *poll_key(void); SDL_KeyboardEvent *get_key(void); /* action.c */ void reset_actions(void); void addaction(int x, int y, double when, enum actions what); void removeaction(int x, int y, enum actions what); void handle_action(void); void retime_all(double when, enum actions what); /* bullets.c */ void add_bullet(int x, int y, int dx, int dy, int color); void run_bullets(void); /* mystery.c */ void mystery(void); /* highscore.c */ void highscore_load(void); void highscore_download(void); void highscore_save(void); void highscore_upload(void); void highscore_show(int myrank, int save); void highscore_endgame(void); /* intro.c */ void intro(void); /* prefs.c */ void load_prefs(void); void set_keys(void); /* homedir.c */ void goto_grv_dir(void); #endif /* GRV_H */