Mario Kart 64
framebuffers.h
Go to the documentation of this file.
1 #ifndef FRAMEBUFFERS_H
2 #define FRAMEBUFFERS_H
3 
4 #include <PR/ultratypes.h>
5 #include "config.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  */
16 typedef struct {
17  u8 pixel_index_array[0x1000];
18 } struct_D_802BFB80; // size = 0x1000
19 
20 /*
21  * Texture prior to be being decoded via mio0decode
22  * Likely over-sized due to encoded textures having variable size
23  */
24 typedef struct {
25  char unk_00[0x920];
26 } struct_D_802DFB80; // size = 0x920
27 
28 typedef struct {
29  u16 red:5;
31  u16 blue:5;
33 } RGBA5551;
34 
35 /*
36  * This type could reasonably be called activeCharacterPalette or similar
37  *
38  * Appears to be a combination of 2 different palettes:
39  * kart_palette contains the palette for all non-wheel elements of the kart (including the driver).
40  * wheel_palette contains the palette for the wheels.
41  *
42  * kart palette sets a defined palette based on the character while
43  * wheels palette sets a dynamic palette as you drive around with the kart.
44  *
45  * The term "palette" appears to be synonymous with "texture lookup table (TLUT)",
46  * at least as far as the N64 texture engine is concerned
47  * According to http://ultra64.ca/files/documentation/online-manuals/man/app/te/us/tlf.html
48  * palettes are technically arrays of u32's, but I feel using a more meaningful data type
49  * helps with understanding.
50  */
51 typedef struct {
52  /* 0x000 */ RGBA5551 kart_palette[0xC0];
53  /* 0x180 */ RGBA5551 wheel_palette[0x40];
54 } struct_D_802F1F80; // size = 0x200
55 
56 extern u16 gRandomSeed16;
57 extern u8 randomSeedPadding[216];
58 extern struct_D_802BFB80 D_802BFB80[][2][8];
59 extern struct_D_802DFB80 D_802DFB80[][2][8];
60 
67 #ifdef AVOID_UB
68 extern struct_D_802F1F80 D_802F1F80[2][4][8];
69 #else
70 extern u16 D_802F1F80[][4][0x100 * 8];
71 #endif
73 
74 // NOTE: This UB fix from sm64 implemented in mk64,
75 // in-case it has the same issue.
76 // untested. Unconfirmed if this applies to mk64.
77 
78 // level_script.c assumes that the frame buffers are adjacent, while game.c's
79 // -g codegen implies that they are separate variables. This is impossible to
80 // reconcile without undefined behavior. Avoid that when possible.
81 #ifdef AVOID_UB
82 extern u16 gFramebuffers[3][SCREEN_WIDTH * SCREEN_HEIGHT];
83 #define gFramebuffer0 gFramebuffers[0]
84 #define gFramebuffer1 gFramebuffers[1]
85 #define gFramebuffer2 gFramebuffers[2]
86 #else
90 #endif
91 
92 #endif // FRAMEBUFFERS_H
#define SCREEN_WIDTH
Definition: config.h:10
#define SCREEN_HEIGHT
Definition: config.h:11
struct_D_802BFB80 D_802BFB80[][2][8]
Definition: framebuffers.c:18
u16 gFramebuffer1[SCREEN_WIDTH *SCREEN_HEIGHT]
Definition: framebuffers.c:32
u16 D_802F1F80[][4][0x100 *8]
Definition: framebuffers.c:23
u16 gRandomSeed16
Definition: framebuffers.c:8
u16 gFramebuffer2[SCREEN_WIDTH *SCREEN_HEIGHT]
Definition: framebuffers.c:33
u16 gFramebuffer0[SCREEN_WIDTH *SCREEN_HEIGHT]
Definition: framebuffers.c:31
struct_D_802DFB80 D_802DFB80[][2][8]
Definition: framebuffers.c:19
u16 gZBuffer[SCREEN_WIDTH *SCREEN_HEIGHT]
Definition: framebuffers.c:26
u8 randomSeedPadding[216]
Definition: framebuffers.c:10
Definition: framebuffers.h:28
u16 red
Definition: framebuffers.h:29
u16 green
Definition: framebuffers.h:30
u16 alpha
Definition: framebuffers.h:32
u16 blue
Definition: framebuffers.h:31
Definition: framebuffers.h:16
Definition: framebuffers.h:24
Definition: framebuffers.h:51
unsigned short int u16
Definition: ultratypes.h:14
unsigned char u8
Definition: ultratypes.h:12