yaze 0.2.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::Rom Class Reference

The Rom class is used to load, save, and modify Rom data. More...

#include <rom.h>

Inheritance diagram for yaze::Rom:
Collaboration diagram for yaze::Rom:

Classes

struct  SaveSettings
 
struct  WriteAction
 

Public Member Functions

absl::Status LoadFromFile (const std::string &filename, bool z3_load=true)
 
absl::Status LoadFromData (const std::vector< uint8_t > &data, bool z3_load=true)
 
absl::Status LoadZelda3 ()
 
absl::Status LoadGfxGroups ()
 
absl::Status SaveGfxGroups ()
 
absl::Status SaveToFile (const SaveSettings &settings)
 
absl::Status SavePalette (int index, const std::string &group_name, gfx::SnesPalette &palette)
 
absl::Status SaveAllPalettes ()
 
void Expand (int size)
 
void Close ()
 
absl::StatusOr< uint8_t > ReadByte (int offset)
 
absl::StatusOr< uint16_t > ReadWord (int offset)
 
absl::StatusOr< uint32_t > ReadLong (int offset)
 
absl::StatusOr< std::vector< uint8_t > > ReadByteVector (uint32_t offset, uint32_t length) const
 
absl::StatusOr< gfx::Tile16ReadTile16 (uint32_t tile16_id)
 
absl::Status WriteTile16 (int tile16_id, const gfx::Tile16 &tile)
 
absl::Status WriteByte (int addr, uint8_t value)
 
absl::Status WriteWord (int addr, uint16_t value)
 
absl::Status WriteShort (int addr, uint16_t value)
 
absl::Status WriteLong (uint32_t addr, uint32_t value)
 
absl::Status WriteVector (int addr, std::vector< uint8_t > data)
 
absl::Status WriteColor (uint32_t address, const gfx::SnesColor &color)
 
template<typename... Args>
absl::Status WriteTransaction (Args... args)
 
template<typename T, typename... Args>
absl::Status ReadTransaction (T &var, int address, Args &&... args)
 
virtual absl::Status WriteHelper (const WriteAction &action)
 
template<typename T>
absl::Status ReadHelper (T &var, int address)
 
uint8_t & operator[] (unsigned long i)
 
bool is_loaded () const
 
auto title () const
 
auto size () const
 
auto data () const
 
auto mutable_data ()
 
auto begin ()
 
auto end ()
 
auto vector () const
 
auto filename () const
 
auto set_filename (std::string_view name)
 
auto short_name () const
 
auto graphics_buffer () const
 
auto mutable_graphics_buffer ()
 
auto palette_group () const
 
auto mutable_palette_group ()
 
auto dungeon_palette (int i)
 
auto mutable_dungeon_palette (int i)
 
ResourceLabelManagerresource_label ()
 
zelda3_version_pointers version_constants () const
 

Public Attributes

std::array< std::array< uint8_t, 8 >, kNumMainBlocksetsmain_blockset_ids
 
std::array< std::array< uint8_t, 4 >, kNumRoomBlocksetsroom_blockset_ids
 
std::array< std::array< uint8_t, 4 >, kNumSpritesetsspriteset_ids
 
std::array< std::array< uint8_t, 4 >, kNumPalettesetspaletteset_ids
 

Private Attributes

unsigned long size_ = 0
 
std::string title_ = "ROM not loaded"
 
std::string filename_ = ""
 
std::string short_name_ = ""
 
std::vector< uint8_t > rom_data_
 
std::vector< uint8_t > graphics_buffer_
 
ResourceLabelManager resource_label_manager_
 
gfx::PaletteGroupMap palette_groups_
 
zelda3_version version_ = zelda3_version::US
 

Detailed Description

The Rom class is used to load, save, and modify Rom data.

Definition at line 58 of file rom.h.

Member Function Documentation

◆ LoadFromFile()

