Skip to content

Commit

Permalink
OSD: fix scrolling file name when help text is scrolling.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorgelig committed Jun 4, 2021
1 parent 0d636b1 commit 214ab93
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1220,12 +1220,12 @@ void HandleUI(void)
}
else if (helpstate == 9)
{
ScrollReset();
ScrollReset(1);
++helpstate;
}
else
{
ScrollText(OsdGetSize() - 1, helptexts[helptext_idx], 0, 0, 0, 0);
ScrollText(OsdGetSize() - 1, helptexts[helptext_idx], 0, 0, 0, 0, 1);
}
}

Expand Down
24 changes: 12 additions & 12 deletions osd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ void StarsUpdate()
#define SCROLL_DELAY2 10
#define SCROLL_DELAY3 50

static unsigned long scroll_offset = 0; // file/dir name scrolling position
static unsigned long scroll_timer = 0; // file/dir name scrolling timer
static unsigned long scroll_offset[2] = {}; // file/dir name scrolling position
static unsigned long scroll_timer[2] = {}; // file/dir name scrolling timer

static int arrow;
static unsigned char titlebuffer[256];
Expand Down Expand Up @@ -593,7 +593,7 @@ static void print_line(unsigned char line, const char *hdr, const char *text, un
}
}

void ScrollText(char n, const char *str, int off, int len, int max_len, unsigned char invert)
void ScrollText(char n, const char *str, int off, int len, int max_len, unsigned char invert, int idx)
{
// this function is called periodically when a string longer than the window is displayed.

Expand All @@ -603,7 +603,7 @@ void ScrollText(char n, const char *str, int off, int len, int max_len, unsigned
long offset;
if (!max_len) max_len = 30;

if (str && str[0] && CheckTimer(scroll_timer)) // scroll if long name and timer delay elapsed
if (str && str[0] && CheckTimer(scroll_timer[idx])) // scroll if long name and timer delay elapsed
{
hdr[0] = 0;
if (off)
Expand All @@ -614,19 +614,19 @@ void ScrollText(char n, const char *str, int off, int len, int max_len, unsigned
if (len > off) len -= off;
}

scroll_timer = GetTimer(SCROLL_DELAY2); // reset scroll timer to repeat delay
scroll_timer[idx] = GetTimer(SCROLL_DELAY2); // reset scroll timer to repeat delay

scroll_offset++; // increase scroll position (1 pixel unit)
scroll_offset[idx]++; // increase scroll position (1 pixel unit)
memset(s, ' ', 32); // clear buffer

if (!len) len = strlen(str); // get name length

if (off+2+len > max_len) // scroll name if longer than display size
{
// reset scroll position if it exceeds predefined maximum
if (scroll_offset >= (uint)(len + BLANKSPACE) << 3) scroll_offset = 0;
if (scroll_offset[idx] >= (uint)(len + BLANKSPACE) << 3) scroll_offset[idx] = 0;

offset = scroll_offset >> 3; // get new starting character of the name (scroll_offset is no longer in 2 pixel unit)
offset = scroll_offset[idx] >> 3; // get new starting character of the name (scroll_offset is no longer in 2 pixel unit)
len -= offset; // remaining number of characters in the name
if (len>max_len) len = max_len;
if (len > 0) strncpy(s, &str[offset], len); // copy name substring
Expand All @@ -636,15 +636,15 @@ void ScrollText(char n, const char *str, int off, int len, int max_len, unsigned
strncpy(s + len + BLANKSPACE, str, max_len - len - BLANKSPACE); // repeat the name after its end and predefined number of blank space
}

print_line(n, hdr, s, (max_len - 1) << 3, (scroll_offset & 0x7), invert); // OSD print function with pixel precision
print_line(n, hdr, s, (max_len - 1) << 3, (scroll_offset[idx] & 0x7), invert); // OSD print function with pixel precision
}
}
}

void ScrollReset()
void ScrollReset(int idx)
{
scroll_timer = GetTimer(SCROLL_DELAY); // set timer to start name scrolling after predefined time delay
scroll_offset = 0; // start scrolling from the start
scroll_timer[idx] = GetTimer(SCROLL_DELAY); // set timer to start name scrolling after predefined time delay
scroll_offset[idx] = 0; // start scrolling from the start
}

/* core currently loaded */
Expand Down
4 changes: 2 additions & 2 deletions osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ void OsdMenuCtl(int en);
void OsdUpdate();
void OSD_PrintInfo(const char *message, int *width, int *height, int frame = 0);
void OsdDrawLogo(int row);
void ScrollText(char n, const char *str, int off, int len, int max_len, unsigned char invert);
void ScrollReset();
void ScrollText(char n, const char *str, int off, int len, int max_len, unsigned char invert, int idx = 0);
void ScrollReset(int idx = 0);
void StarsInit();
void StarsUpdate();
void OsdShiftDown(unsigned char n);
Expand Down

0 comments on commit 214ab93

Please sign in to comment.