#ifndef GEO_COMMANDS_H1#define GEO_COMMANDS_H23#include "command_macros_base.h"45#include "game/shadow.h"6#include "game/object_helpers.h"7#include "game/behavior_actions.h"8#include "game/segment2.h"9#include "game/mario_misc.h"10#include "game/mario_actions_cutscene.h"1112// sky background params13#define BACKGROUND_OCEAN_SKY 014#define BACKGROUND_FLAMING_SKY 115#define BACKGROUND_UNDERWATER_CITY 216#define BACKGROUND_BELOW_CLOUDS 317#define BACKGROUND_SNOW_MOUNTAINS 418#define BACKGROUND_DESERT 519#define BACKGROUND_HAUNTED 620#define BACKGROUND_GREEN_SKY 721#define BACKGROUND_ABOVE_CLOUDS 822#define BACKGROUND_PURPLE_SKY 92324// geo layout macros2526/**27* 0x00: Branch and store return address28* 0x04: scriptTarget, segment address of geo layout29*/30#define GEO_BRANCH_AND_LINK(scriptTarget) \31CMD_BBH(0x00, 0x00, 0x0000), \32CMD_PTR(scriptTarget)3334/**35* 0x01: Terminate geo layout36* 0x01-0x03: unused37*/38#define GEO_END() \39CMD_BBH(0x01, 0x00, 0x0000)4041/**42* 0x02: Branch43* 0x01: if 1, store next geo layout address on stack44* 0x02-0x03: unused45* 0x04: scriptTarget, segment address of geo layout46*/47#define GEO_BRANCH(type, scriptTarget) \48CMD_BBH(0x02, type, 0x0000), \49CMD_PTR(scriptTarget)5051/**52* 0x03: Return from branch53* 0x01-0x03: unused54*/55#define GEO_RETURN() \56CMD_BBH(0x03, 0x00, 0x0000)5758/**59* 0x04: Open node60* 0x01-0x03: unused61*/62#define GEO_OPEN_NODE() \63CMD_BBH(0x04, 0x00, 0x0000)6465/**66* 0x05: Close node67* 0x01-0x03: unused68*/69#define GEO_CLOSE_NODE() \70CMD_BBH(0x05, 0x00, 0x0000)7172/**73* 0x06: Register the current node at the given index in the gGeoViews array74* 0x01: unused75* 0x02: s16 index76*/77#define GEO_ASSIGN_AS_VIEW(index) \78CMD_BBH(0x06, 0x00, index)7980/**81* 0x07: Update current scene graph node flags82* 0x01: u8 operation (0 = reset, 1 = set, 2 = clear)83* 0x02: s16 bits84*/85#define GEO_UPDATE_NODE_FLAGS(operation, flagBits) \86CMD_BBH(0x07, operation, flagBits)8788/**89* 0x08: Create screen area scene graph node90* 0x01: unused91* 0x02: s16 num entries (+2) to allocate92* 0x04: s16 x93* 0x06: s16 y94* 0x08: s16 width95* 0x0A: s16 height96*/97#define GEO_NODE_SCREEN_AREA(numEntries, x, y, width, height) \98CMD_BBH(0x08, 0x00, numEntries), \99CMD_HH(x, y), \100CMD_HH(width, height)101102/**103* 0x09: Create orthographic projection scene graph node104* 0x02: s16 scale as percentage105*/106#define GEO_NODE_ORTHO(scale) \107CMD_BBH(0x09, 0x00, scale)108109/**110* 0x0A: Create camera frustum scene graph node111* 0x01: u8 if nonzero, enable function field112* 0x02: s16 field of view113* 0x04: s16 near114* 0x06: s16 far115* 0x08: [GraphNodeFunc function]116*/117#define GEO_CAMERA_FRUSTUM(fov, near, far) \118CMD_BBH(0x0A, 0x00, fov), \119CMD_HH(near, far)120#define GEO_CAMERA_FRUSTUM_WITH_FUNC(fov, near, far, func) \121CMD_BBH(0x0A, 0x01, fov), \122CMD_HH(near, far), \123CMD_PTR(func)124125/**126* 0x0B: Create a root scene graph node127* 0x01-0x03: unused128*/129#define GEO_NODE_START() \130CMD_BBH(0x0B, 0x00, 0x0000)131132/**133* 0x0C: Create zbuffer-toggling scene graph node134* 0x01: u8 enableZBuffer (1 = on, 0 = off)135* 0x02-0x03: unused136*/137#define GEO_ZBUFFER(enable) \138CMD_BBH(0x0C, enable, 0x0000)139140/**141* 0x0D: Create render range scene graph node142* 0x01-0x03: unused143* 0x04: s16 minDistance144* 0x06: s16 maxDistance145*/146#define GEO_RENDER_RANGE(minDistance, maxDistance) \147CMD_BBH(0x0D, 0x00, 0x0000), \148CMD_HH(minDistance, maxDistance)149150/**151* 0x0E: Create switch-case scene graph node152* 0x01: unused153* 0x02: s16 numCases154* 0x04: GraphNodeFunc caseSelectorFunc155*/156#define GEO_SWITCH_CASE(count, function) \157CMD_BBH(0x0E, 0x00, count), \158CMD_PTR(function)159160/**161* 0x0F: Create a camera scene graph node.162* 0x01: unused163* 0x02: s16 camera type164* 0x04: s16 posX165* 0x06: s16 posY166* 0x08: s16 posZ167* 0x0A: s16 focusX168* 0x0C: s16 focusY169* 0x0E: s16 focusZ170* 0x10: GraphNodeFunc function171*/172#define GEO_CAMERA(type, x1, y1, z1, x2, y2, z2, function) \173CMD_BBH(0x0F, 0x00, type), \174CMD_HHHHHH(x1, y1, z1, x2, y2, z2), \175CMD_PTR(function)176177/**178* 0x10: Create translation & rotation scene graph node with optional display list179* Four different versions of 0x10180* cmd+0x01: u8 params181* 0b1000_0000: if set, enable displayList field and drawingLayer182* 0b0111_0000: fieldLayout (determines how rest of data is formatted183* 0b0000_1111: drawingLayer184*185* fieldLayout = 0: Translate & Rotate186* 0x04: s16 xTranslation187* 0x06: s16 yTranslation188* 0x08: s16 zTranslation189* 0x0A: s16 xRotation190* 0x0C: s16 yRotation191* 0x0E: s16 zRotation192* 0x10: [u32 displayList: if MSbit of params set, display list segmented address]193*/194#define GEO_TRANSLATE_ROTATE(layer, tx, ty, tz, rx, ry, rz) \195CMD_BBH(0x10, (0x00 | layer), 0x0000), \196CMD_HHHHHH(tx, ty, tz, rx, ry, rz)197#define GEO_TRANSLATE_ROTATE_WITH_DL(layer, tx, ty, tz, rx, ry, rz, displayList) \198CMD_BBH(0x10, (0x00 | layer | 0x80), 0x0000), \199CMD_HHHHHH(tx, ty, tz, rx, ry, rz), \200CMD_PTR(displayList)201202/**203* fieldLayout = 1: Translate204* 0x02: s16 xTranslation205* 0x04: s16 yTranslation206* 0x06: s16 zTranslation207* 0x08: [u32 displayList: if MSbit of params set, display list segmented address]208*/209#define GEO_TRANSLATE(layer, tx, ty, tz) \210CMD_BBH(0x10, (0x10 | layer), tx), \211CMD_HH(ty, tz)212#define GEO_TRANSLATE_WITH_DL(layer, tx, ty, tz, displayList) \213CMD_BBH(0x10, (0x10 | layer | 0x80), tx), \214CMD_HH(ty, tz), \215CMD_PTR(displayList)216217/**218* fieldLayout = 2: Rotate219* 0x02: s16 xRotation220* 0x04: s16 yRotation221* 0x06: s16 zRotation222* 0x08: [u32 displayList: if MSbit of params set, display list segmented address]223*/224#define GEO_ROTATE(layer, rx, ry, rz) \225CMD_BBH(0x10, (0x20 | layer), rx), \226CMD_HH(ry, rz)227#define GEO_ROTATE_WITH_DL(layer, rx, ry, rz, displayList) \228CMD_BBH(0x10, (0x20 | layer | 0x80), rx), \229CMD_HH(ry, rz), \230CMD_PTR(displayList)231232/**233* fieldLayout = 3: Rotate Y234* 0x02: s16 yRotation235* 0x04: [u32 displayList: if MSbit of params set, display list segmented address]236*/237#define GEO_ROTATE_Y(layer, ry) \238CMD_BBH(0x10, (0x30 | layer), ry)239#define GEO_ROTATE_Y_WITH_DL(layer, ry, displayList) \240CMD_BBH(0x10, (0x30 | layer | 0x80), ry), \241CMD_PTR(displayList)242243/**244* 0x11: Create translation scene graph node with optional display list245* 0x01: u8 params246* 0b1000_0000: if set, enable displayList field and drawingLayer247* 0b0000_1111: drawingLayer248* 0x02: s16 translationX249* 0x04: s16 translationY250* 0x06: s16 translationZ251* 0x08: [u32 displayList: if MSbit of params set, display list segmented address]252*/253#define GEO_TRANSLATE_NODE(layer, ux, uy, uz) \254CMD_BBH(0x11, layer, ux), \255CMD_HH(uy, uz)256#define GEO_TRANSLATE_NODE_WITH_DL(layer, ux, uy, uz, displayList) \257CMD_BBH(0x11, (layer | 0x80), ux), \258CMD_HH(uy, uz), \259CMD_PTR(displayList)260261/**262* 0x12: Create rotation scene graph node with optional display list263* 0x01: u8 params264* 0b1000_0000: if set, enable displayList field and drawingLayer265* 0b0000_1111: drawingLayer266* 0x02: s16 rotationX267* 0x04: s16 rotationY268* 0x06: s16 rotationZ269* 0x08: [u32 displayList: if MSbit of params set, display list segmented address]270*/271#define GEO_ROTATION_NODE(layer, ux, uy, uz) \272CMD_BBH(0x12, layer, ux), \273CMD_HH(uy, uz)274#define GEO_ROTATION_NODE_WITH_DL(layer, ux, uy, uz, displayList) \275CMD_BBH(0x12, (layer | 0x80), ux), \276CMD_HH(uy, uz), \277CMD_PTR(displayList)278279/**280* 0x13: Create a scene graph node that is rotated by the object's animation.281* 0x01: u8 drawingLayer282* 0x02: s16 xTranslation283* 0x04: s16 yTranslation284* 0x06: s16 zTranslation285* 0x08: u32 displayList: dislay list segmented address286*/287#define GEO_ANIMATED_PART(layer, x, y, z, displayList) \288CMD_BBH(0x13, layer, x), \289CMD_HH(y, z), \290CMD_PTR(displayList)291292/**293* 0x14: Create billboarding node with optional display list294* 0x01: u8 params295* 0b1000_0000: if set, enable displayList field and drawingLayer296* 0b0000_1111: drawingLayer297* 0x02: s16 xTranslation298* 0x04: s16 yTranslation299* 0x06: s16 zTranslation300* 0x08: [u32 displayList: if MSbit of params is set, display list segmented address]301*/302#define GEO_BILLBOARD_WITH_PARAMS(layer, tx, ty, tz) \303CMD_BBH(0x14, layer, tx), \304CMD_HH(ty, tz)305#define GEO_BILLBOARD_WITH_PARAMS_AND_DL(layer, tx, ty, tz, displayList) \306CMD_BBH(0x14, (layer | 0x80), tx), \307CMD_HH(ty, tz), \308CMD_PTR(displayList)309#define GEO_BILLBOARD() \310GEO_BILLBOARD_WITH_PARAMS(0, 0, 0, 0)311312/**313* 0x15: Create plain display list scene graph node314* 0x01: u8 drawingLayer315* 0x02-0x03: unused316* 0x04: u32 displayList: display list segmented address317*/318#define GEO_DISPLAY_LIST(layer, displayList) \319CMD_BBH(0x15, layer, 0x0000), \320CMD_PTR(displayList)321322/**323* 0x16: Create shadow scene graph node324* 0x01: unused325* 0x02: s16 shadowType (cast to u8)326* 0x04: s16 shadowSolidity (cast to u8)327* 0x06: s16 shadowScale328*/329#define GEO_SHADOW(type, solidity, scale) \330CMD_BBH(0x16, 0x00, type), \331CMD_HH(solidity, scale)332333/**334* 0x17: Create render object scene graph node335* 0x01-0x03: unused336*/337#define GEO_RENDER_OBJ() \338CMD_BBH(0x17, 0x00, 0x0000)339340/**341* 0x18: Create dynamically generated displaylist scene graph node342* 0x01: unused343* 0x02: s16 parameter344* 0x04: GraphNodeFunc function345*/346#define GEO_ASM(param, function) \347CMD_BBH(0x18, 0x00, param), \348CMD_PTR(function)349350/**351* 0x19: Create background scene graph node352* 0x02: s16 background: background ID, or RGBA5551 color if backgroundFunc is null353* 0x04: GraphNodeFunc backgroundFunc354*/355#define GEO_BACKGROUND(background, function) \356CMD_BBH(0x19, 0x00, background), \357CMD_PTR(function)358#define GEO_BACKGROUND_COLOR(background) \359GEO_BACKGROUND(background, NULL)360361/**362* 0x1A: No operation363*/364#define GEO_NOP_1A() \365CMD_BBH(0x1A, 0x00, 0x0000), \366CMD_HH(0x0000, 0x0000)367368/**369* 0x1B: Copy the shared children from an object parent node from a specific view370* to a newly created object parent.371* 0x02: s16 index of array372*/373#define GEO_COPY_VIEW(index) \374CMD_BBH(0x1B, 0x00, index)375376/**377* 0x1C: Create a held object scene graph node378* cmd+0x01: u8 unused379* cmd+0x02: s16 offsetX380* cmd+0x04: s16 offsetY381* cmd+0x06: s16 offsetZ382* cmd+0x08: GraphNodeFunc nodeFunc383*/384#define GEO_HELD_OBJECT(param, ux, uy, uz, nodeFunc) \385CMD_BBH(0x1C, param, ux), \386CMD_HH(uy, uz), \387CMD_PTR(nodeFunc)388389/**390* 0x1D: Create scale scene graph node with optional display list391* 0x01: u8 params392* 0b1000_0000: if set, enable displayList field and drawingLayer393* 0b0000_1111: drawingLayer394* 0x02-0x03: unused395* 0x04: u32 scale (0x10000 = 1.0)396* 0x08: [u32 displayList: if MSbit of params is set, display list segment address]397*/398#define GEO_SCALE(layer, scale) \399CMD_BBH(0x1D, layer, 0x0000), \400CMD_W(scale)401#define GEO_SCALE_WITH_DL(layer, scale, displayList) \402CMD_BBH(0x1D, (layer | 0x80), 0x0000), \403CMD_W(scale), \404CMD_PTR(displayList)405406/**407* 0x1E: No operation408*/409#define GEO_NOP_1E() \410CMD_BBH(0x1E, 0x00, 0x0000), \411CMD_HH(0x0000, 0x0000)412413/**414* 0x1F: No operation415*/416#define GEO_NOP_1F() \417CMD_BBH(0x1F, 0x00, 0x0000), \418CMD_HH(0x0000, 0x0000), \419CMD_HH(0x0000, 0x0000), \420CMD_HH(0x0000, 0x0000)421422/**423* 0x20: Create a scene graph node that specifies for an object the radius that424* is used for frustum culling.425* 0x01: unused426* 0x02: s16 cullingRadius427*/428#define GEO_CULLING_RADIUS(cullingRadius) \429CMD_BBH(0x20, 0x00, cullingRadius)430431#endif // GEO_COMMANDS_H432433434