Skip to content

Commit f83cf46

Browse files
committed
Fix for PC11 / Stern PBA
1 parent 4aed641 commit f83cf46

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

Diff for: format0024.c

+16-8
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ typedef struct {
2222
// 0x40 = normal ??
2323

2424

25-
uint32_t drawCount;
25+
uint32_t textureCount;
2626
uint32_t always0_a;
2727
uint32_t vertexCount;
2828
uint32_t always0_b;
@@ -36,7 +36,9 @@ typedef struct {
3636

3737
uint32_t faceCount; // triangle count without degenerates ?!
3838
uint32_t always0_c[4];
39-
uint32_t unk[16+38-7];
39+
uint32_t unk[16+38-7-2];
40+
uint32_t drawCount;
41+
uint32_t unk2;
4042
uint32_t indexCount;
4143
uint32_t always0_d[7];
4244
} Header;
@@ -73,6 +75,7 @@ int main(int argc, char* argv[]) {
7375
d = header.unk[i];
7476
printf("[%d] = 0x%08X [%d]\t\t%f\n", i, d, d, *(float*)&d); // Unknown
7577
}
78+
// assert(header.unk[45] == header.drawCount);
7679

7780
bool hasNormal = false; // atoi(argv[3]);
7881

@@ -94,6 +97,7 @@ int main(int argc, char* argv[]) {
9497
hasNormal |= (header.unk0 == 4163 && header.unk1 == 0x05232001);
9598
hasNormal |= (header.unk0 == 4161 && header.unk1 == 0x1E0F2001);
9699
hasNormal |= (header.unk0 == 4163 && header.unk1 == 0x321E2001);
100+
hasNormal |= (header.unk0 == 4163 && header.unk1 == 0x0F4B2001);
97101

98102
for(unsigned int i = 0; i < header.vertexCount; i++) {
99103
Vector position;
@@ -139,7 +143,8 @@ int main(int argc, char* argv[]) {
139143
for(unsigned int i = 0; i < header.drawCount; i++) {
140144

141145
typedef struct {
142-
uint32_t unk0;
146+
uint16_t unk0a; // Texture index?
147+
uint16_t unk0b;
143148
uint32_t unk1;
144149
uint32_t unk2; // Sometimes matches vertexCount ?!
145150
uint32_t indexCount;
@@ -148,15 +153,16 @@ int main(int argc, char* argv[]) {
148153
Draw draw;
149154
fread(&draw, sizeof(draw), 1, in);
150155

151-
printf("[%d] = 0x%08X 0x%08X 0x%08X, indexCount: %d\n",
156+
printf("[%d] = 0x%04X 0x%04X 0x%08X 0x%08X, indexCount: %d\n",
152157
i,
153-
draw.unk0,
158+
draw.unk0a,
159+
draw.unk0b,
154160
draw.unk1,
155161
draw.unk2,
156162
draw.indexCount);
157163

158164
fprintf(out, "g %s/draw%d\n", basename(outPath), i);
159-
fprintf(out, "usemtl %s/draw%d\n", mtlFile, i);
165+
fprintf(out, "usemtl %s/texture%d\n", mtlFile, draw.unk0a);
160166

161167
for(unsigned int j = 0; j < draw.indexCount; j++) {
162168

@@ -203,18 +209,20 @@ int main(int argc, char* argv[]) {
203209
fclose(out);
204210
out = fopen(mtlPath, "wb");
205211

206-
for(unsigned int i = 0; i < header.drawCount; i++) {
212+
for(unsigned int i = 0; i < header.textureCount; i++) {
207213
typedef struct {
208214
uint16_t file;
209215
uint16_t resource;
210216
uint8_t always0[20];
211217
} TextureReference;
212218

219+
printf("Reading tex at %d\n", ftell(in));
220+
213221
TextureReference texture;
214222
fread(&texture, sizeof(texture), 1, in);
215223
printf("[%d] = resource: %d, index: %d\n", i, texture.resource, texture.file);
216224

217-
fprintf(out, "newmtl %s/draw%d\n", mtlFile, i);
225+
fprintf(out, "newmtl %s/texture%d\n", mtlFile, i);
218226
fprintf(out, "map_Kd -s 1 1 %d-%d.tga\n", texture.resource, texture.file);
219227
}
220228

Diff for: format008D.c

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ int main(int argc, char* argv[]) {
6565
break;
6666
}
6767
default:
68+
printf("Unknown format 0x%X\n", header.format);
6869
assert(false);
6970
break;
7071
}

Diff for: rez.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//#define PC11 //FIXME: Make this a CLI option
1+
#define PC11 //FIXME: Make this a CLI option
22

33
#include <stdbool.h>
44
#include <assert.h>

0 commit comments

Comments
 (0)