commit a2d2a321475b7ad377ce40b52d3fc1f5921072ac Author: KikooDX Date: Fri Apr 16 11:08:47 2021 +0200 KBLE C integration proof of concept diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..41565cf --- /dev/null +++ b/.clang-format @@ -0,0 +1,10 @@ +# https://clang.llvm.org/docs/ClangFormat.html +BasedOnStyle: LLVM +IndentWidth: 8 +UseTab: AlignWithSpaces +BreakBeforeBraces: Linux +AllowShortIfStatementsOnASingleLine: false +IndentCaseLabels: false +ColumnLimit: 80 +AlignConsecutiveMacros: true +AlwaysBreakAfterReturnType: TopLevelDefinitions diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..53803ae --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +# Build files +/build-cg +/*.g3a + +# Common IDE files +*.sublime-project +*.sublime-workspace +.vscode +*.swp + +# KBLE backup files +backup_*.kble diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..cce2f6f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,43 @@ +# Configure with [fxsdk build-fx] or [fxsdk build-cg], which provide the +# toolchain file and module path of the fxSDK + +cmake_minimum_required(VERSION 3.18) +project(KbleGint C) + +include(GenerateG1A) +include(GenerateG3A) +include(Fxconv) +find_package(Gint 2.4 REQUIRED) + +include_directories(include) + +set(SOURCES + src/main.c +) + +set(ASSETS + assets/levels/demo.kble +) + +set(FLAGS + -std=c11 + -Wall -Wextra -pedantic + -Wshadow + -Wswitch-default -Wswitch-enum + -Wunreachable-code + -Wstrict-prototypes -Wmissing-prototypes + -Werror-implicit-function-declaration + -Os +) + +fxconv_declare_assets(${ASSETS} WITH_METADATA) + +add_executable(Main ${SOURCES} ${ASSETS}) +target_compile_options(Main PRIVATE ${FLAGS}) +target_link_libraries(Main Gint::Gint) + +generate_g3a( + TARGET Main + OUTPUT "${PROJECT_NAME}.g3a" + NAME "${PROJECT_NAME}" + ICONS assets/icon-uns.png assets/icon-sel.png) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c823082 --- /dev/null +++ b/LICENSE @@ -0,0 +1,12 @@ +Copyright (C) 2021 KikooDX + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/README b/README new file mode 100644 index 0000000..f85d442 --- /dev/null +++ b/README @@ -0,0 +1,8 @@ +KBLE x gint proof of concept +============================ +The code is self explanatory. + +License +------- +Copyright (C) 2021 KikooDX +This template is under the 0BSD license. See LICENSE for informations. diff --git a/assets/icon-sel.png b/assets/icon-sel.png new file mode 100644 index 0000000..7137b50 Binary files /dev/null and b/assets/icon-sel.png differ diff --git a/assets/icon-uns.png b/assets/icon-uns.png new file mode 100644 index 0000000..3c99f62 Binary files /dev/null and b/assets/icon-uns.png differ diff --git a/assets/levels/demo.kble b/assets/levels/demo.kble new file mode 100644 index 0000000..e2d0a78 Binary files /dev/null and b/assets/levels/demo.kble differ diff --git a/assets/levels/fxconv-metadata.txt b/assets/levels/fxconv-metadata.txt new file mode 100644 index 0000000..1e3fa88 --- /dev/null +++ b/assets/levels/fxconv-metadata.txt @@ -0,0 +1,3 @@ +*.kble: + type: binary + name_regex: (.*)\.kble kble_\1 diff --git a/include/level.h b/include/level.h new file mode 100644 index 0000000..bf504fd --- /dev/null +++ b/include/level.h @@ -0,0 +1,9 @@ +#pragma once + +struct KBLE_Level { + unsigned char format; + unsigned char chunk_size; + unsigned short width; + unsigned short height; + unsigned char data[]; +} __attribute__((__packed__)); diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..02fc2a1 --- /dev/null +++ b/src/main.c @@ -0,0 +1,35 @@ +#include "level.h" +#include +#include + +extern struct KBLE_Level kble_demo; + +int +main(void) +{ + int i; + int x; + int y; + + dclear(C_WHITE); + dprint(1, 0, C_BLACK, "Format version: %u", kble_demo.format); + dprint(1, 16, C_BLACK, "Chunk size: %u", kble_demo.chunk_size); + dprint(1, 32, C_BLACK, "Width: %u", kble_demo.width); + dprint(1, 48, C_BLACK, "Height: %u", kble_demo.height); + dupdate(); + getkey(); + + dclear(C_WHITE); + i = 0; + for (y = 0; y < kble_demo.height; y += 1) { + for (x = 0; x < kble_demo.width; x += 1) { + dprint_opt(6 + x * 16, 8 + y * 16, C_BLACK, C_NONE, + DTEXT_CENTER, DTEXT_MIDDLE, "%u", + kble_demo.data[i++]); + } + } + dupdate(); + getkey(); + + return 1; +}