Add zelda.h for game version handling and refactor ROM version management
This commit is contained in:
90
incl/zelda.h
Normal file
90
incl/zelda.h
Normal file
@@ -0,0 +1,90 @@
|
||||
#ifndef ZELDA_H
|
||||
#define ZELDA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief Different versions of the game supported by yaze.
|
||||
*/
|
||||
enum zelda3_version {
|
||||
US = 1, // US version
|
||||
JP = 2, // JP version
|
||||
SD = 3, // Super Donkey Proto (Experimental)
|
||||
RANDO = 4, // Randomizer (Unimplemented)
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Pointers for each version of the game.
|
||||
*/
|
||||
struct zelda3_version_pointers {
|
||||
uint32_t kGfxAnimatedPointer;
|
||||
uint32_t kOverworldGfxGroups1;
|
||||
uint32_t kOverworldGfxGroups2;
|
||||
uint32_t kCompressedAllMap32PointersHigh;
|
||||
uint32_t kCompressedAllMap32PointersLow;
|
||||
uint32_t kOverworldMapPaletteGroup;
|
||||
uint32_t kOverlayPointers;
|
||||
uint32_t kOverlayPointersBank;
|
||||
uint32_t kOverworldTilesType;
|
||||
uint32_t kOverworldGfxPtr1;
|
||||
uint32_t kOverworldGfxPtr2;
|
||||
uint32_t kOverworldGfxPtr3;
|
||||
uint32_t kMap32TileTL;
|
||||
uint32_t kMap32TileTR;
|
||||
uint32_t kMap32TileBL;
|
||||
uint32_t kMap32TileBR;
|
||||
uint32_t kSpriteBlocksetPointer;
|
||||
uint32_t kDungeonPalettesGroups;
|
||||
};
|
||||
|
||||
const static zelda3_version_pointers zelda3_us_pointers = {
|
||||
0x10275, // kGfxAnimatedPointer
|
||||
0x5D97, // kOverworldGfxGroups1
|
||||
0x6073, // kOverworldGfxGroups2
|
||||
0x1794D, // kCompressedAllMap32PointersHigh
|
||||
0x17B2D, // kCompressedAllMap32PointersLow
|
||||
0x75504, // kOverworldMapPaletteGroup
|
||||
0x77664, // kOverlayPointers
|
||||
0x0E, // kOverlayPointersBank
|
||||
0x71459, // kOverworldTilesType
|
||||
0x4F80, // kOverworldGfxPtr1
|
||||
0x505F, // kOverworldGfxPtr2
|
||||
0x513E, // kOverworldGfxPtr3
|
||||
0x18000, // kMap32TileTL
|
||||
0x1B400, // kMap32TileTR
|
||||
0x20000, // kMap32TileBL
|
||||
0x23400, // kMap32TileBR
|
||||
0x5B57, // kSpriteBlocksetPointer
|
||||
0x75460, // kDungeonPalettesGroups
|
||||
};
|
||||
|
||||
const static zelda3_version_pointers zelda3_jp_pointers = {
|
||||
0x10624, // kGfxAnimatedPointer
|
||||
0x5DD7, // kOverworldGfxGroups1
|
||||
0x60B3, // kOverworldGfxGroups2
|
||||
0x176B1, // kCompressedAllMap32PointersHigh
|
||||
0x17891, // kCompressedAllMap32PointersLow
|
||||
0x67E74, // kOverworldMapPaletteGroup
|
||||
0x3FAF4, // kOverlayPointers
|
||||
0x07, // kOverlayPointersBank
|
||||
0x7FD94, // kOverworldTilesType
|
||||
0x4FC0, // kOverworldGfxPtr1
|
||||
0x509F, // kOverworldGfxPtr2
|
||||
0x517E, // kOverworldGfxPtr3
|
||||
0x18000, // kMap32TileTL
|
||||
0x1B3C0, // kMap32TileTR
|
||||
0x20000, // kMap32TileBL
|
||||
0x233C0, // kMap32TileBR
|
||||
0x5B97, // kSpriteBlocksetPointer
|
||||
0x67DD0, // kDungeonPalettesGroups
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -262,9 +262,9 @@ absl::Status Rom::LoadZelda3() {
|
||||
rom_data_.begin() + kTitleStringOffset + kTitleStringLength,
|
||||
title_.begin());
|
||||
if (rom_data_[kTitleStringOffset + 0x19] == 0) {
|
||||
version_ = Z3_Version::JP;
|
||||
version_ = zelda3_version::JP;
|
||||
} else {
|
||||
version_ = Z3_Version::US;
|
||||
version_ = zelda3_version::US;
|
||||
}
|
||||
|
||||
// Load additional resources
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define YAZE_APP_ROM_H
|
||||
|
||||
#include <SDL.h>
|
||||
#include <zelda.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
@@ -44,88 +45,15 @@ constexpr uint32_t kEntranceGfxGroup = 0x5D97;
|
||||
// TODO: Verify what this was used for in ZS
|
||||
constexpr uint32_t kMaxGraphics = 0xC3FB5;
|
||||
|
||||
/**
|
||||
* @brief Different versions of the game supported by the Rom class.
|
||||
*/
|
||||
enum class Z3_Version {
|
||||
US = 1, // US version
|
||||
JP = 2, // JP version
|
||||
SD = 3, // Super Donkey Proto (Experimental)
|
||||
RANDO = 4, // Randomizer (Unimplemented)
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Constants for each version of the game.
|
||||
*/
|
||||
struct VersionConstants {
|
||||
uint32_t kGfxAnimatedPointer;
|
||||
uint32_t kOverworldGfxGroups1;
|
||||
uint32_t kOverworldGfxGroups2;
|
||||
uint32_t kCompressedAllMap32PointersHigh;
|
||||
uint32_t kCompressedAllMap32PointersLow;
|
||||
uint32_t kOverworldMapPaletteGroup;
|
||||
uint32_t kOverlayPointers;
|
||||
uint32_t kOverlayPointersBank;
|
||||
uint32_t kOverworldTilesType;
|
||||
uint32_t kOverworldGfxPtr1;
|
||||
uint32_t kOverworldGfxPtr2;
|
||||
uint32_t kOverworldGfxPtr3;
|
||||
uint32_t kMap32TileTL;
|
||||
uint32_t kMap32TileTR;
|
||||
uint32_t kMap32TileBL;
|
||||
uint32_t kMap32TileBR;
|
||||
uint32_t kSpriteBlocksetPointer;
|
||||
uint32_t kDungeonPalettesGroups;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A map of version constants for each version of the game.
|
||||
*/
|
||||
static const std::map<Z3_Version, VersionConstants> kVersionConstantsMap = {
|
||||
{Z3_Version::US,
|
||||
{
|
||||
0x10275, // kGfxAnimatedPointer
|
||||
0x5D97, // kOverworldGfxGroups1
|
||||
0x6073, // kOverworldGfxGroups2
|
||||
0x1794D, // kCompressedAllMap32PointersHigh
|
||||
0x17B2D, // kCompressedAllMap32PointersLow
|
||||
0x75504, // kOverworldMapPaletteGroup
|
||||
0x77664, // kOverlayPointers
|
||||
0x0E, // kOverlayPointersBank
|
||||
0x71459, // kOverworldTilesType
|
||||
0x4F80, // kOverworldGfxPtr1
|
||||
0x505F, // kOverworldGfxPtr2
|
||||
0x513E, // kOverworldGfxPtr3
|
||||
0x18000, // kMap32TileTL
|
||||
0x1B400, // kMap32TileTR
|
||||
0x20000, // kMap32TileBL
|
||||
0x23400, // kMap32TileBR
|
||||
0x5B57, // kSpriteBlocksetPointer
|
||||
0x75460, // kDungeonPalettesGroups
|
||||
}},
|
||||
{Z3_Version::JP,
|
||||
{
|
||||
0x10624, // kGfxAnimatedPointer
|
||||
0x5DD7, // kOverworldGfxGroups1
|
||||
0x60B3, // kOverworldGfxGroups2
|
||||
0x176B1, // kCompressedAllMap32PointersHigh
|
||||
0x17891, // kCompressedAllMap32PointersLow
|
||||
0x67E74, // kOverworldMapPaletteGroup
|
||||
0x3FAF4, // kOverlayPointers
|
||||
0x07, // kOverlayPointersBank
|
||||
0x7FD94, // kOverworldTilesType
|
||||
0x4FC0, // kOverworldGfxPtr1
|
||||
0x509F, // kOverworldGfxPtr2
|
||||
0x517E, // kOverworldGfxPtr3
|
||||
0x18000, // kMap32TileTL
|
||||
0x1B3C0, // kMap32TileTR
|
||||
0x20000, // kMap32TileBL
|
||||
0x233C0, // kMap32TileBR
|
||||
0x5B97, // kSpriteBlocksetPointer
|
||||
0x67DD0, // kDungeonPalettesGroups
|
||||
}},
|
||||
{Z3_Version::SD, {}},
|
||||
{Z3_Version::RANDO, {}},
|
||||
static const std::map<zelda3_version, zelda3_version_pointers>
|
||||
kVersionConstantsMap = {
|
||||
{zelda3_version::US, zelda3_us_pointers},
|
||||
{zelda3_version::JP, zelda3_jp_pointers},
|
||||
{zelda3_version::SD, {}},
|
||||
{zelda3_version::RANDO, {}},
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -411,7 +339,7 @@ class Rom {
|
||||
}
|
||||
|
||||
ResourceLabelManager* resource_label() { return &resource_label_manager_; }
|
||||
VersionConstants version_constants() const {
|
||||
zelda3_version_pointers version_constants() const {
|
||||
return kVersionConstantsMap.at(version_);
|
||||
}
|
||||
|
||||
@@ -493,7 +421,7 @@ class Rom {
|
||||
gfx::PaletteGroupMap palette_groups_;
|
||||
|
||||
// Version of the game
|
||||
Z3_Version version_ = Z3_Version::US;
|
||||
zelda3_version version_ = zelda3_version::US;
|
||||
};
|
||||
|
||||
class GraphicsSheetManager {
|
||||
|
||||
Reference in New Issue
Block a user