more cheat fixes + add support to e132xs

This commit is contained in:
dinkc64 2021-04-09 01:29:31 -04:00
parent cadd680ea6
commit 288b7a6c92
6 changed files with 77 additions and 25 deletions

View File

@ -158,7 +158,7 @@ INT32 CheatEnable(INT32 nCheat, INT32 nOption) // -1 / 0 - disable
cheat_subptr->open(cheat_ptr->nCPU);
}
if (pCurrentCheat->bRestoreOnDisable && !pCurrentCheat->bRelAddress) {
if (pCurrentCheat->bRestoreOnDisable && !pAddressInfo->bRelAddress) {
// Write back original values to memory
bprintf(0, _T("Cheat #%d, option #%d. action: "), nCheat, nOption);
bprintf(0, _T("Undo cheat @ 0x%X -> 0x%X.\n"), pAddressInfo->nAddress, pAddressInfo->nOriginalValue);
@ -196,9 +196,13 @@ INT32 CheatEnable(INT32 nCheat, INT32 nOption) // -1 / 0 - disable
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 {
if (pCurrentCheat->bRelAddress) {
if (pAddressInfo->bRelAddress) {
const TCHAR nBits[4][8] = { { _T("8-bit") }, { _T("16-bit") }, { _T("24-bit") }, { _T("32-bit") } };
bprintf(0, _T("Apply cheat @ %s pointer ([0x%X] + 0x%x) -> 0x%X.\n"), nBits[pCurrentCheat->nRelAddressBits & 3], pAddressInfo->nAddress, pCurrentCheat->nRelAddressOffset, pAddressInfo->nValue);
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);
@ -219,7 +223,7 @@ INT32 CheatEnable(INT32 nCheat, INT32 nOption) // -1 / 0 - disable
cheat_subptr->open(cheat_ptr->nCPU);
}
if (!pCurrentCheat->bWatchMode && !pCurrentCheat->bWaitForModification && !pCurrentCheat->bRelAddress) {
if (!pCurrentCheat->bWatchMode && !pCurrentCheat->bWaitForModification && !pAddressInfo->bRelAddress) {
// Activate the cheat
cheat_subptr->write(pAddressInfo->nAddress, pAddressInfo->nValue);
}
@ -301,7 +305,7 @@ INT32 CheatApply()
#endif
} else {
// update the cheat
if (pCurrentCheat->bWaitForModification && !pCurrentCheat->bRelAddress) {
if (pCurrentCheat->bWaitForModification && !pAddressInfo->bRelAddress) {
UINT32 nValNow = cheat_subptr->read(pAddressInfo->nAddress);
if (nValNow != pAddressInfo->nOriginalValue) {
bprintf(0, _T(" - Address modified! old = %X new = %X\n"),pAddressInfo->nOriginalValue, nValNow);
@ -311,19 +315,19 @@ INT32 CheatApply()
}
} else {
// Write the value.
if (pCurrentCheat->bRelAddress) {
if (pAddressInfo->bRelAddress) {
// Cheat with relative address (pointer @ address + offset) see cheat.dat entries ":rdft2:" or ":dreamwld:")
UINT32 addr = 0;
for (INT32 i = 0; i < (pCurrentCheat->nRelAddressBits + 1); i++) {
for (INT32 i = 0; i < (pAddressInfo->nRelAddressBits + 1); i++) {
if (cheat_subptr->nAddressXor) { // big endian
addr |= cheat_subptr->read(pAddressInfo->nAddress + (pCurrentCheat->nRelAddressBits - i)) << (i * 8);
addr |= cheat_subptr->read(pAddressInfo->nAddress + (pAddressInfo->nRelAddressBits - i)) << (i * 8);
} else {
addr |= cheat_subptr->read(pAddressInfo->nAddress + i) << (i * 8);
}
}
cheat_subptr->write(addr + pCurrentCheat->nRelAddressOffset, pAddressInfo->nValue);
//bprintf(0, _T("cw %x -> %x\n"), addr + pAddressInfo->nMultiByte + pAddressInfo->nRelAddressOffset, pAddressInfo->nValue);
cheat_subptr->write(addr + pAddressInfo->nMultiByte + pAddressInfo->nRelAddressOffset, pAddressInfo->nValue);
} else {
// Normal cheat write
cheat_subptr->write(pAddressInfo->nAddress, pAddressInfo->nValue);

View File

@ -7,8 +7,13 @@ extern bool bCheatsAllowed;
struct CheatAddressInfo {
INT32 nCPU;
INT32 nAddress;
INT32 nMultiByte;
UINT32 nValue;
UINT32 nOriginalValue;
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
};
struct CheatOption {
@ -29,10 +34,6 @@ struct CheatInfo {
INT32 bWaitForModification; // Wait for Modification before changing
INT32 bModified; // Wrote cheat?
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
TCHAR szCheatName[CHEAT_MAX_NAME];
struct CheatOption* pOption[CHEAT_MAX_OPTIONS];
};

View File

@ -1878,6 +1878,7 @@ static inline void NeoCDIRQUpdate(UINT8 byteValue)
static inline void SendSoundCommand(const UINT8 nCommand)
{
if (ZetGetActive() == -1) return;
// bprintf(PRINT_NORMAL, _T(" - Sound command sent (0x%02X).\n"), nCommand);
neogeoSynchroniseZ80(0);

View File

@ -433,8 +433,14 @@ static INT32 ConfigParseMAMEFile()
INT32 k = (flags >> 20) & 3; \
for (INT32 i = 0; i < k+1; i++) { \
pCurrentCheat->pOption[n]->AddressInfo[nCurrentAddress].nCPU = 0; \
pCurrentCheat->pOption[n]->AddressInfo[nCurrentAddress].nAddress = nAddress + i; \
if ((flags & 0xf0000000) == 0x80000000) { \
pCurrentCheat->pOption[n]->AddressInfo[nCurrentAddress].bRelAddress = 1; \
pCurrentCheat->pOption[n]->AddressInfo[nCurrentAddress].nRelAddressOffset = nAttrib; \
pCurrentCheat->pOption[n]->AddressInfo[nCurrentAddress].nRelAddressBits = (flags & 0x3000000) >> 24; \
} \
pCurrentCheat->pOption[n]->AddressInfo[nCurrentAddress].nAddress = (pCurrentCheat->pOption[n]->AddressInfo[nCurrentAddress].bRelAddress) ? nAddress : nAddress + i; \
pCurrentCheat->pOption[n]->AddressInfo[nCurrentAddress].nValue = (nValue >> ((k*8)-(i*8))) & 0xff; \
pCurrentCheat->pOption[n]->AddressInfo[nCurrentAddress].nMultiByte = i; \
nCurrentAddress++; \
} \
@ -484,6 +490,19 @@ static INT32 ConfigParseMAMEFile()
if (szLine[0] == ';') continue;
/*
// find the cheat flags & 0x80000000 cheats (for debugging) -dink
int derpy = 0;
for (INT32 i = 0; i < nLen; i++) {
if (szLine[i] == ':') {
derpy++;
if (derpy == 2 && szLine[i+1] == '8') {
bprintf(0, _T("%s\n"), szLine);
}
}
}
*/
#ifdef BUILD_WIN32
if (_tcsncmp (szLine, gName, lstrlen(gName))) {
#else
@ -590,11 +609,6 @@ static INT32 ConfigParseMAMEFile()
if (flags & 0x800000) {
pCurrentCheat->bRestoreOnDisable = 1; // restore previous value on disable
}
if ((flags & 0xf0000000) == 0x80000000) {
pCurrentCheat->bRelAddress = 1; // relative address (pointer)
pCurrentCheat->nRelAddressOffset = nAttrib;
pCurrentCheat->nRelAddressBits = (flags & 0x3000000) >> 24;
}
if ((flags & 0x6) == 0x6) {
pCurrentCheat->bWatchMode = 1; // display value @ address
}
@ -640,11 +654,6 @@ static INT32 ConfigParseMAMEFile()
if (flags & 0x800000) {
pCurrentCheat->bRestoreOnDisable = 1; // restore previous value on disable
}
if ((flags & 0xf0000000) == 0x80000000) {
pCurrentCheat->bRelAddress = 1; // relative address (pointer)
pCurrentCheat->nRelAddressOffset = nAttrib;
pCurrentCheat->nRelAddressBits = (flags & 0x3000000) >> 24;
}
if ((flags & 0x6) == 0x6) {
pCurrentCheat->bWatchMode = 1; // display value @ address
}

View File

@ -4625,6 +4625,29 @@ static void hyperstone_trap(struct regs_decode *)
#include "e132xsop.inc"
static void core_set_irq_line(INT32, INT32 line, INT32 state)
{
E132XSSetIRQLine(line, state);
}
cpu_core_config E132XSConfig =
{
"e132xs",
E132XSOpen,
E132XSClose,
program_read_byte_16be,
program_write_byte_16be,
E132XSGetActive,
E132XSTotalCycles32,
E132XSNewFrame,
E132XSIdle,
core_set_irq_line,
E132XSRun,
E132XSRunEnd,
E132XSReset,
0xffffffff,
1
};
static void map_internal_ram(UINT32 size)
{
@ -4676,6 +4699,8 @@ void E132XSInit(INT32 , INT32 type, INT32 )
io_write_dword_handler = NULL;
io_read_dword_handler = NULL;
CpuCheatRegister(0, &E132XSConfig);
switch (type)
{
case TYPE_E116T:
@ -4786,6 +4811,11 @@ void E132XSReset()
sleep_until_int = 0;
}
INT32 E132XSGetActive()
{
return 0;
}
void E132XSOpen(INT32 nCpu)
{
if (nCpu){}
@ -4805,6 +4835,11 @@ INT64 E132XSTotalCycles()
return utotal_cycles + (n_cycles - m_icount);
}
INT32 E132XSTotalCycles32()
{
return E132XSTotalCycles();
}
void E132XSNewFrame()
{
utotal_cycles = 0;

View File

@ -20,6 +20,7 @@ enum e132xs_types
void E132XSInit(INT32 cpu, INT32 type, INT32 clock);
void E132XSOpen(INT32 cpu);
void E132XSClose();
INT32 E132XSGetActive();
INT32 E132XSRun(INT32);
INT32 E132XSIdle(INT32);
void E132XSReset();
@ -48,3 +49,4 @@ void E132XSRunEnd();
void E132XSRunEndBurnAllCycles();
INT32 E132XSBurnCycles(INT32 cycles);
INT64 E132XSTotalCycles();
INT32 E132XSTotalCycles32();