about summary refs log tree commit diff stats
path: root/Source/Randomizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Randomizer.cpp')
-rw-r--r--Source/Randomizer.cpp58
1 files changed, 36 insertions, 22 deletions
diff --git a/Source/Randomizer.cpp b/Source/Randomizer.cpp index 8c4297d..6729ae7 100644 --- a/Source/Randomizer.cpp +++ b/Source/Randomizer.cpp
@@ -1,18 +1,15 @@
1/* 1/*
2 * TODO: Split out main() logic into another file, and move into separate functions for easier testing. Then write tests.
3 * BUGS: 2 * BUGS:
4 * Shipwreck vault fails, possibly because of dot_reflection? Sometimes? 3 * Shipwreck vault is solved reversed?
5 * Some panels are impossible casually: (idc, I think) 4 * Extra_back_distance to make pillar swaps work
6 ** Town Stars, Invisible dots 5 * Verify UTM perspective?
7 * FEATURES: 6 * FEATURES:
8 * SWAP_TARGETS should still require the full panel sequence (and have ways to prevent softlocks?) 7 * Challenge randomization
9 ** Do: Challenge
10 * Randomize audio logs 8 * Randomize audio logs
11 * Swap sounds in jungle (along with panels) -- maybe impossible 9 * Swap sounds in jungle (along with panels) -- maybe impossible
12 * Make orange 7 (all of oranges?) hard. Like big = hard. 10 * Make orange 7 (all of oranges?) hard. Like big = hard.
13 * Start the game if it isn't running? 11 * Start the game if it isn't running?
14 * UI for the randomizer :( 12 * Increase odds of mountain oranges garbage on other panels? [setting]
15 * Increase odds of mountain oranges garbage on other panels?
16*/ 13*/
17#include "Memory.h" 14#include "Memory.h"
18#include "Randomizer.h" 15#include "Randomizer.h"
@@ -34,11 +31,11 @@ int find(const std::vector<T> &data, T search, size_t startIndex = 0) {
34void Randomizer::Randomize() 31void Randomizer::Randomize()
35{ 32{
36 // Content swaps -- must happen before squarePanels 33 // Content swaps -- must happen before squarePanels
37 _core.Randomize(tallUpDownPanels, SWAP_LINES|SWAP_LINES); 34 _core.Randomize(tallUpDownPanels, SWAP_LINES);
38 _core.Randomize(upDownPanels, SWAP_LINES|SWAP_LINES); 35 _core.Randomize(upDownPanels, SWAP_LINES);
39 _core.Randomize(leftForwardRightPanels, SWAP_LINES|SWAP_LINES); 36 _core.Randomize(leftForwardRightPanels, SWAP_LINES);
40 37
41 _core.Randomize(squarePanels, SWAP_LINES|SWAP_LINES); 38 _core.Randomize(squarePanels, SWAP_LINES);
42 39
43 // Individual area modifications 40 // Individual area modifications
44 RandomizeTutorial(); 41 RandomizeTutorial();
@@ -54,6 +51,7 @@ void Randomizer::Randomize()
54 RandomizeJungle(); 51 RandomizeJungle();
55 RandomizeSwamp(); 52 RandomizeSwamp();
56 RandomizeMountain(); 53 RandomizeMountain();
54 // RandomizeChallenge();
57} 55}
58 56
59void Randomizer::RandomizeTutorial() { 57void Randomizer::RandomizeTutorial() {
@@ -68,7 +66,7 @@ void Randomizer::RandomizeSymmetry() {
68} 66}
69 67
70void Randomizer::RandomizeDesert() { 68void Randomizer::RandomizeDesert() {
71 _core.Randomize(desertPanels, SWAP_LINES|SWAP_LINES); 69 _core.Randomize(desertPanels, SWAP_LINES);
72 70
73 // Turn off desert surface 8 71 // Turn off desert surface 8
74 _core.WritePanelData<float>(0x09F94, POWER, {0.0, 0.0}); 72 _core.WritePanelData<float>(0x09F94, POWER, {0.0, 0.0});
@@ -83,10 +81,14 @@ void Randomizer::RandomizeQuarry() {
83 81
84void Randomizer::RandomizeTreehouse() { 82void Randomizer::RandomizeTreehouse() {
85 // Ensure that whatever pivot panels we have are flagged as "pivotable" 83 // Ensure that whatever pivot panels we have are flagged as "pivotable"
86 _core.WritePanelData<int>(0x17DD1, STYLE_FLAGS, {0x8000}); 84 int panelFlags = _core.ReadPanelData<int>(0x17DD1, STYLE_FLAGS, 1)[0];
87 _core.WritePanelData<int>(0x17CE3, STYLE_FLAGS, {0x8000}); 85 _core.WritePanelData<int>(0x17DD1, STYLE_FLAGS, {panelFlags | 0x8000});
88 _core.WritePanelData<int>(0x17DB7, STYLE_FLAGS, {0x8000}); 86 panelFlags = _core.ReadPanelData<int>(0x17CE3, STYLE_FLAGS, 1)[0];
89 _core.WritePanelData<int>(0x17E52, STYLE_FLAGS, {0x8000}); 87 _core.WritePanelData<int>(0x17CE3, STYLE_FLAGS, {panelFlags | 0x8000});
88 panelFlags = _core.ReadPanelData<int>(0x17DB7, STYLE_FLAGS, 1)[0];
89 _core.WritePanelData<int>(0x17DB7, STYLE_FLAGS, {panelFlags | 0x8000});
90 panelFlags = _core.ReadPanelData<int>(0x17E52, STYLE_FLAGS, 1)[0];
91 _core.WritePanelData<int>(0x17E52, STYLE_FLAGS, {panelFlags | 0x8000});
90} 92}
91 93
92void Randomizer::RandomizeKeep() { 94void Randomizer::RandomizeKeep() {
@@ -138,11 +140,9 @@ void Randomizer::RandomizeBunker() {
138void Randomizer::RandomizeJungle() { 140void Randomizer::RandomizeJungle() {
139 std::vector<int> randomOrder(junglePanels.size(), 0); 141 std::vector<int> randomOrder(junglePanels.size(), 0);
140 std::iota(randomOrder.begin(), randomOrder.end(), 0); 142 std::iota(randomOrder.begin(), randomOrder.end(), 0);
141 // Randomize Waves 2-7
142 // Waves 1 cannot be randomized, since no other panel can start on 143 // Waves 1 cannot be randomized, since no other panel can start on
143 _core.RandomizeRange(randomOrder, SWAP_NONE, 1, 7); 144 _core.RandomizeRange(randomOrder, SWAP_NONE, 1, 7); // Waves 2-7
144 // Randomize Pitches 1-6 onto themselves 145 _core.RandomizeRange(randomOrder, SWAP_NONE, 8, 13); // Pitches 1-6
145 _core.RandomizeRange(randomOrder, SWAP_NONE, 8, 13);
146 _core.ReassignTargets(junglePanels, randomOrder); 146 _core.ReassignTargets(junglePanels, randomOrder);
147} 147}
148 148
@@ -153,9 +153,23 @@ void Randomizer::RandomizeSwamp() {
153 153
154void Randomizer::RandomizeMountain() { 154void Randomizer::RandomizeMountain() {
155 _core.Randomize(lasers, SWAP_TARGETS); 155 _core.Randomize(lasers, SWAP_TARGETS);
156 _core.Randomize(pillars, SWAP_LINES|SWAP_LINES); 156 _core.Randomize(pillars, SWAP_LINES);
157 _core.Randomize(mountainMultipanel, SWAP_LINES);
157 158
158 // Read the target of keep front laser, and write it to keep back laser. 159 // Read the target of keep front laser, and write it to keep back laser.
159 std::vector<int> keepFrontLaserTarget = _core.ReadPanelData<int>(0x0360E, TARGET, 1); 160 std::vector<int> keepFrontLaserTarget = _core.ReadPanelData<int>(0x0360E, TARGET, 1);
160 _core.WritePanelData<int>(0x03317, TARGET, keepFrontLaserTarget); 161 _core.WritePanelData<int>(0x03317, TARGET, keepFrontLaserTarget);
162}
163
164void Randomizer::RandomizeChallenge() {
165 std::vector<int> randomOrder(challengePanels.size(), 0);
166 std::iota(randomOrder.begin(), randomOrder.end(), 0);
167 _core.RandomizeRange(randomOrder, SWAP_NONE, 1, 11); // Easy maze - Triple 2
168 std::vector<int> triple1Target = _core.ReadPanelData<int>(0x00C80, TARGET, 1);
169 _core.WritePanelData<int>(0x00CA1, TARGET, triple1Target);
170 _core.WritePanelData<int>(0x00CB9, TARGET, triple1Target);
171 std::vector<int> triple2Target = _core.ReadPanelData<int>(0x00C22, TARGET, 1);
172 _core.WritePanelData<int>(0x00C59, TARGET, triple2Target);
173 _core.WritePanelData<int>(0x00C68, TARGET, triple2Target);
174 _core.ReassignTargets(challengePanels, randomOrder);
161} \ No newline at end of file 175} \ No newline at end of file