diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index bfc7dfd..33edcec 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -7,20 +7,21 @@ "${workspaceFolder}/src", "${workspaceFolder}/src/components", "${workspaceFolder}/core", - "${workspaceFolder}/core/host/generic", + "${workspaceFolder}/core/host/linux", "/usr/include/lua5.4", "/usr/include/pipewire-0.3", "/usr/include/spa-0.2", "/usr/include/libdrm", "/usr/include/libdecor-0", - "/usr/include/x86_64-linux-gnu", - "${env:HOME}/.local/share/fxsdk/sysroot/sh3eb-elf/include" + "/usr/include/x86_64-linux-gnu"//, +// "${env:HOME}/.local/share/fxsdk/sysroot/sh3eb-elf/include" ], "compilerPath": "/usr/bin/gcc", "defines": [ "_REENTRANT", "FXCG50", - "TARGET_FXCG50" + "TARGET_FXCG50", + "ASSET_FILE_NAME=\"game.data\"" ], "cStandard": "c17", "browse": { diff --git a/Makefile b/Makefile index eb2789f..02cc07b 100644 --- a/Makefile +++ b/Makefile @@ -82,7 +82,6 @@ $(ASSET_OUTPUT): FORCE FORCE: -.PHONY: clean clean-all run print-var-% clean: $(Q)rm -rf $(BUILD_DIR) @@ -94,3 +93,5 @@ run: all print-var-% : @echo $($*) + +.PHONY: clean clean-all run print-var-% \ No newline at end of file diff --git a/assets/maps/tiled-extensions/install.sh b/assets/maps/tiled-extensions/install.sh old mode 100644 new mode 100755 diff --git a/configure b/configure old mode 100644 new mode 100755 index 0ae54a2..5350dc2 --- a/configure +++ b/configure @@ -7,7 +7,7 @@ # # -# Project settings no matter current and target hosts +# Project settings # CONFIG_FILE="config.mk" @@ -34,19 +34,23 @@ for i in "$@"; do TARGET_HOST="${i#*=}" shift ;; + --current-host=*) HOST="${i#*=}" shift ;; + --clean) CLEAN=1 EXIT_AFTER_CLEAN=1 shift ;; + --reconfigure) CLEAN=1 shift ;; + -h|--help) echo "Usage : ./configure [OPTION]..." echo "Add submodules depending on target host platform and" @@ -66,9 +70,11 @@ for i in "$@"; do echo -e "\tshow help and exit" exit 0 ;; + -*) exit_error_message "Unknown option $i" ;; + *) ;; esac @@ -102,7 +108,7 @@ if [ "${HOST}" = "guess" ]; then esac fi -echo "Configuring for current host: ${HOST}" +echo "Configuring for host: ${HOST}" # If target host is guess then configure for host if [ "${TARGET_HOST}" = "guess" ]; then @@ -154,13 +160,16 @@ case "${TARGET_HOST}" in TARGET_HOST_PKG_CONFIG=pkg-config TARGET_HOST_CFLAGS=( "--std=c17" "-Os" - "-DASSET_FILE_NAME=\\\"\$(notdir \$(ASSET_OUTPUT))\\\"" "-D_GNU_SOURCE=1" + "-DASSET_FILE_NAME=\\\"\$(notdir \$(ASSET_OUTPUT))\\\"" + ) + TARGET_HOST_LDFLAGS=( + "-lm" ) - TARGET_HOST_LDFLAGS=() OUTPUT_EXT="" DYNAMIC_LIB_OUTPUT_EXT=".so" STATIC_LIB_OUTPUT_EXT=".a" ;; + *) exit_error_message "Cross compiling from ${HOST} for ${TARGET_HOST} is not supported yet." ;; @@ -168,7 +177,6 @@ case "${TARGET_HOST}" in TARGET_HOST_LIBS=( "sdl3|3.2.10" - "lua|5.4.7" ) ;; @@ -176,7 +184,7 @@ case "${TARGET_HOST}" in echo "Configuring for target: ${TARGET_HOST}" case "${HOST}" in - windows) + windows|linux) TARGET_HOST_CC=x86_64-w64-mingw32-gcc TARGET_HOST_AR=x86_64-w64-mingw32-gcc-ar TARGET_HOST_PKG_CONFIG=x86_64-w64-mingw32-pkg-config @@ -197,7 +205,6 @@ case "${TARGET_HOST}" in TARGET_HOST_LIBS=( "sdl3|3.3.4" - "lua|5.4.7" ) ;; diff --git a/core/host/generic/display.h b/core/host/generic/display.h deleted file mode 100644 index a155b51..0000000 --- a/core/host/generic/display.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef DISPLAY_H -#define DISPLAY_H - -#include "texture.h" -#include "vector2d.h" - -#define C_BLACK 0, 0, 0 -#define C_RED 255, 0, 0 -#define C_GREEN 0, 255, 0 -#define C_BLUE 0, 0, 255 -#define C_WHITE 255, 255, 255 - -#define DISPLAY_WIDTH 720 -#define DISPLAY_HEIGHT 480 - -typedef struct display_t { -} display_t; - -int display_init(void); -void display_exit(void); - -int display_clear(void); -int display_update(void); - -int display_draw_texture(texture_t *texture, const rect_t *src_rect, const rect_t *dst_rect, bool flip); -int display_draw_frect(const frect_t *frect, unsigned int r, unsigned int g, unsigned int b, unsigned int a); - -#endif // DISPLAY_H \ No newline at end of file diff --git a/core/host/generic/inputs.h b/core/host/generic/inputs.h deleted file mode 100644 index ac0c8d0..0000000 --- a/core/host/generic/inputs.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef KEYBOARD_H -#define KEYBOARD_H - -#include -#include -#include "keycodes.h" - -typedef struct input_event_t { - uint32_t type; - int key; -} input_event_t; - -int poll_event(input_event_t *event); - -typedef struct inputs_t { - bool keys[MAX_KEYCODES]; -} inputs_t; - -#endif // KEYBOARD_H \ No newline at end of file diff --git a/core/host/generic/keycodes.h b/core/host/generic/keycodes.h deleted file mode 100644 index 2cbf8c2..0000000 --- a/core/host/generic/keycodes.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef KEYCODES_H -#define KEYCODES_H - -#define MAX_KEYCODES 0xFF - -#define KEY_UP 0x01 -#define KEY_DOWN 0x02 -#define KEY_LEFT 0x03 -#define KEY_RIGHT 0x04 -#define KEY_MOD 0x05 -#define KEY_INTERACT 0x06 - -#define INPUT_EVENT_KEY_UP 0x01 -#define INPUT_EVENT_KEY_DOWN 0x02 -#define INPUT_EVENT_QUIT 0xFF - -#endif // KEYCODES_H \ No newline at end of file diff --git a/core/host/generic/memory_alloc.h b/core/host/generic/memory_alloc.h deleted file mode 100644 index ef8e8b6..0000000 --- a/core/host/generic/memory_alloc.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef MEMORY_ALLOC_H -#define MEMORY_ALLOC_H - -#include - -#endif // MEMORY_ALLOC_H \ No newline at end of file diff --git a/core/host/generic/texture.h b/core/host/generic/texture.h deleted file mode 100644 index b71c4dd..0000000 --- a/core/host/generic/texture.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef TEXTURE_H -#define TEXTURE_H - -#define TEXTURE_TRANSPARENT_COLOR 0x0001 - -typedef struct texture_t texture_t; - -#define get_width(T) 1 -#define get_height(T) 1 - -texture_t *load_texture(void); -void destroy_texture(texture_t *texture); - -#endif // TEXTURE_H \ No newline at end of file diff --git a/core/host/generic/update_time.h b/core/host/generic/update_time.h deleted file mode 100644 index 0b22fb9..0000000 --- a/core/host/generic/update_time.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef TIME_H -#define TIME_H - -void update_time(void); - -#endif // TIME_H \ No newline at end of file diff --git a/core/host/generic/vector2d.h b/core/host/generic/vector2d.h deleted file mode 100644 index 81a5c2d..0000000 --- a/core/host/generic/vector2d.h +++ /dev/null @@ -1,163 +0,0 @@ -#ifndef VECTOR2D_H -#define VECTOR2D_H - -#include -#include - -/** - * @brief Point struct. (int) - * - * @param x X pos - * @param y Y pos -*/ -typedef struct vector2d_t { - int x, y; -} vector2d_t; - -/** - * @brief Point struct. (float) - * - * @param x X pos - * @param y Y pos -*/ -typedef struct fvector2d_t { - float x, y; -} fvector2d_t; - -/** - * @brief Rectangle struct. (int) - * - * @param x X pos - * @param y Y pos - * @param w Width - * @param h Height -*/ -typedef struct rect_t { - int x, y; - int w, h; -} rect_t; - -/** - * @brief Rectangle struct. (float) - * - * @param x X pos - * @param y Y pos - * @param w Width - * @param h Height -*/ -typedef struct frect_t { - float x, y; - float w, h; -} frect_t; - -#define EPSILON 0.0f - -#define f_is_zero(X) (fabsf(X) <= EPSILON) - -#define f_is_not_zero(X) (fabsf(X) > EPSILON) - -void rect_to_frect(const rect_t *rect, frect_t *frect); - -void frect_to_rect(const frect_t *frect, rect_t *rect); - -/** - * @brief Verify if a point is in a rectangle. (int) - * - * @param p Vector2d - * @param r Rectangle - * - * @return True if the point is in the rectangle, else false. -*/ -bool point_in_rect(const vector2d_t *p, const rect_t *r); - -/** - * @brief Verify if a point is in a rectangle. (float) - * - * @param p Vector2d - * @param r Rectangle - * - * @return True if the point is in the rectangle, else false. -*/ -bool fpoint_in_rect(const fvector2d_t *p, const frect_t *r); - -/** - * @brief Verify if a rectangle is empty - * - * @param r Rectangle - * - * @return True if the rectangle is empty, else false. -*/ -bool rect_empty(const rect_t *r); - -/** - * @brief Verify if a rectangle is empty - * - * @param r Rectangle - * - * @return True if the rectangle is empty, else false. -*/ -bool frect_empty(const frect_t *r); - -/** - * @brief Verify if there is a intersction between two rectangles. (int) - * - * @param A Rectangle A - * @param B Rectangle B - * - * @return True if there is an intersection, else false. -*/ -bool has_intersection(const rect_t *a, const rect_t *b); - -/** - * @brief Verify if there is a intersction between two rectangles. (float) - * - * @param A Rectangle A - * @param B Rectangle B - * - * @return True if there is an intersection, else false. -*/ -bool fhas_intersection(const frect_t *a, const frect_t *b); - -/** - * @brief Verify if there is an intersection between two rectangles and get the intersection rectangle. (int) - * - * @param A Rectangle A - * @param B Rectangle B - * @param result The intersection rectangle - * - * @return True if there is an intersection, else false. -*/ -bool intersect_rect(const rect_t *a, const rect_t *b, rect_t *result); - -/** - * @brief Verify if there is an intersection between two rectangles and get the intersection rectangle. (float) - * - * @param A Rectangle A - * @param B Rectangle B - * @param result The intersection rectangle - * - * @return True if there is an intersection, else false. -*/ -bool intersect_frect(const frect_t *a, const frect_t *b, frect_t *result); - -/** - * @brief Lerp a to b with smoothing factor s. - * - * @param a Current value - * @param b Target value - * @param s Smoothing factor - */ -float lerp(float a, float b, float s); - -/** - * @brief Lerp a to b with smoothing factor s and time basis t. - * Smoothing factor is for 60 fps call time. - * - * @param a Current value - * @param b Target value - * @param s Smoothing factor - * @param t Delta time - */ -float lerp_time(float a, float b, float s, float t); - -#endif // VECTOR2D_H \ No newline at end of file