Salem:
I'll post the general bits for file reading here for you. If you want the whole source code, I can create a PasteBin entry for you.
Code:
char portfromentry[145],porttoentry[145];
int dltoport,dltoreplace,extradl,ofstoput,ofstoputstatic,trianglestoget,conversiontheorem,currentcommandoffset,getvertex,writevertex,currentround=0,twentyfour,area,texturelength,grabbed,extradlcheck;
FILE *portfrom, *portto, *vertexdata, *texturedata, *displaylist;
printf("\nZOBJ to port from: ");
scanf("%s",portfromentry);
printf("\nZOBJ to port to: ");
scanf("%s",porttoentry);
printf("\nDisplay List to port: 0x");
scanf("%X",&dltoport);
printf("\nDisplay List to replace: 0x");
scanf("%X",&dltoreplace);
portfrom=fopen(portfromentry,"r+b");
portto=fopen(porttoentry,"r+b");
displaylist=fopen("temp1.zmuffin","w+b");
vertexdata=fopen("temp2.zmuffin","w+b");
texturedata=fopen("temp3.zmuffin","w+b");
for( ; ; )
{
byte1=fgetc(portfrom);
byte2=fgetc(portfrom);
byte3=fgetc(portfrom);
byte4=fgetc(portfrom);
byte5=fgetc(portfrom);
byte6=fgetc(portfrom);
byte7=fgetc(portfrom);
byte8=fgetc(portfrom);
fputc(byte1,displaylist);
fputc(byte2,displaylist);
fputc(byte3,displaylist);
fputc(byte4,displaylist);
fputc(byte5,displaylist);
fputc(byte6,displaylist);
fputc(byte7,displaylist);
fputc(byte8,displaylist);
if(byte1==0xDF) { break; }
}
Even though it all works so flawlessly for me, Windows gets stuck in a permanent loop when dealing with the loop unless it's working with extremely small Display Lists (that have a DF Command 0x50 or less bytes from the start). After reading and putting so many times, it beings to fail to read bytes the way it's supposed to, so by the time it gets to a DF Command about 0x200 bytes later, it doesn't notice that byte1==0xDF, so it never breaks out of the loop. I again repeat that it works flawlessly for me, but Windows struggles with it.
With the actual problem better explained now, hopefully a solution would be easier to come across.
Stahta01:
Actually, the DF Command isn't always at the end of the file that we're porting from. For example, if the user inputs 0x6A48 as the Display List to port, which is, say, 0x528 Bytes long (in this example only), and the total file-size is 0x7FF8, it would be separating the Display List only, which would start at 0x6A48 and end at the end of the DF Command that is up next. It's kind of difficult to explain, despite how simple it really is.