Skip to content

Commit 1e684b4

Browse files
committed
Merge branch 'main' into memcard_mgr
2 parents 6dd3a37 + d3fb044 commit 1e684b4

File tree

12 files changed

+350
-36
lines changed

12 files changed

+350
-36
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
*.sln.docstates
77
*.userprefs
88

9+
#Clion Files
10+
.idea/
11+
912
Debug/
1013
Release/
1114
ReleaseWithTracy/
@@ -88,4 +91,5 @@ vram-viewer.vert
8891
pcsx.lua
8992
DynarecOutput.map
9093
DynarecProfileData.txt
91-
sstate.proto
94+
DynarecDisassembly.txt
95+
sstate.proto

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ PACKAGES := capstone freetype2 glfw3 libavcodec libavformat libavutil libswresam
1010

1111
LOCALES := fr
1212

13-
ifeq ($(wildcard third_party/zlib/zlib.h),)
13+
ifeq ($(wildcard third_party/imgui/imgui.h),)
1414
HAS_SUBMODULES = false
1515
else
1616
HAS_SUBMODULES = true
@@ -228,7 +228,7 @@ runtests: pcsx-redux-tests
228228
./pcsx-redux-tests
229229

230230
psyq-obj-parser: $(SUPPORT_OBJECTS) tools/psyq-obj-parser/psyq-obj-parser.cc
231-
$(LD) -o $@ $(SUPPORT_OBJECTS) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) tools/psyq-obj-parser/psyq-obj-parser.cc -Ithird_party/ELFIO
231+
$(LD) -o $@ $(SUPPORT_OBJECTS) $(CPPFLAGS) $(CXXFLAGS) tools/psyq-obj-parser/psyq-obj-parser.cc -Ithird_party/ELFIO
232232

233233
ps1-packer: $(SUPPORT_OBJECTS) tools/ps1-packer/ps1-packer.cc
234234
$(LD) -o $@ $(SUPPORT_OBJECTS) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) tools/ps1-packer/ps1-packer.cc

