Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
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"
26#include <pse-db/mapsdb.h>
27
29{
30 load(saveFile);
31}
32
34
35void 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);
46
47 npcsFaceAway = toolset->getBit(0x29D9, 1, 5);
49
50 scriptedNPCMovement = toolset->getBit(0x29DA, 1, 7);
52
53 npcSpriteMovement = toolset->getBit(0x29DC, 1, 0);
55
56 ignoreJoypad = toolset->getBit(0x29DC, 1, 5);
58
59 joypadSimulation = toolset->getBit(0x29DC, 1, 7);
61
62 runningTestBattle = toolset->getBit(0x29DF, 1, 0);
64
65 trainerWantsBattle = toolset->getBit(0x29DF, 1, 3);
67
68 trainerHeaderPtr = toolset->getWord(0x2CDC, true);
70}
71
72void 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
88{
89 // Sprites
90 npcsFaceAway = false;
92
93 scriptedNPCMovement = false;
95
96 npcSpriteMovement = false;
98
101
102 // Controls
103 ignoreJoypad = false;
105
106 joypadSimulation = false;
108
109 // Battle
110 runningTestBattle = false;
112
113 trainerWantsBattle = false;
115
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
126{
127 reset();
128}
129
131{
132 Q_UNUSED(map)
133 reset();
134}
bool npcSpriteMovement
Definition areanpc.h:75
void trainerWantsBattleChanged()
void tradeCenterSpritesFacedChanged()
bool npcsFaceAway
Definition areanpc.h:73
void load(SaveFile *saveFile=nullptr)
Expand these flags from the save.
Definition areanpc.cpp:35
AreaNPC(SaveFile *saveFile=nullptr)
< NPCs face away from the player.
Definition areanpc.cpp:28
void trainerHeaderPtrChanged()
bool ignoreJoypad
Definition areanpc.h:79
virtual ~AreaNPC()
Definition areanpc.cpp:33
void randomize()
Randomize the flags.
Definition areanpc.cpp:125
void npcSpriteMovementChanged()
void scriptedNPCMovementChanged()
void ignoreJoypadChanged()
protected::void npcsFaceAwayChanged()
void joypadSimulationChanged()
bool scriptedNPCMovement
Definition areanpc.h:74
bool trainerWantsBattle
Definition areanpc.h:84
bool runningTestBattle
Definition areanpc.h:83
int trainerHeaderPtr
Definition areanpc.h:85
bool joypadSimulation
Definition areanpc.h:80
void save(SaveFile *saveFile)
Flatten these flags to the save.
Definition areanpc.cpp:72
void reset()
Blank the flags.
Definition areanpc.cpp:87
bool tradeCenterSpritesFaced
Definition areanpc.h:76
void runningTestBattleChanged()
void setTo(MapDBEntry *map)
Set from a chosen map's defaults.
Definition areanpc.cpp:130
void setBit(var16 addr, var8 size, var8 bit, bool value, bool reverse=false)
Set a bit into a value.
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
One map's complete static definition – the root of the MapDBEntry family.
Definition mapdbentry.h:56