Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
Loading...
Searching...
No Matches
areanpc.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 "
./areanpc.h
"
23
#include "
../../savefile.h
"
24
#include "
../../savefiletoolset.h
"
25
#include "
../../savefileiterator.h
"
26
#include <
pse-db/mapsdb.h
>
27
28
AreaNPC::AreaNPC
(
SaveFile
* saveFile)
29
{
30
load
(saveFile);
31
}
32
33
AreaNPC::~AreaNPC
() {}
34
35
void
AreaNPC::load
(
SaveFile
* saveFile)
36
{
37
reset
();
38
39
if
(saveFile ==
nullptr
)
40
return
;
41
42
auto
toolset = saveFile->
toolset
;
43
44
tradeCenterSpritesFaced
= toolset->getBit(0x29D9, 1, 0);
45
tradeCenterSpritesFacedChanged
();
46
47
npcsFaceAway
= toolset->getBit(0x29D9, 1, 5);
48
npcsFaceAwayChanged
();
49
50
scriptedNPCMovement
= toolset->getBit(0x29DA, 1, 7);
51
scriptedNPCMovementChanged
();
52
53
npcSpriteMovement
= toolset->getBit(0x29DC, 1, 0);
54
npcSpriteMovementChanged
();
55
56
ignoreJoypad
= toolset->getBit(0x29DC, 1, 5);
57
ignoreJoypadChanged
();
58
59
joypadSimulation
= toolset->getBit(0x29DC, 1, 7);
60
joypadSimulationChanged
();
61
62
runningTestBattle
= toolset->getBit(0x29DF, 1, 0);
63
runningTestBattleChanged
();
64
65
trainerWantsBattle
= toolset->getBit(0x29DF, 1, 3);
66
trainerWantsBattleChanged
();
67
68
trainerHeaderPtr
= toolset->getWord(0x2CDC,
true
);
69
trainerHeaderPtrChanged
();
70
}
71
72
void
AreaNPC::save
(
SaveFile
* saveFile)
73
{
74
auto
toolset = saveFile->
toolset
;
75
76
toolset->
setBit
(0x29D9, 1, 0,
tradeCenterSpritesFaced
);
77
toolset->setBit(0x29D9, 1, 5,
npcsFaceAway
);
78
toolset->setBit(0x29DA, 1, 7,
scriptedNPCMovement
);
79
toolset->setBit(0x29DC, 1, 0,
npcSpriteMovement
);
80
toolset->setBit(0x29DC, 1, 5,
ignoreJoypad
);
81
toolset->setBit(0x29DC, 1, 7,
joypadSimulation
);
82
toolset->setBit(0x29DF, 1, 0,
runningTestBattle
);
83
toolset->setBit(0x29DF, 1, 3,
trainerWantsBattle
);
84
toolset->setWord(0x2CDC,
trainerHeaderPtr
,
true
);
85
}
86
87
void
AreaNPC::reset
()
88
{
89
// Sprites
90
npcsFaceAway
=
false
;
91
npcsFaceAwayChanged
();
92
93
scriptedNPCMovement
=
false
;
94
scriptedNPCMovementChanged
();
95
96
npcSpriteMovement
=
false
;
97
npcSpriteMovementChanged
();
98
99
tradeCenterSpritesFaced
=
false
;
100
tradeCenterSpritesFacedChanged
();
101
102
// Controls
103
ignoreJoypad
=
false
;
104
ignoreJoypadChanged
();
105
106
joypadSimulation
=
false
;
107
joypadSimulationChanged
();
108
109
// Battle
110
runningTestBattle
=
false
;
111
runningTestBattleChanged
();
112
113
trainerWantsBattle
=
false
;
114
trainerWantsBattleChanged
();
115
116
trainerHeaderPtr
= 0;
117
trainerHeaderPtrChanged
();
118
}
119
120
// Don't do any randomization, I can't think of a single benefit to checking
121
// any of these randomly apart from potentially crashing the game or other
122
// quirks that wouldn't be random fun. Random is about creating a random map
123
// that's fun and sometimes challenging to jump in. If it just crashed the game
124
// then it wouldn't be used very much
125
void
AreaNPC::randomize
()
126
{
127
reset
();
128
}
129
130
void
AreaNPC::setTo
(
MapDBEntry
* map)
131
{
132
Q_UNUSED(map)
133
reset
();
134
}
areanpc.h
AreaNPC::npcSpriteMovement
bool npcSpriteMovement
Definition
areanpc.h:75
AreaNPC::trainerWantsBattleChanged
void trainerWantsBattleChanged()
AreaNPC::tradeCenterSpritesFacedChanged
void tradeCenterSpritesFacedChanged()
AreaNPC::npcsFaceAway
bool npcsFaceAway
Definition
areanpc.h:73
AreaNPC::load
void load(SaveFile *saveFile=nullptr)
Expand these flags from the save.
Definition
areanpc.cpp:35
AreaNPC::AreaNPC
AreaNPC(SaveFile *saveFile=nullptr)
< NPCs face away from the player.
Definition
areanpc.cpp:28
AreaNPC::trainerHeaderPtrChanged
void trainerHeaderPtrChanged()
AreaNPC::ignoreJoypad
bool ignoreJoypad
Definition
areanpc.h:79
AreaNPC::~AreaNPC
virtual ~AreaNPC()
Definition
areanpc.cpp:33
AreaNPC::randomize
void randomize()
Randomize the flags.
Definition
areanpc.cpp:125
AreaNPC::npcSpriteMovementChanged
void npcSpriteMovementChanged()
AreaNPC::scriptedNPCMovementChanged
void scriptedNPCMovementChanged()
AreaNPC::ignoreJoypadChanged
void ignoreJoypadChanged()
AreaNPC::npcsFaceAwayChanged
protected::void npcsFaceAwayChanged()
AreaNPC::joypadSimulationChanged
void joypadSimulationChanged()
AreaNPC::scriptedNPCMovement
bool scriptedNPCMovement
Definition
areanpc.h:74
AreaNPC::trainerWantsBattle
bool trainerWantsBattle
Definition
areanpc.h:84
AreaNPC::runningTestBattle
bool runningTestBattle
Definition
areanpc.h:83
AreaNPC::trainerHeaderPtr
int trainerHeaderPtr
Definition
areanpc.h:85
AreaNPC::joypadSimulation
bool joypadSimulation
Definition
areanpc.h:80
AreaNPC::save
void save(SaveFile *saveFile)
Flatten these flags to the save.
Definition
areanpc.cpp:72
AreaNPC::reset
void reset()
Blank the flags.
Definition
areanpc.cpp:87
AreaNPC::tradeCenterSpritesFaced
bool tradeCenterSpritesFaced
Definition
areanpc.h:76
AreaNPC::runningTestBattleChanged
void runningTestBattleChanged()
AreaNPC::setTo
void setTo(MapDBEntry *map)
Set from a chosen map's defaults.
Definition
areanpc.cpp:130
SaveFileToolset::setBit
void setBit(var16 addr, var8 size, var8 bit, bool value, bool reverse=false)
Set a bit into a value.
Definition
savefiletoolset.cpp:183
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
mapsdb.h
savefile.h
savefileiterator.h
savefiletoolset.h
MapDBEntry
One map's complete static definition – the root of the MapDBEntry family.
Definition
mapdbentry.h:56
projects
savefile
src
pse-savefile
expanded
area
areanpc.cpp
Generated by
1.17.0