This commit is contained in:
Reonu
2021-05-27 07:47:12 +01:00
10 changed files with 33 additions and 28 deletions

View File

@@ -18,6 +18,7 @@ Fork of the ultrasm64 repo by CrashOveride which includes the following commonly
- bparam4 fix (the game no longer uses bparam4 to check if an object is mario and therefore you can safely use it)
- Global star IDs (disabled by default, toggleable in config.h). This allows you to create an open world (MVC-style) hack.
- Included `actors/group0.c` in `behavior_data.c`
- 16 bit model IDs by someone2639. This means you can have up to 65536 models (lol)
- coordinate overflow fix by falcobuster
- If you're planning on making maps bigger than 2x bounds, change the value of `WORLD_SCALE` in `config.h` to a bigger value. `3.5f` should be enough for 4x boundaries but you can go up to `4.0f` if you somehow still get rendering glitches on your map.

View File

@@ -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), \

View File

@@ -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;
};

View File

@@ -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,

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;
};

View File

@@ -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;

View File

@@ -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;

View File

@@ -188,7 +188,7 @@ s8 sObjectListUpdateOrder[] = { OBJ_LIST_SPAWNER,
struct ParticleProperties {
u32 particleFlag;
u32 activeParticleFlag;
u8 model;
ModelID model;
const BehaviorScript *behavior;
};