1 /* 2000-08-13T15:29:40Z
3 * handle input from x11 and keyboard and joystick
11 unsigned long RandomEM;
17 unsigned short **Boom;
18 unsigned short **Cave;
19 unsigned short **Next;
20 unsigned short **Draw;
22 static unsigned short *Index[4][HEIGHT];
23 static unsigned short Array[4][HEIGHT][WIDTH];
25 extern unsigned int screen_x;
26 extern unsigned int screen_y;
28 void game_init_vars(void)
32 RandomEM = 1684108901;
34 for (y = 0; y < HEIGHT; y++)
35 for (x = 0; x < WIDTH; x++)
36 Array[0][y][x] = ZBORDER;
37 for (y = 0; y < HEIGHT; y++)
38 for (x = 0; x < WIDTH; x++)
39 Array[1][y][x] = ZBORDER;
40 for (y = 0; y < HEIGHT; y++)
41 for (x = 0; x < WIDTH; x++)
42 Array[2][y][x] = ZBORDER;
43 for (y = 0; y < HEIGHT; y++)
44 for (x = 0; x < WIDTH; x++)
45 Array[3][y][x] = Xblank;
47 for (y = 0; y < HEIGHT; y++)
48 Index[0][y] = Array[0][y];
49 for (y = 0; y < HEIGHT; y++)
50 Index[1][y] = Array[1][y];
51 for (y = 0; y < HEIGHT; y++)
52 Index[2][y] = Array[2][y];
53 for (y = 0; y < HEIGHT; y++)
54 Index[3][y] = Array[3][y];
62 void InitGameEngine_EM()
72 void GameActions_EM(byte action[MAX_PLAYERS])
74 static unsigned long game_frame_delay = 0;
76 unsigned long game_frame_delay_value = getGameFrameDelay_EM(20);
78 unsigned long game_frame_delay_value = getGameFrameDelay_EM(25);
83 /* this is done in screens.c/HandleGameActions() by calling BackToFront() */
84 XSync(display, False); /* block until all graphics are drawn */
87 WaitUntilDelayReached(&game_frame_delay, game_frame_delay_value);
91 RandomEM = RandomEM * 129 + 1;
93 frame = (frame - 1) & 7;
95 for (i = 0; i < 2; i++)
96 readjoy(action[i], i);
98 UpdateEngineValues(screen_x / TILEX, screen_y / TILEY);
111 if (game_frame_delay_value > 0) /* do not redraw values in warp mode */
112 DrawGameDoorValues_EM();
116 if (lev.time_initial == 0)
118 else if (lev.time > 0)
123 if (lev.time_initial > 0 &&
124 lev.time > 0 && lev.time <= 50 && lev.time % 5 == 0 && setup.time_limit)
125 play_sound(-1, -1, SAMPLE_time);
131 void GameActions_EM(byte action)
133 static unsigned long game_frame_delay = 0;
135 unsigned long game_frame_delay_value = getGameFrameDelay_EM(20);
137 unsigned long game_frame_delay_value = getGameFrameDelay_EM(25);
141 /* this is done in screens.c/HandleGameActions() by calling BackToFront() */
142 XSync(display, False); /* block until all graphics are drawn */
145 WaitUntilDelayReached(&game_frame_delay, game_frame_delay_value);
149 RandomEM = RandomEM * 129 + 1;
151 frame = (frame - 1) & 7;
155 UpdateEngineValues(screen_x / TILEX, screen_y / TILEY);
168 if (game_frame_delay_value > 0) /* do not redraw values in warp mode */
169 DrawGameDoorValues_EM();
173 if (lev.time_initial == 0)
175 else if (lev.time > 0)
180 if (lev.time_initial > 0 &&
181 lev.time > 0 && lev.time <= 50 && lev.time % 5 == 0 && setup.time_limit)
182 play_sound(-1, -1, SAMPLE_time);
189 /* read input device for players */
193 void readjoy(byte action, int player_nr)
195 unsigned int north = 0, east = 0, south = 0, west = 0;
196 unsigned int snap = 0, drop = 0;
198 if (action & JOY_LEFT)
201 if (action & JOY_RIGHT)
207 if (action & JOY_DOWN)
210 if (action & JOY_BUTTON_1)
213 if (action & JOY_BUTTON_2)
218 ply1.joy_snap = snap;
219 ply1.joy_drop = drop;
220 if (ply1.joy_stick || (north | east | south | west))
230 ply2.joy_snap = snap;
231 ply2.joy_drop = drop;
232 if (ply2.joy_stick || (north | east | south | west))
244 void readjoy(byte action)
246 unsigned int north = 0, east = 0, south = 0, west = 0;
247 unsigned int snap = 0, drop = 0;
249 if (action & JOY_LEFT)
252 if (action & JOY_RIGHT)
258 if (action & JOY_DOWN)
261 if (action & JOY_BUTTON_1)
264 if (action & JOY_BUTTON_2)
268 ply1.joy_snap = snap;
269 ply1.joy_drop = drop;
270 if (ply1.joy_stick || (north | east | south | west))
280 ply2.joy_snap = snap;
281 ply2.joy_drop = drop;
282 if (ply2.joy_stick || (north | east | south | west))