Initial import.
[neverball] / share / config.h
1 /*
2  * Copyright (C) 2003 Robert Kooima
3  *
4  * NEVERBALL is  free software; you can redistribute  it and/or modify
5  * it under the  terms of the GNU General  Public License as published
6  * by the Free  Software Foundation; either version 2  of the License,
7  * or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT  ANY  WARRANTY;  without   even  the  implied  warranty  of
11  * MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
12  * General Public License for more details.
13  */
14
15 #ifndef CONFIG_H
16 #define CONFIG_H
17
18 #include <SDL.h>
19 #include <stdio.h>
20
21 /*---------------------------------------------------------------------------*/
22
23 #define CONFIG_DATA "./data"
24 #define CONFIG_USER ".neverball"
25
26 /*
27  * Global settings are stored in USER_CONFIG_FILE.  Replays are stored
28  * in  USER_REPLAY_FILE.  These files  are placed  in the  user's home
29  * directory as given by the HOME environment var.  If the config file
30  * is deleted, it will be recreated using the defaults.
31  */
32 #define USER_CONFIG_FILE "neverballrc"
33 #define USER_REPLAY_FILE "Last"
34
35 /*---------------------------------------------------------------------------*/
36
37 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
38 #define RMASK 0xFF000000
39 #define GMASK 0x00FF0000
40 #define BMASK 0x0000FF00
41 #define AMASK 0x000000FF
42 #else
43 #define RMASK 0x000000FF
44 #define GMASK 0x0000FF00
45 #define BMASK 0x00FF0000
46 #define AMASK 0xFF000000
47 #endif
48
49 #ifdef _WIN32
50 #define FMODE_RB "rb"
51 #define FMODE_WB "wb"
52 #else
53 #define FMODE_RB "r"
54 #define FMODE_WB "w"
55 #endif
56
57 #ifdef _WIN32
58 #define AUDIO_BUFF_HI 4096
59 #define AUDIO_BUFF_LO 2048
60 #else
61 #define AUDIO_BUFF_HI 2048
62 #define AUDIO_BUFF_LO 1024
63 #endif
64
65 /*---------------------------------------------------------------------------*/
66
67 enum {
68     CONFIG_FULLSCREEN,
69     CONFIG_WIDTH,
70     CONFIG_HEIGHT,
71     CONFIG_STEREO,
72     CONFIG_CAMERA,
73     CONFIG_TEXTURES,
74     CONFIG_GEOMETRY,
75     CONFIG_REFLECTION,
76     CONFIG_BACKGROUND,
77     CONFIG_SHADOW,
78     CONFIG_AUDIO_RATE,
79     CONFIG_AUDIO_BUFF,
80     CONFIG_MOUSE_SENSE,
81     CONFIG_MOUSE_INVERT,
82     CONFIG_NICE,
83     CONFIG_FPS,
84     CONFIG_SOUND_VOLUME,
85     CONFIG_MUSIC_VOLUME,
86     CONFIG_JOYSTICK,
87     CONFIG_JOYSTICK_DEVICE,
88     CONFIG_JOYSTICK_AXIS_X,
89     CONFIG_JOYSTICK_AXIS_Y,
90     CONFIG_JOYSTICK_BUTTON_A,
91     CONFIG_JOYSTICK_BUTTON_B,
92     CONFIG_JOYSTICK_BUTTON_R,
93     CONFIG_JOYSTICK_BUTTON_L,
94     CONFIG_JOYSTICK_BUTTON_EXIT,
95     CONFIG_JOYSTICK_CAMERA_1,
96     CONFIG_JOYSTICK_CAMERA_2,
97     CONFIG_JOYSTICK_CAMERA_3,
98     CONFIG_KEY_CAMERA_1,
99     CONFIG_KEY_CAMERA_2,
100     CONFIG_KEY_CAMERA_3,
101     CONFIG_KEY_CAMERA_R,
102     CONFIG_KEY_CAMERA_L,
103     CONFIG_VIEW_FOV,
104     CONFIG_VIEW_DP,
105     CONFIG_VIEW_DC,
106     CONFIG_VIEW_DZ,
107     CONFIG_ROTATE_FAST,
108     CONFIG_ROTATE_SLOW,
109
110     CONFIG_OPTION_D_COUNT
111 };
112
113 enum {
114     CONFIG_PLAYER,
115     CONFIG_BALL,
116     CONFIG_COIN,
117
118     CONFIG_OPTION_S_COUNT
119 };
120
121 /*---------------------------------------------------------------------------*/
122
123 #define DEFAULT_FULLSCREEN           0
124 #define DEFAULT_WIDTH                800
125 #define DEFAULT_HEIGHT               600
126 #define DEFAULT_STEREO               0
127 #define DEFAULT_CAMERA               0
128 #define DEFAULT_TEXTURES             1
129 #define DEFAULT_GEOMETRY             1
130 #define DEFAULT_REFLECTION           1
131 #define DEFAULT_BACKGROUND           1
132 #define DEFAULT_SHADOW               1
133 #define DEFAULT_AUDIO_RATE           44100
134 #define DEFAULT_AUDIO_BUFF           AUDIO_BUFF_HI
135 #define DEFAULT_MOUSE_SENSE          300
136 #define DEFAULT_MOUSE_INVERT         0
137 #define DEFAULT_NICE                 1
138 #define DEFAULT_FPS                  0
139 #define DEFAULT_SOUND_VOLUME         10
140 #define DEFAULT_MUSIC_VOLUME         6
141 #define DEFAULT_JOYSTICK             0
142 #define DEFAULT_JOYSTICK_DEVICE      0
143 #define DEFAULT_JOYSTICK_AXIS_X      0
144 #define DEFAULT_JOYSTICK_AXIS_Y      1
145 #define DEFAULT_JOYSTICK_BUTTON_A    0
146 #define DEFAULT_JOYSTICK_BUTTON_B    1
147 #define DEFAULT_JOYSTICK_BUTTON_R    2
148 #define DEFAULT_JOYSTICK_BUTTON_L    3
149 #define DEFAULT_JOYSTICK_BUTTON_EXIT 4
150 #define DEFAULT_JOYSTICK_CAMERA_1    5
151 #define DEFAULT_JOYSTICK_CAMERA_2    6
152 #define DEFAULT_JOYSTICK_CAMERA_3    7
153 #define DEFAULT_KEY_CAMERA_1         SDLK_F1
154 #define DEFAULT_KEY_CAMERA_2         SDLK_F2
155 #define DEFAULT_KEY_CAMERA_3         SDLK_F3
156 #define DEFAULT_KEY_CAMERA_R         SDLK_RIGHT
157 #define DEFAULT_KEY_CAMERA_L         SDLK_LEFT
158 #define DEFAULT_VIEW_FOV             50
159 #define DEFAULT_VIEW_DP              75
160 #define DEFAULT_VIEW_DC              25
161 #define DEFAULT_VIEW_DZ              200
162 #define DEFAULT_ROTATE_SLOW          100
163 #define DEFAULT_ROTATE_FAST          200
164 #define DEFAULT_PLAYER               "Player"
165 #define DEFAULT_BALL                 "png/ball.png"
166 #define DEFAULT_COIN                 "png/coin.png"
167
168 /*---------------------------------------------------------------------------*/
169
170 #define JOY_MAX 32767
171 #define JOY_MID 16383
172
173 #define MAXSTR 256
174 #define MAXLVL 26
175 #define MAXNAM 9
176
177 /*---------------------------------------------------------------------------*/
178
179 void config_init(void);
180 void config_load(void);
181 void config_save(void);
182 int  config_mode(int, int, int);
183
184 const char *config_data(const char *);
185 const char *config_user(const char *);
186
187 int  config_data_path(const char *, const char *);
188 int  config_user_path(const char *);
189
190 /*---------------------------------------------------------------------------*/
191
192 void config_set_d(int, int);
193 void config_tgl_d(int);
194 int  config_tst_d(int, int);
195 int  config_get_d(int);
196
197 void config_set_s(int, char *);
198 void config_get_s(int, char *, int);
199
200 /*---------------------------------------------------------------------------*/
201
202 void config_set_grab(void);
203 void config_clr_grab(void);
204 int  config_get_grab(void);
205
206 int  config_get_pause(void);
207 void config_set_pause(void);
208 void config_clr_pause(void);
209 void config_tgl_pause(void);
210
211 /*---------------------------------------------------------------------------*/
212
213 void config_push_persp(float, float, float);
214 void config_push_ortho(void);
215 void config_pop_matrix(void);
216 void config_clear(void);
217
218 /*---------------------------------------------------------------------------*/
219
220 #endif