Home » Fable TLC » Development » Advanced Modding » BigTools
Re: .big Reading [message #66242 is a reply to message #66235] |
Thu, 29 March 2012 06:48 |
xenn
Messages: 17 Registered: February 2012 Location: Canada
|
|
|
|
morerunes wrote on Wed, 28 March 2012 23:10 | Alright, I've written some code that seems to work, but I'm not convinced. The output is giving me a bank address of 401621575, which just seems too big to me. Am I missing something?
- edit -
I've fixed an error, and gotten a more reasonable bank address value: 6570567
My Code[code]
/* Reads a Fable: TLC .big file and exports texture files
* Version: 0.1 - Alpha
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define INFILE "in.big"
#define BUFFER_SIZE 500
int main()
{
// Open a file stream
FILE *inBig;
char *buffer = (char *) malloc(BUFFER_SIZE);
inBig = fopen(INFILE, "r");
size_t numElementsRead;
if (!inBig)
{
printf("Error opening file! Make sure it is named 'in.big' and placed in the correct folder.");
fclose(inBig);
return -1;
}
numElementsRead = fread(buffer, 4, 4, inBig);
if (numElementsRead != 4)
printf("What the hell!? Read: %d", numElementsRead);
// Capture the bank address
buffer += 2;
long *bankAddress;
bankAddress = (long *) buffer;
buffer -= 2;
printf("Bank Address: %ld", *bankAddress);
fclose(inBig);
return 0;
}
[/pre] [/align]
|
The number that :
Quote: | // Capture the bank address
buffer += 2;
long *bankAddress;
bankAddress = (long *) buffer;
buffer -= 2;
printf("Bank Address: %ld", *bankAddress);
|
is reading out, is the high word of "Char [4] ‘BIGB’" and the low word of "Char [4] Version", which is, for most of the .BIG files I've checked, the red segment in :
or 00644247 in hex,
or 6,570,567 in decimal.
I think by "buffer += 2;", you mean to add 2 dwords to the buffer address.
Instead, what the program does is only add two bytes to the buffer address.
You can resolve this by using "buffer += 2*4;", or, essentially the same thing, "buffer += 8;".
Fixed,
Quote: | // Capture the bank address
buffer += 2*4;
long *bankAddress;
bankAddress = (long *) buffer;
buffer -= 2*4;
printf("Bank Address: %ld", *bankAddress);
|
should read out the correct bank address (in decimal).
Of the original files, for example, these .BIG files should read out :
graphics.big -> 243,841,850
shaders.big -> 452,290
frontend.big -> 13,794,314
textures.big -> 533,633,006
|
|
|
Goto Forum:
Current Time: Sun Nov 24 13:07:59 PST 2024
Total time taken to generate the page: 0.15627 seconds
|