Skip to content

Commit

Permalink
- Replace calcSinTableValue() with game's native bsin() export.
Browse files Browse the repository at this point in the history
* Also repair light for Duke's `DrawCursor()` with a multiply and shift down to get the `bsin()` output up to 24 and not 21.33 etc
  • Loading branch information
mjr4077au committed Jul 26, 2021
1 parent ced8a83 commit 1685890
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
6 changes: 3 additions & 3 deletions wadsrc/static/zscript/games/duke/ui/menu.zs
Expand Up @@ -65,7 +65,7 @@ class DukeMenuDelegate : RazeMenuDelegate
String picname;
if (!right) picname= String.Format("SPINNINGNUKEICON%d", ((mclock >> 3) % frames));
else picname = String.Format("SPINNINGNUKEICON%d", frames - 1 - ((frames - 1 + (mclock >> 3)) % frames));
int light = 231 + (Raze.calcSinTableValue(mclock<<5) / 768.);
int light = 231 + ((Raze.bsin(mclock<<5) * 3) >> 11);
let pe = color(255, light, light, light);
Screen.DrawTexture(TexMan.CheckForTexture(picname), false, x, y, DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Color, pe, DTA_CenterOffsetRel, true);
}
Expand Down Expand Up @@ -137,7 +137,7 @@ class ListMenuItemDukeLogo : ListMenuItem
if (gameinfo.gametype & GAMEFLAG_PLUTOPAK)
{
int mclock = MSTime() * 120 / 1000;
int light = 223 + (Raze.calcSinTableValue(mclock<<4) / 512.);
int light = 223 + (Raze.bsin(mclock<<4) >> 9);
let pe = Color(255, light, light, light);
Screen.DrawTexture(TexMan.CheckForTexture("MENUPLUTOPAKSPRITE"), false, x + 100, 36, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_Color, pe, DTA_CenterOffsetRel, true);
}
Expand Down Expand Up @@ -176,7 +176,7 @@ class ListMenuItemDukeTextItem : ListMenuItemTextItem
if (selected)
{
int mclock = MSTime() * 120 / 1000;
int light = 231 + (Raze.calcSinTableValue(mclock<<5) / 512.);
int light = 231 + (Raze.bsin(mclock<<5) >> 9);
pe = Color(255, light, light, light);
}
else
Expand Down
2 changes: 1 addition & 1 deletion wadsrc/static/zscript/games/exhumed/ui/menu.zs
Expand Up @@ -101,7 +101,7 @@ class ListMenuItemExhumedTextItem : ListMenuItemTextItem
double y = mYpos + v.y / 2;

int shade;
if (selected) shade = Raze.CalcSinTableValue(MSTime() * 16 * 120 / 1000) >> 9;
if (selected) shade = Raze.bsin(MSTime() * 16 * 120 / 1000) >> 9;
else if (Selectable()) shade = 0;
else shade = 25;
let color = Raze.shadeToLight(shade);
Expand Down
5 changes: 0 additions & 5 deletions wadsrc/static/zscript/razebase.zs
Expand Up @@ -135,11 +135,6 @@ struct Raze
{
const kAngleMask = 0x7FF;
const BAngToDegree = 360. / 2048.;

static int calcSinTableValue(int ang)
{
return int(16384 * sin((360./2048) * ang));
}

native static Color shadeToLight(int shade);
native static String PlayerName(int i);
Expand Down

0 comments on commit 1685890

Please sign in to comment.