Update yaze lib source
This commit is contained in:
48
src/yaze.cc
48
src/yaze.cc
@@ -1,21 +1,22 @@
|
|||||||
#include "yaze.h"
|
#include "yaze.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <iostream>
|
||||||
|
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
#include "app/zelda3/overworld/overworld.h"
|
#include "app/zelda3/overworld/overworld.h"
|
||||||
|
#include "dungeon.h"
|
||||||
|
|
||||||
void yaze_check_version(const char* version) {
|
void yaze_check_version(const char *version) {
|
||||||
printf("Yaze version: %s\n", version);
|
std::cout << "Yaze version: " << version << std::endl;
|
||||||
auto version_check = yaze::core::CheckVersion(version);
|
auto version_check = yaze::core::CheckVersion(version);
|
||||||
if (!version_check.ok()) {
|
if (!version_check.ok()) {
|
||||||
printf("%s\n", version_check.status().message().data());
|
std::cout << version_check.status().message() << std::endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int yaze_init(yaze_editor_context* yaze_ctx) {
|
int yaze_init(yaze_editor_context *yaze_ctx) {
|
||||||
if (yaze_ctx->project->rom_filename == nullptr) {
|
if (yaze_ctx->project->rom_filename == nullptr) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -28,27 +29,27 @@ int yaze_init(yaze_editor_context* yaze_ctx) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void yaze_cleanup(yaze_editor_context* yaze_ctx) {
|
void yaze_cleanup(yaze_editor_context *yaze_ctx) {
|
||||||
if (yaze_ctx->rom) {
|
if (yaze_ctx->rom) {
|
||||||
yaze_unload_rom(yaze_ctx->rom);
|
yaze_unload_rom(yaze_ctx->rom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
yaze_project yaze_load_project(const char* filename) {
|
yaze_project yaze_load_project(const char *filename) {
|
||||||
yaze_project project;
|
yaze_project project;
|
||||||
project.filepath = filename;
|
project.filepath = filename;
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
z3_rom* yaze_load_rom(const char* filename) {
|
z3_rom *yaze_load_rom(const char *filename) {
|
||||||
yaze::Rom* internal_rom;
|
yaze::Rom *internal_rom;
|
||||||
internal_rom = new yaze::Rom();
|
internal_rom = new yaze::Rom();
|
||||||
if (!internal_rom->LoadFromFile(filename).ok()) {
|
if (!internal_rom->LoadFromFile(filename).ok()) {
|
||||||
delete internal_rom;
|
delete internal_rom;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
z3_rom* rom = new z3_rom();
|
z3_rom *rom = new z3_rom();
|
||||||
rom->filename = filename;
|
rom->filename = filename;
|
||||||
rom->impl = internal_rom;
|
rom->impl = internal_rom;
|
||||||
rom->data = internal_rom->data();
|
rom->data = internal_rom->data();
|
||||||
@@ -56,9 +57,9 @@ z3_rom* yaze_load_rom(const char* filename) {
|
|||||||
return rom;
|
return rom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void yaze_unload_rom(z3_rom* rom) {
|
void yaze_unload_rom(z3_rom *rom) {
|
||||||
if (rom->impl) {
|
if (rom->impl) {
|
||||||
delete static_cast<yaze::Rom*>(rom->impl);
|
delete static_cast<yaze::Rom *>(rom->impl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rom) {
|
if (rom) {
|
||||||
@@ -66,7 +67,7 @@ void yaze_unload_rom(z3_rom* rom) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
yaze_bitmap yaze_load_bitmap(const char* filename) {
|
yaze_bitmap yaze_load_bitmap(const char *filename) {
|
||||||
yaze_bitmap bitmap;
|
yaze_bitmap bitmap;
|
||||||
bitmap.width = 0;
|
bitmap.width = 0;
|
||||||
bitmap.height = 0;
|
bitmap.height = 0;
|
||||||
@@ -75,7 +76,7 @@ yaze_bitmap yaze_load_bitmap(const char* filename) {
|
|||||||
return bitmap;
|
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;
|
||||||
color_struct.red = 0;
|
color_struct.red = 0;
|
||||||
@@ -83,7 +84,7 @@ snes_color yaze_get_color_from_paletteset(const z3_rom* rom, int palette_set,
|
|||||||
color_struct.blue = 0;
|
color_struct.blue = 0;
|
||||||
|
|
||||||
if (rom->impl) {
|
if (rom->impl) {
|
||||||
yaze::Rom* internal_rom = static_cast<yaze::Rom*>(rom->impl);
|
yaze::Rom *internal_rom = static_cast<yaze::Rom *>(rom->impl);
|
||||||
auto get_color =
|
auto get_color =
|
||||||
internal_rom->palette_group()
|
internal_rom->palette_group()
|
||||||
.get_group(yaze::gfx::kPaletteGroupAddressesKeys[palette_set])
|
.get_group(yaze::gfx::kPaletteGroupAddressesKeys[palette_set])
|
||||||
@@ -100,24 +101,33 @@ snes_color yaze_get_color_from_paletteset(const z3_rom* rom, int palette_set,
|
|||||||
return color_struct;
|
return color_struct;
|
||||||
}
|
}
|
||||||
|
|
||||||
z3_overworld* yaze_load_overworld(const z3_rom* rom) {
|
z3_overworld *yaze_load_overworld(const z3_rom *rom) {
|
||||||
if (rom->impl == nullptr) {
|
if (rom->impl == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
yaze::Rom* internal_rom = static_cast<yaze::Rom*>(rom->impl);
|
yaze::Rom *internal_rom = static_cast<yaze::Rom *>(rom->impl);
|
||||||
auto internal_overworld = new yaze::zelda3::overworld::Overworld();
|
auto internal_overworld = new yaze::zelda3::overworld::Overworld();
|
||||||
if (!internal_overworld->Load(*internal_rom).ok()) {
|
if (!internal_overworld->Load(*internal_rom).ok()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
z3_overworld* overworld = new z3_overworld();
|
z3_overworld *overworld = new z3_overworld();
|
||||||
overworld->impl = internal_overworld;
|
overworld->impl = internal_overworld;
|
||||||
int map_id = 0;
|
int map_id = 0;
|
||||||
for (const auto& ow_map : internal_overworld->overworld_maps()) {
|
for (const auto &ow_map : internal_overworld->overworld_maps()) {
|
||||||
overworld->maps[map_id] = new z3_overworld_map();
|
overworld->maps[map_id] = new z3_overworld_map();
|
||||||
overworld->maps[map_id]->id = map_id;
|
overworld->maps[map_id]->id = map_id;
|
||||||
map_id++;
|
map_id++;
|
||||||
}
|
}
|
||||||
return overworld;
|
return overworld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
z3_dungeon_room *yaze_load_all_rooms(const z3_rom *rom) {
|
||||||
|
if (rom->impl == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
yaze::Rom *internal_rom = static_cast<yaze::Rom *>(rom->impl);
|
||||||
|
z3_dungeon_room *rooms = new z3_dungeon_room[256];
|
||||||
|
return rooms;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user