Skip to content

Commit

Permalink
make zapd addresses globals int64_t so they can store uint32_t addres…
Browse files Browse the repository at this point in the history
…ses and -1
  • Loading branch information
Dragorn421 authored and cadmic committed Jun 21, 2024
1 parent afce9b2 commit 175a31f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions ZAPD/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class Globals
fs::path baseRomPath, inputPath, outputPath, sourceOutputPath, cfgPath;
TextureType texType;
CsFloatType floatType = CsFloatType::FloatOnly;
int baseAddress = -1;
int startOffset = -1;
int endOffset = -1;
int64_t baseAddress = -1;
int64_t startOffset = -1;
int64_t endOffset = -1;
ZGame game;
GameConfig cfg;
bool verboseUnaccounted = false;
Expand Down
12 changes: 9 additions & 3 deletions ZAPD/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,19 +435,25 @@ void Arg_CsFloatMode([[maybe_unused]] int& i, [[maybe_unused]] char* argv[])
}
}

uint32_t parse_u32_hex(char* str)
{
static_assert(sizeof(uint32_t) <= sizeof(unsigned long));
return (uint32_t)std::stoul(str, nullptr, 16);
}

void Arg_BaseAddress(int& i, char* argv[])
{
Globals::Instance->baseAddress = std::stoul(argv[++i], nullptr, 16);
Globals::Instance->baseAddress = parse_u32_hex(argv[++i]);
}

void Arg_StartOffset(int& i, char* argv[])
{
Globals::Instance->startOffset = std::stoul(argv[++i], nullptr, 16);
Globals::Instance->startOffset = parse_u32_hex(argv[++i]);
}

void Arg_EndOffset(int& i, char* argv[])
{
Globals::Instance->endOffset = std::stoul(argv[++i], nullptr, 16);
Globals::Instance->endOffset = parse_u32_hex(argv[++i]);
}

int HandleExtract(ZFileMode fileMode, ExporterSet* exporterSet)
Expand Down

0 comments on commit 175a31f

Please sign in to comment.