added optionally configurable game frame counter to tape display
authorHolger Schemel <info@artsoft.org>
Tue, 3 Feb 2015 23:13:17 +0000 (00:13 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 3 Feb 2015 23:13:17 +0000 (00:13 +0100)
ChangeLog
src/conf_gfx.c
src/conf_var.c
src/files.c
src/game.c
src/tape.c
src/tape.h

index 25ebcf89fbc60ec0bd1a05f06bc8c31ed4f688ee..203fafd823a66953c448740574dc90c3a8fc0c9b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
        * finished configurability of tape date and time display positions
        * fixed bug with game buttons in tape area not properly redrawn
        * fixed small graphical bug with default tape time display position
+       * added optionally configurable game frame counter to tape display
 
 2015-02-02
        * fixed configurability of editor element palette (for columns != 4)
index bfcc5bee8889a7b09eeacc4ef8157e151833d776..b0f3ed9b3340184b9d51da0c10a526f51f624bd5 100644 (file)
@@ -7108,35 +7108,35 @@ struct ConfigInfo image_config[] =
   { "tape.text.date_yyyy.valign",              "top"                   },
   { "tape.text.date_yyyy.digits",              "4"                     },
   { "tape.text.date_yyyy.font",                        "font.tape_recorder"    },
-  { "tape.text.date_yyyy.draw_masked",         "true"                  },
+  { "tape.text.date_yyyy.draw_masked",         "false"                 },
   { "tape.text.date_yy.x",                     "-1"                    },
   { "tape.text.date_yy.y",                     "-1"                    },
   { "tape.text.date_yy.align",                 "left"                  },
   { "tape.text.date_yy.valign",                        "top"                   },
   { "tape.text.date_yy.digits",                        "2"                     },
   { "tape.text.date_yy.font",                  "font.tape_recorder"    },
-  { "tape.text.date_yy.draw_masked",           "true"                  },
+  { "tape.text.date_yy.draw_masked",           "false"                 },
   { "tape.text.date_mon.x",                    "-1"                    },
   { "tape.text.date_mon.y",                    "-1"                    },
   { "tape.text.date_mon.align",                        "left"                  },
   { "tape.text.date_mon.valign",               "top"                   },
   { "tape.text.date_mon.chars",                        "3"                     },
   { "tape.text.date_mon.font",                 "font.tape_recorder"    },
-  { "tape.text.date_mon.draw_masked",          "true"                  },
+  { "tape.text.date_mon.draw_masked",          "false"                 },
   { "tape.text.date_mm.x",                     "-1"                    },
   { "tape.text.date_mm.y",                     "-1"                    },
   { "tape.text.date_mm.align",                 "left"                  },
   { "tape.text.date_mm.valign",                        "top"                   },
   { "tape.text.date_mm.digits",                        "2"                     },
   { "tape.text.date_mm.font",                  "font.tape_recorder"    },
-  { "tape.text.date_mm.draw_masked",           "true"                  },
+  { "tape.text.date_mm.draw_masked",           "false"                 },
   { "tape.text.date_dd.x",                     "-1"                    },
   { "tape.text.date_dd.y",                     "-1"                    },
   { "tape.text.date_dd.align",                 "left"                  },
   { "tape.text.date_dd.valign",                        "top"                   },
   { "tape.text.date_dd.digits",                        "2"                     },
   { "tape.text.date_dd.font",                  "font.tape_recorder"    },
-  { "tape.text.date_dd.draw_masked",           "true"                  },
+  { "tape.text.date_dd.draw_masked",           "false"                 },
 
   { "tape.text.time.x",                                "44"                    },
   { "tape.text.time.y",                                "55"                    },
@@ -7153,21 +7153,29 @@ struct ConfigInfo image_config[] =
   { "tape.text.time_hh.valign",                        "top"                   },
   { "tape.text.time_hh.digits",                        "2"                     },
   { "tape.text.time_hh.font",                  "font.tape_recorder"    },
-  { "tape.text.time_hh.draw_masked",           "true"                  },
+  { "tape.text.time_hh.draw_masked",           "false"                 },
   { "tape.text.time_mm.x",                     "-1"                    },
   { "tape.text.time_mm.y",                     "-1"                    },
   { "tape.text.time_mm.align",                 "left"                  },
   { "tape.text.time_mm.valign",                        "top"                   },
   { "tape.text.time_mm.digits",                        "2"                     },
   { "tape.text.time_mm.font",                  "font.tape_recorder"    },
-  { "tape.text.time_mm.draw_masked",           "true"                  },
+  { "tape.text.time_mm.draw_masked",           "false"                 },
   { "tape.text.time_ss.x",                     "-1"                    },
   { "tape.text.time_ss.y",                     "-1"                    },
   { "tape.text.time_ss.align",                 "left"                  },
   { "tape.text.time_ss.valign",                        "top"                   },
   { "tape.text.time_ss.digits",                        "2"                     },
   { "tape.text.time_ss.font",                  "font.tape_recorder"    },
-  { "tape.text.time_ss.draw_masked",           "true"                  },
+  { "tape.text.time_ss.draw_masked",           "false"                 },
+
+  { "tape.text.frame.x",                       "-1"                    },
+  { "tape.text.frame.y",                       "-1"                    },
+  { "tape.text.frame.align",                   "left"                  },
+  { "tape.text.frame.valign",                  "top"                   },
+  { "tape.text.frame.digits",                  "-1"                    },
+  { "tape.text.frame.font",                    "font.tape_recorder"    },
+  { "tape.text.frame.draw_masked",             "false"                 },
 
   { "tape.show_game_buttons",                  "false"                 },
 
index b4f3f0eff00fbe842c4b3314b1813b98b8b75125..f372c980bfdfe7d832886ea79edd76b1ffe94d85 100644 (file)
@@ -6334,6 +6334,34 @@ struct TokenIntPtrInfo image_config_vars[] =
     "tape.text.time_ss.draw_masked",
     &tape.text.time_ss.draw_masked
   },
