rnd-19990122-2
authorHolger Schemel <info@artsoft.org>
Fri, 22 Jan 1999 12:36:01 +0000 (13:36 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:33:06 +0000 (10:33 +0200)
src/buttons.c
src/cartoons.c
src/init.c
src/main.h
src/screens.c
src/tools.c
src/tools.h

index 95c29674b9ede7c9368d04f62429adc88b6dcb93..f8d181e497dc4f618b952451a1233c252c481354 100644 (file)
@@ -2336,8 +2336,7 @@ void HandleGadgets(int mx, int my, int button)
     gi->event.off_borders = FALSE;
 
     /* initialize delay counter */
-    pressed_delay = 0;
-    DelayReached(&pressed_delay, GADGET_FRAME_DELAY);
+    DelayReached(&pressed_delay, 0);
 
     if (gi->event_mask & GD_EVENT_PRESSED)
       gi->callback_action(gi);
index 834996b73c53ff4a49d594226fc40ee6de9f5dcb..bd00d1af01a6a04bc2dc9906a8dca6465a25f724 100644 (file)
@@ -462,10 +462,12 @@ boolean AnimateToon(int toon_nr, boolean restart)
 
   if (!DelayReached(&anim_delay, anim_delay_value))
   {
-    if (game_status==HELPSCREEN && !restart)
-      DrawAnim(anim_pixmap,anim_clip_gc,
-              src_x+cut_x,src_y+cut_y, width,height,
-              REAL_SX+dest_x,REAL_SY+dest_y, pad_x,pad_y);
+    if ((game_status == HELPSCREEN ||
+        (game_status == MAINMENU && redraw_mask & REDRAW_MICROLEVEL))
+       && !restart)
+      DrawAnim(anim_pixmap, anim_clip_gc,
+              src_x + cut_x, src_y + cut_y, width, height,
+              REAL_SX + dest_x, REAL_SY + dest_y, pad_x, pad_y);
 
     return(FALSE);
   }
index b8e6704eb1dd1ff1061b52fbc4f4f03fb6b911ca..33cec176b737016ff375784fe52dc6add95ae32a 100644 (file)
@@ -887,7 +887,8 @@ void InitElementProperties()
     EL_SP_HARD_BASE5,
     EL_SP_HARD_BASE6,
     EL_SP_TERMINAL,
-    EL_SP_EXIT
+    EL_SP_EXIT,
+    EL_INVISIBLE_STEEL
   };
   static int ep_solid_num = sizeof(ep_solid)/sizeof(int);
 
@@ -919,6 +920,7 @@ void InitElementProperties()
     EL_SP_HARD_BASE4,
     EL_SP_HARD_BASE5,
     EL_SP_HARD_BASE6,
+    EL_INVISIBLE_STEEL
   };
   static int ep_massive_num = sizeof(ep_massive)/sizeof(int);
 
@@ -1007,7 +1009,8 @@ void InitElementProperties()
     EL_SP_HARD_BASE5,
     EL_SP_HARD_BASE6,
     EL_SP_TERMINAL,
-    EL_SP_EXIT
+    EL_SP_EXIT,
+    EL_INVISIBLE_STEEL
   };
   static int ep_mauer_num = sizeof(ep_mauer)/sizeof(int);
 
@@ -1201,7 +1204,8 @@ void InitElementProperties()
     EL_SOKOBAN_OBJEKT,
     EL_SOKOBAN_FELD_LEER,
     EL_SOKOBAN_FELD_VOLL,
-    EL_SPIELFIGUR
+    EL_SPIELFIGUR,
+    EL_INVISIBLE_STEEL
   };
   static int ep_sb_element_num = sizeof(ep_sb_element)/sizeof(int);
 
@@ -1299,7 +1303,8 @@ void InitElementProperties()
     EL_SP_HARD_BASE4,
     EL_SP_HARD_BASE5,
     EL_SP_HARD_BASE6,
-    EL_SP_EXIT
+    EL_SP_EXIT,
+    EL_INVISIBLE_STEEL
   };
   static int ep_inactive_num = sizeof(ep_inactive)/sizeof(int);
 
index 84fa41ea5cfd514e07d93404eb8b3b9feea3426e..da627421439f005a7e89dcfd11f3a0d9177d16b6 100644 (file)
@@ -213,6 +213,7 @@ typedef unsigned char byte;
 #define FFWD_FRAME_DELAY       10      /* 200% speed for fast forward */
 #define FRAMES_PER_SECOND      (1000 / GAME_FRAME_DELAY)
 #define GADGET_FRAME_DELAY     150     /* delay between gadget actions */
