Skip to content

Commit 92e8230

Browse files
committed
Merge pull request #20510 from hrydgard/more-fixes
Fix bug in Win32 debugger, misc fixes
1 parent aedd4fe commit 92e8230

File tree

7 files changed

+33
-19
lines changed

7 files changed

+33
-19
lines changed

Core/Core.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,21 +158,25 @@ void Core_Stop() {
158158
}
159159

160160
void Core_UpdateState(CoreState newState) {
161-
if ((coreState == CORE_RUNNING_CPU || coreState == CORE_NEXTFRAME) && newState != CORE_RUNNING_CPU)
161+
const CoreState state = coreState;
162+
if ((state == CORE_RUNNING_CPU || state == CORE_NEXTFRAME) && newState != CORE_RUNNING_CPU)
162163
coreStatePending = true;
163164
coreState = newState;
164165
}
165166

166167
bool Core_IsStepping() {
167-
return coreState == CORE_STEPPING_CPU || coreState == CORE_POWERDOWN;
168+
const CoreState state = coreState;
169+
return state == CORE_STEPPING_CPU || state == CORE_STEPPING_GE || state == CORE_POWERDOWN;
168170
}
169171

170172
bool Core_IsActive() {
171-
return coreState == CORE_RUNNING_CPU || coreState == CORE_NEXTFRAME || coreStatePending;
173+
const CoreState state = coreState;
174+
return state == CORE_RUNNING_CPU || state == CORE_NEXTFRAME || coreStatePending;
172175
}
173176

174177
bool Core_IsInactive() {
175-
return coreState != CORE_RUNNING_CPU && coreState != CORE_NEXTFRAME && !coreStatePending;
178+
const CoreState state = coreState;
179+
return state != CORE_RUNNING_CPU && state != CORE_NEXTFRAME && !coreStatePending;
176180
}
177181

