<NME> LARA1.C
<BEF> #include "LARA1.H"

#include "3D_OBJ.H"
#include "MISC.H"
#include "CAMERA.H"
#include "DRAWSPKS.H"
#include "DELSTUFF.H"
#include "LARA.H"
#include "MATHS.H"
#include "DRAW.H"
#include "SETUP.H"
#include "GTEREG.H"
#include "GPU.H"
#include "TOMB4FX.H"
#include "HAIR.H"
#include "LOAD_LEV.H"

static int scratchPad[256];


void sub_FC0L1(int x, int y, int z)
{
    int t0 = 0;
    int t1 = 0;
    int t2 = 0;
	int t3 = 0;
	int t4 = 0;
	int t5 = 0;

	t0 = TRX;
    t1 = TRY;
    t2 = TRZ;

    x -= t0;
    y -= t1;
    z -= t2;

    t4 = y >> 15;
    if (y < 0)
    {
        y = -y;
        t4 = y >> 15;
        t4 = -t4;
        y &= 0x7FFF;
        y = -y;
    }
    else
    {
        y &= 0x7FFF;
    }

    //loc_FFC
    t5 = z >> 15;
    if (z < 0)
    {
        z = -z;
        t5 = z >> 15;
        t5 = -t5;
        z &= 0x7FFF;
        z = -z;
    }
    else
    {
        z &= 0x7FFF;
    }

    t3 = x >> 15;
    if (x < 0)
    {
        x = -x;
        t3 = x >> 15;
        t3 = -t3;
        x &= 0x7FFF;
        x = -x;
    }
    else
    {
        x &= 0x7FFF;
    }

    IR1 = t3;
    IR2 = t4;
    IR3 = t5;

    docop2(0x41E012);

    t3 = MAC1;
    t4 = MAC2;
    t5 = MAC3;

    IR1 = x;
    IR2 = y;
    IR3 = z;

    docop2(0x49E012);

    t0 = t3 << 3;
    if (t3 < 0)
    {
        t3 = -t3;
        t3 <<= 3;
        t0 = -t3;
    }

    t1 = t4 << 3;
    if (t4 < 0)
    {
        t4 = -t4;
        t4 <<= 3;
        t1 = -t4;
    }

    t2 = t5 << 3;
    if (t5 < 0)
    {
        t5 = -t5;
        t5 <<= 3;
        t1 = -t4;
    }

    t3 = MAC1;
    t4 = MAC2;
    t5 = MAC3;

    t0 += t3;
    t1 += t4;
    t2 += t5;

    TRX = t0;
    TRY = t1;
    TRZ = t2;
}

void sub_1358L1(int x, int y, int z)
{
	int t0 = 0;
	int t1 = 0;
	int t2 = 0;
	int t3 = 0;
    int t4 = 0;
	int t5 = 0;

	t4 = y >> 15;

    if (y < 0)
    {
        y = -y;
        t4 = y >> 15;
        y &= 0x7FFF;
        t4 = -t4;
        y = -y;
    }
    else
    {
        //loc_1378
        y &= 0x7FFF;
    }

    t5 = z >> 15;
    if (z < 0)
    {
        z = -z;
        t5 = z >> 15;
        z &= 0x7FFF;
        t5 = -t5;
        z = -z;
    }
    else
    {
        z &= 0x7FFF;
    }

    //loc_13A0
    t3 = x >> 15;
    if (x < 0)
    {
        x = -x;
        t3 = x >> 15;
        x &= 0x7FFF;
        t3 = -t3;
        x = -x;
    }
    else
    {
        x &= 0x7FFF;
    }

    //loc_13C4
    IR1 = t3;
    IR2 = t4;
    IR3 = t5;

    docop2(0x41E012);

    t3 = MAC1;
    t4 = MAC2;
    t5 = MAC3;

    IR1 = x;
    IR2 = y;
    IR3 = z;

    docop2(0x498012);

    t0 = t3 << 3;
    if (t3 < 0)
    {
        t3 = -t3;
        t3 <<= 3;
        t0 = -t3;
    }

    //loc_1408
    t1 = t4 << 3;
    if (t4 < 0)
    {
        t4 = -t4;
        t4 <<= 3;
        t1 = -t4;
    }

    //loc_1430
    t2 = t5 << 3;
    if (t5 < 0)
    {
        t5 = -t5;
        t5 <<= 3;
        t2 = -t5;
    }

    //loc_1430
    t3 = MAC1;
    t4 = MAC2;
    t5 = MAC3;

    t0 += t3;
    t1 += t4;
    t2 += t5;

    TRX = t0;
    TRY = t1;
            a2 += 2;

            t0 = LIM(IR1 >> 7, 0x1f, 0, 0) | (LIM(IR2 >> 7, 0x1f, 0, 0) << 5) | (LIM(IR3 >> 7, 0x1f, 0, 0) << 10);
            a2[-1] = t0;
        } while (v1 != 0);

   }

    do
    {
        char v0 = *a1++;

        //loc_C38

        if (v0 >= 0)
        {
            int* a2 = &scratchPad[v0 << 1];
            a00[0] = a2[0];
            a00[1] = a2[1];
            a00 += 2;
        }
        else
        {
            break;
        }
    } while (1);
    //locret_C64
}

void sub_C6CL1(int a0)
{
    int* a00 = (int*)&tsv_buffer[(((a0 << 1) + a0) << 2)];
    char* a2 = (char*)&ScratchVertNums[(((a0 << 1) + a0) << 2)];

    //loc_C88
    do
    {
        char v0 = *a2++;

        //
        if (v0 >= 0)
        {
            int* a1 = &scratchPad[v0 << 1];
            a1[0] = a00[0];
            a1[1] = a00[1];
            a00 += 2;
        }
        else
        {
            break;
        }
    } while (1);
    //locret_CB4
}   

void sub_CBCL1(int a0)//(F)
{
	int t0 = 0;
	int t1 = 0;
	int t2 = 0;
	int t3 = 0;
	int t4 = 0;
	int t5 = 0;
	int t6 = 0;
	int t7 = 0;

    a0 >>= 2;
    a0 &= 0x3FFC;

    if (a0 != 0)
    {
        t5 = ((int*)&rcossin_tbl[a0 >> 1])[0];
        t7 = 0xFFFF0000;
        t6 = t7 & t5;

        VX0 = t6 & 0xFFFF;
        VY0 = (t6 >> 16) & 0xFFFF;
        VZ0 = t5;

        t0 = (R11 & 0xFFFF) | ((R12 & 0xFFFF) << 16);
        t1 = (R13 & 0xFFFF) | ((R21 & 0xFFFF) << 16);
        t3 = (R31 & 0xFFFF) | ((R32 & 0xFFFF) << 16);

        docop2(0x486012);

        t6 = t5 >> 16;
        t5 <<= 16;
        t5 = -t5;

        VX1 = t5 & 0xFFFF;
        VY1 = (t5 >> 16) & 0xFFFF;
        VZ1 = t6 & 0xFFFF;

        t0 &= 0xFFFF;
        t1 &= t7;
        t3 &= 0xFFFF;

        t4 = MAC1;
        t2 = MAC2;
        t5 = MAC3;

        docop2(0x48E012);
        t4 <<= 16;
        t0 |= t4;
        t2 &= 0xFFFF;
        t5 <<= 16;
        t3 |= t5;

        t5 = MAC1;
        t6 = MAC2;
        t4 = MAC3;

        t5 &= 0xFFFF;
        t1 |= t5;
        t6 <<= 16;
        t2 |= t6;

        R11 = t0 & 0xFFFF;
        R12 = (t0 >> 16) & 0xFFFF;
        R13 = t1 & 0xFFFF;
        R21 = (t1 >> 16) & 0xFFFF;
        R22 = t2 & 0xFFFF;
        R23 = (t2 >> 16) & 0xFFFF;
        R31 = t3 & 0xFFFF;
        R32 = (t3 >> 16) & 0xFFFF;
        R33 = t4;
    }
}

void sub_D7CL1(int y_rot)
{
	int t0 = 0;
	int t1 = 0;
	int t2 = 0;
	int t3 = 0;
	int t4 = 0;
	int t5 = 0;
	int t7 = 0;
	int t6 = 0;

    y_rot >>= 2;
    y_rot &= 0x3FFC;

    if (y_rot != 0)
    {
        //t0 = rcossin_tbl
        t5 = ((int*)&rcossin_tbl[y_rot >> 1])[0];
        t7 = 0xFFFF0000;
        t6 = t5 >> 16;
        t5 &= 0xFFFF;
        t2 = -t5;

        VX0 = t6 & 0xFFFF;
        VY0 = (t6 >> 16) & 0xFFFF;
        VZ0 = t2;

        t0 = (R11 & 0xFFFF) | ((R12 & 0xFFFF) << 16);
        t2 = (R22 & 0xFFFF) | ((R23 & 0xFFFF) << 16);
        t3 = (R31 & 0xFFFF) | ((R32 & 0xFFFF) << 16);

        docop2(0x486012);
        VX1 = t5 & 0xFFFF;
        VY1 = (t5 >> 16) & 0xFFFF;
        VZ1 = t6;

        t0 &= t7;
        t2 &= 0xFFFF;
        t3 &= t7;
        t4 = MAC1;
        t1 = MAC2;
        t5 = MAC3;
        docop2(0x48E012);
        t4 &= 0xFFFF;
        t0 |= t4;
        t1 <<= 16;
        t5 &= 0xFFFF;
        t3 |= t5;
        t5 = MAC1;
        t6 = MAC2;
        t4 = MAC3;
        t5 &= 0xFFFF;
        t1 |= t5;
        t6 <<= 16;
        t2 |= t6;

        R11 = t0 & 0xFFFF;
        R12 = (t0 >> 16) & 0xFFFF;
        R13 = t1 & 0xFFFF;
        R21 = (t1 >> 16) & 0xFFFF;
        R22 = t2 & 0xFFFF;
        R23 = (t2 >> 16) & 0xFFFF;
        R31 = t3 & 0xFFFF;
        R32 = (t3 >> 16) & 0xFFFF;
        R33 = t4;
    }
}

void sub_1244L1(int y_rot, int x_rot, int z_rot)
{
	int t0 = 0;
	int t7 = 0;
	int t1 = 0;
	int t2 = 0;
	int t4 = 0;
	int t3 = 0;
	int t5 = 0;
	int t6 = 0;
	int a0 = 0;

    sub_D7CL1(y_rot);
    sub_CBCL1(x_rot);
    
    z_rot >>= 2;
    z_rot &= 0x3FFC;

    if (z_rot != 0)
    {
        t0 = ((int*)&rcossin_tbl[z_rot >> 1])[0];
        t7 = 0xFFFF0000;
        t1 = (t0 >> 16) & 0xFFFF;
        t2 = t0 << 16;
        t1 |= t2;

        VX0 = t1 & 0xFFFF;
        VY0 = (t1 >> 16) & 0xFFFF;
        VZ0 = 0;

        t1 = (R13 & 0xFFFF) | ((R21 & 0xFFFF) << 16);
        t2 = (R22 & 0xFFFF) | ((R23 & 0xFFFF) << 16);
        t4 = R33;

        docop2(0x486012);

        t3 = t0 & t7;
        t0 &= 0xFFFF;
        t0 = -t0;
        t0 &= 0xFFFF;
        t0 |= t3;

        VX1 = t0 & 0xFFFF;
        VY1 = (t0 >> 16) & 0xFFFF;
        VZ1 = 0;

        t1 &= 0xFFFF;

        t0 = MAC1;
        t5 = MAC2;
        t3 = MAC3;

        docop2(0x48E012);
        
        t2 &= t7;
        t0 &= 0xFFFF;
        t5 <<= 16;
        t1 |= t5;
        t3 &= 0xFFFF;

        t5 = MAC1;
        t6 = MAC2;
        a0 = MAC3;

        t5 <<= 16;
        t0 |= t5;
        t6 &= 0xFFFF;
        t2 |= t6;
        a0 <<= 16;
        t3 |= a0;

        R11 = t0 & 0xFFFF;
        R12 = (t0 >> 16) & 0xFFFF;
        R13 = t1 & 0xFFFF;
        R21 = (t1 >> 16) & 0xFFFF;
        R22 = t2 & 0xFFFF;
        R23 = (t2 >> 16) & 0xFFFF;
        R31 = t3 & 0xFFFF;
        R32 = (t3 >> 16) & 0xFFFF;
        R33 = t4;
    }

}

void sub_BACL1(int* t2, int* t6, int* a3, int* t3, int* at, int* t7, int* t8)//(F)
{
    *t2 = *t6 >> 7;
    *t2 &= *a3;
    *t3 = *t6 >> 10;
    *t3 &= 0xF800;
    *t6 >>= 13;
    *t6 &= 0xF8;
    *t6 |= *t3;
    *t6 |= *t2;
    *at >>= 24;
    *at <<= 24;
    *t6 |= *at;
    *t2 = *t7 >> 7;
    *t2 &= *a3;
    *t3 = *t7 >> 10;
    *t3 &= 0xF800;
    *t7 >>= 13;
    *t7 &= 0xF8;
    *t7 |= *t3;
    *t7 |= *t2;
    *t2 = *t8 >> 7;
    *t2 &= *a3;
    *t3 = *t8 >> 10;
    *t3 &= 0xF800;
    *t8 >>= 13;
    *t8 &= 0xF8;
    *t8 |= *t3;
    *t8 |= *t2;
}

