added centering levels that are smaller than the playfield (MM engine)
[rocksndiamonds.git] / src / tools.c
index d11d99d2effc0b5579c2206374facfdfda83a0d8..695a536223c87d07372d8d55be2a62f7b8dd888a 100644 (file)
@@ -360,30 +360,26 @@ static int getLevelFromScreenY_SP(int sy)
 
 static int getLevelFromScreenX_MM(int sx)
 {
-#if 0
   int level_xsize = level.native_mm_level->fieldx;
   int full_xsize = level_xsize * TILESIZE_VAR;
 
   sx -= (full_xsize < SXSIZE ? (SXSIZE - full_xsize) / 2 : 0);
-#endif
 
   int px = sx - SX;
-  int lx = px / TILESIZE_VAR;
+  int lx = (px + TILESIZE_VAR) / TILESIZE_VAR - 1;
 
   return lx;
 }
 
 static int getLevelFromScreenY_MM(int sy)
 {
-#if 0
   int level_ysize = level.native_mm_level->fieldy;
   int full_ysize = level_ysize * TILESIZE_VAR;
 
   sy -= (full_ysize < SYSIZE ? (SYSIZE - full_ysize) / 2 : 0);
-#endif
 
   int py = sy - SY;
-  int ly = py / TILESIZE_VAR;
+  int ly = (py + TILESIZE_VAR) / TILESIZE_VAR - 1;
 
   return ly;
 }
@@ -8747,6 +8743,23 @@ void CheckSaveEngineSnapshot_SP(boolean murphy_is_waiting,
   }
 }
 
+void CheckSaveEngineSnapshot_MM(boolean element_clicked,
+                               boolean button_released)
+{
+  if (button_released)
+  {
+    if (game.snapshot.mode == SNAPSHOT_MODE_EVERY_MOVE)
+      CheckSaveEngineSnapshotToList();
+  }
+  else if (element_clicked)
+  {
+    if (game.snapshot.mode != SNAPSHOT_MODE_EVERY_MOVE)
+      CheckSaveEngineSnapshotToList();
+
+    game.snapshot.changed_action = TRUE;
+  }
+}
+
 void CheckSingleStepMode_EM(byte action[MAX_PLAYERS], int frame,
                            boolean any_player_moving,
                            boolean any_player_snapping,
@@ -8777,6 +8790,16 @@ void CheckSingleStepMode_SP(boolean murphy_is_waiting,
   CheckSaveEngineSnapshot_SP(murphy_is_waiting, murphy_is_dropping);
 }
 
+void CheckSingleStepMode_MM(boolean element_clicked,
+                           boolean button_released)
+{
+  if (tape.single_step && tape.recording && !tape.pausing)
+    if (button_released)
+      TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
+
+  CheckSaveEngineSnapshot_MM(element_clicked, button_released);
+}
+
 void getGraphicSource_SP(struct GraphicInfo_SP *g_sp,
                         int graphic, int sync_frame, int x, int y)
 {