X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fsdl2%2Fmain.c;h=3f149b53302fc22e1722dccbb1c382d33470eef8;hb=cf509314ff0bc57488cbeeec0b1c98d88fb027a4;hp=f9eb159fe7b7342c1ab28cd2fd9a9a9a5ed783c7;hpb=9f3ca6bf02300e3dc72e3c2085a8e35aa9242678;p=flatwaifu.git diff --git a/src/sdl2/main.c b/src/sdl2/main.c index f9eb159..3f149b5 100644 --- a/src/sdl2/main.c +++ b/src/sdl2/main.c @@ -1,3 +1,18 @@ +/* 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 . + */ + #ifdef __EMSCRIPTEN__ # include #endif @@ -11,9 +26,6 @@ #include "system.h" #include "input.h" -#include "cp866.h" - -#include "my.h" // fexists #include "player.h" // pl1 pl2 #include "menu.h" // G_keyf #include "error.h" // logo @@ -28,6 +40,8 @@ #include "music.h" // S_initmusic S_updatemusic S_donemusic #include "render.h" // R_init R_draw R_done +#include "common/cp866.h" + #define TITLE_STR "Doom 2D (SDL2)" static Uint32 ticks; @@ -41,8 +55,7 @@ static const cfg_t arg[] = { {"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}, +// {"musvol", &mus_vol, Y_WORD}, {"mon", &nomon, Y_SW_OFF}, {"warp", &_warp, Y_BYTE}, // {"config", NULL, cfg_file, Y_STRING}, @@ -51,11 +64,10 @@ static const cfg_t arg[] = { static const cfg_t cfg[] = { // {"screenshot", &shot_vga, Y_SW_ON}, - {"sound_volume", &snd_vol, Y_WORD}, - {"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}, +// {"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}, @@ -78,19 +90,19 @@ static const cfg_t cfg[] = { }; static void CFG_args (int argc, char **argv) { - const cfg_t *list[] = { arg, R_args() }; - ARG_parse(argc, argv, 2, list); + 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() }; - CFG_read_config("default.cfg", 2, list); - CFG_read_config("doom2d.cfg", 2, list); + 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() }; - CFG_update_config("doom2d.cfg", "doom2d.cfg", 2, list, "generated by doom2d, do not modify"); + 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 --- */ @@ -113,22 +125,21 @@ void ERR_failinit (char *s, ...) { 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) { @@ -545,7 +556,7 @@ static void poll_events (void) { static void step (void) { poll_events(); - S_updatemusic(); + MUS_update(); Uint32 t = SDL_GetTicks(); if (t - ticks > DELAY) { ticks = t; @@ -555,7 +566,6 @@ static void step (void) { } 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) { @@ -583,23 +593,11 @@ int main (int argc, char **argv) { pl2.kwr = KEY_2; pl2.kp = KEY_E; srand(SDL_GetTicks()); - F_startup(); CFG_load(); -#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"); F_initwads(); - M_startup(); - F_allocres(); S_init(); - S_initmusic(); + MUS_init(); R_init(); G_init(); ticks = SDL_GetTicks(); @@ -612,9 +610,8 @@ int main (int argc, char **argv) { #endif CFG_save(); R_done(); - S_donemusic(); + MUS_done(); S_done(); - M_shutdown(); SDL_Quit(); return 0; }