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

Uploaded Source

Built Distributions

gambaterm-0.10.0-cp311-cp311-win_amd64.whl (162.6 kB view details)

Uploaded CPython 3.11 Windows x86-64

gambaterm-0.10.0-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.10.0-cp310-cp310-win_amd64.whl (163.5 kB view details)

Uploaded CPython 3.10 Windows x86-64

gambaterm-0.10.0-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.10.0-cp310-cp310-macosx_10_9_x86_64.whl (212.8 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

gambaterm-0.10.0-cp39-cp39-win_amd64.whl (163.5 kB view details)

Uploaded CPython 3.9 Windows x86-64

gambaterm-0.10.0-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.10.0-cp39-cp39-macosx_10_9_x86_64.whl (212.9 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

gambaterm-0.10.0-cp38-cp38-win_amd64.whl (163.2 kB view details)

Uploaded CPython 3.8 Windows x86-64

gambaterm-0.10.0-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.10.0-cp38-cp38-macosx_10_9_x86_64.whl (212.8 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

gambaterm-0.10.0-cp37-cp37m-win_amd64.whl (163.2 kB view details)

Uploaded CPython 3.7m Windows x86-64

gambaterm-0.10.0-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.10.0-cp37-cp37m-macosx_10_9_x86_64.whl (212.6 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

gambaterm-0.10.0-cp36-cp36m-win_amd64.whl (186.1 kB view details)

Uploaded CPython 3.6m Windows x86-64

gambaterm-0.10.0-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.10.0-cp36-cp36m-macosx_10_9_x86_64.whl (212.9 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: gambaterm-0.10.0.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.10.0.tar.gz
Algorithm Hash digest
SHA256 6117e043262c26f58b5685b887b18898e25ee339907e6bc6020cc894945d4d65
MD5 cb635f20add6667a5d21932e4c8bf125
BLAKE2b-256 6a2dd3f7476848b017ba42d718f7b4f9fbb1103f42904c0e10983a394a08f443

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.10.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 83fc7c9734c133d552cec37cf0fd053dd3088d208025570fb20cc12f89b25491
MD5 8cf50424485f316e9ff00131263fdb2b
BLAKE2b-256 08172c8130cbbb87d4ab9d5b4616106b76a5647870ecff3102f4d753d2d56da5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f54b45496a49859ab654ceb897c9c1b7092e98626599228553a5846a62ab6237
MD5 e604a55844c1dc6a1ebd859bffb2a020
BLAKE2b-256 b06b3abb63722b9a7a41333a035bbfae1046f1b2aa2630fb162cd3904b188ec4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.10.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 16654183ce3bea4fbb1991c1535d127dbd78369ce6cb2b386d0dbd25d75b09a7
MD5 48ed6bf3cd3f194578ee2a932cc566f3
BLAKE2b-256 9977599158d4577681f84597cb766db512bb3406d79fb04e4fefe6f1d547c4db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a6e883da3a2b381494b732f247ac02061fe8ef53b1c6c681370a8f359f506bae
MD5 3a4a69845e35cc2ba423891aed78c418
BLAKE2b-256 2cef547738b7355d44ba4b8d75a4d4782f6ffc247fbc77ef3de060ac70fe88db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.10.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 387bade2ece6ecb2116674fc81a623b66a8f7c3abb02a1afdb70260ab8254c52
MD5 07a0fb8ec4beb0cd55ef06da0abde487
BLAKE2b-256 9131d5eb61690823f444b7b88c272f9af2008b6b665cfd32cb9b5908c1d3bbcc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gambaterm-0.10.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 163.5 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.10.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 222de46e9aa716293a09b870aba3840c86e29dde8708f83c12cb400af5f951f7
MD5 725d1657de34d0f860aca219d5717268
BLAKE2b-256 6076e4518674ced40c2b316ae97889a9cd1b4214a95feea90b1e37ab8a6c22ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.10.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c7985f5d142ca1ef4178e02c916299553fafc7e8cb7f6d7f75509ae2950e57b3
MD5 38698e1b453a98aa599bc411efd4b785
BLAKE2b-256 994070d1e8fade24803a06a59d3aedfaa13ab653cb3e45a309009cd18206ce19

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.10.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c23b8039ff0870c2a0991c32d57239a51b00c2ce5c5d74c31704a1391d8675b4
MD5 dc6004e91abcf202dc9312b7a27b9a7f
BLAKE2b-256 2d4688c009df7f60c31bc294b50a87dcbed0f85f21caec8631eac4f365d2b70e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gambaterm-0.10.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 163.2 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.10.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 4e2e598c35a13bc96232911b4b25072ecb8eb5d3a23ee7b0a4b3a87c156f35a3
MD5 feb8696cb1c91531418ab9a9a2e37979
BLAKE2b-256 354083fb2493439700ad2c68f68bf5b1217591722ac1c135e61adc95860950da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.10.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ba69dddf923f5bb6a82e5694cb642d5d802bade62972b6739b8e46f8cbed9627
MD5 28b5c4133fc4688b170ec8d328b0a17b
BLAKE2b-256 c5ff68e1dcfa721a346939323a988ba9f28cc40bc9eb3734b730034d34e6edb3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.10.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2094387351f06d70faa35491ce65300155dc564da679c19d5fa359f0c066659e
MD5 ca6c3c7b8d2e9ac9531f31c85d86345e
BLAKE2b-256 52becfcbe13567997646c88f0a5d352636f80f3d2051b81359f7fb6ec069eb0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.10.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 6a850105fb9b33a68febe5fbf15edbde1aa00e1d919fdd6b6aa069bb90a71a1a
MD5 b18f518b2b68f146d5b750005a97baf3
BLAKE2b-256 6399de236bb543ec20be743e881c1b655e60068f8c7d9268fa248fc04ce6d0c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.10.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 62783ef67d91a144fa1122734bb87313f7f5daa140dd02f19af08e8f026976d6
MD5 ab207dfadb6bc795372d9993db3ee47a
BLAKE2b-256 a278d8efa7977dc2169ab767f4d812a9428014b7f659e13ece5c954843cf4e64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.10.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 376f620ada5959f2a9868c5fe0a3ffa5dbdeddd1b2ba2168c1bca36ff59a4503
MD5 768c7c0e2ca21102ff8045dd53432454
BLAKE2b-256 e5eda4b5c8005544951fe07f1de5d424b0c4f5e3fc5cd2da640782ac96259b5d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.10.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 c0cb4760fa258a805c951f1ece1e3807a0cc6a82e001d8ed449440205915086f
MD5 7d99c697dd63b0c49f8e1ccf5644bf42
BLAKE2b-256 cbf787704a428f08dc22372e20a9c4c8397848bea04e53e828f91051c8551ff9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.10.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 73f49d5eb2e4d71ade0d9960da573464123123991df36d8ad2a8350d770c87d5
MD5 f4dc45cd1b17964002acfe147338cec1
BLAKE2b-256 7b7e6258e7ddafef2a2c1da0f2ba24dcd82b9f2840abce767f0d08a8a0fe7f37

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.10.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3280ccdacce376271437719dcfb20ea3bf62ee451def3a44ad9f6570c9522e28
MD5 ab085e51c95286ab6427c7251e392c64
BLAKE2b-256 16aabe5d542cdf325ccaaee52c7c9eeb8b21e7ad2cf20f9062d407eefc313c7c

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