rnd-19980918
[rocksndiamonds.git] / src / game.c
index 2ed2996640d37d969c134f6d6975ecb351eddf72..384d7431d4b14e611113d302da44945d288b0089 100644 (file)
 #include "tape.h"
 #include "joystick.h"
 
-
-
-int tst = 0;
-int tst2 = 0;
-
-
-
-extern int GameSpeed;
-extern int MoveSpeed;
-
 void GetPlayerConfig()
 {
   int old_joystick_nr = joystick_nr;
@@ -57,12 +47,14 @@ void GetPlayerConfig()
   scroll_delay_on = SETUP_SCROLL_DELAY_ON(player.setup);
   soft_scrolling_on = SETUP_SOFT_SCROLL_ON(player.setup);
 
+#ifndef MSDOS
   if (joystick_nr != old_joystick_nr)
   {
     if (joystick_device)
       close(joystick_device);
     InitJoystick();
   }
+#endif
 }
 
 void InitGame()
@@ -174,7 +166,7 @@ void InitGame()
        }
        break;
       case EL_DYNAMIT:
-       MovDelay[x][y] = 48;
+       MovDelay[x][y] = 96;
        break;
       case EL_BIRNE_AUS:
        Lights++;
@@ -383,7 +375,7 @@ void GameWon()
        TimeLeft--;
       DrawText(DX_TIME,DY_TIME,int2str(TimeLeft,3),FS_SMALL,FC_YELLOW);
       BackToFront();
-      Delay(10000);
+      Delay(10);
     }
 
     if (sound_loops_on)
@@ -496,7 +488,7 @@ void InitMovingField(int x, int y, int direction)
 
   MovDir[x][y] = direction;
   MovDir[newx][newy] = direction;
-  if (Feld[newx][newy]==EL_LEERRAUM)
+  if (Feld[newx][newy] == EL_LEERRAUM)
     Feld[newx][newy] = EL_BLOCKED;
 }
 
@@ -597,12 +589,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;
   }
 
@@ -619,12 +611,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;
@@ -638,7 +630,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;
 
@@ -868,13 +860,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]);
+      if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
+       DrawGraphic(SCROLLX(x),SCROLLY(y),graphic+4-MovDelay[x][y]/2);
 
       if (!MovDelay[x][y])
       {
@@ -1093,7 +1085,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;
   }
@@ -1109,7 +1101,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;
   }
@@ -1135,7 +1127,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)
   {
@@ -1159,7 +1151,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)
   {
@@ -1183,7 +1175,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)
   {
@@ -1346,9 +1338,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
     {
@@ -1419,7 +1411,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])
        {
@@ -1448,7 +1440,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])
        {
@@ -1474,7 +1466,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])
        {
@@ -1728,7 +1720,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;
@@ -1787,9 +1779,15 @@ 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);
+      {
+       int nextJX = JX + (JX - lastJX);
+       int nextJY = JY + (JY - lastJY);
+
+       if (!(PlayerPushing && PlayerGfxPos && x == nextJX && y == nextJY))
+         DrawGraphicAnimation(x,y, GFX_SONDE_START, 8, 2, ANIM_NORMAL);
+      }
 
       return;
     }
@@ -2041,9 +2039,9 @@ 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))
+    if (DelayReached(&sound_delay, sound_delay_value))
     {
       PlaySoundLevel(x,y,SND_AMOEBE);
       sound_delay_value = 30;
@@ -2053,8 +2051,8 @@ void AmoebeWaechst(int x, int y)
   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_AMOEBING+3-MovDelay[x][y]);
