Replies: 1 comment 1 reply
-
I probably need to augment the Lua API a bit with some more information. Most or all of this could be built using the ImGui + PCSX Lua API, really. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The freeze commands change the state of the target memory from "not frozen" to "frozen".
When a byte is frozen then all the
sb
instructions that will write to this byte are totally ignored and won't be executed at all or be temporarily treated like anop
instruction until thesb
instructions will write to other byte in memory that is not frozen.When a half is frozen then all the
sh
instructions that will write to this half are totally ignored and won't be executed at all or be temporarily treated like anop
instruction until thesh
instructions will write to other half in memory that is not frozen.When a word is frozen then all the
sw
instructions that will write to this word are totally ignored and won't be executed at all or be temporarily treated like anop
instruction until thesw
instructions will write to other word in memory that is not frozen.Another definition of "frozen memory" is about how the read instructions are interpreted or treated instead of write instructions.
In the second definition:
When the PC encounters a
lb
orlbu
instruction and thislb
orlbu
instruction is going to read a frozen byte then the value of the operand register is going to be the value of the referenced byte when the referenced byte became frozen and not the current value of the referenced byte.When the PC encounters a
lh
orlhu
instruction and thislh
orlhu
instruction is going to read a frozen half then the value of the operand register is going to be the value of the referenced half when the referenced half became frozen and not the current value of the referenced half.In other words all the
lbu
andlhu
instructions are temporarily treated like ali
(ori $OutReg, $r0, 0x....
) instruction and thelb
andlh
instructions are temporarily treated like ali
(eitheraddi
,addiu
,subi
orsubiu $OutReg, $r0, 0x....
) (which the Assembly of PCSX-Redux shows as amove
instruction whose source operand is an immediate) whose immediate operand is the value of the referenced byte or half when the byte or half became frozen until other byte or half that is not frozen is read.When the PC encounters a
lw
instruction and thislw
instruction is going to read a frozen word then the value of the operand register is going to be the value of the referenced word when the referenced word became frozen and not the current value of the referenced word.In other words all the
lw
instructions are temporarily treated like alui
andori
instructions whose immediate operands is the high and low halfs of the referenced word when the word became frozen until other word that is not frozen is read.The two definitions of frozen memory are in fact two different ways to implement the freeze commands but the first definition of frozen memory is the best and more preferable than the second definition in my opinion.
Right now PCSX-Redux users have to add a write breakpoint at the address of the byte, half or word that the user wants to freeze and replace all
sb
,sh
andsw
instructions that writes to this byte, half or word with anop
instruction as an inconvenient workaround and this is still bad because the game pauses AFTER thesb
,sh
orsw
instruction was executed and NOT before which also must be fixed in a future build and release of PCSX-Redux!Using the freeze context menu commands of the memory editor will be much more convenient for PCSX-Redux users and the executable code of the game doesn't have to be modified at all which means that this is much more safe to use the freeze context menu commands than the mentioned workaround above.
Also sometimes this is dangerous to replace a
sb
,sh
orsw
instruction with anop
instruction because thissb
,sh
orsw
instruction may write to more than one address and this can be many different memory addresses.Replacing a
sb
,sh
orsw
instruction with anop
instruction might affect all the memory addresses that thissb
,sh
orsw
instruction writes to and this might break the game and require a load state to fix this or even worse a soft reset or hard reset if save state was not used at all.This is exactly the same when using read breakpoints instead and then replacing all
lbu
andlhu
instructions with ali
(ori $OutReg, $r0, 0x....
) andlb
,lh
andlw
instructions with ali
(eitheraddi
,addiu
,subi
orsubiu $OutReg, $r0, 0x....
), which the Assembly of PCSX-Redux shows as amove
instruction whose source operand is an immediate, and this workaround won't work in cases the immediate operand of theli
instruction has to be bigger than0xFFFF
!If in the Memory Editor the user right clicks a byte that is already frozen then "Unfreeze this byte" appears instead of "Freeze this byte".
If in the Memory Editor the user right clicks a half that is already frozen then "Unfreeze this half" appears instead of "Freeze this half".
If in the Memory Editor the user right clicks a word that is already frozen then "Unfreeze this word" appears instead of "Freeze this word".
The unfreeze commands simply undo the freeze commands and change the state of the target memory from "frozen" to "NOT frozen".
The initial state of the entire memory is "NOT frozen" obviously when booting any game or rom.
Also all bytes, halfs and words that are frozen draw them in blue or cyan colors in the Memory Editor of PCSX-Redux so the user knows what memory is frozen and remains unchanged and what memory is not frozen.
Optionally you can add a new window to the Debug menu that shows all frozen addresses and their size (either Byte, Half or Word) and the ability to add a new address to freeze it and remove an existing address to unfreeze it.
To both Memory Observer and the Watch window suggested in https://github.com/grumpycoders/pcsx-redux/discussions/1071 you can add a fourth column with a button to freeze/unfreeze the address if you want.
To make the freeze commands working the interpreter must be used until breakpoints will work with recompiler one day.
The freeze feature can also be implemented the same way that Cheat Engine, DuckStation and BizHawk already do: Constantly and repeatedly write a given constant value at the frozen address but I don't like this implementation at all because this unnecessarily creates burden on the CPU and make the CPU more busy and cause other applications to take more time to respond to their user especially if the user of this feature freezed a lot of different memory addresses.
Syscalls, like or such as reading a file from disk to RAM, that also modify game memory must also be addressed and be taken into account and consideration and be interpreted in such a way so that the frozen memory and all values of the frozen addresses do not change at all.
Beta Was this translation helpful? Give feedback.
All reactions