mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
Add support for single-line cheats and PAR codes.
notaz: include required header
This commit is contained in:
parent
9e38b1f0d6
commit
8655fd0462
1 changed files with 13 additions and 2 deletions
15
pico/patch.c
15
pico/patch.c
|
@ -22,6 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pico_int.h"
|
#include "pico_int.h"
|
||||||
|
#include "memory.h"
|
||||||
#include "patch.h"
|
#include "patch.h"
|
||||||
|
|
||||||
struct patch
|
struct patch
|
||||||
|
@ -142,7 +143,7 @@ static void hex_decode(const char *code, struct patch *result)
|
||||||
/* THIS is the function you call from the MegaDrive or whatever. This figures
|
/* THIS is the function you call from the MegaDrive or whatever. This figures
|
||||||
* out whether it's a genie or hex code, depunctuates it, and calls the proper
|
* out whether it's a genie or hex code, depunctuates it, and calls the proper
|
||||||
* decoder. */
|
* decoder. */
|
||||||
static void decode(const char* code, struct patch* result)
|
void decode(const char* code, struct patch* result)
|
||||||
{
|
{
|
||||||
int len = strlen(code), i, j;
|
int len = strlen(code), i, j;
|
||||||
char code_to_pass[16], *x;
|
char code_to_pass[16], *x;
|
||||||
|
@ -299,6 +300,8 @@ void PicoPatchPrepare(void)
|
||||||
PicoPatches[i].addr &= ~1;
|
PicoPatches[i].addr &= ~1;
|
||||||
if (PicoPatches[i].addr < Pico.romsize)
|
if (PicoPatches[i].addr < Pico.romsize)
|
||||||
PicoPatches[i].data_old = *(unsigned short *)(Pico.rom + PicoPatches[i].addr);
|
PicoPatches[i].data_old = *(unsigned short *)(Pico.rom + PicoPatches[i].addr);
|
||||||
|
else
|
||||||
|
PicoPatches[i].data_old = (unsigned short) m68k_read16(PicoPatches[i].addr);
|
||||||
if (strstr(PicoPatches[i].name, "AUTO"))
|
if (strstr(PicoPatches[i].name, "AUTO"))
|
||||||
PicoPatches[i].active = 1;
|
PicoPatches[i].active = 1;
|
||||||
}
|
}
|
||||||
|
@ -328,7 +331,15 @@ void PicoPatchApply(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* TODO? */
|
if (PicoPatches[i].active)
|
||||||
|
m68k_write16(PicoPatches[i].addr,PicoPatches[i].data);
|
||||||
|
else {
|
||||||
|
// if current addr is not patched by older patch, write back original val
|
||||||
|
for (u = 0; u < i; u++)
|
||||||
|
if (PicoPatches[u].addr == addr) break;
|
||||||
|
if (u == i)
|
||||||
|
m68k_write16(PicoPatches[i].addr,PicoPatches[i].data_old);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue