Skip to content

Commit

Permalink
star rod dx upstreaming (#1177)
Browse files Browse the repository at this point in the history
* so far

* leftover

* first batch

* part zwei

* item name changes

* misspelling

* comments

* THE

* fix pal

* muurgle

---------

Co-authored-by: HailSanta <[email protected]>
  • Loading branch information
z64a and HailSanta authored Mar 6, 2024
1 parent 8d5b066 commit e342a33
Show file tree
Hide file tree
Showing 231 changed files with 1,012 additions and 973 deletions.
20 changes: 3 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,10 @@ build/
*.sbn

# Star Rod
/sprite/SpriteTable.xml
/mod.cfg
/tools/star-rod
/editor
/logs
/out
dump
.starrod
/ver/us/dump
*.backup
crash.xml
/audio/*
/sprite/*
/battle/*
/globals/*
/map/*
/world/*
/image/*
/strings/*
/res/*
*.crash

/tools/Yay0compress
/tools/n64crc
10 changes: 2 additions & 8 deletions include/common_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ typedef struct Trigger {
/* 0x04 */ s32 varIndex;
/* 0x08 */ union {
/* */ s32 colliderID;
/* */ Vec4f* pos;
/* */ struct BombTrigger* blast;
/* */ } location;
/* 0x0C */ s32 (*onActivateFunc)(struct Trigger*);
/* 0x10 */ EvtScript* onTriggerEvt;
Expand Down Expand Up @@ -1758,15 +1758,9 @@ typedef struct LavaReset {

typedef struct BombTrigger {
/* 0x00 */ Vec3f pos;
/* 0x0C */ s32 radius; // effective 'size' of the object, usually set to zero because bombettes explosion radius is large enough
/* 0x0C */ f32 diameter; // effective 'size' of the object, usually set to zero because bombettes explosion radius is large enough
} BombTrigger; // size = 0x10;

// the use of this is a bug in sam_11
typedef struct BombTriggerF {
/* 0x00 */ Vec3f pos;
/* 0x0C */ f32 radius;
} BombTriggerF; // size = 0x10;

typedef struct AnimatedModel {
/* 0x00 */ s32 animModelID;
/* 0x04 */ Vec3f pos;
Expand Down
20 changes: 9 additions & 11 deletions include/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
typedef s32 EntityScript[];
typedef s32 EntityModelScript[];

extern s32 CreateEntityVarArgBuffer[4];
extern s32 CreateEntityVarArgBuffer[];

enum {
ENTITY_SCRIPT_OP_End,
Expand Down Expand Up @@ -360,9 +360,7 @@ typedef struct SpinningFlowerData {
/* 0x14 */ f32 spinSpeed;
/* 0x18 */ s32 unk_18;
/* 0x1C */ char unk_1C[0x0C];
/* 0x28 */ s16 unk_28;
/* 0x2A */ s16 unk_2A;
/* 0x2C */ s16 unk_2C;
/* 0x28 */ Vec3s pos;
/* 0x30 */ Mtx unk_30;
} SpinningFlowerData; // size = 0x70

Expand Down Expand Up @@ -399,16 +397,16 @@ extern EntityBlueprint Entity_InertRedBlock;
extern EntityBlueprint Entity_BrickBlock;
extern EntityBlueprint Entity_MulticoinBlock;
extern EntityBlueprint Entity_Hammer1Block;
extern EntityBlueprint Entity_Hammer1Block_WideX;
extern EntityBlueprint Entity_Hammer1Block_WideZ;
extern EntityBlueprint Entity_Hammer1BlockWideX;
extern EntityBlueprint Entity_Hammer1BlockWideZ;
extern EntityBlueprint Entity_Hammer1BlockTiny;
extern EntityBlueprint Entity_Hammer2Block;
extern EntityBlueprint Entity_Hammer2Block_WideX;
extern EntityBlueprint Entity_Hammer2Block_WideZ;
extern EntityBlueprint Entity_Hammer2BlockWideX;
extern EntityBlueprint Entity_Hammer2BlockWideZ;
extern EntityBlueprint Entity_Hammer2BlockTiny;
extern EntityBlueprint Entity_Hammer3Block;
extern EntityBlueprint Entity_Hammer3Block_WideX;
extern EntityBlueprint Entity_Hammer3Block_WideZ;
extern EntityBlueprint Entity_Hammer3BlockWideX;
extern EntityBlueprint Entity_Hammer3BlockWideZ;
extern EntityBlueprint Entity_Hammer3BlockTiny;
extern EntityBlueprint Entity_PushBlock;
extern EntityBlueprint Entity_PowBlock;
Expand All @@ -433,7 +431,7 @@ extern EntityBlueprint Entity_PadlockRedFace;
extern EntityBlueprint Entity_PadlockBlueFace;
extern EntityBlueprint Entity_BoardedFloor;
extern EntityBlueprint Entity_BombableRock;
extern EntityBlueprint Entity_BombableRock2;
extern EntityBlueprint Entity_BombableRockWide;
extern EntityBlueprint Entity_Tweester;
extern EntityBlueprint Entity_StarBoxLauncher;
extern EntityBlueprint Entity_CymbalPlant;
Expand Down
26 changes: 22 additions & 4 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ s32 phys_can_player_interact(void);

void ai_enemy_play_sound(Npc* npc, s32 arg1, s32 arg2);

s32 player_test_move_without_slipping(PlayerStatus*, f32*, f32*, f32*, f32, f32, s32*);
s32 player_test_move_with_slipping(PlayerStatus* playerStatus, f32* posX, f32* posY, f32* posZ, f32 speed, f32 heading);
HitID player_test_move_without_slipping(PlayerStatus*, f32*, f32*, f32*, f32, f32, s32*);
HitID player_test_move_with_slipping(PlayerStatus* playerStatus, f32* posX, f32* posY, f32* posZ, f32 speed, f32 heading);

s32 evt_get_variable(Evt* script, Bytecode var);
s32 evt_set_variable(Evt* script, Bytecode var, s32 value);
Expand All @@ -274,6 +274,24 @@ s32 test_ray_zones(f32 startX, f32 startY, f32 startZ, f32 dirX, f32 dirY, f32 d
f32* hitDepth, f32* nx, f32* ny, f32* nz);
s32 test_ray_colliders(s32 ignoreFlags, f32 startX, f32 startY, f32 startZ, f32 dirX, f32 dirY, f32 dirZ, f32* hitX,
f32* hitY, f32* hitZ, f32* hitDepth, f32* hitNx, f32* hitNy, f32* hitNz);

/// Test a general ray from a given starting position and direction against all entities.
/// If one is hit, returns the position and normal of the hit and the length along the ray on the output params.
/// All output params are invalid when a value of `NO_COLLIDER` is returned.
/// @param startX origin x position of the ray
/// @param startY origin y position of the ray
/// @param startZ origin z position of the ray
/// @param dirX normalized x direction of the ray
/// @param dirY normalized y direction of the ray
/// @param dirZ normalized z direction of the ray
/// @param[out] hitX normalized x position of the hit
/// @param[out] hitY normalized y position of the hit
/// @param[out] hitZ normalized z position of the hit
/// @param[in,out] hitDepth as input, maximum length of the ray; as output, distance along the ray of the hit
/// @param[out] hitNx x normal direction of the hit
/// @param[out] hitNy y normal direction of the hit
/// @param[out] hitNz z normal direction of the hit
/// @returns entity index or `NO_COLLIDER` is none is hit
s32 test_ray_entities(f32 startX, f32 startY, f32 startZ, f32 dirX, f32 dirY, f32 dirZ, f32* hitX, f32* hitY, f32* hitZ,
f32* hitDepth, f32* hitNx, f32* hitNy, f32* hitNz);

Expand Down Expand Up @@ -402,9 +420,9 @@ PlayerData* get_player_data(void);
b32 npc_raycast_down_around(s32, f32*, f32*, f32*, f32*, f32, f32);
b32 npc_raycast_down_sides(s32 ignoreFlags, f32* posX, f32* posY, f32* posZ, f32* hitDepth);
s32 npc_raycast_up(s32, f32*, f32*, f32*, f32*);
s32 npc_raycast_up_corners(s32 ignoreFlags, f32* posX, f32* posY, f32* posZ, f32* hitDepth, f32 yaw, f32 radius);
HitID npc_raycast_up_corners(s32 ignoreFlags, f32* posX, f32* posY, f32* posZ, f32* hitDepth, f32 yaw, f32 radius);
s32 player_raycast_up_corners(PlayerStatus*, f32*, f32*, f32*, f32*, f32);
s32 player_raycast_below_cam_relative(PlayerStatus* playerStatus, f32* outX, f32* outY, f32* outZ, f32* outLength,
HitID player_raycast_below_cam_relative(PlayerStatus* playerStatus, f32* outX, f32* outY, f32* outZ, f32* outLength,
f32* hitRx, f32* hitRz, f32* hitDirX, f32* hitDirZ);
b32 npc_test_move_taller_with_slipping(s32, f32*, f32*, f32*, f32, f32, f32, f32);
b32 npc_test_move_simple_with_slipping(s32, f32*, f32*, f32*, f32, f32, f32, f32);
Expand Down
3 changes: 1 addition & 2 deletions include/npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ typedef struct NpcSettings {
typedef struct ItemDrop {
/* 0x00 */ s16 item;
/* 0x02 */ s16 weight;
/* 0x04 */ s16 unk_04;
/* 0x04 */ s16 flagIdx;
} ItemDrop; // size = 0x06

/// @brief Describes heart/flower drop chances after defeating an Npc in the overworld.
Expand Down Expand Up @@ -239,7 +239,6 @@ typedef struct {
typedef union {
EnemyTerritoryWander wander;
EnemyTerritoryPatrol patrol;
s32 temp[48]; // TODO: remove when old map data is replaced
char PADDING[0xC0];
} EnemyTerritory; // size = 0xC0

Expand Down
2 changes: 1 addition & 1 deletion include/saved_flag_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ enum GameFlags {
GF_TIK03_ItemBlock_SnowmanDoll = GameFlag(0x190),
GF_TIK03_ItemBlock_CoinA = GameFlag(0x191),
GF_TIK03_ItemBlock_CoinB = GameFlag(0x192),
GF_TIK05_Chest_PowerSmash1 = GameFlag(0x193),
GF_TIK05_Chest_PowerSmash = GameFlag(0x193),
GF_TIK07_Item_StarPiece = GameFlag(0x194),
GF_TIK10_HiddenItem_CoinA = GameFlag(0x195),
GF_TIK10_HiddenItem_CoinB = GameFlag(0x196),
Expand Down
6 changes: 3 additions & 3 deletions include/script_api/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
#define EVT_LIMIT -270000000 // TODO better name

// This fixes an issue with fixed point numbers not being correct. Potentially a truncation vs round difference.
#define Float_ROUND(x) ((x) >=0 ? (f64)((x) + 0.9) : (f64)(x))
#define Float(DOUBLE) ((Bytecode)Float_ROUND(((DOUBLE) * 1024.0f)) - EVT_FIXED_OFFSET)
#define FLOAT_ROUND(x) ((x) >=0 ? (f64)((x) + 0.9) : (f64)(x))
#define Float(DOUBLE) ((Bytecode)FLOAT_ROUND(((DOUBLE) * 1024.0f)) - EVT_FIXED_OFFSET)

/// Progammatically converts Float --> f32
#define EVT_FIXED_TO_FLOAT(x) ({f32 var = (x) + EVT_FIXED_OFFSET; var /= 1024.0f; var;})

/// Progammatically converts f32 --> Float
#define Float_TO_FIXED(x) (((x) * 1024.0f) + -EVT_FIXED_OFFSET)
#define FLOAT_TO_FIXED(x) (((x) * 1024.0f) + -EVT_FIXED_OFFSET)

/// Address/pointer constant.
#define Ref(sym) ((Bytecode) &(sym))
Expand Down
4 changes: 2 additions & 2 deletions include/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ extern char wMapTexName[];
extern char wMapHitName[];
extern char wMapShapeName[];
extern char wMapBgName[];
extern u8 D_802D9D70; // player alpha1 copy?
extern u8 D_802D9D71; // player alpha2 copy?
extern u8 ReflectWallPrevAlpha; // player alpha1 copy?
extern u8 ReflectFloorPrevAlpha; // player alpha2 copy?

extern DisplayContext D_80164000[2];

Expand Down
Loading

0 comments on commit e342a33

Please sign in to comment.