Skip to content

Commit

Permalink
Fix Mac build after Vulkan changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBuckley committed Mar 8, 2023
1 parent b293366 commit cea5148
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 55 deletions.
2 changes: 2 additions & 0 deletions fscompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#pragma once

#ifdef __cplusplus
#include <string>

enum s9x_getdirtype
Expand Down Expand Up @@ -48,3 +49,4 @@ std::string S9xGetFilename (std::string ext, enum s9x_getdirtype dirtype);
std::string S9xGetFilename (std::string filename, std::string ext, enum s9x_getdirtype dirtype);
std::string S9xGetDirectory (enum s9x_getdirtype);
std::string S9xGetFilenameInc (std::string, enum s9x_getdirtype);
#endif
23 changes: 13 additions & 10 deletions macosx/mac-cheat.mm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ SNES9X for Mac OS (c) Copyright John Stiles

extern SCheatData Cheat;

bool S9xGameGenieToRaw(const std::string &code, uint32 &address, uint8 &byte);
bool S9xProActionReplayToRaw(const std::string &code, uint32 &address, uint8 &byte);

@implementation S9xCheatItem

- (void)setAddress:(uint32)address value:(uint8)value cheatDescription:(const char *)cheatDescription
Expand All @@ -61,29 +64,29 @@ - (void)setAddress:(uint32)address value:(uint8)value cheatDescription:(const ch
@dynamic address;
- (NSNumber *)address
{
return @(Cheat.g[self.cheatID].c[0].address);
return @(Cheat.group[self.cheatID].cheat[0].address);
}

- (void)setAddress:(NSNumber *)address
{
[self setAddress:address.unsignedIntValue value:Cheat.g[self.cheatID].c[0].byte cheatDescription:self.cheatDescription.UTF8String];
[self setAddress:address.unsignedIntValue value:Cheat.group[self.cheatID].cheat[0].byte cheatDescription:self.cheatDescription.UTF8String];
}

@dynamic value;
- (NSNumber *)value
{
return @(Cheat.g[self.cheatID].c[0].byte);
return @(Cheat.group[self.cheatID].cheat[0].byte);
}

- (void)setValue:(NSNumber *)value
{
[self setAddress:Cheat.g[self.cheatID].c[0].address value:value.unsignedCharValue cheatDescription:self.cheatDescription.UTF8String];
[self setAddress:Cheat.group[self.cheatID].cheat[0].address value:value.unsignedCharValue cheatDescription:self.cheatDescription.UTF8String];
}

@dynamic enabled;
- (NSNumber *)enabled
{
return @(Cheat.g[self.cheatID].enabled);
return @(Cheat.group[self.cheatID].enabled);
}

- (void)setEnabled:(NSNumber *)enabled
Expand All @@ -101,12 +104,12 @@ - (void)setEnabled:(NSNumber *)enabled
@dynamic cheatDescription;
- (NSString *)cheatDescription
{
return [NSString stringWithUTF8String:Cheat.g[self.cheatID].name];
return [NSString stringWithUTF8String:Cheat.group[self.cheatID].name.c_str()];
}

- (void)setCheatDescription:(NSString *)cheatDescription
{
[self setAddress:Cheat.g[self.cheatID].c[0].address value:Cheat.g[self.cheatID].c[0].byte cheatDescription:cheatDescription.UTF8String];
[self setAddress:Cheat.group[self.cheatID].cheat[0].address value:Cheat.group[self.cheatID].cheat[0].byte cheatDescription:cheatDescription.UTF8String];
}

- (void)delete
Expand Down Expand Up @@ -151,21 +154,21 @@ void CreateCheatFromAddress(NSNumber *address, NSNumber *value, NSString *cheatD
char code[256];
sprintf(code, "%x=%x", address.unsignedIntValue, value.unsignedCharValue);
S9xAddCheatGroup(cheatDescription.UTF8String, code);
S9xEnableCheatGroup(Cheat.g.size() - 1);
S9xEnableCheatGroup(Cheat.group.size() - 1);
}

void CreateCheatFromCode(NSString *code, NSString *cheatDescription)
{
S9xAddCheatGroup(cheatDescription.UTF8String, code.UTF8String);
S9xEnableCheatGroup(Cheat.g.size() - 1);
S9xEnableCheatGroup(Cheat.group.size() - 1);
}

NSArray<S9xCheatItem *> *GetAllCheats(void)
{
NSMutableArray *cheats = [NSMutableArray new];
uint32 cheatID = 0;

for (auto it : Cheat.g)
for (auto it : Cheat.group)
{
S9xCheatItem *cheat = [S9xCheatItem new];
cheat.cheatID = cheatID++;
Expand Down
48 changes: 18 additions & 30 deletions macosx/mac-file.mm
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ static void AddFolderIcon (NSURL *fref, const char *folderName)

uint32 type;
char folderName[16];
char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], fname[_MAX_FNAME + 1], ext[_MAX_EXT + 1];
const char *p;

index++;
Expand Down Expand Up @@ -289,23 +288,21 @@ static void AddFolderIcon (NSURL *fref, const char *folderName)

if (folderURL != nil)
{
_splitpath(Memory.ROMFilename, drive, dir, fname, ext);
snprintf(filePath[index], PATH_MAX + 1, "%s%s%s%s", folderURL.path.UTF8String, MAC_PATH_SEPARATOR, fname, inExt);
auto path = splitpath(Memory.ROMFilename);
snprintf(filePath[index], PATH_MAX + 1, "%s%s%s%s", folderURL.path.UTF8String, MAC_PATH_SEPARATOR, path.stem.c_str(), inExt);
}
else
{
_splitpath(Memory.ROMFilename, drive, dir, fname, ext);

strlcat(fname, inExt, sizeof(fname));
_makepath(filePath[index], drive, dir, fname, "");
auto path = splitpath(Memory.ROMFilename);
path.ext = inExt;
makepath(path);
}
}
else
{
_splitpath(Memory.ROMFilename, drive, dir, fname, ext);

strlcat(fname, inExt, sizeof(fname));
_makepath(filePath[index], drive, dir, fname, "");
auto path = splitpath(Memory.ROMFilename);
path.ext = inExt;
makepath(path);
}

return (filePath[index]);
Expand Down Expand Up @@ -346,27 +343,19 @@ static void AddFolderIcon (NSURL *fref, const char *folderName)
return (S9xGetFilename(frzExt, SNAPSHOT_DIR));
}

