From efc687fa24714314e8e878fa6f9c45a3e7b8eb9d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 2 Mar 2006 13:16:02 +0000 Subject: [PATCH] Updated for Dreamcast KOS June 2005 snapshot: http://cadcdev.sourceforge.net/svn/snapshots/ http://gamedev.allusion.net/softprj/kos/dcsetup.php --- Makefile.dc | 27 +++++++++++-------------- include/SDL_config.h.in | 2 ++ include/SDL_config_dreamcast.h | 33 +++++++++++++++++++++++++++++-- include/SDL_platform.h | 2 +- src/audio/dc/SDL_dcaudio.c | 7 ------- src/audio/dc/aica.c | 10 +++++++--- src/cdrom/dc/SDL_syscdrom.c | 3 +-- src/joystick/dc/SDL_sysjoystick.c | 3 +-- src/thread/dc/SDL_systhread.c | 30 +--------------------------- src/video/dc/SDL_dcevents.c | 2 +- src/video/dc/SDL_dcvideo.c | 2 ++ 11 files changed, 59 insertions(+), 62 deletions(-) diff --git a/Makefile.dc b/Makefile.dc index 467391326..2356f9a84 100644 --- a/Makefile.dc +++ b/Makefile.dc @@ -1,20 +1,16 @@ #GL=1 -CC = sh-elf-gcc -ml -m4-single-only +CC = sh-elf-gcc AR = sh-elf-ar -KOS_BASE=/prog/kos-1.1.7 -INCS = -I$(KOS_BASE)/libc/include -I$(KOS_BASE)/include -I$(KOS_BASE)/kernel/arch/dreamcast/include -DEFS =-DNO_SIGNAL_H -DENABLE_DC ifdef GL -DEFS += -DHAVE_OPENGL +DEFS += -DSDL_VIDEO_OPENGL=1 TARGET = libSDL_gl.a else TARGET = libSDL.a endif -OPTFLAGS=-O2 -fomit-frame-pointer -CFLAGS=-D_arch_dreamcast $(DEFS) $(INCS) -Iinclude -Isrc -Isrc/audio -Isrc/cdrom -Isrc/endian -Isrc/events -Isrc/joystick -Isrc/thread/dc -Isrc/thread -Isrc/timer -Isrc/video $(OPTFLAGS) +CFLAGS=$(KOS_CFLAGS) $(DEFS) -Iinclude SRCS = \ src/audio/dc/SDL_dcaudio.c \ @@ -22,12 +18,10 @@ SRCS = \ src/audio/SDL_audio.c \ src/audio/SDL_audiocvt.c \ src/audio/SDL_audiodev.c \ - src/audio/SDL_audiomem.c \ src/audio/SDL_mixer.c \ src/audio/SDL_wave.c \ src/cdrom/dc/SDL_syscdrom.c \ src/cdrom/SDL_cdrom.c \ - src/endian/SDL_endian.c \ src/events/SDL_active.c \ src/events/SDL_events.c \ src/events/SDL_expose.c \ @@ -38,11 +32,15 @@ SRCS = \ src/file/SDL_rwops.c \ src/joystick/dc/SDL_sysjoystick.c \ src/joystick/SDL_joystick.c \ + src/loadso/dummy/SDL_sysloadso.c \ src/SDL.c \ src/SDL_error.c \ src/SDL_fatal.c \ - src/SDL_getenv.c \ - src/SDL_loadso.c \ + src/stdlib/SDL_getenv.c \ + src/stdlib/SDL_malloc.c \ + src/stdlib/SDL_qsort.c \ + src/stdlib/SDL_stdlib.c \ + src/stdlib/SDL_string.c \ src/thread/dc/SDL_syscond.c \ src/thread/dc/SDL_sysmutex.c \ src/thread/dc/SDL_syssem.c \ @@ -97,9 +95,8 @@ TEST = \ test/threadwin.c \ test/torturethread.c \ -clean: - rm $(OBJS) - -$(TARGET) : $(OBJS) +$(TARGET): $(OBJS) $(AR) rcs $(TARGET) $(OBJS) +clean: + rm -f $(OBJS) diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index c15c2b8c1..901cd915f 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -106,9 +106,11 @@ #undef HAVE__UITOA #undef HAVE__ULTOA #undef HAVE_STRTOL +#undef HAVE_STRTOUL #undef HAVE__I64TOA #undef HAVE__UI64TOA #undef HAVE_STRTOLL +#undef HAVE_STRTOULL #undef HAVE_STRTOD #undef HAVE_ATOI #undef HAVE_ATOF diff --git a/include/SDL_config_dreamcast.h b/include/SDL_config_dreamcast.h index 884a54a9b..efff6b843 100644 --- a/include/SDL_config_dreamcast.h +++ b/include/SDL_config_dreamcast.h @@ -25,6 +25,15 @@ /* This is a set of defines to configure the SDL features */ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +typedef unsigned long uintptr_t; #define SDL_HAS_64BIT_TYPE 1 /* Useful headers */ @@ -32,8 +41,7 @@ #define HAVE_STDIO_H 1 #define STDC_HEADERS 1 #define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_SIGNAL_H 1 +#define HAVE_CTYPE_H 1 /* C library functions */ #define HAVE_MALLOC 1 @@ -43,10 +51,31 @@ #define HAVE_ALLOCA 1 #define HAVE_GETENV 1 #define HAVE_PUTENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 #define HAVE_MEMSET 1 #define HAVE_MEMCPY 1 #define HAVE_MEMMOVE 1 #define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRDUP 1 +#define HAVE_INDEX 1 +#define HAVE_RINDEX 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRICMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 /* Enable various audio drivers */ #define SDL_AUDIO_DRIVER_DC 1 diff --git a/include/SDL_platform.h b/include/SDL_platform.h index f70bb5a43..24d7540fd 100644 --- a/include/SDL_platform.h +++ b/include/SDL_platform.h @@ -41,7 +41,7 @@ #undef __BSDI__ #define __BSDI__ 1 #endif -#if defined(DREAMCAST) +#if defined(_arch_dreamcast) #undef __DREAMCAST__ #define __DREAMCAST__ 1 #endif diff --git a/src/audio/dc/SDL_dcaudio.c b/src/audio/dc/SDL_dcaudio.c index 8230534b5..8715376fa 100644 --- a/src/audio/dc/SDL_dcaudio.c +++ b/src/audio/dc/SDL_dcaudio.c @@ -24,13 +24,6 @@ /* Output dreamcast aica */ -#include -#include -#include -#include -#include - - #include "SDL_timer.h" #include "SDL_audio.h" #include "../SDL_audiomem.h" diff --git a/src/audio/dc/aica.c b/src/audio/dc/aica.c index 160c2857f..b6a1c9364 100644 --- a/src/audio/dc/aica.c +++ b/src/audio/dc/aica.c @@ -6,6 +6,9 @@ */ #include "aica.h" +#include +#include + /* #define dc_snd_base ((volatile unsigned char *)0x00800000) */ /* arm side */ #define dc_snd_base ((volatile unsigned char *)0xa0700000) /* dc side */ @@ -37,7 +40,7 @@ void aica_init() { - int i, j, old; + int i, j, old = 0; /* Initialize AICA channels */ G2_LOCK(old); @@ -146,9 +149,10 @@ static inline unsigned AICA_FREQ(unsigned freq) { This routine (and the similar ones) owe a lot to Marcus' sound example -- I hadn't gotten quite this far into dissecting the individual regs yet. */ void aica_play(int ch,int mode,unsigned long smpptr,int loopst,int loopend,int freq,int vol,int pan,int loopflag) { - int i; +/* int i; +*/ int val; - int old; + int old = 0; /* Stop the channel (if it's already playing) */ aica_stop(ch); diff --git a/src/cdrom/dc/SDL_syscdrom.c b/src/cdrom/dc/SDL_syscdrom.c index 3f79a8c6e..5c4467cd4 100644 --- a/src/cdrom/dc/SDL_syscdrom.c +++ b/src/cdrom/dc/SDL_syscdrom.c @@ -86,7 +86,7 @@ static int SDL_SYS_CDGetTOC(SDL_CD *cdrom) cdrom->track[i].id = i+1; cdrom->track[i].type = (TOC_CTRL(toc.entry[i])==TRACK_CDDA)?SDL_AUDIO_TRACK:SDL_DATA_TRACK; cdrom->track[i].offset = TOC_LBA(entry)-150; - cdrom->track[i].length = TOC_LBA((i+1track[i].length = TOC_LBA((i+1 -#if SDL_THREADS_DISABLED -int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) -{ - SDL_SetError("Threads are not supported on this platform"); - return(-1); -} - -void SDL_SYS_SetupThread(void) -{ - return; -} - -Uint32 SDL_ThreadID(void) -{ - return(0); -} - -void SDL_SYS_WaitThread(SDL_Thread *thread) -{ - return; -} - -void SDL_SYS_KillThread(SDL_Thread *thread) -{ - return; -} - -#else int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) { thread->handle = thd_create(SDL_RunThread,args); @@ -85,4 +58,3 @@ void SDL_SYS_KillThread(SDL_Thread *thread) { thd_destroy(thread->handle); } -#endif diff --git a/src/video/dc/SDL_dcevents.c b/src/video/dc/SDL_dcevents.c index c1808d2fc..1e8e2b5d8 100644 --- a/src/video/dc/SDL_dcevents.c +++ b/src/video/dc/SDL_dcevents.c @@ -113,7 +113,7 @@ static void keyboard_update(void) maple_raddr(addr,&port,&unit); - state = kbd_get_state(port,unit); + state = maple_dev_state(port,unit); if (!state) return; shiftkeys = state->shift_keys ^ old_state.shift_keys; diff --git a/src/video/dc/SDL_dcvideo.c b/src/video/dc/SDL_dcvideo.c index 6b8b10830..3d884c339 100644 --- a/src/video/dc/SDL_dcvideo.c +++ b/src/video/dc/SDL_dcvideo.c @@ -53,10 +53,12 @@ static int DC_FlipHWSurface(_THIS, SDL_Surface *surface); static void DC_UpdateRects(_THIS, int numrects, SDL_Rect *rects); /* OpenGL */ +#if SDL_VIDEO_OPENGL static void *DC_GL_GetProcAddress(_THIS, const char *proc); static int DC_GL_LoadLibrary(_THIS, const char *path); static int DC_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value); static void DC_GL_SwapBuffers(_THIS); +#endif /* DC driver bootstrap functions */