Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofpackage neogeo.package·originates fromworld 47b50fcd-5…

machine

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.

by◐Deata·posted 3d ago
What it does

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).

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

native

fromSet(set: ?, opts: ?) → void

Build a machine from a romset table (see romset.luau).

argtypedescription
set?
opts?

mapFixed( ) → void

mapBank( ) → void

updateIrq( ) → void

loadTimer( ) → void

lspcModeRead( ) → void

ioRead16(a: number) → number

I/O

argtypedescription
anumber

catchUp(toLine: number) → void

argtypedescription
toLinenumber

systemLatch(a: number) → void

argtypedescription
anumber

lspcWrite(r: number, v: number) → void

argtypedescription
rnumber
vnumber

soundCommand(v: number) → void

argtypedescription
vnumber

ioWrite(a: number, v: number, size: number) → void

argtypedescription
anumber
vnumber
sizenumber

read16(a: number) → number

argtypedescription
anumber

read8(a: number) → number

argtypedescription
anumber

write16(a: number, v: number) → void

argtypedescription
anumber
vnumber

write8(a: number, v: number) → void

argtypedescription
anumber
vnumber

reset( ) → void

mapZ80(s: ?) → void

argtypedescription
s?

read(a: number) → number

argtypedescription
anumber

write(a: number, v: number) → void

argtypedescription
anumber
vnumber

input(port: number) → number

argtypedescription
portnumber

output(port: number, v: number) → void

argtypedescription
portnumber
vnumber

checkNmi(self: ?) → void

argtypedescription
self?

reset(self: ?) → void

argtypedescription
self?

new(gameZip: string, extras: { bios: string? }?) → void

Build from the player's zips.

argtypedescription
gameZipstring
extras{ bios: string? }?

catchUp(self: ?, toLine: number) → void

frame Draw the lines scanned out so far that are not drawn yet, up to `toLine`.

argtypedescription
self?
toLinenumber

runFrame(self: ?, drawArg: boolean?) → void

`draw` (optional): false runs the frame without drawing it (the caller will not show it), true always draws it; nil draws unless the last frame overran.

argtypedescription
self?
drawArgboolean?

padToCnt(w: number) → number

input pad words: bit0 right, 1 left, 2 up, 3 down, 4 A, 5 B, 6 C, 7 D, 8 START, 9 SELECT

argtypedescription
wnumber

setPad(self: ?, p1: number, p2: number) → void

argtypedescription
self?
p1number
p2number

saveRam(self: ?) → string

saves

argtypedescription
self?

loadRam(self: ?, bytes: string) → void

argtypedescription
self?
bytesstring

voices(self: ?) → void

argtypedescription
self?

drainAudio(self: ?) → void

YM2610 output since the last call: (buffer, frames) of 44100 Hz stereo f32

argtypedescription
self?

snapshot(self: ?) → string

argtypedescription
self?

restore(self: ?, data: string) → void

argtypedescription
self?
datastring

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.