Commit graph

131 commits

Author SHA1 Message Date
Andrei Alexeyev
fc54f3f8ce
global,mainmenu: enable Quit if quitting is allowed in kiosk mode 2024-06-04 16:31:46 +02:00
Andrei Alexeyev
8b37d1cbf2
src: the great #include massacre of 2024 2024-05-17 14:11:48 +02:00
Andrei Alexeyev
be7905d6a3
src: run upkeep 2024-05-17 04:58:47 +02:00
Andrei Alexeyev
85f74eb4bf
global: add TAISEI_KIOSK_PREVENT_QUIT env var
Defaults to 1. Set to 0 to be able to close the window in kiosk mode.
This is intended for testing and not recommended for deployment.
2024-05-04 20:07:12 +02:00
Andrei Alexeyev
ee2bb877bc
global: basic kiosk mode support 2023-06-20 01:13:50 +02:00
Andrei Alexeyev
173c8c3cc6
replay: general refactor
* Split replay.c into multiple files under replay/; improve logical
  separation of replay-related code.
* Separate replay playback state from data.
* Get rid of global static replay struct and avoid unnecessary replay
  copying.
* Replay playback and recording are now independent and may occur
  simultaneously, although this functionality is not yet exposed. This
  enables replay "re-recording" while synthesizing new desync check
  events, possibly at a different rate from the original replay.
* Rate of recorded desync check events can now be controlled with the
  TAISEI_REPLAY_DESYNC_CHECK_FREQUENCY environment variable. The default
  value is 300 as before.
