Mesen-SX/Core/EventManager.h

123 lines
3 KiB
C
Raw Normal View History

2019-03-07 20:12:32 -05:00
#pragma once
#include "stdafx.h"
#include "DmaController.h"
#include "DebugTypes.h"
#include "../Utilities/SimpleLock.h"
enum class DebugEventType;
struct DebugEventInfo;
struct EventViewerDisplayOptions;
class Cpu;
class Ppu;
class Debugger;
class DmaController;
2019-03-07 20:12:32 -05:00
class EventManager
{
private:
Cpu * _cpu;
Ppu *_ppu;
DmaController *_dmaController;
2019-03-07 20:12:32 -05:00
Debugger *_debugger;
vector<DebugEventInfo> _debugEvents;
vector<DebugEventInfo> _prevDebugEvents;
vector<DebugEventInfo> _sentEvents;
vector<DebugEventInfo> _snapshot;
uint16_t _snapshotScanline;
uint16_t _snapshotCycle;
2019-03-07 20:12:32 -05:00
SimpleLock _lock;
bool _overscanMode = false;
bool _useHighResOutput = false;
uint32_t _scanlineCount = 262;
uint16_t *_ppuBuffer;
2019-03-07 20:12:32 -05:00
void DrawEvent(DebugEventInfo &evt, bool drawBackground, uint32_t *buffer, EventViewerDisplayOptions &options);
void FilterEvents(EventViewerDisplayOptions &options);
2019-03-07 20:12:32 -05:00
public:
EventManager(Debugger *debugger, Cpu *cpu, Ppu *ppu, DmaController *dmaController);
~EventManager();
2019-03-07 20:12:32 -05:00
void AddEvent(DebugEventType type, MemoryOperationInfo &operation, int32_t breakpointId = -1);
void AddEvent(DebugEventType type);
void GetEvents(DebugEventInfo *eventArray, uint32_t &maxEventCount);
uint32_t GetEventCount(EventViewerDisplayOptions options);
2019-03-07 20:12:32 -05:00
void ClearFrameEvents();
uint32_t TakeEventSnapshot(EventViewerDisplayOptions options);
2019-03-07 20:12:32 -05:00
void GetDisplayBuffer(uint32_t *buffer, EventViewerDisplayOptions options);
DebugEventInfo GetEvent(uint16_t scanline, uint16_t cycle, EventViewerDisplayOptions &options);
};
enum class DebugEventType
{
Register,
Nmi,
Irq,
Breakpoint
};
struct DebugEventInfo
{
MemoryOperationInfo Operation;
DebugEventType Type;
uint32_t ProgramCounter;
uint16_t Scanline;
uint16_t Cycle;
int16_t BreakpointId;
int8_t DmaChannel;
DmaChannelConfig DmaChannelInfo;
2019-03-07 20:12:32 -05:00
};
struct EventViewerDisplayOptions
{
uint32_t IrqColor;
uint32_t NmiColor;
uint32_t BreakpointColor;
uint32_t PpuRegisterReadColor;
uint32_t PpuRegisterWriteCgramColor;
uint32_t PpuRegisterWriteVramColor;
uint32_t PpuRegisterWriteOamColor;
uint32_t PpuRegisterWriteMode7Color;
uint32_t PpuRegisterWriteBgOptionColor;
uint32_t PpuRegisterWriteBgScrollColor;
uint32_t PpuRegisterWriteWindowColor;
uint32_t PpuRegisterWriteOtherColor;
uint32_t ApuRegisterReadColor;
uint32_t ApuRegisterWriteColor;
uint32_t CpuRegisterReadColor;
uint32_t CpuRegisterWriteColor;
uint32_t WorkRamRegisterReadColor;
uint32_t WorkRamRegisterWriteColor;
bool ShowPpuRegisterCgramWrites;
bool ShowPpuRegisterVramWrites;
bool ShowPpuRegisterOamWrites;
bool ShowPpuRegisterMode7Writes;
bool ShowPpuRegisterBgOptionWrites;
bool ShowPpuRegisterBgScrollWrites;
bool ShowPpuRegisterWindowWrites;
bool ShowPpuRegisterOtherWrites;
2019-03-07 20:12:32 -05:00
bool ShowPpuRegisterReads;
bool ShowCpuRegisterWrites;
bool ShowCpuRegisterReads;
bool ShowApuRegisterWrites;
bool ShowApuRegisterReads;
bool ShowWorkRamRegisterWrites;
bool ShowWorkRamRegisterReads;
bool ShowNmi;
bool ShowIrq;
bool ShowMarkedBreakpoints;
bool ShowPreviousFrameEvents;
bool ShowDmaChannels[8];
2019-03-07 20:12:32 -05:00
};