Skip to content
Browse files

Precalculate pixelangle.

Clean ewolf3d.



git-svn-id: svn+ssh://jay/var/svn/wolf/trunk@112 32837ae5-38f0-4cfd-8401-3ff76d8497c4
  • Loading branch information...
1 parent 72ef27a commit d2034e967a828ee71d4c47714199d7aca55a6e16 paul committed Aug 12, 2007
Showing with 49 additions and 2 deletions.
  1. +2 −1 Makefile
  2. +34 −1 build_tables.c
  3. +5 −0 wl_def.h
  4. +6 −0 wl_draw.c
  5. +2 −0 wl_main.c
View
3 Makefile
@@ -111,7 +111,8 @@ sprites.c: build_sprites.c pagemap.c pal4bit.c
./build_sprites > sprites.c
clean:
- rm -rf swolf3d xwolf3d sdlwolf3d *.o *.il build_tables tables.c \
+ rm -rf swolf3d xwolf3d sdlwolf3d ewolf3d *.o *.il \
+ build_tables tables.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 \
View
35 build_tables.c
@@ -8,12 +8,18 @@ fixed finetangent[FINEANGLES/4];
fixed sintable[ANGLES+ANGLES/4+1];
static const double radtoint = (double)FINEANGLES/2.0/PI;
+#ifdef EMBEDDED
+static myshort pa[128];
+#endif
int main()
{
myint i;
- double tang, angle, anglestep;
+ long intang;
+ myint halfview;
+ double tang, angle, anglestep, facedist;
fixed value;
+ fixed scale;
/* FIXME: Use linear interpolation to reduce size of trig tables. */
/* calculate fine tangents */
@@ -50,6 +56,33 @@ int main()
angle += anglestep;
}
printf ("\n};\n");
+
+#ifdef EMBEDDED
+ facedist = 0x5800+MINDIST;
+ halfview = 64; /* half view in pixels */
+
+ if (MAXVIEWWIDTH != 128)
+ printf("#error MAXVIEWWIDTH %d, expected 128\n", MAXVIEWWIDTH);
+/*
+ calculate scale value for vertical height calculations
+ and sprite x calculations
+*/
+ scale = halfview*facedist/(VIEWGLOBAL/2);
+
+/* calculate the angle offset from view angle of each pixel's ray */
+ for (i = 0; i < halfview; i++) {
+ tang = ((double)i)*VIEWGLOBAL/128/facedist;
+ angle = atan(tang);
+ intang = angle*radtoint;
+ pa[halfview-1-i] = intang;
+ pa[halfview+i] = -intang;
+ }
+ printf ("const myshort pixelangle[128] = {\n");
+ for (i = 0; i < 128; i++) {
+ printf (" %d,\n", pa[i]);
+ }
+ printf ("};\n");
+#endif
return 0;
}
View
5 wl_def.h
@@ -709,7 +709,12 @@ extern boolean startgame,loadedgame;
extern myint mouseadjustment;
/* math tables */
+#ifdef EMBEDDED
+// FIXME: This only needs to be half size.
+extern const myshort pixelangle[MAXVIEWWIDTH];
+#else
extern myshort pixelangle[MAXVIEWWIDTH];
+#endif
extern const fixed finetangent[FINEANGLES/4];
extern const uint16_t sintable[];
View
6 wl_draw.c
@@ -51,9 +51,13 @@ static const double radtoint = (double)FINEANGLES/2.0/PI;
// FIXME: Use fixed display size and precalculate angles.
void CalcProjection(long focal)
{
+#ifdef EMBEDDED
+ long facedist;
+#else
myint i;
long intang;
double angle, tang, facedist;
+#endif
myint halfview;
focallength = focal;
@@ -72,6 +76,7 @@ void CalcProjection(long focal)
*/
heightnumerator = (TILEGLOBAL*scale)>>6;
+#ifndef EMBEDDED
/* calculate the angle offset from view angle of each pixel's ray */
for (i = 0; i < halfview; i++) {
tang = ((double)i)*VIEWGLOBAL/viewwidth/facedist;
@@ -80,6 +85,7 @@ void CalcProjection(long focal)
pixelangle[halfview-1-i] = intang;
pixelangle[halfview+i] = -intang;
}
+#endif
}
/*
View
2 wl_main.c
@@ -34,7 +34,9 @@ long frameon;
long lasttimecount;
fixed viewsin, viewcos;
fixed viewx, viewy; /* the focal point */
+#ifndef EMBEDDED
myshort pixelangle[MAXVIEWWIDTH];
+#endif
//int32_t finetangent[FINEANGLES/4];
myshort horizwall[MAXWALLTILES], vertwall[MAXWALLTILES];

0 comments on commit d2034e9

Please sign in to comment.
Something went wrong with that request. Please try again.