yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::core::AsarWrapper Class Reference

Modern C++ wrapper for Asar 65816 assembler integration. More...

#include <asar_wrapper.h>

Public Member Functions

 AsarWrapper ()
 
 ~AsarWrapper ()
 
 AsarWrapper (const AsarWrapper &)=delete
 
AsarWrapperoperator= (const AsarWrapper &)=delete
 
 AsarWrapper (AsarWrapper &&)=default
 
AsarWrapperoperator= (AsarWrapper &&)=default
 
absl::Status Initialize ()
 Initialize the Asar library.
 
void Shutdown ()
 Clean up and close the Asar library.
 
bool IsInitialized () const
 Check if Asar is initialized and ready.
 
std::string GetVersion () const
 Get Asar version information.
 
int GetApiVersion () const
 Get Asar API version.
 
absl::StatusOr< AsarPatchResultApplyPatch (const std::string &patch_path, std::vector< uint8_t > &rom_data, const std::vector< std::string > &include_paths={})
 Apply an assembly patch to a ROM.
 
absl::StatusOr< AsarPatchResultApplyPatchFromString (const std::string &patch_content, std::vector< uint8_t > &rom_data, const std::string &base_path="")
 Apply an assembly patch from string content.
 
absl::StatusOr< std::vector< AsarSymbol > > ExtractSymbols (const std::string &asm_path, const std::vector< std::string > &include_paths={})
 Extract symbols from an assembly file without patching.
 
std::map< std::string, AsarSymbolGetSymbolTable () const
 Get all available symbols from the last patch operation.
 
std::optional< AsarSymbolFindSymbol (const std::string &name) const
 Find a symbol by name.
 
std::vector< AsarSymbolGetSymbolsAtAddress (uint32_t address) const
 Get symbols at a specific address.
 
void Reset ()
 Reset the Asar state (clear errors, warnings, symbols)
 
std::vector< std::string > GetLastErrors () const
 Get the last error messages.
 
std::vector< std::string > GetLastWarnings () const
 Get the last warning messages.
 
absl::Status CreatePatch (const std::vector< uint8_t > &original_rom, const std::vector< uint8_t > &modified_rom, const std::string &patch_path)
 Create a patch that can be applied to transform one ROM to another.
 
absl::Status ValidateAssembly (const std::string &asm_path)
 Validate an assembly file for syntax errors.
 

Private Member Functions

void ProcessErrors ()
 Process errors from Asar and store them.
 
void ProcessWarnings ()
 Process warnings from Asar and store them.
 
void ExtractSymbolsFromLastOperation ()
 Extract symbols from the last Asar operation.
 
AsarSymbol ConvertAsarSymbol (const void *asar_symbol_data) const
 Convert Asar symbol data to AsarSymbol struct.
 

Private Attributes

bool initialized_
 
std::map< std::string, AsarSymbolsymbol_table_
 
std::vector< std::string > last_errors_
 
std::vector< std::string > last_warnings_
 

Detailed Description

Modern C++ wrapper for Asar 65816 assembler integration.

This class provides a high-level interface for:

  • Patching ROMs with assembly code
  • Extracting symbol names and opcodes
  • Cross-platform compatibility (Windows, macOS, Linux)

Definition at line 48 of file asar_wrapper.h.

Constructor & Destructor Documentation

◆ AsarWrapper() [1/3]

yaze::core::AsarWrapper::AsarWrapper ( )

Definition at line 17 of file asar_wrapper.cc.

◆ ~AsarWrapper()

yaze::core::AsarWrapper::~AsarWrapper ( )

Definition at line 19 of file asar_wrapper.cc.

References initialized_, and Shutdown().

Here is the call graph for this function:

◆ AsarWrapper() [2/3]

yaze::core::AsarWrapper::AsarWrapper ( const AsarWrapper )
delete

◆ AsarWrapper() [3/3]

yaze::core::AsarWrapper::AsarWrapper ( AsarWrapper &&  )
default

Member Function Documentation

◆ operator=() [1/2]

