-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.cpp
82 lines (68 loc) · 3.1 KB
/
init.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "revolution.h"
#include "kamek/hooks.h"
#include "Game/Util.h"
typedef void (*Func)();
extern Func __ctor_loc;
extern Func __ctor_end;
namespace {
// ----------------------------------------------------------------------------------------------------------------
// Calls all static initializers after MR::initAcosTable. This is necessary to initialize static variables and
// constants in the BSS segment. Custom Nerve instances will be stored there, for example.
void init() {
for (Func* f = &__ctor_loc; f < &__ctor_end; f++) {
(*f)();
}
}
// Called after initAcosTable
kmBranch(0x8003B344, init);
// ----------------------------------------------------------------------------------------------------------------
// Events to be handled after GameScene::start
void handleGameSceneStart() {
}
kmBranch(0x80451888, handleGameSceneStart);
// ----------------------------------------------------------------------------------------------------------------
// Events to be handled after any scene gets destroyed
void handleAnySceneDestroyed() {
}
double OdysseyLikeCamera (double a, double b) {
// Calculate normal result and then subtract 40°-ish
double result = fmod(a, 6.283185482025146) + (MR::testCorePadTriggerLeft(0) || MR::testCorePadButtonLeft(0) ? 0.698132 : -0.698132);
if (result < 0) {
result = 6.283185482025146 + result;
OSReport("CameraPos < 0, underflowing to %g\n", result);
}
else if (result > 6.283185482025146) {
result -= 6.283185482025146;
OSReport("CameraPos > 2π, overflowing to %g\n", result);
}
return result;
}
int disableSFX () {
return 0;
}
int holdCameraBtnLeft () {
// Normally, the camera functions call MR::testCorePadTriggerLeft,
// but that only returns true once while MR::testCorePadButtonLeft
// returns true on every frame Left is held.
return (MR::testCorePadTriggerLeft(0) || MR::testCorePadButtonLeft(0));
}
int holdCameraBtnRight () {
// Same here.
return (MR::testCorePadTriggerRight(0) || MR::testCorePadButtonRight(0));
}
kmCall(0x801180C8, OdysseyLikeCamera); // fmod in CameraFollow::startRound
kmCall(0x8011E118, holdCameraBtnLeft); // return in CameraLocalUtil::testCameraPadTriggerLeft
kmCall(0x8011E168, holdCameraBtnRight); // return in CameraLocalUtil::testCameraPadTriggerRight
// ----------------------------------------
// Here we change all instances of the game calling CameraDirector::isPlayableCameraSE
// to be false so that it doesn't play any soundeffects
kmCall(0x80115330, disableSFX);
kmCall(0x801153B0, disableSFX);
kmCall(0x801153D8, disableSFX);
kmCall(0x80115454, disableSFX);
kmCall(0x8011547C, disableSFX);
kmCall(0x801154E4, disableSFX);
kmCall(0x8011551C, disableSFX);
kmCall(0x80115578, disableSFX);
kmCall(0x801155C0, disableSFX);
}