+  {
+    "tape.text.frame.x",
+    &tape.text.frame.x
+  },
+  {
+    "tape.text.frame.y",
+    &tape.text.frame.y
+  },
+  {
+    "tape.text.frame.align",
+    &tape.text.frame.align
+  },
+  {
+    "tape.text.frame.valign",
+    &tape.text.frame.valign
+  },
+  {
+    "tape.text.frame.digits",
+    &tape.text.frame.size
+  },
+  {
+    "tape.text.frame.font",
+    &tape.text.frame.font
+  },
+  {
+    "tape.text.frame.draw_masked",
+    &tape.text.frame.draw_masked
+  },
   {
     "tape.show_game_buttons",
     &tape.show_game_buttons
index 9d1c35ac393fe7c5372dcc4bec9515631543201f..bfa9f8160f1d6f9f88630477d8e7ca4209ed4148 100644 (file)
@@ -3743,7 +3743,8 @@ static void CopyNativeTape_SP_to_RND(struct LevelInfo *level)
     tape.pos[i].delay = demo_repeat + 1;
   }
 
-  tape.length_seconds = GetTapeLength();
+  tape.length_frames  = GetTapeLengthFrames();
+  tape.length_seconds = GetTapeLengthSeconds();
 }
 
 
@@ -7430,7 +7431,8 @@ void LoadTape_SokobanSolution(char *filename)
   if (tape.no_valid_file)
     return;
 
-  tape.length_seconds = GetTapeLength();
+  tape.length_frames  = GetTapeLengthFrames();
+  tape.length_seconds = GetTapeLengthSeconds();
 }
 
 void LoadTapeFromFilename(char *filename)
@@ -7572,7 +7574,8 @@ void LoadTapeFromFilename(char *filename)
 
   closeFile(file);
 
