Save Point
- ..
- .metadata17 B
- README.md1.4 KB
- cart.luau5.7 KB
- init.luau17.3 KB
- state.luau3.0 KB
- vdp.luau20.5 KB
- ym2612.luau24.8 KB
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)
| file | what |
|---|---|
init.luau | memory map, I/O pads (TH protocol), Z80 BUSREQ/RESET/bank, SRAM, TMSS, scheduler, V-int/H-int |
vdp.luau | VDP ports, DMA (68k/fill/copy, CPU stall), status/HV, line renderer (planes, window, sprites, scroll modes, shadow/highlight, H32/H40) |
ym2612.luau | YM2612 sample-level FM: 6 ch, DAC, CSM, LFO, SSG-EG, timers; mixes the PSG; 44.1 kHz stereo out |
cart.luau | raw/SMD/zip loader and header (title, SRAM window) |
state.luau | save-state codec |
The 68000, Z80 and zip reader come from the Neo Geo package (neogeo.machine.m68k, .z80, .zip).