+#define MICROLEVEL_SCROLL_DELAY        50      /* delay for scrolling micro level */
 
 struct HiScore
 {
@@ -502,10 +503,10 @@ extern int                num_bg_loops;
 #define EYSIZE                 (VXSIZE + 44)
 #define FULL_SXSIZE            (2+SXSIZE+2)
 #define FULL_SYSIZE            (2+SYSIZE+2)
-#define MICROLEV_XPOS          (SX+4*32+16)
-#define MICROLEV_YPOS          (SX+12*32)
-#define MICROLEV_XSIZE         (STD_LEV_FIELDX*MICRO_TILEX)
-#define MICROLEV_YSIZE         (STD_LEV_FIELDY*MICRO_TILEY)
+#define MICROLEV_XSIZE         ((STD_LEV_FIELDX + 2) * MICRO_TILEX)
+#define MICROLEV_YSIZE         ((STD_LEV_FIELDY + 2) * MICRO_TILEY)
+#define MICROLEV_XPOS          (SX + (SXSIZE - MICROLEV_XSIZE) / 2)
+#define MICROLEV_YPOS          (SX + 12 * TILEY - MICRO_TILEY)
 #define MICROLABEL_YPOS                (MICROLEV_YPOS+MICROLEV_YSIZE+12)
 #define FONT1_XSIZE            32
 #define FONT1_YSIZE            32
@@ -603,9 +604,7 @@ extern int          num_bg_loops;
 #define EL_ERZ_EDEL_GELB       59
 #define EL_MAMPFER2            60
 #define EL_SIEB2_INAKTIV       61
-
-#define EL_UNUSED_62           62
-
+#define EL_INVISIBLE_STEEL     62
 #define EL_DYNABOMB            63
 #define EL_DYNABOMB_NR         64
 #define EL_DYNABOMB_SZ         65
@@ -968,6 +967,8 @@ extern int          num_bg_loops;
 #define GFX_FIREFLY_L          206
 #define GFX_FIREFLY_U          207
 
+#define GFX_INVISIBLE_STEEL    GFX_UNSICHTBAR
+
 #define GFX_SCHLUESSEL         GFX_SCHLUESSEL1
 #define GFX_SPIELFIGUR         GFX_SPIELER1
 
@@ -1263,13 +1264,21 @@ extern int              num_bg_loops;
 #define REDRAW_VIDEO_1         (1L << 4)
 #define REDRAW_VIDEO_2         (1L << 5)
 #define REDRAW_VIDEO_3         (1L << 6)
-#define REDRAW_MICROLEV                (1L << 7)
-#define REDRAW_FROM_BACKBUFFER (1L << 8)
-#define REDRAW_DOOR_2  (REDRAW_VIDEO_1 | REDRAW_VIDEO_2 | REDRAW_VIDEO_3)
-#define REDRAW_DOOR_3          (1L << 9)
-#define REDRAW_DOORS   (REDRAW_DOOR_1 | REDRAW_DOOR_2 | REDRAW_DOOR_3)
-#define REDRAW_MAIN    (REDRAW_FIELD | REDRAW_TILES | REDRAW_MICROLEV)
-#define REDRAWTILES_THRESHOLD  SCR_FIELDX*SCR_FIELDY/2
+#define REDRAW_MICROLEVEL      (1L << 7)
+#define REDRAW_MICROLEVEL_LABEL        (1L << 8)
+#define REDRAW_FROM_BACKBUFFER (1L << 9)
+#define REDRAW_DOOR_2          (REDRAW_VIDEO_1 | \
+                                REDRAW_VIDEO_2 | \
+                                REDRAW_VIDEO_3)
+#define REDRAW_DOOR_3          (1L << 10)
+#define REDRAW_DOORS           (REDRAW_DOOR_1 | \
+                                REDRAW_DOOR_2 | \
+                                REDRAW_DOOR_3)
+#define REDRAW_MAIN            (REDRAW_FIELD | \
+                                REDRAW_TILES | \
+                                REDRAW_MICROLEVEL | \
+                                REDRAW_MICROLEVEL_LABEL)
+#define REDRAWTILES_THRESHOLD  (SCR_FIELDX * SCR_FIELDY / 2)
 
 /* areas in pixmap PIX_DOOR */
 /* meaning in PIX_DB_DOOR: (3 PAGEs)
index 30318da801930829f52300b38aca668f122caa0e..11c6bf2a9c9e011a89a6d4b2ecb067125d154aff 100644 (file)
@@ -89,7 +89,7 @@ void DrawMainMenu()
   DrawText(SX + 32,    SY + 8*32, "Setup", FS_BIG, FC_GREEN);
   DrawText(SX + 32,    SY + 9*32, "Quit", FS_BIG, FC_GREEN);
 
-  DrawMicroLevel(MICROLEV_XPOS,MICROLEV_YPOS);
+  DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
 
   DrawTextF(7*32 + 6, 3*32 + 9, FC_RED, "%d-%d",
            leveldir[leveldir_nr].first_level,
@@ -201,7 +201,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
                int2str(level_nr, 3), FS_BIG, font_color);
 
     LoadLevel(level_nr);
-    DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS);
+    DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, TRUE);
 
     TapeErase();
     LoadTape(level_nr);
@@ -246,7 +246,8 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
       }
       else if (y == 6)
       {
-       if (leveldir[leveldir_nr].readonly)
+       if (leveldir[leveldir_nr].readonly &&
+           strcmp(setup.player_name, "Artsoft") != 0)
          Request("This level is read only !", REQ_CONFIRM);
        game_status = LEVELED;
        DrawLevelEd();
@@ -291,7 +292,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
   out:
 
   if (game_status == MAINMENU)
+  {
+    DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE);
     DoAnimation();
+  }
 }
 
 #define MAX_HELPSCREEN_ELS     10
index fe3291faea48c4958ac3fdfda7554a5b736e6020..900e5ef7078e610454db0973d6b92b0e898d237d 100644 (file)
@@ -184,15 +184,20 @@ void BackToFront()
     redraw_mask &= ~REDRAW_DOORS;
   }
 
-  if (redraw_mask & REDRAW_MICROLEV)
+  if (redraw_mask & REDRAW_MICROLEVEL)
   {
     XCopyArea(display,backbuffer,window,gc,
-             MICROLEV_XPOS,MICROLEV_YPOS, MICROLEV_XSIZE,MICROLEV_YSIZE,
-             MICROLEV_XPOS,MICROLEV_YPOS);
+             MICROLEV_XPOS, MICROLEV_YPOS, MICROLEV_XSIZE, MICROLEV_YSIZE,
+             MICROLEV_XPOS, MICROLEV_YPOS);
+    redraw_mask &= ~REDRAW_MICROLEVEL;
+  }
+
+  if (redraw_mask & REDRAW_MICROLEVEL_LABEL)
+  {
     XCopyArea(display,backbuffer,window,gc,
-             SX,MICROLABEL_YPOS, SXSIZE,FONT4_YSIZE,
-             SX,MICROLABEL_YPOS);
-    redraw_mask &= ~REDRAW_MICROLEV;
+             SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE,
+             SX, MICROLABEL_YPOS);
+    redraw_mask &= ~REDRAW_MICROLEVEL_LABEL;
   }
 
   if (redraw_mask & REDRAW_TILES)
@@ -1401,43 +1406,113 @@ void DrawMiniLevel(int scroll_x, int scroll_y)
   redraw_mask |= REDRAW_FIELD;
 }
 
-void DrawMicroLevel(int xpos, int ypos)
+static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y)
 {
-  int x,y;
+  int x, y;
 
   /* determine border element for this level */
   SetBorderElement();
 
   XFillRectangle(display, drawto, gc,
-                xpos - MICRO_TILEX, ypos - MICRO_TILEY,
-                MICRO_TILEX * (STD_LEV_FIELDX + 2),
-                MICRO_TILEY * (STD_LEV_FIELDY + 2));
+                xpos, ypos, MICROLEV_XSIZE, MICROLEV_YSIZE);
+
   if (lev_fieldx < STD_LEV_FIELDX)