AsarWrapper & yaze::core::AsarWrapper::operator= ( const AsarWrapper )
delete

◆ operator=() [2/2]

AsarWrapper & yaze::core::AsarWrapper::operator= ( AsarWrapper &&  )
default

◆ Initialize()

absl::Status yaze::core::AsarWrapper::Initialize ( )

Initialize the Asar library.

Returns
Status indicating success or failure

Definition at line 25 of file asar_wrapper.cc.

References initialized_.

◆ Shutdown()

void yaze::core::AsarWrapper::Shutdown ( )

Clean up and close the Asar library.

Definition at line 41 of file asar_wrapper.cc.

References initialized_.

Referenced by ~AsarWrapper().

◆ IsInitialized()

bool yaze::core::AsarWrapper::IsInitialized ( ) const
inline

Check if Asar is initialized and ready.

Returns
True if initialized, false otherwise

Definition at line 76 of file asar_wrapper.h.

References initialized_.

◆ GetVersion()

std::string yaze::core::AsarWrapper::GetVersion ( ) const

Get Asar version information.

Returns
Version string

Definition at line 48 of file asar_wrapper.cc.

References initialized_.

◆ GetApiVersion()

int yaze::core::AsarWrapper::GetApiVersion ( ) const

Get Asar API version.

Returns
API version number

Definition at line 61 of file asar_wrapper.cc.

References initialized_.

◆ ApplyPatch()

absl::StatusOr< AsarPatchResult > yaze::core::AsarWrapper::ApplyPatch ( const std::string &  patch_path,
std::vector< uint8_t > &  rom_data,
const std::vector< std::string > &  include_paths = {} 
)

Apply an assembly patch to a ROM.

Parameters
patch_pathPath to the .asm patch file
rom_dataROM data to patch (will be modified)
include_pathsAdditional include paths for assembly files
Returns
Patch result with status and extracted information
Todo:
Implement CRC32 calculation

Definition at line 68 of file asar_wrapper.cc.

References yaze::core::AsarPatchResult::crc32, yaze::core::AsarPatchResult::errors, ExtractSymbolsFromLastOperation(), initialized_, last_errors_, last_warnings_, ProcessErrors(), ProcessWarnings(), Reset(), yaze::core::AsarPatchResult::rom_size, yaze::core::AsarPatchResult::success, symbol_table_, yaze::core::AsarPatchResult::symbols, and yaze::core::AsarPatchResult::warnings.

Referenced by ApplyPatchFromString(), ExtractSymbols(), and ValidateAssembly().

Here is the call graph for this function:

◆ ApplyPatchFromString()

absl::StatusOr< AsarPatchResult > yaze::core::AsarWrapper::ApplyPatchFromString ( const std::string &  patch_content,
std::vector< uint8_t > &  rom_data,
const std::string &  base_path = "" 
)

Apply an assembly patch from string content.

Parameters
patch_contentAssembly source code as string
rom_dataROM data to patch (will be modified)
base_pathBase path for resolving includes
Returns
Patch result with status and extracted information

Definition at line 130 of file asar_wrapper.cc.

References ApplyPatch().

Here is the call graph for this function:

◆ ExtractSymbols()

absl::StatusOr< std::vector< AsarSymbol > > yaze::core::AsarWrapper::ExtractSymbols ( const std::string &  asm_path,
const std::vector< std::string > &  include_paths = {} 
)

Extract symbols from an assembly file without patching.

Parameters
asm_pathPath to the assembly file
include_pathsAdditional include paths
Returns
Vector of extracted symbols

Definition at line 160 of file asar_wrapper.cc.

References ApplyPatch(), and initialized_.

Here is the call graph for this function:

◆ GetSymbolTable()

std::map< std::string, AsarSymbol > yaze::core::AsarWrapper::GetSymbolTable ( ) const

Get all available symbols from the last patch operation.

Returns
Map of symbol names to symbol information

Definition at line 179 of file asar_wrapper.cc.

References symbol_table_.

