OXYGENHUB
◆ main openmsx / src / imgui / ImGuiDisassembly.hh
2.2 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#ifndef IMGUI_DISASSEMBLY_HH
2
#define IMGUI_DISASSEMBLY_HH
3
4
#include "ImGuiPart.hh"
5
6
#include <optional>
7
#include <span>
8
#include <string>
9
#include <utility>
10
11
namespace openmsx {
12
13
class Debugger;
14
class MSXDevice;
15
class MSXCPUInterface;
16
class MSXRom;
17
class RomBlockDebuggableBase;
18
struct Symbol;
19
class SymbolManager;
20
21
class ImGuiDisassembly final : public ImGuiPart
22
{
23
public:
24
	ImGuiDisassembly(ImGuiManager& manager_, size_t index);
25
26
	[[nodiscard]] zstring_view iniName() const override { return title; }
27
	void save(ImGuiTextBuffer& buf) override;
28
	void loadLine(std::string_view name, zstring_view value) override;
29
	void loadEnd() override;
30
	void paint(MSXMotherBoard* motherBoard) override;
31
32
	void signalBreak() { if (scrollToPcOnBreak) syncDisassemblyWithPC = true; }
33
	void setGotoTarget(uint16_t target);
34
	void syncWithPC() { syncDisassemblyWithPC = true; }
35
36
public:
37
	void actionToggleBp(MSXMotherBoard& motherBoard);
38
	[[nodiscard]] static std::pair<const MSXRom*, RomBlockDebuggableBase*>
39
		getRomBlocks(Debugger& debugger, const MSXDevice* device);
40
41
private:
42
	unsigned disassemble(
43
		const MSXCPUInterface& cpuInterface, unsigned addr, unsigned pc, EmuTime time,
44
		std::span<uint8_t, 4> opcodes, std::string& mnemonic,
45
		std::optional<uint16_t>& mnemonicAddr, std::span<const Symbol* const>& mnemonicLabels);
46
	void disassembleToClipboard(
47
		const MSXCPUInterface& cpuInterface, unsigned pc, EmuTime time,
48
		unsigned minAddr, unsigned maxAddr);
49
50
public:
51
	bool show = true;
52
53
private:
54
	SymbolManager& symbolManager;
55
	std::string title;
56
	size_t cycleLabelsCounter = 0;
57
58
	static ImGuiDisassembly* lastWidget;
59
	std::optional<uint16_t> selectedAddr = {};
60
	std::string gotoAddr;
61
	std::string runToAddr;
62
	std::optional<unsigned> gotoTarget;
63
	std::optional<float> setDisassemblyScrollY;
64
	bool followPC = false;
65
	bool scrollToPcOnBreak = true;
66
67
	bool syncDisassemblyWithPC = false;
68
	float disassemblyScrollY = 0.0f;
69
70
	static constexpr auto persistentElements = std::tuple{
71
		PersistentElement{"show",              &ImGuiDisassembly::show},
72
		PersistentElement{"followPC",          &ImGuiDisassembly::followPC},
73
		PersistentElement{"scrollToPcOnBreak", &ImGuiDisassembly::scrollToPcOnBreak},
74
		PersistentElement{"disassemblyY",      &ImGuiDisassembly::disassemblyScrollY},
75
	};
76
};
77
78
} // namespace openmsx
79
80
#endif