Closed Wulf2k closed 6 years ago
Thanks for bringing this to our attention, will take a look when I get a chance.
A lot of the Lua utilities are "legacy" code from the original spike of pcsx2-rr https://github.com/pocokhc/pcsx2-1.4.0-rr/releases if you get a chance, can you see if the feature works as expected on the latest release there, that way it will be obvious if this was the fault of a refactor along the way or if this was always broken.
LUA doesn't seem to work at all for me in that version.
At least, the following code doesn't seem to do anything. I click Start and nothing happens.
function draw() gui.text(50, 50, memory.readbyte(0x795978, "r5900"), "magenta") gui.text(50, 70, memory.readbyte(0x795978, "r3000"), "magenta") end
emu.registerbefore(draw)
Ah ok, well glad to hear that its working more than it isnt! Perhaps just a simple bug, or it never even worked in the first place.
I assume that the values should correspond to whatever is in PCSX2's debug window?
I'm not 100% sure what you mean, so I'll clarify to be sure we mean the same thing.
When I open the Debugger window and go to 0x795978 with "r5900" selected, I get 0x42C80000 (float, 100.0, current HP of Kratos in God of War, reading floats is a side issue, reading it as DWORD is a first step). This is what I'm trying to read with memory.readdword(0x795978, "r5900")
If I click "r3000", I get the hex representation of whatever is displaying in decimal form on the screen.
The above code is returning the valid answer for memory.readdword(0x795978, "r3000")
In the below code segment of LuaFunctions:
static int memory_readdword(lua_State *L) { wxString cpu = luaL_checkstring(L, 2); DebugInterface &mem = r3000Debug; if (cpu == "r5900") { mem = r5900Debug; } unsigned long address = luaL_checkinteger(L, 1); lua_pushinteger(L, mem.read32(address)); return 1; }
It would seem that cpu is not properly being assigned the "r5900" argument.
This is just an assumption as I've run into some issues compiling it myself that I haven't worked through yet.
Let me know what other information you need.
Yup, the issue was around that code. The &mem
reference variable was not being changed after initialization. https://github.com/xTVaser/pcsx2-rr/pull/3/files#diff-b167c498523fe7825f66fdcff309c273
I believe we are on the same page and I was able to reproduce and fix your problem, but take a look at these screenshots and let me know if I'm correct.
There should definitely be some added functions for dealing with floats / doubles, and it would be nice if there could be a small sample lua script. I wasn't able to get gui
drawing to work properly so I just used the console (i tried both the 1.4.0 version and the 1.5.X versions), if you could provide some sample code to get that working that would be helpful.
There was some sort of sample LUA that handled GUI drawing already in the LUA folder, so I'd just taken out the shape-drawing stuff and repurposed the text-drawing lines.
I can get you the exact script I used in about 7 hours if you still need it.
The above image does appear to be showing the expected behaviour, which I would be unable to reproduce with my current build.
changes released https://github.com/xTVaser/pcsx2-rr/releases/tag/rr-1.0.1
give it a try and close the issue if the problem is correctly resolved.
I should be able to confirm and close in about 4 hours.
The same script now returns different (assumed correct) results.
Closing.
PCSX2 version: 1.4.0
local m = memory.readdword(0x795978, "r5900");
It is returning the value at 0x795978 on the R3000 regardless of the string entered.