sm64

A Super Mario 64 decompilation
Log | Files | Refs | README | LICENSE

script.c (12642B)


      1 #include <ultra64.h>
      2 #include "sm64.h"
      3 #include "behavior_data.h"
      4 #include "model_ids.h"
      5 #include "seq_ids.h"
      6 #include "segment_symbols.h"
      7 #include "level_commands.h"
      8 
      9 #include "game/level_update.h"
     10 
     11 #include "levels/scripts.h"
     12 
     13 #include "actors/common1.h"
     14 
     15 #include "make_const_nonconst.h"
     16 #include "levels/thi/header.h"
     17 
     18 static const LevelScript script_func_local_1[] = {
     19     RETURN(),
     20 };
     21 
     22 static const LevelScript script_func_local_2[] = {
     23     OBJECT_WITH_ACTS(/*model*/ MODEL_NONE,    /*pos*/     0, -700, -4500, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_4), /*bhv*/ bhvHiddenStar,          /*acts*/ ALL_ACTS),
     24     RETURN(),
     25 };
     26 
     27 static const LevelScript script_func_local_3[] = {
     28     OBJECT_WITH_ACTS(/*model*/ MODEL_NONE,             /*pos*/ -1800,   800, -1500, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_5), /*bhv*/ bhvHiddenRedCoinStar, /*acts*/ ALL_ACTS),
     29     OBJECT          (/*model*/ MODEL_WIGGLER_HEAD,     /*pos*/    17,  1843,   -62, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_6), /*bhv*/ bhvWigglerHead),
     30     RETURN(),
     31 };
     32 
     33 static const LevelScript script_func_local_4[] = {
     34     OBJECT_WITH_ACTS(/*model*/ MODEL_KOOPA_WITH_SHELL, /*pos*/ -1900,  -511,  2400, /*angle*/ 0, -30, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_3) | BPARAM2(KOOPA_BP_KOOPA_THE_QUICK_THI), /*bhv*/ bhvKoopa,             /*acts*/ ACT_3),
     35     OBJECT_WITH_ACTS(/*model*/ MODEL_NONE,             /*pos*/  7400, -1537, -6300, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvKoopaRaceEndpoint, /*acts*/ ACT_3),
     36     OBJECT          (/*model*/ MODEL_NONE,             /*pos*/ -6556, -2969,  6565, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM2(GOOMBA_TRIPLET_SPAWNER_BP_EXTRA_GOOMBAS(0) | GOOMBA_SIZE_HUGE), /*bhv*/ bhvGoombaTripletSpawner),
     37     OBJECT          (/*model*/ MODEL_GOOMBA,           /*pos*/  6517, -2559,  4327, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM2(GOOMBA_SIZE_HUGE), /*bhv*/ bhvGoomba),
     38     OBJECT          (/*model*/ MODEL_PIRANHA_PLANT,    /*pos*/ -6336, -2047, -3861, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_1) | BPARAM2(0x01), /*bhv*/ bhvFirePiranhaPlant),
     39     OBJECT          (/*model*/ MODEL_PIRANHA_PLANT,    /*pos*/ -5740, -2047, -6578, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_1) | BPARAM2(0x01), /*bhv*/ bhvFirePiranhaPlant),
     40     OBJECT          (/*model*/ MODEL_PIRANHA_PLANT,    /*pos*/ -6481, -2047, -5998, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_1) | BPARAM2(0x01), /*bhv*/ bhvFirePiranhaPlant),
     41     OBJECT          (/*model*/ MODEL_PIRANHA_PLANT,    /*pos*/ -5577, -2047, -4961, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_1) | BPARAM2(0x01), /*bhv*/ bhvFirePiranhaPlant),
     42     OBJECT          (/*model*/ MODEL_PIRANHA_PLANT,    /*pos*/ -6865, -2047, -4568, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_1) | BPARAM2(0x01), /*bhv*/ bhvFirePiranhaPlant),
     43     OBJECT          (/*model*/ MODEL_NONE,             /*pos*/ -4413,   204, -2140, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM2(BBALL_BP_STYPE_THI_LARGE), /*bhv*/ bhvTHIBowlingBallSpawner),
     44     OBJECT          (/*model*/ MODEL_BUBBA,            /*pos*/ -6241, -3300,  -716, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvBubba),
     45     OBJECT          (/*model*/ MODEL_BUBBA,            /*pos*/  1624, -3300,  8142, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvBubba),
     46     RETURN(),
     47 };
     48 
     49 static const LevelScript script_func_local_5[] = {
     50     OBJECT(/*model*/ MODEL_THI_HUGE_ISLAND_TOP, /*pos*/     0, 3891, -1533, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvTHIHugeIslandTop),
     51     RETURN(),
     52 };
     53 
     54 static const LevelScript script_func_local_6[] = {
     55     OBJECT(/*model*/ MODEL_THI_TINY_ISLAND_TOP, /*pos*/     0, 1167,  -460, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvTHITinyIslandTop),
     56     OBJECT(/*model*/ MODEL_NONE,                /*pos*/ -1382,   80,  -649, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM2(BBALL_BP_STYPE_THI_SMALL), /*bhv*/ bhvTHIBowlingBallSpawner),
     57     RETURN(),
     58 };
     59 
     60 static const LevelScript script_func_local_7[] = {
     61     OBJECT(/*model*/ MODEL_THI_WARP_PIPE, /*pos*/  6656, -1536, -5632, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM2(WARP_NODE_32), /*bhv*/ bhvWarpPipe),
     62     OBJECT(/*model*/ MODEL_THI_WARP_PIPE, /*pos*/ -5888, -2048, -5888, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM2(WARP_NODE_33), /*bhv*/ bhvWarpPipe),
     63     OBJECT(/*model*/ MODEL_THI_WARP_PIPE, /*pos*/ -3072,   512, -3840, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM2(WARP_NODE_34), /*bhv*/ bhvWarpPipe),
     64     WARP_NODE(/*id*/ WARP_NODE_32, /*destLevel*/ LEVEL_THI, /*destArea*/ 2, /*destNode*/ WARP_NODE_32, /*flags*/ WARP_NO_CHECKPOINT),
     65     WARP_NODE(/*id*/ WARP_NODE_33, /*destLevel*/ LEVEL_THI, /*destArea*/ 2, /*destNode*/ WARP_NODE_33, /*flags*/ WARP_NO_CHECKPOINT),
     66     WARP_NODE(/*id*/ WARP_NODE_34, /*destLevel*/ LEVEL_THI, /*destArea*/ 2, /*destNode*/ WARP_NODE_34, /*flags*/ WARP_NO_CHECKPOINT),
     67     RETURN(),
     68 };
     69 
     70 static const LevelScript script_func_local_8[] = {
     71     OBJECT(/*model*/ MODEL_THI_WARP_PIPE, /*pos*/  1997, -461, -1690, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM2(WARP_NODE_32), /*bhv*/ bhvWarpPipe),
     72     OBJECT(/*model*/ MODEL_THI_WARP_PIPE, /*pos*/ -1766, -614, -1766, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM2(WARP_NODE_33), /*bhv*/ bhvWarpPipe),
     73     OBJECT(/*model*/ MODEL_THI_WARP_PIPE, /*pos*/  -922,  154, -1152, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM2(WARP_NODE_34), /*bhv*/ bhvWarpPipe),
     74     WARP_NODE(/*id*/ WARP_NODE_32, /*destLevel*/ LEVEL_THI, /*destArea*/ 1, /*destNode*/ WARP_NODE_32, /*flags*/ WARP_NO_CHECKPOINT),
     75     WARP_NODE(/*id*/ WARP_NODE_33, /*destLevel*/ LEVEL_THI, /*destArea*/ 1, /*destNode*/ WARP_NODE_33, /*flags*/ WARP_NO_CHECKPOINT),
     76     WARP_NODE(/*id*/ WARP_NODE_34, /*destLevel*/ LEVEL_THI, /*destArea*/ 1, /*destNode*/ WARP_NODE_34, /*flags*/ WARP_NO_CHECKPOINT),
     77     RETURN(),
     78 };
     79 
     80 const LevelScript level_thi_entry[] = {
     81     INIT_LEVEL(),
     82     LOAD_MIO0        (/*seg*/ 0x07, _thi_segment_7SegmentRomStart, _thi_segment_7SegmentRomEnd),
     83     LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _grass_mio0SegmentRomStart, _grass_mio0SegmentRomEnd),
     84     LOAD_MIO0        (/*seg*/ 0x0A, _water_skybox_mio0SegmentRomStart, _water_skybox_mio0SegmentRomEnd),
     85     LOAD_MIO0        (/*seg*/ 0x05, _group11_mio0SegmentRomStart, _group11_mio0SegmentRomEnd),
     86     LOAD_RAW         (/*seg*/ 0x0C, _group11_geoSegmentRomStart,  _group11_geoSegmentRomEnd),
     87     LOAD_MIO0        (/*seg*/ 0x06, _group14_mio0SegmentRomStart, _group14_mio0SegmentRomEnd),
     88     LOAD_RAW         (/*seg*/ 0x0D, _group14_geoSegmentRomStart,  _group14_geoSegmentRomEnd),
     89     LOAD_MIO0        (/*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd),
     90     LOAD_RAW         (/*seg*/ 0x0F, _common0_geoSegmentRomStart,  _common0_geoSegmentRomEnd),
     91     ALLOC_LEVEL_POOL(),
     92     MARIO(/*model*/ MODEL_MARIO, /*bhvParam*/ BPARAM4(0x01), /*bhv*/ bhvMario),
     93     JUMP_LINK(script_func_global_1),
     94     JUMP_LINK(script_func_global_12),
     95     JUMP_LINK(script_func_global_15),
     96     LOAD_MODEL_FROM_GEO(MODEL_THI_BUBBLY_TREE,     bubbly_tree_geo),
     97     LOAD_MODEL_FROM_GEO(MODEL_LEVEL_GEOMETRY_03,   thi_geo_0005F0),
     98     LOAD_MODEL_FROM_GEO(MODEL_THI_WARP_PIPE,       warp_pipe_geo),
     99     LOAD_MODEL_FROM_GEO(MODEL_THI_HUGE_ISLAND_TOP, thi_geo_0005B0),
    100     LOAD_MODEL_FROM_GEO(MODEL_THI_TINY_ISLAND_TOP, thi_geo_0005C8),
    101 
    102     AREA(/*index*/ 1, thi_geo_000608),
    103         OBJECT(/*model*/ MODEL_NONE, /*pos*/ -7372, -1969,  7373, /*angle*/ 0, 149, 0, /*bhvParam*/ BPARAM2(WARP_NODE_0A), /*bhv*/ bhvSpinAirborneWarp),
    104         OBJECT(/*model*/ MODEL_NONE, /*pos*/   410,  -512,   922, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM2(WARP_NODE_0B), /*bhv*/ bhvInstantActiveWarp),
    105         OBJECT(/*model*/ MODEL_NONE, /*pos*/   410,  -512,   717, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM1(5)  | BPARAM2(WARP_NODE_0C), /*bhv*/ bhvWarp),
    106         OBJECT(/*model*/ MODEL_NONE, /*pos*/     0,  3170, -1570, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM1(10) | BPARAM2(WARP_NODE_0D), /*bhv*/ bhvWarp),
    107         WARP_NODE(/*id*/ WARP_NODE_0A,      /*destLevel*/ LEVEL_THI,    /*destArea*/ 1, /*destNode*/ WARP_NODE_0A, /*flags*/ WARP_NO_CHECKPOINT),
    108         WARP_NODE(/*id*/ WARP_NODE_0B,      /*destLevel*/ LEVEL_THI,    /*destArea*/ 1, /*destNode*/ WARP_NODE_0B, /*flags*/ WARP_NO_CHECKPOINT),
    109         WARP_NODE(/*id*/ WARP_NODE_0C,      /*destLevel*/ LEVEL_THI,    /*destArea*/ 3, /*destNode*/ WARP_NODE_0A, /*flags*/ WARP_NO_CHECKPOINT),
    110         WARP_NODE(/*id*/ WARP_NODE_0D,      /*destLevel*/ LEVEL_THI,    /*destArea*/ 3, /*destNode*/ WARP_NODE_0B, /*flags*/ WARP_NO_CHECKPOINT),
    111         WARP_NODE(/*id*/ WARP_NODE_SUCCESS, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 2, /*destNode*/ WARP_NODE_37, /*flags*/ WARP_NO_CHECKPOINT),
    112         WARP_NODE(/*id*/ WARP_NODE_DEATH,   /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 2, /*destNode*/ WARP_NODE_69, /*flags*/ WARP_NO_CHECKPOINT),
    113         JUMP_LINK(script_func_local_7),
    114         JUMP_LINK(script_func_local_1),
    115         JUMP_LINK(script_func_local_5),
    116         JUMP_LINK(script_func_local_4),
    117         TERRAIN(/*terrainData*/ thi_seg7_area_1_collision),
    118         MACRO_OBJECTS(/*objList*/ thi_seg7_area_1_macro_objs),
    119         SET_BACKGROUND_MUSIC(/*settingsPreset*/ 0x0000, /*seq*/ SEQ_LEVEL_GRASS),
    120         TERRAIN_TYPE(/*terrainType*/ TERRAIN_GRASS),
    121     END_AREA(),
    122 
    123     AREA(/*index*/ 2, thi_geo_0006D4),
    124         OBJECT(/*model*/ MODEL_NONE, /*pos*/ -2211,  110,  2212, /*angle*/ 0,  149, 0, /*bhvParam*/ BPARAM2(WARP_NODE_0A), /*bhv*/ bhvSpinAirborneWarp),
    125         OBJECT(/*model*/ MODEL_NONE, /*pos*/   280, -767, -4180, /*angle*/ 0,    0, 0, /*bhvParam*/ BPARAM2(WARP_NODE_0B), /*bhv*/ bhvFadingWarp),
    126         OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1638,    0, -1988, /*angle*/ 0, -126, 0, /*bhvParam*/ BPARAM2(WARP_NODE_0C), /*bhv*/ bhvFadingWarp),
    127         WARP_NODE(/*id*/ WARP_NODE_0A,      /*destLevel*/ LEVEL_THI,    /*destArea*/ 2, /*destNode*/ WARP_NODE_0A, /*flags*/ WARP_NO_CHECKPOINT),
    128         WARP_NODE(/*id*/ WARP_NODE_0B,      /*destLevel*/ LEVEL_THI,    /*destArea*/ 2, /*destNode*/ WARP_NODE_0C, /*flags*/ WARP_NO_CHECKPOINT),
    129         WARP_NODE(/*id*/ WARP_NODE_0C,      /*destLevel*/ LEVEL_THI,    /*destArea*/ 2, /*destNode*/ WARP_NODE_0B, /*flags*/ WARP_NO_CHECKPOINT),
    130         WARP_NODE(/*id*/ WARP_NODE_SUCCESS, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 2, /*destNode*/ WARP_NODE_33, /*flags*/ WARP_NO_CHECKPOINT),
    131         WARP_NODE(/*id*/ WARP_NODE_DEATH,   /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 2, /*destNode*/ WARP_NODE_65, /*flags*/ WARP_NO_CHECKPOINT),
    132         JUMP_LINK(script_func_local_8),
    133         JUMP_LINK(script_func_local_2),
    134         JUMP_LINK(script_func_local_6),
    135         TERRAIN(/*terrainData*/ thi_seg7_area_2_collision),
    136         MACRO_OBJECTS(/*objList*/ thi_seg7_area_2_macro_objs),
    137         SET_BACKGROUND_MUSIC(/*settingsPreset*/ 0x0000, /*seq*/ SEQ_LEVEL_GRASS),
    138         TERRAIN_TYPE(/*terrainType*/ TERRAIN_GRASS),
    139     END_AREA(),
    140 
    141     AREA(/*index*/ 3, thi_geo_00079C),
    142         OBJECT(/*model*/ MODEL_NONE, /*pos*/ 512, 1024, 2150, /*angle*/ 0, 180, 0, /*bhvParam*/ BPARAM2(WARP_NODE_0A), /*bhv*/ bhvInstantActiveWarp),
    143         OBJECT(/*model*/ MODEL_NONE, /*pos*/   0, 3277,    0, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM2(WARP_NODE_0B), /*bhv*/ bhvAirborneWarp),
    144         OBJECT(/*model*/ MODEL_NONE, /*pos*/ 512, 1024, 2355, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM1(5) | BPARAM2(WARP_NODE_0C), /*bhv*/ bhvWarp),
    145         WARP_NODE(/*id*/ WARP_NODE_0A,      /*destLevel*/ LEVEL_THI,    /*destArea*/ 3, /*destNode*/ WARP_NODE_0A, /*flags*/ WARP_NO_CHECKPOINT),
    146         WARP_NODE(/*id*/ WARP_NODE_0B,      /*destLevel*/ LEVEL_THI,    /*destArea*/ 3, /*destNode*/ WARP_NODE_0B, /*flags*/ WARP_NO_CHECKPOINT),
    147         WARP_NODE(/*id*/ WARP_NODE_0C,      /*destLevel*/ LEVEL_THI,    /*destArea*/ 1, /*destNode*/ WARP_NODE_0B, /*flags*/ WARP_NO_CHECKPOINT),
    148         WARP_NODE(/*id*/ WARP_NODE_SUCCESS, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 2, /*destNode*/ WARP_NODE_37, /*flags*/ WARP_NO_CHECKPOINT),
    149         WARP_NODE(/*id*/ WARP_NODE_DEATH,   /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 2, /*destNode*/ WARP_NODE_69, /*flags*/ WARP_NO_CHECKPOINT),
    150         JUMP_LINK(script_func_local_3),
    151         TERRAIN(/*terrainData*/ thi_seg7_area_3_collision),
    152         MACRO_OBJECTS(/*objList*/ thi_seg7_area_3_macro_objs),
    153         SET_BACKGROUND_MUSIC(/*settingsPreset*/ 0x0004, /*seq*/ SEQ_LEVEL_UNDERGROUND),
    154         TERRAIN_TYPE(/*terrainType*/ TERRAIN_GRASS),
    155     END_AREA(),
    156 
    157     FREE_LEVEL_POOL(),
    158     MARIO_POS(/*area*/ 1, /*yaw*/ 149, /*pos*/ -7372, -2969, 7373),
    159     CALL(/*arg*/ 0, /*func*/ lvl_init_or_update),
    160     CALL_LOOP(/*arg*/ 1, /*func*/ lvl_init_or_update),
    161     CLEAR_LEVEL(),
    162     SLEEP_BEFORE_EXIT(/*frames*/ 1),
    163     EXIT(),
    164 };