+    if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
+      DrawGraphic(SCROLLX(x),SCROLLY(y),GFX_AMOEBING+3-MovDelay[x][y]/2);
 
     if (!MovDelay[x][y])
     {
@@ -2198,7 +2196,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])
@@ -2286,7 +2284,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 */
   {
@@ -2314,19 +2312,22 @@ void Birne(int x, int y)
 
 void Blubber(int x, int y)
 {
-  DrawGraphicAnimation(x,y, GFX_GEBLUBBER, 4, 5, ANIM_NORMAL);
+  if (y > 0 && IS_MOVING(x,y-1) && MovDir[x][y-1] == MV_DOWN)
+    DrawLevelField(x,y-1);
+  else
+    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]);
+    if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
+      DrawGraphic(SCROLLX(x),SCROLLY(y),GFX_CRACKINGNUT+3-MovDelay[x][y]/2);
 
     if (!MovDelay[x][y])
     {
@@ -2338,9 +2339,9 @@ void NussKnacken(int x, int y)
 
 void SiebAktivieren(int x, int y, int typ)
 {
-  if (SiebAktiv%2 && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
+  if (!(SiebAktiv % 4) && IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
     DrawGraphic(SCROLLX(x),SCROLLY(y),
-               (typ==1 ? GFX_SIEB_VOLL : GFX_SIEB2_VOLL)+3-(SiebAktiv%8)/2);
+               (typ==1 ? GFX_SIEB_VOLL : GFX_SIEB2_VOLL)+3-(SiebAktiv%16)/4);
 }
 
 void AusgangstuerPruefen(int x, int y)
@@ -2358,18 +2359,18 @@ void AusgangstuerPruefen(int x, int y)
 
 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])
@@ -2382,7 +2383,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)
@@ -2391,18 +2392,11 @@ void EdelsteinFunkeln(int x, int y)
     return;
 
   if (Feld[x][y] == EL_EDELSTEIN_BD)
