sm64

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

script.c (9229B)


      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/hmc/header.h"
     17 
     18 static const LevelScript script_func_local_1[] = {
     19     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 4936, -357, -4146, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     20     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 5018, -460, -5559, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     21     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 1997,  666,  -235, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     22     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 1762, -460, -2610, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     23     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 4178, -255, -3737, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     24     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 2233, -460,   256, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     25     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 5510, -255, -3429, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     26     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 4690, -357,  -767, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     27     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 3462, -255, -1125, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     28     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 1762,  666,     0, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     29     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 1762, -460,   256, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     30     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 6482,  461,  3226, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     31     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 1075,  461,  6543, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     32     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 6912,  461,  6543, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     33     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 6912,  461,  3697, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     34     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 6482,  461,  7014, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     35     OBJECT(/*model*/ MODEL_RED_FLAME, /*pos*/ 3817,  717,  1034, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvFlame),
     36     OBJECT(/*model*/ MODEL_NONE,      /*pos*/  799, 1024,  4434, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM2(184), /*bhv*/ bhvPoleGrabbing),
     37     OBJECT(/*model*/ MODEL_NONE,      /*pos*/  889, 1024,  3277, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM2(184), /*bhv*/ bhvPoleGrabbing),
     38     RETURN(),
     39 };
     40 
     41 static const LevelScript script_func_local_2[] = {
     42     OBJECT(/*model*/ MODEL_HMC_METAL_PLATFORM,    /*pos*/  1100,   950,  6350, /*angle*/ 0,   0, 0, /*bhvParam*/ 0, /*bhv*/ bhvControllablePlatform),
     43     OBJECT(/*model*/ MODEL_HMC_ELEVATOR_PLATFORM, /*pos*/ -3243,  1434,  1392, /*angle*/ 0,  27, 0, /*bhvParam*/ 0, /*bhv*/ bhvHMCElevatorPlatform),
     44     OBJECT(/*model*/ MODEL_HMC_ELEVATOR_PLATFORM, /*pos*/ -2816,  2253, -2509, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM2(0x01), /*bhv*/ bhvHMCElevatorPlatform),
     45     OBJECT(/*model*/ MODEL_HMC_ELEVATOR_PLATFORM, /*pos*/  -973,  1741, -7347, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM2(0x02), /*bhv*/ bhvHMCElevatorPlatform),
     46     OBJECT(/*model*/ MODEL_HMC_ELEVATOR_PLATFORM, /*pos*/ -3533,  1741, -7040, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM2(0x03), /*bhv*/ bhvHMCElevatorPlatform),
     47     OBJECT(/*model*/ MODEL_NONE,                  /*pos*/   614, -4690,  2330, /*angle*/ 0, 270, 0, /*bhvParam*/ BPARAM2(OPENABLE_GRILL_BP_HMC), /*bhv*/ bhvOpenableGrill),
     48     OBJECT(/*model*/ MODEL_PURPLE_SWITCH,         /*pos*/  -307, -4997,  2483, /*angle*/ 0, 270, 0, /*bhvParam*/ 0, /*bhv*/ bhvFloorSwitchGrills),
     49     OBJECT(/*model*/ MODEL_CHECKERBOARD_PLATFORM, /*pos*/  1270,  2000,  4000, /*angle*/ 0, 270, 0, /*bhvParam*/ BPARAM1(0x09) | BPARAM2(0xA4), /*bhv*/ bhvPlatformOnTrack),
     50     RETURN(),
     51 };
     52 
     53 static const LevelScript script_func_local_3[] = {
     54     OBJECT(/*model*/ MODEL_DORRIE, /*pos*/ -3533, -4969,  3558, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvDorrie),
     55     OBJECT(/*model*/ MODEL_NONE,   /*pos*/ -6093,  3075, -7807, /*angle*/ 0, 0, 0, /*bhvParam*/ 0, /*bhv*/ bhvBigBoulderGenerator),
     56     OBJECT(/*model*/ MODEL_NONE,   /*pos*/  -500,  1600,  3500, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM2(0x04), /*bhv*/ bhvFlamethrower),
     57     OBJECT(/*model*/ MODEL_NONE,   /*pos*/  -500,  1600,  3800, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM2(0x04), /*bhv*/ bhvFlamethrower),
     58     RETURN(),
     59 };
     60 
     61 static const LevelScript script_func_local_4[] = {
     62     OBJECT_WITH_ACTS(/*model*/ MODEL_STAR, /*pos*/ -3600, -4000,  3600, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_1), /*bhv*/ bhvStar,                 /*acts*/ ALL_ACTS),
     63     OBJECT_WITH_ACTS(/*model*/ MODEL_NONE, /*pos*/  4000,   300,  5000, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_2), /*bhv*/ bhvHiddenRedCoinStar, /*acts*/ ALL_ACTS),
     64     OBJECT_WITH_ACTS(/*model*/ MODEL_STAR, /*pos*/  6200, -4400,  2300, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_3), /*bhv*/ bhvStar,                 /*acts*/ ALL_ACTS),
     65     OBJECT_WITH_ACTS(/*model*/ MODEL_STAR, /*pos*/ -2100,  2100, -7550, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_4), /*bhv*/ bhvStar,                 /*acts*/ ALL_ACTS),
     66     OBJECT_WITH_ACTS(/*model*/ MODEL_STAR, /*pos*/ -6500,  2700, -1600, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_5), /*bhv*/ bhvStar,                 /*acts*/ ALL_ACTS),
     67     OBJECT_WITH_ACTS(/*model*/ MODEL_STAR, /*pos*/ -5000,  3050, -6700, /*angle*/ 0, 0, 0, /*bhvParam*/ BPARAM1(STAR_INDEX_ACT_6), /*bhv*/ bhvStar,                 /*acts*/ ALL_ACTS),
     68     RETURN(),
     69 };
     70 
     71 const LevelScript level_hmc_entry[] = {
     72     INIT_LEVEL(),
     73     LOAD_MIO0        (/*seg*/ 0x07, _hmc_segment_7SegmentRomStart, _hmc_segment_7SegmentRomEnd),
     74     LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _cave_mio0SegmentRomStart, _cave_mio0SegmentRomEnd),
     75     LOAD_MIO0        (/*seg*/ 0x05, _group6_mio0SegmentRomStart, _group6_mio0SegmentRomEnd),
     76     LOAD_RAW         (/*seg*/ 0x0C, _group6_geoSegmentRomStart, _group6_geoSegmentRomEnd),
     77     LOAD_MIO0        (/*seg*/ 0x06, _group17_mio0SegmentRomStart, _group17_mio0SegmentRomEnd),
     78     LOAD_RAW         (/*seg*/ 0x0D, _group17_geoSegmentRomStart, _group17_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_7),
     85     JUMP_LINK(script_func_global_18),
     86     LOAD_MODEL_FROM_GEO(MODEL_HMC_WOODEN_DOOR,          wooden_door_geo),
     87     LOAD_MODEL_FROM_GEO(MODEL_HMC_METAL_DOOR,           metal_door_geo),
     88     LOAD_MODEL_FROM_GEO(MODEL_HMC_HAZY_MAZE_DOOR,       hazy_maze_door_geo),
     89     LOAD_MODEL_FROM_GEO(MODEL_HMC_METAL_PLATFORM,       hmc_geo_0005A0),
     90     LOAD_MODEL_FROM_GEO(MODEL_HMC_METAL_ARROW_PLATFORM, hmc_geo_0005B8),
     91     LOAD_MODEL_FROM_GEO(MODEL_HMC_ELEVATOR_PLATFORM,    hmc_geo_0005D0),
     92     LOAD_MODEL_FROM_GEO(MODEL_HMC_ROLLING_ROCK,         hmc_geo_000548),
     93     LOAD_MODEL_FROM_GEO(MODEL_HMC_ROCK_PIECE,           hmc_geo_000570),
     94     LOAD_MODEL_FROM_GEO(MODEL_HMC_ROCK_SMALL_PIECE,     hmc_geo_000588),
     95     LOAD_MODEL_FROM_GEO(MODEL_HMC_RED_GRILLS,           hmc_geo_000530),
     96 
     97     AREA(/*index*/ 1, hmc_geo_000B90),
     98         OBJECT(/*model*/ MODEL_NONE, /*pos*/ -7152,  3161, 7181, /*angle*/ 0, 135, 0, /*bhvParam*/ BPARAM2(WARP_NODE_0A), /*bhv*/ bhvSpinAirborneWarp),
     99         OBJECT(/*model*/ MODEL_NONE, /*pos*/  3351, -4690, 4773, /*angle*/ 0,   0, 0, /*bhvParam*/ BPARAM1(52) | BPARAM2(WARP_NODE_0B), /*bhv*/ bhvWarp),
    100         WARP_NODE(/*id*/ WARP_NODE_0A,      /*destLevel*/ LEVEL_HMC,    /*destArea*/ 1, /*destNode*/ WARP_NODE_0A, /*flags*/ WARP_NO_CHECKPOINT),
    101         WARP_NODE(/*id*/ WARP_NODE_0B,      /*destLevel*/ LEVEL_COTMC,  /*destArea*/ 1, /*destNode*/ WARP_NODE_0A, /*flags*/ WARP_NO_CHECKPOINT),
    102         WARP_NODE(/*id*/ WARP_NODE_SUCCESS, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 3, /*destNode*/ WARP_NODE_34, /*flags*/ WARP_NO_CHECKPOINT),
    103         WARP_NODE(/*id*/ WARP_NODE_DEATH,   /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 3, /*destNode*/ WARP_NODE_66, /*flags*/ WARP_NO_CHECKPOINT),
    104         JUMP_LINK(script_func_local_1),
    105         JUMP_LINK(script_func_local_2),
    106         JUMP_LINK(script_func_local_3),
    107         JUMP_LINK(script_func_local_4),
    108         TERRAIN(/*terrainData*/ hmc_seg7_collision_level),
    109         MACRO_OBJECTS(/*objList*/ hmc_seg7_macro_objs),
    110         ROOMS(/*surfaceRooms*/ hmc_seg7_rooms),
    111         SET_BACKGROUND_MUSIC(/*settingsPreset*/ 0x0004, /*seq*/ SEQ_LEVEL_UNDERGROUND),
    112         TERRAIN_TYPE(/*terrainType*/ TERRAIN_STONE),
    113     END_AREA(),
    114 
    115     FREE_LEVEL_POOL(),
    116     MARIO_POS(/*area*/ 1, /*yaw*/ 135, /*pos*/ -7152, 2161, 7181),
    117     CALL(/*arg*/ 0, /*func*/ lvl_init_or_update),
    118     CALL_LOOP(/*arg*/ 1, /*func*/ lvl_init_or_update),
    119     CLEAR_LEVEL(),
    120     SLEEP_BEFORE_EXIT(/*frames*/ 1),
    121     EXIT(),
    122 };