absl::Status yaze::Rom::LoadFromFile ( const std::string & filename,
bool z3_load = true )

◆ LoadFromData()

◆ LoadZelda3()

absl::Status yaze::Rom::LoadZelda3 ( )

Definition at line 284 of file rom.cc.

References JP, yaze::gfx::LoadAllPalettes(), LoadGfxGroups(), palette_groups_, RETURN_IF_ERROR, rom_data_, size_, title_, US, and version_.

Referenced by LoadFromData(), and LoadFromFile().

Here is the call graph for this function:

◆ LoadGfxGroups()

◆ SaveGfxGroups()

◆ SaveToFile()

◆ SavePalette()

absl::Status yaze::Rom::SavePalette ( int index,
const std::string & group_name,
gfx::SnesPalette & palette )

◆ SaveAllPalettes()

absl::Status yaze::Rom::SaveAllPalettes ( )

Definition at line 502 of file rom.cc.

References palette_groups_, and RETURN_IF_ERROR.

Referenced by SaveToFile().

◆ Expand()

void yaze::Rom::Expand ( int size)
inline

Definition at line 79 of file rom.h.

References rom_data_, size(), and size_.

Here is the call graph for this function:

◆ Close()

void yaze::Rom::Close ( )
inline

Definition at line 84 of file rom.h.

References palette_groups_, rom_data_, and size_.

◆ ReadByte()

absl::StatusOr< uint8_t > yaze::Rom::ReadByte ( int offset)

Definition at line 515 of file rom.cc.

References ReadByte(), and rom_data_.

Referenced by yaze::zelda3::LoadDungeonMaps(), yaze::test::MockRom::MOCK_METHOD(), ReadByte(), and ReadHelper().

Here is the call graph for this function:

◆ ReadWord()

absl::StatusOr< uint16_t > yaze::Rom::ReadWord ( int offset)

◆ ReadLong()

absl::StatusOr< uint32_t > yaze::Rom::ReadLong ( int offset)

Definition at line 530 of file rom.cc.

References ReadLong(), and rom_data_.

Referenced by yaze::test::MockRom::MOCK_METHOD(), and ReadLong().

Here is the call graph for this function:

◆ ReadByteVector()

absl::StatusOr< std::vector< uint8_t > > yaze::Rom::ReadByteVector ( uint32_t offset,
uint32_t length ) const

Definition at line 539 of file rom.cc.

References ReadByteVector(), and rom_data_.

Referenced by yaze::LoadLinkGraphics(), ReadByteVector(), and ReadHelper().

Here is the call graph for this function:

◆ ReadTile16()

absl::StatusOr< gfx::Tile16 > yaze::Rom::ReadTile16 ( uint32_t tile16_id)

Definition at line 551 of file rom.cc.

References ASSIGN_OR_RETURN, yaze::kTile16Ptr, ReadTile16(), ReadWord(), and yaze::gfx::WordToTileInfo().

Referenced by ReadTile16(), and yaze::cli::Tile16Transfer::Run().

Here is the call graph for this function:

◆ WriteTile16()

absl::Status yaze::Rom::WriteTile16 ( int tile16_id,
const gfx::Tile16 & tile )

◆ WriteByte()

absl::Status yaze::Rom::WriteByte ( int addr,
uint8_t value )

Definition at line 582 of file rom.cc.

References data(), yaze::util::HexByte(), rom_data_, and WriteByte().

Referenced by yaze::zelda3::RoomEntrance::Save(), yaze::zelda3::SaveDungeonMaps(), WriteByte(), and WriteHelper().

Here is the call graph for this function:

◆ WriteWord()

absl::Status yaze::Rom::WriteWord ( int addr,
uint16_t value )

Definition at line 593 of file rom.cc.

References data(), yaze::util::HexWord(), rom_data_, and WriteWord().

Referenced by yaze::zelda3::SaveDungeonMapTile16(), and WriteWord().

Here is the call graph for this function:

