aboutsummaryrefslogtreecommitdiff
path: root/plat_sdl.c
diff options
context:
space:
mode:
authorneonloop2021-08-21 00:10:44 +0000
committerneonloop2021-08-21 00:10:44 +0000
commit41fff233f29b6ee7274f4bf525052dcf0fa56c00 (patch)
treecfcc8fc9ae57b694d353cba8752a1f8fd99dc78e /plat_sdl.c
parentf89bcd0179f4e07fe403894053c624d4983090c3 (diff)
downloadpicoarch-41fff233f29b6ee7274f4bf525052dcf0fa56c00.tar.gz
picoarch-41fff233f29b6ee7274f4bf525052dcf0fa56c00.tar.bz2
picoarch-41fff233f29b6ee7274f4bf525052dcf0fa56c00.zip
Updates message display and adds loading message to pcsx
Diffstat (limited to 'plat_sdl.c')
-rw-r--r--plat_sdl.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/plat_sdl.c b/plat_sdl.c
index 395227a..e4d2c1f 100644
--- a/plat_sdl.c
+++ b/plat_sdl.c
@@ -5,6 +5,7 @@
#include "menu.h"
#include "plat.h"
#include "scale.h"
+#include "util.h"
static SDL_Surface* screen;
@@ -22,6 +23,21 @@ struct audio_state {
struct audio_state audio;
static char msg[HUD_LEN];
+static unsigned msg_priority = 0;
+static unsigned msg_expire = 0;
+
+static void video_expire_msg(void)
+{
+ msg[0] = '\0';
+ msg_priority = 0;
+ msg_expire = 0;
+}
+
+static void video_update_msg(void)
+{
+ if (msg[0] && msg_expire < plat_get_ticks_ms())
+ video_expire_msg();
+}
static void video_clear_msg(uint16_t *dst, uint32_t h, uint32_t pitch)
{
@@ -169,29 +185,42 @@ void plat_video_open(void)
{
}
-void plat_video_set_msg(const char *new_msg)
+void plat_video_set_msg(const char *new_msg, unsigned priority, unsigned msec)
{
- snprintf(msg, HUD_LEN, "%s", new_msg);
+ if (!new_msg) {
+ video_expire_msg();
+ } else if (priority >= msg_priority) {
+ snprintf(msg, HUD_LEN, "%s", new_msg);
+ string_truncate(msg, HUD_LEN - 1);
+ msg_priority = priority;
+ msg_expire = plat_get_ticks_ms() + msec;
+ }
}
void plat_video_process(const void *data, unsigned width, unsigned height, size_t pitch) {
+ static int had_msg = 0;
SDL_LockSurface(screen);
- if (msg[0])
+ if (had_msg) {
video_clear_msg(screen->pixels, screen->h, screen->pitch / SCREEN_BPP);
+ had_msg = 0;
+ }
scale(width, height, pitch, data, screen->pixels);
- if (msg[0])
+ if (msg[0]) {
video_print_msg(screen->pixels, screen->h, screen->pitch / SCREEN_BPP, msg);
+ had_msg = 1;
+ }
SDL_UnlockSurface(screen);
+
+ video_update_msg();
}
void plat_video_flip(void)
{
fb_flip();
- msg[0] = 0;
}
void plat_video_close(void)