From 5e4443a1f92acb200f4f461693e62a7c13a38407 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 24 Aug 2025 18:05:28 +1000 Subject: [PATCH] Amiga: WIP vbcc support --- Makefile | 6 +++--- misc/amiga/Makefile | 42 +++++++++++++++++++++++++++++++++++++++++ misc/amiga/Makefile_68k | 34 +++++++++++++++++++-------------- misc/atari_st/Makefile | 10 ++++++++-- src/Core.h | 10 ++++++++++ src/ExtMath.c | 2 +- src/Platform_Amiga.c | 14 ++++++++++++-- src/Vorbis.c | 2 +- 8 files changed, 97 insertions(+), 23 deletions(-) create mode 100644 misc/amiga/Makefile diff --git a/Makefile b/Makefile index a94f5dfe1..49754220a 100644 --- a/Makefile +++ b/Makefile @@ -300,10 +300,10 @@ macclassic_68k: $(MAKE) -f misc/macclassic/Makefile_68k macclassic_ppc: $(MAKE) -f misc/macclassic/Makefile_ppc -amiga_68k: +amiga_gcc: $(MAKE) -f misc/amiga/Makefile_68k -amiga_ppc: - $(MAKE) -f misc/amiga/Makefile_ppc +amiga: + $(MAKE) -f misc/amiga/Makefile atari_st: $(MAKE) -f misc/atari_st/Makefile diff --git a/misc/amiga/Makefile b/misc/amiga/Makefile new file mode 100644 index 000000000..0d5ee083c --- /dev/null +++ b/misc/amiga/Makefile @@ -0,0 +1,42 @@ +TARGET := ClassiCube-amiga +BUILD_DIR := build/amiga +SOURCE_DIRS := src src/amiga + +S_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S)) +C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) +OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o))) + + +#--------------------------------------------------------------------------------- +# Code generation +#--------------------------------------------------------------------------------- +CC = vc +aos68k +CFLAGS = -rmcfg-amiga-softfloat -O1 -DPLAT_AMIGA + +AS = vasmm68k_mot +ASFLAGS = -Fvobj -m68000 -no-fpu + +LDFLAGS = $(CFLAGS) +LDLIBS = -lamiga -lmsoft + + +#--------------------------------------------------------------------------------- +# Main targets +#--------------------------------------------------------------------------------- +default: $(BUILD_DIR) $(TARGET) + +$(BUILD_DIR): + mkdir -p $(BUILD_DIR) + +$(TARGET): $(OBJS) + $(CC) $(LDFLAGS) -final -o $@ $^ $(LDLIBS) + + +#--------------------------------------------------------------------------------- +# object generation +#--------------------------------------------------------------------------------- +$(BUILD_DIR)/%.o : src/%.c + $(CC) $(CFLAGS) -c -o $@ $< + +$(BUILD_DIR)/%.o : src/amiga/%.c + $(CC) $(CFLAGS) -c -o $@ $< diff --git a/misc/amiga/Makefile_68k b/misc/amiga/Makefile_68k index 43276ca2a..498fff892 100644 --- a/misc/amiga/Makefile_68k +++ b/misc/amiga/Makefile_68k @@ -1,20 +1,23 @@ -AS=m68k-amigaos-as -CC=m68k-amigaos-gcc -CXX=m68k-amigaos-g++ +TARGET := ClassiCube-amiga +BUILD_DIR := build/amiga_68k +SOURCE_DIRS := src src/amiga -CFLAGS :=-O1 -fno-math-errno -DPLAT_AMIGA -DCC_BUILD_NOFPU -TARGET := ClassiCube-68k -BUILD_DIR := build-amiga-68k -SOURCE_DIR := src -LDFLAGS := +S_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S)) +C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) +OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o))) -C_SOURCES := $(wildcard $(SOURCE_DIR)/*.c) -C_ASSEMS := $(patsubst $(SOURCE_DIR)/%.c, $(BUILD_DIR)/%.S, $(C_SOURCES)) -C_OBJECTS := $(patsubst $(SOURCE_DIR)/%.c, $(BUILD_DIR)/%.o, $(C_SOURCES)) + +#--------------------------------------------------------------------------------- +# Code generation +#--------------------------------------------------------------------------------- +AS := m68k-amigaos-as +CC := m68k-amigaos-gcc +CXX := m68k-amigaos-g++ +CFLAGS := -O1 -fno-math-errno -DPLAT_AMIGA -DCC_BUILD_NOFPU # Dependency tracking DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d -DEPFILES := $(C_OBJECTS:%.o=%.d) +DEPFILES := $(OBJS:%.o=%.d) #--------------------------------------------------------------------------------- @@ -32,10 +35,13 @@ $(TARGET).exe: $(C_OBJECTS) #--------------------------------------------------------------------------------- # object generation #--------------------------------------------------------------------------------- -$(C_OBJECTS): $(BUILD_DIR)/%.o : $(BUILD_DIR)/%.S +$(BUILD_DIR)/%.o : src/amiga/%.S $(AS) $< -o $@ -$(C_ASSEMS): $(BUILD_DIR)/%.S : $(SOURCE_DIR)/%.c +$(BUILD_DIR)/%.o : src/%.c + $(CC) $(CFLAGS) $(DEPFLAGS) -S -c $< -o $@ + +$(BUILD_DIR)/%.S : src/amiga/%.c $(CC) $(CFLAGS) $(DEPFLAGS) -S -c $< -o $@ # Dependency tracking diff --git a/misc/atari_st/Makefile b/misc/atari_st/Makefile index 328989a11..a415dc85d 100644 --- a/misc/atari_st/Makefile +++ b/misc/atari_st/Makefile @@ -1,4 +1,4 @@ -TARGET := ClassiCube +TARGET := ClassiCube-atari BUILD_DIR := build/atari_st SOURCE_DIRS := src src/atari_st @@ -6,6 +6,7 @@ S_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S)) C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o))) + #--------------------------------------------------------------------------------- # Code generation #--------------------------------------------------------------------------------- @@ -18,8 +19,9 @@ ASFLAGS = -Fvobj -m68000 -no-fpu LDFLAGS = $(CFLAGS) LDLIBS = -lm + #--------------------------------------------------------------------------------- -# targets +# Main targets #--------------------------------------------------------------------------------- default: $(BUILD_DIR) $(TARGET).tos @@ -29,6 +31,10 @@ $(BUILD_DIR): $(TARGET).tos: $(OBJS) $(CC) $(LDFLAGS) -final -o $@ $^ $(LDLIBS) + +#--------------------------------------------------------------------------------- +# object generation +#--------------------------------------------------------------------------------- $(BUILD_DIR)/%.o : src/%.c $(CC) $(CFLAGS) -c -o $@ $< diff --git a/src/Core.h b/src/Core.h index 259d556c8..8922a03a1 100644 --- a/src/Core.h +++ b/src/Core.h @@ -264,9 +264,19 @@ typedef cc_uint8 cc_bool; #undef CC_BUILD_FREETYPE #define CC_BUILD_AMIGA #define CC_BUILD_COOPTHREADED + #define CC_BUILD_TINYMEM #define CC_BUILD_LOWMEM #define CC_BUILD_NOMUSIC #define CC_BUILD_NOSOUNDS + #define CC_BUILD_NOFPU + #undef CC_BUILD_RESOURCES + #undef CC_BUILD_ADVLIGHTING + #undef CC_BUILD_NETWORKING + #undef CC_BUILD_FILESYSTEM + #undef CC_BUILD_COMPRESSION + #define CC_BUILD_MAXSTACK (32 * 1024) + #define CC_DISABLE_ANIMATIONS /* Very costly in FPU less system */ + #define CC_DISABLE_HELDBLOCK /* Very costly in FPU less system */ #define DEFAULT_AUD_BACKEND CC_AUD_BACKEND_NULL #define DEFAULT_NET_BACKEND CC_NET_BACKEND_BUILTIN #define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_SOFTGPU diff --git a/src/ExtMath.c b/src/ExtMath.c index eb5563ac5..c032f283a 100644 --- a/src/ExtMath.c +++ b/src/ExtMath.c @@ -98,7 +98,7 @@ float sqrtf(float x) { } #elif defined __GNUC__ || defined NXDK /* Defined in .h using builtins */ -#elif defined __TINYC__ || defined CC_BUILD_ATARIOS +#elif defined __TINYC__ || defined CC_BUILD_ATARIOS || defined CC_BUILD_AMIGA /* Older versions of TinyC don't support fabsf or sqrtf */ /* Those can be used though if compiling with newer TinyC */ /* versions for a very small performance improvement */ diff --git a/src/Platform_Amiga.c b/src/Platform_Amiga.c index c98b1836b..6ec0d9559 100644 --- a/src/Platform_Amiga.c +++ b/src/Platform_Amiga.c @@ -31,7 +31,11 @@ const char* Platform_AppNameSuffix = " Amiga"; cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS; cc_bool Platform_ReadonlyFilesystem; +#ifdef __GNUC__ static const char __attribute__((used)) min_stack[] = "$STACK:102400"; +#else +size_t __stack = 65536; // vbcc +#endif /*########################################################################################################################* *-----------------------------------------------------Main entrypoint-----------------------------------------------------* @@ -87,9 +91,10 @@ void Platform_Log(const char* msg, int len) { TimeMS DateTime_CurrentUTC(void) { ULONG secs, micro; - CurrentTime(&secs, µ); + //CurrentTime(&secs, µ); // TODO epoch adjustment - return secs; + //return secs; + return 0; } void DateTime_CurrentLocal(struct cc_datetime* t) { @@ -113,9 +118,14 @@ void Process_Abort2(cc_result result, const char* raw_msg) { #define US_PER_SEC 1000000ULL cc_uint64 Stopwatch_Measure(void) { +#ifdef __GNUC__ ULONG secs, micro; CurrentTime(&secs, µ); return secs * US_PER_SEC + micro; +#else + // TODO + return 10; +#endif } cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) { diff --git a/src/Vorbis.c b/src/Vorbis.c index f69a418cd..f82a6af82 100644 --- a/src/Vorbis.c +++ b/src/Vorbis.c @@ -7,7 +7,7 @@ #include "Errors.h" #include "Stream.h" -#if !defined CC_BUILD_ATARIOS +#if !defined CC_BUILD_ATARIOS && !defined CC_BUILD_AMIGA /*########################################################################################################################* *-------------------------------------------------------Ogg stream--------------------------------------------------------* *#########################################################################################################################*/