C -> CPP
Some checks failed
Build Dusk / build-linux (push) Failing after 1m47s
Build Dusk / build-psp (push) Failing after 1m40s

This commit is contained in:
2025-12-22 11:41:49 +10:00
parent a495179e5f
commit 76b5c51ab6
162 changed files with 751 additions and 740 deletions

View File

@@ -7,6 +7,8 @@
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
if(NOT DEFINED DUSK_TARGET_SYSTEM) if(NOT DEFINED DUSK_TARGET_SYSTEM)
@@ -45,7 +47,7 @@ endif()
# Init Project # Init Project
project(${DUSK_TARGET_NAME} project(${DUSK_TARGET_NAME}
VERSION 1.0.0 VERSION 1.0.0
LANGUAGES C LANGUAGES C CXX
) )
# Executable # Executable

View File

@@ -9,7 +9,7 @@ following packages, depending on your system;
Fedora; Fedora;
``` ```
sudo dnf install git make gcc python python-polib python3-pillow python3-dotenv python3-numpy python-qt5 python3-pyopengl sudo dnf install git make gcc python python-polib python3-pillow python3-dotenv python3-numpy python-qt5 python3-pyopengl SDL2-devel libzip-devel bzip2-devel xz-devel lua-devel
``` ```
Ubuntu; Ubuntu;

View File

@@ -12,7 +12,7 @@ endif()
file(STRINGS "${ENV_FILE}" ENV_LINES) file(STRINGS "${ENV_FILE}" ENV_LINES)
set(HEADER_CONTENT "#pragma once\n#include \"dusk.h\"\n\n") set(HEADER_CONTENT "#pragma once\n#include \"dusk.hpp\"\n\n")
foreach(line IN LISTS ENV_LINES) foreach(line IN LISTS ENV_LINES)
# Skip comments and empty lines (allow whitespace before # or ;) # Skip comments and empty lines (allow whitespace before # or ;)

View File

@@ -36,11 +36,11 @@ target_include_directories(${DUSK_TARGET_NAME}
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE PRIVATE
main.c main.cpp
) )
# Defs # Defs
add_defs(duskdefs.env duskdefs.h) add_defs(duskdefs.env duskdefs.hpp)
# Subdirs # Subdirs
add_subdirectory(assert) add_subdirectory(assert)

View File

@@ -6,5 +6,5 @@
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE PRIVATE
assert.c assert.cpp
) )

View File

