/* depend: */
/* cflags: */
-/* linker: block.o color.c constant.o debug.o display.o function.o -lcurses */
-/* doslnk: block.o color.c constant.o debug.o display.o function.o -lpdc~1 */
-/* winlnk: block.o color.c constant.o debug.o display.o function.o -lpdcurses */
+/* linker: block.o color.c constant.o debug.o display.o function.o time.o -lcurses */
+/* doslnk: block.o color.c constant.o debug.o display.o function.o time.o -lpdc~1 */
+/* winlnk: block.o color.c constant.o debug.o display.o function.o time.o -lpdcurses */
#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <time.h>
-#include <sys/time.h>
-#include <unistd.h>
#include "constant.h"
#include "debug.h"
#include "display.h"
#include "function.h"
+#include "time.h"
#include "type.h"
/* static variables */
return cblock;
}
-void setendtime (struct timeval *t, int s)
-{
- gettimeofday (t, NULL);
- t->tv_usec += s * 1000l;
- t->tv_sec += t->tv_usec / 1000000l;
- t->tv_usec = t->tv_usec % 1000000l;
-}
-
-int isovertime (struct timeval *t)
-{
- struct timeval _c;
- struct timeval *c = &_c;
- gettimeofday (c, NULL);
- return ((t->tv_sec < c->tv_sec) || ((t->tv_sec == c->tv_sec) && ( t->tv_usec < c->tv_usec)));
-}
-
/* main function */
int main (int argc, char *argv[])
{
setscale (nextblock, scale);
/* init seed */
- srand (time (NULL));
+ newseed ();
/* get first bloc */
int xblock, yblock;
int speed = 5000;
float chronoratio = 5.0;
int stop = 0;
- struct timeval blockend = {0, 0};
- struct timeval blockend2 = {0, 0};
- struct timeval lineend = {0, 0};
+ timeval_t blockend = {0, 0};
+ timeval_t blockend2 = {0, 0};
+ timeval_t lineend = {0, 0};
while (!stop) {
char msg[128] = {0};
msgwindow (msg, xmsg, ymsg, lmsg);
while (nblines-- > 0) {
boardwindow (board, 0);
stackboard (board);
- usleep ((200 + 2000 / (lines / 10 + 1)) * 100);
+ msleep (20 + 200 / (lines / 10 + 1));
refresh ();
}
if (chrono) {
while (nblines2-- > 0) {
boardwindow (board2, 0);
stackboard (board2);
- usleep ((200 + 2000 / (lines / 10 + 1)) * 100);
+ msleep (20 + 200 / (lines / 10 + 1));
refresh ();
}
}
if (*msg) {
halfdelay (0);
msgwindow (msg, xmsg, ymsg, lmsg);
- usleep (800000);
+ msleep (800);
}
boardwindow (board, 0);
--- /dev/null
+#include <stdlib.h>
+#include <sys/time.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "time.h"
+
+void newseed ()
+{
+ srand (time (NULL));
+}
+
+void setendtime (timeval_t *t, int s)
+{
+ gettimeofday (t, NULL);
+ t->tv_usec += s * 1000l;
+ t->tv_sec += t->tv_usec / 1000000l;
+ t->tv_usec = t->tv_usec % 1000000l;
+}
+
+int isovertime (timeval_t *t)
+{
+ struct timeval _c;
+ struct timeval *c = &_c;
+ gettimeofday (c, NULL);
+ return ((t->tv_sec < c->tv_sec) || ((t->tv_sec == c->tv_sec) && ( t->tv_usec < c->tv_usec)));
+}
+
+void msleep (int msec)
+{
+ usleep (msec * 1000);
+}
+
+/* vim: set ts=4 sw=4 et: */