From 83d4312e3cb2c2625359f4c8ae1a68c876caaf6c Mon Sep 17 00:00:00 2001 From: ekeeke31 Date: Sun, 5 Feb 2012 17:00:50 +0000 Subject: [PATCH] added random RAM pattern initialization on Mark-III & Japanese Master System (fixes "Alibaba and 40 Thieves" & "Block Hole") --- source/cart_hw/sms_cart.c | 21 +++++++++++---------- source/genesis.c | 9 ++++++++- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/source/cart_hw/sms_cart.c b/source/cart_hw/sms_cart.c index e6327d1..799127d 100644 --- a/source/cart_hw/sms_cart.c +++ b/source/cart_hw/sms_cart.c @@ -38,9 +38,6 @@ #include "shared.h" #include "terebi_oekaki.h" -#ifdef NGC -#include "cheats.h" -#endif #define MAPPER_NONE (0) #define MAPPER_TEREBI (1) @@ -52,7 +49,7 @@ #define MAPPER_93C46 (7) #define MAPPER_MULTI (8) -#define GAME_DATABASE_CNT (188) +#define GAME_DATABASE_CNT (190) typedef struct { @@ -133,6 +130,10 @@ static const rominfo_t game_list[GAME_DATABASE_CNT] = {0xBD1CC7DF, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_MARKIII, REGION_JAPAN_NTSC}, /* Super Tetris (K) */ {0x6D309AC5, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_MARKIII, REGION_JAPAN_NTSC}, /* Power Boggle Boggle (K) */ + /* games requiring random RAM pattern initialization */ + {0x08BF3DE3, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_NONE, SYSTEM_MARKIII, REGION_JAPAN_NTSC}, /* Alibaba and 40 Thieves (KR) */ + {0x643B6B76, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_NONE, SYSTEM_MARKIII, REGION_JAPAN_NTSC}, /* Block Hole (KR) */ + /* games requiring PAL timings */ {0x72420F38, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Addams Familly */ {0x2D48C1D3, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Back to the Future Part III */ @@ -932,9 +933,9 @@ static void mapper_8k_w(int offset, unsigned int data) } } -#ifdef NGC - /* update ROM patches */ - ROMCheatUpdate(); +#ifdef CHEATS_UPDATE + /* update ROM patches when banking has changed */ + CHEATS_UPDATE(); #endif } @@ -1076,9 +1077,9 @@ static void mapper_16k_w(int offset, unsigned int data) } } -#ifdef NGC - /* update ROM patches */ - ROMCheatUpdate(); +#ifdef CHEATS_UPDATE + /* update ROM patches when banking has changed */ + CHEATS_UPDATE(); #endif } diff --git a/source/genesis.c b/source/genesis.c index 536a9ab..7b3e7f1 100644 --- a/source/genesis.c +++ b/source/genesis.c @@ -218,7 +218,7 @@ void gen_reset(int hard_reset) /* System Reset */ if (hard_reset) { - /* clear RAM (TODO: use random bit patterns as on real hardware) */ + /* clear RAM (TODO: use random bit patterns for all systems, like on real hardware) */ memset(work_ram, 0x00, sizeof (work_ram)); memset(zram, 0x00, sizeof (zram)); } @@ -286,6 +286,13 @@ void gen_reset(int hard_reset) } else { + /* RAM state at power-on is undefined on some systems */ + if ((system_hw == SYSTEM_MARKIII) || ((system_hw & SYSTEM_SMS) && (region_code == REGION_JAPAN_NTSC))) + { + /* some korean games rely on RAM to be initialized with values different from $00 or $ff */ + memset(work_ram, 0xf0, sizeof(work_ram)); + } + /* Z80 cycles should be a multiple of 15 to avoid rounding errors */ mcycles_z80 = (mcycles_z80 / 15) * 15;