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)); }
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); } }
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); }