diff --git a/src/Makefile b/src/Makefile index 35d7f405..6b0ebed1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -807,7 +807,7 @@ endif doc doxygen htmldoc check # This is the list of the objects we want to build. Dependancies are built by "make depend" automatically. -OBJS = main.o init.o graph.o $(APIOBJ) misc.o special.o \ +OBJS = main.o init.o graph.o $(APIOBJ) misc.o osdep.o special.o \ buttons.o palette.o help.o operatio.o pages.o \ readline.o engine.o filesel.o fileseltools.o \ op_c.o readini.o saveini.o \ diff --git a/src/buttons.c b/src/buttons.c index 7683215d..2cff705d 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -49,6 +49,7 @@ #include "struct.h" #include "global.h" #include "misc.h" +#include "osdep.h" #include "graph.h" #include "engine.h" #include "readline.h" diff --git a/src/engine.c b/src/engine.c index 27459a8d..b92af4ea 100644 --- a/src/engine.c +++ b/src/engine.c @@ -36,6 +36,7 @@ #include "global.h" #include "graph.h" #include "misc.h" +#include "osdep.h" #include "special.h" #include "buttons.h" #include "operatio.h" diff --git a/src/factory.c b/src/factory.c index 8a5e198e..06bc61a1 100644 --- a/src/factory.c +++ b/src/factory.c @@ -36,6 +36,7 @@ #include "graph.h" #include "io.h" // find_last_separator #include "misc.h" +#include "osdep.h" #include "pages.h" // Backup() #include "readline.h" #include "screen.h" diff --git a/src/graph.c b/src/graph.c index be87665c..2a183a37 100644 --- a/src/graph.c +++ b/src/graph.c @@ -39,6 +39,7 @@ #include "screen.h" #include "graph.h" #include "misc.h" +#include "osdep.h" #include "pxsimple.h" #include "pxtall.h" #include "pxwide.h" diff --git a/src/input.c b/src/input.c index 65f13742..e9b29adb 100644 --- a/src/input.c +++ b/src/input.c @@ -58,6 +58,7 @@ #include "windows.h" #include "errors.h" #include "misc.h" +#include "osdep.h" #include "buttons.h" #include "input.h" #include "loadsave.h" diff --git a/src/layers.c b/src/layers.c index 6bb7ded4..c5e37af0 100644 --- a/src/layers.c +++ b/src/layers.c @@ -33,6 +33,7 @@ #include "input.h" #include "help.h" #include "misc.h" +#include "osdep.h" #include "readline.h" #include "graph.h" #include "keycodes.h" diff --git a/src/loadsave.c b/src/loadsave.c index d1dc0394..e68af129 100644 --- a/src/loadsave.c +++ b/src/loadsave.c @@ -62,6 +62,7 @@ #include "loadsave.h" #include "loadsavefuncs.h" #include "misc.h" +#include "osdep.h" #include "graph.h" #include "op_c.h" #include "pages.h" diff --git a/src/misc.c b/src/misc.c index 615f2a40..491b2e34 100644 --- a/src/misc.c +++ b/src/misc.c @@ -28,19 +28,13 @@ #endif #include #include -#if !defined(USE_SDL) && !defined(USE_SDL2) -#if defined(WIN32) -#include -#else -#include -#endif -#endif #include "struct.h" #include "global.h" #include "errors.h" #include "buttons.h" #include "engine.h" #include "misc.h" +#include "osdep.h" #include "keyboard.h" #include "screen.h" #include "windows.h" @@ -864,18 +858,3 @@ int Convert_videomode_arg(const char *argument) return -1; } - -dword GFX2_GetTicks(void) -{ -#if defined(USE_SDL) || defined(USE_SDL2) - return SDL_GetTicks(); -#elif defined(WIN32) - return GetTickCount(); -#else - struct timeval tv; - if (gettimeofday(&tv, NULL) < 0) - return 0; - return tv.tv_sec * 1000 + tv.tv_usec / 1000; -#endif -} - diff --git a/src/misc.h b/src/misc.h index 2f00ded3..ae50d20f 100644 --- a/src/misc.h +++ b/src/misc.h @@ -150,7 +150,4 @@ int Max(int a,int b); const char* Mode_label(int mode); int Convert_videomode_arg(const char *argument); -/// Return a number of milliseconds -dword GFX2_GetTicks(void); - #endif diff --git a/src/operatio.c b/src/operatio.c index 356b03fd..8bfff4e6 100644 --- a/src/operatio.c +++ b/src/operatio.c @@ -27,6 +27,7 @@ #include "struct.h" #include "global.h" #include "misc.h" +#include "osdep.h" #include "engine.h" #include "graph.h" #include "operatio.h" diff --git a/src/osdep.c b/src/osdep.c new file mode 100644 index 00000000..879c00ab --- /dev/null +++ b/src/osdep.c @@ -0,0 +1,50 @@ +/* vim:expandtab:ts=2 sw=2: +*/ +/* Grafx2 - The Ultimate 256-color bitmap paint program + + Copyright 2020 Thomas Bernard + Copyright 2011 Pawel Góralski + Copyright 2008 Yves Rizoud + Copyright 2008 Franck Charlet + Copyright 2007 Adrien Destugues + Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) + + Grafx2 is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; version 2 + of the License. + + Grafx2 is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Grafx2; if not, see +*/ +#if defined(USE_SDL) || defined(USE_SDL2) +#include +#else +#if defined(WIN32) +#include +#else +#include +#endif +#endif + +#include "struct.h" + +dword GFX2_GetTicks(void) +{ +#if defined(USE_SDL) || defined(USE_SDL2) + return SDL_GetTicks(); +#elif defined(WIN32) + return GetTickCount(); +#else + struct timeval tv; + if (gettimeofday(&tv, NULL) < 0) + return 0; + return tv.tv_sec * 1000 + tv.tv_usec / 1000; +#endif +} + diff --git a/src/osdep.h b/src/osdep.h new file mode 100644 index 00000000..267b6d6e --- /dev/null +++ b/src/osdep.h @@ -0,0 +1,36 @@ +/* vim:expandtab:ts=2 sw=2: +*/ +/* Grafx2 - The Ultimate 256-color bitmap paint program + + Copyright 2020 Thomas Bernard + Copyright 2011 Pawel Góralski + Copyright 2008 Yves Rizoud + Copyright 2008 Franck Charlet + Copyright 2007 Adrien Destugues + Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) + + Grafx2 is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; version 2 + of the License. + + Grafx2 is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Grafx2; if not, see +*/ +////////////////////////////////////////////////////////////////////////////// +///@file osdep.h +/// OS Dependend code +////////////////////////////////////////////////////////////////////////////// + +#ifndef OSDEP_H_DEFINED +#define OSDEP_H_DEFINED + +/// Return a number of milliseconds +dword GFX2_GetTicks(void); + +#endif diff --git a/src/special.c b/src/special.c index d6c6bb1a..a03199af 100644 --- a/src/special.c +++ b/src/special.c @@ -29,6 +29,7 @@ #include "special.h" #include "pages.h" #include "misc.h" +#include "osdep.h" #include "buttons.h" diff --git a/src/tiles.c b/src/tiles.c index a4c851e7..dd731308 100644 --- a/src/tiles.c +++ b/src/tiles.c @@ -30,6 +30,7 @@ #include "windows.h" #include "input.h" #include "misc.h" +#include "osdep.h" #include "tiles.h" // These helpers are only needed internally at the moment