sm64

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

script.c (11045B)


      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/wdw/header.h"
     17 
     18 static const LevelScript script_func_local_1[] = {
     19     OBJECT(/*model*/ MODEL_WDW_SQUARE_FLOATING_PLATFORM,      /*pos*/  3390,    0,   384, /*angle*/ 0, 180, 0, /*bhvParam*/ 0, /*bhv*/ bhvWDWSquareFloatingPlatform),
     20     OBJECT(/*model*/ MODEL_WDW_SQUARE_FLOATING_PLATFORM,      /*pos*/  -767,  384,  3584, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvWDWSquareFloatingPlatform),
     21     OBJECT(/*model*/ MODEL_WDW_SQUARE_FLOATING_PLATFORM,      /*pos*/  -767,  384,  1536, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvWDWSquareFloatingPlatform),
     22     OBJECT(/*model*/ MODEL_WDW_SQUARE_FLOATING_PLATFORM,      /*pos*/  -767, 2304, -1279, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvWDWSquareFloatingPlatform),
     23     OBJECT(/*model*/ MODEL_WDW_ARROW_LIFT,                    /*pos*/  -578, 2177,  3009, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvArrowLift),
     24     OBJECT(/*model*/ MODEL_WDW_ARROW_LIFT,                    /*pos*/ -1474, 2177,  3393, /*angle*/ 0, 270, 0, /*bhvParam*/ 0, /*bhv*/ bhvArrowLift),
     25     OBJECT(/*model*/ MODEL_WDW_ARROW_LIFT,                    /*pos*/ -1602, 2177,  3009, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvArrowLift),
     26     OBJECT(/*model*/ MODEL_WDW_ARROW_LIFT,                    /*pos*/ -1090, 2177,  3521, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvArrowLift),
     27     OBJECT(/*model*/ MODEL_WDW_ARROW_LIFT,                    /*pos*/  -962, 2177,  3137, /*angle*/ 0,  90, 0, /*bhvParam*/ 0, /*bhv*/ bhvArrowLift),
     28     OBJECT(/*model*/ MODEL_NONE,                              /*pos*/     0,    0,     0, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvInitializeChangingWaterLevel),
     29     OBJECT(/*model*/ MODEL_WDW_WATER_LEVEL_DIAMOND,           /*pos*/  1920, 2560, -3583, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvWaterLevelDiamond),
     30     OBJECT(/*model*/ MODEL_WDW_WATER_LEVEL_DIAMOND,           /*pos*/  3328,  256,  2918, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvWaterLevelDiamond),
     31     OBJECT(/*model*/ MODEL_WDW_WATER_LEVEL_DIAMOND,           /*pos*/  2048, 1792,  2176, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvWaterLevelDiamond),
     32     OBJECT(/*model*/ MODEL_WDW_WATER_LEVEL_DIAMOND,           /*pos*/   640, 1024,  3712, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvWaterLevelDiamond),
     33     OBJECT(/*model*/ MODEL_WDW_WATER_LEVEL_DIAMOND,           /*pos*/  1810,   40, -3118, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvWaterLevelDiamond),
     34     OBJECT(/*model*/ MODEL_PURPLE_SWITCH,                     /*pos*/  3360, 1280,  3420, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFloorSwitchHiddenObjects),
     35     OBJECT(/*model*/ MODEL_WDW_HIDDEN_PLATFORM,               /*pos*/  2239, 1126,  3391, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM2(HIDDEN_OBJECT_BP_WDW_PLATFORM), /*bhv*/ bhvHiddenObject),
     36     OBJECT(/*model*/ MODEL_WDW_HIDDEN_PLATFORM,               /*pos*/  1215, 1357,  2751, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM2(HIDDEN_OBJECT_BP_WDW_PLATFORM), /*bhv*/ bhvHiddenObject),
     37     OBJECT(/*model*/ MODEL_WDW_HIDDEN_PLATFORM,               /*pos*/  1215, 1229,  3391, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM2(HIDDEN_OBJECT_BP_WDW_PLATFORM), /*bhv*/ bhvHiddenObject),
     38     OBJECT(/*model*/ MODEL_WDW_HIDDEN_PLATFORM,               /*pos*/  1599, 1101,  3391, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM2(HIDDEN_OBJECT_BP_WDW_PLATFORM), /*bhv*/ bhvHiddenObject),
     39     OBJECT(/*model*/ MODEL_WDW_HIDDEN_PLATFORM,               /*pos*/  2879, 1152,  3391, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM2(HIDDEN_OBJECT_BP_WDW_PLATFORM), /*bhv*/ bhvHiddenObject),
     40     OBJECT(/*model*/ MODEL_WDW_EXPRESS_ELEVATOR,              /*pos*/  1024, 3277, -2112, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM2(0x32), /*bhv*/ bhvWDWExpressElevatorPlatform),
     41     OBJECT(/*model*/ MODEL_WDW_EXPRESS_ELEVATOR,              /*pos*/  1024, 3277, -1663, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM2(0x32), /*bhv*/ bhvWDWExpressElevator),
     42     OBJECT(/*model*/ MODEL_WDW_RECTANGULAR_FLOATING_PLATFORM, /*pos*/  -767, 1152,   128, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvWDWRectangularFloatingPlatform),
     43     OBJECT(/*model*/ MODEL_WDW_RECTANGULAR_FLOATING_PLATFORM, /*pos*/  -767, 2304, -2687, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvWDWRectangularFloatingPlatform),
     44     OBJECT(/*model*/ MODEL_WDW_ROTATING_PLATFORM,             /*pos*/   734, 3840,    84, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM1(0x46) | BPARAM2(ROTATING_PLATFORM_BP_WDW), /*bhv*/ bhvRotatingPlatform),
     45     OBJECT(/*model*/ MODEL_SKEETER,                           /*pos*/  2956,  288,  -468, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvSkeeter),
     46     OBJECT(/*model*/ MODEL_SKEETER,                           /*pos*/   184,  384,   621, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvSkeeter),
     47     RETURN(),
     48 };
     49 
     50 static const LevelScript script_func_local_2[] = {
     51     OBJECT(/*model*/ MODEL_NONE,                    /*pos*/     0,     0,     0, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvInitializeChangingWaterLevel),
     52     OBJECT(/*model*/ MODEL_WDW_WATER_LEVEL_DIAMOND, /*pos*/ -3583, -2508, -2047, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvWaterLevelDiamond),
     53     OBJECT(/*model*/ MODEL_WDW_WATER_LEVEL_DIAMOND, /*pos*/  -767,  -127,  1792, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvWaterLevelDiamond),
     54     OBJECT(/*model*/ MODEL_NONE,                    /*pos*/  -768,  -665,  3584, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM2(92), /*bhv*/ bhvPoleGrabbing),
     55     RETURN(),
     56 };
     57 
     58 static const LevelScript script_func_local_3[] = {
     59     OBJECT_WITH_ACTS(/*model*/ MODEL_NONE, /*pos*/ 3360,  1580,  2660, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_3), /*bhv*/ bhvHiddenStar,          /*acts*/ ALL_ACTS),
     60     OBJECT_WITH_ACTS(/*model*/ MODEL_STAR, /*pos*/  890,  3400, -2040, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_4), /*bhv*/ bhvStar,                 /*acts*/ ALL_ACTS),
     61     RETURN(),
     62 };
     63 
     64 static const LevelScript script_func_local_4[] = {
     65     OBJECT_WITH_ACTS(/*model*/ MODEL_NONE, /*pos*/ -770, -1600,  3600, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_5), /*bhv*/ bhvHiddenRedCoinStar, /*acts*/ ALL_ACTS),
     66     OBJECT_WITH_ACTS(/*model*/ MODEL_STAR, /*pos*/ 2180,  -840,  3720, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_6), /*bhv*/ bhvStar,                 /*acts*/ ALL_ACTS),
     67     RETURN(),
     68 };
     69 
     70 const LevelScript level_wdw_entry[] = {
     71     INIT_LEVEL(),
     72     LOAD_MIO0        (/*seg*/ 0x07, _wdw_segment_7SegmentRomStart, _wdw_segment_7SegmentRomEnd),
     73     LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _grass_mio0SegmentRomStart, _grass_mio0SegmentRomEnd),
     74     LOAD_MIO0        (/*seg*/ 0x0A, _wdw_skybox_mio0SegmentRomStart, _wdw_skybox_mio0SegmentRomEnd),
     75     LOAD_MIO0        (/*seg*/ 0x05, _group1_mio0SegmentRomStart, _group1_mio0SegmentRomEnd),
     76     LOAD_RAW         (/*seg*/ 0x0C, _group1_geoSegmentRomStart,  _group1_geoSegmentRomEnd),
     77     LOAD_MIO0        (/*seg*/ 0x06, _group13_mio0SegmentRomStart, _group13_mio0SegmentRomEnd),
     78     LOAD_RAW         (/*seg*/ 0x0D, _group13_geoSegmentRomStart,  _group13_geoSegmentRomEnd),
     79     LOAD_MIO0        (/*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd),
     80     LOAD_RAW         (/*seg*/ 0x0F, _common0_geoSegmentRomStart,  _common0_geoSegmentRomEnd),
     81     ALLOC_LEVEL_POOL(),
     82     MARIO(/*model*/ MODEL_MARIO, /*bhvParam*/ BPARAM4(0x01), /*bhv*/ bhvMario),
     83     JUMP_LINK(script_func_global_1),
     84     JUMP_LINK(script_func_global_2),
     85     JUMP_LINK(script_func_global_14),
     86     LOAD_MODEL_FROM_GEO(MODEL_WDW_BUBBLY_TREE,                   bubbly_tree_geo),
     87     LOAD_MODEL_FROM_GEO(MODEL_WDW_SQUARE_FLOATING_PLATFORM,      wdw_geo_000580),
     88     LOAD_MODEL_FROM_GEO(MODEL_WDW_ARROW_LIFT,                    wdw_geo_000598),
     89     LOAD_MODEL_FROM_GEO(MODEL_WDW_WATER_LEVEL_DIAMOND,           wdw_geo_0005C0),
     90     LOAD_MODEL_FROM_GEO(MODEL_WDW_HIDDEN_PLATFORM,               wdw_geo_0005E8),
     91     LOAD_MODEL_FROM_GEO(MODEL_WDW_EXPRESS_ELEVATOR,              wdw_geo_000610),
     92     LOAD_MODEL_FROM_GEO(MODEL_WDW_RECTANGULAR_FLOATING_PLATFORM, wdw_geo_000628),
     93     LOAD_MODEL_FROM_GEO(MODEL_WDW_ROTATING_PLATFORM,             wdw_geo_000640),
     94 
     95     AREA(/*index*/ 1, wdw_geo_000658),
     96         OBJECT(/*model*/ MODEL_NONE, /*pos*/  3395, 3580,  384, /*angle*/ 0, 180, 0, /*bhvParam*/ BPARAM2(WARP_NODE_0A), /*bhv*/ bhvSpinAirborneWarp),
     97         OBJECT(/*model*/ MODEL_NONE, /*pos*/   818,    0, 3634, /*angle*/ 0,  45, 0, /*bhvParam*/ BPARAM2(WARP_NODE_0B), /*bhv*/ bhvFadingWarp),
     98         OBJECT(/*model*/ MODEL_NONE, /*pos*/ -2865, 3328, 3065, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM2(WARP_NODE_0C), /*bhv*/ bhvFadingWarp),
     99         WARP_NODE(/*id*/ WARP_NODE_0A, /*destLevel*/ LEVEL_WDW, /*destArea*/ 1, /*destNode*/ WARP_NODE_0A, /*flags*/ WARP_NO_CHECKPOINT),
    100         WARP_NODE(/*id*/ WARP_NODE_0B, /*destLevel*/ LEVEL_WDW, /*destArea*/ 1, /*destNode*/ WARP_NODE_0C, /*flags*/ WARP_NO_CHECKPOINT),
    101         WARP_NODE(/*id*/ WARP_NODE_0C, /*destLevel*/ LEVEL_WDW, /*destArea*/ 1, /*destNode*/ WARP_NODE_0B, /*flags*/ WARP_NO_CHECKPOINT),
    102         JUMP_LINK(script_func_local_3),
    103         JUMP_LINK(script_func_local_1),
    104         WARP_NODE(/*id*/ WARP_NODE_SUCCESS, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 2, /*destNode*/ WARP_NODE_32, /*flags*/ WARP_NO_CHECKPOINT),
    105         WARP_NODE(/*id*/ WARP_NODE_DEATH,   /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 2, /*destNode*/ WARP_NODE_64, /*flags*/ WARP_NO_CHECKPOINT),
    106         INSTANT_WARP(/*index*/ 1, /*destArea*/ 2, /*displace*/ 0, 0, 0),
    107         TERRAIN(/*terrainData*/ wdw_seg7_area_1_collision),
    108         MACRO_OBJECTS(/*objList*/ wdw_seg7_area_1_macro_objs),
    109         SET_BACKGROUND_MUSIC(/*settingsPreset*/ 0x0003, /*seq*/ SEQ_LEVEL_UNDERGROUND),
    110         TERRAIN_TYPE(/*terrainType*/ TERRAIN_STONE),
    111     END_AREA(),
    112 
    113     AREA(/*index*/ 2, wdw_geo_000724),
    114         JUMP_LINK(script_func_local_4),
    115         JUMP_LINK(script_func_local_2),
    116         WARP_NODE(/*id*/ WARP_NODE_SUCCESS, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 2, /*destNode*/ WARP_NODE_32, /*flags*/ WARP_NO_CHECKPOINT),
    117         WARP_NODE(/*id*/ WARP_NODE_DEATH,   /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 2, /*destNode*/ WARP_NODE_64, /*flags*/ WARP_NO_CHECKPOINT),
    118         INSTANT_WARP(/*index*/ 0, /*destArea*/ 1, /*displace*/ 0, 0, 0),
    119         TERRAIN(/*terrainData*/ wdw_seg7_area_2_collision),
    120         MACRO_OBJECTS(/*objList*/ wdw_seg7_area_2_macro_objs),
    121         SET_BACKGROUND_MUSIC(/*settingsPreset*/ 0x0003, /*seq*/ SEQ_LEVEL_UNDERGROUND),
    122         TERRAIN_TYPE(/*terrainType*/ TERRAIN_WATER),
    123     END_AREA(),
    124 
    125     FREE_LEVEL_POOL(),
    126     MARIO_POS(/*area*/ 1, /*yaw*/ 180, /*pos*/ 3395, 2580, 384),
    127     CALL(/*arg*/ 0, /*func*/ lvl_init_or_update),
    128     CALL_LOOP(/*arg*/ 1, /*func*/ lvl_init_or_update),
    129     CLEAR_LEVEL(),
    130     SLEEP_BEFORE_EXIT(/*frames*/ 1),
    131     EXIT(),
    132 };