Refresh 8

This commit is contained in:
n64
2020-04-03 14:57:26 -04:00
parent 06ec56df7f
commit c45aa301bb
279 changed files with 6522 additions and 7273 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -12,6 +12,10 @@
#define SOUND_MODE_MONO 3
#define SOUND_MODE_HEADSET 1
#define SEQ_PLAYER_LEVEL 0
#define SEQ_PLAYER_ENV 1
#define SEQ_PLAYER_SFX 2
extern s32 gAudioErrorFlags;
extern f32 gDefaultSoundArgs[3];

View File

@@ -527,6 +527,12 @@ struct Note
/* , 0xB0*/ struct NoteSubEu noteSubEu;
}; // size = 0xC0
#else
struct vNote
{
/* U/J, EU */
/*0x00*/ volatile u8 enabled : 1;
long long int force_structure_alignment;
}; // size = 0xC0
struct Note
{
/* U/J, EU */

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
#include "buffers.h"
ALIGNED8 u8 gDecompressionHeap[0xD000];
#ifdef VERSION_EU
#if defined(VERSION_EU) || defined(VERSION_SH)
ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(0x31200) - 0x3800];
#else
ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(0x31200)];
@@ -13,6 +13,9 @@ ALIGNED8 u8 gIdleThreadStack[0x800];
ALIGNED8 u8 gThread3Stack[0x2000];
ALIGNED8 u8 gThread4Stack[0x2000];
ALIGNED8 u8 gThread5Stack[0x2000];
#ifdef VERSION_SH
ALIGNED8 u8 gThread6Stack[0x2000];
#endif
// 0x400 bytes
ALIGNED8 u8 gGfxSPTaskStack[SP_DRAM_STACK_SIZE8];
// 0xc00 bytes for f3dex, 0x900 otherwise

View File

@@ -3,7 +3,7 @@
#include "types.h"
#include "game/save_file.h"
#include "game/display.h"
#include "game/game_init.h"
extern u8 gDecompressionHeap[];
@@ -17,6 +17,9 @@ extern u8 gIdleThreadStack[];
extern u8 gThread3Stack[];
extern u8 gThread4Stack[];
extern u8 gThread5Stack[];
#ifdef VERSION_SH
extern u8 gThread6Stack[];
#endif
extern u8 gGfxSPTaskYieldBuffer[];

File diff suppressed because it is too large Load Diff

View File

@@ -1,30 +1,29 @@
#ifndef _BEHAVIOR_SCRIPT_H_
#define _BEHAVIOR_SCRIPT_H_
#define BEH_BREAK 1
#define BEH_CONTINUE 0
#define BHV_PROC_CONTINUE 0
#define BHV_PROC_BREAK 1
#define cur_object_get_int(offset) gCurrentObject->OBJECT_FIELD_S32(offset)
#define cur_object_get_float(offset) gCurrentObject->OBJECT_FIELD_F32(offset)
#define cur_obj_get_int(offset) gCurrentObject->OBJECT_FIELD_S32(offset)
#define cur_obj_get_float(offset) gCurrentObject->OBJECT_FIELD_F32(offset)
#define cur_object_add_float(offset, value) gCurrentObject->OBJECT_FIELD_F32(offset) += (f32)(value)
#define cur_object_set_float(offset, value) gCurrentObject->OBJECT_FIELD_F32(offset) = (f32)(value)
#define cur_object_add_int(offset, value) gCurrentObject->OBJECT_FIELD_S32(offset) += (s32)(value)
#define cur_object_set_int(offset, value) gCurrentObject->OBJECT_FIELD_S32(offset) = (s32)(value)
#define cur_object_or_int(offset, value) gCurrentObject->OBJECT_FIELD_S32(offset) |= (s32)(value)
#define cur_object_and_int(offset, value) gCurrentObject->OBJECT_FIELD_S32(offset) &= (s32)(value)
#define cur_object_set_vptr(offset, value) gCurrentObject->OBJECT_FIELD_VPTR(offset) = (void *)(value)
#define cur_obj_add_float(offset, value) gCurrentObject->OBJECT_FIELD_F32(offset) += (f32)(value)
#define cur_obj_set_float(offset, value) gCurrentObject->OBJECT_FIELD_F32(offset) = (f32)(value)
#define cur_obj_add_int(offset, value) gCurrentObject->OBJECT_FIELD_S32(offset) += (s32)(value)
#define cur_obj_set_int(offset, value) gCurrentObject->OBJECT_FIELD_S32(offset) = (s32)(value)
#define cur_obj_or_int(offset, value) gCurrentObject->OBJECT_FIELD_S32(offset) |= (s32)(value)
#define cur_obj_and_int(offset, value) gCurrentObject->OBJECT_FIELD_S32(offset) &= (s32)(value)
#define cur_obj_set_vptr(offset, value) gCurrentObject->OBJECT_FIELD_VPTR(offset) = (void *)(value)
#define object_and_int(object, offset, value) object->OBJECT_FIELD_S32(offset) &= (s32)(value)
#define obj_and_int(object, offset, value) object->OBJECT_FIELD_S32(offset) &= (s32)(value)
u16 RandomU16(void);
float RandomFloat(void);
s32 RandomSign(void);
u16 random_u16(void);
float random_float(void);
s32 random_sign(void);
void func_80383D68(struct Object *object);
void obj_update_gfx_pos_and_angle(struct Object *);
void stub_behavior_script_2(void);
void stub_80385BF0(void);
void cur_object_exec_behavior(void);
void cur_obj_update(void);
#endif /* _BEHAVIOR_SCRIPT_H_ */

View File

@@ -5,7 +5,7 @@
#include "buffers/framebuffers.h"
#include "buffers/zbuffer.h"
#include "game/area.h"
#include "game/display.h"
#include "game/game_init.h"
#include "game/mario.h"
#include "game/memory.h"
#include "game/object_helpers.h"

View File

@@ -20,12 +20,9 @@
*/
static s32 find_wall_collisions_from_list(struct SurfaceNode *surfaceNode,
struct WallCollisionData *data) {
#ifdef VERSION_EU
UNUSED u8 pad;
#endif
register struct Surface *surf;
register f32 offset;
register f32 radius = data->radius;
register struct Surface *surf;
register f32 x = data->x;
register f32 y = data->y + data->offsetY;
register f32 z = data->z;

View File

@@ -103,6 +103,10 @@ static void clear_static_surfaces(void) {
/**
* Add a surface to the correct cell list of surfaces.
* @param dynamic Determines whether the surface is static or dynamic
* @param cellX The X position of the cell in which the surface resides
* @param cellZ The Z position of the cell in which the surface resides
* @param surface The surface to add
*/
static void add_surface_to_cell(s16 dynamic, s16 cellX, s16 cellZ, struct Surface *surface) {
struct SurfaceNode *newNode = alloc_surface_node();
@@ -191,23 +195,24 @@ static s16 max_3(s16 a0, s16 a1, s16 a2) {
/**
* Every level is split into 16 * 16 cells of surfaces (to limit computing
* time). This function determines the lower cell for a given x/z position.
* @param coord The coordinate to test
*/
static s16 lower_cell_index(s16 t) {
static s16 lower_cell_index(s16 coord) {
s16 index;
// Move from range [-0x2000, 0x2000) to [0, 0x4000)
t += 0x2000;
if (t < 0) {
t = 0;
coord += 0x2000;
if (coord < 0) {
coord = 0;
}
// [0, 16)
index = t / 0x400;
index = coord / 0x400;
// Include extra cell if close to boundary
//! Some wall checks are larger than the buffer, meaning wall checks can
// miss walls that are near a cell border.
if (t % 0x400 < 50) {
if (coord % 0x400 < 50) {
index -= 1;
}
@@ -222,23 +227,24 @@ static s16 lower_cell_index(s16 t) {
/**
* Every level is split into 16 * 16 cells of surfaces (to limit computing
* time). This function determines the upper cell for a given x/z position.
* @param coord The coordinate to test
*/
static s16 upper_cell_index(s16 t) {
static s16 upper_cell_index(s16 coord) {
s16 index;
// Move from range [-0x2000, 0x2000) to [0, 0x4000)
t += 0x2000;
if (t < 0) {
t = 0;
coord += 0x2000;
if (coord < 0) {
coord = 0;
}
// [0, 16)
index = t / 0x400;
index = coord / 0x400;
// Include extra cell if close to boundary
//! Some wall checks are larger than the buffer, meaning wall checks can
// miss walls that are near a cell border.
if (t % 0x400 > 0x400 - 50) {
if (coord % 0x400 > 0x400 - 50) {
index += 1;
}
@@ -254,6 +260,8 @@ static s16 upper_cell_index(s16 t) {
* Every level is split into 16x16 cells, this takes a surface, finds
* the appropriate cells (with a buffer), and adds the surface to those
* cells.
* @param surface The surface to check
* @param dynamic Boolean determining whether the surface is static or dynamic
*/
static void add_surface(struct Surface *surface, s32 dynamic) {
// minY/maxY maybe? s32 instead of s16, though.
@@ -283,12 +291,13 @@ static void add_surface(struct Surface *surface, s32 dynamic) {
}
}
static void unused_80382B6C(void) {
static void stub_surface_load_1(void) {
}
/**
* Initialize a surface from reading it's data and putting it into a surface
* stuct.
* Initializes a Surface struct using the given vertex data
* @param vertexData The raw data containing vertex positions
* @param vertexIndices Helper which tells positions in vertexData to start reading vertices
*/
static struct Surface *read_surface_data(s16 *vertexData, s16 **vertexIndices) {
struct Surface *surface;
@@ -602,14 +611,8 @@ static void unused_80383604(void) {
*/
void transform_object_vertices(s16 **data, s16 *vertexData) {
register s16 *vertices;
#ifdef VERSION_EU
register f32 vx, vy, vz;
register s32 numVertices;
#else
register s32 numVertices;
register f32 vx, vy, vz;
#endif
Mat4 *objectTransform;
Mat4 m;

View File

@@ -3,8 +3,7 @@
#include "area.h"
#include "sm64.h"
#include "behavior_data.h"
#include "game.h"
#include "display.h"
#include "game_init.h"
#include "object_list_processor.h"
#include "engine/surface_load.h"
#include "ingame_menu.h"
@@ -19,6 +18,7 @@
#include "level_update.h"
#include "engine/geo_layout.h"
#include "save_file.h"
#include "level_table.h"
struct SpawnInfo gPlayerSpawnInfos[1];
struct GraphNode *D_8033A160[0x100];
@@ -47,19 +47,30 @@ u8 gWarpTransRed = 0;
u8 gWarpTransGreen = 0;
u8 gWarpTransBlue = 0;
s16 gCurrSaveFileNum = 1;
s16 gCurrLevelNum = 1;
s16 gCurrLevelNum = LEVEL_MIN;
const BehaviorScript *D_8032CE9C[] = {
bhvDoorWarp, bhvStar, bhvExitPodiumWarp, bhvWarp, bhvWarpPipe, bhvFadingWarp, bhvWarps60,
bhvWarps64, bhvWarps68, bhvWarps6C, bhvWarps70, bhvWarps74, bhvWarps78, bhvWarps94,
bhvWarps7C, bhvWarps80, bhvWarps88, bhvWarps84, bhvWarps8C, bhvWarps90,
/*
* The following two tables are used in get_mario_spawn_type() to determine spawn type
* from warp behavior.
* When looping through sWarpBhvSpawnTable, if the behavior function in the table matches
* the spawn behavior executed, the index of that behavior is used with sSpawnTypeFromWarpBhv
*/
// D_8032CE9C
const BehaviorScript *sWarpBhvSpawnTable[] = {
bhvDoorWarp, bhvStar, bhvExitPodiumWarp, bhvWarp,
bhvWarpPipe, bhvFadingWarp, bhvWarps60, bhvWarps64,
bhvWarps68, bhvWarps6C, bhvDeathWarp, bhvWarps74,
bhvWarps78, bhvWarps94, bhvWarps7C, bhvPaintingDeathWarp,
bhvWarps88, bhvWarps84, bhvWarps8C, bhvWarps90,
};
u8 D_8032CEEC[] = {
// D_8032CEEC
u8 sSpawnTypeFromWarpBhv[] = {
MARIO_SPAWN_UNKNOWN_01, MARIO_SPAWN_UNKNOWN_02, MARIO_SPAWN_UNKNOWN_03, MARIO_SPAWN_UNKNOWN_03,
MARIO_SPAWN_UNKNOWN_03, MARIO_SPAWN_UNKNOWN_04, MARIO_SPAWN_UNKNOWN_10, MARIO_SPAWN_UNKNOWN_12,
MARIO_SPAWN_UNKNOWN_13, MARIO_SPAWN_UNKNOWN_14, MARIO_SPAWN_UNKNOWN_15, MARIO_SPAWN_UNKNOWN_16,
MARIO_SPAWN_UNKNOWN_17, MARIO_SPAWN_UNKNOWN_11, MARIO_SPAWN_UNKNOWN_20, MARIO_SPAWN_UNKNOWN_21,
MARIO_SPAWN_UNKNOWN_13, MARIO_SPAWN_UNKNOWN_14, MARIO_SPAWN_DEATH, MARIO_SPAWN_UNKNOWN_16,
MARIO_SPAWN_UNKNOWN_17, MARIO_SPAWN_UNKNOWN_11, MARIO_SPAWN_UNKNOWN_20, MARIO_SPAWN_PAINTING_DEATH,
MARIO_SPAWN_UNKNOWN_22, MARIO_SPAWN_UNKNOWN_23, MARIO_SPAWN_UNKNOWN_24, MARIO_SPAWN_UNKNOWN_25,
};
@@ -120,8 +131,8 @@ u32 get_mario_spawn_type(struct Object *o) {
const BehaviorScript *behavior = virtual_to_segmented(0x13, o->behavior);
for (i = 0; i < 20; i++) {
if (D_8032CE9C[i] == behavior) {
return D_8032CEEC[i];
if (sWarpBhvSpawnTable[i] == behavior) {
return sSpawnTypeFromWarpBhv[i];
}
}
return 0;

View File

@@ -3,13 +3,12 @@
#include "sm64.h"
#include "types.h"
#include "behavior_actions.h"
#include "game.h"
#include "game_init.h"
#include "main.h"
#include "mario.h"
#include "engine/behavior_script.h"
#include "engine/math_util.h"
#include "object_helpers.h"
#include "object_helpers2.h"
#include "behavior_data.h"
#include "obj_behaviors.h"
#include "engine/surface_collision.h"
@@ -22,7 +21,6 @@
#include "area.h"
#include "engine/graph_node.h"
#include "camera.h"
#include "display.h"
#include "spawn_object.h"
#include "mario_actions_cutscene.h"
#include "object_list_processor.h"
@@ -37,6 +35,7 @@
#include "ingame_menu.h"
#include "rendering_graph_node.h"
#include "level_table.h"
#include "thread6.h"
#define o gCurrentObject

View File

@@ -260,7 +260,7 @@ void bhv_circling_amp_init(void) {
// Choose a random point along the amp's circle.
// The amp's move angle represents its angle along the circle.
o->oMoveAngleYaw = RandomU16();
o->oMoveAngleYaw = random_u16();
o->oAction = AMP_ACT_IDLE;
}

View File

@@ -20,7 +20,7 @@ void bhv_beta_chest_bottom_init(void) {
// a point with different yaws. Maybe this feature was lazily
// cancelled by setting the yaw to 0, right before this beta
// object was discarded?
o->oMoveAngleYaw = RandomU16();
o->oMoveAngleYaw = random_u16();
o->oMoveAngleYaw = 0;
// Spawn the chest lid 97 units in the +Y direction and 77 units in the -Z direction.

View File

@@ -37,8 +37,8 @@ static void bird_act_inactive(void) {
// Start with a random yaw, and a random pitch from 1000 to 5000.
// Positive pitch is downwards.
o->oMoveAnglePitch = 5000 - (s32)(4000.0f * RandomFloat());
o->oMoveAngleYaw = RandomU16();
o->oMoveAnglePitch = 5000 - (s32)(4000.0f * random_float());
o->oMoveAngleYaw = random_u16();
o->oBirdSpeed = 40.0f;

View File

@@ -15,12 +15,12 @@ void bhv_blue_fish_movement_loop(void) {
// Assigns random values to variables that help determine natural motion.
if (o->oTimer == 0) {
o->oBlueFishRandomAngle = RandomSign() << 11;
o->oBlueFishRandomVel = RandomFloat() * 2;
o->oBlueFishRandomTime = (s32)(RandomFloat() * 30) & 0xFE;
o->oBlueFishRandomAngle = random_sign() << 11;
o->oBlueFishRandomVel = random_float() * 2;
o->oBlueFishRandomTime = (s32)(random_float() * 30) & 0xFE;
// Adjusts pitch velocity or sets to zero dependant on outcome of randomSwitch.
randomSwitch = RandomFloat() * 5;
randomSwitch = random_float() * 5;
if (randomSwitch < 2.0f) {
o->oAngleVelPitch = random_f32_around_zero(128);
} else {

View File

@@ -44,9 +44,9 @@ void bobomb_act_explode(void) {
void bobomb_check_interactions(void) {
obj_set_hitbox(o, &sBobombHitbox);
if ((o->oInteractStatus & INT_STATUS_INTERACTED) != 0) /* bit 15 */
if ((o->oInteractStatus & INT_STATUS_INTERACTED) != 0)
{
if ((o->oInteractStatus & INTERACT_GRABBABLE) != 0) /* bit 1 */
if ((o->oInteractStatus & INT_STATUS_MARIO_UNK1) != 0)
{
o->oMoveAngleYaw = gMarioObject->header.gfx.angle[1];
o->oForwardVel = 25.0;
@@ -54,7 +54,7 @@ void bobomb_check_interactions(void) {
o->oAction = BOBOMB_ACT_LAUNCHED;
}
if ((o->oInteractStatus & INTERACT_TEXT) != 0) /* bit 23 */
if ((o->oInteractStatus & INT_STATUS_TOUCHED_BOB_OMB) != 0)
o->oAction = BOBOMB_ACT_EXPLODE;
o->oInteractStatus = 0;
@@ -174,7 +174,7 @@ void bobomb_free_loop(void) {
}
void bobomb_held_loop(void) {
o->header.gfx.node.flags |= 0x10; /* bit 4 */
o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
cur_obj_init_animation(1);
cur_obj_set_pos_relative(gMarioObject, 0, 60.0f, 100.0);
@@ -183,8 +183,7 @@ void bobomb_held_loop(void) {
//! Although the Bob-omb's action is set to explode when the fuse timer expires,
// bobomb_act_explode() will not execute until the bob-omb's held state changes.
// This allows the Bob-omb to be regrabbed indefinitely.
gMarioObject->oInteractStatus |= INTERACT_DAMAGE; /* bit 3 */
gMarioObject->oInteractStatus |= INT_STATUS_MARIO_DROP_OBJECT;
o->oAction = BOBOMB_ACT_EXPLODE;
}
}
@@ -192,7 +191,7 @@ void bobomb_held_loop(void) {
void bobomb_dropped_loop(void) {
cur_obj_get_dropped();
o->header.gfx.node.flags &= ~0x10; /* bit 4 = 0 */
o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
cur_obj_init_animation(0);
o->oHeldState = 0;
@@ -202,7 +201,7 @@ void bobomb_dropped_loop(void) {
void bobomb_thrown_loop(void) {
cur_obj_enable_rendering_2();
o->header.gfx.node.flags &= ~0x10; /* bit 4 = 0 */
o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
o->oHeldState = 0;
o->oFlags &= ~0x8; /* bit 3 */
o->oForwardVel = 25.0;
@@ -214,7 +213,7 @@ void bobomb_thrown_loop(void) {
void curr_obj_random_blink(s32 *blinkTimer) {
if (*blinkTimer == 0) {
if ((s16)(RandomFloat() * 100.0f) == 0) {
if ((s16)(random_float() * 100.0f) == 0) {
o->oAnimState = 1;
*blinkTimer = 1;
}
@@ -272,9 +271,9 @@ void bhv_bobomb_loop(void) {
}
void bhv_bobomb_fuse_smoke_init(void) {
o->oPosX += (s32)(RandomFloat() * 80.0f) - 40;
o->oPosY += (s32)(RandomFloat() * 80.0f) + 60;
o->oPosZ += (s32)(RandomFloat() * 80.0f) - 40;
o->oPosX += (s32)(random_float() * 80.0f) - 40;
o->oPosY += (s32)(random_float() * 80.0f) + 60;
o->oPosZ += (s32)(random_float() * 80.0f) - 40;
cur_obj_scale(1.2f);
}

View File

@@ -3,7 +3,7 @@
void bhv_small_bomp_init(void) {
o->oFaceAngleYaw -= 0x4000;
o->oSmallBompInitX = o->oPosX;
o->oTimer = RandomFloat() * 100.0f;
o->oTimer = random_float() * 100.0f;
}
void bhv_small_bomp_loop(void) {
@@ -59,7 +59,7 @@ void bhv_small_bomp_loop(void) {
void bhv_large_bomp_init(void) {
o->oMoveAngleYaw += 0x4000;
o->oTimer = RandomFloat() * 100.0f;
o->oTimer = random_float() * 100.0f;
}
void bhv_large_bomp_loop(void) {

View File

@@ -100,7 +100,7 @@ void bhv_courtyard_boo_triplet_init(void) {
bhvGhostHuntBoo
);
boo->oMoveAngleYaw = RandomU16();
boo->oMoveAngleYaw = random_u16();
}
}
}
@@ -412,8 +412,8 @@ static void boo_act_1(void) {
s32 attackStatus;
if (o->oTimer == 0) {
o->oBooNegatedAggressiveness = -RandomFloat() * 5.0f;
o->oBooTurningSpeed = (s32)(RandomFloat() * 128.0f);
o->oBooNegatedAggressiveness = -random_float() * 5.0f;
o->oBooTurningSpeed = (s32)(random_float() * 128.0f);
}
boo_chase_mario(-100.0f, o->oBooTurningSpeed + 0x180, 0.5f);

Some files were not shown because too many files have changed in this diff Show More