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

Uploaded Source

Built Distributions

gambaterm-0.12.0-cp311-cp311-win_amd64.whl (174.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

gambaterm-0.12.0-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.0-cp311-cp311-macosx_10_9_x86_64.whl (216.8 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

gambaterm-0.12.0-cp310-cp310-win_amd64.whl (175.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

gambaterm-0.12.0-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.0-cp310-cp310-macosx_10_9_x86_64.whl (217.1 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

gambaterm-0.12.0-cp39-cp39-win_amd64.whl (175.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

gambaterm-0.12.0-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.0-cp39-cp39-macosx_10_9_x86_64.whl (217.1 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

gambaterm-0.12.0-cp38-cp38-win_amd64.whl (174.5 kB view details)

Uploaded CPython 3.8 Windows x86-64

gambaterm-0.12.0-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.0-cp38-cp38-macosx_10_9_x86_64.whl (217.1 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

gambaterm-0.12.0-cp37-cp37m-win_amd64.whl (174.5 kB view details)

Uploaded CPython 3.7m Windows x86-64

gambaterm-0.12.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.12.0-cp37-cp37m-macosx_10_9_x86_64.whl (216.8 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for gambaterm-0.12.0.tar.gz
Algorithm Hash digest
SHA256 bc5df14be7a84b6084473a35ad19f2d8e6eaa7030f608e59c825431fc410c9f3
MD5 8ccbcf8e417aee3b11d31605c43564bd
BLAKE2b-256 56268ab71771a78f63e19494177998c81516eb2d7248ec9c66b09a402cae449e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8561c663c045aba485338513602f885860e924eec60d00121cf516fea5c4b454
MD5 88866bd5ab1c573e58027131afe2ac27
BLAKE2b-256 80d7ad762bf4b9e467192258e9cc4353b80bed4545b4b0bcdd7b25979a2ed898

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a4ed6d8c5974868abeace5ee9885649185773c1cbedf3b699efae0e55a6a89c2
MD5 4df91125c8505e10ac431f46d89072e6
BLAKE2b-256 b33027af6ddd9c617ee1c3a9a97eae0dcf695d6a53404d599ebda4168fd4a5f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 65a15d57e8404a4cb6b00d05bee83bc5bc49ab14c53bf657066c9eaa0772614a
MD5 70a66df6be131a8177402ec30f620019
BLAKE2b-256 ed3e9d0dd5766b9a2f452aa48e8e0a91fe7fa85e94fdfe423f9cba52aa6e9c3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 03541eb5e8c8b90bc4c4482522f663c4478dfcd5b1d6645bacbbc61646c299ca
MD5 a88427cf97347dcd17e48cf760235dfd
BLAKE2b-256 95dbcce802d157e7f633cc0a26e547d6d89a81784fddf3305af73121e9c29be4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 11e0a9c323bf3e4c7bd44dae603ea068da4df5e4a5f15d6c5fec33743d5a060e
MD5 2a373ccd0cb465c36c2eb6712971ebda
BLAKE2b-256 143c4c388b3d485c57aaa9aaeeefc7e54bfd5bba5f9e6e554c5bee90233d2b85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 76587320b1dc18f1eb9862a8cfe1bced3b75966340e270f3c467c0f634e97bcf
MD5 03b0f48d5af6fe29266c4311e103ef4c
BLAKE2b-256 8c146e4baee42b08d67d2998c3840f6389d6178580f4b434c73075ac180bf36d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for gambaterm-0.12.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 79bfe0949eea347bdb4c63f5886473fa4c568b134eecbb38de1a3e203f804986
MD5 49647948410d5a913ad047386b51c479
BLAKE2b-256 24dada2a09ba22331ddf75f4423c329f447deb7d9c79f7e6a2e049d360c81a54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d8679cdfb9c419760976049bc23a311dab0db04b47a1a2c13df9acdd9d5ca458
MD5 757ded103bbaeac86cfa3a7e33f2b8f2
BLAKE2b-256 c0a3bc15c0bce154889f74e6cdc5412e6f257a8e36d13243dd674aadac997040

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3926d3936ee8d4bc63d67804bf687ce13ff39257681dd7a3eac44eb5a2a97163
MD5 ecb0aa4dc389ced230feb0779eb8295e
BLAKE2b-256 1107a3beeea85fd04a28526aa9c592b63b9cfc1f0df88dc3069431f0c1cc3381

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for gambaterm-0.12.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 de1c9ca8c79aebc140c95721aac3d8441b4242c47b75178428f083d639c6750f
MD5 3a66c2186e60bb46339ef6b30e626648
BLAKE2b-256 50711693e14067d428999b171a85f9f06999d987385646779b462ca97267b874

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2cc6cffe34fe166df1797b130fee480cecceb9df1ff8e651077c865fa46b24e2
MD5 66bd4b28854922766fa9714298387669
BLAKE2b-256 009c1d4a308cd216a23a4b0cbd7de9f6d0346e1114c06099a776f7ad6d045389

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bb51962cb3e27b65911b17b2503d449f5f323650f80020ceed623e43bcc20d4d
MD5 6c9352ff36b6a407fc4cbb491acf3bb9
BLAKE2b-256 26d5f979af5459dbe79601ea74683dd1fa9cdf17eecd9cdbf5233764f3737ad9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 234827cae4f50d229148407a50f3d1a67e1d69e465f6a9f4257d8667d8f88118
MD5 92027d28f8b6c8c7f2cbe016c215d5ec
BLAKE2b-256 891c3cf13cacec959f28aa8f7980c700ec347f898fa588ac575b4d5f4aa64971

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a66d48741492dbe7a6e801f577372dea044b7f70f89521d38cef08922a8ea2b3
MD5 e6be8e3d56b9b3c2a47c55dc8cbd0942
BLAKE2b-256 1ea9eef0211290a7d35154821451c4466ee7c0a50171e5516fdcd521fc77374c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cbe920760cc3fe9a27593ae27697f45a06b005570cc26008c6d0a36508148583
MD5 bce51765a1d3ab4fc4e8d4354917ac1a
BLAKE2b-256 7faee18586c1b4b49775f90baa674ac762e763a95b5c62a744304da8fa157331

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