13#include "yaze_config.h"
16 "Path to the ROM file to load. "
17 "If not specified, the app will run without a ROM.");
22 std::string rom_filename =
"";
23 if (!FLAGS_rom_file->Get().empty()) {
24 rom_filename = FLAGS_rom_file->Get();
28 return yaze_run_cocoa_app_delegate(rom_filename.c_str());
31 auto controller = std::make_unique<yaze::core::Controller>();
33 while (controller->IsActive()) {
34 controller->OnInput();
35 if (
auto status = controller->OnLoad(); !status.ok()) {
36 std::cerr << status.message() << std::endl;
39 controller->DoRender();
46 std::string current_version;
48 ss << YAZE_VERSION_MAJOR <<
"." << YAZE_VERSION_MINOR <<
"."
49 << YAZE_VERSION_PATCH;
50 ss >> current_version;
52 if (version != current_version) {
53 std::cout <<
"Yaze version mismatch: expected " << current_version
54 <<
", got " << version << std::endl;
61 if (yaze_ctx->
rom ==
nullptr) {
63 return yaze_status::YAZE_ERROR;
66 return yaze_status::YAZE_OK;
73 return yaze_status::YAZE_OK;
86 rom->
impl = internal_rom;
87 rom->
data =
const_cast<uint8_t *
>(internal_rom->
data());
106 .backup = true, .save_new = false, .filename = filename});
108 throw std::runtime_error(status.message().data());
118 bitmap.
data =
nullptr;
123 int palette_set,
int palette,
126 color_struct.
red = 0;
127 color_struct.
green = 0;
128 color_struct.
blue = 0;
135 ->palette(palette)[color];
136 color_struct = get_color.rom_color();
145 if (rom->
impl ==
nullptr) {
151 if (!internal_overworld->Load(internal_rom).ok()) {
156 overworld->
impl = internal_overworld;
158 for (
const auto &ow_map : internal_overworld->overworld_maps()) {
160 overworld->
maps[map_id]->
id = map_id;
167 if (rom->
impl ==
nullptr) {
176 if (rom->
impl ==
nullptr) {
177 return yaze_status::YAZE_ERROR;
181 std::vector<yaze::editor::MessageData> message_data =
183 for (
const auto &message : message_data) {
185 messages[message.ID]->
id = message.ID;
186 messages[message.ID]->
address = message.Address;
187 messages[message.ID]->
raw_string =
reinterpret_cast<uint8_t *
>(
188 const_cast<char *
>(message.RawString.data()));
190 const_cast<char *
>(message.ContentsParsed.data()));
191 messages[message.ID]->
data =
192 reinterpret_cast<uint8_t *
>(
const_cast<uint8_t *
>(message.Data.data()));
193 messages[message.ID]->
data_parsed =
reinterpret_cast<uint8_t *
>(
194 const_cast<uint8_t *
>(message.DataParsed.data()));
197 return yaze_status::YAZE_OK;
The Rom class is used to load, save, and modify Rom data.
absl::Status LoadFromFile(const std::string &filename, bool z3_load=true)
auto palette_group() const
absl::Status SaveToFile(const SaveSettings &settings)
void Parse(int argc, char **argv)
Represents the full Overworld data, light and dark world.
#define DEFINE_FLAG(type, name, default_val, help_text)
#define RETURN_IF_EXCEPTION(expression)
#define EXIT_IF_ERROR(expression)
std::vector< MessageData > ReadAllTextData(uint8_t *rom, int pos)
constexpr const char * kPaletteGroupAddressesKeys[]
FlagRegistry * global_flag_registry()
Primitive of 16-bit RGB SNES color.
const char * error_message
uint8_t * contents_parsed
Primitive of the overworld.
zelda3_overworld_map ** maps
zelda3_overworld * yaze_load_overworld(const zelda3_rom *rom)
Load the overworld from the ROM.
void yaze_unload_rom(zelda3_rom *rom)
yaze_status yaze_shutdown(yaze_editor_context *yaze_ctx)
yaze_status yaze_load_messages(zelda3_rom *rom, zelda3_message **messages)
Load all messages from the ROM.
yaze_bitmap yaze_load_bitmap(const char *filename)
int yaze_app_main(int argc, char **argv)
zelda3_dungeon_room * yaze_load_all_rooms(const zelda3_rom *rom)
Load all rooms from the ROM.
yaze_status yaze_init(yaze_editor_context *yaze_ctx, char *rom_filename)
void yaze_check_version(const char *version)
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_rom * yaze_load_rom(const char *filename)
void yaze_save_rom(zelda3_rom *rom, const char *filename)
struct zelda3_overworld_map zelda3_overworld_map
Primitive of an overworld map.
struct zelda3_message zelda3_message
Primitive of a message.
struct zelda3_overworld zelda3_overworld
Primitive of the overworld.
struct zelda3_rom zelda3_rom