@@ -5,8 +5,8 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "assert.h" #include "assert.hpp"
#include "debug/debug.h" #include "debug/debug.hpp"
#ifndef ASSERTIONS_FAKED #ifndef ASSERTIONS_FAKED
void assertTrueImpl( void assertTrueImpl(

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "dusk.h" #include "dusk.hpp"
#ifndef ASSERTIONS_FAKED #ifndef ASSERTIONS_FAKED
/** /**
@@ -115,10 +115,10 @@
assertUnreachableImpl(__FILE__, __LINE__, message) assertUnreachableImpl(__FILE__, __LINE__, message)
#define assertNotNull(pointer, message) \ #define assertNotNull(pointer, message) \
assertNotNullImpl(__FILE__, __LINE__, pointer, message) assertNotNullImpl(__FILE__, __LINE__, (const void*)pointer, message)
#define assertNull(pointer, message) \ #define assertNull(pointer, message) \
assertNullImpl(__FILE__, __LINE__, pointer, message) assertNullImpl(__FILE__, __LINE__, (const void*)pointer, message)
#define assertDeprecated(message) \ #define assertDeprecated(message) \
assertDeprecatedImpl(__FILE__, __LINE__, message) assertDeprecatedImpl(__FILE__, __LINE__, message)

View File

@@ -6,7 +6,7 @@
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE PRIVATE
asset.c asset.cpp
) )
# Subdirs # Subdirs

View File

@@ -5,13 +5,13 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "asset.h" #include "asset.hpp"
#include "util/memory.h" #include "util/memory.hpp"
#include "util/string.h" #include "util/string.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
#include "asset/assettype.h" #include "asset/assettype.h"
#include "engine/engine.h" #include "engine/engine.hpp"
#include "debug/debug.h" #include "debug/debug.hpp"
errorret_t assetInit(void) { errorret_t assetInit(void) {
memoryZero(&ASSET, sizeof(asset_t)); memoryZero(&ASSET, sizeof(asset_t));
@@ -220,7 +220,7 @@ errorret_t assetLoad(const char_t *filename, void *output) {
// We found the asset type, now load the asset data // We found the asset type, now load the asset data
switch(def->loadStrategy) { switch(def->loadStrategy) {
case ASSET_LOAD_STRAT_ENTIRE: case ASSET_LOAD_STRAT_ENTIRE: {
assertNotNull(def->entire, "Asset load function cannot be NULL."); assertNotNull(def->entire, "Asset load function cannot be NULL.");
void *data = memoryAllocate(def->dataSize); void *data = memoryAllocate(def->dataSize);
bytesRead = zip_fread(file, data, def->dataSize); bytesRead = zip_fread(file, data, def->dataSize);
@@ -238,8 +238,9 @@ errorret_t assetLoad(const char_t *filename, void *output) {
memoryFree(data); memoryFree(data);
errorChain(ret); errorChain(ret);
break; break;
}
case ASSET_LOAD_STRAT_CUSTOM: case ASSET_LOAD_STRAT_CUSTOM: {
assertNotNull(def->custom, "Asset load function cannot be NULL."); assertNotNull(def->custom, "Asset load function cannot be NULL.");
assetcustom_t customData = { assetcustom_t customData = {
.zipFile = file, .zipFile = file,
@@ -247,6 +248,7 @@ errorret_t assetLoad(const char_t *filename, void *output) {
}; };
errorChain(def->custom(customData)); errorChain(def->custom(customData));
break; break;
}
default: default:
assertUnreachable("Unknown asset load strategy."); assertUnreachable("Unknown asset load strategy.");

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "error/error.h" #include "error/error.hpp"
#include "assettype.h" #include "assettype.h"
#if ASSET_TYPE == wad #if ASSET_TYPE == wad

View File

@@ -6,12 +6,12 @@
*/ */
#pragma once #pragma once
#include "type/assetpaletteimage.h" #include "type/assetpaletteimage.hpp"
#include "type/assetalphaimage.h" #include "type/assetalphaimage.hpp"
#include "type/assetlanguage.h" #include "type/assetlanguage.hpp"
#include "type/assetmap.h" #include "type/assetmap.hpp"
#include "type/assetchunk.h" #include "type/assetchunk.hpp"
#include "type/assetscript.h" #include "type/assetscript.hpp"
#include <zip.h> #include <zip.h>
typedef enum { typedef enum {
@@ -27,10 +27,9 @@ typedef enum {
ASSET_TYPE_COUNT, ASSET_TYPE_COUNT,
} assettype_t; } assettype_t;
typedef enum { typedef uint8_t assetloadstrat_t;
ASSET_LOAD_STRAT_ENTIRE, #define ASSET_LOAD_STRAT_ENTIRE 0
ASSET_LOAD_STRAT_CUSTOM #define ASSET_LOAD_STRAT_CUSTOM 1
} assetloadstrat_t;
typedef struct assetcustom_s { typedef struct assetcustom_s {
zip_file_t *zipFile; zip_file_t *zipFile;
@@ -39,8 +38,8 @@ typedef struct assetcustom_s {
typedef struct { typedef struct {
const char_t *header; const char_t *header;
const size_t dataSize;
const assetloadstrat_t loadStrategy; const assetloadstrat_t loadStrategy;
const size_t dataSize;
union { union {
errorret_t (*entire)(void *data, void *output); errorret_t (*entire)(void *data, void *output);
errorret_t (*custom)(assetcustom_t custom); errorret_t (*custom)(assetcustom_t custom);

View File

@@ -6,10 +6,10 @@
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE PRIVATE
assetalphaimage.c assetalphaimage.cpp
assetpaletteimage.c assetpaletteimage.cpp
assetlanguage.c assetlanguage.cpp
assetmap.c assetmap.cpp
assetchunk.c assetchunk.cpp
assetscript.c assetscript.cpp
) )

View File

@@ -5,9 +5,9 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "assetalphaimage.h" #include "assetalphaimage.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
#include "display/texture.h" #include "display/texture.hpp"
errorret_t assetAlphaImageLoad(void *data, void *output) { errorret_t assetAlphaImageLoad(void *data, void *output) {
assertNotNull(data, "Data pointer cannot be NULL."); assertNotNull(data, "Data pointer cannot be NULL.");

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "error/error.h" #include "error/error.hpp"
#define ASSET_ALPHA_IMAGE_WIDTH_MAX 256 #define ASSET_ALPHA_IMAGE_WIDTH_MAX 256
#define ASSET_ALPHA_IMAGE_HEIGHT_MAX 256 #define ASSET_ALPHA_IMAGE_HEIGHT_MAX 256

View File

@@ -5,9 +5,9 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "asset/asset.h" #include "asset/asset.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
#include "rpg/entity/entity.h" #include "rpg/entity/entity.hpp"
#pragma pack(push, 1) #pragma pack(push, 1)
typedef struct { typedef struct {

View File

@@ -6,8 +6,8 @@
*/ */
#pragma once #pragma once
#include "error/error.h" #include "error/error.hpp"
#include "rpg/world/chunk.h" #include "rpg/world/chunk.hpp"
typedef struct assetcustom_s assetcustom_t; typedef struct assetcustom_s assetcustom_t;

View File

@@ -5,9 +5,9 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "asset/asset.h" #include "asset/asset.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
#include "locale/localemanager.h" #include "locale/localemanager.hpp"
errorret_t assetLanguageHandler(assetcustom_t custom) { errorret_t assetLanguageHandler(assetcustom_t custom) {
assertNotNull(custom.zipFile, "Custom asset zip file cannot be NULL"); assertNotNull(custom.zipFile, "Custom asset zip file cannot be NULL");

View File

@@ -6,9 +6,9 @@
*/ */
#pragma once #pragma once
#include "locale/language/keys.h" #include "locale/language/keys.hpp"
#include "error/error.h" #include "error/error.hpp"
#include "duskdefs.h" #include "duskdefs.hpp"
#include <zip.h> #include <zip.h>
#define ASSET_LANG_CHUNK_CACHE 4 // Number of chunks to cache in memory #define ASSET_LANG_CHUNK_CACHE 4 // Number of chunks to cache in memory

View File

@@ -5,9 +5,9 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "asset/asset.h" #include "asset/asset.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
#include "util/memory.h" #include "util/memory.hpp"
errorret_t assetMapLoad(void *data, void *output) { errorret_t assetMapLoad(void *data, void *output) {
assertNotNull(data, "Data cannot be NULL"); assertNotNull(data, "Data cannot be NULL");

View File

@@ -6,9 +6,9 @@
*/ */
#pragma once #pragma once
#include "error/error.h" #include "error/error.hpp"
#include "rpg/world/map.h" #include "rpg/world/map.hpp"
#include "display/mesh/mesh.h" #include "display/mesh/mesh.hpp"
/** /**
* Loads a map asset from the given data pointer into the output map structure. * Loads a map asset from the given data pointer into the output map structure.

View File

@@ -5,9 +5,9 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "assetpaletteimage.h" #include "assetpaletteimage.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
#include "display/texture.h" #include "display/texture.hpp"
errorret_t assetPaletteImageLoad(void *data, void *output) { errorret_t assetPaletteImageLoad(void *data, void *output) {
assertNotNull(data, "Data pointer cannot be NULL."); assertNotNull(data, "Data pointer cannot be NULL.");

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "error/error.h" #include "error/error.hpp"
#define ASSET_PALETTE_IMAGE_WIDTH_MAX 128 #define ASSET_PALETTE_IMAGE_WIDTH_MAX 128
#define ASSET_PALETTE_IMAGE_HEIGHT_MAX 128 #define ASSET_PALETTE_IMAGE_HEIGHT_MAX 128

View File

@@ -5,8 +5,8 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "asset/asset.h" #include "asset/asset.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
errorret_t assetScriptHandler(assetcustom_t custom) { errorret_t assetScriptHandler(assetcustom_t custom) {
assertNotNull(custom.zipFile, "Custom asset zip file cannot be NULL"); assertNotNull(custom.zipFile, "Custom asset zip file cannot be NULL");

View File

@@ -6,10 +6,10 @@
*/ */
#pragma once #pragma once
#include "error/error.h" #include "error/error.hpp"
#include "duskdefs.h" #include "duskdefs.hpp"
#include <zip.h> #include <zip.h>
#include <lua.h> #include "script/scriptcontext.hpp"
#define ASSET_SCRIPT_BUFFER_SIZE 1024 #define ASSET_SCRIPT_BUFFER_SIZE 1024

View File

@@ -6,7 +6,7 @@
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE PRIVATE
debug.c debug.cpp
) )
# Subdirs # Subdirs

View File

@@ -5,7 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "debug.h" #include "debug.hpp"
void debugPrint(const char_t *message, ...) { void debugPrint(const char_t *message, ...) {
va_list args; va_list args;

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "dusk.h" #include "dusk.hpp"
/** /**
* Prints a debug message to the debug console. * Prints a debug message to the debug console.

View File

@@ -6,12 +6,12 @@
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE PRIVATE
display.c display.cpp
framebuffer.c framebuffer.cpp
camera.c camera.cpp
screen.c screen.cpp
texture.c texture.cpp
spritebatch.c spritebatch.cpp
) )
# Subdirectories # Subdirectories

View File

@@ -5,11 +5,11 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "camera.h" #include "camera.hpp"
#include "display/display.h" #include "display/display.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
#include "display/framebuffer.h" #include "display/framebuffer.hpp"
#include "display/screen.h" #include "display/screen.hpp"
void cameraInit(camera_t *camera) { void cameraInit(camera_t *camera) {
cameraInitPerspective(camera); cameraInitPerspective(camera);
@@ -93,11 +93,12 @@ void cameraPushMatrix(camera_t *camera) {
} }
switch(camera->viewType) { switch(camera->viewType) {
case CAMERA_VIEW_TYPE_MATRIX: case CAMERA_VIEW_TYPE_MATRIX: {
glm_mat4_copy(camera->view, view); glm_mat4_copy(camera->view, view);
break; break;
}
case CAMERA_VIEW_TYPE_LOOKAT: case CAMERA_VIEW_TYPE_LOOKAT: {
glm_lookat( glm_lookat(
camera->lookat.position, camera->lookat.position,
camera->lookat.target, camera->lookat.target,
@@ -105,8 +106,9 @@ void cameraPushMatrix(camera_t *camera) {
view view
); );
break; break;
}
case CAMERA_VIEW_TYPE_LOOKAT_PIXEL_PERFECT: case CAMERA_VIEW_TYPE_LOOKAT_PIXEL_PERFECT: {
assertTrue( assertTrue(
camera->projType == CAMERA_PROJECTION_TYPE_PERSPECTIVE || camera->projType == CAMERA_PROJECTION_TYPE_PERSPECTIVE ||
camera->projType == CAMERA_PROJECTION_TYPE_PERSPECTIVE_FLIPPED, camera->projType == CAMERA_PROJECTION_TYPE_PERSPECTIVE_FLIPPED,
@@ -133,8 +135,9 @@ void cameraPushMatrix(camera_t *camera) {
view view
); );
break; break;
}
case CAMERA_VIEW_TYPE_2D: case CAMERA_VIEW_TYPE_2D: {
glm_mat4_identity(view); glm_mat4_identity(view);
glm_translate(view, (vec3){ glm_translate(view, (vec3){
-camera->_2d.position[0], -camera->_2d.position[0],
@@ -147,6 +150,7 @@ void cameraPushMatrix(camera_t *camera) {
1.0f 1.0f
}); });
break; break;
}
default: default:
assertUnreachable("Invalid camera view type"); assertUnreachable("Invalid camera view type");

View File

@@ -6,8 +6,8 @@
*/ */
#pragma once #pragma once
#include "dusk.h" #include "dusk.hpp"
#include "display/color.h" #include "display/color.hpp"
#define CAMERA_COUNT_MAX 4 #define CAMERA_COUNT_MAX 4
@@ -17,12 +17,11 @@ typedef enum {
CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC
} cameraprojectiontype_t; } cameraprojectiontype_t;
typedef enum { typedef uint8_t cameraviewtype_t;
CAMERA_VIEW_TYPE_MATRIX, #define CAMERA_VIEW_TYPE_MATRIX 0x00
CAMERA_VIEW_TYPE_LOOKAT, #define CAMERA_VIEW_TYPE_LOOKAT 0x01
CAMERA_VIEW_TYPE_2D, #define CAMERA_VIEW_TYPE_2D 0x02
CAMERA_VIEW_TYPE_LOOKAT_PIXEL_PERFECT #define CAMERA_VIEW_TYPE_LOOKAT_PIXEL_PERFECT 0x03
} cameraviewtype_t;
typedef struct { typedef struct {
cameraprojectiontype_t projType; cameraprojectiontype_t projType;

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "dusk.h" #include "dusk.hpp"
typedef float_t colorchannelf_t; typedef float_t colorchannelf_t;
typedef uint8_t colorchannelb_t; typedef uint8_t colorchannelb_t;

View File

@@ -5,15 +5,15 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "display/display.h" #include "display/display.hpp"
#include "engine/engine.h" #include "engine/engine.hpp"
#include "display/framebuffer.h" #include "display/framebuffer.hpp"
#include "scene/scenemanager.h" #include "scene/scenemanager.hpp"
#include "display/spritebatch.h" #include "display/spritebatch.hpp"
#include "display/mesh/quad.h" #include "display/mesh/quad.hpp"
#include "display/screen.h" #include "display/screen.hpp"
#include "ui/ui.h" #include "ui/ui.hpp"
#include "debug/debug.h" #include "debug/debug.hpp"
display_t DISPLAY; display_t DISPLAY;

View File

@@ -6,10 +6,10 @@
*/ */
#pragma once #pragma once
#include "displaydefs.h" #include "displaydefs.hpp"
#include "error/error.h" #include "error/error.hpp"
#include "display/camera.h" #include "display/camera.hpp"
#include "display/framebuffer.h" #include "display/framebuffer.hpp"
typedef struct { typedef struct {
#if DISPLAY_SDL2 #if DISPLAY_SDL2

View File

@@ -5,10 +5,10 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "framebuffer.h" #include "framebuffer.hpp"
#include "display/display.h" #include "display/display.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
#include "util/memory.h" #include "util/memory.hpp"
framebuffer_t FRAMEBUFFER_BACKBUFFER = {0}; framebuffer_t FRAMEBUFFER_BACKBUFFER = {0};
const framebuffer_t *FRAMEBUFFER_BOUND = &FRAMEBUFFER_BACKBUFFER; const framebuffer_t *FRAMEBUFFER_BOUND = &FRAMEBUFFER_BACKBUFFER;
@@ -31,9 +31,11 @@ void frameBufferInitBackbuffer() {
assertTrue(width > 0 && height > 0, "W/H must be greater than 0"); assertTrue(width > 0 && height > 0, "W/H must be greater than 0");
memoryZero(framebuffer, sizeof(framebuffer_t)); memoryZero(framebuffer, sizeof(framebuffer_t));
textureInit(&framebuffer->texture, width, height, GL_RGBA,(texturedata_t){ textureInit(
.rgba = { .colors = NULL } &framebuffer->texture,
}); width, height, TEXTURE_FORMAT_RGBA,
(texturedata_t){ .rgba = { .colors = NULL } }
);
glGenFramebuffersEXT(1, &framebuffer->id); glGenFramebuffersEXT(1, &framebuffer->id);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer->id); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer->id);

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "display/texture.h" #include "display/texture.hpp"
#define FRAMEBUFFER_CLEAR_COLOR (1 << 0) #define FRAMEBUFFER_CLEAR_COLOR (1 << 0)
#define FRAMEBUFFER_CLEAR_DEPTH (1 << 1) #define FRAMEBUFFER_CLEAR_DEPTH (1 << 1)

View File

@@ -6,6 +6,6 @@
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE PRIVATE
mesh.c mesh.cpp
quad.c quad.cpp
) )

View File

@@ -5,9 +5,9 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "mesh.h" #include "mesh.hpp"
#include "util/memory.h" #include "util/memory.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
void meshInit( void meshInit(
mesh_t *mesh, mesh_t *mesh,

View File

@@ -4,8 +4,8 @@
// https://opensource.org/licenses/MIT // https://opensource.org/licenses/MIT
#pragma once #pragma once
#include "display/display.h" #include "display/display.hpp"
#include "display/color.h" #include "display/color.hpp"
typedef enum { typedef enum {
#if DISPLAY_SDL2 #if DISPLAY_SDL2

View File

@@ -5,8 +5,8 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "quad.h" #include "quad.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
mesh_t QUAD_MESH_SIMPLE; mesh_t QUAD_MESH_SIMPLE;
meshvertex_t QUAD_MESH_SIMPLE_VERTICES[QUAD_VERTEX_COUNT] = { meshvertex_t QUAD_MESH_SIMPLE_VERTICES[QUAD_VERTEX_COUNT] = {

View File

@@ -6,8 +6,8 @@
*/ */
#pragma once #pragma once
#include "mesh.h" #include "mesh.hpp"
#include "display/color.h" #include "display/color.hpp"
#define QUAD_VERTEX_COUNT 6 #define QUAD_VERTEX_COUNT 6
#define QUAD_PRIMITIVE_TYPE MESH_PRIMITIVE_TRIANGLES #define QUAD_PRIMITIVE_TYPE MESH_PRIMITIVE_TRIANGLES

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "display/color.h" #include "display/color.hpp"
typedef struct { typedef struct {
const uint8_t colorCount; const uint8_t colorCount;

View File

@@ -5,10 +5,10 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "screen.h" #include "screen.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
#include "util/memory.h" #include "util/memory.hpp"
#include "display/mesh/quad.h" #include "display/mesh/quad.hpp"
screen_t SCREEN; screen_t SCREEN;

View File

@@ -6,10 +6,10 @@
*/ */
#pragma once #pragma once
#include "dusk.h" #include "dusk.hpp"
#include "display/framebuffer.h" #include "display/framebuffer.hpp"
#include "display/camera.h" #include "display/camera.hpp"
#include "display/mesh/quad.h" #include "display/mesh/quad.hpp"
#if DISPLAY_SIZE_DYNAMIC == 1 #if DISPLAY_SIZE_DYNAMIC == 1
#ifndef DISPLAY_SCREEN_HEIGHT_DEFAULT #ifndef DISPLAY_SCREEN_HEIGHT_DEFAULT

View File

@@ -5,9 +5,9 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "spritebatch.h" #include "spritebatch.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
#include "util/memory.h" #include "util/memory.hpp"
spritebatch_t SPRITEBATCH; spritebatch_t SPRITEBATCH;

View File

@@ -6,8 +6,8 @@
*/ */
#pragma once #pragma once
#include "display/mesh/quad.h" #include "display/mesh/quad.hpp"
#include "display/texture.h" #include "display/texture.hpp"
#define SPRITEBATCH_SPRITES_MAX 1 #define SPRITEBATCH_SPRITES_MAX 1
#define SPRITEBATCH_VERTEX_COUNT (SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT) #define SPRITEBATCH_VERTEX_COUNT (SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT)

View File

@@ -5,11 +5,11 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "texture.h" #include "texture.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
#include "util/memory.h" #include "util/memory.hpp"
#include "util/math.h" #include "util/math.hpp"
#include "display/palette/palettelist.h" #include "display/palette/palettelist.hpp"
const texture_t *TEXTURE_BOUND = NULL; const texture_t *TEXTURE_BOUND = NULL;
@@ -43,21 +43,23 @@ void textureInit(
glBindTexture(GL_TEXTURE_2D, texture->id); glBindTexture(GL_TEXTURE_2D, texture->id);
switch(format) { switch(format) {
case TEXTURE_FORMAT_RGBA: case TEXTURE_FORMAT_RGBA: {
glTexImage2D( glTexImage2D(
GL_TEXTURE_2D, 0, format, width, height, 0, GL_TEXTURE_2D, 0, format, width, height, 0,
format, GL_UNSIGNED_BYTE, (void*)data.rgba.colors format, GL_UNSIGNED_BYTE, (void*)data.rgba.colors
); );
break; break;
}
case TEXTURE_FORMAT_ALPHA: case TEXTURE_FORMAT_ALPHA: {
glTexImage2D( glTexImage2D(
GL_TEXTURE_2D, 0, format, width, height, 0, GL_TEXTURE_2D, 0, format, width, height, 0,
format, GL_UNSIGNED_BYTE, (void*)data.alpha.data format, GL_UNSIGNED_BYTE, (void*)data.alpha.data
); );
break; break;
}
case TEXTURE_FORMAT_PALETTE: case TEXTURE_FORMAT_PALETTE: {
assertNotNull(data.palette.data, "Palette texture data cannot be NULL"); assertNotNull(data.palette.data, "Palette texture data cannot be NULL");
assertTrue( assertTrue(
data.palette.palette < PALETTE_LIST_COUNT, data.palette.palette < PALETTE_LIST_COUNT,
@@ -130,8 +132,8 @@ void textureInit(
GL_UNSIGNED_BYTE, (const void*)pal->colors GL_UNSIGNED_BYTE, (const void*)pal->colors
); );
} }
break; break;
}
default: default:
assertUnreachable("Unknown texture format"); assertUnreachable("Unknown texture format");

View File

@@ -6,8 +6,8 @@
*/ */
#pragma once #pragma once
#include "display/color.h" #include "display/color.hpp"
#include "display/displaydefs.h" #include "display/displaydefs.hpp"
typedef enum { typedef enum {
#if DISPLAY_SDL2 #if DISPLAY_SDL2

View File

@@ -6,5 +6,5 @@
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE PRIVATE
tileset.c tileset.cpp
) )

View File

@@ -5,7 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "tileset.h" #include "tileset.hpp"
void tilesetTileGetUV( void tilesetTileGetUV(
const tileset_t *tileset, const tileset_t *tileset,

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "dusk.h" #include "dusk.hpp"
typedef struct tileset_s { typedef struct tileset_s {
const uint16_t tileWidth; const uint16_t tileWidth;

View File

@@ -1,35 +0,0 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <errno.h>
#include <ctype.h>
#include <stdarg.h>
#include <float.h>
#include <cglm/cglm.h>
#include <cglm/types.h>
#include <cglm/vec2.h>
#if PSP
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <psphprm.h>
#endif
typedef bool bool_t;
typedef int int_t;
typedef float float_t;
typedef char char_t;

38
src/dusk.hpp Normal file
View File

@@ -0,0 +1,38 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
extern "C" {
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <errno.h>
#include <ctype.h>
#include <stdarg.h>
#include <float.h>
#include <cglm/cglm.h>
#include <cglm/types.h>
#include <cglm/vec2.h>
#if PSP
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <psphprm.h>
#endif
typedef bool bool_t;
typedef int int_t;
typedef float float_t;
typedef char char_t;
}

View File

@@ -6,5 +6,5 @@
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE PRIVATE
engine.c engine.cpp
) )

View File

@@ -5,20 +5,20 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "engine.h" #include "engine.hpp"
#include "util/memory.h" #include "util/memory.hpp"
#include "time/time.h" #include "time/time.hpp"
#include "input/input.h" #include "input/input.hpp"
#include "locale/localemanager.h" #include "locale/localemanager.hpp"
#include "display/display.h" #include "display/display.hpp"
#include "scene/scenemanager.h" #include "scene/scenemanager.hpp"
#include "asset/asset.h" #include "asset/asset.hpp"
#include "ui/ui.h" #include "ui/ui.hpp"
#include "rpg/rpg.h" #include "rpg/rpg.hpp"
#include "script/scriptmanager.h" #include "script/scriptmanager.hpp"
#include "debug/debug.h" #include "debug/debug.hpp"
#include "script/scriptcontext.h" #include "script/scriptcontext.hpp"
engine_t ENGINE; engine_t ENGINE;

View File

@@ -6,8 +6,8 @@
*/ */
#pragma once #pragma once
#include "display/display.h"// Important to be included first. #include "display/display.hpp"// Important to be included first.
#include "error/error.h" #include "error/error.hpp"
typedef struct { typedef struct {
bool_t running; bool_t running;

View File

@@ -6,5 +6,5 @@
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE PRIVATE
error.c error.cpp
) )

View File

@@ -5,11 +5,11 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "assert/assert.h" #include "assert/assert.hpp"
#include "error.h" #include "error.hpp"
#include "util/memory.h" #include "util/memory.hpp"
#include "util/string.h" #include "util/string.hpp"
#include "debug/debug.h" #include "debug/debug.hpp"
errorstate_t ERROR_STATE = { 0 }; errorstate_t ERROR_STATE = { 0 };

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "dusk.h" #include "dusk.hpp"
typedef uint8_t errorcode_t; typedef uint8_t errorcode_t;

View File

@@ -6,9 +6,9 @@
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE PRIVATE
input.c input.cpp
inputbutton.c inputbutton.cpp
inputaction.c inputaction.cpp
) )
if(DUSK_TARGET_SYSTEM STREQUAL "linux") if(DUSK_TARGET_SYSTEM STREQUAL "linux")

View File

@@ -5,12 +5,12 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "input.h" #include "input.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
#include "util/memory.h" #include "util/memory.hpp"
#include "util/string.h" #include "util/string.hpp"
#include "util/math.h" #include "util/math.hpp"
#include "time/time.h" #include "time/time.hpp"
input_t INPUT; input_t INPUT;

View File

@@ -6,8 +6,8 @@
*/ */
#pragma once #pragma once
#include "inputbutton.h" #include "inputbutton.hpp"
#include "inputaction.h" #include "inputaction.hpp"
typedef struct { typedef struct {
inputactiondata_t actions[INPUT_ACTION_COUNT]; inputactiondata_t actions[INPUT_ACTION_COUNT];

View File

@@ -5,9 +5,9 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "inputaction.h" #include "inputaction.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
#include "util/string.h" #include "util/string.hpp"
// inputaction_t inputActionGetByName(const char_t *name) { // inputaction_t inputActionGetByName(const char_t *name) {
// assertNotNull(name, "name must not be NULL"); // assertNotNull(name, "name must not be NULL");

View File

@@ -6,20 +6,19 @@
*/ */
#pragma once #pragma once
#include "time/time.h" #include "time/time.hpp"
typedef enum { typedef uint8_t inputaction_t;
INPUT_ACTION_NULL,
INPUT_ACTION_UP,
INPUT_ACTION_DOWN,
INPUT_ACTION_LEFT,
INPUT_ACTION_RIGHT,
INPUT_ACTION_ACCEPT,
INPUT_ACTION_CANCEL,
INPUT_ACTION_RAGEQUIT,
INPUT_ACTION_COUNT #define INPUT_ACTION_NULL 0x00
} inputaction_t; #define INPUT_ACTION_UP 0x01
#define INPUT_ACTION_DOWN 0x02
#define INPUT_ACTION_LEFT 0x03
#define INPUT_ACTION_RIGHT 0x04
#define INPUT_ACTION_ACCEPT 0x05
#define INPUT_ACTION_CANCEL 0x06
#define INPUT_ACTION_RAGEQUIT 0x07
#define INPUT_ACTION_COUNT INPUT_ACTION_RAGEQUIT + 1
typedef struct { typedef struct {
inputaction_t action; inputaction_t action;

View File

@@ -1,233 +0,0 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "inputbutton.h"
#include "input.h"
#include "assert/assert.h"
#include "util/string.h"
inputbuttondata_t INPUT_BUTTON_DATA[] = {
#if INPUT_SDL2 == 1
#if INPUT_GAMEPAD == 1
#if PSP
{ .name = "triangle", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_Y } },
{ .name = "cross", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_A } },
{ .name = "circle", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_B } },
{ .name = "square", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_X } },
{ .name = "start", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_START } },
{ .name = "select", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_BACK } },
{ .name = "up", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_UP } },
{ .name = "down", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_DOWN } },
{ .name = "left", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_LEFT } },
{ .name = "right", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_RIGHT } },
{ .name = "l", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_LEFTSHOULDER } },
{ .name = "r", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER } },
{ .name = "lstick_positive_x", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = true } } },
{ .name = "lstick_negative_x", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = false } } },
{ .name = "lstick_positive_y", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = true } } },
{ .name = "lstick_negative_y", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = false } } },
#else
#endif
#endif
#if INPUT_KEYBOARD == 1
{ .name = "a", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_A } },
{ .name = "b", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_B } },
{ .name = "c", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_C } },
{ .name = "d", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_D } },
{ .name = "e", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_E } },
{ .name = "f", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F } },
{ .name = "g", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_G } },
{ .name = "h", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_H } },
{ .name = "i", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_I } },
{ .name = "j", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_J } },
{ .name = "k", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_K } },
{ .name = "l", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_L } },
{ .name = "m", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_M } },
{ .name = "n", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_N } },
{ .name = "o", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_O } },
{ .name = "p", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_P } },
{ .name = "q", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_Q } },
{ .name = "r", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_R } },
{ .name = "s", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_S } },
{ .name = "t", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_T } },
{ .name = "u", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_U } },
{ .name = "v", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_V } },
{ .name = "w", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_W } },
{ .name = "x", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_X } },
{ .name = "y", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_Y } },
{ .name = "z", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_Z } },
{ .name = "0", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_0 } },
{ .name = "1", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_1 } },
{ .name = "2", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_2 } },
{ .name = "3", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_3 } },
{ .name = "4", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_4 } },
{ .name = "5", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_5 } },
{ .name = "6", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_6 } },
{ .name = "7", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_7 } },
{ .name = "8", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_8 } },
{ .name = "9", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_9 } },
{ .name = "space", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SPACE } },
{ .name = "shift", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LSHIFT } },
{ .name = "lshift", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LSHIFT } },
{ .name = "rshift", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RSHIFT } },
{ .name = "lctrl", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LCTRL } },
{ .name = "rctrl", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RCTRL } },
{ .name = "ctrl", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LCTRL } },
{ .name = "lalt", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LALT } },
{ .name = "ralt", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RALT } },
{ .name = "tab", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_TAB } },
{ .name = "enter", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RETURN } },
{ .name = "backspace", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_BACKSPACE } },
{ .name = "escape", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_ESCAPE } },
{ .name = "esc", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_ESCAPE } },
{ .name = "up", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_UP } },
{ .name = "down", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_DOWN } },
{ .name = "left", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LEFT } },
{ .name = "right", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RIGHT } },
{ .name = "pageup", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_PAGEUP } },
{ .name = "pagedown", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_PAGEDOWN } },
{ .name = "home", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_HOME } },
{ .name = "end", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_END } },
{ .name = "insert", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_INSERT } },
{ .name = "delete", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_DELETE } },
{ .name = "f1", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F1 } },
{ .name = "f2", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F2 } },
{ .name = "f3", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F3 } },
{ .name = "f4", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F4 } },
{ .name = "f5", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F5 } },
{ .name = "f6", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F6 } },
{ .name = "f7", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F7 } },
{ .name = "f8", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F8 } },
{ .name = "f9", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F9 } },
{ .name = "f10", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F10 } },
{ .name = "f11", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F11 } },
{ .name = "f12", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F12 } },
{ .name = "f13", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F13 } },
{ .name = "f14", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F14 } },
{ .name = "f15", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F15 } },
{ .name = "f16", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F16 } },
{ .name = "f17", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F17 } },
{ .name = "f18", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F18 } },
{ .name = "f19", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F19 } },
{ .name = "f20", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F20 } },
{ .name = "f21", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F21 } },
{ .name = "f22", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F22 } },
{ .name = "f23", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F23 } },
{ .name = "f24", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F24 } },
{ .name = "minus", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_MINUS } },
{ .name = "equals", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_EQUALS } },
{ .name = "leftbracket", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LEFTBRACKET } },
{ .name = "rightbracket", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RIGHTBRACKET } },
{ .name = "backslash", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_BACKSLASH } },
{ .name = "semicolon", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SEMICOLON } },
{ .name = "apostrophe", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_APOSTROPHE } },
{ .name = "grave", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_GRAVE } },
{ .name = "comma", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_COMMA } },
{ .name = "period", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_PERIOD } },
{ .name = "slash", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SLASH } },
{ .name = "caps", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_CAPSLOCK } },
{ .name = "capslock", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_CAPSLOCK } },
{ .name = "numlock", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_NUMLOCKCLEAR } },
{ .name = "scrollock", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SCROLLLOCK } },
{ .name = "-", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_MINUS } },
{ .name = "=", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_EQUALS } },
{ .name = "[", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LEFTBRACKET } },
{ .name = "]", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RIGHTBRACKET } },
{ .name = "\\", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_BACKSLASH } },
{ .name = ";", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SEMICOLON } },
{ .name = "'", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_APOSTROPHE } },
{ .name = "`", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_GRAVE } },
{ .name = ",", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_COMMA } },
{ .name = ".", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_PERIOD } },
{ .name = "/", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SLASH } },
{ .name = "kp_0", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_0 } },
{ .name = "kp_1", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_1 } },
{ .name = "kp_2", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_2 } },
{ .name = "kp_3", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_3 } },
{ .name = "kp_4", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_4 } },
{ .name = "kp_5", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_5 } },
{ .name = "kp_6", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_6 } },
{ .name = "kp_7", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_7 } },
{ .name = "kp_8", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_8 } },
{ .name = "kp_9", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_9 } },
{ .name = "kp_period", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_PERIOD } },
{ .name = "kp_divide", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_DIVIDE } },
{ .name = "kp_multiply", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_MULTIPLY } },
{ .name = "kp_minus", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_MINUS } },
{ .name = "kp_plus", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_PLUS } },
{ .name = "kp_enter", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_ENTER } },
{ .name = "kp_equals", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_EQUALS } },
#endif
#endif
{ .name = NULL }
};
inputbutton_t inputButtonGetByName(const char_t *name) {
assertNotNull(name, "name must not be NULL");
inputbuttondata_t *data = INPUT_BUTTON_DATA;
while(data->name != NULL) {
if(stringCompareInsensitive(data->name, name) == 0) {
return data->button;
}
data++;
}
return (inputbutton_t){ .type = INPUT_BUTTON_TYPE_NONE };
}
float_t inputButtonGetValue(const inputbutton_t button) {
switch(button.type) {
#if INPUT_KEYBOARD == 1
case INPUT_BUTTON_TYPE_KEYBOARD: {
#if INPUT_SDL2 == 1
return INPUT.keyboardState[button.scancode] ? 1.0f : 0.0f;
#else
return 0.0f;
#endif
}
#endif
#if INPUT_GAMEPAD == 1
case INPUT_BUTTON_TYPE_GAMEPAD: {
#if INPUT_SDL2 == 1
if(SDL_GameControllerGetButton(INPUT.controller, button.gpButton)) {
return 1.0f;
}
#endif
return 0.0f;
}
case INPUT_BUTTON_TYPE_GAMEPAD_AXIS: {
#if INPUT_SDL2 == 1
Sint16 axis = SDL_GameControllerGetAxis(INPUT.controller, button.gpAxis.axis);
if(!button.gpAxis.positive) axis = -axis;
float_t value = (float_t)axis / 32767.0f;
// Deadzone
if(value < INPUT.deadzone) return 0.0f;
return value;
#endif
}
#endif
default: {
assertUnreachable("Unknown input button type");
return 0.0f;
}
}
}

233
src/input/inputbutton.cpp Normal file
View File

@@ -0,0 +1,233 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "inputbutton.hpp"
#include "input.hpp"
#include "assert/assert.hpp"
#include "util/string.hpp"
inputbuttondata_t INPUT_BUTTON_DATA[] = {
#if INPUT_SDL2 == 1
#if INPUT_GAMEPAD == 1
#if PSP
{ .name = "triangle", .button = { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_Y } },
{ .name = "cross", .button = { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_A } },
{ .name = "circle", .button = { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_B } },
{ .name = "square", .button = { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_X } },
{ .name = "start", .button = { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_START } },
{ .name = "select", .button = { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_BACK } },
{ .name = "up", .button = { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_UP } },
{ .name = "down", .button = { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_DOWN } },
{ .name = "left", .button = { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_LEFT } },
{ .name = "right", .button = { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_RIGHT } },
{ .name = "l", .button = { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_LEFTSHOULDER } },
{ .name = "r", .button = { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER } },
{ .name = "lstick_positive_x", .button = { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = true } } },
{ .name = "lstick_negative_x", .button = { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = false } } },
{ .name = "lstick_positive_y", .button = { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = true } } },
{ .name = "lstick_negative_y", .button = { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = false } } },
#else
#endif
#endif
#if INPUT_KEYBOARD == 1
{ .name = "a", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_A } },
{ .name = "b", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_B } },
{ .name = "c", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_C } },
{ .name = "d", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_D } },
{ .name = "e", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_E } },
{ .name = "f", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F } },
{ .name = "g", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_G } },
{ .name = "h", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_H } },
{ .name = "i", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_I } },
{ .name = "j", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_J } },
{ .name = "k", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_K } },
{ .name = "l", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_L } },
{ .name = "m", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_M } },
{ .name = "n", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_N } },
{ .name = "o", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_O } },
{ .name = "p", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_P } },
{ .name = "q", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_Q } },
{ .name = "r", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_R } },
{ .name = "s", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_S } },
{ .name = "t", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_T } },
{ .name = "u", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_U } },
{ .name = "v", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_V } },
{ .name = "w", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_W } },
{ .name = "x", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_X } },
{ .name = "y", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_Y } },
{ .name = "z", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_Z } },
{ .name = "0", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_0 } },
{ .name = "1", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_1 } },
{ .name = "2", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_2 } },
{ .name = "3", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_3 } },
{ .name = "4", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_4 } },
{ .name = "5", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_5 } },
{ .name = "6", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_6 } },
{ .name = "7", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_7 } },
{ .name = "8", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_8 } },
{ .name = "9", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_9 } },
{ .name = "space", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SPACE } },
{ .name = "shift", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LSHIFT } },
{ .name = "lshift", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LSHIFT } },
{ .name = "rshift", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RSHIFT } },
{ .name = "lctrl", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LCTRL } },
{ .name = "rctrl", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RCTRL } },
{ .name = "ctrl", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LCTRL } },
{ .name = "lalt", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LALT } },
{ .name = "ralt", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RALT } },
{ .name = "tab", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_TAB } },
{ .name = "enter", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RETURN } },
{ .name = "backspace", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_BACKSPACE } },
{ .name = "escape", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_ESCAPE } },
{ .name = "esc", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_ESCAPE } },
{ .name = "up", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_UP } },
{ .name = "down", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_DOWN } },
{ .name = "left", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LEFT } },
{ .name = "right", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RIGHT } },
{ .name = "pageup", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_PAGEUP } },
{ .name = "pagedown", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_PAGEDOWN } },
{ .name = "home", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_HOME } },
{ .name = "end", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_END } },
{ .name = "insert", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_INSERT } },
{ .name = "delete", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_DELETE } },
{ .name = "f1", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F1 } },
{ .name = "f2", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F2 } },
{ .name = "f3", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F3 } },
{ .name = "f4", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F4 } },
{ .name = "f5", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F5 } },
{ .name = "f6", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F6 } },
{ .name = "f7", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F7 } },
{ .name = "f8", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F8 } },
{ .name = "f9", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F9 } },
{ .name = "f10", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F10 } },
{ .name = "f11", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F11 } },
{ .name = "f12", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F12 } },
{ .name = "f13", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F13 } },
{ .name = "f14", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F14 } },
{ .name = "f15", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F15 } },
{ .name = "f16", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F16 } },
{ .name = "f17", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F17 } },
{ .name = "f18", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F18 } },
{ .name = "f19", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F19 } },
{ .name = "f20", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F20 } },
{ .name = "f21", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F21 } },
{ .name = "f22", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F22 } },
{ .name = "f23", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F23 } },
{ .name = "f24", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_F24 } },
{ .name = "minus", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_MINUS } },
{ .name = "equals", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_EQUALS } },
{ .name = "leftbracket", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LEFTBRACKET } },
{ .name = "rightbracket", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RIGHTBRACKET } },
{ .name = "backslash", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_BACKSLASH } },
{ .name = "semicolon", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SEMICOLON } },
{ .name = "apostrophe", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_APOSTROPHE } },
{ .name = "grave", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_GRAVE } },
{ .name = "comma", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_COMMA } },
{ .name = "period", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_PERIOD } },
{ .name = "slash", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SLASH } },
{ .name = "caps", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_CAPSLOCK } },
{ .name = "capslock", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_CAPSLOCK } },
{ .name = "numlock", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_NUMLOCKCLEAR } },
{ .name = "scrollock", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SCROLLLOCK } },
{ .name = "-", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_MINUS } },
{ .name = "=", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_EQUALS } },
{ .name = "[", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_LEFTBRACKET } },
{ .name = "]", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_RIGHTBRACKET } },
{ .name = "\\", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_BACKSLASH } },
{ .name = ";", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SEMICOLON } },
{ .name = "'", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_APOSTROPHE } },
{ .name = "`", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_GRAVE } },
{ .name = ",", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_COMMA } },
{ .name = ".", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_PERIOD } },
{ .name = "/", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_SLASH } },
{ .name = "kp_0", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_0 } },
{ .name = "kp_1", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_1 } },
{ .name = "kp_2", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_2 } },
{ .name = "kp_3", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_3 } },
{ .name = "kp_4", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_4 } },
{ .name = "kp_5", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_5 } },
{ .name = "kp_6", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_6 } },
{ .name = "kp_7", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_7 } },
{ .name = "kp_8", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_8 } },
{ .name = "kp_9", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_9 } },
{ .name = "kp_period", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_PERIOD } },
{ .name = "kp_divide", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_DIVIDE } },
{ .name = "kp_multiply", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_MULTIPLY } },
{ .name = "kp_minus", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_MINUS } },
{ .name = "kp_plus", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_PLUS } },
{ .name = "kp_enter", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_ENTER } },
{ .name = "kp_equals", .button = { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_EQUALS } },
#endif
#endif
{ .name = NULL }
};
inputbutton_t inputButtonGetByName(const char_t *name) {
assertNotNull(name, "name must not be NULL");
inputbuttondata_t *data = INPUT_BUTTON_DATA;
while(data->name != NULL) {
if(stringCompareInsensitive(data->name, name) == 0) {
return data->button;
}
data++;
}
return (inputbutton_t){ .type = INPUT_BUTTON_TYPE_NONE };
}
float_t inputButtonGetValue(const inputbutton_t button) {
switch(button.type) {
#if INPUT_KEYBOARD == 1
case INPUT_BUTTON_TYPE_KEYBOARD: {
#if INPUT_SDL2 == 1
return INPUT.keyboardState[button.scancode] ? 1.0f : 0.0f;
#else
return 0.0f;
#endif
}
#endif
#if INPUT_GAMEPAD == 1
case INPUT_BUTTON_TYPE_GAMEPAD: {
#if INPUT_SDL2 == 1
if(SDL_GameControllerGetButton(INPUT.controller, button.gpButton)) {
return 1.0f;
}
#endif
return 0.0f;
}
case INPUT_BUTTON_TYPE_GAMEPAD_AXIS: {
#if INPUT_SDL2 == 1
Sint16 axis = SDL_GameControllerGetAxis(INPUT.controller, button.gpAxis.axis);
if(!button.gpAxis.positive) axis = -axis;
float_t value = (float_t)axis / 32767.0f;
// Deadzone
if(value < INPUT.deadzone) return 0.0f;
return value;
#endif
}
#endif
default: {
assertUnreachable("Unknown input button type");
return 0.0f;
}
}
}

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "inputaction.h" #include "inputaction.hpp"
#if INPUT_SDL2 == 1 #if INPUT_SDL2 == 1
#include <SDL2/SDL.h> #include <SDL2/SDL.h>

