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