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

Uploaded Source

Built Distributions

gambaterm-0.12.2-cp311-cp311-win_amd64.whl (173.8 kB view details)

Uploaded CPython 3.11 Windows x86-64

gambaterm-0.12.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

gambaterm-0.12.2-cp311-cp311-macosx_10_9_x86_64.whl (218.5 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

gambaterm-0.12.2-cp310-cp310-win_amd64.whl (174.6 kB view details)

Uploaded CPython 3.10 Windows x86-64

gambaterm-0.12.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

gambaterm-0.12.2-cp310-cp310-macosx_10_9_x86_64.whl (218.6 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

gambaterm-0.12.2-cp39-cp39-win_amd64.whl (174.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

gambaterm-0.12.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

gambaterm-0.12.2-cp39-cp39-macosx_10_9_x86_64.whl (218.5 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

gambaterm-0.12.2-cp38-cp38-win_amd64.whl (174.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

gambaterm-0.12.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

gambaterm-0.12.2-cp38-cp38-macosx_10_9_x86_64.whl (218.5 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

gambaterm-0.12.2-cp37-cp37m-win_amd64.whl (174.8 kB view details)

Uploaded CPython 3.7m Windows x86-64

gambaterm-0.12.2-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.12.2-cp37-cp37m-macosx_10_9_x86_64.whl (218.5 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for gambaterm-0.12.2.tar.gz
Algorithm Hash digest
SHA256 0cef18e268ec328da39de4286887bdb505c313d0657cd196eea42d5217366bf2
MD5 b127da100a4c5398ed3836d8c1585957
BLAKE2b-256 d0ded14aa2e3c29317f748b7958315429c949c0df8f44c3701e149128fc25dbd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 702e1d6e489246013350504b97459812c99236bb836671e2882362bbd0ffc80e
MD5 2f7674e34b5b1986eab356295d71629e
BLAKE2b-256 2d5528ccd636d29671e4571bda81374054520367f92ff6366b77783574c2cb05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 541aca7bf159d66789f437d51b45097054e2b69cd75cc1d0a5c94739191539f2
MD5 0479a027b19319900f45261c073d8bc6
BLAKE2b-256 e270e12505dfc04a24f51bab6db8c205a6da38c9641a9b72606f535ce2c5ca60

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7395e2ecee375d13bb5ba2861ce8bcf528b485e7e87b1d61243c0dd41f1c57a3
MD5 f175c2fa3c5eb9c2e84710a3863c944a
BLAKE2b-256 31f4669b85ebda5c828f351a8ba49c2b61d0b730ef30e79bc99760730a85b5c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 dfc6b335010bc921d6e880f01711479c36475f62a6feda1e0314ffda80b14527
MD5 eaa6f2a4e3cb6c16517f0f75c61c4792
BLAKE2b-256 0f7167d180904c0d94a090a51b2081bffb6f8618775e53e71a111a66802d8968

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6fe69dd5f0d6c1a529b69cb83ebac724013d14f8db363f0655198b6a40ccbc69
MD5 ad1ea92e193ca7fd5a988d64deba75b8
BLAKE2b-256 f3755009eec517766262e83933e31f794d602a416758fcdd46019639d0a124c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 06c0b5380d8afe5ef5ab6aff4b397e8703d28f2085f6662a2098151679a3b3c3
MD5 514715c81f36b37f3e87f6faba7f8888
BLAKE2b-256 8520453c92476b76f3a9330e9ecdafa16fd92e439e0e8966844062c482acee7a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for gambaterm-0.12.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e5bf5f47d1c17fa11330cd14889894e1c8df65b0f852e900d59347fd6f46985d
MD5 a35dae7f3f38b8f146fa5293e13910c9
BLAKE2b-256 946d2f10e7439cab2cb78087ba08be55dde44d5b03e10ef316e3effaa0ed84c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 15118c91f9841615f0e6394f229561c6a35dd423fb5b0315dfee939e5efa7e75
MD5 ecd12a0b7c59c4ec4bd40f9a57e8277f
BLAKE2b-256 fbc8e8bc36668f0f52dd1725020a19313b6eaea5b145fa730f63ce3c3de82ccf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e96e37f6477c861fd650fc4a6cb799c08e9422694aebe1078f39ae5f0c0b1966
MD5 75db8645e7515b9c5d20b5357a61837b
BLAKE2b-256 1a9c3dea772391c7b502b2a8691fe07d2afe69be737a93c2fd8dcb4a448ccb19

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for gambaterm-0.12.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 a5327c8f3dd099ede59a7f31830a5256de4a0633fad4af26d555c8ba2f8a8f8c
MD5 f0477f4536fd18ca3e8e5344b8135be0
BLAKE2b-256 a20fcc68a860bb6770689b011610fc4c1c1dec4cef796adf5b838826f8c85692

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 07072b0516cedab20a63671de55a3d7b23d9dc95b275a17313c5630b9aa289f7
MD5 4a3fdee8a5bc31a4269cd5943b86a729
BLAKE2b-256 fc66196b2bc5c49d5544887b081f50f3a332268c684d1e387506e96867409714

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b85b5bb329d60413e8334c211d045155849c3710611b2ab11b5b70df0069651e
MD5 e51da47bcd87bf878e3edd5e9cbcfac8
BLAKE2b-256 38e9eb4d85dc94601a434363993697969eb73ae3bcc46f24bce5c0186a434d6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 31fa92d9e8c0b5acb7898204447b7b626fc791bb7be6fe572aa1b0c5016f444c
MD5 7beeaa80afeb352d16d6bd18428bbb2e
BLAKE2b-256 0a9a978ccb1c134d8b723ce48141df0706253fdcf88a78dde43c06240eaa6347

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a043df543afca00be27b17bac0491568285c6186c80bb2861eec968f9c0b5185
MD5 72da650f50852c913c65f100971217ee
BLAKE2b-256 56e074a7d3a446c8ef940de3f81302619d5b3e1ace832f583a8637991f15381e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 737ce2a2fba2bc9bd31b00f4705bf28c6c27d0e6f069b7330b9efeaff416740e
MD5 5fbe134052ed404c0f915b9fd50660c3
BLAKE2b-256 7554cecf281b249002090146d7f21ec1ba5c979a75f1c763b05b22e57f6a6dde

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