portx64: pd extract - font/anim/audio segments and tiles/pads files fixes

This commit is contained in:
Raf committed 2024-07-23 01:58:47 +08:00
1 parent 00c990eded
commit 315a5642da
6 files changed
+15 -20

No files matched your search

+7 -6
View File
@@ -22,10 +22,10 @@ static void extract_anims_data(uint32_t romoffset, size_t len)
fclose(fp);
}
static void extract_anims_table(uint32_t romoffset)
static void extract_anims_table(uint32_t data_offset, uint32_t table_offset)
{
int num_anims = srctoh32(*(uint32_t *) &g_Rom[romoffset]);
struct animtableentry *srcanims = (struct animtableentry *) &g_Rom[romoffset + 4];
int num_anims = srctoh32(*(uint32_t *) &g_Rom[table_offset]);
struct animtableentry *srcanims = (struct animtableentry *) &g_Rom[table_offset + 4];
size_t dstlen = ALIGN16(4 + num_anims * sizeof(struct animtableentry));
uint8_t *dst = calloc(1, dstlen);
@@ -42,9 +42,11 @@ static void extract_anims_table(uint32_t romoffset)
}
char outfilename[1024];
sprintf(outfilename, "%s/anims_table.bin", g_OutPath);
sprintf(outfilename, "%s/segs/animations", g_OutPath);
FILE *fp = openfile(outfilename);
size_t datalen = table_offset - data_offset;
fwrite(&g_Rom[data_offset], datalen, 1, fp);
fwrite(dst, dstlen, 1, fp);
fclose(fp);
@@ -72,6 +74,5 @@ void extract_anims(void)
break;
}
extract_anims_data(data_offset, table_offset - data_offset);
extract_anims_table(table_offset);
extract_anims_table(data_offset, table_offset);
}
+2 -2
View File
@@ -421,7 +421,7 @@ static void extract_audio_ctl(const char *filename, uint32_t romoffset, size_t s
dstpos = convert_audio_bankfile(dst, dstpos, src, 0);
char outfilename[1024];
sprintf(outfilename, "%s/%s.ctl", g_OutPath, filename);
sprintf(outfilename, "%s/segs/%sctl", g_OutPath, filename);
FILE *fp = openfile(outfilename);
fwrite(dst, ALIGN16(dstpos), 1, fp);
@@ -433,7 +433,7 @@ static void extract_audio_ctl(const char *filename, uint32_t romoffset, size_t s
static void extract_audio_tbl(const char *filename, uint32_t romoffset, size_t len)
{
char outfilename[1024];
sprintf(outfilename, "%s/%s.tbl", g_OutPath, filename);
sprintf(outfilename, "%s/segs/%stbl", g_OutPath, filename);
FILE *fp = openfile(outfilename);
fwrite(&g_Rom[romoffset], len, 1, fp);
+1 -7
View File
@@ -87,13 +87,7 @@ static int convert_pads(uint8_t *dst, int dstpos, uint8_t *src, int srcpos, int
struct padheader *host_padheader = (struct padheader *) &dst[dstpos];
uint32_t flags = (n64_padheader >> 14) & 0x3ffff;
#ifdef FORCE_BE32
*(uint32_t *) host_padheader = htodst32(n64_padheader);
#else
host_padheader->flags = flags;
host_padheader->room = (n64_padheader >> 4) & 0x3ff;
host_padheader->liftnum = n64_padheader & 0xf;
#endif
*(uint32_t*)host_padheader = htodst32(n64_padheader);
srcpos += sizeof(struct padheader);
dstpos += sizeof(struct padheader);
+3 -3
View File
@@ -33,7 +33,7 @@ void extract_file_tiles(char *filename, uint32_t romoffset, size_t len)
int num_rooms = srctoh32(*(uint32_t *) src);
size_t src_ptr_table_len = (num_rooms + 1) * 4;
size_t dst_ptr_table_len = (num_rooms + 1) * sizeof(uintptr_t);
size_t dst_ptr_table_len = (num_rooms + 1) * sizeof(uint32_t);
uint32_t *src_offsets = (uint32_t *) &src[4];
@@ -43,8 +43,8 @@ void extract_file_tiles(char *filename, uint32_t romoffset, size_t len)
*(uint32_t *) dst = htodst32(num_rooms);
uintptr_t *dst_offsets = (uintptr_t *) (dst + ALIGN(4, sizeof(uintptr_t)));
uint32_t cur_dst_offset = ALIGN(4, sizeof(uintptr_t)) + dst_ptr_table_len;
uint32_t*dst_offsets = (uint32_t*) (dst + sizeof(uint32_t));
uint32_t cur_dst_offset = dst_ptr_table_len + sizeof(uint32_t);
uint32_t cur_src_offset = srctoh32(src_offsets[0]);
uint32_t end_src_offset = srctoh32(src_offsets[num_rooms]);
+1 -1
View File
@@ -102,7 +102,7 @@ static void extract_font(const char *filename, uint32_t romoffset, size_t srclen
// Write it
char outfilename[1024];
sprintf(outfilename, "%s/fonts/%s.bin", g_OutPath, filename);
sprintf(outfilename, "%s/segs/font%s", g_OutPath, filename);
FILE *fp = openfile(outfilename);
fwrite(dst, dst_offset, 1, fp);
+1 -1
View File
@@ -6,7 +6,7 @@
static void extract_jpnfont(const char *filename, uint32_t romoffset, size_t len)
{
char outfilename[1024];
sprintf(outfilename, "%s/%s.bin", g_OutPath, filename);
sprintf(outfilename, "%s/segs/%s", g_OutPath, filename);
FILE *fp = openfile(outfilename);
fwrite(&g_Rom[romoffset], len, 1, fp);