Attempt to blindly fix MacOS.

This commit is contained in:
BearOso 2022-04-10 18:16:16 -05:00
parent a953721967
commit 568991681d
1 changed files with 8 additions and 41 deletions

View File

@ -38,11 +38,6 @@ static void S9xInitMetal (void);
static void S9xDeinitMetal(void);
static void S9xPutImageMetal (int, int, uint16 *);
static uint16 *gfxScreen[2],
*snesScreenA,
*snesScreenB;
static uint8 *blitGLBuffer;
static int whichBuf = 0;
static int textureNum = 0;
static int prevBlitWidth, prevBlitHeight;
@ -75,21 +70,6 @@ id<MTLRenderPipelineState> metalPipelineState = nil;
void InitGraphics (void)
{
int safemarginbytes = (520 * 520 - 512 * 512) * 2;
snesScreenA = (uint16 *) calloc( 520 * 520 * 2, 1);
snesScreenB = (uint16 *) calloc( 520 * 520 * 2, 1);
blitGLBuffer = (uint8 *) calloc(1024 * 1024 * 2, 1);
gfxScreen[0] = snesScreenA + (safemarginbytes >> 2);
gfxScreen[1] = snesScreenB + (safemarginbytes >> 2);
GFX.Pitch = 512 * 2;
GFX.Screen = gfxScreen[0];
if (!snesScreenA || !snesScreenB || !blitGLBuffer)
QuitWithFatalError(@"render 01");
if (!S9xBlitFilterInit() |
!S9xBlit2xSaIFilterInit() |
!S9xBlitHQ2xFilterInit() |
@ -127,24 +107,6 @@ void DeinitGraphics (void)
S9xBlitHQ2xFilterDeinit();
S9xBlit2xSaIFilterDeinit();
S9xBlitFilterDeinit();
if (snesScreenA)
{
free(snesScreenA);
snesScreenA = NULL;
}
if (snesScreenB)
{
free(snesScreenB);
snesScreenB = NULL;
}
if (blitGLBuffer)
{
free(blitGLBuffer);
blitGLBuffer = NULL;
}
}
void DrawFreezeDefrostScreen (uint8 *draw)
@ -210,7 +172,6 @@ void S9xInitDisplay (int argc, char **argv)
imageWidth[0] = imageHeight[0] = 0;
imageWidth[1] = imageHeight[1] = 0;
prevBlitWidth = prevBlitHeight = 0;
GFX.Screen = gfxScreen[0];
whichBuf = 0;
textureNum = 0;
@ -310,7 +271,14 @@ void S9xPutImage (int width, int height)
static void S9xPutImageMetal (int width, int height, uint16 *buffer16)
{
uint8 *buffer = (uint8 *)malloc(width * height * 4);
static uint8 *buffer = nil;
static int buffer_size = 0;
if (buffer_size != width * height * 4)
{
buffer = realloc(buffer, width * height * 4);
}
for (int i = 0; i < width * height; ++i)
{
uint16 pixel = buffer16[i];
@ -339,7 +307,6 @@ static void S9xPutImageMetal (int width, int height, uint16 *buffer16)
metalTexture = [metalDevice newTextureWithDescriptor:textureDescriptor];
[metalTexture replaceRegion:MTLRegionMake2D(0, 0, width, height) mipmapLevel:0 withBytes:buffer bytesPerRow:width * 4];
free(buffer);
float vWidth = layerSize.width / 2.0;
float vHeight = layerSize.height / 2.0;