the cutting room mirror

Game Scripts

Camera#

Located in sm64/src/game/camera.c An unused function that sets the camera's position to Mario.

static void set_pos_to_mario(Vec3f foc, Vec3f pos, f32 yOff, f32 focYOff, f32 dist, s16 pitch, s16 yaw) {
    Vec3f marioPos;
    f32 posDist;
    f32 focDist;

    s16 posPitch;
    s16 posYaw;
    s16 focPitch;
    s16 focYaw;

    vec3f_copy(marioPos, sMarioCamState->pos);
    marioPos[1] += yOff;

    vec3f_set_dist_and_angle(marioPos, pos, dist, pitch + sLakituPitch, yaw);
    vec3f_get_dist_and_angle(pos, sMarioCamState->pos, &posDist, &posPitch, &posYaw);

    vec3f_get_dist_and_angle(pos, foc, &focDist, &focPitch, &focYaw);
    vec3f_set_dist_and_angle(pos, foc, focDist, focPitch, focYaw);

    foc[1] = sMarioCamState->pos[1] + focYOff;
}

Game Initilization#

Located in sm64/src/game/game_init.c Unused function to record demos.

static void record_demo(void) {
    u8 buttonMask =
        ((gPlayer1Controller->buttonDown & (A_BUTTON | B_BUTTON | Z_TRIG | START_BUTTON)) >> 8)
        | (gPlayer1Controller->buttonDown & (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS));
    s8 rawStickX = gPlayer1Controller->rawStickX;
    s8 rawStickY = gPlayer1Controller->rawStickY;

    if (rawStickX > -8 && rawStickX < 8) {
        rawStickX = 0;
    }

    if (rawStickY > -8 && rawStickY < 8) {
        rawStickY = 0;
    }

    if (gRecordedDemoInput.timer == 0xFF || buttonMask != gRecordedDemoInput.buttonMask
        || rawStickX != gRecordedDemoInput.rawStickX || rawStickY != gRecordedDemoInput.rawStickY) {
        gRecordedDemoInput.timer = 0;
        gRecordedDemoInput.buttonMask = buttonMask;
        gRecordedDemoInput.rawStickX = rawStickX;
        gRecordedDemoInput.rawStickY = rawStickY;
    }
    gRecordedDemoInput.timer++;
}

Interaction#

Located in sm64/src/game/interaction.c.

An unused simpler version of determining Mario's knockback action.

static u32 determine_knockback_action(struct MarioState *m) {
    u32 bonkAction;
    s16 angleToObject = mario_obj_angle_to_object(m, m->interactObj);
    s16 facingDYaw = angleToObject - m->faceAngle[1];

    if (m->forwardVel < 16.0f) {
        m->forwardVel = 16.0f;
    }

    m->faceAngle[1] = angleToObject;

    if (facingDYaw >= -0x4000 && facingDYaw <= 0x4000) {
        m->forwardVel *= -1.0f;
        if (m->action & (ACT_FLAG_AIR | ACT_FLAG_ON_POLE | ACT_FLAG_HANGING)) {
            bonkAction = ACT_BACKWARD_AIR_KB;
        } else {
            bonkAction = ACT_SOFT_BACKWARD_GROUND_KB;
        }
    } else {
        m->faceAngle[1] += 0x8000;
        if (m->action & (ACT_FLAG_AIR | ACT_FLAG_ON_POLE | ACT_FLAG_HANGING)) {
            bonkAction = ACT_FORWARD_AIR_KB;
        } else {
            bonkAction = ACT_SOFT_FORWARD_GROUND_KB;
        }
    }

    return bonkAction;
}

An unused function thats related to invincibility.

static u32 interact_stub(struct MarioState *m, u32 interactType, struct Object *o) {
    if (!(o->oInteractionSubtype & INT_SUBTYPE_DELAY_INVINCIBILITY)) {
        sDelayInvincTimer = TRUE;
    }
    return FALSE;
}

Level Update#

Located in sm64/src/game/level_update.c

An unused play mode, referred to as FreezePlayerProcess in the source code.

static s32 play_mode(void) {
    if (--sTransitionTimer == -1) {
        gHudDisplay.flags = HUD_DISPLAY_NONE;

        if (sWarpDest.type != WARP_TYPE_NOT_WARPING) {
            return sWarpDest.levelNum;
        } else {
            return D_80339EE0;
        }
    }

    return 0;
}

Macro Special Objects#

A function that spawns a macro coin, Purpose unknown.

