Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
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
"
24
#include "
../../savefiletoolset.h
"
25
#include "
../../savefileiterator.h
"
26
#include <
pse-common/random.h
>
27
#include <
pse-db/mapsdb.h
>
28
#include <
pse-db/entries/mapdbentry.h
>
29
30
AreaGeneral::AreaGeneral
(
SaveFile
* saveFile)
31
{
32
load
(saveFile);
33
}
34
35
AreaGeneral::~AreaGeneral
() {}
36
37
void
AreaGeneral::load
(
SaveFile
* saveFile)
38
{
39
reset
();
40
41
if
(saveFile ==
nullptr
)
42
return
;
43
44
auto
toolset =saveFile->
toolset
;
45
46
contrast
= toolset->getByte(0x2609);
47
contrastChanged
();
48
49
noLetterDelay
= toolset->getBit(0x29DC, 1, 6);
50
noLetterDelayChanged
();
51
52
countPlaytime
= toolset->getBit(0x29DE, 1, 0);
53
countPlaytimeChanged
();
54
}
55
56
void
AreaGeneral::save
(
SaveFile
* saveFile)
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
65
void
AreaGeneral::reset
()
66
{
67
contrast
= 0;
68
contrastChanged
();
69
70
noLetterDelay
=
false
;
71
noLetterDelayChanged
();
72
73
countPlaytime
=
false
;
74
countPlaytimeChanged
();
75
}
76
77
void
AreaGeneral::randomize
()
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
83
contrast
=
Random::inst
()->
rangeInclusive
(0, 8);
84
contrastChanged
();
85
86
// Leaving these options off for now
87
noLetterDelay
=
false
;
88
noLetterDelayChanged
();
89
90
countPlaytime
=
false
;
91
countPlaytimeChanged
();
92
}
93
94
void
AreaGeneral::setTo
(
MapDBEntry
* map)
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;
107
contrastChanged
();
108
109
// Leaving these options off for now
110
noLetterDelay
=
false
;
111
noLetterDelayChanged
();
112
113
countPlaytime
=
false
;
114
countPlaytimeChanged
();
115
}
areageneral.h
MapDBEntry
class SAVEFILE_AUTOPORT MapDBEntry
Definition
areageneral.h:52
AreaGeneral::contrastChanged
protected::void contrastChanged()
AreaGeneral::randomize
void randomize()
Randomize the flags.
Definition
areageneral.cpp:77
AreaGeneral::load
void load(SaveFile *saveFile=nullptr)
Expand these flags from the save.
Definition
areageneral.cpp:37
AreaGeneral::setTo
void setTo(MapDBEntry *map)
Set from a chosen map's defaults.
Definition
areageneral.cpp:94
AreaGeneral::reset
void reset()
Blank the flags.
Definition
areageneral.cpp:65
AreaGeneral::AreaGeneral
AreaGeneral(SaveFile *saveFile=nullptr)
< Screen contrast (see ContrastIds).
Definition
areageneral.cpp:30
AreaGeneral::contrast
int contrast
Definition
areageneral.h:89
AreaGeneral::noLetterDelay
bool noLetterDelay
Definition
areageneral.h:90
AreaGeneral::save
void save(SaveFile *saveFile)
Flatten these flags to the save.
Definition
areageneral.cpp:56
AreaGeneral::~AreaGeneral
virtual ~AreaGeneral()
Definition
areageneral.cpp:35
AreaGeneral::noLetterDelayChanged
void noLetterDelayChanged()
AreaGeneral::countPlaytimeChanged
void countPlaytimeChanged()
AreaGeneral::countPlaytime
bool countPlaytime
Definition
areageneral.h:91
Random::rangeInclusive
int rangeInclusive(const int start, const int end) const
Random integer in the closed interval [start, end].
Definition
random.cpp:42
Random::inst
static Random * inst()
< Convenience 50% coin flip (integer path), readable from QML.
Definition
random.cpp:31
SaveFileToolset::setByte
void setByte(var16 addr, var8 val)
Simply sets a byte.
Definition
savefiletoolset.cpp:237
SaveFile
One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between the...
Definition
savefile.h:46
SaveFile::toolset
SaveFileToolset * toolset
Tools to operate directly on the raw sav file data.
Definition
savefile.h:117
mapdbentry.h
mapsdb.h
random.h
savefile.h
savefileiterator.h
savefiletoolset.h
MapDBEntry::getInd
int getInd() const
Definition
mapdbentry.cpp:582
projects
savefile
src
pse-savefile
expanded
area
areageneral.cpp
Generated by
1.17.0