Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
        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;
            }
        }
Esempio n. 3
0
        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);
        }