static void spawn_macro_coin_unknown(const BehaviorScript *behavior, s16 objInfo[]) {
    struct Object *coin;
    s16 model = bhvYellowCoin == behavior ? MODEL_YELLOW_COIN : MODEL_NONE;

    coin = spawn_object_abs_with_rot(&gMacroObjectDefaultParent, 0, model, behavior,
                                     objInfo[MACRO_OBJ_X], objInfo[MACRO_OBJ_Y], objInfo[MACRO_OBJ_Z],
                                     0, convert_rotation(objInfo[MACRO_OBJ_Y_ROT]), 0);
    coin->oUnusedBhvParams = objInfo[MACRO_OBJ_PARAMS];
    coin->oBhvParams = (objInfo[MACRO_OBJ_PARAMS] & 0xFF) >> 16;
}

Object Behaviors#

Located in sm64/src/game/obj_behaviors.c and sm64/src/game/obj_behaviors_2.c.

A function that bears strong similarity to geo_bits_bowser_coloring.

Gfx *geo_obj_transparency_something(s32 callContext, struct GraphNode *node, Mat4 *mtx) {
    Gfx *gfxHead;
    Gfx *gfx;
    struct Object *heldObject;
    struct Object *obj;
    struct Object *Object;
    u8 filler[4];

    gfxHead = NULL;

    if (callContext == GEO_CONTEXT_RENDER) {
        heldObject = (struct Object *) gCurGraphNodeObject;
        obj = (struct Object *) node;
        unusedObject = (struct Object *) node;

        if (gCurGraphNodeHeldObject != NULL) {
            heldObject = gCurGraphNodeHeldObject->objNode;
        }

        gfxHead = alloc_display_list(3 * sizeof(Gfx));
        gfx = gfxHead;
        obj->header.gfx.node.flags =
            (obj->header.gfx.node.flags & 0xFF) | (GRAPH_NODE_TYPE_FUNCTIONAL | GRAPH_NODE_TYPE_400);

        gDPSetEnvColor(gfx++, 255, 255, 255, heldObject->oOpacity);

        gSPEndDisplayList(gfx);
    }

    return gfxHead;
}

A presumably debug function that tracks for a sequence of inputs.

s8 sDebugSequenceTracker = 0;
s8 sDebugTimer = 0;

 s8 debug_sequence_tracker(s16 debugInputSequence[]) {
    if (debugInputSequence[sDebugSequenceTracker] == 0) {
        sDebugSequenceTracker = 0;
        return TRUE;
    }

    if (debugInputSequence[sDebugSequenceTracker] & gPlayer3Controller->buttonPressed) {
        sDebugSequenceTracker++;
        sDebugTimer = 0;
    } else if (sDebugTimer == 10 || gPlayer3Controller->buttonPressed != 0) {
        sDebugSequenceTracker = 0;
        sDebugTimer = 0;
        return FALSE;
    }
    sDebugTimer++;

    return FALSE;
}

An unused die function, purpose unknown.

static void obj_die(void) {
    o->oHealth = 0;
    obj_die_if_health_non_positive();
}

Object Helpers#

Located in sm64/src/game/object_helpers.c.

An unused function that initialzes the object that's on the floor.

void cur_obj_init_on_floor(void) {
    cur_obj_enable_rendering();

    o->oPosY = find_floor_height(o->oPosX, o->oPosY, o->oPosZ);
    if (o->oPosY < FLOOR_LOWER_LIMIT_MISC) {
        cur_obj_set_pos_relative_to_parent(0, 0, -70);
        o->oPosY = find_floor_height(o->oPosX, o->oPosY, o->oPosZ);
    }
}

An unused function that does nothing.

static void stub_obj_helpers_1(void) {
}

static void stub_obj_helpers_2(void) {
}

void stub_obj_helpers_3(s32 arg0,s32 arg1) {
}

static void stub_obj_helpers_5(void) {
}

A unused function that resolves wall collisions.

void cur_obj_resolve_wall_collisions(f32 offsetY, f32 radius) {
    if (radius > 0.1L) {
        f32_find_wall_collision(&o->oPosX, &o->oPosY, &o->oPosZ, offsetY, radius);
    }
}

An unused function of spawning a star with no level exiting.

