diff --git a/src/sdl/main.c b/src/sdl/main.c
index 2df46b3fb96cdc76a92b6e799f72878b45493c2f..2243ce07cdf74ecc3f545e29e7d4e22fda73c6e0 100644 (file)
--- a/src/sdl/main.c
+++ b/src/sdl/main.c
-/*
- Copyright (C) Prikol Software 1996-1997
- Copyright (C) Aleksey Volynskov 1996-1997
- Copyright (C) <ARembo@gmail.com> 2011
-
- This file is part of the Doom2D:Rembo project.
-
- Doom2D:Rembo is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation.
-
- Doom2D:Rembo is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/> or
- write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+/* Copyright (C) 2020 SovietPony
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#ifdef __EMSCRIPTEN__
# include <emscripten.h>
#include "system.h"
#include "input.h"
-#include "my.h" // fexists
#include "player.h" // pl1 pl2
#include "menu.h" // G_keyf
#include "error.h" // logo
#include "files.h" // F_startup F_addwad F_initwads F_allocres
#include "config.h" // CFG_args CFG_load CFG_save
+#include "args.h" // ARG_parse
#include "memory.h" // M_startup
#include "game.h" // G_init G_act
#include "sound.h" // S_init S_done
{"file", NULL, Y_FILES},
{"cheat", &cheat, Y_SW_ON},
// {"vga", &shot_vga, Y_SW_ON},
- {"sndvol", &snd_vol, Y_WORD},
- {"musvol", &mus_vol, Y_WORD},
-// {"fullscr", &fullscreen, Y_SW_ON},
-// {"window", &fullscreen, Y_SW_OFF},
+// {"musvol", &mus_vol, Y_WORD},
{"mon", &nomon, Y_SW_OFF},
-// {"gamma", &gammaa, Y_DWORD},
{"warp", &_warp, Y_BYTE},
-// {"width", &SCRW, Y_DWORD},
-// {"height", &SCRH, Y_DWORD},
// {"config", NULL, cfg_file, Y_STRING},
{NULL, NULL, 0} // end
};
static const cfg_t cfg[] = {
// {"screenshot", &shot_vga, Y_SW_ON},
- {"sound_volume", &snd_vol, Y_WORD},
- {"music_volume", &mus_vol, Y_WORD},
-// {"fullscreen", &fullscreen, Y_SW_ON},
- {"sky", &w_horiz, Y_SW_ON},
-// {"gamma", &gammaa, Y_DWORD},
-// {"screen_width", &SCRW, Y_DWORD},
-// {"screen_height", &SCRH, Y_DWORD},
- {"music_random", &music_random, Y_SW_ON},
- {"music_time", &music_time, Y_DWORD},
- {"music_fade", &music_fade, Y_DWORD},
+// {"music_volume", &mus_vol, Y_WORD},
+// {"music_random", &music_random, Y_SW_ON},
+// {"music_time", &music_time, Y_DWORD},
+// {"music_fade", &music_fade, Y_DWORD},
{"pl1_left", &pl1.kl, Y_KEY},
{"pl1_right",&pl1.kr, Y_KEY},
{"pl1_up", &pl1.ku, Y_KEY},
};
static void CFG_args (int argc, char **argv) {
- int i;
- for (i = 1; i < argc; i++) {
- if (argv[i][0] == '-' && argv[i][1] != 0) {
- if (i + 1 >= argc) {
- ERR_failinit("CFG_args: not enough arguments for parameter %s\n", argv[i]);
- } else {
- if (CFG_update_key(&argv[i][1], argv[i + 1], arg) != 0) {
- ERR_failinit("CFG_args: unknown parameter %s\n", argv[i]);
- }
- i += 1;
- }
- } else {
- ERR_failinit("CFG_args: something wrong here: %s\n", argv[i]);
- }
- }
+ const cfg_t *list[] = { arg, R_args(), S_args(), MUS_args() };
+ ARG_parse(argc, argv, 4, list);
}
static void CFG_load (void) {
- CFG_read_config("default.cfg", cfg);
- CFG_read_config("doom2d.cfg", cfg);
+ const cfg_t *list[] = { cfg, R_conf(), S_conf(), MUS_conf() };
+ CFG_read_config("default.cfg", 4, list);
+ CFG_read_config("doom2d.cfg", 4, list);
}
static void CFG_save (void) {
- CFG_update_config("doom2d.cfg", "doom2d.cfg", cfg, "generated by doom2d, do not modify");
- //CFG_update_config("doom2d.cfg", "doom2d.tmp", cfg, "temporary file");
- //CFG_update_config("doom2d.tmp", "doom2d.cfg", cfg, "generated by doom2d, do not modify");
- //remove("doom2d.tmp");
+ const cfg_t *list[] = { cfg, R_conf(), S_conf(), MUS_conf() };
+ CFG_update_config("doom2d.cfg", "doom2d.cfg", 4, list, "generated by doom2d, do not modify");
}
/* --- error.h --- */
vprintf(s, ap);
va_end(ap);
puts("");
- exit(1);
+ abort();
}
void ERR_fatal (char *s, ...) {
va_list ap;
R_done();
+ MUS_done();
S_done();
- S_donemusic();
- M_shutdown();
SDL_Quit();
- puts("\nКРИТИЧЕСКАЯ ОШИБКА:");
+ puts("\nCRITICAL ERROR:");
va_start(ap, s);
vprintf(s, ap);
va_end(ap);
puts("");
- exit(1);
+ abort();
}
void ERR_quit (void) {
static void step (void) {
poll_events();
- S_updatemusic();
+ MUS_update();
Uint32 t = SDL_GetTicks();
if (t - ticks > DELAY) {
ticks = t;
}
int main (int argc, char *argv[]) {
- char *pw;
logo("main: initialize SDL\n");
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1) {
logo("main: failed to init SDL: %s\n", SDL_GetError());
pl2.kwr = KEY_2;
pl2.kp = KEY_E;
srand(SDL_GetTicks());
- F_startup();
-#ifndef WIN32
- pw = "/usr/share/doom2d-rembo/doom2d.wad";
-#else
- pw = "doom2d.wad";
-#endif
- if (fexists(pw)) {
- F_addwad(pw);
- } else {
- F_addwad("doom2d.wad");
- }
+ F_addwad("doom2d.wad");
CFG_args(argc, argv);
CFG_load();
F_initwads();
- M_startup();
- F_allocres();
S_init();
- S_initmusic();
+ MUS_init();
R_init();
G_init();
ticks = SDL_GetTicks();
#endif
CFG_save();
R_done();
- S_donemusic();
+ MUS_done();
S_done();
- M_shutdown();
SDL_Quit();
return 0;
}