Skip to content

Commit

Permalink
Additional Mirror World settings (#585)
Browse files Browse the repository at this point in the history
* Random mirror world settings

* Make MW option U8
  • Loading branch information
Roberto-Nessy authored Nov 3, 2022
1 parent 0c2b922 commit 4458cb1
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 7 deletions.
4 changes: 4 additions & 0 deletions code/oot.ld
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,10 @@ SECTIONS
*(.patch_CheckForPocketCuccoHatchGameplayInit)
}

.patch_InitSceneMirrorWorld 0x4490DC : {
*(.patch_InitSceneMirrorWorld)
}

.patch_InitSceneClearExtendedObjects 0x449218 : {
*(.patch_InitSceneClearExtendedObjects)
}
Expand Down
4 changes: 4 additions & 0 deletions code/oot_e.ld
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,10 @@ SECTIONS
*(.patch_CheckForPocketCuccoHatchGameplayInit)
}

.patch_InitSceneMirrorWorld 0x4490FC : {
*(.patch_InitSceneMirrorWorld)
}

.patch_InitSceneClearExtendedObjects 0x449238 : {
*(.patch_InitSceneClearExtendedObjects)
}
Expand Down
15 changes: 15 additions & 0 deletions code/src/entrance.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,3 +834,18 @@ void InitEntranceTrackingData(void) {
}
SortEntranceList(destList, 1);
}

void Entrance_UpdateMQFlag(void) {
if (IsInGame()) {
switch (gSettingsContext.mirrorWorld) {
case MIRRORWORLD_SCENESPECIFIC:
gSaveContext.masterQuestFlag = Hash(gGlobalContext->sceneNum) & 1;
return;
case MIRRORWORLD_ENTRANCESPECIFIC:
gSaveContext.masterQuestFlag = Hash(gSaveContext.entranceIndex) & 1;
return;
case MIRRORWORLD_RANDOM:
gSaveContext.masterQuestFlag = gRandInt & 1;
}
}
}
8 changes: 8 additions & 0 deletions code/src/hooks.s
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,14 @@ hook_CriticalHealthCheck:
movle r0,#0x18
bx lr

.global hook_InitSceneMirrorWorld
hook_InitSceneMirrorWorld:
push {r0-r12,lr}
bl Entrance_UpdateMQFlag
pop {r0-r12,lr}
cpy r4,r0
bx lr

.global hook_CollisionATvsAC
hook_CollisionATvsAC:
ldr r12,[sp,#0x18]
Expand Down
5 changes: 5 additions & 0 deletions code/src/patches.s
Original file line number Diff line number Diff line change
Expand Up @@ -1971,6 +1971,11 @@ CriticalHealthCheckThree_patch:
nop
nop

.section .patch_InitSceneMirrorWorld
.global InitSceneMirrorWorld_patch
InitSceneMirrorWorld_patch:
bl hook_InitSceneMirrorWorld

.section .patch_CollisionATvsAC
.global CollisionATvsAC_patch
CollisionATvsAC_patch:
Expand Down
8 changes: 8 additions & 0 deletions code/src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@ typedef enum {
TRAILDURATION_LIGHTSABER,
} TrailDuration;

typedef enum {
MIRRORWORLD_OFF,
MIRRORWORLD_ON,
MIRRORWORLD_SCENESPECIFIC,
MIRRORWORLD_ENTRANCESPECIFIC,
MIRRORWORLD_RANDOM,
} MirrorWorld;

typedef enum {
PLAY_ON_CONSOLE,
PLAY_ON_CITRA,
Expand Down
9 changes: 7 additions & 2 deletions source/descriptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1078,8 +1078,13 @@ string_view coloredBossKeysDesc = "If set, boss key models will be colored
/*------------------------------ //
| MIRROR WORLD | //
------------------------------*/ //
string_view mirrorWorldDesc = "If set, the world will be mirrored."; //
//
string_view mirrorWorldOffDesc = "The world will not be mirrored."; //
string_view mirrorWorldOnDesc = "The world will be mirrored."; //
string_view mirrorWorldSceneDesc = "Some regions will be mirrored while others won't.";
string_view mirrorWorldEntranceDesc = "Different entrances to the same region will alter\n"
"whether it is mirrored or not."; //
string_view mirrorWorldRandomDesc = "Whether the world is mirrored may change after\n" //
"every loading zone inconsistently."; //
/*------------------------------ //
| SHUFFLE MUSIC | //
------------------------------*/ //
Expand Down
6 changes: 5 additions & 1 deletion source/descriptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,11 @@ extern string_view alwaysSimpleModeDesc;
extern string_view coloredKeysDesc;
extern string_view coloredBossKeysDesc;

extern string_view mirrorWorldDesc;
extern string_view mirrorWorldOffDesc;
extern string_view mirrorWorldOnDesc;
extern string_view mirrorWorldSceneDesc;
extern string_view mirrorWorldEntranceDesc;
extern string_view mirrorWorldRandomDesc;

extern string_view musicRandoDesc;
extern string_view shuffleBGMDesc;
Expand Down
8 changes: 4 additions & 4 deletions source/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,9 +1144,9 @@ namespace Settings {
std::string finalChuTrailInnerColor = BombchuTrailInnerColor.GetSelectedOptionText();
std::string finalChuTrailOuterColor = BombchuTrailOuterColor.GetSelectedOptionText();

Option ColoredKeys = Option::Bool("Colored Small Keys", {"Off", "On"}, {coloredKeysDesc}, OptionCategory::Cosmetic);
Option ColoredBossKeys = Option::Bool("Colored Boss Keys", {"Off", "On"}, {coloredBossKeysDesc}, OptionCategory::Cosmetic);
Option MirrorWorld = Option::Bool("Mirror World", {"Off", "On"}, {mirrorWorldDesc}, OptionCategory::Cosmetic);
Option ColoredKeys = Option::Bool("Colored Small Keys", {"Off", "On"}, {coloredKeysDesc}, OptionCategory::Cosmetic);
Option ColoredBossKeys = Option::Bool("Colored Boss Keys", {"Off", "On"}, {coloredBossKeysDesc}, OptionCategory::Cosmetic);
Option MirrorWorld = Option::U8 ("Mirror World", {"Off", "On", "Scene", "Entrance", "Random"}, {mirrorWorldOffDesc, mirrorWorldOnDesc, mirrorWorldSceneDesc, mirrorWorldEntranceDesc, mirrorWorldRandomDesc}, OptionCategory::Cosmetic);

std::vector<Option *> cosmeticOptions = {
&CustomTunicColors,
Expand Down Expand Up @@ -1467,7 +1467,7 @@ namespace Settings {
ctx.rainbowChuTrailInnerColor = (BombchuTrailInnerColor.Value<u8>() == RAINBOW_TRAIL) ? 1 : 0;
ctx.rainbowChuTrailOuterColor = (BombchuTrailOuterColor.Value<u8>() == RAINBOW_TRAIL) ? 1 : 0;
ctx.bombchuTrailDuration = BombchuTrailDuration.Value<u8>();
ctx.mirrorWorld = (MirrorWorld) ? 1 : 0;
ctx.mirrorWorld = MirrorWorld.Value<u8>();
ctx.coloredKeys = (ColoredKeys) ? 1 : 0;
ctx.coloredBossKeys = (ColoredBossKeys) ? 1 : 0;
ctx.shuffleSFX = ShuffleSFX.Value<u8>();
Expand Down

0 comments on commit 4458cb1

Please sign in to comment.