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 boolean north = FALSE;
21 boolean south = FALSE;
26 if (game_em.use_single_button && action & (JOY_BUTTON_1 | JOY_BUTTON_2))
27 action |= JOY_BUTTON_1 | JOY_BUTTON_2;
29 if (action & JOY_LEFT)
32 if (action & JOY_RIGHT)
38 if (action & JOY_DOWN)
41 if (action & JOY_BUTTON_1)
44 if (action & JOY_BUTTON_2)
47 /* always update drop action */
50 if (ply->joy_stick || (north | east | south | west)) /* (no "| snap"!) */
57 /* when storing last action, only update snap action with direction */
58 /* (prevents clearing direction if snapping stopped before frame 7) */
62 /* if no direction was stored before, allow setting snap to current state */
69 /* use bug with snap key (mainly TAS keys) sometimes moving the player */
70 if (game_em.use_snap_key_bug)
74 void InitGameEngine_EM(void)
82 RedrawPlayfield_EM(FALSE);
85 void GameActions_EM(byte action[MAX_PLAYERS], boolean warp_mode)
88 boolean any_player_dropping = FALSE;
90 game_em.random = game_em.random * 129 + 1;
92 frame = (frame + 1) % 8;
94 for (i = 0; i < MAX_PLAYERS; i++)
95 readjoy(action[i], &ply[i]);
97 UpdateEngineValues(CAVE_POS_X(screen_x / TILEX),
98 CAVE_POS_Y(screen_y / TILEY),
100 CAVE_POS_Y(ply[0].y));
104 for (i = 0; i < MAX_PLAYERS; i++)
105 if (ply[i].joy_drop &&
107 ply[i].dynamite_cnt > 0 &&
108 ply[i].dynamite_cnt < 5)
109 any_player_dropping = TRUE;
111 boolean single_step_mode_paused =
112 CheckSingleStepMode_EM(action, frame, game_em.any_player_moving,
113 game_em.any_player_snapping, any_player_dropping);
115 // draw wrapping around before going to single step pause mode
116 if (single_step_mode_paused && logic_check_wrap())
119 RedrawPlayfield_EM(FALSE);
122 void SaveEngineSnapshotValues_EM(void)
126 engine_snapshot_em.game_em = game_em;
127 engine_snapshot_em.lev = lev;
129 engine_snapshot_em.frame = frame;
130 engine_snapshot_em.screen_x = screen_x;
131 engine_snapshot_em.screen_y = screen_y;
133 for (i = 0; i < 4; i++)
134 engine_snapshot_em.ply[i] = ply[i];
137 void LoadEngineSnapshotValues_EM(void)
141 game_em = engine_snapshot_em.game_em;
142 lev = engine_snapshot_em.lev;
144 frame = engine_snapshot_em.frame;
145 screen_x = engine_snapshot_em.screen_x;
146 screen_y = engine_snapshot_em.screen_y;
148 for (i = 0; i < 4; i++)
149 ply[i] = engine_snapshot_em.ply[i];