-  {
-    const int delay = 4; /* war: 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 */
     {
@@ -2416,16 +2410,27 @@ 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;
-       dest_x = FX+SCROLLX(x)*TILEX;
-       dest_y = FY+SCROLLY(y)*TILEY;
+       if (phase > 2)
+         phase = 4-phase;
 
+       src_x  = SX + GFX_PER_LINE*TILEX;
+       src_y  = SY + phase*TILEY;
+       dest_x = FX + SCROLLX(x)*TILEX;
+       dest_y = FY + SCROLLY(y)*TILEY;
+
+       /*
        XSetClipOrigin(display,clip_gc[PIX_BACK],dest_x-src_x,dest_y-src_y);
        XCopyArea(display,pix[PIX_BACK],drawto_field,clip_gc[PIX_BACK],
                  src_x,src_y, TILEX,TILEY, dest_x,dest_y);
+                 */
+
+       XSetClipMask(display, tile_clip_gc,
+                    tile_clipmask[GFX_MASK_SPARKLING + phase]);
+       XSetClipOrigin(display, tile_clip_gc, dest_x,dest_y);
+       XCopyArea(display, pix[PIX_BACK], drawto_field, tile_clip_gc,
+                 src_x,src_y, TILEX,TILEY, dest_x,dest_y);
 
        if (direct_draw_on)
        {
@@ -2440,18 +2445,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);
 
@@ -2481,7 +2486,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 */
   {
@@ -2575,247 +2580,154 @@ void GameActions()
 {
   static long action_delay = 0;
   long action_delay_value;
+  int sieb_x = 0, sieb_y = 0;
+  int x, y, element;
 
   if (game_status != PLAYING)
     return;
 
-/*
-  action_delay_value =
-    (tape.playing && tape.fast_forward ? FFWD_FRAME_DELAY : GAME_FRAME_DELAY);
-*/
-
+#ifdef DEBUG
   action_delay_value =
     (tape.playing && tape.fast_forward ? FFWD_FRAME_DELAY : GameSpeed);
-
-  /*
-  if (DelayReached(&action_delay, action_delay_value))
-  */
-
-
+#else
+  action_delay_value =
+    (tape.playing && tape.fast_forward ? FFWD_FRAME_DELAY : GAME_FRAME_DELAY);
+#endif
 
   if (PlayerMovPos)
     ScrollFigure(0);
 
-  DrawPlayerField();
+  /* main game synchronization point */
+  WaitUntilDelayReached(&action_delay, action_delay_value);
 
-
-
-
-  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))
+  if (tape.pausing || (tape.playing && !TapePlayDelay()))
     return;
-    */
-
-
-  while(!DelayReached(&action_delay, action_delay_value))
-    Delay(1000);
-
-
-
-
-  /*
-  printf("-----------\n");
-  */
-
-
+  else if (tape.recording)
+    TapeRecordDelay();
 
   FrameCounter++;
+  TimeFrames++;
 
-
-
-  /*
-  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());
-  */
-
-
+  for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
   {
-    int x,y,element;
-    int sieb_x = 0, sieb_y = 0;
-
-    if (tape.pausing || (tape.playing && !TapePlayDelay()))
-      return;
-    else if (tape.recording)
-      TapeRecordDelay();
-
+    Stop[x][y] = FALSE;
+    if (JustHit[x][y]>0)
+      JustHit[x][y]--;
 
-    /*
-    FrameCounter++;
-    */
-
-
-    TimeFrames++;
-
-    for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
+#if DEBUG
+    if (IS_BLOCKED(x,y))
     {
-      Stop[x][y] = FALSE;
-      if (JustHit[x][y]>0)
-       JustHit[x][y]--;
+      int oldx,oldy;
 
-#if DEBUG
-      if (IS_BLOCKED(x,y))
+      Blocked2Moving(x,y,&oldx,&oldy);
+      if (!IS_MOVING(oldx,oldy))
       {
-       int oldx,oldy;
-
-       Blocked2Moving(x,y,&oldx,&oldy);
-       if (!IS_MOVING(oldx,oldy))
-       {
-         printf("GameActions(): (BLOCKED=>MOVING) context corrupted!\n");
-         printf("GameActions(): BLOCKED: x = %d, y = %d\n",x,y);
-         printf("GameActions(): !MOVING: oldx = %d, oldy = %d\n",oldx,oldy);
-         printf("GameActions(): This should never happen!\n");
-       }
+       printf("GameActions(): (BLOCKED=>MOVING) context corrupted!\n");
+       printf("GameActions(): BLOCKED: x = %d, y = %d\n",x,y);
+       printf("GameActions(): !MOVING: oldx = %d, oldy = %d\n",oldx,oldy);
+       printf("GameActions(): This should never happen!\n");
       }
+    }
 #endif
+  }
 
-    }
+  for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
+  {
+    element = Feld[x][y];
 
-    for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
-    {
-      element = Feld[x][y];
+    if (IS_INACTIVE(element))
+      continue;
 
-      if (IS_INACTIVE(element))
-       continue;
+    if (!IS_MOVING(x,y) && (CAN_FALL(element) || CAN_MOVE(element)))
+    {
+      StartMoving(x,y);
+
+      if (IS_GEM(element))
+       EdelsteinFunkeln(x,y);
+    }
+    else if (IS_MOVING(x,y))
+      ContinueMoving(x,y);
+    else if (element==EL_DYNAMIT || element==EL_DYNABOMB)
+      CheckDynamite(x,y);
+    else if (element==EL_EXPLODING)
+      Explode(x,y,Frame[x][y],EX_NORMAL);
+    else if (element==EL_AMOEBING)
+      AmoebeWaechst(x,y);
+    else if (IS_AMOEBALIVE(element))
+      AmoebeAbleger(x,y);
+    else if (element==EL_LIFE || element==EL_LIFE_ASYNC)
+      Life(x,y);
+    else if (element==EL_ABLENK_EIN)
+      Ablenk(x,y);
+    else if (element==EL_SALZSAEURE)
+      Blubber(x,y);
+    else if (element==EL_BLURB_LEFT || element==EL_BLURB_RIGHT)
+      Blurb(x,y);
+    else if (element==EL_CRACKINGNUT)
+      NussKnacken(x,y);
+    else if (element==EL_AUSGANG_ZU)
+      AusgangstuerPruefen(x,y);
+    else if (element==EL_AUSGANG_ACT)
+      AusgangstuerOeffnen(x,y);
+    else if (element==EL_AUSGANG_AUF)
+      AusgangstuerBlinken(x,y);
+    else if (element==EL_MAUERND)
+      MauerWaechst(x,y);
+    else if (element==EL_MAUER_LEBT)
+      MauerAbleger(x,y);
+    else if (element==EL_BURNING)
+      CheckForDragon(x,y);
 
-      if (!IS_MOVING(x,y) && (CAN_FALL(element) || CAN_MOVE(element)))
-      {
-       StartMoving(x,y);
+    if (SiebAktiv)
+    {
+      BOOL sieb = FALSE;
 
-       if (IS_GEM(element))
-         EdelsteinFunkeln(x,y);
+      if (element==EL_SIEB_LEER || element==EL_SIEB_VOLL ||
+         Store[x][y]==EL_SIEB_LEER)
+      {
+       SiebAktivieren(x, y, 1);
+       sieb = TRUE;
       }
-      else if (IS_MOVING(x,y))
-       ContinueMoving(x,y);
-      else if (element==EL_DYNAMIT || element==EL_DYNABOMB)
-       CheckDynamite(x,y);
-      else if (element==EL_EXPLODING)
-       Explode(x,y,Frame[x][y],EX_NORMAL);
-      else if (element==EL_AMOEBING)
-       AmoebeWaechst(x,y);
-      else if (IS_AMOEBALIVE(element))
-       AmoebeAbleger(x,y);
-      else if (element==EL_LIFE || element==EL_LIFE_ASYNC)
-       Life(x,y);
-      else if (element==EL_ABLENK_EIN)
-       Ablenk(x,y);
-      else if (element==EL_SALZSAEURE)
-       Blubber(x,y);
-      else if (element==EL_BLURB_LEFT || element==EL_BLURB_RIGHT)
-       Blurb(x,y);
-      else if (element==EL_CRACKINGNUT)
-       NussKnacken(x,y);
-      else if (element==EL_AUSGANG_ZU)
-       AusgangstuerPruefen(x,y);
-      else if (element==EL_AUSGANG_ACT)
-       AusgangstuerOeffnen(x,y);
-      else if (element==EL_AUSGANG_AUF)
-       AusgangstuerBlinken(x,y);
-      else if (element==EL_MAUERND)
-       MauerWaechst(x,y);
-      else if (element==EL_MAUER_LEBT)
-       MauerAbleger(x,y);
-      else if (element==EL_BURNING)
-       CheckForDragon(x,y);
-
-      if (SiebAktiv)
+      else if (element==EL_SIEB2_LEER || element==EL_SIEB2_VOLL ||
+              Store[x][y]==EL_SIEB2_LEER)
       {
-       BOOL sieb = FALSE;
-
-       if (element==EL_SIEB_LEER || element==EL_SIEB_VOLL ||
-           Store[x][y]==EL_SIEB_LEER)
-       {
-         SiebAktivieren(x, y, 1);
-         sieb = TRUE;
-       }
-       else if (element==EL_SIEB2_LEER || element==EL_SIEB2_VOLL ||
-                Store[x][y]==EL_SIEB2_LEER)
-       {
-         SiebAktivieren(x, y, 2);
-         sieb = TRUE;
-       }
+       SiebAktivieren(x, y, 2);
+       sieb = TRUE;
+      }
 
-       if (sieb && ABS(x-JX)+ABS(y-JY) < ABS(sieb_x-JX)+ABS(sieb_y-JY))
-       {
-         sieb_x = x;
-         sieb_y = y;
-       }
+      if (sieb && ABS(x-JX)+ABS(y-JY) < ABS(sieb_x-JX)+ABS(sieb_y-JY))
+      {
+       sieb_x = x;
+       sieb_y = y;
       }
     }
+  }
 
-    if (SiebAktiv)
+  if (SiebAktiv)
+  {
+    if (!(SiebAktiv%4))
+      PlaySoundLevel(sieb_x,sieb_y,SND_MIEP);
+    SiebAktiv--;
+    if (!SiebAktiv)
     {
-      if (!(SiebAktiv%4))
-       PlaySoundLevel(sieb_x,sieb_y,SND_MIEP);
-      SiebAktiv--;
-      if (!SiebAktiv)
+      for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
       {
-       for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
+       element = Feld[x][y];
+       if (element==EL_SIEB_LEER || element==EL_SIEB_VOLL)
        {
-         element = Feld[x][y];
-         if (element==EL_SIEB_LEER || element==EL_SIEB_VOLL)
-         {
-           Feld[x][y] = EL_SIEB_TOT;
-           DrawLevelField(x,y);
-         }
-         else if (element==EL_SIEB2_LEER || element==EL_SIEB2_VOLL)
-         {
-           Feld[x][y] = EL_SIEB2_TOT;
-           DrawLevelField(x,y);
-         }
+         Feld[x][y] = EL_SIEB_TOT;
+         DrawLevelField(x,y);
+       }
+       else if (element==EL_SIEB2_LEER || element==EL_SIEB2_VOLL)
+       {
+         Feld[x][y] = EL_SIEB2_TOT;
+         DrawLevelField(x,y);
        }
       }
     }
   }
 
-
-  /*
-  printf("%ld\n", Counter());
-  */
-
-
-  if (TimeLeft>0 && TimeFrames>=(100/GameSpeed) && !tape.pausing)
+  if (TimeLeft>0 && TimeFrames>=(1000/GameSpeed) && !tape.pausing)
   {
     TimeFrames = 0;
     TimeLeft--;
@@ -2833,8 +2745,6 @@ void GameActions()
   }
 
   DrawPlayerField();
-
-  BackToFront();
 }
 
 void ScrollLevel(int dx, int dy)
@@ -2990,129 +2900,46 @@ BOOL MoveFigure(int dx, int dy)
 void ScrollFigure(int init)
 {
   static long actual_frame_counter = 0;
-  static int oldJX = -1, oldJY = -1;
 
   if (init)
   {
+    PlayerGfxPos = ScrollStepSize * (PlayerMovPos / ScrollStepSize);
+    actual_frame_counter = FrameCounter;
 
-    PlayerGfxPos =
-      (TILEX/ScrollSteps) * (PlayerMovPos / (TILEX/ScrollSteps));
-
-
-
-    if (0)
-    {
-      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;
-    }
-
-
-
-
-    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;
-
-    if (PlayerPushing)
-    {
-      int nextJX = JX + (JX - lastJX);
-      int nextJY = JY + (JY - lastJY);
-
-      if (Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL)
-       DrawLevelElement(nextJX,nextJY, EL_SOKOBAN_FELD_LEER);
-      else
-       DrawLevelElement(nextJX,nextJY, EL_LEERRAUM);
-    }
+    if (Feld[lastJX][lastJY] == EL_LEERRAUM)
+      Feld[lastJX][lastJY] = EL_PLAYER_IS_LEAVING;
 
     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/8;
+  PlayerGfxPos = ScrollStepSize * (PlayerMovPos / ScrollStepSize);
 
-
-  PlayerGfxPos =
-    (TILEX/ScrollSteps) * (PlayerMovPos / (TILEX/ScrollSteps));
-
-  if (ScreenMovPos)
+  if (ScreenMovPos && ScreenMovPos != PlayerGfxPos)
   {
     ScreenMovPos = PlayerGfxPos;
     redraw_mask |= REDRAW_FIELD;
   }
 
-  if (Feld[oldJX][oldJY] == EL_PLAYER_IS_LEAVING)
-    Feld[oldJX][oldJY] = EL_LEERRAUM;
+  if (Feld[lastJX][lastJY] == EL_PLAYER_IS_LEAVING)
+    Feld[lastJX][lastJY] = 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)
   {
     lastJX = JX;
     lastJY = JY;
-
-    oldJX = oldJY = -1;
   }
 }
 
@@ -3391,12 +3218,12 @@ int DigField(int x, int y, int real_dx, int real_dy, int mode)
       Feld[x][y] = EL_LEERRAUM;
       Key[key_nr] = TRUE;
       RaiseScoreElement(EL_SCHLUESSEL);
-      DrawMiniGraphicExtHiRes(drawto,gc,
-                             DX_KEYS+key_nr*MINI_TILEX,DY_KEYS,
-                             GFX_SCHLUESSEL1+key_nr);
-      DrawMiniGraphicExtHiRes(window,gc,
-                             DX_KEYS+key_nr*MINI_TILEX,DY_KEYS,
-                             GFX_SCHLUESSEL1+key_nr);
+      DrawMiniGraphicExt(drawto,gc,
+                        DX_KEYS+key_nr*MINI_TILEX,DY_KEYS,
+                        GFX_SCHLUESSEL1+key_nr);
+      DrawMiniGraphicExt(window,gc,
+                        DX_KEYS+key_nr*MINI_TILEX,DY_KEYS,
+                        GFX_SCHLUESSEL1+key_nr);
       PlaySoundLevel(x,y,SND_PONG);
       break;
     }
@@ -3638,7 +3465,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);
@@ -3646,7 +3473,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);
   }
@@ -3670,7 +3497,13 @@ void PlaySoundLevel(int x, int y, int sound_nr)
     return;
 
   volume = PSND_MAX_VOLUME;
+#ifndef MSDOS
   stereo = (sx-SCR_FIELDX/2)*12;
+#else
+  stereo = PSND_MIDDLE+(2*sx-(SCR_FIELDX-1))*5;
+  if(stereo > PSND_MAX_RIGHT) stereo = PSND_MAX_RIGHT;
+  if(stereo < PSND_MAX_LEFT) stereo = PSND_MAX_LEFT;
+#endif
 
   if (!IN_SCR_FIELD(sx,sy))
   {