diff --git a/src/am_map.c b/src/am_map.c index 51bd0072..4650cf32 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -291,10 +291,12 @@ static void AM_drawFline_Vanilla(fline_t* fl, int color); static void AM_drawFline_Smooth(fline_t* fl, int color); void (*AM_drawFline)(fline_t*, int) = AM_drawFline_Vanilla; -// [crispy] automap rotate mode needs these early on -boolean automaprotate = false; +// [crispy/Woof!] automap rotate mode and square aspect ratio need these early on +static boolean automaprotate = false; +static boolean automapsquareaspect = false; +#define ADJUST_ASPECT_RATIO (correct_aspect_ratio && automapsquareaspect) static void AM_rotate(int64_t *x, int64_t *y, angle_t a); -static void AM_rotatePoint(mpoint_t *pt); +static void AM_transformPoint(mpoint_t *pt); static mpoint_t mapcenter; static angle_t mapangle; @@ -1511,19 +1513,19 @@ static void AM_drawGrid(int color) // [crispy] moved here ml.a.y = m_y; ml.b.y = m_y+m_h; - if (automaprotate) + if (automaprotate || ADJUST_ASPECT_RATIO) { ml.a.y -= m_w / 2; ml.b.y += m_w / 2; - AM_rotatePoint(&ml.a); - AM_rotatePoint(&ml.b); } + AM_transformPoint(&ml.a); + AM_transformPoint(&ml.b); AM_drawMline(&ml, color); } // Figure out start of horizontal gridlines start = m_y; - if (automaprotate) + if (automaprotate || ADJUST_ASPECT_RATIO) { start -= m_w / 2; } @@ -1532,7 +1534,7 @@ static void AM_drawGrid(int color) start += // (MAPBLOCKUNITS<>FRACTOMAPBITS))%gridsize); end = m_y + m_h; - if (automaprotate) + if (automaprotate || ADJUST_ASPECT_RATIO) { end += m_w / 2; } @@ -1549,9 +1551,9 @@ static void AM_drawGrid(int color) { ml.a.x -= m_h / 2; ml.b.x += m_h / 2; - AM_rotatePoint(&ml.a); - AM_rotatePoint(&ml.b); } + AM_transformPoint(&ml.a); + AM_transformPoint(&ml.b); AM_drawMline(&ml, color); } } @@ -1644,11 +1646,8 @@ static void AM_drawWalls(void) l.a.y = lines[i].v1->y >> FRACTOMAPBITS; l.b.x = lines[i].v2->x >> FRACTOMAPBITS; l.b.y = lines[i].v2->y >> FRACTOMAPBITS; - if (automaprotate) - { - AM_rotatePoint(&l.a); - AM_rotatePoint(&l.b); - } + AM_transformPoint(&l.a); + AM_transformPoint(&l.b); // if line has been seen or IDDT has been used if (ddt_cheating || (lines[i].flags & ML_MAPPED)) { @@ -1877,26 +1876,36 @@ static void AM_rotate // [crispy] rotate point around map center // adapted from prboom-plus/src/am_map.c:898-920 -static void AM_rotatePoint(mpoint_t *pt) +// [Woof!] Also, scale y coordinate of point for square aspect ratio +static void AM_transformPoint(mpoint_t *pt) { - int64_t tmpx; - // [crispy] smooth automap rotation - angle_t smoothangle = followplayer ? ANG90 - viewangle : mapangle; + if (automaprotate) + { + int64_t tmpx; + // [crispy] smooth automap rotation + angle_t smoothangle = followplayer ? ANG90 - viewangle : mapangle; - pt->x -= mapcenter.x; - pt->y -= mapcenter.y; + pt->x -= mapcenter.x; + pt->y -= mapcenter.y; - smoothangle >>= ANGLETOFINESHIFT; + smoothangle >>= ANGLETOFINESHIFT; - tmpx = (int64_t)FixedMul(pt->x, finecosine[smoothangle]) - - (int64_t)FixedMul(pt->y, finesine[smoothangle]) - + mapcenter.x; + tmpx = (int64_t)FixedMul(pt->x, finecosine[smoothangle]) + - (int64_t)FixedMul(pt->y, finesine[smoothangle]) + + mapcenter.x; - pt->y = (int64_t)FixedMul(pt->x, finesine[smoothangle]) - + (int64_t)FixedMul(pt->y, finecosine[smoothangle]) - + mapcenter.y; + pt->y = (int64_t)FixedMul(pt->x, finesine[smoothangle]) + + (int64_t)FixedMul(pt->y, finecosine[smoothangle]) + + mapcenter.y; - pt->x = tmpx; + pt->x = tmpx; + } + if (ADJUST_ASPECT_RATIO) + { + int64_t diff = pt->y - mapcenter.y; + diff = 5 * diff / 6; + pt->y = mapcenter.y + diff; + } } // @@ -1940,6 +1949,9 @@ static void AM_drawLineCharacter if (angle) AM_rotate(&l.a.x, &l.a.y, angle); + if (ADJUST_ASPECT_RATIO) + l.a.y = 5 * l.a.y / 6; + l.a.x += x; l.a.y += y; @@ -1955,6 +1967,9 @@ static void AM_drawLineCharacter if (angle) AM_rotate(&l.b.x, &l.b.y, angle); + if (ADJUST_ASPECT_RATIO) + l.b.y = 5 * l.b.y / 6; + l.b.x += x; l.b.y += y; @@ -1995,10 +2010,7 @@ static void AM_drawPlayers(void) pt.x = plr->mo->x >> FRACTOMAPBITS; pt.y = plr->mo->y >> FRACTOMAPBITS; } - if (automaprotate) - { - AM_rotatePoint(&pt); - } + AM_transformPoint(&pt); if (ddt_cheating) AM_drawLineCharacter @@ -2055,9 +2067,9 @@ static void AM_drawPlayers(void) pt.y = p->mo->y >> FRACTOMAPBITS; } + AM_transformPoint(&pt); if (automaprotate) { - AM_rotatePoint(&pt); smoothangle = p->mo->angle; } else @@ -2118,10 +2130,7 @@ static void AM_drawThings pt.x = t->x >> FRACTOMAPBITS; pt.y = t->y >> FRACTOMAPBITS; } - if (automaprotate) - { - AM_rotatePoint(&pt); - } + AM_transformPoint(&pt); //jff 1/5/98 case over doomednum of thing being drawn if (mapcolor_rkey || mapcolor_ykey || mapcolor_bkey) @@ -2225,10 +2234,7 @@ static void AM_drawMarks(void) // [crispy] center marks around player pt.x = markpoints[i].x; pt.y = markpoints[i].y; - if (automaprotate) - { - AM_rotatePoint(&pt); - } + AM_transformPoint(&pt); fx = CXMTOF(pt.x); fy = CYMTOF(pt.y); @@ -2294,13 +2300,13 @@ void AM_Drawer (void) AM_changeWindowLoc(); } - // [crispy] required for AM_rotatePoint() - if (automaprotate) + // [crispy/Woof!] required for AM_transformPoint() + if (automaprotate || ADJUST_ASPECT_RATIO) { mapcenter.x = m_x + m_w / 2; mapcenter.y = m_y + m_h / 2; // [crispy] keep the map static if not following the player - if (followplayer) + if (automaprotate && followplayer) { mapangle = ANG90 - plr->mo->angle; } @@ -2421,6 +2427,9 @@ void AM_BindAutomapVariables(void) AM_PRESET_VANILLA, AM_PRESET_ZDOOM, ss_auto, wad_no, "Automap color preset (0 = Vanilla Doom; 1 = Crispy Doom; 2 = Boom; 3 = ZDoom)"); + M_BindBool("automapsquareaspect", &automapsquareaspect, NULL, false, ss_auto, wad_no, + "Use square aspect ratio in automap"); + #define BIND_CR(name, v, help) \ M_BindNum(#name, &name, NULL, (v), 0, 255, ss_none, wad_yes, help) diff --git a/src/doomstat.h b/src/doomstat.h index 51211d1b..5a2e18a1 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -242,7 +242,6 @@ typedef enum } overlay_t; extern overlay_t automapoverlay; -extern boolean automaprotate; #define automap_on (automapactive && !automapoverlay) #define automap_off (!automapactive || automapoverlay) diff --git a/src/mn_setup.c b/src/mn_setup.c index 5886b56f..15330438 100644 --- a/src/mn_setup.c +++ b/src/mn_setup.c @@ -2061,6 +2061,8 @@ static setup_menu_t auto_settings1[] = { {"Color Keyed Doors", S_CHOICE, H_X, M_SPC, {"map_keyed_door"}, .strings_id = str_automap_keyed_door}, + {"Square Aspect Ratio", S_ONOFF, H_X, M_SPC, {"automapsquareaspect"}}, + MI_RESET, MI_END