yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze.cc File Reference
#include <cstring>
#include <memory>
#include <string>
#include <vector>
#include "app/editor/message/message_data.h"
#include "rom/rom.h"
#include "yaze.h"
#include "yaze_config.h"
#include "zelda3/game_data.h"
#include "zelda3/overworld/overworld.h"

Go to the source code of this file.

Functions

yaze_status yaze_library_init ()
 Initialize the YAZE library.
 
void yaze_library_shutdown ()
 Shutdown the YAZE library.
 
const char * yaze_status_to_string (yaze_status status)
 Convert a status code to a human-readable string.
 
const char * yaze_get_version_string ()
 Get the current YAZE version string.
 
int yaze_get_version_number ()
 Get the current YAZE version number.
 
bool yaze_check_version_compatibility (const char *expected_version)
 Check if the current YAZE version is compatible with the expected version.
 
yaze_status yaze_init (yaze_editor_context *context, const char *rom_filename)
 Initialize a YAZE editor context.
 
yaze_status yaze_shutdown (yaze_editor_context *context)
 Shutdown and clean up a YAZE editor context.
 
zelda3_romyaze_load_rom (const char *filename)
 Load a ROM file.
 
void yaze_unload_rom (zelda3_rom *rom)
 Unload and free ROM data.
 
int yaze_save_rom (zelda3_rom *rom, const char *filename)
 Save ROM to file.
 
yaze_bitmap yaze_load_bitmap (const char *filename)
 Load a bitmap from file.
 
snes_color yaze_get_color_from_paletteset (const zelda3_rom *rom, int palette_set, int palette, int color)
 Get a color from a palette set.
 
zelda3_overworldyaze_load_overworld (const zelda3_rom *rom)
 Load the overworld from ROM.
 
zelda3_dungeon_roomyaze_load_all_rooms (const zelda3_rom *rom, int *room_count)
 Load all dungeon rooms from ROM.
 
yaze_status yaze_load_messages (const zelda3_rom *rom, zelda3_message **messages, int *message_count)
 Load all text messages from ROM.
 
void yaze_free_bitmap (yaze_bitmap *bitmap)
 Free bitmap data.
 
yaze_bitmap yaze_create_bitmap (int width, int height, uint8_t bpp)
 Create an empty bitmap.
 
snes_color yaze_rgb_to_snes_color (uint8_t r, uint8_t g, uint8_t b)
 Convert RGB888 color to SNES color.
 
void yaze_snes_color_to_rgb (snes_color color, uint8_t *r, uint8_t *g, uint8_t *b)
 Convert SNES color to RGB888.
 
zelda3_version zelda3_detect_version (const uint8_t *rom_data, size_t size)
 Detect ROM version from header data.
 
const char * zelda3_version_to_string (zelda3_version version)
 Get version name as string.
 
const zelda3_version_pointerszelda3_get_version_pointers (zelda3_version version)
 Get version-specific pointers.
 

Function Documentation

◆ yaze_library_init()

yaze_status yaze_library_init ( void )

Initialize the YAZE library.

This function must be called before using any other YAZE functions. It initializes internal subsystems and prepares the library for use.

Returns
YAZE_OK on success, error code on failure

Definition at line 20 of file yaze.cc.

References YAZE_OK.

Referenced by yaze_init().

◆ yaze_library_shutdown()

void yaze_library_shutdown ( void )

Shutdown the YAZE library.

This function cleans up resources allocated by yaze_library_init(). After calling this function, no other YAZE functions should be called until yaze_library_init() is called again.

Definition at line 30 of file yaze.cc.

◆ yaze_status_to_string()

const char * yaze_status_to_string ( yaze_status status)

Convert a status code to a human-readable string.

Parameters
statusThe status code to convert
Returns
A null-terminated string describing the status

Definition at line 41 of file yaze.cc.

References YAZE_ERROR_CORRUPTION, YAZE_ERROR_FILE_NOT_FOUND, YAZE_ERROR_INVALID_ARG, YAZE_ERROR_IO, YAZE_ERROR_MEMORY, YAZE_ERROR_NOT_INITIALIZED, YAZE_ERROR_UNKNOWN, and YAZE_OK.

◆ yaze_get_version_string()

const char * yaze_get_version_string ( void )

Get the current YAZE version string.

Returns
A null-terminated string containing the version

Definition at line 64 of file yaze.cc.

References YAZE_VERSION_STRING.

◆ yaze_get_version_number()

int yaze_get_version_number ( void )

Get the current YAZE version number.

Returns
Version number (major * 10000 + minor * 100 + patch)

Definition at line 66 of file yaze.cc.

References YAZE_VERSION_NUMBER.

◆ yaze_check_version_compatibility()

bool yaze_check_version_compatibility ( const char * expected_version)

Check if the current YAZE version is compatible with the expected version.

Parameters
expected_versionExpected version string (e.g., "0.3.2")
Returns
true if compatible, false otherwise

Definition at line 68 of file yaze.cc.

References YAZE_VERSION_STRING.

◆ yaze_init()

yaze_status yaze_init ( yaze_editor_context * context,
const char * rom_filename )

Initialize a YAZE editor context.

Creates and initializes an editor context for working with ROM files. The context manages the ROM data and provides access to editing functions.

Parameters
contextPointer to context structure to initialize
rom_filenamePath to the ROM file to load (can be NULL to create empty context)
Returns
YAZE_OK on success, error code on failure
Note
The caller is responsible for calling yaze_shutdown() to clean up the context

Definition at line 75 of file yaze.cc.

References yaze_editor_context::error_message, yaze_editor_context::rom, YAZE_ERROR_FILE_NOT_FOUND, YAZE_ERROR_INVALID_ARG, yaze_library_init(), yaze_load_rom(), and YAZE_OK.

