1 2 #ifndef EXTERN 3 #define EXTERN extern 4 #endif 5 6 #include <signal.h> 7 #include <setjmp.h> 8 #include <string.h> 9 #include <stdlib.h> 10 11 #include <X11/Xlib.h> 12 #include <X11/Xutil.h> 13 #include <X11/Xatom.h> 14 #include <X11/keysym.h> 15 16 #ifndef NULL 17 #define NULL 0L 18 #endif 19 20 #define sgn(x) ((x) ? (((x) > 0) ? 1 : -1) : 0) 21 #define abs(x) (((x) < 0) ? -(x) : (x)) 22 23 24 /*-- MACHINE DEPENDENCIES ----------------------------------------------------*/ 25 26 #ifdef VMS 27 EXTERN float vms_delay; 28 #define random() (rand() >> 16) 29 #define usleep(x) { vms_delay = (x) * 0.000001; lib$wait(&vms_delay); } 30 #endif 31 32 #ifdef ULTRIX 33 #include <sys/time.h> 34 EXTERN struct timeval st_delay; 35 #define usleep(x) { st_delay.tv_usec = (x); st_delay.tv_sec = 0; \ 36 select(32, NULL, NULL, NULL, &st_delay); } 37 #endif 38 39 #ifdef stellar 40 #include <sys/time.h> 41 EXTERN struct timeval st_delay; 42 #define usleep(x) { st_delay.tv_usec = (x); st_delay.tv_sec = 0; \ 43 select(32, NULL, NULL, NULL, &st_delay); } 44 #endif 45 46 /*----------------------------------------------------------------------------*/ 47 48 49 #define GHOST_SIZE 16 50 51 #define BLOCK_WIDTH 21 52 #define BLOCK_HEIGHT 16 53 54 #define WIN_WIDTH GHOST_SIZE * BLOCK_WIDTH 55 #define WIN_HEIGHT GHOST_SIZE * BLOCK_HEIGHT 56 57 #define FRUIT_WIDTH 20 58 #define FRUIT_HEIGHT 16 59 60 #define ICON_WIDTH 32 61 #define ICON_HEIGHT 32 62 63 #define MAX_GHOSTS 4 64 #define MAX_POWER_DOTS 4 65 66 #define CREDIT_WIDTH 195 67 #define CREDIT_HEIGHT 22 68 69 #define DEMOBOX_WIDTH 81 70 #define DEMOBOX_HEIGHT 49 71 72 #define TITLE_WIDTH 80 73 #define TITLE_HEIGHT 16 74 75 typedef int intm[8]; 76 typedef char charm[BLOCK_WIDTH]; 77 typedef charm mazedata[BLOCK_HEIGHT]; 78 typedef void (*funcptr)(); 79 80 EXTERN Atom DEC_icon_atom; 81 82 /* Xlib parameters */ 83 EXTERN Display * display; 84 EXTERN Window root, window; 85 EXTERN int screen, depth, black, white; 86 EXTERN Bool normal; 87 EXTERN Font font; 88 EXTERN int ascent, descent; 89 90 /* graphics contexts */ 91 EXTERN GC copyGC, orGC, clearGC, invertGC; 92 EXTERN GC powerGC, fullcopyGC, bitmapGC; 93 94 /* bitmaps */ 95 EXTERN Pixmap icon, map, save, powermap; 96 EXTERN Pixmap demo_map[5], demo_mask[5], demo_back, demo_gray; 97 EXTERN Pixmap credit, demobox, title, pause; 98 EXTERN Pixmap bghost[16], eghost[16], fghost[16], gghost[16]; 99 EXTERN Pixmap lpac[16], rpac[16], upac[16], dpac[16]; 100 EXTERN Pixmap *pac, small_pac, maze[128]; 101 EXTERN Pixmap dead_prot[11], deadpac[11]; 102 EXTERN Pixmap eat_pix[4], fval_pix[14], fruit_pix[14]; 103 104 /* regions */ 105 EXTERN Region fruit_region, power_region, full_region; 106 EXTERN Region ghost_region[MAX_GHOSTS], pac_region, region[2]; 107 108 /* position and direction variables */ 109 EXTERN int ghost_x[MAX_GHOSTS], ghost_y[MAX_GHOSTS]; 110 EXTERN int ghost_ix[MAX_GHOSTS], ghost_iy[MAX_GHOSTS]; 111 EXTERN int ghost_sx[MAX_GHOSTS], ghost_sy[MAX_GHOSTS]; 112 EXTERN int pac_x, pac_y, pac_ix, pac_iy, pac_sx, pac_sy; 113 114 /* additional ghost parameters */ 115 EXTERN funcptr drive[MAX_GHOSTS]; 116 EXTERN funcptr contact[MAX_GHOSTS]; 117 EXTERN Pixmap *ghost[MAX_GHOSTS]; 118 EXTERN int loops[MAX_GHOSTS]; 119 120 /* fruit parameters */ 121 EXTERN int fruit_count, fruit_times, fruit_x, fruit_y; 122 EXTERN Bool fruit_shown; 123 124 /* game parameters */ 125 EXTERN int level, plevel, lives; 126 EXTERN long score, high_score; 127 128 /* miscellaneous variables */ 129 EXTERN int grey_tick, flash_tick, off_tick; 130 EXTERN int count, count_sync, cr; 131 EXTERN Bool eat_mode; 132 EXTERN int door_x, door_y, eat_index; 133 EXTERN int numdots, powerdots, num_ghosts; 134 EXTERN mazedata md, dd; 135 EXTERN KeySym last_key; 136 EXTERN Bool dead, completed; 137 138 EXTERN jmp_buf jb_start; 139 140 EXTERN void follow(int); 141 EXTERN void run(int); 142 EXTERN void go_home(int); 143 EXTERN void hover(int); 144 EXTERN void hover2(int); 145 EXTERN void die(int); 146 EXTERN void eat(int); 147 EXTERN void noop(int); 148 EXTERN Bool pause_seq(); 149 150 void do_exit(); 151 void play_game(int); 152 void destroy_regions(); 153 void create_ghost(); 154 void create_pac(); 155 void create_fruit(); 156 void create_maze_symbols(); 157 void create_demo_images(); 158 void create_GCs(); 159 void create_window(int, char **); 160 void create_maps(); 161 void create_regions(); 162 void demo_seq(); 163 void display_title(); 164 void print_score(long); 165 void display_level(Bool); 166 void clear_maps(); 167 void read_maze(int); 168 void position_players(); 169 int set_lives(int); 170 void get_ready(); 171 void restore_status(); 172 void control_pac(); 173 void usleep(int); 174 void do_sleep(int); 175 void do_usleep(int); 176 void game_over(); 177 void finish(); 178 void control_pac(); 179 void check_dots(); 180 void check_normal_events(); 181