diff --git a/mamelink/README.md b/mamelink/README.md index 6c4e2b1..a004d42 100644 --- a/mamelink/README.md +++ b/mamelink/README.md @@ -5,7 +5,7 @@ A compatibility shim for Lucasfilm Games' "fastlink", using a MAME plugin to imp Run `make`. Assumes a POSIX-like environment. Works On My Machine, totally untested on anything besides Linux. ## Booting reno -Run `./start`. Assumes that `mame` is in the current path, with C64 ROMs installed. +Run `./start`. Assumes that `mame` is in the current path, with C64 ROMs installed. MAME will start, and you will probably need to press a key to start the emulated C64 booting. Once the C64 has completed startup, `reno` will automatically begin uploading, and when it is complete, you will see the command `SYS2122` automatically be entered into the emulator. After a few more seconds, Reno will start. ## How It Works It's a terrible, awful, very bad, no good hack, but it does the trick and should hopefully be portable, even to an enscripten-type browser environment. To send a command to the `mamelink` plugin, the `mamelink.c` library creates a file called `mameplugins/mamelink/linkin` with diff --git a/mamelink/down.c b/mamelink/down.c index 416bc41..de481cd 100644 --- a/mamelink/down.c +++ b/mamelink/down.c @@ -59,7 +59,7 @@ void sendAbsoluteSegments() { readbytes(count); printf("Segment: %4x-%4x\n", start, end); down(buf, count, start); - if (start == end) { + if (start == end && entryPoint == 0) { entryPoint = start; } } diff --git a/mamelink/mameplugins/mamelink/init.lua b/mamelink/mameplugins/mamelink/init.lua index 7ab5b01..01ead96 100644 --- a/mamelink/mameplugins/mamelink/init.lua +++ b/mamelink/mameplugins/mamelink/init.lua @@ -39,7 +39,8 @@ local function fastlink(bytein, byteout) end elseif command == 4 then -- jump local address = readword(bytein) - cpu.state["PC"].value = address + -- cpu.state["PC"].value = address + emu.keypost("SYS" .. tostring(address) .. "\n") else print("Unknown command: " .. tostring(command)) end @@ -47,9 +48,8 @@ local function fastlink(bytein, byteout) end local function is_booted() - local cpu = manager.machine.devices[":u7"] - local mem = cpu.spaces.program - return mem + -- wait for machine to be started, and allow 3 seconds for booting before accepting commands + return manager.machine.time:as_double() > 3 end function exports.startplugin() @@ -77,14 +77,14 @@ function exports.startplugin() io.outfile:write(string.char(byte)) end - print(coroutine.resume(link, bytein, byteout)) + assert(coroutine.resume(link, bytein, byteout)) emu.register_periodic(function() if not is_booted() then return end linkio.infile = io.open(infilename, "rb") if linkio.infile then linkio.outfile = io.open(pendingfilename, "wb") - print(coroutine.resume(link)) + assert(coroutine.resume(link)) linkio.infile:close() linkio.infile = nil linkio.outfile:close()