summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon <simon@hardwired.org.uk>2010-08-26 11:20:16 (GMT)
committer Simon <simon@hardwired.org.uk>2010-08-26 11:20:16 (GMT)
commit72a1d17fe42ccc74ac25328dcd272b7a2bf6856c (patch)
treea064555f1694f7c763eb3f42c56fe92ea016713b
parent5751fea35f31640fddfaea1459503e366ae39729 (diff)
downloadpowder-72a1d17fe42ccc74ac25328dcd272b7a2bf6856c.zip
powder-72a1d17fe42ccc74ac25328dcd272b7a2bf6856c.tar.gz
This build works, but still a work in progress
-rw-r--r--defines.h4
-rw-r--r--graphics.c8
-rw-r--r--misc.c41
-rw-r--r--misc.h23
-rw-r--r--powder.c13
-rwxr-xr-xversion.h4
6 files changed, 67 insertions, 26 deletions
diff --git a/defines.h b/defines.h
index b08407f..5b5daaa 100644
--- a/defines.h
+++ b/defines.h
@@ -5,11 +5,7 @@
#undef PLOSS
-#ifdef MENUV3
#define MENUSIZE 40
-#else
-#define MENUSIZE 20
-#endif
#define BARSIZE 14
#define XRES 612
#define YRES 384
diff --git a/graphics.c b/graphics.c
index 5874116..15f50c6 100644
--- a/graphics.c
+++ b/graphics.c
@@ -3,7 +3,7 @@
#include "powder.h"
#include "graphics.h"
#include "font.h"
-#include "utils.h"
+#include "misc.h"
#include <math.h>
#include <SDL/SDL.h>
@@ -716,9 +716,6 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
void draw_menu(pixel *vid_buf, int i, int hover)
{
-
- //drawtext(vid_buf, XRES+1, /*(12*i)+2*/((YRES/SC_TOTAL)*i)+((YRES/SC_TOTAL)/2), msections[i].icon, 255, 255, 255, 255);
-#ifdef MENUV3
drawrect(vid_buf, XRES-2, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255);
if(hover==i)
{
@@ -729,9 +726,6 @@ void draw_menu(pixel *vid_buf, int i, int hover)
{
drawtext(vid_buf, XRES+1, (i*16)+YRES+MENUSIZE-14-(SC_TOTAL*16), msections[i].icon, 255, 255, 255, 255);
}
-#else
- drawtext(vid_buf, XRES+1, (i*16)+YRES+MENUSIZE-14-(SC_TOTAL*16), msections[i].icon, 255, 255, 255, 255);
-#endif
}
#ifdef WIN32
diff --git a/misc.c b/misc.c
new file mode 100644
index 0000000..fe50b32
--- /dev/null
+++ b/misc.c
@@ -0,0 +1,41 @@
+#include "misc.h"
+
+//Signum function
+#ifdef WIN32
+_inline int sign(float i)
+#else
+inline int sign(float i)
+#endif
+{
+ if (i<0)
+ return -1;
+ if (i>0)
+ return 1;
+ return 0;
+}
+
+#ifdef WIN32
+_inline unsigned clamp_flt(float f, float min, float max)
+#else
+inline unsigned clamp_flt(float f, float min, float max)
+#endif
+{
+ if(f<min)
+ return 0;
+ if(f>max)
+ return 255;
+ return (int)(255.0f*(f-min)/(max-min));
+}
+
+#ifdef WIN32
+_inline float restrict_flt(float f, float min, float max)
+#else
+inline float restrict_flt(float f, float min, float max)
+#endif
+{
+ if(f<min)
+ return min;
+ if(f>max)
+ return max;
+ return f;
+} \ No newline at end of file
diff --git a/misc.h b/misc.h
new file mode 100644
index 0000000..a42396d
--- /dev/null
+++ b/misc.h
@@ -0,0 +1,23 @@
+#ifndef UTILS_H
+#define UTILS_H
+
+//Signum function
+#ifdef WIN32
+extern _inline int sign(float i);
+#else
+extern inline int sign(float i);
+#endif
+
+#ifdef WIN32
+extern _inline unsigned clamp_flt(float f, float min, float max);
+#else
+extern inline unsigned clamp_flt(float f, float min, float max);
+#endif
+
+#ifdef WIN32
+extern _inline float restrict_flt(float f, float min, float max);
+#else
+extern inline float restrict_flt(float f, float min, float max);
+#endif
+
+#endif \ No newline at end of file
diff --git a/powder.c b/powder.c
index c0ff76d..b166535 100644
--- a/powder.c
+++ b/powder.c
@@ -37,7 +37,7 @@
#include <unistd.h>
#endif
-#include "utils.h"
+#include "misc.h"
#include "font.h"
#include "defines.h"
#include "powder.h"
@@ -8619,15 +8619,7 @@ int main(int argc, char *argv[])
{
draw_menu(vid_buf, i, active_menu);
}
-#ifndef MENUV3
- for(i=0; i<SC_TOTAL; i++)
- {
- if(!b&&x>=sdl_scale*(XRES+1) && x<sdl_scale*(XRES+BARSIZE-1) &&y>= sdl_scale*(((YRES/SC_TOTAL)*i)+((YRES/SC_TOTAL)/2)-2) && y<sdl_scale*(((YRES/SC_TOTAL)*i)+((YRES/SC_TOTAL)/2)+12))
- {
- menu_ui(vid_buf, i, &sl, &sr);
- }
- }
-#else
+
for(i=0; i<SC_TOTAL; i++)
{
if(!b&&x>=sdl_scale*(XRES-2) && x<sdl_scale*(XRES+BARSIZE-1) &&y>= sdl_scale*((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)) && y<sdl_scale*((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)+15))
@@ -8636,7 +8628,6 @@ int main(int argc, char *argv[])
}
}
menu_ui_v3(vid_buf, active_menu, &sl, &sr, b, bq, x, y);
-#endif
if(zoom_en && x>=sdl_scale*zoom_wx && y>=sdl_scale*zoom_wy
&& x<sdl_scale*(zoom_wx+ZFACTOR*ZSIZE)
diff --git a/version.h b/version.h
index 0acf9d0..4f37911 100755
--- a/version.h
+++ b/version.h
@@ -24,8 +24,4 @@
#define MINOR_VERSION 3
#define IDENT_VERSION "S" //Change this if you're not Simon! It should be a single letter.
-#define MENUV3
-//#define BETA
-#define HEAT_ENABLE
-
#endif