Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
areamap.h
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#pragma once
17#include <QObject>
18#include <QHash>
19#include <QVector>
20
21#include <pse-common/types.h>
23
24class SaveFile;
25class MapConnData;
26struct MapDBEntry;
27
28// This value never changes, it is the in-memory value in the GB that gen 1
29// games use to store the background tilemap for the world and maps.
30constexpr var16 VramBGPtr = 0x9800;
31
43class SAVEFILE_AUTOPORT AreaMap : public QObject
44{
45 Q_OBJECT
46
47 Q_PROPERTY(int curMap MEMBER curMap NOTIFY curMapChanged)
48 Q_PROPERTY(int outOfBoundsBlock MEMBER outOfBoundsBlock NOTIFY outOfBoundsBlockChanged)
49 Q_PROPERTY(int height MEMBER height NOTIFY heightChanged)
50 Q_PROPERTY(int width MEMBER width NOTIFY widthChanged)
51 Q_PROPERTY(int height2x2 MEMBER height2x2 NOTIFY height2x2Changed)
52 Q_PROPERTY(int width2x2 MEMBER width2x2 NOTIFY width2x2Changed)
53 Q_PROPERTY(int dataPtr MEMBER dataPtr NOTIFY dataPtrChanged)
54 Q_PROPERTY(int txtPtr MEMBER txtPtr NOTIFY txtPtrChanged)
55 Q_PROPERTY(int scriptPtr MEMBER scriptPtr NOTIFY scriptPtrChanged)
58 Q_PROPERTY(int curMapScript MEMBER curMapScript NOTIFY curMapScriptChanged)
59 Q_PROPERTY(int cardKeyDoorX MEMBER cardKeyDoorX NOTIFY cardKeyDoorXChanged)
60 Q_PROPERTY(int cardKeyDoorY MEMBER cardKeyDoorY NOTIFY cardKeyDoorYChanged)
61 Q_PROPERTY(bool forceBikeRide MEMBER forceBikeRide NOTIFY forceBikeRideChanged)
62 Q_PROPERTY(bool blackoutDest MEMBER blackoutDest NOTIFY blackoutDestChanged)
63 Q_PROPERTY(bool curMapNextFrame MEMBER curMapNextFrame NOTIFY curMapNextFrameChanged)
64
65public:
66 AreaMap(SaveFile* saveFile = nullptr);
67 virtual ~AreaMap();
68
69 void load(SaveFile* saveFile = nullptr);
70 void save(SaveFile* saveFile);
71
73 int coordsToPtr(int x, int y, int width);
74
75 Q_INVOKABLE int connCount();
76 Q_INVOKABLE MapConnData* connAt(int dir);
77 Q_INVOKABLE void connRemove(int dir);
78 Q_INVOKABLE void connNew(int dir);
79
81
82signals:
101
102public slots:
103 void reset();
104 void randomize(MapDBEntry* map, int x, int y);
105 void setTo(MapDBEntry* map, int x, int y);
106
107public:
110
115
118 int width;
121
126
127 // Map extra pointers
130
133
137
142
143 // Map Connections
144 // So here's the thing, QHash technically can be a Q_PROPERTY but because of
145 // the template comma it freaks the IDE out and throws a ton of errors. It
146 // compiles just fine, but I can't handle all the red errors the IDE gives
147 QHash<var8, MapConnData*> connections;
148};
constexpr var16 VramBGPtr
Fixed GB VRAM background-tilemap pointer (never changes).
Definition areamap.h:30
void forceBikeRideChanged()
void setTo(MapDBEntry *map, int x, int y)
Configure to map with the player at (x,y).
Definition areamap.cpp:346
void mapViewVRAMPointerChanged()
void cardKeyDoorYChanged()
int height
Map Size including it's double size.
Definition areamap.h:117
int mapViewVRAMPointer
<- Unused, reset at start of gameplay
Definition areamap.h:129
void blackoutDestChanged()
void height2x2Changed()
bool blackoutDest
Definition areamap.h:140
void widthChanged()
protected::void curMapChanged()
void cardKeyDoorXChanged()
int connCount()
Number of edge connections.
Definition areamap.cpp:45
int currentTileBlockMapViewPointer
<- Player coords converted to a ptr
Definition areamap.h:128
int scriptPtr
Definition areamap.h:125
bool forceBikeRide
Flags that may not be used, unknown.
Definition areamap.h:139
void connRemove(int dir)
Remove the connection in dir.
Definition areamap.cpp:55
int cardKeyDoorX
Unknown ???
Definition areamap.h:135
MapDBEntry * toCurMap()
The current map's DB entry.
Definition areamap.cpp:72
int coordsToPtr(int x, int y, int width)
Converts X & Y values to a pointer for currentTileBlockMapViewPointer.
Definition areamap.cpp:353
int width2x2
Definition areamap.h:120
void scriptPtrChanged()
void load(SaveFile *saveFile=nullptr)
Expand the map block from the save.
Definition areamap.cpp:77
void curMapScriptChanged()
void connNew(int dir)
Add a connection in dir.
Definition areamap.cpp:65
void width2x2Changed()
int outOfBoundsBlock
This is not a tile, it's a block.
Definition areamap.h:114
void outOfBoundsBlockChanged()
QHash< var8, MapConnData * > connections
Edge connections by direction (see the IDE note above).
Definition areamap.h:147
int width
Definition areamap.h:118
int curMap
Current Map ID.
Definition areamap.h:109
void save(SaveFile *saveFile)
Flatten the map block to the save.
Definition areamap.cpp:162
void txtPtrChanged()
void curMapNextFrameChanged()
int cardKeyDoorY
Definition areamap.h:136
void dataPtrChanged()
void currentTileBlockMapViewPointerChanged()
AreaMap(SaveFile *saveFile=nullptr)
< Current map id.
Definition areamap.cpp:34
MapConnData * connAt(int dir)
Connection in direction dir (GC-protected return).
Definition areamap.cpp:50
void reset()
Blank the map block.
Definition areamap.cpp:203
int curMapScript
Current map script index.
Definition areamap.h:132
bool curMapNextFrame
Definition areamap.h:141
void heightChanged()
void randomize(MapDBEntry *map, int x, int y)
Randomize to map with the player at (x,y).
Definition areamap.cpp:270
void connectionsChanged()
int txtPtr
Definition areamap.h:124
int height2x2
Definition areamap.h:119
int dataPtr
Map basic pointers.
Definition areamap.h:123
One edge connection of the current map (the seam to a neighbouring map).
Definition mapconndata.h:37
One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between the...
Definition savefile.h:46
Project-wide fixed-width integer aliases (var8, var16, ...).
var16e var16
Everyday 16-bit alias. Exact width to avoid the "fastest" widening bug.
Definition types.h:125
Import/export macro for the savefile library, plus the central list of QObject types kept deliberatel...
#define SAVEFILE_AUTOPORT
Expands to the correct dllexport/dllimport decoration for this library.
One map's complete static definition – the root of the MapDBEntry family.
Definition mapdbentry.h:56