Here is the call graph for this function:

◆ yaze_shutdown()

yaze_status yaze_shutdown ( yaze_editor_context * context)

Shutdown and clean up a YAZE editor context.

Releases all resources associated with the context, including ROM data. After calling this function, the context should not be used.

Parameters
contextPointer to context to shutdown
Returns
YAZE_OK on success, error code on failure

Definition at line 101 of file yaze.cc.

References yaze_editor_context::error_message, yaze_editor_context::rom, YAZE_ERROR_INVALID_ARG, YAZE_OK, and yaze_unload_rom().

Here is the call graph for this function:

◆ yaze_load_bitmap()

yaze_bitmap yaze_load_bitmap ( const char * filename)

Load a bitmap from file.

Loads a bitmap image from the specified file. Supports common image formats and SNES-specific formats.

Parameters
filenamePath to the image file
Returns
Bitmap structure with loaded data, or empty bitmap on error
Note
The caller is responsible for freeing the data pointer

Definition at line 182 of file yaze.cc.

References yaze_bitmap::bpp, yaze_bitmap::data, yaze_bitmap::height, and yaze_bitmap::width.

◆ yaze_get_color_from_paletteset()

snes_color yaze_get_color_from_paletteset ( const zelda3_rom * rom,
int palette_set,
int palette,
int color )

Get a color from a palette set.

Retrieves a specific color from a palette set in the ROM.

Parameters
romThe ROM to get the color from
palette_setThe palette set index (0-255)
paletteThe palette index within the set (0-15)
colorThe color index within the palette (0-15)
Returns
The color from the palette set

Definition at line 191 of file yaze.cc.

References snes_color::blue, yaze::gfx::PaletteGroupMap::get_group(), snes_color::green, yaze::gfx::kPaletteGroupAddressesKeys, yaze::gfx::PaletteGroup::palette(), yaze::zelda3::GameData::palette_groups, and snes_color::red.

Here is the call graph for this function:

◆ yaze_load_overworld()

zelda3_overworld * yaze_load_overworld ( const zelda3_rom * rom)

Load the overworld from ROM.

Loads and parses the overworld data from the ROM, including all maps, sprites, and related data structures.

Parameters
romThe ROM to load the overworld from
Returns
Pointer to overworld structure, or NULL on error
Note
Caller must free the returned pointer when done

Definition at line 213 of file yaze.cc.

References zelda3_overworld_map::id, zelda3_overworld::impl, and zelda3_overworld::maps.

◆ yaze_load_all_rooms()

zelda3_dungeon_room * yaze_load_all_rooms ( const zelda3_rom * rom,
int * room_count )

Load all dungeon rooms from ROM.

Loads and parses all dungeon room data from the ROM.

Parameters
romThe ROM to load rooms from
room_countPointer to store the number of rooms loaded
Returns
Array of room structures, or NULL on error
Note
Caller must free the returned array when done

Definition at line 236 of file yaze.cc.

References zelda3_dungeon_room::id.

◆ yaze_load_messages()

yaze_status yaze_load_messages ( const zelda3_rom * rom,
zelda3_message ** messages,
int * message_count )

Load all text messages from ROM.

Loads and parses all in-game text messages from the ROM.

Parameters
romThe ROM to load messages from
messagesPointer to store array of messages
message_countPointer to store number of messages loaded
Returns
YAZE_OK on success, error code on failure
Note
Caller must free the messages array when done

Definition at line 256 of file yaze.cc.

References yaze::Rom::data(), zelda3_message::id, yaze::editor::ReadAllTextData(), YAZE_ERROR_INVALID_ARG, YAZE_ERROR_MEMORY, YAZE_ERROR_NOT_INITIALIZED, and YAZE_OK.

Here is the call graph for this function:

◆ yaze_free_bitmap()

void yaze_free_bitmap ( yaze_bitmap * bitmap)

Free bitmap data.

Releases memory allocated for bitmap pixel data.

Parameters
bitmapPointer to bitmap structure to free

Definition at line 303 of file yaze.cc.

References yaze_bitmap::bpp, yaze_bitmap::data, yaze_bitmap::height, and yaze_bitmap::width.

◆ yaze_create_bitmap()

yaze_bitmap yaze_create_bitmap ( int width,
int height,
uint8_t bpp )

Create an empty bitmap.

Allocates a new bitmap with the specified dimensions.

Parameters
widthWidth in pixels
heightHeight in pixels
bppBits per pixel
Returns
Initialized bitmap structure, or empty bitmap on error

Definition at line 313 of file yaze.cc.

References yaze_bitmap::bpp, yaze_bitmap::data, yaze_bitmap::height, and yaze_bitmap::width.

◆ yaze_rgb_to_snes_color()

snes_color yaze_rgb_to_snes_color ( uint8_t r,
uint8_t g,
uint8_t b )

Convert RGB888 color to SNES color.

Parameters
rRed component (0-255)
gGreen component (0-255)
bBlue component (0-255)
Returns
SNES color structure

Definition at line 329 of file yaze.cc.

References snes_color::blue, snes_color::green, and snes_color::red.

◆ yaze_snes_color_to_rgb()

void yaze_snes_color_to_rgb ( snes_color color,
uint8_t * r,
uint8_t * g,
uint8_t * b )

Convert SNES color to RGB888.

Parameters
colorSNES color to convert
rPointer to store red component (0-255)
gPointer to store green component (0-255)
bPointer to store blue component (0-255)

Definition at line 337 of file yaze.cc.

References snes_color::blue, snes_color::green, and snes_color::red.