178182
void Core_StateProcessed() {
@@ -422,7 +426,12 @@ static bool Core_ProcessStepping(MIPSDebugInterface *cpu) {
422426
void Core_Break(BreakReason reason, u32 relatedAddress) {
423427
const CoreState state = coreState;
424428
if (state != CORE_RUNNING_CPU) {
425-
ERROR_LOG(Log::CPU, "Core_Break(%s) only works in the CORE_RUNNING_CPU state (was in state %s)", BreakReasonToString(reason), CoreStateToString(state));
429+
if (state == CORE_STEPPING_CPU) {
430+
// Already stepping.
431+
INFO_LOG(Log::CPU, "Core_Break(%s), already in break mode", BreakReasonToString(reason));
432+
return;
433+
}
434+
WARN_LOG(Log::CPU, "Core_Break(%s) only works in the CORE_RUNNING_CPU state (was in state %s)", BreakReasonToString(reason), CoreStateToString(state));
426435
return;
427436
}
428437

Core/HLE/ReplaceTables.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,9 +1283,11 @@ static int Hook_omertachinmokunookitethelegacy_download_frame() {
12831283
// Function at 0886665C in US version (Persona 1)
12841284
// Function at 08807DC4 in EU version (Persona 2)
12851285
static int Hook_persona_download_frame() {
1286-
const u32 fb_address = 0x04088000; // hardcoded at 088666D8
1287-
// const u32 dest_address = currentMIPS->r[MIPS_REG_A1]; // not relevant
1288-
if (Memory::IsVRAMAddress(fb_address)) {
1286+
// Depending on a global (curframe kind of thing), this either reads from
1287+
// 0x04088000 or 0x04000000 (the two addresses are hardcoded).
1288+
// We'd have to do some gnarly stuff to get this address, so let's just download both.
1289+
for (int i = 0; i < 2; i++) {
1290+
const u32 fb_address = i == 0 ? 0x04000000 : 0x04088000;
12891291
gpu->PerformReadbackToMemory(fb_address, 0x00088000);
12901292
NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "persona1_download_frame");
12911293
}

Core/HW/SasReverb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ void SasReverb::ProcessReverb(int16_t *output, const int16_t *input, size_t inpu
225225
// Standard volume is 10, which pairs with a normal shift of 15.
226226
if (reverbVolumeMultiplier <= 0.0f) {
227227
// Force to zero output, which is not the same as "Off."
228-
memset(output, 0, inputSize * 4);
228+
memset(output, 0, inputSize * 4 * sizeof(int16_t));
229229
return;
230230
} else {
231231
volLeft *= reverbVolumeMultiplier;

Core/MIPS/JitCommon/JitBlockCache.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,11 @@ void JitBlockCache::Shutdown() {
120120
// This clears the JIT cache. It's called from JitCache.cpp when the JIT cache
121121
// is full and when saving and loading states.
122122
void JitBlockCache::Clear() {
123+
for (int i = 0; i < num_blocks_; i++) {
124+
DestroyBlock(i, DestroyType::CLEAR);
125+
}
123126
block_map_.clear();
124127
proxyBlockMap_.clear();
125-
for (int i = 0; i < num_blocks_; i++)
126-
DestroyBlock(i, DestroyType::CLEAR);
127128
links_to_.clear();
128129
num_blocks_ = 0;
129130

UI/ImDebugger/ImDebugger.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
#include "Common/Data/Format/IniFile.h"
1010
#include "Common/Data/Text/Parsers.h"
1111
#include "Common/Log/LogManager.h"
12+
#include "Common/TimeUtil.h"
1213
#include "Core/Config.h"
1314
#include "Core/System.h"
15+
#include "Core/SaveState.h"
1416
#include "Core/Debugger/MemBlockInfo.h"
1517
#include "Core/RetroAchievements.h"
1618
#include "Core/Core.h"
@@ -45,6 +47,7 @@
4547
#include "Core/HLE/sceSas.h"
4648
#include "Core/HW/SasAudio.h"
4749
#include "Core/HW/Display.h"
50+
#include "Core/Dialog/PSPSaveDialog.h"
4851

4952
#include "Core/CoreTiming.h"
5053
// Threads window
@@ -703,6 +706,11 @@ static void DrawInternals(ImConfig &cfg) {
703706
ImGui::Text("WantTextInput: %s", BoolStr(io.WantTextInput));
704707
}
705708

709+
if (ImGui::CollapsingHeader("Save detection")) {
710+
ImGui::Text("Last in-game save/load: %0.1f seconds ago", SecondsSinceLastGameSave());
711+
ImGui::Text("Last save/load state: %0.1f seconds ago", SaveState::SecondsSinceLastSavestate());
712+
}
713+
706714
ImGui::End();
707715
}
708716

UI/ImDebugger/ImDisasmView.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImContro
12051205
ImGui::Text("Step: ");
12061206
ImGui::SameLine();
12071207

1208-
if (ImGui::SmallButton("Into")) {
1208+
if (ImGui::RepeatButtonShift("Into")) {
12091209
u32 stepSize = disasmView_.getInstructionSizeAt(mipsDebug->GetPC());
12101210
Core_RequestCPUStep(CPUStepType::Into, stepSize);
12111211
}
@@ -1239,12 +1239,6 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImContro
12391239
Core_Resume();
12401240
}
12411241

1242-
ImGui::SameLine();
1243-
if (ImGui::RepeatButton("Skim")) {
1244-
u32 stepSize = disasmView_.getInstructionSizeAt(mipsDebug->GetPC());
1245-
Core_RequestCPUStep(CPUStepType::Into, stepSize);
1246-
}
1247-
12481242
ImGui::EndDisabled();
12491243

12501244
ImGui::SameLine();

Windows/EmuThread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ void MainThreadFunc() {
300300
while (GetUIState() != UISTATE_EXIT) { // && GetUIState() != UISTATE_EXCEPTION
301301
// We're here again, so the game quit. Restart Run() which controls the UI.
302302
// This way they can load a new game.
303-
if (!Core_IsActive())
303+
if (!(Core_IsActive() || Core_IsStepping()))
304304
UpdateUIState(UISTATE_MENU);
305305
Core_StateProcessed();
306306
NativeFrame(graphicsContext);

0 commit comments

Comments
 (0)