1 /***************************************************************************
2 * TEKMAP.C - 2 dimensional map modes *
3 * *
4 * *
5 ***************************************************************************/
6
7 #include "build.h"
8 #include "pragmas.h"
9 #include "names.h"
10
11 #include "tekwar.h"
12
13 void
drawoverheadmap(int cposx,int cposy,int czoom,short cang)14 drawoverheadmap(int cposx, int cposy, int czoom, short cang)
15 {
16 #if 0// TODO
17 int i, j, k, l, x1, y1, x2, y2, x3, y3, x4, y4, ox, oy, xoff, yoff;
18 int dax, day, cosang, sinang, xspan, yspan, sprx, spry;
19 int xrepeat, yrepeat, z1, z2, startwall, endwall, tilenum, daang;
20 int xvect, yvect, xvect2, yvect2;
21 unsigned char col;
22 walltype *wal, *wal2;
23 spritetype *spr;
24
25 xvect = sintable[(2048-cang)&2047] * czoom;
26 yvect = sintable[(1536-cang)&2047] * czoom;
27 xvect2 = mulscale(xvect,yxaspect,16);
28 yvect2 = mulscale(yvect,yxaspect,16);
29
30 //Draw red lines
31 for(i=0;i<numsectors;i++)
32 {
33 startwall = sector[i].wallptr;
34 endwall = sector[i].wallptr + sector[i].wallnum - 1;
35
36 z1 = sector[i].ceilingz; z2 = sector[i].floorz;
37
38 for(j=startwall,wal=&wall[startwall];j<=endwall;j++,wal++)
39 {
40 k = wal->nextwall; if (k < 0) continue;
41
42 if ((show2dwall[j>>3]&(1<<(j&7))) == 0) continue;
43 if ((k > j) && ((show2dwall[k>>3]&(1<<(k&7))) > 0)) continue;
44
45 if (sector[wal->nextsector].ceilingz == z1)
46 if (sector[wal->nextsector].floorz == z2)
47 if (((wal->cstat|wall[wal->nextwall].cstat)&(16+32)) == 0) continue;
48
49 col = 232;
50
51 if (dimensionmode[screenpeek] == 2)
52 {
53 if (sector[i].floorz != sector[i].ceilingz)
54 if (sector[wal->nextsector].floorz != sector[wal->nextsector].ceilingz)
55 if (((wal->cstat|wall[wal->nextwall].cstat)&(16+32)) == 0)
56 if (sector[i].floorz == sector[wal->nextsector].floorz) continue;
57 if (sector[i].floorpicnum != sector[wal->nextsector].floorpicnum) continue;
58 if (sector[i].floorshade != sector[wal->nextsector].floorshade) continue;
59 col = 232;
60 }
61
62 ox = wal->x-cposx; oy = wal->y-cposy;
63 x1 = mulscale(ox,xvect,16) - mulscale(oy,yvect,16);
64 y1 = mulscale(oy,xvect2,16) + mulscale(ox,yvect2,16);
65
66 wal2 = &wall[wal->point2];
67 ox = wal2->x-cposx; oy = wal2->y-cposy;
68 x2 = mulscale(ox,xvect,16) - mulscale(oy,yvect,16);
69 y2 = mulscale(oy,xvect2,16) + mulscale(ox,yvect2,16);
70
71 drawline256(x1+(xdim<<11),y1+(ydim<<11),x2+(xdim<<11),y2+(ydim<<11),col);
72 }
73 }
74
75 //Draw sprites
76 k = playersprite[screenpeek];
77 show2dsprite[k>>3] |= (1<<(k&7));
78 for(i=0;i<numsectors;i++)
79 for(j=headspritesect[i];j>=0;j=nextspritesect[j])
80 if ((show2dsprite[j>>3]&(1<<(j&7))) > 0)
81 {
82 spr = &sprite[j];
83 col = 56;
84 if ((spr->cstat&1) > 0) col = 248;
85 if (j == k) col = 31;
86
87 sprx = spr->x;
88 spry = spr->y;
89
90 k = spr->statnum;
91 if ((k >= 1) && (k <= 8) && (k != 2)) //Interpolate moving sprite
92 {
93 sprx = osprite[j].x+mulscale(sprx-osprite[j].x,smoothratio,16);
94 spry = osprite[j].y+mulscale(spry-osprite[j].y,smoothratio,16);
95 }
96
97 switch (spr->cstat&48)
98 {
99 case 0:
100 ox = sprx-cposx; oy = spry-cposy;
101 x1 = mulscale(ox,xvect,16) - mulscale(oy,yvect,16);
102 y1 = mulscale(oy,xvect2,16) + mulscale(ox,yvect2,16);
103
104 if (dimensionmode[screenpeek] == 1)
105 {
106 ox = (sintable[(spr->ang+512)&2047]>>7);
107 oy = (sintable[(spr->ang)&2047]>>7);
108 x2 = mulscale(ox,xvect,16) - mulscale(oy,yvect,16);
109 y2 = mulscale(oy,xvect,16) + mulscale(ox,yvect,16);
110
111 if (j == playersprite[screenpeek])
112 {
113 x2 = 0L;
114 y2 = -(czoom<<5);
115 }
116
117 x3 = mulscale(x2,yxaspect,16);
118 y3 = mulscale(y2,yxaspect,16);
119
120 drawline256(x1-x2+(xdim<<11),y1-y3+(ydim<<11),
121 x1+x2+(xdim<<11),y1+y3+(ydim<<11),col);
122 drawline256(x1-y2+(xdim<<11),y1+x3+(ydim<<11),
123 x1+x2+(xdim<<11),y1+y3+(ydim<<11),col);
124 drawline256(x1+y2+(xdim<<11),y1-x3+(ydim<<11),
125 x1+x2+(xdim<<11),y1+y3+(ydim<<11),col);
126 }
127 else
128 {
129 if (((gotsector[i>>3]&(1<<(i&7))) > 0) && (czoom > 192))
130 {
131 daang = (spr->ang-cang)&2047;
132 if (j == playersprite[screenpeek])
133 { x1 = 0; y1 = (yxaspect<<2); daang = 0; }
134 rotatesprite((x1<<4)+(xdim<<15),(y1<<4)+(ydim<<15),mulscale(czoom*spr->yrepeat,yxaspect,16),daang,spr->picnum,spr->shade,spr->pal,(spr->cstat&2)>>1, windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y);
135 }
136 }
137 break;
138 case 16:
139 x1 = sprx; y1 = spry;
140 tilenum = spr->picnum;
141 xoff = (int)((signed char)((picanm[tilenum].xofs)&255))+((int)spr->xoffset);
142 if ((spr->cstat&4) > 0) xoff = -xoff;
143 k = spr->ang; l = spr->xrepeat;
144 dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l;
145 l = tilesiz[tilenum].x; k = (l>>1)+xoff;
146 x1 -= mulscale(dax,k,16); x2 = x1+mulscale(dax,l,16);
147 y1 -= mulscale(day,k,16); y2 = y1+mulscale(day,l,16);
148
149 ox = x1-cposx; oy = y1-cposy;
150 x1 = mulscale(ox,xvect,16) - mulscale(oy,yvect,16);
151 y1 = mulscale(oy,xvect2,16) + mulscale(ox,yvect2,16);
152
153 ox = x2-cposx; oy = y2-cposy;
154 x2 = mulscale(ox,xvect,16) - mulscale(oy,yvect,16);
155 y2 = mulscale(oy,xvect2,16) + mulscale(ox,yvect2,16);
156
157 drawline256(x1+(xdim<<11),y1+(ydim<<11),
158 x2+(xdim<<11),y2+(ydim<<11),col);
159
160 break;
161 case 32:
162 if (dimensionmode[screenpeek] == 1)
163 {
164 tilenum = spr->picnum;
165 xoff = (int)((signed char)((picanm[tilenum].xofs)&255))+((int)spr->xoffset);
166 yoff = (int)((signed char)((picanm[tilenum].yofs)&255))+((int)spr->yoffset);
167 if ((spr->cstat&4) > 0) xoff = -xoff;
168 if ((spr->cstat&8) > 0) yoff = -yoff;
169
170 k = spr->ang;
171 cosang = sintable[(k+512)&2047]; sinang = sintable[k];
172 xspan = tilesiz[tilenum].x; xrepeat = spr->xrepeat;
173 yspan = tilesiz[tilenum].y; yrepeat = spr->yrepeat;
174
175 dax = ((xspan>>1)+xoff)*xrepeat; day = ((yspan>>1)+yoff)*yrepeat;
176 x1 = sprx + mulscale(sinang,dax,16) + mulscale(cosang,day,16);
177 y1 = spry + mulscale(sinang,day,16) - mulscale(cosang,dax,16);
178 l = xspan*xrepeat;
179 x2 = x1 - mulscale(sinang,l,16);
180 y2 = y1 + mulscale(cosang,l,16);
181 l = yspan*yrepeat;
182 k = -mulscale(cosang,l,16); x3 = x2+k; x4 = x1+k;
183 k = -mulscale(sinang,l,16); y3 = y2+k; y4 = y1+k;
184
185 ox = x1-cposx; oy = y1-cposy;
186 x1 = mulscale(ox,xvect,16) - mulscale(oy,yvect,16);
187 y1 = mulscale(oy,xvect2,16) + mulscale(ox,yvect2,16);
188
189 ox = x2-cposx; oy = y2-cposy;
190 x2 = mulscale(ox,xvect,16) - mulscale(oy,yvect,16);
191 y2 = mulscale(oy,xvect2,16) + mulscale(ox,yvect2,16);
192
193 ox = x3-cposx; oy = y3-cposy;
194 x3 = mulscale(ox,xvect,16) - mulscale(oy,yvect,16);
195 y3 = mulscale(oy,xvect2,16) + mulscale(ox,yvect2,16);
196
197 ox = x4-cposx; oy = y4-cposy;
198 x4 = mulscale(ox,xvect,16) - mulscale(oy,yvect,16);
199 y4 = mulscale(oy,xvect2,16) + mulscale(ox,yvect2,16);
200
201 drawline256(x1+(xdim<<11),y1+(ydim<<11),
202 x2+(xdim<<11),y2+(ydim<<11),col);
203
204 drawline256(x2+(xdim<<11),y2+(ydim<<11),
205 x3+(xdim<<11),y3+(ydim<<11),col);
206
207 drawline256(x3+(xdim<<11),y3+(ydim<<11),
208 x4+(xdim<<11),y4+(ydim<<11),col);
209
210 drawline256(x4+(xdim<<11),y4+(ydim<<11),
211 x1+(xdim<<11),y1+(ydim<<11),col);
212
213 }
214 break;
215 }
216 }
217
218 //Draw white lines
219 for(i=0;i<numsectors;i++)
220 {
221 startwall = sector[i].wallptr;
222 endwall = sector[i].wallptr + sector[i].wallnum - 1;
223
224 for(j=startwall,wal=&wall[startwall];j<=endwall;j++,wal++)
225 {
226 if (wal->nextwall >= 0) continue;
227
228 if ((show2dwall[j>>3]&(1<<(j&7))) == 0) continue;
229
230 if (tilesiz[wal->picnum].x == 0) continue;
231 if (tilesiz[wal->picnum].y == 0) continue;
232
233 ox = wal->x-cposx; oy = wal->y-cposy;
234 x1 = mulscale(ox,xvect,16) - mulscale(oy,yvect,16);
235 y1 = mulscale(oy,xvect2,16) + mulscale(ox,yvect2,16);
236
237 wal2 = &wall[wal->point2];
238 ox = wal2->x-cposx; oy = wal2->y-cposy;
239 x2 = mulscale(ox,xvect,16) - mulscale(oy,yvect,16);
240 y2 = mulscale(oy,xvect2,16) + mulscale(ox,yvect2,16);
241
242 drawline256(x1+(xdim<<11),y1+(ydim<<11),x2+(xdim<<11),y2+(ydim<<11),239);
243 }
244 }
245 #endif
246 }
247
248