private void RefreshBreakpoints() { //lock (emulatorLock) { SnesDebugApi.SetBreakpoints(_breakpoints.ToArray(), (UInt32)_breakpoints.Count); } }
private void HandleNotification(NotificationEventArgs e) { switch (e.NotificationType) { case ConsoleNotificationType.GameLoaded: if (!SnesApi.IsPaused()) { RefreshBreakpoints(); } GameLoaded(); if (OnRun != null) { OnRun(); } if (OnStatusChange != null) { OnStatusChange(EmulatorStatus.Playing); } EmitDebugData(); break; case ConsoleNotificationType.CodeBreak: var source = (SnesBreakSource)(byte)e.Parameter.ToInt64(); //if (source == SnesBreakSource.Breakpoint && OnBreak != null) if (OnBreak != null) { var state = SnesDebugApi.GetState(); var address = SnesDebugApi.GetAbsoluteAddress(new AddressInfo { Address = (state.Cpu.K << 16) | state.Cpu.PC, Type = SnesMemoryType.CpuMemory }); OnBreak(address.Address); } if (OnStatusChange != null) { OnStatusChange(EmulatorStatus.Paused); } EmitDebugData(); break; case ConsoleNotificationType.PpuFrameDone: CountFrame(); break; } if (e.NotificationType == ConsoleNotificationType.PpuFrameDone) { return; } if (e.NotificationType == ConsoleNotificationType.EventViewerRefresh) { return; } var status = string.Format("Emulator: {0}", e.NotificationType.ToString()); _logHandler(new LogData(status, LogType.Normal)); }
public void Pause() { if (!IsRunning()) { return; } SnesDebugApi.Step(CpuType.Cpu, 1); }
private void GetTileMapData() { _tilemapOptions.Layer = (byte)_state.TileMaps.GetPage; _state.TileMaps.MapWidth = GetMapWidth(); _state.TileMaps.MapHeight = GetMapHeight(); SnesDebugApi.GetTilemap(_tilemapOptions, _state.SnesState.Ppu, _state.Memory.PpuData, _state.Memory.CgRam, _state.TileMaps.PixelData[0]); _state.TileMaps.ViewportHeight = _state.SnesState.Ppu.OverscanMode ? 239 : 224; _state.TileMaps.ScrollX = (_state.SnesState.Ppu.BgMode == 7 ? (int)_state.SnesState.Ppu.Mode7.HScroll : _state.SnesState.Ppu.Layers[_tilemapOptions.Layer].HScroll) % _state.TileMaps.MapWidth; _state.TileMaps.ScrollY = (_state.SnesState.Ppu.BgMode == 7 ? (int)_state.SnesState.Ppu.Mode7.VScroll : _state.SnesState.Ppu.Layers[_tilemapOptions.Layer].VScroll) % _state.TileMaps.MapHeight; }
private void PushTileMapData() { _state.Memory.CgRam = SnesDebugApi.GetMemoryState(SnesMemoryType.CGRam); _state.Memory.PpuData = SnesDebugApi.GetMemoryState(SnesMemoryType.VideoRam); _state.SnesState = _state.SnesState = SnesDebugApi.GetState(); GetTileMapData(); if (OnRegisterUpdate != null) { OnRegisterUpdate(_state); } }
private void GetCharacterData() { _tileViewOptions.Format = (TileFormat)_state.CharacterData.ColorMode; _tileViewOptions.Width = 16; _tileViewOptions.PageSize = 0x10000; var source = SnesDebugApi.GetMemoryState(SnesMemoryType.VideoRam); var address = 0; var size = Math.Min(source.Length - address, _tileViewOptions.PageSize); Array.Copy(source, address, _tileSource, 0, size); _state.CharacterData.Width = 128; _state.CharacterData.Height = GetChrHeight(_tileViewOptions, _state.CharacterData.ColorMode); SnesDebugApi.GetTileView(_tileViewOptions, _tileSource, _tileSource.Length, _state.Memory.CgRam, _state.CharacterData.PixelData[0]); }
protected override void EmitDebugData() { if (OnRegisterUpdate == null) { return; } _state.SnesState = SnesDebugApi.GetState(); _state.Memory.PpuData = SnesDebugApi.GetMemoryState(SnesMemoryType.VideoRam); _state.Memory.OamData = SnesDebugApi.GetMemoryState(SnesMemoryType.SpriteRam); _state.Memory.CgRam = SnesDebugApi.GetMemoryState(SnesMemoryType.CGRam); _state.Memory.CpuData = SnesDebugApi.GetMemoryState(SnesMemoryType.CpuMemory); _state.Memory.X = _state.SnesState.Cpu.X & (_state.SnesState.Cpu.PS.HasFlag(ProcFlags.IndexMode8) ? 0xFF : 0xFFFF); _state.Memory.Y = _state.SnesState.Cpu.Y & (_state.SnesState.Cpu.PS.HasFlag(ProcFlags.IndexMode8) ? 0xFF : 0xFFFF); SnesDebugApi.GetSpritePreview(_spriteOptions, _state.SnesState.Ppu, _state.Memory.PpuData, _state.Memory.OamData, _state.Memory.CgRam, _state.Sprites.PixelData); _state.Sprites.Details = Sprite.GetSnesSprites(_state.Memory.OamData, _state.SnesState.Ppu.OamMode); GetCharacterData(); GetTileMapData(); OnRegisterUpdate(_state); }
public void StepOver() { SnesDebugApi.Step(CpuType.Cpu, 1, StepType.StepOver); }
public void StepInto() { SnesDebugApi.Step(CpuType.Cpu, 1, StepType.Step); }
public static byte[] GetMemoryState(SnesMemoryType type) { byte[] buffer = new byte[DebugApi.GetMemorySize(type)]; DebugApi.GetMemoryStateWrapper(type, buffer); return(buffer); }
public static byte[] GetEventViewerOutput(UInt32 scanlineCount, EventViewerDisplayOptions options) { byte[] buffer = new byte[340 * 2 * scanlineCount * 2 * 4]; DebugApi.GetEventViewerOutputWrapper(buffer, options); return(buffer); }
public void SetPpuMemory(int offset, byte value) { SnesDebugApi.SetMemoryValue(SnesMemoryType.VideoRam, (uint)offset, value); }
public void SetOamMemory(int offset, byte value) { SnesDebugApi.SetMemoryValue(SnesMemoryType.SpriteRam, (uint)offset, value); }
public static byte[] GetEventViewerOutput(EventViewerDisplayOptions options) { byte[] buffer = new byte[340 * 2 * 262 * 2 * 4]; DebugApi.GetEventViewerOutputWrapper(buffer, options); return(buffer); }
public void SetCpuMemory(int offset, byte value) { // TODO: Is emulator running? SnesDebugApi.SetMemoryValue(SnesMemoryType.CpuMemory, (uint)offset, value); }
public static AddressCounters[] GetMemoryAccessCounts(UInt32 offset, UInt32 length, SnesMemoryType type) { AddressCounters[] counts = new AddressCounters[length]; DebugApi.GetMemoryAccessCountsWrapper(offset, length, type, counts); return(counts); }
public static UInt64[] GetMemoryAccessStamps(UInt32 offset, UInt32 length, SnesMemoryType type, MemoryOperationType operationType) { UInt64[] stamps = new UInt64[length]; DebugApi.GetMemoryAccessStampsWrapper(offset, length, type, operationType, stamps); return(stamps); }
public void StepOut() { SnesDebugApi.Step(CpuType.Cpu, 1, StepType.StepOut); }
public static UInt32[] GetMemoryAccessCounts(UInt32 offset, UInt32 length, SnesMemoryType type, MemoryOperationType operationType) { UInt32[] counts = new UInt32[length]; DebugApi.GetMemoryAccessCountsWrapper(offset, length, type, operationType, counts); return(counts); }
public static string GetScriptLog(Int32 scriptId) { return(Utf8Marshaler.PtrToStringUtf8(DebugApi.GetScriptLogWrapper(scriptId)).Replace("\n", Environment.NewLine)); }
public static string GetExecutionTrace(UInt32 lineCount) { return(Utf8Marshaler.PtrToStringUtf8(DebugApi.GetExecutionTraceWrapper(lineCount))); }
public static byte[] GetCdlData(UInt32 offset, UInt32 length, SnesMemoryType memType) { byte[] cdlData = new byte[length]; DebugApi.GetCdlDataWrapper(offset, length, memType, cdlData); return(cdlData); }
public void InitDebugger() { //var debuggerAlreadyRunning = SnesDebugApi.DebugIsDebuggerRunning(); SnesDebugApi.InitializeDebugger(); }
public static string GetLog() { return(Utf8Marshaler.PtrToStringUtf8(DebugApi.GetDebuggerLogWrapper()).Replace("\n", Environment.NewLine)); }