mirror of
https://github.com/zeldaret/ph
synced 2026-06-12 13:34:51 -04:00
Match base ROM
IT BUILDS!!!
This commit is contained in:
+9
-7
@@ -392,11 +392,14 @@ bool WriteFntSubtable(FileTree *tree, FntContext *pContext) {
|
||||
size_t subtableStart = ctx.subtableSize;
|
||||
|
||||
// Create initial subtable entries
|
||||
size_t numFiles = 0;
|
||||
uint16_t fileId = ctx.nextFileId;
|
||||
for (size_t i = 0; i < tree->numChildren; ++i) {
|
||||
FileTree *child = &tree->children[i];
|
||||
FntSubEntry *entry = child->entry;
|
||||
if (!entry->isSubdir) numFiles += 1;
|
||||
if (!entry->isSubdir) {
|
||||
child->firstFileId = fileId;
|
||||
fileId += 1;
|
||||
}
|
||||
|
||||
size_t entrySize = sizeof(*entry) + entry->length + (entry->isSubdir ? 2 : 0);
|
||||
if (!GrowFntSubtable(&ctx, entrySize)) return false;
|
||||
@@ -410,7 +413,7 @@ bool WriteFntSubtable(FileTree *tree, FntContext *pContext) {
|
||||
ctx.subtable[ctx.subtableSize] = 0; // End of subtable
|
||||
ctx.subtableSize += 1;
|
||||
|
||||
ctx.nextFileId += numFiles;
|
||||
ctx.nextFileId = fileId;
|
||||
|
||||
// Recurse child directories
|
||||
for (size_t i = 0; i < tree->numChildren; ++i) {
|
||||
@@ -574,7 +577,6 @@ bool WriteBanner(FILE *fpRom, size_t *pAddress) {
|
||||
bool TraverseAndAppendAssets(FILE *fpRom, size_t *pAddress, const FileTree *tree, FatEntry *entries, uint16_t firstFileId) {
|
||||
size_t address = *pAddress;
|
||||
|
||||
size_t fileId = firstFileId;
|
||||
for (size_t i = 0; i < tree->numChildren; ++i) {
|
||||
FileTree *child = &tree->children[i];
|
||||
if (child->addedToFat) continue;
|
||||
@@ -586,9 +588,9 @@ bool TraverseAndAppendAssets(FILE *fpRom, size_t *pAddress, const FileTree *tree
|
||||
if (!Align(512, fpRom, &address)) return false;
|
||||
size_t startOffset = address;
|
||||
if (!AppendFile(fpRom, name, &address, NULL)) return false;
|
||||
entries[fileId].startOffset = startOffset;
|
||||
entries[fileId].endOffset = address;
|
||||
++fileId;
|
||||
// For files, `firstFileId` is the ID of the file
|
||||
entries[child->firstFileId].startOffset = startOffset;
|
||||
entries[child->firstFileId].endOffset = address;
|
||||
continue;
|
||||
}
|
||||
if (chdir(name) != 0) FATAL("Failed to enter assets directory '%s'\n", name);
|
||||
|
||||
+16
-1
@@ -170,7 +170,22 @@ int CompareFileTreeNormal(const void *a, const void *b) {
|
||||
int CompareFileTreeAscii(const void *a, const void *b) {
|
||||
FileTree *treeA = (FileTree*) a;
|
||||
FileTree *treeB = (FileTree*) b;
|
||||
return strcmp(treeA->entry->name, treeB->entry->name);
|
||||
|
||||
size_t lenA = treeA->entry->length;
|
||||
size_t lenB = treeB->entry->length;
|
||||
size_t minSize = (lenA < lenB) ? lenA : lenB;
|
||||
|
||||
// ASCII order
|
||||
if (strncmp(treeA->entry->name, "Color0.NCLR", 11) == 0 || strncmp(treeB->entry->name, "Color0.NCLR", 11) == 0) {
|
||||
printf("");
|
||||
}
|
||||
int cmp = strncmp(treeA->entry->name, treeB->entry->name, minSize);
|
||||
if (cmp != 0) return cmp;
|
||||
|
||||
// Shortest name first
|
||||
if (lenA < lenB) return -1;
|
||||
if (lenA > lenB) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool SortFileTree(FileTree *pTree, int (*compare)(const void*, const void*)) {
|
||||
|
||||
Reference in New Issue
Block a user