# HG changeset patch # User David Demelier # Date 1679667331 -3600 # Node ID e070fdcc592b219b448a34fba7a822a3f632a90b # Parent f9e85d0aca74414fcf627cc4e3006a92dd623971 misc: various cleanups diff -r f9e85d0aca74 -r e070fdcc592b .hgignore --- a/.hgignore Tue Mar 21 14:08:15 2023 +0100 +++ b/.hgignore Fri Mar 24 15:15:31 2023 +0100 @@ -13,6 +13,9 @@ # Code and friends. ^\.vscode +# clangd +^\.cache + # vim/emacs specific. ^tags$ ^tags\.lock$ diff -r f9e85d0aca74 -r e070fdcc592b CMakeLists.txt --- a/CMakeLists.txt Tue Mar 21 14:08:15 2023 +0100 +++ b/CMakeLists.txt Fri Mar 24 15:15:31 2023 +0100 @@ -56,7 +56,7 @@ BOOL "Enable doxygen documentation") mlk_option(MLK_WITH_EXAMPLES On BOOL "Enable examples") -mlk_option(MLK_WITH_NLS Off +mlk_option(MLK_WITH_NLS On BOOL "Enable NLS support") mlk_option(MLK_WITH_TESTS On BOOL "Enable unit tests") diff -r f9e85d0aca74 -r e070fdcc592b INSTALL.md --- a/INSTALL.md Tue Mar 21 14:08:15 2023 +0100 +++ b/INSTALL.md Fri Mar 24 15:15:31 2023 +0100 @@ -6,17 +6,17 @@ Requirements ============ -- C11 compliant compiler. -- [GNU Make][], Make build system. +- C23 compliant compiler. +- [CMake][], Make build system. - [Jansson][], JSON parsing library. - [SDL2][], Multimedia library. - [SDL2_image][], Image loading addon for SDL2. - [SDL2_mixer][], Audio addon for SDL2. - [SDL2_ttf][], Fonts addon for SDL2. -Molko's Engine is mostly written in pure C99 with a very limited POSIX -extensions (including `stat`, `strlcpy`, `fmemopen`) but where support is -missing fallback implementations are provided. +Molko's Engine is mostly written in C23 with a very limited POSIX extensions +(including `stat`, `strlcpy`, `fmemopen`) but where support is missing fallback +implementations are provided. Supported platforms =================== @@ -28,32 +28,33 @@ - Linux (musl/amd64, musl/aarch64, glibc/amd64). - FreeBSD (amd64). - OpenBSD (amd64). -- macOS +- NetBSD (amd64). +- macOS (Monterey, Ventura). Basic installation ================== Quick install. - $ bsdtar -xvf molko-x.y.z-tar.xz + $ tar -xvf molko-x.y.z-tar.xz $ cd molko-x.y.z - $ make - # sudo make install + $ cmake -S. -Bbuild + $ cmake --build build + $ cmake --install build Available options ================= -The following make variables as available: - -- `WITH_DEBUG`: Disable optimizations and turn on debug symbols (default: no). - -The following make variables changes installation directories: +The following cmake options as available: -- `PREFIX`: Root install path (default: /usr/local). -- `LIBDIR`: Libraries directory (default: $PREFIX/lib). -- `INCDIR`: C header directory (default: $PREFIX/include). - -Booleans options can be set to `yes` or `no` (case sensitive). +- `MLK_WITH_DOXYGEN`: enable doxygen documentation (default: On, requires + doxygen). +- `MLK_WITH_EXAMPLES`: enable examples (default: on). +- `MLK_WITH_NLS`: enable i18n (default: on, requires gettext). +- `MLK_WITH_TESTS`: enable unit tests (default: on). +- `MLK_WITH_TESTS_GRAPHICAL`: enable unit tests that require a window + context(default: on). +- `MLK_WITH_CMAKEDIR`: root directory for CMake files (default: LIBDIR/cmake). Platform: macOS --------------- @@ -63,11 +64,11 @@ You will need the following packages: -- jansson -- sdl2 -- sdl2_image -- sdl2_mixer -- sdl2_ttf +- *jansson* +- *sdl2* +- *sdl2_image* +- *sdl2_mixer* +- *sdl2_ttf* Platform: Windows ----------------- @@ -79,8 +80,6 @@ Once you have MSYS2 installed, simply install the following packages from the appropriate MinGW shell prior to the chapter above. -- *make* -- *mingw-w64-clang-x86_64-gcc* - *mingw-w64-clang-x86_64-SDL2* - *mingw-w64-clang-x86_64-SDL2_image* - *mingw-w64-clang-x86_64-SDL2_mixer* @@ -99,17 +98,16 @@ recommended to install all of them in a same directory and hierarchy as following: -- /bin -- /lib -- /include +- *dir/bin* +- *dir/lib* +- *dir/include* -Building with Visual Studio is only supported through `clang-cl` which should be -installed as individual component from the Visual Studio installer. You also -need a POSIX compliant toolset such as [MSYS2][] and add it to your path. +Make sure *dir/bin* is in your `PATH` and adjust `CMAKE_PREFIX_PATH` before +running `cmake`. -[brew][]: http://brew.sh -[CMake][]: http://cmake.org -[Jansson][]: http://www.digip.org/jansson +[brew]: http://brew.sh +[CMake]: http://cmake.org +[Jansson]: http://www.digip.org/jansson [MSYS2]: http://www.msys2.org [SDL2]: http://libsdl.org [SDL2_image]: https://www.libsdl.org/projects/SDL_image diff -r f9e85d0aca74 -r e070fdcc592b README.md --- a/README.md Tue Mar 21 14:08:15 2023 +0100 +++ b/README.md Fri Mar 24 15:15:31 2023 +0100 @@ -1,69 +1,22 @@ Molko's Engine ============== -The Molko's Engine is a C and framework to write 2D RPG games in a portable -manner. It is designed in mind to be flexible, simple and convenient to use. +The Molko's Engine is a C framework to write 2D RPG games in a portable manner. +It is designed in mind to be flexible, simple and convenient to use. It has the following features: -- Written in C99, +- Written in C23, - Portable (Windows, macOS and UNIX likes systems), - Simple, flexible, - Well documented, - Virtual file system support. -- Usable in both C or Javascript. - Can embed resources using `mlk-bcc`. -Javascript quick startup ------------------------- - -The `mlk-run` executable exposes the Javascript API and start a game from a -directory or a .mlk file (which is a .zip file with a .mlk extension). - -Hello world in Javascript: - - mkdir superluigi - -Add the following content in superluigi/main.js: - -```js -var w = new Window("Super Luigi, number one", 640, 480); -var run = true; - -while (run) { - var ev; - - while ((ev = Event.poll())) { - switch (ev.type) { - case Event.Type.QUIT: - run = false; - break; - default: - break; - } - - Painter.color = 0xFFFFFFFF; - Painter.clear(); - Painter.present(); - } -} -``` - -Finally run the game using `mlk-run superluigi`. - -You can also create a .zip file with a .mlk extension and `mlk-run` will be able -to use content from it. - - cd superluigi - zip -r ../superluigi.mlk . - cd .. - mlk-run superluigi.mlk - Documentation ------------- -Use `mkdocs serve` inside the **doc** directory to see the user and developer -documentation. +Use the `doxygen` CMake target to build the documentation. Author ------ diff -r f9e85d0aca74 -r e070fdcc592b libmlk-rpg/mlk/rpg/tileset-loader-file.c --- a/libmlk-rpg/mlk/rpg/tileset-loader-file.c Tue Mar 21 14:08:15 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/tileset-loader-file.c Fri Mar 24 15:15:31 2023 +0100 @@ -64,7 +64,6 @@ mlk_alloc_free(self->tileanimations); } - static void * expand(void **array, size_t n, size_t w) { diff -r f9e85d0aca74 -r e070fdcc592b libmlk-rpg/mlk/rpg/tileset-loader-file.h --- a/libmlk-rpg/mlk/rpg/tileset-loader-file.h Tue Mar 21 14:08:15 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/tileset-loader-file.h Fri Mar 24 15:15:31 2023 +0100 @@ -23,7 +23,7 @@ * \file mlk/rpg/tileset-loader-file.h * \brief Tileset file loader implementation * - * This convenient tileset loader loads tilesets from file and its associative + * This convenient tileset loader loads a tileset from file and its associative * resources relative to the tileset file directory. * * It also allocate memory for individual element and as such must be kept @@ -51,16 +51,17 @@ * \return 0 on success or -1 on error */ int -mlk_tileset_loader_file_init(struct mlk_tileset_loader *loader, const char *filename); +mlk_tileset_loader_file_init(struct mlk_tileset_loader *loader, + const char *filename); /** * Cleanup allocated resources by this file loader. * - * \pre file != NULL - * \param file the file loader + * \pre loader != NULL + * \param loader the file loader */ void -mlk_tileset_loader_file_finish(struct mlk_tileset_loader *file); +mlk_tileset_loader_file_finish(struct mlk_tileset_loader *loader); #if defined(__cplusplus) } diff -r f9e85d0aca74 -r e070fdcc592b mlk-map/mlk-map.c --- a/mlk-map/mlk-map.c Tue Mar 21 14:08:15 2023 +0100 +++ b/mlk-map/mlk-map.c Fri Mar 24 15:15:31 2023 +0100 @@ -18,7 +18,6 @@ #include #include -#include #include #include @@ -26,7 +25,7 @@ #include -static bool +static inline int is_layer(const char *name) { return strcmp(name, "background") == 0 || diff -r f9e85d0aca74 -r e070fdcc592b mlk-tileset/mlk-tileset.c --- a/mlk-tileset/mlk-tileset.c Tue Mar 21 14:08:15 2023 +0100 +++ b/mlk-tileset/mlk-tileset.c Fri Mar 24 15:15:31 2023 +0100 @@ -175,11 +175,8 @@ } int -main(int argc, char *argv[]) +main(void) { - (void)argc; - (void)argv; - json_t *document; json_error_t error;