A RetroArch (libretro) core for CHGame handheld games (.CHG files), for Android (arm64) and
Windows. It is a thin libretro front end, libretro/libretro.c, around joyrider3774's
CHGame Emulator, which models the whole
board at the cycle level: the CH32X035 RISC-V CPU, interrupts, timers, SPI and DMA, the ST7735
screen, the buzzer, the microSD card and the real bootloader.
| Content | .chg (also .bin, .hex, .elf) |
| Video | 128 x 128, 60 frames a second, aspect 1:1; an option sends it at 2x-6x, nearest neighbour |
| Audio | the buzzer at 48 kHz: the bare pin signal or a piezo-like filter, volume |
| Saves | the flash pages a game writes, as <game>.sav in RetroArch's save folder |
| Save states | yes |
| SD card | put .DAT files beside the .CHG; the core stages them in <saves>/chgame/sdcard/ |
| Buttons | d-pad or left stick, CHGame A = the bottom face button, B = the right one, Start = Select, Select = Start (CHGame has A and Start on the left) |
Download from the releases page, with chgame_libretro.info:
| File | For | Rename to |
|---|---|---|
chgame_libretro_android.so |
RetroArch on Android | (keep the name) |
chgame_libretro.dll |
Windows | (keep the name) |
chgame_libretro_linux_aarch64.so |
ROCKNIX and other aarch64 Linux handhelds | chgame_libretro.so |
chgame_libretro_linux_x86_64.so |
Linux PCs | chgame_libretro.so |
chgame_libretro_macos_arm64.dylib |
Macs with Apple silicon | chgame_libretro.dylib |
Put the core in RetroArch's cores folder and the .info in its info folder. The Linux x86-64
and macOS files come from GitHub's build and have not been played on yet. Installing on Android
and Windows, ES-DE, Daijisho: docs/GUIDE.md.
chgame_libretro.so (ROCKNIX and other aarch64 Linux devices) can translate the game's code to
native code. That is faster than the interpreter and gives identical results. The core option
chgame_jit has three values:
- Auto (default): JIT on Cortex-A53 and Cortex-A55 CPUs (Allwinner H700, Rockchip RK3566), interpreter on any other CPU or if the CPU can't be read.
- On: always use the JIT.
- Off: always use the interpreter.
Checked on an H700 and an RK3566 (about 15 games). If a game closes straight back to the front end
or shows a black screen, set the option to Off and open an issue naming the device. Most games
already run at full speed with the interpreter. Windows, Android and macOS builds always use the
interpreter. On ROCKNIX the option is saved in config/CHGame/CHGame.opt (chgame_jit = "Off").
Core 0.6 widens the JIT's instruction-cache flush to address an intermittent Cortex-A55 crash; Auto uses the JIT only on A53/A55.
On Windows with zig on the PATH (no make needed; Makefile holds the same Windows recipe):
./build.sh windows # build/chgame_libretro.dll
./build.sh android # build/chgame_libretro_android.so (Android arm64)
./build.sh harness # build/harness.exe, a test front end
zig has no Android C library, so the Android build compiles against zig's musl headers, links
no C library of its own and names libc.so, libm.so and libdl.so through empty stubs;
libretro/android_shim.c maps musl's __errno_location to bionic's __errno.
tools/elfcheck.py checks the result. Android 6 or newer.
build/harness.exe build/chgame_libretro.dll game.CHG 10 outdir --sys sysdir --save savedir
runs a game headless, writes a frame a second and the sound, and prints the speed. On a PC the core runs 6-7 times faster than real time on one core.
- CHGame Emulator by joyrider3774, MIT licence (
emu/LICENSE): all of the emulation, unchanged at the commit inEMULATOR_VERSION.txt. - CHGame by Kevin Bates (bateske), https://chgame.website, Apache-2.0. The bootloader embedded in the emulator is MIT.
libretro/libretro.hfrom libretro-common, by the RetroArch team (MIT-style licence in the file).- The libretro wrapper and tools: jadflat, MIT licence (
LICENSE). SeeNOTICE.