-  tape.length_seconds = GetTapeLength();
+  tape.length_frames  = GetTapeLengthFrames();
+  tape.length_seconds = GetTapeLengthSeconds();
 
 #if 0
   printf("::: tape file version: %d\n",   tape.file_version);
index 7b63ee751bfc090fbb93364d9f12612a937d254c..59a77329b4b5f83dbffb7fe84bd41036a90a46b9 100644 (file)
@@ -10832,6 +10832,9 @@ static void CheckLevelTime()
       DrawVideoDisplay(VIDEO_STATE_TIME_ON, TapeTime);
   }
 
+  if (tape.recording || tape.playing)
+    DrawVideoDisplay(VIDEO_STATE_FRAME_ON, FrameCounter);
+
   UpdateAndDisplayGameControlValues();
 }
 
index 8613f9ba7fafb369854cd8b955c38ff1cd99e0ca..342f346df3703fabf00f668a17c19b528d67f162 100644 (file)
@@ -139,7 +139,8 @@ static struct GadgetInfo *tape_gadget[NUM_TAPE_BUTTONS];
 #define PG_Y2(y)                       (DOOR_GFX_PAGEY2 + (y))
 
 #define VIDEO_INFO_OFF                 (VIDEO_STATE_DATE_OFF   |       \
-                                        VIDEO_STATE_TIME_OFF)
+                                        VIDEO_STATE_TIME_OFF   |       \
+                                        VIDEO_STATE_FRAME_OFF)
 #define VIDEO_STATE_OFF                        (VIDEO_STATE_PLAY_OFF   |       \
                                         VIDEO_STATE_REC_OFF    |       \
                                         VIDEO_STATE_PAUSE_OFF  |       \
@@ -156,7 +157,8 @@ static struct GadgetInfo *tape_gadget[NUM_TAPE_BUTTONS];
                                         VIDEO_PRESS_OFF)
 
 #define VIDEO_INFO_ON                  (VIDEO_STATE_DATE_ON    |       \
-                                        VIDEO_STATE_TIME_ON)
+                                        VIDEO_STATE_TIME_ON    |       \
+                                        VIDEO_STATE_FRAME_ON)
 #define VIDEO_STATE_ON                 (VIDEO_STATE_PLAY_ON    |       \
                                         VIDEO_STATE_REC_ON     |       \
                                         VIDEO_STATE_PAUSE_ON   |       \
@@ -177,7 +179,7 @@ static struct GadgetInfo *tape_gadget[NUM_TAPE_BUTTONS];
 #define VIDEO_PRESS                    (VIDEO_PRESS_ON | VIDEO_PRESS_OFF)
 #define VIDEO_ALL                      (VIDEO_ALL_ON | VIDEO_ALL_OFF)
 
-#define NUM_TAPE_FUNCTIONS             10
+#define NUM_TAPE_FUNCTIONS             11
 #define NUM_TAPE_FUNCTION_PARTS                2
 #define NUM_TAPE_FUNCTION_STATES       2
 
@@ -217,6 +219,11 @@ static void DrawVideoDisplay_Graphics(unsigned int state, unsigned int value)
       { IMG_TAPE_LABEL_GFX_TIME,               &tape.label.time        },
       { -1,                                    NULL                    },
     },
+    {
+      /* (no label for displaying optional frame) */
+      { -1,                                    NULL                    },
+      { -1,                                    NULL                    },
+    },
     {
       { IMG_TAPE_LABEL_GFX_FAST_FORWARD,       &tape.label.fast_forward  },
       { IMG_TAPE_SYMBOL_GFX_FAST_FORWARD,      &tape.symbol.fast_forward },
@@ -245,16 +252,18 @@ static void DrawVideoDisplay_Graphics(unsigned int state, unsigned int value)
     {
       for (j = 0; j < NUM_TAPE_FUNCTION_PARTS; j++)    /* label or symbol */
       {
-       if (video_pos[i][j].graphic == -1 ||
-           video_pos[i][j].pos->x < 0 ||
-           video_pos[i][j].pos->y < 0)
+       int graphic = video_pos[i][j].graphic;
+       struct Rect *pos = video_pos[i][j].pos;
+
+       if (graphic == -1 ||
+           pos->x == -1 ||
+           pos->y == -1)
          continue;
 
        if (state & (1 << (i * 2 + k)))
        {
          struct GraphicInfo *gfx_bg = &graphic_info[IMG_BACKGROUND_TAPE];
-         struct GraphicInfo *gfx = &graphic_info[video_pos[i][j].graphic];
-         struct Rect *pos = video_pos[i][j].pos;
+         struct GraphicInfo *gfx = &graphic_info[graphic];
          Bitmap *gd_bitmap;
          int gd_x, gd_y;
          int skip_value =
@@ -300,8 +309,10 @@ static void DrawVideoDisplay_Graphics(unsigned int state, unsigned int value)
 #define DATETIME_TIME_MM               (1 << 7)
 #define DATETIME_TIME_SS               (1 << 8)
 
-#define DATETIME_XOFFSET_1             (1 << 9)
-#define DATETIME_XOFFSET_2             (1 << 10)
+#define DATETIME_FRAME                 (1 << 9)
+
+#define DATETIME_XOFFSET_1             (1 << 10)
+#define DATETIME_XOFFSET_2             (1 << 11)
 
 #define DATETIME_DATE                  (DATETIME_DATE_YYYY     |       \
                                         DATETIME_DATE_YY       |       \
@@ -358,6 +369,8 @@ static void DrawVideoDisplay_DateTime(unsigned int state, unsigned int value)
     { &tape.text.time_mm,      DATETIME_TIME_MM                        },
     { &tape.text.time_ss,      DATETIME_TIME_SS                        },
 
+    { &tape.text.frame,                DATETIME_FRAME                          },
+
     { NULL,                    DATETIME_NONE                           },
   };
 
@@ -407,6 +420,10 @@ static void DrawVideoDisplay_DateTime(unsigned int state, unsigned int value)
 
       DrawText(xpos, ypos, s, pos->font);
     }
+    else if ((type & DATETIME_FRAME) && (state & VIDEO_STATE_FRAME_ON))
+    {
+      DrawText(xpos, ypos, int2str(value, pos->size), pos->font);
+    }
   }
 }
 
@@ -437,6 +454,7 @@ void DrawCompleteVideoDisplay()
     DrawVideoDisplay(VIDEO_STATE_REC_ON, 0);
     DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
     DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
+    DrawVideoDisplay(VIDEO_STATE_FRAME_ON, tape.length_frames);
 
     if (tape.pausing)
       DrawVideoDisplay(VIDEO_STATE_PAUSE_ON, 0);
@@ -446,6 +464,7 @@ void DrawCompleteVideoDisplay()
     DrawVideoDisplay(VIDEO_STATE_PLAY_ON, 0);
     DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
     DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
+    DrawVideoDisplay(VIDEO_STATE_FRAME_ON, 0);
 
     if (tape.pausing)
       DrawVideoDisplay(VIDEO_STATE_PAUSE_ON, 0);
@@ -454,6 +473,7 @@ void DrawCompleteVideoDisplay()
   {
     DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
     DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
+    DrawVideoDisplay(VIDEO_STATE_FRAME_ON, tape.length_frames);
   }
 
   BlitBitmap(drawto, bitmap_db_door_2, gfx.vx, gfx.vy, gfx.vxsize, gfx.vysize,
@@ -501,6 +521,7 @@ void TapeErase()
 
   tape.counter = 0;
   tape.length = 0;
+  tape.length_frames = 0;
   tape.length_seconds = 0;
 
   if (leveldir_current)
@@ -565,6 +586,7 @@ void TapeStartRecording(int random_seed)
   DrawVideoDisplay(VIDEO_STATE_REC_ON, 0);
   DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
   DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
+  DrawVideoDisplay(VIDEO_STATE_FRAME_ON, 0);
 
   MapTapeWarpButton();
 
@@ -615,7 +637,8 @@ void TapeHaltRecording()
   tape.pos[tape.counter].delay = 0;
 
   tape.length = tape.counter;
-  tape.length_seconds = GetTapeLength();
+  tape.length_frames = GetTapeLengthFrames();
+  tape.length_seconds = GetTapeLengthSeconds();
 }
 
 void TapeStopRecording()
