yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
macro.h File Reference

Go to the source code of this file.

Macros

#define TAB_ITEM(w)   if (ImGui::BeginTabItem(w)) {
 
#define END_TAB_ITEM()
 
#define BEGIN_TABLE(l, n, f)   if (ImGui::BeginTable(l, n, f, ImVec2(0, 0))) {
 
#define SETUP_COLUMN(l)   ImGui::TableSetupColumn(l);
 
#define TABLE_HEADERS()
 
#define NEXT_COLUMN()   ImGui::TableNextColumn();
 
#define END_TABLE()
 
#define HOVER_HINT(string)
 
#define PRINT_IF_ERROR(expression)
 
#define EXIT_IF_ERROR(expression)
 
#define RETURN_VOID_IF_ERROR(expression)
 
#define RETURN_IF_ERROR(expression)
 
#define ASSIGN_OR_RETURN(type_variable_name, expression)
 
#define ASSIGN_OR_RETURN_IMPL(error_or_value, type_variable_name, expression)
 
#define ASSIGN_OR_LOG_ERROR(type_variable_name, expression)
 
#define ASSIGN_OR_LOG_ERROR_IMPL(error_or_value, type_variable_name, expression)
 
#define APPEND_NUMBER(expression, number)    APPEND_NUMBER_INNER(expression, number)
 
#define APPEND_NUMBER_INNER(expression, number)   expression##number
 
#define TEXT_WITH_SEPARATOR(text)
 
#define TABLE_BORDERS_RESIZABLE    ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable
 
#define CLEAR_AND_RETURN_STATUS(status)
 
#define RETURN_IF_EXCEPTION(expression)
 
#define SDL_RETURN_IF_ERROR()
 
#define RETURN_IF_ROM_OUT_OF_RANGE(rom, offset, size)
 Validate ROM offset is within bounds before reading/writing.
 
#define RETURN_FALSE_IF_ROM_OUT_OF_RANGE(rom, offset, size)
 Validate ROM offset is within bounds, returning false on failure.
 
#define RETURN_IF_ROOM_OUT_OF_RANGE(room_id)
 Validate room ID is within valid dungeon room range.
 
#define RETURN_IF_MAP_OUT_OF_RANGE(map_id)
 Validate overworld map ID is within valid range.
 
#define RETURN_IF_PALETTE_OUT_OF_RANGE(palette_id, max_palettes)
 Validate palette index is within SNES palette group range.
 

Typedefs

using uint = unsigned int
 

Macro Definition Documentation

◆ TAB_ITEM

#define TAB_ITEM ( w)    if (ImGui::BeginTabItem(w)) {

Definition at line 6 of file macro.h.

◆ END_TAB_ITEM

#define END_TAB_ITEM ( )
Value:
ImGui::EndTabItem(); \
}

Definition at line 7 of file macro.h.

◆ BEGIN_TABLE

#define BEGIN_TABLE ( l,
n,
f )   if (ImGui::BeginTable(l, n, f, ImVec2(0, 0))) {

◆ SETUP_COLUMN

#define SETUP_COLUMN ( l)    ImGui::TableSetupColumn(l);

◆ TABLE_HEADERS

#define TABLE_HEADERS ( )
Value:
ImGui::TableHeadersRow(); \
ImGui::TableNextRow();

Definition at line 14 of file macro.h.

Referenced by yaze::editor::GraphicsEditor::DrawPrototypeViewer().

◆ NEXT_COLUMN

#define NEXT_COLUMN ( )    ImGui::TableNextColumn();

◆ END_TABLE

#define END_TABLE ( )
Value:
ImGui::EndTable(); \
}

Definition at line 20 of file macro.h.

Referenced by yaze::editor::GraphicsEditor::DrawPrototypeViewer(), and yaze::editor::MemoryEditor::Update().

◆ HOVER_HINT

◆ PRINT_IF_ERROR

