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

Uploaded Source

Built Distributions

gambaterm-0.12.1-cp311-cp311-win_amd64.whl (174.2 kB view details)

Uploaded CPython 3.11 Windows x86-64

gambaterm-0.12.1-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.1-cp311-cp311-macosx_10_9_x86_64.whl (217.0 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

gambaterm-0.12.1-cp310-cp310-win_amd64.whl (175.1 kB view details)

Uploaded CPython 3.10 Windows x86-64

gambaterm-0.12.1-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.1-cp310-cp310-macosx_10_9_x86_64.whl (217.3 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

gambaterm-0.12.1-cp39-cp39-win_amd64.whl (175.1 kB view details)

Uploaded CPython 3.9 Windows x86-64

gambaterm-0.12.1-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.1-cp39-cp39-macosx_10_9_x86_64.whl (217.2 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

gambaterm-0.12.1-cp38-cp38-win_amd64.whl (174.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

gambaterm-0.12.1-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.1-cp38-cp38-macosx_10_9_x86_64.whl (217.2 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

gambaterm-0.12.1-cp37-cp37m-win_amd64.whl (174.7 kB view details)

Uploaded CPython 3.7m Windows x86-64

gambaterm-0.12.1-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.1-cp37-cp37m-macosx_10_9_x86_64.whl (217.0 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: gambaterm-0.12.1.tar.gz
  • Upload date:
  • Size: 142.5 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.1.tar.gz
Algorithm Hash digest
SHA256 eac0c15dd0674506542deeb2be1f49aa29ff2b7a1af0b10dc6ee2b6de8e5b71e
MD5 0ba76e776210e404f9a0181341d207e9
BLAKE2b-256 5dad0ed598abb39d4328be1569fabe46890b74280ccf9cd10f0ab1bcf87e8c50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d06ed498dc5935cd436191198ec65b25224c7bda1b8ff261c0992d0dac834ec7
MD5 18b4fa2a9ff28dff26673f4988eef81e
BLAKE2b-256 f3fe36ca4d84f51aa26238e0d9eb41cbf9153b8659db3dc494c71970a97b2b52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7de4900925c72a332ca70e816d00f948a4b7dc757ab065dae6b2f421c94ea405
MD5 300e9a7e9fa41f3fac57fc4103043bf5
BLAKE2b-256 30b9c5dcafc90dec17bbf1405c96dec046fb9b282f9cb8dc8c42311cf40df6ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a95107f08449de14608ff050e5c15da68e9d2876d03e73428a97b3229aad2855
MD5 52df57f383b2efb6a3aaa0ee04d4d624
BLAKE2b-256 9e2bac47b3aedb17f864a738f60f50864669167b52f47ff5e1c3b5a70c70dc9c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 75d2041a26218e0797cfb5f17674cced2f0a42aff7f8fc424e2048ed18489e90
MD5 910e8345b7da45eba5ca78f86df69055
BLAKE2b-256 682b389b5812ae1d8bd58899bd02ad68e03ff5807b8214097a3c54b96a0146b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cffc8ebc4fff1ce6997c12ba1196a03db285428d57546f9aff57184548e4791f
MD5 c5479a54358b1ace75feb762d5334488
BLAKE2b-256 c1a1ea0396d49ef02fecc76c4ca8df02c1dfa88162665f9653f98c53f14d3a5a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4e661e2726037c31050d54233f4041b5103793f7d2b1e4eb6b0e513da346489d
MD5 14a86533301d67d929d90de61d392afe
BLAKE2b-256 da6dfe4edeb9c920016075c5aff9f3e4015aed4f5f110b10399c295f391610d6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gambaterm-0.12.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 175.1 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.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c78a0dd752b17f2cb873ddb030ef233e82cae368dfe150fb00d866d2a023f574
MD5 26bb038060f195a055ea6362b9b9ab3a
BLAKE2b-256 9ecce673ead5fe351245f2e92e3e0fa1fb7180306ca52dc4295e2bf4cb68e1f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2fba5d899f46465fed808f54eb48f5a46ecff443d5dc029ee190d0006f51269a
MD5 ab0349cab274549c2b6aa415bf22643e
BLAKE2b-256 6c56c312fa94aa77d7c09e9c1e22765cc3d05ff1ab39f09e59a1ac5ea840167b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 900fabe6470cabe062bbebde8326b5fcfc48400deb43f85c24ea4e21a38ddf42
MD5 7d8f612528e8c847edf998c8cf256995
BLAKE2b-256 28ebee99246117ad8a7cfc86c8b799e566a651eca84b345eb8beff72210fa809

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gambaterm-0.12.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 174.7 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.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 eeda2a26b810a168c7ee1fbdba721aceb79f8542fc3b7f2aa851eb900debc347
MD5 fe30dea6ca9f68c5a7172dd94fb8b54f
BLAKE2b-256 4ec401923a87bd42a9b9fa89fb365411d03c31e315a2bff588fc0b14b935d3dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ec04f3c6880caa7d0a2001faa7b69ce62f8fec14c10047a180898eab88cd565d
MD5 aa3eef8ddbbfa1483dc000c4423d7950
BLAKE2b-256 d9a25486be0dc0d5f2f60b39207e3f829f63d5f914bdd3782c4815d1a39f18f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ba938159e1b5bec86ccb4c1a9fdc858fb61c8ebdcdf6d50aae53070314144840
MD5 08f0bfefd4b03006019537d3fb41eca7
BLAKE2b-256 c0252b53feac42b1e874125c12382fef8e31afd30215b0fc0867a8e7e9b055c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 5184003f79ae183866b87c36057085471eb253cc10005cdfbc49cacc5fc5f76e
MD5 5b40c7d8a25ec5abc77aacf7a8e99f9a
BLAKE2b-256 317ca0310e2ef437447632904e072d44bdf543fa944800085b49b75f2e4356d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b4655172f7114502713671d0c0cf4da305cb76fb4d43b4a58e8994cabd09e315
MD5 e6f9a2506d81adaa303b7ffb22ceedd5
BLAKE2b-256 d3e797597e8ea8be8f0667e52a3e7565c0d4d7d1ffdbd8fabf2715dec09f959e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gambaterm-0.12.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ee328959cd658a2f093a710f02081a084a5934cdc99de95c9d3a8ea06f761f55
MD5 1d626987cd5586140b33f393a0e881dc
BLAKE2b-256 0210000f89a917e1a0b5a7a6b8a660a72c52d6382ac80df6d2d4082474539b95

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