diff --git a/Aclock.c b/Aclock.c index a1947bc..68a0eb5 100644 --- a/Aclock.c +++ b/Aclock.c @@ -11,24 +11,31 @@ #include #include -// Copied math implementations from EDK2 source code -#include "math_private.h" #else #include #include #include - #include #include #endif +// GNU EFI does not include libm, so use precomputed values +#ifdef GNU_EFI + +int cosa[]={ 0, 105, 208, 309, 407, 500, 588, 669, 743, 809, 866, 914, 951, 978, 995,1000, 995, 978, 951, 914, 866, 809, 743, 669, 588, 500, 407, 309, 208, 105, 0,-105,-208,-309,-407,-500,-588,-669,-743,-809,-866,-914,-951,-978,-995,-1000,-995,-978,-951,-914,-866,-809,-743,-669,-588,-500,-407,-309,-208,-105 }; +int sina[]={ -1000,-995,-978,-951,-914,-866,-809,-743,-669,-588,-500,-407,-309,-208,-105, 0, 105, 208, 309, 407, 500, 588, 669, 743, 809, 866, 914, 951, 978, 995,1000, 995, 978, 951, 914, 866, 809, 743, 669, 588, 500, 407, 309, 208, 105, 0,-105,-208,-309,-407,-500,-588,-669,-743,-809,-866,-914,-951,-978,-995 }; + +#else + #ifndef M_PI #define M_PI 3.14159265358979323846 #endif +#endif + #define FontWH_Ratio 2 // Global variables @@ -40,8 +47,13 @@ void draw_circle(int hand_max, int sYcen, int sXcen){ char c; for(r=0;r<60;r++){ +#ifdef GNU_EFI + x=(cosa[r]*hand_max*FontWH_Ratio/1000)+sXcen; + y=(sina[r]*hand_max/1000)+sYcen; +#else x=cos(r*M_PI/180*6)*hand_max*FontWH_Ratio+sXcen; y=sin(r*M_PI/180*6)*hand_max+sYcen; +#endif switch (r) { case 0: case 5: @@ -72,14 +84,16 @@ void draw_circle(int hand_max, int sYcen, int sXcen){ void draw_hand(int minute, int hlenght, char c, int sXcen, int sYcen){ int x,y,n; - float r=(minute-15)*(M_PI/180)*6; for(n=1; nSetCursorPosition, 3, ConOut, x, y); #else + float r=(minute-15)*(M_PI/180)*6; + x=cos(r)*n*FontWH_Ratio+sXcen; + y=sin(r)*n+sYcen; ConOut->SetCursorPosition(ConOut, x, y); #endif Print(L"%c", c); diff --git a/Makefile b/Makefile index de67f02..145da71 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ ifeq ($(ARCH),arm) CFLAGS += -marm endif -OBJS = s_fabs.o s_copysign.o s_scalbn.o s_floor.o k_rem_pio2.o e_rem_pio2.o k_cos.o k_sin.o s_cos.o s_sin.o Aclock.o +OBJS = Aclock.o TARGET = aclock-efi-$(ARCH).efi EFIINC = /usr/include/efi diff --git a/binaries/aclock-efi-x86_64.efi b/binaries/aclock-efi-x86_64.efi index 14a6b84..57a363b 100755 Binary files a/binaries/aclock-efi-x86_64.efi and b/binaries/aclock-efi-x86_64.efi differ diff --git a/binaries/aclock-efi.iso b/binaries/aclock-efi.iso index ba989b6..1ba5c55 100644 Binary files a/binaries/aclock-efi.iso and b/binaries/aclock-efi.iso differ diff --git a/binaries/floppy.img b/binaries/floppy.img new file mode 100644 index 0000000..42ec128 Binary files /dev/null and b/binaries/floppy.img differ