1+ #pragma once
2+ #include " Model.hpp"
3+
4+ #include < cstdint>
5+ #include < optional>
6+ #include < string_view>
7+ #include < vector>
8+ #include < filesystem>
9+
10+ // structs
11+ struct DigimonPara
12+ {
13+ char name[20 ];
14+ int32_t boneCount;
15+ int16_t radius;
16+ int16_t height;
17+ uint8_t type;
18+ uint8_t level;
19+ uint8_t special[3 ];
20+ uint8_t dropItem;
21+ uint8_t dropChance;
22+ int8_t moves[16 ];
23+ uint8_t padding;
24+ };
25+
26+ struct DigimonParaPAL
27+ {
28+ int32_t boneCount;
29+ int16_t radius;
30+ int16_t height;
31+ uint8_t type;
32+ uint8_t level;
33+ uint8_t special[3 ];
34+ uint8_t dropItem;
35+ uint8_t dropChance;
36+ int8_t moves[16 ];
37+ uint8_t padding;
38+ };
39+
40+ static_assert (sizeof (DigimonPara) == 52 );
41+ static_assert (sizeof (DigimonParaPAL) == 32 );
42+
43+ struct VersionData
44+ {
45+ std::string_view psexePath;
46+ std::string_view alltimPath;
47+ uint32_t nameOffset;
48+ uint32_t paraOffset;
49+ uint32_t skelOffset;
50+ uint32_t mapEntryOffset;
51+ uint32_t mapNamePtrOffset;
52+ uint32_t toiletDataOffset;
53+ uint32_t doorDataOffset;
54+ bool isPAL;
55+ };
56+
57+ struct MMDTexture
58+ {
59+ uint8_t buffer[0x4800 ];
60+ };
61+
62+ struct DigimonEntry
63+ {
64+ std::string filename;
65+ std::vector<NodeEntry> skeleton;
66+ std::vector<uint8_t > texture;
67+ };
68+
69+
70+
71+ struct ToiletData
72+ {
73+ int16_t x1;
74+ int16_t y1;
75+ int16_t x2;
76+ int16_t y2;
77+ };
78+
79+ struct MapEntryFlags
80+ {
81+ uint8_t soundId : 5 ;
82+ uint8_t : 1 ; // padding
83+ bool hasNoTimeCycle : 1 ;
84+ bool hasDigimon : 1 ;
85+ };
86+
87+ static_assert (sizeof (MapEntryFlags) == 1 );
88+
89+ struct MapEntryData
90+ {
91+ char name[10 ];
92+ uint8_t numMapImages;
93+ uint8_t numMapObjects;
94+ MapEntryFlags flags;
95+ uint8_t doorsId;
96+ uint8_t toiletId;
97+ uint8_t loadingNameId;
98+ };
99+
100+ struct DoorData
101+ {
102+ uint8_t modelId[6 ];
103+ int16_t posX[6 ];
104+ int16_t posY[6 ];
105+ int16_t posZ[6 ];
106+ int16_t rotation[6 ];
107+ };
108+
109+ struct MapEntry
110+ {
111+ MapEntryData data;
112+ std::string name;
113+ std::optional<ToiletData> toilet;
114+ std::optional<DoorData> doors;
115+ };
116+
117+ static_assert (sizeof (MapEntryData) == 0x10 );
118+
119+ // TODO map entry data
120+ // data
121+ /*
122+ * name para skel mapEntry mapName toilets doors
123+ * SLUS_010.32 0x133B44 0x12CEB4 0x11ce60 0x1292d4 0x1291bc 0x122e10 0x122e60
124+ * SLPS_017.97 0x13d844 0x13b344 0x123780 (1.1)
125+ * SLPS_017.97 0x13CE24 0x13A924 0x122E68 (1.0)
126+ * SLPM_804.02 0x13e874 0x13c32c 0x124728
127+ * SLES_029.14 0x13AC0C 0x138B5C 0x122DD4
128+ * SLES_034.34 0x13AE00 0x138D50 0x122DE4
129+ * SLES_034.35 0x13ADD8 0x138D28 0x122D6C
130+ * SLES_034.36 0x13B7E4 0x139734 0x122DA0
131+ * SLES_034.37 0x13B314 0x139264 0x122DA0
132+ */
133+ constexpr uint32_t PSEXE_OFFSET (uint32_t offset) { return (offset - 0x90000 ) & 0x7FFFFFFF ; }
134+
135+ constexpr VersionData SLUS_DATA = {
136+ .psexePath = " SLUS_010.32" ,
137+ .alltimPath = " CHDAT/ALLTIM.TIM" ,
138+ .nameOffset = PSEXE_OFFSET (0x133b44 ),
139+ .paraOffset = PSEXE_OFFSET (0x12ceb4 ),
140+ .skelOffset = PSEXE_OFFSET (0x11ce60 ),
141+ .mapEntryOffset = PSEXE_OFFSET (0x1292d4 ),
142+ .mapNamePtrOffset = PSEXE_OFFSET (0x1291bc ),
143+ .toiletDataOffset = PSEXE_OFFSET (0x122e10 ),
144+ .doorDataOffset = PSEXE_OFFSET (0x122e60 ),
145+ .isPAL = false ,
146+ };
147+
148+ constexpr VersionData SLPS_11_DATA = {
149+ .psexePath = " SLPS_017.97" ,
150+ .alltimPath = " CHDAT/ALLTIM.TIM" ,
151+ .nameOffset = PSEXE_OFFSET (0x13d844 ),
152+ .paraOffset = PSEXE_OFFSET (0x13b344 ),
153+ .skelOffset = PSEXE_OFFSET (0x123780 ),
154+ .isPAL = false ,
155+ };
156+
157+ constexpr VersionData SLPS_10_DATA = {
158+ .psexePath = " SLPS_017.97" ,
159+ .alltimPath = " CHDAT/ALLTIM.TIM" ,
160+ .nameOffset = PSEXE_OFFSET (0x13ce24 ),
161+ .paraOffset = PSEXE_OFFSET (0x13a924 ),
162+ .skelOffset = PSEXE_OFFSET (0x122e68 ),
163+ .isPAL = false ,
164+ };
165+
166+ constexpr VersionData SLPM_DATA = {
167+ .psexePath = " SLPM_804.02" ,
168+ .alltimPath = " CHDAT/ALLTIM.TIM" ,
169+ .nameOffset = PSEXE_OFFSET (0x13e874 ),
170+ .paraOffset = PSEXE_OFFSET (0x13c32c ),
171+ .skelOffset = PSEXE_OFFSET (0x124728 ),
172+ .isPAL = false ,
173+ };
174+
175+ constexpr VersionData SLES02914_DATA = {
176+ .psexePath = " SLES_029.14" ,
177+ .alltimPath = " CHDAT/ALLTIM.TIM" ,
178+ .nameOffset = PSEXE_OFFSET (0x13ac0c ),
179+ .paraOffset = PSEXE_OFFSET (0x138b5c ),
180+ .skelOffset = PSEXE_OFFSET (0x122dd4 ),
181+ .isPAL = true ,
182+ };
183+
184+ constexpr VersionData SLES03434_DATA = {
185+ .psexePath = " SLES_034.34" ,
186+ .alltimPath = " CHDAT/ALLTIM.TIM" ,
187+ .nameOffset = PSEXE_OFFSET (0x13ae00 ),
188+ .paraOffset = PSEXE_OFFSET (0x138d50 ),
189+ .skelOffset = PSEXE_OFFSET (0x122de4 ),
190+ .isPAL = true ,
191+ };
192+
193+ constexpr VersionData SLES03435_DATA = {
194+ .psexePath = " SLES_034.35" ,
195+ .alltimPath = " CHDAT/ALLTIM.TIM" ,
196+ .nameOffset = PSEXE_OFFSET (0x13add8 ),
197+ .paraOffset = PSEXE_OFFSET (0x138d28 ),
198+ .skelOffset = PSEXE_OFFSET (0x122d6c ),
199+ .isPAL = true ,
200+ };
201+
202+ constexpr VersionData SLES03436_DATA = {
203+ .psexePath = " SLES_034.36" ,
204+ .alltimPath = " CHDAT/ALLTIM.TIM" ,
205+ .nameOffset = PSEXE_OFFSET (0x13b7e4 ),
206+ .paraOffset = PSEXE_OFFSET (0x139734 ),
207+ .skelOffset = PSEXE_OFFSET (0x122da0 ),
208+ .isPAL = true ,
209+ };
210+
211+ constexpr VersionData SLES03437_DATA = {
212+ .psexePath = " SLES_034.37" ,
213+ .alltimPath = " CHDAT/ALLTIM.TIM" ,
214+ .nameOffset = PSEXE_OFFSET (0x13b314 ),
215+ .paraOffset = PSEXE_OFFSET (0x139264 ),
216+ .skelOffset = PSEXE_OFFSET (0x122da0 ),
217+ .isPAL = true ,
218+ };
219+
220+ constexpr VersionData VERSION_DATA[] = { SLUS_DATA, SLPS_11_DATA, SLPS_10_DATA, SLPM_DATA, SLES02914_DATA,
221+ SLES03434_DATA, SLES03435_DATA, SLES03436_DATA, SLES03437_DATA };
222+ // functions
223+
224+ VersionData getVersion (std::filesystem::path parentPath);
225+ std::vector<DigimonEntry> loadDigimonEntries (std::filesystem::path parentPath);
226+ std::array<MapEntry, 255 > getMapEntries (std::filesystem::path parentPath);
0 commit comments