HTML;
}
$links = ['language.md' => '../langage/', 'editor.md' => '../editeur/', 'vm.md' => '../vm/'];
$navFr = 'AccueilLe langage ALISL\'éditeurLa machine (doc technique)English';
$navEn = 'HomeThe ALIS languageFrançais';
$language = (string) file_get_contents("$root/docs/language.md");
$editor = (string) file_get_contents("$root/docs/editor.md");
@mkdir("$root/site/langage", 0777, true);
@mkdir("$root/site/editeur", 0777, true);
@mkdir("$root/site/en/language", 0777, true);
file_put_contents("$root/site/langage/index.html", page('fr', 'Le langage de script ALIS – les scripts des jeux Silmarils décompilés',
'Le langage source des scripts ALIS (Robinson\'s Requiem, Ishar, Transarctica) : variables, expressions, instructions, et la table de toutes les instructions de la machine.',
'langage/', md($language, $links), '../', ['fr' => 'langage/', 'en' => 'en/language/', 'x-default' => 'langage/'], $navFr));
file_put_contents("$root/site/editeur/index.html", page('fr', 'L\'éditeur ALIS – modifier les scripts de Robinson\'s Requiem dans le navigateur',
'L\'éditeur de scripts ALIS du moteur Silmarils en PHP : coloration, recherche, compilation, et le jeu relancé avec ta version.',
'editeur/', md($editor, $links) . '
',
'../', ['fr' => 'editeur/', 'x-default' => 'editeur/'], $navFr));
@mkdir("$root/site/vm", 0777, true);
file_put_contents("$root/site/vm/index.html", page('fr', 'La machine virtuelle ALIS – documentation technique de chaque instruction',
'Chaque instruction, élément d\'expression et cible de rangement de la machine ALIS de Silmarils, tels que l\'exécutable DOS de Robinson\'s Requiem les exécute : opérandes, effet, utilisations.',
'vm/', md((string) file_get_contents("$root/docs/vm.md"), $links), '../', ['fr' => 'vm/', 'x-default' => 'vm/'], $navFr));
// English: an overview, then the reference tables of the French document (they are code)
$reference = substr($language, (int) strpos($language, "## Référence"));
$reference = str_replace(['## Référence', '### Échappements', '### Éléments d\'expression'], ['## Reference', '### Escapes', '### Expression items'], $reference);
$en = <<<'MD'
# The ALIS scripting language
Silmarils' games (Robinson's Requiem, Ishar, Transarctica, Targhan…) are **programs for a virtual machine**, ALIS:
each `.io` file of a game is a compiled script (byte code, the variables it reserves, its pictures, sounds and 3D
models). This port of the machine to PHP comes with a **decompiler and a compiler**: every script becomes a text
in the ALIS source language, and the engine compiles that text back when it loads the script.
Silmarils' own sources were never published, so the syntax is a reconstruction: the names of the instructions
and expression items are the machine's own (`cput`, `cscmov`, `oimmb`, `oadd`…), and the structures follow the
habits of the original compiler, read from the byte code (one pass, left-to-right expressions, the same code for
every `if … else` and `while`). The 109 scripts of Robinson's Requiem (46,886 lines) compile back **byte for
byte**, and the game started from the sources shows exactly the same pictures as the original.
```
L0049:
putnat 108, 0, 137, 5 + vb[0x52], 1
if vw[0x54] {
call L010d
}
table inkey(), -187
goto L00b0
goto L00bf
end
```
- variables are named by their address: `vb[0x52]` (a byte of the entity), `vw[...]` (a word), `vs[...]` (a
string), `mw[...]` (the main script's), `hw[e, ...]` (another entity's), tables `tb[...](i)`;
- expressions are evaluated from left to right: `[ ]` groups, `$+`, `$==`… work on strings;
- the engine offers three editions of the game: the original scripts, **ALIS sources** (compiled from the text)
and **HD** (the same, with sharp pixels scaled by the GPU, the texts redrawn with a real font and the 3D rendered at twice the
resolution);
- the **90s form**: the same scripts as a developer of the time could have written them, French words, named and
declared variables (`local octet vague @ $52`), `si … alors … sinon … finsi`, `tantque … faire … fintantque`,
`:=` to store, `=` / `<>` to compare, `$52` numbers; translated word for word both ways, byte-identical;
- **ALIS BASIC**: the scripts as Silmarils' developers most likely wrote them on the Atari ST. The machine's
original instruction names are BASIC words (`locate`, `tab`, `dim`, `plot`, `box`, `ink`…), those of GFA BASIC,
the language of the ST in France: so `PUTNAT`, `TOPALET` in capitals, `IF … ELSE … ENDIF`, `WHILE … WEND`,
`GOSUB`, `SELECT … CASE`, `ADD x, n`, `&H52`, `'` comments, typed variables (`vague|` a byte, `x&` a word,
`name$` a string) declared with `LOCAL` / `GLOBAL`; translated word for word both ways, byte-identical;
- the **ALIS editor** (home screen: ` - ALIS EDITOR`) edits a script with colours and search, compiles it
(a mistake shows its line), keeps your version in your files and starts the game with it (`F5`).
The full guide is in French: [le langage ALIS](../../langage/), [l'éditeur](../../editeur/). Below: every
instruction of the machine and its operands.
MD;
file_put_contents("$root/site/en/language/index.html", page('en', 'The ALIS scripting language – Silmarils\' game scripts decompiled',
'The source language of ALIS scripts (Robinson\'s Requiem, Ishar, Transarctica): variables, expressions, and the table of every instruction of the machine.',
'en/language/', md($en . $reference, ['../../langage/' => '../../langage/']), '../../', ['fr' => 'langage/', 'en' => 'en/language/', 'x-default' => 'langage/'], $navEn));
echo "site/langage/, site/editeur/, site/vm/, site/en/language/\n";