KBLE C integration proof of concept
This commit is contained in:
commit
a2d2a32147
|
@ -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
|
|
@ -0,0 +1,12 @@
|
|||
# Build files
|
||||
/build-cg
|
||||
/*.g3a
|
||||
|
||||
# Common IDE files
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
.vscode
|
||||
*.swp
|
||||
|
||||
# KBLE backup files
|
||||
backup_*.kble
|
|
@ -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)
|
|
@ -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.
|
|
@ -0,0 +1,8 @@
|
|||
KBLE x gint proof of concept
|
||||
============================
|
||||
The code is self explanatory.
|
||||
|
||||
License
|
||||
-------
|
||||
Copyright (C) 2021 KikooDX <kikoodx@paranoici.org>
|
||||
This template is under the 0BSD license. See LICENSE for informations.
|
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
*.kble:
|
||||
type: binary
|
||||
name_regex: (.*)\.kble kble_\1
|
|
@ -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__));
|
|
@ -0,0 +1,35 @@
|
|||
#include "level.h"
|
||||
#include <gint/display.h>
|
||||
#include <gint/keyboard.h>
|
||||
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue