diff --git a/include/level_commands.h b/include/level_commands.h index df1b797f..1772a62b 100644 --- a/include/level_commands.h +++ b/include/level_commands.h @@ -210,8 +210,9 @@ CMD_BBH(0x20, 0x04, 0x0000) #define LOAD_MODEL_FROM_DL(model, dl, layer) \ - CMD_BBH(0x21, 0x08, ((layer << 12) | model)), \ - CMD_PTR(dl) + CMD_BBH(0x21, 0x0C, 0), \ + CMD_PTR(dl), \ + CMD_HH(layer, model) #define LOAD_MODEL_FROM_GEO(model, geo) \ CMD_BBH(0x22, 0x08, model), \ @@ -224,18 +225,20 @@ CMD_W(unk8) #define OBJECT_WITH_ACTS(model, posX, posY, posZ, angleX, angleY, angleZ, behParam, beh, acts) \ - CMD_BBBB(0x24, 0x18, acts, model), \ + CMD_BBBB(0x24, 0x1C, acts, 0x00), \ CMD_HHHHHH(posX, posY, posZ, angleX, angleY, angleZ), \ CMD_W(behParam), \ - CMD_PTR(beh) + CMD_PTR(beh), \ + CMD_HH(0, model) #define OBJECT(model, posX, posY, posZ, angleX, angleY, angleZ, behParam, beh) \ OBJECT_WITH_ACTS(model, posX, posY, posZ, angleX, angleY, angleZ, behParam, beh, 0x1F) -#define MARIO(unk3, behArg, beh) \ - CMD_BBBB(0x25, 0x0C, 0x00, unk3), \ +#define MARIO(model, behArg, beh) \ + CMD_BBH(0x25, 0x10, 0), \ CMD_W(behArg), \ - CMD_PTR(beh) + CMD_PTR(beh), \ + CMD_HH(0, model) #define WARP_NODE(id, destLevel, destArea, destNode, flags) \ CMD_BBBB(0x26, 0x08, id, destLevel), \ diff --git a/include/special_presets.h b/include/special_presets.h index e16ac6a8..a9be6ec2 100644 --- a/include/special_presets.h +++ b/include/special_presets.h @@ -17,7 +17,7 @@ struct SpecialPreset /*00*/ u8 preset_id; /*01*/ u8 type; // Determines whether object is 8, 10, 12 or 14 bytes long. /*02*/ u8 defParam; // Default parameter, only used when type is SPTYPE_DEF_PARAM_AND_YROT - /*03*/ u8 model; + /*03*/ ModelID model; /*04*/ const BehaviorScript *behavior; }; diff --git a/include/types.h b/include/types.h index 1b7152f6..475655cf 100644 --- a/include/types.h +++ b/include/types.h @@ -54,6 +54,7 @@ typedef s16 Trajectory; typedef s16 PaintingData; typedef uintptr_t BehaviorScript; typedef u8 Texture; +typedef u16 ModelID; enum SpTaskState { SPTASK_STATE_NOT_STARTED, diff --git a/src/engine/level_script.c b/src/engine/level_script.c index 6687ac0d..daeff54c 100644 --- a/src/engine/level_script.c +++ b/src/engine/level_script.c @@ -375,23 +375,23 @@ static void level_cmd_end_area(void) { } static void level_cmd_load_model_from_dl(void) { - s16 val1 = CMD_GET(s16, 2) & 0x0FFF; - s16 val2 = ((u16)CMD_GET(s16, 2)) >> 12; - void *val3 = CMD_GET(void *, 4); + ModelID model = CMD_GET(ModelID, 0xA); + s16 layer = CMD_GET(u16, 0x8); + void *dl_ptr = CMD_GET(void *, 4); - if (val1 < 256) { - gLoadedGraphNodes[val1] = - (struct GraphNode *) init_graph_node_display_list(sLevelPool, 0, val2, val3); + if (model < 65536) { + gLoadedGraphNodes[model] = + (struct GraphNode *) init_graph_node_display_list(sLevelPool, 0, layer, dl_ptr); } sCurrentCmd = CMD_NEXT; } static void level_cmd_load_model_from_geo(void) { - s16 arg0 = CMD_GET(s16, 2); + ModelID arg0 = CMD_GET(ModelID, 2); void *arg1 = CMD_GET(void *, 4); - if (arg0 < 256) { + if (arg0 < 65536) { gLoadedGraphNodes[arg0] = process_geo_layout(sLevelPool, arg1); } @@ -404,13 +404,13 @@ static void level_cmd_23(void) { f32 f; } arg2; - s16 model = CMD_GET(s16, 2) & 0x0FFF; + ModelID model = CMD_GET(s16, 2) & 0x0FFF; s16 arg0H = ((u16)CMD_GET(s16, 2)) >> 12; void *arg1 = CMD_GET(void *, 4); // load an f32, but using an integer load instruction for some reason (hence the union) arg2.i = CMD_GET(s32, 8); - if (model < 256) { + if (model < 65536) { // GraphNodeScale has a GraphNode at the top. This // is being stored to the array, so cast the pointer. gLoadedGraphNodes[model] = @@ -428,7 +428,7 @@ static void level_cmd_init_mario(void) { gMarioSpawnInfo->areaIndex = 0; gMarioSpawnInfo->behaviorArg = CMD_GET(u32, 4); gMarioSpawnInfo->behaviorScript = CMD_GET(void *, 8); - gMarioSpawnInfo->unk18 = gLoadedGraphNodes[CMD_GET(u8, 3)]; + gMarioSpawnInfo->unk18 = gLoadedGraphNodes[CMD_GET(ModelID, 0xE)]; gMarioSpawnInfo->next = NULL; sCurrentCmd = CMD_NEXT; @@ -440,7 +440,7 @@ static void level_cmd_place_object(void) { struct SpawnInfo *spawnInfo; if (sCurrAreaIndex != -1 && ((CMD_GET(u8, 2) & val7) || CMD_GET(u8, 2) == 0x1F)) { - model = CMD_GET(u8, 3); + model = CMD_GET(ModelID, 0x1A); spawnInfo = alloc_only_pool_alloc(sLevelPool, sizeof(struct SpawnInfo)); spawnInfo->startPos[0] = CMD_GET(s16, 4); diff --git a/src/game/area.c b/src/game/area.c index af9d0156..dafadf13 100644 --- a/src/game/area.c +++ b/src/game/area.c @@ -23,7 +23,7 @@ #include "level_table.h" struct SpawnInfo gPlayerSpawnInfos[1]; -struct GraphNode *D_8033A160[0x100]; +struct GraphNode *D_8033A160[0x10000]; struct Area gAreaData[8]; struct WarpTransition gWarpTransition; diff --git a/src/game/behavior_actions.c b/src/game/behavior_actions.c index 03dbaa1d..940698a7 100644 --- a/src/game/behavior_actions.c +++ b/src/game/behavior_actions.c @@ -57,7 +57,7 @@ struct Struct8032F34C { s16 numBridgeSections; s16 bridgeRelativeStartingXorZ; s16 platformWidth; - s16 model; + ModelID model; const void *segAddr; }; @@ -73,7 +73,7 @@ struct Struct802C0DF0 { u8 unk0; u8 unk1; u8 unk2; - u8 model; + ModelID model; const BehaviorScript *behavior; }; @@ -85,7 +85,7 @@ struct Struct8032F754 { struct OpenableGrill { s16 halfWidth; - s16 modelID; + ModelID modelID; const Collision *collision; }; diff --git a/src/game/macro_special_objects.c b/src/game/macro_special_objects.c index a0ef16ae..7f03f97a 100644 --- a/src/game/macro_special_objects.c +++ b/src/game/macro_special_objects.c @@ -95,7 +95,7 @@ static void spawn_macro_coin_unknown(const BehaviorScript *behavior, s16 a1[]) { struct LoadedPreset { /*0x00*/ const BehaviorScript *behavior; /*0x04*/ s16 param; // huh? why does the below function swap these.. just use the struct.. - /*0x06*/ s16 model; + /*0x06*/ ModelID model; }; #define MACRO_OBJ_Y_ROT 0 @@ -245,7 +245,7 @@ void spawn_special_objects(s16 areaIndex, s16 **specialObjList) { s16 y; s16 z; s16 extraParams[4]; - u8 model; + ModelID model; u8 type; u8 presetID; u8 defaultParam; diff --git a/src/game/object_helpers.h b/src/game/object_helpers.h index 895604fc..fb2d5ae2 100644 --- a/src/game/object_helpers.h +++ b/src/game/object_helpers.h @@ -55,7 +55,7 @@ struct SpawnParticlesInfo { /*0x00*/ s8 behParam; /*0x01*/ s8 count; - /*0x02*/ u8 model; + /*0x02*/ ModelID model; /*0x03*/ s8 offsetY; /*0x04*/ s8 forwardVelBase; /*0x05*/ s8 forwardVelRange; diff --git a/src/game/object_list_processor.c b/src/game/object_list_processor.c index 8e6cf9d0..834cb59b 100644 --- a/src/game/object_list_processor.c +++ b/src/game/object_list_processor.c @@ -188,7 +188,7 @@ s8 sObjectListUpdateOrder[] = { OBJ_LIST_SPAWNER, struct ParticleProperties { u32 particleFlag; u32 activeParticleFlag; - u8 model; + ModelID model; const BehaviorScript *behavior; };