Mario Kart 64
Loading...
Searching...
No Matches
buffers.h
Go to the documentation of this file.
1#ifndef BUFFERS_H
2#define BUFFERS_H
3
4#include <PR/ultratypes.h>
5#include <mk64.h>
6#include <common_structs.h>
7
8/*
9 * This type could reasonably be called decodedTexture or similar
10 * These are textures that have been passed through mio0decode
11 *
12 * According to http://ultra64.ca/files/documentation/online-manuals/man/app/te/us/tmf.html
13 * This is technically an array of u32's, but each u32 contains 8/4 pixels depending
14 * on pixel depth of the texure (4/8 bits respectively) so representing it as u8's should be fine
15 */
16typedef struct {
17 u8 pixel_index_array[0x1000];
18} struct_D_802BFB80_8; // size = 0x1000
19
20typedef struct {
21 u8 pixel_index_array[0x2000];
22} struct_D_802BFB80_4; // size = 0x1000
23
24/*
25 * In render_player, spawn_players, and staff_ghosts D_802BFB80 is the arraySize8 entry
26 * But in code_80091750 its the arraySize4 entry
27 * The only way to unify those 2 things is to use a union
28 */
29typedef union {
30 struct_D_802BFB80_4 arraySize4[2][2][4];
31 struct_D_802BFB80_8 arraySize8[2][2][8];
33
34/*
35 * Texture prior to be being decoded via mio0decode
36 * Likely over-sized due to encoded textures having variable size
37 */
38typedef struct {
39 char unk_00[0x920];
40} struct_D_802DFB80; // size = 0x920
41
42typedef struct {
43 u16 red : 5;
45 u16 blue : 5;
47} RGBA5551;
48
49/*
50 * This type could reasonably be called activeCharacterPalette or similar
51 *
52 * Appears to be a combination of 2 different palettes:
53 * kart_palette contains the palette for all non-wheel elements of the kart (including the driver).
54 * wheel_palette contains the palette for the wheels.
55 *
56 * kart palette sets a defined palette based on the character while
57 * wheels palette sets a dynamic palette as you drive around with the kart.
58 *
59 * The term "palette" appears to be synonymous with "texture lookup table (TLUT)",
60 * at least as far as the N64 texture engine is concerned
61 * According to http://ultra64.ca/files/documentation/online-manuals/man/app/te/us/tlf.html
62 * palettes are technically arrays of u32's, but I feel using a more meaningful data type
63 * helps with understanding.
64 */
65typedef struct {
66 /* 0x000 */ RGBA5551 kart_palette[0xC0];
67 /* 0x180 */ RGBA5551 wheel_palette[0x40];
68} struct_D_802F1F80; // size = 0x200
69
70extern u16 gRandomSeed16;
71extern u8 randomSeedPadding[216];
74
81#ifdef AVOID_UB
83#else
84extern u16 gPlayerPalettesList[][4][0x100 * 8];
85#endif
87
88// NOTE: This UB fix from sm64 implemented in mk64,
89// in-case it has the same issue.
90// untested. Unconfirmed if this applies to mk64.
91
92// level_script.c assumes that the frame buffers are adjacent, while game.c's
93// -g codegen implies that they are separate variables. This is impossible to
94// reconcile without undefined behavior. Avoid that when possible.
95#ifdef AVOID_UB
96extern u16 gFramebuffers[3][SCREEN_WIDTH * SCREEN_HEIGHT];
97#define gFramebuffer0 gFramebuffers[0]
98#define gFramebuffer1 gFramebuffers[1]
99#define gFramebuffer2 gFramebuffers[2]
100#else
104#endif
105
106#endif // BUFFERS_H
struct_D_802DFB80 gEncodedKartTexture[][2][8]
Definition buffers.c:10
u16 gFramebuffer1[SCREEN_WIDTH *SCREEN_HEIGHT]
Definition buffers.c:23
union_D_802BFB80 D_802BFB80
look like to be a buffer of decoded textures
Definition buffers.c:9
u16 gRandomSeed16
Definition random.c:3
u16 gFramebuffer2[SCREEN_WIDTH *SCREEN_HEIGHT]
Definition buffers.c:24
u16 gPlayerPalettesList[][4][0x100 *8]
Definition buffers.c:14
u16 gFramebuffer0[SCREEN_WIDTH *SCREEN_HEIGHT]
Definition buffers.c:22
u16 gZBuffer[SCREEN_WIDTH *SCREEN_HEIGHT]
Definition buffers.c:17
u8 randomSeedPadding[216]
Definition random.c:4
#define SCREEN_WIDTH
Definition mk64.h:18
#define SCREEN_HEIGHT
Definition mk64.h:19
Definition buffers.h:42
u16 red
Definition buffers.h:43
u16 green
Definition buffers.h:44
u16 alpha
Definition buffers.h:46
u16 blue
Definition buffers.h:45
Definition buffers.h:20
Definition buffers.h:16
Definition buffers.h:38
Definition buffers.h:65
unsigned short int u16
Definition ultratypes.h:14
unsigned char u8
Definition ultratypes.h:12
Definition buffers.h:29