This document provides a reference for the yaze C and C++ APIs, intended for developers creating extensions or contributing to the core application.
C API (<tt>incl/yaze.h</tt>)
The C API provides a stable, language-agnostic interface for interacting with yaze's core functionalities.
Core Library Functions
yaze_status yaze_library_init(void)
Initialize the YAZE library.
const char * yaze_get_version_string(void)
Get the current YAZE version string.
yaze_status
Status codes returned by YAZE functions.
void yaze_library_shutdown(void)
Shutdown the YAZE library.
ROM Operations
void yaze_unload_rom(zelda3_rom *rom)
Unload and free ROM data.
zelda3_rom * yaze_load_rom(const char *filename)
Load a ROM file.
int yaze_save_rom(zelda3_rom *rom, const char *filename)
Save ROM to file.
C++ API
The C++ API offers a more powerful, object-oriented interface. The primary entry point for many operations is the yaze::core::AsarWrapper
class.
AsarWrapper (<tt>src/app/core/asar_wrapper.h</tt>)
This class provides a complete, cross-platform interface for applying assembly patches, extracting symbols, and validating assembly code using the Asar library.
CLI Examples (<tt>z3ed</tt>)
While the AsarWrapper
can be used programmatically, the z3ed
CLI is the most common way to interact with it.
# Apply an assembly patch to a ROM file.
z3ed asar my_patch.asm --rom=zelda3.sfc
# For more complex operations, use the AI agent.
z3ed agent chat --rom zelda3.sfc
Prompt: "Apply the patch `mosaic_change.asm` to my ROM."
C++ API Example
#include <vector>
#include <string>
auto result = wrapper.
ApplyPatch(
"patch.asm", rom_data);
if (result.ok() && result->success) {
for (const auto& symbol : result->symbols) {
std::cout << symbol.name << " @ $" << std::hex << symbol.address << std::endl;
}
}
Modern C++ wrapper for Asar 65816 assembler integration.
absl::Status Initialize()
Initialize the Asar library.
absl::StatusOr< AsarPatchResult > 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.
Class Definition
class AsarWrapper {
public:
const std::string& patch_path,
std::vector<uint8_t>& rom_data,
const std::vector<std::string>& include_paths = {});
const std::string& asm_path,
const std::vector<std::string>& include_paths = {});
};
}
absl::Status ValidateAssembly(const std::string &asm_path)
Validate an assembly file for syntax errors.
void Shutdown()
Clean up and close the Asar library.
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.
Data Structures
<tt>snes_color</tt>
Represents a 15-bit SNES color, composed of 5 bits for each red, green, and blue component.
uint16_t raw;
SNES color in 15-bit RGB format (BGR555)
<tt>zelda3_message</tt>
Represents an in-game text message.
}
In-game text message data.
Error Handling
The C API uses an enum yaze_status
for error handling, while the C++ API uses absl::Status
and absl::StatusOr
.
C API Error Pattern
return 1;
}
const char * yaze_status_to_string(yaze_status status)
Convert a status code to a human-readable string.