예제 #1
0
        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));
        }