X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=frontend%2Fmenu.c;h=34b6e362b0ce1116618a43ceea59e7f0bd0c2398;hp=19ad86fdc2a7a3bc0a4dcea10aa8409cddfa3dc6;hb=ee78346e30720ddb3f4c97b6598bdc6dc7257f98;hpb=201c21e2ad6be25a4b843d1434eabb432ce72884 diff --git a/frontend/menu.c b/frontend/menu.c index 19ad86fd..34b6e362 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -12,14 +12,15 @@ #include #include #include +#include +#include "main.h" #include "menu.h" #include "config.h" #include "plugin.h" #include "plugin_lib.h" #include "omap.h" #include "common/plat.h" -#include "../gui/Linux.h" #include "../libpcsxcore/misc.h" #include "../libpcsxcore/new_dynarec/new_dynarec.h" #include "revision.h" @@ -57,7 +58,6 @@ enum { SCALE_CUSTOM, }; -extern int ready_to_go; static int last_psx_w, last_psx_h, last_psx_bpp; static int scaling, filter, state_slot, cpu_clock, cpu_clock_st; static char rom_fname_reload[MAXPATHLEN]; @@ -101,40 +101,34 @@ void emu_make_path(char *buff, const char *end, int size) static int emu_check_save_file(int slot) { - char *fname; + char fname[MAXPATHLEN]; int ret; - fname = get_state_filename(slot); - if (fname == NULL) + ret = get_state_filename(fname, sizeof(fname), slot); + if (ret != 0) return 0; ret = CheckState(fname); - free(fname); return ret == 0 ? 1 : 0; } static int emu_save_load_game(int load, int sram) { - char *fname; + char fname[MAXPATHLEN]; int ret; - fname = get_state_filename(state_slot); - if (fname == NULL) + ret = get_state_filename(fname, sizeof(fname), state_slot); + if (ret != 0) return 0; if (load) ret = LoadState(fname); else ret = SaveState(fname); - free(fname); return ret; } -static void draw_savestate_bg(int slot) -{ -} - static void menu_set_defconfig(void) { scaling = SCALE_4_3; @@ -392,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"; @@ -902,7 +965,9 @@ const char *plat_get_credits(void) "(C) 2009-2010 PCSX-Reloaded Team\n\n" "GPU and SPU code by Pete Bernert\n" " and the P.E.Op.S. team\n" - "ARM recompiler (C) 2009-2010 Ari64\n\n" + "ARM recompiler (C) 2009-2010 Ari64\n" + "PCSX4ALL plugins by PCSX4ALL team\n" + " Chui, Franxis, Unai\n\n" "integration, optimization and\n" " frontend (C) 2010-2011 notaz\n"; } @@ -1225,7 +1290,6 @@ void menu_prepare_emu(void) } if (GPU_open != NULL) { - extern unsigned long gpuDisp; int ret = GPU_open(&gpuDisp, "PCSX", NULL); if (ret) fprintf(stderr, "Warning: GPU_open returned %d\n", ret);