A kit to make DOS web tiles
README.md

DOS tile kit #

Make web tiles that run MS-DOS programs: games and demos. DOSBox (js-dos emulators) runs a zip in the tile. One runtime serves every tile. Each tile is a folder in tiles/ with a dostile.json.

Doom (shareware) Warcraft: Orcs & Humans (demo)
Doom in a tile: E1M1, the start of the first level Warcraft in a tile: the first Human mission

Quick start #

Node 20 or later is necessary.

npm run fetch -- doom                         # download the game data of a game in tiles/
npm run new -- <archive item> --slug <name>   # make tiles/<name>/ from an Internet Archive item
npm run build -- <name>                       # write build/<name>/ and dist/<name>.tile
npm run serve -- <name> --port 8642           # test on http://127.0.0.1:8642/

Open dist/<name>.tile in Blastile or in a different tile reader.

Example:

npm run new -- WarcraftOrcsHumansDemo --slug warcraft --mouse
npm run build -- warcraft

Commands #

Command Function
npm run new -- <item> [options] Read the Archive metadata. Download each zip of the item, check its SHA-1, and use the first zip that contains the start file. Write tiles/<slug>/dostile.json and tiles/<slug>/data/.
npm run fetch -- <slug> [--file zip] Download source.url again, check size and SHA-1, check that exe is in the zip, write tiles/<slug>/data/. With --file, use a zip on this computer.
npm run build -- <slug> ... | --all [--no-bundle] Write build/<slug>/ and bundle it to dist/<slug>.tile.
npm run serve -- <slug> [--port n] Serve build/<slug>/ on localhost, with connect-src and worker-src of the tile policy. For tests only.
npm run login -- <handle> Log a Bluesky (AT Protocol) handle in to atile. Asks for an app password.
npm run publish-tile -- <slug> [--dry-run] [--user handle] Publish build/<slug>/ with a stable identifier. A later publish of the slug replaces the record.
npm run check Parse each script and the runtime. Check each dostile.json, each tile image and runtime/emulators/. No network access.
npm run emulators [-- <version>] Compare runtime/emulators/ with the latest emulators on npm. With a version, install it.

Options of new:

Option Function
--slug <name> Folder name in tiles/. Default: from the item title.
--file <name> The zip in the item to use.
--exe <path> The start file in the zip. Default: emulator_start of the item.
--mouse Send mouse input to the game.
--force Replace an existing dostile.json.

Layout #

Path Contents
runtime/ The tile page: index.html, style.css, tile.js, emulators/. The same for every game.
runtime/emulators/ js-dos emulators from npm, not changed (GPL-2.0). VERSION gives the version.
tiles/<slug>/dostile.json The settings of one tile.
tiles/<slug>/icon.png Square tile icon, 192 x 192 or larger, for example 512 x 512. A tile reader shows it in the tile list. Optional.
tiles/<slug>/screenshot.png Tile screenshot, for example 640 x 480. Optional.
tiles/<slug>/files/ Files that the tile adds to drive C: at start, if the zip does not have them.
tiles/<slug>/data/ The game zip in parts of 8 MiB, and index.json. Written by new and fetch.
build/<slug>/ The tile source. Written by build.
dist/<slug>.tile The bundled tile. Written by build.
scripts/ The commands above. lib.mjs has the shared functions.
assets/ Screenshots for this README. Not in the tiles.

Each image must be a whole PNG: check and build read every chunk and its CRC. Each image must be 10 MiB or less. build stops on an image that fails.

Repository #

