shithub: zelda3

Download patch

ref: 3ce06c541e3cce45b3eaa2d3d10f35865a42c876
parent: 9d083a7864e2ad20b620c9309f899f63d2fda3e8
author: Snesrev <snesrev@protonmail.com>
date: Fri Oct 14 19:11:42 EDT 2022

Old renderer could crash

--- a/snes/ppu.c
+++ b/snes/ppu.c
@@ -189,13 +189,11 @@
       for (int x = 0; x < 256; x++)
         ppu_handlePixel(ppu, x, line);
 
-      uint8 *dst = ppu->renderBuffer + ((line - 1) * 2 * ppu->renderPitch);
-
+      uint8 *dst = ppu->renderBuffer + ((line - 1) * ppu->renderPitch);
       if (ppu->extraLeftRight != 0) {
-        memset(dst, 0, 2 * sizeof(uint32) * ppu->extraLeftRight);
-        memset(dst + 2 * sizeof(uint32) * (256 + ppu->extraLeftRight), 0, 2 * sizeof(uint32) * ppu->extraLeftRight);
+        memset(dst, 0, sizeof(uint32) * ppu->extraLeftRight);
+        memset(dst + sizeof(uint32) * (256 + ppu->extraLeftRight), 0, sizeof(uint32) * ppu->extraLeftRight);
       }
-      memcpy(dst + ppu->renderPitch, dst, 2 * sizeof(uint32) * (256 + ppu->extraLeftRight * 2));
     }
   }
 }