mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-03-30 01:09:34 +01:00
Update scaninc and preproc with multi-file incbins
This commit is contained in:
parent
f8f7a8e300
commit
e0a83e3d72
@ -325,67 +325,75 @@ void CFile::TryConvertIncbin()
|
|||||||
|
|
||||||
m_pos++;
|
m_pos++;
|
||||||
|
|
||||||
SkipWhitespace();
|
std::printf("{");
|
||||||
|
|
||||||
if (m_buffer[m_pos] != '"')
|
while (true)
|
||||||
RaiseError("expected double quote");
|
|
||||||
|
|
||||||
m_pos++;
|
|
||||||
|
|
||||||
int startPos = m_pos;
|
|
||||||
|
|
||||||
while (m_buffer[m_pos] != '"')
|
|
||||||
{
|
{
|
||||||
if (m_buffer[m_pos] == 0)
|
SkipWhitespace();
|
||||||
|
|
||||||
|
if (m_buffer[m_pos] != '"')
|
||||||
|
RaiseError("expected double quote");
|
||||||
|
|
||||||
|
m_pos++;
|
||||||
|
|
||||||
|
int startPos = m_pos;
|
||||||
|
|
||||||
|
while (m_buffer[m_pos] != '"')
|
||||||
{
|
{
|
||||||
if (m_pos >= m_size)
|
if (m_buffer[m_pos] == 0)
|
||||||
RaiseError("unexpected EOF in path string");
|
{
|
||||||
else
|
if (m_pos >= m_size)
|
||||||
RaiseError("unexpected null character in path string");
|
RaiseError("unexpected EOF in path string");
|
||||||
|
else
|
||||||
|
RaiseError("unexpected null character in path string");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_buffer[m_pos] == '\r' || m_buffer[m_pos] == '\n')
|
||||||
|
RaiseError("unexpected end of line character in path string");
|
||||||
|
|
||||||
|
if (m_buffer[m_pos] == '\\')
|
||||||
|
RaiseError("unexpected escape in path string");
|
||||||
|
|
||||||
|
m_pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_buffer[m_pos] == '\r' || m_buffer[m_pos] == '\n')
|
std::string path(&m_buffer[startPos], m_pos - startPos);
|
||||||
RaiseError("unexpected end of line character in path string");
|
|
||||||
|
m_pos++;
|
||||||
|
|
||||||
|
int fileSize;
|
||||||
|
std::unique_ptr<unsigned char[]> buffer = ReadWholeFile(path, fileSize);
|
||||||
|
|
||||||
|
if ((fileSize % size) != 0)
|
||||||
|
RaiseError("Size %d doesn't evenly divide file size %d.\n", size, fileSize);
|
||||||
|
|
||||||
|
int count = fileSize / size;
|
||||||
|
int offset = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
int data = ExtractData(buffer, offset, size);
|
||||||
|
offset += size;
|
||||||
|
|
||||||
|
if (isSigned)
|
||||||
|
std::printf("%d,", data);
|
||||||
|
else
|
||||||
|
std::printf("%uu,", data);
|
||||||
|
}
|
||||||
|
|
||||||
|
SkipWhitespace();
|
||||||
|
|
||||||
|
if (m_buffer[m_pos] != ',')
|
||||||
|
break;
|
||||||
|
|
||||||
if (m_buffer[m_pos] == '\\')
|
|
||||||
RaiseError("unexpected escape in path string");
|
|
||||||
|
|
||||||
m_pos++;
|
m_pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string path(&m_buffer[startPos], m_pos - startPos);
|
|
||||||
|
|
||||||
m_pos++;
|
|
||||||
|
|
||||||
SkipWhitespace();
|
|
||||||
|
|
||||||
if (m_buffer[m_pos] != ')')
|
if (m_buffer[m_pos] != ')')
|
||||||
RaiseError("expected ')'");
|
RaiseError("expected ')'");
|
||||||
|
|
||||||
m_pos++;
|
m_pos++;
|
||||||
|
|
||||||
std::printf("{");
|
|
||||||
|
|
||||||
int fileSize;
|
|
||||||
std::unique_ptr<unsigned char[]> buffer = ReadWholeFile(path, fileSize);
|
|
||||||
|
|
||||||
if ((fileSize % size) != 0)
|
|
||||||
RaiseError("Size %d doesn't evenly divide file size %d.\n", size, fileSize);
|
|
||||||
|
|
||||||
int count = fileSize / size;
|
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
int data = ExtractData(buffer, offset, size);
|
|
||||||
offset += size;
|
|
||||||
|
|
||||||
if (isSigned)
|
|
||||||
std::printf("%d,", data);
|
|
||||||
else
|
|
||||||
std::printf("%uu,", data);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::printf("}");
|
std::printf("}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,18 +244,27 @@ void CFile::CheckIncbin()
|
|||||||
|
|
||||||
m_pos++;
|
m_pos++;
|
||||||
|
|
||||||
SkipWhitespace();
|
while (true)
|
||||||
|
{
|
||||||
|
SkipWhitespace();
|
||||||
|
|
||||||
std::string path = ReadPath();
|
std::string path = ReadPath();
|
||||||
|
|
||||||
SkipWhitespace();
|
SkipWhitespace();
|
||||||
|
|
||||||
|
m_incbins.emplace(path);
|
||||||
|
|
||||||
|
if (m_buffer[m_pos] != ',')
|
||||||
|
break;
|
||||||
|
|
||||||
|
m_pos++;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_buffer[m_pos] != ')')
|
if (m_buffer[m_pos] != ')')
|
||||||
FATAL_INPUT_ERROR("expected ')'");
|
FATAL_INPUT_ERROR("expected ')'");
|
||||||
|
|
||||||
m_pos++;
|
m_pos++;
|
||||||
|
|
||||||
m_incbins.emplace(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CFile::ReadPath()
|
std::string CFile::ReadPath()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user