diff --git a/src/sdl2/main.c b/src/sdl2/main.c
index 67387dba6b6d8bf2cabfc2e1382ceeb00628e2fb..8f89012d628db67e3712c1d4a3ebcfec4f851a1e 100644 (file)
--- a/src/sdl2/main.c
+++ b/src/sdl2/main.c
+/* 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>
#endif
#ifdef __EMSCRIPTEN__
# include <emscripten.h>
#endif
#include "player.h" // pl1 pl2
#include "menu.h" // G_keyf
#include "error.h" // logo
#include "player.h" // pl1 pl2
#include "menu.h" // G_keyf
#include "error.h" // logo
+#include "monster.h" // nomon
#include "files.h" // F_startup F_addwad F_initwads F_allocres
#include "config.h" // CFG_args CFG_load CFG_save
#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
#include "memory.h" // M_startup
#include "game.h" // G_init G_act
#include "sound.h" // S_init S_done
static SDL_Surface *surf;
static videomode_t vlist;
static SDL_Surface *surf;
static videomode_t vlist;
+static const cfg_t arg[] = {
+ {"file", NULL, Y_FILES},
+ {"cheat", &cheat, Y_SW_ON},
+// {"vga", &shot_vga, Y_SW_ON},
+// {"musvol", &mus_vol, Y_WORD},
+ {"mon", &nomon, Y_SW_OFF},
+ {"warp", &_warp, Y_BYTE},
+// {"config", NULL, cfg_file, Y_STRING},
+ {NULL, NULL, 0} // end
+};
+
+static const cfg_t cfg[] = {
+// {"screenshot", &shot_vga, Y_SW_ON},
+// {"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},
+ {"pl1_down", &pl1.kd, Y_KEY},
+ {"pl1_jump", &pl1.kj, Y_KEY},
+ {"pl1_fire", &pl1.kf, Y_KEY},
+ {"pl1_next", &pl1.kwr, Y_KEY},
+ {"pl1_prev", &pl1.kwl, Y_KEY},
+ {"pl1_use", &pl1.kp, Y_KEY},
+ {"pl2_left", &pl2.kl, Y_KEY},
+ {"pl2_right", &pl2.kr, Y_KEY},
+ {"pl2_up", &pl2.ku, Y_KEY},
+ {"pl2_down", &pl2.kd, Y_KEY},
+ {"pl2_jump", &pl2.kj, Y_KEY},
+ {"pl2_fire", &pl2.kf, Y_KEY},
+ {"pl2_next", &pl2.kwr, Y_KEY},
+ {"pl2_prev", &pl2.kwl, Y_KEY},
+ {"pl2_use", &pl2.kp, Y_KEY},
+ {NULL, NULL, 0} // end
+};
+
+static void CFG_args (int argc, char **argv) {
+ const cfg_t *list[] = { arg, R_args(), S_args(), MUS_args() };
+ ARG_parse(argc, argv, 4, list);
+}
+
+static void CFG_load (void) {
+ 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) {
+ 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 --- */
void logo (const char *s, ...) {
/* --- error.h --- */
void logo (const char *s, ...) {
void ERR_fatal (char *s, ...) {
va_list ap;
R_done();
void ERR_fatal (char *s, ...) {
va_list ap;
R_done();
+ MUS_done();
S_done();
S_done();
- S_donemusic();
M_shutdown();
SDL_Quit();
puts("\nКРИТИЧЕСКАЯ ОШИБКА:");
M_shutdown();
SDL_Quit();
puts("\nКРИТИЧЕСКАЯ ОШИБКА:");
static void step (void) {
poll_events();
static void step (void) {
poll_events();
- S_updatemusic();
+ MUS_update();
Uint32 t = SDL_GetTicks();
if (t - ticks > DELAY) {
ticks = t;
Uint32 t = SDL_GetTicks();
if (t - ticks > DELAY) {
ticks = t;
int main (int argc, char **argv) {
char *pw;
int main (int argc, char **argv) {
char *pw;
+ CFG_args(argc, argv);
logo("system: initialize SDL2\n");
if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_EVENTS) == -1) {
logo("system: failed to init SDL2: %s\n", SDL_GetError());
logo("system: initialize SDL2\n");
if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_EVENTS) == -1) {
logo("system: failed to init SDL2: %s\n", SDL_GetError());
pl2.kp = KEY_E;
srand(SDL_GetTicks());
F_startup();
pl2.kp = KEY_E;
srand(SDL_GetTicks());
F_startup();
+ CFG_load();
#ifndef WIN32
pw = "/usr/share/doom2d-rembo/doom2d.wad";
#else
#ifndef WIN32
pw = "/usr/share/doom2d-rembo/doom2d.wad";
#else
} else {
F_addwad("doom2d.wad");
}
} else {
F_addwad("doom2d.wad");
}
- CFG_args(argc, argv);
- CFG_load();
F_initwads();
M_startup();
F_allocres();
S_init();
F_initwads();
M_startup();
F_allocres();
S_init();
- S_initmusic();
+ MUS_init();
R_init();
G_init();
ticks = SDL_GetTicks();
R_init();
G_init();
ticks = SDL_GetTicks();
#endif
CFG_save();
R_done();
#endif
CFG_save();
R_done();
- S_donemusic();
+ MUS_done();
S_done();
M_shutdown();
SDL_Quit();
S_done();
M_shutdown();
SDL_Quit();