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 (incl/yaze.h)
The C API provides a stable, language-agnostic interface for interacting with yaze's core functionalities.
Core Library Functions
yaze_status yaze_library_init()
Initialize the YAZE library.
const char * yaze_get_version_string()
Get the current YAZE version string.
yaze_status
Status codes returned by YAZE functions.
void yaze_library_shutdown()
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 (src/core/asar_wrapper.h)
This class provides a complete, cross-platform interface for applying assembly patches, extracting symbols, and validating assembly code using the Asar library.
CLI Examples (z3ed)
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::StatusOr< AsarPatchResult > ApplyPatch(const std::string &patch_path, std::vector< uint8_t > &rom_data, const std::vector< std::string > &include_paths={})
absl::Status Initialize()
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)
absl::StatusOr< std::vector< AsarSymbol > > ExtractSymbols(const std::string &asm_path, const std::vector< std::string > &include_paths={})
Data Structures
snes_color
Represents a 15-bit SNES color, composed of 5 bits for each red, green, and blue component.
uint16_t raw;
struct snes_color snes_color
SNES color in 15-bit RGB format (BGR555)
SNES color in 15-bit RGB format (BGR555)
zelda3_message
Represents an in-game text message.
}
struct zelda3_message zelda3_message
In-game text message data.
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.