#define PRINT_IF_ERROR ( expression)
Value:
{ \
auto error = expression; \
if (!error.ok()) { \
std::cout << error.ToString() << std::endl; \
} \
}

Definition at line 28 of file macro.h.

Referenced by yaze::editor::ScreenEditor::DrawDungeonMapsEditor(), yaze::editor::MessageEditor::DrawExpandedMessageSettings(), yaze::editor::EditorManager::Initialize(), yaze::editor::OverworldEditor::RefreshChildMap(), and yaze::editor::MemoryEditor::Update().

◆ EXIT_IF_ERROR

#define EXIT_IF_ERROR ( expression)
Value:
{ \
auto error = expression; \
if (!error.ok()) { \
std::cout << error.ToString() << std::endl; \
return EXIT_FAILURE; \
} \
}

Definition at line 36 of file macro.h.

◆ RETURN_VOID_IF_ERROR

#define RETURN_VOID_IF_ERROR ( expression)
Value:
{ \
auto error = expression; \
if (!error.ok()) { \
std::cout << error.ToString() << std::endl; \
return; \
} \
}

Definition at line 45 of file macro.h.

◆ RETURN_IF_ERROR

#define RETURN_IF_ERROR ( expression)
Value:
{ \
auto error = expression; \
if (!error.ok()) { \
return error; \
} \
}

Definition at line 54 of file macro.h.

◆ ASSIGN_OR_RETURN

#define ASSIGN_OR_RETURN ( type_variable_name,
expression )
Value:
ASSIGN_OR_RETURN_IMPL(APPEND_NUMBER(error_or_value, __LINE__), \
type_variable_name, expression)
#define APPEND_NUMBER(expression, number)
Definition macro.h:85
#define ASSIGN_OR_RETURN_IMPL(error_or_value, type_variable_name, expression)
Definition macro.h:66

Definition at line 62 of file macro.h.

Referenced by yaze::cli::RomSandboxManager::ActiveSandboxRomPath(), yaze::cli::overworld::AnalyzeTileUsage(), yaze::zelda3::Overworld::AssembleMap16Tiles(), yaze::zelda3::Overworld::AssembleMap32Tiles(), yaze::cli::overworld::BuildMapSummary(), yaze::zelda3::Inventory::BuildTileset(), yaze::zelda3::TitleScreen::BuildTileset(), yaze::zelda3::OverworldMapScreen::Create(), yaze::editor::GraphicsEditor::DecompressImportData(), yaze::editor::GraphicsEditor::DecompressSuperDonkey(), yaze::net::HttpLibClient::Delete(), yaze::cli::OverworldDoctorCommandHandler::Execute(), yaze::cli::OverworldValidateCommandHandler::Execute(), yaze::cli::handlers::ResourceListCommandHandler::Execute(), yaze::cli::overworld::FindTileMatches(), yaze::cli::Tile16Proposal::FromJson(), yaze::net::HttpLibClient::Get(), yaze::zelda3::Overworld::GetTile16ForTile32(), yaze::cli::agent::HandleAcceptCommand(), yaze::cli::agent::HandleDescribeCommand(), yaze::cli::HandleOverworldDescribeMapLegacy(), yaze::cli::HandleOverworldFindTileLegacy(), yaze::cli::HandleOverworldListWarpsLegacy(), yaze::cli::agent::HandleRunCommand(), yaze::editor::AgentCollaborationCoordinator::JoinSession(), yaze::editor::DungeonEditorV2::Load(), yaze::editor::ScreenEditor::Load(), yaze::editor::OverworldEditor::Load(), yaze::zelda3::Overworld::Load(), yaze::Load2BppGraphics(), yaze::editor::DungeonCanvasViewer::LoadAndRenderRoomGraphics(), yaze::zelda3::Overworld::LoadDiggableTiles(), yaze::zelda3::LoadDungeonMaps(), yaze::zelda3::LoadDungeonMapTile16(), yaze::zelda3::LoadEntrances(), yaze::zelda3::LoadEntranceTileTypes(), yaze::zelda3::LoadHoles(), yaze::zelda3::music::MusicBank::LoadInstruments(), yaze::zelda3::Inventory::LoadItemIcons(), yaze::zelda3::LoadItems(), yaze::LoadLinkGraphics(), yaze::zelda3::OverworldMapScreen::LoadMapData(), yaze::zelda3::OverworldMap::LoadPalette(), yaze::editor::PolyhedralEditorPanel::LoadShapes(), yaze::zelda3::Overworld::LoadSpritesFromMap(), yaze::zelda3::TitleScreen::LoadTitleScreen(), yaze::cli::agent::anonymous_namespace{general_commands.cc}::ParseDescribeArgs(), yaze::test::TestScriptParser::ParseFromFile(), yaze::cli::anonymous_namespace{test_suite_loader.cc}::ParseScalarConfig(), yaze::net::HttpLibClient::Post(), yaze::net::HttpLibClient::Put(), yaze::Rom::ReadHelper(), yaze::Rom::ReadTile16(), yaze::Rom::ReadTile16(), yaze::cli::resources::CommandHandler::Run(), yaze::zelda3::TitleScreen::Save(), yaze::Rom::SaveGfxGroups(), yaze::zelda3::SaveGfxGroups(), yaze::project::YazeProject::SaveToYazeFormat(), yaze::gfx::lc_lz2::ValidateCompressionResult(), yaze::gfx::lc_lz2::ValidateCompressionResultV3(), and yaze::cli::WriteJUnitReport().

