Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
Loading...
Searching...
No Matches
mapdbentryconnect.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 <QString>
19
#include <QJsonValue>
20
#include "
../db_autoport.h
"
21
22
class
MapDBEntry
;
23
class
QQmlEngine;
24
class
MapDBEntry
;
25
26
/*
27
* A forewarning!!
28
*
29
* Map Connections are one of the most complicated aspects of the entire game
30
* by far and large. Out of any gen 1 data structure, forumlas, algorithms, math
31
* etc... Virtually out of anythign within the game code, this is the most
32
* complicated part. Anyone I've talked to and most docs I've read have all
33
* been in agreement. It's also one of the most difficult to get right and the
34
* most difficult to understand.
35
*
36
* If anything is slightly wrong, the game will liekly crash quickly or at the
37
* least not work right. So... yea... that's why it's inclusion is so late in
38
* this app and the reason why I've been so hesitant to bring in this
39
* functionality.
40
*
41
* Sources to help me:
42
*
43
* PokeRed Team
44
* https://github.com/pret/pokered/blob/master/macros/data_macros.asm
45
*
46
* Bulbapedia User Tiddlywinks
47
* https://bulbapedia.bulbagarden.net/wiki/User:Tiddlywinks/Map_header_data_structure_in_Generation_I
48
*/
60
struct
DB_AUTOPORT
MapDBEntryConnect
:
public
QObject {
61
Q_OBJECT
62
Q_PROPERTY(
int
stripLocation
READ
stripLocation
CONSTANT)
63
Q_PROPERTY(
int
mapPos
READ
mapPos
CONSTANT)
64
Q_PROPERTY(
int
stripSize
READ
stripSize
CONSTANT)
65
Q_PROPERTY(
int
yAlign
READ
yAlign
CONSTANT)
66
Q_PROPERTY(
int
xAlign
READ
xAlign
CONSTANT)
67
Q_PROPERTY(
int
window
READ
window
CONSTANT)
68
Q_PROPERTY(
ConnectDir
getDir
READ
getDir
CONSTANT)
69
Q_PROPERTY(QString
getMap
READ
getMap
CONSTANT)
70
Q_PROPERTY(
int
getStripMove
READ
getStripMove
CONSTANT)
71
Q_PROPERTY(
int
getStripOffset
READ
getStripOffset
CONSTANT)
72
Q_PROPERTY(
bool
getFlag
READ
getFlag
CONSTANT)
73
Q_PROPERTY(
MapDBEntry
*
getToMap
READ
getToMap
CONSTANT)
74
Q_PROPERTY(
MapDBEntry
*
getFromMap
READ
getFromMap
CONSTANT)
75
Q_PROPERTY(
MapDBEntry
*
getParent
READ
getParent
CONSTANT)
76
77
public
:
78
// Hard-Coded value, this is the value that the gen 1 games use, it refers
79
// to a ram address that never changes related to the overworld map
80
static
const
constexpr
int
worldMapPtr
= 0xC6E8;
81
83
enum
ConnectDir
84
{
85
NORTH
,
86
SOUTH
,
87
EAST
,
88
WEST
89
};
90
Q_ENUM(ConnectDir)
91
92
// Location of strip
93
// Pointer to start in connected map
94
// AKA Strip Source
95
int
stripLocation()
const
;
96
97
// Map Position
98
// Pointer to start of connection
99
// AKA Strip Dst
100
int
mapPos()
const
;
101
102
// Strip Size
103
// Connection size (blocks)
104
// AKA stripWidth
105
int
stripSize()
const
;
106
107
// Player Pos
108
// Player Y & X Offset (steps)
109
// AKA X-Align/Y-Align
110
int
yAlign()
const
;
111
int
xAlign()
const
;
112
113
// Map VRAM Offset
114
// Pointer to window
115
// AKA => viewPtr & UL Corner
116
int
window()
const
;
117
118
ConnectDir getDir()
const
;
119
const
QString getMap()
const
;
120
int
getStripMove()
const
;
121
int
getStripOffset()
const
;
122
bool
getFlag()
const
;
123
MapDBEntry
* getToMap()
const
;
124
MapDBEntry
* getFromMap()
const
;
125
MapDBEntry
* getParent()
const
;
126
127
public
slots:
128
void
qmlProtect(
const
QQmlEngine*
const
engine)
const
;
129
130
protected
:
131
MapDBEntryConnect
();
132
MapDBEntryConnect
(
const
ConnectDir dir,
133
MapDBEntry
*
const
fromMap,
134
const
QJsonValue& data);
135
void
deepLink();
136
void
qmlRegister()
const
;
137
138
// Direction used in calculating
139
ConnectDir
dir
=
ConnectDir::NORTH
;
140
141
// Connecting Map
142
QString
map
=
""
;
143
144
// Connecting Strip Centering
145
int
stripMove
= 0;
146
147
// Connecting Strip Position
148
int
stripOffset
= 0;
149
150
// Offset strip by an additional 3 for unknown
151
// reasons
152
bool
flag
=
false
;
153
154
// To connecting map
155
MapDBEntry
*
toMap
=
nullptr
;
156
157
// Map with connection
158
MapDBEntry
*
fromMap
=
nullptr
;
159
MapDBEntry
*
parent
=
nullptr
;
// Basically the same thing, just an alias
160
161
friend
class
MapDBEntry
;
162
};
db_autoport.h
Import/export macro for the db library, plus the central list of DB entry pointer types declared opaq...
DB_AUTOPORT
#define DB_AUTOPORT
Expands to the correct dllexport/dllimport decoration for this library.
Definition
db_autoport.h:37
MapDBEntryConnect
One edge connection of a map (the seam to a neighbouring map).
Definition
mapdbentryconnect.h:60
MapDBEntryConnect::getStripOffset
int getStripOffset() const
Definition
mapdbentryconnect.cpp:98
MapDBEntryConnect::getMap
const QString getMap() const
Definition
mapdbentryconnect.cpp:113
MapDBEntryConnect::toMap
MapDBEntry * toMap
Resolved connected map (deepLink).
Definition
mapdbentryconnect.h:155
MapDBEntryConnect::flag
bool flag
+3 offset flag (purpose unknown; see note).
Definition
mapdbentryconnect.h:152
MapDBEntryConnect::MapDBEntry
friend class MapDBEntry
Definition
mapdbentryconnect.h:161
MapDBEntryConnect::worldMapPtr
static const constexpr int worldMapPtr
< Strip source pointer.
Definition
mapdbentryconnect.h:80
MapDBEntryConnect::stripOffset
int stripOffset
Strip position.
Definition
mapdbentryconnect.h:148
MapDBEntryConnect::mapPos
int mapPos() const
Definition
mapdbentryconnect.cpp:151
MapDBEntryConnect::stripSize
int stripSize() const
Definition
mapdbentryconnect.cpp:178
MapDBEntryConnect::dir
ConnectDir dir
Edge direction.
Definition
mapdbentryconnect.h:139
MapDBEntryConnect::xAlign
int xAlign() const
Definition
mapdbentryconnect.cpp:257
MapDBEntryConnect::stripMove
int stripMove
Strip centering.
Definition
mapdbentryconnect.h:145
MapDBEntryConnect::getStripMove
int getStripMove() const
Definition
mapdbentryconnect.cpp:103
MapDBEntryConnect::fromMap
MapDBEntry * fromMap
Owning map.
Definition
mapdbentryconnect.h:158
MapDBEntryConnect::getFlag
bool getFlag() const
Definition
mapdbentryconnect.cpp:93
MapDBEntryConnect::window
int window() const
Definition
mapdbentryconnect.cpp:288
MapDBEntryConnect::map
QString map
Connected map name.
Definition
mapdbentryconnect.h:142
MapDBEntryConnect::stripLocation
int stripLocation() const
Definition
mapdbentryconnect.cpp:118
MapDBEntryConnect::yAlign
int yAlign() const
Definition
mapdbentryconnect.cpp:232
MapDBEntryConnect::getToMap
MapDBEntry * getToMap() const
Definition
mapdbentryconnect.cpp:88
MapDBEntryConnect::parent
MapDBEntry * parent
Definition
mapdbentryconnect.h:159
MapDBEntryConnect::getParent
MapDBEntry * getParent() const
Definition
mapdbentryconnect.cpp:73
MapDBEntryConnect::getDir
ConnectDir getDir() const
Definition
mapdbentryconnect.cpp:108
MapDBEntryConnect::getFromMap
MapDBEntry * getFromMap() const
Definition
mapdbentryconnect.cpp:83
MapDBEntryConnect::ConnectDir
ConnectDir
The four connectable edges.
Definition
mapdbentryconnect.h:84
MapDBEntryConnect::SOUTH
@ SOUTH
Definition
mapdbentryconnect.h:86
MapDBEntryConnect::NORTH
@ NORTH
Definition
mapdbentryconnect.h:85
MapDBEntryConnect::EAST
@ EAST
Definition
mapdbentryconnect.h:87
MapDBEntryConnect::WEST
@ WEST
Definition
mapdbentryconnect.h:88
MapDBEntryConnect::MapDBEntryConnect
MapDBEntryConnect()
Empty entry.
Definition
mapdbentryconnect.cpp:30
MapDBEntry
One map's complete static definition – the root of the MapDBEntry family.
Definition
mapdbentry.h:56
projects
db
src
pse-db
entries
mapdbentryconnect.h
Generated by
1.17.0