aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornathansmith <nathansmith@posteo.com>2025-04-26 14:49:59 +0000
committernathansmith <nathansmith@posteo.com>2025-04-26 14:49:59 +0000
commitcbc1dfa2fcafb283cea5d87092db1a9b786c962c (patch)
tree969a12b9d37f4bda2aed8a984fe2ac96d0c55d6f /src
parentc2cf22bbfb26f0f778ded8be82ddb16816b8c8f0 (diff)
downloadsldj-cbc1dfa2fcafb283cea5d87092db1a9b786c962c.tar.gz
sldj-cbc1dfa2fcafb283cea5d87092db1a9b786c962c.tar.bz2
sldj-cbc1dfa2fcafb283cea5d87092db1a9b786c962c.zip
Downgraded to makefile lol
Diffstat (limited to 'src')
-rw-r--r--src/Makefile18
-rw-r--r--src/ffmpeg.c2
-rw-r--r--src/ffmpeg.h10
-rw-r--r--src/libsldj/Makefile11
-rw-r--r--src/libsldj/util.c2
-rw-r--r--src/libsldj/util.h68
-rw-r--r--src/scripting.c4
7 files changed, 112 insertions, 3 deletions
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..7b5f86e
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,18 @@
+CFLAGS = -Isrc -I../include
+LDFLAGS = -lm -lraylib -ltcc
+
+TARGET = sldj
+SOURCES = $(shell find -name "*.c")
+OBJECTS = $(SOURCES:.c=.o)
+LIBSLDJ = libsldj/libsldj.so
+
+%.o: %.c
+ $(CC) -c $(CFLAGS) -o $@ $<
+$(TARGET): $(OBJECTS) $(LIBSLDJ)
+ $(CC) $(CFLAGS) -o $(TARGET) $(OBJECTS) $(wildcard "libsldj/*.c") $(LDFLAGS)
+$(LIBSLDJ): $(wildcard libsldj/*.c libsldj/*.h)
+ @$(MAKE) -C libsldj
+clean:
+ rm *.o
+ rm $(TARGET)
+ @$(MAKE) -C libsldj clean
diff --git a/src/ffmpeg.c b/src/ffmpeg.c
new file mode 100644
index 0000000..72dfef8
--- /dev/null
+++ b/src/ffmpeg.c
@@ -0,0 +1,2 @@
+#include "ffmpeg.h"
+
diff --git a/src/ffmpeg.h b/src/ffmpeg.h
new file mode 100644
index 0000000..56ef6d9
--- /dev/null
+++ b/src/ffmpeg.h
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "sldjConfig.h"
+
+#ifndef FFMPEG_H
+#define FFMPEG_H
+
+#endif
+
diff --git a/src/libsldj/Makefile b/src/libsldj/Makefile
new file mode 100644
index 0000000..fc15314
--- /dev/null
+++ b/src/libsldj/Makefile
@@ -0,0 +1,11 @@
+TARGET = libsldj.so
+SOURCES = $(shell find -name "*.c")
+OBJECTS = $(SOURCES:.c=.o)
+
+%.o: %.c
+ $(CC) -c -fPIC -o $@ $<
+$(TARGET): $(OBJECTS)
+ $(CC) -shared -o $(TARGET) $(OBJECTS)
+clean:
+ rm *.o
+ rm $(TARGET)
diff --git a/src/libsldj/util.c b/src/libsldj/util.c
index 61def55..b7e445c 100644
--- a/src/libsldj/util.c
+++ b/src/libsldj/util.c
@@ -1,2 +1,2 @@
-#include "libsldj/util.h"
+#include "util.h"
diff --git a/src/libsldj/util.h b/src/libsldj/util.h
new file mode 100644
index 0000000..566ba8d
--- /dev/null
+++ b/src/libsldj/util.h
@@ -0,0 +1,68 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <math.h>
+
+#ifndef UTIL_H
+#define UTIL_H
+
+#define SET_BIT(b, n) (b | (0x1 << n))
+#define CLEAR_BIT(b, n) (b & ~(0x1 << n))
+#define IS_BIT_SET(b, n) ((b >> n) & 0x1)
+#define TOGGLE_BIT(b, n) (b ^ (0x1 << n))
+#define HAS_FLAG(v, f) ((v & f) == f)
+
+// Fast math macros.
+#define SLDJ_SQRT(number) sldjSqrtTable[(uint16_t)(number)]
+
+#define SLDJ_SIN(number) sldjSinTable[(uint16_t)(number)]
+#define SLDJ_COS(number) sldjCosTable[(uint16_t)(number)]
+#define SLDJ_TAN(number) sldjTanTable[(uint16_t)(number)]
+
+#define SLDJ_HYPOT2(x, y) (SLDJ_SQRT(x * x + y * y))
+#define SLDJ_HYPOT3(x, y, z) (SLDJ_SQRT(x * x + y * y + z * z))
+
+#define SLDJ_RANDOM16(seed) (seed = (75 * seed + 74) % 65537)
+#define SLDJ_RANDOM32(seed) (seed = (1664525 * seed + 1013904223) % 4294967296)
+
+// Stuff stolen from raylib/raymath
+#ifndef RL_COLOR_TYPE
+#define RL_COLOR_TYPE
+typedef struct Color {
+ unsigned char r;
+ unsigned char g;
+ unsigned char b;
+ unsigned char a;
+} Color;
+#endif
+
+#ifndef PI
+ #define PI 3.14159265358979323846f
+#endif
+
+#ifndef DEG2RAD
+ #define DEG2RAD (PI/180.0f)
+#endif
+
+#ifndef RAD2DEG
+ #define RAD2DEG (180.0f/PI)
+#endif
+
+// Used for sending information to a scanner.
+typedef struct SldjContext {
+ uint16_t viewportWidth;
+ uint16_t viewportHeight;
+ uint8_t targetFps;
+ uint16_t xCount;
+ uint16_t yCount;
+} SldjContext;
+
+// Tables.
+extern float sldjSqrtTable[65536];
+
+extern float sldjSinTable[361];
+extern float sldjCosTable[361];
+extern float sldjTanTable[361];
+
+#endif
+
diff --git a/src/scripting.c b/src/scripting.c
index efd85b0..8dbdec5 100644
--- a/src/scripting.c
+++ b/src/scripting.c
@@ -75,8 +75,8 @@ void compileScript(SldjScripting* scripting, const char filePath[SLDJ_NAMEMAX])
tcc_set_error_func(scripting->state, stderr, handle_tcc_error);
tcc_set_output_type(scripting->state, TCC_OUTPUT_MEMORY);
- tcc_add_library_path(scripting->state, "./");
- tcc_add_library(scripting->state, "libsldj");
+ tcc_add_library_path(scripting->state, "./libsldj");
+ tcc_add_library(scripting->state, "sldj");
// Compile.
if (tcc_compile_string(scripting->state, scripting->fileBuf) < 0)