From 869d5b1976fddfc424323311bf5a5539b99cb200 Mon Sep 17 00:00:00 2001 From: gsemaj Date: Wed, 10 Aug 2022 21:03:56 -0400 Subject: [PATCH] Add support for SetTexture --- dx2cg/disassembler.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/dx2cg/disassembler.py b/dx2cg/disassembler.py index 57d7aa2..b0aad29 100644 --- a/dx2cg/disassembler.py +++ b/dx2cg/disassembler.py @@ -100,6 +100,7 @@ def process_header(prog): binds = [] i = 0 lighting = False + textures = 0 while i < len(prog): line = prog[i] if line.startswith("Keywords"): @@ -150,11 +151,22 @@ def process_header(prog): raise ValueError(f"Unrecognized glstate: {val}") if dec[0] == "Local": - loctab[key] = val + loctab[f"c{key}"] = val elif dec[0] == "Matrix": for offset in range(0,4): - loctab[key + offset] = f"{val}[{offset}]" + loctab[f"c{key + offset}"] = f"{val}[{offset}]" + del prog[i] + i = i - 1 + elif line.startswith("SetTexture"): + dec = line.split(' ') + if dec[2] != "{2D}": + raise ValueError(f"Unknown texture type {dec[2]}") + key = f"s{textures}" + val = dec[1][1:-1] + loctab[key] = val + textures = textures + 1 + del prog[i] i = i - 1 i = i + 1 @@ -167,6 +179,8 @@ def process_header(prog): if lighting: header.append("Lighting On") + + # print(loctab) return (keywords, header, loctab, locdecl) @@ -193,8 +207,9 @@ def resolve_args(args, loctab, consts): pass elif arg[0] == 'c': if arg not in consts: - key = int(arg[1:]) - arg = loctab[key] + arg = loctab[arg] + elif arg[0] == 's': + arg = loctab[arg] elif arg[0] == 'o': arg = f"o.{arg[1:].lower()}" elif re.match("[+-]?([0-9]*[.])?[0-9]+", arg):