Skip to content

Commit

Permalink
Fix hardware scaling for games when width adjusted by gcd is greater
Browse files Browse the repository at this point in the history
than the driver's width.
MetalSlug have a resolution 304x224 but is 320x224 adjusted for RG350M.
  • Loading branch information
plrguez committed Oct 18, 2021
1 parent 5968618 commit 9448a9c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/sdl-dingux/sdl_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2030,7 +2030,15 @@ int VideoInit()
if (hwscale > 0) {
int bVideoBufferWidth, bVideoBufferHeight;
BurnDrvGetFullSize(&bVideoBufferWidth, &bVideoBufferHeight);
if (bVideoBufferWidth < VideoBufferWidth) bVideoBufferWidth = VideoBufferWidth;
// If resolution adjusted by gcd for hardware scaling is greater than defined in driver
// adjust width and pitch to correct operation of blit functions
// (MetalSlug have a resolution 304x224 but is 320x224 adjusted for RG350M)
if (bVideoBufferWidth < VideoBufferWidth) {
int temp = bVideoBufferWidth;
bVideoBufferWidth = VideoBufferWidth;
VideoBufferWidth = temp;
nBurnPitch = VideoBufferWidth * 2;
}
if (bVideoBufferHeight < VideoBufferHeight) bVideoBufferHeight = VideoBufferHeight;
BurnVideoBuffer = (unsigned short *)malloc(bVideoBufferWidth * bVideoBufferHeight * 2);
memset(BurnVideoBuffer, 0, bVideoBufferWidth * bVideoBufferHeight * 2);
Expand Down Expand Up @@ -2081,7 +2089,10 @@ int VideoInit()
}
break;
}
p_offset = 0;
if (VideoBufferWidth < screen->w)
p_offset = ( screen->w - VideoBufferWidth ) >> 1;
else
p_offset = 0;
r_offset = 0;
q_offset = VideoBufferWidth*VideoBufferHeight-1;
} else {
Expand Down

0 comments on commit 9448a9c

Please sign in to comment.