added functions to get level position (tile) from screen position (pixel)
[rocksndiamonds.git] / src / game_em / graphics.c
index 03934a71e7beff39ab8d4f8a2e506c4771e1356c..3c68eb033c78c1e88e8179ce754fece1ee806722 100644 (file)
@@ -37,6 +37,16 @@ int screen_x, screen_y;                      /* current scroll position */
 static int screentiles[MAX_PLAYFIELD_HEIGHT + 2][MAX_PLAYFIELD_WIDTH + 2];
 static int crumbled_state[MAX_PLAYFIELD_HEIGHT + 2][MAX_PLAYFIELD_WIDTH + 2];
 
+int getFieldbufferOffsetX_EM()
+{
+  return screen_x % TILEX;
+}
+
+int getFieldbufferOffsetY_EM()
+{
+  return screen_y % TILEY;
+}
+
 void BlitScreenToBitmap_EM(Bitmap *target_bitmap)
 {
   /* blit all (up to four) parts of the scroll buffer to the target bitmap */
@@ -174,7 +184,8 @@ static void DrawLevelFieldCrumbled_EM(int x, int y, int sx, int sy,
 
   g = getObjectGraphic(x, y);
 
-  crumbled_border_size = g->crumbled_border_size * TILESIZE_VAR / TILESIZE;
+  crumbled_border_size =
+    g->crumbled_border_size * TILESIZE_VAR / g->crumbled_tile_size;
 
   for (i = 0; i < 4; i++)
   {