diff -ruN SDL-1.2.3.orig/configure.in SDL-1.2.3/configure.in --- SDL-1.2.3.orig/configure.in Thu Nov 8 08:28:00 2001 +++ SDL-1.2.3/configure.in Wed Jan 9 21:22:42 2002 @@ -65,6 +65,15 @@ ;; esac +dnl Compiling thumb code for GBA +case "$target" in + arm-agb-*) + if test x$ac_cv_prog_gcc = xyes; then + CFLAGS="$CFLAGS -Os -mthumb -mthumb-interwork -D__GBA__ -DENABLE_GBA -DDISABLE_THREADS" + fi + ;; +esac + dnl Add compiler-specific optimization flags dnl See if the user wants aggressive optimizations of the code @@ -124,6 +133,9 @@ *-*-darwin*) MATHLIB="" ;; + arm-agb-*) + MATHLIB="" + ;; *) MATHLIB="-lm" ;; @@ -1026,6 +1038,10 @@ pthread_cflags="" pthread_lib="" ;; + arm-agb-*) + pthread_cflags="" + pthread_lib="" + ;; *) pthread_cflags="-D_REENTRANT" pthread_lib="-lpthread" @@ -2124,6 +2140,46 @@ SDL_CFLAGS="$SDL_CFLAGS -F/System/Library/Frameworks/Carbon.framework -F/System/Library/Frameworks/Cocoa.framework" SDL_LIBS="-lSDLmain $SDL_LIBS -framework Carbon -framework Cocoa" ;; + arm-agb-* ) + ARCH=gba + # Set up files for the main() stub + # COPY_ARCH_SRC(src/main, macos, SDL_main.c) + COPY_ARCH_SRC(src/main, gba, SDL_main.c) + # Set up files for the audio library + if test x$enable_audio = xyes; then + AUDIO_SUBDIRS="$AUDIO_SUBDIRS gba" + AUDIO_DRIVERS="$AUDIO_DRIVERS gba/libaudio_gba.la" + fi + # Set up files for the joystick library + if test x$enable_joystick = xyes; then + JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS gba" + JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS gba/libjoystick_gba.la" + fi + # Set up files for the cdrom library + if test x$enable_cdrom = xyes; then + COPY_ARCH_SRC(src/cdrom, dummy, SDL_syscdrom.c) + fi + # Set up files for the thread library + if test x$enable_threads = xyes; then + COPY_ARCH_SRC(src/thread, generic, SDL_systhread.c) + COPY_ARCH_SRC(src/thread, generic, SDL_systhread_c.h) + COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex.c) + COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex_c.h) + COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c) + COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h) + COPY_ARCH_SRC(src/thread, generic, SDL_syscond.c) + COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h) + fi + # Set up files for the timer library + if test x$enable_timers = xyes; then + COPY_ARCH_SRC(src/timer, gba, SDL_systimer.c) + fi + # The MacOS X platform requires special setup + SDL_CFLAGS="$SDL_CFLAGS " + SDL_LIBS="-lSDLmain $SDL_LIBS " + VIDEO_SUBDIRS="$VIDEO_SUBDIRS gba" + VIDEO_DRIVERS="$VIDEO_DRIVERS gba/libvideo_gba.la" + ;; *) AC_MSG_ERROR(Unsupported target: Please add to configure.in) ;; @@ -2143,6 +2199,7 @@ AM_CONDITIONAL(TARGET_BEOS, test $ARCH = beos) AM_CONDITIONAL(TARGET_MACOS, test $ARCH = macos) AM_CONDITIONAL(TARGET_MACOSX, test $ARCH = macosx) +AM_CONDITIONAL(TARGET_GBA, test $ARCH = gba) # Set conditional variables for shared and static library selection. # These are not used in any Makefile.am but in sdl-config.in. @@ -2240,6 +2297,7 @@ src/audio/dmedia/Makefile src/audio/dsp/Makefile src/audio/esd/Makefile +src/audio/gba/Makefile src/audio/macrom/Makefile src/audio/nas/Makefile src/audio/nto/Makefile @@ -2252,6 +2310,7 @@ src/audio/disk/Makefile src/video/Makefile src/video/cybergfx/Makefile +src/video/gba/Makefile src/video/x11/Makefile src/video/dga/Makefile src/video/nanox/Makefile @@ -2279,6 +2338,7 @@ src/joystick/beos/Makefile src/joystick/darwin/Makefile src/joystick/dummy/Makefile +src/joystick/gba/Makefile src/joystick/linux/Makefile src/joystick/macos/Makefile src/joystick/win32/Makefile diff -ruN SDL-1.2.3.orig/include/SDL.h SDL-1.2.3/include/SDL.h --- SDL-1.2.3.orig/include/SDL.h Thu Apr 26 18:50:17 2001 +++ SDL-1.2.3/include/SDL.h Wed Jan 9 21:19:03 2002 @@ -44,6 +44,10 @@ #include "SDL_byteorder.h" #include "SDL_version.h" +#ifdef __GBA__ +#include "mbv2lib.h" +#endif + #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus diff -ruN SDL-1.2.3.orig/include/SDL_rwops.h SDL-1.2.3/include/SDL_rwops.h --- SDL-1.2.3.orig/include/SDL_rwops.h Thu Apr 26 18:50:17 2001 +++ SDL-1.2.3/include/SDL_rwops.h Wed Jan 9 21:19:03 2002 @@ -33,6 +33,7 @@ #define _SDL_RWops_h #include +#include "mbv2lib.h" #include "SDL_types.h" diff -ruN SDL-1.2.3.orig/include/mbv2lib.h SDL-1.2.3/include/mbv2lib.h --- SDL-1.2.3.orig/include/mbv2lib.h Thu Jan 1 01:00:00 1970 +++ SDL-1.2.3/include/mbv2lib.h Wed Jan 9 21:19:03 2002 @@ -0,0 +1,162 @@ +#define __ANSI_NAMES 1 +// +// v1.41 - Put received keyboard & file data in separate buffers +// +// MB v1.41 or later pc software is required to use this library +// software. +// +// NOTE: THIS LIBRARY USES GLOBAL INITIALIZED DATA SO YOU MUST USE +// A CRT0.S AND A LINKER SCRIPT THAT SUPPORTS THIS AS WELL. GET +// CRTLS V1.1 OR LATER FROM HTTP://www.devrs.com/gba FOR PROPER SUPPORT. +// +// The following library functions are supported: +// +// Library name Standard Name Function +// dprintf printf Print a string on PC console. +// dputchar putchar Print a char on PC console. +// dgetch getch Get a char from PC keyboard. +// dkbhit kbhit Return 1 if PC keyboard char is ready. +// +// dfopen fopen Open PC file. +// dfclose fclose Close PC file. +// dfprintf fprintf Print a string to PC file. +// dfgetc fgetc Get char from PC file. +// dfputc fputc Write a char to PC file. +// drewind rewind Set file pointer to start of file. +// +// If you wish to use the standard naming conventions +// rather than the library names then change "__ANSI_NAMES 0" +// to "__ANSI_NAMES 1" instead. +// +// Notes: +// +// Currently only ONE file may be open at a time. +// +// If you are sending raw binary data to a PC file, use +// dfputc instead of dfprintf. Dfprintf will insert +// carriage return characters before linefeed characters +// on the PC side if the PC console software is running on +// dos/windows for proper text formatting. +// +// If you are missing some .h files during compile than get +// 'arminc.zip' from http://www.devrs.com/gba in the +// Apps / C Compilers section. +// +// Example command line: +// mb -s file.mb -c -w 50 -x 255 -m +// +// In this example, after transferring "file.mb" to the GBA, +// the PC goes into console/file server mode (-c) and also +// shows all of the file open/file close/fgetc/fputc commands +// (-m) on screen. The -w value should be a large enough value +// where the -s is reliable and the -x value should be a large +// enough value where the -c is reliable with the GBA. +// +// [Sending a file & console mode each have +// their own delay settings because they +// each use a different method for transferring +// data. Each method is about ideal for it's +// application.] +// +// Example GBA Code: +// +// #include "mbv2lib.c" +// +// int main (void) +// { +// +// int i,j,k; +// FILE* fp; +// +// dprintf ("Hello world!"); +// +// // Get character from PC keyboard +// i = dgetch (); +// +// // Copy SRAM to PC +// fp = dfopen("sram.bin","wb"); +// for (i = 0; i != 0x8000; i++) +// dfputc(*(unsigned char *)(i + 0xE000000), fp); +// dfclose(fp); +// +// // Read data from file +// fp = dfopen ("foo.bin", "rb"); +// i = dfgetc (fp); +// j = dfgetc (fp); +// k = dfgetc (fp); +// dfclose (fp); +// +// } + +// Data transfer format +// -------------------- +// +// PC -> GBA Comms: +// Raw data is PC File read data. +// ESCCHR 0x00 = nada (used for input polling) +// ESCCHR 0x01 = Escape character from PC file read +// ESCCHR 0x08 0x?? = Keyboard read data +// +// +// GBA -> PC comms +// Raw data is console print data. +// ESCCHR = escape sequence +// ESCCHR 0x00 = nada (used for input polling) +// ESCCHR 0x01 = Escape character for console print +// ESCCHR 0x02 = file open (gba -> PC) +// ESCCHR 0x03 = file close (gba -> PC) +// ESCCHR 0x04 = fgetc (gba -> PC) +// ESCCHR 0x05 0x?? = fputc (gba -> PC) +// ESCCHR 0x06 = rewind (gba -> PC) +// ESCCHR 0x07 = fputc processed (gba -> pC) (Add CR before LF char if win/DOS machine) + +#define FILE int + +#include "vsprintf.h" + +extern int __debug_shutup; + +#define __DOUTBUFSIZE 256 +extern unsigned char __outstr[__DOUTBUFSIZE]; + +extern int dputchar (int c); + +extern void __PrintStr (char *str); + +extern int dgetch (void); + +extern int dfgetch (void); + +extern int dkbhit (void); + +extern FILE* dfopen (const char *file, const char *type); + +extern int dfclose (FILE* fp); + +extern int dfgetc (FILE* fp); + +extern int dfputc (int ch, FILE* fp); + +extern void drewind (FILE* fp); + +extern void __PrintStrToFile (FILE* fp, char *str); + +#define dprintf(x...) ({ dsprintf(__outstr, x); __PrintStr(__outstr); }) +#define dfprintf(y,x...) ({ dsprintf(__outstr, x); __PrintStrToFile((FILE*)y,__outstr); }) + +#ifdef __ANSI_NAMES + #define printf dprintf + #define fprintf dfprintf + #define putchar dputchar + #define getch dgetch + #define kbhit dkbhit + + #define fopen dfopen + #define fclose dfclose + #define fgetc dfgetc + #define fputc dfputc + #define rewind drewind + #define fread dfread + #define fwrite dfwrite + #define fgets dfgets +#endif diff -ruN SDL-1.2.3.orig/include/typegba.h SDL-1.2.3/include/typegba.h --- SDL-1.2.3.orig/include/typegba.h Thu Jan 1 01:00:00 1970 +++ SDL-1.2.3/include/typegba.h Wed Jan 9 21:19:03 2002 @@ -0,0 +1,8 @@ +#ifndef _TYPE_H_ +#define _TYPE_H_ + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; + +#endif diff -ruN SDL-1.2.3.orig/include/vsprintf.h SDL-1.2.3/include/vsprintf.h --- SDL-1.2.3.orig/include/vsprintf.h Thu Jan 1 01:00:00 1970 +++ SDL-1.2.3/include/vsprintf.h Wed Jan 9 21:19:03 2002 @@ -0,0 +1,10 @@ +#include +//#include +#include +#include +extern unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base); +extern long simple_strtol(const char *cp,char **endp,unsigned int base); +extern size_t dstrnlen (const char *s, size_t maxlen); +extern int sprintf(char * buf, const char *fmt, ...); +extern int vsprintf(char *buf, const char *fmt, va_list args); +extern int dsprintf(char * buf, const char *fmt, ...); diff -ruN SDL-1.2.3.orig/src/Makefile.am SDL-1.2.3/src/Makefile.am --- SDL-1.2.3.orig/src/Makefile.am Thu Apr 26 18:45:44 2001 +++ SDL-1.2.3/src/Makefile.am Wed Jan 9 21:19:03 2002 @@ -1,6 +1,13 @@ ## Makefile.am for the main SDL library +if TARGET_GBA +GBA_SRCS=mbv2lib.c vsprintf.c +else +GBA_SRCS= +endif + + # These are the subdirectories that are always built CORE_SUBDIRS = \ main @@ -31,7 +38,7 @@ @SDL_EXTRALIBS@ # The SDL library sources -GENERAL_SRCS = \ +GENERAL_SRCS = $(GBA_SRCS) \ SDL.c \ SDL_error.c \ SDL_error_c.h \ diff -ruN SDL-1.2.3.orig/src/SDL.c SDL-1.2.3/src/SDL.c --- SDL-1.2.3.orig/src/SDL.c Thu May 24 01:35:09 2001 +++ SDL-1.2.3/src/SDL.c Wed Jan 9 21:19:03 2002 @@ -67,13 +67,19 @@ { #ifndef DISABLE_VIDEO /* Initialize the video/event subsystem */ + printf("SDL_InitSubSystem: VideoInit\n"); if ( (flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO) ) { +#ifdef __GBA__ + if ( SDL_VideoInit("gba", +#else if ( SDL_VideoInit(getenv("SDL_VIDEODRIVER"), +#endif (flags&SDL_INIT_EVENTTHREAD)) < 0 ) { return(-1); } SDL_initialized |= SDL_INIT_VIDEO; } + printf("SISS: VI done\n"); #else if ( flags & SDL_INIT_VIDEO ) { SDL_SetError("SDL not built with video support"); @@ -84,7 +90,11 @@ #ifndef DISABLE_AUDIO /* Initialize the audio subsystem */ if ( (flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO) ) { +#ifdef __GBA__ + if ( SDL_AudioInit("gba") < 0 ) { +#else if ( SDL_AudioInit(getenv("SDL_AUDIODRIVER")) < 0 ) { +#endif return(-1); } SDL_initialized |= SDL_INIT_AUDIO; @@ -154,14 +164,16 @@ SDL_ClearError(); /* Initialize the desired subsystems */ + printf("SDL_Init: SDL_InitSubSystem\n"); if ( SDL_InitSubSystem(flags) < 0 ) { return(-1); } - /* Everything is initialized */ + printf("done, SDL_Init: Parachute\n"); if ( !(flags & SDL_INIT_NOPARACHUTE) ) { SDL_InstallParachute(); } + printf("done\n"); return(0); } diff -ruN SDL-1.2.3.orig/src/SDL_error.c SDL-1.2.3/src/SDL_error.c --- SDL-1.2.3.orig/src/SDL_error.c Thu Apr 26 18:50:17 2001 +++ SDL-1.2.3/src/SDL_error.c Wed Jan 9 21:19:03 2002 @@ -32,6 +32,7 @@ #include #include +#include "SDL.h" #include "SDL_types.h" #include "SDL_getenv.h" #include "SDL_error.h" diff -ruN SDL-1.2.3.orig/src/SDL_fatal.c SDL-1.2.3/src/SDL_fatal.c --- SDL-1.2.3.orig/src/SDL_fatal.c Thu Apr 26 18:50:17 2001 +++ SDL-1.2.3/src/SDL_fatal.c Wed Jan 9 21:19:03 2002 @@ -137,7 +137,7 @@ signal(SDL_fatal_signals[i], ohandler); } } -#ifdef SIGALRM +#if defined SIGALRM && !defined(__GBA__) /* Set SIGALRM to be ignored -- necessary on Solaris */ { struct sigaction action, oaction; diff -ruN SDL-1.2.3.orig/src/audio/Makefile.am SDL-1.2.3/src/audio/Makefile.am --- SDL-1.2.3.orig/src/audio/Makefile.am Sat Jun 16 03:51:42 2001 +++ SDL-1.2.3/src/audio/Makefile.am Wed Jan 9 21:19:03 2002 @@ -5,7 +5,7 @@ # Define which subdirectories need to be built SUBDIRS = @AUDIO_SUBDIRS@ -DIST_SUBDIRS = alsa arts baudio dma dmedia dsp esd macrom nas nto openbsd paudio sun ums windib windx5 disk +DIST_SUBDIRS = alsa arts baudio dma dmedia dsp esd gba macrom nas nto openbsd paudio sun ums windib windx5 disk DRIVERS = @AUDIO_DRIVERS@ diff -ruN SDL-1.2.3.orig/src/audio/SDL_audio.c SDL-1.2.3/src/audio/SDL_audio.c --- SDL-1.2.3.orig/src/audio/SDL_audio.c Thu Aug 9 15:09:47 2001 +++ SDL-1.2.3/src/audio/SDL_audio.c Wed Jan 9 21:19:03 2002 @@ -68,6 +68,9 @@ #ifdef ENABLE_DIRECTX &DSOUND_bootstrap, #endif +#ifdef ENABLE_GBA + &GBA_AUDIO_bootstrap, +#endif #ifdef ENABLE_WINDIB &WAVEOUT_bootstrap, #endif diff -ruN SDL-1.2.3.orig/src/audio/SDL_audiomem.c SDL-1.2.3/src/audio/SDL_audiomem.c --- SDL-1.2.3.orig/src/audio/SDL_audiomem.c Thu Apr 26 18:50:17 2001 +++ SDL-1.2.3/src/audio/SDL_audiomem.c Wed Jan 9 21:19:03 2002 @@ -37,6 +37,7 @@ #include #endif +#include "SDL.h" #include "SDL_audiomem.h" /* Allocate memory that will be shared between threads (freed on exit) */ diff -ruN SDL-1.2.3.orig/src/audio/SDL_sysaudio.h SDL-1.2.3/src/audio/SDL_sysaudio.h --- SDL-1.2.3.orig/src/audio/SDL_sysaudio.h Thu Aug 9 15:09:47 2001 +++ SDL-1.2.3/src/audio/SDL_sysaudio.h Wed Jan 9 21:19:03 2002 @@ -127,6 +127,9 @@ #ifdef ENABLE_DIRECTX extern AudioBootStrap DSOUND_bootstrap; #endif +#ifdef ENABLE_GBA +extern AudioBootStrap GBA_AUDIO_bootstrap; +#endif #ifdef ENABLE_WINDIB extern AudioBootStrap WAVEOUT_bootstrap; #endif diff -ruN SDL-1.2.3.orig/src/audio/SDL_wave.c SDL-1.2.3/src/audio/SDL_wave.c --- SDL-1.2.3.orig/src/audio/SDL_wave.c Tue Sep 11 20:52:45 2001 +++ SDL-1.2.3/src/audio/SDL_wave.c Wed Jan 9 21:19:03 2002 @@ -32,6 +32,7 @@ #include #include +#include "SDL.h" #include "SDL_error.h" #include "SDL_audio.h" #include "SDL_wave.h" diff -ruN SDL-1.2.3.orig/src/audio/gba/Makefile.am SDL-1.2.3/src/audio/gba/Makefile.am --- SDL-1.2.3.orig/src/audio/gba/Makefile.am Thu Jan 1 01:00:00 1970 +++ SDL-1.2.3/src/audio/gba/Makefile.am Wed Jan 9 21:19:03 2002 @@ -0,0 +1,9 @@ + +## Makefile.am for SDL using the IRIX DMedia sound driver + +noinst_LTLIBRARIES = libaudio_gba.la +libaudio_gba_la_SOURCES = $(SRCS) + +# The SDL audio driver sources +SRCS = SDL_gbaaudio.c \ + SDL_gbaaudio.h diff -ruN SDL-1.2.3.orig/src/audio/gba/SDL_gbaaudio.c SDL-1.2.3/src/audio/gba/SDL_gbaaudio.c --- SDL-1.2.3.orig/src/audio/gba/SDL_gbaaudio.c Thu Jan 1 01:00:00 1970 +++ SDL-1.2.3/src/audio/gba/SDL_gbaaudio.c Wed Jan 9 21:19:03 2002 @@ -0,0 +1,124 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + 5635-34 Springhouse Dr. + Pleasanton, CA 94588 (USA) + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_gbaaudio.c,v 1.2 2001/04/26 16:50:17 hercules Exp $"; +#endif + +/* Allow access to a raw mixing buffer (For IRIX 6.5 and higher) */ + +#include + +#include "SDL.h" +#include "SDL_endian.h" +#include "SDL_timer.h" +#include "SDL_audio.h" +#include "SDL_audiomem.h" +#include "SDL_audio_c.h" +#include "SDL_gbaaudio.h" + + +/* Audio driver functions */ +static int GBA_OpenAudio(_THIS, SDL_AudioSpec *spec); +static void GBA_WaitAudio(_THIS); +static void GBA_PlayAudio(_THIS); +static Uint8 *GBA_GetAudioBuf(_THIS); +static void GBA_CloseAudio(_THIS); + +/* Audio driver bootstrap functions */ + +static int Audio_Available(void) +{ + return 0; +} + +static void Audio_DeleteDevice(SDL_AudioDevice *device) +{ +} + +static SDL_AudioDevice *Audio_CreateDevice(int devindex) +{ + SDL_AudioDevice *this; + + /* Initialize all variables that we clean on shutdown */ + this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); + if ( this ) { + memset(this, 0, (sizeof *this)); + this->hidden = (struct SDL_PrivateAudioData *) + malloc((sizeof *this->hidden)); + } + if ( (this == NULL) || (this->hidden == NULL) ) { + SDL_OutOfMemory(); + if ( this ) { + free(this); + } + return(0); + } + memset(this->hidden, 0, (sizeof *this->hidden)); + + /* Set the function pointers */ + this->OpenAudio = GBA_OpenAudio; + this->WaitAudio = GBA_WaitAudio; + this->PlayAudio = GBA_PlayAudio; + this->GetAudioBuf = GBA_GetAudioBuf; + this->CloseAudio = GBA_CloseAudio; + + this->free = Audio_DeleteDevice; + + return this; +} + +AudioBootStrap GBA_AUDIO_bootstrap = { + "gba", "GBA audio", + Audio_Available, Audio_CreateDevice +}; + + +void static GBA_WaitAudio(_THIS) +{ +} + +static void GBA_PlayAudio(_THIS) +{ +} + +static Uint8 *GBA_GetAudioBuf(_THIS) +{ + return(mixbuf); +} + +static void GBA_CloseAudio(_THIS) +{ + if ( mixbuf != NULL ) { + SDL_FreeAudioMem(mixbuf); + mixbuf = NULL; + } +} + +static int GBA_OpenAudio(_THIS, SDL_AudioSpec *spec) +{ + /* We're ready to rock and roll. :-) */ + return(0); +} diff -ruN SDL-1.2.3.orig/src/audio/gba/SDL_gbaaudio.h SDL-1.2.3/src/audio/gba/SDL_gbaaudio.h --- SDL-1.2.3.orig/src/audio/gba/SDL_gbaaudio.h Thu Jan 1 01:00:00 1970 +++ SDL-1.2.3/src/audio/gba/SDL_gbaaudio.h Wed Jan 9 21:19:03 2002 @@ -0,0 +1,46 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_gbaaudio.h,v 1.2 2001/04/26 16:50:17 hercules Exp $"; +#endif + +#ifndef _SDL_lowaudio_h +#define _SDL_lowaudio_h + +#include "SDL_sysaudio.h" + +/* Hidden "this" pointer for the audio functions */ +#define _THIS SDL_AudioDevice *this + +struct SDL_PrivateAudioData { + /* The handle for the audio device */ + + Uint8 *mixbuf; /* The app mixing buffer */ +}; + +/* Old variable names */ +#define audio_port (this->hidden->audio_port) +#define mixbuf (this->hidden->mixbuf) + +#endif /* _SDL_lowaudio_h */ diff -ruN SDL-1.2.3.orig/src/cdrom/SDL_cdrom.c SDL-1.2.3/src/cdrom/SDL_cdrom.c --- SDL-1.2.3.orig/src/cdrom/SDL_cdrom.c Thu Apr 26 18:50:17 2001 +++ SDL-1.2.3/src/cdrom/SDL_cdrom.c Wed Jan 9 21:19:03 2002 @@ -31,6 +31,7 @@ #include #include +#include "SDL.h" #include "SDL_error.h" #include "SDL_cdrom.h" #include "SDL_syscdrom.h" diff -ruN SDL-1.2.3.orig/src/events/SDL_events.c SDL-1.2.3/src/events/SDL_events.c --- SDL-1.2.3.orig/src/events/SDL_events.c Thu Apr 26 18:50:17 2001 +++ SDL-1.2.3/src/events/SDL_events.c Wed Jan 9 21:19:03 2002 @@ -219,22 +219,28 @@ SDL_eventstate &= ~(0x00000001 << SDL_SYSWMEVENT); SDL_ProcessEvents[SDL_SYSWMEVENT] = SDL_IGNORE; - /* Initialize event handlers */ + printf("/* Initialize event handlers */\n"); retcode = 0; + printf("IEH: AppAct\n"); retcode += SDL_AppActiveInit(); + printf("IEH: KeyboardInit\n"); retcode += SDL_KeyboardInit(); + printf("IEH: MouseInit\n"); retcode += SDL_MouseInit(); + printf("IEH: QuitInit\n"); retcode += SDL_QuitInit(); if ( retcode < 0 ) { /* We don't expect them to fail, but... */ return(-1); } - - /* Create the lock and event thread */ + printf("IEH: done\n"); + + printf("/* Create the lock and event thread */\n"); if ( SDL_StartEventThread(flags) < 0 ) { SDL_StopEventLoop(); return(-1); } + printf("CtLaET: done\n"); return(0); } diff -ruN SDL-1.2.3.orig/src/events/SDL_keyboard.c SDL-1.2.3/src/events/SDL_keyboard.c --- SDL-1.2.3.orig/src/events/SDL_keyboard.c Fri Nov 2 20:49:14 2001 +++ SDL-1.2.3/src/events/SDL_keyboard.c Wed Jan 9 21:19:03 2002 @@ -387,10 +387,10 @@ memset(&event, 0, sizeof(event)); -#if 0 +//#if 0 printf("The '%s' key has been %s\n", SDL_GetKeyName(keysym->sym), state == SDL_PRESSED ? "pressed" : "released"); -#endif +//#endif /* Set up the keysym */ modstate = (Uint16)SDL_ModState; diff -ruN SDL-1.2.3.orig/src/file/SDL_rwops.c SDL-1.2.3/src/file/SDL_rwops.c --- SDL-1.2.3.orig/src/file/SDL_rwops.c Thu May 24 01:35:09 2001 +++ SDL-1.2.3/src/file/SDL_rwops.c Wed Jan 9 21:19:03 2002 @@ -33,6 +33,7 @@ #include #include +#include "SDL.h" #include "SDL_error.h" #include "SDL_rwops.h" @@ -40,15 +41,23 @@ static int stdio_seek(SDL_RWops *context, int offset, int whence) { +#ifdef __GBA__ + SDL_Error(SDL_EFSEEK); + return -1; +#else if ( fseek(context->hidden.stdio.fp, offset, whence) == 0 ) { return(ftell(context->hidden.stdio.fp)); } else { SDL_Error(SDL_EFSEEK); return(-1); } +#endif } static int stdio_read(SDL_RWops *context, void *ptr, int size, int maxnum) { +#ifdef __GBA__ + SDL_Error(SDL_EFREAD); +#else size_t nread; nread = fread(ptr, size, maxnum, context->hidden.stdio.fp); @@ -56,9 +65,13 @@ SDL_Error(SDL_EFREAD); } return(nread); +#endif } static int stdio_write(SDL_RWops *context, const void *ptr, int size, int num) { +#ifdef __GBA__ + SDL_Error(SDL_EFWRITE); +#else size_t nwrote; nwrote = fwrite(ptr, size, num, context->hidden.stdio.fp); @@ -66,9 +79,13 @@ SDL_Error(SDL_EFWRITE); } return(nwrote); +#endif } static int stdio_close(SDL_RWops *context) { +#ifdef __GBA__ + return 0; +#else if ( context ) { if ( context->hidden.stdio.autoclose ) { /* WARNING: Check the return value here! */ @@ -77,6 +94,7 @@ free(context); } return(0); +#endif } /* Functions to read/write memory pointers */ diff -ruN SDL-1.2.3.orig/src/hello.c SDL-1.2.3/src/hello.c --- SDL-1.2.3.orig/src/hello.c Thu Jan 1 01:00:00 1970 +++ SDL-1.2.3/src/hello.c Wed Jan 9 21:19:03 2002 @@ -0,0 +1,9 @@ +#include "mbv2lib.c" +#define MULTIBOOT volatile const u8 __gba_multiboot; +MULTIBOOT + +main() +{ + printf("Hello, world!\n"); + for(;;); +} diff -ruN SDL-1.2.3.orig/src/joystick/Makefile.am SDL-1.2.3/src/joystick/Makefile.am --- SDL-1.2.3.orig/src/joystick/Makefile.am Tue Sep 11 21:00:18 2001 +++ SDL-1.2.3/src/joystick/Makefile.am Wed Jan 9 21:21:10 2002 @@ -5,7 +5,7 @@ # Define which subdirectories need to be built SUBDIRS = @JOYSTICK_SUBDIRS@ -DIST_SUBDIRS = dummy amigaos beos darwin linux macos win32 +DIST_SUBDIRS = dummy gba amigaos beos darwin linux macos win32 DRIVERS = @JOYSTICK_DRIVERS@ diff -ruN SDL-1.2.3.orig/src/joystick/SDL_joystick.c SDL-1.2.3/src/joystick/SDL_joystick.c --- SDL-1.2.3.orig/src/joystick/SDL_joystick.c Thu Apr 26 18:50:17 2001 +++ SDL-1.2.3/src/joystick/SDL_joystick.c Wed Jan 9 21:19:03 2002 @@ -31,6 +31,7 @@ #include #include +#include "SDL.h" #include "SDL_error.h" #include "SDL_events.h" #ifndef DISABLE_EVENTS diff -ruN SDL-1.2.3.orig/src/joystick/gba/Makefile.am SDL-1.2.3/src/joystick/gba/Makefile.am --- SDL-1.2.3.orig/src/joystick/gba/Makefile.am Thu Jan 1 01:00:00 1970 +++ SDL-1.2.3/src/joystick/gba/Makefile.am Wed Jan 9 21:19:03 2002 @@ -0,0 +1,8 @@ + +## Makefile.am for the gba joystick driver for SDL + +noinst_LTLIBRARIES = libjoystick_gba.la +libjoystick_gba_la_SOURCES = $(SRCS) + +# The SDL joystick driver sources +SRCS = SDL_sysjoystick.c diff -ruN SDL-1.2.3.orig/src/joystick/gba/SDL_sysjoystick.c SDL-1.2.3/src/joystick/gba/SDL_sysjoystick.c --- SDL-1.2.3.orig/src/joystick/gba/SDL_sysjoystick.c Thu Jan 1 01:00:00 1970 +++ SDL-1.2.3/src/joystick/gba/SDL_sysjoystick.c Wed Jan 9 21:19:03 2002 @@ -0,0 +1,105 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_sysjoystick.c,v 1.2 2001/04/26 16:50:17 hercules Exp $"; +#endif + +/* This is the system specific header for the SDL joystick API */ + +#include /* For the definition of NULL */ + +#include "SDL_error.h" +#include "SDL_joystick.h" +#include "SDL_sysjoystick.h" +#include "SDL_joystick_c.h" + +#include "../../video/gba/SDL_gbaevents_c.h" + +/* Function to scan the system for joysticks. + * This function should set SDL_numjoysticks to the number of available + * joysticks. Joystick 0 should be the system default joystick. + * It should return 0, or -1 on an unrecoverable fatal error. + */ +int SDL_SYS_JoystickInit(void) +{ + SDL_numjoysticks = 1; + return(0); +} + +/* Function to get the device-dependent name of a joystick */ +const char *SDL_SYS_JoystickName(int index) +{ + if(!index) + return "GBA builtin joypad"; + SDL_SetError("No joystick available with that index"); + return (NULL); +} + +/* Function to open a joystick for use. + The joystick to open is specified by the index field of the joystick. + This should fill the nbuttons and naxes fields of the joystick structure. + It returns 0, or -1 if there is an error. + */ +int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) +{ + joystick->nbuttons=6; + joystick->nhats=0; + joystick->nballs=0; + joystick->naxes=2; + return 0; +} + +/* Function to update the state of a joystick - called as a device poll. + * This function shouldn't update the joystick structure directly, + * but instead should call SDL_PrivateJoystick*() to deliver events + * and update joystick device state. + */ +void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick) +{ + short x=0,y=0; + if(!(GBA_JOYPAD&(1< +#include +// +// v1.41 - Put received keyboard & file data in separate buffers +// +// MB v1.41 or later pc software is required to use this library +// software. +// +// NOTE: THIS LIBRARY USES GLOBAL INITIALIZED DATA SO YOU MUST USE +// A CRT0.S AND A LINKER SCRIPT THAT SUPPORTS THIS AS WELL. GET +// CRTLS V1.1 OR LATER FROM HTTP://www.devrs.com/gba FOR PROPER SUPPORT. +// +// The following library functions are supported: +// +// Library name Standard Name Function +// dprintf printf Print a string on PC console. +// dputchar putchar Print a char on PC console. +// dgetch getch Get a char from PC keyboard. +// dkbhit kbhit Return 1 if PC keyboard char is ready. +// +// dfopen fopen Open PC file. +// dfclose fclose Close PC file. +// dfprintf fprintf Print a string to PC file. +// dfgetc fgetc Get char from PC file. +// dfputc fputc Write a char to PC file. +// drewind rewind Set file pointer to start of file. +// +// If you wish to use the standard naming conventions +// rather than the library names then change "__ANSI_NAMES 0" +// to "__ANSI_NAMES 1" instead. +// +// Notes: +// +// Currently only ONE file may be open at a time. +// +// If you are sending raw binary data to a PC file, use +// dfputc instead of dfprintf. Dfprintf will insert +// carriage return characters before linefeed characters +// on the PC side if the PC console software is running on +// dos/windows for proper text formatting. +// +// If you are missing some .h files during compile than get +// 'arminc.zip' from http://www.devrs.com/gba in the +// Apps / C Compilers section. +// +// Example command line: +// mb -s file.mb -c -w 50 -x 255 -m +// +// In this example, after transferring "file.mb" to the GBA, +// the PC goes into console/file server mode (-c) and also +// shows all of the file open/file close/fgetc/fputc commands +// (-m) on screen. The -w value should be a large enough value +// where the -s is reliable and the -x value should be a large +// enough value where the -c is reliable with the GBA. +// +// [Sending a file & console mode each have +// their own delay settings because they +// each use a different method for transferring +// data. Each method is about ideal for it's +// application.] +// +// Example GBA Code: +// +// #include "mbv2lib.c" +// +// int main (void) +// { +// +// int i,j,k; +// FILE* fp; +// +// dprintf ("Hello world!"); +// +// // Get character from PC keyboard +// i = dgetch (); +// +// // Copy SRAM to PC +// fp = dfopen("sram.bin","wb"); +// for (i = 0; i != 0x8000; i++) +// dfputc(*(unsigned char *)(i + 0xE000000), fp); +// dfclose(fp); +// +// // Read data from file +// fp = dfopen ("foo.bin", "rb"); +// i = dfgetc (fp); +// j = dfgetc (fp); +// k = dfgetc (fp); +// dfclose (fp); +// +// } + +// Data transfer format +// -------------------- +// +// PC -> GBA Comms: +// Raw data is PC File read data. +// ESCCHR 0x00 = nada (used for input polling) +// ESCCHR 0x01 = Escape character from PC file read +// ESCCHR 0x08 0x?? = Keyboard read data +// +// +// GBA -> PC comms +// Raw data is console print data. +// ESCCHR = escape sequence +// ESCCHR 0x00 = nada (used for input polling) +// ESCCHR 0x01 = Escape character for console print +// ESCCHR 0x02 = file open (gba -> PC) +// ESCCHR 0x03 = file close (gba -> PC) +// ESCCHR 0x04 = fgetc (gba -> PC) +// ESCCHR 0x05 0x?? = fputc (gba -> PC) +// ESCCHR 0x06 = rewind (gba -> PC) +// ESCCHR 0x07 = fputc processed (gba -> pC) (Add CR before LF char if win/DOS machine) + +// Uncomment the following line to define the following types if needed +#define INC_SHORT_NAME_TYPES 1 + +#ifdef INC_SHORT_NAME_TYPES + typedef volatile unsigned char vu8; + typedef volatile unsigned short int vu16; + typedef volatile unsigned int vu32; + typedef volatile unsigned long long int vu64; + + typedef unsigned char u8; + typedef unsigned short int u16; + typedef unsigned int u32; + typedef unsigned long long int u64; + + typedef signed char s8; + typedef signed short int s16; + typedef signed int s32; + typedef signed long long int s64; +#endif + +#define INC_REG_DEFS +#ifdef INC_REG_DEFS + #define REG_BASE 0x4000000 + #define REG_SIOCNT (REG_BASE + 0x128) // Serial Communication Control + #define REG_SIODATA8 (REG_BASE + 0x12a) // 8bit Serial Communication Data + #define REG_RCNT (REG_BASE + 0x134) // General Input/Output Control +#endif + +#define __FINBUFSIZE 256 //Must be a multiple of 2! (ex: 32,64,128,256,512..) +#define __KINBUFSIZE 64 //Must be a multiple of 2! (ex: 32,64,128,256,512..) +#define __ESCCHR 27 + +#define __ESC_NADA 0 +#define __ESC_ESCCHR 1 +#define __ESC_FOPEN 2 +#define __ESC_FCLOSE 3 +#define __ESC_FGETC 4 +#define __ESC_FPUTC 5 +#define __ESC_REWIND 6 +#define __ESC_FPUTC_PROCESSED 7 // PC side add CR before LF if DOS machine +#define __ESC_KBDCHR 8 + +#define FILEHANDLE (0xdeadd00d) // This is less likely to clash with stdout/stderr than 1 + +unsigned char __outstr[__DOUTBUFSIZE]; +unsigned char __finstr[__FINBUFSIZE]; +unsigned char __kinstr[__KINBUFSIZE]; +int finptr = 0; +int foutptr = 0; +int kinptr = 0; +int koutptr = 0; + +int __debug_shutup=0; + +int __dputchar (int c) +{ +if(!__debug_shutup) + { + int rcv; + static int LastChar = 0; + static int KbdCharNext = 0; + + // Set non-general purpose comms mode + *(u16 *)REG_RCNT = 0; + + // Init normal comms, 8 bit transfer, receive clocking + *(u16 *)REG_SIODATA8 = c; + *(u16 *)REG_SIOCNT = 0x80; + + // Wait until transfer is complete + while (*(vu16 *)REG_SIOCNT & 0x80) {} + + // Wait until SC is low + while (*(vu16 *)REG_RCNT & 1) {} + + // Force SD high + *(u16 *)REG_RCNT = 0x8022; + + // Wait until SC is high + while ((*(vu16 *)REG_RCNT & 1)==0) {} + + rcv = *(vu16 *)REG_SIODATA8; + + if (KbdCharNext) + { + // Put into keyboard buffer + __kinstr[kinptr++] = rcv; + kinptr &= (__KINBUFSIZE-1); + + KbdCharNext = 0; + + // Make received char look like a NADA character + // so that it won't be buffered elsewhere. + LastChar = __ESCCHR; + rcv = __ESC_NADA; + } + + if (LastChar == __ESCCHR) + { + // Process escape character + switch (rcv) + { + case __ESC_ESCCHR: + __finstr[finptr++] = __ESCCHR; + finptr &= (__FINBUFSIZE-1); + break; + case __ESC_KBDCHR: + KbdCharNext = 1; + break; + } + LastChar = 0; + } + else + { + if (rcv == __ESCCHR) + LastChar = __ESCCHR; + else + { + // If char received from PC then save in receive FIFO + __finstr[finptr++] = rcv; + finptr &= (__FINBUFSIZE-1); + } + } + return(1); + } +} + +int dputchar (int c) + { + (void) __dputchar(c); + if (c == __ESCCHR) + (void) __dputchar(__ESC_ESCCHR); + return (1); + } + +void __PrintStr (char *str) + { + while (*str) + (void) dputchar(*str++); + } + +int dgetch (void) + { + int c; + + // If no character is in FIFO then wait for one. + while (kinptr == koutptr) + { + __dputchar(__ESCCHR); + __dputchar(__ESC_NADA); + } + + c = __kinstr[koutptr++]; + koutptr &= (__KINBUFSIZE-1); + + return (c); + } + +int dfgetch (void) + { + int c; + + // If no character is in FIFO then wait for one. + while (finptr == foutptr) + { + __dputchar(__ESCCHR); + __dputchar(__ESC_NADA); + } + + c = __finstr[foutptr++]; + foutptr &= (__FINBUFSIZE-1); + + return (c); + } + +int dfread (void* ptr, size_t size, size_t nmemb, FILE* stream) +{ + int i; + for(i=0;i #include +#include "SDL.h" #include "SDL_error.h" #include "SDL_mutex.h" #include "SDL_thread.h" diff -ruN SDL-1.2.3.orig/src/timer/Makefile.am SDL-1.2.3/src/timer/Makefile.am --- SDL-1.2.3.orig/src/timer/Makefile.am Tue Sep 11 22:38:49 2001 +++ SDL-1.2.3/src/timer/Makefile.am Wed Jan 9 21:21:58 2002 @@ -6,6 +6,7 @@ ARCH_SUBDIRS = $(srcdir)/amigaos \ $(srcdir)/beos \ $(srcdir)/epoc \ + $(srcdir)/gba \ $(srcdir)/linux \ $(srcdir)/macos \ $(srcdir)/win32 diff -ruN SDL-1.2.3.orig/src/timer/SDL_timer.c SDL-1.2.3/src/timer/SDL_timer.c --- SDL-1.2.3.orig/src/timer/SDL_timer.c Thu Apr 26 18:50:18 2001 +++ SDL-1.2.3/src/timer/SDL_timer.c Wed Jan 9 21:19:03 2002 @@ -30,6 +30,7 @@ #include #include /* For the definition of NULL */ +#include "SDL.h" #include "SDL_error.h" #include "SDL_timer.h" #include "SDL_timer_c.h" diff -ruN SDL-1.2.3.orig/src/timer/gba/SDL_systimer.c SDL-1.2.3/src/timer/gba/SDL_systimer.c --- SDL-1.2.3.orig/src/timer/gba/SDL_systimer.c Thu Jan 1 01:00:00 1970 +++ SDL-1.2.3/src/timer/gba/SDL_systimer.c Wed Jan 9 21:19:03 2002 @@ -0,0 +1,80 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_systimer.c,v 1.2 2001/04/26 16:50:18 hercules Exp $"; +#endif + +#include "SDL_thread.h" +#include "SDL_timer.h" +#include "SDL_error.h" +#include "SDL_timer_c.h" + +#define GBA_TIMERBASE 0x4000100 +#define GBA_TIMER0 (*(volatile Uint16*)GBA_TIMERBASE) +#define GBA_TIMER0REG (*(volatile Uint16*)(0x4000102)) +#define GBA_TIMER1 (*(volatile Uint16*)(GBA_TIMERBASE+4)) +#define GBA_TIMER1REG (*(volatile Uint16*)(GBA_TIMERBASE+6)) +#define GBA_TIMER2 (*(volatile Uint16*)(GBA_TIMERBASE+8)) +#define GBA_TIMER2REG (*(volatile Uint16*)(GBA_TIMERBASE+10)) +#define GBA_TIMER3 (*(volatile Uint16*)(GBA_TIMERBASE+12)) +#define GBA_TIMER3REG (*(volatile Uint16*)(GBA_TIMERBASE+14)) + +#define timers2ms(tlow,thigh) ((tlow>>4)+(thigh<<12)) /* assuming 16384 Hz timer */ + +void SDL_StartTicks(void) +{ + GBA_TIMER0=0; + GBA_TIMER1=0; + GBA_TIMER1REG=(1<<7)|(1<<2); /* enable, cascade */ + GBA_TIMER0REG=(1<<7)|3; /* enable, 1/1024 CLK ~ 16376 Hz */ +} + +Uint32 SDL_GetTicks(void) +{ + return timers2ms(GBA_TIMER0, GBA_TIMER1); +} + +void SDL_Delay(Uint32 ms) +{ + int now; + now=timers2ms(GBA_TIMER0, GBA_TIMER1); + while(timers2ms(GBA_TIMER0,GBA_TIMER1) #include +#include "SDL.h" #include "SDL_types.h" #include "SDL_video.h" #include "SDL_error.h" diff -ruN SDL-1.2.3.orig/src/video/SDL_cursor.c SDL-1.2.3/src/video/SDL_cursor.c --- SDL-1.2.3.orig/src/video/SDL_cursor.c Wed Jul 18 22:08:18 2001 +++ SDL-1.2.3/src/video/SDL_cursor.c Wed Jan 9 21:19:03 2002 @@ -31,6 +31,7 @@ #include #include +#include "SDL.h" #include "SDL_mutex.h" #include "SDL_error.h" #include "SDL_video.h" @@ -177,6 +178,9 @@ SDL_VideoDevice *video = current_video; SDL_VideoDevice *this = current_video; + //FIXME + return; + /* Make sure that the video subsystem has been initialized */ if ( ! video ) { return; diff -ruN SDL-1.2.3.orig/src/video/SDL_gamma.c SDL-1.2.3/src/video/SDL_gamma.c --- SDL-1.2.3.orig/src/video/SDL_gamma.c Sat Aug 18 23:58:26 2001 +++ SDL-1.2.3/src/video/SDL_gamma.c Wed Jan 9 21:19:03 2002 @@ -35,6 +35,7 @@ #include #include +#include "SDL.h" #include "SDL_error.h" #include "SDL_sysvideo.h" diff -ruN SDL-1.2.3.orig/src/video/SDL_pixels.c SDL-1.2.3/src/video/SDL_pixels.c --- SDL-1.2.3.orig/src/video/SDL_pixels.c Thu Jun 7 17:04:04 2001 +++ SDL-1.2.3/src/video/SDL_pixels.c Wed Jan 9 21:19:03 2002 @@ -31,6 +31,7 @@ #include #include +#include "SDL.h" #include "SDL_error.h" #include "SDL_endian.h" #include "SDL_video.h" diff -ruN SDL-1.2.3.orig/src/video/SDL_surface.c SDL-1.2.3/src/video/SDL_surface.c --- SDL-1.2.3.orig/src/video/SDL_surface.c Tue Jul 31 07:36:10 2001 +++ SDL-1.2.3/src/video/SDL_surface.c Wed Jan 9 21:19:03 2002 @@ -29,6 +29,7 @@ #include #include +#include "SDL.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_sysvideo.h" diff -ruN SDL-1.2.3.orig/src/video/SDL_sysvideo.h SDL-1.2.3/src/video/SDL_sysvideo.h --- SDL-1.2.3.orig/src/video/SDL_sysvideo.h Tue Sep 11 22:38:49 2001 +++ SDL-1.2.3/src/video/SDL_sysvideo.h Wed Jan 9 21:19:03 2002 @@ -392,6 +392,9 @@ #ifdef ENABLE_DUMMYVIDEO extern VideoBootStrap DUMMY_bootstrap; #endif +#ifdef ENABLE_GBA +extern VideoBootStrap GBA_bootstrap; +#endif /* This is the current video device */ extern SDL_VideoDevice *current_video; diff -ruN SDL-1.2.3.orig/src/video/SDL_video.c SDL-1.2.3/src/video/SDL_video.c --- SDL-1.2.3.orig/src/video/SDL_video.c Sun Nov 4 05:18:27 2001 +++ SDL-1.2.3/src/video/SDL_video.c Wed Jan 9 21:19:03 2002 @@ -102,6 +102,9 @@ #ifdef ENABLE_EPOC &EPOC_bootstrap, #endif +#ifdef ENABLE_GBA + &GBA_bootstrap, +#endif #ifdef ENABLE_DUMMYVIDEO &DUMMY_bootstrap, #endif @@ -214,16 +217,18 @@ video->gl_config.accum_green_size = 0; video->gl_config.accum_blue_size = 0; video->gl_config.accum_alpha_size = 0; - /* Initialize the video subsystem */ memset(&vformat, 0, sizeof(vformat)); + printf("video->VideoInit\n"); if ( video->VideoInit(video, &vformat) < 0 ) { SDL_VideoQuit(); return(-1); } - + printf("v->VI: done\n"); + /* Create a zero sized video surface of the appropriate format */ video_flags = SDL_SWSURFACE; + printf("SDL_VideoSurface\n"); SDL_VideoSurface = SDL_CreateRGBSurface(video_flags, 0, 0, vformat.BitsPerPixel, vformat.Rmask, vformat.Gmask, vformat.Bmask, 0); @@ -231,6 +236,7 @@ SDL_VideoQuit(); return(-1); } + printf("SVS: done\n"); SDL_PublicSurface = NULL; /* Until SDL_SetVideoMode() */ #if 0 /* Don't change the current palette - may be used by other programs. @@ -248,12 +254,14 @@ video->info.vfmt = SDL_VideoSurface->format; /* Start the event loop */ + printf("SDL_StartEventLoop\n"); if ( SDL_StartEventLoop(flags) < 0 ) { SDL_VideoQuit(); return(-1); } + printf("SSEL: done, SDL_CursorInit\n"); SDL_CursorInit(flags & SDL_INIT_EVENTTHREAD); - + printf("SCI: done\n"); /* We're ready to go! */ return(0); } @@ -536,6 +544,7 @@ int is_opengl; SDL_GrabMode saved_grab; + printf("SDL_SetVideoMode: SDL_Init\n"); /* Start up the video driver, if necessary.. WARNING: This is the only function protected this way! */ @@ -544,6 +553,7 @@ return(NULL); } } + printf("done\n"); this = video = current_video; /* Default to the current video bpp */ @@ -556,9 +566,11 @@ video_w = width; video_h = height; video_bpp = bpp; + printf("SDL_GetVideoMode\n"); if ( ! SDL_GetVideoMode(&video_w, &video_h, &video_bpp, flags) ) { return(NULL); } + printf("done\n"); /* Check the requested flags */ /* There's no palette in > 8 bits-per-pixel mode */ @@ -583,7 +595,9 @@ } /* Reset the keyboard here so event callbacks can run */ + printf("SDL_ResetKeyboard\n"); SDL_ResetKeyboard(); + printf("done\n"); /* Clean up any previous video mode */ if ( SDL_PublicSurface != NULL ) { @@ -610,7 +624,9 @@ /* Try to set the video mode, along with offset and clipping */ prev_mode = SDL_VideoSurface; + printf("SDL_LockCursor\n"); SDL_LockCursor(); + printf("done\n"); SDL_VideoSurface = NULL; /* In case it's freed by driver */ mode = video->SetVideoMode(this, prev_mode,video_w,video_h,video_bpp,flags); if ( mode ) { /* Prevent resize events from mode change */ diff -ruN SDL-1.2.3.orig/src/video/SDL_yuv.c SDL-1.2.3/src/video/SDL_yuv.c --- SDL-1.2.3.orig/src/video/SDL_yuv.c Tue Jun 26 00:16:44 2001 +++ SDL-1.2.3/src/video/SDL_yuv.c Wed Jan 9 21:19:03 2002 @@ -30,6 +30,7 @@ #include #include +#include "SDL.h" #include "SDL_getenv.h" #include "SDL_video.h" #include "SDL_sysvideo.h" diff -ruN SDL-1.2.3.orig/src/video/SDL_yuv_sw.c SDL-1.2.3/src/video/SDL_yuv_sw.c --- SDL-1.2.3.orig/src/video/SDL_yuv_sw.c Fri Apr 27 22:25:25 2001 +++ SDL-1.2.3/src/video/SDL_yuv_sw.c Wed Jan 9 21:19:03 2002 @@ -90,6 +90,7 @@ #include #include +#include "SDL.h" #include "SDL_error.h" #include "SDL_video.h" #include "SDL_stretch_c.h" diff -ruN SDL-1.2.3.orig/src/video/gba/Makefile.am SDL-1.2.3/src/video/gba/Makefile.am --- SDL-1.2.3.orig/src/video/gba/Makefile.am Thu Jan 1 01:00:00 1970 +++ SDL-1.2.3/src/video/gba/Makefile.am Wed Jan 9 21:19:03 2002 @@ -0,0 +1,15 @@ + +## Makefile.am for SDL using the gba video driver + +noinst_LTLIBRARIES = libvideo_gba.la +libvideo_gba_la_SOURCES = $(NULL_SRCS) + +# The SDL gba video driver sources +NULL_SRCS = \ + SDL_gbavideo.h \ + SDL_gbaevents.c \ + SDL_gbaevents_c.h \ + SDL_gbamouse.c \ + SDL_gbamouse_c.h \ + SDL_gbavideo.c + diff -ruN SDL-1.2.3.orig/src/video/gba/SDL_gbaevents.c SDL-1.2.3/src/video/gba/SDL_gbaevents.c --- SDL-1.2.3.orig/src/video/gba/SDL_gbaevents.c Thu Jan 1 01:00:00 1970 +++ SDL-1.2.3/src/video/gba/SDL_gbaevents.c Wed Jan 9 21:19:03 2002 @@ -0,0 +1,80 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_gbaevents.c,v 1.1 2001/04/26 16:50:18 hercules Exp $"; +#endif + +/* Being a gba driver, there's no event stream. We just define stubs for + most of the API. */ + +#include "SDL.h" +#include "SDL_sysevents.h" +#include "SDL_events_c.h" +#include "SDL_gbavideo.h" +#include "SDL_gbaevents_c.h" + +static SDLKey keymap[GBA_NUMKEYS]; +char keymem[GBA_NUMKEYS]; /* memorize states of buttons */ + +void GBA_PumpEvents(_THIS) +{ + int i; + SDL_keysym keysym; + keysym.mod=KMOD_NONE; + for(i=0;i + +#include "SDL_error.h" +#include "SDL_mouse.h" +#include "SDL_events_c.h" + +#include "SDL_gbamouse_c.h" + + +/* The implementation dependent data for the window manager cursor */ +struct WMcursor { + int unused; +}; diff -ruN SDL-1.2.3.orig/src/video/gba/SDL_gbamouse_c.h SDL-1.2.3/src/video/gba/SDL_gbamouse_c.h --- SDL-1.2.3.orig/src/video/gba/SDL_gbamouse_c.h Thu Jan 1 01:00:00 1970 +++ SDL-1.2.3/src/video/gba/SDL_gbamouse_c.h Wed Jan 9 21:19:03 2002 @@ -0,0 +1,30 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_gbamouse_c.h,v 1.1 2001/04/26 16:50:18 hercules Exp $"; +#endif + +#include "SDL_gbavideo.h" + +/* Functions to be exported */ diff -ruN SDL-1.2.3.orig/src/video/gba/SDL_gbavideo.c SDL-1.2.3/src/video/gba/SDL_gbavideo.c --- SDL-1.2.3.orig/src/video/gba/SDL_gbavideo.c Thu Jan 1 01:00:00 1970 +++ SDL-1.2.3/src/video/gba/SDL_gbavideo.c Wed Jan 9 21:19:03 2002 @@ -0,0 +1,313 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_gbavideo.c,v 1.2 2001/07/02 00:20:29 hercules Exp $"; +#endif + +/* Dummy SDL video driver implementation; this is just enough to make an + * SDL-based application THINK it's got a working video driver, for + * applications that call SDL_Init(SDL_INIT_VIDEO) when they don't need it, + * and also for use as a collection of stubs when porting SDL to a new + * platform for which you haven't yet written a valid video driver. + * + * This is also a great way to determine bottlenecks: if you think that SDL + * is a performance problem for a given platform, enable this driver, and + * then see if your application runs faster without video overhead. + * + * Initial work by Ryan C. Gordon (icculus@linuxgames.com). A good portion + * of this was cut-and-pasted from Stephane Peter's work in the AAlib + * SDL video driver. Renamed to "DUMMY" by Sam Lantinga. + */ + +#include +#include + +#include "SDL.h" +#include "SDL_error.h" +#include "SDL_video.h" +#include "SDL_mouse.h" +#include "SDL_sysvideo.h" +#include "SDL_pixels_c.h" +#include "SDL_events_c.h" + +#include "SDL_gbavideo.h" +#include "SDL_gbaevents_c.h" +#include "SDL_gbamouse_c.h" + +#define GBAVID_DRIVER_NAME "gba" + +/* Initialization/Query functions */ +static int GBA_VideoInit(_THIS, SDL_PixelFormat *vformat); +static SDL_Rect **GBA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); +static SDL_Surface *GBA_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); +static int GBA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); +static void GBA_VideoQuit(_THIS); + +/* Hardware surface functions */ +static int GBA_AllocHWSurface(_THIS, SDL_Surface *surface); +static int GBA_LockHWSurface(_THIS, SDL_Surface *surface); +static int GBA_FlipHWSurface(_THIS, SDL_Surface *surface); +static void GBA_UnlockHWSurface(_THIS, SDL_Surface *surface); +static void GBA_FreeHWSurface(_THIS, SDL_Surface *surface); + +/* etc. */ +static void GBA_UpdateRects(_THIS, int numrects, SDL_Rect *rects); + +/* DUMMY driver bootstrap functions */ + +static int GBA_Available(void) +{ + return(1); +} + +static void GBA_DeleteDevice(SDL_VideoDevice *device) +{ + free(device->hidden); + free(device); +} + +static SDL_VideoDevice *GBA_CreateDevice(int devindex) +{ + SDL_VideoDevice *device=0; + + + /* Initialize all variables that we clean on shutdown */ + device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); + if ( device ) { + memset(device, 0, (sizeof *device)); + device->hidden = (struct SDL_PrivateVideoData *) + malloc((sizeof *device->hidden)); + } + if ( (device == NULL) || (device->hidden == NULL) ) { + SDL_OutOfMemory(); + if ( device ) { + free(device); + } + return(0); + } + memset(device->hidden, 0, (sizeof *device->hidden)); + + /* Set the function pointers */ + device->VideoInit = GBA_VideoInit; + device->ListModes = GBA_ListModes; + device->SetVideoMode = GBA_SetVideoMode; + device->CreateYUVOverlay = NULL; + device->SetColors = GBA_SetColors; + device->UpdateRects = GBA_UpdateRects; + device->VideoQuit = GBA_VideoQuit; + device->AllocHWSurface = GBA_AllocHWSurface; + device->CheckHWBlit = NULL; + device->FillHWRect = NULL; + device->SetHWColorKey = NULL; + device->SetHWAlpha = NULL; + device->LockHWSurface = GBA_LockHWSurface; + device->UnlockHWSurface = GBA_UnlockHWSurface; + device->FlipHWSurface = GBA_FlipHWSurface; + device->FreeHWSurface = GBA_FreeHWSurface; + device->SetCaption = NULL; + device->SetIcon = NULL; + device->IconifyWindow = NULL; + device->GrabInput = NULL; + device->GetWMInfo = NULL; + device->InitOSKeymap = GBA_InitOSKeymap; + device->PumpEvents = GBA_PumpEvents; + + device->free = GBA_DeleteDevice; + return device; +} + +VideoBootStrap GBA_bootstrap = { + GBAVID_DRIVER_NAME, "SDL GBA video driver", + GBA_Available, GBA_CreateDevice +}; + + +int GBA_VideoInit(_THIS, SDL_PixelFormat *vformat) +{ + printf("WARNING: You are using the SDL GBA video driver!\n"); + + /* Determine the screen depth (use default 8-bit depth) */ + /* we change this during the SDL_SetVideoMode implementation... */ + vformat->BitsPerPixel = 15; // mode 3 + vformat->BytesPerPixel = 2; + + /* We're done! */ + return(0); +} + +SDL_Rect **GBA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) +{ + return (SDL_Rect **) -1; +} + +SDL_Surface *GBA_SetVideoMode(_THIS, SDL_Surface *current, + int width, int height, int bpp, Uint32 flags) +{ + printf("GBA_SetVideoMode\n"); + if(width > 240 || height > 160 || bpp > 15) + return(NULL); + if(bpp <= 8) bpp=8; + else + if(bpp < 15) bpp=15; + if(width<=160) width=160; + else + if(width<240) width=240; + if(height<=128) height=128; + else + if(height<160) height=160; + + if(bpp==8) + { + if(width<240) width=240; + if(height<160) height=160; + this->hidden->gbamode=4; + } + + if(bpp==15) + { + if(width<240) this->hidden->gbamode=5; + else this->hidden->gbamode=3; + } + + this->hidden->buffer= GBA_VRAM_BASE; + + GBA_DISPCNT = GBA_DISP_MODE(this->hidden->gbamode)|GBA_DISP_BG2; + + printf("Setting mode %dx%d (gbamode %d)\n", width, height,this->hidden->gbamode); + + // FIXME: How do I tell that 15 bits mode is 555? + + memset(this->hidden->buffer, 0, width * height * ((this->hidden->gbamode==4 || this->hidden->gbamode==5) ? 2 : 1 ) * ((bpp+7) / 8)); + + /* Allocate the new pixel format for the screen */ + if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) { + this->hidden->buffer = NULL; + SDL_SetError("Couldn't allocate new pixel format for requested mode"); + return(NULL); + } + + /* Set up the new mode framebuffer */ + current->flags = flags | SDL_FULLSCREEN | SDL_HWSURFACE | (this->hidden->gbamode > 3 ? SDL_DOUBLEBUF : 0); + this->hidden->w = current->w = width; + this->hidden->h = current->h = height; + this->hidden->secondbufferallocd=0; + current->pitch = current->w * ((bpp+7) / 8); + current->pixels = this->hidden->buffer; + + /* We're done */ + return(current); +} + +static int GBA_AllocHWSurface(_THIS, SDL_Surface *surface) +{ + if(this->hidden->secondbufferallocd) { + printf("double double buffer alloc\n"); + return -1; + } + if(this->hidden->gbamode==3) + { + printf("no 2nd buffer in mode3\n"); + return -1; + } + this->hidden->secondbufferallocd=1; + surface->pitch = SDL_VideoSurface->pitch; + surface->flags |= SDL_HWSURFACE; + surface->pixels = GBA_VRAM_2NDBUF; + + return(0); +} +static void GBA_FreeHWSurface(_THIS, SDL_Surface *surface) +{ + this->hidden->secondbufferallocd=0; +} + +/* We need to wait for vertical retrace on page flipped displays */ +static int GBA_LockHWSurface(_THIS, SDL_Surface *surface) +{ + printf("GBA_LockHWSurface\n"); + while(GBA_SCANLINE<160); + return(0); +} + +static void GBA_UnlockHWSurface(_THIS, SDL_Surface *surface) +{ + return; +} + +static int GBA_FlipHWSurface(_THIS, SDL_Surface *surface) +{ + unsigned char buf; + + printf("GBA_FlipHWSurface\n"); + printf("ptr now: 0x%x\n",surface->pixels); + if(surface->pixels == GBA_VRAM_BASE) + { + surface->pixels = GBA_VRAM_2NDBUF; + buf=16; + } + else + { + surface->pixels = GBA_VRAM_BASE; + buf=0; + } + printf("ptr then: 0x%x\n",surface->pixels); + + printf("setting dispcnt to 0x%x\n",GBA_DISPCNT = GBA_DISP_MODE(this->hidden->gbamode)|GBA_DISP_BG2| buf); + return(0); +} + +static void GBA_UpdateRects(_THIS, int numrects, SDL_Rect *rects) +{ + /* do nothing. */ +} + +int GBA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) +{ + int i; + Uint16* fcp; + short r,g,b; + + if(this->hidden->gbamode != 4) + { + printf("This is not a palettized mode\n"); + return -1; + } + + fcp=GBA_BGPAL+firstcolor; + for(i=0;i>3; + g=colors[i].g>>3; + b=colors[i].b>>3; + fcp[i]=(r+(g<<5)+(b<<10)); + } + return(0); +} + +/* Note: If we are terminated, this could be called in the middle of + another SDL video routine -- notably UpdateRects. +*/ +void GBA_VideoQuit(_THIS) +{ +} diff -ruN SDL-1.2.3.orig/src/video/gba/SDL_gbavideo.h SDL-1.2.3/src/video/gba/SDL_gbavideo.h --- SDL-1.2.3.orig/src/video/gba/SDL_gbavideo.h Thu Jan 1 01:00:00 1970 +++ SDL-1.2.3/src/video/gba/SDL_gbavideo.h Wed Jan 9 21:19:03 2002 @@ -0,0 +1,65 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_gbavideo.h,v 1.1 2001/04/26 16:50:18 hercules Exp $"; +#endif + +#ifndef _SDL_gbavideo_h +#define _SDL_gbavideo_h + +#include "SDL_mouse.h" +#include "SDL_sysvideo.h" +#include "SDL_mutex.h" + +/* Hidden "this" pointer for the video functions */ +#define _THIS SDL_VideoDevice *this + + +/* Private display data */ + +struct SDL_PrivateVideoData { + int w, h; + void *buffer; + short gbamode; + short secondbufferallocd; +}; + +#define GBA_VIDC_BASE 0x4000000 +#define GBA_DISPCNT (*(volatile Uint32*)(GBA_VIDC_BASE)) +#define GBA_VIDC_SCANLINE (GBA_VIDC_BASE+6) +#define GBA_SCANLINE (*(volatile Uint8*)(GBA_VIDC_SCANLINE)) + +#define GBA_DISP_MODE(n) (n&7) +#define GBA_DISP_BG2 0x400 +#define GBA_DISP_FB 0x10 + +#define GBA_PAL_BASE 0x5000000 +#define GBA_BGPAL ((volatile Uint16*)(GBA_PAL_BASE)) +#define GBA_OBJPAL ((volatile Uint16*)(GBA_PAL_BASE+0x200)) + +#define GBA_VRAM_BASE 0x6000000 +#define GBA_VRAM_2NDBUF 0x600a000 +#define GBA_VRAM = ((volatile Uint16* )GBA_VRAM_BASE) + +#endif /* _SDL_gbavideo_h */ diff -ruN SDL-1.2.3.orig/src/vsprintf.c SDL-1.2.3/src/vsprintf.c --- SDL-1.2.3.orig/src/vsprintf.c Thu Jan 1 01:00:00 1970 +++ SDL-1.2.3/src/vsprintf.c Wed Jan 9 21:19:03 2002 @@ -0,0 +1,328 @@ +/* + * linux/lib/vsprintf.c + * + * Copyright (C) 1991, 1992 Linus Torvalds + */ + +/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ +/* + * Wirzenius wrote this portably, Torvalds fucked it up :-) + */ + +#include +//#include +#include +#include + +#include + +unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base) +{ + unsigned long result = 0,value; + + if (!base) { + base = 10; + if (*cp == '0') { + base = 8; + cp++; + if ((*cp == 'x') && isxdigit(cp[1])) { + cp++; + base = 16; + } + } + } + while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp) + ? toupper(*cp) : *cp)-'A'+10) < base) { + result = result*base + value; + cp++; + } + if (endp) + *endp = (char *)cp; + return result; +} + +long simple_strtol(const char *cp,char **endp,unsigned int base) +{ + if(*cp=='-') + return -simple_strtoul(cp+1,endp,base); + return simple_strtoul(cp,endp,base); +} + +/* we use this so that we can do without the ctype library */ +#define is_digit(c) ((c) >= '0' && (c) <= '9') + +static int skip_atoi(const char **s) +{ + int i=0; + + while (is_digit(**s)) + i = i*10 + *((*s)++) - '0'; + return i; +} + +#define ZEROPAD 1 /* pad with zero */ +#define SIGN 2 /* unsigned/signed long */ +#define PLUS 4 /* show plus */ +#define SPACE 8 /* space if plus */ +#define LEFT 16 /* left justified */ +#define SPECIAL 32 /* 0x */ +#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ + +#define do_div(n,base) ({ \ +int __res; \ +__res = ((unsigned long) n) % (unsigned) base; \ +n = ((unsigned long) n) / (unsigned) base; \ +__res; }) + +size_t dstrnlen (const char *s, size_t maxlen) + { + if (strlen(s) < maxlen) + return (strlen(s)); + else + return (maxlen); + } + +static char * number(char * str, long num, int base, int size, int precision + ,int type) +{ + char c,sign,tmp[66]; + const char *digits="0123456789abcdefghijklmnopqrstuvwxyz"; + int i; + + if (type & LARGE) + digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + if (type & LEFT) + type &= ~ZEROPAD; + if (base < 2 || base > 36) + return 0; + c = (type & ZEROPAD) ? '0' : ' '; + sign = 0; + if (type & SIGN) { + if (num < 0) { + sign = '-'; + num = -num; + size--; + } else if (type & PLUS) { + sign = '+'; + size--; + } else if (type & SPACE) { + sign = ' '; + size--; + } + } + if (type & SPECIAL) { + if (base == 16) + size -= 2; + else if (base == 8) + size--; + } + i = 0; + if (num == 0) + tmp[i++]='0'; + else while (num != 0) + tmp[i++] = digits[do_div(num,base)]; + if (i > precision) + precision = i; + size -= precision; + if (!(type&(ZEROPAD+LEFT))) + while(size-->0) + *str++ = ' '; + if (sign) + *str++ = sign; + if (type & SPECIAL) { + if (base==8) + *str++ = '0'; + else if (base==16) { + *str++ = '0'; + *str++ = digits[33]; + } + } + if (!(type & LEFT)) + while (size-- > 0) + *str++ = c; + while (i < precision--) + *str++ = '0'; + while (i-- > 0) + *str++ = tmp[i]; + while (size-- > 0) + *str++ = ' '; + return str; +} + +/* Forward decl. needed for IP address printing stuff... */ +int sprintf(char * buf, const char *fmt, ...); + +int vsprintf(char *buf, const char *fmt, va_list args) +{ + int len; + unsigned long num; + int i, base; + char * str; + const char *s; + + int flags; /* flags to number() */ + + int field_width; /* width of output field */ + int precision; /* min. # of digits for integers; max + number of chars for from string */ + int qualifier; /* 'h', 'l', or 'L' for integer fields */ + + for (str=buf ; *fmt ; ++fmt) { + if (*fmt != '%') { + *str++ = *fmt; + continue; + } + + /* process flags */ + flags = 0; + repeat: + ++fmt; /* this also skips first '%' */ + switch (*fmt) { + case '-': flags |= LEFT; goto repeat; + case '+': flags |= PLUS; goto repeat; + case ' ': flags |= SPACE; goto repeat; + case '#': flags |= SPECIAL; goto repeat; + case '0': flags |= ZEROPAD; goto repeat; + } + + /* get field width */ + field_width = -1; + if (is_digit(*fmt)) + field_width = skip_atoi(&fmt); + else if (*fmt == '*') { + ++fmt; + /* it's the next argument */ + field_width = va_arg(args, int); + if (field_width < 0) { + field_width = -field_width; + flags |= LEFT; + } + } + + /* get the precision */ + precision = -1; + if (*fmt == '.') { + ++fmt; + if (is_digit(*fmt)) + precision = skip_atoi(&fmt); + else if (*fmt == '*') { + ++fmt; + /* it's the next argument */ + precision = va_arg(args, int); + } + if (precision < 0) + precision = 0; + } + + /* get the conversion qualifier */ + qualifier = -1; + if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') { + qualifier = *fmt; + ++fmt; + } + + /* default base */ + base = 10; + + switch (*fmt) { + case 'c': + if (!(flags & LEFT)) + while (--field_width > 0) + *str++ = ' '; + *str++ = (unsigned char) va_arg(args, int); + while (--field_width > 0) + *str++ = ' '; + continue; + + case 's': + s = va_arg(args, char *); + if (!s) + s = ""; + + len = dstrnlen(s, precision); + + if (!(flags & LEFT)) + while (len < field_width--) + *str++ = ' '; + for (i = 0; i < len; ++i) + *str++ = *s++; + while (len < field_width--) + *str++ = ' '; + continue; + + case 'p': + if (field_width == -1) { + field_width = 2*sizeof(void *); + flags |= ZEROPAD; + } + str = number(str, + (unsigned long) va_arg(args, void *), 16, + field_width, precision, flags); + continue; + + + case 'n': + if (qualifier == 'l') { + long * ip = va_arg(args, long *); + *ip = (str - buf); + } else { + int * ip = va_arg(args, int *); + *ip = (str - buf); + } + continue; + + case '%': + *str++ = '%'; + continue; + + /* integer number formats - set up the flags and "break" */ + case 'o': + base = 8; + break; + + case 'X': + flags |= LARGE; + case 'x': + base = 16; + break; + + case 'd': + case 'i': + flags |= SIGN; + case 'u': + break; + + default: + *str++ = '%'; + if (*fmt) + *str++ = *fmt; + else + --fmt; + continue; + } + if (qualifier == 'l') + num = va_arg(args, unsigned long); + else if (qualifier == 'h') { + num = (unsigned short) va_arg(args, int); + if (flags & SIGN) + num = (short) num; + } else if (flags & SIGN) + num = va_arg(args, int); + else + num = va_arg(args, unsigned int); + str = number(str, num, base, field_width, precision, flags); + } + *str = '\0'; + return str-buf; +} + +int dsprintf(char * buf, const char *fmt, ...) +{ + va_list args; + int i; + + va_start(args, fmt); + i=vsprintf(buf,fmt,args); + va_end(args); + return i; +}