◆ WriteShort()

absl::Status yaze::Rom::WriteShort ( int addr,
uint16_t value )

Definition at line 605 of file rom.cc.

References data(), yaze::util::HexWord(), rom_data_, and WriteShort().

Referenced by yaze::zelda3::RoomEntrance::Save(), WriteColor(), WriteHelper(), WriteShort(), and WriteTile16().

Here is the call graph for this function:

◆ WriteLong()

absl::Status yaze::Rom::WriteLong ( uint32_t addr,
uint32_t value )

Definition at line 617 of file rom.cc.

References data(), yaze::util::HexLong(), rom_data_, and WriteLong().

Referenced by WriteLong().

Here is the call graph for this function:

◆ WriteVector()

absl::Status yaze::Rom::WriteVector ( int addr,
std::vector< uint8_t > data )

Definition at line 630 of file rom.cc.

References data(), yaze::util::HexByte(), rom_data_, and WriteVector().

Referenced by WriteHelper(), and WriteVector().

Here is the call graph for this function:

◆ WriteColor()

absl::Status yaze::Rom::WriteColor ( uint32_t address,
const gfx::SnesColor & color )

◆ WriteTransaction()

template<typename... Args>
absl::Status yaze::Rom::WriteTransaction ( Args... args)
inline

Definition at line 106 of file rom.h.

References WriteHelper().

Referenced by yaze::test::TEST_F(), and yaze::test::TEST_F().

Here is the call graph for this function:

◆ ReadTransaction()

template<typename T, typename... Args>
absl::Status yaze::Rom::ReadTransaction ( T & var,
int address,
Args &&... args )
inline

Definition at line 114 of file rom.h.

References ReadHelper(), and ReadTransaction().

Referenced by ReadTransaction(), yaze::test::TEST_F(), and yaze::test::TEST_F().

Here is the call graph for this function:

◆ WriteHelper()

virtual absl::Status yaze::Rom::WriteHelper ( const WriteAction & action)
inlinevirtual

Definition at line 133 of file rom.h.

References yaze::Rom::WriteAction::address, yaze::Rom::WriteAction::value, WriteByte(), WriteColor(), WriteShort(), and WriteVector().

Referenced by yaze::test::MockRom::MOCK_METHOD(), and WriteTransaction().

Here is the call graph for this function:

◆ ReadHelper()

template<typename T>
absl::Status yaze::Rom::ReadHelper ( T & var,
int address )
inline

Definition at line 155 of file rom.h.

References ASSIGN_OR_RETURN, ReadByte(), ReadByteVector(), and ReadWord().

Referenced by yaze::test::MockRom::MOCK_METHOD2(), yaze::test::MockRom::MOCK_METHOD2(), yaze::test::MockRom::MOCK_METHOD2(), and ReadTransaction().

Here is the call graph for this function:

◆ operator[]()

uint8_t & yaze::Rom::operator[] ( unsigned long i)
inline

Definition at line 169 of file rom.h.

References rom_data_, and size_.

◆ is_loaded()

bool yaze::Rom::is_loaded ( ) const
inline

Definition at line 174 of file rom.h.

References rom_data_.

Referenced by main().

◆ title()

auto yaze::Rom::title ( ) const
inline

Definition at line 175 of file rom.h.

References title_.

◆ size()

◆ data()

◆ mutable_data()

◆ begin()

auto yaze::Rom::begin ( )
inline

◆ end()

auto yaze::Rom::end ( )
inline

Definition at line 180 of file rom.h.

References rom_data_.

◆ vector()

auto yaze::Rom::vector ( ) const
inline

◆ filename()

auto yaze::Rom::filename ( ) const
inline

Definition at line 182 of file rom.h.

References filename_.

Referenced by LoadFromFile(), SaveToFile(), and yaze::editor::MemoryEditorWithDiffChecker::Update().

◆ set_filename()

