Skip to content

Commit

Permalink
Adding toggle to see GTE registers in fixed point format.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasnoble committed Dec 9, 2023
1 parent bd3b657 commit 4f7ab52
Show file tree
Hide file tree
Showing 2 changed files with 196 additions and 37 deletions.
228 changes: 191 additions & 37 deletions src/gui/widgets/registers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

#include "gui/widgets/registers.h"

#include <cmath>
#include <numbers>

#include "core/disr3000a.h"
#include "core/r3000a.h"
#include "core/system.h"
Expand Down Expand Up @@ -98,77 +101,228 @@ void PCSX::Widgets::Registers::draw(PCSX::GUI* gui, PCSX::psxRegisters* register
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("CP2D")) {
ImGui::Checkbox(_("Show fixed point"), &m_showFixed);

Check warning on line 104 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L104

Added line #L104 was not covered by tests
auto v0 = registers->CP2D.n.v0;
ImGui::Text("v0 : {%i, %i, %i}", v0.x, v0.y, v0.z);
if (m_showFixed) {
ImGui::Text("v0 : {% 3.5f, % 3.5f, % 3.5f}", fixedToFloat(v0.x), fixedToFloat(v0.y),
fixedToFloat(v0.z));

Check warning on line 108 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L106-L108

Added lines #L106 - L108 were not covered by tests
} else {
ImGui::Text("v0 : {%i, %i, %i}", v0.x, v0.y, v0.z);

Check warning on line 110 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L110

Added line #L110 was not covered by tests
}
auto v1 = registers->CP2D.n.v1;
ImGui::Text("v1 : {%i, %i, %i}", v1.x, v1.y, v1.z);
if (m_showFixed) {
ImGui::Text("v1 : {% 3.5f, % 3.5f, % 3.5f}", fixedToFloat(v1.x), fixedToFloat(v1.y),
fixedToFloat(v1.z));

Check warning on line 115 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L113-L115

Added lines #L113 - L115 were not covered by tests
} else {
ImGui::Text("v1 : {%i, %i, %i}", v1.x, v1.y, v1.z);

Check warning on line 117 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L117

Added line #L117 was not covered by tests
}
auto v2 = registers->CP2D.n.v2;
ImGui::Text("v2 : {%i, %i, %i}", v2.x, v2.y, v2.z);
if (m_showFixed) {
ImGui::Text("v2 : {% 3.5f, % 3.5f, % 3.5f}", fixedToFloat(v2.x), fixedToFloat(v2.y),
fixedToFloat(v2.z));

Check warning on line 122 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L120-L122

Added lines #L120 - L122 were not covered by tests
} else {
ImGui::Text("v2 : {%i, %i, %i}", v2.x, v2.y, v2.z);

Check warning on line 124 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L124

Added line #L124 was not covered by tests
}
auto rgb = registers->CP2D.n.rgb;
ImGui::Text("rgb : {%i, %i, %i, %i}", rgb.r, rgb.g, rgb.b, rgb.c);
ImGui::Text("otz : %i", registers->CP2D.n.otz);
ImGui::Text("ir0 : %i", registers->CP2D.n.ir0);
ImGui::Text("ir1 : %i", registers->CP2D.n.ir1);
ImGui::Text("ir2 : %i", registers->CP2D.n.ir2);
ImGui::Text("ir3 : %i", registers->CP2D.n.ir3);
if (m_showFixed) {
ImGui::Text("otz : % 3.5f", fixedToFloat(registers->CP2D.n.otz));

Check warning on line 129 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L128-L129

Added lines #L128 - L129 were not covered by tests
} else {
ImGui::Text("otz : %i", registers->CP2D.n.otz);

Check warning on line 131 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L131

Added line #L131 was not covered by tests
}
if (m_showFixed) {
ImGui::Text("ir0 : % 3.5f", fixedToFloat(registers->CP2D.n.ir0));

Check warning on line 134 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L133-L134

Added lines #L133 - L134 were not covered by tests
} else {
ImGui::Text("ir0 : %i", registers->CP2D.n.ir0);

Check warning on line 136 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L136

Added line #L136 was not covered by tests
}
if (m_showFixed) {
ImGui::Text("ir1 : % 3.5f", fixedToFloat(registers->CP2D.n.ir1));

Check warning on line 139 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L138-L139

Added lines #L138 - L139 were not covered by tests
} else {
ImGui::Text("ir1 : %i", registers->CP2D.n.ir1);

Check warning on line 141 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L141

Added line #L141 was not covered by tests
}
if (m_showFixed) {
ImGui::Text("ir2 : % 3.5f", fixedToFloat(registers->CP2D.n.ir2));

Check warning on line 144 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L143-L144

Added lines #L143 - L144 were not covered by tests
} else {
ImGui::Text("ir2 : %i", registers->CP2D.n.ir2);

Check warning on line 146 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L146

Added line #L146 was not covered by tests
}
if (m_showFixed) {
ImGui::Text("ir3 : % 3.5f", fixedToFloat(registers->CP2D.n.ir3));

Check warning on line 149 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L148-L149

Added lines #L148 - L149 were not covered by tests
} else {
ImGui::Text("ir3 : %i", registers->CP2D.n.ir3);

Check warning on line 151 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L151

Added line #L151 was not covered by tests
}
auto sxy0 = registers->CP2D.n.sxy0;
ImGui::Text("sxy0: {%i, %i}", sxy0.x, sxy0.y);
if (m_showFixed) {
ImGui::Text("sxy0: {% 3.5f, % 3.5f}", fixedToFloat(sxy0.x), fixedToFloat(sxy0.y));

Check warning on line 155 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L154-L155

Added lines #L154 - L155 were not covered by tests
} else {
ImGui::Text("sxy0: {%i, %i}", sxy0.x, sxy0.y);

Check warning on line 157 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L157

Added line #L157 was not covered by tests
}
auto sxy1 = registers->CP2D.n.sxy1;
ImGui::Text("sxy1: {%i, %i}", sxy1.x, sxy1.y);
if (m_showFixed) {
ImGui::Text("sxy1: {% 3.5f, % 3.5f}", fixedToFloat(sxy1.x), fixedToFloat(sxy1.y));

Check warning on line 161 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L160-L161

Added lines #L160 - L161 were not covered by tests
} else {
ImGui::Text("sxy1: {%i, %i}", sxy1.x, sxy1.y);

Check warning on line 163 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L163

Added line #L163 was not covered by tests
}
auto sxy2 = registers->CP2D.n.sxy2;
ImGui::Text("sxy2: {%i, %i}", sxy2.x, sxy2.y);
if (m_showFixed) {
ImGui::Text("sxy2: {% 3.5f, % 3.5f}", fixedToFloat(sxy2.x), fixedToFloat(sxy2.y));

Check warning on line 167 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L166-L167

Added lines #L166 - L167 were not covered by tests
} else {
ImGui::Text("sxy2: {%i, %i}", sxy2.x, sxy2.y);

Check warning on line 169 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L169

Added line #L169 was not covered by tests
}
auto sxyp = registers->CP2D.n.sxyp;
ImGui::Text("sxyp: {%i, %i}", sxyp.x, sxyp.y);
if (m_showFixed) {
ImGui::Text("sxyp: {% 3.5f, % 3.5f}", fixedToFloat(sxyp.x), fixedToFloat(sxyp.y));

Check warning on line 173 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L172-L173

Added lines #L172 - L173 were not covered by tests
} else {
ImGui::Text("sxyp: {%i, %i}", sxyp.x, sxyp.y);

Check warning on line 175 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L175

Added line #L175 was not covered by tests
}
auto sz0 = registers->CP2D.n.sz0;
ImGui::Text("sz0 : {%i, %i}", sz0.z, sz0.unused);
if (m_showFixed) {
ImGui::Text("sz0 : % 3.5f", fixedToFloat(sz0.z));

Check warning on line 179 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L178-L179

Added lines #L178 - L179 were not covered by tests
} else {
ImGui::Text("sz0 : %i", sz0.z);

Check warning on line 181 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L181

Added line #L181 was not covered by tests
}
auto sz1 = registers->CP2D.n.sz1;
ImGui::Text("sz1 : {%i, %i}", sz1.z, sz1.unused);
if (m_showFixed) {
ImGui::Text("sz1 : % 3.5f", fixedToFloat(sz1.z));

Check warning on line 185 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L184-L185

Added lines #L184 - L185 were not covered by tests
} else {
ImGui::Text("sz1 : %i", sz1.z);

Check warning on line 187 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L187

Added line #L187 was not covered by tests
}
auto sz2 = registers->CP2D.n.sz2;
ImGui::Text("sz2 : {%i, %i}", sz2.z, sz2.unused);
if (m_showFixed) {
ImGui::Text("sz2 : % 3.5f", fixedToFloat(sz2.z));

Check warning on line 191 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L190-L191

Added lines #L190 - L191 were not covered by tests
} else {
ImGui::Text("sz2 : %i", sz2.z);

Check warning on line 193 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L193

Added line #L193 was not covered by tests
}
auto sz3 = registers->CP2D.n.sz3;
ImGui::Text("sz3 : {%i, %i}", sz3.z, sz3.unused);
if (m_showFixed) {
ImGui::Text("sz3 : % 3.5f", fixedToFloat(sz3.z));

Check warning on line 197 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L196-L197

Added lines #L196 - L197 were not covered by tests
} else {
ImGui::Text("sz3 : %i", sz3.z);

Check warning on line 199 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L199

Added line #L199 was not covered by tests
}
auto rgb0 = registers->CP2D.n.rgb0;
ImGui::Text("rgb0: {%i, %i, %i, %i}", rgb0.r, rgb0.g, rgb0.b, rgb0.c);
auto rgb1 = registers->CP2D.n.rgb0;
ImGui::Text("rgb1: {%i, %i, %i, %i}", rgb1.r, rgb1.g, rgb1.b, rgb1.c);
auto rgb2 = registers->CP2D.n.rgb0;
ImGui::Text("rgb2: {%i, %i, %i, %i}", rgb2.r, rgb2.g, rgb2.b, rgb2.c);
ImGui::Text("mac0: %i", registers->CP2D.n.mac0);
ImGui::Text("mac1: %i", registers->CP2D.n.mac1);
ImGui::Text("mac2: %i", registers->CP2D.n.mac2);
ImGui::Text("mac3: %i", registers->CP2D.n.mac3);
if (m_showFixed) {
ImGui::Text("mac0: % 3.5f", fixedToFloat(registers->CP2D.n.mac0));

Check warning on line 208 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L207-L208

Added lines #L207 - L208 were not covered by tests
} else {
ImGui::Text("mac0: %i", registers->CP2D.n.mac0);

Check warning on line 210 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L210

Added line #L210 was not covered by tests
}
if (m_showFixed) {
ImGui::Text("mac1: % 3.5f", fixedToFloat(registers->CP2D.n.mac1));

Check warning on line 213 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L212-L213

Added lines #L212 - L213 were not covered by tests
} else {
ImGui::Text("mac1: %i", registers->CP2D.n.mac1);

Check warning on line 215 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L215

Added line #L215 was not covered by tests
}
if (m_showFixed) {
ImGui::Text("mac2: % 3.5f", fixedToFloat(registers->CP2D.n.mac2));

Check warning on line 218 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L217-L218

Added lines #L217 - L218 were not covered by tests
} else {
ImGui::Text("mac2: %i", registers->CP2D.n.mac2);

Check warning on line 220 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L220

Added line #L220 was not covered by tests
}
if (m_showFixed) {
ImGui::Text("mac3: % 3.5f", fixedToFloat(registers->CP2D.n.mac3));

Check warning on line 223 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L222-L223

Added lines #L222 - L223 were not covered by tests
} else {
ImGui::Text("mac3: %i", registers->CP2D.n.mac3);

Check warning on line 225 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L225

Added line #L225 was not covered by tests
}
ImGui::Text("irgb: %u", registers->CP2D.n.irgb);
ImGui::Text("orgb: %u", registers->CP2D.n.orgb);
ImGui::Text("lzcs: %i", registers->CP2D.n.lzcs);
ImGui::Text("lzcr: %i", registers->CP2D.n.lzcr);
if (m_showFixed) {
ImGui::Text("lzcs: % 3.5f", fixedToFloat(registers->CP2D.n.lzcs));

Check warning on line 230 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L229-L230

Added lines #L229 - L230 were not covered by tests
} else {
ImGui::Text("lzcs: %i", registers->CP2D.n.lzcs);

Check warning on line 232 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L232

Added line #L232 was not covered by tests
}
if (m_showFixed) {
ImGui::Text("lzcr: % 3.5f", fixedToFloat(registers->CP2D.n.lzcr));

Check warning on line 235 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L234-L235

Added lines #L234 - L235 were not covered by tests
} else {
ImGui::Text("lzcr: %i", registers->CP2D.n.lzcr);

Check warning on line 237 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L237

Added line #L237 was not covered by tests
}
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("CP2C")) {
auto displayMatrix = [](const SMatrix3D& matrix, const char* name) {
ImGui::Checkbox(_("Show fixed point"), &m_showFixed);
auto showFixed = m_showFixed;
auto displayMatrixPlain = [](SMatrix3D matrix, const char* name) {

Check warning on line 244 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L242-L244

Added lines #L242 - L244 were not covered by tests
ImGui::Text(" [%5i, %5i, %5i]", matrix.m11, matrix.m12, matrix.m13);
ImGui::Text("%s: [%5i, %5i, %5i]", name, matrix.m21, matrix.m22, matrix.m23);
ImGui::Text(" [%5i, %5i, %5i]", matrix.m31, matrix.m32, matrix.m33);
};
auto displayMatrixFixed = [](SMatrix3D matrix, const char* name) {
ImGui::Text(" [% 3.5f, % 3.5f, % 3.5f]", fixedToFloat(matrix.m11), fixedToFloat(matrix.m12),
fixedToFloat(matrix.m13));
ImGui::Text("%s: [% 3.5f, % 3.5f, % 3.5f]", name, fixedToFloat(matrix.m21), fixedToFloat(matrix.m22),
fixedToFloat(matrix.m23));
ImGui::Text(" [% 3.5f, % 3.5f, % 3.5f]", fixedToFloat(matrix.m31), fixedToFloat(matrix.m32),
fixedToFloat(matrix.m33));
};
auto displayMatrix = showFixed ? displayMatrixFixed : displayMatrixPlain;

Check warning on line 257 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L249-L257

Added lines #L249 - L257 were not covered by tests
displayMatrix(registers->CP2C.n.rMatrix, "R");
if (showFixed) {
float m11 = fixedToFloat(registers->CP2C.n.rMatrix.m11);
float m12 = fixedToFloat(registers->CP2C.n.rMatrix.m12);
float m13 = fixedToFloat(registers->CP2C.n.rMatrix.m13);
float m21 = fixedToFloat(registers->CP2C.n.rMatrix.m21);
float m22 = fixedToFloat(registers->CP2C.n.rMatrix.m22);
float m23 = fixedToFloat(registers->CP2C.n.rMatrix.m23);
float m31 = fixedToFloat(registers->CP2C.n.rMatrix.m31);
float m32 = fixedToFloat(registers->CP2C.n.rMatrix.m32);
float m33 = fixedToFloat(registers->CP2C.n.rMatrix.m33);
float c11 = m22 * m33 - m23 * m32;
float c12 = m23 * m31 - m21 * m33;
float c13 = m21 * m32 - m22 * m31;
auto trace = m11 + m22 + m33;
auto determinant = m11 * c11 + m12 * c12 + m13 * c13;
ImGui::Text(" :: deter: % 3.5f", determinant);
ImGui::Text(" :: trace: % 3.5f", trace);
auto angle = std::acos((trace - 1.0) / 2.0);
ImGui::Text(" :: angle: % 3.5f x Pi", angle / std::numbers::pi);
float f = 1.0f / (2.0f * std::sin(angle));
float x = (m32 - m23) * f;
float y = (m13 - m31) * f;
float z = (m21 - m12) * f;
float magnitude = std::sqrt(x * x + y * y + z * z);
x /= magnitude;
y /= magnitude;
z /= magnitude;
ImGui::Text(" :: axis : {%3.5f, %3.5f, %3.5f}", x, y, z);

Check warning on line 286 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L259-L286

Added lines #L259 - L286 were not covered by tests
}
ImGui::Text("trX : %i", registers->CP2C.n.trX);
ImGui::Text("trY : %i", registers->CP2C.n.trY);
ImGui::Text("trZ : %i", registers->CP2C.n.trZ);
displayMatrix(registers->CP2C.n.lMatrix, "L");
ImGui::Text("rbk : %i", registers->CP2C.n.rbk);
ImGui::Text("gbk : %i", registers->CP2C.n.gbk);
ImGui::Text("bbk : %i", registers->CP2C.n.bbk);
if (showFixed) {
ImGui::Text("rbk : % 3.5f", fixedToFloat(registers->CP2C.n.rbk));
ImGui::Text("gbk : % 3.5f", fixedToFloat(registers->CP2C.n.gbk));
ImGui::Text("bbk : % 3.5f", fixedToFloat(registers->CP2C.n.bbk));

Check warning on line 295 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L292-L295

Added lines #L292 - L295 were not covered by tests
} else {
ImGui::Text("rbk : %i", registers->CP2C.n.rbk);
ImGui::Text("gbk : %i", registers->CP2C.n.gbk);
ImGui::Text("bbk : %i", registers->CP2C.n.bbk);

Check warning on line 299 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L297-L299

Added lines #L297 - L299 were not covered by tests
}
displayMatrix(registers->CP2C.n.cMatrix, "C");
ImGui::Text("rfc : %i", registers->CP2C.n.rfc);
ImGui::Text("gfc : %i", registers->CP2C.n.gfc);
ImGui::Text("bfc : %i", registers->CP2C.n.bfc);
ImGui::Text("ofx : %i", registers->CP2C.n.ofx);
ImGui::Text("ofy : %i", registers->CP2C.n.ofy);
ImGui::Text("h : %i", registers->CP2C.n.h);
ImGui::Text("dqa : %i", registers->CP2C.n.dqa);
ImGui::Text("dqb : %i", registers->CP2C.n.dqb);
ImGui::Text("zsf3: %i", registers->CP2C.n.zsf3);
ImGui::Text("zsf4: %i", registers->CP2C.n.zsf4);
ImGui::Text("flag: %i", registers->CP2C.n.flag);
if (showFixed) {
ImGui::Text("rfc : % 3.5f", fixedToFloat<4>(registers->CP2C.n.rfc));
ImGui::Text("gfc : % 3.5f", fixedToFloat<4>(registers->CP2C.n.gfc));
ImGui::Text("bfc : % 3.5f", fixedToFloat<4>(registers->CP2C.n.bfc));
ImGui::Text("ofx : % 3.5f", fixedToFloat<15>(registers->CP2C.n.ofx));
ImGui::Text("ofy : % 3.5f", fixedToFloat<15>(registers->CP2C.n.ofy));
ImGui::Text("h : % i", registers->CP2C.n.h);
ImGui::Text("dqa : % 3.5f", fixedToFloat<8>(registers->CP2C.n.dqa));
ImGui::Text("dqb : % 3.5f", fixedToFloat<24>(registers->CP2C.n.dqb));
ImGui::Text("zsf3: % 3.5f", fixedToFloat(registers->CP2C.n.zsf3));
ImGui::Text("zsf4: % 3.5f", fixedToFloat(registers->CP2C.n.zsf4));

Check warning on line 312 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L302-L312

Added lines #L302 - L312 were not covered by tests
} else {
ImGui::Text("rfc : %i", registers->CP2C.n.rfc);
ImGui::Text("gfc : %i", registers->CP2C.n.gfc);
ImGui::Text("bfc : %i", registers->CP2C.n.bfc);
ImGui::Text("ofx : %i", registers->CP2C.n.ofx);
ImGui::Text("ofy : %i", registers->CP2C.n.ofy);
ImGui::Text("h : %i", registers->CP2C.n.h);
ImGui::Text("dqa : %i", registers->CP2C.n.dqa);
ImGui::Text("dqb : %i", registers->CP2C.n.dqb);
ImGui::Text("zsf3: %i", registers->CP2C.n.zsf3);
ImGui::Text("zsf4: %i", registers->CP2C.n.zsf4);

Check warning on line 323 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L314-L323

Added lines #L314 - L323 were not covered by tests
}
ImGui::Text("flag: 0x%08x", registers->CP2C.n.flag);

Check warning on line 325 in src/gui/widgets/registers.cc

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

PCSX::Widgets::Registers::draw increases in cyclomatic complexity from 26 to 52, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

Check warning on line 325 in src/gui/widgets/registers.cc

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Bumpy Road Ahead

PCSX::Widgets::Registers::draw increases from 4 to 6 logical blocks with deeply nested code, threshold is one single block per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.

Check warning on line 325 in src/gui/widgets/registers.cc

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.cc#L325

Added line #L325 was not covered by tests
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem(_("Misc"))) {
Expand Down
5 changes: 5 additions & 0 deletions src/gui/widgets/registers.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ class Registers {

private:
void makeEditableRegister(const char* name, uint32_t reg);
template <size_t Fract = 12>
static float fixedToFloat(int32_t value) {
return static_cast<float>(value) / static_cast<float>(1 << Fract);

Check warning on line 42 in src/gui/widgets/registers.h

View check run for this annotation

Codecov / codecov/patch

src/gui/widgets/registers.h#L41-L42

Added lines #L41 - L42 were not covered by tests
}

unsigned m_selected = 0;
bool m_showFixed = false;
char m_registerEditor[20];
std::string m_editorToOpen;
};
Expand Down

0 comments on commit 4f7ab52

Please sign in to comment.