mirror of https://github.com/snes9xgit/snes9x.git
macOS: try to use new cheat commands (incomplete format support)
This commit is contained in:
parent
6f00d63116
commit
77c30172a4
|
@ -243,7 +243,7 @@ typedef struct
|
||||||
|
|
||||||
static WindowRef wRef;
|
static WindowRef wRef;
|
||||||
static HIViewRef dbRef;
|
static HIViewRef dbRef;
|
||||||
static CheatItem citem[MAX_CHEATS];
|
static CheatItem citem[MAC_MAX_CHEATS];
|
||||||
static uint32 numofcheats;
|
static uint32 numofcheats;
|
||||||
|
|
||||||
static void InitCheatItems (void);
|
static void InitCheatItems (void);
|
||||||
|
@ -260,7 +260,7 @@ static pascal OSStatus CheatEventHandler (EventHandlerCallRef, EventRef, void *)
|
||||||
|
|
||||||
static void InitCheatItems (void)
|
static void InitCheatItems (void)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < MAX_CHEATS; i++)
|
for (unsigned int i = 0; i < MAC_MAX_CHEATS; i++)
|
||||||
{
|
{
|
||||||
citem[i].id = i + 1;
|
citem[i].id = i + 1;
|
||||||
citem[i].valid = false;
|
citem[i].valid = false;
|
||||||
|
@ -273,30 +273,33 @@ static void InitCheatItems (void)
|
||||||
|
|
||||||
static void ImportCheatItems (void)
|
static void ImportCheatItems (void)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < Cheat.num_cheats; i++)
|
int cheat_num = std::min(Cheat.g.size(), MAC_MAX_CHEATS);
|
||||||
|
for (unsigned int i = 0; i < cheat_num; i++)
|
||||||
{
|
{
|
||||||
citem[i].valid = true;
|
citem[i].valid = true;
|
||||||
citem[i].enabled = Cheat.c[i].enabled;
|
citem[i].enabled = Cheat.g[i].enabled;
|
||||||
citem[i].address = Cheat.c[i].address;
|
citem[i].address = Cheat.g[i].c[0].address; // mac dialog only supports one cheat per group at the moment
|
||||||
citem[i].value = Cheat.c[i].byte;
|
citem[i].value = Cheat.g[i].c[0].byte;
|
||||||
strcpy(citem[i].description, Cheat.c[i].name);
|
strncpy(citem[i].description, Cheat.g[i].name, 21);
|
||||||
|
citem[i].description[21] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DetachCheatItems (void)
|
static void DetachCheatItems (void)
|
||||||
{
|
{
|
||||||
S9xDeleteCheats(); // Cheat.num_cheats = 0
|
S9xDeleteCheats();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < MAX_CHEATS; i++)
|
for (unsigned int i = 0; i < MAC_MAX_CHEATS; i++)
|
||||||
{
|
{
|
||||||
if (citem[i].valid)
|
if (citem[i].valid)
|
||||||
{
|
{
|
||||||
strcpy(Cheat.c[Cheat.num_cheats].name, citem[i].description);
|
char code[10];
|
||||||
S9xAddCheat(citem[i].enabled, false, citem[i].address, citem[i].value); // Cheat.num_cheats++
|
snprintf(code, 10, "%x=%x", citem[i].address, citem[i].value);
|
||||||
|
int index = S9xAddCheatGroup(citem[i].description, code);
|
||||||
|
if(citem[i].enabled)
|
||||||
|
S9xEnableCheatGroup(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
S9xApplyCheats();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureCheat (void)
|
void ConfigureCheat (void)
|
||||||
|
@ -355,13 +358,13 @@ void ConfigureCheat (void)
|
||||||
|
|
||||||
DataBrowserItemID *id;
|
DataBrowserItemID *id;
|
||||||
|
|
||||||
id = new DataBrowserItemID[MAX_CHEATS];
|
id = new DataBrowserItemID[MAC_MAX_CHEATS];
|
||||||
if (!id)
|
if (!id)
|
||||||
QuitWithFatalError(0, "cheat 01");
|
QuitWithFatalError(0, "cheat 01");
|
||||||
|
|
||||||
numofcheats = 0;
|
numofcheats = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < MAX_CHEATS; i++)
|
for (unsigned int i = 0; i < MAC_MAX_CHEATS; i++)
|
||||||
{
|
{
|
||||||
if (citem[i].valid)
|
if (citem[i].valid)
|
||||||
{
|
{
|
||||||
|
@ -377,7 +380,7 @@ void ConfigureCheat (void)
|
||||||
|
|
||||||
cid.signature = kNewButton;
|
cid.signature = kNewButton;
|
||||||
HIViewFindByID(root, cid, &ctl);
|
HIViewFindByID(root, cid, &ctl);
|
||||||
if (numofcheats == MAX_CHEATS)
|
if (numofcheats == MAC_MAX_CHEATS)
|
||||||
err = DeactivateControl(ctl);
|
err = DeactivateControl(ctl);
|
||||||
else
|
else
|
||||||
err = ActivateControl(ctl);
|
err = ActivateControl(ctl);
|
||||||
|
@ -428,14 +431,14 @@ static void AddCheatItem (void)
|
||||||
DataBrowserItemID id[1];
|
DataBrowserItemID id[1];
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (numofcheats == MAX_CHEATS)
|
if (numofcheats == MAC_MAX_CHEATS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < MAX_CHEATS; i++)
|
for (i = 0; i < MAC_MAX_CHEATS; i++)
|
||||||
if (citem[i].valid == false)
|
if (citem[i].valid == false)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (i == MAX_CHEATS)
|
if (i == MAC_MAX_CHEATS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
numofcheats++;
|
numofcheats++;
|
||||||
|
@ -452,7 +455,7 @@ static void AddCheatItem (void)
|
||||||
root = HIViewGetRoot(wRef);
|
root = HIViewGetRoot(wRef);
|
||||||
cid.id = 0;
|
cid.id = 0;
|
||||||
|
|
||||||
if (numofcheats == MAX_CHEATS)
|
if (numofcheats == MAC_MAX_CHEATS)
|
||||||
{
|
{
|
||||||
cid.signature = kNewButton;
|
cid.signature = kNewButton;
|
||||||
HIViewFindByID(root, cid, &ctl);
|
HIViewFindByID(root, cid, &ctl);
|
||||||
|
@ -502,7 +505,7 @@ static void DeleteCheatItem (void)
|
||||||
root = HIViewGetRoot(wRef);
|
root = HIViewGetRoot(wRef);
|
||||||
cid.id = 0;
|
cid.id = 0;
|
||||||
|
|
||||||
if (numofcheats < MAX_CHEATS)
|
if (numofcheats < MAC_MAX_CHEATS)
|
||||||
{
|
{
|
||||||
cid.signature = kNewButton;
|
cid.signature = kNewButton;
|
||||||
HIViewFindByID(root, cid, &ctl);
|
HIViewFindByID(root, cid, &ctl);
|
||||||
|
@ -521,7 +524,7 @@ static void EnableAllCheatItems (void)
|
||||||
{
|
{
|
||||||
OSStatus err;
|
OSStatus err;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < MAX_CHEATS; i++)
|
for (unsigned int i = 0; i < MAC_MAX_CHEATS; i++)
|
||||||
if (citem[i].valid)
|
if (citem[i].valid)
|
||||||
citem[i].enabled = true;
|
citem[i].enabled = true;
|
||||||
|
|
||||||
|
|
|
@ -1297,7 +1297,7 @@ static void CheatFinderHandleAddEntryButton (WindowData *cf)
|
||||||
if (cfAddress[cfListSelection] > (0x20000 - cfViewNumBytes))
|
if (cfAddress[cfListSelection] > (0x20000 - cfViewNumBytes))
|
||||||
PlayAlertSound();
|
PlayAlertSound();
|
||||||
else
|
else
|
||||||
if (Cheat.num_cheats + cfViewNumBytes > MAX_CHEATS)
|
if (Cheat.g.size() + cfViewNumBytes > MAX_CHEATS)
|
||||||
AppearanceAlert(kAlertCautionAlert, kS9xMacAlertCFCantAddEntry, kS9xMacAlertCFCantAddEntryHint);
|
AppearanceAlert(kAlertCautionAlert, kS9xMacAlertCFCantAddEntry, kS9xMacAlertCFCantAddEntryHint);
|
||||||
else
|
else
|
||||||
CheatFinderBeginAddEntrySheet(cf);
|
CheatFinderBeginAddEntrySheet(cf);
|
||||||
|
@ -1467,11 +1467,11 @@ static void CheatFinderAddEntry (SInt64 value, char *description)
|
||||||
|
|
||||||
for (unsigned int i = 0; i < cfViewNumBytes; i++)
|
for (unsigned int i = 0; i < cfViewNumBytes; i++)
|
||||||
{
|
{
|
||||||
strcpy(Cheat.c[Cheat.num_cheats].name, description);
|
char code[10];
|
||||||
S9xAddCheat(true, true, addr + i + 0x7E0000, (UInt8) ((v & (0x000000FF << (i * 8))) >> (i * 8)));
|
snprintf(code, 10, "%x=%x", addr + i + 0x7E0000, (UInt8) ((v & (0x000000FF << (i * 8))) >> (i * 8)));
|
||||||
|
int index = S9xAddCheatGroup(description, code);
|
||||||
|
S9xEnableCheatGroup(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
S9xApplyCheats();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static pascal OSStatus CheatFinderListFrameEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *userData)
|
static pascal OSStatus CheatFinderListFrameEventHandler (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *userData)
|
||||||
|
|
|
@ -296,6 +296,7 @@ typedef struct
|
||||||
|
|
||||||
#define kMacWindowHeight (SNES_HEIGHT_EXTENDED << 1)
|
#define kMacWindowHeight (SNES_HEIGHT_EXTENDED << 1)
|
||||||
#define MAC_MAX_PLAYERS 8
|
#define MAC_MAX_PLAYERS 8
|
||||||
|
#define MAC_MAX_CHEATS 150
|
||||||
|
|
||||||
extern volatile bool8 running, s9xthreadrunning;
|
extern volatile bool8 running, s9xthreadrunning;
|
||||||
extern volatile bool8 eventQueued, windowExtend;
|
extern volatile bool8 eventQueued, windowExtend;
|
||||||
|
|
|
@ -1794,9 +1794,9 @@ static OSStatus HandleMenuChoice (UInt32 command, Boolean *done)
|
||||||
Settings.ApplyCheats = applycheat;
|
Settings.ApplyCheats = applycheat;
|
||||||
|
|
||||||
if (!Settings.ApplyCheats)
|
if (!Settings.ApplyCheats)
|
||||||
S9xRemoveCheats();
|
S9xCheatsDisable();
|
||||||
else
|
else
|
||||||
S9xApplyCheats();
|
S9xCheatsEnable();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
85FEF90820DDB15C00C038E9 /* bml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85FEF90620DDB15B00C038E9 /* bml.cpp */; };
|
||||||
|
85FEF90920DDB15C00C038E9 /* bml.h in Headers */ = {isa = PBXBuildFile; fileRef = 85FEF90720DDB15C00C038E9 /* bml.h */; };
|
||||||
|
85FEF90C20DDB18E00C038E9 /* sha256.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85FEF90A20DDB18D00C038E9 /* sha256.cpp */; };
|
||||||
|
85FEF90D20DDB18E00C038E9 /* sha256.h in Headers */ = {isa = PBXBuildFile; fileRef = 85FEF90B20DDB18D00C038E9 /* sha256.h */; };
|
||||||
BF0B39AF1FA5792F002B04D3 /* apu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BF0B397A1FA5792F002B04D3 /* apu.cpp */; };
|
BF0B39AF1FA5792F002B04D3 /* apu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BF0B397A1FA5792F002B04D3 /* apu.cpp */; };
|
||||||
BF0B39B01FA5792F002B04D3 /* apu.h in Headers */ = {isa = PBXBuildFile; fileRef = BF0B397B1FA5792F002B04D3 /* apu.h */; };
|
BF0B39B01FA5792F002B04D3 /* apu.h in Headers */ = {isa = PBXBuildFile; fileRef = BF0B397B1FA5792F002B04D3 /* apu.h */; };
|
||||||
BF0B39B11FA5792F002B04D3 /* blargg_common.h in Headers */ = {isa = PBXBuildFile; fileRef = BF0B397E1FA5792F002B04D3 /* blargg_common.h */; };
|
BF0B39B11FA5792F002B04D3 /* blargg_common.h in Headers */ = {isa = PBXBuildFile; fileRef = BF0B397E1FA5792F002B04D3 /* blargg_common.h */; };
|
||||||
|
@ -712,6 +716,10 @@
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
20286C33FDCF999611CA2CEA /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
|
20286C33FDCF999611CA2CEA /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
|
||||||
|
85FEF90620DDB15B00C038E9 /* bml.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bml.cpp; sourceTree = "<group>"; };
|
||||||
|
85FEF90720DDB15C00C038E9 /* bml.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bml.h; sourceTree = "<group>"; };
|
||||||
|
85FEF90A20DDB18D00C038E9 /* sha256.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sha256.cpp; sourceTree = "<group>"; };
|
||||||
|
85FEF90B20DDB18D00C038E9 /* sha256.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sha256.h; sourceTree = "<group>"; };
|
||||||
BF0B397A1FA5792F002B04D3 /* apu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = apu.cpp; sourceTree = "<group>"; };
|
BF0B397A1FA5792F002B04D3 /* apu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = apu.cpp; sourceTree = "<group>"; };
|
||||||
BF0B397B1FA5792F002B04D3 /* apu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = apu.h; sourceTree = "<group>"; };
|
BF0B397B1FA5792F002B04D3 /* apu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = apu.h; sourceTree = "<group>"; };
|
||||||
BF0B397E1FA5792F002B04D3 /* blargg_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blargg_common.h; sourceTree = "<group>"; };
|
BF0B397E1FA5792F002B04D3 /* blargg_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blargg_common.h; sourceTree = "<group>"; };
|
||||||
|
@ -1180,6 +1188,10 @@
|
||||||
EAE061540526CCB900A80003 /* snes9x */ = {
|
EAE061540526CCB900A80003 /* snes9x */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
85FEF90A20DDB18D00C038E9 /* sha256.cpp */,
|
||||||
|
85FEF90B20DDB18D00C038E9 /* sha256.h */,
|
||||||
|
85FEF90620DDB15B00C038E9 /* bml.cpp */,
|
||||||
|
85FEF90720DDB15C00C038E9 /* bml.h */,
|
||||||
EAE0615A0526CCB900A80003 /* 65c816.h */,
|
EAE0615A0526CCB900A80003 /* 65c816.h */,
|
||||||
EA2F381A09B17E9E0078DCA7 /* bsx.h */,
|
EA2F381A09B17E9E0078DCA7 /* bsx.h */,
|
||||||
EAE061600526CCB900A80003 /* c4.h */,
|
EAE061600526CCB900A80003 /* c4.h */,
|
||||||
|
@ -1523,6 +1535,7 @@
|
||||||
CF5D3E130FAFD34200340007 /* dsp.h in Headers */,
|
CF5D3E130FAFD34200340007 /* dsp.h in Headers */,
|
||||||
BF0B39DA1FA5792F002B04D3 /* snes.hpp in Headers */,
|
BF0B39DA1FA5792F002B04D3 /* snes.hpp in Headers */,
|
||||||
CF05669D0CF98E7E00C7877C /* font.h in Headers */,
|
CF05669D0CF98E7E00C7877C /* font.h in Headers */,
|
||||||
|
85FEF90D20DDB18E00C038E9 /* sha256.h in Headers */,
|
||||||
CF05669E0CF98E7E00C7877C /* fxemu.h in Headers */,
|
CF05669E0CF98E7E00C7877C /* fxemu.h in Headers */,
|
||||||
CF05669F0CF98E7E00C7877C /* fxinst.h in Headers */,
|
CF05669F0CF98E7E00C7877C /* fxinst.h in Headers */,
|
||||||
CF0566A00CF98E7E00C7877C /* getset.h in Headers */,
|
CF0566A00CF98E7E00C7877C /* getset.h in Headers */,
|
||||||
|
@ -1557,6 +1570,7 @@
|
||||||
CFEFAE9710EAC92B00FB081A /* snes_ntsc_config.h in Headers */,
|
CFEFAE9710EAC92B00FB081A /* snes_ntsc_config.h in Headers */,
|
||||||
CFEFAE9810EAC92B00FB081A /* snes_ntsc_impl.h in Headers */,
|
CFEFAE9810EAC92B00FB081A /* snes_ntsc_impl.h in Headers */,
|
||||||
BF0B39B11FA5792F002B04D3 /* blargg_common.h in Headers */,
|
BF0B39B11FA5792F002B04D3 /* blargg_common.h in Headers */,
|
||||||
|
85FEF90920DDB15C00C038E9 /* bml.h in Headers */,
|
||||||
CFA518E80EBCB5B1008379F6 /* crypt.h in Headers */,
|
CFA518E80EBCB5B1008379F6 /* crypt.h in Headers */,
|
||||||
BF0B39B31FA5792F002B04D3 /* blargg_endian.h in Headers */,
|
BF0B39B31FA5792F002B04D3 /* blargg_endian.h in Headers */,
|
||||||
CFA518D90EBCB4CA008379F6 /* ioapi.h in Headers */,
|
CFA518D90EBCB4CA008379F6 /* ioapi.h in Headers */,
|
||||||
|
@ -2110,10 +2124,12 @@
|
||||||
CF05673E0CF98E7E00C7877C /* mac-client.cpp in Sources */,
|
CF05673E0CF98E7E00C7877C /* mac-client.cpp in Sources */,
|
||||||
CF05673F0CF98E7E00C7877C /* mac-cocoatools.mm in Sources */,
|
CF05673F0CF98E7E00C7877C /* mac-cocoatools.mm in Sources */,
|
||||||
CF0567400CF98E7E00C7877C /* mac-controls.cpp in Sources */,
|
CF0567400CF98E7E00C7877C /* mac-controls.cpp in Sources */,
|
||||||
|
85FEF90820DDB15C00C038E9 /* bml.cpp in Sources */,
|
||||||
CF0567410CF98E7E00C7877C /* mac-coreimage.mm in Sources */,
|
CF0567410CF98E7E00C7877C /* mac-coreimage.mm in Sources */,
|
||||||
CF0567420CF98E7E00C7877C /* mac-dialog.cpp in Sources */,
|
CF0567420CF98E7E00C7877C /* mac-dialog.cpp in Sources */,
|
||||||
CF0567440CF98E7E00C7877C /* mac-file.cpp in Sources */,
|
CF0567440CF98E7E00C7877C /* mac-file.cpp in Sources */,
|
||||||
CF0567450CF98E7E00C7877C /* mac-gworld.cpp in Sources */,
|
CF0567450CF98E7E00C7877C /* mac-gworld.cpp in Sources */,
|
||||||
|
85FEF90C20DDB18E00C038E9 /* sha256.cpp in Sources */,
|
||||||
CF0567470CF98E7E00C7877C /* mac-joypad.cpp in Sources */,
|
CF0567470CF98E7E00C7877C /* mac-joypad.cpp in Sources */,
|
||||||
CF0567480CF98E7E00C7877C /* mac-keyboard.cpp in Sources */,
|
CF0567480CF98E7E00C7877C /* mac-keyboard.cpp in Sources */,
|
||||||
CF0567490CF98E7E00C7877C /* mac-multicart.cpp in Sources */,
|
CF0567490CF98E7E00C7877C /* mac-multicart.cpp in Sources */,
|
||||||
|
@ -2315,7 +2331,7 @@
|
||||||
);
|
);
|
||||||
LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)\"";
|
LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)\"";
|
||||||
PRODUCT_NAME = Snes9x;
|
PRODUCT_NAME = Snes9x;
|
||||||
SDKROOT = macosx10.6;
|
SDKROOT = macosx10.11;
|
||||||
WARNING_CFLAGS = "-Wfloat-equal";
|
WARNING_CFLAGS = "-Wfloat-equal";
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
|
@ -2516,7 +2532,7 @@
|
||||||
"-fast",
|
"-fast",
|
||||||
);
|
);
|
||||||
PRODUCT_NAME = Snes9x;
|
PRODUCT_NAME = Snes9x;
|
||||||
SDKROOT = macosx10.6;
|
SDKROOT = macosx10.11;
|
||||||
WARNING_CFLAGS = "-Wfloat-equal";
|
WARNING_CFLAGS = "-Wfloat-equal";
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
|
|
Loading…
Reference in New Issue