1 /* 2000-08-13T15:29:40Z
3 * handle input from x11 and keyboard and joystick
9 unsigned long RandomEM;
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()
69 /* blit playfield from scroll buffer to normal back buffer for fading in */
70 BlitScreenToBitmap_EM(backbuffer);
74 void GameActions_EM(byte action[MAX_PLAYERS], boolean warp_mode)
77 boolean player_is_dropping = FALSE;
82 if (action[0] == 0 && foo != 0)
83 printf("KEY RELEASED @ %05d\n", FrameCounter);
90 if (FrameCounter % 10 == 0)
92 printf("::: %05d: %lu, %d\n", FrameCounter, RandomEM, frame);
107 RandomEM = RandomEM * 129 + 1;
109 frame = (frame - 1) & 7;
111 for (i = 0; i < MAX_PLAYERS; i++)
112 readjoy(action[i], &ply[i]);
114 UpdateEngineValues(screen_x / TILEX, screen_y / TILEY);
127 if (!warp_mode) /* do not redraw values in warp mode */
128 DrawGameDoorValues_EM();
131 for (i = 0; i < MAX_PLAYERS; i++)
132 if (ply[i].joy_drop &&
134 ply[i].dynamite_cnt > 0 &&
135 ply[i].dynamite_cnt < 5)
136 player_is_dropping = TRUE;
138 CheckSingleStepMode_EM(action, frame, game_em.any_player_moving,
154 /* read input device for players */
156 void readjoy(byte action, struct PLAYER *ply)
158 int north = 0, east = 0, south = 0, west = 0;
159 int snap = 0, drop = 0;
161 if (action & JOY_LEFT)
164 if (action & JOY_RIGHT)
170 if (action & JOY_DOWN)
173 if (action & JOY_BUTTON_1)
176 if (action & JOY_BUTTON_2)
179 ply->joy_snap = snap;
180 ply->joy_drop = drop;
182 if (ply->joy_stick || (north | east | south | west))
191 void SaveEngineSnapshotValues_EM()
195 engine_snapshot_em.game_em = game_em;
196 engine_snapshot_em.lev = lev;
198 engine_snapshot_em.RandomEM = RandomEM;
199 engine_snapshot_em.frame = frame;
201 engine_snapshot_em.screen_x = screen_x;
202 engine_snapshot_em.screen_y = screen_y;
204 engine_snapshot_em.Boom = Boom;
205 engine_snapshot_em.Cave = Cave;
206 engine_snapshot_em.Next = Next;
207 engine_snapshot_em.Draw = Draw;
209 for (i = 0; i < 4; i++)
210 engine_snapshot_em.ply[i] = ply[i];
212 for (i = 0; i < 4; i++)
213 for (j = 0; j < HEIGHT; j++)
214 for (k = 0; k < WIDTH; k++)
215 engine_snapshot_em.Array[i][j][k] = Array[i][j][k];
218 void LoadEngineSnapshotValues_EM()
222 game_em = engine_snapshot_em.game_em;
223 lev = engine_snapshot_em.lev;
225 RandomEM = engine_snapshot_em.RandomEM;
226 frame = engine_snapshot_em.frame;
228 screen_x = engine_snapshot_em.screen_x;
229 screen_y = engine_snapshot_em.screen_y;
231 Boom = engine_snapshot_em.Boom;
232 Cave = engine_snapshot_em.Cave;
233 Next = engine_snapshot_em.Next;
234 Draw = engine_snapshot_em.Draw;
236 for (i = 0; i < 4; i++)
237 ply[i] = engine_snapshot_em.ply[i];
239 for (i = 0; i < 4; i++)
240 for (j = 0; j < HEIGHT; j++)
241 for (k = 0; k < WIDTH; k++)
242 Array[i][j][k] = engine_snapshot_em.Array[i][j][k];