int* sub_658L1(short* meshp, int* s5/*db.polyptr*/, int s6/*ot*/)//(F)
{
    unsigned int t00;
    int t0;
    int t1;
    int t2;
    int t3;
    int t4;
    int t5;
    int t6;
    int t7;
    int t8;
    int t9;
    int at;
    int v1;
    int* a3;
    int* a0;
	int v0 = 0;
	int* a2 = NULL;
	unsigned int* a1 = NULL;
	int a33 = 0;
	struct PSXTEXTSTRUCT* a22 = NULL;

    v0 = ((int*)meshp)[2];
    meshp += 6;
    a1 = (unsigned int*)&meshp[v0 >> 17];
    v0 &= 0xFF;
    a2 = &scratchPad[0];

    if (v0 != 0)
    {
        t0 = (R11 & 0xFFFF) | ((R12 & 0xFFFF) << 16);
        t1 = (R13 & 0xFFFF) | ((R21 & 0xFFFF) << 16);
        t2 = (R22 & 0xFFFF) | ((R23 & 0xFFFF) << 16);
        t3 = (R31 & 0xFFFF) | ((R32 & 0xFFFF) << 16);
        t4 = (R33 & 0xFFFF);

        t5 = 0xFFFF0000;
        t6 = t0 & t5;
        t7 = t2 & t5;
        t0 &= 0xFFFF;
        at = t1 & t5;
        t0 |= at;
        t2 &= 0xFFFF;
        at = t3 & t5;
        t2 |= at;
        t1 &= 0xFFFF;
        t1 |= t7;
        t3 &= 0xFFFF;
        t3 |= t6;

        L11 = t0 & 0xFFFF;
        L12 = (t0 >> 16) & 0xFFFF;
        L13 = t3 & 0xFFFF;
        L21 = (t3 >> 16) & 0xFFFF;
        L22 = t2 & 0xFFFF;
        L23 = (t2 >> 16) & 0xFFFF;
        L31 = t1 & 0xFFFF;
        L32 = (t1 >> 16) & 0xFFFF;
        L33 = t4 & 0xFFFF;

        //t9 = &LightPos

        t0 = ((int*)&LightPos)[0];
        t1 = ((int*)&LightPos)[1];
        VX0 = (t0 & 0xFFFF);
        VY0 = (t0 >> 16) & 0xFFFF;
        VZ0 = (t1 & 0xFFFF);
        docop2(0x4A6012);
        t0 = ((int*)&LightPos)[2];
        t1 >>= 16;
        at = t0 << 16;
        t1 |= at;
        t0 >>= 16;

        VX1 = t1 & 0xFFFF;
        VY1 = (t1 >> 16) & 0xFFFF;
        VZ1 = t0;

        t0 = IR1;
        t2 = IR2;
        t1 = IR3;

        docop2(0x4AE012);
        VX2 = ((int*)&LightPos)[3] & 0xFFFF;
        VY2 = (((int*)&LightPos)[3] >> 16) & 0xFFFF;
        VZ2 = ((int*)&LightPos)[4] & 0xFFFF;

        t0 &= 0xFFFF;
        t2 <<= 16;
        t0 |= t2;
        t1 &= 0xFFFF;

        t3 = IR1;
        t2 = IR2;
        t4 = IR3;

        docop2(0x4B6012);

        t3 <<= 16;
        t1 |= t3;
        t2 &= 0xFFFF;
        t4 <<= 16;
        t2 |= t4;

        t3 = IR1;
        t5 = IR2;
        t4 = IR3;

        t3 &= 0xFFFF;
        t5 <<= 16;
        t3 |= t5;

        L11 = t0 & 0xFFFF;
        L12 = (t0 >> 16) & 0xFFFF;

        L13 = t1 & 0xFFFF;
        L21 = (t1 >> 16) & 0xFFFF;

        L22 = t2 & 0xFFFF;
        L23 = (t2 >> 16) & 0xFFFF;

        L31 = t3 & 0xFFFF;
        L32 = (t3 >> 16) & 0xFFFF;

        L33 = t4;

        at = v0 << 3;
        v1 = v0;

        a3 = (int*)&meshp[v0 << 2];

        t0 = ((int*)meshp)[0];
        t1 = ((int*)meshp)[1];
        t2 = ((int*)meshp)[2];
        t3 = ((int*)meshp)[3];
        t4 = ((int*)meshp)[4];
        t5 = ((int*)meshp)[5];

        //loc_7AC
        do
        {
            VX0 = t0 & 0xFFFF;
            VY0 = (t0 >> 16) & 0xFFFF;
            VZ0 = t1 & 0xFFFF;

            VX1 = t2 & 0xFFFF;
            VY1 = (t2 >> 16) & 0xFFFF;
            VZ1 = t3 & 0xFFFF;

            VX2 = t4 & 0xFFFF;
            VY2 = (t4 >> 16) & 0xFFFF;
            VZ2 = t5 & 0xFFFF;

            meshp += 12;
            v0 -= 3;

            docop2(0x280030);

            t0 = ((int*)meshp)[0];
            t1 = ((int*)meshp)[1];
            t2 = ((int*)meshp)[2];
            t3 = ((int*)meshp)[3];
            t4 = ((int*)meshp)[4];
            t5 = ((int*)meshp)[5];

            a2[0] = SXY0;
            a2[1] = SZ1;
            a2[2] = SXY1;
            a2[3] = SZ2;
            a2[4] = SXY2;
            a2[5] = SZ3;

            a2 += 6;
        } while (v0 > 0);


        t0 = TRZ;
        t1 = 0;
        t0 -= 0x3000;
        at = v0 << 3;

        if (t0 > 0)
        {
            t1 = t0 >> 1;
        }

        //loc_820
        IR0 = t1;
        t1 = a3[0];
        t2 = a3[1];
        a2 = &scratchPad[0];

        //loc_830
        do
        {
            VX0 = t1 & 0xFFFF;
            VY0 = (t1 >> 16) & 0xFFFF;
            VZ0 = t2 & 0xFFFF;

            a3 += 2;
            docop2(0xE80413);
            t1 = a3[0];
            t2 = a3[1];
            v1--;
            a2 += 2;

            ORGB = LIM(IR1 >> 7, 0x1F, 0, 0) | (LIM(IR2 >> 7, 0x1F, 0, 0) << 5) | (LIM(IR3 >> 7, 0x1F, 0, 0) << 10);
            t0 = ORGB; 
            ((short*)a2)[-1] = t0;
        } while (v1 != 0);

   }
    //loc_85C
   a0 = &scratchPad[0];
   a22 = psxtextinfo;
   v0 = a1[0];
   a33 = 0xF80000;
   at = v0 >> 16;
   DQA = at;
   v0 &= 0xFFFF;
   a1++;

   if (v0 != 0)
   {
       t00 = a1[0];

loc_884:
       a1++;
       v1 = 3;

loc_88C:
       t1 = a1[0];
       v0--;

       t8 = (t1 >> 13) & 0x7F8;
       t8 += (int)a0;
       t7 = (t1 >> 5) & 0x7F8;
       t7 += (int)a0;
       t6 = (t1 << 3) & 0x7F8;
       t6 += (int)a0;

       SXY0 = ((int*)t6)[0];
       SXY1 = ((int*)t7)[0];
       SXY2 = ((int*)t8)[0];

       t5 = t00 & 0xFF;
       t00 >>= 8;
       docop2(0x1400006);

       t6 = ((int*)t6)[1];
       t7 = ((int*)t7)[1];
       t8 = ((int*)t8)[1];

       SZ1 = t6;
       SZ2 = t7;
       SZ3 = t8;

       t1 >>= 16;
       t1 &= 0xF00;
       at = MAC0;
       docop2(0x158002D);
       t5 |= t1;
       t5 <<= 4;

       if (at >= 0)
       {
           t5 += (int)a22;
           t1 = SXY0;
           t2 = SXY1;
           t3 = SXY2;

           if (!(t1 & 0xFE00) || !(t2 & 0xFE00) || !(t3 & 0xFE00))
           {
               //loc_92C
               at = t1 & t2;
               at &= t3;

               if (at >= 0)
               {
                   if ((t1 >> 16) < 0xF0 || (t2 >> 16) < 0xF0 || (t3 >> 16) < 0xF0)
                   {
                       t1 = OTZ;
                       if (t1 < 0xA01)
                       {
                           t1 <<= 2;
                           t4 = ((int*)t5)[2];
                           at = t4 << 8;
                           sub_BACL1(&t2, &t6, &a33, &t3, &at, &t7, &t8);
                           at = DQB;
                           t2 = ((int*)t5)[0];
                           t3 = ((int*)t5)[1];
                           t2 -= at;
#if defined(USE_32_BIT_ADDR)
                           ((int*)s5)[3] = SXY0;
                           ((int*)s5)[6] = SXY1;
                           ((int*)s5)[9] = SXY2;
                           ((int*)s5)[2] = t6;
                           ((int*)s5)[4] = t2;
                           ((int*)s5)[5] = t7;
                           ((int*)s5)[7] = t3;
                           ((int*)s5)[8] = t8;
                           ((int*)s5)[10] = t4;
                           t1 *= 2;
                           t1 += s6;
                           setlen(s5, 9);
                           addPrim(t1, s5);
#else
                           ((int*)s5)[2] = SXY0;
                           ((int*)s5)[5] = SXY1;
                           ((int*)s5)[8] = SXY2;
                           ((int*)s5)[1] = t6;
                           ((int*)s5)[3] = t2;
                           ((int*)s5)[4] = t7;
                           ((int*)s5)[6] = t3;
                           ((int*)s5)[7] = t8;
                           ((int*)s5)[9] = t4;
                           t1 += s6;
                           t2 = ((int*)t1)[0];
                           at = 0x9000000;
                           t2 |= at;
                           ((int*)t1)[0] = (int)s5;
                           s5[0] = t2;
#endif
                           s5 += sizeof(POLY_GT3) / sizeof(unsigned long);
                       }//loc_9D0
                   }//loc_9D0
               }//loc_9D0
           }//loc_9D0
       }//loc_9D0

       a1++;
       if (v0 != 0)
       {
           if (v1-- != 0)
           {
               goto loc_88C;
           }

           t00 = a1[0];
           goto loc_884;

       }//loc_9E8
   }
   //loc_9E8
   v0 = DQA;

   t00 = a1[0];

   if (v0 != 0)
   {
loc_9F4:
       a1++;
       v1 = 1;

loc_9FC:
       t1 = a1[0];
       v0--;
       
       t9 = t1 >> 21;
       t8 = t1 >> 13;
       t8 &= 0x7F8;
       t8 += (int)a0;
       t7 = t1 >> 5;
       t7 &= 0x7F8;
       t7 += (int)a0;
       t6 = t1 << 3;
       t6 &= 0x7F8;
       t6 += (int)a0;
       SXY0 = ((int*)t6)[0];
       SXY1 = ((int*)t7)[0];
       SXY2 = ((int*)t8)[0];
       t9 &= 0x7F8;
       t9 += (int)a0;
       docop2(0x1400006);
       t6 = ((int*)t6)[1];
       t7 = ((int*)t7)[1];
       t8 = ((int*)t8)[1];
       t4 = ((int*)t9)[0];
       t9 = ((int*)t9)[1];
       SZ0 = t6;
       SZ1 = t7;
       SZ2 = t8;
       SZ3 = t9;
       at = MAC0;
       docop2(0x168002E);
       t5 = t00 & 0xFFF;
       t00 >>= 16;
       t5 <<= 4;

       if (at >= 0)
       {
           t1 = SXY0;
           t2 = SXY1;
           t3 = SXY2;

           if (!(t1 & 0xFE00) || !(t2 & 0xFE00) || !(t3 & 0xFE00) || !(t4 & 0xFE00))
           {
               //loc_AAC
               at = t1 & t2;
               at &= t3;
               at &= t4;

               if (at >= 0)
               {
                   if ((t1 >> 16) < 0xF0 || (t2 >> 16) < 0xF0 || (t3 >> 16) < 0xF0 || (t4 >> 16) < 0xF0)
                   {
                       //loc_AEC
                       t5 += (int)a22;
                       t2 = t9 >> 7;
                       t1 = OTZ;
                       t2 &= a33;

                       if (t1 < 0xA01)
                       {
                           t1 <<= 2;
#if defined(USE_32_BIT_ADDR)
                           s5[3] = SXY0;
                           s5[6] = SXY1;
                           s5[9] = SXY2;
                           s5[12] = t4;
#else
                           s5[2] = SXY0;
                           s5[5] = SXY1;
                           s5[8] = SXY2;
                           s5[11] = t4;
#endif
                           t3 = t9 >> 10;
                           t3 &= 0xF800;
                           t9 >>= 13;
                           t9 &= 0xF8;
                           t9 |= t3;
                           t9 |= t2;
                           t4 = ((int*)t5)[2];
                           at = t4;
                           sub_BACL1(&t2, &t6, &a33, &t3, &at, &t7, &t8);
                           at = DQB;
                           t2 = ((int*)t5)[0];
                           t3 = ((int*)t5)[1];
                           t5 = ((int*)t5)[3];
                           t2 -= at;

#if defined(USE_32_BIT_ADDR)
                           s5[2] = t6;
                           s5[4] = t2;
                           s5[5] = t7;
                           s5[7] = t3;
                           s5[8] = t8;
                           s5[10] = t4;
                           s5[11] = t9;
                           s5[13] = t5;
                           t1 *= 2;
                           t1 += s6;
                           setlen(s5, 12);
                           addPrim(t1, s5);
#else
                           s5[1] = t6;
                           s5[3] = t2;
                           s5[4] = t7;
                           s5[6] = t3;
                           s5[7] = t8;
                           s5[9] = t4;
                           s5[10] = t9;
                           s5[12] = t5;
                           t1 += s6;
                           t2 = ((int*)t1)[0];
                           at = 0xC000000;
                           t2 |= at;
                           ((int*)t1)[0] = (int)s5;
                           ((int*)s5)[0] = t2;
#endif
                           s5 += sizeof(POLY_GT4) / sizeof(unsigned long);
                       }//loc_B8C
                   }
               }//loc_B8C
           }//loc_B8C
       }
       //loc_B8C
       a1++;
       if (v0 != 0)
       {
           if (v1-- != 0)
           {
               goto loc_9FC;
           }

           t00 = a1[0];
           goto loc_9F4;
       }
   }//loc_BA4

   return s5;
}

