void InitializeSaveRam(GameInfo game) { if (EepromEnabled) return; if (game["DisableSaveRam"] || RH_SRamPresent == false) return; SaveRamEnabled = true; SaveRamEveryOtherByte = RH_SRamCode != 0; SaveRamStartOffset = RH_SRamStart; SaveRamEndOffset = RH_SRamEnd; if (game["SaveRamStartOffset"]) SaveRamStartOffset = game.GetHexValue("SaveRamStartOffset"); if (game["SaveRamEndOffset"]) SaveRamEndOffset = game.GetHexValue("SaveRamEndOffset"); SaveRamLength = (SaveRamEndOffset - SaveRamStartOffset) + 1; if (SaveRamEveryOtherByte) SaveRamLength = ((SaveRamEndOffset - SaveRamStartOffset) / 2) + 1; SaveRAM = new byte[SaveRamLength]; Console.WriteLine("SaveRAM enabled. Start: ${0:X6} End: ${1:X6} Length: ${2:X} Mode: {3}", SaveRamStartOffset, SaveRamEndOffset, SaveRamLength, RH_SRamInterpretation()); }
// Code void InitializeEeprom(GameInfo game) { if (game["EEPROM"] == false) return; EepromEnabled = true; EepromAddrMask = game.GetHexValue("EEPROM_ADDR_MASK"); EepromSize = EepromAddrMask + 1; var t = game.OptionValue("SDA_IN").Split(':'); SdaInAddr = int.Parse(t[0], NumberStyles.HexNumber); SdaInBit = int.Parse(t[1]); t = game.OptionValue("SDA_OUT").Split(':'); SdaOutAddr = int.Parse(t[0], NumberStyles.HexNumber); SdaOutBit = int.Parse(t[1]); t = game.OptionValue("SCL").Split(':'); SclAddr = int.Parse(t[0], NumberStyles.HexNumber); SclBit = int.Parse(t[1]); SaveRAM = new byte[EepromSize]; Console.WriteLine("EEPROM enabled. Size: ${0:X} SDA_IN: ${1:X}:{2} SDA_OUT: ${3:X}:{4}, SCL: ${5:X}:{6}", EepromSize, SdaInAddr, SdaInBit, SdaOutAddr, SdaOutBit, SclAddr, SclBit); }