📄 am_map.c
字号:
m_x = plr->mo->x - m_w/2; m_y = plr->mo->y - m_h/2; AM_changeWindowLoc(); // for saving & restoring old_m_x = m_x; old_m_y = m_y; old_m_w = m_w; old_m_h = m_h; if( gamemode == heretic ) { REDS = 12*8; REDRANGE = 1; BLUES = (256-4*16+8); BLUERANGE = 1; GREENS = 224; GREENRANGE = 1; GRAYS = (5*8); GRAYSRANGE = 1; BROWNS = (14*8); BROWNRANGE = 1; YELLOWS = 10*8; YELLOWRANGE= 1; DBLACK = 0; DWHITE = 4*8; BLUEKEYCOLOR = 197; YELLOWKEYCOLOR = 144; REDKEYCOLOR = 220; // green } else { BLUEKEYCOLOR = 200; YELLOWKEYCOLOR = 231; REDKEYCOLOR = 176; } // inform the status bar of the change ST_Responder(&st_notify);}static byte *maplump; // pointer to the raw data for the automap background.//////static void AM_loadPics(void){ int i; char namebuf[9]; for (i=0;i<10;i++) { sprintf(namebuf, "AMMNUM%d", i); marknums[i] = W_CachePatchName(namebuf, PU_STATIC); } if( W_CheckNumForName("AUTOPAGE")>=0 ) maplump = W_CacheLumpName("AUTOPAGE", PU_STATIC); else maplump = NULL;}static void AM_unloadPics(void){ int i; //faB: GlidePatch_t are always purgeable if (rendermode == render_soft) { for (i=0;i<10;i++) Z_ChangeTag(marknums[i], PU_CACHE); if( maplump ) Z_ChangeTag(maplump, PU_CACHE); }}void AM_clearMarks(void){ int i; for (i=0;i<AM_NUMMARKPOINTS;i++) markpoints[i].x = -1; // means empty markpointnum = 0;}//// should be called at the start of every level// right now, i figure it out myself//void AM_LevelInit(void){ leveljuststarted = 0; f_x = f_y = 0; f_w = vid.width; f_h = vid.height - stbarheight; if (rendermode == render_soft) AM_drawFline = AM_drawFline_soft;#ifdef HWRENDER // not win32 only 19990829 by Kin else AM_drawFline = (AMDRAWFLINEFUNC) HWR_drawAMline;#endif AM_clearMarks(); AM_findMinMaxBoundaries(); scale_mtof = FixedDiv(min_scale_mtof, (int) (0.7*FRACUNIT)); if (scale_mtof > max_scale_mtof) scale_mtof = min_scale_mtof; scale_ftom = FixedDiv(FRACUNIT, scale_mtof);}//////void AM_Stop(void){ static event_t st_notify = { 0, ev_keyup, AM_MSGEXITED }; AM_unloadPics(); automapactive = false; ST_Responder(&st_notify); stopped = true;}//////void AM_Start (void){ static int lastlevel = -1, lastepisode = -1; if (!stopped) AM_Stop(); stopped = false; if (lastlevel != gamemap || lastepisode != gameepisode || am_recalc) //added:05-02-98:screen size changed { am_recalc = false; AM_LevelInit(); lastlevel = gamemap; lastepisode = gameepisode; } AM_initVariables(); AM_loadPics();}//// set the window scale to the maximum size//void AM_minOutWindowScale(void){ scale_mtof = min_scale_mtof; scale_ftom = FixedDiv(FRACUNIT, scale_mtof); AM_activateNewScale();}//// set the window scale to the minimum size//void AM_maxOutWindowScale(void){ scale_mtof = max_scale_mtof; scale_ftom = FixedDiv(FRACUNIT, scale_mtof); AM_activateNewScale();}//// Handle events (user inputs) in automap mode//boolean AM_Responder ( event_t* ev ){ int rc; static int cheatstate=0; static char buffer[20]; rc = false; if (!automapactive) { if (ev->type == ev_keydown && ev->data1 == AM_STARTKEY) { //faB: prevent alt-tab in win32 version to activate automap just before minimizing the app // doesn't do any harm to the DOS version if (!gamekeydown[KEY_ALT]) { bigstate = 0; //added:24-01-98:toggle off large view AM_Start (); viewactive = false; rc = true; } } } else if (ev->type == ev_keydown) { rc = true; switch(ev->data1) { case AM_PANRIGHTKEY: // pan right if (!followplayer) m_paninc.x = FTOM(F_PANINC); else rc = false; break; case AM_PANLEFTKEY: // pan left if (!followplayer) m_paninc.x = -FTOM(F_PANINC); else rc = false; break; case AM_PANUPKEY: // pan up if (!followplayer) m_paninc.y = FTOM(F_PANINC); else rc = false; break; case AM_PANDOWNKEY: // pan down if (!followplayer) m_paninc.y = -FTOM(F_PANINC); else rc = false; break; case AM_ZOOMOUTKEY: // zoom out mtof_zoommul = M_ZOOMOUT; ftom_zoommul = M_ZOOMIN; break; case AM_ZOOMINKEY: // zoom in mtof_zoommul = M_ZOOMIN; ftom_zoommul = M_ZOOMOUT; break; case AM_ENDKEY: viewactive = true; AM_Stop (); break; case AM_GOBIGKEY: bigstate = !bigstate; if (bigstate) { AM_saveScaleAndLoc(); AM_minOutWindowScale(); } else AM_restoreScaleAndLoc(); break; case AM_FOLLOWKEY: followplayer = !followplayer; f_oldloc.x = MAXINT; plr->message = followplayer ? AMSTR_FOLLOWON : AMSTR_FOLLOWOFF; break; case AM_GRIDKEY: grid = !grid; plr->message = grid ? AMSTR_GRIDON : AMSTR_GRIDOFF; break; case AM_MARKKEY: sprintf(buffer, "%s %d", AMSTR_MARKEDSPOT, markpointnum); plr->message = buffer; AM_addMark(); break; case AM_CLEARMARKKEY: AM_clearMarks(); plr->message = AMSTR_MARKSCLEARED; break; default: cheatstate=0; rc = false; } } else if (ev->type == ev_keyup) { rc = false; switch (ev->data1) { case AM_PANRIGHTKEY: if (!followplayer) m_paninc.x = 0; break; case AM_PANLEFTKEY: if (!followplayer) m_paninc.x = 0; break; case AM_PANUPKEY: if (!followplayer) m_paninc.y = 0; break; case AM_PANDOWNKEY: if (!followplayer) m_paninc.y = 0; break; case AM_ZOOMOUTKEY: case AM_ZOOMINKEY: mtof_zoommul = FRACUNIT; ftom_zoommul = FRACUNIT; break; } } return rc;}//// Zooming//void AM_changeWindowScale(void){ // Change the scaling multipliers scale_mtof = FixedMul(scale_mtof, mtof_zoommul); scale_ftom = FixedDiv(FRACUNIT, scale_mtof); if (scale_mtof < min_scale_mtof) AM_minOutWindowScale(); else if (scale_mtof > max_scale_mtof) AM_maxOutWindowScale(); else AM_activateNewScale();}//////void AM_doFollowPlayer(void){ if (f_oldloc.x != plr->mo->x || f_oldloc.y != plr->mo->y) { m_x = FTOM(MTOF(plr->mo->x)) - m_w/2; m_y = FTOM(MTOF(plr->mo->y)) - m_h/2; m_x2 = m_x + m_w; m_y2 = m_y + m_h; f_oldloc.x = plr->mo->x; f_oldloc.y = plr->mo->y; // m_x = FTOM(MTOF(plr->mo->x - m_w/2)); // m_y = FTOM(MTOF(plr->mo->y - m_h/2)); // m_x = plr->mo->x - m_w/2; // m_y = plr->mo->y - m_h/2; }}//////void AM_updateLightLev(void){ static int nexttic = 0; //static int litelevels[] = { 0, 3, 5, 6, 6, 7, 7, 7 }; static int litelevels[] = { 0, 4, 7, 10, 12, 14, 15, 15 }; static int litelevelscnt = 0; // Change light level if (amclock>nexttic) { lightlev = litelevels[litelevelscnt++]; if (litelevelscnt == sizeof(litelevels)/sizeof(int)) litelevelscnt = 0; nexttic = amclock + 6 - (amclock % 6); }}//// Updates on Game Tick//void AM_Ticker (void){ if (!automapactive) return; amclock++; if (followplayer) AM_doFollowPlayer(); // Change the zoom if necessary if (ftom_zoommul != FRACUNIT) AM_changeWindowScale(); // Change x,y location if (m_paninc.x || m_paninc.y) AM_changeWindowLoc(); // Update light level // AM_updateLightLev();}//// Clear automap frame buffer.//void AM_clearFB(int color){#ifdef HWRENDER if (rendermode != render_soft) { HWR_clearAutomap (); return; }#endif if( !maplump ) { memset(fb, color, f_w*f_h*vid.bpp); } else { int i,y; int dmapx; int dmapy; static int mapxstart; static int mapystart; byte *dest = screens[0],*src; #define MAPLUMPHEIGHT (200-SBARHEIGHT) if(followplayer) { static vertex_t oldplr; dmapx = (MTOF(plr->mo->x)-MTOF(oldplr.x)); //fixed point dmapy = (MTOF(oldplr.y)-MTOF(plr->mo->y)); oldplr.x = plr->mo->x; oldplr.y = plr->mo->y; mapxstart += dmapx>>1; mapystart += dmapy>>1; while(mapxstart >= 320) mapxstart -= 320; while(mapxstart < 0) mapxstart += 320; while(mapystart >= MAPLUMPHEIGHT) mapystart -= MAPLUMPHEIGHT; while(mapystart < 0) mapystart += MAPLUMPHEIGHT; } else { mapxstart += (MTOF(m_paninc.x)>>1); mapystart -= (MTOF(m_paninc.y)>>1); if( mapxstart >= 320 ) mapxstart -= 320; if( mapxstart < 0 ) mapxstart += 320; if( mapystart >= MAPLUMPHEIGHT ) mapystart -= MAPLUMPHEIGHT; if( mapystart < 0 ) mapystart += MAPLUMPHEIGHT; } //blit the automap background to the screen. for (y=0 ; y<f_h ; y++) { src = maplump + mapxstart + (y+mapystart)*320; for (i=0 ; i<320*vid.dupx ; i++) { while( src>maplump+320*MAPLUMPHEIGHT ) src-=320*MAPLUMPHEIGHT; *dest++ = *src++; } dest += vid.width-vid.dupx*320; } }}//// Automap clipping of lines.//// Based on Cohen-Sutherland clipping algorithm but with a slightly// faster reject and precalculated slopes. If the speed is needed,// use a hash algorithm to handle the common cases.//boolean AM_clipMline ( mline_t* ml, fline_t* fl ){ enum { LEFT =1, RIGHT =2, BOTTOM =4, TOP =8 }; register int outcode1 = 0; register int outcode2 = 0; register int outside; fpoint_t tmp; int dx; int dy;#define DOOUTCODE(oc, mx, my) \ (oc) = 0; \ if ((my) < 0) (oc) |= TOP; \ else if ((my) >= f_h) (oc) |= BOTTOM; \ if ((mx) < 0) (oc) |= LEFT; \ else if ((mx) >= f_w) (oc) |= RIGHT; // do trivial rejects and outcodes if (ml->a.y > m_y2) outcode1 = TOP;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -