diff options
-rw-r--r-- | frontend/common/menu.c | 6 | ||||
-rw-r--r-- | frontend/menu.c | 74 |
2 files changed, 75 insertions, 5 deletions
diff --git a/frontend/common/menu.c b/frontend/common/menu.c index f7085fa..ae1ff57 100644 --- a/frontend/common/menu.c +++ b/frontend/common/menu.c @@ -653,7 +653,7 @@ static void draw_menu_credits(void (*draw_more)(void)) p++;
}
- x = g_menuscreen_w / 2 - w * me_mfont_w / 2;
+ x = g_menuscreen_w / 2 - w * me_mfont_w / 2;
y = g_menuscreen_h / 2 - h * me_mfont_h / 2;
if (x < 0) x = 0;
if (y < 0) y = 0;
@@ -949,6 +949,10 @@ static void draw_savestate_menu(int menu_sel, int is_loading) if (x < 0) x = 0;
y = g_menuscreen_h / 2 - h / 2;
if (y < 0) y = 0;
+#ifdef MENU_ALIGN_LEFT
+ if (x > 12 + me_mfont_w * 2)
+ x = 12 + me_mfont_w * 2;
+#endif
menu_draw_begin(1);
diff --git a/frontend/menu.c b/frontend/menu.c index e04d19e..9036d5f 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -12,6 +12,7 @@ #include <string.h> #include <errno.h> #include <dlfcn.h> +#include <zlib.h> #include "main.h" #include "menu.h" @@ -128,10 +129,6 @@ static int emu_save_load_game(int load, int sram) return ret; } -static void draw_savestate_bg(int slot) -{ -} - static void menu_set_defconfig(void) { scaling = SCALE_4_3; @@ -389,11 +386,80 @@ static unsigned short fname2color(const char *fname) return 0xffff; } +static void draw_savestate_bg(int slot); + #define MENU_ALIGN_LEFT #define menu_init menu_init_common #include "common/menu.c" #undef menu_init +// a bit of black magic here +static void draw_savestate_bg(int slot) +{ + extern void bgr555_to_rgb565(void *dst, void *src, int bytes); + static const int psx_widths[8] = { 256, 368, 320, 384, 512, 512, 640, 640 }; + int x, y, w, h; + char fname[MAXPATHLEN]; + GPUFreeze_t *gpu; + u16 *s, *d; + gzFile f; + int ret; + u32 tmp; + + ret = get_state_filename(fname, sizeof(fname), slot); + if (ret != 0) + return; + + f = gzopen(fname, "rb"); + if (f == NULL) + return; + + if (gzseek(f, 0x29933d, SEEK_SET) != 0x29933d) { + fprintf(stderr, "gzseek failed\n"); + gzclose(f); + return; + } + + gpu = malloc(sizeof(*gpu)); + if (gpu == NULL) { + gzclose(f); + return; + } + + ret = gzread(f, gpu, sizeof(*gpu)); + gzclose(f); + if (ret != sizeof(*gpu)) { + fprintf(stderr, "gzread failed\n"); + goto out; + } + + memcpy(g_menubg_ptr, g_menubg_src_ptr, g_menuscreen_w * g_menuscreen_h * 2); + + if ((gpu->ulStatus & 0x800000) || (gpu->ulStatus & 0x200000)) + goto out; // disabled || 24bpp (NYET) + + x = gpu->ulControl[5] & 0x3ff; + y = (gpu->ulControl[5] >> 10) & 0x1ff; + s = (u16 *)gpu->psxVRam + y * 1024 + (x & ~3); + w = psx_widths[(gpu->ulStatus >> 16) & 7]; + tmp = gpu->ulControl[7]; + h = ((tmp >> 10) & 0x3ff) - (tmp & 0x3ff); + if (gpu->ulStatus & 0x80000) // doubleheight + h *= 2; + + x = max(0, g_menuscreen_w - w) & ~3; + y = max(0, g_menuscreen_h / 2 - h / 2); + w = min(g_menuscreen_w, w); + h = min(g_menuscreen_h, h); + d = (u16 *)g_menubg_ptr + g_menuscreen_w * y + x; + + for (; h > 0; h--, d += g_menuscreen_w, s += 1024) + bgr555_to_rgb565(d, s, w * 2); + +out: + free(gpu); +} + // ---------- pandora specific ----------- static const char pnd_script_base[] = "sudo -n /usr/pandora/scripts"; |