Skip to content

Commit

Permalink
#368 GBA data packer (PKD & WAD)
Browse files Browse the repository at this point in the history
  • Loading branch information
XProger committed Nov 25, 2022
1 parent a311245 commit 9418492
Show file tree
Hide file tree
Showing 5 changed files with 457 additions and 214 deletions.
6 changes: 4 additions & 2 deletions src/platform/gba/packer/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,11 @@ enum ItemType {
#define MAX_ITEMS 240
#define MAX_NODES 32
#define MAX_TEXTURES 1536 * 2
#define MAX_ANIM_TEX 128

#define TEX_ATTR_AKILL 0x0001
#define FACE_TEXTURE 0x07FF
#define TEX_ATTR_AKILL 0x0001
#define TEX_ATTR_ANIM 0x0002
#define FACE_TEXTURE 0x3FFF

struct vec3s
{
Expand Down
48 changes: 48 additions & 0 deletions src/platform/gba/packer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,49 @@
#include "TR1_PSX.h"
#include "out_GBA.h"
#include "out_3DO.h"
#include "out_32X.h"

TR1_PC* pc[LVL_MAX];
TR1_PSX* psx[LVL_MAX];

void dumpLightmap(const char* fileName, TR1_PC* level)
{
uint32 data[34 * 256];

uint32 *ptr = data;

for (int32 i = 0; i < 256; i++)
{
int32 idx = i * 3;

uint8 r = level->palette.colors[idx + 0] << 2;
uint8 g = level->palette.colors[idx + 1] << 2;
uint8 b = level->palette.colors[idx + 2] << 2;

*ptr++ = (b | (g << 8) | (r << 16) | 0xFF000000);
}

for (int32 i = 0; i < 256; i++) {
*ptr++ = 0;
}

for (int32 j = 0; j < 32; j++)
{
for (int32 i = 0; i < 256; i++)
{
int32 idx = level->lightmap[j * 256 + i] * 3;

uint8 r = level->palette.colors[idx + 0] << 2;
uint8 g = level->palette.colors[idx + 1] << 2;
uint8 b = level->palette.colors[idx + 2] << 2;

*ptr++ = (b | (g << 8) | (r << 16) | 0xFF000000);
}
}

saveBitmap(fileName, (uint8*)data, 256, 32 + 2, 32);
}

int main(int argc, char** argv)
{
if (argc < 3) {
Expand All @@ -34,6 +73,8 @@ int main(int argc, char** argv)
}
}

dumpLightmap("lightmap.bmp", pc[LVL_TR1_1]);

if (strcmp(argv[1], "gba") == 0)
{
out_GBA* out = new out_GBA();
Expand All @@ -48,6 +89,13 @@ int main(int argc, char** argv)
delete out;
}

if (strcmp(argv[1], "32x") == 0)
{
out_32X* out = new out_32X();
out->process(argv[2], pc, NULL);
delete out;
}

for (int32 i = 0; i < LVL_MAX; i++)
{
delete pc[i];
Expand Down
Loading

0 comments on commit 9418492

Please sign in to comment.