Fixed CPSIII video rendering

This commit is contained in:
Akop Karapetyan 2019-10-22 09:12:16 -07:00 committed by tmaul
parent 204c3d28ad
commit b461a0e61a
4 changed files with 34 additions and 26 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@ joyconfig
fbneo.ini
xcuserdata
project.xcworkspace
projectfiles/xcode/build

View File

@ -11,14 +11,12 @@ use `File/Open` and `File/Open Recent`. ROMs can reside anywhere, though if you
load a game that requires other sets (e.g. Neo-Geo), the supplementary ROMs are
expected to be in the same directory. Supported archives are `zip` and `7z`.
Error display is fairly rudimentary at the moment - if you're wondering why a
set failed to load, launch the macOS Console app and filter by app name.
Error display is fairly rudimentary - if you're wondering why a set failed to load,
launch the macOS Console app and filter by process name.
## Input
Only input device currently supported is the keyboard, using standard FinalBurn layout.
## Known issues
* CPS3 titles - and perhaps others - will not render at the moment. There's sound
and the keys work, but no video. This must be fixed.
* Joysticks/mice are currently unsupported
* Error display is exceptionally spartan at the moment, and needs improvement

View File

@ -39,6 +39,7 @@
NSPoint _lastCursorPosition;
NSTrackingArea *_trackingArea;
NSRect viewBounds; // Access from non-UI thread
GLint textureFormat;
}
#pragma mark - Initialize, Dealloc
@ -70,7 +71,7 @@
// Synchronize buffer swaps with vertical refresh rate
GLint swapInt = 1;
[[self openGLContext] setValues:&swapInt
[self.openGLContext setValues:&swapInt
forParameter:NSOpenGLCPSwapInterval];
glClearColor(0, 0, 0, 1.0);
@ -85,8 +86,7 @@
{
[renderLock lock];
NSOpenGLContext *nsContext = [self openGLContext];
[nsContext makeCurrentContext];
[self.openGLContext makeCurrentContext];
glClear(GL_COLOR_BUFFER_BIT);
@ -112,7 +112,7 @@
glEnd();
glDisable(GL_TEXTURE_2D);
[nsContext flushBuffer];
[self.openGLContext flushBuffer];
[renderLock unlock];
}
@ -122,8 +122,8 @@
viewBounds = [self bounds];
[renderLock lock];
[[self openGLContext] makeCurrentContext];
[[self openGLContext] update];
[self.openGLContext makeCurrentContext];
[self.openGLContext update];
[self resetProjection];
@ -144,8 +144,7 @@
[renderLock lock];
NSOpenGLContext *nsContext = [self openGLContext];
[nsContext makeCurrentContext];
[self.openGLContext makeCurrentContext];
free(texture);
@ -157,6 +156,7 @@
textureHeight = [FBScreenView powerOfTwoClosestTo:imageHeight];
textureBytesPerPixel = bytesPerPixel;
screenSize = NSMakeSize((CGFloat)width, (CGFloat)height);
textureFormat = GL_UNSIGNED_SHORT_5_6_5;
int texSize = textureWidth * textureHeight * bytesPerPixel;
texture = (unsigned char *) malloc(texSize);
@ -170,9 +170,9 @@
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, bytesPerPixel,
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
textureWidth, textureHeight,
0, GL_BGR, GL_UNSIGNED_BYTE, texture);
0, GL_RGB, textureFormat, texture);
glDisable(GL_TEXTURE_2D);
@ -195,8 +195,7 @@
[renderLock lock];
NSOpenGLContext *nsContext = [self openGLContext];
[nsContext makeCurrentContext];
[self.openGLContext makeCurrentContext];
glClear(GL_COLOR_BUFFER_BIT);
@ -207,12 +206,20 @@
glBindTexture(GL_TEXTURE_2D, screenTextureId);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
for (int y = 0; y < imageHeight; y += 1) {
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, y, imageWidth, 1,
GL_BGR, GL_UNSIGNED_BYTE,
bitmap + y * imageWidth * textureBytesPerPixel);
unsigned char *ps = (unsigned char *) bitmap;
unsigned char *pd = (unsigned char *) texture;
int bitmapPitch = imageWidth * textureBytesPerPixel;
int texturePitch = textureWidth * textureBytesPerPixel;
for (int y = imageHeight; y--; ) {
memcpy(pd, ps, bitmapPitch);
pd += texturePitch;
ps += bitmapPitch;
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, textureWidth, textureHeight, 0,
GL_RGB, textureFormat, texture);
NSSize size = viewBounds.size;
CGFloat offset = 0;
@ -228,7 +235,7 @@
glEnd();
glDisable(GL_TEXTURE_2D);
[nsContext flushBuffer];
[self.openGLContext flushBuffer];
[renderLock unlock];
}

View File

@ -60,6 +60,8 @@
});
}
#pragma mark - Public
- (NSSize) gameScreenSize
{
if (nBurnDrvActive == ~0U)
@ -98,8 +100,8 @@ static int MacOSVideoInit()
nVidImageWidth = gameWidth;
nVidImageHeight = gameHeight;
nVidImageDepth = 24;
nVidImageBPP = 3;
nVidImageDepth = 16;
nVidImageBPP = nVidImageDepth / 8;
if (!rotationMode) {
nVidImagePitch = nVidImageWidth * nVidImageBPP;
} else {