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 ▄ █ ▀. Changing the code page might be necessary on windows, using chcp 65001. 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 (chcp 65001) 30 FPS Buggy display
Cmder Unplayable 24-bit colors Good (chcp 65001) 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.9.9.tar.gz (139.8 kB view details)

Uploaded Source

Built Distributions

gambaterm-0.9.9-cp311-cp311-win_amd64.whl (162.7 kB view details)

Uploaded CPython 3.11 Windows x86-64

gambaterm-0.9.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

gambaterm-0.9.9-cp310-cp310-win_amd64.whl (163.7 kB view details)

Uploaded CPython 3.10 Windows x86-64

gambaterm-0.9.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

gambaterm-0.9.9-cp310-cp310-macosx_10_9_x86_64.whl (212.9 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

gambaterm-0.9.9-cp39-cp39-win_amd64.whl (163.7 kB view details)

Uploaded CPython 3.9 Windows x86-64

gambaterm-0.9.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

gambaterm-0.9.9-cp39-cp39-macosx_10_9_x86_64.whl (212.9 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

gambaterm-0.9.9-cp38-cp38-win_amd64.whl (163.3 kB view details)

Uploaded CPython 3.8 Windows x86-64

gambaterm-0.9.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

gambaterm-0.9.9-cp38-cp38-macosx_10_9_x86_64.whl (212.9 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

gambaterm-0.9.9-cp37-cp37m-win_amd64.whl (163.4 kB view details)

Uploaded CPython 3.7m Windows x86-64

gambaterm-0.9.9-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

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

gambaterm-0.9.9-cp37-cp37m-macosx_10_9_x86_64.whl (212.6 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

gambaterm-0.9.9-cp36-cp36m-win_amd64.whl (186.2 kB view details)

Uploaded CPython 3.6m Windows x86-64

gambaterm-0.9.9-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

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

gambaterm-0.9.9-cp36-cp36m-macosx_10_9_x86_64.whl (213.0 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: gambaterm-0.9.9.tar.gz
  • Upload date:
  • Size: 139.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for gambaterm-0.9.9.tar.gz
Algorithm Hash digest
SHA256 e6a03ffb9dda77eae76b23d8263d98d4de1d0b33660105e9766b447c83a7e852
MD5 a350c24f2cea662361e220362e2f5d39
BLAKE2b-256 49df3dd3936698ee4d6c0b032d9b50338c67d4b55051f2e0751a7b345ba8b3ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.9.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cab20f6404b01ed54816e9770f7218dcd6935c38e2053f399011ba34ce3b8b7f
MD5 7f48302b7f04ebd5cbbad4cc22b87836
BLAKE2b-256 65c7114f67187e31d823a2dceedc21084585385e1389402fd34e36f7fb69e74b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.9.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2cc3644e4038f3bb95875a334ee472d1fdd800eef9a6bee8a89d6f75022d83f2
MD5 f294cf5a6cd81b1d0d63439f61c6fa5d
BLAKE2b-256 47cdac09647d1ec8fb0360051ffb86078abc8347f8d429f2bd223a409d2ac81c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.9.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ab1bc1d91561292a6b48779b6b1232ddf1bd49ec9b9714e699f8e90de0f5d9dd
MD5 af99ddab15ca52c791c3fec6f74bd4a8
BLAKE2b-256 b9b3cca707c1e88904d25aec0601b4ebd033736ad1fd7761dbce6c2ce7f9ac64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.9.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e4d4d0b88e007a30b6ce7af8c3e68b5a5faf0a7c5fca72626818bb0cad582fb8
MD5 296611e4f0e7cc27e3acc22cfa6658db
BLAKE2b-256 547767fccceb1c2ac035c75bed72344d72de8e1c100c6f243c88b4fc7ae5e979

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.9.9-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 11640c689e23a07b82939373a4660c0d4217db3628d7a8cef167b78369f6b1d3
MD5 91d6f85c34daee3e6c5cc5072a0cc8de
BLAKE2b-256 5f802ce75621da67f69a2fad49a3535cd9e5a1d6b18a952ad3d81a9cb4078607

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gambaterm-0.9.9-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 163.7 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for gambaterm-0.9.9-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f4e61418eceec224873ddd54ef406e0649bfbe4def27e0e66a5ffc0475628e11
MD5 085f9b43f2286e388741c2ca0a86148c
BLAKE2b-256 052b18c9fb48452c4e4044e05836c55abd56abf0e4e042bf9c2e741babe9dabc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.9.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2fc54687d03e5f3abbfbea83b36d9f99260ec6c5e730d1b48cc31aef634203f6
MD5 f0f6929352697c2bbc69e31ab490c03d
BLAKE2b-256 23727c513a2e7624129e4adc1139a8453c995c19fc04084fd2cfd614003d6292

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.9.9-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9e869769905bc99e07cb821c25ee55523e8759f994dcfc44465c71b3a11291f7
MD5 5a811f416824dfb5e33b6459edefaa7f
BLAKE2b-256 66c83843de7e0677afe88cb392bcdc433d4f2bbfd15169d458d4bffbe13669bc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gambaterm-0.9.9-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 163.3 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for gambaterm-0.9.9-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 cd4b075398e0b80a4ec1f49da6191c9c8b28a44478848a9c78544beb264b5d0b
MD5 17bbaa1ca49e064e06b482d0723d54fa
BLAKE2b-256 63e4d566520ce5c5fbccd63ddaa471b8a44366c226b5dc4e48d9ea9f93b62d37

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.9.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6fb0e2b3fbfdde0d2a3eeb809fb1fa357a78ba96b1d958a0113b03d52bc54e36
MD5 64c7f9fab7c8b9ec29353de42e9caefe
BLAKE2b-256 6568e3e6d846384810ae20cf4fa53b8049614a44d4a644aabb2a1462f794bfb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.9.9-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fba907f7b25f2bb1e09fb20081cfc99ccd1f59fd8dea3dcb850c2a2749ec3e8a
MD5 3f83e650b18da686c2b87d8a1ae79a1b
BLAKE2b-256 6d645b0e71af19053f833c1008d83670b2aedf694be80eea56a7ba48133906d8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gambaterm-0.9.9-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 163.4 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for gambaterm-0.9.9-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 36a610c6084452475f646cb219f8bf18d552299829e206ce5e227e9b9a5b2259
MD5 b9922d3d2e024b9ec1b63eea08418414
BLAKE2b-256 090236e94a41b34e97bb85ab3ea6ce40d74e52843e18725a4a1bf8dbddd94fd4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.9.9-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d39a80c1bf5a936f3afea9a1bdd07fbf5ecef9d6e48e1c317fa99ef6afa9e365
MD5 b92645cac404aa1a85e81fd020e10ed4
BLAKE2b-256 14ad24f0c438dbc50cf0fc937bd2cfcba5b513029f9f4e707e9716d54b720e8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.9.9-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dc36187692f2ae169adb3a825c0ddd3fb0e156e61ab577934c7f9bd2c320882d
MD5 87843504c7eefe406fdfec8143b4b835
BLAKE2b-256 c71a7dd13061f2914deb7d06ac1f5d4b66cae7582eddb54ee35ca1faf16101c3

See more details on using hashes here.

File details

Details for the file gambaterm-0.9.9-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: gambaterm-0.9.9-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 186.2 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for gambaterm-0.9.9-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 ef3df80ea51780418fa01fa94dbdbdc5d5204427cdaa942e001222f283b96cf4
MD5 6a6f13c1af3e3219ec6241aac90ca431
BLAKE2b-256 6730b598e5408b4dc9b2345c440cca954877a9af19b93f184ce717c193821f2a

See more details on using hashes here.

File details

Details for the file gambaterm-0.9.9-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.9.9-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fe36ad23b2bdd90480a00f7935e56b30c98508aee7ee63638d5f8ec3412025f0
MD5 68215e48efea687438f11ccce552365a
BLAKE2b-256 d6088c15341d13f0e1cea0c8c08c7b36b20c7fa02569c6b44e2d6a55eb290ab6

See more details on using hashes here.

File details

Details for the file gambaterm-0.9.9-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.9.9-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b55ad6aa5b62dd726c680aeeef666a2a3498b8632c78b03bc08a0fdde5cfdfce
MD5 eef423178825c64e7b4380920a7df23e
BLAKE2b-256 ef9147a900a640e1a4184986e15ddc89cde1857d4b03e9542d2272c45f1c9074

See more details on using hashes here.

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