void sub_1184L1()
{
	int t0 = 0;
	int t1 = 0;
	int t2 = 0;
	int t3 = 0;
    int* s3 = &scratchPad[0];
    struct GUNSHELL_STRUCT* s1 = &Gunshells[0];///@FIXME GUNSHELL_STRUCT size not matching PSX!
    struct object_info* a0 = NULL;
    int s2 = 0x18;

    //loc_1198
    do
    {
        s2--;
        if (s1->counter != 0)
        {
            sub_FC0L1(s1->pos.x_pos, s1->pos.y_pos, s1->pos.z_pos);
            sub_1244L1(s1->pos.y_rot, s1->pos.x_rot, s1->pos.z_rot);
            a0 = &objects[s1->object_number];
#if defined(USE_32_BIT_ADDR)
            db.polyptr = (char*)sub_658L1((short*)((int*)meshes[a0->mesh_index])[0], (int*)db.polyptr, (int)db.ot);
#else
            db.polyptr = (char*)sub_658L1((short*)((int*)meshes[a0->mesh_index])[0], (int*)db.polyptr, (int)db.ot);
#endif

            t0 = scratchPad[128];
            t1 = scratchPad[129];
            t2 = scratchPad[130];
            t3 = scratchPad[131];

            R11 = t0 & 0xFFFF;
            R12 = (t0 >> 16) & 0xFFFF;
            R13 = t1 & 0xFFFF;
            R21 = (t1 >> 16) & 0xFFFF;
            R22 = t2 & 0xFFFF;
            R23 = (t2 >> 16) & 0xFFFF;
            R31 = t3 & 0xFFFF;
            R32 = (t3 >> 16) & 0xFFFF;

            t0 = scratchPad[132];
            t1 = scratchPad[134];
            t2 = scratchPad[135];
            t3 = scratchPad[136];

            R33 = t0;
            TRX = t1;
            TRY = t2;
            TRZ = t3;

            s1++;
        }
    } while (s2 != 0);
    //loc_1234
}


void sub_1330L1(struct ITEM_INFO* item)
{
	struct object_info* object = &objects[item->object_number];
	//S_PrintNiceShadow(object->shadow_size, GLaraShadowframe, 0);
}

void sub_10DCL1(int a1, int a2)
{
    struct HAIR_STRUCT* hair = &hairs[0][a1];//$a0
    int at = 0;
    int* a22 = NULL;
	int* a00 = NULL;

    //v0 = &hairs[0]
    //v1 = a1 << 5

    if (a1 == 0)
    {
        //v0 = (CamRot.vy << 4)
        at = -32768 - (CamRot.vy << 4);
    }
    else
    {
        a1 = 0;
        at = ((unsigned short*)hair)[-9];
    }
    //loc_110C
    //a0 = ((unsigned short*)hair)[23];
    //v1 = 0xBFFE

loc_1114:
    at &= 0xFFFF;
    if (ABS(at - ((unsigned short*)hair)[23]) - 0x2001 >= 0xBFFE)
    {
        at = 0x4000;
        a1++;
        goto loc_1114;
    }

    //v1 = &ScratchVertNums[0];
    a22 = (int*)&ScratchVertNums[((a2 << 1) + a2) << 2];
    a00 = (int*)&HairRotScratchVertNums[0][a1];
    a22[0] = a00[0];
    ((unsigned char*)a22)[4] = ((unsigned char*)a00)[4];

}

void sub_E38L1()
{
    int* a3 = NULL;
    int t0 = 0;
    int t1 = 0;
    int t2 = 0;
    int t3 = 0;
    int t4 = 0;
    int t5 = 0;
    int t6 = 0;
    int t7 = 0;
	struct HAIR_STRUCT* h = NULL;
	short* s4 = NULL;
	int s2 = 0;
	short* s1 = NULL;

	a3 = &scratchPad[0];
    t0 = (R11 & 0xFFFF) | ((R12 & 0xFFFF) << 16);
    t1 = (R13 & 0xFFFF) | ((R21 & 0xFFFF) << 16);
    t2 = (R22 & 0xFFFF) | ((R23 & 0xFFFF) << 16);
    t3 = (R31 & 0xFFFF) | ((R32 & 0xFFFF) << 16);
    t4 = R33;
    t5 = TRX;
    t6 = TRY;
    t7 = TRZ;

    a3[128] = t0;
    a3[129] = t1;
    a3[130] = t2;
    a3[131] = t3;
    a3[132] = t4;
    a3[133] = t5;
    a3[134] = t6;
    a3[135] = t7;

    h = &hairs[0][1];//$s0
    //v0 = objects[HAIR].mesh_index
    //s4 = meshes
    s4 = (short*)&meshes[objects[HAIR].mesh_index];
    s2 = 1;//Really hair index, see h
    s1 = s4 + 4;

    //loc_EA4
    do
    {
        sub_FC0L1(h->pos.x_pos, h->pos.y_pos, h->pos.z_pos);
        sub_D7CL1(h->pos.y_rot);
        sub_CBCL1(h->pos.x_rot);
        h += 2;
#if defined(USE_32_BIT_ADDR)
        db.polyptr = (char*)sub_658L1((short*)((int*)s1)[0], (int*)db.polyptr, (int)db.ot);
#else
        db.polyptr = (char*)sub_658L1((short*)((int*)s1)[0], (int*)db.polyptr, (int)db.ot);
#endif

        //t0 = &tsv_buffer[0]
        //t1 = &SkinVertNums[0]
        //at = 5;

        if (s2 != 5)
        {
            sub_C1CL1(s2 + 0x1C);
            sub_C1CL1(s2 + 0x1D);
        }
        else
        {
            //loc_F04
            sub_C1CL1(0x21);
        }

        s2 += 2;

        t0 = scratchPad[128];
        t1 = scratchPad[129];
        t2 = scratchPad[130];
        t3 = scratchPad[131];
        t4 = scratchPad[132];
        t5 = scratchPad[133];
        t6 = scratchPad[134];
        t7 = scratchPad[135];

        R11 = t0 & 0xFFFF;
        R12 = (t0 >> 16) & 0xFFFF;
        R13 = t1 & 0xFFFF;
        R21 = (t1 >> 16) & 0xFFFF;
        R22 = t2 & 0xFFFF;
        R23 = (t2 >> 16) & 0xFFFF;
        R31 = t3 & 0xFFFF;
        R32 = (t3 >> 16) & 0xFFFF;
        R33 = t4;
        TRX = t5;
        TRY = t6;
        TRZ = t7;
        s1 += 8;

    } while (s2 < 6);

    s2 = 0;
    s1 = s4;

    do
    {
        //t0 = &tsv_buffer[0];
        //t1 = &ScratchVertNums[0];
        sub_C6CL1(s2 + 0x1C);
        sub_10DCL1(s2, s2 + 0x1D);
        sub_C6CL1(s2 + 0x1D);
#if defined(USE_32_BIT_ADDR)
        db.polyptr = (char*)sub_658L1((short*)((int*)s1)[0], (int*)db.polyptr, (int)db.ot);
#else
        db.polyptr = (char*)sub_658L1((short*)((int*)s1)[0], (int*)db.polyptr, (int)db.ot);
#endif

        s2 += 2;
        s1 += 8;
    } while (s2 < 6);
}

