1 #ifndef _memorywatch__hpp__included__
2 #define _memorywatch__hpp__included__
8 #include "library/memorywatch.hpp"
9 #include "library/json.hpp"
14 class emu_framebuffer
;
15 namespace framebuffer
{ class queue
; }
18 * lsnes memory watch printer variables.
20 struct memwatch_printer
27 * Serialize the printer to JSON value.
29 JSON::node
serialize();
31 * Unserialize the printer from JSON value.
33 void unserialize(const JSON::node
& node
);
35 * Get a printer object corresponding to this object.
37 GC::pointer
<memorywatch::item_printer
> get_printer_obj(
38 std::function
<GC::pointer
<mathexpr::mathexpr
>(const std::string
& n
)> vars
);
40 enum position_category
{
45 bool cond_enable
; //Ignored for disabled.
46 std::string enabled
; //Ignored for disabled.
47 std::string onscreen_xpos
;
48 std::string onscreen_ypos
;
49 bool onscreen_alt_origin_x
;
50 bool onscreen_alt_origin_y
;
51 bool onscreen_cliprange_x
;
52 bool onscreen_cliprange_y
;
53 std::string onscreen_font
; //"" is system default.
54 int64_t onscreen_fg_color
;
55 int64_t onscreen_bg_color
;
56 int64_t onscreen_halo_color
;
60 * lsnes memory watch item.
69 * Serialize the item to JSON value.
71 JSON::node
serialize();
73 * Unserialize the item from JSON value.
75 void unserialize(const JSON::node
& node
);
77 * Get memory read operator.
79 * If bytes == 0, returns NULL.
81 mathexpr::operinfo
* get_memread_oper(memory_space
& memory
, loaded_rom
& rom
);
83 * Translate compatiblity item.
85 void compatiblity_unserialize(memory_space
& memory
, const std::string
& item
);
87 memwatch_printer printer
; //The printer.
88 std::string expr
; //The main expression.
89 std::string format
; //Format.
90 unsigned bytes
; //Number of bytes to read (0 => Not memory read operator).
91 bool signed_flag
; //Is signed?
92 bool float_flag
; //Is float?
93 int endianess
; //Endianess (-1 => little, 0 => host, 1 => Big).
94 uint64_t scale_div
; //Scale divisor.
95 uint64_t addr_base
; //Address base.
96 uint64_t addr_size
; //Address size (0 => All).
101 memwatch_set(memory_space
& _memory
, project_state
& _project
, emu_framebuffer
& _fbuf
,
104 * Get the specified memory watch item.
106 memwatch_item
& get(const std::string
& name
);
108 * Get the specified memory watch item as JSON serialization.
110 * Parameter name: The item name.
111 * Parameter printer: JSON pretty-printer to use.
113 std::string
get_string(const std::string
& name
, JSON::printer
* printer
= NULL
);
115 * Set the specified memory watch item. Fills the runtime variables.
117 * Parameter name: The name of the new item.
118 * Parameter item: The item to insert. Fields are shallow-copied.
120 void set(const std::string
& name
, memwatch_item
& item
);
122 * Set the specified memory watch item from JSON serialization. Fills the runtime variables.
124 * Parameter name: The name of the new item.
125 * Parameter item: The serialization of item to insert.
127 void set(const std::string
& name
, const std::string
& item
);
129 * Set multiple items at once.
131 * Parameter list: The list of items.
133 void set_multi(std::list
<std::pair
<std::string
, memwatch_item
>>& list
);
135 * Set multiple items at once from JSON descriptions.
137 * Parameter list: The list of items.
139 void set_multi(std::list
<std::pair
<std::string
, std::string
>>& list
);
141 * Rename a memory watch item.
143 * Parameter oname: The old name.
144 * Parameter newname: The new name.
145 * Returns: True on success, false if failed (new item already exists).
147 bool rename(const std::string
& oname
, const std::string
& newname
);
151 * Parameter name: The name of the item to delete.
153 void clear(const std::string
& name
);
155 * Delete multiple items.
157 * Parameter names: The names of the items to delete.
159 void clear_multi(const std::set
<std::string
>& name
);
161 * Enumerate item names.
163 std::set
<std::string
> enumerate();
165 * Get value of specified memory watch as a string.
167 std::string
get_value(const std::string
& name
);
169 * Watch all the items.
171 * Parameter rq: The render queue to use.
173 void watch(struct framebuffer::queue
& rq
);
175 * Get memory watch vars that go to window.
177 const std::map
<std::string
, std::u32string
>& get_window_vars() { return window_vars
; }
179 void rebuild(std::map
<std::string
, memwatch_item
>& nitems
);
180 std::map
<std::string
, memwatch_item
> items
;
181 std::map
<std::string
, std::u32string
> window_vars
;
182 std::map
<std::string
, bool> used_memorywatches
;
183 void erase_unused_watches();
184 void watch_output(const std::string
& name
, const std::string
& value
);
185 memorywatch::set watch_set
;
186 memory_space
& memory
;
187 project_state
& project
;
188 emu_framebuffer
& fbuf
;