From 9178dab7dd33e9a2ed6649ef282ca44b5edd431e Mon Sep 17 00:00:00 2001 From: Sergey Stepanov Date: Mon, 3 Apr 2023 20:39:49 +0300 Subject: [PATCH] Fix N64 overlapping frame draw --- pkg/worker/emulator/libretro/nanoarch.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/worker/emulator/libretro/nanoarch.go b/pkg/worker/emulator/libretro/nanoarch.go index b61e4ed1..101f7207 100644 --- a/pkg/worker/emulator/libretro/nanoarch.go +++ b/pkg/worker/emulator/libretro/nanoarch.go @@ -131,7 +131,7 @@ func coreVideoRefresh(data unsafe.Pointer, width, height uint, packed uint) { // calculate real frame width in pixels from packed data (realWidth >= width) // some cores or games output zero pitch, i.e. N64 Mupen if packed == 0 { - packed = width + packed = width * nano.v.bpp } // calculate space for the video frame bytes := packed * height @@ -152,6 +152,8 @@ func coreVideoRefresh(data unsafe.Pointer, width, height uint, packed uint) { if fr == nil { fr = &emulator.GameFrame{} } + // !to fix possible nil pointer dereference + // when the internal pool can be nil during first Get??? fr.Data = frontend.canvas. Draw(nano.v.pixFmt, nano.rot, int(width), int(height), int(packed), int(nano.v.bpp), data_, frontend.th) fr.Duration = time.Duration(dt)