1#ifndef REVERSEMANGER_HH
2#define REVERSEMANGER_HH
21class EventDistributor;
38 keyboard = &keyboard_;
44 eventDelay = &eventDelay_;
51 reRecordCount =
count;
57 template<
typename T,
typename... Args>
61 history.events.push_back(std::make_unique<T>(time, std::forward<Args>(args)...));
62 return *history.events.back();
67 ReverseChunk() : time(EmuTime::zero()) {}
70 std::vector<std::shared_ptr<DeltaBlock>> deltaBlocks;
71 MemBuffer<uint8_t> savestate;
79 using Chunks = std::map<unsigned, ReverseChunk>;
80 using Events = std::deque<std::unique_ptr<StateChange>>;
82 struct ReverseHistory {
83 void swap(ReverseHistory& other)
noexcept;
85 [[nodiscard]]
unsigned getNextSeqNum(EmuTime::param time)
const;
89 LastDeltaBlocks lastDeltaBlocks;
92 [[nodiscard]]
bool isCollecting()
const {
return collecting; }
96 void status(TclObject& result)
const;
97 void debugInfo(TclObject& result)
const;
98 void goBack(std::span<const TclObject> tokens);
99 void goTo(std::span<const TclObject> tokens);
100 void saveReplay(Interpreter& interp,
101 std::span<const TclObject> tokens, TclObject& result);
102 void loadReplay(Interpreter& interp,
103 std::span<const TclObject> tokens, TclObject& result);
105 void signalStopReplay(EmuTime::param time);
106 [[nodiscard]] EmuTime::param getEndTime(
const ReverseHistory& history)
const;
107 void goTo(EmuTime::param targetTime,
bool noVideo);
108 void goTo(EmuTime::param targetTime,
bool noVideo,
109 ReverseHistory& history,
bool sameTimeLine);
110 void transferHistory(ReverseHistory& oldHistory,
111 unsigned oldEventCount);
112 void transferState(MSXMotherBoard& newBoard);
113 void takeSnapshot(EmuTime::param time);
114 void schedule(EmuTime::param time);
115 void replayNextEvent();
116 template<
unsigned N>
void dropOldSnapshots(
unsigned count);
122 void executeUntil(EmuTime::param )
override {
124 rm.execNewSnapshot();
130 void executeUntil(EmuTime::param )
override {
136 void execNewSnapshot();
137 void execInputEvent();
138 [[nodiscard]] EmuTime::param getCurrentTime()
const {
return syncNewSnapshot.getCurrentTime(); }
141 int signalEvent(
const Event& event)
override;
144 MSXMotherBoard& motherBoard;
145 EventDistributor& eventDistributor;
147 struct ReverseCmd final : Command {
148 explicit ReverseCmd(CommandController& controller);
149 void execute(std::span<const TclObject> tokens, TclObject& result)
override;
150 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
151 void tabCompletion(std::vector<std::string>& tokens)
const override;
155 EventDelay* eventDelay =
nullptr;
156 ReverseHistory history;
157 unsigned replayIndex = 0;
158 bool collecting =
false;
159 bool pendingTakeSnapshot =
false;
161 unsigned reRecordCount = 0;
This class is responsible for translating host events into MSX events.
void setReRecordCount(unsigned count)
void registerKeyboard(Keyboard &keyboard_)
void stopReplay(EmuTime::param time) noexcept
void registerEventDelay(EventDelay &eventDelay_)
StateChange & record(EmuTime::param time, Args &&...args)
ReverseManager(MSXMotherBoard &motherBoard)
Base class for all external MSX state changing events.
ALWAYS_INLINE unsigned count(const uint8_t *pIn, const uint8_t *pMatch, const uint8_t *pInLimit)
This file implemented 3 utility functions:
void swap(openmsx::MemBuffer< T > &l, openmsx::MemBuffer< T > &r) noexcept
size_t size(std::string_view utf8)
#define OUTER(type, member)