COND_BIT + fix transparent tree layer + asymptitic turn

This commit is contained in:
Arceveti
2021-09-27 18:03:06 -07:00
parent 87cdbc8ceb
commit 56fa02ec87
25 changed files with 68 additions and 151 deletions

View File

@@ -9,7 +9,7 @@ const GeoLayout bubbly_tree_geo[] = {
#endif
GEO_DISPLAY_LIST(LAYER_ALPHA, tree_seg3_dl_bubbly),
#ifdef OBJ_OPACITY_BY_CAM_DIST
GEO_DISPLAY_LIST(LAYER_TRANSPARENT, tree_seg3_dl_bubbly),
GEO_DISPLAY_LIST(LAYER_TRANSPARENT_INTER, tree_seg3_dl_bubbly),
GEO_CLOSE_NODE(),
#endif
GEO_CLOSE_NODE(),
@@ -27,7 +27,7 @@ const GeoLayout spiky_tree_geo[] = {
#endif
GEO_DISPLAY_LIST(LAYER_ALPHA, tree_seg3_dl_spiky),
#ifdef OBJ_OPACITY_BY_CAM_DIST
GEO_DISPLAY_LIST(LAYER_TRANSPARENT, tree_seg3_dl_spiky),
GEO_DISPLAY_LIST(LAYER_TRANSPARENT_INTER, tree_seg3_dl_spiky),
GEO_CLOSE_NODE(),
#endif
GEO_CLOSE_NODE(),
@@ -45,7 +45,7 @@ const GeoLayout snow_tree_geo[] = {
#endif
GEO_DISPLAY_LIST(LAYER_ALPHA, tree_seg3_dl_snowy_pine),
#ifdef OBJ_OPACITY_BY_CAM_DIST
GEO_DISPLAY_LIST(LAYER_TRANSPARENT, tree_seg3_dl_snowy_pine),
GEO_DISPLAY_LIST(LAYER_TRANSPARENT_INTER, tree_seg3_dl_snowy_pine),
GEO_CLOSE_NODE(),
#endif
GEO_CLOSE_NODE(),
@@ -63,7 +63,7 @@ const GeoLayout palm_tree_geo[] = {
#endif
GEO_DISPLAY_LIST(LAYER_ALPHA, tree_seg3_dl_palm),
#ifdef OBJ_OPACITY_BY_CAM_DIST
GEO_DISPLAY_LIST(LAYER_TRANSPARENT, tree_seg3_dl_palm),
GEO_DISPLAY_LIST(LAYER_TRANSPARENT_INTER, tree_seg3_dl_palm),
GEO_CLOSE_NODE(),
#endif
GEO_CLOSE_NODE(),

View File

@@ -66,6 +66,7 @@
// 1 is similar to vanilla, but prevents Mario from moving in the wrong direction, and allows finer control with the analog stick.
// 2 is similar to mode 1, but a bit further from vanilla, and allows instant turnaround if Mario is moving slower than a certain threshold.
// 3 is instant turning to the intended direction regardless of speed and angle.
// 4 is an expeimental asymptotic turn.
#define GROUND_TURN_MODE 0
// Improved hanging:
// - Doesn't require holding down the A button

View File

@@ -10,6 +10,7 @@
#define BIT(i) (1 << (i))
#define BITMASK(size) ((BIT(size)) - 1)
#define COND_BIT(cond, dst, flag) { (dst) &= ~(flag); if (cond) (dst) |= (flag); }
struct Config
{

View File

@@ -971,17 +971,8 @@ void cur_obj_update(void) {
obj_update_gfx_pos_and_angle(gCurrentObject);
}
if (objFlags & OBJ_FLAG_UCODE_LARGE) {
gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_UCODE_REJ;
} else {
gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_UCODE_REJ;
}
if (objFlags & OBJ_FLAG_SILHOUETTE) {
gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_SILHOUETTE;
} else {
gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_SILHOUETTE;
}
COND_BIT((!(objFlags & OBJ_FLAG_UCODE_LARGE)), gCurrentObject->header.gfx.node.flags, GRAPH_RENDER_UCODE_REJ );
COND_BIT( (objFlags & OBJ_FLAG_SILHOUETTE ), gCurrentObject->header.gfx.node.flags, GRAPH_RENDER_SILHOUETTE);
#ifdef OBJ_OPACITY_BY_CAM_DIST
if (objFlags & OBJ_FLAG_OPACITY_FROM_CAMERA_DIST) {

View File

@@ -172,15 +172,9 @@ void geo_layout_cmd_update_node_flags(void) {
u16 flagBits = cur_geo_cmd_s16(0x02);
switch (operation) {
case GEO_CMD_FLAGS_RESET:
gCurGraphNodeList[gCurGraphNodeIndex]->flags = flagBits;
break;
case GEO_CMD_FLAGS_SET:
gCurGraphNodeList[gCurGraphNodeIndex]->flags |= flagBits;
break;
case GEO_CMD_FLAGS_CLEAR:
gCurGraphNodeList[gCurGraphNodeIndex]->flags &= ~flagBits;
break;
case GEO_CMD_FLAGS_RESET: gCurGraphNodeList[gCurGraphNodeIndex]->flags = flagBits; break;
case GEO_CMD_FLAGS_SET: gCurGraphNodeList[gCurGraphNodeIndex]->flags |= flagBits; break;
case GEO_CMD_FLAGS_CLEAR: gCurGraphNodeList[gCurGraphNodeIndex]->flags &= ~flagBits; break;
}
gGeoLayoutCommand += 0x04 << CMD_SIZE_SHIFT;

View File

@@ -722,9 +722,9 @@ void geo_obj_init(struct GraphNodeObject *graphNode, void *sharedChild, Vec3f po
graphNode->throwMatrix = NULL;
graphNode->animInfo.curAnim = NULL;
graphNode->node.flags |= GRAPH_RENDER_ACTIVE;
graphNode->node.flags |= GRAPH_RENDER_ACTIVE;
graphNode->node.flags &= ~GRAPH_RENDER_INVISIBLE;
graphNode->node.flags |= GRAPH_RENDER_HAS_ANIMATION;
graphNode->node.flags |= GRAPH_RENDER_HAS_ANIMATION;
graphNode->node.flags &= ~GRAPH_RENDER_BILLBOARD;
}

View File

@@ -753,13 +753,8 @@ void load_object_collision_model(void) {
load_object_surfaces(&collisionData, vertexData);
}
}
if (marioDist < gCurrentObject->oDrawingDistance) {
gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE;
} else {
gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE;
}
#if PUPPYPRINT_DEBUG
COND_BIT((marioDist < gCurrentObject->oDrawingDistance), gCurrentObject->header.gfx.node.flags, GRAPH_RENDER_ACTIVE);
#if PUPPYPRINT_DEBUG
collisionTime[perfIteration] += osGetTime()-first;
#endif
#endif
}

View File

@@ -248,7 +248,7 @@ void unload_area(void) {
unload_objects_from_area(0, gCurrentArea->index);
geo_call_global_function_nodes(&gCurrentArea->graphNode->node, GEO_CONTEXT_AREA_UNLOAD);
gCurrentArea->flags = 0;
gCurrentArea->flags = AREA_FLAG_UNLOAD;
gCurrentArea = NULL;
gWarpTransition.isActive = FALSE;
}
@@ -259,20 +259,19 @@ void load_mario_area(void) {
load_area(gMarioSpawnInfo->areaIndex);
if (gCurrentArea->index == gMarioSpawnInfo->areaIndex) {
gCurrentArea->flags |= 0x01;
gCurrentArea->flags |= AREA_FLAG_LOAD;
spawn_objects_from_info(0, gMarioSpawnInfo);
}
if (gAreaSkyboxStart[gCurrAreaIndex-1]) {
load_segment_decompress(0x0A, gAreaSkyboxStart[gCurrAreaIndex-1], gAreaSkyboxEnd[gCurrAreaIndex-1]);
if (gAreaSkyboxStart[gCurrAreaIndex - 1]) {
load_segment_decompress(0x0A, gAreaSkyboxStart[gCurrAreaIndex - 1], gAreaSkyboxEnd[gCurrAreaIndex - 1]);
}
}
void unload_mario_area(void) {
if (gCurrentArea != NULL && (gCurrentArea->flags & 0x01)) {
if (gCurrentArea != NULL && (gCurrentArea->flags & AREA_FLAG_LOAD)) {
unload_objects_from_area(0, gMarioSpawnInfo->activeAreaIndex);
gCurrentArea->flags &= ~0x01;
if (gCurrentArea->flags == 0) {
gCurrentArea->flags &= ~AREA_FLAG_LOAD;
if (gCurrentArea->flags == AREA_FLAG_UNLOAD) {
unload_area();
}
}

View File

@@ -60,6 +60,9 @@ struct Whirlpool
/*0x03*/ s16 strength;
};
#define AREA_FLAG_UNLOAD 0x0
#define AREA_FLAG_LOAD 0x1
struct Area
{
/*0x00*/ s8 index;

View File

@@ -366,10 +366,11 @@ void bobomb_buddy_act_talk(void) {
break;
case BOBOMB_BUDDY_ROLE_CANNON:
if (gCurrCourseNum == COURSE_BOB)
if (gCurrCourseNum == COURSE_BOB) {
bobomb_buddy_cannon_dialog(DIALOG_004, DIALOG_105);
else
} else {
bobomb_buddy_cannon_dialog(DIALOG_047, DIALOG_106);
}
break;
}
}

View File

@@ -57,10 +57,7 @@ void breakable_box_small_released_loop(void) {
// Begin flashing
if (o->oBreakableBoxSmallFramesSinceReleased > 810) {
if (o->oBreakableBoxSmallFramesSinceReleased & 1)
o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
else
o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
COND_BIT((o->oBreakableBoxSmallFramesSinceReleased & 0X1), o->header.gfx.node.flags, GRAPH_RENDER_INVISIBLE);
}
// Despawn, and create a corkbox respawner

View File

@@ -33,8 +33,8 @@ void bhv_flame_mario_loop(void) {
spawn_object(o, MODEL_BURN_SMOKE, bhvBlackSmokeMario);
gMarioObject->prevObj = o; // weird?
obj_set_parent_relative_pos(o, 40, -120, 0);
if (!(gMarioObject->oMarioParticleFlags & 0x800)) {
o->parentObj->oActiveParticleFlags &= ~0x800;
if (!(gMarioObject->oMarioParticleFlags & ACTIVE_PARTICLE_FIRE)) {
o->parentObj->oActiveParticleFlags &= ~ACTIVE_PARTICLE_FIRE;
obj_mark_for_deletion(o);
gMarioObject->prevObj = NULL;
}

View File

@@ -36,7 +36,7 @@ void bhv_snow_leaf_particle_spawn_init(void) {
struct Object *obj; // Either snow or leaf
struct Object *nearestTree = NULL;
f32 scale;
gMarioObject->oActiveParticleFlags &= ~0x2000;
gMarioObject->oActiveParticleFlags &= ~ACTIVE_PARTICLE_LEAF;
// Whether a tree uses snow particles or not is decided via the model IDs instead of the course number
nearestTree = cur_obj_nearest_object_with_behavior(bhvTree);
if (nearestTree->header.gfx.sharedChild == gLoadedGraphNodes[MODEL_CCM_SNOW_TREE] || nearestTree->header.gfx.sharedChild == gLoadedGraphNodes[MODEL_SL_SNOW_TREE]) {

View File

@@ -60,10 +60,7 @@ void bhv_water_droplet_loop(void) {
f32 waterLevel = find_water_level(o->oPosX, o->oPosZ);
if (o->oTimer == 0) {
if (cur_obj_has_model(MODEL_FISH))
o->header.gfx.node.flags &= ~GRAPH_RENDER_BILLBOARD;
else
o->header.gfx.node.flags |= GRAPH_RENDER_BILLBOARD;
COND_BIT((!cur_obj_has_model(MODEL_FISH)), o->header.gfx.node.flags, GRAPH_RENDER_BILLBOARD);
o->oFaceAngleYaw = random_u16();
}
// Apply gravity

View File

@@ -364,22 +364,19 @@ void mario_blow_off_cap(struct MarioState *m, f32 capSpeed) {
}
u32 mario_lose_cap_to_enemy(u32 enemyType) {
u32 wasWearingCap = FALSE;
if (does_mario_have_normal_cap_on_head(gMarioState)) {
save_file_set_flags(enemyType == 1 ? SAVE_FLAG_CAP_ON_KLEPTO : SAVE_FLAG_CAP_ON_UKIKI);
gMarioState->flags &= ~(MARIO_NORMAL_CAP | MARIO_CAP_ON_HEAD);
wasWearingCap = TRUE;
return TRUE;
}
return wasWearingCap;
return FALSE;
}
void mario_retrieve_cap(void) {
mario_drop_held_object(gMarioState);
save_file_clear_flags(SAVE_FLAG_CAP_ON_KLEPTO | SAVE_FLAG_CAP_ON_UKIKI);
gMarioState->flags &= ~MARIO_CAP_ON_HEAD;
gMarioState->flags |= MARIO_NORMAL_CAP | MARIO_CAP_IN_HAND;
gMarioState->flags |= (MARIO_NORMAL_CAP | MARIO_CAP_IN_HAND);
}
u32 able_to_grab_object(struct MarioState *m, UNUSED struct Object *obj) {

View File

@@ -907,11 +907,7 @@ void update_hud_values(void) {
#ifdef BREATH_METER
s16 numBreathWedges = ((gMarioState->breath > 0) ? (gMarioState->breath >> 8) : 0);
#endif
if (gCurrCourseNum >= COURSE_MIN) {
gHudDisplay.flags |= HUD_DISPLAY_FLAG_COIN_COUNT;
} else {
gHudDisplay.flags &= ~HUD_DISPLAY_FLAG_COIN_COUNT;
}
COND_BIT((gCurrCourseNum >= COURSE_MIN), gHudDisplay.flags, HUD_DISPLAY_FLAG_COIN_COUNT);
if (gHudDisplay.coins < gMarioState->numCoins) {
if (gGlobalTimer & 0x1) {
@@ -947,18 +943,10 @@ void update_hud_values(void) {
play_sound(SOUND_MENU_POWER_METER, gGlobalSoundSource);
}
gHudDisplay.wedges = numHealthWedges;
if (gMarioState->hurtCounter > 0) {
gHudDisplay.flags |= HUD_DISPLAY_FLAG_EMPHASIZE_POWER;
} else {
gHudDisplay.flags &= ~HUD_DISPLAY_FLAG_EMPHASIZE_POWER;
}
COND_BIT((gMarioState->hurtCounter > 0), gHudDisplay.flags, HUD_DISPLAY_FLAG_EMPHASIZE_POWER);
#ifdef BREATH_METER
gHudDisplay.breath = numBreathWedges;
if (gMarioState->breath > 0) {
gHudDisplay.flags |= HUD_DISPLAY_FLAG_BREATH_METER;
} else {
gHudDisplay.flags &= ~HUD_DISPLAY_FLAG_BREATH_METER;
}
COND_BIT((gMarioState->breath > 0), gHudDisplay.flags, HUD_DISPLAY_FLAG_BREATH_METER);
#endif
}
}

View File

@@ -500,6 +500,8 @@ void update_walking_speed(struct MarioState *m) {
}
#elif GROUND_TURN_MODE == 3 // Instant turn.
m->faceAngle[1] = m->intendedYaw;
#elif GROUND_TURN_MODE == 4
m->faceAngle[1] = approach_s16_asymptotic(m->faceAngle[1], m->intendedYaw, m->forwardVel / 8.0f); // should be max speed for the current action instead of m->forwardVel
#endif
apply_slope_accel(m);
}

View File

@@ -512,11 +512,7 @@ Gfx *geo_switch_mario_cap_on_off(s32 callContext, struct GraphNode *node, UNUSED
switchCase->selectedCase = bodyState->capState & 1;
while (next != node) {
if (next->type == GRAPH_NODE_TYPE_TRANSLATION_ROTATION) {
if (bodyState->capState & 2) {
next->flags |= GRAPH_RENDER_ACTIVE;
} else {
next->flags &= ~GRAPH_RENDER_ACTIVE;
}
COND_BIT((bodyState->capState & 0x2), next->flags, GRAPH_RENDER_ACTIVE);
}
next = next->next;
}

View File

@@ -513,15 +513,7 @@ s8 is_point_close_to_object(struct Object *obj, f32 x, f32 y, f32 z, s32 dist) {
* Sets an object as visible if within a certain distance of Mario's graphical position.
*/
void set_object_visibility(struct Object *obj, s32 dist) {
f32 objX = obj->oPosX;
f32 objY = obj->oPosY;
f32 objZ = obj->oPosZ;
if (is_point_within_radius_of_mario(objX, objY, objZ, dist) == TRUE) {
obj->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
} else {
obj->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
}
COND_BIT((!is_point_within_radius_of_mario(obj->oPosX, obj->oPosY, obj->oPosZ, dist)), obj->header.gfx.node.flags, GRAPH_RENDER_INVISIBLE);
}
/**
@@ -620,11 +612,7 @@ s8 obj_flicker_and_disappear(struct Object *obj, s16 lifeSpan) {
}
if (obj->oTimer < lifeSpan + 40) {
if (obj->oTimer % 2 != 0) {
obj->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
} else {
obj->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
}
COND_BIT((obj->oTimer & 0x1), obj->header.gfx.node.flags, GRAPH_RENDER_INVISIBLE);
} else {
obj->activeFlags = ACTIVE_FLAG_DEACTIVATED;
return TRUE;

View File

@@ -34,28 +34,20 @@ s32 detect_object_hitbox_overlap(struct Object *a, struct Object *b) {
f32 dya_top = a->hitboxHeight + dya_bottom;
f32 dyb_top = b->hitboxHeight + dyb_bottom;
if (dya_bottom > dyb_top) {
return 0;
}
if (dya_top < dyb_bottom) {
return 0;
}
if (a->numCollidedObjs >= 4) {
return 0;
}
if (b->numCollidedObjs >= 4) {
return 0;
}
if (dya_bottom > dyb_top) return FALSE;
if (dya_top < dyb_bottom) return FALSE;
if (a->numCollidedObjs >= 4) return FALSE;
if (b->numCollidedObjs >= 4) return FALSE;
a->collidedObjs[a->numCollidedObjs] = b;
b->collidedObjs[b->numCollidedObjs] = a;
a->collidedObjInteractTypes |= b->oInteractType;
b->collidedObjInteractTypes |= a->oInteractType;
a->numCollidedObjs++;
b->numCollidedObjs++;
return 1;
return TRUE;
}
return 0;
return FALSE;
}
s32 detect_object_hurtbox_overlap(struct Object *a, struct Object *b) {
@@ -74,19 +66,15 @@ s32 detect_object_hurtbox_overlap(struct Object *a, struct Object *b) {
f32 dya_top = a->hitboxHeight + dya_bottom;
f32 dyb_top = b->hurtboxHeight + dyb_bottom;
if (dya_bottom > dyb_top) {
return 0;
}
if (dya_top < dyb_bottom) {
return 0;
}
if (dya_bottom > dyb_top) return FALSE;
if (dya_top < dyb_bottom) return FALSE;
if (a == gMarioObject) {
b->oInteractionSubtype &= ~INT_SUBTYPE_DELAY_INVINCIBILITY;
}
return 1;
return TRUE;
}
return 0;
return FALSE;
}
void clear_object_collision(struct Object *a) {

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