10#include "PeddleConfig.h"
11#include "PeddleTypes.h"
12#include "PeddleDisassembler.h"
13#include "PeddleDebugger.h"
14#include "SubComponent.h"
15#include "PeddleUtils.h"
16#include "TimeDelayed.h"
20namespace vc64::peddle {
22class Peddle :
public SubComponent {
24 friend class Debugger;
25 friend class Disassembler;
26 friend class Breakpoints;
27 friend class Watchpoints;
36 static MicroInstruction actionFunc[256];
39 static const char *mnemonic[256];
42 static AddressingMode addressingMode[256];
55 CPURevision cpuModel = MOS_6510;
64 Debugger debugger = Debugger(*
this);
65 Disassembler disassembler = Disassembler(*
this);
83 MicroInstruction next;
132 TimeDelayed <u8,1> edgeDetector = TimeDelayed <u8,1> (&clock);
142 TimeDelayed <u8,1> levelDetector = TimeDelayed <u8,1> (&clock);
173 virtual ~Peddle() =
default;
183 void registerInstructions();
184 void registerLegalInstructions();
185 void registerIllegalInstructions();
188 void registerCallback(u8 opcode,
189 const char *mnemonic,
191 MicroInstruction mInstr);
201 void setModel(CPURevision cpuModel);
211 u16 hasProcessorPort()
const;
212 template <CPURevision C> u16 hasProcessorPort()
const;
215 u16 addrMask()
const;
216 template <CPURevision C> u16 addrMask()
const;
219 bool inFetchPhase()
const {
return next == fetch; }
229 isize getLengthOfInstruction(u8 opcode)
const;
230 isize getLengthOfInstructionAt(u16 addr)
const;
231 isize getLengthOfCurrentInstruction()
const;
234 u16 getAddressOfNextInstruction()
const;
245 template <CPURevision C>
void reset();
249 template <CPURevision C>
void execute();
252 void execute(
int count);
253 template <CPURevision C>
void execute(
int count);
256 void executeInstruction();
257 template <CPURevision C>
void executeInstruction();
260 void executeInstruction(
int count);
261 template <CPURevision C>
void executeInstruction(
int count);
264 void finishInstruction();
265 template <CPURevision C>
void finishInstruction();
270 template <CPURevision C>
void done();
280 void pullDownNmiLine(IntSource source);
281 void pullDownIrqLine(IntSource source);
284 void releaseNmiLine(IntSource source);
285 void releaseIrqLine(IntSource source);
288 IntSource getNmiLine()
const {
return nmiLine; }
289 IntSource getIrqLine()
const {
return irqLine; }
292 void setRDY(
bool value);
309 u16 getPC0()
const {
return reg.pc0; }
311 u16 getSP()
const {
return reg.sp; }
313 bool getN()
const {
return reg.sr.n; }
314 void setN(
bool value) { reg.sr.n = value; }
316 bool getV()
const {
return reg.sr.v; }
317 void setV(
bool value) { reg.sr.v = value; }
319 bool getB()
const {
return reg.sr.b; }
320 void setB(
bool value) { reg.sr.b = value; }
322 bool getD()
const {
return reg.sr.d; }
323 void setD(
bool value) { reg.sr.d = value; }
325 bool getI()
const {
return reg.sr.i; }
326 void setI(
bool value) { reg.sr.i = value; }
328 bool getZ()
const {
return reg.sr.z; }
329 void setZ(
bool value) { reg.sr.z = value; }
331 bool getC()
const {
return reg.sr.c; }
332 void setC(
bool value) { reg.sr.c = value; }
339 u8 getPWithClearedB()
const;
340 void setPWithoutB(u8 p);
349 template <CPURevision C> u8 read(u16 addr);
350 template <CPURevision C> u8 readZeroPage(u8 addr);
351 template <CPURevision C> u8 readStack(u8 sp);
353 template <CPURevision C>
void readIdle(u16 addr);
354 template <CPURevision C>
void readZeroPageIdle(u8 addr);
355 template <CPURevision C>
void readStackIdle(u8 sp);
357 template <CPURevision C>
void write(u16 addr, u8 value);
358 template <CPURevision C>
void writeZeroPage(u8 addr, u8 value);
359 template <CPURevision C>
void writeStack(u8 sp, u8 value);
361 template <CPURevision C> u16 readDasm(u16 addr)
const;
371 virtual u8 read(u16 addr) {
return 0; }
372 virtual void write(u16 addr, u8 val) { };
373 virtual u8 readDasm(u16 addr)
const {
return 0; }
374 virtual u16 readResetVector();
384 virtual u8 readPort()
const;
385 virtual u8 readPortDir()
const {
return reg.pport.direction; }
388 virtual void writePort(u8 val) { reg.pport.data = val; }
389 virtual void writePortDir(u8 val) { reg.pport.direction = val; }
394 virtual u8 externalPortBits()
const {
return 0; }
404 virtual void cpuDidJam() { }
407 virtual void irqWillTrigger() { }
408 virtual void irqDidTrigger() { }
409 virtual void nmiWillTrigger() { }
410 virtual void nmiDidTrigger() { }
413 virtual void breakpointReached(u16 addr)
const { }
414 virtual void watchpointReached(u16 addr)
const { }
415 virtual void instructionLogged()
const { }
416 virtual void jumpedTo(u16 addr)
const { }
426 void adcBinary(u8 op);
429 void sbcBinary(u8 op);
431 void cmp(u8 op1, u8 op2);
VirtualC64 project namespace.
Definition CmdQueue.cpp:16