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

Uploaded Source

Built Distributions

gambaterm-0.9.8-cp39-cp39-win_amd64.whl (162.8 kB view details)

Uploaded CPython 3.9 Windows x86-64

gambaterm-0.9.8-cp39-cp39-manylinux2010_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

gambaterm-0.9.8-cp39-cp39-manylinux1_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9

gambaterm-0.9.8-cp39-cp39-macosx_10_9_x86_64.whl (211.3 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

gambaterm-0.9.8-cp38-cp38-win_amd64.whl (163.1 kB view details)

Uploaded CPython 3.8 Windows x86-64

gambaterm-0.9.8-cp38-cp38-manylinux2010_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

gambaterm-0.9.8-cp38-cp38-manylinux1_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8

gambaterm-0.9.8-cp38-cp38-macosx_10_9_x86_64.whl (212.8 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

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

Uploaded CPython 3.7m Windows x86-64

gambaterm-0.9.8-cp37-cp37m-manylinux2010_x86_64.whl (1.4 MB view details)

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

gambaterm-0.9.8-cp37-cp37m-manylinux1_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.7m

gambaterm-0.9.8-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.8-cp36-cp36m-win_amd64.whl (186.0 kB view details)

Uploaded CPython 3.6m Windows x86-64

gambaterm-0.9.8-cp36-cp36m-manylinux2010_x86_64.whl (1.4 MB view details)

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

gambaterm-0.9.8-cp36-cp36m-manylinux1_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.6m

gambaterm-0.9.8-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.8.tar.gz.

File metadata

  • Download URL: gambaterm-0.9.8.tar.gz
  • Upload date:
  • Size: 139.7 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.8.tar.gz
Algorithm Hash digest
SHA256 ed5732d87e721e5d0e2a86ba4dc6b3afd545db2d78debcec39a2af83d754f186
MD5 57d088436cd116a3f7b7f5cfa713ef42
BLAKE2b-256 5a80c5169e869756813783746e3e0c8166baa9f72cfd1a2e9d46e391478dea07

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gambaterm-0.9.8-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 162.8 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.8-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 7cc8e7dc283b25a4b38ff23c493d0550b57bba69500a1f055cc47892767363e6
MD5 d63e7fd75b0d829409f9c7466cc0bf5f
BLAKE2b-256 ce15e15cdd0f7f46924cdb9de534b6336a49a2fc3824a45228d7818456db7d91

See more details on using hashes here.

File details

Details for the file gambaterm-0.9.8-cp39-cp39-manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.9.8-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 b8d6a4484ca0891d9887a7903ebbb181631c26cde0ce46c8f3dc6d9fb7bee55b
MD5 06fc0870041aa1508a6afa1e196464f6
BLAKE2b-256 a94408a838af29d44c19acc3db84d10d5efca2562eaccb0a92b5c85b4d8659e3

See more details on using hashes here.

File details

Details for the file gambaterm-0.9.8-cp39-cp39-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.9.8-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7d6f548192c476a090bb978bac7a82379f2d9f781fc5380380809aba4f485014
MD5 6cb15a2bb2ad02c6f12d09d57dddbe95
BLAKE2b-256 6e60a6cdd4154a93702c2f70cf722f2d2800cc36c7e521753c233d12f623feb3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.9.8-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 790b7896fe9c816763f06576e221012e27cefc21aad788f508f5c82c201af604
MD5 d27835c698e9fd578af719bb9a6e9072
BLAKE2b-256 9c454c81a75608b7b62b29bc0cd962a71cabfdad00cb6d0e3b813ffbc221b75e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gambaterm-0.9.8-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 163.1 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.8-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e1271c9120f8fc46b19a699e8ff64e685edc8c76315c5d66569e67a47035b548
MD5 d1796b10a1a4e27f534e2beb3a7cc237
BLAKE2b-256 5e566ce8f3f2226a59deb655aa56dc6892f8fdb5bd2895f395419982298424eb

See more details on using hashes here.

File details

Details for the file gambaterm-0.9.8-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.9.8-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 001f4ae944509bd139c06152c734e53068d15b8b2c3fcad759cc7515755cf284
MD5 1f2d17250044c06469a5aca49e05780e
BLAKE2b-256 4ccbb56523563d191f57863899f525b6bd7047a432e707e52878fdf5929b6b0d

See more details on using hashes here.

File details

Details for the file gambaterm-0.9.8-cp38-cp38-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.9.8-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 79a842330735477f1803d712baf37ae6f587961147b0d1fa497e66e3d689c85c
MD5 ff5a59495fcfccddf53095ec961590f8
BLAKE2b-256 176a02cf4133cc457070ca2f06e58f0994ed80714ab203f01540ee8151cd2b6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.9.8-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4b66b48bfa613b7bdfc0da58126d28a22e40c7d0bebc118022cb097edf316c0e
MD5 62fe83e76d2da3bfacde86a8aa5b1ef5
BLAKE2b-256 fac6c78949ca2505654673b380416e41d1c60d63b61c500339a626330f46fc8a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gambaterm-0.9.8-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 163.2 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.8-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 f75b6afcb553a8fe8b142c5fa1033c9f6fd4279ffa159a71c7511bc9857cc668
MD5 dfef32434b8186e7e80ccfbce098d09f
BLAKE2b-256 57430b2afb9a0f64b0d32996fa0a3e70a1feb62c306593d63a5c7e9c29acff09

See more details on using hashes here.

File details

Details for the file gambaterm-0.9.8-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.9.8-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 e4d74ce3628dcc231609903bff03a65b0e656b105882a323bf78c23392cc6088
MD5 99cc58ec4058eaf9cdee329a054d27ad
BLAKE2b-256 da464c1ea5664f0697ea71e9ea818f75756d9045744bfaf984066f5ff51fdec2

See more details on using hashes here.

File details

Details for the file gambaterm-0.9.8-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.9.8-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3e1baef13e0dac0a31a90f5b058c378989b866f7a8ba8bd5a90f2a137f92f2ce
MD5 6f564daa5835ef0e32d2d9ed529678d4
BLAKE2b-256 28c2e84c768b5a6e69ee76bf1631611f28e986a716e94afd4ac7ddff71758fd7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.9.8-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d706657a77654c35df1576592129d52bead96a3806edc60c40631dba09a996ec
MD5 056209ba7c8e71f81bf99cc21687d6e9
BLAKE2b-256 22f81bd9490c59cece29c3d6aa367949deb7b3ba412b6c8bafacf2fcc2448fa5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gambaterm-0.9.8-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 186.0 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.8-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 53cb79109a521b9c3bec6d3e4c3fcdb73eda15eb7df9086ac38bbcc20b569e12
MD5 20905eb7f54ef9ad18bfc6af7b905edc
BLAKE2b-256 07d8f7fb1ce011dab08b819f420426e5608474ff16480e38ddaad2fc29b6d7e7

See more details on using hashes here.

File details

Details for the file gambaterm-0.9.8-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.9.8-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 d673e7e960273b065f76873dfbac3310624cc10e2c286e562f9bb04a9fdd1a2d
MD5 81274cdd61324068d41db76da5fac455
BLAKE2b-256 095dcce73cd950b8aa9c164e1b3352ba7210d48ecf4b3871c12f64d2df59043d

See more details on using hashes here.

File details

Details for the file gambaterm-0.9.8-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for gambaterm-0.9.8-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 815dcada67c0ef8483a7b1d9bf400c38e460e513b4e9cc5d5c75ed0f99c9ff8d
MD5 a6a4d8fbc75c92936c140da2e0d6bcbd
BLAKE2b-256 539a70a886f984cde488ee1cee884356551d419267c7df43ace5acd202343ca6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.9.8-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bd10bfab1de55cdca07625293a5460da3b4f02008066a80fc3a1c62ad1de7480
MD5 4a504432d21ee64612115578a235dc56
BLAKE2b-256 9565e7a5bf978fdabe2e4ff9a028ec4be06274491d63496afded0bb8bb9afec6

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