Compare commits
No commits in common. "7cf84ecd7a11a16ed3b6acdfe4fad295ccbead0f" and "e3e3d5f4768d299130536361439b59ee79b15537" have entirely different histories.
7cf84ecd7a
...
e3e3d5f476
|
|
@ -13,14 +13,11 @@
|
|||
"/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"
|
||||
],
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
"defines": [
|
||||
"_REENTRANT",
|
||||
"FXCG50",
|
||||
"TARGET_FXCG50"
|
||||
"-D_REENTRANT"
|
||||
],
|
||||
"cStandard": "c17",
|
||||
"browse": {
|
||||
|
|
|
|||
25
Makefile
25
Makefile
|
|
@ -4,15 +4,6 @@ SHELL = /usr/bin/env bash
|
|||
|
||||
ROOT := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
# Import config
|
||||
ifeq ($(filter clean-all,$(MAKECMDGOALS)),)
|
||||
ifneq ($(realpath $(ROOT)/config.mk), $(ROOT)/config.mk)
|
||||
$(error ERROR: Please run the configure script before building)
|
||||
endif
|
||||
|
||||
include $(ROOT)/config.mk
|
||||
endif
|
||||
|
||||
#
|
||||
# User settings
|
||||
#
|
||||
|
|
@ -26,6 +17,7 @@ ASSET_BUILDER_DIR = asset_builder
|
|||
|
||||
OUTPUT = 2D_Engine
|
||||
ASSET_OUTPUT = game.data
|
||||
ASSET_BUILDER_OUTPUT = asset_builder/asset_builder
|
||||
|
||||
ifneq ($(DEBUG),)
|
||||
TARGET_HOST_CFLAGS += -O1 -g -DDEBUG=$(DEBUG) -Wextra -Wall --pedantic -Wno-missing-braces \
|
||||
|
|
@ -47,6 +39,15 @@ endif
|
|||
# End
|
||||
#
|
||||
|
||||
# Import config
|
||||
ifeq ($(filter clean-all,$(MAKECMDGOALS)),)
|
||||
ifneq ($(realpath $(ROOT)/config.mk), $(ROOT)/config.mk)
|
||||
$(error ERROR: Please run the configure script before building)
|
||||
endif
|
||||
|
||||
include $(ROOT)/config.mk
|
||||
endif
|
||||
|
||||
# Relocate vars
|
||||
BUILD_DIR := $(ROOT)/$(BUILD_DIR)/$(TARGET_HOST)
|
||||
|
||||
|
|
@ -55,10 +56,10 @@ CORE_DIR := $(ROOT)/$(CORE_DIR)
|
|||
ASSETS_DIR := $(ROOT)/$(ASSETS_DIR)
|
||||
ASSET_BUILDER_DIR := $(ROOT)/$(ASSET_BUILDER_DIR)
|
||||
|
||||
OUTPUT := $(BUILD_DIR)/$(OUTPUT)$(OUTPUT_EXT)
|
||||
LIBCORE := $(BUILD_DIR)/libcore$(LIB_OUTPUT_EXT)
|
||||
OUTPUT := $(BUILD_DIR)/$(OUTPUT)
|
||||
LIBCORE := $(BUILD_DIR)/$(LIBCORE)
|
||||
ASSET_OUTPUT := $(BUILD_DIR)/$(ASSET_OUTPUT)
|
||||
ASSET_BUILDER_OUTPUT := $(BUILD_DIR)/asset_builder/asset_builder$(OUTPUT_EXT)
|
||||
ASSET_BUILDER_OUTPUT := $(BUILD_DIR)/$(ASSET_BUILDER_OUTPUT)
|
||||
|
||||
# Verbosity
|
||||
export Q := @
|
||||
|
|
|
|||
|
|
@ -11,23 +11,22 @@
|
|||
#
|
||||
|
||||
CONFIG_FILE="config.mk"
|
||||
CACHE_DIR="cache"
|
||||
LIB_DIR="lib"
|
||||
|
||||
#LUA_VERSION="5.5.1"
|
||||
#LUA_CHECKSUM="1c4b4068d67061f2a2231ad2b5422e77acea1487ea9890f6320af614f4373dce"
|
||||
|
||||
#
|
||||
# Main
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
exit_error_message()
|
||||
print_error()
|
||||
{
|
||||
echo -e "\033[31merror\033[m: $1"
|
||||
exit 0
|
||||
}
|
||||
|
||||
## Parse args
|
||||
HOST="guess"
|
||||
CURRENT_HOST="guess"
|
||||
TARGET_HOST="guess"
|
||||
|
||||
for i in "$@"; do
|
||||
|
|
@ -37,7 +36,7 @@ for i in "$@"; do
|
|||
shift
|
||||
;;
|
||||
--current-host=*)
|
||||
HOST="${i#*=}"
|
||||
CURRENT_HOST="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--clean)
|
||||
|
|
@ -69,7 +68,7 @@ for i in "$@"; do
|
|||
exit 0
|
||||
;;
|
||||
-*)
|
||||
exit_error_message "Unknown option $i"
|
||||
print_error "Unknown option $i"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
|
|
@ -79,7 +78,7 @@ done
|
|||
## Clean
|
||||
if [ -n "${CLEAN}" ]; then
|
||||
make clean-all
|
||||
rm -rf ${CONFIG_FILE} ${CACHE_DIR} ${LIB_DIR}
|
||||
rm -rf ${CONFIG_FILE}
|
||||
fi
|
||||
|
||||
if [ -n "${EXIT_AFTER_CLEAN}" ]; then
|
||||
|
|
@ -87,10 +86,10 @@ if [ -n "${EXIT_AFTER_CLEAN}" ]; then
|
|||
fi
|
||||
|
||||
## Deduce current and target hosts
|
||||
if [ "${HOST}" = "guess" ]; then
|
||||
if [ "${CURRENT_HOST}" = "guess" ]; then
|
||||
case "${OSTYPE}" in
|
||||
linux*)
|
||||
HOST="linux"
|
||||
CURRENT_HOST="linux"
|
||||
;;
|
||||
msys*|cygwin*)
|
||||
CURRENT_HOST="windows"
|
||||
|
|
@ -99,31 +98,23 @@ if [ "${HOST}" = "guess" ]; then
|
|||
# CURRENT_HOST="macos"
|
||||
# ;;
|
||||
*)
|
||||
exit_error_message "Current detected os is unsuppoted to build from: ${OSTYPE}\nUse --help for more informations."
|
||||
print_error "Current detected os is unsuppoted to build from: ${OSTYPE}\nUse --help for more informations."
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo "Configuring for current host: ${HOST}"
|
||||
echo "Configuring for current host: ${CURRENT_HOST}"
|
||||
|
||||
# If target host is guess then configure for host
|
||||
if [ "${TARGET_HOST}" = "guess" ]; then
|
||||
TARGET_HOST=${HOST}
|
||||
TARGET_HOST=${CURRENT_HOST}
|
||||
fi
|
||||
|
||||
# Set host compiler and asset builder flags
|
||||
case "${HOST}" in
|
||||
case "${CURRENT_HOST}" in
|
||||
linux)
|
||||
HOST_CC=gcc
|
||||
ASSET_BUILDER_CFLAGS=(
|
||||
"--std=c17"
|
||||
"-O2"
|
||||
)
|
||||
ASSET_BUILDER_LDFLAGS=()
|
||||
ASSET_BUILDER_LIBS=(
|
||||
"libpng|1.6.48"
|
||||
"json-c|0.18"
|
||||
)
|
||||
HOST_CC="gcc"
|
||||
HOST_AR="ar"
|
||||
ASSET_BUILDER_CFLAGS="--std=c17 -O2 \$(shell pkg-config --cflags libpng json-c)"
|
||||
ASSET_BUILDER_LDFLAGS="\$(shell pkg-config --libs libpng json-c)"
|
||||
;;
|
||||
windows)
|
||||
HOST_CC="x86_64-w64-mingw32-gcc"
|
||||
|
|
@ -132,36 +123,26 @@ case "${HOST}" in
|
|||
ASSET_BUILDER_LDFLAGS="\$(shell x86_64-w64-mingw32-pkg-config --libs libpng json-c)"
|
||||
;;
|
||||
*)
|
||||
exit_error_message "Compiling from ${HOST} is not supported yet."
|
||||
print_error "Compiling from ${CURRENT_HOST} is not supported yet."
|
||||
;;
|
||||
esac
|
||||
|
||||
# Set target host compiler, outputs extensions and flags
|
||||
case "${TARGET_HOST}" in
|
||||
linux)
|
||||
echo "Configuring for target: ${TARGET_HOST}"
|
||||
|
||||
case "${HOST}" in
|
||||
case "${CURRENT_HOST}" in
|
||||
linux)
|
||||
TARGET_HOST_CC=gcc
|
||||
TARGET_HOST_AR=ar
|
||||
TARGET_HOST_CFLAGS=(
|
||||
"--std=c17" "-Os"
|
||||
"-DASSET_FILE_NAME=\\\"\$(notdir \$(ASSET_OUTPUT))\\\"" "-D_GNU_SOURCE=1"
|
||||
)
|
||||
TARGET_HOST_LDFLAGS=()
|
||||
OUTPUT_EXT=""
|
||||
LIB_OUTPUT_EXT=".a"
|
||||
TARGET_HOST_CC="gcc"
|
||||
TARGET_HOST_AR="ar"
|
||||
TARGET_HOST_CFLAGS="--std=c17 -Os -DASSET_FILE_NAME=\\\"\$(notdir \$(ASSET_OUTPUT))\\\" -D_GNU_SOURCE=1 \$(shell pkg-config --cflags sdl3 lua)"
|
||||
TARGET_HOST_LDFLAGS="\$(shell pkg-config --libs sdl3 lua) -lm"
|
||||
TARGET_HOST_LIBCORE="libcore.a"
|
||||
;;
|
||||
*)
|
||||
exit_error_message "Cross compiling from ${HOST} for ${TARGET_HOST} is not supported yet."
|
||||
print_error "Cross compiling from ${CURRENT_HOST} for ${TARGET_HOST} is not supported yet."
|
||||
;;
|
||||
esac
|
||||
|
||||
TARGET_HOST_LIBS=(
|
||||
"sdl3|3.2.10"
|
||||
"lua|5.4.7"
|
||||
)
|
||||
;;
|
||||
|
||||
windows)
|
||||
|
|
@ -185,150 +166,23 @@ case "${TARGET_HOST}" in
|
|||
fxcg50)
|
||||
echo "Configuring for target: ${TARGET_HOST}"
|
||||
|
||||
case "${HOST}" in
|
||||
case "${CURRENT_HOST}" in
|
||||
linux)
|
||||
TARGET_HOST_CC=sh-elf-gcc
|
||||
TARGET_HOST_AR=sh-elf-ar
|
||||
TARGET_HOST_CFLAGS=(
|
||||
"--std=c17" "-Os"
|
||||
"-DASSET_FILE_NAME=\\\"\$(notdir \$(ASSET_OUTPUT))\\\"" "-DFXCG50" "-DTARGET_FXCG50"
|
||||
"-mb" "-m4-nofpu"
|
||||
"-ffreestanding" "-nostdlib" "-fstrict-volatile-bitfields"
|
||||
)
|
||||
TARGET_HOST_LDFLAGS="-T fxcg50.ld"
|
||||
OUTPUT_EXT=""
|
||||
LIB_OUTPUT_EXT=".a"
|
||||
TARGET_HOST_CC="sh-elf-gcc"
|
||||
TARGET_HOST_AR="sh-elf-ar"
|
||||
TARGET_HOST_CFLAGS="--std=c17 -Os"
|
||||
TARGET_HOST_LDFLAGS=""
|
||||
TARGET_HOST_LIBCORE="libcore.a"
|
||||
;;
|
||||
*)
|
||||
exit_error_message "Cross compiling from ${HOST} for ${TARGET_HOST} is not supported yet."
|
||||
print_error "Cross compiling from ${CURRENT_HOST} for ${TARGET_HOST} is not supported yet."
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
exit_error_message "Unsupported target host: ${TARGET_HOST}"
|
||||
print_error "Unsupported target host: ${TARGET_HOST}"
|
||||
esac
|
||||
|
||||
#
|
||||
# Checks
|
||||
#
|
||||
|
||||
echo
|
||||
|
||||
echo "Checking host compiler \"${HOST_CC}\"."
|
||||
if ${HOST_CC} --version &> /dev/null; then
|
||||
echo " ${HOST_CC} OK."
|
||||
else
|
||||
exit_error_message "Compiler not working."
|
||||
fi
|
||||
|
||||
echo "Checking asset builder libs."
|
||||
for LIB in ${ASSET_BUILDER_LIBS[@]}; do
|
||||
LIB_NAME="$(echo ${LIB} | cut -d "|" -f 1)"
|
||||
LIB_MIN_VERSION="$(echo ${LIB} | cut -d "|" -f 2)"
|
||||
|
||||
if pkg-config --atleast-version "${LIB_MIN_VERSION}" "${LIB_NAME}"; then
|
||||
echo " ${LIB_NAME} OK."
|
||||
else
|
||||
LIB_URL=$(echo $LIB | cut -d "|" -f 3)
|
||||
|
||||
if [ "${LIB_URL}" = "" ]; then
|
||||
exit_error_message "Library ${LIB_NAME} version >= ${LIB_MIN_VERSION} was not found and no precompiled binaries are available."
|
||||
else
|
||||
LIB_DOWNLOAD_CHECKSUM=$(echo $LIB | cut -d "|" -f 4)
|
||||
LIB_DOWNLOAD_FILENAME="$(echo ${LIB_URL} | rev | cut -d "/" -f 1 | rev)"
|
||||
LIB_DOWNLOAD_PATH="${CACHE_DIR}/${TARGET_HOST}/${LIB_DOWNLOAD_FILENAME}"
|
||||
|
||||
case "${LIB_DOWNLOAD_FILENAME}" in
|
||||
*.txz)
|
||||
LIB_FOLDER_NAME="${LIB_DOWNLOAD_FILENAME%.txz}"
|
||||
;;
|
||||
*)
|
||||
exit_error_message "File ${LIB_DOWNLOAD_FILENAME} extension substitution is not supported."
|
||||
esac
|
||||
LIB_PATH="${LIB_DIR}/${TARGET_HOST}/${LIB_FOLDER_NAME}"
|
||||
|
||||
echo " ${LIB_NAME} version >= ${LIB_MIN_VERSION} was not found but precompiled binaries are available."
|
||||
|
||||
if [ ! -f "${LIB_DOWNLOAD_PATH}" ]; then
|
||||
echo " downloading from ${LIB_URL}."
|
||||
mkdir -p "$(dirname "${LIB_DOWNLOAD_PATH}")"
|
||||
wget -q -O"${LIB_DOWNLOAD_PATH}" "${LIB_URL}"
|
||||
fi
|
||||
|
||||
if echo "${LIB_DOWNLOAD_CHECKSUM} ${LIB_DOWNLOAD_PATH}" | md5sum --check &> /dev/null; then
|
||||
echo " ${LIB_DOWNLOAD_PATH} OK."
|
||||
else
|
||||
rm -rf "${LIB_DOWNLOAD_PATH}"
|
||||
exit_error_message "Failed to verify checksum of ${LIB_DOWNLOAD_PATH}."
|
||||
fi
|
||||
|
||||
mkdir -p "${LIB_PATH}"
|
||||
tar -xf "${LIB_DOWNLOAD_PATH}" -C "${LIB_PATH}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Checking target host compiler \"${TARGET_HOST_CC}\"."
|
||||
if ${TARGET_HOST_CC} --version &> /dev/null; then
|
||||
echo " ${TARGET_HOST_CC} OK."
|
||||
else
|
||||
exit_error_message "Compiler not working."
|
||||
fi
|
||||
|
||||
echo "Checking target host archiver \"${TARGET_HOST_AR}\"."
|
||||
if ${TARGET_HOST_AR} --version &> /dev/null; then
|
||||
echo " ${TARGET_HOST_AR} OK."
|
||||
else
|
||||
exit_error_message "Compiler not working."
|
||||
fi
|
||||
|
||||
echo "Checking target host libs."
|
||||
for LIB in ${TARGET_HOST_LIBS[@]}; do
|
||||
LIB_NAME="$(echo ${LIB} | cut -d "|" -f 1)"
|
||||
LIB_MIN_VERSION="$(echo ${LIB} | cut -d "|" -f 2)"
|
||||
|
||||
if pkg-config --atleast-version "${LIB_MIN_VERSION}" "${LIB_NAME}"; then
|
||||
echo " ${LIB_NAME} OK."
|
||||
else
|
||||
LIB_URL=$(echo $LIB | cut -d "|" -f 3)
|
||||
|
||||
if [ "${LIB_URL}" = "" ]; then
|
||||
exit_error_message "Library ${LIB_NAME} version >= ${LIB_MIN_VERSION} was not found and no precompiled binaries are available."
|
||||
else
|
||||
LIB_DOWNLOAD_CHECKSUM=$(echo $LIB | cut -d "|" -f 4)
|
||||
LIB_DOWNLOAD_FILENAME="$(echo ${LIB_URL} | rev | cut -d "/" -f 1 | rev)"
|
||||
LIB_DOWNLOAD_PATH="${CACHE_DIR}/${TARGET_HOST}/${LIB_DOWNLOAD_FILENAME}"
|
||||
|
||||
case "${LIB_DOWNLOAD_FILENAME}" in
|
||||
*.txz)
|
||||
LIB_FOLDER_NAME="${LIB_DOWNLOAD_FILENAME%.txz}"
|
||||
;;
|
||||
*)
|
||||
exit_error_message "File ${LIB_DOWNLOAD_FILENAME} extension substitution is not supported."
|
||||
esac
|
||||
LIB_PATH="${LIB_DIR}/${TARGET_HOST}/${LIB_FOLDER_NAME}"
|
||||
|
||||
echo " ${LIB_NAME} version >= ${LIB_MIN_VERSION} was not found but precompiled binaries are available."
|
||||
|
||||
if [ ! -f "${LIB_DOWNLOAD_PATH}" ]; then
|
||||
echo " downloading from ${LIB_URL}."
|
||||
mkdir -p "$(dirname "${LIB_DOWNLOAD_PATH}")"
|
||||
wget -q -O"${LIB_DOWNLOAD_PATH}" "${LIB_URL}"
|
||||
fi
|
||||
|
||||
if echo "${LIB_DOWNLOAD_CHECKSUM} ${LIB_DOWNLOAD_PATH}" | md5sum --check &> /dev/null; then
|
||||
echo " ${LIB_DOWNLOAD_PATH} OK."
|
||||
else
|
||||
rm -rf "${LIB_DOWNLOAD_PATH}"
|
||||
exit_error_message "Failed to verify checksum of ${LIB_DOWNLOAD_PATH}."
|
||||
fi
|
||||
|
||||
mkdir -p "${LIB_PATH}"
|
||||
tar -xf "${LIB_DOWNLOAD_PATH}" -C "${LIB_PATH}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Writing config file."
|
||||
echo
|
||||
echo "${CONFIG_FILE}:"
|
||||
|
|
@ -338,17 +192,17 @@ tee "${CONFIG_FILE}" <<EOF
|
|||
# This file was generated by the configure script.
|
||||
|
||||
TARGET_HOST = ${TARGET_HOST}
|
||||
LIB_OUTPUT_EXT = ${LIB_OUTPUT_EXT}
|
||||
LIBCORE = ${TARGET_HOST_LIBCORE}
|
||||
|
||||
TARGET_HOST_CC = ${TARGET_HOST_CC}
|
||||
TARGET_HOST_AR = ${TARGET_HOST_AR}
|
||||
TARGET_HOST_CFLAGS = ${TARGET_HOST_CFLAGS[@]}
|
||||
TARGET_HOST_LDFLAGS = ${TARGET_HOST_LDFLAGS[@]}
|
||||
TARGET_HOST_CFLAGS = ${TARGET_HOST_CFLAGS}
|
||||
TARGET_HOST_LDFLAGS = ${TARGET_HOST_LDFLAGS}
|
||||
|
||||
HOST_CC = ${HOST_CC}
|
||||
|
||||
ASSET_BUILDER_CFLAGS = ${ASSET_BUILDER_CFLAGS[@]}
|
||||
ASSET_BUILDER_LDFLAGS = ${ASSET_BUILDER_LDFLAGS[@]}
|
||||
ASSET_BUILDER_CFLAGS = ${ASSET_BUILDER_CFLAGS}
|
||||
ASSET_BUILDER_LDFLAGS = ${ASSET_BUILDER_LDFLAGS}
|
||||
EOF
|
||||
|
||||
if [ "${CURRENT_HOST}" = "windows" ]; then
|
||||
|
|
@ -360,3 +214,29 @@ EOF
|
|||
fi
|
||||
|
||||
echo "\`\`\`"
|
||||
|
||||
#
|
||||
### Download libs
|
||||
#echo "===== downloading lua ====="
|
||||
#
|
||||
#LUA_TAR_GZ="${CACHE_DIR}/lua-${LUA_VERSION}.tar.gz"
|
||||
#if [ ! -e "${LUA_TAR_GZ}" ]; then
|
||||
# echo "Downloading lua source..."
|
||||
# if ! curl --output "${LUA_TAR_GZ}" "https://www.lua.org/ftp/lua-${LUA_VERSION}.tar.gz"; then
|
||||
# print_error "Failed to download lua source."
|
||||
# fi
|
||||
#fi
|
||||
#
|
||||
#echo "Checking lua source sum..."
|
||||
#if ! echo "${LUA_CHECKSUM} ${LUA_TAR_GZ}" | sha256sum -c; then
|
||||
# CHECKSUM="$(sha256sum "${LUA_TAR_GZ}" | cut -d " " -f 1)"
|
||||
# rm "${LUA_TAR_GZ}"
|
||||
# print_error "Lua zip checksum not valid.\nExpected: \"${LUA_CHECKSUM}\"\nGot: \"${CHECKSUM}\"\nPlease rerun command to retry downloading."
|
||||
#fi
|
||||
#
|
||||
#echo "Extracting lua source"
|
||||
#if ! tar -xzf "${LUA_TAR_GZ}" --directory "${LIB_DIR}"; then
|
||||
# print_error "Failed to extract lua source."
|
||||
#fi
|
||||
#
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ SOURCES += \
|
|||
event_bus.c \
|
||||
ecs.c \
|
||||
asset_manager.c \
|
||||
inputs.c \
|
||||
map.c
|
||||
|
||||
INCLUDES += \
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
SOURCES += $(addprefix host/$(TARGET_HOST)/, \
|
||||
vector2d.c \
|
||||
inputs.c \
|
||||
update_time.c \
|
||||
)
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef DISPLAY_H
|
||||
#define DISPLAY_H
|
||||
|
||||
#include <gint/display.h>
|
||||
#include "texture.h"
|
||||
#include "vector2d.h"
|
||||
|
||||
#define DISPLAY_WIDTH DWIDTH
|
||||
#define DISPLAY_HEIGHT DHEIGHT
|
||||
|
||||
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
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#include "inputs.h"
|
||||
|
||||
#include <gint/keyboard.h>
|
||||
|
||||
inline int poll_event(input_event_t *event)
|
||||
{
|
||||
key_event_t gint_event = pollevent();
|
||||
|
||||
if(gint_event.type = KEYEV_NONE)
|
||||
return 0;
|
||||
|
||||
event->type = gint_event.type;
|
||||
event->key = gint_event.key;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
#ifndef KEYBOARD_H
|
||||
#define KEYBOARD_H
|
||||
|
||||
#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
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#ifndef KEYCODES_H
|
||||
#define KEYCODES_H
|
||||
|
||||
#include <gint/keyboard.h>
|
||||
|
||||
#define MAX_KEYCODES 0xB0
|
||||
|
||||
#define KEY_MOD KEY_SHIFT
|
||||
#define KEY_INTERACT KEY_ALPHA
|
||||
|
||||
#define INPUT_EVENT_KEY_UP KEYEV_UP
|
||||
#define INPUT_EVENT_KEY_DOWN KEYEV_DOWN
|
||||
#define INPUT_EVENT_QUIT 0xFF
|
||||
|
||||
#endif // KEYCODES_H
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef MEMORY_ALLOC_H
|
||||
#define MEMORY_ALLOC_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#endif // MEMORY_ALLOC_H
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#ifndef TEXTURE_H
|
||||
#define TEXTURE_H
|
||||
|
||||
#include <gint/display.h>
|
||||
|
||||
#define TEXTURE_TRANSPARENT_COLOR 0x0001
|
||||
|
||||
typedef bopti_image_t texture_t;
|
||||
|
||||
#define get_width(T) T->width
|
||||
#define get_height(T) T->height
|
||||
|
||||
texture_t *load_texture(void);
|
||||
void destroy_texture(texture_t *texture);
|
||||
|
||||
#endif // TEXTURE_H
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
#include "update_time.h"
|
||||
|
||||
#include <time.h>
|
||||
#include "game.h"
|
||||
|
||||
inline void update_time(void)
|
||||
{
|
||||
static clock_t last_clock_state = 0;
|
||||
clock_t start_clock = clock();
|
||||
game.delta_time_ms = (float)(start_clock - last_clock_state) / (float)CLOCKS_PER_SEC;
|
||||
if(game.delta_time_ms > 100.0f) game.delta_time_ms = 100.0f;
|
||||
last_clock_state = start_clock;
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef TIME_H
|
||||
#define TIME_H
|
||||
|
||||
void update_time(void);
|
||||
|
||||
#endif // TIME_H
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef VECTOR2D_H
|
||||
#define VECTOR2D_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <SDL3/SDL_rect.h>
|
||||
#include <math.h>
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@
|
|||
#define DISPLAY_WIDTH 720
|
||||
#define DISPLAY_HEIGHT 480
|
||||
|
||||
//#define DRIVERS NULL
|
||||
#define DRIVERS "vulkan,gpu,software"
|
||||
|
||||
typedef struct display_t {
|
||||
} display_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef TIME_H
|
||||
#define TIME_H
|
||||
|
||||
void update_time(void);
|
||||
|
||||
#endif // TIME_H
|
||||
|
|
@ -2,6 +2,4 @@ SOURCES += $(addprefix host/$(TARGET_HOST)/, \
|
|||
display.c \
|
||||
vector2d.c \
|
||||
texture.c \
|
||||
inputs.c \
|
||||
update_time.c \
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
#ifndef KEYBOARD_H
|
||||
#define KEYBOARD_H
|
||||
|
||||
#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
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
#include "update_time.h"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include "game.h"
|
||||
|
||||
inline void update_time(void)
|
||||
{
|
||||
static uint64_t last_clock_state = 0;
|
||||
uint64_t start_clock = SDL_GetTicksNS();
|
||||
game.delta_time_ms = SDL_NS_TO_MS((float)(start_clock - last_clock_state));
|
||||
if(game.delta_time_ms > 100.0f) game.delta_time_ms = 100.0f;
|
||||
last_clock_state = start_clock;
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef TIME_H
|
||||
#define TIME_H
|
||||
|
||||
void update_time(void);
|
||||
|
||||
#endif // TIME_H
|
||||
|
|
@ -1,13 +1,16 @@
|
|||
#ifndef KEYBOARD_H
|
||||
#define KEYBOARD_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <SDL3/SDL_events.h>
|
||||
#include "keycodes.h"
|
||||
|
||||
#define INPUT_EVENT_KEY_UP SDL_EVENT_KEY_UP
|
||||
#define INPUT_EVENT_KEY_DOWN SDL_EVENT_KEY_DOWN
|
||||
#define INPUT_EVENT_QUIT SDL_EVENT_QUIT
|
||||
|
||||
typedef struct input_event_t {
|
||||
uint32_t type;
|
||||
int key;
|
||||
SDL_Scancode key;
|
||||
} input_event_t;
|
||||
|
||||
int poll_event(input_event_t *event);
|
||||
|
|
@ -12,8 +12,4 @@
|
|||
#define KEY_MOD SDL_SCANCODE_LCTRL
|
||||
#define KEY_INTERACT SDL_SCANCODE_E
|
||||
|
||||
#define INPUT_EVENT_KEY_UP SDL_EVENT_KEY_UP
|
||||
#define INPUT_EVENT_KEY_DOWN SDL_EVENT_KEY_DOWN
|
||||
#define INPUT_EVENT_QUIT SDL_EVENT_QUIT
|
||||
|
||||
#endif // KEYCODES_H
|
||||
11
core/main.c
11
core/main.c
|
|
@ -1,11 +1,20 @@
|
|||
#include "game.h"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <stdlib.h>
|
||||
#include "update_time.h"
|
||||
#include "errors.h"
|
||||
|
||||
game_t game;
|
||||
|
||||
static inline void update_time(void)
|
||||
{
|
||||
static uint64_t last_clock_state = 0;
|
||||
uint64_t start_clock = SDL_GetTicksNS();
|
||||
game.delta_time_ms = SDL_NS_TO_MS((float)(start_clock - last_clock_state));
|
||||
if(game.delta_time_ms > 100.0f) game.delta_time_ms = 100.0f;
|
||||
last_clock_state = start_clock;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
if(game_init()) goto_failure;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ SOURCES += \
|
|||
components/animation_system.c \
|
||||
components/player_system.c \
|
||||
components/lever_component.c \
|
||||
components/door_component.c# \
|
||||
components/door_component.c \
|
||||
components/lua_component.c
|
||||
|
||||
INCLUDES += \
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@
|
|||
COMPONENT(TRANSFORM_COMPONENT, transform_component, DRAW)
|
||||
COMPONENT(HITBOX_COMPONENT, hitbox_component, DRAW)
|
||||
COMPONENT(INTERACT_COMPONENT, interact_component, DRAW)
|
||||
//COMPONENT(LUA_COMPONENT, lua_component, DRAW)
|
||||
COMPONENT(LUA_COMPONENT, lua_component, DRAW)
|
||||
#else
|
||||
COMPONENT(TRANSFORM_COMPONENT, transform_component, NO_DRAW)
|
||||
COMPONENT(HITBOX_COMPONENT, hitbox_component, NO_DRAW)
|
||||
COMPONENT(INTERACT_COMPONENT, interact_component, NO_DRAW)
|
||||
//COMPONENT(LUA_COMPONENT, lua_component, NO_DRAW)
|
||||
COMPONENT(LUA_COMPONENT, lua_component, NO_DRAW)
|
||||
#endif // DEBUG >= 2
|
||||
|
||||
COMPONENT(PHYSICS_SYSTEM, physics_system, NO_DRAW)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#include "player_system.h"
|
||||
#include "lever_component.h"
|
||||
#include "door_component.h"
|
||||
//#include "lua_component.h"
|
||||
#include "lua_component.h"
|
||||
// Add new components header file here
|
||||
|
||||
#endif // COMPONENTS_H
|
||||
|
|
@ -21,7 +21,7 @@ int game_init(void)
|
|||
entity_manager_init();
|
||||
if(asset_manager_init()) return_failure_int;
|
||||
|
||||
asset_t *map_asset = asset_manager_load_asset("dungeon_room_1", ASSET_MAP);
|
||||
asset_t *map_asset = asset_manager_load_asset("dungeon_entry", ASSET_MAP);
|
||||
if(!map_asset) return_failure_int;
|
||||
|
||||
game.map = map_asset->data;
|
||||
|
|
|
|||
Loading…
Reference in New Issue