From bdc58f5b48d254a5a783708b1d0bf3c6e253fd71 Mon Sep 17 00:00:00 2001 From: rattatwinko Date: Tue, 7 Apr 2026 17:20:42 +0200 Subject: [PATCH] nice refactors, now way cleaner to work with! --- .vscode/settings.json | 9 +++++ Makefile | 33 +++++++++++++++---- Dayton Paper.pdf => doc/Dayton Paper.pdf | Bin image.h => include/encoder/image.h | 0 martin.h => include/encoder/modes/martin.h | 2 +- robot36.h => include/encoder/modes/robot36.h | 2 +- scottie.h => include/encoder/modes/scottie.h | 2 +- sstv.h => include/encoder/sstv.h | 2 +- wav.h => include/sound/wav.h | 0 image.c => src/encoder/image.c | 4 +-- martin.c => src/encoder/modes/martin.c | 9 ++--- robot36.c => src/encoder/modes/robot36.c | 4 +-- scottie.c => src/encoder/modes/scottie.c | 9 ++--- sstv.c => src/encoder/sstv.c | 8 ++--- main.c => src/main.c | 6 ++-- wav.c => src/sound/wav.c | 2 +- stb_image.h => third_party/stb_image.h | 0 17 files changed, 61 insertions(+), 31 deletions(-) create mode 100644 .vscode/settings.json rename Dayton Paper.pdf => doc/Dayton Paper.pdf (100%) rename image.h => include/encoder/image.h (100%) rename martin.h => include/encoder/modes/martin.h (95%) rename robot36.h => include/encoder/modes/robot36.h (89%) rename scottie.h => include/encoder/modes/scottie.h (95%) rename sstv.h => include/encoder/sstv.h (92%) rename wav.h => include/sound/wav.h (100%) rename image.c => src/encoder/image.c (92%) rename martin.c => src/encoder/modes/martin.c (92%) rename robot36.c => src/encoder/modes/robot36.c (96%) rename scottie.c => src/encoder/modes/scottie.c (94%) rename sstv.c => src/encoder/sstv.c (94%) rename main.c => src/main.c (95%) rename wav.c => src/sound/wav.c (98%) rename stb_image.h => third_party/stb_image.h (100%) diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..48a67ac --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "makefile.launchConfigurations": [ + { + "cwd": "/home/sebastian/Documents/e36", + "binaryPath": "/home/sebastian/Documents/e36/e36", + "binaryArgs": [] + } + ] +} \ No newline at end of file diff --git a/Makefile b/Makefile index f0f271e..b0e71af 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,35 @@ +# Makefile CC = gcc -CFLAGS = -Wall -O2 +CFLAGS = -Wall -O2 -Iinclude -Ithird_party LDFLAGS = -lm +SRCDIR = src +BUILDDIR = build +TARGET = e36 -TARGET = e36 -SRCS = main.c sstv.c robot36.c image.c wav.c martin.c scottie.c -OBJS = $(SRCS:.c=.o) +SRCS = \ + $(SRCDIR)/main.c \ + $(SRCDIR)/encoder/image.c \ + $(SRCDIR)/encoder/sstv.c \ + $(SRCDIR)/encoder/modes/martin.c \ + $(SRCDIR)/encoder/modes/robot36.c \ + $(SRCDIR)/encoder/modes/scottie.c \ + $(SRCDIR)/sound/wav.c + +OBJS = $(patsubst $(SRCDIR)/%.c,$(BUILDDIR)/%.o,$(SRCS)) + +.PHONY: all clean dirs + +all: dirs $(TARGET) + +dirs: + mkdir -p $(BUILDDIR)/encoder/modes $(BUILDDIR)/sound $(TARGET): $(OBJS) - $(CC) $(OBJS) -o $(TARGET) $(LDFLAGS) + $(CC) $(OBJS) -o $@ $(LDFLAGS) -%.o: %.c +$(BUILDDIR)/%.o: $(SRCDIR)/%.c $(CC) $(CFLAGS) -c $< -o $@ clean: - rm -f $(TARGET) $(OBJS) + rm -rf $(BUILDDIR) $(TARGET) + diff --git a/Dayton Paper.pdf b/doc/Dayton Paper.pdf similarity index 100% rename from Dayton Paper.pdf rename to doc/Dayton Paper.pdf diff --git a/image.h b/include/encoder/image.h similarity index 100% rename from image.h rename to include/encoder/image.h diff --git a/martin.h b/include/encoder/modes/martin.h similarity index 95% rename from martin.h rename to include/encoder/modes/martin.h index 42ac96b..1f6f4ba 100644 --- a/martin.h +++ b/include/encoder/modes/martin.h @@ -1,7 +1,7 @@ #ifndef MARTIN_H #define MARTIN_H -#include "wav.h" +#include "sound/wav.h" #include typedef struct { diff --git a/robot36.h b/include/encoder/modes/robot36.h similarity index 89% rename from robot36.h rename to include/encoder/modes/robot36.h index e0d2f78..bd7f370 100644 --- a/robot36.h +++ b/include/encoder/modes/robot36.h @@ -1,7 +1,7 @@ #ifndef ROBOT36_H #define ROBOT36_H -#include "wav.h" +#include "sound/wav.h" #include #define ROBOT36_WIDTH 320 diff --git a/scottie.h b/include/encoder/modes/scottie.h similarity index 95% rename from scottie.h rename to include/encoder/modes/scottie.h index 16e6661..0cb953a 100644 --- a/scottie.h +++ b/include/encoder/modes/scottie.h @@ -1,7 +1,7 @@ #ifndef SCOTTIE_H #define SCOTTIE_H -#include "wav.h" +#include "sound/wav.h" #include typedef struct { diff --git a/sstv.h b/include/encoder/sstv.h similarity index 92% rename from sstv.h rename to include/encoder/sstv.h index 6cdfab7..1187f4c 100644 --- a/sstv.h +++ b/include/encoder/sstv.h @@ -1,7 +1,7 @@ #ifndef SSTV_H #define SSTV_H -#include "wav.h" +#include "sound/wav.h" #include void sstv_tone(wav_t *wav, double freq, double duration_ms); diff --git a/wav.h b/include/sound/wav.h similarity index 100% rename from wav.h rename to include/sound/wav.h diff --git a/image.c b/src/encoder/image.c similarity index 92% rename from image.c rename to src/encoder/image.c index ad5c3c4..3e2059b 100644 --- a/image.c +++ b/src/encoder/image.c @@ -1,6 +1,6 @@ #define STB_IMAGE_IMPLEMENTATION -#include "stb_image.h" -#include "image.h" +#include "../../third_party/stb_image.h" +#include "../../include/encoder/image.h" #include int image_load(image_t *img, const char *filename) { diff --git a/martin.c b/src/encoder/modes/martin.c similarity index 92% rename from martin.c rename to src/encoder/modes/martin.c index c87cfdb..4eb2363 100644 --- a/martin.c +++ b/src/encoder/modes/martin.c @@ -1,7 +1,8 @@ -#include "martin.h" -#include "image.h" -#include "sstv.h" -#include "wav.h" +// martin.c - includes look shit, but this has to be like this +#include "encoder/modes/martin.h" +#include "encoder/image.h" +#include "encoder/sstv.h" +#include "sound/wav.h" #include const martin_mode_t MARTIN_M1 = { diff --git a/robot36.c b/src/encoder/modes/robot36.c similarity index 96% rename from robot36.c rename to src/encoder/modes/robot36.c index 1358002..3b62207 100644 --- a/robot36.c +++ b/src/encoder/modes/robot36.c @@ -1,5 +1,5 @@ -#include "robot36.h" -#include "sstv.h" +#include "encoder/modes/robot36.h" +#include "encoder/sstv.h" #include // From Dayton Paper Appendix B - ITU BT.601 diff --git a/scottie.c b/src/encoder/modes/scottie.c similarity index 94% rename from scottie.c rename to src/encoder/modes/scottie.c index 4f01cb2..38b3dd3 100644 --- a/scottie.c +++ b/src/encoder/modes/scottie.c @@ -1,7 +1,8 @@ -#include "scottie.h" -#include "image.h" -#include "sstv.h" -#include "wav.h" +#include "encoder/modes/scottie.h" +#include "encoder/image.h" +#include "encoder/sstv.h" +#include "sound/wav.h" + #include const scottie_mode_t SCOTTIE_S1 = { diff --git a/sstv.c b/src/encoder/sstv.c similarity index 94% rename from sstv.c rename to src/encoder/sstv.c index 504b188..09e07b6 100644 --- a/sstv.c +++ b/src/encoder/sstv.c @@ -1,7 +1,7 @@ -#include "sstv.h" -#include "image.h" -#include "robot36.h" -#include "wav.h" +#include "sound/wav.h" +#include "encoder/sstv.h" +#include "encoder/image.h" +#include "encoder/modes/robot36.h" #include #include diff --git a/main.c b/src/main.c similarity index 95% rename from main.c rename to src/main.c index 9779d33..51a5dc6 100644 --- a/main.c +++ b/src/main.c @@ -1,6 +1,6 @@ -#include "sstv.h" -#include "martin.h" -#include "scottie.h" +#include "encoder/modes/martin.h" +#include "encoder/modes/scottie.h" +#include "encoder/sstv.h" #include #include #include diff --git a/wav.c b/src/sound/wav.c similarity index 98% rename from wav.c rename to src/sound/wav.c index e65fe78..462d8dc 100644 --- a/wav.c +++ b/src/sound/wav.c @@ -1,4 +1,4 @@ -#include "wav.h" +#include "sound/wav.h" #include #include diff --git a/stb_image.h b/third_party/stb_image.h similarity index 100% rename from stb_image.h rename to third_party/stb_image.h