diff --git a/decompressed.pal.yaml b/decompressed.pal.yaml index 8339909c..a0b5a0d0 100644 --- a/decompressed.pal.yaml +++ b/decompressed.pal.yaml @@ -2058,7 +2058,7 @@ segments: # # - [0x1081E30, c, ch/bearcub] #DONE # # - [0x1082430, c, sirslushgame] #DONE # # - [0x1082600, c, snowmanbuttongame] #DONE -# # - [0x10827A0, c, racectrl] #DONE +# # - [0x10827A0, c, ma/slalom] #DONE # # - [0x1083CF0, c, ch/twinkly] # # - [0x1084B10, c, ch/twinklybox] #DONE # # - [0x10859B0, c, ch/twinklymuncher] #DONE @@ -2085,7 +2085,7 @@ segments: # # - [0x1089A30, .data, ch/bearcub] # # - [0x1089AF0, .data, sirslushgame] # # - [0x1089B00, .data, snowmanbuttongame] -# # - [0x1089B10, .data, racectrl] +# # - [0x1089B10, .data, ma/slalom] # # - [0x1089B90, .data, ch/twinkly] # # - [0x1089D00, .data, ch/twinklybox] # # - [0x1089FD0, .data, ch/twinklymuncher] @@ -2107,7 +2107,7 @@ segments: # # - [0x108A860, .rodata, code_1FF0] # # - [0x108A870, .rodata, ch/boggy2] # # - [0x108A950, .rodata, ch/bearcub] -# # - [0x108A970, .rodata, racectrl] +# # - [0x108A970, .rodata, ma/slalom] # # - [0x108A9C0, .rodata, ch/twinkly] # # - [0x108AA40, .rodata, ch/twinklybox] # # - [0x108AA80, .rodata, ch/twinklymuncher] @@ -2120,7 +2120,7 @@ segments: # # - [0x108AB50, .bss, ch/boggy2] # # - [0x108AB50, .bss, sirslushgame] # # - [0x108AB50, .bss, snowmanbuttongame] -# # - [0x108AB50, .bss, racectrl] +# # - [0x108AB50, .bss, ma/slalom] # # - [0x108AB50, .bss, ch/xmastreestar] # # - [0x108AB50, .bss, code_B4D0] # - name: SM diff --git a/decompressed.us.v10.yaml b/decompressed.us.v10.yaml index 9895a65f..20a43874 100644 --- a/decompressed.us.v10.yaml +++ b/decompressed.us.v10.yaml @@ -2056,7 +2056,7 @@ segments: - [0x1081E30, c, ch/bearcub] #DONE - [0x1082430, c, sirslushgame] #DONE - [0x1082600, c, snowmanbuttongame] #DONE - - [0x10827A0, c, racectrl] #DONE + - [0x10827A0, c, ma/slalom] #DONE - [0x1083CF0, c, ch/twinkly] - [0x1084B10, c, ch/twinklybox] #DONE - [0x10859B0, c, ch/twinklymuncher] #DONE @@ -2083,7 +2083,7 @@ segments: - [0x1089A30, .data, ch/bearcub] - [0x1089AF0, .data, sirslushgame] - [0x1089B00, .data, snowmanbuttongame] - - [0x1089B10, .data, racectrl] + - [0x1089B10, .data, ma/slalom] - [0x1089B90, .data, ch/twinkly] - [0x1089D00, .data, ch/twinklybox] - [0x1089FD0, .data, ch/twinklymuncher] @@ -2105,7 +2105,7 @@ segments: - [0x108A860, .rodata, code_1FF0] - [0x108A870, .rodata, ch/boggy2] - [0x108A950, .rodata, ch/bearcub] - - [0x108A970, .rodata, racectrl] + - [0x108A970, .rodata, ma/slalom] - [0x108A9C0, .rodata, ch/twinkly] - [0x108AA40, .rodata, ch/twinklybox] - [0x108AA80, .rodata, ch/twinklymuncher] @@ -2118,7 +2118,7 @@ segments: - [0x108AB50, .bss, ch/boggy2] - [0x108AB50, .bss, sirslushgame] - [0x108AB50, .bss, snowmanbuttongame] - - [0x108AB50, .bss, racectrl] + - [0x108AB50, .bss, ma/slalom] - [0x108AB50, .bss, ch/xmastreestar] - [0x108AB50, .bss, code_B4D0] - name: SM diff --git a/src/FP/ch/boggy2.c b/src/FP/ch/boggy2.c index 78d140bd..bb4bae3a 100644 --- a/src/FP/ch/boggy2.c +++ b/src/FP/ch/boggy2.c @@ -5,7 +5,7 @@ extern void func_8028E668(f32[3], f32, f32, f32); extern Actor *func_80328230(enum actor_e id, f32 pos[3], f32 rot[3]); extern NodeProp *cubeList_findNodePropByActorIdAndPosition_s32(enum actor_e, s32[3]); -extern f32 func_8038BE20(f32 arg0[3]); +extern f32 maSlalom_compareBoggyToPlayer(f32 arg0[3]); typedef struct { ParticleEmitter *unk0; @@ -110,7 +110,7 @@ void FP_func_803888E4(Actor *this){ } }//L80388A30 mapSpecificFlags_set(5, TRUE); - func_8038B9C8(); + maSlalom_start(); } void func_80388A50(Actor *this){ @@ -343,7 +343,7 @@ void func_803893E4(Actor *this, f32 arg1, u8 arg2){ this->unk4C += ((f32)D_80392F20[1] - this->position_y)*0.02; } else{ - this->unk4C += ((f32)D_80392F20[1] - this->position_y)*0.03 + sp28*func_8038BE20(this->position); + this->unk4C += ((f32)D_80392F20[1] - this->position_y)*0.03 + sp28*maSlalom_compareBoggyToPlayer(this->position); } if(this->unk4C < sp30){ @@ -401,7 +401,7 @@ void func_803896FC(Actor *this){ f32 sp54; s32 sp3C[6]; - sp58 = func_8038BE20(this->position); + sp58 = maSlalom_compareBoggyToPlayer(this->position); sp54 = time_getDelta(); controller_copyFaceButtons(0, sp3C); @@ -421,7 +421,7 @@ void func_803896FC(Actor *this){ local->unkC = 0.0f; local->unk10 = 0.0f; local->unk8 = 1.0f; - func_8038B9B0(this->marker); + maSlalom_linkBoggy(this->marker); this->unk38_31 = 0; func_80388C88(this); __spawnQueue_add_0(func_803895E0); @@ -583,12 +583,12 @@ void func_803896FC(Actor *this){ if(this->unk38_31 == 2){ if(jiggyscore_isCollected(JIGGY_30_FP_BOGGY_2)){ __spawnQueue_add_1((GenFunction_1)func_80388F54, reinterpret_cast(s32, this->marker)); - func_8038B9BC(); + maSlalom_unlinkBoggy(); marker_despawn(this->marker); } } else{ - func_8038B9BC(); + maSlalom_unlinkBoggy(); marker_despawn(this->marker); } @@ -597,13 +597,13 @@ void func_803896FC(Actor *this){ case 2: //L80389FDC if(this->unk38_31 == 2){ if(jiggyscore_isCollected(JIGGY_2C_FP_BOGGY_3)){ - func_8038B9BC(); + maSlalom_unlinkBoggy(); marker_despawn(this->marker); mapSpecificFlags_set(0xC, TRUE); } } else{ - func_8038B9BC(); + maSlalom_unlinkBoggy(); marker_despawn(this->marker); } break; diff --git a/src/FP/ch/twinklybox.c b/src/FP/ch/twinklybox.c index 3ce1b78e..cb577b7e 100644 --- a/src/FP/ch/twinklybox.c +++ b/src/FP/ch/twinklybox.c @@ -26,7 +26,7 @@ ActorInfo D_803920E8 = { 0x204, 0x336, 0x442, /* .code */ Actor *FP_func_8038CED0(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ Actor *this = marker_getActor(marker); - if( func_8038BFA0() || fileProgressFlag_get(FILEPROG_13_COMPLETED_TWINKLIES_MINIGAME) ){ + if( maSlalom_isActive() || fileProgressFlag_get(FILEPROG_13_COMPLETED_TWINKLIES_MINIGAME) ){ if(0.0f == this->velocity[1]) return this; } @@ -281,7 +281,7 @@ void func_8038D6C8(Actor *this){ sp24 = time_getDelta(); mapSpecificFlags_set(0xd, BOOL(this->state != 1 && this->state != 2)); - if(func_8038BFA0() || fileProgressFlag_get(FILEPROG_13_COMPLETED_TWINKLIES_MINIGAME)){ + if(maSlalom_isActive() || fileProgressFlag_get(FILEPROG_13_COMPLETED_TWINKLIES_MINIGAME)){ this->marker->propPtr->unk8_3 = FALSE; actor_collisionOff(this); func_8028F8F8(7, FALSE); diff --git a/src/FP/ch/wozza.c b/src/FP/ch/wozza.c index 97e7e615..03699977 100644 --- a/src/FP/ch/wozza.c +++ b/src/FP/ch/wozza.c @@ -41,7 +41,7 @@ f32 D_803925AC[3] = {-4026.0f, 800.0f, -4097.0f}; /* .code */ Actor *func_8038F210(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ Actor *this = marker_getActor(marker); - if(func_8038BFA0() || this->unk38_31) + if(maSlalom_isActive() || this->unk38_31) return this; return actor_draw(marker, gfx, mtx, vtx); @@ -209,7 +209,7 @@ void FP_func_8038F7AC(Actor *this){ } }//L8038F910 - if(func_8038BFA0() || this->unk38_31 || !subaddie_playerIsWithinSphere(this, 3000)){ + if(maSlalom_isActive() || this->unk38_31 || !subaddie_playerIsWithinSphere(this, 3000)){ actor_collisionOff(this); return; } diff --git a/src/FP/ch/wozzasjig.c b/src/FP/ch/wozzasjig.c index c9b8a980..9a8ca293 100644 --- a/src/FP/ch/wozzasjig.c +++ b/src/FP/ch/wozzasjig.c @@ -31,7 +31,7 @@ ActorInfo D_80392628 = { MARKER_20C_WOZZAS_JIGGY, ACTOR_1F4_WOZZAS_JIGGY, ASSET_ /* .code */ Actor *func_8038FF00(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ Actor *this = marker_getActor(marker); - if(func_8038BFA0()) return this; + if(maSlalom_isActive()) return this; return actor_draw(marker, gfx, mtx, vtx); } @@ -42,7 +42,7 @@ void func_8038FF54(Actor *this){ f32 sp40[3]; ParticleEmitter *sp3C; - if( func_8038BFA0() ) return; + if( maSlalom_isActive() ) return; if( !subaddie_playerIsWithinSphere(this, 4500) ) return; this->marker->propPtr->unk8_3 = FALSE; diff --git a/src/FP/ch/xmastree.c b/src/FP/ch/xmastree.c index 269901d9..99f93506 100644 --- a/src/FP/ch/xmastree.c +++ b/src/FP/ch/xmastree.c @@ -176,7 +176,7 @@ void chXmasTree_update(Actor *this){ subaddie_set_state(this, 5); mapSpecificFlags_set(2, FALSE); this->lifetime_value = 0.1f; - if(!func_8038BFA0()){ + if(!maSlalom_isActive()){ if(!mapSpecificFlags_get(9) || mapSpecificFlags_get(1)){ func_8025A6EC(COMUSIC_3C_MINIGAME_LOSS, 28000); func_802BAFE4(0x1a); diff --git a/src/FP/code_19E0.c b/src/FP/code_19E0.c index a5662531..09cedd84 100644 --- a/src/FP/code_19E0.c +++ b/src/FP/code_19E0.c @@ -115,7 +115,7 @@ void func_803881AC(Actor *this){ this->unk124_6 = FALSE; func_803289EC(this, randf(), 1); if(this->unk38_31 == 0){ - func_8038B8B0(this->marker); + maSlalom_linkActiveFlag(this->marker); this->velocity_x = 0.0f; } this->initialized = FALSE; @@ -127,7 +127,7 @@ void func_803881AC(Actor *this){ if(0.0f == this->velocity_x) return; }else{ - if(!func_80329530(this, 2000) && !func_8038BFE8(this->position, 2000)) + if(!func_80329530(this, 2000) && !maSlolam_WithinRadiusOfBoggy(this->position, 2000)) return; this->marker->collidable = TRUE; this->unk124_6 = TRUE; @@ -143,10 +143,10 @@ void func_803881AC(Actor *this){ if( 1.0f == this->velocity_x && func_80387EE4(this)){ func_8025A6EC(COMUSIC_2B_DING_B, 28000); - FP_func_8038BA88(this->unkF4_8); + maSlalom_setPlayerGate(this->unkF4_8); } if(func_80388000(this)){ - func_8038BC0C(this->unkF4_8); + maSlalom_setBoggyGate(this->unkF4_8); } } diff --git a/src/FP/code_1FF0.c b/src/FP/code_1FF0.c index f60699ee..8d5b95ae 100644 --- a/src/FP/code_1FF0.c +++ b/src/FP/code_1FF0.c @@ -55,7 +55,7 @@ void func_80388584(Actor *this){ func_803289EC(this, randf(), 1); this->unk124_6 = 0; if(this->unk38_31 == 0){ - func_8038B930(this->marker); + maSlalom_linkDummyFlag(this->marker); this->velocity[0] = 0.0f; } }//L8038863C @@ -70,7 +70,7 @@ void func_80388584(Actor *this){ } } else{//L80388694 - if(!func_80329530(this, 2000)&& !func_8038BFE8(this->position, 2000)) + if(!func_80329530(this, 2000)&& !maSlolam_WithinRadiusOfBoggy(this->position, 2000)) return; this->marker->collidable = TRUE; this->unk124_6 = TRUE; diff --git a/src/FP/ma/slalom.c b/src/FP/ma/slalom.c new file mode 100644 index 00000000..ee3e17fa --- /dev/null +++ b/src/FP/ma/slalom.c @@ -0,0 +1,636 @@ +#include +#include "functions.h" +#include "variables.h" + + +#include "core2/statetimer.h" +extern void player_stateTimer_set(s32, f32); + +#define NUM_BRIDGES 5 +#define NUM_GATES 39 + +typedef struct { + ActorMarker *marker; + f32 position[3]; + f32 distGatesSq; +}MaSlalomGate; + +typedef enum { + MA_SLALOM_STATE_0_NONE, + MA_SLALOM_STATE_1_STARTING, + MA_SLALOM_STATE_2_RACING, + MA_SLALOM_STATE_3_WIN, + MA_SLALOM_STATE_4_LOSE +} MaSlalomState; + +/* .data */ +f32 D_80391ED0[3] = {-880.0f, 3.0f, 1769.0f}; +f32 D_80391EDC = 180.0f; + +f32 D_80391EE0[3] = {5187.0f, 428.0f, 854.0f}; +f32 D_80391EEC = 194.0f; + +f32 D_80391EF0[3] = {-904.0f, -10.0f, -1662.0f}; +f32 FP_D_80391EFC = 180.0f; + +f32 D_80391F00[3] = {2192.0f, 7.0f, 2901.0f}; +f32 D_80391F0C = 85.0f; + +f32 D_80391F10[3] = {712.0f, 7.0f, 3036.0f}; +f32 D_80391F1C = 284.0f; + +f32 D_80391F20[3] = {1605.0f, 658.0f, 5402.0f}; +f32 D_80391F2C[3] = {-4454.0f, 1920.0f, -6898.0f}; +f32 D_80391F38[3] = {-4451.0f, 1920.0f, -6685.0f}; + +/* .bss */ +MaSlalomGate meActiveFlags[NUM_GATES]; +MaSlalomGate meDummyFlags[NUM_GATES]; +ActorMarker *meBridgeLinks[NUM_BRIDGES]; +struct { + u8 state; + s32 flagCount; + s32 playerGate; + s32 boggyGate; + s32 boggyHasFinished; + ActorMarker *boggyLink; + u8 hasBeenTwoBehind; + u8 hasBeenThreeBehind; + u8 hasBeenFourBehind; +}Me; + + +/* .code */ +void FP_func_8038AB60(s32 arg0){ + int i; + + func_8028F8F8(0xe, arg0 ^ 1); + + for (i = 0x14; i < 0x23; i++){ + func_8028F8F8(i, arg0); + } + + for (i = 0x32; i < 0x38; i++){ + func_8028F8F8(i, arg0); + } +} + +void func_8038ABDC(void){ + comusic_8025AB44(COMUSIC_3A_FP_BOGGY_RACE, 0, 4000); + func_8025AABC(COMUSIC_3A_FP_BOGGY_RACE); + func_8025A58C(-1, 4000); + core1_ce60_incOrDecCounter(TRUE); +} + +void func_8038AC20(s32 gate_indx, s32 arg1){ + Actor *a1; + Actor *a2; + + a1 = marker_getActor(meActiveFlags[gate_indx].marker); + a2 = marker_getActor(meDummyFlags[gate_indx].marker); + + a1->velocity[0] = (f32)arg1; + a2->velocity[0] = (f32)arg1; +} + +void __maSlalom_spawnGate(s32 indx, s32 arg1){ + ActorMarker *m1; + ActorMarker *m2; + Actor *a1; + Actor *a2; + + m1 = actor_spawnWithYaw_f32(0x161, meActiveFlags[indx].position, 0)->marker; + m2 = actor_spawnWithYaw_f32(0x162, meDummyFlags[indx].position, 0)->marker; + a1 = marker_getActor(m1); + a2 = marker_getActor(m2); + + a1->unk38_31 = 1; + a2->unk38_31 = 1; + + a1->unkF4_8 = indx + 1; + a2->unkF4_8 = indx + 1; + + meActiveFlags[indx].marker = a1->marker; + meDummyFlags[indx].marker = a2->marker; + + func_8038AC20(indx, arg1); + + a1->unk1C[0] = a2->position_x; + a1->unk1C[1] = a2->position_y; + a1->unk1C[2] = a2->position_z; + + if(indx + 1 == NUM_GATES){ + a1->velocity[1] = 1.0f; + a2->velocity[1] = 1.0f; + } +} + +void maSlalom_spawnGate(s32 indx, s32 arg1){ + __spawnQueue_add_2((GenFunction_2)__maSlalom_spawnGate, indx, arg1); +} + +void __maSlalom_despawnGate(s32 indx){ + if(meActiveFlags[indx].marker){ + func_80326310(marker_getActor(meActiveFlags[indx].marker)); + meActiveFlags[indx].marker = NULL; + } + + if(meDummyFlags[indx].marker){ + func_80326310(marker_getActor(meDummyFlags[indx].marker)); + meDummyFlags[indx].marker = NULL; + } +} + +void __maSlalom_despawnAllGates(void){ + int i; + for(i = 0; i < NUM_GATES; i++){ + __maSlalom_despawnGate(i); + } +} + +void __maSlalom_spawnBridge(s32 indx){ + Actor *sp1C; + switch(indx){ + case 0:// L8038AF0C + sp1C = actor_spawnWithYaw_f32(0x22d, D_80391ED0, D_80391EDC); + break; + + case 1:// L8038AF38 + sp1C = actor_spawnWithYaw_f32(0x22e, D_80391EE0, D_80391EEC); + break; + + case 2:// L8038AF64 + sp1C = actor_spawnWithYaw_f32(0x22d, D_80391EF0, FP_D_80391EFC); + break; + + case 3:// L8038AF90 + sp1C = actor_spawnWithYaw_f32(0x22d, D_80391F00, D_80391F0C); + break; + + case 4:// L8038AFBC + sp1C = actor_spawnWithYaw_f32(0x22d, D_80391F10, D_80391F1C); + break; + } + meBridgeLinks[indx] = sp1C->marker; +} + +void maSlalom_spawnBridge(s32 indx){ + __spawnQueue_add_1((GenFunction_1)__maSlalom_spawnBridge, indx); +} + +void maSlalom_spawnAllBridges(void){ + int i; + for(i = 0; i < NUM_BRIDGES; i++){ + maSlalom_spawnBridge(i); + } +} + +void __maSlalom_despawnBridge(s32 indx){ + if(meBridgeLinks[indx]){ + marker_despawn(meBridgeLinks[indx]); + meBridgeLinks[indx] = NULL; + } +} + +void __maSlalom_despawnAllBridges(void){ + int i; + for(i = 0; i < NUM_BRIDGES; i++){ + __maSlalom_despawnBridge(i); + } +} + +void __maSlalom_spawnTrainers(void){ + Actor *trainers = actor_spawnWithYaw_f32(ACTOR_2C_TURBO_TALON_TRAINERS, D_80391F20, 100); + trainers->unk10_1 = FALSE; +} + +void __maSlalom_spawnJiggy(enum jiggy_e jiggy_id){ + if(jiggy_id == JIGGY_2C_FP_BOGGY_3 && !jiggyscore_isCollected(JIGGY_30_FP_BOGGY_2)){ + jiggy_spawn(jiggy_id, D_80391F38); + } + else{ + jiggy_spawn(jiggy_id, D_80391F2C); + } +} + +void __maSlalom_8038B190(void){ + func_8028F66C(BS_INTR_2B); + mapSpecificFlags_set(4, FALSE); + func_8028F918(0); +} + +void __maSlalom_clearState(void){ + Me.state = MA_SLALOM_STATE_0_NONE; +} + +void __maSlalom_winDialogCallback(enum jiggy_e jiggy_id){ + timed_setStaticCameraToNode(0.0f, 3); + timedFunc_set_0(0.0f, __maSlalom_despawnAllGates); + timedFunc_set_0(0.0f, __maSlalom_despawnAllBridges); + timedFunc_set_1(0.1f, (GenFunction_1) __maSlalom_spawnJiggy, jiggy_id); + timedFunc_set_0(5.0f, __maSlalom_8038B190); + timedFunc_set_0(5.0f, __maSlalom_clearState); + timed_exitStaticCamera(5.0f); + +} + +void __maSlalom_loseDialogCallback(void){ + timed_exitStaticCamera(0.0f); + timedFunc_set_0(0.0f, __maSlalom_despawnAllGates); + timedFunc_set_0(0.0f, __maSlalom_despawnAllBridges); + func_8028FA14(map_get(), 0x11); + func_8028F66C(BS_INTR_2A); +} + +void maSlalom_dialogCallback(ActorMarker *caller, enum asset_e text_id, s32 arg2){ + Actor *pntBoggy; + if(Me.boggyLink){ + pntBoggy = marker_getActor(Me.boggyLink); + } + + switch(text_id){ + case 0xc04: //8038B318 + __maSlalom_loseDialogCallback(); + break; + + case 0xc07: //8038B328 + __maSlalom_winDialogCallback(JIGGY_30_FP_BOGGY_2); + break; + + case 0xc0b: //8038B338 + __maSlalom_loseDialogCallback(); + break; + + case 0xc0d: //8038B348 + __maSlalom_winDialogCallback(JIGGY_2C_FP_BOGGY_3); + break; + + case 0xc10: //8038B358 + func_8038ABDC(); + func_8028FA14(map_get(), 0x11); + func_8028F66C(BS_INTR_2A); + timedFunc_set_0(0.0f, __maSlalom_clearState); + break; + }//L8038B38C +} + +void maSlalom_win(void){ + if(jiggyscore_isCollected(JIGGY_30_FP_BOGGY_2) && func_8028ECAC() == BSGROUP_6_TURBO_TALON_TRAINERS){ + player_stateTimer_set(STATE_TIMER_3_TURBO_TALON, 2.0f); + } + func_8028F918(1); + func_8025A6EC(COMUSIC_3B_MINIGAME_VICTORY, 28000); + FP_func_8038AB60(0); + func_8038ABDC(); + timed_setStaticCameraToNode(0.0f, 1); +} + +void maSlalom_lose(void){ + Actor *pntBoggy; + + func_8028F918(2); + if(Me.boggyLink) + pntBoggy = marker_getActor(Me.boggyLink); + + pntBoggy->unk38_31 = 1; + func_8025A6EC(COMUSIC_3C_MINIGAME_LOSS, 28000); + FP_func_8038AB60(0); + func_8038ABDC(); + if(!jiggyscore_isCollected(JIGGY_30_FP_BOGGY_2)){ + timed_setStaticCameraToNode(0.0f, 1); + timed_playSfx(1.0f, SFX_8C_BOGGY_WAHEY, 1.0f, 32000); + func_80324DBC(2.0f, 0xC04, 0x2b, pntBoggy->position, NULL, maSlalom_dialogCallback, NULL); + }//L8038B4E0 + else{ + timed_setStaticCameraToNode(0.0f, 1); + timed_playSfx(1.0f, SFX_8C_BOGGY_WAHEY, 1.0f, 32000); + func_80324DBC(2.0f, 0xC0b, 0x2b, pntBoggy->position, NULL, maSlalom_dialogCallback, NULL); + + } +} + +void maSlalom_update(void){ + Actor *pntBoggy; + int i; + f32 f2; + f32 f0; + + switch(Me.state){ + case MA_SLALOM_STATE_1_STARTING: //L8038B57C + if(Me.flagCount < 2*NUM_GATES) break; + + for(i = 0; i < NUM_GATES; i++){ + if(i < (NUM_GATES - 1)){ + f0 = meActiveFlags[i+1].position[2] - meActiveFlags[i].position[2]; + f2 = meActiveFlags[i+1].position[0] - meActiveFlags[i].position[0]; + meActiveFlags[i].distGatesSq = f0*f0 + f2*f2; + } + if(meActiveFlags[NUM_GATES - 1].distGatesSq < meActiveFlags[i].distGatesSq) + meActiveFlags[NUM_GATES - 1].distGatesSq = meActiveFlags[i].distGatesSq; + } + __maSlalom_despawnAllGates(); + Me.state = MA_SLALOM_STATE_0_NONE; + break; + + case MA_SLALOM_STATE_2_RACING: //L8038B61C + if(jiggyscore_isCollected(JIGGY_30_FP_BOGGY_2) && func_8028ECAC() == BSGROUP_6_TURBO_TALON_TRAINERS){ + player_stateTimer_set(STATE_TIMER_3_TURBO_TALON, 20.0f); + } + + if(meActiveFlags[NUM_GATES - 1].marker == NULL) break; + + if(3.0f == marker_getActor(meActiveFlags[NUM_GATES - 1].marker)->velocity[0]){ + maSlalom_win(); + Me.state = MA_SLALOM_STATE_3_WIN; + break; + } + + if(Me.boggyHasFinished){ + maSlalom_lose(); + Me.state = MA_SLALOM_STATE_4_LOSE; + } + break; + + case MA_SLALOM_STATE_3_WIN: //L8038B6C4 + if(Me.boggyLink){ + pntBoggy = marker_getActor(Me.boggyLink); + } + pntBoggy->unk38_31 = 2; + timed_playSfx(1.0f, SFX_8D_BOGGY_OHWW, 1.0f, 32000); + if(jiggyscore_isCollected(JIGGY_30_FP_BOGGY_2) || jiggyscore_isSpawned(JIGGY_30_FP_BOGGY_2)){ + func_80324DBC(2.0f, 0xc0d, 0x2a, pntBoggy->position, NULL, maSlalom_dialogCallback, NULL); + } + else{ + func_80324DBC(2.0f, 0xc07, 0x22, pntBoggy->position, NULL, maSlalom_dialogCallback, NULL); + } + Me.state = MA_SLALOM_STATE_4_LOSE; + break; + }//L8038B794 +} + +void maSlalom_init(void){ + int i; + + FP_func_8038AB60(0); + + if(map_get() != MAP_27_FP_FREEZEEZY_PEAK || jiggyscore_isCollected(JIGGY_2C_FP_BOGGY_3)){ + Me.state = MA_SLALOM_STATE_0_NONE; + return; + } + + Me.state = MA_SLALOM_STATE_1_STARTING; + Me.boggyLink = NULL; + Me.flagCount = 0; + Me.playerGate = -1; + Me.boggyGate = -1; + Me.boggyHasFinished = 0; + Me.hasBeenTwoBehind = 0; + Me.hasBeenThreeBehind = 0; + Me.hasBeenFourBehind = 0; + + for(i = 0; i < NUM_GATES; i++){ + meActiveFlags[i].marker = NULL; + meDummyFlags[i].marker = NULL; + meActiveFlags[i].position[0] = meActiveFlags[i].position[1] = meActiveFlags[i].position[2] = 0.0f; + meDummyFlags[i].position[0] = meDummyFlags[i].position[1] = meDummyFlags[i].position[2] = 0.0f; + meActiveFlags[i].distGatesSq = 0.0f; + meDummyFlags[i].distGatesSq = 0.0f; + } + for(i = 0; i < NUM_BRIDGES; i++){ + meBridgeLinks[i] = NULL; + } +} + +void maSlalom_end(){} + +void maSlalom_linkActiveFlag(ActorMarker *marker){ + Actor *actor = marker_getActor(marker); + s32 num; + + num = actor->unkF4_8 - 1; + if(num < NUM_GATES){ + meActiveFlags[num].marker = actor->marker; + meActiveFlags[num].position[0] = actor->position[0]; + meActiveFlags[num].position[1] = actor->position[1]; + meActiveFlags[num].position[2] = actor->position[2]; + Me.flagCount++; + }//L8038B920 +} + +void maSlalom_linkDummyFlag(ActorMarker *marker){ + Actor *actor = marker_getActor(marker); + s32 num; + + num = actor->unkF4_8 - 1; + if(num < NUM_GATES){ + meDummyFlags[num].marker = actor->marker; + meDummyFlags[num].position[0] = actor->position[0]; + meDummyFlags[num].position[1] = actor->position[1]; + meDummyFlags[num].position[2] = actor->position[2]; + Me.flagCount++; + }//L8038B9A0 +} + +void maSlalom_linkBoggy(ActorMarker *marker){ + Me.boggyLink = marker; +} + +void maSlalom_unlinkBoggy(void){ + Me.boggyLink = NULL; +} + +void maSlalom_start(void){ + int i; + + maSlalom_spawnGate(0, 1); + for(i = 1; i < 4; i++){ + maSlalom_spawnGate(i, 2); + } + maSlalom_spawnGate(NUM_GATES - 1, 2); + maSlalom_spawnAllBridges(); + if(jiggyscore_isSpawned(JIGGY_30_FP_BOGGY_2) || jiggyscore_isCollected(JIGGY_30_FP_BOGGY_2)){ + __spawnQueue_add_0(__maSlalom_spawnTrainers); + } + + Me.playerGate = -1; + Me.boggyGate = -1; + Me.boggyHasFinished = 0; + Me.hasBeenTwoBehind = 0; + Me.hasBeenThreeBehind = 0; + Me.hasBeenFourBehind = 0; + FP_func_8038AB60(1); + Me.state = MA_SLALOM_STATE_2_RACING; +} + +void maSlalom_setPlayerGate(s32 gate_num){ + + Me.playerGate = --gate_num; + func_8038AC20(gate_num, 3); + if(gate_num + 1 < NUM_GATES){ + func_8038AC20(gate_num + 1, 1); + } + + // make sure next 4 gates are spawned + if(gate_num + 4 < (NUM_GATES - 1)){ + maSlalom_spawnGate(gate_num + 4, 2); + } + + // despawn old gate + if(gate_num >= 2){ + __maSlalom_despawnGate(gate_num - 2); + } + + if(gate_num + 4 < 11){ + func_8028F8F8(20, 1); + func_8028F8F8(20, 1); + func_8028F8F8(21, 1); + func_8028F8F8(22, 1); + func_8028F8F8(30, 0); + } + else{ + func_8028F8F8(20, 0); + func_8028F8F8(21, 0); + func_8028F8F8(22, 0); + func_8028F8F8(30, 1); + } + + switch(Me.boggyGate - Me.playerGate){ + case 3: + func_8025AEA0(0x3a, 266666); + break; + case 2: + func_8025AEA0(0x3a, 300000); + break; + case 4: + break; + default: + func_8025AEA0(0x3a, 333333); + break; + + + } +} + +void maSlalom_setBoggyGate(s32 gate_num){ + + if(Me.boggyGate - Me.playerGate < 4 || 0x23 < Me.boggyGate){ + if(Me.boggyLink) + marker_getActor(Me.boggyLink); + + if(func_8038A1A0(Me.boggyLink)) + return; + + Me.boggyGate = gate_num-1; + if(Me.boggyGate >= NUM_GATES - 1){ + Me.boggyHasFinished = 1; + return; + } + + if(Me.state == MA_SLALOM_STATE_3_WIN) return; + if(Me.state == MA_SLALOM_STATE_4_LOSE) return; + if(Me.boggyGate >= 0x25) return; + + switch(Me.boggyGate - Me.playerGate){ + case 4: + if(Me.hasBeenFourBehind) + break; + Me.hasBeenFourBehind = TRUE; + FP_func_8038AB60(0); + if(!player_isDead()){ + func_8028F918(2); + gcdialog_showText(0xc10, 0x20, NULL, NULL, maSlalom_dialogCallback, NULL); + }//L8038BD40 + Me.state = MA_SLALOM_STATE_4_LOSE; + break; + + case 3: + if(!Me.hasBeenThreeBehind && !player_isDead()){ + Me.hasBeenThreeBehind = 1; + gcdialog_showText(0xc0f, 0x20, NULL, NULL, NULL, NULL); + }//L8038BD94 + func_8025AEA0(0x3a, 0x411aa); + break; + + case 2: + if(!Me.hasBeenTwoBehind && !player_isDead()){ + Me.hasBeenTwoBehind = 1; + gcdialog_showText(0xc0e, 0x20, NULL, NULL, NULL, NULL); + }//L8038BDF0 + func_8025AEA0(0x3a, 0x493e0); + break; + + default: + func_8025AEA0(0x3a, 0x51615); + break; + } + } +} + +/** + * @brief: returns a float between -4.0 and +NUM_GATES based on how many gates + difference there is between boggy and the player + */ +f32 maSlalom_compareBoggyToPlayer(f32 boggy_position[3]){ + f32 player_position[4]; + f32 f18; + f32 player_progress; + f32 boggy_progress; + f32 gate_diff; + + gate_diff = (f32)(Me.boggyGate - Me.playerGate); + if(Me.state != MA_SLALOM_STATE_2_RACING || Me.boggyGate < 0 || Me.playerGate < 0) + return 0.0f; + + if(gate_diff == 0.0f){ + player_getPosition(player_position); + + f18 = meActiveFlags[Me.boggyGate].distGatesSq; + if( 0.0 == f18 ) + return 0.5f; + + player_progress = ((boggy_position[0] - meActiveFlags[Me.boggyGate].position[0])*(meActiveFlags[Me.boggyGate+1].position[0] - meActiveFlags[Me.boggyGate].position[0]) + (boggy_position[2] - meActiveFlags[Me.boggyGate].position[2])*(meActiveFlags[Me.boggyGate+1].position[2] - meActiveFlags[Me.boggyGate].position[2]))/f18; + boggy_progress = ((player_position[0] - meActiveFlags[Me.boggyGate].position[0])*(meActiveFlags[Me.boggyGate+1].position[0] - meActiveFlags[Me.boggyGate].position[0]) + (player_position[2] - meActiveFlags[Me.boggyGate].position[2])*(meActiveFlags[Me.boggyGate+1].position[2] - meActiveFlags[Me.boggyGate].position[2]))/f18; + return -(player_progress - boggy_progress); + }//L8038BF58 + + gate_diff += (gate_diff < 0.0f) ? -0.5 : 0.5; + return -gate_diff; +} + +bool maSlalom_isActive(void){ + if ( Me.state == MA_SLALOM_STATE_2_RACING + || Me.state == MA_SLALOM_STATE_3_WIN + || Me.state == MA_SLALOM_STATE_4_LOSE + || Me.hasBeenFourBehind + ){ + return TRUE; + } + return FALSE; +} + +bool maSlolam_WithinRadiusOfBoggy(f32 position[3], s32 radius){ + Actor *pntBoggy; + + // WARNING: (maslalom.c) - You must set a valid radius. + + if(Me.boggyLink){ + pntBoggy = marker_getActor(Me.boggyLink); + } + else{ + return FALSE; + } + + if( (pntBoggy->position[0] - position[0])*(pntBoggy->position[0] - position[0]) + + (pntBoggy->position[1] - position[1])*(pntBoggy->position[1] - position[1]) + + (pntBoggy->position[2] - position[2])*(pntBoggy->position[2] - position[2]) + < radius*radius + ){ + return TRUE; + } + + return FALSE; +} + +s32 maSlalom_boggyHasFinished(void){ + return Me.boggyHasFinished; +} diff --git a/src/FP/racectrl.c b/src/FP/racectrl.c deleted file mode 100644 index 3c7875c4..00000000 --- a/src/FP/racectrl.c +++ /dev/null @@ -1,618 +0,0 @@ -#include -#include "functions.h" -#include "variables.h" - - -#include "core2/statetimer.h" -extern void player_stateTimer_set(s32, f32); - -typedef struct { - ActorMarker *marker; - f32 position[3]; - f32 unk10; -}Struct_FP_4770; - -/* .data */ -f32 D_80391ED0[3] = {-880.0f, 3.0f, 1769.0f}; -f32 D_80391EDC = 180.0f; - -f32 D_80391EE0[3] = {5187.0f, 428.0f, 854.0f}; -f32 D_80391EEC = 194.0f; - -f32 D_80391EF0[3] = {-904.0f, -10.0f, -1662.0f}; -f32 FP_D_80391EFC = 180.0f; - -f32 D_80391F00[3] = {2192.0f, 7.0f, 2901.0f}; -f32 D_80391F0C = 85.0f; - -f32 D_80391F10[3] = {712.0f, 7.0f, 3036.0f}; -f32 D_80391F1C = 284.0f; - -f32 D_80391F20[3] = {1605.0f, 658.0f, 5402.0f}; -f32 D_80391F2C[3] = {-4454.0f, 1920.0f, -6898.0f}; -f32 D_80391F38[3] = {-4451.0f, 1920.0f, -6685.0f}; - -/* .bss */ -Struct_FP_4770 D_80392F70[0x27]; -Struct_FP_4770 D_80393280[0x27]; -ActorMarker *D_80393590[5]; -struct { - u8 unk0; - // u8 pad1[0x3]; - s32 unk4; - s32 unk8; - s32 unkC; - s32 unk10; - ActorMarker *unk14; - u8 unk18; - u8 unk19; - u8 unk1A; -}FP_D_803935A8; - - -/* .code */ -void FP_func_8038AB60(s32 arg0){ - int i; - - func_8028F8F8(0xe, arg0 ^ 1); - - for (i = 0x14; i < 0x23; i++){ - func_8028F8F8(i, arg0); - } - - for (i = 0x32; i < 0x38; i++){ - func_8028F8F8(i, arg0); - } -} - -void func_8038ABDC(void){ - comusic_8025AB44(COMUSIC_3A_FP_BOGGY_RACE, 0, 4000); - func_8025AABC(COMUSIC_3A_FP_BOGGY_RACE); - func_8025A58C(-1, 4000); - core1_ce60_incOrDecCounter(TRUE); -} - -void func_8038AC20(s32 gate_indx, s32 arg1){ - Actor *a1; - Actor *a2; - - a1 = marker_getActor(D_80392F70[gate_indx].marker); - a2 = marker_getActor(D_80393280[gate_indx].marker); - - a1->velocity[0] = (f32)arg1; - a2->velocity[0] = (f32)arg1; -} - -//spawn race flag pair -void func_8038AC90(s32 indx, s32 arg1){ - ActorMarker *m1; - ActorMarker *m2; - Actor *a1; - Actor *a2; - - m1 = actor_spawnWithYaw_f32(0x161, D_80392F70[indx].position, 0)->marker; - m2 = actor_spawnWithYaw_f32(0x162, D_80393280[indx].position, 0)->marker; - a1 = marker_getActor(m1); - a2 = marker_getActor(m2); - - a1->unk38_31 = 1; - a2->unk38_31 = 1; - - a1->unkF4_8 = indx + 1; - a2->unkF4_8 = indx + 1; - - D_80392F70[indx].marker = a1->marker; - D_80393280[indx].marker = a2->marker; - - func_8038AC20(indx, arg1); - - a1->unk1C[0] = a2->position_x; - a1->unk1C[1] = a2->position_y; - a1->unk1C[2] = a2->position_z; - - if(indx + 1 == 0x27){ - a1->velocity[1] = 1.0f; - a2->velocity[1] = 1.0f; - } -} - -void func_8038ADE4(s32 indx, s32 arg1){ - __spawnQueue_add_2((GenFunction_2)func_8038AC90, indx, arg1); -} - -void func_8038AE14(s32 indx){ - if(D_80392F70[indx].marker){ - func_80326310(marker_getActor(D_80392F70[indx].marker)); - D_80392F70[indx].marker = NULL; - } - - if(D_80393280[indx].marker){ - func_80326310(marker_getActor(D_80393280[indx].marker)); - D_80393280[indx].marker = NULL; - } -} - -void func_8038AEA0(void){ - int i; - for(i = 0; i < 0x27; i++){ - func_8038AE14(i); - } -} - -void func_8038AEE0(s32 indx){ - Actor *sp1C; - switch(indx){ - case 0:// L8038AF0C - sp1C = actor_spawnWithYaw_f32(0x22d, D_80391ED0, D_80391EDC); - break; - - case 1:// L8038AF38 - sp1C = actor_spawnWithYaw_f32(0x22e, D_80391EE0, D_80391EEC); - break; - - case 2:// L8038AF64 - sp1C = actor_spawnWithYaw_f32(0x22d, D_80391EF0, FP_D_80391EFC); - break; - - case 3:// L8038AF90 - sp1C = actor_spawnWithYaw_f32(0x22d, D_80391F00, D_80391F0C); - break; - - case 4:// L8038AFBC - sp1C = actor_spawnWithYaw_f32(0x22d, D_80391F10, D_80391F1C); - break; - } - D_80393590[indx] = sp1C->marker; -} - -void func_8038B00C(s32 indx){ - __spawnQueue_add_1((GenFunction_1)func_8038AEE0, indx); -} - -void func_8038B034(void){ - int i; - for(i = 0; i < 5; i++){ - func_8038B00C(i); - } -} - -void func_8038B074(s32 indx){ - if(D_80393590[indx]){ - marker_despawn(D_80393590[indx]); - D_80393590[indx] = NULL; - } -} - -void FP_func_8038B0B8(void){ - int i; - for(i = 0; i < 5; i++){ - func_8038B074(i); - } -} - -void func_8038B0F8(void){ - Actor *trainers = actor_spawnWithYaw_f32(ACTOR_2C_TURBO_TALON_TRAINERS, D_80391F20, 100); - trainers->unk10_1 = FALSE; -} - -void func_8038B130(enum jiggy_e jiggy_id){ - if(jiggy_id == JIGGY_2C_FP_BOGGY_3 && !jiggyscore_isCollected(JIGGY_30_FP_BOGGY_2)){ - jiggy_spawn(jiggy_id, D_80391F38); - } - else{ - jiggy_spawn(jiggy_id, D_80391F2C); - } -} - -void func_8038B190(void){ - func_8028F66C(BS_INTR_2B); - mapSpecificFlags_set(4, FALSE); - func_8028F918(0); -} - -void func_8038B1C4(void){ - FP_D_803935A8.unk0 = 0; -} - -void func_8038B1D0(enum jiggy_e jiggy_id){ - timed_setStaticCameraToNode(0.0f, 3); - timedFunc_set_0(0.0f, func_8038AEA0); - timedFunc_set_0(0.0f, FP_func_8038B0B8); - timedFunc_set_1(0.1f, (GenFunction_1) func_8038B130, jiggy_id); - timedFunc_set_0(5.0f, func_8038B190); - timedFunc_set_0(5.0f, func_8038B1C4); - timed_exitStaticCamera(5.0f); - -} - -void func_8038B268(void){ - timed_exitStaticCamera(0.0f); - timedFunc_set_0(0.0f, func_8038AEA0); - timedFunc_set_0(0.0f, FP_func_8038B0B8); - func_8028FA14(map_get(), 0x11); - func_8028F66C(BS_INTR_2A); -} - -void func_8038B2C8(ActorMarker *caller, enum asset_e text_id, s32 arg2){ - Actor *actor; - if(FP_D_803935A8.unk14){ - actor = marker_getActor(FP_D_803935A8.unk14); - } - - switch(text_id){ - case 0xc04: //8038B318 - func_8038B268(); - break; - - case 0xc07: //8038B328 - func_8038B1D0(JIGGY_30_FP_BOGGY_2); - break; - - case 0xc0b: //8038B338 - func_8038B268(); - break; - - case 0xc0d: //8038B348 - func_8038B1D0(JIGGY_2C_FP_BOGGY_3); - break; - - case 0xc10: //8038B358 - func_8038ABDC(); - func_8028FA14(map_get(), 0x11); - func_8028F66C(BS_INTR_2A); - timedFunc_set_0(0.0f, func_8038B1C4); - break; - }//L8038B38C -} - -void func_8038B39C(void){ - if(jiggyscore_isCollected(JIGGY_30_FP_BOGGY_2) && func_8028ECAC() == BSGROUP_6_TURBO_TALON_TRAINERS){ - player_stateTimer_set(STATE_TIMER_3_TURBO_TALON, 2.0f); - } - func_8028F918(1); - func_8025A6EC(COMUSIC_3B_MINIGAME_VICTORY, 28000); - FP_func_8038AB60(0); - func_8038ABDC(); - timed_setStaticCameraToNode(0.0f, 1); -} - -void func_8038B410(void){ - Actor *sp2C; - - func_8028F918(2); - if(FP_D_803935A8.unk14) - sp2C = marker_getActor(FP_D_803935A8.unk14); - - sp2C->unk38_31 = 1; - func_8025A6EC(COMUSIC_3C_MINIGAME_LOSS, 28000); - FP_func_8038AB60(0); - func_8038ABDC(); - if(!jiggyscore_isCollected(JIGGY_30_FP_BOGGY_2)){ - timed_setStaticCameraToNode(0.0f, 1); - timed_playSfx(1.0f, SFX_8C_BOGGY_WAHEY, 1.0f, 32000); - func_80324DBC(2.0f, 0xC04, 0x2b, sp2C->position, NULL, func_8038B2C8, NULL); - }//L8038B4E0 - else{ - timed_setStaticCameraToNode(0.0f, 1); - timed_playSfx(1.0f, SFX_8C_BOGGY_WAHEY, 1.0f, 32000); - func_80324DBC(2.0f, 0xC0b, 0x2b, sp2C->position, NULL, func_8038B2C8, NULL); - - } -} - -void func_8038B544(void){ - Actor *sp2C; - int i; - f32 f2; - f32 f0; - - switch(FP_D_803935A8.unk0){ - case 1: //L8038B57C - if(FP_D_803935A8.unk4 < 0x4e) break; - - for(i = 0; i < 0x27; i++){ - if(i < 0x26){ - f0 = D_80392F70[i+1].position[2] - D_80392F70[i].position[2]; - f2 = D_80392F70[i+1].position[0] - D_80392F70[i].position[0]; - D_80392F70[i].unk10 = f0*f0 + f2*f2; - } - if(D_80392F70[0x26].unk10 < D_80392F70[i].unk10) - D_80392F70[0x26].unk10 = D_80392F70[i].unk10; - } - func_8038AEA0(); - FP_D_803935A8.unk0 = NULL; - break; - - case 2: //L8038B61C - if(jiggyscore_isCollected(JIGGY_30_FP_BOGGY_2) && func_8028ECAC() == BSGROUP_6_TURBO_TALON_TRAINERS){ - player_stateTimer_set(STATE_TIMER_3_TURBO_TALON, 20.0f); - } - - if(D_80392F70[0x26].marker == NULL) break; - - if(3.0f == marker_getActor(D_80392F70[0x26].marker)->velocity[0]){ - func_8038B39C(); - FP_D_803935A8.unk0 = 3; - break; - } - - if(FP_D_803935A8.unk10){ - func_8038B410(); - FP_D_803935A8.unk0 = 4; - } - break; - - case 3: //L8038B6C4 - if(FP_D_803935A8.unk14){ - sp2C = marker_getActor(FP_D_803935A8.unk14); - } - sp2C->unk38_31 = 2; - timed_playSfx(1.0f, SFX_8D_BOGGY_OHWW, 1.0f, 32000); - if(jiggyscore_isCollected(JIGGY_30_FP_BOGGY_2) || jiggyscore_isSpawned(JIGGY_30_FP_BOGGY_2)){ - func_80324DBC(2.0f, 0xc0d, 0x2a, sp2C->position, NULL, func_8038B2C8, NULL); - } - else{ - func_80324DBC(2.0f, 0xc07, 0x22, sp2C->position, NULL, func_8038B2C8, NULL); - } - FP_D_803935A8.unk0 = 4; - break; - }//L8038B794 -} - -void func_8038B7A4(void){ - int i; - - FP_func_8038AB60(0); - - if(map_get() != MAP_27_FP_FREEZEEZY_PEAK || jiggyscore_isCollected(JIGGY_2C_FP_BOGGY_3)){ - FP_D_803935A8.unk0 = 0; - return; - } - - FP_D_803935A8.unk0 = 1; - FP_D_803935A8.unk14 = NULL; - FP_D_803935A8.unk4 = 0; - FP_D_803935A8.unk8 = -1; - FP_D_803935A8.unkC = -1; - FP_D_803935A8.unk10 = 0; - FP_D_803935A8.unk18 = 0; - FP_D_803935A8.unk19 = 0; - FP_D_803935A8.unk1A = 0; - - for(i = 0; i < 0x27; i++){ - D_80392F70[i].marker = NULL; - D_80393280[i].marker = NULL; - D_80392F70[i].position[0] = D_80392F70[i].position[1] = D_80392F70[i].position[2] = 0.0f; - D_80393280[i].position[0] = D_80393280[i].position[1] = D_80393280[i].position[2] = 0.0f; - D_80392F70[i].unk10 = 0.0f; - D_80393280[i].unk10 = 0.0f; - } - for(i = 0; i < 5; i++){ - D_80393590[i] = NULL; - } -} - -void func_8038B8A8(){} - -void func_8038B8B0(ActorMarker *marker){ - Actor *actor = marker_getActor(marker); - s32 tmp_a0; - - tmp_a0 = actor->unkF4_8 - 1; - if(tmp_a0 < 0x27){ - D_80392F70[tmp_a0].marker = actor->marker; - D_80392F70[tmp_a0].position[0] = actor->position[0]; - D_80392F70[tmp_a0].position[1] = actor->position[1]; - D_80392F70[tmp_a0].position[2] = actor->position[2]; - FP_D_803935A8.unk4++; - }//L8038B920 -} - -void func_8038B930(ActorMarker *marker){ - Actor *actor = marker_getActor(marker); - s32 tmp_a0; - - tmp_a0 = actor->unkF4_8 - 1; - if(tmp_a0 < 0x27){ - D_80393280[tmp_a0].marker = actor->marker; - D_80393280[tmp_a0].position[0] = actor->position[0]; - D_80393280[tmp_a0].position[1] = actor->position[1]; - D_80393280[tmp_a0].position[2] = actor->position[2]; - FP_D_803935A8.unk4++; - }//L8038B9A0 -} - -void func_8038B9B0(ActorMarker *marker){ - FP_D_803935A8.unk14 = marker; -} - -void func_8038B9BC(void){ - FP_D_803935A8.unk14 = NULL; -} - -void func_8038B9C8(void){ - int i; - - func_8038ADE4(0, 1); - for(i = 1; i < 4; i++){ - func_8038ADE4(i, 2); - } - func_8038ADE4(0x26, 2); - func_8038B034(); - if(jiggyscore_isSpawned(JIGGY_30_FP_BOGGY_2) || jiggyscore_isCollected(JIGGY_30_FP_BOGGY_2)){ - __spawnQueue_add_0(func_8038B0F8); - } - - FP_D_803935A8.unk8 = -1; - FP_D_803935A8.unkC = -1; - FP_D_803935A8.unk10 = 0; - FP_D_803935A8.unk18 = 0; - FP_D_803935A8.unk19 = 0; - FP_D_803935A8.unk1A = 0; - FP_func_8038AB60(1); - FP_D_803935A8.unk0 = 2; -} - -void FP_func_8038BA88(s32 arg0){ - - FP_D_803935A8.unk8 = --arg0; - func_8038AC20(arg0, 3); - if(arg0 + 1 < 39){ - func_8038AC20(arg0 + 1, 1); - } - - if(arg0 + 4 < 38){ - func_8038ADE4(arg0 + 4, 2); - } - - if(arg0 >= 2){ - func_8038AE14(arg0 - 2); - } - - if(arg0 + 4 < 11){ - func_8028F8F8(20, 1); - func_8028F8F8(20, 1); - func_8028F8F8(21, 1); - func_8028F8F8(22, 1); - func_8028F8F8(30, 0); - } - else{ - func_8028F8F8(20, 0); - func_8028F8F8(21, 0); - func_8028F8F8(22, 0); - func_8028F8F8(30, 1); - } - - switch(FP_D_803935A8.unkC - FP_D_803935A8.unk8){ - case 3: - func_8025AEA0(0x3a, 266666); - break; - case 2: - func_8025AEA0(0x3a, 300000); - break; - case 4: - break; - default: - func_8025AEA0(0x3a, 333333); - break; - - - } -} - -void func_8038BC0C(s32 arg0){ - - if(FP_D_803935A8.unkC - FP_D_803935A8.unk8 < 4 || 0x23 < FP_D_803935A8.unkC){ - if(FP_D_803935A8.unk14) - marker_getActor(FP_D_803935A8.unk14); - - if(func_8038A1A0(FP_D_803935A8.unk14)) - return; - - FP_D_803935A8.unkC = arg0-1; - if(FP_D_803935A8.unkC >= 0x26){ - FP_D_803935A8.unk10 = 1; - return; - } - - if(FP_D_803935A8.unk0 == 3) return; - if(FP_D_803935A8.unk0 == 4) return; - if(FP_D_803935A8.unkC >= 0x25) return; - - switch(FP_D_803935A8.unkC - FP_D_803935A8.unk8){ - case 4: - if(FP_D_803935A8.unk1A) - break; - FP_D_803935A8.unk1A = TRUE; - FP_func_8038AB60(0); - if(!player_isDead()){ - func_8028F918(2); - gcdialog_showText(0xc10, 0x20, NULL, NULL, func_8038B2C8, NULL); - }//L8038BD40 - FP_D_803935A8.unk0 = 4; - break; - - case 3: - if(!FP_D_803935A8.unk19 && !player_isDead()){ - FP_D_803935A8.unk19 = 1; - gcdialog_showText(0xc0f, 0x20, NULL, NULL, NULL, NULL); - }//L8038BD94 - func_8025AEA0(0x3a, 0x411aa); - break; - - case 2: - if(!FP_D_803935A8.unk18 && !player_isDead()){ - FP_D_803935A8.unk18 = 1; - gcdialog_showText(0xc0e, 0x20, NULL, NULL, NULL, NULL); - }//L8038BDF0 - func_8025AEA0(0x3a, 0x493e0); - break; - - default: - func_8025AEA0(0x3a, 0x51615); - break; - } - } -} - -f32 func_8038BE20(f32 arg0[3]){ - f32 sp38[4]; - f32 f18; - f32 sp30; - f32 sp2C; - f32 tmp_f12; - - tmp_f12 = (f32)(FP_D_803935A8.unkC - FP_D_803935A8.unk8); - if(FP_D_803935A8.unk0 != 2 || FP_D_803935A8.unkC < 0 || FP_D_803935A8.unk8 < 0) - return 0.0f; - - if(tmp_f12 == 0.0f){ - player_getPosition(sp38); - - f18 = D_80392F70[FP_D_803935A8.unkC].unk10; - if( 0.0 == f18 ) - return 0.5f; - - sp30 = ((arg0[0] - D_80392F70[FP_D_803935A8.unkC].position[0])*(D_80392F70[FP_D_803935A8.unkC+1].position[0] - D_80392F70[FP_D_803935A8.unkC].position[0]) + (arg0[2] - D_80392F70[FP_D_803935A8.unkC].position[2])*(D_80392F70[FP_D_803935A8.unkC+1].position[2] - D_80392F70[FP_D_803935A8.unkC].position[2]))/f18; - sp2C = ((sp38[0] - D_80392F70[FP_D_803935A8.unkC].position[0])*(D_80392F70[FP_D_803935A8.unkC+1].position[0] - D_80392F70[FP_D_803935A8.unkC].position[0]) + (sp38[2] - D_80392F70[FP_D_803935A8.unkC].position[2])*(D_80392F70[FP_D_803935A8.unkC+1].position[2] - D_80392F70[FP_D_803935A8.unkC].position[2]))/f18; - return -(sp30 - sp2C); - }//L8038BF58 - - tmp_f12 += (tmp_f12 < 0.0f) ? -0.5 : 0.5; - return -tmp_f12; -} - -bool func_8038BFA0(void){ - if ( FP_D_803935A8.unk0 == 2 - || FP_D_803935A8.unk0 == 3 - || FP_D_803935A8.unk0 == 4 - || FP_D_803935A8.unk1A - ){ - return TRUE; - } - return FALSE; -} - -bool func_8038BFE8(f32 arg0[3], s32 arg1){ - Actor *actor; - - if(FP_D_803935A8.unk14){ - actor = marker_getActor(FP_D_803935A8.unk14); - } - else{ - return FALSE; - } - - if( (actor->position[0] - arg0[0])*(actor->position[0] - arg0[0]) - + (actor->position[1] - arg0[1])*(actor->position[1] - arg0[1]) - + (actor->position[2] - arg0[2])*(actor->position[2] - arg0[2]) - < arg1*arg1 - ){ - return TRUE; - } - return FALSE; -} - -s32 func_8038C098(void){ - return FP_D_803935A8.unk10; -} diff --git a/src/core2/ch/beehive.c b/src/core2/ch/beehive.c index e29e7947..64d37ceb 100644 --- a/src/core2/ch/beehive.c +++ b/src/core2/ch/beehive.c @@ -47,7 +47,7 @@ void chBeehive_update(Actor *this){ this->unk38_0 = volatileFlag_get(VOLATILE_FLAG_1)| volatileFlag_get(VOLATILE_FLAG_1F_IN_CHARACTER_PARADE); }//L802CE960 if(map_get() == MAP_27_FP_FREEZEEZY_PEAK){ - if(func_8038BFA0()){ + if(maSlalom_isActive()){ this->unk58_0 = 0; return; } diff --git a/src/core2/ch/icecube.c b/src/core2/ch/icecube.c index e4c0f549..9199ed70 100644 --- a/src/core2/ch/icecube.c +++ b/src/core2/ch/icecube.c @@ -254,7 +254,7 @@ void chicecube_update(Actor *this){ f32 sp30[3]; if(map_get() == MAP_27_FP_FREEZEEZY_PEAK){ - if(func_8038BFA0()){ + if(maSlalom_isActive()){ actor_collisionOff(this); this->unk58_0 = FALSE; return; diff --git a/src/core2/ch/snowman.c b/src/core2/ch/snowman.c index a234e937..66aad14b 100644 --- a/src/core2/ch/snowman.c +++ b/src/core2/ch/snowman.c @@ -228,7 +228,7 @@ void chSnowman_update(Actor *this){ } }//L802E21D8 if(map_get() == MAP_27_FP_FREEZEEZY_PEAK){ - if(func_8038BFA0() || func_8038DD14()){ + if(maSlalom_isActive() || func_8038DD14()){ actor_collisionOff(this); this->unk58_0 = 0; return; diff --git a/src/core2/code_42CB0.c b/src/core2/code_42CB0.c index f2bebc72..67d64480 100644 --- a/src/core2/code_42CB0.c +++ b/src/core2/code_42CB0.c @@ -135,7 +135,7 @@ void chHoneycomb_update(Actor *this){ }//L802CA098 if(map_get() == MAP_27_FP_FREEZEEZY_PEAK){ - if(func_8038BFA0()){ + if(maSlalom_isActive()){ this->unk58_0 = FALSE; actor_collisionOff(this); return; diff --git a/src/core2/code_47BD0.c b/src/core2/code_47BD0.c index 60c08399..a39d9da9 100644 --- a/src/core2/code_47BD0.c +++ b/src/core2/code_47BD0.c @@ -390,7 +390,7 @@ void chBeeSwarm_update(Actor *this) { } } if (map_get() == MAP_27_FP_FREEZEEZY_PEAK) { - if (func_8038BFA0()) { + if (maSlalom_isActive()) { this->unk58_0 = FALSE; return; } diff --git a/src/core2/code_4C020.c b/src/core2/code_4C020.c index 9cffb360..5de3826a 100644 --- a/src/core2/code_4C020.c +++ b/src/core2/code_4C020.c @@ -712,7 +712,7 @@ void func_802D4CAC(Actor *this){ void func_802D4CD4(Actor *this){ if(map_get() == MAP_27_FP_FREEZEEZY_PEAK){ - if(func_8038BFA0()){ + if(maSlalom_isActive()){ this->unk58_0 = FALSE; return; }//L802D4D10 diff --git a/src/core2/code_9B990.c b/src/core2/code_9B990.c index 829d6130..4ad5a015 100644 --- a/src/core2/code_9B990.c +++ b/src/core2/code_9B990.c @@ -302,21 +302,21 @@ void __overlay_fp_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx){ return; } void __overlay_fp_release(void){ fp_sirslushgame_end(); fp_snowmanButtonGame_end(); - func_8038B8A8(); + maSlalom_end(); func_8039195C(); } void overlay_fp_init(void){ fp_sirslushgame_init(); fp_snowmanButtonGame_init(); - func_8038B7A4(); + maSlalom_init(); func_803918C0(); } void __overlay_fp_update(void){ fp_sirslushgame_update(); fp_snowmanButtonGame_update(); - func_8038B544(); + maSlalom_update(); func_80391994(); }