private void TurnOn() { if (_backend != null) { return; } var buffers = new Buffers(UnityEngine.SystemInfo.SupportsTextureFormat(TextureFormat.RGB565)); _backend = new Backend(buffers); _backend.On(Rom.bytes); var w = Convert.ToInt32(Backend.SystemAvInfo.geometry.base_width); var h = Convert.ToInt32(Backend.SystemAvInfo.geometry.base_height); Texture = new Texture2D(w, h, buffers.VideoSupport16Bit ? TextureFormat.RGB565 : TextureFormat.RGB24, false) { filterMode = FilterMode.Point }; Display.material.mainTexture = Texture; AudioSource.clip = AudioClip.Create(name, buffers.AudioBufferSize / 2, 2, 44100, true, OnAudioRead); AudioSource.playOnAwake = false; AudioSource.spatialBlend = 0; AudioSource.loop = true; Bridges.SetupExternalInput(); }
public void TurnOn(string filename = "") { if (_backend != null) { return; } var buffers = new Buffers() { VideoSupport16Bit = UnityEngine.SystemInfo.SupportsTextureFormat(TextureFormat.RGB565), SystemDirectory = Application.persistentDataPath, PersistentDataPath = Application.persistentDataPath, TemporaryDataPath = Application.temporaryCachePath, StreamingAssets = Application.streamingAssetsPath }; _backend = new Backend(buffers); _backend.Init(); _backend.LoadGame(GetRom(filename)); _backend.LoadSram(GetSramFilePaths()); _backend.LoadRtc(GetRtcFilePaths()); Debug.Log($"load game: {Backend.RomHeader.GameTitle}"); _texture = new Texture2D(buffers.VideoUnitSize, buffers.VideoUnitSize, buffers.VideoSupport16Bit ? TextureFormat.RGB565 : TextureFormat.RGBA32, false) { filterMode = FilterMode.Point }; InputMapper = new InputMapper(); InputMapper.SetKeyAsICade(); Display.material.mainTexture = _texture; AudioSource.clip = AudioClip.Create(name, buffers.AudioBufferSize / 2, 2, 44100, true, OnAudioRead); AudioSource.playOnAwake = false; AudioSource.spatialBlend = 0; AudioSource.loop = true; Bridges.SetupExternalInput(); }
public Backend(Buffers buffers) { Buffers = buffers; }