Compare commits

...

5 Commits

Author SHA1 Message Date
Xavier Del Campo Romero 3e341ff440
README.md: Update according to ESP32 port 2024-01-30 23:49:22 +01:00
Xavier Del Campo Romero 986f0d9a37
esp32: Import Geekbit library 2024-01-30 23:49:22 +01:00
Xavier Del Campo Romero decf2bd092
Add FindGeekbit.cmake 2024-01-30 23:49:22 +01:00
Xavier Del Campo Romero 52571b0f5a
gfx: #undef quad
Surprisingly, esp-idf #includes files such as sys/types.h when pulling
other standard header files, even when not explicitly defined. While
this is not a serious issue, incredibly their sys/types.h implementation
uses "#define quad", therefore breaking user code such as anything
related to "struct quad".
2024-01-30 23:49:22 +01:00
Xavier Del Campo Romero 77c4420c06
std/main.c: Use engine_main 2024-01-30 23:49:22 +01:00
10 changed files with 123 additions and 14 deletions

View File

@ -112,7 +112,7 @@ building `enet`.
A stripped version of the executable, as well as game assets, will be
located in `build/cdimg`.
#### Dependencies
##### Dependencies
A cross-compiled `i386-mingw32` version of all required dependencies
is needed before building `jancity`.
@ -126,6 +126,32 @@ of this writing, so it is provisionally provided on
Read [the documentation](doc/BUILD-win9x.md) for further reference on
how to build the dependencies from source.
#### Espressif ESP32
```sh
. $IDF_PATH/export.sh
ENETDIR=<enet-prefix> \
cmake -B build -DCMAKE_TOOLCHAIN_FILE=cmake/win9x-toolchain.cmake
cmake --build build
```
Where:
- `ENETDIR` is the path to the cross-compiled version for `enet`.
##### Dependencies
[`esp-idf`](https://github.com/espressif/esp-idf) is required to build this
or any ESP32-related project. The `release/v5.1` branch is assumed here.
As pointed out by
[their documentation](https://docs.espressif.com/projects/esp-idf/en/v5.1.2/esp32/api-guides/build-system.html?highlight=idf_path#initialization),
remember to assign the `IDF_PATH` environment variable to the directory
where `esp-idf` is located.
`esp-idf` requires to build `enet` using a custom CMake wrapper on top of it.
For this project, this has been provided by the
[`enet-esp32`](https://gitea.privatedns.org/xavi/enet-esp32) repository.
## License
Unless stated otherwise, **jancity** follows the license described by the

84
cmake/FindGeekbit.cmake Normal file
View File

@ -0,0 +1,84 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
FindGeekbit
-----------
Find Geekbit (an open source software development kit for the Geekbit
handheld video game console) libraries and header files.
Imported targets
^^^^^^^^^^^^^^^^
This module defines the following :prop_tgt:`IMPORTED` targets:
``geekbit::geekbit``,
The geekbit library, if found.
Result variables
^^^^^^^^^^^^^^^^
This module will set the following variables in your project:
``GEEKBIT_FOUND``
true if geekbit libraries and header files were found.
``GEEKBIT_VERSION``
geekbit release version
``GEEKBIT_INCLUDE_DIRS``
the directory containing the geekbit headers; note
``GEEKBIT_INCLUDE_DIRS`` is also required
``GEEKBIT_LIBRARIES``
geekbit libraries to be linked; note ``GEEKBIT_LIBRARIES`` is also
required
#]=======================================================================]
find_path(GEEKBIT_INCLUDE_DIRS
NAMES
geekbit/gb.h
HINTS
ENV GEEKBIT_PATH
PATH_SUFFIXES
include
)
find_library(GEEKBIT_LIBRARIES
NAMES geekbit
HINTS
ENV GEEKBIT_PATH
PATH_SUFFIXES
lib
)
# Header files are meant to be included as "geekbit/<file>.h". Therefore,
# the "geekbit" directory must not be referred to by GEEKBIT_INCLUDE_DIRS.
string(REGEX REPLACE "include/geekbit[/]*$"
"include" GEEKBIT_INCLUDE_DIRS ${GEEKBIT_INCLUDE_DIRS})
if(GEEKBIT_INCLUDE_DIRS AND EXISTS "${GEEKBIT_INCLUDE_DIRS}/geekbit/version.h")
set(version_regex "^#define[ \t]+GEEKBIT_VERSION_STRING[ \t]+\"([0-9\.]+)\"$")
file(STRINGS "${GEEKBIT_INCLUDE_DIRS}/geekbit/version.h" GEEKBIT_VERSION_LINE REGEX ${version_regex})
string(REGEX REPLACE ${version_regex} "\\1" GEEKBIT_VERSION "${GEEKBIT_VERSION_LINE}")
unset(GEEKBIT_VERSION_LINE)
unset(version_regex)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Geekbit
REQUIRED_VARS
GEEKBIT_LIBRARIES GEEKBIT_INCLUDE_DIRS
VERSION_VAR
GEEKBIT_VERSION
)
if(GEEKBIT_FOUND)
if(NOT TARGET Geekbit::Geekbit)
add_library(Geekbit::Geekbit INTERFACE IMPORTED)
target_include_directories(Geekbit::Geekbit
INTERFACE "${GEEKBIT_INCLUDE_DIRS}")
set_target_properties(Geekbit::Geekbit PROPERTIES
IMPORTED_LOCATION "${GEEKBIT_LIBRARIES}")
endif()
endif()

View File

@ -1,3 +1,4 @@
find_package(Geekbit 0.0.1 REQUIRED)
set(cdroot ${CMAKE_BINARY_DIR})
if(NOT DEFINED ENV{IDF_PATH})

View File

@ -35,7 +35,7 @@ set(interfaces
target_compile_options(${PROJECT_NAME} PUBLIC ${cflags})
# Dependencies for main.c
target_link_libraries(${PROJECT_NAME} PRIVATE main system menu)
target_link_libraries(${PROJECT_NAME} PRIVATE main)
foreach(c ${components})
add_subdirectory("${c}")

View File

@ -3,6 +3,8 @@
#include <stdbool.h>
#undef quad
#ifdef __cplusplus
extern "C"
{

View File

@ -4,6 +4,8 @@
#include <stddef.h>
#include <stdlib.h>
#undef quad
int quad_from_sprite(const struct sprite *const s, struct quad *const q)
{
return -1;

View File

@ -1,9 +1,9 @@
#ifndef GFX_H
#define GFX_H
#include <gfx/port.h>
#include <stdbool.h>
#include <stdio.h>
#include <gfx/port.h>
#ifdef __cplusplus
extern "C"

View File

@ -1,14 +1,6 @@
#include <menu.h>
#include <system.h>
#include <stdlib.h>
#include <engine_main.h>
int main(void)
{
int ret = EXIT_SUCCESS;
if (system_init() || menu())
ret = EXIT_FAILURE;
system_deinit();
return ret;
return engine_main();
}

View File

@ -21,6 +21,7 @@ elseif(ESP32_BUILD)
set(src "esp32/src/system.c")
set(inc ${inc} "esp32/inc")
set(privinc ${privinc} "esp32/privinc")
set(privdeps ${privdeps} Geekbit::Geekbit)
endif()
add_library(system ${src})

View File

@ -1,5 +1,6 @@
#include <system.h>
#include <system_private.h>
#include <geekbit/gb.h>
#include <gfx.h>
#include <net.h>
#include <sfx.h>
@ -21,5 +22,5 @@ void system_deinit(void)
int system_init(void)
{
return -1;
return gb_init();
}