-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstaterow.cc
208 lines (188 loc) · 8.57 KB
/
staterow.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#include <bitset>
#include "ui/staterow.h"
#include "ui/statebox.h"
#include "core/rom.h"
#include "core/disassembler.h"
#include "utils/str.h"
reRegisterStateRow::reRegisterStateRow(reRegisterStateBox* box,
const wxString& label,
wxSizer* label_column,
wxSizer* first_nibble_column,
wxSizer* second_nibble_column,
wxSizer* hex_column,
wxSizer* signed_column,
wxSizer* unsigned_column)
{
label_ = new wxStaticText(box, wxID_ANY, label);
first_nibble_ = new wxStaticText(box, wxID_ANY, "0000");
second_nibble_ = new wxStaticText(box, wxID_ANY, "0000");
hex_ = new wxStaticText(box, wxID_ANY, "00");
unsigned_ = new wxStaticText(box, wxID_ANY, "0");
signed_ = new wxStaticText(box, wxID_ANY, "0");
wxFont label_font = label_->GetFont();
label_font.SetWeight(wxFONTWEIGHT_BOLD);
label_->SetFont(label_font);
const int margin = box->GetFont().GetPixelSize().GetY() / 2;
label_column->Add(label_, 0, wxALIGN_RIGHT | wxBOTTOM, margin);
first_nibble_column->Add(first_nibble_, 0, wxALIGN_RIGHT | wxBOTTOM,
margin);
second_nibble_column->Add(second_nibble_, 0, wxALIGN_RIGHT | wxBOTTOM,
margin);
hex_column->Add(hex_, 0, wxALIGN_RIGHT | wxBOTTOM, margin);
signed_column->Add(signed_, 0, wxALIGN_RIGHT | wxBOTTOM, margin);
unsigned_column->Add(unsigned_, 0, wxALIGN_RIGHT | wxBOTTOM, margin);
}
void reRegisterStateRow::SetValue(uint8_t val)
{
first_nibble_->SetLabel(std::bitset<4>(val >> 4).to_string());
second_nibble_->SetLabel(std::bitset<4>(val & 0x0F).to_string());
hex_->SetLabel(to_hex_string(val, 2));
signed_->SetLabel(std::to_string(static_cast<int8_t>(val)));
unsigned_->SetLabel(std::to_string(val));
}
reFlagStateRow::reFlagStateRow(reFlagStateBox* box,
const wxString& label,
wxSizer* label_column,
wxSizer* value_column)
{
label_ = new wxStaticText(box, wxID_ANY, label);
wxFont label_font = label_->GetFont();
label_font.SetWeight(wxFONTWEIGHT_BOLD);
label_->SetFont(label_font);
value_ = new wxStaticText(box, wxID_ANY, "0");
label_column->Add(label_, 0, wxALIGN_RIGHT);
value_column->Add(value_, 0, wxALIGN_RIGHT);
const int margin = box->GetFont().GetPixelSize().GetY() / 2;
label_column->AddSpacer(margin);
value_column->AddSpacer(margin);
}
void reFlagStateRow::SetValue(bool val)
{
value_->SetLabel(std::to_string(val));
}
reROMStateRow::reROMStateRow(reROMStateBox* box,
int addr,
wxSizer* addr_column,
wxSizer* ls_byte_ms_nibble_column,
wxSizer* ls_byte_ls_nibble_column,
wxSizer* ls_byte_hex_column,
wxSizer* ms_byte_ms_nibble_column,
wxSizer* ms_byte_ls_nibble_column,
wxSizer* ms_byte_hex_column,
wxSizer* disassembled_column)
{
addr_ = new wxStaticText(box, wxID_ANY, to_hex_string(addr, 2));
ls_byte_ms_nibble_ = new wxStaticText(box, wxID_ANY, "----");
ls_byte_ls_nibble_ = new wxStaticText(box, wxID_ANY, "----");
ls_byte_hex_ = new wxStaticText(box, wxID_ANY, "--");
ms_byte_ms_nibble_ = new wxStaticText(box, wxID_ANY, "----");
ms_byte_ls_nibble_ = new wxStaticText(box, wxID_ANY, "----");
ms_byte_hex_ = new wxStaticText(box, wxID_ANY, "--");
disassembled_ = new wxStaticText(box, wxID_ANY, "---");
wxFont addr_font = addr_->GetFont();
addr_font.SetWeight(wxFONTWEIGHT_BOLD);
addr_->SetFont(addr_font);
addr_column->Add(addr_, 0, wxALIGN_RIGHT);
ls_byte_ms_nibble_column->Add(ls_byte_ms_nibble_, 0, wxALIGN_RIGHT);
ls_byte_ls_nibble_column->Add(ls_byte_ls_nibble_, 0, wxALIGN_RIGHT);
ls_byte_hex_column->Add(ls_byte_hex_, 0, wxALIGN_RIGHT);
ms_byte_ms_nibble_column->Add(ms_byte_ms_nibble_, 0, wxALIGN_RIGHT);
ms_byte_ls_nibble_column->Add(ms_byte_ls_nibble_, 0, wxALIGN_RIGHT);
ms_byte_hex_column->Add(ms_byte_hex_, 0, wxALIGN_RIGHT);
disassembled_column->Add(disassembled_, 0, wxALIGN_RIGHT);
const int margin = box->GetFont().GetPixelSize().GetY() / 2;
addr_column->AddSpacer(margin);
ls_byte_ms_nibble_column->AddSpacer(margin);
ls_byte_ls_nibble_column->AddSpacer(margin);
ls_byte_hex_column->AddSpacer(margin);
ms_byte_ms_nibble_column->AddSpacer(margin);
ms_byte_ls_nibble_column->AddSpacer(margin);
ms_byte_hex_column->AddSpacer(margin);
disassembled_column->AddSpacer(margin);
}
reProgramDataStateRow::reProgramDataStateRow(reROMStateBox* box,
int addr,
wxSizer* addr_column,
wxSizer* ls_byte_ms_nibble_column,
wxSizer* ls_byte_ls_nibble_column,
wxSizer* ls_byte_hex_column,
wxSizer* ms_byte_ms_nibble_column,
wxSizer* ms_byte_ls_nibble_column,
wxSizer* ms_byte_hex_column,
wxSizer* disassembled_column)
: reROMStateRow(box, addr, addr_column, ls_byte_ms_nibble_column,
ls_byte_ls_nibble_column, ls_byte_hex_column,
ms_byte_ms_nibble_column, ms_byte_ls_nibble_column,
ms_byte_hex_column, disassembled_column)
{
GetLSByteMSNibble()->SetLabel("0000");
GetLSByteLSNibble()->SetLabel("0000");
GetLSByteHex()->SetLabel("00");
GetMSByteMSNibble()->SetLabel("0000");
GetMSByteLSNibble()->SetLabel("0000");
GetMSByteHex()->SetLabel("00");
GetDisassembled()->SetLabel("NOP");
}
void reProgramDataStateRow::SetValue(uint16_t val)
{
uint8_t ls_byte_val = static_cast<uint8_t>(val);
GetLSByteHex()->SetLabel(to_hex_string(ls_byte_val, 2));
GetLSByteLSNibble()->SetLabel(
std::bitset<4>(ls_byte_val & 0x0F).to_string());
GetLSByteMSNibble()->SetLabel(
std::bitset<4>(ls_byte_val >> 4).to_string());
uint8_t ms_byte_val = static_cast<uint8_t>(val >> 8);
GetMSByteHex()->SetLabel(to_hex_string(ms_byte_val, 2));
GetMSByteLSNibble()->SetLabel(
std::bitset<4>(ms_byte_val & 0x0F).to_string());
GetMSByteMSNibble()->SetLabel(
std::bitset<4>(ms_byte_val >> 4).to_string());
GetDisassembled()->SetLabel(disassemble(val));
}
reInputSwitchesStateRow::reInputSwitchesStateRow(
reROMStateBox* box,
int addr,
wxSizer* addr_column,
wxSizer* ls_byte_ms_nibble_column,
wxSizer* ls_byte_ls_nibble_column,
wxSizer* ls_byte_hex_column,
wxSizer* ms_byte_ms_nibble_column,
wxSizer* ms_byte_ls_nibble_column,
wxSizer* ms_byte_hex_column,
wxSizer* disassembled_column)
: reROMStateRow(box, addr, addr_column, ls_byte_ms_nibble_column,
ls_byte_ls_nibble_column, ls_byte_hex_column,
ms_byte_ms_nibble_column, ms_byte_ls_nibble_column,
ms_byte_hex_column, disassembled_column)
{
GetLSByteLSNibble()->SetLabel("---0");
GetLSByteHex()->SetLabel("00");
}
void reInputSwitchesStateRow::SetValue(uint16_t val)
{
uint8_t bit = val & 0x0001;
GetLSByteHex()->SetLabel("0" + std::to_string(bit));
GetLSByteLSNibble()->SetLabel("---" + std::to_string(bit));
}
reUnusedStateRow::reUnusedStateRow(reROMStateBox* box,
int addr,
wxSizer* addr_column,
wxSizer* ls_byte_ms_nibble_column,
wxSizer* ls_byte_ls_nibble_column,
wxSizer* ls_byte_hex_column,
wxSizer* ms_byte_ms_nibble_column,
wxSizer* ms_byte_ls_nibble_column,
wxSizer* ms_byte_hex_column,
wxSizer* disassembled_column)
: reROMStateRow(box, addr, addr_column, ls_byte_ms_nibble_column,
ls_byte_ls_nibble_column, ls_byte_hex_column,
ms_byte_ms_nibble_column, ms_byte_ls_nibble_column,
ms_byte_hex_column, disassembled_column)
{
GetLSByteMSNibble()->SetLabel("0000");
GetLSByteLSNibble()->SetLabel("0000");
GetLSByteHex()->SetLabel("00");
}
void reUnusedStateRow::SetValue(uint16_t val)
{
}