/*
 
 * src/system.h
 
 *
 
 * 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.
 
 */
 
 
 
#ifndef _SYSTEM_H
 
#define _SYSTEM_H
 
 
 
#include <stdint.h>
 
typedef uint8_t U8;
 
typedef uint16_t U16;
 
typedef uint32_t U32;
 
typedef int8_t S8;
 
typedef int16_t S16;
 
typedef int32_t S32;
 
#ifdef WIN32
 
#include <stdio.h> // for sprintf_s() and the likes
 
#else // !WIN32
 
#define strcpy_s(dest,size,source) strcpy (dest, source)
 
#define strcat_s(dest,size,source) strcat (dest, source)
 
#define sprintf_s(dest,size,format,...) sprintf (dest, format, __VA_ARGS__)
 
#define strncpy_s(dest,size,source,count) strncpy (dest, source, count)
 
#define vsprintf_s(buffer,maxsize,format,...) vsprintf(buffer,format, ##__VA_ARGS__)
 
#define fopen_s(fp,filename,mode) *(fp) = fopen (filename, mode)
 
#endif // WIN32
 
 
 
/* this must be after typedefs because it relies on types defined above */
 
#include "rects.h"
 
#include "img.h"
 
 
 
/*
 
 * main section
 
 */
 
extern void sys_init (int, char **);
 
extern void sys_shutdown (void);
 
extern char *sys_getbasepath (void);
 
extern void sys_panic (char *, ...);
 
extern void sys_printf (char *, ...);
 
extern U32 sys_gettime (void);
 
extern void sys_sleep (int);
 
 
 
/*
 
 * video section
 
 */
 
extern void sysvid_init (void);
 
extern void sysvid_shutdown (void);
 
extern void sysvid_clear (void);
 
extern void sysvid_paint (rect_t *);
 
 
 
/*
 
 * events section
 
 */
 
extern void sysevt_poll (void);
 
extern void sysevt_wait (void);
 
 
 
/*
 
 * sound section
 
 */
 
typedef struct
 
{
 
   U8 *buf;
 
   U32 len;
 
   U8 dispose;
 
} sound_t;
 
 
 
extern void syssnd_init (void);
 
extern void syssnd_shutdown (void);
 
extern void syssnd_vol (S8);
 
extern void syssnd_toggleMute (void);
 
extern S8 syssnd_play (sound_t *, S8);
 
extern void syssnd_pause (U8, U8);
 
extern void syssnd_stopchan (S8);
 
extern void syssnd_stopsound (sound_t *);
 
extern void syssnd_stopall (void);
 
extern int syssnd_isplaying (sound_t *);
 
extern sound_t *syssnd_load (char *name);
 
extern void syssnd_free (sound_t *);
 
 
 
/*
 
 * args section
 
 */
 
extern int sysarg_args_period;
 
extern int sysarg_args_map;
 
extern int sysarg_args_submap;
 
extern int sysarg_args_nosound;
 
extern int sysarg_args_vol;
 
 
 
extern void sysarg_init (int, char **);
 
 
 
/*
 
 * joystick section
 
 */
 
extern void sysjoy_init (void);
 
extern void sysjoy_shutdown (void);
 
 
 
#endif