Permalink
Browse files

Remove unused code.

Precompile map data.



git-svn-id: svn+ssh://jay/var/svn/wolf/trunk@139 32837ae5-38f0-4cfd-8401-3ff76d8497c4
  • Loading branch information...
paul
paul committed Aug 19, 2007
1 parent c73c287 commit f8d3b9d591b5e58eb320e4b5a30be605044ed614
Showing with 90 additions and 33 deletions.
  1. +8 −3 Makefile
  2. +2 −0 arm_support.c
  3. +45 −0 build_mapdata.c
  4. +2 −0 build_mapheaders.c
  5. +15 −9 id_ca.c
  6. +2 −1 id_ca.h
  7. +4 −16 id_vh.c
  8. +2 −0 misc.c
  9. +2 −0 wl_act2.c
  10. +1 −1 wl_agent.c
  11. +4 −0 wl_game.c
  12. +3 −3 wl_inter.c
View
@@ -20,8 +20,8 @@ OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \
wl_act1.o wl_act2.o wl_act3.o wl_agent.o wl_game.o \
wl_inter.o wl_menu.o wl_play.o wl_state.o wl_main.o \
wl_debug.o vi_comm.o tables.o mapheaders.o pagemap.c \
- grstarts.o pictable.o pal4bit.o tff.o mmc.o \
- sprites.o walls.o
+ grstarts.o pictable.o pal4bit.o \
+ sprites.o walls.o mapdata.o
# romchunk.o
ROBJS = wl_draw.o
SOBJS = $(OBJS) $(ROBJS) vi_svga.o
@@ -117,13 +117,18 @@ walls.c: build_walls.c pagemap.c pal4bit.c
gcc $(HOSTCFLAGS) build_walls.c pagemap.c pal4bit.c -o build_walls
./build_walls > walls.c
+mapdata.c: build_mapdata.c mapheaders.c
+ gcc $(HOSTCFLAGS) build_mapdata.c mapheaders.c -o build_mapdata
+ ./build_mapdata > mapdata.c
+
clean:
rm -rf swolf3d xwolf3d sdlwolf3d ewolf3d *.o *.il \
build_tables tables.c build_walls walls.c \
build_huffman huffman.h build_mapheaders mapheaders.c \
build_pagemap pagemap.c build_grstarts grstarts.c \
build_pictable pictable.c build_pal4bit pal4bit.c \
- build_romchunk romchunk.c build_sprites sprites.c
+ build_romchunk romchunk.c build_sprites sprites.c \
+ build_mapdata mapdata.c
distclean: clean
rm -rf *~ DEADJOE
View
@@ -116,6 +116,7 @@ void *memcpy(void *dest, const void *src, size_t n)
return dest;
}
+#ifndef PRECOMPILE
#ifdef LUMINARY
#define MAX_FILES 4
static FATFS fat;
@@ -252,3 +253,4 @@ off_t lseek(int fd, off_t ptr, int whence)
return ptr;
}
#endif
+#endif
View
@@ -0,0 +1,45 @@
+#include "wl_def.h"
+
+FILE *f;
+
+static void writeplane(int map, int plane)
+{
+ int n;
+ int len;
+ char buf[16384];
+ len = mapheaderseg[map].planelength[plane];
+ fseek(f, mapheaderseg[map].planestart[plane], SEEK_SET);
+ fread(buf, mapheaderseg[map].planelength[plane], 1, f);
+ printf("static const byte MapData%02d_%d[%d] = {", map, plane, len);
+ for (n = 0; n < len; n++) {
+ if ((n & 15) == 0)
+ printf("\n");
+ printf (" %d,", buf[n]);
+ }
+ printf("\n};\n");
+
+}
+
+int main()
+{
+ int i;
+
+ printf("#include \"wl_def.h\"\n");
+ f = fopen("gamemaps." GAMEEXT, "rb");
+ if (!f)
+ return 1;
+ for (i = 0; i < NUMMAPS; i++) {
+ writeplane(i, 0);
+ writeplane(i, 1);
+ }
+ fclose(f);
+
+ printf("const byte *const ROMAREA MapPlane[NUMMAPS * 2] = {\n");
+ for (i = 0; i < NUMMAPS; i++) {
+ printf(" MapData%02d_%d,\n", i, 0);
+ printf(" MapData%02d_%d,\n", i, 1);
+ }
+ printf("};\n");
+ return 0;
+}
+
View
@@ -21,6 +21,7 @@ int main()
printf("#include \"wl_def.h\"\n");
printf("const word RLEWtag = 0x%x;\n", rlew);
+ printf("#ifdef HOST\n");
printf("const maptype mapheaderseg[NUMMAPS] = {\n");
f = fopen("gamemaps." GAMEEXT, "rb");
for (i = 0; i < NUMMAPS; i++)
@@ -40,6 +41,7 @@ int main()
}
}
printf("};\n");
+ printf("#endif\n");
return 0;
}
View
24 id_ca.c
@@ -60,7 +60,9 @@ static huffnode grhuffman[256];
#ifndef EMBEDDED
static myint grhandle = -1; /* handle to VGAGRAPH */
#endif
+#ifndef ENABLE_PRECOMPILE
static myint maphandle = -1; /* handle to GAMEMAPS */
+#endif
#ifdef ENABLE_AUDIO
static myint audiohandle = -1; /* handle to AUDIOT */
#endif
@@ -73,6 +75,7 @@ static myint audiohandle = -1; /* handle to AUDIOT */
=============================================================================
*/
+#ifndef ENABLE_PRECOMPILE
static void CA_CannotOpen(const char *string)
{
char str[30];
@@ -82,6 +85,7 @@ static void CA_CannotOpen(const char *string)
strcat(str, "!\n");
Quit(str);
}
+#endif
#ifdef ENABLE_DEMO
/*
@@ -398,6 +402,7 @@ static void CAL_SetupGrFile()
/* ======================================================================== */
+#ifndef ENABLE_PRECOMPILE
/*
======================
=
@@ -408,18 +413,15 @@ static void CAL_SetupGrFile()
static void CAL_SetupMapFile()
{
-#ifndef ENABLE_PRECOMPILE
myint i;
myint handle;
long pos;
-#endif
/* open the data file */
maphandle = OpenRead(gmapsname);
if (maphandle == -1)
CA_CannotOpen(gmapsname);
-#ifndef ENABLE_PRECOMPILE
handle = OpenRead(mheadname);
if (handle == -1)
CA_CannotOpen(mheadname);
@@ -452,9 +454,8 @@ static void CAL_SetupMapFile()
}
CloseRead(handle);
-#endif
-
}
+#endif
/* ======================================================================== */
@@ -509,7 +510,9 @@ static void CAL_SetupAudioFile()
void CA_Startup()
{
+#ifndef ENABLE_PRECOMPILE
CAL_SetupMapFile();
+#endif
#ifndef EMBEDDED
CAL_SetupGrFile();
#endif
@@ -532,7 +535,9 @@ void CA_Startup()
void CA_Shutdown()
{
+#ifndef ENABLE_PRECOMPILE
CloseRead(maphandle);
+#endif
#ifndef EMBEDDED
CloseRead(grhandle);
#endif
@@ -711,7 +716,9 @@ void CA_CacheGrChunk(myint chunk)
void CA_CacheMap(myint mapnum, myint plane)
{
+#ifndef ENABLE_PRECOMPILE
long pos,compressed;
+#endif
byte *source;
memptr buffer2seg;
long expanded;
@@ -721,19 +728,18 @@ void CA_CacheMap(myint mapnum, myint plane)
/* load plane into the already allocated buffers */
#ifdef ENABLE_PRECOMPILE
- pos = mapheaderseg[mapnum].planestart[plane];
- compressed = mapheaderseg[mapnum].planelength[plane];
+ source = (byte *)MapPlane[mapnum * 2 + plane];
#else
pos = mapheaderseg[mapnum]->planestart[plane];
compressed = mapheaderseg[mapnum]->planelength[plane];
-#endif
ReadSeek(maphandle, pos, SEEK_SET);
source = MM_AllocPool(NULL, compressed);
//MM_GetPtr((void *)&source, compressed);
ReadBytes(maphandle, (byte *)source, compressed);
+#endif
expanded = source[0] | (source[1] << 8);
buffer2seg = MM_AllocPool(NULL, expanded);
@@ -868,10 +874,10 @@ void MM_SortMem()
{
}
+#ifndef ENABLE_PRECOMPILE
static boolean PMStarted;
static myint PageFile = -1;
-#ifndef ENABLE_PRECOMPILE
myint ChunksInFile, PMSpriteStart, PMSoundStart;
PageListStruct *PMPages;
#endif
View
@@ -29,8 +29,9 @@ extern myint mapon;
typedef byte ms0;
extern ms0 mapseg0[64 * 64];
#ifdef ENABLE_PRECOMPILE
-extern const maptype mapheaderseg[NUMMAPS];
+extern const byte *const MapPlane[NUMMAPS * 2];
extern const word RLEWtag;
+extern const maptype mapheaderseg[NUMMAPS];
#else
extern maptype *mapheaderseg[NUMMAPS];
#endif
View
20 id_vh.c
@@ -124,18 +124,16 @@ void VL_FadeIn(myint start, myint end, const byte *palette, myint steps)
}
#endif
+#ifndef EMBEDDED
void VL_CacheScreen(myint chunk)
{
-#ifndef EMBEDDED
CA_CacheGrChunk(chunk);
VL_MemToScreen(CA_GetChunk(chunk), 320, 200, 0, 0);
CA_UnCacheGrChunk(chunk);
-#endif
}
void VL_DeModeXize(byte *buf, myint width, myint height)
{
-#ifndef EMBEDDED
byte *mem, *ptr, *destline;
myint plane, x, y;
@@ -160,7 +158,6 @@ void VL_DeModeXize(byte *buf, myint width, myint height)
memcpy(buf, mem, width * height);
MM_FreePtr((memptr)&mem);
-#endif
}
/*
@@ -173,7 +170,6 @@ void VL_DeModeXize(byte *buf, myint width, myint height)
static void VL_Plot(myint x, myint y, myint color)
{
-#ifndef EMBEDDED
myint xend, yend, xs, ys;
xend = x + 1;
@@ -192,7 +188,6 @@ static void VL_Plot(myint x, myint y, myint color)
for (xs = x; xs < xend; xs++)
for (ys = y; ys < yend; ys++)
*(gfxbuf + ys * vwidth + xs) = color;
-#endif
}
void VW_Plot(myint x, myint y, myint color)
@@ -209,7 +204,6 @@ data
*/
void VW_DrawPropString(const char *string)
{
-#ifndef EMBEDDED
byte *font;
myint width, step, height, x, xs, y;
byte *source, *ptrs;
@@ -234,12 +228,10 @@ void VW_DrawPropString(const char *string)
source++;
}
}
-#endif
}
void VW_MeasurePropString(const char *string, word *width, word *height)
{
-#ifndef EMBEDDED
myint w, mw;
byte *font = CA_GetChunk(STARTFONT+fontnumber);
@@ -261,27 +253,22 @@ void VW_MeasurePropString(const char *string, word *width, word *height)
mw = w;
*width = mw;
-#endif
}
void VWB_DrawTile8(myint x, myint y, myint tile)
{
-#ifndef EMBEDDED
VL_MemToScreen(CA_GetChunk(STARTTILE8)+(tile*64), 8, 8, x, y);
-#endif
}
void VWB_DrawPic(myint x, myint y, myint chunknum)
{
-#ifndef EMBEDDED
myint picnum = chunknum - STARTPICS;
myint width, height;
width = pictable[picnum].width;
height = pictable[picnum].height;
VL_MemToScreen(CA_GetChunk(chunknum), width, height, x, y);
-#endif
}
/*
@@ -374,7 +361,6 @@ void VL_Vlin(myint x, myint y, myint height, myint color)
void VW_Bar(myint x, myint y, myint width, myint height, myint color)
{
-#ifndef EMBEDDED
myint w, h;
byte *ptr;
@@ -390,8 +376,8 @@ void VW_Bar(myint x, myint y, myint width, myint height, myint color)
memset(ptr, color, w);
ptr += vwidth;
}
-#endif
}
+#endif
void VL_Bar(myint x, myint y, myint width, myint height, myint color)
{
@@ -414,6 +400,7 @@ void VL_Bar(myint x, myint y, myint width, myint height, myint color)
#endif
}
+#ifndef EMBEDDED
/*
=================
=
@@ -432,6 +419,7 @@ void VL_MemToScreen(const byte *source, myint width, myint height, myint x, myin
for (h = 0; h < height; h++)
VL_Plot(x+w, y+h, source[h*width+w]);
}
+#endif
void VW_Startup()
{
View
2 misc.c
@@ -343,6 +343,7 @@ uint32_t SwapInt32L(uint32_t i)
/* ** */
+#ifndef PRECOMPILE
myint OpenWrite(const char *fn)
{
myint fp;
@@ -454,6 +455,7 @@ myint ReadBytes(myint fp, byte *d, myint len)
{
return read(fp, d, len);
}
+#endif
myshort atan2fix(fixed x, fixed y)
{
Oops, something went wrong.

0 comments on commit f8d3b9d

Please sign in to comment.