<?phpnamespace App\Alis;// Port of alis/src/storenames.c (MIT, Olivier Huguenot, Vadim Kindl).// ============================================================================// Store routines// ============================================================================// Storename no. 01 opcode 0x00 pnul// Storename no. 02 opcode 0x02 pnul// Storename no. 03 opcode 0x04 pnul// Calls stub pnul// Storename no. 04 opcode 0x06 slocb// reads a word (offset) from script, then stores d7 byte at (vram + offset)function slocb(): void{ $offset = s16(script_read16()); xwrite8(Alis::$script->vram_org + $offset, Alis::$varD7);}// Storename no. 05 opcode 0x08 slocw// reads a word (offset) from script, then stores d7 word at (vram + offset)function slocw(): void{ $offset = s16(script_read16()); xwrite16(Alis::$script->vram_org + $offset, Alis::$varD7);}// Storename no. 06 opcode 0x0a slocp// reads a word (offset) from script, then stores null-terminated string in ARRAY_C at (vram + offset)function slocp(): void{ $offset = s16(script_read16()); mem_strcpy(get_vram($offset), Alis::$oldsd7);}// Storename no. 07 opcode 0x0c sloctp// Store at LOCation with offseT: Pointerfunction sloctp(): void{ $addr = tabstring(Alis::$script->vram_org + script_read16()); mem_strcpy($addr, Alis::$oldsd7);}// Storename no. 08 opcode 0x0e sloctc// Store at LOCation with offseT: Charfunction sloctc(): void{ $addr = tabchar(Alis::$script->vram_org + script_read16()); Alis::$varD7 = hread32(Alis::$acc); Alis::$acc += 4; xwrite8($addr, Alis::$varD7);}// Storename no. 09 opcode 0x10 slocti// Store at LOCation with offseT: Intfunction slocti(): void{ $addr = tabint(Alis::$script->vram_org + script_read16()); Alis::$varD7 = hread32(Alis::$acc); Alis::$acc += 4; xwrite16($addr, Alis::$varD7);}// Storename no. 10 opcode 0x12 sdirb// reads a byte (offset) from script, then stores d7 byte at (vram + offset)function sdirb(): void{ xwrite8(Alis::$script->vram_org + script_read8(), Alis::$varD7 & 0xff);}// Storename no. 11 opcode 0x14 sdirw// reads a byte (offset) from script, then stores d7 word at (vram + offset)function sdirw(): void{ $offset = script_read8(); xwrite16(Alis::$script->vram_org + $offset, Alis::$varD7);}// Storename no. 12 opcode 0x16 sdirp// reads a byte (offset) from script, then stores null-terminated string in ARRAY_C at (vram + offset)function sdirp(): void{ $offset = script_read8(); mem_strcpy(get_vram($offset), Alis::$oldsd7);}// Storename no. 13 opcode 0x18 sdirtpfunction sdirtp(): void{ $addr = tabstring(Alis::$script->vram_org + script_read8()); mem_strcpy($addr, Alis::$oldsd7);}// Storename no. 14 opcode 0x1a sdirtcfunction sdirtc(): void{ $addr = tabchar(Alis::$script->vram_org + script_read8()); Alis::$varD7 = hread32(Alis::$acc); Alis::$acc += 4; xwrite8($addr, Alis::$varD7);}// Storename no. 15 opcode 0x1c sdirtifunction sdirti(): void{ $addr = tabint(Alis::$script->vram_org + script_read8()); Alis::$varD7 = hread32(Alis::$acc); Alis::$acc += 4; xwrite16($addr, Alis::$varD7);}// Storename no. 16 opcode 0x1e smainbfunction smainb(): void{ $offset = s16(script_read16()); xwrite8(Alis::$basemain + $offset, Alis::$varD7 & 0xff);}// Storename no. 17 opcode 0x20 smainwfunction smainw(): void{ $offset = s16(script_read16()); xwrite16(Alis::$basemain + $offset, s16(Alis::$varD7));}// Storename no. 18 opcode 0x22 smainpfunction smainp(): void{ $offset = s16(script_read16()); mem_strcpy(Alis::$basemain + $offset, Alis::$oldsd7);}// Storename no. 19 opcode 0x24 smaintpfunction smaintp(): void{ $addr = tabstring(Alis::$basemain + script_read16()); mem_strcpy($addr, Alis::$oldsd7);}// Storename no. 20 opcode 0x26 smaintcfunction smaintc(): void{ $addr = tabchar(Alis::$basemain + script_read16()); Alis::$varD7 = hread32(Alis::$acc); Alis::$acc += 4; xwrite8($addr, Alis::$varD7);}// Storename no. 21 opcode 0x28 smaintifunction smainti(): void{ $addr = tabint(Alis::$basemain + script_read16()); Alis::$varD7 = hread32(Alis::$acc); Alis::$acc += 4; xwrite16($addr, Alis::$varD7);}// Storename no. 22 opcode 0x2a shimbfunction shimb(): void{ $offset = s16(script_read16()); $ent = xread16(Alis::$script->vram_org + $offset); $vram = xread32(Alis::$atent + $ent); $offset2 = s16(script_read16()); // v6, and the v3 DOS VM (0xa8e8): no write into a dead or not started entity (vram <= 0). if ($vram <= 0 && (Alis::$platform->version >= 60 || (Alis::$platform->kind == C::EPlatformPC && Alis::$platform->version >= 30))) { return; } xwrite8($vram + $offset2, Alis::$varD7 & 0xff);}// Storename no. 23 opcode 0x2c shimwfunction shimw(): void{ $offset = s16(script_read16()); $ent = xread16(Alis::$script->vram_org + $offset); $vram = xread32(Alis::$atent + $ent); $offset2 = s16(script_read16()); // v6, and the v3 DOS VM (0xa90f): no write into a dead or not started entity (vram <= 0). if ($vram <= 0 && (Alis::$platform->version >= 60 || (Alis::$platform->kind == C::EPlatformPC && Alis::$platform->version >= 30))) { return; } xwrite16($vram + $offset2, s16(Alis::$varD7));}// Storename no. 24 opcode 0x2e shimpfunction shimp(): void{ // MISSING in the C}// Storename no. 25 opcode 0x30 shimtpfunction shimtp(): void{ // MISSING in the C}// Storename no. 26 opcode 0x32 shimtcfunction shimtc(): void{ // MISSING in the C}// Storename no. 27 opcode 0x34 shimtifunction shimti(): void{ // MISSING in the C}// Storename no. 28 opcode 0x36 spilefunction spile(): void{ Alis::$acc -= 4; hwrite32(Alis::$acc, Alis::$varD7);}// Storename no. 29 opcode 0x38 sevalfunction seval(): void{ if (Alis::$platform->version >= 60) { Alis::$acc = Alis::$acc_org; } Alis::$acc -= 4; hwrite32(Alis::$acc, Alis::$varD7); oeval(); readexec_storename();}// Storename no. 30 opcode 0x3a ofin// Addname no. 30 opcode 0x3a ofin// Calls oper->ofinfunction cstore_continue(): void{ $tmp = Alis::$sd7; Alis::$sd7 = Alis::$oldsd7; Alis::$oldsd7 = $tmp; readexec_storename();}// ============================================================================// Store routines pointer table, indexed by the opcode byte (odd slots are NULL in the C)// ============================================================================function table_storenames(): array{ $t = [ pnul(...), null, pnul(...), null, pnul(...), null, slocb(...), null, slocw(...), null, slocp(...), null, sloctp(...), null, sloctc(...), null, slocti(...), null, sdirb(...), null, sdirw(...), null, sdirp(...), null, sdirtp(...), null, sdirtc(...), null, sdirti(...), null, smainb(...), null, smainw(...), null, smainp(...), null, smaintp(...), null, smaintc(...), null, smainti(...), null, shimb(...), null, shimw(...), null, shimp(...), null, shimtp(...), null, shimtc(...), null, shimti(...), null, spile(...), null, seval(...), null, ofin(...), ]; $names = [ 'pnul', 'pnul', 'pnul', 'slocb', 'slocw', 'slocp', 'sloctp', 'sloctc', 'slocti', 'sdirb', 'sdirw', 'sdirp', 'sdirtp', 'sdirtc', 'sdirti', 'smainb', 'smainw', 'smainp', 'smaintp', 'smaintc', 'smainti', 'shimb', 'shimw', 'shimp', 'shimtp', 'shimtc', 'shimti', 'spile', 'seval', 'ofin', ]; $n = []; foreach ($names as $i => $name) { $n[$i * 2] = $name; if ($i * 2 + 1 < count($t)) { $n[$i * 2 + 1] = ''; } } Tables::$names['storenames'] = $n; return $t;}// v6 selects its own table: the base one with the storenames_v6_ov entries (storenames_v6.php) applied,// and the add block merged at 0x3c..0x76 (was readexec_storename's `addnames[code - 0x3c]` case).// PORT: the C caches the first result in a static; cached per v6-ness here (game switch in one process).function alis_tab_storenames(): array{ static $live = []; $v6 = Alis::$platform->version >= 60 ? 1 : 0; if (!isset($live[$v6])) { $t = table_storenames(); if ($v6) { foreach (table_storenames_v6_ov() as $code => [$f, $name]) { $t[$code & 0xff] = $f; Tables::$names['storenames'][$code & 0xff] = $name; } // memcpy(&storenames_v6[0x3c], alis_tab_addnames(), sizeof(sAlisOpcode) * 0x3c) $add = alis_tab_addnames(); for ($i = 0; $i < 0x3c; $i++) { $t[0x3c + $i] = $add[$i] ?? null; Tables::$names['storenames'][0x3c + $i] = Tables::$names['addnames'][$i] ?? ''; } } $live[$v6] = $t; } return $live[$v6];}