fix some random corner cases
authornotaz <notasas@gmail.com>
Tue, 13 Nov 2012 00:28:41 +0000 (02:28 +0200)
committernotaz <notasas@gmail.com>
Tue, 13 Nov 2012 00:28:41 +0000 (02:28 +0200)
frontend/menu.c
plugins/gpulib/gpu.c
plugins/gpulib/vout_pl.c

index ec3c5a2..f77bc9d 100644 (file)
@@ -624,12 +624,18 @@ static void draw_savestate_bg(int slot)
 
        x = gpu->ulControl[5] & 0x3ff;
        y = (gpu->ulControl[5] >> 10) & 0x1ff;
 
        x = gpu->ulControl[5] & 0x3ff;
        y = (gpu->ulControl[5] >> 10) & 0x1ff;
-       s = (u16 *)gpu->psxVRam + y * 1024 + x;
        w = psx_widths[(gpu->ulStatus >> 16) & 7];
        tmp = gpu->ulControl[7];
        h = ((tmp >> 10) & 0x3ff) - (tmp & 0x3ff);
        if (gpu->ulStatus & 0x80000) // doubleheight
                h *= 2;
        w = psx_widths[(gpu->ulStatus >> 16) & 7];
        tmp = gpu->ulControl[7];
        h = ((tmp >> 10) & 0x3ff) - (tmp & 0x3ff);
        if (gpu->ulStatus & 0x80000) // doubleheight
                h *= 2;
+       if (h <= 0 || h > 512)
+               goto out;
+       if (y > 512 - 64)
+               y = 0;
+       if (y + h > 512)
+               h = 512 - y;
+       s = (u16 *)gpu->psxVRam + y * 1024 + x;
 
        x = max(0, g_menuscreen_w - w) & ~3;
        y = max(0, g_menuscreen_h / 2 - h / 2);
 
        x = max(0, g_menuscreen_w - w) & ~3;
        y = max(0, g_menuscreen_h / 2 - h / 2);
index b61bff6..b300c88 100644 (file)
@@ -212,7 +212,7 @@ void GPUwriteStatus(uint32_t data)
       break;
     case 0x05:
       gpu.screen.x = data & 0x3ff;
       break;
     case 0x05:
       gpu.screen.x = data & 0x3ff;
-      gpu.screen.y = (data >> 10) & 0x3ff;
+      gpu.screen.y = (data >> 10) & 0x1ff;
       if (gpu.frameskip.set) {
         decide_frameskip_allow(gpu.ex_regs[3]);
         if (gpu.frameskip.last_flip_frame != *gpu.state.frame_count) {
       if (gpu.frameskip.set) {
         decide_frameskip_allow(gpu.ex_regs[3]);
         if (gpu.frameskip.last_flip_frame != *gpu.state.frame_count) {
index 11307e2..7b229db 100644 (file)
@@ -72,8 +72,8 @@ void vout_update(void)
   if (y + h > vram_h) {
     if (y + h - vram_h > h / 2) {
       // wrap
   if (y + h > vram_h) {
     if (y + h - vram_h > h / 2) {
       // wrap
-      y = 0;
       h -= vram_h - y;
       h -= vram_h - y;
+      y = 0;
     }
     else
       // clip
     }
     else
       // clip