/*
* games/_shared/ - shared routines for games
*
* standart-linux.c - standard GNU/Linux subroutines library
* ____________________________________________________________
*
* Developed by Ondrej Jombik <nepto@platon.sk>
* Copyright (c) 2003-2004 Platon SDG, http://platon.sk/
* All rights reserved.
*
* See README file for more information about this software.
* See COPYING file for license information.
*
* Download the latest version from
* http://platon.sk/projects/games/
*
* Changelog:
* 2003-05-05 - created
*/
/* $Platon: games/_shared/standart-linux.c,v 1.6 2004/04/06 09:54:16 nepto Exp $ */
/* NOTE: incorrect "standart" word in filename is kept
from historical reasons; correct word is "standard" */
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <typedef.h>
#include <dos2linux.h>
#include <time.h>
#include <sys/times.h>
#include "standart.h"
#define MOUSE_SUPPORT_IN_WAIT 1
#if defined(MOUSE_SUPPORT_IN_WAIT) && MOUSE_SUPPORT_IN_WAIT
/* This must be synchronized with mouse-svgalib.c and/or mouse-x11.c */
void mouse_status_update(void);
#endif
/* IMPLEMENTATION */
#include "stshared.c"
#if defined(MOUSE_SUPPORT_IN_WAIT) && MOUSE_SUPPORT_IN_WAIT
/* nothing */
#else
static void wait_clocks_dummy_func(void)
{
return;
}
#endif
static void wait_clocks(clock_t total, void (*user_fnc)())
{
clock_t start = times(NULL);
while (times(NULL) - start < total)
user_fnc();
}
void wait(double sec)
{
wait_clocks(max(1, sec * sysconf(_SC_CLK_TCK)),
#if defined(MOUSE_SUPPORT_IN_WAIT) && MOUSE_SUPPORT_IN_WAIT
mouse_status_update
#else
wait_clocks_dummy_func
#endif
);
}
/* Modeline for ViM {{{
* vim: set ts=4:
* vim600: fdm=marker fdl=0 fdc=0:
* }}} */
Platon Group <platon@platon.sk> http://platon.sk/
|