yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
overworld_version_helper.h
Go to the documentation of this file.
1#ifndef YAZE_ZELDA3_OVERWORLD_VERSION_HELPER_H
2#define YAZE_ZELDA3_OVERWORLD_VERSION_HELPER_H
3
4#include <cstdint>
5
6#include "rom/rom.h"
7#include "zelda3/common.h"
8
9namespace yaze::zelda3 {
10
11// =============================================================================
12// ZSCustomOverworld Version System
13// =============================================================================
14//
15// OVERVIEW:
16// ---------
17// ZSCustomOverworld is an ASM patch system that extends the overworld
18// capabilities of A Link to the Past ROMs. This header provides centralized
19// version detection to enable feature gating throughout the editor.
20//
21// VERSION HISTORY:
22// ----------------
23// - Vanilla (0xFF/0x00): Original game, no patches applied
24// - v1: Basic expanded pointers for map data overflow
25// - v2: Custom BG colors per area, main palette selection
26// - v3: Area enum system, wide/tall areas, mosaic, animated GFX, overlays
27//
28// ROM MARKER LOCATION:
29// --------------------
30// The version byte is stored at OverworldCustomASMHasBeenApplied (0x140145):
31// - 0xFF or 0x00: Vanilla ROM (no ZScream ASM applied)
32// - 0x01: ZSCustomOverworld v1
33// - 0x02: ZSCustomOverworld v2
34// - 0x03+: ZSCustomOverworld v3
35//
36// FEATURE TESTING:
37// ----------------
38// To test a specific version's features:
39// 1. Load a ROM with that version applied
40// 2. Use GetVersion() to confirm detection works
41// 3. Check feature flags with SupportsXXX() methods
42// 4. Enable/edit the feature in the editor
43// 5. Save and verify in an emulator
44//
45// UPGRADE WORKFLOW:
46// -----------------
47// In OverworldEditor::ApplyZSCustomOverworldASM(int target_version):
48// 1. Validate current ROM version (can only upgrade, not downgrade)
49// 2. Load appropriate ASM file (yaze.asm for v3, ZSCustomOverworld.asm for v2)
50// 3. Apply patch via AsarWrapper
51// 4. Update version markers via UpdateROMVersionMarkers()
52// 5. Enable feature flags in ROM
53// 6. Reload overworld data to reflect changes
54//
55// See overworld/README.md for complete documentation.
56// =============================================================================
57
65enum class AreaSizeEnum {
66 SmallArea = 0,
67 LargeArea = 1,
68 WideArea = 2,
69 TallArea = 3,
70};
71
83enum class OverworldVersion {
84 kVanilla = 0,
85 kZSCustomV1 = 1,
86 kZSCustomV2 = 2,
87 kZSCustomV3 = 3
88};
89
141 public:
142 // ===========================================================================
143 // Version Detection
144 // ===========================================================================
145
154 static OverworldVersion GetVersion(const Rom& rom) {
157 }
158 uint8_t asm_version = rom.data()[OverworldCustomASMHasBeenApplied];
159
160 // 0xFF = vanilla ROM (no ZScream ASM applied)
161 if (asm_version == 0xFF || asm_version == 0x00) {
163 }
164
165 if (asm_version == 1) {
167 }
168 if (asm_version == 2) {
170 }
171 if (asm_version >= 3) {
173 }
174
175 // Fallback for unknown values
177 }
178
184 static uint8_t GetAsmVersion(const Rom& rom) {
186 }
187
188 // ===========================================================================
189 // Feature Checks
190 // ===========================================================================
191
207 static bool SupportsAreaEnum(OverworldVersion version) {
208 return version == OverworldVersion::kZSCustomV3;
209 }
210
225 return version != OverworldVersion::kVanilla;
226 }
227
240 return version == OverworldVersion::kZSCustomV2 ||
242 }
243
256 return version == OverworldVersion::kZSCustomV3;
257 }
258
271 return version == OverworldVersion::kZSCustomV3;
272 }
273
286 return version == OverworldVersion::kZSCustomV3;
287 }
288
289 // ===========================================================================
290 // Utility Methods
291 // ===========================================================================
292
298 static const char* GetVersionName(OverworldVersion version) {
299 switch (version) {
301 return "Vanilla";
303 return "ZSCustomOverworld v1";
305 return "ZSCustomOverworld v2";
307 return "ZSCustomOverworld v3";
308 default:
309 return "Unknown";
310 }
311 }
312};
313
314} // namespace yaze::zelda3
315
316#endif // YAZE_ZELDA3_OVERWORLD_VERSION_HELPER_H
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:24
auto data() const
Definition rom.h:135
auto size() const
Definition rom.h:134
Helper for ROM version detection and feature gating.
static bool SupportsCustomBGColors(OverworldVersion version)
Check if ROM supports custom background colors per area (v2+)
static OverworldVersion GetVersion(const Rom &rom)
Detect ROM version from ASM marker byte.
static uint8_t GetAsmVersion(const Rom &rom)
Get raw ASM version byte from ROM.
static bool SupportsAreaEnum(OverworldVersion version)
Check if ROM supports area enum system (v3+ only)
static bool SupportsSubscreenOverlay(OverworldVersion version)
Check if ROM supports subscreen overlays (v3+)
static bool SupportsAnimatedGFX(OverworldVersion version)
Check if ROM supports animated GFX selection (v3+)
static bool SupportsExpandedSpace(OverworldVersion version)
Check if ROM uses expanded ROM space for overworld data.
static const char * GetVersionName(OverworldVersion version)
Get human-readable version name for display/logging.
static bool SupportsCustomTileGFX(OverworldVersion version)
Check if ROM supports custom tile GFX groups (v3+)
Zelda 3 specific classes and functions.
Definition editor.h:35
AreaSizeEnum
Area size enumeration for v3+ ROMs.
constexpr int OverworldCustomASMHasBeenApplied
Definition common.h:89
OverworldVersion
ROM version detection for overworld features.
@ kZSCustomV2
Parent system, BG colors, main palettes.
@ kZSCustomV1
Basic features, expanded pointers.
@ kVanilla
0xFF in ROM, no ZScream ASM applied
@ kZSCustomV3
Area enum, wide/tall areas, all features.