◆ ASSIGN_OR_RETURN_IMPL

#define ASSIGN_OR_RETURN_IMPL ( error_or_value,
type_variable_name,
expression )
Value:
auto error_or_value = expression; \
if (!error_or_value.ok()) { \
return error_or_value.status(); \
} \
type_variable_name = std::move(*error_or_value)

Definition at line 66 of file macro.h.

◆ ASSIGN_OR_LOG_ERROR

#define ASSIGN_OR_LOG_ERROR ( type_variable_name,
expression )
Value:
ASSIGN_OR_LOG_ERROR_IMPL(APPEND_NUMBER(error_or_value, __LINE__), \
type_variable_name, expression)
#define ASSIGN_OR_LOG_ERROR_IMPL(error_or_value, type_variable_name, expression)
Definition macro.h:77

Definition at line 73 of file macro.h.

◆ ASSIGN_OR_LOG_ERROR_IMPL

#define ASSIGN_OR_LOG_ERROR_IMPL ( error_or_value,
type_variable_name,
expression )
Value:
auto error_or_value = expression; \
if (!error_or_value.ok()) { \
std::cout << error_or_value.status().ToString() << std::endl; \
} \
type_variable_name = std::move(*error_or_value);

Definition at line 77 of file macro.h.

◆ APPEND_NUMBER

#define APPEND_NUMBER ( expression,
number )    APPEND_NUMBER_INNER(expression, number)

Definition at line 85 of file macro.h.

◆ APPEND_NUMBER_INNER

#define APPEND_NUMBER_INNER ( expression,
number )   expression##number

Definition at line 88 of file macro.h.

◆ TEXT_WITH_SEPARATOR

#define TEXT_WITH_SEPARATOR ( text)
Value:
ImGui::Text(text); \
ImGui::Separator();

Definition at line 90 of file macro.h.

Referenced by yaze::editor::DisplayPalette().

◆ TABLE_BORDERS_RESIZABLE

#define TABLE_BORDERS_RESIZABLE    ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable

Definition at line 94 of file macro.h.

◆ CLEAR_AND_RETURN_STATUS

#define CLEAR_AND_RETURN_STATUS ( status)
Value:
if (!status.ok()) { \
auto temp = status; \
status = absl::OkStatus(); \
return temp; \
}

Definition at line 97 of file macro.h.

Referenced by yaze::editor::GraphicsEditor::Update().

◆ RETURN_IF_EXCEPTION

