/*
* src/system.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include <SDL.h>
#include <signal.h>
#include "system.h"
#include "windows.h"
/*
* Panic
*/
void sys_panic (char *err, ...)
{
va_list argptr;
char s[1024];
/* prepare message */
vsprintf_s (s, sizeof (s), err, argptr);
/* print message and die */
MessageBox (NULL, s, NULL, MB_OK);
}
/*
* Print a message
*/
void sys_printf (char *msg, ...)
{
va_list argptr;
char s[2048];
/* prepare message */
vsprintf_s (s, sizeof (s), msg, argptr);
MessageBox (NULL, s, NULL, MB_OK);
}
/*
* Return number of microseconds elapsed since first call
*/
U32 sys_gettime (void)
{
static U32 ticks_base = 0;
U32 ticks;
ticks = SDL_GetTicks ();
if (!ticks_base)
ticks_base = ticks;
return ticks - ticks_base;
}
/*
* Sleep a number of microseconds
*/
void sys_sleep (int s)
{
SDL_Delay (s);
}
/*
* Initialize system
*/
void sys_init (int argc, char **argv)
{
sysarg_init (argc, argv);
sysvid_init ();
sysjoy_init ();
if (sysarg_args_nosound == 0)
syssnd_init ();
}
/*
* Shutdown system
*/
void sys_shutdown (void)
{
syssnd_shutdown ();
sysjoy_shutdown ();
sysvid_shutdown ();
}