EN
games/alis / docs / vm / audit-entries.json · commit 9c722cf
[ {  "table": "opcodes 0x18432",  "index": "0x00",  "name": "cnul",  "original_addr": "0x38ef",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:37",  "status": "differs",  "severity": "low",  "details": "Original: bare RET at 0x38ef: a 1-byte no-op, execution simply continues with the next byte (the same address is used for opcodes 0x37, 0x8b and esc1[0]). Port: cnul() sets Alis::$state = eAlisStateStopped, which halts the whole VM. Scripts: 'nul' appears 53 times, and every one comes right after 'exit' (padding/dead code), so it should never run unless an earlier opcode lost sync.",  "fix": "Make cnul() a no-op for the DOS v31 VM (return with no effect). If the halt is still wanted as a desync guard, keep it only behind a debug flag, because the original carries on.",  "used_by_game": "53 (all after exit, unreachable)" }, {  "table": "opcodes 0x18432",  "index": "0x01",  "name": "cesc1",  "original_addr": "0x38f0",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:62",  "status": "same",  "severity": "none",  "details": "Original: lodsb, then jmp [eax*4+0x18832] (7-entry escape table: 0x38ef, 0x95c1, 0x95c9, 0x95d1, 0x95d9, 0x8ef9, 0x8e5b). There is no bounds check and no version test. Port: for version 31, readexec_codesc1name() reads one byte and dispatches through Tables::$tab_codesc1, so the same bytes are consumed. Side note for the esc1 audit: esc1[0] is a RET no-op in the original, but the port's codesc1names[0] is presumably cnul, which stops the VM (same issue as opcode 0x00).",  "fix": "",  "used_by_game": "0 as 'esc1' (escape statements appear under their own names)" }, {  "table": "opcodes 0x18432",  "index": "0x02",  "name": "cesc2",  "original_addr": "0x38f8",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:77",  "status": "differs",  "severity": "low",  "details": "Original: bare RET at 0x38f8, a 1-byte no-op that reads no operand. Port: for version 31 (not 10 and below 60) it calls readexec_codesc2name(), which reads one extra script byte and dispatches through table_codesc2names() (escnames.php:169, which holds only [cnul]). With byte 0 the VM stops; with any other byte the array key is undefined and PHP hits a fatal error. The stream gets out of sync by 1 byte compared with the original.",  "fix": "In cesc2(), return without reading anything when the platform is the DOS v31 VM (or in every case except a proven version that has an esc2 table).",  "used_by_game": "0" }, {  "table": "opcodes 0x18432",  "index": "0x03",  "name": "cesc3",  "original_addr": "0x38f9",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:88",  "status": "differs",  "severity": "low",  "details": "Original: bare RET at 0x38f9, a 1-byte no-op. Port: calls readexec_codesc3name(), which consumes one more byte and dispatches through table_codesc3names() ([cnul] only, escnames.php:181): the VM stops or PHP hits a fatal error, and the stream is desynced by 1 byte.",  "fix": "In cesc3(), return without reading anything for the v31 DOS VM.",  "used_by_game": "0" }, {  "table": "opcodes 0x18432",  "index": "0x04",  "name": "cbreakpt",  "original_addr": "0x1992",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:104",  "status": "same",  "severity": "none",  "details": "Original: bare RET at 0x1992 (no operand). Port: empty function. Same.",  "fix": "",  "used_by_game": "0" }, {  "table": "opcodes 0x18432",  "index": "0x05",  "name": "cjsr8",  "original_addr": "0x38fb",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3224",  "status": "same",  "severity": "none",  "details": "Original: lodsb; sp=[es:ebp-0xa] (s16) - 4; stores sp back at [ebp-0xa]; [ebp+sp] = ESI (absolute address after the operand); ESI += sign-extended byte. Port: s8 offset; xpush32(pc - pc_org) (vacc_off -= 4, s16, writes at vram_org+vacc_off); pc += offset. The port pushes an offset relative to pc_org instead of an absolute address, and cret adds pc_org back, so the behaviour is equivalent as long as the script does not move between call and ret. Same bytes consumed, same stack slot.",  "fix": "",  "used_by_game": "1555 'call' in total for 0x05/0x06/0x07 (backward calls use 8/16-bit, forward ones 24-bit)" }, {  "table": "opcodes 0x18432",  "index": "0x06",  "name": "cjsr16",  "original_addr": "0x3913",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3233",  "status": "same",  "severity": "none",  "details": "Original: lodsw; pushes ESI (after the 2-byte operand) on the script stack at [ebp-0xa]; ESI += sign-extended word. Port: s16(script_read16()), then cjsr(): pushes the return offset and adds the offset. Same.",  "fix": "",  "used_by_game": "part of 1555 'call'" }, {  "table": "opcodes 0x18432",  "index": "0x07",  "name": "cjsr24",  "original_addr": "0x392c",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3241",  "status": "same",  "severity": "none",  "details": "Original: lodsw; inc esi (the 3rd byte is skipped, so only a signed 16-bit offset is used); pushes ESI (after the 3 bytes); ESI += s16. Port: read_off24() (opcodes_a.php:321): on a little-endian platform with version < 60 it reads s16 and skips 1 byte. That matches the original exactly, including the ignored high byte.",  "fix": "",  "used_by_game": "part of 1555 'call' (every forward call)" }, {  "table": "opcodes 0x18432",  "index": "0x08",  "name": "cjmp8",  "original_addr": "0x3946",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3253",  "status": "same",  "severity": "none",  "details": "Original: lodsb; movsx; ESI += offset (relative to after the operand). Port: pc += s8(read8). Same.",  "fix": "",  "used_by_game": "7285 'goto' in total over every goto form (includes if/ifnot/case gotos)" }, {  "table": "opcodes 0x18432",  "index": "0x09",  "name": "cjmp16",  "original_addr": "0x394d",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3261",  "status": "same",  "severity": "none",  "details": "Original: lodsw; movsx; ESI += offset. Port: pc += s16(read16). Same.",  "fix": "",  "used_by_game": "part of the gotos (backward jumps)" }, {  "table": "opcodes 0x18432",  "index": "0x0a",  "name": "cjmp24",  "original_addr": "0x3955",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3269",  "status": "same",  "severity": "none",  "details": "Original: lodsw; inc esi; ESI += s16 (the 3rd byte is ignored). Port: read_off24() in little-endian mode, s16 then skip 1 byte. Same.",  "fix": "",  "used_by_game": "part of the gotos (every forward goto)" }, {  "table": "opcodes 0x18432",  "index": "0x0b",  "name": "cjsrabs",  "original_addr": "0x3a4d",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:110",  "status": "same",  "severity": "none",  "details": "Original: bare RET (1-byte no-op, no operand). Port: empty function. Same.",  "fix": "",  "used_by_game": "0" }, {  "table": "opcodes 0x18432",  "index": "0x0c",  "name": "cjmpabs",  "original_addr": "0x3a4e",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:116",  "status": "same",  "severity": "none",  "details": "Original: bare RET. Port: empty function. Same.",  "fix": "",  "used_by_game": "0" }, {  "table": "opcodes 0x18432",  "index": "0x0d",  "name": "cjsrind16",  "original_addr": "0x3a4f",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:122",  "status": "same",  "severity": "none",  "details": "Original: bare RET. Port: empty function. Same.",  "fix": "",  "used_by_game": "0" }, {  "table": "opcodes 0x18432",  "index": "0x0e",  "name": "cjsrind24",  "original_addr": "0x3a50",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:129",  "status": "same",  "severity": "none",  "details": "Original: bare RET. Port: empty function. Same.",  "fix": "",  "used_by_game": "0" }, {  "table": "opcodes 0x18432",  "index": "0x0f",  "name": "cjmpind16",  "original_addr": "0x3a51",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:135",  "status": "same",  "severity": "none",  "details": "Original: bare RET. Port: empty function. Same.",  "fix": "",  "used_by_game": "0" }, {  "table": "opcodes 0x18432",  "index": "0x10",  "name": "cjmpind24",  "original_addr": "0x3a52",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:141",  "status": "same",  "severity": "none",  "details": "Original: bare RET. Port: empty function. Same.",  "fix": "",  "used_by_game": "0" }, {  "table": "opcodes 0x18432",  "index": "0x11",  "name": "cret",  "original_addr": "0x3a53",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3200",  "status": "same",  "severity": "none",  "details": "Original: if byte [0x15fcb] (fseq) == 0 and s16 [ebp-0xa] (vacc_off) >= [0x16006] (saversp), it jumps to 0x41c0 (add esp,4; ret, which leaves the run loop: the same handler as cstop, opcode 0x42). Otherwise: ESI = [ebp+sp] (absolute return address); if sp == [ebp-0xc] then [ebp-0xc] = 0; [ebp-0xa] += 4. Port: if fseq == 0 and saversp <= vacc_off it calls cstop() (running = 0); otherwise pc = pc_org + xpeek32(); clears 0x0c when vacc_off == get_0x0c; vacc_off = s16(vacc_off + 4). Same condition (signed 16-bit), same order of effects. The return value is stored as an offset rather than an absolute address, consistent with cjsr and cstart in the port.",  "fix": "",  "used_by_game": "635" }, {  "table": "opcodes 0x18432",  "index": "0x12",  "name": "cbz8",  "original_addr": "0x3af5",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3287",  "status": "same",  "severity": "none",  "details": "Original: test dx,dx (16-bit value of the last expression, d7). If zero: lodsb, ESI += s8. Otherwise: inc esi (skips the operand). Port: bztest() returns s16(varD7) for DOS. If zero, pc += s8(read8); otherwise pc += 1. Same (16-bit test, as in the original; the 3DO version uses 32 bits).",  "fix": "",  "used_by_game": "part of 497 'ifnot expr goto' (cbz 8/16/24; 'ifz goto' 0)" }, {  "table": "opcodes 0x18432",  "index": "0x13",  "name": "cbz16",  "original_addr": "0x3b03",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3296",  "status": "same",  "severity": "none",  "details": "Original: test dx; if zero: lodsw, ESI += s16; otherwise ESI += 2. Port: identical, with s16(varD7).",  "fix": "",  "used_by_game": "part of 497 'ifnot ... goto'" }, {  "table": "opcodes 0x18432",  "index": "0x14",  "name": "cbz24",  "original_addr": "0x3b14",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3305",  "status": "same",  "severity": "none",  "details": "Original: test dx; if zero: lodsw, inc esi, ESI += s16 (the 3rd byte is ignored); otherwise ESI += 3. Port: if zero, read_off24() (s16, then skips 1 byte); otherwise pc += 3. Same.",  "fix": "",  "used_by_game": "part of 497 'ifnot ... goto' (every forward one)" }, {  "table": "opcodes 0x18432",  "index": "0x15",  "name": "cbnz8",  "original_addr": "0x3b26",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3318",  "status": "same",  "severity": "none",  "details": "Original: test dx,dx. If non-zero: lodsb, ESI += s8. If zero, it falls through to inc esi (skips the 1-byte operand), mirroring 0x3af5. Port: if s16(varD7) == 0, pc += 1; otherwise pc += s8(read8). Same.",  "fix": "",  "used_by_game": "part of 303 'if expr goto' (cbnz 8/16/24; 'ifnz goto' 0)" }, {  "table": "opcodes",  "index": "0xc6",  "name": "cscscale",  "original_addr": "0x4875",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:777",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: one expression (0x9d24); bx=[ebp-0x16] screen id, if !=0: scr=basemain([0x15fa0])+id; byte scr+0x1c = DL (result); byte scr+0 = CL; then scr+0 |= 0x80. CL is CX at the end of evaluation; 0x9d24 starts with mov cx,dx, so for a plain operand CL = low byte of DX/varD7 left by the previous opcode: the original OVERWRITES the screen state byte with that leftover byte before setting 0x80 (an original quirk). Port (non-3DO path): writes scr+0x1c = s8(varD7) and only ORs 0x80 into the state byte, keeping the other state bits.",  "fix": "To be exact: save the previous varD7 before readexec_opername() and do set_scr_state(id, (prevD7 & 0xff) | 0x80) instead of get_scr_state|0x80 (only matters if the game used it; it does not)." }, {  "table": "opcodes",  "index": "0xc7",  "name": "creducing",  "original_addr": "0x57f2",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:805",  "status": "same",  "severity": "none",  "used_by_game": "96 (36 files)",  "details": "Original: expr -> byte [ebp-0x26]; expr -> byte [ebp-0x27]. Port: set_0x26_creducing / set_0x27_creducing with the two expression results (byte writes at vram-0x26/-0x27). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0xc8",  "name": "cscmap",  "original_addr": "0x4895",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:814",  "status": "same",  "severity": "none",  "used_by_game": "1 (scmap 0, &v[0xe5e])",  "details": "Original: expr (result thrown away); cx=[ebp-0xe]; lodsw ax; if ax==0 {cx=0; lodsw ax}; if word [ebp-0x16]!=0: word scr+0x42=ax, word scr+0x40=cx. Port: readexec_opername, ent=get_0x0e_script_ent, val=script_read16 (twice if 0 -> ent=0), same writes at basemain+screen+0x42/+0x40. Same operands and effects.",  "fix": "" }, {  "table": "opcodes",  "index": "0xc9",  "name": "cscdump",  "original_addr": "0x4923",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:161",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: a bare ret (no operand). Port: empty function. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0xca",  "name": "cfindcla",  "original_addr": "0x7c4f",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:832",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: expr (DL = class); walks the entity chain from index 0 ([0x15f72]=atent, next at +4); keeps entities with byte [vram+0x4c]==DL and vram!=current: matent (+0x100)=0, tablent word=index; stops after the first one unless fallent [0x16056]!=0; ends with 0xffff, clears fallent, jmp 0x7610 (= crstent: ptr=0x17a2a, then csuccent stores the first one through the store table). Port v<60 path: same test (s8 compare at +0x4c, not self), same fallent handling, ENTLIST_END, fallent=0, crstent(). Only change: the port stops at 255 entries (tabent_full); the original table at 0x17a2a has no check (128 words before matent at +0x100). No practical difference.",  "fix": "" }, {  "table": "opcodes",  "index": "0xcb",  "name": "cnearcla",  "original_addr": "0x7fb5",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:891",  "status": "stub_in_port",  "severity": "medium",  "used_by_game": "0",  "details": "Original: fview [0x16034]=0; expr = distance, squared 16x16 unsigned mul -> valnorme [0x16036]/[0x16038]; lodsw = 16-bit immediate class; then the same sorted nearest search as cneartyp (0x7e9d), except that the test is byte [ent+0x4c] (class) instead of word [ent-0x10] (type), and 0x15eaa is not set: same world (word +0x30), not self, call 0x82bf (distance/view test), insertion sorted by distance (buffer 0x1802c, 0x7fffffff sentinel when fallent==0), 0x7ceb called when fallent!=0, fallent=0, jmp 0x7610 (crstent + store operand). Original quirk: the class word goes into DX at 0x7fd6, but at 0x7fe0 'lea edx,[0x1802c]' overwrites it, so 'cmp dl,[edi+0x4c]' at 0x801d compares the class with the low byte of the distance-buffer pointer (0x30 when fallent==0, so in effect class==48 whatever the operand; 0x2c + 4*n when fallent!=0). Port: for v<60 does NOTHING and reads no operand (expr, word and store target are left in the stream): the script would lose sync. Grammar.php also lists 0xcb with no operands ('').",  "fix": "In cnearcla() for v<60: Alis::$fview=0; readexec_opername(); Alis::$valnorme = mul32(varD7,varD7) (16-bit unsigned like cneartyp); Alis::$varD7 = script_read16(); then a sviewcla() = copy of sviewtyp() (opcodes_a.php:1842) where the test is on the byte at tgt_vram+0x4c instead of get_0x10_script_id. To be faithful, compare it with 0x30 (fallent==0) or 0x2c+4*count (fallent!=0) and not with the operand. Fix Grammar 0xcb to 'E w S'." }, {  "table": "opcodes",  "index": "0xcc",  "name": "cviewcla",  "original_addr": "0x8255",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:900",  "status": "stub_in_port",  "severity": "medium",  "used_by_game": "0",  "details": "Original: fview [0x16034]=1; expr distance squared -> [0x16036/38]; expr -> valchamp [0x1603a]; lodsw class; jmp 0x7fd9 = the cnearcla loop (class test at +0x4c, with the same DL quirk: it compares the low byte of the distance-buffer pointer), then crstent + store operand. Port: v<60 does nothing and reads no operand: the stream loses sync (Grammar also has '').",  "fix": "For v<60: fview=1; readexec_opername(); valnorme=d7*d7; readexec_opername(); valchamp=s16(d7); varD7=script_read16(); then the same sviewcla() as cnearcla. Grammar 0xcc -> 'E E w S'." }, {  "table": "opcodes",  "index": "0xcd",  "name": "cinstru",  "original_addr": "0x94be",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:909",  "status": "differs",  "severity": "low",  "used_by_game": "4 (2 files: instru vw[0x5a], vw[0x5a]+2 / 2, vw[0x58])",  "details": "Original: [0x15fc7]=0; expr -> di (slot); expr -> resource index; 0x9484 resolves the address AT ONCE with no check (ebx=[ebp-0x14]; +=[ebx+0xe]; +=[ebx+0xc]; += movsx16(idx*4); +=[ebx]); expr -> instrument value; if byte [addr] is 1, 2 or 6: slot&=0x1f; dword [0x160be+slot*8]=addr+0x10, dword [0x160c2+slot*8]=movsx(value). Port: adds a type-5 case (5 accepted, the original refuses it); a branch for a negative index (address 0, value 0) that the original does not have (it resolves a negative offset); adresmus with a bound check (len>idx else mem+0x11) the original does not do; the slot is not masked with 0x1f (Aud::$tabinst has 128 entries, an index >=128 or <0 would fail in PHP, the original wraps to 32 slots).",  "fix": "cinstru/cminstru: $tabidx &= 0x1f; accept only types 1, 2, 6 (drop 5) for RRQ DOS. Optionally drop the scridx<0 special case. Harmless for the game's uses (index 2 / vw[0x5a]+2, within range)." }, {  "table": "opcodes",  "index": "0xce",  "name": "cminstru",  "original_addr": "0x94b5",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:939",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Same as cinstru with [0x15fc7]=1: 0x9484 then uses the main script (ebp=[0x15fa0]) for the resource table; the port does it through flagmain=1 -> Alis::$main->vram_org. Same differences as cinstru: type 5 accepted, negative-index branch, no &0x1f on the slot, bound check in adresmus.",  "fix": "As cinstru: slot &= 0x1f, types 1/2/6 only." }, {  "table": "opcodes",  "index": "0xcf",  "name": "cordspr",  "original_addr": "0x5842",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:967",  "status": "same",  "severity": "none",  "used_by_game": "9 (6 files)",  "details": "Original: expr -> byte [ebp-0x2b]. Port: set_0x2b_cordspr(vram, d7&0xff). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0xd0",  "name": "calign",  "original_addr": "0x5811",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:974",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: expr; al = 4 if DL&0x10, 3 if &8, 2 if &4, 1 if &2, else 0 -> byte [ebp-0x2c]; expr -> byte [ebp-0x2d]. Port: same priority encoding and the same two byte writes.",  "fix": "" }, {  "table": "opcodes",  "index": "0xd1",  "name": "cbackstar",  "original_addr": "0x8f05",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1003 (RRQ case 1059-1075)",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: 6 expressions -> words 0x19676..0x19680, word 0x19682=0 (only 0x19676 is read again in the whole image); if word [ebp-0x16] >= 0 (signed): scr=id+basemain; byte scr+1 &= 0xe7; if word [0x19676] (the FIRST value) != 0: byte scr+1 |= 0x18. Port (RRQ case): tests Alis::$varD7, i.e. the SIXTH value (starbuff[5]), not the first; and on a non-zero value it also calls rescmode($at,$value) (line 1070), which writes sprite_var(word scr+2)->numelem = value|flags. The original has no such write (it corrupts the numelem of the screen's first sprite).",  "fix": "In the RRQ branch: test Opcodes2Vars::$starbuff[0] != 0 instead of Alis::$varD7, and remove the rescmode() call (lines 1068-1070)." }, {  "table": "opcodes",  "index": "0xd2",  "name": "cstarring",  "original_addr": "0x8f7d",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1084",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: 8 expressions stored into words 0x19676..0x19684, nothing else (push/pop edi only). Port: for non-Colorado reads 8 expressions into starbuff[0..7]. Same operands; the values are never used by anything else in either.",  "fix": "" }, {  "table": "opcodes",  "index": "0xd3",  "name": "cengine",  "original_addr": "0x9196",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1111",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: a bare ret, no operand. Port: returns at once for EPlatformPC (RRQ DOS) without reading operands. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0xd4",  "name": "cautobase",  "original_addr": "0xa392",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:167",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: a bare ret. Port: empty. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0xd5",  "name": "cquality",  "original_addr": "0x95bb",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1128",  "status": "same",  "severity": "none",  "used_by_game": "4 (2 files: quality 1)",  "details": "Original: one expression, result thrown away (call 0x9d24; ret). Port: reads one expression and stores it in Alis::$vquality, which nothing reads (only Alis.php:299 declares it). No observable difference.",  "fix": "" }, {  "table": "opcodes",  "index": "0xd6",  "name": "chsprite",  "original_addr": "0x5861",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1135",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: expr -> byte [ebp-0x2f]; then 3 expressions thrown away. Port: set_0x2f_chsprite(s8(d7)) and 3 more readexec_opername in both branches. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0xd7",  "name": "cselpalet",  "original_addr": "0x87d4",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1156",  "status": "platform",  "severity": "none",  "used_by_game": "0",  "details": "Original: expr -> byte [0x15f9e] (no mask), byte [0x15f9f]=1 (written only here, never read). 0x15f9e is a one-shot 'skip' flag read by the palette code (0x894d: when 0 and the resource starts with 0xfe it applies the palette; cleared at 0x897f/0x8ad7). Port: dos_pal_active() is true for RRQ (DPAL_B32) -> dos_cselpalet sets ImageVars::$dpal_skip = val&0xff, read and cleared by the palette loaders (image.php:615/634). Same behaviour.",  "fix": "" }, {  "table": "opcodes",  "index": "0xd8",  "name": "clinepalet",  "original_addr": "0x87c9",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1170",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: expr (0x9d24) + expr (0x9d17: push dx, eval, cx=dx, pop dx), no effect. Port: reads two expressions; setlinepalet is skipped because dos_pal_active() is true for RRQ DOS. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0xd9",  "name": "cautomode",  "original_addr": "0xa393",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1181",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: reads ONE expression and throws the result away (call 0x9d24; ret). Port: reads the operand only for EGameRobinsonsRequiem3DO; for RRQ DOS it reads nothing, so the operand is left in the stream (desync if used). Grammar.php:76 also gives it no operand ('').",  "fix": "cautomode(): readexec_opername() for every platform (at least for RRQ DOS / v3); Grammar 0xd9 -> 'E'." }, {  "table": "opcodes",  "index": "0xda",  "name": "cautofile",  "original_addr": "0xa399",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1192",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: call 0x9d3d = swaps the string buffer pointers [0x16008]<->[0x1600c] (never swapped back), then evaluates one expression (enters at 0x9d2d, without the 'lea ebx' / 'mov cx,dx' of 0x9d24); nothing else. Port: readexec_opername_swap() (swaps sd7/sd6, not restored, then evaluates) and copies 12 bytes of sd7 into Alis::$autoname, which nothing reads. Same observable behaviour.",  "fix": "" }, {  "table": "opcodes",  "index": "0xdb",  "name": "ccancel",  "original_addr": "0x5cb7",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1205",  "status": "stub_in_port",  "severity": "medium",  "used_by_game": "0",  "details": "Original: ferase [0x15f9d]=1; call 0x5cc4 (= the cerase handler, opcode 0x4a: searchtete 0x5737, then kills the current screen's elements of this entity through 0x5d16, which with ferase=1 returns them to the free list 0x15f90 and calls 0x5d94 to unlink them from the screen right away instead of marking them for a delayed erase); ferase=0. No operand. Port: empty function (no operand read either, so no desync), but the sprites are not cancelled.",  "fix": "ccancel(): Alis::$ferase = 1; cerase(); (cerase() in opcodes_a.php:1028 runs the v<60 searchtete/killelem loop and sets ferase back to 0)." }, {  "table": "opcodes",  "index": "0x6e",  "name": "cnoise",  "original_addr": "0x944f",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2522",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original DOS v31: four calls to 0x9d24 (evaluates 4 expressions) then ret. No sound at all, no global written. Port (v31, PC): psg_ops_dos_v6() returns 0 for version<60, so it reads the 4 operands the same way and then calls runson(eChannelTypeNoise, ...) (when longson != 0). So the port plays a noise channel where DOS stays silent. The script stays in sync.",  "fix": "In cnoise(): for kind==EPlatformPC && version>=30 (the DOS v3 interpreter), evaluate 4 operands and return. For example, make psg_ops_dos_v6() (opcodes_v6a.php:1419) also return 1 for PC v30..59, which keeps cding/czap consistent, if they also turn out to be no-ops in DOS." }, {  "table": "opcodes",  "index": "0x6f",  "name": "cinitab",  "original_addr": "0x87b3",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2557",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original: lodsw -> movsx edi (offset), lodsw -> movsx ecx (count), dec ecx, edi += ebp, rep movsb: copies count-1 inline script bytes to vars[ebp+offset] and advances ESI past them (if count==0, ecx=-1 and the copy runs away: an original bug). Port: for version 31 (not 3DO, not v>=60, not v10) the code falls to '// MISSING: cinitab'. It consumes NO operand, so the script would desync (the following bytes would be decoded as opcodes).",  "fix": "In cinitab(), use the v>=60 branch (off=s16(read16), count=s16(read16), copy count-1 bytes to vram_org+off) for version>=30 as well (condition: version >= 30 && uid != RRQ3DO)." }, {  "table": "opcodes",  "index": "0x70",  "name": "cfopen",  "original_addr": "0x9678 (-> open routine 0x2dcd)",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2594 (afopen fn/alis.php:1538, sys_fopen_b fn/sys.php:913)",  "status": "differs",  "severity": "high",  "used_by_game": "44 (modes 2, 770=0x302, 2050=0x802; inline names and vs[] strings)",  "details": "Operand reading is the same. Inline form: NUL-terminated name, then a word mode. 0xff form: esi++, then 0x9d3d (swap 0x16008/0x1600c + string expression), then 0x9d24 (mode); name=[0x16008]. The port uses readexec_opername_swap + readexec_opername + sd7, which is equivalent. Open routine 0x2dcd: typepack[0x15ee4]=0. Mode 0x100: if the file does not exist (0x2f71), create it (0x3035, int21 3Ch) and return. Mode 0x200: if it exists, create/truncate it and return. Otherwise int21 3Dh AL=2 (always read/write, whatever the low bits), handle in [0x15f5a], with a CD-drive retry (platform); on failure error 1 (0x144a0). Mode 0x800: read 12 bytes into 0x1802c. 'PB60' -> typepack=0xa0, wordpack=0, longpack=BE dword. 'PW60' -> wordpack=1. OTHERWISE lseek(handle,0,SEEK_SET) (0x2f2d-0x2f42) rewinds to offset 0. Mode 0x400: lseek to the end. DIFFERENCE 1 (real bug): port afopen (alis.php:1551-1570) never rewinds when the 12-byte header is not PB60/PW60. main.als:1955 'fopen z\"canyon.dat\", 2050' opens an UNPACKED file (starts c400c400...). The next 'freadb &v[0xe5e], 262144' (main.als:1981) therefore reads from offset 12 in the port: the table is shifted by 12 bytes and its last 12 bytes are stale. Every other 2050 file starts with PW60, so only canyon.dat is affected. DIFFERENCE 2: plain mode 2 opens 'rb' (read-only) in the port, while the original opens read/write. The game only reads after mode-2 opens, so this has no effect. DIFFERENCE 3: 0x200 on a missing file is an error in the original; the port's 'wb' creates the file. Mode 0x400 is 'ab' in the port (writes always at the end, no reads) instead of RW + seek-to-end. Not used.",  "fix": "In afopen() (fn/alis.php:1551): after the 12-byte read with 0x800, when type is neither 0x50423630 nor 0x50573630, call fseek(Alis::$fp, 0, SEEK_SET). Optional: in sys_fopen_b, open plain modes as 'r+b' with a fallback to 'rb' (RW like DOS AL=2), and for 0x400 use 'r+b' + fseek(SEEK_END)." }, {  "table": "opcodes",  "index": "0x71",  "name": "cfclose",  "original_addr": "0x96a8 -> 0x2feb",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2620",  "status": "same",  "severity": "none",  "used_by_game": "35",  "details": "Original: int21 3Eh on handle [0x15f5a]. On carry, error 0xe (0x302a -> 0x144a0). Also a CD-drive restore when [0x18ab5]==1 (platform). No operand. Port: sys_fclose(Alis::$fp), alis_error(FCLOSE) on failure, fp=null. Equivalent.",  "fix": "" }, {  "table": "opcodes",  "index": "0x72",  "name": "cfcreat",  "original_addr": "0x96ad",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2630",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original: edx=esi (name), skips the inline NUL-terminated name, lodsw (a word, ignored), call 0x3035 (int21 3Ch create/truncate with CX=0, handle -> [0x15f5a], error 8 on failure), then call 0x2feb (close it). So it creates or truncates an empty file. Port v31: '// MISSING: cfcreat'. It consumes nothing (the script desyncs) and creates no file. The 3DO branch (name + word, fopen 'ab') and the v10 branch only skip operands.",  "fix": "In cfcreat(), for version>=30 non-3DO, read the NUL-terminated name, read16, then sys_fopen(path.name,'wb') + sys_fclose (create/truncate like DOS 3Ch). Raise alis_error on failure." }, {  "table": "opcodes",  "index": "0x73",  "name": "cfdel",  "original_addr": "0x96c1 -> 0x3081",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2668",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original: edx=esi, skips the inline NUL-terminated name (no 0xff expression form in DOS), int21 41h delete. Error 9 (0x144a0) if it fails. Port v31: '// MISSING: cfdel'. No operand is consumed (desync) and nothing is deleted.",  "fix": "In cfdel(), for version>=30 non-3DO, read the NUL-terminated inline name and sys_fdelete(path.name)." }, {  "table": "opcodes",  "index": "0x74",  "name": "cfreadv",  "original_addr": "0x96ce",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2703",  "status": "same",  "severity": "low",  "used_by_game": "400",  "details": "Original: reads 2 bytes into the shared buffer 0x1802c (0x30bb, int21 3Fh, error 0xd only on carry). dx=word with its bytes swapped (big-endian file value, 16-bit). jmp 0x3bd1: swaps [0x16008]<->[0x16010] and dispatches the store target (cstore continuation). Port: same 2-byte BE read, varD7=s16, cstore_continue() (swaps sd7/oldsd7 + readexec_storename). Edge case: on a short read/EOF, the original keeps the stale bytes of 0x1802c (also used by the fopen header and cfwritev); the port pads with zeros.",  "fix": "Optional: on a short read, keep the previous Alis::$buffer[0..1] bytes for the missing ones instead of \\0, and have cfwritev store its swapped word in Alis::$buffer[0..1] (the original shares 0x1802c)." }, {  "table": "opcodes",  "index": "0x75",  "name": "cfwritev",  "original_addr": "0x96ec",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2715",  "status": "same",  "severity": "none",  "used_by_game": "400",  "details": "Original: 0x9d24 evaluates one expression, xchg dl,dh, stores the word in 0x1802c and writes 2 bytes (0x312c, int21 40h, error 7 on carry). Port: readexec_opername and fwrite of the big-endian 16-bit word. Same bytes in the file. The port has no write-error check and does not update the shared buffer (no visible effect).",  "fix": "" }, {  "table": "opcodes",  "index": "0x76",  "name": "cfwritei",  "original_addr": "0x970b",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2730",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original: ecx=length of the inline NUL-terminated string INCLUDING the NUL, edx=start, ESI advanced past it, then 0x312c writes the string and its NUL to the open file. Port v31: '// MISSING: cfwritei'. No operand is consumed (desync) and nothing is written. The port's v>=60 branch does exactly the DOS behaviour.",  "fix": "Extend the v>=60 branch of cfwritei() to version>=30 (non-3DO): len=mem_strlen(pc)+1, write those bytes, pc+=len." }, {  "table": "opcodes",  "index": "0x77",  "name": "cfreadb",  "original_addr": "0x971b",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2861",  "status": "differs",  "severity": "low",  "used_by_game": "96",  "details": "Original: edi=ebp. lodsw off; if 0, edi=[0x15fa0] (basemain) and lodsw again. edi+=sext(off). If byte[edi-1]<0 (indirect table, 0x9796): edx=[edi]; if <=0, error 0x1a (0x144a0) and ret WITHOUT reading the length dword; else edx=[edx] (no check on the second pointer). Then lodsd length. If typepack[0x15ee4]: unpack 0xb074(length), and 0xb36a (unmixword) when wordpack[0x15ee5]; else read (0x30bb, chunks of 0xfa00, error 0xd). Then if byte[cell-2]==2, byte-swap length/2 words in place. Port: read_vaddr is the same, the length/typepack/unmixword/fic_swap logic is the same (fic_cellsize(cell)==2 matches [edi-2]==2). Differences only in the error path: the port reads [[cell]] and tests the SECOND pointer (<1 -> return without consuming the length) instead of the first ([cell]<=0 -> error 0x1a); no error is raised. Normal game data is unaffected. Note the 12-byte offset bug on canyon.dat comes from cfopen, not from here.",  "fix": "Optional: in the indirect branch (opcodes_a.php:2873-2878) test p1=xread32(cell) <= 0 (then alis_error 0x1a / return without reading the length), and only then addr=xread32(p1)." }, {  "table": "opcodes",  "index": "0x78",  "name": "cfwriteb",  "original_addr": "0x97ae",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2918",  "status": "differs",  "severity": "low",  "used_by_game": "95",  "details": "Original: same address resolution as cfreadb. Indirect: [cell]<=0 -> error 0x1a, ret, length NOT consumed; else data=[[cell]]. Then lodsd length. If byte[cell-2]==2: swap the words in place, write (0x312c), swap back; else write. Port (v>=30 branch): reads the length FIRST (always consumed). Indirect: writes only if addr2=[[cell]]!=0 and tests the second pointer, not the first. No error is raised. The normal path (direct cell, or valid indirect) writes the same bytes with the same swap/unswap (writeswap).",  "fix": "Optional: in cfwriteb() (opcodes_a.php:2929-2941), in the indirect case test xread32(cell) <= 0 first (error/return before script_read32), then read the length." }, {  "table": "opcodes",  "index": "0x79",  "name": "cplot",  "original_addr": "0x981e",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2962",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: 2 expressions (0x9d24 x2), nothing else. Port: pen_ops_nodraw() is true for PC v>=30, so it reads 2 operands and returns.",  "fix": "" }, {  "table": "opcodes",  "index": "0x7a",  "name": "cdraw",  "original_addr": "0x9829",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2980",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: 0x9d24, then 0x9d17 (evaluate with DX saved). Nothing drawn, no state changed. Port: readexec_opername + readexec_opername_saveD6, then pen_ops_nodraw() returns before any drawing or pen update. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x7b",  "name": "cbox",  "original_addr": "0x9834",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2998",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: 0x9d24 + 0x9d17, no effect. Port: 2 operands, pen_ops_nodraw() return. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x7c",  "name": "cboxf",  "original_addr": "0x983f",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3016",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: 0x9d24 + 0x9d17, no effect. Port: 2 operands, pen_ops_nodraw() return. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x7d",  "name": "cink",  "original_addr": "0x984a",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3034",  "status": "same",  "severity": "none",  "used_by_game": "1 (time.als:1063, dead code)",  "details": "Original: 1 expression, byte [0x15f32]=dl. That global has no other reference in the image (dead store). Port: Img::$inkcolor = varD7 & 0xffff (16-bit instead of 8). It is only read by draw_pixel/draw_boxf, which are never reached on PC v31. No visible difference.",  "fix": "" }, {  "table": "opcodes",  "index": "0x7e",  "name": "cpset",  "original_addr": "0x9862",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3041",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: 2 expressions, no effect. Port (v<60): sets Alis::$poldx/poldy from them. That pen position is only used by the drawing ops (no-ops on DOS v31) and by picture_v10. Same operands consumed, no observable difference.",  "fix": "" }, {  "table": "opcodes",  "index": "0x7f",  "name": "cpmove",  "original_addr": "0x986d",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3056",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: 2 expressions, no effect. Port (v<60): adds them to poldx/poldy, which is unobservable on DOS v31. Same operands consumed.",  "fix": "" }, {  "table": "opcodes",  "index": "0x80",  "name": "cpmode",  "original_addr": "0x9878",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3071",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: 1 expression, byte [0x15f33]=dl, which no other code references (dead store). Port: Img::$line_a_mode = varD7&0xffff, with no other user in the port. Equivalent.",  "fix": "" }, {  "table": "opcodes",  "index": "0x81",  "name": "cpicture",  "original_addr": "0x9884",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3078",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original DOS v31: evaluates one expression (0x9d24) and does nothing else. Port: only version 10 is handled; for v31 it falls to '// MISSING: cpicture' and consumes NO operand, so the script would desync if it were ever executed.",  "fix": "In cpicture(), after the v10 branch, add readexec_opername() for the other versions (at least for PC v>=30)." }, {  "table": "opcodes",  "index": "0x82",  "name": "cxyscroll",  "original_addr": "0x9aeb",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3095",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: 2 expressions, nothing else. Port: two readexec_opername(). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x83",  "name": "clinking",  "original_addr": "0x57e7",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3102",  "status": "same",  "severity": "none",  "used_by_game": "27 (all 'linking 0')",  "details": "Original: 1 expression, word [es:ebp-0x2a]=dx (the clinking field of the current script). Port (v<60): set_0x2a_clinking(vram_org, varD7), i.e. xwrite16(vram-0x2a) (accessors.php:258). Same field, same width.",  "fix": "" }, {  "table": "0x189ae (storenames)",  "index": "0 (code 0x06)",  "name": "slocb",  "original_addr": "0xa76c",  "port_location": "games/alis/src/Alis/fn/storenames.php:18",  "status": "same",  "severity": "none",  "used_by_game": "157 (vb[off] = ..., off outside 0..255)",  "details": "Original: lodsw, movsx (signed 16-bit offset), mov [es:ebp+off], dl (low byte of the value). Port: s16(script_read16()), xwrite8(vram_org+off, varD7). Same operands (2 bytes) and effect.",  "fix": "" }, {  "table": "0x189ae (storenames)",  "index": "1 (code 0x08)",  "name": "slocw",  "original_addr": "0xa776",  "port_location": "games/alis/src/Alis/fn/storenames.php:26",  "status": "same",  "severity": "none",  "used_by_game": "192",  "details": "Original: lodsw signed offset, mov word [es:ebp+off], dx. Port: xwrite16(vram_org + s16(off), varD7). Same.",  "fix": "" }, {  "table": "0x189ae (storenames)",  "index": "2 (code 0x0a)",  "name": "slocp",  "original_addr": "0xa781",  "port_location": "games/alis/src/Alis/fn/storenames.php:34",  "status": "same",  "severity": "none",  "used_by_game": "34",  "details": "Original: lodsw signed offset, strcpy from [0x16010] (cstore at 0x3bd1 swapped [0x16008]<->[0x16010] before dispatch, so [0x16010] = the string just evaluated) to ebp+off, terminator included. Port: get_vram(s16 off), mem_strcpy(.., oldsd7) after cstore_continue swapped sd7/oldsd7: same buffer mapping (sd7=0x16008, oldsd7=0x16010).",  "fix": "" }, {  "table": "0x189ae (storenames)",  "index": "3 (code 0x0c)",  "name": "sloctp",  "original_addr": "0xa7ba",  "port_location": "games/alis/src/Alis/fn/storenames.php:42",  "status": "differs",  "severity": "low",  "used_by_game": "0 (no ts[] store with an offset outside 0..255)",  "details": "Original: lodsw, call 0xa199 (tabstring: movsx esi,ax = SIGNED offset; first index = dx, more indices popped from the word accumulator [ebx]; bound checks -> error 0x17/0x18 via 0x144a0, pointer tables (bit7 of [A-1]) double-indirected with null check -> error 0x1a), then strcpy from [0x16010]. Port: tabstring(vram_org + script_read16()) uses the UNSIGNED 16-bit offset, so a table at a negative local offset (>=0x8000) would be addressed 64 KB too high; no bound/null checks. Same operand count.",  "fix": "Use s16(script_read16()) in sloctp (and the other *loct* stores) so negative offsets work like the original's movsx at 0xa19b; optional: the original's index checks are error-only." }, {  "table": "0x189ae (storenames)",  "index": "4 (code 0x0e)",  "name": "sloctc",  "original_addr": "0xa799",  "port_location": "games/alis/src/Alis/fn/storenames.php:50",  "status": "differs",  "severity": "low",  "used_by_game": "1 (tb[0x183a](..) = .., positive offset)",  "details": "Original: lodsw, call 0xa034 (tabchar, signed offset via movsx, index = dx then acc words), then pops the value (mov dx,[ebx]; add ebx,2) and stores the low byte. Port: tabchar(vram_org + unsigned script_read16()), pops varD7 from acc (32-bit cells), xwrite8. Only difference: unsigned offset (no effect for the game's only use, offset 0x183a) and missing error checks.",  "fix": "s16(script_read16()) for the offset." }, {  "table": "0x189ae (storenames)",  "index": "5 (code 0x10)",  "name": "slocti",  "original_addr": "0xa7a9",  "port_location": "games/alis/src/Alis/fn/storenames.php:60",  "status": "differs",  "severity": "low",  "used_by_game": "21 (tw[0x1744](..) = .., positive offsets)",  "details": "Original: lodsw, call 0xa0f3 (tabint: signed offset, first index doubled, further indices from acc), pop value, store word. Port: tabint(vram_org + unsigned script_read16()), pop, xwrite16. Same except unsigned offset (game only uses positive ones) and no bound checks.",  "fix": "s16(script_read16()) for the offset." }, {  "table": "0x189ae (storenames)",  "index": "6 (code 0x12)",  "name": "sdirb",  "original_addr": "0xa7d2",  "port_location": "games/alis/src/Alis/fn/storenames.php:70",  "status": "same",  "severity": "none",  "used_by_game": "1560",  "details": "Original: lodsb, zero-extended offset, store dl at ebp+off. Port: xwrite8(vram_org + script_read8(), varD7&0xff). Same.",  "fix": "" }, {  "table": "0x189ae (storenames)",  "index": "7 (code 0x14)",  "name": "sdirw",  "original_addr": "0xa7dd",  "port_location": "games/alis/src/Alis/fn/storenames.php:77",  "status": "same",  "severity": "none",  "used_by_game": "1046",  "details": "Original: lodsb unsigned offset, store word dx. Port same.",  "fix": "" }, {  "table": "0x189ae (storenames)",  "index": "8 (code 0x16)",  "name": "sdirp",  "original_addr": "0xa7e9",  "port_location": "games/alis/src/Alis/fn/storenames.php:85",  "status": "same",  "severity": "none",  "used_by_game": "929",  "details": "Original: lodsb unsigned offset, strcpy [0x16010] -> ebp+off. Port: mem_strcpy(get_vram(off), oldsd7). Same.",  "fix": "" }, {  "table": "0x189ae (storenames)",  "index": "9 (code 0x18)",  "name": "sdirtp",  "original_addr": "0xa824",  "port_location": "games/alis/src/Alis/fn/storenames.php:92",  "status": "same",  "severity": "none",  "used_by_game": "1844",  "details": "Original: sub eax,eax; lodsb; call 0xa199 (tabstring) ; strcpy from [0x16010]. Port: tabstring(vram_org + script_read8()), mem_strcpy(.., oldsd7). Same (offset 0..255 so signedness irrelevant); only the original's index/null error checks (0x17/0x18/0x1a) are absent in the port.",  "fix": "" }, {  "table": "0x189ae (storenames)",  "index": "10 (code 0x1a)",  "name": "sdirtc",  "original_addr": "0xa801",  "port_location": "games/alis/src/Alis/fn/storenames.php:99",  "status": "same",  "severity": "none",  "used_by_game": "228",  "details": "Original: lodsb, call 0xa034, pop value word from acc, store low byte. Port identical sequence (tabchar, pop, xwrite8).",  "fix": "" }, {  "table": "0x189ae (storenames)",  "index": "11 (code 0x1c)",  "name": "sdirti",  "original_addr": "0xa812",  "port_location": "games/alis/src/Alis/fn/storenames.php:108",  "status": "same",  "severity": "none",  "used_by_game": "8",  "details": "Original: lodsb, call 0xa0f3, pop, store word. Port same.",  "fix": "" }, {  "table": "0x189ae (storenames)",  "index": "12 (code 0x1e)",  "name": "smainb",  "original_addr": "0xa83d",  "port_location": "games/alis/src/Alis/fn/storenames.php:117",  "status": "same",  "severity": "none",  "used_by_game": "577",  "details": "Original: lodsw signed, + [0x15fa0] (main script vars = basemain), store byte. Port: xwrite8(basemain + s16(off), d7). Same.",  "fix": "" }, {  "table": "0x189ae (storenames)",  "index": "13 (code 0x20)",  "name": "smainw",  "original_addr": "0xa84c",  "port_location": "games/alis/src/Alis/fn/storenames.php:124",  "status": "same",  "severity": "none",  "used_by_game": "216",  "details": "Original: lodsw signed, store word at [0x15fa0]+off. Port same.",  "fix": "" }, {  "table": "0x189ae (storenames)",  "index": "14 (code 0x22)",  "name": "smainp",  "original_addr": "0xa85c",  "port_location": "games/alis/src/Alis/fn/storenames.php:131",  "status": "same",  "severity": "none",  "used_by_game": "63",  "details": "Original: lodsw signed, strcpy [0x16010] -> [0x15fa0]+off. Port: mem_strcpy(basemain + s16(off), oldsd7). Same.",  "fix": "" }, {  "table": "0x189ae (storenames)",  "index": "15 (code 0x24)",  "name": "smaintp",  "original_addr": "0xa8a9",  "port_location": "games/alis/src/Alis/fn/storenames.php:138",  "status": "differs",  "severity": "low",  "used_by_game": "12 (mts[0x1a52](..) = ..)",  "details": "Original: lodsw, ebp := [0x15fa0], call 0xa199 with signed ax, strcpy from [0x16010]. Port: tabstring(basemain + unsigned script_read16()). Same for the game's positive offsets; differs only for offsets >= 0x8000.",  "fix": "s16(script_read16())." }, {  "table": "0x189ae (storenames)",  "index": "16 (code 0x26)",  "name": "smaintc",  "original_addr": "0xa878",  "port_location": "games/alis/src/Alis/fn/storenames.php:145",  "status": "same",  "severity": "none",  "used_by_game": "252",  "details": "Original: lodsw, ebp := basemain, call 0xa034, pop value, store byte. Port same (offset unsigned, game uses positive ones).",  "fix": "(optional) s16 on the offset" }, {  "table": "0x189ae (storenames)",  "index": "17 (code 0x28)",  "name": "smainti",  "original_addr": "0xa890",  "port_location": "games/alis/src/Alis/fn/storenames.php:154",  "status": "same",  "severity": "none",  "used_by_game": "1870",  "details": "Original: lodsw, ebp := basemain, call 0xa0f3, pop value, store word. Port same (unsigned offset, positive in the game).",  "fix": "(optional) s16 on the offset" }, {  "table": "0x189ae (storenames)",  "index": "18 (code 0x2a)",  "name": "shimb",  "original_addr": "0xa8cb",  "port_location": "games/alis/src/Alis/fn/storenames.php:163",  "status": "differs",  "severity": "medium",  "used_by_game": "738 (hb[var, off] = ..)",  "details": "Original: lodsw off1 (signed); ent = movsx word [ebp+off1] (SIGNED); edi = atent([0x15f72]) + ent; call 0x9ffb: if ent < 0 -> error 0x1f (0x144a0); target = dword [edi]; lodsw off2 (signed); if target <= 0 (jng 0xa8f1) the write is SKIPPED, else byte dl -> target+off2. Port: ent = xread16 (unsigned), vram = xread32(atent+ent), and the 'vram <= 0 -> return' test is only done for version >= 60. Robinson is v31, so a store to an entity slot whose script is dead/not started (vram 0) writes the byte at mem[0+off2] instead of being ignored (memory corruption of the low area of alis.mem).",  "fix": "In shimb (storenames.php:172) drop the 'Alis::$platform->version >= 60 &&' condition: return when $vram <= 0 for every version (original 0xa8e8). Read ent signed: s16(xread16(...)) (original movsx at 0xa8d0)." }, {  "table": "0x189ae (storenames)",  "index": "19 (code 0x2c)",  "name": "shimw",  "original_addr": "0xa8f2",  "port_location": "games/alis/src/Alis/fn/storenames.php:180",  "status": "differs",  "severity": "medium",  "used_by_game": "58 (hw[var, off] = ..)",  "details": "Same as shimb but word: ent signed, error 0x21 via 0xa017 if ent < 0, write SKIPPED when target vram <= 0 (0xa90f jng). Port only skips for version >= 60, reads ent unsigned, so on v31 writes 2 bytes at mem[off2] when the target entity is dead.",  "fix": "storenames.php:189: return when $vram <= 0 for all versions; s16 on the ent word." }, {  "table": "0x189ae (storenames)",  "index": "20 (code 0x2e)",  "name": "shimp",  "original_addr": "0xa91a",  "port_location": "games/alis/src/Alis/fn/storenames.php:197",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original: lodsw off1 (signed), ent = movsx word [ebp+off1], target = dword [atent+ent] (NO <=0 check, no error check), lodsw off2 (signed), strcpy [0x16010] -> target+off2. Consumes 4 operand bytes. Port: empty function (consumes nothing -> script desync if ever used); Lang/Grammar.php:137 also declares it without operands ('', 'f').",  "fix": "Implement: $off1=s16(script_read16()); $ent=s16(xread16(vram_org+$off1)); $vram=xread32(atent+$ent); $off2=s16(script_read16()); mem_strcpy($vram+$off2, oldsd7). Grammar STORES 0x2e => ['shimp','h','v']." }, {  "table": "0x189ae (storenames)",  "index": "21 (code 0x30)",  "name": "shimtp",  "original_addr": "0xa99e",  "port_location": "games/alis/src/Alis/fn/storenames.php:203",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original: lodsw w1, lodsw w2, xchg: w2 = offset of the entity variable in the current script, w1 = table offset in the TARGET's vars. ent = movsx [ebp+w2]; ebp := dword [atent+ent] (no null check); call 0xa199 (tabstring with ax=w1, index dx + acc); strcpy [0x16010] there. Consumes 4 bytes. Port: empty stub (consumes nothing); Grammar.php:138 declares no operands.",  "fix": "Implement: $tab=s16(script_read16()); $var=s16(script_read16()); $ent=s16(xread16(vram_org+$var)); $base=xread32(atent+$ent); mem_strcpy(tabstring($base+$tab), oldsd7). Grammar operands 'w w' (table offset first, then entity var)." }, {  "table": "0x189ae (storenames)",  "index": "22 (code 0x32)",  "name": "shimtc",  "original_addr": "0xa945",  "port_location": "games/alis/src/Alis/fn/storenames.php:209",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original: w1 = table offset (target), w2 = entity var offset; base = dword [atent + s16[ebp+w2]]; ebp=base; call 0xa034 (tabchar, ax=w1); pop value from acc; store byte. Consumes 4 bytes. Port: empty stub, no operands consumed, the value pushed by seval stays on acc.",  "fix": "Implement like shimtp with tabchar($base+$tab), pop varD7 from acc, xwrite8. Grammar 0x32 => operands 'w w', kind 't'." }, {  "table": "0x189ae (storenames)",  "index": "23 (code 0x34)",  "name": "shimti",  "original_addr": "0xa970",  "port_location": "games/alis/src/Alis/fn/storenames.php:215",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original: same as shimtc with 0xa0f3 (tabint), pop, store word (the 'add ebp,eax' at 0xa997 is dead: ebp restored). Port: empty stub.",  "fix": "Implement with tabint($base+$tab), pop, xwrite16. Grammar 0x34 => 'w w', 't'." }, {  "table": "0x189ae (storenames)",  "index": "24 (code 0x36)",  "name": "spile",  "original_addr": "0xa9d1",  "port_location": "games/alis/src/Alis/fn/storenames.php:221",  "status": "same",  "severity": "none",  "used_by_game": "0 as a store target",  "details": "Original: sub ebx,2; mov [ebx],dx (push the 16-bit value on the word accumulator). Port: acc -= 4; hwrite32(acc, varD7): the port's accumulator has 32-bit cells everywhere (tab* pops 4 bytes too), so equivalent; d7 is already s16-clamped for v<60.",  "fix": "" }, {  "table": "0x189ae (storenames)",  "index": "25 (code 0x38)",  "name": "seval",  "original_addr": "0xa9d8",  "port_location": "games/alis/src/Alis/fn/storenames.php:228",  "status": "differs",  "severity": "low",  "used_by_game": "~4236 (every table store x(..)= : ts/tb/tw/mts/mtb/mtw, the assembler emits seval <index chain> ofin <target>)",  "details": "Original: lea ebx,[0x18328] (RESET the accumulator to its origin, every version), push dx, call 0xa75f (eval loop until ofin), then lodsb + movsx and jmp [edi*2+0x189a2] (next store target). Port: resets acc to acc_org only for version >= 60, then push, oeval(), readexec_storename(). For a seval reached from cstore it is equivalent because the original cstore also does lea ebx,0x18328 at 0x3be3 right before dispatch, but the port's cstore never resets acc, so any accumulator imbalance left by an earlier expression drifts in the port while the original starts each table store from acc_org.",  "fix": "In seval drop the version test: always Alis::$acc = Alis::$acc_org before the push (and, in cstore, reset acc to acc_org before the expression and before readexec_storename, as at 0x3bc6/0x3be3)." }, {  "table": "0x189ae (storenames)",  "index": "26 (code 0x3a)",  "name": "ofin",  "original_addr": "0xa767",  "port_location": "games/alis/src/Alis/fn/opernames.php:410 (table slot storenames.php:288)",  "status": "same",  "severity": "none",  "used_by_game": "0 as a store target (only as the end of a seval chain, handled by the opername ofin)",  "details": "Original: add sp,4; ret (shared with the opername ofin: leaves the eval loop of 0xa75f). As a store target dispatched from cstore it would unbalance the stack, so never used that way. Port: ofin() clears oeval_loop, a no-op as a store target.",  "fix": "" }, {  "table": "0x18a26 (addnames)",  "index": "0 (code 0x06)",  "name": "alocb",  "original_addr": "0xa9f5",  "port_location": "games/alis/src/Alis/fn/addnames.php:17",  "status": "same",  "severity": "none",  "used_by_game": "10 `vb[>0xff] +=/-=` + 1 `loop vb[...]`",  "details": "Original: lodsw, movsx edi (s16 offset); add [es:edi+ebp],dl (low byte of the value, 8-bit wrap). ZF from the add is what cloop (0x3a8e/0x3aae/0x3ad1, `call 0x3c23; jnz`) tests. Port: s16(script_read16()), xadd8(vram_org+off, varD7&0xff), sets sr['zero'] = (byte==0). Same operands, same effect, same ZF.",  "fix": "" }, {  "table": "0x18a26 (addnames)",  "index": "1 (code 0x08)",  "name": "alocw",  "original_addr": "0xa9ff",  "port_location": "games/alis/src/Alis/fn/addnames.php:25",  "status": "same",  "severity": "none",  "used_by_game": "43 `vw[>0xff] +=/-=` + 2 `loop vw[...]`",  "details": "Original: lodsw s16 offset; add word [es:edi+ebp],dx; ZF used by cloop. Port: s16 offset, xadd16, sr['zero'] = (word==0). Identical.",  "fix": "" }, {  "table": "0x18a26 (addnames)",  "index": "2 (code 0x0a)",  "name": "alocp",  "original_addr": "0xaa0a",  "port_location": "games/alis/src/Alis/fn/addnames.php:33",  "status": "same",  "severity": "none",  "used_by_game": "12 (`vs[0x184] += ...` etc.)",  "details": "Original: lodsw s16 offset, edi=ebp+off, scan to NUL, copy string from [0x16010] (after cadd 0x3c23 swapped [0x16008]<->[0x16010]; the expression string is built in [0x16008], e.g. oimmp 0x9d5c) including NUL; no length limit. Port: s16 offset, mem_putstr(dst, mem_str(dst).mem_str(oldsd7)) after readexec_addname_swap (sd7<->oldsd7, sd7 == [0x16008]). Same buffer, same concatenation. ZF not meaningful in either (not used by loops).",  "fix": "" }, {  "table": "0x18a26 (addnames)",  "index": "3 (code 0x0c)",  "name": "aloctp",  "original_addr": "0xaa4c",  "port_location": "games/alis/src/Alis/fn/addnames.php:41",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: lodsw; call 0xa199 (string-array cell: movsx esi,ax = SIGNED offset; index dx * byte elem size at base-2, extra dims popped from the ebx stack, 16-bit mul; direct/indirect arrays; out-of-range index -> error 0x17/0x18/0x1a via 0x144a0); then append [0x16010]. Port: tabstring(vram_org + script_read16()) with an UNSIGNED 16-bit offset (script_read16 returns u16, runtime.php:502), no bounds errors. Same result for offsets < 0x8000 and in-range indices.",  "fix": "Use s16(script_read16()) for the offset (as alocb/alocp do); optionally report out-of-range indices like the original's error 0x17/0x18." }, {  "table": "0x18a26 (addnames)",  "index": "4 (code 0x0e)",  "name": "aloctc",  "original_addr": "0xaa2b",  "port_location": "games/alis/src/Alis/fn/addnames.php:48",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: lodsw; call 0xa034 (byte-array cell, signed offset via movsx, index dx, other indices popped from ebx stack, bounds checked -> fatal error 0x17/0x18/0x1a); pop value from ebx stack (mov dx,[ebx]; add ebx,2); add [edi],dl (ZF set). Port: tabchar(vram_org + script_read16()) (unsigned offset), pops value from acc, xadd8. Does not set sr['zero'] (only matters if a cloop used it; game loops only use vb/vw). Offset sign and missing bounds checks are the only differences.",  "fix": "s16(script_read16()) for the offset; set Alis::$sr['zero'] = (xread8($addr)==0) after the add for cloop parity." }, {  "table": "0x18a26 (addnames)",  "index": "5 (code 0x10)",  "name": "alocti",  "original_addr": "0xaa3b",  "port_location": "games/alis/src/Alis/fn/addnames.php:57",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: lodsw; call 0xa0f3 (word-array cell: add dx,dx 16-bit, signed offset, bounds checks), pop value from ebx stack, add [edi],dx. Port: tabint(vram_org + script_read16()) unsigned offset, pop acc, xadd16; no ZF, no bounds errors.",  "fix": "s16(script_read16()); set sr['zero'] after the add." }, {  "table": "0x18a26 (addnames)",  "index": "6 (code 0x12)",  "name": "adirb",  "original_addr": "0xaa6d",  "port_location": "games/alis/src/Alis/fn/addnames.php:66",  "status": "same",  "severity": "none",  "used_by_game": "272 `vb[0..0xff] +=/-=` + 43 `loop vb[...]`",  "details": "Original: lodsb, movzx (unsigned 8-bit offset); add [es:edi+ebp],dl; ZF for cloop. Port: script_read8 (unsigned), xadd8, sr['zero']. Identical.",  "fix": "" }, {  "table": "0x18a26 (addnames)",  "index": "7 (code 0x14)",  "name": "adirw",  "original_addr": "0xaa76",  "port_location": "games/alis/src/Alis/fn/addnames.php:74",  "status": "same",  "severity": "none",  "used_by_game": "227 `vw[0..0xff] +=/-=` + 7 `loop vw[...]`",  "details": "Original: lodsb movzx; add word [es:edi+ebp],dx; ZF. Port: read8, xadd16, sr['zero']. Identical.",  "fix": "" }, {  "table": "0x18a26 (addnames)",  "index": "8 (code 0x16)",  "name": "adirp",  "original_addr": "0xaa81",  "port_location": "games/alis/src/Alis/fn/addnames.php:84",  "status": "same",  "severity": "none",  "used_by_game": "328 (all `vs[0x5e] += ...`)",  "details": "Original: lodsb movzx offset, edi=ebp+off, strcat from [0x16010]. Port: read8, get_vram, mem_putstr(dst . oldsd7). Same.",  "fix": "" }, {  "table": "0x18a26 (addnames)",  "index": "9 (code 0x18)",  "name": "adirtp",  "original_addr": "0xaac4",  "port_location": "games/alis/src/Alis/fn/addnames.php:92",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: sub eax,eax; lodsb (unsigned byte offset); call 0xa199 (string cell); strcat [0x16010]. Port: tabstring(vram_org + read8), strcat oldsd7. Same except the original's fatal bounds errors (0xa0c6/0xa0d5/0xa0e4) are not reproduced.",  "fix": "" }, {  "table": "0x18a26 (addnames)",  "index": "10 (code 0x1a)",  "name": "adirtc",  "original_addr": "0xaaa1",  "port_location": "games/alis/src/Alis/fn/addnames.php:99",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: lodsb; sub ah,ah; call 0xa034; pop value from ebx stack; add [edi],dl. Port: tabchar(vram_org+read8), pop acc, xadd8(s8). Same (except no ZF in port / no bounds errors; irrelevant for the game).",  "fix": "Optional: set sr['zero'] after the add." }, {  "table": "0x18a26 (addnames)",  "index": "11 (code 0x1c)",  "name": "adirti",  "original_addr": "0xaab2",  "port_location": "games/alis/src/Alis/fn/addnames.php:108",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: lodsb; sub ah,ah; call 0xa0f3; pop value; add [edi],dx. Port: tabint(vram_org+read8), pop acc, xadd16. Same (no ZF / bounds errors in port).",  "fix": "Optional: set sr['zero'] after the add." }, {  "table": "0x18a26 (addnames)",  "index": "12 (code 0x1e)",  "name": "amainb",  "original_addr": "0xaae6",  "port_location": "games/alis/src/Alis/fn/addnames.php:117",  "status": "differs",  "severity": "low",  "used_by_game": "42 `mb[...] +=/-=` (0 in loops)",  "details": "Original: lodsw movsx (s16) + [0x15fa0] (basemain); add [es:edi],dl; ZF set (cloop-able). Port: s16 offset, xadd8(basemain+off). Same effect; port does not update sr['zero'], so a `loop mb[..]` would test a stale flag (game never does that).",  "fix": "Add Alis::$sr['zero'] = (int)(xread8(basemain+off)==0)." }, {  "table": "0x18a26 (addnames)",  "index": "13 (code 0x20)",  "name": "amainw",  "original_addr": "0xaaf5",  "port_location": "games/alis/src/Alis/fn/addnames.php:124",  "status": "differs",  "severity": "low",  "used_by_game": "137 `mw[...] +=/-=` (0 in loops)",  "details": "Original: s16 offset + [0x15fa0]; add word [es:edi],dx; ZF. Port: same add (xadd16), no sr['zero'] update (only matters for cloop on mw, unused).",  "fix": "Set sr['zero'] = (xread16(...)==0) after the add." }, {  "table": "0x18a26 (addnames)",  "index": "14 (code 0x22)",  "name": "amainp",  "original_addr": "0xab05",  "port_location": "games/alis/src/Alis/fn/addnames.php:131",  "status": "same",  "severity": "none",  "used_by_game": "2 (`ms[0x3cea] += \".dat\"`)",  "details": "Original: s16 offset + basemain, strcat from [0x16010]. Port: s16, mem_putstr(dst . oldsd7). Same.",  "fix": "" }, {  "table": "0x18a26 (addnames)",  "index": "15 (code 0x24)",  "name": "amaintp",  "original_addr": "0xab5b",  "port_location": "games/alis/src/Alis/fn/addnames.php:139",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: lodsw; ebp=basemain; call 0xa199 (movsx: signed offset); strcat [0x16010]. Port: tabstring(basemain + script_read16()) unsigned offset. Differs only for offsets >= 0x8000 (and bounds errors).",  "fix": "s16(script_read16())." }, {  "table": "0x18a26 (addnames)",  "index": "16 (code 0x26)",  "name": "amaintc",  "original_addr": "0xab2a",  "port_location": "games/alis/src/Alis/fn/addnames.php:146",  "status": "same",  "severity": "none",  "used_by_game": "2 (`mtb[0x3cd8](vb[0x62]) -= 1`, `mtb[0x2d9a](vb[0x62]) -= 1`, via aeval)",  "details": "Original: lodsw; ebp=basemain; call 0xa034 (signed offset, bounds checks); pop value from ebx stack; add [edi],dl. Port: tabchar(basemain + unsigned read16), pop acc, xadd8(&0xff). Same for the game's offsets (< 0x8000); no ZF / bounds errors in port.",  "fix": "Optional: s16(script_read16()) and sr['zero'] for strict parity." }, {  "table": "0x18a26 (addnames)",  "index": "17 (code 0x28)",  "name": "amainti",  "original_addr": "0xab42",  "port_location": "games/alis/src/Alis/fn/addnames.php:155",  "status": "same",  "severity": "none",  "used_by_game": "63 (`mtw[0x1a9e](vw[..], 0) -= scan()`, `mtw[0xec0](9) += ...`, via aeval)",  "details": "Original: lodsw; ebp=basemain; call 0xa0f3 (index*2 16-bit, extra dims popped and multiplied by stored dims with 16-bit mul, signed offset); pop value; add [edi],dx. Port: tabint(basemain + unsigned read16) with 32-bit mul32 of dims, pop acc, xadd16. Same results for the game's offsets/indices (only out-of-range or >64K products differ: original fatal error 0x17/0x18/0x1a or 16-bit wrap).",  "fix": "Optional: s16 offset, sr['zero']." }, {  "table": "0x18a26 (addnames)",  "index": "18 (code 0x2a)",  "name": "ahimb",  "original_addr": "0xab86",  "port_location": "games/alis/src/Alis/fn/addnames.php:164",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0 (no `hb[..] +=`)",  "details": "Original: lodsw s16 off1; edi = s16 word [ebp+off1] + [0x15f72] (atent); call 0x9ffb (error 0x1f if < atent); edi = dword [edi] (other script's vram); lodsw s16 off2; if edi > 0: add [edi+off2],dl (else skip, operands still consumed). Port: for version 31 the body is empty ('MISSING in the C'): reads NO operand -> the 4 operand bytes would be executed as opcodes (script desync). The v10 branch also uses an unsigned off2 and no edi>0 check.",  "fix": "Implement for all versions: $v = xread16(vram_org + s16(script_read16())); $p = xread32(atent + $v); $off2 = s16(script_read16()); if ($p > 0) xadd8($p + $off2, varD7 & 0xff); sr['zero'] = result==0 (or 1 when skipped: ZF from test edi,edi with edi==0)." }, {  "table": "0x18a26 (addnames)",  "index": "19 (code 0x2c)",  "name": "ahimw",  "original_addr": "0xabad",  "port_location": "games/alis/src/Alis/fn/addnames.php:177",  "status": "differs",  "severity": "low",  "used_by_game": "0 (no `hw[..] +=`)",  "details": "Original: same as ahimb but call 0xa017 (error 0x21) and add word [edi+off2],dx, only when the target vram pointer > 0. Port: reads off1 and off2 UNSIGNED (script_read16), no `pointer > 0` check: an empty script slot (pointer 0) makes the port write to address 0+off2 (memory corruption) where the original skips; negative off2 becomes +0xFFxx.",  "fix": "Use s16() on both offsets and wrap the xadd16 in `if (xread32(atent+$v) > 0)`; set sr['zero']." }, {  "table": "0x18a26 (addnames)",  "index": "20 (code 0x2e)",  "name": "ahimp",  "original_addr": "0xabd5",  "port_location": "games/alis/src/Alis/fn/addnames.php:185",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0 (no `hs[..] +=`)",  "details": "Original: lodsw s16 off1; edi = dword [ s16 word[ebp+off1] + atent ]; lodsw s16 off2; edi += off2 (no >0 check); strcat from [0x16010]. Port: empty function, consumes no operands -> script desync if ever reached.",  "fix": "$p = xread32(atent + xread16(vram_org + s16(script_read16()))) + s16(script_read16()); mem_putstr($p, mem_str($p) . mem_str(Alis::$oldsd7));" }, {  "table": "0x18a26 (addnames)",  "index": "21 (code 0x30)",  "name": "ahimtp",  "original_addr": "0xac60",  "port_location": "games/alis/src/Alis/fn/addnames.php:191",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: lodsw A (array offset), lodsw B (variable holding the script id), xchg; edi = dword[ s16 word[ebp+B] + atent ]; ebp=edi; call 0xa199 with ax=A; strcat [0x16010]. Port: offset1=s16, offset2=s16, addr = xread32(atent + xread16(vram_org+offset2)); tabstring(addr+offset1); strcat oldsd7. Same operand order and effect.",  "fix": "" }, {  "table": "0x18a26 (addnames)",  "index": "22 (code 0x32)",  "name": "ahimtc",  "original_addr": "0xac09",  "port_location": "games/alis/src/Alis/fn/addnames.php:201",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original: lodsw A, lodsw B (xchg); edi = dword[ s16 word[ebp+B] + atent ]; ebp=edi; call 0xa034 with ax=A (byte cell in the other script, indices from dx + ebx stack); pop value from ebx stack; add [edi],dl. Port: empty: reads no operand and does not pop the value/indices -> script desync and acc imbalance.",  "fix": "$a = s16(script_read16()); $b = s16(script_read16()); $base = xread32(atent + xread16(vram_org + $b)); $addr = tabchar($base + $a); varD7 = hread32(acc); acc += 4; xadd8($addr, varD7 & 0xff);" }, {  "table": "0x18a26 (addnames)",  "index": "23 (code 0x34)",  "name": "ahimti",  "original_addr": "0xac34",  "port_location": "games/alis/src/Alis/fn/addnames.php:207",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original: as ahimtc but call 0xa0f3 (word cell) and add [edi],dx. Port: empty, no operands consumed, no pops -> desync.",  "fix": "Same as ahimtc with tabint() and xadd16()." }, {  "table": "0x18a26 (addnames)",  "index": "24 (code 0x36)",  "name": "spile",  "original_addr": "0xa9d1",  "port_location": "games/alis/src/Alis/fn/storenames.php:221",  "status": "same",  "severity": "none",  "used_by_game": "0 as an add target",  "details": "Original: sub ebx,2; mov [ebx],dx: pushes the value on the expression stack (shared with storename 24). In cadd context ebx was just reset to 0x18328 (0x3c35), so it is effectively discarded at the next statement. Port: acc -= 4; push varD7; acc is only reset when a script is entered (alis.php:1142), so it leaks 4 bytes per use until then. No operand read in either. (Stack cell size 2 vs 4 bytes is internal.)",  "fix": "" }, {  "table": "0x18a26 (addnames)",  "index": "25 (code 0x38)",  "name": "aeval",  "original_addr": "0xac9c",  "port_location": "games/alis/src/Alis/fn/addnames.php:216",  "status": "differs",  "severity": "low",  "used_by_game": "65 (every `mtw[..](..) +=/-=` and `mtb[..](..) -=`)",  "details": "Original: lea ebx,[0x18328] (RESETS the expression stack), push dx (value), call 0xa75f (loop on 0x9d2d evaluating opernames until ofin), lodsb, jmp [code*2+0x18a1a] (next add target). Port: for version < 60 does not reset acc (only v6 resets to acc_org), pushes varD7, oeval(), readexec_addname(). Same operand stream and same result when the stack is balanced; only stale stack entries are kept in the port instead of discarded.",  "fix": "Optional: reset Alis::$acc = Alis::$acc_org for all versions before pushing, as the original does (0xac9c)." }, {  "table": "0x18a26 (addnames)",  "index": "26 (code 0x3a)",  "name": "ofin",  "original_addr": "0xa767",  "port_location": "games/alis/src/Alis/fn/opernames.php:410",  "status": "differs",  "severity": "low",  "used_by_game": "0 as an add target",  "details": "Original: add sp,4; ret: drops the caller's return address. As an add target (reached by jmp from cadd 0x3c3e or aeval 0xacb1) it discards the main loop's return (0x7b73 call) and returns from the interpreter loop: the script's run stops for this frame (inside cloop it returns from the loop opcode without branching). Port: ofin with oeval_loop==0 and version<60 does nothing; the script carries on with the next byte.",  "fix": "Unused by the game; if wanted, make the add-target ofin end the current script slice (the same exit path cret/opcodes use to leave the VM loop)." }, {  "table": "opcodes",  "index": "0x58",  "name": "cpredent",  "original_addr": "0x75e6",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1749",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: ebx=[0x1603e] (cursor into tablent at 0x17a2a); if ebx!=0x17a2a {dx=word[ebx-2]; [0x1603e]-=2} else dx=0xffff; jmp 0x3bd1 (swap [0x16008]/[0x16010] expression buffers, lodsb, store through table 0x189a2). No operand besides the store target. Port: ptrent!=0 -> ptrent--, varD7=tablent[ptrent], else -1; cstore_continue() swaps sd7/oldsd7 and runs readexec_storename. Identical.",  "fix": "" }, {  "table": "opcodes",  "index": "0x59",  "name": "cnearent",  "original_addr": "0x80bb",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2099 (sviewent 2020, calcnear 1761, trinorme 1790)",  "status": "differs",  "severity": "medium",  "used_by_game": "1 (nearent 128, vw[0x52], vw[0x54], right after allentity)",  "details": "Original: [0x16034]=0 (fview); expr1 -> valnorme=[0x16036/38]= u16*u16 (mul dx, unsigned 32-bit); expr2 -> entity filter [0x15eaa] (forced -1 if fallent [0x16056]); walks the entity chain from offset 0 of [0x15f72]: keep if (filter<0 || filter==[vram-0xe]) && [vram+0x30]==[self+0x30] && vram!=self && calcnear (0x82bf) in range. fallent==0: sentinel 0x7fffffff/-1, keeps only a strictly nearer one (signed 32 compare). fallent!=0: appends every match (no cap), then 0x7ceb sorts: bubble passes REPEATED until no swap (jnz 0x7d23), ascending signed 32-bit distance, swapping tablent alongside. Then fallent=0, jmp 0x7610 (crstent -> csuccent -> store). Port: same operands, same filter and insertion, but trinorme() (opcodes_a.php:1790) does only ONE bubble pass: after the first pass bufidx is 0, so the do/while breaks on length<=0 even when a swap happened (result is never reset either). With allentity + nearent the list is only partially sorted (nearest first, the rest not in distance order), unlike the original. Minor edge differences in calcnear: original wraps the deltas to 16 bits (mov ax,[edi]; sub ax,[ebp]) and compares val<=valnorme SIGNED (jg on hi word); port does not wrap deltas (xread16-xread16) and compares unsigned (ule); valnorme from mul32(s,s) instead of u16*u16 (differs only for negative radius). Port also caps the list at 255 (tabent_full) where the original allows ~769 (0x17a2a..0x1802c).",  "fix": "Rewrite trinorme() as the original 0x7ceb: loop { swapped=false; for i=n-1 down to 1: if buf[i] < buf[i-1] (signed 32) swap buf and tablent; } while swapped; never touch index -1. Optionally in calcnear (v>=30): $dx=s16(...-...), etc., and compare s32($val) <= s32(valnorme) signed; valnorme = (varD7&0xffff)*(varD7&0xffff) as u32." }, {  "table": "opcodes",  "index": "0x5a",  "name": "cneartyp",  "original_addr": "0x7e9d",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2113 (sviewtyp 1842)",  "status": "differs",  "severity": "low",  "used_by_game": "60 (neartyp R, 15, vw[..])",  "details": "Original: fview=0; expr -> valnorme (u16*u16); then lodsw: a raw inline 16-bit type id (NOT an expression) -> [0x15eaa]; keep if id==word[vram-0x10] && same group [+0x30] && not self && calcnear; same nearest/all logic and 0x7ceb full sort as cnearent; crstent store. Port: for EPlatformPC reads script_read16() inline (sync OK), same filters/insertion. Differences: (1) port does `if ($id < 0) $id &= 0xff` and compares with get_0x10_script_id() (unsigned 16): the original compares the raw 16-bit word, so a negative id would match differently (scripts only use 15, so no effect); (2) shares the one-pass trinorme bug when preceded by allentity (no allentity+neartyp in the scripts as far as seen); (3) calcnear edge cases as for cnearent.",  "fix": "Drop the `&= 0xff` for DOS v3 (compare s16(id) with s16(word[vram-0x10])); fix trinorme as for 0x59." }, {  "table": "opcodes",  "index": "0x5b",  "name": "cnearmat",  "original_addr": "0x7d99",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2132 (sviewmat 1957, clipmat 1940, traitmat/multimat/monomat 1901-1938)",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: fview=0; expr -> valnorme; expr -> matmask stored as a BYTE at [0x16032]; per entity: same group, then 0x7ac6 (clipmat), then calcnear. 0x7ac6: forme=[vram-0x1a]; if forme<0 or low16(ebp)==low16(edi) returns ZF=1 => entity SKIPPED. Forme table = 16-bit signed offsets; header test `test bl,bl` (first byte, sign) -> multi (0x7b2e: count = byte header+1, entries recurse through 0x7b5b with 16-bit offsets, where a sub-header word >=0 means multi and <0 means mono) else mono (0x7b74: goodmat=[0x1603c]=word, and with word[0x16032]). Port: clipmat returns $wforme when forme<0 or self, i.e. -1 (truthy) or a non-zero forme: those entities are INCLUDED instead of skipped; header tested with xread16()<0 (sign of the 2nd byte on LE data) and count read at header byte 0, both swapped vs the original's byte0-flag/byte1-count; traitmat reads the offset with xread32 instead of a signed 16-bit word and uses the inverted mono/multi test of the sub-level. Unused by Robinson's scripts.",  "fix": "clipmat: return 0 when forme<0 or src==tgt; header flag = s8(xread8(hdr)) < 0, count = xread8(hdr+1); traitmat: offset = xread16 (signed) at baseform+2*idx, sub-header word >=0 -> multimat, <0 -> monomat; matmask kept as a byte (plus whatever is at the next byte if exactness matters)." }, {  "table": "opcodes",  "index": "0x5c",  "name": "cviewent",  "original_addr": "0x828a",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2147",  "status": "same",  "severity": "low",  "used_by_game": "0",  "details": "Original: fview=1; expr -> valnorme (u16*u16); expr -> valchamp [0x1603a]; expr -> entity filter; jmp 0x80df (cnearent body). calcnear view test: dot = sum(s8 dir[+0x34/38/3c] * delta) 32-bit, product = dot * champ computed as lo16(dot)*champ (unsigned) + hi16(dot)*champ<<16, val <= product signed. Port: same operands, calcnear `$val <= mul32(dot, valchamp)`: same for champ>=0. Inherits the trinorme one-pass and calcnear edge differences of 0x59.",  "fix": "Same trinorme fix as 0x59." }, {  "table": "opcodes",  "index": "0x5d",  "name": "cviewtyp",  "original_addr": "0x8220",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2163",  "status": "same",  "severity": "low",  "used_by_game": "0",  "details": "Original: fview=1; expr -> valnorme; expr -> valchamp; lodsw inline type id; jmp 0x7ec1 (cneartyp body). Port: same order (script_read16 on PC). Same `&0xff` / trinorme remarks as 0x5a.",  "fix": "As 0x5a." }, {  "table": "opcodes",  "index": "0x5e",  "name": "cviewmat",  "original_addr": "0x81e5",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2184",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: fview=1; expr valnorme; expr valchamp; expr -> matmask byte [0x16032]; jmp 0x7dc3 (cnearmat body). Port: same operands; shares the clipmat/traitmat differences described for 0x5b (forme<0/self included, header byte order, 32-bit offset read).",  "fix": "As 0x5b." }, {  "table": "opcodes",  "index": "0x5f",  "name": "corient",  "original_addr": "0x6019",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2201",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: expr dx; base = word[ebp-0x20] (setvect) ? movsx(setvect)+[ebp-0x14]+1 : 0x19687 (standard vector table +1); bx=dx*3 (16-bit); copies 3 bytes to [ebp+0x34],[+0x38],[+0x3c]. Port: varD7*3, vstandard+1 or setvect+org+1, writes WCX2/WCY2/WCZ2. Same (only a 16-bit wrap of idx*3 for huge indexes differs).",  "fix": "" }, {  "table": "opcodes",  "index": "0x60",  "name": "crstent",  "original_addr": "0x7610",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1665",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: [0x1603e]=0x17a2a then falls into csuccent 0x75cc (dx=[ptr]; if dx>=0 ptr+=2; store). Port: ptrent=0; csuccent(). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x61",  "name": "csend",  "original_addr": "0x8665",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2216",  "status": "same",  "severity": "none",  "used_by_game": "162",  "details": "Original: lodsb n, ecx=n+1 values; expr entity; if -1, null vram ([0x15f72]+ent), or byte[vram-0x24]&1: evaluates the n+1 values and drops them (0x86e9 loop). Else bx=head [vram-0x1c], ax=word[org+0x16]; per value: cur=bx, bx+=2, if bx>=-0x3e bx-=ax; if bx==tail [vram-0x1e]: head=bx, skip the remaining ecx-1 values; else word[vram+cur]=dx, loop; at the end head=bx and byte[vram-0x24]|=0x80. Port: identical consumption (length+1 values, same counts on the full/skip paths), limit -0x3f, head set to the next slot on full, 0x80 flag only on normal end. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x62",  "name": "cscanon",  "original_addr": "0x8795",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2288",  "status": "same",  "severity": "none",  "used_by_game": "49",  "details": "byte[ebp-0x24] &= 0xfe in both.",  "fix": "" }, {  "table": "opcodes",  "index": "0x63",  "name": "cscanoff",  "original_addr": "0x878a",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2294",  "status": "same",  "severity": "none",  "used_by_game": "55",  "details": "Original: byte[ebp-0x24] |= 1 then 0x877a (scanclr: word[-0x1e]=word[-0x1c], byte[-0x24]&=0x7f). Port: |1 then cscanclr() for version!=10. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x64",  "name": "cinteron",  "original_addr": "0x87a1",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2303",  "status": "same",  "severity": "none",  "used_by_game": "55",  "details": "byte[ebp-0x24] &= 0xfd in both.",  "fix": "" }, {  "table": "opcodes",  "index": "0x65",  "name": "cinteroff",  "original_addr": "0x879b",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2309",  "status": "same",  "severity": "none",  "used_by_game": "62",  "details": "byte[ebp-0x24] |= 2 in both.",  "fix": "" }, {  "table": "opcodes",  "index": "0x66",  "name": "cscanclr",  "original_addr": "0x877a",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2279",  "status": "same",  "severity": "none",  "used_by_game": "66",  "details": "word[ebp-0x1e]=word[ebp-0x1c]; byte[ebp-0x24]&=0x7f in both (port skips the &0x7f only for v1.0).",  "fix": "" }, {  "table": "opcodes",  "index": "0x67",  "name": "callentity",  "original_addr": "0x842f",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2315",  "status": "same",  "severity": "none",  "used_by_game": "67 (mostly before findtyp; once before nearent)",  "details": "[0x16056]=1 (fallent) in both. The difference in the following near/view sort is reported under 0x59.",  "fix": "" }, {  "table": "opcodes",  "index": "0x68",  "name": "cpalette",  "original_addr": "0x8914",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2321 -> dos_cpalette fn/image.php:606",  "status": "same",  "severity": "low",  "used_by_game": "27",  "details": "Original: [0x15fc7]=0 (flagmain); expr; if <0: if >=-2 clear [0x16081..83] and call 0x8c3d with cx=0 (restore saved palette, no fade); if >=0 and [0x15f9e] (selpalet skip)==0: 0x5c01 (resource of the current script, bounds checked against [res+4], resolved ptr) and if byte==0xfe clear counters and 0x8988 with cx=0 (immediate topalette: [0x1607f]=1, [0x16084]=1, copies 6-bit colours into 0x1682f, ...); always [0x15f9e]=0. Port (DPAL_B32): flagmain=0, idx<0 && >=-2 -> counter/reload=0, dpal_ctopalsav(idx,0); idx>=0 && !dpal_skip && byte 0xfe -> dpal_topalette(res,0); dpal_skip=0. Same operands and control flow. Unverified detail: 0x8988 sets [0x1607f]=1 unconditionally whereas dos_cpalette sets dpal_ftopal=1 only for non-B32 families (worth checking against the palette module audit if 0x1607f is dpal_ftopal).",  "fix": "" }, {  "table": "opcodes",  "index": "0x69",  "name": "cdefcolor",  "original_addr": "0x8bdd",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2352",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original DOS RRQ: two expressions (0x9d24, 0x9d17) and ret: no effect. Port: two expressions, dos_pal_active -> dos_cdefcolor, which does nothing for DPAL_B32 (default case). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x6a",  "name": "ctiming",  "original_addr": "0x87a7",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2387",  "status": "same",  "severity": "none",  "used_by_game": "8",  "details": "Original: expr; byte [0x1605e]=dl. Port: Alis::$ctiming = varD7 & 0xff. Same (its consumers are elsewhere).",  "fix": "" }, {  "table": "opcodes",  "index": "0x6b",  "name": "czap",  "original_addr": "0x8fe0",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2425",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: [0x1608d]=word[ebp-0xe]; expr prior (byte 0x1608f), expr vol (byte 0x16097), expr freq (0x16093), expr long (0x16091); if long==0 ret (4 operands only); else expr dfreq (0x16095), [0x16099]=0, [0x16090]=1, call 0x922f which is a bare RET: the DOS executable plays nothing. Port: same operand count (5, or 4 when long==0) but then runson() starts an OPL tone channel (fn/audio.php:474), i.e. a sound the original never makes and a channel taken from other PSG effects.",  "fix": "For the DOS Robinson's Requiem (v3x DOS) skip runson after reading the operands (as psg_ops_dos_v6 does for v6), e.g. extend psg_ops_dos_v6's condition or add a DOS-RRQ check that reads 4 operands then a 5th only if the 4th is non-zero, and returns." }, {  "table": "opcodes",  "index": "0x6c",  "name": "cexplode",  "original_addr": "0x9042",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2456",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: stores pere/prior/vol/freq/long from 4 expressions, `test dx,dx; ret` at 0x907f: the explode setup at 0x9080 is dead code, nothing plays. Port: 4 expressions (same sync) then runson(eChannelTypeExplode...) plays an OPL noise.",  "fix": "Read the 4 operands and return for DOS RRQ (no runson)." }, {  "table": "opcodes",  "index": "0x6d",  "name": "cding",  "original_addr": "0x911d",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:2489",  "status": "differs",  "severity": "medium",  "used_by_game": "1 (logo.als: ding 127, 127, 500, 100)",  "details": "Original: 4 expressions (prior byte, vol byte, freq word unchanged, long); if long!=0: dfreq=0, dvol=-max(1,(vol<<8)/long) at [0x16099], type [0x16090]=1, call 0x922f = bare RET: silent on DOS. Port: same 4 operands but runson(eChannelTypeDingZap, ..., freq = varD7>>1, ...) synthesises an OPL tone (sys_audio.php:337) on the logo screen, a sound the DOS original never produces (and the freq>>1 is not in the original either).",  "fix": "For DOS RRQ: read the 4 operands and return without runson (the original's player 0x922f is a no-op)." }, {  "table": "opcodes",  "index": "0x16",  "name": "cbnz16",  "original_addr": "0x3b34",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3327",  "status": "same",  "severity": "none",  "used_by_game": "34 (binary decode of var/scripts/*.bin)",  "details": "Original: test dx,dx; if dx!=0 lodsw, movsx, esi+=offset (relative to after the 2-byte operand); else esi+=2. dx = 16-bit result of the last expression. Port: bztest() = s16(varD7) on DOS; d7==0 ? pc+=2 : pc+=s16(read16()). Same operands consumed, same target.",  "fix": "" }, {  "table": "opcodes",  "index": "0x17",  "name": "cbnz24",  "original_addr": "0x3b45",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3336",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: dx!=0 -> lodsw (signed 16-bit offset), inc esi (3rd byte ignored), esi+=offset (relative to after 3 bytes); else esi+=3. Port: read_off24() on little-endian = s16(read16) + skip 1 byte; same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x18",  "name": "cbeq8",  "original_addr": "0x3b57",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3369",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: cmp dx,cx (16-bit D7 vs D6); equal -> lodsb movsx add esi; else inc esi. Port: cbcond(beqtest()) reads s8 then adds if s16(D7)==s16(D6). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x19",  "name": "cbeq16",  "original_addr": "0x3b65",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3375",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: dx==cx -> lodsw signed offset added after operand; else esi+=2. Port identical.",  "fix": "" }, {  "table": "opcodes",  "index": "0x1a",  "name": "cbeq24",  "original_addr": "0x3b76",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3381",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: dx==cx -> lodsw, inc esi, add (16-bit offset, 3rd byte ignored); else esi+=3. Port read_off24 LE = same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x1b",  "name": "cbne8",  "original_addr": "0x3b88",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3387",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: dx!=cx -> s8 jump; else skip 1. Port same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x1c",  "name": "cbne16",  "original_addr": "0x3b96",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3393",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: dx!=cx -> s16 jump; else skip 2. Port same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x1d",  "name": "cbne24",  "original_addr": "0x3ba7",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3399",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: dx!=cx -> lodsw, inc esi, add; else skip 3. Port same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x1e",  "name": "cstore",  "original_addr": "0x3bb9",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:188",  "status": "same",  "severity": "low",  "used_by_game": "9806",  "details": "Original: if byte [0x15fc3]!=0 -> jmp 0x1c33 (shutdown: 0x2dc3,0x10857,0x1ed4,0x2779,0x230f,0x20a7 then int21 ax=4c00, i.e. quit to DOS: abort flag checked here, in ceval/cadd/csub, key wait 0x2485 and the scheduler 0x37fe). Else lea ebx,[0x18328] (RESETS the expression stack pointer), call 0x9d2a (cx=dx i.e. D6=D7, eval opername via table 0x1884e), xchg [0x16008]<->[0x16010] (sd7<->oldsd7), lodsb and jmp [eax*2+0x189a2] (storenames). Port: readexec_opername_saveD7 (D6=D7, eval, s16) + cstore_continue (swap sd7/oldsd7, storename). Operand stream and effects identical. Differences: (1) port never resets Alis::$acc to acc_org at the start of an expression opcode (only per script frame, fn/alis.php:1141/1224), the original resets ebx at every cstore/ceval/cadd/csub and every 0x9d24 call: any unbalanced push in an opername accumulates in the port but not in the original; (2) quit flag 0x15fc3 = platform (host quits).",  "fix": "Optional robustness: set Alis::$acc = Alis::$acc_org at the start of cstore/ceval/cadd/csub (v3), as the original's lea ebx,[0x18328]. Note: original stack cells are 16-bit (aeval 0xac9c does sub ebx,2) while the port uses 4-byte cells; harmless as long as it is internally consistent." }, {  "table": "opcodes",  "index": "0x1f",  "name": "ceval",  "original_addr": "0x3bf3",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:195",  "status": "same",  "severity": "none",  "used_by_game": "4149",  "details": "Original: quit-flag check [0x15fc3] (-> 0x1c33), lea ebx,[0x18328], jmp 0x9d2a (cx=dx, lodsb, jmp [eax*2+0x1884e]). Port: readexec_opername_saveD7 (D6=D7, eval, s16 for v<60). Same except the expression-stack reset (see cstore) and the quit flag (platform).",  "fix": "" }, {  "table": "opcodes",  "index": "0x20",  "name": "cadd",  "original_addr": "0x3c0b",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:201",  "status": "same",  "severity": "none",  "used_by_game": "931",  "details": "Original: quit-flag check, lea ebx, call 0x9d2a (D6=D7, eval), then 0x3c23: xchg [0x16008]<->[0x16010], lodsb, jmp [eax*2+0x18a1a] (addnames). Port: readexec_opername_saveD7 + readexec_addname_swap (swap sd7/oldsd7, addname). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x21",  "name": "csub",  "original_addr": "0x3c45",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:208",  "status": "same",  "severity": "none",  "used_by_game": "207",  "details": "Original: quit-flag check, lea ebx, call 0x9d2a, neg dx (16-bit), jmp 0x3c23 (swap buffers, addname). Port: saveD7, varD7 = s32(-varD7), addname_swap. Only edge case: -(-32768) = 32768 in the port vs 0x8000 in the original; every addname of the original (0xa9f5.. 0xac9c) uses dl/dx only, and the port's add helpers mask to 8/16 bits, so the result is identical.",  "fix": "" }, {  "table": "opcodes",  "index": "0x22",  "name": "cmul",  "original_addr": "0x3c62",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:147",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original handler is a bare RET (no operand consumed). Port cmul() is empty. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x23",  "name": "op_cdiv (cdiv)",  "original_addr": "0x3c63",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:155",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: bare RET. Port op_cdiv() empty (renamed because of runtime.php cdiv()). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x24",  "name": "cvprint",  "original_addr": "0x3e30",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:216",  "status": "platform",  "severity": "low",  "used_by_game": "0",  "details": "Original: [0x15f48] charmode=0, call 0x9d24 (lea ebx, D6=D7, eval), 0x3e76 -> 0x3f82: 0x3fa0 converts dx to decimal in the [0x16008] (sd7) buffer ('-' + neg, 5 digits from table 0x1966c, leading zeros suppressed, last digit always), then each char via 0x3ecf; charmode 0 -> 0x2248 = DOS int21 ah=2 (console / BIOS teletype at the BIOS cursor). Port: charmode=0, saveD7, putval -> printd0/valtostr into sd7 then put_char, which drops charmode 0 (fn/image.php:1483). Operands same; visible output dropped (debug console text).",  "fix": "If wanted: in put_char() charmode 0, draw the char with an 8x8 BIOS-like font at (xlocate*8, ylocate*8) and advance xlocate (handle 0x0d/0x0a), emulating int21/2 in VGA mode." }, {  "table": "opcodes",  "index": "0x25",  "name": "csprinti",  "original_addr": "0x3e42",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:224",  "status": "platform",  "severity": "none",  "used_by_game": "0",  "details": "Original: loop {charmode=0; lodsb; if 0 ret; call 0x3ecf} (charmode reset before every char). Port: charmode=0 once, read bytes until 0, put_char each (charmode 0 dropped). put_char never changes charmode, so same; output dropped as for cvprint.",  "fix": "" }, {  "table": "opcodes",  "index": "0x26",  "name": "csprinta",  "original_addr": "0x3e57",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:233",  "status": "platform",  "severity": "low",  "used_by_game": "34",  "details": "Original: charmode=0, call 0x9d24 (D6=D7, eval string into [0x16008]), 0x3e69 -> 0x400a: print the zero-terminated string at [0x16008] char by char through 0x3ecf -> charmode 0 -> 0x2248 int21 ah=2 (DOS console output at the BIOS cursor set by clocate). Port: charmode=0, saveD7, put_string() over sd7; put_char drops charmode 0. Operands in sync. Uses in the game: debug/cheat screens only (main.als:113-130 level list when model()<1000, heros.als:836 '** SUPER MEGA SPEED PENTIUM ! **', the 'PASSWORD:' prompt of prefs*/newpref*.als:583 before vinput when inkey()==42 and mb[0x1a0e]==1). These texts are invisible in the port.",  "fix": "Optional: render charmode-0 text (BIOS 8x8 font, cursor xlocate/ylocate in 8-pixel cells, CR/LF) in put_char() so the PASSWORD prompt / debug menus show as on DOS." }, {  "table": "opcodes",  "index": "0x27",  "name": "clocate",  "original_addr": "0x3e7f",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:245",  "status": "same",  "severity": "none",  "used_by_game": "20",  "details": "Original: charmode=0, call 0x9d24 (dx=x, D6 saved), call 0x9d17 (push dx; eval y; cx=y; pop dx) -> dx=x, cx=y; 0x222e: [0x15f5c]=x (al), [0x15f5d]=y (bl), int10 ah=2 sets the BIOS cursor (dh=row, dl=col). Port: charmode=0, saveD7, saveD6 -> D7=x, D6=y; xlocate=x&0xff, ylocate=y&0xff. Same state (BIOS cursor = platform).",  "fix": "" }, {  "table": "opcodes",  "index": "0x28",  "name": "ctab",  "original_addr": "0x3e9c",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:255",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: charmode=0, call 0x9d24, [0x15f5c]=dl (column), dh=[0x15f5d], int10 ah=2 (BIOS cursor). Port: charmode=0, saveD7, xlocate=D7&0xff. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x29",  "name": "cdim",  "original_addr": "0x8515",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:263",  "status": "differs",  "severity": "medium",  "used_by_game": "70 (51 x counter 0x40, 16 x 0x41, 2 x 0xc1, 1 x 0xc2)",  "details": "Original: lodsw-1 -> edi; lodsb counter -> [ebp+edi]; edi--; lodsb byte2 -> [ebp+edi]; n=counter&0xf. If counter>=0 (0x8524): n times {edi-=2; lodsw; mov [ebp+edi],ax} at off-4..off-2-2n, then edi-=2; LODSD (4 bytes consumed) and `66 26 89 04 2f` = mov [es:edi+ebp],AX: only the LOW 16 BITS are written, at off-4-2n. If counter<0 (0x854f): n dwords at off-6-4k then a final dword at off-6-4n (32-bit writes) - port matches this case. Port (and the C) positive case: after the words, offset-=4 and xwrite32(off-6-2n, script_read32()): on little-endian DOS this writes the low word at off-6-2n and the HIGH word (normally 0) at off-4-2n. E.g. `dim 0x70, 0x40, 0x02, [32]`: original writes word 32 at 0x6c; the port writes 32 at 0x6a and 0 at 0x6c, clobbering 2 bytes (0x6a-0x6b) that the original leaves untouched and putting 0 where the original has 32. (On big-endian Atari the C's write32 at off-6-2n happens to put the low word at off-4-2n, which is why it looks right there.) tabint/tabchar/tabstring do not read that word for positive arrays, but the 2 extra bytes may overlap another variable of the script, and anything reading the size word sees 0.",  "fix": "In cdim(), v3 little-endian, positive branch: replace `$offset = s16($offset - 4); xwrite32(vram_org+$offset, script_read32());` by `$offset = s16($offset - 2); xwrite16(Alis::$script->vram_org + $offset, script_read32() & 0xffff);` (consume 4 bytes, write only the low word at off-4-2n), keeping the big-endian path as is." }, {  "table": "opcodes",  "index": "0x2a",  "name": "crandom",  "original_addr": "0x3ebb",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:311",  "status": "differs",  "severity": "medium",  "used_by_game": "1 (main.als:2397 `random 0`)",  "details": "Original: call 0x9d24 (lea ebx, cx=dx i.e. D6=D7, eval), mov ax,dx; test ax,ax; jnz 0x3ec8 (jumps to the very next instruction: no special case), mov [0x15ffc],ax: the seed is stored as is, 0 included. orandom (0xa358) then does seed = seed*0x7ab7 + 0xf881 (16-bit), so seed 0 is a valid deterministic start (first value 0xf881). Port: readexec_opername() (D6 NOT updated), random_number = D7&0xffff, and if 0 -> random_number = sys_random()&0xffff (ANSI-C LCG). The only use in the game is `random 0`, so the port seeds with a different value than DOS and every later random draw differs from the original sequence; D6 also differs after the opcode.",  "fix": "For v3 DOS (at least Robinson's Requiem): crandom() = readexec_opername_saveD7(); Alis::$random_number = Alis::$varD7 & 0xffff; with no zero replacement by sys_random()." }, {  "table": "opcodes",  "index": "0x2b",  "name": "cloop8",  "original_addr": "0x3a8e",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:352 (cloop at :336)",  "status": "same",  "severity": "low",  "used_by_game": "49 (targets: vb/vw locals only)",  "details": "Original: [0x16002]=esi (offset byte address), esi++ (skip offset), dx=0xffff, call 0x3c23 (swap [0x16008]/[0x16010], addname: no D6 save, no ebx reset); if ZF (result of the addname's final add) -> continue after the instruction; else esi=[0x16002], lodsb, movsx, esi+=offset (relative to after the offset byte). Port: reads s8 first, save_loop_pc=pc (after the byte), D7=-1, readexec_addname_swap, if !sr['zero'] pc=save+offset. Same for the targets the game uses (alocb/alocw set sr['zero'], fn/addnames.php:21,29). Latent difference: in the port only alocb/alocw/adirb/adirw (addnames.php:21,29,70,78) set sr['zero']; the other addnames (aloctc/alocti, amain*, ahim*, table targets) leave it stale, whereas in the original every addname ends with an add that sets ZF.",  "fix": "Only if needed: set Alis::$sr['zero'] in every numeric addname (aloctc, alocti, adirtc, adirti, amainb/w/tc/ti, ahimb/w/tc/ti) from the stored result, like alocb/alocw." }, {  "table": "opcodes",  "index": "0x84",  "name": "cmouson",  "original_addr": "0x988a",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3113 (sys_enable_mouse, fn/sys.php:331)",  "status": "differs",  "severity": "low",  "used_by_game": "8",  "details": "Original: no operands. Does nothing if no mouse driver ([0x16068]!=0). If the cursor is hidden ([0x16077]<0): call 0x2941 (reads mouse pos via 0x2876, stores it in [0x1606c]/[0x1606e], then 0x139f6 draws the cursor sprite), sets [0x16077]=1 (shown) and [0x16078]=0xff (hide/show nesting counter). desmouse ([0x1607a]) is NOT touched. Port: sys_enable_mouse(1) sets mouse->enabled=1 and marks the cursor dirty. Operand use is the same (none); the visible effect is equivalent only if desmouse is still set, but the port's cmousoff clears it (see 0x85), so mouson after mousoff shows no cursor in the port.",  "fix": "Nothing to change in cmouson itself; fix cmousoff (0x85) so desmouse survives a mousoff/mouson pair." }, {  "table": "opcodes",  "index": "0x85",  "name": "cmousoff",  "original_addr": "0x98b1",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3119 -> fn/sys.php:331-338",  "status": "differs",  "severity": "high",  "used_by_game": "8",  "details": "Original: no operands. Returns if no mouse ([0x16068]!=0). If the cursor is shown ([0x16077]>=0): [0x16077]=0xff and call 0x13a16 (0x13bbf, erases the cursor sprite). The cursor descriptor [0x1607a] (desmouse, written only by cdefmouse at 0x991a) is kept. Port: sys_enable_mouse(0) sets enabled=0 AND, for version<60, sets Alis::$desmouse=0 (fn/sys.php:334-336), so sys_dirty_mouse builds cursor=null. Robinson does mousoff ... mouson with no defmouse in between (playfilm.als:168/189, main.als:2134..2292, yoda.als:2146/2254, 4622/4648), and defmouse runs only once at the start of souris.als:16 / flags.als:13. In the port the cursor disappears for good after the first film / mousoff.",  "fix": "In sys_enable_mouse (fn/sys.php:334-336) do not clear Alis::$desmouse when disabling for version < 60: only toggle mouse->enabled and set dirty_mouse (PlayScene::drawCursor already hides the cursor when !enabled)." }, {  "table": "opcodes",  "index": "0x86",  "name": "cmouse",  "original_addr": "0x98d1",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3126",  "status": "differs",  "severity": "medium",  "used_by_game": "21",  "details": "Original: call 0x2876, then three stores through 0x3bd1 (cstore_continue: swap sd7/oldsd7, storename dispatch) in the order x, y, buttons. 0x2876: if no mouse ([0x16068]!=0) returns x=-1, y=-1, buttons=0; otherwise x=[0x18e3b]+[0x18a98], y=[0x18e3d]+[0x18a9a] (raw position + the offset set by csetmouse), each clamped to 0..[0x178ef]-1 / 0..[0x178f1]-1 (screen width/height), and buttons=[0x18e43] = raw button bits & 3 (written at 0x280d: 1=left, 2=right, 3=both). Port: same three stores in the same order, but (a) buttons = lb?1:(rb?2:0): the value 3 (both buttons) is never returned, and souris.als uses it ('table vb[0x5c], -1' third case L0082: mb[0xe88]=2, mb[0x1a0e]=1); (b) the csetmouse offset is not applied (the port has none, see 0x88); (c) the port also reports latched quick clicks (lb_clicked/rb_clicked), a deliberate port addition.",  "fix": "In cmouse: compute buttons as ($lb_seen ? 1 : 0) | ($rb_seen ? 2 : 0) so both buttons give 3. Add persistent offsets (e.g. SysVars::$mouseOffX/$mouseOffY) and return clamp(raw+off, 0, frameW-1) / clamp(raw+off, 0, frameH-1), like 0x2876." }, {  "table": "opcodes",  "index": "0x87",  "name": "cdefmouse",  "original_addr": "0x98f1",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3153",  "status": "differs",  "severity": "low",  "used_by_game": "2",  "details": "Original: [0x15fc7]=0 (flagmain), read one expression (0x9d24), 0x5c46 = address of the entry in the script's sprite/descriptor table (error 0xf through 0x144a0 if index >= count at [tbl+4]), kept in [0x15eb6]; 0x5c01 = the resolved descriptor (entry + [entry]) -> [0x1607a] (desmouse). Then writes the table-entry address into the cursor sprite slot [fs:[0x16074]+8], so the cursor is a real sprite of the VM's sprite list. No check of the descriptor's type byte. Port (v<60, non-Mac): flagmain=0, one expression, adresdes(), ptr = addr+[addr], sets desmouse only when the first byte of the descriptor is 0, 0x10 or 0x14, then set_update_cursor(). Same operands consumed; the port silently ignores other descriptor types where the original accepts any; the cursor is drawn by the host overlay instead of the sprite slot (platform).",  "fix": "Optional: drop the type filter (0/0x10/0x14) for version 31 DOS, or log when it rejects; keep the software overlay (platform)." }, {  "table": "opcodes",  "index": "0x88",  "name": "csetmouse",  "original_addr": "0x9a22",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3180 -> fn/sys.php:325",  "status": "differs",  "severity": "high",  "used_by_game": "4",  "details": "Original: x = expression (0x9d24, dx), y = expression (0x9d17: pushes dx, evaluates, cx=result, pops dx), then 0x28f1: if x < 0 (signed): offset [0x18a98]=[0x18a9a]=0 (reset); else [0x18a98] = x - raw_x([0x18e3b]), [0x18a9a] = y - raw_y([0x18e3d]). It never moves the hardware mouse: it sets a persistent offset that cmouse (0x2876) adds, so the reported position becomes (x,y) and then follows the real moves. Port: x = varD7, then y = Alis::$varD6 after the second expression (bug carried from the C: the second operand is in varD7, varD6 is unrelated), then sys_set_mouse(x,y) writes SysVars::$mouse->x/y directly; PlayScene.php:240-241 overwrites x/y from the host mouse every frame, so the effect is lost, and 'setmouse -1, -1' would write 65535,65535 instead of resetting. Robinson uses it in souris.als:63-77 for the shaking/drunk cursor (setmouse x+rnd, y+rnd, and setmouse -1,-1 to cancel).",  "fix": "csetmouse: $x = s16(varD7) after the first readexec_opername, $y = s16(varD7) after the second. Replace sys_set_mouse with an offset: if ($x < 0) { offX = offY = 0 } else { offX = $x - rawX; offY = $y - rawY } (raw = the host position PlayScene writes), and make cmouse return clamp(raw + off)." }, {  "table": "opcodes",  "index": "0x89",  "name": "cdefvect",  "original_addr": "0x9ab9",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3194",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: lodsb n; add si, n*3+3 (skips the n+1 three-byte vectors). Port: reads the byte, pc += n*3+3. Same bytes skipped. Only quirk: the original adds to SI (16-bit), so a carry out of the low 16 bits of ESI is lost; irrelevant in practice.",  "fix": "" }, {  "table": "opcodes",  "index": "0x8a",  "name": "csetvect",  "original_addr": "0x9acc",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3204",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: lodsw; word [ebp-0x20] = it. Port: script_read16 then set_0x20_set_vect (xwrite16(vram-0x20)). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x8b",  "name": "cnul (Grammar: cnul2)",  "original_addr": "0x38ef",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:37 (table opcodes_b.php ~4286)",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: plain 'ret' at 0x38ef: a no-op, the VM goes on with the next opcode. Port: cnul() sets Alis::$state = eAlisStateStopped, which stops the whole VM if a script ever executes 0x8b.",  "fix": "Map 0x8b to a no-op function (e.g. cnul2(): void {}) for version 31 instead of cnul." }, {  "table": "opcodes",  "index": "0x8c",  "name": "capproach",  "original_addr": "0x9bd0",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3248 (deb_approach 3214, calscal 3229)",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: expression = entity offset; returns if -1. 0x9b05: d = target.wc{x,y,z} - self.wc{x,y,z} (16-bit) into [0x16028..0x1602c]; vector table = 0x19686 (vstandard) if word [ebp-0x20]==0, else script base + [ebp-0x20]; count byte n, [ebp+0x32]=n+1, loop n+1 times, dot = sum of s8*s16 imul products as 32 bits; keeps the strictly greatest (start 0x80000000), then [ebp+0x32] -= loop counter of the best (=> index of the best vector, 0-based), [ebp+0x34/0x38/0x3c] = its 3 bytes. Port: same computation; ADDR is first written n instead of n+1 but the final value (n - best D7) is the same index. Quirk only in the original: the set_vect path uses 'lds di,[ebp-0x14]' (16-bit DI + DS load), a latent bug on a path Robinson never reaches.",  "fix": "" }, {  "table": "opcodes",  "index": "0x8d",  "name": "cescape",  "original_addr": "0x9c66",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3284",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Same as capproach, but keeps the strictly smallest dot product, starting at 0x7fffffff and comparing the full 32-bit sum (0x9ca2-0x9cb4). Port: $test = s16(calscal(...)) truncates the 32-bit dot product to 16 bits before comparing (inherited from the C), so products outside -32768..32767 compare wrongly.",  "fix": "In cescape use $test = calscal($addr0, $wcx, $wcy, $wcz) (no s16) like capproach." }, {  "table": "opcodes",  "index": "0x8e",  "name": "cvtstmov",  "original_addr": "0x7398",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3320",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: [0x1602e]=xinv [ebp-3]; wcx/wcy/wcz = s8 [ebp+0x34/0x38/0x3c] + word [ebp+0/8/0x10]; matmask [0x16032] = one expression; wforme [0x16030] = cforme [ebp-0x1a]; clipform 0x7631; jmp 0x7610 = crstent (tablent pointer reset, first entry stored through a storename operand via 0x3bd1). Port: same values, clipform() then crstent() (which reads xinv itself and consumes the store operand). Same operands (E S).",  "fix": "" }, {  "table": "opcodes",  "index": "0x8f",  "name": "cvftstmov",  "original_addr": "0x7476",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3333",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Like 0x8e, but two expressions: first -> matmask [0x16032], second -> wforme [0x16030]; then clipform 0x7631 and crstent (0x7610 + store). Port: same order (matmask, wforme), clipform(), crstent().",  "fix": "" }, {  "table": "opcodes",  "index": "0x90",  "name": "cvmov",  "original_addr": "0x5e5a",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3347",  "status": "same",  "severity": "none",  "used_by_game": "3",  "details": "Original: word [ebp+0] += s8 [ebp+0x34]; word [ebp+8] += s8 [ebp+0x38]; word [ebp+0x10] += s8 [ebp+0x3c]. Port (v<60): xadd16 of WCX/WCY(8)/WCZ(16) with s8 WCX2(0x34)/WCY2(0x38)/WCZ2(0x3c). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x91",  "name": "cdefworld",  "original_addr": "0x9ad4",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3363 (Grammar 'w r6', Lang/Grammar.php:58)",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: lodsw offset (sign-extended), edi = ebp + offset, rep movsb with ecx=5: copies 5 script bytes to vram+offset .. vram+offset+4 (7 bytes consumed in all). Port (v31): counter = 6 (5 only for v1.0 PC) and writes every byte to the SAME address vram_org+offset (the C bug): consumes 8 bytes, so the script would lose sync by one byte, and only the last byte lands in memory. The decompiler's Grammar 'w r6' has the same wrong length.",  "fix": "cdefworld for v<60: $counter = 5 for version 31 (as 0x9adb mov ecx,5) and write to vram_org + offset + i (i = 0..4). Change Grammar 0x91 to 'w r5' for v31." }, {  "table": "opcodes",  "index": "0x92",  "name": "cworld",  "original_addr": "0x9ae3",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3397",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: lodsw; word [ebp-0x22] = it (the bytes go to vram-0x22 and vram-0x21). Port (v<60): writes the two bytes at vram_org+0xffde and vram_org+0xffdf, i.e. 64 KiB forward instead of 0x22 bytes back (the C's u16 wrap of -0x22 kept as is); two bytes consumed in both, so no desync, but the wrong memory is written.",  "fix": "cworld for v<60: xwrite8(vram_org - 0x22, script_read8()); xwrite8(vram_org - 0x21, script_read8()) (or xwrite16le(vram_org - 0x22, read16))." }, {  "table": "opcodes",  "index": "0x93",  "name": "cfindmat",  "original_addr": "0x7b89",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3410",  "status": "missing_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original: one expression, low byte -> byte [0x16032] (matmask; the high byte of the word keeps its old value and is used too). Walks the entity list from offset 0 (main included) through [atent+off+4] until 0; for each target (0x7ac6): skip if cforme [t-0x1a] < 0 or if bp==di (low 16 bits of self vram == target vram: self); form = base([t-0x14]+[+0xe]+[+6]) + word[base+cforme*2]; a simple form (header low byte >= 0) matches if (its material word & [0x16032]) != 0 (0x7b74, word also kept in [0x1603c]); a composite form (header low byte < 0) recurses over its sub-form indexes (count = header high byte, 0x7b2e/0x7b5b) and matches on the first sub-form that matches. Matches go to tablent (0x17a2a) with no size check; it reads (does not write) the matent slot [+0x100] into [0x1603c]; stops after the first unless fallent [0x16056]; terminator 0xffff, fallent=0, then jmp 0x7610 = crstent which consumes a storename operand. Port (v31): only logs MISSING and consumes nothing, so the expression and store bytes would be executed as opcodes (desync). Grammar 0x93 '' is wrong too (should be 'E S').",  "fix": "Implement cfindmat for version >= 20 < 60: readexec_opername(); matmask low byte = varD7 & 0xff; loop entities from 0 with the form-material test above (reuse the form walk used by clipform/formhit), fill Alis::$tablent, ENTLIST_END, fallent = 0, crstent(). Set Grammar 0x93 to 'E S'." }, {  "table": "opcodes",  "index": "0x94",  "name": "cfindtyp",  "original_addr": "0x7bef",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3423",  "status": "same",  "severity": "none",  "used_by_game": "215",  "details": "Original: lodsw id (raw 16 bits); walks entities from offset 0; match if word [t-0x10] (script id) == id and t != self (full ebp compare); matent slot [+0x100] = 0, tablent = entity offset; stops after the first unless fallent [0x16056]; terminator 0xffff; fallent = 0; jmp 0x7610 (crstent + storename). Port (PC): script_read16 (unsigned, so the '<0 then &0xff' never applies), same walk from alis_first_ent()=0, same matent=0/tablent, ENTLIST_END, fallent=0, crstent(). Edge differences only: the port compares s16(id) with the unsigned script id, so an id >= 0x8000 never matches (the original compares raw words); tabent_full caps at 255 entries where the original has no check (128-word buffer). Robinson's ids are all small positive values (15, 18, 4, 21, 3, 84 ...).",  "fix": "Optional: compare ($id & 0xffff) == get_0x10_script_id($tgt_vram) for exact parity." }, {  "table": "opcodes",  "index": "0x95",  "name": "cmusic",  "original_addr": "0x9511",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3596 -> music() 3494",  "status": "platform",  "severity": "medium",  "used_by_game": "4",  "details": "Original: [0x15fc7]=0, one expression = music index, 0x9484 adresmus (script base + [+0xe] + [+0xc] + idx*4, no bounds check). If the type byte is not 0, 3 or 4: 5 more expressions read and ignored. Else: [0x160a8]=addr+6, then 5 expressions stored raw: volume byte [0x160a3], tempo byte [0x160a1], word [0x160ac] (attack), word [0x160b0] (fall), word [0x160ae] (duration) - no +1/+2 adjustment - then 0x10a14: only if music is enabled ([0x1609e]) and a sound card is present ([0x18aaa]); counts the 32 sample slots ([0x160be]) holding type-6 sounds, flag [0x1abb0]=1 if >=3, and starts the DOS tracker 0x1158e (128-byte order list at +2, patterns at +0x86 + order*1024, volume = [0x160a3]>>1, tempo = [0x1bb0d]*6>>4, attack/duration/fall copied raw). Port: same operand count (6 expressions) and type tests, but: type 0 goes to mv1_gomusic (Atari engine) where DOS uses the same tracker for 0/3/4; type 3 sets mustate=1 and plays nothing; type 0/3 use attack+1, duration+1, fall+2 and type 4 attack+1, fall+1 where DOS stores the raw values (Robinson calls 'music v, t, v, 1, -1, 200'); muvol = (volume>>1)+1 in mv2_gomusic vs volume>>1; tempo taken from the operand (mutempo) whereas 0x1158e takes it from [0x1bb0d]; it also stores Aud::$musicId (not in the original).",  "fix": "For the DOS v31 path: send types 0, 3 and 4 to the same (mv2/tracker) engine, store attack/duration/fall without the +1/+2 (or check that mv2 adds them back itself), and muvol = volume >> 1. Low priority (audio host layer)." }, {  "table": "opcodes",  "index": "0x96",  "name": "cdelmusic",  "original_addr": "0x9597",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3611",  "status": "platform",  "severity": "low",  "used_by_game": "6",  "details": "Original: one expression -> [0x160ae] (fade length), [0x160ac]=0, [0x160b0]=1, then 0x10a8a: if a sound card is present, 0x11697: if music is playing ([0x1bae5]): length 0 -> stop now (flags cleared, 4 tracker voices silenced via 0x10d65); else fade out over that length ([0x1bae8]/[0x1baea]=length, [0x1bae4]=1). Port: one expression, mv2_offmusic(varD7): 0 -> mv2_stopmusic (muflag=0), else fade (mubufc=length, mubreak=1). Same operand and equivalent effect in the host audio layer.",  "fix": "" }, {  "table": "opcodes",  "index": "0x97",  "name": "ccadence",  "original_addr": "0x9476",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3631",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: one expression, ax=value, call 0x10ac0, which is a bare 'ret': a no-op in the DOS build (operand consumed, nothing changes). Port (v31): 0 -> 1, then sets Aud::$mutempo and Aud::$mutemp = mutempo*6/32, which changes the tempo of the music playing.",  "fix": "For the DOS v31 build make ccadence only consume its operand (readexec_opername(); return;)." }, {  "table": "opcodes",  "index": "0x98",  "name": "csetvolum",  "original_addr": "0x9464",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3648",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: one expression; low byte -> [0x161c6] and [0x160a3] (the volume byte the next cmusic passes to the tracker). It does not touch the music playing ([0x1badd]/[0x1badc]). Port: sets muvolume, the low byte of maxvolume, muvol = (v>>1)+1 and recomputes dattac/dchute, which changes the current music's volume right away.",  "fix": "For DOS v31: only store the byte for the next cmusic (e.g. a pending volume used by music()), and do not change muvol/maxvolume of the current music." }, {  "table": "opcodes",  "index": "0x99",  "name": "cxinv",  "original_addr": "0x535b",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3671",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: byte [ebp-3] ^= 1. Port: get_0x03_xinv ^ 1 -> set_0x03_xinv. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x42",  "name": "cstop",  "original_addr": "0x41c0",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:645",  "status": "same",  "severity": "none",  "used_by_game": "1415",  "details": "Original: `add esp,4; ret`. It drops the return address of the opcode loop 0x38e3 and returns to the scheduler. In a main run (0x37b5..0x38de) the scheduler then saves ESI (the PC just after the opcode) into [ebp-8]. It reads no operand. Port: Alis::$script->running = 0. The scheduler (Machine.php) then saves pc and vacc into vram+0x08 / vram+0x0a, which has the same effect.",  "fix": "" }, {  "table": "opcodes",  "index": "0x43",  "name": "cstopret",  "original_addr": "0x41c4",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:766",  "status": "differs",  "severity": "low",  "used_by_game": "74",  "details": "Original: `cmp byte [0x15fcb],0`. When it is 0 (interrupt or 'before'/'after' vector run, fseq=0), it jumps to 0x41c0 and only stops: no stack pop and no touch of [ebp-0xc]. When it is not 0 (main run), it calls 0x3a53 (cret: pops the PC from [ebp+[ebp-0xa]], clears [ebp-0xc] when equal, adds 4 to [ebp-0xa]) and then stops. Port: when fseq==0 it calls cstop() and then, for every version except 1.0, ALSO calls cret() and sets running=0. With fseq==0, cret() pops a return address when saversp > vacc_off, i.e. when the interrupt code is inside a jsr, and can clear vram-0xc (set_0x0c_vacc_offset(...,0)). The original never does this in that mode. [ebp-0xc] is read by cjsr in fseq==0 mode (0x3969..0x3978), so clearing it can change later interrupt jsr behaviour. The popped pc/vacc themselves are thrown away, because the scheduler reloads them from vram.",  "fix": "In cstopret(): `if (Alis::$fseq == 0) { cstop(); return; }` for every version, as at 0x41cb (jz 0x41c0), then `cret(); Alis::$script->running = 0;`." }, {  "table": "opcodes",  "index": "0x44",  "name": "cexit",  "original_addr": "0x41d7",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:780",  "status": "differs",  "severity": "medium",  "used_by_game": "252",  "details": "Original: when the current entity [0x15e8e]==0 it jumps to 0x3767, then 0x1c33 (full teardown and DOS exit: platform). Otherwise [0x15e92]=[0x15e8e] and it jumps to killent 0xba45. Killing itself ends at 0xbb53..0xbb6b: [0x15e8e]=previous entity, `add sp,8` drops the opcode-loop AND the scheduler-call return addresses, then `jmp 0x37df`, the next entity. Every remaining scheduler step for the killed entity is skipped, in any phase: after an interrupt ('before' vector) run it skips updtcoord 0x60a1 and the main run. Port: cexit -> killent() (opcodes_b.php:3470), which sets restart_loop=1 and varD5=prev when the entity kills itself. Same operands (none); quitting is platform. BUT the v3 scheduler Machine.php mainV3, after `resume_before:` (line 338), calls updtcoord(Alis::$script->vram_org) and then tests get_0x04_cstart_csleep on Alis::$script->vram_org without checking restart_loop. The v1.0 variant at line 227 has `$this->killed`, the v3 one has nothing. After a cexit/ckill of itself during the 'before' vector, the port writes coordinates into the dead entity's old vram, which memory compaction has given to the next entity, and may even run the main sequence of the killed script.",  "fix": "Machine.php mainV3 (around line 338-344): after the 'before' run, `if (Alis::$restart_loop) { goto next_entity; }`: skip updtcoord and the main/after phases and go straight to `Alis::$varD5 = xread16(atent+4+varD5)`. In other words, apply the v1.0 `$killed` logic to version 3 too, like 0xbb67 `add sp,8; jmp 0x37df`. Same in fn/alis.php alis_main_V3 (line ~1240) if it is still used." }, {  "table": "opcodes",  "index": "0x45",  "name": "cload",  "original_addr": "0x41f7",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:795",  "status": "differs",  "severity": "low",  "used_by_game": "201 (never with id 0)",  "details": "Original: first calls 0x2b47, a debug PCX screenshot (PAGE_xx.PCX at 0x18e47) taken when a key is held: platform. Then lodsw id. When id!=0: [0x15e90]=id, call 0xafaf(edx=name), then skip the name up to its 0. 0xafaf first looks up the id (0xb770) and does nothing if a program with that id is loaded. Otherwise it opens the name as written and checks the file's id. When id==0: 0x9d3d (swap the string buffers and evaluate a string expression), then 0xacd7: builds <basedir 0x17871> + '\\\\' + name, int21 AH=3Bh chdir there (0x2aac), reloads main.io (0x196d6) with id 0, then `add sp,8; jmp 0x37b5` (restarts the scheduler from entity 0). Port: id!=0 replaces the name's extension with platform->ext, calls script_load(), and script_init() skips it when the FILE's id is already loaded. The result is the same; only the I/O order differs, and the port adds an artificial load delay. id==0: the port only evaluates the string (readexec_opername_swap) and ignores the chdir, the main reload and the scheduler restart. Robinson never uses load 0.",  "fix": "Optional: in cload() id==0 branch (v3), after readexec_opername_swap(), set the data path to platform->path + sd7 + '/', reload the main script and restart the scheduler at entity 0 (varD5=0, restart_loop), as at 0xacd7 / 0x4224. Not needed for Robinson." }, {  "table": "opcodes",  "index": "0x46",  "name": "cdefsc",  "original_addr": "0x423a",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:851",  "status": "differs",  "severity": "low",  "used_by_game": "2 (main.als:14-15)",  "details": "Original: lodsw idx (movsx), scr=basemain+idx. `or [scr],0x40`, lodsb -> [scr+1], rep movsb 0x20 bytes -> scr+6. di=libsprit [0x15f90], libsprit=[di+4], [scr+2]=di, [di+6]=0, [scr+4]=0, [di+1]=[scr+1]. Then 0x46f4 (scdosprite): newx [di+0xc] = [scr+0xe] & 0xfff0; newy = [scr+0x10]; DWORD 0x7fff at [di+0x10] (newd=0x7fff AND the word at sprite+0x12 cleared); depx [di+0x16] = ([scr+0xe]+[scr+0x12]) | 0xf; depy = y+h. Then clears [scr+0x2a..0x2f], calls 0x5283 (scadd onto [0x15fc8]) and 0x52fd (vectoriel). Port: same operand reads and flags, with these differences. (1) scdosprite (screen.php:59) masks newx & 0xfff0 and ORs depx with 0xf only for version 1.0. The DOS v3 executable always does it (0x46fd `and ax,-0x10`, 0x4725 `or ax,0xf`), and the same routine is shared by scpos/scsize. (2) vectoriel (screen.php:89) writes 3 bytes at scr+0x26..0x28. The original does three overlapping 16-bit writes (0x5313/0x532e/0x5349), so scr+0x29 also gets the high byte of (m0*m4 - m3*m1). (3) The word at sprite+0x12 is not cleared. With the game's two screens (x=0, w=319/255, scpos 48/0) the masking changes nothing today.",  "fix": "screen.php scdosprite(): use the masked form (newx = x & 0xfff0, depx = (x+w) | 0xf) also for PC v3 (version 31), not only version 1.0. vectoriel(): for v3 also write xwrite8($m+9, (($m0*$m4 - $m3*$m1) >> 8) & 0xff). Optionally clear the word at sprite offset 0x12. Remove the duplicate `Img::$libsprit = $sprite->to_next;`, which is harmless." }, {  "table": "opcodes",  "index": "0x47",  "name": "cscreen",  "original_addr": "0x465d",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:910",  "status": "same",  "severity": "none",  "used_by_game": "101",  "details": "Original: `lodsw; mov [es:ebp-0x16],ax` (unconditional). Port: reads the word and writes vram-0x16 when it differs. Same result.",  "fix": "" }, {  "table": "opcodes",  "index": "0x48",  "name": "cput",  "original_addr": "0x5361",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:923",  "status": "same",  "severity": "none",  "used_by_game": "525",  "details": "Original: flagmain[0x15fc7]=0, invert_x[0x15fc4]=[ebp-3], one expression (0x9d24) -> dx = element index. depx/depy/depz [0x15fb2/b4/b6]=0, numelem word [0x15fbe]=0, then the shared put at 0x5479. Port: same order and values, then put($idx).",  "fix": "" }, {  "table": "opcodes",  "index": "0x49",  "name": "cputnat",  "original_addr": "0x539f",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:947",  "status": "same",  "severity": "none",  "used_by_game": "775",  "details": "Original: flagmain=0, invert_x=[ebp-3]. Five expressions: depx, depy, depz, then idx in dx and numelem via 0x9d17 (cx), stored as a word in [0x15fbe]. Every reader of [0x15fbe] (0x56e9, 0x5709, 0x57a7) reads the byte. Then put 0x5479. Port: reads depx, depy, depz (version != 10), idx, numelem=s8(D6). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x4a",  "name": "cerase",  "original_addr": "0x5cc4",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1028",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: searchtete 0x5737. When found, loop killelem 0x5d16 while di!=0 and [fs:di+2]==[ebp-0x16]. Then ferase [0x15f9d]=0. No operand. Port: searchtete / killelem loop on the same screen_id test, then ferase=0. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x4b",  "name": "cerasen",  "original_addr": "0x5c96",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1054",  "status": "same",  "severity": "none",  "used_by_game": "236",  "details": "Original: one expression -> numelem byte [0x15fbe]; loop searchelem 0x56f7 / killelem 0x5d16 until not found; ferase=0. Port: same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x4c",  "name": "cset",  "original_addr": "0x5dde",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1070",  "status": "same",  "severity": "none",  "used_by_game": "106",  "details": "Original: three expressions written as words to [ebp+0], [ebp+8], [ebp+0x10]. Port (v3): xwrite16 at WCX=0, WCY=8, WCZ=16. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x4d",  "name": "cmov",  "original_addr": "0x5dfd",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1091",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: three expressions added as 16-bit words to [ebp+0/8/0x10]. Port: xadd16 at the same offsets. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x4e",  "name": "copensc",  "original_addr": "0x523e",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1112",  "status": "same",  "severity": "none",  "used_by_game": "8",  "details": "Original: lodsw id (movsx). [basemain+id] &= 0xbf, |= 0x80. scbreak 0x52b9, scadd 0x5283; when bit 1 of [basemain+id+1] is set, openland 0xbb70. Port: same; the id is unsigned in the port, which only matters for ids >= 0x8000, never used (82/338).",  "fix": "" }, {  "table": "opcodes",  "index": "0x4f",  "name": "cclosesc",  "original_addr": "0x5270",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1145",  "status": "same",  "severity": "none",  "used_by_game": "11",  "details": "Original: lodsw id; [basemain+id] |= 0x40. Port: same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x50",  "name": "cerasall",  "original_addr": "0x5cf7",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1158",  "status": "same",  "severity": "none",  "used_by_game": "105",  "details": "Original: bx=0, di=[ebp-0x18]; killelem while di!=0; ferase=0. Port: same loop from get_0x18, then ferase=0.",  "fix": "" }, {  "table": "opcodes",  "index": "0x51",  "name": "cforme",  "original_addr": "0x7150",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1170",  "status": "same",  "severity": "none",  "used_by_game": "57",  "details": "Original: one expression -> word [ebp-0x1a]. Port: set_0x1a_cforme = xwrite16(vram-0x1a). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x52",  "name": "cdelforme",  "original_addr": "0x715b",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1177",  "status": "same",  "severity": "none",  "used_by_game": "24",  "details": "Original: word [ebp-0x1a] = 0xffff. Port: set_0x1a_cforme(-1). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x53",  "name": "ctstmov",  "original_addr": "0x733b",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1672",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: [0x1602e]=xinv [ebp-3]. Three expressions + [ebp+0/8/0x10] -> 0x16028/2a/2c (16-bit), matmask expression -> 0x16032, forme [ebp-0x1a] -> 0x16030. tstform 0x7631: list at 0x17a2a, entities with the same group word +0x30 and forme>=0, not itself, goodmat stored at +0x100, 0xffff end, stops after one hit unless fallent [0x16056]. Then 0x7610 resets the list pointer and runs csuccent 0x75cc (stores the first entry through cstore 0x3bd1). Operands E E E E S. Port: same operands, clipform() + crstent(). Differences inside clipform, a shared callee: an extra bound check of the form index against form count (+0xa) and witmov handling, harmless here.",  "fix": "" }, {  "table": "opcodes",  "index": "0x54",  "name": "ctstset",  "original_addr": "0x74d4",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1688",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original (v3): [0x1602e]=xinv. Four expressions: absolute wcx, wcy, wcz (0x16028/2a/2c), matmask (0x16032). forme=[ebp-0x1a]. tstform 0x7631, then 0x7610 (reset list + csuccent: store the first entity into a storename target). Operands E E E E S. Port: only version 1.0 is handled. For v3 the body is '// MISSING: ctstset': it reads no operand and stores nothing, so the script would desync. Lang/Grammar.php also lists 0x54 ctstset with '' (no operands), which is wrong for v3. Not used by Robinson.",  "fix": "In ctstset(): drop the version==10 test and use that path for v3 too (4 x readexec_opername -> wcx/wcy/wcz/matmask, wforme=get_0x1a_cforme, clipform(), crstent()). Set Grammar OPCODES 0x54 to 'E E E E S'." }, {  "table": "opcodes",  "index": "0x55",  "name": "cftstmov",  "original_addr": "0x7522",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1709",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: xinv. Three relative expressions (+[ebp+0/8/0x10]), matmask expression, forme expression -> 0x16030. tstform 0x7631, then reset list + csuccent store. Operands E E E E E S. Port: same reads, clipform(), crstent().",  "fix": "" }, {  "table": "opcodes",  "index": "0x56",  "name": "cftstset",  "original_addr": "0x7580",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1726",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: xinv. Five expressions: absolute x, y, z, matmask, forme. tstform, then reset + csuccent store. Port (v3): same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x57",  "name": "csuccent",  "original_addr": "0x75cc",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1653",  "status": "same",  "severity": "none",  "used_by_game": "85",  "details": "Original: dx=word at [0x1603e]; when it is >= 0, [0x1603e]+=2; then jmp 0x3bd1 (cstore continuation: stores dx into the storename target that follows). Port: varD7=tablent[ptrent]; ptrent++ when > -1; cstore_continue(). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "9a",  "name": "cxinvon",  "original_addr": "0x534f",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3679",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: mov byte [es:ebp-3],1; no operand. Port: set_0x03_xinv(vram, 1) = xwrite8(vram-3, 1). Identical. (The port's comment says 'Codopname no. 155', but the table slot is 0x9a; only the comment numbering is off.)",  "fix": "" }, {  "table": "opcodes",  "index": "9b",  "name": "cxinvoff",  "original_addr": "0x5355",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3685",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: mov byte [es:ebp-3],0; no operand. Port: xwrite8(vram-3, 0). Identical.",  "fix": "" }, {  "table": "opcodes",  "index": "9c",  "name": "clistent",  "original_addr": "0x7cae",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3691",  "status": "same",  "severity": "low",  "used_by_game": "17",  "details": "Original: walks the entity chain from atent ([0x15f72]) via word [ent+4], starting AFTER entry 0. For each entry it writes matent [0x17a2a+0x100+2i]=0 and tablent [0x17a2a+2i]=ent. It ends the list with 0xffff, sets [0x16056] (fallent)=0, then jumps to crstent 0x7610: ptr=0x17a2a, dx=first entry, ptr+=2 if >=0, then 0x3bd1 (swap the 0x16008/0x16010 string buffers and dispatch one store target S). The original has no bound check: the table holds 128 words before the matent area. Port: same walk, matent=0, tablent, ENTLIST_END=-1, fallent=0, crstent (ptrent=0, csuccent, cstore_continue). One store target is consumed in both. The only difference: the port stops at 255 entries (tabent_full, opcodes_a.php:18), while the original has no check, so more than 127 entities would overwrite its matent area. Robinson never has that many entities.",  "fix": "" }, {  "table": "opcodes",  "index": "9d",  "name": "csound",  "original_addr": "0x95e1",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3780 (sound() at :3717, playsample at fn/audio.php:424, mixer at fn/sys_audio.php:542-600)",  "status": "differs",  "severity": "medium",  "used_by_game": "254",  "details": "Original: [0x15fc7](flagmain)=0. e1=index (pushed), e2=priority. 0x9197 picks one of 4 sample voices (table 0x1abb8, stride 0x40, count [0x1abb1]=4) using priority dx and owner bx=word [ebp-0xe] (the script's entity, get_0x0e_script_ent). If prio<0: reuse the voice with the same prio. If prio>=0: reuse an ACTIVE voice with the same OWNER and the same prio. Otherwise: the first free voice, else the voice with the lowest prio, with the same accept rule as the port. On success it stores owner at +6 and prio at +4. No voice: evaluates the 3 remaining expressions and returns. With a voice: state=0; 0x9484 gives the sample address (script resource table, or main's if flagmain). start=+0xc/+0x10 = addr+0xe; end=+0x14/+0x18/+0x1c = addr+[addr+2]-8. e3: (vol&0xff)>>1 -> +3. e4: 16-bit loop count -> +8. e5*1000 (16-bit mul, no clamp, no fallback) -> +0xa. Then 0x1088e computes the step (freq<<16)/[0x1b5bc] and starts the voice. Mixer 0x10b7e/0x10be8: at the end, dec word loop. If it reaches 0: stop. If >0: restart. If it was <=0: inc keeps it there, so the sample loops FOREVER. There is no check of the sample type byte. Port differences: (1) playsample's first pass matches the priority only and never the owner for positive priorities (runson does it with ->pere, playsample does not). So two entities playing the same positive priority (very common in Robinson: 20, 30, 50...) cut each other off in the port but get separate voices in the original. (2) Loop: the port keeps loopsam&0xffff, then playsample stores loop&0xff (audio.php:467), and the mixer only repeats while loop>1 (sys_audio.php:572). So loop=-1 (used about 29 times in Robinson for ambient loops, e.g. 'sound 5, -10, 20, -1, 6') plays 255 times then stops instead of forever, and loop=0 plays once instead of forever. (3) The port plays only types 1 and 2; the original does not check the type. (4) speed=0 makes the port take the header byte addr+1, and it clamps the frequency to 1..20 kHz (else 10). The original always uses e5*1000; scripts use 3..14 and rnd()+pile(), so this is harmless. (5) Data window: the port plays from addr+0x10 for [addr+2]-0x10+1 bytes, the original from addr+0xe to addr+[addr+2]-8. Volume>>1 is the same (vol_table(ch, volume>>1)). The operand stream is consumed identically (5 E).",  "fix": "In playsample (fn/audio.php:424), add an owner parameter (get_0x0e_script_ent(Alis::$script->vram_org), the current script even for cmsound, like the original bx=[ebp-0xe]). Store it in $canal->pere. In the first loop, match `curson == prio` when prio<0, and `pere == owner && curson == prio && type != None` when prio>=0 (like runson). Store the loop as s16($loop), not &0xff, and in sys_audio.php:572 restart forever when loop<=0, decrement and restart when loop>1, stop when loop==1. Optional for DOS fidelity: drop the type 1/2 test and the speed fallback/clamp for EPlatformPC v3, and use start addr+0xe, length [addr+2]-0x16." }, {  "table": "opcodes",  "index": "9e",  "name": "cmsound",  "original_addr": "0x9662",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3791",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: [0x15fc7]=1, then jmp 0x95e8 (the csound body). The sample is looked up in main's resources: 0x9484 with ebp=[0x15fa0]. The voice owner is still the CURRENT script's [ebp-0xe] (bx is read before 0x9484 switches ebp). Port: flagmain=1; sound() \u2192 adresmus uses main. It inherits every csound difference (owner matching, loop&0xff, type check).",  "fix": "Same as csound (the owner stays the current script's get_0x0e_script_ent)." }, {  "table": "opcodes",  "index": "9f",  "name": "credon",  "original_addr": "0x5805",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3802",  "status": "same",  "severity": "none",  "used_by_game": "2",  "details": "Original: mov byte [es:ebp-0x25],0; no operand. Port (version 31): set_0x25_credon_credoff(vram, 0) = xwrite8(vram-0x25, 0). Identical.",  "fix": "" }, {  "table": "opcodes",  "index": "a0",  "name": "credoff",  "original_addr": "0x580b",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3815",  "status": "same",  "severity": "none",  "used_by_game": "9",  "details": "Original: mov byte [es:ebp-0x25],0x80; no operand. Port: version>=30 gives 0x80 written at vram-0x25. Identical.",  "fix": "" }, {  "table": "opcodes",  "index": "a1",  "name": "cdelsound",  "original_addr": "0x966e",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:3828 (offsound fn/audio.php:544)",  "status": "same",  "severity": "low",  "used_by_game": "16",  "details": "Original: ax=0xffff, call 0x108e4. If sound is enabled ([0x18aaa]) and al<0, it clears the state byte of the 4 sample voices (0x1abb8.., stride 0x40) only. Priority and owner fields are kept, and the music voices and other sound devices are not touched. No operand. Port: offsound() runs channel_off(0..3): type None, curson=-0x80, pere=0, and for channels <3 io_canal. So it also stops PSG ding/noise/explode channels and channel 3, which carries the FLI speech while a film plays. For Robinson DOS the audible result is the same: all SFX stop. The only possible difference is a cdelsound during a film cutting the film's speech in the port.",  "fix": "Optional: in offsound, leave channel 3 alone while audio_film_playing() is true." }, {  "table": "opcodes",  "index": "a2",  "name": "cwmov",  "original_addr": "0x5ebd",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:11 (get_vector fn/opcodes_a.php:550)",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: call 0x7176 (get_vector: one E = form index; form address via 0x7139 = script+[+0xe]+[+6]+word[2*idx]), then add ax\u2192[ebp+0](wcx), bx\u2192[ebp+8](wcy), cx\u2192[ebp+0x10](wcz); registers preserved. get_vector by form type: type 0 gives ax=s8(+4)+s8(+7)>>1, bx=s8(+5)+s8(+8)>>1, cx=s8(+6)+s8(+9)>>1, with SIGNED bytes (cbw). Type 1 gives ax=[+4]+[+a]>>1, bx=[+6]+[+c]>>1, cx=[+8]+[+e]>>1. Type >=2 gives ax=[+2], bx=[+4], cx=[+6]. A negative type calls the error routine 0x144a0 (code 0x14). ax is negated when byte [ebp-0x2e]>=0x15 and xinv!=0. Port (copied from the C): reads x=+4.., z=+5.., y=+6.. and adds y to WCY(+8) and z to WCZ(+0x10). So the second and third components are SWAPPED compared with DOS: DOS adds form +5 (type 0), +6 (type 1) or +4 (type >=2) to [vram+8], the port adds +6, +8 or +6. Type-0 bytes are read unsigned (xread8) instead of sign-extended. The same get_vector is used by cwlive (0x3c, not used by Robinson either).",  "fix": "In get_vector (fn/opcodes_a.php:550-582), put the 2nd component (+5/+6/+4) in $y and the 3rd (+6/+8/+6) in $z, and read type-0 bytes as s8(xread8(...)) with arithmetic >>1. Do it only for PC v3 if other platforms really differ." }, {  "table": "opcodes",  "index": "a3",  "name": "cwtstmov",  "original_addr": "0x7248",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:28",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original: [0x1602e]=xinv byte [ebp-3]. Then get_vector (1 E) plus [ebp+0]/[ebp+8]/[ebp+0x10] go into wcx/wcy/wcz globals [0x16028]/[0x1602a]/[0x1602c]. Then E \u2192 matmask [0x16032]; wforme [0x16030] = the script's cforme word [ebp-0x1a]. Then call 0x7631 (clipform) and jmp 0x7610 (crstent: stores the first found entity into ONE store target S). Operands: E E S. Port: empty body that reads nothing, so any use would desync the script. Lang/Grammar.php:62 also gives it no operands (''), so the decompiler would desync too.",  "fix": "Implement: `get_vector($x,$y,$z); Alis::$wcx = s16(xread16(vram+WCX)+$x); wcy = s16(xread16(vram+8)+$y); wcz = s16(xread16(vram+0x10)+$z); readexec_opername(); Alis::$matmask = s16(varD7); Alis::$wforme = get_0x1a_cforme(vram); clipform(); crstent();` (like ctstmov, but the vector comes from a form). Grammar operands: 'E E S'." }, {  "table": "opcodes",  "index": "a4",  "name": "cwftstmov",  "original_addr": "0x729a",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:34",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original: same as cwtstmov, except that after matmask a second E is read into wforme [0x16030] (instead of the script's cforme), then clipform 0x7631 and crstent 0x7610 (one store target S). Operands: E E E S. Port: empty body that consumes nothing. Grammar has ''.",  "fix": "Implement like cwtstmov, but with `readexec_opername(); Alis::$wforme = s16(varD7);` after matmask. Grammar operands: 'E E E S'." }, {  "table": "opcodes",  "index": "a5",  "name": "ctstform",  "original_addr": "0x72ed",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:40",  "status": "same",  "severity": "none",  "used_by_game": "1",  "details": "Original: [0x1602e]=xinv. wcx/wcy/wcz = words [ebp+0]/[ebp+8]/[ebp+0x10]. E \u2192 matmask [0x16032], E \u2192 wforme [0x16030]. clipform 0x7631, then crstent 0x7610 (one store target). Port: wcx/wcy/wcz read from vram+0/+8/+0x10, matmask, wforme, clipform(), crstent(). The port's clipform reads xinv from the script vram itself, which matches [0x1602e]. Same operands (E E S), same effects.",  "fix": "" }, {  "table": "opcodes",  "index": "a6",  "name": "cxput",  "original_addr": "0x53e9",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:54",  "status": "same",  "severity": "none",  "used_by_game": "3",  "details": "Original: flagmain [0x15fc7]=0; invert [0x15fc4] = low byte of (word [ebp-3] xor 1), i.e. xinv^1. Then 0x5371: E=index; depx/depy/depz [0x15fb2/4/6]=0; numelem [0x15fbe]=0; put 0x5479. Port: flagmain=0, invert_x=(xinv^1)&0xff, one E, dep=0, numelem=0, put(idx&0xffff). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "a7",  "name": "cxputat",  "original_addr": "0x5404",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:69",  "status": "same",  "severity": "low",  "used_by_game": "12",  "details": "Original: flagmain=0, invert=xinv^1. Then 0x53af: E\u2192depx, E\u2192depy, E\u2192depz (words). E4=index (dx). E5 evaluated by 0x9d17 into cx and stored as a WORD in numelem [0x15fbe]. put. Port: same order and operands. The only difference: numelem = s8(varD6) (8-bit sign-extended) where the original keeps 16 bits. Robinson passes 0..5, so nothing changes.",  "fix": "Optional: Img::$numelem = s16(Alis::$varD6)." }, {  "table": "opcodes",  "index": "a8",  "name": "cmput",  "original_addr": "0x541c",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:88",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: flagmain=1, invert=xinv (no xor), then 0x5371 (E index, dep=0, numelem=0, put). Port: flagmain=1, invert_x=xinv, same. Identical.",  "fix": "" }, {  "table": "opcodes",  "index": "a9",  "name": "cmputat",  "original_addr": "0x5431",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:102",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: flagmain=1, invert=xinv, then 0x53af (5 E: depx, depy, depz, index, numelem as a 16-bit word). Port: same. numelem is s8 instead of 16-bit, as in cxputat.",  "fix": "" }, {  "table": "opcodes",  "index": "aa",  "name": "cmxput",  "original_addr": "0x5460",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:119",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: flagmain=1; al=byte [ebp-3]; `xor bx,1` works on BX, not AL, and AL (the plain xinv) is stored in [0x15fc4]. This is a bug of the original: cmxput behaves exactly like cmput (no extra mirror). Then 0x5371 (E index, dep=0, numelem=0, put). Port: invert_x = (xinv^1)&0xff, so the sprite is mirrored compared with the DOS original.",  "fix": "For PC (DOS) v3, use `Img::$invert_x = get_0x03_xinv(vram)` (no ^1) in cmxput to match the original. Robinson never uses it." }, {  "table": "opcodes",  "index": "ab",  "name": "cmxputat",  "original_addr": "0x5446",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:132",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: flagmain=1; bl=xinv, xor bx,1, store bl, so invert=xinv^1. Then 0x53af (5 E). Port: flagmain=1, invert_x=(xinv^1)&0xff, 5 E, put. Same (numelem is s8 instead of 16-bit).",  "fix": "" }, {  "table": "opcodes",  "index": "ac",  "name": "cmmusic",  "original_addr": "0x9508",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:149 (music() fn/opcodes_a.php:3494)",  "status": "platform",  "severity": "low",  "used_by_game": "0",  "details": "Original: flagmain=1, then the cmusic body 0x9518. E=index, address via 0x9484 (main's resources). If type byte not in {0,3,4}: evaluates 5 more E and returns. Otherwise [0x160a8]=addr+6; E\u2192[0x160a3] byte (volume); E\u2192[0x160a1] byte (tempo); E\u2192[0x160ac], E\u2192[0x160b0], E\u2192[0x160ae] words (raw attack/duration/fall); call 0x10a14 (DOS music start, needs [0x1609e]). Port: flagmain=1, music(): same 6 E and same accepted types (0/3 \u2192 mv1, 4 \u2192 mv2, else 5 E skipped). The values are converted for the port's own music drivers (maxvolume<<8, attac+1...). That is the host music layer, not a byte-for-byte copy. Stream consumption is identical.",  "fix": "" }, {  "table": "opcodes",  "index": "ad",  "name": "cmforme",  "original_addr": "0x7163",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:164",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: E, then with ebp=[0x15fa0] (the MAIN script's vram) it writes word [main-0x1a]=dx. It sets the MAIN script's current form (the 'm' prefix = main, like cmput/cmsound). Port: set_0x1a_cforme(Alis::$script->vram_org, varD7) writes the CURRENT script's cforme. It behaves like cforme (0x51), not like the original.",  "fix": "In cmforme: set_0x1a_cforme(Alis::$main->vram_org, Alis::$varD7 & 0xffff)." }, {  "table": "opcodes",  "index": "ae",  "name": "csettime",  "original_addr": "0x4037",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:171",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: 3 E (h, m, s) evaluated, then call 0x2965, which is a bare `ret`: no effect on DOS. Port: 3 E, then sys_set_time() (fn/sys.php:80, empty). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "af",  "name": "cgettime",  "original_addr": "0x405f",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:183",  "status": "differs",  "severity": "none",  "used_by_game": "0",  "details": "Original: call 0x2966 (a bare `ret`, no clock read). Then push bx, push cx; dx=ax \u2192 store (0x3bd1); pop \u2192 cx \u2192 store; pop \u2192 bx \u2192 store. Three store targets get whatever is left in the registers: ax=0x00af (the main loop leaves the opcode byte in eax) and the cx/bx left by the previous code. Port: stores 0, 0, and (sys_get_time()<<0)&0xff = 0. Both consume 3 store targets. Only the garbage values differ, and the game never uses this opcode.",  "fix": "" }, {  "table": "opcodes",  "index": "0xb0",  "name": "cvinput",  "original_addr": "0x3d33",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:262",  "status": "same",  "severity": "low",  "used_by_game": "8 (vinput vw[0x60] x7, vinput vb[0x3ca6] x1)",  "details": "Original: [0x15f48] (charmode) = 0, then 0x3d8a getval. It reads keys with 0x3dde, which loops on 0x2485 (waits for a press and then the release, and skips key codes with bit 7 set). It accepts only '-' and '0'..'9' (0x3d9d-0x3da7), handles BS (0x3dbd: echoes BS, space, BS) and stops on CR. It writes into the buffer at [0x16008], converts it with 0x3d4b strtoval and stores it with 0x3bd1 cstore-continue. Port: charmode=0, getval() (opcodes_b.php:201) with the same filter `c=='-' || 0x30<=c<=0x39`, the same BS echo, oval() and cstore_continue(). Key fetching does not block (yield/retry), which is platform glue. The script stays in sync and the effect is the same. One small gap: keys >= 0x80 are ignored by the original and dropped by the port's filter anyway.",  "fix": "" }, {  "table": "opcodes",  "index": "0xb1",  "name": "csinput",  "original_addr": "0x3d1f",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:304",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: charmode=0, then 0x3d47 getstring. It stores every key whose code is >= 0 as a signed byte (0x3dde loops while al<0, so bytes 0x80-0xff are never taken), handles BS (the original's BS when the buffer is empty: nothing), ends on CR with a NUL, then 0x3bd1 cstore-continue. Port getstring() (opcodes_b.php:269) stores every key returned by input_nextkey(), which is io_inkey()&0xff, so a key code >= 0x80 (accented host keys) would be stored and echoed where the original drops it. The rest is the same.",  "fix": "In getstring(), skip keys with c >= 0x80 (continue the loop without storing or echoing them), as the original's 0x3dde does." }, {  "table": "opcodes",  "index": "0xb2",  "name": "casleepfar",  "original_addr": "0x8437",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:330",  "status": "differs",  "severity": "low",  "used_by_game": "2 (heros.als: asleepfar 1120)",  "details": "Original: val=expr; [0x16036] = val*val (16x16 unsigned mul, 32-bit). It walks the atent list from offset 0 (next = [atent+ecx+4]) and skips an entity when bit 2 of dword [vram-0x24] is set. Each difference is computed in 16 bits (sub ax,[ebp+..], so it wraps) and squared with imul ax (signed 16x16->32). The 32-bit sum is compared unsigned (jnc) with [0x16036]. Inside: if [vram-4]==0, set it to 1 and send 0x8001. Outside: if it is !=0, set it to 0 and send 0x8000. 0x86f3 sendmess is the same as the port's. Two differences: (1) the second message is `mov dx,[es:edi-0xe]` (0x84ce / 0x84f6), with EDI = the TARGET entity's vram, so the original sends the target's own [vram-0xe] script_ent. The port (opcodes_b.php:351 and 358) sends get_0x0e_script_ent(Alis::$script->vram_org), the CALLER's entity number (this is what the C does too). (2) The port does not wrap the differences to 16 bits (xread16 is signed, so xdif can reach \u00b165535) before mul32, so the result differs when two coordinates are more than 32767 apart. Impact: the Robinson receivers (bison.als:16 etc.) test vw==-32768/-32767 and scanclr, so the second word is discarded. Low.",  "fix": "In casleepfar(), pass get_0x0e_script_ent($vram) (the target) as the second sendmess argument in both branches. Wrap the differences with s16() before multiplying: $xdif = s16(xread16($vram) - xread16(org)), and the same for ydif and zdif." }, {  "table": "opcodes",  "index": "0xb3",  "name": "casleepon",  "original_addr": "0x8506",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:367",  "status": "same",  "severity": "none",  "used_by_game": "26",  "details": "Original: btr dword [es:ebp-0x24],2 clears bit 2 of the current entity's 0x24 flags byte (low byte, little endian). Port: set_0x24_scan_inter(org, get & 0xfb). Same. No operands.",  "fix": "" }, {  "table": "opcodes",  "index": "0xb4",  "name": "casleepoff",  "original_addr": "0x850d",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:373",  "status": "same",  "severity": "none",  "used_by_game": "52",  "details": "Original: bts dword [es:ebp-0x24],2. Port: |4 on the byte at vram-0x24. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0xb5",  "name": "crunfilm",  "original_addr": "0x8ed0",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:379",  "status": "same",  "severity": "none",  "used_by_game": "5 (runfilm 1, vw/mw[0x3ce2], vw/mw[0x3ce4])",  "details": "Original: 0x9cfc evaluates one expression. Film struct at 0x17944: [+0x46] = value (batchframes), call 0x13da8 runfilm, then cstore-continue (0x3bd1) of word [+0x4] (frame) and cstore-continue of word [+0x44] (result). Port: batchframes=s16(D7) (set once across its yield/restart), runfilm(), stores bfilm->frame then bfilm->result. Same operands and order. The film player itself (0x13da8) is outside this entry.",  "fix": "" }, {  "table": "opcodes",  "index": "0xb6",  "name": "cvpicprint",  "original_addr": "0x3dfa",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:419",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: [0x15f48]=1, evaluates one expression, 0x3e76 -> 0x3f82 valtostr + putchar per character. Putchar 0x3ecf with charmode 1 returns at once (0x3ef1 ret), so it prints nothing on DOS. Port: charmode=1, putval(), and put_char() does nothing for charmode 1 (image.php:1480). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0xb7",  "name": "cspicprint",  "original_addr": "0x3de8",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:427",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: charmode=1, 0x9d37 (swaps the string buffers 0x16008/0x1600c and evaluates a string expression), 0x3e69 -> 0x400a prints the string at [0x16008] through 0x3ecf (a no-op in mode 1). Port: charmode=1, readexec_opername_swap(), put_string(). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0xb8",  "name": "cvputprint",  "original_addr": "0x3e1e",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:435",  "status": "same",  "severity": "none",  "used_by_game": "349",  "details": "Original: charmode=2, one expression, 0x3fa0 converts it as a signed 16-bit value (sign, 5 powers 10000..1, leading zeros dropped, '0' kept for the last digit), then putchar for each character. Port: putval(s16(D7)) -> valtostr (10 powers, the same output for 16-bit values, -32768 included) -> put_char. Same. The differences inside put_char are reported under cfont (0xba).",  "fix": "" }, {  "table": "opcodes",  "index": "0xb9",  "name": "csputprint",  "original_addr": "0x3e0c",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:450",  "status": "same",  "severity": "none",  "used_by_game": "932",  "details": "Original: charmode=2, 0x9d37 string expression, 0x400a prints each byte until NUL through 0x3ecf. Port: charmode=2, readexec_opername_swap(), put_string(). Same operands and order. Character drawing: see 0xba.",  "fix": "" }, {  "table": "opcodes",  "index": "0xba",  "name": "cfont",  "original_addr": "0x3c64",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:465",  "status": "differs",  "severity": "high",  "used_by_game": "93 (font -16,0,0,0,0 x11 and font -16,4,0,0,0 x4 in baratin/baratind/baratine/baratinu/playfilm, plus normal fonts)",  "details": "Original (0x3c64-0x3cee): word [0x15f36]=1, then a=expr. If a>=0: foasc[0x15f40]=a, fonum[0x15f38]=b, folarg[0x15f3a]=(u8)c, fohaut[0x15f3c]=(u8)d, fomax[0x15f3e]=e (the port does this too). If a==-16 (0x3cae): only byte [0x15f42] = (u8)b, the TEXT COLOUR; c, d and e are read and thrown away, and foasc/fonum/folarg/fohaut/fomax are KEPT. If a<0 and a!=-16: [0x15f36]=a, foasc=0xffff, fonum=0, b is read and thrown away, then folarg=c, fohaut=d, fomax=e. The colour is used in putchar 0x3ecf (mode 2): it sets [0x15f43]=1 around the put (0x3f3e). In the put at 0x5627-0x5643, when [0x15f43] and [0x15f42]!=0, sprite word +0x26 = 0x8000|colour. The blitter at 0x1292d/0x12a76 then sees byte +0x27==0x80 and draws every non-zero glyph pixel in colour byte +0x26. Port: no special case. `font -16,4,0,0,0` gives foasc=0xfff0, fonum=4, folarg=0, fohaut=0, fomax=0, so every following character fails the s16(charidx - fomax) < 0 test and the cursor does not move. The highlighted subtitle line in baratin*.als (lines ~1152-1158: numput / sputprint after font -16,4) is INVISIBLE in the port where the original draws it in colour 4. `font -16,0,...` (playfilm.als:112, 171, 732; baratin end) also wipes the font in the port, so text printed later without a fresh `font` disappears. The colour feature does not exist at all (no global, no tint in put_char or putmapin, no recolour in the renderer). Smaller differences: the port stores fonum as &0xffff, so the `Alis::$fonum < 0` test (image.php:1499) can never be true, where the original's `cmp word [0x15f38],0; js` is signed. put_char uses s8(character) where the original uses the unsigned byte (0x3f0b: dl=al, dh=0), so characters >= 0x80 are never drawn by the port (no effect with Robinson's fonts, foasc 32 / fomax 65).",  "fix": "In cfont() (opcodes_b.php:465): $a = s16(D7). If $a == -16: read b and put Alis::$focolor = b & 0xff (new global, default 0, saved in states), read and throw away 3 more operands, return. If $a < 0: foasc=0xffff, fonum=0, read b and throw it away, then folarg/fohaut/fomax from c/d/e. Otherwise do as now, but store fonum signed (s16). In put_char (image.php:1480), use $charidx = s16(($character & 0xff) - foasc), and set a flag (like 0x15f43) around put(). In putmapin (image.php ~1418), when that flag is set and focolor != 0, set the high word of the sprite's u32 at +0x24 (sprite_0x28 >> 16 on LE) to 0x8000|focolor. In the DOS sprite blitter, when that byte +0x27 == 0x80, draw every non-zero source pixel in colour byte +0x26 (original 0x12974-0x129b4)." }, {  "table": "opcodes",  "index": "0xbb",  "name": "cpaper",  "original_addr": "0x9856",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:480",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: one expression, byte [0x15f35] = (u8)value. Nothing else in the image reads [0x15f35] by direct address (grep of the whole disassembly), so its effect is a no-op. Port: reads the operand and does nothing. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0xbc",  "name": "ctoblack",  "original_addr": "0x8d32",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:488",  "status": "platform",  "severity": "low",  "used_by_game": "5 (toblack 10/20/30)",  "details": "Original: 0x9d17 reads one operand (CX=dur). Step [0x16084]=1. If dur!=0 and dur<63 (signed): step = 63/cl + 1 (8-bit div), [0x16081]=cl, [0x16082]=[0x16083]=1. Else [0x16081]=0x3f, [0x16082]=[0x16083]=dur/63 (8-bit div, no +1, no 127 cap; #DE when the quotient is >255). Then the target palette 0x1682f is set to zero. If the CPU benchmark word [0x16064] (computed at 0x1ec6) is <=200, or dur==0: instant (counters reset, live palette 0x1622f zeroed). Then lock [0x1607f]=1, 0x13989 (chase), ftopal [0x1607e]=1, lock=0, skip [0x15f9e]=0. Port dos_ctoblack (image.php:647) with dpal_steps(dur,0): the same step/counter values for the game's durations (10/20/30 < 63), the same zeroing, chase, ftopal=1, skip=0. Differences: the slow-machine instant path ([0x16064]<=200) is a platform benchmark (the port acts as a fast PC). The q>127 cap only matters for durations >= 8064, where the original itself would fault.",  "fix": "" }, {  "table": "opcodes",  "index": "0xbd",  "name": "cmovcolor",  "original_addr": "0x8be8",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:529",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: reads 2 expressions (0x9d24, 0x9d17) and does nothing else. Port: reads 2 operands; its palette code only runs when bpp==4 (Atari ST), which DOS VGA (8 bpp) is not, so it is a no-op too. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0xbe",  "name": "ctopalet",  "original_addr": "0x8bf3",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:566",  "status": "same",  "severity": "none",  "used_by_game": "4 (topalet 0,30 / 1,30 / 6,50)",  "details": "Original: flagmain [0x15fc7]=0, reads idx and dur (DX=idx, CX=dur). If skip [0x15f9e]==0: if idx<0 and idx>=-2, 0x8c3d restores sav1 (idx==-1, 0x16b6f) or sav2 (0x16e6f), fading. If idx>=0: 0x5c01 resolves the resource; when its first byte is 0xfe, 0x8988 topalette(dur) (steps 63/cl+1 for dur<63, else dur/63+1, then the same <=200 benchmark instant path). Then skip=0. Port: flagmain=0, dos_ctopalet() (image.php:626) for the B32 family: the same skip test, the same -2..-1 range (dpal_ctopalsav), the same 0xfe check, dpal_topalette with inc=1, skip=0. Same (benchmark path: platform).",  "fix": "" }, {  "table": "opcodes",  "index": "0xbf",  "name": "cnumput",  "original_addr": "0x3cef",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:590",  "status": "same",  "severity": "none",  "used_by_game": "477",  "details": "Original: depx [0x15fb2]=e1, depy [0x15fb4]=e2, depz [0x15fb6]=e3 (words), numelem byte [0x15fbe]=(u8)e4. Port: Img::$depx/depy/depz = s16, numelem = s8. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0xc0",  "name": "cscheart",  "original_addr": "0x4665",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:608",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: reads 2 operands first. If word [ebp-0x16]!=0: scr=basemain+(signed)id, [scr+0xa]=a, [scr+0xc]=b, [scr]|=0x80. Port: the same reads, set_scr_unknown0x0a / 0x0c, state|=0x80. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0xc1",  "name": "cscpos",  "original_addr": "0x46c4",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:634",  "status": "differs",  "severity": "low",  "used_by_game": "2 (main.als:2958, 2963, each followed at once by scsize)",  "details": "Original: reads 2 operands. If the screen exists: [scr+0xe]=x, [scr+0x10]=y, CALLS 0x46f4 (updates the screen's sprite: +0xc=x&0xfff0, +0xe=y, dword +0x10=0x7fff, +0x16=(x+w)|0xf, +0x18=y+h), then [scr]|=0x80. Port (v<60 path): stores newx/newy and state|=0x80 but does NOT call scdosprite(), so the screen's sprite keeps its old position until the next cscsize/copensc. No visible effect in Robinson because scpos is always followed by scsize, which calls scdosprite.",  "fix": "In cscpos() for version 20-59 (v>=30), call scdosprite($screen_id) after set_scr_newy and before setting the state bit, as 0x46ea does." }, {  "table": "opcodes",  "index": "0xc2",  "name": "cscsize",  "original_addr": "0x4690",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:673",  "status": "differs",  "severity": "low",  "used_by_game": "2 (scsize 160,78 / 256,126)",  "details": "Original: reads 2 operands. If the screen exists: [scr+0x12]=w-1, [scr+0x14]=h-1, 0x46f4, [scr]|=0x80. Port (v>=30): the same stores and scdosprite(). But port scdosprite (screen.php:59) differs from 0x46f4 for v3: the original aligns newx = x & 0xfff0 and depx = (x+w) | 0xf for every version, the port only does it for v10 (screen.php:76-82). The port also writes sprite->numelem (0x46f4 does not), and the original's dword write of 0x7fff at +0x10 also sets the word at +0x12 to zero. With Robinson's values (x=48 or 0, x+w=207 or 255) the alignment changes nothing.",  "fix": "In scdosprite() for DOS v3 (or all versions, to match 0x46f4), use newx = x & 0xfff0 and depx = (x+w) | 0xf, and do not write numelem." }, {  "table": "opcodes",  "index": "0xc3",  "name": "cschoriz",  "original_addr": "0x4740",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:720",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: tests word [ebp-0x16] FIRST. When it is 0, no operand is read. Otherwise it reads 3 operands: byte [scr+0x20]=e1, +0x21=e2, +0x22=e3, then [scr]|=0x80. Port: the same order, including the conditional operand read.",  "fix": "" }, {  "table": "opcodes",  "index": "0xc4",  "name": "cscvertic",  "original_addr": "0x477b",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:735",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: if the screen exists, reads 3 operands into bytes +0x23, +0x24, +0x25, then CALLS 0x52fd: the cross product of the horizontal vector (0x20-0x22) and the vertical vector (0x23-0x25) with signed 8-bit imul. Word [scr+0x26] = h1*v2 - v1*h2, word [scr+0x27] = h2*v0 - v2*h0, word [scr+0x28] = h0*v1 - v0*h1 (the writes overlap, so in the end bytes 0x26 and 0x27 hold the low bytes of the first two terms and 0x28-0x29 the third word). Then [scr]|=0x80. Port: stores the 3 bytes and the state but never computes the normal at 0x26-0x29.",  "fix": "After the three stores in cscvertic() (v3 path), compute $h=[0x20,0x21,0x22], $v=[0x23,0x24,0x25] as s8 values and write xwrite16(scr+0x26, h1*v2-v1*h2); xwrite16(scr+0x27, h2*v0-v2*h0); xwrite16(scr+0x28, h0*v1-v0*h1) in this order (original 0x52fd)." }, {  "table": "opcodes",  "index": "0xc5",  "name": "cscreduce",  "original_addr": "0x4840",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:754",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: reads 2 operands (DX=a, CX=b). If the screen exists: byte +0x1d=a, +0x1e=b-1, then reads a 3rd operand into +0x1f, then [scr]|=0x80. When the screen id is 0, the 3rd operand is NOT read. Port: set_scr_creducing (+0x1d)=a, reads the 3rd, redmax (+0x1e)=(b-1)&0xff, redshift (+0x1f)=c, state|=0x80. The same values and the same conditional read.",  "fix": "" }, {  "table": "opernames",  "index": "2b (code 0x56)",  "name": "oadd",  "original_addr": "0xa2f0",  "port_location": "games/alis/src/Alis/fn/opernames.php:518",  "status": "same",  "severity": "none",  "used_by_game": "thousands (binary '+' everywhere, incl. '+ pile()')",  "details": "Original: call 0x9d2a (CX=DX, read the next operand into DX), add dx,cx (16-bit). Port: d6=d7, readexec, d7=s32(d7+d6); readexec_opername() (alis.php:148) truncates d7 to s16 after every element for version<60, so the 16-bit wrap matches.",  "fix": "" }, {  "table": "opernames",  "index": "2c (code 0x58)",  "name": "osub",  "original_addr": "0xa2f9",  "port_location": "games/alis/src/Alis/fn/opernames.php:526",  "status": "same",  "severity": "none",  "used_by_game": "~544 (' - ')",  "details": "Original: cx = cx - dx (left - right), dx = cx. Port: d6 = d6 - d7, d7 = d6. Same, 16-bit by the s16 truncation of readexec_opername.",  "fix": "" }, {  "table": "opernames",  "index": "2d (code 0x5a)",  "name": "omod",  "original_addr": "0xa305",  "port_location": "games/alis/src/Alis/fn/opernames.php:535",  "status": "same",  "severity": "none",  "used_by_game": "~44 (' % ')",  "details": "Original: ax=left, cx=right, cwd, divisor 0 -> 1, idiv cx, DX = remainder (sign of the dividend). x % 0 therefore = x % 1 = 0. Port pre-v6: cmod() returns 0 for divisor 0 and PHP % uses the dividend's sign, so it matches. (The -32768 % -1 #DE fault of the original is not reproduced: that does not matter.)",  "fix": "" }, {  "table": "opernames",  "index": "2e (code 0x5c)",  "name": "odiv",  "original_addr": "0xa31f",  "port_location": "games/alis/src/Alis/fn/opernames.php:549",  "status": "differs",  "severity": "medium",  "used_by_game": "~307 (' / ')",  "details": "Original 0xa31f: ax=left, cx=right; if cx==0 then cx=1 (0xa32c-0xa331), idiv cx, dx=quotient. So x/0 = x. Port: the divisor 0 -> 1 substitution only runs for version>=60; for Robinson (v31) cdiv() (runtime.php:128) returns 0 on a zero divisor. The result differs: x/0 gives 0 in the port and x in the original. (A truncated quotient that rounds toward zero, as idiv does, is the same.)",  "fix": "In odiv(), replace the divisor 0 by 1 for every version (at least for the DOS v3 games): `if (Alis::$varD7 == 0) Alis::$varD7 = 1;` before cdiv. Do the same in omod for consistency (the result there is 0 either way)." }, {  "table": "opernames",  "index": "2f (code 0x5e)",  "name": "omul",  "original_addr": "0xa33c",  "port_location": "games/alis/src/Alis/fn/opernames.php:563",  "status": "same",  "severity": "none",  "used_by_game": "~342 (' * ')",  "details": "Original: imul cx (16x16), DX = low word. Port: mul32 and then the s16 truncation give the same low 16 bits.",  "fix": "" }, {  "table": "opernames",  "index": "30 (code 0x60)",  "name": "oneg",  "original_addr": "0xa34b",  "port_location": "games/alis/src/Alis/fn/opernames.php:570",  "status": "same",  "severity": "none",  "used_by_game": "40",  "details": "neg dx. Port s32(-d7), then s16 (-(-32768) = -32768 in both).",  "fix": "" }, {  "table": "opernames",  "index": "31 (code 0x62)",  "name": "oabs",  "original_addr": "0xa34f",  "port_location": "games/alis/src/Alis/fn/opernames.php:576",  "status": "same",  "severity": "none",  "used_by_game": "75",  "details": "test dx; neg when negative. Same, -32768 stays -32768.",  "fix": "" }, {  "table": "opernames",  "index": "32 (code 0x64)",  "name": "ornd",  "original_addr": "0xa358 (LCG 0xa36d)",  "port_location": "games/alis/src/Alis/fn/opernames.php:584",  "status": "same",  "severity": "none",  "used_by_game": "360",  "details": "Original: seed [0x15ffc] = seed*0x7ab7 + 0xf881 (16-bit), then mul dx (unsigned 16x16), DX = high word, i.e. a value in [0, (u16)d7). Port: random_number = (r*0x7ab7 - 0x77f) & 0xffff (= +0xf881), then the high 16 bits of (d7&0xffff)*r. Identical. (The initial seed is 0 in the image; crandom 0x3ebb keeps 0 when d7=0, while the port's crandom uses sys_random(): that belongs to the opcode, outside this share.)",  "fix": "" }, {  "table": "opernames",  "index": "33 (code 0x66)",  "name": "osgn",  "original_addr": "0xa37d",  "port_location": "games/alis/src/Alis/fn/opernames.php:593",  "status": "same",  "severity": "none",  "used_by_game": "10",  "details": "0 -> 0, negative -> -1, positive -> 1. Same.",  "fix": "" }, {  "table": "opernames",  "index": "34 (code 0x68)",  "name": "onot",  "original_addr": "0xa38e",  "port_location": "games/alis/src/Alis/fn/opernames.php:603",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "not dx. Port ~d7, then s16. Same.",  "fix": "" }, {  "table": "opernames",  "index": "35 (code 0x6a)",  "name": "oinkey",  "original_addr": "0xa39f -> 0x246c",  "port_location": "games/alis/src/Alis/fn/opernames.php:609 (io_inkey sys.php:386)",  "status": "platform",  "severity": "low",  "used_by_game": "130",  "details": "Original: dx = zero-extended byte [0x18b68] = the ALIS code of the key currently held, set by the keyboard IRQ through the translation table at 0x18d10, cleared or replaced on release at 0x23af. It is not consumed. Port: io_inkey() returns the held key mapped to the same ALIS codes (0x1b, 0xc8...); automode replay is specific to the port. Equivalent through the host layer.",  "fix": "" }, {  "table": "opernames",  "index": "36 (code 0x6c)",  "name": "okeyon",  "original_addr": "0xa3b9",  "port_location": "games/alis/src/Alis/fn/opernames.php:621",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original 0xa3b9 is a bare `ret` (the bytes before it, 0xa3ac-0xa3b8, are the keypad string '789-456+1230.'): it reads no operand and leaves DX unchanged. The port's okeyon() is empty: same.",  "fix": "" }, {  "table": "opernames",  "index": "37 (code 0x6e)",  "name": "ojoy",  "original_addr": "0xa3d2 -> 0x253f",  "port_location": "games/alis/src/Alis/fn/opernames.php:626 (io_joy sys.php:586)",  "status": "platform",  "severity": "low",  "used_by_game": "5 (main.als: joy(..., 0) > 127 to skip the intro)",  "details": "Original: dl = d7. It returns 0 when [0x16066]!=0, when dl!=0 (only joystick 0 exists) or when no joystick was detected ([0x18aa0]==0). Otherwise it returns analog-port bits: bit0 = Y < centre/2, bit1 = Y >= 2*centre, bit2/bit3 = the same for X, bit7 = button (port 0x201 bits 0x30), zero-extended. Port: io_joy(0) returns SysVars::$joystick1 = gamepad + arrow/keypad keys + mouse left button as bit7. io_joy(n!=0) returns joystick0 instead of 0. So in the port a mouse click or an arrow key also counts as 'joystick', where on a DOS machine without a joystick the result is always 0.",  "fix": "Optional: make io_joy() return 0 for port != 0. Keep the keyboard/mouse mix only if that is the intended choice of the host (it lets a click skip main.als's intro loops, which DOS without a joystick does not allow)." }, {  "table": "opernames",  "index": "38 (code 0x70)",  "name": "oprnd",  "original_addr": "0xa3e2",  "port_location": "games/alis/src/Alis/fn/opernames.php:634",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: pops a 16-bit word from the expression stack (ebx), ror ax,6 (16-bit rotate), seed' = ax*0x7ab7+0xf881 (not stored back), dx = high word of seed'*dx (unsigned). Port: pops a 32-bit cell and computes (shl32(r,10)|shr32(r,6)) & 0xffff. When the pushed value is negative (opushacc stores the s16 sign-extended: 0xFFFFxxxx), shr32 brings sign bits 16..21 into bits 10..15, which are ORed with the rotated low bits. The rotation is wrong for negative seeds. Everything else (LCG, high word) is the same.",  "fix": "Mask before the rotate: `$result = hread32(Alis::$acc) & 0xffff;` then `$result = (($result << 10) | ($result >> 6)) & 0xffff;`." }, {  "table": "opernames",  "index": "39 (code 0x72)",  "name": "oscan",  "original_addr": "0x873c",  "port_location": "games/alis/src/Alis/fn/opernames.php:645",  "status": "same",  "severity": "none",  "used_by_game": "70",  "details": "Original: when [ebp-0x1e]==[ebp-0x1c] the result is -1. Otherwise dx = word [ebp+rd]; rd += 2; if rd >= -0x3e (signed) then rd -= word [[ebp-0x14]+0x16]; store rd; when rd == wr, clear bit 7 of byte [ebp-0x24]. Port: the same, limit -0x3f for version>=30 (`-0x3f < new` is the same as `new >= -0x3e`), the same header field 0x16 and the same bit-7 clear.",  "fix": "" }, {  "table": "opernames",  "index": "3a (code 0x74)",  "name": "oshiftkey",  "original_addr": "0xa3ba -> 0x247c",  "port_location": "games/alis/src/Alis/fn/opernames.php:671 (io_shiftkey sys.php:474)",  "status": "platform",  "severity": "low",  "used_by_game": "21",  "details": "Original: dx = zero-extended byte [0x18b6a]. The IRQ sets its bits from the translation codes: 0xe1 -> bit0, 0xe0 -> bit1, 0xe2 -> bit2 (Ctrl), 0xe3 -> bit3 (Alt). Port: the same bit layout from SDL, but either Shift sets bits 0 and 1 together (a deliberate choice, commented in the code), and 0 in automode.",  "fix": "" }, {  "table": "opernames",  "index": "3b (code 0x76)",  "name": "ofree",  "original_addr": "0xa3fa -> 0x2967",  "port_location": "games/alis/src/Alis/fn/opernames.php:685 (the v>20 branch, lines ~713-737)",  "status": "differs",  "severity": "low",  "used_by_game": "15 (free(0), free(1), free(4) only)",  "details": "Original 0x2967: 0 -> ([0x15f26]-[0x15f66])/1000; 1 -> ([0x15f84]-[0x15f7a])/1000; 2 -> [0x15f6a]-[0x15f6c]; 3 -> [0x15f7e]-[0x15f80]; 4 -> length of the list at [0x15f8c] from [0x15f90]; 'a'/'A','b'/'B','c'/'C','d'/'D' -> free disk space (int21 AH=36h, /1000, capped at 0x7d00); EVERY other value -> -1. Port (version>20 branch): 0..4 equivalent. 0x41..0x48 and 0x61..0x68 -> io_dfree(), so 'E'..'H' differ. Any other value > 0x40 leaves d7 UNCHANGED instead of -1. The values the game uses (0, 1, 4) are not affected.",  "fix": "For version 30..59 (DOS v3), accept only 0x41-0x44 and 0x61-0x64 as drives and return -1 for every other value, including the other values > 0x40." }, {  "table": "opernames",  "index": "3c (code 0x78)",  "name": "omodel",  "original_addr": "0xa400 -> 0x21fb",  "port_location": "games/alis/src/Alis/fn/opernames.php:741 (sys_get_model sys.php:117)",  "status": "differs",  "severity": "low",  "used_by_game": "22 (thresholds <1000, <2000, <3000, <4000, >=1000)",  "details": "Original: 2000 + n, where n = 4/5/6 when [0x18aae] (the setup video byte [0x1538d]) is 5/6/8, else 2000. So 2000, 2004, 2005 or 2006. Port: 2000 for PC v31, 2004 only for 11<version<30. Every threshold the scripts test gives the same branch for any value 2000..2006.",  "fix": "Optional: return 2004/2005/2006 according to the configured video mode (START.STP/OPTION) if a script ever compares model() exactly." }, {  "table": "opernames",  "index": "3d (code 0x7a)",  "name": "ogetkey",  "original_addr": "0xa3c9 -> 0x2485",  "port_location": "games/alis/src/Alis/fn/opernames.php:754 (io_getkey sys.php:458)",  "status": "platform",  "severity": "low",  "used_by_game": "4 (robinson.als:74, monstre.als:76 and the u-variants: vw[0x11c] = getkey())",  "details": "Original: if byte [0x15fc3]!=0 it quits to DOS (jmp 0x1c33). [0x15fc3] is never written by plain code, so this is in practice a busy-wait until [0x18b68]!=0, then another until every key is released. It returns the key code. Port: io_getkey() yields (vm_yield_retry restarts the opcode) until a key is pressed, returns it and clears SysVars::\\$button (no wait for the release). Equivalent without blocking. The restart is safe here because the uses are plain `vw = getkey()` with no side effect before it.",  "fix": "" }, {  "table": "opernames",  "index": "3e (code 0x7c)",  "name": "oleft",  "original_addr": "0xa409",  "port_location": "games/alis/src/Alis/fn/opernames.php:760",  "status": "same",  "severity": "none",  "used_by_game": "4 (left(spush(vs[...]) ; 8))",  "details": "Original: pop a string from the stack into [0x16008] (0xa635), then buf[dx & 0xff] = 0. Port: pop_sd7(), then sd7[d7 & 0xff] = 0. Same (the port's stack padding to an even size is internal and matches its push).",  "fix": "" }, {  "table": "opernames",  "index": "3f (code 0x7e)",  "name": "oright",  "original_addr": "0xa421",  "port_location": "games/alis/src/Alis/fn/opernames.php:767",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original: pops the string from the stack into [0x16008] (0xa635), finds its end, src = end - (signed)dx; if src <= start (unsigned) then src = start; copies src..NUL to the start of the buffer, which keeps the last dx characters. Port: empty function ('MISSING in the C'). It does not pop the string, which desyncs the expression stack (acc), and it gives no result. Harmless today because no script uses right().",  "fix": "Implement: `pop_sd7(); $s = Alis::$sd7; $end = $s + mem_strlen($s); $src = $end - s16(Alis::$varD7); if ($src <= $s) $src = $s; do { $c = Alis::$mem[$src++]; Alis::$mem[$s++] = $c; } while ($c !== \"\\0\");`" }, {  "table": "opernames",  "index": "40 (code 0x80)",  "name": "omid",  "original_addr": "0xa456",  "port_location": "games/alis/src/Alis/fn/opernames.php:773",  "status": "differs",  "severity": "low",  "used_by_game": "22 (len 1, 21 or 29)",  "details": "Original: pops a 16-bit start (movsx) and computes src = buf+start BEFORE popping the string into buf. Then dx--, and a do-while loop: copy a byte, dx--, stop on NUL, continue while dx>=0, and write the NUL when it ran out. With len <= 0 it still copies ONE character. Port: the same order and start, but a for-loop whose `d7 > -1` test comes before the first copy, so len <= 0 gives an empty string, where the original gives 1 character. When it stops on the NUL, the final d7 is off by one compared with the original DX (that value is irrelevant). The game's lengths (1, 21, 29) behave the same.",  "fix": "Make the copy a do-while (copy at least one byte) to match lengths <= 0." }, {  "table": "opernames",  "index": "41 (code 0x82)",  "name": "olen",  "original_addr": "0xa485",  "port_location": "games/alis/src/Alis/fn/opernames.php:797",  "status": "same",  "severity": "none",  "used_by_game": "23",  "details": "dx = strlen([0x16008]). Same.",  "fix": "" }, {  "table": "opernames",  "index": "42 (code 0x84)",  "name": "oasc",  "original_addr": "0xa53d",  "port_location": "games/alis/src/Alis/fn/opernames.php:803",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: sub dx,dx; mov dl,[buf]: the first byte zero-extended (0..255). Port pre-v6: s8() (signed, 'C char is signed'), so bytes >= 0x80 (accented CP850 letters) give a negative value.",  "fix": "For DOS (version 30..59, or kind PC) use xread8(Alis::$sd7) without s8." }, {  "table": "opernames",  "index": "43 (code 0x86)",  "name": "ostr",  "original_addr": "0xa54b -> 0x3fa0",  "port_location": "games/alis/src/Alis/fn/opernames.php:815 (valtostr image.php:1533)",  "status": "same",  "severity": "none",  "used_by_game": "28",  "details": "Original 0x3fa0: an optional '-' and the magnitude in 5 digits by repeated subtraction (powers table at 0x1966c), leading zeros suppressed, last digit always written, NUL. -32768 gives '-32768'. Port valtostr(s16): the same text.",  "fix": "" }, {  "table": "opernames",  "index": "44 (code 0x88)",  "name": "osadd",  "original_addr": "0xa719",  "port_location": "games/alis/src/Alis/fn/opernames.php:821",  "status": "same",  "severity": "none",  "used_by_game": "74 ('$+')",  "details": "Original: 0x9d3d swaps [0x16008]/[0x1600c] and evaluates the right operand into the new [0x16008], appends it to [0x1600c] (the left operand), then swaps back so the result is in [0x16008]. Port: readexec_opername_swap, sd6 .= sd7, swap. Same.",  "fix": "" }, {  "table": "opernames",  "index": "45 (code 0x8a)",  "name": "osequal",  "original_addr": "0xa69b (cmp 0xa5de)",  "port_location": "games/alis/src/Alis/fn/opernames.php:833",  "status": "same",  "severity": "none",  "used_by_game": "20 ('$==')",  "details": "Original 0xa5de compares left ([0x1600c]) with right ([0x16008]) byte by byte. When the left string ends first, the strings count as EQUAL (a prefix matches). The buffers stay swapped. Port: strncmp(sd6, sd7, strlen(sd6)) has the same prefix rule and also leaves the buffers swapped. -1 when equal, else 0.",  "fix": "" }, {  "table": "opernames",  "index": "46 (code 0x8c)",  "name": "osdiff",  "original_addr": "0xa6b0",  "port_location": "games/alis/src/Alis/fn/opernames.php:840",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "The negation of osequal, with the same prefix rule. Same.",  "fix": "" }, {  "table": "opernames",  "index": "47 (code 0x8e)",  "name": "osinfeg",  "original_addr": "0xa6c5",  "port_location": "games/alis/src/Alis/fn/opernames.php:847",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: on a mismatch al = left - right as a byte, and `jng` is a SIGNED byte comparison (bytes >= 0x80 count as negative). PHP strncmp compares unsigned bytes, so the order differs when one of the mismatching bytes is >= 0x80 (accented letters). The prefix rule is the same.",  "fix": "Use a small comparison loop over signed bytes (s8) with the original's prefix rule, shared by the four ordering operators." }, {  "table": "opernames",  "index": "48 (code 0x90)",  "name": "ossupeg",  "original_addr": "0xa6da",  "port_location": "games/alis/src/Alis/fn/opernames.php:854",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "`jnl` on the signed byte difference. The same signed/unsigned difference as osinfeg.",  "fix": "As for osinfeg." }, {  "table": "opernames",  "index": "49 (code 0x92)",  "name": "osinf",  "original_addr": "0xa6ef",  "port_location": "games/alis/src/Alis/fn/opernames.php:861",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "`jl` on the signed byte difference. The same signed/unsigned difference as osinfeg.",  "fix": "As for osinfeg." }, {  "table": "opernames",  "index": "4a (code 0x94)",  "name": "ossup",  "original_addr": "0xa704",  "port_location": "games/alis/src/Alis/fn/opernames.php:868",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "`jg` on the signed byte difference. The same signed/unsigned difference as osinfeg.",  "fix": "As for osinfeg." }, {  "table": "opernames",  "index": "4b (code 0x96)",  "name": "ospushacc",  "original_addr": "0xa679 -> 0xa617",  "port_location": "games/alis/src/Alis/fn/opernames.php:875",  "status": "same",  "severity": "none",  "used_by_game": "34 (spush)",  "details": "Pushes [0x16008] with its NUL onto the expression stack (no padding in the original, padding to an even size in the port: internal and symmetric with pop).",  "fix": "" }, {  "table": "opernames",  "index": "4c (code 0x98)",  "name": "ospile",  "original_addr": "0xa67f",  "port_location": "games/alis/src/Alis/fn/opernames.php:881",  "status": "same",  "severity": "none",  "used_by_game": "8",  "details": "Original: swaps [0x16008]/[0x1600c], then pops the stack string into the new [0x1600c]: sd7 = old sd6, sd6 = popped (the string twin of opile). Port: swap, then pop_sd6(). Same.",  "fix": "" }, {  "table": "opernames",  "index": "4d (code 0x9a)",  "name": "oval",  "original_addr": "0xa49d",  "port_location": "games/alis/src/Alis/fn/opernames.php:891",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: writes the word [0x15e9a]=10 (the base, a side effect only). An empty string gives 0. An optional '-', then '$' + hex digits (0-9, A-F case-insensitive through &0xdf), or decimal digits; 16-bit accumulation; stops at the first invalid character; negated at the end. Port: the same parsing and limits, 16-bit through s16 (the base global is not reproduced, and nothing reads it).",  "fix": "" }, {  "table": "opernames",  "index": "4e (code 0x9c)",  "name": "oexistf",  "original_addr": "0xa56b -> 0x2f71",  "port_location": "games/alis/src/Alis/fn/opernames.php:946",  "status": "platform",  "severity": "none",  "used_by_game": "16 (CONFIG.INF, BACKSAVE.INF, *.SAV)",  "details": "Original: opens the file (int21 AH=3Dh, after 0x316e builds the path, with a CD retry path when [0x18ab5]==1). Carry clear -> -1, else 0. Port: tests the file in the data folder or the saves storage (with extension substitution). Equivalent through the host layer.",  "fix": "" }, {  "table": "opernames",  "index": "4f (code 0x9e)",  "name": "ochr",  "original_addr": "0xa55c",  "port_location": "games/alis/src/Alis/fn/opernames.php:965",  "status": "same",  "severity": "none",  "used_by_game": "13",  "details": "buf[0] = dl, buf[1] = 0. Same.",  "fix": "" }, {  "table": "opernames",  "index": "50 (code 0xa0)",  "name": "ochange",  "original_addr": "0xa581 -> 0x2ab5",  "port_location": "games/alis/src/Alis/fn/opernames.php:972",  "status": "differs",  "severity": "high",  "used_by_game": "43 (`if 63 ; change() < 67` = change('?') < 'C', and `vb[0x9a] = 65 ; change()` = change('A'), in baratin*.als, newpref*.als, prefsu.als: `change('?') != 67 -> ret`)",  "details": "Original: d7=='?' -> 0x2ab5(-1) returns the current drive [0x18aba] (0=A). d7>='a' -> d7-0x61; >='A' -> d7-0x41; else -> 0 (and no call). 0x2ab5(n): n==1 checks for a second floppy (int 11h); otherwise int21 AH=0Eh selects the drive. It returns n, or -1 if invalid. The result is 0 when negative, else the drive LETTER ('A'+n). So change('?') returns 'C'(67) or higher on a hard-disk install. Port: always 0. As a result `change('?') < 67` is TRUE in the port, and the scripts take the FLOPPY path: baratin.als:1013 shows 'INSEREZ UNE DISQUETTE DE SAUVEGARDE ... APPUYEZ SUR RETURN' (when mb[0xe71]==0), :1381 etc. call change('A') before existf/fopen of the save, and prefsu.als:403 `change('?') != 67 -> ret` returns early.",  "fix": "Emulate a hard disk: keep a current drive (default 2 = 'C'). '?' -> return 0x41 + curdrive. A letter a-z/A-Z -> return the uppercase letter, and either remember it or, better, ignore the change so that '?' keeps answering 'C' (saves live in the port's storage anyway). Anything else -> 0. That makes `change('?') < 67` false and `!= 67` false, like the original running from C:." }, {  "table": "opernames",  "index": "51 (code 0xa2)",  "name": "ocountry",  "original_addr": "0xa5c3",  "port_location": "games/alis/src/Alis/fn/opernames.php:979",  "status": "platform",  "severity": "low",  "used_by_game": "0",  "details": "Original: dx = zero-extended byte [0x1608c], set at 0x2268 from the setup keyboard byte [0x18aad]: 'A'(AZERTY) -> 1, 'Z'(QWERTZ) -> 2, 'Q' or anything else -> 0. Port: Alis::$pays is fixed to 0 (alis.php:378).",  "fix": "Optional: derive pays from the configured keyboard (AZERTY -> 1, QWERTZ -> 2)." }, {  "table": "opernames",  "index": "52 (code 0xa4)",  "name": "omip",  "original_addr": "0xa5cc -> 0x21ed",  "port_location": "games/alis/src/Alis/fn/opernames.php:990",  "status": "platform",  "severity": "medium",  "used_by_game": "1 (heros.als:41: `if mip() > 700 { clock 4 }`, else clock 7)",  "details": "Original: ax = word [0x16064], a CPU speed benchmark computed at 0x1e81-0x1ecd: loop iterations counted between two timer ticks ([0x1605f]), capped at 0x7fff, divided by 40. Port: the constant 0x64 (100) for pre-v6. In the heros scene the port therefore always runs `clock 7` (the slow-machine timing); a fast machine, where the original gives > 700, gets `clock 4`.",  "fix": "Return a value that stands for the machine the port wants to emulate. A modern / Pentium-class machine is > 700 (e.g. 800, or a host benchmark), so heros.als selects clock 4 as on a fast PC. Keep 100 only if the slower timing is wanted on purpose." }, {  "table": "opernames",  "index": "53 (code 0xa6)",  "name": "ojoykey",  "original_addr": "0xa3dd",  "port_location": "games/alis/src/Alis/fn/opernames.php:996 (io_joykey sys.php:592)",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: mov dx,0: it always returns 0, with no operand. Port pre-v6: io_joykey(d7&0xff), which returns joystick fire / Ctrl / Alt bits when d7==0 (unless in automode).",  "fix": "For the DOS v3 games, return 0 (as the port already does for v6)." }, {  "table": "opernames",  "index": "54 (code 0xa8)",  "name": "oconfig",  "original_addr": "0xa5d5 -> 0x21f4",  "port_location": "games/alis/src/Alis/fn/opernames.php:1009 (init fn/alis.php:423)",  "status": "differs",  "severity": "low",  "used_by_game": "3 (main.als:2331 `config() & 32 != 32`, main.als:2414 `config()/64 == 0` -> logo150 vs logo300 film)",  "details": "Original: ax = word [0x16062], whose bits are set at init: bit0 joystick A (0x2503), bit1 joystick B (0x252e), bit2 mouse (0x2753), bit6 (0x40) CD speed [0x18abc] >= 0x30d40 (0x330b; the default speed 0x493e0 sets it). Bit 7 is never set. Typical value: 0x44 (mouse + CD), 0x45 or 0x47 with joysticks. Port: 0x87 (bits 0, 1, 2, 7), so bit 6 is missing and bit 7 is wrong. The current uses give the same branches (bit5 = 0 in both; /64 is 2 in the port, 1 in the original, both non-zero -> logo300.dat).",  "fix": "Set theconfig = 0x44 for PC v3 (plus 1 / 2 when gamepads are present) instead of 0x87. The comment at alis.php:419 already says the films test bit 0x40." }, {  "table": "opernames",  "index": "55 (code 0xaa)",  "name": "ogettext",  "original_addr": "0x0 (no handler)",  "port_location": "games/alis/src/Alis/fn/opernames.php table_opernames() slot 0xaa",  "status": "platform",  "severity": "none",  "used_by_game": "0",  "details": "The original v3 table ends at index 84: entries 85-87 are 0 (code 0xaa would jump to address 0 and crash), and the storenames table starts at index 88 (0x189ae). The port provides ogettext for later games. That extra entry is harmless for Robinson.",  "fix": "" }, {  "table": "opernames",  "index": "56 (code 0xac)",  "name": "oips",  "original_addr": "0x0 (no handler)",  "port_location": "games/alis/src/Alis/fn/opernames.php:985",  "status": "platform",  "severity": "none",  "used_by_game": "0",  "details": "Not in the original v3 table (dword 0). The port's oips (v6) is never reached by Robinson.",  "fix": "" }, {  "table": "opernames",  "index": "57 (code 0xae)",  "name": "unknown",  "original_addr": "0x0 (no handler)",  "port_location": "none",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Last zero slot of the original table, before 0x189ae (storenames). The port table also ends at 0xad.",  "fix": "" }, {  "table": "esc1",  "index": "0x00",  "name": "cnul",  "original_addr": "0x38ef",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:37",  "status": "differs",  "severity": "low",  "details": "Original esc1[0] is a bare `ret` (0x38ef): a no-op that reads no operand. The port puts cnul() there, which sets Alis::$state = eAlisStateStopped and stops the VM. The script stream stays in sync in both, but the effect is different.",  "fix": "In table_codesc1names() (fn/escnames.php:156) use a no-op closure for index 0 (fn() => null) instead of cnul(...). Keep cnul for the opcode-table slots if the original stops there.",  "used_by_game": "0" }, {  "table": "esc1",  "index": "0x01",  "name": "csoundon",  "original_addr": "0x95c1",  "port_location": "games/alis/src/Alis/fn/escnames.php:18",  "status": "same",  "severity": "none",  "details": "Original sets byte [0x1609f]=1, no operand. That flag gates the sound-effect start (0x10941, together with card-present [0x18aaa]) and the mixing of the sfx voices in the tick loop (0x10ae3, count [0x1abb1]). The port sets Aud::$fsound=1, which gates the sfx mixing (sys_audio.php:532, audio.php:373). Small gap: the original also refuses to START a sound while the flag is off; the port only freezes the mixer, so a sound queued while off can play once sound is back on.",  "fix": "Optional: also check Aud::$fsound where csound/csound2 start a channel, so no sound is started while it is off (like 0x10941).",  "used_by_game": "4" }, {  "table": "esc1",  "index": "0x02",  "name": "csoundoff",  "original_addr": "0x95c9",  "port_location": "games/alis/src/Alis/fn/escnames.php:25",  "status": "same",  "severity": "low",  "details": "Original sets byte [0x1609f]=0, no operand. The port sets Aud::$fsound=0. Same flag; the only gap is the one at the start of a sound, described under csoundon.",  "fix": "See csoundon (gate the channel start on Aud::$fsound).",  "used_by_game": "4" }, {  "table": "esc1",  "index": "0x03",  "name": "cmusicon",  "original_addr": "0x95d1",  "port_location": "games/alis/src/Alis/fn/escnames.php:32",  "status": "differs",  "severity": "low",  "details": "Original sets byte [0x1609e]=1, no operand. That flag gates the music start (0x10a14) AND the per-tick mixing of the music voices (0x10afd..0x10b0e, count [0x1abb3]). The port sets Aud::$fmusic=1, but reads it in one place only: the start of a v2 music (opcodes_a.php:3580, mv2_gomusic). So in the original a music that was muted by musicoff resumes on musicon; in the port it never stopped.",  "fix": "Make the music mixer/tick (mv2 / mv1 / mv0 tick, sys_audio music path) skip the music voices while Aud::$fmusic==0, as 0x10afd does, so musicoff/musicon mute and unmute at once.",  "used_by_game": "1 (main.als:2943, prefs toggle vb[0x3bc0])" }, {  "table": "esc1",  "index": "0x04",  "name": "cmusicoff",  "original_addr": "0x95d9",  "port_location": "games/alis/src/Alis/fn/escnames.php:39",  "status": "differs",  "severity": "medium",  "details": "Original sets byte [0x1609e]=0. The tick loop at 0x10afd then stops mixing the music voices at once, so the music falls silent immediately. The port sets Aud::$fmusic=0, which only stops the NEXT music from starting (opcodes_a.php:3580). A music already playing keeps playing. The game uses it as the Preferences 'music off' switch (main.als:2941), so in the port, turning music off does nothing until the music changes.",  "fix": "Check Aud::$fmusic in the music rendering path (the mv2/mv1 tick or the music part of the sys_audio mixer) and output no music while it is 0. Keep the gomusic gate as it is.",  "used_by_game": "1 (main.als:2941)" }, {  "table": "esc1",  "index": "0x05",  "name": "cdelfilm",  "original_addr": "0x8ef9",  "port_location": "games/alis/src/Alis/fn/escnames.php:45",  "status": "same",  "severity": "none",  "details": "Original: edi=0x17944 (film struct), call 0x13d53. That routine calls 0x13f08(eax=-1) to stop the film, frees the buffer [film+0x50] if non-zero (call 0x1ca2) and clears +0x50/+0x28, then closes the file handle [film+0x4e] if non-zero (call 0x2ff4) and clears it. No operand. The port runs endfilm() (flstofen(-1)), fli_stream_close(), frees the data and calls film_reset(). This is equivalent; the streaming buffers are platform details.",  "fix": "",  "used_by_game": "11" }, {  "table": "esc1",  "index": "0x06",  "name": "copenfilm",  "original_addr": "0x8e5b",  "port_location": "games/alis/src/Alis/fn/escnames.php:71",  "status": "differs",  "severity": "medium",  "details": "Original, film struct at 0x17944:\n1. If handle [+0x4e]!=0, call 0x13d53 (full close, including stop 0x13f08(-1)).\n2. Expression 1 -> word [+0] (id/flags; bit 2 and the high byte are tested later).\n3. String expression (0x9d3d: sd7/sd6 swap) -> open the file (0x2dcd, mode 1) -> handle [+0x4e].\n4. Expression 3 -> dword [+0x24] = u16*1000 (stream buffer size, at least 0x23a50).\n5. Expression 4 -> word [+0x48] (rate/clock).\n6. [+0x4a] = basemain + s16 word [vram_org-0x16]: the CURRENT SCRIPT'S SCREEN record.\n7. call 0x13c2f (start the film).\n8. Store word [+6] through the store target (0x3bd1).\nThe port reads the same operands, so the script stays in sync, but:\n(a) $bf->basemain = Alis::$basemain (escnames.php:142, also opcodes_b.php:2355). The original uses basemain+screen_id. 0x13da8 reads the film window from that record (+0xe x, +0x10 y, +0x12 w, +0x14 h -> fenx1/feny1/clip). The port reads basemain+0xe.. instead (video.php:345, fli.php:655), so the film is placed from the wrong record unless screen_id is 0.\n(b) The port maps '150.' to '300.' on purpose; the original opens the name the script gives (logo150.dat is asked once).\n(c) When a film is already open, the port only does fli_stream_close + film_reset, without endfilm/flstofen(-1). The original runs the full close 0x13d53.\n(d) Expression 3 (buffer size) is discarded: platform.\n(e) Stored value: the port stores bfilm->frames, the original word [film+6]. Most likely the FLI frame count, not verified.",  "fix": "In copenfilm, after the 4th readexec_opername, set $bf->basemain = Alis::$basemain + s16(get_0x16_screen_id(Alis::$script->vram_org)) (escnames.php:142), and do the same at opcodes_b.php:2355 (the other film-open opcode, original 0x8e0e, which does the same at 0x8e3e). If a film is open (bfilm has data or a stream), call endfilm() before fli_stream_close()/film_reset(), as 0x8e68 does. Keep the 150->300 remap only if it is a deliberate choice; note that it changes what the script asked for.",  "used_by_game": "9" }, {  "table": "opernames",  "index": "0x00 (idx 0)",  "name": "oimmb",  "original_addr": "0x9d4f",  "port_location": "games/alis/src/Alis/fn/opernames.php:99",  "status": "same",  "severity": "none",  "details": "Original: lodsb; cbw -> DX (signed byte). The port does varD7 = s8(read8). Same.",  "fix": "",  "used_by_game": "30455" }, {  "table": "opernames",  "index": "0x02 (idx 1)",  "name": "oimmw",  "original_addr": "0x9d56",  "port_location": "games/alis/src/Alis/fn/opernames.php:106",  "status": "same",  "severity": "none",  "details": "Original: lodsw -> DX. The port does s16(read16). Same.",  "fix": "",  "used_by_game": "2838" }, {  "table": "opernames",  "index": "0x04 (idx 2)",  "name": "oimmp",  "original_addr": "0x9d5c",  "port_location": "games/alis/src/Alis/fn/opernames.php:120",  "status": "same",  "severity": "none",  "details": "Original copies the inline zero-terminated string from the script into [0x16008] (sd7), terminator included; DX is untouched. The port uses script_read_until_zero(sd7). Same.",  "fix": "",  "used_by_game": "4125" }, {  "table": "opernames",  "index": "0x06 (idx 3)",  "name": "olocb",  "original_addr": "0x9d6a",  "port_location": "games/alis/src/Alis/fn/opernames.php:133",  "status": "same",  "severity": "none",  "details": "Original: lodsw, movsx offset, byte [vram+off], cbw. The port does s8(xread8(vram_org+s16(off))). Same.",  "fix": "",  "used_by_game": "381" }, {  "table": "opernames",  "index": "0x08 (idx 4)",  "name": "olocw",  "original_addr": "0x9d79",  "port_location": "games/alis/src/Alis/fn/opernames.php:141",  "status": "same",  "severity": "none",  "details": "Original: word [vram+s16 off] -> DX. The port does the same.",  "fix": "",  "used_by_game": "1391" }, {  "table": "opernames",  "index": "0x0a (idx 5)",  "name": "olocp",  "original_addr": "0x9d84",  "port_location": "games/alis/src/Alis/fn/opernames.php:149",  "status": "same",  "severity": "none",  "details": "Original: strcpy from vram+s16 off into [0x16008]. The port does mem_strcpy(sd7, vram_org+s16 off). Same.",  "fix": "",  "used_by_game": "83" }, {  "table": "opernames",  "index": "0x0c (idx 6)",  "name": "oloctp",  "original_addr": "0x9db7",  "port_location": "games/alis/src/Alis/fn/opernames.php:161",  "status": "differs",  "severity": "low",  "details": "Original: lodsw, then 0xa199 (string-array cell; the first index is DX, the other indices come from the [ebx] stack), then strcpy to sd7. The port uses tabstring(vram_org + u16 off) (alis.php:1501).\nDifferences:\n(1) The offset is unsigned in the port, signed (movsx at 0xa19b) in the original. This only matters for offsets >= 0x8000, which no script uses.\n(2) INDIRECT arrays (header byte [base-1] bit 7): the original takes the element size from byte [base-2] in both cases (0xa1bf / 0xa220). The port's indirect branch uses xread8($addr+1) = byte [base-1], the flags/dimensions header (alis.php:1515). This is wrong for every indirect string array, used by odirtp/omaintp too.\n(3) The original checks bounds (index<0 -> error 0x17, index>=dim -> 0x18, null indirect pointer -> 0x1a, via 0x144a0); the port does not.",  "fix": "alis.php:1515: use xread8($addr) (byte base-2, the same byte as the direct case) instead of xread8($addr + 1). Optional: s16() the offset in oloctp/oloctc/olocti/omaint*.",  "used_by_game": "0" }, {  "table": "opernames",  "index": "0x0e (idx 7)",  "name": "oloctc",  "original_addr": "0x9d9d",  "port_location": "games/alis/src/Alis/fn/opernames.php:182",  "status": "same",  "severity": "low",  "details": "Original: lodsw, then 0xa034 (byte cell). Direct case: base+DX + idx_k*word[base-4-2k], with the extra indices popped from [ebx]. Indirect case (bit 7): dword strides at base-6.. and the base pointer double-dereferenced. The result goes to DX with cbw. The port's tabchar (alis.php:1462) uses the same layout and pop order. Minor gaps: the original truncates each idx*stride product to 16 bits (movzx eax,ax after mul word) and checks bounds (errors 0x17/0x18/0x1a); the port does neither.",  "fix": "",  "used_by_game": "1" }, {  "table": "opernames",  "index": "0x10 (idx 8)",  "name": "olocti",  "original_addr": "0x9dac",  "port_location": "games/alis/src/Alis/fn/opernames.php:189",  "status": "same",  "severity": "none",  "details": "Original: 0xa0f3 (word cell: DX*2 computed in 16 bits with add dx,dx; extra dimensions as in 0xa034) -> word to DX. The port's tabint does the same, without the bounds checks.",  "fix": "",  "used_by_game": "28" }, {  "table": "opernames",  "index": "0x12 (idx 9)",  "name": "odirb",  "original_addr": "0x9dd0",  "port_location": "games/alis/src/Alis/fn/opernames.php:198",  "status": "same",  "severity": "none",  "details": "Original: lodsb, movzx offset, signed byte from vram -> DX. The port does the same.",  "fix": "",  "used_by_game": "4396" }, {  "table": "opernames",  "index": "0x14 (idx 10)",  "name": "odirw",  "original_addr": "0x9dde",  "port_location": "games/alis/src/Alis/fn/opernames.php:207",  "status": "same",  "severity": "none",  "details": "Original: unsigned byte offset, word from vram -> DX. The port does the same.",  "fix": "",  "used_by_game": "4884" }, {  "table": "opernames",  "index": "0x16 (idx 11)",  "name": "odirp",  "original_addr": "0x9de8",  "port_location": "games/alis/src/Alis/fn/opernames.php:216",  "status": "same",  "severity": "none",  "details": "Original: unsigned byte offset, strcpy from vram+off to sd7. The port does the same.",  "fix": "",  "used_by_game": "1362" }, {  "table": "opernames",  "index": "0x18 (idx 12)",  "name": "odirtp",  "original_addr": "0x9e1b",  "port_location": "games/alis/src/Alis/fn/opernames.php:228",  "status": "differs",  "severity": "medium",  "details": "Original: lodsb (zero-extended), 0xa199, strcpy to sd7. The port uses tabstring(vram_org + u8). The operands match, but tabstring's indirect branch takes the element size from byte [base-1] instead of byte [base-2] (alis.php:1515; see oloctp). This entry is heavily used (1864), so any indirect string array read here gives a wrong cell. Bounds checks are absent in the port.",  "fix": "alis.php:1515: xread8($addr) instead of xread8($addr + 1).",  "used_by_game": "1864" }, {  "table": "opernames",  "index": "0x1a (idx 13)",  "name": "odirtc",  "original_addr": "0x9dff",  "port_location": "games/alis/src/Alis/fn/opernames.php:239",  "status": "same",  "severity": "none",  "details": "Original: lodsb, sub ah,ah, then 0xa034, then cbw. The port does s8(xread8(tabchar(vram_org+u8))). Same.",  "fix": "",  "used_by_game": "264" }, {  "table": "opernames",  "index": "0x1c (idx 14)",  "name": "odirti",  "original_addr": "0x9e0f",  "port_location": "games/alis/src/Alis/fn/opernames.php:246",  "status": "same",  "severity": "none",  "details": "Original: byte offset, then 0xa0f3, then a word. The port uses tabint. Same.",  "fix": "",  "used_by_game": "12" }, {  "table": "opernames",  "index": "0x1e (idx 15)",  "name": "omainb",  "original_addr": "0x9e35",  "port_location": "games/alis/src/Alis/fn/opernames.php:253",  "status": "same",  "severity": "none",  "details": "Original: signed byte at [0x15fa0](basemain)+s16 off. The port does the same.",  "fix": "",  "used_by_game": "2595" }, {  "table": "opernames",  "index": "0x20 (idx 16)",  "name": "omainw",  "original_addr": "0x9e49",  "port_location": "games/alis/src/Alis/fn/opernames.php:260",  "status": "same",  "severity": "none",  "details": "Original: word at basemain+s16. The port does the same.",  "fix": "",  "used_by_game": "2427" }, {  "table": "opernames",  "index": "0x22 (idx 17)",  "name": "omainp",  "original_addr": "0x9e59",  "port_location": "games/alis/src/Alis/fn/opernames.php:267",  "status": "same",  "severity": "none",  "details": "Original: strcpy from basemain+s16 to sd7. The port does the same.",  "fix": "",  "used_by_game": "70" }, {  "table": "opernames",  "index": "0x24 (idx 18)",  "name": "omaintp",  "original_addr": "0x9e9e",  "port_location": "games/alis/src/Alis/fn/opernames.php:279",  "status": "differs",  "severity": "low",  "details": "Original: lodsw, ebp=basemain, 0xa199 (signed offset), strcpy to sd7. The port uses tabstring(basemain+u16). The element-size byte of INDIRECT arrays is wrong, as for oloctp (alis.php:1515). The unsigned offset is harmless: no main offset >= 0x8000 is used.",  "fix": "alis.php:1515 as for oloctp.",  "used_by_game": "40" }, {  "table": "opernames",  "index": "0x26 (idx 19)",  "name": "omaintc",  "original_addr": "0x9e74",  "port_location": "games/alis/src/Alis/fn/opernames.php:290",  "status": "same",  "severity": "none",  "details": "Original: ebp=basemain, 0xa034, cbw. The port uses tabchar(basemain+off). Same, for the offsets used (all < 0x8000).",  "fix": "",  "used_by_game": "323" }, {  "table": "opernames",  "index": "0x28 (idx 20)",  "name": "omainti",  "original_addr": "0x9e8b",  "port_location": "games/alis/src/Alis/fn/opernames.php:297",  "status": "same",  "severity": "none",  "details": "Original: ebp=basemain, 0xa0f3, then a word. The port uses tabint. Same.",  "fix": "",  "used_by_game": "2924" }, {  "table": "opernames",  "index": "0x2a (idx 21)",  "name": "ohimb",  "original_addr": "0x9ebf",  "port_location": "games/alis/src/Alis/fn/opernames.php:304",  "status": "differs",  "severity": "medium",  "details": "Original:\n1. w1=lodsw; entry = movsx word [vram+w1]; edi = atent[0x15f72]+entry.\n2. 0x9fc3: entry<0 -> fatal error 0x1b.\n3. edi = dword [edi] (the other entity's vram); w2 = lodsw (signed).\n4. If edi <= 0 (the entity is dead or empty), RETURN WITHOUT CHANGING DX (0x9edc jng).\n5. Otherwise DX = sbyte [edi+w2].\nThe port's v3 path (version < 60) has no vram<=0 check: it reads xread8(0+offset), i.e. low memory, and puts garbage in D7. Only the v6 branch has the check. The entry is also read &0xffff instead of signed (error case only).",  "fix": "In ohimb, apply the dead-entity test for every version: after $offset = s16(script_read16()), add `if ($vram_addr <= 0) return;` before reading (keep s16 offset for v3).",  "used_by_game": "848" }, {  "table": "opernames",  "index": "0x2c (idx 22)",  "name": "ohimw",  "original_addr": "0x9eeb",  "port_location": "games/alis/src/Alis/fn/opernames.php:323",  "status": "differs",  "severity": "medium",  "details": "Same as ohimb, with a word read: the original checks entry<0 (0x9fdf, error 0x1d) and leaves DX unchanged when the target vram <= 0 (0x9f08). The port's v3 path reads xread16(vram_addr+offset) even for a dead entity.",  "fix": "Add `if ($vram_addr <= 0) return;` after reading the s16 offset, for all versions.",  "used_by_game": "311" }, {  "table": "opernames",  "index": "0x2e (idx 23)",  "name": "ohimp",  "original_addr": "0x9f13",  "port_location": "games/alis/src/Alis/fn/opernames.php:342",  "status": "same",  "severity": "none",  "details": "Original: w1 (entity var) -> entry -> vram=[atent+entry] (no check), w2 signed, strcpy vram+w2 to sd7. The port does the same.",  "fix": "",  "used_by_game": "0" }, {  "table": "opernames",  "index": "0x30 (idx 24)",  "name": "ohimtp",  "original_addr": "0x9f8f",  "port_location": "games/alis/src/Alis/fn/opernames.php:357",  "status": "stub_in_port",  "severity": "low",  "details": "Original reads TWO words. Note the order: the FIRST word is the ARRAY offset, the SECOND is the entity-variable offset (xchg at 0x9f99). Then entry = movsx [vram+w2], target vram = [atent+entry] (no check), ebp = target, then 0xa199 (string cell, index DX + stack) and strcpy to sd7. The port's function is empty: it reads no operand, so the script would desync. Grammar.php:109 also decodes it with no operand.",  "fix": "Implement for v3: $off = s16(script_read16()); $vram = xread32(Alis::$atent + xread16(Alis::$script->vram_org + s16(script_read16()))); mem_strcpy(Alis::$sd7, tabstring($vram + $off)). Also fix Grammar.php:109 (operand spec 'h' with the array offset first).",  "used_by_game": "0" }, {  "table": "opernames",  "index": "0x32 (idx 25)",  "name": "ohimtc",  "original_addr": "0x9f3f",  "port_location": "games/alis/src/Alis/fn/opernames.php:363",  "status": "stub_in_port",  "severity": "low",  "details": "Original: w1 = array offset, w2 = entity var (xchg at 0x9f49); entry = movsx [vram+w2]; target = [atent+entry]; ebp = target; 0xa034 (byte cell); cbw -> DX. The port only implements this for version==10; for v3 (31) it does nothing and reads no operand, so the script would desync. The v10 code already has the right operand order.",  "fix": "Remove the `version == 10` guard (or extend it to >=10 && <60) so v31 runs: $offset=s16(read16); $vram=xread32(atent+xread16(vram_org+s16(read16))); D7=s8(xread8(tabchar($vram+$offset))). Also fix Grammar.php:109.",  "used_by_game": "0" }, {  "table": "opernames",  "index": "0x34 (idx 26)",  "name": "ohimti",  "original_addr": "0x9f69",  "port_location": "games/alis/src/Alis/fn/opernames.php:376",  "status": "stub_in_port",  "severity": "low",  "details": "Original: same as ohimtc but with 0xa0f3 (word cell) and a word -> DX. The port only handles version 10; for v31 it reads no operand, so the script would desync.",  "fix": "Extend the v10 branch to v31: D7 = xread16(tabint($vram+$offset)), with the same operand order (array offset first). Also fix Grammar.php:109.",  "used_by_game": "0" }, {  "table": "opernames",  "index": "0x36 (idx 27)",  "name": "opile",  "original_addr": "0xa755",  "port_location": "games/alis/src/Alis/fn/opernames.php:390",  "status": "same",  "severity": "none",  "details": "Original: DX=CX; CX=word [ebx]; ebx+=2 (pop from the 16-bit expression stack). The port does D7=D6; D6=pop 32-bit from acc. Same values: what is pushed is always an s16 D7.",  "fix": "",  "used_by_game": "2018" }, {  "table": "opernames",  "index": "0x38 (idx 28)",  "name": "oeval",  "original_addr": "0xa75f",  "port_location": "games/alis/src/Alis/fn/opernames.php:400",  "status": "same",  "severity": "none",  "details": "Original loops on call 0x9d2d (dispatch the next operand without cx=dx); ofin escapes by dropping the return address (add sp,4). Nesting works through the CPU stack. The port uses a global flag Alis::$oeval_loop, so a NESTED oeval would end the outer loop too early. A scan of all 111 decoded scripts finds 9316 oevals and none nested, so it is harmless for this game.",  "fix": "",  "used_by_game": "9316" }, {  "table": "opernames",  "index": "0x3a (idx 29)",  "name": "ofin",  "original_addr": "0xa767",  "port_location": "games/alis/src/Alis/fn/opernames.php:410",  "status": "same",  "severity": "none",  "details": "Original: add sp,4; ret (leaves the oeval loop). The port clears oeval_loop. It only appears as the terminator of oeval/seval (9316 times, never on its own).",  "fix": "",  "used_by_game": "9316 (only as oeval terminator)" }, {  "table": "opernames",  "index": "0x3c (idx 30)",  "name": "oimml",  "original_addr": "0x0 (null)",  "port_location": "games/alis/src/Alis/fn/opernames.php:113",  "status": "differs",  "severity": "none",  "details": "Original table entry is 0: the code does not exist in v31 (jumping there would crash). The port has the v6 oimml (reads a 32-bit long). Not used by the game.",  "fix": "",  "used_by_game": "0" }, {  "table": "opernames",  "index": "0x3e (idx 31)",  "name": "olocto",  "original_addr": "0x0 (null)",  "port_location": "games/alis/src/Alis/fn/opernames.php:172",  "status": "differs",  "severity": "none",  "details": "Original entry is null (not in v31). The port has the v6 olocto. Not used.",  "fix": "",  "used_by_game": "0" }, {  "table": "opernames",  "index": "0x40 (idx 32)",  "name": "opushacc",  "original_addr": "0xa74e",  "port_location": "games/alis/src/Alis/fn/opernames.php:427",  "status": "same",  "severity": "low",  "details": "Original: ebx-=2; word [ebx]=DX. The expression stack (ebx) is reset to 0x18328 at EVERY expression entry (0x9d24, 0x9d37, cstore 0x3bc6/0x3be3). The port pushes a 32-bit cell on Alis::$acc, which is only reset when a script starts running (alis.php:1142/1224). Values are the same within one expression; a push left unpopped would only accumulate in the port. No such pattern is visible in the scripts.",  "fix": "",  "used_by_game": "4530" }, {  "table": "opernames",  "index": "0x42 (idx 33)",  "name": "oand",  "original_addr": "0xa257",  "port_location": "games/alis/src/Alis/fn/opernames.php:435",  "status": "same",  "severity": "none",  "details": "Original: call 0x9d2a (CX=DX, read the next operand into DX); DX&=CX. The port does D6=D7; read; D7&=D6. Same.",  "fix": "",  "used_by_game": "1148" }, {  "table": "opernames",  "index": "0x44 (idx 34)",  "name": "oor",  "original_addr": "0xa260",  "port_location": "games/alis/src/Alis/fn/opernames.php:444",  "status": "same",  "severity": "none",  "details": "Original: DX|=CX after reading the next operand. Same as the port.",  "fix": "",  "used_by_game": "402" }, {  "table": "opernames",  "index": "0x46 (idx 35)",  "name": "oxor",  "original_addr": "0xa269",  "port_location": "games/alis/src/Alis/fn/opernames.php:453",  "status": "same",  "severity": "none",  "details": "Original: DX^=CX. Same as the port.",  "fix": "",  "used_by_game": "0" }, {  "table": "opernames",  "index": "0x48 (idx 36)",  "name": "oeqv",  "original_addr": "0xa272",  "port_location": "games/alis/src/Alis/fn/opernames.php:461",  "status": "same",  "severity": "none",  "details": "Original: DX = NOT(DX XOR CX), 16-bit. The port does ~(D7^D6), then s16 in readexec_opername. Same.",  "fix": "",  "used_by_game": "0" }, {  "table": "opernames",  "index": "0x4a (idx 37)",  "name": "oegal",  "original_addr": "0xa27e",  "port_location": "games/alis/src/Alis/fn/opernames.php:470",  "status": "same",  "severity": "none",  "details": "Original: cmp dx,cx; equal -> 0xffff, else 0. The port gives -1/0. Same.",  "fix": "",  "used_by_game": "1888" }, {  "table": "opernames",  "index": "0x4c (idx 38)",  "name": "odiff",  "original_addr": "0xa291",  "port_location": "games/alis/src/Alis/fn/opernames.php:478",  "status": "same",  "severity": "none",  "details": "Original: not equal -> -1, else 0. Same as the port.",  "fix": "",  "used_by_game": "727" }, {  "table": "opernames",  "index": "0x4e (idx 39)",  "name": "oinfeg",  "original_addr": "0xa2a4",  "port_location": "games/alis/src/Alis/fn/opernames.php:486",  "status": "same",  "severity": "none",  "details": "Original: cmp cx,dx; jng -> -1, i.e. left(CX) <= right(DX), signed 16-bit. The port does D6<=D7 on s16 values. Same.",  "fix": "",  "used_by_game": "432" }, {  "table": "opernames",  "index": "0x50 (idx 40)",  "name": "osupeg",  "original_addr": "0xa2b7",  "port_location": "games/alis/src/Alis/fn/opernames.php:494",  "status": "same",  "severity": "none",  "details": "Original: CX >= DX signed -> -1. The port does D6>=D7. Same.",  "fix": "",  "used_by_game": "130" }, {  "table": "opernames",  "index": "0x52 (idx 41)",  "name": "oinf",  "original_addr": "0xa2ca",  "port_location": "games/alis/src/Alis/fn/opernames.php:502",  "status": "same",  "severity": "none",  "details": "Original: CX < DX signed -> -1. The port does D6<D7. Same.",  "fix": "",  "used_by_game": "726" }, {  "table": "opernames",  "index": "0x54 (idx 42)",  "name": "osup",  "original_addr": "0xa2dd",  "port_location": "games/alis/src/Alis/fn/opernames.php:510",  "status": "same",  "severity": "none",  "details": "Original: CX > DX signed -> -1. The port does D6>D7. Same.",  "fix": "",  "used_by_game": "862" }, {  "table": "opcodes",  "index": "f2",  "name": "cscaset",  "original_addr": "0x430e",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2286",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original 0x430e: eval a (0x9d24) and push dx; eval b with 0x9d17 (returns cx=b, dx=a); eval c with 0x9d24. 0x9d24 begins with 'mov cx,dx' (0x9d2a), so cx becomes a again and b is lost. Then ebx = basemain([0x15fa0]) + s16[ebp-0x16] (the screen), word[ebx+0x38]=c, word[ebx+0x36]=cx (=a in practice), word[ebx+0x34]=pop (=a), and bts [ebx],7 (screen dirty bit 0x80 of byte 0). The port's function is an empty stub copied from the C ('MISSING'): it reads no operands, so the script would go out of sync if this opcode ever ran.",  "fix": "Implement cscaset: $s = basemain + get_0x16_screen_id(vram); readexec_opername() -> a; readexec_opername() -> b; readexec_opername() -> c; xwrite16($s+0x38,c); xwrite16($s+0x36,a /* original quirk: 0x9d24 overwrites cx with dx */); xwrite16($s+0x34,a); xwrite8($s, xread8($s)|0x80). Writing b at +0x36 is the probable intent; the game never uses this opcode." }, {  "table": "opcodes",  "index": "f3",  "name": "cscamov",  "original_addr": "0x42db",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2292",  "status": "stub_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original 0x42db: reads three expressions a, b, c (each pushed). On the screen (basemain + s16[ebp-0x16]): word[+0x38]+=c, word[+0x36]+=b, word[+0x34]+=a (16-bit wrap), then bts [screen],7. The port's function is an empty stub that reads no operands.",  "fix": "Implement: three readexec_opername(); xadd16($s+0x34,a); xadd16($s+0x36,b); xadd16($s+0x38,c); set bit 0x80 of byte $s." }, {  "table": "opcodes",  "index": "f4",  "name": "cscfollow",  "original_addr": "0x4368",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2298",  "status": "differs",  "severity": "low",  "used_by_game": "14",  "details": "Original reads 8 expressions. On the screen it writes word +0x60 = e1, byte +0x84 = e2 (dl), words +0x86..+0x8e = e3..e7, word +0x90 = AX after the 8th expression (not DX), then 'bts dword [ebx],7' at 0x43eb, which sets the screen dirty bit 0x80. The port writes the same fields from varD7 but never sets bit 0x80 of the screen byte (its cscview does set it). The AX/DX quirk changes nothing for the game: AX equals DX for immediates, and every script passes the literal 0 as the 8th operand (AX differs only for a local-word operand, handler 0x9d79, where AX holds the offset).",  "fix": "Add xwrite8($screen, xread8($screen) | 0x80); at the end of cscfollow." }, {  "table": "opcodes",  "index": "f5",  "name": "cscview",  "original_addr": "0x4556",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2320",  "status": "same",  "severity": "none",  "used_by_game": "5",  "details": "Original 0x4556: 6 expressions go to screen words +0x64,+0x66,+0x68,+0x6a,+0x6c,+0x6e in that order, then bts [screen],7. The port does the same (it sets bit 0x80 of byte 0).",  "fix": "" }, {  "table": "opcodes",  "index": "f6",  "name": "cfilm",  "original_addr": "0x8e0e",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2339",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original 0x8e0e: [0x17944]=id (eval 1). Eval 2 is resolved with 0x5c01: ebx = entry + [entry], the resource data itself (it uses flag 0x15fc7 for main). addr1 = addr2 = resource + 0x20 (bfilm+0x18/+0x1c), word bfilm+0x4e = 0, waitclock = eval 3 (+0x48), bfilm+0x4a = SCREEN address (basemain + s16[ebp-0x16]). Then inifilm (0x13c2f) and the store of word bfilm+6 (frames) through 0x3bd1. The port (like the C) uses adresdes(id)+0x24. Port adresdes returns the unresolved table-entry address (alis.php:1355), so the film pointer is wrong. It also sets bfilm->basemain to basemain instead of the screen address, and it resets every film field (film_reset) while the original only clears +0x4e. Robinson's scripts never use this opcode.",  "fix": "If ever needed: $e = adresdes(D7); $res = $e + xread32($e); film_use_mem($res + 0x20); bfilm screen = basemain + get_0x16_screen_id(vram)." }, {  "table": "opcodes",  "index": "f7",  "name": "cwalkmap",  "original_addr": "0x4e14 (walk 0xd127, landalti 0xd5e6)",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2550 (walkland 2406, landalti 2594)",  "status": "differs",  "severity": "high",  "used_by_game": "61 (walktete is 0 in 48 calls, -1 in 11; never > 0)",  "details": "Operands match: map offset (0 -> main), then three expressions into 0x1aad8 walkhaut, 0x1aada walktete and 0x1aadc walkdim (walkdim is unused), and a store of AX = walkcz - walkocz. 0x472 only sets GS = map - 0xc00, which is platform-level. The walk routine 0xd127 differs from the port's walkland in three ways. (1) Look-ahead probes: the original ALWAYS runs the 5 extra landalti probes (0xd215-0xd3cb, no condition) with d0/d4 = the rotated STEP vector, d0 = (cos*wcx2 - sin*wcy2)<<7 and d4 = (sin*wcx2 + cos*wcy2)<<7 (0x1aad0/0x1aad4 written at 0xd1ac/0xd1e8). The probes sit at X+d0+d4 / Y+d4+d0, X+d0-d4 / Y+d4-d0, 2d0 / 2d4, 2d0+d4 / 2d4+d0, 2d0-d4 / 2d4-d0, and any altitude >= 0xff sets walkcz and blocks the move. The port runs them only when matmask != 0 (line 2447), with the dim-based vectors (-[map-0x3f4]*sin, [map-0x3f4]*cos), which the original computes only later, for head-bob (0xd3f1). So with walktete=0 the port has no look-ahead against 0xff (wall) cells, and with walktete=-1 it probes at the wrong points. (2) Rejected move (|walkcz - ocz| > walkhaut): the original writes nothing (0xd55c jg 0xd581). The port (line 2535) calls landalti at the current position and writes WCZ. (3) In landalti 0xd5e6, flag == 1 with dword[+0x10] != 0 and matmask != 0 does 'add cx,0xff' (0xd67d): it adds 0xff to the ALTITUDE. The port treats this as a no-op (line 2624), so with walktete=-1 such material cells do not block. Head-bob (walktete > 0) also differs: the port drops the 2x sample (line 2492), while the original sums 4*(s1-oz) + 2*(s2-oz) + (s4-oz). The original also multiplies the ABSOLUTE sum (AX, at 0xd4f4) by the SIGNED high byte of walktete (movsx [0x1aadb]); the >0x3c0 clamp zeroes only SI, which is unused; and the threshold is the low byte of walktete ([0x1aada]), where the port uses the never-set walkmap3. The game never uses head-bob. Minor: column address 'lea ax,[eax+ebx*2]' (0xd621) wraps within 64 KB, and an out-of-bounds probe leaves CX (walkcz) at its previous register value.",  "fix": "In walkland: compute $pdx = mul32($cos_az*$offset_x - $sin_az*$offset_y, 0x80) and $pdy = mul32($cos_az*$offset_y + $sin_az*$offset_x, 0x80). Run the 5 probes UNCONDITIONALLY with $pdx/$pdy in place of walkdx/walkdy. Compute the dim-based walkdx/walkdy only inside the `0 < walktete` head-bob block. In the reject branch, remove the landalti + xwrite16(WCZ) (write nothing). In landalti, flag == 1 && xread32($addr+0x10+$terrain_offset) != 0 => $out_alt = s16($out_alt + 0xff). Optionally fix head-bob: keep $s2 = ($s2-oz)*2 in the sum; multiply abs(sum) by s8(walktete >> 8); compare (abs & 0xff) with (walktete & 0xff)." }, {  "table": "opcodes",  "index": "f8",  "name": "catstmap",  "original_addr": "0x4e57",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2637",  "status": "differs",  "severity": "low",  "used_by_game": "10",  "details": "Original: map offset (0 -> main); x, y, z expressions; polarmov 0xcf0d(x, y, z, angles [ebp+0x18], [ebp+0x28]; [ebp+0x20] is passed but unused). Then X = (WCX32 + vx) >> 16, Y = (WCY32 + vy) >> 16, [0x16032] matmask = 0, landalti 0xd5e6, and a store of DX = the cell word (the redirected cell when the overhang path is taken). The port matches: polarmov is DOS-correct (x*cosaz not scaled by 0x80, s16((sin*cos)>>9)*y<<7) and it stores out_cell. The landalti differences of cwalkmap do not matter here because matmask = 0. Edge cases: out of bounds, the original stores DX = low word of the polar Y vector, the port stores varD7 (z); and the original column address wraps within 64 KB (0xd621).",  "fix": "Optional: on out-of-bounds, store s16($vec->y) to mimic the original." }, {  "table": "opcodes",  "index": "f9",  "name": "cavtstmov",  "original_addr": "0x73f5",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2676",  "status": "same",  "severity": "none",  "used_by_game": "67",  "details": "Original: s8 wcx2/wcy2/wcz2 (+0x34/+0x38/+0x3c); polarmov with [ebp+0x18] and [ebp+0x28]. [0x16028/2a/2c] = high word of (WC?32 + vector) for X, Y and Z. Then matmask [0x16032] = expression, [0x16030] = [ebp-0x1a] cforme, clipform 0x7631, then 0x7610 ([0x1603e]=0x17a2a; jmp 0x75cc = succent + store). Like the original, it does not set 0x1602e. The port does the same: polarmov, xread32_wc, matmask, wforme, clipform(), crstent() (ptrent=0 + csuccent, which stores).",  "fix": "" }, {  "table": "opcodes",  "index": "fa",  "name": "cavmov",  "original_addr": "0x5e7c",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2706",  "status": "same",  "severity": "none",  "used_by_game": "7",  "details": "Original: polarmov(s8 +0x34, +0x38, +0x3c; angles +0x18, +0x28); rol 16, then 16-bit add of the integer part only to words [ebp+0], [ebp+8] and [ebp+0x10]. Fractions are untouched. No operands. The port's little-endian branch does xadd16 of s16(vec >> 16) on WCX, WCY and WCZ, which is identical.",  "fix": "" }, {  "table": "opcodes",  "index": "fb",  "name": "caim",  "original_addr": "0x5f57 (polarang 0xcfc6, getangle 0xcff9)",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2847",  "status": "differs",  "severity": "low",  "used_by_game": "52 (4th operand always 360)",  "details": "Original: x, y, z expressions; polarang 0xcfc6 returns ax = azimuth, bx = elevation, cx = distance. If distance == 0, ax = WCAZ [ebp+0x28]. Max-turn expression: when (u16)max < 0xb4, the delta is clamped against WCAZ, with the wrap logic (delta >= 0xb4 -> -0x168; delta <= -0xb4 -> +0x168; then a positive or negative clamp chosen by the sign). Normalised to +/-0x167. Stores: S1 = bx (elevation, ALWAYS), S2 = new azimuth, S3 = distance. The port's polarang/getangle match, apart from an edge case: |y|<<5/|x| >= 0x10000 skips the division in the original (bp = 0x5a), while the port s16-wraps the quotient. Port bugs reachable only with max_turn <= 0xb3: (a) at line 2879 it overwrites $cy (elevation) with WCAZ, so S1 receives the current azimuth instead of the elevation; (b) in the 'delta > 0xb3' branch, when delta-0x168 is still >= 0 it applies no positive clamp, where the original jumps to 0x5fc4 and clamps. The game always passes 360, so neither case occurs.",  "fix": "Use a separate local ($curaz) for WCAZ in the clamp so that $cy keeps the elevation. In the '0xb3 < diff' branch, apply the positive clamp (diff = min(diff, max_turn); cx = curaz + diff) when diff-0x168 >= 0." }, {  "table": "opcodes",  "index": "fc",  "name": "cpointpix",  "original_addr": "0x9a5b (pointpix 0xcdc0)",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2951 (pointpix fn/rrq3d.php:1664)",  "status": "differs",  "severity": "low",  "used_by_game": "14",  "details": "Original: x, y; 0xcdc0. On the screen: d = word +0x94, [0x1aaf0] = [0x1aaf2] = -1, ftstpix = 1, it pushes the screen flags word, and if bit 6 is clear it sets bit 7 (bts, 0xce1f) before affiland 0xbc6e. Then it computes ntstpix from etstpix through atent ([0x15f72]) with the basemain fallback, the render context = [atent + s16 scr+0x40] + s16 scr+0x42, pixtoland 0xccb9(x, y, d) -> cx, cy, cz, ftstpix = 0, and finally restores the screen flags word (pop word [ebp+0], 0xced4). 6 stores in the order cx, cy, cz, d, n, e (0x1aae8..0x1aaf2). The port has the same operands, store order and ntstpix math. It does not set bit 7 of the screen before affiland, and it does not save and restore the screen's flags word, so any flag change made by affiland survives in the port, and an affiland that reads bit 7 sees a different state.",  "fix": "In pointpix(): $flags = xread16($scene_addr); if bit 6 is clear, xwrite8($scene_addr, xread8($scene_addr) | 0x80) before affiland; at the end, xwrite16($scene_addr, $flags)." }, {  "table": "opcodes",  "index": "fd",  "name": "cchartmap",  "original_addr": "0x4eca",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2973",  "status": "differs",  "severity": "medium",  "used_by_game": "9 (sub 0/1 x4, 2, 4, 5, default -1 radius 240)",  "details": "Sub-commands: 0/1 fill the map bitmap with 0 / 0xffff, then read another map offset into [map-0x3ba]. 2 and 3 write -0x3b6. 4 writes -0x3ae. 5 writes -0x3b0. Any other value clears a rectangle around the current position. The port matches these, with two differences. (1) The default (radius) path takes the centre from es:ebp+0 / es:ebp+8, the CURRENT SCRIPT's WCX/WCY integer words (0x4f31, 0x4f8f). The port uses Alis::$wcx / Alis::$wcy (line 3016): the globals of the last tstmov test (0x16028/0x1602a), which may be stale or offset. (2) Fill count: the original computes (u16)([map-0x3c6]*[map-0x3c4]) with 'shr ax,1', a LOGICAL shift (0x5146). The port's s16(product) >> 1 (line 3125) goes negative, and fills nothing, when the 16-bit product is >= 0x8000. The rest (clamps, sar shifts, edge masks, word span, row pointer (x0a>>4)*stride + 2*y0, indirect base when byte[map-1] < 0, row loop) matches.",  "fix": "Line 3016: $pos_x = xread16($vram_script + C::ALIS_SCR_WCX); $pos_y = xread16($vram_script + Opcodes2Const::ALIS_SCR_WCY()) with $vram_script = Alis::$script->vram_org (not the map base). Line 3125: $loops = ((xread16($addr-0x3c6) * xread16($addr-0x3c4)) & 0xffff) >> 1." }, {  "table": "opcodes",  "index": "fe",  "name": "cscsky",  "original_addr": "0x447b",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3147",  "status": "differs",  "severity": "low",  "used_by_game": "6 (scsky 1, 0|1, 0)",  "details": "Original: screen = basemain + s16[ebp-0x16]; +0xa2 = e1. +0xa4 = 0x5c46(e2), the table-entry address (unresolved); it honours flag [0x15fc7] (flagmain) and does NOT clear it. +0xa8 = e3, then overwritten. Sprite: entry + [entry], with the type-3 redirect. The value is ((s16(4*h6c) >> 3) * 0x168 / (movzx w + 1) + 0x80) & 0xff00, times (w+1), / 0x168; then bts bit 7. Port differences: it forces Alis::$flagmain = 0 first, while the original keeps whatever the last opcode left in 0x15fc7. 4*h6c is not wrapped to 16 bits (it differs when |h6c| >= 0x2000). The width is read signed (xread16), where the original uses movzx. None of these matter with the game's values (h6c about 1110..1120).",  "fix": "Optional: $q = cdiv((s16(xread16($mem+0x6c)*4) >> 3) * 0x168, $w1) with $w1 = (xread16($spdata+2) & 0xffff) + 1. To mimic the original exactly, do not reset flagmain." }, {  "table": "opcodes",  "index": "ff",  "name": "czoom",  "original_addr": "0x584c",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3178",  "status": "same",  "severity": "none",  "used_by_game": "16",  "details": "Original: two expressions to word [ebp-0x36] and [ebp-0x38]. The port writes vram-0x36 and vram-0x38 in the same order.",  "fix": "" }, {  "table": "opcodes",  "index": "0x2c",  "name": "cloop16",  "original_addr": "0x3aae",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:358 (cloop at :336)",  "status": "same",  "severity": "none",  "used_by_game": "4 (opcode 0x2c in var/scripts; 53 'loop' statements in all, counters vb x44 / vw x9)",  "details": "Original: saves ESI (start of the s16 offset) in [0x16002], skips 2 bytes, DX=-1, calls 0x3c23 (swap [0x16008]/[0x16010] = sd7/oldsd7, then lodsb + jmp [eax*2+0x18a1a] = addname target: adds DX to it, ZF from the add). ZF set (counter reached 0): falls through after the target. Otherwise ESI = saved; lodsw; ESI += s16 offset (relative to the byte after the offset). Port: reads s16 offset first, saves pc (after offset), varD7=-1, readexec_addname_swap() (same sd7/oldsd7 swap), if !sr['zero'] pc = saved + offset. Same operands consumed, same target. Zero flag is only set by alocb/alocw/adirb/adirw in the port (fn/addnames.php:21,29,70,78); the original's add sets ZF for every target, but Robinson's loops only use vb/vw locals, which are covered.",  "fix": "Optional: set Alis::$sr['zero'] in the other numeric addnames too (amainb/amainw/ahimb/ahimw/aloctc/alocti/...) so a loop on a main/table variable behaves like the original." }, {  "table": "opcodes",  "index": "0x2d",  "name": "cloop24",  "original_addr": "0x3ad1",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:364",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: like cloop16 but skips 3 bytes; on loop: lodsw, inc esi, ESI += s16 (offset relative to after the 3-byte field, third byte ignored). Port: read_off24() little endian = s16 + skip one byte (fn/opcodes_a.php:320), then cloop(). Identical.",  "fix": "" }, {  "table": "opcodes",  "index": "0x2e",  "name": "cswitch1",  "original_addr": "0x8577",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:377",  "status": "same",  "severity": "low",  "used_by_game": "79",  "details": "Original: eval expr -> DX; n=lodsb, count=n+1; align ESI to even (test esi,1 / inc esi); loop over (s16 value, s16 offset) pairs: signed 16-bit cmp DX,[esi]: equal -> ESI = offset field + 2 + s16 offset; DX < value -> skip remaining entries (ESI += remaining*4) and continue after the table; else next entry; after n+1 entries continue after the table. Port reproduces the same walk (do/while with --addition > -1 and pc += addition*4) and the same signed compare. Only difference: the port adds the case offset with script_read16() which is UNSIGNED (pc += 0..65535) while the original uses movsx (signed). Checked all 3399 switch/table entries of the Robinson scripts: no negative case offset, so no observable effect. Alignment uses absolute pc parity; all Robinson script images have even sizes, so parity matches the original.",  "fix": "In cswitch1 use Alis::$script->pc += s16(script_read16()) for the matched case offset (robustness only)." }, {  "table": "opcodes",  "index": "0x2f",  "name": "cswitch2",  "original_addr": "0x85b3",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:404",  "status": "same",  "severity": "low",  "used_by_game": "327 ('table expr, base')",  "details": "Original: eval -> DX; n=lodsb; align even; DX += s16 base (16-bit add); if result negative (js) or > n (unsigned ja) -> ESI += 4 + 2n (skip base + n+1 offsets), DX keeps the sum; else ESI += 2, DX = DX*2 (16-bit shl), ESI += movsx DX, ESI += s16[esi] + 2. Port: varD7 = s16(varD7 + base); in range: varD7 = val*2, pc += varD7, pc += script_read16() (UNSIGNED, original signed); out of range: pc += n*2+2 (after base already read) = same. Same operands, same D7 side effect. Like cswitch1, the unsigned offset add never matters for Robinson (no negative offsets found).",  "fix": "Use s16(script_read16()) for the jump offset (robustness only)." }, {  "table": "opcodes",  "index": "0x30",  "name": "cstart8",  "original_addr": "0x395e",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3448 (cstart at :3407)",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original common body at 0x3969: fseq ([0x15fcb]) == 0: if [ebp-0xc]==0 { edi=[0x16006]-4 (0x16006 = copy of [ebp-0xa] made at vector entry, written back to [ebp-0xa] after the vector, 0x383d/0x3852), [ebp-0xc]=edi, [0x16006]=edi, [ebp+edi]=[ebp-8] (old resume address), [ebp-8]=ESI+off } else { [0x16006]=[ebp-0xc]; [ebp-8]=ESI+off }; then byte[-4]=1, byte[-1]=1, dword[-0x3e]=0; ESI not moved. fseq != 0: if [ebp-0xc]==0 { [ebp-0xa]-=4; [ebp-0xc]=[ebp-0xa]; [ebp+edi]=ESI } else [ebp-0xa]=[ebp-0xc]; ESI += off. Port does the same with the 0x0a field directly (equivalent, because the original copies [0x16006] back into -0xa at the end of the vector) and stores return addresses as offsets from pc_org instead of absolute addresses; that is consistent with the port's cret (pc = pc_org + peek). Offset s8, relative to after the operand: same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x31",  "name": "cstart16",  "original_addr": "0x3964",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3455",  "status": "same",  "severity": "none",  "used_by_game": "4",  "details": "Original: lodsw, movsx, then the shared cstart body (0x3969, see cstart8). Port: cstart(s16(script_read16())). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x32",  "name": "cstart24",  "original_addr": "0x39f3",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3461",  "status": "same",  "severity": "none",  "used_by_game": "151",  "details": "Original: lodsw, inc esi (3rd byte ignored), movsx, jmp 0x3969 (shared body). Port: cstart(read_off24()) = s16 + skip one byte on little-endian. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x33",  "name": "cleave",  "original_addr": "0x39fe",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:425",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: fseq==0: if [ebp-0xc]!=0 { [ebp-0xc]=0; [ebp-8]=[ebp+edi] (ABSOLUTE resume address saved by cstart); [0x16006]=edi+4; return }. fseq!=0: if [ebp-0xc]!=0 { [ebp-0xc]=0; ESI=[ebp+edi]; [ebp-0xa]=edi+4; return }. If -0xc == 0 in either case: falls into the cret code at 0x3a53 WITHOUT touching -0xa. Port has two bugs (inherited from the C): (1) fseq==0 branch (line ~431) sets 0x08 = xread32(slot), but the port's slot holds an offset from pc_org (cstart writes get_0x08 - pc_org), so 0x08 gets a relative value instead of an absolute address -> the sequence would resume at a wrong address. (2) fseq!=0 branch (line ~437) sets Alis::$script->vacc_off = get_0x0c BEFORE testing it, so when -0xc==0 it calls cret() with vacc_off = 0 (the original keeps -0xa) -> cret reads its return slot at vram+0. Not reachable in Robinson (opcode never used).",  "fix": "fseq==0: set_0x08_script_ret_offset(vram, s32(Alis::$script->pc_org + xread32(vram + vacc_offset))). fseq!=0: $v = get_0x0c_vacc_offset(vram); if ($v != 0) { Alis::$script->vacc_off = $v; set_0x0c(vram, 0); pc = pc_org + xpop32(); return; } then cret() with vacc_off untouched." }, {  "table": "opcodes",  "index": "0x34",  "name": "cprotect",  "original_addr": "0x9af6",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:448",  "status": "same",  "severity": "none",  "used_by_game": "1 (main.als:3214 'protect -1', inside 'if 0' = dead code)",  "details": "Original: eval, stores DX as a WORD in [0x15fc0]. A periodic routine at 0x19a1 acts only if the word is > 0 (js skips negatives): clears it, calls the protection check 0x19d9 which is a stub returning 0, so the sabotage ([0x15fa0]=[0x15f5e], basemain=atprog) never happens. Port: vprotect = s8(varD7) (byte, not word); protect()/debprot() (fn/script.php:60-73) would sabotage on any non-zero value, but debprot() is never called in the port, so the value has no effect. Net observable behaviour: none in both.",  "fix": "Optional: store s16 and make protect() a no-op for Robinson DOS (the original check always passes)." }, {  "table": "opcodes",  "index": "0x35",  "name": "casleep",  "original_addr": "0x860d",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:455",  "status": "same",  "severity": "none",  "used_by_game": "21",  "details": "Original: eval; if DX (signed 16) >= 0 and [atent([0x15f72]) + movsx DX] != 0 -> byte [vram-4] = 0. Port: same (xread32(atent+varD7), set_0x04_cstart_csleep(vram,0)). Port compares the full PHP int (varD7 can exceed 16 bits after arithmetic), original only DX; irrelevant for entity handles.",  "fix": "" }, {  "table": "opcodes",  "index": "0x36",  "name": "cclock",  "original_addr": "0x85f5",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:3188",  "status": "differs",  "severity": "low",  "used_by_game": "104 (constants 0..70, one expression 'clock 7 + [vb[0x4d] - 102 / 2]')",  "details": "Original: eval; word [vram-0x3a] = DX; dword [vram-0x3e] = ZERO-EXTENDED DX (movzx) + [0x16058] (timeclock). Port: set_0x3a(varD7); set_0x3e(s32(varD7 + timeclock)) with a signed varD7: a negative or > 0xffff value gives a different wake time (original: timeclock + (v & 0xffff)). Robinson uses small positive values only. Related (main loop, not this opcode): the original wake test at 0x3875 is a SIGNED compare (cmp esi,[ebp-0x3e]; jl), the port uses ule() (fn/alis.php:1247).",  "fix": "set_0x3e_wait_time(vram, s32((Alis::$varD7 & 0xffff) + Alis::$timeclock))." }, {  "table": "opcodes",  "index": "0x37",  "name": "canim",  "original_addr": "0x38ef",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:1017",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: a bare ret (no operand). Port: cnul() for version < 60. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x38",  "name": "cscmov",  "original_addr": "0x45b7",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:468",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: 3 exprs x,y,z (pushed); screen = basemain([0x15fa0]) + movsx word [vram-0x16]; if z: word[+0x1a]+=z, bts bit7 of [screen]; if y: [+0x18]+=y, bit7; if x: [+0x16]+=x, bit7. Port v>=30 branch: identical fields (depz 0x1a, depy 0x18, depx 0x16, state |= 0x80) in the same order. Port reads the screen id unsigned (& 0xffff) instead of movsx; no difference for valid ids.",  "fix": "" }, {  "table": "opcodes",  "index": "0x39",  "name": "cscset",  "original_addr": "0x4607",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:502",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: 3 exprs; for z/y/x: if value != current word (+0x1a/+0x18/+0x16) store it and set bit 7 of the screen state. Port v>=30 branch: same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x3a",  "name": "cclipping",  "original_addr": "0x42d3",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:537",  "status": "differs",  "severity": "low",  "used_by_game": "7 (prefs*/newpref* hidden PASSWORD prompt: clipping, locate, sprinta, vinput, switching)",  "details": "Original: byte [0x15fe1] = 0, no operand. In this DOS build the flag is inert: its only readers (0x6374: jz to the next instruction; 0x6404: jnz 0x6472 / jmp 0x6472) take the same path either way, so the original always renders the same way. Port: Alis::$fswitch = 0, and fswitch DOES change the port's rendering (fn/image.php:2620/2710/2832/2975/2982/3023, rrq3d.php:1567: direct drawing instead of the double-buffer path) until the next switching. In Robinson this only covers the debug password prompt, where drawing straight away is probably what the player expects anyway.",  "fix": "For exact fidelity keep the port's rendering path fixed (ignore cclipping/cswitching for Robinson DOS), or accept the current behaviour, which looks fine for the password prompt." }, {  "table": "opcodes",  "index": "0x3b",  "name": "cswitching",  "original_addr": "0x42d2",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:545",  "status": "differs",  "severity": "low",  "used_by_game": "10",  "details": "Original: a bare ret (no-op; the C marks it [N/I] for Robinson's Requiem). Port: Alis::$fswitch = 1 (comment line 544: needed or nothing is shown, since the port's renderer depends on fswitch). Operands are in sync (none). This is a deliberate, documented difference that keeps the port's renderer in the state matching the original's fixed behaviour.",  "fix": "None needed if fswitch=1 is the port's equivalent of the original's only rendering path; document it as platform." }, {  "table": "opcodes",  "index": "0x3c",  "name": "cwlive",  "original_addr": "0x407e",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:585 (get_vector :550, clivin :671)",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original: get_vector 0x7176 (eval form index, form address via 0x7139); form type 0: coordinates from SIGNED bytes (cbw) +4/+5/+6 plus (signed byte +7/+8/+9) sar 1; type 1: words +4/+6/+8 plus (word +0xa/+0xc/+0xe) sar 1 (signed); type>=2: words +2/+4/+6; negative type: fatal error 0x14 (0x144a0); then neg x if byte[vram-0x2e] >= 0x15 and byte[vram-3] != 0. Results -> [0x16028..0x1602c], then the clive body at 0x40b4. Port get_vector reads type-0 bytes with xread8 (UNSIGNED) and type-1 deltas with unsigned xread16 >> 1, so negative byte coordinates / sizes give wrong offsets; negative type silently gives 0,0,0 (and skips the xinv negation). Not used by Robinson.",  "fix": "In get_vector use s8(xread8(...)) for the 6 bytes of type 0 and s16(xread16(...)) >> 1 (arithmetic) for type 1 sizes; optionally treat a negative type as a fatal error like the original." }, {  "table": "opcodes",  "index": "0x3d",  "name": "cunload",  "original_addr": "0x422d",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:594",  "status": "differs",  "severity": "low",  "used_by_game": "154",  "details": "Original: lodsw id -> [0x15e90]; 0xb68b: return if id == -1 or id == [vram-0x10]; find program (0xb770, sorted by id, unsigned compare); end = lowest atprog address above it, else [0x15f66] (finprog); length = end - start; calls 0x108e4 with EAX = length, a sound routine that clears the active byte of sound channel (length) if < 4, or of ALL 4 channels (0x1abb8, stride 0x40) if bit 7 of the low byte is set (looks like a buggy 'stop sounds' call, only when [0x18aaa] sound is on); [0x15f47]=1; shrinkprog 0xb517 (move memory, kill the entities of that script). Port: same id tests, same end search, shrinkprog(start, length, id); it relocates playing samples (audio_relocate) instead of the original's length-dependent channel cut, and adds an interruptible host delay sys_sleep_interactive(unload_delay) (line 626, a platform choice). Operands in sync.",  "fix": "Optional fidelity: before shrinkprog, stop sound channels the way 0x108e4 does with al = length (all channels if (length & 0x80), channel `length` if length < 4)." }, {  "table": "opcodes",  "index": "0x3e",  "name": "cwakeup",  "original_addr": "0x8643",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:632",  "status": "same",  "severity": "none",  "used_by_game": "33",  "details": "Original: eval; if DX >= 0 and atent[DX] != 0 -> byte [vram-4] = 1. Port: same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x3f",  "name": "csleep",  "original_addr": "0x862f",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:652",  "status": "same",  "severity": "none",  "used_by_game": "128",  "details": "Original: byte [ebp-4] = 0; if fseq != 0 jmp 0x41c0 (add esp,4; ret = leaves the script's opcode loop). Port: set_0x04(vram,0); if fseq cstop(). Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0x40",  "name": "clive",  "original_addr": "0x4099",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:661 (clivin :671)",  "status": "differs",  "severity": "low",  "used_by_game": "703",  "details": "Original: [0x16028..2c]=0; lodsw id; 0xb770 finds the program; not found (any id, -1 included): FATAL error 0x15 (0x144a0) then DX=-1 and store. Found: 0xb8ac links a new entity ([0x15e92]; entity count > max -> fatal 5; vram overflow -> fatal 0xc), zeroes its positive area, sets its context; DX = new entity index; copies dword +0/+8/+0x10, word +0x34/+0x38/+0x3c, word -0xe -> new -0x28, dword +0x18/+0x20/+0x28, word +0x40/+0x44/+0x48; adds wcx/wcy/wcz to +0/+8/+0x10; copies -0x16 and -0x22; new -0x2a = new -0xe; stores DX through 0x3bd1 (sd7/oldsd7 swap + storename). Port: same copies and adds, PLUS mem_move(next+0x30, prev+0x30, 2) (line 706) which the original does not do (new +0x30 stays 0). +0x30 is the group word compared by the near/view searches (0x7e06...); nothing in Robinson DOS writes it, so it is 0 everywhere and the extra copy has no visible effect. Error paths: port stores -1 silently for id -1 / unknown id (original aborts); when the entity table is full the port returns at line 738 WITHOUT cstore_continue(), so the store target bytes would be run as opcodes (original: fatal error).",  "fix": "Remove the +0x30 copy for Robinson DOS (version 31 PC) to match 0x40d3-0x418d; at line 738 call cstore_continue() (or raise a fatal error like the original) instead of a bare return." }, {  "table": "opcodes",  "index": "0x41",  "name": "ckill",  "original_addr": "0x41a4",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:750",  "status": "differs",  "severity": "medium",  "used_by_game": "112 (always 'kill vw[...]', handle variables like vw[0x54], vw[0x84], vw[0x52])",  "details": "Original: eval (call 0x9d2a); test dx,dx; js ret; jz ret: entity 0 (the main script) and negative values are ignored. Otherwise [0x15e92]=DX and killent 0xba45 (atent[DX]==0 -> [0x15f9d]=0; else erase its sprites 0x5cf7, move the vram memory down (rep movsw, count (finent-source)>>1), shift the vram pointers >= the killed one, unlink, free slot, dec count; killed == current entity -> current = previous, add sp,8, jmp 0x37df (next entity); else reload the current vram). Port v<60: `elseif (Alis::$varD7 < 0) return;` then killent(varD7 & 0xffff): a value of 0 (a handle variable that was never set or was cleared to 0) KILLS THE MAIN ENTITY 0 in the port, the original does nothing. Port's killent also waits for the music to stop when killing the music script (port addition) and rounds the copy length up instead of down (harmless).",  "fix": "In ckill for version < 60: `if (s16(Alis::$varD7) <= 0) return;` (ignore 0 like the original at 0x41a9-0x41ae)." }, {  "table": "opcodes",  "index": "0xdc",  "name": "ccancall",  "original_addr": "0x5cea",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1211",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: mov byte [0x15f9d],1 (ferase), then calls cerasall (0x5cf7, the 0x50 handler). That walks the screen-element list from [ebp-0x18] and frees each element through 0x5d16; with ferase=1 an element is always unlinked and put on the free list 0x15f90 (0x5d4c..0x5d7d, delprec 0x5d94), then ferase is cleared at 0x5d0e. It reads no operands. The port sets ferase=1, runs the same killelem loop over get_0x18 inline, then ferase=0. Same behaviour.",  "fix": "" }, {  "table": "opcodes",  "index": "0xdd",  "name": "ccancen",  "original_addr": "0x5c89",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1225",  "status": "same",  "severity": "none",  "used_by_game": "2 (main.als:2877 'cancen 33', main.als:2897 'cancen 0')",  "details": "Original: ferase=1, then falls into cerasen (0x5c96). That reads 1 expression and stores its low byte in numelem [0x15fbe]. It loops searchelem (0x56f7: same screen id [ebp-0x16], same numelem) followed by killelem 0x5d16 until nothing is found, then sets ferase=0 (0x5ca8). The port sets ferase=1 and calls cerasen() (opcodes_a.php:1054): readexec_opername_saveD7, numelem=s8, the same searchelem/killelem loop, then ferase=0. Same operands and effects.",  "fix": "" }, {  "table": "opcodes",  "index": "0xde",  "name": "cblast",  "original_addr": "0x4197",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1232 (calls ckill, fn/opcodes_a.php:750)",  "status": "differs",  "severity": "low",  "used_by_game": "68 (main.als 'blast vw[0x3cbc]' x62, 'blast vw[0x84]' x6)",  "details": "Original: ferase=1, then ckill (0x41a4). ckill reads 1 expression (0x9d2a). 'test dx,dx; js; jz' returns when the value is NEGATIVE OR ZERO. Otherwise it stores [0x15e92]=dx and jumps to killent 0xba45. killent calls cerasall in the killed entity (0xba84), and cerasall clears ferase; when the entity's slot is empty, killent clears ferase at 0xba7c. The port v<60 branch of ckill only returns when varD7 < 0, so a value of 0 calls killent(0). Entity 0 is the main script (atent+0 is non-zero), so the port would kill main where the original does nothing. Robinson always guards with '!= -1' after findtyp, so 0 is unlikely in practice. When the value is <= 0, ferase stays 1 in both.",  "fix": "In ckill() (fn/opcodes_a.php:758), for version < 60 test 'if (Alis::$varD7 <= 0) return;' to match 0x41a9..0x41ae (js + jz). This also fixes cblast." }, {  "table": "opcodes",  "index": "0xdf",  "name": "cscback",  "original_addr": "0x51ea",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1278",  "status": "differs",  "severity": "low",  "used_by_game": "0",  "details": "Original DOS RRQ: it pushes the old sback, reads 6 expressions into globals (byte [0x178b1]=sback, words [0x178bf]=backprof, [0x178c1]=x1, [0x178c3]=y1, [0x178c5]=x2, [0x178c7]=y2), pops dx and returns. Nothing else happens: no iniback, no background-sprite setup, no screen flag. [0x178b1] is read nowhere else in the image, so the feature is dead in this executable. The port consumes the same 6 operands (in sync), but for v>=30 it also runs iniback(), sets up the backsprite, flips screen bit 2 and calls rangesprite. The original does none of this. Robinson never uses the opcode.",  "fix": "Optional: for EGameRobinsonsRequiem0/1 (DOS), store the 6 values and return without the iniback/backsprite block." }, {  "table": "opcodes",  "index": "0xe0",  "name": "cscrolpage",  "original_addr": "0x51a0",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1359",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: 4 expressions go to byte [0x178f3]=spag, words [0x178f5]=pagdx, [0x178f7]=pagdy, [0x178f9]=pagcount. If spag != 0, it ORs 0x20 into byte 0 of the screen (basemain+[ebp-0x16]). The port does the same with a byte read-modify-write.",  "fix": "" }, {  "table": "opcodes",  "index": "0xe1",  "name": "cmatent",  "original_addr": "0x761c",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1376",  "status": "same",  "severity": "none",  "used_by_game": "2 (souris.als:87,90)",  "details": "Original: ebx=[0x1603e] (ptrent, a pointer into tablent 0x17a2a), dx = word [ebx-2+0x100] (matent of the last entry), then jumps to cstore's continuation 0x3bd1, which swaps the 0x16008/0x16010 string buffers and dispatches the storename. The Ghidra listing shows the dispatch through 0x189a2. The port does varD7 = matent[ptrent-1] then cstore_continue(), which is equivalent. Edge case: with ptrent == tablent, the original reads the word before matent, while the port indexes matent[-1] (a PHP undefined index, i.e. a warning). Unreachable after a findtyp/findmat that found something.",  "fix": "" }, {  "table": "opcodes",  "index": "0xe2",  "name": "cshrink",  "original_addr": "0xb428",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1390",  "status": "differs",  "severity": "medium",  "used_by_game": "9 (human.als: 'shrink vw[0x5e], 0')",  "details": "Original: 2 expressions (the bitmap index stays in dx, the second goes to cx and is unused). It sets flagmain [0x15fc7]=0 and resolves the bitmap through adresdes 0x5c01. Only formats 0x00/0x02/0x10/0x12 (cl=0) and 0x14/0x16 (cl=1) are handled; ANY other format returns at once (0xb469). size = ((movsx w + 1) >> 1) * (movsx h + 1), doubled when cl=1, i.e. ((w+1)>>1)*2*(h+1) for 0x14/0x16. It returns if h == 0. It relocates every resource offset whose target is strictly above the bitmap, subtracts the size from header +6 and +0xc, sets w=0xf and h=0, and memmoves [bmp+6+size, finprog) down by size (0xb517, finprog -= size, program table relocated). The port differs in two places (opcodes_b.php:1400-1410). (1) It shrinks formats 0x18/0x1a/0x1c/0x1e (width w+1), where the original does nothing. (2) For 0x14/0x16 it uses (w+1)*(h+1) instead of ((w+1)>>1)*2*(h+1), which is 1 byte per row larger when w+1 is odd. Operand count, the relocation loop and the finprog shift otherwise match. If the human.als bitmaps are type 0x1c/0x1e, the port deletes data the original keeps.",  "fix": "In cshrink(): for v3 DOS (EGameRobinsonsRequiem0/1), compute width = (w+1)>>1 for 0/2/0x10/0x12 and ((w+1)>>1)*2 for 0x14/0x16, and return for every other format (drop the 0x18/0x1a and 0x1c/0x1e branches)." }, {  "table": "opcodes",  "index": "0xe3",  "name": "cdefmap",  "original_addr": "0x493b",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1449 (RRQ branch 1486-1550)",  "status": "differs",  "severity": "low",  "used_by_game": "2 (main.als:2384,2387)",  "details": "Original: vaddr (lodsw, 0 = main + lodsw) then 7 expressions. [m-0x400]=dl. Expression 2 is stored BYTE-SWAPPED: [m-0x3fe]=dh, [m-0x3fd]=dl (0x4966). [m-0x3fc]=[ebp-0xe]. [m-0x3fa]=[m-0x3f8]=e3, and [m-0x3f8] += e4-1. [m-0x3f4], [m-0x3f2], [m-0x3f0] get e5..e7 with NO clamping of 0 to 1. [m-0x3ff]=0, dword [m-0x3dc]=4, [m-0x3d8]=0x7f. If byte [m-1] < 0: ecx=[m-6], eax=[m-0xa] (32-bit), else 16-bit words [m-4], [m-6]. Then 'cdq; div ecx' with the FULL 32-bit divisor, ax to -0x3c6 and -0x3cc, cx to -0x3c4, cx>>1 to -0x3ca. word [EBP-0x3b6]=0 (0x4a32): written relative to the calling SCRIPT's variables, not to the map. Then the bit counts go to -0x3c0, -0x3be, -0x3bc; the 0x0a test is dead code. The port differs in four ways. (a) xwrite16 at 1498 stores e2 little-endian on DOS: for 'defmap ..., 9, 256, ...' the original has byte -0x3fe=1, -0x3fd=0, the port the reverse. The only reader in the original is 'test byte [rc-0x3fe],2' (0x12d91/0x12eb9); the port's renderer reads byte -0x3fe == 1 (rrq3d_dos.php:1005). With the values Robinson uses both results are false, by coincidence. (b) Line 1540 clears mapram-0x3b6 instead of vram-0x3b6. The original never resets map[-0x3b6], which the renderer reads at 0x1329b and chartmap writes at 0x5171. (c) It clamps 0 to 1 for -0x3f4/-0x3f2/-0x3f0 (1506-1520). (d) It masks the divisor to 16 bits (1535). With Robinson's arguments ([m-6]=512, no zeros, main has no var 0x3b6) none of these changes the result today.",  "fix": "For DOS: write e2 as xwrite8($m-0x3fe, v>>8); xwrite8($m-0x3fd, v&0xff). Replace line 1540 with xwrite16(Alis::$script->vram_org - 0x3b6, 0). Drop the 0->1 clamps. Divide by the full $valb when byte [m-1] < 0. Then make rrq3d_dos.php:1005 test (byte[-0x3fe] & 2) to match 0x12d91." }, {  "table": "opcodes",  "index": "0xe4",  "name": "csetmap",  "original_addr": "0x4ab1",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1568",  "status": "same",  "severity": "none",  "used_by_game": "4 (map.als:66,69,72; main.als:2385)",  "details": "Original: vaddr then 6 expressions. -0x3ee, -0x3ec, -0x3ea and -0x3e8 get e1..e4; -0x3d6 = e4-1, and -0x3ee += (e4-1)>>1 (16-bit shr). -0x3e6 and -0x3e4 get e5, e6; -0x3d4 = e6-1, and -0x3ea += (e6-1)>>1. The port's RRQ branch is the same, with 16-bit masks.",  "fix": "" }, {  "table": "opcodes",  "index": "0xe5",  "name": "cputmap",  "original_addr": "0x4b4d",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1675 (RRQ branch 1748-1785)",  "status": "differs",  "severity": "low",  "used_by_game": "1 (map.als:74 'putmap &m[0x39ac], 0, 0, 0, 1')",  "details": "Original: vaddr then 4 expressions. -0x3e2, -0x3e0 and -0x3de get e1..e3. e4 goes to [0x15fbe] as a WORD (numelem plus byte 0x15fbf, which is never read alone). Then 'mov dx,0; mov ax,[m-0x3de]; div word [m-0x3f0]' (16-bit unsigned dividend) and the remainder goes to -0x3d2. fmuldes [0x15fc5]=0. searchelem, else createlem 0x5769; state=2 if >= 0. putin-common at 0x55a3 with ebx=m-0x3dc. Then a second searchelem; if found: +0x1c=0xff, +0x23=0, +0x21=0, depx/y/z = -0x3ee/-0x3ec/-0x3ea. The port matches, except that umod32 at 1758 uses the SIGN-EXTENDED s16 as the dividend: for a negative position and a width that is not a power of two the remainder differs. Robinson passes 0, so no effect. Not compared in this audit: the inner put routine (0x55a3 vs putmapin, image.php:1414).",  "fix": "Line 1757: $map_pos = xread16($map_base - 0x3de) & 0xffff (16-bit unsigned dividend, as the original's div word)." }, {  "table": "opcodes",  "index": "0xe6",  "name": "csavepal",  "original_addr": "0x88bf",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1790 (dos_csavepal image.php:708)",  "status": "same",  "severity": "none",  "used_by_game": "3 (srain.als:55, playfilm.als:116, time.als:456: 'savepal -1')",  "details": "Original: 1 expression. Only for -2 <= v <= -1 it copies 0x180 words (768 bytes) of the target palette 0x1682f into 0x16b6f (v=-1) or 0x16e6f (v=-2); every other value does nothing. The port's dos_csavepal copies dpal_tpal into dpal_sav1/dpal_sav2 for -1/-2 (B32 family), which is equivalent.",  "fix": "" }, {  "table": "opcodes",  "index": "0xe7",  "name": "csczoom",  "original_addr": "0x433b",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1801",  "status": "missing_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original: reads 3 expressions (e1 pushed, e2 to cx, e3 to dx). On the screen (basemain + [ebp-0x16]): word +0x3a=e1, +0x3c=e2, +0x3e=e3, then 'bts dword [scr],7' (screen byte 0, bit 7). The port does nothing for DOS and reads NO operands; Lang/Grammar.php:79 also gives it ''. If a script used it, the stream would desync by 3 expressions. Robinson does not use it.",  "fix": "For DOS RRQ: 3x readexec_opername into screen +0x3a/+0x3c/+0x3e (16-bit), then xwrite8($scr, xread8($scr) | 0x80). Grammar 0xe7 => 'E E E' for v3 DOS." }, {  "table": "opcodes",  "index": "0xe8",  "name": "ctexmap",  "original_addr": "0x4c50",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:1818",  "status": "differs",  "severity": "medium",  "used_by_game": "393 (cglace, jungle, cqg, ctyra, clarve, coo, desert, foret, marais, canyon)",  "details": "Original: vaddr goes to [0x15ece]; slot via 0x9d06 goes to [0x15e9a]; entry = scene + movsx16(slot*0x20 + 0xf400). [e+8]=dl of E1, then E2. If [e+8]==0: [e+4]=0, [e]=0, [e+2]=0. If > 0: [e+4] = adresdes slot (0x5c46, which honours the CURRENT flagmain: ctexmap never clears 0x15fc7). bmp = slot + [slot]; [e] = bit count of [bmp+2]; [e+2]=0. Opaque-row scan: esi = bmp+8 ALWAYS, 'mov cx,[bmp+2] ... dec cl; jns' (an 8-BIT counter per row). If a row has no zero byte: yorigin = h - rows_left goes to [e+2], and if non-zero, y_mask is snapped with the 15-word table at 0x1620d: [0,1,3,7,0xf,0x1f,3,0x7f,0xff,...,0x3fff] (exact match keeps; otherwise T[i-1]+yorigin at the first entry above; past the table, T[14]+yorigin). Then E3 to word +0xa, E4 to byte +9, E5 to word +0xe, E6 to byte +0x14 (type). Type 2: +0x16=E7, two discarded, +0x1a=E10. Type < 0: +0x10/+0x12/+0x16/+0x1a, then +0x10 = (x*[scene-0x3ca] + y)*2 (imul 16x16, 32-bit). Every other type, INCLUDING 0: read E7; +0x10 = 0 for type 0, adresdes(E7) for positive types; then +0x16=E8 (word), +0x15=E9 (byte), +0x1a=E10 (word), +0x1c=[ebp-0xe]. Port differences: (1) type 0 (1953-1958) skips the 4 operands and does not write +0x10=0, +0x16, +0x15, +0x1a or +0x1c=entity. Robinson uses type 0 with non-zero values, e.g. jungle.als:22 '..., 0, 0, 0, 1, 0' sets +0x1a=1 in the original; the port keeps stale values (the renderer gates on +0x14 first, which limits the impact). (2) The scan offset is 6 for formats 0/2 (1859); the original always uses 8. (3) The row loop counts x_mask+1 bytes with an s16 counter (1885); the original counts (x_mask & 0xff)+1 and, for low byte >= 0x80 (e.g. a 256-wide texture, x_mask=0xff), checks only 1 byte per 'row' and walks the bitmap contiguously, so yorigin and y_mask come out different. (4) The snap table is POW2M1=[1..32767] (Opcodes2Vars.php:33); the image's table has 0 first, 3 instead of 0x3f at index 6 (bytes at 0x16219), and stops at 0x3fff. For an available height of 32..126 (other than 127) the original sets y_mask = 3+yorigin, and above 16383 it sets 0x3fff+yorigin; the port leaves it unchanged. (5) The port sets flagmain=0 at entry (inherited from the C); the original keeps the flagmain left by the last put*/mput* (0xa8-0xab set it to 1). (6) The port turns type < 0 into type 0 when the offset is negative (1971); the original does not.",  "fix": "In ctexmap(): make the 'type == 0' branch share the positive path: readexec_opername(); xwrite32(e+0x10, 0); then E8 to +0x16 (16-bit), E9 to +0x15 (8-bit), E10 to +0x1a (16-bit), and +0x1c = xread16(vram-0xe). For DOS, use $pixel_offset=8 always, and count each row with an 8-bit counter: $cl = x_mask & 0xff; do {...; $cl = ($cl-1)&0xff;} while ($cl < 0x80). Replace POW2M1 with the image's table [0,1,3,7,15,31,3,127,255,511,1023,2047,4095,8191,16383], and when no entry is larger, write T[14]+yorigin. Do not clear flagmain, and drop the 'tex_offset < 0' reset for DOS." }, {  "table": "opcodes",  "index": "0xe9",  "name": "calloctab",  "original_addr": "0x48c8",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2051",  "status": "differs",  "severity": "low",  "used_by_game": "3 (main.als:2379-2382)",  "details": "Original: vaddr (0x4924) goes to edi. If byte [cell-1] < 0: size = [cell-6-4*(flag&0xf)] and malloc(size + 0x800) (0x1c58 returns a handle). Then [handle] = ([handle] + 0x7ff) & ~0x7ff, aligning the data pointer to 2 KB while +4 keeps the raw pointer for mfree, and [cell] = handle. It does NOT check whether [cell] is already non-zero: a repeated call leaks the old block. The port returns when [cell] != 0, allocates exactly size, and does not align. The handle layout is otherwise the same. No masking of 2 KB-aligned addresses was found in the renderer, so the visible effect is nil. The extra 0x800 per table only changes how fast memory fills.",  "fix": "Optional: allocate size+0x800 and align xwrite32($h, (xread32($h)+0x7ff) & ~0x7ff) for exact memory layout. Keep or drop the [cell]!=0 guard knowingly: the original re-allocates." }, {  "table": "opcodes",  "index": "0xea",  "name": "cfreetab",  "original_addr": "0x4906",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2068",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: vaddr; if byte [cell-1] < 0 and [cell] != 0: [cell]=0, then mfree(handle) (0x1ca2: [handle]=0; if the block is the lowest, finmem += size). The port, for v3: same tests, [cell]=0, io_mfree($h). The port also zeroes handle+4, which is harmless.",  "fix": "" }, {  "table": "opcodes",  "index": "0xeb",  "name": "cscantab",  "original_addr": "0x48c6",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:173",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original handler is a bare 'ret': no operands, no effect. The port's function is empty, and the grammar has no operands for it.",  "fix": "" }, {  "table": "opcodes",  "index": "0xec",  "name": "cneartab",  "original_addr": "0x48c7",  "port_location": "games/alis/src/Alis/fn/opcodes_a.php:179",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original handler is a bare 'ret': no operands, no effect. The port's function is empty.",  "fix": "" }, {  "table": "opcodes",  "index": "0xed",  "name": "cscsun",  "original_addr": "0x450b",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2096",  "status": "missing_in_port",  "severity": "low",  "used_by_game": "0",  "details": "Original: reads 4 expressions. Screen (basemain + [ebp-0x16]) words +0x7c=e1, +0x7e=e2, +0x80=e3, +0x82=e4, then 'bts dword [scr],7'. The port, for version < 60, returns without reading any operand; Grammar.php:81 gives ''. A use would desync the stream by 4 expressions. Robinson does not use it.",  "fix": "For v3 DOS: 4x readexec_opername into screen +0x7c/+0x7e/+0x80/+0x82 (16-bit), then set bit 7 of screen byte 0. Grammar 'E E E E' for v3." }, {  "table": "opcodes",  "index": "0xee",  "name": "cdarkpal",  "original_addr": "0x87e8",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2136 (scan at 2204)",  "status": "differs",  "severity": "high",  "used_by_game": "52 (cglace, and others: 'darkpal 256,256,256,0,160' resets, then 'darkpal mw[0x3bec],mw[0x3bee],mw[0x3bf0], 80|96|112|128|144, 16')",  "details": "Original: 5 expressions go to [0x178fd] R, [0x178ff] G, [0x17901] B, [0x17903] first, [0x17905] count. It fills `count` RGB word triples of dkpalet (0x1716f) from `first`, with no clamping, then dkpalet[0..2]=0 and fdarkpal [0x178fb]=1. It scans 0x2fd words from 0x17175 (dkpalet[3]..[767], i.e. ALL 256 colours) and clears fdarkpal only if every one is 0x100. The port (non-Deus path) scans only dkpalet[3..0xb5] (colours 1..60) at line 2204, and only recomputes when first < 0x100. Failure case: after 'darkpal 256,256,256,0,160' (neutral), 'darkpal r,g,b,112,16' darkens colours 112..127. The original sets fdarkpal=1; the port finds 3..0xb5 all equal to 0x100 and sets fdarkpal=0. dpal_load_dark (image.php:560/577) is then skipped, so the darkening is lost. The clamp of first+count to 256 is harmless for Robinson's values (max 0+256).",  "fix": "In cdarkpal(), for bpp==8 (DOS RRQ), scan the whole palette like the Deus branch: for ($i = 3; $i < 0x300; $i++). Recompute fdarkpal (set to 1, cleared only if all 0x100) on every call, not only when $darkpac < $val0." }, {  "table": "opcodes",  "index": "0xef",  "name": "cscdark",  "original_addr": "0x43f0",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2216",  "status": "differs",  "severity": "low",  "used_by_game": "10 (jungle, clarve, desert, canyon...)",  "details": "Original: screen = basemain + [ebp-0x16]. word +0x98=e1. e2 goes through adresdes 0x5c01 (resolved; uses the CURRENT flagmain, which is not cleared) into +0x9a. word +0x9e=e3, and basedark [0x1aafe]=e3. +0xa0 = [[+0x9a]+4]+1; if +0x9e < 0, +0x9e = +0xa0 >> 1 (shr) and basedark follows. Then the selector base [0x1aafc] is set to [+0x9a]+8 (0x424: the dark-table segment, i.e. the port's ptrdark), and 'bts [scr],7'. The port matches, except that it forces flagmain=0 at entry (inherited from the C), so the resource always comes from the current script. The original would take main's table if the last put was an mput* (0xa8-0xab). Setting ptrdark through the segment base is platform.",  "fix": "Optional: do not clear Alis::$flagmain in cscdark (and ctexmap) for DOS RRQ, to match 0x43f0, which never writes 0x15fc7." }, {  "table": "opcodes",  "index": "0xf0",  "name": "caset",  "original_addr": "0x5e1c",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2252",  "status": "same",  "severity": "none",  "used_by_game": "2 (combat.als:126,851)",  "details": "Original: 3 expressions into words [es:ebp+0x18], [ebp+0x20], [ebp+0x28] (ebp = current script vram). The port does xwrite16 at vram+0x18/+0x20/+0x28 for v>=30. Same.",  "fix": "" }, {  "table": "opcodes",  "index": "0xf1",  "name": "camov",  "original_addr": "0x5e3b",  "port_location": "games/alis/src/Alis/fn/opcodes_b.php:2269",  "status": "same",  "severity": "none",  "used_by_game": "0",  "details": "Original: 3 expressions, each ADDed (16-bit) to [ebp+0x18], [ebp+0x20], [ebp+0x28]. The port does xadd16 on the same offsets. Same.",  "fix": "" }]