1 #ifndef _memorywatch__hpp__included__
2 #define _memorywatch__hpp__included__
7 #include "library/memorywatch.hpp"
8 #include "library/json.hpp"
12 class emu_framebuffer
;
15 * lsnes memory watch printer variables.
17 struct memwatch_printer
24 * Serialize the printer to JSON value.
26 JSON::node
serialize();
28 * Unserialize the printer from JSON value.
30 void unserialize(const JSON::node
& node
);
32 * Get a printer object corresponding to this object.
34 gcroot_pointer
<memorywatch::item_printer
> get_printer_obj(
35 std::function
<gcroot_pointer
<mathexpr::mathexpr
>(const std::string
& n
)> vars
);
37 enum position_category
{
42 bool cond_enable
; //Ignored for disabled.
43 std::string enabled
; //Ignored for disabled.
44 std::string onscreen_xpos
;
45 std::string onscreen_ypos
;
46 bool onscreen_alt_origin_x
;
47 bool onscreen_alt_origin_y
;
48 bool onscreen_cliprange_x
;
49 bool onscreen_cliprange_y
;
50 std::string onscreen_font
; //"" is system default.
51 int64_t onscreen_fg_color
;
52 int64_t onscreen_bg_color
;
53 int64_t onscreen_halo_color
;
57 * lsnes memory watch item.
64 memwatch_item(memory_space
& memory
);
66 * Serialize the item to JSON value.
68 JSON::node
serialize();
70 * Unserialize the item from JSON value.
72 void unserialize(const JSON::node
& node
);
74 * Get memory read operator.
76 * If bytes == 0, returns NULL.
78 memorywatch::memread_oper
* get_memread_oper();
80 * Translate compatiblity item.
82 void compatiblity_unserialize(memory_space
& memory
, const std::string
& item
);
84 memwatch_printer printer
; //The printer.
85 std::string expr
; //The main expression.
86 std::string format
; //Format.
87 unsigned bytes
; //Number of bytes to read (0 => Not memory read operator).
88 bool signed_flag
; //Is signed?
89 bool float_flag
; //Is float?
90 int endianess
; //Endianess (-1 => little, 0 => host, 1 => Big).
91 uint64_t scale_div
; //Scale divisor.
92 uint64_t addr_base
; //Address base.
93 uint64_t addr_size
; //Address size (0 => All).
94 memory_space
* mspace
; //Memory space to read.
99 memwatch_set(memory_space
& _memory
, project_state
& _project
, emu_framebuffer
& _fbuf
);
101 * Get the specified memory watch item.
103 memwatch_item
& get(const std::string
& name
);
105 * Get the specified memory watch item as JSON serialization.
107 * Parameter name: The item name.
108 * Parameter printer: JSON pretty-printer to use.
110 std::string
get_string(const std::string
& name
, JSON::printer
* printer
= NULL
);
112 * Set the specified memory watch item. Fills the runtime variables.
114 * Parameter name: The name of the new item.
115 * Parameter item: The item to insert. Fields are shallow-copied.
117 void set(const std::string
& name
, memwatch_item
& item
);
119 * Set the specified memory watch item from JSON serialization. Fills the runtime variables.
121 * Parameter name: The name of the new item.
122 * Parameter item: The serialization of item to insert.
124 void set(const std::string
& name
, const std::string
& item
);
126 * Set multiple items at once.
128 * Parameter list: The list of items.
130 void set_multi(std::list
<std::pair
<std::string
, memwatch_item
>>& list
);
132 * Set multiple items at once from JSON descriptions.
134 * Parameter list: The list of items.
136 void set_multi(std::list
<std::pair
<std::string
, std::string
>>& list
);
138 * Rename a memory watch item.
140 * Parameter oname: The old name.
141 * Parameter newname: The new name.
142 * Returns: True on success, false if failed (new item already exists).
144 bool rename(const std::string
& oname
, const std::string
& newname
);
148 * Parameter name: The name of the item to delete.
150 void clear(const std::string
& name
);
152 * Delete multiple items.
154 * Parameter names: The names of the items to delete.
156 void clear_multi(const std::set
<std::string
>& name
);
158 * Enumerate item names.
160 std::set
<std::string
> enumerate();
162 * Get value of specified memory watch as a string.
164 std::string
get_value(const std::string
& name
);
166 * Watch all the items.
168 * Parameter rq: The render queue to use.
170 void watch(struct framebuffer::queue
& rq
);
172 * Get memory watch vars that go to window.
174 const std::map
<std::string
, std::u32string
>& get_window_vars() { return window_vars
; }
176 void rebuild(std::map
<std::string
, memwatch_item
>& nitems
);
177 std::map
<std::string
, memwatch_item
> items
;
178 std::map
<std::string
, std::u32string
> window_vars
;
179 std::map
<std::string
, bool> used_memorywatches
;
180 void erase_unused_watches();
181 void watch_output(const std::string
& name
, const std::string
& value
);
182 memorywatch::set watch_set
;
183 memory_space
& memory
;
184 project_state
& project
;
185 emu_framebuffer
& fbuf
;