#define RETURN_IF_EXCEPTION ( expression)
Value:
try { \
expression; \
} catch (const std::exception& e) { \
std::cerr << e.what() << std::endl; \
return EXIT_FAILURE; \
}

Definition at line 104 of file macro.h.

Referenced by main().

◆ SDL_RETURN_IF_ERROR

#define SDL_RETURN_IF_ERROR ( )
Value:
if (SDL_GetError() != nullptr) { \
return absl::InternalError(SDL_GetError()); \
}

Definition at line 112 of file macro.h.

◆ RETURN_IF_ROM_OUT_OF_RANGE

#define RETURN_IF_ROM_OUT_OF_RANGE ( rom,
offset,
size )
Value:
do { \
if (((offset) + (size)) > (rom)->size()) { \
return absl::OutOfRangeError( \
absl::StrFormat("ROM access out of range: offset 0x%X + size " \
"0x%X exceeds ROM size 0x%X", \
(offset), (size), (rom)->size())); \
} \
} while (0)

Validate ROM offset is within bounds before reading/writing.

Returns absl::OutOfRangeError if the offset + size exceeds ROM size.

Parameters
romPointer to the Rom object
offsetStart offset for the operation
sizeNumber of bytes to read/write

Definition at line 132 of file macro.h.

◆ RETURN_FALSE_IF_ROM_OUT_OF_RANGE

#define RETURN_FALSE_IF_ROM_OUT_OF_RANGE ( rom,
offset,
size )
Value:
do { \
if (((offset) + (size)) > (rom)->size()) { \
return false; \
} \
} while (0)

Validate ROM offset is within bounds, returning false on failure.

Use this variant for bool-returning functions that can't return Status.

Parameters
romPointer to the Rom object
offsetStart offset for the operation
sizeNumber of bytes to read/write

Definition at line 151 of file macro.h.

◆ RETURN_IF_ROOM_OUT_OF_RANGE

#define RETURN_IF_ROOM_OUT_OF_RANGE ( room_id)
Value:
do { \
constexpr int kMaxRoomId = 296; \
if ((room_id) < 0 || (room_id) >= kMaxRoomId) { \
return absl::OutOfRangeError(absl::StrFormat( \
"Room ID %d out of range [0, %d)", (room_id), kMaxRoomId)); \
} \
} while (0)

Validate room ID is within valid dungeon room range.

SNES A Link to the Past has 296 dungeon rooms (0x000-0x127).

Parameters
room_idThe room ID to validate

Definition at line 165 of file macro.h.

◆ RETURN_IF_MAP_OUT_OF_RANGE

#define RETURN_IF_MAP_OUT_OF_RANGE ( map_id)
Value:
do { \
constexpr int kMaxMapId = 160; \
if ((map_id) < 0 || (map_id) >= kMaxMapId) { \
return absl::OutOfRangeError(absl::StrFormat( \
"Map ID %d out of range [0, %d)", (map_id), kMaxMapId)); \
} \
} while (0)

Validate overworld map ID is within valid range.

SNES A Link to the Past has 160 overworld maps (0x00-0x9F).

Parameters
map_idThe map ID to validate

Definition at line 181 of file macro.h.

◆ RETURN_IF_PALETTE_OUT_OF_RANGE

#define RETURN_IF_PALETTE_OUT_OF_RANGE ( palette_id,
max_palettes )
Value:
do { \
if ((palette_id) < 0 || (palette_id) >= (max_palettes)) { \
return absl::OutOfRangeError(absl::StrFormat( \
"Palette ID %d out of range [0, %d)", \
(palette_id), (max_palettes))); \
} \
} while (0)

Validate palette index is within SNES palette group range.

SNES palettes have 16 entries (0-15) per sub-palette.

Parameters
palette_idThe palette index to validate
max_palettesMaximum number of palettes in the group

Definition at line 198 of file macro.h.

Typedef Documentation

◆ uint

using uint = unsigned int

Definition at line 4 of file macro.h.