// // VCC (Virtual Color Computer) is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // VCC (Virtual Color Computer) is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with VCC (Virtual Color Computer). If not, see . // // OpDecoder Interface - Part of the Debugger package for VCC // Author: Mike Rojas #pragma once #include "../../src/core/BuildConfig.h" #include "Windows.h" #include #include #include #include "../../src/core/OpCodeTables.h" #include "../../src/core/MachineDefs.h" namespace VCC::Debugger { class OpDecoder { public: OpDecoder() { Reset(500000); }; // Interrupt Types on a 6x09 microprocessor enum class IRQType { InterruptRequest, FastInterruptRequest, NonMaskableInterrupt }; void Reset(long maxSamples); void CaptureBefore(long cycleTime, const CPUState& state); void CaptureAfter(long cycleTime, const CPUState& state); void CaptureInterrupt(TraceEvent evt, IRQType irq, long cycleTime, const CPUState& state); #if USE_NEWTIMING void CaptureScreenEvent(TraceEvent evt, double cycles, unsigned int line); void CaptureScreenEvent(TraceEvent evt, double cycles, unsigned int line, const char *s); #else void CaptureScreenEvent(TraceEvent evt, double cycles); #endif void CaptureEmulatorCycle(TraceEvent evt, int state, double lineNS, double irqNS, double soundNS, double cycles, double drift); const std::vector& GetTrace() const; size_t GetSampleCount() const; IRQType ToIRQType(unsigned char irq) const; bool DecodeInstruction(const CPUState& state, CPUTrace& trace); protected: bool DecodeInterrupt(TraceEvent evt, IRQType irq, std::string& interrupt) const; #if USE_NEWTIMING bool DecodeScreen(TraceEvent evt, std::string& screen, unsigned int n, const char *s); #else bool DecodeScreen(TraceEvent evt, std::string& screen); #endif bool DecodePage2Instruction(unsigned short PC, const CPUState& state, CPUTrace& trace); bool DecodePage3Instruction(unsigned short PC, const CPUState& state, CPUTrace& trace); private: std::unique_ptr OpCodeTables_; std::vector TraceCaptured_; CPUTrace CurrentTrace_; long TotalCycles_ = 0; long BeforeCycles_ = 0; long AfterCycles_ = 0; int CurrentFrame_ = 0; int CurrentLine_ = 0; }; }