-    xpos += (STD_LEV_FIELDX - lev_fieldx)/2 * MICRO_TILEX;
+    xpos += (STD_LEV_FIELDX - lev_fieldx) / 2 * MICRO_TILEX;
   if (lev_fieldy < STD_LEV_FIELDY)
-    ypos += (STD_LEV_FIELDY - lev_fieldy)/2 * MICRO_TILEY;
+    ypos += (STD_LEV_FIELDY - lev_fieldy) / 2 * MICRO_TILEY;
+
+  xpos += MICRO_TILEX;
+  ypos += MICRO_TILEY;
 
   for(x=-1; x<=STD_LEV_FIELDX; x++)
+  {
     for(y=-1; y<=STD_LEV_FIELDY; y++)
-      if (x >= 0 && x < lev_fieldx && y >= 0 && y < lev_fieldy)
+    {
+      int lx = from_x + x, ly = from_y + y;
+
+      if (lx >= 0 && lx < lev_fieldx && ly >= 0 && ly < lev_fieldy)
        DrawMicroElement(xpos + x * MICRO_TILEX, ypos + y * MICRO_TILEY,
-                        Ur[x][y]);
-      else if (x >= -1 && x < lev_fieldx+1 && y >= -1 && y < lev_fieldy+1)
+                        Ur[lx][ly]);
+      else if (lx >= -1 && lx < lev_fieldx+1 && ly >= -1 && ly < lev_fieldy+1)
        DrawMicroElement(xpos + x * MICRO_TILEX, ypos + y * MICRO_TILEY,
                         BorderElement);
+    }
+  }
 
