Browser player

Run a libtini game in a web page. tools/web.py compiles the development machine of the repository to WebAssembly, and puts it in a package with the disk of the game. The page runs the same 65C02 program as the hardware. Thus a game needs no changes.

STARFALL runs in this player at appletini.org/demo/starfall. The player is an emulator, and its timing comes from the emulator models.

Build and play on your computer

Install Emscripten 6.0.13 with emsdk. The tool does not accept other versions. Build the disk of the game with tools/build.py. Then run:

python tools/web.py --emsdk D:/Repos/emsdk --game starfall --boot-roms build-inputs/native-roms --serve 8642

Open http://localhost:8642/, select a speed and push Play. The output is build/web/GAME/, a folder of static files.

Browsers permit audio worklets and module workers only through http://localhost or HTTPS. Thus open the page through a server, not as a file. --serve serves the page only to this computer, with the MIME types that browsers need.

OptionEffect
--emsdk DIRThe installed emsdk. You can also set EMSDK.
--game NAMEThe game in examples/. The default is STARFALL.
--boot-roms DIRBoot all of the disk through the installed enhanced //e ROM and slot-7 SmartPort firmware. The package then contains the Apple ROM and the ProDOS of the disk.
--download-diskAlso offer the disk, with its ProDOS, as GAME.po next to the page.
--serve PORTAfter the build, serve the page on http://localhost:PORT/.
--rebuildBuild the WebAssembly player again.

Without --boot-roms, the player loads the files of the disk, except PRODOS, through the ProDOS MLI stand-in of the machine. The package then contains only the game. The stand-in does not have ALLOC_INTERRUPT, so ti_audio_init fails. A game that needs the slot-4 clock then reports that the card is missing. STARFALL shows "SLOT 4 AUDIO REQUIRED". Use --boot-roms for such games.

What the page does

Publish a game page

Copy build/web/GAME/ to a static host that serves HTTPS. The page sets its base URL from its own location, so it works at all paths. Each package contains COPYING.txt and source.zip. source.zip is the Corresponding Source of the player, with its build record.

The player links the GPL-3.0 emulator and speech code of the repository. Thus the player and its files in tools/web/ are GPL-3.0-only. The library is MIT. A published copy must offer its source, and the package does this. A --boot-roms or --download-disk package also contains the Apple ROM and ProDOS. Publish it only if you have the right to distribute them.

The comparison check

python tests/web_validate.py --emsdk D:/Repos/emsdk --cc C:/msys64/ucrt64/bin/gcc.exe --boot-roms build-inputs/native-roms

This check runs a STARFALL script of 1,100 frames two times: in the player under Node, and in the native machine with its separate speech worker. The script boots, starts with the Mockingboard, moves, drops a bomb and uses the joystick.

At each checkpoint, the tick count, the program counter, AUX $2000-$9FFF and the decoded frame must be the same. The digest of the mixed audio must also be the same. The two profiles match at all nine checkpoints.

Under Node, the player runs at approximately 2.1 times real time at vtw33 and 1.3 times real time at turbo-f122. A slower computer can be too slow for turbo-f122.