Fix a bunch of 'variable set but not used' warnings reported from GCC 4.6.0.
[kugel-rb.git] / apps / plugins / doom / am_map.c
blob88e27b4dc21266362f4238ca4e190eaa2f02d16f
1 /* Emacs style mode select -*- C++ -*-
2 *-----------------------------------------------------------------------------
5 * PrBoom a Doom port merged with LxDoom and LSDLDoom
6 * based on BOOM, a modified and improved DOOM engine
7 * Copyright (C) 1999 by
8 * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9 * Copyright (C) 1999-2000 by
10 * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 * 02111-1307, USA.
27 * DESCRIPTION:
28 * the automap code
30 *-----------------------------------------------------------------------------
33 #include "doomstat.h"
35 #include "st_stuff.h"
36 #include "r_main.h"
37 #include "p_setup.h"
38 #include "p_maputl.h"
39 #include "w_wad.h"
40 #include "v_video.h"
41 #include "p_spec.h"
42 #include "am_map.h"
43 #include "dstrings.h"
44 #include "d_deh.h" // Ty 03/27/98 - externalizations
45 #include "g_game.h"
46 #include "rockmacros.h"
49 //jff 1/7/98 default automap colors added
50 int mapcolor_back; // map background
51 int mapcolor_grid; // grid lines color
52 int mapcolor_wall; // normal 1s wall color
53 int mapcolor_fchg; // line at floor height change color
54 int mapcolor_cchg; // line at ceiling height change color
55 int mapcolor_clsd; // line at sector with floor=ceiling color
56 int mapcolor_rkey; // red key color
57 int mapcolor_bkey; // blue key color
58 int mapcolor_ykey; // yellow key color
59 int mapcolor_rdor; // red door color (diff from keys to allow option)
60 int mapcolor_bdor; // blue door color (of enabling one but not other )
61 int mapcolor_ydor; // yellow door color
62 int mapcolor_tele; // teleporter line color
63 int mapcolor_secr; // secret sector boundary color
64 int mapcolor_exit; // jff 4/23/98 add exit line color
65 int mapcolor_unsn; // computer map unseen line color
66 int mapcolor_flat; // line with no floor/ceiling changes
67 int mapcolor_sprt; // general sprite color
68 int mapcolor_item; // item sprite color
69 int mapcolor_frnd; // friendly sprite color
70 int mapcolor_hair; // crosshair color
71 int mapcolor_sngl; // single player arrow color
72 int mapcolor_plyr[4] = { 112, 88, 64, 176 }; // colors for player arrows in multiplayer
74 //jff 3/9/98 add option to not show secret sectors until entered
75 int map_secret_after;
76 //jff 4/3/98 add symbols for "no-color" for disable and "black color" for black
77 #define NC 0
78 #define BC 247
80 // drawing stuff
81 #define FB 0
83 // scale on entry
84 #define INITSCALEMTOF (.2*FRACUNIT)
85 // how much the automap moves window per tic in frame-buffer coordinates
86 // moves 140 pixels in 1 second
87 #define F_PANINC 4
88 // how much zoom-in per tic
89 // goes to 2x in 1 second
90 #define M_ZOOMIN ((int) (1.02*FRACUNIT))
91 // how much zoom-out per tic
92 // pulls out to 0.5x in 1 second
93 #define M_ZOOMOUT ((int) (FRACUNIT/1.02))
95 // translates between frame-buffer and map distances
96 #define FTOM(x) FixedMul(((x)<<16),scale_ftom)
97 #define MTOF(x) (FixedMul((x),scale_mtof)>>16)
98 // translates between frame-buffer and map coordinates
99 #define CXMTOF(x) (f_x + MTOF((x)-m_x))
100 #define CYMTOF(y) (f_y + (f_h - MTOF((y)-m_y)))
102 typedef struct
104 int x, y;
105 } fpoint_t;
107 typedef struct
109 fpoint_t a, b;
110 } fline_t;
112 typedef struct
114 mpoint_t a, b;
115 } mline_t;
117 typedef struct
119 fixed_t slp, islp;
120 } islope_t;
123 // The vector graphics for the automap.
124 // A line drawing of the player pointing right,
125 // starting from the middle.
127 #define R ((8*PLAYERRADIUS)/7)
128 mline_t player_arrow[] =
130 { { -R+R/8, 0 }, { R, 0 } }, // -----
131 { { R, 0 }, { R-R/2, R/4 } }, // ----->
132 { { R, 0 }, { R-R/2, -R/4 } },
133 { { -R+R/8, 0 }, { -R-R/8, R/4 } }, // >---->
134 { { -R+R/8, 0 }, { -R-R/8, -R/4 } },
135 { { -R+3*R/8, 0 }, { -R+R/8, R/4 } }, // >>--->
136 { { -R+3*R/8, 0 }, { -R+R/8, -R/4 } }
138 #undef R
139 #define NUMPLYRLINES (sizeof(player_arrow)/sizeof(mline_t))
141 #define R ((8*PLAYERRADIUS)/7)
142 mline_t cheat_player_arrow[] =
143 { // killough 3/22/98: He's alive, Jim :)
144 { { -R+R/8, 0 }, { R, 0 } }, // -----
145 { { R, 0 }, { R-R/2, R/4 } }, // ----->
146 { { R, 0 }, { R-R/2, -R/4 } },
147 { { -R+R/8, 0 }, { -R-R/8, R/4 } }, // >---->
148 { { -R+R/8, 0 }, { -R-R/8, -R/4 } },
149 { { -R+3*R/8, 0 }, { -R+R/8, R/4 } }, // >>--->
150 { { -R+3*R/8, 0 }, { -R+R/8, -R/4 } },
151 { { -R/10-R/6, R/4}, {-R/10-R/6, -R/4} }, // J
152 { { -R/10-R/6, -R/4}, {-R/10-R/6-R/8, -R/4} },
153 { { -R/10-R/6-R/8, -R/4}, {-R/10-R/6-R/8, -R/8} },
154 { { -R/10, R/4}, {-R/10, -R/4}}, // F
155 { { -R/10, R/4}, {-R/10+R/8, R/4}},
156 { { -R/10+R/4, R/4}, {-R/10+R/4, -R/4}}, // F
157 { { -R/10+R/4, R/4}, {-R/10+R/4+R/8, R/4}},
159 #undef R
160 #define NUMCHEATPLYRLINES (sizeof(cheat_player_arrow)/sizeof(mline_t))
162 #define R (FRACUNIT)
163 mline_t triangle_guy[] =
165 { { (fixed_t)(-.867*R), (fixed_t)(-.5*R) }, { (fixed_t)( .867*R), (fixed_t)(-.5*R) } },
166 { { (fixed_t)( .867*R), (fixed_t)(-.5*R) }, { (fixed_t)(0 ), (fixed_t)( R) } },
167 { { (fixed_t)(0 ), (fixed_t)( R) }, { (fixed_t)(-.867*R), (fixed_t)(-.5*R) } }
169 #undef R
170 #define NUMTRIANGLEGUYLINES (sizeof(triangle_guy)/sizeof(mline_t))
172 //jff 1/5/98 new symbol for keys on automap
173 #define R (FRACUNIT)
174 mline_t cross_mark[] =
176 { { -R, 0 }, { R, 0} },
177 { { 0, -R }, { 0, R } },
179 #undef R
180 #define NUMCROSSMARKLINES (sizeof(cross_mark)/sizeof(mline_t))
181 //jff 1/5/98 end of new symbol
183 #define R (FRACUNIT)
184 mline_t thintriangle_guy[] =
186 { { (fixed_t)(-.5*R), (fixed_t)(-.7*R) }, { (fixed_t)( R), (fixed_t)( 0) } },
187 { { (fixed_t)( R), (fixed_t)( 0) }, { (fixed_t)(-.5*R), (fixed_t)( .7*R) } },
188 { { (fixed_t)(-.5*R), (fixed_t)( .7*R) }, { (fixed_t)(-.5*R), (fixed_t)(-.7*R) } }
190 #undef R
191 #define NUMTHINTRIANGLEGUYLINES (sizeof(thintriangle_guy)/sizeof(mline_t))
193 int ddt_cheating = 0; // killough 2/7/98: make global, rename to ddt_*
195 static int leveljuststarted = 1; // kluge until AM_LevelInit() is called
197 automapmode_e automapmode; // Mode that the automap is in
199 // location of window on screen
200 static int f_x;
201 static int f_y;
203 // size of window on screen
204 static int f_w;
205 static int f_h;
207 static mpoint_t m_paninc; // how far the window pans each tic (map coords)
208 static fixed_t mtof_zoommul; // how far the window zooms each tic (map coords)
209 static fixed_t ftom_zoommul; // how far the window zooms each tic (fb coords)
211 static fixed_t m_x, m_y; // LL x,y window location on the map (map coords)
212 static fixed_t m_x2, m_y2; // UR x,y window location on the map (map coords)
215 // width/height of window on map (map coords)
217 static fixed_t m_w;
218 static fixed_t m_h;
220 // based on level size
221 static fixed_t min_x;
222 static fixed_t min_y;
223 static fixed_t max_x;
224 static fixed_t max_y;
226 static fixed_t max_w; // max_x-min_x,
227 static fixed_t max_h; // max_y-min_y
229 // based on player size
230 static fixed_t min_w;
231 static fixed_t min_h;
234 static fixed_t min_scale_mtof; // used to tell when to stop zooming out
235 static fixed_t max_scale_mtof; // used to tell when to stop zooming in
237 // old stuff for recovery later
238 static fixed_t old_m_w, old_m_h;
239 static fixed_t old_m_x, old_m_y;
241 // old location used by the Follower routine
242 static mpoint_t f_oldloc;
244 // used by MTOF to scale from map-to-frame-buffer coords
245 static fixed_t scale_mtof = (fixed_t)INITSCALEMTOF;
246 // used by FTOM to scale from frame-buffer-to-map coords (=1/scale_mtof)
247 static fixed_t scale_ftom;
249 static player_t *plr; // the player represented by an arrow
251 // killough 2/22/98: Remove limit on automap marks,
252 // and make variables external for use in savegames.
254 mpoint_t *markpoints = NULL; // where the points are
255 int markpointnum = 0; // next point to be assigned (also number of points now)
256 int markpointnum_max = 0; // killough 2/22/98
258 static boolean stopped = true;
261 // AM_getIslope()
263 // Calculates the slope and slope according to the x-axis of a line
264 // segment in map coordinates (with the upright y-axis n' all) so
265 // that it can be used with the brain-dead drawing stuff.
267 // Passed the line slope is desired for and an islope_t structure for return
268 // Returns nothing
270 void AM_getIslope
271 ( mline_t* ml,
272 islope_t* is )
274 int dx, dy;
276 dy = ml->a.y - ml->b.y;
277 dx = ml->b.x - ml->a.x;
278 if (!dy)
279 is->islp = (dx<0?-INT_MAX:INT_MAX);
280 else
281 is->islp = FixedDiv(dx, dy);
282 if (!dx)
283 is->slp = (dy<0?-INT_MAX:INT_MAX);
284 else
285 is->slp = FixedDiv(dy, dx);
289 // AM_activateNewScale()
291 // Changes the map scale after zooming or translating
293 // Passed nothing, returns nothing
295 void AM_activateNewScale(void)
297 m_x += m_w/2;
298 m_y += m_h/2;
299 m_w = FTOM(f_w);
300 m_h = FTOM(f_h);
301 m_x -= m_w/2;
302 m_y -= m_h/2;
303 m_x2 = m_x + m_w;
304 m_y2 = m_y + m_h;
308 // AM_saveScaleAndLoc()
310 // Saves the current center and zoom
311 // Affects the variables that remember old scale and loc
313 // Passed nothing, returns nothing
315 void AM_saveScaleAndLoc(void)
317 old_m_x = m_x;
318 old_m_y = m_y;
319 old_m_w = m_w;
320 old_m_h = m_h;
324 // AM_restoreScaleAndLoc()
326 // restores the center and zoom from locally saved values
327 // Affects global variables for location and scale
329 // Passed nothing, returns nothing
331 void AM_restoreScaleAndLoc(void)
333 m_w = old_m_w;
334 m_h = old_m_h;
335 if (!(automapmode & am_follow))
337 m_x = old_m_x;
338 m_y = old_m_y;
340 else
342 m_x = plr->mo->x - m_w/2;
343 m_y = plr->mo->y - m_h/2;
345 m_x2 = m_x + m_w;
346 m_y2 = m_y + m_h;
348 // Change the scaling multipliers
349 scale_mtof = FixedDiv(f_w<<FRACBITS, m_w);
350 scale_ftom = FixedDiv(FRACUNIT, scale_mtof);
354 // AM_addMark()
356 // Adds a marker at the current location
357 // Affects global variables for marked points
359 // Passed nothing, returns nothing
361 void AM_addMark(void)
363 // killough 2/22/98:
364 // remove limit on automap marks
366 if (markpointnum >= markpointnum_max)
367 markpoints = realloc(markpoints,
368 (markpointnum_max = markpointnum_max ?
369 markpointnum_max*2 : 16) * sizeof(*markpoints));
371 markpoints[markpointnum].x = m_x + m_w/2;
372 markpoints[markpointnum].y = m_y + m_h/2;
373 markpointnum++;
377 // AM_findMinMaxBoundaries()
379 // Determines bounding box of all vertices,
380 // sets global variables controlling zoom range.
382 // Passed nothing, returns nothing
384 void AM_findMinMaxBoundaries(void)
386 int i;
387 fixed_t a;
388 fixed_t b;
390 min_x = min_y = INT_MAX;
391 max_x = max_y = -INT_MAX;
393 for (i=0;i<numvertexes;i++)
395 if (vertexes[i].x < min_x)
396 min_x = vertexes[i].x;
397 else if (vertexes[i].x > max_x)
398 max_x = vertexes[i].x;
400 if (vertexes[i].y < min_y)
401 min_y = vertexes[i].y;
402 else if (vertexes[i].y > max_y)
403 max_y = vertexes[i].y;
406 max_w = max_x - min_x;
407 max_h = max_y - min_y;
409 min_w = 2*PLAYERRADIUS; // const? never changed?
410 min_h = 2*PLAYERRADIUS;
412 a = FixedDiv(f_w<<FRACBITS, max_w);
413 b = FixedDiv(f_h<<FRACBITS, max_h);
415 min_scale_mtof = a < b ? a : b;
416 max_scale_mtof = FixedDiv(f_h<<FRACBITS, 2*PLAYERRADIUS);
420 // AM_changeWindowLoc()
422 // Moves the map window by the global variables m_paninc.x, m_paninc.y
424 // Passed nothing, returns nothing
426 void AM_changeWindowLoc(void)
428 if (m_paninc.x || m_paninc.y)
430 automapmode &= ~am_follow;
431 f_oldloc.x = INT_MAX;
434 m_x += m_paninc.x;
435 m_y += m_paninc.y;
437 if (m_x + m_w/2 > max_x)
438 m_x = max_x - m_w/2;
439 else if (m_x + m_w/2 < min_x)
440 m_x = min_x - m_w/2;
442 if (m_y + m_h/2 > max_y)
443 m_y = max_y - m_h/2;
444 else if (m_y + m_h/2 < min_y)
445 m_y = min_y - m_h/2;
447 m_x2 = m_x + m_w;
448 m_y2 = m_y + m_h;
453 // AM_initVariables()
455 // Initialize the variables for the automap
457 // Affects the automap global variables
458 // Status bar is notified that the automap has been entered
459 // Passed nothing, returns nothing
461 void AM_initVariables(void)
463 int pnum;
464 static event_t st_notify = { ev_keyup, AM_MSGENTERED, 0 , 0 };
466 automapmode |= am_active;
468 f_oldloc.x = INT_MAX;
470 m_paninc.x = m_paninc.y = 0;
471 ftom_zoommul = FRACUNIT;
472 mtof_zoommul = FRACUNIT;
474 m_w = FTOM(f_w);
475 m_h = FTOM(f_h);
477 // find player to center on initially
478 if (!playeringame[pnum = consoleplayer])
479 for (pnum=0;pnum<MAXPLAYERS;pnum++)
480 if (playeringame[pnum])
481 break;
483 plr = &players[pnum];
484 m_x = plr->mo->x - m_w/2;
485 m_y = plr->mo->y - m_h/2;
486 AM_changeWindowLoc();
488 // for saving & restoring
489 old_m_x = m_x;
490 old_m_y = m_y;
491 old_m_w = m_w;
492 old_m_h = m_h;
494 // inform the status bar of the change
495 ST_Responder(&st_notify);
499 // AM_loadPics()
501 void AM_loadPics(void)
503 // cph - mark numbers no longer needed cached
507 // AM_unloadPics()
509 void AM_unloadPics(void)
511 // cph - mark numbers no longer needed cached
515 // AM_clearMarks()
517 // Sets the number of marks to 0, thereby clearing them from the display
519 // Affects the global variable markpointnum
520 // Passed nothing, returns nothing
522 void AM_clearMarks(void)
524 markpointnum = 0;
528 // AM_LevelInit()
530 // Initialize the automap at the start of a new level
531 // should be called at the start of every level
533 // Passed nothing, returns nothing
534 // Affects automap's global variables
536 // CPhipps - get status bar height from status bar code
537 void AM_LevelInit(void)
539 leveljuststarted = 0;
541 f_x = f_y = 0;
542 f_w = SCREENWIDTH; // killough 2/7/98: get rid of finit_ vars
543 f_h = SCREENHEIGHT-ST_SCALED_HEIGHT;// to allow runtime setting of width/height
545 AM_findMinMaxBoundaries();
546 scale_mtof = FixedDiv(min_scale_mtof, (int) (0.7*FRACUNIT));
547 if (scale_mtof > max_scale_mtof)
548 scale_mtof = min_scale_mtof;
549 scale_ftom = FixedDiv(FRACUNIT, scale_mtof);
553 // AM_Stop()
555 // Cease automap operations, unload patches, notify status bar
557 // Passed nothing, returns nothing
559 void AM_Stop (void)
561 static event_t st_notify = { 0, ev_keyup, AM_MSGEXITED, 0 };
563 AM_unloadPics();
564 automapmode &= ~am_active;
565 ST_Responder(&st_notify);
566 stopped = true;
570 // AM_Start()
572 // Start up automap operations,
573 // if a new level, or game start, (re)initialize level variables
574 // init map variables
575 // load mark patches
577 // Passed nothing, returns nothing
579 void AM_Start()
581 static int lastlevel = -1, lastepisode = -1;
583 if (!stopped)
584 AM_Stop();
585 stopped = false;
586 if (lastlevel != gamemap || lastepisode != gameepisode)
588 AM_LevelInit();
589 lastlevel = gamemap;
590 lastepisode = gameepisode;
592 AM_initVariables();
593 AM_loadPics();
597 // AM_minOutWindowScale()
599 // Set the window scale to the maximum size
601 // Passed nothing, returns nothing
603 void AM_minOutWindowScale()
605 scale_mtof = min_scale_mtof;
606 scale_ftom = FixedDiv(FRACUNIT, scale_mtof);
607 AM_activateNewScale();
611 // AM_maxOutWindowScale(void)
613 // Set the window scale to the minimum size
615 // Passed nothing, returns nothing
617 void AM_maxOutWindowScale(void)
619 scale_mtof = max_scale_mtof;
620 scale_ftom = FixedDiv(FRACUNIT, scale_mtof);
621 AM_activateNewScale();
625 // AM_Responder()
627 // Handle events (user inputs) in automap mode
629 // Passed an input event, returns true if its handled
631 boolean AM_Responder
632 ( event_t* ev )
634 int rc;
635 static int bigstate=0;
636 static char buffer[20];
637 int ch; // phares
639 rc = false;
641 if (!(automapmode & am_active))
643 if (ev->type == ev_keydown && ev->data1 == key_map) // phares
645 AM_Start ();
646 rc = true;
649 else if (ev->type == ev_keydown)
651 rc = true;
652 ch = ev->data1; // phares
653 if (ch == key_map_right) // |
654 if (!(automapmode & am_follow)) // V
655 m_paninc.x = FTOM(F_PANINC);
656 else
657 rc = false;
658 else if (ch == key_map_left)
659 if (!(automapmode & am_follow))
660 m_paninc.x = -FTOM(F_PANINC);
661 else
662 rc = false;
663 else if (ch == key_map_up)
664 if (!(automapmode & am_follow))
665 m_paninc.y = FTOM(F_PANINC);
666 else
667 rc = false;
668 else if (ch == key_map_down)
669 if (!(automapmode & am_follow))
670 m_paninc.y = -FTOM(F_PANINC);
671 else
672 rc = false;
673 else if (ch == key_map_zoomout)
675 mtof_zoommul = M_ZOOMOUT;
676 ftom_zoommul = M_ZOOMIN;
678 else if (ch == key_map_zoomin)
680 mtof_zoommul = M_ZOOMIN;
681 ftom_zoommul = M_ZOOMOUT;
683 else if (ch == key_map)
685 bigstate = 0;
686 AM_Stop ();
688 else if (ch == key_map_gobig)
690 bigstate = !bigstate;
691 if (bigstate)
693 AM_saveScaleAndLoc();
694 AM_minOutWindowScale();
696 else
697 AM_restoreScaleAndLoc();
699 else if (ch == key_map_follow)
701 automapmode ^= am_follow; // CPhipps - put all automap mode stuff into one enum
702 f_oldloc.x = INT_MAX;
703 // Ty 03/27/98 - externalized
704 plr->message = (automapmode & am_follow) ? s_AMSTR_FOLLOWON : s_AMSTR_FOLLOWOFF;
706 else if (ch == key_map_grid)
708 automapmode ^= am_grid; // CPhipps
709 // Ty 03/27/98 - *not* externalized
710 plr->message = (automapmode & am_grid) ? s_AMSTR_GRIDON : s_AMSTR_GRIDOFF;
712 else if (ch == key_map_mark)
714 // Ty 03/27/98 - *not* externalized
715 snprintf(buffer, sizeof(buffer), "%s %d", s_AMSTR_MARKEDSPOT, markpointnum);
716 plr->message = buffer;
717 AM_addMark();
719 else if (ch == key_map_clear)
721 AM_clearMarks(); // Ty 03/27/98 - *not* externalized
722 plr->message = s_AMSTR_MARKSCLEARED; // ^
723 } // |
724 else if (ch == key_map_rotate) {
725 automapmode ^= am_rotate;
726 plr->message = (automapmode & am_rotate) ? s_AMSTR_ROTATEON : s_AMSTR_ROTATEOFF;
728 else if (ch == key_map_overlay) {
729 automapmode ^= am_overlay;
730 plr->message = (automapmode & am_overlay) ? s_AMSTR_OVERLAYON : s_AMSTR_OVERLAYOFF;
732 else // phares
734 rc = false;
737 else if (ev->type == ev_keyup)
739 rc = false;
740 ch = ev->data1;
741 if (ch == key_map_right)
743 if (!(automapmode & am_follow))
744 m_paninc.x = 0;
746 else if (ch == key_map_left)
748 if (!(automapmode & am_follow))
749 m_paninc.x = 0;
751 else if (ch == key_map_up)
753 if (!(automapmode & am_follow))
754 m_paninc.y = 0;
756 else if (ch == key_map_down)
758 if (!(automapmode & am_follow))
759 m_paninc.y = 0;
761 else if ((ch == key_map_zoomout) || (ch == key_map_zoomin))
763 mtof_zoommul = FRACUNIT;
764 ftom_zoommul = FRACUNIT;
767 return rc;
771 // AM_rotate()
773 // Rotation in 2D.
774 // Used to rotate player arrow line character.
776 // Passed the coordinates of a point, and an angle
777 // Returns the coordinates rotated by the angle
779 // CPhipps - made static & enhanced for automap rotation
781 static void AM_rotate(fixed_t* x, fixed_t* y, angle_t a, fixed_t xorig, fixed_t yorig)
783 fixed_t tmpx;
785 tmpx =
786 FixedMul(*x - xorig,finecosine[a>>ANGLETOFINESHIFT])
787 - FixedMul(*y - yorig,finesine[a>>ANGLETOFINESHIFT]);
789 *y = yorig +
790 FixedMul(*x - xorig,finesine[a>>ANGLETOFINESHIFT])
791 + FixedMul(*y - yorig,finecosine[a>>ANGLETOFINESHIFT]);
793 *x = tmpx + xorig;
797 // AM_changeWindowScale()
799 // Automap zooming
801 // Passed nothing, returns nothing
803 void AM_changeWindowScale(void)
805 // Change the scaling multipliers
806 scale_mtof = FixedMul(scale_mtof, mtof_zoommul);
807 scale_ftom = FixedDiv(FRACUNIT, scale_mtof);
809 if (scale_mtof < min_scale_mtof)
810 AM_minOutWindowScale();
811 else if (scale_mtof > max_scale_mtof)
812 AM_maxOutWindowScale();
813 else
814 AM_activateNewScale();
818 // AM_doFollowPlayer()
820 // Turn on follow mode - the map scrolls opposite to player motion
822 // Passed nothing, returns nothing
824 void AM_doFollowPlayer(void)
826 if (f_oldloc.x != plr->mo->x || f_oldloc.y != plr->mo->y)
828 m_x = FTOM(MTOF(plr->mo->x)) - m_w/2;
829 m_y = FTOM(MTOF(plr->mo->y)) - m_h/2;
830 m_x2 = m_x + m_w;
831 m_y2 = m_y + m_h;
832 f_oldloc.x = plr->mo->x;
833 f_oldloc.y = plr->mo->y;
838 // AM_Ticker()
840 // Updates on gametic - enter follow mode, zoom, or change map location
842 // Passed nothing, returns nothing
844 void AM_Ticker (void)
846 if (!(automapmode & am_active))
847 return;
849 if (automapmode & am_follow)
850 AM_doFollowPlayer();
852 // Change the zoom if necessary
853 if (ftom_zoommul != FRACUNIT)
854 AM_changeWindowScale();
856 // Change x,y location
857 if (m_paninc.x || m_paninc.y)
858 AM_changeWindowLoc();
862 // AM_clipMline()
864 // Automap clipping of lines.
866 // Based on Cohen-Sutherland clipping algorithm but with a slightly
867 // faster reject and precalculated slopes. If the speed is needed,
868 // use a hash algorithm to handle the common cases.
870 // Passed the line's coordinates on map and in the frame buffer performs
871 // clipping on them in the lines frame coordinates.
872 // Returns true if any part of line was not clipped
874 boolean AM_clipMline
875 ( mline_t* ml,
876 fline_t* fl )
878 enum
880 LEFT =1,
881 RIGHT =2,
882 BOTTOM =4,
883 TOP =8
886 register int outcode1 = 0;
887 register int outcode2 = 0;
888 register int outside;
890 fpoint_t tmp = {0,0};
891 int dx;
892 int dy;
895 #define DOOUTCODE(oc, mx, my) \
896 (oc) = 0; \
897 if ((my) < 0) (oc) |= TOP; \
898 else if ((my) >= f_h) (oc) |= BOTTOM; \
899 if ((mx) < 0) (oc) |= LEFT; \
900 else if ((mx) >= f_w) (oc) |= RIGHT;
903 // do trivial rejects and outcodes
904 if (ml->a.y > m_y2)
905 outcode1 = TOP;
906 else if (ml->a.y < m_y)
907 outcode1 = BOTTOM;
909 if (ml->b.y > m_y2)
910 outcode2 = TOP;
911 else if (ml->b.y < m_y)
912 outcode2 = BOTTOM;
914 if (outcode1 & outcode2)
915 return false; // trivially outside
917 if (ml->a.x < m_x)
918 outcode1 |= LEFT;
919 else if (ml->a.x > m_x2)
920 outcode1 |= RIGHT;
922 if (ml->b.x < m_x)
923 outcode2 |= LEFT;
924 else if (ml->b.x > m_x2)
925 outcode2 |= RIGHT;
927 if (outcode1 & outcode2)
928 return false; // trivially outside
930 // transform to frame-buffer coordinates.
931 fl->a.x = CXMTOF(ml->a.x);
932 fl->a.y = CYMTOF(ml->a.y);
933 fl->b.x = CXMTOF(ml->b.x);
934 fl->b.y = CYMTOF(ml->b.y);
936 DOOUTCODE(outcode1, fl->a.x, fl->a.y);
937 DOOUTCODE(outcode2, fl->b.x, fl->b.y);
939 if (outcode1 & outcode2)
940 return false;
942 while (outcode1 | outcode2)
944 // may be partially inside box
945 // find an outside point
946 if (outcode1)
947 outside = outcode1;
948 else
949 outside = outcode2;
951 // clip to each side
952 if (outside & TOP)
954 dy = fl->a.y - fl->b.y;
955 dx = fl->b.x - fl->a.x;
956 tmp.x = fl->a.x + (dx*(fl->a.y))/dy;
957 tmp.y = 0;
959 else if (outside & BOTTOM)
961 dy = fl->a.y - fl->b.y;
962 dx = fl->b.x - fl->a.x;
963 tmp.x = fl->a.x + (dx*(fl->a.y-f_h))/dy;
964 tmp.y = f_h-1;
966 else if (outside & RIGHT)
968 dy = fl->b.y - fl->a.y;
969 dx = fl->b.x - fl->a.x;
970 tmp.y = fl->a.y + (dy*(f_w-1 - fl->a.x))/dx;
971 tmp.x = f_w-1;
973 else if (outside & LEFT)
975 dy = fl->b.y - fl->a.y;
976 dx = fl->b.x - fl->a.x;
977 tmp.y = fl->a.y + (dy*(-fl->a.x))/dx;
978 tmp.x = 0;
981 if (outside == outcode1)
983 fl->a = tmp;
984 DOOUTCODE(outcode1, fl->a.x, fl->a.y);
986 else
988 fl->b = tmp;
989 DOOUTCODE(outcode2, fl->b.x, fl->b.y);
992 if (outcode1 & outcode2)
993 return false; // trivially outside
996 return true;
998 #undef DOOUTCODE
1001 // AM_drawFline()
1003 // Draw a line in the frame buffer.
1004 // Classic Bresenham w/ whatever optimizations needed for speed
1006 // Passed the frame coordinates of line, and the color to be drawn
1007 // Returns nothing
1010 void AM_drawFline
1011 ( fline_t* fl,
1012 int color )
1014 register int x;
1015 register int y;
1016 register int dx;
1017 register int dy;
1018 register int sx;
1019 register int sy;
1020 register int ax;
1021 register int ay;
1022 register int d;
1024 #ifdef RANGECHECK // killough 2/22/98
1025 static int fuck = 0;
1027 // For debugging only
1030 fl->a.x < 0 || fl->a.x >= f_w
1031 || fl->a.y < 0 || fl->a.y >= f_h
1032 || fl->b.x < 0 || fl->b.x >= f_w
1033 || fl->b.y < 0 || fl->b.y >= f_h
1036 //jff 8/3/98 use logical output routine
1037 printf("fuck %d \r", fuck++);
1038 return;
1040 #endif
1042 #define PUTDOT(xx,yy,cc) V_PlotPixel(FB,xx,yy,(byte)cc)
1044 dx = fl->b.x - fl->a.x;
1045 ax = 2 * (dx<0 ? -dx : dx);
1046 sx = dx<0 ? -1 : 1;
1048 dy = fl->b.y - fl->a.y;
1049 ay = 2 * (dy<0 ? -dy : dy);
1050 sy = dy<0 ? -1 : 1;
1052 x = fl->a.x;
1053 y = fl->a.y;
1055 if (ax > ay)
1057 d = ay - ax/2;
1058 while (1)
1060 PUTDOT(x,y,color);
1061 if (x == fl->b.x) return;
1062 if (d>=0)
1064 y += sy;
1065 d -= ax;
1067 x += sx;
1068 d += ay;
1071 else
1073 d = ax - ay/2;
1074 while (1)
1076 PUTDOT(x, y, color);
1077 if (y == fl->b.y) return;
1078 if (d >= 0)
1080 x += sx;
1081 d -= ay;
1083 y += sy;
1084 d += ax;
1091 // AM_drawMline()
1093 // Clip lines, draw visible parts of lines.
1095 // Passed the map coordinates of the line, and the color to draw it
1096 // Color -1 is special and prevents drawing. Color 247 is special and
1097 // is translated to black, allowing Color 0 to represent feature disable
1098 // in the defaults file.
1099 // Returns nothing.
1101 void AM_drawMline
1102 ( mline_t* ml,
1103 int color )
1105 static fline_t fl;
1107 if (color==-1) // jff 4/3/98 allow not drawing any sort of line
1108 return; // by setting its color to -1
1109 if (color==247) // jff 4/3/98 if color is 247 (xparent), use black
1110 color=0;
1112 if (AM_clipMline(ml, &fl))
1113 AM_drawFline(&fl, color); // draws it on frame buffer using fb coords
1117 // AM_drawGrid()
1119 // Draws blockmap aligned grid lines.
1121 // Passed the color to draw the grid lines
1122 // Returns nothing
1124 void AM_drawGrid(int color)
1126 fixed_t x, y;
1127 fixed_t start, end;
1128 mline_t ml;
1130 // Figure out start of vertical gridlines
1131 start = m_x;
1132 if ((start-bmaporgx)%(MAPBLOCKUNITS<<FRACBITS))
1133 start += (MAPBLOCKUNITS<<FRACBITS)
1134 - ((start-bmaporgx)%(MAPBLOCKUNITS<<FRACBITS));
1135 end = m_x + m_w;
1137 // draw vertical gridlines
1138 ml.a.y = m_y;
1139 ml.b.y = m_y+m_h;
1140 for (x=start; x<end; x+=(MAPBLOCKUNITS<<FRACBITS))
1142 ml.a.x = x;
1143 ml.b.x = x;
1144 AM_drawMline(&ml, color);
1147 // Figure out start of horizontal gridlines
1148 start = m_y;
1149 if ((start-bmaporgy)%(MAPBLOCKUNITS<<FRACBITS))
1150 start += (MAPBLOCKUNITS<<FRACBITS)
1151 - ((start-bmaporgy)%(MAPBLOCKUNITS<<FRACBITS));
1152 end = m_y + m_h;
1154 // draw horizontal gridlines
1155 ml.a.x = m_x;
1156 ml.b.x = m_x + m_w;
1157 for (y=start; y<end; y+=(MAPBLOCKUNITS<<FRACBITS))
1159 ml.a.y = y;
1160 ml.b.y = y;
1161 AM_drawMline(&ml, color);
1166 // AM_DoorColor()
1168 // Returns the 'color' or key needed for a door linedef type
1170 // Passed the type of linedef, returns:
1171 // -1 if not a keyed door
1172 // 0 if a red key required
1173 // 1 if a blue key required
1174 // 2 if a yellow key required
1175 // 3 if a multiple keys required
1177 // jff 4/3/98 add routine to get color of generalized keyed door
1179 int AM_DoorColor(int type)
1181 if (GenLockedBase <= type && type< GenDoorBase)
1183 type -= GenLockedBase;
1184 type = (type & LockedKey) >> LockedKeyShift;
1185 if (!type || type==7)
1186 return 3; //any or all keys
1187 else return (type-1)%3;
1189 switch (type) // closed keyed door
1191 case 26: case 32: case 99: case 133:
1192 /*bluekey*/
1193 return 1;
1194 case 27: case 34: case 136: case 137:
1195 /*yellowkey*/
1196 return 2;
1197 case 28: case 33: case 134: case 135:
1198 /*redkey*/
1199 return 0;
1200 default:
1201 return -1; //not a keyed door
1203 return -1; //not a keyed door
1207 // Determines visible lines, draws them.
1208 // This is LineDef based, not LineSeg based.
1210 // jff 1/5/98 many changes in this routine
1211 // backward compatibility not needed, so just changes, no ifs
1212 // addition of clauses for:
1213 // doors opening, keyed door id, secret sectors,
1214 // teleports, exit lines, key things
1215 // ability to suppress any of added features or lines with no height changes
1217 // support for gamma correction in automap abandoned
1219 // jff 4/3/98 changed mapcolor_xxxx=0 as control to disable feature
1220 // jff 4/3/98 changed mapcolor_xxxx=-1 to disable drawing line completely
1222 void AM_drawWalls(void)
1224 int i;
1225 static mline_t l;
1227 // draw the unclipped visible portions of all lines
1228 for (i=0;i<numlines;i++)
1230 l.a.x = lines[i].v1->x;
1231 l.a.y = lines[i].v1->y;
1232 l.b.x = lines[i].v2->x;
1233 l.b.y = lines[i].v2->y;
1235 if (automapmode & am_rotate) {
1236 AM_rotate(&l.a.x, &l.a.y, ANG90-plr->mo->angle, plr->mo->x, plr->mo->y);
1237 AM_rotate(&l.b.x, &l.b.y, ANG90-plr->mo->angle, plr->mo->x, plr->mo->y);
1240 // if line has been seen or IDDT has been used
1241 if (ddt_cheating || (lines[i].flags & ML_MAPPED))
1243 if ((lines[i].flags & ML_DONTDRAW) && !ddt_cheating)
1244 continue;
1246 /* cph - show keyed doors and lines */
1247 int amd;
1248 if ((mapcolor_bdor || mapcolor_ydor || mapcolor_rdor) &&
1249 !(lines[i].flags & ML_SECRET) && /* non-secret */
1250 (amd = AM_DoorColor(lines[i].special)) != -1
1254 switch (amd) /* closed keyed door */
1256 case 1:
1257 /*bluekey*/
1258 AM_drawMline(&l,
1259 mapcolor_bdor? mapcolor_bdor : mapcolor_cchg);
1260 continue;
1261 case 2:
1262 /*yellowkey*/
1263 AM_drawMline(&l,
1264 mapcolor_ydor? mapcolor_ydor : mapcolor_cchg);
1265 continue;
1266 case 0:
1267 /*redkey*/
1268 AM_drawMline(&l,
1269 mapcolor_rdor? mapcolor_rdor : mapcolor_cchg);
1270 continue;
1271 case 3:
1272 /*any or all*/
1273 AM_drawMline(&l,
1274 mapcolor_clsd? mapcolor_clsd : mapcolor_cchg);
1275 continue;
1280 if /* jff 4/23/98 add exit lines to automap */
1282 mapcolor_exit &&
1284 lines[i].special==11 ||
1285 lines[i].special==52 ||
1286 lines[i].special==197 ||
1287 lines[i].special==51 ||
1288 lines[i].special==124 ||
1289 lines[i].special==198
1292 AM_drawMline(&l, mapcolor_exit); /* exit line */
1293 continue;
1296 if (!lines[i].backsector)
1298 // jff 1/10/98 add new color for 1S secret sector boundary
1299 if (mapcolor_secr && //jff 4/3/98 0 is disable
1302 map_secret_after &&
1303 P_WasSecret(lines[i].frontsector) &&
1304 !P_IsSecret(lines[i].frontsector)
1308 !map_secret_after &&
1309 P_WasSecret(lines[i].frontsector)
1313 AM_drawMline(&l, mapcolor_secr); // line bounding secret sector
1314 else //jff 2/16/98 fixed bug
1315 AM_drawMline(&l, mapcolor_wall); // special was cleared
1317 else /* now for 2S lines */
1319 // jff 1/10/98 add color change for all teleporter types
1322 mapcolor_tele && !(lines[i].flags & ML_SECRET) &&
1323 (lines[i].special == 39 || lines[i].special == 97 ||
1324 lines[i].special == 125 || lines[i].special == 126)
1326 { // teleporters
1327 AM_drawMline(&l, mapcolor_tele);
1329 else if (lines[i].flags & ML_SECRET) // secret door
1331 AM_drawMline(&l, mapcolor_wall); // wall color
1333 else if
1335 mapcolor_clsd &&
1336 !(lines[i].flags & ML_SECRET) && // non-secret closed door
1337 ((lines[i].backsector->floorheight==lines[i].backsector->ceilingheight) ||
1338 (lines[i].frontsector->floorheight==lines[i].frontsector->ceilingheight))
1341 AM_drawMline(&l, mapcolor_clsd); // non-secret closed door
1342 } //jff 1/6/98 show secret sector 2S lines
1343 else if
1345 mapcolor_secr && //jff 2/16/98 fixed bug
1346 ( // special was cleared after getting it
1347 (map_secret_after &&
1349 (P_WasSecret(lines[i].frontsector)
1350 && !P_IsSecret(lines[i].frontsector)) ||
1351 (P_WasSecret(lines[i].backsector)
1352 && !P_IsSecret(lines[i].backsector))
1355 || //jff 3/9/98 add logic to not show secret til after entered
1356 ( // if map_secret_after is true
1357 !map_secret_after &&
1358 (P_WasSecret(lines[i].frontsector) ||
1359 P_WasSecret(lines[i].backsector))
1364 AM_drawMline(&l, mapcolor_secr); // line bounding secret sector
1365 } //jff 1/6/98 end secret sector line change
1366 else if (lines[i].backsector->floorheight !=
1367 lines[i].frontsector->floorheight)
1369 AM_drawMline(&l, mapcolor_fchg); // floor level change
1371 else if (lines[i].backsector->ceilingheight !=
1372 lines[i].frontsector->ceilingheight)
1374 AM_drawMline(&l, mapcolor_cchg); // ceiling level change
1376 else if (mapcolor_flat && ddt_cheating)
1378 AM_drawMline(&l, mapcolor_flat); //2S lines that appear only in IDDT
1381 } // now draw the lines only visible because the player has computermap
1382 else if (plr->powers[pw_allmap]) // computermap visible lines
1384 if (!(lines[i].flags & ML_DONTDRAW)) // invisible flag lines do not show
1388 mapcolor_flat
1390 !lines[i].backsector
1392 lines[i].backsector->floorheight
1393 != lines[i].frontsector->floorheight
1395 lines[i].backsector->ceilingheight
1396 != lines[i].frontsector->ceilingheight
1398 AM_drawMline(&l, mapcolor_unsn);
1405 // AM_drawLineCharacter()
1407 // Draws a vector graphic according to numerous parameters
1409 // Passed the structure defining the vector graphic shape, the number
1410 // of vectors in it, the scale to draw it at, the angle to draw it at,
1411 // the color to draw it with, and the map coordinates to draw it at.
1412 // Returns nothing
1414 void AM_drawLineCharacter
1415 ( mline_t* lineguy,
1416 int lineguylines,
1417 fixed_t scale,
1418 angle_t angle,
1419 int color,
1420 fixed_t x,
1421 fixed_t y )
1423 int i;
1424 mline_t l;
1426 if (automapmode & am_rotate) angle -= plr->mo->angle - ANG90; // cph
1428 for (i=0;i<lineguylines;i++)
1430 l.a.x = lineguy[i].a.x;
1431 l.a.y = lineguy[i].a.y;
1433 if (scale)
1435 l.a.x = FixedMul(scale, l.a.x);
1436 l.a.y = FixedMul(scale, l.a.y);
1439 if (angle)
1440 AM_rotate(&l.a.x, &l.a.y, angle, 0, 0);
1442 l.a.x += x;
1443 l.a.y += y;
1445 l.b.x = lineguy[i].b.x;
1446 l.b.y = lineguy[i].b.y;
1448 if (scale)
1450 l.b.x = FixedMul(scale, l.b.x);
1451 l.b.y = FixedMul(scale, l.b.y);
1454 if (angle)
1455 AM_rotate(&l.b.x, &l.b.y, angle, 0, 0);
1457 l.b.x += x;
1458 l.b.y += y;
1460 AM_drawMline(&l, color);
1465 // AM_drawPlayers()
1467 // Draws the player arrow in single player,
1468 // or all the player arrows in a netgame.
1470 // Passed nothing, returns nothing
1472 void AM_drawPlayers(void)
1474 int i;
1476 if (!netgame)
1478 if (ddt_cheating)
1479 AM_drawLineCharacter
1481 cheat_player_arrow,
1482 NUMCHEATPLYRLINES,
1484 plr->mo->angle,
1485 mapcolor_sngl, //jff color
1486 plr->mo->x,
1487 plr->mo->y
1489 else
1490 AM_drawLineCharacter
1492 player_arrow,
1493 NUMPLYRLINES,
1495 plr->mo->angle,
1496 mapcolor_sngl, //jff color
1497 plr->mo->x,
1498 plr->mo->y);
1499 return;
1502 for (i=0;i<MAXPLAYERS;i++) {
1503 player_t* p = &players[i];
1505 if ( (deathmatch && !singledemo) && p != plr)
1506 continue;
1508 if (playeringame[i]) {
1509 fixed_t x = p->mo->x, y = p->mo->y;
1510 if (automapmode & am_rotate)
1511 AM_rotate(&x, &y, ANG90-plr->mo->angle, plr->mo->x, plr->mo->y);
1513 AM_drawLineCharacter (player_arrow, NUMPLYRLINES, 0, p->mo->angle,
1514 p->powers[pw_invisibility] ? 246 /* *close* to black */
1515 : mapcolor_plyr[i], //jff 1/6/98 use default color
1516 x, y);
1522 // AM_drawThings()
1524 // Draws the things on the automap in double IDDT cheat mode
1526 // Passed colors and colorrange, no longer used
1527 // Returns nothing
1529 void AM_drawThings
1530 ( int colors,
1531 int colorrange)
1533 (void)colors;
1534 (void)colorrange;
1535 int i;
1536 mobj_t* t;
1538 // for all sectors
1539 for (i=0;i<numsectors;i++)
1541 t = sectors[i].thinglist;
1542 while (t) // for all things in that sector
1544 fixed_t x = t->x, y = t->y;
1546 if (automapmode & am_rotate)
1547 AM_rotate(&x, &y, ANG90-plr->mo->angle, plr->mo->x, plr->mo->y);
1549 //jff 1/5/98 case over doomednum of thing being drawn
1550 if (mapcolor_rkey || mapcolor_ykey || mapcolor_bkey)
1552 switch(t->info->doomednum)
1554 //jff 1/5/98 treat keys special
1555 case 38: case 13: //jff red key
1556 AM_drawLineCharacter
1558 cross_mark,
1559 NUMCROSSMARKLINES,
1560 16<<FRACBITS,
1561 t->angle,
1562 mapcolor_rkey!=-1? mapcolor_rkey : mapcolor_sprt,
1563 x, y
1565 t = t->snext;
1566 continue;
1567 case 39: case 6: //jff yellow key
1568 AM_drawLineCharacter
1570 cross_mark,
1571 NUMCROSSMARKLINES,
1572 16<<FRACBITS,
1573 t->angle,
1574 mapcolor_ykey!=-1? mapcolor_ykey : mapcolor_sprt,
1575 x, y
1577 t = t->snext;
1578 continue;
1579 case 40: case 5: //jff blue key
1580 AM_drawLineCharacter
1582 cross_mark,
1583 NUMCROSSMARKLINES,
1584 16<<FRACBITS,
1585 t->angle,
1586 mapcolor_bkey!=-1? mapcolor_bkey : mapcolor_sprt,
1587 x, y
1589 t = t->snext;
1590 continue;
1591 default:
1592 break;
1595 //jff 1/5/98 end added code for keys
1596 //jff previously entire code
1597 AM_drawLineCharacter
1599 thintriangle_guy,
1600 NUMTHINTRIANGLEGUYLINES,
1601 16<<FRACBITS,
1602 t->angle,
1603 t->flags & MF_FRIEND && !t->player ? mapcolor_frnd :
1604 /* bbm 2/28/03 Show countable items in yellow. */
1605 t->flags & MF_COUNTITEM ? mapcolor_item : mapcolor_sprt,
1606 x, y
1608 t = t->snext;
1614 // AM_drawMarks()
1616 // Draw the marked locations on the automap
1618 // Passed nothing, returns nothing
1620 // killough 2/22/98:
1621 // Rewrote AM_drawMarks(). Removed limit on marks.
1623 void AM_drawMarks(void)
1625 int i;
1626 for (i=0;i<markpointnum;i++) // killough 2/22/98: remove automap mark limit
1627 if (markpoints[i].x != -1)
1629 int w = 5;
1630 int h = 6;
1631 int fx = markpoints[i].x;
1632 int fy = markpoints[i].y;
1633 int j = i;
1635 if (automapmode & am_rotate)
1636 AM_rotate(&fx, &fy, ANG90-plr->mo->angle, plr->mo->x, plr->mo->y);
1638 fx = CXMTOF(fx); fy = CYMTOF(fy);
1642 int d = j % 10;
1643 if (d==1) // killough 2/22/98: less spacing for '1'
1644 fx++;
1646 if (fx >= f_x && fx < f_w - w && fy >= f_y && fy < f_h - h) {
1647 // cph - construct patch name and draw marker
1648 char namebuf[] = { 'A', 'M', 'M', 'N', 'U', 'M', '0'+d, 0 };
1650 V_DrawNamePatch(fx, fy, FB, namebuf, CR_DEFAULT, VPT_NONE);
1652 fx -= w-1; // killough 2/22/98: 1 space backwards
1653 j /= 10;
1655 while (j>0);
1660 // AM_drawCrosshair()
1662 // Draw the single point crosshair representing map center
1664 // Passed the color to draw the pixel with
1665 // Returns nothing
1667 // CPhipps - made static inline, and use the general pixel plotter function
1669 inline static void AM_drawCrosshair(int color)
1671 // single point for now
1672 V_PlotPixel(FB, f_w/2, f_h/2, (byte)color);
1676 // AM_Drawer()
1678 // Draws the entire automap
1680 // Passed nothing, returns nothing
1682 void AM_Drawer (void)
1684 // CPhipps - all automap modes put into one enum
1685 if (!(automapmode & am_active)) return;
1687 if (!(automapmode & am_overlay)) // cph - If not overlay mode, clear background for the automap
1688 V_FillRect(FB, f_x, f_y, f_w, f_h, (byte)mapcolor_back); //jff 1/5/98 background default color
1689 if (automapmode & am_grid)
1690 AM_drawGrid(mapcolor_grid); //jff 1/7/98 grid default color
1691 AM_drawWalls();
1692 AM_drawPlayers();
1693 if (ddt_cheating==2)
1694 AM_drawThings(mapcolor_sprt, 0); //jff 1/5/98 default double IDDT sprite
1695 AM_drawCrosshair(mapcolor_hair); //jff 1/7/98 default crosshair color
1697 AM_drawMarks();
1699 V_MarkRect(f_x, f_y, f_w, f_h);