From 9c92df9586b75ab4afc1345e944108e95e2f8174 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 4 Feb 2015 00:13:17 +0100 Subject: [PATCH] added optionally configurable game frame counter to tape display --- ChangeLog | 1 + src/conf_gfx.c | 24 +++++++++++++------- src/conf_var.c | 28 +++++++++++++++++++++++ src/files.c | 9 +++++--- src/game.c | 3 +++ src/tape.c | 60 +++++++++++++++++++++++++++++++++++++------------- src/tape.h | 49 +++++++++++++++++++++++------------------ 7 files changed, 127 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index 25ebcf89..203fafd8 100644 --- 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) diff --git a/src/conf_gfx.c b/src/conf_gfx.c index bfcc5bee..b0f3ed9b 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -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" }, diff --git a/src/conf_var.c b/src/conf_var.c index b4f3f0ef..f372c980 100644 --- a/src/conf_var.c +++ b/src/conf_var.c @@ -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 diff --git a/src/files.c b/src/files.c index 9d1c35ac..bfa9f816 100644 --- a/src/files.c +++ b/src/files.c @@ -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); diff --git a/src/game.c b/src/game.c index 7b63ee75..59a77329 100644 --- a/src/game.c +++ b/src/game.c @@ -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(); } diff --git a/src/tape.c b/src/tape.c index 8613f9ba..342f346d 100644 --- a/src/tape.c +++ b/src/tape.c @@ -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() diff --git a/src/tape.h b/src/tape.h index 6b536fb1..934239f2 100644 --- a/src/tape.h +++ b/src/tape.h @@ -50,37 +50,40 @@ #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); -- 2.34.1