#pragma once /** * Functionality for switching game behavior based on the loaded game version (e.g. PAL/JPN, GC/Wii) */ namespace dusk::version { enum class GameVersion : u8 { WiiUsaRev0, WiiPal, WiiJpn, GcnUsa, GcnPal, GcnJpn, WiiUsa, WiiKor, }; bool isGcn(); bool isWii(); bool isJpnOrLessThanWiiJpn(); bool isPalOrAtLeastWiiR2(); bool isRegionPal(); bool isRegionJpn(); bool isRegionUsa(); GameVersion getGameVersion(); const DVDDiskID& getDiskID(); void init(); template struct VersionOption { GameVersion mVersion; T mValue; constexpr VersionOption(GameVersion version, T value) : mVersion(version), mValue(value) {} }; template const T& versionSelect(const std::initializer_list> options) { const auto version = getGameVersion(); for (const auto& opt : options) { if (opt.mVersion == version) { return opt.mValue; } } // Unable to find value. abort(); } template const T& versionSelect(const std::initializer_list> options, const T& defaultValue) { const auto version = getGameVersion(); for (const auto& opt : options) { if (opt.mVersion == version) { return opt.mValue; } } return defaultValue; } template T platformSelect(const T& gcn, const T& wii) { return isGcn() ? gcn : wii; } template T regionSelect(const T& usa, const T& pal, const T& jpn) { return isRegionUsa() ? usa : isRegionPal() ? pal : jpn; } } // namespace dusk::version