@@ -737,6 +760,7 @@ void TapeStartPlaying()
   DrawVideoDisplay(VIDEO_STATE_PLAY_ON, 0);
   DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
   DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);
+  DrawVideoDisplay(VIDEO_STATE_FRAME_ON, 0);
 
   MapTapeWarpButton();
 
@@ -881,21 +905,27 @@ void TapeStop()
   {
     DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
     DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
+    DrawVideoDisplay(VIDEO_STATE_FRAME_ON, tape.length_frames);
   }
 }
 
-unsigned int GetTapeLength()
+unsigned int GetTapeLengthFrames()
 {
-  unsigned int tape_length = 0;
+  unsigned int tape_length_frames = 0;
   int i;
 
   if (TAPE_IS_EMPTY(tape))
     return(0);
 
   for (i = 0; i < tape.length; i++)
-    tape_length += tape.pos[i].delay;
+    tape_length_frames += tape.pos[i].delay;
 
-  return(tape_length * GAME_FRAME_DELAY / 1000);
+  return tape_length_frames;
+}
+
+unsigned int GetTapeLengthSeconds()
+{
+  return (GetTapeLengthFrames() * GAME_FRAME_DELAY / 1000);
 }
 
 static void TapeStartWarpForward()
index 6b536fb1901baa68dedefdf1bbc649301c1328cc..934239f202d030d2c51cd4826185bee807017f9d 100644 (file)
 #define VIDEO_STATE_TIME_OFF   (1 << 8)
 #define VIDEO_STATE_TIME_ON    (1 << 9)
 #define VIDEO_STATE_TIME       (VIDEO_STATE_TIME_OFF   | VIDEO_STATE_TIME_ON)
+#define VIDEO_STATE_FRAME_OFF  (1 << 10)
+#define VIDEO_STATE_FRAME_ON   (1 << 11)
+#define VIDEO_STATE_FRAME      (VIDEO_STATE_FRAME_OFF  | VIDEO_STATE_FRAME_ON)
 
-#define VIDEO_STATE_FFWD_OFF   (1 << 10)
-#define VIDEO_STATE_FFWD_ON    (1 << 11)
+#define VIDEO_STATE_FFWD_OFF   (1 << 12)
+#define VIDEO_STATE_FFWD_ON    (1 << 13)
 #define VIDEO_STATE_FFWD       (VIDEO_STATE_FFWD_OFF   | VIDEO_STATE_FFWD_ON)
-#define VIDEO_STATE_PBEND_OFF  (1 << 12)
-#define VIDEO_STATE_PBEND_ON   (1 << 13)
+#define VIDEO_STATE_PBEND_OFF  (1 << 14)
+#define VIDEO_STATE_PBEND_ON   (1 << 15)
 #define VIDEO_STATE_PBEND      (VIDEO_STATE_PBEND_OFF  | VIDEO_STATE_PBEND_ON)
-#define VIDEO_STATE_WARP_OFF   (1 << 14)
-#define VIDEO_STATE_WARP_ON    (1 << 15)
+#define VIDEO_STATE_WARP_OFF   (1 << 16)
+#define VIDEO_STATE_WARP_ON    (1 << 17)
 #define VIDEO_STATE_WARP       (VIDEO_STATE_WARP_OFF   | VIDEO_STATE_WARP_ON)
-#define VIDEO_STATE_WARP2_OFF  (1 << 16)
-#define VIDEO_STATE_WARP2_ON   (1 << 17)
+#define VIDEO_STATE_WARP2_OFF  (1 << 18)
+#define VIDEO_STATE_WARP2_ON   (1 << 19)
 #define VIDEO_STATE_WARP2      (VIDEO_STATE_WARP_OFF   | VIDEO_STATE_WARP_ON)
