2024-07-12 20:48:23 -03:00
|
|
|
#ifndef UTIL_H
|
|
|
|
#define UTIL_H
|
|
|
|
|
2024-07-15 03:37:57 -03:00
|
|
|
#include <psxgpu.h>
|
2024-07-12 20:48:23 -03:00
|
|
|
#include <psxgte.h>
|
|
|
|
|
2024-10-12 12:50:06 -03:00
|
|
|
// These definitions should be given by CMake
|
|
|
|
#ifndef GIT_SHA1
|
|
|
|
#define GIT_SHA1 "UNKNOWN"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef GIT_REFSPEC
|
|
|
|
#define GIT_REFSPEC "UNKNOWN"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef GIT_COMMIT
|
|
|
|
#define GIT_COMMIT "UNKNOWN"
|
|
|
|
#endif
|
|
|
|
|
2024-11-02 21:00:28 -03:00
|
|
|
#ifndef GIT_VERSION
|
|
|
|
#define GIT_VERSION "UNKNOWN"
|
|
|
|
#endif
|
2024-10-12 12:50:06 -03:00
|
|
|
|
2024-07-19 03:20:04 -03:00
|
|
|
#define BCD_TO_DEC(x) (((x & 0xF0) >> 4) * 10 + (x & 0x0F))
|
2024-08-12 23:33:34 -03:00
|
|
|
#define SIGNUM(x) (x < 0 ? -1 : 1)
|
2024-08-17 13:12:56 -03:00
|
|
|
#define MAX(x, y) (x > y ? x : y)
|
|
|
|
#define MIN(x, y) (x < y ? x : y)
|
2024-07-19 03:20:04 -03:00
|
|
|
|
2024-07-16 18:25:18 -03:00
|
|
|
int RotTransPers(SVECTOR *v, uint32_t *xy0);
|
2024-09-21 17:33:37 -03:00
|
|
|
int RotAverageNclip3(SVECTOR *a, SVECTOR *b, SVECTOR *c,
|
|
|
|
uint32_t *xy0, uint32_t *xy1, uint32_t *xy2,
|
|
|
|
int *otz);
|
2024-07-12 20:48:23 -03:00
|
|
|
int RotAverageNclip4(SVECTOR *a, SVECTOR *b, SVECTOR *c, SVECTOR *d,
|
2024-07-16 18:25:18 -03:00
|
|
|
uint32_t *xy0, uint32_t *xy1, uint32_t *xy2, uint32_t *xy3,
|
2024-07-12 20:48:23 -03:00
|
|
|
int *otz);
|
2024-08-12 22:28:34 -03:00
|
|
|
void CrossProduct0(VECTOR *v0, VECTOR *v1, VECTOR *out);
|
|
|
|
void CrossProduct12(VECTOR *v0, VECTOR *v1, VECTOR *out);
|
2024-07-12 20:48:23 -03:00
|
|
|
|
2024-07-15 17:53:40 -03:00
|
|
|
uint8_t *file_read(const char *filename, uint32_t *length);
|
|
|
|
void load_texture(uint8_t *data, TIM_IMAGE *tim);
|
2024-07-15 03:37:57 -03:00
|
|
|
|
2024-07-15 17:53:40 -03:00
|
|
|
uint8_t get_byte(uint8_t *bytes, uint32_t *b);
|
|
|
|
uint16_t get_short_be(uint8_t *bytes, uint32_t *b);
|
|
|
|
uint16_t get_short_le(uint8_t *bytes, uint32_t *b);
|
2024-08-12 22:28:34 -03:00
|
|
|
uint32_t get_long_be(uint8_t *bytes, uint32_t *b);
|
2024-07-15 03:37:57 -03:00
|
|
|
|
2024-07-21 19:43:49 -03:00
|
|
|
uint32_t adler32(const char *s);
|
2024-08-26 22:47:21 -03:00
|
|
|
int32_t div12(int32_t a, int32_t b); // Division ignoring remainder
|
|
|
|
int32_t floor12(int32_t a);
|
2024-07-21 19:43:49 -03:00
|
|
|
|
2024-07-12 20:48:23 -03:00
|
|
|
#endif
|