Pinyol for ESP32-S3
An ESP32 audio project for ESP32-S3 involving Microphone, Speaker, SD card.
Parts and sourceBefore you start
Check the exact Microphone, Speaker, SD card configuration against the upstream wiring or parts list.
Upstream README
pinyol
Play every example in your browser, with the engine's measures on the console.

A small C engine for 2D games on the Cirera console, an open-source handheld built on an ESP32-S3 (480×320 touch screen, buttons, speaker, microSD).

A game is a folder: copy it to the console's microSD under games/<id>/ and it appears in the game list. The same folder runs in a desktop simulator and in the browser. There are two kinds:
- Lua games (
"engine": "pinyol@2"), any genre. The engine gives them a virtual console modelled on the Game Boy Advance: four background layers (tiles, rotated and scaled, Mode 7), 128 sprites, palettes, transparency, windows, mosaic and per-line effects, with text drawn on top at full resolution. They hold 60 fps on the console. Beyond the screen and the buttons: the microphone (level, pitch, claps, recordings), stories written as plain text, a song's clock for rhythm games, bodies that tip over, roll and float, video clips on canvases, the console's LED and battery, and consoles playing together. The API: docs/lua.md. - Adventures made of data (
"engine": "pinyol@1"): JSON for zones, dialogues, items, puzzles and events, no code. The engine's first games were made this way: docs/game-format.md.
A game looks like the console it is made for, and the engine moves them all: pick a look and follow its recipe in
docs/art.md. Each picture is a moment of play in that look's example (docs/looks/shots.sh
takes them again).
![]() |
![]() |
| Game Boy: cerezo, a Zelda-style adventure | ZX Spectrum: socavon, a mine, from the tape loading |
![]() |
![]() |
| Game Boy Advance: botin, a treasure-hunting platformer | SNES / Mega Drive: poncho, a giant playroom |
![]() |
![]() |
| Neo Geo: paella, a run and gun | CPS2: taller |
![]() |
![]() |
| PICO-8: tumba, a sliding puzzle | Pocket LCD: malabar, a Game & Watch |
![]() |
![]() |
| Vector arcade: pozo, no pictures | Vertical screen: traca, the console on its side |
![]() |
![]() |
First person: celler, raycast() |
ZX Spectrum: socavon's tape loading |
![]() |
![]() |
| PlayStation / Saturn 2D: faro | PlayStation / Saturn 2D: its boss |
Quick start
macOS: brew install cmake sdl2 uv. On Linux, install the same three with your package manager (libsdl2-dev).
cmake -B build && cmake --build build
./build/pinyol_sim --game examples/botin # or naves, carreras, hola
ctest --test-dir build # validates every example and plays its test script
| Action | Keyboard | Console |
|---|---|---|
| Move | Arrows / WASD | D-pad |
| A: interact, advance, jump, fire | Enter, E, Space, Z | A |
| B: back | Esc, Backspace, X | B |
| Cycle target, puzzle help | Tab, C | C |
| Bag | I | MENU |
| Pause | P | START |
| Touch | Mouse | Screen |
| Restart the game (the simulator also restarts it when you save one of its files) | F5 | |
| Screenshot (PNG), the cover from the screen, record the play as a test script, the last 8 s as a GIF | F6, F7, F8, F9 |
Make your own game
With a coding agent
On a Mac, install Homebrew (it brings git and Apple's compiler with it) and an agent, for example
Codex: brew install codex, then codex login with a ChatGPT account. Clone this repository, open the agent in its
folder (codex) and ask for the game you want, in any language. It reads AGENTS.md, installs what is
missing (approve it when it asks: installing runs outside its sandbox), builds the engine, makes the game in
games/<id>/ and plays it with a test to check it. ./build/pinyol_sim --game games/<id> plays it on your screen.
The site's ladder shows five games Codex made this way, from a paddle game to a
Mega Drive speed platformer, each with its request, its time and tokens, and its frame rate on the console.
Without code: the editor

LÍNEA 0, a Game Boy Advance game made entirely with the editor, live, here sped up: the whole video.
editor/ is a web page for making a game without programming: draw the pictures pixel by pixel (with frames for
animation) or bring them in from image files (PNG with transparency, JPG, a row of frames; dropped or pasted), in
any of the console's colours; paint the levels' maps with them and put the objects on them (a player who walks and
jumps, enemies that patrol or chase, coins), with up to three pictures behind each that move slower than the camera,
and a cover before the first; make the sounds from recipes (coin, laser, explosion, jump...) or bring them in from
files (WAV, MP3, OGG...: effects, and music for each level and the cover, cut and made louder or softer), or compose a
song on a grid (melody, bass and drums, in a scale where every note fits); write the rules
with blocks ("when the hero touches a coin: remove the other, play coin, add 1 to points"; "when the hero touches
the flag: go on to the next level"), and with the blocks of Diálogos (characters who speak and ask, the game waiting
for the answer), Micrófono (when you clap, when you blow, how loud) and Vídeo (a video brought in from a file or a GIF,
over the whole screen or in a window), and Guardar (a record or progress kept in the console); music can also come as a
tracker's .mod. The cover is also the game's picture in the console's menu, with a line, an author and what it is about.
Jugar plays it right there; Pasar a la consola sends it over the USB
cable (Chrome and Edge, with Web Serial) or gives the zip for the card. A short guide walks a first-time user through
it (again with ?); everything works from the keyboard too, and on a phone or a tablet. A game takes a look
(Game Boy, PICO-8, ZX Spectrum, 16 bits, or free): its console's colours for every drawing, its tiles (8 or 16
pixels), its letters and the colours of its texts; and a language for the sentences the engine says. Objects can have
named animations (still, walking, hit), and the Lives and time blocks put hearts and a countdown on the screen.
Nuevo starts from one of six games to change, each with its own drawings, levels and rules: a platformer, an
adventure seen from above (keys and doors), a space shooter, a box-pushing puzzle and Abella, a whole Game Boy
game in three levels (made live in the editor, and the first game in the site's Library), and LÍNEA 0, a
Game Boy Advance game in five levels of five genres about a metro that does not obey its own rules (made live too: its
video is on the site). The interface is in
Spanish, Catalan or English (chosen in the header, Idioma). It needs the web player beside it (see below to build it):
python3 tools/make_editor.py dist/editor --player build-web
python3 -m http.server -d dist/editor # open http://localhost:8000
The editor keeps the project in the browser (IndexedDB) as it changes; Guardar archivo saves it to a file (.pinyol.json) and
Abrir opens it again. The game it makes is ordinary Lua on the kit library (lib/kit.lua), so it
can be carried on by hand; it carries its own copy of kit, so it plays the same on a console with older firmware.
In Lua
uv run tools/new_game.py games/mygame --lua --title "My Game"
./build/pinyol_sim --game games/mygame
You get a small game to change: a room bigger than the screen, a character to walk around it, gems to pick up, sounds and a best time saved. main.lua is the game, room.lua the room as text, and art.py draws the art and converts it (replace its PNGs with your own and run it again). docs/tutorial.md takes it from there step by step, to a game on the console and in the browser. Levels can be drawn in Tiled and imported with tools/tiled2asset.py, or in LDtk (its simplified export, tools/ldtk2asset.py); a character drawn in Aseprite comes in straight from its .aseprite, frames, tags and slices, with tools/ase2asset.py; tools/pack_game.py --budget says what a game weighs. Art made with an image model (backgrounds removed, frames cut, scale and feet fitted): docs/art.md. Everything else is in docs/lua.md, and the examples show more:
| Example | What it shows |
|---|---|
| botin | a treasure-hunting platformer as the Game Boy Advance's: four worlds (jungle, a lit cave, a sunken galleon, a forge), four jewel pieces in each, a ram that breaks blocks and a smash from above, enemies to stun, pick up and throw, a frog switch that starts a timed escape, a golden Golem for a boss; the hills and sky painted into one layer cut in two bands that scroll at their own speeds, 16-colour palette banks that recolour one picture, ripples on the water, heat haze in the escape, mosaic changes of scene, turned sprites for the boss, music from a bank of samples, and a menu that takes the screen apart and says what each effect costs |
| naves | a shoot-'em-up: a star field with a speed per line, a turning planet, blended explosions, a flash |
| carreras | a kart race in Mode 7: a perspective floor, rivals as scaled sprites, laps and positions |
| puzle | a sliding puzzle for the touch screen: a ghost hint by blending, a mosaic reveal, music made of notes |
| stylus | the touch screen as the DS used it (lib/pointer.lua): shapes drawn and recognised, a box dragged, a flick's direction |
| dedos | every finger on the screen, the pinch two make, how much a finger held still shakes: to try a touch panel |
| dos_pantallas | two screens in the simulator ("screens": 2): a close view above, a touch map below; a tap picks, a flick sends |
| aldea | a top-down adventure: a village drawn in Tiled, people with typed-out dialogue, tree tops you walk behind |
| estilos | a game's own look: fonts from the library, outlined and wavy text, frames cut from a picture, turned pictures |
| inventos | toys of no genre, from code alone: painting, land that breaks, generative trails, 3D triangles, a split screen |
| juntos | consoles playing together over the air (ESP-NOW, no router): a shared whiteboard, a ball passed from screen to screen |
| paella | a run and gun as Metal Slug's, with its own jokes: six cooks (homages with invented names) against a mechanical seagull army along a harbour, a main street and a beach, a tractor with a sardine cannon, grannies to free, food for score and a giant seagull boss; every pixel at the native 480x320 from packed pictures, characters painted with an image model and fitted in code (50 whole-body frames a cook, so every aim goes with every step; a clockwork-seagull boss of 42 frames), music as MIDI on a sample bank, and a menu that explains the Neo Geo's tricks |
| nubes | a horizontal shoot-em-up over a sea of clouds: drones in formation, a battleship that fills the sky with orbs (swarms) |
| calle | a beat-em-up on a neon street at night: depth, groups of thugs, the camera stopping at each fight |
| futbol | five a side on a pitch twice the screen's width: four kits that are one picture in four palettes |
| moto | a motorbike race: the road on the world's Mode 7 floor, the coast, the roadside and the rivals at full resolution over it |
| duelo | a fighting game as a Neo Geo's: every pixel at 480x320, a stage in two layers, fighters in 192x184 frames as packed pictures, hit flashes and sparks, a rival played by the console |
| taller | a beat 'em up as the CPS2's: three clockmakers in clockwork exo-frames (parts torn from broken automatons change how each one fights) against rebel automatons through a street, a factory and a clock tower, to a giant clock; every pixel at 480x320, characters in 15 colours painted with an image model and fitted in code (43 frames each, second colours borrowed from another palette), floors where depth decides what is in front, pillars at the seams, ten songs as MIDI and a menu that explains the CPS2's tricks |
| mazmorra | a beat-em-up in a dungeon as a CPS2's: goblins and skeletons in groups, torches that flicker, pillars that pass in front of everyone |
| cerezo | a top-down adventure as the last Game Boy ones: a world of screens that slide, a dungeon, a boss, dialogue, four tones that C changes into the Color's palettes; art and music made by code |
| socavon | a one-screen mine platformer as a ZX Spectrum's, from the tape loading (striped border, the screen in its own order): eight rooms, blocks of two colours, sprites that clash, flashing keys, belts, crumbling floors, a beeper voice, and a menu that shows the attributes |
| poncho | a side-scrolling platformer as the 16-bit consoles made them: a three-year-old hero runs, jumps and scoots across a giant playroom, with costumes that give him powers |
| tumba | a sliding puzzle as a PICO-8 cartridge: sixteen tomb levels on a 128x128 screen in its sixteen colours, each with a par (the fewest moves, found by a solver); mud, cracking walls, teleporters, keys, one-way gates; four chiptune channels; and a menu that shows what a cartridge is made of |
| malabar | a pocket LCD game as a Game & Watch: a juggler throws balls from hand to hand and you catch them in time; every figure is a fixed polygon either on or a faint ghost over a printed circus, the score in seven-segment digits, a step and a beep at a time, games A and B, a clock when nobody plays, and a menu that shows what a segment screen is |
| pozo | a vector arcade shooter down a geometric well: bright lines with a glow, even the letters, no pictures; its menu replays a frame line by line, as the beam drew it |
| traca | a vertical shoot-'em-up at a village festival: a fireworks rocket climbs among lanterns and bullets, played with the console on its side, a standing canvas shown turned |
| celler | first person as 1992 drew it: a night watchman with a candle that burns down crosses cava cellars, sliding doors and secret passages, drawn by raycast() straight onto the screen |
| faro | a platformer up a dark lighthouse on a stormy night as the 32-bit consoles made them: the keeper's daughter calms the ánimas of drowned fishermen with her lantern held high and leads them to the windows, floor by floor, to relight the lamp against the Octopus of the Storm; every picture painted with an image model at 480x320 in 256 colours, light added and ghosts half seen through, gears, tentacles and the lens as quads, water rippling over the whole screen, ADPCM sounds and MIDI habaneras in one reverb room, and a menu that explains the PlayStation's tricks (it will replace gotico once it is measured on the console) |
| psx_views | one actor and three staged PS1-style cameras: lateral, fixed with foreground occlusion, and a corridor seen from behind; the same position and state survive every cut |
| psx_demo | a small 32-bit hall drawn by code alone: a perspective floor and a swinging sign with quad(), a dithered sky with grad(), a light that adds and a shadow that subtracts, and ADPCM sound with envelope, pan and the PlayStation's reverb rooms |
| selva | a runner as the 32-bit consoles drew them: the camera behind a fox that jumps crates, picks fruit and dodges pits down a path between trees; every solid a few textured faces with mesh(), flat light, fog and trembling vertices, and a menu that switches each trick off |
| niebla | a street at night, a torch and something that follows, as the fixed-camera horror games of the 32 bits: the camera cuts when you cross the street, tank controls, fog that hides what is far, a radio that crackles as it comes near; all mesh() |
| cajas | a one-on-one fight of boxy fighters as the first 32-bit fighting games: side camera, punch, kick, sweep, block and jump, best of three rounds against the machine; each fighter eleven textured boxes moved with kinematics in Lua and drawn with mesh() |
| recortes | call-and-response rhythm with paper-cutout characters as the 32-bit rhythm games: the toad master sings a phrase on the buttons and you sing it back in time; the dolls are quads that fold like paper, the set runs on the PPU's layers, the music plays live on the synth's voices |
| sonidos | sounds made from numbers (a factory of coins, lasers, explosions), a theremin, an engine that follows the speed, music in layers, a keyboard that plays one recording as any note |
| control | directing a 1994 newscast from the control room: cuts, tape and captions on the beat of the theme, the producer's lines written as a story in Catalan and Spanish, the console's LED as the tally light, a video clip on a monitor; then a camera that does not exist looks at you, hears you and knows your battery |
| raton_de_biblioteca | made by Codex from one sentence on a fresh clone: a Game Boy-look mouse in a library, cheese and cats (then put on the whole screen by hand) |
| oxigeno | made by Codex from one sentence: a ZX Spectrum-look astronaut after oxygen bottles, with its tape loading screen |
| museo_nocturno | made by Codex from one sentence: a first-person museum at night, five stolen paintings and guards |
| paletes | made by Codex from one sentence: paddles and a ball against the console, in vectors, to 7 points |
| cripta | a metroidvania in eight rooms, each its own Tiled map imported with tools/tiled2asset.py and placed in the castle by two map properties: wings for a second jump, a gust that breaks cracked walls, each power opening the way to the next, statues that save, a map of the rooms walked and a gargoyle; a solver proves the castle is finished in that order |
| horizonte | a whole day over the sea in a handful of palette entries, recoloured line by line with line_pal and line_pal_obj: the sky deepening upwards, the clouds lit from below, the sun reddening as it sets, the water glinting under it and a boat's sail painted by the sunset; A shows it without |
| isla | an isometric island in the way GBA games drew one: the ground one tiled background, and every column, crate, palm, gem and the hero sprites given their numbers again each frame by depth, so the hero goes behind one tower and in front of another; five gems, some walked and jumped to, others reached by pushing a crate against a pillar or into the sea to cross it |
| sima | a turn-based roguelike in the way of the GBA's Mystery Dungeons: five floors made from the run's seed (a new one from the ticks it took to press A, or the day's for everyone, from clock()), written into a background cell by cell with mset, the fog of what has not been seen on a second background over the sprites, and monsters that chase the hero down one grid:distances field; a bot plays a whole run in the tests |
| microjuegos | WarioWare-style: eight games of a few seconds (press, dodge, count, mash, search, turn, keep still, a boss), four lives, a speed that goes up every four; each one leaves something on the picture or the sound on purpose (a fade, a round window, a mosaic, a note, the LED) and scene.go(..., {clean = true}) puts it all back; a demonstration played by the games' own bots |
| tablero | turn-based tactics on a grid, in the manner of Advance Wars: two armies of four on a 15 x 10 field with forest, mountain, a river and two bridges; reach, paths, distance fields and a danger map from grid, highlights on a second layer of the picture (mset, blend), an AI that decides with what the player has, and a demonstration of the AI against itself |
| combate | a small RPG: a meadow, tall grass that hides enemies, and a fight by turns that begins with the picture's own effects (flash, a ripple line by line, mosaic, an iris with line_window); enemies turned and scaled by a matrix, menus, a party that levels up and is saved |
| pinball | a whole table on the screen, three balls, four bumpers and two flippers that turn about their ends (physics and its w:drive), a spring you pull with DOWN, a ball saver |
| costa_relampago | made by Codex in three requests (the game, its generated art, 60 fps on the console): a Mega Drive-look squirrel on a coast, layers at their own speeds and a sea moved line by line |
As an adventure made of data
uv run tools/new_game.py games/mygame --title "My Game"
./build/pinyol_sim --game games/mygame
./build/pinyol_headless --game games/mygame --validate # every ID exists, every text fits
new_game.py writes a tiny but complete game: two zones, a player, a friend with a dialogue choice, a key, a locked door, a chest and the end screen. All its art is placeholder drawn by code. Then make it yours:
- Text and logic are JSON. The full reference is docs/game-format.md.
- Art: draw a PNG and convert it under the same ID. Character sheets are horizontal strips in direction order N, E, S, W.
uv run tools/png2asset.py street.png games/mygame/assets BG_Z01 --type background uv run tools/png2asset.py hero_walk.png games/mygame/assets PJ_WALK --frames 16 --ms 125 --anchor 12,29 uv run tools/png2asset.py fighter.png games/mygame/assets SPR_KAI --frames 11 --packed # big art: its own palette, a quarter of the memory - Sound: WAV, PCM 16-bit mono at 22,050 Hz.
- Fonts:
tools/font2fnt.pyturns a TTF, OTF, BDF or PNG sheet into the engine's FNT format; twelve free pixel fonts come with it (third_party/fonts), so each game can have its own letters. - The careta: every game opens with POWERED BY PINYOL. A Lua game can have its own, in its own style, with the seal on it (docs/lua.md,
examples/careta);pinyol_sim --no-splashskips it while you make the game. - Tests: a script plays the game with real input and checks flags, zones and screens. See tests/hola.script; run it with
./build/pinyol_headless --game DIR --fresh --script FILE, andtools/record.sh DIR FILE out.mp4records the run as a video.
A game in its own repo
A bigger game can live in its own repository and build pinyol as a subproject, with its own tests:
cmake_minimum_required(VERSION 3.21)
project(mygame C)
set(GAME_DIR ${CMAKE_SOURCE_DIR}/games/mygame) # what pinyol_sim and pinyol_headless open by default
add_subdirectory(../pinyol pinyol) # pinyol_core, pinyol_headless, pinyol_sim
enable_testing()
add_test(NAME validate COMMAND pinyol_headless --game ${GAME_DIR} --validate)
The data adventures pinyol started with are built this way.
The engine's checkout is found by the game's scripts through PINYOL_ENGINE (a path; ENGINE in some) and, failing that, a
sibling folder: export PINYOL_ENGINE=/path/to/pinyol works wherever the game's repo lives.
Share a game, play it in the browser
python3 tools/pack_game.py games/mygame -o dist/ # -> dist/mygame.zip, a folder mygame/ inside
Unzipped into the card's games/ folder, the game is installed. The same zip plays in a browser: the simulator builds with Emscripten into player.html, which plays any game's zip, given as player.html?game=URL or dropped on the page, with on-screen buttons on phones, a gamepad over USB or Bluetooth (standard layout: the bottom button is A), and saves kept in the browser. ?lang=ca or ?lang=en puts its words in Catalan or English.
emcmake cmake -B build-web -DCMAKE_BUILD_TYPE=Release
cmake --build build-web --target pinyol_player
cp dist/mygame.zip build-web/
python3 -m http.server -d build-web # open http://localhost:8000/player.html?game=mygame.zip
The pinyol_web target makes index.html instead, with one game (-DGAME_DIR=...) packed inside.
A whole shelf of games, each playable and downloadable, with a picture of its title screen:
python3 tools/make_gallery.py gallery/ --player build-web --headless build/pinyol_headless examples/*
python3 -m http.server -d gallery # open http://localhost:8000
A finished game can go in the site's Library, to be played there and downloaded for the console: send it with a form, a robot opens it, plays it for ten seconds and, once we review it, it shows up there.

From your game to the Library, sped up: the whole tutorial.
Run it on the console
The quickest way: the site installs the latest release on a board over USB, from Chrome or Edge, with fifteen games in its flash.
The firmware in firmware/ is the console's platform: screen, touch, buttons, audio, microSD, battery and updates over the card. It needs ESP-IDF 5.4.
For signed OTA updates and Secure Boot v2, follow the secure firmware guide. Provisioning burns eFuses irreversibly.
. $IDF_PATH/export.sh
cd firmware
idf.py build
idf.py -p /dev/cu.usbmodem1101 flash # your board's port
A game can also go over the USB cable, straight from the editor (Chrome or Edge) or from a terminal: the console writes it to the card (or, with none, its flash) and starts it.
uv run --with pyserial tools/send_game.py games/mygame # a game folder, or a game's .zip
The firmware also bakes games into the flash, so the console works without a card: examples/hola by default, or a list, idf.py -DFLASH_GAME="/abs/a;/abs/b" build (then flash build/game.bin too, at 0x420000). Every other game goes on the microSD (FAT32) as games/<id>/. Holding MENU for two seconds leaves a Lua game for the list. To update the firmware later, copy build/pinyol_console.bin to the card as firmware.bin (a console that runs a build of main from 2026-10-21 or 2026-10-22 cannot do it: its flash driver corrupted memory on the erase; the released firmwares, 0.3.0 and before, never had that driver; flash it once by the cable, esptool write_flash 0xf000 ota_data_initial.bin 0x20000 pinyol_console.bin).
The console starts in Cirera's menu, which is itself a pinyol game (firmware/cirera) baked
into the flash with the firmware: an animated intro, then every game as a card with its cover, to pick with the
d-pad and A (B asks before turning the console off). A game's cover is its cover.rgb565, a 240×160 picture that
tools/cover.py takes from a moment of play; without one, its title screen (assets/BG_TITLE) or a card with its name.
Pins and peripherals, each with its source: docs/hardware.md.
Cirera on your computer: Mac, Windows and Linux
The console as an app: its menu, the examples inside, and any game's .zip dropped on its window, installed. Download it
from the release "cirera" or the site, which says how to open it the first time (Apple
and Microsoft have not signed it yet). Its games and saves go to ~/Library/Application Support/pinyol/Cirera on a
Mac, %APPDATA%\pinyol\Cirera on Windows, ~/.local/share/pinyol/Cirera on Linux (x86_64 or aarch64, glibc 2.35 and
up; a dropped game is unpacked with unzip).
It is pinyol_sim built as the app, and tools/make_app.py packs it:
cmake -B build-app -DCMAKE_BUILD_TYPE=Release -DPINYOL_APP=ON
cmake --build build-app --target pinyol_sim # -> build-app/Cirera (Cirera.exe on Windows)
python3 tools/make_app.py build-app/Cirera -o dist/ # -> dist/Cirera-mac.zip (Cirera-linux-*.tar.gz on Linux)
The app asks GitHub once at start (a thread, curl, nothing is sent but the request) whether a release newer than its VERSION exists and, if so, tells the player once for that version, with a button to its page (the console itself only changes its firmware by a firmware.bin copied to its card). PINYOL_NO_UPDATE_CHECK=1 turns it off. The release process bumps VERSION.
The Windows app is built from a Mac or Linux with MinGW-w64 (cmake/mingw-w64-x86_64.cmake).
.github/workflows/desktop.yml builds them all with SDL inside, so they need nothing
installed, and opens each one on its own system before publishing it. The simulator plays the console too:
pinyol_sim --console examples --menu firmware/cirera.
Play it in RetroArch: RetroPie, RetroBat, Batocera, Lakka
The engine is also a libretro core, which plays a game's zip in RetroArch and in everything built on it, a Raspberry Pi with RetroPie among them:
cmake -B build-release -DCMAKE_BUILD_TYPE=Release
cmake --build build-release --target pinyol_libretro # -> build-release/pinyol_libretro.so
How to install it, the controls and what it does not do yet: docs/libretro.md.
How it is built
src/ the engine, portable C11: no SDL or ESP-IDF headers (hal.h is the whole platform contract)
ppu.c the virtual picture processor (layers, sprites, effects) that Lua games draw with
lua_game.c pinyol@2: the Lua sandbox and its API
platform/sdl/ desktop simulator, the Cirera app (-DPINYOL_APP=ON), and the web players when built with Emscripten
platform/desktop/ the app's icons
platform/null/ pinyol_headless: validator and test runner without a window
platform/libretro/ the libretro core, for RetroArch and RetroPie
platform/web/ the web pages around the players
site/ the site (https://pinyol.ipaud.dev/), built by site/build.py in Spanish, Catalan and English
firmware/ the console: ESP-IDF project, builds src/ unchanged; cirera/ is its menu, a pinyol game
examples/ games as they go on the microSD: fifty in Lua, hola as data
templates/lua/ the game new_game.py --lua starts from
tests/ test scripts for the examples, and the PPU's own tests
tools/ new_game.py, png2asset.py, tiled2asset.py, pack_game.py, make_gallery.py, font2fnt.py, clip2npv.py, ...
lib/ Lua libraries built into the engine, require()d by any game: juice, particles, physics, keyboard, kit, story
editor/ the web editor (plain HTML and JavaScript, no build step) and Blockly in vendor/
third_party/ cJSON, Lua 5.4, pocketmod, puff (unzip), libretro.h, the Pixelify Sans font and a library of pixel fonts (fonts/)
The world is 240×160 logical pixels drawn at 2× into a 480×320 frame; text and UI use the full resolution. Logic runs at 60 ticks per second on every platform. On the console the frame goes to the panel in 32-row strips drawn straight from the game while the previous strip is sent, in step with the panel's refresh; a Lua game's picture is drawn by both cores. How it got fast enough, measured: docs/measurements.md.

In slow motion: a real frame takes 16.6 ms; here, 2.4 seconds. Red, core 0; yellow, core 1.
Status
pinyol was first written for two data adventures, and then opened up with Lua for any genre. What to know:
- The Lua API (
pinyol@2) is new and may still change; the data format (pinyol@1) is stable. - The built-in interface text of data adventures (menus, pause, bag) is in Spanish.
- Some pinyol@1 defaults come from the first game: without a
"player"ingame.jsonthe player isKLAUSwith sprite prefixKL, and the start zone defaults toZ01. Set them in yourgame.json. - What was done and measured, step by step: docs/progress.md.
- pinyol was first called np2d: games whose
game.jsonsays"engine": "np2d@1"or"np2d@2"still run, and a game's repo can still use the targetsbp_core,bp_headlessandbp_sim.
License
pinyol is MIT licensed (LICENSE). It includes cJSON (MIT), Lua 5.4 (MIT), pocketmod (MIT), puff (zlib), libretro's libretro.h (MIT), the Pixelify Sans font and the pixel fonts in third_party/fonts (all SIL Open Font License 1.1). The editor includes Blockly (Apache 2.0). The site serves ESP Web Tools (Apache 2.0) to install the firmware, and GoatCounter's count.js (ISC) to count visits; the firmware is built with ESP-IDF (Apache 2.0, with parts under MIT and BSD licences) and the web player with Emscripten and SDL2. The desktop app carries SDL2 (zlib) and, on Windows, MinGW-w64's runtime (ZPL 2.1 and MIT). Every notice they ask for is in THIRD_PARTY_NOTICES.md, which also goes with each release.
The pictures, sounds, music and video of the examples, the template and the tests were made for pinyol, generated
with an image model or drawn and synthesised by code (each game's art.py and art/): they are dedicated to the
public domain (CC0 1.0), to use in your own games as you like.
Game Boy, Game Boy Advance, PlayStation, Saturn, Mega Drive, Super Nintendo, Neo Geo, CPS2, PICO-8, ZX Spectrum, Wolfenstein 3D and the other consoles and games named here are trademarks of their owners. pinyol and Cirera are not affiliated with them or endorsed by them: the names only say which look a game takes after.













