21 Commits

Author SHA1 Message Date
C.W. Betts 3fe5b1a41d Don't build fmemopen and open_memstream if targeting macOS versions 10.13 or above.
This is currently limited to 11.0 on Apple Silicon.
2021-01-16 15:27:31 -07:00
C.W. Betts da07e7e466 Xcode project maintenance. 2021-01-16 15:00:38 -07:00
C.W. Betts 0f0245743f Also use native open_memstream if available. 2021-01-15 14:52:30 -07:00
C.W. Betts 137232a50d Poke the plists: get the development language from Xcode build. 2020-10-01 01:51:38 -06:00
C.W. Betts d891dc75e4 Fix locations of the system plugin headers.
Minor Xcode maintenance.
2020-10-01 01:26:42 -06:00
C.W. Betts 89ac34677d Update language resources.
This quiets warnings in newer Xcode releases.

Also update framework locations.
2020-01-07 16:34:56 -07:00
clobber a25c7277cd Merge pull request #2 from MaddTheSane/updateFmem
Use Mac OS X's native fmemopen if present.
2018-03-26 12:38:28 -05:00
C.W. Betts 78cdb9a493 Use Mac OS X's native fmemopen if present. 2018-03-24 14:03:48 -06:00
clobber d47ffbc5ec Bump version for sparkle updater. Core is still r268 2017-12-17 21:51:48 -06:00
clobber 85a75b3ec7 Remove support for SMS, GG, SG-1000. This will be ColecoVision only. 2017-10-28 23:18:36 -05:00
clobber 97f3d66a9d Clean up input handling. 2017-10-20 21:21:58 -05:00
clobber dab27bf1d2 Update SG-1000 input for API change. 2017-10-20 20:53:53 -05:00
clobber 955658e547 Use -fileSystemRepresentation instead of -UTF8String for file names 2017-08-16 23:38:21 -05:00
clobber c614a91a1f Enable direct-rendering 2017-07-21 14:56:40 -05:00
clobber f6f74109be Clean up after commit a7ad4d21cf 2017-07-20 17:02:17 -05:00
clobber a7ad4d21cf Use proper API for video output 2017-07-20 16:35:35 -05:00
Rudy Richter 944d9954bb Use spaces 2017-07-20 08:50:18 -04:00
mrvacbob 4274fa8510 Remove internalPixelFormat 2017-07-20 01:12:25 -07:00
clobber f8c7919cdf Remove unneeded "deployment location" project file setting 2016-09-23 19:54:45 -05:00
clobber c3db984ef7 Update to CrabEmu r268 2016-09-06 01:15:04 -05:00
clobber f0ebea6655 Update to CrabEmu r265 2016-09-04 22:43:37 -05:00
15 changed files with 2193 additions and 2487 deletions
+26 -26
View File
@@ -35,7 +35,7 @@
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
1B46D09D14293CAD0025EF88 /* libz.1.2.5.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B46D09C14293CAD0025EF88 /* libz.1.2.5.dylib */; };
1B46D09D14293CAD0025EF88 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B46D09C14293CAD0025EF88 /* libz.tbd */; };
27E3D4E41B6543BC00D8D8B5 /* fmemopen.c in Sources */ = {isa = PBXBuildFile; fileRef = 27E3D4E21B6543BC00D8D8B5 /* fmemopen.c */; };
27E3D4E71B6543D500D8D8B5 /* open_memstream.c in Sources */ = {isa = PBXBuildFile; fileRef = 27E3D4E51B6543D500D8D8B5 /* open_memstream.c */; };
3720DB4D0F19510D00744A9A /* CrabEmu.icns in Resources */ = {isa = PBXBuildFile; fileRef = 3720DB4C0F19510D00744A9A /* CrabEmu.icns */; };
@@ -120,17 +120,17 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
1B46D09C14293CAD0025EF88 /* libz.1.2.5.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.1.2.5.dylib; path = usr/lib/libz.1.2.5.dylib; sourceTree = SDKROOT; };
27E3D4E21B6543BC00D8D8B5 /* fmemopen.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = fmemopen.c; path = fmemopen/fmemopen.c; sourceTree = "<group>"; };
27E3D4E31B6543BC00D8D8B5 /* fmemopen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = fmemopen.h; path = fmemopen/fmemopen.h; sourceTree = "<group>"; };
27E3D4E51B6543D500D8D8B5 /* open_memstream.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = open_memstream.c; path = fmemopen/open_memstream.c; sourceTree = "<group>"; };
27E3D4E61B6543D500D8D8B5 /* open_memstream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = open_memstream.h; path = fmemopen/open_memstream.h; sourceTree = "<group>"; };
089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
089C167EFE841241C02AAC07 /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
1B46D09C14293CAD0025EF88 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
27E3D4E21B6543BC00D8D8B5 /* fmemopen.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fmemopen.c; sourceTree = "<group>"; };
27E3D4E31B6543BC00D8D8B5 /* fmemopen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fmemopen.h; sourceTree = "<group>"; };
27E3D4E51B6543D500D8D8B5 /* open_memstream.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = open_memstream.c; sourceTree = "<group>"; };
27E3D4E61B6543D500D8D8B5 /* open_memstream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = open_memstream.h; sourceTree = "<group>"; };
3720DB4C0F19510D00744A9A /* CrabEmu.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = CrabEmu.icns; sourceTree = "<group>"; };
8291C4E21489595000A72540 /* OEGGSystemResponderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OEGGSystemResponderClient.h; path = ../OpenEmu/GameGear/OEGGSystemResponderClient.h; sourceTree = "<group>"; };
8291C4E21489595000A72540 /* OEGGSystemResponderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OEGGSystemResponderClient.h; path = ../OpenEmu/SystemPlugins/GameGear/OEGGSystemResponderClient.h; sourceTree = "<group>"; };
878700D11B674AB3006841C9 /* queue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = queue.h; path = utils/queue.h; sourceTree = "<group>"; };
878700DA1B675E9C006841C9 /* chip8.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = chip8.c; path = chip8/chip8.c; sourceTree = "<group>"; };
878700DB1B675E9C006841C9 /* chip8.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = chip8.h; path = chip8/chip8.h; sourceTree = "<group>"; };
@@ -251,14 +251,14 @@
9443D4371715F33C00E452AC /* ym2413.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ym2413.h; sourceTree = "<group>"; };
9443D45B1715F67D00E452AC /* rom.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rom.c; sourceTree = "<group>"; };
9443D45C1715F67D00E452AC /* rom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rom.h; sourceTree = "<group>"; };
946C18AF171491B300C64BF9 /* OESG1000SystemResponderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OESG1000SystemResponderClient.h; path = "../OpenEmu/SG-1000/OESG1000SystemResponderClient.h"; sourceTree = "<group>"; };
94BE9E79171695AE00AB08E6 /* OEColecoVisionSystemResponderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OEColecoVisionSystemResponderClient.h; path = ../OpenEmu/ColecoVision/OEColecoVisionSystemResponderClient.h; sourceTree = "<group>"; };
946C18AF171491B300C64BF9 /* OESG1000SystemResponderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OESG1000SystemResponderClient.h; path = "../OpenEmu/SystemPlugins/SG-1000/OESG1000SystemResponderClient.h"; sourceTree = "<group>"; };
94BE9E79171695AE00AB08E6 /* OEColecoVisionSystemResponderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OEColecoVisionSystemResponderClient.h; path = ../OpenEmu/SystemPlugins/ColecoVision/OEColecoVisionSystemResponderClient.h; sourceTree = "<group>"; };
B5DA7D8C0F5B28940008F047 /* CrabEmu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrabEmu.h; sourceTree = "<group>"; };
C66DFC180F51D82F0080AA28 /* SMSGameCore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SMSGameCore.m; sourceTree = "<group>"; };
C66DFC190F51D82F0080AA28 /* SMSGameCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SMSGameCore.h; sourceTree = "<group>"; };
C6B3E67C1365255700D34947 /* OESMSSystemResponderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OESMSSystemResponderClient.h; path = ../OpenEmu/SegaMasterSystem/OESMSSystemResponderClient.h; sourceTree = "<group>"; };
C6B3E67C1365255700D34947 /* OESMSSystemResponderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OESMSSystemResponderClient.h; path = ../OpenEmu/SystemPlugins/SegaMasterSystem/OESMSSystemResponderClient.h; sourceTree = "<group>"; };
C6D120E71711302600E868A8 /* OpenEmuBase.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = OpenEmuBase.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -268,7 +268,7 @@
files = (
C6D120E91711302600E868A8 /* OpenEmuBase.framework in Frameworks */,
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */,
1B46D09D14293CAD0025EF88 /* libz.1.2.5.dylib in Frameworks */,
1B46D09D14293CAD0025EF88 /* libz.tbd in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -281,20 +281,21 @@
08FB77AFFE84173DC02AAC07 /* Classes */,
32C88E010371C26100C91783 /* Other Sources */,
089C167CFE841241C02AAC07 /* Resources */,
089C1671FE841209C02AAC07 /* Frameworks and Libraries */,
089C1671FE841209C02AAC07 /* Frameworks */,
19C28FB8FE9D52D311CA2CBB /* Products */,
);
name = CrabEmu;
sourceTree = "<group>";
usesTabs = 0;
};
089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = {
089C1671FE841209C02AAC07 /* Frameworks */ = {
isa = PBXGroup;
children = (
C6D120E71711302600E868A8 /* OpenEmuBase.framework */,
1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */,
1058C7AEFEA557BF11CA2CBB /* Other Frameworks */,
);
name = "Frameworks and Libraries";
name = Frameworks;
sourceTree = "<group>";
};
089C167CFE841241C02AAC07 /* Resources */ = {
@@ -323,7 +324,7 @@
1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
1B46D09C14293CAD0025EF88 /* libz.1.2.5.dylib */,
1B46D09C14293CAD0025EF88 /* libz.tbd */,
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */,
);
name = "Linked Frameworks";
@@ -355,7 +356,7 @@
27E3D4E51B6543D500D8D8B5 /* open_memstream.c */,
27E3D4E61B6543D500D8D8B5 /* open_memstream.h */,
);
name = fmemopen;
path = fmemopen;
sourceTree = "<group>";
};
32C88E010371C26100C91783 /* Other Sources */ = {
@@ -624,12 +625,11 @@
089C1669FE841209C02AAC07 /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 0700;
};
buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "CrabEmu" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 1;
knownRegions = (
en,
@@ -762,7 +762,7 @@
089C167DFE841241C02AAC07 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
089C167EFE841241C02AAC07 /* English */,
089C167EFE841241C02AAC07 /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
@@ -827,7 +827,6 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEPLOYMENT_LOCATION = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
@@ -844,6 +843,7 @@
HEADER_SEARCH_PATHS = "";
INSTALL_PATH = "$(HOME)/Library/Bundles";
MACOSX_DEPLOYMENT_TARGET = 10.11;
"MACOSX_DEPLOYMENT_TARGET[arch=arm64]" = 11.0;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
"-DCRABZ80_NO_READMAP_FALLBACK",
@@ -868,7 +868,6 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEPLOYMENT_LOCATION = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
@@ -885,6 +884,7 @@
HEADER_SEARCH_PATHS = "";
INSTALL_PATH = "$(HOME)/Library/Bundles";
MACOSX_DEPLOYMENT_TARGET = 10.11;
"MACOSX_DEPLOYMENT_TARGET[arch=arm64]" = 11.0;
OTHER_CFLAGS = (
"-DCRABZ80_NO_READMAP_FALLBACK",
"-DIN_CRABEMU",
Binary file not shown.
+2 -5
View File
@@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
@@ -17,7 +17,7 @@
<key>CFBundleSignature</key>
<string>OpEm</string>
<key>CFBundleVersion</key>
<string>0.2.1.261</string>
<string>0.2.1.269</string>
<key>NSPrincipalClass</key>
<string>OEGameCoreController</string>
<key>OEGameCoreClass</key>
@@ -90,9 +90,6 @@
<string>http://crabemu.sourceforge.net/</string>
<key>OESystemIdentifiers</key>
<array>
<string>openemu.system.sms</string>
<string>openemu.system.gg</string>
<string>openemu.system.sg1000</string>
<string>openemu.system.colecovision</string>
</array>
<key>SUEnableAutomaticChecks</key>
+33 -127
View File
@@ -43,22 +43,20 @@
#include "cheats.h"
#include "console.h"
#if MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_13
#include "fmemopen/fmemopen.h"
#include "fmemopen/open_memstream.h"
#endif
#define SAMPLERATE 44100
@interface SMSGameCore () <OESMSSystemResponderClient, OEGGSystemResponderClient, OESG1000SystemResponderClient, OEColecoVisionSystemResponderClient>
{
unsigned char *tempBuffer;
NSLock *bufLock;
BOOL paused;
NSURL *romFile;
NSMutableDictionary *cheatList;
}
- (int)crabButtonForButton:(OESMSButton)button player:(NSUInteger)player;
- (int)crabButtonForSG1000Button:(OESG1000Button)button;
- (int)crabButtonForColecoVisionButton:(OEColecoVisionButton)button player:(NSUInteger)player;
@end
@implementation SMSGameCore
@@ -73,7 +71,6 @@ console_t *cur_console;
if(self != nil)
{
bufLock = [[NSLock alloc] init];
tempBuffer = malloc(256 * 256 * 4);
cheatList = [[NSMutableDictionary alloc] init];
ringBuffer = [self ringBufferAtIndex:0];
}
@@ -83,7 +80,6 @@ console_t *cur_console;
- (void)dealloc
{
DLog(@"releasing/deallocating CrabEmu memory");
free(tempBuffer);
cur_console->shutdown();
}
@@ -93,15 +89,15 @@ console_t *cur_console;
- (BOOL)loadFileAtPath:(NSString *)path error:(NSError **)error
{
romFile = [NSURL fileURLWithPath:path];
int console = rom_detect_console([path UTF8String]);
int console = rom_detect_console(path.fileSystemRepresentation);
DLog(@"Loaded File");
//TODO: add choice NTSC/PAL
if(console == CONSOLE_COLECOVISION)
{
NSString *biosPath = [[self biosDirectoryPath] stringByAppendingPathComponent:@"coleco.rom"];
coleco_init(VIDEO_NTSC);
coleco_mem_load_bios([biosPath UTF8String]);
coleco_mem_load_rom([path UTF8String]);
coleco_mem_load_bios(biosPath.fileSystemRepresentation);
coleco_mem_load_rom(path.fileSystemRepresentation);
}
else
{
@@ -143,7 +139,7 @@ console_t *cur_console;
region = SMS_REGION_DOMESTIC;
sms_init(SMS_VIDEO_NTSC, region, 0); // 1 = VDP borders
sms_mem_load_rom([path UTF8String], console);
sms_mem_load_rom(path.fileSystemRepresentation, console);
cur_console->frame(0);
}
@@ -154,7 +150,7 @@ console_t *cur_console;
[[NSFileManager defaultManager] createDirectoryAtURL:batterySavesDirectory withIntermediateDirectories:YES attributes:nil error:nil];
NSURL *saveFile = [batterySavesDirectory URLByAppendingPathComponent:[extensionlessFilename stringByAppendingPathExtension:@"sav"]];
if([saveFile checkResourceIsReachableAndReturnError:nil] && sms_read_cartram_from_file([[saveFile path] UTF8String]) == 0)
if([saveFile checkResourceIsReachableAndReturnError:nil] && sms_read_cartram_from_file(saveFile.path.fileSystemRepresentation) == 0)
NSLog(@"CrabEmu: Loaded sram");
}
@@ -181,7 +177,7 @@ console_t *cur_console;
NSURL *batterySavesDirectory = [NSURL fileURLWithPath:[self batterySavesDirectoryPath]];
NSURL *saveFile = [batterySavesDirectory URLByAppendingPathComponent:[extensionlessFilename stringByAppendingPathExtension:@"sav"]];
cur_console->save_sram([[saveFile path] UTF8String]);
cur_console->save_sram(saveFile.path.fileSystemRepresentation);
}
[super stopEmulation];
@@ -196,12 +192,16 @@ console_t *cur_console;
- (OEIntSize)bufferSize
{
return OEIntSizeMake(cur_console->console_type == CONSOLE_GG ? 160 : 256, cur_console->console_type == CONSOLE_GG ? 144 : 256);
uint32_t f_x, f_y;
cur_console->frame_size(&f_x, &f_y);
return OEIntSizeMake(f_x, f_y);
}
- (OEIntRect)screenRect
{
return OEIntRectMake(0, 0, cur_console->console_type == CONSOLE_GG ? 160 : 256, cur_console->console_type == CONSOLE_GG ? 144 : smsvdp.lines);
uint32_t a_x, a_y, a_w, a_h;
cur_console->active_size(&a_x, &a_y, &a_w, &a_h);
return OEIntRectMake(a_x, a_y, a_w, a_h);
}
- (OEIntSize)aspectSize
@@ -209,16 +209,12 @@ console_t *cur_console;
return OEIntSizeMake(cur_console->console_type == CONSOLE_GG ? 160 : 256 * (8.0/7.0), cur_console->console_type == CONSOLE_GG ? 144 : 192);
}
- (const void *)videoBuffer
- (const void *)getVideoBufferWithHint:(void *)hint
{
if (cur_console->console_type != CONSOLE_GG)
return smsvdp.framebuffer;
else
for (int i = 0; i < 144; i++)
//jump 24 lines, skip 48 pixels and capture for each line of the buffer 160 pixels
// sizeof(unsigned char) is always equal to 1 by definition
memcpy(tempBuffer + i * 160 * 4, smsvdp.framebuffer + 24 * 256 * 1 + 48 * 1 + i * 256 * 1, 160 * 4);
return tempBuffer;
if (!hint) {
return cur_console->framebuffer();
}
return smsvdp.framebuffer = (uint32*)hint;
}
- (GLenum)pixelFormat
@@ -231,11 +227,6 @@ console_t *cur_console;
return GL_UNSIGNED_INT_8_8_8_8_REV;
}
- (GLenum)internalPixelFormat
{
return GL_RGB8;
}
# pragma mark - Audio
- (double)audioSampleRate
@@ -370,109 +361,27 @@ void gui_set_console(console_t *c)
# pragma mark - Input
- (int)crabButtonForButton:(OESMSButton)button player:(NSUInteger)player;
{
int btn = -1;
switch(button)
{
case OESMSButtonUp : btn = SMS_UP; break;
case OESMSButtonDown : btn = SMS_DOWN; break;
case OESMSButtonLeft : btn = SMS_LEFT; break;
case OESMSButtonRight : btn = SMS_RIGHT; break;
case OESMSButtonA : btn = SMS_BUTTON_1; break;
case OESMSButtonB : btn = SMS_BUTTON_2; break;
default : break;
}
return btn;
}
- (int)crabButtonForButton:(OEGGButton)button;
{
int btn = -1;
switch(button)
{
case OEGGButtonUp: btn = SMS_UP; break;
case OEGGButtonDown: btn = SMS_DOWN; break;
case OEGGButtonLeft: btn = SMS_LEFT; break;
case OEGGButtonRight: btn = SMS_RIGHT; break;
case OEGGButtonA: btn = SMS_BUTTON_1; break;
case OEGGButtonB: btn = SMS_BUTTON_2; break;
case OEGGButtonStart: btn = GAMEGEAR_START; break;
default : break;
}
return btn;
}
- (int)crabButtonForSG1000Button:(OESG1000Button)button;
{
int btn = -1;
switch(button)
{
case OESG1000ButtonUp: btn = SMS_UP; break;
case OESG1000ButtonDown: btn = SMS_DOWN; break;
case OESG1000ButtonLeft: btn = SMS_LEFT; break;
case OESG1000ButtonRight: btn = SMS_RIGHT; break;
case OESG1000Button1: btn = SMS_BUTTON_1; break;
case OESG1000Button2: btn = SMS_BUTTON_2; break;
default : break;
}
return btn;
}
- (int)crabButtonForColecoVisionButton:(OEColecoVisionButton)button player:(NSUInteger)player;
{
int btn = -1;
switch(button)
{
case OEColecoVisionButtonUp : btn = COLECOVISION_UP; break;
case OEColecoVisionButtonDown : btn = COLECOVISION_DOWN; break;
case OEColecoVisionButtonLeft : btn = COLECOVISION_LEFT; break;
case OEColecoVisionButtonRight : btn = COLECOVISION_RIGHT; break;
case OEColecoVisionButtonLeftAction : btn = COLECOVISION_L_ACTION; break;
case OEColecoVisionButtonRightAction : btn = COLECOVISION_R_ACTION; break;
case OEColecoVisionButton1 : btn = COLECOVISION_1; break;
case OEColecoVisionButton2 : btn = COLECOVISION_2; break;
case OEColecoVisionButton3 : btn = COLECOVISION_3; break;
case OEColecoVisionButton4 : btn = COLECOVISION_4; break;
case OEColecoVisionButton5 : btn = COLECOVISION_5; break;
case OEColecoVisionButton6 : btn = COLECOVISION_6; break;
case OEColecoVisionButton7 : btn = COLECOVISION_7; break;
case OEColecoVisionButton8 : btn = COLECOVISION_8; break;
case OEColecoVisionButton9 : btn = COLECOVISION_9; break;
case OEColecoVisionButton0 : btn = COLECOVISION_0; break;
case OEColecoVisionButtonAsterisk : btn = COLECOVISION_STAR; break;
case OEColecoVisionButtonPound : btn = COLECOVISION_POUND; break;
default : break;
}
return btn;
}
const int MasterSystemMap[] = {SMS_UP, SMS_DOWN, SMS_LEFT, SMS_RIGHT, SMS_BUTTON_1, SMS_BUTTON_2, GAMEGEAR_START};
const int ColecoVisionMap[] = {COLECOVISION_UP, COLECOVISION_DOWN, COLECOVISION_LEFT, COLECOVISION_RIGHT, COLECOVISION_L_ACTION, COLECOVISION_R_ACTION, COLECOVISION_1, COLECOVISION_2, COLECOVISION_3, COLECOVISION_4, COLECOVISION_5, COLECOVISION_6, COLECOVISION_7, COLECOVISION_8, COLECOVISION_9, COLECOVISION_0, COLECOVISION_STAR, COLECOVISION_POUND};
- (oneway void)didPushGGButton:(OEGGButton)button;
{
int btn = [self crabButtonForButton:button];
if(btn > -1) sms_button_pressed(1, btn);
sms_button_pressed(1, MasterSystemMap[button]);
}
- (oneway void)didReleaseGGButton:(OEGGButton)button;
{
int btn = [self crabButtonForButton:button];
if(btn > -1) sms_button_released(1, btn);
sms_button_released(1, MasterSystemMap[button]);
}
- (oneway void)didPushSMSButton:(OESMSButton)button forPlayer:(NSUInteger)player;
{
int btn = [self crabButtonForButton:button player:player];
if(btn > -1) sms_button_pressed(player, btn);
sms_button_pressed((int)player, MasterSystemMap[button]);
}
- (oneway void)didReleaseSMSButton:(OESMSButton)button forPlayer:(NSUInteger)player;
{
int btn = [self crabButtonForButton:button player:player];
if(btn > -1) sms_button_released(player, btn);
sms_button_released((int)player, MasterSystemMap[button]);
}
- (oneway void)didPushSMSStartButton;
@@ -482,7 +391,7 @@ void gui_set_console(console_t *c)
- (oneway void)didReleaseSMSStartButton;
{
sms_button_released(1, GAMEGEAR_START);
}
- (oneway void)didPushSMSResetButton;
@@ -495,28 +404,25 @@ void gui_set_console(console_t *c)
sms_button_released(1, SMS_CONSOLE_RESET);
}
- (oneway void)didPushSG1000Button:(OESG1000Button)button;
- (oneway void)didPushSG1000Button:(OESG1000Button)button forPlayer:(NSUInteger)player
{
int btn = [self crabButtonForSG1000Button:button];
if(btn > -1) sms_button_pressed(1, btn);
//console pause, sms_z80_nmi()
sms_button_pressed((int)player, MasterSystemMap[button]);
}
- (oneway void)didReleaseSG1000Button:(OESG1000Button)button;
- (oneway void)didReleaseSG1000Button:(OESG1000Button)button forPlayer:(NSUInteger)player
{
int btn = [self crabButtonForSG1000Button:button];
if(btn > -1) sms_button_released(1, btn);
sms_button_released((int)player, MasterSystemMap[button]);
}
- (oneway void)didPushColecoVisionButton:(OEColecoVisionButton)button forPlayer:(NSUInteger)player;
{
int btn = [self crabButtonForColecoVisionButton:button player:player];
if(btn > -1) coleco_button_pressed(player, btn);
coleco_button_pressed((int)player, ColecoVisionMap[button]);
}
- (oneway void)didReleaseColecoVisionButton:(OEColecoVisionButton)button forPlayer:(NSUInteger)player;
{
int btn = [self crabButtonForColecoVisionButton:button player:player];
if(btn > -1) coleco_button_released(player, btn);
coleco_button_released((int)player, ColecoVisionMap[button]);
}
#pragma mark - Cheats
+106 -8
View File
@@ -2,7 +2,7 @@
This file is part of CrabEmu.
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,
2014, 2015 Lawrence Sebald
2014, 2015, 2016 Lawrence Sebald
CrabEmu is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
@@ -66,6 +66,9 @@ static uint32 cart_len = 0;
static uint8 cont_mode = 0;
static uint32 rom_crc, rom_adler;
static uint32 megacart_page = 0;
static uint32 megacart_pages = 0;
extern sn76489_t psg;
uint16 coleco_cont_bits[2];
@@ -117,10 +120,36 @@ void coleco_port_write(uint16 port, uint8 data) {
}
uint8 coleco_mem_read(uint16 addr) {
if(megacart_pages && addr >= 0xFFC0) {
int i;
megacart_page = (addr & (megacart_pages - 1));
/* Fix the paging... */
for(i = 0; i < 0x40; ++i) {
read_map[i + 0xC0] = cart_rom + (megacart_page << 14) + (i << 8);
}
sms_z80_set_readmap(read_map);
}
return read_map[addr >> 8][addr & 0xFF];
}
void coleco_mem_write(uint16 addr, uint8 data) {
if(megacart_pages && addr >= 0xFFC0) {
int i;
megacart_page = (addr & (megacart_pages - 1));
/* Fix the paging... */
for(i = 0; i < 0x40; ++i) {
read_map[i + 0xC0] = cart_rom + (megacart_page << 14) + (i << 8);
}
sms_z80_set_readmap(read_map);
}
write_map[addr >> 8][addr & 0xFF] = data;
}
@@ -128,6 +157,20 @@ uint16 coleco_mem_read16(uint16 addr) {
uint16 rv = (uint16)read_map[addr >> 8][addr & 0xFF];
++addr;
/* Nobody'd be stupid enough to do this, would they?... */
if(megacart_pages && addr >= 0xFFC0) {
int i;
megacart_page = (addr & (megacart_pages - 1));
/* Fix the paging... */
for(i = 0; i < 0x40; ++i) {
read_map[i + 0xC0] = cart_rom + (megacart_page << 14) + (i << 8);
}
sms_z80_set_readmap(read_map);
}
rv |= ((uint16)read_map[addr >> 8][addr & 0xFF]) << 8;
return rv;
}
@@ -135,6 +178,22 @@ uint16 coleco_mem_read16(uint16 addr) {
void coleco_mem_write16(uint16 addr, uint16 data) {
write_map[addr >> 8][addr & 0xFF] = (uint8)data;
++addr;
/* Hopefully if nobody's stupid enough to trigger the one above, there
really won't be anyone triggering THIS one... */
if(megacart_pages && addr >= 0xFFC0) {
int i;
megacart_page = (addr & (megacart_pages - 1));
/* Fix the paging... */
for(i = 0; i < 0x40; ++i) {
read_map[i + 0xC0] = cart_rom + (megacart_page << 14) + (i << 8);
}
sms_z80_set_readmap(read_map);
}
write_map[addr >> 8][addr & 0xFF] = (uint8)(data >> 8);
}
@@ -169,13 +228,38 @@ static void finalize_load(const char *fn) {
}
/* ROM */
for(i = 0; i < 0x80; ++i) {
write_map[i + 0x80] = dummy_areaw;
if(cart_len > 0x8000) {
/* We have a MegaCart... */
megacart_page = 0;
megacart_pages = cart_len >> 14;
if(i < (cart_len >> 8))
read_map[i + 0x80] = cart_rom + (i << 8);
else
read_map[i + 0x80] = dummy_arear;
#ifdef DEBUG
printf("coleco_mem_load_rom: Detected MegaCart\n"
" %" PRIu32 " bytes long = %" PRIu32 " pages\n",
cart_len, megacart_pages);
#endif
/* Always map 0x8000-0xBFFF to the top 16k of the cart... The page
selected for 0xC000-0xFFFF starts out as page 0. */
for(i = 0; i < 0x40; ++i) {
write_map[i + 0x80] = dummy_areaw;
write_map[i + 0xC0] = dummy_areaw;
read_map[i + 0x80] = cart_rom + (cart_len - 0x4000) + (i << 8);
read_map[i + 0xC0] = cart_rom + (i << 8);
}
}
else {
megacart_pages = megacart_page = 0;
for(i = 0; i < 0x80; ++i) {
write_map[i + 0x80] = dummy_areaw;
if(i < (cart_len >> 8))
read_map[i + 0x80] = cart_rom + (i << 8);
else
read_map[i + 0x80] = dummy_arear;
}
}
sms_z80_set_readmap(read_map);
@@ -545,6 +629,18 @@ int coleco_regs_read_context(const uint8 *buf) {
/* Copy in the registers */
cont_mode = buf[16];
if(megacart_pages) {
int i;
megacart_page = buf[17];
/* Fix the paging... */
for(i = 0; i < 0x40; ++i) {
read_map[i + 0xC0] = cart_rom + (megacart_page << 14) + (i << 8);
sms_z80_set_readmap(read_map);
}
}
return 0;
}
@@ -588,7 +684,8 @@ int coleco_mem_write_context(FILE *fp) {
fwrite(data, 1, 4, fp); /* Child pointer */
data[0] = cont_mode;
data[1] = data[2] = data[3] = 0;
data[1] = megacart_page;
data[2] = data[3] = 0;
fwrite(data, 1, 4, fp);
return 0;
@@ -658,6 +755,7 @@ int coleco_mem_init(void) {
memset(bios_rom, 0, 8192);
bios_loaded = 0;
megacart_page = megacart_pages = 0;
coleco_cont_bits[0] = 0;
coleco_cont_bits[1] = 0;
+11 -9
View File
@@ -1,7 +1,8 @@
/*
This file is part of CrabEmu.
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2014 Lawrence Sebald
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2014,
2016 Lawrence Sebald
CrabEmu is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
@@ -49,6 +50,7 @@ int sms_psg_enabled = 1;
int sms_ym2413_enabled = 1;
sn76489_t psg;
int sms_region = SMS_REGION_EXPORT;
YM2413 *sms_fm = NULL;
uint32 psg_samples[313];
@@ -142,7 +144,7 @@ int sms_init(int video_system, int region, int borders) {
sn76489_init(&psg, NTSC_Z80_CLOCK, 44100.0f,
SN76489_NOISE_BITS_SMS, SN76489_NOISE_TAPPED_SMS);
YM2413Init(1, NTSC_Z80_CLOCK, 44100);
sms_fm = ym2413_init(NTSC_Z80_CLOCK, 44100);
}
else {
tmp = PAL_Z80_CLOCK / PSG_DIVISOR / PAL_FPS / PAL_LINES_PER_FRAME /
@@ -158,7 +160,7 @@ int sms_init(int video_system, int region, int borders) {
sn76489_init(&psg, PAL_Z80_CLOCK, 44100.0f,
SN76489_NOISE_BITS_SMS, SN76489_NOISE_TAPPED_SMS);
YM2413Init(1, PAL_Z80_CLOCK, 44100);
sms_fm = ym2413_init(PAL_Z80_CLOCK, 44100);
}
sms_region = region;
@@ -174,7 +176,7 @@ int sms_init(int video_system, int region, int borders) {
sound_init(2, video_system);
sms_sdsc_reset();
YM2413ResetChip(0);
ym2413_reset(sms_fm);
cycles_run = cycles_to_run = scanline = 0;
sms_cons._base.initialized = 1;
@@ -195,7 +197,7 @@ int sms_reset(void) {
SN76489_NOISE_BITS_SMS, SN76489_NOISE_TAPPED_SMS);
}
YM2413ResetChip(0);
ym2413_reset(sms_fm);
sound_reset_buffer();
@@ -218,7 +220,7 @@ int sms_soft_reset(void) {
if(sms_cons._base.initialized == 0)
return 0;
YM2413ResetChip(0);
ym2413_reset(sms_fm);
sound_reset_buffer();
@@ -238,7 +240,7 @@ int sms_shutdown(void) {
sms_mem_shutdown();
sms_vdp_shutdown();
sms_z80_shutdown();
YM2413Shutdown();
ym2413_shutdown(sms_fm);
sound_shutdown();
/* Reset a few things in case we reinit later. */
@@ -261,11 +263,11 @@ static __INLINE__ int update_sound(int16 buf[], int start, int line) {
memset(buf + start, 0, psg_samples[line] << 2);
if(sms_ym2413_enabled) {
YM2413UpdateOne(0, fmbuf, psg_samples[line]);
ym2413_update(sms_fm, fmbuf, psg_samples[line]);
/* Mix in the FM unit's samples */
for(i = 0; i < psg_samples[line]; ++i) {
tmp = (fmbuf[i << 1] + fmbuf[(i << 1) + 1]) / 2;
tmp = (fmbuf[i << 1] + fmbuf[(i << 1) + 1]);
buf[(i << 1) + start] += tmp;
buf[(i << 1) + 1 + start] += tmp;
}
+20 -15
View File
@@ -1,8 +1,8 @@
/*
This file is part of CrabEmu.
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
2014, 2015 Lawrence Sebald
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014,
2015, 2016 Lawrence Sebald
CrabEmu is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
@@ -82,6 +82,7 @@ extern int sms_region;
extern sn76489_t psg;
extern eeprom93c46_t e93c46;
extern int sms_ym2413_enabled;
extern YM2413 *sms_fm;
uint8 sms_paging_regs[4];
uint8 *sms_rom_page0;
@@ -700,12 +701,14 @@ void sms_port_write(uint16 port, uint8 data) {
if(sms_ym2413_enabled) {
if(port == 0xF0) {
sms_ym2413_regs[0x40] = data;
YM2413Write(0, 0, data);
//YM2413Write(0, 0, data);
ym2413_write(sms_fm, 0, data);
sms_ym2413_in_use = 1;
}
else if(port == 0xF1) {
sms_ym2413_regs[sms_ym2413_regs[0x40]] = data;
YM2413Write(0, 1, data);
//YM2413Write(0, 1, data);
ym2413_write(sms_fm, 1, data);
sms_ym2413_in_use = 1;
}
else if(port == 0xF2) {
@@ -1676,30 +1679,30 @@ int sms_ym2413_read_context(const uint8 *buf) {
memcpy(sms_ym2413_regs, buf + 16, 65);
/* This is based on how SMS Plus handles things... */
YM2413Write(0, 0, 0x0E);
YM2413Write(0, 1, sms_ym2413_regs[0x0E]);
ym2413_write(sms_fm, 0, 0x0E);
ym2413_write(sms_fm, 1, sms_ym2413_regs[0x0E]);
for(i = 0x00; i <= 0x07; ++i) {
YM2413Write(0, 0, i);
YM2413Write(0, 1, sms_ym2413_regs[i]);
ym2413_write(sms_fm, 0, i);
ym2413_write(sms_fm, 1, sms_ym2413_regs[i]);
}
for(i = 0x10; i <= 0x18; ++i) {
YM2413Write(0, 0, i);
YM2413Write(0, 1, sms_ym2413_regs[i]);
ym2413_write(sms_fm, 0, i);
ym2413_write(sms_fm, 1, sms_ym2413_regs[i]);
}
for(i = 0x20; i <= 0x28; ++i) {
YM2413Write(0, 0, i);
YM2413Write(0, 1, sms_ym2413_regs[i]);
ym2413_write(sms_fm, 0, i);
ym2413_write(sms_fm, 1, sms_ym2413_regs[i]);
}
for(i = 0x30; i <= 0x38; ++i) {
YM2413Write(0, 0, i);
YM2413Write(0, 1, sms_ym2413_regs[i]);
ym2413_write(sms_fm, 0, i);
ym2413_write(sms_fm, 1, sms_ym2413_regs[i]);
}
YM2413Write(0, 0, sms_ym2413_regs[64]);
ym2413_write(sms_fm, 0, sms_ym2413_regs[64]);
return 0;
}
@@ -2073,6 +2076,8 @@ int sms_mapper_read_context(const uint8 *buf) {
ptr += clen;
}
reorganize_pages();
return 0;
}
+22 -7
View File
@@ -1,7 +1,7 @@
/*
This file is part of CrabEmu.
Copyright (C) 2005, 2006, 2007, 2008, 2012, 2013, 2014 Lawrence Sebald
Copyright (C) 2005, 2006, 2007, 2008, 2012, 2013, 2014, 2016 Lawrence Sebald
CrabEmu is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
@@ -1440,7 +1440,7 @@ static int sms_vdp_read_vram_context(const uint8 *buf) {
/* Check the size */
BUF_TO_UINT32(buf + 4, len);
if(len < 16 || len > 0x4010)
if(len != 0x4010)
return -1;
/* Check the version number */
@@ -1453,7 +1453,7 @@ static int sms_vdp_read_vram_context(const uint8 *buf) {
return -1;
memset(smsvdp.vram, 0, 0x4000);
memcpy(smsvdp.vram, buf + 16, len - 16);
memcpy(smsvdp.vram, buf + 16, 0x4000);
return 0;
}
@@ -1490,7 +1490,7 @@ static int sms_vdp_read_cram_context(const uint8 *buf) {
/* Check the size */
BUF_TO_UINT32(buf + 4, len);
if(len < 16 || len > 80)
if(len != 80)
return -1;
/* Check the version number */
@@ -1503,7 +1503,7 @@ static int sms_vdp_read_cram_context(const uint8 *buf) {
return -1;
memset(smsvdp.cram, 0, 64);
memcpy(smsvdp.cram, buf + 16, len - 16);
memcpy(smsvdp.cram, buf + 16, 64);
return 0;
}
@@ -1565,7 +1565,7 @@ int sms_vdp_read_context(const uint8 *buf) {
uint32 len, child, clen;
uint16 ver;
const uint8 *ptr;
int rv, i;
int rv, i, tmp;
/* Check the size */
BUF_TO_UINT32(buf + 4, len);
@@ -1584,7 +1584,7 @@ int sms_vdp_read_context(const uint8 *buf) {
/* Read the VDP state */
for(i = 0; i < 16; ++i) {
sms_vdp_reg_write(i, buf[16 + i]);
smsvdp.regs[i] = buf[16 + i];
}
BUF_TO_UINT16(buf + 32, smsvdp.addr);
@@ -1647,6 +1647,21 @@ int sms_vdp_read_context(const uint8 *buf) {
}
}
/* Deal with the updated register values... */
sms_z80_clear_irq();
smsvdp.sat = smsvdp.vram + ((smsvdp.regs[5] & 0x7E) << 7);
tmp = (smsvdp.regs[8] & 0xF8) >> 3;
smsvdp.xscroll_coarse = (32 - tmp) & 0x1F;
smsvdp.xscroll_fine = smsvdp.regs[8] & 0x07;
smsvdp.yscroll_fine = smsvdp.regs[9] & 0x07;
sms_vdp_set_vidmode(smsvdp.vidmode, smsvdp.machine);
readjust_name_table();
/* Assert the irq line if we need to. */
if((smsvdp.status & 0x80) && (smsvdp.regs[1] & 0x20)) {
sms_z80_assert_irq();
}
/* Mark all patterns as dirty */
for(i = 0; i < 512; ++i) {
smsvdp.pattern[i].dirty = 1;
+2
View File
@@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */
+20 -2
View File
@@ -3,10 +3,21 @@
* 20081017 AF
*/
#include <AvailabilityMacros.h>
/* Don't build if the deployment target is 10.13 or above. */
#if MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_13
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fmemopen.h"
#undef fmemopen
#ifndef __has_builtin // Optional of course.
#define __has_builtin(x) 0 // Compatibility with non-clang compilers.
#endif
#ifndef linux
struct fmem {
@@ -67,12 +78,19 @@ static int closefn(void *handler)
}
/* simple, but portable version of fmemopen for OS X / BSD */
FILE *fmemopen(void *buf, size_t size, const char *mode)
FILE *fmemopen_(void *buf, size_t size, const char *mode)
{
#if __has_builtin(__builtin_available)
if (__builtin_available(macOS 10.13, iOS 11.0, tvOS 11.0, watchOS 4.0, *)) {
return fmemopen(buf, size, mode);
}
#endif
fmem_t *mem = (fmem_t *) malloc(sizeof(fmem_t));
memset(mem, 0, sizeof(fmem_t));
mem->size = size, mem->buffer = buf;
return funopen(mem, readfn, writefn, seekfn, closefn);
}
#endif
#endif
#endif
+4 -3
View File
@@ -43,10 +43,11 @@ extern "C"
* @returns A pointer that can be used in the fread/fwrite/fseek/fclose family of methods.
* If a failure occurred NULL will be returned.
*/
FILE *fmemopen(void *buf, size_t size, const char *mode);
FILE *fmemopen_(void *buf, size_t size, const char *mode);
#define fmemopen fmemopen_
#ifdef __cplusplus
}
#endif
#endif // #ifndef FMEMOPEN_H_
#endif // #ifndef FMEMOPEN_H_
+16 -2
View File
@@ -1,9 +1,16 @@
/* Use funopen(3) to provide open_memstream(3) like functionality. */
#include <AvailabilityMacros.h>
/* But only if the deployment target is below 10.13 */
#if MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_13
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "open_memstream.h"
#undef open_memstream
struct memstream {
char **cp;
@@ -107,8 +114,13 @@ memstream_close(void *cookie)
}
FILE *
open_memstream(char **cp, size_t *lenp)
open_memstream_(char **cp, size_t *lenp)
{
#if __has_builtin(__builtin_available)
if (__builtin_available(macOS 10.13, iOS 11.0, tvOS 11.0, watchOS 4.0, *)) {
return open_memstream(cp, lenp);
}
#endif
struct memstream *ms;
int save_errno;
FILE *fp;
@@ -127,4 +139,6 @@ open_memstream(char **cp, size_t *lenp)
errno = save_errno;
}
return (fp);
}
}
#endif
+3 -2
View File
@@ -6,10 +6,11 @@ extern "C"
{
#endif
FILE *open_memstream(char **cp, size_t *lenp);
FILE *open_memstream_(char **cp, size_t *lenp);
#define open_memstream open_memstream_
#ifdef __cplusplus
}
#endif
#endif // #ifndef FMEMOPEN_H_
#endif // #ifndef FMEMOPEN_H_
+1757 -2240
View File
File diff suppressed because it is too large Load Diff
+171 -41
View File
@@ -1,41 +1,171 @@
#ifndef _H_YM2413_
#define _H_YM2413_
/* select output bits size of output : 8 or 16 */
#define SAMPLE_BITS 16
/* compiler dependence */
#ifndef OSD_CPU_H
#define OSD_CPU_H
typedef unsigned char UINT8; /* unsigned 8bit */
typedef unsigned short UINT16; /* unsigned 16bit */
typedef unsigned int UINT32; /* unsigned 32bit */
typedef signed char INT8; /* signed 8bit */
typedef signed short INT16; /* signed 16bit */
typedef signed int INT32; /* signed 32bit */
#endif
#if (SAMPLE_BITS==16)
typedef INT16 SAMP;
#endif
#if (SAMPLE_BITS==8)
typedef INT8 SAMP;
#endif
int YM2413Init(int num, int clock, int rate);
void YM2413Shutdown(void);
void YM2413ResetChip(int which);
void YM2413Write(int which, int a, int v);
unsigned char YM2413Read(int which, int a);
void YM2413UpdateOne(int which, INT16 *buffers, int length);
void YM2413UpdateOneMono(int which, INT16 *buffers, int length);
typedef void (*OPLL_UPDATEHANDLER)(int param,int min_interval_us);
void YM2413SetUpdateHandler(int which, OPLL_UPDATEHANDLER UpdateHandler, int param);
#endif /*_H_YM2413_*/
/*
CrabEmu Modifications to this code:
- Added typedefs and such to unglue the code from MAME's core.
- Added mono update function for the Dreamcast port.
- Updated to mamedev current as of September 4, 2016, backporting to C
from C++.
Copyright (C) 2011, 2012, 2016 Lawrence Sebald
Modifications distributed under the same license as the rest of the code in
this file (GPLv2 or newer).
*/
// license:GPL-2.0+
// copyright-holders:Jarek Burczynski,Ernesto Corvi
#ifndef __YM2413_H__
#define __YM2413_H__
/* MAME glue... */
#if __STDC_VERSION__ >= 199901L
#include <stdint.h>
typedef uint8_t UINT8;
typedef uint32_t UINT32;
typedef int8_t INT8;
typedef int16_t INT16;
typedef int32_t INT32;
#else
#warning Check integer types, they may not be correct!
typedef unsigned char UINT8;
typedef unsigned int UINT32;
typedef signed char INT8;
typedef signed int INT32;
#endif
/* End MAME glue... */
struct OPLL_SLOT
{
UINT32 ar; /* attack rate: AR<<2 */
UINT32 dr; /* decay rate: DR<<2 */
UINT32 rr; /* release rate:RR<<2 */
UINT8 KSR; /* key scale rate */
UINT8 ksl; /* keyscale level */
UINT8 ksr; /* key scale rate: kcode>>KSR */
UINT8 mul; /* multiple: mul_tab[ML] */
/* Phase Generator */
UINT32 phase; /* frequency counter */
UINT32 freq; /* frequency counter step */
UINT8 fb_shift; /* feedback shift value */
INT32 op1_out[2]; /* slot1 output for feedback */
/* Envelope Generator */
UINT8 eg_type; /* percussive/nonpercussive mode*/
UINT8 state; /* phase type */
UINT32 TL; /* total level: TL << 2 */
INT32 TLL; /* adjusted now TL */
INT32 volume; /* envelope counter */
UINT32 sl; /* sustain level: sl_tab[SL] */
UINT8 eg_sh_dp; /* (dump state) */
UINT8 eg_sel_dp; /* (dump state) */
UINT8 eg_sh_ar; /* (attack state) */
UINT8 eg_sel_ar; /* (attack state) */
UINT8 eg_sh_dr; /* (decay state) */
UINT8 eg_sel_dr; /* (decay state) */
UINT8 eg_sh_rr; /* (release state for non-perc.)*/
UINT8 eg_sel_rr; /* (release state for non-perc.)*/
UINT8 eg_sh_rs; /* (release state for perc.mode)*/
UINT8 eg_sel_rs; /* (release state for perc.mode)*/
UINT32 key; /* 0 = KEY OFF, >0 = KEY ON */
/* LFO */
UINT32 AMmask; /* LFO Amplitude Modulation enable mask */
UINT8 vib; /* LFO Phase Modulation enable flag (active high)*/
/* waveform select */
unsigned int wavetable;
};
struct OPLL_CH
{
struct OPLL_SLOT SLOT[2];
/* phase generator state */
UINT32 block_fnum; /* block+fnum */
UINT32 fc; /* Freq. freqement base */
UINT32 ksl_base; /* KeyScaleLevel Base step */
UINT8 kcode; /* key code (for key scaling) */
UINT8 sus; /* sus on/off (release speed in percussive mode)*/
};
enum {
RATE_STEPS = (8),
/* sinwave entries */
SIN_BITS = 10,
SIN_LEN = (1<<SIN_BITS),
SIN_MASK = (SIN_LEN-1),
TL_RES_LEN = (256), /* 8 bits addressing (real chip) */
/* TL_TAB_LEN is calculated as:
* 11 - sinus amplitude bits (Y axis)
* 2 - sinus sign bit (Y axis)
* TL_RES_LEN - sinus resolution (X axis)
*/
TL_TAB_LEN = (11*2*TL_RES_LEN),
LFO_AM_TAB_ELEMENTS = 210
};
typedef struct ym2413_s {
int tl_tab[TL_TAB_LEN];
/* sin waveform table in 'decibel' scale */
/* two waveforms on OPLL type chips */
unsigned int sin_tab[SIN_LEN * 2];
struct OPLL_CH P_CH[9]; /* OPLL chips have 9 channels*/
UINT8 instvol_r[9]; /* instrument/volume (or volume/volume in percussive mode)*/
UINT32 eg_cnt; /* global envelope generator counter */
UINT32 eg_timer; /* global envelope generator counter works at frequency = chipclock/72 */
UINT32 eg_timer_add; /* step of eg_timer */
UINT32 eg_timer_overflow; /* envelope generator timer overlfows every 1 sample (on real chip) */
UINT8 rhythm; /* Rhythm mode */
/* LFO */
UINT32 LFO_AM;
INT32 LFO_PM;
UINT32 lfo_am_cnt;
UINT32 lfo_am_inc;
UINT32 lfo_pm_cnt;
UINT32 lfo_pm_inc;
UINT32 noise_rng; /* 23 bit noise shift register */
UINT32 noise_p; /* current noise 'phase' */
UINT32 noise_f; /* current noise period */
/* instrument settings */
/*
0-user instrument
1-15 - fixed instruments
16 -bass drum settings
17,18 - other percussion instruments
*/
UINT8 inst_tab[19][8];
UINT32 fn_tab[1024]; /* fnumber->increment counter */
UINT8 address; /* address register */
signed int output[2];
} YM2413;
/* CrabEmu's public interface... */
YM2413 *ym2413_init(int clock, int rate);
void ym2413_shutdown(YM2413 *fm);
void ym2413_reset(YM2413 *fm);
void ym2413_write(YM2413 *fm, int a, int v);
void ym2413_update(YM2413 *fm, int16_t *buf, int samples);
void ym2413_update_mono(YM2413 *fm, int16_t buf, int samples);
unsigned char ym2413_read(YM2413 *fm, int a);
#endif /*__YM2413_H__*/