Improve info handling.
This commit is contained in:
@@ -1446,7 +1446,7 @@ static void joy_digital(int num, uint16_t mask, char press, int bnum)
|
||||
if (autofire[num] & amask) autofire[num] &= ~amask;
|
||||
else autofire[num] |= amask;
|
||||
|
||||
if(hasAPI1_5()) Info((autofire[num] & amask) ? "\n Auto fire: ON" : "\n Auto fire: OFF", 16, 3);
|
||||
if(hasAPI1_5()) Info((autofire[num] & amask) ? "Auto fire: ON" : "Auto fire: OFF");
|
||||
else InfoMessage((autofire[num] & amask) ? "\n\n Auto fire\n ON" :
|
||||
"\n\n Auto fire\n OFF");
|
||||
}
|
||||
@@ -1460,8 +1460,8 @@ static void joy_digital(int num, uint16_t mask, char press, int bnum)
|
||||
|
||||
if (hasAPI1_5())
|
||||
{
|
||||
sprintf(str, "\n Auto fire period: %d ms", af_delay[num] * 2);
|
||||
Info(str, 27, 3);
|
||||
sprintf(str, "Auto fire period: %d ms", af_delay[num] * 2);
|
||||
Info(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1491,7 +1491,8 @@ static void joy_digital(int num, uint16_t mask, char press, int bnum)
|
||||
user_io_mouse(0, 0, 0);
|
||||
|
||||
mouse_emu ^= 2;
|
||||
InfoMessage((mouse_emu & 2) ? "\n\n Mouse mode lock\n ON" :
|
||||
if (hasAPI1_5()) Info((mouse_emu & 2) ? "Mouse mode ON" : "Mouse mode OFF");
|
||||
else InfoMessage((mouse_emu & 2) ? "\n\n Mouse mode lock\n ON" :
|
||||
"\n\n Mouse mode lock\n OFF");
|
||||
}
|
||||
return;
|
||||
|
||||
43
menu.cpp
43
menu.cpp
@@ -782,6 +782,10 @@ void HandleUI(void)
|
||||
OsdSetSize(8);
|
||||
break;
|
||||
|
||||
case MENU_INFO:
|
||||
if (CheckTimer(menu_timer)) menustate = MENU_NONE1;
|
||||
// fall through
|
||||
case MENU_ERROR:
|
||||
case MENU_NONE2:
|
||||
if (menu)
|
||||
{
|
||||
@@ -3278,26 +3282,6 @@ void HandleUI(void)
|
||||
menustate = MENU_NONE1;
|
||||
break;
|
||||
|
||||
/******************************************************************/
|
||||
/* error message menu */
|
||||
/******************************************************************/
|
||||
case MENU_ERROR:
|
||||
if (menu)
|
||||
menustate = MENU_NONE1;
|
||||
break;
|
||||
|
||||
/******************************************************************/
|
||||
/* popup info menu */
|
||||
/******************************************************************/
|
||||
case MENU_INFO:
|
||||
|
||||
if (menu)
|
||||
menustate = MENU_NONE1;
|
||||
else if (CheckTimer(menu_timer))
|
||||
menustate = MENU_NONE1;
|
||||
|
||||
break;
|
||||
|
||||
/******************************************************************/
|
||||
/* we should never come here */
|
||||
/******************************************************************/
|
||||
@@ -3547,7 +3531,7 @@ void ErrorMessage(const char *message, unsigned char code)
|
||||
OsdEnable(0); // do not disable KEYBOARD
|
||||
}
|
||||
|
||||
void InfoMessage(const char *message)
|
||||
void InfoMessage(const char *message, int timeout)
|
||||
{
|
||||
if (menustate != MENU_INFO)
|
||||
{
|
||||
@@ -3557,29 +3541,18 @@ void InfoMessage(const char *message)
|
||||
|
||||
set_text(message, 0);
|
||||
|
||||
menu_timer = GetTimer(2000);
|
||||
menu_timer = GetTimer(timeout);
|
||||
menustate = MENU_INFO;
|
||||
}
|
||||
|
||||
void InfoMessageEx(const char *message, int timeout)
|
||||
{
|
||||
InfoMessage(message);
|
||||
menu_timer = GetTimer(timeout);
|
||||
}
|
||||
|
||||
void InfoEx(const char *message, int width, int height, int timeout)
|
||||
void Info(const char *message, int timeout, int width, int height, int frame)
|
||||
{
|
||||
if (!user_io_osd_is_visible())
|
||||
{
|
||||
OSD_PrintInfo(message, width, height, 0);
|
||||
OSD_PrintInfo(message, &width, &height, frame);
|
||||
InfoEnable(20, 10, width, height);
|
||||
|
||||
menu_timer = GetTimer(timeout);
|
||||
menustate = MENU_INFO;
|
||||
}
|
||||
}
|
||||
|
||||
void Info(const char *message, int width, int height)
|
||||
{
|
||||
InfoEx(message, width, height, 2000);
|
||||
}
|
||||
|
||||
8
menu.h
8
menu.h
@@ -18,12 +18,8 @@ void HandleUI(void);
|
||||
void PrintDirectory(void);
|
||||
void ScrollLongName(void);
|
||||
void ErrorMessage(const char *message, unsigned char code);
|
||||
void InfoMessage(const char *message);
|
||||
void InfoMessageEx(const char *message, int timeout);
|
||||
void InfoEx(const char *message, int width, int height, int timeout);
|
||||
void Info(const char *message, int width, int height);
|
||||
void ShowSplash();
|
||||
void HideSplash();
|
||||
void InfoMessage(const char *message, int timeout = 2000);
|
||||
void Info(const char *message, int timeout = 2000, int width = 0, int height = 0, int frame = 0);
|
||||
|
||||
unsigned long getStatus(char *opt, unsigned long status);
|
||||
|
||||
|
||||
45
osd.cpp
45
osd.cpp
@@ -461,59 +461,70 @@ void OSD_PrintText(unsigned char line, const char *text, unsigned long start, un
|
||||
#define INFO_MAXW 32
|
||||
#define INFO_MAXH 16
|
||||
|
||||
void OSD_PrintInfo(const char *message, int width, int height, int frame)
|
||||
void OSD_PrintInfo(const char *message, int *width, int *height, int frame)
|
||||
{
|
||||
static char str[INFO_MAXW * INFO_MAXH];
|
||||
|
||||
if (!width || !height) return;
|
||||
|
||||
memset(str, ' ', sizeof(str));
|
||||
if (width > INFO_MAXW) width = INFO_MAXW;
|
||||
if (height > INFO_MAXH) height = INFO_MAXH;
|
||||
|
||||
int x = 0, y = 0;
|
||||
// calc height/width if none provided. Add frame to calculated size.
|
||||
// no frame will be added if width and height are provided.
|
||||
int calc = !*width || !*height || frame;
|
||||
|
||||
int maxw = 0;
|
||||
int x = calc ? 1 : 0;
|
||||
int y = calc ? 1 : 0;
|
||||
while (*message)
|
||||
{
|
||||
char c = *message++;
|
||||
if (c == 0xD) continue;
|
||||
if (c == 0xA)
|
||||
{
|
||||
x = 0;
|
||||
x = calc ? 1 : 0;
|
||||
y++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (x < INFO_MAXW && y < INFO_MAXH) str[(y*INFO_MAXW) + x] = c;
|
||||
|
||||
x++;
|
||||
if (x > maxw) maxw = x;
|
||||
}
|
||||
|
||||
int w = !calc ? *width + 2 : maxw+1;
|
||||
if (w > INFO_MAXW) w = INFO_MAXW;
|
||||
*width = w;
|
||||
|
||||
int h = !calc ? *height + 2 : y+2;
|
||||
if (h > INFO_MAXH) h = INFO_MAXH;
|
||||
*height = h;
|
||||
|
||||
if (frame)
|
||||
{
|
||||
frame = (frame - 1) * 6;
|
||||
for (x = 1; x < width - 1; x++)
|
||||
for (x = 1; x < w - 1; x++)
|
||||
{
|
||||
str[(0 * INFO_MAXW) + x] = 0x81+frame;
|
||||
str[((height - 1)*INFO_MAXW) + x] = 0x81 + frame;
|
||||
str[((h - 1)*INFO_MAXW) + x] = 0x81 + frame;
|
||||
}
|
||||
for (y = 1; y < height - 1; y++)
|
||||
for (y = 1; y < h - 1; y++)
|
||||
{
|
||||
str[(y * INFO_MAXW)] = 0x83 + frame;
|
||||
str[(y * INFO_MAXW) + width - 1] = 0x83 + frame;
|
||||
str[(y * INFO_MAXW) + w - 1] = 0x83 + frame;
|
||||
}
|
||||
str[0] = 0x80 + frame;
|
||||
str[width - 1] = 0x82 + frame;
|
||||
str[(height - 1)*INFO_MAXW] = 0x85 + frame;
|
||||
str[((height - 1)*INFO_MAXW) + width - 1] = 0x84 + frame;
|
||||
str[w - 1] = 0x82 + frame;
|
||||
str[(h - 1)*INFO_MAXW] = 0x85 + frame;
|
||||
str[((h - 1)*INFO_MAXW) + w - 1] = 0x84 + frame;
|
||||
}
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
if (!is_minimig())
|
||||
spi_osd_cmd_cont(MM1_OSDCMDWRITE | y);
|
||||
else
|
||||
spi_osd_cmd32_cont(OSD_CMD_OSD_WR, y);
|
||||
|
||||
for (x = 0; x < width; x++)
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
const unsigned char *p = charfont[str[(y*INFO_MAXW) + x]];
|
||||
for (int i = 0; i < 8; i++) spi8(*p++);
|
||||
|
||||
2
osd.h
2
osd.h
@@ -82,7 +82,7 @@ void ConfigChipset(unsigned char chipset);
|
||||
void ConfigFloppy(unsigned char drives, unsigned char speed);
|
||||
void ConfigAutofire(unsigned char autofire, unsigned char mask);
|
||||
void OSD_PrintText(unsigned char line, const char *text, unsigned long start, unsigned long width, unsigned long offset, unsigned char invert);
|
||||
void OSD_PrintInfo(const char *message, int width, int height, int frame);
|
||||
void OSD_PrintInfo(const char *message, int *width, int *height, int frame = 0);
|
||||
void OsdDrawLogo(unsigned char n, char row, char superimpose);
|
||||
void ScrollText(char n, const char *str, int off, int len, int max_len, unsigned char invert);
|
||||
void ScrollReset();
|
||||
|
||||
14
user_io.cpp
14
user_io.cpp
@@ -1798,7 +1798,7 @@ static void set_volume()
|
||||
spi_uio_cmd8(UIO_AUDVOL, vol_att);
|
||||
if (vol_att & 0x10)
|
||||
{
|
||||
InfoEx("\n \x8d Mute", 8, 3, 1000);
|
||||
Info("\x8d Mute", 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1806,11 +1806,11 @@ static void set_volume()
|
||||
memset(str, 0, sizeof(str));
|
||||
|
||||
int vol = vol_att & 0xf;
|
||||
sprintf(str, "\n \x8d ");
|
||||
sprintf(str, "\x8d ");
|
||||
char *bar = str + strlen(str);
|
||||
memset(bar, 0x8C, 16);
|
||||
memset(bar, 0x7f, 16 - vol);
|
||||
InfoEx(str, 20, 3, 1000);
|
||||
Info(str, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2208,11 +2208,11 @@ static uint32_t show_video_info(int force)
|
||||
static char str[128];
|
||||
float vrateh = 100000000;
|
||||
if (vtimeh) vrateh /= vtimeh; else vrateh = 0;
|
||||
sprintf(str, "\n %4dx%-4d %6.2fKHz %4.1fHz" \
|
||||
"\n \x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81" \
|
||||
"\n %4dx%-4d %6.2fMHz %4.1fHz",
|
||||
sprintf(str, "%4dx%-4d %6.2fKHz %4.1fHz\n" \
|
||||
"\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\n" \
|
||||
"%4dx%-4d %6.2fMHz %4.1fHz",
|
||||
width, height, hrate, vrate, vitems[1], vitems[5], Fpix, vrateh);
|
||||
InfoEx(str, 30, 5, cfg.video_info * 1000);
|
||||
Info(str, cfg.video_info * 1000);
|
||||
}
|
||||
|
||||
if (vtime && vtimeh) return vtime;
|
||||
|
||||
Reference in New Issue
Block a user