From 031da68c8edaa8c0192fae8c3e0fc8706aeacf48 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 30 Sep 2023 15:22:23 +1000 Subject: [PATCH] Dreamcast: Fix build not working, also add classicube textures for default textures since Dreamcast build currently can't write any files --- .github/workflows/build_dreamcast.yml | 6 ------ misc/dreamcast/Makefile | 9 ++++++++- src/Platform_Dreamcast.c | 27 ++------------------------- 3 files changed, 10 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build_dreamcast.yml b/.github/workflows/build_dreamcast.yml index 72d2b881c..c121aa17c 100644 --- a/.github/workflows/build_dreamcast.yml +++ b/.github/workflows/build_dreamcast.yml @@ -26,12 +26,6 @@ jobs: NOTIFY_MESSAGE: 'Failed to compile Dreamcast build' WEBHOOK_URL: '${{ secrets.WEBHOOK_URL }}' - - uses: ./.github/actions/upload_build - if: ${{ always() && steps.compile.outcome == 'success' }} - with: - SOURCE_FILE: 'ClassiCube-dc.elf' - DEST_NAME: 'ClassiCube-dc.elf' - - uses: ./.github/actions/upload_build if: ${{ always() && steps.compile.outcome == 'success' }} with: diff --git a/misc/dreamcast/Makefile b/misc/dreamcast/Makefile index ab37c445c..9dbd60f88 100644 --- a/misc/dreamcast/Makefile +++ b/misc/dreamcast/Makefile @@ -10,12 +10,13 @@ LDFLAGS=-g LIBS=-lm $(GLDC_LIB) TARGET := ClassiCube-dc +CC_TEXTURES = classicube.zip ifeq ($(strip $(KOS_BASE)),) $(error "Please set KOS variables in your environment.") endif -default: $(GLDC_LIB) $(BUILD_DIR) $(TARGET).cdi +default: $(CC_TEXTURES) $(GLDC_LIB) $(BUILD_DIR) $(TARGET).cdi $(BUILD_DIR): mkdir -p $(BUILD_DIR) @@ -23,6 +24,10 @@ $(BUILD_DIR): $(GLDC_LIB): $(MAKE) -C third_party/gldc +# TODO add textures to misc folder ? +$(CC_TEXTURES): + curl http://www.classicube.net/static/default.zip -o $@ + $(BUILD_DIR)/%.o: src/%.c kos-cc $(CFLAGS) -c $< -o $@ @@ -43,6 +48,8 @@ $(TARGET)-scr.bin: $(TARGET).bin $(TARGET).iso: $(TARGET)-scr.bin mkdir -p ISO_FILES cp $(TARGET)-scr.bin ISO_FILES/1ST_READ.BIN + mkdir -p ISO_FILES/texpacks + cp $(CC_TEXTURES) ISO_FILES/texpacks/classicube.zip cp misc/dreamcast/IP.BIN IP.BIN mkisofs -G IP.BIN -C 0,11702 -J -l -r -o $(TARGET).iso ISO_FILES # genisoimage -V ClassiCube -G IP.BIN -joliet -rock -l -o $(TARGET).iso ISO_FILES diff --git a/src/Platform_Dreamcast.c b/src/Platform_Dreamcast.c index 62bc23ea6..59c4025d6 100644 --- a/src/Platform_Dreamcast.c +++ b/src/Platform_Dreamcast.c @@ -34,33 +34,12 @@ const char* Platform_AppNameSuffix = " Dreamcast"; *#########################################################################################################################*/ cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) { if (end < beg) return 0; - return (end - beg) / 1000; + return end - beg; } -// Borrowed from kos/kernel/arch/dreamcast/kernel/timer.c so it compiles -// with older toolchain versions -#define _PMCR_CTRL_0 ( *((volatile uint16*)(0xff000084)) ) -#define _PMCTR_HIGH_0 ( *((volatile uint32*)(0xff100004)) ) -#define _PMCTR_LOW_0 ( *((volatile uint32*)(0xff100008)) ) -#define _PMCR_CLR 0x2000 -#define _PMCR_PMENABLE 0x8000 -#define _PMCR_RUN 0xc000 -#define _PMCR_PMM_MASK 0x003f -#define _PMCR_CLOCK_TYPE_SHIFT 8 -#define _NS_PER_CYCLE 5 -#define _PMCR_COUNT_CPU_CYCLES 0 -#define _PMCR_ELAPSED_TIME_MODE 0x23 cc_uint64 Stopwatch_Measure(void) { - uint64 cycles = (uint64)(_PMCTR_HIGH_0 & 0xFFFF) << 32 | _PMCTR_LOW_0; - return cycles * _NS_PER_CYCLE; + return timer_us_gettime64(); } -static void Stopwatch_Init(void) { - _PMCR_CTRL_0 &= ~(_PMCR_PMM_MASK | _PMCR_PMENABLE); - _PMCR_CTRL_0 |= _PMCR_CLR; - _PMCR_CTRL_0 = _PMCR_RUN | _PMCR_ELAPSED_TIME_MODE | (_PMCR_COUNT_CPU_CYCLES << _PMCR_CLOCK_TYPE_SHIFT); -} -// NOTE: If using newer toolchain versions, only need this: -// cc_uint64 Stopwatch_Measure(void) { return timer_ns_gettime64(); } void Platform_Log(const char* msg, int len) { fs_write(STDOUT_FILENO, msg, len); @@ -441,8 +420,6 @@ cc_result Process_StartOpen(const cc_string* args) { } void Platform_Init(void) { - Stopwatch_Init(); - char cwd[600] = { 0 }; char* ptr = getcwd(cwd, 600); Platform_Log1("WORKING DIR: %c", ptr);