MAMEWorld Central >> EmuChat
Previous thread Previous  View all threads Index   Next thread Next   Flat Mode Flat  

Jfarro
MAME Fan
Reged: 02/24/14
Posts: 8
Send PM
Seeking info on making a mame plugin (mem:read_u8 over TCP/IP)
11/02/17 10:35 AM


A while ago I wrote a hack into UME's debug on a custom compile which allowed me to read memory, and then send it over TCPIP to a client every so many milliseconds. This allows for some incredible extensibility...I could, for instance, tell what character someone selected in MK, and list the moveset. I could put up maps of Zelda or Atari 2600 Adventure, and overlay where the person was on those maps (and then overlay the secrets for the Zelda one). I had dozens of ideas, but I wanted to release it in a way the community could build upon it. The hack I did into mame's source was sloppy, hurt perf, and required running under the debugger.

With the LUA plugins, I've been meaning to revisit this, and finally did. I have a basic proof of concept working, as far as I can get the memory address of the NES Zelda locations. My next step is to dump those off, ideally, to another application which would do the heavy lifting of the map display and such. Ideally I'd just have the LUA plugin in mame send the data over TCP/IP to my client, which could be on the same box or another. This technique could also be used for remote debugging.

Here's my challenge...I'm a bit of a LUA noob (though I learn fast). I want to import the socket library, but it appears that the version of LUA that is included with Mame doesn't have it (or I'm doing it wrong). Any LUA experts out there got a sec to help me out?

From the LUA console, I'm trying to call:
local socket=require("socket")

The error I'm getting back is:
error: plugins/socket.lua:13: module 'socket.core' not found:
no field package.preload['socket.core']
no file 'plugins/socket\core.lua'
no file 'plugins/socket\core/init.lua'
no file 'C:\Users\Joe\OneDrive\Mame91\socket\core.dll'
no file 'C:\Users\Joe\OneDrive\Mame91\..\lib\lua\5.3\socket\core.dll'
no file 'C:\Users\Joe\OneDrive\Mame91\loadall.dll'
no file '.\socket\core.dll'
no file 'C:\Users\Joe\OneDrive\Mame91\socket.dll'
no file 'C:\Users\Joe\OneDrive\Mame91\..\lib\lua\5.3\socket.dll'
no file 'C:\Users\Joe\OneDrive\Mame91\loadall.dll'
no file '.\socket.dll'


I'm following code from:
http://w3.impa.br/~diego/software/luasocket/tcp.html#receive

For those curious of what this would look like, or want to see the beginning of it, launch zelda with the -console option to bring up the lua console. Then start the game, and type:

print("x: " .. mem:read_u8(0x0070) .. " y: " .. mem:read_u8(0x0084))


You'll see your location on the screen in x/y.

If you type:
print("map location: ",string.format('%x',mem:read_u8(0x00Eb)))


you'll see 77...this means your 7 spaces 'down' and 7 over...this is hex, you can actually use mem:write_u8 to write in a new hex value (It wont kick in till you try to go to the next screen..but it does wonky stuff).

If I can read that out over TCP/IP, I can show an interactive map. Almost like the Microsoft Smartglass promised for xbox back in the day. I had this working, as I stated, back in the day, but I want to 'ship it' to the community.

My command line to start mame with the proper lua console was:

mame -plugins -console nes -cart [path to Zelda rom]

Thanks in advance for any help you can provide!







Entire thread
Subject Posted by Posted on
* Seeking info on making a mame plugin (mem:read_u8 over TCP/IP) Jfarro 11/02/17 10:35 AM
. * Re: Seeking info on making a mame plugin (mem:read_u8 over TCP/IP) Jfarro  11/09/17 11:46 AM
. * Re: Seeking info on making a mame plugin (mem:read_u8 over TCP/IP) crazyc  11/09/17 08:35 PM
. * Re: Seeking info on making a mame plugin (mem:read_u8 over TCP/IP) Jfarro  11/10/17 11:21 AM
. * Re: Seeking info on making a mame plugin (mem:read_u8 over TCP/IP) Jfarro  11/22/17 04:51 AM
. * Re: Seeking info on making a mame plugin (mem:read_u8 over TCP/IP) Dullaron  11/22/17 03:27 PM

Extra information Permissions
Moderator:  redk9258, URherenow, Tafoid 
0 registered and 35 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 311