Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Sep 30, 2023
1 parent ee9e9b0 commit 7addea1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 27 deletions.
9 changes: 8 additions & 1 deletion misc/dreamcast/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@ 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)

$(GLDC_LIB):
$(MAKE) -C third_party/gldc

# TODO add textures to misc folder ?
$(CC_TEXTURES):
wget http://www.classicube.net/static/default.zip -O $@

$(BUILD_DIR)/%.o: src/%.c
kos-cc $(CFLAGS) -c $< -o $@

Expand All @@ -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
Expand Down
29 changes: 3 additions & 26 deletions src/Platform_Dreamcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
// 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
return end - beg;
}

cc_uint64 Stopwatch_Measure(void) {
uint64 cycles = (uint64)(_PMCTR_HIGH_0 & 0xFFFF) << 32 | _PMCTR_LOW_0;
return cycles * _NS_PER_CYCLE;
}
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);
return timer_us_gettime64();
}
// 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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7addea1

Please sign in to comment.