mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-27 13:04:21 +01:00
fix cheats not working
This commit is contained in:
parent
a9f851a19f
commit
1e55157a6e
@ -32,8 +32,7 @@ static bool LoadCheatFile (int length)
|
|||||||
uint8 data [28];
|
uint8 data [28];
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
while (offset < length)
|
while (offset < length) {
|
||||||
{
|
|
||||||
if(Cheat.g.size() >= MAX_CHEATS || (length - offset) < 28)
|
if(Cheat.g.size() >= MAX_CHEATS || (length - offset) < 28)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -43,7 +42,6 @@ static bool LoadCheatFile (int length)
|
|||||||
SCheat c;
|
SCheat c;
|
||||||
char name[21];
|
char name[21];
|
||||||
char cheat[10];
|
char cheat[10];
|
||||||
c.enabled = (data[0] & 4) == 0;
|
|
||||||
c.byte = data[1];
|
c.byte = data[1];
|
||||||
c.address = data[2] | (data[3] << 8) | (data[4] << 16);
|
c.address = data[2] | (data[3] << 8) | (data[4] << 16);
|
||||||
memcpy (name, &data[8], 20);
|
memcpy (name, &data[8], 20);
|
||||||
@ -55,6 +53,23 @@ static bool LoadCheatFile (int length)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToggleCheat(uint32 num) {
|
||||||
|
if(Cheat.g[num].enabled) {
|
||||||
|
S9xDisableCheatGroup(num);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
S9xEnableCheatGroup(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0; i < Cheat.g.size(); i++) {
|
||||||
|
if(Cheat.g[i].enabled) {
|
||||||
|
Cheat.enabled = TRUE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Cheat.enabled = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* SetupCheats
|
* SetupCheats
|
||||||
*
|
*
|
||||||
@ -64,8 +79,6 @@ static bool LoadCheatFile (int length)
|
|||||||
void
|
void
|
||||||
WiiSetupCheats()
|
WiiSetupCheats()
|
||||||
{
|
{
|
||||||
S9xDeleteCheats();
|
|
||||||
|
|
||||||
char filepath[1024];
|
char filepath[1024];
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include "snes9x/cheats.h"
|
#include "snes9x/cheats.h"
|
||||||
|
|
||||||
extern SCheatData Cheat;
|
extern SCheatData Cheat;
|
||||||
|
extern void ToggleCheat(uint32);
|
||||||
|
|
||||||
#define THREAD_SLEEP 100
|
#define THREAD_SLEEP 100
|
||||||
|
|
||||||
@ -2148,10 +2149,7 @@ static int MenuGameCheats()
|
|||||||
|
|
||||||
if(ret >= 0)
|
if(ret >= 0)
|
||||||
{
|
{
|
||||||
if(Cheat.g[ret].enabled)
|
ToggleCheat(ret);
|
||||||
S9xDisableCheatGroup(ret);
|
|
||||||
else
|
|
||||||
S9xEnableCheatGroup(ret);
|
|
||||||
sprintf (options.value[ret], "%s", Cheat.g[ret].enabled == true ? "On" : "Off");
|
sprintf (options.value[ret], "%s", Cheat.g[ret].enabled == true ? "On" : "Off");
|
||||||
optionBrowser.TriggerUpdate();
|
optionBrowser.TriggerUpdate();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user