From bd9abf33adb3e3cf4df31b7e3c507a02f18346fe Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sat, 24 Jun 2017 09:20:37 +0000 Subject: [PATCH] scale(a, b, 1<<##) --> mulscale##(a, b) git-svn-id: https://svn.eduke32.com/eduke32@6255 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/menus.cpp | 34 ++++++++++++++++---------------- source/duke3d/src/menus.h | 14 ++++++------- source/duke3d/src/screentext.cpp | 22 ++++++++++----------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index 10e8aeecd..4c584cb30 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -4230,8 +4230,8 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current const int32_t z = entry->font->cursorScale; Menu_ShadePal(object->font, status, &s, &p); - const int32_t slidebarwidth = scale(tilesiz[SLIDEBAR].x<<16, z, 65536); - const int32_t slidebarheight = scale(tilesiz[SLIDEBAR].y<<16, z, 65536); + const int32_t slidebarwidth = mulscale16(tilesiz[SLIDEBAR].x<<16, z); + const int32_t slidebarheight = mulscale16(tilesiz[SLIDEBAR].y<<16, z); if (status & MT_XRight) x -= slidebarwidth; @@ -4243,9 +4243,9 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current rotatesprite_ybounds(slidebarx, slidebary, z, 0, SLIDEBAR, s, (entry->flags & (MEF_Disabled|MEF_LookDisabled)) ? 1 : 0, 2|8|16|ROTATESPRITE_FULL16, ydim_upper, ydim_lower); - const int32_t slideregionwidth = scale((tilesiz[SLIDEBAR].x-2-tilesiz[SLIDEBAR+1].x)<<16, z, 65536); + const int32_t slideregionwidth = mulscale16((tilesiz[SLIDEBAR].x-2-tilesiz[SLIDEBAR+1].x)<<16, z); const int32_t slidepointx = slidebarx + (1<<16) + scale(slideregionwidth, *object->variable - object->min, object->max - object->min); - const int32_t slidepointy = slidebary + scale((tilesiz[SLIDEBAR].y-tilesiz[SLIDEBAR+1].y)<<15, z, 65536); + const int32_t slidepointy = slidebary + mulscale16((tilesiz[SLIDEBAR].y-tilesiz[SLIDEBAR+1].y)<<15, z); rotatesprite_ybounds(slidepointx, slidepointy, z, 0, SLIDEBAR+1, s, (entry->flags & (MEF_Disabled|MEF_LookDisabled)) ? 1 : 0, 2|8|16|ROTATESPRITE_FULL16, ydim_upper, ydim_lower); @@ -4286,7 +4286,7 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current if (!m_mousecaught && (mousepressstate == Mouse_Pressed || mousepressstate == Mouse_Held)) { - const int32_t slidepointhalfwidth = scale((2+tilesiz[SLIDEBAR+1].x)<<15, z, 65536); + const int32_t slidepointhalfwidth = mulscale16((2+tilesiz[SLIDEBAR+1].x)<<15, z); const int32_t slideregionx = slidebarx + slidepointhalfwidth; menu->currentEntry = e; @@ -4325,8 +4325,8 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current const int32_t z = entry->font->cursorScale; Menu_ShadePal(object->font, status, &s, &p); - const int32_t slidebarwidth = scale(tilesiz[SLIDEBAR].x<<16, z, 65536); - const int32_t slidebarheight = scale(tilesiz[SLIDEBAR].y<<16, z, 65536); + const int32_t slidebarwidth = mulscale16(tilesiz[SLIDEBAR].x<<16, z); + const int32_t slidebarheight = mulscale16(tilesiz[SLIDEBAR].y<<16, z); if (status & MT_XRight) x -= slidebarwidth; @@ -4338,9 +4338,9 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current rotatesprite_ybounds(slidebarx, slidebary, z, 0, SLIDEBAR, s, (entry->flags & (MEF_Disabled|MEF_LookDisabled)) ? 1 : 0, 2|8|16|ROTATESPRITE_FULL16, ydim_upper, ydim_lower); - const int32_t slideregionwidth = scale((tilesiz[SLIDEBAR].x-2-tilesiz[SLIDEBAR+1].x)<<16, z, 65536); + const int32_t slideregionwidth = mulscale16((tilesiz[SLIDEBAR].x-2-tilesiz[SLIDEBAR+1].x)<<16, z); const int32_t slidepointx = slidebarx + (1<<16) + (int32_t)((float) slideregionwidth * (*object->variable - object->min) / (object->max - object->min)); - const int32_t slidepointy = slidebary + scale((tilesiz[SLIDEBAR].y-tilesiz[SLIDEBAR+1].y)<<15, z, 65536); + const int32_t slidepointy = slidebary + mulscale16((tilesiz[SLIDEBAR].y-tilesiz[SLIDEBAR+1].y)<<15, z); rotatesprite_ybounds(slidepointx, slidepointy, z, 0, SLIDEBAR+1, s, (entry->flags & (MEF_Disabled|MEF_LookDisabled)) ? 1 : 0, 2|8|16|ROTATESPRITE_FULL16, ydim_upper, ydim_lower); @@ -4381,7 +4381,7 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current if (!m_mousecaught && (mousepressstate == Mouse_Pressed || mousepressstate == Mouse_Held)) { - const int32_t slidepointhalfwidth = scale((2+tilesiz[SLIDEBAR+1].x)<<15, z, 65536); + const int32_t slidepointhalfwidth = mulscale16((2+tilesiz[SLIDEBAR+1].x)<<15, z); const int32_t slideregionx = slidebarx + slidepointhalfwidth; menu->currentEntry = e; @@ -4420,8 +4420,8 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current const int32_t z = entry->font->cursorScale; Menu_ShadePal(object->font, status, &s, &p); - const int32_t slidebarwidth = scale(tilesiz[SLIDEBAR].x<<16, z, 65536); - const int32_t slidebarheight = scale(tilesiz[SLIDEBAR].y<<16, z, 65536); + const int32_t slidebarwidth = mulscale16(tilesiz[SLIDEBAR].x<<16, z); + const int32_t slidebarheight = mulscale16(tilesiz[SLIDEBAR].y<<16, z); if (status & MT_XRight) x -= slidebarwidth; @@ -4433,9 +4433,9 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current rotatesprite_ybounds(slidebarx, slidebary, z, 0, SLIDEBAR, s, (entry->flags & (MEF_Disabled|MEF_LookDisabled)) ? 1 : 0, 2|8|16|ROTATESPRITE_FULL16, ydim_upper, ydim_lower); - const int32_t slideregionwidth = scale((tilesiz[SLIDEBAR].x-2-tilesiz[SLIDEBAR+1].x)<<16, z, 65536); + const int32_t slideregionwidth = mulscale16((tilesiz[SLIDEBAR].x-2-tilesiz[SLIDEBAR+1].x)<<16, z); const int32_t slidepointx = slidebarx + (1<<16) + (int32_t)((double) slideregionwidth * (*object->variable - object->min) / (object->max - object->min)); - const int32_t slidepointy = slidebary + scale((tilesiz[SLIDEBAR].y-tilesiz[SLIDEBAR+1].y)<<15, z, 65536); + const int32_t slidepointy = slidebary + mulscale16((tilesiz[SLIDEBAR].y-tilesiz[SLIDEBAR+1].y)<<15, z); rotatesprite_ybounds(slidepointx, slidepointy, z, 0, SLIDEBAR+1, s, (entry->flags & (MEF_Disabled|MEF_LookDisabled)) ? 1 : 0, 2|8|16|ROTATESPRITE_FULL16, ydim_upper, ydim_lower); @@ -4476,7 +4476,7 @@ static int32_t M_RunMenu_Menu(Menu_t *cm, MenuMenu_t *menu, MenuEntry_t *current if (!m_mousecaught && (mousepressstate == Mouse_Pressed || mousepressstate == Mouse_Held)) { - const int32_t slidepointhalfwidth = scale((2+tilesiz[SLIDEBAR+1].x)<<15, z, 65536); + const int32_t slidepointhalfwidth = mulscale16((2+tilesiz[SLIDEBAR+1].x)<<15, z); const int32_t slideregionx = slidebarx + slidepointhalfwidth; menu->currentEntry = e; @@ -6133,8 +6133,8 @@ void M_DisplayMenus(void) { const int32_t screenwidth = scale(240<<16, xdim, ydim); - origin.x = scale(screenwidth, m_animation.in(&m_animation), 32768); - previousOrigin.x = scale(screenwidth, m_animation.out(&m_animation), 32768); + origin.x = mulscale15(screenwidth, m_animation.in(&m_animation)); + previousOrigin.x = mulscale15(screenwidth, m_animation.out(&m_animation)); ud.m_origin = previousOrigin; VM_OnEventWithReturn(EVENT_DISPLAYINACTIVEMENU, g_player[screenpeek].ps->i, screenpeek, m_animation.previous->menuID); diff --git a/source/duke3d/src/menus.h b/source/duke3d/src/menus.h index 91ef4ba32..91f436260 100644 --- a/source/duke3d/src/menus.h +++ b/source/duke3d/src/menus.h @@ -127,7 +127,7 @@ typedef struct MenuFont_t int8_t shade_deselected; // selected entries are mandated to glow uint8_t pal, pal_disabled; - int32_t get_yline() const { return scale(emptychar.y, zoom, 65536); } + int32_t get_yline() const { return mulscale16(emptychar.y, zoom); } } MenuFont_t; @@ -186,8 +186,8 @@ typedef struct MenuOptionSet_t // appearance uint8_t features; // bit 1 = disable left/right arrows, bit 2 = disable list - int32_t getMarginBottom() const { return scale(entryFormat->marginBottom, font->zoom, 65536); } - int32_t getIndent() const { return scale(entryFormat->indent, font->zoom, 65536); } + int32_t getMarginBottom() const { return mulscale16(entryFormat->marginBottom, font->zoom); } + int32_t getIndent() const { return mulscale16(entryFormat->indent, font->zoom); } } MenuOptionSet_t; typedef struct MenuOption_t { @@ -322,11 +322,11 @@ typedef struct MenuEntry_t int32_t flags; int32_t ytop, ybottom; - int32_t getMarginBottom() const { return scale(format->marginBottom, font->zoom, 65536); } - int32_t getIndent() const { return scale(format->indent, font->zoom, 65536); } + int32_t getMarginBottom() const { return mulscale16(format->marginBottom, font->zoom); } + int32_t getIndent() const { return mulscale16(format->indent, font->zoom); } int32_t getHeight() const { - return type == Spacer ? scale(((MenuSpacer_t *)entry)->height, font->zoom, 65536) : font->get_yline(); + return type == Spacer ? mulscale16(((MenuSpacer_t *)entry)->height, font->zoom) : font->get_yline(); } } MenuEntry_t; @@ -414,7 +414,7 @@ typedef struct MenuFileSelect_t fnlist_t fnlist; int32_t currentList; - int32_t getMarginBottom(size_t index) const { return scale(marginBottom[index], font[index]->zoom, 65536); } + int32_t getMarginBottom(size_t index) const { return mulscale16(marginBottom[index], font[index]->zoom); } } MenuFileSelect_t; typedef struct Menu_t diff --git a/source/duke3d/src/screentext.cpp b/source/duke3d/src/screentext.cpp index 27ca4cb9d..b50798531 100644 --- a/source/duke3d/src/screentext.cpp +++ b/source/duke3d/src/screentext.cpp @@ -187,10 +187,10 @@ vec2_t G_ScreenTextSize(const int32_t font, // coordinate values should be shifted left by 16 // handle zooming where applicable - xspace = scale(xspace, z, 65536); - yline = scale(yline, z, 65536); - xbetween = scale(xbetween, z, 65536); - ybetween = scale(ybetween, z, 65536); + xspace = mulscale16(xspace, z); + yline = mulscale16(yline, z); + xbetween = mulscale16(xbetween, z); + ybetween = mulscale16(ybetween, z); // size/width/height/spacing/offset values should be multiplied or scaled by $z, zoom (since 100% is 65536, the same as 1<<16) // loop through the string @@ -449,8 +449,8 @@ vec2_t G_ScreenTextSize(const int32_t font, void G_AddCoordsFromRotation(vec2_t *coords, const vec2_t *unitDirection, const int32_t magnitude) { - coords->x += scale(magnitude, unitDirection->x, 16384); - coords->y += scale(magnitude, unitDirection->y, 16384); + coords->x += mulscale14(magnitude, unitDirection->x); + coords->y += mulscale14(magnitude, unitDirection->y); } // screentext @@ -505,10 +505,10 @@ vec2_t G_ScreenText(const int32_t font, size = G_ScreenTextSize(font, x, y, z, blockangle, str, o | ROTATESPRITE_FULL16, xspace, yline, (f & TEXT_XJUSTIFY) ? 0 : xbetween, (f & TEXT_YJUSTIFY) ? 0 : ybetween, f & ~(TEXT_XJUSTIFY|TEXT_YJUSTIFY), x1, y1, x2, y2); // handle zooming where applicable - xspace = scale(xspace, z, 65536); - yline = scale(yline, z, 65536); - xbetween = scale(xbetween, z, 65536); - ybetween = scale(ybetween, z, 65536); + xspace = mulscale16(xspace, z); + yline = mulscale16(yline, z); + xbetween = mulscale16(xbetween, z); + ybetween = mulscale16(ybetween, z); // size/width/height/spacing/offset values should be multiplied or scaled by $z, zoom (since 100% is 65536, the same as 1<<16) // alignment @@ -863,7 +863,7 @@ vec2_t G_ScreenTextShadow(int32_t sx, int32_t sy, ybetween <<= 16; } - G_ScreenText(font, x + scale(sx, z, 65536), y + scale(sy, z, 65536), z, blockangle, charangle, str, 127, 4, o|ROTATESPRITE_FULL16, alpha, xspace, yline, xbetween, ybetween, f, x1, y1, x2, y2); + G_ScreenText(font, x + mulscale16(sx, z), y + mulscale16(sy, z), z, blockangle, charangle, str, 127, 4, o|ROTATESPRITE_FULL16, alpha, xspace, yline, xbetween, ybetween, f, x1, y1, x2, y2); size = G_ScreenText(font, x, y, z, blockangle, charangle, str, shade, pal, o|ROTATESPRITE_FULL16, alpha, xspace, yline, xbetween, ybetween, f, x1, y1, x2, y2);