<?phpnamespace App\Alis;// Port of alis/src/screen.c (MIT, Olivier Huguenot, Vadim Kindl).// C: sScreen screen = { .ptscreen = 0 } -> Scr::$ptscreen.function get_screen_var(int $var, int $screen_idx): int{ return xread16(Alis::$basemain + $screen_idx + $var);}function set_screen_var(int $var, int $screen_idx, int $val): void{ xwrite16(Alis::$basemain + $screen_idx + $var, $val);}function scadd(int $scridx): void{ set_scr_to_next($scridx, 0); $nextscreen = Scr::$ptscreen & 0xffff; if (Scr::$ptscreen == 0) { Scr::$ptscreen = $scridx & 0xffff; return; } do { $curscreen = s16($nextscreen); $nextscreen = get_scr_to_next($curscreen); } while ($nextscreen != 0); set_scr_to_next($curscreen, $scridx);}function scbreak(int $scridx): void{ if (Scr::$ptscreen == 0) { return; } $prevptscreen = s16(Scr::$ptscreen); if ($scridx == Scr::$ptscreen) { Scr::$ptscreen = get_scr_to_next($scridx); return; } do { $nextptscreen = s16(get_scr_to_next($prevptscreen)); if ($nextptscreen == $scridx) { set_scr_to_next($prevptscreen, get_scr_to_next($scridx)); return; } $prevptscreen = $nextptscreen; } while ($nextptscreen != 0);}function scdosprite(int $scridx): void{ $spritidx = s16(get_scr_screen_id($scridx)); $sprite = sprite_var($spritidx); $sprite->numelem = get_scr_numelem($scridx); $x = get_scr_newx($scridx); $y = get_scr_newy($scridx); $w = get_scr_width($scridx); $h = get_scr_height($scridx); if (Alis::$platform->kind == C::EPlatformMac) { mac_update_pos($x, $y); mac_update_pos($w, $h); } if (Alis::$platform->version == 10) { $sprite->newx = s16($x & 0xfff0); $sprite->depx = s16(($x + $w) | 0xf); } else { $sprite->newx = s16($x); $sprite->depx = s16($x + $w); } $sprite->newy = s16($y); $sprite->newd = 0x7fff; $sprite->depy = s16($y + $h);}function vectoriel(int $scridx): void{ $m = Alis::$basemain + $scridx + (Alis::$platform->version == 10 ? 0x1a : 0x20); $m0 = s8(xread8($m + 0)); $m1 = s8(xread8($m + 1)); $m2 = s8(xread8($m + 2)); $m3 = s8(xread8($m + 3)); $m4 = s8(xread8($m + 4)); $m5 = s8(xread8($m + 5)); xwrite8($m + 6, $m1 * $m5 - $m4 * $m2); xwrite8($m + 7, $m2 * $m3 - $m5 * $m0); xwrite8($m + 8, $m0 * $m4 - $m3 * $m1);}