/src/*.als), hd, special or php (GameLibrary::EDITIONS) */ private string $edition = 'original'; /** source editions: the VM starts once the main script's source is here (downloaded on demand) */ private bool $bootPending = false; /** HD edition: the picture scaled by the GPU with an edge-directed filter (App\Hd\HdRenderer) */ private ?\App\Hd\HdRenderer $hd = null; /** the "CRT 1995" option (App\Hd\CrtRenderer): the picture as a monitor of the time showed it, by the GPU */ private ?\App\Hd\CrtRenderer $crt = null; /** the "FPS" option: the frames per second, small, top left (measured over the last second) */ private bool $fps = false; private float $fpsSince = 0.0; private int $fpsFrames = 0; private string $fpsText = ''; /** the "Skip intro" button (the films and credits of the introduction) */ private \App\Alis\IntroSkip $skip; /** the engine's messages (LOADING..., errors) in a real font at the window's resolution */ private ?\App\Hd\ScreenText $text = null; /** 'editor': the pause key goes back to the ALIS editor (EditorScene), on the script being edited */ private string $back = ''; private string $backScript = ''; private string $gameId = ''; /** @var list tests and shots: left clicks [seconds, x, y] (game pixels), oldest first */ private array $clicks = []; private const AUDIO_RATE = 22050; /** frames mixed per push: 1/30 s */ private const AUDIO_BLOCK = 735; /** the playground's externals (jumphp/externals): where the big files of the games come from (alis//) */ public function __construct(private \JumPHP\Externals\Externals $externals) { } public function enter(array $params = []): void { // 'dir' = folder of the game data, or 'game' = a folder name in data/ (tests: {"game":"robinson"}) $this->dir = (string) ($params['dir'] ?? (isset($params['game']) ? $this->engine->config->path('data/' . $params['game']) : '')); $this->time = 0.0; $this->back = (string) ($params['back'] ?? ''); $this->backScript = (string) ($params['script'] ?? ''); $this->clicks = array_map(static fn (array $c) => [(float) $c[0], (int) $c[1], (int) $c[2]], $params['clicks'] ?? []); $this->shownFrame = -1; $this->cursorVersion = -1; $this->machine = new Machine(); SysVars::$storage = $this->engine->storage; // the big files of the game (films, maps) are downloaded when the VM opens them (catalog/.json) $id = (string) ($params['game'] ?? basename($this->dir)); $this->gameId = $id; $catalog = \App\Alis\GameLibrary::catalog($this->engine->config->path('catalog'), $id); SysVars::$lazy = $catalog['lazy'] ?? []; // the playground serves them at //play/private/lazy// (same origin as the game's page) SysVars::$lazyBase = '/' . rawurlencode($this->engine->config->id()) . '/play/private/lazy/' . rawurlencode($id) . '/'; $dev = $this->engine->config->path('../../.alis-data/' . $id); // a developer's full copy (desktop) SysVars::$lazyDev = is_dir($dev) ? $dev : ''; SysVars::$http = $this->engine->http(); SysVars::$externals = $this->externals->isAvailable() ? $this->externals : null; SysVars::$externalsDir = 'alis/' . $id; SysVars::$externalsOff = false; // one list of the game's folder: the files opened later need no round trip each (Externals::open()) SysVars::$externals?->list(SysVars::$externalsDir, false); \App\Alis\Prefetch::start($id); // the small files in the background, into the browser's cache SysVars::$fetching = SysVars::$lazyFailed = SysVars::$lazyLoaded = []; $this->audioDue = 0.0; $this->edition = (string) ($params['edition'] ?? 'original'); SysVars::$sourceDir = in_array($this->edition, ['source', 'hd', 'special', 'phphd'], true) && $this->dir !== '' ? $this->dir . '/src' : ''; // the PHP code edition: each script turned into PHP when it is loaded (App\Alis\Compiled\Compiler), no VM loop \App\Alis\Compiled\Compiler::$on = $this->edition === 'php' || $this->edition === 'phphd'; SysVars::$sourceCache = SysVars::$sourcePack = []; SysVars::$sourceGame = SysVars::$sourceDir !== '' ? $id : ''; $this->bootPending = false; $this->hd?->disable(); $this->hd = null; $this->skip = new \App\Alis\IntroSkip(); // debugging a real session (desktop): var/trace.on makes var/trace/