3 * handle interaction between screen and cave
11 struct PLAYER ply[MAX_PLAYERS];
13 struct EngineSnapshotInfo_EM engine_snapshot_em;
15 /* handle input actions for players */
17 static void readjoy(byte action, struct PLAYER *ply)
19 int north = 0, east = 0, south = 0, west = 0;
20 int snap = 0, drop = 0;
22 if (game_em.use_single_button && action & (JOY_BUTTON_1 | JOY_BUTTON_2))
23 action |= JOY_BUTTON_1 | JOY_BUTTON_2;
25 if (action & JOY_LEFT)
28 if (action & JOY_RIGHT)
34 if (action & JOY_DOWN)
37 if (action & JOY_BUTTON_1)
40 if (action & JOY_BUTTON_2)
43 /* always update drop action */
46 if (ply->joy_stick || (north | east | south | west)) /* (no "| snap"!) */
53 /* when storing last action, only update snap action with direction */
54 /* (prevents clearing direction if snapping stopped before frame 7) */
58 /* if no direction was stored before, allow setting snap to current state */
65 /* use bug with snap key (mainly TAS keys) sometimes moving the player */
66 if (game_em.use_snap_key_bug)
70 void InitGameEngine_EM(void)
76 RedrawPlayfield_EM(FALSE);
79 static void UpdateGameDoorValues_EM(void)
83 void GameActions_EM(byte action[MAX_PLAYERS], boolean warp_mode)
86 boolean any_player_dropping = FALSE;
88 game_em.random = game_em.random * 129 + 1;
90 frame = (frame - 1) & 7;
92 for (i = 0; i < MAX_PLAYERS; i++)
93 readjoy(action[i], &ply[i]);
95 UpdateEngineValues(screen_x / TILEX, screen_y / TILEY, ply[0].x, ply[0].y);
107 UpdateGameDoorValues_EM();
110 for (i = 0; i < MAX_PLAYERS; i++)
111 if (ply[i].joy_drop &&
113 ply[i].dynamite_cnt > 0 &&
114 ply[i].dynamite_cnt < 5)
115 any_player_dropping = TRUE;
117 CheckSingleStepMode_EM(action, frame, game_em.any_player_moving,
118 game_em.any_player_snapping, any_player_dropping);
120 RedrawPlayfield_EM(FALSE);
123 void SaveEngineSnapshotValues_EM(void)
127 engine_snapshot_em.game_em = game_em;
128 engine_snapshot_em.lev = lev;
130 engine_snapshot_em.frame = frame;
131 engine_snapshot_em.screen_x = screen_x;
132 engine_snapshot_em.screen_y = screen_y;
134 for (i = 0; i < 4; i++)
135 engine_snapshot_em.ply[i] = ply[i];
138 void LoadEngineSnapshotValues_EM(void)
142 game_em = engine_snapshot_em.game_em;
143 lev = engine_snapshot_em.lev;
145 frame = engine_snapshot_em.frame;
146 screen_x = engine_snapshot_em.screen_x;
147 screen_y = engine_snapshot_em.screen_y;
149 for (i = 0; i < 4; i++)
150 ply[i] = engine_snapshot_em.ply[i];