Permalink
Browse files

Shrink Wall chunk index.

git-svn-id: svn+ssh://jay/var/svn/wolf/trunk@138 32837ae5-38f0-4cfd-8401-3ff76d8497c4
  • Loading branch information...
1 parent 06a2b2e commit c73c2875c253b567bc9cc9d3edea52ea7a438ff1 paul committed Aug 19, 2007
Showing with 21 additions and 9 deletions.
  1. +17 −7 build_walls.c
  2. +2 −1 id_ca.c
  3. +2 −1 id_ca.h
View
@@ -8,7 +8,7 @@ int total_rle;
int total_lz;
int total_before;
-void compress_wall(int picnum)
+int compress_wall(int picnum)
{
byte pixels[64 * 64];
byte data[16];
@@ -22,16 +22,17 @@ void compress_wall(int picnum)
byte c;
if (PMPages[picnum].length == 0) {
- printf("#define Wall%d NULL\n", picnum);
- return;
+ return 0;
}
fseek(vswap, PMPages[picnum].offset << 8, SEEK_SET);
fread(pixels, PMPages[picnum].length, 1, vswap);
for (i = 0; i < 64 * 64; i++) {
pixels[i] = pal4bit[pixels[i]];
}
+#if 0
printf ("static const byte ROMAREA Wall%d[%d] = {\n", picnum,
64 * 64 / 4 + WALLCBLOCK * 2);
+#endif
p = pixels;
for (i = 0; i < WALLCBLOCK; i++) {
for (j = 0; j < 16; j++)
@@ -74,21 +75,30 @@ void compress_wall(int picnum)
printf ("\n");
p += WALLBLOCKSIZE;
}
- printf("};\n");
+ printf ("\n");
+ return 1;
}
int main()
{
int i;
+ int *wallstarts;
+ int wallnum;
+ wallstarts = (int *)malloc(PMSpriteStart * sizeof(int));
vswap = fopen("vswap." GAMEEXT, "rb");
printf("#include \"wl_def.h\"\n");
+ wallnum = 0;
+ printf("const byte ROMAREA WallData[] = {\n");
for (i = 0; i < PMSpriteStart; i++) {
- compress_wall(i);
+ wallstarts[i] = wallnum;
+ if (compress_wall(i))
+ wallnum++;
}
+ printf("};\n");
// FIXME: Could use array indices instead of pointers. */
- printf("const byte *const ROMAREA WallChunks[%d] = {\n", PMSpriteStart);
+ printf("const byte const ROMAREA WallChunks[%d] = {\n", PMSpriteStart);
for (i = 0; i < PMSpriteStart; i++) {
- printf(" Wall%d,\n", i);
+ printf(" %d,\n", wallstarts[i]);
}
printf("};\n");
fclose(vswap);
View
@@ -980,7 +980,8 @@ memptr PM_GetPage(myint pagenum)
addr = MM_AllocPool(&PageAddr[pagenum], 64 * 64);
p = (byte *)addr;
- src = WallChunks[pagenum];
+ y = WallChunks[pagenum] * (64 * 64 / 4 + WALLCBLOCK * 2);
+ src = WallData+y;
for (x = 0; x < WALLCBLOCK; x++) {
pal[0] = 0x1f - (src[0] >> 4);
pal[1] = 0x1f - (src[0] & 0x0f);
View
@@ -85,7 +85,8 @@ extern const PageListStruct PMPages[];
extern pool_id PageAddr[];
extern const uint32_t grstarts[NUMCHUNKS + 1];
extern const byte *const RomChunks[];
-extern const byte *const WallChunks[];
+extern const byte WallData[];
+extern const byte WallChunks[];
#else
extern myint ChunksInFile, PMSpriteStart, PMSoundStart;
extern PageListStruct *PMPages;

0 comments on commit c73c287

Please sign in to comment.