X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fsdl%2Fmain.c;h=1c16dc33307100048c40af58c3a38ee2060b7319;hb=9f3ca6bf02300e3dc72e3c2085a8e35aa9242678;hp=36b32798913dd64aa89f179ecec0dee2a9c80a8e;hpb=7b2f2285593458477b8185e62099d61975faf7d4;p=flatwaifu.git diff --git a/src/sdl/main.c b/src/sdl/main.c index 36b3279..1c16dc3 100644 --- a/src/sdl/main.c +++ b/src/sdl/main.c @@ -28,8 +28,6 @@ #include #include #include // srand exit -#include // strcasecmp -#include #include #include "system.h" #include "input.h" @@ -38,9 +36,11 @@ #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 "args.h" // ARG_parse #include "memory.h" // M_startup #include "game.h" // G_init G_act #include "sound.h" // S_init S_done @@ -56,6 +56,63 @@ static int quit = 0; static SDL_Surface *surf = NULL; static int mode = MODE_NONE; static int text_input; +static videomode_t vlist; + +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}, + {"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}, + {"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}, + {"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() }; + ARG_parse(argc, argv, 2, 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); +} + +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"); +} /* --- error.h --- */ @@ -151,6 +208,47 @@ int Y_set_videomode_software (int w, int h, int fullscreen) { return s != NULL; } +static void init_videomode_list (Uint32 flags) { + int i, n; + SDL_Rect **r; + if (vlist.modes != NULL) { + free(vlist.modes); + vlist.modes = NULL; + vlist.n = 0; + } + r = SDL_ListModes(NULL, flags); + if (r == (SDL_Rect **)-1) { + if ((flags & SDL_FULLSCREEN) == 0) { + init_videomode_list(flags | SDL_FULLSCREEN); + } + } else if (r != (SDL_Rect**)0) { + n = 0; + while (r[n] != NULL) { + n++; + } + vlist.modes = malloc(n * sizeof(videomode_size_t)); + if (vlist.modes != NULL) { + vlist.n = n; + for (i = 0; i < n; i++) { + vlist.modes[i] = (videomode_size_t) { + .w = r[i]->w, + .h = r[i]->h + }; + } + } + } +} + +const videomode_t *Y_get_videomode_list_opengl (int fullscreen) { + init_videomode_list(SDL_OPENGL | (fullscreen ? SDL_FULLSCREEN : 0)); + return &vlist; +} + +const videomode_t *Y_get_videomode_list_software (int fullscreen) { + init_videomode_list(SDL_SWSURFACE | SDL_HWPALETTE | (fullscreen ? SDL_FULLSCREEN : 0)); + return &vlist; +} + void Y_get_videomode (int *w, int *h) { if (mode != MODE_NONE) { *w = surf->w;