commit 226ea40887fd922574b56ca27730cab46f63af8a Author: KikooDX Date: Fri Apr 16 11:08:47 2021 +0200 gint project template diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..f39c7af --- /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: 72 +AlignConsecutiveMacros: true +AlwaysBreakAfterReturnType: TopLevelDefinitions diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..98a1d5c --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +# Build files +/build-fx +/build-cg +/*.g1a +/*.g3a + +# Python bytecode + __pycache__/ + +# Common IDE files +*.sublime-project +*.sublime-workspace +.vscode +*.swp + +# Krita backup files +*.png~ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..48c742f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,85 @@ +# 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) +# replace this with your project's name +project(ProjectName) + +include(GenerateG1A) +include(GenerateG3A) +include(Fxconv) +find_package(Gint 2.1 REQUIRED) + +# include directories, put your .h files in those folders +include_directories(include) + +# source files +set(SOURCES + src/main.c + src/sample.c + # ... +) +# shared assets +set(ASSETS + # ... +) +# fx-9860G-only assets (monochrome) +set(ASSETS_fx + assets-fx/example.png + # ... +) +# fx-CG-50-only assets (polychrome) +set(ASSETS_cg + assets-cg/example.png + # ... +) + +# Compile flags +set(FLAGS + # C standard, other values: c89, c99 + -std=c11 + + # general warnings + -Wall -Wextra -pedantic + + # enable this flag to stop compilation on warnings + #-Werror + + # specific warnings + # variable shadowing + -Wshadow + # switch/case safety + -Wswitch-default -Wswitch-enum + # unreachable code, bad 99% of the time + -Wunreachable-code + # prototypes warnings + -Wstrict-prototypes -Wmissing-prototypes + # function declaration + -Werror-implicit-function-declaration + + # optimisation level + # -Os: small binary + # -O2: good speed/size tradeoff + # -O3: gotta go fast + -Os +) + +fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} WITH_METADATA) + +add_executable(${PROJECT_NAME} ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}}) +target_compile_options(${PROJECT_NAME} PRIVATE ${FLAGS}) +target_link_libraries(${PROJECT_NAME} Gint::Gint) + +if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G) + generate_g1a( + TARGET ${PROJECT_NAME} + OUTPUT "${PROJECT_NAME}.g1a" + NAME "${PROJECT_NAME}" + ICON assets-fx/icon.png) +elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50) + generate_g3a( + TARGET ${PROJECT_NAME} + OUTPUT "${PROJECT_NAME}.g3a" + NAME "${PROJECT_NAME}" + ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png) +endif() 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..7b1909c --- /dev/null +++ b/README @@ -0,0 +1,46 @@ +KikooDX's gint project template +=============================== +This is a base project for gint softwares. + +Before anything +--------------- +Open and read CMakeLists.txt. + +Building your project +--------------------- +For monochrome calculator target: +$ fxsdk build-fx + +For color calculator target: +$ fxsdk build-cg + +Making changes +-------------- +After creating new .c files, add those to the SRC list in CMakeLists and +rebuild. Same process for graphical assets in the corresponding ASSETS +in the corresponding ASSETS* list, but you will also need to edit +assets*/fxconv-metada. + +Before commiting +---------------- +Run this command at the base of the git tree: +$ clang-format -i src/**.c include/**.h +It will beautify the source of your project according to the +configuration in the .clang-format file. + +Nice tricks +----------- +Search for a function declaration. +$ git grep '$sample' + +See changes since last commit. +$ git diff + +Require entr, recompile whenever a source file change (poor man LSP). +Ctrl-C to end. +$ find src/ include/ -type f | entr -r fxsdk build-cg + +License +------- +Copyright (C) 2021 KikooDX +This template is under the 0BSD license. See LICENSE for informations. diff --git a/assets-cg/example.png b/assets-cg/example.png new file mode 100644 index 0000000..8826800 Binary files /dev/null and b/assets-cg/example.png differ diff --git a/assets-cg/fxconv-metadata.txt b/assets-cg/fxconv-metadata.txt new file mode 100644 index 0000000..d435d5f --- /dev/null +++ b/assets-cg/fxconv-metadata.txt @@ -0,0 +1,3 @@ +example.png: + type: bopti-image + name: img_example diff --git a/assets-cg/icon-sel.png b/assets-cg/icon-sel.png new file mode 100644 index 0000000..7137b50 Binary files /dev/null and b/assets-cg/icon-sel.png differ diff --git a/assets-cg/icon-uns.png b/assets-cg/icon-uns.png new file mode 100644 index 0000000..3c99f62 Binary files /dev/null and b/assets-cg/icon-uns.png differ diff --git a/assets-fx/example.png b/assets-fx/example.png new file mode 100644 index 0000000..b26ba9a Binary files /dev/null and b/assets-fx/example.png differ diff --git a/assets-fx/fxconv-metadata.txt b/assets-fx/fxconv-metadata.txt new file mode 100644 index 0000000..d435d5f --- /dev/null +++ b/assets-fx/fxconv-metadata.txt @@ -0,0 +1,3 @@ +example.png: + type: bopti-image + name: img_example diff --git a/assets-fx/icon.png b/assets-fx/icon.png new file mode 100644 index 0000000..c92f12a Binary files /dev/null and b/assets-fx/icon.png differ diff --git a/include/sample.h b/include/sample.h new file mode 100644 index 0000000..ec7ac38 --- /dev/null +++ b/include/sample.h @@ -0,0 +1,4 @@ +#pragma once + +/* return 42 */ +int sample(void); diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..09da437 --- /dev/null +++ b/src/main.c @@ -0,0 +1,16 @@ +#include "sample.h" +#include +#include + +int +main(void) +{ + dclear(C_WHITE); + dtext(1, 1, C_BLACK, "Sample add-in."); + dprint(1, 16, C_BLACK, "Return value of sample(): %d.", + sample()); + dupdate(); + + getkey(); + return 1; +} diff --git a/src/sample.c b/src/sample.c new file mode 100644 index 0000000..eadfd3b --- /dev/null +++ b/src/sample.c @@ -0,0 +1,7 @@ +#include "sample.h" + +int +sample(void) +{ + return 42; +}