1//============================================================================
2//
3// SSSS tt lll lll
4// SS SS tt ll ll
5// SS tttttt eeee ll ll aaaa
6// SSSS tt ee ee ll ll aa
7// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
8// SS SS tt ee ll ll aa aa
9// SSSS ttt eeeee llll llll aaaaa
10//
11// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony
12// and the Stella Team
13//
14// See the file "License.txt" for information on usage and redistribution of
15// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16//============================================================================
17
18#ifndef CPU_DEBUG_HXX
19#define CPU_DEBUG_HXX
20
21class M6502;
22class System;
23
24// Function type for CpuDebug instance methods
25class CpuDebug;
26using CpuMethod = int (CpuDebug::*)() const;
27
28#include "DebuggerSystem.hxx"
29
30class CpuState : public DebuggerState
31{
32 public:
33 int PC, SP, PS, A, X, Y;
34 int srcS, srcA, srcX, srcY;
35 BoolArray PSbits;
36
37 CpuState() : PC(0), SP(0), PS(0), A(0), X(0), Y(0), srcS(0), srcA(0), srcX(0), srcY(0) { }
38};
39
40class CpuDebug : public DebuggerSystem
41{
42 public:
43 CpuDebug(Debugger& dbg, Console& console);
44
45 const DebuggerState& getState() override;
46 const DebuggerState& getOldState() override { return myOldState; }
47
48 void saveOldState() override;
49 string toString() override { return EmptyString; } // Not needed, since CPU stuff is always visible
50
51 int pc() const;
52 int sp() const;
53 int a() const;
54 int x() const;
55 int y() const;
56
57 // These return int, not boolean!
58 int n() const;
59 int v() const;
60 int b() const;
61 int d() const;
62 int i() const;
63 int z() const;
64 int c() const;
65
66 int icycles() const;
67
68 void setPC(int pc);
69 void setSP(int sp);
70 void setPS(int ps);
71 void setA(int a);
72 void setX(int x);
73 void setY(int y);
74
75 void setN(bool on);
76 void setV(bool on);
77 void setB(bool on);
78 void setD(bool on);
79 void setI(bool on);
80 void setZ(bool on);
81 void setC(bool on);
82
83 void setCycles(int cycles);
84
85 void toggleN();
86 void toggleV();
87 void toggleB();
88 void toggleD();
89 void toggleI();
90 void toggleZ();
91 void toggleC();
92
93 private:
94 M6502& my6502;
95
96 CpuState myState;
97 CpuState myOldState;
98
99 private:
100 // Following constructors and assignment operators not supported
101 CpuDebug() = delete;
102 CpuDebug(const CpuDebug&) = delete;
103 CpuDebug(CpuDebug&&) = delete;
104 CpuDebug& operator=(const CpuDebug&) = delete;
105 CpuDebug& operator=(CpuDebug&&) = delete;
106};
107
108#endif
109