Log inGet started
World

Save Point

Branchmain
Branchesmain
Commit8937fc8d08

README.md

megadrive.machine

The Sega Mega Drive / Genesis machine (NTSC) as Luau, one file per chip. The megadrive_core.emulatorCore spec calls it; anything else that wants a Mega Drive can too.

local Md = require("megadrive.machine")
local m = Md.new(cartBytes)   -- .md/.bin/.gen, interleaved .smd, or a zip of one
m:runFrame(true)              -- one 59.92 Hz frame: 262 lines x 488 68000 cycles
m.vdp.fb                      -- 320*224*4 RGBA8 (H32 games centred)
m:setPad(p1, p2)              -- station pad words: d-pad, A B C, Start
m:drainAudio()                -- (buffer, frames) 44.1 kHz stereo f32 (YM2612 + PSG)
m:saveRam() / m:loadRam(s)    -- battery SRAM
m:snapshot() / m:restore(s)   -- save states
m:watchRam(addr)              -- count a game's own frame counter (logic-rate probe)
filewhat
init.luaumemory map, I/O pads (TH protocol), Z80 BUSREQ/RESET/bank, SRAM, TMSS, scheduler, V-int/H-int
vdp.luauVDP ports, DMA (68k/fill/copy, CPU stall), status/HV, line renderer (planes, window, sprites, scroll modes, shadow/highlight, H32/H40)
ym2612.luauYM2612 sample-level FM: 6 ch, DAC, CSM, LFO, SSG-EG, timers; mixes the PSG; 44.1 kHz stereo out
cart.luauraw/SMD/zip loader and header (title, SRAM window)
state.luausave-state codec

The 68000, Z80 and zip reader come from the Neo Geo package (neogeo.machine.m68k, .z80, .zip).