◆ FindSymbol()

std::optional< AsarSymbol > yaze::core::AsarWrapper::FindSymbol ( const std::string &  name) const

Find a symbol by name.

Parameters
nameSymbol name to search for
Returns
Symbol information if found

Definition at line 183 of file asar_wrapper.cc.

References symbol_table_.

◆ GetSymbolsAtAddress()

std::vector< AsarSymbol > yaze::core::AsarWrapper::GetSymbolsAtAddress ( uint32_t  address) const

Get symbols at a specific address.

Parameters
addressMemory address to search
Returns
Vector of symbols at that address

Definition at line 191 of file asar_wrapper.cc.

References symbol_table_.

◆ Reset()

void yaze::core::AsarWrapper::Reset ( )

Reset the Asar state (clear errors, warnings, symbols)

Definition at line 201 of file asar_wrapper.cc.

References initialized_, last_errors_, last_warnings_, and symbol_table_.

Referenced by ApplyPatch().

◆ GetLastErrors()

std::vector< std::string > yaze::core::AsarWrapper::GetLastErrors ( ) const
inline

Get the last error messages.

Returns
Vector of error strings

Definition at line 153 of file asar_wrapper.h.

References last_errors_.

◆ GetLastWarnings()

std::vector< std::string > yaze::core::AsarWrapper::GetLastWarnings ( ) const
inline

Get the last warning messages.

Returns
Vector of warning strings

Definition at line 159 of file asar_wrapper.h.

References last_warnings_.

◆ CreatePatch()

absl::Status yaze::core::AsarWrapper::CreatePatch ( const std::vector< uint8_t > &  original_rom,
const std::vector< uint8_t > &  modified_rom,
const std::string &  patch_path 
)

Create a patch that can be applied to transform one ROM to another.

Parameters
original_romOriginal ROM data
modified_romModified ROM data
patch_pathOutput path for the generated patch
Returns
Status indicating success or failure

Definition at line 210 of file asar_wrapper.cc.

◆ ValidateAssembly()

absl::Status yaze::core::AsarWrapper::ValidateAssembly ( const std::string &  asm_path)

Validate an assembly file for syntax errors.

Parameters
asm_pathPath to the assembly file
Returns
Status indicating validation result

Definition at line 225 of file asar_wrapper.cc.

References ApplyPatch().

Here is the call graph for this function:

◆ ProcessErrors()

void yaze::core::AsarWrapper::ProcessErrors ( )
private

Process errors from Asar and store them.

Definition at line 243 of file asar_wrapper.cc.

References last_errors_.

Referenced by ApplyPatch().

◆ ProcessWarnings()

void yaze::core::AsarWrapper::ProcessWarnings ( )
private

Process warnings from Asar and store them.

Definition at line 254 of file asar_wrapper.cc.

References last_warnings_.

Referenced by ApplyPatch().

◆ ExtractSymbolsFromLastOperation()

void yaze::core::AsarWrapper::ExtractSymbolsFromLastOperation ( )
private

◆ ConvertAsarSymbol()

AsarSymbol yaze::core::AsarWrapper::ConvertAsarSymbol ( const void *  asar_symbol_data) const
private

Convert Asar symbol data to AsarSymbol struct.

Definition at line 285 of file asar_wrapper.cc.

Member Data Documentation

◆ initialized_

bool yaze::core::AsarWrapper::initialized_
private

◆ symbol_table_

std::map<std::string, AsarSymbol> yaze::core::AsarWrapper::symbol_table_
private

◆ last_errors_

std::vector<std::string> yaze::core::AsarWrapper::last_errors_
private

Definition at line 183 of file asar_wrapper.h.

Referenced by ApplyPatch(), GetLastErrors(), ProcessErrors(), and Reset().

◆ last_warnings_

std::vector<std::string> yaze::core::AsarWrapper::last_warnings_
private

Definition at line 184 of file asar_wrapper.h.

Referenced by ApplyPatch(), GetLastWarnings(), ProcessWarnings(), and Reset().


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