machine
The Sega Master System / Game Gear / SG-1000 machine (NTSC) as Luau: Z80 (`neogeo.machine.z80`), the SMS VDP (`vdp.luau`), SN76489 (`megadrive.psg`), cart loader and mappers (`cart.luau`), I/O and the line scheduler (`init.luau`).
mastersystem.machine
The Sega Master System / Game Gear / SG-1000 machine (NTSC) as Luau: Z80
(neogeo.machine.z80), the SMS VDP (vdp.luau), SN76489 (megadrive.psg),
cart loader and mappers (cart.luau), I/O and the line scheduler (init.luau).
local Sms = require("mastersystem.machine")
local m = Sms.new(cartBytes, { gg = false }) -- .sms/.gg/.sg or a zip of one
m:runFrame(true) -- one 59.92 Hz frame (262 lines x 228 T-states)
m.vdp.fb -- 256*192*4 RGBA8 (160*144 on a Game Gear)
m:setPad(p1, p2) -- station pad words: d-pad, A = button 1, B = button 2, Start = Pause / GG Start
m:drainAudio() -- (buffer, frames) 44.1 kHz stereo f32
m:saveRam() / m:loadRam(s) -- cartridge battery RAM
m:snapshot() / m:restore(s) -- save states
m:watchRam(addr) -- count a game's own logic-step counter
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2native
new(bytes: string, opts: any?) → void
| arg | type | description |
|---|---|---|
| bytes | string | |
| opts | any? |
setPage(slot: number, v: number) → void
| arg | type | description |
|---|---|---|
| slot | number | |
| v | number |
applyMapper( ) → void
psgWrite(v: number) → void
| arg | type | description |
|---|---|---|
| v | number |
padDC( ) → number
padDD( ) → number
onIrqChange( ) → void
reset(self: ?) → void
| arg | type | description |
|---|---|---|
| self | ? |
runFrame(self: ?, draw: boolean?) → void
one frame; draw = false runs it without drawing the picture
| arg | type | description |
|---|---|---|
| self | ? | |
| draw | boolean? |
watchRam(self: ?, addr: number, size: number?) → void
the game's own logic rate: a RAM byte/word it advances once per logic step
| arg | type | description |
|---|---|---|
| self | ? | |
| addr | number | |
| size | number? |
watchStep(self: ?) → void
| arg | type | description |
|---|---|---|
| self | ? |
toPad(w: number) → number
station pad words: bit0 right 1 left 2 up 3 down 4 A 5 B 6 C 7 D 8 Start 9 Select
| arg | type | description |
|---|---|---|
| w | number |
setPad(self: ?, p1: number, p2: number) → void
| arg | type | description |
|---|---|---|
| self | ? | |
| p1 | number | |
| p2 | number |
drainAudio(self: ?) → void
| arg | type | description |
|---|---|---|
| self | ? |
hasBattery(self: ?) → boolean
| arg | type | description |
|---|---|---|
| self | ? |
saveRam(self: ?) → string
| arg | type | description |
|---|---|---|
| self | ? |
loadRam(self: ?, s: string) → void
| arg | type | description |
|---|---|---|
| self | ? | |
| s | string |
snapshot(self: ?) → string
| arg | type | description |
|---|---|---|
| self | ? |
restore(self: ?, s: string) → void
| arg | type | description |
|---|---|---|
| self | ? | |
| s | string |
Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Showing up to 3 levels deep. Open a part to see what it holds further down.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ 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".
Scoped to this part · feeds back into the world's score.