DINKY programming manual
DINKY is a tiny fantasy games console. Every game lives entirely inside one QR code: no download, no game server, no account. You print the code on a card, a friend scans it, and the game is on their phone, working offline. The machine is deliberately small, in the spirit of the ZX Spectrum: a 256 x 192 screen, 16 colours, one pixel font, a little sound chip, and about 1.4 KB of compressed code per game.
This manual is for people writing games for it. It covers the machine, every ROM call, sound, the rules, the byte budget, testing, and making and sharing cards.
How a game travels
games/mygame.js
-> minify (terser: comments gone, names shortened)
-> deflate (zopfli, raw deflate)
-> base43 (two bytes in three characters, capitals, digits and $*+-./: only)
-> https://your-console/#3<payload> (the "3" is the link format)
-> QR code on a card: the address in byte mode, the game in alphanumeric mode
Why base43: a QR code stores capitals, digits and a few symbols ("alphanumeric" characters) in 5.5 bits each, but anything with lowercase in 8. base43 sticks to those characters, so the game part of the code costs about 8.3 bits per byte instead of the 10.7 base64 would, and each code comes out about four QR versions smaller. Cards from before this change start with #2 and hold the same bytes as base64; the console still reads them, and a game keeps its high scores whichever format its card uses.
The console is a web app (a PWA) that you install once. When it reads a card, it takes everything after the #, unpacks it and runs it. The part after # never leaves the phone (browsers don't send it to servers), so a game plays with no connection at all once the console is installed.
What goes into the link is just the game's title, its spine colour and its minified code. The rest of the header block (tagline, how to play and so on) is only used for the printed card.
Quickstart
Five minutes from nothing to a game on your phone.
- Install the SDK's tools once, from the project folder:
npm install - Start a game. The id is 2 to 20 lowercase letters, numbers or dashes; the title is up to 24 characters.
This createsnpm run dinky -- new mygame "My Game"games/mygame.js(a small working game to change) andgames/mygame.test.mjs(its tests). For a game you steer by tilting the phone, add--tiltto start from the tilt template instead (see Tilt, under Input). - Run the dev console:
Open http://localhost:8080/?dev=mygame (or addnpm run dinky -- dev mygame--opento the command). Every time you save a file ingames/, the game reloads and the terminal shows any lint errors. The browser tab's title shows the current size, the QR version and how many bytes you have left. - Change something. Colours, text, speed. Save and watch it reload.
- Run the tests:
npm run dinky -- test mygame - Build the cards:
npm run dinky -- build --dev--devpoints the codes at your local console (devUrlindinky.config.json). The cards are indist/games/, and with the dev server running you can see them at http://localhost:8080/games/. - Play it from the code. On the computer, open the link in
dist/mygame.url.txt. On a phone, see "The console's address" under Making cards: alocalhostlink only works on the machine running the dev server.
The machine
Screen
- 256 x 192 pixels, like the ZX Spectrum.
ROM.Wis 256 andROM.His 192. - Every pixel is one of 16 palette colours, given as a number 0 to 15. There are no other colours.
- (0, 0) is the top-left corner. Coordinates are rounded to whole pixels; anything off-screen is clipped.
- You can also colour the border around the screen with
border(c), handy for flashes. It starts blue (1). - The console scales the screen up in whole steps to fit the phone, with crisp pixels.
Palette
The ZX Spectrum palette. Colours 8 to 15 are the bright versions of 0 to 7, so c - 8 is the darker version of a bright colour. 8 is the same black as 0.

| # | Name | Hex | # | Name | Hex |
|---|---|---|---|---|---|
| 0 | black | #000000 |
8 | bright black | #000000 |
| 1 | blue | #0000d7 |
9 | bright blue | #0000ff |
| 2 | red | #d70000 |
10 | bright red | #ff0000 |
| 3 | magenta | #d700d7 |
11 | bright magenta | #ff00ff |
| 4 | green | #00d700 |
12 | bright green | #00ff00 |
| 5 | cyan | #00d7d7 |
13 | bright cyan | #00ffff |
| 6 | yellow | #d7d700 |
14 | bright yellow | #ffff00 |
| 7 | white | #d7d7d7 |
15 | bright white | #ffffff |
Colour numbers are wrapped into range with c & 15, so 16 is 0 and -1 is 15. A missing colour in rect and friends is 0 (black).
Font
The console has one built-in pixel font, BM mini, covering ASCII 32 to 126.

