feck IO functions
This commit is contained in:
parent
c947256c37
commit
90eee5838e
|
@ -1,6 +1,6 @@
|
|||
[submodule "fe"]
|
||||
path = fe
|
||||
url = https://github.com/rxi/fe
|
||||
url = https://gitea.planet-casio.com/KikooDX/fe
|
||||
[submodule "raygint"]
|
||||
path = raygint
|
||||
url = https://gitea.planet-casio.com/KikooDX/raygint
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# toolchain file and module path of the fxSDK
|
||||
|
||||
cmake_minimum_required(VERSION 3.18)
|
||||
project(CRYSTAL C)
|
||||
project(FECK C)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
|
||||
|
@ -36,7 +36,7 @@ if ("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
|
|||
|
||||
generate_g3a(TARGET target
|
||||
OUTPUT "${PROJECT_NAME}.g3a"
|
||||
NAME ""
|
||||
NAME "${PROJECT_NAME}"
|
||||
ICONS res/icon-uns.png res/icon-sel.png
|
||||
)
|
||||
else()
|
||||
|
|
8
Makefile
8
Makefile
|
@ -1,7 +1,7 @@
|
|||
all: format
|
||||
all: format out/file.h
|
||||
fxsdk build-cg
|
||||
|
||||
ray: clean format
|
||||
ray: clean format out/file.h
|
||||
mkdir -p build
|
||||
cmake -B build .
|
||||
make -C build
|
||||
|
@ -9,6 +9,10 @@ ray: clean format
|
|||
run: ray
|
||||
build/target
|
||||
|
||||
out/file.h:
|
||||
mkdir -p out
|
||||
cembed -z test.fe > out/file.h
|
||||
|
||||
format:
|
||||
clang-format -style=file -i src/**.c inc/**.h || true
|
||||
|
||||
|
|
2
fe
2
fe
|
@ -1 +1 @@
|
|||
Subproject commit ed4cda96bd582cbb08520964ba627efb40f3dd91
|
||||
Subproject commit 0c0d60706cb78fa953cbe26db76b32d0b4ef46d2
|
31
src/main.c
31
src/main.c
|
@ -1,12 +1,15 @@
|
|||
#include "fe.h"
|
||||
#include "file.h"
|
||||
#include "raygint/display.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define UNUSED(c) (void)(c)
|
||||
|
||||
static fe_Object *f_dblock(fe_Context *ctx, fe_Object *arg);
|
||||
static fe_Object *f_dcolor(fe_Context *ctx, fe_Object *arg);
|
||||
static fe_Object *f_dclear(fe_Context *ctx, fe_Object *arg);
|
||||
static fe_Object *f_drect(fe_Context *ctx, fe_Object *arg);
|
||||
static char read_custom(fe_Context *ctx, void *udata);
|
||||
|
||||
static int r = 0;
|
||||
static int g = 0;
|
||||
|
@ -18,19 +21,20 @@ 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);
|
||||
rDisplayInit();
|
||||
SetTargetFPS(30);
|
||||
|
||||
fe_set(ctx, fe_symbol(ctx, "dblock"), fe_cfunc(ctx, f_dblock));
|
||||
fe_set(ctx, fe_symbol(ctx, "dcolor"), fe_cfunc(ctx, f_dcolor));
|
||||
fe_set(ctx, fe_symbol(ctx, "dclear"), fe_cfunc(ctx, f_dclear));
|
||||
fe_set(ctx, fe_symbol(ctx, "drect"), fe_cfunc(ctx, f_drect));
|
||||
|
||||
rDisplayInit();
|
||||
#ifdef RAYLIB
|
||||
SetTargetFPS(30);
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
fe_Object *obj = fe_readfp(ctx, fp);
|
||||
fe_Object *obj = fe_read(ctx, read_custom, test_fe);
|
||||
|
||||
/* break if there's nothing left to read */
|
||||
if (!obj)
|
||||
|
@ -45,8 +49,6 @@ main(void)
|
|||
}
|
||||
|
||||
rDisplayDeinit();
|
||||
fclose(fp);
|
||||
#endif
|
||||
fe_close(ctx);
|
||||
free(data);
|
||||
return 0;
|
||||
|
@ -74,6 +76,8 @@ f_dcolor(fe_Context *ctx, fe_Object *arg)
|
|||
static fe_Object *
|
||||
f_dclear(fe_Context *ctx, fe_Object *arg)
|
||||
{
|
||||
UNUSED(ctx);
|
||||
UNUSED(arg);
|
||||
dclear(C_RGB(r, g, b));
|
||||
return NULL;
|
||||
}
|
||||
|
@ -88,3 +92,14 @@ f_drect(fe_Context *ctx, fe_Object *arg)
|
|||
drect(x, y, x + w - 1, y + h - 1, C_RGB(r, g, b));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char
|
||||
read_custom(fe_Context *ctx, void *udata)
|
||||
{
|
||||
static int cursor = 0;
|
||||
const char *data = (char *)udata;
|
||||
UNUSED(ctx);
|
||||
if (data[cursor])
|
||||
return data[cursor++];
|
||||
return data[cursor];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue