IT
games/alis / src / Alis / Deus3dVars.php · commit 9c722cf
<?phpnamespace App\Alis;/** File-scope variables of alis/src/render/deus3d.c (see docs/porting.md and fn/deus3d.php). */final class Deus3dVars{    /** Slot index of the clip node sV6CNode v6x3d_cnode[0] (k-th node: CN + 2 * k), after the 0x4000 cache slots. */    public const CN = 0x4000;    /** Slot index of v6x3d_cnode_ctr. */    public const CNCTR = 0x4000 + 10;    /** C: sV6Shad v6shad (also read by opcodes.c) */    public static sV6Shad $v6shad;    /** C: v6shad_fogrows() static s16 stepR, stepG, stepB */    public static int $fog_stepR = 0;    public static int $fog_stepG = 0;    public static int $fog_stepB = 0;    /** C: sV6Ctx v6tf_objcam, v6tf_camobj, v6tf_light, v6tf_parentctx (global); v6tf_w2c, v6tf_c2w, v6tf_destacc, v6tf_scratch (static) */    public static sV6Ctx $v6tf_objcam;    public static sV6Ctx $v6tf_camobj;    public static sV6Ctx $v6tf_light;    public static sV6Ctx $v6tf_parentctx;    public static sV6Ctx $v6tf_w2c;    public static sV6Ctx $v6tf_c2w;    public static sV6Ctx $v6tf_destacc;    public static sV6Ctx $v6tf_scratch;    /** C: s32 v6tf_eye[4] */    public static array $v6tf_eye = [0, 0, 0, 0];    /** C: u8 v6tf_cacheon */    public static int $v6tf_cacheon = 0;    /** C: static sV6Ctx *v6tf_out */    public static ?sV6Ctx $v6tf_out = null;    /** C: static u8 v6tf_srcflags; u16 v6tf_srcscale; u32 v6tf_camera */    public static int $v6tf_srcflags = 0;    public static int $v6tf_srcscale = 0;    public static int $v6tf_camera = 0;    /** C: static u8 v6tf_pool[0x8020]: the sV6Ctx records keyed by byte offset (v6tf_poolctx()) */    public static array $v6tf_pool = [];    /** C: static u32 v6tf_poolnext, v6tf_poolend, v6tf_hits, v6tf_allocs */    public static int $v6tf_poolnext = 0;    public static int $v6tf_poolend = 0;    public static int $v6tf_hits = 0;    public static int $v6tf_allocs = 0;    /** C: static u32 v6x3d_slothead[0x2000]; u8 v6x3d_slotdirty[0x200] */    public static array $v6x3d_slothead = [];    public static array $v6x3d_slotdirty = [];    /** C: face-record arena */    public static int $v6x3d_arena = 0;    public static int $v6x3d_arenacur = 0;    public static int $v6x3d_arenalim = 0;    public static int $v6x3d_shl16 = 0;    /** C: frame counters */    public static int $v6x3d_cntfaces = 0;    public static int $v6x3d_cntverts = 0;    /** C: u8 v6x3d_heapmoved (global, written by opcodes.c) */    public static int $v6x3d_heapmoved = 0;    /** C: static sV6Row v6x3d_rows[500], one array per field */    public static array $row_lx = [];    public static array $row_lv = [];    public static array $row_lu = [];    public static array $row_lv15 = [];    public static array $row_lu15 = [];    public static array $row_lz15 = [];    public static array $row_lband = [];    public static array $row_rband = [];    public static array $row_rx = [];    public static array $row_rv = [];    public static array $row_ru = [];    public static array $row_rv15 = [];    public static array $row_ru15 = [];    public static array $row_rz15 = [];    public static array $row_rowoff = [];    /** C: pick state */    public static int $v6x3d_pick = 0;    public static int $v6x3d_pickhit = 0;    public static int $v6x3d_pickx = 0;    public static int $v6x3d_picky = 0;    public static int $v6x3d_pickrec = 0;    /** C: static sV6Light v6x3d_light[0x40]; int v6x3d_nlights */    public static array $v6x3d_light = [];    public static int $v6x3d_nlights = 0;    /** C: sV6Fog v6x3dfog */    public static sV6Fog $v6x3dfog;    /** C: collision probe */    public static array $v6col_pw = [0, 0, 0, 0];    public static array $v6col_pc = [0, 0, 0];    public static int $v6col_r7 = 0;    public static int $v6col_r2 = 0;    public static int $v6col_r = 0;    public static int $v6col_matout = 0;    public static int $v6col_facesA = 0;    public static int $v6col_verts = 0;    public static int $v6col_mats = 0;    /** C: static u8 v6col_fbits[0x2000] */    public static array $v6col_fbits = [];    /** C: rasteriser latches */    public static int $v6x3d_fogbase = 0;    public static int $v6x3d_bands = 0;    public static int $v6x3d_ae98 = 0;    public static int $v6x3d_ae9c = 0;    public static int $v6x3d_ae5f = 0;    public static int $v6x3d_res = 0;    public static int $v6x3d_texw = 0;    public static int $v6x3d_texw8 = 0;    public static int $v6x3d_texh = 0;    /** C: static sV6RastWS v6x3d_ws */    public static int $ws_y = 0;    public static int $ws_n = 0;    public static int $ws_cur = 0;    public static int $ws_first = 0;    public static int $ws_end = 0;    /** @var sV6RastEdge[] C: sV6RastEdge e[2] */    public static array $ws_e = [];    /** C: static u16 v6p_ustep[64] */    public static array $v6p_ustep = [];    /** C: static sV6Lat v6x3d_lat */    public static int $lat_ae3c = 0;    public static int $lat_ae40 = 0;    public static int $lat_ae44 = 0;    public static int $lat_ae48 = 0;    public static int $lat_ae4c = 0;    public static int $lat_ae50 = 0;    public static int $lat_ae54 = 0;    public static int $lat_fogsel = 0;    public static int $v6x3d_scale4 = 0;    public static int $v6x3d_b544 = 0;    public static int $v6x3d_lighton = 1;    public static array $v6x3d_b660 = [0, 0, 0];    /** C: static u8 v6x3d_vbits[0x2000] */    public static array $v6x3d_vbits = [];    /** C: static sV6Slot v6x3d_vcache[0x4000] + the clip nodes: one array per field, indexed by slot */    public static array $sl_sx = [];    public static array $sl_d = [];    public static array $sl_sy = [];    public static array $sl_u = [];    public static array $sl_v = [];    public static array $sl_n0 = [];    public static array $sl_n1 = [];    public static array $sl_n2 = [];    public static array $sl_b = [];    /** C: sV6CNode camx / rawd / camy, indexed by the node slot */    public static array $cn_camx = [];    public static array $cn_rawd = [];    public static array $cn_camy = [];    public static int $v6x3d_vertbase = 0;    public static int $v6x3d_matbase = 0;    public static int $v6x3d_b530 = 0;    public static int $v6x3d_b54c = 0;    public static int $v6x3d_near = 0;    public static int $v6x3d_ae92 = 0;    public static int $v6x3d_ae94 = 0;    public static int $v6x3d_ae58 = 0;    public static int $v6x3d_ae59 = 0;    public static int $v6x3d_ae5a = 0;    public static int $v6x3d_ae5c = 0;    public static int $v6x3d_ae5d = 0;    public static int $v6x3d_ae5e = 0;    /** C: u32 v6x3d_tick (global, bumped by image.c v6x_draw) */    public static int $v6x3d_tick = 0;    /** C: clip constants */    public static int $v6x3d_b6cc = 0;    public static int $v6x3d_b6d0 = 0;    public static int $v6x3d_b6d4 = 0;    public static int $v6x3d_b6dc = 0;    public static int $v6x3d_b6e0 = 0;    public static int $v6x3d_cscratch = 0;    /** C: static u8 v6x3d_fbits[0x2000] */    public static array $v6x3d_fbits = [];    public static int $v6x3d_fake = 0;    /** C: s32 v6x_walkzoff; s16 v6x_walkaoff (global, written by opcodes.c) */    public static int $v6x_walkzoff = 0;    public static int $v6x_walkaoff = 0;    public static function init(): void    {        self::$v6shad = new sV6Shad();        foreach (['v6tf_objcam', 'v6tf_camobj', 'v6tf_light', 'v6tf_parentctx', 'v6tf_w2c', 'v6tf_c2w', 'v6tf_destacc', 'v6tf_scratch'] as $p) {            self::${$p} = new sV6Ctx();        }        self::$v6tf_out = null;        self::$v6tf_pool = [];        self::$v6x3d_slothead = array_fill(0, 0x2000, 0);        self::$v6x3d_slotdirty = array_fill(0, 0x200, 0);        self::$row_lx = array_fill(0, 500, 0);        self::$row_lv = array_fill(0, 500, 0);        self::$row_lu = array_fill(0, 500, 0);        self::$row_lv15 = array_fill(0, 500, 0);        self::$row_lu15 = array_fill(0, 500, 0);        self::$row_lz15 = array_fill(0, 500, 0);        self::$row_lband = array_fill(0, 500, 0);        self::$row_rband = array_fill(0, 500, 0);        self::$row_rx = array_fill(0, 500, 0);        self::$row_rv = array_fill(0, 500, 0);        self::$row_ru = array_fill(0, 500, 0);        self::$row_rv15 = array_fill(0, 500, 0);        self::$row_ru15 = array_fill(0, 500, 0);        self::$row_rz15 = array_fill(0, 500, 0);        self::$row_rowoff = array_fill(0, 500, 0);        self::$v6x3d_light = [];        for ($i = 0; $i < 0x40; $i++) {            self::$v6x3d_light[$i] = new sV6Light();        }        self::$v6x3dfog = new sV6Fog();        self::$v6col_fbits = array_fill(0, 0x2000, 0);        self::$ws_e = [new sV6RastEdge(), new sV6RastEdge()];        self::$v6p_ustep = array_fill(0, 64, 0);        self::$v6x3d_vbits = array_fill(0, 0x2000, 0);        self::$v6x3d_fbits = array_fill(0, 0x2000, 0);        self::$sl_sx = array_fill(0, self::CNCTR + 2, 0);        self::$sl_d = array_fill(0, self::CNCTR + 2, 0);        self::$sl_sy = array_fill(0, self::CNCTR + 2, 0);        self::$sl_u = array_fill(0, self::CNCTR + 2, 0);        self::$sl_v = array_fill(0, self::CNCTR + 2, 0);        self::$sl_n0 = array_fill(0, self::CNCTR + 2, 0);        self::$sl_n1 = array_fill(0, self::CNCTR + 2, 0);        self::$sl_n2 = array_fill(0, self::CNCTR + 2, 0);        self::$sl_b = array_fill(0, self::CNCTR + 2, 0);        self::$cn_camx = array_fill(0, self::CNCTR + 2, 0);        self::$cn_rawd = array_fill(0, self::CNCTR + 2, 0);        self::$cn_camy = array_fill(0, self::CNCTR + 2, 0);    }}// C globals are zero / statically initialised at program start: initialise on class load.Deus3dVars::init();