| assets | ||
| cmake | ||
| docs | ||
| include/fxCGIO | ||
| pc | ||
| src | ||
| tests | ||
| .gitignore | ||
| build.sh | ||
| buildall.sh | ||
| cleanall.sh | ||
| CMakeLists.txt | ||
| giteapc.make | ||
| maketargz.sh | ||
| makezip.sh | ||
| README.md | ||
| runprog.sh | ||
fxCGIO !!
Terminal / Console / IO Library for Casio fx-CG50 / fx-CG90
Overview
When I started developing on the Casio fx-CG50 with the excellent fxSDK by Lephenixnoir, I quickly found that every single project needed the same boilerplate code: setting up keyboard polling, managing display output, handling colors, and implementing the same basic I/O loop over and over again. The calculator has a rich 396×224 display and a full keyboard, yet getting a simple printf() to work correctly required non-trivial effort every time.
fxCGIO was created to solve this permanently. It wraps the gint kernel into a clean, Unix-style terminal abstraction, making Casio development feel as natural as writing a program for a Linux terminal. Standard C printf(), scanf() and getchar() all work out of the box — no custom display API needed.
Since then the library has grown to cover multiple color modes (16-color ANSI, 256-color xterm, and 24-bit true RGB), a complete keyboard mapping with SHIFT/ALPHA modifiers and all special keys, a game development API for direct character-grid access (perfect for roguelikes and text adventures), eight bitmap fonts, command history, C++ iostream wrappers, and a full ANSI/VT100 terminal emulator.
The library also targets the PC through a separate CMake build, allowing calculator applications to run on a Linux terminal with full 24-bit color output — tremendously useful for development and debugging without touching the calculator at all.
fxCGIO is based on:
- gint 2.11+ --- https://gitea.planet-casio.com/Lephenixnoir/gint
- fxSDK --- https://gitea.planet-casio.com/Lephenixnoir/fxsdk
Compatibility and Requirements
| Model | Supported |
|---|---|
| fx-CG50 | ✔ Yes |
| PC (Linux x86) | ✔ Yes — via pc/ CMake build |
| fx-CG10 / 20 | ✔ Yes |
| fx-CG100 | ✔ Yes |
| fx9860G-like | ❌ No |
Minimum gint version: 2.11 Build system: fxSDK (calculator) or CMake 3.15+ (PC)
What fxCGIO Provides
Standard Input / Output
Write calculator programs exactly as you would write a standard C or C++ application:
printf()/puts()/putchar()--- write text to the screenscanf()/gets()/getchar()--- read from the keyboard with echostd::cout/std::cin--- C++ iostream wrapper for stream operators- Command history --- UP / DOWN arrows replay the last 20 input lines, just like a real shell
Color System
Three color modes, selectable at runtime, from simple to full true-color:
| Mode | Colors | Notes |
|---|---|---|
| ANSI 16 | 16 | Standard terminal palette, FXCGIO_COLOR_* constants |
| xterm 256 | 256 | 0–15 ANSI + 216 RGB cube + 24 grey levels |
| True RGB | 16.7M | C_RGB(r, g, b) — 5-6-5 packed, hardware-exact |
Keyboard Mapping
All calculator keys are mapped, including multi-modifier combinations. Special keys return negative integer codes (Unicode-safe):
- Printable keys --- Letters, digits, operators via SHIFT / ALPHA modifier state
- Arrow keys --- UP(-2), DOWN(-3), LEFT(-4), RIGHT(-5), HOME(-6), END(-7)
- Function keys --- F1(-8) through F6(-13)
- Shifted arrows --- SHIFT+UP(-14) through SHIFT+RIGHT(-17)
- Alpha arrows --- ALPHA+UP(-18) through ALPHA+RIGHT(-21)
- Shifted F-keys --- SHIFT+F1(-26) through SHIFT+F6(-31)
- Alpha F-keys --- ALPHA+F1(-32) through ALPHA+F6(-37)
- Game polling ---
keydown()/keypressed()for non-blocking real-time input
Game Development API
A direct character-grid API makes it easy to build roguelikes, text adventures, or any tile-based application:
fxCGIO_game_begin()/fxCGIO_game_end()--- frame managementfxCGIO_game_cols()/fxCGIO_game_rows()--- query grid dimensions at runtimefxCGIO_game_put(x, y, ch, fg, bg)--- place a character with foreground/background colorfxCGIO_game_clear(bg)--- fill the entire grid with a color
Bitmap Fonts
Eight fonts are bundled, covering very different styles and cell sizes:
| Font | Size | Grid (cols×rows) | Use case |
|---|---|---|---|
| font5x7 | 5×7 | 66 × 28 | Default — readable, compact |
| font8x9 | 8×9 | 44 × 22 | Larger, easier to read |
| vga | 8×8 | 44 × 24 | Classic VGA CP437 terminal look |
| microfont | 3×5 | 110 × 40 | Maximum density |
| tinytype | 8×8 | 44 × 24 | Small but clean |
| milifont | 5×7 | 66 × 28 | small font retro terminal style |
| thin | 8×8 | 44 × 24 | Elegant thin-stroke variant |
| fantasy | 8×8 | 44 × 24 | Decorative — RPG / game titles |
ANSI / VT100 Terminal Emulator
Full escape sequence support for terminal-style applications:
- Cursor positioning:
\033[row;colH - 24-bit foreground/background:
\033[38;2;R;G;Bm/\033[48;2;R;G;Bm - Text attributes: bold, dim, underline, blink, reverse
- Erase sequences:
\033[K(erase to end of line),\033[J(erase to end of screen) - Scroll region control
Quick Start
C Example
#include <fxCGIO/fxCGIO.h>
#include <stdio.h>
int main(void)
{
fxCGIO_init();
printf("Hello, fx-CG50!\n");
printf("Type something: ");
char buf[64];
scanf("%63s", buf);
printf("You said: %s\n", buf);
fxCGIO_free();
return 1;
}
C++ Example
#include <fxCGIO/fxCGIO.hpp>
#include <fxCGIO/cpp/iostream.h>
int main(void)
{
fxCGIO::init();
fxCGIO::cout << "Enter a number: ";
int n;
fxCGIO::cin >> n;
fxCGIO::cout << "Doubled: " << n * 2 << fxCGIO::endl;
fxCGIO::free();
return 1;
}
or more easy to write :
#include <fxCGIO/fxCGIO.hpp>
#include <fxCGIO/cpp/iostream.h>
using namespace fxCGIO;
int main(void)
{
init();
cout << "Enter a number: ";
int n;
cin >> n;
cout << "Doubled: " << n * 2 << endl;
free();
return 1;
}
Game API Example
#include <fxCGIO/fxCGIO.h>
#include <fxCGIO/game.h>
#include <gint/keyboard.h>
int main(void)
{
fxCGIO_init();
int x = fxCGIO_game_cols() / 2, y = fxCGIO_game_rows() / 2;
for(;;) {
clearevents();
if (keydown(KEY_EXIT)) break;
if (keydown(KEY_LEFT)) x--;
if (keydown(KEY_RIGHT)) x++;
if (keydown(KEY_UP)) y--;
if (keydown(KEY_DOWN)) y++;
fxCGIO_game_begin();
fxCGIO_game_clear(FXCGIO_COLOR_BLACK);
fxCGIO_game_put(x, y, '@', FXCGIO_COLOR_YELLOW, FXCGIO_COLOR_BLACK);
fxCGIO_game_end();
}
fxCGIO_free();
return 1;
}
Build & Install
Calculator Build and install
cd fxcgIO
fxsdk build-cg install
PC Build
cd fxcgIO/pc && mkdir build && cd build
cmake .. && make
# Produces: libfxcgio-pc.a
TODO List
Short-Term (High Priority)
- Standard C I/O (
printf,scanf,getchar,puts) - 16-color ANSI mode
- 256-color xterm mode
- 24-bit true-color RGB mode
- Complete keyboard mapping (all keys, SHIFT/ALPHA modifiers)
- Negative-integer special key codes (Unicode-safe)
- Command history (20 entries)
- Game API (direct character grid)
- Eight bitmap fonts
- Full ANSI / VT100 escape sequences
- C++ iostream wrapper (
std::cout/std::cin) - PC build — Linux terminal with true-color ANSI output
- Windows / WSL PC build support
- fx-CG50 USB serial passthrough for remote debugging
Long-Term (Possible Future Work)
- Soft keyboard overlay (on-screen virtual keyboard)
- Mouse cursor emulation via arrow keys
- Font editor / import tool
- Compressed font format for larger character sets
Version History
Version 0.8
- Initial public release
- Standard C I/O (
printf,scanf,getchar,puts) - 16-color ANSI color mode
- Basic keyboard mapping (letters, digits, arrows, F-keys)
- Default font (5×7)
Version 0.9
- Added 256-color xterm mode
- Added 24-bit true-color
C_RGB()support - Extended keyboard mapping: SHIFT+arrow, ALPHA+arrow, SHIFT/ALPHA+F-keys
- Added command history (up to 20 lines)
- Added C++ iostream wrapper
Version 1.0
- Added Game API (
fxCGIO_game_begin/end/put/clear/cols/rows) - Added 7 additional bitmap fonts (vga, microfont, tinytype, milifont, thin, fantasy, font8x9)
- Full ANSI/VT100 escape sequence support
- Line discipline improvements (backspace, echo toggle)
Version 1.1
- PC build via separate CMake configuration
- PC keyboard driver: termios raw mode + ANSI CSI/SS3 escape decoder
- PC renderer: 24-bit ANSI output, dirty-cell batching, consecutive-cell optimisation
- Unified special key codes between calculator and PC builds
Documentation
Full documentation is available in the docs/ directory:
- Installation Guide
- Getting Started
- Tutorial
- API Quick Reference
- Color System Guide
- Code Examples
- FAQ
Disclaimer
This software is a Work in Progress and is provided "as is", without warranty of any kind. Although extensive testing has been performed, unexpected behavior may occur — especially on edge-case keyboard combinations or in non-standard terminal environments on the PC build.
Please:
- Test new color and keyboard features on your specific calculator model
- Report bugs with the simplest possible reproducer
- Check gint version compatibility before upgrading
The author cannot be held responsible for any issues caused by the use of this library.
Credits
Thanks to Lephenixnoir for his extraordinary work on gint and fxSDK, and for his patience in answering every question about the SH4 internals.
Thanks to the Planète Casio community.



