| 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_FRAME_MANAGER |
| 19 | #define TIA_FRAME_MANAGER |
| 20 | |
| 21 | #include "AbstractFrameManager.hxx" |
| 22 | #include "TIAConstants.hxx" |
| 23 | #include "bspf.hxx" |
| 24 | #include "JitterEmulation.hxx" |
| 25 | |
| 26 | class FrameManager: public AbstractFrameManager { |
| 27 | public: |
| 28 | |
| 29 | FrameManager(); |
| 30 | |
| 31 | public: |
| 32 | |
| 33 | void setJitterFactor(uInt8 factor) override { myJitterEmulation.setJitterFactor(factor); } |
| 34 | |
| 35 | bool jitterEnabled() const override { return myJitterEnabled; } |
| 36 | |
| 37 | void enableJitter(bool enabled) override { myJitterEnabled = enabled; } |
| 38 | |
| 39 | uInt32 height() const override { return myHeight; } |
| 40 | |
| 41 | uInt32 getY() const override { return myY; } |
| 42 | |
| 43 | uInt32 scanlines() const override { return myCurrentFrameTotalLines; } |
| 44 | |
| 45 | Int32 missingScanlines() const override; |
| 46 | |
| 47 | void setYstart(uInt32 ystart) override; |
| 48 | |
| 49 | uInt32 ystart() const override { return myYStart; } |
| 50 | |
| 51 | void setLayout(FrameLayout mode) override { layout(mode); } |
| 52 | |
| 53 | void onSetVsync() override; |
| 54 | |
| 55 | void onNextLine() override; |
| 56 | |
| 57 | void onReset() override; |
| 58 | |
| 59 | void onLayoutChange() override; |
| 60 | |
| 61 | bool onSave(Serializer& out) const override; |
| 62 | |
| 63 | bool onLoad(Serializer& in) override; |
| 64 | |
| 65 | private: |
| 66 | |
| 67 | enum class State { |
| 68 | waitForVsyncStart, |
| 69 | waitForVsyncEnd, |
| 70 | waitForFrameStart, |
| 71 | frame |
| 72 | }; |
| 73 | |
| 74 | private: |
| 75 | |
| 76 | void setState(State state); |
| 77 | |
| 78 | void updateIsRendering(); |
| 79 | |
| 80 | private: |
| 81 | |
| 82 | State myState; |
| 83 | uInt32 myLineInState; |
| 84 | uInt32 myVsyncLines; |
| 85 | uInt32 myY, myLastY; |
| 86 | |
| 87 | uInt32 myVblankLines; |
| 88 | uInt32 myKernelLines; |
| 89 | uInt32 myOverscanLines; |
| 90 | uInt32 myFrameLines; |
| 91 | uInt32 myHeight; |
| 92 | uInt32 myYStart; |
| 93 | |
| 94 | bool myJitterEnabled; |
| 95 | |
| 96 | JitterEmulation myJitterEmulation; |
| 97 | |
| 98 | private: |
| 99 | |
| 100 | FrameManager(const FrameManager&) = delete; |
| 101 | FrameManager(FrameManager&&) = delete; |
| 102 | FrameManager& operator=(const FrameManager&) = delete; |
| 103 | FrameManager& operator=(FrameManager&&) = delete; |
| 104 | }; |
| 105 | |
| 106 | #endif // TIA_FRAME_MANAGER |
| 107 | |