| 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 TIA_DEBUG_HXX |
| 19 | #define TIA_DEBUG_HXX |
| 20 | |
| 21 | class Debugger; |
| 22 | class TIA; |
| 23 | class DelayQueueIterator; |
| 24 | |
| 25 | // Function type for TIADebug instance methods |
| 26 | class TIADebug; |
| 27 | using TiaMethod = int (TIADebug::*)() const; |
| 28 | |
| 29 | #include "DebuggerSystem.hxx" |
| 30 | #include "bspf.hxx" |
| 31 | |
| 32 | class TiaState : public DebuggerState |
| 33 | { |
| 34 | public: |
| 35 | IntArray coluRegs; |
| 36 | IntArray fixedCols; |
| 37 | BoolArray cx; |
| 38 | IntArray gr; |
| 39 | BoolArray ref; |
| 40 | BoolArray vdel; |
| 41 | BoolArray res; |
| 42 | IntArray pos; |
| 43 | IntArray hm; |
| 44 | IntArray pf; |
| 45 | IntArray size; |
| 46 | IntArray aud; |
| 47 | IntArray info; |
| 48 | |
| 49 | // Indices for various IntArray above |
| 50 | enum { P0, P1, M0, M1, BL }; |
| 51 | }; |
| 52 | |
| 53 | class TIADebug : public DebuggerSystem |
| 54 | { |
| 55 | public: |
| 56 | TIADebug(Debugger& dbg, Console& console); |
| 57 | TIA& tia() const { return myTIA; } |
| 58 | |
| 59 | const DebuggerState& getState() override; |
| 60 | const DebuggerState& getOldState() override { return myOldState; } |
| 61 | |
| 62 | void saveOldState() override; |
| 63 | string toString() override; |
| 64 | string debugColors() const; |
| 65 | string palette() const; |
| 66 | |
| 67 | // TIA byte (or part of a byte) registers |
| 68 | uInt8 nusiz0(int newVal = -1); |
| 69 | uInt8 nusiz1(int newVal = -1); |
| 70 | uInt8 nusizP0(int newVal = -1); |
| 71 | uInt8 nusizP1(int newVal = -1); |
| 72 | uInt8 nusizM0(int newVal = -1); |
| 73 | uInt8 nusizM1(int newVal = -1); |
| 74 | const string& nusizP0String() { return nusizStrings[nusizP0()]; } |
| 75 | const string& nusizP1String() { return nusizStrings[nusizP1()]; } |
| 76 | |
| 77 | uInt8 coluP0(int newVal = -1); |
| 78 | uInt8 coluP1(int newVal = -1); |
| 79 | uInt8 coluPF(int newVal = -1); |
| 80 | uInt8 coluBK(int newVal = -1); |
| 81 | |
| 82 | uInt8 sizeBL(int newVal = -1); |
| 83 | uInt8 ctrlPF(int newVal = -1); |
| 84 | |
| 85 | uInt8 pf0(int newVal = -1); |
| 86 | uInt8 pf1(int newVal = -1); |
| 87 | uInt8 pf2(int newVal = -1); |
| 88 | |
| 89 | uInt8 grP0(int newVal = -1); |
| 90 | uInt8 grP1(int newVal = -1); |
| 91 | uInt8 posP0(int newVal = -1); |
| 92 | uInt8 posP1(int newVal = -1); |
| 93 | uInt8 posM0(int newVal = -1); |
| 94 | uInt8 posM1(int newVal = -1); |
| 95 | uInt8 posBL(int newVal = -1); |
| 96 | uInt8 hmP0(int newVal = -1); |
| 97 | uInt8 hmP1(int newVal = -1); |
| 98 | uInt8 hmM0(int newVal = -1); |
| 99 | uInt8 hmM1(int newVal = -1); |
| 100 | uInt8 hmBL(int newVal = -1); |
| 101 | |
| 102 | uInt8 audC0(int newVal = -1); |
| 103 | uInt8 audC1(int newVal = -1); |
| 104 | uInt8 audF0(int newVal = -1); |
| 105 | uInt8 audF1(int newVal = -1); |
| 106 | uInt8 audV0(int newVal = -1); |
| 107 | uInt8 audV1(int newVal = -1); |
| 108 | |
| 109 | void setGRP0Old(uInt8 b); |
| 110 | void setGRP1Old(uInt8 b); |
| 111 | void setENABLOld(bool b); |
| 112 | |
| 113 | // TIA bool registers |
| 114 | bool refP0(int newVal = -1); |
| 115 | bool refP1(int newVal = -1); |
| 116 | bool enaM0(int newVal = -1); |
| 117 | bool enaM1(int newVal = -1); |
| 118 | bool enaBL(int newVal = -1); |
| 119 | |
| 120 | bool vdelP0(int newVal = -1); |
| 121 | bool vdelP1(int newVal = -1); |
| 122 | bool vdelBL(int newVal = -1); |
| 123 | |
| 124 | bool resMP0(int newVal = -1); |
| 125 | bool resMP1(int newVal = -1); |
| 126 | |
| 127 | bool refPF(int newVal = -1); |
| 128 | bool scorePF(int newVal = -1); |
| 129 | bool priorityPF(int newVal = -1); |
| 130 | |
| 131 | /** Get specific bits in the collision register (used by collXX_XX) */ |
| 132 | bool collision(CollisionBit id, bool toggle = false) const; |
| 133 | |
| 134 | // Collision registers |
| 135 | bool collM0_P1() const { return collision(CollisionBit::M0P1); } |
| 136 | bool collM0_P0() const { return collision(CollisionBit::M0P0); } |
| 137 | bool collM1_P0() const { return collision(CollisionBit::M1P0); } |
| 138 | bool collM1_P1() const { return collision(CollisionBit::M1P1); } |
| 139 | bool collP0_PF() const { return collision(CollisionBit::P0PF); } |
| 140 | bool collP0_BL() const { return collision(CollisionBit::P0BL); } |
| 141 | bool collP1_PF() const { return collision(CollisionBit::P1PF); } |
| 142 | bool collP1_BL() const { return collision(CollisionBit::P1BL); } |
| 143 | bool collM0_PF() const { return collision(CollisionBit::M0PF); } |
| 144 | bool collM0_BL() const { return collision(CollisionBit::M0BL); } |
| 145 | bool collM1_PF() const { return collision(CollisionBit::M1PF); } |
| 146 | bool collM1_BL() const { return collision(CollisionBit::M1BL); } |
| 147 | bool collBL_PF() const { return collision(CollisionBit::BLPF); } |
| 148 | bool collP0_P1() const { return collision(CollisionBit::P0P1); } |
| 149 | bool collM0_M1() const { return collision(CollisionBit::M0M1); } |
| 150 | |
| 151 | // TIA strobe registers |
| 152 | void strobeWsync(); |
| 153 | void strobeRsync(); |
| 154 | void strobeResP0(); |
| 155 | void strobeResP1(); |
| 156 | void strobeResM0(); |
| 157 | void strobeResM1(); |
| 158 | void strobeResBL(); |
| 159 | void strobeHmove(); |
| 160 | void strobeHmclr(); |
| 161 | void strobeCxclr(); |
| 162 | |
| 163 | // Read-only internal TIA state |
| 164 | int scanlines() const; |
| 165 | int scanlinesLastFrame() const; |
| 166 | int frameCount() const; |
| 167 | int frameCycles() const; |
| 168 | int cyclesLo() const; |
| 169 | int cyclesHi() const; |
| 170 | int clocksThisLine() const; |
| 171 | int cyclesThisLine() const; |
| 172 | bool vsync() const; |
| 173 | bool vblank() const; |
| 174 | int vsyncAsInt() const { return int(vsync()); } // so we can use _vsync pseudo-register |
| 175 | int vblankAsInt() const { return int(vblank()); } // so we can use _vblank pseudo-register |
| 176 | |
| 177 | shared_ptr<DelayQueueIterator> delayQueueIterator() const; |
| 178 | |
| 179 | private: |
| 180 | /** Display a color patch for color at given index in the palette */ |
| 181 | string colorSwatch(uInt8 c) const; |
| 182 | |
| 183 | string audFreq(uInt8 div); |
| 184 | string booleanWithLabel(string label, bool value); |
| 185 | |
| 186 | private: |
| 187 | TiaState myState; |
| 188 | TiaState myOldState; |
| 189 | |
| 190 | TIA& myTIA; |
| 191 | |
| 192 | static const std::array<string, 8> nusizStrings; |
| 193 | |
| 194 | private: |
| 195 | // Following constructors and assignment operators not supported |
| 196 | TIADebug() = delete; |
| 197 | TIADebug(const TIADebug&) = delete; |
| 198 | TIADebug(TIADebug&&) = delete; |
| 199 | TIADebug& operator=(const TIADebug&) = delete; |
| 200 | TIADebug& operator=(TIADebug&&) = delete; |
| 201 | }; |
| 202 | |
| 203 | #endif |
| 204 | |