- int x,y;
- char name[MAXNAME+2];
- int temp;
- int pos;
-
- Random = 1684108901;
-
- for(y = 0; y < HEIGHT; y++) for(x = 0; x < WIDTH; x++) Array[0][y][x] = ZBORDER;
- for(y = 0; y < HEIGHT; y++) for(x = 0; x < WIDTH; x++) Array[1][y][x] = ZBORDER;
- for(y = 0; y < HEIGHT; y++) for(x = 0; x < WIDTH; x++) Array[2][y][x] = ZBORDER;
- for(y = 0; y < HEIGHT; y++) for(x = 0; x < WIDTH; x++) Array[3][y][x] = Xblank;
-
- for(y = 0; y < HEIGHT; y++) Index[0][y] = Array[0][y];
- for(y = 0; y < HEIGHT; y++) Index[1][y] = Array[1][y];
- for(y = 0; y < HEIGHT; y++) Index[2][y] = Array[2][y];
- for(y = 0; y < HEIGHT; y++) Index[3][y] = Array[3][y];
-
- Cave = Index[0];
- Next = Index[1];
- Draw = Index[2];
- Boom = Index[3];
-
- player_mode = 1; /* start off as single player */
- strcpy(player_name, "dave");
- player_level = 0;
-
- input_pause = 1 * 0;
-
- for(;;) {
-
- pos = 4;
-
- title_initscreen();
-
- for(temp = 0; temp < 7; temp++) drawmenu(temp); /* display all lines */
- title_blitants(4 + pos);
-
- title_blitscore();
- title_animscreen();
-
-#if 0
- printf("--> M1: xwindow == %ld\n", xwindow);
-#endif
-
- temp = 1;
- for(;;) {
- input_eventloop();
- if(input_die) return(0);
- if(input_refresh) blitscreen();
-
-#if 0
- printf("--> M2: xwindow == %ld\n", xwindow);
-#endif
-
- if(!input_pause) {
- title_blitants(4 + pos);
- title_blitscore();
- title_animscreen();
-
-#if 0
- printf("--> M3: xwindow == %ld\n", xwindow);
-#endif
-
- ply1.joy_n = ply1.joy_e = ply1.joy_s = ply1.joy_w = 0;
-
- readjoy();
-
- if(temp == 0) {
- if(ply1.joy_fire) break;
-
- if(ply1.joy_e && player_level < 99) {
- player_level++;
- drawmenu(2);
- }
- if(ply1.joy_w && player_level > 0) {
- player_level--;
- drawmenu(2);
- }
- if(ply1.joy_n && pos > 0) {
- drawmenu(pos);
- pos--;
- title_blitants(4 + pos);
- }
- if(ply1.joy_s && pos < 4) {
- drawmenu(pos);
- pos++;
- title_blitants(4 + pos);
- }
- }
- temp = (ply1.joy_n || ply1.joy_e || ply1.joy_s || ply1.joy_w || ply1.joy_fire);
- }
- }
-
-#if 0
- printf("--> M4: xwindow == %ld\n", xwindow);
-#endif
-
- name[MAXNAME] = 0;
- snprintf(name, MAXNAME+2, "%s/lev%02d", EM_LVL_DIR, player_level);
- if(name[MAXNAME]) snprintf_overflow("read a level in cave/");
-
- if(cave_convert(name)) continue;
-
-#if 0
- printf("--> M5: xwindow == %ld\n", xwindow);
-#endif
-
- game_initscreen();
-#if 0
- printf("--> M6: xwindow == %ld\n", xwindow);
-#endif
- game_blitscore();
-#if 0
- printf("--> M7: xwindow == %ld\n", xwindow);
-#endif
- game_animscreen();
-
-#if 0
- printf("--> M8: xwindow == %ld\n", xwindow);
-#endif
-
- for(;;) {
- input_eventloop();
- if(input_die || input_esc) break;
- if(input_refresh) blitscreen();
-
- if(!input_pause) {
- game_animscreen();
-
- frame = (frame - 1) & 7;
-
- readjoy();
-
- if(frame == 7) {
- synchro_1();
- synchro_2();
- }
- if(frame == 6) {
- synchro_3();
- sound_play();
- game_blitscore();
- }
- }
- }
- }
+ int i;
+ boolean any_player_dropping = FALSE;
+
+ RandomEM = RandomEM * 129 + 1;
+
+ frame = (frame - 1) & 7;
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ readjoy(action[i], &ply[i]);
+
+ UpdateEngineValues(screen_x / TILEX, screen_y / TILEY, ply[0].x, ply[0].y);
+
+ if (frame == 7)
+ {
+ synchro_1();
+ synchro_2();
+ }
+
+ if (frame == 6)
+ {
+ synchro_3();
+ sound_play();
+
+ UpdateGameDoorValues_EM();
+ }
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ if (ply[i].joy_drop &&
+ ply[i].dynamite &&
+ ply[i].dynamite_cnt > 0 &&
+ ply[i].dynamite_cnt < 5)
+ any_player_dropping = TRUE;
+
+ CheckSingleStepMode_EM(action, frame, game_em.any_player_moving,
+ game_em.any_player_snapping, any_player_dropping);
+
+ RedrawPlayfield_EM(FALSE);