Remove static label from game functions
[kraptor.git] / src / main.c
bloba25091435f41f380e46aeda7542b453d1c120244
1 // --------------------------------------------------------
2 // Kraptor - Call of the freedom
3 // --------------------------------------------------------
4 // main.c
5 // --------------------------------------------------------
6 // Copyright (c) 2002-2004, Kronoman
7 // En memoria de mi querido padre
8 // --------------------------------------------------------
9 // Este modulo es el 'arranque' del programa
10 // Inicia el video, carga los datos, etc...
11 // --------------------------------------------------------
12 // Ultima revision: 18/ENERO/2004
14 #ifndef MAIN_C
15 #define MAIN_C
17 // --------------------------------------------------------
18 // Inclusiones
19 // --------------------------------------------------------
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <allegro.h>
24 #include <aldumb.h> /* DUMB: musica MOD, XM, etc */
25 #include "main.h"
26 #include "error.h"
27 #include "game.h"
28 #include "data.h"
29 #include "jugador.h"
30 #include "global.h"
31 #include "menu.h"
32 #include "mapa.h"
33 #include "config.h"
36 int main(int argc, char *argv[] )
38 int i1; // para el for de los parametros
39 int rx = 640, ry = 480; // para permitir que el usuario elija la resolucion
40 int vid_card = GFX_AUTODETECT; // placa de video por defecto
42 int snd = TRUE; // quiere sonido
43 lenguaje[0]='e';
44 lenguaje[1]='s';
45 lenguaje[2]= '\0';
47 /* Iniciar Allegro y el hardware */
48 allegro_init();
49 atexit(&dumb_exit);
51 /* setear allegro al idioma configurado, default = en (ingles) */
52 strncpy(lenguaje, get_config_string("system", "language", "en"), 2);
53 reload_config_texts(lenguaje);
55 /* configuracion de DUMB, por default, CASI la mas baja (1), la mas baja es 0 :^) */
56 dumb_resampling_quality = get_config_int("sound", "dumb_resampling_quality", 1);
57 dumb_it_max_to_mix = get_config_int("sound", "dumb_it_max_to_mix", 8);
59 /* registro los IT, XM y S3M para cargarlos con DUMB */
60 dumb_register_dat_it(DUMB_DAT_IT);
61 dumb_register_dat_xm(DUMB_DAT_XM);
62 dumb_register_dat_s3m(DUMB_DAT_S3M);
65 srand(time(0));
66 if (install_timer() != 0) levantar_error("ERROR: Fallo el inicio del temporizador!");
67 if (install_keyboard() != 0) levantar_error("ERROR: Imposible acceder al teclado!");
69 install_mouse(); /* Tambien uso el mouse para los menus! */
71 // --------------------------------------------------------
72 // Interpretar parametros
73 // --------------------------------------------------------
74 for (i1=1; i1<argc; i1++) {
76 // -steroids (modo 'rapido', el scroll pasa 5 veces mas rapido!)
77 if (stricmp(argv[i1], "-steroids") == 0) scroll_mapa_speed = 5;
79 // -crazy_speed (modo 'super rapido', el scroll pasa 10 veces mas rapido!)
80 if (stricmp(argv[i1], "-crazy_speed") == 0) scroll_mapa_speed = 10;
82 // -kronoman (cheat: modo DIOS - no muere nunca)
83 if (stricmp(argv[i1], "-kronoman") == 0) cheat_god_mode = TRUE;
85 // -safe (modo seguro, video pedorro y sin sonido)
86 if (stricmp(argv[i1], "-safe") == 0) { rx = 320; ry = 200; snd = FALSE; vid_card = GFX_SAFE; }
88 // video: modo en ventana (solo algunas plataformas)
89 if (stricmp(argv[i1], "-windowscreen")== 0) vid_card = GFX_AUTODETECT_WINDOWED;
90 // video: modo en pantalla completa
91 if (stricmp(argv[i1], "-fullscreen") == 0) vid_card = GFX_AUTODETECT_FULLSCREEN;
93 // video: video automatico
94 if (stricmp(argv[i1], "-autoscreen") == 0) vid_card = GFX_AUTODETECT;
97 // video: -320x200 (320x200)
98 if (stricmp(argv[i1], "-320x200") == 0) { rx = 320; ry = 200; }
100 // video: -320x240 (320x240)
101 if (stricmp(argv[i1], "-320x240") == 0) { rx = 320; ry = 240; }
103 // video: -640x480 (640x480)
104 if (stricmp(argv[i1], "-640x480") == 0) { rx = 640; ry = 480; }
106 // video: -800x600 (800x600)
107 if (stricmp(argv[i1], "-800x600") == 0) { rx = 800; ry = 600; }
109 // video: -1024x768 (1024x768)
110 if (stricmp(argv[i1], "-1024x768") == 0) { rx = 1024; ry = 768; }
112 // -nosound - sin sonido
113 if (stricmp(argv[i1], "-nosound") == 0) { snd=FALSE; }
115 // ayuda
116 if (stricmp(argv[i1],"-h")==0 || stricmp(argv[i1],"-?") == 0 || stricmp(argv[i1],"--h") == 0 || stricmp(argv[i1],"/?") == 0)
118 /* DEBUG: falta mostrar la ayuda!!! */
119 exit(0);
122 // DEBUG: falta un -v para la version! */
124 } // fin for
127 /* Iniciar video */
128 set_color_depth(8); /* setear a 8bpp, en otros modos, no ANDA! */
130 // DEBUG: probar con GFX_SAFE que tambien intenta setear el rx, ry, pero anda mejor en Linux
131 if (set_gfx_mode(vid_card, rx, ry, 0, 0))
132 if (set_gfx_mode(GFX_SAFE, rx, ry, 0, 0))
133 if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0))
134 if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0))
135 levantar_error("ERROR: imposible utilizar algun modo grafico de 8bpp!");
137 // chequear el 'depth' de color (porque GFX_SAFE puede meter otro que no sea 8bpp)
138 // if (bitmap_color_depth(screen) != 8); levantar_error("ERROR: el modo grafico no es de 8bpp!");
140 clear(screen);
141 textout(screen, font,"Wait... loading...",0,SCREEN_H - text_height(font)*2, makecol(255,255,255));
143 // textout(screen, font,"Espere... iniciando programa...",0,0, makecol(255,255,255));
144 // textout(screen, font,"Si el juego se detiene aqui, intente reiniciarlo con el parametro -nosound.",0,SCREEN_H - text_height(font)*2 , makecol(255,255,255));
145 // textout(screen, font,"Utilize el parametro -h para mas informacion.",0,SCREEN_H - text_height(font), makecol(255,255,255));
147 set_teclado_default();
149 /* DEBUG: Joystick! wow!! */
150 install_joystick(JOY_TYPE_AUTODETECT);
152 // SONIDO
153 // reserve_voices(8, 0); // 8 voces de sonido
155 // volumen por voz (def: 2, maximo volumen: 0)
156 // set_volume_per_voice(1); // puede causar distorsion, ojo! causa DISTORSION!
158 if (snd)
160 if (install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL) == -1)
161 { levantar_error("ERROR: no se puede configurar el sonido.\nPara desactivarlo use el parametro -nosound!");}
163 driver_de_sonido = TRUE;
165 else
167 install_sound(DIGI_NONE, MIDI_NONE, NULL);
168 quiere_snd = FALSE;
169 quiere_musica = FALSE;
170 driver_de_sonido = FALSE;
171 } // sin sonido
173 // volumen al mango
174 set_volume(255,-1);
176 // instalo colision de mascaras [IMPORTANTE]
177 install_pmask();
179 // Hacer backup del font default
180 font_backup = font;
182 cargar_datos_principales(); /* Cargar datos del programa */
184 // cargar configuracion especifica de Kraptor
185 cargar_configuracion();
187 /* menu principal */
188 realizar_menu_principal();
190 // aqui salvar la configuracion especifica de Kraptor!!!
191 salvar_configuracion();
193 return 0;
195 END_OF_MAIN();
197 #endif