grumpycoders / pcsx-redux

The PCSX-Redux project is a collection of tools, research, hardware design, and libraries aiming at development and reverse engineering on the PlayStation 1. The core product itself, PCSX-Redux, is yet another fork of the Playstation emulator, PCSX.
https://pcsx-redux.consoledev.net
GNU General Public License v2.0
663 stars 108 forks source link

Breakpoints don't work at all with recompiler but only with interpreter #1028

Closed ghost closed 1 year ago

ghost commented 2 years ago

Describe the bug

I want to hack Castlevania Symphony of the Night. When beginning a new game Richter starts with 30 hearts. I managed to find the address of this quantity and I added a write breakpoint on this address.

When I collect new hearts or spend them by pressing triangle the PCSX-Redux does not break at all.

I viewed it in the breakpoints window and the write breakpoint is not disabled.

Is there something that I must do to make it work?

Expected behavior

PCSX-Redux must break when an address, where a write breakpoint was set, has been written.

In my example when Richter gets more hearts or spends hearts by pressing triangle the hearts address is written and the write breakpoint that I set should cause PCSX-Redux to break.

Steps to reproduce the bug

  1. Play Castlevania Symphony of the Night USA region with scph1001.bin as the bios
  2. Begin a new game. The name of the new game doesn't matter.
  3. Add a write breakpoint of width 4 at 80097BA8 (this is the hearts quantity address).
  4. Collect a heart or press triangle to spend them.
  5. PCSX-Redux should break but it doesn't.

Operating System

Windows 10

PCSX-Redux version

pcsx-redux-nightly-11147.20221106.5-x64

CPU model

Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz 3.70 GHz

GPU model

Nvidia GeForce GTX 950

BIOS version

SCPH1001.bin

CPU emulation mode

Recompiler

Additional information

I have said everything above

nicolasnoble commented 2 years ago

The debugger won't work properly with the dynarec enabled. Please turn it off and enable the debugger in the options.

ghost commented 2 years ago

The debugger won't work properly with the dynarec enabled. Please turn it off and enable the debugger in the options.

I configured PCSX-Redux to use interpreter but this slowed my system so much that I had to restart it.

nicolasnoble commented 2 years ago

Your machine is more than capable to run Redux in interpreter mode at more than full speed. Heck, my laptop can easily get above 60fps when debugging. Did you enable tracing by any chance? If yes, disable it.

ghost commented 2 years ago

Your machine is more than capable to run Redux in interpreter mode at more than full speed. Heck, my laptop can easily get above 60fps when debugging. Did you enable tracing by any chance? If yes, disable it.

Do you think that tracing slows down my system so much? If yes then how to disable it?

nicolasnoble commented 2 years ago

CPU Tracing is extremely taxing, but it should've been disabled by default. Maybe you've enabled it by mistake while trying to troubleshoot your root cause. Check the logs window, in the Special menu. This checkbox should be disabled.

Worst case scenario, you can reset Redux to its default settings by running it using the -safe command line option.

image

ghost commented 2 years ago

I don't see this logs window at all. Even the Special menu I don't see at all. I will try the -safe option that you suggest.

nicolasnoble commented 2 years ago

The Logs window is accessible from the main Debug menu:

image

ghost commented 2 years ago

The CPU trace was checked. I unchecked it. Hope that this will solve this problem. I don't know why it was checked. I never seen this logs window before I opened this issue.

nicolasnoble commented 2 years ago

Good :) Please try and report here.

ghost commented 2 years ago

Good :) Please try and report here.

I am going to play Castlevania Symphony of the Night again and I will let you know if all problems are solved.

EDIT:

I am playing Castlevania Symphony of the Night but the movies are not good. All the colors of all the pixels are not correct and I can't see the movies clearly but except movies the game runs flawlessly 60 FPS with correct colors.

Now I am going to try to use a write breakpoint and let's see if this is going to work on interpreter.

EDIT:

Alright! The write breakpoint is working now with interpreter! A pity that I can't change the instruction that the PC points at.

For a workaround I can use the change instruction of no$psx and use a memory editor of PCSX-Redux to change the instruction in PCSX-Redux. I must use this workaround until PCSX-Redux will have a change instruction feature.

But I still don't know why the movies are bad?

wheremyfoodat commented 2 years ago

@buruto Due to icache emulation or the recompiler caching executed code, sometimes changing an instruction with the memory editors might not work and the old code might keep being executed. This could be mitigated by either adding an option to flush the emulated CPU cache when the memory editor writes somewhere, or by adding a dedicated "flush cache" button in the GUI.

If you want to be able to assemble instructions by typing some MIPS code alq no$, that is probably coming eventually.

nicolasnoble commented 2 years ago

Regarding the movies being in the wrong color, did you enable the OpenGL renderer by any chance?

ghost commented 1 year ago

Regarding the movies being in the wrong color, did you enable the OpenGL renderer by any chance?

Yes I did.

ghost commented 1 year ago

@buruto Due to icache emulation or the recompiler caching executed code, sometimes changing an instruction with the memory editors might not work and the old code might keep being executed. This could be mitigated by either adding an option to flush the emulated CPU cache when the memory editor writes somewhere, or by adding a dedicated "flush cache" button in the GUI.

If you want to be able to assemble instructions by typing some MIPS code alq no$, that is probably coming eventually.

Changing MIPS instructions with the Memory Editor always worked for me while using the interpreter though.

ghost commented 1 year ago

I have solved it.