IT
games/alis / src / Alis / R3doVars.php · commit 9c722cf
<?phpnamespace App\Alis;/** * File-scope variables of alis/src/render/rrq3d_3do.c (RRQ 3DO renderer, see docs/porting.md). * * PORT: the C structs become PHP arrays: *  - mat3d  = flat int array [m0..m8 (s16), t0, t1, t2] (12 entries); *  - view3d = flat int array [mat3d (0..11), fx, fy, cx, cy, near] (17 entries); *  - pt3d   = [x, z, y, valid] (screen x, depth, screen y); *  - cel3d  = ['img', 'p' => [8 ints], 'pixc', 'accw', 'depth', 'owner', 'aux'] (no next pointer: a *    bucket is a PHP list in insertion order, walked from its end = the C linked list order); *  - celedge = [y0, y1, x, dx, u, du, v, dv]; *  - celmap = ['ax','ay','ex','ey','fx','fy','gx','gy','k2','eu','ev'] (floats). */final class R3doVars{    /** C: static s32 *costab [0x1000] (null until tables()) */    public static ?array $costab = null;    /** C: static s32 *recip [0x8000], 0x40000 / i */    public static array $recip = [];    /** C: static int done (tables()) */    public static int $tables_done = 0;    /** C: static const u32 pixctab[15] */    public const pixctab = [        0, 0x03000300, 0x08000800, 0x02000200, 0x10001000, 0x0b000b00, 0x18001800, 0x01000100,        0x13001300, 0x0a000a00, 0x1b001b00, 0x05000500, 0x12001200, 0x09000900, 0x1a001a00,    ];    /** C: static cel3d *bucket[BUCKETS]: bucket index => list of cel3d arrays (insertion order) */    public static array $bucket = [];    /** C: static int ncel */    public static int $ncel = 0;    /** C: static int maxbucket = -1 */    public static int $maxbucket = -1;    /** C: static int drewland */    public static int $drewland = 0;    /** C: static struct { u32 img, len; u8 sig[48]; s32 w, h; u16 *px; } tex[TEXMAX]:     *  list of ['img', 'len', 'sig' (48-byte string), 'w', 'h', 'px' (int array)] */    public static array $tex = [];    /** C: static int ntex */    public static int $ntex = 0;    /** C: static u32 texbytes */    public static int $texbytes = 0;    /** C: static u32 pixlut[3][32]: the three channels hold the same 8-bit level (only shifted in C),     *  so one table of 8-bit levels */    public static array $pixlut = [];    /** C: static u32 pixlutc = 1 */    public static int $pixlutc = 1;    /** PORT: cache texel (u16) => 3-byte B,G,R string for the current pixlut (reset with it) */    public static array $pixstr = [];    /** C: static struct { const u16 *px; s32 w, h, cx1, cy1, cx2, cy2, ytop, ybot, ymin, ymax; } cc; */    public static array $cc_px = [];    public static int $cc_w = 0;    public static int $cc_h = 0;    public static int $cc_cx1 = 0;    public static int $cc_cy1 = 0;    public static int $cc_cx2 = 0;    public static int $cc_cy2 = 0;    public static int $cc_ytop = 0;    public static int $cc_ybot = 0;    public static int $cc_ymin = 0;    public static int $cc_ymax = 0;}