Log inGet started
Package

machine.module

Newest version

README.md

ng — Neo Geo machine core

The Neo Geo MVS/AES as Luau, one file per chip. neogeo_core.emulatorCore calls it; anything else that wants a Neo Geo can too.

local Ng = require("neogeo.machine")
local m = Ng.new(gameZipBytes, { bios = neogeoZipBytes })
m:runFrame()              -- one 59.185 Hz frame: 264 lines, 68000 + Z80 + timers
m.lspc.fb                 -- 320*224*4 RGBA8, row-major
m:setPad(p1, p2)          -- 10-bit words: right left up down A B C D START SELECT(=coin on MVS)
m:drainAudio()            -- YM2610 output since the last call: (buf, frames), 44.1 kHz stereo f32
m:saveRam() / m:loadRam(s)   -- MVS backup RAM (64 KB)
local s = m:snapshot()    -- whole-machine save state; m:restore(s)
filewhat
zip.luauzip central directory, DEFLATE (stored/fixed/dynamic), gzip, CRC-32
romset.luauMAME file roles by name (*.p1 *.s1 *.cN *.m1 *.vN, v1x/v2x), BIOS by priority, byte-order and half-swap detection for P ROMs, C-ROM pair interleave
m68k.luau68000: 65536-entry decoded closure table, full ISA, exceptions, autovectored IRQs, manual timings
z80.luauZ80: full ISA with undocumented flags/opcodes, IM 0/1/2, NMI, HALT
lspc.luauvideo: 381 sprites, sticky chains, H/V shrink (L0 ROM or derived), auto-animation, fix layer, 2×4096 palette, 96 sprites/line, per-line rendering, lazy C-ROM tile cache
ym2610.luauYM2610 sample-level: FM (8 algorithms, SSG-EG, LFO), SSG, ADPCM-A/B, timers A/B → Z80 IRQ, end flags, 44.1 kHz stereo mix
rtc.luauuPD4990A serial clock with TP pulse
snapshot.luausave states
init.luaumemory map, I/O, banking, system latches, watchdog, LSPC timer/VBlank IRQs, sound latches, scheduler, frame skip

Frame skip: when a frame takes longer than its 16.9 ms slot, the next frame runs without drawing (game speed is unaffected).

Sound: the YM2610 is emulated sample by sample at its native 55.5 kHz (4 FM channels with all 8 algorithms, feedback, DT/MUL, ADSR, SSG-EG, LFO AM/PM and channel-3 special mode; 3 SSG tones + noise + envelope; 6 ADPCM-A channels and ADPCM-B from the V-ROMs) and mixed to 44.1 kHz stereo f32 with a DC blocker and a 15 kHz low-pass. m:drainAudio() hands it to the host, which plays it through stations.pcmout (rate-matched to the audio stream). Metal Slug costs about 0.5 ms of chip time per emulated frame. Tests: luau /zero/source/neogeo.package/tests/ym2610_tests.luau (synthetic data only).