rnd-19980828
[rocksndiamonds.git] / src / game.c
index dbc5458281c82836719c2db85724588faebd3b11..424ca530d32b6650498dfe2de6a3cbcb52cbd4d8 100644 (file)
 #include "tape.h"
 #include "joystick.h"
 
-extern int Gamespeed;
-extern int Movemethod;
-extern int Movespeed[2];
+
+
+int tst = 0;
+int tst2 = 0;
+
+
+
+extern int GameSpeed;
+extern int MoveSpeed;
 
 void GetPlayerConfig()
 {
@@ -49,6 +55,7 @@ void GetPlayerConfig()
   joystick_nr = SETUP_2ND_JOYSTICK_ON(player.setup);
   quick_doors = SETUP_QUICK_DOORS_ON(player.setup);
   scroll_delay_on = SETUP_SCROLL_DELAY_ON(player.setup);
+  soft_scrolling_on = SETUP_SOFT_SCROLL_ON(player.setup);
 
   if (joystick_nr != old_joystick_nr)
   {
@@ -74,8 +81,10 @@ void InitGame()
   FrameCounter = 0;
   TimeFrames = 0;
   TimeLeft = level.time;
+  ScreenMovPos = 0;
   PlayerMovDir = MV_NO_MOVING;
   PlayerMovPos = 0;
+  PlayerGfxPos = 0;
   PlayerFrame = 0;
   PlayerPushing = FALSE;
   PlayerGone = LevelSolved = GameOver = SiebAktiv = FALSE;
@@ -105,8 +114,8 @@ void InitGame()
       case EL_SPIELFIGUR:
       case EL_SPIELER1:
        Feld[x][y] = EL_LEERRAUM;
-       JX = x;
-       JY = y;
+       JX = lastJX = x;
+       JY = lastJY = y;
        break;
       case EL_SPIELER2:
        Feld[x][y] = EL_LEERRAUM;
@@ -165,7 +174,7 @@ void InitGame()
        }
        break;
       case EL_DYNAMIT:
-       MovDelay[x][y] = 48;
+       MovDelay[x][y] = 96;
        break;
       case EL_BIRNE_AUS:
        Lights++;
@@ -588,12 +597,12 @@ void DrawDynamite(int x, int y)
 
   if (Feld[x][y]==EL_DYNAMIT)
   {
-    if ((phase = (48-MovDelay[x][y])/6) > 6)
+    if ((phase = (96-MovDelay[x][y])/12) > 6)
       phase = 6;
   }
   else
   {
-    if ((phase = ((48-MovDelay[x][y])/3) % 8) > 3)
+    if ((phase = ((96-MovDelay[x][y])/6) % 8) > 3)
       phase = 7-phase;
   }
 
@@ -610,12 +619,12 @@ void CheckDynamite(int x, int y)
     MovDelay[x][y]--;
     if (MovDelay[x][y])
     {
-      if (!(MovDelay[x][y] % 6))
+      if (!(MovDelay[x][y] % 12))
        PlaySoundLevel(x,y,SND_ZISCH);
 
-      if (Feld[x][y]==EL_DYNAMIT && !(MovDelay[x][y] % 6))
+      if (Feld[x][y]==EL_DYNAMIT && !(MovDelay[x][y] % 12))
        DrawDynamite(x,y);
-      else if (Feld[x][y]==EL_DYNABOMB && !(MovDelay[x][y] % 3))
+      else if (Feld[x][y]==EL_DYNABOMB && !(MovDelay[x][y] % 6))
        DrawDynamite(x,y);
 
       return;
@@ -629,7 +638,7 @@ void CheckDynamite(int x, int y)
 void Explode(int ex, int ey, int phase, int mode)
 {
   int x,y;
-  int num_phase = 9, delay = 1;
+  int num_phase = 9, delay = 2;
   int last_phase = num_phase*delay;
   int half_phase = (num_phase/2)*delay;
 
@@ -859,13 +868,13 @@ void Blurb(int x, int y)
     int graphic = (element==EL_BLURB_LEFT ? GFX_BLURB_LEFT : GFX_BLURB_RIGHT);
 
     if (!MovDelay[x][y])       /* neue Phase / noch nicht gewartet */
-      MovDelay[x][y] = 5;
+      MovDelay[x][y] = 9;
 
     if (MovDelay[x][y])                /* neue Phase / in Wartezustand */
     {
       MovDelay[x][y]--;
       if (MovDelay[x][y] && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
-       DrawGraphic(SCROLLX(x),SCROLLY(y),graphic+4-MovDelay[x][y]);
+       DrawGraphic(SCROLLX(x),SCROLLY(y),graphic+4-MovDelay[x][y]/2);
 
       if (!MovDelay[x][y])
       {
@@ -1084,7 +1093,7 @@ void TurnRound(int x, int y)
       MovDir[x][y] = left_dir;
 
     if (element==EL_KAEFER && MovDir[x][y] != old_move_dir)
-      MovDelay[x][y] = 5;
+      MovDelay[x][y] = 9;
     else if (element==EL_BUTTERFLY)    /* && MovDir[x][y]==left_dir) */
       MovDelay[x][y] = 1;
   }
@@ -1100,7 +1109,7 @@ void TurnRound(int x, int y)
       MovDir[x][y] = right_dir;
 
     if (element==EL_FLIEGER && MovDir[x][y] != old_move_dir)
-      MovDelay[x][y] = 5;
+      MovDelay[x][y] = 9;
     else if (element==EL_FIREFLY)      /* && MovDir[x][y]==right_dir) */
       MovDelay[x][y] = 1;
   }
@@ -1126,7 +1135,7 @@ void TurnRound(int x, int y)
     else
       MovDir[x][y] = back_dir;
 
-    MovDelay[x][y] = 8+8*RND(3);
+    MovDelay[x][y] = 16+16*RND(3);
   }
   else if (element==EL_MAMPFER2)
   {
@@ -1150,7 +1159,7 @@ void TurnRound(int x, int y)
     else
       MovDir[x][y] = back_dir;
 
-    MovDelay[x][y] = 8+8*RND(3);
+    MovDelay[x][y] = 16+16*RND(3);
   }
   else if (element==EL_PACMAN)
   {
@@ -1174,7 +1183,7 @@ void TurnRound(int x, int y)
     else
       MovDir[x][y] = back_dir;
 
-    MovDelay[x][y] = 3+RND(20);
+    MovDelay[x][y] = 6+RND(40);
   }
   else if (element==EL_SCHWEIN)
   {
@@ -1337,9 +1346,9 @@ void TurnRound(int x, int y)
       Moving2Blocked(x,y,&newx,&newy);
 
       if (IN_LEV_FIELD(newx,newy) && IS_FREE_OR_PLAYER(newx,newy))
-       MovDelay[x][y] = 4+4*!RND(3);
+       MovDelay[x][y] = 8+8*!RND(3);
       else
-       MovDelay[x][y] = 8;
+       MovDelay[x][y] = 16;
     }
     else
     {
@@ -1390,6 +1399,15 @@ void StartMoving(int x, int y)
 
   if (CAN_FALL(element) && y<lev_fieldy-1)
   {
+    if (PlayerPushing && PlayerMovPos)
+    {
+      int nextJX = JX + (JX - lastJX);
+      int nextJY = JY + (JY - lastJY);
+
+      if (x == nextJX && y == nextJY)
+       return;
+    }
+
     if (element==EL_MORAST_VOLL)
     {
       if (IS_FREE(x,y+1))
@@ -1401,7 +1419,7 @@ void StartMoving(int x, int y)
       else if (Feld[x][y+1]==EL_MORAST_LEER)
       {
        if (!MovDelay[x][y])
-         MovDelay[x][y] = 16;
+         MovDelay[x][y] = TILEY + 1;
 
        if (MovDelay[x][y])
        {
@@ -1430,7 +1448,7 @@ void StartMoving(int x, int y)
       else if (Feld[x][y+1]==EL_SIEB_LEER)
       {
        if (!MovDelay[x][y])
-         MovDelay[x][y] = 2;
+         MovDelay[x][y] = TILEY/4 + 1;
 
        if (MovDelay[x][y])
        {
@@ -1456,7 +1474,7 @@ void StartMoving(int x, int y)
       else if (Feld[x][y+1]==EL_SIEB2_LEER)
       {
        if (!MovDelay[x][y])
-         MovDelay[x][y] = 2;
+         MovDelay[x][y] = TILEY/4 + 1;
 
        if (MovDelay[x][y])
        {
@@ -1710,7 +1728,7 @@ void StartMoving(int x, int y)
          else
            DrawLevelField(x,y);
 
-         MovDelay[x][y] = 25;
+         MovDelay[x][y] = 50;
          Feld[newx][newy] = EL_BURNING;
          if (IN_LEV_FIELD(newx1,newy1) && Feld[newx1][newy1] == EL_LEERRAUM)
            Feld[newx1][newy1] = EL_BURNING;
@@ -1769,9 +1787,9 @@ void StartMoving(int x, int y)
       if (element == EL_KAEFER || element == EL_FLIEGER)
        DrawLevelField(x,y);
       else if (element == EL_BUTTERFLY || element == EL_FIREFLY)
-       DrawGraphicAnimation(x,y, el2gfx(element), 2, 2, ANIM_NORMAL);
+       DrawGraphicAnimation(x,y, el2gfx(element), 2, 4, ANIM_NORMAL);
       else if (element==EL_SONDE)
-       DrawGraphicAnimation(x,y, GFX_SONDE_START, 8, 1, ANIM_NORMAL);
+       DrawGraphicAnimation(x,y, GFX_SONDE_START, 8, 2, ANIM_NORMAL);
 
       return;
     }
@@ -1794,7 +1812,7 @@ void ContinueMoving(int x, int y)
   int dy = (direction==MV_UP   ? -1 : direction==MV_DOWN  ? +1 : 0);
   int horiz_move = (dx!=0);
   int newx = x + dx, newy = y + dy;
-  int step = (horiz_move ? dx : dy)*TILEX/4;
+  int step = (horiz_move ? dx : dy) * TILEX/8;
 
   if (CAN_FALL(element) && horiz_move)
     step*=2;
@@ -2023,7 +2041,7 @@ void AmoebeWaechst(int x, int y)
 
   if (!MovDelay[x][y])         /* neue Phase / noch nicht gewartet */
   {
-    MovDelay[x][y] = 4;
+    MovDelay[x][y] = 7;
 
     if (DelayReached(&sound_delay,sound_delay_value))
     {
@@ -2036,7 +2054,7 @@ void AmoebeWaechst(int x, int y)
   {
     MovDelay[x][y]--;
     if (MovDelay[x][y] && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
-      DrawGraphic(SCROLLX(x),SCROLLY(y),GFX_AMOEBING+3-MovDelay[x][y]);
+      DrawGraphic(SCROLLX(x),SCROLLY(y),GFX_AMOEBING+3-MovDelay[x][y]/2);
 
     if (!MovDelay[x][y])
     {
@@ -2180,7 +2198,7 @@ void Life(int ax, int ay)
 {
   int x1,y1,x2,y2;
   static int life[4] = { 2,3,3,3 };    /* "Life"-Parameter */
-  int life_time = 20;
+  int life_time = 40;
   int element = Feld[ax][ay];
 
   if (Stop[ax][ay])
@@ -2268,7 +2286,7 @@ void Ablenk(int x, int y)
 void Birne(int x, int y)
 {
   if (!MovDelay[x][y])         /* neue Phase / noch nicht gewartet */
-    MovDelay[x][y] = 400;
+    MovDelay[x][y] = 800;
 
   if (MovDelay[x][y])          /* neue Phase / in Wartezustand */
   {
@@ -2296,19 +2314,19 @@ void Birne(int x, int y)
 
 void Blubber(int x, int y)
 {
-  DrawGraphicAnimation(x,y, GFX_GEBLUBBER, 4, 5, ANIM_NORMAL);
+  DrawGraphicAnimation(x,y, GFX_GEBLUBBER, 4, 10, ANIM_NORMAL);
 }
 
 void NussKnacken(int x, int y)
 {
   if (!MovDelay[x][y])         /* neue Phase / noch nicht gewartet */
-    MovDelay[x][y] = 4;
+    MovDelay[x][y] = 7;
 
   if (MovDelay[x][y])          /* neue Phase / in Wartezustand */
   {
     MovDelay[x][y]--;
     if (MovDelay[x][y] && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
-      DrawGraphic(SCROLLX(x),SCROLLY(y),GFX_CRACKINGNUT+3-MovDelay[x][y]);
+      DrawGraphic(SCROLLX(x),SCROLLY(y),GFX_CRACKINGNUT+3-MovDelay[x][y]/2);
 
     if (!MovDelay[x][y])
     {
@@ -2330,24 +2348,28 @@ void AusgangstuerPruefen(int x, int y)
   if (!Gems && !SokobanFields && !Lights)
   {
     Feld[x][y] = EL_AUSGANG_ACT;
-    PlaySoundLevel(x,y,SND_OEFFNEN);
+
+    if (IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
+      PlaySoundLevel(x,y,SND_OEFFNEN);
+    else
+      PlaySoundLevel(JX,JY,SND_OEFFNEN);
   }
 }
 
 void AusgangstuerOeffnen(int x, int y)
 {
-  int speed = 3;
+  int delay = 6;
 
   if (!MovDelay[x][y])         /* neue Phase / noch nicht gewartet */
-    MovDelay[x][y] = 5*speed;
+    MovDelay[x][y] = 5*delay;
 
   if (MovDelay[x][y])          /* neue Phase / in Wartezustand */
   {
     int tuer;
 
     MovDelay[x][y]--;
-    tuer = MovDelay[x][y]/speed;
-    if (!(MovDelay[x][y]%speed) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
+    tuer = MovDelay[x][y]/delay;
+    if (!(MovDelay[x][y]%delay) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
       DrawGraphic(SCROLLX(x),SCROLLY(y),GFX_AUSGANG_AUF-tuer);
 
     if (!MovDelay[x][y])
@@ -2360,7 +2382,7 @@ void AusgangstuerOeffnen(int x, int y)
 
 void AusgangstuerBlinken(int x, int y)
 {
-  DrawGraphicAnimation(x,y, GFX_AUSGANG_AUF, 4, 2, ANIM_OSCILLATE);
+  DrawGraphicAnimation(x,y, GFX_AUSGANG_AUF, 4, 4, ANIM_OSCILLATE);
 }
 
 void EdelsteinFunkeln(int x, int y)
@@ -2369,18 +2391,11 @@ void EdelsteinFunkeln(int x, int y)
     return;
 
   if (Feld[x][y] == EL_EDELSTEIN_BD)
-  {
-    const int delay = 2;
-    const int frames = 4;
-    int phase = (FrameCounter % (delay*frames)) / delay;
-
-    if (!(FrameCounter % delay))
-      DrawGraphic(SCROLLX(x),SCROLLY(y), GFX_EDELSTEIN_BD - phase);
-  }
+    DrawGraphicAnimation(x,y, GFX_EDELSTEIN_BD, 4, 4, ANIM_REVERSE);
   else
   {
     if (!MovDelay[x][y])       /* neue Phase / noch nicht gewartet */
-      MovDelay[x][y] = 6*!SimpleRND(500);
+      MovDelay[x][y] = 11 * !SimpleRND(500);
 
     if (MovDelay[x][y])                /* neue Phase / in Wartezustand */
     {
@@ -2394,7 +2409,7 @@ void EdelsteinFunkeln(int x, int y)
       if (MovDelay[x][y])
       {
        int src_x,src_y, dest_x,dest_y;
-       int phase = MovDelay[x][y]-1;
+       int phase = (MovDelay[x][y]-1)/2;
 
        src_x  = SX+GFX_PER_LINE*TILEX;
        src_y  = SY+(phase > 2 ? 4-phase : phase)*TILEY;
@@ -2418,18 +2433,18 @@ void EdelsteinFunkeln(int x, int y)
 
 void MauerWaechst(int x, int y)
 {
-  int speed = 3;
+  int delay = 6;
 
   if (!MovDelay[x][y])         /* neue Phase / noch nicht gewartet */
-    MovDelay[x][y] = 3*speed;
+    MovDelay[x][y] = 3*delay;
 
   if (MovDelay[x][y])          /* neue Phase / in Wartezustand */
   {
     int phase;
 
     MovDelay[x][y]--;
-    phase = 2-MovDelay[x][y]/speed;
-    if (!(MovDelay[x][y]%speed) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
+    phase = 2-MovDelay[x][y]/delay;
+    if (!(MovDelay[x][y]%delay) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
       DrawGraphic(SCROLLX(x),SCROLLY(y),
                  (Store[x][y]==MV_LEFT ? GFX_MAUER_L1 : GFX_MAUER_R1)+phase);
 
@@ -2459,7 +2474,7 @@ void MauerAbleger(int ax, int ay)
   BOOL links_massiv = FALSE, rechts_massiv = FALSE;
 
   if (!MovDelay[ax][ay])       /* neue Mauer / noch nicht gewartet */
-    MovDelay[ax][ay] = 3;
+    MovDelay[ax][ay] = 6;
 
   if (MovDelay[ax][ay])                /* neue Mauer / in Wartezustand */
   {
@@ -2551,7 +2566,7 @@ void CheckForDragon(int x, int y)
 
 void GameActions()
 {
-  static long action_delay=0;
+  static long action_delay = 0;
   long action_delay_value;
 
   if (game_status != PLAYING)
@@ -2563,7 +2578,7 @@ void GameActions()
 */
 
   action_delay_value =
-    (tape.playing && tape.fast_forward ? FFWD_FRAME_DELAY : Gamespeed);
+    (tape.playing && tape.fast_forward ? FFWD_FRAME_DELAY : GameSpeed);
 
   /*
   if (DelayReached(&action_delay, action_delay_value))
@@ -2579,8 +2594,75 @@ void GameActions()
 
 
 
+  tst++;
+
+  if (0)
+  {
+    static long last_Counter = 0;
+    long new_Counter = Counter();
+
+    printf("--> %ld / %ld [%d]\n",
+          new_Counter - last_Counter,
+          new_Counter,
+          FrameCounter);
+    last_Counter = new_Counter;
+  }
+
+
+
+
+  /*
   if (!DelayReached(&action_delay, action_delay_value))
     return;
+    */
+
+
+  while(!DelayReached(&action_delay, action_delay_value))
+    Delay(1000);
+
+
+
+
+  /*
+  printf("-----------\n");
+  */
+
+
+
+  FrameCounter++;
+
+
+
+  /*
+  if (PlayerMovPos)
+    ScrollFigure(0);
+
+  DrawPlayerField();
+  */
+
+
+  tst2 = tst;
+  tst = 0;
+
+
+
+  if (0)
+  {
+    static long last_Counter = 0;
+    long new_Counter = Counter();
+
+    printf("--> %ld / %ld [%d]\n",
+          new_Counter - last_Counter,
+          new_Counter,
+          FrameCounter);
+    last_Counter = new_Counter;
+  }
+
+
+  /*
+  printf("--> %ld / ", Counter());
+  */
+
 
   {
     int x,y,element;
@@ -2591,7 +2673,12 @@ void GameActions()
     else if (tape.recording)
       TapeRecordDelay();
 
+
+    /*
     FrameCounter++;
+    */
+
+
     TimeFrames++;
 
     for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
@@ -2713,17 +2800,15 @@ void GameActions()
        }
       }
     }
+  }
 
-    /*
-    if (PlayerMovPos)
-      ScrollFigure(0);
 
-    DrawPlayerField();
-    */
+  /*
+  printf("%ld\n", Counter());
+  */
 
-  }
 
-  if (TimeLeft>0 && TimeFrames>=25 && !tape.pausing)
+  if (TimeLeft>0 && TimeFrames>=(100/GameSpeed) && !tape.pausing)
   {
     TimeFrames = 0;
     TimeLeft--;
@@ -2740,30 +2825,17 @@ void GameActions()
       KillHero();
   }
 
-  /*
-  if (PlayerMovPos)
-    ScrollFigure(0);
-    */
-
-
-  /*
   DrawPlayerField();
-  */
-
 
   BackToFront();
 }
 
 void ScrollLevel(int dx, int dy)
 {
+  int softscroll_offset = (soft_scrolling_on ? TILEX : 0);
   int x,y;
-  int softscroll_offset = (FX == TILEX ? TILEX : 0);
 
-  if (soft_scrolling_on)
-  {
-    ScreenMovPos = PlayerMovPos;
-    redraw_mask |= REDRAW_FIELD;
-  }
+  ScreenMovPos = PlayerGfxPos;
 
   XCopyArea(display,drawto_field,drawto_field,gc,
            FX + TILEX*(dx==-1) - softscroll_offset,
@@ -2791,14 +2863,10 @@ void ScrollLevel(int dx, int dy)
 
 BOOL MoveFigureOneStep(int dx, int dy, int real_dx, int real_dy)
 {
-  int oldJX,oldJY, newJX = JX+dx,newJY = JY+dy;
+  int newJX = JX+dx, newJY = JY+dy;
   int element;
   int can_move;
 
-/*
-  int old_move_dir = PlayerMovDir;
-*/
-
   if (PlayerGone || (!dx && !dy))
     return(MF_NO_ACTION);
 
@@ -2806,12 +2874,6 @@ BOOL MoveFigureOneStep(int dx, int dy, int real_dx, int real_dy)
                  dx > 0 ? MV_RIGHT :
                  dy < 0 ? MV_UP :
                  dy > 0 ? MV_DOWN :    MV_NO_MOVING);
-/*
-  if (old_move_dir != PlayerMovDir)
-    PlayerFrame = 0;
-  else
-    PlayerFrame = (PlayerFrame + 1) % 4;
-*/
 
   if (!IN_LEV_FIELD(newJX,newJY))
     return(MF_NO_ACTION);
@@ -2839,90 +2901,58 @@ BOOL MoveFigureOneStep(int dx, int dy, int real_dx, int real_dy)
   if (can_move != MF_MOVING)
     return(can_move);
 
-  oldJX = JX;
-  oldJY = JY;
+  lastJX = JX;
+  lastJY = JY;
   JX = newJX;
   JY = newJY;
 
-
-  JX2 = oldJX;
-  JY2 = oldJY;
-
-  PlayerMovPos = (dx > 0 || dy > 0 ? -1 : 1) * 3*TILEX/4;
+  PlayerMovPos = (dx > 0 || dy > 0 ? -1 : 1) * 7*TILEX/8;
 
   ScrollFigure(-1);
 
-  if (Store[oldJX][oldJY])
-  {
-    DrawGraphic(SCROLLX(oldJX),SCROLLY(oldJY),el2gfx(Store[oldJX][oldJY]));
-    DrawGraphicThruMask(SCROLLX(oldJX),SCROLLY(oldJY),
-                       el2gfx(Feld[oldJX][oldJY]));
-  }
-  else if (Feld[oldJX][oldJY]==EL_DYNAMIT)
-    DrawDynamite(oldJX,oldJY);
-  else
-    DrawLevelField(oldJX,oldJY);
-
   return(MF_MOVING);
 }
 
 BOOL MoveFigure(int dx, int dy)
 {
   static long move_delay = 0;
+  static int last_move_dir = MV_NO_MOVING;
   int moved = MF_NO_ACTION;
   int oldJX = JX, oldJY = JY;
 
   if (PlayerGone || (!dx && !dy))
     return(FALSE);
 
-/*
-  if (!DelayReached(&move_delay,8) && !tape.playing)
-    return(FALSE);
-*/
-
-/*
-  if (!DelayReached(&move_delay,10) && !tape.playing)
+  if (!FrameReached(&move_delay,MoveSpeed) && !tape.playing)
     return(FALSE);
-*/
-
-/*
-  if (!FrameReached(&move_delay,2) && !tape.playing)
-    return(FALSE);
-*/
 
-  if (Movemethod == 0)
+  if (last_move_dir & (MV_LEFT | MV_RIGHT))
   {
-    if (!DelayReached(&move_delay,Movespeed[0]) && !tape.playing)
-      return(FALSE);
+    if (!(moved |= MoveFigureOneStep(0,dy, dx,dy)))
+      moved |= MoveFigureOneStep(dx,0, dx,dy);
   }
   else
   {
-    if (!FrameReached(&move_delay,Movespeed[1]) && !tape.playing)
-      return(FALSE);
+    if (!(moved |= MoveFigureOneStep(dx,0, dx,dy)))
+      moved |= MoveFigureOneStep(0,dy, dx,dy);
   }
 
-  if (moved |= MoveFigureOneStep(dx,0, dx,dy))
-    moved |= MoveFigureOneStep(0,dy, dx,dy);
-  else
-  {
-    moved |= MoveFigureOneStep(0,dy, dx,dy);
-    moved |= MoveFigureOneStep(dx,0, dx,dy);
-  }
+  last_move_dir = MV_NO_MOVING;
 
   if (moved & MF_MOVING)
   {
-    int old_scroll_x=scroll_x, old_scroll_y=scroll_y;
+    int old_scroll_x = scroll_x, old_scroll_y = scroll_y;
     int offset = (scroll_delay_on ? 3 : 0);
 
     if ((scroll_x < JX-MIDPOSX-offset || scroll_x > JX-MIDPOSX+offset) &&
-       JX>=MIDPOSX-1-offset && JX<=lev_fieldx-(MIDPOSX-offset))
+       JX >= MIDPOSX-1-offset && JX <= lev_fieldx-(MIDPOSX-offset))
       scroll_x = JX-MIDPOSX + (scroll_x < JX-MIDPOSX ? -offset : offset);
     if ((scroll_y < JY-MIDPOSY-offset || scroll_y > JY-MIDPOSY+offset) &&
-       JY>=MIDPOSY-1-offset && JY<=lev_fieldy-(MIDPOSY-offset))
+       JY >= MIDPOSY-1-offset && JY <= lev_fieldy-(MIDPOSY-offset))
       scroll_y = JY-MIDPOSY + (scroll_y < JY-MIDPOSY ? -offset : offset);
 
-    if (scroll_x!=old_scroll_x || scroll_y!=old_scroll_y)
-      ScrollLevel(old_scroll_x-scroll_x,old_scroll_y-scroll_y);
+    if (scroll_x != old_scroll_x || scroll_y != old_scroll_y)
+      ScrollLevel(old_scroll_x - scroll_x, old_scroll_y - scroll_y);
   }
 
   if (!(moved & MF_MOVING) && !PlayerPushing)
@@ -2938,14 +2968,12 @@ BOOL MoveFigure(int dx, int dy)
       PlayerMovDir = (oldJY < JY ? MV_DOWN : MV_UP);
 
     DrawLevelField(JX,JY);     /* für "ErdreichAnbroeckeln()" */
+
+    last_move_dir = PlayerMovDir;
   }
 
   TestIfHeroHitsBadThing();
 
-  /*
-  BackToFront();
-  */
-
   if (PlayerGone)
     RemoveHero();
 
@@ -2954,50 +2982,141 @@ BOOL MoveFigure(int dx, int dy)
 
 void ScrollFigure(int init)
 {
-  static long actual_frame_counter;
-  static int oldX = -1, oldY = -1;
+  static long actual_frame_counter = 0;
+  static int oldJX = -1, oldJY = -1;
 
   if (init)
   {
-    if (PlayerMovPos && oldX != -1 && oldY != -1)
+
+
+
+    PlayerGfxPos = ScrollStepSize * (PlayerMovPos / ScrollStepSize);
+
+
+
+    /*
+    ScreenMovPos = PlayerGfxPos;
+    redraw_mask |= REDRAW_FIELD;
+    */
+
+
+
+    if (0)
     {
-      DrawLevelElement(oldX,oldY, Feld[oldX][oldY]);
-      DrawPlayerField();
+      static long last_Counter = 0;
+      long new_Counter = Counter();
+
+      printf("--> %ld / %ld [%d, %d]\n",
+            new_Counter - last_Counter,
+            new_Counter,
+            FrameCounter,
+            tst2);
+      last_Counter = new_Counter;
     }
 
-    oldX = JX2;
-    oldY = JY2;
+
+
+
+    if (oldJX != -1 && oldJY != -1)
+      DrawLevelElement(oldJX,oldJY, Feld[oldJX][oldJY]);
+
+    if (Feld[lastJX][lastJY] == EL_LEERRAUM &&
+       IN_LEV_FIELD(lastJX,lastJY-1) &&
+       CAN_FALL(Feld[lastJX][lastJY-1]))
+      Feld[lastJX][lastJY] = EL_PLAYER_IS_LEAVING;
+    DrawLevelElement(lastJX,lastJY, Feld[lastJX][lastJY]);
+    DrawPlayerField();
+
+    oldJX = lastJX;
+    oldJY = lastJY;
     actual_frame_counter = FrameCounter;
 
-    redraw[redraw_x1 + oldX][redraw_y1 + oldY] = 1;
-    redraw_tiles++;
+    if (PlayerPushing)
+    {
+      int nextJX = JX + (JX - lastJX);
+      int nextJY = JY + (JY - lastJY);
 
-    /*
-    DrawLevelElement(oldX,oldY, Feld[oldX][oldY]);
-    */
+      if (Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL)
+       DrawLevelElement(nextJX,nextJY, EL_SOKOBAN_FELD_LEER);
+      else
+       DrawLevelElement(nextJX,nextJY, EL_LEERRAUM);
+    }
 
     DrawPlayerField();
 
+    if (Store[lastJX][lastJY])
+    {
+      DrawGraphic(SCROLLX(lastJX),SCROLLY(lastJY),
+                 el2gfx(Store[lastJX][lastJY]));
+      DrawGraphicThruMask(SCROLLX(lastJX),SCROLLY(lastJY),
+                         el2gfx(Feld[lastJX][lastJY]));
+    }
+    else if (Feld[lastJX][lastJY]==EL_DYNAMIT)
+      DrawDynamite(lastJX,lastJY);
+    else
+      DrawLevelField(lastJX,lastJY);
+
     return;
   }
   else if (!FrameReached(&actual_frame_counter,1))
     return;
 
-  PlayerMovPos += (PlayerMovPos > 0 ? -1 : 1) * TILEX/4;
+  PlayerMovPos += (PlayerMovPos > 0 ? -1 : 1) * TILEX/8;
+  PlayerGfxPos = ScrollStepSize * (PlayerMovPos / ScrollStepSize);
+
+
+  /*
+  printf("PlayerGfxPos = %d\n", PlayerGfxPos);
+  */
 
-  if (ScreenMovPos)
+
+  if (ScreenMovPos && ScreenMovPos != PlayerGfxPos)
   {
-    ScreenMovPos = PlayerMovPos;
+    ScreenMovPos = PlayerGfxPos;
     redraw_mask |= REDRAW_FIELD;
   }
 
-  DrawLevelElement(oldX,oldY, Feld[oldX][oldY]);
+  if (Feld[oldJX][oldJY] == EL_PLAYER_IS_LEAVING)
+    Feld[oldJX][oldJY] = EL_LEERRAUM;
+
+  DrawLevelElement(oldJX,oldJY, Feld[oldJX][oldJY]);
   DrawPlayerField();
 
+
+
+  if (Store[oldJX][oldJY])
+  {
+    DrawGraphic(SCROLLX(oldJX),SCROLLY(oldJY),el2gfx(Store[oldJX][oldJY]));
+    DrawGraphicThruMask(SCROLLX(oldJX),SCROLLY(oldJY),
+                       el2gfx(Feld[oldJX][oldJY]));
+  }
+  else if (Feld[oldJX][oldJY]==EL_DYNAMIT)
+    DrawDynamite(oldJX,oldJY);
+  else
+    DrawLevelField(oldJX,oldJY);
+
+  if (PlayerPushing)
+  {
+    int nextJX = JX + (JX - lastJX);
+    int nextJY = JY + (JY - lastJY);
+
+    if (PlayerGfxPos)
+    {
+      if (Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL)
+       DrawLevelElement(nextJX,nextJY, EL_SOKOBAN_FELD_LEER);
+      else
+       DrawLevelElement(nextJX,nextJY, EL_LEERRAUM);
+    }
+    else
+      DrawLevelElement(nextJX,nextJY, Feld[nextJX][nextJY]);
+  }
+
   if (!PlayerMovPos)
   {
-    JX2 = JX;
-    JY2 = JY;
+    lastJX = JX;
+    lastJY = JY;
+
+    oldJX = oldJY = -1;
   }
 }
 
@@ -3189,7 +3308,8 @@ int DigField(int x, int y, int real_dx, int real_dy, int mode)
   static long push_delay = 0;
   static int push_delay_value = 5;
 
-  PlayerPushing = FALSE;
+  if (!PlayerMovPos)
+    PlayerPushing = FALSE;
 
   if (mode == DF_NO_PUSH)
   {
@@ -3507,7 +3627,7 @@ BOOL PlaceBomb(void)
 {
   int element;
 
-  if (PlayerGone)
+  if (PlayerGone || PlayerMovPos)
     return(FALSE);
 
   element = Feld[JX][JY];
@@ -3522,7 +3642,7 @@ BOOL PlaceBomb(void)
   if (Dynamite)
   {
     Feld[JX][JY] = EL_DYNAMIT;
-    MovDelay[JX][JY] = 48;
+    MovDelay[JX][JY] = 96;
     Dynamite--;
     DrawText(DX_DYNAMITE,DY_DYNAMITE,int2str(Dynamite,3),FS_SMALL,FC_YELLOW);
     DrawGraphicThruMask(SCROLLX(JX),SCROLLY(JY),GFX_DYNAMIT);
@@ -3530,7 +3650,7 @@ BOOL PlaceBomb(void)
   else
   {
     Feld[JX][JY] = EL_DYNABOMB;
-    MovDelay[JX][JY] = 48;
+    MovDelay[JX][JY] = 96;
     DynaBombsLeft--;
     DrawGraphicThruMask(SCROLLX(JX),SCROLLY(JY),GFX_DYNABOMB);
   }