mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-01 14:31:54 +00:00
(GX) implement debug text
This commit is contained in:
parent
fdd4adf76c
commit
535f83be3e
@ -18,6 +18,8 @@
|
||||
|
||||
#define FONT_WIDTH 5
|
||||
#define FONT_HEIGHT 10
|
||||
#define FONT_WIDTH_STRIDE (FONT_WIDTH + 1)
|
||||
#define FONT_HEIGHT_STRIDE (FONT_HEIGHT + 1)
|
||||
|
||||
#define FONT_OFFSET(x) ((x) * ((FONT_HEIGHT * FONT_WIDTH + 7) / 8))
|
||||
|
||||
|
@ -24,9 +24,6 @@
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#define FONT_WIDTH_STRIDE (FONT_WIDTH + 1)
|
||||
#define FONT_HEIGHT_STRIDE (FONT_HEIGHT + 1)
|
||||
|
||||
#define TERM_START_X 15
|
||||
#define TERM_START_Y 27
|
||||
#define TERM_WIDTH (((RGUI_WIDTH - TERM_START_X - 15) / (FONT_WIDTH_STRIDE)))
|
||||
@ -380,6 +377,9 @@ static void render_text(rgui_handle_t *rgui)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case RGUI_SETTINGS_DEBUG_TEXT:
|
||||
snprintf(type_str, sizeof(type_str), g_console.fps_info_msg_enable ? "ON" : "OFF");
|
||||
break;
|
||||
case RGUI_SETTINGS_CUSTOM_VIEWPORT:
|
||||
case RGUI_SETTINGS_CORE:
|
||||
case RGUI_SETTINGS_CONTROLLER_1:
|
||||
@ -615,6 +615,12 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t
|
||||
else if (action == RGUI_ACTION_RIGHT && g_console.zip_extract_mode < LAST_ZIP_EXTRACT)
|
||||
g_console.zip_extract_mode++;
|
||||
break;
|
||||
case RGUI_SETTINGS_DEBUG_TEXT:
|
||||
if (action == RGUI_ACTION_START || action == RGUI_ACTION_LEFT)
|
||||
g_console.fps_info_msg_enable = false;
|
||||
else if (action == RGUI_ACTION_RIGHT)
|
||||
g_console.fps_info_msg_enable = true;
|
||||
break;
|
||||
case RGUI_SETTINGS_RESTART_EMULATOR:
|
||||
if (action == RGUI_ACTION_OK)
|
||||
{
|
||||
@ -718,6 +724,7 @@ static void rgui_settings_populate_entries(rgui_handle_t *rgui)
|
||||
RGUI_MENU_ITEM("Controller #2 Config", RGUI_SETTINGS_CONTROLLER_2);
|
||||
RGUI_MENU_ITEM("Controller #3 Config", RGUI_SETTINGS_CONTROLLER_3);
|
||||
RGUI_MENU_ITEM("Controller #4 Config", RGUI_SETTINGS_CONTROLLER_4);
|
||||
RGUI_MENU_ITEM("Debug Text", RGUI_SETTINGS_DEBUG_TEXT);
|
||||
RGUI_MENU_ITEM("Restart RetroArch", RGUI_SETTINGS_RESTART_EMULATOR);
|
||||
RGUI_MENU_ITEM("Exit RetroArch", RGUI_SETTINGS_QUIT_EMULATOR);
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ typedef enum
|
||||
RGUI_SETTINGS_CONTROLLER_2,
|
||||
RGUI_SETTINGS_CONTROLLER_3,
|
||||
RGUI_SETTINGS_CONTROLLER_4,
|
||||
RGUI_SETTINGS_DEBUG_TEXT,
|
||||
RGUI_SETTINGS_RESTART_EMULATOR,
|
||||
RGUI_SETTINGS_QUIT_EMULATOR,
|
||||
|
||||
|
@ -31,14 +31,18 @@
|
||||
#include <sys/sys_time.h>
|
||||
#endif
|
||||
|
||||
#ifdef GEKKO
|
||||
#include <ogc/lwp_watchdog.h>
|
||||
#endif
|
||||
|
||||
#if IS_LINUX
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(_MSC_VER)
|
||||
static int gettimeofday(struct timeval *val, void *dummy)
|
||||
#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(_MSC_VER) || defined(GEKKO)
|
||||
static int gettimeofday2(struct timeval *val, void *dummy)
|
||||
{
|
||||
(void)dummy;
|
||||
#if defined(_MSC_VER) && !defined(_XBOX360)
|
||||
@ -49,6 +53,8 @@ static int gettimeofday(struct timeval *val, void *dummy)
|
||||
|
||||
#if defined(__CELLOS_LV2__)
|
||||
uint64_t usec = sys_time_get_system_time();
|
||||
#elif defined(GEKKO)
|
||||
uint64_t usec = ticks_to_microsecs(gettime());
|
||||
#else
|
||||
uint64_t usec = msec * 1000;
|
||||
#endif
|
||||
@ -57,6 +63,9 @@ static int gettimeofday(struct timeval *val, void *dummy)
|
||||
val->tv_usec = usec % 1000000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// GEKKO has gettimeofday, but it's not accurate enough for calculating FPS, so hack around it
|
||||
#define gettimeofday gettimeofday2
|
||||
#endif
|
||||
|
||||
static float tv_to_fps(const struct timeval *tv, const struct timeval *new_tv, int frames)
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "../driver.h"
|
||||
#include "../general.h"
|
||||
#include "../console/rarch_console_video.h"
|
||||
#include "../console/font.h"
|
||||
#include "../gfx/gfx_common.h"
|
||||
#include "gx_video.h"
|
||||
#include <gccore.h>
|
||||
#include <ogcsys.h>
|
||||
@ -534,6 +536,66 @@ static void gx_resize(gx_video_t *gx)
|
||||
gx->should_resize = false;
|
||||
}
|
||||
|
||||
static void gx_blit_line(unsigned x, unsigned y, const char *message)
|
||||
{
|
||||
const GXColor b = {
|
||||
.r = 0x00,
|
||||
.g = 0x00,
|
||||
.b = 0x00,
|
||||
.a = 0xff
|
||||
};
|
||||
|
||||
const GXColor w = {
|
||||
.r = 0xff,
|
||||
.g = 0xff,
|
||||
.b = 0xff,
|
||||
.a = 0xff
|
||||
};
|
||||
|
||||
unsigned h;
|
||||
|
||||
for (h = 0; h < FONT_HEIGHT * 2; h++)
|
||||
{
|
||||
GX_PokeARGB(x, y + h, b);
|
||||
GX_PokeARGB(x + 1, y + h, b);
|
||||
}
|
||||
|
||||
x += 2;
|
||||
|
||||
while (*message)
|
||||
{
|
||||
for (unsigned j = 0; j < FONT_HEIGHT; j++)
|
||||
{
|
||||
for (unsigned i = 0; i < FONT_WIDTH; i++)
|
||||
{
|
||||
GXColor c;
|
||||
uint8_t rem = 1 << ((i + j * FONT_WIDTH) & 7);
|
||||
unsigned offset = (i + j * FONT_WIDTH) >> 3;
|
||||
bool col = (_binary_console_font_bin_start[FONT_OFFSET((unsigned char) *message) + offset] & rem);
|
||||
|
||||
if (col)
|
||||
c = w;
|
||||
else
|
||||
c = b;
|
||||
|
||||
GX_PokeARGB(x + (i * 2), y + (j * 2), c);
|
||||
GX_PokeARGB(x + (i * 2) + 1, y + (j * 2), c);
|
||||
GX_PokeARGB(x + (i * 2) + 1, y + (j * 2) + 1, c);
|
||||
GX_PokeARGB(x + (i * 2), y + (j * 2) + 1, c);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned h = 0; h < FONT_HEIGHT * 2; h++)
|
||||
{
|
||||
GX_PokeARGB(x + (FONT_WIDTH * 2), y + h, b);
|
||||
GX_PokeARGB(x + (FONT_WIDTH * 2) + 1, y + h, b);
|
||||
}
|
||||
|
||||
x += FONT_WIDTH_STRIDE * 2;
|
||||
message++;
|
||||
}
|
||||
}
|
||||
|
||||
static bool gx_frame(void *data, const void *frame,
|
||||
unsigned width, unsigned height, unsigned pitch,
|
||||
const char *msg)
|
||||
@ -580,6 +642,26 @@ static bool gx_frame(void *data, const void *frame,
|
||||
GX_DrawDone();
|
||||
}
|
||||
|
||||
if (g_console.fps_info_msg_enable)
|
||||
{
|
||||
static char fps_txt[128];
|
||||
char mem1_txt[128];
|
||||
unsigned x = 15;
|
||||
unsigned y = 15;
|
||||
|
||||
gfx_window_title(fps_txt, sizeof(fps_txt));
|
||||
gx_blit_line(x, y, fps_txt);
|
||||
y += FONT_HEIGHT * 2;
|
||||
snprintf(mem1_txt, sizeof(mem1_txt), "MEM1: %8d / 25165824", SYS_GetArena1Size()); /* 25165824 = 0x01800000 */
|
||||
gx_blit_line(x, y, mem1_txt);
|
||||
#ifdef HW_RVL
|
||||
y += FONT_HEIGHT * 2;
|
||||
char mem2_txt[128];
|
||||
snprintf(mem2_txt, sizeof(mem2_txt), "MEM2: %8d / 67108864", SYS_GetArena2Size()); /* 67108864 = 0x04000000 */
|
||||
gx_blit_line(x, y, mem2_txt);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef TAKE_EFB_SCREENSHOT_ON_EXIT
|
||||
GX_CopyDisp(g_framebuf[g_current_framebuf], GX_FALSE);
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user