- Capitals and digits are 6 pixels tall. Lowercase letters are 4 pixels tall (x-height), and
g j p q yhave 2-pixel descenders, so a lowercase line is 8 pixels tall in all. - Widths vary. Most capitals, digits and lowercase letters are 4 pixels wide.
M T W m w # $ & @are 5,%is 7,I f tand the space are 3,jis 2 andi l ! . : ;are 1. There is a 1-pixel gap between characters. Usetw(text)to measure. - y is the baseline.
txt(s, x, y)puts the bottom row of the capitals ony - 1, so capitals fill rowsy - 6toy - 1and descenders hang into rowsyandy + 1. In the chart, the blue line is rowy. Text aty = 7sits neatly in an 8-pixel bar at the top of the screen. - Scale with
z(rounded to a whole number): every font pixel becomes a z x z block, and the gap grows with it. - Alignment:
align0 (default) centres the text on x, -1 starts it at x, 1 ends it at x (the last pixel is atx - 1). - A few quirks:
$is drawn as a heart, the backtick is blank, and|looks the same asl. Characters outside ASCII 32 to 126 (accents,£, emoji) draw as spaces. - Link-like text is drawn as solid blocks. See Rules and security, below. The
@in the chart can never actually be shown bytxt.
Sound
The console has two sound devices. Games send it short commands; the console does the playing.
- Effects: 20 built-in presets (
sfx('coin')), or your own ZzFX sound as an array of numbers. - Music: three channels (0, 1, 2) that play tunes written in MML, a little music language like the Spectrum 128's
PLAYcommand. Square, triangle and noise waves. - Beeps:
beep(f, d, f2), a square-wave sweep, the cheapest sound in bytes. - Music Chip V2 (games with
// @sound 2): six more music channels on one clock, with sine, saw and variable pulse waves, envelopes, vibrato, glides, arpeggios, drums, stereo and 32 instrument presets, played withROM.music. See the Music Chip V2 chapter.
There is no sound data in a game, only commands. The Sound chapter, after the API reference, has the details.
Input
- Touch and mouse: each finger (and the mouse) is tracked separately, so two players can share one screen. Every press and every release calls your handler with the screen position in game pixels (0 to 255, 0 to 191).
- Keys: a key press calls the same handler with
XandYas -1 and the key'scode(for example'Space','ArrowLeft','KeyA','Digit1','Enter','ShiftLeft'). Auto-repeat is ignored: you get one press per real press. ROM.heldis true while any finger, mouse button or key is down.- There are no move events. You learn where a finger went down and where it came up, not where it travelled. Design for taps, holds and screen halves, or for tilt (below).
- Tilt: on a phone,
ROM.tiltgives how the phone is tipped, for games you steer without touching the screen. - The game's square. Touches reach your game inside a square centred on the screen, as wide as the phone in portrait (in landscape, as tall as the phone, and never smaller than the screen). Touching the border inside the square counts as touching the nearest edge of the screen: a tap just left of the screen arrives as
X = 0. Touches outside the square (the top and bottom of a portrait phone) never reach the game; that space is for the console, such as the MENU button.
Tilt
ROM.tilt is the phone's tilt, { x, y, r, on, off }, for games you steer by tipping the phone. It is phones only; there is no keyboard stand-in.
xandyrun from -1 to 1.x > 0means the right of the screen is lower;y > 0means the bottom of the screen is lower. They are already rotated for the way the phone is held, so "bottom" is the bottom of what the player sees.ris the screen angle divided by 90 (0 to 3), so you can tell when the player turns the phone.onis true while readings are arriving.offis true if the player said no or the phone has no motion sensor. Before either, both are false (waiting). Whileonis false,xandyare 0.- iOS asks permission, and only inside a tap. The first time your game reads
ROM.tilt, the console starts waiting; the prompt appears on the player's next tap on the game screen. Show a "tap to start" screen and treatonfalse andofffalse as "waiting". Once the player allows motion, the console remembers it: every tilt game after that gets readings straight away with no tap, and after the console is reloaded it asks again on the player's first tap anywhere. Still handle "waiting", since the first game of a session, or a player who said no, won't have readings at the start. - Tilt has no neutral: the player holds the phone however they like. Take a neutral position in your game (for example the first reading after a tap) and measure from it, and do it again when
rchanges. - Always read it as
ROM.tilt(orconst t = ROM.tilteach frame).const { tilt } = ROMcaptures one snapshot that never updates. - Motion sensors need HTTPS, so
localhoston a laptop won't give you readings. Test on a phone through a deployed console, or acloudflaredtunnel withbuild --url. - The axes follow the iPhone, which reports gravity the opposite way round from the web standard. On Android they come out reversed; DINKY targets iPhone.
Starting a tilt game
npm run dinky -- new mygame "My Game" --tilt creates a small working tilt game (roll a ball over coins for thirty seconds) and its tests. It already does the things every tilt game needs:
- Two taps to start. The first tap answers the iPhone's motion prompt; the top bar says
TAP TO ALLOW MOTION, thenTAP TO STARTonce readings arrive, orMOTION IS BLOCKEDif the player said no. - A READY moment. The ball sits still for half a second while the game records how the player is holding the phone, and every move is measured from there.
- A new neutral when things change. Turning the phone (
rchanges) or readings stopping (the console does that briefly when the player resumes from the pause menu) go back to READY. - A dead zone and friction. Tiny tilts are ignored so the ball doesn't creep, and friction stops it when the phone is level again.
If your game has walls, cap the ball's speed below the wall thickness plus the ball's radius per step, so it can't pass through a wall in one step. TILT MAZE (games/tiltmaze.js) is a fuller example: a maze, pits, level times and rotation handling.
The card's screenshot is taken in headless Chrome, which has no motion sensor, so a tilt game can only be shot on its title or waiting screen. Keep the @shot wait under a second (the template uses 128,96 w700): after that the console decides there is no sensor and your game shows its blocked message.
Storage
A game can't store anything except high scores, through hi(key, value). Scores are kept on the phone, per game. A game is identified by its exact contents, so changing a single byte of a game makes it a new game, with its own library entry and empty scores.
The ROM API
ROM is the only thing a game can talk to. It is the same object in the console and in the tests. Most games start by pulling out what they need:
const { W, H, cls, rect, txt, spr, sfx, beep, border, hi, rnd, run } = ROM;
That's fine for functions and constants. Five members are not safe to copy out, because they change or because you set them: ROM.t, ROM.held, ROM.tilt, and the handlers ROM.press and ROM.release. Always write those with ROM. in front.
Quick list
| Member | What it does |
|---|---|
W, H |
Screen width (256) and height (192) |
cls(c) |
Fill the whole screen |
rect(x, y, w, h, c) |
Filled rectangle |
box(x, y, w, h, c) |
Rectangle outline |
pset(x, y, c) |
Set one pixel |
pget(x, y) |
Read one pixel's colour |
line(x0, y0, x1, y1, c) |
Straight line |
txt(s, x, y, c, z, align) |
Text in the ROM font |
tw(s, z) |
Width of some text in pixels |
spr(s, x, y, z) |
Draw a sprite from a string |
cam(x, y) |
Scroll everything drawn after it |
flip(on) |
Turn drawing round 180 degrees |
border(c) |
Border colour |
ROM.press, ROM.release |
Your input handlers |
ROM.held |
Is anything held down? |
ROM.tilt |
The phone's tilt: { x, y, r, on, off } |
ROM.phys |
Physics: gravity, bouncing balls and boxes, solid pixel walls |
run(step, draw) |
Start the game loop |
ROM.t |
Steps since the game started |
sfx(name or array) |
Sound effect |
play(mml, ch, loop) |
Play a tune on channel 0 to 2 |
stop(ch) |
Stop a channel, or all sound |
beep(f, d, f2) |
Square-wave beep or sweep |
ROM.music / ROM.m |
Music Chip V2 songs (games with // @sound 2 only) |
hi(key, value) |
Read or save a high score |
rnd(n) |
Random number |
FONT |
The font data itself |
Screen
cls(c = 0) fills the whole screen with colour c. It ignores cam and flip.
cls(1); // blue background
rect(x, y, w, h, c) fills a rectangle. Everything is rounded to whole pixels and clipped to the screen.
rect(0, H - 8, W, 8, 4); // green ground along the bottom
box(x, y, w, h, c) draws a 1-pixel outline of the same rectangle.
box(60, 64, 136, 48, 10); // red frame round a message
pset(x, y, c) sets one pixel. pget(x, y) returns the colour of one pixel (0 if it is off-screen). Both follow cam and flip, so pget reads back what you drew at those coordinates.
pset(rnd(W), rnd(H), 7); // a star
if (pget(px, py + 8) == 4) onGround = true; // standing on green?
line(x0, y0, x1, y1, c) draws a straight line between two points (up to 2000 pixels long).
line(0, 0, W - 1, H - 1, 6);
Text
txt(s, x, y, c = 15, z = 1, align = 0) draws text in the ROM font. s can be a string or a number. y is the baseline (see Font, above); align is 0 centred on x, -1 starting at x, 1 ending at x.
txt(`SCORE ${score}`, 4, 7, 7, 1, -1); // top-left, grey
txt('GAME OVER', 128, 96, 10, 2); // centred, red, double size
tw(s, z = 1) returns the width of s in pixels at scale z, gap between characters included.
rect(128 - tw('PAUSED') / 2 - 2, 88, tw('PAUSED') + 4, 10, 1);
Sprites
spr(s, x, y, z = 1) draws a picture written as a string. Rows are separated by /. Each character is one pixel: a hex digit 0 to f is a palette colour, and . or a space is see-through (in fact anything that isn't a hex digit is). z scales each pixel to a z x z block. 0 is solid black, not see-through.
spr('..d../.ddd./ddfdd/d.d.d', x, y, 3); // a little cyan ship, 3x size
Sprite strings cost bytes (see Size budget). For blocky shapes, a few rect calls are often cheaper.
Drawing sprites
With npm run dev running, click Draw at the top right of the dev console (?dev=<id>), or open http://localhost:8080/draw?game=mygame. It finds every sprite in the file (named ones like const RAT = '...' or [...rows].join('/'), and unnamed ones inside a call) and shows them in a strip along the bottom. Pick colours with 0-9/a-f, draw with the left button, erase with the right. ⌘Z undoes.
Save (⌘S) writes the pixels straight back into games/<id>.js, changing only the sprites you touched, and the open game reloads. It also writes art/<id>.png and art/<id>.json, a picture of every sprite you can open elsewhere and bring back with Import PNG. If the file changed on disk since the editor loaded it, nothing is saved.
- Hit box and Anchor mark areas on a sprite. Each is kept as a comment above it (
// @hit RAT body 1,0,6,4,// @anchor RAT 4,4), which costs nothing. Tick "write to code" to also getconst RAT_BODY = [1,0,6,4];([x, y, w, h], the same shaperect()takes) orconst RAT_AT = [4,4];for the game to use. - Add frame 2 makes
RAT2, a second frame the same size, forspr(t & 8 ? RAT2 : RAT, x, y). The editor pairs anyXandX2of the same size. - An unnamed sprite needs Name it before it can have a second frame or hit areas; that moves it into a
constabove where it's used. - A sprite inside a shared
// ---- frame ----block (the CRACK ON games) is saved into every game that shares it.
The byte figures are estimates: ~N B once used is what the sprite adds when the game draws it, and the build packs a little smaller. Art the game doesn't use yet isn't always free: the build drops an unused '...' string sprite and unused hit and anchor consts, but keeps an unused [...].join('/') sprite, which is how the editor writes new sprites and frame 2, so those cost their bytes from the first save.
View: cam and flip
cam(x = 0, y = 0) moves the camera: anything drawn after it at world position (x, y) appears at the top-left of the screen. It affects rect, box, pset, pget, line, txt and spr, but not cls. Call cam() with no arguments to go back to screen coordinates (for a score bar, say).
cam(playerX - 128, 0); drawWorld();
cam(); txt(score, 128, 7);
flip(on) turns all following drawing round by 180 degrees: what you draw at the top-left lands at the bottom-right, upside down. It is made for two-player games on a phone lying flat between the players: draw one player's half, flip, draw the other's with the same code. flip(0) turns it off. Input coordinates are never flipped: a tap is always reported in real screen pixels.
for (let p = 0; p < 2; p++) { flip(p); drawHalf(p) }
flip(0);
Both reset after every frame. After each draw(), the console puts cam back to (0, 0) and flip off, so each frame starts clean. Set them in draw(), not step().
Input
ROM.press = (X, Y, key) => { ... } is called once whenever a finger, mouse button or key goes down. For touch and mouse, X and Y are the game pixel and key is null. For keys, X and Y are -1 and key is the key's code, like 'Space' or 'ArrowLeft'.
ROM.press = (X, Y, key) => {
if (key == 'ArrowLeft' || (key == null && X < 128)) dir = -1;
else dir = 1;
};
ROM.release = (X, Y, key) => { ... } is called when it comes up again, with the same kind of arguments. A finger can slide off the screen before it lifts, so the release position can be outside 0 to 255 / 0 to 191.
ROM.release = () => { dir = 0 };
ROM.held is true while at least one finger, button or key is down. Good for one-button "hold to rise" games.
v += ROM.held ? -0.3 : 0.2;
ROM.tilt is { x, y, r, on, off }: x, y from -1 to 1 (x > 0 right side lower, y > 0 bottom lower), r the screen angle / 90, on when readings are arriving, off when denied or no sensor. See Input, under The machine, for how and when the phone asks. Reading it for the first time is what makes the console ask for the motion sensor.
const t = ROM.tilt;
if (t.on) ball.x += t.x * 2;
Holding is easy to time by counting steps between press and release (MINEFIELD MOLE digs on a short tap and plants a flag after a 20-step hold). For two players on one screen, split by screen half: Y < 96 is the top player (see SHOWDOWN).
Time and the game loop
run(step, draw) starts the game. Call it once, at the end of your file.
step()is your game logic. It runs exactly 50 times a second, like a PAL Spectrum, whatever the phone's screen rate. Move things, check collisions, count timers here.draw()paints the screen. It runs once per screen refresh, after any steps that were due. On a 60 Hz phone,draw()sometimes runs with no step in between; on a 120 Hz phone it runs more than twice per step. So don't change game state indraw(), or your game will run at different speeds on different phones.- If the phone stalls, the console catches up by at most 5 steps (a tenth of a second) per frame, then lets the game slow down rather than jump.
function step() { x += dx }
function draw() { cls(0); rect(x, 90, 8, 8, 14) }
run(step, draw);
ROM.t is the number of steps since the game started. Read it as ROM.t each time; copying it out with const { t } = ROM gives you a number that never changes. Many games keep their own counter in step() instead (t++), which is also free to reset.
if (ROM.t % 50 == 0) beep(880, .05); // once a second
Timing in steps keeps everything in time with pausing and testing: 50 steps is one second. setTimeout(fn, ms) works too: inside a game it counts game frames (ms / 20, rounded up), so it pauses with the game and runs the same way in tests. setInterval isn't available; use setTimeout again from inside the callback, or count steps.
Physics
ROM.phys is a small physics engine built into the console: gravity, balls and boxes that bounce, slide and come to rest, and walls you simply draw. It lives on the console, so a game pays only for the calls it makes.
const P = ROM.phys;
cls(); rect(0, 180, 256, 4, 5); // draw the floor in colour 5
P.world({ gy: .15, walls: [5] }); // gravity down; colour 5 is solid
const ball = P.add({ x: 128, y: 20, r: 3, e: .6 });
function step() { P.step() } // advance the physics once per step
function draw() { cls(); rect(0, 180, 256, 4, 5); rect(ball.x - 2, ball.y - 2, 5, 5, 14) }
ROM.press = () => ball.vy = -4; // tap to throw it up
run(step, draw);
P.world(options)starts a fresh world and removes every body. Options:gx,gygravity in pixels per step per step (default 0),wallsa list of palette colours that are solid (default none),subsub-steps per step, 1 to 16 (default 4).P.add(fields)adds a body and returns it. It's a plain object: read and change its fields whenever you like, and the change counts from the next step.
| Field | Meaning (default) |
|---|---|
x, y |
centre, in pixels |
vx, vy |
speed in pixels per step (0) |
r |
radius: makes a ball (4) |
w, h |
width and height: makes a box instead (no rotation) |
m |
mass (from its size); 0 makes it fixed: it never moves, and things bounce off it |
e |
bounciness, 0 to 1 (.3) |
f |
friction, 0 to 1 (.2) |
d |
drag per step, 0 to 1 (0): its speed is multiplied by 1 - d each step |
g |
how much gravity pulls it (1); 0 to float |
walls |
bumps into pixel walls (true) |
hits |
read only: what it touched during the last P.step() |
P.step()moves everything one step. Call it from yourstep(), after you've pushed things, and only when the game is playing (not on a title screen).P.gx,P.gycan be changed at any time without resetting the world. A tilt game sets them fromROM.tiltevery step, so tipping the phone is gravity.ball.hitslists what the body touched in the last step:{ b, nx, ny, v }, wherebis the other body (ornullfor a pixel wall),nx, nypoints away from what it hit, andvis how hard it hit. Play a sound whenvis over about .5, so resting bodies stay quiet.P.del(body)removes a body.P.bodieslists them in the order they were added. The world holds at most 64.P.snap()re-reads the walls. Walls are a snapshot of the screen taken byworld(), not the live screen: steps can run between draws, and the testkit never draws, so a snapshot keeps the game the same on every phone and in tests. If your walls change, draw them instep()(or a press handler) and callP.snap()again.- Pixel walls are exactly their pixels. Flat walls and corners feel smooth, but a slope drawn with
line()is a staircase: a ball can rest on a step, so slopes feel sticky. Use straight walls, or make the ball's own push do the work. (Smooth slopes would be a future add-on module.) - Pixel walls are in screen positions, with no
cam. A scrolling game should use fixed bodies (m: 0) for its walls instead. - Draw your bodies in colours that aren't walls. Walls are only read on
world()andsnap(), but it keeps things clear. - Fast things don't pass through walls: speed is capped at
2 * subpixels per step, and each step is split intosubsmaller moves. Balls of radius 1.5 or more never cross a 1-pixel wall; smaller ones can, so give tiny balls walls at least 2 pixels thick. - Older consoles don't have it. Check once and show a message, as TILT MAZE does:
if (!ROM.phys) txt('UPDATE THE CONSOLE', 128, 90). - Once a version of the console ships, the physics never changes how it behaves for the options above, so old games always play the same. New features will arrive as new options and add-on modules (a game checks for them the same way, for example
if (P.rope)).
Sound
sfx(name) plays a preset effect; sfx([...]) plays a custom ZzFX sound.
sfx('coin');
sfx([.5, 0, 988, , .04, .18, 5, 1, , , 331, .05]);
play(mml, ch = 0, loop = false) plays a tune on channel 0, 1 or 2, replacing whatever that channel was playing.
play('T200 O5 L16 C E G > C', 1);
stop(ch) stops one channel; stop() with no argument stops all sound.
stop(2);
beep(f, d, f2 = f) plays a square wave starting at f Hz and sliding to f2 Hz over d seconds (0.01 to 1).
beep(440, .1, 880); // a rising blip
Scores
hi(key) returns the saved score for key (0 if there isn't one). hi(key, value) saves value (rounded to a whole number) and returns it. Keys are cut to 16 characters.
hi doesn't compare for you: it always saves what you give it. Check first:
let best = hi('best');
// later, at game over:
if (score > best) best = hi('best', score);
Scores belong to this game on this phone. The library shows the highest value a game has saved under any key as its "BEST". For "lower is better" scores, like a reaction time, store the time anyway: it is your game that decides what counts as better (SHOWDOWN and MINEFIELD MOLE both do this).
Misc
rnd(n) returns a whole number from 0 to n - 1. rnd() returns a fraction from 0 up to (not including) 1, like Math.random().
const lane = rnd(4); // 0, 1, 2 or 3
W and H are 256 and 192.
FONT is the font data: one array per character from ASCII 32, one number per pixel column, bit 0 at the top. You won't normally need it.
Math, String, arrays, objects, classes and the rest of plain JavaScript are all there. performance.now() works too (SHOWDOWN uses it to time reactions to the millisecond).
Sound
Presets
| Name | Sounds like |
|---|---|
coin |
two-tone pickup, B5 to E6 |
jump |
square sweep up |
hit |
gritty thud |
boom |
crunchy explosion |
shoot |
pew |
laser |
thin falling zap |
power |
rising staircase |
blip |
menu blip |
select |
two quick notes up |
hurt |
falling buzz |
step |
footstep tick |
win |
bugle arpeggio, C4 up to C6 |
lose |
sad steps down |
tick |
clock tick |
whoosh |
airy sweep |
alarm |
whoop whoop |
splash |
hiss |
pickup |
quick bloop up |
door |
low grind |
warp |
wobbling rise |
You can hear them all in console/sound-test.html (open it through the dev server: http://localhost:8080/sound-test.html).
Custom effects (ZzFX)
sfx([...]) takes a ZzFX parameter list of up to 21 numbers. Design one in Frank Force's ZzFX designer at https://killedbyapixel.github.io/ZzFX/ and paste the numbers in (just the array, not the zzfx(...) call). Empty slots (, ,) use ZzFX's defaults.
The console clamps every value to a safe range, and stretches nothing beyond 2 seconds: an effect with longer attack, sustain, release, delay and decay is squashed to fit. So a sound may come out slightly different from the designer if you push it to extremes.
A custom array costs bytes (around 17 for a typical one); a preset name costs almost nothing. Try the presets first.
MML cheat sheet
Tunes are strings, at most 512 characters each (longer ones are ignored). Case and spaces don't matter.
| Write | Means |
|---|---|
C D E F G A B |
notes. Add # or + for sharp, - for flat, then an optional length and dots: C#8, E-16, G4. |
R |
rest, with a length the same way: R4, R8 |
L<n> |
default length: 1 whole, 2 half, 4 quarter (default), 8, 16, 32 (1 to 64) |
. |
dot: half as long again (C4. is three eighths) |
O<n> |
octave 1 to 8 (default 4). O4 C is middle C, O4 A is 440 Hz |
< > |
octave down / up |
T<n> |
tempo, in quarter notes per minute, 32 to 255 (default 120) |
V<n> |
volume 0 to 15 (default 15) |
W<n> |
wave: 0 square (default), 1 triangle, 2 noise (the note sets the colour of the noise) |
& or _ |
tie: join the next note on (the same pitch becomes one long note) |
[ ... ]<n> |
repeat n times (default 2, up to 99). Can be nested |
Settings carry on through repeats, and each channel keeps its own. A tune stops after 2000 notes or 120 seconds.
A start jingle (half a second):
play('T180 L16 O5 C E G > C4', 1);
A looping triangle-wave bassline on channel 2, with a melody on channel 0:
play('T120 O2 L8 W1 [C C > C < C E- E- > E- < E-]2', 2, true);
play('T120 L8 O5 V10 E D C D E E E4 D D D4 E G G4', 0);
A noise drum loop:
play('T160 O3 L8 W2 [C R C C]', 1, true);
Sound tips
- Keep tunes short. A 40-note tune costs about 50 bytes. A four-note jingle and a short loop go a long way.
beepis the cheapest sound there is, and with a sweep it covers jumps, hits, coins and falls. Most of the example games use nothing else.- About 30 sounds can start per second; any more are dropped. Don't call
sfxevery step. - Sound can't start until the player has touched the screen or pressed a key (a browser rule). A title screen that waits for a tap solves this for free.
- Pausing freezes sound (music included) and resuming carries on from the same note, so a looping tune started once keeps going across pauses.
Music Chip V2
A second sound chip for games that want proper music. Put // @sound 2 in the header and the game gets ROM.music: up to six channels in one MML string, all on one clock, with instruments, effects and drums. Everything from the first chip (sfx, beep, play) still works alongside it, unchanged, on its own three channels.
The chip lives in the console, like the first one, so it costs a game nothing: a song is one string and one call.
// @sound 2
ROM.press = () => ROM.music.play('T140 L8 I2 O5 C E G >C< G E C4 | I4 O2 [C G]4 | [K0 K2 K1 K2]2');
Calls
| Call | Short | Does |
|---|---|---|
ROM.music.play(song, loop = true) |
ROM.m.p |
Play a song. It loops unless loop is false. A new song replaces the old one. |
ROM.music.stop() |
ROM.m.s |
Stop the song. |
ROM.music.pause() / resume() |
ROM.m.h / ROM.m.r |
Pause the song and carry on from the same place. |
ROM.music.volume(v) |
ROM.m.v |
Music volume, 0 to 1 (default 0.8). Effects aren't affected. |
ROM.music.tempo(n) |
ROM.m.t |
Change the tempo while it plays, 32 to 255. |
ROM.music.mute(ch, on = true) |
ROM.m.u |
Mute or unmute channel 0 to 5. |
ROM.music.transpose(n) |
ROM.m.x |
Shift every note by n semitones, -24 to 24. |
Write the long names. The build turns ROM.music.play(...) (and const { music } = ROM; music.play(...)) into ROM.m.p(...) before packing, so readable code costs nothing. Measured on a busy fixture with 14 music calls: 283 packed bytes written long without the rewrite, 253 with it, the same as writing ROM.m.p by hand (node sdk/measure-api.mjs). If you copy ROM.music into another variable (const mu = ROM.music), the build can't follow it and leaves it alone; it still works, it just costs the long names.
A song sent before the player has touched the screen waits and starts on the first touch (browsers don't allow sound before one).
MML for the V2 chip
Everything in the first chip's MML works the same (notes, R, lengths and dots, L O < > V & _ [ ]n). New:
| Write | Means |
|---|---|
| |
Next channel, up to 6. All channels share one clock and loop together on the longest one. |
T<n> |
The song's tempo: the first T anywhere counts. |
L<n> |
An L before channel 0's first note is every channel's default length, so 'T140L8 CEG|O2 C' gives both channels eighths. |
W0-W5 |
Wave: 0 square, 1 triangle, 2 noise, 3 sine, 4 saw, 5 pulse |
I0-I31 |
Instrument preset: sets the wave, envelope, pulse width, vibrato, arpeggio and gate in one go. Commands after it change them. |
P1-P15 |
Pulse width, in sixteenths (P8 is square, P2 is thin and nasal) |
Q1-Q8 |
Gate: how many eighths of each note sound (Q4 is staccato) |
@a,d,s,r |
Envelope: attack, decay, sustain, release, each 0 to 15 (@0,6,0,4 is a pluck). Not E, which is a note. |
M0-M15 |
Vibrato preset (0 off) |
S0-S15 |
Glide into each note from the one before (0 off) |
X0-X15 |
Arpeggio preset, the classic chiptune chord: 1 major, 2 minor, 3 octave, 4 fifth, 5 major with octave (0 off) |
N-8-N8 |
Pan the channel, left to right |
K0-K7 |
A drum hit at the current length: kick, snare, closed hat, open hat, low tom, high tom, clap, crash |
A song is at most 2048 characters, 4000 notes and 240 seconds a pass; anything past that is cut off.
Instruments
Hear them all on the sound test page (npm run dev, then http://localhost:8080/sound-test.html). The sounds may still be tuned, but the numbers won't change.
| # | # | # | # | ||||
|---|---|---|---|---|---|---|---|
| 0 | square lead | 8 | saw lead | 16 | square pluck | 24 | chip brass |
| 1 | soft square | 9 | flute | 17 | harp | 25 | staccato |
| 2 | pulse lead | 10 | vibrato square | 18 | bell | 26 | noise snare |
| 3 | thin pulse | 11 | pwm lead | 19 | organ | 27 | noise hat |
| 4 | triangle bass | 12 | soft pad | 20 | major arp | 28 | surf |
| 5 | saw bass | 13 | saw pad | 21 | minor arp | 29 | zap |
| 6 | punch bass | 14 | pwm pad | 22 | octave arp | 30 | tri kick |
| 7 | sub bass | 15 | sine pad | 23 | power arp | 31 | drone |
Music tips
- One string is cheap. WATERFUL's four-channel loop (melody, harp, bass and pad) costs 18 bytes more than its old three-channel V1 tune.
- Rate limits: about 30 songs and 60 controls (
volume,tempo,mute,transpose,pause,resume) a second. Don't call them every step. - Older consoles don't have the chip: a V2 game on a console that hasn't updated yet stops with "This game crashed". Consoles update themselves when they're online, and newer consoles say
NEEDS A NEWER CONSOLEfor hardware they don't have.
The header block
Every game starts with a block of comments. The first line is required; the @ lines feed the printed card and the library.
// STACK ATTACK: tap to drop the sliding block. Whatever overhangs gets sliced off.
// @tagline How high can you build before it all comes down?
// @how Tap to drop the sliding block onto the tower.
// @how Anything hanging over the edge is sliced off and falls.
// @how Miss the tower completely and it's game over.
// @controls Tap screen / click / any key to drop
// @players 1
// @shot 128,96 w1000 128,96 w900
// @colour 14
| Line | Required | Used for |
|---|---|---|
// TITLE: note |
yes, first line of the file | The title goes into the link: loading screen, library, pause menu, share screen, card. 1 to 24 plain ASCII characters, no : (the colon ends the title). The note after the colon is for people reading the code; nothing uses it. |
// @tagline ... |
yes | The strapline on the inlay card. |
// @how ... |
yes, at least one | One line each of the "How to play" list on the card. Repeat as needed. |
// @controls ... |
yes | The controls line on the card. |
// @players 1 |
no (default 1) | 2 prints "Two players, one phone" on the card. |
// @shot ... |
no | The script shots plays before taking the card's screenshot (below). Default 128,96 w1200. |
// @colour 14 |
yes | Palette number 1 to 15. Goes into the link: the title colour in the library and pause menu, and the card's spine and title. |
// @sound 2 |
no (default 1) | The sound chip the game needs. 2 is Music Chip V2 (ROM.music). Goes into the link (see Hardware versions). |
// @graphics 1 |
no (default 1) | The graphics chip the game needs. There is only 1 so far. |
Titles are usually written in capitals (new does this for you). Avoid | in a title: it is the separator inside the game's link.
Hardware versions
The console's sound and graphics are versioned hardware, so the console can grow without old games changing. A game says what it needs with // @sound N and // @graphics N; anything it doesn't say is version 1, the hardware every game was made for before versions existed.
- The build writes the versions into the link's header (
TITLE|COLOUR|s2) only when something isn't 1, so every V1 game is byte for byte what it always was, with the same library entry and scores. - The console checks the versions when it loads a game. If it doesn't have them, it says
NEEDS A NEWER CONSOLEand which chip, and keeps the game on the shelf for after the update. - Each version is a separate implementation inside the console (
console/hardware/registry.js), so a new chip never changes how an old one sounds or draws. Games never carry hardware code, and can't reach it: they only send it commands, which it checks.
@shot syntax
A space-separated list of steps, run in the real console in a headless browser:
| Step | Does |
|---|---|
X,Y |
tap the screen at game pixel X, Y |
w500 |
wait 500 ms |
kSpace |
press and release a key, by its code (kEnter, kArrowLeft, kKeyA) |
So 128,96 w1000 128,96 w900 taps the middle, waits a second, taps again, waits 0.9 s, then takes the picture.
Rules and security
Why there are rules
Cards get swapped between strangers. Whoever scans one is trusting a picture on a bit of card. So a game must never be able to phish, spam, track or advertise. The console makes that impossible rather than just discouraged, and the rules below are what that means for you.
What a game can't do
- No network. No
fetch, no web sockets, no images or scripts from anywhere. A game is all of its own code; nothing can be downloaded. - No storage, except
hi(). It can't see the game library, other games' scores or anything else on the phone. - No page. No DOM, no HTML, no links, no forms, no pop-ups, no canvas. The only way to show anything is the ROM's 16-colour framebuffer.
- No links in text. Any
txtstring that looks like a link is drawn as solid blocks, all of it. "Looks like a link" means it contains the wordshttp,wwworftp, an@, a//, or a word followed by a web ending such as.com. It looks for whole words and real web endings (.com,.co.uk,.ly,.io,.ggand similar), so game text likeLIFTPASS,READY...GOorGAME.OVERis left alone. The title gets the same treatment wherever the console shows it. - No motion prompts at will. A game that reads
ROM.tiltcan cause one motion-sensor prompt, and only on a tap in that game. The readings go only to the sandboxed worker, which has no network. - No CSS colours or fonts. Palette numbers and the ROM font only.
- No
evalornew Function. The game's code is all the code there is.
How the console enforces it
Each game runs in a Web Worker started from a hidden, sandboxed iframe with no origin and a strict security policy. That alone blocks the network, storage and the page. On top, the console checks every message a game sends: a frame of exactly 256 x 192 palette numbers plus a border colour, a sound command (cleaned up and clamped), a high-score save (a whole number with a short key), an error message, or one request for tilt (the only other thing a game may say). Nothing a game sends is ever opened, navigated to or shown as HTML.
The game itself is checked when it's unpacked: the code must unpack to 64 KB or less (a real QR code can't hold anything that would legitimately grow bigger), and the title must be 1 to 24 printable ASCII characters.
What lint checks
npm run dinky -- lint (and dev, build) checks your game before the console ever sees it:
- The header: the first line is
// TITLE: ..., the title is 1 to 24 plain characters, and@tagline,@how,@controlsare present and@colouris 1 to 15. - The code parses.
- No browser globals:
document,window,globalThis,self,localStorage,fetch,navigator,location,eval,Function,Image,Audio,AudioContextand friends (unless you declared a variable with that name yourself). - No canvas drawing (
fillStyle,fillRect,fillText,getContext,drawImageand so on). - No
ROM.somethingthat isn't in ROM v2, including inconst { ... } = ROM.ROM.musicandROM.mneed// @sound 2. @soundand@graphicsare numbers this console has (sound 1 or 2, graphics 1).- No CSS colours in strings (
'#ff0','rgb(...)'). This also catches text like'#123', so write'NO. 123'instead. setInterval(not available; usesetTimeout, which counts game frames).
Lint can't catch everything. const { t, held } = ROM passes, but gives you values that never update.
When things go wrong
The console stops a game and shows GAME STOPPED with a reason when:
| Reason shown | Cause |
|---|---|
| This game crashed: error | An uncaught error, in your top-level code or in step, draw, press or release. |
| This game stopped responding and was closed. | One frame took more than 2 seconds (usually an endless loop). |
| This game could not start. | The top-level code didn't finish within 4 seconds. |
| This game was flooding the console and was stopped. | More than 400 messages in a second. Frames, sounds and score saves are all messages, so a loop that calls sfx or hi hundreds of times will trip it. |
| This game tried to leave the console and was stopped. | The sandbox was asked to navigate away. |
Separately, more than 10 hi() saves in a second are ignored by the console (your game will still think it saved). Save once, at game over.
In the dev console, a crash shows the same screen; save a fix and it reloads.
Size budget
The numbers
| Limit | About this much packed game |
|---|---|
| Easy to scan (QR version 32 or less), from paper or a screen | 1850 bytes |
| Absolute maximum (QR version 40, low error correction) | 2820 bytes |
The whole code counts, console address included, so these are for an address of about 29 characters like https://console.konoha.co.uk/. The address is stored at 8 bits a character and the game at about 8.3 bits a byte. The example games are 1060 to 1430 bytes, QR versions 24 to 28.
A shorter console URL leaves more room for games: every character saved in the address is about a byte for the game.
Reading the build table
│ (index) │ source B │ packed B │ QR version │ bytes left (easy scan) │ bytes left (max) │
│ STACK ATTACK │ 4048 │ 1058 │ '24 (113x113)' │ 796 │ 1766 │
- source B: your file, comments and all.
- packed B: what actually goes in the code, after minifying and compressing. This is the number to watch.
- QR version: the size of the code. Up to 32 scans easily; 40 is the largest there is. The second part is the code's size in modules (squares).
- bytes left (easy scan) and bytes left (max): how many more packed bytes fit before the code grows past version 32 (easy scanning) and version 40 (the QR limit), worked out from the real code for your console address. Negative means over.
The dev console's tab title shows the same thing while you work, in the form 1058 B, QR v24, 796 B left (packed bytes, QR version, bytes left for easy scanning). It compresses a little less hard than build and measures against consoleUrl, so treat it as a close estimate.
What costs bytes and what doesn't
Measured on a small game (about 330 packed bytes):
| Change | Cost |
|---|---|
| All comments | free (minifying removes them) |
| Long, readable variable and function names | free (minifying shortens them) |
A second sfx('coin') call |
4 bytes |
beep(988, .1, 1300) instead of sfx('coin') |
9 bytes more |
A custom ZzFX array instead of sfx('coin') |
17 bytes more |
An object property name used twice (game.scoreValue) |
20 bytes |
An 8 x 8 spr string |
24 bytes |
| A 45-character line of text | 38 bytes |
| A 40-note tune | 49 bytes |
So:
- Write readable code. Names and comments are free. Never squash your source by hand.
- Repetition is cheap. Compression loves repeated patterns: a second call to the same function with similar arguments costs a few bytes. Unique logic, numbers and strings are what cost.
- Property names survive minifying.
obj.velocitykeeps the word "velocity". Short property names (r.x,r.v) or plain variables help. - Text is expensive. Title screens and instructions add up fast. The card's
@howlines are free (they're printed, not packed), so put the instructions there. - Sprites as strings cost their pixels. For simple shapes,
rectcalls or a pattern drawn in a loop may be cheaper. SHOWDOWN packs its cowboy as rectangles in a base-36 string. - Prefer presets and
beepover custom effects, and short tunes over long ones. - Music Chip V2 calls can be written long. On a
// @sound 2game the build packsROM.music.playasROM.m.p, so the readable names are free. - Check often. The dev tab title updates on every save, so you see the cost of each change straight away.
Testing with the testkit
Tests run your game on the real ROM, in Node, with no browser. A test file is a plain script:
import { load, ok, done } from '../sdk/testkit.mjs';
const g = load('games/mygame.js', { expose: ['st', 'score'] });
g.run(10);
ok(g.st == 0, 'starts on the title screen');
done();
Run one game's tests with npm run dinky -- test mygame, or everything (SDK and all games) with npm run dinky -- test. Paths are relative to the project folder.
load(file, options)
Loads a game and returns a handle g. Options:
expose: names of your game's own top-level variables and functions. Each becomes a property ofgthat you can read and set (g.score,g.rocks = []). Setting one changes the game's real variable, which is the easiest way to set up a situation.scores: high scores already saved, as{ key: value }, to test what happens with an existing best.
Driving the game
| Call | Does |
|---|---|
g.step(n = 1) |
run n steps of game logic, no drawing (fast) |
g.draw() |
run your draw() once |
g.run(n = 1) |
exactly n steps then one draw, through the same loop as the console |
g.tap(x, y, id) |
press and release at a game pixel |
g.press(x, y, id), g.release(x, y, id) |
press and release separately, to hold. id (default 'finger') lets you use two fingers at once |
g.key(code) |
press and release a key, like g.key('Space') |
g.keyDown(code), g.keyUp(code) |
hold a key down, let it go |
g.tilt(x, y, r = 0) |
readings arriving: the phone tipped by x, y (each -1 to 1), screen angle r (0 to 3). Stays until you change it |
g.tilt(null) |
waiting: no readings yet (the start, or just after a resume) |
g.tilt(false) |
blocked: the player said no, or there is no sensor |
All of them return g, so they chain: g.press(250, 180).step(20).release(250, 180).
step and run both advance g.t and any setTimeout timers by one frame per step.
Looking at the result
| Property | Gives |
|---|---|
g.screen.at(x, y) |
colour of one pixel |
g.screen.count(c) |
how many pixels are colour c |
g.screen.colours() |
the colours on screen, sorted |
g.screen.has(c, x, y, w, h) |
true if any pixel in the rectangle is colour c (whole screen if you leave out the rectangle) |
g.sounds |
every sound command so far, like { t: 'sfx', n: 'coin' }, { t: 'beep', f: 440, d: .1, f2: 880 }, { t: 'play', m: '...', c: 1, l: false } |
g.saved |
scores saved with hi(), as { key: value } |
g.wantsTilt |
true once the game has read ROM.tilt (which is what makes the console ask for the motion sensor) |
g.border |
the border colour of the last frame |
g.frames |
how many frames have been drawn by run |
g.t |
ROM.t |
g.rom |
the ROM itself |
The screen reflects the last draw(); call g.draw() after stepping if you want to check pixels.
ok and done
ok(condition, message) prints PASS message or FAIL message. done() prints the totals and makes the test fail if anything did. Call it at the end.
A worked example
A whole tiny game, PIP: tap the dot as often as you can in ten seconds.
// PIP: tap the dot before it moves.
// @tagline One dot. Ten seconds. How quick are you?
// @how Tap the yellow dot. Each hit scores a point and moves it.
// @how You have ten seconds.
// @controls Tap the dot
// @players 1
// @shot 128,96 w500
// @colour 14
const { W, H, cls, rect, txt, sfx, border, hi, rnd, run } = ROM;
let st = 0, score = 0, best = hi('pip'), x = 120, y = 90, left = 0;
ROM.press = (X, Y) => {
if (st == 0) { st = 1; score = 0; left = 500; border(1); return sfx('select') }
if (X >= x && X < x + 16 && Y >= y && Y < y + 16) {
score++; sfx('coin');
x = rnd(W - 16); y = 16 + rnd(H - 32);
}
};
function step() {
if (st == 1 && --left == 0) {
st = 0; sfx('lose'); border(2);
if (score > best) best = hi('pip', score);
}
}
function draw() {
cls(0);
txt(`SCORE ${score} BEST ${best}`, 128, 7, 7);
if (st == 1) {
rect(x, y, 16, 16, 14);
rect(0, H - 4, left * W / 500, 4, 5);
} else txt('TAP TO PLAY', 128, 100, 15, 2);
}
run(step, draw);
And its test, games/pip.test.mjs:
import { load, ok, done } from '../sdk/testkit.mjs';
const g = load('games/pip.js', { expose: ['st', 'score', 'x', 'y', 'left'], scores: { pip: 3 } });
g.run(1);
ok(g.st == 0, 'starts on the title');
ok(g.screen.has(15, 0, 80, 256, 30), 'TAP TO PLAY is drawn');
g.tap(10, 10);
ok(g.st == 1 && g.left == 500, 'a tap starts a round');
g.x = 50; g.y = 60; // put the dot somewhere known
g.tap(55, 65);
ok(g.score == 1, 'tapping the dot scores');
ok(g.sounds.some(s => s.n == 'coin'), 'and plays the coin sound');
g.step(500); // ten seconds of play
ok(g.st == 0, 'the round ends after ten seconds');
ok(g.saved.pip == undefined, 'a score of 1 does not beat the saved best of 3');
g.draw();
ok(g.screen.at(255, 191) != 5, 'timer bar is gone');
done();
Tips:
- Test the rules, not the pixels. Exposed variables are more reliable than counting colours.
- Put things where you need them (
g.rocks = [...],g.x = 50) instead of playing until they happen. - If your game uses
Math.random, you can replace it at the top of the test with a seeded one to make runs repeatable (SIGNAL BOX's test does this). games/mygame.test.mjsfromnewis a good template: title, start, controls, game over, restart pause. With--tiltyou get the tilt version: asking for motion, READY and the neutral, rolling, turning the phone and blocked motion.
Making cards
Build
npm run dinky -- build # codes point at consoleUrl
npm run dinky -- build --dev # codes point at devUrl (your machine)
build lints every game (and stops if any fails), then packs each one into dist/:
<id>.svgand<id>.png: the QR code.<id>.url.txt: the full URL inside it.games/<id>.html: the cassette inlay card for that game, andgames/index.html: a rack of all of them.
Screenshots
The inlay shows a screenshot of the game in play. To take them:
npm run dinky -- build --dev(the screenshots load each game from its--devURL).- In another terminal,
npm run dinky -- dev. npm run dinky -- shots. This opens each game in headless Google Chrome (installed in/Applications), plays its@shotscript and savesdist/<id>-shot.png.- Build again (with or without
--dev) so the cards pick the screenshots up.
Open a card from dist/games/ and use its Print inlay button. The print layout is A4 landscape and draws the card at real size (one card unit is 1 mm), so print at 100% scale, not "fit to page". Cut it out and fold it into a cassette case, or just stick it on a card.
The console's address
Every card has the console's address baked in. Set it in dinky.config.json once you have a domain:
{
"consoleUrl": "https://PLACEHOLDER.example/",
"devUrl": "http://localhost:8080/",
"devPort": 8080
}
- Until
consoleUrlis real,buildprints a warning and its cards won't open anything useful when scanned with a phone's own camera. - Choose it carefully: cards printed with one address keep pointing there. The console's in-app scanner accepts games from any address, so old cards still play when scanned from inside DINKY, but a phone camera app follows the address on the card.
- A short address leaves more bytes for games (see Size budget).
devUrlishttp://localhost:8080/by default, which only works on the machine runningdev. To try--devcards on a phone on the same Wi-Fi, setdevUrlto your computer's local address, likehttp://192.168.1.20:8080/(the dev server listens on the whole network). The phone's camera app can open those links; the in-app scanner needs the camera, which browsers only allow on HTTPS or localhost.
Publish the console
npm run dinky -- site
npx wrangler deploy
site refreshes the console (its security policy hash, offline file list, icons and this manual, as console/manual.html) and copies it to dist/site/, with the built cards and codes under it. Upload that folder to any static host over HTTPS. The one set up here is a Cloudflare Worker called dinky that serves dist/site/ as static files (wrangler.jsonc); npx wrangler deploy publishes it. Build the cards with the final consoleUrl before running site.
Console versions. Every time the console's files change, site (and console) moves the console version up by one: a plain number kept in console/version.json and committed with the change. Rebuilding with no changes keeps the same number, and building cards never changes it.
Playing and swapping
Install the console
Open the console's address on the phone, then:
- iPhone and iPad: in Safari, Share, then Add to Home Screen.
- Android: in Chrome, the menu, then Install app (or Add to Home screen).
Once installed, the console and every game work with no connection at all. The console's version shows under the logo (v12). When the phone is online and a newer console has been published, a yellow refresh mark and UPDATE appear next to it: tap them to switch to the new console. Offline you just see the number. On iPhone, the installed app keeps its own library, separate from Safari's, so use the app's scanner rather than the camera app for games you want to keep there.
Scan a game
Tap SCAN GAME and point the camera at a card. Scanning works offline. If the code isn't a DINKY game, the console says NOT A GAME and does nothing else: it never opens a scanned link. The game plays after a short Spectrum-style loading screen and is saved to the library.
The library
The home screen lists your games, most recently played first, with each one's best score (or NEW GAME). Tap one to play it. QR shows its code, X deletes it (with its scores). The library holds up to 200 games.
Share phone to phone
QR in the library (or SHOW QR in the pause menu) puts the game's code on screen. A friend scans it with their DINKY, and now they have the game too. No cards, no internet.
Pause
Tap MENU in the top corner or press Esc. The pause menu has RESUME, SHOW QR and BACK TO GAMES. The game also pauses itself when you switch away from the app.
Credits and licences
- BM mini A8 pixel font: (c) 2001 BitmapMania / COOZ. The licence is unknown and must be cleared before DINKY is released publicly.
- ZzFX (Zuper Zmall Zound Zynth) by Frank Force: MIT licence. https://github.com/KilledByAPixel/ZzFX
- zxing-wasm by Ze-Zheng Wu (the QR scanner on phones without a built-in one): MIT licence. It's built from zxing-cpp (Apache License 2.0), noted in
console/vendor/LICENSE-zxing-cpp. - qrcode-generator by Kazuhiko Arase (the on-screen share codes): MIT licence.
The palette and screen size are a tribute to Sinclair's ZX Spectrum.