From 50b3872ddbe6b925155ff5657670f73dc36b2c6d Mon Sep 17 00:00:00 2001 From: Mauro Vietri Date: Sat, 18 May 2024 11:20:01 -0300 Subject: [PATCH] fix clock on main menu regression and updates gpsp core --- cores/makefile | 4 ++-- src/common/api.c | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/cores/makefile b/cores/makefile index 924aeb2..14f9d01 100644 --- a/cores/makefile +++ b/cores/makefile @@ -27,12 +27,12 @@ fceumm_REPO = https://github.com/libretro/libretro-fceumm gambatte_REPO = https://github.com/libretro/gambatte-libretro -gpsp_HASH = 1d1c719 # last known working save states +gpsp_HASH = 8745bf3 # last known working save states mednafen_supafaust_REPO = https://github.com/libretro/supafaust pcsx_rearmed_MAKEFILE = Makefile.libretro -pcsx_rearmed_HASH = 672e715 # e2fb138 # last known working build +pcsx_rearmed_HASH = 672e715 # last known working build picodrive_REPO = https://github.com/irixxxx/picodrive picodrive_MAKEFILE = Makefile.libretro diff --git a/src/common/api.c b/src/common/api.c index ef7a430..212cbed 100644 --- a/src/common/api.c +++ b/src/common/api.c @@ -694,7 +694,7 @@ void GFX_blitRect(int asset, SDL_Surface* dst, SDL_Rect* dst_rect) { SDL_FillRect(dst, &(SDL_Rect){x+r,y+h-r,w-d,r}, c); GFX_blitAsset(asset, &(SDL_Rect){r,r,r,r}, dst, &(SDL_Rect){x+w-r,y+h-r}); } -void GFX_blitBattery(SDL_Surface* dst, SDL_Rect* dst_rect) { +void GFX_blitClockAndBattery(SDL_Surface* dst, SDL_Rect* dst_rect) { // LOG_info("dst: %p\n", dst); if (!dst_rect) dst_rect = &(SDL_Rect){0,0,0,0}; @@ -722,7 +722,20 @@ void GFX_blitBattery(SDL_Surface* dst, SDL_Rect* dst_rect) { clip.y = 0; GFX_blitAsset(percent<=20?ASSET_BATTERY_FILL_LOW:ASSET_BATTERY_FILL, &clip, dst, &(SDL_Rect){x+SCALE1(3)+clip.x,y+SCALE1(2)}); - } + } + + // Get the current time + time_t currentTime = time(NULL); + struct tm* timeinfo = localtime(¤tTime); + int hours = timeinfo->tm_hour; + int minutes = timeinfo->tm_min; + + // Convert hours and minutes to strings + char timeStr[6]; + snprintf(timeStr, sizeof(timeStr), "%02d:%02d", hours, minutes); + SDL_Surface* text = TTF_RenderUTF8_Blended(font.large, timeStr, COLOR_WHITE); + SDL_BlitSurface(text, NULL, dst, &(SDL_Rect){dst_rect->x - text->w - 20, dst_rect->y + (SCALE1(PILL_SIZE) - text->h) / 2}); + SDL_FreeSurface(text); } int GFX_getButtonWidth(char* hint, char* button) { int button_width = 0; @@ -889,7 +902,7 @@ int GFX_blitHardwareGroup(SDL_Surface* dst, int show_setting) { ow, SCALE1(PILL_SIZE) }); - GFX_blitBattery(dst, &(SDL_Rect){ox,oy}); + GFX_blitClockAndBattery(dst, &(SDL_Rect){ox,oy}); } return ow; @@ -1348,7 +1361,7 @@ static void POW_initOverlay(void) { SDL_SetAlpha(gfx.assets, 0,0); GFX_blitAsset(ASSET_BLACK_PILL, NULL, pow.overlay, NULL); SDL_SetAlpha(gfx.assets, SDL_SRCALPHA,0); - GFX_blitBattery(pow.overlay, NULL); + GFX_blitClockAndBattery(pow.overlay, NULL); // setup overlay memset(&pow.oargs, 0, sizeof(struct owlfb_overlay_args));