1 /* 2000-08-13T15:29:40Z
3 * handle input from x11 and keyboard and joystick
11 unsigned long RandomEM;
14 struct PLAYER ply[MAX_PLAYERS];
21 static short *Index[4][HEIGHT];
22 static short Array[4][HEIGHT][WIDTH];
27 void game_init_vars(void)
31 RandomEM = 1684108901;
33 for (y = 0; y < HEIGHT; y++)
34 for (x = 0; x < WIDTH; x++)
35 Array[0][y][x] = ZBORDER;
36 for (y = 0; y < HEIGHT; y++)
37 for (x = 0; x < WIDTH; x++)
38 Array[1][y][x] = ZBORDER;
39 for (y = 0; y < HEIGHT; y++)
40 for (x = 0; x < WIDTH; x++)
41 Array[2][y][x] = ZBORDER;
42 for (y = 0; y < HEIGHT; y++)
43 for (x = 0; x < WIDTH; x++)
44 Array[3][y][x] = Xblank;
46 for (y = 0; y < HEIGHT; y++)
47 Index[0][y] = Array[0][y];
48 for (y = 0; y < HEIGHT; y++)
49 Index[1][y] = Array[1][y];
50 for (y = 0; y < HEIGHT; y++)
51 Index[2][y] = Array[2][y];
52 for (y = 0; y < HEIGHT; y++)
53 Index[3][y] = Array[3][y];
61 void InitGameEngine_EM()
71 void GameActions_EM(byte action[MAX_PLAYERS])
73 static unsigned long game_frame_delay = 0;
75 unsigned long game_frame_delay_value = getGameFrameDelay_EM(20);
77 unsigned long game_frame_delay_value = getGameFrameDelay_EM(25);
82 /* this is done in screens.c/HandleGameActions() by calling BackToFront() */
83 XSync(display, False); /* block until all graphics are drawn */
86 WaitUntilDelayReached(&game_frame_delay, game_frame_delay_value);
90 RandomEM = RandomEM * 129 + 1;
92 frame = (frame - 1) & 7;
94 for (i = 0; i < MAX_PLAYERS; i++)
95 readjoy(action[i], &ply[i]);
97 UpdateEngineValues(screen_x / TILEX, screen_y / TILEY);
110 if (game_frame_delay_value > 0) /* do not redraw values in warp mode */
111 DrawGameDoorValues_EM();
115 if (lev.time_initial == 0)
117 else if (lev.time > 0)
122 if (lev.time_initial > 0 &&
123 lev.time > 0 && lev.time <= 50 && lev.time % 5 == 0 && setup.time_limit)
124 play_sound(-1, -1, SAMPLE_time);
130 void GameActions_EM(byte action)
132 static unsigned long game_frame_delay = 0;
134 unsigned long game_frame_delay_value = getGameFrameDelay_EM(20);
136 unsigned long game_frame_delay_value = getGameFrameDelay_EM(25);
140 /* this is done in screens.c/HandleGameActions() by calling BackToFront() */
141 XSync(display, False); /* block until all graphics are drawn */
144 WaitUntilDelayReached(&game_frame_delay, game_frame_delay_value);
148 RandomEM = RandomEM * 129 + 1;
150 frame = (frame - 1) & 7;
154 UpdateEngineValues(screen_x / TILEX, screen_y / TILEY);
167 if (game_frame_delay_value > 0) /* do not redraw values in warp mode */
168 DrawGameDoorValues_EM();
172 if (lev.time_initial == 0)
174 else if (lev.time > 0)
179 if (lev.time_initial > 0 &&
180 lev.time > 0 && lev.time <= 50 && lev.time % 5 == 0 && setup.time_limit)
181 play_sound(-1, -1, SAMPLE_time);
188 /* read input device for players */
192 void readjoy(byte action, struct PLAYER *ply)
194 int north = 0, east = 0, south = 0, west = 0;
195 int snap = 0, drop = 0;
197 if (action & JOY_LEFT)
200 if (action & JOY_RIGHT)
206 if (action & JOY_DOWN)
209 if (action & JOY_BUTTON_1)
212 if (action & JOY_BUTTON_2)
215 ply->joy_snap = snap;
216 ply->joy_drop = drop;
218 if (ply->joy_stick || (north | east | south | west))
229 void readjoy(byte action)
231 int north = 0, east = 0, south = 0, west = 0;
232 int snap = 0, drop = 0;
234 if (action & JOY_LEFT)
237 if (action & JOY_RIGHT)
243 if (action & JOY_DOWN)
246 if (action & JOY_BUTTON_1)
249 if (action & JOY_BUTTON_2)
253 ply1.joy_snap = snap;
254 ply1.joy_drop = drop;
255 if (ply1.joy_stick || (north | east | south | west))
265 ply2.joy_snap = snap;
266 ply2.joy_drop = drop;
267 if (ply2.joy_stick || (north | east | south | west))