From 61bab3cc790c608a894319fb5d77e4ca3fd090de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Luis=20Rodr=C3=ADguez=20Gonz=C3=A1lez?= Date: Mon, 9 Aug 2021 23:13:40 +0200 Subject: [PATCH] Adjust the buffer size keeping in mind that the screen size may have been adjusted by the gcd calculation. This fix the problem with the 256x246 resolutions adjusted to 256x24 by the gcd. --- src/sdl-dingux/sdl_video.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/sdl-dingux/sdl_video.cpp b/src/sdl-dingux/sdl_video.cpp index f488267bf..4c55c0c1c 100644 --- a/src/sdl-dingux/sdl_video.cpp +++ b/src/sdl-dingux/sdl_video.cpp @@ -1958,10 +1958,6 @@ int VideoInit() VideoBufferWidth = gcd(VideoBufferWidth, modes[0]->w); VideoBufferHeight = gcd(VideoBufferHeight, modes[0]->h); } - - /* TODO: Kung fu Master This must be valid but for now it fails in OD Beta 20210809 */ - if (VideoBufferWidth == 256 && VideoBufferHeight == 240) - VideoBufferHeight = 256; if (hwscale == 1) //Aspect setenv("SDL_VIDEO_KMSDRM_SCALING_MODE", "1", 1); @@ -2023,9 +2019,22 @@ int VideoInit() nBurnPitch = VideoBufferWidth * 2; PhysicalBufferWidth = screen->w; +#ifdef DEVICE_GCW0 + /* If resolution adjusted by gcd for hardware scaling is lesser than original */ + /* then adjust the buffer size */ + if (hwscale > 0) { + int bVideoBufferWidth, bVideoBufferHeight; + BurnDrvGetFullSize(&bVideoBufferWidth, &bVideoBufferHeight); + if (bVideoBufferWidth < VideoBufferWidth) bVideoBufferWidth = VideoBufferWidth; + if (bVideoBufferHeight < VideoBufferHeight) bVideoBufferHeight = VideoBufferHeight; + BurnVideoBuffer = (unsigned short *)malloc(bVideoBufferWidth * bVideoBufferHeight * 2); + memset(BurnVideoBuffer, 0, bVideoBufferWidth * bVideoBufferHeight * 2); + } else { +#endif BurnVideoBuffer = (unsigned short *)malloc(VideoBufferWidth * VideoBufferHeight * 2); memset(BurnVideoBuffer, 0, VideoBufferWidth * VideoBufferHeight * 2); #ifdef DEVICE_GCW0 + } #endif #ifdef DEVICE_GCW0