RAM initialization options: default (00 00 00 00 FF FF FF FF as always), all FF, all 00, random.

This commit is contained in:
rainwarrior 2016-08-24 22:42:21 +00:00
parent ed3783db55
commit 74139bf111
5 changed files with 56 additions and 15 deletions

View File

@ -73,6 +73,7 @@ extern int palsharpness;
extern int palcontrast;
extern int palbrightness;
extern bool paldeemphswap;
extern int RAMInitOption;
extern TASEDITOR_CONFIG taseditorConfig;
extern char* recentProjectsArray[];
@ -123,6 +124,9 @@ extern int HexFreezeColorB;
extern int RomFreezeColorR;
extern int RomFreezeColorG;
extern int RomFreezeColorB;
extern int HexBoundColorR;
extern int HexBoundColorG;
extern int HexBoundColorB;
//adelikat: Hacky fix for Ram Watch recent menu
char* ramWatchRecent[] = {0, 0, 0, 0, 0};
@ -183,6 +187,7 @@ static CFGSTRUCT fceuconfig[] =
AC(ntsccol_enable),AC(ntsctint),AC(ntschue),
AC(force_grayscale),
AC(dendy),
AC(RAMInitOption),
AC(postrenderscanlines),
AC(vblankscanlines),
AC(overclock_enabled),
@ -444,6 +449,9 @@ static CFGSTRUCT fceuconfig[] =
AC(RomFreezeColorR),
AC(RomFreezeColorG),
AC(RomFreezeColorB),
AC(HexBoundColorR),
AC(HexBoundColorG),
AC(HexBoundColorB),
//ACS(memwLastfile[2048]),
AC(AutoRWLoad),

View File

@ -1871,6 +1871,13 @@ BEGIN
MENUITEM "Old PPU", ID_OLDPPU
MENUITEM "New PPU", ID_NEWPPU
END
POPUP "RAM Init"
BEGIN
MENUITEM "&Default", MENU_RAMINIT_DEFAULT
MENUITEM "Fill $&FF", MENU_RAMINIT_FF
MENUITEM "Fill $&00", MENU_RAMINIT_00
MENUITEM "&Random", MENU_RAMINIT_RANDOM
END
MENUITEM SEPARATOR
MENUITEM "&Directories...", MENU_DIRECTORIES
MENUITEM "&GUI...", MENU_GUI_OPTIONS

View File

@ -1229,6 +1229,10 @@
#define MENU_MV_FILE_DUMP_64K 40590
#define ID_CONFIG_REGION 40591
#define MENU_MV_FILE_DUMP_OAM 40592
#define MENU_RAMINIT_DEFAULT 40593
#define MENU_RAMINIT_FF 40594
#define MENU_RAMINIT_00 40595
#define MENU_RAMINIT_RANDOM 40596
#define IDC_DEBUGGER_ICONTRAY 55535
#define MW_ValueLabel2 65423
#define MW_ValueLabel1 65426

View File

@ -121,6 +121,7 @@ extern int newppu;
extern BOOL CALLBACK ReplayMetadataDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); //Metadata dialog
extern bool CheckFileExists(const char* filename); //Receives a filename (fullpath) and checks to see if that file exists
extern bool oldInputDisplay;
extern int RAMInitOption;
//AutoFire-----------------------------------------------
void ShowNetplayConsole(void); //mbg merge 7/17/06 YECH had to add
@ -453,6 +454,9 @@ void UpdateCheckedMenuItems()
else
CheckMenuRadioItem(fceumenu, MENU_NTSC, MENU_DENDY, MENU_NTSC, MF_BYCOMMAND);
//Config - RAM Init SubMenu
CheckMenuRadioItem(fceumenu, MENU_RAMINIT_DEFAULT, MENU_RAMINIT_RANDOM, MENU_RAMINIT_DEFAULT + RAMInitOption, MF_BYCOMMAND);
// Tools Menu
CheckMenuItem(fceumenu, MENU_ALTERNATE_AB, GetAutoFireDesynch() ? MF_CHECKED : MF_UNCHECKED);
CheckedAutoFirePattern = GetCheckedAutoFirePattern();
@ -1994,6 +1998,13 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
case MENU_DENDY:
FCEUI_SetRegion(2);
break;
case MENU_RAMINIT_DEFAULT:
case MENU_RAMINIT_FF:
case MENU_RAMINIT_00:
case MENU_RAMINIT_RANDOM:
RAMInitOption = LOWORD(wParam) - MENU_RAMINIT_DEFAULT;
UpdateCheckedMenuItems();
break;
case MENU_DIRECTORIES:
ConfigDirectories();
break;

View File

@ -797,17 +797,35 @@ void ResetNES(void) {
FCEU_DispMessage("Reset", 0);
}
int RAMInitOption = 0;
// Note: this option does not currently apply to WRAM.
// Would it be appropriate to call FCEU_MemoryRand inside FCEU_gmalloc to initialize them?
void FCEU_MemoryRand(uint8 *ptr, uint32 size) {
int x = 0;
while (size) {
*ptr = (x & 4) ? 0xFF : 0x00; // Huang Di DEBUG MODE enabled by default
// Cybernoid NO MUSIC by default
// *ptr = (x & 4) ? 0x7F : 0x00; // Huang Di DEBUG MODE enabled by default
// Minna no Taabou no Nakayoshi Daisakusen DOESN'T BOOT
// Cybernoid NO MUSIC by default
// *ptr = (x & 1) ? 0x55 : 0xAA; // F-15 Sity War HISCORE is screwed...
// 1942 SCORE/HISCORE is screwed...
// *ptr = 0xFF; // Work for all cases
uint8 v = 0;
switch (RAMInitOption)
{
default:
case 0: v = (x & 4) ? 0xFF : 0x00; break;
case 1: v = 0xFF; break;
case 2: v = 0x00; break;
case 3: v = uint8(rand()); break;
// the default is this 8 byte pattern: 00 00 00 00 FF FF FF FF
// it has been used in FCEUX since time immemorial
// Some games to examine uninitialied RAM problems with:
// * Cybernoid - music option starts turned off with default pattern
// * Huang Di - debug mode is enabled with default pattern
// * Minna no Taabou no Nakayoshi Daisakusen - fails to boot with some patterns
// * F-15 City War - high score table
// * 1942 - high score table
// * Cheetahmen II - may start in different levels with different RAM startup
}
*ptr = v;
x++;
size--;
ptr++;
@ -826,13 +844,6 @@ void PowerNES(void) {
FCEU_GeniePower();
//dont do this, it breaks some games: Cybernoid; Minna no Taabou no Nakayoshi Daisakusen; and maybe mechanized attack
//memset(RAM,0xFF,0x800);
//this fixes the above, but breaks Huang Di, which expects $100 to be non-zero or else it believes it has debug cheats enabled, giving you moon jump and other great but likely unwanted things
//FCEU_MemoryRand(RAM,0x800);
//this should work better, based on observational evidence. fixes all of the above:
//for(int i=0;i<0x800;i++) if(i&1) RAM[i] = 0xAA; else RAM[i] = 0x55;
//but we're leaving this for now until we collect some more data
FCEU_MemoryRand(RAM, 0x800);
SetReadHandler(0x0000, 0xFFFF, ANull);