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

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

#include <rom.h>

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

Classes

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 SaveToFile (bool backup, bool save_new=false, std::string filename="")
 Saves the Rom data to a file.
 
absl::Status SavePalette (int index, const std::string &group_name, gfx::SnesPalette &palette)
 
absl::Status SaveAllPalettes ()
 Saves all palettes in the Rom.
 
void Expand (int size)
 
absl::Status 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)
 
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 version () const
 
auto filename () const
 
auto set_filename (std::string name)
 
std::vector< uint8_t > 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 Member Functions

virtual absl::Status WriteHelper (const WriteAction &action)
 
template<typename T>
absl::Status ReadHelper (T &var, int address)
 
absl::Status LoadZelda3 ()
 
absl::Status LoadGfxGroups ()
 
absl::Status SaveGroupsToRom ()
 

Private Attributes

bool is_loaded_ = false
 
unsigned long size_ = 0
 
std::string title_ = "ROM not loaded"
 
std::string filename_ = ""
 
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 59 of file rom.h.

Member Function Documentation

◆ LoadFromFile()

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

Load Rom data from a file.

Parameters
filenameThe name of the file to load.
z3_loadWhether to load data specific to Zelda 3.

Definition at line 173 of file rom.cc.

◆ LoadFromData()

absl::Status yaze::Rom::LoadFromData ( const std::vector< uint8_t > & data,
bool z3_load = true )

Definition at line 218 of file rom.cc.

◆ SaveToFile()

absl::Status yaze::Rom::SaveToFile ( bool backup,
bool save_new = false,
std::string filename = "" )

Saves the Rom data to a file.

Parameters
backupIf true, creates a backup file with timestamp in its name
filenameThe name of the file to save the Rom data to
Returns
absl::Status Returns an OK status if the save was successful, otherwise returns an error status

Definition at line 408 of file rom.cc.

◆ SavePalette()

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

Saves the given palette to the Rom if any of its colors have been modified.

Parameters
indexThe index of the palette to save.
group_nameThe name of the group containing the palette.
paletteThe palette to save.

Definition at line 504 of file rom.cc.

◆ SaveAllPalettes()

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

Saves all palettes in the Rom.

This function iterates through all palette groups and all palettes in each group, and saves each palette using the SavePalette() function.

Definition at line 518 of file rom.cc.

◆ Expand()

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

Definition at line 102 of file rom.h.

◆ Close()

absl::Status yaze::Rom::Close ( )
inline

Definition at line 107 of file rom.h.

◆ ReadByte()

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

Definition at line 235 of file rom.cc.

◆ ReadWord()

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

Definition at line 242 of file rom.cc.

◆ ReadLong()

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

Definition at line 250 of file rom.cc.

◆ ReadByteVector()

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

Definition at line 259 of file rom.cc.

◆ ReadTile16()

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

Definition at line 271 of file rom.cc.

◆ WriteTile16()

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

Definition at line 289 of file rom.cc.

◆ WriteByte()

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

Definition at line 302 of file rom.cc.

◆ WriteWord()

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

Definition at line 313 of file rom.cc.

◆ WriteShort()

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

Definition at line 325 of file rom.cc.

◆ WriteLong()

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

Definition at line 337 of file rom.cc.

◆ WriteVector()

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

Definition at line 350 of file rom.cc.

◆ WriteColor()

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

Definition at line 363 of file rom.cc.

◆ WriteTransaction()

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

Definition at line 130 of file rom.h.

◆ ReadTransaction()

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

Definition at line 138 of file rom.h.

◆ operator[]()

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

Definition at line 149 of file rom.h.

◆ is_loaded()

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

Definition at line 154 of file rom.h.

◆ title()

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

Definition at line 162 of file rom.h.

◆ size()

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

Definition at line 163 of file rom.h.

◆ data()

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

Definition at line 164 of file rom.h.

◆ mutable_data()

auto yaze::Rom::mutable_data ( )
inline

Definition at line 165 of file rom.h.

◆ begin()

auto yaze::Rom::begin ( )
inline

Definition at line 166 of file rom.h.

◆ end()

auto yaze::Rom::end ( )
inline

Definition at line 167 of file rom.h.

◆ vector()

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

Definition at line 169 of file rom.h.

◆ version()

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

Definition at line 170 of file rom.h.

◆ filename()

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

Definition at line 171 of file rom.h.

◆ set_filename()

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

Definition at line 172 of file rom.h.

◆ graphics_buffer()

std::vector< uint8_t > yaze::Rom::graphics_buffer ( ) const
inline

Definition at line 174 of file rom.h.

◆ mutable_graphics_buffer()

auto yaze::Rom::mutable_graphics_buffer ( )
inline

Definition at line 175 of file rom.h.

◆ palette_group()

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

Definition at line 176 of file rom.h.

◆ mutable_palette_group()

auto yaze::Rom::mutable_palette_group ( )
inline

Definition at line 177 of file rom.h.

◆ dungeon_palette()

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

Definition at line 178 of file rom.h.

◆ mutable_dungeon_palette()

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

Definition at line 179 of file rom.h.

◆ resource_label()

ResourceLabelManager * yaze::Rom::resource_label ( )
inline

Definition at line 183 of file rom.h.

◆ version_constants()

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

Definition at line 184 of file rom.h.

◆ WriteHelper()

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

Definition at line 201 of file rom.h.

◆ ReadHelper()

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

Definition at line 223 of file rom.h.

◆ LoadZelda3()

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

Definition at line 372 of file rom.cc.

◆ LoadGfxGroups()

absl::Status yaze::Rom::LoadGfxGroups ( )
private

Definition at line 531 of file rom.cc.

◆ SaveGroupsToRom()

absl::Status yaze::Rom::SaveGroupsToRom ( )
private

Definition at line 564 of file rom.cc.

Member Data Documentation

◆ main_blockset_ids

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

Definition at line 188 of file rom.h.

◆ room_blockset_ids

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

Definition at line 189 of file rom.h.

◆ spriteset_ids

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

Definition at line 190 of file rom.h.

◆ paletteset_ids

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

Definition at line 191 of file rom.h.

◆ is_loaded_

bool yaze::Rom::is_loaded_ = false
private

Definition at line 242 of file rom.h.

◆ size_

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

Definition at line 245 of file rom.h.

◆ title_

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

Definition at line 248 of file rom.h.

◆ filename_

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

Definition at line 251 of file rom.h.

◆ rom_data_

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

Definition at line 254 of file rom.h.

◆ graphics_buffer_

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

Definition at line 257 of file rom.h.

◆ resource_label_manager_

ResourceLabelManager yaze::Rom::resource_label_manager_
private

Definition at line 260 of file rom.h.

◆ palette_groups_

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

Definition at line 263 of file rom.h.

◆ version_

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

Definition at line 266 of file rom.h.


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