const char * S9xGetFilenameInc (const char *inExt, enum s9x_getdirtype dirtype)
std::string S9xGetFilenameInc (std::string, enum s9x_getdirtype type)
{
uint32 type;
const char *p;

if (strlen(inExt) < 4)
return (NULL);

p = inExt + strlen(inExt) - 4;
type = ((uint32) p[0] << 24) + ((uint32) p[1] << 16) + ((uint32) p[2] << 8) + (uint32) p[3];

switch (type)
{
case '.spc':
case SPC_DIR:
return (S9xGetSPCFilename());

case '.png':
case SCREENSHOT_DIR:
return (S9xGetPNGFilename());
}

return (NULL);
default:
return "";
}
}

bool8 S9xOpenSnapshotFile (const char *fname, bool8 read_only, STREAM *file)
Expand Down Expand Up @@ -408,13 +397,12 @@ void S9xCloseSnapshotFile (STREAM file)
return (basename(s));
}

const char * S9xGetDirectory (enum s9x_getdirtype dirtype)
std::string S9xGetDirectory (enum s9x_getdirtype dirtype)
{
static int index = 0;
static char path[4][PATH_MAX + 1];

char inExt[16];
char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], fname[_MAX_FNAME + 1], ext[_MAX_EXT + 1];
char inExt[16];

index++;
if (index > 3)
Expand All @@ -432,8 +420,8 @@ void S9xCloseSnapshotFile (STREAM file)
default: strlcpy(inExt, ".xxx", sizeof(inExt)); break;
}

_splitpath(S9xGetFilename(inExt, dirtype), drive, dir, fname, ext);
_makepath(path[index], drive, dir, "", "");
auto p = splitpath(S9xGetFilename(inExt, dirtype));
makepath(p.drive, p.drive, path[index], "");

size_t l = strlen(path[index]);
if (l > 1)
Expand Down
9 changes: 4 additions & 5 deletions macosx/mac-musicbox.mm
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ - (id) init
NSRect rect;
NSSize size;
BOOL apuonly, r;
char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], fname[_MAX_FNAME + 1], ext[_MAX_EXT + 1];

self = [super init];
if (!self)
return (self);

r = [NSBundle loadNibNamed: @"musicbox" owner: self];
r = [NSBundle loadNibNamed: @"musicbox" owner: self ];
if (!r)
return (self);

Expand All @@ -76,8 +75,8 @@ - (id) init
else
MusicBoxForceFreeze();

_splitpath(Memory.ROMFilename, drive, dir, fname, ext);
[gametitle setStringValue: [NSString stringWithUTF8String: fname]];
auto path = splitpath(Memory.ROMFilename);
[gametitle setStringValue: [NSString stringWithUTF8String: path.stem.c_str()]];

[led setImage: [NSImage imageNamed: (apuonly ? @"musicbox_ledoff.icns" : @"musicbox_ledon.icns")]];

Expand Down Expand Up @@ -124,7 +123,7 @@ - (id) init
pthread_create(&mbxThread, NULL, SoundTask, NULL);

timer = [NSTimer scheduledTimerWithTimeInterval: (2.0 / (double) Memory.ROMFramesPerSecond) target: self selector: @selector(updateIndicator:) userInfo: nil repeats: YES];

//
return (self);
}

Expand Down
12 changes: 6 additions & 6 deletions macosx/mac-snes9x.mm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ bool8 SNES9X_OpenCart (NSURL *inRef)
Settings.ForcePAL = (videoDetect == kPALForce );
Settings.ForceNTSC = (videoDetect == kNTSCForce );

GFX.InfoString = NULL;
GFX.InfoString = "";
GFX.InfoStringTimeout = 0;

S9xResetSaveTimer(true);
Expand Down Expand Up @@ -148,7 +148,7 @@ bool8 SNES9X_OpenMultiCart (void)
Settings.ForcePAL = (videoDetect == kPALForce );
Settings.ForceNTSC = (videoDetect == kNTSCForce );

GFX.InfoString = NULL;
GFX.InfoString = "";
GFX.InfoStringTimeout = 0;

S9xResetSaveTimer(true);
Expand Down Expand Up @@ -192,18 +192,18 @@ bool8 SNES9X_OpenMultiCart (void)
void SNES9X_LoadSRAM (void)
{
if (cartOpen)
Memory.LoadSRAM(S9xGetFilename(".srm", SRAM_DIR));
Memory.LoadSRAM(S9xGetFilename(".srm", SRAM_DIR).c_str());
}

void SNES9X_SaveSRAM (void)
{
const char *sramFilename;
std::string sramFilename;

if (cartOpen)
{
sramFilename = S9xGetFilename(".srm", SRAM_DIR);
Memory.SaveSRAM(sramFilename);
ChangeTypeAndCreator(sramFilename, 'SRAM', '~9X~');
Memory.SaveSRAM(sramFilename.c_str());
ChangeTypeAndCreator(sramFilename.c_str(), 'SRAM', '~9X~');
}
}