-#define VIDEO_STATE_1STEP_OFF  (1 << 18)
-#define VIDEO_STATE_1STEP_ON   (1 << 19)
+#define VIDEO_STATE_1STEP_OFF  (1 << 20)
+#define VIDEO_STATE_1STEP_ON   (1 << 21)
 #define VIDEO_STATE_1STEP      (VIDEO_STATE_1STEP_OFF  | VIDEO_STATE_1STEP_ON)
 
-#define VIDEO_PRESS_PLAY_ON    (1 << 20)
-#define VIDEO_PRESS_PLAY_OFF   (1 << 21)
+#define VIDEO_PRESS_PLAY_ON    (1 << 22)
+#define VIDEO_PRESS_PLAY_OFF   (1 << 23)
 #define VIDEO_PRESS_PLAY       (VIDEO_PRESS_PLAY_OFF   | VIDEO_PRESS_PLAY_ON)
-#define VIDEO_PRESS_REC_ON     (1 << 22)
-#define VIDEO_PRESS_REC_OFF    (1 << 23)
+#define VIDEO_PRESS_REC_ON     (1 << 24)
+#define VIDEO_PRESS_REC_OFF    (1 << 25)
 #define VIDEO_PRESS_REC                (VIDEO_PRESS_REC_OFF    | VIDEO_PRESS_REC_ON)
-#define VIDEO_PRESS_PAUSE_ON   (1 << 24)
-#define VIDEO_PRESS_PAUSE_OFF  (1 << 25)
+#define VIDEO_PRESS_PAUSE_ON   (1 << 26)
+#define VIDEO_PRESS_PAUSE_OFF  (1 << 27)
 #define VIDEO_PRESS_PAUSE      (VIDEO_PRESS_PAUSE_OFF  | VIDEO_PRESS_PAUSE_ON)
-#define VIDEO_PRESS_STOP_ON    (1 << 26)
-#define VIDEO_PRESS_STOP_OFF   (1 << 27)
+#define VIDEO_PRESS_STOP_ON    (1 << 28)
+#define VIDEO_PRESS_STOP_OFF   (1 << 29)
 #define VIDEO_PRESS_STOP       (VIDEO_PRESS_STOP_OFF   | VIDEO_PRESS_STOP_ON)
-#define VIDEO_PRESS_EJECT_ON   (1 << 28)
-#define VIDEO_PRESS_EJECT_OFF  (1 << 29)
+#define VIDEO_PRESS_EJECT_ON   (1 << 30)
+#define VIDEO_PRESS_EJECT_OFF  (1 << 31)
 #define VIDEO_PRESS_EJECT      (VIDEO_PRESS_EJECT_OFF  | VIDEO_PRESS_EJECT_ON)
 
 /* tags to draw video display labels or symbols only */
@@ -143,6 +146,8 @@ struct TapeTextInfo
   struct TextPosInfo time_hh;
   struct TextPosInfo time_mm;
   struct TextPosInfo time_ss;
+
+  struct TextPosInfo frame;
 };
 
 struct TapeInfo
@@ -157,6 +162,7 @@ struct TapeInfo
   unsigned int date;
   unsigned int counter;
   unsigned int length;
+  unsigned int length_frames;
   unsigned int length_seconds;
   unsigned int delay_played;
   boolean pause_before_death;
@@ -210,7 +216,8 @@ void TapeStopPlaying(void);
 byte *TapePlayAction(void);
 void TapeStop(void);
 void TapeErase(void);
-unsigned int GetTapeLength(void);
+unsigned int GetTapeLengthFrames(void);
+unsigned int GetTapeLengthSeconds(void);
 void TapeQuickSave(void);
 void TapeQuickLoad(void);
 void InsertSolutionTape(void);