This fixes a nasty bug that manifests on windows when building without
precompiled headers. util/stringops.h used to silently replace strdup
with a macro that's compatible with mem_free(). This header would
typically be included everywhere due to PCH, but without it the strdup
from libc would sometimes be in scope. On most platforms mem_free() is
equivalent to free(), but not on windows, because we have to use
_aligned_free() there. Attempting to mem_free() the result of a libc
strdup() would segfault in such a configuration.
Avoid the footgun by banning strdup() entirely. Maybe redefining libc
names isn't such a great idea, who knew?
Introduces wrappers around memory allocation functions in `memory.h`
that should be used instead of the standard C ones.
These never return NULL and, with the exception of `mem_realloc()`,
zero-initialize the allocated memory like `calloc()` does.
All allocations made with the memory.h API must be deallocated with
`mem_free()`. Although standard `free()` will work on some platforms,
it's not portable (currently it won't work on Windows). Likewise,
`mem_free()` must not be used to free foreign allocations.
The standard C allocation functions are now diagnosed as deprecated.
They are, however, available with the `libc_` prefix in case interfacing
with foreign APIs is required. So far they are only used to implement
`memory.h`.
Perhaps the most important change is the introduction of the `ALLOC()`,
`ALLOC_ARRAY()`, and `ALLOC_FLEX()` macros. They take a type as a
parameter, and allocate enough memory with the correct alignment for
that type. That includes overaligned types as well. In most
circumstances you should prefer to use these macros. See the `memory.h`
header for some usage examples.
Most client code no longer needs to care about paddings at all, aside
from some very special cases involving dynamic creation of padded
sprites. So far we only have one known example of this in portrait_render().
This should let us optimize most of our sprites with autotrimming in the
future.
Additionally, support for deprecated offset_{x,y} keys in sprite files
has been removed.
this means glm_mat_proj_perspective is no longer meant to be called by the stage code. The parameters are set to sensible defaults of the pbr stages.
I found that the old stages use STAGE3D_DEFAULT_ASPECT which is somehow stretched. I did not change the behavior but added a FIXME comment to lines that should at some point just be deleted to use the correct default aspect.
I did not fix the extra stage code to avoid conflicts.
* basic stage 6 structure (nothing here yet)
* it compiles and runs (needs testing)
* reindent
* missing import
* fix baryons
* import cleanups
* moving spells from elly.c to their spellcard sources
* code review changes, and some additional cleanup
* more PR changes, removing more dead code
* clean up some imports, move functions to spellcards
* remove dual initalization
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.
* new story doc for Taisei Project
* more romanization fixes
* new Reimu script, yay
* accidentally stomped on some dashes
* typo in iku's dialogue
* marisa dialogue, complete!
* formatting fixes, and some timing changes
* youmu script! all three routes complete!
* youmu typoes
* remove trailing whitespaces, use smartquotes, move a couple of words around
* good/bad endings complete!
* remove unneccesary whitespaces
* revert --
* story doc typo
* formatting issues, a couple of word changes
* smart-quotes
* typoes and minor grammar changes to dialogue/story/endings
* one last typo in Marisa's dialogue
* correct smartquotes on STORY.txt
This replaces the r_mat_foo functions with specialized r_mat_{mv,tex,proj}_foo counterparts that operate explicitly on the modelview, texture, and projection matrix stacks respectively.
* implement player spellcard declarations on bomb
* stagedraw: move "bottom text" to a separate (higher) layer
* update boss spell declaration effect
* import afensorm's character portrait art
* improve dialog visuals
* acknowledge afensorm in credits and COPYING
* 'alphamap' functionality; effects for wriggle and youmu portraits
* update afens art
* add cirno alphamap
* dialog: draw active speaker above other other
* charselect: use r_draw_sprite
* Switch BGMs to Opus
* Switch SFX to Opus; use floating-point mixing
* opus sfx: support resampling via SDL_AudioStream
* bump SDL2 version requirement to 2.0.6
2.0.5 doesn't have the SDL_AudioStream API, and is ancient anyway.
* 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
* Added (and fixed) a few useful warnings
* Removed some dead code
* Cleaned up the build system files a bit
* Once again separated ZIP support from data packaging
* Converted macOS cross-compilation options into cross-file properties