void spawn_base_star_with_no_lvl_exit(void) {
    spawn_star_with_no_lvl_exit(0, 0);
}
void set_mario_interact_true_if_in_range(s32 arg0, s32 arg1, f32 range) {
    if (o->oDistanceToMario < range) {
        gMarioObject->oInteractStatus = TRUE;
    }
}
void cur_obj_play_footstep_sound(s32 animFrame1, s32 animFrame2, s32 sound) {
    if (cur_obj_check_anim_frame(animFrame1) || cur_obj_check_anim_frame(animFrame2)) {
        cur_obj_play_sound_2(sound);
    }
}

Object List Processor#

Located in sm64/src/game/object_list_processor.c.

An unknown variable, purpose unknown.

s32 8033BEF8;

An unknown wall count variable, No code calls this.

s32 gUnknownWallCount;

A function that gets the elapsed time from cycle counts.

static u16 get_elapsed_time(u64 *cycleCounts, s32 index) {
    u16 time;
    f64 cycles;

    cycles = cycleCounts[index] - cycleCounts[index - 1];
    if (cycles < 0) {
        cycles = 0;
    }

    time = (u16)(((u64) cycles * 1000000 / osClockRate) / 16667.0 * 1000.0);
    if (time > 999) {
        time = 999;
    }

    return time;
}

Save File#

Located in sm64/src/game/save_file.c

An unused function that does nothing, Might've been debug.

void stub_save_file_1(void) {
    u8 filler[4];
}

Spawn Object#

Located in sm64/src/game/spawn_object.c.

An unused linked list struct that seems to have been replaced by ObjectNode.

struct LinkedList {
    struct LinkedList *next;
    struct LinkedList *prev;
};

A function that removes the node from the doubly linked list it's in, and place it in the singly linked freeList. This function seems to have been replaced by deallocate_object.

void deallocate(struct LinkedList *freeList, struct LinkedList *node) {
    node->next->prev = node->prev;
    node->prev->next = node->next;

    node->next = freeList->next;
    freeList->next = node;
}

A function that clears the doubly linked usedList, Singly link each item in the pool into a list, and return this list in pFreeList. Appears to have been replaced by init_free_object_list.

void init_free_list(struct LinkedList *usedList, struct LinkedList **pFreeList,
                           struct LinkedList *pool, s32 itemSize, s32 poolLength) {
    s32 i;
    struct LinkedList *node = pool;

    usedList->next = usedList;
    usedList->prev = usedList;

    *pFreeList = pool;

    for (i = 0; i < poolLength - 1; i++) {
        node = (struct LinkedList *) ((u8 *) node + itemSize);
        pool->next = node;
        pool = node;
    }
    
    pool->next = NULL;
}

A function that attempts to allocate a node from freeList (singly linked) and append itto the end of destList (doubly linked). Return the object, or NULL if freeList is empty. Appears to have been replaced by try_allocate_object.

struct LinkedList *try_allocate(struct LinkedList *destList,
                                       struct LinkedList *freeList) {
    struct LinkedList *node = freeList->next;

    if (node != NULL) {
        freeList->next = node->next;

        node->prev = destList->prev;
        node->next = destList;
        destList->prev->next = node;
        destList->prev = node;
    }

    return node;
}

An unused function that deletes leaf nodes under obj and obj's siblings.

static void delete_leaf_nodes(struct Object *obj) {
    struct Object *children;
    struct Object *sibling;
    struct Object *obj0 = obj;

    if ((children = (struct Object *) obj->header.gfx.node.children) != NULL) {
        delete_leaf_nodes(children);
    } else {
        mark_obj_for_deletion(obj);
    }

    while ((sibling = (struct Object *) obj->header.gfx.node.next) == obj0) {
        delete_leaf_nodes(sibling);
        obj = (struct Object *) sibling->header.gfx.node.next;
    }
}

Spawn Sound#

Located in sm64/src/game/spawn_sound.c.

Functions that calculates the distance to volume range.

s32 calc_dist_to_volume_range_1(f32 distance) {
    s32 volume;

    if (distance < 500.0f) {
        volume = 127;
    } else if (1500.0f < distance) {
        volume = 0;
    } else {
        volume = (((distance - 500.0f) / 1000.0f) * 64.0f) + 60.0f;
    }

    return volume;
}

s32 calc_dist_to_volume_range_2(f32 distance) {
    s32 volume;

    if (distance < 1300.0f) {
        volume = 127;
    } else if (2300.0f < distance) {
        volume = 0;
    } else {
        volume = (((distance - 1000.0f) / 1000.0f) * 64.0f) + 60.0f;
    }

    return volume;
}