public Atari2600(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) { var ser = new BasicServiceProvider(this); ServiceProvider = ser; MemoryCallbacks = new MemoryCallbackSystem(); InputCallbacks = new InputCallbackSystem(); Ram = new byte[128]; CoreComm = comm; Settings = (A2600Settings)settings ?? new A2600Settings(); SyncSettings = (A2600SyncSettings)syncSettings ?? new A2600SyncSettings(); _leftDifficultySwitchPressed = SyncSettings.LeftDifficulty; _rightDifficultySwitchPressed = SyncSettings.RightDifficulty; Rom = rom; _game = game; if (!game.GetOptionsDict().ContainsKey("m")) { game.AddOption("m", DetectMapper(rom)); } if (Rom.HashSHA1() == "3A77DB43B6583E8689435F0F14AA04B9E57BDDED" || Rom.HashSHA1() == "E986E1818E747BEB9B33CE4DFF1CDC6B55BDB620") { game.RemoveOption("m"); game.AddOption("m", "F8_sega"); } Console.WriteLine("Game uses mapper " + game.GetOptionsDict()["m"]); Console.WriteLine(Rom.HashSHA1()); RebootCore(); SetupMemoryDomains(); Tracer = new TraceBuffer { Header = Cpu.TraceHeader }; ser.Register <IDisassemblable>(Cpu); ser.Register <ITraceable>(Tracer); ser.Register <IVideoProvider>(_tia); }
/// <summary> /// Adds the specified parameter name and value to the current <see cref="TraceContext" />. /// </summary> /// <param name="parameterName">The parameter name.</param> /// <param name="parameterValue">The parameter value.</param> /// <returns>The current instance of <see cref="TraceContext" />.</returns> public TraceContext Add <T>(string parameterName, T parameterValue) { if (parameterName == null) { throw new ArgumentNullException(nameof(parameterName)); } ITraceable traceableObject = parameterValue as ITraceable; if (traceableObject != null) { Add(TraceParameter.CreateCollection(parameterName, traceableObject)); } else { _parameters.Add(TraceParameter.Create(parameterName, parameterValue)); } return(this); }
public virtual void Format(ITraceBuilder builder, T value) { if (value == null) { builder.AddArgument(string.Empty); return; } ITraceable traceable = value as ITraceable; if (traceable != null) { traceable.TraceTo(builder); return; } string value2 = value.ToString(); builder.AddArgument(value2); }
public bool Copy(CM1GroupsTree pSrcTree) { trace?.Write(TraceLevel.Debug, "CM1GroupsTree::Copy"); bool fnResult = true; try { trace = pSrcTree.trace; m_nNodeNum = pSrcTree.m_nNodeNum; m_nGroupNum = pSrcTree.m_nGroupNum; int i = 0; for (i = 0; i < m_nGroupNum; i++) { m_Groups[i].Init(); m_Groups[i].Copy(pSrcTree.m_Groups[i]); } long lGrpId; for (i = 0; i < m_nNodeNum; i++) { m_Nodes[i].Init(); m_Nodes[i].Copy(pSrcTree.m_Nodes[i]); if (pSrcTree.m_Nodes[i].Grp != null) { lGrpId = pSrcTree.m_Nodes[i].Grp.GetGrpId(); m_Nodes[i].Grp = GetGroupFromGrpId(lGrpId); } if (pSrcTree.m_Nodes[i].GrpChild != null) { lGrpId = pSrcTree.m_Nodes[i].GrpChild.GetGrpId(); m_Nodes[i].GrpChild = GetGroupFromGrpId(lGrpId); } } } catch (Exception error) { trace?.Write(TraceLevel.Error, error.ToLogString()); fnResult = false; } return(fnResult); }
/// <inheritdoc /> public void ComputeDerivativesTo(ITraceable traceable) { if (traceable is TNumber) { TNumber number = (TNumber)traceable; AD.ReverseProp(new DNumber(1.0f).asADD, number.Handle.asADD); } else if (traceable is TNDArray) { TNDArray array = (TNDArray)traceable; AD.ReverseProp(new DNumber(1.0f).asADD, array.Handle.asADDND); } else { throw new InvalidOperationException($"Cannot compute derivatives for traceable of unknown type (type of object {traceable} not compatible with this handler)."); } }
public override void ProcessMessage(SoapMessage message) { ITraceable traceable = GetTraceable(message); //If proxy is not configured to be traced, return if (traceable == null) { return; } switch (message.Stage) { case SoapMessageStage.BeforeSerialize: //If tracing is enabled, switch to memory buffer if (traceable.IsTraceRequestEnabled) { traceStream.SwitchToNewStream(); } break; case SoapMessageStage.AfterSerialize: //If message was written to memory buffer, write its content to log and copy to the SOAP stream if (traceStream.IsNewStream) { traceStream.Position = 0; WriteToLog(DumpType.Request, traceable); traceStream.Position = 0; traceStream.CopyNewToOld(); } break; case SoapMessageStage.BeforeDeserialize: //If tracing is enabled, copy SOAP stream to the new stream and write its content to log if (traceable.IsTraceResponseEnabled) { traceStream.SwitchToNewStream(); traceStream.CopyOldToNew(); WriteToLog(DumpType.Response, traceable); traceStream.Position = 0; } break; } }
private bool FindInteractionVolumeHit(Ray ray, out int interactionVolumeHitIndex, out IntersectInfo info) { interactionVolumeHitIndex = -1; if (interactionVolumes.Count == 0 || interactionVolumes[0].CollisionVolume == null) { info = null; return(false); } List <ITraceable> uiTraceables = new List <ITraceable>(); foreach (InteractionVolume interactionVolume in interactionVolumes) { if (interactionVolume.CollisionVolume != null) { var traceData = interactionVolume.CollisionVolume; uiTraceables.Add(new Transform(traceData, interactionVolume.TotalTransform)); } } ITraceable allUiObjects = BoundingVolumeHierarchy.CreateNewHierachy(uiTraceables); info = allUiObjects.GetClosestIntersection(ray); if (info != null) { for (int i = 0; i < interactionVolumes.Count; i++) { List <IBvhItem> insideBounds = new List <IBvhItem>(); if (interactionVolumes[i].CollisionVolume != null) { interactionVolumes[i].CollisionVolume.GetContained(insideBounds, info.ClosestHitObject.GetAxisAlignedBoundingBox()); if (insideBounds.Contains(info.ClosestHitObject)) { interactionVolumeHitIndex = i; return(true); } } } } return(false); }
public static void Trace(object content, string title = null) { string contentAsString; ITraceable tracable = content as ITraceable; if (tracable != null) { contentAsString = tracable.TraceAsString(); } else if (content != null) { contentAsString = content.ToString(); } else { contentAsString = "<null>"; } RollbarUnitTestEnvironmentUtil.Trace(contentAsString, title); }
public static ITraceable CreateNewHierachy(List <ITraceable> tracePrimitives, BvhCreationOptions bvhCreationOptions = BvhCreationOptions.LegacySlowConstructionFastTracing) { ITraceable output = null; using (new QuickTimer("LocalOrderClustering", 1)) { //output = BvhBuilderLocallyOrderedClustering.Create(tracePrimitives); //return output; } switch (bvhCreationOptions) { case BvhCreationOptions.LegacyFastConstructionSlowTracing: using (new QuickTimer("LegacyFastConstructionSlowTracing", 1)) { output = BvhBuilderBottomUp.Create(tracePrimitives, 0); } break; case BvhCreationOptions.LegacySlowConstructionFastTracing: using (new QuickTimer("LegacySlowConstructionFastTracing", 1)) { output = BvhBuilderBottomUp.Create(tracePrimitives); } break; case BvhCreationOptions.LocFastContructionFastTracing: using (new QuickTimer("LocFastContructionFastTracing", 1)) { output = BvhBuilderLocallyOrderedClustering.Create(tracePrimitives); } break; default: output = BvhBuilderBottomUp.Create(tracePrimitives); break; } return(output); }
public async Task Publish(MessageTopic topic, ITraceable message, Guid correlationId) { message.CorrelationId = correlationId; var queueName = topic.ToString().ToLowerInvariant(); var queue = TableClient.GetQueueReference(queueName); bool retry; int attempts = 0; do { retry = false; attempts++; try { var msg = new CloudQueueMessage(JsonConvert.SerializeObject(message)); _logger.LogInformation($"Published message {queueName}:{message.CorrelationId}"); await queue.AddMessageAsync(msg); } catch (StorageException ex) { _logger.LogError(ex, $"Error publishing message {queueName}:{message.CorrelationId}"); var ri = ex.RequestInformation; if (ri.HttpStatusCode == 404) // if error response is 404 then queue does not exist { _logger.LogInformation($"Creating queue {queueName}"); await queue.CreateIfNotExistsAsync(); _logger.LogInformation($"Created queue {queueName} successfully"); retry = true; } else { throw; } } } while (retry && attempts < 4); }
public ILogger Log(ErrorLevel level, object obj, IDictionary <string, object> custom = null) { Data data = obj as Data; if (data != null) { return(this.Log(data)); } System.Exception exception = obj as System.Exception; if (exception != null) { this.Report(exception, level, custom); return(this); } ITraceable traceable = obj as ITraceable; if (traceable != null) { return(this.Log(level, traceable.TraceAsString(), custom)); } return(this.Log(level, obj.ToString(), custom)); }
public ArticlesRulesSelectCommand(long dbVersion, IDbConnection connection, ITraceable trace) : base(connection, trace) { DbVersion = dbVersion; }
public TimeTablesSelectCommand(IDbConnection connection, ITraceable trace) : base(connection, trace) { }
public ILogger Debug(ITraceable traceableObj, IDictionary <string, object> custom = null) { return(this.Debug(traceableObj.TraceAsString(), custom)); }
/// <inheritdoc /> public void ComputeDerivativesTo(ITraceable traceable) { UnderlyingHandler.ComputeDerivativesTo(traceable); }
public ConstraintsSelectCommand(IDbConnection connection, ITraceable trace) : base(connection, trace) { }
public GBHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ object settings, object syncSettings) { var ser = new BasicServiceProvider(this); cpu = new LR35902 { ReadMemory = ReadMemory, WriteMemory = WriteMemory, PeekMemory = PeekMemory, DummyReadMemory = ReadMemory, OnExecFetch = ExecFetch, SpeedFunc = SpeedFunc, }; timer = new Timer(); audio = new Audio(); serialport = new SerialPort(); CoreComm = comm; _settings = (GBSettings)settings ?? new GBSettings(); _syncSettings = (GBSyncSettings)syncSettings ?? new GBSyncSettings(); _controllerDeck = new GBHawkControllerDeck(_syncSettings.Port1); byte[] Bios = null; // Load up a BIOS and initialize the correct PPU if (_syncSettings.ConsoleMode == GBSyncSettings.ConsoleModeType.Auto) { if (game.System == "GB") { Bios = comm.CoreFileProvider.GetFirmware("GB", "World", true, "BIOS Not Found, Cannot Load"); ppu = new GB_PPU(); } else { Bios = comm.CoreFileProvider.GetFirmware("GBC", "World", true, "BIOS Not Found, Cannot Load"); ppu = new GBC_PPU(); is_GBC = true; } } else if (_syncSettings.ConsoleMode == GBSyncSettings.ConsoleModeType.GB) { Bios = comm.CoreFileProvider.GetFirmware("GB", "World", true, "BIOS Not Found, Cannot Load"); ppu = new GB_PPU(); } else { Bios = comm.CoreFileProvider.GetFirmware("GBC", "World", true, "BIOS Not Found, Cannot Load"); ppu = new GBC_PPU(); is_GBC = true; } if (Bios == null) { throw new MissingFirmwareException("Missing Gamboy Bios"); } _bios = Bios; // Here we modify the BIOS if GBA mode is set (credit to ExtraTricky) if (is_GBC && _syncSettings.GBACGB) { for (int i = 0; i < 13; i++) { _bios[i + 0xF3] = (byte)((GBA_override[i] + _bios[i + 0xF3]) & 0xFF); } } // CPU needs to know about GBC status too cpu.is_GBC = is_GBC; Buffer.BlockCopy(rom, 0x100, header, 0, 0x50); string hash_md5 = null; hash_md5 = "md5:" + rom.HashMD5(0, rom.Length); Console.WriteLine(hash_md5); _rom = rom; Setup_Mapper(); _frameHz = 60; timer.Core = this; audio.Core = this; ppu.Core = this; serialport.Core = this; ser.Register <IVideoProvider>(this); ser.Register <ISoundProvider>(audio); ServiceProvider = ser; _settings = (GBSettings)settings ?? new GBSettings(); _syncSettings = (GBSyncSettings)syncSettings ?? new GBSyncSettings(); _tracer = new TraceBuffer { Header = cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); SetupMemoryDomains(); HardReset(); iptr0 = Marshal.AllocHGlobal(VRAM.Length + 1); iptr1 = Marshal.AllocHGlobal(OAM.Length + 1); iptr2 = Marshal.AllocHGlobal(color_palette.Length * 8 * 8 + 1); iptr3 = Marshal.AllocHGlobal(color_palette.Length * 8 * 8 + 1); _scanlineCallback = null; }
public OperationsSelectCommand(IDbConnection connection, ITraceable trace) : base(connection, trace) { }
public VectrexHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ object settings, object syncSettings) { var ser = new BasicServiceProvider(this); cpu = new MC6809 { ReadMemory = ReadMemory, WriteMemory = WriteMemory, PeekMemory = PeekMemory, DummyReadMemory = ReadMemory, OnExecFetch = ExecFetch, }; audio = new Audio(); ppu = new PPU(); serialport = new SerialPort(); CoreComm = comm; _settings = (VectrexSettings)settings ?? new VectrexSettings(); _syncSettings = (VectrexSyncSettings)syncSettings ?? new VectrexSyncSettings(); _controllerDeck = new VectrexHawkControllerDeck(_syncSettings.Port1, _syncSettings.Port2); byte[] Bios = null; byte[] Mine = null; Bios = comm.CoreFileProvider.GetFirmware("Vectrex", "Bios", true, "BIOS Not Found, Cannot Load"); _bios = Bios; Mine = comm.CoreFileProvider.GetFirmware("Vectrex", "Minestorm", true, "Minestorm Not Found, Cannot Load"); minestorm = Mine; Console.WriteLine("SHA1:" + rom.HashSHA1(0, rom.Length)); _rom = rom; // If the game is minstorm, then no cartridge is inserted, retun 0xFF if ((rom.HashSHA1(0, rom.Length) == "65D07426B520DDD3115D40F255511E0FD2E20AE7") || (rom.HashSHA1(0, rom.Length) == "1FDCC6E54AE5177BC9CDC79CE616AE3401E5C229")) { _rom = new byte[0x8000]; for (int i = 0; i < 0x8000; i++) { _rom[i] = 0xFF; } } // mirror games that are too small if (_rom.Length < 0x8000) { _rom = new byte[0x8000]; for (int i = 0; i < 0x8000 / rom.Length; i++) { for (int j = 0; j < rom.Length; j++) { _rom[j + i * rom.Length] = rom[j]; } } } // RAM appears to power up to either random values or 0xFF, otherwise all the asteroids in minestorm are on the same side if RAM[0x7E]=0 for (int i = 0; i < RAM.Length; i++) { RAM[i] = 0xFF; } Setup_Mapper(); _frameHz = 50; audio.Core = this; ppu.Core = this; serialport.Core = this; ser.Register <IVideoProvider>(this); ser.Register <ISoundProvider>(audio); ServiceProvider = ser; _settings = (VectrexSettings)settings ?? new VectrexSettings(); _syncSettings = (VectrexSyncSettings)syncSettings ?? new VectrexSyncSettings(); _tracer = new TraceBuffer { Header = cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); SetupMemoryDomains(); HardReset(); cpu.SetCallbacks(ReadMemory, PeekMemory, PeekMemory, WriteMemory); }
public O2Hawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ object settings, object syncSettings) { var ser = new BasicServiceProvider(this); cpu = new I8048 { ReadMemory = ReadMemory, WriteMemory = WriteMemory, PeekMemory = PeekMemory, DummyReadMemory = ReadMemory, ReadPort = ReadPort, WritePort = WritePort, OnExecFetch = ExecFetch, }; serialport = new SerialPort(); _settings = (O2Settings)settings ?? new O2Settings(); _syncSettings = (O2SyncSettings)syncSettings ?? new O2SyncSettings(); _controllerDeck = new O2HawkControllerDeck("O2 Controller", "O2 Controller"); byte[] Bios = null; Bios = comm.CoreFileProvider.GetFirmware("O2", "BIOS", true, "BIOS Not Found, Cannot Load"); ppu = new PPU(); if (Bios == null) { throw new MissingFirmwareException("Missing Odyssey2 Bios"); } _bios = Bios; Buffer.BlockCopy(rom, 0x100, header, 0, 0x50); Console.WriteLine("MD5: " + rom.HashMD5(0, rom.Length)); Console.WriteLine("SHA1: " + rom.HashSHA1(0, rom.Length)); _rom = rom; Setup_Mapper(); _frameHz = 60; ppu.Core = this; cpu.Core = this; serialport.Core = this; ser.Register <IVideoProvider>(this); ser.Register <ISoundProvider>(ppu); ServiceProvider = ser; _settings = (O2Settings)settings ?? new O2Settings(); _syncSettings = (O2SyncSettings)syncSettings ?? new O2SyncSettings(); _tracer = new TraceBuffer { Header = cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); ser.Register <IStatable>(new StateSerializer(SyncState)); SetupMemoryDomains(); HardReset(); /* * for (int i = 0; i < 64; i++) * { * cpu.Regs[i] = (byte)i; * } * * * for (int j = 0; j < 0x80; j++) * { * RAM[j] = (byte)j; * } * * for (int k = 0; k < 0x100; k++) * { * ppu.WriteReg(k, (byte)k); * } */ }
public CPDMMessage(ILoggerManager loggerManager) { m_pTrace = loggerManager.CreateTracer(this.GetType()); }
public GBHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ GBSettings settings, GBSyncSettings syncSettings) { var ser = new BasicServiceProvider(this); cpu = new LR35902 { ReadMemory = ReadMemory, WriteMemory = WriteMemory, PeekMemory = PeekMemory, DummyReadMemory = ReadMemory, OnExecFetch = ExecFetch, SpeedFunc = SpeedFunc, GetButtons = GetButtons, GetIntRegs = GetIntRegs, SetIntRegs = SetIntRegs }; timer = new Timer(); audio = new Audio(); serialport = new SerialPort(); _settings = (GBSettings)settings ?? new GBSettings(); _syncSettings = (GBSyncSettings)syncSettings ?? new GBSyncSettings(); byte[] Bios = null; // Load up a BIOS and initialize the correct PPU if (_syncSettings.ConsoleMode == GBSyncSettings.ConsoleModeType.Auto) { if (game.System == "GB") { Bios = comm.CoreFileProvider.GetFirmware("GB", "World", true, "BIOS Not Found, Cannot Load"); ppu = new GB_PPU(); } else { Bios = comm.CoreFileProvider.GetFirmware("GBC", "World", true, "BIOS Not Found, Cannot Load"); ppu = new GBC_PPU(); is_GBC = true; } } else if (_syncSettings.ConsoleMode == GBSyncSettings.ConsoleModeType.GB) { Bios = comm.CoreFileProvider.GetFirmware("GB", "World", true, "BIOS Not Found, Cannot Load"); ppu = new GB_PPU(); } else { Bios = comm.CoreFileProvider.GetFirmware("GBC", "World", true, "BIOS Not Found, Cannot Load"); ppu = new GBC_PPU(); is_GBC = true; } if (Bios == null) { throw new MissingFirmwareException("Missing Gamboy Bios"); } _bios = Bios; // set up IR register to off state if (is_GBC) { IR_mask = 0; IR_reg = 0x3E; IR_receive = 2; IR_self = 2; IR_signal = 2; } // Here we modify the BIOS if GBA mode is set (credit to ExtraTricky) if (is_GBC && _syncSettings.GBACGB) { for (int i = 0; i < 13; i++) { _bios[i + 0xF3] = (byte)((GBA_override[i] + _bios[i + 0xF3]) & 0xFF); } IR_mask = 2; } // CPU needs to know about GBC status too cpu.is_GBC = is_GBC; Buffer.BlockCopy(rom, 0x100, header, 0, 0x50); if (is_GBC && ((header[0x43] != 0x80) && (header[0x43] != 0xC0))) { ppu = new GBC_GB_PPU(); } Console.WriteLine("MD5: " + rom.HashMD5(0, rom.Length)); Console.WriteLine("SHA1: " + rom.HashSHA1(0, rom.Length)); _rom = rom; string mppr = Setup_Mapper(); if (cart_RAM != null) { cart_RAM_vbls = new byte[cart_RAM.Length]; } if (mppr == "MBC7") { _controllerDeck = new GBHawkControllerDeck(_syncSettings.Port1); } else { _controllerDeck = new GBHawkControllerDeck(GBHawkControllerDeck.DefaultControllerName); } timer.Core = this; audio.Core = this; ppu.Core = this; serialport.Core = this; ser.Register <IVideoProvider>(this); ser.Register <ISoundProvider>(audio); ServiceProvider = ser; _settings = (GBSettings)settings ?? new GBSettings(); _syncSettings = (GBSyncSettings)syncSettings ?? new GBSyncSettings(); _tracer = new TraceBuffer { Header = cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); ser.Register <IStatable>(new StateSerializer(SyncState)); SetupMemoryDomains(); cpu.SetCallbacks(ReadMemory, PeekMemory, PeekMemory, WriteMemory); HardReset(); iptr0 = Marshal.AllocHGlobal(VRAM.Length + 1); iptr1 = Marshal.AllocHGlobal(OAM.Length + 1); iptr2 = Marshal.AllocHGlobal(ppu.color_palette.Length * 8 * 8 + 1); iptr3 = Marshal.AllocHGlobal(ppu.color_palette.Length * 8 * 8 + 1); _scanlineCallback = null; /* * for (int i = 0; i < ZP_RAM.Length; i++) * { * ZP_RAM[i] = 0xFF; * } * * for (int i = 0; i < RAM.Length; i++) * { * RAM[i] = 0xFF; * } */ }
public static PromiseMethodContinuer GetOrCreate <TStateMachine>(ref TStateMachine stateMachine, ITraceable owner) where TStateMachine : IAsyncStateMachine { var continuer = Continuer <TStateMachine> .ReuseOrNew(ref stateMachine); #if PROMISE_DEBUG continuer._owner = owner; #endif return(continuer); }
private void Init(GameInfo game, byte[] rom) { Cpu = new HuC6280(MemoryCallbacks); VCE = new VCE(); VDC1 = new VDC(this, Cpu, VCE); PSG = new HuC6280PSG(735); SCSI = new ScsiCDBus(this, disc); Cpu.Logger = s => Tracer.Put(s); if (TurboGrafx) { Ram = new byte[0x2000]; Cpu.ReadMemory21 = ReadMemory; Cpu.WriteMemory21 = WriteMemory; Cpu.WriteVDC = VDC1.WriteVDC; _soundProvider = PSG; CDAudio = new CDAudio(null, 0); } else if (SuperGrafx) { VDC2 = new VDC(this, Cpu, VCE); VPC = new VPC(this, VDC1, VDC2, VCE, Cpu); Ram = new byte[0x8000]; Cpu.ReadMemory21 = ReadMemorySGX; Cpu.WriteMemory21 = WriteMemorySGX; Cpu.WriteVDC = VDC1.WriteVDC; _soundProvider = PSG; CDAudio = new CDAudio(null, 0); } else if (TurboCD) { Ram = new byte[0x2000]; CDRam = new byte[0x10000]; ADPCM = new ADPCM(this, SCSI); Cpu.ReadMemory21 = ReadMemoryCD; Cpu.WriteMemory21 = WriteMemoryCD; Cpu.WriteVDC = VDC1.WriteVDC; CDAudio = new CDAudio(disc); SetCDAudioCallback(); PSG.MaxVolume = short.MaxValue * 3 / 4; SoundMixer = new SoundMixer(735, PSG, CDAudio, ADPCM); _soundProvider = SoundMixer; Cpu.ThinkAction = cycles => { SCSI.Think(); ADPCM.Think(cycles); }; } if (rom.Length == 0x60000) { // 384k roms require special loading code. Why ;_; // In memory, 384k roms look like [1st 256k][Then full 384k] RomData = new byte[0xA0000]; var origRom = rom; for (int i = 0; i < 0x40000; i++) { RomData[i] = origRom[i]; } for (int i = 0; i < 0x60000; i++) { RomData[i + 0x40000] = origRom[i]; } RomLength = RomData.Length; } else if (rom.Length > 1024 * 1024) { // If the rom is bigger than 1 megabyte, switch to Street Fighter 2 mapper Cpu.ReadMemory21 = ReadMemorySF2; Cpu.WriteMemory21 = WriteMemorySF2; RomData = rom; RomLength = RomData.Length; // user request: current value of the SF2MapperLatch on the tracelogger Cpu.Logger = s => Tracer.Put(new TraceInfo { Disassembly = $"{SF2MapperLatch:X1}:{s}", RegisterInfo = "" }); } else { // normal rom. RomData = rom; RomLength = RomData.Length; } if (game["BRAM"] || Type == NecSystemType.TurboCD) { BramEnabled = true; BRAM = new byte[2048]; // pre-format BRAM. damn are we helpful. BRAM[0] = 0x48; BRAM[1] = 0x55; BRAM[2] = 0x42; BRAM[3] = 0x4D; BRAM[4] = 0x00; BRAM[5] = 0x88; BRAM[6] = 0x10; BRAM[7] = 0x80; } if (game["SuperSysCard"]) { SuperRam = new byte[0x30000]; } if (game["ArcadeCard"]) { ArcadeRam = new byte[0x200000]; ArcadeCard = true; ArcadeCardRewindHack = Settings.ArcadeCardRewindHack; for (int i = 0; i < 4; i++) { ArcadePage[i] = new ArcadeCardPage(); } } if (game["PopulousSRAM"]) { PopulousRAM = new byte[0x8000]; Cpu.ReadMemory21 = ReadMemoryPopulous; Cpu.WriteMemory21 = WriteMemoryPopulous; } // the gamedb can force sprite limit on, ignoring settings if (game["ForceSpriteLimit"] || game.NotInDatabase) { ForceSpriteLimit = true; } if (game["CdVol"]) { CDAudio.MaxVolume = int.Parse(game.OptionValue("CdVol")); } if (game["PsgVol"]) { PSG.MaxVolume = int.Parse(game.OptionValue("PsgVol")); } if (game["AdpcmVol"]) { ADPCM.MaxVolume = int.Parse(game.OptionValue("AdpcmVol")); } // the gamedb can also force equalizevolumes on if (TurboCD && (Settings.EqualizeVolume || game["EqualizeVolumes"] || game.NotInDatabase)) { SoundMixer.EqualizeVolumes(); } // Ok, yes, HBlankPeriod's only purpose is game-specific hax. // 1) At least they're not coded directly into the emulator, but instead data-driven. // 2) The games which have custom HBlankPeriods work without it, the override only // serves to clean up minor gfx anomalies. // 3) There's no point in haxing the timing with incorrect values in an attempt to avoid this. // The proper fix is cycle-accurate/bus-accurate timing. That isn't coming to the C# // version of this core. Let's just acknolwedge that the timing is imperfect and fix // it in the least intrusive and most honest way we can. if (game["HBlankPeriod"]) { VDC1.HBlankCycles = game.GetIntValue("HBlankPeriod"); } // This is also a hack. Proper multi-res/TV emulation will be a native-code core feature. if (game["MultiResHack"]) { VDC1.MultiResHack = game.GetIntValue("MultiResHack"); } Cpu.ResetPC(); Tracer = new TraceBuffer { Header = Cpu.TraceHeader }; var ser = new BasicServiceProvider(this); ServiceProvider = ser; ser.Register <ITraceable>(Tracer); ser.Register <IDisassemblable>(Cpu); ser.Register <IVideoProvider>((IVideoProvider)VPC ?? VDC1); ser.Register <ISoundProvider>(_soundProvider); ser.Register <IStatable>(new StateSerializer(SyncState)); SetupMemoryDomains(); }
public TariffsConstraintsMaxVersionCommand(IDbConnection connection, ITraceable trace) : base(connection, trace) { }
public GetActualPayedQuantityForOperationCommand(long operationId, IDbConnection connection, ITraceable trace) : base(connection, trace) { OperationId = operationId; }
public GBHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ object settings, object syncSettings) { var ser = new BasicServiceProvider(this); cpu = new LR35902 { ReadMemory = ReadMemory, WriteMemory = WriteMemory, PeekMemory = PeekMemory, DummyReadMemory = ReadMemory, OnExecFetch = ExecFetch }; ppu = new PPU(); timer = new Timer(); audio = new Audio(); serialport = new SerialPort(); CoreComm = comm; _settings = (GBSettings)settings ?? new GBSettings(); _syncSettings = (GBSyncSettings)syncSettings ?? new GBSyncSettings(); _controllerDeck = new GBHawkControllerDeck(_syncSettings.Port1); byte[] Bios = comm.CoreFileProvider.GetFirmware("GB", "World", false, "BIOS Not Found, Cannot Load"); if (Bios == null) { throw new MissingFirmwareException("Missing Gamboy Bios"); } _bios = Bios; Buffer.BlockCopy(rom, 0x100, header, 0, 0x50); string hash_md5 = null; hash_md5 = "md5:" + rom.HashMD5(0, rom.Length); Console.WriteLine(hash_md5); _rom = rom; Setup_Mapper(); _frameHz = 60; timer.Core = this; audio.Core = this; ppu.Core = this; serialport.Core = this; ser.Register <IVideoProvider>(this); ser.Register <ISoundProvider>(audio); ServiceProvider = ser; _settings = (GBSettings)settings ?? new GBSettings(); _syncSettings = (GBSyncSettings)syncSettings ?? new GBSyncSettings(); _tracer = new TraceBuffer { Header = cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); SetupMemoryDomains(); HardReset(); iptr0 = Marshal.AllocHGlobal(CHR_RAM.Length + BG_map_1.Length + BG_map_2.Length + 1); iptr1 = Marshal.AllocHGlobal(OAM.Length + 1); iptr2 = Marshal.AllocHGlobal(color_palette.Length * 2 * 8 + 1); iptr3 = Marshal.AllocHGlobal(color_palette.Length * 8 + 1); _scanlineCallback = null; }
public O2Hawk(CoreComm comm, GameInfo game, byte[] rom, O2Settings settings, O2SyncSettings syncSettings) { var ser = new BasicServiceProvider(this); cpu = new I8048 { ReadMemory = ReadMemory, WriteMemory = WriteMemory, PeekMemory = PeekMemory, DummyReadMemory = ReadMemory, ReadPort = ReadPort, WritePort = WritePort, OnExecFetch = ExecFetch, }; _settings = settings ?? new O2Settings(); _syncSettings = syncSettings ?? new O2SyncSettings(); is_G7400 = _syncSettings.G7400_Enable; _controllerDeck = new O2HawkControllerDeck("O2 Controller", "O2 Controller", is_G7400); _bios = comm.CoreFileProvider.GetFirmwareOrThrow(new("O2", is_G7400 ? "BIOS-G7400" : "BIOS-O2"), "BIOS Not Found, Cannot Load"); Buffer.BlockCopy(rom, 0x100, header, 0, 0x50); Console.WriteLine("MD5: " + rom.HashMD5(0, rom.Length)); Console.WriteLine("SHA1: " + rom.HashSHA1(0, rom.Length)); _rom = rom; if (game["XROM"]) { is_XROM = true; } Setup_Mapper(); _frameHz = 60; ser.Register <IVideoProvider>(this); ServiceProvider = ser; _tracer = new TraceBuffer(cpu.TraceHeader); ser.Register(_tracer); ser.Register <IStatable>(new StateSerializer(SyncState)); SetupMemoryDomains(); cpu.SetCallbacks(ReadMemory, PeekMemory, PeekMemory, WriteMemory); // set up differences between PAL and NTSC systems if ((game.Region == "US" || game.Region == "EU-US" || game.Region == null) && !is_G7400) { is_pal = false; pic_height = 240; _frameHz = 60; ppu = new NTSC_PPU(); } else { is_pal = true; pic_height = 240; _frameHz = 50; ppu = new PAL_PPU(); } ppu.Core = this; ppu.set_region(is_pal, is_G7400); ser.Register <ISoundProvider>(ppu); _vidbuffer = new int[372 * pic_height]; frame_buffer = new int[320 * pic_height]; HardReset(); }
public A7800Hawk(CoreComm comm, GameInfo game, byte[] rom, string gameDbFn, object settings, object syncSettings) { var ser = new BasicServiceProvider(this); maria = new Maria(); tia = new TIA(); m6532 = new M6532(); pokey = new Pokey(); cpu = new MOS6502X <CpuLink>(new CpuLink(this)); maria = new Maria { ReadMemory = ReadMemory }; CoreComm = comm; _blip.SetRates(1789773, 44100); _settings = (A7800Settings)settings ?? new A7800Settings(); _syncSettings = (A7800SyncSettings)syncSettings ?? new A7800SyncSettings(); _controllerDeck = new A7800HawkControllerDeck(_syncSettings.Port1, _syncSettings.Port2); byte[] highscoreBios = comm.CoreFileProvider.GetFirmware("A78", "Bios_HSC", false, "Some functions may not work without the high score BIOS."); byte[] palBios = comm.CoreFileProvider.GetFirmware("A78", "Bios_PAL", false, "The game will not run if the correct region BIOS is not available."); byte[] ntscBios = comm.CoreFileProvider.GetFirmware("A78", "Bios_NTSC", false, "The game will not run if the correct region BIOS is not available."); byte[] header = new byte[128]; bool is_header = false; if (rom.Length % 1024 == 128) { Console.WriteLine("128 byte header detected"); byte[] newrom = new byte[rom.Length - 128]; is_header = true; Buffer.BlockCopy(rom, 0, header, 0, 128); Buffer.BlockCopy(rom, 128, newrom, 0, newrom.Length); rom = newrom; } _isPAL = false; // look up hash in gamedb to see what mapper to use // if none found default is zero // also check for PAL region string hash_md5 = null; s_mapper = null; hash_md5 = "md5:" + rom.HashMD5(0, rom.Length); var gi = Database.CheckDatabase(hash_md5); if (gi != null) { var dict = gi.GetOptionsDict(); if (dict.ContainsKey("PAL")) { _isPAL = true; } if (dict.ContainsKey("board")) { s_mapper = dict["board"]; } else { throw new Exception("No Board selected for this game"); } // check if the game uses pokey or RAM if (dict.ContainsKey("RAM")) { int.TryParse(dict["RAM"], out cart_RAM); Console.WriteLine(cart_RAM); } if (dict.ContainsKey("Pokey")) { bool.TryParse(dict["Pokey"], out is_pokey); } // some games will not function with the high score bios // if such a game is being played, tell the user and disable it if (dict.ContainsKey("No_HS")) { bool no_hs; bool.TryParse(dict["No_HS"], out no_hs); if (no_hs) { Console.WriteLine("This game is incompatible with the High Score BIOS, disabling it"); highscoreBios = null; } } } else if (is_header) { Console.WriteLine("ROM not in DB, inferring mapper info from header"); byte cart_1 = header[0x35]; byte cart_2 = header[0x36]; _isPAL = (header[0x39] > 0); if (cart_2.Bit(1)) { if (cart_2.Bit(3)) { s_mapper = "2"; } else { s_mapper = "1"; } if (cart_2.Bit(2)) { cart_RAM = 8; } } else { s_mapper = "0"; } if (cart_2.Bit(0)) { is_pokey = true; } } else { throw new Exception("ROM not in gamedb and has no header"); } // some games that use the Super Game mapper only have 4 banks, so let's set a flag to limit bank size if (rom.Length < 0x14000) { small_flag = true; // additionally, PAL Karateka has bank 6 (actually 2) at 0x4000 if (rom.HashMD5() == "5E0A1E832BBCEA6FACB832FDE23A440A") { PAL_Kara = true; } } _rom = rom; Reset_Mapper(s_mapper); _hsbios = highscoreBios; _bios = _isPAL ? palBios : ntscBios; if (_bios == null) { throw new MissingFirmwareException("The BIOS corresponding to the region of the game you loaded is required to run Atari 7800 games."); } // set up palette and frame rate if (_isPAL) { _frameHz = 50; _screen_width = 320; _screen_height = 313; _vblanklines = 20; maria._palette = PALPalette; } else { _frameHz = 60; _screen_width = 320; _screen_height = 263; _vblanklines = 20; maria._palette = NTSCPalette; } maria.Core = this; m6532.Core = this; tia.Core = this; pokey.Core = this; ser.Register <IVideoProvider>(this); ser.Register <ISoundProvider>(this); ServiceProvider = ser; _tracer = new TraceBuffer { Header = cpu.TraceHeader }; ser.Register <ITraceable>(_tracer); SetupMemoryDomains(); ser.Register <IDisassemblable>(cpu); HardReset(); }
public CDatM(ILoggerManager loggerManager) : this() { trace = loggerManager.CreateTracer(this.GetType()); Clear(); }