public void FrameAdvance(bool render, bool renderSound) { Cpu.Debug = Tracer.Enabled; Frame++; _isLag = true; PSG.BeginFrame(Cpu.TotalExecutedCycles); if (Cpu.Debug && Cpu.Logger == null) // TODO, lets not do this on each frame. But lets refactor CoreComm/CoreComm first { Cpu.Logger = (s) => Tracer.Put(s); } byte temp_ret1 = ControllerDeck.ReadPort1(Controller, true, true); byte temp_ret2 = ControllerDeck.ReadPort2(Controller, true, true); bool Int_pending = (!temp_ret1.Bit(4)) | (!temp_ret2.Bit(4)); VDP.ExecuteFrame(Int_pending); PSG.EndFrame(Cpu.TotalExecutedCycles); if (_isLag) { _lagCount++; } }
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; CoreComm = comm; CoreComm.NominalWidth = 240; CoreComm.NominalHeight = 160; PutSettings(_settings); _tracer = new TraceBuffer() { Header = "ARM7: PC, machine code, mnemonic, operands, registers" }; _tracecb = new LibmGBA.TraceCallback((msg) => _tracer.Put(_traceInfo(msg))); ser.Register(_tracer); } catch { LibmGBA.BizDestroy(_core); throw; } }
public MGBAHawk(byte[] file, CoreComm comm, SyncSettings syncSettings, Settings settings, bool deterministic, GameInfo game) { _syncSettings = syncSettings ?? new SyncSettings(); _settings = settings ?? new Settings(); DeterministicEmulation = deterministic; var bios = comm.CoreFileProvider.GetFirmware(new("GBA", "Bios")); DeterministicEmulation &= bios != null; if (DeterministicEmulation != deterministic) { throw new MissingFirmwareException("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(_syncSettings), 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); const string TRACE_HEADER = "ARM7: PC, machine code, mnemonic, operands, registers"; Tracer = new TraceBuffer(TRACE_HEADER); _tracecb = msg => Tracer.Put(_traceInfo(msg)); ser.Register(Tracer); MemoryCallbacks = new MGBAMemoryCallbackSystem(this); } catch { LibmGBA.BizDestroy(Core); throw; } InputCallback = new LibmGBA.InputCallback(InputCb); LibmGBA.BizSetInputCallback(Core, InputCallback); }
public void FrameAdvance(bool render, bool renderSound) { Cpu.Debug = Tracer.Enabled; Frame++; _isLag = true; PSG.BeginFrame(Cpu.TotalExecutedCycles); if (Cpu.Debug && Cpu.Logger == null) // TODO, lets not do this on each frame. But lets refactor CoreComm/CoreComm first { Cpu.Logger = (s) => Tracer.Put(s); } VDP.ExecuteFrame(); PSG.EndFrame(Cpu.TotalExecutedCycles); if (_isLag) { _lagCount++; } }