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 "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 */
16typedef 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 */
24typedef struct {
25 char unk_00[0x920];
26} struct_D_802DFB80; // size = 0x920
27
28typedef struct {
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 */
51typedef struct {
52 /* 0x000 */ RGBA5551 kart_palette[0xC0];
53 /* 0x180 */ RGBA5551 wheel_palette[0x40];
54} struct_D_802F1F80; // size = 0x200
55
56extern u16 gRandomSeed16;
57extern u8 randomSeedPadding[216];
58extern struct_D_802BFB80 D_802BFB80[][2][8];
59extern struct_D_802DFB80 D_802DFB80[][2][8];
60
67#ifdef AVOID_UB
68extern struct_D_802F1F80 D_802F1F80[2][4][8];
69#else
70extern 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
82extern 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 // BUFFERS_H
struct_D_802BFB80 D_802BFB80[][2][8]
Definition buffers.c:16
u16 gFramebuffer1[SCREEN_WIDTH *SCREEN_HEIGHT]
Definition buffers.c:30
u16 D_802F1F80[][4][0x100 *8]
Definition buffers.c:21
u16 gRandomSeed16
Definition buffers.c:6
u16 gFramebuffer2[SCREEN_WIDTH *SCREEN_HEIGHT]
Definition buffers.c:31
u16 gFramebuffer0[SCREEN_WIDTH *SCREEN_HEIGHT]
Definition buffers.c:29
struct_D_802DFB80 D_802DFB80[][2][8]
Definition buffers.c:17
u16 gZBuffer[SCREEN_WIDTH *SCREEN_HEIGHT]
Definition buffers.c:24
u8 randomSeedPadding[216]
Definition buffers.c:8
#define SCREEN_WIDTH
Definition config.h:10
#define SCREEN_HEIGHT
Definition config.h:11
Definition buffers.h:28
u16 red
Definition buffers.h:29
u16 green
Definition buffers.h:30
u16 alpha
Definition buffers.h:32
u16 blue
Definition buffers.h:31
Definition buffers.h:16
Definition buffers.h:24
Definition buffers.h:51
unsigned short int u16
Definition ultratypes.h:14
unsigned char u8
Definition ultratypes.h:12