11 March 2016 - Forum Rules

Main Menu


Started by Hacker65xx, November 12, 2019, 03:53:04 PM

Previous topic - Next topic


I would like linked 2 emulators SNES by sharing/mirroring RAM

A method is with LUA script , What is the method ?
"Edit: An other method is with Angelscript , what is the method ?"



What kind of latency are you looking for here? Just some kind of shared inventory type thing, some kind of challenge mode that you just need to set up a start of level for or something more akin to actual play or system buses? 10 frames in a RPG probably is not going to do much but 10 frames in Tetris or some kind of co-op action game is likely killer. Is this a master-host affair or more of a shared thing where bother devices can do things to it? If it is shared you have to figure out what you want to do when two people do something at once (and in the case of shared inventory what the game might do if someone is sitting there contemplating using the last of something/all of something and the other in the meantime uses it and thus the game does not have it (easy enough to handle for a PC game you anticipate this for, less of something a dev 30 something years ago was thinking about handling in a potentially single player game).

Anyway don't know about angelscript and a quick search says it is a generic scripting language like we have a thousand others for, though it claims a small focus for games. Either way it will work the same as lua, which is also a scripting language. Lua just found itself in heavy use by various ROM hacking and tool assisted speedrun communities and thus baked into various emulators at some level (FCEUX probably being the reference standard here that most others compare themselves to, or use as a basis for things. Don't know what we are suggesting for SNES lua supporting emulators).

Two choices then
For the likes of lua then if the emulator supports it you need a way to export the memory and also import it into the other (and any other ways around it for a shared inventory). I will note that lua also gives options to pause emulation which might help with certain sync issues if you can get both emulators to pause, sync things and then carry on.

For everything else then you either need to force an export of memory or reach out and grab it from the program itself (all those cheat programs like emuhaste, artmoney, cheat engine and whatever else will be doing this, and hex editors also often handle it).
Forcing an export is not so bad if you don't have latency issues -- have the program force a savestate and what is a savestate if not a dump of memory, and speaking of memory dumps you might be able to do that. Make a savestate, slice out the relevant section and inject it back into the second emulator (possibly by having it make a savestate and injecting the data into that before loading it again).
Grabbing it from the program itself then. You will need to know where the emulator stores the console's memory within its program memory for this one (hence why those cheat programs often want specific versions or need you to fiddle with an ini file or something if you do want to use another). Normally it is in a fixed location but modern programming being what it is means I could see something more dynamic, don't think any emulators do anything with the likes of ASLR (a security measure some/many programs employ to randomise the memory) but I have been surprised in the past. Should be easy enough to find -- pause the game, do a savestate, find the same data from the savestate in a memory dump of the emulator you made with a hex editor, windows debugger or whatever else and you have an answer, close the program and launch it again and see if it is in the same location. Hopefully the savestates are not compressed or are easy to decompress.
Do also note a program looking at another program's memory tends to make anti virus programs get a bit freaky as it is only programmers debugging things, some cheat makers and malware writers that ever do that -- normal programming has other means of transmitting data between processes. Not so bad when it is just your machine you can ignore the antivirus program's paranoia for but can be harder to have normal people do, or demonstrate on other machines.

It is usually at points like this that people also start thinking of things they can do for specific games as far as things you can do to spice it up, or specific things you can share but leave others alone, but I will leave that for now.


For latence of shared/mirrored memory, is not a problem for 2 emulators for my project (but of course the least is the best for the gaming experience)