worked on LCS world

This commit is contained in:
aap 2015-12-23 23:23:46 +01:00
parent aed3fefd01
commit 040d167da0
3 changed files with 171 additions and 7 deletions

View File

@ -1,3 +1,9 @@
enum {
TEX_IDENT = 0x00746578,
MDL_IDENT = 0x006D646C,
WRLD_IDENT = 0x57524C44
};
struct RslStream {
uint32 ident;
bool32 isMulti;
@ -263,10 +269,104 @@ struct RslPS2InstanceData {
float32 bound[4]; // ?
float32 uvScale[2];
int32 unk1;
uint8 *dmaPacket;
uint32 dmaPacket;
uint16 numTriangles;
int16 matID;
void *unk2;
void *unk3;
void *unk4;
int16 min[3]; // bounding box
int16 max[3];
};
struct RslStreamHeader {
uint32 ident;
uint32 unk;
uint32 fileEnd; //
uint32 dataEnd; // relative to beginning of header
uint32 reloc; //
uint32 relocSize;
uint32 root; // absolute
uint16 zero;
uint16 numAtomics;
};
struct RslWorldGeometry {
uint16 numMeshes;
uint16 size;
// array of numMeshes RslWorldMesh
// dma data
};
struct RslWorldMesh {
uint16 texID; // index into resource table
uint16 dmaSize;
uint16 uvScale[2]; // half precision float
uint16 unk1;
int16 min[3]; // bounding box
int16 max[3];
};
struct Resource {
union {
RslRaster *raster;
RslWorldGeometry *geometry;
uint8 *raw;
};
uint32 *dma;
};
struct OverlayResource {
int32 id;
union {
RslRaster *raster;
RslWorldGeometry *geometry;
uint8 *raw;
};
};
struct Placement {
uint16 id;
uint16 resId;
int16 bound[4];
int32 pad;
float matrix[16];
};
struct Sector {
OverlayResource *resources;
uint16 numResources;
uint16 unk1;
Placement *sectionA;
Placement *sectionB;
Placement *sectionC;
Placement *sectionD;
Placement *sectionE;
Placement *sectionF;
Placement *sectionG;
Placement *sectionEnd;
uint16 unk2;
uint16 unk3;
uint32 unk4;
};
struct SectorEntry {
RslStreamHeader *sector;
uint32 num;
};
struct World {
Resource *resources;
SectorEntry sectors[47];
uint32 numResources;
uint8 pad[0x180];
uint32 numX;
void *tabX; // size 0x4
uint32 numY;
void *tabY; // size 0x30
uint32 numZ;
void *tabZ; // size 0x6
uint32 numTextures;
RslStreamHeader *textures; // stream headers
};

View File

@ -99,7 +99,7 @@ main(int argc, char *argv[])
assert(sizeof(void*) == 4);
if(argc < 2){
printf("usage: %s [-u] in.dff\n", argv[0]);
printf("usage: %s in\n", argv[0]);
return 0;
}
@ -112,8 +112,71 @@ main(int argc, char *argv[])
stream.close();
rslstr->relocate();
int largefile = rslstr->dataSize > 0x100000;
World *world;
RslClump *clump;
if(rslstr->numAtomics){
Sector *sector;
if(rslstr->ident = WRLD_IDENT && largefile){ // hack
world = (World*)rslstr->data;
int len = strlen(argv[1])+1;
char filename[1024];
strncpy(filename, argv[1], len);
filename[len-3] = 'i';
filename[len-2] = 'm';
filename[len-1] = 'g';
filename[len] = '\0';
assert(stream.open(filename, "rb"));
filename[len-4] = '\\';
filename[len-3] = '\0';
char name[1024];
uint8 *data;
StreamFile outf;
RslStreamHeader *h;
int i = 0;
for(h = world->sectors->sector; h->ident == WRLD_IDENT; h++){
sprintf(name, "world%04d.wrld", i++);
strcat(filename, name);
assert(outf.open(filename, "wb"));
data = new uint8[h->fileEnd];
memcpy(data, h, 0x20);
stream.seek(h->root, 0);
stream.read(data+0x20, h->fileEnd-0x20);
outf.write(data, h->fileEnd);
outf.close();
filename[len-3] = '\0';
}
// radar textures
h = world->textures;
for(i = 0; i < world->numTextures; i++){
sprintf(name, "txd%04d.chk", i);
strcat(filename, name);
assert(outf.open(filename, "wb"));
data = new uint8[h->fileEnd];
memcpy(data, h, 0x20);
stream.seek(h->root, 0);
stream.read(data+0x20, h->fileEnd-0x20);
outf.write(data, h->fileEnd);
outf.close();
filename[len-3] = '\0';
h++;
}
stream.close();
}else if(rslstr->ident = WRLD_IDENT){ // sector
sector = (Sector*)rslstr->data;
printf("resources\n");
for(uint32 i = 0; i < sector->numResources; i++){
OverlayResource *r = &sector->resources[i];
printf(" %d %p\n", r->id, r->raw);
}
printf("placement\n");
Placement *p;
for(p = sector->sectionA; p < sector->sectionEnd; p++){
printf(" %d, %d, %f %f %f\n", p->id &0x7FFF, p->resId, p->matrix[12], p->matrix[13], p->matrix[14]);
}
}else if(rslstr->ident = MDL_IDENT){
uint8 *p = *rslstr->hashTab;
p -= 0x24;
RslAtomic *a = (RslAtomic*)p;

View File

@ -51,6 +51,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>