Git does not track build/, dist/ and tiles/*/data/. After a clone, run npm run fetch -- <slug> for each game. fetch downloads the zip from source.url and checks its SHA-1. The game data stays out of the history.

.gitattributes keeps the CRLF line endings of DOS config files and marks .wasm, .zip and .WAR files as binary.

CI runs on Tangled (Spindle). .tangled/workflows/check.yml runs npm run check and npm run build -- --all --no-bundle on each push and pull request to main. Start it by hand with the manual event. Skip it with git push -o skip-ci.

atile keeps the AT URL of each published tile in ~/.atile/identifiers.json, keyed by the absolute path of build/<slug>/. After a move of the kit, change the keys in that file, or the next publish makes a new record.

dostile.json #

Key Function
name Tile name and page title. Necessary.
shortName Short tile name.
heading Text on the start screen. Default: name in capitals.
description Tile description in manifest.json.
categories Tags in manifest.json. Default ["games", "dos"].
hint The line at the bottom of the tile.
source item, file, url, size, sha1, license. fetch checks size and sha1. Necessary.
exe Path of the start file in the zip, for example WAR.EXE or DOOM/DOOM.EXE. Necessary.
args Arguments for the start file.
start DOSBox commands. If set, used in place of exe and args.
mouse true sends mouse input to the game and hides the system cursor over the screen.
autostart true starts DOSBox when the tile loads. The tile shows no Start button.
keys Key presses after the start, for example to go past a setup screen. A list of { "wait": ms, "key": code }. wait counts from the key before. code is a KeyboardEvent.code, for example Enter or ArrowDown.
dosbox DOSBox settings that replace the defaults of the emulator: { "section": { "key": "value" } }, for example { "cpu": { "cycles": "max" } }. The tile ignores autoexec.
saves false removes Export saves and Import saves. Default true.
controls The gamepad map. See Gamepad.
touch Key buttons for touch screens. See Touch.
colors accent, dark, line, theme.
sizing Tile size in manifest.json. Default 640 x 520.
notes Free text. The build does not use it.

A browser holds the sound of a page until the first click or key press. With autostart, the tile shows "Sound is off. Click to turn it on." until then.

A keyboard game must not set mouse. The tile sends absolute positions. A game that reads mouse motion (Doom turns with the mouse) moves when the pointer crosses the screen.

Gamepad #

The tile reads each connected gamepad once a frame. It sends DOS keys and mouse buttons. Before the start, A or Start presses the Start button.

controls in dostile.json sets the map:

"controls": {
  "stick": "arrows",
  "buttons": { "a": ["ControlLeft", "Enter"], "b": "Space", "select": null }
}
  • stick: the left stick. arrows presses the arrow keys. mouse moves the mouse. none does nothing. Default arrows.
  • buttons: a button name and its target. The names are those of the standard layout: a, b, x, y, lb, rb, lt, rt, select, start, ls, rs, up, down, left, right, home. A target is a KeyboardEvent.code, or MouseLeft, MouseRight, MouseMiddle. A list presses each target. null removes a default.
  • Defaults: the d-pad presses the arrow keys. A and Start press Enter. B and Select press Esc. A key in buttons replaces the default of that button.
Game Map
doom Stick and d-pad move. A fires and selects. B opens. X runs. Y answers yes. LB and RB strafe. Start opens the menu. Select shows the map.
warcraft Stick moves the mouse. A is the left button, B the right button. D-pad scrolls. Start opens the game menu. Select does nothing: Esc on the main menu quits to DOS.
second-reality, unreal Defaults. A or Start is Enter on the setup screen. B is Esc.

A tile reader can block the Gamepad API. Then the tile has no gamepad input and shows no error. npm run check checks the button names, the stick mode and the form of each target.

Touch #

A phone has no keyboard. On a touch device, the footer has a button for each key in touch. A button holds its key down while the finger is on it. A desktop shows no buttons.

"touch": [{ "label": "Enter", "key": "Enter" }]
  • label: the text on the button.
  • key: a KeyboardEvent.code.
  • Default: Enter and Esc. [] shows no buttons.
Game Buttons
doom, second-reality, unreal Default: Enter, Esc.
warcraft Enter. Esc on the main menu quits to DOS.

Touch does not give full play of a game. Warcraft has no right click on a touch screen. A tap on the screen of a mouse game is a left click.

Default files #

Put a file in tiles/<slug>/files/ at its path on drive C:. At start the tile adds the file if the game zip and the imported saves do not have a file at that path. Use this for config files that the game reads at start:

Game File Function
doom DEFAULT.CFG Selects the Sound Blaster for sound and music. With no config, Doom has no sound.
warcraft PREFS.WAR Sets Mouse Scroll and Key Scroll to Normal. Five 32-bit little-endian values: game speed, music volume, sound volume, mouse scroll, key scroll. 2 is Normal, 3 is Fast.

The DOSBox config of the emulator has a Sound Blaster 16 at 220h, IRQ 7, DMA 1. A game config must use these values.

Saved games #

The origin of a tile is erased when the tile closes. Files that the tile keeps in the browser are lost.

  • Export saves downloads <slug>-saves-<date>-<time>.zip. The zip holds each file on drive C: that changed after the start.
  • Import saves, before Start, adds such a zip at the next start. A file in it replaces the file at the same path.

Import works only before Start.

The tile sandbox #

  1. connect-src 'self' blob: data:. A tile cannot get data from the network. The game zip is in the tile.
  2. worker-src 'self'. emulators.dosboxWorker() starts its worker from a blob, and the sandbox stops that. tile.js starts the worker from emulators/wdosbox.js and gives its own transport to emulators.backend().
  3. A tile loader refuses a resource of more than 10 MiB. The game zip is in parts of 8 MiB. tile.js joins the parts and checks the SHA-1.
  4. No pointer lock. Mouse input is absolute.
  5. The sandbox permits downloads and file inputs. Export and import use them.
  6. A tile reader can embed the tile without permission for full screen. Then document.fullscreenEnabled is false, and the tile removes the Full screen button.

Games #

Slug Item Zip Start Mouse
doom DoomsharewareEpisode DoomV1.9sw1995idSoftwareInc.action.zip (shareware 1.9) DOOM.EXE no
warcraft WarcraftOrcsHumansDemo WCRFT.ZIP (demo 1.12, installed) WAR.EXE yes
second-reality msdos_2ND_REAL_shareware 2ND_REAL.zip (Future Crew, 1993) SECOND.EXE no
unreal demoscene_Unreal-FutureCrew unreal11.zip (Future Crew, 1992, version 1.1) UNREAL.EXE no

second-reality and unreal use autostart and dosbox. Each tile starts its demo when it loads. The dosbox key turns on the Gravis Ultrasound and sets cycles=max. The setup screen of each demo then selects the Gravis Ultrasound. Enter on the setup screen starts the demo.

Publish #

  1. Make an app password at https://bsky.app/settings/app-passwords.
  2. npm run login -- your.handle. The password goes to the system keychain.
  3. npm run build -- <slug>.
  4. npm run publish-tile -- <slug> --dry-run. Read the file list.
  5. npm run publish-tile -- <slug>. At a terminal, atile asks before it uploads.

atile keeps the AT URL of the tile for build/<slug>/. To delete the record: npx @dasl/atile@3.0.1 delete build/<slug>. A deleted record was public while it existed and can stay in copies.

Licenses #

  • The kit: GPL-2.0-or-later. You can use it under version 2 of the GNU General Public License, or under a later version. See LICENSE.
  • runtime/emulators/: GPL-2.0. Source: https://github.com/js-dos/emulators.
  • Game data: the terms of each game.