***EDIT***
Since I struck out with that idea, since bizhawk is c#, how can i connect to ram with a custom program? I get that I read the dlls. from the dll folder in bizhawk, but which one? i want to be able to read and poke ram in my program
I am interested in creating an experience like Super Mario 35 for Donkey Kong Country (DKC). Basically, the main goal of SM35 is to outlive opponents. defeating enemies sends them to other players. I got a working prototype. All I do is in-game, I store each object's pointer. When an enemy dies, I transfer that to a 'SendMessage" variable. Every frame, I check 'ReadMessage' (I know this can be simpler, but on a 20+ yr old game I'm not being picky) and spawn a new enemy if anything is in there. I wrote this basic script to mimic what would happen if I were both the sender and the receiver.
Language: lua
memory.usememorydomain("WRAM") -- just in case
local SentMessage = 0x18012 -- Send message in-game. Message to send from killing an enemy
local ToSend = 0x18010 -- Received message in-game. Send to a specific client
local function unsigned16(num) -- Fixes underflow problem
local maxval = 0x8000
if num >= 0 then
return num
else
return 2 * maxval + num
end
end
local function format_hex16(number)
return string.format('%4x', unsigned16(number))
end
while true do
local msg = memory.read_u16_le(SentMessage)
local asInt = tonumber(msg)
local asString = format_hex16(asInt) -- For debugging
if asInt ~= 0 then
memory.write_u16_le(ToSend, asInt) -- Assign new object to 'received'
memory.write_u16_le(SentMessage, 0) -- 0 'send'
console.writeline(asString)
end
emu.frameadvance()
end
A good chunk of the remaining work is programming the Lua backend. Unfortunately, I am pretty nooby when it comes to sockets. Can someone else walk me through socket programming in Lua, please? Again, I have it setup so the game automatically sends and reads a message via ram. Can someone please give me an example of how to send messages between clients? I don't need you to program this for me. Just an example will do. I can handle it from there!
EDIT***
I think i see... ip address is like street address. port is like the entrance/doors and windows (access paths)
So, ultimately, I would need 2 scripts, right? A server script and a client script?
***EDIT***
Since I struck out with that idea, since bizhawk is c#, how can i connect to ram with a custom program? I get that I read the dlls. from the dll folder in bizhawk, but which one? i want to be able to read and poke ram in my program