View File

@@ -6,5 +6,5 @@
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE PRIVATE
localemanager.c localemanager.cpp
) )

View File

@@ -5,10 +5,10 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "localemanager.h" #include "localemanager.hpp"
#include "util/memory.h" #include "util/memory.hpp"
#include "asset/asset.h" #include "asset/asset.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
localemanager_t LOCALE; localemanager_t LOCALE;

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "asset/asset.h" #include "asset/asset.hpp"
typedef enum { typedef enum {
DUSK_LOCALE_EN_US, DUSK_LOCALE_EN_US,

View File

@@ -5,10 +5,10 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "engine/engine.h" #include "engine/engine.hpp"
#include "asset/asset.h" #include "asset/asset.hpp"
#include "util/string.h" #include "util/string.hpp"
#include "input/input.h" #include "input/input.hpp"
int main(int argc, char **argv) { int main(int argc, char **argv) {
// Main applet // Main applet

View File

@@ -6,9 +6,9 @@
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE PRIVATE
rpg.c rpg.cpp
rpgcamera.c rpgcamera.cpp
rpgtextbox.c rpgtextbox.cpp
) )
# Subdirs # Subdirs

View File

@@ -6,8 +6,8 @@
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE PRIVATE
cutscenesystem.c cutscenesystem.cpp
cutscenemode.c cutscenemode.cpp
) )
# Subdirs # Subdirs

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "rpg/cutscene/item/cutsceneitem.h" #include "rpg/cutscene/item/cutsceneitem.hpp"
typedef struct cutscene_s { typedef struct cutscene_s {
const cutsceneitem_t *items; const cutsceneitem_t *items;

View File

@@ -5,7 +5,7 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "rpg/cutscene/cutscenesystem.h" #include "rpg/cutscene/cutscenesystem.hpp"
bool_t cutsceneModeIsInputAllowed() { bool_t cutsceneModeIsInputAllowed() {
switch(CUTSCENE_SYSTEM.mode) { switch(CUTSCENE_SYSTEM.mode) {

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "dusk.h" #include "dusk.hpp"
typedef enum { typedef enum {
CUTSCENE_MODE_NONE, CUTSCENE_MODE_NONE,

View File

@@ -5,8 +5,8 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "cutscenesystem.h" #include "cutscenesystem.hpp"
#include "util/memory.h" #include "util/memory.hpp"
cutscenesystem_t CUTSCENE_SYSTEM; cutscenesystem_t CUTSCENE_SYSTEM;

View File

@@ -6,8 +6,8 @@
*/ */
#pragma once #pragma once
#include "cutscene.h" #include "cutscene.hpp"
#include "cutscenemode.h" #include "cutscenemode.hpp"
typedef struct { typedef struct {
const cutscene_t *scene; const cutscene_t *scene;

View File

@@ -6,5 +6,5 @@
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE PRIVATE
cutsceneitem.c cutsceneitem.cpp
) )

View File

@@ -6,6 +6,6 @@
*/ */
#pragma once #pragma once
#include "dusk.h" #include "dusk.hpp"
typedef void (*cutscenecallback_t)(void); typedef void (*cutscenecallback_t)(void);

View File

@@ -6,8 +6,6 @@
*/ */
#pragma once #pragma once
#include "dusk.h" #include "dusk.hpp"
typedef struct cutscene_s cutscene_t; typedef struct cutscene_s cutscene_t;
typedef cutscene_t* cutscenecutscene_t;

View File

@@ -5,9 +5,9 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "rpg/cutscene/cutscenesystem.h" #include "rpg/cutscene/cutscenesystem.hpp"
#include "input/input.h" #include "input/input.hpp"
#include "time/time.h" #include "time/time.hpp"
void cutsceneItemStart(const cutsceneitem_t *item, cutsceneitemdata_t *data) { void cutsceneItemStart(const cutsceneitem_t *item, cutsceneitemdata_t *data) {
switch(item->type) { switch(item->type) {

View File

@@ -6,10 +6,10 @@
*/ */
#pragma once #pragma once
#include "cutscenewait.h" #include "cutscenewait.hpp"
#include "cutscenecallback.h" #include "cutscenecallback.hpp"
#include "cutscenetext.h" #include "cutscenetext.hpp"
#include "cutscenecutscene.h" #include "cutscenecutscene.hpp"
typedef enum { typedef enum {
CUTSCENE_ITEM_TYPE_NULL, CUTSCENE_ITEM_TYPE_NULL,
@@ -27,7 +27,7 @@ typedef struct cutsceneitem_s {
cutscenetext_t text; cutscenetext_t text;
cutscenecallback_t callback; cutscenecallback_t callback;
cutscenewait_t wait; cutscenewait_t wait;
const cutscenecutscene_t cutscene; const cutscene_t *cutscene;
}; };
} cutsceneitem_t; } cutsceneitem_t;

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "rpg/rpgtextbox.h" #include "rpg/rpgtextbox.hpp"
typedef struct { typedef struct {
char_t text[RPG_TEXTBOX_MAX_CHARS]; char_t text[RPG_TEXTBOX_MAX_CHARS];

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "dusk.h" #include "dusk.hpp"
typedef float_t cutscenewait_t; typedef float_t cutscenewait_t;
typedef float_t cutscenewaitdata_t; typedef float_t cutscenewaitdata_t;

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "rpg/cutscene/cutscenesystem.h" #include "rpg/cutscene/cutscenesystem.hpp"
static const cutsceneitem_t TEST_CUTSCENE_ONE_ITEMS[] = { static const cutsceneitem_t TEST_CUTSCENE_ONE_ITEMS[] = {
{ .type = CUTSCENE_ITEM_TYPE_TEXT, .text = { .text = "This is a test cutscene.", .position = RPG_TEXTBOX_POS_BOTTOM } }, { .type = CUTSCENE_ITEM_TYPE_TEXT, .text = { .text = "This is a test cutscene.", .position = RPG_TEXTBOX_POS_BOTTOM } },

View File

@@ -6,9 +6,9 @@
# Sources # Sources
target_sources(${DUSK_TARGET_NAME} target_sources(${DUSK_TARGET_NAME}
PRIVATE PRIVATE
entity.c entity.cpp
entityanim.c entityanim.cpp
npc.c npc.cpp
player.c player.cpp
entitydir.c entitydir.cpp
) )

View File

@@ -5,13 +5,13 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "entity.h" #include "entity.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
#include "util/memory.h" #include "util/memory.hpp"
#include "time/time.h" #include "time/time.hpp"
#include "util/math.h" #include "util/math.hpp"
#include "rpg/cutscene/cutscenemode.h" #include "rpg/cutscene/cutscenemode.hpp"
#include "rpg/world/map.h" #include "rpg/world/map.hpp"
entity_t ENTITIES[ENTITY_COUNT]; entity_t ENTITIES[ENTITY_COUNT];

View File

@@ -6,17 +6,17 @@
*/ */
#pragma once #pragma once
#include "entitydir.h" #include "entitydir.hpp"
#include "entityanim.h" #include "entityanim.hpp"
#include "entitytype.h" #include "entitytype.hpp"
#include "npc.h" #include "npc.hpp"
typedef struct map_s map_t; typedef struct map_s map_t;
typedef struct entity_s { typedef struct entity_s {
uint8_t id; uint8_t id;
entitytype_t type; entitytype_t type;
entitytypedata_t; entitytypedata_t data;
// Movement // Movement
entitydir_t direction; entitydir_t direction;

View File

@@ -5,5 +5,5 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "entityanim.h" #include "entityanim.hpp"

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "dusk.h" #include "dusk.hpp"
#define ENTITY_ANIM_TURN_DURATION 0.06f #define ENTITY_ANIM_TURN_DURATION 0.06f
#define ENTITY_ANIM_WALK_DURATION 0.1f #define ENTITY_ANIM_WALK_DURATION 0.1f

View File

@@ -5,8 +5,8 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "entitydir.h" #include "entitydir.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
entitydir_t entityDirGetOpposite(const entitydir_t dir) { entitydir_t entityDirGetOpposite(const entitydir_t dir) {
switch(dir) { switch(dir) {

View File

@@ -6,14 +6,13 @@
*/ */
#pragma once #pragma once
#include "rpg/world/worldpos.h" #include "rpg/world/worldpos.hpp"
typedef enum { typedef uint8_t entitydir_t;
ENTITY_DIR_UP = ENTITY_DIR_NORTH, #define ENTITY_DIR_UP ENTITY_DIR_NORTH
ENTITY_DIR_DOWN = ENTITY_DIR_SOUTH, #define ENTITY_DIR_DOWN ENTITY_DIR_SOUTH
ENTITY_DIR_LEFT = ENTITY_DIR_WEST, #define ENTITY_DIR_LEFT ENTITY_DIR_WEST
ENTITY_DIR_RIGHT = ENTITY_DIR_EAST, #define ENTITY_DIR_RIGHT ENTITY_DIR_EAST
} entitydir_t;
/** /**
* Gets the opposite direction of a given direction. * Gets the opposite direction of a given direction.

View File

@@ -6,9 +6,9 @@
*/ */
#pragma once #pragma once
#include "duskdefs.h" #include "duskdefs.hpp"
#include "rpg/entity/player.h" #include "rpg/entity/player.hpp"
#include "npc.h" #include "npc.hpp"
typedef uint8_t entitytype_t; typedef uint8_t entitytype_t;

View File

@@ -5,11 +5,11 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "entity.h" #include "entity.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
#include "rpg/cutscene/scene/testcutscene.h" #include "rpg/cutscene/scene/testcutscene.hpp"
#include "rpg/rpgtextbox.h" #include "rpg/rpgtextbox.hpp"
void npcInit(entity_t *entity) { void npcInit(entity_t *entity) {
assertNotNull(entity, "Entity pointer cannot be NULL"); assertNotNull(entity, "Entity pointer cannot be NULL");

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "dusk.h" #include "dusk.hpp"
typedef struct entity_s entity_t; typedef struct entity_s entity_t;

View File

@@ -5,11 +5,11 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "entity.h" #include "entity.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
#include "rpg/rpgcamera.h" #include "rpg/rpgcamera.hpp"
#include "util/memory.h" #include "util/memory.hpp"
#include "time/time.h" #include "time/time.hpp"
void playerInit(entity_t *entity) { void playerInit(entity_t *entity) {
assertNotNull(entity, "Entity pointer cannot be NULL"); assertNotNull(entity, "Entity pointer cannot be NULL");

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "input/input.h" #include "input/input.hpp"
typedef struct entity_s entity_t; typedef struct entity_s entity_t;
@@ -24,8 +24,7 @@ static const playerinputdirmap_t PLAYER_INPUT_DIR_MAP[] = {
{ INPUT_ACTION_DOWN, ENTITY_DIR_SOUTH }, { INPUT_ACTION_DOWN, ENTITY_DIR_SOUTH },
{ INPUT_ACTION_LEFT, ENTITY_DIR_WEST }, { INPUT_ACTION_LEFT, ENTITY_DIR_WEST },
{ INPUT_ACTION_RIGHT, ENTITY_DIR_EAST }, { INPUT_ACTION_RIGHT, ENTITY_DIR_EAST },
{ .action = 0xFF, .direction = 0xFF }
{ 0xFF, 0xFF }
}; };
/** /**

View File

@@ -5,15 +5,15 @@
* https://opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
#include "rpg.h" #include "rpg.hpp"
#include "entity/entity.h" #include "entity/entity.hpp"
#include "rpg/world/map.h" #include "rpg/world/map.hpp"
#include "rpg/cutscene/cutscenesystem.h" #include "rpg/cutscene/cutscenesystem.hpp"
#include "time/time.h" #include "time/time.hpp"
#include "rpgcamera.h" #include "rpgcamera.hpp"
#include "rpgtextbox.h" #include "rpgtextbox.hpp"
#include "util/memory.h" #include "util/memory.hpp"
#include "assert/assert.h" #include "assert/assert.hpp"
errorret_t rpgInit(void) { errorret_t rpgInit(void) {
memoryZero(ENTITIES, sizeof(ENTITIES)); memoryZero(ENTITIES, sizeof(ENTITIES));

View File

@@ -6,7 +6,7 @@
*/ */
#pragma once #pragma once
#include "error/error.h" #include "error/error.hpp"
typedef struct { typedef struct {
int32_t nothing; int32_t nothing;

Some files were not shown because too many files have changed in this diff Show More