commit 3a2609f8e4f7cc14995941cae0166e4ab8cb67b0 Author: KikooDX Date: Thu Nov 18 00:11:52 2021 +0100 helloworld diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..57fd90a --- /dev/null +++ b/.clang-format @@ -0,0 +1,9 @@ +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..8ea1418 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +out/ +build/ +build-cg/ +build-fx/ +*.g3a +*.g1a +*.png~ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ebd6936 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "fe"] + path = fe + url = https://github.com/rxi/fe +[submodule "raygint"] + path = raygint + url = https://gitea.planet-casio.com/KikooDX/raygint diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..8e78e16 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,46 @@ +# Configure with [fxsdk build-cg], which provide the +# toolchain file and module path of the fxSDK + +cmake_minimum_required(VERSION 3.18) +project(CRYSTAL C) + +set(CMAKE_C_STANDARD 99) + +include_directories(inc out raygint/include fe/src) + +set(SOURCES + src/main.c + raygint/src/display.c + raygint/src/keyboard.c + fe/src/fe.c +) + +set(ASSETS +) + +set(FLAGS + -Wall -Wextra -Wshadow -O3 +) + +if ("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50) + find_package(Gint 2.6.0 REQUIRED) + + include(GenerateG3A) + include(Fxconv) + fxconv_declare_assets(${ASSETS} WITH_METADATA) + + add_executable(target ${SOURCES} ${ASSETS}) + target_compile_options(target PRIVATE ${FLAGS} -DGINT) + target_link_libraries(target Gint::Gint) + target_link_options(target PRIVATE -Wl,-Map=map) + + generate_g3a(TARGET target + OUTPUT "${PROJECT_NAME}.g3a" + NAME "" + ICONS res/icon-uns.png res/icon-sel.png + ) +else() + add_executable(target ${SOURCES}) + target_compile_options(target PRIVATE ${FLAGS} -DRAYLIB -g) + target_link_libraries(target raylib) +endif() diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..eaa8930 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +all: format + fxsdk build-cg + +ray: clean format + mkdir -p build + cmake -B build . + make -C build + +run: ray + build/target + +format: + clang-format -style=file -i src/**.c inc/**.h || true + +clean: + rm -Rf out/ + rm -Rf build/ + rm -Rf build-cg/ + rm -f *.g3a + +.PHONY: format ray run clean diff --git a/fe b/fe new file mode 160000 index 0000000..ed4cda9 --- /dev/null +++ b/fe @@ -0,0 +1 @@ +Subproject commit ed4cda96bd582cbb08520964ba627efb40f3dd91 diff --git a/raygint b/raygint new file mode 160000 index 0000000..2403783 --- /dev/null +++ b/raygint @@ -0,0 +1 @@ +Subproject commit 2403783b3a7574828815aa9be9b541342d4684fa diff --git a/res/icon-sel.png b/res/icon-sel.png new file mode 100644 index 0000000..7137b50 Binary files /dev/null and b/res/icon-sel.png differ diff --git a/res/icon-uns.png b/res/icon-uns.png new file mode 100644 index 0000000..3c99f62 Binary files /dev/null and b/res/icon-uns.png differ diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..21258ae --- /dev/null +++ b/src/main.c @@ -0,0 +1,34 @@ +#include "fe.h" +#include + +int +main(void) +{ + const int size = 0xffffff; + void *data = malloc(size); + fe_Context *ctx = fe_open(data, size); +#ifdef RAYLIB + FILE *fp = fopen("test.fe", "rb"); + int gc = fe_savegc(ctx); + + for (;;) { + fe_Object *obj = fe_readfp(ctx, fp); + + /* break if there's nothing left to read */ + if (!obj) + break; + + /* evaluate read object */ + fe_eval(ctx, obj); + + /* restore GC stack which would now contain both the + * read object and result from evaluation */ + fe_restoregc(ctx, gc); + } + + fclose(fp); +#endif + fe_close(ctx); + free(data); + return 0; +} diff --git a/test.fe b/test.fe new file mode 100644 index 0000000..1c0498a --- /dev/null +++ b/test.fe @@ -0,0 +1,2 @@ +(= x 2) (= y 3) +(print "hello world" (+ y (* x x)))