auto yaze::Rom::set_filename ( std::string_view name)
inline

Definition at line 183 of file rom.h.

References filename_.

◆ short_name()

auto yaze::Rom::short_name ( ) const
inline

Definition at line 184 of file rom.h.

References short_name_.

◆ graphics_buffer()

auto yaze::Rom::graphics_buffer ( ) const
inline

Definition at line 185 of file rom.h.

References graphics_buffer_.

◆ mutable_graphics_buffer()

auto yaze::Rom::mutable_graphics_buffer ( )
inline

Definition at line 186 of file rom.h.

References graphics_buffer_.

Referenced by yaze::LoadAllGraphicsData().

◆ palette_group()

◆ mutable_palette_group()

auto yaze::Rom::mutable_palette_group ( )
inline

Definition at line 188 of file rom.h.

References palette_groups_.

Referenced by yaze::editor::PaletteEditor::DrawPaletteGroup().

◆ dungeon_palette()

auto yaze::Rom::dungeon_palette ( int i)
inline

Definition at line 189 of file rom.h.

References palette_groups_.

◆ mutable_dungeon_palette()

auto yaze::Rom::mutable_dungeon_palette ( int i)
inline

◆ resource_label()

◆ version_constants()

zelda3_version_pointers yaze::Rom::version_constants ( ) const
inline

Member Data Documentation

◆ main_blockset_ids

std::array<std::array<uint8_t, 8>, kNumMainBlocksets> yaze::Rom::main_blockset_ids

Definition at line 199 of file rom.h.

Referenced by LoadGfxGroups(), and SaveGfxGroups().

◆ room_blockset_ids

std::array<std::array<uint8_t, 4>, kNumRoomBlocksets> yaze::Rom::room_blockset_ids

Definition at line 200 of file rom.h.

Referenced by LoadGfxGroups(), and SaveGfxGroups().

◆ spriteset_ids

std::array<std::array<uint8_t, 4>, kNumSpritesets> yaze::Rom::spriteset_ids

Definition at line 201 of file rom.h.

Referenced by LoadGfxGroups(), and SaveGfxGroups().

◆ paletteset_ids

std::array<std::array<uint8_t, 4>, kNumPalettesets> yaze::Rom::paletteset_ids

Definition at line 202 of file rom.h.

Referenced by yaze::editor::DungeonEditor::Load(), LoadGfxGroups(), and SaveGfxGroups().

◆ size_

unsigned long yaze::Rom::size_ = 0
private

Definition at line 206 of file rom.h.

Referenced by Close(), Expand(), LoadFromData(), LoadFromFile(), LoadZelda3(), operator[](), and size().

◆ title_

std::string yaze::Rom::title_ = "ROM not loaded"
private

Definition at line 209 of file rom.h.

Referenced by LoadZelda3(), and title().

◆ filename_

std::string yaze::Rom::filename_ = ""
private

Definition at line 212 of file rom.h.

Referenced by filename(), LoadFromFile(), SaveToFile(), and set_filename().

◆ short_name_

std::string yaze::Rom::short_name_ = ""
private

Definition at line 215 of file rom.h.

Referenced by LoadFromFile(), and short_name().

◆ rom_data_

◆ graphics_buffer_

std::vector<uint8_t> yaze::Rom::graphics_buffer_
private

Definition at line 221 of file rom.h.

Referenced by graphics_buffer(), and mutable_graphics_buffer().

◆ resource_label_manager_

ResourceLabelManager yaze::Rom::resource_label_manager_
private

Definition at line 224 of file rom.h.

Referenced by LoadFromFile(), and resource_label().

◆ palette_groups_

gfx::PaletteGroupMap yaze::Rom::palette_groups_
private

◆ version_

zelda3_version yaze::Rom::version_ = zelda3_version::US
private

Definition at line 230 of file rom.h.

Referenced by LoadZelda3(), and version_constants().


The documentation for this class was generated from the following files: