Skip to content

Commit 1ce423e

Browse files
authored
Merge branch 'grumpycoders:main' into Breakpoints-improvements
2 parents c10ee53 + 0933dcd commit 1ce423e

File tree

19 files changed

+530
-134
lines changed

19 files changed

+530
-134
lines changed

.github/workflows/linux-build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ jobs:
7070
APPDISTRIB_TOKEN: ${{ secrets.APPDISTRIB_DEV_LINUX_X64 }}
7171
APPDISTRIB_ORGANIZATION: pcsx-redux
7272
APPDISTRIB_PROJECT: dev-linux-x64
73-
APPCENTER_ACCESS_TOKEN: ${{ secrets.LINUX_APPCENTER_ACCESS_TOKEN }}
7473
run: |
7574
git config --global --add safe.directory /__w/pcsx-redux/pcsx-redux
7675
export BUILD=`git rev-parse HEAD | cut -c 1-8`
7776
zip PCSX-Redux-$BUILD-linux-x86_64.zip *.AppImage
78-
npx appcenter-cli distribute release -b $BUILD -f PCSX-Redux-$BUILD-linux-x86_64.zip -g public -a grumpycoders/pcsx-redux-linux64 --disable-telemetry
7977
npx @appdistrib/cli -l buildId -m version.json upload PCSX-Redux-$BUILD-linux-x86_64.zip

.github/workflows/macos-build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ jobs:
160160
APPDISTRIB_TOKEN: ${{ secrets.APPDISTRIB_DEV_MACOS_X64 }}
161161
APPDISTRIB_ORGANIZATION: pcsx-redux
162162
APPDISTRIB_PROJECT: dev-macos-x64
163-
APPCENTER_ACCESS_TOKEN: ${{ secrets.MACOS_APPCENTER_ACCESS_TOKEN }}
164163
run: |
165-
npx appcenter-cli distribute release -n 0 -b $BUILD -f PCSX-Redux-$BUILD-Intel.dmg -g 'Public' -a grumpycoders/pcsx-redux-macos --disable-telemetry
166164
npx @appdistrib/cli -l buildId -m version.json upload PCSX-Redux-$BUILD-Intel.dmg
167165
168166
macos-arm-build-and-test:

src/core/debug.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ void PCSX::Debug::process(uint32_t oldPC, uint32_t newPC, uint32_t oldCode, uint
111111
const bool isSWL = basic == 0x2a;
112112
const bool isSW = (basic == 0x2b) || (basic == 0x3a);
113113
const bool isSWR = basic == 0x2e;
114+
const bool isLWC2 = basic == 0x32;
115+
const bool isSWC2 = basic == 0x3a;
114116
uint32_t offset = regs.GPR.r[(newCode >> 21) & 0x1f] + int16_t(newCode);
115117
if (isLWL || isLWR || isSWR || isSWL) offset &= ~3;
116118
if (isLB || isLBU) {
@@ -127,7 +129,7 @@ void PCSX::Debug::process(uint32_t oldPC, uint32_t newPC, uint32_t oldCode, uint
127129
}
128130
if (m_mapping_r16) markMap(offset, MAP_R16);
129131
}
130-
if (isLW || isLWR || isLWL) {
132+
if (isLW || isLWR || isLWL || isLWC2) {
131133
checkBP(offset, BreakpointType::Read, 4);
132134
if (m_breakmp_r32 && !isMapMarked(offset, MAP_R32)) {
133135
triggerBP(nullptr, offset, 4, _("Read 32 map"));
@@ -148,7 +150,7 @@ void PCSX::Debug::process(uint32_t oldPC, uint32_t newPC, uint32_t oldCode, uint
148150
}
149151
if (m_mapping_w16) markMap(offset, MAP_W16);
150152
}
151-
if (isSW || isSWR || isSWL) {
153+
if (isSW || isSWR || isSWL || isSWC2) {
152154
checkBP(offset, BreakpointType::Write, 4);
153155
if (m_breakmp_w32 && !isMapMarked(offset, MAP_W32)) {
154156
triggerBP(nullptr, offset, 4, _("Write 32 map"));

src/core/gpu.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,7 @@ void PCSX::GPU::Poly<shading, shape, textured, blend, modulation>::drawLogNode(u
11311131
int minX = 2048, minY = 1024, maxX = -1024, maxY = -512;
11321132
int minU = 2048, minV = 1024, maxU = -1024, maxV = -512;
11331133
for (unsigned i = 0; i < count; i++) {
1134+
ImGui::PushID(i);
11341135
ImGui::Separator();
11351136
ImGui::Text(_("Vertex %i"), i);
11361137
ImGui::Text(" X: %i + %i = %i, Y: %i + %i = %i", x[i], offset.x, x[i] + offset.x, y[i], offset.y,
@@ -1153,6 +1154,7 @@ void PCSX::GPU::Poly<shading, shape, textured, blend, modulation>::drawLogNode(u
11531154
maxU = std::max(maxU, int(u[i] >> shift));
11541155
maxV = std::max(maxV, int(v[i]));
11551156
}
1157+
ImGui::PopID();
11561158
}
11571159
ImGui::Separator();
11581160
std::string label = fmt::format(f_("Go to primitive##{}"), itemIndex);
@@ -1197,6 +1199,7 @@ void PCSX::GPU::Line<shading, lineType, blend>::drawLogNode(unsigned itemIndex,
11971199
ImGui::TextUnformatted(_("Semi-transparency blending"));
11981200
}
11991201
for (unsigned i = 1; i < colors.size(); i++) {
1202+
ImGui::PushID(i);
12001203
ImGui::Separator();
12011204
if constexpr (lineType == LineType::Poly) {
12021205
ImGui::Text(_("Line %i"), i);
@@ -1215,6 +1218,7 @@ void PCSX::GPU::Line<shading, lineType, blend>::drawLogNode(unsigned itemIndex,
12151218
minY = std::min(minY, y[i] + offset.y);
12161219
maxX = std::max(maxX, x[i] + offset.x);
12171220
maxY = std::max(maxY, y[i] + offset.y);
1221+
ImGui::PopID();
12181222
}
12191223
ImGui::Separator();
12201224
std::string label = fmt::format(f_("Go to primitive##{}"), itemIndex);

src/core/gte.h

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,30 @@ class GTE {
5151

5252
void MTC2(uint32_t code) { MTC2_internal(PCSX::g_emulator->m_cpu->m_regs.GPR.r[_Rt_], _Rd_); }
5353
void CTC2(uint32_t code) { CTC2_internal(PCSX::g_emulator->m_cpu->m_regs.GPR.r[_Rt_], _Rd_); }
54-
void LWC2(uint32_t code) { MTC2_internal(PCSX::g_emulator->m_mem->read32(gteoB), _Rt_); }
55-
void SWC2(uint32_t code) { PCSX::g_emulator->m_mem->write32(gteoB, MFC2_internal(_Rt_)); }
54+
void LWC2(uint32_t code) {
55+
if (gteoB & 3) {
56+
PCSX::g_emulator->m_cpu->m_regs.pc -= 4;
57+
PCSX::g_system->log(PCSX::LogClass::CPU, _("Unaligned address 0x%08x in LWC2 from 0x%08x\n"), gteoB,
58+
PCSX::g_emulator->m_cpu->m_regs.pc);
59+
PCSX::g_emulator->m_cpu->m_regs.CP0.n.BadVAddr = gteoB;
60+
PCSX::g_emulator->m_cpu->exception(PCSX::R3000Acpu::Exception::LoadAddressError,
61+
PCSX::g_emulator->m_cpu->m_inDelaySlot);
62+
return;
63+
}
64+
MTC2_internal(PCSX::g_emulator->m_mem->read32(gteoB), _Rt_);
65+
}
66+
void SWC2(uint32_t code) {
67+
if (gteoB & 3) {
68+
PCSX::g_emulator->m_cpu->m_regs.pc -= 4;
69+
PCSX::g_system->log(PCSX::LogClass::CPU, _("Unaligned address 0x%08x in SWC2 from 0x%08x\n"), gteoB,
70+
PCSX::g_emulator->m_cpu->m_regs.pc);
71+
PCSX::g_emulator->m_cpu->m_regs.CP0.n.BadVAddr = gteoB;
72+
PCSX::g_emulator->m_cpu->exception(PCSX::R3000Acpu::Exception::StoreAddressError,
73+
PCSX::g_emulator->m_cpu->m_inDelaySlot);
74+
return;
75+
}
76+
PCSX::g_emulator->m_mem->write32(gteoB, MFC2_internal(_Rt_));
77+
}
5678

5779
void RTPS(uint32_t code);
5880
void NCLIP(uint32_t code);

src/core/r3000a.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,10 @@ class R3000Acpu {
318318
void scheduleInterrupt(unsigned interrupt, uint32_t eCycle) {
319319
PSXIRQ_LOG("Scheduling interrupt %08x at %08x\n", interrupt, eCycle);
320320
const uint64_t cycle = m_regs.cycle;
321-
uint64_t target = uint64_t(cycle + eCycle * m_interruptScales[interrupt]);
321+
uint64_t target = cycle + uint64_t(eCycle * m_interruptScales[interrupt]);
322322
m_regs.interrupt |= (1 << interrupt);
323323
m_regs.intTargets[interrupt] = target;
324-
int64_t lowest = m_regs.lowestTarget - cycle;
325-
int64_t maybeNewLowest = target - cycle;
326-
if (maybeNewLowest < lowest) m_regs.lowestTarget = target;
324+
if (target < m_regs.lowestTarget) m_regs.lowestTarget = target;
327325
}
328326

329327
psxRegisters m_regs;

src/core/web-server.cc

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -952,11 +952,14 @@ struct PCSX::WebClient::WebClientImpl {
952952
}
953953

954954
void onEOF() {
955-
llhttp_execute(&m_httpParser, nullptr, 0);
956-
if (m_httpParser.upgrade) {
955+
auto error = llhttp_finish(&m_httpParser);
956+
if (error == HPE_PAUSED_UPGRADE) {
957957
onUpgrade();
958+
} else if (error != HPE_OK) {
959+
send400(magic_enum::enum_name(error));
960+
} else {
961+
scheduleClose();
958962
}
959-
scheduleClose();
960963
}
961964

962965
void onUpgrade() {}
@@ -1104,7 +1107,7 @@ struct PCSX::WebClient::WebClientImpl {
11041107
void read(ssize_t nread, const uv_buf_t* buf) {
11051108
m_allocated = false;
11061109
if (nread <= 0) {
1107-
close();
1110+
onEOF();
11081111
return;
11091112
}
11101113
Slice slice;
@@ -1119,11 +1122,12 @@ struct PCSX::WebClient::WebClientImpl {
11191122
const char* ptr = reinterpret_cast<const char*>(slice.data());
11201123
auto size = slice.size();
11211124

1122-
auto parsed = llhttp_execute(&m_httpParser, ptr, size);
1125+
auto error = llhttp_execute(&m_httpParser, ptr, size);
11231126
if (m_status != OPEN) return;
1124-
if (parsed != size) send400();
1125-
if (m_httpParser.upgrade) {
1127+
if (error == HPE_PAUSED_UPGRADE) {
11261128
onUpgrade();
1129+
} else if (error != HPE_OK) {
1130+
send400(magic_enum::enum_name(error));
11271131
}
11281132
}
11291133

@@ -1150,8 +1154,10 @@ struct PCSX::WebClient::WebClientImpl {
11501154
write(std::move(slice));
11511155
}
11521156

1153-
void send400() {
1154-
write("HTTP/1.1 400 Bad Request\r\n\r\nThis request failed to parse properly.\r\n");
1157+
void send400(std::string_view code) {
1158+
std::string str =
1159+
fmt::format("HTTP/1.1 400 Bad Request\r\n\r\Request failed to parse properly. Error: {}\r\n", code);
1160+
write(std::move(str));
11551161
scheduleClose();
11561162
}
11571163

src/gui/widgets/gpulogger.cc

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ void PCSX::Widgets::GPULogger::draw(PCSX::GPULogger* logger, const char* title)
173173
int n = 0;
174174

175175
for (auto& logged : logger->m_list) {
176+
ImGui::PushID(n);
176177
if (m_filterEnabled && !logged.isInside(m_filter.x, m_filter.y)) {
177178
continue;
178179
}
@@ -220,12 +221,10 @@ void PCSX::Widgets::GPULogger::draw(PCSX::GPULogger* logger, const char* title)
220221
if (disableFromHere) logged.enabled = false;
221222
if (removeHighlight) logged.highlight = false;
222223
ImGui::BeginGroup();
223-
label = fmt::format("##enable{}", n);
224224
if (!m_replay) ImGui::BeginDisabled();
225-
ImGui::Checkbox(label.c_str(), &logged.enabled);
225+
ImGui::Checkbox("##enable", &logged.enabled);
226226
ImGui::SameLine();
227-
label = fmt::format("T##upto{}", n);
228-
if (ImGui::Button(label.c_str())) {
227+
if (ImGui::Button("T")) {
229228
for (auto& before : logger->m_list) {
230229
before.enabled = true;
231230
if (&before == &logged) break;
@@ -234,17 +233,14 @@ void PCSX::Widgets::GPULogger::draw(PCSX::GPULogger* logger, const char* title)
234233
}
235234
if (!m_replay) ImGui::EndDisabled();
236235
ImGui::SameLine();
237-
label = fmt::format("##highlight{}", n);
238-
ImGui::Checkbox(label.c_str(), &logged.highlight);
236+
ImGui::Checkbox("##highlight", &logged.highlight);
239237
ImGui::SameLine();
240-
label = fmt::format("B##upto{}", n);
241-
if (ImGui::Button(label.c_str())) {
238+
if (ImGui::Button("B")) {
242239
m_setHighlightRange = true;
243240
m_beginHighlight = n;
244241
}
245242
ImGui::SameLine();
246-
label = fmt::format("E##upto{}", n);
247-
if (ImGui::Button(label.c_str())) {
243+
if (ImGui::Button("E")) {
248244
m_setHighlightRange = true;
249245
m_endHighlight = n;
250246
}
@@ -267,6 +263,7 @@ void PCSX::Widgets::GPULogger::draw(PCSX::GPULogger* logger, const char* title)
267263
hasHighlight = true;
268264
}
269265
n++;
266+
ImGui::PopID();
270267
}
271268

272269
ImGui::EndChild();

src/mips/psyqo-paths/cdrom-loader.hh

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ SOFTWARE.
3030
#include <EASTL/vector.h>
3131
#include <stdint.h>
3232

33+
#include <coroutine>
34+
3335
#include "psyqo/gpu.hh"
3436
#include "psyqo/iso9660-parser.hh"
3537
#include "psyqo/task.hh"
@@ -45,10 +47,34 @@ namespace psyqo::paths {
4547
* the data of the file, or an empty vector if the file could not be read.
4648
* This is going to allocate memory in different places. Only one file can
4749
* be read at a time, but it is safe to call readFile() again from the
48-
* callback.
50+
* callback. If preferred, the loader can be cascaded into another `TaskQueue`.
51+
* Also, for convenience, readFile() can be awaited on using the co_await
52+
* keyword in a coroutine.
4953
*/
5054

5155
class CDRomLoader {
56+
struct ReadFileAwaiter {
57+
ReadFileAwaiter(eastl::string_view path, GPU &gpu, ISO9660Parser &parser, CDRomLoader &loader)
58+
: m_path(path), m_gpu(gpu), m_parser(parser), m_loader(loader) {}
59+
~ReadFileAwaiter() {}
60+
constexpr bool await_ready() const { return false; }
61+
template <typename U>
62+
void await_suspend(std::coroutine_handle<U> handle) {
63+
m_loader.readFile(m_path, m_gpu, m_parser, [handle, this](eastl::vector<uint8_t> &&data) {
64+
m_data = eastl::move(data);
65+
handle.resume();
66+
});
67+
}
68+
eastl::vector<uint8_t> await_resume() { return eastl::move(m_data); }
69+
70+
private:
71+
eastl::string_view m_path;
72+
GPU &m_gpu;
73+
ISO9660Parser &m_parser;
74+
CDRomLoader &m_loader;
75+
eastl::vector<uint8_t> m_data;
76+
};
77+
5278
public:
5379
/**
5480
* @brief Reads a file from the CDRom.
@@ -61,16 +87,23 @@ class CDRomLoader {
6187
* will be called with the data of the file, or an empty vector if the file
6288
* could not be read.
6389
*/
64-
void readFile(eastl::string_view path, GPU& gpu, ISO9660Parser& parser,
65-
eastl::function<void(eastl::vector<uint8_t>&&)>&& callback) {
90+
void readFile(eastl::string_view path, GPU &gpu, ISO9660Parser &parser,
91+
eastl::function<void(eastl::vector<uint8_t> &&)> &&callback) {
6692
setupQueue(path, gpu, parser, eastl::move(callback));
6793
m_queue.run();
6894
}
95+
psyqo::TaskQueue::Task scheduleReadFile(eastl::string_view path, GPU &gpu, ISO9660Parser &parser) {
96+
setupQueue(path, gpu, parser, {});
97+
return m_queue.schedule();
98+
}
99+
ReadFileAwaiter readFile(eastl::string_view path, GPU &gpu, ISO9660Parser &parser) {
100+
return {path, gpu, parser, *this};
101+
}
69102

70103
private:
71-
void setupQueue(eastl::string_view path, GPU& gpu, ISO9660Parser& parser,
72-
eastl::function<void(eastl::vector<uint8_t>&&)>&& callback);
73-
eastl::function<void(eastl::vector<uint8_t>&&)> m_callback;
104+
void setupQueue(eastl::string_view path, GPU &gpu, ISO9660Parser &parser,
105+
eastl::function<void(eastl::vector<uint8_t> &&)> &&callback);
106+
eastl::function<void(eastl::vector<uint8_t> &&)> m_callback;
74107
psyqo::TaskQueue m_queue;
75108
ISO9660Parser::ReadRequest m_request;
76109
eastl::vector<uint8_t> m_data;

0 commit comments

Comments
 (0)