src/core/DynaRec_x64/recompiler.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,13 @@ class DynaRecCPU final : public PCSX::R3000Acpu {
163163
virtual void Reset() final;
164164
virtual void Shutdown() final;
165165
virtual bool isDynarec() final { return true; }
166-
167166
virtual void Execute() final {
168167
ZoneScoped; // Tell the Tracy profiler to do its thing
169168
(*m_dispatcher)(); // Jump to assembly dispatcher
170169
}
170+
// For the GUI dynarec disassembly widget
171+
virtual const uint8_t *getBufferPtr() final { return gen.getCode<const uint8_t*>(); }
172+
virtual const size_t getBufferSize() final { return gen.getSize(); }
171173

172174
// TODO: Make it less slow and bad
173175
// Possibly clear blocks more aggressively

src/core/ix86/iR3000A.cc

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ class DynaRecCPU final : public PCSX::R3000Acpu {
8686
virtual void Shutdown() final;
8787
virtual void SetPGXPMode(uint32_t pgxpMode) final;
8888
virtual bool isDynarec() final { return true; }
89+
// For the GUI dynarec disassembly widget
90+
virtual const uint8_t *getBufferPtr() final { return gen.getCode<const uint8_t *>(); }
91+
virtual const size_t getBufferSize() final { return gen.getSize(); }
8992

9093
static void recClearWrapper(DynaRecCPU *that, uint32_t a, uint32_t s) { that->Clear(a, s); }
9194
static uint32_t psxExceptionWrapper(DynaRecCPU *that, int e, int32_t bd) {
@@ -2861,14 +2864,14 @@ const func_t DynaRecCPU::m_recSPC[64] = {
28612864
};
28622865

28632866
const func_t DynaRecCPU::m_recREG[32] = {
2864-
&DynaRecCPU::recBLTZ, &DynaRecCPU::recBGEZ, &DynaRecCPU::recNULL, &DynaRecCPU::recNULL, // 00
2865-
&DynaRecCPU::recNULL, &DynaRecCPU::recNULL, &DynaRecCPU::recNULL, &DynaRecCPU::recNULL, // 04
2866-
&DynaRecCPU::recNULL, &DynaRecCPU::recNULL, &DynaRecCPU::recNULL, &DynaRecCPU::recNULL, // 08
2867-
&DynaRecCPU::recNULL, &DynaRecCPU::recNULL, &DynaRecCPU::recNULL, &DynaRecCPU::recNULL, // 0c
2868-
&DynaRecCPU::recBLTZAL, &DynaRecCPU::recBGEZAL, &DynaRecCPU::recNULL, &DynaRecCPU::recNULL, // 10
2869-
&DynaRecCPU::recNULL, &DynaRecCPU::recNULL, &DynaRecCPU::recNULL, &DynaRecCPU::recNULL, // 14
2870-
&DynaRecCPU::recNULL, &DynaRecCPU::recNULL, &DynaRecCPU::recNULL, &DynaRecCPU::recNULL, // 18
2871-
&DynaRecCPU::recNULL, &DynaRecCPU::recNULL, &DynaRecCPU::recNULL, &DynaRecCPU::recNULL, // 1c
2867+
&DynaRecCPU::recBLTZ, &DynaRecCPU::recBGEZ, &DynaRecCPU::recBLTZ, &DynaRecCPU::recBGEZ, // 00
2868+
&DynaRecCPU::recBLTZ, &DynaRecCPU::recBGEZ, &DynaRecCPU::recBLTZ, &DynaRecCPU::recBGEZ, // 04
2869+
&DynaRecCPU::recBLTZ, &DynaRecCPU::recBGEZ, &DynaRecCPU::recBLTZ, &DynaRecCPU::recBGEZ, // 08
2870+
&DynaRecCPU::recBLTZ, &DynaRecCPU::recBGEZ, &DynaRecCPU::recBLTZ, &DynaRecCPU::recBGEZ, // 0c
2871+
&DynaRecCPU::recBLTZAL, &DynaRecCPU::recBGEZAL, &DynaRecCPU::recBLTZ, &DynaRecCPU::recBGEZ, // 10
2872+
&DynaRecCPU::recBLTZ, &DynaRecCPU::recBGEZ, &DynaRecCPU::recBLTZ, &DynaRecCPU::recBGEZ, // 14
2873+
&DynaRecCPU::recBLTZ, &DynaRecCPU::recBGEZ, &DynaRecCPU::recBLTZ, &DynaRecCPU::recBGEZ, // 18
2874+
&DynaRecCPU::recBLTZ, &DynaRecCPU::recBGEZ, &DynaRecCPU::recBLTZ, &DynaRecCPU::recBGEZ // 1c
28722875
};
28732876

28742877
const func_t DynaRecCPU::m_recCP0[32] = {

src/core/psxinterpreter.cc

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ class InterpretedCPU final : public PCSX::R3000Acpu {
9898
virtual void Shutdown() override;
9999
virtual void SetPGXPMode(uint32_t pgxpMode) override;
100100
virtual bool isDynarec() override { return false; }
101-
102101
void maybeCancelDelayedLoad(uint32_t index) {
103102
unsigned other = m_currentDelayedLoad ^ 1;
104103
if (m_delayedLoadInfo[other].index == index) m_delayedLoadInfo[other].active = false;
105104
}
105+
// For the GUI dynarec disassembly widget
106+
virtual const uint8_t *getBufferPtr() final { return nullptr; }
107+
virtual const size_t getBufferSize() final { return 0; }
106108

107109
void psxTestSWInts();
108110

@@ -787,7 +789,7 @@ void InterpretedCPU::psxRFE(uint32_t code) {
787789
* Format: OP rs, rt, offset *
788790
*********************************************************/
789791
#define RepBranchi32(op) \
790-
if ((int32_t)_rRs_ op (int32_t)_rRt_) doBranch(_BranchTarget_, false);
792+
if ((int32_t)_rRs_ op(int32_t) _rRt_) doBranch(_BranchTarget_, false);
791793

792794
void InterpretedCPU::psxBEQ(uint32_t code) { RepBranchi32(==) } // Branch if Rs == Rt
793795
void InterpretedCPU::psxBNE(uint32_t code) { RepBranchi32(!=) } // Branch if Rs != Rt
@@ -1188,15 +1190,18 @@ const InterpretedCPU::intFunc_t InterpretedCPU::s_psxSPC[64] = {
11881190
&InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, // 3c
11891191
};
11901192

1193+
// The REGIMM instruction is actually valid for every single value that the rt field might have
1194+
// If the lowest bit of the rt field is 1 then the instruction is a BGEZ, otherwise it's a BLTZ.
1195+
// If ((_Rt_ >> 4) & 0xF) == 0x8 then the instruction should link the return address to $ra, otherwise not.
11911196
const InterpretedCPU::intFunc_t InterpretedCPU::s_psxREG[32] = {
1192-
&InterpretedCPU::psxBLTZ, &InterpretedCPU::psxBGEZ, &InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, // 00
1193-
&InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, // 04
1194-
&InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, // 08
1195-
&InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, // 0c
1196-
&InterpretedCPU::psxBLTZAL, &InterpretedCPU::psxBGEZAL, &InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, // 10
1197-
&InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, // 14
1198-
&InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, // 18
1199-
&InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, &InterpretedCPU::psxNULL, // 1c
1197+
&InterpretedCPU::psxBLTZ, &InterpretedCPU::psxBGEZ, &InterpretedCPU::psxBLTZ, &InterpretedCPU::psxBGEZ, // 00
1198+
&InterpretedCPU::psxBLTZ, &InterpretedCPU::psxBGEZ, &InterpretedCPU::psxBLTZ, &InterpretedCPU::psxBGEZ, // 04
1199+
&InterpretedCPU::psxBLTZ, &InterpretedCPU::psxBGEZ, &InterpretedCPU::psxBLTZ, &InterpretedCPU::psxBGEZ, // 08
1200+
&InterpretedCPU::psxBLTZ, &InterpretedCPU::psxBGEZ, &InterpretedCPU::psxBLTZ, &InterpretedCPU::psxBGEZ, // 0c
1201+
&InterpretedCPU::psxBLTZAL, &InterpretedCPU::psxBGEZAL, &InterpretedCPU::psxBLTZ, &InterpretedCPU::psxBGEZ, // 10
1202+
&InterpretedCPU::psxBLTZ, &InterpretedCPU::psxBGEZ, &InterpretedCPU::psxBLTZ, &InterpretedCPU::psxBGEZ, // 14
1203+
&InterpretedCPU::psxBLTZ, &InterpretedCPU::psxBGEZ, &InterpretedCPU::psxBLTZ, &InterpretedCPU::psxBGEZ, // 18
1204+
&InterpretedCPU::psxBLTZ, &InterpretedCPU::psxBGEZ, &InterpretedCPU::psxBLTZ, &InterpretedCPU::psxBGEZ // 1c
12001205
};
12011206

12021207
const InterpretedCPU::intFunc_t InterpretedCPU::s_psxCP0[32] = {

src/core/r3000a.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919

2020
#pragma once
2121

22-
#include <stdint.h>
23-
2422
#include <atomic>
23+
#include <cstdint>
2524
#include <memory>
2625
#include <type_traits>
2726

@@ -32,6 +31,7 @@
3231
#include "support/file.h"
3332
#include "support/hashtable.h"
3433

34+
3535
#if defined(__i386__) || defined(_M_IX86)
3636
#define DYNAREC_X86_32
3737
#elif defined(__x86_64) || defined(_M_AMD64)
@@ -264,6 +264,9 @@ class R3000Acpu {
264264
virtual void Shutdown() = 0;
265265
virtual void SetPGXPMode(uint32_t pgxpMode) = 0;
266266
virtual bool Implemented() = 0;
267+
// For the GUI dynarec disassembly widget
268+
virtual const uint8_t *getBufferPtr() = 0;
269+
virtual const size_t getBufferSize() = 0;
267270

268271
const std::string &getName() { return m_name; }
269272

src/gui/gui.cc

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,18 @@ static void drop_callback(GLFWwindow* window, int count, const char** paths) {
112112
s_this->magicOpen(paths[0]);
113113
}
114114

115+
static void ShowHelpMarker(const char* desc) {
116+
ImGui::SameLine();
117+
ImGui::TextDisabled("(?)");
118+
if (ImGui::IsItemHovered()) {
119+
ImGui::BeginTooltip();
120+
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
121+
ImGui::TextUnformatted(desc);
122+
ImGui::PopTextWrapPos();
123+
ImGui::EndTooltip();
124+
}
125+
}
126+
115127
void LoadImguiBindings(lua_State* lState);
116128

117129
ImFont* PCSX::GUI::loadFont(const PCSX::u8string& name, int size, ImGuiIO& io, const ImWchar* ranges, bool combine) {
@@ -856,6 +868,14 @@ void PCSX::GUI::endFrame() {
856868
}
857869
ImGui::MenuItem(_("Show Registers"), nullptr, &m_registers.m_show);
858870
ImGui::MenuItem(_("Show Assembly"), nullptr, &m_assembly.m_show);
871+
if (PCSX::g_emulator->m_psxCpu->isDynarec()) {
872+
ImGui::MenuItem(_("Show DynaRec Disassembly"), nullptr, &m_disassembly.m_show);
873+
} else {
874+
ImGui::MenuItem(_("Show DynaRec Disassembly"), nullptr, false, false);
875+
ShowHelpMarker(
876+
_(R"(DynaRec Disassembler is not available in Interpreted CPU mode. Try enabling [Dynarec CPU]
877+
in Configuration->Emulation, restart PCSX-Redux, then try again.)"));
878+
}
859879
ImGui::MenuItem(_("Show Breakpoints"), nullptr, &m_breakpoints.m_show);
860880
ImGui::MenuItem(_("Show Callstacks"), nullptr, &m_callstacks.m_show);
861881
ImGui::MenuItem(_("Breakpoint on vsync"), nullptr, &m_breakOnVSync);
@@ -1057,6 +1077,10 @@ void PCSX::GUI::endFrame() {
10571077
_("Assembly"));
10581078
}
10591079

1080+
if (m_disassembly.m_show && PCSX::g_emulator->m_psxCpu->isDynarec()) {
1081+
m_disassembly.draw(this, _("DynaRec Disassembler"));
1082+
}
1083+
10601084
if (m_breakpoints.m_show) {
10611085
m_breakpoints.draw(_("Breakpoints"));
10621086
}
@@ -1182,18 +1206,6 @@ void PCSX::GUI::endFrame() {
11821206
FrameMark
11831207
}
11841208

1185-
static void ShowHelpMarker(const char* desc) {
1186-
ImGui::SameLine();
1187-
ImGui::TextDisabled("(?)");
1188-
if (ImGui::IsItemHovered()) {
1189-
ImGui::BeginTooltip();
1190-
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
1191-
ImGui::TextUnformatted(desc);
1192-
ImGui::PopTextWrapPos();
1193-
ImGui::EndTooltip();
1194-
}
1195-
}
1196-
11971209
bool PCSX::GUI::configure() {
11981210
bool changed = false;
11991211
bool selectBiosDialog = false;

src/gui/gui.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "flags.h"
2929
#include "fmt/printf.h"
3030
#include "gui/widgets/assembly.h"
31+
#include "gui/widgets/dynarec_disassembly.h"
3132
#include "gui/widgets/breakpoints.h"
3233
#include "gui/widgets/callstacks.h"
3334
#include "gui/widgets/console.h"
@@ -248,6 +249,7 @@ class GUI final {
248249
Widgets::MemcardManager m_memcardManager;
249250
Widgets::Registers m_registers;
250251
Widgets::Assembly m_assembly;
252+
Widgets::Disassembly m_disassembly;
251253
Widgets::FileDialog m_openIsoFileDialog = {[]() { return _("Open Image"); }};
252254
Widgets::FileDialog m_openBinaryDialog = {[]() { return _("Open Binary"); }};
253255
Widgets::FileDialog m_selectBiosDialog = {[]() { return _("Select BIOS"); }};

0 commit comments

Comments
 (0)