void SaveConfigFile(EmuCores.BytePusher.ConfigsBytePusher aConfigs) { try { string confFile = JsonUtility.ToJson(aConfigs, prettyPrint: true); System.IO.File.WriteAllText(Application.dataPath + "/../core_BytePusher.cfg", confFile); } catch (System.Exception e) { EmuEnvironment.ShowErrorBox("BytePusher Emu Error", e.Message); } }
EmuCores.BytePusher.ConfigsBytePusher LoadConfigFile() { try { string confFile = System.IO.File.ReadAllText(Application.dataPath + "/../core_BytePusher.cfg"); EmuCores.BytePusher.ConfigsBytePusher confData = JsonUtility.FromJson <EmuCores.BytePusher.ConfigsBytePusher>(confFile); return(confData); } catch (System.Exception e) { return(new EmuCores.BytePusher.ConfigsBytePusher()); } }
void Start() { EmuCores.BytePusher.ConfigsBytePusher configsBytePusher = LoadConfigFile(); // Running direct from scene if (EmuEnvironment.EmuCore == EmuEnvironment.Cores._Unknown) { EmuEnvironment.RomFilePath = frontendConfigs.romsPath[frontendConfigs.selectedRomIndex]; OverrideConfigsWithFrontend(configsBytePusher); } emuDisplay.displayWidth = 256; emuDisplay.displayHeight = 256; emuDisplay.displayZoomFactor = configsBytePusher.graphics.displayZoom; emuDisplay.SetScreenStandard(); m_emuBytePusher = new EmuCores.BytePusher.EmuBytePusher(configsBytePusher); m_emuBytePusher.DrawDisplay = DisplayRenderer; m_emuBytePusher.PlayAudio = PlayAudio; m_emuBytePusher.UpdateInputKeys = UpdateKeys; try { byte[] romData = System.IO.File.ReadAllBytes(EmuEnvironment.RomFilePath); if (!m_emuBytePusher.LoadRom(romData)) { throw new System.ArgumentException("Invalid ROM format"); } } catch (System.Exception e) { EmuEnvironment.ShowErrorBox("BytePusher Emu Error", "Failed loading rom:\n" + e.Message); Application.Quit(); } SaveConfigFile(configsBytePusher); }
void OverrideConfigsWithFrontend(EmuCores.BytePusher.ConfigsBytePusher aConf) { aConf.graphics.displayZoom = frontendConfigs.zoomFactor; }