1 /* 2000-08-13T15:29:40Z
3 * handle input from x11 and keyboard and joystick
12 struct PLAYER ply[MAX_PLAYERS];
19 static short *Index[4][HEIGHT];
20 static short Array[4][HEIGHT][WIDTH];
25 struct EngineSnapshotInfo_EM engine_snapshot_em;
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()
67 RedrawPlayfield_EM(FALSE);
70 void UpdateGameDoorValues_EM()
74 void GameActions_EM(byte action[MAX_PLAYERS], boolean warp_mode)
77 boolean any_player_dropping = FALSE;
79 RandomEM = RandomEM * 129 + 1;
81 frame = (frame - 1) & 7;
83 for (i = 0; i < MAX_PLAYERS; i++)
84 readjoy(action[i], &ply[i]);
86 UpdateEngineValues(screen_x / TILEX, screen_y / TILEY, ply[0].x, ply[0].y);
99 UpdateGameDoorValues_EM();
102 for (i = 0; i < MAX_PLAYERS; i++)
103 if (ply[i].joy_drop &&
105 ply[i].dynamite_cnt > 0 &&
106 ply[i].dynamite_cnt < 5)
107 any_player_dropping = TRUE;
109 CheckSingleStepMode_EM(action, frame, game_em.any_player_moving,
110 game_em.any_player_snapping, any_player_dropping);
112 RedrawPlayfield_EM(FALSE);
115 /* read input device for players */
117 void readjoy(byte action, struct PLAYER *ply)
119 int north = 0, east = 0, south = 0, west = 0;
120 int snap = 0, drop = 0;
122 if (game_em.use_single_button && action & (JOY_BUTTON_1 | JOY_BUTTON_2))
123 action |= JOY_BUTTON_1 | JOY_BUTTON_2;
125 if (action & JOY_LEFT)
128 if (action & JOY_RIGHT)
134 if (action & JOY_DOWN)
137 if (action & JOY_BUTTON_1)
140 if (action & JOY_BUTTON_2)
143 /* always update drop action */
144 ply->joy_drop = drop;
146 if (ply->joy_stick || (north | east | south | west)) /* (no "| snap"!) */
153 /* when storing last action, only update snap action with direction */
154 /* (prevents clearing direction if snapping stopped before frame 7) */
155 ply->joy_snap = snap;
158 /* if no direction was stored before, allow setting snap to current state */
163 ply->joy_snap = snap;
165 /* use bug with snap key (mainly TAS keys) sometimes moving the player */
166 if (game_em.use_snap_key_bug)
167 ply->joy_snap = snap;
170 void SaveEngineSnapshotValues_EM()
174 engine_snapshot_em.game_em = game_em;
175 engine_snapshot_em.lev = lev;
177 engine_snapshot_em.RandomEM = RandomEM;
178 engine_snapshot_em.frame = frame;
180 engine_snapshot_em.screen_x = screen_x;
181 engine_snapshot_em.screen_y = screen_y;
183 engine_snapshot_em.Boom = Boom;
184 engine_snapshot_em.Cave = Cave;
185 engine_snapshot_em.Next = Next;
186 engine_snapshot_em.Draw = Draw;
188 for (i = 0; i < 4; i++)
189 engine_snapshot_em.ply[i] = ply[i];
191 for (i = 0; i < 4; i++)
192 for (j = 0; j < HEIGHT; j++)
193 for (k = 0; k < WIDTH; k++)
194 engine_snapshot_em.Array[i][j][k] = Array[i][j][k];
197 void LoadEngineSnapshotValues_EM()
201 game_em = engine_snapshot_em.game_em;
202 lev = engine_snapshot_em.lev;
204 RandomEM = engine_snapshot_em.RandomEM;
205 frame = engine_snapshot_em.frame;
207 screen_x = engine_snapshot_em.screen_x;
208 screen_y = engine_snapshot_em.screen_y;
210 Boom = engine_snapshot_em.Boom;
211 Cave = engine_snapshot_em.Cave;
212 Next = engine_snapshot_em.Next;
213 Draw = engine_snapshot_em.Draw;
215 for (i = 0; i < 4; i++)
216 ply[i] = engine_snapshot_em.ply[i];
218 for (i = 0; i < 4; i++)
219 for (j = 0; j < HEIGHT; j++)
220 for (k = 0; k < WIDTH; k++)
221 Array[i][j][k] = engine_snapshot_em.Array[i][j][k];