level_commands.h (7573B)
1 #ifndef LEVEL_COMMANDS_H 2 #define LEVEL_COMMANDS_H 3 4 #include "command_macros_base.h" 5 6 #include "level_table.h" 7 8 #define OP_AND 0 9 #define OP_NAND 1 10 #define OP_EQ 2 11 #define OP_NEQ 3 12 #define OP_LT 4 13 #define OP_LEQ 5 14 #define OP_GT 6 15 #define OP_GEQ 7 16 17 #define OP_SET 0 18 #define OP_GET 1 19 20 #define VAR_CURR_SAVE_FILE_NUM 0 21 #define VAR_CURR_COURSE_NUM 1 22 #define VAR_CURR_ACT_NUM 2 23 #define VAR_CURR_LEVEL_NUM 3 24 #define VAR_CURR_AREA_INDEX 4 25 26 #define WARP_CHECKPOINT 0x80 27 #define WARP_NO_CHECKPOINT 0x00 28 29 #define WHIRLPOOL_COND_ALWAYS 0 30 #define WHIRLPOOL_COND_BOWSER2_BEATEN 2 31 #define WHIRLPOOL_COND_AT_LEAST_SECOND_STAR 3 32 33 // Head defines 34 #define REGULAR_FACE 0x0002 35 #define DIZZY_FACE 0x0003 36 37 #ifdef NO_SEGMENTED_MEMORY 38 #define EXECUTE(seg, script, scriptEnd, entry) \ 39 CMD_BBH(0x00, 0x10, 0x0000), \ 40 CMD_PTR(NULL), \ 41 CMD_PTR(NULL), \ 42 CMD_PTR(entry) 43 44 #define EXIT_AND_EXECUTE(seg, script, scriptEnd, entry) \ 45 CMD_BBH(0x01, 0x10, 0x0000), \ 46 CMD_PTR(NULL), \ 47 CMD_PTR(NULL), \ 48 CMD_PTR(entry) 49 #else 50 #define EXECUTE(seg, script, scriptEnd, entry) \ 51 CMD_BBH(0x00, 0x10, seg), \ 52 CMD_PTR(script), \ 53 CMD_PTR(scriptEnd), \ 54 CMD_PTR(entry) 55 56 #define EXIT_AND_EXECUTE(seg, script, scriptEnd, entry) \ 57 CMD_BBH(0x01, 0x10, seg), \ 58 CMD_PTR(script), \ 59 CMD_PTR(scriptEnd), \ 60 CMD_PTR(entry) 61 #endif 62 63 #define EXIT() \ 64 CMD_BBH(0x02, 0x04, 0x0000) 65 66 #define SLEEP(frames) \ 67 CMD_BBH(0x03, 0x04, frames) 68 69 #define SLEEP_BEFORE_EXIT(frames) \ 70 CMD_BBH(0x04, 0x04, frames) 71 72 #define JUMP(target) \ 73 CMD_BBH(0x05, 0x08, 0x0000), \ 74 CMD_PTR(target) 75 76 #define JUMP_LINK(target) \ 77 CMD_BBH(0x06, 0x08, 0x0000), \ 78 CMD_PTR(target) 79 80 #define RETURN() \ 81 CMD_BBH(0x07, 0x04, 0x0000) 82 83 #define JUMP_LINK_PUSH_ARG(arg) \ 84 CMD_BBH(0x08, 0x04, arg) 85 86 #define JUMP_N_TIMES() \ 87 CMD_BBH(0x09, 0x04, 0x0000) 88 89 #define LOOP_BEGIN() \ 90 CMD_BBH(0x0A, 0x04, 0x0000) 91 92 #define LOOP_UNTIL(op, arg) \ 93 CMD_BBBB(0x0B, 0x08, op, 0x00), \ 94 CMD_W(arg) 95 96 #define JUMP_IF(op, arg, target) \ 97 CMD_BBBB(0x0C, 0x0C, op, 0x00), \ 98 CMD_W(arg), \ 99 CMD_PTR(target) 100 101 #define JUMP_LINK_IF(op, arg, target) \ 102 CMD_BBBB(0x0D, 0x0C, op, 0x00), \ 103 CMD_W(arg), \ 104 CMD_PTR(target) 105 106 107 #define SKIP_IF(op, arg) \ 108 CMD_BBBB(0x0E, 0x08, op, 0) \ 109 CMD_W(arg) 110 111 #define SKIP() \ 112 CMD_BBH(0x0F, 0x04, 0x0000) 113 114 #define SKIP_NOP() \ 115 CMD_BBH(0x10, 0x04, 0x0000) 116 117 #define CALL(arg, func) \ 118 CMD_BBH(0x11, 0x08, arg), \ 119 CMD_PTR(func) 120 121 // Calls func in a loop until it returns nonzero 122 #define CALL_LOOP(arg, func) \ 123 CMD_BBH(0x12, 0x08, arg), \ 124 CMD_PTR(func) 125 126 #define SET_REG(value) \ 127 CMD_BBH(0x13, 0x04, value) 128 129 #define PUSH_POOL() \ 130 CMD_BBH(0x14, 0x04, 0x0000) 131 132 #define POP_POOL() \ 133 CMD_BBH(0x15, 0x04, 0x0000) 134 135 #ifdef NO_SEGMENTED_MEMORY 136 #define FIXED_LOAD(loadAddr, romStart, romEnd) \ 137 CMD_BBH(0x16, 0x10, 0x0000), \ 138 CMD_PTR(NULL), \ 139 CMD_PTR(NULL), \ 140 CMD_PTR(NULL) 141 142 #define LOAD_RAW(seg, romStart, romEnd) \ 143 CMD_BBH(0x17, 0x0C, 0x0000), \ 144 CMD_PTR(NULL), \ 145 CMD_PTR(NULL) 146 147 #define LOAD_MIO0(seg, romStart, romEnd) \ 148 CMD_BBH(0x18, 0x0C, 0x0000), \ 149 CMD_PTR(NULL), \ 150 CMD_PTR(NULL) 151 #else 152 #define FIXED_LOAD(loadAddr, romStart, romEnd) \ 153 CMD_BBH(0x16, 0x10, 0x0000), \ 154 CMD_PTR(loadAddr), \ 155 CMD_PTR(romStart), \ 156 CMD_PTR(romEnd) 157 158 #define LOAD_RAW(seg, romStart, romEnd) \ 159 CMD_BBH(0x17, 0x0C, seg), \ 160 CMD_PTR(romStart), \ 161 CMD_PTR(romEnd) 162 163 #define LOAD_MIO0(seg, romStart, romEnd) \ 164 CMD_BBH(0x18, 0x0C, seg), \ 165 CMD_PTR(romStart), \ 166 CMD_PTR(romEnd) 167 #endif 168 169 #define LOAD_MARIO_HEAD(sethead) \ 170 CMD_BBH(0x19, 0x04, sethead) 171 172 #ifdef NO_SEGMENTED_MEMORY 173 #define LOAD_MIO0_TEXTURE(seg, romStart, romEnd) \ 174 CMD_BBH(0x1A, 0x0C, 0x0000), \ 175 CMD_PTR(NULL), \ 176 CMD_PTR(NULL) 177 #else 178 #define LOAD_MIO0_TEXTURE(seg, romStart, romEnd) \ 179 CMD_BBH(0x1A, 0x0C, seg), \ 180 CMD_PTR(romStart), \ 181 CMD_PTR(romEnd) 182 #endif 183 184 #define INIT_LEVEL() \ 185 CMD_BBH(0x1B, 0x04, 0x0000) 186 187 #define CLEAR_LEVEL() \ 188 CMD_BBH(0x1C, 0x04, 0x0000) 189 190 #define ALLOC_LEVEL_POOL() \ 191 CMD_BBH(0x1D, 0x04, 0x0000) 192 193 #define FREE_LEVEL_POOL() \ 194 CMD_BBH(0x1E, 0x04, 0x0000) 195 196 #define AREA(index, geo) \ 197 CMD_BBBB(0x1F, 0x08, index, 0), \ 198 CMD_PTR(geo) 199 200 #define END_AREA() \ 201 CMD_BBH(0x20, 0x04, 0x0000) 202 203 #define LOAD_MODEL_FROM_DL(model, dl, layer) \ 204 CMD_BBH(0x21, 0x08, ((layer << 12) | model)), \ 205 CMD_PTR(dl) 206 207 #define LOAD_MODEL_FROM_GEO(model, geo) \ 208 CMD_BBH(0x22, 0x08, model), \ 209 CMD_PTR(geo) 210 211 // unk8 is float, but doesn't really matter since CMD23 is unused 212 #define CMD23(model, unk4, unk8) \ 213 CMD_BBH(0x22, 0x08, model), \ 214 CMD_PTR(unk4), \ 215 CMD_W(unk8) 216 217 #define OBJECT_WITH_ACTS(model, posX, posY, posZ, angleX, angleY, angleZ, bhvParam, bhv, acts) \ 218 CMD_BBBB(0x24, 0x18, acts, model), \ 219 CMD_HHHHHH(posX, posY, posZ, angleX, angleY, angleZ), \ 220 CMD_W(bhvParam), \ 221 CMD_PTR(bhv) 222 223 #define OBJECT(model, posX, posY, posZ, angleX, angleY, angleZ, bhvParam, bhv) \ 224 OBJECT_WITH_ACTS(model, posX, posY, posZ, angleX, angleY, angleZ, bhvParam, bhv, 0x1F) 225 226 #define MARIO(model, bhvArg, bhv) \ 227 CMD_BBBB(0x25, 0x0C, 0x00, model), \ 228 CMD_W(bhvArg), \ 229 CMD_PTR(bhv) 230 231 #define WARP_NODE(id, destLevel, destArea, destNode, flags) \ 232 CMD_BBBB(0x26, 0x08, id, destLevel), \ 233 CMD_BBBB(destArea, destNode, flags, 0x00) 234 235 #define PAINTING_WARP_NODE(id, destLevel, destArea, destNode, flags) \ 236 CMD_BBBB(0x27, 0x08, id, destLevel), \ 237 CMD_BBBB(destArea, destNode, flags, 0x00) 238 239 #define INSTANT_WARP(index, destArea, displaceX, displaceY, displaceZ) \ 240 CMD_BBBB(0x28, 0x0C, index, destArea), \ 241 CMD_HH(displaceX, displaceY), \ 242 CMD_HH(displaceZ, 0x0000) 243 244 #define LOAD_AREA(area) \ 245 CMD_BBBB(0x29, 0x04, area, 0x00) 246 247 #define CMD2A(unk2) \ 248 CMD_BBBB(0x2A, 0x04, unk2, 0x00) 249 250 #define MARIO_POS(area, yaw, posX, posY, posZ) \ 251 CMD_BBBB(0x2B, 0x0C, area, 0x00), \ 252 CMD_HH(yaw, posX), \ 253 CMD_HH(posY, posZ) 254 255 // unused 256 #define CMD2C() \ 257 CMD_BBH(0x2C, 0x04, 0x0000) 258 259 // unused 260 #define CMD2D() \ 261 CMD_BBH(0x2D, 0x04, 0x0000) 262 263 #define TERRAIN(terrainData) \ 264 CMD_BBH(0x2E, 0x08, 0x0000), \ 265 CMD_PTR(terrainData) 266 267 #define ROOMS(surfaceRooms) \ 268 CMD_BBH(0x2F, 0x08, 0x0000), \ 269 CMD_PTR(surfaceRooms) 270 271 #define SHOW_DIALOG(index, dialogID) \ 272 CMD_BBBB(0x30, 0x04, index, dialogID) 273 274 #define TERRAIN_TYPE(terrainType) \ 275 CMD_BBH(0x31, 0x04, terrainType) 276 277 #define NOP() \ 278 CMD_BBH(0x32, 0x04, 0x0000) 279 280 #define TRANSITION(transType, time, colorR, colorG, colorB) \ 281 CMD_BBBB(0x33, 0x08, transType, time), \ 282 CMD_BBBB(colorR, colorG, colorB, 0x00) 283 284 #define BLACKOUT(active) \ 285 CMD_BBBB(0x34, 0x04, active, 0x00) 286 287 #define GAMMA(enabled) \ 288 CMD_BBBB(0x35, 0x04, enabled, 0x00) 289 290 #define SET_BACKGROUND_MUSIC(settingsPreset, seq) \ 291 CMD_BBH(0x36, 0x08, settingsPreset), \ 292 CMD_HH(seq, 0x0000) 293 294 #define SET_MENU_MUSIC(seq) \ 295 CMD_BBH(0x37, 0x04, seq) 296 297 #define STOP_MUSIC(fadeOutTime) \ 298 CMD_BBH(0x38, 0x04, fadeOutTime) 299 300 #define MACRO_OBJECTS(objList) \ 301 CMD_BBH(0x39, 0x08, 0x0000), \ 302 CMD_PTR(objList) 303 304 // unused 305 #define CMD3A(unk2, unk4, unk6, unk8, unk10) \ 306 CMD_BBH(0x3A, 0x0C, unk2), \ 307 CMD_HH(unk6, unk8), \ 308 CMD_HH(unk10, 0x0000) 309 310 #define WHIRLPOOL(index, condition, posX, posY, posZ, strength) \ 311 CMD_BBBB(0x3B, 0x0C, index, condition), \ 312 CMD_HH(posX, posY), \ 313 CMD_HH(posZ, strength) 314 315 #define GET_OR_SET(op, var) \ 316 CMD_BBBB(0x3C, 0x04, op, var) 317 318 #endif // LEVEL_COMMANDS_H