Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
worldgeneral.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2020 Twilight
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15*/
16
22
23#include "./worldgeneral.h"
24#include "../../savefile.h"
27#include <pse-db/mapsdb.h>
30#include <pse-common/random.h>
31
33{
34 options = new Options;
36 load(saveFile);
37}
38
40 options->deleteLater();
41 letterDelay->deleteLater();
42}
43
45{
46 reset();
47
48 if(saveFile == nullptr)
49 return;
50
51 auto toolset = saveFile->toolset;
52
53 // Bits 0-3 [max 15]
54 options->textSlowness = toolset->getByte(0x2601) & 0b00001111;
55 options->textSlownessChanged();
56
57 options->battleStyleSet = toolset->getBit(0x2601, 1, 6);
58 options->battleStyleSetChanged();
59
60 options->battleAnimOff = toolset->getBit(0x2601, 1, 7);
61 options->battleAnimOffChanged();
62
63 letterDelay->normalDelay = toolset->getBit(0x2604, 1, 0);
64 letterDelay->normalDelayChanged();
65
66 letterDelay->dontDelay = toolset->getBit(0x2604, 1, 1);
67 letterDelay->dontDelayChanged();
68
69 lastBlackoutMap = toolset->getByte(0x29C5);
71
72 lastMap = toolset->getByte(0x2611);
74}
75
77{
78 auto toolset = saveFile->toolset;
79
80 toolset->setByte(0x2601, options->textSlowness);
81 toolset->setBit(0x2601, 1, 6, options->battleStyleSet);
82 toolset->setBit(0x2601, 1, 7, options->battleAnimOff);
83
84 toolset->setBit(0x2604, 1, 0, letterDelay->normalDelay);
85 toolset->setBit(0x2604, 1, 1, letterDelay->dontDelay);
86
87 toolset->setByte(0x29C5, lastBlackoutMap);
88 toolset->setByte(0x2611, lastMap);
89}
90
92{
95
96 lastMap = 0;
98
99 options->textSlowness = 0;
100 options->textSlownessChanged();
101
102 options->battleStyleSet = false;
103 options->battleStyleSetChanged();
104
105 options->battleAnimOff = false;
106 options->battleAnimOffChanged();
107
108 letterDelay->normalDelay = false;
109 letterDelay->normalDelayChanged();
110
111 letterDelay->dontDelay = false;
112 letterDelay->dontDelayChanged();
113}
114
116{
117 reset();
118
119 // Map-dependent randomization disabled until the map randomizer is set up. These
120 // pick random maps via MapsDB search, but the type/city searches can come back
121 // empty (e.g. isType("Outdoor") matches 0 maps), so pickRandom() returns null and
122 // getInd() crashes. Left at the reset() default (0) so the rest of the world
123 // randomizes cleanly. Re-enable alongside the map randomizer. (Twilight-authorised,
124 // 2026-06-07.)
125 // lastBlackoutMap = MapsDB::inst()->search()->isGood()->isCity()->pickRandom()->getInd();
126 // lastBlackoutMapChanged();
127 // lastMap = MapsDB::inst()->search()->isGood()->isType("Outdoor")->pickRandom()->getInd();
128 // lastMapChanged();
129
130 // Options (text speed / battle style / battle animations / letter delay) and the
131 // last/blackout maps above are part of the Options and Maps screens, which aren't
132 // set up yet, so we don't randomize them until those screens exist. After reset()
133 // they're left at defaults. Re-enable with the Options/Maps screens.
134 // (Twilight-authorised, 2026-06-07.)
135 // options->textSlowness = Random::inst()->rangeInclusive(0, 15);
136 // options->textSlownessChanged();
137 // options->battleStyleSet = Random::inst()->chanceSuccess(20);
138 // options->battleStyleSetChanged();
139 // options->battleAnimOff = Random::inst()->chanceSuccess(20);
140 // options->battleAnimOffChanged();
141 // letterDelay->normalDelay = Random::inst()->chanceSuccess(90);
142 // letterDelay->normalDelayChanged();
143 // letterDelay->dontDelay = Random::inst()->chanceSuccess(10);
144 // letterDelay->dontDelayChanged();
145}
The text letter-printing delay flags (paired with the Options text speed).
In-game Options menu settings (text speed, battle style, animations).
void setByte(var16 addr, var8 val)
Simply sets a byte.
One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between the...
Definition savefile.h:46
SaveFileToolset * toolset
Tools to operate directly on the raw sav file data.
Definition savefile.h:117
WorldGeneral(SaveFile *saveFile=nullptr)
< Map a blackout returns you to.
virtual ~WorldGeneral()
LetterDelay * letterDelay
protected::void lastBlackoutMapChanged()
void load(SaveFile *saveFile=nullptr)
Expand general world settings from the save.
void randomize()
Randomize these settings.
void save(SaveFile *saveFile)
Flatten general world settings to the save.
Options * options
void lastMapChanged()
void reset()
Blank these settings.