2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 13:04:56 +00:00

New code style refactor

This commit is contained in:
Jack Andersen
2018-12-07 19:30:43 -10:00
parent 41ae32be31
commit 636c82a568
1451 changed files with 171430 additions and 203303 deletions

View File

@@ -6,46 +6,41 @@
#if __BYTE_ORDER__ == __BIG_ENDIAN
#define SBIG(q) q
#else
#define SBIG(q) ( ( (q) & 0x000000FF ) << 24 | ( (q) & 0x0000FF00 ) << 8 \
| ( (q) & 0x00FF0000 ) >> 8 | ( (q) & 0xFF000000 ) >> 24 )
#define SBIG(q) (((q)&0x000000FF) << 24 | ((q)&0x0000FF00) << 8 | ((q)&0x00FF0000) >> 8 | ((q)&0xFF000000) >> 24)
#endif
int main(int argc, char* argv[])
{
if (argc < 2)
{
printf("mpcksum <save> [output]\n");
return 1;
}
int main(int argc, char* argv[]) {
if (argc < 2) {
printf("mpcksum <save> [output]\n");
return 1;
}
athena::io::MemoryCopyReader in(argv[1]);
std::unique_ptr<athena::io::FileWriter> out;
if (argc > 2)
out.reset(new athena::io::FileWriter(argv[2]));
else
out.reset(new athena::io::FileWriter(argv[1]));
athena::io::MemoryCopyReader in(argv[1]);
std::unique_ptr<athena::io::FileWriter> out;
if (argc > 2)
out.reset(new athena::io::FileWriter(argv[2]));
else
out.reset(new athena::io::FileWriter(argv[1]));
atUint32 magic;
in.readUBytesToBuf(&magic, 4);
if (magic != SBIG('GM8E') && magic != SBIG('GM8P') && magic != SBIG('GM8J'))
{
printf("Unsupported file, MP .gci file expected\n");
return 1;
}
atUint32 magic;
in.readUBytesToBuf(&magic, 4);
if (magic != SBIG('GM8E') && magic != SBIG('GM8P') && magic != SBIG('GM8J')) {
printf("Unsupported file, MP .gci file expected\n");
return 1;
}
if (in.length() != 8256)
{
printf("File too small expected 8,256 bytes got %" PRIu64, in.length());
return 1;
}
if (in.length() != 8256) {
printf("File too small expected 8,256 bytes got %" PRIu64, in.length());
return 1;
}
atUint8* data = in.data();
atUint8* data = in.data();
atUint32 newCkSum = athena::checksums::crc32(data + 68, 8188, ~0, 0);
*(atUint32*)(data + 64) = SBIG(newCkSum);
out->writeBytes(data, 8256);
atUint32 newCkSum = athena::checksums::crc32(data + 68, 8188, ~0, 0);
*(atUint32*)(data + 64) = SBIG(newCkSum);
out->writeBytes(data, 8256);
delete data;
delete data;
return 0;
return 0;
}