emuworker
Runs an emulator core off the engine thread, on the `jobs` worker pool, so a console station's emulation costs the frame nothing. One machine per worker key: `ConsoleStation` dispatches `boot` once with the cartridge bytes (and the BIOS) under a key of its own, then `step` whenev…
emuworker
Runs an emulator core off the engine thread, on the jobs worker pool, so a console station's emulation costs the
frame nothing. One machine per worker key: ConsoleStation dispatches boot once with the cartridge bytes (and the
BIOS) under a key of its own, then step whenever the previous step settled, and releases the key when the cart comes
out.
A core opts in by naming the require path of its spec as workerModule in its emulatorCore (the Neo Geo does); a
core without it keeps running in the frame.
local key = "console:" .. stationId .. ":1"
jobs.dispatch("stations.emuworker", "boot", { core = "neogeo.neogeo_core", rom = romBytes, bios = biosBytes }, { key = key })
-- each tick once the last step settled (n = frames wall time owes, at most 5):
local p = jobs.dispatch("stations.emuworker", "step", { n = 2, p1 = padWord1, p2 = padWord2 }, { key = key })
-- p settles with { fb = buffer (RGBA, a copy), audio = buffer? (stereo f32), frames, n, ms } or { lost = true }
jobs.release(key)
Only the last frame of a step is drawn (drawControl cores); ms is the worker's time for the n frames.
Scoped to this part · feeds back into the world's score.