mirror of https://github.com/snes9xgit/snes9x.git
Add special S9xDisplayStringType to pass additional info.
Add some arrow characters for displayed keys.
This commit is contained in:
parent
bb66278585
commit
8a2cd602da
14
font.h
14
font.h
|
@ -131,13 +131,13 @@ static const char *font[] =
|
|||
" ",
|
||||
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" . . ",
|
||||
" .#. .#. . ..... ",
|
||||
" .##. .##. .#. .#####. ",
|
||||
" .###. .###. .###. .###. ",
|
||||
" .##. .##. .#####. .#. ",
|
||||
" .#. .#. ..... . ",
|
||||
" . . ",
|
||||
" ",
|
||||
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
|
||||
" ",
|
||||
|
|
30
gfx.cpp
30
gfx.cpp
|
@ -22,7 +22,7 @@ extern struct SLineMatrixData LineMatrixData[240];
|
|||
void S9xComputeClipWindows (void);
|
||||
|
||||
static int font_width = 8, font_height = 9;
|
||||
void (*S9xCustomDisplayString) (const char *, int, int, bool) = NULL;
|
||||
void (*S9xCustomDisplayString) (const char *, int, int, bool, int) = NULL;
|
||||
|
||||
static void SetupOBJ (void);
|
||||
static void DrawOBJS (int);
|
||||
|
@ -38,6 +38,7 @@ static inline void DrawBackgroundMode7 (int, void (*DrawMath) (uint32, uint32, i
|
|||
static inline void DrawBackdrop (void);
|
||||
static inline void RenderScreen (bool8);
|
||||
static uint16 get_crosshair_color (uint8);
|
||||
static void S9xDisplayStringType (const char *, int, int, bool, int);
|
||||
|
||||
#define TILE_PLUS(t, x) (((t) & 0xfc00) | ((t + x) & 0x3ff))
|
||||
|
||||
|
@ -1827,7 +1828,7 @@ static void DisplayStringFromBottom (const char *string, int linesFromBottom, in
|
|||
{
|
||||
if (S9xCustomDisplayString)
|
||||
{
|
||||
S9xCustomDisplayString (string, linesFromBottom, pixelsFromLeft, allowWrap);
|
||||
S9xCustomDisplayString (string, linesFromBottom, pixelsFromLeft, allowWrap, S9X_NO_INFO);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1862,6 +1863,17 @@ static void DisplayStringFromBottom (const char *string, int linesFromBottom, in
|
|||
}
|
||||
}
|
||||
|
||||
static void S9xDisplayStringType (const char *string, int linesFromBottom, int pixelsFromLeft, bool allowWrap, int type)
|
||||
{
|
||||
if (S9xCustomDisplayString)
|
||||
{
|
||||
S9xCustomDisplayString (string, linesFromBottom, pixelsFromLeft, allowWrap, type);
|
||||
return;
|
||||
}
|
||||
|
||||
S9xDisplayString (string, linesFromBottom, pixelsFromLeft, allowWrap);
|
||||
}
|
||||
|
||||
static void DisplayFrameRate (void)
|
||||
{
|
||||
char string[10];
|
||||
|
@ -1892,8 +1904,8 @@ static void DisplayFrameRate (void)
|
|||
|
||||
static void DisplayPressedKeys (void)
|
||||
{
|
||||
static char KeyMap[] = { '0', '1', '2', 'R', 'L', 'X', 'A', '>', '<', 'v', '^', 'S', 's', 'Y', 'B' };
|
||||
static int KeyOrder[] = { 8, 10, 7, 9, 0, 6, 14, 13, 5, 1, 4, 3, 2, 11, 12 }; // < ^ > v A B Y X L R S s
|
||||
static unsigned char KeyMap[] = { '0', '1', '2', 'R', 'L', 'X', 'A', 225, 224, 227, 226, 'S', 's', 'Y', 'B' };
|
||||
static int KeyOrder[] = { 8, 10, 7, 9, 0, 6, 14, 13, 5, 1, 4, 3, 2, 11, 12 }; // < ^ > v A B Y X L R S s
|
||||
|
||||
enum controllers controller;
|
||||
int line = Settings.DisplayMovieFrame && S9xMovieActive() ? 2 : 1;
|
||||
|
@ -1916,7 +1928,7 @@ static void DisplayPressedKeys (void)
|
|||
uint8 buttons = buf[4];
|
||||
sprintf(string, "#%d %d: (%03d,%03d) %c%c", port + 1, ids[0] + 1, x, y,
|
||||
(buttons & 0x40) ? 'L' : ' ', (buttons & 0x80) ? 'R' : ' ');
|
||||
S9xDisplayString(string, line++, 1, false);
|
||||
S9xDisplayStringType(string, line++, 1, false, S9X_PRESSED_KEYS_INFO);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1931,7 +1943,7 @@ static void DisplayPressedKeys (void)
|
|||
sprintf(string, "#%d %d: (%03d,%03d) %c%c%c%c", port + 1, ids[0] + 1, x, y,
|
||||
(buttons & 0x80) ? 'F' : ' ', (buttons & 0x40) ? 'C' : ' ',
|
||||
(buttons & 0x20) ? 'T' : ' ', (buttons & 0x10) ? 'P' : ' ');
|
||||
S9xDisplayString(string, line++, 1, false);
|
||||
S9xDisplayStringType(string, line++, 1, false, S9X_PRESSED_KEYS_INFO);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1950,7 +1962,7 @@ static void DisplayPressedKeys (void)
|
|||
sprintf(string, "#%d %d: (%03d,%03d) %c%c%c / (%03d,%03d) %c%c%c", port + 1, ids[0] + 1,
|
||||
x1, y1, (buttons & 0x80) ? 'T' : ' ', (buttons & 0x20) ? 'S' : ' ', offscreen1 ? 'O' : ' ',
|
||||
x2, y2, (buttons & 0x40) ? 'T' : ' ', (buttons & 0x10) ? 'S' : ' ', offscreen2 ? 'O' : ' ');
|
||||
S9xDisplayString(string, line++, 1, false);
|
||||
S9xDisplayStringType(string, line++, 1, false, S9X_PRESSED_KEYS_INFO);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1965,7 +1977,7 @@ static void DisplayPressedKeys (void)
|
|||
string[6 + i]= (pad & mask) ? KeyMap[j] : ' ';
|
||||
}
|
||||
|
||||
S9xDisplayString(string, line++, 1, false);
|
||||
S9xDisplayStringType(string, line++, 1, false, S9X_PRESSED_KEYS_INFO);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1984,7 +1996,7 @@ static void DisplayPressedKeys (void)
|
|||
string[6 + i]= (pad & mask) ? KeyMap[j] : ' ';
|
||||
}
|
||||
|
||||
S9xDisplayString(string, line++, 1, false);
|
||||
S9xDisplayStringType(string, line++, 1, false, S9X_PRESSED_KEYS_INFO);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
gfx.h
2
gfx.h
|
@ -191,6 +191,6 @@ void S9xSetPalette (void);
|
|||
void S9xSyncSpeed (void);
|
||||
|
||||
// called instead of S9xDisplayString if set to non-NULL
|
||||
extern void (*S9xCustomDisplayString) (const char *, int, int, bool);
|
||||
extern void (*S9xCustomDisplayString) (const char *, int, int, bool, int type);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1800,15 +1800,15 @@ static int StringWidth (const char *str)
|
|||
return pixcount;
|
||||
}
|
||||
|
||||
static void GTKDisplayChar (int x, int y, uint8 c, bool overlap = false)
|
||||
static void GTKDisplayChar (int x, int y, uint8 c, bool overlap = false, bool monospace = false)
|
||||
{
|
||||
int cindex = c - 32;
|
||||
int crow = cindex >> 4;
|
||||
int ccol = cindex & 15;
|
||||
int cwidth = font_width - kern[cindex][0] - kern[cindex][1];
|
||||
int cwidth = font_width - (monospace ? 0 : (kern[cindex][0] + kern[cindex][1]));
|
||||
|
||||
int line = crow * font_height;
|
||||
int offset = ccol * font_width + kern[cindex][0];
|
||||
int offset = ccol * font_width + (monospace ? 0 : kern[cindex][0]);
|
||||
int scale = IPPU.RenderedScreenWidth / SNES_WIDTH;
|
||||
|
||||
uint16 *s = GFX.Screen + y * GFX.RealPPL + x * scale;
|
||||
|
@ -1821,7 +1821,9 @@ static void GTKDisplayChar (int x, int y, uint8 c, bool overlap = false)
|
|||
|
||||
if (p == '#')
|
||||
*s = Settings.DisplayColor;
|
||||
else if (!overlap || w > 0)
|
||||
else if (monospace && p == '.')
|
||||
*s = 0x0000;
|
||||
else if (!monospace && (!overlap || w > 0))
|
||||
*s = (*s & 0xf7de) >> 1;
|
||||
|
||||
if (scale > 1)
|
||||
|
@ -1834,16 +1836,22 @@ static void GTKDisplayChar (int x, int y, uint8 c, bool overlap = false)
|
|||
}
|
||||
|
||||
static void S9xGTKDisplayString (const char *string, int linesFromBottom,
|
||||
int pixelsFromLeft, bool allowWrap)
|
||||
int pixelsFromLeft, bool allowWrap, int type)
|
||||
{
|
||||
if (linesFromBottom <= 0)
|
||||
linesFromBottom = 1;
|
||||
bool monospace = true;
|
||||
if (type == S9X_NO_INFO)
|
||||
{
|
||||
if (linesFromBottom <= 0)
|
||||
linesFromBottom = 1;
|
||||
|
||||
if (linesFromBottom >= 5)
|
||||
linesFromBottom -= 3;
|
||||
if (linesFromBottom >= 5)
|
||||
linesFromBottom -= 3;
|
||||
|
||||
if (pixelsFromLeft > 128)
|
||||
pixelsFromLeft = SNES_WIDTH - StringWidth (string);
|
||||
if (pixelsFromLeft > 128)
|
||||
pixelsFromLeft = SNES_WIDTH - StringWidth (string);
|
||||
|
||||
monospace = false;
|
||||
}
|
||||
|
||||
int dst_x = pixelsFromLeft;
|
||||
int dst_y = IPPU.RenderedScreenHeight - font_height * linesFromBottom;
|
||||
|
@ -1858,7 +1866,7 @@ static void S9xGTKDisplayString (const char *string, int linesFromBottom,
|
|||
for (int i = 0 ; i < len ; i++)
|
||||
{
|
||||
int cindex = string[i] - 32;
|
||||
int char_width = font_width - kern[cindex][0] - kern[cindex][1];
|
||||
int char_width = font_width - (monospace ? 1 : (kern[cindex][0] + kern[cindex][1]));
|
||||
|
||||
if (dst_x + char_width > SNES_WIDTH || (uint8) string[i] < 32)
|
||||
{
|
||||
|
@ -1876,7 +1884,8 @@ static void S9xGTKDisplayString (const char *string, int linesFromBottom,
|
|||
if ((uint8) string[i] < 32)
|
||||
continue;
|
||||
|
||||
GTKDisplayChar(dst_x, dst_y, string[i], overlap);
|
||||
GTKDisplayChar(dst_x, dst_y, string[i], overlap, monospace);
|
||||
|
||||
dst_x += char_width - 1;
|
||||
overlap = true;
|
||||
}
|
||||
|
|
|
@ -370,6 +370,14 @@ gboolean S9xScreenSaverCheckFunc (gpointer data)
|
|||
/* Snes9x core hooks */
|
||||
void S9xMessage (int type, int number, const char *message)
|
||||
{
|
||||
switch (number)
|
||||
{
|
||||
case S9X_MOVIE_INFO:
|
||||
S9xSetInfoString (message);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Varies from ParseArgs because this one is for the OS port to handle */
|
||||
|
|
|
@ -21,6 +21,7 @@ enum
|
|||
// Individual message numbers
|
||||
enum
|
||||
{
|
||||
S9X_NO_INFO,
|
||||
S9X_ROM_INFO,
|
||||
S9X_HEADERS_INFO,
|
||||
S9X_CONFIG_INFO,
|
||||
|
@ -51,7 +52,8 @@ enum
|
|||
S9X_WRONG_MOVIE_SNAPSHOT,
|
||||
S9X_NOT_A_MOVIE_SNAPSHOT,
|
||||
S9X_SNAPSHOT_INCONSISTENT,
|
||||
S9X_AVI_INFO
|
||||
S9X_AVI_INFO,
|
||||
S9X_PRESSED_KEYS_INFO,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue