Skip to content

Commit

Permalink
Merge branch 'finalburnneo-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
barbudreadmon committed May 1, 2021
2 parents 7da9d6e + 9df3a7e commit e468e2e
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 75 deletions.
101 changes: 65 additions & 36 deletions src/burn/cheat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

#define CHEAT_MAXCPU 8 // enough?

#define HW_NES ( ((BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_NES) || ((BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_FDS) )
void nes_add_cheat(char *code); // from drv/nes/d_nes.cpp
void nes_remove_cheat(char *code);

bool bCheatsAllowed;
CheatInfo* pCheatInfo = NULL;
Expand Down Expand Up @@ -106,6 +109,21 @@ INT32 CheatUpdate()
return 0;
}

static void NESCheatDisable(CheatInfo* pCurrentCheat, INT32 nCheat)
{
// Deactivate old option (if any)
CheatAddressInfo* pAddressInfo = pCurrentCheat->pOption[pCurrentCheat->nCurrent]->AddressInfo;

while (pAddressInfo->nAddress) {
if (HW_NES) {
// Disable Game Genie code
bprintf(0, _T("NES-Cheat #%d, option #%d: "), nCheat, pCurrentCheat->nCurrent);
nes_remove_cheat(pAddressInfo->szGenieCode);
}
pAddressInfo++;
}
}

INT32 CheatEnable(INT32 nCheat, INT32 nOption) // -1 / 0 - disable
{
INT32 nCurrentCheat = 0;
Expand Down Expand Up @@ -138,6 +156,12 @@ INT32 CheatEnable(INT32 nCheat, INT32 nOption) // -1 / 0 - disable
return 0;
}

if (HW_NES && pCurrentCheat->nCurrent != nOption) {
// NES: going from one option to the next in a list, must deactivate
// previous option before selecting the next, unless we're coming from default.
NESCheatDisable(pCurrentCheat, nCheat);
}

