cleanup ROM class
This commit is contained in:
@@ -27,11 +27,6 @@
|
|||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
using gfx::lc_lz2::CompressionPiece;
|
|
||||||
using gfx::lc_lz2::kCommandDirectCopy;
|
|
||||||
using gfx::lc_lz2::kCommandMod;
|
|
||||||
using gfx::lc_lz2::kSnesByteMax;
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
int GetGraphicsAddress(const uchar* data, uint8_t offset) {
|
int GetGraphicsAddress(const uchar* data, uint8_t offset) {
|
||||||
@@ -378,26 +373,6 @@ gfx::SNESPalette ROM::ReadPalette(int offset, int num_colors) {
|
|||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
void ROM::Write(int addr, int value) { rom_data_[addr] = value; }
|
|
||||||
|
|
||||||
void ROM::WriteShort(int addr, int value) {
|
|
||||||
rom_data_[addr] = (uchar)(value & 0xFF);
|
|
||||||
rom_data_[addr + 1] = (uchar)((value >> 8) & 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
void ROM::WriteColor(uint32_t address, const gfx::SNESColor& color) {
|
|
||||||
uint16_t bgr = ((color.GetSNES() >> 10) & 0x1F) |
|
|
||||||
((color.GetSNES() & 0x1F) << 10) | (color.GetSNES() & 0x7C00);
|
|
||||||
|
|
||||||
// Write the 16-bit color value to the ROM at the specified address
|
|
||||||
rom_data_[address] = static_cast<uint8_t>(bgr & 0xFF);
|
|
||||||
rom_data_[address + 1] = static_cast<uint8_t>((bgr >> 8) & 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
uint32_t ROM::GetPaletteAddress(const std::string& groupName,
|
uint32_t ROM::GetPaletteAddress(const std::string& groupName,
|
||||||
size_t paletteIndex, size_t color_index) const {
|
size_t paletteIndex, size_t color_index) const {
|
||||||
// Retrieve the base address for the palette group
|
// Retrieve the base address for the palette group
|
||||||
|
|||||||
@@ -41,6 +41,13 @@ constexpr int kTitleStringOffset = 0x7FC0;
|
|||||||
constexpr int kTitleStringLength = 20;
|
constexpr int kTitleStringLength = 20;
|
||||||
constexpr int kSNESToPCOffset = 0x138000;
|
constexpr int kSNESToPCOffset = 0x138000;
|
||||||
|
|
||||||
|
constexpr uint32_t kNumGfxSheets = 223;
|
||||||
|
constexpr uint32_t kNormalGfxSpaceStart = 0x87000;
|
||||||
|
constexpr uint32_t kNormalGfxSpaceEnd = 0xC4200;
|
||||||
|
constexpr uint32_t kPtrTableStart = 0x4F80;
|
||||||
|
constexpr uint32_t kLinkSpriteLocation = 0x80000;
|
||||||
|
constexpr uint32_t kFontSpriteLocation = 0x70000;
|
||||||
|
|
||||||
const absl::flat_hash_map<std::string, uint32_t> paletteGroupAddresses = {
|
const absl::flat_hash_map<std::string, uint32_t> paletteGroupAddresses = {
|
||||||
{"ow_main", core::overworldPaletteMain},
|
{"ow_main", core::overworldPaletteMain},
|
||||||
{"ow_aux", core::overworldPaletteAuxialiary},
|
{"ow_aux", core::overworldPaletteAuxialiary},
|
||||||
@@ -90,19 +97,29 @@ class ROM {
|
|||||||
gfx::SNESPalette ReadPalette(int offset, int num_colors);
|
gfx::SNESPalette ReadPalette(int offset, int num_colors);
|
||||||
|
|
||||||
// Write functions
|
// Write functions
|
||||||
void Write(int addr, int value);
|
void Write(int addr, int value) { rom_data_[addr] = value; }
|
||||||
void WriteShort(int addr, int value);
|
|
||||||
void WriteColor(uint32_t address, const gfx::SNESColor& color);
|
|
||||||
|
|
||||||
Bytes GetGraphicsBuffer() const { return graphics_buffer_; }
|
void WriteShort(int addr, int value) {
|
||||||
gfx::BitmapTable GetGraphicsBin() const { return graphics_bin_; }
|
rom_data_[addr] = (uint16_t)(value & 0xFF);
|
||||||
|
rom_data_[addr + 1] = (uint16_t)((value >> 8) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteColor(uint32_t address, const gfx::SNESColor& color) {
|
||||||
|
uint16_t bgr = ((color.GetSNES() >> 10) & 0x1F) |
|
||||||
|
((color.GetSNES() & 0x1F) << 10) |
|
||||||
|
(color.GetSNES() & 0x7C00);
|
||||||
|
|
||||||
|
// Write the 16-bit color value to the ROM at the specified address
|
||||||
|
WriteShort(address, bgr);
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t GetPaletteAddress(const std::string& groupName, size_t paletteIndex,
|
uint32_t GetPaletteAddress(const std::string& groupName, size_t paletteIndex,
|
||||||
size_t colorIndex) const;
|
size_t colorIndex) const;
|
||||||
|
|
||||||
gfx::PaletteGroup GetPaletteGroup(const std::string& group) {
|
gfx::PaletteGroup GetPaletteGroup(const std::string& group) {
|
||||||
return palette_groups_[group];
|
return palette_groups_[group];
|
||||||
}
|
}
|
||||||
|
Bytes GetGraphicsBuffer() const { return graphics_buffer_; }
|
||||||
|
gfx::BitmapTable GetGraphicsBin() const { return graphics_bin_; }
|
||||||
|
|
||||||
auto title() const { return title_; }
|
auto title() const { return title_; }
|
||||||
auto size() const { return size_; }
|
auto size() const { return size_; }
|
||||||
|
|||||||
Reference in New Issue
Block a user