-  XFillRectangle(display, drawto,gc, SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE);
+  redraw_mask |= REDRAW_MICROLEVEL;
+}
+
+void DrawMicroLevel(int xpos, int ypos, boolean restart)
+{
+  static unsigned long scroll_delay = 0;
+  static int from_x, from_y, scroll_direction;
 
-  if (level.name)
+  if (restart)
   {
-    int len = strlen(level.name);
-    int lxpos = SX + (SXSIZE - len * FONT4_XSIZE) / 2;
-    int lypos = MICROLABEL_YPOS;
+    from_x = from_y = 0;
+    scroll_direction = MV_RIGHT;
+
+    DrawMicroLevelExt(xpos, ypos, from_x, from_y);
+
+    XFillRectangle(display, drawto,gc,
+                  SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE);
+
+    if (level.name && restart)
+    {
+      int len = strlen(level.name);
+      int lxpos = SX + (SXSIZE - len * FONT4_XSIZE) / 2;
+      int lypos = MICROLABEL_YPOS;
+
+      DrawText(lxpos, lypos, level.name, FS_SMALL, FC_SPECIAL2);
+    }
+
+    /* initialize delay counter */
+    DelayReached(&scroll_delay, 0);
 
-    DrawText(lxpos, lypos, level.name, FS_SMALL, FC_SPECIAL2);
+    redraw_mask |= REDRAW_MICROLEVEL_LABEL;
   }
+  else
+  {
+    if ((lev_fieldx <= STD_LEV_FIELDX && lev_fieldy <= STD_LEV_FIELDY) ||
+       !DelayReached(&scroll_delay, MICROLEVEL_SCROLL_DELAY))
+      return;
+
+    switch (scroll_direction)
+    {
+      case MV_LEFT:
+       if (from_x > 0)
+         from_x--;
+       else
+         scroll_direction = MV_UP;
+       break;
+
+      case MV_RIGHT:
+       if (from_x < lev_fieldx - STD_LEV_FIELDX)
+         from_x++;
+       else
+         scroll_direction = MV_DOWN;
+       break;
 
-  redraw_mask |= REDRAW_MICROLEV;
+      case MV_UP:
+       if (from_y > 0)
+         from_y--;
+       else
+         scroll_direction = MV_RIGHT;
+       break;
+
+      case MV_DOWN:
+       if (from_y < lev_fieldy - STD_LEV_FIELDY)
+         from_y++;
+       else
+         scroll_direction = MV_LEFT;
+       break;
+
+      default:
+       break;
+    }
+
+    DrawMicroLevelExt(xpos, ypos, from_x, from_y);
+  }
 }
 
 int REQ_in_range(int x, int y)
@@ -1987,6 +2062,7 @@ int el2gfx(int element)
     case EL_SPEED_PILL:                return GFX_SPEED_PILL;
     case EL_SP_TERMINAL_ACTIVE:        return GFX_SP_TERMINAL;
     case EL_SP_BUG_ACTIVE:     return GFX_SP_BUG_ACTIVE;
+    case EL_INVISIBLE_STEEL:   return GFX_INVISIBLE_STEEL;
 
     default:
     {
index 538793099e875d1ebfcf970b42130e4b226c08cb..e83ebfa9a7ffa3aa78254dea36492d5cf1a13ae1 100644 (file)
@@ -97,7 +97,7 @@ void DrawMiniElementOrWall(int, int, int, int);
 void DrawMicroElement(int, int, int);
 void DrawLevel(void);
 void DrawMiniLevel(int, int);
-void DrawMicroLevel(int, int);
+void DrawMicroLevel(int, int, boolean);
 boolean Request(char *, unsigned int);
 unsigned int OpenDoor(unsigned int);
 unsigned int CloseDoor(unsigned int);