1 /* 2000-08-13T15:29:40Z
3 * handle input from x11 and keyboard and joystick
12 struct PLAYER ply[MAX_PLAYERS];
17 struct EngineSnapshotInfo_EM engine_snapshot_em;
19 void game_init_vars(void)
23 RandomEM = 1684108901;
25 for (y = 0; y < HEIGHT; y++)
26 for (x = 0; x < WIDTH; x++)
27 lev.cavebuf[x][y] = Zborder;
28 for (y = 0; y < HEIGHT; y++)
29 for (x = 0; x < WIDTH; x++)
30 lev.nextbuf[x][y] = Zborder;
31 for (y = 0; y < HEIGHT; y++)
32 for (x = 0; x < WIDTH; x++)
33 lev.drawbuf[x][y] = Zborder;
34 for (y = 0; y < HEIGHT; y++)
35 for (x = 0; x < WIDTH; x++)
36 lev.boombuf[x][y] = Xblank;
38 for (x = 0; x < WIDTH; x++)
39 lev.cavecol[x] = lev.cavebuf[x];
40 for (x = 0; x < WIDTH; x++)
41 lev.nextcol[x] = lev.nextbuf[x];
42 for (x = 0; x < WIDTH; x++)
43 lev.drawcol[x] = lev.drawbuf[x];
44 for (x = 0; x < WIDTH; x++)
45 lev.boomcol[x] = lev.boombuf[x];
47 lev.cave = lev.cavecol;
48 lev.next = lev.nextcol;
49 lev.draw = lev.drawcol;
50 lev.boom = lev.boomcol;
53 void InitGameEngine_EM(void)
59 RedrawPlayfield_EM(FALSE);
62 static void UpdateGameDoorValues_EM(void)
66 void GameActions_EM(byte action[MAX_PLAYERS], boolean warp_mode)
69 boolean any_player_dropping = FALSE;
71 RandomEM = RandomEM * 129 + 1;
73 frame = (frame - 1) & 7;
75 for (i = 0; i < MAX_PLAYERS; i++)
76 readjoy(action[i], &ply[i]);
78 UpdateEngineValues(screen_x / TILEX, screen_y / TILEY, ply[0].x, ply[0].y);
90 UpdateGameDoorValues_EM();
93 for (i = 0; i < MAX_PLAYERS; i++)
94 if (ply[i].joy_drop &&
96 ply[i].dynamite_cnt > 0 &&
97 ply[i].dynamite_cnt < 5)
98 any_player_dropping = TRUE;
100 CheckSingleStepMode_EM(action, frame, game_em.any_player_moving,
101 game_em.any_player_snapping, any_player_dropping);
103 RedrawPlayfield_EM(FALSE);
106 /* read input device for players */
108 void readjoy(byte action, struct PLAYER *ply)
110 int north = 0, east = 0, south = 0, west = 0;
111 int snap = 0, drop = 0;
113 if (game_em.use_single_button && action & (JOY_BUTTON_1 | JOY_BUTTON_2))
114 action |= JOY_BUTTON_1 | JOY_BUTTON_2;
116 if (action & JOY_LEFT)
119 if (action & JOY_RIGHT)
125 if (action & JOY_DOWN)
128 if (action & JOY_BUTTON_1)
131 if (action & JOY_BUTTON_2)
134 /* always update drop action */
135 ply->joy_drop = drop;
137 if (ply->joy_stick || (north | east | south | west)) /* (no "| snap"!) */
144 /* when storing last action, only update snap action with direction */
145 /* (prevents clearing direction if snapping stopped before frame 7) */
146 ply->joy_snap = snap;
149 /* if no direction was stored before, allow setting snap to current state */
154 ply->joy_snap = snap;
156 /* use bug with snap key (mainly TAS keys) sometimes moving the player */
157 if (game_em.use_snap_key_bug)
158 ply->joy_snap = snap;
161 void SaveEngineSnapshotValues_EM(void)
165 engine_snapshot_em.game_em = game_em;
166 engine_snapshot_em.lev = lev;
168 engine_snapshot_em.RandomEM = RandomEM;
169 engine_snapshot_em.frame = frame;
171 engine_snapshot_em.screen_x = screen_x;
172 engine_snapshot_em.screen_y = screen_y;
174 for (i = 0; i < 4; i++)
175 engine_snapshot_em.ply[i] = ply[i];
178 void LoadEngineSnapshotValues_EM(void)
182 game_em = engine_snapshot_em.game_em;
183 lev = engine_snapshot_em.lev;
185 RandomEM = engine_snapshot_em.RandomEM;
186 frame = engine_snapshot_em.frame;
188 screen_x = engine_snapshot_em.screen_x;
189 screen_y = engine_snapshot_em.screen_y;
191 for (i = 0; i < 4; i++)
192 ply[i] = engine_snapshot_em.ply[i];