Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
areageneral.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#include "areageneral.h"
23#include "../../savefile.h"
26#include <pse-common/random.h>
27#include <pse-db/mapsdb.h>
29
31{
32 load(saveFile);
33}
34
36
38{
39 reset();
40
41 if(saveFile == nullptr)
42 return;
43
44 auto toolset =saveFile->toolset;
45
46 contrast = toolset->getByte(0x2609);
48
49 noLetterDelay = toolset->getBit(0x29DC, 1, 6);
51
52 countPlaytime = toolset->getBit(0x29DE, 1, 0);
54}
55
57{
58 auto toolset =saveFile->toolset;
59
60 toolset->setByte(0x2609, contrast);
61 toolset->setBit(0x29DC, 1, 6, noLetterDelay);
62 toolset->setBit(0x29DE, 1, 0, countPlaytime);
63}
64
66{
67 contrast = 0;
69
70 noLetterDelay = false;
72
73 countPlaytime = false;
75}
76
78{
79 reset();
80
81 // Pick a number between 1 - 8
82 // That's beacuse 9 is solid black which can be fun but not very playable lol
85
86 // Leaving these options off for now
87 noLetterDelay = false;
89
90 countPlaytime = false;
92}
93
95{
96 reset();
97
98 int mapInd = (map == nullptr)
99 ? 0
100 : map->getInd();
101
102 // Set "Needs Flash" contrast level for Rock Tunnel 1 and 2, otherwise normal
103 // no flash needed
104 contrast = (mapInd == 82 || mapInd == 232)
105 ? 6
106 : 0;
108
109 // Leaving these options off for now
110 noLetterDelay = false;
112
113 countPlaytime = false;
115}
class SAVEFILE_AUTOPORT MapDBEntry
Definition areageneral.h:52
protected::void contrastChanged()
void randomize()
Randomize the flags.
void load(SaveFile *saveFile=nullptr)
Expand these flags from the save.
void setTo(MapDBEntry *map)
Set from a chosen map's defaults.
void reset()
Blank the flags.
AreaGeneral(SaveFile *saveFile=nullptr)
< Screen contrast (see ContrastIds).
bool noLetterDelay
Definition areageneral.h:90
void save(SaveFile *saveFile)
Flatten these flags to the save.
virtual ~AreaGeneral()
void noLetterDelayChanged()
void countPlaytimeChanged()
bool countPlaytime
Definition areageneral.h:91
int rangeInclusive(const int start, const int end) const
Random integer in the closed interval [start, end].
Definition random.cpp:42
static Random * inst()
< Convenience 50% coin flip (integer path), readable from QML.
Definition random.cpp:31
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
int getInd() const