From 7f905cd9dc8dee8467a571f894f93da2bbefd924 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sun, 25 Feb 2018 12:43:19 +1100 Subject: [PATCH] Cleanup some math stuff --- Makefile.nx | 2 +- common/math.c | 7 +------ common/menu.c | 5 ++--- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Makefile.nx b/Makefile.nx index c765b15..933e98b 100644 --- a/Makefile.nx +++ b/Makefile.nx @@ -52,7 +52,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 ASFLAGS := -g $(ARCH) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -LIBS := -lnx +LIBS := -lnx -lm #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing diff --git a/common/math.c b/common/math.c index 23b86dc..67799b3 100644 --- a/common/math.c +++ b/common/math.c @@ -5,12 +5,7 @@ float approxSin(float x) { float ret; // always wrap input angle to -PI..PI - while (x<-3.14159265 || x>3.14159265) { - if (x<-3.14159265) - x += 6.28318531; - else if (x >3.14159265) - x -= 6.28318531; - } + x = fmod(x, M_PI*2.0)-M_PI; // compute sine if (x<0) diff --git a/common/menu.c b/common/menu.c index 704b75d..2accac3 100644 --- a/common/menu.c +++ b/common/menu.c @@ -68,12 +68,11 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) { int shadow_inset; color_t shadow_color; uint8_t shadow_alpha_base = 80; - float highlight_multiplier, highlight_mod; + float highlight_multiplier; int shadow_size = 4; if (is_active) { - highlight_mod = timer - 1.0 * (int)(timer / 1.0); - highlight_multiplier = fmax(0.0, fabs(highlight_mod - 0.5) / 0.5); + highlight_multiplier = fmax(0.0, fabs(fmod(timer, 1.0) - 0.5) / 0.5); border_color = MakeColor(themeCurrent.highlightColor.r + (255 - themeCurrent.highlightColor.r) * highlight_multiplier, themeCurrent.highlightColor.g + (255 - themeCurrent.highlightColor.g) * highlight_multiplier, themeCurrent.highlightColor.b + (255 - themeCurrent.highlightColor.b) * highlight_multiplier, 255); border_start_x = start_x-5; border_end_x = end_x+5;