Expand Down
12 changes: 8 additions & 4 deletions macosx/snes9x.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
3045A1EF22D03C4B0092B97D /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3045A1EE22D03C4B0092B97D /* Cocoa.framework */; };
304B364A262E328400F8DC8E /* S9xControlsPreferencesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 304B3649262E328400F8DC8E /* S9xControlsPreferencesViewController.xib */; };
304B366C262E82B800F8DC8E /* S9xPreferencesConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 304B366B262E82B800F8DC8E /* S9xPreferencesConstants.m */; };
3059DA94250690DB003EF183 /* compat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3059DA93250690DB003EF183 /* compat.cpp */; };
30656200236A8BA700A1B3B2 /* gamecontrollerdb.txt in Resources */ = {isa = PBXBuildFile; fileRef = 306561FF236A8BA700A1B3B2 /* gamecontrollerdb.txt */; };
306937CA2635EE5800007ABB /* S9xDisplayPreferencesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 306937C82635EE5800007ABB /* S9xDisplayPreferencesViewController.m */; };
306937CB2635EE5800007ABB /* S9xDisplayPreferencesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 306937C92635EE5800007ABB /* S9xDisplayPreferencesViewController.xib */; };
Expand Down Expand Up @@ -60,6 +59,8 @@
307C863022D29E29001B879E /* mac-render.mm in Sources */ = {isa = PBXBuildFile; fileRef = EA942A50059B0F9000D7D022 /* mac-render.mm */; };
307C863222D29E29001B879E /* mac-snes9x.mm in Sources */ = {isa = PBXBuildFile; fileRef = EAECB68604AC7FCE00A80003 /* mac-snes9x.mm */; };
307C863322D29E29001B879E /* mac-stringtools.mm in Sources */ = {isa = PBXBuildFile; fileRef = EAECB68804AC7FCE00A80003 /* mac-stringtools.mm */; };
307DB16C29B8421800378ADE /* fscompat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 307DB16A29B8421800378ADE /* fscompat.cpp */; };
307DB16D29B8421800378ADE /* fscompat.h in Headers */ = {isa = PBXBuildFile; fileRef = 307DB16B29B8421800378ADE /* fscompat.h */; };
308092F72320B041006A2860 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 308092F62320B041006A2860 /* CoreGraphics.framework */; };
308092F92320B06F006A2860 /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 308092F82320B06F006A2860 /* Quartz.framework */; };
30823CD92379200700EA2331 /* snes9x_framework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30D15CEF22CE6B5A005BC352 /* snes9x_framework.framework */; };
Expand Down Expand Up @@ -278,7 +279,6 @@
304B3649262E328400F8DC8E /* S9xControlsPreferencesViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = S9xControlsPreferencesViewController.xib; sourceTree = "<group>"; };
304B366A262E82B800F8DC8E /* S9xPreferencesConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = S9xPreferencesConstants.h; sourceTree = "<group>"; };
304B366B262E82B800F8DC8E /* S9xPreferencesConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = S9xPreferencesConstants.m; sourceTree = "<group>"; };
3059DA93250690DB003EF183 /* compat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = compat.cpp; sourceTree = "<group>"; };
306561FF236A8BA700A1B3B2 /* gamecontrollerdb.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = gamecontrollerdb.txt; sourceTree = "<group>"; };
306937C72635EE5800007ABB /* S9xDisplayPreferencesViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = S9xDisplayPreferencesViewController.h; sourceTree = "<group>"; };
306937C82635EE5800007ABB /* S9xDisplayPreferencesViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = S9xDisplayPreferencesViewController.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -311,6 +311,8 @@
307C861022D27C53001B879E /* tileimpl-h2x1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "tileimpl-h2x1.cpp"; sourceTree = "<group>"; usesTabs = 1; };
307C861A22D29D6D001B879E /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
307C861C22D29DD2001B879E /* GLUT.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLUT.framework; path = System/Library/Frameworks/GLUT.framework; sourceTree = SDKROOT; };
307DB16A29B8421800378ADE /* fscompat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fscompat.cpp; sourceTree = "<group>"; };
307DB16B29B8421800378ADE /* fscompat.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = fscompat.h; sourceTree = "<group>"; };
308092F62320B041006A2860 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
308092F82320B06F006A2860 /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = System/Library/Frameworks/Quartz.framework; sourceTree = SDKROOT; };
3082C41E2378BCE80081CA7C /* FakeHandles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FakeHandles.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -883,7 +885,6 @@
EAE061640526CCB900A80003 /* cheats.h */,
EAE061650526CCB900A80003 /* cheats2.cpp */,
EAE061660526CCB900A80003 /* clip.cpp */,
3059DA93250690DB003EF183 /* compat.cpp */,
EA809E9908F8D7240072CDFB /* controls.cpp */,
EA809E9308F8D6C40072CDFB /* controls.h */,
EAE061690526CCB900A80003 /* cpu.cpp */,
Expand All @@ -908,6 +909,8 @@
CF5D3E1C0FAFD35400340007 /* dsp4.cpp */,
CF5553B00EA24C36005957E4 /* filter */,
EAE0617A0526CCB900A80003 /* font.h */,
307DB16A29B8421800378ADE /* fscompat.cpp */,
307DB16B29B8421800378ADE /* fscompat.h */,
EAE0617C0526CCB900A80003 /* fxemu.cpp */,
EAE0617D0526CCB900A80003 /* fxemu.h */,
EAE0617E0526CCB900A80003 /* fxinst.cpp */,
Expand Down Expand Up @@ -1134,6 +1137,7 @@
30D15DD322CE6BC9005BC352 /* snes_ntsc_config.h in Headers */,
30D15DD422CE6BC9005BC352 /* snes_ntsc_impl.h in Headers */,
30D15DD522CE6BC9005BC352 /* 7z.h in Headers */,
307DB16D29B8421800378ADE /* fscompat.h in Headers */,
30D15DD622CE6BC9005BC352 /* aribitcd.h in Headers */,
30D15DD722CE6BC9005BC352 /* ariconst.h in Headers */,
30CF849727AEFD4F002B37A9 /* mac-cheat.h in Headers */,
Expand Down Expand Up @@ -1350,6 +1354,7 @@
307C861622D27C53001B879E /* tileimpl-n2x1.cpp in Sources */,
30D15D3C22CE6B74005BC352 /* dsp2.cpp in Sources */,
30D15D3D22CE6B74005BC352 /* dsp3.cpp in Sources */,
307DB16C29B8421800378ADE /* fscompat.cpp in Sources */,
30D15D3E22CE6B74005BC352 /* dsp4.cpp in Sources */,
30D15D3F22CE6B74005BC352 /* fxemu.cpp in Sources */,
30D15D4022CE6B74005BC352 /* fxinst.cpp in Sources */,
Expand Down Expand Up @@ -1393,7 +1398,6 @@
307C861822D27C53001B879E /* tileimpl-h2x1.cpp in Sources */,
30D15D8E22CE6B75005BC352 /* s9x-jma.cpp in Sources */,
30D15D8F22CE6B75005BC352 /* winout.cpp in Sources */,
3059DA94250690DB003EF183 /* compat.cpp in Sources */,
30D15D9322CE6B75005BC352 /* ioapi.c in Sources */,
30D15D9422CE6B75005BC352 /* unzip.c in Sources */,
);
Expand Down

0 comments on commit cea5148

Please sign in to comment.