Skip to content

Commit

Permalink
megadrive, fix sanguoyan
Browse files Browse the repository at this point in the history
  • Loading branch information
dinkc64 committed Aug 5, 2023
1 parent d2bd03a commit ec37193
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/burn/drv/megadrive/d_megadrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52044,7 +52044,7 @@ struct BurnDriver Burnmd_Sanguoyan = {
"md_sanguoyan", NULL, NULL, NULL, "199?",
"San Guo Yan Yi - Huo Shao Chi Bi (Unl)\0", NULL, "<unknown>", "Sega Megadrive",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_16BIT_ONLY, 2, HARDWARE_SEGA_MEGADRIVE, GBF_STRATEGY, 0,
BDF_GAME_WORKING | BDF_16BIT_ONLY, 2, HARDWARE_SEGA_MEGADRIVE | HARDWARE_SEGA_MEGADRIVE_PCB_REDCL_EN, GBF_SCRFIGHT, 0,
MegadriveGetZipName, md_SanguoyanRomInfo, md_SanguoyanRomName, NULL, NULL, NULL, NULL, MegadriveInputInfo, MegadriveDIPInfo,
MegadriveInit, MegadriveExit, MegadriveFrame, MegadriveDraw, MegadriveScan,
&bMegadriveRecalcPalette, 0x100, 320, 224, 4, 3
Expand Down
27 changes: 17 additions & 10 deletions src/burn/drv/megadrive/megadrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1880,26 +1880,30 @@ static void __fastcall LK3WriteWord(UINT32 address, UINT16 data)
SEK_DEF_WRITE_WORD(7, address, data);
}

static UINT8 __fastcall RedclifProtReadByte(UINT32 /*sekAddress*/)
static UINT8 __fastcall RedclifProtReadByte(UINT32 sekAddress)
{
//bprintf(PRINT_NORMAL, _T("RedclifeProt Read byte %x pc %x\n"), sekAddress, SekGetPC(-1));

return (UINT8)-0x56;
}

static UINT16 __fastcall RedclifProtReadWord(UINT32 sekAddress)
{
bprintf(PRINT_NORMAL, _T("RedclifeProt Read Word %x\n"), sekAddress);
bprintf(PRINT_NORMAL, _T("RedclifeProt Read word %x pc %x\n"), sekAddress, SekGetPC(-1));

return 0;
}

static UINT8 __fastcall RedclifProt2ReadByte(UINT32 /*sekAddress*/)
static UINT8 __fastcall RedclifProt2ReadByte(UINT32 sekAddress)
{
//bprintf(PRINT_NORMAL, _T("RedclifeProt2 Read byte %x pc %x\n"), sekAddress, SekGetPC(-1));

return 0x55;
}

static UINT16 __fastcall RedclifProt2ReadWord(UINT32 sekAddress)
{
bprintf(PRINT_NORMAL, _T("RedclifeProt2 Read Word %x\n"), sekAddress);
bprintf(PRINT_NORMAL, _T("RedclifeProt2 Read word %x pc %x\n"), sekAddress, SekGetPC(-1));

return 0;
}
Expand Down Expand Up @@ -2515,13 +2519,16 @@ static void SetupCustomCartridgeMappers()
}

if ((BurnDrvGetHardwareCode() & 0xff) == HARDWARE_SEGA_MEGADRIVE_PCB_REDCL_EN) {
OriginalRom = (UINT8*)BurnMalloc(0x200005);
memcpy(OriginalRom, RomMain, 0x200005);
for (UINT32 i = 0; i < RomSize; i++) {
OriginalRom[i] ^= 0x40;
}
if (RomSize == 0x200005) {
bprintf(0, _T("Redcliff - decrypting rom\n"));
OriginalRom = (UINT8*)BurnMalloc(0x200005);
memcpy(OriginalRom, RomMain, 0x200005);
for (UINT32 i = 0; i < RomSize; i++) {
OriginalRom[i] ^= 0x40;
}

memcpy(RomMain + 0x000000, OriginalRom + 0x000004, 0x200000);
memcpy(RomMain + 0x000000, OriginalRom + 0x000004, 0x200000);
}

SekOpen(0);
SekMapHandler(7, 0x400000, 0x400001, MAP_READ);
Expand Down

0 comments on commit ec37193

Please sign in to comment.