almost bulding for fxcg50.
This commit is contained in:
parent
18c8e6b887
commit
4a00e9f6d4
|
|
@ -13,11 +13,14 @@
|
|||
"/usr/include/spa-0.2",
|
||||
"/usr/include/libdrm",
|
||||
"/usr/include/libdecor-0",
|
||||
"/usr/include/x86_64-linux-gnu"
|
||||
"/usr/include/x86_64-linux-gnu",
|
||||
"${env:HOME}/.local/share/fxsdk/sysroot/sh3eb-elf/include"
|
||||
],
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
"defines": [
|
||||
"-D_REENTRANT"
|
||||
"_REENTRANT",
|
||||
"FXCG50",
|
||||
"TARGET_FXCG50"
|
||||
],
|
||||
"cStandard": "c17",
|
||||
"browse": {
|
||||
|
|
|
|||
|
|
@ -146,8 +146,8 @@ case "${TARGET_HOST}" in
|
|||
linux)
|
||||
TARGET_HOST_CC="sh-elf-gcc"
|
||||
TARGET_HOST_AR="sh-elf-ar"
|
||||
TARGET_HOST_CFLAGS="--std=c17 -Os"
|
||||
TARGET_HOST_LDFLAGS=""
|
||||
TARGET_HOST_CFLAGS="--std=c17 -Os -DASSET_FILE_NAME=\\\"\$(notdir \$(ASSET_OUTPUT))\\\" -mb -ffreestanding -nostdlib -fstrict-volatile-bitfields -DFXCG50 -DTARGET_FXCG50 -m4-nofpu"
|
||||
TARGET_HOST_LDFLAGS="-T fxcg50.ld -lgint-cg -lgcc"
|
||||
TARGET_HOST_LIBCORE="libcore.a"
|
||||
;;
|
||||
*)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ SOURCES += \
|
|||
event_bus.c \
|
||||
ecs.c \
|
||||
asset_manager.c \
|
||||
inputs.c \
|
||||
map.c
|
||||
|
||||
INCLUDES += \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
SOURCES += $(addprefix host/$(TARGET_HOST)/, \
|
||||
vector2d.c \
|
||||
inputs.c \
|
||||
update_time.c \
|
||||
)
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#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
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
#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,16 +1,11 @@
|
|||
#ifndef KEYBOARD_H
|
||||
#define KEYBOARD_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;
|
||||
SDL_Scancode key;
|
||||
int key;
|
||||
} input_event_t;
|
||||
|
||||
int poll_event(input_event_t *event);
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#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
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef MEMORY_ALLOC_H
|
||||
#define MEMORY_ALLOC_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#endif // MEMORY_ALLOC_H
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
#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
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#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;
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef TIME_H
|
||||
#define TIME_H
|
||||
|
||||
void update_time(void);
|
||||
|
||||
#endif // TIME_H
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef VECTOR2D_H
|
||||
#define VECTOR2D_H
|
||||
|
||||
#include <SDL3/SDL_rect.h>
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -13,9 +13,6 @@
|
|||
#define DISPLAY_WIDTH 720
|
||||
#define DISPLAY_HEIGHT 480
|
||||
|
||||
//#define DRIVERS NULL
|
||||
#define DRIVERS "vulkan,gpu,software"
|
||||
|
||||
typedef struct display_t {
|
||||
} display_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef KEYBOARD_H
|
||||
#define KEYBOARD_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.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
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#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
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef TIME_H
|
||||
#define TIME_H
|
||||
|
||||
void update_time(void);
|
||||
|
||||
#endif // TIME_H
|
||||
|
|
@ -2,4 +2,6 @@ SOURCES += $(addprefix host/$(TARGET_HOST)/, \
|
|||
display.c \
|
||||
vector2d.c \
|
||||
texture.c \
|
||||
inputs.c \
|
||||
update_time.c \
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
#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
|
||||
|
|
@ -12,4 +12,8 @@
|
|||
#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
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#include "update_time.h"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include "game.h"
|
||||
|
||||
inline void update_time(void)
|
||||
{
|
||||
static uint32_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;
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef TIME_H
|
||||
#define TIME_H
|
||||
|
||||
void update_time(void);
|
||||
|
||||
#endif // TIME_H
|
||||
11
core/main.c
11
core/main.c
|
|
@ -1,20 +1,11 @@
|
|||
#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
|
||||
Loading…
Reference in New Issue