public MGBAHawk(byte[] file, CoreComm comm, SyncSettings syncSettings, Settings settings, bool deterministic, GameInfo game) { _syncSettings = syncSettings ?? new SyncSettings(); _settings = settings ?? new Settings(); DeterministicEmulation = deterministic; byte[] bios = comm.CoreFileProvider.GetFirmware("GBA", "Bios", false); DeterministicEmulation &= bios != null; if (DeterministicEmulation != deterministic) { throw new InvalidOperationException("A BIOS is required for deterministic recordings!"); } if (!DeterministicEmulation && bios != null && !_syncSettings.RTCUseRealTime && !_syncSettings.SkipBios) { // in these situations, this core is deterministic even though it wasn't asked to be DeterministicEmulation = true; } if (bios != null && bios.Length != 16384) { throw new InvalidOperationException("BIOS must be exactly 16384 bytes!"); } var skipBios = !DeterministicEmulation && _syncSettings.SkipBios; Core = LibmGBA.BizCreate(bios, file, file.Length, GetOverrideInfo(game), skipBios); if (Core == IntPtr.Zero) { throw new InvalidOperationException($"{nameof(LibmGBA.BizCreate)}() returned NULL! Bad BIOS? and/or ROM?"); } try { CreateMemoryDomains(file.Length); var ser = new BasicServiceProvider(this); ser.Register <IDisassemblable>(new ArmV4Disassembler()); ser.Register <IMemoryDomains>(_memoryDomains); ServiceProvider = ser; PutSettings(_settings); Tracer = new TraceBuffer { Header = "ARM7: PC, machine code, mnemonic, operands, registers" }; _tracecb = msg => Tracer.Put(_traceInfo(msg)); ser.Register(Tracer); MemoryCallbacks = new MGBAMemoryCallbackSystem(this); } catch { LibmGBA.BizDestroy(Core); throw; } InputCallbacks = new MemoryBasedInputCallbackSystem(this, "System Bus", new[] { 0x4000130u }); }
public MGBAHawk(byte[] file, CoreComm comm, SyncSettings syncSettings, Settings settings, bool deterministic) { _syncSettings = syncSettings ?? new SyncSettings(); _settings = settings ?? new Settings(); DeterministicEmulation = deterministic; byte[] bios = comm.CoreFileProvider.GetFirmware("GBA", "Bios", false); DeterministicEmulation &= bios != null; if (DeterministicEmulation != deterministic) { throw new InvalidOperationException("A BIOS is required for deterministic recordings!"); } if (!DeterministicEmulation && bios != null && !_syncSettings.RTCUseRealTime && !_syncSettings.SkipBios) { // in these situations, this core is deterministic even though it wasn't asked to be DeterministicEmulation = true; } if (bios != null && bios.Length != 16384) { throw new InvalidOperationException("BIOS must be exactly 16384 bytes!"); } core = LibmGBA.BizCreate(bios); if (core == IntPtr.Zero) { throw new InvalidOperationException("BizCreate() returned NULL! Bad BIOS?"); } try { if (!LibmGBA.BizLoad(core, file, file.Length)) { throw new InvalidOperationException("BizLoad() returned FALSE! Bad ROM?"); } if (!DeterministicEmulation && _syncSettings.SkipBios) { LibmGBA.BizSkipBios(core); } var ser = new BasicServiceProvider(this); ser.Register <IDisassemblable>(new ArmV4Disassembler()); ser.Register <IMemoryDomains>(CreateMemoryDomains(file.Length)); ServiceProvider = ser; CoreComm = comm; CoreComm.VsyncNum = 262144; CoreComm.VsyncDen = 4389; CoreComm.NominalWidth = 240; CoreComm.NominalHeight = 160; InitStates(); } catch { LibmGBA.BizDestroy(core); throw; } }
public void Dispose() { if (_core != IntPtr.Zero) { LibmGBA.BizDestroy(_core); _core = IntPtr.Zero; } }
public MGBAHawk(byte[] file, CoreComm comm, SyncSettings syncSettings, Settings settings, bool deterministic, GameInfo game) { _syncSettings = syncSettings ?? new SyncSettings(); _settings = settings ?? new Settings(); DeterministicEmulation = deterministic; //RTC_Hijack : Make GBA bios mandatory byte[] bios = comm.CoreFileProvider.GetFirmware("GBA", "Bios", true, "GBA bios file is mandatory."); DeterministicEmulation &= bios != null; if (DeterministicEmulation != deterministic) { throw new InvalidOperationException("A BIOS is required for deterministic recordings!"); } if (!DeterministicEmulation && bios != null && !_syncSettings.RTCUseRealTime && !_syncSettings.SkipBios) { // in these situations, this core is deterministic even though it wasn't asked to be DeterministicEmulation = true; } if (bios != null && bios.Length != 16384) { throw new InvalidOperationException("BIOS must be exactly 16384 bytes!"); } var skipBios = !DeterministicEmulation && _syncSettings.SkipBios; _core = LibmGBA.BizCreate(bios, file, file.Length, GetOverrideInfo(game), skipBios); if (_core == IntPtr.Zero) { throw new InvalidOperationException("BizCreate() returned NULL! Bad BIOS? and/or ROM?"); } try { CreateMemoryDomains(file.Length); var ser = new BasicServiceProvider(this); ser.Register <IDisassemblable>(new ArmV4Disassembler()); ser.Register <IMemoryDomains>(_memoryDomains); ServiceProvider = ser; CoreComm = comm; CoreComm.NominalWidth = 240; CoreComm.NominalHeight = 160; PutSettings(_settings); } catch { LibmGBA.BizDestroy(_core); throw; } }