NAME
gb, gba, nes, snes – emulators

SYNOPSIS
games/gb [ –acd ] [ –C ... ] [ –x scale ] [ –li addr ] romfile
games/gba [ –a ] [ –b biosfile ] [ –s savetype ] [ –g gpiotype ] [ –x scale ] romfile
games/nes [ –aos ] [ –x scale ] romfile
games/snes [ –ahms ] [ –x scale ] romfile

DESCRIPTION
Gb, gba, nes and snes are emulators for the Nintendo Game Boy and Game Boy Color (GB and GBC), Nintendo Game Boy Advance (GBA), Nintendo Entertainment System (NES), and Super Nintendo Entertainment System (SNES). They execute the romfile given as an argument. The z, x, a, s, q, w, return and shift keys correspond to B, A, Y, X, L1, L2, Start and Select, respectively. Other keys:
F1    Pause the emulator. If already paused it will step one video frame.
F5    Save the current state in gb.save / gba.save / nes.save / snes.save.
F6    Load the current state from gb.save / gba.save / nes.save / snes.save.
F12    Toggle the emulator's speedometer. It shows in the upper left, off–viewport corner, the ratio between the expected and observed time it took to draw 60 frames.
t     Toggle tracing of the emulator.
`     It uncaps the 60fps frame rate and lets emulation go as fast as possible.
Esc    Pause the emulator.
Del   Exit the emulator.

Command line options:
a    Enable audio output.
x    Scale the screen to a given factor regardless of the window's size.

gb options:
c    Run GBC roms in GBC mode and DMG (GB) roms in GBC's DMG compatibility mode.
d    Run GB roms in DMG mode. GBC–only roms will not run in this mode; others will run only in black & white.
Cnnnnnn,nnnnnn,nnnnnn,nnnnnn
Select a color palette. Has no effect on roms in color mode. The syntax is of the form –C ffffff,aaaaaa,555555,000000 (using HTML style rrggbb notation).
liaddr
These enable serial port connectivity emulation using the network. The –l flag configures the listening partner, whereas –i configures the dialing partner. The connection is established before the rom starts. Communication is synchronous, emulation will stall while waiting for the other partner.

gba options:
b    Location of the GBA BIOS file (required to operate the emulator). Default is /sys/games/lib/gbabios.bin.
s    Save format used by the original game. Valid formats are: eeprom4, eeprom64, sram256, flash512, flash1024. The number corresponds to the size, in kilobits, of the save file. By default, the emulator attempts to automatically detect the save format, but does not always succeed. Some roms require a specific
flash device id which may need to be set manually for them to work. Valid formats and corresponding ids are: flash512 (SST), flash512mx (Macronix 64K), flash512pan (Panasonic), flash512atm (Atmel), flash1024 (Macronix 128K), flash1024san (Sanyo).
g    GPIO hardware used by the original game. The only valid type currently is rtc (real time clock). By default, the emulator attempts to automatically detect the GPIO hardware using the game code found in the rom header.

nes options:
o    Hide the top and bottom eight pixels (overscan area), like a real television would.
s    Save contents of battery backed SRAM (used by some games for savegames) as a file (gb and snes automatically detect if this is needed).

snes options:
h    Override HiROM/LoROM detection: –h sets LoROM, –hh sets HiROM.
m    Enable mouse emulation using system mouse. Mouse button 1 (left button) engages the SNES left mouse button. Mouse button 3 (right button) engages the SNES right mouse button. Holding down mouse button 2 (middle button) disengages the SNES mouse entirely so that the Plan 9 cursor offset can be
adjusted to align with the SNES cursor.

Each of these emulators support the use of joysticks via joy(1). Nes also supports selecting the joystick for either player 1 or 2.

SOURCE
/sys/src/games/gb
/sys/src/games/gba
/sys/src/games/nes
/sys/src/games/snes

BUGS
You bet!
SRAM saving on the NES only functions when the –s option is used.
The SNES horizontal hires mode is supported only with –2 scaling.
All emulators assume a North American (i.e. NTSC) system. PAL games (and in some cases Japanese games) are not supported.
The serial link emulation has issues with desynchronization in timing dependent scenarios.

HISTORY
Gb first appeared in 9front (April, 2012).
Gba first appeared in 9front (September, 2014).
Nes first appeared in 9front (February, 2014).
Snes first appeared in 9front (March, 2014).