Skip to main content

A terminal frontend for gambatte game boy color emulator

Project description

gambatte-terminal

A terminal front-end for gambatte, the gameboy color emulator.

It supports:

  • 16 colors, 256 colors and 24-bit colors terminal
  • Playing audio from the emulator
  • Using TAS input files as game input
  • Using keyboard presses as game input

Installation

Wheels are available on linux, windows and macos for python 3.6, 3.7, 3.8 and 3.9:

$ pip3 install gambaterm

Usage and arguments

Usage:

usage: gambaterm [-h] [--input-file INPUT_FILE] [--frame-advance FRAME_ADVANCE] [--break-after BREAK_AFTER] [--speed-factor SPEED_FACTOR] [--force-gameboy]
                 [--skip-inputs SKIP_INPUTS] [--cpr-sync] [--disable-audio] [--color-mode COLOR_MODE]
                 ROM

Positional arguments:

  • ROM

    Path to a GB or GBC rom file

Optional arguments:

  • --input-file INPUT_FILE, -i INPUT_FILE

    Path to a bizhawk BK2 input file

  • --frame-advance FRAME_ADVANCE, --fa FRAME_ADVANCE

    Number of frames to run before displaying the next one (default is 1)

  • --break-after BREAK_AFTER, --ba BREAK_AFTER

    Number of frames to run before forcing the emulator to stop (doesn't stop by default)

  • --speed-factor SPEED_FACTOR, --sf SPEED_FACTOR

    Speed factor to apply to the emulation (default is 1.0 corresponding to 60 FPS)

  • --force-gameboy, --fg

    Force the emulator to treat the rom as a GB file

  • --skip-inputs SKIP_INPUTS, --si SKIP_INPUTS

    Number of frame inputs to skip in order to compensate for the lack of BIOS (default is 188)

  • --cpr-sync, --cs

    Use CPR synchronization to prevent video buffering

  • --enable-controller, --ec

    Enable game controller support

  • --disable-audio, --da

    Disable audio entirely

  • --color-mode COLOR_MODE, -c COLOR_MODE

    Force a color mode (1: 4 greyscale colors, 2: 16 colors, 3: 256 colors, 4: 24-bit colors)

SSH server

It is possible to serve the emulation though SSH, although clients won't be able to send input to the emulator without an X server and the ssh -X option. Use gambaterm-ssh --help for more information.

Terminal support

Not all terminals will actually offer a pleasant experience. The main criteria are:

  • Support for basic ANSI codes (VT100) More specifically setting background/foreground colors and moving cursor (absolute and relative). Those are usually supported.

  • Support for at least 256 colors Those are usually supported. 16 colors also works but it doesn't look too good. In this case, it might be better to use greyscale colors using --force-gameboy or --color-mode=1.

  • Support for UTF-8 and good rendering of unicode block elements More specifically the following characters ▄ █ ▀. Also, the alignement might be off (e.g small spaces between pixels) This is not always well supported.

  • Good rendering performance The terminal has to be able to process about 500KB of requests per seconds for a smooth rendering of "intense" frames. Typically, the most intense frames happen during screen transitions of two detailed scenes.

The table below sums up my findings when I tried a the most common terminal emulators. Here's about linux:

Linux Status Colors Unicode rendering Performance Comments
Gnome terminal Excellent 24-bit colors Good 60 FPS
Terminator Excellent 24-bit colors Good 60 FPS
Kitty Excellent 24-bit colors Good 60 FPS
XTerm Good 24-bit colors Good 60 FPS No resize shortcuts
Termit Ok 24-bit colors Good 60 FPS No window title
Rxvt Ok 256 colors Good 60 FPS No resize shortcuts
Mlterm Ok 24-bit colors Light misalignments 60 FPS No resize shortcuts
Terminology Ok 24-bit colors Possible misalignments 30 FPS Weird colors

About MacOS:

MacOS Status Colors Unicode rendering Performance Comments
iTerm2 Good 24-bit colors Good 30 FPS
Terminal Unplayable 256 colors Misalignments 20 FPS

About Windows:

Windows Status Colors Unicode rendering Performance Comments
Windows terminal Unpleasant 24-bit colors Good 30 FPS Buggy display
Cmder Unplayable 24-bit colors Good 2 FPS No window title
Terminus Unplayable 24-bit colors Misalignments 10 FPS
Command prompt Broken N/A N/A N/A No ANSI code support
Git bash Broken N/A N/A N/A Doesn't work with winpty

Terminal size

The emulator uses a single character on screen to display two vertically aligned pixels, like so ▄▀. The gameboy being 160 pixels wide over 144 pixels high, you'll need your terminal to be at least 160 characters wide over 72 characters high to display the entire screen. Setting the terminal to full screen is usually enough but you might want to tweak the character size, typically using the ctrl - / ctrl + or ctrl wheel shortcuts.

Keyboard, game controller and file inputs

Keyboard controls are enabled by default, while game controller controls have to be enabled using --enable-controller or --ec. The key bindings are not configurable at the moment:

Buttons Keyboard Controller
Directions Arrows Left hat / Left stick
A F / V / Space Button 0 / Button 3
B D / C / Alt Button 1 / Button 2
Start Right Ctrl / Enter Button 7
Select Right Shift / Delete Button 6

Key releases, which are usually mandatory to play games, cannot be detected through stdin. It is then required to access the window system to get access to the key presses. There are a couple of problems with that:

  • It can be hard to detect the window corresponding to the terminal. With X11, the best solution is to look for the current focused window. For other systems, the fallback solution is to use global hotkeys.

  • It only works through SSH for clients with X servers using ssh -X, meaning it requires Windows and MacOS users to run an X server. Moreover, it's a bad idea to connect with -X to an untrusted server.

  • Additional permissions might be required to access the window system, especially on MacOS (see this guide)

It is also possible to use a bizhawk BK2 input file to play tool-assisted speedruns using the --input-file (or -i) option.

Motivation

To be honest there is no actual reason to use this gameboy emulator, other than you might find it fun or interesting. The motivation behind this project is simply to push the idea of running a video game console emulator in a terminal as far as possible. It seems like there has been a similar attempt that used a different approach for displaying the video stream. In any case I'm quite satisfied with this project, and also a bit surprised that I could push it to the point where playing games is actually enjoyable. In particular, I've been able to complete The Bouncing Ball at 60 FPS in XTerm, and I'm now looking forward to playing more homebrew games :)

Dependencies

Here is the list of the dependencies used in this project, all great open source libraries:

Contact

Vincent Michel

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gambaterm-0.12.4.tar.gz (143.9 kB view details)

Uploaded Source

Built Distributions

gambaterm-0.12.4-cp312-cp312-win_amd64.whl (193.1 kB view details)

Uploaded CPython 3.12 Windows x86-64

gambaterm-0.12.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

gambaterm-0.12.4-cp312-cp312-macosx_10_9_x86_64.whl (237.9 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

gambaterm-0.12.4-cp311-cp311-win_amd64.whl (192.2 kB view details)

Uploaded CPython 3.11 Windows x86-64

gambaterm-0.12.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

gambaterm-0.12.4-cp311-cp311-macosx_10_9_x86_64.whl (236.7 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

gambaterm-0.12.4-cp310-cp310-win_amd64.whl (192.2 kB view details)

Uploaded CPython 3.10 Windows x86-64

gambaterm-0.12.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

gambaterm-0.12.4-cp310-cp310-macosx_10_9_x86_64.whl (236.7 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

gambaterm-0.12.4-cp39-cp39-win_amd64.whl (192.8 kB view details)

Uploaded CPython 3.9 Windows x86-64

gambaterm-0.12.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

gambaterm-0.12.4-cp39-cp39-macosx_10_9_x86_64.whl (237.6 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

gambaterm-0.12.4-cp38-cp38-win_amd64.whl (193.4 kB view details)

Uploaded CPython 3.8 Windows x86-64

gambaterm-0.12.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

gambaterm-0.12.4-cp38-cp38-macosx_10_9_x86_64.whl (238.2 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

gambaterm-0.12.4-cp37-cp37m-win_amd64.whl (193.8 kB view details)

Uploaded CPython 3.7m Windows x86-64

gambaterm-0.12.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

gambaterm-0.12.4-cp37-cp37m-macosx_10_9_x86_64.whl (239.5 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

Details for the file gambaterm-0.12.4.tar.gz.

File metadata

  • Download URL: gambaterm-0.12.4.tar.gz
  • Upload date:
  • Size: 143.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for gambaterm-0.12.4.tar.gz
Algorithm Hash digest
SHA256 0ae5a433ea61d33e41a8df22d4ddfc50159b624c46afea25da1125ee09d0157a
MD5 e330dab89385793730cc9f89f6347835
BLAKE2b-256 6b549aaca7662a4330486b84302bf252a4c66e16509abc91208f757bc987f88e

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for gambaterm-0.12.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 afed521cfc34d3ddaba3951c3993a834359ba67052d2e21fb8faef929fa77403
MD5 1eae4b9e19f5e46fd2fb24524ab9b819
BLAKE2b-256 6880b2992a31484f6658d6185d2e93a85a6e4c0d520183556abca2db8db00df8

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.12.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0336b5279bda87df964d88356d9bd1945ab1ecf981ae2361097b8e7da5759950
MD5 48e116938985a81e74f6ae26005572e6
BLAKE2b-256 09f8174f2acba49c1abbbf3ebe54ed3304c0ac5956b45802d055e420d8e69429

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.12.4-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 958b22f00a19e4169b71f58dc265f31cbc7b1879d9727d590e994d91cd4d456d
MD5 708aa3d99f326fe4c28f1039276c5db5
BLAKE2b-256 c81f8c4d279becd7b8e714b27f5d1d09f9f2683d6dbcc8e5a62e3db442da1d2c

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for gambaterm-0.12.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1df83ccc82a63076b349b54ca6d8b0c0638b8f5b9cfe5405a015c24be9ae5a96
MD5 06189808b1b582c9ec8de8fedac3f8fa
BLAKE2b-256 5757700afffe69564036285208f7daee11ced9c89c40fe112e7f12d8dcde88ae

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.12.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7140dbd8c303f2da287dcc7b6b8f8e10f7fd5ab2b30caf61428321188c7b4c86
MD5 c5c9cdd3d4b549d871eb021c73b4b1d8
BLAKE2b-256 fff4d135d01369d4e74eab6696e8177f131363a16430c107ad1682165b2525ba

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.12.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6c8ca59d96e0b9b55c80dee3e6e7404c9df1fa4b3272d83614f72ff7f35acfa1
MD5 18c2b9761b3d907c4db7fb144bc8688c
BLAKE2b-256 28ca076be91777f5c4b7cd4bd4fd1eba392228158307a08ad24f0927840918a9

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for gambaterm-0.12.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 37c2427ae2658b937a071076deaef2f94abf6c403b8d1f2a4e57d423c29007f5
MD5 b4a6628fc7015567853050c0ea4e8cb1
BLAKE2b-256 a4eaec1d752155bde6355871b522f9bd1fbb73b26e63eff4c4ea714057fbfeda

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.12.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6ca92214c657059be9a0a2b8696de2ad91751279196e153c7fb7c4dd2067f5f2
MD5 b4c1998202e778c0544d78c446b48c0b
BLAKE2b-256 767739a54a770dbf5e7ffe250cc3d23fbb361b64f71c3915b53428860c81e3a5

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.12.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 370da023fcfdd712c533f6c8317082a549f6c04822b2cbf1d45be3261b9729cd
MD5 b3fc0d974aecd56f2d8c49b5fc79beb0
BLAKE2b-256 53a2d8416708520ebf45bf09e83e43a0df15c2c102e1a10fc758c26463e9071f

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: gambaterm-0.12.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 192.8 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for gambaterm-0.12.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6b21fa3fa32140c88d7bf19aa898ac4952845b98b655e2ddad2a7b51b028cefe
MD5 6b0d857aeae98ca3c2c5f6ccdd8685d0
BLAKE2b-256 65d277fd291c3fae55f2df45aacbfce132ae1e4caec1acb0bda777780b6e445e

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.12.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5e198e94b4a1ce4efc40b1c46394385bbc3d10d41a5037e88690744c81ba2535
MD5 3d8c4a41763f3127d525feaae3aafa1c
BLAKE2b-256 d5ba052c104cd1ab59c5d39f3d2bc698bb371c53b6c504e1071ecc61954220d3

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.12.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 661cb3aa38dde09b89fee002fa0d9c12968a1664ab0fc76f4f05ace9deb7a361
MD5 6946a09c830786f59fd71451c78a7d5d
BLAKE2b-256 2d9ebcbf71d9424e9f6ad7267ca7c82e81707a3bb87f253eb63487211386d2ee

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: gambaterm-0.12.4-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 193.4 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for gambaterm-0.12.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 54b2ba7b5df87067403ad18ebb97a7597a674dceeeafded57b466d17db4b1181
MD5 73b5544a43e37a35bb8a79d090f0f3d0
BLAKE2b-256 e653908ec6618bdb7b599222b22334cc333442e9e5d18f4e290127f5f3d8fac4

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.12.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 96a151222a5d34fc01b34b077bc36a41cfc69f0f2f5a9857c4a24e85bc56a995
MD5 3e9789ae26c1414512b62af48e19fc80
BLAKE2b-256 e139c36ba00617ef680711e25642e3bc8f2fd33e67fbd7a807c729bfc5a3bb8c

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.12.4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9c74ab47c8bb492e68594cc1a8029030052a0e6600cf224575d671b5a9512524
MD5 51d72e5e5be9aa69b241909d1f8ee1f7
BLAKE2b-256 9ce491f88c53a792b72a51d3f65623d87fdfd572872d062fee33788f726308ea

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for gambaterm-0.12.4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 c1c714bb28846ca15dbb41c8718694312cb00a0bc1b071e12c2a07c0d8f9bbc4
MD5 5f2986db569b4308521e09d8d3735fd7
BLAKE2b-256 6e59a8bb348e2e6b6b3da5e6b0a025e74ded1e2a73e5c256d4c39b999406f31c

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.12.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 83df7dd01ed3dab6705ef4c81d8d68212fba0cb934716435ee45cec71bbd5c5b
MD5 187ea9d7e0907606d51c8baec1a8bcaa
BLAKE2b-256 9c466087aaeba7a106305cac1c5944b29561838699e09a85417a5e66a076deef

See more details on using hashes here.

Provenance

File details

Details for the file gambaterm-0.12.4-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.12.4-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 45eff8a27c8b12221c116793c78452b09a39b7f1882b24ec0a9c69cadd61204b
MD5 68999ac4df7d5d90f10555b046ad7589
BLAKE2b-256 debedf973f801d52760d1ee12bfaa730149382ac785804064e78cd99e0faa426

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page