yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
API Reference

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

const char* yaze_get_version_string(void);
yaze_status yaze_library_init()
Initialize the YAZE library.
Definition yaze.cc:19
const char * yaze_get_version_string()
Get the current YAZE version string.
Definition yaze.cc:63
yaze_status
Status codes returned by YAZE functions.
Definition yaze.h:65
void yaze_library_shutdown()
Shutdown the YAZE library.
Definition yaze.cc:29

ROM Operations

zelda3_rom* yaze_load_rom(const char* filename);
yaze_status yaze_save_rom(zelda3_rom* rom, const char* filename);
void yaze_unload_rom(zelda3_rom *rom)
Unload and free ROM data.
Definition yaze.cc:142
zelda3_rom * yaze_load_rom(const char *filename)
Load a ROM file.
Definition yaze.cc:114
int yaze_save_rom(zelda3_rom *rom, const char *filename)
Save ROM to file.
Definition yaze.cc:160
ROM data structure.
Definition zelda.h:210

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>
// Assume rom_data is a std::vector<uint8_t> holding the ROM content.
wrapper.Initialize();
// Apply a patch to the ROM data in memory.
auto result = wrapper.ApplyPatch("patch.asm", rom_data);
if (result.ok() && result->success) {
// On success, print the symbols generated by the patch.
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

namespace yaze::core {
class AsarWrapper {
public:
absl::Status Initialize();
void Shutdown();
absl::StatusOr<AsarPatchResult> ApplyPatch(
const std::string& patch_path,
std::vector<uint8_t>& rom_data,
const std::vector<std::string>& include_paths = {});
absl::StatusOr<std::vector<AsarSymbol>> ExtractSymbols(
const std::string& asm_path,
const std::vector<std::string>& include_paths = {});
absl::Status ValidateAssembly(const std::string& asm_path);
};
} // namespace yaze::core
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.

typedef struct snes_color {
uint16_t raw;
uint8_t red;
uint8_t green;
uint8_t blue;
struct snes_color snes_color
SNES color in 15-bit RGB format (BGR555)
SNES color in 15-bit RGB format (BGR555)
Definition yaze.h:218
uint16_t green
Definition yaze.h:220
uint16_t red
Definition yaze.h:219
uint16_t blue
Definition yaze.h:221

zelda3_message

Represents an in-game text message.

typedef struct zelda3_message {
uint16_t id;
uint32_t rom_address;
uint16_t length;
uint8_t* raw_data;
char* parsed_text;
}
struct zelda3_message zelda3_message
In-game text message data.
In-game text message data.
Definition zelda.h:272
uint32_t rom_address
Definition zelda.h:274
uint8_t * raw_data
Definition zelda.h:276
uint16_t id
Definition zelda.h:273
bool is_compressed
Definition zelda.h:278
char * parsed_text
Definition zelda.h:277
uint16_t length
Definition zelda.h:275

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

if (status != YAZE_OK) {
fprintf(stderr, "Failed to initialize YAZE: %s\n", yaze_status_to_string(status));
return 1;
}
// ... operations ...
const char * yaze_status_to_string(yaze_status status)
Convert a status code to a human-readable string.
Definition yaze.cc:40
@ YAZE_OK
Definition yaze.h:66