sm64

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

script.c (11639B)


      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 "dialog_ids.h"
      7 #include "segment_symbols.h"
      8 #include "level_commands.h"
      9 
     10 #include "game/level_update.h"
     11 
     12 #include "levels/scripts.h"
     13 
     14 #include "actors/common1.h"
     15 
     16 #include "make_const_nonconst.h"
     17 #include "levels/bbh/header.h"
     18 
     19 
     20 static const LevelScript script_func_local_1[] = {
     21     OBJECT(/*model*/ MODEL_RED_FLAME,                  /*pos*/  2089,  1331, -1125, /*angle*/ 0, 270, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     22     OBJECT(/*model*/ MODEL_RED_FLAME,                  /*pos*/  1331,  1075, -1330, /*angle*/ 0, 90, 0,  /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     23     OBJECT(/*model*/ MODEL_RED_FLAME,                  /*pos*/  2089,  1331,  -511, /*angle*/ 0, 270, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     24     OBJECT(/*model*/ MODEL_RED_FLAME,                  /*pos*/  -511,   358, -1330, /*angle*/ 0, 90, 0,  /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     25     OBJECT(/*model*/ MODEL_RED_FLAME,                  /*pos*/  1126,   358,  2212, /*angle*/ 0, 0, 0,   /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     26     OBJECT(/*model*/ MODEL_RED_FLAME,                  /*pos*/   205,   358,  2212, /*angle*/ 0, 0, 0,   /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     27     RETURN(),
     28 };
     29 
     30 static const LevelScript script_func_local_2[] = {
     31     OBJECT(/*model*/ MODEL_BBH_TILTING_FLOOR_PLATFORM, /*pos*/  2866,   820,  1897, /*angle*/ 0, 0, 0,   /*bhvParam*/ 0, /*bhv*/ bhvBBHTiltingTrapPlatform),
     32     OBJECT(/*model*/ MODEL_BBH_TUMBLING_PLATFORM,      /*pos*/  2961,     0,  -768, /*angle*/ 0, 0, 0,   /*bhvParam*/ 0, /*bhv*/ bhvBBHTumblingBridge),
     33     OBJECT(/*model*/ MODEL_BBH_MOVING_BOOKSHELF,       /*pos*/ -1994,   819,   213, /*angle*/ 0, 0, 0,   /*bhvParam*/ 0, /*bhv*/ bhvHauntedBookshelf),
     34     OBJECT(/*model*/ MODEL_BBH_MESH_ELEVATOR,          /*pos*/ -2985,  -205,  5400, /*angle*/ 0, -45, 0, /*bhvParam*/ 0, /*bhv*/ bhvMeshElevator),
     35     OBJECT(/*model*/ MODEL_BBH_MERRY_GO_ROUND,         /*pos*/  -205, -2560,   205, /*angle*/ 0, 0, 0,   /*bhvParam*/ 0, /*bhv*/ bhvMerryGoRound),
     36     OBJECT(/*model*/ MODEL_NONE,                       /*pos*/  2200,   819,  -800, /*angle*/ 0, 0, 0,   /*bhvParam*/ 0, /*bhv*/ bhvCoffinSpawner),
     37     RETURN(),
     38 };
     39 
     40 static const LevelScript script_func_local_3[] = {
     41     OBJECT_WITH_ACTS(/*model*/ MODEL_BOO,                        /*pos*/  1000,    50,  1000, /*angle*/ 0, 0, 0,   /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_1) | BPARAM2(BIG_BOO_BP_GHOST_HUNT), /*bhv*/ bhvGhostHuntBigBoo,       /*acts*/ ACT_1),
     42     OBJECT_WITH_ACTS(/*model*/ MODEL_BOO,                        /*pos*/    20,   100,  -908, /*angle*/ 0, 0, 0,   /*bhvParam*/ BPARAM2(BOO_BP_GHOST_HUNT), /*bhv*/ bhvGhostHuntBoo,                 /*acts*/ ACT_1),
     43     OBJECT_WITH_ACTS(/*model*/ MODEL_BOO,                        /*pos*/  3150,   100,   398, /*angle*/ 0, 0, 0,   /*bhvParam*/ BPARAM2(BOO_BP_GHOST_HUNT), /*bhv*/ bhvGhostHuntBoo,                 /*acts*/ ACT_1),
     44     OBJECT_WITH_ACTS(/*model*/ MODEL_BOO,                        /*pos*/ -2000,   150,  -800, /*angle*/ 0, 0, 0,   /*bhvParam*/ BPARAM2(BOO_BP_GHOST_HUNT), /*bhv*/ bhvGhostHuntBoo,                 /*acts*/ ACT_1),
     45     OBJECT_WITH_ACTS(/*model*/ MODEL_BOO,                        /*pos*/  2851,   100,  2289, /*angle*/ 0, 0, 0,   /*bhvParam*/ BPARAM2(BOO_BP_GHOST_HUNT), /*bhv*/ bhvGhostHuntBoo,                 /*acts*/ ACT_1),
     46     OBJECT_WITH_ACTS(/*model*/ MODEL_BOO,                        /*pos*/ -1551,   100, -1018, /*angle*/ 0, 0, 0,   /*bhvParam*/ BPARAM2(BOO_BP_GHOST_HUNT), /*bhv*/ bhvGhostHuntBoo,                 /*acts*/ ACT_1),
     47     OBJECT_WITH_ACTS(/*model*/ MODEL_BBH_STAIRCASE_STEP,         /*pos*/   973,     0,   517, /*angle*/ 0, 0, 0,   /*bhvParam*/ 0, /*bhv*/ bhvHiddenStaircaseStep, /*acts*/ ACT_2 | ACT_3 | ACT_4 | ACT_5 | ACT_6),
     48     OBJECT_WITH_ACTS(/*model*/ MODEL_BBH_STAIRCASE_STEP,         /*pos*/   973,  -206,   717, /*angle*/ 0, 0, 0,   /*bhvParam*/ 0, /*bhv*/ bhvHiddenStaircaseStep, /*acts*/ ACT_2 | ACT_3 | ACT_4 | ACT_5 | ACT_6),
     49     OBJECT_WITH_ACTS(/*model*/ MODEL_BBH_STAIRCASE_STEP,         /*pos*/   973,  -412,   917, /*angle*/ 0, 0, 0,   /*bhvParam*/ 0, /*bhv*/ bhvHiddenStaircaseStep, /*acts*/ ACT_2 | ACT_3 | ACT_4 | ACT_5 | ACT_6),
     50     OBJECT_WITH_ACTS(/*model*/ MODEL_BOO,                        /*pos*/    20,   100,  -908, /*angle*/ 0, 0, 0,   /*bhvParam*/ 0, /*bhv*/ bhvBoo,                 /*acts*/ ACT_2 | ACT_3 | ACT_4 | ACT_5 | ACT_6),
     51     OBJECT_WITH_ACTS(/*model*/ MODEL_BOO,                        /*pos*/  3150,   100,   398, /*angle*/ 0, 0, 0,   /*bhvParam*/ 0, /*bhv*/ bhvBoo,                 /*acts*/ ACT_2 | ACT_3 | ACT_4 | ACT_5 | ACT_6),
     52     OBJECT_WITH_ACTS(/*model*/ MODEL_BOO,                        /*pos*/ -2000,   150,  -800, /*angle*/ 0, 0, 0,   /*bhvParam*/ 0, /*bhv*/ bhvBoo,                 /*acts*/ ACT_2 | ACT_3 | ACT_4 | ACT_5 | ACT_6),
     53     OBJECT_WITH_ACTS(/*model*/ MODEL_BOO,                        /*pos*/  2851,   100,  2289, /*angle*/ 0, 0, 0,   /*bhvParam*/ 0, /*bhv*/ bhvBoo,                 /*acts*/ ACT_2 | ACT_3 | ACT_4 | ACT_5 | ACT_6),
     54     OBJECT_WITH_ACTS(/*model*/ MODEL_BOO,                        /*pos*/ -1551,   100, -1018, /*angle*/ 0, 0, 0,   /*bhvParam*/ 0, /*bhv*/ bhvBoo,                 /*acts*/ ACT_2 | ACT_3 | ACT_4 | ACT_5 | ACT_6),
     55     OBJECT_WITH_ACTS(/*model*/ MODEL_NONE,                       /*pos*/   990, -2146,  -908, /*angle*/ 0, -45, 0, /*bhvParam*/ BPARAM2(0x03), /*bhv*/ bhvFlamethrower,          /*acts*/ ACT_2 | ACT_3 | ACT_4 | ACT_5 | ACT_6),
     56     OBJECT_WITH_ACTS(/*model*/ MODEL_NONE,                       /*pos*/ -1100, -2372,  1100, /*angle*/ 0, 135, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_2), /*bhv*/ bhvMerryGoRoundBooManager,         /*acts*/ ACT_2 | ACT_3 | ACT_4 | ACT_5 | ACT_6),
     57     OBJECT_WITH_ACTS(/*model*/ MODEL_BOO,                        /*pos*/  1030,  1922,  2546, /*angle*/ 0, -90, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_5), /*bhv*/ bhvBalconyBigBoo,        /*acts*/ ALL_ACTS),
     58     OBJECT_WITH_ACTS(/*model*/ MODEL_BOO,                        /*pos*/   581,  1850,  -206, /*angle*/ 0, -90, 0, /*bhvParam*/ 0, /*bhv*/ bhvBoo,                 /*acts*/ ALL_ACTS),
     59     OBJECT          (/*model*/ MODEL_MAD_PIANO,                  /*pos*/ -1300,     0,  2310, /*angle*/ 0, 243, 0, /*bhvParam*/ 0, /*bhv*/ bhvMadPiano),
     60     OBJECT          (/*model*/ MODEL_HAUNTED_CHAIR,              /*pos*/ -1530,     0,  2200, /*angle*/ 0, 66, 0,  /*bhvParam*/ 0, /*bhv*/ bhvHauntedChair),
     61     OBJECT          (/*model*/ MODEL_NONE,                       /*pos*/ -1330,   890,   200, /*angle*/ 0, 90, 0,  /*bhvParam*/ 0, /*bhv*/ bhvBookendSpawn),
     62     OBJECT          (/*model*/ MODEL_NONE,                       /*pos*/  -818,   890,  -200, /*angle*/ 0, 270, 0, /*bhvParam*/ 0, /*bhv*/ bhvBookendSpawn),
     63     OBJECT          (/*model*/ MODEL_NONE,                       /*pos*/ -1330,   890,  -622, /*angle*/ 0, 90, 0,  /*bhvParam*/ 0, /*bhv*/ bhvBookendSpawn),
     64     OBJECT          (/*model*/ MODEL_NONE,                       /*pos*/  -818,   890,  -686, /*angle*/ 0, 270, 0, /*bhvParam*/ 0, /*bhv*/ bhvBookendSpawn),
     65     OBJECT          (/*model*/ MODEL_NONE,                       /*pos*/ -1950,   880,     8, /*angle*/ 0, 180, 0, /*bhvParam*/ 0, /*bhv*/ bhvHauntedBookshelfManager),
     66     OBJECT          (/*model*/ MODEL_BOOKEND,                    /*pos*/  2680,  1045,   876, /*angle*/ 0, 166, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlyingBookend),
     67     OBJECT          (/*model*/ MODEL_BOOKEND,                    /*pos*/  3075,  1045,   995, /*angle*/ 0, 166, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlyingBookend),
     68     OBJECT          (/*model*/ MODEL_BOOKEND,                    /*pos*/ -1411,   218,   922, /*angle*/ 0, 180, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlyingBookend),
     69     RETURN(),
     70 };
     71 
     72 static const LevelScript script_func_local_4[] = {
     73     OBJECT_WITH_ACTS(/*model*/ MODEL_STAR, /*pos*/ -2030, 1350,  1940, /*angle*/ 0, 0, 0,  /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_3), /*bhv*/ bhvStar,                    /*acts*/ ALL_ACTS),
     74     OBJECT_WITH_ACTS(/*model*/ MODEL_NONE, /*pos*/  -204, 1100,  1576, /*angle*/ 0, 0, 0,  /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_4), /*bhv*/ bhvHiddenRedCoinStar,    /*acts*/ ALL_ACTS),
     75     OBJECT_WITH_ACTS(/*model*/ MODEL_NONE, /*pos*/   923, 1741,  -332, /*angle*/ 0, 18, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_6) | BPARAM2(0x01), /*bhv*/ bhvMrI,                    /*acts*/ ALL_ACTS),
     76     RETURN(),
     77 };
     78 
     79 const LevelScript level_bbh_entry[] = {
     80     INIT_LEVEL(),
     81     LOAD_MIO0        (/*seg*/ 0x07, _bbh_segment_7SegmentRomStart, _bbh_segment_7SegmentRomEnd),
     82     LOAD_MIO0        (/*seg*/ 0x0A, _bbh_skybox_mio0SegmentRomStart, _bbh_skybox_mio0SegmentRomEnd),
     83     LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _spooky_mio0SegmentRomStart, _spooky_mio0SegmentRomEnd),
     84     LOAD_MIO0        (/*seg*/ 0x05, _group9_mio0SegmentRomStart, _group9_mio0SegmentRomEnd),
     85     LOAD_RAW         (/*seg*/ 0x0C, _group9_geoSegmentRomStart,  _group9_geoSegmentRomEnd),
     86     LOAD_MIO0        (/*seg*/ 0x06, _group17_mio0SegmentRomStart, _group17_mio0SegmentRomEnd),
     87     LOAD_RAW         (/*seg*/ 0x0D, _group17_geoSegmentRomStart, _group17_geoSegmentRomEnd),
     88     LOAD_MIO0        (/*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd),
     89     LOAD_RAW         (/*seg*/ 0x0F, _common0_geoSegmentRomStart,  _common0_geoSegmentRomEnd),
     90     ALLOC_LEVEL_POOL(),
     91     MARIO(/*model*/ MODEL_MARIO, /*bhvParam*/ BPARAM4(0x01), /*bhv*/ bhvMario),
     92     JUMP_LINK(script_func_global_1),
     93     JUMP_LINK(script_func_global_10),
     94     JUMP_LINK(script_func_global_18),
     95     LOAD_MODEL_FROM_GEO(MODEL_BBH_HAUNTED_DOOR,           haunted_door_geo),
     96     LOAD_MODEL_FROM_GEO(MODEL_BBH_STAIRCASE_STEP,         geo_bbh_0005B0),
     97     LOAD_MODEL_FROM_GEO(MODEL_BBH_TILTING_FLOOR_PLATFORM, geo_bbh_0005C8),
     98     LOAD_MODEL_FROM_GEO(MODEL_BBH_TUMBLING_PLATFORM,      geo_bbh_0005E0),
     99     LOAD_MODEL_FROM_GEO(MODEL_BBH_TUMBLING_PLATFORM_PART, geo_bbh_0005F8),
    100     LOAD_MODEL_FROM_GEO(MODEL_BBH_MOVING_BOOKSHELF,       geo_bbh_000610),
    101     LOAD_MODEL_FROM_GEO(MODEL_BBH_MESH_ELEVATOR,          geo_bbh_000628),
    102     LOAD_MODEL_FROM_GEO(MODEL_BBH_MERRY_GO_ROUND,         geo_bbh_000640),
    103     LOAD_MODEL_FROM_GEO(MODEL_BBH_WOODEN_TOMB,            geo_bbh_000658),
    104 
    105     AREA(/*index*/ 1, geo_bbh_000F00),
    106         JUMP_LINK(script_func_local_1),
    107         JUMP_LINK(script_func_local_2),
    108         JUMP_LINK(script_func_local_3),
    109         JUMP_LINK(script_func_local_4),
    110         OBJECT(/*model*/ MODEL_NONE, /*pos*/ 666, 796, 5350, /*angle*/ 0, 180, 0, /*bhvParam*/ BPARAM2(WARP_NODE_0A), /*bhv*/ bhvSpinAirborneWarp),
    111         WARP_NODE(/*id*/ WARP_NODE_0A,      /*destLevel*/ LEVEL_BBH,              /*destArea*/ 1, /*destNode*/ WARP_NODE_0A, /*flags*/ WARP_NO_CHECKPOINT),
    112         WARP_NODE(/*id*/ WARP_NODE_SUCCESS, /*destLevel*/ LEVEL_CASTLE_COURTYARD, /*destArea*/ 1, /*destNode*/ WARP_NODE_0A, /*flags*/ WARP_NO_CHECKPOINT),
    113         WARP_NODE(/*id*/ WARP_NODE_DEATH,   /*destLevel*/ LEVEL_CASTLE_COURTYARD, /*destArea*/ 1, /*destNode*/ WARP_NODE_0B, /*flags*/ WARP_NO_CHECKPOINT),
    114         TERRAIN(/*terrainData*/ bbh_seg7_collision_level),
    115         MACRO_OBJECTS(/*objList*/ bbh_seg7_macro_objs),
    116         ROOMS(/*surfaceRooms*/ bbh_seg7_rooms),
    117         SHOW_DIALOG(/*index*/ 0x00, DIALOG_098),
    118         SET_BACKGROUND_MUSIC(/*settingsPreset*/ 0x0006, /*seq*/ SEQ_LEVEL_SPOOKY),
    119         TERRAIN_TYPE(/*terrainType*/ TERRAIN_SPOOKY),
    120     END_AREA(),
    121 
    122     FREE_LEVEL_POOL(),
    123     MARIO_POS(/*area*/ 1, /*yaw*/ 180, /*pos*/ 666, -204, 5350),
    124     CALL(/*arg*/ 0, /*func*/ lvl_init_or_update),
    125     CALL_LOOP(/*arg*/ 1, /*func*/ lvl_init_or_update),
    126     CLEAR_LEVEL(),
    127     SLEEP_BEFORE_EXIT(/*frames*/ 1),
    128     EXIT(),
    129 };