1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
/*
* xrick/system/system.h
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
* Copyright (C) 2008-2014 Pierluigi Vicinanza.
* 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
/*
* Detect GCC
*/
#ifdef __GNUC__
/*
* make POSIX functions available
*/
# ifndef _POSIX_SOURCE
# define _POSIX_SOURCE
# endif
#endif
/*
* Detect Microsoft Visual C
*/
#ifdef _MSC_VER
/*
* FIXME disable "integral size mismatch in argument; conversion supplied" warning
* as long as the code has not been cleared -- there are so many of them...
*/
#pragma warning( disable : 4761 )
#endif
/*
* Detect Microsoft Windows
*/
#if !defined( __WIN32__ ) && ( defined( WIN32 ) || defined( _WIN32 ) )
#define __WIN32__
#endif
#include "xrick/config.h"
#include "xrick/rects.h"
#include "xrick/data/img.h"
#ifdef ENABLE_SOUND
#include "xrick/data/sounds.h"
#endif
#include <stddef.h> /* size_t */
#include <sys/types.h> /* off_t */
/*
* main section
*/
extern bool sys_init(int, char **);
extern void sys_shutdown(void);
extern void sys_error(const char *, ...);
extern void sys_printf(const char *, ...);
extern void sys_snprintf(char *, size_t, const char *, ...);
extern size_t sys_strlen(const char *);
extern U32 sys_gettime(void);
extern void sys_yield(void);
extern bool sys_cacheData(void);
extern void sys_uncacheData(void);
/*
* memory section
*/
extern bool sysmem_init(void);
extern void sysmem_shutdown(void);
extern void *sysmem_push(size_t);
extern void sysmem_pop(void *);
/*
* video section
*/
#define SYSVID_ZOOM 2
#define SYSVID_MAXZOOM 4
#define SYSVID_WIDTH 320
#define SYSVID_HEIGHT 200
extern U8 *sysvid_fb; /* frame buffer */
extern bool sysvid_init(void);
extern void sysvid_shutdown(void);
extern void sysvid_update(const rect_t *);
extern void sysvid_clear(void);
extern void sysvid_zoom(S8);
extern void sysvid_toggleFullscreen(void);
extern void sysvid_setGamePalette(void);
extern void sysvid_setPalette(img_color_t *, U16);
/*
* file management section
*/
typedef void *file_t;
extern const char *sysfile_defaultPath;
extern bool sysfile_setRootPath(const char *);
extern void sysfile_clearRootPath(void);
extern file_t sysfile_open(const char *);
extern int sysfile_seek(file_t file, long offset, int origin);
extern int sysfile_tell(file_t);
extern off_t sysfile_size(file_t);
extern int sysfile_read(file_t, void *, size_t, size_t);
extern void sysfile_close(file_t);
/*
* events section
*/
extern void sysevt_poll(void);
extern void sysevt_wait(void);
/*
* keyboard section
*/
extern U8 syskbd_up;
extern U8 syskbd_down;
extern U8 syskbd_left;
extern U8 syskbd_right;
extern U8 syskbd_pause;
extern U8 syskbd_end;
extern U8 syskbd_xtra;
extern U8 syskbd_fire;
/*
* sound section
*/
#ifdef ENABLE_SOUND
extern const U8 syssnd_period; /* time between each sound update, in millisecond */
extern bool syssnd_init(void);
extern void syssnd_shutdown(void);
extern void syssnd_update(void);
extern void syssnd_vol(S8);
extern void syssnd_toggleMute(void);
extern void syssnd_play(sound_t *, S8);
extern void syssnd_pauseAll(bool);
extern void syssnd_stop(sound_t *);
extern void syssnd_stopAll(void);
#endif /* ENABLE_ SOUND */
/*
* args section
*/
extern int sysarg_args_period;
extern int sysarg_args_map;
extern int sysarg_args_submap;
extern int sysarg_args_fullscreen;
extern int sysarg_args_zoom;
#ifdef ENABLE_SOUND
extern bool sysarg_args_nosound;
extern int sysarg_args_vol;
#endif /* ENABLE_ SOUND */
extern const char *sysarg_args_data;
extern bool sysarg_init(int, char **);
/*
* joystick section
*/
#ifdef ENABLE_JOYSTICK
extern bool sysjoy_init(void);
extern void sysjoy_shutdown(void);
#endif
#endif /* ndef _SYSTEM_H */
/* eof */
|