scale(a, b, 1<<##) --> mulscale##(a, b)

git-svn-id: https://svn.eduke32.com/eduke32@6255 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-06-24 09:20:37 +00:00
parent 965e40bda7
commit bd9abf33ad
3 changed files with 35 additions and 35 deletions

View file

@ -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; const int32_t z = entry->font->cursorScale;
Menu_ShadePal(object->font, status, &s, &p); Menu_ShadePal(object->font, status, &s, &p);
const int32_t slidebarwidth = scale(tilesiz[SLIDEBAR].x<<16, z, 65536); const int32_t slidebarwidth = mulscale16(tilesiz[SLIDEBAR].x<<16, z);
const int32_t slidebarheight = scale(tilesiz[SLIDEBAR].y<<16, z, 65536); const int32_t slidebarheight = mulscale16(tilesiz[SLIDEBAR].y<<16, z);
if (status & MT_XRight) if (status & MT_XRight)
x -= slidebarwidth; 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); 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 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); 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)) 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; const int32_t slideregionx = slidebarx + slidepointhalfwidth;
menu->currentEntry = e; 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; const int32_t z = entry->font->cursorScale;
Menu_ShadePal(object->font, status, &s, &p); Menu_ShadePal(object->font, status, &s, &p);
const int32_t slidebarwidth = scale(tilesiz[SLIDEBAR].x<<16, z, 65536); const int32_t slidebarwidth = mulscale16(tilesiz[SLIDEBAR].x<<16, z);
const int32_t slidebarheight = scale(tilesiz[SLIDEBAR].y<<16, z, 65536); const int32_t slidebarheight = mulscale16(tilesiz[SLIDEBAR].y<<16, z);
if (status & MT_XRight) if (status & MT_XRight)
x -= slidebarwidth; 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); 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 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); 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)) 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; const int32_t slideregionx = slidebarx + slidepointhalfwidth;
menu->currentEntry = e; 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; const int32_t z = entry->font->cursorScale;
Menu_ShadePal(object->font, status, &s, &p); Menu_ShadePal(object->font, status, &s, &p);
const int32_t slidebarwidth = scale(tilesiz[SLIDEBAR].x<<16, z, 65536); const int32_t slidebarwidth = mulscale16(tilesiz[SLIDEBAR].x<<16, z);
const int32_t slidebarheight = scale(tilesiz[SLIDEBAR].y<<16, z, 65536); const int32_t slidebarheight = mulscale16(tilesiz[SLIDEBAR].y<<16, z);
if (status & MT_XRight) if (status & MT_XRight)
x -= slidebarwidth; 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); 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 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); 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)) 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; const int32_t slideregionx = slidebarx + slidepointhalfwidth;
menu->currentEntry = e; menu->currentEntry = e;
@ -6133,8 +6133,8 @@ void M_DisplayMenus(void)
{ {
const int32_t screenwidth = scale(240<<16, xdim, ydim); const int32_t screenwidth = scale(240<<16, xdim, ydim);
origin.x = scale(screenwidth, m_animation.in(&m_animation), 32768); origin.x = mulscale15(screenwidth, m_animation.in(&m_animation));
previousOrigin.x = scale(screenwidth, m_animation.out(&m_animation), 32768); previousOrigin.x = mulscale15(screenwidth, m_animation.out(&m_animation));
ud.m_origin = previousOrigin; ud.m_origin = previousOrigin;
VM_OnEventWithReturn(EVENT_DISPLAYINACTIVEMENU, g_player[screenpeek].ps->i, screenpeek, m_animation.previous->menuID); VM_OnEventWithReturn(EVENT_DISPLAYINACTIVEMENU, g_player[screenpeek].ps->i, screenpeek, m_animation.previous->menuID);

View file

@ -127,7 +127,7 @@ typedef struct MenuFont_t
int8_t shade_deselected; // selected entries are mandated to glow int8_t shade_deselected; // selected entries are mandated to glow
uint8_t pal, pal_disabled; 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; } MenuFont_t;
@ -186,8 +186,8 @@ typedef struct MenuOptionSet_t
// appearance // appearance
uint8_t features; // bit 1 = disable left/right arrows, bit 2 = disable list 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 getMarginBottom() const { return mulscale16(entryFormat->marginBottom, font->zoom); }
int32_t getIndent() const { return scale(entryFormat->indent, font->zoom, 65536); } int32_t getIndent() const { return mulscale16(entryFormat->indent, font->zoom); }
} MenuOptionSet_t; } MenuOptionSet_t;
typedef struct MenuOption_t typedef struct MenuOption_t
{ {
@ -322,11 +322,11 @@ typedef struct MenuEntry_t
int32_t flags; int32_t flags;
int32_t ytop, ybottom; int32_t ytop, ybottom;
int32_t getMarginBottom() const { return scale(format->marginBottom, font->zoom, 65536); } int32_t getMarginBottom() const { return mulscale16(format->marginBottom, font->zoom); }
int32_t getIndent() const { return scale(format->indent, font->zoom, 65536); } int32_t getIndent() const { return mulscale16(format->indent, font->zoom); }
int32_t getHeight() const 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; } MenuEntry_t;
@ -414,7 +414,7 @@ typedef struct MenuFileSelect_t
fnlist_t fnlist; fnlist_t fnlist;
int32_t currentList; 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; } MenuFileSelect_t;
typedef struct Menu_t typedef struct Menu_t

View file

@ -187,10 +187,10 @@ vec2_t G_ScreenTextSize(const int32_t font,
// coordinate values should be shifted left by 16 // coordinate values should be shifted left by 16
// handle zooming where applicable // handle zooming where applicable
xspace = scale(xspace, z, 65536); xspace = mulscale16(xspace, z);
yline = scale(yline, z, 65536); yline = mulscale16(yline, z);
xbetween = scale(xbetween, z, 65536); xbetween = mulscale16(xbetween, z);
ybetween = scale(ybetween, z, 65536); 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) // 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 // 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) void G_AddCoordsFromRotation(vec2_t *coords, const vec2_t *unitDirection, const int32_t magnitude)
{ {
coords->x += scale(magnitude, unitDirection->x, 16384); coords->x += mulscale14(magnitude, unitDirection->x);
coords->y += scale(magnitude, unitDirection->y, 16384); coords->y += mulscale14(magnitude, unitDirection->y);
} }
// screentext // 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); 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 // handle zooming where applicable
xspace = scale(xspace, z, 65536); xspace = mulscale16(xspace, z);
yline = scale(yline, z, 65536); yline = mulscale16(yline, z);
xbetween = scale(xbetween, z, 65536); xbetween = mulscale16(xbetween, z);
ybetween = scale(ybetween, z, 65536); 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) // size/width/height/spacing/offset values should be multiplied or scaled by $z, zoom (since 100% is 65536, the same as 1<<16)
// alignment // alignment
@ -863,7 +863,7 @@ vec2_t G_ScreenTextShadow(int32_t sx, int32_t sy,
ybetween <<= 16; 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); 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);