Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LUA Readdword, CPU string being ignored #2

Closed
Wulf2k opened this issue Jan 11, 2018 · 9 comments
Closed

LUA Readdword, CPU string being ignored #2

Wulf2k opened this issue Jan 11, 2018 · 9 comments
Assignees

Comments

@Wulf2k
Copy link

Wulf2k commented Jan 11, 2018

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.

mem

@xTVaser
Copy link
Owner

xTVaser commented Jan 11, 2018

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.

@Wulf2k
Copy link
Author

Wulf2k commented Jan 13, 2018

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)

@xTVaser
Copy link
Owner

xTVaser commented Jan 13, 2018

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?

@Wulf2k
Copy link
Author

Wulf2k commented Jan 13, 2018

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.

xTVaser added a commit that referenced this issue Jan 13, 2018
@xTVaser
Copy link
Owner

xTVaser commented Jan 13, 2018

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.

image

image

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.

@Wulf2k
Copy link
Author

Wulf2k commented Jan 15, 2018

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.

@xTVaser
Copy link
Owner

xTVaser commented Jan 16, 2018

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.

@xTVaser xTVaser closed this as completed Jan 16, 2018
@xTVaser xTVaser reopened this Jan 16, 2018
@xTVaser xTVaser self-assigned this Jan 16, 2018
@Wulf2k
Copy link
Author

Wulf2k commented Jan 16, 2018

I should be able to confirm and close in about 4 hours.

@Wulf2k
Copy link
Author

Wulf2k commented Jan 16, 2018

The same script now returns different (assumed correct) results.

Closing.

@Wulf2k Wulf2k closed this as completed Jan 16, 2018
xTVaser added a commit that referenced this issue May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants