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.3.tar.gz (143.7 kB view details)

Uploaded Source

Built Distributions

gambaterm-0.12.3-cp312-cp312-win_amd64.whl (192.9 kB view details)

Uploaded CPython 3.12 Windows x86-64

gambaterm-0.12.3-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.3-cp312-cp312-macosx_10_9_x86_64.whl (237.7 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

gambaterm-0.12.3-cp311-cp311-win_amd64.whl (192.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

gambaterm-0.12.3-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.3-cp311-cp311-macosx_10_9_x86_64.whl (236.5 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

gambaterm-0.12.3-cp310-cp310-win_amd64.whl (192.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

gambaterm-0.12.3-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.3-cp310-cp310-macosx_10_9_x86_64.whl (236.5 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

gambaterm-0.12.3-cp39-cp39-win_amd64.whl (192.5 kB view details)

Uploaded CPython 3.9 Windows x86-64

gambaterm-0.12.3-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.3-cp39-cp39-macosx_10_9_x86_64.whl (237.4 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

gambaterm-0.12.3-cp38-cp38-win_amd64.whl (193.2 kB view details)

Uploaded CPython 3.8 Windows x86-64

gambaterm-0.12.3-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.3-cp38-cp38-macosx_10_9_x86_64.whl (238.0 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

gambaterm-0.12.3-cp37-cp37m-win_amd64.whl (193.6 kB view details)

Uploaded CPython 3.7m Windows x86-64

gambaterm-0.12.3-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.3-cp37-cp37m-macosx_10_9_x86_64.whl (239.3 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: gambaterm-0.12.3.tar.gz
  • Upload date:
  • Size: 143.7 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.3.tar.gz
Algorithm Hash digest
SHA256 cd1f84813947bf7046f919423704624036bb93f52968562b02870fbd8a0936ad
MD5 1c6bea5d193713f708f8aabf09459e69
BLAKE2b-256 8aff786a7476d14b3becd98a979134b55f56adca246de33044a4cbd9154d63a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0dd6f36efa7aa3b775936bc6a32640238f792092168b6bc04ea9b340b23c13e8
MD5 2c6441676d5e7ad8055ec2ed6b28e611
BLAKE2b-256 572a786cf6af8533725baf80dfbb1d40f549ade38c1378f4bdbe6c8636eaf3fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 96a03f24cbe84d273f13a074022f8841b66703ded1fd14fb0e4d804643777e83
MD5 d625b2d89ae2bca7c4ba8beb5c6be9b1
BLAKE2b-256 d28eb3ec54971cae0789bacb80dd1da7c18bd1b142585986833f386f8455c7a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.3-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 33e7a40bf9d151a5d15629e39b4e03b85724622d1e05fd0f22b3eb7ff1a5bb4b
MD5 2960bfe904d63de7ebbc0597728bef3b
BLAKE2b-256 3b0b2d9b8c5f787d3d83ab8240b7634b474d6e3f2aa15a1f1ad4c7b1b6134ae3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c0ae528255ad8c3f50122c7361baa9c3513f86d8d87a4a88ff69b7e2405a3cc8
MD5 ea9b0eee48c3e7b4601ce2bbbb049e63
BLAKE2b-256 22d77dc658765acb70365fc0fbd5d188e5878686f9a54af3d5c7dacbddb3a48c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c405f091f94870fce4069ff1c885b6bd755844eabd37d18df0bc060935d10387
MD5 99c5ba64c03114b15825c8eabcc3a5c2
BLAKE2b-256 69c7cb6a87221d996eee48b3bf4e264274b29c6f4f7e2836be14b5c8f495337b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.3-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 baead2e460562e6cd41d9597dc181dcbe43c2dee53139e29d8caa1fcdf1b8472
MD5 b76464f961af6ca406cc0112091a69d4
BLAKE2b-256 14be8f30d0bd7e5b8400420813dc9d11bc67b06410537ff59536a8affe0ba4ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ee88460092c37db73ed460731b79af85c997510821c79b2e992c38a16ad2ee3f
MD5 6a13533ca1c661147a1cda5b0d363f33
BLAKE2b-256 b9d43f4be237522135001d991365280fa7e6f61578122b30b73ec5aee82c155b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2ed3ccf9ca3c3b41b4a9ce666219d4e064770c511716fb0414c1b43233e3d65a
MD5 bea2f43f35ee5c1b38940b64c2a9ba4a
BLAKE2b-256 a40145c7dc678388898ccc692502e6a8db2c7224e313ae85896329c00f453b66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6896c712defed9d285a2c5e601f5cb6ad6503a2b64204e53dae190542938e88f
MD5 e6d7b89572f0cf5ed478ab89e77cebb6
BLAKE2b-256 cd94cc3672be0bc35ede2f516d1e46dd870405388fbdc1f0137580a34c0c36ca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gambaterm-0.12.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 192.5 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.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1eb4b5f4ca276ff6549f283c09df33f14a1817651ce97cd4ddaffca7045a97f1
MD5 da88b77b8a2f87b548ed6ade99f9e4f2
BLAKE2b-256 f0b05f9fe11e7da8381e02466d42a9e8c0fd75591dc51aa7b2f4fc1f5037e9ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 da8bbe19a5eb7ba339e8e50b27c9c986bf7ab3b2629808331db3e78d36e387b7
MD5 ad47913d1b56fd66fe07ea505c6da9fe
BLAKE2b-256 fe037315fbb4b35aa9f5019f721b4884bea0a90d55c9114962a3496f1dfcf813

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 60a7a000ff7c00b4948a1ef80335e561ac8a3f03947ded4c9c2894f89c3c6c59
MD5 c6f36248bc5038f0edca8b6109c4f8a4
BLAKE2b-256 5d3fb2771f98d10b9084027a789134fbe1fe79e2f02768609121baac9d8e97a2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gambaterm-0.12.3-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 193.2 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.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 34344209cc594fcc2a6dc1d504451de8dcd52edc4bece2cdf8ae1f222aced1a9
MD5 e2414af061633266d303bbac9ae0adae
BLAKE2b-256 c3f4225a4696e0e3dbaa0692ba994f84151352be286e3b09b687715143a5c937

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b3207d54a32a480cd9ea28c2356f60968508f92ddab392ea85e5cd4cbdfb9484
MD5 7775501d77ae4c66744129d53bd98a8a
BLAKE2b-256 9fba5ee9e4f508b667488de38482cb2fb7285f890c93970f4dfb9eb101303a7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 74ee08874f9d87e30115c8146148a6bf5e0cd151aa913e6af0e7cc969f1c825a
MD5 732ad8d04c316916b43548facd962630
BLAKE2b-256 271de25db99dcc262d415a306f8c2c519f9e582561f4a2789915c38f6052d88b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 9470375550c44a53c94cace089664d96afb318b1342f38f9e292363865cf79c0
MD5 d7b64cff4fbd9e6fdb73b089ddf3bbc9
BLAKE2b-256 6a3bacd91433a85fce71dd759425c0cb8035cd3a52c0bc6c7b11621e58cdde14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9a35a3e28726fef7d2478a4eb7a06494475583cdb7be91e736d7f102b98d62f8
MD5 29da608c97894afca910c03832e77f82
BLAKE2b-256 2cc8badbb7f1f0faa332bd6163a78e5430a4b67b62bcf545314aaad0d6424398

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d13330586ce2d5bae255bc5f6906f9fdd2c3db684a5830ccbb9cc5a2bd3f9ff5
MD5 e8dff8e3dbfeee12ab1c2ce3628a923a
BLAKE2b-256 60b669a272f45ef54cac4d5e5e56a131e92a8f14cdc90d9cb4bb8aaf9e87a594

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