* Probably other stuff I forgot about.
2021-06-16 01:43:10 +03:00
Andrei Alexeyev
8480d41b7b
Audio rewrite (#236)
This replaces SDL_mixer with an internal streaming and mixing system,
relying only on basic SDL audio support. It's also a partial refactor of
the audio API, most notably BGM-related. The BGM metadata resource type
is gone, as well as the `.bgm` files. The metadata is now stored inside
the `.opus` files directly, using standard Opus tags.
2020-06-22 17:41:03 +03:00
Andrei Alexeyev
1f1db18076
New RNG API, with crude semi-automatic misuse detection 2020-03-04 22:26:42 +02:00
Andrei Alexeyev
1acd9b4d12
sync music after skipping to bookmark 2020-03-04 22:26:40 +02:00
Andrei Alexeyev
f4d25a8409
basic "bookmark" system for skipping to specific stage portions 2020-03-04 22:26:40 +02:00
Andrei Alexeyev
5a23fb95fc
make upkeep script preserve existing copyrights 2019-08-03 20:44:22 +03:00
Andrei Alexeyev
3055901998
update my email 2019-07-03 21:00:56 +03:00
Andrei Alexeyev
180f9e3856
Emscripten compatibility (#161)
* Major refactoring of the main loop(s) and control flow (WIP)

run_at_fps() is gone 🦀

Instead of nested blocking event loops, there is now an eventloop API
that manages an explicit stack of scenes. This makes Taisei a lot more
portable to async environments where spinning a loop forever without
yielding control simply is not an option, and that is the entire point
of this change.

A prime example of such an environment is the Web (via emscripten).
Taisei was able to run there through a terrible hack: inserting
emscripten_sleep calls into the loop, which would yield to the browser.
This has several major drawbacks: first of all, every function that
could possibly call emscripten_sleep must be compiled into a special
kind of bytecode, which then has to be interpreted at runtime, *much*
slower than JITed WebAssembly. And that includes *everything* down the
call stack, too! For more information, see
https://emscripten.org/docs/porting/emterpreter.html

Even though that method worked well enough for experimenting, despite
suboptimal performance, there is another obvious drawback:
emscripten_sleep is implemented via setTimeout(), which can be very
imprecise and is generally not reliable for fluid animation. Browsers
actually have an API specifically for that use case:
window.requestAnimationFrame(), but Taisei's original blocking control
flow style is simply not compatible with it. Emscripten exposes this API
with its emscripten_set_main_loop(), which the eventloop backend now
uses on that platform.

Unfortunately, C is still C, with no fancy closures or coroutines.
With blocking calls into menu/scene loops gone, the control flow is
reimplemented via so-called (pun intended) "call chains". That is
basically an euphemism for callback hell. With manual memory management
and zero type-safety. Not that the menu system wasn't shitty enough
already. I'll just keep telling myself that this is all temporary and
will be replaced with scripts in v1.4.

* improve build system for emscripten + various fixes

* squish menu bugs

* improve emscripten event loop; disable EMULATE_FUNCTION_POINTER_CASTS

Note that stock freetype does not work without
EMULATE_FUNCTION_POINTER_CASTS; use a patched version from the
"emscripten" branch here:

    https://github.com/taisei-project/freetype2/tree/emscripten

* Enable -Wcast-function-type

Calling functions through incompatible pointers is nasal demons and
doesn't work in WASM.

* webgl: workaround a crash on some browsers

* emscripten improvements:

    * Persist state (config, progress, replays, ...) in local IndexDB
    * Simpler HTML shell (temporary)
    * Enable more optimizations

* fix build if validate_glsl=false

* emscripten: improve asset packaging, with local cache

Note that even though there are rules to build audio bundles, audio
does *not* work yet. It looks like SDL2_mixer can not work without
threads, which is a problem. Yet another reason to write an OpenAL
backend - emscripten supports that natively.

* emscripten: customize the html shell

* emscripten: force "show log" checkbox unchecked initially

* emscripten: remove quit shortcut from main menu (since there's no quit)

* emscripten: log area fixes

* emscripten/webgl: workaround for fullscreen viewport issue

* emscripten: implement frameskip

* emscripter: improve framerate limiter

* align List to at least 8 bytes (shut up warnings)

* fix non-emscripten builds

* improve fullscreen handling, mainly for emscripten

* Workaround to make audio work in chromium

emscripten-core/emscripten#6511

* emscripten: better vsync handling; enable vsync & disable fxaa by default
2019-03-09 21:32:32 +02:00
Andrei Alexeyev
4159ea1249
'upkeep' target for maintenance tasks; back to include guards; happy new year! 2019-01-23 22:10:43 +02:00
Andrei Alexeyev
b16f402040
Refactor framebuffer-related stuff (#130)
* Renderer: rename render targets to framebuffers

* Refactor framebuffer pair helper and some of the video API

* Remove hardcoded dimensions from draw_framebuffer_tex

* Make viewport a per-framebuffer property rather than a global one

* Handle config updates via the events system. React to viewport fg/bg quality change requests.
2018-07-04 11:36:16 +03:00
Andrei Alexeyev
fdfc2de543
attempt to ensure clean exit by external request (window closed, process terminated, etc.) 2018-05-19 05:01:16 +03:00
Andrei Alexeyev
58252950d4
add replay verification mode: taisei --verify-replay file.tsr 2018-04-18 02:48:28 +03:00
Andrei Alexeyev
485c9a8ed6
Happy New Year! 2018-01-04 19:14:31 +02:00
Andrei Alexeyev
5b7de7d8a2
gamepad: basic support for trigger buttons (analog and digital) 2017-12-30 17:39:42 +02:00
Andrei Alexeyev
48b13cd83a
frameskip option for slow GPUs 2017-12-26 13:07:40 +02:00
Andrei Alexeyev
29acd5f58a meson: intel intrinsics, various improvements 2017-12-21 03:58:54 +01:00
Andrei Alexeyev
ef67a16867
WIP event system rewrite. text input missing 2017-10-01 00:43:18 +03:00
Andrei "Akari" Alexeyev
7c9e54a71d
update copyright and credits 2017-09-12 04:28:15 +03:00
Andrei "Akari" Alexeyev
d41bb02753 Replaced TAISEI_SANIC with --frameskip/-f
and fixed some more cli issues
2017-04-03 02:30:12 +03:00
Andrei "Akari" Alexeyev
45da155cb2 Implemented a simple and consistent logging subsystem
The goal of this change is mainly to clean up Taisei's codebase and
improve its console output. I've been frustrated by files littered with
inconsistent printf/fprintf/warnx/errx calls for a long time, and now I
actually did something about it.

All the above functions are now considered deprecated and result in a
compile-time warning when used. Instead, the following macros should be
used:

    log_debug(format, ...)
    log_info(format, ...)
    log_warn(format, ...)
    log_err(format, ...)

As you can see, all of them have the same printf-like interface. But
they have different functionality and purpose:

    log_debug is intended for very verbose and specific information. It
    does nothing in release builds, much like assert(), so don't use
    expressions with side-effects in its arguments.

    log_info is for various status updates that are expected during
    normal operation of the program.

    log_warn is for non-critical failures or other things that may be
    worth investigating, but don't inherently render the program
    non-functional.

    log_err is for when the only choice is to give up. Like errx, it
    also terminates the program. Unlike errx, it actually calls abort(),
    which means the cleanup functions are not ran -- but on the other
    hand, you get a debuggable backtrace. However, if you're trying to
    catch programming errors, consider using assert() instead.

All of them produce output that contains a timestamp, the log level
identifier, the calling function's name, and the formatted message.

The newline at the end of the format string is not required -- no, it is
actually *prohibited*. The logging system will take care of the line
breaks by itself, don't litter the code with that shit.

Internally, the logging system is based on the SDL_RWops abstraction,
and may have multiple, configurable destinations. This makes it easily
extensible. Currently, log_debug and log_info are set to write to
stdout, log_warn and log_err to stderr, and all of them also to the file
log.txt in the Taisei config directory.

Consequently, the nasty freopen hacks we used to make Taisei write to
log files on Windows are no longer needed -- which is a very good thing,
considering they probably would break if the configdir path contains
UTF-8 characters. SDL_RWFromFile does not suffer this limitation.

As an added bonus, it's also thread-safe.

Note about printf and fprintf: in very few cases, the logging system is
not a good substitute for these functions. That is, when you care about
writing exactly to stdout/stderr and about exactly how the output looks.

However, I insist on keeping the deprecation warnings on them to not
tempt anyone to use them for logging/debugging out of habit and/or
laziness.

For this reason, I've added a tsfprintf function to util.c. It is
functionally identical to fprintf, except it returns void. Yes, the name
is deliberately ugly. Avoid using it if possible, but if you must, only
use it to write to stdout or stderr. Do not write to actual files with
it, use SDL_RWops.
2017-03-13 07:45:01 +02:00
Andrei "Akari" Alexeyev
dacbf96427 moved util functions from global to where they make a bit more sense 2017-03-06 03:24:47 +02:00
Andrei "Akari" Alexeyev
0ebf29660f brutally murdered various malloc/strcat/strcpy constructs 2017-03-06 02:03:06 +02:00
Andrei "Akari" Alexeyev
ca16c30966 large refactoring WIP
windows & osx untested
bgm untested
too many changes to comment on
2017-03-05 00:39:17 +02:00
Andrei "Akari" Alexeyev
f61e77d351 pleasing the stages array haters 2017-02-27 16:27:48 +02:00
Andrei "Akari" Alexeyev
0091c7aca7 Refactored the gl loader into a polyglot macro monstrosity
We no longer link to libGL by default. All GL functions are loaded
dynamically through SDL apis. Use -DLINK_TO_LIBGL to enable linking, in
which case Taisei won't try to dynamically load any of the gl functions.

Previously we used a strange inconsistent setup where some functions
were loaded dynamically and others pulled from the linked library.

We also no longer link to libGLU even if LINK_TO_LIBGL is set. The only
function we used from that library was gluPerspective. taiseigl now
provides a simple substitute via glFrustum.

The SDL2 gl headers are now used instead of the system ones, this should
be more portable. The taiseigl.h header contains generated code
partially based on content from those headers. It also doubles as a
python3 script that actually generates that code and inserts it into
itself. It scans the Taisei source tree for gl* calls and generates code
only for the functions we use, and a few manually specified ones that
are called indirectly.

Assumptions such as "linux = glx" are no longer made. SDL takes care of
platform specifics, as it should.

The GL_EXT_draw_instanced/GL_ARB_draw_instanced extension detection has
been improved. Taisei should be able to figure out which one to use
without a compile-time check, and support for the ARB version has been
actually implemented for the laser snippet loader. I've tested it on
Windows 8 with Intel drivers that don't support the EXT version but do
support the ARB one, instanced drawing works and the lasers don't lag!
OSX should benefit from this change as well, although I've not yet
tested the OSX build, beyond simply compiling it.
2017-02-25 15:24:54 +02:00
Andrei "Akari" Alexeyev
b0abd177ac Removed redundant null checks before free() calls
free(NULL) is guaranteed to be a no-op by the C standard, so let's not
clutter the code with those.
2017-02-23 16:05:55 +02:00
Andrei "Akari" Alexeyev
397719a2a2 Switched from GNU C99 to Standard C11. Enabled pedantic warnings.
Fixed all warnings and compile errors.
Confirmed successful compilation without warnings for linux (gcc,
clang), windows (gcc-mingw), osx (clang-osxcross).
2017-02-23 13:16:52 +02:00
Andrei "Akari" Alexeyev
30db5c8fd6 Support for viewing replays specified on the command line
$ taisei replay /path/to/replay.tsr
$ curl http://example.com/replay.tsr | taisei replay /dev/stdin
2017-02-21 22:31:46 +02:00
Andrei "Akari" Alexeyev
1e6011433c Initial support for single-spell stages
Adapted all of the current spellcards into spellstages, which will
later be used in a spell practice mode a-la IN.
For now they are only accessible through the stage select menu or
by specifying their ID on the command line; both available only
if you built with -DTAISEI_DEBUG=1
2017-02-19 03:28:00 +01:00
Andrei "Akari" Alexeyev
f92da23638 config: preserve unknown options in the config file 2017-02-18 06:18:13 +02:00
Andrei "Akari" Alexeyev
32f7edd24e Refactored config into a macro hell 2017-02-17 18:03:49 +02:00
Andrei "Akari" Alexeyev
67b0c4da5e fixed screenshot crash when windows is resized 2017-02-15 14:40:35 +02:00
Andrei "Akari" Alexeyev
9a7a874783 Use the standard bool type instead of that stupid enum
Also removed all of the annoying trailing tabs/whitespaces
2017-02-11 05:56:47 +02:00
Andrei "Akari" Alexeyev
f2386657f5 Updated replay structure, added checks to load routine to make sure that corrupted or garbage data in the replay won't crash the game 2017-02-09 02:13:06 +02:00
Andrei "Akari" Alexeyev
22f51b9652 Merge branch 'master' into replaysagain 2017-02-07 06:26:51 +02:00
Andrei "Akari" Alexeyev
dcfec0ffad Use scancodes instead of keycodes for keyboard input
See https://wiki.libsdl.org/CategoryKeyboard for the implications of this
2017-02-07 06:26:04 +02:00
Andrei "Akari" Alexeyev
b38e41e681 Added extra checks to prevent and help debug incorrect usage of some tsrand functions 2017-02-05 22:16:50 +02:00
Andrei "Akari" Alexeyev
3d639aae52 Added a frameskip mode, mainly to debug replays 2017-02-05 20:25:18 +02:00
Andrei "Akari" Alexeyev
167e9e12f1 Initial migration to SDL2 (WIP) 2017-02-04 04:56:40 +02:00
makise-homura
815ae7b23b Added background music subsystem. 2017-01-24 16:40:57 +03:00
Andrew "Akari" Alexeyew
27377a9ee3 Fixed corrupted screenshots on windows 2012-09-09 20:28:21 +03:00
Andrew "Akari" Alexeyew
536b5b7f09 "Fixed" a stupid input workaround. It doesn't depend on keyboard anymore. 2012-08-17 21:58:23 +03:00
Andrew "Akari" Alexeyew
cf72d8dee3 event abstraction layer 2012-08-13 18:50:28 +03:00
laochailan
c4e0298922 blocked ingame menu, instantselect flag 2012-08-12 20:16:40 +02:00
Andrew "Akari" Alexeyew
f5f03275fc Merge branch 'master' of github.com:laochailan/taisei 2012-08-10 23:14:53 +03:00