void sub_2CL1(struct ITEM_INFO* item)
{
    int i;
    int underwater_node = 0;//$v1
    int a1 = 0;
    int v0;
    int v1;
    CVECTOR a0;
    int* s0;
    int a00;
    int j;//$t6
	int t0 = 0;
    int t1 = 0;
    int t2 = 0;
    int t3 = 0;
	int t4 = 0;
	int t5 = 0;
	int t6 = 0;
	int t7 = 0;
	int* v11 = NULL;
	short* s1 = NULL;
	int a000 = 0;
	long* bone = NULL;
	int at = 0;
	short a2 = 0;
    S_MemSet((char*)&scratchPad[0], 0, 1024);

    //v0 = item->hit_points
    if (item->hit_points > 0)
    {
        sub_1330L1(item);
    }
    //loc_6C
    mPushMatrix();
    CalculateObjectLightingLara();
    //a0 = LaraNodeUnderwater
    a1 = 0;
    //a2 = 14
    //loc_8C
    //v0 = LaraNodeUnderwater[0];
    //a2--;
    for (i = 0; i < 15; i++)
    {
        if (!LaraNodeUnderwater[i])
        {
            break;
        }
        else
        {
            a1 = 1;
        }
    }
    //loc_A0
    if (a1 == 0)
    {
        v0 = RBK >> 5;
        at = GBK >> 5;
        v1 = BBK >> 5;

        if (v0 >= 0xFF)
        {
            v0 = 0xFF;
        }

        if (v1 >= 0xFF)
        {
            v1 = 0xFF;
        }

        if (at >= 0xFF)
        {
            at = 0xFF;
        }

        //loc_E4
        if (a1 >= 0xFF)
        {
            a1 = 0xFF;
        }

        //loc_F0
        at <<= 8;
        v1 <<= 16;
        v0 |= v1;
        v0 |= at;

        ((int*)&LaraNodeAmbient[0].r)[0] = v0;
    }
    //loc_104
    //s5 = db.polyptr
    //s6 = db.ot[1]
    //s3 = lara_item
    s0 = &lara_mesh_sweetness_table[0];
    //s1 = &lara_matrices
    //s2 = 0xF
    //s4 = &NodesToStashFromScratch
    //s3 = lara_item->mesh_bits >> 16;

    //loc_138
    for (i = 0; i < 15; i++)///@TODO check < 15
    {
        t0 = ((int*)&lara_matrices[i])[0];
        t1 = ((int*)&lara_matrices[i])[1];
        t2 = ((int*)&lara_matrices[i])[2];
        t3 = ((int*)&lara_matrices[i])[3];

        R11 = t0 & 0xFFFF;
        R12 = (t0 >> 16) & 0xFFFF;

        R13 = t1 & 0xFFFF;
        R21 = (t1 >> 16) & 0xFFFF;

        R22 = t2 & 0xFFFF;
        R23 = (t2 >> 16) & 0xFFFF;

        R31 = t3 & 0xFFFF;
        R32 = (t3 >> 16) & 0xFFFF;

        t0 = ((int*)&lara_matrices[i])[4];
        t1 = ((int*)&lara_matrices[i])[5];
        t2 = ((int*)&lara_matrices[i])[6];
        t3 = ((int*)&lara_matrices[i])[7];

        R33 = t0;
        TRX = t1;
        TRY = t2;
        TRZ = t3;
        //a0 = &LaraNodeUnderwater[0];
        //a1 = 0xF - 
        if (LaraNodeUnderwater[i])
        {
            a0 = LaraNodeAmbient[1];
        }
        else
        {
            a0 = LaraNodeAmbient[0];
        }
        //loc_1A0
        RBK = (((int*)&a0.r)[0] & 0xFF) << 4;
        GBK = ((((int*)&a0.r)[0] >> 4) & 0xFF0);
        BBK = ((((int*)&a0.r)[0] >> 12) & 0xFF0);

        a00 = *s0++;
        //v1 = &lara.mesh_ptrs[0];
        //a00 = &lara.mesh_ptrs[lara_mesh_sweetness_table[0]]
        //v0 = (lara_item->mesh_bits >> 16) & (1 << 0xF)

        if ((lara_item->mesh_bits >> 16)& (1 << 0xF))
        {
#if defined(USE_32_BIT_ADDR)
            db.polyptr = (char*)sub_658L1(lara.mesh_ptrs[lara_mesh_sweetness_table[i]], (int*)db.polyptr, (int)(db.ot+1*2));
#else
            db.polyptr = (char*)sub_658L1(lara.mesh_ptrs[lara_mesh_sweetness_table[i]], (int*)db.polyptr, (int)(db.ot+1));
#endif
        }//loc_1FC

        //s2--;
        //int t7 = &NodesToStashFromScratch[0];
        t6 = 4;
        //t0 = &tsv_buffer[0]
        //t1 = &SkinVertNums[0];

        //loc_218
        for (j = 0; j < 4; j++)
        {
            if (NodesToStashFromScratch[i][j] != -1)
            {
                sub_C1CL1(NodesToStashFromScratch[i][j]);
            }
            else
            {
                //loc_238
                break;
            }
        }
    }
    //loc_238
    //s4 = lara_item
    //s0 = &SkinUseMatrix[0][0];
    //v0 = objects[LARA_SKIN_JOINTS].mesh_index
    //v1 = meshes
    s1 = (short*)&meshes[objects[LARA_SKIN_JOINTS].mesh_index];
    s1 += 4;
    //s3 = NodesToStashToScratch[0][0]
    i = 0xE;//s2
    //s4 = lara_item->mesh_bits

    //loc_278
    for (i = 0; i < 0xE; i++)
    {
        //v0 = 1 << 0xE
        //v0 = lara_item->mesh_bits & (1 << 0xE)

        if (lara_item->mesh_bits & (1 << 0xE))
        {
            //a0 = &LaraNodeUnderwater[0];
            //a2 = &lara_underwater_skin_sweetness_table[0];
            //a1 = 0xE
            //a1 -= s2
            //a2 = &lara_underwater_skin_sweetness_table[i]
            //v0 = lara_underwater_skin_sweetness_table[i]
            //a0 = &LaraNodeUnderwater[lara_underwater_skin_sweetness_table[i]];
            //v0 = LaraNodeUnderwater[lara_underwater_skin_sweetness_table[i]];

            a000 = ((int*)&LaraNodeAmbient)[0];

            if (LaraNodeUnderwater[lara_underwater_skin_sweetness_table[i]])
            {
                a000 = ((int*)&LaraNodeAmbient)[1];
            }

            //loc_2C8
            RBK = (a000 & 0xFF) << 4;
            GBK = (a000 >> 4) & 0xFF0;
            BBK = (a000 >> 12) & 0xFF0;

            // int t2 = SkinUseMatrix[0][0];//derive from s0
             //t0 = &tsv_buffer[0];
             //t1 = &ScratchVertNums[0];
            sub_C6CL1(NodesToStashToScratch[i][0]);
            sub_C6CL1(NodesToStashToScratch[i][1]);

            if (SkinUseMatrix[i][0] < 0xFF)
            {
                //  v1 = SkinUseMatrix[0][1];
                  //t0 = lara_matrices
                  //v0 = &lara_matrices[SkinUseMatrix[0][0]];
                  //v1 = &lara_matrices[SkinUseMatrix[0][1]];
                t0 = ((int*)&lara_matrices[SkinUseMatrix[i][1]])[0];
                t1 = ((int*)&lara_matrices[SkinUseMatrix[i][1]])[1];
                t2 = ((int*)&lara_matrices[SkinUseMatrix[i][1]])[2];
                t3 = ((int*)&lara_matrices[SkinUseMatrix[i][1]])[3];
                t4 = ((int*)&lara_matrices[SkinUseMatrix[i][1]])[4];
                t5 = ((int*)&lara_matrices[SkinUseMatrix[i][1]])[5];
                t6 = ((int*)&lara_matrices[SkinUseMatrix[i][1]])[6];
                t7 = ((int*)&lara_matrices[SkinUseMatrix[i][1]])[7];

                a000 = ((short*)&lara_matrices[SkinUseMatrix[i][0]])[4];
                a1 = (t2 << 16) >> 16;
                a000 *= a1;

                a1 = ((short*)&lara_matrices[SkinUseMatrix[i][0]])[1];
                a2 = ((short*)&lara_matrices[SkinUseMatrix[i][1]])[1];
                at = a000 >> 1;
                a000 += at;
                at = a1 * a2;

                a1 = ((short*)&lara_matrices[SkinUseMatrix[i][0]])[7];
                a2 = ((short*)&lara_matrices[SkinUseMatrix[i][1]])[7];
                a000 += at;

                R11 = t0 & 0xFFFF;
                R12 = (t0 >> 16) & 0xFFFF;

                a1 = a1 * a2;

                R13 = t1 & 0xFFFF;
                R21 = (t1 >> 16) & 0xFFFF;
                R22 = t2 & 0xFFFF;
                R23 = (t2 >> 16) & 0xFFFF;
                R31 = t3 & 0xFFFF;
                R32 = (t3 >> 16) & 0xFFFF;
                R33 = t4;
                TRX = t5;
                TRY = t6;
                TRZ = t7;

                a000 += a1;
                a000 >>= 12;
                t0 = a000;
                a000 = a000 * a000;

                //0x1000000
                v0 = phd_atan_asm(t0, mSqrt(0x1000000 - a000));
                //at = 0xD

                if (i == 0xE - 0xD || i == 0xE - 0xA)//Really || 0xD and 0xA without 0xE - 
                {
                    v0 = -v0;
                }
                //loc_3FC
                a000 = v0 >> 1;
                a000 = -a000;
                sub_CBCL1(a000);

            }//loc_408

#if defined(USE_32_BIT_ADDR)
            db.polyptr = (char*)sub_658L1((short*)((int*)s1)[0], (int*)db.polyptr, (int)(db.ot + 1 * 2));
#else
            db.polyptr = (char*)sub_658L1((short*)((int*)s1)[0], (int*)db.polyptr, (int)(db.ot + 1));
#endif
        }
        //loc_410
        //s1 = &s1[0xD - i * 4];
        s1 += 4;
    }

    //s6 = db.ot[0];
    if (lara_item->mesh_bits + 1 == 0)
    {
        if (LaraNodeUnderwater[0] != 0)
        {
            a0 = LaraNodeAmbient[1];
        }
        else
        {
            a0 = LaraNodeAmbient[0];
        }

        RBK = (((int*)&a0.r)[0] & 0xFF) << 4;
        GBK = ((((int*)&a0.r)[0] >> 4) & 0xFF0);
        BBK = ((((int*)&a0.r)[0] >> 12) & 0xFF0);

        //v0 = lara.hostler
        //v1 = objects
        s0 = (int*)&meshes[objects[lara.holster].mesh_index];
        s0 += 8;
        v11 = (int*)&lara_matrices[1];
        t0 = v11[0];
        t1 = v11[1];
        t2 = v11[2];
        t3 = v11[3];
        t4 = v11[4];
        t5 = v11[5];
        t6 = v11[6];
        t7 = v11[7];

        R11 = t0 & 0xFFFF;
        R12 = (t0 >> 16) & 0xFFFF;

        R13 = t1 & 0xFFFF;
        R21 = (t1 >> 16) & 0xFFFF;

        R22 = t2 & 0xFFFF;
        R23 = (t2 >> 16) & 0xFFFF;

        R31 = t3 & 0xFFFF;
        R32 = (t3 >> 16) & 0xFFFF;
        R33 = t4;

        TRX = t5;
        TRY = t6;
        TRZ = t7;

        ///@FIXME for some reason at index 0 it wont draw left holster!
#if defined(USE_32_BIT_ADDR)
        db.polyptr = (char*)sub_658L1((short*)((int*)s0)[0], (int*)db.polyptr, (int)db.ot);
#else
        db.polyptr = (char*)sub_658L1((short*)((int*)s0)[0], (int*)db.polyptr, (int)db.ot);
#endif
        s0 += 8;

        v11 = (int*)&lara_matrices[4];

        t0 = v11[0];
        t1 = v11[1];
        t2 = v11[2];
        t3 = v11[3];
        t4 = v11[4];
        t5 = v11[5];
        t6 = v11[6];
        t7 = v11[7];

        R11 = t0 & 0xFFFF;
        R12 = (t0 >> 16) & 0xFFFF;

        R13 = t1 & 0xFFFF;
        R21 = (t1 >> 16) & 0xFFFF;

        R22 = t2 & 0xFFFF;
        R23 = (t2 >> 16) & 0xFFFF;

        R31 = t3 & 0xFFFF;
        R32 = (t3 >> 16) & 0xFFFF;
        R33 = t4;

        TRX = t5;
        TRY = t6;
        TRZ = t7;

        ///@FIXME for some reason at index 0 it wont draw right holster!
#if defined(USE_32_BIT_ADDR)
        db.polyptr = (char*)sub_658L1((short*)((int*)s0)[0], (int*)db.polyptr, (int)db.ot);
#else
        db.polyptr = (char*)sub_658L1((short*)((int*)s0)[0], (int*)db.polyptr, (int)db.ot);
#endif
    }
    //loc_538
    //v0 = lara.back_gun
    //v1 = objects

    if (lara.back_gun != 0)
    {
        //a2 = objects[lara.back_gun].bone_index
        //v1 = 
        bone = &bones[objects[lara.back_gun].bone_index];//a2
        //v0 =  objects[lara.back_gun].mesh_index
        s0 = (int*)&meshes[objects[lara.back_gun].mesh_index];//$s0

        v11 = (int*)&lara_matrices[7];

        t0 = v11[0];
        t1 = v11[1];
        t2 = v11[2];
        t3 = v11[3];
        t4 = v11[4];
        t5 = v11[5];
        t6 = v11[6];
        t7 = v11[7];

        R11 = t0 & 0xFFFF;
        R12 = (t0 >> 16) & 0xFFFF;

        R13 = t1 & 0xFFFF;
        R21 = (t1 >> 16) & 0xFFFF;

        R22 = t2 & 0xFFFF;
        R23 = (t2 >> 16) & 0xFFFF;

        R31 = t3 & 0xFFFF;
        R32 = (t3 >> 16) & 0xFFFF;
        R33 = t4;

        TRX = t5;
        TRY = t6;
        TRZ = t7;

        sub_1358L1(bone[53], bone[54], bone[55]);
        ///@FIXME for some reason at index 0 it wont draw back gun!
#if defined(USE_32_BIT_ADDR)
        db.polyptr = (char*)sub_658L1((short*)((int*)s0)[28], (int*)db.polyptr, (int)db.ot);
#else
        db.polyptr = (char*)sub_658L1((short*)((int*)s0)[28], (int*)db.polyptr, (int)db.ot);
#endif

    }
    //loc_5D0
    mPopMatrix();

    if (LaraNodeUnderwater[8] != 0)
    {
        a0 = LaraNodeAmbient[1];
    }
    else
    {
        a0 = LaraNodeAmbient[0];
    }

    //loc_5F0
    RBK = (((int*)&a0.r)[0] & 0xFF) << 4;
    GBK = ((((int*)&a0.r)[0] >> 4) & 0xFF0);
    BBK = ((((int*)&a0.r)[0] >> 12) & 0xFF0);

    sub_E38L1();

    sub_1184L1();
}

void DrawLaraL1()
{
    sub_2CL1(lara_item);
}
<MSG> [Specific-PSXPC_N] Correct sub_658.

<DFF> @@ -242,7 +242,7 @@ void sub_658(short* meshp, int* s5/*db.polyptr*/, int s6/*ot*/)
             a2 += 2;
 
             t0 = LIM(IR1 >> 7, 0x1f, 0, 0) | (LIM(IR2 >> 7, 0x1f, 0, 0) << 5) | (LIM(IR3 >> 7, 0x1f, 0, 0) << 10);
-            a2[-1] = t0;
+            ((short*)a2)[-1] = t0;
         } while (v1 != 0);
 
    }

