2010-10-12 10:55:23 +02:00
|
|
|
/*
|
2011-03-05 13:44:21 +01:00
|
|
|
* This software is licensed under the terms of the MIT-License
|
2017-02-11 04:52:08 +01:00
|
|
|
* See COPYING for further information.
|
2011-03-05 13:44:21 +01:00
|
|
|
* ---
|
2019-01-23 21:10:43 +01:00
|
|
|
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
|
|
|
|
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@alienslab.net>.
|
2010-10-12 10:55:23 +02:00
|
|
|
*/
|
|
|
|
|
2017-11-25 20:45:11 +01:00
|
|
|
#include "taisei.h"
|
|
|
|
|
2010-10-12 10:55:23 +02:00
|
|
|
#include "global.h"
|
|
|
|
|
|
|
|
Global global;
|
|
|
|
|
2017-04-03 01:30:12 +02:00
|
|
|
void init_global(CLIAction *cli) {
|
2017-02-11 04:52:08 +01:00
|
|
|
memset(&global, 0, sizeof(global));
|
2017-02-05 21:16:50 +01:00
|
|
|
|
|
|
|
tsrand_init(&global.rand_game, time(0));
|
|
|
|
tsrand_init(&global.rand_visual, time(0));
|
2012-07-27 19:11:45 +02:00
|
|
|
tsrand_switch(&global.rand_visual);
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-07-14 19:46:03 +02:00
|
|
|
memset(&global.replay, 0, sizeof(Replay));
|
2017-02-05 19:25:18 +01:00
|
|
|
|
2017-04-03 01:30:12 +02:00
|
|
|
global.replaymode = REPLAY_RECORD;
|
|
|
|
global.frameskip = cli->frameskip;
|
2017-02-05 19:25:18 +01:00
|
|
|
|
2018-04-18 01:17:28 +02:00
|
|
|
if(cli->type == CLI_VerifyReplay) {
|
|
|
|
global.is_headless = true;
|
|
|
|
global.is_replay_verification = true;
|
|
|
|
global.frameskip = 1;
|
|
|
|
} else if(global.frameskip) {
|
2017-04-03 01:30:12 +02:00
|
|
|
log_warn("FPS limiter disabled. Gotta go fast! (frameskip = %i)", global.frameskip);
|
2017-02-05 19:25:18 +01:00
|
|
|
}
|
2017-12-26 12:07:40 +01:00
|
|
|
|
|
|
|
fpscounter_reset(&global.fps.logic);
|
|
|
|
fpscounter_reset(&global.fps.render);
|
|
|
|
fpscounter_reset(&global.fps.busy);
|
2011-04-25 19:40:21 +02:00
|
|
|
}
|
2017-09-29 21:03:49 +02:00
|
|
|
|
|
|
|
// Inputdevice-agnostic method of checking whether a game control is pressed.
|
|
|
|
// ALWAYS use this instead of SDL_GetKeyState if you need it.
|
|
|
|
// XXX: Move this somewhere?
|
|
|
|
bool gamekeypressed(KeyIndex key) {
|
2017-12-30 16:38:35 +01:00
|
|
|
return SDL_GetKeyboardState(NULL)[config_get_int(KEYIDX_TO_CFGIDX(key))] || gamepad_game_key_pressed(key);
|
2017-09-29 21:03:49 +02:00
|
|
|
}
|
2018-05-19 04:01:16 +02:00
|
|
|
|
|
|
|
static SDL_atomic_t quitting;
|
|
|
|
|
|
|
|
void taisei_quit(void) {
|
|
|
|
if(SDL_AtomicCAS(&quitting, 0, 1)) {
|
|
|
|
log_info("Exit requested");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool taisei_quit_requested(void) {
|
|
|
|
return SDL_AtomicGet(&quitting);
|
|
|
|
}
|