Refactor sprite and editor context structures to use typedefs for clarity; add bitmap loading function
This commit is contained in:
@@ -10,11 +10,11 @@ extern "C" {
|
|||||||
/**
|
/**
|
||||||
* @brief Primitive of a sprite.
|
* @brief Primitive of a sprite.
|
||||||
*/
|
*/
|
||||||
struct z3_sprite {
|
typedef struct z3_sprite {
|
||||||
const char* name; /**< Name of the sprite. */
|
const char* name; /**< Name of the sprite. */
|
||||||
uint8_t id; /**< ID of the sprite. */
|
uint8_t id; /**< ID of the sprite. */
|
||||||
};
|
uint8_t subtype; /**< Subtype of the sprite. */
|
||||||
typedef struct z3_sprite z3_sprite;
|
} z3_sprite;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/yaze.cc
16
src/yaze.cc
@@ -70,6 +70,15 @@ void yaze_unload_rom(z3_rom* rom) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
yaze_bitmap yaze_load_bitmap(const char* filename) {
|
||||||
|
yaze_bitmap bitmap;
|
||||||
|
bitmap.width = 0;
|
||||||
|
bitmap.height = 0;
|
||||||
|
bitmap.bpp = 0;
|
||||||
|
bitmap.data = nullptr;
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
snes_color yaze_get_color_from_paletteset(const z3_rom* rom, int palette_set,
|
snes_color yaze_get_color_from_paletteset(const z3_rom* rom, int palette_set,
|
||||||
int palette, int color) {
|
int palette, int color) {
|
||||||
snes_color color_struct;
|
snes_color color_struct;
|
||||||
@@ -101,11 +110,8 @@ z3_overworld* yaze_load_overworld(const z3_rom* rom) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
yaze::app::Rom* internal_rom = static_cast<yaze::app::Rom*>(rom->impl);
|
yaze::app::Rom* internal_rom = static_cast<yaze::app::Rom*>(rom->impl);
|
||||||
|
auto internal_overworld = new yaze::app::zelda3::overworld::Overworld();
|
||||||
yaze::app::zelda3::overworld::Overworld* internal_overworld =
|
if (!internal_overworld->Load(*internal_rom).ok()) {
|
||||||
new yaze::app::zelda3::overworld::Overworld();
|
|
||||||
auto load_ow = internal_overworld->Load(*internal_rom);
|
|
||||||
if (!load_ow.ok()) {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
21
src/yaze.h
21
src/yaze.h
@@ -21,18 +21,16 @@ typedef struct yaze_project yaze_project;
|
|||||||
typedef struct yaze_command_registry yaze_command_registry;
|
typedef struct yaze_command_registry yaze_command_registry;
|
||||||
typedef struct yaze_event_dispatcher yaze_event_dispatcher;
|
typedef struct yaze_event_dispatcher yaze_event_dispatcher;
|
||||||
|
|
||||||
typedef struct yaze_editor_context yaze_editor_context;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Extension editor context.
|
* @brief Extension editor context.
|
||||||
*/
|
*/
|
||||||
struct yaze_editor_context {
|
typedef struct yaze_editor_context {
|
||||||
yaze_project* project;
|
yaze_project* project;
|
||||||
yaze_flags* flags;
|
yaze_flags* flags;
|
||||||
|
|
||||||
yaze_command_registry* command_registry;
|
yaze_command_registry* command_registry;
|
||||||
yaze_event_dispatcher* event_dispatcher;
|
yaze_event_dispatcher* event_dispatcher;
|
||||||
};
|
} yaze_editor_context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Flags to initialize the Yaze library.
|
* @brief Flags to initialize the Yaze library.
|
||||||
@@ -92,6 +90,21 @@ z3_rom* yaze_load_rom(const char* filename);
|
|||||||
*/
|
*/
|
||||||
void yaze_unload_rom(z3_rom* rom);
|
void yaze_unload_rom(z3_rom* rom);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Primitive of a Bitmap
|
||||||
|
*/
|
||||||
|
typedef struct yaze_bitmap {
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
uint8_t bpp;
|
||||||
|
uint8_t* data;
|
||||||
|
} yaze_bitmap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Load a bitmap from a file.
|
||||||
|
*/
|
||||||
|
yaze_bitmap yaze_load_bitmap(const char* filename);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get a color from a palette set.
|
* @brief Get a color from a palette set.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user