Mario Kart 64
Loading...
Searching...
No Matches
trig_tables.h
Go to the documentation of this file.
1#ifndef TRIG_TABLES_H
2#define TRIG_TABLES_H
3
4/*
5 * The sine and cosine tables overlap, but "#define gCosineTable (gSineTable +
6 * 0x400)" doesn't give expected codegen; gSineTable and gCosineTable need to
7 * be different symbols for code to match. Most likely the tables were placed
8 * adjacent to each other, and gSineTable cut short, such that reads overflow
9 * into gCosineTable.
10 *
11 * These kinds of out of bounds reads are undefined behavior, and break on
12 * e.g. GCC (which doesn't place the tables next to each other, and probably
13 * exploits array sizes for range analysis-based optimizations as well).
14 * Thus, for non-IDO compilers we use the standard-compliant version.
15 */
16extern f32 gSineTable[];
17#ifdef AVOID_UB
18#define gCosineTable (gSineTable + 0x400)
19#else
20extern f32 gCosineTable[];
21#endif
22
23extern s16 gArctanTable[];
24
25#endif
f32 gSineTable[]
Definition trig_tables.c:4
f32 gCosineTable[]
Definition trig_tables.c:136
s16 gArctanTable[]
Definition trig_tables.c:4243
signed short int s16
Definition ultratypes.h:13
float f32
Definition ultratypes.h:34