Regarding the n64tool's error that trashes the image after the hdr+bin are merged ,try to replace output_zeros in n64tool with this (it makes absolutely no sense for that function to expect alignment
since the input is already the required bytes to pad the size! ...bad naming...) :
int output_zeros(FILE* f,int amount) {
for (;amount > 0;--amount)
fputc(0,f);
return 0;
}
For example , imagine the case of sizeof(hdr+bin) being aligned , then merged with unaligned fs data , resulting in non aligned remainder , which
makes the code to jump to this case:
if(amount & 3 != 0)
{
/* Don't support odd word alignments */
return -1;
}
All calls to that function expect (int)0 for positive result , without explicit statement in the comparison , which may result in different code for the jump instruction being generated between different gcc versions....