{'commit': 'diff --git a/SPEC_PSXPC_N/LARA1.C b/SPEC_PSXPC_N/LARA1.C\nindex 084db86a..035a4785 100644\n--- a/SPEC_PSXPC_N/LARA1.C\n+++ b/SPEC_PSXPC_N/LARA1.C\n@@ -242,7 +242,7 @@ void sub_658(short* meshp, int* s5/*db.polyptr*/, int s6/*ot*/)\n             a2 += 2;\n \n             t0 = LIM(IR1 >> 7, 0x1f, 0, 0) | (LIM(IR2 >> 7, 0x1f, 0, 0) << 5) | (LIM(IR3 >> 7, 0x1f, 0, 0) << 10);\n-            a2[-1] = t0;\n+            ((short*)a2)[-1] = t0;\n         } while (v1 != 0);\n \n    }\n', 'commit_subject': '[Specific-PSXPC_N] Correct sub_658.', 'repo_name': 'TOMB5/TOMB5', 'committer': {'name': 'Gh0stBlade', 'email': '19ffcc48b5297ad4998e7ea4f40eaa34eefb03dd@users.noreply.github.com', 'time_sec': '1581623310', 'tz_offset': '0', 'date': {'seconds': '1581623310'}}, 'commit_tree': 'ff30c5589c27346f4dd89d57ebf7d06b4e669a94', 'commit_message': '[Specific-PSXPC_N] Correct sub_658.\n', 'language_name': 'Java', 'license': 'mit', 'hunks': '@@ -242,7 +242,7 @@ void sub_658(short* meshp, int* s5/*db.polyptr*/, int s6/*ot*/)\n             a2 += 2;\n \n             t0 = LIM(IR1 >> 7, 0x1f, 0, 0) | (LIM(IR2 >> 7, 0x1f, 0, 0) << 5) | (LIM(IR3 >> 7, 0x1f, 0, 0) << 10);\n-            a2[-1] = t0;\n+            ((short*)a2)[-1] = t0;\n         } while (v1 != 0);\n \n    }\n', 'addition_count': 1, 'deletion_count': 1, 'src_file': 'a/SPEC_PSXPC_N/LARA1.C', 'tgt_file': 'b/SPEC_PSXPC_N/LARA1.C', 'file_extension': '.C', 'before_file': '#include "LARA1.H"\n\n#include "3D_OBJ.H"\n#include "MISC.H"\n#include "CAMERA.H"\n#include "DRAWSPKS.H"\n#include "DELSTUFF.H"\n#include "LARA.H"\n#include "MATHS.H"\n#include "DRAW.H"\n#include "SETUP.H"\n#include "GTEREG.H"\n#include "GPU.H"\n#include "TOMB4FX.H"\n#include "HAIR.H"\n#include "LOAD_LEV.H"\n\nstatic int scratchPad[256];\n\n\nvoid sub_FC0L1(int x, int y, int z)\n{\n    int t0 = 0;\n    int t1 = 0;\n    int t2 = 0;\n\tint t3 = 0;\n\tint t4 = 0;\n\tint t5 = 0;\n\n\tt0 = TRX;\n    t1 = TRY;\n    t2 = TRZ;\n\n    x -= t0;\n    y -= t1;\n    z -= t2;\n\n    t4 = y >> 15;\n    if (y < 0)\n    {\n        y = -y;\n        t4 = y >> 15;\n        t4 = -t4;\n        y &= 0x7FFF;\n        y = -y;\n    }\n    else\n    {\n        y &= 0x7FFF;\n    }\n\n    //loc_FFC\n    t5 = z >> 15;\n    if (z < 0)\n    {\n        z = -z;\n        t5 = z >> 15;\n        t5 = -t5;\n        z &= 0x7FFF;\n        z = -z;\n    }\n    else\n    {\n        z &= 0x7FFF;\n    }\n\n    t3 = x >> 15;\n    if (x < 0)\n    {\n        x = -x;\n        t3 = x >> 15;\n        t3 = -t3;\n        x &= 0x7FFF;\n        x = -x;\n    }\n    else\n    {\n        x &= 0x7FFF;\n    }\n\n    IR1 = t3;\n    IR2 = t4;\n    IR3 = t5;\n\n    docop2(0x41E012);\n\n    t3 = MAC1;\n    t4 = MAC2;\n    t5 = MAC3;\n\n    IR1 = x;\n    IR2 = y;\n    IR3 = z;\n\n    docop2(0x49E012);\n\n    t0 = t3 << 3;\n    if (t3 < 0)\n    {\n        t3 = -t3;\n        t3 <<= 3;\n        t0 = -t3;\n    }\n\n    t1 = t4 << 3;\n    if (t4 < 0)\n    {\n        t4 = -t4;\n        t4 <<= 3;\n        t1 = -t4;\n    }\n\n    t2 = t5 << 3;\n    if (t5 < 0)\n    {\n        t5 = -t5;\n        t5 <<= 3;\n        t1 = -t4;\n    }\n\n    t3 = MAC1;\n    t4 = MAC2;\n    t5 = MAC3;\n\n    t0 += t3;\n    t1 += t4;\n    t2 += t5;\n\n    TRX = t0;\n    TRY = t1;\n    TRZ = t2;\n}\n\nvoid sub_1358L1(int x, int y, int z)\n{\n\tint t0 = 0;\n\tint t1 = 0;\n\tint t2 = 0;\n\tint t3 = 0;\n    int t4 = 0;\n\tint t5 = 0;\n\n\tt4 = y >> 15;\n\n    if (y < 0)\n    {\n        y = -y;\n        t4 = y >> 15;\n        y &= 0x7FFF;\n        t4 = -t4;\n        y = -y;\n    }\n    else\n    {\n        //loc_1378\n        y &= 0x7FFF;\n    }\n\n    t5 = z >> 15;\n    if (z < 0)\n    {\n        z = -z;\n        t5 = z >> 15;\n        z &= 0x7FFF;\n        t5 = -t5;\n        z = -z;\n    }\n    else\n    {\n        z &= 0x7FFF;\n    }\n\n    //loc_13A0\n    t3 = x >> 15;\n    if (x < 0)\n    {\n        x = -x;\n        t3 = x >> 15;\n        x &= 0x7FFF;\n        t3 = -t3;\n        x = -x;\n    }\n    else\n    {\n        x &= 0x7FFF;\n    }\n\n    //loc_13C4\n    IR1 = t3;\n    IR2 = t4;\n    IR3 = t5;\n\n    docop2(0x41E012);\n\n    t3 = MAC1;\n    t4 = MAC2;\n    t5 = MAC3;\n\n    IR1 = x;\n    IR2 = y;\n    IR3 = z;\n\n    docop2(0x498012);\n\n    t0 = t3 << 3;\n    if (t3 < 0)\n    {\n        t3 = -t3;\n        t3 <<= 3;\n        t0 = -t3;\n    }\n\n    //loc_1408\n    t1 = t4 << 3;\n    if (t4 < 0)\n    {\n        t4 = -t4;\n        t4 <<= 3;\n        t1 = -t4;\n    }\n\n    //loc_1430\n    t2 = t5 << 3;\n    if (t5 < 0)\n    {\n        t5 = -t5;\n        t5 <<= 3;\n        t2 = -t5;\n    }\n\n    //loc_1430\n    t3 = MAC1;\n    t4 = MAC2;\n    t5 = MAC3;\n\n    t0 += t3;\n    t1 += t4;\n    t2 += t5;\n\n    TRX = t0;\n    TRY = t1;\n            a2 += 2;\n\n            t0 = LIM(IR1 >> 7, 0x1f, 0, 0) | (LIM(IR2 >> 7, 0x1f, 0, 0) << 5) | (LIM(IR3 >> 7, 0x1f, 0, 0) << 10);\n            a2[-1] = t0;\n        } while (v1 != 0);\n\n   }\n\n    do\n    {\n        char v0 = *a1++;\n\n        //loc_C38\n\n        if (v0 >= 0)\n        {\n            int* a2 = &scratchPad[v0 << 1];\n            a00[0] = a2[0];\n            a00[1] = a2[1];\n            a00 += 2;\n        }\n        else\n        {\n            break;\n        }\n    } while (1);\n    //locret_C64\n}\n\nvoid sub_C6CL1(int a0)\n{\n    int* a00 = (int*)&tsv_buffer[(((a0 << 1) + a0) << 2)];\n    char* a2 = (char*)&ScratchVertNums[(((a0 << 1) + a0) << 2)];\n\n    //loc_C88\n    do\n    {\n        char v0 = *a2++;\n\n        //\n        if (v0 >= 0)\n        {\n            int* a1 = &scratchPad[v0 << 1];\n            a1[0] = a00[0];\n            a1[1] = a00[1];\n            a00 += 2;\n        }\n        else\n        {\n            break;\n        }\n    } while (1);\n    //locret_CB4\n}   \n\nvoid sub_CBCL1(int a0)//(F)\n{\n\tint t0 = 0;\n\tint t1 = 0;\n\tint t2 = 0;\n\tint t3 = 0;\n\tint t4 = 0;\n\tint t5 = 0;\n\tint t6 = 0;\n\tint t7 = 0;\n\n    a0 >>= 2;\n    a0 &= 0x3FFC;\n\n    if (a0 != 0)\n    {\n        t5 = ((int*)&rcossin_tbl[a0 >> 1])[0];\n        t7 = 0xFFFF0000;\n        t6 = t7 & t5;\n\n        VX0 = t6 & 0xFFFF;\n        VY0 = (t6 >> 16) & 0xFFFF;\n        VZ0 = t5;\n\n        t0 = (R11 & 0xFFFF) | ((R12 & 0xFFFF) << 16);\n        t1 = (R13 & 0xFFFF) | ((R21 & 0xFFFF) << 16);\n        t3 = (R31 & 0xFFFF) | ((R32 & 0xFFFF) << 16);\n\n        docop2(0x486012);\n\n        t6 = t5 >> 16;\n        t5 <<= 16;\n        t5 = -t5;\n\n        VX1 = t5 & 0xFFFF;\n        VY1 = (t5 >> 16) & 0xFFFF;\n        VZ1 = t6 & 0xFFFF;\n\n        t0 &= 0xFFFF;\n        t1 &= t7;\n        t3 &= 0xFFFF;\n\n        t4 = MAC1;\n        t2 = MAC2;\n        t5 = MAC3;\n\n        docop2(0x48E012);\n        t4 <<= 16;\n        t0 |= t4;\n        t2 &= 0xFFFF;\n        t5 <<= 16;\n        t3 |= t5;\n\n        t5 = MAC1;\n        t6 = MAC2;\n        t4 = MAC3;\n\n        t5 &= 0xFFFF;\n        t1 |= t5;\n        t6 <<= 16;\n        t2 |= t6;\n\n        R11 = t0 & 0xFFFF;\n        R12 = (t0 >> 16) & 0xFFFF;\n        R13 = t1 & 0xFFFF;\n        R21 = (t1 >> 16) & 0xFFFF;\n        R22 = t2 & 0xFFFF;\n        R23 = (t2 >> 16) & 0xFFFF;\n        R31 = t3 & 0xFFFF;\n        R32 = (t3 >> 16) & 0xFFFF;\n        R33 = t4;\n    }\n}\n\nvoid sub_D7CL1(int y_rot)\n{\n\tint t0 = 0;\n\tint t1 = 0;\n\tint t2 = 0;\n\tint t3 = 0;\n\tint t4 = 0;\n\tint t5 = 0;\n\tint t7 = 0;\n\tint t6 = 0;\n\n    y_rot >>= 2;\n    y_rot &= 0x3FFC;\n\n    if (y_rot != 0)\n    {\n        //t0 = rcossin_tbl\n        t5 = ((int*)&rcossin_tbl[y_rot >> 1])[0];\n        t7 = 0xFFFF0000;\n        t6 = t5 >> 16;\n        t5 &= 0xFFFF;\n        t2 = -t5;\n\n        VX0 = t6 & 0xFFFF;\n        VY0 = (t6 >> 16) & 0xFFFF;\n        VZ0 = t2;\n\n        t0 = (R11 & 0xFFFF) | ((R12 & 0xFFFF) << 16);\n        t2 = (R22 & 0xFFFF) | ((R23 & 0xFFFF) << 16);\n        t3 = (R31 & 0xFFFF) | ((R32 & 0xFFFF) << 16);\n\n        docop2(0x486012);\n        VX1 = t5 & 0xFFFF;\n        VY1 = (t5 >> 16) & 0xFFFF;\n        VZ1 = t6;\n\n        t0 &= t7;\n        t2 &= 0xFFFF;\n        t3 &= t7;\n        t4 = MAC1;\n        t1 = MAC2;\n        t5 = MAC3;\n        docop2(0x48E012);\n        t4 &= 0xFFFF;\n        t0 |= t4;\n        t1 <<= 16;\n        t5 &= 0xFFFF;\n        t3 |= t5;\n        t5 = MAC1;\n        t6 = MAC2;\n        t4 = MAC3;\n        t5 &= 0xFFFF;\n        t1 |= t5;\n        t6 <<= 16;\n        t2 |= t6;\n\n        R11 = t0 & 0xFFFF;\n        R12 = (t0 >> 16) & 0xFFFF;\n        R13 = t1 & 0xFFFF;\n        R21 = (t1 >> 16) & 0xFFFF;\n        R22 = t2 & 0xFFFF;\n        R23 = (t2 >> 16) & 0xFFFF;\n        R31 = t3 & 0xFFFF;\n        R32 = (t3 >> 16) & 0xFFFF;\n        R33 = t4;\n    }\n}\n\nvoid sub_1244L1(int y_rot, int x_rot, int z_rot)\n{\n\tint t0 = 0;\n\tint t7 = 0;\n\tint t1 = 0;\n\tint t2 = 0;\n\tint t4 = 0;\n\tint t3 = 0;\n\tint t5 = 0;\n\tint t6 = 0;\n\tint a0 = 0;\n\n    sub_D7CL1(y_rot);\n    sub_CBCL1(x_rot);\n    \n    z_rot >>= 2;\n    z_rot &= 0x3FFC;\n\n    if (z_rot != 0)\n    {\n        t0 = ((int*)&rcossin_tbl[z_rot >> 1])[0];\n        t7 = 0xFFFF0000;\n        t1 = (t0 >> 16) & 0xFFFF;\n        t2 = t0 << 16;\n        t1 |= t2;\n\n        VX0 = t1 & 0xFFFF;\n        VY0 = (t1 >> 16) & 0xFFFF;\n        VZ0 = 0;\n\n        t1 = (R13 & 0xFFFF) | ((R21 & 0xFFFF) << 16);\n        t2 = (R22 & 0xFFFF) | ((R23 & 0xFFFF) << 16);\n        t4 = R33;\n\n        docop2(0x486012);\n\n        t3 = t0 & t7;\n        t0 &= 0xFFFF;\n        t0 = -t0;\n        t0 &= 0xFFFF;\n        t0 |= t3;\n\n        VX1 = t0 & 0xFFFF;\n        VY1 = (t0 >> 16) & 0xFFFF;\n        VZ1 = 0;\n\n        t1 &= 0xFFFF;\n\n        t0 = MAC1;\n        t5 = MAC2;\n        t3 = MAC3;\n\n        docop2(0x48E012);\n        \n        t2 &= t7;\n        t0 &= 0xFFFF;\n        t5 <<= 16;\n        t1 |= t5;\n        t3 &= 0xFFFF;\n\n        t5 = MAC1;\n        t6 = MAC2;\n        a0 = MAC3;\n\n        t5 <<= 16;\n        t0 |= t5;\n        t6 &= 0xFFFF;\n        t2 |= t6;\n        a0 <<= 16;\n        t3 |= a0;\n\n        R11 = t0 & 0xFFFF;\n        R12 = (t0 >> 16) & 0xFFFF;\n        R13 = t1 & 0xFFFF;\n        R21 = (t1 >> 16) & 0xFFFF;\n        R22 = t2 & 0xFFFF;\n        R23 = (t2 >> 16) & 0xFFFF;\n        R31 = t3 & 0xFFFF;\n        R32 = (t3 >> 16) & 0xFFFF;\n        R33 = t4;\n    }\n\n}\n\nvoid sub_BACL1(int* t2, int* t6, int* a3, int* t3, int* at, int* t7, int* t8)//(F)\n{\n    *t2 = *t6 >> 7;\n    *t2 &= *a3;\n    *t3 = *t6 >> 10;\n    *t3 &= 0xF800;\n    *t6 >>= 13;\n    *t6 &= 0xF8;\n    *t6 |= *t3;\n    *t6 |= *t2;\n    *at >>= 24;\n    *at <<= 24;\n    *t6 |= *at;\n    *t2 = *t7 >> 7;\n    *t2 &= *a3;\n    *t3 = *t7 >> 10;\n    *t3 &= 0xF800;\n    *t7 >>= 13;\n    *t7 &= 0xF8;\n    *t7 |= *t3;\n    *t7 |= *t2;\n    *t2 = *t8 >> 7;\n    *t2 &= *a3;\n    *t3 = *t8 >> 10;\n    *t3 &= 0xF800;\n    *t8 >>= 13;\n    *t8 &= 0xF8;\n    *t8 |= *t3;\n    *t8 |= *t2;\n}\n\nint* sub_658L1(short* meshp, int* s5/*db.polyptr*/, int s6/*ot*/)//(F)\n{\n    unsigned int t00;\n    int t0;\n    int t1;\n    int t2;\n    int t3;\n    int t4;\n    int t5;\n    int t6;\n    int t7;\n    int t8;\n    int t9;\n    int at;\n    int v1;\n    int* a3;\n    int* a0;\n\tint v0 = 0;\n\tint* a2 = NULL;\n\tunsigned int* a1 = NULL;\n\tint a33 = 0;\n\tstruct PSXTEXTSTRUCT* a22 = NULL;\n\n    v0 = ((int*)meshp)[2];\n    meshp += 6;\n    a1 = (unsigned int*)&meshp[v0 >> 17];\n    v0 &= 0xFF;\n    a2 = &scratchPad[0];\n\n    if (v0 != 0)\n    {\n        t0 = (R11 & 0xFFFF) | ((R12 & 0xFFFF) << 16);\n        t1 = (R13 & 0xFFFF) | ((R21 & 0xFFFF) << 16);\n        t2 = (R22 & 0xFFFF) | ((R23 & 0xFFFF) << 16);\n        t3 = (R31 & 0xFFFF) | ((R32 & 0xFFFF) << 16);\n        t4 = (R33 & 0xFFFF);\n\n        t5 = 0xFFFF0000;\n        t6 = t0 & t5;\n        t7 = t2 & t5;\n        t0 &= 0xFFFF;\n        at = t1 & t5;\n        t0 |= at;\n        t2 &= 0xFFFF;\n        at = t3 & t5;\n        t2 |= at;\n        t1 &= 0xFFFF;\n        t1 |= t7;\n        t3 &= 0xFFFF;\n        t3 |= t6;\n\n        L11 = t0 & 0xFFFF;\n        L12 = (t0 >> 16) & 0xFFFF;\n        L13 = t3 & 0xFFFF;\n        L21 = (t3 >> 16) & 0xFFFF;\n        L22 = t2 & 0xFFFF;\n        L23 = (t2 >> 16) & 0xFFFF;\n        L31 = t1 & 0xFFFF;\n        L32 = (t1 >> 16) & 0xFFFF;\n        L33 = t4 & 0xFFFF;\n\n        //t9 = &LightPos\n\n        t0 = ((int*)&LightPos)[0];\n        t1 = ((int*)&LightPos)[1];\n        VX0 = (t0 & 0xFFFF);\n        VY0 = (t0 >> 16) & 0xFFFF;\n        VZ0 = (t1 & 0xFFFF);\n        docop2(0x4A6012);\n        t0 = ((int*)&LightPos)[2];\n        t1 >>= 16;\n        at = t0 << 16;\n        t1 |= at;\n        t0 >>= 16;\n\n        VX1 = t1 & 0xFFFF;\n        VY1 = (t1 >> 16) & 0xFFFF;\n        VZ1 = t0;\n\n        t0 = IR1;\n        t2 = IR2;\n        t1 = IR3;\n\n        docop2(0x4AE012);\n        VX2 = ((int*)&LightPos)[3] & 0xFFFF;\n        VY2 = (((int*)&LightPos)[3] >> 16) & 0xFFFF;\n        VZ2 = ((int*)&LightPos)[4] & 0xFFFF;\n\n        t0 &= 0xFFFF;\n        t2 <<= 16;\n        t0 |= t2;\n        t1 &= 0xFFFF;\n\n        t3 = IR1;\n        t2 = IR2;\n        t4 = IR3;\n\n        docop2(0x4B6012);\n\n        t3 <<= 16;\n        t1 |= t3;\n        t2 &= 0xFFFF;\n        t4 <<= 16;\n        t2 |= t4;\n\n        t3 = IR1;\n        t5 = IR2;\n        t4 = IR3;\n\n        t3 &= 0xFFFF;\n        t5 <<= 16;\n        t3 |= t5;\n\n        L11 = t0 & 0xFFFF;\n        L12 = (t0 >> 16) & 0xFFFF;\n\n        L13 = t1 & 0xFFFF;\n        L21 = (t1 >> 16) & 0xFFFF;\n\n        L22 = t2 & 0xFFFF;\n        L23 = (t2 >> 16) & 0xFFFF;\n\n        L31 = t3 & 0xFFFF;\n        L32 = (t3 >> 16) & 0xFFFF;\n\n        L33 = t4;\n\n        at = v0 << 3;\n        v1 = v0;\n\n        a3 = (int*)&meshp[v0 << 2];\n\n        t0 = ((int*)meshp)[0];\n        t1 = ((int*)meshp)[1];\n        t2 = ((int*)meshp)[2];\n        t3 = ((int*)meshp)[3];\n        t4 = ((int*)meshp)[4];\n        t5 = ((int*)meshp)[5];\n\n        //loc_7AC\n        do\n        {\n            VX0 = t0 & 0xFFFF;\n            VY0 = (t0 >> 16) & 0xFFFF;\n            VZ0 = t1 & 0xFFFF;\n\n            VX1 = t2 & 0xFFFF;\n            VY1 = (t2 >> 16) & 0xFFFF;\n            VZ1 = t3 & 0xFFFF;\n\n            VX2 = t4 & 0xFFFF;\n            VY2 = (t4 >> 16) & 0xFFFF;\n            VZ2 = t5 & 0xFFFF;\n\n            meshp += 12;\n            v0 -= 3;\n\n            docop2(0x280030);\n\n            t0 = ((int*)meshp)[0];\n            t1 = ((int*)meshp)[1];\n            t2 = ((int*)meshp)[2];\n            t3 = ((int*)meshp)[3];\n            t4 = ((int*)meshp)[4];\n            t5 = ((int*)meshp)[5];\n\n            a2[0] = SXY0;\n            a2[1] = SZ1;\n            a2[2] = SXY1;\n            a2[3] = SZ2;\n            a2[4] = SXY2;\n            a2[5] = SZ3;\n\n            a2 += 6;\n        } while (v0 > 0);\n\n\n        t0 = TRZ;\n        t1 = 0;\n        t0 -= 0x3000;\n        at = v0 << 3;\n\n        if (t0 > 0)\n        {\n            t1 = t0 >> 1;\n        }\n\n        //loc_820\n        IR0 = t1;\n        t1 = a3[0];\n        t2 = a3[1];\n        a2 = &scratchPad[0];\n\n        //loc_830\n        do\n        {\n            VX0 = t1 & 0xFFFF;\n            VY0 = (t1 >> 16) & 0xFFFF;\n            VZ0 = t2 & 0xFFFF;\n\n            a3 += 2;\n            docop2(0xE80413);\n            t1 = a3[0];\n            t2 = a3[1];\n            v1--;\n            a2 += 2;\n\n            ORGB = LIM(IR1 >> 7, 0x1F, 0, 0) | (LIM(IR2 >> 7, 0x1F, 0, 0) << 5) | (LIM(IR3 >> 7, 0x1F, 0, 0) << 10);\n            t0 = ORGB; \n            ((short*)a2)[-1] = t0;\n        } while (v1 != 0);\n\n   }\n    //loc_85C\n   a0 = &scratchPad[0];\n   a22 = psxtextinfo;\n   v0 = a1[0];\n   a33 = 0xF80000;\n   at = v0 >> 16;\n   DQA = at;\n   v0 &= 0xFFFF;\n   a1++;\n\n   if (v0 != 0)\n   {\n       t00 = a1[0];\n\nloc_884:\n       a1++;\n       v1 = 3;\n\nloc_88C:\n       t1 = a1[0];\n       v0--;\n\n       t8 = (t1 >> 13) & 0x7F8;\n       t8 += (int)a0;\n       t7 = (t1 >> 5) & 0x7F8;\n       t7 += (int)a0;\n       t6 = (t1 << 3) & 0x7F8;\n       t6 += (int)a0;\n\n       SXY0 = ((int*)t6)[0];\n       SXY1 = ((int*)t7)[0];\n       SXY2 = ((int*)t8)[0];\n\n       t5 = t00 & 0xFF;\n       t00 >>= 8;\n       docop2(0x1400006);\n\n       t6 = ((int*)t6)[1];\n       t7 = ((int*)t7)[1];\n       t8 = ((int*)t8)[1];\n\n       SZ1 = t6;\n       SZ2 = t7;\n       SZ3 = t8;\n\n       t1 >>= 16;\n       t1 &= 0xF00;\n       at = MAC0;\n       docop2(0x158002D);\n       t5 |= t1;\n       t5 <<= 4;\n\n       if (at >= 0)\n       {\n           t5 += (int)a22;\n           t1 = SXY0;\n           t2 = SXY1;\n           t3 = SXY2;\n\n           if (!(t1 & 0xFE00) || !(t2 & 0xFE00) || !(t3 & 0xFE00))\n           {\n               //loc_92C\n               at = t1 & t2;\n               at &= t3;\n\n               if (at >= 0)\n               {\n                   if ((t1 >> 16) < 0xF0 || (t2 >> 16) < 0xF0 || (t3 >> 16) < 0xF0)\n                   {\n                       t1 = OTZ;\n                       if (t1 < 0xA01)\n                       {\n                           t1 <<= 2;\n                           t4 = ((int*)t5)[2];\n                           at = t4 << 8;\n                           sub_BACL1(&t2, &t6, &a33, &t3, &at, &t7, &t8);\n                           at = DQB;\n                           t2 = ((int*)t5)[0];\n                           t3 = ((int*)t5)[1];\n                           t2 -= at;\n#if defined(USE_32_BIT_ADDR)\n                           ((int*)s5)[3] = SXY0;\n                           ((int*)s5)[6] = SXY1;\n                           ((int*)s5)[9] = SXY2;\n                           ((int*)s5)[2] = t6;\n                           ((int*)s5)[4] = t2;\n                           ((int*)s5)[5] = t7;\n                           ((int*)s5)[7] = t3;\n                           ((int*)s5)[8] = t8;\n                           ((int*)s5)[10] = t4;\n                           t1 *= 2;\n                           t1 += s6;\n                           setlen(s5, 9);\n                           addPrim(t1, s5);\n#else\n                           ((int*)s5)[2] = SXY0;\n                           ((int*)s5)[5] = SXY1;\n                           ((int*)s5)[8] = SXY2;\n                           ((int*)s5)[1] = t6;\n                           ((int*)s5)[3] = t2;\n                           ((int*)s5)[4] = t7;\n                           ((int*)s5)[6] = t3;\n                           ((int*)s5)[7] = t8;\n                           ((int*)s5)[9] = t4;\n                           t1 += s6;\n                           t2 = ((int*)t1)[0];\n                           at = 0x9000000;\n                           t2 |= at;\n                           ((int*)t1)[0] = (int)s5;\n                           s5[0] = t2;\n#endif\n                           s5 += sizeof(POLY_GT3) / sizeof(unsigned long);\n                       }//loc_9D0\n                   }//loc_9D0\n               }//loc_9D0\n           }//loc_9D0\n       }//loc_9D0\n\n       a1++;\n       if (v0 != 0)\n       {\n           if (v1-- != 0)\n           {\n               goto loc_88C;\n           }\n\n           t00 = a1[0];\n           goto loc_884;\n\n       }//loc_9E8\n   }\n   //loc_9E8\n   v0 = DQA;\n\n   t00 = a1[0];\n\n   if (v0 != 0)\n   {\nloc_9F4:\n       a1++;\n       v1 = 1;\n\nloc_9FC:\n       t1 = a1[0];\n       v0--;\n       \n       t9 = t1 >> 21;\n       t8 = t1 >> 13;\n       t8 &= 0x7F8;\n       t8 += (int)a0;\n       t7 = t1 >> 5;\n       t7 &= 0x7F8;\n       t7 += (int)a0;\n       t6 = t1 << 3;\n       t6 &= 0x7F8;\n       t6 += (int)a0;\n       SXY0 = ((int*)t6)[0];\n       SXY1 = ((int*)t7)[0];\n       SXY2 = ((int*)t8)[0];\n       t9 &= 0x7F8;\n       t9 += (int)a0;\n       docop2(0x1400006);\n       t6 = ((int*)t6)[1];\n       t7 = ((int*)t7)[1];\n       t8 = ((int*)t8)[1];\n       t4 = ((int*)t9)[0];\n       t9 = ((int*)t9)[1];\n       SZ0 = t6;\n       SZ1 = t7;\n       SZ2 = t8;\n       SZ3 = t9;\n       at = MAC0;\n       docop2(0x168002E);\n       t5 = t00 & 0xFFF;\n       t00 >>= 16;\n       t5 <<= 4;\n\n       if (at >= 0)\n       {\n           t1 = SXY0;\n           t2 = SXY1;\n           t3 = SXY2;\n\n           if (!(t1 & 0xFE00) || !(t2 & 0xFE00) || !(t3 & 0xFE00) || !(t4 & 0xFE00))\n           {\n               //loc_AAC\n               at = t1 & t2;\n               at &= t3;\n               at &= t4;\n\n               if (at >= 0)\n               {\n                   if ((t1 >> 16) < 0xF0 || (t2 >> 16) < 0xF0 || (t3 >> 16) < 0xF0 || (t4 >> 16) < 0xF0)\n                   {\n                       //loc_AEC\n                       t5 += (int)a22;\n                       t2 = t9 >> 7;\n                       t1 = OTZ;\n                       t2 &= a33;\n\n                       if (t1 < 0xA01)\n                       {\n                           t1 <<= 2;\n#if defined(USE_32_BIT_ADDR)\n                           s5[3] = SXY0;\n                           s5[6] = SXY1;\n                           s5[9] = SXY2;\n                           s5[12] = t4;\n#else\n                           s5[2] = SXY0;\n                           s5[5] = SXY1;\n                           s5[8] = SXY2;\n                           s5[11] = t4;\n#endif\n                           t3 = t9 >> 10;\n                           t3 &= 0xF800;\n                           t9 >>= 13;\n                           t9 &= 0xF8;\n                           t9 |= t3;\n                           t9 |= t2;\n                           t4 = ((int*)t5)[2];\n                           at = t4;\n                           sub_BACL1(&t2, &t6, &a33, &t3, &at, &t7, &t8);\n                           at = DQB;\n                           t2 = ((int*)t5)[0];\n                           t3 = ((int*)t5)[1];\n                           t5 = ((int*)t5)[3];\n                           t2 -= at;\n\n#if defined(USE_32_BIT_ADDR)\n                           s5[2] = t6;\n                           s5[4] = t2;\n                           s5[5] = t7;\n                           s5[7] = t3;\n                           s5[8] = t8;\n                           s5[10] = t4;\n                           s5[11] = t9;\n                           s5[13] = t5;\n                           t1 *= 2;\n                           t1 += s6;\n                           setlen(s5, 12);\n                           addPrim(t1, s5);\n#else\n                           s5[1] = t6;\n                           s5[3] = t2;\n                           s5[4] = t7;\n                           s5[6] = t3;\n                           s5[7] = t8;\n                           s5[9] = t4;\n                           s5[10] = t9;\n                           s5[12] = t5;\n                           t1 += s6;\n                           t2 = ((int*)t1)[0];\n                           at = 0xC000000;\n                           t2 |= at;\n                           ((int*)t1)[0] = (int)s5;\n                           ((int*)s5)[0] = t2;\n#endif\n                           s5 += sizeof(POLY_GT4) / sizeof(unsigned long);\n                       }//loc_B8C\n                   }\n               }//loc_B8C\n           }//loc_B8C\n       }\n       //loc_B8C\n       a1++;\n       if (v0 != 0)\n       {\n           if (v1-- != 0)\n           {\n               goto loc_9FC;\n           }\n\n           t00 = a1[0];\n           goto loc_9F4;\n       }\n   }//loc_BA4\n\n   return s5;\n}\n\nvoid sub_1184L1()\n{\n\tint t0 = 0;\n\tint t1 = 0;\n\tint t2 = 0;\n\tint t3 = 0;\n    int* s3 = &scratchPad[0];\n    struct GUNSHELL_STRUCT* s1 = &Gunshells[0];///@FIXME GUNSHELL_STRUCT size not matching PSX!\n    struct object_info* a0 = NULL;\n    int s2 = 0x18;\n\n    //loc_1198\n    do\n    {\n        s2--;\n        if (s1->counter != 0)\n        {\n            sub_FC0L1(s1->pos.x_pos, s1->pos.y_pos, s1->pos.z_pos);\n            sub_1244L1(s1->pos.y_rot, s1->pos.x_rot, s1->pos.z_rot);\n            a0 = &objects[s1->object_number];\n#if defined(USE_32_BIT_ADDR)\n            db.polyptr = (char*)sub_658L1((short*)((int*)meshes[a0->mesh_index])[0], (int*)db.polyptr, (int)db.ot);\n#else\n            db.polyptr = (char*)sub_658L1((short*)((int*)meshes[a0->mesh_index])[0], (int*)db.polyptr, (int)db.ot);\n#endif\n\n            t0 = scratchPad[128];\n            t1 = scratchPad[129];\n            t2 = scratchPad[130];\n            t3 = scratchPad[131];\n\n            R11 = t0 & 0xFFFF;\n            R12 = (t0 >> 16) & 0xFFFF;\n            R13 = t1 & 0xFFFF;\n            R21 = (t1 >> 16) & 0xFFFF;\n            R22 = t2 & 0xFFFF;\n            R23 = (t2 >> 16) & 0xFFFF;\n            R31 = t3 & 0xFFFF;\n            R32 = (t3 >> 16) & 0xFFFF;\n\n            t0 = scratchPad[132];\n            t1 = scratchPad[134];\n            t2 = scratchPad[135];\n            t3 = scratchPad[136];\n\n            R33 = t0;\n            TRX = t1;\n            TRY = t2;\n            TRZ = t3;\n\n            s1++;\n        }\n    } while (s2 != 0);\n    //loc_1234\n}\n\n\nvoid sub_1330L1(struct ITEM_INFO* item)\n{\n\tstruct object_info* object = &objects[item->object_number];\n\t//S_PrintNiceShadow(object->shadow_size, GLaraShadowframe, 0);\n}\n\nvoid sub_10DCL1(int a1, int a2)\n{\n    struct HAIR_STRUCT* hair = &hairs[0][a1];//$a0\n    int at = 0;\n    int* a22 = NULL;\n\tint* a00 = NULL;\n\n    //v0 = &hairs[0]\n    //v1 = a1 << 5\n\n    if (a1 == 0)\n    {\n        //v0 = (CamRot.vy << 4)\n        at = -32768 - (CamRot.vy << 4);\n    }\n    else\n    {\n        a1 = 0;\n        at = ((unsigned short*)hair)[-9];\n    }\n    //loc_110C\n    //a0 = ((unsigned short*)hair)[23];\n    //v1 = 0xBFFE\n\nloc_1114:\n    at &= 0xFFFF;\n    if (ABS(at - ((unsigned short*)hair)[23]) - 0x2001 >= 0xBFFE)\n    {\n        at = 0x4000;\n        a1++;\n        goto loc_1114;\n    }\n\n    //v1 = &ScratchVertNums[0];\n    a22 = (int*)&ScratchVertNums[((a2 << 1) + a2) << 2];\n    a00 = (int*)&HairRotScratchVertNums[0][a1];\n    a22[0] = a00[0];\n    ((unsigned char*)a22)[4] = ((unsigned char*)a00)[4];\n\n}\n\nvoid sub_E38L1()\n{\n    int* a3 = NULL;\n    int t0 = 0;\n    int t1 = 0;\n    int t2 = 0;\n    int t3 = 0;\n    int t4 = 0;\n    int t5 = 0;\n    int t6 = 0;\n    int t7 = 0;\n\tstruct HAIR_STRUCT* h = NULL;\n\tshort* s4 = NULL;\n\tint s2 = 0;\n\tshort* s1 = NULL;\n\n\ta3 = &scratchPad[0];\n    t0 = (R11 & 0xFFFF) | ((R12 & 0xFFFF) << 16);\n    t1 = (R13 & 0xFFFF) | ((R21 & 0xFFFF) << 16);\n    t2 = (R22 & 0xFFFF) | ((R23 & 0xFFFF) << 16);\n    t3 = (R31 & 0xFFFF) | ((R32 & 0xFFFF) << 16);\n    t4 = R33;\n    t5 = TRX;\n    t6 = TRY;\n    t7 = TRZ;\n\n    a3[128] = t0;\n    a3[129] = t1;\n    a3[130] = t2;\n    a3[131] = t3;\n    a3[132] = t4;\n    a3[133] = t5;\n    a3[134] = t6;\n    a3[135] = t7;\n\n    h = &hairs[0][1];//$s0\n    //v0 = objects[HAIR].mesh_index\n    //s4 = meshes\n    s4 = (short*)&meshes[objects[HAIR].mesh_index];\n    s2 = 1;//Really hair index, see h\n    s1 = s4 + 4;\n\n    //loc_EA4\n    do\n    {\n        sub_FC0L1(h->pos.x_pos, h->pos.y_pos, h->pos.z_pos);\n        sub_D7CL1(h->pos.y_rot);\n        sub_CBCL1(h->pos.x_rot);\n        h += 2;\n#if defined(USE_32_BIT_ADDR)\n        db.polyptr = (char*)sub_658L1((short*)((int*)s1)[0], (int*)db.polyptr, (int)db.ot);\n#else\n        db.polyptr = (char*)sub_658L1((short*)((int*)s1)[0], (int*)db.polyptr, (int)db.ot);\n#endif\n\n        //t0 = &tsv_buffer[0]\n        //t1 = &SkinVertNums[0]\n        //at = 5;\n\n        if (s2 != 5)\n        {\n            sub_C1CL1(s2 + 0x1C);\n            sub_C1CL1(s2 + 0x1D);\n        }\n        else\n        {\n            //loc_F04\n            sub_C1CL1(0x21);\n        }\n\n        s2 += 2;\n\n        t0 = scratchPad[128];\n        t1 = scratchPad[129];\n        t2 = scratchPad[130];\n        t3 = scratchPad[131];\n        t4 = scratchPad[132];\n        t5 = scratchPad[133];\n        t6 = scratchPad[134];\n        t7 = scratchPad[135];\n\n        R11 = t0 & 0xFFFF;\n        R12 = (t0 >> 16) & 0xFFFF;\n        R13 = t1 & 0xFFFF;\n        R21 = (t1 >> 16) & 0xFFFF;\n        R22 = t2 & 0xFFFF;\n        R23 = (t2 >> 16) & 0xFFFF;\n        R31 = t3 & 0xFFFF;\n        R32 = (t3 >> 16) & 0xFFFF;\n        R33 = t4;\n        TRX = t5;\n        TRY = t6;\n        TRZ = t7;\n        s1 += 8;\n\n    } while (s2 < 6);\n\n    s2 = 0;\n    s1 = s4;\n\n    do\n    {\n        //t0 = &tsv_buffer[0];\n        //t1 = &ScratchVertNums[0];\n        sub_C6CL1(s2 + 0x1C);\n        sub_10DCL1(s2, s2 + 0x1D);\n        sub_C6CL1(s2 + 0x1D);\n#if defined(USE_32_BIT_ADDR)\n        db.polyptr = (char*)sub_658L1((short*)((int*)s1)[0], (int*)db.polyptr, (int)db.ot);\n#else\n        db.polyptr = (char*)sub_658L1((short*)((int*)s1)[0], (int*)db.polyptr, (int)db.ot);\n#endif\n\n        s2 += 2;\n        s1 += 8;\n    } while (s2 < 6);\n}\n\nvoid sub_2CL1(struct ITEM_INFO* item)\n{\n    int i;\n    int underwater_node = 0;//$v1\n    int a1 = 0;\n    int v0;\n    int v1;\n    CVECTOR a0;\n    int* s0;\n    int a00;\n    int j;//$t6\n\tint t0 = 0;\n    int t1 = 0;\n    int t2 = 0;\n    int t3 = 0;\n\tint t4 = 0;\n\tint t5 = 0;\n\tint t6 = 0;\n\tint t7 = 0;\n\tint* v11 = NULL;\n\tshort* s1 = NULL;\n\tint a000 = 0;\n\tlong* bone = NULL;\n\tint at = 0;\n\tshort a2 = 0;\n    S_MemSet((char*)&scratchPad[0], 0, 1024);\n\n    //v0 = item->hit_points\n    if (item->hit_points > 0)\n    {\n        sub_1330L1(item);\n    }\n    //loc_6C\n    mPushMatrix();\n    CalculateObjectLightingLara();\n    //a0 = LaraNodeUnderwater\n    a1 = 0;\n    //a2 = 14\n    //loc_8C\n    //v0 = LaraNodeUnderwater[0];\n    //a2--;\n    for (i = 0; i < 15; i++)\n    {\n        if (!LaraNodeUnderwater[i])\n        {\n            break;\n        }\n        else\n        {\n            a1 = 1;\n        }\n    }\n    //loc_A0\n    if (a1 == 0)\n    {\n        v0 = RBK >> 5;\n        at = GBK >> 5;\n        v1 = BBK >> 5;\n\n        if (v0 >= 0xFF)\n        {\n            v0 = 0xFF;\n        }\n\n        if (v1 >= 0xFF)\n        {\n            v1 = 0xFF;\n        }\n\n        if (at >= 0xFF)\n        {\n            at = 0xFF;\n        }\n\n        //loc_E4\n        if (a1 >= 0xFF)\n        {\n            a1 = 0xFF;\n        }\n\n        //loc_F0\n        at <<= 8;\n        v1 <<= 16;\n        v0 |= v1;\n        v0 |= at;\n\n        ((int*)&LaraNodeAmbient[0].r)[0] = v0;\n    }\n    //loc_104\n    //s5 = db.polyptr\n    //s6 = db.ot[1]\n    //s3 = lara_item\n    s0 = &lara_mesh_sweetness_table[0];\n    //s1 = &lara_matrices\n    //s2 = 0xF\n    //s4 = &NodesToStashFromScratch\n    //s3 = lara_item->mesh_bits >> 16;\n\n    //loc_138\n    for (i = 0; i < 15; i++)///@TODO check < 15\n    {\n        t0 = ((int*)&lara_matrices[i])[0];\n        t1 = ((int*)&lara_matrices[i])[1];\n        t2 = ((int*)&lara_matrices[i])[2];\n        t3 = ((int*)&lara_matrices[i])[3];\n\n        R11 = t0 & 0xFFFF;\n        R12 = (t0 >> 16) & 0xFFFF;\n\n        R13 = t1 & 0xFFFF;\n        R21 = (t1 >> 16) & 0xFFFF;\n\n        R22 = t2 & 0xFFFF;\n        R23 = (t2 >> 16) & 0xFFFF;\n\n        R31 = t3 & 0xFFFF;\n        R32 = (t3 >> 16) & 0xFFFF;\n\n        t0 = ((int*)&lara_matrices[i])[4];\n        t1 = ((int*)&lara_matrices[i])[5];\n        t2 = ((int*)&lara_matrices[i])[6];\n        t3 = ((int*)&lara_matrices[i])[7];\n\n        R33 = t0;\n        TRX = t1;\n        TRY = t2;\n        TRZ = t3;\n        //a0 = &LaraNodeUnderwater[0];\n        //a1 = 0xF - \n        if (LaraNodeUnderwater[i])\n        {\n            a0 = LaraNodeAmbient[1];\n        }\n        else\n        {\n            a0 = LaraNodeAmbient[0];\n        }\n        //loc_1A0\n        RBK = (((int*)&a0.r)[0] & 0xFF) << 4;\n        GBK = ((((int*)&a0.r)[0] >> 4) & 0xFF0);\n        BBK = ((((int*)&a0.r)[0] >> 12) & 0xFF0);\n\n        a00 = *s0++;\n        //v1 = &lara.mesh_ptrs[0];\n        //a00 = &lara.mesh_ptrs[lara_mesh_sweetness_table[0]]\n        //v0 = (lara_item->mesh_bits >> 16) & (1 << 0xF)\n\n        if ((lara_item->mesh_bits >> 16)& (1 << 0xF))\n        {\n#if defined(USE_32_BIT_ADDR)\n            db.polyptr = (char*)sub_658L1(lara.mesh_ptrs[lara_mesh_sweetness_table[i]], (int*)db.polyptr, (int)(db.ot+1*2));\n#else\n            db.polyptr = (char*)sub_658L1(lara.mesh_ptrs[lara_mesh_sweetness_table[i]], (int*)db.polyptr, (int)(db.ot+1));\n#endif\n        }//loc_1FC\n\n        //s2--;\n        //int t7 = &NodesToStashFromScratch[0];\n        t6 = 4;\n        //t0 = &tsv_buffer[0]\n        //t1 = &SkinVertNums[0];\n\n        //loc_218\n        for (j = 0; j < 4; j++)\n        {\n            if (NodesToStashFromScratch[i][j] != -1)\n            {\n                sub_C1CL1(NodesToStashFromScratch[i][j]);\n            }\n            else\n            {\n                //loc_238\n                break;\n            }\n        }\n    }\n    //loc_238\n    //s4 = lara_item\n    //s0 = &SkinUseMatrix[0][0];\n    //v0 = objects[LARA_SKIN_JOINTS].mesh_index\n    //v1 = meshes\n    s1 = (short*)&meshes[objects[LARA_SKIN_JOINTS].mesh_index];\n    s1 += 4;\n    //s3 = NodesToStashToScratch[0][0]\n    i = 0xE;//s2\n    //s4 = lara_item->mesh_bits\n\n    //loc_278\n    for (i = 0; i < 0xE; i++)\n    {\n        //v0 = 1 << 0xE\n        //v0 = lara_item->mesh_bits & (1 << 0xE)\n\n        if (lara_item->mesh_bits & (1 << 0xE))\n        {\n            //a0 = &LaraNodeUnderwater[0];\n            //a2 = &lara_underwater_skin_sweetness_table[0];\n            //a1 = 0xE\n            //a1 -= s2\n            //a2 = &lara_underwater_skin_sweetness_table[i]\n            //v0 = lara_underwater_skin_sweetness_table[i]\n            //a0 = &LaraNodeUnderwater[lara_underwater_skin_sweetness_table[i]];\n            //v0 = LaraNodeUnderwater[lara_underwater_skin_sweetness_table[i]];\n\n            a000 = ((int*)&LaraNodeAmbient)[0];\n\n            if (LaraNodeUnderwater[lara_underwater_skin_sweetness_table[i]])\n            {\n                a000 = ((int*)&LaraNodeAmbient)[1];\n            }\n\n            //loc_2C8\n            RBK = (a000 & 0xFF) << 4;\n            GBK = (a000 >> 4) & 0xFF0;\n            BBK = (a000 >> 12) & 0xFF0;\n\n            // int t2 = SkinUseMatrix[0][0];//derive from s0\n             //t0 = &tsv_buffer[0];\n             //t1 = &ScratchVertNums[0];\n            sub_C6CL1(NodesToStashToScratch[i][0]);\n            sub_C6CL1(NodesToStashToScratch[i][1]);\n\n            if (SkinUseMatrix[i][0] < 0xFF)\n            {\n                //  v1 = SkinUseMatrix[0][1];\n                  //t0 = lara_matrices\n                  //v0 = &lara_matrices[SkinUseMatrix[0][0]];\n                  //v1 = &lara_matrices[SkinUseMatrix[0][1]];\n                t0 = ((int*)&lara_matrices[SkinUseMatrix[i][1]])[0];\n                t1 = ((int*)&lara_matrices[SkinUseMatrix[i][1]])[1];\n                t2 = ((int*)&lara_matrices[SkinUseMatrix[i][1]])[2];\n                t3 = ((int*)&lara_matrices[SkinUseMatrix[i][1]])[3];\n                t4 = ((int*)&lara_matrices[SkinUseMatrix[i][1]])[4];\n                t5 = ((int*)&lara_matrices[SkinUseMatrix[i][1]])[5];\n                t6 = ((int*)&lara_matrices[SkinUseMatrix[i][1]])[6];\n                t7 = ((int*)&lara_matrices[SkinUseMatrix[i][1]])[7];\n\n                a000 = ((short*)&lara_matrices[SkinUseMatrix[i][0]])[4];\n                a1 = (t2 << 16) >> 16;\n                a000 *= a1;\n\n                a1 = ((short*)&lara_matrices[SkinUseMatrix[i][0]])[1];\n                a2 = ((short*)&lara_matrices[SkinUseMatrix[i][1]])[1];\n                at = a000 >> 1;\n                a000 += at;\n                at = a1 * a2;\n\n                a1 = ((short*)&lara_matrices[SkinUseMatrix[i][0]])[7];\n                a2 = ((short*)&lara_matrices[SkinUseMatrix[i][1]])[7];\n                a000 += at;\n\n                R11 = t0 & 0xFFFF;\n                R12 = (t0 >> 16) & 0xFFFF;\n\n                a1 = a1 * a2;\n\n                R13 = t1 & 0xFFFF;\n                R21 = (t1 >> 16) & 0xFFFF;\n                R22 = t2 & 0xFFFF;\n                R23 = (t2 >> 16) & 0xFFFF;\n                R31 = t3 & 0xFFFF;\n                R32 = (t3 >> 16) & 0xFFFF;\n                R33 = t4;\n                TRX = t5;\n                TRY = t6;\n                TRZ = t7;\n\n                a000 += a1;\n                a000 >>= 12;\n                t0 = a000;\n                a000 = a000 * a000;\n\n                //0x1000000\n                v0 = phd_atan_asm(t0, mSqrt(0x1000000 - a000));\n                //at = 0xD\n\n                if (i == 0xE - 0xD || i == 0xE - 0xA)//Really || 0xD and 0xA without 0xE - \n                {\n                    v0 = -v0;\n                }\n                //loc_3FC\n                a000 = v0 >> 1;\n                a000 = -a000;\n                sub_CBCL1(a000);\n\n            }//loc_408\n\n#if defined(USE_32_BIT_ADDR)\n            db.polyptr = (char*)sub_658L1((short*)((int*)s1)[0], (int*)db.polyptr, (int)(db.ot + 1 * 2));\n#else\n            db.polyptr = (char*)sub_658L1((short*)((int*)s1)[0], (int*)db.polyptr, (int)(db.ot + 1));\n#endif\n        }\n        //loc_410\n        //s1 = &s1[0xD - i * 4];\n        s1 += 4;\n    }\n\n    //s6 = db.ot[0];\n    if (lara_item->mesh_bits + 1 == 0)\n    {\n        if (LaraNodeUnderwater[0] != 0)\n        {\n            a0 = LaraNodeAmbient[1];\n        }\n        else\n        {\n            a0 = LaraNodeAmbient[0];\n        }\n\n        RBK = (((int*)&a0.r)[0] & 0xFF) << 4;\n        GBK = ((((int*)&a0.r)[0] >> 4) & 0xFF0);\n        BBK = ((((int*)&a0.r)[0] >> 12) & 0xFF0);\n\n        //v0 = lara.hostler\n        //v1 = objects\n        s0 = (int*)&meshes[objects[lara.holster].mesh_index];\n        s0 += 8;\n        v11 = (int*)&lara_matrices[1];\n        t0 = v11[0];\n        t1 = v11[1];\n        t2 = v11[2];\n        t3 = v11[3];\n        t4 = v11[4];\n        t5 = v11[5];\n        t6 = v11[6];\n        t7 = v11[7];\n\n        R11 = t0 & 0xFFFF;\n        R12 = (t0 >> 16) & 0xFFFF;\n\n        R13 = t1 & 0xFFFF;\n        R21 = (t1 >> 16) & 0xFFFF;\n\n        R22 = t2 & 0xFFFF;\n        R23 = (t2 >> 16) & 0xFFFF;\n\n        R31 = t3 & 0xFFFF;\n        R32 = (t3 >> 16) & 0xFFFF;\n        R33 = t4;\n\n        TRX = t5;\n        TRY = t6;\n        TRZ = t7;\n\n        ///@FIXME for some reason at index 0 it wont draw left holster!\n#if defined(USE_32_BIT_ADDR)\n        db.polyptr = (char*)sub_658L1((short*)((int*)s0)[0], (int*)db.polyptr, (int)db.ot);\n#else\n        db.polyptr = (char*)sub_658L1((short*)((int*)s0)[0], (int*)db.polyptr, (int)db.ot);\n#endif\n        s0 += 8;\n\n        v11 = (int*)&lara_matrices[4];\n\n        t0 = v11[0];\n        t1 = v11[1];\n        t2 = v11[2];\n        t3 = v11[3];\n        t4 = v11[4];\n        t5 = v11[5];\n        t6 = v11[6];\n        t7 = v11[7];\n\n        R11 = t0 & 0xFFFF;\n        R12 = (t0 >> 16) & 0xFFFF;\n\n        R13 = t1 & 0xFFFF;\n        R21 = (t1 >> 16) & 0xFFFF;\n\n        R22 = t2 & 0xFFFF;\n        R23 = (t2 >> 16) & 0xFFFF;\n\n        R31 = t3 & 0xFFFF;\n        R32 = (t3 >> 16) & 0xFFFF;\n        R33 = t4;\n\n        TRX = t5;\n        TRY = t6;\n        TRZ = t7;\n\n        ///@FIXME for some reason at index 0 it wont draw right holster!\n#if defined(USE_32_BIT_ADDR)\n        db.polyptr = (char*)sub_658L1((short*)((int*)s0)[0], (int*)db.polyptr, (int)db.ot);\n#else\n        db.polyptr = (char*)sub_658L1((short*)((int*)s0)[0], (int*)db.polyptr, (int)db.ot);\n#endif\n    }\n    //loc_538\n    //v0 = lara.back_gun\n    //v1 = objects\n\n    if (lara.back_gun != 0)\n    {\n        //a2 = objects[lara.back_gun].bone_index\n        //v1 = \n        bone = &bones[objects[lara.back_gun].bone_index];//a2\n        //v0 =  objects[lara.back_gun].mesh_index\n        s0 = (int*)&meshes[objects[lara.back_gun].mesh_index];//$s0\n\n        v11 = (int*)&lara_matrices[7];\n\n        t0 = v11[0];\n        t1 = v11[1];\n        t2 = v11[2];\n        t3 = v11[3];\n        t4 = v11[4];\n        t5 = v11[5];\n        t6 = v11[6];\n        t7 = v11[7];\n\n        R11 = t0 & 0xFFFF;\n        R12 = (t0 >> 16) & 0xFFFF;\n\n        R13 = t1 & 0xFFFF;\n        R21 = (t1 >> 16) & 0xFFFF;\n\n        R22 = t2 & 0xFFFF;\n        R23 = (t2 >> 16) & 0xFFFF;\n\n        R31 = t3 & 0xFFFF;\n        R32 = (t3 >> 16) & 0xFFFF;\n        R33 = t4;\n\n        TRX = t5;\n        TRY = t6;\n        TRZ = t7;\n\n        sub_1358L1(bone[53], bone[54], bone[55]);\n        ///@FIXME for some reason at index 0 it wont draw back gun!\n#if defined(USE_32_BIT_ADDR)\n        db.polyptr = (char*)sub_658L1((short*)((int*)s0)[28], (int*)db.polyptr, (int)db.ot);\n#else\n        db.polyptr = (char*)sub_658L1((short*)((int*)s0)[28], (int*)db.polyptr, (int)db.ot);\n#endif\n\n    }\n    //loc_5D0\n    mPopMatrix();\n\n    if (LaraNodeUnderwater[8] != 0)\n    {\n        a0 = LaraNodeAmbient[1];\n    }\n    else\n    {\n        a0 = LaraNodeAmbient[0];\n    }\n\n    //loc_5F0\n    RBK = (((int*)&a0.r)[0] & 0xFF) << 4;\n    GBK = ((((int*)&a0.r)[0] >> 4) & 0xFF0);\n    BBK = ((((int*)&a0.r)[0] >> 12) & 0xFF0);\n\n    sub_E38L1();\n\n    sub_1184L1();\n}\n\nvoid DrawLaraL1()\n{\n    sub_2CL1(lara_item);\n}', 'message': '[Specific-PSXPC_N] Correct sub_658.\n', 'author_name': 'Gh0stBlade', 'lang': 'C'}