Mario Kart 64
Loading...
Searching...
No Matches
mk64.h
Go to the documentation of this file.
1#ifndef MK64_H
2#define MK64_H
3
4#include <libultraship.h>
5#include <string.h>
6#include <libultra/gbi.h>
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
16
17/*=======================
18 Configuration
19=======================*/
20
21#define AUDIO_HEAP_SIZE 0x48C00
22#define AUDIO_HEAP_INIT_SIZE 0x2600
23
24#define DOUBLE_SIZE_ON_64_BIT(size) ((size) * (sizeof(void*) / 4))
25
26#define SCREEN_WIDTH 320
27#define SCREEN_HEIGHT 240
28
29#define STACKSIZE 0x2000
30
31// Border Height Define for NTSC Versions
32#define BORDER_HEIGHT 1
33
58
59#define COURSE_NULL 0xFF
60
80
85 /* -0x1 */ SURFACE_DEFAULT = -1,
86 /* 0x00 */ AIRBORNE,
87 /* 0x01 */ ASPHALT, // Luigi's Raceway, Toad's Turnpike, Koopa Troop beach shortcut tunnel, Mario Raceway, Royal
88 // Raceway, Rainbow Road, Block Fort, Double Deck, Skyscraper
89 /* 0x02 */ DIRT, // Luigi's Raceway, Moo Moo Farm, Kalimiari Desert on course, Choco Mountain, Wario Stadium, DK
90 // Jungle on course, Yoshi Valley
91 /* 0x03 */ SAND, // Koopa Troopa Beach light color, Royal Raceway
92 /* 0x04 */ STONE, // Royal Raceway castle entrance, Bowser's Castle
93 /* 0x05 */ SNOW, // Frappe Snowland on course, Sherber Land tunnel
94 /* 0x06 */ BRIDGE, // Royal Raceway castle bridges (even the wooden one), Banshee's Boardwalk, Big Donut
95 /* 0x07 */ SAND_OFFROAD, // Mario Raceway
96 /* 0x08 */ GRASS, // Luigi's Raceway, Mario Raceway, Royal Raceway, Bowser's Castle, DK Jungle, Yoshi Valley
97 /* 0x09 */ ICE, // Sherbert Land
98 /* 0x0A */ WET_SAND, // Koop Troopa Beach dark color
99 /* 0x0B */ SNOW_OFFROAD, // Frappe Snowland off course
100 /* 0x0C */ CLIFF, // Koopa Troopa Beach, Choco Mountain
101 /* 0x0D */ DIRT_OFFROAD, // Kalimari Desert off course
102 /* 0x0E */ TRAIN_TRACK, // Kalimari Desert
103 /* 0x0F */ CAVE, // DK Jungle cave
104 /* 0x10 */ ROPE_BRIDGE, // Bowser's Castle bridge 2, DK Jungle bridge
105 /* 0x11 */ WOOD_BRIDGE, // Frappe Snowland bridge, Bowser's Castle bridge 1,3, Yoshi Valley bridge 2
106 /* 0xFB */ WATER_SURFACE = 0xFB, // Water effect and Lakitu picks up the player
107 /* 0xFC */ BOOST_RAMP_WOOD = 0xFC, // DK Jungle
108 /* 0xFD */ OUT_OF_BOUNDS, // DK Jungle river island oob / out of bounds
109 /* 0xFE */ BOOST_RAMP_ASPHALT, // Royal Raceway
110 /* 0xFF */ RAMP // Koopa Troopa beach
111};
112
113#define GFX_GET_OPCODE(var) ((uint32_t) ((var) & 0xFF000000))
114
115// Pointer casting is technically UB, and avoiding it gets rid of endian issues
116// as well as a nice side effect.
117#ifdef AVOID_UB
118#define GET_HIGH_U16_OF_32(var) ((u16) ((var) >> 16))
119#define GET_HIGH_S16_OF_32(var) ((s16) ((var) >> 16))
120#define GET_LOW_U16_OF_32(var) ((u16) ((var) & 0xFFFF))
121#define GET_LOW_S16_OF_32(var) ((s16) ((var) & 0xFFFF))
122#define SET_HIGH_U16_OF_32(var, x) ((var) = ((var) & 0xFFFF) | ((x) << 16))
123#define SET_HIGH_S16_OF_32(var, x) ((var) = ((var) & 0xFFFF) | ((x) << 16))
124#else
125#define GET_HIGH_U16_OF_32(var) (((u16*) &(var))[0])
126#define GET_HIGH_S16_OF_32(var) (((s16*) &(var))[0])
127#define GET_LOW_U16_OF_32(var) (((u16*) &(var))[1])
128#define GET_LOW_S16_OF_32(var) (((s16*) &(var))[1])
129#define SET_HIGH_U16_OF_32(var, x) ((((u16*) &(var))[0]) = (x))
130#define SET_HIGH_S16_OF_32(var, x) ((((s16*) &(var))[0]) = (x))
131#endif
132
133#define MACRO_COLOR_FLAG(r, g, b, flag) (r & ~0x3) | (flag & 0x3), (g & ~0x3) | ((flag >> 2) & 0x3), b
134
135// Extra gbi commands
136void gSPSegmentLoadRes(void* value, int segNum, uintptr_t target);
137void gSPDisplayList(Gfx* pkt, Gfx* dl);
138void gSPDisplayListOffset(Gfx* pkt, Gfx* dl, int offset);
139void gSPVertex(Gfx* pkt, uintptr_t v, int n, int v0);
140void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr);
141
142#define TEXTURE_LOAD_FIX 2
143#define TEXTURE_SIZE_FIX 1
144
145#ifdef __cplusplus
146}
147#endif
148
149#endif // MK64_H
void gSPInvalidateTexCache(Gfx *pkt, uintptr_t texAddr)
Definition GBIMiddleware.cpp:32
void gSPSegmentLoadRes(void *value, int segNum, uintptr_t target)
void gSPDisplayList(Gfx *pkt, Gfx *dl)
Definition GBIMiddleware.cpp:11
SURFACE_TYPE
The different types of surface in the game.
Definition mk64.h:84
@ WATER_SURFACE
Definition mk64.h:106
@ STONE
Definition mk64.h:92
@ RAMP
Definition mk64.h:110
@ WOOD_BRIDGE
Definition mk64.h:105
@ WET_SAND
Definition mk64.h:98
@ BRIDGE
Definition mk64.h:94
@ ICE
Definition mk64.h:97
@ ASPHALT
Definition mk64.h:87
@ ROPE_BRIDGE
Definition mk64.h:104
@ SAND_OFFROAD
Definition mk64.h:95
@ BOOST_RAMP_WOOD
Definition mk64.h:107
@ DIRT_OFFROAD
Definition mk64.h:101
@ CAVE
Definition mk64.h:103
@ SNOW
Definition mk64.h:93
@ SNOW_OFFROAD
Definition mk64.h:99
@ BOOST_RAMP_ASPHALT
Definition mk64.h:109
@ OUT_OF_BOUNDS
Definition mk64.h:108
@ SAND
Definition mk64.h:91
@ SURFACE_DEFAULT
Definition mk64.h:85
@ AIRBORNE
Definition mk64.h:86
@ TRAIN_TRACK
Definition mk64.h:102
@ CLIFF
Definition mk64.h:100
@ DIRT
Definition mk64.h:89
@ GRASS
Definition mk64.h:96
COURSES
Definition mk64.h:34
@ COURSE_WARIO_STADIUM
Definition mk64.h:49
@ COURSE_MARIO_RACEWAY
Definition mk64.h:35
@ COURSE_BANSHEE_BOARDWALK
Definition mk64.h:38
@ COURSE_BIG_DONUT
Definition mk64.h:54
@ COURSE_ROYAL_RACEWAY
Definition mk64.h:42
@ COURSE_BLOCK_FORT
Definition mk64.h:50
@ COURSE_KALIMARI_DESERT
Definition mk64.h:46
@ COURSE_FRAPPE_SNOWLAND
Definition mk64.h:40
@ COURSE_LUIGI_RACEWAY
Definition mk64.h:43
@ COURSE_RAINBOW_ROAD
Definition mk64.h:48
@ COURSE_YOSHI_VALLEY
Definition mk64.h:39
@ COURSE_CHOCO_MOUNTAIN
Definition mk64.h:36
@ COURSE_TOADS_TURNPIKE
Definition mk64.h:45
@ COURSE_SKYSCRAPER
Definition mk64.h:51
@ COURSE_DOUBLE_DECK
Definition mk64.h:52
@ COURSE_BOWSER_CASTLE
Definition mk64.h:37
@ COURSE_KOOPA_BEACH
Definition mk64.h:41
@ NUM_COURSES
Definition mk64.h:56
@ COURSE_MOO_MOO_FARM
Definition mk64.h:44
@ COURSE_DK_JUNGLE
Definition mk64.h:53
@ COURSE_SHERBET_LAND
Definition mk64.h:47
@ COURSE_AWARD_CEREMONY
Definition mk64.h:55
void gSPDisplayListOffset(Gfx *pkt, Gfx *dl, int offset)
void gSPVertex(Gfx *pkt, uintptr_t v, int n, int v0)
Definition GBIMiddleware.cpp:23
TIME_TRIAL_DATA_INDEX
Definition mk64.h:61
@ TIME_TRIAL_DATA_BANSHEE_BOARDWALK
Definition mk64.h:76
@ TIME_TRIAL_DATA_ROYAL_RACEWAY
Definition mk64.h:72
@ TIME_TRIAL_DATA_SHERBET_LAND
Definition mk64.h:71
@ TIME_TRIAL_DATA_KOOPA_BEACH
Definition mk64.h:64
@ TIME_TRIAL_DATA_YOSHI_VALLEY
Definition mk64.h:75
@ TIME_TRIAL_DATA_KALAMARI_DESERT
Definition mk64.h:65
@ TIME_TRIAL_DATA_WARIO_STADIUM
Definition mk64.h:70
@ TIME_TRIAL_DATA_BOWSER_CASTLE
Definition mk64.h:73
@ TIME_TRIAL_DATA_CHOCO_MOUNTAIN
Definition mk64.h:68
@ TIME_TRIAL_DATA_FRAPPE_SNOWLAND
Definition mk64.h:67
@ NUM_TIME_TRIAL_DATA
Definition mk64.h:78
@ TIME_TRIAL_DATA_RAINBOW_ROAD
Definition mk64.h:77
@ TIME_TRIAL_DATA_TOADS_TURNPIKE
Definition mk64.h:66
@ TIME_TRIAL_DATA_MARIO_RACEWAY
Definition mk64.h:69
@ TIME_TRIAL_DATA_LUIGI_RACEWAY
Definition mk64.h:62
@ TIME_TRIAL_DATA_DK_JUNGLE
Definition mk64.h:74
@ TIME_TRIAL_DATA_MOO_MOO_FARM
Definition mk64.h:63