if (deactivate) { // disable cheat option
if (pCurrentCheat->nType != 1) {
nOption = 1; // Set to the first option as there is no addressinfo associated with default (disabled) cheat entry. -dink
Expand Down Expand Up @@ -185,47 +209,52 @@ INT32 CheatEnable(INT32 nCheat, INT32 nOption) // -1 / 0 - disable

pCurrentCheat->bModified = 0;

// Copy the original values
pAddressInfo->nOriginalValue = cheat_subptr->read(pAddressInfo->nAddress);

bprintf(0, _T("Cheat #%d, option #%d. action: "), nCheat, nOption);
if (pCurrentCheat->bWatchMode) {
bprintf(0, _T("Watch memory @ 0x%X (0x%X)\n"), pAddressInfo->nAddress, pAddressInfo->nOriginalValue);
} else
if (pCurrentCheat->bOneShot) {
bprintf(0, _T("Apply cheat @ 0x%X -> 0x%X. (Before 0x%X - One-Shot mode)\n"), pAddressInfo->nAddress, pAddressInfo->nValue, pAddressInfo->nOriginalValue);
pCurrentCheat->bOneShot = 3; // re-load the one-shot frame counter
if (HW_NES) {
bprintf(0, _T("NES-Cheat #%d, option #%d: "), nCheat, nOption);
nes_add_cheat(pAddressInfo->szGenieCode);
} else {
if (pAddressInfo->bRelAddress) {
const TCHAR nBits[4][8] = { { _T("8-bit") }, { _T("16-bit") }, { _T("24-bit") }, { _T("32-bit") } };
if (pAddressInfo->nMultiByte) {
bprintf(0, _T("Apply cheat @ %s pointer ([0x%X] + 0x%x + %x) -> 0x%X.\n"), nBits[pAddressInfo->nRelAddressBits & 3], pAddressInfo->nAddress, pAddressInfo->nRelAddressOffset, pAddressInfo->nMultiByte, pAddressInfo->nValue);
// Copy the original values
pAddressInfo->nOriginalValue = cheat_subptr->read(pAddressInfo->nAddress);

bprintf(0, _T("Cheat #%d, option #%d. action: "), nCheat, nOption);
if (pCurrentCheat->bWatchMode) {
bprintf(0, _T("Watch memory @ 0x%X (0x%X)\n"), pAddressInfo->nAddress, pAddressInfo->nOriginalValue);
} else
if (pCurrentCheat->bOneShot) {
bprintf(0, _T("Apply cheat @ 0x%X -> 0x%X. (Before 0x%X - One-Shot mode)\n"), pAddressInfo->nAddress, pAddressInfo->nValue, pAddressInfo->nOriginalValue);
pCurrentCheat->bOneShot = 3; // re-load the one-shot frame counter
} else {
bprintf(0, _T("Apply cheat @ %s pointer ([0x%X] + 0x%x) -> 0x%X.\n"), nBits[pAddressInfo->nRelAddressBits & 3], pAddressInfo->nAddress, pAddressInfo->nRelAddressOffset, pAddressInfo->nValue);
if (pAddressInfo->bRelAddress) {
const TCHAR nBits[4][8] = { { _T("8-bit") }, { _T("16-bit") }, { _T("24-bit") }, { _T("32-bit") } };
if (pAddressInfo->nMultiByte) {
bprintf(0, _T("Apply cheat @ %s pointer ([0x%X] + 0x%x + %x) -> 0x%X.\n"), nBits[pAddressInfo->nRelAddressBits & 3], pAddressInfo->nAddress, pAddressInfo->nRelAddressOffset, pAddressInfo->nMultiByte, pAddressInfo->nValue);
} else {
bprintf(0, _T("Apply cheat @ %s pointer ([0x%X] + 0x%x) -> 0x%X.\n"), nBits[pAddressInfo->nRelAddressBits & 3], pAddressInfo->nAddress, pAddressInfo->nRelAddressOffset, pAddressInfo->nValue);
}
} else {
// normal cheat
bprintf(0, _T("Apply cheat @ 0x%X -> 0x%X. (Undo 0x%X)\n"), pAddressInfo->nAddress, pAddressInfo->nValue, pAddressInfo->nOriginalValue);
}
}
} else {
// normal cheat
bprintf(0, _T("Apply cheat @ 0x%X -> 0x%X. (Undo 0x%X)\n"), pAddressInfo->nAddress, pAddressInfo->nValue, pAddressInfo->nOriginalValue);
}
}
if (pCurrentCheat->bWaitForModification)
bprintf(0, _T(" - Triggered by: Waiting for modification!\n"));
if (pCurrentCheat->bWaitForModification)
bprintf(0, _T(" - Triggered by: Waiting for modification!\n"));

if (pCurrentCheat->nType != 0) { // not cheat.dat
if (pAddressInfo->nCPU != nOpenCPU) {
if (nOpenCPU != -1) {
cheat_subptr->close();
}
if (pCurrentCheat->nType != 0) { // not cheat.dat
if (pAddressInfo->nCPU != nOpenCPU) {
if (nOpenCPU != -1) {
cheat_subptr->close();
}

nOpenCPU = pAddressInfo->nCPU;
cheat_ptr = &cpus[nOpenCPU];
cheat_subptr = cheat_ptr->cpuconfig;
cheat_subptr->open(cheat_ptr->nCPU);
}
nOpenCPU = pAddressInfo->nCPU;
cheat_ptr = &cpus[nOpenCPU];
cheat_subptr = cheat_ptr->cpuconfig;
cheat_subptr->open(cheat_ptr->nCPU);
}

if (!pCurrentCheat->bWatchMode && !pCurrentCheat->bWaitForModification && !pAddressInfo->bRelAddress) {
// Activate the cheat
cheat_subptr->write(pAddressInfo->nAddress, pAddressInfo->nValue);
if (!pCurrentCheat->bWatchMode && !pCurrentCheat->bWaitForModification && !pAddressInfo->bRelAddress) {
// Activate the cheat
cheat_subptr->write(pAddressInfo->nAddress, pAddressInfo->nValue);
}
}
}

Expand Down Expand Up @@ -269,7 +298,7 @@ extern INT32 VidSNewTinyMsg(const TCHAR* pText, INT32 nRGB = 0, INT32 nDuration

INT32 CheatApply()
{
if (!bCheatsEnabled) {
if (!bCheatsEnabled || HW_NES) { // NES cheats use Game Genie codes
return 0;
}

Expand Down
1 change: 1 addition & 0 deletions src/burn/cheat.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct CheatAddressInfo {
INT32 bRelAddress; // Relative address (pointer offset) cheat, see :rdft2: or :dreamwld: in cheat.dat
INT32 nRelAddressOffset; // The offset
INT32 nRelAddressBits; // 0, 1, 2, 3 = 8, 16, 24, 32bit
char szGenieCode[0x10]; // Game Genie Code (NES)
};

struct CheatOption {
Expand Down
16 changes: 8 additions & 8 deletions src/burn/drv/midway/d_wunit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,11 +911,11 @@ struct BurnDriver BurnDrvUmk3te = {
};


// Ultimate Mortal Kombat 3 Cup Edition (2021-04-01)
// Ultimate Mortal Kombat 3 Cup Edition (2021-04-30)

static struct BurnRomInfo umk3ucRomDesc[] = {
{ "umk3uc-u54.bin", 0x080000, 0x14d9ece8, 1 | BRF_PRG | BRF_ESS }, // 0 TMS34010
{ "umk3uc-u63.bin", 0x080000, 0x336117ae, 1 | BRF_PRG | BRF_ESS }, // 1
{ "umk3uc-u54.bin", 0x080000, 0x26707d48, 1 | BRF_PRG | BRF_ESS }, // 0 TMS34010
{ "umk3uc-u63.bin", 0x080000, 0x57f16a4a, 1 | BRF_PRG | BRF_ESS }, // 1

{ "umk3uc-u2.bin", 0x100000, 0x3838cfe5, 2 | BRF_PRG | BRF_ESS }, // 2 DCS sound banks
{ "umk3uc-u3.bin", 0x100000, 0x856fe411, 2 | BRF_PRG | BRF_ESS }, // 3
Expand All @@ -942,10 +942,10 @@ static struct BurnRomInfo umk3ucRomDesc[] = {
{ "umk3uc-u119.bin", 0x100000, 0x948d4aa7, 3 | BRF_GRA | BRF_ESS | WUNIT_GFX(0x0c, 2) }, // 20
{ "umk3uc-u118.bin", 0x100000, 0xab7ca588, 3 | BRF_GRA | BRF_ESS | WUNIT_GFX(0x0c, 3) }, // 21

{ "umk3uc-u117.bin", 0x100000, 0x00c36b29, 3 | BRF_GRA | BRF_ESS | WUNIT_GFX(0x10, 0) }, // 22
{ "umk3uc-u116.bin", 0x100000, 0x8128d475, 3 | BRF_GRA | BRF_ESS | WUNIT_GFX(0x10, 1) }, // 23
{ "umk3uc-u115.bin", 0x100000, 0x6ec6376c, 3 | BRF_GRA | BRF_ESS | WUNIT_GFX(0x10, 2) }, // 24
{ "umk3uc-u114.bin", 0x100000, 0x7f22d1fd, 3 | BRF_GRA | BRF_ESS | WUNIT_GFX(0x10, 3) }, // 25
{ "umk3uc-u117.bin", 0x100000, 0x48a21834, 3 | BRF_GRA | BRF_ESS | WUNIT_GFX(0x10, 0) }, // 22
{ "umk3uc-u116.bin", 0x100000, 0x7a16b282, 3 | BRF_GRA | BRF_ESS | WUNIT_GFX(0x10, 1) }, // 23
{ "umk3uc-u115.bin", 0x100000, 0x32195ef2, 3 | BRF_GRA | BRF_ESS | WUNIT_GFX(0x10, 2) }, // 24
{ "umk3uc-u114.bin", 0x100000, 0xb15f13e1, 3 | BRF_GRA | BRF_ESS | WUNIT_GFX(0x10, 3) }, // 25

{ "umk3uc-u113.bin", 0x100000, 0xb352019b, 3 | BRF_GRA | BRF_ESS | WUNIT_GFX(0x14, 0) }, // 26
{ "umk3uc-u112.bin", 0x100000, 0x71143b7c, 3 | BRF_GRA | BRF_ESS | WUNIT_GFX(0x14, 1) }, // 27
Expand All @@ -960,7 +960,7 @@ STD_ROM_FN(umk3uc)

struct BurnDriver BurnDrvUmk3uc = {
"umk3uc", "umk3", NULL, NULL, "2021",
"Ultimate Mortal Kombat 3 Cup Edition (Hack, Ver. 2021-04-01)\0", NULL, "hack", "MIDWAY Wolf-Unit",
"Ultimate Mortal Kombat 3 Cup Edition (Hack, Ver. 2021-04-30)\0", NULL, "hack", "MIDWAY Wolf-Unit",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_HACK, 2, HARDWARE_MIDWAY_WUNIT, GBF_MISC, 0,
NULL, umk3ucRomInfo, umk3ucRomName, NULL, NULL, NULL, NULL, Mk3InputInfo, Mk3DIPInfo,
Expand Down
7 changes: 2 additions & 5 deletions src/burn/drv/nes/d_nes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9406,11 +9406,6 @@ static INT32 DrvDoReset()
}
}

//contra-test-nescheatengine
//nes_add_cheat("IPVGZGZE"); // 30 lives
//nes_add_cheat("AAVGTGZA"); // 1p2p 30 lives
//nes_add_cheat("SLAIUZ"); // invincible

return 0;
}

Expand All @@ -9420,6 +9415,8 @@ static INT32 NESInit()

NES_CPU_RAM = (UINT8*)BurnMalloc(0x800);

cheats_active = 0;

struct BurnRomInfo ri;
char *romname = NULL;
BurnDrvGetRomInfo(&ri, 0);
Expand Down
6 changes: 3 additions & 3 deletions src/burn/drv/pre90s/d_asteroids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ struct BurnDriver BurnDrvAstdelux = {
"astdelux", NULL, NULL, NULL, "1980",
"Asteroids Deluxe (rev 3)\0", NULL, "Atari", "Miscellaneous",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_SHOOT, 0,
BDF_GAME_WORKING, 2, HARDWARE_MISC_PRE90S, GBF_SHOOT, 0,
NULL, astdeluxRomInfo, astdeluxRomName, NULL, NULL, NULL, NULL, AstdeluxInputInfo, AstdeluxDIPInfo,
AstdeluxInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x2000,
640, 480, 4, 3
Expand All @@ -1632,7 +1632,7 @@ struct BurnDriver BurnDrvAstdelux2 = {
"astdelux2", "astdelux", NULL, NULL, "1980",
"Asteroids Deluxe (rev 2)\0", NULL, "Atari", "Miscellaneous",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_SHOOT, 0,
BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_PRE90S, GBF_SHOOT, 0,
NULL, astdelux2RomInfo, astdelux2RomName, NULL, NULL, NULL, NULL, AstdeluxInputInfo, AstdeluxDIPInfo,
AstdeluxInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x2000,
640, 480, 4, 3
Expand Down Expand Up @@ -1660,7 +1660,7 @@ struct BurnDriver BurnDrvAstdelux1 = {
"astdelux1", "astdelux", NULL, NULL, "1980",
"Asteroids Deluxe (rev 1)\0", NULL, "Atari", "Miscellaneous",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE | BDF_HISCORE_SUPPORTED, 2, HARDWARE_MISC_PRE90S, GBF_SHOOT, 0,
BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_PRE90S, GBF_SHOOT, 0,
NULL, astdelux1RomInfo, astdelux1RomName, NULL, NULL, NULL, NULL, AstdeluxInputInfo, AstdeluxDIPInfo,
AstdeluxInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 0x2000,
640, 480, 4, 3
Expand Down
65 changes: 42 additions & 23 deletions src/burner/conc.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "burner.h"

#define HW_NES ( ((BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_NES) || ((BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_FDS) )

static bool SkipComma(TCHAR** s)
{
while (**s && **s != _T(',')) {
Expand Down Expand Up @@ -226,29 +228,46 @@ static INT32 ConfigParseFile(TCHAR* pszFilename)
INT32 nCPU = 0, nAddress = 0, nValue = 0;

if (SkipComma(&s)) {
nCPU = _tcstol(s, &t, 0); // CPU number
if (t == s) {
CheatError(pszFilename, nLine, pCurrentCheat, _T("CPU number omitted"), szLine);
bOK = false;
break;
}
s = t;

SkipComma(&s);
nAddress = _tcstol(s, &t, 0); // Address
if (t == s) {
bOK = false;
CheatError(pszFilename, nLine, pCurrentCheat, _T("address omitted"), szLine);
break;
}
s = t;

SkipComma(&s);
nValue = _tcstol(s, &t, 0); // Value
if (t == s) {
bOK = false;
CheatError(pszFilename, nLine, pCurrentCheat, _T("value omitted"), szLine);
break;
if (HW_NES) {
t = s;
INT32 newlen = 0;
#if defined(BUILD_WIN32)
for (INT32 z = 0; z < lstrlen(t); z++) {
#else
for (INT32 z = 0; z < strlen(t); z++) {
#endif
char c = toupper((char)*s);
if (c >= 'A' && c <= 'Z' && newlen < 10)
pCurrentCheat->pOption[n]->AddressInfo[nCurrentAddress].szGenieCode[newlen++] = c;
s++;
if (*s == _T(',')) break;
}
nAddress = 0xffff; // nAddress not used, but needs to be nonzero (NES/Game Genie)
} else {
nCPU = _tcstol(s, &t, 0); // CPU number
if (t == s) {
CheatError(pszFilename, nLine, pCurrentCheat, _T("CPU number omitted"), szLine);
bOK = false;
break;
}
s = t;

SkipComma(&s);
nAddress = _tcstol(s, &t, 0); // Address
if (t == s) {
bOK = false;
CheatError(pszFilename, nLine, pCurrentCheat, _T("address omitted"), szLine);
break;
}
s = t;

SkipComma(&s);
nValue = _tcstol(s, &t, 0); // Value
if (t == s) {
bOK = false;
CheatError(pszFilename, nLine, pCurrentCheat, _T("value omitted"), szLine);
break;
}
}
} else {
if (nCurrentAddress) { // Only the first option is allowed no address
Expand Down

0 comments on commit e468e2e

Please sign in to comment.