Files
hackerlibultra/src/gu/mtxutil.c
someone2639 c366e0122a Format the Repo (#3)
* set build options

* remove COMPARE and MDOERN_* switches

* remove tools makefile

* AR patching is gone too since we want a fullly decomped version

* AR is modern

* remove cwd changes

* edit my own tool to fix compile errors

* compile files generated with my own tool instead of the originals

* inline modern_gcc makefile

* port mips toolchain detection logic

* add util.mk for find-command

* remove forced AR order and strip/mdebug removal commands

* add -mabi=32 to as flags

* formatting changes

* add clang format files

* formatting changes

* make libgultra CI work

* install mips gcc too

* add format check tools

* Add formatting to CI

* Add CI (#4)

* make libgultra CI work

* install mips gcc too

* remove make setup

---------

Co-authored-by: someone2639 <someone2639@gmail.com>

* we don't use clang-tidy

* use 120 width for formatting

* a

* address clang-tidy messing up

* test

* align consecutive macros and declarations

* only align macros for now

* SpaceAfterCStyleCast: false

* format headers too

* remove cast space switch because its false by default

* pointers on left

* AlignConsecutiveBitFields: true

* install clang-format and clang-tidy on gh actions

* and clang-tools

* show diff in format check tool

* make CI work

---------

Co-authored-by: someone2639 <someone2639@gmail.com>
🙏
2025-02-17 22:56:09 -05:00

71 lines
1.9 KiB
C

/**************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
#include "guint.h"
void guMtxF2L(float mf[4][4], Mtx* m) {
int i, j;
int e1, e2;
int *ai, *af;
ai = (int*)&m->m[0][0];
af = (int*)&m->m[2][0];
for (i = 0; i < 4; i++)
for (j = 0; j < 2; j++) {
e1 = FTOFIX32(mf[i][j * 2]);
e2 = FTOFIX32(mf[i][j * 2 + 1]);
*(ai++) = (e1 & 0xffff0000) | ((e2 >> 16) & 0xffff);
*(af++) = ((e1 << 16) & 0xffff0000) | (e2 & 0xffff);
}
}
void guMtxL2F(float mf[4][4], Mtx* m) {
int i, j;
unsigned int e1, e2;
unsigned int *ai, *af;
int q1, q2;
ai = (unsigned int*)&m->m[0][0];
af = (unsigned int*)&m->m[2][0];
for (i = 0; i < 4; i++)
for (j = 0; j < 2; j++) {
e1 = (*ai & 0xffff0000) | ((*af >> 16) & 0xffff);
e2 = ((*(ai++) << 16) & 0xffff0000) | (*(af++) & 0xffff);
q1 = *((int*)&e1);
q2 = *((int*)&e2);
mf[i][j * 2] = FIX32TOF(q1);
mf[i][j * 2 + 1] = FIX32TOF(q2);
}
}
void guMtxIdentF(float mf[4][4]) {
int i, j;
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++)
if (i == j)
mf[i][j] = 1.0;
else
mf[i][j] = 0.0;
}
void guMtxIdent(Mtx* m) {
float mf[4][4];
guMtxIdentF(mf);
guMtxF2L(mf, m);
}