# HG changeset patch # User Sam Lantinga # Date 1148875475 0 # Node ID 4da1ee79c9af88bcab1bc128479a51c618eef67b # Parent 1fddae038bc8b0c6a2d24a459cab4acc7fd14ba2 more tweaking indent options diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL.h --- a/include/SDL.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL.h Mon May 29 04:04:35 2006 +0000 @@ -118,24 +118,24 @@ * Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup * signal handlers for some commonly ignored fatal signals (like SIGSEGV) */ -extern DECLSPEC int SDLCALL SDL_Init (Uint32 flags); +extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); /* This function initializes specific SDL subsystems */ -extern DECLSPEC int SDLCALL SDL_InitSubSystem (Uint32 flags); +extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); /* This function cleans up specific SDL subsystems */ -extern DECLSPEC void SDLCALL SDL_QuitSubSystem (Uint32 flags); +extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); /* This function returns mask of the specified subsystems which have been initialized. If 'flags' is 0, it returns a mask of all initialized subsystems. */ -extern DECLSPEC Uint32 SDLCALL SDL_WasInit (Uint32 flags); +extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); /* This function cleans up all initialized subsystems and unloads the * dynamically linked library. You should call it upon all exit conditions. */ -extern DECLSPEC void SDLCALL SDL_Quit (void); +extern DECLSPEC void SDLCALL SDL_Quit(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_audio.h --- a/include/SDL_audio.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_audio.h Mon May 29 04:04:35 2006 +0000 @@ -106,20 +106,20 @@ /* These functions return the list of built in video drivers, in the * order that they are normally initialized by default. */ -extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers (void); -extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver (int index); +extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void); +extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index); /* These functions are used internally, and should not be used unless you * have a specific need to specify the audio driver you want to use. * You should normally use SDL_Init() or SDL_InitSubSystem(). */ -extern DECLSPEC int SDLCALL SDL_AudioInit (const char *driver_name); -extern DECLSPEC void SDLCALL SDL_AudioQuit (void); +extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); +extern DECLSPEC void SDLCALL SDL_AudioQuit(void); /* This function returns the name of the current audio driver, or NULL * if no driver has been initialized. */ -extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver (void); +extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void); /* * This function opens the audio device with the desired parameters, and @@ -162,8 +162,8 @@ * may modify the requested size of the audio buffer, you should allocate * any local mixing buffers after you open the audio device. */ -extern DECLSPEC int SDLCALL SDL_OpenAudio (SDL_AudioSpec * desired, - SDL_AudioSpec * obtained); +extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired, + SDL_AudioSpec * obtained); /* * Get the current audio state: @@ -174,7 +174,7 @@ SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED } SDL_audiostatus; -extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus (void); +extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus(void); /* * This function pauses and unpauses the audio callback processing. @@ -183,7 +183,7 @@ * data for your callback function after opening the audio device. * Silence will be written to the audio device during the pause. */ -extern DECLSPEC void SDLCALL SDL_PauseAudio (int pause_on); +extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); /* * This function loads a WAVE from the data source, automatically freeing @@ -202,11 +202,11 @@ * wave file cannot be opened, uses an unknown data format, or is * corrupt. Currently raw and MS-ADPCM WAVE files are supported. */ -extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW (SDL_RWops * src, - int freesrc, - SDL_AudioSpec * spec, - Uint8 ** audio_buf, - Uint32 * audio_len); +extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src, + int freesrc, + SDL_AudioSpec * spec, + Uint8 ** audio_buf, + Uint32 * audio_len); /* Compatibility convenience function -- loads a WAV from a file */ #define SDL_LoadWAV(file, spec, audio_buf, audio_len) \ @@ -215,7 +215,7 @@ /* * This function frees data previously allocated with SDL_LoadWAV_RW() */ -extern DECLSPEC void SDLCALL SDL_FreeWAV (Uint8 * audio_buf); +extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf); /* * This function takes a source format and rate and a destination format @@ -224,13 +224,13 @@ * to the other. * This function returns 0, or -1 if there was an error. */ -extern DECLSPEC int SDLCALL SDL_BuildAudioCVT (SDL_AudioCVT * cvt, - Uint16 src_format, - Uint8 src_channels, - int src_rate, - Uint16 dst_format, - Uint8 dst_channels, - int dst_rate); +extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt, + Uint16 src_format, + Uint8 src_channels, + int src_rate, + Uint16 dst_format, + Uint8 dst_channels, + int dst_rate); /* Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(), * created an audio buffer cvt->buf, and filled it with cvt->len bytes of @@ -240,7 +240,7 @@ * cvt->buf should be allocated after the cvt structure is initialized by * SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long. */ -extern DECLSPEC int SDLCALL SDL_ConvertAudio (SDL_AudioCVT * cvt); +extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT * cvt); /* * This takes two audio buffers of the playing audio format and mixes @@ -250,8 +250,8 @@ * This is provided for convenience -- you can mix your own audio data. */ #define SDL_MIX_MAXVOLUME 128 -extern DECLSPEC void SDLCALL SDL_MixAudio (Uint8 * dst, const Uint8 * src, - Uint32 len, int volume); +extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src, + Uint32 len, int volume); /* * The lock manipulated by these functions protects the callback function. @@ -259,13 +259,13 @@ * callback function is not running. Do not call these from the callback * function or you will cause deadlock. */ -extern DECLSPEC void SDLCALL SDL_LockAudio (void); -extern DECLSPEC void SDLCALL SDL_UnlockAudio (void); +extern DECLSPEC void SDLCALL SDL_LockAudio(void); +extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); /* * This function shuts down audio processing and closes the audio device. */ -extern DECLSPEC void SDLCALL SDL_CloseAudio (void); +extern DECLSPEC void SDLCALL SDL_CloseAudio(void); /* Ends C function definitions when using C++ */ diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_cdrom.h --- a/include/SDL_cdrom.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_cdrom.h Mon May 29 04:04:35 2006 +0000 @@ -104,7 +104,7 @@ /* Returns the number of CD-ROM drives on the system, or -1 if SDL_Init() has not been called with the SDL_INIT_CDROM flag. */ -extern DECLSPEC int SDLCALL SDL_CDNumDrives (void); +extern DECLSPEC int SDLCALL SDL_CDNumDrives(void); /* Returns a human-readable, system-dependent identifier for the CD-ROM. Example: @@ -112,7 +112,7 @@ "E:" "/dev/disk/ide/1/master" */ -extern DECLSPEC const char *SDLCALL SDL_CDName (int drive); +extern DECLSPEC const char *SDLCALL SDL_CDName(int drive); /* Opens a CD-ROM drive for access. It returns a drive handle on success, or NULL if the drive was invalid or busy. This newly opened CD-ROM @@ -120,13 +120,13 @@ CD-ROM handle. Drives are numbered starting with 0. Drive 0 is the system default CD-ROM. */ -extern DECLSPEC SDL_CD *SDLCALL SDL_CDOpen (int drive); +extern DECLSPEC SDL_CD *SDLCALL SDL_CDOpen(int drive); /* This function returns the current status of the given drive. If the drive has a CD in it, the table of contents of the CD and current play position of the CD will be stored in the SDL_CD structure. */ -extern DECLSPEC CDstatus SDLCALL SDL_CDStatus (SDL_CD * cdrom); +extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD * cdrom); /* Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks' tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play @@ -147,31 +147,30 @@ This function returns 0, or -1 if there was an error. */ -extern DECLSPEC int SDLCALL SDL_CDPlayTracks (SDL_CD * cdrom, - int start_track, - int start_frame, int ntracks, - int nframes); +extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD * cdrom, + int start_track, + int start_frame, int ntracks, + int nframes); /* Play the given CD starting at 'start' frame for 'length' frames. It returns 0, or -1 if there was an error. */ -extern DECLSPEC int SDLCALL SDL_CDPlay (SDL_CD * cdrom, int start, - int length); +extern DECLSPEC int SDLCALL SDL_CDPlay(SDL_CD * cdrom, int start, int length); /* Pause play -- returns 0, or -1 on error */ -extern DECLSPEC int SDLCALL SDL_CDPause (SDL_CD * cdrom); +extern DECLSPEC int SDLCALL SDL_CDPause(SDL_CD * cdrom); /* Resume play -- returns 0, or -1 on error */ -extern DECLSPEC int SDLCALL SDL_CDResume (SDL_CD * cdrom); +extern DECLSPEC int SDLCALL SDL_CDResume(SDL_CD * cdrom); /* Stop play -- returns 0, or -1 on error */ -extern DECLSPEC int SDLCALL SDL_CDStop (SDL_CD * cdrom); +extern DECLSPEC int SDLCALL SDL_CDStop(SDL_CD * cdrom); /* Eject CD-ROM -- returns 0, or -1 on error */ -extern DECLSPEC int SDLCALL SDL_CDEject (SDL_CD * cdrom); +extern DECLSPEC int SDLCALL SDL_CDEject(SDL_CD * cdrom); /* Closes the handle for the CD-ROM drive */ -extern DECLSPEC void SDLCALL SDL_CDClose (SDL_CD * cdrom); +extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD * cdrom); /* Ends C function definitions when using C++ */ diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_compat.h --- a/include/SDL_compat.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_compat.h Mon May 29 04:04:35 2006 +0000 @@ -66,29 +66,28 @@ SDL_GRAB_ON = 1 } SDL_GrabMode; -extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version (void); -extern DECLSPEC char *SDLCALL SDL_AudioDriverName (char *namebuf, int maxlen); -extern DECLSPEC char *SDLCALL SDL_VideoDriverName (char *namebuf, int maxlen); -extern DECLSPEC int SDLCALL SDL_VideoModeOK (int width, int height, int bpp, - Uint32 flags); -extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes (SDL_PixelFormat * format, - Uint32 flags); -extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode (int width, int height, - int bpp, Uint32 flags); -extern DECLSPEC SDL_Surface *SDLCALL SDL_GetVideoSurface (void); -extern DECLSPEC void SDLCALL SDL_WM_SetCaption (const char *title, - const char *icon); -extern DECLSPEC void SDLCALL SDL_WM_GetCaption (char **title, char **icon); -extern DECLSPEC void SDLCALL SDL_WM_SetIcon (SDL_Surface * icon, - Uint8 * mask); -extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow (void); -extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen (SDL_Surface * surface); -extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput (SDL_GrabMode mode); -extern DECLSPEC Uint8 SDLCALL SDL_GetAppState (void); -extern DECLSPEC int SDLCALL SDL_SetPalette (SDL_Surface * surface, int flags, - SDL_Color * colors, - int firstcolor, int ncolors); -extern DECLSPEC int SDLCALL SDL_GetWMInfo (SDL_SysWMinfo * info); +extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void); +extern DECLSPEC char *SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen); +extern DECLSPEC char *SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen); +extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp, + Uint32 flags); +extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(SDL_PixelFormat * format, + Uint32 flags); +extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width, int height, + int bpp, Uint32 flags); +extern DECLSPEC SDL_Surface *SDLCALL SDL_GetVideoSurface(void); +extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, + const char *icon); +extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon); +extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask); +extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void); +extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface * surface); +extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode); +extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void); +extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface * surface, int flags, + SDL_Color * colors, + int firstcolor, int ncolors); +extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo * info); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_cpuinfo.h --- a/include/SDL_cpuinfo.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_cpuinfo.h Mon May 29 04:04:35 2006 +0000 @@ -41,35 +41,35 @@ /* This function returns true if the CPU has the RDTSC instruction */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC (void); +extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); /* This function returns true if the CPU has MMX features */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX (void); +extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); /* This function returns true if the CPU has MMX Ext. features */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt (void); +extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt(void); /* This function returns true if the CPU has 3DNow features */ -extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow (void); +extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); /* This function returns true if the CPU has 3DNow! Ext. features */ -extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt (void); +extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt(void); /* This function returns true if the CPU has SSE features */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE (void); +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); /* This function returns true if the CPU has SSE2 features */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2 (void); +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); /* This function returns true if the CPU has AltiVec features */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec (void); +extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_endian.h --- a/include/SDL_endian.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_endian.h Mon May 29 04:04:35 2006 +0000 @@ -64,37 +64,37 @@ #if defined(__GNUC__) && defined(__i386__) && \ !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */) static __inline__ Uint16 -SDL_Swap16 (Uint16 x) +SDL_Swap16(Uint16 x) { - __asm__ ("xchgb %b0,%h0": "=q" (x):"0" (x)); + __asm__("xchgb %b0,%h0": "=q"(x):"0"(x)); return x; } #elif defined(__GNUC__) && defined(__x86_64__) static __inline__ Uint16 -SDL_Swap16 (Uint16 x) +SDL_Swap16(Uint16 x) { - __asm__ ("xchgb %b0,%h0": "=Q" (x):"0" (x)); + __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x)); return x; } #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) static __inline__ Uint16 -SDL_Swap16 (Uint16 x) +SDL_Swap16(Uint16 x) { Uint16 result; - __asm__ ("rlwimi %0,%2,8,16,23": "=&r" (result):"0" (x >> 8), "r" (x)); + __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); return result; } #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) static __inline__ Uint16 -SDL_Swap16 (Uint16 x) +SDL_Swap16(Uint16 x) { - __asm__ ("rorw #8,%0": "=d" (x): "0" (x):"cc"); + __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc"); return x; } #else static __inline__ Uint16 -SDL_Swap16 (Uint16 x) +SDL_Swap16(Uint16 x) { return ((x << 8) | (x >> 8)); } @@ -102,40 +102,39 @@ #if defined(__GNUC__) && defined(__i386__) static __inline__ Uint32 -SDL_Swap32 (Uint32 x) +SDL_Swap32(Uint32 x) { - __asm__ ("bswap %0": "=r" (x):"0" (x)); + __asm__("bswap %0": "=r"(x):"0"(x)); return x; } #elif defined(__GNUC__) && defined(__x86_64__) static __inline__ Uint32 -SDL_Swap32 (Uint32 x) +SDL_Swap32(Uint32 x) { - __asm__ ("bswapl %0": "=r" (x):"0" (x)); + __asm__("bswapl %0": "=r"(x):"0"(x)); return x; } #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) static __inline__ Uint32 -SDL_Swap32 (Uint32 x) +SDL_Swap32(Uint32 x) { Uint32 result; - __asm__ ("rlwimi %0,%2,24,16,23": "=&r" (result):"0" (x >> 24), - "r" (x)); - __asm__ ("rlwimi %0,%2,8,8,15": "=&r" (result):"0" (result), "r" (x)); - __asm__ ("rlwimi %0,%2,24,0,7": "=&r" (result):"0" (result), "r" (x)); + __asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x)); + __asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x)); + __asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x)); return result; } #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) static __inline__ Uint32 -SDL_Swap32 (Uint32 x) +SDL_Swap32(Uint32 x) { - __asm__ ("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d" (x): "0" (x):"cc"); + __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc"); return x; } #else static __inline__ Uint32 -SDL_Swap32 (Uint32 x) +SDL_Swap32(Uint32 x) { return ((x << 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x >> 24)); @@ -145,7 +144,7 @@ #ifdef SDL_HAS_64BIT_TYPE #if defined(__GNUC__) && defined(__i386__) static __inline__ Uint64 -SDL_Swap64 (Uint64 x) +SDL_Swap64(Uint64 x) { union { @@ -156,21 +155,21 @@ Uint64 u; } v; v.u = x; - __asm__ ("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r" (v.s.a), "=r" (v.s.b):"0" (v.s.a), - "1" (v.s. - b)); + __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a), + "1"(v.s. + b)); return v.u; } #elif defined(__GNUC__) && defined(__x86_64__) static __inline__ Uint64 -SDL_Swap64 (Uint64 x) +SDL_Swap64(Uint64 x) { - __asm__ ("bswapq %0": "=r" (x):"0" (x)); + __asm__("bswapq %0": "=r"(x):"0"(x)); return x; } #else static __inline__ Uint64 -SDL_Swap64 (Uint64 x) +SDL_Swap64(Uint64 x) { Uint32 hi, lo; @@ -178,9 +177,9 @@ lo = (Uint32) (x & 0xFFFFFFFF); x >>= 32; hi = (Uint32) (x & 0xFFFFFFFF); - x = SDL_Swap32 (lo); + x = SDL_Swap32(lo); x <<= 32; - x |= SDL_Swap32 (hi); + x |= SDL_Swap32(hi); return (x); } #endif diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_error.h --- a/include/SDL_error.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_error.h Mon May 29 04:04:35 2006 +0000 @@ -39,9 +39,9 @@ #endif /* Public functions */ -extern DECLSPEC void SDLCALL SDL_SetError (const char *fmt, ...); -extern DECLSPEC char *SDLCALL SDL_GetError (void); -extern DECLSPEC void SDLCALL SDL_ClearError (void); +extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...); +extern DECLSPEC char *SDLCALL SDL_GetError(void); +extern DECLSPEC void SDLCALL SDL_ClearError(void); /* Private error message function - used internally */ #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) @@ -55,7 +55,7 @@ SDL_UNSUPPORTED, SDL_LASTERROR } SDL_errorcode; -extern DECLSPEC void SDLCALL SDL_Error (SDL_errorcode code); +extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code); /* Ends C function definitions when using C++ */ diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_events.h --- a/include/SDL_events.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_events.h Mon May 29 04:04:35 2006 +0000 @@ -89,28 +89,26 @@ #define SDL_EVENTMASK(X) (1<<(X)) typedef enum { - SDL_WINDOWEVENTMASK = SDL_EVENTMASK (SDL_WINDOWEVENT), - SDL_KEYDOWNMASK = SDL_EVENTMASK (SDL_KEYDOWN), - SDL_KEYUPMASK = SDL_EVENTMASK (SDL_KEYUP), - SDL_KEYEVENTMASK = SDL_EVENTMASK (SDL_KEYDOWN) | - SDL_EVENTMASK (SDL_KEYUP), - SDL_MOUSEMOTIONMASK = SDL_EVENTMASK (SDL_MOUSEMOTION), - SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK (SDL_MOUSEBUTTONDOWN), - SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK (SDL_MOUSEBUTTONUP), - SDL_MOUSEEVENTMASK = SDL_EVENTMASK (SDL_MOUSEMOTION) | - SDL_EVENTMASK (SDL_MOUSEBUTTONDOWN) | - SDL_EVENTMASK (SDL_MOUSEBUTTONUP), - SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK (SDL_JOYAXISMOTION), - SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK (SDL_JOYBALLMOTION), - SDL_JOYHATMOTIONMASK = SDL_EVENTMASK (SDL_JOYHATMOTION), - SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK (SDL_JOYBUTTONDOWN), - SDL_JOYBUTTONUPMASK = SDL_EVENTMASK (SDL_JOYBUTTONUP), - SDL_JOYEVENTMASK = SDL_EVENTMASK (SDL_JOYAXISMOTION) | - SDL_EVENTMASK (SDL_JOYBALLMOTION) | - SDL_EVENTMASK (SDL_JOYHATMOTION) | - SDL_EVENTMASK (SDL_JOYBUTTONDOWN) | SDL_EVENTMASK (SDL_JOYBUTTONUP), - SDL_QUITMASK = SDL_EVENTMASK (SDL_QUIT), - SDL_SYSWMEVENTMASK = SDL_EVENTMASK (SDL_SYSWMEVENT) + SDL_WINDOWEVENTMASK = SDL_EVENTMASK(SDL_WINDOWEVENT), + SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN), + SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP), + SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN) | SDL_EVENTMASK(SDL_KEYUP), + SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION), + SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN), + SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP), + SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION) | + SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN) | SDL_EVENTMASK(SDL_MOUSEBUTTONUP), + SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION), + SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_JOYBALLMOTION), + SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_JOYHATMOTION), + SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK(SDL_JOYBUTTONDOWN), + SDL_JOYBUTTONUPMASK = SDL_EVENTMASK(SDL_JOYBUTTONUP), + SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION) | + SDL_EVENTMASK(SDL_JOYBALLMOTION) | + SDL_EVENTMASK(SDL_JOYHATMOTION) | + SDL_EVENTMASK(SDL_JOYBUTTONDOWN) | SDL_EVENTMASK(SDL_JOYBUTTONUP), + SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT), + SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT) } SDL_EventMask; #define SDL_ALLEVENTS 0xFFFFFFFF @@ -299,7 +297,7 @@ This function updates the event queue and internal input device state. This should only be run in the thread that sets the video mode. */ -extern DECLSPEC void SDLCALL SDL_PumpEvents (void); +extern DECLSPEC void SDLCALL SDL_PumpEvents(void); /* Checks the event queue for messages and optionally returns them. If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to @@ -320,27 +318,27 @@ SDL_GETEVENT } SDL_eventaction; /* */ -extern DECLSPEC int SDLCALL SDL_PeepEvents (SDL_Event * events, int numevents, - SDL_eventaction action, - Uint32 mask); +extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents, + SDL_eventaction action, + Uint32 mask); /* Polls for currently pending events, and returns 1 if there are any pending events, or 0 if there are none available. If 'event' is not NULL, the next event is removed from the queue and stored in that area. */ -extern DECLSPEC int SDLCALL SDL_PollEvent (SDL_Event * event); +extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event); /* Waits indefinitely for the next available event, returning 1, or 0 if there was an error while waiting for events. If 'event' is not NULL, the next event is removed from the queue and stored in that area. */ -extern DECLSPEC int SDLCALL SDL_WaitEvent (SDL_Event * event); +extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event); /* Add an event to the event queue. This function returns 0 on success, or -1 if the event queue was full or there was some other error. */ -extern DECLSPEC int SDLCALL SDL_PushEvent (SDL_Event * event); +extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event); /* This function sets up a filter to process all events before they @@ -365,13 +363,13 @@ If the quit event is generated by an interrupt signal, it will bypass the internal queue and be delivered to the application at the next event poll. */ -extern DECLSPEC void SDLCALL SDL_SetEventFilter (SDL_EventFilter filter); +extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter); /* Return the current event filter - can be used to "chain" filters. If there is no event filter set, this function returns NULL. */ -extern DECLSPEC SDL_EventFilter SDLCALL SDL_GetEventFilter (void); +extern DECLSPEC SDL_EventFilter SDLCALL SDL_GetEventFilter(void); /* This function allows you to set the state of processing certain events. @@ -385,7 +383,7 @@ #define SDL_IGNORE 0 #define SDL_DISABLE 0 #define SDL_ENABLE 1 -extern DECLSPEC Uint8 SDLCALL SDL_EventState (Uint8 type, int state); +extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state); /* Ends C function definitions when using C++ */ diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_joystick.h --- a/include/SDL_joystick.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_joystick.h Mon May 29 04:04:35 2006 +0000 @@ -54,14 +54,14 @@ /* * Count the number of joysticks attached to the system */ -extern DECLSPEC int SDLCALL SDL_NumJoysticks (void); +extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); /* * Get the implementation dependent name of a joystick. * This can be called before any joysticks are opened. * If no name can be found, this function returns NULL. */ -extern DECLSPEC const char *SDLCALL SDL_JoystickName (int device_index); +extern DECLSPEC const char *SDLCALL SDL_JoystickName(int device_index); /* * Open a joystick for use - the index passed as an argument refers to @@ -70,46 +70,46 @@ * * This function returns a joystick identifier, or NULL if an error occurred. */ -extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen (int device_index); +extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index); /* * Returns 1 if the joystick has been opened, or 0 if it has not. */ -extern DECLSPEC int SDLCALL SDL_JoystickOpened (int device_index); +extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index); /* * Get the device index of an opened joystick. */ -extern DECLSPEC int SDLCALL SDL_JoystickIndex (SDL_Joystick * joystick); +extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick * joystick); /* * Get the number of general axis controls on a joystick */ -extern DECLSPEC int SDLCALL SDL_JoystickNumAxes (SDL_Joystick * joystick); +extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick); /* * Get the number of trackballs on a joystick * Joystick trackballs have only relative motion events associated * with them and their state cannot be polled. */ -extern DECLSPEC int SDLCALL SDL_JoystickNumBalls (SDL_Joystick * joystick); +extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick); /* * Get the number of POV hats on a joystick */ -extern DECLSPEC int SDLCALL SDL_JoystickNumHats (SDL_Joystick * joystick); +extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick); /* * Get the number of buttons on a joystick */ -extern DECLSPEC int SDLCALL SDL_JoystickNumButtons (SDL_Joystick * joystick); +extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick); /* * Update the current state of the open joysticks. * This is called automatically by the event loop if any joystick * events are enabled. */ -extern DECLSPEC void SDLCALL SDL_JoystickUpdate (void); +extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); /* * Enable/disable joystick event polling. @@ -118,15 +118,15 @@ * information. * The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE. */ -extern DECLSPEC int SDLCALL SDL_JoystickEventState (int state); +extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); /* * Get the current state of an axis control on a joystick * The state is a value ranging from -32768 to 32767. * The axis indices start at index 0. */ -extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis (SDL_Joystick * joystick, - int axis); +extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick, + int axis); /* * Get the current state of a POV hat on a joystick @@ -144,28 +144,28 @@ /* * The hat indices start at index 0. */ -extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat (SDL_Joystick * joystick, - int hat); +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick, + int hat); /* * Get the ball axis change since the last poll * This returns 0, or -1 if you passed it invalid parameters. * The ball indices start at index 0. */ -extern DECLSPEC int SDLCALL SDL_JoystickGetBall (SDL_Joystick * joystick, - int ball, int *dx, int *dy); +extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick, + int ball, int *dx, int *dy); /* * Get the current state of a button on a joystick * The button indices start at index 0. */ -extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton (SDL_Joystick * joystick, - int button); +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick, + int button); /* * Close a joystick previously opened with SDL_JoystickOpen() */ -extern DECLSPEC void SDLCALL SDL_JoystickClose (SDL_Joystick * joystick); +extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick); /* Ends C function definitions when using C++ */ diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_keyboard.h --- a/include/SDL_keyboard.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_keyboard.h Mon May 29 04:04:35 2006 +0000 @@ -77,7 +77,7 @@ * If 'enable' is -1, the translation state is not changed. * It returns the previous state of keyboard translation. */ -extern DECLSPEC int SDLCALL SDL_EnableUNICODE (int enable); +extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable); /* * Enable/Disable keyboard repeat. Keyboard repeat defaults to off. @@ -90,8 +90,8 @@ /* * If 'delay' is set to 0, keyboard repeat is disabled. */ -extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat (int delay, int interval); -extern DECLSPEC void SDLCALL SDL_GetKeyRepeat (int *delay, int *interval); +extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval); +extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval); /* * Get a snapshot of the current state of the keyboard. @@ -100,23 +100,23 @@ * Uint8 *keystate = SDL_GetKeyState(NULL); * if ( keystate[SDLK_RETURN] ) ... is pressed. */ -extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyState (int *numkeys); +extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyState(int *numkeys); /* * Get the current key modifier state */ -extern DECLSPEC SDLMod SDLCALL SDL_GetModState (void); +extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); /* * Set the current key modifier state * This does not change the keyboard state, only the key modifier flags. */ -extern DECLSPEC void SDLCALL SDL_SetModState (SDLMod modstate); +extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); /* * Get the name of an SDL virtual keysym */ -extern DECLSPEC char *SDLCALL SDL_GetKeyName (SDLKey key); +extern DECLSPEC char *SDLCALL SDL_GetKeyName(SDLKey key); /* Ends C function definitions when using C++ */ diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_loadso.h --- a/include/SDL_loadso.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_loadso.h Mon May 29 04:04:35 2006 +0000 @@ -57,17 +57,17 @@ * to the object handle (or NULL if there was an error). * The 'sofile' parameter is a system dependent name of the object file. */ -extern DECLSPEC void *SDLCALL SDL_LoadObject (const char *sofile); +extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile); /* Given an object handle, this function looks up the address of the * named function in the shared object and returns it. This address * is no longer valid after calling SDL_UnloadObject(). */ -extern DECLSPEC void *SDLCALL SDL_LoadFunction (void *handle, - const char *name); +extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle, + const char *name); /* Unload a shared object from memory */ -extern DECLSPEC void SDLCALL SDL_UnloadObject (void *handle); +extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_main.h --- a/include/SDL_main.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_main.h Mon May 29 04:04:35 2006 +0000 @@ -50,7 +50,7 @@ #define main SDL_main /* The prototype for the application's main() function */ -extern C_LINKAGE int SDL_main (int argc, char *argv[]); +extern C_LINKAGE int SDL_main(int argc, char *argv[]); /* From the SDL library code -- needed for registering the app on Win32 */ @@ -64,12 +64,12 @@ #endif /* This should be called from your WinMain() function, if any */ -extern DECLSPEC void SDLCALL SDL_SetModuleHandle (void *hInst); +extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst); /* This can also be called, but is no longer necessary */ -extern DECLSPEC int SDLCALL SDL_RegisterApp (char *name, Uint32 style, - void *hInst); +extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, + void *hInst); /* This can also be called, but is no longer necessary (SDL_Quit calls it) */ -extern DECLSPEC void SDLCALL SDL_UnregisterApp (void); +extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); #ifdef __cplusplus /* *INDENT-OFF* */ } @@ -92,7 +92,7 @@ struct QDGlobals; /* This should be called from your main() function, if any */ -extern DECLSPEC void SDLCALL SDL_InitQuickDraw (struct QDGlobals *the_qd); +extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd); #ifdef __cplusplus /* *INDENT-OFF* */ diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_mouse.h --- a/include/SDL_mouse.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_mouse.h Mon May 29 04:04:35 2006 +0000 @@ -59,7 +59,7 @@ * be tested using the SDL_BUTTON(X) macros, and x and y are set to the * current mouse cursor position. You can pass NULL for either x or y. */ -extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState (int *x, int *y); +extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y); /* * Retrieve the current state of the mouse. @@ -67,12 +67,12 @@ * be tested using the SDL_BUTTON(X) macros, and x and y are set to the * mouse deltas since the last call to SDL_GetRelativeMouseState(). */ -extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState (int *x, int *y); +extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); /* * Set the position of the mouse cursor (generates a mouse motion event) */ -extern DECLSPEC void SDLCALL SDL_WarpMouse (Uint16 x, Uint16 y); +extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y); /* * Create a cursor using the specified data and mask (in MSB format). @@ -95,17 +95,17 @@ * If the cursor is currently visible, the change will be immediately * represented on the display. */ -extern DECLSPEC void SDLCALL SDL_SetCursor (SDL_Cursor * cursor); +extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor); /* * Returns the currently active cursor. */ -extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor (void); +extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void); /* * Deallocates a cursor created with SDL_CreateCursor(). */ -extern DECLSPEC void SDLCALL SDL_FreeCursor (SDL_Cursor * cursor); +extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor); /* * Toggle whether or not the cursor is shown on the screen. @@ -114,7 +114,7 @@ * before the call, or 0 if it was not. You can query the current * state by passing a 'toggle' value of -1. */ -extern DECLSPEC int SDLCALL SDL_ShowCursor (int toggle); +extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); /* Used as a mask when testing buttons in buttonstate Button 1: Left mouse button diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_mutex.h --- a/include/SDL_mutex.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_mutex.h Mon May 29 04:04:35 2006 +0000 @@ -58,21 +58,21 @@ typedef struct SDL_mutex SDL_mutex; /* Create a mutex, initialized unlocked */ -extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex (void); +extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void); /* Lock the mutex (Returns 0, or -1 on error) */ #define SDL_LockMutex(m) SDL_mutexP(m) -extern DECLSPEC int SDLCALL SDL_mutexP (SDL_mutex * mutex); +extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex * mutex); /* Unlock the mutex (Returns 0, or -1 on error) It is an error to unlock a mutex that has not been locked by the current thread, and doing so results in undefined behavior. */ #define SDL_UnlockMutex(m) SDL_mutexV(m) -extern DECLSPEC int SDLCALL SDL_mutexV (SDL_mutex * mutex); +extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex * mutex); /* Destroy a mutex */ -extern DECLSPEC void SDLCALL SDL_DestroyMutex (SDL_mutex * mutex); +extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex); /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -84,21 +84,21 @@ typedef struct SDL_semaphore SDL_sem; /* Create a semaphore, initialized with value, returns NULL on failure. */ -extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore (Uint32 initial_value); +extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value); /* Destroy a semaphore */ -extern DECLSPEC void SDLCALL SDL_DestroySemaphore (SDL_sem * sem); +extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem); /* This function suspends the calling thread until the semaphore pointed * to by sem has a positive count. It then atomically decreases the semaphore * count. */ -extern DECLSPEC int SDLCALL SDL_SemWait (SDL_sem * sem); +extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem); /* Non-blocking variant of SDL_SemWait(), returns 0 if the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error. */ -extern DECLSPEC int SDLCALL SDL_SemTryWait (SDL_sem * sem); +extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem); /* Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in @@ -106,15 +106,15 @@ On some platforms this function is implemented by looping with a delay of 1 ms, and so should be avoided if possible. */ -extern DECLSPEC int SDLCALL SDL_SemWaitTimeout (SDL_sem * sem, Uint32 ms); +extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms); /* Atomically increases the semaphore's count (not blocking), returns 0, or -1 on error. */ -extern DECLSPEC int SDLCALL SDL_SemPost (SDL_sem * sem); +extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem); /* Returns the current count of the semaphore */ -extern DECLSPEC Uint32 SDLCALL SDL_SemValue (SDL_sem * sem); +extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem); /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -126,27 +126,27 @@ typedef struct SDL_cond SDL_cond; /* Create a condition variable */ -extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond (void); +extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void); /* Destroy a condition variable */ -extern DECLSPEC void SDLCALL SDL_DestroyCond (SDL_cond * cond); +extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond); /* Restart one of the threads that are waiting on the condition variable, returns 0 or -1 on error. */ -extern DECLSPEC int SDLCALL SDL_CondSignal (SDL_cond * cond); +extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond); /* Restart all threads that are waiting on the condition variable, returns 0 or -1 on error. */ -extern DECLSPEC int SDLCALL SDL_CondBroadcast (SDL_cond * cond); +extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond); /* Wait on the condition variable, unlocking the provided mutex. The mutex must be locked before entering this function! The mutex is re-locked once the condition variable is signaled. Returns 0 when it is signaled, or -1 on error. */ -extern DECLSPEC int SDLCALL SDL_CondWait (SDL_cond * cond, SDL_mutex * mut); +extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mut); /* Waits for at most 'ms' milliseconds, and returns 0 if the condition variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not @@ -154,9 +154,8 @@ On some platforms this function is implemented by looping with a delay of 1 ms, and so should be avoided if possible. */ -extern DECLSPEC int SDLCALL SDL_CondWaitTimeout (SDL_cond * cond, - SDL_mutex * mutex, - Uint32 ms); +extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond, + SDL_mutex * mutex, Uint32 ms); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_pixels.h --- a/include/SDL_pixels.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_pixels.h Mon May 29 04:04:35 2006 +0000 @@ -109,64 +109,64 @@ { SDL_PixelFormat_Unknown, SDL_PixelFormat_Index1LSB = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Index1, SDL_BitmapOrder_1234, 0, - 1, 0), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Index1, SDL_BitmapOrder_1234, 0, + 1, 0), SDL_PixelFormat_Index1MSB = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Index1, SDL_BitmapOrder_4321, 0, - 1, 0), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Index1, SDL_BitmapOrder_4321, 0, + 1, 0), SDL_PixelFormat_Index4LSB = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Index4, SDL_BitmapOrder_1234, 0, - 2, 0), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Index4, SDL_BitmapOrder_1234, 0, + 2, 0), SDL_PixelFormat_Index4MSB = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Index4, SDL_BitmapOrder_4321, 0, - 2, 0), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Index4, SDL_BitmapOrder_4321, 0, + 2, 0), SDL_PixelFormat_Index8 = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Index8, 0, 0, 8, 1), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Index8, 0, 0, 8, 1), SDL_PixelFormat_RGB332 = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed8, SDL_PackedOrder_XRGB, - SDL_PackedLayout_332, 8, 1), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed8, SDL_PackedOrder_XRGB, + SDL_PackedLayout_332, 8, 1), SDL_PixelFormat_RGB444 = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed16, SDL_PackedOrder_XRGB, - SDL_PackedLayout_4444, 12, 2), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed16, SDL_PackedOrder_XRGB, + SDL_PackedLayout_4444, 12, 2), SDL_PixelFormat_RGB555 = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed16, SDL_PackedOrder_XRGB, - SDL_PackedLayout_1555, 15, 2), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed16, SDL_PackedOrder_XRGB, + SDL_PackedLayout_1555, 15, 2), SDL_PixelFormat_ARGB4444 = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed16, SDL_PackedOrder_ARGB, - SDL_PackedLayout_4444, 16, 2), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed16, SDL_PackedOrder_ARGB, + SDL_PackedLayout_4444, 16, 2), SDL_PixelFormat_ARGB1555 = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed16, SDL_PackedOrder_ARGB, - SDL_PackedLayout_1555, 16, 2), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed16, SDL_PackedOrder_ARGB, + SDL_PackedLayout_1555, 16, 2), SDL_PixelFormat_RGB565 = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed16, SDL_PackedOrder_XRGB, - SDL_PackedLayout_565, 16, 2), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed16, SDL_PackedOrder_XRGB, + SDL_PackedLayout_565, 16, 2), SDL_PixelFormat_RGB24 = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_ArrayU8, SDL_ArrayOrder_RGB, 0, - 24, 3), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_ArrayU8, SDL_ArrayOrder_RGB, 0, + 24, 3), SDL_PixelFormat_BGR24 = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_ArrayU8, SDL_ArrayOrder_BGR, 0, - 24, 3), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_ArrayU8, SDL_ArrayOrder_BGR, 0, + 24, 3), SDL_PixelFormat_RGB888 = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_XRGB, - SDL_PackedLayout_8888, 24, 4), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed32, SDL_PackedOrder_XRGB, + SDL_PackedLayout_8888, 24, 4), SDL_PixelFormat_BGR888 = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_XBGR, - SDL_PackedLayout_8888, 24, 4), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed32, SDL_PackedOrder_XBGR, + SDL_PackedLayout_8888, 24, 4), SDL_PixelFormat_ARGB8888 = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_ARGB, - SDL_PackedLayout_8888, 32, 4), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed32, SDL_PackedOrder_ARGB, + SDL_PackedLayout_8888, 32, 4), SDL_PixelFormat_RGBA8888 = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_RGBA, - SDL_PackedLayout_8888, 32, 4), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed32, SDL_PackedOrder_RGBA, + SDL_PackedLayout_8888, 32, 4), SDL_PixelFormat_ABGR8888 = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_ABGR, - SDL_PackedLayout_8888, 32, 4), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed32, SDL_PackedOrder_ABGR, + SDL_PackedLayout_8888, 32, 4), SDL_PixelFormat_BGRA8888 = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_BGRA, - SDL_PackedLayout_8888, 32, 4), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed32, SDL_PackedOrder_BGRA, + SDL_PackedLayout_8888, 32, 4), SDL_PixelFormat_ARGB2101010 = - SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_ARGB, - SDL_PackedLayout_2101010, 32, 4), + SDL_DEFINE_PIXELFORMAT(SDL_PixelType_Packed32, SDL_PackedOrder_ARGB, + SDL_PackedLayout_2101010, 32, 4), }; typedef struct SDL_Color @@ -213,19 +213,19 @@ * Convert one of the enumerated formats above to a bpp and RGBA masks. * Returns SDL_TRUE, or SDL_FALSE if the conversion wasn't possible. */ -extern DECLSPEC SDL_bool SDL_PixelFormatEnumToMasks (Uint32 format, int *bpp, - Uint32 * Rmask, - Uint32 * Gmask, - Uint32 * Bmask, - Uint32 * Amask); +extern DECLSPEC SDL_bool SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, + Uint32 * Rmask, + Uint32 * Gmask, + Uint32 * Bmask, + Uint32 * Amask); /* * Convert a bpp and RGBA masks to one of the enumerated formats above. * Returns SDL_PixelFormat_Unknown if the conversion wasn't possible. */ -extern DECLSPEC Uint32 SDL_MasksToPixelFormatEnum (int bpp, Uint32 Rmask, - Uint32 Gmask, Uint32 Bmask, - Uint32 Amask); +extern DECLSPEC Uint32 SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, + Uint32 Gmask, Uint32 Bmask, + Uint32 Amask); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_rwops.h --- a/include/SDL_rwops.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_rwops.h Mon May 29 04:04:35 2006 +0000 @@ -102,19 +102,19 @@ /* Functions to create SDL_RWops structures from various data sources */ -extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile (const char *file, - const char *mode); +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, + const char *mode); #ifdef HAVE_STDIO_H -extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP (FILE * fp, int autoclose); +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp, int autoclose); #endif -extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem (void *mem, int size); -extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem (const void *mem, - int size); +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size); +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, + int size); -extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW (void); -extern DECLSPEC void SDLCALL SDL_FreeRW (SDL_RWops * area); +extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void); +extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); #define RW_SEEK_SET 0 /* Seek from the beginning of data */ #define RW_SEEK_CUR 1 /* Seek relative to current read point */ @@ -129,20 +129,20 @@ /* Read an item of the specified endianness and return in native format */ -extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16 (SDL_RWops * src); -extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16 (SDL_RWops * src); -extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32 (SDL_RWops * src); -extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32 (SDL_RWops * src); -extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64 (SDL_RWops * src); -extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64 (SDL_RWops * src); +extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src); +extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src); /* Write an item of native format to the specified endianness */ -extern DECLSPEC int SDLCALL SDL_WriteLE16 (SDL_RWops * dst, Uint16 value); -extern DECLSPEC int SDLCALL SDL_WriteBE16 (SDL_RWops * dst, Uint16 value); -extern DECLSPEC int SDLCALL SDL_WriteLE32 (SDL_RWops * dst, Uint32 value); -extern DECLSPEC int SDLCALL SDL_WriteBE32 (SDL_RWops * dst, Uint32 value); -extern DECLSPEC int SDLCALL SDL_WriteLE64 (SDL_RWops * dst, Uint64 value); -extern DECLSPEC int SDLCALL SDL_WriteBE64 (SDL_RWops * dst, Uint64 value); +extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value); +extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value); +extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value); +extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value); +extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value); +extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value); /* Ends C function definitions when using C++ */ diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_stdinc.h --- a/include/SDL_stdinc.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_stdinc.h Mon May 29 04:04:35 2006 +0000 @@ -141,14 +141,14 @@ #define SDL_COMPILE_TIME_ASSERT(name, x) \ typedef int SDL_dummy_ ## name[(x) * 2 - 1] #ifndef DOXYGEN_SHOULD_IGNORE_THIS -SDL_COMPILE_TIME_ASSERT (uint8, sizeof (Uint8) == 1); -SDL_COMPILE_TIME_ASSERT (sint8, sizeof (Sint8) == 1); -SDL_COMPILE_TIME_ASSERT (uint16, sizeof (Uint16) == 2); -SDL_COMPILE_TIME_ASSERT (sint16, sizeof (Sint16) == 2); -SDL_COMPILE_TIME_ASSERT (uint32, sizeof (Uint32) == 4); -SDL_COMPILE_TIME_ASSERT (sint32, sizeof (Sint32) == 4); -SDL_COMPILE_TIME_ASSERT (uint64, sizeof (Uint64) == 8); -SDL_COMPILE_TIME_ASSERT (sint64, sizeof (Sint64) == 8); +SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); +SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); +SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); +SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); +SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); +SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); +SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); +SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); #endif /* DOXYGEN_SHOULD_IGNORE_THIS */ /* Check to make sure enums are the size of ints, for structure packing. @@ -167,7 +167,7 @@ DUMMY_ENUM_VALUE } SDL_DUMMY_ENUM; -SDL_COMPILE_TIME_ASSERT (enum, sizeof (SDL_DUMMY_ENUM) == sizeof (int)); +SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); #endif /* DOXYGEN_SHOULD_IGNORE_THIS */ #include "begin_code.h" @@ -181,25 +181,25 @@ #ifdef HAVE_MALLOC #define SDL_malloc malloc #else -extern DECLSPEC void *SDLCALL SDL_malloc (size_t size); +extern DECLSPEC void *SDLCALL SDL_malloc(size_t size); #endif #ifdef HAVE_CALLOC #define SDL_calloc calloc #else -extern DECLSPEC void *SDLCALL SDL_calloc (size_t nmemb, size_t size); +extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size); #endif #ifdef HAVE_REALLOC #define SDL_realloc realloc #else -extern DECLSPEC void *SDLCALL SDL_realloc (void *mem, size_t size); +extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size); #endif #ifdef HAVE_FREE #define SDL_free free #else -extern DECLSPEC void SDLCALL SDL_free (void *mem); +extern DECLSPEC void SDLCALL SDL_free(void *mem); #endif #if defined(HAVE_ALLOCA) && !defined(alloca) @@ -215,9 +215,9 @@ # elif defined(__AIX__) #pragma alloca # elif defined(__MRC__) -void *alloca (unsigned); +void *alloca(unsigned); # else -char *alloca (); +char *alloca(); # endif #endif #ifdef HAVE_ALLOCA @@ -231,21 +231,21 @@ #ifdef HAVE_GETENV #define SDL_getenv getenv #else -extern DECLSPEC char *SDLCALL SDL_getenv (const char *name); +extern DECLSPEC char *SDLCALL SDL_getenv(const char *name); #endif #ifdef HAVE_PUTENV #define SDL_putenv putenv #else -extern DECLSPEC int SDLCALL SDL_putenv (const char *variable); +extern DECLSPEC int SDLCALL SDL_putenv(const char *variable); #endif #ifdef HAVE_QSORT #define SDL_qsort qsort #else -extern DECLSPEC void SDLCALL SDL_qsort (void *base, size_t nmemb, size_t size, - int (*compare) (const void *, - const void *)); +extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, + int (*compare) (const void *, + const void *)); #endif #ifdef HAVE_ABS @@ -272,7 +272,7 @@ #ifdef HAVE_MEMSET #define SDL_memset memset #else -extern DECLSPEC void *SDLCALL SDL_memset (void *dst, int c, size_t len); +extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len); #endif #define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x))) #define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x))) @@ -331,8 +331,8 @@ #elif defined(HAVE_BCOPY) #define SDL_memcpy(d, s, n) bcopy((s), (d), (n)) #else -extern DECLSPEC void *SDLCALL SDL_memcpy (void *dst, const void *src, - size_t len); +extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, + size_t len); #endif #endif @@ -379,8 +379,8 @@ } while(0) #endif #ifndef SDL_revcpy -extern DECLSPEC void *SDLCALL SDL_revcpy (void *dst, const void *src, - size_t len); +extern DECLSPEC void *SDLCALL SDL_revcpy(void *dst, const void *src, + size_t len); #endif #ifdef HAVE_MEMMOVE @@ -401,52 +401,52 @@ #ifdef HAVE_MEMCMP #define SDL_memcmp memcmp #else -extern DECLSPEC int SDLCALL SDL_memcmp (const void *s1, const void *s2, - size_t len); +extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, + size_t len); #endif #ifdef HAVE_STRLEN #define SDL_strlen strlen #else -extern DECLSPEC size_t SDLCALL SDL_strlen (const char *string); +extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string); #endif #ifdef HAVE_STRLCPY #define SDL_strlcpy strlcpy #else -extern DECLSPEC size_t SDLCALL SDL_strlcpy (char *dst, const char *src, - size_t maxlen); +extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, + size_t maxlen); #endif #ifdef HAVE_STRLCAT #define SDL_strlcat strlcat #else -extern DECLSPEC size_t SDLCALL SDL_strlcat (char *dst, const char *src, - size_t maxlen); +extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, + size_t maxlen); #endif #ifdef HAVE_STRDUP #define SDL_strdup strdup #else -extern DECLSPEC char *SDLCALL SDL_strdup (const char *string); +extern DECLSPEC char *SDLCALL SDL_strdup(const char *string); #endif #ifdef HAVE__STRREV #define SDL_strrev _strrev #else -extern DECLSPEC char *SDLCALL SDL_strrev (char *string); +extern DECLSPEC char *SDLCALL SDL_strrev(char *string); #endif #ifdef HAVE__STRUPR #define SDL_strupr _strupr #else -extern DECLSPEC char *SDLCALL SDL_strupr (char *string); +extern DECLSPEC char *SDLCALL SDL_strupr(char *string); #endif #ifdef HAVE__STRLWR #define SDL_strlwr _strlwr #else -extern DECLSPEC char *SDLCALL SDL_strlwr (char *string); +extern DECLSPEC char *SDLCALL SDL_strlwr(char *string); #endif #ifdef HAVE_STRCHR @@ -454,7 +454,7 @@ #elif defined(HAVE_INDEX) #define SDL_strchr index #else -extern DECLSPEC char *SDLCALL SDL_strchr (const char *string, int c); +extern DECLSPEC char *SDLCALL SDL_strchr(const char *string, int c); #endif #ifdef HAVE_STRRCHR @@ -462,14 +462,14 @@ #elif defined(HAVE_RINDEX) #define SDL_strrchr rindex #else -extern DECLSPEC char *SDLCALL SDL_strrchr (const char *string, int c); +extern DECLSPEC char *SDLCALL SDL_strrchr(const char *string, int c); #endif #ifdef HAVE_STRSTR #define SDL_strstr strstr #else -extern DECLSPEC char *SDLCALL SDL_strstr (const char *haystack, - const char *needle); +extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, + const char *needle); #endif #ifdef HAVE_ITOA @@ -481,7 +481,7 @@ #ifdef HAVE__LTOA #define SDL_ltoa _ltoa #else -extern DECLSPEC char *SDLCALL SDL_ltoa (long value, char *string, int radix); +extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *string, int radix); #endif #ifdef HAVE__UITOA @@ -493,22 +493,22 @@ #ifdef HAVE__ULTOA #define SDL_ultoa _ultoa #else -extern DECLSPEC char *SDLCALL SDL_ultoa (unsigned long value, char *string, - int radix); +extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *string, + int radix); #endif #ifdef HAVE_STRTOL #define SDL_strtol strtol #else -extern DECLSPEC long SDLCALL SDL_strtol (const char *string, char **endp, - int base); +extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, + int base); #endif #ifdef HAVE_STRTOUL #define SDL_strtoul strtoul #else -extern DECLSPEC unsigned long SDLCALL SDL_strtoul (const char *string, - char **endp, int base); +extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, + char **endp, int base); #endif #ifdef SDL_HAS_64BIT_TYPE @@ -516,29 +516,29 @@ #ifdef HAVE__I64TOA #define SDL_lltoa _i64toa #else -extern DECLSPEC char *SDLCALL SDL_lltoa (Sint64 value, char *string, - int radix); +extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *string, + int radix); #endif #ifdef HAVE__UI64TOA #define SDL_ulltoa _ui64toa #else -extern DECLSPEC char *SDLCALL SDL_ulltoa (Uint64 value, char *string, - int radix); +extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *string, + int radix); #endif #ifdef HAVE_STRTOLL #define SDL_strtoll strtoll #else -extern DECLSPEC Sint64 SDLCALL SDL_strtoll (const char *string, char **endp, - int base); +extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, + int base); #endif #ifdef HAVE_STRTOULL #define SDL_strtoull strtoull #else -extern DECLSPEC Uint64 SDLCALL SDL_strtoull (const char *string, char **endp, - int base); +extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp, + int base); #endif #endif /* SDL_HAS_64BIT_TYPE */ @@ -546,7 +546,7 @@ #ifdef HAVE_STRTOD #define SDL_strtod strtod #else -extern DECLSPEC double SDLCALL SDL_strtod (const char *string, char **endp); +extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp); #endif #ifdef HAVE_ATOI @@ -564,14 +564,14 @@ #ifdef HAVE_STRCMP #define SDL_strcmp strcmp #else -extern DECLSPEC int SDLCALL SDL_strcmp (const char *str1, const char *str2); +extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); #endif #ifdef HAVE_STRNCMP #define SDL_strncmp strncmp #else -extern DECLSPEC int SDLCALL SDL_strncmp (const char *str1, const char *str2, - size_t maxlen); +extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, + size_t maxlen); #endif #ifdef HAVE_STRCASECMP @@ -579,8 +579,8 @@ #elif defined(HAVE__STRICMP) #define SDL_strcasecmp _stricmp #else -extern DECLSPEC int SDLCALL SDL_strcasecmp (const char *str1, - const char *str2); +extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, + const char *str2); #endif #ifdef HAVE_STRNCASECMP @@ -588,29 +588,29 @@ #elif defined(HAVE__STRNICMP) #define SDL_strncasecmp _strnicmp #else -extern DECLSPEC int SDLCALL SDL_strncasecmp (const char *str1, - const char *str2, size_t maxlen); +extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, + const char *str2, size_t maxlen); #endif #ifdef HAVE_SSCANF #define SDL_sscanf sscanf #else -extern DECLSPEC int SDLCALL SDL_sscanf (const char *text, const char *fmt, - ...); +extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, + ...); #endif #ifdef HAVE_SNPRINTF #define SDL_snprintf snprintf #else -extern DECLSPEC int SDLCALL SDL_snprintf (char *text, size_t maxlen, - const char *fmt, ...); +extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, + const char *fmt, ...); #endif #ifdef HAVE_VSNPRINTF #define SDL_vsnprintf vsnprintf #else -extern DECLSPEC int SDLCALL SDL_vsnprintf (char *text, size_t maxlen, - const char *fmt, va_list ap); +extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, + const char *fmt, va_list ap); #endif /* The SDL implementation of iconv() returns these error codes */ @@ -623,25 +623,25 @@ #define SDL_iconv_t iconv_t #define SDL_iconv_open iconv_open #define SDL_iconv_close iconv_close -extern DECLSPEC size_t SDLCALL SDL_iconv (SDL_iconv_t cd, char **inbuf, - size_t * inbytesleft, char **outbuf, - size_t * outbytesleft); +extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf, + size_t * inbytesleft, char **outbuf, + size_t * outbytesleft); #else typedef struct _SDL_iconv_t *SDL_iconv_t; -extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open (const char *tocode, - const char *fromcode); -extern DECLSPEC int SDLCALL SDL_iconv_close (SDL_iconv_t cd); -extern DECLSPEC size_t SDLCALL SDL_iconv (SDL_iconv_t cd, char **inbuf, - size_t * inbytesleft, char **outbuf, - size_t * outbytesleft); +extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, + const char *fromcode); +extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); +extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, char **inbuf, + size_t * inbytesleft, char **outbuf, + size_t * outbytesleft); #endif /* This function converts a string between encodings in one pass, returning a string that must be freed with SDL_free() or NULL on error. */ -extern DECLSPEC char *SDLCALL SDL_iconv_string (const char *tocode, - const char *fromcode, - char *inbuf, - size_t inbytesleft); +extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode, + const char *fromcode, + char *inbuf, + size_t inbytesleft); #define SDL_iconv_utf8_ascii(S) SDL_iconv_string("ASCII", "UTF-8", S, SDL_strlen(S)+1) #define SDL_iconv_utf8_latin1(S) SDL_iconv_string("LATIN1", "UTF-8", S, SDL_strlen(S)+1) #define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1) diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_syswm.h --- a/include/SDL_syswm.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_syswm.h Mon May 29 04:04:35 2006 +0000 @@ -228,8 +228,8 @@ * if ( SDL_GetWindowWMInfo(&info) ) { ... } * \endcode */ -extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo (SDL_WindowID windowID, - SDL_SysWMinfo * info); +extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_WindowID windowID, + SDL_SysWMinfo * info); /* Ends C function definitions when using C++ */ diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_thread.h --- a/include/SDL_thread.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_thread.h Mon May 29 04:04:35 2006 +0000 @@ -82,21 +82,21 @@ *threadID); typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); #else -typedef uintptr_t (__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, - unsigned (__stdcall * - func) (void - *), - void *arg, unsigned, - unsigned *threadID); +typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, + unsigned (__stdcall * + func) (void + *), + void *arg, unsigned, + unsigned *threadID); typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); #endif -extern DECLSPEC SDL_Thread *SDLCALL SDL_CreateThread (int (*fn) (void *), - void *data, - pfnSDL_CurrentBeginThread - pfnBeginThread, - pfnSDL_CurrentEndThread - pfnEndThread); +extern DECLSPEC SDL_Thread *SDLCALL SDL_CreateThread(int (*fn) (void *), + void *data, + pfnSDL_CurrentBeginThread + pfnBeginThread, + pfnSDL_CurrentEndThread + pfnEndThread); #ifdef __OS2__ #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread) @@ -107,26 +107,25 @@ #endif #else extern DECLSPEC SDL_Thread *SDLCALL -SDL_CreateThread (int (SDLCALL * fn) (void *), void *data); +SDL_CreateThread(int (SDLCALL * fn) (void *), void *data); #endif /* Get the 32-bit thread identifier for the current thread */ -extern DECLSPEC Uint32 SDLCALL SDL_ThreadID (void); +extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void); /* Get the 32-bit thread identifier for the specified thread, equivalent to SDL_ThreadID() if the specified thread is NULL. */ -extern DECLSPEC Uint32 SDLCALL SDL_GetThreadID (SDL_Thread * thread); +extern DECLSPEC Uint32 SDLCALL SDL_GetThreadID(SDL_Thread * thread); /* Wait for a thread to finish. The return code for the thread function is placed in the area pointed to by 'status', if 'status' is not NULL. */ -extern DECLSPEC void SDLCALL SDL_WaitThread (SDL_Thread * thread, - int *status); +extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread * thread, int *status); /* Forcefully kill a thread without worrying about its state */ -extern DECLSPEC void SDLCALL SDL_KillThread (SDL_Thread * thread); +extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread * thread); /* Ends C function definitions when using C++ */ diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_timer.h --- a/include/SDL_timer.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_timer.h Mon May 29 04:04:35 2006 +0000 @@ -49,13 +49,13 @@ /* Get the number of milliseconds since the SDL library initialization. * Note that this value wraps if the program runs for more than ~49 days. */ -extern DECLSPEC Uint32 SDLCALL SDL_GetTicks (void); +extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); /* Wait a specified number of milliseconds before returning */ -extern DECLSPEC void SDLCALL SDL_Delay (Uint32 ms); +extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); /* Function prototype for the timer callback function */ -typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval); +typedef Uint32(SDLCALL * SDL_TimerCallback) (Uint32 interval); /* Set a callback to run after the specified number of milliseconds has * elapsed. The callback function is passed the current timer interval @@ -85,8 +85,8 @@ * * This function returns 0 if successful, or -1 if there was an error. */ -extern DECLSPEC int SDLCALL SDL_SetTimer (Uint32 interval, - SDL_TimerCallback callback); +extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, + SDL_TimerCallback callback); /* New timer API, supports multiple timers * Written by Stephane Peter @@ -98,8 +98,7 @@ * passed in, the periodic alarm continues, otherwise a new alarm is * scheduled. If the callback returns 0, the periodic alarm is cancelled. */ -typedef Uint32 (SDLCALL * SDL_NewTimerCallback) (Uint32 interval, - void *param); +typedef Uint32(SDLCALL * SDL_NewTimerCallback) (Uint32 interval, void *param); /* Definition of the timer ID type */ typedef struct _SDL_TimerID *SDL_TimerID; @@ -107,14 +106,14 @@ /* Add a new timer to the pool of timers already running. Returns a timer ID, or NULL when an error occurs. */ -extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer (Uint32 interval, - SDL_NewTimerCallback - callback, void *param); +extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, + SDL_NewTimerCallback + callback, void *param); /* Remove one of the multiple timers knowing its ID. * Returns a boolean value indicating success. */ -extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer (SDL_TimerID t); +extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_version.h --- a/include/SDL_version.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_version.h Mon May 29 04:04:35 2006 +0000 @@ -129,7 +129,7 @@ * * \sa SDL_VERSION */ -extern DECLSPEC void SDLCALL SDL_GetVersion (SDL_version * ver); +extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff -r 1fddae038bc8 -r 4da1ee79c9af include/SDL_video.h --- a/include/SDL_video.h Mon May 29 03:53:21 2006 +0000 +++ b/include/SDL_video.h Mon May 29 04:04:35 2006 +0000 @@ -285,7 +285,7 @@ * * \sa SDL_GetVideoDriver() */ -extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers (void); +extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void); /** * \fn const char *SDL_GetVideoDriver(int index) @@ -297,7 +297,7 @@ * * \sa SDL_GetNumVideoDrivers() */ -extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver (int index); +extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index); /** * \fn int SDL_VideoInit(const char *driver_name, Uint32 flags) @@ -315,8 +315,8 @@ * * \sa SDL_VideoQuit() */ -extern DECLSPEC int SDLCALL SDL_VideoInit (const char *driver_name, - Uint32 flags); +extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name, + Uint32 flags); /** * \fn void SDL_VideoQuit(void) @@ -327,7 +327,7 @@ * * \sa SDL_VideoInit() */ -extern DECLSPEC void SDLCALL SDL_VideoQuit (void); +extern DECLSPEC void SDLCALL SDL_VideoQuit(void); /** * \fn const char *SDL_GetCurrentVideoDriver(void) @@ -340,7 +340,7 @@ * \sa SDL_GetNumVideoDrivers() * \sa SDL_GetVideoDriver() */ -extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver (void); +extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void); /** * \fn const SDL_VideoInfo *SDL_GetVideoInfo(void) @@ -350,7 +350,7 @@ * \return A read-only pointer to information about the video hardware, * or NULL if no video driver has been initialized. */ -extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo (void); +extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void); /** * \fn int SDL_GetNumVideoDisplays(void) @@ -359,7 +359,7 @@ * * \sa SDL_SelectVideoDisplay() */ -extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays (void); +extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void); /** * \fn int SDL_SelectVideoDisplay(int index) @@ -370,7 +370,7 @@ * * \sa SDL_GetNumVideoDisplays() */ -extern DECLSPEC int SDLCALL SDL_SelectVideoDisplay (int index); +extern DECLSPEC int SDLCALL SDL_SelectVideoDisplay(int index); /** * \fn int SDL_GetNumDisplayModes(void) @@ -379,7 +379,7 @@ * * \sa SDL_GetDisplayMode() */ -extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes (void); +extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(void); /** * \fn const SDL_DisplayMode *SDL_GetDisplayMode(int index) @@ -394,7 +394,7 @@ * * \sa SDL_GetNumDisplayModes() */ -extern DECLSPEC const SDL_DisplayMode *SDLCALL SDL_GetDisplayMode (int index); +extern DECLSPEC const SDL_DisplayMode *SDLCALL SDL_GetDisplayMode(int index); /** * \fn const SDL_DisplayMode *SDL_GetDesktopDisplayMode(void) @@ -402,7 +402,7 @@ * \brief Retrieve information about the desktop display mode for the current display. */ extern DECLSPEC const SDL_DisplayMode *SDLCALL -SDL_GetDesktopDisplayMode (void); +SDL_GetDesktopDisplayMode(void); /** * \fn const SDL_DisplayMode *SDL_GetCurrentDisplayMode(void) @@ -410,7 +410,7 @@ * \brief Retrieve information about the current display mode. */ extern DECLSPEC const SDL_DisplayMode *SDLCALL -SDL_GetCurrentDisplayMode (void); +SDL_GetCurrentDisplayMode(void); /** * \fn SDL_DisplayMode *SDL_GetClosestDisplayMode(const SDL_DisplayMode *mode, SDL_DisplayMode *closest) @@ -427,12 +427,11 @@ * \sa SDL_GetNumDisplayModes() * \sa SDL_GetDisplayMode() */ -extern DECLSPEC SDL_DisplayMode *SDLCALL SDL_GetClosestDisplayMode (const - SDL_DisplayMode - * mode, - SDL_DisplayMode - * - closest); +extern DECLSPEC SDL_DisplayMode *SDLCALL SDL_GetClosestDisplayMode(const + SDL_DisplayMode + * mode, + SDL_DisplayMode + * closest); /** * \fn int SDL_SetDisplayMode(const SDL_DisplayMode *mode) @@ -443,7 +442,7 @@ * * \return 0 on success, or -1 if setting the display mode failed. */ -extern DECLSPEC int SDLCALL SDL_SetDisplayMode (const SDL_DisplayMode * mode); +extern DECLSPEC int SDLCALL SDL_SetDisplayMode(const SDL_DisplayMode * mode); /** * \fn SDL_WindowID SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) @@ -463,9 +462,9 @@ * * \sa SDL_DestroyWindow() */ -extern DECLSPEC SDL_WindowID SDLCALL SDL_CreateWindow (const char *title, - int x, int y, int w, - int h, Uint32 flags); +extern DECLSPEC SDL_WindowID SDLCALL SDL_CreateWindow(const char *title, + int x, int y, int w, + int h, Uint32 flags); /** * \fn SDL_WindowID SDL_CreateWindowFrom(void *data) @@ -480,14 +479,14 @@ * * \sa SDL_DestroyWindow() */ -extern DECLSPEC SDL_WindowID SDLCALL SDL_CreateWindowFrom (void *data); +extern DECLSPEC SDL_WindowID SDLCALL SDL_CreateWindowFrom(void *data); /** * \fn Uint32 SDL_GetWindowFlags(SDL_WindowID windowID) * * \brief Get the window flags. */ -extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags (SDL_WindowID windowID); +extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_WindowID windowID); /** * \fn void SDL_SetWindowTitle(SDL_WindowID windowID, const char *title) @@ -496,8 +495,8 @@ * * \sa SDL_GetWindowTitle() */ -extern DECLSPEC void SDLCALL SDL_SetWindowTitle (SDL_WindowID windowID, - const char *title); +extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_WindowID windowID, + const char *title); /** * \fn const char *SDL_GetWindowTitle(SDL_WindowID windowID) @@ -506,8 +505,7 @@ * * \sa SDL_SetWindowTitle() */ -extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle (SDL_WindowID - windowID); +extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_WindowID windowID); /** * \fn void SDL_SetWindowIcon(SDL_Surface *icon) @@ -518,7 +516,7 @@ * * FIXME: The icon needs to be set before the window is first shown. Should some icon representation be part of the window creation data? */ -extern DECLSPEC void SDLCALL SDL_SetWindowIcon (SDL_Surface * icon); +extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Surface * icon); /** * \fn void SDL_SetWindowData(SDL_WindowID windowID, void *userdata) @@ -527,8 +525,8 @@ * * \sa SDL_GetWindowData() */ -extern DECLSPEC void SDLCALL SDL_SetWindowData (SDL_WindowID windowID, - void *userdata); +extern DECLSPEC void SDLCALL SDL_SetWindowData(SDL_WindowID windowID, + void *userdata); /** * \fn void *SDL_GetWindowData(SDL_WindowID windowID) @@ -537,7 +535,7 @@ * * \sa SDL_SetWindowData() */ -extern DECLSPEC void *SDLCALL SDL_GetWindowData (SDL_WindowID windowID); +extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_WindowID windowID); /** * \fn void SDL_SetWindowPosition(SDL_WindowID windowID, int x, int y) @@ -546,8 +544,8 @@ * * \sa SDL_GetWindowPosition() */ -extern DECLSPEC void SDLCALL SDL_SetWindowPosition (SDL_WindowID windowID, - int x, int y); +extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_WindowID windowID, + int x, int y); /** * \fn void SDL_GetWindowPosition(SDL_WindowID windowID, int *x, int *y) @@ -556,8 +554,8 @@ * * \sa SDL_SetWindowPosition() */ -extern DECLSPEC void SDLCALL SDL_GetWindowPosition (SDL_WindowID windowID, - int *x, int *y); +extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_WindowID windowID, + int *x, int *y); /** * \fn void SDL_SetWindowSize(SDL_WindowID windowID, int w, int w) @@ -569,8 +567,8 @@ * * \sa SDL_GetWindowSize() */ -extern DECLSPEC void SDLCALL SDL_SetWindowSize (SDL_WindowID windowID, int w, - int h); +extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_WindowID windowID, int w, + int h); /** * \fn void SDL_GetWindowSize(SDL_WindowID windowID, int *w, int *w) @@ -579,8 +577,8 @@ * * \sa SDL_SetWindowSize() */ -extern DECLSPEC void SDLCALL SDL_GetWindowSize (SDL_WindowID windowID, int *w, - int *h); +extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_WindowID windowID, int *w, + int *h); /** * \fn void SDL_ShowWindow(SDL_WindowID windowID) @@ -589,7 +587,7 @@ * * \sa SDL_HideWindow() */ -extern DECLSPEC void SDLCALL SDL_ShowWindow (SDL_WindowID windowID); +extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_WindowID windowID); /** * \fn void SDL_HideWindow(SDL_WindowID windowID) @@ -598,14 +596,14 @@ * * \sa SDL_ShowWindow() */ -extern DECLSPEC void SDLCALL SDL_HideWindow (SDL_WindowID windowID); +extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_WindowID windowID); /** * \fn void SDL_RaiseWindow(SDL_WindowID windowID) * * \brief Raise the window so it's above other windows. */ -extern DECLSPEC void SDLCALL SDL_RaiseWindow (SDL_WindowID windowID); +extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_WindowID windowID); /** * \fn void SDL_MaximizeWindow(SDL_WindowID windowID) @@ -614,7 +612,7 @@ * * \sa SDL_RestoreWindow() */ -extern DECLSPEC void SDLCALL SDL_MaximizeWindow (SDL_WindowID windowID); +extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_WindowID windowID); /** * \fn void SDL_MinimizeWindow(SDL_WindowID windowID) @@ -623,7 +621,7 @@ * * \sa SDL_RestoreWindow() */ -extern DECLSPEC void SDLCALL SDL_MinimizeWindow (SDL_WindowID windowID); +extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_WindowID windowID); /** * \fn void SDL_RestoreWindow(SDL_WindowID windowID) @@ -633,7 +631,7 @@ * \sa SDL_MaximizeWindow() * \sa SDL_MinimizeWindow() */ -extern DECLSPEC void SDLCALL SDL_RestoreWindow (SDL_WindowID windowID); +extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_WindowID windowID); /** * \fn void SDL_SetWindowGrab(SDL_WindowID windowID, int mode) @@ -645,8 +643,8 @@ * \sa SDL_GrabMode * \sa SDL_GetWindowGrab() */ -extern DECLSPEC void SDLCALL SDL_SetWindowGrab (SDL_WindowID windowID, - int mode); +extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_WindowID windowID, + int mode); /** * \fn int SDL_GetWindowGrab(SDL_WindowID windowID) @@ -658,24 +656,24 @@ * \sa SDL_GrabMode * \sa SDL_SetWindowGrab() */ -extern DECLSPEC int SDLCALL SDL_GetWindowGrab (SDL_WindowID windowID); +extern DECLSPEC int SDLCALL SDL_GetWindowGrab(SDL_WindowID windowID); /** * \fn void SDL_DestroyWindow(SDL_WindowID windowID) * * \brief Destroy a window. */ -extern DECLSPEC void SDLCALL SDL_DestroyWindow (SDL_WindowID windowID); +extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_WindowID windowID); /** * \fn SDL_Surface *SDL_CreateWindowSurface (SDL_WindowID windowID, Uint32 format, Uint32 flags) * * \brief Create an SDL_Surface representing the drawing area of the window. */ -extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateWindowSurface (SDL_WindowID - windowID, - Uint32 format, - Uint32 flags); +extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateWindowSurface(SDL_WindowID + windowID, + Uint32 format, + Uint32 flags); /* * Makes sure the given list of rectangles is updated on the given screen. @@ -698,7 +696,7 @@ * setting the video mode for this function to perform hardware flipping. * This function returns 0 if successful, or -1 if there was an error. */ -extern DECLSPEC int SDLCALL SDL_Flip (SDL_Surface * screen); +extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface * screen); /* * Set the gamma correction for each of the color channels. @@ -708,7 +706,7 @@ * be emulated using gamma ramps, if available. If successful, this * function returns 0, otherwise it returns -1. */ -extern DECLSPEC int SDLCALL SDL_SetGamma (float red, float green, float blue); +extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue); /* * Set the gamma translation table for the red, green, and blue channels @@ -722,9 +720,9 @@ * hardware does not support gamma translation, or otherwise fails, * this function will return -1. */ -extern DECLSPEC int SDLCALL SDL_SetGammaRamp (const Uint16 * red, - const Uint16 * green, - const Uint16 * blue); +extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 * red, + const Uint16 * green, + const Uint16 * blue); /* * Retrieve the current values of the gamma translation tables. @@ -735,8 +733,8 @@ * hardware does not support gamma translation, or otherwise fails, * this function will return -1. */ -extern DECLSPEC int SDLCALL SDL_GetGammaRamp (Uint16 * red, Uint16 * green, - Uint16 * blue); +extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 * red, Uint16 * green, + Uint16 * blue); /* * Sets a portion of the colormap for the given 8-bit surface. If 'surface' @@ -753,9 +751,9 @@ * you desire, even if the window colormap has to be warped or run under * emulation. */ -extern DECLSPEC int SDLCALL SDL_SetColors (SDL_Surface * surface, - SDL_Color * colors, int firstcolor, - int ncolors); +extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface * surface, + SDL_Color * colors, int firstcolor, + int ncolors); /* * Maps an RGB triple to an opaque pixel value for a given pixel format @@ -766,22 +764,22 @@ /* * Maps an RGBA quadruple to a pixel value for a given pixel format */ -extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA (SDL_PixelFormat * format, - Uint8 r, Uint8 g, Uint8 b, - Uint8 a); +extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(SDL_PixelFormat * format, + Uint8 r, Uint8 g, Uint8 b, + Uint8 a); /* * Maps a pixel value into the RGB components for a given pixel format */ -extern DECLSPEC void SDLCALL SDL_GetRGB (Uint32 pixel, SDL_PixelFormat * fmt, - Uint8 * r, Uint8 * g, Uint8 * b); +extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, SDL_PixelFormat * fmt, + Uint8 * r, Uint8 * g, Uint8 * b); /* * Maps a pixel value into the RGBA components for a given pixel format */ -extern DECLSPEC void SDLCALL SDL_GetRGBA (Uint32 pixel, SDL_PixelFormat * fmt, - Uint8 * r, Uint8 * g, Uint8 * b, - Uint8 * a); +extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat * fmt, + Uint8 * r, Uint8 * g, Uint8 * b, + Uint8 * a); /* * Allocate and free an RGB surface (must be called after SDL_SetVideoMode) @@ -821,16 +819,16 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface (Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); -extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom (void *pixels, - int width, - int height, - int depth, - int pitch, - Uint32 Rmask, - Uint32 Gmask, - Uint32 Bmask, - Uint32 Amask); -extern DECLSPEC void SDLCALL SDL_FreeSurface (SDL_Surface * surface); +extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, + int width, + int height, + int depth, + int pitch, + Uint32 Rmask, + Uint32 Gmask, + Uint32 Bmask, + Uint32 Amask); +extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface); /* * SDL_LockSurface() sets up a surface for directly accessing the pixels. @@ -850,8 +848,8 @@ * * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. */ -extern DECLSPEC int SDLCALL SDL_LockSurface (SDL_Surface * surface); -extern DECLSPEC void SDLCALL SDL_UnlockSurface (SDL_Surface * surface); +extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface); +extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface); /* * Load a surface from a seekable SDL data source (memory or file.) @@ -859,8 +857,8 @@ * Returns the new surface, or NULL if there was an error. * The new surface should be freed with SDL_FreeSurface(). */ -extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW (SDL_RWops * src, - int freesrc); +extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src, + int freesrc); /* Convenience macro -- load a surface from a file */ #define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) @@ -904,8 +902,8 @@ * * The 'alpha' parameter is ignored for surfaces that have an alpha channel. */ -extern DECLSPEC int SDLCALL SDL_SetAlpha (SDL_Surface * surface, Uint32 flag, - Uint8 alpha); +extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, + Uint8 alpha); /* * Sets the clipping rectangle for the destination surface in a blit. @@ -919,16 +917,16 @@ * Note that blits are automatically clipped to the edges of the source * and destination surfaces. */ -extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect (SDL_Surface * surface, - const SDL_Rect * rect); +extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface, + const SDL_Rect * rect); /* * Gets the clipping rectangle for the destination surface in a blit. * 'rect' must be a pointer to a valid rectangle which will be filled * with the correct values. */ -extern DECLSPEC void SDLCALL SDL_GetClipRect (SDL_Surface * surface, - SDL_Rect * rect); +extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface, + SDL_Rect * rect); /* * Creates a new surface of the specified format, and then copies and maps @@ -1052,8 +1050,7 @@ * * If the conversion fails or runs out of memory, it returns NULL */ -extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormat (SDL_Surface * - surface); +extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormat(SDL_Surface * surface); /* * This function takes a surface and copies it to a new surface of the @@ -1067,8 +1064,8 @@ * * If the conversion fails or runs out of memory, it returns NULL */ -extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormatAlpha (SDL_Surface * - surface); +extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormatAlpha(SDL_Surface * + surface); /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -1080,15 +1077,15 @@ the contents of the display surface underneath the area where the overlay is shown is undefined - it may be overwritten with the converted YUV data. */ -extern DECLSPEC SDL_Overlay *SDLCALL SDL_CreateYUVOverlay (int width, - int height, - Uint32 format, - SDL_Surface * - display); +extern DECLSPEC SDL_Overlay *SDLCALL SDL_CreateYUVOverlay(int width, + int height, + Uint32 format, + SDL_Surface * + display); /* Lock an overlay for direct access, and unlock it when you are done */ -extern DECLSPEC int SDLCALL SDL_LockYUVOverlay (SDL_Overlay * overlay); -extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay (SDL_Overlay * overlay); +extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay * overlay); +extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay * overlay); /* Blit a video overlay to the display surface. The contents of the video surface underneath the blit destination are @@ -1096,11 +1093,11 @@ The width and height of the destination rectangle may be different from that of the overlay, but currently only 2x scaling is supported. */ -extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay (SDL_Overlay * overlay, - SDL_Rect * dstrect); +extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay * overlay, + SDL_Rect * dstrect); /* Free a video overlay */ -extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay (SDL_Overlay * overlay); +extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay); /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -1113,17 +1110,17 @@ * If you do this, you need to retrieve all of the GL functions used in * your program from the dynamic library using SDL_GL_GetProcAddress(). */ -extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary (const char *path); +extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path); /* * Get the address of a GL function */ -extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress (const char *proc); +extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress(const char *proc); /* * Set an attribute of the OpenGL subsystem before window creation. */ -extern DECLSPEC int SDLCALL SDL_GL_SetAttribute (SDL_GLattr attr, int value); +extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value); /* * Get an attribute of the OpenGL subsystem from the windowing @@ -1134,18 +1131,18 @@ * Developers should track the values they pass into SDL_GL_SetAttribute * themselves if they want to retrieve these values. */ -extern DECLSPEC int SDLCALL SDL_GL_GetAttribute (SDL_GLattr attr, int *value); +extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value); /* * Swap the OpenGL buffers, if double-buffering is supported. */ -extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers (void); +extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void); /* Not in public API at the moment - do not use! */ -extern DECLSPEC int SDLCALL SDL_SoftStretch (SDL_Surface * src, - SDL_Rect * srcrect, - SDL_Surface * dst, - SDL_Rect * dstrect); +extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src, + SDL_Rect * srcrect, + SDL_Surface * dst, + SDL_Rect * dstrect); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff -r 1fddae038bc8 -r 4da1ee79c9af src/SDL.c --- a/src/SDL.c Mon May 29 03:53:21 2006 +0000 +++ b/src/SDL.c Mon May 29 04:04:35 2006 +0000 @@ -35,17 +35,17 @@ /* Initialization/Cleanup routines */ #if !SDL_JOYSTICK_DISABLED -extern int SDL_JoystickInit (void); -extern void SDL_JoystickQuit (void); +extern int SDL_JoystickInit(void); +extern void SDL_JoystickQuit(void); #endif #if !SDL_CDROM_DISABLED -extern int SDL_CDROMInit (void); -extern void SDL_CDROMQuit (void); +extern int SDL_CDROMInit(void); +extern void SDL_CDROMQuit(void); #endif #if !SDL_TIMERS_DISABLED -extern void SDL_StartTicks (void); -extern int SDL_TimerInit (void); -extern void SDL_TimerQuit (void); +extern void SDL_StartTicks(void); +extern int SDL_TimerInit(void); +extern void SDL_TimerQuit(void); #endif /* The initialized subsystems */ @@ -57,20 +57,20 @@ #endif int -SDL_InitSubSystem (Uint32 flags) +SDL_InitSubSystem(Uint32 flags) { #if !SDL_VIDEO_DISABLED /* Initialize the video/event subsystem */ if ((flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO)) { - if (SDL_VideoInit (SDL_getenv ("SDL_VIDEODRIVER"), - (flags & SDL_INIT_EVENTTHREAD)) < 0) { + if (SDL_VideoInit(SDL_getenv("SDL_VIDEODRIVER"), + (flags & SDL_INIT_EVENTTHREAD)) < 0) { return (-1); } SDL_initialized |= SDL_INIT_VIDEO; } #else if (flags & SDL_INIT_VIDEO) { - SDL_SetError ("SDL not built with video support"); + SDL_SetError("SDL not built with video support"); return (-1); } #endif @@ -78,14 +78,14 @@ #if !SDL_AUDIO_DISABLED /* Initialize the audio subsystem */ if ((flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO)) { - if (SDL_AudioInit (SDL_getenv ("SDL_AUDIODRIVER")) < 0) { + if (SDL_AudioInit(SDL_getenv("SDL_AUDIODRIVER")) < 0) { return (-1); } SDL_initialized |= SDL_INIT_AUDIO; } #else if (flags & SDL_INIT_AUDIO) { - SDL_SetError ("SDL not built with audio support"); + SDL_SetError("SDL not built with audio support"); return (-1); } #endif @@ -93,18 +93,18 @@ #if !SDL_TIMERS_DISABLED /* Initialize the timer subsystem */ if (!ticks_started) { - SDL_StartTicks (); + SDL_StartTicks(); ticks_started = 1; } if ((flags & SDL_INIT_TIMER) && !(SDL_initialized & SDL_INIT_TIMER)) { - if (SDL_TimerInit () < 0) { + if (SDL_TimerInit() < 0) { return (-1); } SDL_initialized |= SDL_INIT_TIMER; } #else if (flags & SDL_INIT_TIMER) { - SDL_SetError ("SDL not built with timer support"); + SDL_SetError("SDL not built with timer support"); return (-1); } #endif @@ -112,14 +112,14 @@ #if !SDL_JOYSTICK_DISABLED /* Initialize the joystick subsystem */ if ((flags & SDL_INIT_JOYSTICK) && !(SDL_initialized & SDL_INIT_JOYSTICK)) { - if (SDL_JoystickInit () < 0) { + if (SDL_JoystickInit() < 0) { return (-1); } SDL_initialized |= SDL_INIT_JOYSTICK; } #else if (flags & SDL_INIT_JOYSTICK) { - SDL_SetError ("SDL not built with joystick support"); + SDL_SetError("SDL not built with joystick support"); return (-1); } #endif @@ -127,14 +127,14 @@ #if !SDL_CDROM_DISABLED /* Initialize the CD-ROM subsystem */ if ((flags & SDL_INIT_CDROM) && !(SDL_initialized & SDL_INIT_CDROM)) { - if (SDL_CDROMInit () < 0) { + if (SDL_CDROMInit() < 0) { return (-1); } SDL_initialized |= SDL_INIT_CDROM; } #else if (flags & SDL_INIT_CDROM) { - SDL_SetError ("SDL not built with cdrom support"); + SDL_SetError("SDL not built with cdrom support"); return (-1); } #endif @@ -142,67 +142,67 @@ } int -SDL_Init (Uint32 flags) +SDL_Init(Uint32 flags) { #if !SDL_THREADS_DISABLED && SDL_THREAD_PTH - if (!pth_init ()) { + if (!pth_init()) { return -1; } #endif /* Clear the error message */ - SDL_ClearError (); + SDL_ClearError(); /* Initialize the desired subsystems */ - if (SDL_InitSubSystem (flags) < 0) { + if (SDL_InitSubSystem(flags) < 0) { return (-1); } /* Everything is initialized */ if (!(flags & SDL_INIT_NOPARACHUTE)) { - SDL_InstallParachute (); + SDL_InstallParachute(); } return (0); } void -SDL_QuitSubSystem (Uint32 flags) +SDL_QuitSubSystem(Uint32 flags) { /* Shut down requested initialized subsystems */ #if !SDL_CDROM_DISABLED if ((flags & SDL_initialized & SDL_INIT_CDROM)) { - SDL_CDROMQuit (); + SDL_CDROMQuit(); SDL_initialized &= ~SDL_INIT_CDROM; } #endif #if !SDL_JOYSTICK_DISABLED if ((flags & SDL_initialized & SDL_INIT_JOYSTICK)) { - SDL_JoystickQuit (); + SDL_JoystickQuit(); SDL_initialized &= ~SDL_INIT_JOYSTICK; } #endif #if !SDL_TIMERS_DISABLED if ((flags & SDL_initialized & SDL_INIT_TIMER)) { - SDL_TimerQuit (); + SDL_TimerQuit(); SDL_initialized &= ~SDL_INIT_TIMER; } #endif #if !SDL_AUDIO_DISABLED if ((flags & SDL_initialized & SDL_INIT_AUDIO)) { - SDL_AudioQuit (); + SDL_AudioQuit(); SDL_initialized &= ~SDL_INIT_AUDIO; } #endif #if !SDL_VIDEO_DISABLED if ((flags & SDL_initialized & SDL_INIT_VIDEO)) { - SDL_VideoQuit (); + SDL_VideoQuit(); SDL_initialized &= ~SDL_INIT_VIDEO; } #endif } Uint32 -SDL_WasInit (Uint32 flags) +SDL_WasInit(Uint32 flags) { if (!flags) { flags = SDL_INIT_EVERYTHING; @@ -211,50 +211,50 @@ } void -SDL_Quit (void) +SDL_Quit(void) { /* Quit all subsystems */ #ifdef DEBUG_BUILD - printf ("[SDL_Quit] : Enter! Calling QuitSubSystem()\n"); - fflush (stdout); + printf("[SDL_Quit] : Enter! Calling QuitSubSystem()\n"); + fflush(stdout); #endif - SDL_QuitSubSystem (SDL_INIT_EVERYTHING); + SDL_QuitSubSystem(SDL_INIT_EVERYTHING); #ifdef CHECK_LEAKS #ifdef DEBUG_BUILD - printf ("[SDL_Quit] : CHECK_LEAKS\n"); - fflush (stdout); + printf("[SDL_Quit] : CHECK_LEAKS\n"); + fflush(stdout); #endif /* Print the number of surfaces not freed */ if (surfaces_allocated != 0) { - fprintf (stderr, "SDL Warning: %d SDL surfaces extant\n", - surfaces_allocated); + fprintf(stderr, "SDL Warning: %d SDL surfaces extant\n", + surfaces_allocated); } #endif #ifdef DEBUG_BUILD - printf ("[SDL_Quit] : SDL_UninstallParachute()\n"); - fflush (stdout); + printf("[SDL_Quit] : SDL_UninstallParachute()\n"); + fflush(stdout); #endif /* Uninstall any parachute signal handlers */ - SDL_UninstallParachute (); + SDL_UninstallParachute(); #if !SDL_THREADS_DISABLED && SDL_THREAD_PTH - pth_kill (); + pth_kill(); #endif #ifdef DEBUG_BUILD - printf ("[SDL_Quit] : Returning!\n"); - fflush (stdout); + printf("[SDL_Quit] : Returning!\n"); + fflush(stdout); #endif } /* Get the library version number */ void -SDL_GetVersion (SDL_version * ver) +SDL_GetVersion(SDL_version * ver) { - SDL_VERSION (ver); + SDL_VERSION(ver); } #if defined(__OS2__) @@ -267,9 +267,9 @@ /* Exception handler to prevent the Audio thread hanging, making a zombie process! */ ULONG _System -SDL_Main_ExceptionHandler (PEXCEPTIONREPORTRECORD pERepRec, - PEXCEPTIONREGISTRATIONRECORD pERegRec, - PCONTEXTRECORD pCtxRec, PVOID p) +SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec, + PEXCEPTIONREGISTRATIONRECORD pERegRec, + PCONTEXTRECORD pCtxRec, PVOID p) { if (pERepRec->fHandlerFlags & EH_EXIT_UNWIND) return XCPT_CONTINUE_SEARCH; @@ -288,7 +288,7 @@ printf ("[SDL_Main_ExceptionHandler] : Calling SDL_CloseAudio()!\n"); #endif - SDL_CloseAudio (); + SDL_CloseAudio(); } } return (XCPT_CONTINUE_SEARCH); @@ -300,26 +300,26 @@ /* The main DLL entry for DLL Initialization and Uninitialization: */ unsigned _System -LibMain (unsigned hmod, unsigned termination) +LibMain(unsigned hmod, unsigned termination) { if (termination) { #ifdef DEBUG_BUILD /* printf("[SDL DLL Unintialization] : Removing exception handler\n"); */ #endif - DosUnsetExceptionHandler (&SDL_Main_xcpthand); + DosUnsetExceptionHandler(&SDL_Main_xcpthand); return 1; } else { #ifdef DEBUG_BUILD /* Make stdout and stderr unbuffered! */ - setbuf (stdout, NULL); - setbuf (stderr, NULL); + setbuf(stdout, NULL); + setbuf(stderr, NULL); #endif /* Fire up exception handler */ #ifdef DEBUG_BUILD /* printf("[SDL DLL Initialization] : Setting exception handler\n"); */ #endif /* Set exception handler */ - DosSetExceptionHandler (&SDL_Main_xcpthand); + DosSetExceptionHandler(&SDL_Main_xcpthand); return 1; } @@ -334,8 +334,8 @@ #include BOOL APIENTRY -_DllMainCRTStartup (HANDLE hModule, - DWORD ul_reason_for_call, LPVOID lpReserved) +_DllMainCRTStartup(HANDLE hModule, + DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: diff -r 1fddae038bc8 -r 4da1ee79c9af src/SDL_compat.c --- a/src/SDL_compat.c Mon May 29 03:53:21 2006 +0000 +++ b/src/SDL_compat.c Mon May 29 04:04:35 2006 +0000 @@ -32,48 +32,48 @@ static char *wm_title; char * -SDL_AudioDriverName (char *namebuf, int maxlen) +SDL_AudioDriverName(char *namebuf, int maxlen) { - const char *name = SDL_GetCurrentAudioDriver (); + const char *name = SDL_GetCurrentAudioDriver(); if (name) { - SDL_strlcpy (namebuf, name, maxlen); + SDL_strlcpy(namebuf, name, maxlen); return namebuf; } return NULL; } char * -SDL_VideoDriverName (char *namebuf, int maxlen) +SDL_VideoDriverName(char *namebuf, int maxlen) { - const char *name = SDL_GetCurrentVideoDriver (); + const char *name = SDL_GetCurrentVideoDriver(); if (name) { - SDL_strlcpy (namebuf, name, maxlen); + SDL_strlcpy(namebuf, name, maxlen); return namebuf; } return NULL; } int -SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags) +SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags) { int i, actual_bpp = 0; - if (!SDL_GetVideoDevice ()) { + if (!SDL_GetVideoDevice()) { return 0; } if (!(flags & SDL_FULLSCREEN)) { - return SDL_BITSPERPIXEL (SDL_GetDesktopDisplayMode ()->format); + return SDL_BITSPERPIXEL(SDL_GetDesktopDisplayMode()->format); } - for (i = 0; i < SDL_GetNumDisplayModes (); ++i) { - const SDL_DisplayMode *mode = SDL_GetDisplayMode (i); + for (i = 0; i < SDL_GetNumDisplayModes(); ++i) { + const SDL_DisplayMode *mode = SDL_GetDisplayMode(i); if (!mode->w || !mode->h || (width == mode->w && height == mode->h)) { if (!mode->format) { return bpp; } - if (SDL_BITSPERPIXEL (mode->format) >= bpp) { - actual_bpp = SDL_BITSPERPIXEL (mode->format); + if (SDL_BITSPERPIXEL(mode->format) >= bpp) { + actual_bpp = SDL_BITSPERPIXEL(mode->format); } } } @@ -81,12 +81,12 @@ } SDL_Rect ** -SDL_ListModes (SDL_PixelFormat * format, Uint32 flags) +SDL_ListModes(SDL_PixelFormat * format, Uint32 flags) { int i, nmodes; SDL_Rect **modes; - if (!SDL_GetVideoDevice ()) { + if (!SDL_GetVideoDevice()) { return NULL; } @@ -96,12 +96,12 @@ /* Memory leak, but this is a compatibility function, who cares? */ nmodes = 0; - for (i = 0; i < SDL_GetNumDisplayModes (); ++i) { - const SDL_DisplayMode *mode = SDL_GetDisplayMode (i); + for (i = 0; i < SDL_GetNumDisplayModes(); ++i) { + const SDL_DisplayMode *mode = SDL_GetDisplayMode(i); if (!mode->w || !mode->h) { return (SDL_Rect **) (-1); } - if (SDL_BITSPERPIXEL (mode->format) != format->BitsPerPixel) { + if (SDL_BITSPERPIXEL(mode->format) != format->BitsPerPixel) { continue; } if (nmodes > 0 && modes[nmodes - 1]->w == mode->w @@ -109,11 +109,11 @@ continue; } - modes = SDL_realloc (modes, (nmodes + 2) * sizeof (*modes)); + modes = SDL_realloc(modes, (nmodes + 2) * sizeof(*modes)); if (!modes) { return NULL; } - modes[nmodes] = (SDL_Rect *) SDL_malloc (sizeof (SDL_Rect)); + modes[nmodes] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect)); if (!modes[nmodes]) { return NULL; } @@ -130,7 +130,7 @@ } SDL_Surface * -SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) +SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) { SDL_DisplayMode mode; int i; @@ -138,14 +138,14 @@ Uint32 desktop_format; Uint32 desired_format; - if (!SDL_GetVideoDevice ()) { - if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) { + if (!SDL_GetVideoDevice()) { + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) { return NULL; } } /* Destroy existing window */ - SDL_DestroyWindow (window); + SDL_DestroyWindow(window); /* Create a new window */ window_flags = SDL_WINDOW_SHOWN; @@ -161,13 +161,13 @@ if (flags & SDL_NOFRAME) { window_flags |= SDL_WINDOW_BORDERLESS; } - window = SDL_CreateWindow (wm_title, 0, 0, width, height, window_flags); + window = SDL_CreateWindow(wm_title, 0, 0, width, height, window_flags); if (!window) { return NULL; } /* Set up the desired display mode */ - desktop_format = SDL_GetDesktopDisplayMode ()->format; + desktop_format = SDL_GetDesktopDisplayMode()->format; if ((bpp == SDL_BITSPERPIXEL(desktop_format)) || (desktop_format && (flags & SDL_ANYFORMAT))) { desired_format = desktop_format; @@ -189,7 +189,7 @@ desired_format = SDL_PixelFormat_RGB888; break; default: - SDL_SetError ("Unsupported bpp in SDL_SetVideoMode()"); + SDL_SetError("Unsupported bpp in SDL_SetVideoMode()"); return NULL; } } @@ -200,41 +200,41 @@ /* Set the desired display mode */ if (flags & SDL_FULLSCREEN) { - if (!SDL_GetClosestDisplayMode (&mode, &mode)) { + if (!SDL_GetClosestDisplayMode(&mode, &mode)) { return NULL; } } else { - mode = *SDL_GetDesktopDisplayMode (); + mode = *SDL_GetDesktopDisplayMode(); } - if (SDL_SetDisplayMode (&mode) < 0) { + if (SDL_SetDisplayMode(&mode) < 0) { return NULL; } /* Create the display surface */ - return SDL_CreateWindowSurface (window, desired_format, flags); + return SDL_CreateWindowSurface(window, desired_format, flags); } SDL_Surface * -SDL_GetVideoSurface (void) +SDL_GetVideoSurface(void) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); return SDL_VideoSurface; } void -SDL_WM_SetCaption (const char *title, const char *icon) +SDL_WM_SetCaption(const char *title, const char *icon) { if (wm_title) { - SDL_free (wm_title); + SDL_free(wm_title); } else { - wm_title = SDL_strdup (title); + wm_title = SDL_strdup(title); } - SDL_SetWindowTitle (window, wm_title); + SDL_SetWindowTitle(window, wm_title); } void -SDL_WM_GetCaption (char **title, char **icon) +SDL_WM_GetCaption(char **title, char **icon) { if (title) { *title = wm_title; @@ -245,39 +245,39 @@ } void -SDL_WM_SetIcon (SDL_Surface * icon, Uint8 * mask) +SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask) { /* FIXME */ } int -SDL_WM_IconifyWindow (void) +SDL_WM_IconifyWindow(void) { - SDL_MinimizeWindow (window); + SDL_MinimizeWindow(window); } int -SDL_WM_ToggleFullScreen (SDL_Surface * surface) +SDL_WM_ToggleFullScreen(SDL_Surface * surface) { return 0; } SDL_GrabMode -SDL_WM_GrabInput (SDL_GrabMode mode) +SDL_WM_GrabInput(SDL_GrabMode mode) { if (mode != SDL_GRAB_QUERY) { - SDL_SetWindowGrab (window, mode); + SDL_SetWindowGrab(window, mode); } - return (SDL_GrabMode) SDL_GetWindowGrab (window); + return (SDL_GrabMode) SDL_GetWindowGrab(window); } Uint8 -SDL_GetAppState (void) +SDL_GetAppState(void) { Uint8 state = 0; Uint32 flags = 0; - flags = SDL_GetWindowFlags (window); + flags = SDL_GetWindowFlags(window); if ((flags & SDL_WINDOW_SHOWN) && !(flags & SDL_WINDOW_MINIMIZED)) { state |= SDL_APPACTIVE; } @@ -291,24 +291,24 @@ } const SDL_version * -SDL_Linked_Version (void) +SDL_Linked_Version(void) { static SDL_version version; - SDL_VERSION (&version); + SDL_VERSION(&version); return &version; } int -SDL_SetPalette (SDL_Surface * surface, int flags, SDL_Color * colors, - int firstcolor, int ncolors) +SDL_SetPalette(SDL_Surface * surface, int flags, SDL_Color * colors, + int firstcolor, int ncolors) { - SDL_SetColors (surface, colors, firstcolor, ncolors); + SDL_SetColors(surface, colors, firstcolor, ncolors); } int -SDL_GetWMInfo (SDL_SysWMinfo * info) +SDL_GetWMInfo(SDL_SysWMinfo * info) { - return SDL_GetWindowWMInfo (window, info); + return SDL_GetWindowWMInfo(window, info); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/SDL_error.c --- a/src/SDL_error.c Mon May 29 03:53:21 2006 +0000 +++ b/src/SDL_error.c Mon May 29 04:04:35 2006 +0000 @@ -32,7 +32,7 @@ static SDL_error SDL_global_error; #define SDL_GetErrBuf() (&SDL_global_error) #else -extern SDL_error *SDL_GetErrBuf (void); +extern SDL_error *SDL_GetErrBuf(void); #endif /* SDL_THREADS_DISABLED */ #define SDL_ERRBUFIZE 1024 @@ -40,7 +40,7 @@ /* Private functions */ static const char * -SDL_LookupString (const char *key) +SDL_LookupString(const char *key) { /* FIXME: Add code to lookup key in language string hash-table */ return key; @@ -49,17 +49,17 @@ /* Public functions */ void -SDL_SetError (const char *fmt, ...) +SDL_SetError(const char *fmt, ...) { va_list ap; SDL_error *error; /* Copy in the key, mark error as valid */ - error = SDL_GetErrBuf (); + error = SDL_GetErrBuf(); error->error = 1; - SDL_strlcpy ((char *) error->key, fmt, sizeof (error->key)); + SDL_strlcpy((char *) error->key, fmt, sizeof(error->key)); - va_start (ap, fmt); + va_start(ap, fmt); error->argc = 0; while (*fmt) { if (*fmt++ == '%') { @@ -77,22 +77,22 @@ case 'o': case 'x': case 'X': - error->args[error->argc++].value_i = va_arg (ap, int); + error->args[error->argc++].value_i = va_arg(ap, int); break; case 'f': - error->args[error->argc++].value_f = va_arg (ap, double); + error->args[error->argc++].value_f = va_arg(ap, double); break; case 'p': - error->args[error->argc++].value_ptr = va_arg (ap, void *); + error->args[error->argc++].value_ptr = va_arg(ap, void *); break; case 's': { int i = error->argc; - const char *str = va_arg (ap, const char *); + const char *str = va_arg(ap, const char *); if (str == NULL) str = "(null)"; - SDL_strlcpy ((char *) error->args[i].buf, str, - ERR_MAX_STRLEN); + SDL_strlcpy((char *) error->args[i].buf, str, + ERR_MAX_STRLEN); error->argc++; } break; @@ -104,11 +104,11 @@ } } } - va_end (ap); + va_end(ap); /* If we are in debug mode, print out an error message */ #ifdef DEBUG_ERROR - fprintf (stderr, "SDL_SetError: %s\n", SDL_GetError ()); + fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError()); #endif } @@ -116,7 +116,7 @@ so that it supports internationalization and thread-safe errors. */ char * -SDL_GetErrorMsg (char *errstr, unsigned int maxlen) +SDL_GetErrorMsg(char *errstr, unsigned int maxlen) { SDL_error *error; @@ -125,21 +125,21 @@ --maxlen; /* Get the thread-safe error, and print it out */ - error = SDL_GetErrBuf (); + error = SDL_GetErrBuf(); if (error->error) { const char *fmt; char *msg = errstr; int len; int argi; - fmt = SDL_LookupString (error->key); + fmt = SDL_LookupString(error->key); argi = 0; while (*fmt && (maxlen > 0)) { if (*fmt == '%') { char tmp[32], *spot = tmp; *spot++ = *fmt++; while ((*fmt == '.' || (*fmt >= '0' && *fmt <= '9')) - && spot < (tmp + SDL_arraysize (tmp) - 2)) { + && spot < (tmp + SDL_arraysize(tmp) - 2)) { *spot++ = *fmt++; } *spot++ = *fmt++; @@ -157,30 +157,30 @@ case 'x': case 'X': len = - SDL_snprintf (msg, maxlen, tmp, - error->args[argi++].value_i); + SDL_snprintf(msg, maxlen, tmp, + error->args[argi++].value_i); msg += len; maxlen -= len; break; case 'f': len = - SDL_snprintf (msg, maxlen, tmp, - error->args[argi++].value_f); + SDL_snprintf(msg, maxlen, tmp, + error->args[argi++].value_f); msg += len; maxlen -= len; break; case 'p': len = - SDL_snprintf (msg, maxlen, tmp, - error->args[argi++].value_ptr); + SDL_snprintf(msg, maxlen, tmp, + error->args[argi++].value_ptr); msg += len; maxlen -= len; break; case 's': len = - SDL_snprintf (msg, maxlen, tmp, - SDL_LookupString (error-> - args[argi++].buf)); + SDL_snprintf(msg, maxlen, tmp, + SDL_LookupString(error-> + args[argi++].buf)); msg += len; maxlen -= len; break; @@ -197,59 +197,59 @@ /* Available for backwards compatibility */ char * -SDL_GetError (void) +SDL_GetError(void) { static char errmsg[SDL_ERRBUFIZE]; - return ((char *) SDL_GetErrorMsg (errmsg, SDL_ERRBUFIZE)); + return ((char *) SDL_GetErrorMsg(errmsg, SDL_ERRBUFIZE)); } void -SDL_ClearError (void) +SDL_ClearError(void) { SDL_error *error; - error = SDL_GetErrBuf (); + error = SDL_GetErrBuf(); error->error = 0; } /* Very common errors go here */ void -SDL_Error (SDL_errorcode code) +SDL_Error(SDL_errorcode code) { switch (code) { case SDL_ENOMEM: - SDL_SetError ("Out of memory"); + SDL_SetError("Out of memory"); break; case SDL_EFREAD: - SDL_SetError ("Error reading from datastream"); + SDL_SetError("Error reading from datastream"); break; case SDL_EFWRITE: - SDL_SetError ("Error writing to datastream"); + SDL_SetError("Error writing to datastream"); break; case SDL_EFSEEK: - SDL_SetError ("Error seeking in datastream"); + SDL_SetError("Error seeking in datastream"); break; default: - SDL_SetError ("Unknown SDL error"); + SDL_SetError("Unknown SDL error"); break; } } #ifdef TEST_ERROR int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { char buffer[BUFSIZ + 1]; - SDL_SetError ("Hi there!"); - printf ("Error 1: %s\n", SDL_GetError ()); - SDL_ClearError (); - SDL_memset (buffer, '1', BUFSIZ); + SDL_SetError("Hi there!"); + printf("Error 1: %s\n", SDL_GetError()); + SDL_ClearError(); + SDL_memset(buffer, '1', BUFSIZ); buffer[BUFSIZ] = 0; - SDL_SetError ("This is the error: %s (%f)", buffer, 1.0); - printf ("Error 2: %s\n", SDL_GetError ()); - exit (0); + SDL_SetError("This is the error: %s (%f)", buffer, 1.0); + printf("Error 2: %s\n", SDL_GetError()); + exit(0); } #endif /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/SDL_fatal.c --- a/src/SDL_fatal.c Mon May 29 03:53:21 2006 +0000 +++ b/src/SDL_fatal.c Mon May 29 04:04:35 2006 +0000 @@ -36,11 +36,11 @@ */ static void -SDL_Parachute (int sig) +SDL_Parachute(int sig) { - signal (sig, SIG_DFL); - SDL_Quit (); - raise (sig); + signal(sig, SIG_DFL); + SDL_Quit(); + raise(sig); } static int SDL_fatal_signals[] = { @@ -58,7 +58,7 @@ }; void -SDL_InstallParachute (void) +SDL_InstallParachute(void) { /* Set a handler for any fatal signal not already handled */ int i; @@ -66,27 +66,27 @@ struct sigaction action; for (i = 0; SDL_fatal_signals[i]; ++i) { - sigaction (SDL_fatal_signals[i], NULL, &action); + sigaction(SDL_fatal_signals[i], NULL, &action); if (action.sa_handler == SIG_DFL) { action.sa_handler = SDL_Parachute; - sigaction (SDL_fatal_signals[i], &action, NULL); + sigaction(SDL_fatal_signals[i], &action, NULL); } } #ifdef SIGALRM /* Set SIGALRM to be ignored -- necessary on Solaris */ - sigaction (SIGALRM, NULL, &action); + sigaction(SIGALRM, NULL, &action); if (action.sa_handler == SIG_DFL) { action.sa_handler = SIG_IGN; - sigaction (SIGALRM, &action, NULL); + sigaction(SIGALRM, &action, NULL); } #endif #else void (*ohandler) (int); for (i = 0; SDL_fatal_signals[i]; ++i) { - ohandler = signal (SDL_fatal_signals[i], SDL_Parachute); + ohandler = signal(SDL_fatal_signals[i], SDL_Parachute); if (ohandler != SIG_DFL) { - signal (SDL_fatal_signals[i], ohandler); + signal(SDL_fatal_signals[i], ohandler); } } #endif /* HAVE_SIGACTION */ @@ -94,7 +94,7 @@ } void -SDL_UninstallParachute (void) +SDL_UninstallParachute(void) { /* Remove a handler for any fatal signal handled */ int i; @@ -102,19 +102,19 @@ struct sigaction action; for (i = 0; SDL_fatal_signals[i]; ++i) { - sigaction (SDL_fatal_signals[i], NULL, &action); + sigaction(SDL_fatal_signals[i], NULL, &action); if (action.sa_handler == SDL_Parachute) { action.sa_handler = SIG_DFL; - sigaction (SDL_fatal_signals[i], &action, NULL); + sigaction(SDL_fatal_signals[i], &action, NULL); } } #else void (*ohandler) (int); for (i = 0; SDL_fatal_signals[i]; ++i) { - ohandler = signal (SDL_fatal_signals[i], SIG_DFL); + ohandler = signal(SDL_fatal_signals[i], SIG_DFL); if (ohandler != SDL_Parachute) { - signal (SDL_fatal_signals[i], ohandler); + signal(SDL_fatal_signals[i], ohandler); } } #endif /* HAVE_SIGACTION */ @@ -125,13 +125,13 @@ /* No signals on this platform, nothing to do.. */ void -SDL_InstallParachute (void) +SDL_InstallParachute(void) { return; } void -SDL_UninstallParachute (void) +SDL_UninstallParachute(void) { return; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/SDL_fatal.h --- a/src/SDL_fatal.h Mon May 29 03:53:21 2006 +0000 +++ b/src/SDL_fatal.h Mon May 29 04:04:35 2006 +0000 @@ -23,6 +23,6 @@ /* General fatal signal handling code for SDL */ -extern void SDL_InstallParachute (void); -extern void SDL_UninstallParachute (void); +extern void SDL_InstallParachute(void); +extern void SDL_UninstallParachute(void); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/SDL_audio.c --- a/src/audio/SDL_audio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/SDL_audio.c Mon May 29 04:04:35 2006 +0000 @@ -112,8 +112,8 @@ SDL_AudioDevice *current_audio = NULL; /* Various local functions */ -int SDL_AudioInit (const char *driver_name); -void SDL_AudioQuit (void); +int SDL_AudioInit(const char *driver_name); +void SDL_AudioQuit(void); #if SDL_AUDIO_DRIVER_AHI static int audio_configured = 0; @@ -121,7 +121,7 @@ /* The general mixing thread function */ int SDLCALL -SDL_RunAudio (void *audiop) +SDL_RunAudio(void *audiop) { SDL_AudioDevice *audio = (SDL_AudioDevice *) audiop; Uint8 *stream; @@ -134,21 +134,21 @@ /* AmigaOS NEEDS that the audio driver is opened in the thread that uses it! */ - D (bug ("Task audio started audio struct:<%lx>...\n", audiop)); + D(bug("Task audio started audio struct:<%lx>...\n", audiop)); - D (bug ("Before Openaudio...")); - if (audio->OpenAudio (audio, &audio->spec) == -1) { - D (bug ("Open audio failed...\n")); + D(bug("Before Openaudio...")); + if (audio->OpenAudio(audio, &audio->spec) == -1) { + D(bug("Open audio failed...\n")); return (-1); } - D (bug ("OpenAudio...OK\n")); + D(bug("OpenAudio...OK\n")); #endif /* Perform any thread setup */ if (audio->ThreadInit) { - audio->ThreadInit (audio); + audio->ThreadInit(audio); } - audio->threadid = SDL_ThreadID (); + audio->threadid = SDL_ThreadID(); /* Set up the mixing function */ fill = audio->spec.callback; @@ -157,9 +157,9 @@ #if SDL_AUDIO_DRIVER_AHI audio_configured = 1; - D (bug ("Audio configured... Checking for conversion\n")); - SDL_mutexP (audio->mixer_lock); - D (bug ("Semaphore obtained...\n")); + D(bug("Audio configured... Checking for conversion\n")); + SDL_mutexP(audio->mixer_lock); + D(bug("Semaphore obtained...\n")); #endif if (audio->convert.needed) { @@ -175,28 +175,28 @@ } #if SDL_AUDIO_DRIVER_AHI - SDL_mutexV (audio->mixer_lock); - D (bug ("Entering audio loop...\n")); + SDL_mutexV(audio->mixer_lock); + D(bug("Entering audio loop...\n")); #endif #ifdef __OS2__ /* Increase the priority of this thread to make sure that the audio will be continuous all the time! */ #ifdef USE_DOSSETPRIORITY - if (SDL_getenv ("SDL_USE_TIMECRITICAL_AUDIO")) { + if (SDL_getenv("SDL_USE_TIMECRITICAL_AUDIO")) { #ifdef DEBUG_BUILD printf ("[SDL_RunAudio] : Setting priority to TimeCritical+0! (TID%d)\n", - SDL_ThreadID ()); + SDL_ThreadID()); #endif - DosSetPriority (PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0); + DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0); } else { #ifdef DEBUG_BUILD printf ("[SDL_RunAudio] : Setting priority to ForegroundServer+0! (TID%d)\n", - SDL_ThreadID ()); + SDL_ThreadID()); #endif - DosSetPriority (PRTYS_THREAD, PRTYC_FOREGROUNDSERVER, 0, 0); + DosSetPriority(PRTYS_THREAD, PRTYC_FOREGROUNDSERVER, 0, 0); } #endif #endif @@ -212,82 +212,82 @@ continue; } } else { - stream = audio->GetAudioBuf (audio); + stream = audio->GetAudioBuf(audio); if (stream == NULL) { stream = audio->fake_stream; } } - SDL_memset (stream, silence, stream_len); + SDL_memset(stream, silence, stream_len); if (!audio->paused) { - SDL_mutexP (audio->mixer_lock); + SDL_mutexP(audio->mixer_lock); (*fill) (udata, stream, stream_len); - SDL_mutexV (audio->mixer_lock); + SDL_mutexV(audio->mixer_lock); } /* Convert the audio if necessary */ if (audio->convert.needed) { - SDL_ConvertAudio (&audio->convert); - stream = audio->GetAudioBuf (audio); + SDL_ConvertAudio(&audio->convert); + stream = audio->GetAudioBuf(audio); if (stream == NULL) { stream = audio->fake_stream; } - SDL_memcpy (stream, audio->convert.buf, audio->convert.len_cvt); + SDL_memcpy(stream, audio->convert.buf, audio->convert.len_cvt); } /* Ready current buffer for play and change current buffer */ if (stream != audio->fake_stream) { - audio->PlayAudio (audio); + audio->PlayAudio(audio); } /* Wait for an audio buffer to become available */ if (stream == audio->fake_stream) { - SDL_Delay ((audio->spec.samples * 1000) / audio->spec.freq); + SDL_Delay((audio->spec.samples * 1000) / audio->spec.freq); } else { - audio->WaitAudio (audio); + audio->WaitAudio(audio); } } /* Wait for the audio to drain.. */ if (audio->WaitDone) { - audio->WaitDone (audio); + audio->WaitDone(audio); } #if SDL_AUDIO_DRIVER_AHI - D (bug ("WaitAudio...Done\n")); + D(bug("WaitAudio...Done\n")); - audio->CloseAudio (audio); + audio->CloseAudio(audio); - D (bug ("CloseAudio..Done, subtask exiting...\n")); + D(bug("CloseAudio..Done, subtask exiting...\n")); audio_configured = 0; #endif #ifdef __OS2__ #ifdef DEBUG_BUILD - printf ("[SDL_RunAudio] : Task exiting. (TID%d)\n", SDL_ThreadID ()); + printf("[SDL_RunAudio] : Task exiting. (TID%d)\n", SDL_ThreadID()); #endif #endif return (0); } static void -SDL_LockAudio_Default (SDL_AudioDevice * audio) +SDL_LockAudio_Default(SDL_AudioDevice * audio) { - if (audio->thread && (SDL_ThreadID () == audio->threadid)) { + if (audio->thread && (SDL_ThreadID() == audio->threadid)) { return; } - SDL_mutexP (audio->mixer_lock); + SDL_mutexP(audio->mixer_lock); } static void -SDL_UnlockAudio_Default (SDL_AudioDevice * audio) +SDL_UnlockAudio_Default(SDL_AudioDevice * audio) { - if (audio->thread && (SDL_ThreadID () == audio->threadid)) { + if (audio->thread && (SDL_ThreadID() == audio->threadid)) { return; } - SDL_mutexV (audio->mixer_lock); + SDL_mutexV(audio->mixer_lock); } static Uint16 -SDL_ParseAudioFormat (const char *string) +SDL_ParseAudioFormat(const char *string) { Uint16 format = 0; @@ -303,7 +303,7 @@ default: return 0; } - switch (SDL_atoi (string)) { + switch (SDL_atoi(string)) { case 8: string += 1; format |= 8; @@ -311,16 +311,16 @@ case 16: string += 2; format |= 16; - if (SDL_strcmp (string, "LSB") == 0 + if (SDL_strcmp(string, "LSB") == 0 #if SDL_BYTEORDER == SDL_LIL_ENDIAN - || SDL_strcmp (string, "SYS") == 0 + || SDL_strcmp(string, "SYS") == 0 #endif ) { format |= 0x0000; } - if (SDL_strcmp (string, "MSB") == 0 + if (SDL_strcmp(string, "MSB") == 0 #if SDL_BYTEORDER == SDL_BIG_ENDIAN - || SDL_strcmp (string, "SYS") == 0 + || SDL_strcmp(string, "SYS") == 0 #endif ) { format |= 0x1000; @@ -333,58 +333,58 @@ } int -SDL_GetNumAudioDrivers (void) +SDL_GetNumAudioDrivers(void) { - return (SDL_arraysize (bootstrap) - 1); + return (SDL_arraysize(bootstrap) - 1); } const char * -SDL_GetAudioDriver (int index) +SDL_GetAudioDriver(int index) { - if (index >= 0 && index < SDL_GetNumAudioDrivers ()) { + if (index >= 0 && index < SDL_GetNumAudioDrivers()) { return (bootstrap[index]->name); } return (NULL); } int -SDL_AudioInit (const char *driver_name) +SDL_AudioInit(const char *driver_name) { SDL_AudioDevice *audio; int i = 0, idx; /* Check to make sure we don't overwrite 'current_audio' */ if (current_audio != NULL) { - SDL_AudioQuit (); + SDL_AudioQuit(); } /* Select the proper audio driver */ audio = NULL; idx = 0; #if SDL_AUDIO_DRIVER_ESD - if ((driver_name == NULL) && (SDL_getenv ("ESPEAKER") != NULL)) { + if ((driver_name == NULL) && (SDL_getenv("ESPEAKER") != NULL)) { /* Ahem, we know that if ESPEAKER is set, user probably wants to use ESD, but don't start it if it's not already running. This probably isn't the place to do this, but... Shh! :) */ for (i = 0; bootstrap[i]; ++i) { - if (SDL_strcmp (bootstrap[i]->name, "esd") == 0) { + if (SDL_strcmp(bootstrap[i]->name, "esd") == 0) { #ifdef HAVE_PUTENV const char *esd_no_spawn; /* Don't start ESD if it's not running */ - esd_no_spawn = getenv ("ESD_NO_SPAWN"); + esd_no_spawn = getenv("ESD_NO_SPAWN"); if (esd_no_spawn == NULL) { - putenv ("ESD_NO_SPAWN=1"); + putenv("ESD_NO_SPAWN=1"); } #endif - if (bootstrap[i]->available ()) { - audio = bootstrap[i]->create (0); + if (bootstrap[i]->available()) { + audio = bootstrap[i]->create(0); break; } #ifdef HAVE_UNSETENV if (esd_no_spawn == NULL) { - unsetenv ("ESD_NO_SPAWN"); + unsetenv("ESD_NO_SPAWN"); } #endif } @@ -394,23 +394,23 @@ if (audio == NULL) { if (driver_name != NULL) { #if 0 /* This will be replaced with a better driver selection API */ - if (SDL_strrchr (driver_name, ':') != NULL) { - idx = atoi (SDL_strrchr (driver_name, ':') + 1); + if (SDL_strrchr(driver_name, ':') != NULL) { + idx = atoi(SDL_strrchr(driver_name, ':') + 1); } #endif for (i = 0; bootstrap[i]; ++i) { - if (SDL_strncmp (bootstrap[i]->name, driver_name, - SDL_strlen (bootstrap[i]->name)) == 0) { - if (bootstrap[i]->available ()) { - audio = bootstrap[i]->create (idx); + if (SDL_strncmp(bootstrap[i]->name, driver_name, + SDL_strlen(bootstrap[i]->name)) == 0) { + if (bootstrap[i]->available()) { + audio = bootstrap[i]->create(idx); } break; } } } else { for (i = 0; bootstrap[i]; ++i) { - if (bootstrap[i]->available ()) { - audio = bootstrap[i]->create (idx); + if (bootstrap[i]->available()) { + audio = bootstrap[i]->create(idx); if (audio != NULL) { break; } @@ -419,9 +419,9 @@ } if (audio == NULL) { if (driver_name) { - SDL_SetError ("%s not available", driver_name); + SDL_SetError("%s not available", driver_name); } else { - SDL_SetError ("No available audio device"); + SDL_SetError("No available audio device"); } #if 0 /* Don't fail SDL_Init() if audio isn't available. SDL_OpenAudio() will handle it at that point. *sigh* @@ -445,7 +445,7 @@ * Get the current audio driver name */ const char * -SDL_GetCurrentAudioDriver () +SDL_GetCurrentAudioDriver() { if (current_audio) { return current_audio->name; @@ -454,14 +454,14 @@ } int -SDL_OpenAudio (SDL_AudioSpec * desired, SDL_AudioSpec * obtained) +SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained) { SDL_AudioDevice *audio; const char *env; /* Start up the audio driver, if necessary */ if (!current_audio) { - if ((SDL_InitSubSystem (SDL_INIT_AUDIO) < 0) || + if ((SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) || (current_audio == NULL)) { return (-1); } @@ -469,15 +469,15 @@ audio = current_audio; if (audio->opened) { - SDL_SetError ("Audio device is already opened"); + SDL_SetError("Audio device is already opened"); return (-1); } /* Verify some parameters */ if (desired->freq == 0) { - env = SDL_getenv ("SDL_AUDIO_FREQUENCY"); + env = SDL_getenv("SDL_AUDIO_FREQUENCY"); if (env) { - desired->freq = SDL_atoi (env); + desired->freq = SDL_atoi(env); } } if (desired->freq == 0) { @@ -485,9 +485,9 @@ desired->freq = 22050; } if (desired->format == 0) { - env = SDL_getenv ("SDL_AUDIO_FORMAT"); + env = SDL_getenv("SDL_AUDIO_FORMAT"); if (env) { - desired->format = SDL_ParseAudioFormat (env); + desired->format = SDL_ParseAudioFormat(env); } } if (desired->format == 0) { @@ -495,9 +495,9 @@ desired->format = AUDIO_S16; } if (desired->channels == 0) { - env = SDL_getenv ("SDL_AUDIO_CHANNELS"); + env = SDL_getenv("SDL_AUDIO_CHANNELS"); if (env) { - desired->channels = SDL_atoi (env); + desired->channels = SDL_atoi(env); } } if (desired->channels == 0) { @@ -511,13 +511,13 @@ case 6: /* surround with center and lfe */ break; default: - SDL_SetError ("1 (mono) and 2 (stereo) channels supported"); + SDL_SetError("1 (mono) and 2 (stereo) channels supported"); return (-1); } if (desired->samples == 0) { - env = SDL_getenv ("SDL_AUDIO_SAMPLES"); + env = SDL_getenv("SDL_AUDIO_SAMPLES"); if (env) { - desired->samples = SDL_atoi (env); + desired->samples = SDL_atoi(env); } } if (desired->samples == 0) { @@ -530,7 +530,7 @@ desired->samples = power2; } if (desired->callback == NULL) { - SDL_SetError ("SDL_OpenAudio() passed a NULL callback"); + SDL_SetError("SDL_OpenAudio() passed a NULL callback"); return (-1); } #if defined(__MACOS__) || (defined(__RISCOS__) && SDL_THREADS_DISABLED) @@ -540,20 +540,20 @@ /* Uses interrupt driven audio, without thread */ #else /* Create a semaphore for locking the sound buffers */ - audio->mixer_lock = SDL_CreateMutex (); + audio->mixer_lock = SDL_CreateMutex(); if (audio->mixer_lock == NULL) { - SDL_SetError ("Couldn't create mixer lock"); - SDL_CloseAudio (); + SDL_SetError("Couldn't create mixer lock"); + SDL_CloseAudio(); return (-1); } #endif /* __MINT__ */ #endif /* __MACOS__ */ /* Calculate the silence and size of the audio specification */ - SDL_CalculateAudioSpec (desired); + SDL_CalculateAudioSpec(desired); /* Open the audio subsystem */ - SDL_memcpy (&audio->spec, desired, sizeof (audio->spec)); + SDL_memcpy(&audio->spec, desired, sizeof(audio->spec)); audio->convert.needed = 0; audio->enabled = 1; audio->paused = 1; @@ -561,68 +561,68 @@ #if !SDL_AUDIO_DRIVER_AHI /* AmigaOS opens audio inside the main loop */ - audio->opened = audio->OpenAudio (audio, &audio->spec) + 1; + audio->opened = audio->OpenAudio(audio, &audio->spec) + 1; if (!audio->opened) { - SDL_CloseAudio (); + SDL_CloseAudio(); return (-1); } #else - D (bug ("Locking semaphore...")); - SDL_mutexP (audio->mixer_lock); + D(bug("Locking semaphore...")); + SDL_mutexP(audio->mixer_lock); - audio->thread = SDL_CreateThread (SDL_RunAudio, audio); - D (bug ("Created thread...\n")); + audio->thread = SDL_CreateThread(SDL_RunAudio, audio); + D(bug("Created thread...\n")); if (audio->thread == NULL) { - SDL_mutexV (audio->mixer_lock); - SDL_CloseAudio (); - SDL_SetError ("Couldn't create audio thread"); + SDL_mutexV(audio->mixer_lock); + SDL_CloseAudio(); + SDL_SetError("Couldn't create audio thread"); return (-1); } while (!audio_configured) - SDL_Delay (100); + SDL_Delay(100); #endif /* If the audio driver changes the buffer size, accept it */ if (audio->spec.samples != desired->samples) { desired->samples = audio->spec.samples; - SDL_CalculateAudioSpec (desired); + SDL_CalculateAudioSpec(desired); } /* Allocate a fake audio memory buffer */ - audio->fake_stream = SDL_AllocAudioMem (audio->spec.size); + audio->fake_stream = SDL_AllocAudioMem(audio->spec.size); if (audio->fake_stream == NULL) { - SDL_CloseAudio (); - SDL_OutOfMemory (); + SDL_CloseAudio(); + SDL_OutOfMemory(); return (-1); } /* See if we need to do any conversion */ if (obtained != NULL) { - SDL_memcpy (obtained, &audio->spec, sizeof (audio->spec)); + SDL_memcpy(obtained, &audio->spec, sizeof(audio->spec)); } else if (desired->freq != audio->spec.freq || desired->format != audio->spec.format || desired->channels != audio->spec.channels) { /* Build an audio conversion block */ - if (SDL_BuildAudioCVT (&audio->convert, - desired->format, desired->channels, - desired->freq, - audio->spec.format, audio->spec.channels, - audio->spec.freq) < 0) { - SDL_CloseAudio (); + if (SDL_BuildAudioCVT(&audio->convert, + desired->format, desired->channels, + desired->freq, + audio->spec.format, audio->spec.channels, + audio->spec.freq) < 0) { + SDL_CloseAudio(); return (-1); } if (audio->convert.needed) { audio->convert.len = desired->size; audio->convert.buf = - (Uint8 *) SDL_AllocAudioMem (audio->convert.len * - audio->convert.len_mult); + (Uint8 *) SDL_AllocAudioMem(audio->convert.len * + audio->convert.len_mult); if (audio->convert.buf == NULL) { - SDL_CloseAudio (); - SDL_OutOfMemory (); + SDL_CloseAudio(); + SDL_OutOfMemory(); return (-1); } } @@ -634,13 +634,13 @@ /* Start the audio thread */ #if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC) #undef SDL_CreateThread - audio->thread = SDL_CreateThread (SDL_RunAudio, audio, NULL, NULL); + audio->thread = SDL_CreateThread(SDL_RunAudio, audio, NULL, NULL); #else - audio->thread = SDL_CreateThread (SDL_RunAudio, audio); + audio->thread = SDL_CreateThread(SDL_RunAudio, audio); #endif if (audio->thread == NULL) { - SDL_CloseAudio (); - SDL_SetError ("Couldn't create audio thread"); + SDL_CloseAudio(); + SDL_SetError("Couldn't create audio thread"); return (-1); } break; @@ -650,8 +650,8 @@ break; } #else - SDL_mutexV (audio->mixer_lock); - D (bug ("SDL_OpenAudio USCITA...\n")); + SDL_mutexV(audio->mixer_lock); + D(bug("SDL_OpenAudio USCITA...\n")); #endif @@ -659,7 +659,7 @@ } SDL_audiostatus -SDL_GetAudioStatus (void) +SDL_GetAudioStatus(void) { SDL_AudioDevice *audio = current_audio; SDL_audiostatus status; @@ -676,7 +676,7 @@ } void -SDL_PauseAudio (int pause_on) +SDL_PauseAudio(int pause_on) { SDL_AudioDevice *audio = current_audio; @@ -686,61 +686,61 @@ } void -SDL_LockAudio (void) +SDL_LockAudio(void) { SDL_AudioDevice *audio = current_audio; /* Obtain a lock on the mixing buffers */ if (audio && audio->LockAudio) { - audio->LockAudio (audio); + audio->LockAudio(audio); } } void -SDL_UnlockAudio (void) +SDL_UnlockAudio(void) { SDL_AudioDevice *audio = current_audio; /* Release lock on the mixing buffers */ if (audio && audio->UnlockAudio) { - audio->UnlockAudio (audio); + audio->UnlockAudio(audio); } } void -SDL_CloseAudio (void) +SDL_CloseAudio(void) { - SDL_QuitSubSystem (SDL_INIT_AUDIO); + SDL_QuitSubSystem(SDL_INIT_AUDIO); } void -SDL_AudioQuit (void) +SDL_AudioQuit(void) { SDL_AudioDevice *audio = current_audio; if (audio) { audio->enabled = 0; if (audio->thread != NULL) { - SDL_WaitThread (audio->thread, NULL); + SDL_WaitThread(audio->thread, NULL); } if (audio->mixer_lock != NULL) { - SDL_DestroyMutex (audio->mixer_lock); + SDL_DestroyMutex(audio->mixer_lock); } if (audio->fake_stream != NULL) { - SDL_FreeAudioMem (audio->fake_stream); + SDL_FreeAudioMem(audio->fake_stream); } if (audio->convert.needed) { - SDL_FreeAudioMem (audio->convert.buf); + SDL_FreeAudioMem(audio->convert.buf); } #if !SDL_AUDIO_DRIVER_AHI if (audio->opened) { - audio->CloseAudio (audio); + audio->CloseAudio(audio); audio->opened = 0; } #endif /* Free the driver data */ - audio->free (audio); + audio->free(audio); current_audio = NULL; } } @@ -764,7 +764,7 @@ }; Uint16 -SDL_FirstAudioFormat (Uint16 format) +SDL_FirstAudioFormat(Uint16 format) { for (format_idx = 0; format_idx < NUM_FORMATS; ++format_idx) { if (format_list[format_idx][0] == format) { @@ -772,11 +772,11 @@ } } format_idx_sub = 0; - return (SDL_NextAudioFormat ()); + return (SDL_NextAudioFormat()); } Uint16 -SDL_NextAudioFormat (void) +SDL_NextAudioFormat(void) { if ((format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS)) { return (0); @@ -785,7 +785,7 @@ } void -SDL_CalculateAudioSpec (SDL_AudioSpec * spec) +SDL_CalculateAudioSpec(SDL_AudioSpec * spec) { switch (spec->format) { case AUDIO_U8: diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/SDL_audio_c.h --- a/src/audio/SDL_audio_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/SDL_audio_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,12 +24,12 @@ /* Functions and variables exported from SDL_audio.c for SDL_sysaudio.c */ /* Functions to get a list of "close" audio formats */ -extern Uint16 SDL_FirstAudioFormat (Uint16 format); -extern Uint16 SDL_NextAudioFormat (void); +extern Uint16 SDL_FirstAudioFormat(Uint16 format); +extern Uint16 SDL_NextAudioFormat(void); /* Function to calculate the size and silence for a SDL_AudioSpec */ -extern void SDL_CalculateAudioSpec (SDL_AudioSpec * spec); +extern void SDL_CalculateAudioSpec(SDL_AudioSpec * spec); /* The actual mixing thread function */ -extern int SDLCALL SDL_RunAudio (void *audiop); +extern int SDLCALL SDL_RunAudio(void *audiop); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/SDL_audiocvt.c --- a/src/audio/SDL_audiocvt.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/SDL_audiocvt.c Mon May 29 04:04:35 2006 +0000 @@ -28,13 +28,13 @@ /* Effectively mix right and left channels into a single channel */ void SDLCALL -SDL_ConvertMono (SDL_AudioCVT * cvt, Uint16 format) +SDL_ConvertMono(SDL_AudioCVT * cvt, Uint16 format) { int i; Sint32 sample; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting to mono\n"); + fprintf(stderr, "Converting to mono\n"); #endif switch (format & 0x8018) { @@ -172,13 +172,13 @@ /* Discard top 4 channels */ void SDLCALL -SDL_ConvertStrip (SDL_AudioCVT * cvt, Uint16 format) +SDL_ConvertStrip(SDL_AudioCVT * cvt, Uint16 format) { int i; Sint32 lsample, rsample; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting down to stereo\n"); + fprintf(stderr, "Converting down to stereo\n"); #endif switch (format & 0x8018) { @@ -293,13 +293,13 @@ /* Discard top 2 channels of 6 */ void SDLCALL -SDL_ConvertStrip_2 (SDL_AudioCVT * cvt, Uint16 format) +SDL_ConvertStrip_2(SDL_AudioCVT * cvt, Uint16 format) { int i; Sint32 lsample, rsample; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting 6 down to quad\n"); + fprintf(stderr, "Converting 6 down to quad\n"); #endif switch (format & 0x8018) { @@ -413,12 +413,12 @@ /* Duplicate a mono channel to both stereo channels */ void SDLCALL -SDL_ConvertStereo (SDL_AudioCVT * cvt, Uint16 format) +SDL_ConvertStereo(SDL_AudioCVT * cvt, Uint16 format) { int i; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting to stereo\n"); + fprintf(stderr, "Converting to stereo\n"); #endif if ((format & 0xFF) == 16) { Uint16 *src, *dst; @@ -452,12 +452,12 @@ /* Duplicate a stereo channel to a pseudo-5.1 stream */ void SDLCALL -SDL_ConvertSurround (SDL_AudioCVT * cvt, Uint16 format) +SDL_ConvertSurround(SDL_AudioCVT * cvt, Uint16 format) { int i; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting stereo to surround\n"); + fprintf(stderr, "Converting stereo to surround\n"); #endif switch (format & 0x8018) { @@ -634,12 +634,12 @@ /* Duplicate a stereo channel to a pseudo-4.0 stream */ void SDLCALL -SDL_ConvertSurround_4 (SDL_AudioCVT * cvt, Uint16 format) +SDL_ConvertSurround_4(SDL_AudioCVT * cvt, Uint16 format) { int i; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting stereo to quad\n"); + fprintf(stderr, "Converting stereo to quad\n"); #endif switch (format & 0x8018) { @@ -792,13 +792,13 @@ /* Convert 8-bit to 16-bit - LSB */ void SDLCALL -SDL_Convert16LSB (SDL_AudioCVT * cvt, Uint16 format) +SDL_Convert16LSB(SDL_AudioCVT * cvt, Uint16 format) { int i; Uint8 *src, *dst; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting to 16-bit LSB\n"); + fprintf(stderr, "Converting to 16-bit LSB\n"); #endif src = cvt->buf + cvt->len_cvt; dst = cvt->buf + cvt->len_cvt * 2; @@ -817,13 +817,13 @@ /* Convert 8-bit to 16-bit - MSB */ void SDLCALL -SDL_Convert16MSB (SDL_AudioCVT * cvt, Uint16 format) +SDL_Convert16MSB(SDL_AudioCVT * cvt, Uint16 format) { int i; Uint8 *src, *dst; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting to 16-bit MSB\n"); + fprintf(stderr, "Converting to 16-bit MSB\n"); #endif src = cvt->buf + cvt->len_cvt; dst = cvt->buf + cvt->len_cvt * 2; @@ -842,13 +842,13 @@ /* Convert 16-bit to 8-bit */ void SDLCALL -SDL_Convert8 (SDL_AudioCVT * cvt, Uint16 format) +SDL_Convert8(SDL_AudioCVT * cvt, Uint16 format) { int i; Uint8 *src, *dst; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting to 8-bit\n"); + fprintf(stderr, "Converting to 8-bit\n"); #endif src = cvt->buf; dst = cvt->buf; @@ -869,13 +869,13 @@ /* Toggle signed/unsigned */ void SDLCALL -SDL_ConvertSign (SDL_AudioCVT * cvt, Uint16 format) +SDL_ConvertSign(SDL_AudioCVT * cvt, Uint16 format) { int i; Uint8 *data; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting audio signedness\n"); + fprintf(stderr, "Converting audio signedness\n"); #endif data = cvt->buf; if ((format & 0xFF) == 16) { @@ -899,13 +899,13 @@ /* Toggle endianness */ void SDLCALL -SDL_ConvertEndian (SDL_AudioCVT * cvt, Uint16 format) +SDL_ConvertEndian(SDL_AudioCVT * cvt, Uint16 format) { int i; Uint8 *data, tmp; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting audio endianness\n"); + fprintf(stderr, "Converting audio endianness\n"); #endif data = cvt->buf; for (i = cvt->len_cvt / 2; i; --i) { @@ -922,13 +922,13 @@ /* Convert rate up by multiple of 2 */ void SDLCALL -SDL_RateMUL2 (SDL_AudioCVT * cvt, Uint16 format) +SDL_RateMUL2(SDL_AudioCVT * cvt, Uint16 format) { int i; Uint8 *src, *dst; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting audio rate * 2\n"); + fprintf(stderr, "Converting audio rate * 2\n"); #endif src = cvt->buf + cvt->len_cvt; dst = cvt->buf + cvt->len_cvt * 2; @@ -961,13 +961,13 @@ /* Convert rate up by multiple of 2, for stereo */ void SDLCALL -SDL_RateMUL2_c2 (SDL_AudioCVT * cvt, Uint16 format) +SDL_RateMUL2_c2(SDL_AudioCVT * cvt, Uint16 format) { int i; Uint8 *src, *dst; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting audio rate * 2\n"); + fprintf(stderr, "Converting audio rate * 2\n"); #endif src = cvt->buf + cvt->len_cvt; dst = cvt->buf + cvt->len_cvt * 2; @@ -1005,13 +1005,13 @@ /* Convert rate up by multiple of 2, for quad */ void SDLCALL -SDL_RateMUL2_c4 (SDL_AudioCVT * cvt, Uint16 format) +SDL_RateMUL2_c4(SDL_AudioCVT * cvt, Uint16 format) { int i; Uint8 *src, *dst; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting audio rate * 2\n"); + fprintf(stderr, "Converting audio rate * 2\n"); #endif src = cvt->buf + cvt->len_cvt; dst = cvt->buf + cvt->len_cvt * 2; @@ -1062,13 +1062,13 @@ /* Convert rate up by multiple of 2, for 5.1 */ void SDLCALL -SDL_RateMUL2_c6 (SDL_AudioCVT * cvt, Uint16 format) +SDL_RateMUL2_c6(SDL_AudioCVT * cvt, Uint16 format) { int i; Uint8 *src, *dst; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting audio rate * 2\n"); + fprintf(stderr, "Converting audio rate * 2\n"); #endif src = cvt->buf + cvt->len_cvt; dst = cvt->buf + cvt->len_cvt * 2; @@ -1130,13 +1130,13 @@ /* Convert rate down by multiple of 2 */ void SDLCALL -SDL_RateDIV2 (SDL_AudioCVT * cvt, Uint16 format) +SDL_RateDIV2(SDL_AudioCVT * cvt, Uint16 format) { int i; Uint8 *src, *dst; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting audio rate / 2\n"); + fprintf(stderr, "Converting audio rate / 2\n"); #endif src = cvt->buf; dst = cvt->buf; @@ -1166,13 +1166,13 @@ /* Convert rate down by multiple of 2, for stereo */ void SDLCALL -SDL_RateDIV2_c2 (SDL_AudioCVT * cvt, Uint16 format) +SDL_RateDIV2_c2(SDL_AudioCVT * cvt, Uint16 format) { int i; Uint8 *src, *dst; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting audio rate / 2\n"); + fprintf(stderr, "Converting audio rate / 2\n"); #endif src = cvt->buf; dst = cvt->buf; @@ -1205,13 +1205,13 @@ /* Convert rate down by multiple of 2, for quad */ void SDLCALL -SDL_RateDIV2_c4 (SDL_AudioCVT * cvt, Uint16 format) +SDL_RateDIV2_c4(SDL_AudioCVT * cvt, Uint16 format) { int i; Uint8 *src, *dst; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting audio rate / 2\n"); + fprintf(stderr, "Converting audio rate / 2\n"); #endif src = cvt->buf; dst = cvt->buf; @@ -1249,13 +1249,13 @@ /* Convert rate down by multiple of 2, for 5.1 */ void SDLCALL -SDL_RateDIV2_c6 (SDL_AudioCVT * cvt, Uint16 format) +SDL_RateDIV2_c6(SDL_AudioCVT * cvt, Uint16 format) { int i; Uint8 *src, *dst; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting audio rate / 2\n"); + fprintf(stderr, "Converting audio rate / 2\n"); #endif src = cvt->buf; dst = cvt->buf; @@ -1299,13 +1299,13 @@ /* Very slow rate conversion routine */ void SDLCALL -SDL_RateSLOW (SDL_AudioCVT * cvt, Uint16 format) +SDL_RateSLOW(SDL_AudioCVT * cvt, Uint16 format) { double ipos; int i, clen; #ifdef DEBUG_CONVERT - fprintf (stderr, "Converting audio rate * %4.4f\n", 1.0 / cvt->rate_incr); + fprintf(stderr, "Converting audio rate * %4.4f\n", 1.0 / cvt->rate_incr); #endif clen = (int) ((double) cvt->len_cvt / cvt->rate_incr); if (cvt->rate_incr > 1.0) { @@ -1378,11 +1378,11 @@ } int -SDL_ConvertAudio (SDL_AudioCVT * cvt) +SDL_ConvertAudio(SDL_AudioCVT * cvt) { /* Make sure there's data to convert */ if (cvt->buf == NULL) { - SDL_SetError ("No buffer allocated for conversion"); + SDL_SetError("No buffer allocated for conversion"); return (-1); } /* Return okay if no conversion is necessary */ @@ -1403,9 +1403,9 @@ */ int -SDL_BuildAudioCVT (SDL_AudioCVT * cvt, - Uint16 src_format, Uint8 src_channels, int src_rate, - Uint16 dst_format, Uint8 dst_channels, int dst_rate) +SDL_BuildAudioCVT(SDL_AudioCVT * cvt, + Uint16 src_format, Uint8 src_channels, int src_rate, + Uint16 dst_format, Uint8 dst_channels, int dst_rate) { /*printf("Build format %04x->%04x, channels %u->%u, rate %d->%d\n", src_format, dst_format, src_channels, dst_channels, src_rate, dst_rate);*/ diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/SDL_audiodev.c --- a/src/audio/SDL_audiodev.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/SDL_audiodev.c Mon May 29 04:04:35 2006 +0000 @@ -48,52 +48,52 @@ int -SDL_OpenAudioPath (char *path, int maxlen, int flags, int classic) +SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic) { const char *audiodev; int audio_fd; char audiopath[1024]; /* Figure out what our audio device is */ - if (((audiodev = SDL_getenv ("SDL_PATH_DSP")) == NULL) && - ((audiodev = SDL_getenv ("AUDIODEV")) == NULL)) { + if (((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) && + ((audiodev = SDL_getenv("AUDIODEV")) == NULL)) { if (classic) { audiodev = _PATH_DEV_AUDIO; } else { struct stat sb; /* Added support for /dev/sound/\* in Linux 2.4 */ - if (((stat ("/dev/sound", &sb) == 0) && S_ISDIR (sb.st_mode)) - && ((stat (_PATH_DEV_DSP24, &sb) == 0) - && S_ISCHR (sb.st_mode))) { + if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) + && ((stat(_PATH_DEV_DSP24, &sb) == 0) + && S_ISCHR(sb.st_mode))) { audiodev = _PATH_DEV_DSP24; } else { audiodev = _PATH_DEV_DSP; } } } - audio_fd = open (audiodev, flags, 0); + audio_fd = open(audiodev, flags, 0); /* If the first open fails, look for other devices */ - if ((audio_fd < 0) && (SDL_strlen (audiodev) < (sizeof (audiopath) - 3))) { + if ((audio_fd < 0) && (SDL_strlen(audiodev) < (sizeof(audiopath) - 3))) { int exists, instance; struct stat sb; instance = 1; do { /* Don't use errno ENOENT - it may not be thread-safe */ - SDL_snprintf (audiopath, SDL_arraysize (audiopath), - "%s%d", audiodev, instance++); + SDL_snprintf(audiopath, SDL_arraysize(audiopath), + "%s%d", audiodev, instance++); exists = 0; - if (stat (audiopath, &sb) == 0) { + if (stat(audiopath, &sb) == 0) { exists = 1; - audio_fd = open (audiopath, flags, 0); + audio_fd = open(audiopath, flags, 0); } } while (exists && (audio_fd < 0)); audiodev = audiopath; } if (path != NULL) { - SDL_strlcpy (path, audiodev, maxlen); + SDL_strlcpy(path, audiodev, maxlen); path[maxlen - 1] = '\0'; } return (audio_fd); @@ -126,51 +126,51 @@ }; static int -OpenUserDefinedDevice (char *path, int maxlen, int flags) +OpenUserDefinedDevice(char *path, int maxlen, int flags) { const char *audiodev; int audio_fd; /* Figure out what our audio device is */ - if ((audiodev = SDL_getenv ("SDL_PATH_DSP")) == NULL) { - audiodev = SDL_getenv ("AUDIODEV"); + if ((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) { + audiodev = SDL_getenv("AUDIODEV"); } if (audiodev == NULL) { return -1; } - audio_fd = open (audiodev, flags, 0); + audio_fd = open(audiodev, flags, 0); if (path != NULL) { - SDL_strlcpy (path, audiodev, maxlen); + SDL_strlcpy(path, audiodev, maxlen); path[maxlen - 1] = '\0'; } return audio_fd; } int -SDL_OpenAudioPath (char *path, int maxlen, int flags, int classic) +SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic) { struct stat sb; int audio_fd; char audiopath[1024]; int cycle; - audio_fd = OpenUserDefinedDevice (path, maxlen, flags); + audio_fd = OpenUserDefinedDevice(path, maxlen, flags); if (audio_fd != -1) { return audio_fd; } cycle = 0; while (devsettings[cycle][0] != '\0') { - SDL_snprintf (audiopath, SDL_arraysize (audiopath), - _PATH_DEV_DSP, - devsettings[cycle][0], - devsettings[cycle][1], devsettings[cycle][2]); + SDL_snprintf(audiopath, SDL_arraysize(audiopath), + _PATH_DEV_DSP, + devsettings[cycle][0], + devsettings[cycle][1], devsettings[cycle][2]); - if (stat (audiopath, &sb) == 0) { - audio_fd = open (audiopath, flags, 0); + if (stat(audiopath, &sb) == 0) { + audio_fd = open(audiopath, flags, 0); if (audio_fd > 0) { if (path != NULL) { - SDL_strlcpy (path, audiopath, maxlen); + SDL_strlcpy(path, audiopath, maxlen); } return audio_fd; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/SDL_audiodev_c.h --- a/src/audio/SDL_audiodev_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/SDL_audiodev_c.h Mon May 29 04:04:35 2006 +0000 @@ -22,5 +22,5 @@ #include "SDL_config.h" /* Open the audio device, storing the pathname in 'path' */ -extern int SDL_OpenAudioPath (char *path, int maxlen, int flags, int classic); +extern int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/SDL_mixer.c --- a/src/audio/SDL_mixer.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/SDL_mixer.c Mon May 29 04:04:35 2006 +0000 @@ -90,7 +90,7 @@ #define ADJUST_VOLUME_U8(s, v) (s = (((s-128)*v)/SDL_MIX_MAXVOLUME)+128) void -SDL_MixAudio (Uint8 * dst, const Uint8 * src, Uint32 len, int volume) +SDL_MixAudio(Uint8 * dst, const Uint8 * src, Uint32 len, int volume) { Uint16 format; @@ -113,15 +113,15 @@ case AUDIO_U8: { #if defined(__GNUC__) && defined(__M68000__) && defined(SDL_ASSEMBLY_ROUTINES) - SDL_MixAudio_m68k_U8 ((char *) dst, (char *) src, - (unsigned long) len, (long) volume, - (char *) mix8); + SDL_MixAudio_m68k_U8((char *) dst, (char *) src, + (unsigned long) len, (long) volume, + (char *) mix8); #else Uint8 src_sample; while (len--) { src_sample = *src; - ADJUST_VOLUME_U8 (src_sample, volume); + ADJUST_VOLUME_U8(src_sample, volume); *dst = mix8[*dst + src_sample]; ++dst; ++src; @@ -133,19 +133,19 @@ case AUDIO_S8: { #if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES) - if (SDL_HasMMX ()) { - SDL_MixAudio_MMX_S8 ((char *) dst, (char *) src, - (unsigned int) len, (int) volume); + if (SDL_HasMMX()) { + SDL_MixAudio_MMX_S8((char *) dst, (char *) src, + (unsigned int) len, (int) volume); } else #elif ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES) - if (SDL_HasMMX ()) { - SDL_MixAudio_MMX_S8_VC ((char *) dst, (char *) src, - (unsigned int) len, (int) volume); + if (SDL_HasMMX()) { + SDL_MixAudio_MMX_S8_VC((char *) dst, (char *) src, + (unsigned int) len, (int) volume); } else #endif #if defined(__GNUC__) && defined(__M68000__) && defined(SDL_ASSEMBLY_ROUTINES) - SDL_MixAudio_m68k_S8 ((char *) dst, (char *) src, - (unsigned long) len, (long) volume); + SDL_MixAudio_m68k_S8((char *) dst, (char *) src, + (unsigned long) len, (long) volume); #else { Sint8 *dst8, *src8; @@ -158,7 +158,7 @@ dst8 = (Sint8 *) dst; while (len--) { src_sample = *src8; - ADJUST_VOLUME (src_sample, volume); + ADJUST_VOLUME(src_sample, volume); dst_sample = *dst8 + src_sample; if (dst_sample > max_audioval) { *dst8 = max_audioval; @@ -178,19 +178,19 @@ case AUDIO_S16LSB: { #if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES) - if (SDL_HasMMX ()) { - SDL_MixAudio_MMX_S16 ((char *) dst, (char *) src, - (unsigned int) len, (int) volume); + if (SDL_HasMMX()) { + SDL_MixAudio_MMX_S16((char *) dst, (char *) src, + (unsigned int) len, (int) volume); } else #elif ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES) - if (SDL_HasMMX ()) { - SDL_MixAudio_MMX_S16_VC ((char *) dst, (char *) src, - (unsigned int) len, (int) volume); + if (SDL_HasMMX()) { + SDL_MixAudio_MMX_S16_VC((char *) dst, (char *) src, + (unsigned int) len, (int) volume); } else #endif #if defined(__GNUC__) && defined(__M68000__) && defined(SDL_ASSEMBLY_ROUTINES) - SDL_MixAudio_m68k_S16LSB ((short *) dst, (short *) src, - (unsigned long) len, (long) volume); + SDL_MixAudio_m68k_S16LSB((short *) dst, (short *) src, + (unsigned long) len, (long) volume); #else { Sint16 src1, src2; @@ -201,7 +201,7 @@ len /= 2; while (len--) { src1 = ((src[1]) << 8 | src[0]); - ADJUST_VOLUME (src1, volume); + ADJUST_VOLUME(src1, volume); src2 = ((dst[1]) << 8 | dst[0]); src += 2; dst_sample = src1 + src2; @@ -223,8 +223,8 @@ case AUDIO_S16MSB: { #if defined(__GNUC__) && defined(__M68000__) && defined(SDL_ASSEMBLY_ROUTINES) - SDL_MixAudio_m68k_S16MSB ((short *) dst, (short *) src, - (unsigned long) len, (long) volume); + SDL_MixAudio_m68k_S16MSB((short *) dst, (short *) src, + (unsigned long) len, (long) volume); #else Sint16 src1, src2; int dst_sample; @@ -234,7 +234,7 @@ len /= 2; while (len--) { src1 = ((src[0]) << 8 | src[1]); - ADJUST_VOLUME (src1, volume); + ADJUST_VOLUME(src1, volume); src2 = ((dst[0]) << 8 | dst[1]); src += 2; dst_sample = src1 + src2; @@ -253,7 +253,7 @@ break; default: /* If this happens... FIXME! */ - SDL_SetError ("SDL_MixAudio(): unknown audio format"); + SDL_SetError("SDL_MixAudio(): unknown audio format"); return; } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/SDL_mixer_MMX.c --- a/src/audio/SDL_mixer_MMX.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/SDL_mixer_MMX.c Mon May 29 04:04:35 2006 +0000 @@ -37,49 +37,49 @@ #if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES) void -SDL_MixAudio_MMX_S16 (char *dst, char *src, unsigned int size, int volume) +SDL_MixAudio_MMX_S16(char *dst, char *src, unsigned int size, int volume) { - __asm__ __volatile__ (" movl %3,%%eax\n" /* eax = volume */ - " movl %2,%%edx\n" /* edx = size */ - " shrl $4,%%edx\n" /* process 16 bytes per iteration = 8 samples */ - " jz .endS16\n" " pxor %%mm0,%%mm0\n" " movd %%eax,%%mm0\n" " movq %%mm0,%%mm1\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" /* mm0 = vol|vol|vol|vol */ - ".align 8\n" " .mixloopS16:\n" " movq (%1),%%mm1\n" /* mm1 = a|b|c|d */ - " movq %%mm1,%%mm2\n" /* mm2 = a|b|c|d */ - " movq 8(%1),%%mm4\n" /* mm4 = e|f|g|h */ - /* pré charger le buffer dst dans mm7 */ - " movq (%0),%%mm7\n" /* mm7 = dst[0] */ - /* multiplier par le volume */ - " pmullw %%mm0,%%mm1\n" /* mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */ - " pmulhw %%mm0,%%mm2\n" /* mm2 = h(a*v)|h(b*v)|h(c*v)|h(d*v) */ - " movq %%mm4,%%mm5\n" /* mm5 = e|f|g|h */ - " pmullw %%mm0,%%mm4\n" /* mm4 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */ - " pmulhw %%mm0,%%mm5\n" /* mm5 = h(e*v)|h(f*v)|h(g*v)|h(h*v) */ - " movq %%mm1,%%mm3\n" /* mm3 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */ - " punpckhwd %%mm2,%%mm1\n" /* mm1 = a*v|b*v */ - " movq %%mm4,%%mm6\n" /* mm6 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */ - " punpcklwd %%mm2,%%mm3\n" /* mm3 = c*v|d*v */ - " punpckhwd %%mm5,%%mm4\n" /* mm4 = e*f|f*v */ - " punpcklwd %%mm5,%%mm6\n" /* mm6 = g*v|h*v */ - /* pré charger le buffer dst dans mm5 */ - " movq 8(%0),%%mm5\n" /* mm5 = dst[1] */ - /* diviser par 128 */ - " psrad $7,%%mm1\n" /* mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME */ - " add $16,%1\n" " psrad $7,%%mm3\n" /* mm3 = c*v/128|d*v/128 */ - " psrad $7,%%mm4\n" /* mm4 = e*v/128|f*v/128 */ - /* mm1 = le sample avec le volume modifié */ - " packssdw %%mm1,%%mm3\n" /* mm3 = s(a*v|b*v|c*v|d*v) */ - " psrad $7,%%mm6\n" /* mm6= g*v/128|h*v/128 */ - " paddsw %%mm7,%%mm3\n" /* mm3 = adjust_volume(src)+dst */ - /* mm4 = le sample avec le volume modifié */ - " packssdw %%mm4,%%mm6\n" /* mm6 = s(e*v|f*v|g*v|h*v) */ - " movq %%mm3,(%0)\n" " paddsw %%mm5,%%mm6\n" /* mm6 = adjust_volume(src)+dst */ - " movq %%mm6,8(%0)\n" - " add $16,%0\n" - " dec %%edx\n" - " jnz .mixloopS16\n" - " emms\n" - ".endS16:\n"::"r" (dst), "r" (src), - "m" (size), "m" (volume):"eax", "edx", "memory"); + __asm__ __volatile__(" movl %3,%%eax\n" /* eax = volume */ + " movl %2,%%edx\n" /* edx = size */ + " shrl $4,%%edx\n" /* process 16 bytes per iteration = 8 samples */ + " jz .endS16\n" " pxor %%mm0,%%mm0\n" " movd %%eax,%%mm0\n" " movq %%mm0,%%mm1\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" /* mm0 = vol|vol|vol|vol */ + ".align 8\n" " .mixloopS16:\n" " movq (%1),%%mm1\n" /* mm1 = a|b|c|d */ + " movq %%mm1,%%mm2\n" /* mm2 = a|b|c|d */ + " movq 8(%1),%%mm4\n" /* mm4 = e|f|g|h */ + /* pré charger le buffer dst dans mm7 */ + " movq (%0),%%mm7\n" /* mm7 = dst[0] */ + /* multiplier par le volume */ + " pmullw %%mm0,%%mm1\n" /* mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */ + " pmulhw %%mm0,%%mm2\n" /* mm2 = h(a*v)|h(b*v)|h(c*v)|h(d*v) */ + " movq %%mm4,%%mm5\n" /* mm5 = e|f|g|h */ + " pmullw %%mm0,%%mm4\n" /* mm4 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */ + " pmulhw %%mm0,%%mm5\n" /* mm5 = h(e*v)|h(f*v)|h(g*v)|h(h*v) */ + " movq %%mm1,%%mm3\n" /* mm3 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */ + " punpckhwd %%mm2,%%mm1\n" /* mm1 = a*v|b*v */ + " movq %%mm4,%%mm6\n" /* mm6 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */ + " punpcklwd %%mm2,%%mm3\n" /* mm3 = c*v|d*v */ + " punpckhwd %%mm5,%%mm4\n" /* mm4 = e*f|f*v */ + " punpcklwd %%mm5,%%mm6\n" /* mm6 = g*v|h*v */ + /* pré charger le buffer dst dans mm5 */ + " movq 8(%0),%%mm5\n" /* mm5 = dst[1] */ + /* diviser par 128 */ + " psrad $7,%%mm1\n" /* mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME */ + " add $16,%1\n" " psrad $7,%%mm3\n" /* mm3 = c*v/128|d*v/128 */ + " psrad $7,%%mm4\n" /* mm4 = e*v/128|f*v/128 */ + /* mm1 = le sample avec le volume modifié */ + " packssdw %%mm1,%%mm3\n" /* mm3 = s(a*v|b*v|c*v|d*v) */ + " psrad $7,%%mm6\n" /* mm6= g*v/128|h*v/128 */ + " paddsw %%mm7,%%mm3\n" /* mm3 = adjust_volume(src)+dst */ + /* mm4 = le sample avec le volume modifié */ + " packssdw %%mm4,%%mm6\n" /* mm6 = s(e*v|f*v|g*v|h*v) */ + " movq %%mm3,(%0)\n" " paddsw %%mm5,%%mm6\n" /* mm6 = adjust_volume(src)+dst */ + " movq %%mm6,8(%0)\n" + " add $16,%0\n" + " dec %%edx\n" + " jnz .mixloopS16\n" + " emms\n" + ".endS16:\n"::"r"(dst), "r"(src), + "m"(size), "m"(volume):"eax", "edx", "memory"); } @@ -89,32 +89,32 @@ /*////////////////////////////////////////////// */ void -SDL_MixAudio_MMX_S8 (char *dst, char *src, unsigned int size, int volume) +SDL_MixAudio_MMX_S8(char *dst, char *src, unsigned int size, int volume) { - __asm__ __volatile__ (" movl %3,%%eax\n" /* eax = volume */ - " movd %%eax,%%mm0\n" " movq %%mm0,%%mm1\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " movl %2,%%edx\n" /* edx = size */ - " shr $3,%%edx\n" /* process 8 bytes per iteration = 8 samples */ - " cmp $0,%%edx\n" " je .endS8\n" ".align 8\n" " .mixloopS8:\n" " pxor %%mm2,%%mm2\n" /* mm2 = 0 */ - " movq (%1),%%mm1\n" /* mm1 = a|b|c|d|e|f|g|h */ - " movq %%mm1,%%mm3\n" /* mm3 = a|b|c|d|e|f|g|h */ - /* on va faire le "sign extension" en faisant un cmp avec 0 qui retourne 1 si <0, 0 si >0 */ - " pcmpgtb %%mm1,%%mm2\n" /* mm2 = 11111111|00000000|00000000.... */ - " punpckhbw %%mm2,%%mm1\n" /* mm1 = 0|a|0|b|0|c|0|d */ - " punpcklbw %%mm2,%%mm3\n" /* mm3 = 0|e|0|f|0|g|0|h */ - " movq (%0),%%mm2\n" /* mm2 = destination */ - " pmullw %%mm0,%%mm1\n" /* mm1 = v*a|v*b|v*c|v*d */ - " add $8,%1\n" " pmullw %%mm0,%%mm3\n" /* mm3 = v*e|v*f|v*g|v*h */ - " psraw $7,%%mm1\n" /* mm1 = v*a/128|v*b/128|v*c/128|v*d/128 */ - " psraw $7,%%mm3\n" /* mm3 = v*e/128|v*f/128|v*g/128|v*h/128 */ - " packsswb %%mm1,%%mm3\n" /* mm1 = v*a/128|v*b/128|v*c/128|v*d/128|v*e/128|v*f/128|v*g/128|v*h/128 */ - " paddsb %%mm2,%%mm3\n" /* add to destination buffer */ - " movq %%mm3,(%0)\n" /* store back to ram */ - " add $8,%0\n" - " dec %%edx\n" - " jnz .mixloopS8\n" - ".endS8:\n" - " emms\n"::"r" (dst), "r" (src), "m" (size), - "m" (volume):"eax", "edx", "memory"); + __asm__ __volatile__(" movl %3,%%eax\n" /* eax = volume */ + " movd %%eax,%%mm0\n" " movq %%mm0,%%mm1\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " movl %2,%%edx\n" /* edx = size */ + " shr $3,%%edx\n" /* process 8 bytes per iteration = 8 samples */ + " cmp $0,%%edx\n" " je .endS8\n" ".align 8\n" " .mixloopS8:\n" " pxor %%mm2,%%mm2\n" /* mm2 = 0 */ + " movq (%1),%%mm1\n" /* mm1 = a|b|c|d|e|f|g|h */ + " movq %%mm1,%%mm3\n" /* mm3 = a|b|c|d|e|f|g|h */ + /* on va faire le "sign extension" en faisant un cmp avec 0 qui retourne 1 si <0, 0 si >0 */ + " pcmpgtb %%mm1,%%mm2\n" /* mm2 = 11111111|00000000|00000000.... */ + " punpckhbw %%mm2,%%mm1\n" /* mm1 = 0|a|0|b|0|c|0|d */ + " punpcklbw %%mm2,%%mm3\n" /* mm3 = 0|e|0|f|0|g|0|h */ + " movq (%0),%%mm2\n" /* mm2 = destination */ + " pmullw %%mm0,%%mm1\n" /* mm1 = v*a|v*b|v*c|v*d */ + " add $8,%1\n" " pmullw %%mm0,%%mm3\n" /* mm3 = v*e|v*f|v*g|v*h */ + " psraw $7,%%mm1\n" /* mm1 = v*a/128|v*b/128|v*c/128|v*d/128 */ + " psraw $7,%%mm3\n" /* mm3 = v*e/128|v*f/128|v*g/128|v*h/128 */ + " packsswb %%mm1,%%mm3\n" /* mm1 = v*a/128|v*b/128|v*c/128|v*d/128|v*e/128|v*f/128|v*g/128|v*h/128 */ + " paddsb %%mm2,%%mm3\n" /* add to destination buffer */ + " movq %%mm3,(%0)\n" /* store back to ram */ + " add $8,%0\n" + " dec %%edx\n" + " jnz .mixloopS8\n" + ".endS8:\n" + " emms\n"::"r"(dst), "r"(src), "m"(size), + "m"(volume):"eax", "edx", "memory"); } #endif /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/SDL_mixer_MMX.h --- a/src/audio/SDL_mixer_MMX.h Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/SDL_mixer_MMX.h Mon May 29 04:04:35 2006 +0000 @@ -9,7 +9,7 @@ #include "SDL_config.h" #if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES) -void SDL_MixAudio_MMX_S16 (char *, char *, unsigned int, int); -void SDL_MixAudio_MMX_S8 (char *, char *, unsigned int, int); +void SDL_MixAudio_MMX_S16(char *, char *, unsigned int, int); +void SDL_MixAudio_MMX_S8(char *, char *, unsigned int, int); #endif /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/SDL_mixer_MMX_VC.c --- a/src/audio/SDL_mixer_MMX_VC.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/SDL_mixer_MMX_VC.c Mon May 29 04:04:35 2006 +0000 @@ -38,7 +38,7 @@ //////////////////////////////////////////////// void -SDL_MixAudio_MMX_S16_VC (char *dst, char *src, unsigned int nSize, int volume) +SDL_MixAudio_MMX_S16_VC(char *dst, char *src, unsigned int nSize, int volume) { __asm { @@ -102,7 +102,7 @@ //////////////////////////////////////////////// void -SDL_MixAudio_MMX_S8_VC (char *dst, char *src, unsigned int nSize, int volume) +SDL_MixAudio_MMX_S8_VC(char *dst, char *src, unsigned int nSize, int volume) { _asm { diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/SDL_mixer_MMX_VC.h --- a/src/audio/SDL_mixer_MMX_VC.h Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/SDL_mixer_MMX_VC.h Mon May 29 04:04:35 2006 +0000 @@ -31,7 +31,7 @@ Assumes buffer size in bytes is a multiple of 16 Assumes SDL_MIX_MAXVOLUME = 128 */ -void SDL_MixAudio_MMX_S16_VC (char *, char *, unsigned int, int); -void SDL_MixAudio_MMX_S8_VC (char *, char *, unsigned int, int); +void SDL_MixAudio_MMX_S16_VC(char *, char *, unsigned int, int); +void SDL_MixAudio_MMX_S8_VC(char *, char *, unsigned int, int); #endif /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/SDL_mixer_m68k.c --- a/src/audio/SDL_mixer_m68k.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/SDL_mixer_m68k.c Mon May 29 04:04:35 2006 +0000 @@ -29,112 +29,112 @@ #if defined(__M68000__) && defined(__GNUC__) void -SDL_MixAudio_m68k_U8 (char *dst, char *src, long len, long volume, char *mix8) +SDL_MixAudio_m68k_U8(char *dst, char *src, long len, long volume, char *mix8) { - __asm__ __volatile__ ("tstl %2\n" " beqs stoploop_u8\n" "mixloop_u8:\n" - /* Mix a sample */ - " moveq #0,%%d0\n" " moveq #0,%%d1\n" " moveb %1@+,%%d0\n" /* d0 = *src++ */ - " sub #128,%%d0\n" /* d0 -= 128 */ - " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */ - " moveb %0@,%%d1\n" /* d1 = *dst */ - " asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */ - " add #128,%%d0\n" /* d0 += 128 */ - " add %%d1,%%d0\n" - " moveb %4@(%%d0:w),%0@+\n" - /* Loop till done */ - " subql #1,%2\n" " bhis mixloop_u8\n" "stoploop_u8:\n": /* no return value */ - : /* input */ - "a" (dst), "a" (src), "d" (len), "d" (volume), "a" (mix8): /* clobbered registers */ - "d0", "d1", "cc", "memory"); + __asm__ __volatile__("tstl %2\n" " beqs stoploop_u8\n" "mixloop_u8:\n" + /* Mix a sample */ + " moveq #0,%%d0\n" " moveq #0,%%d1\n" " moveb %1@+,%%d0\n" /* d0 = *src++ */ + " sub #128,%%d0\n" /* d0 -= 128 */ + " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */ + " moveb %0@,%%d1\n" /* d1 = *dst */ + " asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */ + " add #128,%%d0\n" /* d0 += 128 */ + " add %%d1,%%d0\n" + " moveb %4@(%%d0:w),%0@+\n" + /* Loop till done */ + " subql #1,%2\n" " bhis mixloop_u8\n" "stoploop_u8:\n": /* no return value */ + : /* input */ + "a"(dst), "a"(src), "d"(len), "d"(volume), "a"(mix8): /* clobbered registers */ + "d0", "d1", "cc", "memory"); } void -SDL_MixAudio_m68k_S8 (char *dst, char *src, long len, long volume) +SDL_MixAudio_m68k_S8(char *dst, char *src, long len, long volume) { - __asm__ __volatile__ ("tstl %2\n" - " beqs stoploop_s8\n" - " moveq #-128,%%d2\n" - " moveq #127,%%d3\n" "mixloop_s8:\n" - /* Mix a sample */ - " moveq #0,%%d0\n" " moveq #0,%%d1\n" " moveb %1@+,%%d0\n" /* d0 = *src++ */ - " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */ - " moveb %0@,%%d1\n" /* d1 = *dst */ - " asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */ - " add %%d1,%%d0\n" - " cmp %%d2,%%d0\n" - " bges lower_limit_s8\n" - " move %%d2,%%d0\n" - "lower_limit_s8:\n" - " cmp %%d3,%%d0\n" - " bles upper_limit_s8\n" - " move %%d3,%%d0\n" - "upper_limit_s8:\n" " moveb %%d0,%0@+\n" - /* Loop till done */ - " subql #1,%2\n" " bhis mixloop_s8\n" "stoploop_s8:\n": /* no return value */ - : /* input */ - "a" (dst), "a" (src), "d" (len), "d" (volume): /* clobbered registers */ - "d0", "d1", "d2", "d3", "cc", "memory"); + __asm__ __volatile__("tstl %2\n" + " beqs stoploop_s8\n" + " moveq #-128,%%d2\n" + " moveq #127,%%d3\n" "mixloop_s8:\n" + /* Mix a sample */ + " moveq #0,%%d0\n" " moveq #0,%%d1\n" " moveb %1@+,%%d0\n" /* d0 = *src++ */ + " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */ + " moveb %0@,%%d1\n" /* d1 = *dst */ + " asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */ + " add %%d1,%%d0\n" + " cmp %%d2,%%d0\n" + " bges lower_limit_s8\n" + " move %%d2,%%d0\n" + "lower_limit_s8:\n" + " cmp %%d3,%%d0\n" + " bles upper_limit_s8\n" + " move %%d3,%%d0\n" + "upper_limit_s8:\n" " moveb %%d0,%0@+\n" + /* Loop till done */ + " subql #1,%2\n" " bhis mixloop_s8\n" "stoploop_s8:\n": /* no return value */ + : /* input */ + "a"(dst), "a"(src), "d"(len), "d"(volume): /* clobbered registers */ + "d0", "d1", "d2", "d3", "cc", "memory"); } void -SDL_MixAudio_m68k_S16MSB (short *dst, short *src, long len, long volume) +SDL_MixAudio_m68k_S16MSB(short *dst, short *src, long len, long volume) { - __asm__ __volatile__ ("tstl %2\n" - " beqs stoploop_s16msb\n" - " movel #-32768,%%d2\n" - " movel #32767,%%d3\n" - " lsrl #1,%2\n" "mixloop_s16msb:\n" - /* Mix a sample */ - " move %1@+,%%d0\n" /* d0 = *src++ */ - " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */ - " move %0@,%%d1\n" /* d1 = *dst */ - " extl %%d1\n" /* extend d1 to 32 bits */ - " asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */ - " addl %%d1,%%d0\n" - " cmpl %%d2,%%d0\n" - " bges lower_limit_s16msb\n" - " move %%d2,%%d0\n" - "lower_limit_s16msb:\n" - " cmpl %%d3,%%d0\n" - " bles upper_limit_s16msb\n" - " move %%d3,%%d0\n" - "upper_limit_s16msb:\n" " move %%d0,%0@+\n" - /* Loop till done */ - " subql #1,%2\n" " bhis mixloop_s16msb\n" "stoploop_s16msb:\n": /* no return value */ - : /* input */ - "a" (dst), "a" (src), "d" (len), "d" (volume): /* clobbered registers */ - "d0", "d1", "d2", "d3", "cc", "memory"); + __asm__ __volatile__("tstl %2\n" + " beqs stoploop_s16msb\n" + " movel #-32768,%%d2\n" + " movel #32767,%%d3\n" + " lsrl #1,%2\n" "mixloop_s16msb:\n" + /* Mix a sample */ + " move %1@+,%%d0\n" /* d0 = *src++ */ + " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */ + " move %0@,%%d1\n" /* d1 = *dst */ + " extl %%d1\n" /* extend d1 to 32 bits */ + " asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */ + " addl %%d1,%%d0\n" + " cmpl %%d2,%%d0\n" + " bges lower_limit_s16msb\n" + " move %%d2,%%d0\n" + "lower_limit_s16msb:\n" + " cmpl %%d3,%%d0\n" + " bles upper_limit_s16msb\n" + " move %%d3,%%d0\n" + "upper_limit_s16msb:\n" " move %%d0,%0@+\n" + /* Loop till done */ + " subql #1,%2\n" " bhis mixloop_s16msb\n" "stoploop_s16msb:\n": /* no return value */ + : /* input */ + "a"(dst), "a"(src), "d"(len), "d"(volume): /* clobbered registers */ + "d0", "d1", "d2", "d3", "cc", "memory"); } void -SDL_MixAudio_m68k_S16LSB (short *dst, short *src, long len, long volume) +SDL_MixAudio_m68k_S16LSB(short *dst, short *src, long len, long volume) { - __asm__ __volatile__ ("tstl %2\n" - " beqs stoploop_s16lsb\n" - " movel #-32768,%%d2\n" - " movel #32767,%%d3\n" - " lsrl #1,%2\n" "mixloop_s16lsb:\n" - /* Mix a sample */ - " move %1@+,%%d0\n" /* d0 = *src++ */ - " rorw #8,%%d0\n" " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */ - " move %0@,%%d1\n" /* d1 = *dst */ - " rorw #8,%%d1\n" " extl %%d1\n" /* extend d1 to 32 bits */ - " asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */ - " addl %%d1,%%d0\n" - " cmpl %%d2,%%d0\n" - " bges lower_limit_s16lsb\n" - " move %%d2,%%d0\n" - "lower_limit_s16lsb:\n" - " cmpl %%d3,%%d0\n" - " bles upper_limit_s16lsb\n" - " move %%d3,%%d0\n" - "upper_limit_s16lsb:\n" - " rorw #8,%%d0\n" " move %%d0,%0@+\n" - /* Loop till done */ - " subql #1,%2\n" " bhis mixloop_s16lsb\n" "stoploop_s16lsb:\n": /* no return value */ - : /* input */ - "a" (dst), "a" (src), "d" (len), "d" (volume): /* clobbered registers */ - "d0", "d1", "d2", "d3", "cc", "memory"); + __asm__ __volatile__("tstl %2\n" + " beqs stoploop_s16lsb\n" + " movel #-32768,%%d2\n" + " movel #32767,%%d3\n" + " lsrl #1,%2\n" "mixloop_s16lsb:\n" + /* Mix a sample */ + " move %1@+,%%d0\n" /* d0 = *src++ */ + " rorw #8,%%d0\n" " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */ + " move %0@,%%d1\n" /* d1 = *dst */ + " rorw #8,%%d1\n" " extl %%d1\n" /* extend d1 to 32 bits */ + " asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */ + " addl %%d1,%%d0\n" + " cmpl %%d2,%%d0\n" + " bges lower_limit_s16lsb\n" + " move %%d2,%%d0\n" + "lower_limit_s16lsb:\n" + " cmpl %%d3,%%d0\n" + " bles upper_limit_s16lsb\n" + " move %%d3,%%d0\n" + "upper_limit_s16lsb:\n" + " rorw #8,%%d0\n" " move %%d0,%0@+\n" + /* Loop till done */ + " subql #1,%2\n" " bhis mixloop_s16lsb\n" "stoploop_s16lsb:\n": /* no return value */ + : /* input */ + "a"(dst), "a"(src), "d"(len), "d"(volume): /* clobbered registers */ + "d0", "d1", "d2", "d3", "cc", "memory"); } #endif /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/SDL_mixer_m68k.h --- a/src/audio/SDL_mixer_m68k.h Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/SDL_mixer_m68k.h Mon May 29 04:04:35 2006 +0000 @@ -28,11 +28,11 @@ */ #if defined(__M68000__) && defined(__GNUC__) -void SDL_MixAudio_m68k_U8 (char *dst, char *src, long len, long volume, - char *mix8); -void SDL_MixAudio_m68k_S8 (char *dst, char *src, long len, long volume); +void SDL_MixAudio_m68k_U8(char *dst, char *src, long len, long volume, + char *mix8); +void SDL_MixAudio_m68k_S8(char *dst, char *src, long len, long volume); -void SDL_MixAudio_m68k_S16MSB (short *dst, short *src, long len, long volume); -void SDL_MixAudio_m68k_S16LSB (short *dst, short *src, long len, long volume); +void SDL_MixAudio_m68k_S16MSB(short *dst, short *src, long len, long volume); +void SDL_MixAudio_m68k_S16LSB(short *dst, short *src, long len, long volume); #endif /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/SDL_wave.c --- a/src/audio/SDL_wave.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/SDL_wave.c Mon May 29 04:04:35 2006 +0000 @@ -27,7 +27,7 @@ #include "SDL_wave.h" -static int ReadChunk (SDL_RWops * src, Chunk * chunk); +static int ReadChunk(SDL_RWops * src, Chunk * chunk); struct MS_ADPCM_decodestate { @@ -47,45 +47,45 @@ } MS_ADPCM_state; static int -InitMS_ADPCM (WaveFMT * format) +InitMS_ADPCM(WaveFMT * format) { Uint8 *rogue_feel; Uint16 extra_info; int i; /* Set the rogue pointer to the MS_ADPCM specific data */ - MS_ADPCM_state.wavefmt.encoding = SDL_SwapLE16 (format->encoding); - MS_ADPCM_state.wavefmt.channels = SDL_SwapLE16 (format->channels); - MS_ADPCM_state.wavefmt.frequency = SDL_SwapLE32 (format->frequency); - MS_ADPCM_state.wavefmt.byterate = SDL_SwapLE32 (format->byterate); - MS_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16 (format->blockalign); + MS_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding); + MS_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels); + MS_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency); + MS_ADPCM_state.wavefmt.byterate = SDL_SwapLE32(format->byterate); + MS_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16(format->blockalign); MS_ADPCM_state.wavefmt.bitspersample = - SDL_SwapLE16 (format->bitspersample); - rogue_feel = (Uint8 *) format + sizeof (*format); - if (sizeof (*format) == 16) { + SDL_SwapLE16(format->bitspersample); + rogue_feel = (Uint8 *) format + sizeof(*format); + if (sizeof(*format) == 16) { extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]); - rogue_feel += sizeof (Uint16); + rogue_feel += sizeof(Uint16); } MS_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1] << 8) | rogue_feel[0]); - rogue_feel += sizeof (Uint16); + rogue_feel += sizeof(Uint16); MS_ADPCM_state.wNumCoef = ((rogue_feel[1] << 8) | rogue_feel[0]); - rogue_feel += sizeof (Uint16); + rogue_feel += sizeof(Uint16); if (MS_ADPCM_state.wNumCoef != 7) { - SDL_SetError ("Unknown set of MS_ADPCM coefficients"); + SDL_SetError("Unknown set of MS_ADPCM coefficients"); return (-1); } for (i = 0; i < MS_ADPCM_state.wNumCoef; ++i) { MS_ADPCM_state.aCoeff[i][0] = ((rogue_feel[1] << 8) | rogue_feel[0]); - rogue_feel += sizeof (Uint16); + rogue_feel += sizeof(Uint16); MS_ADPCM_state.aCoeff[i][1] = ((rogue_feel[1] << 8) | rogue_feel[0]); - rogue_feel += sizeof (Uint16); + rogue_feel += sizeof(Uint16); } return (0); } static Sint32 -MS_ADPCM_nibble (struct MS_ADPCM_decodestate *state, - Uint8 nybble, Sint16 * coeff) +MS_ADPCM_nibble(struct MS_ADPCM_decodestate *state, + Uint8 nybble, Sint16 * coeff) { const Sint32 max_audioval = ((1 << (16 - 1)) - 1); const Sint32 min_audioval = -(1 << (16 - 1)); @@ -118,7 +118,7 @@ } static int -MS_ADPCM_decode (Uint8 ** audio_buf, Uint32 * audio_len) +MS_ADPCM_decode(Uint8 ** audio_buf, Uint32 * audio_len) { struct MS_ADPCM_decodestate *state[2]; Uint8 *freeable, *encoded, *decoded; @@ -133,10 +133,10 @@ freeable = *audio_buf; *audio_len = (encoded_len / MS_ADPCM_state.wavefmt.blockalign) * MS_ADPCM_state.wSamplesPerBlock * - MS_ADPCM_state.wavefmt.channels * sizeof (Sint16); - *audio_buf = (Uint8 *) SDL_malloc (*audio_len); + MS_ADPCM_state.wavefmt.channels * sizeof(Sint16); + *audio_buf = (Uint8 *) SDL_malloc(*audio_len); if (*audio_buf == NULL) { - SDL_Error (SDL_ENOMEM); + SDL_Error(SDL_ENOMEM); return (-1); } decoded = *audio_buf; @@ -152,22 +152,22 @@ state[1]->hPredictor = *encoded++; } state[0]->iDelta = ((encoded[1] << 8) | encoded[0]); - encoded += sizeof (Sint16); + encoded += sizeof(Sint16); if (stereo) { state[1]->iDelta = ((encoded[1] << 8) | encoded[0]); - encoded += sizeof (Sint16); + encoded += sizeof(Sint16); } state[0]->iSamp1 = ((encoded[1] << 8) | encoded[0]); - encoded += sizeof (Sint16); + encoded += sizeof(Sint16); if (stereo) { state[1]->iSamp1 = ((encoded[1] << 8) | encoded[0]); - encoded += sizeof (Sint16); + encoded += sizeof(Sint16); } state[0]->iSamp2 = ((encoded[1] << 8) | encoded[0]); - encoded += sizeof (Sint16); + encoded += sizeof(Sint16); if (stereo) { state[1]->iSamp2 = ((encoded[1] << 8) | encoded[0]); - encoded += sizeof (Sint16); + encoded += sizeof(Sint16); } coeff[0] = MS_ADPCM_state.aCoeff[state[0]->hPredictor]; coeff[1] = MS_ADPCM_state.aCoeff[state[1]->hPredictor]; @@ -195,14 +195,14 @@ MS_ADPCM_state.wavefmt.channels; while (samplesleft > 0) { nybble = (*encoded) >> 4; - new_sample = MS_ADPCM_nibble (state[0], nybble, coeff[0]); + new_sample = MS_ADPCM_nibble(state[0], nybble, coeff[0]); decoded[0] = new_sample & 0xFF; new_sample >>= 8; decoded[1] = new_sample & 0xFF; decoded += 2; nybble = (*encoded) & 0x0F; - new_sample = MS_ADPCM_nibble (state[1], nybble, coeff[1]); + new_sample = MS_ADPCM_nibble(state[1], nybble, coeff[1]); decoded[0] = new_sample & 0xFF; new_sample >>= 8; decoded[1] = new_sample & 0xFF; @@ -213,7 +213,7 @@ } encoded_len -= MS_ADPCM_state.wavefmt.blockalign; } - SDL_free (freeable); + SDL_free(freeable); return (0); } @@ -231,30 +231,30 @@ } IMA_ADPCM_state; static int -InitIMA_ADPCM (WaveFMT * format) +InitIMA_ADPCM(WaveFMT * format) { Uint8 *rogue_feel; Uint16 extra_info; /* Set the rogue pointer to the IMA_ADPCM specific data */ - IMA_ADPCM_state.wavefmt.encoding = SDL_SwapLE16 (format->encoding); - IMA_ADPCM_state.wavefmt.channels = SDL_SwapLE16 (format->channels); - IMA_ADPCM_state.wavefmt.frequency = SDL_SwapLE32 (format->frequency); - IMA_ADPCM_state.wavefmt.byterate = SDL_SwapLE32 (format->byterate); - IMA_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16 (format->blockalign); + IMA_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding); + IMA_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels); + IMA_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency); + IMA_ADPCM_state.wavefmt.byterate = SDL_SwapLE32(format->byterate); + IMA_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16(format->blockalign); IMA_ADPCM_state.wavefmt.bitspersample = - SDL_SwapLE16 (format->bitspersample); - rogue_feel = (Uint8 *) format + sizeof (*format); - if (sizeof (*format) == 16) { + SDL_SwapLE16(format->bitspersample); + rogue_feel = (Uint8 *) format + sizeof(*format); + if (sizeof(*format) == 16) { extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]); - rogue_feel += sizeof (Uint16); + rogue_feel += sizeof(Uint16); } IMA_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1] << 8) | rogue_feel[0]); return (0); } static Sint32 -IMA_ADPCM_nibble (struct IMA_ADPCM_decodestate *state, Uint8 nybble) +IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state, Uint8 nybble) { const Sint32 max_audioval = ((1 << (16 - 1)) - 1); const Sint32 min_audioval = -(1 << (16 - 1)); @@ -308,9 +308,9 @@ /* Fill the decode buffer with a channel block of data (8 samples) */ static void -Fill_IMA_ADPCM_block (Uint8 * decoded, Uint8 * encoded, - int channel, int numchannels, - struct IMA_ADPCM_decodestate *state) +Fill_IMA_ADPCM_block(Uint8 * decoded, Uint8 * encoded, + int channel, int numchannels, + struct IMA_ADPCM_decodestate *state) { int i; Sint8 nybble; @@ -319,14 +319,14 @@ decoded += (channel * 2); for (i = 0; i < 4; ++i) { nybble = (*encoded) & 0x0F; - new_sample = IMA_ADPCM_nibble (state, nybble); + new_sample = IMA_ADPCM_nibble(state, nybble); decoded[0] = new_sample & 0xFF; new_sample >>= 8; decoded[1] = new_sample & 0xFF; decoded += 2 * numchannels; nybble = (*encoded) >> 4; - new_sample = IMA_ADPCM_nibble (state, nybble); + new_sample = IMA_ADPCM_nibble(state, nybble); decoded[0] = new_sample & 0xFF; new_sample >>= 8; decoded[1] = new_sample & 0xFF; @@ -337,7 +337,7 @@ } static int -IMA_ADPCM_decode (Uint8 ** audio_buf, Uint32 * audio_len) +IMA_ADPCM_decode(Uint8 ** audio_buf, Uint32 * audio_len) { struct IMA_ADPCM_decodestate *state; Uint8 *freeable, *encoded, *decoded; @@ -346,9 +346,9 @@ /* Check to make sure we have enough variables in the state array */ channels = IMA_ADPCM_state.wavefmt.channels; - if (channels > SDL_arraysize (IMA_ADPCM_state.state)) { - SDL_SetError ("IMA ADPCM decoder can only handle %d channels", - SDL_arraysize (IMA_ADPCM_state.state)); + if (channels > SDL_arraysize(IMA_ADPCM_state.state)) { + SDL_SetError("IMA ADPCM decoder can only handle %d channels", + SDL_arraysize(IMA_ADPCM_state.state)); return (-1); } state = IMA_ADPCM_state.state; @@ -359,10 +359,10 @@ freeable = *audio_buf; *audio_len = (encoded_len / IMA_ADPCM_state.wavefmt.blockalign) * IMA_ADPCM_state.wSamplesPerBlock * - IMA_ADPCM_state.wavefmt.channels * sizeof (Sint16); - *audio_buf = (Uint8 *) SDL_malloc (*audio_len); + IMA_ADPCM_state.wavefmt.channels * sizeof(Sint16); + *audio_buf = (Uint8 *) SDL_malloc(*audio_len); if (*audio_buf == NULL) { - SDL_Error (SDL_ENOMEM); + SDL_Error(SDL_ENOMEM); return (-1); } decoded = *audio_buf; @@ -393,8 +393,8 @@ samplesleft = (IMA_ADPCM_state.wSamplesPerBlock - 1) * channels; while (samplesleft > 0) { for (c = 0; c < channels; ++c) { - Fill_IMA_ADPCM_block (decoded, encoded, - c, channels, &state[c]); + Fill_IMA_ADPCM_block(decoded, encoded, + c, channels, &state[c]); encoded += 4; samplesleft -= 8; } @@ -402,13 +402,13 @@ } encoded_len -= IMA_ADPCM_state.wavefmt.blockalign; } - SDL_free (freeable); + SDL_free(freeable); return (0); } SDL_AudioSpec * -SDL_LoadWAV_RW (SDL_RWops * src, int freesrc, - SDL_AudioSpec * spec, Uint8 ** audio_buf, Uint32 * audio_len) +SDL_LoadWAV_RW(SDL_RWops * src, int freesrc, + SDL_AudioSpec * spec, Uint8 ** audio_buf, Uint32 * audio_len) { int was_error; Chunk chunk; @@ -433,53 +433,53 @@ } /* Check the magic header */ - RIFFchunk = SDL_ReadLE32 (src); - wavelen = SDL_ReadLE32 (src); + RIFFchunk = SDL_ReadLE32(src); + wavelen = SDL_ReadLE32(src); if (wavelen == WAVE) { /* The RIFFchunk has already been read */ WAVEmagic = wavelen; wavelen = RIFFchunk; RIFFchunk = RIFF; } else { - WAVEmagic = SDL_ReadLE32 (src); + WAVEmagic = SDL_ReadLE32(src); } if ((RIFFchunk != RIFF) || (WAVEmagic != WAVE)) { - SDL_SetError ("Unrecognized file type (not WAVE)"); + SDL_SetError("Unrecognized file type (not WAVE)"); was_error = 1; goto done; } - headerDiff += sizeof (Uint32); /* for WAVE */ + headerDiff += sizeof(Uint32); /* for WAVE */ /* Read the audio data format chunk */ chunk.data = NULL; do { if (chunk.data != NULL) { - SDL_free (chunk.data); + SDL_free(chunk.data); } - lenread = ReadChunk (src, &chunk); + lenread = ReadChunk(src, &chunk); if (lenread < 0) { was_error = 1; goto done; } /* 2 Uint32's for chunk header+len, plus the lenread */ - headerDiff += lenread + 2 * sizeof (Uint32); + headerDiff += lenread + 2 * sizeof(Uint32); } while ((chunk.magic == FACT) || (chunk.magic == LIST)); /* Decode the audio data format */ format = (WaveFMT *) chunk.data; if (chunk.magic != FMT) { - SDL_SetError ("Complex WAVE files not supported"); + SDL_SetError("Complex WAVE files not supported"); was_error = 1; goto done; } MS_ADPCM_encoded = IMA_ADPCM_encoded = 0; - switch (SDL_SwapLE16 (format->encoding)) { + switch (SDL_SwapLE16(format->encoding)) { case PCM_CODE: /* We can understand this */ break; case MS_ADPCM_CODE: /* Try to understand this */ - if (InitMS_ADPCM (format) < 0) { + if (InitMS_ADPCM(format) < 0) { was_error = 1; goto done; } @@ -487,26 +487,26 @@ break; case IMA_ADPCM_CODE: /* Try to understand this */ - if (InitIMA_ADPCM (format) < 0) { + if (InitIMA_ADPCM(format) < 0) { was_error = 1; goto done; } IMA_ADPCM_encoded = 1; break; case MP3_CODE: - SDL_SetError ("MPEG Layer 3 data not supported", - SDL_SwapLE16 (format->encoding)); + SDL_SetError("MPEG Layer 3 data not supported", + SDL_SwapLE16(format->encoding)); was_error = 1; goto done; default: - SDL_SetError ("Unknown WAVE data format: 0x%.4x", - SDL_SwapLE16 (format->encoding)); + SDL_SetError("Unknown WAVE data format: 0x%.4x", + SDL_SwapLE16(format->encoding)); was_error = 1; goto done; } - SDL_memset (spec, 0, (sizeof *spec)); - spec->freq = SDL_SwapLE32 (format->frequency); - switch (SDL_SwapLE16 (format->bitspersample)) { + SDL_memset(spec, 0, (sizeof *spec)); + spec->freq = SDL_SwapLE32(format->frequency); + switch (SDL_SwapLE16(format->bitspersample)) { case 4: if (MS_ADPCM_encoded || IMA_ADPCM_encoded) { spec->format = AUDIO_S16; @@ -525,20 +525,20 @@ break; } if (was_error) { - SDL_SetError ("Unknown %d-bit PCM data format", - SDL_SwapLE16 (format->bitspersample)); + SDL_SetError("Unknown %d-bit PCM data format", + SDL_SwapLE16(format->bitspersample)); goto done; } - spec->channels = (Uint8) SDL_SwapLE16 (format->channels); + spec->channels = (Uint8) SDL_SwapLE16(format->channels); spec->samples = 4096; /* Good default buffer size */ /* Read the audio data chunk */ *audio_buf = NULL; do { if (*audio_buf != NULL) { - SDL_free (*audio_buf); + SDL_free(*audio_buf); } - lenread = ReadChunk (src, &chunk); + lenread = ReadChunk(src, &chunk); if (lenread < 0) { was_error = 1; goto done; @@ -546,19 +546,19 @@ *audio_len = lenread; *audio_buf = chunk.data; if (chunk.magic != DATA) - headerDiff += lenread + 2 * sizeof (Uint32); + headerDiff += lenread + 2 * sizeof(Uint32); } while (chunk.magic != DATA); - headerDiff += 2 * sizeof (Uint32); /* for the data chunk and len */ + headerDiff += 2 * sizeof(Uint32); /* for the data chunk and len */ if (MS_ADPCM_encoded) { - if (MS_ADPCM_decode (audio_buf, audio_len) < 0) { + if (MS_ADPCM_decode(audio_buf, audio_len) < 0) { was_error = 1; goto done; } } if (IMA_ADPCM_encoded) { - if (IMA_ADPCM_decode (audio_buf, audio_len) < 0) { + if (IMA_ADPCM_decode(audio_buf, audio_len) < 0) { was_error = 1; goto done; } @@ -570,15 +570,14 @@ done: if (format != NULL) { - SDL_free (format); + SDL_free(format); } if (src) { if (freesrc) { - SDL_RWclose (src); + SDL_RWclose(src); } else { /* seek to the end of the file (given by the RIFF chunk) */ - SDL_RWseek (src, wavelen - chunk.length - headerDiff, - RW_SEEK_CUR); + SDL_RWseek(src, wavelen - chunk.length - headerDiff, RW_SEEK_CUR); } } if (was_error) { @@ -591,26 +590,26 @@ be freed here. (Necessary under Win32, VC++) */ void -SDL_FreeWAV (Uint8 * audio_buf) +SDL_FreeWAV(Uint8 * audio_buf) { if (audio_buf != NULL) { - SDL_free (audio_buf); + SDL_free(audio_buf); } } static int -ReadChunk (SDL_RWops * src, Chunk * chunk) +ReadChunk(SDL_RWops * src, Chunk * chunk) { - chunk->magic = SDL_ReadLE32 (src); - chunk->length = SDL_ReadLE32 (src); - chunk->data = (Uint8 *) SDL_malloc (chunk->length); + chunk->magic = SDL_ReadLE32(src); + chunk->length = SDL_ReadLE32(src); + chunk->data = (Uint8 *) SDL_malloc(chunk->length); if (chunk->data == NULL) { - SDL_Error (SDL_ENOMEM); + SDL_Error(SDL_ENOMEM); return (-1); } - if (SDL_RWread (src, chunk->data, chunk->length, 1) != 1) { - SDL_Error (SDL_EFREAD); - SDL_free (chunk->data); + if (SDL_RWread(src, chunk->data, chunk->length, 1) != 1) { + SDL_Error(SDL_EFREAD); + SDL_free(chunk->data); return (-1); } return (chunk->length); diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/alsa/SDL_alsa_audio.c --- a/src/audio/alsa/SDL_alsa_audio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/alsa/SDL_alsa_audio.c Mon May 29 04:04:35 2006 +0000 @@ -48,11 +48,11 @@ #define DEFAULT_DEVICE "default" /* Audio driver functions */ -static int ALSA_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void ALSA_WaitAudio (_THIS); -static void ALSA_PlayAudio (_THIS); -static Uint8 *ALSA_GetAudioBuf (_THIS); -static void ALSA_CloseAudio (_THIS); +static int ALSA_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void ALSA_WaitAudio(_THIS); +static void ALSA_PlayAudio(_THIS); +static Uint8 *ALSA_GetAudioBuf(_THIS); +static void ALSA_CloseAudio(_THIS); #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC @@ -62,83 +62,81 @@ static int (*SDL_snd_pcm_open) (snd_pcm_t ** pcm, const char *name, snd_pcm_stream_t stream, int mode); -static int (*SDL_NAME (snd_pcm_open)) (snd_pcm_t ** pcm, const char *name, - snd_pcm_stream_t stream, int mode); -static int (*SDL_NAME (snd_pcm_close)) (snd_pcm_t * pcm); -static snd_pcm_sframes_t (*SDL_NAME (snd_pcm_writei)) (snd_pcm_t * pcm, - const void *buffer, - snd_pcm_uframes_t - size); -static int (*SDL_NAME (snd_pcm_resume)) (snd_pcm_t * pcm); -static int (*SDL_NAME (snd_pcm_prepare)) (snd_pcm_t * pcm); -static int (*SDL_NAME (snd_pcm_drain)) (snd_pcm_t * pcm); -static const char *(*SDL_NAME (snd_strerror)) (int errnum); -static size_t (*SDL_NAME (snd_pcm_hw_params_sizeof)) (void); -static size_t (*SDL_NAME (snd_pcm_sw_params_sizeof)) (void); -static int (*SDL_NAME (snd_pcm_hw_params_any)) (snd_pcm_t * pcm, - snd_pcm_hw_params_t * params); -static int (*SDL_NAME (snd_pcm_hw_params_set_access)) (snd_pcm_t * pcm, - snd_pcm_hw_params_t * - params, - snd_pcm_access_t - access); -static int (*SDL_NAME (snd_pcm_hw_params_set_format)) (snd_pcm_t * pcm, - snd_pcm_hw_params_t * - params, - snd_pcm_format_t val); -static int (*SDL_NAME (snd_pcm_hw_params_set_channels)) (snd_pcm_t * pcm, - snd_pcm_hw_params_t * - params, - unsigned int val); -static int (*SDL_NAME (snd_pcm_hw_params_get_channels)) (const - snd_pcm_hw_params_t * - params); +static int (*SDL_NAME(snd_pcm_open)) (snd_pcm_t ** pcm, const char *name, + snd_pcm_stream_t stream, int mode); +static int (*SDL_NAME(snd_pcm_close)) (snd_pcm_t * pcm); +static snd_pcm_sframes_t(*SDL_NAME(snd_pcm_writei)) (snd_pcm_t * pcm, + const void *buffer, + snd_pcm_uframes_t size); +static int (*SDL_NAME(snd_pcm_resume)) (snd_pcm_t * pcm); +static int (*SDL_NAME(snd_pcm_prepare)) (snd_pcm_t * pcm); +static int (*SDL_NAME(snd_pcm_drain)) (snd_pcm_t * pcm); +static const char *(*SDL_NAME(snd_strerror)) (int errnum); +static size_t(*SDL_NAME(snd_pcm_hw_params_sizeof)) (void); +static size_t(*SDL_NAME(snd_pcm_sw_params_sizeof)) (void); +static int (*SDL_NAME(snd_pcm_hw_params_any)) (snd_pcm_t * pcm, + snd_pcm_hw_params_t * params); +static int (*SDL_NAME(snd_pcm_hw_params_set_access)) (snd_pcm_t * pcm, + snd_pcm_hw_params_t * + params, + snd_pcm_access_t + access); +static int (*SDL_NAME(snd_pcm_hw_params_set_format)) (snd_pcm_t * pcm, + snd_pcm_hw_params_t * + params, + snd_pcm_format_t val); +static int (*SDL_NAME(snd_pcm_hw_params_set_channels)) (snd_pcm_t * pcm, + snd_pcm_hw_params_t * + params, + unsigned int val); +static int (*SDL_NAME(snd_pcm_hw_params_get_channels)) (const + snd_pcm_hw_params_t * + params); static unsigned int - (*SDL_NAME (snd_pcm_hw_params_set_rate_near)) (snd_pcm_t * - pcm, - snd_pcm_hw_params_t - * params, - unsigned - int val, int *dir); + (*SDL_NAME(snd_pcm_hw_params_set_rate_near)) (snd_pcm_t * + pcm, + snd_pcm_hw_params_t + * params, + unsigned int val, int *dir); static snd_pcm_uframes_t - (*SDL_NAME (snd_pcm_hw_params_set_period_size_near)) (snd_pcm_t * pcm, - snd_pcm_hw_params_t - * params, - snd_pcm_uframes_t - val, int *dir); + (*SDL_NAME(snd_pcm_hw_params_set_period_size_near)) (snd_pcm_t * pcm, + snd_pcm_hw_params_t + * params, + snd_pcm_uframes_t + val, int *dir); static snd_pcm_sframes_t - (*SDL_NAME (snd_pcm_hw_params_get_period_size)) (const - snd_pcm_hw_params_t - * params); + (*SDL_NAME(snd_pcm_hw_params_get_period_size)) (const + snd_pcm_hw_params_t + * params); static unsigned int - (*SDL_NAME (snd_pcm_hw_params_set_periods_near)) (snd_pcm_t * pcm, - snd_pcm_hw_params_t - * params, - unsigned int val, - int *dir); -static int (*SDL_NAME (snd_pcm_hw_params_get_periods)) (snd_pcm_hw_params_t * - params); -static int (*SDL_NAME (snd_pcm_hw_params)) (snd_pcm_t * pcm, - snd_pcm_hw_params_t * params); + (*SDL_NAME(snd_pcm_hw_params_set_periods_near)) (snd_pcm_t * pcm, + snd_pcm_hw_params_t + * params, + unsigned int val, + int *dir); +static int (*SDL_NAME(snd_pcm_hw_params_get_periods)) (snd_pcm_hw_params_t * + params); +static int (*SDL_NAME(snd_pcm_hw_params)) (snd_pcm_t * pcm, + snd_pcm_hw_params_t * params); /* */ -static int (*SDL_NAME (snd_pcm_sw_params_current)) (snd_pcm_t * pcm, - snd_pcm_sw_params_t * - swparams); -static int (*SDL_NAME (snd_pcm_sw_params_set_start_threshold)) (snd_pcm_t * - pcm, - snd_pcm_sw_params_t - * params, - snd_pcm_uframes_t - val); -static int (*SDL_NAME (snd_pcm_sw_params_set_avail_min)) (snd_pcm_t * pcm, - snd_pcm_sw_params_t - * params, - snd_pcm_uframes_t - val); -static int (*SDL_NAME (snd_pcm_sw_params)) (snd_pcm_t * pcm, - snd_pcm_sw_params_t * params); -static int (*SDL_NAME (snd_pcm_nonblock)) (snd_pcm_t * pcm, int nonblock); +static int (*SDL_NAME(snd_pcm_sw_params_current)) (snd_pcm_t * pcm, + snd_pcm_sw_params_t * + swparams); +static int (*SDL_NAME(snd_pcm_sw_params_set_start_threshold)) (snd_pcm_t * + pcm, + snd_pcm_sw_params_t + * params, + snd_pcm_uframes_t + val); +static int (*SDL_NAME(snd_pcm_sw_params_set_avail_min)) (snd_pcm_t * pcm, + snd_pcm_sw_params_t + * params, + snd_pcm_uframes_t + val); +static int (*SDL_NAME(snd_pcm_sw_params)) (snd_pcm_t * pcm, + snd_pcm_sw_params_t * params); +static int (*SDL_NAME(snd_pcm_nonblock)) (snd_pcm_t * pcm, int nonblock); #define snd_pcm_hw_params_sizeof SDL_NAME(snd_pcm_hw_params_sizeof) #define snd_pcm_sw_params_sizeof SDL_NAME(snd_pcm_sw_params_sizeof) @@ -149,81 +147,81 @@ void **func; } alsa_functions[] = { { - "snd_pcm_open", (void **) (char *) &SDL_NAME (snd_pcm_open)}, { - "snd_pcm_close", (void **) (char *) &SDL_NAME (snd_pcm_close)}, { - "snd_pcm_writei", (void **) (char *) &SDL_NAME (snd_pcm_writei)}, { - "snd_pcm_resume", (void **) (char *) &SDL_NAME (snd_pcm_resume)}, { - "snd_pcm_prepare", (void **) (char *) &SDL_NAME (snd_pcm_prepare)}, { - "snd_pcm_drain", (void **) (char *) &SDL_NAME (snd_pcm_drain)}, { - "snd_strerror", (void **) (char *) &SDL_NAME (snd_strerror)}, { + "snd_pcm_open", (void **) (char *) &SDL_NAME(snd_pcm_open)}, { + "snd_pcm_close", (void **) (char *) &SDL_NAME(snd_pcm_close)}, { + "snd_pcm_writei", (void **) (char *) &SDL_NAME(snd_pcm_writei)}, { + "snd_pcm_resume", (void **) (char *) &SDL_NAME(snd_pcm_resume)}, { + "snd_pcm_prepare", (void **) (char *) &SDL_NAME(snd_pcm_prepare)}, { + "snd_pcm_drain", (void **) (char *) &SDL_NAME(snd_pcm_drain)}, { + "snd_strerror", (void **) (char *) &SDL_NAME(snd_strerror)}, { "snd_pcm_hw_params_sizeof", - (void **) (char *) &SDL_NAME (snd_pcm_hw_params_sizeof)}, { + (void **) (char *) &SDL_NAME(snd_pcm_hw_params_sizeof)}, { "snd_pcm_sw_params_sizeof", - (void **) (char *) &SDL_NAME (snd_pcm_sw_params_sizeof)}, { + (void **) (char *) &SDL_NAME(snd_pcm_sw_params_sizeof)}, { "snd_pcm_hw_params_any", - (void **) (char *) &SDL_NAME (snd_pcm_hw_params_any)}, { + (void **) (char *) &SDL_NAME(snd_pcm_hw_params_any)}, { "snd_pcm_hw_params_set_access", - (void **) (char *) &SDL_NAME (snd_pcm_hw_params_set_access)}, { + (void **) (char *) &SDL_NAME(snd_pcm_hw_params_set_access)}, { "snd_pcm_hw_params_set_format", - (void **) (char *) &SDL_NAME (snd_pcm_hw_params_set_format)}, { + (void **) (char *) &SDL_NAME(snd_pcm_hw_params_set_format)}, { "snd_pcm_hw_params_set_channels", - (void **) (char *) &SDL_NAME (snd_pcm_hw_params_set_channels)}, { + (void **) (char *) &SDL_NAME(snd_pcm_hw_params_set_channels)}, { "snd_pcm_hw_params_get_channels", - (void **) (char *) &SDL_NAME (snd_pcm_hw_params_get_channels)}, { + (void **) (char *) &SDL_NAME(snd_pcm_hw_params_get_channels)}, { "snd_pcm_hw_params_set_rate_near", - (void **) (char *) &SDL_NAME (snd_pcm_hw_params_set_rate_near)}, { + (void **) (char *) &SDL_NAME(snd_pcm_hw_params_set_rate_near)}, { "snd_pcm_hw_params_set_period_size_near", (void **) (char *) - &SDL_NAME (snd_pcm_hw_params_set_period_size_near)}, { + &SDL_NAME(snd_pcm_hw_params_set_period_size_near)}, { "snd_pcm_hw_params_get_period_size", - (void **) (char *) &SDL_NAME (snd_pcm_hw_params_get_period_size)}, + (void **) (char *) &SDL_NAME(snd_pcm_hw_params_get_period_size)}, { "snd_pcm_hw_params_set_periods_near", (void **) (char *) - &SDL_NAME (snd_pcm_hw_params_set_periods_near)}, { + &SDL_NAME(snd_pcm_hw_params_set_periods_near)}, { "snd_pcm_hw_params_get_periods", - (void **) (char *) &SDL_NAME (snd_pcm_hw_params_get_periods)}, { - "snd_pcm_hw_params", (void **) (char *) &SDL_NAME (snd_pcm_hw_params)}, { + (void **) (char *) &SDL_NAME(snd_pcm_hw_params_get_periods)}, { + "snd_pcm_hw_params", (void **) (char *) &SDL_NAME(snd_pcm_hw_params)}, { "snd_pcm_sw_params_current", - (void **) (char *) &SDL_NAME (snd_pcm_sw_params_current)}, { + (void **) (char *) &SDL_NAME(snd_pcm_sw_params_current)}, { "snd_pcm_sw_params_set_start_threshold", (void **) (char *) - &SDL_NAME (snd_pcm_sw_params_set_start_threshold)}, { + &SDL_NAME(snd_pcm_sw_params_set_start_threshold)}, { "snd_pcm_sw_params_set_avail_min", - (void **) (char *) &SDL_NAME (snd_pcm_sw_params_set_avail_min)}, { - "snd_pcm_sw_params", (void **) (char *) &SDL_NAME (snd_pcm_sw_params)}, { -"snd_pcm_nonblock", (void **) (char *) &SDL_NAME (snd_pcm_nonblock)},}; + (void **) (char *) &SDL_NAME(snd_pcm_sw_params_set_avail_min)}, { + "snd_pcm_sw_params", (void **) (char *) &SDL_NAME(snd_pcm_sw_params)}, { +"snd_pcm_nonblock", (void **) (char *) &SDL_NAME(snd_pcm_nonblock)},}; static void -UnloadALSALibrary (void) +UnloadALSALibrary(void) { if (alsa_loaded) { /* SDL_UnloadObject(alsa_handle);*/ - dlclose (alsa_handle); + dlclose(alsa_handle); alsa_handle = NULL; alsa_loaded = 0; } } static int -LoadALSALibrary (void) +LoadALSALibrary(void) { int i, retval = -1; /* alsa_handle = SDL_LoadObject(alsa_library);*/ - alsa_handle = dlopen (alsa_library, RTLD_NOW); + alsa_handle = dlopen(alsa_library, RTLD_NOW); if (alsa_handle) { alsa_loaded = 1; retval = 0; - for (i = 0; i < SDL_arraysize (alsa_functions); i++) { + for (i = 0; i < SDL_arraysize(alsa_functions); i++) { /* *alsa_functions[i].func = SDL_LoadFunction(alsa_handle,alsa_functions[i].name);*/ #if HAVE_DLVSYM *alsa_functions[i].func = - dlvsym (alsa_handle, alsa_functions[i].name, "ALSA_0.9"); + dlvsym(alsa_handle, alsa_functions[i].name, "ALSA_0.9"); if (!*alsa_functions[i].func) #endif *alsa_functions[i].func = - dlsym (alsa_handle, alsa_functions[i].name); + dlsym(alsa_handle, alsa_functions[i].name); if (!*alsa_functions[i].func) { retval = -1; - UnloadALSALibrary (); + UnloadALSALibrary(); break; } } @@ -234,13 +232,13 @@ #else static void -UnloadALSALibrary (void) +UnloadALSALibrary(void) { return; } static int -LoadALSALibrary (void) +LoadALSALibrary(void) { return 0; } @@ -248,11 +246,11 @@ #endif /* SDL_AUDIO_DRIVER_ALSA_DYNAMIC */ static const char * -get_audio_device (int channels) +get_audio_device(int channels) { const char *device; - device = SDL_getenv ("AUDIODEV"); /* Is there a standard variable name? */ + device = SDL_getenv("AUDIODEV"); /* Is there a standard variable name? */ if (device == NULL) { if (channels == 6) device = "surround51"; @@ -267,56 +265,56 @@ /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { int available; int status; snd_pcm_t *handle; available = 0; - if (LoadALSALibrary () < 0) { + if (LoadALSALibrary() < 0) { return available; } status = - SDL_NAME (snd_pcm_open) (&handle, get_audio_device (2), - SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); + SDL_NAME(snd_pcm_open) (&handle, get_audio_device(2), + SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); if (status >= 0) { available = 1; - SDL_NAME (snd_pcm_close) (handle); + SDL_NAME(snd_pcm_close) (handle); } - UnloadALSALibrary (); + UnloadALSALibrary(); return (available); } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); - UnloadALSALibrary (); + SDL_free(device->hidden); + SDL_free(device); + UnloadALSALibrary(); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - LoadALSALibrary (); - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + LoadALSALibrary(); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = ALSA_OpenAudio; @@ -337,7 +335,7 @@ /* This function waits until it is possible to write a full sound buffer */ static void -ALSA_WaitAudio (_THIS) +ALSA_WaitAudio(_THIS) { /* Check to see if the thread-parent process is still alive */ { @@ -346,7 +344,7 @@ that use a different process id for each thread. */ if (parent && (((++cnt) % 10) == 0)) { /* Check every 10 loops */ - if (kill (parent, 0) < 0) { + if (kill(parent, 0) < 0) { this->enabled = 0; } } @@ -354,7 +352,7 @@ } static void -ALSA_PlayAudio (_THIS) +ALSA_PlayAudio(_THIS) { int status; int sample_len; @@ -364,21 +362,21 @@ sample_buf = (signed short *) mixbuf; while (sample_len > 0) { status = - SDL_NAME (snd_pcm_writei) (pcm_handle, sample_buf, sample_len); + SDL_NAME(snd_pcm_writei) (pcm_handle, sample_buf, sample_len); if (status < 0) { if (status == -EAGAIN) { - SDL_Delay (1); + SDL_Delay(1); continue; } if (status == -ESTRPIPE) { do { - SDL_Delay (1); - status = SDL_NAME (snd_pcm_resume) (pcm_handle); + SDL_Delay(1); + status = SDL_NAME(snd_pcm_resume) (pcm_handle); } while (status == -EAGAIN); } if (status < 0) { - status = SDL_NAME (snd_pcm_prepare) (pcm_handle); + status = SDL_NAME(snd_pcm_prepare) (pcm_handle); } if (status < 0) { /* Hmm, not much we can do - abort */ @@ -393,27 +391,27 @@ } static Uint8 * -ALSA_GetAudioBuf (_THIS) +ALSA_GetAudioBuf(_THIS) { return (mixbuf); } static void -ALSA_CloseAudio (_THIS) +ALSA_CloseAudio(_THIS) { if (mixbuf != NULL) { - SDL_FreeAudioMem (mixbuf); + SDL_FreeAudioMem(mixbuf); mixbuf = NULL; } if (pcm_handle) { - SDL_NAME (snd_pcm_drain) (pcm_handle); - SDL_NAME (snd_pcm_close) (pcm_handle); + SDL_NAME(snd_pcm_drain) (pcm_handle); + SDL_NAME(snd_pcm_close) (pcm_handle); pcm_handle = NULL; } } static int -ALSA_OpenAudio (_THIS, SDL_AudioSpec * spec) +ALSA_OpenAudio(_THIS, SDL_AudioSpec * spec) { int status; snd_pcm_hw_params_t *hwparams; @@ -425,40 +423,40 @@ /* Open the audio device */ /* Name of device should depend on # channels in spec */ status = - SDL_NAME (snd_pcm_open) (&pcm_handle, - get_audio_device (spec->channels), - SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); + SDL_NAME(snd_pcm_open) (&pcm_handle, + get_audio_device(spec->channels), + SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); if (status < 0) { - SDL_SetError ("Couldn't open audio device: %s", - SDL_NAME (snd_strerror) (status)); + SDL_SetError("Couldn't open audio device: %s", + SDL_NAME(snd_strerror) (status)); return (-1); } /* Figure out what the hardware is capable of */ - snd_pcm_hw_params_alloca (&hwparams); - status = SDL_NAME (snd_pcm_hw_params_any) (pcm_handle, hwparams); + snd_pcm_hw_params_alloca(&hwparams); + status = SDL_NAME(snd_pcm_hw_params_any) (pcm_handle, hwparams); if (status < 0) { - SDL_SetError ("Couldn't get hardware config: %s", - SDL_NAME (snd_strerror) (status)); - ALSA_CloseAudio (this); + SDL_SetError("Couldn't get hardware config: %s", + SDL_NAME(snd_strerror) (status)); + ALSA_CloseAudio(this); return (-1); } /* SDL only uses interleaved sample output */ status = - SDL_NAME (snd_pcm_hw_params_set_access) (pcm_handle, hwparams, - SND_PCM_ACCESS_RW_INTERLEAVED); + SDL_NAME(snd_pcm_hw_params_set_access) (pcm_handle, hwparams, + SND_PCM_ACCESS_RW_INTERLEAVED); if (status < 0) { - SDL_SetError ("Couldn't set interleaved access: %s", - SDL_NAME (snd_strerror) (status)); - ALSA_CloseAudio (this); + SDL_SetError("Couldn't set interleaved access: %s", + SDL_NAME(snd_strerror) (status)); + ALSA_CloseAudio(this); return (-1); } /* Try for a closest match on audio format */ status = -1; - for (test_format = SDL_FirstAudioFormat (spec->format); + for (test_format = SDL_FirstAudioFormat(spec->format); test_format && (status < 0);) { switch (test_format) { case AUDIO_U8: @@ -485,29 +483,29 @@ } if (format != 0) { status = - SDL_NAME (snd_pcm_hw_params_set_format) (pcm_handle, - hwparams, format); + SDL_NAME(snd_pcm_hw_params_set_format) (pcm_handle, + hwparams, format); } if (status < 0) { - test_format = SDL_NextAudioFormat (); + test_format = SDL_NextAudioFormat(); } } if (status < 0) { - SDL_SetError ("Couldn't find any hardware audio formats"); - ALSA_CloseAudio (this); + SDL_SetError("Couldn't find any hardware audio formats"); + ALSA_CloseAudio(this); return (-1); } spec->format = test_format; /* Set the number of channels */ status = - SDL_NAME (snd_pcm_hw_params_set_channels) (pcm_handle, hwparams, - spec->channels); + SDL_NAME(snd_pcm_hw_params_set_channels) (pcm_handle, hwparams, + spec->channels); if (status < 0) { - status = SDL_NAME (snd_pcm_hw_params_get_channels) (hwparams); + status = SDL_NAME(snd_pcm_hw_params_get_channels) (hwparams); if ((status <= 0) || (status > 2)) { - SDL_SetError ("Couldn't set audio channels"); - ALSA_CloseAudio (this); + SDL_SetError("Couldn't set audio channels"); + ALSA_CloseAudio(this); return (-1); } spec->channels = status; @@ -515,12 +513,12 @@ /* Set the audio rate */ status = - SDL_NAME (snd_pcm_hw_params_set_rate_near) (pcm_handle, hwparams, - spec->freq, NULL); + SDL_NAME(snd_pcm_hw_params_set_rate_near) (pcm_handle, hwparams, + spec->freq, NULL); if (status < 0) { - SDL_SetError ("Couldn't set audio frequency: %s", - SDL_NAME (snd_strerror) (status)); - ALSA_CloseAudio (this); + SDL_SetError("Couldn't set audio frequency: %s", + SDL_NAME(snd_strerror) (status)); + ALSA_CloseAudio(this); return (-1); } spec->freq = status; @@ -528,19 +526,19 @@ /* Set the buffer size, in samples */ frames = spec->samples; frames = - SDL_NAME (snd_pcm_hw_params_set_period_size_near) (pcm_handle, - hwparams, frames, - NULL); + SDL_NAME(snd_pcm_hw_params_set_period_size_near) (pcm_handle, + hwparams, frames, + NULL); spec->samples = frames; - SDL_NAME (snd_pcm_hw_params_set_periods_near) (pcm_handle, hwparams, 2, - NULL); + SDL_NAME(snd_pcm_hw_params_set_periods_near) (pcm_handle, hwparams, 2, + NULL); /* "set" the hardware with the desired parameters */ - status = SDL_NAME (snd_pcm_hw_params) (pcm_handle, hwparams); + status = SDL_NAME(snd_pcm_hw_params) (pcm_handle, hwparams); if (status < 0) { - SDL_SetError ("Couldn't set hardware audio parameters: %s", - SDL_NAME (snd_strerror) (status)); - ALSA_CloseAudio (this); + SDL_SetError("Couldn't set hardware audio parameters: %s", + SDL_NAME(snd_strerror) (status)); + ALSA_CloseAudio(this); return (-1); } @@ -555,57 +553,57 @@ */ /* Set the software parameters */ - snd_pcm_sw_params_alloca (&swparams); - status = SDL_NAME (snd_pcm_sw_params_current) (pcm_handle, swparams); + snd_pcm_sw_params_alloca(&swparams); + status = SDL_NAME(snd_pcm_sw_params_current) (pcm_handle, swparams); if (status < 0) { - SDL_SetError ("Couldn't get software config: %s", - SDL_NAME (snd_strerror) (status)); - ALSA_CloseAudio (this); + SDL_SetError("Couldn't get software config: %s", + SDL_NAME(snd_strerror) (status)); + ALSA_CloseAudio(this); return (-1); } status = - SDL_NAME (snd_pcm_sw_params_set_start_threshold) (pcm_handle, - swparams, 0); + SDL_NAME(snd_pcm_sw_params_set_start_threshold) (pcm_handle, + swparams, 0); if (status < 0) { - SDL_SetError ("Couldn't set start threshold: %s", - SDL_NAME (snd_strerror) (status)); - ALSA_CloseAudio (this); + SDL_SetError("Couldn't set start threshold: %s", + SDL_NAME(snd_strerror) (status)); + ALSA_CloseAudio(this); return (-1); } status = - SDL_NAME (snd_pcm_sw_params_set_avail_min) (pcm_handle, swparams, - frames); + SDL_NAME(snd_pcm_sw_params_set_avail_min) (pcm_handle, swparams, + frames); if (status < 0) { - SDL_SetError ("Couldn't set avail min: %s", - SDL_NAME (snd_strerror) (status)); - ALSA_CloseAudio (this); + SDL_SetError("Couldn't set avail min: %s", + SDL_NAME(snd_strerror) (status)); + ALSA_CloseAudio(this); return (-1); } - status = SDL_NAME (snd_pcm_sw_params) (pcm_handle, swparams); + status = SDL_NAME(snd_pcm_sw_params) (pcm_handle, swparams); if (status < 0) { - SDL_SetError ("Couldn't set software audio parameters: %s", - SDL_NAME (snd_strerror) (status)); - ALSA_CloseAudio (this); + SDL_SetError("Couldn't set software audio parameters: %s", + SDL_NAME(snd_strerror) (status)); + ALSA_CloseAudio(this); return (-1); } /* Calculate the final parameters for this audio specification */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Allocate mixing buffer */ mixlen = spec->size; - mixbuf = (Uint8 *) SDL_AllocAudioMem (mixlen); + mixbuf = (Uint8 *) SDL_AllocAudioMem(mixlen); if (mixbuf == NULL) { - ALSA_CloseAudio (this); + ALSA_CloseAudio(this); return (-1); } - SDL_memset (mixbuf, spec->silence, spec->size); + SDL_memset(mixbuf, spec->silence, spec->size); /* Get the parent process id (we're the parent of the audio thread) */ - parent = getpid (); + parent = getpid(); /* Switch to blocking mode for playback */ - SDL_NAME (snd_pcm_nonblock) (pcm_handle, 0); + SDL_NAME(snd_pcm_nonblock) (pcm_handle, 0); /* We're ready to rock and roll. :-) */ return (0); diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/amigaos/SDL_ahiaudio.c --- a/src/audio/amigaos/SDL_ahiaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/amigaos/SDL_ahiaudio.c Mon May 29 04:04:35 2006 +0000 @@ -28,11 +28,11 @@ #include "SDL_ahiaudio.h" /* Audio driver functions */ -static int AHI_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void AHI_WaitAudio (_THIS); -static void AHI_PlayAudio (_THIS); -static Uint8 *AHI_GetAudioBuf (_THIS); -static void AHI_CloseAudio (_THIS); +static int AHI_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void AHI_WaitAudio(_THIS); +static void AHI_PlayAudio(_THIS); +static Uint8 *AHI_GetAudioBuf(_THIS); +static void AHI_CloseAudio(_THIS); #ifndef __SASC #define mymalloc(x) AllocVec(x,MEMF_PUBLIC) @@ -45,64 +45,64 @@ /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { int ok = 0; struct MsgPort *p; struct AHIRequest *req; - if (p = CreateMsgPort ()) { + if (p = CreateMsgPort()) { if (req = - (struct AHIRequest *) CreateIORequest (p, - sizeof (struct - AHIRequest))) { + (struct AHIRequest *) CreateIORequest(p, + sizeof(struct + AHIRequest))) { req->ahir_Version = 4; - if (!OpenDevice (AHINAME, 0, (struct IORequest *) req, NULL)) { - D (bug ("AHI available.\n")); + if (!OpenDevice(AHINAME, 0, (struct IORequest *) req, NULL)) { + D(bug("AHI available.\n")); ok = 1; - CloseDevice ((struct IORequest *) req); + CloseDevice((struct IORequest *) req); } - DeleteIORequest ((struct IORequest *) req); + DeleteIORequest((struct IORequest *) req); } - DeleteMsgPort (p); + DeleteMsgPort(p); } - D (if (!ok) bug ("AHI not available\n")); + D(if (!ok) bug("AHI not available\n")); return ok; } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; #ifndef NO_AMIGADEBUG - D (bug ("AHI created...\n")); + D(bug("AHI created...\n")); #endif /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = AHI_OpenAudio; @@ -122,19 +122,19 @@ void static -AHI_WaitAudio (_THIS) +AHI_WaitAudio(_THIS) { - if (!CheckIO ((struct IORequest *) audio_req[current_buffer])) { - WaitIO ((struct IORequest *) audio_req[current_buffer]); + if (!CheckIO((struct IORequest *) audio_req[current_buffer])) { + WaitIO((struct IORequest *) audio_req[current_buffer]); // AbortIO((struct IORequest *)audio_req[current_buffer]); } } static void -AHI_PlayAudio (_THIS) +AHI_PlayAudio(_THIS) { if (playing > 1) - WaitIO ((struct IORequest *) audio_req[current_buffer]); + WaitIO((struct IORequest *) audio_req[current_buffer]); /* Write the audio data out */ audio_req[current_buffer]->ahir_Std.io_Message.mn_Node.ln_Pri = 60; @@ -149,92 +149,92 @@ audio_req[current_buffer]->ahir_Link = (playing > 0 ? audio_req[current_buffer ^ 1] : NULL); - SendIO ((struct IORequest *) audio_req[current_buffer]); + SendIO((struct IORequest *) audio_req[current_buffer]); current_buffer ^= 1; playing++; } static Uint8 * -AHI_GetAudioBuf (_THIS) +AHI_GetAudioBuf(_THIS) { return (mixbuf[current_buffer]); } static void -AHI_CloseAudio (_THIS) +AHI_CloseAudio(_THIS) { - D (bug ("Closing audio...\n")); + D(bug("Closing audio...\n")); playing = 0; if (audio_req[0]) { if (audio_req[1]) { - D (bug ("Break req[1]...\n")); + D(bug("Break req[1]...\n")); - AbortIO ((struct IORequest *) audio_req[1]); - WaitIO ((struct IORequest *) audio_req[1]); + AbortIO((struct IORequest *) audio_req[1]); + WaitIO((struct IORequest *) audio_req[1]); } - D (bug ("Break req[0]...\n")); + D(bug("Break req[0]...\n")); - AbortIO ((struct IORequest *) audio_req[0]); - WaitIO ((struct IORequest *) audio_req[0]); + AbortIO((struct IORequest *) audio_req[0]); + WaitIO((struct IORequest *) audio_req[0]); if (audio_req[1]) { - D (bug ("Break AGAIN req[1]...\n")); - AbortIO ((struct IORequest *) audio_req[1]); - WaitIO ((struct IORequest *) audio_req[1]); + D(bug("Break AGAIN req[1]...\n")); + AbortIO((struct IORequest *) audio_req[1]); + WaitIO((struct IORequest *) audio_req[1]); } // Double abort to be sure to break the dbuffering process. - SDL_Delay (200); + SDL_Delay(200); - D (bug ("Reqs breaked, closing device...\n")); - CloseDevice ((struct IORequest *) audio_req[0]); - D (bug ("Device closed, freeing memory...\n")); - myfree (audio_req[1]); - D (bug ("Memory freed, deleting IOReq...\n")); - DeleteIORequest ((struct IORequest *) audio_req[0]); + D(bug("Reqs breaked, closing device...\n")); + CloseDevice((struct IORequest *) audio_req[0]); + D(bug("Device closed, freeing memory...\n")); + myfree(audio_req[1]); + D(bug("Memory freed, deleting IOReq...\n")); + DeleteIORequest((struct IORequest *) audio_req[0]); audio_req[0] = audio_req[1] = NULL; } - D (bug ("Freeing mixbuf[0]...\n")); + D(bug("Freeing mixbuf[0]...\n")); if (mixbuf[0] != NULL) { - myfree (mixbuf[0]); + myfree(mixbuf[0]); // SDL_FreeAudioMem(mixbuf[0]); mixbuf[0] = NULL; } - D (bug ("Freeing mixbuf[1]...\n")); + D(bug("Freeing mixbuf[1]...\n")); if (mixbuf[1] != NULL) { - myfree (mixbuf[1]); + myfree(mixbuf[1]); // SDL_FreeAudioMem(mixbuf[1]); mixbuf[1] = NULL; } - D (bug ("Freeing audio_port...\n")); + D(bug("Freeing audio_port...\n")); if (audio_port != NULL) { - DeleteMsgPort (audio_port); + DeleteMsgPort(audio_port); audio_port = NULL; } - D (bug ("...done!\n")); + D(bug("...done!\n")); } static int -AHI_OpenAudio (_THIS, SDL_AudioSpec * spec) +AHI_OpenAudio(_THIS, SDL_AudioSpec * spec) { // int width; - D (bug ("AHI opening...\n")); + D(bug("AHI opening...\n")); /* Determine the audio parameters from the AudioSpec */ switch (spec->format & 0xFF) { case 8: { /* Signed 8 bit audio data */ - D (bug ("Samples a 8 bit...\n")); + D(bug("Samples a 8 bit...\n")); spec->format = AUDIO_S8; this->hidden->bytespersample = 1; if (spec->channels < 2) @@ -246,7 +246,7 @@ case 16: { /* Signed 16 bit audio data */ - D (bug ("Samples a 16 bit...\n")); + D(bug("Samples a 16 bit...\n")); spec->format = AUDIO_S16MSB; this->hidden->bytespersample = 2; if (spec->channels < 2) @@ -258,89 +258,88 @@ default: { - SDL_SetError ("Unsupported audio format"); + SDL_SetError("Unsupported audio format"); return (-1); } } if (spec->channels != 1 && spec->channels != 2) { - D (bug ("Wrong channel number!\n")); - SDL_SetError ("Channel number non supported"); + D(bug("Wrong channel number!\n")); + SDL_SetError("Channel number non supported"); return -1; } - D (bug ("Before CalculateAudioSpec\n")); + D(bug("Before CalculateAudioSpec\n")); /* Update the fragment size as size in bytes */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); - D (bug ("Before CreateMsgPort\n")); + D(bug("Before CreateMsgPort\n")); - if (!(audio_port = CreateMsgPort ())) { - SDL_SetError ("Unable to create a MsgPort"); + if (!(audio_port = CreateMsgPort())) { + SDL_SetError("Unable to create a MsgPort"); return -1; } - D (bug ("Before CreateIORequest\n")); + D(bug("Before CreateIORequest\n")); if (! (audio_req[0] = - (struct AHIRequest *) CreateIORequest (audio_port, - sizeof (struct AHIRequest)))) - { - SDL_SetError ("Unable to create an AHIRequest"); - DeleteMsgPort (audio_port); + (struct AHIRequest *) CreateIORequest(audio_port, + sizeof(struct AHIRequest)))) { + SDL_SetError("Unable to create an AHIRequest"); + DeleteMsgPort(audio_port); return -1; } audio_req[0]->ahir_Version = 4; - if (OpenDevice (AHINAME, 0, (struct IORequest *) audio_req[0], NULL)) { - SDL_SetError ("Unable to open AHI device!\n"); - DeleteIORequest ((struct IORequest *) audio_req[0]); - DeleteMsgPort (audio_port); + if (OpenDevice(AHINAME, 0, (struct IORequest *) audio_req[0], NULL)) { + SDL_SetError("Unable to open AHI device!\n"); + DeleteIORequest((struct IORequest *) audio_req[0]); + DeleteMsgPort(audio_port); return -1; } - D (bug ("AFTER opendevice\n")); + D(bug("AFTER opendevice\n")); /* Set output frequency and size */ this->hidden->freq = spec->freq; this->hidden->size = spec->size; - D (bug ("Before buffer allocation\n")); + D(bug("Before buffer allocation\n")); /* Allocate mixing buffer */ - mixbuf[0] = (Uint8 *) mymalloc (spec->size); - mixbuf[1] = (Uint8 *) mymalloc (spec->size); + mixbuf[0] = (Uint8 *) mymalloc(spec->size); + mixbuf[1] = (Uint8 *) mymalloc(spec->size); - D (bug ("Before audio_req allocation\n")); + D(bug("Before audio_req allocation\n")); - if (!(audio_req[1] = mymalloc (sizeof (struct AHIRequest)))) { - SDL_OutOfMemory (); + if (!(audio_req[1] = mymalloc(sizeof(struct AHIRequest)))) { + SDL_OutOfMemory(); return (-1); } - D (bug ("Before audio_req memcpy\n")); + D(bug("Before audio_req memcpy\n")); - SDL_memcpy (audio_req[1], audio_req[0], sizeof (struct AHIRequest)); + SDL_memcpy(audio_req[1], audio_req[0], sizeof(struct AHIRequest)); if (mixbuf[0] == NULL || mixbuf[1] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } - D (bug ("Before mixbuf memset\n")); + D(bug("Before mixbuf memset\n")); - SDL_memset (mixbuf[0], spec->silence, spec->size); - SDL_memset (mixbuf[1], spec->silence, spec->size); + SDL_memset(mixbuf[0], spec->silence, spec->size); + SDL_memset(mixbuf[1], spec->silence, spec->size); current_buffer = 0; playing = 0; - D (bug - ("AHI opened: freq:%ld mixbuf:%lx/%lx buflen:%ld bits:%ld channels:%ld\n", - spec->freq, mixbuf[0], mixbuf[1], spec->size, - this->hidden->bytespersample * 8, spec->channels)); + D(bug + ("AHI opened: freq:%ld mixbuf:%lx/%lx buflen:%ld bits:%ld channels:%ld\n", + spec->freq, mixbuf[0], mixbuf[1], spec->size, + this->hidden->bytespersample * 8, spec->channels)); /* We're ready to rock and roll. :-) */ return (0); diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/arts/SDL_artsaudio.c --- a/src/audio/arts/SDL_artsaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/arts/SDL_artsaudio.c Mon May 29 04:04:35 2006 +0000 @@ -41,11 +41,11 @@ #define ARTS_DRIVER_NAME "arts" /* Audio driver functions */ -static int ARTS_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void ARTS_WaitAudio (_THIS); -static void ARTS_PlayAudio (_THIS); -static Uint8 *ARTS_GetAudioBuf (_THIS); -static void ARTS_CloseAudio (_THIS); +static int ARTS_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void ARTS_WaitAudio(_THIS); +static void ARTS_PlayAudio(_THIS); +static Uint8 *ARTS_GetAudioBuf(_THIS); +static void ARTS_CloseAudio(_THIS); #ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC @@ -53,18 +53,18 @@ static void *arts_handle = NULL; static int arts_loaded = 0; -static int (*SDL_NAME (arts_init)) (void); -static void (*SDL_NAME (arts_free)) (void); -static arts_stream_t (*SDL_NAME (arts_play_stream)) (int rate, int bits, - int channels, - const char *name); -static int (*SDL_NAME (arts_stream_set)) (arts_stream_t s, - arts_parameter_t param, int value); -static int (*SDL_NAME (arts_stream_get)) (arts_stream_t s, - arts_parameter_t param); -static int (*SDL_NAME (arts_write)) (arts_stream_t s, const void *buffer, - int count); -static void (*SDL_NAME (arts_close_stream)) (arts_stream_t s); +static int (*SDL_NAME(arts_init)) (void); +static void (*SDL_NAME(arts_free)) (void); +static arts_stream_t(*SDL_NAME(arts_play_stream)) (int rate, int bits, + int channels, + const char *name); +static int (*SDL_NAME(arts_stream_set)) (arts_stream_t s, + arts_parameter_t param, int value); +static int (*SDL_NAME(arts_stream_get)) (arts_stream_t s, + arts_parameter_t param); +static int (*SDL_NAME(arts_write)) (arts_stream_t s, const void *buffer, + int count); +static void (*SDL_NAME(arts_close_stream)) (arts_stream_t s); static struct { @@ -72,39 +72,39 @@ void **func; } arts_functions[] = { { - "arts_init", (void **) &SDL_NAME (arts_init)}, { - "arts_free", (void **) &SDL_NAME (arts_free)}, { - "arts_play_stream", (void **) &SDL_NAME (arts_play_stream)}, { - "arts_stream_set", (void **) &SDL_NAME (arts_stream_set)}, { - "arts_stream_get", (void **) &SDL_NAME (arts_stream_get)}, { - "arts_write", (void **) &SDL_NAME (arts_write)}, { -"arts_close_stream", (void **) &SDL_NAME (arts_close_stream)},}; + "arts_init", (void **) &SDL_NAME(arts_init)}, { + "arts_free", (void **) &SDL_NAME(arts_free)}, { + "arts_play_stream", (void **) &SDL_NAME(arts_play_stream)}, { + "arts_stream_set", (void **) &SDL_NAME(arts_stream_set)}, { + "arts_stream_get", (void **) &SDL_NAME(arts_stream_get)}, { + "arts_write", (void **) &SDL_NAME(arts_write)}, { +"arts_close_stream", (void **) &SDL_NAME(arts_close_stream)},}; static void -UnloadARTSLibrary () +UnloadARTSLibrary() { if (arts_loaded) { - SDL_UnloadObject (arts_handle); + SDL_UnloadObject(arts_handle); arts_handle = NULL; arts_loaded = 0; } } static int -LoadARTSLibrary (void) +LoadARTSLibrary(void) { int i, retval = -1; - arts_handle = SDL_LoadObject (arts_library); + arts_handle = SDL_LoadObject(arts_library); if (arts_handle) { arts_loaded = 1; retval = 0; - for (i = 0; i < SDL_arraysize (arts_functions); ++i) { + for (i = 0; i < SDL_arraysize(arts_functions); ++i) { *arts_functions[i].func = - SDL_LoadFunction (arts_handle, arts_functions[i].name); + SDL_LoadFunction(arts_handle, arts_functions[i].name); if (!*arts_functions[i].func) { retval = -1; - UnloadARTSLibrary (); + UnloadARTSLibrary(); break; } } @@ -115,13 +115,13 @@ #else static void -UnloadARTSLibrary () +UnloadARTSLibrary() { return; } static int -LoadARTSLibrary (void) +LoadARTSLibrary(void) { return 0; } @@ -131,58 +131,58 @@ /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { int available = 0; - if (LoadARTSLibrary () < 0) { + if (LoadARTSLibrary() < 0) { return available; } - if (SDL_NAME (arts_init) () == 0) { + if (SDL_NAME(arts_init) () == 0) { #define ARTS_CRASH_HACK /* Play a stream so aRts doesn't crash */ #ifdef ARTS_CRASH_HACK arts_stream_t stream2; - stream2 = SDL_NAME (arts_play_stream) (44100, 16, 2, "SDL"); - SDL_NAME (arts_write) (stream2, "", 0); - SDL_NAME (arts_close_stream) (stream2); + stream2 = SDL_NAME(arts_play_stream) (44100, 16, 2, "SDL"); + SDL_NAME(arts_write) (stream2, "", 0); + SDL_NAME(arts_close_stream) (stream2); #endif available = 1; - SDL_NAME (arts_free) (); + SDL_NAME(arts_free) (); } - UnloadARTSLibrary (); + UnloadARTSLibrary(); return available; } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); - UnloadARTSLibrary (); + SDL_free(device->hidden); + SDL_free(device); + UnloadARTSLibrary(); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - LoadARTSLibrary (); - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + LoadARTSLibrary(); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); stream = 0; /* Set the function pointers */ @@ -204,7 +204,7 @@ /* This function waits until it is possible to write a full sound buffer */ static void -ARTS_WaitAudio (_THIS) +ARTS_WaitAudio(_THIS) { Sint32 ticks; @@ -215,26 +215,26 @@ that use a different process id for each thread. */ if (parent && (((++cnt) % 10) == 0)) { /* Check every 10 loops */ - if (kill (parent, 0) < 0) { + if (kill(parent, 0) < 0) { this->enabled = 0; } } } /* Use timer for general audio synchronization */ - ticks = ((Sint32) (next_frame - SDL_GetTicks ())) - FUDGE_TICKS; + ticks = ((Sint32) (next_frame - SDL_GetTicks())) - FUDGE_TICKS; if (ticks > 0) { - SDL_Delay (ticks); + SDL_Delay(ticks); } } static void -ARTS_PlayAudio (_THIS) +ARTS_PlayAudio(_THIS) { int written; /* Write the audio data */ - written = SDL_NAME (arts_write) (stream, mixbuf, mixlen); + written = SDL_NAME(arts_write) (stream, mixbuf, mixlen); /* If timer synchronization is enabled, set the next write frame */ if (frame_ticks) { @@ -246,32 +246,32 @@ this->enabled = 0; } #ifdef DEBUG_AUDIO - fprintf (stderr, "Wrote %d bytes of audio data\n", written); + fprintf(stderr, "Wrote %d bytes of audio data\n", written); #endif } static Uint8 * -ARTS_GetAudioBuf (_THIS) +ARTS_GetAudioBuf(_THIS) { return (mixbuf); } static void -ARTS_CloseAudio (_THIS) +ARTS_CloseAudio(_THIS) { if (mixbuf != NULL) { - SDL_FreeAudioMem (mixbuf); + SDL_FreeAudioMem(mixbuf); mixbuf = NULL; } if (stream) { - SDL_NAME (arts_close_stream) (stream); + SDL_NAME(arts_close_stream) (stream); stream = 0; } - SDL_NAME (arts_free) (); + SDL_NAME(arts_free) (); } static int -ARTS_OpenAudio (_THIS, SDL_AudioSpec * spec) +ARTS_OpenAudio(_THIS, SDL_AudioSpec * spec) { int bits, frag_spec; Uint16 test_format, format; @@ -284,10 +284,10 @@ /* Try for a closest match on audio format */ format = 0; bits = 0; - for (test_format = SDL_FirstAudioFormat (spec->format); + for (test_format = SDL_FirstAudioFormat(spec->format); !format && test_format;) { #ifdef DEBUG_AUDIO - fprintf (stderr, "Trying format 0x%4.4x\n", test_format); + fprintf(stderr, "Trying format 0x%4.4x\n", test_format); #endif switch (test_format) { case AUDIO_U8: @@ -303,52 +303,52 @@ break; } if (!format) { - test_format = SDL_NextAudioFormat (); + test_format = SDL_NextAudioFormat(); } } if (format == 0) { - SDL_SetError ("Couldn't find any hardware audio formats"); + SDL_SetError("Couldn't find any hardware audio formats"); return (-1); } spec->format = test_format; - if (SDL_NAME (arts_init) () != 0) { - SDL_SetError ("Unable to initialize ARTS"); + if (SDL_NAME(arts_init) () != 0) { + SDL_SetError("Unable to initialize ARTS"); return (-1); } stream = - SDL_NAME (arts_play_stream) (spec->freq, bits, spec->channels, "SDL"); + SDL_NAME(arts_play_stream) (spec->freq, bits, spec->channels, "SDL"); /* Calculate the final parameters for this audio specification */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Determine the power of two of the fragment size */ for (frag_spec = 0; (0x01 << frag_spec) < spec->size; ++frag_spec); if ((0x01 << frag_spec) != spec->size) { - SDL_SetError ("Fragment size must be a power of two"); + SDL_SetError("Fragment size must be a power of two"); return (-1); } frag_spec |= 0x00020000; /* two fragments, for low latency */ #ifdef ARTS_P_PACKET_SETTINGS - SDL_NAME (arts_stream_set) (stream, ARTS_P_PACKET_SETTINGS, frag_spec); + SDL_NAME(arts_stream_set) (stream, ARTS_P_PACKET_SETTINGS, frag_spec); #else - SDL_NAME (arts_stream_set) (stream, ARTS_P_PACKET_SIZE, - frag_spec & 0xffff); - SDL_NAME (arts_stream_set) (stream, ARTS_P_PACKET_COUNT, frag_spec >> 16); + SDL_NAME(arts_stream_set) (stream, ARTS_P_PACKET_SIZE, + frag_spec & 0xffff); + SDL_NAME(arts_stream_set) (stream, ARTS_P_PACKET_COUNT, frag_spec >> 16); #endif - spec->size = SDL_NAME (arts_stream_get) (stream, ARTS_P_PACKET_SIZE); + spec->size = SDL_NAME(arts_stream_get) (stream, ARTS_P_PACKET_SIZE); /* Allocate mixing buffer */ mixlen = spec->size; - mixbuf = (Uint8 *) SDL_AllocAudioMem (mixlen); + mixbuf = (Uint8 *) SDL_AllocAudioMem(mixlen); if (mixbuf == NULL) { return (-1); } - SDL_memset (mixbuf, spec->silence, spec->size); + SDL_memset(mixbuf, spec->silence, spec->size); /* Get the parent process id (we're the parent of the audio thread) */ - parent = getpid (); + parent = getpid(); /* We're ready to rock and roll. :-) */ return (0); diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/baudio/SDL_beaudio.cc --- a/src/audio/baudio/SDL_beaudio.cc Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/baudio/SDL_beaudio.cc Mon May 29 04:04:35 2006 +0000 @@ -38,44 +38,44 @@ /* Audio driver functions */ - static int BE_OpenAudio (_THIS, SDL_AudioSpec * spec); - static void BE_WaitAudio (_THIS); - static void BE_PlayAudio (_THIS); - static Uint8 *BE_GetAudioBuf (_THIS); - static void BE_CloseAudio (_THIS); + static int BE_OpenAudio(_THIS, SDL_AudioSpec * spec); + static void BE_WaitAudio(_THIS); + static void BE_PlayAudio(_THIS); + static Uint8 *BE_GetAudioBuf(_THIS); + static void BE_CloseAudio(_THIS); /* Audio driver bootstrap functions */ - static int Audio_Available (void) + static int Audio_Available(void) { return (1); } - static void Audio_DeleteDevice (SDL_AudioDevice * device) + static void Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } - static SDL_AudioDevice *Audio_CreateDevice (int devindex) + static SDL_AudioDevice *Audio_CreateDevice(int devindex) { SDL_AudioDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + device = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->OpenAudio = BE_OpenAudio; @@ -95,13 +95,13 @@ }; /* The BeOS callback for handling the audio buffer */ - static void FillSound (void *device, void *stream, size_t len, - const media_raw_audio_format & format) + static void FillSound(void *device, void *stream, size_t len, + const media_raw_audio_format & format) { SDL_AudioDevice *audio = (SDL_AudioDevice *) device; /* Silence the buffer, since it's ours */ - SDL_memset (stream, audio->spec.silence, len); + SDL_memset(stream, audio->spec.silence, len); /* Only do soemthing if audio is enabled */ if (!audio->enabled) @@ -109,56 +109,56 @@ if (!audio->paused) { if (audio->convert.needed) { - SDL_mutexP (audio->mixer_lock); + SDL_mutexP(audio->mixer_lock); (*audio->spec.callback) (audio->spec.userdata, (Uint8 *) audio->convert.buf, audio->convert.len); - SDL_mutexV (audio->mixer_lock); - SDL_ConvertAudio (&audio->convert); - SDL_memcpy (stream, audio->convert.buf, - audio->convert.len_cvt); + SDL_mutexV(audio->mixer_lock); + SDL_ConvertAudio(&audio->convert); + SDL_memcpy(stream, audio->convert.buf, + audio->convert.len_cvt); } else { - SDL_mutexP (audio->mixer_lock); + SDL_mutexP(audio->mixer_lock); (*audio->spec.callback) (audio->spec.userdata, (Uint8 *) stream, len); - SDL_mutexV (audio->mixer_lock); + SDL_mutexV(audio->mixer_lock); } } return; } /* Dummy functions -- we don't use thread-based audio */ - void BE_WaitAudio (_THIS) + void BE_WaitAudio(_THIS) { return; } - void BE_PlayAudio (_THIS) + void BE_PlayAudio(_THIS) { return; } - Uint8 *BE_GetAudioBuf (_THIS) + Uint8 *BE_GetAudioBuf(_THIS) { return (NULL); } - void BE_CloseAudio (_THIS) + void BE_CloseAudio(_THIS) { if (audio_obj) { - audio_obj->Stop (); + audio_obj->Stop(); delete audio_obj; audio_obj = NULL; } /* Quit the Be Application, if there's nothing left to do */ - SDL_QuitBeApp (); + SDL_QuitBeApp(); } - int BE_OpenAudio (_THIS, SDL_AudioSpec * spec) + int BE_OpenAudio(_THIS, SDL_AudioSpec * spec) { media_raw_audio_format format; /* Initialize the Be Application, if it's not already started */ - if (SDL_InitBeApp () < 0) { + if (SDL_InitBeApp() < 0) { return (-1); } @@ -188,20 +188,20 @@ format.buffer_size = spec->samples; /* Calculate the final parameters for this audio specification */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Subscribe to the audio stream (creates a new thread) */ { sigset_t omask; - SDL_MaskSignals (&omask); - audio_obj = new BSoundPlayer (&format, "SDL Audio", FillSound, - NULL, _this); - SDL_UnmaskSignals (&omask); + SDL_MaskSignals(&omask); + audio_obj = new BSoundPlayer(&format, "SDL Audio", FillSound, + NULL, _this); + SDL_UnmaskSignals(&omask); } - if (audio_obj->Start () == B_NO_ERROR) { - audio_obj->SetHasData (true); + if (audio_obj->Start() == B_NO_ERROR) { + audio_obj->SetHasData(true); } else { - SDL_SetError ("Unable to start Be audio"); + SDL_SetError("Unable to start Be audio"); return (-1); } diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/bsd/SDL_bsdaudio.c --- a/src/audio/bsd/SDL_bsdaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/bsd/SDL_bsdaudio.c Mon May 29 04:04:35 2006 +0000 @@ -67,59 +67,59 @@ #endif /* Audio driver functions */ -static void OBSD_WaitAudio (_THIS); -static int OBSD_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void OBSD_PlayAudio (_THIS); -static Uint8 *OBSD_GetAudioBuf (_THIS); -static void OBSD_CloseAudio (_THIS); +static void OBSD_WaitAudio(_THIS); +static int OBSD_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void OBSD_PlayAudio(_THIS); +static Uint8 *OBSD_GetAudioBuf(_THIS); +static void OBSD_CloseAudio(_THIS); #ifdef DEBUG_AUDIO -static void OBSD_Status (_THIS); +static void OBSD_Status(_THIS); #endif /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { int fd; int available; available = 0; - fd = SDL_OpenAudioPath (NULL, 0, OPEN_FLAGS, 0); + fd = SDL_OpenAudioPath(NULL, 0, OPEN_FLAGS, 0); if (fd >= 0) { available = 1; - close (fd); + close(fd); } return (available); } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) - SDL_free (this); + SDL_free(this); return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); audio_fd = -1; /* Set the function pointers */ @@ -141,7 +141,7 @@ /* This function waits until it is possible to write a full sound buffer */ static void -OBSD_WaitAudio (_THIS) +OBSD_WaitAudio(_THIS) { #ifndef USE_BLOCKING_WRITES /* Not necessary when using blocking writes */ /* See if we need to use timed audio synchronization */ @@ -149,63 +149,63 @@ /* Use timer for general audio synchronization */ Sint32 ticks; - ticks = ((Sint32) (next_frame - SDL_GetTicks ())) - FUDGE_TICKS; + ticks = ((Sint32) (next_frame - SDL_GetTicks())) - FUDGE_TICKS; if (ticks > 0) { - SDL_Delay (ticks); + SDL_Delay(ticks); } } else { /* Use select() for audio synchronization */ fd_set fdset; struct timeval timeout; - FD_ZERO (&fdset); - FD_SET (audio_fd, &fdset); + FD_ZERO(&fdset); + FD_SET(audio_fd, &fdset); timeout.tv_sec = 10; timeout.tv_usec = 0; #ifdef DEBUG_AUDIO - fprintf (stderr, "Waiting for audio to get ready\n"); + fprintf(stderr, "Waiting for audio to get ready\n"); #endif - if (select (audio_fd + 1, NULL, &fdset, NULL, &timeout) <= 0) { + if (select(audio_fd + 1, NULL, &fdset, NULL, &timeout) <= 0) { const char *message = "Audio timeout - buggy audio driver? (disabled)"; /* In general we should never print to the screen, but in this case we have no other way of letting the user know what happened. */ - fprintf (stderr, "SDL: %s\n", message); + fprintf(stderr, "SDL: %s\n", message); this->enabled = 0; /* Don't try to close - may hang */ audio_fd = -1; #ifdef DEBUG_AUDIO - fprintf (stderr, "Done disabling audio\n"); + fprintf(stderr, "Done disabling audio\n"); #endif } #ifdef DEBUG_AUDIO - fprintf (stderr, "Ready!\n"); + fprintf(stderr, "Ready!\n"); #endif } #endif /* !USE_BLOCKING_WRITES */ } static void -OBSD_PlayAudio (_THIS) +OBSD_PlayAudio(_THIS) { int written, p = 0; /* Write the audio data, checking for EAGAIN on broken audio drivers */ do { - written = write (audio_fd, &mixbuf[p], mixlen - p); + written = write(audio_fd, &mixbuf[p], mixlen - p); if (written > 0) p += written; if (written == -1 && errno != 0 && errno != EAGAIN && errno != EINTR) { /* Non recoverable error has occurred. It should be reported!!! */ - perror ("audio"); + perror("audio"); break; } if (p < written || ((written < 0) && ((errno == 0) || (errno == EAGAIN)))) { - SDL_Delay (1); /* Let a little CPU time go by */ + SDL_Delay(1); /* Let a little CPU time go by */ } } while (p < written); @@ -220,147 +220,147 @@ this->enabled = 0; } #ifdef DEBUG_AUDIO - fprintf (stderr, "Wrote %d bytes of audio data\n", written); + fprintf(stderr, "Wrote %d bytes of audio data\n", written); #endif } static Uint8 * -OBSD_GetAudioBuf (_THIS) +OBSD_GetAudioBuf(_THIS) { return (mixbuf); } static void -OBSD_CloseAudio (_THIS) +OBSD_CloseAudio(_THIS) { if (mixbuf != NULL) { - SDL_FreeAudioMem (mixbuf); + SDL_FreeAudioMem(mixbuf); mixbuf = NULL; } if (audio_fd >= 0) { - close (audio_fd); + close(audio_fd); audio_fd = -1; } } #ifdef DEBUG_AUDIO void -OBSD_Status (_THIS) +OBSD_Status(_THIS) { audio_info_t info; - if (ioctl (audio_fd, AUDIO_GETINFO, &info) < 0) { - fprintf (stderr, "AUDIO_GETINFO failed.\n"); + if (ioctl(audio_fd, AUDIO_GETINFO, &info) < 0) { + fprintf(stderr, "AUDIO_GETINFO failed.\n"); return; } - fprintf (stderr, "\n" - "[play/record info]\n" - "buffer size : %d bytes\n" - "sample rate : %i Hz\n" - "channels : %i\n" - "precision : %i-bit\n" - "encoding : 0x%x\n" - "seek : %i\n" - "sample count : %i\n" - "EOF count : %i\n" - "paused : %s\n" - "error occured : %s\n" - "waiting : %s\n" - "active : %s\n" - "", - info. - play. - buffer_size, - info. - play. - sample_rate, - info. - play. - channels, - info. - play. - precision, - info. - play. - encoding, - info. - play. - seek, - info. - play. - samples, - info. - play. - eof, - info. - play. - pause - ? - "yes" - : - "no", - info. - play. - error - ? - "yes" - : - "no", - info. - play.waiting ? "yes" : "no", info.play.active ? "yes" : "no"); + fprintf(stderr, "\n" + "[play/record info]\n" + "buffer size : %d bytes\n" + "sample rate : %i Hz\n" + "channels : %i\n" + "precision : %i-bit\n" + "encoding : 0x%x\n" + "seek : %i\n" + "sample count : %i\n" + "EOF count : %i\n" + "paused : %s\n" + "error occured : %s\n" + "waiting : %s\n" + "active : %s\n" + "", + info. + play. + buffer_size, + info. + play. + sample_rate, + info. + play. + channels, + info. + play. + precision, + info. + play. + encoding, + info. + play. + seek, + info. + play. + samples, + info. + play. + eof, + info. + play. + pause + ? + "yes" + : + "no", + info. + play. + error + ? + "yes" + : + "no", + info. + play.waiting ? "yes" : "no", info.play.active ? "yes" : "no"); - fprintf (stderr, "\n" - "[audio info]\n" - "monitor_gain : %i\n" - "hw block size : %d bytes\n" - "hi watermark : %i\n" - "lo watermark : %i\n" - "audio mode : %s\n" - "", - info.monitor_gain, - info.blocksize, - info.hiwat, info.lowat, - (info.mode == AUMODE_PLAY) ? "PLAY" - : (info.mode = AUMODE_RECORD) ? "RECORD" - : (info.mode == AUMODE_PLAY_ALL ? "PLAY_ALL" : "?")); + fprintf(stderr, "\n" + "[audio info]\n" + "monitor_gain : %i\n" + "hw block size : %d bytes\n" + "hi watermark : %i\n" + "lo watermark : %i\n" + "audio mode : %s\n" + "", + info.monitor_gain, + info.blocksize, + info.hiwat, info.lowat, + (info.mode == AUMODE_PLAY) ? "PLAY" + : (info.mode = AUMODE_RECORD) ? "RECORD" + : (info.mode == AUMODE_PLAY_ALL ? "PLAY_ALL" : "?")); } #endif /* DEBUG_AUDIO */ static int -OBSD_OpenAudio (_THIS, SDL_AudioSpec * spec) +OBSD_OpenAudio(_THIS, SDL_AudioSpec * spec) { char audiodev[64]; Uint16 format; audio_info_t info; - AUDIO_INITINFO (&info); + AUDIO_INITINFO(&info); /* Calculate the final parameters for this audio specification */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); #ifdef USE_TIMER_SYNC frame_ticks = 0.0; #endif /* Open the audio device */ - audio_fd = SDL_OpenAudioPath (audiodev, sizeof (audiodev), OPEN_FLAGS, 0); + audio_fd = SDL_OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0); if (audio_fd < 0) { - SDL_SetError ("Couldn't open %s: %s", audiodev, strerror (errno)); + SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno)); return (-1); } /* Set to play mode */ info.mode = AUMODE_PLAY; - if (ioctl (audio_fd, AUDIO_SETINFO, &info) < 0) { - SDL_SetError ("Couldn't put device into play mode"); + if (ioctl(audio_fd, AUDIO_SETINFO, &info) < 0) { + SDL_SetError("Couldn't put device into play mode"); return (-1); } mixbuf = NULL; - AUDIO_INITINFO (&info); - for (format = SDL_FirstAudioFormat (spec->format); - format; format = SDL_NextAudioFormat ()) { + AUDIO_INITINFO(&info); + for (format = SDL_FirstAudioFormat(spec->format); + format; format = SDL_NextAudioFormat()) { switch (format) { case AUDIO_U8: info.play.encoding = AUDIO_ENCODING_ULINEAR; @@ -389,42 +389,42 @@ default: continue; } - if (ioctl (audio_fd, AUDIO_SETINFO, &info) == 0) + if (ioctl(audio_fd, AUDIO_SETINFO, &info) == 0) break; } if (!format) { - SDL_SetError ("No supported encoding for 0x%x", spec->format); + SDL_SetError("No supported encoding for 0x%x", spec->format); return (-1); } spec->format = format; - AUDIO_INITINFO (&info); + AUDIO_INITINFO(&info); info.play.channels = spec->channels; - if (ioctl (audio_fd, AUDIO_SETINFO, &info) == -1) + if (ioctl(audio_fd, AUDIO_SETINFO, &info) == -1) spec->channels = 1; - AUDIO_INITINFO (&info); + AUDIO_INITINFO(&info); info.play.sample_rate = spec->freq; info.blocksize = spec->size; info.hiwat = 5; info.lowat = 3; - (void) ioctl (audio_fd, AUDIO_SETINFO, &info); - (void) ioctl (audio_fd, AUDIO_GETINFO, &info); + (void) ioctl(audio_fd, AUDIO_SETINFO, &info); + (void) ioctl(audio_fd, AUDIO_GETINFO, &info); spec->freq = info.play.sample_rate; /* Allocate mixing buffer */ mixlen = spec->size; - mixbuf = (Uint8 *) SDL_AllocAudioMem (mixlen); + mixbuf = (Uint8 *) SDL_AllocAudioMem(mixlen); if (mixbuf == NULL) { return (-1); } - SDL_memset (mixbuf, spec->silence, spec->size); + SDL_memset(mixbuf, spec->silence, spec->size); /* Get the parent process id (we're the parent of the audio thread) */ - parent = getpid (); + parent = getpid(); #ifdef DEBUG_AUDIO - OBSD_Status (this); + OBSD_Status(this); #endif /* We're ready to rock and roll. :-) */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/dart/SDL_dart.c --- a/src/audio/dart/SDL_dart.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/dart/SDL_dart.c Mon May 29 04:04:35 2006 +0000 @@ -46,7 +46,7 @@ // playback of a buffer, etc... //--------------------------------------------------------------------- LONG APIENTRY -DARTEventFunc (ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, ULONG ulFlags) +DARTEventFunc(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, ULONG ulFlags) { if (ulFlags && MIX_WRITE_COMPLETE) { // Playback of buffer completed! @@ -62,8 +62,8 @@ pBufDesc->iBufferUsage = BUFFER_EMPTY; // And notify DART feeder thread that it will have to work a bit. if (pSDLAudioDevice) - DosPostEventSem (pSDLAudioDevice->hidden-> - hevAudioBufferPlayed); + DosPostEventSem(pSDLAudioDevice->hidden-> + hevAudioBufferPlayed); } } } @@ -72,7 +72,7 @@ int -DART_OpenAudio (_THIS, SDL_AudioSpec * spec) +DART_OpenAudio(_THIS, SDL_AudioSpec * spec) { MCI_AMP_OPEN_PARMS AmpOpenParms; MCI_GENERIC_PARMS GenericParms; @@ -88,7 +88,7 @@ int rc; // First thing is to try to open a given DART device! - SDL_memset (&AmpOpenParms, 0, sizeof (MCI_AMP_OPEN_PARMS)); + SDL_memset(&AmpOpenParms, 0, sizeof(MCI_AMP_OPEN_PARMS)); // pszDeviceType should contain the device type in low word, and device ordinal in high word! AmpOpenParms.pszDeviceType = (PSZ) (MCI_DEVTYPE_AUDIO_AMPMIX | (iDeviceOrd << 16)); @@ -97,7 +97,7 @@ if (bOpenShared) iOpenMode |= MCI_OPEN_SHAREABLE; - rc = mciSendCommand (0, MCI_OPEN, iOpenMode, (PVOID) & AmpOpenParms, 0); + rc = mciSendCommand(0, MCI_OPEN, iOpenMode, (PVOID) & AmpOpenParms, 0); if (rc != MCIERR_SUCCESS) // No audio available?? return (-1); // Save the device ID we got from DART! @@ -120,19 +120,19 @@ break; default: // Close DART, and exit with error code! - mciSendCommand (iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); - SDL_SetError ("Unsupported audio format"); + mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); + SDL_SetError("Unsupported audio format"); return (-1); } iFreq = spec->freq; iChannels = spec->channels; /* Update the fragment size as size in bytes */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); iBufSize = spec->size; // Now query this device if it supports the given freq/bits/channels! - SDL_memset (&(_this->hidden->MixSetupParms), 0, - sizeof (MCI_MIXSETUP_PARMS)); + SDL_memset(&(_this->hidden->MixSetupParms), 0, + sizeof(MCI_MIXSETUP_PARMS)); _this->hidden->MixSetupParms.ulBitsPerSample = iBits; _this->hidden->MixSetupParms.ulFormatTag = MCI_WAVE_FORMAT_PCM; _this->hidden->MixSetupParms.ulSamplesPerSec = iFreq; @@ -140,34 +140,34 @@ _this->hidden->MixSetupParms.ulFormatMode = MCI_PLAY; _this->hidden->MixSetupParms.ulDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; _this->hidden->MixSetupParms.pmixEvent = DARTEventFunc; - rc = mciSendCommand (iDeviceOrd, MCI_MIXSETUP, - MCI_WAIT | MCI_MIXSETUP_QUERYMODE, - &(_this->hidden->MixSetupParms), 0); + rc = mciSendCommand(iDeviceOrd, MCI_MIXSETUP, + MCI_WAIT | MCI_MIXSETUP_QUERYMODE, + &(_this->hidden->MixSetupParms), 0); if (rc != MCIERR_SUCCESS) { // The device cannot handle this format! // Close DART, and exit with error code! - mciSendCommand (iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); - SDL_SetError ("Audio device doesn't support requested audio format"); + mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); + SDL_SetError("Audio device doesn't support requested audio format"); return (-1); } // The device can handle this format, so initialize! - rc = mciSendCommand (iDeviceOrd, MCI_MIXSETUP, - MCI_WAIT | MCI_MIXSETUP_INIT, - &(_this->hidden->MixSetupParms), 0); + rc = mciSendCommand(iDeviceOrd, MCI_MIXSETUP, + MCI_WAIT | MCI_MIXSETUP_INIT, + &(_this->hidden->MixSetupParms), 0); if (rc != MCIERR_SUCCESS) { // The device could not be opened! // Close DART, and exit with error code! - mciSendCommand (iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); - SDL_SetError ("Audio device could not be set up"); + mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); + SDL_SetError("Audio device could not be set up"); return (-1); } // Ok, the device is initialized. // Now we should allocate buffers. For this, we need a place where // the buffer descriptors will be: _this->hidden->pMixBuffers = - (MCI_MIX_BUFFER *) SDL_malloc (sizeof (MCI_MIX_BUFFER) * iNumBufs); + (MCI_MIX_BUFFER *) SDL_malloc(sizeof(MCI_MIX_BUFFER) * iNumBufs); if (!(_this->hidden->pMixBuffers)) { // Not enough memory! // Close DART, and exit with error code! - mciSendCommand (iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); - SDL_SetError ("Not enough memory for audio buffer descriptors"); + mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); + SDL_SetError("Not enough memory for audio buffer descriptors"); return (-1); } // Now that we have the place for buffer list, we can ask DART for the @@ -176,17 +176,17 @@ _this->hidden->BufferParms.ulBufferSize = iBufSize; // each with this size _this->hidden->BufferParms.pBufList = _this->hidden->pMixBuffers; // getting descriptorts into this list // Allocate buffers! - rc = mciSendCommand (iDeviceOrd, MCI_BUFFER, - MCI_WAIT | MCI_ALLOCATE_MEMORY, - &(_this->hidden->BufferParms), 0); + rc = mciSendCommand(iDeviceOrd, MCI_BUFFER, + MCI_WAIT | MCI_ALLOCATE_MEMORY, + &(_this->hidden->BufferParms), 0); if ((rc != MCIERR_SUCCESS) || (iNumBufs != _this->hidden->BufferParms.ulNumBuffers) || (_this->hidden->BufferParms.ulBufferSize == 0)) { // Could not allocate memory! // Close DART, and exit with error code! - SDL_free (_this->hidden->pMixBuffers); + SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL; - mciSendCommand (iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); - SDL_SetError ("DART could not allocate buffers"); + mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); + SDL_SetError("DART could not allocate buffers"); return (-1); } // Ok, we have all the buffers allocated, let's mark them! @@ -194,7 +194,7 @@ int i; for (i = 0; i < iNumBufs; i++) { pMixBufferDesc pBufferDesc = - (pMixBufferDesc) SDL_malloc (sizeof (tMixBufferDesc));; + (pMixBufferDesc) SDL_malloc(sizeof(tMixBufferDesc));; // Check if this buffer was really allocated by DART if ((!(_this->hidden->pMixBuffers[i].pBuffer)) || (!pBufferDesc)) { // Wrong buffer! @@ -203,18 +203,18 @@ { int j; for (j = 0; j < i; j++) - SDL_free ((void *) (_this->hidden->pMixBuffers[j]. - ulUserParm)); + SDL_free((void *) (_this->hidden->pMixBuffers[j]. + ulUserParm)); } // and cleanup - mciSendCommand (iDeviceOrd, MCI_BUFFER, - MCI_WAIT | MCI_DEALLOCATE_MEMORY, - &(_this->hidden->BufferParms), 0); - SDL_free (_this->hidden->pMixBuffers); + mciSendCommand(iDeviceOrd, MCI_BUFFER, + MCI_WAIT | MCI_DEALLOCATE_MEMORY, + &(_this->hidden->BufferParms), 0); + SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL; - mciSendCommand (iDeviceOrd, MCI_CLOSE, MCI_WAIT, - &GenericParms, 0); - SDL_SetError ("Error at internal buffer check"); + mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, + &GenericParms, 0); + SDL_SetError("Error at internal buffer check"); return (-1); } pBufferDesc->iBufferUsage = BUFFER_EMPTY; @@ -226,8 +226,8 @@ _this->hidden->pMixBuffers[i].ulFlags = 0; // Some stuff should be flagged here for DART, like end of // audio data, but as we will continously send // audio data, there will be no end.:) - SDL_memset (_this->hidden->pMixBuffers[i].pBuffer, iSilence, - iBufSize); + SDL_memset(_this->hidden->pMixBuffers[i].pBuffer, iSilence, + iBufSize); } } _this->hidden->iNextFreeBuffer = 0; @@ -240,16 +240,15 @@ { int i; for (i = 0; i < iNumBufs; i++) - SDL_free ((void *) (_this->hidden->pMixBuffers[i]. - ulUserParm)); + SDL_free((void *) (_this->hidden->pMixBuffers[i].ulUserParm)); } - mciSendCommand (iDeviceOrd, MCI_BUFFER, - MCI_WAIT | MCI_DEALLOCATE_MEMORY, - &(_this->hidden->BufferParms), 0); - SDL_free (_this->hidden->pMixBuffers); + mciSendCommand(iDeviceOrd, MCI_BUFFER, + MCI_WAIT | MCI_DEALLOCATE_MEMORY, + &(_this->hidden->BufferParms), 0); + SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL; - mciSendCommand (iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); - SDL_SetError ("Could not create event semaphore"); + mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); + SDL_SetError("Could not create event semaphore"); return (-1); } // Store the new settings in global variables @@ -266,20 +265,20 @@ void -DART_ThreadInit (_THIS) +DART_ThreadInit(_THIS) { return; } /* This function waits until it is possible to write a full sound buffer */ void -DART_WaitAudio (_THIS) +DART_WaitAudio(_THIS) { int i; pMixBufferDesc pBufDesc; ULONG ulPostCount; - DosResetEventSem (_this->hidden->hevAudioBufferPlayed, &ulPostCount); + DosResetEventSem(_this->hidden->hevAudioBufferPlayed, &ulPostCount); // If there is already an empty buffer, then return now! for (i = 0; i < _this->hidden->iCurrNumBufs; i++) { pBufDesc = (pMixBufferDesc) _this->hidden->pMixBuffers[i].ulUserParm; @@ -287,12 +286,12 @@ return; } // If there is no empty buffer, wait for one to be empty! - DosWaitEventSem (_this->hidden->hevAudioBufferPlayed, 1000); // Wait max 1 sec!!! Important! + DosWaitEventSem(_this->hidden->hevAudioBufferPlayed, 1000); // Wait max 1 sec!!! Important! return; } void -DART_PlayAudio (_THIS) +DART_PlayAudio(_THIS) { int iFreeBuf = _this->hidden->iNextFreeBuffer; pMixBufferDesc pBufDesc; @@ -301,10 +300,10 @@ (pMixBufferDesc) _this->hidden->pMixBuffers[iFreeBuf].ulUserParm; pBufDesc->iBufferUsage = BUFFER_USED; // Send it to DART to be queued - _this->hidden->MixSetupParms.pmixWrite (_this->hidden->MixSetupParms. - ulMixHandle, - &(_this->hidden-> - pMixBuffers[iFreeBuf]), 1); + _this->hidden->MixSetupParms.pmixWrite(_this->hidden->MixSetupParms. + ulMixHandle, + &(_this->hidden-> + pMixBuffers[iFreeBuf]), 1); _this->hidden->iLastPlayedBuf = iFreeBuf; iFreeBuf = (iFreeBuf + 1) % _this->hidden->iCurrNumBufs; @@ -312,7 +311,7 @@ } Uint8 * -DART_GetAudioBuf (_THIS) +DART_GetAudioBuf(_THIS) { int iFreeBuf; Uint8 *pResult; @@ -331,18 +330,18 @@ return pResult; } } else - printf ("[DART_GetAudioBuf] : ERROR! pBufDesc = %p\n", - pBufDesc); + printf("[DART_GetAudioBuf] : ERROR! pBufDesc = %p\n", + pBufDesc); } else - printf ("[DART_GetAudioBuf] : ERROR! _this->hidden = %p\n", - _this->hidden); + printf("[DART_GetAudioBuf] : ERROR! _this->hidden = %p\n", + _this->hidden); } else - printf ("[DART_GetAudioBuf] : ERROR! _this = %p\n", _this); + printf("[DART_GetAudioBuf] : ERROR! _this = %p\n", _this); return NULL; } void -DART_WaitDone (_THIS) +DART_WaitDone(_THIS) { pMixBufferDesc pBufDesc; ULONG ulPostCount; @@ -354,84 +353,84 @@ ulUserParm; rc = NO_ERROR; while ((pBufDesc->iBufferUsage != BUFFER_EMPTY) && (rc == NO_ERROR)) { - DosResetEventSem (_this->hidden->hevAudioBufferPlayed, &ulPostCount); - rc = DosWaitEventSem (_this->hidden->hevAudioBufferPlayed, 1000); // 1 sec timeout! Important! + DosResetEventSem(_this->hidden->hevAudioBufferPlayed, &ulPostCount); + rc = DosWaitEventSem(_this->hidden->hevAudioBufferPlayed, 1000); // 1 sec timeout! Important! } } void -DART_CloseAudio (_THIS) +DART_CloseAudio(_THIS) { MCI_GENERIC_PARMS GenericParms; int rc; // Stop DART playback - rc = mciSendCommand (_this->hidden->iCurrDeviceOrd, MCI_STOP, MCI_WAIT, - &GenericParms, 0); + rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_STOP, MCI_WAIT, + &GenericParms, 0); if (rc != MCIERR_SUCCESS) { #ifdef SFX_DEBUG_BUILD - printf ("Could not stop DART playback!\n"); - fflush (stdout); + printf("Could not stop DART playback!\n"); + fflush(stdout); #endif } // Close event semaphore - DosCloseEventSem (_this->hidden->hevAudioBufferPlayed); + DosCloseEventSem(_this->hidden->hevAudioBufferPlayed); // Free memory of buffer descriptions { int i; for (i = 0; i < _this->hidden->iCurrNumBufs; i++) - SDL_free ((void *) (_this->hidden->pMixBuffers[i].ulUserParm)); + SDL_free((void *) (_this->hidden->pMixBuffers[i].ulUserParm)); } // Deallocate buffers - rc = mciSendCommand (_this->hidden->iCurrDeviceOrd, MCI_BUFFER, - MCI_WAIT | MCI_DEALLOCATE_MEMORY, - &(_this->hidden->BufferParms), 0); + rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_BUFFER, + MCI_WAIT | MCI_DEALLOCATE_MEMORY, + &(_this->hidden->BufferParms), 0); // Free bufferlist - SDL_free (_this->hidden->pMixBuffers); + SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL; // Close dart - rc = mciSendCommand (_this->hidden->iCurrDeviceOrd, MCI_CLOSE, MCI_WAIT, - &(GenericParms), 0); + rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_CLOSE, MCI_WAIT, + &(GenericParms), 0); } /* Audio driver bootstrap functions */ int -Audio_Available (void) +Audio_Available(void) { return (1); } void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) - SDL_free (this); + SDL_free(this); return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = DART_OpenAudio; diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/dc/SDL_dcaudio.c --- a/src/audio/dc/SDL_dcaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/dc/SDL_dcaudio.c Mon May 29 04:04:35 2006 +0000 @@ -35,46 +35,46 @@ #include /* Audio driver functions */ -static int DCAUD_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void DCAUD_WaitAudio (_THIS); -static void DCAUD_PlayAudio (_THIS); -static Uint8 *DCAUD_GetAudioBuf (_THIS); -static void DCAUD_CloseAudio (_THIS); +static int DCAUD_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void DCAUD_WaitAudio(_THIS); +static void DCAUD_PlayAudio(_THIS); +static Uint8 *DCAUD_GetAudioBuf(_THIS); +static void DCAUD_CloseAudio(_THIS); /* Audio driver bootstrap functions */ static int -DCAUD_Available (void) +DCAUD_Available(void) { return 1; } static void -DCAUD_DeleteDevice (SDL_AudioDevice * device) +DCAUD_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -DCAUD_CreateDevice (int devindex) +DCAUD_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = DCAUD_OpenAudio; @@ -85,7 +85,7 @@ this->free = DCAUD_DeleteDevice; - spu_init (); + spu_init(); return this; } @@ -97,12 +97,12 @@ /* This function waits until it is possible to write a full sound buffer */ static void -DCAUD_WaitAudio (_THIS) +DCAUD_WaitAudio(_THIS) { if (this->hidden->playing) { /* wait */ - while (aica_get_pos (0) / this->spec.samples == this->hidden->nextbuf) { - thd_pass (); + while (aica_get_pos(0) / this->spec.samples == this->hidden->nextbuf) { + thd_pass(); } } } @@ -110,7 +110,7 @@ #define SPU_RAM_BASE 0xa0800000 static void -spu_memload_stereo8 (int leftpos, int rightpos, void *src0, size_t size) +spu_memload_stereo8(int leftpos, int rightpos, void *src0, size_t size) { uint8 *src = src0; uint32 *left = (uint32 *) (leftpos + SPU_RAM_BASE); @@ -126,14 +126,14 @@ rval |= (*src++) << 16; lval |= (*src++) << 24; rval |= (*src++) << 24; - g2_write_32 (left++, lval); - g2_write_32 (right++, rval); - g2_fifo_wait (); + g2_write_32(left++, lval); + g2_write_32(right++, rval); + g2_fifo_wait(); } } static void -spu_memload_stereo16 (int leftpos, int rightpos, void *src0, size_t size) +spu_memload_stereo16(int leftpos, int rightpos, void *src0, size_t size) { uint16 *src = src0; uint32 *left = (uint32 *) (leftpos + SPU_RAM_BASE); @@ -145,22 +145,22 @@ rval = *src++; lval |= (*src++) << 16; rval |= (*src++) << 16; - g2_write_32 (left++, lval); - g2_write_32 (right++, rval); - g2_fifo_wait (); + g2_write_32(left++, lval); + g2_write_32(right++, rval); + g2_fifo_wait(); } } static void -DCAUD_PlayAudio (_THIS) +DCAUD_PlayAudio(_THIS) { SDL_AudioSpec *spec = &this->spec; unsigned int offset; if (this->hidden->playing) { /* wait */ - while (aica_get_pos (0) / spec->samples == this->hidden->nextbuf) { - thd_pass (); + while (aica_get_pos(0) / spec->samples == this->hidden->nextbuf) { + thd_pass(); } } @@ -168,18 +168,18 @@ this->hidden->nextbuf ^= 1; /* Write the audio data, checking for EAGAIN on broken audio drivers */ if (spec->channels == 1) { - spu_memload (this->hidden->leftpos + offset, this->hidden->mixbuf, - this->hidden->mixlen); + spu_memload(this->hidden->leftpos + offset, this->hidden->mixbuf, + this->hidden->mixlen); } else { offset /= 2; if ((this->spec.format & 255) == 8) { - spu_memload_stereo8 (this->hidden->leftpos + offset, + spu_memload_stereo8(this->hidden->leftpos + offset, + this->hidden->rightpos + offset, + this->hidden->mixbuf, this->hidden->mixlen); + } else { + spu_memload_stereo16(this->hidden->leftpos + offset, this->hidden->rightpos + offset, this->hidden->mixbuf, this->hidden->mixlen); - } else { - spu_memload_stereo16 (this->hidden->leftpos + offset, - this->hidden->rightpos + offset, - this->hidden->mixbuf, this->hidden->mixlen); } } @@ -188,37 +188,37 @@ this->hidden->playing = 1; mode = (spec->format == AUDIO_S8) ? SM_8BIT : SM_16BIT; if (spec->channels == 1) { - aica_play (0, mode, this->hidden->leftpos, 0, - spec->samples * 2, spec->freq, 255, 128, 1); + aica_play(0, mode, this->hidden->leftpos, 0, + spec->samples * 2, spec->freq, 255, 128, 1); } else { - aica_play (0, mode, this->hidden->leftpos, 0, - spec->samples * 2, spec->freq, 255, 0, 1); - aica_play (1, mode, this->hidden->rightpos, 0, - spec->samples * 2, spec->freq, 255, 255, 1); + aica_play(0, mode, this->hidden->leftpos, 0, + spec->samples * 2, spec->freq, 255, 0, 1); + aica_play(1, mode, this->hidden->rightpos, 0, + spec->samples * 2, spec->freq, 255, 255, 1); } } } static Uint8 * -DCAUD_GetAudioBuf (_THIS) +DCAUD_GetAudioBuf(_THIS) { return (this->hidden->mixbuf); } static void -DCAUD_CloseAudio (_THIS) +DCAUD_CloseAudio(_THIS) { - aica_stop (0); + aica_stop(0); if (this->spec.channels == 2) - aica_stop (1); + aica_stop(1); if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem (this->hidden->mixbuf); + SDL_FreeAudioMem(this->hidden->mixbuf); this->hidden->mixbuf = NULL; } } static int -DCAUD_OpenAudio (_THIS, SDL_AudioSpec * spec) +DCAUD_OpenAudio(_THIS, SDL_AudioSpec * spec) { switch (spec->format & 0xff) { case 8: @@ -228,20 +228,20 @@ spec->format = AUDIO_S16LSB; break; default: - SDL_SetError ("Unsupported audio format"); + SDL_SetError("Unsupported audio format"); return (-1); } /* Update the fragment size as size in bytes */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Allocate mixing buffer */ this->hidden->mixlen = spec->size; - this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem (this->hidden->mixlen); + this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen); if (this->hidden->mixbuf == NULL) { return (-1); } - SDL_memset (this->hidden->mixbuf, spec->silence, spec->size); + SDL_memset(this->hidden->mixbuf, spec->silence, spec->size); this->hidden->leftpos = 0x11000; this->hidden->rightpos = 0x11000 + spec->size; this->hidden->playing = 0; diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/dc/aica.c --- a/src/audio/dc/aica.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/dc/aica.c Mon May 29 04:04:35 2006 +0000 @@ -42,28 +42,28 @@ void -aica_init () +aica_init() { int i, j, old = 0; /* Initialize AICA channels */ - G2_LOCK (old); - SNDREG32 (0x2800) = 0x0000; + G2_LOCK(old); + SNDREG32(0x2800) = 0x0000; for (i = 0; i < 64; i++) { for (j = 0; j < 0x80; j += 4) { if ((j & 31) == 0) - g2_fifo_wait (); - CHNREG32 (i, j) = 0; + g2_fifo_wait(); + CHNREG32(i, j) = 0; } - g2_fifo_wait (); - CHNREG32 (i, 0) = 0x8000; - CHNREG32 (i, 20) = 0x1f; + g2_fifo_wait(); + CHNREG32(i, 0) = 0x8000; + CHNREG32(i, 20) = 0x1f; } - SNDREG32 (0x2800) = 0x000f; - g2_fifo_wait (); - G2_UNLOCK (old); + SNDREG32(0x2800) = 0x000f; + g2_fifo_wait(); + G2_UNLOCK(old); } /* Translates a volume from linear form to logarithmic form (required by @@ -119,7 +119,7 @@ //#define AICA_VOL(x) (0xff - logs[x&255]) static inline unsigned -AICA_FREQ (unsigned freq) +AICA_FREQ(unsigned freq) { unsigned long freq_lo, freq_base = 5644800; int freq_hi = 7; @@ -156,8 +156,8 @@ 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) +aica_play(int ch, int mode, unsigned long smpptr, int loopst, int loopend, + int freq, int vol, int pan, int loopflag) { /* int i; */ @@ -165,7 +165,7 @@ int old = 0; /* Stop the channel (if it's already playing) */ - aica_stop (ch); + aica_stop(ch); /* doesn't seem to be needed, but it's here just in case */ /* for (i=0; i<256; i++) { @@ -175,26 +175,26 @@ asm("nop"); } */ - G2_LOCK (old); + G2_LOCK(old); /* Envelope setup. The first of these is the loop point, e.g., where the sample starts over when it loops. The second is the loop end. This is the full length of the sample when you are not looping, or the loop end point when you are (though storing more than that is a waste of memory if you're not doing volume enveloping). */ - CHNREG32 (ch, 8) = loopst & 0xffff; - CHNREG32 (ch, 12) = loopend & 0xffff; + CHNREG32(ch, 8) = loopst & 0xffff; + CHNREG32(ch, 12) = loopend & 0xffff; /* Write resulting values */ - CHNREG32 (ch, 24) = AICA_FREQ (freq); + CHNREG32(ch, 24) = AICA_FREQ(freq); /* Set volume, pan, and some other things that we don't know what they do =) */ - CHNREG32 (ch, 36) = AICA_PAN (pan) | (0xf << 8); + CHNREG32(ch, 36) = AICA_PAN(pan) | (0xf << 8); /* Convert the incoming volume and pan into hardware values */ /* Vol starts at zero so we can ramp */ - vol = AICA_VOL (vol); - CHNREG32 (ch, 40) = 0x24 | (vol << 8); + vol = AICA_VOL(vol); + CHNREG32(ch, 40) = 0x24 | (vol << 8); /* Convert the incoming volume and pan into hardware values */ /* Vol starts at zero so we can ramp */ @@ -205,44 +205,44 @@ default (below) sets it into normal mode (play and terminate/loop). CHNREG32(ch, 16) = 0xf010; */ - CHNREG32 (ch, 16) = 0x1f; /* No volume envelope */ + CHNREG32(ch, 16) = 0x1f; /* No volume envelope */ /* Set sample format, buffer address, and looping control. If 0x0200 mask is set on reg 0, the sample loops infinitely. If it's not set, the sample plays once and terminates. We'll also set the bits to start playback here. */ - CHNREG32 (ch, 4) = smpptr & 0xffff; + CHNREG32(ch, 4) = smpptr & 0xffff; val = 0xc000 | 0x0000 | (mode << 7) | (smpptr >> 16); if (loopflag) val |= 0x200; - CHNREG32 (ch, 0) = val; + CHNREG32(ch, 0) = val; - G2_UNLOCK (old); + G2_UNLOCK(old); /* Enable playback */ /* CHNREG32(ch, 0) |= 0xc000; */ - g2_fifo_wait (); + g2_fifo_wait(); #if 0 for (i = 0xff; i >= vol; i--) { if ((i & 7) == 0) - g2_fifo_wait (); - CHNREG32 (ch, 40) = 0x24 | (i << 8);; + g2_fifo_wait(); + CHNREG32(ch, 40) = 0x24 | (i << 8);; } - g2_fifo_wait (); + g2_fifo_wait(); #endif } /* Stop the sound on a given channel */ void -aica_stop (int ch) +aica_stop(int ch) { - g2_write_32 (CHNREGADDR (ch, 0), - (g2_read_32 (CHNREGADDR (ch, 0)) & ~0x4000) | 0x8000); - g2_fifo_wait (); + g2_write_32(CHNREGADDR(ch, 0), + (g2_read_32(CHNREGADDR(ch, 0)) & ~0x4000) | 0x8000); + g2_fifo_wait(); } @@ -251,50 +251,50 @@ /* Set channel volume */ void -aica_vol (int ch, int vol) +aica_vol(int ch, int vol) { // g2_write_8(CHNREGADDR(ch, 41),AICA_VOL(vol)); - g2_write_32 (CHNREGADDR (ch, 40), - (g2_read_32 (CHNREGADDR (ch, 40)) & 0xffff00ff) | - (AICA_VOL (vol) << 8)); - g2_fifo_wait (); + g2_write_32(CHNREGADDR(ch, 40), + (g2_read_32(CHNREGADDR(ch, 40)) & 0xffff00ff) | + (AICA_VOL(vol) << 8)); + g2_fifo_wait(); } /* Set channel pan */ void -aica_pan (int ch, int pan) +aica_pan(int ch, int pan) { // g2_write_8(CHNREGADDR(ch, 36),AICA_PAN(pan)); - g2_write_32 (CHNREGADDR (ch, 36), - (g2_read_32 (CHNREGADDR (ch, 36)) & 0xffffff00) | - (AICA_PAN (pan))); - g2_fifo_wait (); + g2_write_32(CHNREGADDR(ch, 36), + (g2_read_32(CHNREGADDR(ch, 36)) & 0xffffff00) | + (AICA_PAN(pan))); + g2_fifo_wait(); } /* Set channel frequency */ void -aica_freq (int ch, int freq) +aica_freq(int ch, int freq) { - g2_write_32 (CHNREGADDR (ch, 24), AICA_FREQ (freq)); - g2_fifo_wait (); + g2_write_32(CHNREGADDR(ch, 24), AICA_FREQ(freq)); + g2_fifo_wait(); } /* Get channel position */ int -aica_get_pos (int ch) +aica_get_pos(int ch) { #if 1 /* Observe channel ch */ - g2_write_32 (SNDREGADDR (0x280c), - (g2_read_32 (SNDREGADDR (0x280c)) & 0xffff00ff) | (ch << 8)); - g2_fifo_wait (); + g2_write_32(SNDREGADDR(0x280c), + (g2_read_32(SNDREGADDR(0x280c)) & 0xffff00ff) | (ch << 8)); + g2_fifo_wait(); /* Update position counters */ - return g2_read_32 (SNDREGADDR (0x2814)) & 0xffff; + return g2_read_32(SNDREGADDR(0x2814)) & 0xffff; #else /* Observe channel ch */ - g2_write_8 (SNDREGADDR (0x280d), ch); + g2_write_8(SNDREGADDR(0x280d), ch); /* Update position counters */ - return g2_read_32 (SNDREGADDR (0x2814)) & 0xffff; + return g2_read_32(SNDREGADDR(0x2814)) & 0xffff; #endif } diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/dc/aica.h --- a/src/audio/dc/aica.h Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/dc/aica.h Mon May 29 04:04:35 2006 +0000 @@ -30,13 +30,13 @@ #define SM_16BIT 0 #define SM_ADPCM 2 -void aica_play (int ch, int mode, unsigned long smpptr, int looptst, - int loopend, int freq, int vol, int pan, int loopflag); -void aica_stop (int ch); -void aica_vol (int ch, int vol); -void aica_pan (int ch, int pan); -void aica_freq (int ch, int freq); -int aica_get_pos (int ch); +void aica_play(int ch, int mode, unsigned long smpptr, int looptst, + int loopend, int freq, int vol, int pan, int loopflag); +void aica_stop(int ch); +void aica_vol(int ch, int vol); +void aica_pan(int ch, int pan); +void aica_freq(int ch, int freq); +int aica_get_pos(int ch); #endif /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/disk/SDL_diskaudio.c --- a/src/audio/disk/SDL_diskaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/disk/SDL_diskaudio.c Mon May 29 04:04:35 2006 +0000 @@ -47,62 +47,62 @@ #define DISKDEFAULT_WRITEDELAY 150 /* Audio driver functions */ -static int DISKAUD_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void DISKAUD_WaitAudio (_THIS); -static void DISKAUD_PlayAudio (_THIS); -static Uint8 *DISKAUD_GetAudioBuf (_THIS); -static void DISKAUD_CloseAudio (_THIS); +static int DISKAUD_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void DISKAUD_WaitAudio(_THIS); +static void DISKAUD_PlayAudio(_THIS); +static Uint8 *DISKAUD_GetAudioBuf(_THIS); +static void DISKAUD_CloseAudio(_THIS); static const char * -DISKAUD_GetOutputFilename (void) +DISKAUD_GetOutputFilename(void) { - const char *envr = SDL_getenv (DISKENVR_OUTFILE); + const char *envr = SDL_getenv(DISKENVR_OUTFILE); return ((envr != NULL) ? envr : DISKDEFAULT_OUTFILE); } /* Audio driver bootstrap functions */ static int -DISKAUD_Available (void) +DISKAUD_Available(void) { - const char *envr = SDL_getenv ("SDL_AUDIODRIVER"); - if (envr && (SDL_strcmp (envr, DISKAUD_DRIVER_NAME) == 0)) { + const char *envr = SDL_getenv("SDL_AUDIODRIVER"); + if (envr && (SDL_strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) { return (1); } return (0); } static void -DISKAUD_DeleteDevice (SDL_AudioDevice * device) +DISKAUD_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -DISKAUD_CreateDevice (int devindex) +DISKAUD_CreateDevice(int devindex) { SDL_AudioDevice *this; const char *envr; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); - envr = SDL_getenv (DISKENVR_WRITEDELAY); + envr = SDL_getenv(DISKENVR_WRITEDELAY); this->hidden->write_delay = - (envr) ? SDL_atoi (envr) : DISKDEFAULT_WRITEDELAY; + (envr) ? SDL_atoi(envr) : DISKDEFAULT_WRITEDELAY; /* Set the function pointers */ this->OpenAudio = DISKAUD_OpenAudio; @@ -123,70 +123,70 @@ /* This function waits until it is possible to write a full sound buffer */ static void -DISKAUD_WaitAudio (_THIS) +DISKAUD_WaitAudio(_THIS) { - SDL_Delay (this->hidden->write_delay); + SDL_Delay(this->hidden->write_delay); } static void -DISKAUD_PlayAudio (_THIS) +DISKAUD_PlayAudio(_THIS) { int written; /* Write the audio data */ - written = SDL_RWwrite (this->hidden->output, - this->hidden->mixbuf, 1, this->hidden->mixlen); + written = SDL_RWwrite(this->hidden->output, + this->hidden->mixbuf, 1, this->hidden->mixlen); /* If we couldn't write, assume fatal error for now */ if ((Uint32) written != this->hidden->mixlen) { this->enabled = 0; } #ifdef DEBUG_AUDIO - fprintf (stderr, "Wrote %d bytes of audio data\n", written); + fprintf(stderr, "Wrote %d bytes of audio data\n", written); #endif } static Uint8 * -DISKAUD_GetAudioBuf (_THIS) +DISKAUD_GetAudioBuf(_THIS) { return (this->hidden->mixbuf); } static void -DISKAUD_CloseAudio (_THIS) +DISKAUD_CloseAudio(_THIS) { if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem (this->hidden->mixbuf); + SDL_FreeAudioMem(this->hidden->mixbuf); this->hidden->mixbuf = NULL; } if (this->hidden->output != NULL) { - SDL_RWclose (this->hidden->output); + SDL_RWclose(this->hidden->output); this->hidden->output = NULL; } } static int -DISKAUD_OpenAudio (_THIS, SDL_AudioSpec * spec) +DISKAUD_OpenAudio(_THIS, SDL_AudioSpec * spec) { - const char *fname = DISKAUD_GetOutputFilename (); + const char *fname = DISKAUD_GetOutputFilename(); /* Open the audio device */ - this->hidden->output = SDL_RWFromFile (fname, "wb"); + this->hidden->output = SDL_RWFromFile(fname, "wb"); if (this->hidden->output == NULL) { return (-1); } #if HAVE_STDIO_H - fprintf (stderr, "WARNING: You are using the SDL disk writer" - " audio driver!\n Writing to file [%s].\n", fname); + fprintf(stderr, "WARNING: You are using the SDL disk writer" + " audio driver!\n Writing to file [%s].\n", fname); #endif /* Allocate mixing buffer */ this->hidden->mixlen = spec->size; - this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem (this->hidden->mixlen); + this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen); if (this->hidden->mixbuf == NULL) { return (-1); } - SDL_memset (this->hidden->mixbuf, spec->silence, spec->size); + SDL_memset(this->hidden->mixbuf, spec->silence, spec->size); /* We're ready to rock and roll. :-) */ return (0); diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/dma/SDL_dmaaudio.c --- a/src/audio/dma/SDL_dmaaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/dma/SDL_dmaaudio.c Mon May 29 04:04:35 2006 +0000 @@ -60,64 +60,64 @@ #define OPEN_FLAGS (O_RDWR|O_NONBLOCK) /* Audio driver functions */ -static int DMA_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void DMA_WaitAudio (_THIS); -static void DMA_PlayAudio (_THIS); -static Uint8 *DMA_GetAudioBuf (_THIS); -static void DMA_CloseAudio (_THIS); +static int DMA_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void DMA_WaitAudio(_THIS); +static void DMA_PlayAudio(_THIS); +static Uint8 *DMA_GetAudioBuf(_THIS); +static void DMA_CloseAudio(_THIS); /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { int available; int fd; available = 0; - fd = SDL_OpenAudioPath (NULL, 0, OPEN_FLAGS, 0); + fd = SDL_OpenAudioPath(NULL, 0, OPEN_FLAGS, 0); if (fd >= 0) { int caps; struct audio_buf_info info; - if ((ioctl (fd, SNDCTL_DSP_GETCAPS, &caps) == 0) && + if ((ioctl(fd, SNDCTL_DSP_GETCAPS, &caps) == 0) && (caps & DSP_CAP_TRIGGER) && (caps & DSP_CAP_MMAP) && - (ioctl (fd, SNDCTL_DSP_GETOSPACE, &info) == 0)) { + (ioctl(fd, SNDCTL_DSP_GETOSPACE, &info) == 0)) { available = 1; } - close (fd); + close(fd); } return (available); } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); audio_fd = -1; /* Set the function pointers */ @@ -139,7 +139,7 @@ /* This function waits until it is possible to write a full sound buffer */ static void -DMA_WaitAudio (_THIS) +DMA_WaitAudio(_THIS) { fd_set fdset; @@ -150,7 +150,7 @@ that use a different process id for each thread. */ if (parent && (((++cnt) % 10) == 0)) { /* Check every 10 loops */ - if (kill (parent, 0) < 0) { + if (kill(parent, 0) < 0) { this->enabled = 0; } } @@ -161,21 +161,21 @@ /* Use timer for general audio synchronization */ Sint32 ticks; - ticks = ((Sint32) (next_frame - SDL_GetTicks ())) - FUDGE_TICKS; + ticks = ((Sint32) (next_frame - SDL_GetTicks())) - FUDGE_TICKS; if (ticks > 0) { - SDL_Delay (ticks); + SDL_Delay(ticks); } } else { /* Use select() for audio synchronization */ struct timeval timeout; - FD_ZERO (&fdset); - FD_SET (audio_fd, &fdset); + FD_ZERO(&fdset); + FD_SET(audio_fd, &fdset); timeout.tv_sec = 10; timeout.tv_usec = 0; #ifdef DEBUG_AUDIO - fprintf (stderr, "Waiting for audio to get ready\n"); + fprintf(stderr, "Waiting for audio to get ready\n"); #endif - if (select (audio_fd + 1, NULL, &fdset, NULL, &timeout) <= 0) { + if (select(audio_fd + 1, NULL, &fdset, NULL, &timeout) <= 0) { const char *message = #ifdef AUDIO_OSPACE_HACK "Audio timeout - buggy audio driver? (trying ospace)"; @@ -186,29 +186,29 @@ but in this case we have no other way of letting the user know what happened. */ - fprintf (stderr, "SDL: %s\n", message); + fprintf(stderr, "SDL: %s\n", message); #ifdef AUDIO_OSPACE_HACK /* We may be able to use GET_OSPACE trick */ frame_ticks = (float) (this->spec->samples * 1000) / this->spec->freq; - next_frame = SDL_GetTicks () + frame_ticks; + next_frame = SDL_GetTicks() + frame_ticks; #else this->enabled = 0; /* Don't try to close - may hang */ audio_fd = -1; #ifdef DEBUG_AUDIO - fprintf (stderr, "Done disabling audio\n"); + fprintf(stderr, "Done disabling audio\n"); #endif #endif /* AUDIO_OSPACE_HACK */ } #ifdef DEBUG_AUDIO - fprintf (stderr, "Ready!\n"); + fprintf(stderr, "Ready!\n"); #endif } } static void -DMA_PlayAudio (_THIS) +DMA_PlayAudio(_THIS) { /* If timer synchronization is enabled, set the next write frame */ if (frame_ticks) { @@ -218,7 +218,7 @@ } static Uint8 * -DMA_GetAudioBuf (_THIS) +DMA_GetAudioBuf(_THIS) { count_info info; int playing; @@ -226,7 +226,7 @@ /* Get number of blocks, looping if we're not using select() */ do { - if (ioctl (audio_fd, SNDCTL_DSP_GETOPTR, &info) < 0) { + if (ioctl(audio_fd, SNDCTL_DSP_GETOPTR, &info) < 0) { /* Uh oh... */ this->enabled = 0; return (NULL); @@ -235,7 +235,7 @@ while (frame_ticks && (info.blocks < 1)); #ifdef DEBUG_AUDIO if (info.blocks > 1) { - printf ("Warning: audio underflow (%d frags)\n", info.blocks - 1); + printf("Warning: audio underflow (%d frags)\n", info.blocks - 1); } #endif playing = info.ptr / this->spec.size; @@ -244,69 +244,68 @@ } static void -DMA_CloseAudio (_THIS) +DMA_CloseAudio(_THIS) { if (dma_buf != NULL) { - munmap (dma_buf, dma_len); + munmap(dma_buf, dma_len); dma_buf = NULL; } if (audio_fd >= 0) { - close (audio_fd); + close(audio_fd); audio_fd = -1; } } static int -DMA_ReopenAudio (_THIS, const char *audiodev, int format, int stereo, - SDL_AudioSpec * spec) +DMA_ReopenAudio(_THIS, const char *audiodev, int format, int stereo, + SDL_AudioSpec * spec) { int frag_spec; int value; /* Close and then reopen the audio device */ - close (audio_fd); - audio_fd = open (audiodev, O_RDWR, 0); + close(audio_fd); + audio_fd = open(audiodev, O_RDWR, 0); if (audio_fd < 0) { - SDL_SetError ("Couldn't open %s: %s", audiodev, strerror (errno)); + SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno)); return (-1); } /* Calculate the final parameters for this audio specification */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Determine the power of two of the fragment size */ for (frag_spec = 0; (0x01 << frag_spec) < spec->size; ++frag_spec); if ((0x01 << frag_spec) != spec->size) { - SDL_SetError ("Fragment size must be a power of two"); + SDL_SetError("Fragment size must be a power of two"); return (-1); } /* Set the audio buffering parameters */ - if (ioctl (audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0) { - SDL_SetError ("Couldn't set audio fragment spec"); + if (ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0) { + SDL_SetError("Couldn't set audio fragment spec"); return (-1); } /* Set the audio format */ value = format; - if ((ioctl (audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || - (value != format)) { - SDL_SetError ("Couldn't set audio format"); + if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || (value != format)) { + SDL_SetError("Couldn't set audio format"); return (-1); } /* Set mono or stereo audio */ value = (spec->channels > 1); - if ((ioctl (audio_fd, SNDCTL_DSP_STEREO, &stereo) < 0) || + if ((ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo) < 0) || (value != stereo)) { - SDL_SetError ("Couldn't set audio channels"); + SDL_SetError("Couldn't set audio channels"); return (-1); } /* Set the DSP frequency */ value = spec->freq; - if (ioctl (audio_fd, SNDCTL_DSP_SPEED, &value) < 0) { - SDL_SetError ("Couldn't set audio frequency"); + if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &value) < 0) { + SDL_SetError("Couldn't set audio frequency"); return (-1); } spec->freq = value; @@ -316,7 +315,7 @@ } static int -DMA_OpenAudio (_THIS, SDL_AudioSpec * spec) +DMA_OpenAudio(_THIS, SDL_AudioSpec * spec) { char audiodev[1024]; int format; @@ -329,26 +328,26 @@ frame_ticks = 0.0; /* Open the audio device */ - audio_fd = SDL_OpenAudioPath (audiodev, sizeof (audiodev), OPEN_FLAGS, 0); + audio_fd = SDL_OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0); if (audio_fd < 0) { - SDL_SetError ("Couldn't open %s: %s", audiodev, strerror (errno)); + SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno)); return (-1); } dma_buf = NULL; - ioctl (audio_fd, SNDCTL_DSP_RESET, 0); + ioctl(audio_fd, SNDCTL_DSP_RESET, 0); /* Get a list of supported hardware formats */ - if (ioctl (audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0) { - SDL_SetError ("Couldn't get audio format list"); + if (ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0) { + SDL_SetError("Couldn't get audio format list"); return (-1); } /* Try for a closest match on audio format */ format = 0; - for (test_format = SDL_FirstAudioFormat (spec->format); + for (test_format = SDL_FirstAudioFormat(spec->format); !format && test_format;) { #ifdef DEBUG_AUDIO - fprintf (stderr, "Trying format 0x%4.4x\n", test_format); + fprintf(stderr, "Trying format 0x%4.4x\n", test_format); #endif switch (test_format) { case AUDIO_U8: @@ -386,26 +385,25 @@ break; } if (!format) { - test_format = SDL_NextAudioFormat (); + test_format = SDL_NextAudioFormat(); } } if (format == 0) { - SDL_SetError ("Couldn't find any hardware audio formats"); + SDL_SetError("Couldn't find any hardware audio formats"); return (-1); } spec->format = test_format; /* Set the audio format */ value = format; - if ((ioctl (audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || - (value != format)) { - SDL_SetError ("Couldn't set audio format"); + if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || (value != format)) { + SDL_SetError("Couldn't set audio format"); return (-1); } /* Set mono or stereo audio (currently only two channels supported) */ stereo = (spec->channels > 1); - ioctl (audio_fd, SNDCTL_DSP_STEREO, &stereo); + ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo); if (stereo) { spec->channels = 2; } else { @@ -416,14 +414,14 @@ after setting the format, we must re-open the audio device once we know what format and channels are supported */ - if (DMA_ReopenAudio (this, audiodev, format, stereo, spec) < 0) { + if (DMA_ReopenAudio(this, audiodev, format, stereo, spec) < 0) { /* Error is set by DMA_ReopenAudio() */ return (-1); } /* Memory map the audio buffer */ - if (ioctl (audio_fd, SNDCTL_DSP_GETOSPACE, &info) < 0) { - SDL_SetError ("Couldn't get OSPACE parameters"); + if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info) < 0) { + SDL_SetError("Couldn't get OSPACE parameters"); return (-1); } spec->size = info.fragsize; @@ -431,36 +429,36 @@ spec->samples /= spec->channels; num_buffers = info.fragstotal; dma_len = num_buffers * spec->size; - dma_buf = (Uint8 *) mmap (NULL, dma_len, PROT_WRITE, MAP_SHARED, - audio_fd, 0); + dma_buf = (Uint8 *) mmap(NULL, dma_len, PROT_WRITE, MAP_SHARED, + audio_fd, 0); if (dma_buf == MAP_FAILED) { - SDL_SetError ("DMA memory map failed"); + SDL_SetError("DMA memory map failed"); dma_buf = NULL; return (-1); } - SDL_memset (dma_buf, spec->silence, dma_len); + SDL_memset(dma_buf, spec->silence, dma_len); /* Check to see if we need to use select() workaround */ { char *workaround; - workaround = SDL_getenv ("SDL_DSP_NOSELECT"); + workaround = SDL_getenv("SDL_DSP_NOSELECT"); if (workaround) { frame_ticks = (float) (spec->samples * 1000) / spec->freq; - next_frame = SDL_GetTicks () + frame_ticks; + next_frame = SDL_GetTicks() + frame_ticks; } } /* Trigger audio playback */ value = 0; - ioctl (audio_fd, SNDCTL_DSP_SETTRIGGER, &value); + ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &value); value = PCM_ENABLE_OUTPUT; - if (ioctl (audio_fd, SNDCTL_DSP_SETTRIGGER, &value) < 0) { - SDL_SetError ("Couldn't trigger audio output"); + if (ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &value) < 0) { + SDL_SetError("Couldn't trigger audio output"); return (-1); } /* Get the parent process id (we're the parent of the audio thread) */ - parent = getpid (); + parent = getpid(); /* We're ready to rock and roll. :-) */ return (0); diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/dmedia/SDL_irixaudio.c --- a/src/audio/dmedia/SDL_irixaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/dmedia/SDL_irixaudio.c Mon May 29 04:04:35 2006 +0000 @@ -45,47 +45,47 @@ #endif /* Audio driver functions */ -static int AL_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void AL_WaitAudio (_THIS); -static void AL_PlayAudio (_THIS); -static Uint8 *AL_GetAudioBuf (_THIS); -static void AL_CloseAudio (_THIS); +static int AL_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void AL_WaitAudio(_THIS); +static void AL_PlayAudio(_THIS); +static Uint8 *AL_GetAudioBuf(_THIS); +static void AL_CloseAudio(_THIS); /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { return 1; } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = AL_OpenAudio; @@ -106,48 +106,48 @@ void static -AL_WaitAudio (_THIS) +AL_WaitAudio(_THIS) { Sint32 timeleft; - timeleft = this->spec.samples - alGetFillable (audio_port); + timeleft = this->spec.samples - alGetFillable(audio_port); if (timeleft > 0) { timeleft /= (this->spec.freq / 1000); - SDL_Delay ((Uint32) timeleft); + SDL_Delay((Uint32) timeleft); } } static void -AL_PlayAudio (_THIS) +AL_PlayAudio(_THIS) { /* Write the audio data out */ - if (alWriteFrames (audio_port, mixbuf, this->spec.samples) < 0) { + if (alWriteFrames(audio_port, mixbuf, this->spec.samples) < 0) { /* Assume fatal error, for now */ this->enabled = 0; } } static Uint8 * -AL_GetAudioBuf (_THIS) +AL_GetAudioBuf(_THIS) { return (mixbuf); } static void -AL_CloseAudio (_THIS) +AL_CloseAudio(_THIS) { if (mixbuf != NULL) { - SDL_FreeAudioMem (mixbuf); + SDL_FreeAudioMem(mixbuf); mixbuf = NULL; } if (audio_port != NULL) { - alClosePort (audio_port); + alClosePort(audio_port); audio_port = NULL; } } static int -AL_OpenAudio (_THIS, SDL_AudioSpec * spec) +AL_OpenAudio(_THIS, SDL_AudioSpec * spec) { ALconfig audio_config; #ifdef OLD_IRIX_AUDIO @@ -176,51 +176,51 @@ default: { - SDL_SetError ("Unsupported audio format"); + SDL_SetError("Unsupported audio format"); return (-1); } } /* Update the fragment size as size in bytes */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Set output frequency */ #ifdef OLD_IRIX_AUDIO audio_param[0] = AL_OUTPUT_RATE; audio_param[1] = spec->freq; - if (ALsetparams (AL_DEFAULT_DEVICE, audio_param, 2) < 0) { + if (ALsetparams(AL_DEFAULT_DEVICE, audio_param, 2) < 0) { #else audio_param.param = AL_RATE; audio_param.value.i = spec->freq; - if (alSetParams (AL_DEFAULT_OUTPUT, &audio_param, 1) < 0) { + if (alSetParams(AL_DEFAULT_OUTPUT, &audio_param, 1) < 0) { #endif - SDL_SetError ("alSetParams failed"); + SDL_SetError("alSetParams failed"); return (-1); } /* Open the audio port with the requested frequency */ audio_port = NULL; - audio_config = alNewConfig (); + audio_config = alNewConfig(); if (audio_config && - (alSetSampFmt (audio_config, AL_SAMPFMT_TWOSCOMP) >= 0) && - (alSetWidth (audio_config, width) >= 0) && - (alSetQueueSize (audio_config, spec->samples * 2) >= 0) && - (alSetChannels (audio_config, spec->channels) >= 0)) { - audio_port = alOpenPort ("SDL audio", "w", audio_config); + (alSetSampFmt(audio_config, AL_SAMPFMT_TWOSCOMP) >= 0) && + (alSetWidth(audio_config, width) >= 0) && + (alSetQueueSize(audio_config, spec->samples * 2) >= 0) && + (alSetChannels(audio_config, spec->channels) >= 0)) { + audio_port = alOpenPort("SDL audio", "w", audio_config); } - alFreeConfig (audio_config); + alFreeConfig(audio_config); if (audio_port == NULL) { - SDL_SetError ("Unable to open audio port"); + SDL_SetError("Unable to open audio port"); return (-1); } /* Allocate mixing buffer */ - mixbuf = (Uint8 *) SDL_AllocAudioMem (spec->size); + mixbuf = (Uint8 *) SDL_AllocAudioMem(spec->size); if (mixbuf == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } - SDL_memset (mixbuf, spec->silence, spec->size); + SDL_memset(mixbuf, spec->silence, spec->size); /* We're ready to rock and roll. :-) */ return (0); diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/dsp/SDL_dspaudio.c --- a/src/audio/dsp/SDL_dspaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/dsp/SDL_dspaudio.c Mon May 29 04:04:35 2006 +0000 @@ -58,56 +58,56 @@ #define OPEN_FLAGS (O_WRONLY|O_NONBLOCK) /* Audio driver functions */ -static int DSP_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void DSP_WaitAudio (_THIS); -static void DSP_PlayAudio (_THIS); -static Uint8 *DSP_GetAudioBuf (_THIS); -static void DSP_CloseAudio (_THIS); +static int DSP_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void DSP_WaitAudio(_THIS); +static void DSP_PlayAudio(_THIS); +static Uint8 *DSP_GetAudioBuf(_THIS); +static void DSP_CloseAudio(_THIS); /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { int fd; int available; available = 0; - fd = SDL_OpenAudioPath (NULL, 0, OPEN_FLAGS, 0); + fd = SDL_OpenAudioPath(NULL, 0, OPEN_FLAGS, 0); if (fd >= 0) { available = 1; - close (fd); + close(fd); } return (available); } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); audio_fd = -1; /* Set the function pointers */ @@ -129,44 +129,44 @@ /* This function waits until it is possible to write a full sound buffer */ static void -DSP_WaitAudio (_THIS) +DSP_WaitAudio(_THIS) { /* Not needed at all since OSS handles waiting automagically */ } static void -DSP_PlayAudio (_THIS) +DSP_PlayAudio(_THIS) { - if (write (audio_fd, mixbuf, mixlen) == -1) { - perror ("Audio write"); + if (write(audio_fd, mixbuf, mixlen) == -1) { + perror("Audio write"); this->enabled = 0; } #ifdef DEBUG_AUDIO - fprintf (stderr, "Wrote %d bytes of audio data\n", mixlen); + fprintf(stderr, "Wrote %d bytes of audio data\n", mixlen); #endif } static Uint8 * -DSP_GetAudioBuf (_THIS) +DSP_GetAudioBuf(_THIS) { return (mixbuf); } static void -DSP_CloseAudio (_THIS) +DSP_CloseAudio(_THIS) { if (mixbuf != NULL) { - SDL_FreeAudioMem (mixbuf); + SDL_FreeAudioMem(mixbuf); mixbuf = NULL; } if (audio_fd >= 0) { - close (audio_fd); + close(audio_fd); audio_fd = -1; } } static int -DSP_OpenAudio (_THIS, SDL_AudioSpec * spec) +DSP_OpenAudio(_THIS, SDL_AudioSpec * spec) { char audiodev[1024]; int format; @@ -175,9 +175,9 @@ Uint16 test_format; /* Open the audio device */ - audio_fd = SDL_OpenAudioPath (audiodev, sizeof (audiodev), OPEN_FLAGS, 0); + audio_fd = SDL_OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0); if (audio_fd < 0) { - SDL_SetError ("Couldn't open %s: %s", audiodev, strerror (errno)); + SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno)); return (-1); } mixbuf = NULL; @@ -185,29 +185,29 @@ /* Make the file descriptor use blocking writes with fcntl() */ { long flags; - flags = fcntl (audio_fd, F_GETFL); + flags = fcntl(audio_fd, F_GETFL); flags &= ~O_NONBLOCK; - if (fcntl (audio_fd, F_SETFL, flags) < 0) { - SDL_SetError ("Couldn't set audio blocking mode"); - DSP_CloseAudio (this); + if (fcntl(audio_fd, F_SETFL, flags) < 0) { + SDL_SetError("Couldn't set audio blocking mode"); + DSP_CloseAudio(this); return (-1); } } /* Get a list of supported hardware formats */ - if (ioctl (audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0) { - perror ("SNDCTL_DSP_GETFMTS"); - SDL_SetError ("Couldn't get audio format list"); - DSP_CloseAudio (this); + if (ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0) { + perror("SNDCTL_DSP_GETFMTS"); + SDL_SetError("Couldn't get audio format list"); + DSP_CloseAudio(this); return (-1); } /* Try for a closest match on audio format */ format = 0; - for (test_format = SDL_FirstAudioFormat (spec->format); + for (test_format = SDL_FirstAudioFormat(spec->format); !format && test_format;) { #ifdef DEBUG_AUDIO - fprintf (stderr, "Trying format 0x%4.4x\n", test_format); + fprintf(stderr, "Trying format 0x%4.4x\n", test_format); #endif switch (test_format) { case AUDIO_U8: @@ -251,88 +251,87 @@ break; } if (!format) { - test_format = SDL_NextAudioFormat (); + test_format = SDL_NextAudioFormat(); } } if (format == 0) { - SDL_SetError ("Couldn't find any hardware audio formats"); - DSP_CloseAudio (this); + SDL_SetError("Couldn't find any hardware audio formats"); + DSP_CloseAudio(this); return (-1); } spec->format = test_format; /* Set the audio format */ value = format; - if ((ioctl (audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || - (value != format)) { - perror ("SNDCTL_DSP_SETFMT"); - SDL_SetError ("Couldn't set audio format"); - DSP_CloseAudio (this); + if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || (value != format)) { + perror("SNDCTL_DSP_SETFMT"); + SDL_SetError("Couldn't set audio format"); + DSP_CloseAudio(this); return (-1); } /* Set the number of channels of output */ value = spec->channels; - if (ioctl (audio_fd, SNDCTL_DSP_CHANNELS, &value) < 0) { - perror ("SNDCTL_DSP_CHANNELS"); - SDL_SetError ("Cannot set the number of channels"); - DSP_CloseAudio (this); + if (ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &value) < 0) { + perror("SNDCTL_DSP_CHANNELS"); + SDL_SetError("Cannot set the number of channels"); + DSP_CloseAudio(this); return (-1); } spec->channels = value; /* Set the DSP frequency */ value = spec->freq; - if (ioctl (audio_fd, SNDCTL_DSP_SPEED, &value) < 0) { - perror ("SNDCTL_DSP_SPEED"); - SDL_SetError ("Couldn't set audio frequency"); - DSP_CloseAudio (this); + if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &value) < 0) { + perror("SNDCTL_DSP_SPEED"); + SDL_SetError("Couldn't set audio frequency"); + DSP_CloseAudio(this); return (-1); } spec->freq = value; /* Calculate the final parameters for this audio specification */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Determine the power of two of the fragment size */ for (frag_spec = 0; (0x01U << frag_spec) < spec->size; ++frag_spec); if ((0x01U << frag_spec) != spec->size) { - SDL_SetError ("Fragment size must be a power of two"); - DSP_CloseAudio (this); + SDL_SetError("Fragment size must be a power of two"); + DSP_CloseAudio(this); return (-1); } frag_spec |= 0x00020000; /* two fragments, for low latency */ /* Set the audio buffering parameters */ #ifdef DEBUG_AUDIO - fprintf (stderr, "Requesting %d fragments of size %d\n", - (frag_spec >> 16), 1 << (frag_spec & 0xFFFF)); + fprintf(stderr, "Requesting %d fragments of size %d\n", + (frag_spec >> 16), 1 << (frag_spec & 0xFFFF)); #endif - if (ioctl (audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0) { - perror ("SNDCTL_DSP_SETFRAGMENT"); + if (ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0) { + perror("SNDCTL_DSP_SETFRAGMENT"); } #ifdef DEBUG_AUDIO { audio_buf_info info; - ioctl (audio_fd, SNDCTL_DSP_GETOSPACE, &info); - fprintf (stderr, "fragments = %d\n", info.fragments); - fprintf (stderr, "fragstotal = %d\n", info.fragstotal); - fprintf (stderr, "fragsize = %d\n", info.fragsize); - fprintf (stderr, "bytes = %d\n", info.bytes); + ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info); + fprintf(stderr, "fragments = %d\n", info.fragments); + fprintf(stderr, "fragstotal = %d\n", info.fragstotal); + fprintf(stderr, "fragsize = %d\n", info.fragsize); + fprintf(stderr, "bytes = %d\n", info.bytes); } #endif /* Allocate mixing buffer */ mixlen = spec->size; - mixbuf = (Uint8 *) SDL_AllocAudioMem (mixlen); + mixbuf = (Uint8 *) SDL_AllocAudioMem(mixlen); if (mixbuf == NULL) { - DSP_CloseAudio (this); + DSP_CloseAudio(this); return (-1); } - SDL_memset (mixbuf, spec->silence, spec->size); + SDL_memset(mixbuf, spec->silence, spec->size); /* Get the parent process id (we're the parent of the audio thread) */ - parent = getpid (); + parent = getpid(); /* We're ready to rock and roll. :-) */ return (0); diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/dummy/SDL_dummyaudio.c --- a/src/audio/dummy/SDL_dummyaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/dummy/SDL_dummyaudio.c Mon May 29 04:04:35 2006 +0000 @@ -37,50 +37,50 @@ #define DUMMYAUD_DRIVER_NAME "dummy" /* Audio driver functions */ -static int DUMMYAUD_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void DUMMYAUD_WaitAudio (_THIS); -static void DUMMYAUD_PlayAudio (_THIS); -static Uint8 *DUMMYAUD_GetAudioBuf (_THIS); -static void DUMMYAUD_CloseAudio (_THIS); +static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void DUMMYAUD_WaitAudio(_THIS); +static void DUMMYAUD_PlayAudio(_THIS); +static Uint8 *DUMMYAUD_GetAudioBuf(_THIS); +static void DUMMYAUD_CloseAudio(_THIS); /* Audio driver bootstrap functions */ static int -DUMMYAUD_Available (void) +DUMMYAUD_Available(void) { - const char *envr = SDL_getenv ("SDL_AUDIODRIVER"); - if (envr && (SDL_strcmp (envr, DUMMYAUD_DRIVER_NAME) == 0)) { + const char *envr = SDL_getenv("SDL_AUDIODRIVER"); + if (envr && (SDL_strcmp(envr, DUMMYAUD_DRIVER_NAME) == 0)) { return (1); } return (0); } static void -DUMMYAUD_DeleteDevice (SDL_AudioDevice * device) +DUMMYAUD_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -DUMMYAUD_CreateDevice (int devindex) +DUMMYAUD_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = DUMMYAUD_OpenAudio; @@ -101,48 +101,48 @@ /* This function waits until it is possible to write a full sound buffer */ static void -DUMMYAUD_WaitAudio (_THIS) +DUMMYAUD_WaitAudio(_THIS) { /* Don't block on first calls to simulate initial fragment filling. */ if (this->hidden->initial_calls) this->hidden->initial_calls--; else - SDL_Delay (this->hidden->write_delay); + SDL_Delay(this->hidden->write_delay); } static void -DUMMYAUD_PlayAudio (_THIS) +DUMMYAUD_PlayAudio(_THIS) { /* no-op...this is a null driver. */ } static Uint8 * -DUMMYAUD_GetAudioBuf (_THIS) +DUMMYAUD_GetAudioBuf(_THIS) { return (this->hidden->mixbuf); } static void -DUMMYAUD_CloseAudio (_THIS) +DUMMYAUD_CloseAudio(_THIS) { if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem (this->hidden->mixbuf); + SDL_FreeAudioMem(this->hidden->mixbuf); this->hidden->mixbuf = NULL; } } static int -DUMMYAUD_OpenAudio (_THIS, SDL_AudioSpec * spec) +DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec * spec) { float bytes_per_sec = 0.0f; /* Allocate mixing buffer */ this->hidden->mixlen = spec->size; - this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem (this->hidden->mixlen); + this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen); if (this->hidden->mixbuf == NULL) { return (-1); } - SDL_memset (this->hidden->mixbuf, spec->silence, spec->size); + SDL_memset(this->hidden->mixbuf, spec->silence, spec->size); bytes_per_sec = (float) (((spec->format & 0xFF) / 8) * spec->channels * spec->freq); diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/esd/SDL_esdaudio.c --- a/src/audio/esd/SDL_esdaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/esd/SDL_esdaudio.c Mon May 29 04:04:35 2006 +0000 @@ -47,11 +47,11 @@ #define ESD_DRIVER_NAME "esd" /* Audio driver functions */ -static int ESD_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void ESD_WaitAudio (_THIS); -static void ESD_PlayAudio (_THIS); -static Uint8 *ESD_GetAudioBuf (_THIS); -static void ESD_CloseAudio (_THIS); +static int ESD_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void ESD_WaitAudio(_THIS); +static void ESD_PlayAudio(_THIS); +static Uint8 *ESD_GetAudioBuf(_THIS); +static void ESD_CloseAudio(_THIS); #ifdef SDL_AUDIO_DRIVER_ESD_DYNAMIC @@ -59,45 +59,45 @@ static void *esd_handle = NULL; static int esd_loaded = 0; -static int (*SDL_NAME (esd_open_sound)) (const char *host); -static int (*SDL_NAME (esd_close)) (int esd); -static int (*SDL_NAME (esd_play_stream)) (esd_format_t format, int rate, - const char *host, const char *name); +static int (*SDL_NAME(esd_open_sound)) (const char *host); +static int (*SDL_NAME(esd_close)) (int esd); +static int (*SDL_NAME(esd_play_stream)) (esd_format_t format, int rate, + const char *host, const char *name); static struct { const char *name; void **func; } esd_functions[] = { { - "esd_open_sound", (void **) &SDL_NAME (esd_open_sound)}, { - "esd_close", (void **) &SDL_NAME (esd_close)}, { -"esd_play_stream", (void **) &SDL_NAME (esd_play_stream)},}; + "esd_open_sound", (void **) &SDL_NAME(esd_open_sound)}, { + "esd_close", (void **) &SDL_NAME(esd_close)}, { +"esd_play_stream", (void **) &SDL_NAME(esd_play_stream)},}; static void -UnloadESDLibrary () +UnloadESDLibrary() { if (esd_loaded) { - SDL_UnloadObject (esd_handle); + SDL_UnloadObject(esd_handle); esd_handle = NULL; esd_loaded = 0; } } static int -LoadESDLibrary (void) +LoadESDLibrary(void) { int i, retval = -1; - esd_handle = SDL_LoadObject (esd_library); + esd_handle = SDL_LoadObject(esd_library); if (esd_handle) { esd_loaded = 1; retval = 0; - for (i = 0; i < SDL_arraysize (esd_functions); ++i) { + for (i = 0; i < SDL_arraysize(esd_functions); ++i) { *esd_functions[i].func = - SDL_LoadFunction (esd_handle, esd_functions[i].name); + SDL_LoadFunction(esd_handle, esd_functions[i].name); if (!*esd_functions[i].func) { retval = -1; - UnloadESDLibrary (); + UnloadESDLibrary(); break; } } @@ -108,13 +108,13 @@ #else static void -UnloadESDLibrary () +UnloadESDLibrary() { return; } static int -LoadESDLibrary (void) +LoadESDLibrary(void) { return 0; } @@ -124,53 +124,53 @@ /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { int connection; int available; available = 0; - if (LoadESDLibrary () < 0) { + if (LoadESDLibrary() < 0) { return available; } - connection = SDL_NAME (esd_open_sound) (NULL); + connection = SDL_NAME(esd_open_sound) (NULL); if (connection >= 0) { available = 1; - SDL_NAME (esd_close) (connection); + SDL_NAME(esd_close) (connection); } - UnloadESDLibrary (); + UnloadESDLibrary(); return (available); } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); - UnloadESDLibrary (); + SDL_free(device->hidden); + SDL_free(device); + UnloadESDLibrary(); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - LoadESDLibrary (); - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + LoadESDLibrary(); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); audio_fd = -1; /* Set the function pointers */ @@ -192,7 +192,7 @@ /* This function waits until it is possible to write a full sound buffer */ static void -ESD_WaitAudio (_THIS) +ESD_WaitAudio(_THIS) { Sint32 ticks; @@ -203,29 +203,29 @@ that use a different process id for each thread. */ if (parent && (((++cnt) % 10) == 0)) { /* Check every 10 loops */ - if (kill (parent, 0) < 0) { + if (kill(parent, 0) < 0) { this->enabled = 0; } } } /* Use timer for general audio synchronization */ - ticks = ((Sint32) (next_frame - SDL_GetTicks ())) - FUDGE_TICKS; + ticks = ((Sint32) (next_frame - SDL_GetTicks())) - FUDGE_TICKS; if (ticks > 0) { - SDL_Delay (ticks); + SDL_Delay(ticks); } } static void -ESD_PlayAudio (_THIS) +ESD_PlayAudio(_THIS) { int written; /* Write the audio data, checking for EAGAIN on broken audio drivers */ do { - written = write (audio_fd, mixbuf, mixlen); + written = write(audio_fd, mixbuf, mixlen); if ((written < 0) && ((errno == 0) || (errno == EAGAIN))) { - SDL_Delay (1); /* Let a little CPU time go by */ + SDL_Delay(1); /* Let a little CPU time go by */ } } while ((written < 0) && @@ -241,52 +241,52 @@ } static Uint8 * -ESD_GetAudioBuf (_THIS) +ESD_GetAudioBuf(_THIS) { return (mixbuf); } static void -ESD_CloseAudio (_THIS) +ESD_CloseAudio(_THIS) { if (mixbuf != NULL) { - SDL_FreeAudioMem (mixbuf); + SDL_FreeAudioMem(mixbuf); mixbuf = NULL; } if (audio_fd >= 0) { - SDL_NAME (esd_close) (audio_fd); + SDL_NAME(esd_close) (audio_fd); audio_fd = -1; } } /* Try to get the name of the program */ static char * -get_progname (void) +get_progname(void) { char *progname = NULL; #ifdef __LINUX__ FILE *fp; static char temp[BUFSIZ]; - SDL_snprintf (temp, SDL_arraysize (temp), "/proc/%d/cmdline", getpid ()); - fp = fopen (temp, "r"); + SDL_snprintf(temp, SDL_arraysize(temp), "/proc/%d/cmdline", getpid()); + fp = fopen(temp, "r"); if (fp != NULL) { - if (fgets (temp, sizeof (temp) - 1, fp)) { - progname = SDL_strrchr (temp, '/'); + if (fgets(temp, sizeof(temp) - 1, fp)) { + progname = SDL_strrchr(temp, '/'); if (progname == NULL) { progname = temp; } else { progname = progname + 1; } } - fclose (fp); + fclose(fp); } #endif return (progname); } static int -ESD_OpenAudio (_THIS, SDL_AudioSpec * spec) +ESD_OpenAudio(_THIS, SDL_AudioSpec * spec) { esd_format_t format; @@ -300,7 +300,7 @@ format |= ESD_BITS16; break; default: - SDL_SetError ("Unsupported ESD audio format"); + SDL_SetError("Unsupported ESD audio format"); return (-1); } if (spec->channels == 1) { @@ -314,28 +314,27 @@ /* Open a connection to the ESD audio server */ audio_fd = - SDL_NAME (esd_play_stream) (format, spec->freq, NULL, - get_progname ()); + SDL_NAME(esd_play_stream) (format, spec->freq, NULL, get_progname()); if (audio_fd < 0) { - SDL_SetError ("Couldn't open ESD connection"); + SDL_SetError("Couldn't open ESD connection"); return (-1); } /* Calculate the final parameters for this audio specification */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); frame_ticks = (float) (spec->samples * 1000) / spec->freq; - next_frame = SDL_GetTicks () + frame_ticks; + next_frame = SDL_GetTicks() + frame_ticks; /* Allocate mixing buffer */ mixlen = spec->size; - mixbuf = (Uint8 *) SDL_AllocAudioMem (mixlen); + mixbuf = (Uint8 *) SDL_AllocAudioMem(mixlen); if (mixbuf == NULL) { return (-1); } - SDL_memset (mixbuf, spec->silence, spec->size); + SDL_memset(mixbuf, spec->silence, spec->size); /* Get the parent process id (we're the parent of the audio thread) */ - parent = getpid (); + parent = getpid(); /* We're ready to rock and roll. :-) */ return (0); diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/macosx/SDL_coreaudio.c --- a/src/audio/macosx/SDL_coreaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/macosx/SDL_coreaudio.c Mon May 29 04:04:35 2006 +0000 @@ -31,47 +31,47 @@ /* Audio driver functions */ -static int Core_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void Core_WaitAudio (_THIS); -static void Core_PlayAudio (_THIS); -static Uint8 *Core_GetAudioBuf (_THIS); -static void Core_CloseAudio (_THIS); +static int Core_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void Core_WaitAudio(_THIS); +static void Core_PlayAudio(_THIS); +static Uint8 *Core_GetAudioBuf(_THIS); +static void Core_CloseAudio(_THIS); /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { return (1); } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = Core_OpenAudio; @@ -92,10 +92,10 @@ /* The CoreAudio callback */ static OSStatus -audioCallback (void *inRefCon, - AudioUnitRenderActionFlags inActionFlags, - const AudioTimeStamp * inTimeStamp, - UInt32 inBusNumber, AudioBuffer * ioData) +audioCallback(void *inRefCon, + AudioUnitRenderActionFlags inActionFlags, + const AudioTimeStamp * inTimeStamp, + UInt32 inBusNumber, AudioBuffer * ioData) { SDL_AudioDevice *this = (SDL_AudioDevice *) inRefCon; UInt32 remaining, len; @@ -103,7 +103,7 @@ /* Only do anything if audio is enabled and not paused */ if (!this->enabled || this->paused) { - SDL_memset (ioData->mData, this->spec.silence, ioData->mDataByteSize); + SDL_memset(ioData->mData, this->spec.silence, ioData->mDataByteSize); return 0; } @@ -120,17 +120,17 @@ while (remaining > 0) { if (bufferOffset >= bufferSize) { /* Generate the data */ - SDL_memset (buffer, this->spec.silence, bufferSize); - SDL_mutexP (this->mixer_lock); + SDL_memset(buffer, this->spec.silence, bufferSize); + SDL_mutexP(this->mixer_lock); (*this->spec.callback) (this->spec.userdata, buffer, bufferSize); - SDL_mutexV (this->mixer_lock); + SDL_mutexV(this->mixer_lock); bufferOffset = 0; } len = bufferSize - bufferOffset; if (len > remaining) len = remaining; - SDL_memcpy (ptr, (char *) buffer + bufferOffset, len); + SDL_memcpy(ptr, (char *) buffer + bufferOffset, len); ptr = (char *) ptr + len; remaining -= len; bufferOffset += len; @@ -141,56 +141,56 @@ /* Dummy functions -- we don't use thread-based audio */ void -Core_WaitAudio (_THIS) +Core_WaitAudio(_THIS) { return; } void -Core_PlayAudio (_THIS) +Core_PlayAudio(_THIS) { return; } Uint8 * -Core_GetAudioBuf (_THIS) +Core_GetAudioBuf(_THIS) { return (NULL); } void -Core_CloseAudio (_THIS) +Core_CloseAudio(_THIS) { OSStatus result; struct AudioUnitInputCallback callback; /* stop processing the audio unit */ - result = AudioOutputUnitStop (outputAudioUnit); + result = AudioOutputUnitStop(outputAudioUnit); if (result != noErr) { - SDL_SetError ("Core_CloseAudio: AudioOutputUnitStop"); + SDL_SetError("Core_CloseAudio: AudioOutputUnitStop"); return; } /* Remove the input callback */ callback.inputProc = 0; callback.inputProcRefCon = 0; - result = AudioUnitSetProperty (outputAudioUnit, - kAudioUnitProperty_SetInputCallback, - kAudioUnitScope_Input, - 0, &callback, sizeof (callback)); + result = AudioUnitSetProperty(outputAudioUnit, + kAudioUnitProperty_SetInputCallback, + kAudioUnitScope_Input, + 0, &callback, sizeof(callback)); if (result != noErr) { SDL_SetError ("Core_CloseAudio: AudioUnitSetProperty (kAudioUnitProperty_SetInputCallback)"); return; } - result = CloseComponent (outputAudioUnit); + result = CloseComponent(outputAudioUnit); if (result != noErr) { - SDL_SetError ("Core_CloseAudio: CloseComponent"); + SDL_SetError("Core_CloseAudio: CloseComponent"); return; } - SDL_free (buffer); + SDL_free(buffer); } #define CHECK_RESULT(msg) \ @@ -201,7 +201,7 @@ int -Core_OpenAudio (_THIS, SDL_AudioSpec * spec) +Core_OpenAudio(_THIS, SDL_AudioSpec * spec) { OSStatus result = noErr; Component comp; @@ -235,7 +235,7 @@ desc.componentFlags = 0; desc.componentFlagsMask = 0; - comp = FindNextComponent (NULL, &desc); + comp = FindNextComponent(NULL, &desc); if (comp == NULL) { SDL_SetError ("Failed to start CoreAudio: FindNextComponent returned NULL"); @@ -243,37 +243,35 @@ } /* Open & initialize the default output audio unit */ - result = OpenAComponent (comp, &outputAudioUnit); - CHECK_RESULT ("OpenAComponent") - result = AudioUnitInitialize (outputAudioUnit); - CHECK_RESULT ("AudioUnitInitialize") + result = OpenAComponent(comp, &outputAudioUnit); + CHECK_RESULT("OpenAComponent") + result = AudioUnitInitialize(outputAudioUnit); + CHECK_RESULT("AudioUnitInitialize") /* Set the input format of the audio unit. */ - result = AudioUnitSetProperty (outputAudioUnit, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Input, - 0, - &requestedDesc, - sizeof (requestedDesc)); - CHECK_RESULT ("AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)") + result = AudioUnitSetProperty(outputAudioUnit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Input, + 0, + &requestedDesc, sizeof(requestedDesc)); + CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)") /* Set the audio callback */ callback.inputProc = audioCallback; callback.inputProcRefCon = this; - result = AudioUnitSetProperty (outputAudioUnit, - kAudioUnitProperty_SetInputCallback, - kAudioUnitScope_Input, - 0, &callback, sizeof (callback)); - CHECK_RESULT - ("AudioUnitSetProperty (kAudioUnitProperty_SetInputCallback)") + result = AudioUnitSetProperty(outputAudioUnit, + kAudioUnitProperty_SetInputCallback, + kAudioUnitScope_Input, + 0, &callback, sizeof(callback)); + CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_SetInputCallback)") /* Calculate the final parameters for this audio specification */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Allocate a sample buffer */ bufferOffset = bufferSize = this->spec.size; - buffer = SDL_malloc (bufferSize); + buffer = SDL_malloc(bufferSize); /* Finally, start processing of the audio unit */ - result = AudioOutputUnitStart (outputAudioUnit); - CHECK_RESULT ("AudioOutputUnitStart") + result = AudioOutputUnitStart(outputAudioUnit); + CHECK_RESULT("AudioOutputUnitStart") /* We're running! */ return (1); } diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/macrom/SDL_romaudio.c --- a/src/audio/macrom/SDL_romaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/macrom/SDL_romaudio.c Mon May 29 04:04:35 2006 +0000 @@ -47,47 +47,47 @@ /* Audio driver functions */ -static void Mac_CloseAudio (_THIS); -static int Mac_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void Mac_LockAudio (_THIS); -static void Mac_UnlockAudio (_THIS); +static void Mac_CloseAudio(_THIS); +static int Mac_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void Mac_LockAudio(_THIS); +static void Mac_UnlockAudio(_THIS); /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { return (1); } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = Mac_OpenAudio; @@ -122,67 +122,67 @@ static volatile Uint32 fill_me = 0; static void -mix_buffer (SDL_AudioDevice * audio, UInt8 * buffer) +mix_buffer(SDL_AudioDevice * audio, UInt8 * buffer) { if (!audio->paused) { #ifdef __MACOSX__ - SDL_mutexP (audio->mixer_lock); + SDL_mutexP(audio->mixer_lock); #endif if (audio->convert.needed) { - audio->spec.callback (audio->spec.userdata, - (Uint8 *) audio->convert.buf, - audio->convert.len); - SDL_ConvertAudio (&audio->convert); + audio->spec.callback(audio->spec.userdata, + (Uint8 *) audio->convert.buf, + audio->convert.len); + SDL_ConvertAudio(&audio->convert); if (audio->convert.len_cvt != audio->spec.size) { /* Uh oh... probably crashes here */ ; } - SDL_memcpy (buffer, audio->convert.buf, audio->convert.len_cvt); + SDL_memcpy(buffer, audio->convert.buf, audio->convert.len_cvt); } else { - audio->spec.callback (audio->spec.userdata, buffer, - audio->spec.size); + audio->spec.callback(audio->spec.userdata, buffer, + audio->spec.size); } #ifdef __MACOSX__ - SDL_mutexV (audio->mixer_lock); + SDL_mutexV(audio->mixer_lock); #endif } - DecrementAtomic ((SInt32 *) & need_to_mix); + DecrementAtomic((SInt32 *) & need_to_mix); } static void -Mac_LockAudio (_THIS) +Mac_LockAudio(_THIS) { - IncrementAtomic ((SInt32 *) & audio_is_locked); + IncrementAtomic((SInt32 *) & audio_is_locked); } static void -Mac_UnlockAudio (_THIS) +Mac_UnlockAudio(_THIS) { SInt32 oldval; - oldval = DecrementAtomic ((SInt32 *) & audio_is_locked); + oldval = DecrementAtomic((SInt32 *) & audio_is_locked); if (oldval != 1) /* != 1 means audio is still locked. */ return; /* Did we miss the chance to mix in an interrupt? Do it now. */ - if (BitAndAtomic (0xFFFFFFFF, (UInt32 *) & need_to_mix)) { + if (BitAndAtomic(0xFFFFFFFF, (UInt32 *) & need_to_mix)) { /* * Note that this could be a problem if you missed an interrupt * while the audio was locked, and get preempted by a second * interrupt here, but that means you locked for way too long anyhow. */ - mix_buffer (this, buffer[fill_me]); + mix_buffer(this, buffer[fill_me]); } } static void -callBackProc (SndChannel * chan, SndCommand * cmd_passed) +callBackProc(SndChannel * chan, SndCommand * cmd_passed) { UInt32 play_me; SndCommand cmd; SDL_AudioDevice *audio = (SDL_AudioDevice *) chan->userInfo; - IncrementAtomic ((SInt32 *) & need_to_mix); + IncrementAtomic((SInt32 *) & need_to_mix); fill_me = cmd_passed->param2; /* buffer that has just finished playing, so fill it */ play_me = !fill_me; /* filled buffer to play _now_ */ @@ -196,16 +196,16 @@ cmd.cmd = bufferCmd; cmd.param1 = 0; cmd.param2 = (long) &header; - SndDoCommand (chan, &cmd, 0); + SndDoCommand(chan, &cmd, 0); - memset (buffer[fill_me], 0, audio->spec.size); + memset(buffer[fill_me], 0, audio->spec.size); /* * if audio device isn't locked, mix the next buffer to be queued in * the memory block that just finished playing. */ - if (!BitAndAtomic (0xFFFFFFFF, (UInt32 *) & audio_is_locked)) { - mix_buffer (audio, buffer[fill_me]); + if (!BitAndAtomic(0xFFFFFFFF, (UInt32 *) & audio_is_locked)) { + mix_buffer(audio, buffer[fill_me]); } /* set this callback to run again when current buffer drains. */ @@ -214,12 +214,12 @@ cmd.param1 = 0; cmd.param2 = play_me; - SndDoCommand (chan, &cmd, 0); + SndDoCommand(chan, &cmd, 0); } } static int -Mac_OpenAudio (_THIS, SDL_AudioSpec * spec) +Mac_OpenAudio(_THIS, SDL_AudioSpec * spec) { SndCallBackUPP callback; @@ -239,17 +239,17 @@ spec->format = AUDIO_S16MSB; break; } - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* initialize bufferCmd header */ - memset (&header, 0, sizeof (header)); - callback = (SndCallBackUPP) NewSndCallBackUPP (callBackProc); + memset(&header, 0, sizeof(header)); + callback = (SndCallBackUPP) NewSndCallBackUPP(callBackProc); sample_bits = spec->size / spec->samples / spec->channels * 8; #ifdef DEBUG_AUDIO - fprintf (stderr, - "Audio format 0x%x, channels = %d, sample_bits = %d, frequency = %d\n", - spec->format, spec->channels, sample_bits, spec->freq); + fprintf(stderr, + "Audio format 0x%x, channels = %d, sample_bits = %d, frequency = %d\n", + spec->format, spec->channels, sample_bits, spec->freq); #endif /* DEBUG_AUDIO */ header.numChannels = spec->channels; @@ -266,18 +266,18 @@ /* allocate 2 buffers */ for (i = 0; i < 2; i++) { - buffer[i] = (UInt8 *) malloc (sizeof (UInt8) * spec->size); + buffer[i] = (UInt8 *) malloc(sizeof(UInt8) * spec->size); if (buffer[i] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } - memset (buffer[i], 0, spec->size); + memset(buffer[i], 0, spec->size); } /* Create the sound manager channel */ - channel = (SndChannelPtr) SDL_malloc (sizeof (*channel)); + channel = (SndChannelPtr) SDL_malloc(sizeof(*channel)); if (channel == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } if (spec->channels >= 2) { @@ -287,10 +287,9 @@ } channel->userInfo = (long) this; channel->qLength = 128; - if (SndNewChannel (&channel, sampledSynth, initOptions, callback) != - noErr) { - SDL_SetError ("Unable to create audio channel"); - SDL_free (channel); + if (SndNewChannel(&channel, sampledSynth, initOptions, callback) != noErr) { + SDL_SetError("Unable to create audio channel"); + SDL_free(channel); channel = NULL; return (-1); } @@ -301,14 +300,14 @@ cmd.cmd = callBackCmd; cmd.param2 = 0; running = 1; - SndDoCommand (channel, &cmd, 0); + SndDoCommand(channel, &cmd, 0); } return 1; } static void -Mac_CloseAudio (_THIS) +Mac_CloseAudio(_THIS) { int i; @@ -316,13 +315,13 @@ running = 0; if (channel) { - SndDisposeChannel (channel, true); + SndDisposeChannel(channel, true); channel = NULL; } for (i = 0; i < 2; ++i) { if (buffer[i]) { - SDL_free (buffer[i]); + SDL_free(buffer[i]); buffer[i] = NULL; } } @@ -331,13 +330,13 @@ #else /* !TARGET_API_MAC_CARBON && !USE_RYANS_SOUNDCODE */ static void -Mac_LockAudio (_THIS) +Mac_LockAudio(_THIS) { /* no-op. */ } static void -Mac_UnlockAudio (_THIS) +Mac_UnlockAudio(_THIS) { /* no-op. */ } @@ -348,7 +347,7 @@ we're not paused. */ static pascal void -sndDoubleBackProc (SndChannelPtr chan, SndDoubleBufferPtr newbuf) +sndDoubleBackProc(SndChannelPtr chan, SndDoubleBufferPtr newbuf) { SDL_AudioDevice *audio = (SDL_AudioDevice *) newbuf->dbUserInfo[0]; @@ -356,47 +355,47 @@ if (!audio->enabled) { return; } - memset (newbuf->dbSoundData, 0, audio->spec.size); + memset(newbuf->dbSoundData, 0, audio->spec.size); newbuf->dbNumFrames = audio->spec.samples; if (!audio->paused) { if (audio->convert.needed) { - audio->spec.callback (audio->spec.userdata, - (Uint8 *) audio->convert.buf, - audio->convert.len); - SDL_ConvertAudio (&audio->convert); + audio->spec.callback(audio->spec.userdata, + (Uint8 *) audio->convert.buf, + audio->convert.len); + SDL_ConvertAudio(&audio->convert); #if 0 if (audio->convert.len_cvt != audio->spec.size) { /* Uh oh... probably crashes here */ ; } #endif - SDL_memcpy (newbuf->dbSoundData, audio->convert.buf, - audio->convert.len_cvt); + SDL_memcpy(newbuf->dbSoundData, audio->convert.buf, + audio->convert.len_cvt); } else { - audio->spec.callback (audio->spec.userdata, - (Uint8 *) newbuf->dbSoundData, - audio->spec.size); + audio->spec.callback(audio->spec.userdata, + (Uint8 *) newbuf->dbSoundData, + audio->spec.size); } } newbuf->dbFlags |= dbBufferReady; } static int -DoubleBufferAudio_Available (void) +DoubleBufferAudio_Available(void) { int available; NumVersion sndversion; long response; available = 0; - sndversion = SndSoundManagerVersion (); + sndversion = SndSoundManagerVersion(); if (sndversion.majorRev >= 3) { - if (Gestalt (gestaltSoundAttr, &response) == noErr) { + if (Gestalt(gestaltSoundAttr, &response) == noErr) { if ((response & (1 << gestaltSndPlayDoubleBuffer))) { available = 1; } } } else { - if (Gestalt (gestaltSoundAttr, &response) == noErr) { + if (Gestalt(gestaltSoundAttr, &response) == noErr) { if ((response & (1 << gestaltHasASC))) { available = 1; } @@ -406,25 +405,25 @@ } static void -Mac_CloseAudio (_THIS) +Mac_CloseAudio(_THIS) { int i; if (channel != NULL) { /* Clean up the audio channel */ - SndDisposeChannel (channel, true); + SndDisposeChannel(channel, true); channel = NULL; } for (i = 0; i < 2; ++i) { if (audio_buf[i]) { - SDL_free (audio_buf[i]); + SDL_free(audio_buf[i]); audio_buf[i] = NULL; } } } static int -Mac_OpenAudio (_THIS, SDL_AudioSpec * spec) +Mac_OpenAudio(_THIS, SDL_AudioSpec * spec) { SndDoubleBufferHeader2 audio_dbh; int i; @@ -433,8 +432,8 @@ SndDoubleBackUPP doubleBackProc; /* Check to make sure double-buffered audio is available */ - if (!DoubleBufferAudio_Available ()) { - SDL_SetError ("Sound manager doesn't support double-buffering"); + if (!DoubleBufferAudio_Available()) { + SDL_SetError("Sound manager doesn't support double-buffering"); return (-1); } @@ -450,11 +449,11 @@ spec->format = AUDIO_S16MSB; break; } - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* initialize the double-back header */ - SDL_memset (&audio_dbh, 0, sizeof (audio_dbh)); - doubleBackProc = NewSndDoubleBackProc (sndDoubleBackProc); + SDL_memset(&audio_dbh, 0, sizeof(audio_dbh)); + doubleBackProc = NewSndDoubleBackProc(sndDoubleBackProc); sample_bits = spec->size / spec->samples / spec->channels * 8; audio_dbh.dbhNumChannels = spec->channels; @@ -473,9 +472,9 @@ /* allocate the 2 double-back buffers */ for (i = 0; i < 2; ++i) { - audio_buf[i] = SDL_calloc (1, sizeof (SndDoubleBuffer) + spec->size); + audio_buf[i] = SDL_calloc(1, sizeof(SndDoubleBuffer) + spec->size); if (audio_buf[i] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } audio_buf[i]->dbNumFrames = spec->samples; @@ -485,9 +484,9 @@ } /* Create the sound manager channel */ - channel = (SndChannelPtr) SDL_malloc (sizeof (*channel)); + channel = (SndChannelPtr) SDL_malloc(sizeof(*channel)); if (channel == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } if (spec->channels >= 2) { @@ -497,17 +496,17 @@ } channel->userInfo = 0; channel->qLength = 128; - if (SndNewChannel (&channel, sampledSynth, initOptions, 0L) != noErr) { - SDL_SetError ("Unable to create audio channel"); - SDL_free (channel); + if (SndNewChannel(&channel, sampledSynth, initOptions, 0L) != noErr) { + SDL_SetError("Unable to create audio channel"); + SDL_free(channel); channel = NULL; return (-1); } /* Start playback */ - if (SndPlayDoubleBuffer (channel, (SndDoubleBufferHeaderPtr) & audio_dbh) + if (SndPlayDoubleBuffer(channel, (SndDoubleBufferHeaderPtr) & audio_dbh) != noErr) { - SDL_SetError ("Unable to play double buffered audio"); + SDL_SetError("Unable to play double buffered audio"); return (-1); } diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/mint/SDL_mintaudio.c --- a/src/audio/mint/SDL_mintaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/mint/SDL_mintaudio.c Mon May 29 04:04:35 2006 +0000 @@ -56,13 +56,13 @@ /* The callback function, called by each driver whenever needed */ void -SDL_MintAudio_Callback (void) +SDL_MintAudio_Callback(void) { Uint8 *buffer; SDL_AudioDevice *audio = SDL_MintAudio_device; buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; - SDL_memset (buffer, audio->spec.silence, audio->spec.size); + SDL_memset(buffer, audio->spec.silence, audio->spec.size); if (audio->paused) return; @@ -75,21 +75,21 @@ } else { silence = 0; } - SDL_memset (audio->convert.buf, silence, audio->convert.len); - audio->spec.callback (audio->spec.userdata, - (Uint8 *) audio->convert.buf, - audio->convert.len); - SDL_ConvertAudio (&audio->convert); - SDL_memcpy (buffer, audio->convert.buf, audio->convert.len_cvt); + SDL_memset(audio->convert.buf, silence, audio->convert.len); + audio->spec.callback(audio->spec.userdata, + (Uint8 *) audio->convert.buf, + audio->convert.len); + SDL_ConvertAudio(&audio->convert); + SDL_memcpy(buffer, audio->convert.buf, audio->convert.len_cvt); } else { - audio->spec.callback (audio->spec.userdata, buffer, audio->spec.size); + audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size); } } /* Add a new frequency/clock/predivisor to the current list */ void -SDL_MintAudio_AddFrequency (_THIS, Uint32 frequency, Uint32 clock, - Uint32 prediv, int gpio_bits) +SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock, + Uint32 prediv, int gpio_bits) { int i, p; @@ -107,9 +107,9 @@ /* Put all following ones farer */ if (MINTAUDIO_freqcount > 0) { for (i = MINTAUDIO_freqcount; i > p; i--) { - SDL_memcpy (&MINTAUDIO_frequencies[i], - &MINTAUDIO_frequencies[i - 1], - sizeof (mint_frequency_t)); + SDL_memcpy(&MINTAUDIO_frequencies[i], + &MINTAUDIO_frequencies[i - 1], + sizeof(mint_frequency_t)); } } @@ -124,7 +124,7 @@ /* Search for the nearest frequency */ int -SDL_MintAudio_SearchFrequency (_THIS, int desired_freq) +SDL_MintAudio_SearchFrequency(_THIS, int desired_freq) { int i; @@ -147,14 +147,14 @@ /* The thread function, used under MiNT with xbios */ int -SDL_MintAudio_Thread (long param) +SDL_MintAudio_Thread(long param) { SndBufPtr pointers; SDL_bool buffers_filled[2] = { SDL_FALSE, SDL_FALSE }; SDL_MintAudio_thread_finished = SDL_FALSE; while (!SDL_MintAudio_quit_thread) { - if (Buffptr (&pointers) != 0) + if (Buffptr(&pointers) != 0) continue; if (((unsigned long) pointers.play >= @@ -164,10 +164,10 @@ /* DMA is reading buffer #0, setup buffer #1 if not already done */ if (!buffers_filled[1]) { SDL_MintAudio_numbuf = 1; - SDL_MintAudio_Callback (); - Setbuffer (0, SDL_MintAudio_audiobuf[1], - SDL_MintAudio_audiobuf[1] + - SDL_MintAudio_audiosize); + SDL_MintAudio_Callback(); + Setbuffer(0, SDL_MintAudio_audiobuf[1], + SDL_MintAudio_audiobuf[1] + + SDL_MintAudio_audiosize); buffers_filled[1] = SDL_TRUE; buffers_filled[0] = SDL_FALSE; } @@ -175,23 +175,23 @@ /* DMA is reading buffer #1, setup buffer #0 if not already done */ if (!buffers_filled[0]) { SDL_MintAudio_numbuf = 0; - SDL_MintAudio_Callback (); - Setbuffer (0, SDL_MintAudio_audiobuf[0], - SDL_MintAudio_audiobuf[0] + - SDL_MintAudio_audiosize); + SDL_MintAudio_Callback(); + Setbuffer(0, SDL_MintAudio_audiobuf[0], + SDL_MintAudio_audiobuf[0] + + SDL_MintAudio_audiosize); buffers_filled[0] = SDL_TRUE; buffers_filled[1] = SDL_FALSE; } } - usleep (100); + usleep(100); } SDL_MintAudio_thread_finished = SDL_TRUE; return 0; } void -SDL_MintAudio_WaitThread (void) +SDL_MintAudio_WaitThread(void) { if (!SDL_MintAudio_mint_present) return; @@ -201,7 +201,7 @@ SDL_MintAudio_quit_thread = SDL_TRUE; while (!SDL_MintAudio_thread_finished) { - Syield (); + Syield(); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/mint/SDL_mintaudio.h --- a/src/audio/mint/SDL_mintaudio.h Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/mint/SDL_mintaudio.h Mon May 29 04:04:35 2006 +0000 @@ -136,22 +136,22 @@ extern long SDL_MintAudio_thread_pid; /* Functions */ -void SDL_MintAudio_Callback (void); -void SDL_MintAudio_AddFrequency (_THIS, Uint32 frequency, Uint32 clock, - Uint32 prediv, int gpio_bits); -int SDL_MintAudio_SearchFrequency (_THIS, int desired_freq); +void SDL_MintAudio_Callback(void); +void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock, + Uint32 prediv, int gpio_bits); +int SDL_MintAudio_SearchFrequency(_THIS, int desired_freq); /* MiNT thread functions */ -int SDL_MintAudio_Thread (long param); -void SDL_MintAudio_WaitThread (void); +int SDL_MintAudio_Thread(long param); +void SDL_MintAudio_WaitThread(void); /* ASM interrupt functions */ -void SDL_MintAudio_GsxbInterrupt (void); -void SDL_MintAudio_EmptyGsxbInterrupt (void); -void SDL_MintAudio_XbiosInterruptMeasureClock (void); -void SDL_MintAudio_XbiosInterrupt (void); -void SDL_MintAudio_Dma8Interrupt (void); -void SDL_MintAudio_StfaInterrupt (void); +void SDL_MintAudio_GsxbInterrupt(void); +void SDL_MintAudio_EmptyGsxbInterrupt(void); +void SDL_MintAudio_XbiosInterruptMeasureClock(void); +void SDL_MintAudio_XbiosInterrupt(void); +void SDL_MintAudio_Dma8Interrupt(void); +void SDL_MintAudio_StfaInterrupt(void); #endif /* _SDL_mintaudio_h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/mint/SDL_mintaudio_dma8.c --- a/src/audio/mint/SDL_mintaudio_dma8.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/mint/SDL_mintaudio_dma8.c Mon May 29 04:04:35 2006 +0000 @@ -63,85 +63,85 @@ /*--- Audio driver functions ---*/ -static void Mint_CloseAudio (_THIS); -static int Mint_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void Mint_LockAudio (_THIS); -static void Mint_UnlockAudio (_THIS); +static void Mint_CloseAudio(_THIS); +static int Mint_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void Mint_LockAudio(_THIS); +static void Mint_UnlockAudio(_THIS); /* To check/init hardware audio */ -static int Mint_CheckAudio (_THIS, SDL_AudioSpec * spec); -static void Mint_InitAudio (_THIS, SDL_AudioSpec * spec); +static int Mint_CheckAudio(_THIS, SDL_AudioSpec * spec); +static void Mint_InitAudio(_THIS, SDL_AudioSpec * spec); /*--- Audio driver bootstrap functions ---*/ static int -Audio_Available (void) +Audio_Available(void) { - const char *envr = SDL_getenv ("SDL_AUDIODRIVER"); + const char *envr = SDL_getenv("SDL_AUDIODRIVER"); /* Check if user asked a different audio driver */ - if ((envr) && (SDL_strcmp (envr, MINT_AUDIO_DRIVER_NAME) != 0)) { - DEBUG_PRINT ((DEBUG_NAME "user asked a different audio driver\n")); + if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME) != 0)) { + DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); return 0; } /* Cookie _MCH present ? if not, assume ST machine */ - if (Getcookie (C__MCH, &cookie_mch) == C_NOTFOUND) { + if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) { cookie_mch = MCH_ST; } /* Cookie _SND present ? if not, assume ST machine */ - if (Getcookie (C__SND, &cookie_snd) == C_NOTFOUND) { + if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { cookie_snd = SND_PSG; } /* Check if we have 8 bits audio */ if ((cookie_snd & SND_8BIT) == 0) { - DEBUG_PRINT ((DEBUG_NAME "no 8 bits sound\n")); + DEBUG_PRINT((DEBUG_NAME "no 8 bits sound\n")); return (0); } /* Check if audio is lockable */ if (cookie_snd & SND_16BIT) { - if (Locksnd () != 1) { - DEBUG_PRINT ((DEBUG_NAME "audio locked by other application\n")); + if (Locksnd() != 1) { + DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n")); return (0); } - Unlocksnd (); + Unlocksnd(); } - DEBUG_PRINT ((DEBUG_NAME "8 bits audio available!\n")); + DEBUG_PRINT((DEBUG_NAME "8 bits audio available!\n")); return (1); } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = Mint_OpenAudio; @@ -159,70 +159,70 @@ }; static void -Mint_LockAudio (_THIS) +Mint_LockAudio(_THIS) { void *oldpile; /* Stop replay */ - oldpile = (void *) Super (0); + oldpile = (void *) Super(0); DMAAUDIO_IO.control = 0; - Super (oldpile); + Super(oldpile); } static void -Mint_UnlockAudio (_THIS) +Mint_UnlockAudio(_THIS) { void *oldpile; /* Restart replay */ - oldpile = (void *) Super (0); + oldpile = (void *) Super(0); DMAAUDIO_IO.control = 3; - Super (oldpile); + Super(oldpile); } static void -Mint_CloseAudio (_THIS) +Mint_CloseAudio(_THIS) { void *oldpile; /* Stop replay */ - oldpile = (void *) Super (0); + oldpile = (void *) Super(0); DMAAUDIO_IO.control = 0; - Super (oldpile); + Super(oldpile); - DEBUG_PRINT ((DEBUG_NAME "closeaudio: replay stopped\n")); + DEBUG_PRINT((DEBUG_NAME "closeaudio: replay stopped\n")); /* Disable interrupt */ - Jdisint (MFP_DMASOUND); + Jdisint(MFP_DMASOUND); - DEBUG_PRINT ((DEBUG_NAME "closeaudio: interrupt disabled\n")); + DEBUG_PRINT((DEBUG_NAME "closeaudio: interrupt disabled\n")); /* Wait if currently playing sound */ while (SDL_MintAudio_mutex != 0) { } - DEBUG_PRINT ((DEBUG_NAME "closeaudio: no more interrupt running\n")); + DEBUG_PRINT((DEBUG_NAME "closeaudio: no more interrupt running\n")); /* Clear buffers */ if (SDL_MintAudio_audiobuf[0]) { - Mfree (SDL_MintAudio_audiobuf[0]); + Mfree(SDL_MintAudio_audiobuf[0]); SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; } - DEBUG_PRINT ((DEBUG_NAME "closeaudio: buffers freed\n")); + DEBUG_PRINT((DEBUG_NAME "closeaudio: buffers freed\n")); } static int -Mint_CheckAudio (_THIS, SDL_AudioSpec * spec) +Mint_CheckAudio(_THIS, SDL_AudioSpec * spec) { int i, masterprediv, sfreq; unsigned long masterclock; - DEBUG_PRINT ((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff)); - DEBUG_PRINT (("signed=%d, ", ((spec->format & 0x8000) != 0))); - DEBUG_PRINT (("big endian=%d, ", ((spec->format & 0x1000) != 0))); - DEBUG_PRINT (("channels=%d, ", spec->channels)); - DEBUG_PRINT (("freq=%d\n", spec->freq)); + DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff)); + DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); + DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); + DEBUG_PRINT(("channels=%d, ", spec->channels)); + DEBUG_PRINT(("freq=%d\n", spec->freq)); /* Check formats available */ spec->format = AUDIO_S8; @@ -252,34 +252,34 @@ MINTAUDIO_freqcount = 0; for (i = sfreq; i < 4; i++) { - SDL_MintAudio_AddFrequency (this, - masterclock / (masterprediv * (1 << i)), - masterclock, i - sfreq, -1); + SDL_MintAudio_AddFrequency(this, + masterclock / (masterprediv * (1 << i)), + masterclock, i - sfreq, -1); } #if 1 for (i = 0; i < MINTAUDIO_freqcount; i++) { - DEBUG_PRINT ((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n", - i, MINTAUDIO_frequencies[i].frequency, - MINTAUDIO_frequencies[i].masterclock, - MINTAUDIO_frequencies[i].predivisor)); + DEBUG_PRINT((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n", + i, MINTAUDIO_frequencies[i].frequency, + MINTAUDIO_frequencies[i].masterclock, + MINTAUDIO_frequencies[i].predivisor)); } #endif - MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency (this, spec->freq); + MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq); spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; - DEBUG_PRINT ((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff)); - DEBUG_PRINT (("signed=%d, ", ((spec->format & 0x8000) != 0))); - DEBUG_PRINT (("big endian=%d, ", ((spec->format & 0x1000) != 0))); - DEBUG_PRINT (("channels=%d, ", spec->channels)); - DEBUG_PRINT (("freq=%d\n", spec->freq)); + DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff)); + DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); + DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); + DEBUG_PRINT(("channels=%d, ", spec->channels)); + DEBUG_PRINT(("freq=%d\n", spec->freq)); return 0; } static void -Mint_InitAudio (_THIS, SDL_AudioSpec * spec) +Mint_InitAudio(_THIS, SDL_AudioSpec * spec) { void *oldpile; unsigned long buffer; @@ -287,11 +287,11 @@ /* Set replay tracks */ if (cookie_snd & SND_16BIT) { - Settracks (0, 0); - Setmontracks (0); + Settracks(0, 0); + Setmontracks(0); } - oldpile = (void *) Super (0); + oldpile = (void *) Super(0); /* Stop currently playing sound */ DMAAUDIO_IO.control = 0; @@ -314,55 +314,55 @@ DMAAUDIO_IO.sound_ctrl = mode; /* Set interrupt */ - Jdisint (MFP_DMASOUND); - Xbtimer (XB_TIMERA, 8, 1, SDL_MintAudio_Dma8Interrupt); - Jenabint (MFP_DMASOUND); + Jdisint(MFP_DMASOUND); + Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_Dma8Interrupt); + Jenabint(MFP_DMASOUND); if (cookie_snd & SND_16BIT) { - if (Setinterrupt (SI_TIMERA, SI_PLAY) < 0) { - DEBUG_PRINT ((DEBUG_NAME "Setinterrupt() failed\n")); + if (Setinterrupt(SI_TIMERA, SI_PLAY) < 0) { + DEBUG_PRINT((DEBUG_NAME "Setinterrupt() failed\n")); } } /* Go */ DMAAUDIO_IO.control = 3; /* playback + repeat */ - Super (oldpile); + Super(oldpile); } static int -Mint_OpenAudio (_THIS, SDL_AudioSpec * spec) +Mint_OpenAudio(_THIS, SDL_AudioSpec * spec) { SDL_MintAudio_device = this; /* Check audio capabilities */ - if (Mint_CheckAudio (this, spec) == -1) { + if (Mint_CheckAudio(this, spec) == -1) { return -1; } - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Allocate memory for audio buffers in DMA-able RAM */ - DEBUG_PRINT ((DEBUG_NAME "buffer size=%d\n", spec->size)); + DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", spec->size)); - SDL_MintAudio_audiobuf[0] = Atari_SysMalloc (spec->size * 2, MX_STRAM); + SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(spec->size * 2, MX_STRAM); if (SDL_MintAudio_audiobuf[0] == NULL) { - SDL_SetError ("MINT_OpenAudio: Not enough memory for audio buffer"); + SDL_SetError("MINT_OpenAudio: Not enough memory for audio buffer"); return (-1); } SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size; SDL_MintAudio_numbuf = 0; - SDL_memset (SDL_MintAudio_audiobuf[0], spec->silence, spec->size * 2); + SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size * 2); SDL_MintAudio_audiosize = spec->size; SDL_MintAudio_mutex = 0; - DEBUG_PRINT ((DEBUG_NAME "buffer 0 at 0x%08x\n", - SDL_MintAudio_audiobuf[0])); - DEBUG_PRINT ((DEBUG_NAME "buffer 1 at 0x%08x\n", - SDL_MintAudio_audiobuf[1])); + DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", + SDL_MintAudio_audiobuf[0])); + DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", + SDL_MintAudio_audiobuf[1])); /* Setup audio hardware */ - Mint_InitAudio (this, spec); + Mint_InitAudio(this, spec); return (1); /* We don't use threaded audio */ } diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/mint/SDL_mintaudio_gsxb.c --- a/src/audio/mint/SDL_mintaudio_gsxb.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/mint/SDL_mintaudio_gsxb.c Mon May 29 04:04:35 2006 +0000 @@ -63,91 +63,91 @@ /*--- Audio driver functions ---*/ -static void Mint_CloseAudio (_THIS); -static int Mint_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void Mint_LockAudio (_THIS); -static void Mint_UnlockAudio (_THIS); +static void Mint_CloseAudio(_THIS); +static int Mint_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void Mint_LockAudio(_THIS); +static void Mint_UnlockAudio(_THIS); /* To check/init hardware audio */ -static int Mint_CheckAudio (_THIS, SDL_AudioSpec * spec); -static void Mint_InitAudio (_THIS, SDL_AudioSpec * spec); +static int Mint_CheckAudio(_THIS, SDL_AudioSpec * spec); +static void Mint_InitAudio(_THIS, SDL_AudioSpec * spec); /* GSXB callbacks */ -static void Mint_GsxbInterrupt (void); -static void Mint_GsxbNullInterrupt (void); +static void Mint_GsxbInterrupt(void); +static void Mint_GsxbNullInterrupt(void); /*--- Audio driver bootstrap functions ---*/ static int -Audio_Available (void) +Audio_Available(void) { - const char *envr = SDL_getenv ("SDL_AUDIODRIVER"); + const char *envr = SDL_getenv("SDL_AUDIODRIVER"); /* Check if user asked a different audio driver */ - if ((envr) && (SDL_strcmp (envr, MINT_AUDIO_DRIVER_NAME) != 0)) { - DEBUG_PRINT ((DEBUG_NAME "user asked a different audio driver\n")); + if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME) != 0)) { + DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); return (0); } /* Cookie _SND present ? if not, assume ST machine */ - if (Getcookie (C__SND, &cookie_snd) == C_NOTFOUND) { + if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { cookie_snd = SND_PSG; } /* Check if we have 16 bits audio */ if ((cookie_snd & SND_16BIT) == 0) { - DEBUG_PRINT ((DEBUG_NAME "no 16 bits sound\n")); + DEBUG_PRINT((DEBUG_NAME "no 16 bits sound\n")); return (0); } /* Cookie GSXB present ? */ - cookie_gsxb = (Getcookie (C_GSXB, &cookie_gsxb) == C_FOUND); + cookie_gsxb = (Getcookie(C_GSXB, &cookie_gsxb) == C_FOUND); /* Is it GSXB ? */ if (((cookie_snd & SND_GSXB) == 0) || (cookie_gsxb == 0)) { - DEBUG_PRINT ((DEBUG_NAME "no GSXB audio\n")); + DEBUG_PRINT((DEBUG_NAME "no GSXB audio\n")); return (0); } /* Check if audio is lockable */ - if (Locksnd () != 1) { - DEBUG_PRINT ((DEBUG_NAME "audio locked by other application\n")); + if (Locksnd() != 1) { + DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n")); return (0); } - Unlocksnd (); + Unlocksnd(); - DEBUG_PRINT ((DEBUG_NAME "GSXB audio available!\n")); + DEBUG_PRINT((DEBUG_NAME "GSXB audio available!\n")); return (1); } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = Mint_OpenAudio; @@ -165,28 +165,28 @@ }; static void -Mint_LockAudio (_THIS) +Mint_LockAudio(_THIS) { /* Stop replay */ - Buffoper (0); + Buffoper(0); } static void -Mint_UnlockAudio (_THIS) +Mint_UnlockAudio(_THIS) { /* Restart replay */ - Buffoper (SB_PLA_ENA | SB_PLA_RPT); + Buffoper(SB_PLA_ENA | SB_PLA_RPT); } static void -Mint_CloseAudio (_THIS) +Mint_CloseAudio(_THIS) { /* Stop replay */ - Buffoper (0); + Buffoper(0); /* Uninstall interrupt */ - if (NSetinterrupt (2, SI_NONE, Mint_GsxbNullInterrupt) < 0) { - DEBUG_PRINT ((DEBUG_NAME "NSetinterrupt() failed in close\n")); + if (NSetinterrupt(2, SI_NONE, Mint_GsxbNullInterrupt) < 0) { + DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed in close\n")); } /* Wait if currently playing sound */ @@ -195,16 +195,16 @@ /* Clear buffers */ if (SDL_MintAudio_audiobuf[0]) { - Mfree (SDL_MintAudio_audiobuf[0]); + Mfree(SDL_MintAudio_audiobuf[0]); SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; } /* Unlock sound system */ - Unlocksnd (); + Unlocksnd(); } static int -Mint_CheckAudio (_THIS, SDL_AudioSpec * spec) +Mint_CheckAudio(_THIS, SDL_AudioSpec * spec) { long snd_format; int i, resolution, format_signed, format_bigendian; @@ -213,31 +213,31 @@ format_signed = ((spec->format & 0x8000) != 0); format_bigendian = ((spec->format & 0x1000) != 0); - DEBUG_PRINT ((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff)); - DEBUG_PRINT (("signed=%d, ", ((spec->format & 0x8000) != 0))); - DEBUG_PRINT (("big endian=%d, ", ((spec->format & 0x1000) != 0))); - DEBUG_PRINT (("channels=%d, ", spec->channels)); - DEBUG_PRINT (("freq=%d\n", spec->freq)); + DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff)); + DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); + DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); + DEBUG_PRINT(("channels=%d, ", spec->channels)); + DEBUG_PRINT(("freq=%d\n", spec->freq)); /* Check formats available */ - snd_format = Sndstatus (SND_QUERYFORMATS); + snd_format = Sndstatus(SND_QUERYFORMATS); switch (resolution) { case 8: if ((snd_format & SND_FORMAT8) == 0) { - SDL_SetError ("Mint_CheckAudio: 8 bits samples not supported"); + SDL_SetError("Mint_CheckAudio: 8 bits samples not supported"); return -1; } - snd_format = Sndstatus (SND_QUERY8BIT); + snd_format = Sndstatus(SND_QUERY8BIT); break; case 16: if ((snd_format & SND_FORMAT16) == 0) { - SDL_SetError ("Mint_CheckAudio: 16 bits samples not supported"); + SDL_SetError("Mint_CheckAudio: 16 bits samples not supported"); return -1; } - snd_format = Sndstatus (SND_QUERY16BIT); + snd_format = Sndstatus(SND_QUERY16BIT); break; default: - SDL_SetError ("Mint_CheckAudio: Unsupported sample resolution"); + SDL_SetError("Mint_CheckAudio: Unsupported sample resolution"); return -1; break; } @@ -278,45 +278,45 @@ /* Calculate and select the closest frequency */ MINTAUDIO_freqcount = 0; for (i = 1; i < 4; i++) { - SDL_MintAudio_AddFrequency (this, - MASTERCLOCK_44K / (MASTERPREDIV_MILAN * - (1 << i)), - MASTERCLOCK_44K, (1 << i) - 1, -1); + SDL_MintAudio_AddFrequency(this, + MASTERCLOCK_44K / (MASTERPREDIV_MILAN * + (1 << i)), + MASTERCLOCK_44K, (1 << i) - 1, -1); } #if 1 for (i = 0; i < MINTAUDIO_freqcount; i++) { - DEBUG_PRINT ((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n", - i, MINTAUDIO_frequencies[i].frequency, - MINTAUDIO_frequencies[i].masterclock, - MINTAUDIO_frequencies[i].predivisor)); + DEBUG_PRINT((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n", + i, MINTAUDIO_frequencies[i].frequency, + MINTAUDIO_frequencies[i].masterclock, + MINTAUDIO_frequencies[i].predivisor)); } #endif - MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency (this, spec->freq); + MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq); spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; - DEBUG_PRINT ((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff)); - DEBUG_PRINT (("signed=%d, ", ((spec->format & 0x8000) != 0))); - DEBUG_PRINT (("big endian=%d, ", ((spec->format & 0x1000) != 0))); - DEBUG_PRINT (("channels=%d, ", spec->channels)); - DEBUG_PRINT (("freq=%d\n", spec->freq)); + DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff)); + DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); + DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); + DEBUG_PRINT(("channels=%d, ", spec->channels)); + DEBUG_PRINT(("freq=%d\n", spec->freq)); return 0; } static void -Mint_InitAudio (_THIS, SDL_AudioSpec * spec) +Mint_InitAudio(_THIS, SDL_AudioSpec * spec) { int channels_mode, prediv; void *buffer; /* Stop currently playing sound */ - Buffoper (0); + Buffoper(0); /* Set replay tracks */ - Settracks (0, 0); - Setmontracks (0); + Settracks(0, 0); + Setmontracks(0); /* Select replay format */ switch (spec->format & 0xff) { @@ -338,74 +338,74 @@ channels_mode = STEREO16; break; } - if (Setmode (channels_mode) < 0) { - DEBUG_PRINT ((DEBUG_NAME "Setmode() failed\n")); + if (Setmode(channels_mode) < 0) { + DEBUG_PRINT((DEBUG_NAME "Setmode() failed\n")); } prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor; - Devconnect (DMAPLAY, DAC, CLKEXT, prediv, 1); + Devconnect(DMAPLAY, DAC, CLKEXT, prediv, 1); /* Set buffer */ buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; - if (Setbuffer (0, buffer, buffer + spec->size) < 0) { - DEBUG_PRINT ((DEBUG_NAME "Setbuffer() failed\n")); + if (Setbuffer(0, buffer, buffer + spec->size) < 0) { + DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n")); } /* Install interrupt */ - if (NSetinterrupt (2, SI_PLAY, Mint_GsxbInterrupt) < 0) { - DEBUG_PRINT ((DEBUG_NAME "NSetinterrupt() failed\n")); + if (NSetinterrupt(2, SI_PLAY, Mint_GsxbInterrupt) < 0) { + DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed\n")); } /* Go */ - Buffoper (SB_PLA_ENA | SB_PLA_RPT); - DEBUG_PRINT ((DEBUG_NAME "hardware initialized\n")); + Buffoper(SB_PLA_ENA | SB_PLA_RPT); + DEBUG_PRINT((DEBUG_NAME "hardware initialized\n")); } static int -Mint_OpenAudio (_THIS, SDL_AudioSpec * spec) +Mint_OpenAudio(_THIS, SDL_AudioSpec * spec) { /* Lock sound system */ - if (Locksnd () != 1) { - SDL_SetError ("Mint_OpenAudio: Audio system already in use"); + if (Locksnd() != 1) { + SDL_SetError("Mint_OpenAudio: Audio system already in use"); return (-1); } SDL_MintAudio_device = this; /* Check audio capabilities */ - if (Mint_CheckAudio (this, spec) == -1) { + if (Mint_CheckAudio(this, spec) == -1) { return -1; } - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Allocate memory for audio buffers in DMA-able RAM */ - DEBUG_PRINT ((DEBUG_NAME "buffer size=%d\n", spec->size)); + DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", spec->size)); - SDL_MintAudio_audiobuf[0] = Atari_SysMalloc (spec->size * 2, MX_STRAM); + SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(spec->size * 2, MX_STRAM); if (SDL_MintAudio_audiobuf[0] == NULL) { - SDL_SetError ("MINT_OpenAudio: Not enough memory for audio buffer"); + SDL_SetError("MINT_OpenAudio: Not enough memory for audio buffer"); return (-1); } SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size; SDL_MintAudio_numbuf = 0; - SDL_memset (SDL_MintAudio_audiobuf[0], spec->silence, spec->size * 2); + SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size * 2); SDL_MintAudio_audiosize = spec->size; SDL_MintAudio_mutex = 0; - DEBUG_PRINT ((DEBUG_NAME "buffer 0 at 0x%08x\n", - SDL_MintAudio_audiobuf[0])); - DEBUG_PRINT ((DEBUG_NAME "buffer 1 at 0x%08x\n", - SDL_MintAudio_audiobuf[1])); + DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", + SDL_MintAudio_audiobuf[0])); + DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", + SDL_MintAudio_audiobuf[1])); /* Setup audio hardware */ - Mint_InitAudio (this, spec); + Mint_InitAudio(this, spec); return (1); /* We don't use threaded audio */ } static void -Mint_GsxbInterrupt (void) +Mint_GsxbInterrupt(void) { Uint8 *newbuf; @@ -415,15 +415,15 @@ SDL_MintAudio_mutex = 1; SDL_MintAudio_numbuf ^= 1; - SDL_MintAudio_Callback (); + SDL_MintAudio_Callback(); newbuf = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; - Setbuffer (0, newbuf, newbuf + SDL_MintAudio_audiosize); + Setbuffer(0, newbuf, newbuf + SDL_MintAudio_audiosize); SDL_MintAudio_mutex = 0; } static void -Mint_GsxbNullInterrupt (void) +Mint_GsxbNullInterrupt(void) { } diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/mint/SDL_mintaudio_mcsn.c --- a/src/audio/mint/SDL_mintaudio_mcsn.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/mint/SDL_mintaudio_mcsn.c Mon May 29 04:04:35 2006 +0000 @@ -66,103 +66,103 @@ /*--- Audio driver functions ---*/ -static void Mint_CloseAudio (_THIS); -static int Mint_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void Mint_LockAudio (_THIS); -static void Mint_UnlockAudio (_THIS); +static void Mint_CloseAudio(_THIS); +static int Mint_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void Mint_LockAudio(_THIS); +static void Mint_UnlockAudio(_THIS); /* To check/init hardware audio */ -static int Mint_CheckAudio (_THIS, SDL_AudioSpec * spec); -static void Mint_InitAudio (_THIS, SDL_AudioSpec * spec); +static int Mint_CheckAudio(_THIS, SDL_AudioSpec * spec); +static void Mint_InitAudio(_THIS, SDL_AudioSpec * spec); /*--- Audio driver bootstrap functions ---*/ static int -Audio_Available (void) +Audio_Available(void) { unsigned long dummy; - const char *envr = SDL_getenv ("SDL_AUDIODRIVER"); + const char *envr = SDL_getenv("SDL_AUDIODRIVER"); - SDL_MintAudio_mint_present = (Getcookie (C_MiNT, &dummy) == C_FOUND); + SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); /* We can't use XBIOS in interrupt with Magic, don't know about thread */ - if (Getcookie (C_MagX, &dummy) == C_FOUND) { + if (Getcookie(C_MagX, &dummy) == C_FOUND) { return (0); } /* Check if user asked a different audio driver */ - if ((envr) && (SDL_strcmp (envr, MINT_AUDIO_DRIVER_NAME) != 0)) { - DEBUG_PRINT ((DEBUG_NAME "user asked a different audio driver\n")); + if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME) != 0)) { + DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); return (0); } /* Cookie _MCH present ? if not, assume ST machine */ - if (Getcookie (C__MCH, &cookie_mch) == C_NOTFOUND) { + if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) { cookie_mch = MCH_ST; } /* Cookie _SND present ? if not, assume ST machine */ - if (Getcookie (C__SND, &cookie_snd) == C_NOTFOUND) { + if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { cookie_snd = SND_PSG; } /* Check if we have 16 bits audio */ if ((cookie_snd & SND_16BIT) == 0) { - DEBUG_PRINT ((DEBUG_NAME "no 16 bits sound\n")); + DEBUG_PRINT((DEBUG_NAME "no 16 bits sound\n")); return (0); } /* Cookie MCSN present ? */ - if (Getcookie (C_McSn, (long *) &cookie_mcsn) != C_FOUND) { - DEBUG_PRINT ((DEBUG_NAME "no MCSN audio\n")); + if (Getcookie(C_McSn, (long *) &cookie_mcsn) != C_FOUND) { + DEBUG_PRINT((DEBUG_NAME "no MCSN audio\n")); return (0); } /* Check if interrupt at end of replay */ if (cookie_mcsn->pint == 0) { - DEBUG_PRINT ((DEBUG_NAME "no interrupt at end of replay\n")); + DEBUG_PRINT((DEBUG_NAME "no interrupt at end of replay\n")); return (0); } /* Check if audio is lockable */ - if (Locksnd () != 1) { - DEBUG_PRINT ((DEBUG_NAME "audio locked by other application\n")); + if (Locksnd() != 1) { + DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n")); return (0); } - Unlocksnd (); + Unlocksnd(); - DEBUG_PRINT ((DEBUG_NAME "MCSN audio available!\n")); + DEBUG_PRINT((DEBUG_NAME "MCSN audio available!\n")); return (1); } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = Mint_OpenAudio; @@ -180,29 +180,29 @@ }; static void -Mint_LockAudio (_THIS) +Mint_LockAudio(_THIS) { /* Stop replay */ - Buffoper (0); + Buffoper(0); } static void -Mint_UnlockAudio (_THIS) +Mint_UnlockAudio(_THIS) { /* Restart replay */ - Buffoper (SB_PLA_ENA | SB_PLA_RPT); + Buffoper(SB_PLA_ENA | SB_PLA_RPT); } static void -Mint_CloseAudio (_THIS) +Mint_CloseAudio(_THIS) { /* Stop replay */ - SDL_MintAudio_WaitThread (); - Buffoper (0); + SDL_MintAudio_WaitThread(); + Buffoper(0); if (!SDL_MintAudio_mint_present) { /* Uninstall interrupt */ - Jdisint (MFP_DMASOUND); + Jdisint(MFP_DMASOUND); } /* Wait if currently playing sound */ @@ -211,25 +211,25 @@ /* Clear buffers */ if (SDL_MintAudio_audiobuf[0]) { - Mfree (SDL_MintAudio_audiobuf[0]); + Mfree(SDL_MintAudio_audiobuf[0]); SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; } /* Unlock sound system */ - Unlocksnd (); + Unlocksnd(); } static int -Mint_CheckAudio (_THIS, SDL_AudioSpec * spec) +Mint_CheckAudio(_THIS, SDL_AudioSpec * spec) { int i; unsigned long masterclock, masterprediv; - DEBUG_PRINT ((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff)); - DEBUG_PRINT (("signed=%d, ", ((spec->format & 0x8000) != 0))); - DEBUG_PRINT (("big endian=%d, ", ((spec->format & 0x1000) != 0))); - DEBUG_PRINT (("channels=%d, ", spec->channels)); - DEBUG_PRINT (("freq=%d\n", spec->freq)); + DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff)); + DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); + DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); + DEBUG_PRINT(("channels=%d, ", spec->channels)); + DEBUG_PRINT(("freq=%d\n", spec->freq)); /* Check formats available */ MINTAUDIO_freqcount = 0; @@ -237,7 +237,7 @@ case MCSN_ST: spec->channels = 1; spec->format = 8; /* FIXME: is it signed or unsigned ? */ - SDL_MintAudio_AddFrequency (this, 12500, 0, 0, -1); + SDL_MintAudio_AddFrequency(this, 12500, 0, 0, -1); break; case MCSN_TT: /* Also STE, Mega STE */ spec->format = AUDIO_S8; @@ -248,10 +248,10 @@ masterprediv = MASTERPREDIV_TT; } for (i = 0; i < 4; i++) { - SDL_MintAudio_AddFrequency (this, - masterclock / (masterprediv * - (1 << i)), - masterclock, 3 - i, -1); + SDL_MintAudio_AddFrequency(this, + masterclock / (masterprediv * + (1 << i)), + masterclock, 3 - i, -1); } break; case MCSN_FALCON: /* Also Mac */ @@ -260,18 +260,18 @@ if ((i == 6) || (i == 8) || (i == 10)) { continue; } - SDL_MintAudio_AddFrequency (this, - MASTERCLOCK_FALCON1 / - (MASTERPREDIV_FALCON * (i + 1)), - CLK25M, i + 1, -1); + SDL_MintAudio_AddFrequency(this, + MASTERCLOCK_FALCON1 / + (MASTERPREDIV_FALCON * (i + 1)), + CLK25M, i + 1, -1); } if (cookie_mcsn->res1 != 0) { for (i = 1; i < 4; i++) { - SDL_MintAudio_AddFrequency (this, - (cookie_mcsn->res1) / - (MASTERPREDIV_FALCON * - (1 << i)), CLKEXT, - (1 << i) - 1, -1); + SDL_MintAudio_AddFrequency(this, + (cookie_mcsn->res1) / + (MASTERPREDIV_FALCON * + (1 << i)), CLKEXT, + (1 << i) - 1, -1); } } spec->format |= 0x8000; /* Audio is always signed */ @@ -284,27 +284,27 @@ #if 1 for (i = 0; i < MINTAUDIO_freqcount; i++) { - DEBUG_PRINT ((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n", - i, MINTAUDIO_frequencies[i].frequency, - MINTAUDIO_frequencies[i].masterclock, - MINTAUDIO_frequencies[i].predivisor)); + DEBUG_PRINT((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n", + i, MINTAUDIO_frequencies[i].frequency, + MINTAUDIO_frequencies[i].masterclock, + MINTAUDIO_frequencies[i].predivisor)); } #endif - MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency (this, spec->freq); + MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq); spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; - DEBUG_PRINT ((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff)); - DEBUG_PRINT (("signed=%d, ", ((spec->format & 0x8000) != 0))); - DEBUG_PRINT (("big endian=%d, ", ((spec->format & 0x1000) != 0))); - DEBUG_PRINT (("channels=%d, ", spec->channels)); - DEBUG_PRINT (("freq=%d\n", spec->freq)); + DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff)); + DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); + DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); + DEBUG_PRINT(("channels=%d, ", spec->channels)); + DEBUG_PRINT(("freq=%d\n", spec->freq)); return 0; } static void -Mint_InitAudio (_THIS, SDL_AudioSpec * spec) +Mint_InitAudio(_THIS, SDL_AudioSpec * spec) { int channels_mode, prediv, dmaclock; void *buffer; @@ -312,12 +312,12 @@ /* Stop currently playing sound */ SDL_MintAudio_quit_thread = SDL_FALSE; SDL_MintAudio_thread_finished = SDL_TRUE; - SDL_MintAudio_WaitThread (); - Buffoper (0); + SDL_MintAudio_WaitThread(); + Buffoper(0); /* Set replay tracks */ - Settracks (0, 0); - Setmontracks (0); + Settracks(0, 0); + Setmontracks(0); /* Select replay format */ channels_mode = STEREO16; @@ -330,87 +330,87 @@ } break; } - if (Setmode (channels_mode) < 0) { - DEBUG_PRINT ((DEBUG_NAME "Setmode() failed\n")); + if (Setmode(channels_mode) < 0) { + DEBUG_PRINT((DEBUG_NAME "Setmode() failed\n")); } dmaclock = MINTAUDIO_frequencies[MINTAUDIO_numfreq].masterclock; prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor; switch (cookie_mcsn->play) { case MCSN_TT: - Devconnect (DMAPLAY, DAC, CLK25M, CLKOLD, 1); - Soundcmd (SETPRESCALE, prediv); - DEBUG_PRINT ((DEBUG_NAME "STE/TT prescaler selected\n")); + Devconnect(DMAPLAY, DAC, CLK25M, CLKOLD, 1); + Soundcmd(SETPRESCALE, prediv); + DEBUG_PRINT((DEBUG_NAME "STE/TT prescaler selected\n")); break; case MCSN_FALCON: - Devconnect (DMAPLAY, DAC, dmaclock, prediv, 1); - DEBUG_PRINT ((DEBUG_NAME "Falcon prescaler selected\n")); + Devconnect(DMAPLAY, DAC, dmaclock, prediv, 1); + DEBUG_PRINT((DEBUG_NAME "Falcon prescaler selected\n")); break; } /* Set buffer */ buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; - if (Setbuffer (0, buffer, buffer + spec->size) < 0) { - DEBUG_PRINT ((DEBUG_NAME "Setbuffer() failed\n")); + if (Setbuffer(0, buffer, buffer + spec->size) < 0) { + DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n")); } if (SDL_MintAudio_mint_present) { - SDL_MintAudio_thread_pid = tfork (SDL_MintAudio_Thread, 0); + SDL_MintAudio_thread_pid = tfork(SDL_MintAudio_Thread, 0); } else { /* Install interrupt */ - Jdisint (MFP_DMASOUND); - Xbtimer (XB_TIMERA, 8, 1, SDL_MintAudio_XbiosInterrupt); - Jenabint (MFP_DMASOUND); + Jdisint(MFP_DMASOUND); + Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_XbiosInterrupt); + Jenabint(MFP_DMASOUND); - if (Setinterrupt (SI_TIMERA, SI_PLAY) < 0) { - DEBUG_PRINT ((DEBUG_NAME "Setinterrupt() failed\n")); + if (Setinterrupt(SI_TIMERA, SI_PLAY) < 0) { + DEBUG_PRINT((DEBUG_NAME "Setinterrupt() failed\n")); } } /* Go */ - Buffoper (SB_PLA_ENA | SB_PLA_RPT); - DEBUG_PRINT ((DEBUG_NAME "hardware initialized\n")); + Buffoper(SB_PLA_ENA | SB_PLA_RPT); + DEBUG_PRINT((DEBUG_NAME "hardware initialized\n")); } static int -Mint_OpenAudio (_THIS, SDL_AudioSpec * spec) +Mint_OpenAudio(_THIS, SDL_AudioSpec * spec) { /* Lock sound system */ - if (Locksnd () != 1) { - SDL_SetError ("Mint_OpenAudio: Audio system already in use"); + if (Locksnd() != 1) { + SDL_SetError("Mint_OpenAudio: Audio system already in use"); return (-1); } SDL_MintAudio_device = this; /* Check audio capabilities */ - if (Mint_CheckAudio (this, spec) == -1) { + if (Mint_CheckAudio(this, spec) == -1) { return -1; } - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Allocate memory for audio buffers in DMA-able RAM */ - DEBUG_PRINT ((DEBUG_NAME "buffer size=%d\n", spec->size)); + DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", spec->size)); - SDL_MintAudio_audiobuf[0] = Atari_SysMalloc (spec->size * 2, MX_STRAM); + SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(spec->size * 2, MX_STRAM); if (SDL_MintAudio_audiobuf[0] == NULL) { - SDL_SetError ("MINT_OpenAudio: Not enough memory for audio buffer"); + SDL_SetError("MINT_OpenAudio: Not enough memory for audio buffer"); return (-1); } SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size; SDL_MintAudio_numbuf = 0; - SDL_memset (SDL_MintAudio_audiobuf[0], spec->silence, spec->size * 2); + SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size * 2); SDL_MintAudio_audiosize = spec->size; SDL_MintAudio_mutex = 0; - DEBUG_PRINT ((DEBUG_NAME "buffer 0 at 0x%08x\n", - SDL_MintAudio_audiobuf[0])); - DEBUG_PRINT ((DEBUG_NAME "buffer 1 at 0x%08x\n", - SDL_MintAudio_audiobuf[1])); + DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", + SDL_MintAudio_audiobuf[0])); + DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", + SDL_MintAudio_audiobuf[1])); /* Setup audio hardware */ - Mint_InitAudio (this, spec); + Mint_InitAudio(this, spec); return (1); /* We don't use SDL threaded audio */ } diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/mint/SDL_mintaudio_stfa.c --- a/src/audio/mint/SDL_mintaudio_stfa.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/mint/SDL_mintaudio_stfa.c Mon May 29 04:04:35 2006 +0000 @@ -71,77 +71,77 @@ /*--- Audio driver functions ---*/ -static void Mint_CloseAudio (_THIS); -static int Mint_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void Mint_LockAudio (_THIS); -static void Mint_UnlockAudio (_THIS); +static void Mint_CloseAudio(_THIS); +static int Mint_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void Mint_LockAudio(_THIS); +static void Mint_UnlockAudio(_THIS); /* To check/init hardware audio */ -static int Mint_CheckAudio (_THIS, SDL_AudioSpec * spec); -static void Mint_InitAudio (_THIS, SDL_AudioSpec * spec); +static int Mint_CheckAudio(_THIS, SDL_AudioSpec * spec); +static void Mint_InitAudio(_THIS, SDL_AudioSpec * spec); /*--- Audio driver bootstrap functions ---*/ static int -Audio_Available (void) +Audio_Available(void) { - const char *envr = SDL_getenv ("SDL_AUDIODRIVER"); + const char *envr = SDL_getenv("SDL_AUDIODRIVER"); /* Check if user asked a different audio driver */ - if ((envr) && (SDL_strcmp (envr, MINT_AUDIO_DRIVER_NAME) != 0)) { - DEBUG_PRINT ((DEBUG_NAME "user asked a different audio driver\n")); + if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME) != 0)) { + DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); return (0); } /* Cookie _MCH present ? if not, assume ST machine */ - if (Getcookie (C__MCH, &cookie_mch) == C_NOTFOUND) { + if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) { cookie_mch = MCH_ST; } /* Cookie _SND present ? if not, assume ST machine */ - if (Getcookie (C__SND, &cookie_snd) == C_NOTFOUND) { + if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { cookie_snd = SND_PSG; } /* Cookie STFA present ? */ - if (Getcookie (C_STFA, (long *) &cookie_stfa) != C_FOUND) { - DEBUG_PRINT ((DEBUG_NAME "no STFA audio\n")); + if (Getcookie(C_STFA, (long *) &cookie_stfa) != C_FOUND) { + DEBUG_PRINT((DEBUG_NAME "no STFA audio\n")); return (0); } SDL_MintAudio_stfa = cookie_stfa; - DEBUG_PRINT ((DEBUG_NAME "STFA audio available!\n")); + DEBUG_PRINT((DEBUG_NAME "STFA audio available!\n")); return (1); } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = Mint_OpenAudio; @@ -159,36 +159,36 @@ }; static void -Mint_LockAudio (_THIS) +Mint_LockAudio(_THIS) { void *oldpile; /* Stop replay */ - oldpile = (void *) Super (0); + oldpile = (void *) Super(0); cookie_stfa->sound_enable = STFA_PLAY_DISABLE; - Super (oldpile); + Super(oldpile); } static void -Mint_UnlockAudio (_THIS) +Mint_UnlockAudio(_THIS) { void *oldpile; /* Restart replay */ - oldpile = (void *) Super (0); + oldpile = (void *) Super(0); cookie_stfa->sound_enable = STFA_PLAY_ENABLE | STFA_PLAY_REPEAT; - Super (oldpile); + Super(oldpile); } static void -Mint_CloseAudio (_THIS) +Mint_CloseAudio(_THIS) { void *oldpile; /* Stop replay */ - oldpile = (void *) Super (0); + oldpile = (void *) Super(0); cookie_stfa->sound_enable = STFA_PLAY_DISABLE; - Super (oldpile); + Super(oldpile); /* Wait if currently playing sound */ while (SDL_MintAudio_mutex != 0) { @@ -196,58 +196,58 @@ /* Clear buffers */ if (SDL_MintAudio_audiobuf[0]) { - Mfree (SDL_MintAudio_audiobuf[0]); + Mfree(SDL_MintAudio_audiobuf[0]); SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; } } static int -Mint_CheckAudio (_THIS, SDL_AudioSpec * spec) +Mint_CheckAudio(_THIS, SDL_AudioSpec * spec) { int i; - DEBUG_PRINT ((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff)); - DEBUG_PRINT (("signed=%d, ", ((spec->format & 0x8000) != 0))); - DEBUG_PRINT (("big endian=%d, ", ((spec->format & 0x1000) != 0))); - DEBUG_PRINT (("channels=%d, ", spec->channels)); - DEBUG_PRINT (("freq=%d\n", spec->freq)); + DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff)); + DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); + DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); + DEBUG_PRINT(("channels=%d, ", spec->channels)); + DEBUG_PRINT(("freq=%d\n", spec->freq)); /* Check formats available */ MINTAUDIO_freqcount = 0; for (i = 0; i < 16; i++) { - SDL_MintAudio_AddFrequency (this, freqs[i], 0, i, -1); + SDL_MintAudio_AddFrequency(this, freqs[i], 0, i, -1); } #if 1 for (i = 0; i < MINTAUDIO_freqcount; i++) { - DEBUG_PRINT ((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n", - i, MINTAUDIO_frequencies[i].frequency, - MINTAUDIO_frequencies[i].masterclock, - MINTAUDIO_frequencies[i].predivisor)); + DEBUG_PRINT((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n", + i, MINTAUDIO_frequencies[i].frequency, + MINTAUDIO_frequencies[i].masterclock, + MINTAUDIO_frequencies[i].predivisor)); } #endif - MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency (this, spec->freq); + MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq); spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; - DEBUG_PRINT ((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff)); - DEBUG_PRINT (("signed=%d, ", ((spec->format & 0x8000) != 0))); - DEBUG_PRINT (("big endian=%d, ", ((spec->format & 0x1000) != 0))); - DEBUG_PRINT (("channels=%d, ", spec->channels)); - DEBUG_PRINT (("freq=%d\n", spec->freq)); + DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff)); + DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); + DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); + DEBUG_PRINT(("channels=%d, ", spec->channels)); + DEBUG_PRINT(("freq=%d\n", spec->freq)); return 0; } static void -Mint_InitAudio (_THIS, SDL_AudioSpec * spec) +Mint_InitAudio(_THIS, SDL_AudioSpec * spec) { void *buffer; void *oldpile; buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; - oldpile = (void *) Super (0); + oldpile = (void *) Super(0); /* Stop replay */ cookie_stfa->sound_enable = STFA_PLAY_DISABLE; @@ -286,44 +286,44 @@ /* Restart replay */ cookie_stfa->sound_enable = STFA_PLAY_ENABLE | STFA_PLAY_REPEAT; - Super (oldpile); + Super(oldpile); - DEBUG_PRINT ((DEBUG_NAME "hardware initialized\n")); + DEBUG_PRINT((DEBUG_NAME "hardware initialized\n")); } static int -Mint_OpenAudio (_THIS, SDL_AudioSpec * spec) +Mint_OpenAudio(_THIS, SDL_AudioSpec * spec) { SDL_MintAudio_device = this; /* Check audio capabilities */ - if (Mint_CheckAudio (this, spec) == -1) { + if (Mint_CheckAudio(this, spec) == -1) { return -1; } - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Allocate memory for audio buffers in DMA-able RAM */ - DEBUG_PRINT ((DEBUG_NAME "buffer size=%d\n", spec->size)); + DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", spec->size)); - SDL_MintAudio_audiobuf[0] = Atari_SysMalloc (spec->size * 2, MX_STRAM); + SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(spec->size * 2, MX_STRAM); if (SDL_MintAudio_audiobuf[0] == NULL) { - SDL_SetError ("MINT_OpenAudio: Not enough memory for audio buffer"); + SDL_SetError("MINT_OpenAudio: Not enough memory for audio buffer"); return (-1); } SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size; SDL_MintAudio_numbuf = 0; - SDL_memset (SDL_MintAudio_audiobuf[0], spec->silence, spec->size * 2); + SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size * 2); SDL_MintAudio_audiosize = spec->size; SDL_MintAudio_mutex = 0; - DEBUG_PRINT ((DEBUG_NAME "buffer 0 at 0x%08x\n", - SDL_MintAudio_audiobuf[0])); - DEBUG_PRINT ((DEBUG_NAME "buffer 1 at 0x%08x\n", - SDL_MintAudio_audiobuf[1])); + DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", + SDL_MintAudio_audiobuf[0])); + DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", + SDL_MintAudio_audiobuf[1])); /* Setup audio hardware */ - Mint_InitAudio (this, spec); + Mint_InitAudio(this, spec); return (1); /* We don't use threaded audio */ } diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/mint/SDL_mintaudio_xbios.c --- a/src/audio/mint/SDL_mintaudio_xbios.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/mint/SDL_mintaudio_xbios.c Mon May 29 04:04:35 2006 +0000 @@ -66,86 +66,86 @@ /*--- Audio driver functions ---*/ -static void Mint_CloseAudio (_THIS); -static int Mint_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void Mint_LockAudio (_THIS); -static void Mint_UnlockAudio (_THIS); +static void Mint_CloseAudio(_THIS); +static int Mint_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void Mint_LockAudio(_THIS); +static void Mint_UnlockAudio(_THIS); /* To check/init hardware audio */ -static int Mint_CheckAudio (_THIS, SDL_AudioSpec * spec); -static void Mint_InitAudio (_THIS, SDL_AudioSpec * spec); +static int Mint_CheckAudio(_THIS, SDL_AudioSpec * spec); +static void Mint_InitAudio(_THIS, SDL_AudioSpec * spec); /*--- Audio driver bootstrap functions ---*/ static int -Audio_Available (void) +Audio_Available(void) { unsigned long dummy; - const char *envr = SDL_getenv ("SDL_AUDIODRIVER"); + const char *envr = SDL_getenv("SDL_AUDIODRIVER"); - SDL_MintAudio_mint_present = (Getcookie (C_MiNT, &dummy) == C_FOUND); + SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); /* We can't use XBIOS in interrupt with Magic, don't know about thread */ - if (Getcookie (C_MagX, &dummy) == C_FOUND) { + if (Getcookie(C_MagX, &dummy) == C_FOUND) { return (0); } /* Check if user asked a different audio driver */ - if ((envr) && (SDL_strcmp (envr, MINT_AUDIO_DRIVER_NAME) != 0)) { - DEBUG_PRINT ((DEBUG_NAME "user asked a different audio driver\n")); + if ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME) != 0)) { + DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\n")); return (0); } /* Cookie _SND present ? if not, assume ST machine */ - if (Getcookie (C__SND, &cookie_snd) == C_NOTFOUND) { + if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { cookie_snd = SND_PSG; } /* Check if we have 16 bits audio */ if ((cookie_snd & SND_16BIT) == 0) { - DEBUG_PRINT ((DEBUG_NAME "no 16 bits sound\n")); + DEBUG_PRINT((DEBUG_NAME "no 16 bits sound\n")); return (0); } /* Check if audio is lockable */ - if (Locksnd () != 1) { - DEBUG_PRINT ((DEBUG_NAME "audio locked by other application\n")); + if (Locksnd() != 1) { + DEBUG_PRINT((DEBUG_NAME "audio locked by other application\n")); return (0); } - Unlocksnd (); + Unlocksnd(); - DEBUG_PRINT ((DEBUG_NAME "XBIOS audio available!\n")); + DEBUG_PRINT((DEBUG_NAME "XBIOS audio available!\n")); return (1); } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = Mint_OpenAudio; @@ -163,29 +163,29 @@ }; static void -Mint_LockAudio (_THIS) +Mint_LockAudio(_THIS) { /* Stop replay */ - Buffoper (0); + Buffoper(0); } static void -Mint_UnlockAudio (_THIS) +Mint_UnlockAudio(_THIS) { /* Restart replay */ - Buffoper (SB_PLA_ENA | SB_PLA_RPT); + Buffoper(SB_PLA_ENA | SB_PLA_RPT); } static void -Mint_CloseAudio (_THIS) +Mint_CloseAudio(_THIS) { /* Stop replay */ - SDL_MintAudio_WaitThread (); - Buffoper (0); + SDL_MintAudio_WaitThread(); + Buffoper(0); if (!SDL_MintAudio_mint_present) { /* Uninstall interrupt */ - Jdisint (MFP_DMASOUND); + Jdisint(MFP_DMASOUND); } /* Wait if currently playing sound */ @@ -194,17 +194,17 @@ /* Clear buffers */ if (SDL_MintAudio_audiobuf[0]) { - Mfree (SDL_MintAudio_audiobuf[0]); + Mfree(SDL_MintAudio_audiobuf[0]); SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; } /* Unlock sound system */ - Unlocksnd (); + Unlocksnd(); } /* Falcon XBIOS implementation of Devconnect() is buggy with external clock */ static void -Devconnect2 (int src, int dst, int sclk, int pre) +Devconnect2(int src, int dst, int sclk, int pre) { static const unsigned short MASK1[3] = { 0, 0x6000, 0 }; static const unsigned short MASK2[4] = { 0xFFF0, 0xFF8F, 0xF0FF, 0x0FFF }; @@ -217,7 +217,7 @@ return; } - oldstack = (void *) Super (0); + oldstack = (void *) Super(0); dev_ctrl = DMAAUDIO_IO.dev_ctrl; dest_ctrl = DMAAUDIO_IO.dest_ctrl; @@ -264,11 +264,11 @@ DMAAUDIO_IO.dest_ctrl = dest_ctrl; DMAAUDIO_IO.sync_div = sync_div; - Super (oldstack); + Super(oldstack); } static void -Mint_CheckExternalClock (_THIS) +Mint_CheckExternalClock(_THIS) { #define SIZE_BUF_CLOCK_MEASURE (44100/10) @@ -277,93 +277,93 @@ int i, j; /* DSP present with its GPIO port ? */ - if (Getcookie (C__SND, &cookie_snd) == C_NOTFOUND) { + if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { return; } if ((cookie_snd & SND_DSP) == 0) { return; } - buffer = Atari_SysMalloc (SIZE_BUF_CLOCK_MEASURE, MX_STRAM); + buffer = Atari_SysMalloc(SIZE_BUF_CLOCK_MEASURE, MX_STRAM); if (buffer == NULL) { - DEBUG_PRINT ((DEBUG_NAME "Not enough memory for the measure\n")); + DEBUG_PRINT((DEBUG_NAME "Not enough memory for the measure\n")); return; } - SDL_memset (buffer, 0, SIZE_BUF_CLOCK_MEASURE); + SDL_memset(buffer, 0, SIZE_BUF_CLOCK_MEASURE); - Buffoper (0); - Settracks (0, 0); - Setmontracks (0); - Setmode (MONO8); - Jdisint (MFP_TIMERA); + Buffoper(0); + Settracks(0, 0); + Setmontracks(0); + Setmode(MONO8); + Jdisint(MFP_TIMERA); for (i = 0; i < 2; i++) { - Gpio (GPIO_SET, 7); /* DSP port gpio outputs */ - Gpio (GPIO_WRITE, 2 + i); /* 22.5792/24.576 MHz for 44.1/48KHz */ - Devconnect2 (DMAPLAY, DAC, CLKEXT, CLK50K); /* Matrix and clock source */ - Setbuffer (0, buffer, buffer + SIZE_BUF_CLOCK_MEASURE); /* Set buffer */ - Xbtimer (XB_TIMERA, 5, 38, SDL_MintAudio_XbiosInterruptMeasureClock); /* delay mode timer A, prediv /64, 1KHz */ - Jenabint (MFP_TIMERA); + Gpio(GPIO_SET, 7); /* DSP port gpio outputs */ + Gpio(GPIO_WRITE, 2 + i); /* 22.5792/24.576 MHz for 44.1/48KHz */ + Devconnect2(DMAPLAY, DAC, CLKEXT, CLK50K); /* Matrix and clock source */ + Setbuffer(0, buffer, buffer + SIZE_BUF_CLOCK_MEASURE); /* Set buffer */ + Xbtimer(XB_TIMERA, 5, 38, SDL_MintAudio_XbiosInterruptMeasureClock); /* delay mode timer A, prediv /64, 1KHz */ + Jenabint(MFP_TIMERA); SDL_MintAudio_clocktics = 0; - Buffoper (SB_PLA_ENA); - usleep (110000); + Buffoper(SB_PLA_ENA); + usleep(110000); - if ((Buffoper (-1) & 1) == 0) { + if ((Buffoper(-1) & 1) == 0) { if (SDL_MintAudio_clocktics) { unsigned long khz; khz = ((SIZE_BUF_CLOCK_MEASURE / SDL_MintAudio_clocktics) + 1) & 0xFFFFFFFE; - DEBUG_PRINT ((DEBUG_NAME "measure %d: freq=%lu KHz\n", - i + 1, khz)); + DEBUG_PRINT((DEBUG_NAME "measure %d: freq=%lu KHz\n", + i + 1, khz)); if (khz == 44) { for (j = 1; j < 4; j++) { - SDL_MintAudio_AddFrequency (this, - MASTERCLOCK_44K - / - (MASTERPREDIV_FALCON - * (1 << j)), - MASTERCLOCK_44K, - (1 << j) - 1, 2 + i); + SDL_MintAudio_AddFrequency(this, + MASTERCLOCK_44K + / + (MASTERPREDIV_FALCON + * (1 << j)), + MASTERCLOCK_44K, + (1 << j) - 1, 2 + i); } } else if (khz == 48) { for (j = 1; j < 4; j++) { - SDL_MintAudio_AddFrequency (this, - MASTERCLOCK_48K - / - (MASTERPREDIV_FALCON - * (1 << j)), - MASTERCLOCK_48K, - (1 << j) - 1, 2 + i); + SDL_MintAudio_AddFrequency(this, + MASTERCLOCK_48K + / + (MASTERPREDIV_FALCON + * (1 << j)), + MASTERCLOCK_48K, + (1 << j) - 1, 2 + i); } } } else { - DEBUG_PRINT ((DEBUG_NAME "No measure\n")); + DEBUG_PRINT((DEBUG_NAME "No measure\n")); } } else { - DEBUG_PRINT ((DEBUG_NAME "No SDMA clock\n")); + DEBUG_PRINT((DEBUG_NAME "No SDMA clock\n")); } - Buffoper (0); /* stop */ - Jdisint (MFP_TIMERA); /* Uninstall interrupt */ + Buffoper(0); /* stop */ + Jdisint(MFP_TIMERA); /* Uninstall interrupt */ } - Mfree (buffer); + Mfree(buffer); } static int -Mint_CheckAudio (_THIS, SDL_AudioSpec * spec) +Mint_CheckAudio(_THIS, SDL_AudioSpec * spec) { int i; Uint32 extclock; - DEBUG_PRINT ((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff)); - DEBUG_PRINT (("signed=%d, ", ((spec->format & 0x8000) != 0))); - DEBUG_PRINT (("big endian=%d, ", ((spec->format & 0x1000) != 0))); - DEBUG_PRINT (("channels=%d, ", spec->channels)); - DEBUG_PRINT (("freq=%d\n", spec->freq)); + DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff)); + DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); + DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); + DEBUG_PRINT(("channels=%d, ", spec->channels)); + DEBUG_PRINT(("freq=%d\n", spec->freq)); spec->format |= 0x8000; /* Audio is always signed */ if ((spec->format & 0x00ff) == 16) { @@ -374,7 +374,7 @@ MINTAUDIO_freqcount = 0; /* Add external clocks if present */ - Mint_CheckExternalClock (this); + Mint_CheckExternalClock(this); /* Standard clocks */ for (i = 1; i < 12; i++) { @@ -382,35 +382,35 @@ if ((i == 6) || (i == 8) || (i == 10)) { continue; } - SDL_MintAudio_AddFrequency (this, - MASTERCLOCK_FALCON1 / - (MASTERPREDIV_FALCON * (i + 1)), - MASTERCLOCK_FALCON1, i, -1); + SDL_MintAudio_AddFrequency(this, + MASTERCLOCK_FALCON1 / + (MASTERPREDIV_FALCON * (i + 1)), + MASTERCLOCK_FALCON1, i, -1); } #if 1 for (i = 0; i < MINTAUDIO_freqcount; i++) { - DEBUG_PRINT ((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n", - i, MINTAUDIO_frequencies[i].frequency, - MINTAUDIO_frequencies[i].masterclock, - MINTAUDIO_frequencies[i].predivisor)); + DEBUG_PRINT((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n", + i, MINTAUDIO_frequencies[i].frequency, + MINTAUDIO_frequencies[i].masterclock, + MINTAUDIO_frequencies[i].predivisor)); } #endif - MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency (this, spec->freq); + MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq); spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; - DEBUG_PRINT ((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff)); - DEBUG_PRINT (("signed=%d, ", ((spec->format & 0x8000) != 0))); - DEBUG_PRINT (("big endian=%d, ", ((spec->format & 0x1000) != 0))); - DEBUG_PRINT (("channels=%d, ", spec->channels)); - DEBUG_PRINT (("freq=%d\n", spec->freq)); + DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff)); + DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); + DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); + DEBUG_PRINT(("channels=%d, ", spec->channels)); + DEBUG_PRINT(("freq=%d\n", spec->freq)); return 0; } static void -Mint_InitAudio (_THIS, SDL_AudioSpec * spec) +Mint_InitAudio(_THIS, SDL_AudioSpec * spec) { int channels_mode, dmaclock, prediv; void *buffer; @@ -418,12 +418,12 @@ /* Stop currently playing sound */ SDL_MintAudio_quit_thread = SDL_FALSE; SDL_MintAudio_thread_finished = SDL_TRUE; - SDL_MintAudio_WaitThread (); - Buffoper (0); + SDL_MintAudio_WaitThread(); + Buffoper(0); /* Set replay tracks */ - Settracks (0, 0); - Setmontracks (0); + Settracks(0, 0); + Setmontracks(0); /* Select replay format */ channels_mode = STEREO16; @@ -436,83 +436,83 @@ } break; } - if (Setmode (channels_mode) < 0) { - DEBUG_PRINT ((DEBUG_NAME "Setmode() failed\n")); + if (Setmode(channels_mode) < 0) { + DEBUG_PRINT((DEBUG_NAME "Setmode() failed\n")); } dmaclock = MINTAUDIO_frequencies[MINTAUDIO_numfreq].masterclock; prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor; if (MINTAUDIO_frequencies[MINTAUDIO_numfreq].gpio_bits != -1) { - Gpio (GPIO_SET, 7); /* DSP port gpio outputs */ - Gpio (GPIO_WRITE, MINTAUDIO_frequencies[MINTAUDIO_numfreq].gpio_bits); - Devconnect2 (DMAPLAY, DAC | EXTOUT, CLKEXT, prediv); + Gpio(GPIO_SET, 7); /* DSP port gpio outputs */ + Gpio(GPIO_WRITE, MINTAUDIO_frequencies[MINTAUDIO_numfreq].gpio_bits); + Devconnect2(DMAPLAY, DAC | EXTOUT, CLKEXT, prediv); } else { - Devconnect2 (DMAPLAY, DAC, CLK25M, prediv); + Devconnect2(DMAPLAY, DAC, CLK25M, prediv); } /* Set buffer */ buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; - if (Setbuffer (0, buffer, buffer + spec->size) < 0) { - DEBUG_PRINT ((DEBUG_NAME "Setbuffer() failed\n")); + if (Setbuffer(0, buffer, buffer + spec->size) < 0) { + DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n")); } if (SDL_MintAudio_mint_present) { - SDL_MintAudio_thread_pid = tfork (SDL_MintAudio_Thread, 0); + SDL_MintAudio_thread_pid = tfork(SDL_MintAudio_Thread, 0); } else { /* Install interrupt */ - Jdisint (MFP_DMASOUND); - Xbtimer (XB_TIMERA, 8, 1, SDL_MintAudio_XbiosInterrupt); - Jenabint (MFP_DMASOUND); + Jdisint(MFP_DMASOUND); + Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_XbiosInterrupt); + Jenabint(MFP_DMASOUND); - if (Setinterrupt (SI_TIMERA, SI_PLAY) < 0) { - DEBUG_PRINT ((DEBUG_NAME "Setinterrupt() failed\n")); + if (Setinterrupt(SI_TIMERA, SI_PLAY) < 0) { + DEBUG_PRINT((DEBUG_NAME "Setinterrupt() failed\n")); } } /* Go */ - Buffoper (SB_PLA_ENA | SB_PLA_RPT); - DEBUG_PRINT ((DEBUG_NAME "hardware initialized\n")); + Buffoper(SB_PLA_ENA | SB_PLA_RPT); + DEBUG_PRINT((DEBUG_NAME "hardware initialized\n")); } static int -Mint_OpenAudio (_THIS, SDL_AudioSpec * spec) +Mint_OpenAudio(_THIS, SDL_AudioSpec * spec) { /* Lock sound system */ - if (Locksnd () != 1) { - SDL_SetError ("Mint_OpenAudio: Audio system already in use"); + if (Locksnd() != 1) { + SDL_SetError("Mint_OpenAudio: Audio system already in use"); return (-1); } SDL_MintAudio_device = this; /* Check audio capabilities */ - if (Mint_CheckAudio (this, spec) == -1) { + if (Mint_CheckAudio(this, spec) == -1) { return -1; } - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Allocate memory for audio buffers in DMA-able RAM */ - DEBUG_PRINT ((DEBUG_NAME "buffer size=%d\n", spec->size)); + DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", spec->size)); - SDL_MintAudio_audiobuf[0] = Atari_SysMalloc (spec->size * 2, MX_STRAM); + SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(spec->size * 2, MX_STRAM); if (SDL_MintAudio_audiobuf[0] == NULL) { - SDL_SetError ("MINT_OpenAudio: Not enough memory for audio buffer"); + SDL_SetError("MINT_OpenAudio: Not enough memory for audio buffer"); return (-1); } SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size; SDL_MintAudio_numbuf = 0; - SDL_memset (SDL_MintAudio_audiobuf[0], spec->silence, spec->size * 2); + SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size * 2); SDL_MintAudio_audiosize = spec->size; SDL_MintAudio_mutex = 0; - DEBUG_PRINT ((DEBUG_NAME "buffer 0 at 0x%08x\n", - SDL_MintAudio_audiobuf[0])); - DEBUG_PRINT ((DEBUG_NAME "buffer 1 at 0x%08x\n", - SDL_MintAudio_audiobuf[1])); + DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", + SDL_MintAudio_audiobuf[0])); + DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", + SDL_MintAudio_audiobuf[1])); /* Setup audio hardware */ - Mint_InitAudio (this, spec); + Mint_InitAudio(this, spec); return (1); /* We don't use SDL threaded audio */ } diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/mme/SDL_mmeaudio.c --- a/src/audio/mme/SDL_mmeaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/mme/SDL_mmeaudio.c Mon May 29 04:04:35 2006 +0000 @@ -32,52 +32,52 @@ static BOOL inUse[NUM_BUFFERS]; /* Audio driver functions */ -static int MME_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void MME_WaitAudio (_THIS); -static Uint8 *MME_GetAudioBuf (_THIS); -static void MME_PlayAudio (_THIS); -static void MME_WaitDone (_THIS); -static void MME_CloseAudio (_THIS); +static int MME_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void MME_WaitAudio(_THIS); +static Uint8 *MME_GetAudioBuf(_THIS); +static void MME_PlayAudio(_THIS); +static void MME_WaitDone(_THIS); +static void MME_CloseAudio(_THIS); /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { return (1); } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { if (device) { if (device->hidden) { - SDL_free (device->hidden); + SDL_free(device->hidden); device->hidden = NULL; } - SDL_free (device); + SDL_free(device); device = NULL; } } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = SDL_malloc (sizeof (SDL_AudioDevice)); + this = SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); - this->hidden = SDL_malloc ((sizeof *this->hidden)); + SDL_memset(this, 0, (sizeof *this)); + this->hidden = SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = MME_OpenAudio; this->WaitAudio = MME_WaitAudio; @@ -96,20 +96,20 @@ }; static void -SetMMerror (char *function, MMRESULT code) +SetMMerror(char *function, MMRESULT code) { int len; char errbuf[MAXERRORLENGTH]; - SDL_snprintf (errbuf, SDL_arraysize (errbuf), "%s: ", function); - len = SDL_strlen (errbuf); - waveOutGetErrorText (code, errbuf + len, MAXERRORLENGTH - len); - SDL_SetError ("%s", errbuf); + SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function); + len = SDL_strlen(errbuf); + waveOutGetErrorText(code, errbuf + len, MAXERRORLENGTH - len); + SDL_SetError("%s", errbuf); } static void CALLBACK -MME_CALLBACK (HWAVEOUT hwo, - UINT uMsg, DWORD dwInstance, LPARAM dwParam1, LPARAM dwParam2) +MME_CALLBACK(HWAVEOUT hwo, + UINT uMsg, DWORD dwInstance, LPARAM dwParam1, LPARAM dwParam2) { WAVEHDR *wp = (WAVEHDR *) dwParam1; @@ -118,7 +118,7 @@ } static int -MME_OpenAudio (_THIS, SDL_AudioSpec * spec) +MME_OpenAudio(_THIS, SDL_AudioSpec * spec) { MMRESULT result; int i; @@ -126,9 +126,9 @@ mixbuf = NULL; /* Set basic WAVE format parameters */ - shm = mmeAllocMem (sizeof (*shm)); + shm = mmeAllocMem(sizeof(*shm)); if (shm == NULL) { - SDL_SetError ("Out of memory: shm"); + SDL_SetError("Out of memory: shm"); return (-1); } shm->sound = 0; @@ -147,7 +147,7 @@ shm->wFmt.wBitsPerSample = 16; break; default: - SDL_SetError ("Unsupported audio format"); + SDL_SetError("Unsupported audio format"); return (-1); } @@ -163,23 +163,23 @@ spec->samples = ((spec->freq / 4) + 3) & ~3; /* Update the fragment size as size in bytes */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Open the audio device */ - result = waveOutOpen (&(shm->sound), - WAVE_MAPPER, - &(shm->wFmt.wf), - MME_CALLBACK, - NULL, (CALLBACK_FUNCTION | WAVE_OPEN_SHAREABLE)); + result = waveOutOpen(&(shm->sound), + WAVE_MAPPER, + &(shm->wFmt.wf), + MME_CALLBACK, + NULL, (CALLBACK_FUNCTION | WAVE_OPEN_SHAREABLE)); if (result != MMSYSERR_NOERROR) { - SetMMerror ("waveOutOpen()", result); + SetMMerror("waveOutOpen()", result); return (-1); } /* Create the sound buffers */ - mixbuf = (Uint8 *) mmeAllocBuffer (NUM_BUFFERS * (spec->size)); + mixbuf = (Uint8 *) mmeAllocBuffer(NUM_BUFFERS * (spec->size)); if (mixbuf == NULL) { - SDL_SetError ("Out of memory: mixbuf"); + SDL_SetError("Out of memory: mixbuf"); return (-1); } @@ -198,16 +198,16 @@ } static void -MME_WaitAudio (_THIS) +MME_WaitAudio(_THIS) { while (inUse[next_buffer]) { - mmeWaitForCallbacks (); - mmeProcessCallbacks (); + mmeWaitForCallbacks(); + mmeProcessCallbacks(); } } static Uint8 * -MME_GetAudioBuf (_THIS) +MME_GetAudioBuf(_THIS) { Uint8 *retval; @@ -217,15 +217,15 @@ } static void -MME_PlayAudio (_THIS) +MME_PlayAudio(_THIS) { /* Queue it up */ - waveOutWrite (shm->sound, &(shm->wHdr[next_buffer]), sizeof (WAVEHDR)); + waveOutWrite(shm->sound, &(shm->wHdr[next_buffer]), sizeof(WAVEHDR)); next_buffer = (next_buffer + 1) % NUM_BUFFERS; } static void -MME_WaitDone (_THIS) +MME_WaitDone(_THIS) { MMRESULT result; int i; @@ -233,38 +233,38 @@ if (shm->sound) { for (i = 0; i < NUM_BUFFERS; i++) while (inUse[i]) { - mmeWaitForCallbacks (); - mmeProcessCallbacks (); + mmeWaitForCallbacks(); + mmeProcessCallbacks(); } - result = waveOutReset (shm->sound); + result = waveOutReset(shm->sound); if (result != MMSYSERR_NOERROR) - SetMMerror ("waveOutReset()", result); - mmeProcessCallbacks (); + SetMMerror("waveOutReset()", result); + mmeProcessCallbacks(); } } static void -MME_CloseAudio (_THIS) +MME_CloseAudio(_THIS) { MMRESULT result; if (mixbuf) { - result = mmeFreeBuffer (mixbuf); + result = mmeFreeBuffer(mixbuf); if (result != MMSYSERR_NOERROR) - SetMMerror ("mmeFreeBuffer", result); + SetMMerror("mmeFreeBuffer", result); mixbuf = NULL; } if (shm) { if (shm->sound) { - result = waveOutClose (shm->sound); + result = waveOutClose(shm->sound); if (result != MMSYSERR_NOERROR) - SetMMerror ("waveOutClose()", result); - mmeProcessCallbacks (); + SetMMerror("waveOutClose()", result); + mmeProcessCallbacks(); } - result = mmeFreeMem (shm); + result = mmeFreeMem(shm); if (result != MMSYSERR_NOERROR) - SetMMerror ("mmeFreeMem()", result); + SetMMerror("mmeFreeMem()", result); shm = NULL; } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/nas/SDL_nasaudio.c --- a/src/audio/nas/SDL_nasaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/nas/SDL_nasaudio.c Mon May 29 04:04:35 2006 +0000 @@ -43,52 +43,52 @@ static struct SDL_PrivateAudioData *this2 = NULL; /* Audio driver functions */ -static int NAS_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void NAS_WaitAudio (_THIS); -static void NAS_PlayAudio (_THIS); -static Uint8 *NAS_GetAudioBuf (_THIS); -static void NAS_CloseAudio (_THIS); +static int NAS_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void NAS_WaitAudio(_THIS); +static void NAS_PlayAudio(_THIS); +static Uint8 *NAS_GetAudioBuf(_THIS); +static void NAS_CloseAudio(_THIS); /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { - AuServer *aud = AuOpenServer ("", 0, NULL, 0, NULL, NULL); + AuServer *aud = AuOpenServer("", 0, NULL, 0, NULL, NULL); if (!aud) return 0; - AuCloseServer (aud); + AuCloseServer(aud); return 1; } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = NAS_OpenAudio; @@ -109,60 +109,59 @@ /* This function waits until it is possible to write a full sound buffer */ static void -NAS_WaitAudio (_THIS) +NAS_WaitAudio(_THIS) { while (this->hidden->buf_free < this->hidden->mixlen) { AuEvent ev; - AuNextEvent (this->hidden->aud, AuTrue, &ev); - AuDispatchEvent (this->hidden->aud, &ev); + AuNextEvent(this->hidden->aud, AuTrue, &ev); + AuDispatchEvent(this->hidden->aud, &ev); } } static void -NAS_PlayAudio (_THIS) +NAS_PlayAudio(_THIS) { while (this->hidden->mixlen > this->hidden->buf_free) { /* We think the buffer is full? Yikes! Ask the server for events, in the hope that some of them is LowWater events telling us more of the buffer is free now than what we think. */ AuEvent ev; - AuNextEvent (this->hidden->aud, AuTrue, &ev); - AuDispatchEvent (this->hidden->aud, &ev); + AuNextEvent(this->hidden->aud, AuTrue, &ev); + AuDispatchEvent(this->hidden->aud, &ev); } this->hidden->buf_free -= this->hidden->mixlen; /* Write the audio data */ - AuWriteElement (this->hidden->aud, this->hidden->flow, 0, - this->hidden->mixlen, this->hidden->mixbuf, AuFalse, - NULL); + AuWriteElement(this->hidden->aud, this->hidden->flow, 0, + this->hidden->mixlen, this->hidden->mixbuf, AuFalse, NULL); this->hidden->written += this->hidden->mixlen; #ifdef DEBUG_AUDIO - fprintf (stderr, "Wrote %d bytes of audio data\n", this->hidden->mixlen); + fprintf(stderr, "Wrote %d bytes of audio data\n", this->hidden->mixlen); #endif } static Uint8 * -NAS_GetAudioBuf (_THIS) +NAS_GetAudioBuf(_THIS) { return (this->hidden->mixbuf); } static void -NAS_CloseAudio (_THIS) +NAS_CloseAudio(_THIS) { if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem (this->hidden->mixbuf); + SDL_FreeAudioMem(this->hidden->mixbuf); this->hidden->mixbuf = NULL; } if (this->hidden->aud) { - AuCloseServer (this->hidden->aud); + AuCloseServer(this->hidden->aud); this->hidden->aud = 0; } } static unsigned char -sdlformat_to_auformat (unsigned int fmt) +sdlformat_to_auformat(unsigned int fmt) { switch (fmt) { case AUDIO_U8: @@ -182,7 +181,7 @@ } static AuBool -event_handler (AuServer * aud, AuEvent * ev, AuEventHandlerRec * hnd) +event_handler(AuServer * aud, AuEvent * ev, AuEventHandlerRec * hnd) { switch (ev->type) { case AuEventTypeElementNotify: @@ -193,7 +192,7 @@ case AuElementNotifyKindLowWater: if (this2->buf_free >= 0) { this2->really += event->num_bytes; - gettimeofday (&this2->last_tv, 0); + gettimeofday(&this2->last_tv, 0); this2->buf_free += event->num_bytes; } else { this2->buf_free = event->num_bytes; @@ -205,7 +204,7 @@ if (event->reason != AuReasonUser) { if (this2->buf_free >= 0) { this2->really += event->num_bytes; - gettimeofday (&this2->last_tv, 0); + gettimeofday(&this2->last_tv, 0); this2->buf_free += event->num_bytes; } else { this2->buf_free = event->num_bytes; @@ -220,22 +219,21 @@ } static AuDeviceID -find_device (_THIS, int nch) +find_device(_THIS, int nch) { int i; - for (i = 0; i < AuServerNumDevices (this->hidden->aud); i++) { - if ((AuDeviceKind (AuServerDevice (this->hidden->aud, i)) == + for (i = 0; i < AuServerNumDevices(this->hidden->aud); i++) { + if ((AuDeviceKind(AuServerDevice(this->hidden->aud, i)) == AuComponentKindPhysicalOutput) && - AuDeviceNumTracks (AuServerDevice (this->hidden->aud, i)) == - nch) { - return AuDeviceIdentifier (AuServerDevice (this->hidden->aud, i)); + AuDeviceNumTracks(AuServerDevice(this->hidden->aud, i)) == nch) { + return AuDeviceIdentifier(AuServerDevice(this->hidden->aud, i)); } } return AuNone; } static int -NAS_OpenAudio (_THIS, SDL_AudioSpec * spec) +NAS_OpenAudio(_THIS, SDL_AudioSpec * spec) { AuElement elms[3]; int buffer_size; @@ -245,33 +243,32 @@ /* Try for a closest match on audio format */ format = 0; - for (test_format = SDL_FirstAudioFormat (spec->format); + for (test_format = SDL_FirstAudioFormat(spec->format); !format && test_format;) { - format = sdlformat_to_auformat (test_format); + format = sdlformat_to_auformat(test_format); if (format == AuNone) { - test_format = SDL_NextAudioFormat (); + test_format = SDL_NextAudioFormat(); } } if (format == 0) { - SDL_SetError ("Couldn't find any hardware audio formats"); + SDL_SetError("Couldn't find any hardware audio formats"); return (-1); } spec->format = test_format; - this->hidden->aud = AuOpenServer ("", 0, NULL, 0, NULL, NULL); + this->hidden->aud = AuOpenServer("", 0, NULL, 0, NULL, NULL); if (this->hidden->aud == 0) { - SDL_SetError ("Couldn't open connection to NAS server"); + SDL_SetError("Couldn't open connection to NAS server"); return (-1); } - this->hidden->dev = find_device (this, spec->channels); + this->hidden->dev = find_device(this, spec->channels); if ((this->hidden->dev == AuNone) - || (!(this->hidden->flow = AuCreateFlow (this->hidden->aud, NULL)))) { - AuCloseServer (this->hidden->aud); + || (!(this->hidden->flow = AuCreateFlow(this->hidden->aud, NULL)))) { + AuCloseServer(this->hidden->aud); this->hidden->aud = 0; - SDL_SetError - ("Couldn't find a fitting playback device on NAS server"); + SDL_SetError("Couldn't find a fitting playback device on NAS server"); return (-1); } @@ -283,32 +280,32 @@ buffer_size = 32768; /* So that the buffer won't get unmanageably big. */ /* Calculate the final parameters for this audio specification */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); this2 = this->hidden; - AuMakeElementImportClient (elms, spec->freq, format, spec->channels, - AuTrue, buffer_size, buffer_size / 4, 0, NULL); - AuMakeElementExportDevice (elms + 1, 0, this->hidden->dev, spec->freq, - AuUnlimitedSamples, 0, NULL); - AuSetElements (this->hidden->aud, this->hidden->flow, AuTrue, 2, elms, - NULL); - AuRegisterEventHandler (this->hidden->aud, AuEventHandlerIDMask, 0, - this->hidden->flow, event_handler, - (AuPointer) NULL); + AuMakeElementImportClient(elms, spec->freq, format, spec->channels, + AuTrue, buffer_size, buffer_size / 4, 0, NULL); + AuMakeElementExportDevice(elms + 1, 0, this->hidden->dev, spec->freq, + AuUnlimitedSamples, 0, NULL); + AuSetElements(this->hidden->aud, this->hidden->flow, AuTrue, 2, elms, + NULL); + AuRegisterEventHandler(this->hidden->aud, AuEventHandlerIDMask, 0, + this->hidden->flow, event_handler, + (AuPointer) NULL); - AuStartFlow (this->hidden->aud, this->hidden->flow, NULL); + AuStartFlow(this->hidden->aud, this->hidden->flow, NULL); /* Allocate mixing buffer */ this->hidden->mixlen = spec->size; - this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem (this->hidden->mixlen); + this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen); if (this->hidden->mixbuf == NULL) { return (-1); } - SDL_memset (this->hidden->mixbuf, spec->silence, spec->size); + SDL_memset(this->hidden->mixbuf, spec->silence, spec->size); /* Get the parent process id (we're the parent of the audio thread) */ - this->hidden->parent = getpid (); + this->hidden->parent = getpid(); /* We're ready to rock and roll. :-) */ return (0); diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/nto/SDL_nto_audio.c --- a/src/audio/nto/SDL_nto_audio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/nto/SDL_nto_audio.c Mon May 29 04:04:35 2006 +0000 @@ -70,26 +70,26 @@ }; /* Audio driver functions */ -static void NTO_ThreadInit (_THIS); -static int NTO_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void NTO_WaitAudio (_THIS); -static void NTO_PlayAudio (_THIS); -static Uint8 *NTO_GetAudioBuf (_THIS); -static void NTO_CloseAudio (_THIS); +static void NTO_ThreadInit(_THIS); +static int NTO_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void NTO_WaitAudio(_THIS); +static void NTO_PlayAudio(_THIS); +static Uint8 *NTO_GetAudioBuf(_THIS); +static void NTO_CloseAudio(_THIS); /* card names check to apply the workarounds */ static int -NTO_CheckBuggyCards (_THIS, unsigned long checkfor) +NTO_CheckBuggyCards(_THIS, unsigned long checkfor) { char scardname[33]; int it; - if (snd_card_get_name (cardno, scardname, 32) < 0) { + if (snd_card_get_name(cardno, scardname, 32) < 0) { return 0; } for (it = 0; it < QSA_WA_CARDS; it++) { - if (SDL_strcmp (buggycards[it].cardname, scardname) == 0) { + if (SDL_strcmp(buggycards[it].cardname, scardname) == 0) { if (buggycards[it].bugtype == checkfor) { return 1; } @@ -100,22 +100,22 @@ } static void -NTO_ThreadInit (_THIS) +NTO_ThreadInit(_THIS) { int status; struct sched_param param; /* increasing default 10 priority to 25 to avoid jerky sound */ - status = SchedGet (0, 0, ¶m); + status = SchedGet(0, 0, ¶m); param.sched_priority = param.sched_curpriority + 15; - status = SchedSet (0, 0, SCHED_NOCHANGE, ¶m); + status = SchedSet(0, 0, SCHED_NOCHANGE, ¶m); } /* PCM transfer channel parameters initialize function */ static void -NTO_InitAudioParams (snd_pcm_channel_params_t * cpars) +NTO_InitAudioParams(snd_pcm_channel_params_t * cpars) { - SDL_memset (cpars, 0, sizeof (snd_pcm_channel_params_t)); + SDL_memset(cpars, 0, sizeof(snd_pcm_channel_params_t)); cpars->channel = SND_PCM_CHANNEL_PLAYBACK; cpars->mode = SND_PCM_MODE_BLOCK; @@ -131,7 +131,7 @@ } static int -NTO_AudioAvailable (void) +NTO_AudioAvailable(void) { /* See if we can open a nonblocking channel. Return value '1' means we can. @@ -144,15 +144,15 @@ available = 0; handle = NULL; - rval = snd_pcm_open_preferred (&handle, NULL, NULL, OPEN_FLAGS); + rval = snd_pcm_open_preferred(&handle, NULL, NULL, OPEN_FLAGS); if (rval >= 0) { available = 1; - if ((rval = snd_pcm_close (handle)) < 0) { + if ((rval = snd_pcm_close(handle)) < 0) { SDL_SetError ("NTO_AudioAvailable(): snd_pcm_close failed: %s\n", - snd_strerror (rval)); + snd_strerror(rval)); available = 0; } } else { @@ -164,36 +164,36 @@ } static void -NTO_DeleteAudioDevice (SDL_AudioDevice * device) +NTO_DeleteAudioDevice(SDL_AudioDevice * device) { if ((device) && (device->hidden)) { - SDL_free (device->hidden); + SDL_free(device->hidden); } if (device) { - SDL_free (device); + SDL_free(device); } } static SDL_AudioDevice * -NTO_CreateAudioDevice (int devindex) +NTO_CreateAudioDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, sizeof (SDL_AudioDevice)); + SDL_memset(this, 0, sizeof(SDL_AudioDevice)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc (sizeof (struct SDL_PrivateAudioData)); + SDL_malloc(sizeof(struct SDL_PrivateAudioData)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, sizeof (struct SDL_PrivateAudioData)); + SDL_memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData)); audio_handle = NULL; /* Set the function pointers */ @@ -217,24 +217,24 @@ /* This function waits until it is possible to write a full sound buffer */ static void -NTO_WaitAudio (_THIS) +NTO_WaitAudio(_THIS) { fd_set wfds; int selectret; - FD_ZERO (&wfds); - FD_SET (audio_fd, &wfds); + FD_ZERO(&wfds); + FD_SET(audio_fd, &wfds); do { - selectret = select (audio_fd + 1, NULL, &wfds, NULL, NULL); + selectret = select(audio_fd + 1, NULL, &wfds, NULL, NULL); switch (selectret) { case -1: case 0: - SDL_SetError ("NTO_WaitAudio(): select() failed: %s\n", - strerror (errno)); + SDL_SetError("NTO_WaitAudio(): select() failed: %s\n", + strerror(errno)); return; default: - if (FD_ISSET (audio_fd, &wfds)) { + if (FD_ISSET(audio_fd, &wfds)) { return; } break; @@ -244,7 +244,7 @@ } static void -NTO_PlayAudio (_THIS) +NTO_PlayAudio(_THIS) { int written, rval; int towrite; @@ -259,36 +259,35 @@ /* Write the audio data, checking for EAGAIN (buffer full) and underrun */ do { - written = snd_pcm_plugin_write (audio_handle, pcm_buf, towrite); + written = snd_pcm_plugin_write(audio_handle, pcm_buf, towrite); if (written != towrite) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) { /* Let a little CPU time go by and try to write again */ - SDL_Delay (1); + SDL_Delay(1); /* if we wrote some data */ towrite -= written; pcmbuffer += written * this->spec.channels; continue; } else { if ((errno == EINVAL) || (errno == EIO)) { - SDL_memset (&cstatus, 0, sizeof (cstatus)); + SDL_memset(&cstatus, 0, sizeof(cstatus)); cstatus.channel = SND_PCM_CHANNEL_PLAYBACK; if ((rval = - snd_pcm_plugin_status (audio_handle, - &cstatus)) < 0) { + snd_pcm_plugin_status(audio_handle, &cstatus)) < 0) { SDL_SetError ("NTO_PlayAudio(): snd_pcm_plugin_status failed: %s\n", - snd_strerror (rval)); + snd_strerror(rval)); return; } if ((cstatus.status == SND_PCM_STATUS_UNDERRUN) || (cstatus.status == SND_PCM_STATUS_READY)) { if ((rval = - snd_pcm_plugin_prepare (audio_handle, - SND_PCM_CHANNEL_PLAYBACK)) + snd_pcm_plugin_prepare(audio_handle, + SND_PCM_CHANNEL_PLAYBACK)) < 0) { SDL_SetError ("NTO_PlayAudio(): snd_pcm_plugin_prepare failed: %s\n", - snd_strerror (rval)); + snd_strerror(rval)); return; } } @@ -314,13 +313,13 @@ } static Uint8 * -NTO_GetAudioBuf (_THIS) +NTO_GetAudioBuf(_THIS) { return pcm_buf; } static void -NTO_CloseAudio (_THIS) +NTO_CloseAudio(_THIS) { int rval; @@ -328,16 +327,16 @@ if (audio_handle != NULL) { if ((rval = - snd_pcm_plugin_flush (audio_handle, - SND_PCM_CHANNEL_PLAYBACK)) < 0) { + snd_pcm_plugin_flush(audio_handle, + SND_PCM_CHANNEL_PLAYBACK)) < 0) { SDL_SetError ("NTO_CloseAudio(): snd_pcm_plugin_flush failed: %s\n", - snd_strerror (rval)); + snd_strerror(rval)); return; } - if ((rval = snd_pcm_close (audio_handle)) < 0) { - SDL_SetError ("NTO_CloseAudio(): snd_pcm_close failed: %s\n", - snd_strerror (rval)); + if ((rval = snd_pcm_close(audio_handle)) < 0) { + SDL_SetError("NTO_CloseAudio(): snd_pcm_close failed: %s\n", + snd_strerror(rval)); return; } audio_handle = NULL; @@ -345,7 +344,7 @@ } static int -NTO_OpenAudio (_THIS, SDL_AudioSpec * spec) +NTO_OpenAudio(_THIS, SDL_AudioSpec * spec) { int rval; int format; @@ -356,30 +355,29 @@ this->enabled = 0; if (pcm_buf != NULL) { - SDL_FreeAudioMem (pcm_buf); + SDL_FreeAudioMem(pcm_buf); pcm_buf = NULL; } /* initialize channel transfer parameters to default */ - NTO_InitAudioParams (&cparams); + NTO_InitAudioParams(&cparams); /* Open the audio device */ rval = - snd_pcm_open_preferred (&audio_handle, &cardno, &deviceno, - OPEN_FLAGS); + snd_pcm_open_preferred(&audio_handle, &cardno, &deviceno, OPEN_FLAGS); if (rval < 0) { - SDL_SetError ("NTO_OpenAudio(): snd_pcm_open failed: %s\n", - snd_strerror (rval)); + SDL_SetError("NTO_OpenAudio(): snd_pcm_open failed: %s\n", + snd_strerror(rval)); return (-1); } - if (!NTO_CheckBuggyCards (this, QSA_MMAP_WORKAROUND)) { + if (!NTO_CheckBuggyCards(this, QSA_MMAP_WORKAROUND)) { /* enable count status parameter */ if ((rval = - snd_pcm_plugin_set_disable (audio_handle, - PLUGIN_DISABLE_MMAP)) < 0) { - SDL_SetError ("snd_pcm_plugin_set_disable failed: %s\n", - snd_strerror (rval)); + snd_pcm_plugin_set_disable(audio_handle, + PLUGIN_DISABLE_MMAP)) < 0) { + SDL_SetError("snd_pcm_plugin_set_disable failed: %s\n", + snd_strerror(rval)); return (-1); } } @@ -389,7 +387,7 @@ /* can't use format as SND_PCM_SFMT_U8 = 0 in nto */ found = 0; - for (test_format = SDL_FirstAudioFormat (spec->format); !found;) { + for (test_format = SDL_FirstAudioFormat(spec->format); !found;) { /* if match found set format to equivalent ALSA format */ switch (test_format) { case AUDIO_U8: @@ -421,7 +419,7 @@ } if (!found) { - test_format = SDL_NextAudioFormat (); + test_format = SDL_NextAudioFormat(); } } @@ -444,66 +442,66 @@ cparams.format.rate = spec->freq; /* Setup the transfer parameters according to cparams */ - rval = snd_pcm_plugin_params (audio_handle, &cparams); + rval = snd_pcm_plugin_params(audio_handle, &cparams); if (rval < 0) { SDL_SetError ("NTO_OpenAudio(): snd_pcm_channel_params failed: %s\n", - snd_strerror (rval)); + snd_strerror(rval)); return (-1); } /* Make sure channel is setup right one last time */ - SDL_memset (&csetup, 0x00, sizeof (csetup)); + SDL_memset(&csetup, 0x00, sizeof(csetup)); csetup.channel = SND_PCM_CHANNEL_PLAYBACK; - if (snd_pcm_plugin_setup (audio_handle, &csetup) < 0) { - SDL_SetError ("NTO_OpenAudio(): Unable to setup playback channel\n"); + if (snd_pcm_plugin_setup(audio_handle, &csetup) < 0) { + SDL_SetError("NTO_OpenAudio(): Unable to setup playback channel\n"); return -1; } /* Calculate the final parameters for this audio specification */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); pcm_len = spec->size; if (pcm_len == 0) { pcm_len = csetup.buf.block.frag_size * spec->channels * - (snd_pcm_format_width (format) / 8); + (snd_pcm_format_width(format) / 8); } /* Allocate memory to the audio buffer and initialize with silence (Note that buffer size must be a multiple of fragment size, so find closest multiple) */ - pcm_buf = (Uint8 *) SDL_AllocAudioMem (pcm_len); + pcm_buf = (Uint8 *) SDL_AllocAudioMem(pcm_len); if (pcm_buf == NULL) { - SDL_SetError ("NTO_OpenAudio(): pcm buffer allocation failed\n"); + SDL_SetError("NTO_OpenAudio(): pcm buffer allocation failed\n"); return (-1); } - SDL_memset (pcm_buf, spec->silence, pcm_len); + SDL_memset(pcm_buf, spec->silence, pcm_len); /* get the file descriptor */ if ((audio_fd = - snd_pcm_file_descriptor (audio_handle, - SND_PCM_CHANNEL_PLAYBACK)) < 0) { + snd_pcm_file_descriptor(audio_handle, + SND_PCM_CHANNEL_PLAYBACK)) < 0) { SDL_SetError ("NTO_OpenAudio(): snd_pcm_file_descriptor failed with error code: %s\n", - snd_strerror (rval)); + snd_strerror(rval)); return (-1); } /* Trigger audio playback */ - rval = snd_pcm_plugin_prepare (audio_handle, SND_PCM_CHANNEL_PLAYBACK); + rval = snd_pcm_plugin_prepare(audio_handle, SND_PCM_CHANNEL_PLAYBACK); if (rval < 0) { - SDL_SetError ("snd_pcm_plugin_prepare failed: %s\n", - snd_strerror (rval)); + SDL_SetError("snd_pcm_plugin_prepare failed: %s\n", + snd_strerror(rval)); return (-1); } this->enabled = 1; /* Get the parent process id (we're the parent of the audio thread) */ - parent = getpid (); + parent = getpid(); /* We're really ready to rock and roll. :-) */ return (0); diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/paudio/SDL_paudio.c --- a/src/audio/paudio/SDL_paudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/paudio/SDL_paudio.c Mon May 29 04:04:35 2006 +0000 @@ -55,56 +55,56 @@ #define OPEN_FLAGS O_WRONLY /* Audio driver functions */ -static int Paud_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void Paud_WaitAudio (_THIS); -static void Paud_PlayAudio (_THIS); -static Uint8 *Paud_GetAudioBuf (_THIS); -static void Paud_CloseAudio (_THIS); +static int Paud_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void Paud_WaitAudio(_THIS); +static void Paud_PlayAudio(_THIS); +static Uint8 *Paud_GetAudioBuf(_THIS); +static void Paud_CloseAudio(_THIS); /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { int fd; int available; available = 0; - fd = SDL_OpenAudioPath (NULL, 0, OPEN_FLAGS, 0); + fd = SDL_OpenAudioPath(NULL, 0, OPEN_FLAGS, 0); if (fd >= 0) { available = 1; - close (fd); + close(fd); } return (available); } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); audio_fd = -1; /* Set the function pointers */ @@ -126,7 +126,7 @@ /* This function waits until it is possible to write a full sound buffer */ static void -Paud_WaitAudio (_THIS) +Paud_WaitAudio(_THIS) { fd_set fdset; @@ -135,21 +135,21 @@ /* Use timer for general audio synchronization */ Sint32 ticks; - ticks = ((Sint32) (next_frame - SDL_GetTicks ())) - FUDGE_TICKS; + ticks = ((Sint32) (next_frame - SDL_GetTicks())) - FUDGE_TICKS; if (ticks > 0) { - SDL_Delay (ticks); + SDL_Delay(ticks); } } else { audio_buffer paud_bufinfo; /* Use select() for audio synchronization */ struct timeval timeout; - FD_ZERO (&fdset); - FD_SET (audio_fd, &fdset); + FD_ZERO(&fdset); + FD_SET(audio_fd, &fdset); - if (ioctl (audio_fd, AUDIO_BUFFER, &paud_bufinfo) < 0) { + if (ioctl(audio_fd, AUDIO_BUFFER, &paud_bufinfo) < 0) { #ifdef DEBUG_AUDIO - fprintf (stderr, "Couldn't get audio buffer information\n"); + fprintf(stderr, "Couldn't get audio buffer information\n"); #endif timeout.tv_sec = 10; timeout.tv_usec = 0; @@ -159,16 +159,16 @@ ms_in_buf = ms_in_buf - timeout.tv_sec * 1000; timeout.tv_usec = ms_in_buf * 1000; #ifdef DEBUG_AUDIO - fprintf (stderr, - "Waiting for write_buf_time=%ld,%ld\n", - timeout.tv_sec, timeout.tv_usec); + fprintf(stderr, + "Waiting for write_buf_time=%ld,%ld\n", + timeout.tv_sec, timeout.tv_usec); #endif } #ifdef DEBUG_AUDIO - fprintf (stderr, "Waiting for audio to get ready\n"); + fprintf(stderr, "Waiting for audio to get ready\n"); #endif - if (select (audio_fd + 1, NULL, &fdset, NULL, &timeout) <= 0) { + if (select(audio_fd + 1, NULL, &fdset, NULL, &timeout) <= 0) { const char *message = "Audio timeout - buggy audio driver? (disabled)"; /* @@ -176,30 +176,30 @@ * but in this case we have no other way of letting * the user know what happened. */ - fprintf (stderr, "SDL: %s - %s\n", strerror (errno), message); + fprintf(stderr, "SDL: %s - %s\n", strerror(errno), message); this->enabled = 0; /* Don't try to close - may hang */ audio_fd = -1; #ifdef DEBUG_AUDIO - fprintf (stderr, "Done disabling audio\n"); + fprintf(stderr, "Done disabling audio\n"); #endif } #ifdef DEBUG_AUDIO - fprintf (stderr, "Ready!\n"); + fprintf(stderr, "Ready!\n"); #endif } } static void -Paud_PlayAudio (_THIS) +Paud_PlayAudio(_THIS) { int written; /* Write the audio data, checking for EAGAIN on broken audio drivers */ do { - written = write (audio_fd, mixbuf, mixlen); + written = write(audio_fd, mixbuf, mixlen); if ((written < 0) && ((errno == 0) || (errno == EAGAIN))) { - SDL_Delay (1); /* Let a little CPU time go by */ + SDL_Delay(1); /* Let a little CPU time go by */ } } while ((written < 0) && @@ -215,31 +215,31 @@ this->enabled = 0; } #ifdef DEBUG_AUDIO - fprintf (stderr, "Wrote %d bytes of audio data\n", written); + fprintf(stderr, "Wrote %d bytes of audio data\n", written); #endif } static Uint8 * -Paud_GetAudioBuf (_THIS) +Paud_GetAudioBuf(_THIS) { return mixbuf; } static void -Paud_CloseAudio (_THIS) +Paud_CloseAudio(_THIS) { if (mixbuf != NULL) { - SDL_FreeAudioMem (mixbuf); + SDL_FreeAudioMem(mixbuf); mixbuf = NULL; } if (audio_fd >= 0) { - close (audio_fd); + close(audio_fd); audio_fd = -1; } } static int -Paud_OpenAudio (_THIS, SDL_AudioSpec * spec) +Paud_OpenAudio(_THIS, SDL_AudioSpec * spec) { char audiodev[1024]; int format; @@ -255,9 +255,9 @@ frame_ticks = 0.0; /* Open the audio device */ - audio_fd = SDL_OpenAudioPath (audiodev, sizeof (audiodev), OPEN_FLAGS, 0); + audio_fd = SDL_OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0); if (audio_fd < 0) { - SDL_SetError ("Couldn't open %s: %s", audiodev, strerror (errno)); + SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno)); return -1; } @@ -265,8 +265,8 @@ * We can't set the buffer size - just ask the device for the maximum * that we can have. */ - if (ioctl (audio_fd, AUDIO_BUFFER, &paud_bufinfo) < 0) { - SDL_SetError ("Couldn't get audio buffer information"); + if (ioctl(audio_fd, AUDIO_BUFFER, &paud_bufinfo) < 0) { + SDL_SetError("Couldn't get audio buffer information"); return -1; } @@ -329,10 +329,10 @@ /* Try for a closest match on audio format */ format = 0; - for (test_format = SDL_FirstAudioFormat (spec->format); + for (test_format = SDL_FirstAudioFormat(spec->format); !format && test_format;) { #ifdef DEBUG_AUDIO - fprintf (stderr, "Trying format 0x%4.4x\n", test_format); + fprintf(stderr, "Trying format 0x%4.4x\n", test_format); #endif switch (test_format) { case AUDIO_U8: @@ -375,14 +375,14 @@ break; } if (!format) { - test_format = SDL_NextAudioFormat (); + test_format = SDL_NextAudioFormat(); } } if (format == 0) { #ifdef DEBUG_AUDIO - fprintf (stderr, "Couldn't find any hardware audio formats\n"); + fprintf(stderr, "Couldn't find any hardware audio formats\n"); #endif - SDL_SetError ("Couldn't find any hardware audio formats"); + SDL_SetError("Couldn't find any hardware audio formats"); return -1; } spec->format = test_format; @@ -406,7 +406,7 @@ } paud_init.bsize = bytes_per_sample * spec->channels; - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* * The AIX paud device init can't modify the values of the audio_init @@ -416,7 +416,7 @@ * /dev/paud supports all of the encoding formats, so we don't need * to do anything like reopening the device, either. */ - if (ioctl (audio_fd, AUDIO_INIT, &paud_init) < 0) { + if (ioctl(audio_fd, AUDIO_INIT, &paud_init) < 0) { switch (paud_init.rc) { case 1: SDL_SetError @@ -429,7 +429,7 @@ return -1; break; case 4: - SDL_SetError ("Couldn't set audio format: request was invalid"); + SDL_SetError("Couldn't set audio format: request was invalid"); return -1; break; case 5: @@ -452,11 +452,11 @@ /* Allocate mixing buffer */ mixlen = spec->size; - mixbuf = (Uint8 *) SDL_AllocAudioMem (mixlen); + mixbuf = (Uint8 *) SDL_AllocAudioMem(mixlen); if (mixbuf == NULL) { return -1; } - SDL_memset (mixbuf, spec->silence, spec->size); + SDL_memset(mixbuf, spec->silence, spec->size); /* * Set some paramters: full volume, first speaker that we can find. @@ -475,9 +475,9 @@ paud_control.ioctl_request = AUDIO_CHANGE; paud_control.request_info = (char *) &paud_change; - if (ioctl (audio_fd, AUDIO_CONTROL, &paud_control) < 0) { + if (ioctl(audio_fd, AUDIO_CONTROL, &paud_control) < 0) { #ifdef DEBUG_AUDIO - fprintf (stderr, "Can't change audio display settings\n"); + fprintf(stderr, "Can't change audio display settings\n"); #endif } @@ -487,26 +487,26 @@ */ paud_control.ioctl_request = AUDIO_START; paud_control.position = 0; - if (ioctl (audio_fd, AUDIO_CONTROL, &paud_control) < 0) { + if (ioctl(audio_fd, AUDIO_CONTROL, &paud_control) < 0) { #ifdef DEBUG_AUDIO - fprintf (stderr, "Can't start audio play\n"); + fprintf(stderr, "Can't start audio play\n"); #endif - SDL_SetError ("Can't start audio play"); + SDL_SetError("Can't start audio play"); return -1; } /* Check to see if we need to use select() workaround */ { char *workaround; - workaround = SDL_getenv ("SDL_DSP_NOSELECT"); + workaround = SDL_getenv("SDL_DSP_NOSELECT"); if (workaround) { frame_ticks = (float) (spec->samples * 1000) / spec->freq; - next_frame = SDL_GetTicks () + frame_ticks; + next_frame = SDL_GetTicks() + frame_ticks; } } /* Get the parent process id (we're the parent of the audio thread) */ - parent = getpid (); + parent = getpid(); /* We're ready to rock and roll. :-) */ return 0; diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/sun/SDL_sunaudio.c --- a/src/audio/sun/SDL_sunaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/sun/SDL_sunaudio.c Mon May 29 04:04:35 2006 +0000 @@ -48,58 +48,58 @@ #define OPEN_FLAGS (O_WRONLY|O_NONBLOCK) /* Audio driver functions */ -static int DSP_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void DSP_WaitAudio (_THIS); -static void DSP_PlayAudio (_THIS); -static Uint8 *DSP_GetAudioBuf (_THIS); -static void DSP_CloseAudio (_THIS); +static int DSP_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void DSP_WaitAudio(_THIS); +static void DSP_PlayAudio(_THIS); +static Uint8 *DSP_GetAudioBuf(_THIS); +static void DSP_CloseAudio(_THIS); -static Uint8 snd2au (int sample); +static Uint8 snd2au(int sample); /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { int fd; int available; available = 0; - fd = SDL_OpenAudioPath (NULL, 0, OPEN_FLAGS, 1); + fd = SDL_OpenAudioPath(NULL, 0, OPEN_FLAGS, 1); if (fd >= 0) { available = 1; - close (fd); + close(fd); } return (available); } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); audio_fd = -1; /* Set the function pointers */ @@ -121,30 +121,30 @@ #ifdef DEBUG_AUDIO void -CheckUnderflow (_THIS) +CheckUnderflow(_THIS) { #ifdef AUDIO_GETINFO audio_info_t info; int left; - ioctl (audio_fd, AUDIO_GETINFO, &info); + ioctl(audio_fd, AUDIO_GETINFO, &info); left = (written - info.play.samples); if (written && (left == 0)) { - fprintf (stderr, "audio underflow!\n"); + fprintf(stderr, "audio underflow!\n"); } #endif } #endif void -DSP_WaitAudio (_THIS) +DSP_WaitAudio(_THIS) { #ifdef AUDIO_GETINFO #define SLEEP_FUDGE 10 /* 10 ms scheduling fudge factor */ audio_info_t info; Sint32 left; - ioctl (audio_fd, AUDIO_GETINFO, &info); + ioctl(audio_fd, AUDIO_GETINFO, &info); left = (written - info.play.samples); if (left > fragsize) { Sint32 sleepy; @@ -152,20 +152,20 @@ sleepy = ((left - fragsize) / frequency); sleepy -= SLEEP_FUDGE; if (sleepy > 0) { - SDL_Delay (sleepy); + SDL_Delay(sleepy); } } #else fd_set fdset; - FD_ZERO (&fdset); - FD_SET (audio_fd, &fdset); - select (audio_fd + 1, NULL, &fdset, NULL, NULL); + FD_ZERO(&fdset); + FD_SET(audio_fd, &fdset); + select(audio_fd + 1, NULL, &fdset, NULL, NULL); #endif } void -DSP_PlayAudio (_THIS) +DSP_PlayAudio(_THIS) { /* Write the audio data */ if (ulaw_only) { @@ -183,7 +183,7 @@ sndbuf = mixbuf; for (pos = 0; pos < fragsize; ++pos) { - *aubuf = snd2au ((0x80 - *sndbuf) * 64); + *aubuf = snd2au((0x80 - *sndbuf) * 64); accum += incr; while (accum > 0) { accum -= 1000; @@ -199,7 +199,7 @@ sndbuf = (Sint16 *) mixbuf; for (pos = 0; pos < fragsize; ++pos) { - *aubuf = snd2au (*sndbuf / 4); + *aubuf = snd2au(*sndbuf / 4); accum += incr; while (accum > 0) { accum -= 1000; @@ -211,18 +211,18 @@ break; } #ifdef DEBUG_AUDIO - CheckUnderflow (this); + CheckUnderflow(this); #endif - if (write (audio_fd, ulaw_buf, fragsize) < 0) { + if (write(audio_fd, ulaw_buf, fragsize) < 0) { /* Assume fatal error, for now */ this->enabled = 0; } written += fragsize; } else { #ifdef DEBUG_AUDIO - CheckUnderflow (this); + CheckUnderflow(this); #endif - if (write (audio_fd, mixbuf, this->spec.size) < 0) { + if (write(audio_fd, mixbuf, this->spec.size) < 0) { /* Assume fatal error, for now */ this->enabled = 0; } @@ -231,27 +231,27 @@ } Uint8 * -DSP_GetAudioBuf (_THIS) +DSP_GetAudioBuf(_THIS) { return (mixbuf); } void -DSP_CloseAudio (_THIS) +DSP_CloseAudio(_THIS) { if (mixbuf != NULL) { - SDL_FreeAudioMem (mixbuf); + SDL_FreeAudioMem(mixbuf); mixbuf = NULL; } if (ulaw_buf != NULL) { - SDL_free (ulaw_buf); + SDL_free(ulaw_buf); ulaw_buf = NULL; } - close (audio_fd); + close(audio_fd); } int -DSP_OpenAudio (_THIS, SDL_AudioSpec * spec) +DSP_OpenAudio(_THIS, SDL_AudioSpec * spec) { char audiodev[1024]; #ifdef AUDIO_SETINFO @@ -287,16 +287,16 @@ default: { - SDL_SetError ("Unsupported audio format"); + SDL_SetError("Unsupported audio format"); return (-1); } } audio_fmt = spec->format; /* Open the audio device */ - audio_fd = SDL_OpenAudioPath (audiodev, sizeof (audiodev), OPEN_FLAGS, 1); + audio_fd = SDL_OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 1); if (audio_fd < 0) { - SDL_SetError ("Couldn't open %s: %s", audiodev, strerror (errno)); + SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno)); return (-1); } @@ -304,7 +304,7 @@ #ifdef AUDIO_SETINFO for (;;) { audio_info_t info; - AUDIO_INITINFO (&info); /* init all fields to "no change" */ + AUDIO_INITINFO(&info); /* init all fields to "no change" */ /* Try to set the requested settings */ info.play.sample_rate = spec->freq; @@ -312,12 +312,12 @@ info.play.precision = (enc == AUDIO_ENCODING_ULAW) ? 8 : spec->format & 0xff; info.play.encoding = enc; - if (ioctl (audio_fd, AUDIO_SETINFO, &info) == 0) { + if (ioctl(audio_fd, AUDIO_SETINFO, &info) == 0) { /* Check to be sure we got what we wanted */ - if (ioctl (audio_fd, AUDIO_GETINFO, &info) < 0) { - SDL_SetError ("Error getting audio parameters: %s", - strerror (errno)); + if (ioctl(audio_fd, AUDIO_GETINFO, &info) < 0) { + SDL_SetError("Error getting audio parameters: %s", + strerror(errno)); return -1; } if (info.play.encoding == enc @@ -347,8 +347,8 @@ default: /* oh well... */ - SDL_SetError ("Error setting audio parameters: %s", - strerror (errno)); + SDL_SetError("Error setting audio parameters: %s", + strerror(errno)); return -1; } } @@ -360,9 +360,9 @@ spec->freq = desired_freq; fragsize = (spec->samples * 1000) / (spec->freq / 8); frequency = 8; - ulaw_buf = (Uint8 *) SDL_malloc (fragsize); + ulaw_buf = (Uint8 *) SDL_malloc(fragsize); if (ulaw_buf == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } spec->channels = 1; @@ -371,22 +371,22 @@ frequency = spec->freq / 1000; } #ifdef DEBUG_AUDIO - fprintf (stderr, "Audio device %s U-Law only\n", - ulaw_only ? "is" : "is not"); - fprintf (stderr, "format=0x%x chan=%d freq=%d\n", - spec->format, spec->channels, spec->freq); + fprintf(stderr, "Audio device %s U-Law only\n", + ulaw_only ? "is" : "is not"); + fprintf(stderr, "format=0x%x chan=%d freq=%d\n", + spec->format, spec->channels, spec->freq); #endif /* Update the fragment size as size in bytes */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Allocate mixing buffer */ - mixbuf = (Uint8 *) SDL_AllocAudioMem (spec->size); + mixbuf = (Uint8 *) SDL_AllocAudioMem(spec->size); if (mixbuf == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } - SDL_memset (mixbuf, spec->silence, spec->size); + SDL_memset(mixbuf, spec->silence, spec->size); /* We're ready to rock and roll. :-) */ return (0); @@ -411,7 +411,7 @@ /************************************************************************/ static Uint8 -snd2au (int sample) +snd2au(int sample) { int mask; diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/ums/SDL_umsaudio.c --- a/src/audio/ums/SDL_umsaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/ums/SDL_umsaudio.c Mon May 29 04:04:35 2006 +0000 @@ -45,64 +45,64 @@ #define DEBUG_AUDIO 1 /* Audio driver functions */ -static int UMS_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void UMS_PlayAudio (_THIS); -static Uint8 *UMS_GetAudioBuf (_THIS); -static void UMS_CloseAudio (_THIS); +static int UMS_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void UMS_PlayAudio(_THIS); +static Uint8 *UMS_GetAudioBuf(_THIS); +static void UMS_CloseAudio(_THIS); -static UMSAudioDevice_ReturnCode UADOpen (_THIS, string device, string mode, - long flags); -static UMSAudioDevice_ReturnCode UADClose (_THIS); -static UMSAudioDevice_ReturnCode UADGetBitsPerSample (_THIS, long *bits); -static UMSAudioDevice_ReturnCode UADSetBitsPerSample (_THIS, long bits); -static UMSAudioDevice_ReturnCode UADSetSampleRate (_THIS, long rate, - long *set_rate); -static UMSAudioDevice_ReturnCode UADSetByteOrder (_THIS, string byte_order); -static UMSAudioDevice_ReturnCode UADSetAudioFormatType (_THIS, string fmt); -static UMSAudioDevice_ReturnCode UADSetNumberFormat (_THIS, string fmt); -static UMSAudioDevice_ReturnCode UADInitialize (_THIS); -static UMSAudioDevice_ReturnCode UADStart (_THIS); -static UMSAudioDevice_ReturnCode UADStop (_THIS); -static UMSAudioDevice_ReturnCode UADSetTimeFormat (_THIS, - UMSAudioTypes_TimeFormat - fmt); -static UMSAudioDevice_ReturnCode UADWriteBuffSize (_THIS, long *buff_size); -static UMSAudioDevice_ReturnCode UADWriteBuffRemain (_THIS, long *buff_size); -static UMSAudioDevice_ReturnCode UADWriteBuffUsed (_THIS, long *buff_size); -static UMSAudioDevice_ReturnCode UADSetDMABufferSize (_THIS, long bytes, - long *bytes_ret); -static UMSAudioDevice_ReturnCode UADSetVolume (_THIS, long volume); -static UMSAudioDevice_ReturnCode UADSetBalance (_THIS, long balance); -static UMSAudioDevice_ReturnCode UADSetChannels (_THIS, long channels); -static UMSAudioDevice_ReturnCode UADPlayRemainingData (_THIS, boolean block); -static UMSAudioDevice_ReturnCode UADEnableOutput (_THIS, string output, - long *left_gain, - long *right_gain); -static UMSAudioDevice_ReturnCode UADWrite (_THIS, UMSAudioTypes_Buffer * buff, - long samples, - long *samples_written); +static UMSAudioDevice_ReturnCode UADOpen(_THIS, string device, string mode, + long flags); +static UMSAudioDevice_ReturnCode UADClose(_THIS); +static UMSAudioDevice_ReturnCode UADGetBitsPerSample(_THIS, long *bits); +static UMSAudioDevice_ReturnCode UADSetBitsPerSample(_THIS, long bits); +static UMSAudioDevice_ReturnCode UADSetSampleRate(_THIS, long rate, + long *set_rate); +static UMSAudioDevice_ReturnCode UADSetByteOrder(_THIS, string byte_order); +static UMSAudioDevice_ReturnCode UADSetAudioFormatType(_THIS, string fmt); +static UMSAudioDevice_ReturnCode UADSetNumberFormat(_THIS, string fmt); +static UMSAudioDevice_ReturnCode UADInitialize(_THIS); +static UMSAudioDevice_ReturnCode UADStart(_THIS); +static UMSAudioDevice_ReturnCode UADStop(_THIS); +static UMSAudioDevice_ReturnCode UADSetTimeFormat(_THIS, + UMSAudioTypes_TimeFormat + fmt); +static UMSAudioDevice_ReturnCode UADWriteBuffSize(_THIS, long *buff_size); +static UMSAudioDevice_ReturnCode UADWriteBuffRemain(_THIS, long *buff_size); +static UMSAudioDevice_ReturnCode UADWriteBuffUsed(_THIS, long *buff_size); +static UMSAudioDevice_ReturnCode UADSetDMABufferSize(_THIS, long bytes, + long *bytes_ret); +static UMSAudioDevice_ReturnCode UADSetVolume(_THIS, long volume); +static UMSAudioDevice_ReturnCode UADSetBalance(_THIS, long balance); +static UMSAudioDevice_ReturnCode UADSetChannels(_THIS, long channels); +static UMSAudioDevice_ReturnCode UADPlayRemainingData(_THIS, boolean block); +static UMSAudioDevice_ReturnCode UADEnableOutput(_THIS, string output, + long *left_gain, + long *right_gain); +static UMSAudioDevice_ReturnCode UADWrite(_THIS, UMSAudioTypes_Buffer * buff, + long samples, + long *samples_written); /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { return 1; } static void -Audio_DeleteDevice (_THIS) +Audio_DeleteDevice(_THIS) { if (this->hidden->playbuf._buffer) - SDL_free (this->hidden->playbuf._buffer); + SDL_free(this->hidden->playbuf._buffer); if (this->hidden->fillbuf._buffer) - SDL_free (this->hidden->fillbuf._buffer); - _somFree (this->hidden->umsdev); - SDL_free (this->hidden); - SDL_free (this); + SDL_free(this->hidden->fillbuf._buffer); + _somFree(this->hidden->umsdev); + SDL_free(this->hidden); + SDL_free(this); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; @@ -110,29 +110,29 @@ * Allocate and initialize management storage and private management * storage for this SDL-using library. */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); #ifdef DEBUG_AUDIO - fprintf (stderr, "Creating UMS Audio device\n"); + fprintf(stderr, "Creating UMS Audio device\n"); #endif /* * Calls for UMS env initialization and audio object construction. */ - this->hidden->ev = somGetGlobalEnvironment (); - this->hidden->umsdev = UMSAudioDeviceNew (); + this->hidden->ev = somGetGlobalEnvironment(); + this->hidden->umsdev = UMSAudioDeviceNew(); /* * Set the function pointers. @@ -145,7 +145,7 @@ this->free = Audio_DeleteDevice; #ifdef DEBUG_AUDIO - fprintf (stderr, "done\n"); + fprintf(stderr, "done\n"); #endif return this; } @@ -156,10 +156,10 @@ }; static Uint8 * -UMS_GetAudioBuf (_THIS) +UMS_GetAudioBuf(_THIS) { #ifdef DEBUG_AUDIO - fprintf (stderr, "enter UMS_GetAudioBuf\n"); + fprintf(stderr, "enter UMS_GetAudioBuf\n"); #endif return this->hidden->fillbuf._buffer; /* @@ -172,20 +172,20 @@ } static void -UMS_CloseAudio (_THIS) +UMS_CloseAudio(_THIS) { UMSAudioDevice_ReturnCode rc; #ifdef DEBUG_AUDIO - fprintf (stderr, "enter UMS_CloseAudio\n"); + fprintf(stderr, "enter UMS_CloseAudio\n"); #endif - rc = UADPlayRemainingData (this, TRUE); - rc = UADStop (this); - rc = UADClose (this); + rc = UADPlayRemainingData(this, TRUE); + rc = UADStop(this); + rc = UADClose(this); } static void -UMS_PlayAudio (_THIS) +UMS_PlayAudio(_THIS) { UMSAudioDevice_ReturnCode rc; long samplesToWrite; @@ -193,13 +193,13 @@ UMSAudioTypes_Buffer swpbuf; #ifdef DEBUG_AUDIO - fprintf (stderr, "enter UMS_PlayAudio\n"); + fprintf(stderr, "enter UMS_PlayAudio\n"); #endif samplesToWrite = this->hidden->playbuf._length / this->hidden->bytesPerSample; do { - rc = UADWrite (this, &this->hidden->playbuf, - samplesToWrite, &samplesWritten); + rc = UADWrite(this, &this->hidden->playbuf, + samplesToWrite, &samplesWritten); samplesToWrite -= samplesWritten; /* rc values: UMSAudioDevice_Success @@ -210,24 +210,22 @@ */ if (rc == UMSAudioDevice_DeviceError) { #ifdef DEBUG_AUDIO - fprintf (stderr, "Returning from PlayAudio with devices error\n"); + fprintf(stderr, "Returning from PlayAudio with devices error\n"); #endif return; } } while (samplesToWrite > 0); - SDL_LockAudio (); - SDL_memcpy (&swpbuf, &this->hidden->playbuf, - sizeof (UMSAudioTypes_Buffer)); - SDL_memcpy (&this->hidden->playbuf, &this->hidden->fillbuf, - sizeof (UMSAudioTypes_Buffer)); - SDL_memcpy (&this->hidden->fillbuf, &swpbuf, - sizeof (UMSAudioTypes_Buffer)); - SDL_UnlockAudio (); + SDL_LockAudio(); + SDL_memcpy(&swpbuf, &this->hidden->playbuf, sizeof(UMSAudioTypes_Buffer)); + SDL_memcpy(&this->hidden->playbuf, &this->hidden->fillbuf, + sizeof(UMSAudioTypes_Buffer)); + SDL_memcpy(&this->hidden->fillbuf, &swpbuf, sizeof(UMSAudioTypes_Buffer)); + SDL_UnlockAudio(); #ifdef DEBUG_AUDIO - fprintf (stderr, "Wrote audio data and swapped buffer\n"); + fprintf(stderr, "Wrote audio data and swapped buffer\n"); #endif } @@ -242,7 +240,7 @@ #endif static int -UMS_OpenAudio (_THIS, SDL_AudioSpec * spec) +UMS_OpenAudio(_THIS, SDL_AudioSpec * spec) { char *audiodev = "/dev/paud0"; long lgain; @@ -257,21 +255,21 @@ UMSAudioDevice_ReturnCode rc; #ifdef DEBUG_AUDIO - fprintf (stderr, "enter UMS_OpenAudio\n"); + fprintf(stderr, "enter UMS_OpenAudio\n"); #endif - rc = UADOpen (this, audiodev, "PLAY", UMSAudioDevice_BlockingIO); + rc = UADOpen(this, audiodev, "PLAY", UMSAudioDevice_BlockingIO); if (rc != UMSAudioDevice_Success) { - SDL_SetError ("Couldn't open %s: %s", audiodev, strerror (errno)); + SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno)); return -1; } - rc = UADSetAudioFormatType (this, "PCM"); + rc = UADSetAudioFormatType(this, "PCM"); success = 0; - test_format = SDL_FirstAudioFormat (spec->format); + test_format = SDL_FirstAudioFormat(spec->format); do { #ifdef DEBUG_AUDIO - fprintf (stderr, "Trying format 0x%4.4x\n", test_format); + fprintf(stderr, "Trying format 0x%4.4x\n", test_format); #endif switch (test_format) { case AUDIO_U8: @@ -279,56 +277,56 @@ /* sample_bits = spec->size / spec->samples / spec->channels * 8; */ success = 1; bitsPerSample = 8; - rc = UADSetSampleRate (this, spec->freq << 16, &outRate); - rc = UADSetByteOrder (this, "MSB"); /* irrelevant */ - rc = UADSetNumberFormat (this, "UNSIGNED"); + rc = UADSetSampleRate(this, spec->freq << 16, &outRate); + rc = UADSetByteOrder(this, "MSB"); /* irrelevant */ + rc = UADSetNumberFormat(this, "UNSIGNED"); break; case AUDIO_S8: success = 1; bitsPerSample = 8; - rc = UADSetSampleRate (this, spec->freq << 16, &outRate); - rc = UADSetByteOrder (this, "MSB"); /* irrelevant */ - rc = UADSetNumberFormat (this, "SIGNED"); + rc = UADSetSampleRate(this, spec->freq << 16, &outRate); + rc = UADSetByteOrder(this, "MSB"); /* irrelevant */ + rc = UADSetNumberFormat(this, "SIGNED"); break; case AUDIO_S16LSB: success = 1; bitsPerSample = 16; - rc = UADSetSampleRate (this, spec->freq << 16, &outRate); - rc = UADSetByteOrder (this, "LSB"); - rc = UADSetNumberFormat (this, "SIGNED"); + rc = UADSetSampleRate(this, spec->freq << 16, &outRate); + rc = UADSetByteOrder(this, "LSB"); + rc = UADSetNumberFormat(this, "SIGNED"); break; case AUDIO_S16MSB: success = 1; bitsPerSample = 16; - rc = UADSetSampleRate (this, spec->freq << 16, &outRate); - rc = UADSetByteOrder (this, "MSB"); - rc = UADSetNumberFormat (this, "SIGNED"); + rc = UADSetSampleRate(this, spec->freq << 16, &outRate); + rc = UADSetByteOrder(this, "MSB"); + rc = UADSetNumberFormat(this, "SIGNED"); break; case AUDIO_U16LSB: success = 1; bitsPerSample = 16; - rc = UADSetSampleRate (this, spec->freq << 16, &outRate); - rc = UADSetByteOrder (this, "LSB"); - rc = UADSetNumberFormat (this, "UNSIGNED"); + rc = UADSetSampleRate(this, spec->freq << 16, &outRate); + rc = UADSetByteOrder(this, "LSB"); + rc = UADSetNumberFormat(this, "UNSIGNED"); break; case AUDIO_U16MSB: success = 1; bitsPerSample = 16; - rc = UADSetSampleRate (this, spec->freq << 16, &outRate); - rc = UADSetByteOrder (this, "MSB"); - rc = UADSetNumberFormat (this, "UNSIGNED"); + rc = UADSetSampleRate(this, spec->freq << 16, &outRate); + rc = UADSetByteOrder(this, "MSB"); + rc = UADSetNumberFormat(this, "UNSIGNED"); break; default: break; } if (!success) { - test_format = SDL_NextAudioFormat (); + test_format = SDL_NextAudioFormat(); } } while (!success && test_format); if (success == 0) { - SDL_SetError ("Couldn't find any hardware audio formats"); + SDL_SetError("Couldn't find any hardware audio formats"); return -1; } @@ -336,7 +334,7 @@ for (frag_spec = 0; (0x01 << frag_spec) < spec->size; ++frag_spec); if ((0x01 << frag_spec) != spec->size) { - SDL_SetError ("Fragment size must be a power of two"); + SDL_SetError("Fragment size must be a power of two"); return -1; } if (frag_spec > 2048) @@ -347,22 +345,22 @@ this->hidden->playbuf._length = 0; this->hidden->playbuf._maximum = spec->size; - this->hidden->playbuf._buffer = (unsigned char *) SDL_malloc (spec->size); + this->hidden->playbuf._buffer = (unsigned char *) SDL_malloc(spec->size); this->hidden->fillbuf._length = 0; this->hidden->fillbuf._maximum = spec->size; - this->hidden->fillbuf._buffer = (unsigned char *) SDL_malloc (spec->size); + this->hidden->fillbuf._buffer = (unsigned char *) SDL_malloc(spec->size); - rc = UADSetBitsPerSample (this, bitsPerSample); - rc = UADSetDMABufferSize (this, frag_spec, &outBufSize); - rc = UADSetChannels (this, spec->channels); /* functions reduces to mono or stereo */ + rc = UADSetBitsPerSample(this, bitsPerSample); + rc = UADSetDMABufferSize(this, frag_spec, &outBufSize); + rc = UADSetChannels(this, spec->channels); /* functions reduces to mono or stereo */ lgain = 100; /*maximum left input gain */ rgain = 100; /*maimum right input gain */ - rc = UADEnableOutput (this, "LINE_OUT", &lgain, &rgain); - rc = UADInitialize (this); - rc = UADStart (this); - rc = UADSetVolume (this, 100); - rc = UADSetBalance (this, 0); + rc = UADEnableOutput(this, "LINE_OUT", &lgain, &rgain); + rc = UADInitialize(this); + rc = UADStart(this); + rc = UADSetVolume(this, 100); + rc = UADSetBalance(this, 0); /* We're ready to rock and roll. :-) */ return 0; @@ -370,142 +368,142 @@ static UMSAudioDevice_ReturnCode -UADGetBitsPerSample (_THIS, long *bits) +UADGetBitsPerSample(_THIS, long *bits) { - return UMSAudioDevice_get_bits_per_sample (this->hidden->umsdev, - this->hidden->ev, bits); + return UMSAudioDevice_get_bits_per_sample(this->hidden->umsdev, + this->hidden->ev, bits); } static UMSAudioDevice_ReturnCode -UADSetBitsPerSample (_THIS, long bits) +UADSetBitsPerSample(_THIS, long bits) { - return UMSAudioDevice_set_bits_per_sample (this->hidden->umsdev, - this->hidden->ev, bits); + return UMSAudioDevice_set_bits_per_sample(this->hidden->umsdev, + this->hidden->ev, bits); } static UMSAudioDevice_ReturnCode -UADSetSampleRate (_THIS, long rate, long *set_rate) +UADSetSampleRate(_THIS, long rate, long *set_rate) { /* from the mac code: sample rate = spec->freq << 16; */ - return UMSAudioDevice_set_sample_rate (this->hidden->umsdev, - this->hidden->ev, rate, set_rate); + return UMSAudioDevice_set_sample_rate(this->hidden->umsdev, + this->hidden->ev, rate, set_rate); } static UMSAudioDevice_ReturnCode -UADSetByteOrder (_THIS, string byte_order) +UADSetByteOrder(_THIS, string byte_order) { - return UMSAudioDevice_set_byte_order (this->hidden->umsdev, - this->hidden->ev, byte_order); + return UMSAudioDevice_set_byte_order(this->hidden->umsdev, + this->hidden->ev, byte_order); } static UMSAudioDevice_ReturnCode -UADSetAudioFormatType (_THIS, string fmt) +UADSetAudioFormatType(_THIS, string fmt) { /* possible PCM, A_LAW or MU_LAW */ - return UMSAudioDevice_set_audio_format_type (this->hidden->umsdev, - this->hidden->ev, fmt); + return UMSAudioDevice_set_audio_format_type(this->hidden->umsdev, + this->hidden->ev, fmt); } static UMSAudioDevice_ReturnCode -UADSetNumberFormat (_THIS, string fmt) +UADSetNumberFormat(_THIS, string fmt) { /* possible SIGNED, UNSIGNED, or TWOS_COMPLEMENT */ - return UMSAudioDevice_set_number_format (this->hidden->umsdev, - this->hidden->ev, fmt); + return UMSAudioDevice_set_number_format(this->hidden->umsdev, + this->hidden->ev, fmt); } static UMSAudioDevice_ReturnCode -UADInitialize (_THIS) +UADInitialize(_THIS) { - return UMSAudioDevice_initialize (this->hidden->umsdev, this->hidden->ev); + return UMSAudioDevice_initialize(this->hidden->umsdev, this->hidden->ev); } static UMSAudioDevice_ReturnCode -UADStart (_THIS) +UADStart(_THIS) { - return UMSAudioDevice_start (this->hidden->umsdev, this->hidden->ev); + return UMSAudioDevice_start(this->hidden->umsdev, this->hidden->ev); } static UMSAudioDevice_ReturnCode -UADSetTimeFormat (_THIS, UMSAudioTypes_TimeFormat fmt) +UADSetTimeFormat(_THIS, UMSAudioTypes_TimeFormat fmt) { /* * Switches the time format to the new format, immediately. * possible UMSAudioTypes_Msecs, UMSAudioTypes_Bytes or UMSAudioTypes_Samples */ - return UMSAudioDevice_set_time_format (this->hidden->umsdev, - this->hidden->ev, fmt); + return UMSAudioDevice_set_time_format(this->hidden->umsdev, + this->hidden->ev, fmt); } static UMSAudioDevice_ReturnCode -UADWriteBuffSize (_THIS, long *buff_size) +UADWriteBuffSize(_THIS, long *buff_size) { /* * returns write buffer size in the current time format */ - return UMSAudioDevice_write_buff_size (this->hidden->umsdev, - this->hidden->ev, buff_size); + return UMSAudioDevice_write_buff_size(this->hidden->umsdev, + this->hidden->ev, buff_size); } static UMSAudioDevice_ReturnCode -UADWriteBuffRemain (_THIS, long *buff_size) +UADWriteBuffRemain(_THIS, long *buff_size) { /* * returns amount of available space in the write buffer * in the current time format */ - return UMSAudioDevice_write_buff_remain (this->hidden->umsdev, - this->hidden->ev, buff_size); + return UMSAudioDevice_write_buff_remain(this->hidden->umsdev, + this->hidden->ev, buff_size); } static UMSAudioDevice_ReturnCode -UADWriteBuffUsed (_THIS, long *buff_size) +UADWriteBuffUsed(_THIS, long *buff_size) { /* * returns amount of filled space in the write buffer * in the current time format */ - return UMSAudioDevice_write_buff_used (this->hidden->umsdev, - this->hidden->ev, buff_size); + return UMSAudioDevice_write_buff_used(this->hidden->umsdev, + this->hidden->ev, buff_size); } static UMSAudioDevice_ReturnCode -UADSetDMABufferSize (_THIS, long bytes, long *bytes_ret) +UADSetDMABufferSize(_THIS, long bytes, long *bytes_ret) { /* * Request a new DMA buffer size, maximum requested size 2048. * Takes effect with next initialize() call. * Devices may or may not support DMA. */ - return UMSAudioDevice_set_DMA_buffer_size (this->hidden->umsdev, - this->hidden->ev, - bytes, bytes_ret); + return UMSAudioDevice_set_DMA_buffer_size(this->hidden->umsdev, + this->hidden->ev, + bytes, bytes_ret); } static UMSAudioDevice_ReturnCode -UADSetVolume (_THIS, long volume) +UADSetVolume(_THIS, long volume) { /* * Set the volume. * Takes effect immediately. */ - return UMSAudioDevice_set_volume (this->hidden->umsdev, - this->hidden->ev, volume); + return UMSAudioDevice_set_volume(this->hidden->umsdev, + this->hidden->ev, volume); } static UMSAudioDevice_ReturnCode -UADSetBalance (_THIS, long balance) +UADSetBalance(_THIS, long balance) { /* * Set the balance. * Takes effect immediately. */ - return UMSAudioDevice_set_balance (this->hidden->umsdev, - this->hidden->ev, balance); + return UMSAudioDevice_set_balance(this->hidden->umsdev, + this->hidden->ev, balance); } static UMSAudioDevice_ReturnCode -UADSetChannels (_THIS, long channels) +UADSetChannels(_THIS, long channels) { /* * Set mono or stereo. @@ -513,51 +511,51 @@ */ if (channels != 1) channels = 2; - return UMSAudioDevice_set_number_of_channels (this->hidden->umsdev, - this->hidden->ev, channels); + return UMSAudioDevice_set_number_of_channels(this->hidden->umsdev, + this->hidden->ev, channels); } static UMSAudioDevice_ReturnCode -UADOpen (_THIS, string device, string mode, long flags) +UADOpen(_THIS, string device, string mode, long flags) { - return UMSAudioDevice_open (this->hidden->umsdev, - this->hidden->ev, device, mode, flags); + return UMSAudioDevice_open(this->hidden->umsdev, + this->hidden->ev, device, mode, flags); } static UMSAudioDevice_ReturnCode -UADWrite (_THIS, UMSAudioTypes_Buffer * buff, - long samples, long *samples_written) +UADWrite(_THIS, UMSAudioTypes_Buffer * buff, + long samples, long *samples_written) { - return UMSAudioDevice_write (this->hidden->umsdev, - this->hidden->ev, - buff, samples, samples_written); + return UMSAudioDevice_write(this->hidden->umsdev, + this->hidden->ev, + buff, samples, samples_written); } static UMSAudioDevice_ReturnCode -UADPlayRemainingData (_THIS, boolean block) +UADPlayRemainingData(_THIS, boolean block) { - return UMSAudioDevice_play_remaining_data (this->hidden->umsdev, - this->hidden->ev, block); + return UMSAudioDevice_play_remaining_data(this->hidden->umsdev, + this->hidden->ev, block); } static UMSAudioDevice_ReturnCode -UADStop (_THIS) +UADStop(_THIS) { - return UMSAudioDevice_stop (this->hidden->umsdev, this->hidden->ev); + return UMSAudioDevice_stop(this->hidden->umsdev, this->hidden->ev); } static UMSAudioDevice_ReturnCode -UADClose (_THIS) +UADClose(_THIS) { - return UMSAudioDevice_close (this->hidden->umsdev, this->hidden->ev); + return UMSAudioDevice_close(this->hidden->umsdev, this->hidden->ev); } static UMSAudioDevice_ReturnCode -UADEnableOutput (_THIS, string output, long *left_gain, long *right_gain) +UADEnableOutput(_THIS, string output, long *left_gain, long *right_gain) { - return UMSAudioDevice_enable_output (this->hidden->umsdev, - this->hidden->ev, - output, left_gain, right_gain); + return UMSAudioDevice_enable_output(this->hidden->umsdev, + this->hidden->ev, + output, left_gain, right_gain); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/windib/SDL_dibaudio.c --- a/src/audio/windib/SDL_dibaudio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/windib/SDL_dibaudio.c Mon May 29 04:04:35 2006 +0000 @@ -37,49 +37,49 @@ /* Audio driver functions */ -static int DIB_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void DIB_ThreadInit (_THIS); -static void DIB_WaitAudio (_THIS); -static Uint8 *DIB_GetAudioBuf (_THIS); -static void DIB_PlayAudio (_THIS); -static void DIB_WaitDone (_THIS); -static void DIB_CloseAudio (_THIS); +static int DIB_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void DIB_ThreadInit(_THIS); +static void DIB_WaitAudio(_THIS); +static Uint8 *DIB_GetAudioBuf(_THIS); +static void DIB_PlayAudio(_THIS); +static void DIB_WaitDone(_THIS); +static void DIB_CloseAudio(_THIS); /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { return (1); } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = DIB_OpenAudio; @@ -103,8 +103,8 @@ /* The Win32 callback for filling the WAVE device */ static void CALLBACK -FillSound (HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, - DWORD dwParam1, DWORD dwParam2) +FillSound(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, + DWORD dwParam1, DWORD dwParam2) { SDL_AudioDevice *this = (SDL_AudioDevice *) dwInstance; @@ -114,14 +114,14 @@ /* Signal that we are done playing a buffer */ #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) - ReleaseSemaphoreCE (audio_sem, 1, NULL); + ReleaseSemaphoreCE(audio_sem, 1, NULL); #else - ReleaseSemaphore (audio_sem, 1, NULL); + ReleaseSemaphore(audio_sem, 1, NULL); #endif } static void -SetMMerror (char *function, MMRESULT code) +SetMMerror(char *function, MMRESULT code) { size_t len; char errbuf[MAXERRORLENGTH]; @@ -129,41 +129,41 @@ wchar_t werrbuf[MAXERRORLENGTH]; #endif - SDL_snprintf (errbuf, SDL_arraysize (errbuf), "%s: ", function); - len = SDL_strlen (errbuf); + SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function); + len = SDL_strlen(errbuf); #ifdef _WIN32_WCE /* UNICODE version */ - waveOutGetErrorText (code, werrbuf, MAXERRORLENGTH - len); - WideCharToMultiByte (CP_ACP, 0, werrbuf, -1, errbuf + len, - MAXERRORLENGTH - len, NULL, NULL); + waveOutGetErrorText(code, werrbuf, MAXERRORLENGTH - len); + WideCharToMultiByte(CP_ACP, 0, werrbuf, -1, errbuf + len, + MAXERRORLENGTH - len, NULL, NULL); #else - waveOutGetErrorText (code, errbuf + len, (UINT) (MAXERRORLENGTH - len)); + waveOutGetErrorText(code, errbuf + len, (UINT) (MAXERRORLENGTH - len)); #endif - SDL_SetError ("%s", errbuf); + SDL_SetError("%s", errbuf); } /* Set high priority for the audio thread */ static void -DIB_ThreadInit (_THIS) +DIB_ThreadInit(_THIS) { - SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST); + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); } void -DIB_WaitAudio (_THIS) +DIB_WaitAudio(_THIS) { /* Wait for an audio chunk to finish */ #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) - WaitForSemaphoreCE (audio_sem, INFINITE); + WaitForSemaphoreCE(audio_sem, INFINITE); #else - WaitForSingleObject (audio_sem, INFINITE); + WaitForSingleObject(audio_sem, INFINITE); #endif } Uint8 * -DIB_GetAudioBuf (_THIS) +DIB_GetAudioBuf(_THIS) { Uint8 *retval; @@ -172,15 +172,15 @@ } void -DIB_PlayAudio (_THIS) +DIB_PlayAudio(_THIS) { /* Queue it up */ - waveOutWrite (sound, &wavebuf[next_buffer], sizeof (wavebuf[0])); + waveOutWrite(sound, &wavebuf[next_buffer], sizeof(wavebuf[0])); next_buffer = (next_buffer + 1) % NUM_BUFFERS; } void -DIB_WaitDone (_THIS) +DIB_WaitDone(_THIS) { int i, left; @@ -192,45 +192,45 @@ } } if (left > 0) { - SDL_Delay (100); + SDL_Delay(100); } } while (left > 0); } void -DIB_CloseAudio (_THIS) +DIB_CloseAudio(_THIS) { int i; /* Close up audio */ if (audio_sem) { #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) - CloseSynchHandle (audio_sem); + CloseSynchHandle(audio_sem); #else - CloseHandle (audio_sem); + CloseHandle(audio_sem); #endif } if (sound) { - waveOutClose (sound); + waveOutClose(sound); } /* Clean up mixing buffers */ for (i = 0; i < NUM_BUFFERS; ++i) { if (wavebuf[i].dwUser != 0xFFFF) { - waveOutUnprepareHeader (sound, &wavebuf[i], sizeof (wavebuf[i])); + waveOutUnprepareHeader(sound, &wavebuf[i], sizeof(wavebuf[i])); wavebuf[i].dwUser = 0xFFFF; } } /* Free raw mixing buffer */ if (mixbuf != NULL) { - SDL_free (mixbuf); + SDL_free(mixbuf); mixbuf = NULL; } } int -DIB_OpenAudio (_THIS, SDL_AudioSpec * spec) +DIB_OpenAudio(_THIS, SDL_AudioSpec * spec) { MMRESULT result; int i; @@ -244,7 +244,7 @@ mixbuf = NULL; /* Set basic WAVE format parameters */ - SDL_memset (&waveformat, 0, sizeof (waveformat)); + SDL_memset(&waveformat, 0, sizeof(waveformat)); waveformat.wFormatTag = WAVE_FORMAT_PCM; /* Determine the audio parameters from the AudioSpec */ @@ -260,7 +260,7 @@ waveformat.wBitsPerSample = 16; break; default: - SDL_SetError ("Unsupported audio format"); + SDL_SetError("Unsupported audio format"); return (-1); } waveformat.nChannels = spec->channels; @@ -275,14 +275,14 @@ spec->samples = ((spec->freq / 4) + 3) & ~3; /* Update the fragment size as size in bytes */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Open the audio device */ - result = waveOutOpen (&sound, WAVE_MAPPER, &waveformat, - (DWORD_PTR) FillSound, (DWORD_PTR) this, - CALLBACK_FUNCTION); + result = waveOutOpen(&sound, WAVE_MAPPER, &waveformat, + (DWORD_PTR) FillSound, (DWORD_PTR) this, + CALLBACK_FUNCTION); if (result != MMSYSERR_NOERROR) { - SetMMerror ("waveOutOpen()", result); + SetMMerror("waveOutOpen()", result); return (-1); } #ifdef SOUND_DEBUG @@ -290,41 +290,40 @@ { WAVEOUTCAPS caps; - result = waveOutGetDevCaps ((UINT) sound, &caps, sizeof (caps)); + result = waveOutGetDevCaps((UINT) sound, &caps, sizeof(caps)); if (result != MMSYSERR_NOERROR) { - SetMMerror ("waveOutGetDevCaps()", result); + SetMMerror("waveOutGetDevCaps()", result); return (-1); } - printf ("Audio device: %s\n", caps.szPname); + printf("Audio device: %s\n", caps.szPname); } #endif /* Create the audio buffer semaphore */ #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) - audio_sem = CreateSemaphoreCE (NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL); + audio_sem = CreateSemaphoreCE(NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL); #else - audio_sem = CreateSemaphore (NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL); + audio_sem = CreateSemaphore(NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL); #endif if (audio_sem == NULL) { - SDL_SetError ("Couldn't create semaphore"); + SDL_SetError("Couldn't create semaphore"); return (-1); } /* Create the sound buffers */ - mixbuf = (Uint8 *) SDL_malloc (NUM_BUFFERS * spec->size); + mixbuf = (Uint8 *) SDL_malloc(NUM_BUFFERS * spec->size); if (mixbuf == NULL) { - SDL_SetError ("Out of memory"); + SDL_SetError("Out of memory"); return (-1); } for (i = 0; i < NUM_BUFFERS; ++i) { - SDL_memset (&wavebuf[i], 0, sizeof (wavebuf[i])); + SDL_memset(&wavebuf[i], 0, sizeof(wavebuf[i])); wavebuf[i].lpData = (LPSTR) & mixbuf[i * spec->size]; wavebuf[i].dwBufferLength = spec->size; wavebuf[i].dwFlags = WHDR_DONE; - result = waveOutPrepareHeader (sound, &wavebuf[i], - sizeof (wavebuf[i])); + result = waveOutPrepareHeader(sound, &wavebuf[i], sizeof(wavebuf[i])); if (result != MMSYSERR_NOERROR) { - SetMMerror ("waveOutPrepareHeader()", result); + SetMMerror("waveOutPrepareHeader()", result); return (-1); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/audio/windx5/SDL_dx5audio.c --- a/src/audio/windx5/SDL_dx5audio.c Mon May 29 03:53:21 2006 +0000 +++ b/src/audio/windx5/SDL_dx5audio.c Mon May 29 04:04:35 2006 +0000 @@ -32,31 +32,31 @@ //#define USE_POSITION_NOTIFY /* DirectX function pointers for audio */ -HRESULT (WINAPI * DSoundCreate) (LPGUID, LPDIRECTSOUND *, LPUNKNOWN); +HRESULT(WINAPI * DSoundCreate) (LPGUID, LPDIRECTSOUND *, LPUNKNOWN); /* Audio driver functions */ -static int DX5_OpenAudio (_THIS, SDL_AudioSpec * spec); -static void DX5_ThreadInit (_THIS); -static void DX5_WaitAudio_BusyWait (_THIS); +static int DX5_OpenAudio(_THIS, SDL_AudioSpec * spec); +static void DX5_ThreadInit(_THIS); +static void DX5_WaitAudio_BusyWait(_THIS); #ifdef USE_POSITION_NOTIFY -static void DX6_WaitAudio_EventWait (_THIS); +static void DX6_WaitAudio_EventWait(_THIS); #endif -static void DX5_PlayAudio (_THIS); -static Uint8 *DX5_GetAudioBuf (_THIS); -static void DX5_WaitDone (_THIS); -static void DX5_CloseAudio (_THIS); +static void DX5_PlayAudio(_THIS); +static Uint8 *DX5_GetAudioBuf(_THIS); +static void DX5_WaitDone(_THIS); +static void DX5_CloseAudio(_THIS); /* Audio driver bootstrap functions */ static int -Audio_Available (void) +Audio_Available(void) { HINSTANCE DSoundDLL; int dsound_ok; /* Version check DSOUND.DLL (Is DirectX okay?) */ dsound_ok = 0; - DSoundDLL = LoadLibrary (TEXT ("DSOUND.DLL")); + DSoundDLL = LoadLibrary(TEXT("DSOUND.DLL")); if (DSoundDLL != NULL) { /* We just use basic DirectSound, we're okay */ /* Yay! */ @@ -66,8 +66,8 @@ in the audio - it sounds terrible. Punt for now. */ OSVERSIONINFO ver; - ver.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); - GetVersionEx (&ver); + ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&ver); switch (ver.dwPlatformId) { case VER_PLATFORM_WIN32_NT: if (ver.dwMajorVersion > 4) { @@ -88,13 +88,12 @@ * to fall back to the DIB driver. */ if (dsound_ok) { /* DirectSoundCaptureCreate was added in DX5 */ - if (!GetProcAddress - (DSoundDLL, TEXT ("DirectSoundCaptureCreate"))) + if (!GetProcAddress(DSoundDLL, TEXT("DirectSoundCaptureCreate"))) dsound_ok = 0; } /* Clean up.. */ - FreeLibrary (DSoundDLL); + FreeLibrary(DSoundDLL); } return (dsound_ok); } @@ -103,67 +102,67 @@ static HINSTANCE DSoundDLL = NULL; static void -DX5_Unload (void) +DX5_Unload(void) { if (DSoundDLL != NULL) { - FreeLibrary (DSoundDLL); + FreeLibrary(DSoundDLL); DSoundCreate = NULL; DSoundDLL = NULL; } } static int -DX5_Load (void) +DX5_Load(void) { int status; - DX5_Unload (); - DSoundDLL = LoadLibrary (TEXT ("DSOUND.DLL")); + DX5_Unload(); + DSoundDLL = LoadLibrary(TEXT("DSOUND.DLL")); if (DSoundDLL != NULL) { - DSoundCreate = (void *) GetProcAddress (DSoundDLL, - TEXT ("DirectSoundCreate")); + DSoundCreate = (void *) GetProcAddress(DSoundDLL, + TEXT("DirectSoundCreate")); } if (DSoundDLL && DSoundCreate) { status = 0; } else { - DX5_Unload (); + DX5_Unload(); status = -1; } return status; } static void -Audio_DeleteDevice (SDL_AudioDevice * device) +Audio_DeleteDevice(SDL_AudioDevice * device) { - DX5_Unload (); - SDL_free (device->hidden); - SDL_free (device); + DX5_Unload(); + SDL_free(device->hidden); + SDL_free(device); } static SDL_AudioDevice * -Audio_CreateDevice (int devindex) +Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; /* Load DirectX */ - if (DX5_Load () < 0) { + if (DX5_Load() < 0) { return (NULL); } /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice)); + this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = DX5_OpenAudio; @@ -185,7 +184,7 @@ }; static void -SetDSerror (const char *function, int code) +SetDSerror(const char *function, int code) { static const char *error; static char errbuf[1024]; @@ -227,15 +226,15 @@ error = "Function not supported"; break; default: - SDL_snprintf (errbuf, SDL_arraysize (errbuf), - "%s: Unknown DirectSound error: 0x%x", function, code); + SDL_snprintf(errbuf, SDL_arraysize(errbuf), + "%s: Unknown DirectSound error: 0x%x", function, code); break; } if (!errbuf[0]) { - SDL_snprintf (errbuf, SDL_arraysize (errbuf), "%s: %s", function, - error); + SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, + error); } - SDL_SetError ("%s", errbuf); + SDL_SetError("%s", errbuf); return; } @@ -243,19 +242,19 @@ static HWND mainwin = NULL; /* */ void -DX5_SoundFocus (HWND hwnd) +DX5_SoundFocus(HWND hwnd) { mainwin = hwnd; } static void -DX5_ThreadInit (_THIS) +DX5_ThreadInit(_THIS) { - SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST); + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); } static void -DX5_WaitAudio_BusyWait (_THIS) +DX5_WaitAudio_BusyWait(_THIS) { DWORD status; DWORD cursor, junk; @@ -264,13 +263,13 @@ /* Semi-busy wait, since we have no way of getting play notification on a primary mixing buffer located in hardware (DirectX 5.0) */ - result = IDirectSoundBuffer_GetCurrentPosition (mixbuf, &cursor, &junk); + result = IDirectSoundBuffer_GetCurrentPosition(mixbuf, &cursor, &junk); if (result != DS_OK) { if (result == DSERR_BUFFERLOST) { - IDirectSoundBuffer_Restore (mixbuf); + IDirectSoundBuffer_Restore(mixbuf); } #ifdef DEBUG_SOUND - SetDSerror ("DirectSound GetCurrentPosition", result); + SetDSerror("DirectSound GetCurrentPosition", result); #endif return; } @@ -278,33 +277,33 @@ while (cursor == playing) { /* FIXME: find out how much time is left and sleep that long */ - SDL_Delay (10); + SDL_Delay(10); /* Try to restore a lost sound buffer */ - IDirectSoundBuffer_GetStatus (mixbuf, &status); + IDirectSoundBuffer_GetStatus(mixbuf, &status); if ((status & DSBSTATUS_BUFFERLOST)) { - IDirectSoundBuffer_Restore (mixbuf); - IDirectSoundBuffer_GetStatus (mixbuf, &status); + IDirectSoundBuffer_Restore(mixbuf); + IDirectSoundBuffer_GetStatus(mixbuf, &status); if ((status & DSBSTATUS_BUFFERLOST)) { break; } } if (!(status & DSBSTATUS_PLAYING)) { - result = IDirectSoundBuffer_Play (mixbuf, 0, 0, DSBPLAY_LOOPING); + result = IDirectSoundBuffer_Play(mixbuf, 0, 0, DSBPLAY_LOOPING); if (result == DS_OK) { continue; } #ifdef DEBUG_SOUND - SetDSerror ("DirectSound Play", result); + SetDSerror("DirectSound Play", result); #endif return; } /* Find out where we are playing */ - result = IDirectSoundBuffer_GetCurrentPosition (mixbuf, - &cursor, &junk); + result = IDirectSoundBuffer_GetCurrentPosition(mixbuf, + &cursor, &junk); if (result != DS_OK) { - SetDSerror ("DirectSound GetCurrentPosition", result); + SetDSerror("DirectSound GetCurrentPosition", result); return; } cursor /= mixlen; @@ -313,45 +312,45 @@ #ifdef USE_POSITION_NOTIFY static void -DX6_WaitAudio_EventWait (_THIS) +DX6_WaitAudio_EventWait(_THIS) { DWORD status; HRESULT result; /* Try to restore a lost sound buffer */ - IDirectSoundBuffer_GetStatus (mixbuf, &status); + IDirectSoundBuffer_GetStatus(mixbuf, &status); if ((status & DSBSTATUS_BUFFERLOST)) { - IDirectSoundBuffer_Restore (mixbuf); - IDirectSoundBuffer_GetStatus (mixbuf, &status); + IDirectSoundBuffer_Restore(mixbuf); + IDirectSoundBuffer_GetStatus(mixbuf, &status); if ((status & DSBSTATUS_BUFFERLOST)) { return; } } if (!(status & DSBSTATUS_PLAYING)) { - result = IDirectSoundBuffer_Play (mixbuf, 0, 0, DSBPLAY_LOOPING); + result = IDirectSoundBuffer_Play(mixbuf, 0, 0, DSBPLAY_LOOPING); if (result != DS_OK) { #ifdef DEBUG_SOUND - SetDSerror ("DirectSound Play", result); + SetDSerror("DirectSound Play", result); #endif return; } } - WaitForSingleObject (audio_event, INFINITE); + WaitForSingleObject(audio_event, INFINITE); } #endif /* USE_POSITION_NOTIFY */ static void -DX5_PlayAudio (_THIS) +DX5_PlayAudio(_THIS) { /* Unlock the buffer, allowing it to play */ if (locked_buf) { - IDirectSoundBuffer_Unlock (mixbuf, locked_buf, mixlen, NULL, 0); + IDirectSoundBuffer_Unlock(mixbuf, locked_buf, mixlen, NULL, 0); } } static Uint8 * -DX5_GetAudioBuf (_THIS) +DX5_GetAudioBuf(_THIS) { DWORD cursor, junk; HRESULT result; @@ -359,14 +358,14 @@ /* Figure out which blocks to fill next */ locked_buf = NULL; - result = IDirectSoundBuffer_GetCurrentPosition (mixbuf, &cursor, &junk); + result = IDirectSoundBuffer_GetCurrentPosition(mixbuf, &cursor, &junk); if (result == DSERR_BUFFERLOST) { - IDirectSoundBuffer_Restore (mixbuf); - result = IDirectSoundBuffer_GetCurrentPosition (mixbuf, - &cursor, &junk); + IDirectSoundBuffer_Restore(mixbuf); + result = IDirectSoundBuffer_GetCurrentPosition(mixbuf, + &cursor, &junk); } if (result != DS_OK) { - SetDSerror ("DirectSound GetCurrentPosition", result); + SetDSerror("DirectSound GetCurrentPosition", result); return (NULL); } cursor /= mixlen; @@ -375,53 +374,53 @@ cursor *= mixlen; /* Lock the audio buffer */ - result = IDirectSoundBuffer_Lock (mixbuf, cursor, mixlen, - (LPVOID *) & locked_buf, &rawlen, NULL, - &junk, 0); + result = IDirectSoundBuffer_Lock(mixbuf, cursor, mixlen, + (LPVOID *) & locked_buf, &rawlen, NULL, + &junk, 0); if (result == DSERR_BUFFERLOST) { - IDirectSoundBuffer_Restore (mixbuf); - result = IDirectSoundBuffer_Lock (mixbuf, cursor, mixlen, - (LPVOID *) & locked_buf, &rawlen, - NULL, &junk, 0); + IDirectSoundBuffer_Restore(mixbuf); + result = IDirectSoundBuffer_Lock(mixbuf, cursor, mixlen, + (LPVOID *) & locked_buf, &rawlen, + NULL, &junk, 0); } if (result != DS_OK) { - SetDSerror ("DirectSound Lock", result); + SetDSerror("DirectSound Lock", result); return (NULL); } return (locked_buf); } static void -DX5_WaitDone (_THIS) +DX5_WaitDone(_THIS) { Uint8 *stream; /* Wait for the playing chunk to finish */ - stream = this->GetAudioBuf (this); + stream = this->GetAudioBuf(this); if (stream != NULL) { - SDL_memset (stream, silence, mixlen); - this->PlayAudio (this); + SDL_memset(stream, silence, mixlen); + this->PlayAudio(this); } - this->WaitAudio (this); + this->WaitAudio(this); /* Stop the looping sound buffer */ - IDirectSoundBuffer_Stop (mixbuf); + IDirectSoundBuffer_Stop(mixbuf); } static void -DX5_CloseAudio (_THIS) +DX5_CloseAudio(_THIS) { if (sound != NULL) { if (mixbuf != NULL) { /* Clean up the audio buffer */ - IDirectSoundBuffer_Release (mixbuf); + IDirectSoundBuffer_Release(mixbuf); mixbuf = NULL; } if (audio_event != NULL) { - CloseHandle (audio_event); + CloseHandle(audio_event); audio_event = NULL; } - IDirectSound_Release (sound); + IDirectSound_Release(sound); sound = NULL; } } @@ -431,9 +430,9 @@ number of audio chunks available in the created buffer. */ static int -CreatePrimary (LPDIRECTSOUND sndObj, HWND focus, - LPDIRECTSOUNDBUFFER * sndbuf, WAVEFORMATEX * wavefmt, - Uint32 chunksize) +CreatePrimary(LPDIRECTSOUND sndObj, HWND focus, + LPDIRECTSOUNDBUFFER * sndbuf, WAVEFORMATEX * wavefmt, + Uint32 chunksize) { HRESULT result; DSBUFFERDESC format; @@ -441,40 +440,40 @@ int numchunks; /* Try to set primary mixing privileges */ - result = IDirectSound_SetCooperativeLevel (sndObj, focus, - DSSCL_WRITEPRIMARY); + result = IDirectSound_SetCooperativeLevel(sndObj, focus, + DSSCL_WRITEPRIMARY); if (result != DS_OK) { #ifdef DEBUG_SOUND - SetDSerror ("DirectSound SetCooperativeLevel", result); + SetDSerror("DirectSound SetCooperativeLevel", result); #endif return (-1); } /* Try to create the primary buffer */ - SDL_memset (&format, 0, sizeof (format)); - format.dwSize = sizeof (format); + SDL_memset(&format, 0, sizeof(format)); + format.dwSize = sizeof(format); format.dwFlags = (DSBCAPS_PRIMARYBUFFER | DSBCAPS_GETCURRENTPOSITION2); format.dwFlags |= DSBCAPS_STICKYFOCUS; #ifdef USE_POSITION_NOTIFY format.dwFlags |= DSBCAPS_CTRLPOSITIONNOTIFY; #endif - result = IDirectSound_CreateSoundBuffer (sndObj, &format, sndbuf, NULL); + result = IDirectSound_CreateSoundBuffer(sndObj, &format, sndbuf, NULL); if (result != DS_OK) { #ifdef DEBUG_SOUND - SetDSerror ("DirectSound CreateSoundBuffer", result); + SetDSerror("DirectSound CreateSoundBuffer", result); #endif return (-1); } /* Check the size of the fragment buffer */ - SDL_memset (&caps, 0, sizeof (caps)); - caps.dwSize = sizeof (caps); - result = IDirectSoundBuffer_GetCaps (*sndbuf, &caps); + SDL_memset(&caps, 0, sizeof(caps)); + caps.dwSize = sizeof(caps); + result = IDirectSoundBuffer_GetCaps(*sndbuf, &caps); if (result != DS_OK) { #ifdef DEBUG_SOUND - SetDSerror ("DirectSound GetCaps", result); + SetDSerror("DirectSound GetCaps", result); #endif - IDirectSoundBuffer_Release (*sndbuf); + IDirectSoundBuffer_Release(*sndbuf); return (-1); } if ((chunksize > caps.dwBufferBytes) || @@ -483,7 +482,7 @@ -- this hopefully doesn't happen when 'chunksize' is a power of 2. */ - IDirectSoundBuffer_Release (*sndbuf); + IDirectSoundBuffer_Release(*sndbuf); SDL_SetError ("Primary buffer size is: %d, cannot break it into chunks of %d bytes\n", caps.dwBufferBytes, chunksize); @@ -492,12 +491,12 @@ numchunks = (caps.dwBufferBytes / chunksize); /* Set the primary audio format */ - result = IDirectSoundBuffer_SetFormat (*sndbuf, wavefmt); + result = IDirectSoundBuffer_SetFormat(*sndbuf, wavefmt); if (result != DS_OK) { #ifdef DEBUG_SOUND - SetDSerror ("DirectSound SetFormat", result); + SetDSerror("DirectSound SetFormat", result); #endif - IDirectSoundBuffer_Release (*sndbuf); + IDirectSoundBuffer_Release(*sndbuf); return (-1); } return (numchunks); @@ -508,9 +507,9 @@ number of audio chunks available in the created buffer. */ static int -CreateSecondary (LPDIRECTSOUND sndObj, HWND focus, - LPDIRECTSOUNDBUFFER * sndbuf, WAVEFORMATEX * wavefmt, - Uint32 chunksize) +CreateSecondary(LPDIRECTSOUND sndObj, HWND focus, + LPDIRECTSOUNDBUFFER * sndbuf, WAVEFORMATEX * wavefmt, + Uint32 chunksize) { const int numchunks = 2; HRESULT result; @@ -520,23 +519,23 @@ /* Try to set primary mixing privileges */ if (focus) { - result = IDirectSound_SetCooperativeLevel (sndObj, - focus, DSSCL_PRIORITY); + result = IDirectSound_SetCooperativeLevel(sndObj, + focus, DSSCL_PRIORITY); } else { - result = IDirectSound_SetCooperativeLevel (sndObj, - GetDesktopWindow (), - DSSCL_NORMAL); + result = IDirectSound_SetCooperativeLevel(sndObj, + GetDesktopWindow(), + DSSCL_NORMAL); } if (result != DS_OK) { #ifdef DEBUG_SOUND - SetDSerror ("DirectSound SetCooperativeLevel", result); + SetDSerror("DirectSound SetCooperativeLevel", result); #endif return (-1); } /* Try to create the secondary buffer */ - SDL_memset (&format, 0, sizeof (format)); - format.dwSize = sizeof (format); + SDL_memset(&format, 0, sizeof(format)); + format.dwSize = sizeof(format); format.dwFlags = DSBCAPS_GETCURRENTPOSITION2; #ifdef USE_POSITION_NOTIFY format.dwFlags |= DSBCAPS_CTRLPOSITIONNOTIFY; @@ -549,34 +548,34 @@ format.dwBufferBytes = numchunks * chunksize; if ((format.dwBufferBytes < DSBSIZE_MIN) || (format.dwBufferBytes > DSBSIZE_MAX)) { - SDL_SetError ("Sound buffer size must be between %d and %d", - DSBSIZE_MIN / numchunks, DSBSIZE_MAX / numchunks); + SDL_SetError("Sound buffer size must be between %d and %d", + DSBSIZE_MIN / numchunks, DSBSIZE_MAX / numchunks); return (-1); } format.dwReserved = 0; format.lpwfxFormat = wavefmt; - result = IDirectSound_CreateSoundBuffer (sndObj, &format, sndbuf, NULL); + result = IDirectSound_CreateSoundBuffer(sndObj, &format, sndbuf, NULL); if (result != DS_OK) { - SetDSerror ("DirectSound CreateSoundBuffer", result); + SetDSerror("DirectSound CreateSoundBuffer", result); return (-1); } - IDirectSoundBuffer_SetFormat (*sndbuf, wavefmt); + IDirectSoundBuffer_SetFormat(*sndbuf, wavefmt); /* Silence the initial audio buffer */ - result = IDirectSoundBuffer_Lock (*sndbuf, 0, format.dwBufferBytes, - (LPVOID *) & pvAudioPtr1, - &dwAudioBytes1, - (LPVOID *) & pvAudioPtr2, - &dwAudioBytes2, DSBLOCK_ENTIREBUFFER); + result = IDirectSoundBuffer_Lock(*sndbuf, 0, format.dwBufferBytes, + (LPVOID *) & pvAudioPtr1, + &dwAudioBytes1, + (LPVOID *) & pvAudioPtr2, + &dwAudioBytes2, DSBLOCK_ENTIREBUFFER); if (result == DS_OK) { if (wavefmt->wBitsPerSample == 8) { - SDL_memset (pvAudioPtr1, 0x80, dwAudioBytes1); + SDL_memset(pvAudioPtr1, 0x80, dwAudioBytes1); } else { - SDL_memset (pvAudioPtr1, 0x00, dwAudioBytes1); + SDL_memset(pvAudioPtr1, 0x00, dwAudioBytes1); } - IDirectSoundBuffer_Unlock (*sndbuf, - (LPVOID) pvAudioPtr1, dwAudioBytes1, - (LPVOID) pvAudioPtr2, dwAudioBytes2); + IDirectSoundBuffer_Unlock(*sndbuf, + (LPVOID) pvAudioPtr1, dwAudioBytes1, + (LPVOID) pvAudioPtr2, dwAudioBytes2); } /* We're ready to go */ @@ -586,7 +585,7 @@ /* This function tries to set position notify events on the mixing buffer */ #ifdef USE_POSITION_NOTIFY static int -CreateAudioEvent (_THIS) +CreateAudioEvent(_THIS) { LPDIRECTSOUNDNOTIFY notify; DSBPOSITIONNOTIFY *notify_positions; @@ -598,23 +597,23 @@ notify = NULL; /* Query for the interface */ - result = IDirectSoundBuffer_QueryInterface (mixbuf, - &IID_IDirectSoundNotify, - (void *) ¬ify); + result = IDirectSoundBuffer_QueryInterface(mixbuf, + &IID_IDirectSoundNotify, + (void *) ¬ify); if (result != DS_OK) { goto done; } /* Allocate the notify structures */ - notify_positions = (DSBPOSITIONNOTIFY *) SDL_malloc (NUM_BUFFERS * - sizeof - (*notify_positions)); + notify_positions = (DSBPOSITIONNOTIFY *) SDL_malloc(NUM_BUFFERS * + sizeof + (*notify_positions)); if (notify_positions == NULL) { goto done; } /* Create the notify event */ - audio_event = CreateEvent (NULL, FALSE, FALSE, NULL); + audio_event = CreateEvent(NULL, FALSE, FALSE, NULL); if (audio_event == NULL) { goto done; } @@ -624,28 +623,28 @@ notify_positions[i].dwOffset = i * mixlen; notify_positions[i].hEventNotify = audio_event; } - result = IDirectSoundNotify_SetNotificationPositions (notify, - NUM_BUFFERS, - notify_positions); + result = IDirectSoundNotify_SetNotificationPositions(notify, + NUM_BUFFERS, + notify_positions); if (result == DS_OK) { retval = 0; } done: if (notify != NULL) { - IDirectSoundNotify_Release (notify); + IDirectSoundNotify_Release(notify); } return (retval); } #endif /* USE_POSITION_NOTIFY */ static int -DX5_OpenAudio (_THIS, SDL_AudioSpec * spec) +DX5_OpenAudio(_THIS, SDL_AudioSpec * spec) { HRESULT result; WAVEFORMATEX waveformat; /* Set basic WAVE format parameters */ - SDL_memset (&waveformat, 0, sizeof (waveformat)); + SDL_memset(&waveformat, 0, sizeof(waveformat)); waveformat.wFormatTag = WAVE_FORMAT_PCM; /* Determine the audio parameters from the AudioSpec */ @@ -663,7 +662,7 @@ waveformat.wBitsPerSample = 16; break; default: - SDL_SetError ("Unsupported audio format"); + SDL_SetError("Unsupported audio format"); return (-1); } waveformat.nChannels = spec->channels; @@ -674,12 +673,12 @@ waveformat.nSamplesPerSec * waveformat.nBlockAlign; /* Update the fragment size as size in bytes */ - SDL_CalculateAudioSpec (spec); + SDL_CalculateAudioSpec(spec); /* Open the audio device */ - result = DSoundCreate (NULL, &sound, NULL); + result = DSoundCreate(NULL, &sound, NULL); if (result != DS_OK) { - SetDSerror ("DirectSoundCreate", result); + SetDSerror("DirectSoundCreate", result); return (-1); } @@ -687,23 +686,23 @@ NUM_BUFFERS = -1; #ifdef USE_PRIMARY_BUFFER if (mainwin) { - NUM_BUFFERS = CreatePrimary (sound, mainwin, &mixbuf, - &waveformat, spec->size); + NUM_BUFFERS = CreatePrimary(sound, mainwin, &mixbuf, + &waveformat, spec->size); } #endif /* USE_PRIMARY_BUFFER */ if (NUM_BUFFERS < 0) { - NUM_BUFFERS = CreateSecondary (sound, mainwin, &mixbuf, - &waveformat, spec->size); + NUM_BUFFERS = CreateSecondary(sound, mainwin, &mixbuf, + &waveformat, spec->size); if (NUM_BUFFERS < 0) { return (-1); } #ifdef DEBUG_SOUND - fprintf (stderr, "Using secondary audio buffer\n"); + fprintf(stderr, "Using secondary audio buffer\n"); #endif } #ifdef DEBUG_SOUND else - fprintf (stderr, "Using primary audio buffer\n"); + fprintf(stderr, "Using primary audio buffer\n"); #endif /* The buffer will auto-start playing in DX5_WaitAudio() */ @@ -712,7 +711,7 @@ #ifdef USE_POSITION_NOTIFY /* See if we can use DirectX 6 event notification */ - if (CreateAudioEvent (this) == 0) { + if (CreateAudioEvent(this) == 0) { this->WaitAudio = DX6_WaitAudio_EventWait; } else { this->WaitAudio = DX5_WaitAudio_BusyWait; diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/SDL_cdrom.c --- a/src/cdrom/SDL_cdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/SDL_cdrom.c Mon May 29 04:04:35 2006 +0000 @@ -49,12 +49,12 @@ int SDL_numcds; int -SDL_CDROMInit (void) +SDL_CDROMInit(void) { int retval; SDL_numcds = 0; - retval = SDL_SYS_CDInit (); + retval = SDL_SYS_CDInit(); if (retval == 0) { SDL_cdinitted = 1; } @@ -64,7 +64,7 @@ /* Check to see if the CD-ROM subsystem has been initialized */ static int -CheckInit (int check_cdrom, SDL_CD ** cdrom) +CheckInit(int check_cdrom, SDL_CD ** cdrom) { int okay; @@ -72,63 +72,63 @@ if (check_cdrom && (*cdrom == NULL)) { *cdrom = default_cdrom; if (*cdrom == NULL) { - SDL_SetError ("CD-ROM not opened"); + SDL_SetError("CD-ROM not opened"); okay = 0; } } if (!SDL_cdinitted) { - SDL_SetError ("CD-ROM subsystem not initialized"); + SDL_SetError("CD-ROM subsystem not initialized"); } return (okay); } int -SDL_CDNumDrives (void) +SDL_CDNumDrives(void) { - if (!CheckInit (0, NULL)) { + if (!CheckInit(0, NULL)) { return (-1); } return (SDL_numcds); } const char * -SDL_CDName (int drive) +SDL_CDName(int drive) { - if (!CheckInit (0, NULL)) { + if (!CheckInit(0, NULL)) { return (NULL); } if (drive >= SDL_numcds) { - SDL_SetError ("Invalid CD-ROM drive index"); + SDL_SetError("Invalid CD-ROM drive index"); return (NULL); } if (SDL_CDcaps.Name) { - return (SDL_CDcaps.Name (drive)); + return (SDL_CDcaps.Name(drive)); } else { return (""); } } SDL_CD * -SDL_CDOpen (int drive) +SDL_CDOpen(int drive) { struct SDL_CD *cdrom; - if (!CheckInit (0, NULL)) { + if (!CheckInit(0, NULL)) { return (NULL); } if (drive >= SDL_numcds) { - SDL_SetError ("Invalid CD-ROM drive index"); + SDL_SetError("Invalid CD-ROM drive index"); return (NULL); } - cdrom = (SDL_CD *) SDL_malloc (sizeof (*cdrom)); + cdrom = (SDL_CD *) SDL_malloc(sizeof(*cdrom)); if (cdrom == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } - SDL_memset (cdrom, 0, sizeof (*cdrom)); - cdrom->id = SDL_CDcaps.Open (drive); + SDL_memset(cdrom, 0, sizeof(*cdrom)); + cdrom->id = SDL_CDcaps.Open(drive); if (cdrom->id < 0) { - SDL_free (cdrom); + SDL_free(cdrom); return (NULL); } default_cdrom = cdrom; @@ -136,14 +136,14 @@ } CDstatus -SDL_CDStatus (SDL_CD * cdrom) +SDL_CDStatus(SDL_CD * cdrom) { CDstatus status; int i; Uint32 position; /* Check if the CD-ROM subsystem has been initialized */ - if (!CheckInit (1, &cdrom)) { + if (!CheckInit(1, &cdrom)) { return (CD_ERROR); } @@ -151,13 +151,13 @@ cdrom->numtracks = 0; cdrom->cur_track = 0; cdrom->cur_frame = 0; - status = SDL_CDcaps.Status (cdrom, &i); + status = SDL_CDcaps.Status(cdrom, &i); position = (Uint32) i; cdrom->status = status; /* Get the table of contents, if there's a CD available */ - if (CD_INDRIVE (status)) { - if (SDL_CDcaps.GetTOC (cdrom) < 0) { + if (CD_INDRIVE(status)) { + if (SDL_CDcaps.GetTOC(cdrom) < 0) { status = CD_ERROR; } /* If the drive is playing, get current play position */ @@ -166,9 +166,9 @@ /* Keep looking */ ; } #ifdef DEBUG_CDROM - fprintf (stderr, - "Current position: %d, track = %d (offset is %d)\n", - position, i - 1, cdrom->track[i - 1].offset); + fprintf(stderr, + "Current position: %d, track = %d (offset is %d)\n", + position, i - 1, cdrom->track[i - 1].offset); #endif cdrom->cur_track = i - 1; position -= cdrom->track[cdrom->cur_track].offset; @@ -179,20 +179,20 @@ } int -SDL_CDPlayTracks (SDL_CD * cdrom, - int strack, int sframe, int ntracks, int nframes) +SDL_CDPlayTracks(SDL_CD * cdrom, + int strack, int sframe, int ntracks, int nframes) { int etrack, eframe; int start, length; /* Check if the CD-ROM subsystem has been initialized */ - if (!CheckInit (1, &cdrom)) { + if (!CheckInit(1, &cdrom)) { return (CD_ERROR); } /* Determine the starting and ending tracks */ if ((strack < 0) || (strack >= cdrom->numtracks)) { - SDL_SetError ("Invalid starting track"); + SDL_SetError("Invalid starting track"); return (CD_ERROR); } if (!ntracks && !nframes) { @@ -207,7 +207,7 @@ } } if (etrack > cdrom->numtracks) { - SDL_SetError ("Invalid play length"); + SDL_SetError("Invalid play length"); return (CD_ERROR); } @@ -217,7 +217,7 @@ ++strack; } if (sframe >= (int) cdrom->track[strack].length) { - SDL_SetError ("Invalid starting frame for track %d", strack); + SDL_SetError("Invalid starting frame for track %d", strack); return (CD_ERROR); } while ((etrack > strack) && @@ -225,7 +225,7 @@ --etrack; } if (eframe > (int) cdrom->track[etrack].length) { - SDL_SetError ("Invalid ending frame for track %d", etrack); + SDL_SetError("Invalid ending frame for track %d", etrack); return (CD_ERROR); } @@ -242,37 +242,37 @@ /* Play! */ #ifdef DEBUG_CDROM - fprintf (stderr, "Playing %d frames at offset %d\n", length, start); + fprintf(stderr, "Playing %d frames at offset %d\n", length, start); #endif - return (SDL_CDcaps.Play (cdrom, start, length)); + return (SDL_CDcaps.Play(cdrom, start, length)); } int -SDL_CDPlay (SDL_CD * cdrom, int sframe, int length) +SDL_CDPlay(SDL_CD * cdrom, int sframe, int length) { /* Check if the CD-ROM subsystem has been initialized */ - if (!CheckInit (1, &cdrom)) { + if (!CheckInit(1, &cdrom)) { return (CD_ERROR); } - return (SDL_CDcaps.Play (cdrom, sframe, length)); + return (SDL_CDcaps.Play(cdrom, sframe, length)); } int -SDL_CDPause (SDL_CD * cdrom) +SDL_CDPause(SDL_CD * cdrom) { CDstatus status; int retval; /* Check if the CD-ROM subsystem has been initialized */ - if (!CheckInit (1, &cdrom)) { + if (!CheckInit(1, &cdrom)) { return (CD_ERROR); } - status = SDL_CDcaps.Status (cdrom, NULL); + status = SDL_CDcaps.Status(cdrom, NULL); switch (status) { case CD_PLAYING: - retval = SDL_CDcaps.Pause (cdrom); + retval = SDL_CDcaps.Pause(cdrom); break; default: retval = 0; @@ -282,20 +282,20 @@ } int -SDL_CDResume (SDL_CD * cdrom) +SDL_CDResume(SDL_CD * cdrom) { CDstatus status; int retval; /* Check if the CD-ROM subsystem has been initialized */ - if (!CheckInit (1, &cdrom)) { + if (!CheckInit(1, &cdrom)) { return (CD_ERROR); } - status = SDL_CDcaps.Status (cdrom, NULL); + status = SDL_CDcaps.Status(cdrom, NULL); switch (status) { case CD_PAUSED: - retval = SDL_CDcaps.Resume (cdrom); + retval = SDL_CDcaps.Resume(cdrom); default: retval = 0; break; @@ -304,21 +304,21 @@ } int -SDL_CDStop (SDL_CD * cdrom) +SDL_CDStop(SDL_CD * cdrom) { CDstatus status; int retval; /* Check if the CD-ROM subsystem has been initialized */ - if (!CheckInit (1, &cdrom)) { + if (!CheckInit(1, &cdrom)) { return (CD_ERROR); } - status = SDL_CDcaps.Status (cdrom, NULL); + status = SDL_CDcaps.Status(cdrom, NULL); switch (status) { case CD_PLAYING: case CD_PAUSED: - retval = SDL_CDcaps.Stop (cdrom); + retval = SDL_CDcaps.Stop(cdrom); default: retval = 0; break; @@ -327,31 +327,31 @@ } int -SDL_CDEject (SDL_CD * cdrom) +SDL_CDEject(SDL_CD * cdrom) { /* Check if the CD-ROM subsystem has been initialized */ - if (!CheckInit (1, &cdrom)) { + if (!CheckInit(1, &cdrom)) { return (CD_ERROR); } - return (SDL_CDcaps.Eject (cdrom)); + return (SDL_CDcaps.Eject(cdrom)); } void -SDL_CDClose (SDL_CD * cdrom) +SDL_CDClose(SDL_CD * cdrom) { /* Check if the CD-ROM subsystem has been initialized */ - if (!CheckInit (1, &cdrom)) { + if (!CheckInit(1, &cdrom)) { return; } - SDL_CDcaps.Close (cdrom); - SDL_free (cdrom); + SDL_CDcaps.Close(cdrom); + SDL_free(cdrom); default_cdrom = NULL; } void -SDL_CDROMQuit (void) +SDL_CDROMQuit(void) { - SDL_SYS_CDQuit (); + SDL_SYS_CDQuit(); SDL_cdinitted = 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/SDL_syscdrom.h --- a/src/cdrom/SDL_syscdrom.h Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/SDL_syscdrom.h Mon May 29 04:04:35 2006 +0000 @@ -41,7 +41,7 @@ /* Return the current status and play position, in frames, of the drive. 'position' may be NULL, and if so, should be ignored. */ - CDstatus (*Status) (SDL_CD * cdrom, int *position); + CDstatus(*Status) (SDL_CD * cdrom, int *position); /* Play from frame 'start' to 'start+len' */ int (*Play) (SDL_CD * cdrom, int start, int len); @@ -70,8 +70,8 @@ * drives. Drive 0 should be the system default CD-ROM. * It should return 0, or -1 on an unrecoverable fatal error. */ -extern int SDL_SYS_CDInit (void); +extern int SDL_SYS_CDInit(void); /* Function to perform any system-specific CD-ROM related cleanup */ -extern void SDL_SYS_CDQuit (void); +extern void SDL_SYS_CDQuit(void); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/aix/SDL_syscdrom.c --- a/src/cdrom/aix/SDL_syscdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/aix/SDL_syscdrom.c Mon May 29 04:04:35 2006 +0000 @@ -54,21 +54,21 @@ static dev_t SDL_cdmode[MAX_DRIVES]; /* The system-dependent CD control functions */ -static const char *SDL_SYS_CDName (int drive); -static int SDL_SYS_CDOpen (int drive); -static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); -static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); -static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); -static int SDL_SYS_CDPause (SDL_CD * cdrom); -static int SDL_SYS_CDResume (SDL_CD * cdrom); -static int SDL_SYS_CDStop (SDL_CD * cdrom); -static int SDL_SYS_CDEject (SDL_CD * cdrom); -static void SDL_SYS_CDClose (SDL_CD * cdrom); -static int SDL_SYS_CDioctl (int id, int command, void *arg); +static const char *SDL_SYS_CDName(int drive); +static int SDL_SYS_CDOpen(int drive); +static int SDL_SYS_CDGetTOC(SDL_CD * cdrom); +static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position); +static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length); +static int SDL_SYS_CDPause(SDL_CD * cdrom); +static int SDL_SYS_CDResume(SDL_CD * cdrom); +static int SDL_SYS_CDStop(SDL_CD * cdrom); +static int SDL_SYS_CDEject(SDL_CD * cdrom); +static void SDL_SYS_CDClose(SDL_CD * cdrom); +static int SDL_SYS_CDioctl(int id, int command, void *arg); /* Check a drive to see if it is a CD-ROM */ static int -CheckDrive (char *drive, struct stat *stbuf) +CheckDrive(char *drive, struct stat *stbuf) { int is_cd; int cdfd; @@ -76,16 +76,16 @@ struct devinfo info; /* If it doesn't exist, return -1 */ - if (stat (drive, stbuf) < 0) { + if (stat(drive, stbuf) < 0) { return -1; } /* If it does exist, verify that it's an available CD-ROM */ is_cd = 0; - if (S_ISCHR (stbuf->st_mode) || S_ISBLK (stbuf->st_mode)) { - cdfd = open (drive, (O_RDONLY | O_EXCL | O_NONBLOCK), 0); + if (S_ISCHR(stbuf->st_mode) || S_ISBLK(stbuf->st_mode)) { + cdfd = open(drive, (O_RDONLY | O_EXCL | O_NONBLOCK), 0); if (cdfd >= 0) { - ret = SDL_SYS_CDioctl (cdfd, IOCINFO, &info); + ret = SDL_SYS_CDioctl(cdfd, IOCINFO, &info); if (ret < 0) { /* Some kind of error */ is_cd = 0; @@ -96,12 +96,12 @@ is_cd = 0; } } - close (cdfd); + close(cdfd); } #ifdef DEBUG_CDROM else { - fprintf (stderr, "Could not open drive %s (%s)\n", drive, - strerror (errno)); + fprintf(stderr, "Could not open drive %s (%s)\n", drive, + strerror(errno)); } #endif } @@ -110,7 +110,7 @@ /* Add a CD-ROM drive to our list of valid drives */ static void -AddDrive (char *drive, struct stat *stbuf) +AddDrive(char *drive, struct stat *stbuf) { int i; @@ -121,8 +121,8 @@ for (i = 0; i < SDL_numcds; ++i) { if (stbuf->st_rdev == SDL_cdmode[i]) { #ifdef DEBUG_CDROM - fprintf (stderr, "Duplicate drive detected: %s == %s\n", - drive, SDL_cdlist[i]); + fprintf(stderr, "Duplicate drive detected: %s == %s\n", + drive, SDL_cdlist[i]); #endif return; } @@ -130,54 +130,54 @@ /* Add this drive to our list */ i = SDL_numcds; - SDL_cdlist[i] = SDL_strdup (drive); + SDL_cdlist[i] = SDL_strdup(drive); if (SDL_cdlist[i] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return; } SDL_cdmode[i] = stbuf->st_rdev; ++SDL_numcds; #ifdef DEBUG_CDROM - fprintf (stderr, "Added CD-ROM drive: %s\n", drive); + fprintf(stderr, "Added CD-ROM drive: %s\n", drive); #endif } } static void -CheckMounts () +CheckMounts() { char *buffer; int bufsz; struct vmount *ptr; int ret; - buffer = (char *) SDL_malloc (10); + buffer = (char *) SDL_malloc(10); bufsz = 10; if (buffer == NULL) { - fprintf (stderr, - "Could not allocate 10 bytes in aix/SDL_syscdrom.c:CheckMounts\n"); - exit (-10); + fprintf(stderr, + "Could not allocate 10 bytes in aix/SDL_syscdrom.c:CheckMounts\n"); + exit(-10); } do { /* mntctrl() returns an array of all mounted filesystems */ - ret = mntctl (MCTL_QUERY, bufsz, buffer); + ret = mntctl(MCTL_QUERY, bufsz, buffer); if (ret == 0) { /* Buffer was too small, realloc. */ bufsz = *(int *) buffer; /* Required size is in first word. */ /* (whatever a word is in AIX 4.3.3) */ /* int seems to be OK in 32bit mode. */ - SDL_free (buffer); - buffer = (char *) SDL_malloc (bufsz); + SDL_free(buffer); + buffer = (char *) SDL_malloc(bufsz); if (buffer == NULL) { - fprintf (stderr, - "Could not allocate %d bytes in aix/SDL_syscdrom.c:CheckMounts\n", - bufsz); - exit (-10); + fprintf(stderr, + "Could not allocate %d bytes in aix/SDL_syscdrom.c:CheckMounts\n", + bufsz); + exit(-10); } } else if (ret < 0) { #ifdef DEBUG_CDROM - fprintf (stderr, "Error reading vmount structures\n"); + fprintf(stderr, "Error reading vmount structures\n"); #endif return; } @@ -185,7 +185,7 @@ while (ret == 0); #ifdef DEBUG_CDROM - fprintf (stderr, "Read %d vmount structures\n", ret); + fprintf(stderr, "Read %d vmount structures\n", ret); #endif ptr = (struct vmount *) buffer; do { @@ -197,12 +197,12 @@ text = (char *) ptr + ptr->vmt_data[VMT_OBJECT].vmt_off; #ifdef DEBUG_CDROM - fprintf (stderr, - "Checking mount path: %s mounted on %s\n", text, - (char *) ptr + ptr->vmt_data[VMT_STUB].vmt_off); + fprintf(stderr, + "Checking mount path: %s mounted on %s\n", text, + (char *) ptr + ptr->vmt_data[VMT_STUB].vmt_off); #endif - if (CheckDrive (text, &stbuf) > 0) { - AddDrive (text, &stbuf); + if (CheckDrive(text, &stbuf) > 0) { + AddDrive(text, &stbuf); } } break; @@ -214,11 +214,11 @@ } while (ret > 0); - free (buffer); + free(buffer); } static int -CheckNonmounts () +CheckNonmounts() { #ifdef _THREAD_SAFE AFILE_t fsFile = NULL; @@ -227,29 +227,29 @@ struct fstab entry; struct stat stbuf; - ret = setfsent_r (&fsFile, &passNo); + ret = setfsent_r(&fsFile, &passNo); if (ret != 0) return -1; do { - ret = getfsent_r (&entry, &fsFile, &passNo); + ret = getfsent_r(&entry, &fsFile, &passNo); if (ret == 0) { - char *l = SDL_strrchr (entry.fs_spec, '/'); + char *l = SDL_strrchr(entry.fs_spec, '/'); if (l != NULL) { - if (!SDL_strncmp ("cd", ++l, 2)) { + if (!SDL_strncmp("cd", ++l, 2)) { #ifdef DEBUG_CDROM - fprintf (stderr, - "Found unmounted CD ROM drive with device name %s\n", - entry.fs_spec); + fprintf(stderr, + "Found unmounted CD ROM drive with device name %s\n", + entry.fs_spec); #endif - if (CheckDrive (entry.fs_spec, &stbuf) > 0) { - AddDrive (entry.fs_spec, &stbuf); + if (CheckDrive(entry.fs_spec, &stbuf) > 0) { + AddDrive(entry.fs_spec, &stbuf); } } } } } while (ret == 0); - ret = endfsent_r (&fsFile); + ret = endfsent_r(&fsFile); if (ret != 0) return -1; return 0; @@ -257,32 +257,32 @@ struct fstab *entry; struct stat stbuf; - setfsent (); + setfsent(); do { - entry = getfsent (); + entry = getfsent(); if (entry != NULL) { - char *l = SDL_strrchr (entry->fs_spec, '/'); + char *l = SDL_strrchr(entry->fs_spec, '/'); if (l != NULL) { - if (!SDL_strncmp ("cd", ++l, 2)) { + if (!SDL_strncmp("cd", ++l, 2)) { #ifdef DEBUG_CDROM - fprintf (stderr, - "Found unmounted CD ROM drive with device name %s", - entry->fs_spec); + fprintf(stderr, + "Found unmounted CD ROM drive with device name %s", + entry->fs_spec); #endif - if (CheckDrive (entry->fs_spec, &stbuf) > 0) { - AddDrive (entry->fs_spec, &stbuf); + if (CheckDrive(entry->fs_spec, &stbuf) > 0) { + AddDrive(entry->fs_spec, &stbuf); } } } } } while (entry != NULL); - endfsent (); + endfsent(); #endif } int -SDL_SYS_CDInit (void) +SDL_SYS_CDInit(void) { char *SDLcdrom; struct stat stbuf; @@ -300,26 +300,26 @@ SDL_CDcaps.Close = SDL_SYS_CDClose; /* Look in the environment for our CD-ROM drive list */ - SDLcdrom = SDL_getenv ("SDL_CDROM"); /* ':' separated list of devices */ + SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ if (SDLcdrom != NULL) { char *cdpath, *delim; - size_t len = SDL_strlen (SDLcdrom) + 1; - cdpath = SDL_stack_alloc (char, len); + size_t len = SDL_strlen(SDLcdrom) + 1; + cdpath = SDL_stack_alloc(char, len); if (cdpath != NULL) { - SDL_strlcpy (cdpath, SDLcdrom, len); + SDL_strlcpy(cdpath, SDLcdrom, len); SDLcdrom = cdpath; do { - delim = SDL_strchr (SDLcdrom, ':'); + delim = SDL_strchr(SDLcdrom, ':'); if (delim) { *delim++ = '\0'; } #ifdef DEBUG_CDROM - fprintf (stderr, - "Checking CD-ROM drive from SDL_CDROM: %s\n", - SDLcdrom); + fprintf(stderr, + "Checking CD-ROM drive from SDL_CDROM: %s\n", + SDLcdrom); #endif - if (CheckDrive (SDLcdrom, &stbuf) > 0) { - AddDrive (SDLcdrom, &stbuf); + if (CheckDrive(SDLcdrom, &stbuf) > 0) { + AddDrive(SDLcdrom, &stbuf); } if (delim) { SDLcdrom = delim; @@ -328,7 +328,7 @@ } } while (SDLcdrom); - SDL_stack_free (cdpath); + SDL_stack_free(cdpath); } /* If we found our drives, there's nothing left to do */ @@ -337,33 +337,33 @@ } } - CheckMounts (); - CheckNonmounts (); + CheckMounts(); + CheckNonmounts(); return 0; } /* General ioctl() CD-ROM command function */ static int -SDL_SYS_CDioctl (int id, int command, void *arg) +SDL_SYS_CDioctl(int id, int command, void *arg) { int retval; - retval = ioctl (id, command, arg); + retval = ioctl(id, command, arg); if (retval < 0) { - SDL_SetError ("ioctl() error: %s", strerror (errno)); + SDL_SetError("ioctl() error: %s", strerror(errno)); } return retval; } static const char * -SDL_SYS_CDName (int drive) +SDL_SYS_CDName(int drive) { return (SDL_cdlist[drive]); } static int -SDL_SYS_CDOpen (int drive) +SDL_SYS_CDOpen(int drive) { int fd; char *lastsl; @@ -374,22 +374,22 @@ * We found /dev/cd? drives and that is in our list. But we can * open only the /dev/rcd? versions of those devices for Audio CD. */ - len = SDL_strlen (SDL_cdlist[drive]) + 2; - cdromname = (char *) SDL_malloc (len); - SDL_strlcpy (cdromname, SDL_cdlist[drive], len); - lastsl = SDL_strrchr (cdromname, '/'); + len = SDL_strlen(SDL_cdlist[drive]) + 2; + cdromname = (char *) SDL_malloc(len); + SDL_strlcpy(cdromname, SDL_cdlist[drive], len); + lastsl = SDL_strrchr(cdromname, '/'); if (lastsl) { *lastsl = 0; - SDL_strlcat (cdromname, "/r", len); - lastsl = SDL_strrchr (SDL_cdlist[drive], '/'); + SDL_strlcat(cdromname, "/r", len); + lastsl = SDL_strrchr(SDL_cdlist[drive], '/'); if (lastsl) { lastsl++; - SDL_strlcat (cdromname, lastsl, len); + SDL_strlcat(cdromname, lastsl, len); } } #ifdef DEBUG_CDROM - fprintf (stderr, "Should open drive %s, opening %s\n", SDL_cdlist[drive], - cdromname); + fprintf(stderr, "Should open drive %s, opening %s\n", SDL_cdlist[drive], + cdromname); #endif /* @@ -397,46 +397,46 @@ * require root priviledges, and we don't want that. SC_SINGLE provides * exclusive access with less trouble. */ - fd = openx (cdromname, O_RDONLY, NULL, SC_SINGLE); + fd = openx(cdromname, O_RDONLY, NULL, SC_SINGLE); if (fd < 0) { #ifdef DEBUG_CDROM - fprintf (stderr, "Could not open drive %s (%s)\n", cdromname, - strerror (errno)); + fprintf(stderr, "Could not open drive %s (%s)\n", cdromname, + strerror(errno)); #endif } else { struct mode_form_op cdMode; int ret; #ifdef DEBUG_CDROM cdMode.action = CD_GET_MODE; - ret = SDL_SYS_CDioctl (fd, DK_CD_MODE, &cdMode); + ret = SDL_SYS_CDioctl(fd, DK_CD_MODE, &cdMode); if (ret < 0) { - fprintf (stderr, - "Could not get drive mode for %s (%s)\n", - cdromname, strerror (errno)); + fprintf(stderr, + "Could not get drive mode for %s (%s)\n", + cdromname, strerror(errno)); } else { switch (cdMode.cd_mode_form) { case CD_MODE1: - fprintf (stderr, - "Drive mode for %s is %s\n", - cdromname, "CD-ROM Data Mode 1"); + fprintf(stderr, + "Drive mode for %s is %s\n", + cdromname, "CD-ROM Data Mode 1"); break; case CD_MODE2_FORM1: - fprintf (stderr, - "Drive mode for %s is %s\n", - cdromname, "CD-ROM XA Data Mode 2 Form 1"); + fprintf(stderr, + "Drive mode for %s is %s\n", + cdromname, "CD-ROM XA Data Mode 2 Form 1"); break; case CD_MODE2_FORM2: - fprintf (stderr, - "Drive mode for %s is %s\n", - cdromname, "CD-ROM XA Data Mode 2 Form 2"); + fprintf(stderr, + "Drive mode for %s is %s\n", + cdromname, "CD-ROM XA Data Mode 2 Form 2"); break; case CD_DA: - fprintf (stderr, - "Drive mode for %s is %s\n", cdromname, "CD-DA"); + fprintf(stderr, + "Drive mode for %s is %s\n", cdromname, "CD-DA"); break; default: - fprintf (stderr, - "Drive mode for %s is %s\n", cdromname, "unknown"); + fprintf(stderr, + "Drive mode for %s is %s\n", cdromname, "unknown"); break; } } @@ -444,28 +444,28 @@ cdMode.action = CD_CHG_MODE; cdMode.cd_mode_form = CD_DA; - ret = SDL_SYS_CDioctl (fd, DK_CD_MODE, &cdMode); + ret = SDL_SYS_CDioctl(fd, DK_CD_MODE, &cdMode); if (ret < 0) { #ifdef DEBUG_CDROM - fprintf (stderr, - "Could not set drive mode for %s (%s)\n", - cdromname, strerror (errno)); + fprintf(stderr, + "Could not set drive mode for %s (%s)\n", + cdromname, strerror(errno)); #endif SDL_SetError ("ioctl() error: Could not set CD drive mode, %s", - strerror (errno)); + strerror(errno)); } else { #ifdef DEBUG_CDROM - fprintf (stderr, "Drive mode for %s set to CD_DA\n", cdromname); + fprintf(stderr, "Drive mode for %s set to CD_DA\n", cdromname); #endif } } - SDL_free (cdromname); + SDL_free(cdromname); return fd; } static int -SDL_SYS_CDGetTOC (SDL_CD * cdrom) +SDL_SYS_CDGetTOC(SDL_CD * cdrom) { struct cd_audio_cmd cmd; struct cd_audio_cmd entry; @@ -474,7 +474,7 @@ cmd.audio_cmds = CD_TRK_INFO_AUDIO; cmd.msf_flag = FALSE; - if (SDL_SYS_CDioctl (cdrom->id, DKAUDIO, &cmd) < 0) { + if (SDL_SYS_CDioctl(cdrom->id, DKAUDIO, &cmd) < 0) { return -1; } @@ -494,14 +494,14 @@ } entry.audio_cmds = CD_GET_TRK_MSF; entry.indexing.track_msf.track = cdrom->track[i].id; - if (SDL_SYS_CDioctl (cdrom->id, DKAUDIO, &entry) < 0) { + if (SDL_SYS_CDioctl(cdrom->id, DKAUDIO, &entry) < 0) { break; } else { cdrom->track[i].type = 0; /* don't know how to detect 0x04 data track */ cdrom->track[i].offset = - MSF_TO_FRAMES (entry.indexing.track_msf.mins, - entry.indexing.track_msf.secs, - entry.indexing.track_msf.frames); + MSF_TO_FRAMES(entry.indexing.track_msf.mins, + entry.indexing.track_msf.secs, + entry.indexing.track_msf.frames); cdrom->track[i].length = 0; if (i > 0) { cdrom->track[i - 1].length = cdrom->track[i].offset @@ -517,16 +517,16 @@ /* Get CD-ROM status */ static CDstatus -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position) { CDstatus status; struct cd_audio_cmd cmd; cmd.audio_cmds = CD_INFO_AUDIO; - if (SDL_SYS_CDioctl (cdrom->id, DKAUDIO, &cmd) < 0) { + if (SDL_SYS_CDioctl(cdrom->id, DKAUDIO, &cmd) < 0) { #ifdef DEBUG_CDROM - fprintf (stderr, "ioctl failed in SDL_SYS_CDStatus (%s)\n", - SDL_GetError ()); + fprintf(stderr, "ioctl failed in SDL_SYS_CDStatus (%s)\n", + SDL_GetError()); #endif status = CD_ERROR; } else { @@ -543,19 +543,19 @@ break; case CD_NOT_VALID: #ifdef DEBUG_CDROM - fprintf (stderr, "cdStatus failed with CD_NOT_VALID\n"); + fprintf(stderr, "cdStatus failed with CD_NOT_VALID\n"); #endif status = CD_ERROR; break; case CD_STATUS_ERROR: #ifdef DEBUG_CDROM - fprintf (stderr, "cdStatus failed with CD_STATUS_ERROR\n"); + fprintf(stderr, "cdStatus failed with CD_STATUS_ERROR\n"); #endif status = CD_ERROR; break; default: #ifdef DEBUG_CDROM - fprintf (stderr, "cdStatus failed with unknown error\n"); + fprintf(stderr, "cdStatus failed with unknown error\n"); #endif status = CD_ERROR; break; @@ -564,9 +564,9 @@ if (position) { if (status == CD_PLAYING || (status == CD_PAUSED)) { *position = - MSF_TO_FRAMES (cmd.indexing.info_audio.current_mins, - cmd.indexing.info_audio.current_secs, - cmd.indexing.info_audio.current_frames); + MSF_TO_FRAMES(cmd.indexing.info_audio.current_mins, + cmd.indexing.info_audio.current_secs, + cmd.indexing.info_audio.current_frames); } else { *position = 0; } @@ -576,7 +576,7 @@ /* Start play */ static int -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) { struct cd_audio_cmd cmd; @@ -587,14 +587,13 @@ */ cmd.audio_cmds = CD_PLAY_AUDIO | CD_SET_VOLUME; cmd.msf_flag = TRUE; - FRAMES_TO_MSF (start, - &cmd.indexing.msf.first_mins, - &cmd.indexing.msf.first_secs, - &cmd.indexing.msf.first_frames); - FRAMES_TO_MSF (start + length, - &cmd.indexing.msf.last_mins, - &cmd.indexing.msf.last_secs, - &cmd.indexing.msf.last_frames); + FRAMES_TO_MSF(start, + &cmd.indexing.msf.first_mins, + &cmd.indexing.msf.first_secs, + &cmd.indexing.msf.first_frames); + FRAMES_TO_MSF(start + length, + &cmd.indexing.msf.last_mins, + &cmd.indexing.msf.last_secs, &cmd.indexing.msf.last_frames); cmd.volume_type = CD_VOLUME_ALL; cmd.all_channel_vol = 255; /* This is a uchar. What is a good value? No docu! */ cmd.out_port_0_sel = CD_AUDIO_CHNL_0; @@ -603,65 +602,65 @@ cmd.out_port_3_sel = CD_AUDIO_CHNL_3; #ifdef DEBUG_CDROM - fprintf (stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", - cmd.indexing.msf.first_mins, - cmd.indexing.msf.first_secs, - cmd.indexing.msf.first_frames, - cmd.indexing.msf.last_mins, - cmd.indexing.msf.last_secs, cmd.indexing.msf.last_frames); + fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", + cmd.indexing.msf.first_mins, + cmd.indexing.msf.first_secs, + cmd.indexing.msf.first_frames, + cmd.indexing.msf.last_mins, + cmd.indexing.msf.last_secs, cmd.indexing.msf.last_frames); #endif - return (SDL_SYS_CDioctl (cdrom->id, DKAUDIO, &cmd)); + return (SDL_SYS_CDioctl(cdrom->id, DKAUDIO, &cmd)); } /* Pause play */ static int -SDL_SYS_CDPause (SDL_CD * cdrom) +SDL_SYS_CDPause(SDL_CD * cdrom) { struct cd_audio_cmd cmd; cmd.audio_cmds = CD_PAUSE_AUDIO; - return (SDL_SYS_CDioctl (cdrom->id, DKAUDIO, &cmd)); + return (SDL_SYS_CDioctl(cdrom->id, DKAUDIO, &cmd)); } /* Resume play */ static int -SDL_SYS_CDResume (SDL_CD * cdrom) +SDL_SYS_CDResume(SDL_CD * cdrom) { struct cd_audio_cmd cmd; cmd.audio_cmds = CD_RESUME_AUDIO; - return (SDL_SYS_CDioctl (cdrom->id, DKAUDIO, &cmd)); + return (SDL_SYS_CDioctl(cdrom->id, DKAUDIO, &cmd)); } /* Stop play */ static int -SDL_SYS_CDStop (SDL_CD * cdrom) +SDL_SYS_CDStop(SDL_CD * cdrom) { struct cd_audio_cmd cmd; cmd.audio_cmds = CD_STOP_AUDIO; - return (SDL_SYS_CDioctl (cdrom->id, DKAUDIO, &cmd)); + return (SDL_SYS_CDioctl(cdrom->id, DKAUDIO, &cmd)); } /* Eject the CD-ROM */ static int -SDL_SYS_CDEject (SDL_CD * cdrom) +SDL_SYS_CDEject(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, DKEJECT, 0)); + return (SDL_SYS_CDioctl(cdrom->id, DKEJECT, 0)); } /* Close the CD-ROM handle */ static void -SDL_SYS_CDClose (SDL_CD * cdrom) +SDL_SYS_CDClose(SDL_CD * cdrom) { - close (cdrom->id); + close(cdrom->id); } void -SDL_SYS_CDQuit (void) +SDL_SYS_CDQuit(void) { int i; if (SDL_numcds > 0) { for (i = 0; i < SDL_numcds; ++i) { - SDL_free (SDL_cdlist[i]); + SDL_free(SDL_cdlist[i]); } SDL_numcds = 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/beos/SDL_syscdrom.cc --- a/src/cdrom/beos/SDL_syscdrom.cc Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/beos/SDL_syscdrom.cc Mon May 29 04:04:35 2006 +0000 @@ -66,42 +66,42 @@ static char *SDL_cdlist[MAX_DRIVES]; /* The system-dependent CD control functions */ -static const char *SDL_SYS_CDName (int drive); -static int SDL_SYS_CDOpen (int drive); -static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); -static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); -static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); -static int SDL_SYS_CDPause (SDL_CD * cdrom); -static int SDL_SYS_CDResume (SDL_CD * cdrom); -static int SDL_SYS_CDStop (SDL_CD * cdrom); -static int SDL_SYS_CDEject (SDL_CD * cdrom); -static void SDL_SYS_CDClose (SDL_CD * cdrom); -int try_dir (const char *directory); +static const char *SDL_SYS_CDName(int drive); +static int SDL_SYS_CDOpen(int drive); +static int SDL_SYS_CDGetTOC(SDL_CD * cdrom); +static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position); +static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length); +static int SDL_SYS_CDPause(SDL_CD * cdrom); +static int SDL_SYS_CDResume(SDL_CD * cdrom); +static int SDL_SYS_CDStop(SDL_CD * cdrom); +static int SDL_SYS_CDEject(SDL_CD * cdrom); +static void SDL_SYS_CDClose(SDL_CD * cdrom); +int try_dir(const char *directory); /* Check a drive to see if it is a CD-ROM */ static int -CheckDrive (char *drive) +CheckDrive(char *drive) { struct stat stbuf; int is_cd, cdfd; device_geometry info; /* If it doesn't exist, return -1 */ - if (stat (drive, &stbuf) < 0) { + if (stat(drive, &stbuf) < 0) { return (-1); } /* If it does exist, verify that it's an available CD-ROM */ is_cd = 0; - cdfd = open (drive, 0); + cdfd = open(drive, 0); if (cdfd >= 0) { - if (ioctl (cdfd, B_GET_GEOMETRY, &info) == B_NO_ERROR) { + if (ioctl(cdfd, B_GET_GEOMETRY, &info) == B_NO_ERROR) { if (info.device_type == B_CD) { is_cd = 1; } } - close (cdfd); + close(cdfd); } else { /* This can happen when the drive is open .. (?) */ ; is_cd = 1; @@ -111,7 +111,7 @@ /* Add a CD-ROM drive to our list of valid drives */ static void -AddDrive (char *drive) +AddDrive(char *drive) { int i; size_t len; @@ -119,16 +119,16 @@ if (SDL_numcds < MAX_DRIVES) { /* Add this drive to our list */ i = SDL_numcds; - len = SDL_strlen (drive) + 1; - SDL_cdlist[i] = (char *) SDL_malloc (len); + len = SDL_strlen(drive) + 1; + SDL_cdlist[i] = (char *) SDL_malloc(len); if (SDL_cdlist[i] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return; } - SDL_strlcpy (SDL_cdlist[i], drive, len); + SDL_strlcpy(SDL_cdlist[i], drive, len); ++SDL_numcds; #ifdef CDROM_DEBUG - fprintf (stderr, "Added CD-ROM drive: %s\n", drive); + fprintf(stderr, "Added CD-ROM drive: %s\n", drive); #endif } } @@ -153,7 +153,7 @@ }; int -SDL_SYS_CDInit (void) +SDL_SYS_CDInit(void) { char *SDLcdrom; int raw_fd; @@ -172,21 +172,21 @@ SDL_CDcaps.Close = SDL_SYS_CDClose; /* Look in the environment for our CD-ROM drive list */ - SDLcdrom = SDL_getenv ("SDL_CDROM"); /* ':' separated list of devices */ + SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ if (SDLcdrom != NULL) { char *cdpath, *delim; - size_t len = SDL_strlen (SDLcdrom) + 1; - cdpath = SDL_stack_alloc (char, len); + size_t len = SDL_strlen(SDLcdrom) + 1; + cdpath = SDL_stack_alloc(char, len); if (cdpath != NULL) { - SDL_strlcpy (cdpath, SDLcdrom, len); + SDL_strlcpy(cdpath, SDLcdrom, len); SDLcdrom = cdpath; do { - delim = SDL_strchr (SDLcdrom, ':'); + delim = SDL_strchr(SDLcdrom, ':'); if (delim) { *delim++ = '\0'; } - if (CheckDrive (SDLcdrom) > 0) { - AddDrive (SDLcdrom); + if (CheckDrive(SDLcdrom) > 0) { + AddDrive(SDLcdrom); } if (delim) { SDLcdrom = delim; @@ -195,7 +195,7 @@ } } while (SDLcdrom); - SDL_stack_free (cdpath); + SDL_stack_free(cdpath); } /* If we found our drives, there's nothing left to do */ @@ -205,56 +205,56 @@ } /* Scan the system for CD-ROM drives */ - try_dir ("/dev/disk"); + try_dir("/dev/disk"); return 0; } int -try_dir (const char *directory) +try_dir(const char *directory) { BDirectory dir; - dir.SetTo (directory); - if (dir.InitCheck () != B_NO_ERROR) { + dir.SetTo(directory); + if (dir.InitCheck() != B_NO_ERROR) { return false; } - dir.Rewind (); + dir.Rewind(); BEntry entry; - while (dir.GetNextEntry (&entry) >= 0) { + while (dir.GetNextEntry(&entry) >= 0) { BPath path; const char *name; entry_ref e; - if (entry.GetPath (&path) != B_NO_ERROR) + if (entry.GetPath(&path) != B_NO_ERROR) continue; - name = path.Path (); + name = path.Path(); - if (entry.GetRef (&e) != B_NO_ERROR) + if (entry.GetRef(&e) != B_NO_ERROR) continue; - if (entry.IsDirectory ()) { - if (SDL_strcmp (e.name, "floppy") == 0) + if (entry.IsDirectory()) { + if (SDL_strcmp(e.name, "floppy") == 0) continue; /* ignore floppy (it is not silent) */ - int devfd = try_dir (name); + int devfd = try_dir(name); if (devfd >= 0) return devfd; } else { int devfd; device_geometry g; - if (SDL_strcmp (e.name, "raw") != 0) + if (SDL_strcmp(e.name, "raw") != 0) continue; /* ignore partitions */ - devfd = open (name, O_RDONLY); + devfd = open(name, O_RDONLY); if (devfd < 0) continue; - if (ioctl (devfd, B_GET_GEOMETRY, &g, sizeof (g)) >= 0) { + if (ioctl(devfd, B_GET_GEOMETRY, &g, sizeof(g)) >= 0) { if (g.device_type == B_CD) { - AddDrive (strdup (name)); + AddDrive(strdup(name)); } } - close (devfd); + close(devfd); } } return B_ERROR; @@ -263,52 +263,52 @@ /* General ioctl() CD-ROM command function */ static int -SDL_SYS_CDioctl (int index, int command, void *arg) +SDL_SYS_CDioctl(int index, int command, void *arg) { int okay; int fd; okay = 0; - fd = open (SDL_cdlist[index], 0); + fd = open(SDL_cdlist[index], 0); if (fd >= 0) { - if (ioctl (fd, command, arg) == B_NO_ERROR) { + if (ioctl(fd, command, arg) == B_NO_ERROR) { okay = 1; } - close (fd); + close(fd); } return (okay ? 0 : -1); } static const char * -SDL_SYS_CDName (int drive) +SDL_SYS_CDName(int drive) { return (SDL_cdlist[drive]); } static int -SDL_SYS_CDOpen (int drive) +SDL_SYS_CDOpen(int drive) { return (drive); } static int -SDL_SYS_CDGetTOC (SDL_CD * cdrom) +SDL_SYS_CDGetTOC(SDL_CD * cdrom) { int i; scsi_toc toc; - if (SDL_SYS_CDioctl (cdrom->id, B_SCSI_GET_TOC, &toc) == 0) { - cdrom->numtracks = CD_NUMTRACKS (toc); + if (SDL_SYS_CDioctl(cdrom->id, B_SCSI_GET_TOC, &toc) == 0) { + cdrom->numtracks = CD_NUMTRACKS(toc); if (cdrom->numtracks > SDL_MAX_TRACKS) { cdrom->numtracks = SDL_MAX_TRACKS; } for (i = 0; i <= cdrom->numtracks; ++i) { - cdrom->track[i].id = CD_TRACK_N (toc, i); + cdrom->track[i].id = CD_TRACK_N(toc, i); /* FIXME: How do we tell on BeOS? */ cdrom->track[i].type = SDL_AUDIO_TRACK; - cdrom->track[i].offset = MSF_TO_FRAMES (CD_TRACK_M (toc, i), - CD_TRACK_S (toc, i), - CD_TRACK_F (toc, i)); + cdrom->track[i].offset = MSF_TO_FRAMES(CD_TRACK_M(toc, i), + CD_TRACK_S(toc, i), + CD_TRACK_F(toc, i)); cdrom->track[i].length = 0; if (i > 0) { cdrom->track[i - 1].length = @@ -323,20 +323,19 @@ /* Get CD-ROM status */ static CDstatus -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position) { CDstatus status; int fd; int cur_frame; scsi_position pos; - fd = open (SDL_cdlist[cdrom->id], 0); + fd = open(SDL_cdlist[cdrom->id], 0); cur_frame = 0; if (fd >= 0) { - if (ioctl (fd, B_SCSI_GET_POSITION, &pos) == B_NO_ERROR) { + if (ioctl(fd, B_SCSI_GET_POSITION, &pos) == B_NO_ERROR) { cur_frame = - MSF_TO_FRAMES (POS_ABS_M (pos), POS_ABS_S (pos), - POS_ABS_F (pos)); + MSF_TO_FRAMES(POS_ABS_M(pos), POS_ABS_S(pos), POS_ABS_F(pos)); } if (!pos.position[1] || (pos.position[1] >= 0x13) || ((pos.position[1] == 0x12) && (!pos.position[6]))) { @@ -346,7 +345,7 @@ } else { status = CD_PAUSED; } - close (fd); + close(fd); } else { status = CD_TRAYEMPTY; } @@ -358,68 +357,68 @@ /* Start play */ static int -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) { int okay; int fd; scsi_play_position pos; okay = 0; - fd = open (SDL_cdlist[cdrom->id], 0); + fd = open(SDL_cdlist[cdrom->id], 0); if (fd >= 0) { - FRAMES_TO_MSF (start, &pos.start_m, &pos.start_s, &pos.start_f); - FRAMES_TO_MSF (start + length, &pos.end_m, &pos.end_s, &pos.end_f); - if (ioctl (fd, B_SCSI_PLAY_POSITION, &pos) == B_NO_ERROR) { + FRAMES_TO_MSF(start, &pos.start_m, &pos.start_s, &pos.start_f); + FRAMES_TO_MSF(start + length, &pos.end_m, &pos.end_s, &pos.end_f); + if (ioctl(fd, B_SCSI_PLAY_POSITION, &pos) == B_NO_ERROR) { okay = 1; } - close (fd); + close(fd); } return (okay ? 0 : -1); } /* Pause play */ static int -SDL_SYS_CDPause (SDL_CD * cdrom) +SDL_SYS_CDPause(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, B_SCSI_PAUSE_AUDIO, 0)); + return (SDL_SYS_CDioctl(cdrom->id, B_SCSI_PAUSE_AUDIO, 0)); } /* Resume play */ static int -SDL_SYS_CDResume (SDL_CD * cdrom) +SDL_SYS_CDResume(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, B_SCSI_RESUME_AUDIO, 0)); + return (SDL_SYS_CDioctl(cdrom->id, B_SCSI_RESUME_AUDIO, 0)); } /* Stop play */ static int -SDL_SYS_CDStop (SDL_CD * cdrom) +SDL_SYS_CDStop(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, B_SCSI_STOP_AUDIO, 0)); + return (SDL_SYS_CDioctl(cdrom->id, B_SCSI_STOP_AUDIO, 0)); } /* Eject the CD-ROM */ static int -SDL_SYS_CDEject (SDL_CD * cdrom) +SDL_SYS_CDEject(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, B_SCSI_EJECT, 0)); + return (SDL_SYS_CDioctl(cdrom->id, B_SCSI_EJECT, 0)); } /* Close the CD-ROM handle */ static void -SDL_SYS_CDClose (SDL_CD * cdrom) +SDL_SYS_CDClose(SDL_CD * cdrom) { - close (cdrom->id); + close(cdrom->id); } void -SDL_SYS_CDQuit (void) +SDL_SYS_CDQuit(void) { int i; if (SDL_numcds > 0) { for (i = 0; i < SDL_numcds; ++i) { - SDL_free (SDL_cdlist[i]); + SDL_free(SDL_cdlist[i]); } SDL_numcds = 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/bsdi/SDL_syscdrom.c --- a/src/cdrom/bsdi/SDL_syscdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/bsdi/SDL_syscdrom.c Mon May 29 04:04:35 2006 +0000 @@ -52,13 +52,13 @@ #define FRAMES_PER_MINUTE (FRAMES_PER_SECOND * 60) int -msf_to_frame (int minute, int second, int frame) +msf_to_frame(int minute, int second, int frame) { return (minute * FRAMES_PER_MINUTE + second * FRAMES_PER_SECOND + frame); } void -frame_to_msf (int frame, int *minp, int *secp, int *framep) +frame_to_msf(int frame, int *minp, int *secp, int *framep) { *minp = frame / FRAMES_PER_MINUTE; *secp = (frame % FRAMES_PER_MINUTE) / FRAMES_PER_SECOND; @@ -73,24 +73,24 @@ static dev_t SDL_cdmode[MAX_DRIVES]; /* The system-dependent CD control functions */ -static const char *SDL_SYS_CDName (int drive); -static int SDL_SYS_CDOpen (int drive); -static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); -static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); -static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); -static int SDL_SYS_CDPause (SDL_CD * cdrom); -static int SDL_SYS_CDResume (SDL_CD * cdrom); -static int SDL_SYS_CDStop (SDL_CD * cdrom); -static int SDL_SYS_CDEject (SDL_CD * cdrom); -static void SDL_SYS_CDClose (SDL_CD * cdrom); +static const char *SDL_SYS_CDName(int drive); +static int SDL_SYS_CDOpen(int drive); +static int SDL_SYS_CDGetTOC(SDL_CD * cdrom); +static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position); +static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length); +static int SDL_SYS_CDPause(SDL_CD * cdrom); +static int SDL_SYS_CDResume(SDL_CD * cdrom); +static int SDL_SYS_CDStop(SDL_CD * cdrom); +static int SDL_SYS_CDEject(SDL_CD * cdrom); +static void SDL_SYS_CDClose(SDL_CD * cdrom); typedef struct scsi_cdb cdb_t; static int -scsi_cmd (int fd, - struct scsi_cdb *cdb, - int cdblen, - int rw, caddr_t data, int datalen, struct scsi_user_cdb *sus) +scsi_cmd(int fd, + struct scsi_cdb *cdb, + int cdblen, + int rw, caddr_t data, int datalen, struct scsi_user_cdb *sus) { int scsistatus; unsigned char *cp; @@ -104,11 +104,11 @@ suc.suc_flags = rw; suc.suc_cdblen = cdblen; - bcopy (cdb, suc.suc_cdb, cdblen); + bcopy(cdb, suc.suc_cdb, cdblen); suc.suc_datalen = datalen; suc.suc_data = data; suc.suc_timeout = 10; /* 10 secs max for TUR or SENSE */ - if (ioctl (fd, SCSIRAWCDB, &suc) == -1) + if (ioctl(fd, SCSIRAWCDB, &suc) == -1) return (-11); scsistatus = suc.suc_sus.sus_status; cp = suc.suc_sus.sus_sense; @@ -119,16 +119,15 @@ * out if the status was not successful. */ if (scsistatus != 0 && !sus) { - fprintf (stderr, "scsistatus = %x cmd = %x\n", scsistatus, cdb[0]); - fprintf (stderr, - "sense %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", - cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7], - cp[8], cp[9], cp[10], cp[11], cp[12], cp[13], cp[14], - cp[15]); + fprintf(stderr, "scsistatus = %x cmd = %x\n", scsistatus, cdb[0]); + fprintf(stderr, + "sense %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n", + cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7], + cp[8], cp[9], cp[10], cp[11], cp[12], cp[13], cp[14], cp[15]); return (1); } if (sus) - bcopy (&suc, sus, sizeof (struct scsi_user_cdb)); + bcopy(&suc, sus, sizeof(struct scsi_user_cdb)); if (scsistatus) return (1); /* Return non-zero for unsuccessful status */ return (0); @@ -136,7 +135,7 @@ /* request vendor brand and model */ unsigned char * -Inquiry (int fd) +Inquiry(int fd) { static struct scsi_cdb6 cdb = { 0x12, @@ -146,8 +145,8 @@ }; static unsigned char Inqbuffer[56]; - if (scsi_cmd (fd, (cdb_t *) & cdb, 6, SUC_READ, Inqbuffer, - sizeof (Inqbuffer), 0)) + if (scsi_cmd(fd, (cdb_t *) & cdb, 6, SUC_READ, Inqbuffer, + sizeof(Inqbuffer), 0)) return ("\377"); return (Inqbuffer); } @@ -156,7 +155,7 @@ #define ADD_SC_QUALIFIER 13 int -TestForMedium (int fd) +TestForMedium(int fd) { int sts, asc, ascq; struct scsi_user_cdb sus; @@ -169,7 +168,7 @@ 0 /* reserved */ }; - again:sts = scsi_cmd (fd, (cdb_t *) & cdb, 6, SUC_READ, 0, 0, &sus); + again:sts = scsi_cmd(fd, (cdb_t *) & cdb, 6, SUC_READ, 0, 0, &sus); asc = sus.suc_sus.sus_sense[ADD_SENSECODE]; ascq = sus.suc_sus.sus_sense[ADD_SC_QUALIFIER]; if (asc == 0x3a && ascq == 0x0) /* no medium */ @@ -177,7 +176,7 @@ if (asc == 0x28 && ascq == 0x0) /* medium changed */ goto again; if (asc == 0x4 && ascq == 0x1) { /* coming ready */ - sleep (2); + sleep(2); goto again; } return (1); @@ -185,30 +184,30 @@ /* Check a drive to see if it is a CD-ROM */ static int -CheckDrive (char *drive, struct stat *stbuf) +CheckDrive(char *drive, struct stat *stbuf) { int is_cd = 0, cdfd; char *p; /* If it doesn't exist, return -1 */ - if (stat (drive, stbuf) < 0) { + if (stat(drive, stbuf) < 0) { return (-1); } /* If it does exist, verify that it's an available CD-ROM */ - cdfd = open (drive, (O_RDONLY | O_EXCL | O_NONBLOCK), 0); + cdfd = open(drive, (O_RDONLY | O_EXCL | O_NONBLOCK), 0); if (cdfd >= 0) { - p = Inquiry (cdfd); + p = Inquiry(cdfd); if (*p == TYPE_ROM) is_cd = 1; - close (cdfd); + close(cdfd); } return (is_cd); } /* Add a CD-ROM drive to our list of valid drives */ static void -AddDrive (char *drive, struct stat *stbuf) +AddDrive(char *drive, struct stat *stbuf) { int i; @@ -219,8 +218,8 @@ for (i = 0; i < SDL_numcds; ++i) { if (stbuf->st_rdev == SDL_cdmode[i]) { #ifdef DEBUG_CDROM - fprintf (stderr, "Duplicate drive detected: %s == %s\n", - drive, SDL_cdlist[i]); + fprintf(stderr, "Duplicate drive detected: %s == %s\n", + drive, SDL_cdlist[i]); #endif return; } @@ -228,21 +227,21 @@ /* Add this drive to our list */ i = SDL_numcds; - SDL_cdlist[i] = SDL_strdup (drive); + SDL_cdlist[i] = SDL_strdup(drive); if (SDL_cdlist[i] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return; } SDL_cdmode[i] = stbuf->st_rdev; ++SDL_numcds; #ifdef DEBUG_CDROM - fprintf (stderr, "Added CD-ROM drive: %s\n", drive); + fprintf(stderr, "Added CD-ROM drive: %s\n", drive); #endif } } int -SDL_SYS_CDInit (void) +SDL_SYS_CDInit(void) { /* checklist: /dev/rsr?c */ static char *checklist[] = { @@ -266,21 +265,21 @@ SDL_CDcaps.Close = SDL_SYS_CDClose; /* Look in the environment for our CD-ROM drive list */ - SDLcdrom = SDL_getenv ("SDL_CDROM"); /* ':' separated list of devices */ + SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ if (SDLcdrom != NULL) { char *cdpath, *delim; - size_t len = SDL_strlen (SDLcdrom) + 1; - cdpath = SDL_stack_alloc (char, len); + size_t len = SDL_strlen(SDLcdrom) + 1; + cdpath = SDL_stack_alloc(char, len); if (cdpath != NULL) { - SDL_strlcpy (cdpath, SDLcdrom, len); + SDL_strlcpy(cdpath, SDLcdrom, len); SDLcdrom = cdpath; do { - delim = SDL_strchr (SDLcdrom, ':'); + delim = SDL_strchr(SDLcdrom, ':'); if (delim) { *delim++ = '\0'; } - if (CheckDrive (SDLcdrom, &stbuf) > 0) { - AddDrive (SDLcdrom, &stbuf); + if (CheckDrive(SDLcdrom, &stbuf) > 0) { + AddDrive(SDLcdrom, &stbuf); } if (delim) { SDLcdrom = delim; @@ -289,7 +288,7 @@ } } while (SDLcdrom); - SDL_stack_free (cdpath); + SDL_stack_free(cdpath); } /* If we found our drives, there's nothing left to do */ @@ -304,16 +303,16 @@ char *insert; exists = 1; for (j = checklist[i][1]; exists; ++j) { - SDL_snprintf (drive, SDL_arraysize (drive), "/dev/%sc", - &checklist[i][3]); - insert = SDL_strchr (drive, '?'); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%sc", + &checklist[i][3]); + insert = SDL_strchr(drive, '?'); if (insert != NULL) { *insert = j; } - switch (CheckDrive (drive, &stbuf)) { + switch (CheckDrive(drive, &stbuf)) { /* Drive exists and is a CD-ROM */ case 1: - AddDrive (drive, &stbuf); + AddDrive(drive, &stbuf); break; /* Drive exists, but isn't a CD-ROM */ case 0: @@ -325,10 +324,10 @@ } } } else { - SDL_snprintf (drive, SDL_arraysize (drive), "/dev/%s", - checklist[i]); - if (CheckDrive (drive, &stbuf) > 0) { - AddDrive (drive, &stbuf); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", + checklist[i]); + if (CheckDrive(drive, &stbuf) > 0) { + AddDrive(drive, &stbuf); } } } @@ -336,29 +335,29 @@ } static const char * -SDL_SYS_CDName (int drive) +SDL_SYS_CDName(int drive) { return (SDL_cdlist[drive]); } static int -SDL_SYS_CDOpen (int drive) +SDL_SYS_CDOpen(int drive) { - return (open (SDL_cdlist[drive], O_RDONLY | O_NONBLOCK | O_EXCL, 0)); + return (open(SDL_cdlist[drive], O_RDONLY | O_NONBLOCK | O_EXCL, 0)); } static int -SDL_SYS_CDGetTOC (SDL_CD * cdrom) +SDL_SYS_CDGetTOC(SDL_CD * cdrom) { u_char cdb[10], buf[4], *p, *toc; struct scsi_user_cdb sus; int i, sts, first_track, last_track, ntracks, toc_size; - bzero (cdb, sizeof (cdb)); + bzero(cdb, sizeof(cdb)); cdb[0] = 0x43; /* Read TOC */ cdb[1] = 0x2; /* MSF */ cdb[8] = 4; /* size TOC header */ - sts = scsi_cmd (cdrom->id, (cdb_t *) cdb, 10, SUC_READ, buf, 4, &sus); + sts = scsi_cmd(cdrom->id, (cdb_t *) cdb, 10, SUC_READ, buf, 4, &sus); if (sts < 0) return (-1); first_track = buf[2]; @@ -366,19 +365,19 @@ ntracks = last_track - first_track + 1; cdrom->numtracks = ntracks; toc_size = 4 + (ntracks + 1) * 8; - toc = (u_char *) SDL_malloc (toc_size); + toc = (u_char *) SDL_malloc(toc_size); if (toc == NULL) return (-1); - bzero (cdb, sizeof (cdb)); + bzero(cdb, sizeof(cdb)); cdb[0] = 0x43; cdb[1] = 0x2; cdb[6] = first_track; cdb[7] = toc_size >> 8; cdb[8] = toc_size & 0xff; - sts = scsi_cmd (cdrom->id, (cdb_t *) cdb, 10, SUC_READ, toc, toc_size, - &sus); + sts = scsi_cmd(cdrom->id, (cdb_t *) cdb, 10, SUC_READ, toc, toc_size, + &sus); if (sts < 0) { - SDL_free (toc); + SDL_free(toc); return (-1); } @@ -391,38 +390,38 @@ cdrom->track[i].type = SDL_DATA_TRACK; else cdrom->track[i].type = SDL_AUDIO_TRACK; - cdrom->track[i].offset = msf_to_frame (p[5], p[6], p[7]); + cdrom->track[i].offset = msf_to_frame(p[5], p[6], p[7]); cdrom->track[i].length = 0; if (i > 0) cdrom->track[i - 1].length = cdrom->track[i].offset - cdrom->track[i - 1].offset; } - SDL_free (toc); + SDL_free(toc); return (0); } /* Get CD-ROM status */ static CDstatus -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position) { CDstatus status; u_char cdb[10], buf[16]; int sts; struct scsi_user_cdb sus; - bzero (cdb, sizeof (cdb)); + bzero(cdb, sizeof(cdb)); cdb[0] = 0x42; /* read subq */ cdb[1] = 0x2; /* MSF */ cdb[2] = 0x40; /* q channel */ cdb[3] = 1; /* current pos */ - cdb[7] = sizeof (buf) >> 8; - cdb[8] = sizeof (buf) & 0xff; - sts = scsi_cmd (cdrom->id, (cdb_t *) cdb, 10, SUC_READ, buf, sizeof (buf), - &sus); + cdb[7] = sizeof(buf) >> 8; + cdb[8] = sizeof(buf) & 0xff; + sts = scsi_cmd(cdrom->id, (cdb_t *) cdb, 10, SUC_READ, buf, sizeof(buf), + &sus); if (sts < 0) return (-1); if (sts) { - if (TestForMedium (cdrom->id) == 0) + if (TestForMedium(cdrom->id) == 0) status = CD_TRAYEMPTY; else status = CD_ERROR; @@ -446,7 +445,7 @@ } if (position) { if (status == CD_PLAYING || (status == CD_PAUSED)) - *position = msf_to_frame (buf[9], buf[10], buf[11]); + *position = msf_to_frame(buf[9], buf[10], buf[11]); else *position = 0; } @@ -455,94 +454,94 @@ /* Start play */ static int -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) { u_char cdb[10]; int sts, minute, second, frame, eminute, esecond, eframe; struct scsi_user_cdb sus; - bzero (cdb, sizeof (cdb)); + bzero(cdb, sizeof(cdb)); cdb[0] = 0x47; /* Play */ - frame_to_msf (start, &minute, &second, &frame); - frame_to_msf (start + length, &eminute, &esecond, &eframe); + frame_to_msf(start, &minute, &second, &frame); + frame_to_msf(start + length, &eminute, &esecond, &eframe); cdb[3] = minute; cdb[4] = second; cdb[5] = frame; cdb[6] = eminute; cdb[7] = esecond; cdb[8] = eframe; - sts = scsi_cmd (cdrom->id, (cdb_t *) cdb, 10, SUC_READ, 0, 0, &sus); + sts = scsi_cmd(cdrom->id, (cdb_t *) cdb, 10, SUC_READ, 0, 0, &sus); return (sts); } static int -pauseresume (SDL_CD * cdrom, int flag) +pauseresume(SDL_CD * cdrom, int flag) { u_char cdb[10]; struct scsi_user_cdb sus; - bzero (cdb, sizeof (cdb)); + bzero(cdb, sizeof(cdb)); cdb[0] = 0x4b; cdb[8] = flag & 0x1; - return (scsi_cmd (cdrom->id, (cdb_t *) cdb, 10, SUC_READ, 0, 0, &sus)); + return (scsi_cmd(cdrom->id, (cdb_t *) cdb, 10, SUC_READ, 0, 0, &sus)); } /* Pause play */ static int -SDL_SYS_CDPause (SDL_CD * cdrom) +SDL_SYS_CDPause(SDL_CD * cdrom) { - return (pauseresume (cdrom, 0)); + return (pauseresume(cdrom, 0)); } /* Resume play */ static int -SDL_SYS_CDResume (SDL_CD * cdrom) +SDL_SYS_CDResume(SDL_CD * cdrom) { - return (pauseresume (cdrom, 1)); + return (pauseresume(cdrom, 1)); } /* Stop play */ static int -SDL_SYS_CDStop (SDL_CD * cdrom) +SDL_SYS_CDStop(SDL_CD * cdrom) { u_char cdb[6]; struct scsi_user_cdb sus; - bzero (cdb, sizeof (cdb)); + bzero(cdb, sizeof(cdb)); cdb[0] = 0x1b; /* stop */ cdb[1] = 1; /* immediate */ - return (scsi_cmd (cdrom->id, (cdb_t *) cdb, 6, SUC_READ, 0, 0, &sus)); + return (scsi_cmd(cdrom->id, (cdb_t *) cdb, 6, SUC_READ, 0, 0, &sus)); } /* Eject the CD-ROM */ static int -SDL_SYS_CDEject (SDL_CD * cdrom) +SDL_SYS_CDEject(SDL_CD * cdrom) { u_char cdb[6]; struct scsi_user_cdb sus; - bzero (cdb, sizeof (cdb)); + bzero(cdb, sizeof(cdb)); cdb[0] = 0x1b; /* stop */ cdb[1] = 1; /* immediate */ cdb[4] = 2; /* eject */ - return (scsi_cmd (cdrom->id, (cdb_t *) cdb, 6, SUC_READ, 0, 0, &sus)); + return (scsi_cmd(cdrom->id, (cdb_t *) cdb, 6, SUC_READ, 0, 0, &sus)); } /* Close the CD-ROM handle */ static void -SDL_SYS_CDClose (SDL_CD * cdrom) +SDL_SYS_CDClose(SDL_CD * cdrom) { - close (cdrom->id); + close(cdrom->id); } void -SDL_SYS_CDQuit (void) +SDL_SYS_CDQuit(void) { int i; if (SDL_numcds > 0) { for (i = 0; i < SDL_numcds; ++i) { - SDL_free (SDL_cdlist[i]); + SDL_free(SDL_cdlist[i]); } } SDL_numcds = 0; diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/dc/SDL_syscdrom.c --- a/src/cdrom/dc/SDL_syscdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/dc/SDL_syscdrom.c Mon May 29 04:04:35 2006 +0000 @@ -32,20 +32,20 @@ #include "../SDL_syscdrom.h" /* The system-dependent CD control functions */ -static const char *SDL_SYS_CDName (int drive); -static int SDL_SYS_CDOpen (int drive); -static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); -static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); -static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); -static int SDL_SYS_CDPause (SDL_CD * cdrom); -static int SDL_SYS_CDResume (SDL_CD * cdrom); -static int SDL_SYS_CDStop (SDL_CD * cdrom); -static int SDL_SYS_CDEject (SDL_CD * cdrom); -static void SDL_SYS_CDClose (SDL_CD * cdrom); +static const char *SDL_SYS_CDName(int drive); +static int SDL_SYS_CDOpen(int drive); +static int SDL_SYS_CDGetTOC(SDL_CD * cdrom); +static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position); +static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length); +static int SDL_SYS_CDPause(SDL_CD * cdrom); +static int SDL_SYS_CDResume(SDL_CD * cdrom); +static int SDL_SYS_CDStop(SDL_CD * cdrom); +static int SDL_SYS_CDEject(SDL_CD * cdrom); +static void SDL_SYS_CDClose(SDL_CD * cdrom); int -SDL_SYS_CDInit (void) +SDL_SYS_CDInit(void) { /* Fill in our driver capabilities */ SDL_CDcaps.Name = SDL_SYS_CDName; @@ -63,41 +63,41 @@ } static const char * -SDL_SYS_CDName (int drive) +SDL_SYS_CDName(int drive) { return "/cd"; } static int -SDL_SYS_CDOpen (int drive) +SDL_SYS_CDOpen(int drive) { return (drive); } #define TRACK_CDDA 0 static int -SDL_SYS_CDGetTOC (SDL_CD * cdrom) +SDL_SYS_CDGetTOC(SDL_CD * cdrom) { CDROM_TOC toc; int ret, i; - ret = cdrom_read_toc (&toc, 0); + ret = cdrom_read_toc(&toc, 0); if (ret != ERR_OK) { return -1; } - cdrom->numtracks = TOC_TRACK (toc.last) - TOC_TRACK (toc.first) + 1; + cdrom->numtracks = TOC_TRACK(toc.last) - TOC_TRACK(toc.first) + 1; for (i = 0; i < cdrom->numtracks; i++) { unsigned long entry = toc.entry[i]; cdrom->track[i].id = i + 1; cdrom->track[i].type = - (TOC_CTRL (toc.entry[i]) == + (TOC_CTRL(toc.entry[i]) == TRACK_CDDA) ? SDL_AUDIO_TRACK : SDL_DATA_TRACK; - cdrom->track[i].offset = TOC_LBA (entry) - 150; + cdrom->track[i].offset = TOC_LBA(entry) - 150; cdrom->track[i].length = - TOC_LBA ((i + 1 < - toc.last) ? toc.entry[i + 1] : toc.leadout_sector) - - TOC_LBA (entry); + TOC_LBA((i + 1 < + toc.last) ? toc.entry[i + 1] : toc.leadout_sector) - + TOC_LBA(entry); } return 0; @@ -105,11 +105,11 @@ /* Get CD-ROM status */ static CDstatus -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position) { int ret, dc_status, disc_type; - ret = cdrom_get_status (&dc_status, &disc_type); + ret = cdrom_get_status(&dc_status, &disc_type); if (ret != ERR_OK) return CD_ERROR; @@ -133,52 +133,52 @@ /* Start play */ static int -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) { int ret = - cdrom_cdda_play (start - 150, start - 150 + length, 1, CDDA_SECTORS); + cdrom_cdda_play(start - 150, start - 150 + length, 1, CDDA_SECTORS); return ret == ERR_OK ? 0 : -1; } /* Pause play */ static int -SDL_SYS_CDPause (SDL_CD * cdrom) +SDL_SYS_CDPause(SDL_CD * cdrom) { - int ret = cdrom_cdda_pause (); + int ret = cdrom_cdda_pause(); return ret == ERR_OK ? 0 : -1; } /* Resume play */ static int -SDL_SYS_CDResume (SDL_CD * cdrom) +SDL_SYS_CDResume(SDL_CD * cdrom) { - int ret = cdrom_cdda_resume (); + int ret = cdrom_cdda_resume(); return ret == ERR_OK ? 0 : -1; } /* Stop play */ static int -SDL_SYS_CDStop (SDL_CD * cdrom) +SDL_SYS_CDStop(SDL_CD * cdrom) { - int ret = cdrom_spin_down (); + int ret = cdrom_spin_down(); return ret == ERR_OK ? 0 : -1; } /* Eject the CD-ROM */ static int -SDL_SYS_CDEject (SDL_CD * cdrom) +SDL_SYS_CDEject(SDL_CD * cdrom) { return -1; } /* Close the CD-ROM handle */ static void -SDL_SYS_CDClose (SDL_CD * cdrom) +SDL_SYS_CDClose(SDL_CD * cdrom) { } void -SDL_SYS_CDQuit (void) +SDL_SYS_CDQuit(void) { } diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/dummy/SDL_syscdrom.c --- a/src/cdrom/dummy/SDL_syscdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/dummy/SDL_syscdrom.c Mon May 29 04:04:35 2006 +0000 @@ -29,13 +29,13 @@ #include "../SDL_syscdrom.h" int -SDL_SYS_CDInit (void) +SDL_SYS_CDInit(void) { return (0); } void -SDL_SYS_CDQuit (void) +SDL_SYS_CDQuit(void) { return; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/freebsd/SDL_syscdrom.c --- a/src/cdrom/freebsd/SDL_syscdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/freebsd/SDL_syscdrom.c Mon May 29 04:04:35 2006 +0000 @@ -44,16 +44,16 @@ static dev_t SDL_cdmode[MAX_DRIVES]; /* The system-dependent CD control functions */ -static const char *SDL_SYS_CDName (int drive); -static int SDL_SYS_CDOpen (int drive); -static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); -static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); -static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); -static int SDL_SYS_CDPause (SDL_CD * cdrom); -static int SDL_SYS_CDResume (SDL_CD * cdrom); -static int SDL_SYS_CDStop (SDL_CD * cdrom); -static int SDL_SYS_CDEject (SDL_CD * cdrom); -static void SDL_SYS_CDClose (SDL_CD * cdrom); +static const char *SDL_SYS_CDName(int drive); +static int SDL_SYS_CDOpen(int drive); +static int SDL_SYS_CDGetTOC(SDL_CD * cdrom); +static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position); +static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length); +static int SDL_SYS_CDPause(SDL_CD * cdrom); +static int SDL_SYS_CDResume(SDL_CD * cdrom); +static int SDL_SYS_CDStop(SDL_CD * cdrom); +static int SDL_SYS_CDEject(SDL_CD * cdrom); +static void SDL_SYS_CDClose(SDL_CD * cdrom); /* Some ioctl() errno values which occur when the tray is empty */ #define ERRNO_TRAYEMPTY(errno) \ @@ -61,20 +61,20 @@ /* Check a drive to see if it is a CD-ROM */ static int -CheckDrive (char *drive, struct stat *stbuf) +CheckDrive(char *drive, struct stat *stbuf) { int is_cd, cdfd; struct ioc_read_subchannel info; /* If it doesn't exist, return -1 */ - if (stat (drive, stbuf) < 0) { + if (stat(drive, stbuf) < 0) { return (-1); } /* If it does exist, verify that it's an available CD-ROM */ is_cd = 0; - if (S_ISCHR (stbuf->st_mode) || S_ISBLK (stbuf->st_mode)) { - cdfd = open (drive, (O_RDONLY | O_EXCL | O_NONBLOCK), 0); + if (S_ISCHR(stbuf->st_mode) || S_ISBLK(stbuf->st_mode)) { + cdfd = open(drive, (O_RDONLY | O_EXCL | O_NONBLOCK), 0); if (cdfd >= 0) { info.address_format = CD_MSF_FORMAT; info.data_format = CD_CURRENT_POSITION; @@ -84,11 +84,11 @@ This isn't 100% reliable, so we use the USE_MNTENT code above instead. */ - if ((ioctl (cdfd, CDIOCREADSUBCHANNEL, &info) == 0) || - ERRNO_TRAYEMPTY (errno)) { + if ((ioctl(cdfd, CDIOCREADSUBCHANNEL, &info) == 0) || + ERRNO_TRAYEMPTY(errno)) { is_cd = 1; } - close (cdfd); + close(cdfd); } } return (is_cd); @@ -96,7 +96,7 @@ /* Add a CD-ROM drive to our list of valid drives */ static void -AddDrive (char *drive, struct stat *stbuf) +AddDrive(char *drive, struct stat *stbuf) { int i; @@ -107,8 +107,8 @@ for (i = 0; i < SDL_numcds; ++i) { if (stbuf->st_rdev == SDL_cdmode[i]) { #ifdef DEBUG_CDROM - fprintf (stderr, "Duplicate drive detected: %s == %s\n", - drive, SDL_cdlist[i]); + fprintf(stderr, "Duplicate drive detected: %s == %s\n", + drive, SDL_cdlist[i]); #endif return; } @@ -116,21 +116,21 @@ /* Add this drive to our list */ i = SDL_numcds; - SDL_cdlist[i] = SDL_strdup (drive); + SDL_cdlist[i] = SDL_strdup(drive); if (SDL_cdlist[i] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return; } SDL_cdmode[i] = stbuf->st_rdev; ++SDL_numcds; #ifdef DEBUG_CDROM - fprintf (stderr, "Added CD-ROM drive: %s\n", drive); + fprintf(stderr, "Added CD-ROM drive: %s\n", drive); #endif } } int -SDL_SYS_CDInit (void) +SDL_SYS_CDInit(void) { /* checklist: /dev/cdrom,/dev/cd?c /dev/acd?c /dev/matcd?c /dev/mcd?c /dev/scd?c */ @@ -155,21 +155,21 @@ SDL_CDcaps.Close = SDL_SYS_CDClose; /* Look in the environment for our CD-ROM drive list */ - SDLcdrom = SDL_getenv ("SDL_CDROM"); /* ':' separated list of devices */ + SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ if (SDLcdrom != NULL) { char *cdpath, *delim; - size_t len = SDL_strlen (SDLcdrom) + 1; - cdpath = SDL_stack_alloc (char, len); + size_t len = SDL_strlen(SDLcdrom) + 1; + cdpath = SDL_stack_alloc(char, len); if (cdpath != NULL) { - SDL_strlcpy (cdpath, SDLcdrom, len); + SDL_strlcpy(cdpath, SDLcdrom, len); SDLcdrom = cdpath; do { - delim = SDL_strchr (SDLcdrom, ':'); + delim = SDL_strchr(SDLcdrom, ':'); if (delim) { *delim++ = '\0'; } - if (CheckDrive (SDLcdrom, &stbuf) > 0) { - AddDrive (SDLcdrom, &stbuf); + if (CheckDrive(SDLcdrom, &stbuf) > 0) { + AddDrive(SDLcdrom, &stbuf); } if (delim) { SDLcdrom = delim; @@ -178,7 +178,7 @@ } } while (SDLcdrom); - SDL_stack_free (cdpath); + SDL_stack_free(cdpath); } /* If we found our drives, there's nothing left to do */ @@ -193,16 +193,16 @@ char *insert; exists = 1; for (j = checklist[i][1]; exists; ++j) { - SDL_snprintf (drive, SDL_arraysize (drive), "/dev/%sc", - &checklist[i][3]); - insert = SDL_strchr (drive, '?'); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%sc", + &checklist[i][3]); + insert = SDL_strchr(drive, '?'); if (insert != NULL) { *insert = j; } - switch (CheckDrive (drive, &stbuf)) { + switch (CheckDrive(drive, &stbuf)) { /* Drive exists and is a CD-ROM */ case 1: - AddDrive (drive, &stbuf); + AddDrive(drive, &stbuf); break; /* Drive exists, but isn't a CD-ROM */ case 0: @@ -214,10 +214,10 @@ } } } else { - SDL_snprintf (drive, SDL_arraysize (drive), "/dev/%s", - checklist[i]); - if (CheckDrive (drive, &stbuf) > 0) { - AddDrive (drive, &stbuf); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", + checklist[i]); + if (CheckDrive(drive, &stbuf) > 0) { + AddDrive(drive, &stbuf); } } } @@ -226,31 +226,31 @@ /* General ioctl() CD-ROM command function */ static int -SDL_SYS_CDioctl (int id, int command, void *arg) +SDL_SYS_CDioctl(int id, int command, void *arg) { int retval; - retval = ioctl (id, command, arg); + retval = ioctl(id, command, arg); if (retval < 0) { - SDL_SetError ("ioctl() error: %s", strerror (errno)); + SDL_SetError("ioctl() error: %s", strerror(errno)); } return (retval); } static const char * -SDL_SYS_CDName (int drive) +SDL_SYS_CDName(int drive) { return (SDL_cdlist[drive]); } static int -SDL_SYS_CDOpen (int drive) +SDL_SYS_CDOpen(int drive) { - return (open (SDL_cdlist[drive], (O_RDONLY | O_EXCL | O_NONBLOCK), 0)); + return (open(SDL_cdlist[drive], (O_RDONLY | O_EXCL | O_NONBLOCK), 0)); } static int -SDL_SYS_CDGetTOC (SDL_CD * cdrom) +SDL_SYS_CDGetTOC(SDL_CD * cdrom) { struct ioc_toc_header toc; int i, okay; @@ -258,7 +258,7 @@ struct cd_toc_entry data; okay = 0; - if (SDL_SYS_CDioctl (cdrom->id, CDIOREADTOCHEADER, &toc) == 0) { + if (SDL_SYS_CDioctl(cdrom->id, CDIOREADTOCHEADER, &toc) == 0) { cdrom->numtracks = toc.ending_track - toc.starting_track + 1; if (cdrom->numtracks > SDL_MAX_TRACKS) { cdrom->numtracks = SDL_MAX_TRACKS; @@ -272,15 +272,15 @@ } entry.starting_track = cdrom->track[i].id; entry.address_format = CD_MSF_FORMAT; - entry.data_len = sizeof (data); + entry.data_len = sizeof(data); entry.data = &data; - if (SDL_SYS_CDioctl (cdrom->id, CDIOREADTOCENTRYS, &entry) < 0) { + if (SDL_SYS_CDioctl(cdrom->id, CDIOREADTOCENTRYS, &entry) < 0) { break; } else { cdrom->track[i].type = data.control; cdrom->track[i].offset = - MSF_TO_FRAMES (data.addr.msf.minute, - data.addr.msf.second, data.addr.msf.frame); + MSF_TO_FRAMES(data.addr.msf.minute, + data.addr.msf.second, data.addr.msf.frame); cdrom->track[i].length = 0; if (i > 0) { cdrom->track[i - 1].length = @@ -297,7 +297,7 @@ /* Get CD-ROM status */ static CDstatus -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position) { CDstatus status; struct ioc_toc_header toc; @@ -307,10 +307,10 @@ info.address_format = CD_MSF_FORMAT; info.data_format = CD_CURRENT_POSITION; info.track = 0; - info.data_len = sizeof (data); + info.data_len = sizeof(data); info.data = &data; - if (ioctl (cdrom->id, CDIOCREADSUBCHANNEL, &info) < 0) { - if (ERRNO_TRAYEMPTY (errno)) { + if (ioctl(cdrom->id, CDIOCREADSUBCHANNEL, &info) < 0) { + if (ERRNO_TRAYEMPTY(errno)) { status = CD_TRAYEMPTY; } else { status = CD_ERROR; @@ -320,7 +320,7 @@ case CD_AS_AUDIO_INVALID: case CD_AS_NO_STATUS: /* Try to determine if there's a CD available */ - if (ioctl (cdrom->id, CDIOREADTOCHEADER, &toc) == 0) + if (ioctl(cdrom->id, CDIOREADTOCHEADER, &toc) == 0) status = CD_STOPPED; else status = CD_TRAYEMPTY; @@ -342,9 +342,9 @@ if (position) { if (status == CD_PLAYING || (status == CD_PAUSED)) { *position = - MSF_TO_FRAMES (data.what.position.absaddr.msf.minute, - data.what.position.absaddr.msf.second, - data.what.position.absaddr.msf.frame); + MSF_TO_FRAMES(data.what.position.absaddr.msf.minute, + data.what.position.absaddr.msf.second, + data.what.position.absaddr.msf.frame); } else { *position = 0; } @@ -354,66 +354,66 @@ /* Start play */ static int -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) { struct ioc_play_msf playtime; - FRAMES_TO_MSF (start, - &playtime.start_m, &playtime.start_s, &playtime.start_f); - FRAMES_TO_MSF (start + length, - &playtime.end_m, &playtime.end_s, &playtime.end_f); + FRAMES_TO_MSF(start, + &playtime.start_m, &playtime.start_s, &playtime.start_f); + FRAMES_TO_MSF(start + length, + &playtime.end_m, &playtime.end_s, &playtime.end_f); #ifdef DEBUG_CDROM - fprintf (stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", - playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0, - playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1); + fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", + playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0, + playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1); #endif - ioctl (cdrom->id, CDIOCSTART, 0); - return (SDL_SYS_CDioctl (cdrom->id, CDIOCPLAYMSF, &playtime)); + ioctl(cdrom->id, CDIOCSTART, 0); + return (SDL_SYS_CDioctl(cdrom->id, CDIOCPLAYMSF, &playtime)); } /* Pause play */ static int -SDL_SYS_CDPause (SDL_CD * cdrom) +SDL_SYS_CDPause(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, CDIOCPAUSE, 0)); + return (SDL_SYS_CDioctl(cdrom->id, CDIOCPAUSE, 0)); } /* Resume play */ static int -SDL_SYS_CDResume (SDL_CD * cdrom) +SDL_SYS_CDResume(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, CDIOCRESUME, 0)); + return (SDL_SYS_CDioctl(cdrom->id, CDIOCRESUME, 0)); } /* Stop play */ static int -SDL_SYS_CDStop (SDL_CD * cdrom) +SDL_SYS_CDStop(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, CDIOCSTOP, 0)); + return (SDL_SYS_CDioctl(cdrom->id, CDIOCSTOP, 0)); } /* Eject the CD-ROM */ static int -SDL_SYS_CDEject (SDL_CD * cdrom) +SDL_SYS_CDEject(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, CDIOCEJECT, 0)); + return (SDL_SYS_CDioctl(cdrom->id, CDIOCEJECT, 0)); } /* Close the CD-ROM handle */ static void -SDL_SYS_CDClose (SDL_CD * cdrom) +SDL_SYS_CDClose(SDL_CD * cdrom) { - close (cdrom->id); + close(cdrom->id); } void -SDL_SYS_CDQuit (void) +SDL_SYS_CDQuit(void) { int i; if (SDL_numcds > 0) { for (i = 0; i < SDL_numcds; ++i) { - SDL_free (SDL_cdlist[i]); + SDL_free(SDL_cdlist[i]); } SDL_numcds = 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/linux/SDL_syscdrom.c --- a/src/cdrom/linux/SDL_syscdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/linux/SDL_syscdrom.c Mon May 29 04:04:35 2006 +0000 @@ -96,16 +96,16 @@ static dev_t SDL_cdmode[MAX_DRIVES]; /* The system-dependent CD control functions */ -static const char *SDL_SYS_CDName (int drive); -static int SDL_SYS_CDOpen (int drive); -static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); -static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); -static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); -static int SDL_SYS_CDPause (SDL_CD * cdrom); -static int SDL_SYS_CDResume (SDL_CD * cdrom); -static int SDL_SYS_CDStop (SDL_CD * cdrom); -static int SDL_SYS_CDEject (SDL_CD * cdrom); -static void SDL_SYS_CDClose (SDL_CD * cdrom); +static const char *SDL_SYS_CDName(int drive); +static int SDL_SYS_CDOpen(int drive); +static int SDL_SYS_CDGetTOC(SDL_CD * cdrom); +static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position); +static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length); +static int SDL_SYS_CDPause(SDL_CD * cdrom); +static int SDL_SYS_CDResume(SDL_CD * cdrom); +static int SDL_SYS_CDStop(SDL_CD * cdrom); +static int SDL_SYS_CDEject(SDL_CD * cdrom); +static void SDL_SYS_CDClose(SDL_CD * cdrom); /* Some ioctl() errno values which occur when the tray is empty */ #ifndef ENOMEDIUM @@ -117,33 +117,33 @@ /* Check a drive to see if it is a CD-ROM */ static int -CheckDrive (char *drive, char *mnttype, struct stat *stbuf) +CheckDrive(char *drive, char *mnttype, struct stat *stbuf) { int is_cd, cdfd; struct cdrom_subchnl info; /* If it doesn't exist, return -1 */ - if (stat (drive, stbuf) < 0) { + if (stat(drive, stbuf) < 0) { return (-1); } /* If it does exist, verify that it's an available CD-ROM */ is_cd = 0; - if (S_ISCHR (stbuf->st_mode) || S_ISBLK (stbuf->st_mode)) { - cdfd = open (drive, (O_RDONLY | O_NONBLOCK), 0); + if (S_ISCHR(stbuf->st_mode) || S_ISBLK(stbuf->st_mode)) { + cdfd = open(drive, (O_RDONLY | O_NONBLOCK), 0); if (cdfd >= 0) { info.cdsc_format = CDROM_MSF; /* Under Linux, EIO occurs when a disk is not present. */ - if ((ioctl (cdfd, CDROMSUBCHNL, &info) == 0) || - ERRNO_TRAYEMPTY (errno)) { + if ((ioctl(cdfd, CDROMSUBCHNL, &info) == 0) || + ERRNO_TRAYEMPTY(errno)) { is_cd = 1; } - close (cdfd); + close(cdfd); } #ifdef USE_MNTENT /* Even if we can't read it, it might be mounted */ - else if (mnttype && (SDL_strcmp (mnttype, MNTTYPE_CDROM) == 0)) { + else if (mnttype && (SDL_strcmp(mnttype, MNTTYPE_CDROM) == 0)) { is_cd = 1; } #endif @@ -153,7 +153,7 @@ /* Add a CD-ROM drive to our list of valid drives */ static void -AddDrive (char *drive, struct stat *stbuf) +AddDrive(char *drive, struct stat *stbuf) { int i; @@ -164,8 +164,8 @@ for (i = 0; i < SDL_numcds; ++i) { if (stbuf->st_rdev == SDL_cdmode[i]) { #ifdef DEBUG_CDROM - fprintf (stderr, "Duplicate drive detected: %s == %s\n", - drive, SDL_cdlist[i]); + fprintf(stderr, "Duplicate drive detected: %s == %s\n", + drive, SDL_cdlist[i]); #endif return; } @@ -173,28 +173,28 @@ /* Add this drive to our list */ i = SDL_numcds; - SDL_cdlist[i] = SDL_strdup (drive); + SDL_cdlist[i] = SDL_strdup(drive); if (SDL_cdlist[i] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return; } SDL_cdmode[i] = stbuf->st_rdev; ++SDL_numcds; #ifdef DEBUG_CDROM - fprintf (stderr, "Added CD-ROM drive: %s\n", drive); + fprintf(stderr, "Added CD-ROM drive: %s\n", drive); #endif } } #ifdef USE_MNTENT static void -CheckMounts (const char *mtab) +CheckMounts(const char *mtab) { FILE *mntfp; struct mntent *mntent; struct stat stbuf; - mntfp = setmntent (mtab, "r"); + mntfp = setmntent(mtab, "r"); if (mntfp != NULL) { char *tmp; char *mnt_type; @@ -202,67 +202,67 @@ char *mnt_dev; size_t mnt_dev_len; - while ((mntent = getmntent (mntfp)) != NULL) { - mnt_type_len = SDL_strlen (mntent->mnt_type) + 1; - mnt_type = SDL_stack_alloc (char, mnt_type_len); + while ((mntent = getmntent(mntfp)) != NULL) { + mnt_type_len = SDL_strlen(mntent->mnt_type) + 1; + mnt_type = SDL_stack_alloc(char, mnt_type_len); if (mnt_type == NULL) continue; /* maybe you'll get lucky next time. */ - mnt_dev_len = SDL_strlen (mntent->mnt_fsname) + 1; - mnt_dev = SDL_stack_alloc (char, mnt_dev_len); + mnt_dev_len = SDL_strlen(mntent->mnt_fsname) + 1; + mnt_dev = SDL_stack_alloc(char, mnt_dev_len); if (mnt_dev == NULL) { - SDL_stack_free (mnt_type); + SDL_stack_free(mnt_type); continue; } - SDL_strlcpy (mnt_type, mntent->mnt_type, mnt_type_len); - SDL_strlcpy (mnt_dev, mntent->mnt_fsname, mnt_dev_len); + SDL_strlcpy(mnt_type, mntent->mnt_type, mnt_type_len); + SDL_strlcpy(mnt_dev, mntent->mnt_fsname, mnt_dev_len); /* Handle "supermount" filesystem mounts */ - if (SDL_strcmp (mnt_type, MNTTYPE_SUPER) == 0) { - tmp = SDL_strstr (mntent->mnt_opts, "fs="); + if (SDL_strcmp(mnt_type, MNTTYPE_SUPER) == 0) { + tmp = SDL_strstr(mntent->mnt_opts, "fs="); if (tmp) { - SDL_free (mnt_type); - mnt_type = SDL_strdup (tmp + SDL_strlen ("fs=")); + SDL_free(mnt_type); + mnt_type = SDL_strdup(tmp + SDL_strlen("fs=")); if (mnt_type) { - tmp = SDL_strchr (mnt_type, ','); + tmp = SDL_strchr(mnt_type, ','); if (tmp) { *tmp = '\0'; } } } - tmp = SDL_strstr (mntent->mnt_opts, "dev="); + tmp = SDL_strstr(mntent->mnt_opts, "dev="); if (tmp) { - SDL_free (mnt_dev); - mnt_dev = SDL_strdup (tmp + SDL_strlen ("dev=")); + SDL_free(mnt_dev); + mnt_dev = SDL_strdup(tmp + SDL_strlen("dev=")); if (mnt_dev) { - tmp = SDL_strchr (mnt_dev, ','); + tmp = SDL_strchr(mnt_dev, ','); if (tmp) { *tmp = '\0'; } } } } - if (SDL_strcmp (mnt_type, MNTTYPE_CDROM) == 0) { + if (SDL_strcmp(mnt_type, MNTTYPE_CDROM) == 0) { #ifdef DEBUG_CDROM - fprintf (stderr, - "Checking mount path from %s: %s mounted on %s of %s\n", - mtab, mnt_dev, mntent->mnt_dir, mnt_type); + fprintf(stderr, + "Checking mount path from %s: %s mounted on %s of %s\n", + mtab, mnt_dev, mntent->mnt_dir, mnt_type); #endif - if (CheckDrive (mnt_dev, mnt_type, &stbuf) > 0) { - AddDrive (mnt_dev, &stbuf); + if (CheckDrive(mnt_dev, mnt_type, &stbuf) > 0) { + AddDrive(mnt_dev, &stbuf); } } - SDL_stack_free (mnt_dev); - SDL_stack_free (mnt_type); + SDL_stack_free(mnt_dev); + SDL_stack_free(mnt_type); } - endmntent (mntfp); + endmntent(mntfp); } } #endif /* USE_MNTENT */ int -SDL_SYS_CDInit (void) +SDL_SYS_CDInit(void) { /* checklist: /dev/cdrom, /dev/hd?, /dev/scd? /dev/sr? */ static char *checklist[] = { @@ -286,26 +286,26 @@ SDL_CDcaps.Close = SDL_SYS_CDClose; /* Look in the environment for our CD-ROM drive list */ - SDLcdrom = SDL_getenv ("SDL_CDROM"); /* ':' separated list of devices */ + SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ if (SDLcdrom != NULL) { char *cdpath, *delim; - size_t len = SDL_strlen (SDLcdrom) + 1; - cdpath = SDL_stack_alloc (char, len); + size_t len = SDL_strlen(SDLcdrom) + 1; + cdpath = SDL_stack_alloc(char, len); if (cdpath != NULL) { - SDL_strlcpy (cdpath, SDLcdrom, len); + SDL_strlcpy(cdpath, SDLcdrom, len); SDLcdrom = cdpath; do { - delim = SDL_strchr (SDLcdrom, ':'); + delim = SDL_strchr(SDLcdrom, ':'); if (delim) { *delim++ = '\0'; } #ifdef DEBUG_CDROM - fprintf (stderr, - "Checking CD-ROM drive from SDL_CDROM: %s\n", - SDLcdrom); + fprintf(stderr, + "Checking CD-ROM drive from SDL_CDROM: %s\n", + SDLcdrom); #endif - if (CheckDrive (SDLcdrom, NULL, &stbuf) > 0) { - AddDrive (SDLcdrom, &stbuf); + if (CheckDrive(SDLcdrom, NULL, &stbuf) > 0) { + AddDrive(SDLcdrom, &stbuf); } if (delim) { SDLcdrom = delim; @@ -314,7 +314,7 @@ } } while (SDLcdrom); - SDL_stack_free (cdpath); + SDL_stack_free(cdpath); } /* If we found our drives, there's nothing left to do */ @@ -324,15 +324,15 @@ } #ifdef USE_MNTENT /* Check /dev/cdrom first :-) */ - if (CheckDrive ("/dev/cdrom", NULL, &stbuf) > 0) { - AddDrive ("/dev/cdrom", &stbuf); + if (CheckDrive("/dev/cdrom", NULL, &stbuf) > 0) { + AddDrive("/dev/cdrom", &stbuf); } /* Now check the currently mounted CD drives */ - CheckMounts (_PATH_MOUNTED); + CheckMounts(_PATH_MOUNTED); /* Finally check possible mountable drives in /etc/fstab */ - CheckMounts (_PATH_MNTTAB); + CheckMounts(_PATH_MNTTAB); /* If we found our drives, there's nothing left to do */ if (SDL_numcds > 0) { @@ -348,20 +348,20 @@ char *insert; exists = 1; for (j = checklist[i][1]; exists; ++j) { - SDL_snprintf (drive, SDL_arraysize (drive), "/dev/%s", - &checklist[i][3]); - insert = SDL_strchr (drive, '?'); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", + &checklist[i][3]); + insert = SDL_strchr(drive, '?'); if (insert != NULL) { *insert = j; } #ifdef DEBUG_CDROM - fprintf (stderr, "Checking possible CD-ROM drive: %s\n", - drive); + fprintf(stderr, "Checking possible CD-ROM drive: %s\n", + drive); #endif - switch (CheckDrive (drive, NULL, &stbuf)) { + switch (CheckDrive(drive, NULL, &stbuf)) { /* Drive exists and is a CD-ROM */ case 1: - AddDrive (drive, &stbuf); + AddDrive(drive, &stbuf); break; /* Drive exists, but isn't a CD-ROM */ case 0: @@ -373,13 +373,13 @@ } } } else { - SDL_snprintf (drive, SDL_arraysize (drive), "/dev/%s", - checklist[i]); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", + checklist[i]); #ifdef DEBUG_CDROM - fprintf (stderr, "Checking possible CD-ROM drive: %s\n", drive); + fprintf(stderr, "Checking possible CD-ROM drive: %s\n", drive); #endif - if (CheckDrive (drive, NULL, &stbuf) > 0) { - AddDrive (drive, &stbuf); + if (CheckDrive(drive, NULL, &stbuf) > 0) { + AddDrive(drive, &stbuf); } } } @@ -388,38 +388,38 @@ /* General ioctl() CD-ROM command function */ static int -SDL_SYS_CDioctl (int id, int command, void *arg) +SDL_SYS_CDioctl(int id, int command, void *arg) { int retval; - retval = ioctl (id, command, arg); + retval = ioctl(id, command, arg); if (retval < 0) { - SDL_SetError ("ioctl() error: %s", strerror (errno)); + SDL_SetError("ioctl() error: %s", strerror(errno)); } return (retval); } static const char * -SDL_SYS_CDName (int drive) +SDL_SYS_CDName(int drive) { return (SDL_cdlist[drive]); } static int -SDL_SYS_CDOpen (int drive) +SDL_SYS_CDOpen(int drive) { - return (open (SDL_cdlist[drive], (O_RDONLY | O_NONBLOCK), 0)); + return (open(SDL_cdlist[drive], (O_RDONLY | O_NONBLOCK), 0)); } static int -SDL_SYS_CDGetTOC (SDL_CD * cdrom) +SDL_SYS_CDGetTOC(SDL_CD * cdrom) { struct cdrom_tochdr toc; int i, okay; struct cdrom_tocentry entry; okay = 0; - if (SDL_SYS_CDioctl (cdrom->id, CDROMREADTOCHDR, &toc) == 0) { + if (SDL_SYS_CDioctl(cdrom->id, CDROMREADTOCHDR, &toc) == 0) { cdrom->numtracks = toc.cdth_trk1 - toc.cdth_trk0 + 1; if (cdrom->numtracks > SDL_MAX_TRACKS) { cdrom->numtracks = SDL_MAX_TRACKS; @@ -433,7 +433,7 @@ } entry.cdte_track = cdrom->track[i].id; entry.cdte_format = CDROM_MSF; - if (SDL_SYS_CDioctl (cdrom->id, CDROMREADTOCENTRY, &entry) < 0) { + if (SDL_SYS_CDioctl(cdrom->id, CDROMREADTOCENTRY, &entry) < 0) { break; } else { if (entry.cdte_ctrl & CDROM_DATA_TRACK) { @@ -442,9 +442,9 @@ cdrom->track[i].type = SDL_AUDIO_TRACK; } cdrom->track[i].offset = - MSF_TO_FRAMES (entry.cdte_addr.msf.minute, - entry.cdte_addr.msf.second, - entry.cdte_addr.msf.frame); + MSF_TO_FRAMES(entry.cdte_addr.msf.minute, + entry.cdte_addr.msf.second, + entry.cdte_addr.msf.frame); cdrom->track[i].length = 0; if (i > 0) { cdrom->track[i - 1].length = @@ -461,15 +461,15 @@ /* Get CD-ROM status */ static CDstatus -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position) { CDstatus status; struct cdrom_tochdr toc; struct cdrom_subchnl info; info.cdsc_format = CDROM_MSF; - if (ioctl (cdrom->id, CDROMSUBCHNL, &info) < 0) { - if (ERRNO_TRAYEMPTY (errno)) { + if (ioctl(cdrom->id, CDROMSUBCHNL, &info) < 0) { + if (ERRNO_TRAYEMPTY(errno)) { status = CD_TRAYEMPTY; } else { status = CD_ERROR; @@ -479,7 +479,7 @@ case CDROM_AUDIO_INVALID: case CDROM_AUDIO_NO_STATUS: /* Try to determine if there's a CD available */ - if (ioctl (cdrom->id, CDROMREADTOCHDR, &toc) == 0) + if (ioctl(cdrom->id, CDROMREADTOCHDR, &toc) == 0) status = CD_STOPPED; else status = CD_TRAYEMPTY; @@ -505,9 +505,9 @@ } if (position) { if (status == CD_PLAYING || (status == CD_PAUSED)) { - *position = MSF_TO_FRAMES (info.cdsc_absaddr.msf.minute, - info.cdsc_absaddr.msf.second, - info.cdsc_absaddr.msf.frame); + *position = MSF_TO_FRAMES(info.cdsc_absaddr.msf.minute, + info.cdsc_absaddr.msf.second, + info.cdsc_absaddr.msf.frame); } else { *position = 0; } @@ -517,66 +517,66 @@ /* Start play */ static int -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) { struct cdrom_msf playtime; - FRAMES_TO_MSF (start, - &playtime.cdmsf_min0, &playtime.cdmsf_sec0, - &playtime.cdmsf_frame0); - FRAMES_TO_MSF (start + length, &playtime.cdmsf_min1, &playtime.cdmsf_sec1, - &playtime.cdmsf_frame1); + FRAMES_TO_MSF(start, + &playtime.cdmsf_min0, &playtime.cdmsf_sec0, + &playtime.cdmsf_frame0); + FRAMES_TO_MSF(start + length, &playtime.cdmsf_min1, &playtime.cdmsf_sec1, + &playtime.cdmsf_frame1); #ifdef DEBUG_CDROM - fprintf (stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", - playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0, - playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1); + fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", + playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0, + playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1); #endif - return (SDL_SYS_CDioctl (cdrom->id, CDROMPLAYMSF, &playtime)); + return (SDL_SYS_CDioctl(cdrom->id, CDROMPLAYMSF, &playtime)); } /* Pause play */ static int -SDL_SYS_CDPause (SDL_CD * cdrom) +SDL_SYS_CDPause(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, CDROMPAUSE, 0)); + return (SDL_SYS_CDioctl(cdrom->id, CDROMPAUSE, 0)); } /* Resume play */ static int -SDL_SYS_CDResume (SDL_CD * cdrom) +SDL_SYS_CDResume(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, CDROMRESUME, 0)); + return (SDL_SYS_CDioctl(cdrom->id, CDROMRESUME, 0)); } /* Stop play */ static int -SDL_SYS_CDStop (SDL_CD * cdrom) +SDL_SYS_CDStop(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, CDROMSTOP, 0)); + return (SDL_SYS_CDioctl(cdrom->id, CDROMSTOP, 0)); } /* Eject the CD-ROM */ static int -SDL_SYS_CDEject (SDL_CD * cdrom) +SDL_SYS_CDEject(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, CDROMEJECT, 0)); + return (SDL_SYS_CDioctl(cdrom->id, CDROMEJECT, 0)); } /* Close the CD-ROM handle */ static void -SDL_SYS_CDClose (SDL_CD * cdrom) +SDL_SYS_CDClose(SDL_CD * cdrom) { - close (cdrom->id); + close(cdrom->id); } void -SDL_SYS_CDQuit (void) +SDL_SYS_CDQuit(void) { int i; if (SDL_numcds > 0) { for (i = 0; i < SDL_numcds; ++i) { - SDL_free (SDL_cdlist[i]); + SDL_free(SDL_cdlist[i]); } SDL_numcds = 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/macos/SDL_syscdrom.c --- a/src/cdrom/macos/SDL_syscdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/macos/SDL_syscdrom.c Mon May 29 04:04:35 2006 +0000 @@ -54,31 +54,31 @@ static StringPtr gDriverName = "\p.AppleCD"; /* The system-dependent CD control functions */ -static const char *SDL_SYS_CDName (int drive); -static int SDL_SYS_CDOpen (int drive); -static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); -static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); -static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); -static int SDL_SYS_CDPause (SDL_CD * cdrom); -static int SDL_SYS_CDResume (SDL_CD * cdrom); -static int SDL_SYS_CDStop (SDL_CD * cdrom); -static int SDL_SYS_CDEject (SDL_CD * cdrom); -static void SDL_SYS_CDClose (SDL_CD * cdrom); +static const char *SDL_SYS_CDName(int drive); +static int SDL_SYS_CDOpen(int drive); +static int SDL_SYS_CDGetTOC(SDL_CD * cdrom); +static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position); +static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length); +static int SDL_SYS_CDPause(SDL_CD * cdrom); +static int SDL_SYS_CDResume(SDL_CD * cdrom); +static int SDL_SYS_CDStop(SDL_CD * cdrom); +static int SDL_SYS_CDEject(SDL_CD * cdrom); +static void SDL_SYS_CDClose(SDL_CD * cdrom); static short -SDL_SYS_ShortToBCD (short value) +SDL_SYS_ShortToBCD(short value) { return ((value % 10) + (value / 10) * 0x10); /* Convert value to BCD */ } static short -SDL_SYS_BCDToShort (short value) +SDL_SYS_BCDToShort(short value) { return ((value % 0x10) + (value / 0x10) * 10); /* Convert value from BCD */ } int -SDL_SYS_CDInit (void) +SDL_SYS_CDInit(void) { SInt16 dRefNum = 0; SInt16 first, last; @@ -86,7 +86,7 @@ SDL_numcds = 0; /* Check that the software is available */ - if (Gestalt (kGestaltAudioCDSelector, &SDL_cdversion) || !SDL_cdversion) + if (Gestalt(kGestaltAudioCDSelector, &SDL_cdversion) || !SDL_cdversion) return (0); /* Fill in our driver capabilities */ @@ -103,13 +103,13 @@ /* Walk the list, count each AudioCD driver, and save the refnums */ first = -1; - last = 0 - LMGetUnitTableEntryCount (); + last = 0 - LMGetUnitTableEntryCount(); for (dRefNum = first; dRefNum >= last; dRefNum--) { Str255 driverName; StringPtr namePtr; DCtlHandle deviceEntry; - deviceEntry = GetDCtlEntry (dRefNum); + deviceEntry = GetDCtlEntry(dRefNum); if (!deviceEntry) continue; @@ -117,15 +117,15 @@ namePtr = (*deviceEntry)->dCtlFlags & (1L << dRAMBased) ? ((StringPtr) ((DCtlPtr) deviceEntry)->dCtlDriver + 18) : ((StringPtr) (*deviceEntry)->dCtlDriver + 18); - BlockMoveData (namePtr, driverName, namePtr[0] + 1); + BlockMoveData(namePtr, driverName, namePtr[0] + 1); if (driverName[0] > gDriverName[0]) driverName[0] = gDriverName[0]; - if (!EqualString (driverName, gDriverName, false, false)) + if (!EqualString(driverName, gDriverName, false, false)) continue; /* Record the basic info for each drive */ SDL_cdlist[SDL_numcds].dRefNum = dRefNum; - BlockMoveData (namePtr + 1, SDL_cdlist[SDL_numcds].name, namePtr[0]); + BlockMoveData(namePtr + 1, SDL_cdlist[SDL_numcds].name, namePtr[0]); SDL_cdlist[SDL_numcds].name[namePtr[0]] = 0; SDL_cdlist[SDL_numcds].hasAudio = false; SDL_numcds++; @@ -134,15 +134,15 @@ } static const char * -SDL_SYS_CDName (int drive) +SDL_SYS_CDName(int drive) { return (SDL_cdlist[drive].name); } static int -get_drivenum (int drive) +get_drivenum(int drive) { - QHdr *driveQ = GetDrvQHdr (); + QHdr *driveQ = GetDrvQHdr(); DrvQEl *driveElem; /* Update the drive number */ @@ -161,32 +161,32 @@ } static int -SDL_SYS_CDOpen (int drive) +SDL_SYS_CDOpen(int drive) { return (drive); } static int -SDL_SYS_CDGetTOC (SDL_CD * cdrom) +SDL_SYS_CDGetTOC(SDL_CD * cdrom) { CDCntrlParam cdpb; CDTrackData tracks[SDL_MAX_TRACKS]; long i, leadout; /* Get the number of tracks on the CD by examining the TOC */ - SDL_memset (&cdpb, 0, sizeof (cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kReadTOC; cdpb.csParam.words[0] = kGetTrackRange; - if (PBControlSync ((ParmBlkPtr) & cdpb) != noErr) { - SDL_SetError ("PBControlSync() failed"); + if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) { + SDL_SetError("PBControlSync() failed"); return (-1); } cdrom->numtracks = - SDL_SYS_BCDToShort (cdpb.csParam.bytes[1]) - - SDL_SYS_BCDToShort (cdpb.csParam.bytes[0]) + 1; + SDL_SYS_BCDToShort(cdpb.csParam.bytes[1]) - + SDL_SYS_BCDToShort(cdpb.csParam.bytes[0]) + 1; if (cdrom->numtracks > SDL_MAX_TRACKS) cdrom->numtracks = SDL_MAX_TRACKS; cdrom->status = CD_STOPPED; @@ -195,32 +195,32 @@ /* Get the lead out area of the CD by examining the TOC */ - SDL_memset (&cdpb, 0, sizeof (cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kReadTOC; cdpb.csParam.words[0] = kGetLeadOutArea; - if (PBControlSync ((ParmBlkPtr) & cdpb) != noErr) { - SDL_SetError ("PBControlSync() failed"); + if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) { + SDL_SetError("PBControlSync() failed"); return (-1); } - leadout = MSF_TO_FRAMES (SDL_SYS_BCDToShort (cdpb.csParam.bytes[0]), - SDL_SYS_BCDToShort (cdpb.csParam.bytes[1]), - SDL_SYS_BCDToShort (cdpb.csParam.bytes[2])); + leadout = MSF_TO_FRAMES(SDL_SYS_BCDToShort(cdpb.csParam.bytes[0]), + SDL_SYS_BCDToShort(cdpb.csParam.bytes[1]), + SDL_SYS_BCDToShort(cdpb.csParam.bytes[2])); /* Get an array of track locations by examining the TOC */ - SDL_memset (tracks, 0, sizeof (tracks)); - SDL_memset (&cdpb, 0, sizeof (cdpb)); + SDL_memset(tracks, 0, sizeof(tracks)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kReadTOC; cdpb.csParam.words[0] = kGetTrackEntries; /* Type of Query */ *((long *) (cdpb.csParam.words + 1)) = (long) tracks; - cdpb.csParam.words[3] = cdrom->numtracks * sizeof (tracks[0]); + cdpb.csParam.words[3] = cdrom->numtracks * sizeof(tracks[0]); *((char *) (cdpb.csParam.words + 4)) = 1; /* First track */ - if (PBControlSync ((ParmBlkPtr) & cdpb) != noErr) { - SDL_SetError ("PBControlSync() failed"); + if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) { + SDL_SetError("PBControlSync() failed"); return (-1); } @@ -236,13 +236,13 @@ } cdrom->track[i].offset = - MSF_TO_FRAMES (SDL_SYS_BCDToShort (tracks[i].entry.min), - SDL_SYS_BCDToShort (tracks[i].entry.min), - SDL_SYS_BCDToShort (tracks[i].entry.frame)); + MSF_TO_FRAMES(SDL_SYS_BCDToShort(tracks[i].entry.min), + SDL_SYS_BCDToShort(tracks[i].entry.min), + SDL_SYS_BCDToShort(tracks[i].entry.frame)); cdrom->track[i].length = - MSF_TO_FRAMES (SDL_SYS_BCDToShort (tracks[i + 1].entry.min), - SDL_SYS_BCDToShort (tracks[i + 1].entry.min), - SDL_SYS_BCDToShort (tracks[i + 1].entry.frame)) - + MSF_TO_FRAMES(SDL_SYS_BCDToShort(tracks[i + 1].entry.min), + SDL_SYS_BCDToShort(tracks[i + 1].entry.min), + SDL_SYS_BCDToShort(tracks[i + 1].entry.frame)) - cdrom->track[i].offset; } @@ -255,7 +255,7 @@ /* Get CD-ROM status */ static CDstatus -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position) { CDCntrlParam cdpb; CDstatus status = CD_ERROR; @@ -265,22 +265,22 @@ *position = 0; /* Get the number of tracks on the CD by examining the TOC */ - if (!get_drivenum (cdrom->id)) { + if (!get_drivenum(cdrom->id)) { return (CD_TRAYEMPTY); } - SDL_memset (&cdpb, 0, sizeof (cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kReadTOC; cdpb.csParam.words[0] = kGetTrackRange; - if (PBControlSync ((ParmBlkPtr) & cdpb) != noErr) { - SDL_SetError ("PBControlSync() failed"); + if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) { + SDL_SetError("PBControlSync() failed"); return (CD_ERROR); } cdrom->numtracks = - SDL_SYS_BCDToShort (cdpb.csParam.bytes[1]) - - SDL_SYS_BCDToShort (cdpb.csParam.bytes[0]) + 1; + SDL_SYS_BCDToShort(cdpb.csParam.bytes[1]) - + SDL_SYS_BCDToShort(cdpb.csParam.bytes[0]) + 1; if (cdrom->numtracks > SDL_MAX_TRACKS) cdrom->numtracks = SDL_MAX_TRACKS; cdrom->cur_track = 0; /* Apparently these are set elsewhere */ @@ -289,12 +289,12 @@ if (1 || SDL_cdlist[cdrom->id].hasAudio) { /* Get the current playback status */ - SDL_memset (&cdpb, 0, sizeof (cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioStatus; - if (PBControlSync ((ParmBlkPtr) & cdpb) != noErr) { - SDL_SetError ("PBControlSync() failed"); + if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) { + SDL_SetError("PBControlSync() failed"); return (-1); } @@ -328,9 +328,9 @@ if (spinning && position) *position = - MSF_TO_FRAMES (SDL_SYS_BCDToShort (cdpb.csParam.cd.minute), - SDL_SYS_BCDToShort (cdpb.csParam.cd.second), - SDL_SYS_BCDToShort (cdpb.csParam.cd.frame)); + MSF_TO_FRAMES(SDL_SYS_BCDToShort(cdpb.csParam.cd.minute), + SDL_SYS_BCDToShort(cdpb.csParam.cd.second), + SDL_SYS_BCDToShort(cdpb.csParam.cd.frame)); } else status = CD_ERROR; /* What should I do here? */ @@ -339,40 +339,40 @@ /* Start play */ static int -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) { CDCntrlParam cdpb; /* Pause the current audio playback to avoid audible artifacts */ - if (SDL_SYS_CDPause (cdrom) < 0) { + if (SDL_SYS_CDPause(cdrom) < 0) { return (-1); } /* Specify the AudioCD playback mode */ - SDL_memset (&cdpb, 0, sizeof (cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kSetPlayMode; cdpb.csParam.bytes[0] = false; /* Repeat? */ cdpb.csParam.bytes[1] = kPlayModeSequential; /* Play mode */ /* ¥¥¥ÊTreat as soft error, NEC Drive doesnt support this call ¥¥¥ */ - PBControlSync ((ParmBlkPtr) & cdpb); + PBControlSync((ParmBlkPtr) & cdpb); #if 1 /* Specify the end of audio playback */ - SDL_memset (&cdpb, 0, sizeof (cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioStop; cdpb.csParam.words[0] = kBlockPosition; /* Position Mode */ *(long *) (cdpb.csParam.words + 1) = start + length - 1; /* Search Address */ - if (PBControlSync ((ParmBlkPtr) & cdpb) != noErr) { - SDL_SetError ("PBControlSync() failed"); + if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) { + SDL_SetError("PBControlSync() failed"); return (-1); } /* Specify the start of audio playback, and start it */ - SDL_memset (&cdpb, 0, sizeof (cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioPlay; @@ -380,39 +380,39 @@ *(long *) (cdpb.csParam.words + 1) = start + 1; /* Search Address */ cdpb.csParam.words[3] = false; /* Stop address? */ cdpb.csParam.words[4] = kStereoPlayMode; /* Audio Play Mode */ - if (PBControlSync ((ParmBlkPtr) & cdpb) != noErr) { - SDL_SetError ("PBControlSync() failed"); + if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) { + SDL_SetError("PBControlSync() failed"); return (-1); } #else /* Specify the end of audio playback */ - FRAMES_TO_MSF (start + length, &m, &s, &f); - SDL_memset (&cdpb, 0, sizeof (cdpb)); + FRAMES_TO_MSF(start + length, &m, &s, &f); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioStop; cdpb.csParam.words[0] = kTrackPosition; /* Position Mode */ cdpb.csParam.words[1] = 0; /* Search Address (hiword) */ cdpb.csParam.words[2] = /* Search Address (loword) */ - SDL_SYS_ShortToBCD (cdrom->numtracks); - if (PBControlSync ((ParmBlkPtr) & cdpb) != noErr) { - SDL_SetError ("PBControlSync() failed"); + SDL_SYS_ShortToBCD(cdrom->numtracks); + if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) { + SDL_SetError("PBControlSync() failed"); return (-1); } /* Specify the start of audio playback, and start it */ - FRAMES_TO_MSF (start, &m, &s, &f); - SDL_memset (&cdpb, 0, sizeof (cdpb)); + FRAMES_TO_MSF(start, &m, &s, &f); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioPlay; cdpb.csParam.words[0] = kTrackPosition; /* Position Mode */ cdpb.csParam.words[1] = 0; /* Search Address (hiword) */ - cdpb.csParam.words[2] = SDL_SYS_ShortToBCD (1); /* Search Address (loword) */ + cdpb.csParam.words[2] = SDL_SYS_ShortToBCD(1); /* Search Address (loword) */ cdpb.csParam.words[3] = false; /* Stop address? */ cdpb.csParam.words[4] = kStereoPlayMode; /* Audio Play Mode */ - if (PBControlSync ((ParmBlkPtr) & cdpb) != noErr) { - SDL_SetError ("PBControlSync() failed"); + if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) { + SDL_SetError("PBControlSync() failed"); return (-1); } #endif @@ -422,18 +422,18 @@ /* Pause play */ static int -SDL_SYS_CDPause (SDL_CD * cdrom) +SDL_SYS_CDPause(SDL_CD * cdrom) { CDCntrlParam cdpb; - SDL_memset (&cdpb, 0, sizeof (cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioPause; cdpb.csParam.words[0] = 0; /* Pause/Continue Flag (hiword) */ cdpb.csParam.words[1] = 1; /* Pause/Continue Flag (loword) */ - if (PBControlSync ((ParmBlkPtr) & cdpb) != noErr) { - SDL_SetError ("PBControlSync() failed"); + if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) { + SDL_SetError("PBControlSync() failed"); return (-1); } return (0); @@ -441,18 +441,18 @@ /* Resume play */ static int -SDL_SYS_CDResume (SDL_CD * cdrom) +SDL_SYS_CDResume(SDL_CD * cdrom) { CDCntrlParam cdpb; - SDL_memset (&cdpb, 0, sizeof (cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioPause; cdpb.csParam.words[0] = 0; /* Pause/Continue Flag (hiword) */ cdpb.csParam.words[1] = 0; /* Pause/Continue Flag (loword) */ - if (PBControlSync ((ParmBlkPtr) & cdpb) != noErr) { - SDL_SetError ("PBControlSync() failed"); + if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) { + SDL_SetError("PBControlSync() failed"); return (-1); } return (0); @@ -460,19 +460,19 @@ /* Stop play */ static int -SDL_SYS_CDStop (SDL_CD * cdrom) +SDL_SYS_CDStop(SDL_CD * cdrom) { CDCntrlParam cdpb; - SDL_memset (&cdpb, 0, sizeof (cdpb)); + SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioStop; cdpb.csParam.words[0] = 0; /* Position Mode */ cdpb.csParam.words[1] = 0; /* Search Address (hiword) */ cdpb.csParam.words[2] = 0; /* Search Address (loword) */ - if (PBControlSync ((ParmBlkPtr) & cdpb) != noErr) { - SDL_SetError ("PBControlSync() failed"); + if (PBControlSync((ParmBlkPtr) & cdpb) != noErr) { + SDL_SetError("PBControlSync() failed"); return (-1); } return (0); @@ -480,10 +480,10 @@ /* Eject the CD-ROM */ static int -SDL_SYS_CDEject (SDL_CD * cdrom) +SDL_SYS_CDEject(SDL_CD * cdrom) { Boolean disk = false; - QHdr *driveQ = GetDrvQHdr (); + QHdr *driveQ = GetDrvQHdr(); DrvQEl *driveElem; HParamBlockRec hpb; ParamBlockRec cpb; @@ -499,13 +499,13 @@ } /* Does drive contain mounted volume? If not, skip */ - SDL_memset (&hpb, 0, sizeof (hpb)); + SDL_memset(&hpb, 0, sizeof(hpb)); hpb.volumeParam.ioVRefNum = driveElem->dQDrive; - if (PBHGetVInfoSync (&hpb) != noErr) { + if (PBHGetVInfoSync(&hpb) != noErr) { continue; } - if ((UnmountVol (0, driveElem->dQDrive) == noErr) && - (Eject (0, driveElem->dQDrive) == noErr)) { + if ((UnmountVol(0, driveElem->dQDrive) == noErr) && + (Eject(0, driveElem->dQDrive) == noErr)) { driveElem = 0; /* Clear pointer to reset our loop */ disk = true; } @@ -513,12 +513,12 @@ /* If no disk is present, just eject the tray */ if (!disk) { - SDL_memset (&cpb, 0, sizeof (cpb)); + SDL_memset(&cpb, 0, sizeof(cpb)); cpb.cntrlParam.ioVRefNum = 0; /* No Drive */ cpb.cntrlParam.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cpb.cntrlParam.csCode = kEjectTheDisc; - if (PBControlSync ((ParmBlkPtr) & cpb) != noErr) { - SDL_SetError ("PBControlSync() failed"); + if (PBControlSync((ParmBlkPtr) & cpb) != noErr) { + SDL_SetError("PBControlSync() failed"); return (-1); } } @@ -527,16 +527,16 @@ /* Close the CD-ROM handle */ static void -SDL_SYS_CDClose (SDL_CD * cdrom) +SDL_SYS_CDClose(SDL_CD * cdrom) { return; } void -SDL_SYS_CDQuit (void) +SDL_SYS_CDQuit(void) { while (SDL_numcds--) - SDL_memset (SDL_cdlist + SDL_numcds, 0, sizeof (SDL_cdlist[0])); + SDL_memset(SDL_cdlist + SDL_numcds, 0, sizeof(SDL_cdlist[0])); } #endif /* SDL_CDROM_MACOS */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/macosx/AudioFilePlayer.c --- a/src/cdrom/macosx/AudioFilePlayer.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/macosx/AudioFilePlayer.c Mon May 29 04:04:35 2006 +0000 @@ -39,42 +39,42 @@ #if DEBUG static void -PrintStreamDesc (AudioStreamBasicDescription * inDesc) +PrintStreamDesc(AudioStreamBasicDescription * inDesc) { if (!inDesc) { - printf ("Can't print a NULL desc!\n"); + printf("Can't print a NULL desc!\n"); return; } - printf ("- - - - - - - - - - - - - - - - - - - -\n"); - printf (" Sample Rate:%f\n", inDesc->mSampleRate); - printf (" Format ID:%s\n", (char *) &inDesc->mFormatID); - printf (" Format Flags:%lX\n", inDesc->mFormatFlags); - printf (" Bytes per Packet:%ld\n", inDesc->mBytesPerPacket); - printf (" Frames per Packet:%ld\n", inDesc->mFramesPerPacket); - printf (" Bytes per Frame:%ld\n", inDesc->mBytesPerFrame); - printf (" Channels per Frame:%ld\n", inDesc->mChannelsPerFrame); - printf (" Bits per Channel:%ld\n", inDesc->mBitsPerChannel); - printf ("- - - - - - - - - - - - - - - - - - - -\n"); + printf("- - - - - - - - - - - - - - - - - - - -\n"); + printf(" Sample Rate:%f\n", inDesc->mSampleRate); + printf(" Format ID:%s\n", (char *) &inDesc->mFormatID); + printf(" Format Flags:%lX\n", inDesc->mFormatFlags); + printf(" Bytes per Packet:%ld\n", inDesc->mBytesPerPacket); + printf(" Frames per Packet:%ld\n", inDesc->mFramesPerPacket); + printf(" Bytes per Frame:%ld\n", inDesc->mBytesPerFrame); + printf(" Channels per Frame:%ld\n", inDesc->mChannelsPerFrame); + printf(" Bits per Channel:%ld\n", inDesc->mBitsPerChannel); + printf("- - - - - - - - - - - - - - - - - - - -\n"); } #endif static int -AudioFilePlayer_SetDestination (AudioFilePlayer * afp, AudioUnit * inDestUnit) +AudioFilePlayer_SetDestination(AudioFilePlayer * afp, AudioUnit * inDestUnit) { /*if (afp->mConnected) throw static_cast(-1); *//* can't set dest if already engaged */ if (afp->mConnected) return 0; - SDL_memcpy (&afp->mPlayUnit, inDestUnit, sizeof (afp->mPlayUnit)); + SDL_memcpy(&afp->mPlayUnit, inDestUnit, sizeof(afp->mPlayUnit)); OSStatus result = noErr; /* we can "down" cast a component instance to a component */ ComponentDescription desc; - result = GetComponentInfo ((Component) * inDestUnit, &desc, 0, 0, 0); + result = GetComponentInfo((Component) * inDestUnit, &desc, 0, 0, 0); if (result) return 0; /*THROW_RESULT("GetComponentInfo") */ @@ -89,12 +89,12 @@ } /* Set the input format of the audio unit. */ - result = AudioUnitSetProperty (*inDestUnit, - kAudioUnitProperty_StreamFormat, - kAudioUnitScope_Input, - 0, - &afp->mFileDescription, - sizeof (afp->mFileDescription)); + result = AudioUnitSetProperty(*inDestUnit, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Input, + 0, + &afp->mFileDescription, + sizeof(afp->mFileDescription)); /*THROW_RESULT("AudioUnitSetProperty") */ if (result) return 0; @@ -102,100 +102,100 @@ } static void -AudioFilePlayer_SetNotifier (AudioFilePlayer * afp, - AudioFilePlayNotifier inNotifier, void *inRefCon) +AudioFilePlayer_SetNotifier(AudioFilePlayer * afp, + AudioFilePlayNotifier inNotifier, void *inRefCon) { afp->mNotifier = inNotifier; afp->mRefCon = inRefCon; } static int -AudioFilePlayer_IsConnected (AudioFilePlayer * afp) +AudioFilePlayer_IsConnected(AudioFilePlayer * afp) { return afp->mConnected; } static AudioUnit -AudioFilePlayer_GetDestUnit (AudioFilePlayer * afp) +AudioFilePlayer_GetDestUnit(AudioFilePlayer * afp) { return afp->mPlayUnit; } static void -AudioFilePlayer_Print (AudioFilePlayer * afp) +AudioFilePlayer_Print(AudioFilePlayer * afp) { #if DEBUG - printf ("Is Connected:%s\n", (IsConnected ()? "true" : "false")); - printf ("- - - - - - - - - - - - - - \n"); + printf("Is Connected:%s\n", (IsConnected()? "true" : "false")); + printf("- - - - - - - - - - - - - - \n"); #endif } static void -AudioFilePlayer_SetStartFrame (AudioFilePlayer * afp, int frame) +AudioFilePlayer_SetStartFrame(AudioFilePlayer * afp, int frame) { SInt64 position = frame * 2352; afp->mStartFrame = frame; - afp->mAudioFileManager->SetPosition (afp->mAudioFileManager, position); + afp->mAudioFileManager->SetPosition(afp->mAudioFileManager, position); } static int -AudioFilePlayer_GetCurrentFrame (AudioFilePlayer * afp) +AudioFilePlayer_GetCurrentFrame(AudioFilePlayer * afp) { return afp->mStartFrame + - (afp->mAudioFileManager->GetByteCounter (afp->mAudioFileManager) / + (afp->mAudioFileManager->GetByteCounter(afp->mAudioFileManager) / 2352); } static void -AudioFilePlayer_SetStopFrame (AudioFilePlayer * afp, int frame) +AudioFilePlayer_SetStopFrame(AudioFilePlayer * afp, int frame) { SInt64 position = frame * 2352; - afp->mAudioFileManager->SetEndOfFile (afp->mAudioFileManager, position); + afp->mAudioFileManager->SetEndOfFile(afp->mAudioFileManager, position); } void -delete_AudioFilePlayer (AudioFilePlayer * afp) +delete_AudioFilePlayer(AudioFilePlayer * afp) { if (afp != NULL) { - afp->Disconnect (afp); + afp->Disconnect(afp); if (afp->mAudioFileManager) { - delete_AudioFileManager (afp->mAudioFileManager); + delete_AudioFileManager(afp->mAudioFileManager); afp->mAudioFileManager = 0; } if (afp->mForkRefNum) { - FSCloseFork (afp->mForkRefNum); + FSCloseFork(afp->mForkRefNum); afp->mForkRefNum = 0; } - SDL_free (afp); + SDL_free(afp); } } static int -AudioFilePlayer_Connect (AudioFilePlayer * afp) +AudioFilePlayer_Connect(AudioFilePlayer * afp) { #if DEBUG - printf ("Connect:%x, engaged=%d\n", (int) afp->mPlayUnit, - (afp->mConnected ? 1 : 0)); + printf("Connect:%x, engaged=%d\n", (int) afp->mPlayUnit, + (afp->mConnected ? 1 : 0)); #endif if (!afp->mConnected) { - if (!afp->mAudioFileManager->DoConnect (afp->mAudioFileManager)) + if (!afp->mAudioFileManager->DoConnect(afp->mAudioFileManager)) return 0; /* set the render callback for the file data to be supplied to the sound converter AU */ afp->mInputCallback.inputProc = afp->mAudioFileManager->FileInputProc; afp->mInputCallback.inputProcRefCon = afp->mAudioFileManager; - OSStatus result = AudioUnitSetProperty (afp->mPlayUnit, - kAudioUnitProperty_SetInputCallback, - kAudioUnitScope_Input, - 0, - &afp->mInputCallback, - sizeof (afp->mInputCallback)); + OSStatus result = AudioUnitSetProperty(afp->mPlayUnit, + kAudioUnitProperty_SetInputCallback, + kAudioUnitScope_Input, + 0, + &afp->mInputCallback, + sizeof(afp->mInputCallback)); if (result) return 0; /*THROW_RESULT("AudioUnitSetProperty") */ afp->mConnected = 1; @@ -207,43 +207,43 @@ /* warning noted, now please go away ;-) */ /* #warning This should redirect the calling of notification code to some other thread */ static void -AudioFilePlayer_DoNotification (AudioFilePlayer * afp, OSStatus inStatus) +AudioFilePlayer_DoNotification(AudioFilePlayer * afp, OSStatus inStatus) { if (afp->mNotifier) { (*afp->mNotifier) (afp->mRefCon, inStatus); } else { - SDL_SetError ("Notification posted with no notifier in place"); + SDL_SetError("Notification posted with no notifier in place"); if (inStatus == kAudioFilePlay_FileIsFinished) - afp->Disconnect (afp); + afp->Disconnect(afp); else if (inStatus != kAudioFilePlayErr_FilePlayUnderrun) - afp->Disconnect (afp); + afp->Disconnect(afp); } } static void -AudioFilePlayer_Disconnect (AudioFilePlayer * afp) +AudioFilePlayer_Disconnect(AudioFilePlayer * afp) { #if DEBUG - printf ("Disconnect:%x,%ld, engaged=%d\n", (int) afp->mPlayUnit, 0, - (afp->mConnected ? 1 : 0)); + printf("Disconnect:%x,%ld, engaged=%d\n", (int) afp->mPlayUnit, 0, + (afp->mConnected ? 1 : 0)); #endif if (afp->mConnected) { afp->mConnected = 0; afp->mInputCallback.inputProc = 0; afp->mInputCallback.inputProcRefCon = 0; - OSStatus result = AudioUnitSetProperty (afp->mPlayUnit, - kAudioUnitProperty_SetInputCallback, - kAudioUnitScope_Input, - 0, - &afp->mInputCallback, - sizeof (afp->mInputCallback)); + OSStatus result = AudioUnitSetProperty(afp->mPlayUnit, + kAudioUnitProperty_SetInputCallback, + kAudioUnitScope_Input, + 0, + &afp->mInputCallback, + sizeof(afp->mInputCallback)); if (result) - SDL_SetError ("AudioUnitSetProperty:RemoveInputCallback:%ld", - result); + SDL_SetError("AudioUnitSetProperty:RemoveInputCallback:%ld", + result); - afp->mAudioFileManager->Disconnect (afp->mAudioFileManager); + afp->mAudioFileManager->Disconnect(afp->mAudioFileManager); } } @@ -254,8 +254,8 @@ } SSNDData; static int -AudioFilePlayer_OpenFile (AudioFilePlayer * afp, const FSRef * inRef, - SInt64 * outFileDataSize) +AudioFilePlayer_OpenFile(AudioFilePlayer * afp, const FSRef * inRef, + SInt64 * outFileDataSize) { ContainerChunk chunkHeader; ChunkHeader chunk; @@ -267,20 +267,20 @@ SInt64 offset; /* Open the data fork of the input file */ - result = FSGetDataForkName (&dfName); + result = FSGetDataForkName(&dfName); if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSGetDataForkName") */ result = - FSOpenFork (inRef, dfName.length, dfName.unicode, fsRdPerm, - &afp->mForkRefNum); + FSOpenFork(inRef, dfName.length, dfName.unicode, fsRdPerm, + &afp->mForkRefNum); if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSOpenFork") */ /* Read the file header, and check if it's indeed an AIFC file */ result = - FSReadFork (afp->mForkRefNum, fsAtMark, 0, sizeof (chunkHeader), - &chunkHeader, &actual); + FSReadFork(afp->mForkRefNum, fsAtMark, 0, sizeof(chunkHeader), + &chunkHeader, &actual); if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork") */ @@ -304,8 +304,8 @@ offset = 0; do { result = - FSReadFork (afp->mForkRefNum, fsFromMark, offset, - sizeof (chunk), &chunk, &actual); + FSReadFork(afp->mForkRefNum, fsFromMark, offset, + sizeof(chunk), &chunk, &actual); if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork") */ @@ -317,13 +317,12 @@ /* Read the header of the SSND chunk. After this, we are positioned right at the start of the audio data. */ result = - FSReadFork (afp->mForkRefNum, fsAtMark, 0, sizeof (ssndData), - &ssndData, &actual); + FSReadFork(afp->mForkRefNum, fsAtMark, 0, sizeof(ssndData), + &ssndData, &actual); if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork") */ - result = - FSSetForkPosition (afp->mForkRefNum, fsFromMark, ssndData.offset); + result = FSSetForkPosition(afp->mForkRefNum, fsFromMark, ssndData.offset); if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSSetForkPosition") */ @@ -345,33 +344,33 @@ } AudioFilePlayer * -new_AudioFilePlayer (const FSRef * inFileRef) +new_AudioFilePlayer(const FSRef * inFileRef) { SInt64 fileDataSize = 0; AudioFilePlayer *afp = - (AudioFilePlayer *) SDL_malloc (sizeof (AudioFilePlayer)); + (AudioFilePlayer *) SDL_malloc(sizeof(AudioFilePlayer)); if (afp == NULL) return NULL; - SDL_memset (afp, '\0', sizeof (*afp)); + SDL_memset(afp, '\0', sizeof(*afp)); #define SET_AUDIOFILEPLAYER_METHOD(m) afp->m = AudioFilePlayer_##m - SET_AUDIOFILEPLAYER_METHOD (SetDestination); - SET_AUDIOFILEPLAYER_METHOD (SetNotifier); - SET_AUDIOFILEPLAYER_METHOD (SetStartFrame); - SET_AUDIOFILEPLAYER_METHOD (GetCurrentFrame); - SET_AUDIOFILEPLAYER_METHOD (SetStopFrame); - SET_AUDIOFILEPLAYER_METHOD (Connect); - SET_AUDIOFILEPLAYER_METHOD (Disconnect); - SET_AUDIOFILEPLAYER_METHOD (DoNotification); - SET_AUDIOFILEPLAYER_METHOD (IsConnected); - SET_AUDIOFILEPLAYER_METHOD (GetDestUnit); - SET_AUDIOFILEPLAYER_METHOD (Print); - SET_AUDIOFILEPLAYER_METHOD (OpenFile); + SET_AUDIOFILEPLAYER_METHOD(SetDestination); + SET_AUDIOFILEPLAYER_METHOD(SetNotifier); + SET_AUDIOFILEPLAYER_METHOD(SetStartFrame); + SET_AUDIOFILEPLAYER_METHOD(GetCurrentFrame); + SET_AUDIOFILEPLAYER_METHOD(SetStopFrame); + SET_AUDIOFILEPLAYER_METHOD(Connect); + SET_AUDIOFILEPLAYER_METHOD(Disconnect); + SET_AUDIOFILEPLAYER_METHOD(DoNotification); + SET_AUDIOFILEPLAYER_METHOD(IsConnected); + SET_AUDIOFILEPLAYER_METHOD(GetDestUnit); + SET_AUDIOFILEPLAYER_METHOD(Print); + SET_AUDIOFILEPLAYER_METHOD(OpenFile); #undef SET_AUDIOFILEPLAYER_METHOD - if (!afp->OpenFile (afp, inFileRef, &fileDataSize)) { - SDL_free (afp); + if (!afp->OpenFile(afp, inFileRef, &fileDataSize)) { + SDL_free(afp); return NULL; } @@ -381,15 +380,15 @@ afp->mFileDescription.mBytesPerFrame); #if DEBUG - printf ("File format:\n"); - PrintStreamDesc (&afp->mFileDescription); + printf("File format:\n"); + PrintStreamDesc(&afp->mFileDescription); #endif - afp->mAudioFileManager = new_AudioFileManager (afp, afp->mForkRefNum, - fileDataSize, - bytesPerSecond); + afp->mAudioFileManager = new_AudioFileManager(afp, afp->mForkRefNum, + fileDataSize, + bytesPerSecond); if (afp->mAudioFileManager == NULL) { - delete_AudioFilePlayer (afp); + delete_AudioFilePlayer(afp); return NULL; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/macosx/AudioFilePlayer.h --- a/src/cdrom/macosx/AudioFilePlayer.h Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/macosx/AudioFilePlayer.h Mon May 29 04:04:35 2006 +0000 @@ -36,7 +36,7 @@ #include "SDL_error.h" -const char *AudioFilePlayerErrorStr (OSStatus error); +const char *AudioFilePlayerErrorStr(OSStatus error); /* void ThrowResult (OSStatus result, const char *str); @@ -74,7 +74,7 @@ void (*Disconnect) (struct S_AudioFilePlayer * afp); void (*DoNotification) (struct S_AudioFilePlayer * afp, OSStatus inError); int (*IsConnected) (struct S_AudioFilePlayer * afp); - AudioUnit (*GetDestUnit) (struct S_AudioFilePlayer * afp); + AudioUnit(*GetDestUnit) (struct S_AudioFilePlayer * afp); void (*Print) (struct S_AudioFilePlayer * afp); /*private:*/ @@ -101,8 +101,8 @@ } AudioFilePlayer; -AudioFilePlayer *new_AudioFilePlayer (const FSRef * inFileRef); -void delete_AudioFilePlayer (AudioFilePlayer * afp); +AudioFilePlayer *new_AudioFilePlayer(const FSRef * inFileRef); +void delete_AudioFilePlayer(AudioFilePlayer * afp); @@ -114,8 +114,8 @@ as it is called by the parent's Disconnect() method */ void (*Disconnect) (struct S_AudioFileManager * afm); int (*DoConnect) (struct S_AudioFileManager * afm); - OSStatus (*Read) (struct S_AudioFileManager * afm, char *buffer, - UInt32 * len); + OSStatus(*Read) (struct S_AudioFileManager * afm, char *buffer, + UInt32 * len); const char *(*GetFileBuffer) (struct S_AudioFileManager * afm); const AudioFilePlayer *(*GetParent) (struct S_AudioFileManager * afm); void (*SetPosition) (struct S_AudioFileManager * afm, SInt64 pos); /* seek/rewind in the file */ @@ -149,27 +149,27 @@ int mFinishedReadingData; /*protected:*/ - OSStatus (*Render) (struct S_AudioFileManager * afm, - AudioBuffer * ioData); - OSStatus (*GetFileData) (struct S_AudioFileManager * afm, - void **inOutData, UInt32 * inOutDataSize); + OSStatus(*Render) (struct S_AudioFileManager * afm, + AudioBuffer * ioData); + OSStatus(*GetFileData) (struct S_AudioFileManager * afm, + void **inOutData, UInt32 * inOutDataSize); void (*AfterRender) (struct S_AudioFileManager * afm); /*public:*/ /*static */ - OSStatus (*FileInputProc) (void *inRefCon, - AudioUnitRenderActionFlags inActionFlags, - const AudioTimeStamp * inTimeStamp, - UInt32 inBusNumber, AudioBuffer * ioData); + OSStatus(*FileInputProc) (void *inRefCon, + AudioUnitRenderActionFlags inActionFlags, + const AudioTimeStamp * inTimeStamp, + UInt32 inBusNumber, AudioBuffer * ioData); } AudioFileManager; -AudioFileManager *new_AudioFileManager (AudioFilePlayer * inParent, - SInt16 inForkRefNum, - SInt64 inFileLength, - UInt32 inChunkSize); +AudioFileManager *new_AudioFileManager(AudioFilePlayer * inParent, + SInt16 inForkRefNum, + SInt64 inFileLength, + UInt32 inChunkSize); -void delete_AudioFileManager (AudioFileManager * afm); +void delete_AudioFileManager(AudioFileManager * afm); #endif /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/macosx/AudioFileReaderThread.c --- a/src/cdrom/macosx/AudioFileReaderThread.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/macosx/AudioFileReaderThread.c Mon May 29 04:04:35 2006 +0000 @@ -67,32 +67,32 @@ void (*ReadNextChunk) (struct S_FileReaderThread * frt); int (*StartFixedPriorityThread) (struct S_FileReaderThread * frt); /*static */ - UInt32 (*GetThreadBasePriority) (pthread_t inThread); + UInt32(*GetThreadBasePriority) (pthread_t inThread); /*static */ void *(*DiskReaderEntry) (void *inRefCon); } FileReaderThread; static SDLOSXCAGuard * -FileReaderThread_GetGuard (FileReaderThread * frt) +FileReaderThread_GetGuard(FileReaderThread * frt) { return frt->mGuard; } /* returns 1 if succeeded */ static int -FileReaderThread_TryNextRead (FileReaderThread * frt, - AudioFileManager * inItem) +FileReaderThread_TryNextRead(FileReaderThread * frt, + AudioFileManager * inItem) { int didLock = 0; int succeeded = 0; - if (frt->mGuard->Try (frt->mGuard, &didLock)) { + if (frt->mGuard->Try(frt->mGuard, &didLock)) { /*frt->mFileData.push_back (inItem); */ /* !!! FIXME: this could be faster with a "tail" member. --ryan. */ FileData *i = frt->mFileData; FileData *prev = NULL; - FileData *newfd = (FileData *) SDL_malloc (sizeof (FileData)); + FileData *newfd = (FileData *) SDL_malloc(sizeof(FileData)); newfd->obj = inItem; newfd->next = NULL; @@ -105,32 +105,32 @@ else prev->next = newfd; - frt->mGuard->Notify (frt->mGuard); + frt->mGuard->Notify(frt->mGuard); succeeded = 1; if (didLock) - frt->mGuard->Unlock (frt->mGuard); + frt->mGuard->Unlock(frt->mGuard); } return succeeded; } static void -FileReaderThread_AddReader (FileReaderThread * frt) +FileReaderThread_AddReader(FileReaderThread * frt) { if (frt->mNumReaders == 0) { frt->mThreadShouldDie = 0; - frt->StartFixedPriorityThread (frt); + frt->StartFixedPriorityThread(frt); } frt->mNumReaders++; } static void -FileReaderThread_RemoveReader (FileReaderThread * frt, - AudioFileManager * inItem) +FileReaderThread_RemoveReader(FileReaderThread * frt, + AudioFileManager * inItem) { if (frt->mNumReaders > 0) { - int bNeedsRelease = frt->mGuard->Lock (frt->mGuard); + int bNeedsRelease = frt->mGuard->Lock(frt->mGuard); /*frt->mFileData.remove (inItem); */ FileData *i = frt->mFileData; @@ -144,44 +144,43 @@ frt->mFileData = next; else prev->next = next; - SDL_free (i); + SDL_free(i); } i = next; } if (--frt->mNumReaders == 0) { frt->mThreadShouldDie = 1; - frt->mGuard->Notify (frt->mGuard); /* wake up thread so it will quit */ - frt->mGuard->Wait (frt->mGuard); /* wait for thread to die */ + frt->mGuard->Notify(frt->mGuard); /* wake up thread so it will quit */ + frt->mGuard->Wait(frt->mGuard); /* wait for thread to die */ } if (bNeedsRelease) - frt->mGuard->Unlock (frt->mGuard); + frt->mGuard->Unlock(frt->mGuard); } } static int -FileReaderThread_StartFixedPriorityThread (FileReaderThread * frt) +FileReaderThread_StartFixedPriorityThread(FileReaderThread * frt) { pthread_attr_t theThreadAttrs; pthread_t pThread; - OSStatus result = pthread_attr_init (&theThreadAttrs); + OSStatus result = pthread_attr_init(&theThreadAttrs); if (result) return 0; /*THROW_RESULT("pthread_attr_init - Thread attributes could not be created.") */ result = - pthread_attr_setdetachstate (&theThreadAttrs, - PTHREAD_CREATE_DETACHED); + pthread_attr_setdetachstate(&theThreadAttrs, PTHREAD_CREATE_DETACHED); if (result) return 0; /*THROW_RESULT("pthread_attr_setdetachstate - Thread attributes could not be detached.") */ result = - pthread_create (&pThread, &theThreadAttrs, frt->DiskReaderEntry, frt); + pthread_create(&pThread, &theThreadAttrs, frt->DiskReaderEntry, frt); if (result) return 0; /*THROW_RESULT("pthread_create - Create and start the thread.") */ - pthread_attr_destroy (&theThreadAttrs); + pthread_attr_destroy(&theThreadAttrs); /* we've now created the thread and started it we'll now set the priority of the thread to the nominated priority @@ -193,23 +192,23 @@ /* make thread fixed */ theFixedPolicy.timeshare = 0; /* set to 1 for a non-fixed thread */ result = - thread_policy_set (pthread_mach_thread_np (pThread), - THREAD_EXTENDED_POLICY, - (thread_policy_t) & theFixedPolicy, - THREAD_EXTENDED_POLICY_COUNT); + thread_policy_set(pthread_mach_thread_np(pThread), + THREAD_EXTENDED_POLICY, + (thread_policy_t) & theFixedPolicy, + THREAD_EXTENDED_POLICY_COUNT); if (result) return 0; /*THROW_RESULT("thread_policy - Couldn't set thread as fixed priority.") */ /* set priority */ /* precedency policy's "importance" value is relative to spawning thread's priority */ relativePriority = - frt->mThreadPriority - frt->GetThreadBasePriority (pthread_self ()); + frt->mThreadPriority - frt->GetThreadBasePriority(pthread_self()); thePrecedencePolicy.importance = relativePriority; result = - thread_policy_set (pthread_mach_thread_np (pThread), - THREAD_PRECEDENCE_POLICY, - (thread_policy_t) & thePrecedencePolicy, - THREAD_PRECEDENCE_POLICY_COUNT); + thread_policy_set(pthread_mach_thread_np(pThread), + THREAD_PRECEDENCE_POLICY, + (thread_policy_t) & thePrecedencePolicy, + THREAD_PRECEDENCE_POLICY_COUNT); if (result) return 0; /*THROW_RESULT("thread_policy - Couldn't set thread priority.") */ @@ -217,7 +216,7 @@ } static UInt32 -FileReaderThread_GetThreadBasePriority (pthread_t inThread) +FileReaderThread_GetThreadBasePriority(pthread_t inThread) { thread_basic_info_data_t threadInfo; policy_info_data_t thePolicyInfo; @@ -225,23 +224,23 @@ /* get basic info */ count = THREAD_BASIC_INFO_COUNT; - thread_info (pthread_mach_thread_np (inThread), THREAD_BASIC_INFO, - (integer_t *) & threadInfo, &count); + thread_info(pthread_mach_thread_np(inThread), THREAD_BASIC_INFO, + (integer_t *) & threadInfo, &count); switch (threadInfo.policy) { case POLICY_TIMESHARE: count = POLICY_TIMESHARE_INFO_COUNT; - thread_info (pthread_mach_thread_np (inThread), - THREAD_SCHED_TIMESHARE_INFO, - (integer_t *) & (thePolicyInfo.ts), &count); + thread_info(pthread_mach_thread_np(inThread), + THREAD_SCHED_TIMESHARE_INFO, + (integer_t *) & (thePolicyInfo.ts), &count); return thePolicyInfo.ts.base_priority; break; case POLICY_FIFO: count = POLICY_FIFO_INFO_COUNT; - thread_info (pthread_mach_thread_np (inThread), - THREAD_SCHED_FIFO_INFO, - (integer_t *) & (thePolicyInfo.fifo), &count); + thread_info(pthread_mach_thread_np(inThread), + THREAD_SCHED_FIFO_INFO, + (integer_t *) & (thePolicyInfo.fifo), &count); if (thePolicyInfo.fifo.depressed) { return thePolicyInfo.fifo.depress_priority; } else { @@ -251,9 +250,9 @@ case POLICY_RR: count = POLICY_RR_INFO_COUNT; - thread_info (pthread_mach_thread_np (inThread), - THREAD_SCHED_RR_INFO, - (integer_t *) & (thePolicyInfo.rr), &count); + thread_info(pthread_mach_thread_np(inThread), + THREAD_SCHED_RR_INFO, + (integer_t *) & (thePolicyInfo.rr), &count); if (thePolicyInfo.rr.depressed) { return thePolicyInfo.rr.depress_priority; } else { @@ -266,19 +265,19 @@ } static void * -FileReaderThread_DiskReaderEntry (void *inRefCon) +FileReaderThread_DiskReaderEntry(void *inRefCon) { FileReaderThread *frt = (FileReaderThread *) inRefCon; - frt->ReadNextChunk (frt); + frt->ReadNextChunk(frt); #if DEBUG - printf ("finished with reading file\n"); + printf("finished with reading file\n"); #endif return 0; } static void -FileReaderThread_ReadNextChunk (FileReaderThread * frt) +FileReaderThread_ReadNextChunk(FileReaderThread * frt) { OSStatus result; UInt32 dataChunkSize; @@ -286,26 +285,26 @@ for (;;) { { /* this is a scoped based lock */ - int bNeedsRelease = frt->mGuard->Lock (frt->mGuard); + int bNeedsRelease = frt->mGuard->Lock(frt->mGuard); if (frt->mThreadShouldDie) { - frt->mGuard->Notify (frt->mGuard); + frt->mGuard->Notify(frt->mGuard); if (bNeedsRelease) - frt->mGuard->Unlock (frt->mGuard); + frt->mGuard->Unlock(frt->mGuard); return; } /*if (frt->mFileData.empty()) */ if (frt->mFileData == NULL) { - frt->mGuard->Wait (frt->mGuard); + frt->mGuard->Wait(frt->mGuard); } /* kill thread */ if (frt->mThreadShouldDie) { - frt->mGuard->Notify (frt->mGuard); + frt->mGuard->Notify(frt->mGuard); if (bNeedsRelease) - frt->mGuard->Unlock (frt->mGuard); + frt->mGuard->Unlock(frt->mGuard); return; } @@ -315,12 +314,12 @@ if (frt->mFileData != NULL) { FileData *next = frt->mFileData->next; theItem = frt->mFileData->obj; - SDL_free (frt->mFileData); + SDL_free(frt->mFileData); frt->mFileData = next; } if (bNeedsRelease) - frt->mGuard->Unlock (frt->mGuard); + frt->mGuard->Unlock(frt->mGuard); } if ((theItem->mFileLength - theItem->mReadFilePosition) < @@ -335,17 +334,17 @@ continue; } /* construct pointer */ - char *writePtr = (char *) (theItem->GetFileBuffer (theItem) + + char *writePtr = (char *) (theItem->GetFileBuffer(theItem) + (theItem-> mWriteToFirstBuffer ? 0 : theItem-> mChunkSize)); /* read data */ - result = theItem->Read (theItem, writePtr, &dataChunkSize); + result = theItem->Read(theItem, writePtr, &dataChunkSize); if (result != noErr && result != eofErr) { AudioFilePlayer *afp = - (AudioFilePlayer *) theItem->GetParent (theItem); - afp->DoNotification (afp, result); + (AudioFilePlayer *) theItem->GetParent(theItem); + afp->DoNotification(afp, result); continue; } @@ -353,7 +352,7 @@ writePtr += dataChunkSize; /* can't exit yet.. we still have to pass the partial buffer back */ - SDL_memset (writePtr, 0, (theItem->mChunkSize - dataChunkSize)); + SDL_memset(writePtr, 0, (theItem->mChunkSize - dataChunkSize)); } theItem->mWriteToFirstBuffer = !theItem->mWriteToFirstBuffer; /* switch buffers */ @@ -366,37 +365,37 @@ } void -delete_FileReaderThread (FileReaderThread * frt) +delete_FileReaderThread(FileReaderThread * frt) { if (frt != NULL) { - delete_SDLOSXCAGuard (frt->mGuard); - SDL_free (frt); + delete_SDLOSXCAGuard(frt->mGuard); + SDL_free(frt); } } FileReaderThread * -new_FileReaderThread () +new_FileReaderThread() { FileReaderThread *frt = - (FileReaderThread *) SDL_malloc (sizeof (FileReaderThread)); + (FileReaderThread *) SDL_malloc(sizeof(FileReaderThread)); if (frt == NULL) return NULL; - SDL_memset (frt, '\0', sizeof (*frt)); + SDL_memset(frt, '\0', sizeof(*frt)); - frt->mGuard = new_SDLOSXCAGuard (); + frt->mGuard = new_SDLOSXCAGuard(); if (frt->mGuard == NULL) { - SDL_free (frt); + SDL_free(frt); return NULL; } #define SET_FILEREADERTHREAD_METHOD(m) frt->m = FileReaderThread_##m - SET_FILEREADERTHREAD_METHOD (GetGuard); - SET_FILEREADERTHREAD_METHOD (AddReader); - SET_FILEREADERTHREAD_METHOD (RemoveReader); - SET_FILEREADERTHREAD_METHOD (TryNextRead); - SET_FILEREADERTHREAD_METHOD (ReadNextChunk); - SET_FILEREADERTHREAD_METHOD (StartFixedPriorityThread); - SET_FILEREADERTHREAD_METHOD (GetThreadBasePriority); - SET_FILEREADERTHREAD_METHOD (DiskReaderEntry); + SET_FILEREADERTHREAD_METHOD(GetGuard); + SET_FILEREADERTHREAD_METHOD(AddReader); + SET_FILEREADERTHREAD_METHOD(RemoveReader); + SET_FILEREADERTHREAD_METHOD(TryNextRead); + SET_FILEREADERTHREAD_METHOD(ReadNextChunk); + SET_FILEREADERTHREAD_METHOD(StartFixedPriorityThread); + SET_FILEREADERTHREAD_METHOD(GetThreadBasePriority); + SET_FILEREADERTHREAD_METHOD(DiskReaderEntry); #undef SET_FILEREADERTHREAD_METHOD frt->mThreadPriority = 62; @@ -408,7 +407,7 @@ static int -AudioFileManager_DoConnect (AudioFileManager * afm) +AudioFileManager_DoConnect(AudioFileManager * afm) { if (!afm->mIsEngaged) { OSStatus result; @@ -426,7 +425,7 @@ else dataChunkSize = afm->mChunkSize; - result = afm->Read (afm, afm->mFileBuffer, &dataChunkSize); + result = afm->Read(afm, afm->mFileBuffer, &dataChunkSize); if (result) return 0; /*THROW_RESULT("AudioFileManager::DoConnect(): Read") */ @@ -435,7 +434,7 @@ afm->mWriteToFirstBuffer = 0; afm->mReadFromFirstBuffer = 1; - sReaderThread->AddReader (sReaderThread); + sReaderThread->AddReader(sReaderThread); afm->mIsEngaged = 1; } @@ -447,26 +446,26 @@ } static void -AudioFileManager_Disconnect (AudioFileManager * afm) +AudioFileManager_Disconnect(AudioFileManager * afm) { if (afm->mIsEngaged) { - sReaderThread->RemoveReader (sReaderThread, afm); + sReaderThread->RemoveReader(sReaderThread, afm); afm->mIsEngaged = 0; } } static OSStatus -AudioFileManager_Read (AudioFileManager * afm, char *buffer, UInt32 * len) +AudioFileManager_Read(AudioFileManager * afm, char *buffer, UInt32 * len) { - return FSReadFork (afm->mForkRefNum, - fsFromStart, - afm->mReadFilePosition + afm->mAudioDataOffset, - *len, buffer, len); + return FSReadFork(afm->mForkRefNum, + fsFromStart, + afm->mReadFilePosition + afm->mAudioDataOffset, + *len, buffer, len); } static OSStatus -AudioFileManager_GetFileData (AudioFileManager * afm, void **inOutData, - UInt32 * inOutDataSize) +AudioFileManager_GetFileData(AudioFileManager * afm, void **inOutData, + UInt32 * inOutDataSize) { if (afm->mFinishedReadingData) { ++afm->mNumTimesAskedSinceFinished; @@ -477,11 +476,11 @@ if (afm->mReadFromFirstBuffer == afm->mWriteToFirstBuffer) { #if DEBUG - printf ("* * * * * * * Can't keep up with reading file\n"); + printf("* * * * * * * Can't keep up with reading file\n"); #endif - afm->mParent->DoNotification (afm->mParent, - kAudioFilePlayErr_FilePlayUnderrun); + afm->mParent->DoNotification(afm->mParent, + kAudioFilePlayErr_FilePlayUnderrun); *inOutDataSize = 0; *inOutData = 0; } else { @@ -492,7 +491,7 @@ afm->mChunkSize); } - afm->mLockUnsuccessful = !sReaderThread->TryNextRead (sReaderThread, afm); + afm->mLockUnsuccessful = !sReaderThread->TryNextRead(sReaderThread, afm); afm->mReadFromFirstBuffer = !afm->mReadFromFirstBuffer; @@ -500,26 +499,26 @@ } static void -AudioFileManager_AfterRender (AudioFileManager * afm) +AudioFileManager_AfterRender(AudioFileManager * afm) { if (afm->mNumTimesAskedSinceFinished > 0) { int didLock = 0; - SDLOSXCAGuard *guard = sReaderThread->GetGuard (sReaderThread); - if (guard->Try (guard, &didLock)) { - afm->mParent->DoNotification (afm->mParent, - kAudioFilePlay_FileIsFinished); + SDLOSXCAGuard *guard = sReaderThread->GetGuard(sReaderThread); + if (guard->Try(guard, &didLock)) { + afm->mParent->DoNotification(afm->mParent, + kAudioFilePlay_FileIsFinished); if (didLock) - guard->Unlock (guard); + guard->Unlock(guard); } } if (afm->mLockUnsuccessful) afm->mLockUnsuccessful = - !sReaderThread->TryNextRead (sReaderThread, afm); + !sReaderThread->TryNextRead(sReaderThread, afm); } static void -AudioFileManager_SetPosition (AudioFileManager * afm, SInt64 pos) +AudioFileManager_SetPosition(AudioFileManager * afm, SInt64 pos) { if (pos < 0 || pos >= afm->mFileLength) { SDL_SetError @@ -532,7 +531,7 @@ } static void -AudioFileManager_SetEndOfFile (AudioFileManager * afm, SInt64 pos) +AudioFileManager_SetEndOfFile(AudioFileManager * afm, SInt64 pos) { if (pos <= 0 || pos > afm->mFileLength) { SDL_SetError @@ -544,44 +543,44 @@ } static const char * -AudioFileManager_GetFileBuffer (AudioFileManager * afm) +AudioFileManager_GetFileBuffer(AudioFileManager * afm) { return afm->mFileBuffer; } const AudioFilePlayer * -AudioFileManager_GetParent (AudioFileManager * afm) +AudioFileManager_GetParent(AudioFileManager * afm) { return afm->mParent; } static int -AudioFileManager_GetByteCounter (AudioFileManager * afm) +AudioFileManager_GetByteCounter(AudioFileManager * afm) { return afm->mByteCounter; } static OSStatus -AudioFileManager_FileInputProc (void *inRefCon, - AudioUnitRenderActionFlags inActionFlags, - const AudioTimeStamp * inTimeStamp, - UInt32 inBusNumber, AudioBuffer * ioData) +AudioFileManager_FileInputProc(void *inRefCon, + AudioUnitRenderActionFlags inActionFlags, + const AudioTimeStamp * inTimeStamp, + UInt32 inBusNumber, AudioBuffer * ioData) { AudioFileManager *afm = (AudioFileManager *) inRefCon; - return afm->Render (afm, ioData); + return afm->Render(afm, ioData); } static OSStatus -AudioFileManager_Render (AudioFileManager * afm, AudioBuffer * ioData) +AudioFileManager_Render(AudioFileManager * afm, AudioBuffer * ioData) { OSStatus result = noErr; if (afm->mBufferOffset >= afm->mBufferSize) { - result = afm->GetFileData (afm, &afm->mTmpBuffer, &afm->mBufferSize); + result = afm->GetFileData(afm, &afm->mTmpBuffer, &afm->mBufferSize); if (result) { - SDL_SetError ("AudioConverterFillBuffer:%ld\n", result); - afm->mParent->DoNotification (afm->mParent, result); + SDL_SetError("AudioConverterFillBuffer:%ld\n", result); + afm->mParent->DoNotification(afm->mParent, result); return result; } @@ -594,55 +593,55 @@ afm->mBufferOffset += ioData->mDataByteSize; afm->mByteCounter += ioData->mDataByteSize; - afm->AfterRender (afm); + afm->AfterRender(afm); return result; } void -delete_AudioFileManager (AudioFileManager * afm) +delete_AudioFileManager(AudioFileManager * afm) { if (afm != NULL) { if (afm->mFileBuffer) { - free (afm->mFileBuffer); + free(afm->mFileBuffer); } - SDL_free (afm); + SDL_free(afm); } } AudioFileManager * -new_AudioFileManager (AudioFilePlayer * inParent, - SInt16 inForkRefNum, - SInt64 inFileLength, UInt32 inChunkSize) +new_AudioFileManager(AudioFilePlayer * inParent, + SInt16 inForkRefNum, + SInt64 inFileLength, UInt32 inChunkSize) { AudioFileManager *afm; if (sReaderThread == NULL) { - sReaderThread = new_FileReaderThread (); + sReaderThread = new_FileReaderThread(); if (sReaderThread == NULL) return NULL; } - afm = (AudioFileManager *) SDL_malloc (sizeof (AudioFileManager)); + afm = (AudioFileManager *) SDL_malloc(sizeof(AudioFileManager)); if (afm == NULL) return NULL; - SDL_memset (afm, '\0', sizeof (*afm)); + SDL_memset(afm, '\0', sizeof(*afm)); #define SET_AUDIOFILEMANAGER_METHOD(m) afm->m = AudioFileManager_##m - SET_AUDIOFILEMANAGER_METHOD (Disconnect); - SET_AUDIOFILEMANAGER_METHOD (DoConnect); - SET_AUDIOFILEMANAGER_METHOD (Read); - SET_AUDIOFILEMANAGER_METHOD (GetFileBuffer); - SET_AUDIOFILEMANAGER_METHOD (GetParent); - SET_AUDIOFILEMANAGER_METHOD (SetPosition); - SET_AUDIOFILEMANAGER_METHOD (GetByteCounter); - SET_AUDIOFILEMANAGER_METHOD (SetEndOfFile); - SET_AUDIOFILEMANAGER_METHOD (Render); - SET_AUDIOFILEMANAGER_METHOD (GetFileData); - SET_AUDIOFILEMANAGER_METHOD (AfterRender); - SET_AUDIOFILEMANAGER_METHOD (FileInputProc); + SET_AUDIOFILEMANAGER_METHOD(Disconnect); + SET_AUDIOFILEMANAGER_METHOD(DoConnect); + SET_AUDIOFILEMANAGER_METHOD(Read); + SET_AUDIOFILEMANAGER_METHOD(GetFileBuffer); + SET_AUDIOFILEMANAGER_METHOD(GetParent); + SET_AUDIOFILEMANAGER_METHOD(SetPosition); + SET_AUDIOFILEMANAGER_METHOD(GetByteCounter); + SET_AUDIOFILEMANAGER_METHOD(SetEndOfFile); + SET_AUDIOFILEMANAGER_METHOD(Render); + SET_AUDIOFILEMANAGER_METHOD(GetFileData); + SET_AUDIOFILEMANAGER_METHOD(AfterRender); + SET_AUDIOFILEMANAGER_METHOD(FileInputProc); #undef SET_AUDIOFILEMANAGER_METHOD afm->mParent = inParent; @@ -651,9 +650,9 @@ afm->mBufferOffset = inChunkSize; afm->mChunkSize = inChunkSize; afm->mFileLength = inFileLength; - afm->mFileBuffer = (char *) SDL_malloc (afm->mChunkSize * 2); - FSGetForkPosition (afm->mForkRefNum, &afm->mAudioDataOffset); - assert (afm->mFileBuffer != NULL); + afm->mFileBuffer = (char *) SDL_malloc(afm->mChunkSize * 2); + FSGetForkPosition(afm->mForkRefNum, &afm->mAudioDataOffset); + assert(afm->mFileBuffer != NULL); return afm; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/macosx/CDPlayer.c --- a/src/cdrom/macosx/CDPlayer.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/macosx/CDPlayer.c Mon May 29 04:04:35 2006 +0000 @@ -67,32 +67,32 @@ #pragma mark -- Prototypes -- -static OSStatus CheckInit (); +static OSStatus CheckInit(); -static void FilePlayNotificationHandler (void *inRefCon, OSStatus inStatus); +static void FilePlayNotificationHandler(void *inRefCon, OSStatus inStatus); -static int RunCallBackThread (void *inRefCon); +static int RunCallBackThread(void *inRefCon); #pragma mark -- Public Functions -- void -Lock () +Lock() { if (!apiMutex) { - apiMutex = SDL_CreateMutex (); + apiMutex = SDL_CreateMutex(); } - SDL_mutexP (apiMutex); + SDL_mutexP(apiMutex); } void -Unlock () +Unlock() { - SDL_mutexV (apiMutex); + SDL_mutexV(apiMutex); } int -DetectAudioCDVolumes (FSVolumeRefNum * volumes, int numVolumes) +DetectAudioCDVolumes(FSVolumeRefNum * volumes, int numVolumes) { int volumeIndex; int cdVolumeCount = 0; @@ -102,12 +102,12 @@ FSVolumeRefNum actualVolume; FSVolumeInfo volumeInfo; - memset (&volumeInfo, 0, sizeof (volumeInfo)); + memset(&volumeInfo, 0, sizeof(volumeInfo)); - result = FSGetVolumeInfo (kFSInvalidVolumeRefNum, - volumeIndex, - &actualVolume, - kFSVolInfoFSInfo, &volumeInfo, NULL, NULL); + result = FSGetVolumeInfo(kFSInvalidVolumeRefNum, + volumeIndex, + &actualVolume, + kFSVolInfoFSInfo, &volumeInfo, NULL, NULL); if (result == noErr) { if (volumeInfo.filesystemID == kAudioCDFilesystemID) { /* It's an audio CD */ @@ -126,7 +126,7 @@ } int -ReadTOCData (FSVolumeRefNum theVolume, SDL_CD * theCD) +ReadTOCData(FSVolumeRefNum theVolume, SDL_CD * theCD) { HFSUniStr255 dataForkName; OSStatus theErr; @@ -149,7 +149,7 @@ fsRefPB.ioDirID = 0; fsRefPB.newRef = &tocPlistFSRef; - theErr = PBMakeFSRefSync (&fsRefPB); + theErr = PBMakeFSRefSync(&fsRefPB); if (theErr != noErr) { error = "PBMakeFSRefSync"; goto bail; @@ -157,51 +157,50 @@ /* Load and parse the TOC XML data */ - theErr = FSGetDataForkName (&dataForkName); + theErr = FSGetDataForkName(&dataForkName); if (theErr != noErr) { error = "FSGetDataForkName"; goto bail; } theErr = - FSOpenFork (&tocPlistFSRef, dataForkName.length, dataForkName.unicode, - fsRdPerm, &forkRefNum); + FSOpenFork(&tocPlistFSRef, dataForkName.length, dataForkName.unicode, + fsRdPerm, &forkRefNum); if (theErr != noErr) { error = "FSOpenFork"; goto bail; } - theErr = FSGetForkSize (forkRefNum, &forkSize); + theErr = FSGetForkSize(forkRefNum, &forkSize); if (theErr != noErr) { error = "FSGetForkSize"; goto bail; } /* Allocate some memory for the XML data */ - forkData = NewPtr (forkSize); + forkData = NewPtr(forkSize); if (forkData == NULL) { error = "NewPtr"; goto bail; } - theErr = FSReadFork (forkRefNum, fsFromStart, 0 /* offset location */ , - forkSize, forkData, &actualRead); + theErr = FSReadFork(forkRefNum, fsFromStart, 0 /* offset location */ , + forkSize, forkData, &actualRead); if (theErr != noErr) { error = "FSReadFork"; goto bail; } - dataRef = - CFDataCreate (kCFAllocatorDefault, (UInt8 *) forkData, forkSize); + dataRef = CFDataCreate(kCFAllocatorDefault, (UInt8 *) forkData, forkSize); if (dataRef == 0) { error = "CFDataCreate"; goto bail; } - propertyListRef = CFPropertyListCreateFromXMLData (kCFAllocatorDefault, - dataRef, - kCFPropertyListImmutable, - NULL); + propertyListRef = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, + dataRef, + kCFPropertyListImmutable, + NULL); if (propertyListRef == NULL) { error = "CFPropertyListCreateFromXMLData"; goto bail; @@ -210,7 +209,7 @@ /* Now we got the Property List in memory. Parse it. */ /* First, make sure the root item is a CFDictionary. If not, release and bail. */ - if (CFGetTypeID (propertyListRef) == CFDictionaryGetTypeID ()) { + if (CFGetTypeID(propertyListRef) == CFDictionaryGetTypeID()) { CFDictionaryRef dictRef = (CFDictionaryRef) propertyListRef; CFDataRef theRawTOCDataRef; @@ -220,16 +219,16 @@ /* This is how we get the Raw TOC Data */ theRawTOCDataRef = - (CFDataRef) CFDictionaryGetValue (dictRef, - CFSTR (kRawTOCDataString)); + (CFDataRef) CFDictionaryGetValue(dictRef, + CFSTR(kRawTOCDataString)); /* Get the session array info. */ theSessionArrayRef = - (CFArrayRef) CFDictionaryGetValue (dictRef, - CFSTR (kSessionsString)); + (CFArrayRef) CFDictionaryGetValue(dictRef, + CFSTR(kSessionsString)); /* Find out how many sessions there are. */ - numSessions = CFArrayGetCount (theSessionArrayRef); + numSessions = CFArrayGetCount(theSessionArrayRef); /* Initialize the total number of tracks to 0 */ theCD->numtracks = 0; @@ -244,17 +243,17 @@ UInt32 value = 0; theSessionDict = (CFDictionaryRef) - CFArrayGetValueAtIndex (theSessionArrayRef, index); + CFArrayGetValueAtIndex(theSessionArrayRef, index); leadoutBlock = - (CFNumberRef) CFDictionaryGetValue (theSessionDict, - CFSTR - (kLeadoutBlockString)); + (CFNumberRef) CFDictionaryGetValue(theSessionDict, + CFSTR + (kLeadoutBlockString)); trackArray = - (CFArrayRef) CFDictionaryGetValue (theSessionDict, - CFSTR (kTrackArrayString)); + (CFArrayRef) CFDictionaryGetValue(theSessionDict, + CFSTR(kTrackArrayString)); - numTracks = CFArrayGetCount (trackArray); + numTracks = CFArrayGetCount(trackArray); for (trackIndex = 0; trackIndex < numTracks; trackIndex++) { @@ -266,32 +265,32 @@ UInt32 value; theTrackDict = (CFDictionaryRef) - CFArrayGetValueAtIndex (trackArray, trackIndex); + CFArrayGetValueAtIndex(trackArray, trackIndex); trackNumber = - (CFNumberRef) CFDictionaryGetValue (theTrackDict, - CFSTR - (kPointKeyString)); + (CFNumberRef) CFDictionaryGetValue(theTrackDict, + CFSTR + (kPointKeyString)); sessionNumber = - (CFNumberRef) CFDictionaryGetValue (theTrackDict, - CFSTR - (kSessionNumberKeyString)); + (CFNumberRef) CFDictionaryGetValue(theTrackDict, + CFSTR + (kSessionNumberKeyString)); startBlock = - (CFNumberRef) CFDictionaryGetValue (theTrackDict, - CFSTR - (kStartBlockKeyString)); + (CFNumberRef) CFDictionaryGetValue(theTrackDict, + CFSTR + (kStartBlockKeyString)); isDataTrack = - (CFBooleanRef) CFDictionaryGetValue (theTrackDict, - CFSTR - (kDataKeyString)); + (CFBooleanRef) CFDictionaryGetValue(theTrackDict, + CFSTR + (kDataKeyString)); /* Fill in the SDL_CD struct */ int idx = theCD->numtracks++; - CFNumberGetValue (trackNumber, kCFNumberSInt32Type, &value); + CFNumberGetValue(trackNumber, kCFNumberSInt32Type, &value); theCD->track[idx].id = value; - CFNumberGetValue (startBlock, kCFNumberSInt32Type, &value); + CFNumberGetValue(startBlock, kCFNumberSInt32Type, &value); theCD->track[idx].offset = value; theCD->track[idx].type = @@ -307,7 +306,7 @@ } /* Compute the length of the last track */ - CFNumberGetValue (leadoutBlock, kCFNumberSInt32Type, &value); + CFNumberGetValue(leadoutBlock, kCFNumberSInt32Type, &value); theCD->track[theCD->numtracks - 1].length = value - theCD->track[theCD->numtracks - 1].offset; @@ -321,24 +320,24 @@ theErr = 0; goto cleanup; bail: - SDL_SetError ("ReadTOCData: %s returned %d", error, theErr); + SDL_SetError("ReadTOCData: %s returned %d", error, theErr); theErr = -1; cleanup: if (propertyListRef != NULL) - CFRelease (propertyListRef); + CFRelease(propertyListRef); if (dataRef != NULL) - CFRelease (dataRef); + CFRelease(dataRef); if (forkData != NULL) - DisposePtr (forkData); + DisposePtr(forkData); - FSCloseFork (forkRefNum); + FSCloseFork(forkRefNum); return theErr; } int -ListTrackFiles (FSVolumeRefNum theVolume, FSRef * trackFiles, int numTracks) +ListTrackFiles(FSVolumeRefNum theVolume, FSRef * trackFiles, int numTracks) { OSStatus result = -1; FSIterator iterator; @@ -347,113 +346,112 @@ FSRef ref; HFSUniStr255 nameStr; - result = FSGetVolumeInfo (theVolume, - 0, - NULL, - kFSVolInfoFSInfo, NULL, NULL, &rootDirectory); + result = FSGetVolumeInfo(theVolume, + 0, + NULL, + kFSVolInfoFSInfo, NULL, NULL, &rootDirectory); if (result != noErr) { - SDL_SetError ("ListTrackFiles: FSGetVolumeInfo returned %d", result); + SDL_SetError("ListTrackFiles: FSGetVolumeInfo returned %d", result); return result; } - result = FSOpenIterator (&rootDirectory, kFSIterateFlat, &iterator); + result = FSOpenIterator(&rootDirectory, kFSIterateFlat, &iterator); if (result == noErr) { do { - result = FSGetCatalogInfoBulk (iterator, 1, &actualObjects, - NULL, kFSCatInfoNone, NULL, - &ref, NULL, &nameStr); + result = FSGetCatalogInfoBulk(iterator, 1, &actualObjects, + NULL, kFSCatInfoNone, NULL, + &ref, NULL, &nameStr); if (result == noErr) { CFStringRef name; name = - CFStringCreateWithCharacters (NULL, nameStr.unicode, - nameStr.length); + CFStringCreateWithCharacters(NULL, nameStr.unicode, + nameStr.length); /* Look for .aiff extension */ - if (CFStringHasSuffix (name, CFSTR (".aiff")) || - CFStringHasSuffix (name, CFSTR (".cdda"))) { + if (CFStringHasSuffix(name, CFSTR(".aiff")) || + CFStringHasSuffix(name, CFSTR(".cdda"))) { /* Extract the track id from the filename */ int trackID = 0, i = 0; - while (i < nameStr.length - && !isdigit (nameStr.unicode[i])) { + while (i < nameStr.length && !isdigit(nameStr.unicode[i])) { ++i; } - while (i < nameStr.length && isdigit (nameStr.unicode[i])) { + while (i < nameStr.length && isdigit(nameStr.unicode[i])) { trackID = 10 * trackID + (nameStr.unicode[i] - '0'); ++i; } #if DEBUG_CDROM - printf ("Found AIFF for track %d: '%s'\n", - trackID, CFStringGetCStringPtr (name, - CFStringGetSystemEncoding - ())); + printf("Found AIFF for track %d: '%s'\n", + trackID, CFStringGetCStringPtr(name, + CFStringGetSystemEncoding + ())); #endif /* Track ID's start at 1, but we want to start at 0 */ trackID--; - assert (0 <= trackID && trackID <= SDL_MAX_TRACKS); + assert(0 <= trackID && trackID <= SDL_MAX_TRACKS); if (trackID < numTracks) - memcpy (&trackFiles[trackID], &ref, sizeof (FSRef)); + memcpy(&trackFiles[trackID], &ref, sizeof(FSRef)); } - CFRelease (name); + CFRelease(name); } } while (noErr == result); - FSCloseIterator (iterator); + FSCloseIterator(iterator); } return 0; } int -LoadFile (const FSRef * ref, int startFrame, int stopFrame) +LoadFile(const FSRef * ref, int startFrame, int stopFrame) { int error = -1; - if (CheckInit () < 0) + if (CheckInit() < 0) goto bail; /* release any currently playing file */ - if (ReleaseFile () < 0) + if (ReleaseFile() < 0) goto bail; #if DEBUG_CDROM - printf ("LoadFile: %d %d\n", startFrame, stopFrame); + printf("LoadFile: %d %d\n", startFrame, stopFrame); #endif /*try { */ /* create a new player, and attach to the audio unit */ - thePlayer = new_AudioFilePlayer (ref); + thePlayer = new_AudioFilePlayer(ref); if (thePlayer == NULL) { - SDL_SetError ("LoadFile: Could not create player"); + SDL_SetError("LoadFile: Could not create player"); return -3; /*throw (-3); */ } - if (!thePlayer->SetDestination (thePlayer, &theUnit)) + if (!thePlayer->SetDestination(thePlayer, &theUnit)) goto bail; if (startFrame >= 0) - thePlayer->SetStartFrame (thePlayer, startFrame); + thePlayer->SetStartFrame(thePlayer, startFrame); if (stopFrame >= 0 && stopFrame > startFrame) - thePlayer->SetStopFrame (thePlayer, stopFrame); + thePlayer->SetStopFrame(thePlayer, stopFrame); /* we set the notifier later */ /*thePlayer->SetNotifier(thePlayer, FilePlayNotificationHandler, NULL); */ - if (!thePlayer->Connect (thePlayer)) + if (!thePlayer->Connect(thePlayer)) goto bail; #if DEBUG_CDROM - thePlayer->Print (thePlayer); - fflush (stdout); + thePlayer->Print(thePlayer); + fflush(stdout); #endif /*} catch (...) @@ -468,7 +466,7 @@ } int -ReleaseFile () +ReleaseFile() { int error = -1; @@ -476,9 +474,9 @@ /*try { */ if (thePlayer != NULL) { - thePlayer->Disconnect (thePlayer); + thePlayer->Disconnect(thePlayer); - delete_AudioFilePlayer (thePlayer); + delete_AudioFilePlayer(thePlayer); thePlayer = NULL; } @@ -495,17 +493,17 @@ } int -PlayFile () +PlayFile() { OSStatus result = -1; - if (CheckInit () < 0) + if (CheckInit() < 0) goto bail; /*try { */ // start processing of the audio unit - result = AudioOutputUnitStart (theUnit); + result = AudioOutputUnitStart(theUnit); if (result) goto bail; //THROW_RESULT("PlayFile: AudioOutputUnitStart") @@ -522,17 +520,17 @@ } int -PauseFile () +PauseFile() { OSStatus result = -1; - if (CheckInit () < 0) + if (CheckInit() < 0) goto bail; /*try { */ /* stop processing the audio unit */ - result = AudioOutputUnitStop (theUnit); + result = AudioOutputUnitStop(theUnit); if (result) goto bail; /*THROW_RESULT("PauseFile: AudioOutputUnitStop") */ /*} @@ -547,24 +545,24 @@ } void -SetCompletionProc (CDPlayerCompletionProc proc, SDL_CD * cdrom) +SetCompletionProc(CDPlayerCompletionProc proc, SDL_CD * cdrom) { - assert (thePlayer != NULL); + assert(thePlayer != NULL); theCDROM = cdrom; completionProc = proc; - thePlayer->SetNotifier (thePlayer, FilePlayNotificationHandler, cdrom); + thePlayer->SetNotifier(thePlayer, FilePlayNotificationHandler, cdrom); } int -GetCurrentFrame () +GetCurrentFrame() { int frame; if (thePlayer == NULL) frame = 0; else - frame = thePlayer->GetCurrentFrame (thePlayer); + frame = thePlayer->GetCurrentFrame(thePlayer); return frame; } @@ -573,7 +571,7 @@ #pragma mark -- Private Functions -- static OSStatus -CheckInit () +CheckInit() { if (playBackWasInit) return 0; @@ -581,10 +579,10 @@ OSStatus result = noErr; /* Create the callback semaphore */ - callbackSem = SDL_CreateSemaphore (0); + callbackSem = SDL_CreateSemaphore(0); /* Start callback thread */ - SDL_CreateThread (RunCallBackThread, NULL); + SDL_CreateThread(RunCallBackThread, NULL); { /*try { */ ComponentDescription desc; @@ -595,19 +593,19 @@ desc.componentFlags = 0; desc.componentFlagsMask = 0; - Component comp = FindNextComponent (NULL, &desc); + Component comp = FindNextComponent(NULL, &desc); if (comp == NULL) { - SDL_SetError ("CheckInit: FindNextComponent returned NULL"); + SDL_SetError("CheckInit: FindNextComponent returned NULL"); if (result) return -1; //throw(internalComponentErr); } - result = OpenAComponent (comp, &theUnit); + result = OpenAComponent(comp, &theUnit); if (result) return -1; //THROW_RESULT("CheckInit: OpenAComponent") // you need to initialize the output unit before you set it as a destination - result = AudioUnitInitialize (theUnit); + result = AudioUnitInitialize(theUnit); if (result) return -1; //THROW_RESULT("CheckInit: AudioUnitInitialize") @@ -623,46 +621,46 @@ } static void -FilePlayNotificationHandler (void *inRefCon, OSStatus inStatus) +FilePlayNotificationHandler(void *inRefCon, OSStatus inStatus) { if (inStatus == kAudioFilePlay_FileIsFinished) { /* notify non-CA thread to perform the callback */ - SDL_SemPost (callbackSem); + SDL_SemPost(callbackSem); } else if (inStatus == kAudioFilePlayErr_FilePlayUnderrun) { - SDL_SetError ("CDPlayer Notification: buffer underrun"); + SDL_SetError("CDPlayer Notification: buffer underrun"); } else if (inStatus == kAudioFilePlay_PlayerIsUninitialized) { - SDL_SetError ("CDPlayer Notification: player is uninitialized"); + SDL_SetError("CDPlayer Notification: player is uninitialized"); } else { - SDL_SetError ("CDPlayer Notification: unknown error %ld", inStatus); + SDL_SetError("CDPlayer Notification: unknown error %ld", inStatus); } } static int -RunCallBackThread (void *param) +RunCallBackThread(void *param) { for (;;) { - SDL_SemWait (callbackSem); + SDL_SemWait(callbackSem); if (completionProc && theCDROM) { #if DEBUG_CDROM - printf ("callback!\n"); + printf("callback!\n"); #endif (*completionProc) (theCDROM); } else { #if DEBUG_CDROM - printf ("callback?\n"); + printf("callback?\n"); #endif } } #if DEBUG_CDROM - printf ("thread dying now...\n"); + printf("thread dying now...\n"); #endif return 0; diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/macosx/CDPlayer.h --- a/src/cdrom/macosx/CDPlayer.h Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/macosx/CDPlayer.h Mon May 29 04:04:35 2006 +0000 @@ -41,28 +41,28 @@ typedef void (*CDPlayerCompletionProc) (SDL_CD * cdrom); - void Lock (); + void Lock(); - void Unlock (); + void Unlock(); - int LoadFile (const FSRef * ref, int startFrame, int endFrame); /* pass -1 to do nothing */ + int LoadFile(const FSRef * ref, int startFrame, int endFrame); /* pass -1 to do nothing */ - int ReleaseFile (); + int ReleaseFile(); - int PlayFile (); + int PlayFile(); - int PauseFile (); + int PauseFile(); - void SetCompletionProc (CDPlayerCompletionProc proc, SDL_CD * cdrom); + void SetCompletionProc(CDPlayerCompletionProc proc, SDL_CD * cdrom); - int ReadTOCData (FSVolumeRefNum theVolume, SDL_CD * theCD); + int ReadTOCData(FSVolumeRefNum theVolume, SDL_CD * theCD); - int ListTrackFiles (FSVolumeRefNum theVolume, FSRef * trackFiles, - int numTracks); + int ListTrackFiles(FSVolumeRefNum theVolume, FSRef * trackFiles, + int numTracks); - int DetectAudioCDVolumes (FSVolumeRefNum * volumes, int numVolumes); + int DetectAudioCDVolumes(FSVolumeRefNum * volumes, int numVolumes); - int GetCurrentFrame (); + int GetCurrentFrame(); #ifdef __cplusplus }; diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/macosx/SDLOSXCAGuard.c --- a/src/cdrom/macosx/SDLOSXCAGuard.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/macosx/SDLOSXCAGuard.c Mon May 29 04:04:35 2006 +0000 @@ -92,15 +92,15 @@ =============================================================================*/ static int -SDLOSXCAGuard_Lock (SDLOSXCAGuard * cag) +SDLOSXCAGuard_Lock(SDLOSXCAGuard * cag) { int theAnswer = 0; - if (pthread_self () != cag->mOwner) { - OSStatus theError = pthread_mutex_lock (&cag->mMutex); + if (pthread_self() != cag->mOwner) { + OSStatus theError = pthread_mutex_lock(&cag->mMutex); (void) theError; - assert (theError == 0); - cag->mOwner = pthread_self (); + assert(theError == 0); + cag->mOwner = pthread_self(); theAnswer = 1; } @@ -108,30 +108,30 @@ } static void -SDLOSXCAGuard_Unlock (SDLOSXCAGuard * cag) +SDLOSXCAGuard_Unlock(SDLOSXCAGuard * cag) { OSStatus theError; - assert (pthread_self () == cag->mOwner); + assert(pthread_self() == cag->mOwner); cag->mOwner = 0; - theError = pthread_mutex_unlock (&cag->mMutex); + theError = pthread_mutex_unlock(&cag->mMutex); (void) theError; - assert (theError == 0); + assert(theError == 0); } static int -SDLOSXCAGuard_Try (SDLOSXCAGuard * cag, int *outWasLocked) +SDLOSXCAGuard_Try(SDLOSXCAGuard * cag, int *outWasLocked) { int theAnswer = 0; *outWasLocked = 0; - if (pthread_self () == cag->mOwner) { + if (pthread_self() == cag->mOwner) { theAnswer = 1; *outWasLocked = 0; } else { - OSStatus theError = pthread_mutex_trylock (&cag->mMutex); + OSStatus theError = pthread_mutex_trylock(&cag->mMutex); if (theError == 0) { - cag->mOwner = pthread_self (); + cag->mOwner = pthread_self(); theAnswer = 1; *outWasLocked = 1; } @@ -141,65 +141,64 @@ } static void -SDLOSXCAGuard_Wait (SDLOSXCAGuard * cag) +SDLOSXCAGuard_Wait(SDLOSXCAGuard * cag) { OSStatus theError; - assert (pthread_self () == cag->mOwner); + assert(pthread_self() == cag->mOwner); cag->mOwner = 0; - theError = pthread_cond_wait (&cag->mCondVar, &cag->mMutex); + theError = pthread_cond_wait(&cag->mCondVar, &cag->mMutex); (void) theError; - assert (theError == 0); - cag->mOwner = pthread_self (); + assert(theError == 0); + cag->mOwner = pthread_self(); } static void -SDLOSXCAGuard_Notify (SDLOSXCAGuard * cag) +SDLOSXCAGuard_Notify(SDLOSXCAGuard * cag) { - OSStatus theError = pthread_cond_signal (&cag->mCondVar); + OSStatus theError = pthread_cond_signal(&cag->mCondVar); (void) theError; - assert (theError == 0); + assert(theError == 0); } SDLOSXCAGuard * -new_SDLOSXCAGuard (void) +new_SDLOSXCAGuard(void) { OSStatus theError; - SDLOSXCAGuard *cag = - (SDLOSXCAGuard *) SDL_malloc (sizeof (SDLOSXCAGuard)); + SDLOSXCAGuard *cag = (SDLOSXCAGuard *) SDL_malloc(sizeof(SDLOSXCAGuard)); if (cag == NULL) return NULL; - SDL_memset (cag, '\0', sizeof (*cag)); + SDL_memset(cag, '\0', sizeof(*cag)); #define SET_SDLOSXCAGUARD_METHOD(m) cag->m = SDLOSXCAGuard_##m - SET_SDLOSXCAGUARD_METHOD (Lock); - SET_SDLOSXCAGUARD_METHOD (Unlock); - SET_SDLOSXCAGUARD_METHOD (Try); - SET_SDLOSXCAGUARD_METHOD (Wait); - SET_SDLOSXCAGUARD_METHOD (Notify); + SET_SDLOSXCAGUARD_METHOD(Lock); + SET_SDLOSXCAGUARD_METHOD(Unlock); + SET_SDLOSXCAGUARD_METHOD(Try); + SET_SDLOSXCAGUARD_METHOD(Wait); + SET_SDLOSXCAGUARD_METHOD(Notify); #undef SET_SDLOSXCAGUARD_METHOD - theError = pthread_mutex_init (&cag->mMutex, NULL); + theError = pthread_mutex_init(&cag->mMutex, NULL); (void) theError; - assert (theError == 0); + assert(theError == 0); - theError = pthread_cond_init (&cag->mCondVar, NULL); + theError = pthread_cond_init(&cag->mCondVar, NULL); (void) theError; - assert (theError == 0); + assert(theError == 0); cag->mOwner = 0; return cag; } void -delete_SDLOSXCAGuard (SDLOSXCAGuard * cag) +delete_SDLOSXCAGuard(SDLOSXCAGuard * cag) { if (cag != NULL) { - pthread_mutex_destroy (&cag->mMutex); - pthread_cond_destroy (&cag->mCondVar); - SDL_free (cag); + pthread_mutex_destroy(&cag->mMutex); + pthread_cond_destroy(&cag->mCondVar); + SDL_free(cag); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/macosx/SDLOSXCAGuard.h --- a/src/cdrom/macosx/SDLOSXCAGuard.h Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/macosx/SDLOSXCAGuard.h Mon May 29 04:04:35 2006 +0000 @@ -109,8 +109,8 @@ pthread_t mOwner; } SDLOSXCAGuard; -SDLOSXCAGuard *new_SDLOSXCAGuard (void); -void delete_SDLOSXCAGuard (SDLOSXCAGuard * cag); +SDLOSXCAGuard *new_SDLOSXCAGuard(void); +void delete_SDLOSXCAGuard(SDLOSXCAGuard * cag); #endif /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/macosx/SDL_syscdrom.c --- a/src/cdrom/macosx/SDL_syscdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/macosx/SDL_syscdrom.c Mon May 29 04:04:35 2006 +0000 @@ -40,22 +40,22 @@ #pragma mark -- Prototypes -- -static const char *SDL_SYS_CDName (int drive); -static int SDL_SYS_CDOpen (int drive); -static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); -static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); -static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); -static int SDL_SYS_CDPause (SDL_CD * cdrom); -static int SDL_SYS_CDResume (SDL_CD * cdrom); -static int SDL_SYS_CDStop (SDL_CD * cdrom); -static int SDL_SYS_CDEject (SDL_CD * cdrom); -static void SDL_SYS_CDClose (SDL_CD * cdrom); +static const char *SDL_SYS_CDName(int drive); +static int SDL_SYS_CDOpen(int drive); +static int SDL_SYS_CDGetTOC(SDL_CD * cdrom); +static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position); +static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length); +static int SDL_SYS_CDPause(SDL_CD * cdrom); +static int SDL_SYS_CDResume(SDL_CD * cdrom); +static int SDL_SYS_CDStop(SDL_CD * cdrom); +static int SDL_SYS_CDEject(SDL_CD * cdrom); +static void SDL_SYS_CDClose(SDL_CD * cdrom); #pragma mark -- Helper Functions -- /* Read a list of tracks from the volume */ static int -LoadTracks (SDL_CD * cdrom) +LoadTracks(SDL_CD * cdrom) { /* Check if tracks are already loaded */ if (tracks[cdrom->id] != NULL) @@ -63,9 +63,9 @@ /* Allocate memory for tracks */ tracks[cdrom->id] = - (FSRef *) SDL_calloc (1, sizeof (**tracks) * cdrom->numtracks); + (FSRef *) SDL_calloc(1, sizeof(**tracks) * cdrom->numtracks); if (tracks[cdrom->id] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return -1; } @@ -79,8 +79,8 @@ /* Find a file for a given start frame and length */ static FSRef * -GetFileForOffset (SDL_CD * cdrom, int start, int length, int *outStartFrame, - int *outStopFrame) +GetFileForOffset(SDL_CD * cdrom, int start, int length, int *outStartFrame, + int *outStopFrame) { int i; @@ -115,10 +115,10 @@ /* Setup another file for playback, or stop playback (called from another thread) */ static void -CompletionProc (SDL_CD * cdrom) +CompletionProc(SDL_CD * cdrom) { - Lock (); + Lock(); if (nextTrackFrame > 0 && nextTrackFramesRemaining > 0) { @@ -126,33 +126,33 @@ int startFrame, stopFrame; FSRef *file; - PauseFile (); - ReleaseFile (); + PauseFile(); + ReleaseFile(); - file = GetFileForOffset (cdrom, nextTrackFrame, - nextTrackFramesRemaining, &startFrame, - &stopFrame); + file = GetFileForOffset(cdrom, nextTrackFrame, + nextTrackFramesRemaining, &startFrame, + &stopFrame); if (file == NULL) { status = CD_STOPPED; - Unlock (); + Unlock(); return; } - LoadFile (file, startFrame, stopFrame); + LoadFile(file, startFrame, stopFrame); - SetCompletionProc (CompletionProc, cdrom); + SetCompletionProc(CompletionProc, cdrom); - PlayFile (); + PlayFile(); } else { /* Release the current file */ - PauseFile (); - ReleaseFile (); + PauseFile(); + ReleaseFile(); status = CD_STOPPED; } - Unlock (); + Unlock(); } @@ -160,7 +160,7 @@ /* Initialize */ int -SDL_SYS_CDInit (void) +SDL_SYS_CDInit(void) { /* Initialize globals */ volumes = NULL; @@ -196,7 +196,7 @@ */ /* Find out how many cd volumes are mounted */ - SDL_numcds = DetectAudioCDVolumes (NULL, 0); + SDL_numcds = DetectAudioCDVolumes(NULL, 0); /* If there are no volumes, fake a cd device @@ -212,17 +212,16 @@ } /* Allocate space for volumes */ - volumes = - (FSVolumeRefNum *) SDL_calloc (1, sizeof (*volumes) * SDL_numcds); + volumes = (FSVolumeRefNum *) SDL_calloc(1, sizeof(*volumes) * SDL_numcds); if (volumes == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return -1; } /* Allocate space for tracks */ - tracks = (FSRef **) SDL_calloc (1, sizeof (*tracks) * (SDL_numcds + 1)); + tracks = (FSRef **) SDL_calloc(1, sizeof(*tracks) * (SDL_numcds + 1)); if (tracks == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return -1; } @@ -236,11 +235,11 @@ { int numVolumes = SDL_numcds; - SDL_numcds = DetectAudioCDVolumes (volumes, numVolumes); + SDL_numcds = DetectAudioCDVolumes(volumes, numVolumes); /* If more cds suddenly show up, ignore them */ if (SDL_numcds > numVolumes) { - SDL_SetError ("Some CD's were added but they will be ignored"); + SDL_SetError("Some CD's were added but they will be ignored"); SDL_numcds = numVolumes; } } @@ -250,27 +249,27 @@ /* Shutdown and cleanup */ void -SDL_SYS_CDQuit (void) +SDL_SYS_CDQuit(void) { - ReleaseFile (); + ReleaseFile(); if (volumes != NULL) - free (volumes); + free(volumes); if (tracks != NULL) { FSRef **ptr; for (ptr = tracks; *ptr != (FSRef *) - 1; ptr++) if (*ptr != NULL) - free (*ptr); + free(*ptr); - free (tracks); + free(tracks); } } /* Get the Unix disk name of the volume */ static const char * -SDL_SYS_CDName (int drive) +SDL_SYS_CDName(int drive) { OSStatus err = noErr; HParamBlockRec pb; @@ -282,11 +281,11 @@ pb.ioParam.ioNamePtr = NULL; pb.ioParam.ioVRefNum = volumes[drive]; pb.ioParam.ioBuffer = (Ptr) & volParmsInfo; - pb.ioParam.ioReqCount = (SInt32) sizeof (volParmsInfo); - err = PBHGetVolParmsSync (&pb); + pb.ioParam.ioReqCount = (SInt32) sizeof(volParmsInfo); + err = PBHGetVolParmsSync(&pb); if (err != noErr) { - SDL_SetError ("PBHGetVolParmsSync returned %d", err); + SDL_SetError("PBHGetVolParmsSync returned %d", err); return NULL; } @@ -295,11 +294,11 @@ /* Open the "device" */ static int -SDL_SYS_CDOpen (int drive) +SDL_SYS_CDOpen(int drive) { /* Only allow 1 device to be open */ if (currentDrive >= 0) { - SDL_SetError ("Only one cdrom is supported"); + SDL_SetError("Only one cdrom is supported"); return -1; } else currentDrive = drive; @@ -309,10 +308,10 @@ /* Get the table of contents */ static int -SDL_SYS_CDGetTOC (SDL_CD * cdrom) +SDL_SYS_CDGetTOC(SDL_CD * cdrom) { if (fakeCD) { - SDL_SetError (kErrorFakeDevice); + SDL_SetError(kErrorFakeDevice); return -1; } @@ -322,7 +321,7 @@ } - ReadTOCData (volumes[cdrom->id], cdrom); + ReadTOCData(volumes[cdrom->id], cdrom); didReadTOC = SDL_TRUE; cacheTOCNumTracks = cdrom->numtracks; @@ -331,14 +330,14 @@ /* Get CD-ROM status */ static CDstatus -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position) { if (position) { int trackFrame; - Lock (); - trackFrame = GetCurrentFrame (); - Unlock (); + Lock(); + trackFrame = GetCurrentFrame(); + Unlock(); *position = cdrom->track[currentTrack].offset + trackFrame; } @@ -348,155 +347,155 @@ /* Start playback */ static int -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) { int startFrame, stopFrame; FSRef *ref; if (fakeCD) { - SDL_SetError (kErrorFakeDevice); + SDL_SetError(kErrorFakeDevice); return -1; } - Lock (); + Lock(); - if (LoadTracks (cdrom) < 0) + if (LoadTracks(cdrom) < 0) return -2; - if (PauseFile () < 0) + if (PauseFile() < 0) return -3; - if (ReleaseFile () < 0) + if (ReleaseFile() < 0) return -4; - ref = GetFileForOffset (cdrom, start, length, &startFrame, &stopFrame); + ref = GetFileForOffset(cdrom, start, length, &startFrame, &stopFrame); if (ref == NULL) { - SDL_SetError ("SDL_SYS_CDPlay: No file for start=%d, length=%d", - start, length); + SDL_SetError("SDL_SYS_CDPlay: No file for start=%d, length=%d", + start, length); return -5; } - if (LoadFile (ref, startFrame, stopFrame) < 0) + if (LoadFile(ref, startFrame, stopFrame) < 0) return -6; - SetCompletionProc (CompletionProc, cdrom); + SetCompletionProc(CompletionProc, cdrom); - if (PlayFile () < 0) + if (PlayFile() < 0) return -7; status = CD_PLAYING; - Unlock (); + Unlock(); return 0; } /* Pause playback */ static int -SDL_SYS_CDPause (SDL_CD * cdrom) +SDL_SYS_CDPause(SDL_CD * cdrom) { if (fakeCD) { - SDL_SetError (kErrorFakeDevice); + SDL_SetError(kErrorFakeDevice); return -1; } - Lock (); + Lock(); - if (PauseFile () < 0) { - Unlock (); + if (PauseFile() < 0) { + Unlock(); return -2; } status = CD_PAUSED; - Unlock (); + Unlock(); return 0; } /* Resume playback */ static int -SDL_SYS_CDResume (SDL_CD * cdrom) +SDL_SYS_CDResume(SDL_CD * cdrom) { if (fakeCD) { - SDL_SetError (kErrorFakeDevice); + SDL_SetError(kErrorFakeDevice); return -1; } - Lock (); + Lock(); - if (PlayFile () < 0) { - Unlock (); + if (PlayFile() < 0) { + Unlock(); return -2; } status = CD_PLAYING; - Unlock (); + Unlock(); return 0; } /* Stop playback */ static int -SDL_SYS_CDStop (SDL_CD * cdrom) +SDL_SYS_CDStop(SDL_CD * cdrom) { if (fakeCD) { - SDL_SetError (kErrorFakeDevice); + SDL_SetError(kErrorFakeDevice); return -1; } - Lock (); + Lock(); - if (PauseFile () < 0) { - Unlock (); + if (PauseFile() < 0) { + Unlock(); return -2; } - if (ReleaseFile () < 0) { - Unlock (); + if (ReleaseFile() < 0) { + Unlock(); return -3; } status = CD_STOPPED; - Unlock (); + Unlock(); return 0; } /* Eject the CD-ROM (Unmount the volume) */ static int -SDL_SYS_CDEject (SDL_CD * cdrom) +SDL_SYS_CDEject(SDL_CD * cdrom) { OSStatus err; pid_t dissenter; if (fakeCD) { - SDL_SetError (kErrorFakeDevice); + SDL_SetError(kErrorFakeDevice); return -1; } - Lock (); + Lock(); - if (PauseFile () < 0) { - Unlock (); + if (PauseFile() < 0) { + Unlock(); return -2; } - if (ReleaseFile () < 0) { - Unlock (); + if (ReleaseFile() < 0) { + Unlock(); return -3; } status = CD_STOPPED; /* Eject the volume */ - err = FSEjectVolumeSync (volumes[cdrom->id], kNilOptions, &dissenter); + err = FSEjectVolumeSync(volumes[cdrom->id], kNilOptions, &dissenter); if (err != noErr) { - Unlock (); - SDL_SetError ("PBUnmountVol returned %d", err); + Unlock(); + SDL_SetError("PBUnmountVol returned %d", err); return -4; } @@ -504,17 +503,17 @@ /* Invalidate volume and track info */ volumes[cdrom->id] = 0; - free (tracks[cdrom->id]); + free(tracks[cdrom->id]); tracks[cdrom->id] = NULL; - Unlock (); + Unlock(); return 0; } /* Close the CD-ROM */ static void -SDL_SYS_CDClose (SDL_CD * cdrom) +SDL_SYS_CDClose(SDL_CD * cdrom) { currentDrive = -1; return; diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/mint/SDL_syscdrom.c --- a/src/cdrom/mint/SDL_syscdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/mint/SDL_syscdrom.c Mon May 29 04:04:35 2006 +0000 @@ -57,37 +57,37 @@ static metados_drive_t metados_drives[MAX_DRIVES]; /* The system-dependent CD control functions */ -static const char *SDL_SYS_CDName (int drive); -static int SDL_SYS_CDOpen (int drive); -static void SDL_SYS_CDClose (SDL_CD * cdrom); -static int SDL_SYS_CDioctl (int id, int command, void *arg); -static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); -static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); -static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); -static int SDL_SYS_CDPause (SDL_CD * cdrom); -static int SDL_SYS_CDResume (SDL_CD * cdrom); -static int SDL_SYS_CDStop (SDL_CD * cdrom); -static int SDL_SYS_CDEject (SDL_CD * cdrom); +static const char *SDL_SYS_CDName(int drive); +static int SDL_SYS_CDOpen(int drive); +static void SDL_SYS_CDClose(SDL_CD * cdrom); +static int SDL_SYS_CDioctl(int id, int command, void *arg); +static int SDL_SYS_CDGetTOC(SDL_CD * cdrom); +static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position); +static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length); +static int SDL_SYS_CDPause(SDL_CD * cdrom); +static int SDL_SYS_CDResume(SDL_CD * cdrom); +static int SDL_SYS_CDStop(SDL_CD * cdrom); +static int SDL_SYS_CDEject(SDL_CD * cdrom); int -SDL_SYS_CDInit (void) +SDL_SYS_CDInit(void) { metainit_t metainit = { 0, 0, 0, 0 }; metaopen_t metaopen; int i, handle; struct cdrom_subchnl info; - Metainit (&metainit); + Metainit(&metainit); if (metainit.version == NULL) { #ifdef DEBUG_CDROM - fprintf (stderr, "MetaDOS not installed\n"); + fprintf(stderr, "MetaDOS not installed\n"); #endif return -1; } if (metainit.drives_map == 0) { #ifdef DEBUG_CDROM - fprintf (stderr, "No MetaDOS devices present\n"); + fprintf(stderr, "No MetaDOS devices present\n"); #endif return -1; } @@ -100,18 +100,18 @@ metados_drives[SDL_numcds].device[2] = 0; if (metainit.drives_map & (1 << (i - 'A'))) { - handle = Metaopen (i, &metaopen); + handle = Metaopen(i, &metaopen); if (handle == 0) { info.cdsc_format = CDROM_MSF; if ((Metaioctl (i, METADOS_IOCTL_MAGIC, CDROMSUBCHNL, &info) == 0) - || ERRNO_TRAYEMPTY (errno)) { + || ERRNO_TRAYEMPTY(errno)) { metados_drives[SDL_numcds].device[0] = i; ++SDL_numcds; } - Metaclose (i); + Metaclose(i); } } } @@ -133,25 +133,25 @@ } void -SDL_SYS_CDQuit (void) +SDL_SYS_CDQuit(void) { SDL_numcds = 0; } static const char * -SDL_SYS_CDName (int drive) +SDL_SYS_CDName(int drive) { return (metados_drives[drive].device); } static int -SDL_SYS_CDOpen (int drive) +SDL_SYS_CDOpen(int drive) { int handle; handle = - Metaopen (metados_drives[drive].device[0], - &(metados_drives[drive].metaopen)); + Metaopen(metados_drives[drive].device[0], + &(metados_drives[drive].metaopen)); if (handle == 0) { return drive; } @@ -160,34 +160,34 @@ } static void -SDL_SYS_CDClose (SDL_CD * cdrom) +SDL_SYS_CDClose(SDL_CD * cdrom) { - Metaclose (metados_drives[cdrom->id].device[0]); + Metaclose(metados_drives[cdrom->id].device[0]); } static int -SDL_SYS_CDioctl (int id, int command, void *arg) +SDL_SYS_CDioctl(int id, int command, void *arg) { int retval; retval = - Metaioctl (metados_drives[id].device[0], METADOS_IOCTL_MAGIC, command, - arg); + Metaioctl(metados_drives[id].device[0], METADOS_IOCTL_MAGIC, command, + arg); if (retval < 0) { - SDL_SetError ("ioctl() error: %s", strerror (errno)); + SDL_SetError("ioctl() error: %s", strerror(errno)); } return (retval); } static int -SDL_SYS_CDGetTOC (SDL_CD * cdrom) +SDL_SYS_CDGetTOC(SDL_CD * cdrom) { int i, okay; struct cdrom_tochdr toc; struct cdrom_tocentry entry; /* Use standard ioctl() */ - if (SDL_SYS_CDioctl (cdrom->id, CDROMREADTOCHDR, &toc) < 0) { + if (SDL_SYS_CDioctl(cdrom->id, CDROMREADTOCHDR, &toc) < 0) { return -1; } @@ -206,7 +206,7 @@ } entry.cdte_track = cdrom->track[i].id; entry.cdte_format = CDROM_MSF; - if (SDL_SYS_CDioctl (cdrom->id, CDROMREADTOCENTRY, &entry) < 0) { + if (SDL_SYS_CDioctl(cdrom->id, CDROMREADTOCENTRY, &entry) < 0) { okay = 0; break; } else { @@ -216,9 +216,9 @@ cdrom->track[i].type = SDL_AUDIO_TRACK; } cdrom->track[i].offset = - MSF_TO_FRAMES (entry.cdte_addr.msf.minute, - entry.cdte_addr.msf.second, - entry.cdte_addr.msf.frame); + MSF_TO_FRAMES(entry.cdte_addr.msf.minute, + entry.cdte_addr.msf.second, + entry.cdte_addr.msf.frame); cdrom->track[i].length = 0; if (i > 0) { cdrom->track[i - 1].length = @@ -232,15 +232,15 @@ /* Get CD-ROM status */ static CDstatus -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position) { CDstatus status; struct cdrom_tochdr toc; struct cdrom_subchnl info; info.cdsc_format = CDROM_MSF; - if (SDL_SYS_CDioctl (cdrom->id, CDROMSUBCHNL, &info) < 0) { - if (ERRNO_TRAYEMPTY (errno)) { + if (SDL_SYS_CDioctl(cdrom->id, CDROMSUBCHNL, &info) < 0) { + if (ERRNO_TRAYEMPTY(errno)) { status = CD_TRAYEMPTY; } else { status = CD_ERROR; @@ -250,7 +250,7 @@ case CDROM_AUDIO_INVALID: case CDROM_AUDIO_NO_STATUS: /* Try to determine if there's a CD available */ - if (SDL_SYS_CDioctl (cdrom->id, CDROMREADTOCHDR, &toc) == 0) { + if (SDL_SYS_CDioctl(cdrom->id, CDROMREADTOCHDR, &toc) == 0) { status = CD_STOPPED; } else { status = CD_TRAYEMPTY; @@ -277,9 +277,9 @@ } if (position) { if (status == CD_PLAYING || (status == CD_PAUSED)) { - *position = MSF_TO_FRAMES (info.cdsc_absaddr.msf.minute, - info.cdsc_absaddr.msf.second, - info.cdsc_absaddr.msf.frame); + *position = MSF_TO_FRAMES(info.cdsc_absaddr.msf.minute, + info.cdsc_absaddr.msf.second, + info.cdsc_absaddr.msf.frame); } else { *position = 0; } @@ -289,50 +289,50 @@ /* Start play */ static int -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) { struct cdrom_msf playtime; - FRAMES_TO_MSF (start, - &playtime.cdmsf_min0, &playtime.cdmsf_sec0, - &playtime.cdmsf_frame0); - FRAMES_TO_MSF (start + length, &playtime.cdmsf_min1, &playtime.cdmsf_sec1, - &playtime.cdmsf_frame1); + FRAMES_TO_MSF(start, + &playtime.cdmsf_min0, &playtime.cdmsf_sec0, + &playtime.cdmsf_frame0); + FRAMES_TO_MSF(start + length, &playtime.cdmsf_min1, &playtime.cdmsf_sec1, + &playtime.cdmsf_frame1); #ifdef DEBUG_CDROM - fprintf (stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", - playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0, - playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1); + fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", + playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0, + playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1); #endif - return SDL_SYS_CDioctl (cdrom->id, CDROMPLAYMSF, &playtime); + return SDL_SYS_CDioctl(cdrom->id, CDROMPLAYMSF, &playtime); } /* Pause play */ static int -SDL_SYS_CDPause (SDL_CD * cdrom) +SDL_SYS_CDPause(SDL_CD * cdrom) { - return SDL_SYS_CDioctl (cdrom->id, CDROMPAUSE, 0); + return SDL_SYS_CDioctl(cdrom->id, CDROMPAUSE, 0); } /* Resume play */ static int -SDL_SYS_CDResume (SDL_CD * cdrom) +SDL_SYS_CDResume(SDL_CD * cdrom) { - return SDL_SYS_CDioctl (cdrom->id, CDROMRESUME, 0); + return SDL_SYS_CDioctl(cdrom->id, CDROMRESUME, 0); } /* Stop play */ static int -SDL_SYS_CDStop (SDL_CD * cdrom) +SDL_SYS_CDStop(SDL_CD * cdrom) { - return SDL_SYS_CDioctl (cdrom->id, CDROMSTOP, 0); + return SDL_SYS_CDioctl(cdrom->id, CDROMSTOP, 0); } /* Eject the CD-ROM */ static int -SDL_SYS_CDEject (SDL_CD * cdrom) +SDL_SYS_CDEject(SDL_CD * cdrom) { - return SDL_SYS_CDioctl (cdrom->id, CDROMEJECT, 0); + return SDL_SYS_CDioctl(cdrom->id, CDROMEJECT, 0); } #endif /* SDL_CDROM_MINT */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/openbsd/SDL_syscdrom.c --- a/src/cdrom/openbsd/SDL_syscdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/openbsd/SDL_syscdrom.c Mon May 29 04:04:35 2006 +0000 @@ -46,16 +46,16 @@ static dev_t SDL_cdmode[MAX_DRIVES]; /* The system-dependent CD control functions */ -static const char *SDL_SYS_CDName (int drive); -static int SDL_SYS_CDOpen (int drive); -static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); -static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); -static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); -static int SDL_SYS_CDPause (SDL_CD * cdrom); -static int SDL_SYS_CDResume (SDL_CD * cdrom); -static int SDL_SYS_CDStop (SDL_CD * cdrom); -static int SDL_SYS_CDEject (SDL_CD * cdrom); -static void SDL_SYS_CDClose (SDL_CD * cdrom); +static const char *SDL_SYS_CDName(int drive); +static int SDL_SYS_CDOpen(int drive); +static int SDL_SYS_CDGetTOC(SDL_CD * cdrom); +static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position); +static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length); +static int SDL_SYS_CDPause(SDL_CD * cdrom); +static int SDL_SYS_CDResume(SDL_CD * cdrom); +static int SDL_SYS_CDStop(SDL_CD * cdrom); +static int SDL_SYS_CDEject(SDL_CD * cdrom); +static void SDL_SYS_CDClose(SDL_CD * cdrom); /* Some ioctl() errno values which occur when the tray is empty */ #define ERRNO_TRAYEMPTY(errno) \ @@ -64,20 +64,20 @@ /* Check a drive to see if it is a CD-ROM */ static int -CheckDrive (char *drive, struct stat *stbuf) +CheckDrive(char *drive, struct stat *stbuf) { int is_cd, cdfd; struct ioc_read_subchannel info; /* If it doesn't exist, return -1 */ - if (stat (drive, stbuf) < 0) { + if (stat(drive, stbuf) < 0) { return (-1); } /* If it does exist, verify that it's an available CD-ROM */ is_cd = 0; - if (S_ISCHR (stbuf->st_mode) || S_ISBLK (stbuf->st_mode)) { - cdfd = open (drive, (O_RDONLY | O_EXCL | O_NONBLOCK), 0); + if (S_ISCHR(stbuf->st_mode) || S_ISBLK(stbuf->st_mode)) { + cdfd = open(drive, (O_RDONLY | O_EXCL | O_NONBLOCK), 0); if (cdfd >= 0) { info.address_format = CD_MSF_FORMAT; info.data_format = CD_CURRENT_POSITION; @@ -87,12 +87,12 @@ This isn't 100% reliable, so we use the USE_MNTENT code above instead. */ - if ((ioctl (cdfd, CDIOCREADSUBCHANNEL, &info) == 0) || - ERRNO_TRAYEMPTY (errno)) { + if ((ioctl(cdfd, CDIOCREADSUBCHANNEL, &info) == 0) || + ERRNO_TRAYEMPTY(errno)) { is_cd = 1; } - close (cdfd); - } else if (ERRNO_TRAYEMPTY (errno)) + close(cdfd); + } else if (ERRNO_TRAYEMPTY(errno)) is_cd = 1; } return (is_cd); @@ -100,7 +100,7 @@ /* Add a CD-ROM drive to our list of valid drives */ static void -AddDrive (char *drive, struct stat *stbuf) +AddDrive(char *drive, struct stat *stbuf) { int i; @@ -111,8 +111,8 @@ for (i = 0; i < SDL_numcds; ++i) { if (stbuf->st_rdev == SDL_cdmode[i]) { #ifdef DEBUG_CDROM - fprintf (stderr, "Duplicate drive detected: %s == %s\n", - drive, SDL_cdlist[i]); + fprintf(stderr, "Duplicate drive detected: %s == %s\n", + drive, SDL_cdlist[i]); #endif return; } @@ -120,21 +120,21 @@ /* Add this drive to our list */ i = SDL_numcds; - SDL_cdlist[i] = SDL_strdup (drive); + SDL_cdlist[i] = SDL_strdup(drive); if (SDL_cdlist[i] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return; } SDL_cdmode[i] = stbuf->st_rdev; ++SDL_numcds; #ifdef DEBUG_CDROM - fprintf (stderr, "Added CD-ROM drive: %s\n", drive); + fprintf(stderr, "Added CD-ROM drive: %s\n", drive); #endif } } int -SDL_SYS_CDInit (void) +SDL_SYS_CDInit(void) { static char *checklist[] = { #if defined(__OPENBSD__) @@ -163,21 +163,21 @@ SDL_CDcaps.Close = SDL_SYS_CDClose; /* Look in the environment for our CD-ROM drive list */ - SDLcdrom = SDL_getenv ("SDL_CDROM"); /* ':' separated list of devices */ + SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ if (SDLcdrom != NULL) { char *cdpath, *delim; - size_t len = SDL_strlen (SDLcdrom) + 1; - cdpath = SDL_stack_alloc (char, len); + size_t len = SDL_strlen(SDLcdrom) + 1; + cdpath = SDL_stack_alloc(char, len); if (cdpath != NULL) { - SDL_strlcpy (cdpath, SDLcdrom, len); + SDL_strlcpy(cdpath, SDLcdrom, len); SDLcdrom = cdpath; do { - delim = SDL_strchr (SDLcdrom, ':'); + delim = SDL_strchr(SDLcdrom, ':'); if (delim) { *delim++ = '\0'; } - if (CheckDrive (SDLcdrom, &stbuf) > 0) { - AddDrive (SDLcdrom, &stbuf); + if (CheckDrive(SDLcdrom, &stbuf) > 0) { + AddDrive(SDLcdrom, &stbuf); } if (delim) { SDLcdrom = delim; @@ -186,7 +186,7 @@ } } while (SDLcdrom); - SDL_stack_free (cdpath); + SDL_stack_free(cdpath); } /* If we found our drives, there's nothing left to do */ @@ -201,16 +201,16 @@ char *insert; exists = 1; for (j = checklist[i][1]; exists; ++j) { - SDL_snprintf (drive, SDL_arraysize (drive), "/dev/%s", - &checklist[i][3]); - insert = SDL_strchr (drive, '?'); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", + &checklist[i][3]); + insert = SDL_strchr(drive, '?'); if (insert != NULL) { *insert = j; } - switch (CheckDrive (drive, &stbuf)) { + switch (CheckDrive(drive, &stbuf)) { /* Drive exists and is a CD-ROM */ case 1: - AddDrive (drive, &stbuf); + AddDrive(drive, &stbuf); break; /* Drive exists, but isn't a CD-ROM */ case 0: @@ -222,10 +222,10 @@ } } } else { - SDL_snprintf (drive, SDL_arraysize (drive), "/dev/%s", - checklist[i]); - if (CheckDrive (drive, &stbuf) > 0) { - AddDrive (drive, &stbuf); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", + checklist[i]); + if (CheckDrive(drive, &stbuf) > 0) { + AddDrive(drive, &stbuf); } } } @@ -234,31 +234,31 @@ /* General ioctl() CD-ROM command function */ static int -SDL_SYS_CDioctl (int id, int command, void *arg) +SDL_SYS_CDioctl(int id, int command, void *arg) { int retval; - retval = ioctl (id, command, arg); + retval = ioctl(id, command, arg); if (retval < 0) { - SDL_SetError ("ioctl() error: %s", strerror (errno)); + SDL_SetError("ioctl() error: %s", strerror(errno)); } return (retval); } static const char * -SDL_SYS_CDName (int drive) +SDL_SYS_CDName(int drive) { return (SDL_cdlist[drive]); } static int -SDL_SYS_CDOpen (int drive) +SDL_SYS_CDOpen(int drive) { - return (open (SDL_cdlist[drive], (O_RDONLY | O_EXCL | O_NONBLOCK), 0)); + return (open(SDL_cdlist[drive], (O_RDONLY | O_EXCL | O_NONBLOCK), 0)); } static int -SDL_SYS_CDGetTOC (SDL_CD * cdrom) +SDL_SYS_CDGetTOC(SDL_CD * cdrom) { struct ioc_toc_header toc; int i, okay; @@ -266,7 +266,7 @@ struct cd_toc_entry data; okay = 0; - if (SDL_SYS_CDioctl (cdrom->id, CDIOREADTOCHEADER, &toc) == 0) { + if (SDL_SYS_CDioctl(cdrom->id, CDIOREADTOCHEADER, &toc) == 0) { cdrom->numtracks = toc.ending_track - toc.starting_track + 1; if (cdrom->numtracks > SDL_MAX_TRACKS) { cdrom->numtracks = SDL_MAX_TRACKS; @@ -280,15 +280,15 @@ } entry.starting_track = cdrom->track[i].id; entry.address_format = CD_MSF_FORMAT; - entry.data_len = sizeof (data); + entry.data_len = sizeof(data); entry.data = &data; - if (SDL_SYS_CDioctl (cdrom->id, CDIOREADTOCENTRYS, &entry) < 0) { + if (SDL_SYS_CDioctl(cdrom->id, CDIOREADTOCENTRYS, &entry) < 0) { break; } else { cdrom->track[i].type = data.control; cdrom->track[i].offset = - MSF_TO_FRAMES (data.addr.msf.minute, - data.addr.msf.second, data.addr.msf.frame); + MSF_TO_FRAMES(data.addr.msf.minute, + data.addr.msf.second, data.addr.msf.frame); cdrom->track[i].length = 0; if (i > 0) { cdrom->track[i - 1].length = @@ -305,7 +305,7 @@ /* Get CD-ROM status */ static CDstatus -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position) { CDstatus status; struct ioc_toc_header toc; @@ -315,10 +315,10 @@ info.address_format = CD_MSF_FORMAT; info.data_format = CD_CURRENT_POSITION; info.track = 0; - info.data_len = sizeof (data); + info.data_len = sizeof(data); info.data = &data; - if (ioctl (cdrom->id, CDIOCREADSUBCHANNEL, &info) < 0) { - if (ERRNO_TRAYEMPTY (errno)) { + if (ioctl(cdrom->id, CDIOCREADSUBCHANNEL, &info) < 0) { + if (ERRNO_TRAYEMPTY(errno)) { status = CD_TRAYEMPTY; } else { status = CD_ERROR; @@ -328,7 +328,7 @@ case CD_AS_AUDIO_INVALID: case CD_AS_NO_STATUS: /* Try to determine if there's a CD available */ - if (ioctl (cdrom->id, CDIOREADTOCHEADER, &toc) == 0) + if (ioctl(cdrom->id, CDIOREADTOCHEADER, &toc) == 0) status = CD_STOPPED; else status = CD_TRAYEMPTY; @@ -350,9 +350,9 @@ if (position) { if (status == CD_PLAYING || (status == CD_PAUSED)) { *position = - MSF_TO_FRAMES (data.what.position.absaddr.msf.minute, - data.what.position.absaddr.msf.second, - data.what.position.absaddr.msf.frame); + MSF_TO_FRAMES(data.what.position.absaddr.msf.minute, + data.what.position.absaddr.msf.second, + data.what.position.absaddr.msf.frame); } else { *position = 0; } @@ -362,66 +362,66 @@ /* Start play */ static int -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) { struct ioc_play_msf playtime; - FRAMES_TO_MSF (start, - &playtime.start_m, &playtime.start_s, &playtime.start_f); - FRAMES_TO_MSF (start + length, - &playtime.end_m, &playtime.end_s, &playtime.end_f); + FRAMES_TO_MSF(start, + &playtime.start_m, &playtime.start_s, &playtime.start_f); + FRAMES_TO_MSF(start + length, + &playtime.end_m, &playtime.end_s, &playtime.end_f); #ifdef DEBUG_CDROM - fprintf (stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", - playtime.start_m, playtime.start_s, playtime.start_f, - playtime.end_m, playtime.end_s, playtime.end_f); + fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", + playtime.start_m, playtime.start_s, playtime.start_f, + playtime.end_m, playtime.end_s, playtime.end_f); #endif - ioctl (cdrom->id, CDIOCSTART, 0); - return (SDL_SYS_CDioctl (cdrom->id, CDIOCPLAYMSF, &playtime)); + ioctl(cdrom->id, CDIOCSTART, 0); + return (SDL_SYS_CDioctl(cdrom->id, CDIOCPLAYMSF, &playtime)); } /* Pause play */ static int -SDL_SYS_CDPause (SDL_CD * cdrom) +SDL_SYS_CDPause(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, CDIOCPAUSE, 0)); + return (SDL_SYS_CDioctl(cdrom->id, CDIOCPAUSE, 0)); } /* Resume play */ static int -SDL_SYS_CDResume (SDL_CD * cdrom) +SDL_SYS_CDResume(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, CDIOCRESUME, 0)); + return (SDL_SYS_CDioctl(cdrom->id, CDIOCRESUME, 0)); } /* Stop play */ static int -SDL_SYS_CDStop (SDL_CD * cdrom) +SDL_SYS_CDStop(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, CDIOCSTOP, 0)); + return (SDL_SYS_CDioctl(cdrom->id, CDIOCSTOP, 0)); } /* Eject the CD-ROM */ static int -SDL_SYS_CDEject (SDL_CD * cdrom) +SDL_SYS_CDEject(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, CDIOCEJECT, 0)); + return (SDL_SYS_CDioctl(cdrom->id, CDIOCEJECT, 0)); } /* Close the CD-ROM handle */ static void -SDL_SYS_CDClose (SDL_CD * cdrom) +SDL_SYS_CDClose(SDL_CD * cdrom) { - close (cdrom->id); + close(cdrom->id); } void -SDL_SYS_CDQuit (void) +SDL_SYS_CDQuit(void) { int i; if (SDL_numcds > 0) { for (i = 0; i < SDL_numcds; ++i) { - SDL_free (SDL_cdlist[i]); + SDL_free(SDL_cdlist[i]); } SDL_numcds = 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/os2/SDL_syscdrom.c --- a/src/cdrom/os2/SDL_syscdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/os2/SDL_syscdrom.c Mon May 29 04:04:35 2006 +0000 @@ -43,16 +43,16 @@ //static dev_t SDL_cdmode[MAX_DRIVES]; /* The system-dependent CD control functions */ -static const char *SDL_SYS_CDName (int drive); -static int SDL_SYS_CDOpen (int drive); -static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); -static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); -static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); -static int SDL_SYS_CDPause (SDL_CD * cdrom); -static int SDL_SYS_CDResume (SDL_CD * cdrom); -static int SDL_SYS_CDStop (SDL_CD * cdrom); -static int SDL_SYS_CDEject (SDL_CD * cdrom); -static void SDL_SYS_CDClose (SDL_CD * cdrom); +static const char *SDL_SYS_CDName(int drive); +static int SDL_SYS_CDOpen(int drive); +static int SDL_SYS_CDGetTOC(SDL_CD * cdrom); +static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position); +static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length); +static int SDL_SYS_CDPause(SDL_CD * cdrom); +static int SDL_SYS_CDResume(SDL_CD * cdrom); +static int SDL_SYS_CDStop(SDL_CD * cdrom); +static int SDL_SYS_CDEject(SDL_CD * cdrom); +static void SDL_SYS_CDClose(SDL_CD * cdrom); /* MCI Timing Functions */ #define MCI_MMTIMEPERSECOND 3000 @@ -61,7 +61,7 @@ /* Ready for MCI CDAudio Devices */ int -SDL_SYS_CDInit (void) +SDL_SYS_CDInit(void) { int i; /* generig counter */ MCI_SYSINFO_PARMS msp; /* Structure to MCI SysInfo parameters */ @@ -81,7 +81,7 @@ /* Get the number of CD ROMs in the System */ /* Clean SysInfo structure */ - SDL_memset (&msp, 0x00, sizeof (MCI_SYSINFO_PARMS)); + SDL_memset(&msp, 0x00, sizeof(MCI_SYSINFO_PARMS)); /* Prepare structure to Ask Numer of Audio CDs */ msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO; /* CD Audio Type */ msp.pszReturn = (PSZ) & SysInfoRet; /* Return Structure */ @@ -91,7 +91,7 @@ (0, MCI_SYSINFO, MCI_SYSINFO_QUANTITY | MCI_WAIT, (PVOID) & msp, 0)) != MCIERR_SUCCESS) return (CD_ERROR); - SDL_numcds = atoi (SysInfoRet); + SDL_numcds = atoi(SysInfoRet); if (SDL_numcds > MAX_DRIVES) SDL_numcds = MAX_DRIVES; /* Limit maximum CD number */ @@ -101,10 +101,10 @@ msp.usDeviceType = MCI_DEVTYPE_CD_AUDIO; /* CD Audio Type */ for (i = 0; i < SDL_numcds; i++) { msp.ulNumber = i + 1; - mciSendCommand (0, MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_WAIT, &msp, 0); - SDL_cdlist[i] = SDL_strdup (SysInfoRet); + mciSendCommand(0, MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_WAIT, &msp, 0); + SDL_cdlist[i] = SDL_strdup(SysInfoRet); if (SDL_cdlist[i] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } } @@ -113,14 +113,14 @@ /* Return CDAudio System Dependent Device Name - Ready for MCI*/ static const char * -SDL_SYS_CDName (int drive) +SDL_SYS_CDName(int drive) { return (SDL_cdlist[drive]); } /* Open CDAudio Device - Ready for MCI */ static int -SDL_SYS_CDOpen (int drive) +SDL_SYS_CDOpen(int drive) { MCI_OPEN_PARMS mop; MCI_SET_PARMS msp; @@ -130,7 +130,7 @@ mop.hwndCallback = (HWND) NULL; // None mop.usDeviceID = (USHORT) NULL; // Will be returned. mop.pszDeviceType = (PSZ) SDL_cdlist[drive]; // CDAudio Device - if (LOUSHORT (mciSendCommand (0, MCI_OPEN, MCI_WAIT, &mop, 0)) != + if (LOUSHORT(mciSendCommand(0, MCI_OPEN, MCI_WAIT, &mop, 0)) != MCIERR_SUCCESS) return (CD_ERROR); /* Set time format */ @@ -149,13 +149,13 @@ return (mop.usDeviceID); /* Error setting time format? - Close opened device */ mgp.hwndCallback = (HWND) NULL; // None - mciSendCommand (mop.usDeviceID, MCI_CLOSE, MCI_WAIT, &mgp, 0); + mciSendCommand(mop.usDeviceID, MCI_CLOSE, MCI_WAIT, &mgp, 0); return (CD_ERROR); } /* Get CD Table Of Contents - Ready for MCI */ static int -SDL_SYS_CDGetTOC (SDL_CD * cdrom) +SDL_SYS_CDGetTOC(SDL_CD * cdrom) { MCI_TOC_PARMS mtp; MCI_STATUS_PARMS msp; @@ -181,19 +181,18 @@ cdrom->numtracks = SDL_MAX_TRACKS; } /* Alocate space for TOC data */ - mtr = - (MCI_TOC_REC *) SDL_malloc (cdrom->numtracks * sizeof (MCI_TOC_REC)); + mtr = (MCI_TOC_REC *) SDL_malloc(cdrom->numtracks * sizeof(MCI_TOC_REC)); if (mtr == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } /* Get TOC from CD */ mtp.pBuf = mtr; - mtp.ulBufSize = cdrom->numtracks * sizeof (MCI_TOC_REC); - if (LOUSHORT (mciSendCommand (cdrom->id, MCI_GETTOC, MCI_WAIT, &mtp, 0)) + mtp.ulBufSize = cdrom->numtracks * sizeof(MCI_TOC_REC); + if (LOUSHORT(mciSendCommand(cdrom->id, MCI_GETTOC, MCI_WAIT, &mtp, 0)) != MCIERR_SUCCESS) { - SDL_OutOfMemory (); - SDL_free (mtr); + SDL_OutOfMemory(); + SDL_free(mtr); return (CD_ERROR); } /* Fill SDL Tracks Structure */ @@ -209,7 +208,7 @@ (mciSendCommand (cdrom->id, MCI_STATUS, MCI_WAIT | MCI_TRACK | MCI_STATUS_ITEM, &msp, 0)) != MCIERR_SUCCESS) { - SDL_free (mtr); + SDL_free(mtr); return (CD_ERROR); } if (msp.ulReturn == MCI_CD_TRACK_AUDIO) @@ -218,18 +217,18 @@ cdrom->track[i].type = SDL_DATA_TRACK; /* Set Track Length - values from MCI are in MMTIMEs - 3000 MMTIME = 1 second */ cdrom->track[i].length = - FRAMESFROMMM ((mtr + i)->ulEndAddr - (mtr + i)->ulStartAddr); + FRAMESFROMMM((mtr + i)->ulEndAddr - (mtr + i)->ulStartAddr); /* Set Track Offset */ - cdrom->track[i].offset = FRAMESFROMMM ((mtr + i)->ulStartAddr); + cdrom->track[i].offset = FRAMESFROMMM((mtr + i)->ulStartAddr); } - SDL_free (mtr); + SDL_free(mtr); return (0); } /* Get CD-ROM status - Ready for MCI */ static CDstatus -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position) { CDstatus status; MCI_STATUS_PARMS msp; @@ -282,9 +281,9 @@ return (CD_ERROR); /* Convert from MSF (format selected in the Open process) to Frames (format that will be returned) */ *position = - MSF_TO_FRAMES (MSF_MINUTE (msp.ulReturn), - MSF_SECOND (msp.ulReturn), - MSF_FRAME (msp.ulReturn)); + MSF_TO_FRAMES(MSF_MINUTE(msp.ulReturn), + MSF_SECOND(msp.ulReturn), + MSF_FRAME(msp.ulReturn)); } else *position = 0; } @@ -293,7 +292,7 @@ /* Start play - Ready for MCI */ static int -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) { MCI_GENERIC_PARMS mgp; MCI_STATUS_PARMS msp; @@ -301,19 +300,19 @@ ULONG min, sec, frm; /* Start MSF */ - FRAMES_TO_MSF (start, &min, &sec, &frm); - MSF_MINUTE (mpp.ulFrom) = min; - MSF_SECOND (mpp.ulFrom) = sec; - MSF_FRAME (mpp.ulFrom) = frm; + FRAMES_TO_MSF(start, &min, &sec, &frm); + MSF_MINUTE(mpp.ulFrom) = min; + MSF_SECOND(mpp.ulFrom) = sec; + MSF_FRAME(mpp.ulFrom) = frm; /* End MSF */ - FRAMES_TO_MSF (start + length, &min, &sec, &frm); - MSF_MINUTE (mpp.ulTo) = min; - MSF_SECOND (mpp.ulTo) = sec; - MSF_FRAME (mpp.ulTo) = frm; + FRAMES_TO_MSF(start + length, &min, &sec, &frm); + MSF_MINUTE(mpp.ulTo) = min; + MSF_SECOND(mpp.ulTo) = sec; + MSF_FRAME(mpp.ulTo) = frm; #ifdef DEBUG_CDROM - fprintf (stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", - playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0, - playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1); + fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", + playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0, + playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1); #endif /* Verifies if it is paused first... and if it is, unpause before stopping it. */ msp.hwndCallback = (HWND) NULL; /* None */ @@ -326,13 +325,13 @@ 0)) == MCIERR_SUCCESS) { if (msp.ulReturn == MCI_MODE_PAUSE) { mgp.hwndCallback = (HWND) NULL; // None - mciSendCommand (cdrom->id, MCI_RESUME, 0, &mgp, 0); + mciSendCommand(cdrom->id, MCI_RESUME, 0, &mgp, 0); } } /* Now play it. */ mpp.hwndCallback = (HWND) NULL; // We do not want the info. temp if (LOUSHORT - (mciSendCommand (cdrom->id, MCI_PLAY, MCI_FROM | MCI_TO, &mpp, 0)) == + (mciSendCommand(cdrom->id, MCI_PLAY, MCI_FROM | MCI_TO, &mpp, 0)) == MCIERR_SUCCESS) return 0; return (CD_ERROR); @@ -340,12 +339,12 @@ /* Pause play - Ready for MCI */ static int -SDL_SYS_CDPause (SDL_CD * cdrom) +SDL_SYS_CDPause(SDL_CD * cdrom) { MCI_GENERIC_PARMS mgp; mgp.hwndCallback = (HWND) NULL; // None - if (LOUSHORT (mciSendCommand (cdrom->id, MCI_PAUSE, MCI_WAIT, &mgp, 0)) == + if (LOUSHORT(mciSendCommand(cdrom->id, MCI_PAUSE, MCI_WAIT, &mgp, 0)) == MCIERR_SUCCESS) return 0; return (CD_ERROR); @@ -353,12 +352,12 @@ /* Resume play - Ready for MCI */ static int -SDL_SYS_CDResume (SDL_CD * cdrom) +SDL_SYS_CDResume(SDL_CD * cdrom) { MCI_GENERIC_PARMS mgp; mgp.hwndCallback = (HWND) NULL; // None - if (LOUSHORT (mciSendCommand (cdrom->id, MCI_RESUME, MCI_WAIT, &mgp, 0)) + if (LOUSHORT(mciSendCommand(cdrom->id, MCI_RESUME, MCI_WAIT, &mgp, 0)) == MCIERR_SUCCESS) return 0; return (CD_ERROR); @@ -366,7 +365,7 @@ /* Stop play - Ready for MCI */ static int -SDL_SYS_CDStop (SDL_CD * cdrom) +SDL_SYS_CDStop(SDL_CD * cdrom) { MCI_GENERIC_PARMS mgp; MCI_STATUS_PARMS msp; @@ -382,12 +381,12 @@ 0)) == MCIERR_SUCCESS) { if (msp.ulReturn == MCI_MODE_PAUSE) { mgp.hwndCallback = (HWND) NULL; // None - mciSendCommand (cdrom->id, MCI_RESUME, 0, &mgp, 0); + mciSendCommand(cdrom->id, MCI_RESUME, 0, &mgp, 0); } } /* Now stops the media */ mgp.hwndCallback = (HWND) NULL; // None - if (LOUSHORT (mciSendCommand (cdrom->id, MCI_STOP, MCI_WAIT, &mgp, 0)) == + if (LOUSHORT(mciSendCommand(cdrom->id, MCI_STOP, MCI_WAIT, &mgp, 0)) == MCIERR_SUCCESS) return 0; return (CD_ERROR); @@ -395,7 +394,7 @@ /* Eject the CD-ROM - Ready for MCI */ static int -SDL_SYS_CDEject (SDL_CD * cdrom) +SDL_SYS_CDEject(SDL_CD * cdrom) { MCI_SET_PARMS msp; @@ -417,23 +416,23 @@ /* Close the CD-ROM handle - Ready for MCI */ static void -SDL_SYS_CDClose (SDL_CD * cdrom) +SDL_SYS_CDClose(SDL_CD * cdrom) { MCI_GENERIC_PARMS mgp; mgp.hwndCallback = (HWND) NULL; // None - mciSendCommand (cdrom->id, MCI_CLOSE, MCI_WAIT, &mgp, 0); + mciSendCommand(cdrom->id, MCI_CLOSE, MCI_WAIT, &mgp, 0); } /* Finalize CDROM Subsystem - Ready for MCI */ void -SDL_SYS_CDQuit (void) +SDL_SYS_CDQuit(void) { int i; if (SDL_numcds > 0) { for (i = 0; i < SDL_numcds; ++i) { - SDL_free (SDL_cdlist[i]); + SDL_free(SDL_cdlist[i]); } SDL_numcds = 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/osf/SDL_syscdrom.c --- a/src/cdrom/osf/SDL_syscdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/osf/SDL_syscdrom.c Mon May 29 04:04:35 2006 +0000 @@ -45,21 +45,21 @@ static dev_t SDL_cdmode[MAX_DRIVES]; /* The system-dependent CD control functions */ -static const char *SDL_SYS_CDName (int drive); -static int SDL_SYS_CDOpen (int drive); -static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); -static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); -static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); -static int SDL_SYS_CDPause (SDL_CD * cdrom); -static int SDL_SYS_CDResume (SDL_CD * cdrom); -static int SDL_SYS_CDStop (SDL_CD * cdrom); -static int SDL_SYS_CDEject (SDL_CD * cdrom); -static void SDL_SYS_CDClose (SDL_CD * cdrom); +static const char *SDL_SYS_CDName(int drive); +static int SDL_SYS_CDOpen(int drive); +static int SDL_SYS_CDGetTOC(SDL_CD * cdrom); +static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position); +static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length); +static int SDL_SYS_CDPause(SDL_CD * cdrom); +static int SDL_SYS_CDResume(SDL_CD * cdrom); +static int SDL_SYS_CDStop(SDL_CD * cdrom); +static int SDL_SYS_CDEject(SDL_CD * cdrom); +static void SDL_SYS_CDClose(SDL_CD * cdrom); /* Check a drive to see if it is a CD-ROM */ /* Caution!! Not tested. */ static int -CheckDrive (char *drive, struct stat *stbuf) +CheckDrive(char *drive, struct stat *stbuf) { int cdfd, is_cd = 0; struct mode_sel_sns_params msp; @@ -71,29 +71,29 @@ }; #endif - bzero (&msp, sizeof (msp)); - bzero (&inq, sizeof (inq)); + bzero(&msp, sizeof(msp)); + bzero(&inq, sizeof(inq)); /* If it doesn't exist, return -1 */ - if (stat (drive, stbuf) < 0) { + if (stat(drive, stbuf) < 0) { return (-1); } - if ((cdfd = open (drive, (O_RDWR | O_NDELAY), 0)) >= 0) { + if ((cdfd = open(drive, (O_RDWR | O_NDELAY), 0)) >= 0) { msp.msp_addr = (caddr_t) & inq; msp.msp_pgcode = 0; msp.msp_pgctrl = 0; - msp.msp_length = sizeof (inq); + msp.msp_length = sizeof(inq); msp.msp_setps = 0; - if (ioctl (cdfd, SCSI_GET_INQUIRY_DATA, &msp)) + if (ioctl(cdfd, SCSI_GET_INQUIRY_DATA, &msp)) return (0); #ifdef DEBUG_CDROM - fprintf (stderr, "Device Type: %s\n", devtype[inq.perfdt]); - fprintf (stderr, "Vendor: %.8s\n", inq.vndrid); - fprintf (stderr, "Product: %.8s\n", inq.prodid); - fprintf (stderr, "Revision: %.8s\n", inq.revlvl); + fprintf(stderr, "Device Type: %s\n", devtype[inq.perfdt]); + fprintf(stderr, "Vendor: %.8s\n", inq.vndrid); + fprintf(stderr, "Product: %.8s\n", inq.prodid); + fprintf(stderr, "Revision: %.8s\n", inq.revlvl); #endif if (inq.perfdt == DTYPE_RODIRECT) is_cd = 1; @@ -104,7 +104,7 @@ /* Add a CD-ROM drive to our list of valid drives */ static void -AddDrive (char *drive, struct stat *stbuf) +AddDrive(char *drive, struct stat *stbuf) { int i; @@ -116,8 +116,8 @@ for (i = 0; i < SDL_numcds; ++i) { if (stbuf->st_rdev == SDL_cdmode[i]) { #ifdef DEBUG_CDROM - fprintf (stderr, "Duplicate drive detected: %s == %s\n", - drive, SDL_cdlist[i]); + fprintf(stderr, "Duplicate drive detected: %s == %s\n", + drive, SDL_cdlist[i]); #endif return; } @@ -125,21 +125,21 @@ /* Add this drive to our list */ i = SDL_numcds; - SDL_cdlist[i] = SDL_strdup (drive); + SDL_cdlist[i] = SDL_strdup(drive); if (SDL_cdlist[i] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return; } SDL_cdmode[i] = stbuf->st_rdev; ++SDL_numcds; #ifdef DEBUG_CDROM - fprintf (stderr, "Added CD-ROM drive: %s\n", drive); + fprintf(stderr, "Added CD-ROM drive: %s\n", drive); #endif } } int -SDL_SYS_CDInit (void) +SDL_SYS_CDInit(void) { /* checklist: * @@ -178,21 +178,21 @@ /* Look in the environment for our CD-ROM drive list */ - SDLcdrom = SDL_getenv ("SDL_CDROM"); /* ':' separated list of devices */ + SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ if (SDLcdrom != NULL) { char *cdpath, *delim; - size_t len = SDL_strlen (SDLcdrom) + 1; - cdpath = SDL_stack_alloc (char, len); + size_t len = SDL_strlen(SDLcdrom) + 1; + cdpath = SDL_stack_alloc(char, len); if (cdpath != NULL) { - SDL_strlcpy (cdpath, SDLcdrom, len); + SDL_strlcpy(cdpath, SDLcdrom, len); SDLcdrom = cdpath; do { - delim = SDL_strchr (SDLcdrom, ':'); + delim = SDL_strchr(SDLcdrom, ':'); if (delim) { *delim++ = '\0'; } - if (CheckDrive (SDLcdrom, &stbuf) > 0) { - AddDrive (SDLcdrom, &stbuf); + if (CheckDrive(SDLcdrom, &stbuf) > 0) { + AddDrive(SDLcdrom, &stbuf); } if (delim) { SDLcdrom = delim; @@ -201,7 +201,7 @@ } } while (SDLcdrom); - SDL_stack_free (cdpath); + SDL_stack_free(cdpath); } /* If we found our drives, there's nothing left to do */ @@ -215,26 +215,26 @@ struct dirent *devent; int name_len; - devdir = opendir (checklist[i].dir); + devdir = opendir(checklist[i].dir); if (devdir) { - name_len = SDL_strlen (checklist[i].name); - while (devent = readdir (devdir)) + name_len = SDL_strlen(checklist[i].name); + while (devent = readdir(devdir)) if (SDL_memcmp (checklist[i].name, devent->d_name, name_len) == 0) if (devent->d_name[devent->d_namlen - 1] == 'c') { - SDL_snprintf (drive, SDL_arraysize (drive), - "%s/%s", checklist[i].dir, - devent->d_name); + SDL_snprintf(drive, SDL_arraysize(drive), + "%s/%s", checklist[i].dir, + devent->d_name); #ifdef DEBUG_CDROM - fprintf (stderr, "Try to add drive: %s\n", drive); + fprintf(stderr, "Try to add drive: %s\n", drive); #endif - if (CheckDrive (drive, &stbuf) > 0) - AddDrive (drive, &stbuf); + if (CheckDrive(drive, &stbuf) > 0) + AddDrive(drive, &stbuf); } - closedir (devdir); + closedir(devdir); } else { #ifdef DEBUG_CDROM - fprintf (stderr, "cannot open dir: %s\n", checklist[i].dir); + fprintf(stderr, "cannot open dir: %s\n", checklist[i].dir); #endif } } @@ -242,28 +242,28 @@ } static const char * -SDL_SYS_CDName (int drive) +SDL_SYS_CDName(int drive) { return (SDL_cdlist[drive]); } static int -SDL_SYS_CDOpen (int drive) +SDL_SYS_CDOpen(int drive) { /* O_RDWR: To use ioctl(fd, SCSI_STOP_UNIT) */ - return (open (SDL_cdlist[drive], (O_RDWR | O_NDELAY), 0)); + return (open(SDL_cdlist[drive], (O_RDWR | O_NDELAY), 0)); } static int -SDL_SYS_CDGetTOC (SDL_CD * cdrom) +SDL_SYS_CDGetTOC(SDL_CD * cdrom) { struct cd_toc toc; struct cd_toc_header hdr; struct cd_toc_entry *cdte; int i; int okay = 0; - if (ioctl (cdrom->id, CDROM_TOC_HEADER, &hdr)) { - fprintf (stderr, "ioctl error CDROM_TOC_HEADER\n"); + if (ioctl(cdrom->id, CDROM_TOC_HEADER, &hdr)) { + fprintf(stderr, "ioctl error CDROM_TOC_HEADER\n"); return -1; } cdrom->numtracks = hdr.th_ending_track - hdr.th_starting_track + 1; @@ -271,28 +271,28 @@ cdrom->numtracks = SDL_MAX_TRACKS; } #ifdef DEBUG_CDROM - fprintf (stderr, "hdr.th_data_len1 = %d\n", hdr.th_data_len1); - fprintf (stderr, "hdr.th_data_len0 = %d\n", hdr.th_data_len0); - fprintf (stderr, "hdr.th_starting_track = %d\n", hdr.th_starting_track); - fprintf (stderr, "hdr.th_ending_track = %d\n", hdr.th_ending_track); - fprintf (stderr, "cdrom->numtracks = %d\n", cdrom->numtracks); + fprintf(stderr, "hdr.th_data_len1 = %d\n", hdr.th_data_len1); + fprintf(stderr, "hdr.th_data_len0 = %d\n", hdr.th_data_len0); + fprintf(stderr, "hdr.th_starting_track = %d\n", hdr.th_starting_track); + fprintf(stderr, "hdr.th_ending_track = %d\n", hdr.th_ending_track); + fprintf(stderr, "cdrom->numtracks = %d\n", cdrom->numtracks); #endif toc.toc_address_format = CDROM_LBA_FORMAT; toc.toc_starting_track = 0; toc.toc_alloc_length = (hdr.th_data_len1 << 8) + - hdr.th_data_len0 + sizeof (hdr); - if ((toc.toc_buffer = alloca (toc.toc_alloc_length)) == NULL) { - fprintf (stderr, "cannot allocate toc.toc_buffer\n"); + hdr.th_data_len0 + sizeof(hdr); + if ((toc.toc_buffer = alloca(toc.toc_alloc_length)) == NULL) { + fprintf(stderr, "cannot allocate toc.toc_buffer\n"); return -1; } - bzero (toc.toc_buffer, toc.toc_alloc_length); - if (ioctl (cdrom->id, CDROM_TOC_ENTRYS, &toc)) { - fprintf (stderr, "ioctl error CDROM_TOC_ENTRYS\n"); + bzero(toc.toc_buffer, toc.toc_alloc_length); + if (ioctl(cdrom->id, CDROM_TOC_ENTRYS, &toc)) { + fprintf(stderr, "ioctl error CDROM_TOC_ENTRYS\n"); return -1; } - cdte = (struct cd_toc_entry *) ((char *) toc.toc_buffer + sizeof (hdr)); + cdte = (struct cd_toc_entry *) ((char *) toc.toc_buffer + sizeof(hdr)); for (i = 0; i <= cdrom->numtracks; ++i) { if (i == cdrom->numtracks) { cdrom->track[i].id = 0xAA;; @@ -313,15 +313,15 @@ } #ifdef DEBUG_CDROM for (i = 0; i <= cdrom->numtracks; i++) { - fprintf (stderr, "toc_entry[%d].te_track_number = %d\n", - i, cdte[i].te_track_number); - fprintf (stderr, "cdrom->track[%d].id = %d\n", i, cdrom->track[i].id); - fprintf (stderr, "cdrom->track[%d].type = %x\n", i, - cdrom->track[i].type); - fprintf (stderr, "cdrom->track[%d].offset = %d\n", i, - cdrom->track[i].offset); - fprintf (stderr, "cdrom->track[%d].length = %d\n", i, - cdrom->track[i].length); + fprintf(stderr, "toc_entry[%d].te_track_number = %d\n", + i, cdte[i].te_track_number); + fprintf(stderr, "cdrom->track[%d].id = %d\n", i, cdrom->track[i].id); + fprintf(stderr, "cdrom->track[%d].type = %x\n", i, + cdrom->track[i].type); + fprintf(stderr, "cdrom->track[%d].offset = %d\n", i, + cdrom->track[i].offset); + fprintf(stderr, "cdrom->track[%d].length = %d\n", i, + cdrom->track[i].length); } #endif if (i == (cdrom->numtracks + 1)) { @@ -333,7 +333,7 @@ /* Get CD-ROM status */ static CDstatus -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position) { CDstatus status; struct cd_sub_channel sc; @@ -342,11 +342,11 @@ sc.sch_address_format = CDROM_LBA_FORMAT; sc.sch_data_format = CDROM_CURRENT_POSITION; sc.sch_track_number = 0; - sc.sch_alloc_length = sizeof (scd); + sc.sch_alloc_length = sizeof(scd); sc.sch_buffer = (caddr_t) & scd; - if (ioctl (cdrom->id, CDROM_READ_SUBCHANNEL, &sc)) { + if (ioctl(cdrom->id, CDROM_READ_SUBCHANNEL, &sc)) { status = CD_ERROR; - fprintf (stderr, "ioctl error CDROM_READ_SUBCHANNEL \n"); + fprintf(stderr, "ioctl error CDROM_READ_SUBCHANNEL \n"); } else { switch (scd.scd_header.sh_audio_status) { case AS_AUDIO_INVALID: @@ -372,8 +372,8 @@ break; } #ifdef DEBUG_CDROM - fprintf (stderr, "scd.scd_header.sh_audio_status = %x\n", - scd.scd_header.sh_audio_status); + fprintf(stderr, "scd.scd_header.sh_audio_status = %x\n", + scd.scd_header.sh_audio_status); #endif } if (position) { @@ -393,7 +393,7 @@ /* Start play */ static int -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) { /* * Play MSF @@ -401,61 +401,61 @@ struct cd_play_audio_msf msf; int end; - bzero (&msf, sizeof (msf)); + bzero(&msf, sizeof(msf)); end = start + length; - FRAMES_TO_MSF (start + 150, /* LBA = 4500*M + 75*S + F - 150 */ - &msf.msf_starting_M_unit, - &msf.msf_starting_S_unit, &msf.msf_starting_F_unit); - FRAMES_TO_MSF (end + 150, /* LBA = 4500*M + 75*S + F - 150 */ - &msf.msf_ending_M_unit, - &msf.msf_ending_S_unit, &msf.msf_ending_F_unit); + FRAMES_TO_MSF(start + 150, /* LBA = 4500*M + 75*S + F - 150 */ + &msf.msf_starting_M_unit, + &msf.msf_starting_S_unit, &msf.msf_starting_F_unit); + FRAMES_TO_MSF(end + 150, /* LBA = 4500*M + 75*S + F - 150 */ + &msf.msf_ending_M_unit, + &msf.msf_ending_S_unit, &msf.msf_ending_F_unit); - return (ioctl (cdrom->id, CDROM_PLAY_AUDIO_MSF, &msf)); + return (ioctl(cdrom->id, CDROM_PLAY_AUDIO_MSF, &msf)); } /* Pause play */ static int -SDL_SYS_CDPause (SDL_CD * cdrom) +SDL_SYS_CDPause(SDL_CD * cdrom) { - return (ioctl (cdrom->id, CDROM_PAUSE_PLAY)); + return (ioctl(cdrom->id, CDROM_PAUSE_PLAY)); } /* Resume play */ static int -SDL_SYS_CDResume (SDL_CD * cdrom) +SDL_SYS_CDResume(SDL_CD * cdrom) { - return (ioctl (cdrom->id, CDROM_RESUME_PLAY)); + return (ioctl(cdrom->id, CDROM_RESUME_PLAY)); } /* Stop play */ static int -SDL_SYS_CDStop (SDL_CD * cdrom) +SDL_SYS_CDStop(SDL_CD * cdrom) { - return (ioctl (cdrom->id, SCSI_STOP_UNIT)); + return (ioctl(cdrom->id, SCSI_STOP_UNIT)); } /* Eject the CD-ROM */ static int -SDL_SYS_CDEject (SDL_CD * cdrom) +SDL_SYS_CDEject(SDL_CD * cdrom) { - return (ioctl (cdrom->id, CDROM_EJECT_CADDY)); + return (ioctl(cdrom->id, CDROM_EJECT_CADDY)); } /* Close the CD-ROM handle */ static void -SDL_SYS_CDClose (SDL_CD * cdrom) +SDL_SYS_CDClose(SDL_CD * cdrom) { - close (cdrom->id); + close(cdrom->id); } void -SDL_SYS_CDQuit (void) +SDL_SYS_CDQuit(void) { int i; if (SDL_numcds > 0) { for (i = 0; i < SDL_numcds; ++i) { - SDL_free (SDL_cdlist[i]); + SDL_free(SDL_cdlist[i]); } SDL_numcds = 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/qnx/SDL_syscdrom.c --- a/src/cdrom/qnx/SDL_syscdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/qnx/SDL_syscdrom.c Mon May 29 04:04:35 2006 +0000 @@ -49,20 +49,20 @@ static int SDL_cdopen[MAX_DRIVES]; /* The system-dependent CD control functions */ -static const char *SDL_SYS_CDName (int drive); -static int SDL_SYS_CDOpen (int drive); -static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); -static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); -static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); -static int SDL_SYS_CDPause (SDL_CD * cdrom); -static int SDL_SYS_CDResume (SDL_CD * cdrom); -static int SDL_SYS_CDStop (SDL_CD * cdrom); -static int SDL_SYS_CDEject (SDL_CD * cdrom); -static void SDL_SYS_CDClose (SDL_CD * cdrom); +static const char *SDL_SYS_CDName(int drive); +static int SDL_SYS_CDOpen(int drive); +static int SDL_SYS_CDGetTOC(SDL_CD * cdrom); +static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position); +static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length); +static int SDL_SYS_CDPause(SDL_CD * cdrom); +static int SDL_SYS_CDResume(SDL_CD * cdrom); +static int SDL_SYS_CDStop(SDL_CD * cdrom); +static int SDL_SYS_CDEject(SDL_CD * cdrom); +static void SDL_SYS_CDClose(SDL_CD * cdrom); /* Check a drive to see if it is a CD-ROM */ static int -CheckDrive (char *drive, struct stat *stbuf) +CheckDrive(char *drive, struct stat *stbuf) { int is_cd, cdfd; cam_devinfo_t dinfo; @@ -73,19 +73,19 @@ int cdb10; /* If it doesn't exist, return -1 */ - if (stat (drive, stbuf) < 0) { + if (stat(drive, stbuf) < 0) { return (-1); } /* If it does exist, verify that it's an available CD-ROM */ is_cd = 0; - if (S_ISCHR (stbuf->st_mode) || S_ISBLK (stbuf->st_mode)) { - cdfd = open (drive, QNX_CD_OPENMODE); + if (S_ISCHR(stbuf->st_mode) || S_ISBLK(stbuf->st_mode)) { + cdfd = open(drive, QNX_CD_OPENMODE); if (cdfd >= 0) { devctlret = - devctl (cdfd, DCMD_CAM_DEVINFO, &dinfo, - sizeof (cam_devinfo_t), NULL); + devctl(cdfd, DCMD_CAM_DEVINFO, &dinfo, + sizeof(cam_devinfo_t), NULL); if (devctlret == EOK) { atapi = dinfo.flags & DEV_ATAPI; @@ -98,7 +98,7 @@ } } - close (cdfd); + close(cdfd); } } return (is_cd); @@ -106,7 +106,7 @@ /* Add a CD-ROM drive to our list of valid drives */ static void -AddDrive (char *drive, struct stat *stbuf) +AddDrive(char *drive, struct stat *stbuf) { int i; @@ -123,9 +123,9 @@ /* Add this drive to our list */ i = SDL_numcds; - SDL_cdlist[i] = SDL_strdup (drive); + SDL_cdlist[i] = SDL_strdup(drive); if (SDL_cdlist[i] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return; } SDL_cdmode[i] = stbuf->st_rdev; @@ -134,7 +134,7 @@ } int -SDL_SYS_CDInit (void) +SDL_SYS_CDInit(void) { /* checklist: /dev/cdrom, /dev/cd?, /dev/scd? */ static char *checklist[] = @@ -163,21 +163,21 @@ } /* Look in the environment for our CD-ROM drive list */ - SDLcdrom = SDL_getenv ("SDL_CDROM"); /* ':' separated list of devices */ + SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ if (SDLcdrom != NULL) { char *cdpath, *delim; - size_t len = SDL_strlen (SDLcdrom) + 1; - cdpath = SDL_stack_alloc (char, len); + size_t len = SDL_strlen(SDLcdrom) + 1; + cdpath = SDL_stack_alloc(char, len); if (cdpath != NULL) { - SDL_strlcpy (cdpath, SDLcdrom, len); + SDL_strlcpy(cdpath, SDLcdrom, len); SDLcdrom = cdpath; do { - delim = SDL_strchr (SDLcdrom, ':'); + delim = SDL_strchr(SDLcdrom, ':'); if (delim) { *delim++ = '\0'; } - if (CheckDrive (SDLcdrom, &stbuf) > 0) { - AddDrive (SDLcdrom, &stbuf); + if (CheckDrive(SDLcdrom, &stbuf) > 0) { + AddDrive(SDLcdrom, &stbuf); } if (delim) { SDLcdrom = delim; @@ -186,7 +186,7 @@ } } while (SDLcdrom); - SDL_stack_free (cdpath); + SDL_stack_free(cdpath); } /* If we found our drives, there's nothing left to do */ @@ -202,16 +202,16 @@ exists = 1; for (j = checklist[i][1]; exists; ++j) { - SDL_snprintf (drive, SDL_arraysize (drive), "/dev/%s", - &checklist[i][3]); - insert = SDL_strchr (drive, '?'); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", + &checklist[i][3]); + insert = SDL_strchr(drive, '?'); if (insert != NULL) { *insert = j; } - switch (CheckDrive (drive, &stbuf)) { + switch (CheckDrive(drive, &stbuf)) { /* Drive exists and is a CD-ROM */ case 1: - AddDrive (drive, &stbuf); + AddDrive(drive, &stbuf); break; /* Drive exists, but isn't a CD-ROM */ case 0: @@ -223,10 +223,10 @@ } } } else { - SDL_snprintf (drive, SDL_arraysize (drive), "/dev/%s", - checklist[i]); - if (CheckDrive (drive, &stbuf) > 0) { - AddDrive (drive, &stbuf); + SDL_snprintf(drive, SDL_arraysize(drive), "/dev/%s", + checklist[i]); + if (CheckDrive(drive, &stbuf) > 0) { + AddDrive(drive, &stbuf); } } } @@ -234,17 +234,17 @@ } static const char * -SDL_SYS_CDName (int drive) +SDL_SYS_CDName(int drive) { return (SDL_cdlist[drive]); } static int -SDL_SYS_CDOpen (int drive) +SDL_SYS_CDOpen(int drive) { int handle; - handle = open (SDL_cdlist[drive], QNX_CD_OPENMODE); + handle = open(SDL_cdlist[drive], QNX_CD_OPENMODE); if (handle > 0) { SDL_cdopen[drive] = handle; @@ -254,13 +254,13 @@ } static int -SDL_SYS_CDGetTOC (SDL_CD * cdrom) +SDL_SYS_CDGetTOC(SDL_CD * cdrom) { cdrom_read_toc_t toc; int i, okay; okay = 0; - if (devctl (cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof (toc), NULL) == + if (devctl(cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof(toc), NULL) == 0) { cdrom->numtracks = toc.last_track - toc.first_track + 1; if (cdrom->numtracks > SDL_MAX_TRACKS) { @@ -292,7 +292,7 @@ /* Get CD-ROM status */ static CDstatus -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position) { CDstatus status; @@ -308,8 +308,8 @@ /* check media presence before read subchannel call, some cdroms can lockups */ /* if no media, while calling read subchannel functions. */ devctlret = - devctl (cdrom->id, DCMD_CAM_DEVINFO, &dinfo, sizeof (cam_devinfo_t), - NULL); + devctl(cdrom->id, DCMD_CAM_DEVINFO, &dinfo, sizeof(cam_devinfo_t), + NULL); if (devctlret == EOK) { if ((dinfo.flags & DEV_NO_MEDIA) != 0) { @@ -323,13 +323,13 @@ /* if media exists, then do other stuff */ - SDL_memset (&info, 0x00, sizeof (info)); + SDL_memset(&info, 0x00, sizeof(info)); info.subch_command.data_format = CDROM_SUBCH_CURRENT_POSITION; do { devctlret = - devctl (cdrom->id, DCMD_CAM_CDROMSUBCHNL, &info, sizeof (info), - NULL); + devctl(cdrom->id, DCMD_CAM_CDROMSUBCHNL, &info, sizeof(info), + NULL); if (devctlret == EIO) { /* big workaround for media change, handle is unusable after that, that bug was found in QNX 6.2, 6.2.1 is not released yet. */ @@ -344,8 +344,8 @@ /* that cannot happen, but ... */ break; } - close (cdrom->id); - cdrom->id = open (SDL_cdlist[drive], QNX_CD_OPENMODE); + close(cdrom->id); + cdrom->id = open(SDL_cdlist[drive], QNX_CD_OPENMODE); devctlret = EAGAIN; } if (devctlret == EAGAIN) { @@ -372,7 +372,7 @@ case CDROM_AUDIO_NO_STATUS: /* Try to determine if there's a CD available */ if (devctl - (cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof (toc), + (cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof(toc), NULL) == 0) status = CD_STOPPED; else @@ -401,9 +401,9 @@ if (position) { if (status == CD_PLAYING || (status == CD_PAUSED)) { *position = - MSF_TO_FRAMES (info.current_position.addr.msf.minute, - info.current_position.addr.msf.second, - info.current_position.addr.msf.frame); + MSF_TO_FRAMES(info.current_position.addr.msf.minute, + info.current_position.addr.msf.second, + info.current_position.addr.msf.frame); } else { *position = 0; } @@ -414,17 +414,17 @@ /* Start play */ static int -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) { cdrom_playmsf_t playtime; - FRAMES_TO_MSF (start, &playtime.start_minute, &playtime.start_second, - &playtime.start_frame); - FRAMES_TO_MSF (start + length, &playtime.end_minute, &playtime.end_second, - &playtime.end_frame); + FRAMES_TO_MSF(start, &playtime.start_minute, &playtime.start_second, + &playtime.start_frame); + FRAMES_TO_MSF(start + length, &playtime.end_minute, &playtime.end_second, + &playtime.end_frame); if (devctl - (cdrom->id, DCMD_CAM_CDROMPLAYMSF, &playtime, sizeof (playtime), + (cdrom->id, DCMD_CAM_CDROMPLAYMSF, &playtime, sizeof(playtime), NULL) != 0) { return -1; } else { @@ -434,9 +434,9 @@ /* Pause play */ static int -SDL_SYS_CDPause (SDL_CD * cdrom) +SDL_SYS_CDPause(SDL_CD * cdrom) { - if (devctl (cdrom->id, DCMD_CAM_CDROMPAUSE, NULL, 0, NULL) != 0) { + if (devctl(cdrom->id, DCMD_CAM_CDROMPAUSE, NULL, 0, NULL) != 0) { return -1; } else { return 0; @@ -445,9 +445,9 @@ /* Resume play */ static int -SDL_SYS_CDResume (SDL_CD * cdrom) +SDL_SYS_CDResume(SDL_CD * cdrom) { - if (devctl (cdrom->id, DCMD_CAM_CDROMRESUME, NULL, 0, NULL) != 0) { + if (devctl(cdrom->id, DCMD_CAM_CDROMRESUME, NULL, 0, NULL) != 0) { return -1; } else { return 0; @@ -456,9 +456,9 @@ /* Stop play */ static int -SDL_SYS_CDStop (SDL_CD * cdrom) +SDL_SYS_CDStop(SDL_CD * cdrom) { - if (devctl (cdrom->id, DCMD_CAM_CDROMSTOP, NULL, 0, NULL) != 0) { + if (devctl(cdrom->id, DCMD_CAM_CDROMSTOP, NULL, 0, NULL) != 0) { return -1; } else { return 0; @@ -467,9 +467,9 @@ /* Eject the CD-ROM */ static int -SDL_SYS_CDEject (SDL_CD * cdrom) +SDL_SYS_CDEject(SDL_CD * cdrom) { - if (devctl (cdrom->id, DCMD_CAM_EJECT_MEDIA, NULL, 0, NULL) != 0) { + if (devctl(cdrom->id, DCMD_CAM_EJECT_MEDIA, NULL, 0, NULL) != 0) { return -1; } else { return 0; @@ -478,7 +478,7 @@ /* Close the CD-ROM handle */ static void -SDL_SYS_CDClose (SDL_CD * cdrom) +SDL_SYS_CDClose(SDL_CD * cdrom) { int i; @@ -489,17 +489,17 @@ } } - close (cdrom->id); + close(cdrom->id); } void -SDL_SYS_CDQuit (void) +SDL_SYS_CDQuit(void) { int i; if (SDL_numcds > 0) { for (i = 0; i < SDL_numcds; ++i) { - SDL_free (SDL_cdlist[i]); + SDL_free(SDL_cdlist[i]); } SDL_numcds = 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/cdrom/win32/SDL_syscdrom.c --- a/src/cdrom/win32/SDL_syscdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cdrom/win32/SDL_syscdrom.c Mon May 29 04:04:35 2006 +0000 @@ -47,41 +47,41 @@ static int SDL_CD_end_position; /* The system-dependent CD control functions */ -static const char *SDL_SYS_CDName (int drive); -static int SDL_SYS_CDOpen (int drive); -static int SDL_SYS_CDGetTOC (SDL_CD * cdrom); -static CDstatus SDL_SYS_CDStatus (SDL_CD * cdrom, int *position); -static int SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length); -static int SDL_SYS_CDPause (SDL_CD * cdrom); -static int SDL_SYS_CDResume (SDL_CD * cdrom); -static int SDL_SYS_CDStop (SDL_CD * cdrom); -static int SDL_SYS_CDEject (SDL_CD * cdrom); -static void SDL_SYS_CDClose (SDL_CD * cdrom); +static const char *SDL_SYS_CDName(int drive); +static int SDL_SYS_CDOpen(int drive); +static int SDL_SYS_CDGetTOC(SDL_CD * cdrom); +static CDstatus SDL_SYS_CDStatus(SDL_CD * cdrom, int *position); +static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length); +static int SDL_SYS_CDPause(SDL_CD * cdrom); +static int SDL_SYS_CDResume(SDL_CD * cdrom); +static int SDL_SYS_CDStop(SDL_CD * cdrom); +static int SDL_SYS_CDEject(SDL_CD * cdrom); +static void SDL_SYS_CDClose(SDL_CD * cdrom); /* Add a CD-ROM drive to our list of valid drives */ static void -AddDrive (char *drive) +AddDrive(char *drive) { int i; if (SDL_numcds < MAX_DRIVES) { /* Add this drive to our list */ i = SDL_numcds; - SDL_cdlist[i] = SDL_strdup (drive); + SDL_cdlist[i] = SDL_strdup(drive); if (SDL_cdlist[i] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return; } ++SDL_numcds; #ifdef CDROM_DEBUG - fprintf (stderr, "Added CD-ROM drive: %s\n", drive); + fprintf(stderr, "Added CD-ROM drive: %s\n", drive); #endif } } int -SDL_SYS_CDInit (void) +SDL_SYS_CDInit(void) { /* checklist: Drive 'A' - 'Z' */ int i; @@ -101,39 +101,39 @@ /* Scan the system for CD-ROM drives */ for (i = 'A'; i <= 'Z'; ++i) { - SDL_snprintf (drive, SDL_arraysize (drive), "%c:\\", i); - if (GetDriveType (drive) == DRIVE_CDROM) { - AddDrive (drive); + SDL_snprintf(drive, SDL_arraysize(drive), "%c:\\", i); + if (GetDriveType(drive) == DRIVE_CDROM) { + AddDrive(drive); } } - SDL_memset (SDL_mciID, 0, sizeof (SDL_mciID)); + SDL_memset(SDL_mciID, 0, sizeof(SDL_mciID)); return (0); } /* General ioctl() CD-ROM command function */ static int -SDL_SYS_CDioctl (int id, UINT msg, DWORD flags, void *arg) +SDL_SYS_CDioctl(int id, UINT msg, DWORD flags, void *arg) { MCIERROR mci_error; - mci_error = mciSendCommand (SDL_mciID[id], msg, flags, (DWORD_PTR) arg); + mci_error = mciSendCommand(SDL_mciID[id], msg, flags, (DWORD_PTR) arg); if (mci_error) { char error[256]; - mciGetErrorString (mci_error, error, 256); - SDL_SetError ("mciSendCommand() error: %s", error); + mciGetErrorString(mci_error, error, 256); + SDL_SetError("mciSendCommand() error: %s", error); } return (!mci_error ? 0 : -1); } static const char * -SDL_SYS_CDName (int drive) +SDL_SYS_CDName(int drive) { return (SDL_cdlist[drive]); } static int -SDL_SYS_CDOpen (int drive) +SDL_SYS_CDOpen(int drive) { MCI_OPEN_PARMS mci_open; MCI_SET_PARMS mci_set; @@ -149,9 +149,9 @@ flags = (MCI_OPEN_TYPE | MCI_OPEN_SHAREABLE | MCI_OPEN_TYPE_ID | MCI_OPEN_ELEMENT); - if (SDL_SYS_CDioctl (0, MCI_OPEN, flags, &mci_open) < 0) { + if (SDL_SYS_CDioctl(0, MCI_OPEN, flags, &mci_open) < 0) { flags &= ~MCI_OPEN_SHAREABLE; - if (SDL_SYS_CDioctl (0, MCI_OPEN, flags, &mci_open) < 0) { + if (SDL_SYS_CDioctl(0, MCI_OPEN, flags, &mci_open) < 0) { return (-1); } } @@ -159,7 +159,7 @@ /* Set the minute-second-frame time format */ mci_set.dwTimeFormat = MCI_FORMAT_MSF; - SDL_SYS_CDioctl (drive, MCI_SET, MCI_SET_TIME_FORMAT, &mci_set); + SDL_SYS_CDioctl(drive, MCI_SET, MCI_SET_TIME_FORMAT, &mci_set); #ifdef BROKEN_MCI_PAUSE SDL_paused[drive] = 0; @@ -168,7 +168,7 @@ } static int -SDL_SYS_CDGetTOC (SDL_CD * cdrom) +SDL_SYS_CDGetTOC(SDL_CD * cdrom) { MCI_STATUS_PARMS mci_status; int i, okay; @@ -177,7 +177,7 @@ okay = 0; mci_status.dwItem = MCI_STATUS_NUMBER_OF_TRACKS; flags = MCI_STATUS_ITEM | MCI_WAIT; - if (SDL_SYS_CDioctl (cdrom->id, MCI_STATUS, flags, &mci_status) == 0) { + if (SDL_SYS_CDioctl(cdrom->id, MCI_STATUS, flags, &mci_status) == 0) { cdrom->numtracks = mci_status.dwReturn; if (cdrom->numtracks > SDL_MAX_TRACKS) { cdrom->numtracks = SDL_MAX_TRACKS; @@ -189,8 +189,8 @@ mci_status.dwTrack = cdrom->track[i].id; #ifdef MCI_CDA_STATUS_TYPE_TRACK mci_status.dwItem = MCI_CDA_STATUS_TYPE_TRACK; - if (SDL_SYS_CDioctl (cdrom->id, MCI_STATUS, flags, - &mci_status) < 0) { + if (SDL_SYS_CDioctl(cdrom->id, MCI_STATUS, flags, + &mci_status) < 0) { break; } if (mci_status.dwReturn == MCI_CDA_TRACK_AUDIO) { @@ -202,14 +202,14 @@ cdrom->track[i].type = SDL_AUDIO_TRACK; #endif mci_status.dwItem = MCI_STATUS_POSITION; - if (SDL_SYS_CDioctl (cdrom->id, MCI_STATUS, flags, - &mci_status) < 0) { + if (SDL_SYS_CDioctl(cdrom->id, MCI_STATUS, flags, + &mci_status) < 0) { break; } cdrom->track[i].offset = - MSF_TO_FRAMES (MCI_MSF_MINUTE (mci_status.dwReturn), - MCI_MSF_SECOND (mci_status.dwReturn), - MCI_MSF_FRAME (mci_status.dwReturn)); + MSF_TO_FRAMES(MCI_MSF_MINUTE(mci_status.dwReturn), + MCI_MSF_SECOND(mci_status.dwReturn), + MCI_MSF_FRAME(mci_status.dwReturn)); cdrom->track[i].length = 0; if (i > 0) { cdrom->track[i - 1].length = @@ -219,12 +219,12 @@ if (i == cdrom->numtracks) { mci_status.dwTrack = cdrom->track[i - 1].id; mci_status.dwItem = MCI_STATUS_LENGTH; - if (SDL_SYS_CDioctl (cdrom->id, MCI_STATUS, flags, - &mci_status) == 0) { + if (SDL_SYS_CDioctl(cdrom->id, MCI_STATUS, flags, + &mci_status) == 0) { cdrom->track[i - 1].length = - MSF_TO_FRAMES (MCI_MSF_MINUTE (mci_status.dwReturn), - MCI_MSF_SECOND (mci_status.dwReturn), - MCI_MSF_FRAME (mci_status.dwReturn)); + MSF_TO_FRAMES(MCI_MSF_MINUTE(mci_status.dwReturn), + MCI_MSF_SECOND(mci_status.dwReturn), + MCI_MSF_FRAME(mci_status.dwReturn)); /* compute lead-out offset */ cdrom->track[i].offset = cdrom->track[i - 1].offset + cdrom->track[i - 1].length; @@ -238,7 +238,7 @@ /* Get CD-ROM status */ static CDstatus -SDL_SYS_CDStatus (SDL_CD * cdrom, int *position) +SDL_SYS_CDStatus(SDL_CD * cdrom, int *position) { CDstatus status; MCI_STATUS_PARMS mci_status; @@ -246,7 +246,7 @@ flags = MCI_STATUS_ITEM | MCI_WAIT; mci_status.dwItem = MCI_STATUS_MODE; - if (SDL_SYS_CDioctl (cdrom->id, MCI_STATUS, flags, &mci_status) < 0) { + if (SDL_SYS_CDioctl(cdrom->id, MCI_STATUS, flags, &mci_status) < 0) { status = CD_ERROR; } else { switch (mci_status.dwReturn) { @@ -287,12 +287,12 @@ if (position) { if (status == CD_PLAYING || (status == CD_PAUSED)) { mci_status.dwItem = MCI_STATUS_POSITION; - if (SDL_SYS_CDioctl (cdrom->id, MCI_STATUS, flags, - &mci_status) == 0) { + if (SDL_SYS_CDioctl(cdrom->id, MCI_STATUS, flags, + &mci_status) == 0) { *position = - MSF_TO_FRAMES (MCI_MSF_MINUTE (mci_status.dwReturn), - MCI_MSF_SECOND (mci_status.dwReturn), - MCI_MSF_FRAME (mci_status.dwReturn)); + MSF_TO_FRAMES(MCI_MSF_MINUTE(mci_status.dwReturn), + MCI_MSF_SECOND(mci_status.dwReturn), + MCI_MSF_FRAME(mci_status.dwReturn)); } else { *position = 0; } @@ -305,7 +305,7 @@ /* Start play */ static int -SDL_SYS_CDPlay (SDL_CD * cdrom, int start, int length) +SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) { MCI_PLAY_PARMS mci_play; int m, s, f; @@ -313,27 +313,27 @@ flags = MCI_FROM | MCI_TO | MCI_NOTIFY; mci_play.dwCallback = 0; - FRAMES_TO_MSF (start, &m, &s, &f); - mci_play.dwFrom = MCI_MAKE_MSF (m, s, f); - FRAMES_TO_MSF (start + length, &m, &s, &f); - mci_play.dwTo = MCI_MAKE_MSF (m, s, f); + FRAMES_TO_MSF(start, &m, &s, &f); + mci_play.dwFrom = MCI_MAKE_MSF(m, s, f); + FRAMES_TO_MSF(start + length, &m, &s, &f); + mci_play.dwTo = MCI_MAKE_MSF(m, s, f); SDL_CD_end_position = mci_play.dwTo; - return (SDL_SYS_CDioctl (cdrom->id, MCI_PLAY, flags, &mci_play)); + return (SDL_SYS_CDioctl(cdrom->id, MCI_PLAY, flags, &mci_play)); } /* Pause play */ static int -SDL_SYS_CDPause (SDL_CD * cdrom) +SDL_SYS_CDPause(SDL_CD * cdrom) { #ifdef BROKEN_MCI_PAUSE SDL_paused[cdrom->id] = 1; #endif - return (SDL_SYS_CDioctl (cdrom->id, MCI_PAUSE, MCI_WAIT, NULL)); + return (SDL_SYS_CDioctl(cdrom->id, MCI_PAUSE, MCI_WAIT, NULL)); } /* Resume play */ static int -SDL_SYS_CDResume (SDL_CD * cdrom) +SDL_SYS_CDResume(SDL_CD * cdrom) { #ifdef BROKEN_MCI_PAUSE MCI_STATUS_PARMS mci_status; @@ -344,53 +344,53 @@ /* Play from the current play position to the end position set earlier */ flags = MCI_STATUS_ITEM | MCI_WAIT; mci_status.dwItem = MCI_STATUS_POSITION; - if (SDL_SYS_CDioctl (cdrom->id, MCI_STATUS, flags, &mci_status) == 0) { + if (SDL_SYS_CDioctl(cdrom->id, MCI_STATUS, flags, &mci_status) == 0) { MCI_PLAY_PARMS mci_play; flags = MCI_FROM | MCI_TO | MCI_NOTIFY; mci_play.dwCallback = 0; mci_play.dwFrom = mci_status.dwReturn; mci_play.dwTo = SDL_CD_end_position; - if (SDL_SYS_CDioctl (cdrom->id, MCI_PLAY, flags, &mci_play) == 0) { + if (SDL_SYS_CDioctl(cdrom->id, MCI_PLAY, flags, &mci_play) == 0) { okay = 1; SDL_paused[cdrom->id] = 0; } } return (okay ? 0 : -1); #else - return (SDL_SYS_CDioctl (cdrom->id, MCI_RESUME, MCI_WAIT, NULL)); + return (SDL_SYS_CDioctl(cdrom->id, MCI_RESUME, MCI_WAIT, NULL)); #endif /* BROKEN_MCI_PAUSE */ } /* Stop play */ static int -SDL_SYS_CDStop (SDL_CD * cdrom) +SDL_SYS_CDStop(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, MCI_STOP, MCI_WAIT, NULL)); + return (SDL_SYS_CDioctl(cdrom->id, MCI_STOP, MCI_WAIT, NULL)); } /* Eject the CD-ROM */ static int -SDL_SYS_CDEject (SDL_CD * cdrom) +SDL_SYS_CDEject(SDL_CD * cdrom) { - return (SDL_SYS_CDioctl (cdrom->id, MCI_SET, MCI_SET_DOOR_OPEN, NULL)); + return (SDL_SYS_CDioctl(cdrom->id, MCI_SET, MCI_SET_DOOR_OPEN, NULL)); } /* Close the CD-ROM handle */ static void -SDL_SYS_CDClose (SDL_CD * cdrom) +SDL_SYS_CDClose(SDL_CD * cdrom) { - SDL_SYS_CDioctl (cdrom->id, MCI_CLOSE, MCI_WAIT, NULL); + SDL_SYS_CDioctl(cdrom->id, MCI_CLOSE, MCI_WAIT, NULL); } void -SDL_SYS_CDQuit (void) +SDL_SYS_CDQuit(void) { int i; if (SDL_numcds > 0) { for (i = 0; i < SDL_numcds; ++i) { - SDL_free (SDL_cdlist[i]); + SDL_free(SDL_cdlist[i]); } SDL_numcds = 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/cpuinfo/SDL_cpuinfo.c --- a/src/cpuinfo/SDL_cpuinfo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/cpuinfo/SDL_cpuinfo.c Mon May 29 04:04:35 2006 +0000 @@ -48,23 +48,23 @@ */ static jmp_buf jmpbuf; static void -illegal_instruction (int sig) +illegal_instruction(int sig) { - longjmp (jmpbuf, 1); + longjmp(jmpbuf, 1); } #endif /* HAVE_SETJMP */ static __inline__ int -CPU_haveCPUID (void) +CPU_haveCPUID(void) { int has_CPUID = 0; #if defined(__GNUC__) && defined(i386) - __asm__ (" pushfl # Get original EFLAGS \n" " popl %%eax \n" " movl %%eax,%%ecx \n" " xorl $0x200000,%%eax # Flip ID bit in EFLAGS \n" " pushl %%eax # Save new EFLAGS value on stack \n" " popfl # Replace current EFLAGS value \n" " pushfl # Get new EFLAGS \n" " popl %%eax # Store new EFLAGS in EAX \n" " xorl %%ecx,%%eax # Can not toggle ID bit, \n" " jz 1f # Processor=80486 \n" " movl $1,%0 # We have CPUID support \n" "1: \n": "=m" (has_CPUID): + __asm__(" pushfl # Get original EFLAGS \n" " popl %%eax \n" " movl %%eax,%%ecx \n" " xorl $0x200000,%%eax # Flip ID bit in EFLAGS \n" " pushl %%eax # Save new EFLAGS value on stack \n" " popfl # Replace current EFLAGS value \n" " pushfl # Get new EFLAGS \n" " popl %%eax # Store new EFLAGS in EAX \n" " xorl %%ecx,%%eax # Can not toggle ID bit, \n" " jz 1f # Processor=80486 \n" " movl $1,%0 # We have CPUID support \n" "1: \n": "=m"(has_CPUID): :"%eax", "%ecx"); #elif defined(__GNUC__) && defined(__x86_64__) /* Technically, if this is being compiled under __x86_64__ then it has CPUid by definition. But it's nice to be able to prove it. :) */ - __asm__ (" pushfq # Get original EFLAGS \n" " popq %%rax \n" " movq %%rax,%%rcx \n" " xorl $0x200000,%%eax # Flip ID bit in EFLAGS \n" " pushq %%rax # Save new EFLAGS value on stack \n" " popfq # Replace current EFLAGS value \n" " pushfq # Get new EFLAGS \n" " popq %%rax # Store new EFLAGS in EAX \n" " xorl %%ecx,%%eax # Can not toggle ID bit, \n" " jz 1f # Processor=80486 \n" " movl $1,%0 # We have CPUID support \n" "1: \n": "=m" (has_CPUID): + __asm__(" pushfq # Get original EFLAGS \n" " popq %%rax \n" " movq %%rax,%%rcx \n" " xorl $0x200000,%%eax # Flip ID bit in EFLAGS \n" " pushq %%rax # Save new EFLAGS value on stack \n" " popfq # Replace current EFLAGS value \n" " pushfq # Get new EFLAGS \n" " popq %%rax # Store new EFLAGS in EAX \n" " xorl %%ecx,%%eax # Can not toggle ID bit, \n" " jz 1f # Processor=80486 \n" " movl $1,%0 # We have CPUID support \n" "1: \n": "=m"(has_CPUID): :"%rax", "%rcx"); #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) __asm { @@ -79,41 +79,41 @@ Processor = 80486 mov has_CPUID, 1; We have CPUID support done:} #elif defined(__sun) && defined(__x86) - __asm (" pushfl \n" - " popl %eax \n" - " movl %eax,%ecx \n" - " xorl $0x200000,%eax \n" - " pushl %eax \n" - " popfl \n" - " pushfl \n" - " popl %eax \n" - " xorl %ecx,%eax \n" - " jz 1f \n" - " movl $1,-8(%ebp) \n" - "1: \n"); + __asm(" pushfl \n" + " popl %eax \n" + " movl %eax,%ecx \n" + " xorl $0x200000,%eax \n" + " pushl %eax \n" + " popfl \n" + " pushfl \n" + " popl %eax \n" + " xorl %ecx,%eax \n" + " jz 1f \n" + " movl $1,-8(%ebp) \n" + "1: \n"); #elif defined(__sun) && defined(__amd64) - __asm (" pushfq \n" - " popq %rax \n" - " movq %rax,%rcx \n" - " xorl $0x200000,%eax \n" - " pushq %rax \n" - " popfq \n" - " pushfq \n" - " popq %rax \n" - " xorl %ecx,%eax \n" - " jz 1f \n" - " movl $1,-8(%rbp) \n" - "1: \n"); + __asm(" pushfq \n" + " popq %rax \n" + " movq %rax,%rcx \n" + " xorl $0x200000,%eax \n" + " pushq %rax \n" + " popfq \n" + " pushfq \n" + " popq %rax \n" + " xorl %ecx,%eax \n" + " jz 1f \n" + " movl $1,-8(%rbp) \n" + "1: \n"); #endif return has_CPUID; } static __inline__ int -CPU_getCPUIDFeatures (void) +CPU_getCPUIDFeatures(void) { int features = 0; #if defined(__GNUC__) && ( defined(i386) || defined(__x86_64__) ) - __asm__ (" movl %%ebx,%%edi\n" " xorl %%eax,%%eax # Set up for CPUID instruction \n" " cpuid # Get and save vendor ID \n" " cmpl $1,%%eax # Make sure 1 is valid input for CPUID\n" " jl 1f # We dont have the CPUID instruction\n" " xorl %%eax,%%eax \n" " incl %%eax \n" " cpuid # Get family/model/stepping/features\n" " movl %%edx,%0 \n" "1: \n" " movl %%edi,%%ebx\n": "=m" (features): + __asm__(" movl %%ebx,%%edi\n" " xorl %%eax,%%eax # Set up for CPUID instruction \n" " cpuid # Get and save vendor ID \n" " cmpl $1,%%eax # Make sure 1 is valid input for CPUID\n" " jl 1f # We dont have the CPUID instruction\n" " xorl %%eax,%%eax \n" " incl %%eax \n" " cpuid # Get family/model/stepping/features\n" " movl %%edx,%0 \n" "1: \n" " movl %%edi,%%ebx\n": "=m"(features): :"%eax", "%ecx", "%edx", "%edi"); #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) __asm { @@ -148,11 +148,11 @@ } static __inline__ int -CPU_getCPUIDFeaturesExt (void) +CPU_getCPUIDFeaturesExt(void) { int features = 0; #if defined(__GNUC__) && (defined(i386) || defined (__x86_64__) ) - __asm__ (" movl %%ebx,%%edi\n" " movl $0x80000000,%%eax # Query for extended functions \n" " cpuid # Get extended function limit \n" " cmpl $0x80000001,%%eax \n" " jl 1f # Nope, we dont have function 800000001h\n" " movl $0x80000001,%%eax # Setup extended function 800000001h\n" " cpuid # and get the information \n" " movl %%edx,%0 \n" "1: \n" " movl %%edi,%%ebx\n": "=m" (features): + __asm__(" movl %%ebx,%%edi\n" " movl $0x80000000,%%eax # Query for extended functions \n" " cpuid # Get extended function limit \n" " cmpl $0x80000001,%%eax \n" " jl 1f # Nope, we dont have function 800000001h\n" " movl $0x80000001,%%eax # Setup extended function 800000001h\n" " cpuid # and get the information \n" " movl %%edx,%0 \n" "1: \n" " movl %%edi,%%ebx\n": "=m"(features): :"%eax", "%ecx", "%edx", "%edi"); #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) __asm { @@ -164,106 +164,106 @@ Setup extended function 800000001 h cpuid; and get the information mov features, edx done:} #elif defined(__sun) && ( defined(__i386) || defined(__amd64) ) - __asm (" movl %ebx,%edi\n" - " movl $0x80000000,%eax \n" - " cpuid \n" - " cmpl $0x80000001,%eax \n" - " jl 1f \n" - " movl $0x80000001,%eax \n" - " cpuid \n" + __asm(" movl %ebx,%edi\n" + " movl $0x80000000,%eax \n" + " cpuid \n" + " cmpl $0x80000001,%eax \n" + " jl 1f \n" + " movl $0x80000001,%eax \n" + " cpuid \n" #ifdef __i386 - " movl %edx,-8(%ebp) \n" + " movl %edx,-8(%ebp) \n" #else - " movl %edx,-8(%rbp) \n" + " movl %edx,-8(%rbp) \n" #endif - "1: \n" - " movl %edi,%ebx\n"); + "1: \n" + " movl %edi,%ebx\n"); #endif return features; } static __inline__ int -CPU_haveRDTSC (void) +CPU_haveRDTSC(void) { - if (CPU_haveCPUID ()) { - return (CPU_getCPUIDFeatures () & 0x00000010); + if (CPU_haveCPUID()) { + return (CPU_getCPUIDFeatures() & 0x00000010); } return 0; } static __inline__ int -CPU_haveMMX (void) +CPU_haveMMX(void) { - if (CPU_haveCPUID ()) { - return (CPU_getCPUIDFeatures () & 0x00800000); + if (CPU_haveCPUID()) { + return (CPU_getCPUIDFeatures() & 0x00800000); } return 0; } static __inline__ int -CPU_haveMMXExt (void) +CPU_haveMMXExt(void) { - if (CPU_haveCPUID ()) { - return (CPU_getCPUIDFeaturesExt () & 0x00400000); + if (CPU_haveCPUID()) { + return (CPU_getCPUIDFeaturesExt() & 0x00400000); } return 0; } static __inline__ int -CPU_have3DNow (void) +CPU_have3DNow(void) { - if (CPU_haveCPUID ()) { - return (CPU_getCPUIDFeaturesExt () & 0x80000000); + if (CPU_haveCPUID()) { + return (CPU_getCPUIDFeaturesExt() & 0x80000000); } return 0; } static __inline__ int -CPU_have3DNowExt (void) +CPU_have3DNowExt(void) { - if (CPU_haveCPUID ()) { - return (CPU_getCPUIDFeaturesExt () & 0x40000000); + if (CPU_haveCPUID()) { + return (CPU_getCPUIDFeaturesExt() & 0x40000000); } return 0; } static __inline__ int -CPU_haveSSE (void) +CPU_haveSSE(void) { - if (CPU_haveCPUID ()) { - return (CPU_getCPUIDFeatures () & 0x02000000); + if (CPU_haveCPUID()) { + return (CPU_getCPUIDFeatures() & 0x02000000); } return 0; } static __inline__ int -CPU_haveSSE2 (void) +CPU_haveSSE2(void) { - if (CPU_haveCPUID ()) { - return (CPU_getCPUIDFeatures () & 0x04000000); + if (CPU_haveCPUID()) { + return (CPU_getCPUIDFeatures() & 0x04000000); } return 0; } static __inline__ int -CPU_haveAltiVec (void) +CPU_haveAltiVec(void) { volatile int altivec = 0; #if defined(__MACOSX__) && defined(__ppc__) int selectors[2] = { CTL_HW, HW_VECTORUNIT }; int hasVectorUnit = 0; - size_t length = sizeof (hasVectorUnit); - int error = sysctl (selectors, 2, &hasVectorUnit, &length, NULL, 0); + size_t length = sizeof(hasVectorUnit); + int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0); if (0 == error) altivec = (hasVectorUnit != 0); #elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP void (*handler) (int sig); - handler = signal (SIGILL, illegal_instruction); - if (setjmp (jmpbuf) == 0) { + handler = signal(SIGILL, illegal_instruction); + if (setjmp(jmpbuf) == 0) { asm volatile ("mtspr 256, %0\n\t" "vand %%v0, %%v0, %%v0"::"r" (-1)); altivec = 1; } - signal (SIGILL, handler); + signal(SIGILL, handler); #endif return altivec; } @@ -271,32 +271,32 @@ static Uint32 SDL_CPUFeatures = 0xFFFFFFFF; static Uint32 -SDL_GetCPUFeatures (void) +SDL_GetCPUFeatures(void) { if (SDL_CPUFeatures == 0xFFFFFFFF) { SDL_CPUFeatures = 0; - if (CPU_haveRDTSC ()) { + if (CPU_haveRDTSC()) { SDL_CPUFeatures |= CPU_HAS_RDTSC; } - if (CPU_haveMMX ()) { + if (CPU_haveMMX()) { SDL_CPUFeatures |= CPU_HAS_MMX; } - if (CPU_haveMMXExt ()) { + if (CPU_haveMMXExt()) { SDL_CPUFeatures |= CPU_HAS_MMXEXT; } - if (CPU_have3DNow ()) { + if (CPU_have3DNow()) { SDL_CPUFeatures |= CPU_HAS_3DNOW; } - if (CPU_have3DNowExt ()) { + if (CPU_have3DNowExt()) { SDL_CPUFeatures |= CPU_HAS_3DNOWEXT; } - if (CPU_haveSSE ()) { + if (CPU_haveSSE()) { SDL_CPUFeatures |= CPU_HAS_SSE; } - if (CPU_haveSSE2 ()) { + if (CPU_haveSSE2()) { SDL_CPUFeatures |= CPU_HAS_SSE2; } - if (CPU_haveAltiVec ()) { + if (CPU_haveAltiVec()) { SDL_CPUFeatures |= CPU_HAS_ALTIVEC; } } @@ -304,72 +304,72 @@ } SDL_bool -SDL_HasRDTSC (void) +SDL_HasRDTSC(void) { - if (SDL_GetCPUFeatures () & CPU_HAS_RDTSC) { + if (SDL_GetCPUFeatures() & CPU_HAS_RDTSC) { return SDL_TRUE; } return SDL_FALSE; } SDL_bool -SDL_HasMMX (void) +SDL_HasMMX(void) { - if (SDL_GetCPUFeatures () & CPU_HAS_MMX) { + if (SDL_GetCPUFeatures() & CPU_HAS_MMX) { return SDL_TRUE; } return SDL_FALSE; } SDL_bool -SDL_HasMMXExt (void) +SDL_HasMMXExt(void) { - if (SDL_GetCPUFeatures () & CPU_HAS_MMXEXT) { + if (SDL_GetCPUFeatures() & CPU_HAS_MMXEXT) { return SDL_TRUE; } return SDL_FALSE; } SDL_bool -SDL_Has3DNow (void) +SDL_Has3DNow(void) { - if (SDL_GetCPUFeatures () & CPU_HAS_3DNOW) { + if (SDL_GetCPUFeatures() & CPU_HAS_3DNOW) { return SDL_TRUE; } return SDL_FALSE; } SDL_bool -SDL_Has3DNowExt (void) +SDL_Has3DNowExt(void) { - if (SDL_GetCPUFeatures () & CPU_HAS_3DNOWEXT) { + if (SDL_GetCPUFeatures() & CPU_HAS_3DNOWEXT) { return SDL_TRUE; } return SDL_FALSE; } SDL_bool -SDL_HasSSE (void) +SDL_HasSSE(void) { - if (SDL_GetCPUFeatures () & CPU_HAS_SSE) { + if (SDL_GetCPUFeatures() & CPU_HAS_SSE) { return SDL_TRUE; } return SDL_FALSE; } SDL_bool -SDL_HasSSE2 (void) +SDL_HasSSE2(void) { - if (SDL_GetCPUFeatures () & CPU_HAS_SSE2) { + if (SDL_GetCPUFeatures() & CPU_HAS_SSE2) { return SDL_TRUE; } return SDL_FALSE; } SDL_bool -SDL_HasAltiVec (void) +SDL_HasAltiVec(void) { - if (SDL_GetCPUFeatures () & CPU_HAS_ALTIVEC) { + if (SDL_GetCPUFeatures() & CPU_HAS_ALTIVEC) { return SDL_TRUE; } return SDL_FALSE; @@ -380,16 +380,16 @@ #include int -main () +main() { - printf ("RDTSC: %d\n", SDL_HasRDTSC ()); - printf ("MMX: %d\n", SDL_HasMMX ()); - printf ("MMXExt: %d\n", SDL_HasMMXExt ()); - printf ("3DNow: %d\n", SDL_Has3DNow ()); - printf ("3DNowExt: %d\n", SDL_Has3DNowExt ()); - printf ("SSE: %d\n", SDL_HasSSE ()); - printf ("SSE2: %d\n", SDL_HasSSE2 ()); - printf ("AltiVec: %d\n", SDL_HasAltiVec ()); + printf("RDTSC: %d\n", SDL_HasRDTSC()); + printf("MMX: %d\n", SDL_HasMMX()); + printf("MMXExt: %d\n", SDL_HasMMXExt()); + printf("3DNow: %d\n", SDL_Has3DNow()); + printf("3DNowExt: %d\n", SDL_Has3DNowExt()); + printf("SSE: %d\n", SDL_HasSSE()); + printf("SSE2: %d\n", SDL_HasSSE2()); + printf("AltiVec: %d\n", SDL_HasAltiVec()); return 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/events/SDL_events.c --- a/src/events/SDL_events.c Mon May 29 03:53:21 2006 +0000 +++ b/src/events/SDL_events.c Mon May 29 04:04:35 2006 +0000 @@ -62,21 +62,21 @@ static Uint32 event_thread; /* The event thread id */ void -SDL_Lock_EventThread (void) +SDL_Lock_EventThread(void) { - if (SDL_EventThread && (SDL_ThreadID () != event_thread)) { + if (SDL_EventThread && (SDL_ThreadID() != event_thread)) { /* Grab lock and spin until we're sure event thread stopped */ - SDL_mutexP (SDL_EventLock.lock); + SDL_mutexP(SDL_EventLock.lock); while (!SDL_EventLock.safe) { - SDL_Delay (1); + SDL_Delay(1); } } } void -SDL_Unlock_EventThread (void) +SDL_Unlock_EventThread(void) { - if (SDL_EventThread && (SDL_ThreadID () != event_thread)) { - SDL_mutexV (SDL_EventLock.lock); + if (SDL_EventThread && (SDL_ThreadID() != event_thread)) { + SDL_mutexV(SDL_EventLock.lock); } } @@ -92,41 +92,41 @@ #endif static int SDLCALL -SDL_GobbleEvents (void *unused) +SDL_GobbleEvents(void *unused) { - event_thread = SDL_ThreadID (); + event_thread = SDL_ThreadID(); #ifdef __OS2__ #ifdef USE_DOSSETPRIORITY /* Increase thread priority, so it will process events in time for sure! */ - DosSetPriority (PRTYS_THREAD, PRTYC_REGULAR, +16, 0); + DosSetPriority(PRTYS_THREAD, PRTYC_REGULAR, +16, 0); #endif #endif while (SDL_EventQ.active) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); /* Get events from the video subsystem */ if (_this) { - _this->PumpEvents (_this); + _this->PumpEvents(_this); } /* Queue pending key-repeat events */ - SDL_CheckKeyRepeat (); + SDL_CheckKeyRepeat(); #if !SDL_JOYSTICK_DISABLED /* Check for joystick state change */ if (SDL_numjoysticks && (SDL_eventstate & SDL_JOYEVENTMASK)) { - SDL_JoystickUpdate (); + SDL_JoystickUpdate(); } #endif /* Give up the CPU for the rest of our timeslice */ SDL_EventLock.safe = 1; if (SDL_timer_running) { - SDL_ThreadedTimerCheck (); + SDL_ThreadedTimerCheck(); } - SDL_Delay (1); + SDL_Delay(1); /* Check for event locking. On the P of the lock mutex, if the lock is held, this thread @@ -136,25 +136,25 @@ so as soon as the mutex is free, other threads can see that it's not safe to interfere with the event thread. */ - SDL_mutexP (SDL_EventLock.lock); + SDL_mutexP(SDL_EventLock.lock); SDL_EventLock.safe = 0; - SDL_mutexV (SDL_EventLock.lock); + SDL_mutexV(SDL_EventLock.lock); } - SDL_SetTimerThreaded (0); + SDL_SetTimerThreaded(0); event_thread = 0; return (0); } static int -SDL_StartEventThread (Uint32 flags) +SDL_StartEventThread(Uint32 flags) { /* Reset everything to zero */ SDL_EventThread = NULL; - SDL_memset (&SDL_EventLock, 0, sizeof (SDL_EventLock)); + SDL_memset(&SDL_EventLock, 0, sizeof(SDL_EventLock)); /* Create the lock and set ourselves active */ #if !SDL_THREADS_DISABLED - SDL_EventQ.lock = SDL_CreateMutex (); + SDL_EventQ.lock = SDL_CreateMutex(); if (SDL_EventQ.lock == NULL) { #ifdef __MACOS__ /* MacOS classic you can't multithread, so no lock needed */ ; @@ -166,20 +166,20 @@ SDL_EventQ.active = 1; if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) { - SDL_EventLock.lock = SDL_CreateMutex (); + SDL_EventLock.lock = SDL_CreateMutex(); if (SDL_EventLock.lock == NULL) { return (-1); } SDL_EventLock.safe = 0; /* The event thread will handle timers too */ - SDL_SetTimerThreaded (2); + SDL_SetTimerThreaded(2); #if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC) #undef SDL_CreateThread SDL_EventThread = - SDL_CreateThread (SDL_GobbleEvents, NULL, NULL, NULL); + SDL_CreateThread(SDL_GobbleEvents, NULL, NULL, NULL); #else - SDL_EventThread = SDL_CreateThread (SDL_GobbleEvents, NULL); + SDL_EventThread = SDL_CreateThread(SDL_GobbleEvents, NULL); #endif if (SDL_EventThread == NULL) { return (-1); @@ -191,21 +191,21 @@ } static void -SDL_StopEventThread (void) +SDL_StopEventThread(void) { SDL_EventQ.active = 0; if (SDL_EventThread) { - SDL_WaitThread (SDL_EventThread, NULL); + SDL_WaitThread(SDL_EventThread, NULL); SDL_EventThread = NULL; - SDL_DestroyMutex (SDL_EventLock.lock); + SDL_DestroyMutex(SDL_EventLock.lock); } #ifndef IPOD - SDL_DestroyMutex (SDL_EventQ.lock); + SDL_DestroyMutex(SDL_EventQ.lock); #endif } Uint32 -SDL_EventThreadID (void) +SDL_EventThreadID(void) { return (event_thread); } @@ -213,15 +213,15 @@ /* Public functions */ void -SDL_StopEventLoop (void) +SDL_StopEventLoop(void) { /* Halt the event thread, if running */ - SDL_StopEventThread (); + SDL_StopEventThread(); /* Shutdown event handlers */ - SDL_KeyboardQuit (); - SDL_MouseQuit (); - SDL_QuitQuit (); + SDL_KeyboardQuit(); + SDL_MouseQuit(); + SDL_QuitQuit(); /* Clean out EventQ */ SDL_EventQ.head = 0; @@ -231,18 +231,18 @@ /* This function (and associated calls) may be called more than once */ int -SDL_StartEventLoop (Uint32 flags) +SDL_StartEventLoop(Uint32 flags) { int retcode; /* Clean out the event queue */ SDL_EventThread = NULL; SDL_EventQ.lock = NULL; - SDL_StopEventLoop (); + SDL_StopEventLoop(); /* No filter to start with, process most event types */ SDL_EventOK = NULL; - SDL_memset (SDL_ProcessEvents, SDL_ENABLE, sizeof (SDL_ProcessEvents)); + SDL_memset(SDL_ProcessEvents, SDL_ENABLE, sizeof(SDL_ProcessEvents)); SDL_eventstate = ~0; /* It's not save to call SDL_EventState() yet */ SDL_eventstate &= ~(0x00000001 << SDL_SYSWMEVENT); @@ -250,17 +250,17 @@ /* Initialize event handlers */ retcode = 0; - retcode += SDL_KeyboardInit (); - retcode += SDL_MouseInit (); - retcode += SDL_QuitInit (); + retcode += SDL_KeyboardInit(); + retcode += SDL_MouseInit(); + retcode += SDL_QuitInit(); if (retcode < 0) { /* We don't expect them to fail, but... */ return (-1); } /* Create the lock and event thread */ - if (SDL_StartEventThread (flags) < 0) { - SDL_StopEventLoop (); + if (SDL_StartEventThread(flags) < 0) { + SDL_StopEventLoop(); return (-1); } return (0); @@ -269,7 +269,7 @@ /* Add an event to the event queue -- called with the queue locked */ static int -SDL_AddEvent (SDL_Event * event) +SDL_AddEvent(SDL_Event * event) { int tail, added; @@ -296,7 +296,7 @@ /* Cut an event, and return the next valid spot, or the tail */ /* -- called with the queue locked */ static int -SDL_CutEvent (int spot) +SDL_CutEvent(int spot) { if (spot == SDL_EventQ.head) { SDL_EventQ.head = (SDL_EventQ.head + 1) % MAXEVENTS; @@ -324,8 +324,8 @@ /* Lock the event queue, take a peep at it, and unlock it */ int -SDL_PeepEvents (SDL_Event * events, int numevents, SDL_eventaction action, - Uint32 mask) +SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action, + Uint32 mask) { int i, used; @@ -335,10 +335,10 @@ } /* Lock the event queue */ used = 0; - if (SDL_mutexP (SDL_EventQ.lock) == 0) { + if (SDL_mutexP(SDL_EventQ.lock) == 0) { if (action == SDL_ADDEVENT) { for (i = 0; i < numevents; ++i) { - used += SDL_AddEvent (&events[i]); + used += SDL_AddEvent(&events[i]); } } else { SDL_Event tmpevent; @@ -352,10 +352,10 @@ } spot = SDL_EventQ.head; while ((used < numevents) && (spot != SDL_EventQ.tail)) { - if (mask & SDL_EVENTMASK (SDL_EventQ.event[spot].type)) { + if (mask & SDL_EVENTMASK(SDL_EventQ.event[spot].type)) { events[used++] = SDL_EventQ.event[spot]; if (action == SDL_GETEVENT) { - spot = SDL_CutEvent (spot); + spot = SDL_CutEvent(spot); } else { spot = (spot + 1) % MAXEVENTS; } @@ -364,9 +364,9 @@ } } } - SDL_mutexV (SDL_EventQ.lock); + SDL_mutexV(SDL_EventQ.lock); } else { - SDL_SetError ("Couldn't lock event queue"); + SDL_SetError("Couldn't lock event queue"); used = -1; } return (used); @@ -374,23 +374,23 @@ /* Run the system dependent event loops */ void -SDL_PumpEvents (void) +SDL_PumpEvents(void) { if (!SDL_EventThread) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); /* Get events from the video subsystem */ if (_this) { - _this->PumpEvents (_this); + _this->PumpEvents(_this); } /* Queue pending key-repeat events */ - SDL_CheckKeyRepeat (); + SDL_CheckKeyRepeat(); #if !SDL_JOYSTICK_DISABLED /* Check for joystick state change */ if (SDL_numjoysticks && (SDL_eventstate & SDL_JOYEVENTMASK)) { - SDL_JoystickUpdate (); + SDL_JoystickUpdate(); } #endif } @@ -399,58 +399,58 @@ /* Public functions */ int -SDL_PollEvent (SDL_Event * event) +SDL_PollEvent(SDL_Event * event) { - SDL_PumpEvents (); + SDL_PumpEvents(); /* We can't return -1, just return 0 (no event) on error */ - if (SDL_PeepEvents (event, 1, SDL_GETEVENT, SDL_ALLEVENTS) <= 0) + if (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_ALLEVENTS) <= 0) return 0; return 1; } int -SDL_WaitEvent (SDL_Event * event) +SDL_WaitEvent(SDL_Event * event) { while (1) { - SDL_PumpEvents (); - switch (SDL_PeepEvents (event, 1, SDL_GETEVENT, SDL_ALLEVENTS)) { + SDL_PumpEvents(); + switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_ALLEVENTS)) { case -1: return 0; case 1: return 1; case 0: - SDL_Delay (10); + SDL_Delay(10); } } } int -SDL_PushEvent (SDL_Event * event) +SDL_PushEvent(SDL_Event * event) { - if (SDL_PeepEvents (event, 1, SDL_ADDEVENT, 0) <= 0) + if (SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0) <= 0) return -1; return 0; } void -SDL_SetEventFilter (SDL_EventFilter filter) +SDL_SetEventFilter(SDL_EventFilter filter) { SDL_Event bitbucket; /* Set filter and discard pending events */ SDL_EventOK = filter; - while (SDL_PollEvent (&bitbucket) > 0); + while (SDL_PollEvent(&bitbucket) > 0); } SDL_EventFilter -SDL_GetEventFilter (void) +SDL_GetEventFilter(void) { return (SDL_EventOK); } Uint8 -SDL_EventState (Uint8 type, int state) +SDL_EventState(Uint8 type, int state) { SDL_Event bitbucket; Uint8 current_state; @@ -469,7 +469,7 @@ SDL_eventstate &= ~(0x00000001 << (type)); } } - while (SDL_PollEvent (&bitbucket) > 0); + while (SDL_PollEvent(&bitbucket) > 0); return (current_state); } @@ -485,7 +485,7 @@ } else { SDL_eventstate &= ~(0x00000001 << (type)); } - while (SDL_PollEvent (&bitbucket) > 0); + while (SDL_PollEvent(&bitbucket) > 0); break; default: /* Querying state? */ @@ -497,19 +497,19 @@ /* This is a generic event handler. */ int -SDL_PrivateSysWMEvent (SDL_SysWMmsg * message) +SDL_PrivateSysWMEvent(SDL_SysWMmsg * message) { int posted; posted = 0; if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) { SDL_Event event; - SDL_memset (&event, 0, sizeof (event)); + SDL_memset(&event, 0, sizeof(event)); event.type = SDL_SYSWMEVENT; event.syswm.msg = message; if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) { posted = 1; - SDL_PushEvent (&event); + SDL_PushEvent(&event); } } /* Update internal event state */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/events/SDL_events_c.h --- a/src/events/SDL_events_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/events/SDL_events_c.h Mon May 29 04:04:35 2006 +0000 @@ -25,23 +25,23 @@ #include "SDL_events.h" /* Start and stop the event processing loop */ -extern int SDL_StartEventLoop (Uint32 flags); -extern void SDL_StopEventLoop (void); -extern void SDL_QuitInterrupt (void); +extern int SDL_StartEventLoop(Uint32 flags); +extern void SDL_StopEventLoop(void); +extern void SDL_QuitInterrupt(void); -extern void SDL_Lock_EventThread (void); -extern void SDL_Unlock_EventThread (void); -extern Uint32 SDL_EventThreadID (void); +extern void SDL_Lock_EventThread(void); +extern void SDL_Unlock_EventThread(void); +extern Uint32 SDL_EventThreadID(void); /* Event handler init routines */ -extern int SDL_KeyboardInit (void); -extern int SDL_MouseInit (void); -extern int SDL_QuitInit (void); +extern int SDL_KeyboardInit(void); +extern int SDL_MouseInit(void); +extern int SDL_QuitInit(void); /* Event handler quit routines */ -extern void SDL_KeyboardQuit (void); -extern void SDL_MouseQuit (void); -extern void SDL_QuitQuit (void); +extern void SDL_KeyboardQuit(void); +extern void SDL_MouseQuit(void); +extern void SDL_QuitQuit(void); /* The event filter function */ extern SDL_EventFilter SDL_EventOK; @@ -52,24 +52,24 @@ /* Internal event queueing functions (from SDL_mouse.c, SDL_keyboard.c, SDL_quit.c, SDL_events.c, SDL_windowevents.c) */ -extern int SDL_PrivateWindowEvent (SDL_WindowID windowID, Uint8 windowevent, - int data1, int data2); -extern int SDL_PrivateMouseMotion (Uint8 buttonstate, int relative, Sint16 x, - Sint16 y); -extern int SDL_PrivateMouseButton (Uint8 state, Uint8 button, Sint16 x, - Sint16 y); -extern int SDL_PrivateKeyboard (Uint8 state, SDL_keysym * key); -extern int SDL_PrivateQuit (void); -extern int SDL_PrivateSysWMEvent (SDL_SysWMmsg * message); +extern int SDL_PrivateWindowEvent(SDL_WindowID windowID, Uint8 windowevent, + int data1, int data2); +extern int SDL_PrivateMouseMotion(Uint8 buttonstate, int relative, Sint16 x, + Sint16 y); +extern int SDL_PrivateMouseButton(Uint8 state, Uint8 button, Sint16 x, + Sint16 y); +extern int SDL_PrivateKeyboard(Uint8 state, SDL_keysym * key); +extern int SDL_PrivateQuit(void); +extern int SDL_PrivateSysWMEvent(SDL_SysWMmsg * message); /* Used by the activity event handler to remove mouse focus */ -extern void SDL_ResetMouse (void); +extern void SDL_ResetMouse(void); /* Used by the activity event handler to remove keyboard focus */ -extern void SDL_ResetKeyboard (void); +extern void SDL_ResetKeyboard(void); /* Used by the event loop to queue pending keyboard repeat events */ -extern void SDL_CheckKeyRepeat (void); +extern void SDL_CheckKeyRepeat(void); /* Used by the OS keyboard code to detect whether or not to do UNICODE */ #ifndef DEFAULT_UNICODE_TRANSLATION diff -r 1fddae038bc8 -r 4da1ee79c9af src/events/SDL_keyboard.c --- a/src/events/SDL_keyboard.c Mon May 29 03:53:21 2006 +0000 +++ b/src/events/SDL_keyboard.c Mon May 29 04:04:35 2006 +0000 @@ -51,20 +51,20 @@ /* Public functions */ int -SDL_KeyboardInit (void) +SDL_KeyboardInit(void) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); /* Set default mode of UNICODE translation */ - SDL_EnableUNICODE (DEFAULT_UNICODE_TRANSLATION); + SDL_EnableUNICODE(DEFAULT_UNICODE_TRANSLATION); /* Initialize the tables */ SDL_ModState = KMOD_NONE; - SDL_memset ((void *) keynames, 0, sizeof (keynames)); - SDL_memset (SDL_KeyState, 0, sizeof (SDL_KeyState)); - _this->InitOSKeymap (_this); + SDL_memset((void *) keynames, 0, sizeof(keynames)); + SDL_memset(SDL_KeyState, 0, sizeof(SDL_KeyState)); + _this->InitOSKeymap(_this); - SDL_EnableKeyRepeat (0, 0); + SDL_EnableKeyRepeat(0, 0); /* Fill in the blanks in keynames */ keynames[SDLK_BACKSPACE] = "backspace"; @@ -311,29 +311,29 @@ } void -SDL_KeyboardQuit (void) +SDL_KeyboardQuit(void) { } /* We lost the keyboard, so post key up messages for all pressed keys */ void -SDL_ResetKeyboard (void) +SDL_ResetKeyboard(void) { SDL_keysym keysym; SDLKey key; - SDL_memset (&keysym, 0, (sizeof keysym)); + SDL_memset(&keysym, 0, (sizeof keysym)); for (key = SDLK_FIRST; key < SDLK_LAST; ++key) { if (SDL_KeyState[key] == SDL_PRESSED) { keysym.sym = key; - SDL_PrivateKeyboard (SDL_RELEASED, &keysym); + SDL_PrivateKeyboard(SDL_RELEASED, &keysym); } } SDL_KeyRepeat.timestamp = 0; } int -SDL_EnableUNICODE (int enable) +SDL_EnableUNICODE(int enable) { int old_mode; @@ -345,7 +345,7 @@ } Uint8 * -SDL_GetKeyState (int *numkeys) +SDL_GetKeyState(int *numkeys) { if (numkeys != (int *) 0) *numkeys = SDLK_LAST; @@ -353,19 +353,19 @@ } SDLMod -SDL_GetModState (void) +SDL_GetModState(void) { return (SDL_ModState); } void -SDL_SetModState (SDLMod modstate) +SDL_SetModState(SDLMod modstate) { SDL_ModState = modstate; } char * -SDL_GetKeyName (SDLKey key) +SDL_GetKeyName(SDLKey key) { const char *keyname; @@ -382,17 +382,17 @@ /* These are global for SDL_eventloop.c */ int -SDL_PrivateKeyboard (Uint8 state, SDL_keysym * keysym) +SDL_PrivateKeyboard(Uint8 state, SDL_keysym * keysym) { SDL_Event event; int posted, repeatable; Uint16 modstate; - SDL_memset (&event, 0, sizeof (event)); + SDL_memset(&event, 0, sizeof(event)); #if 0 - printf ("The '%s' key has been %s\n", SDL_GetKeyName (keysym->sym), - state == SDL_PRESSED ? "pressed" : "released"); + printf("The '%s' key has been %s\n", SDL_GetKeyName(keysym->sym), + state == SDL_PRESSED ? "pressed" : "released"); #endif /* Set up the keysym */ modstate = (Uint16) SDL_ModState; @@ -512,7 +512,7 @@ /* Drop events that don't change state */ if (SDL_KeyState[keysym->sym] == state) { #if 0 - printf ("Keyboard event didn't change state - dropped!\n"); + printf("Keyboard event didn't change state - dropped!\n"); #endif return (0); } @@ -533,11 +533,11 @@ if (repeatable && (SDL_KeyRepeat.delay != 0)) { SDL_KeyRepeat.evt = event; SDL_KeyRepeat.firsttime = 1; - SDL_KeyRepeat.timestamp = SDL_GetTicks (); + SDL_KeyRepeat.timestamp = SDL_GetTicks(); } - if ((SDL_EventOK == NULL) || SDL_EventOK (&event)) { + if ((SDL_EventOK == NULL) || SDL_EventOK(&event)) { posted = 1; - SDL_PushEvent (&event); + SDL_PushEvent(&event); } } return (posted); @@ -547,12 +547,12 @@ * jk 991215 - Added */ void -SDL_CheckKeyRepeat (void) +SDL_CheckKeyRepeat(void) { if (SDL_KeyRepeat.timestamp) { Uint32 now, interval; - now = SDL_GetTicks (); + now = SDL_GetTicks(); interval = (now - SDL_KeyRepeat.timestamp); if (SDL_KeyRepeat.firsttime) { if (interval > (Uint32) SDL_KeyRepeat.delay) { @@ -563,8 +563,8 @@ if (interval > (Uint32) SDL_KeyRepeat.interval) { SDL_KeyRepeat.timestamp = now; if ((SDL_EventOK == NULL) - || SDL_EventOK (&SDL_KeyRepeat.evt)) { - SDL_PushEvent (&SDL_KeyRepeat.evt); + || SDL_EventOK(&SDL_KeyRepeat.evt)) { + SDL_PushEvent(&SDL_KeyRepeat.evt); } } } @@ -572,10 +572,10 @@ } int -SDL_EnableKeyRepeat (int delay, int interval) +SDL_EnableKeyRepeat(int delay, int interval) { if ((delay < 0) || (interval < 0)) { - SDL_SetError ("keyboard repeat value less than zero"); + SDL_SetError("keyboard repeat value less than zero"); return (-1); } SDL_KeyRepeat.firsttime = 0; @@ -586,7 +586,7 @@ } void -SDL_GetKeyRepeat (int *delay, int *interval) +SDL_GetKeyRepeat(int *delay, int *interval) { *delay = SDL_KeyRepeat.delay; *interval = SDL_KeyRepeat.interval; diff -r 1fddae038bc8 -r 4da1ee79c9af src/events/SDL_mouse.c --- a/src/events/SDL_mouse.c Mon May 29 03:53:21 2006 +0000 +++ b/src/events/SDL_mouse.c Mon May 29 04:04:35 2006 +0000 @@ -39,7 +39,7 @@ /* Public functions */ int -SDL_MouseInit (void) +SDL_MouseInit(void) { /* The mouse is at (0,0) */ SDL_MouseX = 0; @@ -53,24 +53,24 @@ } void -SDL_MouseQuit (void) +SDL_MouseQuit(void) { } /* We lost the mouse, so post button up messages for all pressed buttons */ void -SDL_ResetMouse (void) +SDL_ResetMouse(void) { Uint8 i; - for (i = 0; i < sizeof (SDL_ButtonState) * 8; ++i) { - if (SDL_ButtonState & SDL_BUTTON (i)) { - SDL_PrivateMouseButton (SDL_RELEASED, i, 0, 0); + for (i = 0; i < sizeof(SDL_ButtonState) * 8; ++i) { + if (SDL_ButtonState & SDL_BUTTON(i)) { + SDL_PrivateMouseButton(SDL_RELEASED, i, 0, 0); } } } Uint8 -SDL_GetMouseState (int *x, int *y) +SDL_GetMouseState(int *x, int *y) { if (x) { *x = SDL_MouseX; @@ -82,7 +82,7 @@ } Uint8 -SDL_GetRelativeMouseState (int *x, int *y) +SDL_GetRelativeMouseState(int *x, int *y) { if (x) *x = SDL_DeltaX; @@ -94,9 +94,9 @@ } static void -ClipOffset (Sint16 * x, Sint16 * y) +ClipOffset(Sint16 * x, Sint16 * y) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); /* This clips absolute mouse coordinates when the apparent display surface is smaller than the real display surface. @@ -110,9 +110,9 @@ /* These are global for SDL_eventloop.c */ int -SDL_PrivateMouseMotion (Uint8 buttonstate, int relative, Sint16 x, Sint16 y) +SDL_PrivateMouseMotion(Uint8 buttonstate, int relative, Sint16 x, Sint16 y) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); int posted; Uint16 X, Y; Sint16 Xrel; @@ -136,7 +136,7 @@ y = (SDL_MouseY + y); } else { /* Do we need to clip {x,y} ? */ - ClipOffset (&x, &y); + ClipOffset(&x, &y); } /* Mouse coordinates range from 0 - width-1 and 0 - height-1 */ @@ -166,7 +166,7 @@ /* Drop events that don't change state */ if (!Xrel && !Yrel) { #if 0 - printf ("Mouse event didn't change state - dropped!\n"); + printf("Mouse event didn't change state - dropped!\n"); #endif return (0); } @@ -177,13 +177,13 @@ SDL_MouseY = Y; SDL_DeltaX += Xrel; SDL_DeltaY += Yrel; - SDL_MoveCursor (SDL_MouseX, SDL_MouseY); + SDL_MoveCursor(SDL_MouseX, SDL_MouseY); /* Post the event, if desired */ posted = 0; if (SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE) { SDL_Event event; - SDL_memset (&event, 0, sizeof (event)); + SDL_memset(&event, 0, sizeof(event)); event.type = SDL_MOUSEMOTION; event.motion.state = buttonstate; event.motion.x = X; @@ -192,26 +192,26 @@ event.motion.yrel = Yrel; if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) { posted = 1; - SDL_PushEvent (&event); + SDL_PushEvent(&event); } } return (posted); } int -SDL_PrivateMouseButton (Uint8 state, Uint8 button, Sint16 x, Sint16 y) +SDL_PrivateMouseButton(Uint8 state, Uint8 button, Sint16 x, Sint16 y) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); SDL_Event event; int posted; int move_mouse; Uint8 buttonstate; - SDL_memset (&event, 0, sizeof (event)); + SDL_memset(&event, 0, sizeof(event)); /* Check parameters */ if (x || y) { - ClipOffset (&x, &y); + ClipOffset(&x, &y); move_mouse = 1; /* Mouse coordinates range from 0 - width-1 and 0 - height-1 */ if (x < 0) @@ -236,11 +236,11 @@ switch (state) { case SDL_PRESSED: event.type = SDL_MOUSEBUTTONDOWN; - buttonstate |= SDL_BUTTON (button); + buttonstate |= SDL_BUTTON(button); break; case SDL_RELEASED: event.type = SDL_MOUSEBUTTONUP; - buttonstate &= ~SDL_BUTTON (button); + buttonstate &= ~SDL_BUTTON(button); break; default: /* Invalid state -- bail */ @@ -252,7 +252,7 @@ if (move_mouse) { SDL_MouseX = x; SDL_MouseY = y; - SDL_MoveCursor (SDL_MouseX, SDL_MouseY); + SDL_MoveCursor(SDL_MouseX, SDL_MouseY); } /* Post the event, if desired */ @@ -264,7 +264,7 @@ event.button.y = y; if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) { posted = 1; - SDL_PushEvent (&event); + SDL_PushEvent(&event); } } return (posted); diff -r 1fddae038bc8 -r 4da1ee79c9af src/events/SDL_quit.c --- a/src/events/SDL_quit.c Mon May 29 03:53:21 2006 +0000 +++ b/src/events/SDL_quit.c Mon May 29 04:04:35 2006 +0000 @@ -33,30 +33,30 @@ #ifdef HAVE_SIGNAL_H static void -SDL_HandleSIG (int sig) +SDL_HandleSIG(int sig) { /* Reset the signal handler */ - signal (sig, SDL_HandleSIG); + signal(sig, SDL_HandleSIG); /* Signal a quit interrupt */ - SDL_PrivateQuit (); + SDL_PrivateQuit(); } #endif /* HAVE_SIGNAL_H */ /* Public functions */ int -SDL_QuitInit (void) +SDL_QuitInit(void) { #ifdef HAVE_SIGNAL_H void (*ohandler) (int); /* Both SIGINT and SIGTERM are translated into quit interrupts */ - ohandler = signal (SIGINT, SDL_HandleSIG); + ohandler = signal(SIGINT, SDL_HandleSIG); if (ohandler != SIG_DFL) - signal (SIGINT, ohandler); - ohandler = signal (SIGTERM, SDL_HandleSIG); + signal(SIGINT, ohandler); + ohandler = signal(SIGTERM, SDL_HandleSIG); if (ohandler != SIG_DFL) - signal (SIGTERM, ohandler); + signal(SIGTERM, ohandler); #endif /* HAVE_SIGNAL_H */ /* That's it! */ @@ -64,23 +64,23 @@ } void -SDL_QuitQuit (void) +SDL_QuitQuit(void) { #ifdef HAVE_SIGNAL_H void (*ohandler) (int); - ohandler = signal (SIGINT, SIG_DFL); + ohandler = signal(SIGINT, SIG_DFL); if (ohandler != SDL_HandleSIG) - signal (SIGINT, ohandler); - ohandler = signal (SIGTERM, SIG_DFL); + signal(SIGINT, ohandler); + ohandler = signal(SIGTERM, SIG_DFL); if (ohandler != SDL_HandleSIG) - signal (SIGTERM, ohandler); + signal(SIGTERM, ohandler); #endif /* HAVE_SIGNAL_H */ } /* This function returns 1 if it's okay to close the application window */ int -SDL_PrivateQuit (void) +SDL_PrivateQuit(void) { int posted; @@ -90,7 +90,7 @@ event.type = SDL_QUIT; if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) { posted = 1; - SDL_PushEvent (&event); + SDL_PushEvent(&event); } } return (posted); diff -r 1fddae038bc8 -r 4da1ee79c9af src/events/SDL_windowevents.c --- a/src/events/SDL_windowevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/events/SDL_windowevents.c Mon May 29 04:04:35 2006 +0000 @@ -27,8 +27,8 @@ #include "SDL_events_c.h" int -SDL_PrivateWindowEvent (SDL_WindowID windowID, Uint8 windowevent, int data1, - int data2) +SDL_PrivateWindowEvent(SDL_WindowID windowID, Uint8 windowevent, int data1, + int data2) { int posted; @@ -43,7 +43,7 @@ event.window.windowID = windowID; if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) { posted = 1; - SDL_PushEvent (&event); + SDL_PushEvent(&event); } } return (posted); diff -r 1fddae038bc8 -r 4da1ee79c9af src/file/SDL_rwops.c --- a/src/file/SDL_rwops.c Mon May 29 03:53:21 2006 +0000 +++ b/src/file/SDL_rwops.c Mon May 29 04:04:35 2006 +0000 @@ -44,7 +44,7 @@ #endif static int SDLCALL -win32_file_open (SDL_RWops * context, const char *filename, const char *mode) +win32_file_open(SDL_RWops * context, const char *filename, const char *mode) { #ifndef _WIN32_WCE UINT old_error_mode; @@ -66,12 +66,12 @@ /* "a+"= append + read, file may not exist */ /* "w+" = read, write, truncate. file may not exist */ - must_exist = (SDL_strchr (mode, 'r') != NULL) ? OPEN_EXISTING : 0; - truncate = (SDL_strchr (mode, 'w') != NULL) ? CREATE_ALWAYS : 0; - r_right = (SDL_strchr (mode, '+') != NULL + must_exist = (SDL_strchr(mode, 'r') != NULL) ? OPEN_EXISTING : 0; + truncate = (SDL_strchr(mode, 'w') != NULL) ? CREATE_ALWAYS : 0; + r_right = (SDL_strchr(mode, '+') != NULL || must_exist) ? GENERIC_READ : 0; - a_mode = (SDL_strchr (mode, 'a') != NULL) ? OPEN_ALWAYS : 0; - w_right = (a_mode || SDL_strchr (mode, '+') + a_mode = (SDL_strchr(mode, 'a') != NULL) ? OPEN_ALWAYS : 0; + w_right = (a_mode || SDL_strchr(mode, '+') || truncate) ? GENERIC_WRITE : 0; if (!r_right && !w_right) /* inconsistent mode */ @@ -79,37 +79,37 @@ #ifdef _WIN32_WCE { - size_t size = SDL_strlen (filename) + 1; - wchar_t *filenameW = SDL_stack_alloc (wchar_t, size); + size_t size = SDL_strlen(filename) + 1; + wchar_t *filenameW = SDL_stack_alloc(wchar_t, size); - if (MultiByteToWideChar (CP_UTF8, 0, filename, -1, filenameW, size) == + if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, size) == 0) { - SDL_SetError ("Unable to convert filename to Unicode"); - SDL_stack_free (filenameW); + SDL_SetError("Unable to convert filename to Unicode"); + SDL_stack_free(filenameW); return -1; } - h = CreateFile (filenameW, (w_right | r_right), - (w_right) ? 0 : FILE_SHARE_READ, NULL, - (must_exist | truncate | a_mode), - FILE_ATTRIBUTE_NORMAL, NULL); - SDL_stack_free (filenameW); + h = CreateFile(filenameW, (w_right | r_right), + (w_right) ? 0 : FILE_SHARE_READ, NULL, + (must_exist | truncate | a_mode), + FILE_ATTRIBUTE_NORMAL, NULL); + SDL_stack_free(filenameW); } #else /* Do not open a dialog box if failure */ old_error_mode = - SetErrorMode (SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); + SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); - h = CreateFile (filename, (w_right | r_right), - (w_right) ? 0 : FILE_SHARE_READ, NULL, - (must_exist | truncate | a_mode), FILE_ATTRIBUTE_NORMAL, - NULL); + h = CreateFile(filename, (w_right | r_right), + (w_right) ? 0 : FILE_SHARE_READ, NULL, + (must_exist | truncate | a_mode), FILE_ATTRIBUTE_NORMAL, + NULL); /* restore old behaviour */ - SetErrorMode (old_error_mode); + SetErrorMode(old_error_mode); #endif /* _WIN32_WCE */ if (h == INVALID_HANDLE_VALUE) { - SDL_SetError ("Couldn't open %s", filename); + SDL_SetError("Couldn't open %s", filename); return -2; /* failed (CreateFile) */ } context->hidden.win32io.h = h; @@ -118,13 +118,13 @@ return 0; /* ok */ } static int SDLCALL -win32_file_seek (SDL_RWops * context, int offset, int whence) +win32_file_seek(SDL_RWops * context, int offset, int whence) { DWORD win32whence; int file_pos; if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE) { - SDL_SetError ("win32_file_seek: invalid context/file not opened"); + SDL_SetError("win32_file_seek: invalid context/file not opened"); return -1; } @@ -139,21 +139,21 @@ win32whence = FILE_END; break; default: - SDL_SetError ("win32_file_seek: Unknown value for 'whence'"); + SDL_SetError("win32_file_seek: Unknown value for 'whence'"); return -1; } file_pos = - SetFilePointer (context->hidden.win32io.h, offset, NULL, win32whence); + SetFilePointer(context->hidden.win32io.h, offset, NULL, win32whence); if (file_pos != INVALID_SET_FILE_POINTER) return file_pos; /* success */ - SDL_Error (SDL_EFSEEK); + SDL_Error(SDL_EFSEEK); return -1; /* error */ } static int SDLCALL -win32_file_read (SDL_RWops * context, void *ptr, int size, int maxnum) +win32_file_read(SDL_RWops * context, void *ptr, int size, int maxnum) { int total_bytes; @@ -167,14 +167,14 @@ if (!ReadFile (context->hidden.win32io.h, ptr, total_bytes, &byte_read, NULL)) { - SDL_Error (SDL_EFREAD); + SDL_Error(SDL_EFREAD); return 0; } nread = byte_read / size; return nread; } static int SDLCALL -win32_file_write (SDL_RWops * context, const void *ptr, int size, int num) +win32_file_write(SDL_RWops * context, const void *ptr, int size, int num) { int total_bytes; @@ -188,16 +188,16 @@ /* if in append mode, we must go to the EOF before write */ if (context->hidden.win32io.append) { - if (SetFilePointer (context->hidden.win32io.h, 0L, NULL, FILE_END) + if (SetFilePointer(context->hidden.win32io.h, 0L, NULL, FILE_END) == INVALID_SET_FILE_POINTER) { - SDL_Error (SDL_EFWRITE); + SDL_Error(SDL_EFWRITE); return 0; } } if (!WriteFile (context->hidden.win32io.h, ptr, total_bytes, &byte_written, NULL)) { - SDL_Error (SDL_EFWRITE); + SDL_Error(SDL_EFWRITE); return 0; } @@ -205,15 +205,15 @@ return nwritten; } static int SDLCALL -win32_file_close (SDL_RWops * context) +win32_file_close(SDL_RWops * context) { if (context) { if (context->hidden.win32io.h != INVALID_HANDLE_VALUE) { - CloseHandle (context->hidden.win32io.h); + CloseHandle(context->hidden.win32io.h); context->hidden.win32io.h = INVALID_HANDLE_VALUE; /* to be sure */ } - SDL_FreeRW (context); + SDL_FreeRW(context); } return (0); } @@ -224,46 +224,46 @@ /* Functions to read/write stdio file pointers */ static int SDLCALL -stdio_seek (SDL_RWops * context, int offset, int whence) +stdio_seek(SDL_RWops * context, int offset, int whence) { - if (fseek (context->hidden.stdio.fp, offset, whence) == 0) { - return (ftell (context->hidden.stdio.fp)); + if (fseek(context->hidden.stdio.fp, offset, whence) == 0) { + return (ftell(context->hidden.stdio.fp)); } else { - SDL_Error (SDL_EFSEEK); + SDL_Error(SDL_EFSEEK); return (-1); } } static int SDLCALL -stdio_read (SDL_RWops * context, void *ptr, int size, int maxnum) +stdio_read(SDL_RWops * context, void *ptr, int size, int maxnum) { size_t nread; - nread = fread (ptr, size, maxnum, context->hidden.stdio.fp); - if (nread == 0 && ferror (context->hidden.stdio.fp)) { - SDL_Error (SDL_EFREAD); + nread = fread(ptr, size, maxnum, context->hidden.stdio.fp); + if (nread == 0 && ferror(context->hidden.stdio.fp)) { + SDL_Error(SDL_EFREAD); } return (nread); } static int SDLCALL -stdio_write (SDL_RWops * context, const void *ptr, int size, int num) +stdio_write(SDL_RWops * context, const void *ptr, int size, int num) { size_t nwrote; - nwrote = fwrite (ptr, size, num, context->hidden.stdio.fp); - if (nwrote == 0 && ferror (context->hidden.stdio.fp)) { - SDL_Error (SDL_EFWRITE); + nwrote = fwrite(ptr, size, num, context->hidden.stdio.fp); + if (nwrote == 0 && ferror(context->hidden.stdio.fp)) { + SDL_Error(SDL_EFWRITE); } return (nwrote); } static int SDLCALL -stdio_close (SDL_RWops * context) +stdio_close(SDL_RWops * context) { if (context) { if (context->hidden.stdio.autoclose) { /* WARNING: Check the return value here! */ - fclose (context->hidden.stdio.fp); + fclose(context->hidden.stdio.fp); } - SDL_FreeRW (context); + SDL_FreeRW(context); } return (0); } @@ -272,7 +272,7 @@ /* Functions to read/write memory pointers */ static int SDLCALL -mem_seek (SDL_RWops * context, int offset, int whence) +mem_seek(SDL_RWops * context, int offset, int whence) { Uint8 *newpos; @@ -287,7 +287,7 @@ newpos = context->hidden.mem.stop + offset; break; default: - SDL_SetError ("Unknown value for 'whence'"); + SDL_SetError("Unknown value for 'whence'"); return (-1); } if (newpos < context->hidden.mem.base) { @@ -300,7 +300,7 @@ return (context->hidden.mem.here - context->hidden.mem.base); } static int SDLCALL -mem_read (SDL_RWops * context, void *ptr, int size, int maxnum) +mem_read(SDL_RWops * context, void *ptr, int size, int maxnum) { size_t total_bytes; size_t mem_available; @@ -316,32 +316,32 @@ total_bytes = mem_available; } - SDL_memcpy (ptr, context->hidden.mem.here, total_bytes); + SDL_memcpy(ptr, context->hidden.mem.here, total_bytes); context->hidden.mem.here += total_bytes; return (total_bytes / size); } static int SDLCALL -mem_write (SDL_RWops * context, const void *ptr, int size, int num) +mem_write(SDL_RWops * context, const void *ptr, int size, int num) { if ((context->hidden.mem.here + (num * size)) > context->hidden.mem.stop) { num = (context->hidden.mem.stop - context->hidden.mem.here) / size; } - SDL_memcpy (context->hidden.mem.here, ptr, num * size); + SDL_memcpy(context->hidden.mem.here, ptr, num * size); context->hidden.mem.here += num * size; return (num); } static int SDLCALL -mem_writeconst (SDL_RWops * context, const void *ptr, int size, int num) +mem_writeconst(SDL_RWops * context, const void *ptr, int size, int num) { - SDL_SetError ("Can't write to read-only memory"); + SDL_SetError("Can't write to read-only memory"); return (-1); } static int SDLCALL -mem_close (SDL_RWops * context) +mem_close(SDL_RWops * context) { if (context) { - SDL_FreeRW (context); + SDL_FreeRW(context); } return (0); } @@ -355,10 +355,10 @@ * name; return malloced string */ static char * -unix_to_mac (const char *file) +unix_to_mac(const char *file) { - int flen = SDL_strlen (file); - char *path = SDL_malloc (flen + 2); + int flen = SDL_strlen(file); + char *path = SDL_malloc(flen + 2); const char *src = file; char *dst = path; if (*src == '/') { @@ -370,7 +370,7 @@ *dst++ = ':'; /* relative paths begin with ':' */ } while (src < file + flen) { - const char *end = SDL_strchr (src, '/'); + const char *end = SDL_strchr(src, '/'); int len; if (!end) end = file + flen; /* last component */ @@ -381,7 +381,7 @@ if (len == 2 && src[0] == '.' && src[1] == '.') { /* replace .. with the empty string */ } else { - SDL_memcpy (dst, src, len); + SDL_memcpy(dst, src, len); dst += len; } if (end < file + flen) @@ -395,23 +395,23 @@ #endif /* __MACOS__ */ SDL_RWops * -SDL_RWFromFile (const char *file, const char *mode) +SDL_RWFromFile(const char *file, const char *mode) { SDL_RWops *rwops = NULL; #ifdef HAVE_STDIO_H FILE *fp = NULL; #endif if (!file || !*file || !mode || !*mode) { - SDL_SetError ("SDL_RWFromFile(): No file or no mode specified"); + SDL_SetError("SDL_RWFromFile(): No file or no mode specified"); return NULL; } #if defined(__WIN32__) - rwops = SDL_AllocRW (); + rwops = SDL_AllocRW(); if (!rwops) return NULL; /* SDL_SetError already setup by SDL_AllocRW() */ rwops->hidden.win32io.h = INVALID_HANDLE_VALUE; - if (win32_file_open (rwops, file, mode)) { - SDL_FreeRW (rwops); + if (win32_file_open(rwops, file, mode)) { + SDL_FreeRW(rwops); return NULL; } rwops->seek = win32_file_seek; @@ -423,20 +423,20 @@ #ifdef __MACOS__ { - char *mpath = unix_to_mac (file); - fp = fopen (mpath, mode); - SDL_free (mpath); + char *mpath = unix_to_mac(file); + fp = fopen(mpath, mode); + SDL_free(mpath); } #else - fp = fopen (file, mode); + fp = fopen(file, mode); #endif if (fp == NULL) { - SDL_SetError ("Couldn't open %s", file); + SDL_SetError("Couldn't open %s", file); } else { - rwops = SDL_RWFromFP (fp, 1); + rwops = SDL_RWFromFP(fp, 1); } #else - SDL_SetError ("SDL not compiled with stdio support"); + SDL_SetError("SDL not compiled with stdio support"); #endif /* !HAVE_STDIO_H */ return (rwops); @@ -444,11 +444,11 @@ #ifdef HAVE_STDIO_H SDL_RWops * -SDL_RWFromFP (FILE * fp, int autoclose) +SDL_RWFromFP(FILE * fp, int autoclose) { SDL_RWops *rwops = NULL; - rwops = SDL_AllocRW (); + rwops = SDL_AllocRW(); if (rwops != NULL) { rwops->seek = stdio_seek; rwops->read = stdio_read; @@ -462,11 +462,11 @@ #endif /* HAVE_STDIO_H */ SDL_RWops * -SDL_RWFromMem (void *mem, int size) +SDL_RWFromMem(void *mem, int size) { SDL_RWops *rwops; - rwops = SDL_AllocRW (); + rwops = SDL_AllocRW(); if (rwops != NULL) { rwops->seek = mem_seek; rwops->read = mem_read; @@ -480,11 +480,11 @@ } SDL_RWops * -SDL_RWFromConstMem (const void *mem, int size) +SDL_RWFromConstMem(const void *mem, int size) { SDL_RWops *rwops; - rwops = SDL_AllocRW (); + rwops = SDL_AllocRW(); if (rwops != NULL) { rwops->seek = mem_seek; rwops->read = mem_read; @@ -498,119 +498,119 @@ } SDL_RWops * -SDL_AllocRW (void) +SDL_AllocRW(void) { SDL_RWops *area; - area = (SDL_RWops *) SDL_malloc (sizeof *area); + area = (SDL_RWops *) SDL_malloc(sizeof *area); if (area == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return (area); } void -SDL_FreeRW (SDL_RWops * area) +SDL_FreeRW(SDL_RWops * area) { - SDL_free (area); + SDL_free(area); } /* Functions for dynamically reading and writing endian-specific values */ Uint16 -SDL_ReadLE16 (SDL_RWops * src) +SDL_ReadLE16(SDL_RWops * src) { Uint16 value; - SDL_RWread (src, &value, (sizeof value), 1); - return (SDL_SwapLE16 (value)); + SDL_RWread(src, &value, (sizeof value), 1); + return (SDL_SwapLE16(value)); } Uint16 -SDL_ReadBE16 (SDL_RWops * src) +SDL_ReadBE16(SDL_RWops * src) { Uint16 value; - SDL_RWread (src, &value, (sizeof value), 1); - return (SDL_SwapBE16 (value)); + SDL_RWread(src, &value, (sizeof value), 1); + return (SDL_SwapBE16(value)); } Uint32 -SDL_ReadLE32 (SDL_RWops * src) +SDL_ReadLE32(SDL_RWops * src) { Uint32 value; - SDL_RWread (src, &value, (sizeof value), 1); - return (SDL_SwapLE32 (value)); + SDL_RWread(src, &value, (sizeof value), 1); + return (SDL_SwapLE32(value)); } Uint32 -SDL_ReadBE32 (SDL_RWops * src) +SDL_ReadBE32(SDL_RWops * src) { Uint32 value; - SDL_RWread (src, &value, (sizeof value), 1); - return (SDL_SwapBE32 (value)); + SDL_RWread(src, &value, (sizeof value), 1); + return (SDL_SwapBE32(value)); } Uint64 -SDL_ReadLE64 (SDL_RWops * src) +SDL_ReadLE64(SDL_RWops * src) { Uint64 value; - SDL_RWread (src, &value, (sizeof value), 1); - return (SDL_SwapLE64 (value)); + SDL_RWread(src, &value, (sizeof value), 1); + return (SDL_SwapLE64(value)); } Uint64 -SDL_ReadBE64 (SDL_RWops * src) +SDL_ReadBE64(SDL_RWops * src) { Uint64 value; - SDL_RWread (src, &value, (sizeof value), 1); - return (SDL_SwapBE64 (value)); + SDL_RWread(src, &value, (sizeof value), 1); + return (SDL_SwapBE64(value)); } int -SDL_WriteLE16 (SDL_RWops * dst, Uint16 value) +SDL_WriteLE16(SDL_RWops * dst, Uint16 value) { - value = SDL_SwapLE16 (value); - return (SDL_RWwrite (dst, &value, (sizeof value), 1)); + value = SDL_SwapLE16(value); + return (SDL_RWwrite(dst, &value, (sizeof value), 1)); } int -SDL_WriteBE16 (SDL_RWops * dst, Uint16 value) +SDL_WriteBE16(SDL_RWops * dst, Uint16 value) { - value = SDL_SwapBE16 (value); - return (SDL_RWwrite (dst, &value, (sizeof value), 1)); + value = SDL_SwapBE16(value); + return (SDL_RWwrite(dst, &value, (sizeof value), 1)); } int -SDL_WriteLE32 (SDL_RWops * dst, Uint32 value) +SDL_WriteLE32(SDL_RWops * dst, Uint32 value) { - value = SDL_SwapLE32 (value); - return (SDL_RWwrite (dst, &value, (sizeof value), 1)); + value = SDL_SwapLE32(value); + return (SDL_RWwrite(dst, &value, (sizeof value), 1)); } int -SDL_WriteBE32 (SDL_RWops * dst, Uint32 value) +SDL_WriteBE32(SDL_RWops * dst, Uint32 value) { - value = SDL_SwapBE32 (value); - return (SDL_RWwrite (dst, &value, (sizeof value), 1)); + value = SDL_SwapBE32(value); + return (SDL_RWwrite(dst, &value, (sizeof value), 1)); } int -SDL_WriteLE64 (SDL_RWops * dst, Uint64 value) +SDL_WriteLE64(SDL_RWops * dst, Uint64 value) { - value = SDL_SwapLE64 (value); - return (SDL_RWwrite (dst, &value, (sizeof value), 1)); + value = SDL_SwapLE64(value); + return (SDL_RWwrite(dst, &value, (sizeof value), 1)); } int -SDL_WriteBE64 (SDL_RWops * dst, Uint64 value) +SDL_WriteBE64(SDL_RWops * dst, Uint64 value) { - value = SDL_SwapBE64 (value); - return (SDL_RWwrite (dst, &value, (sizeof value), 1)); + value = SDL_SwapBE64(value); + return (SDL_RWwrite(dst, &value, (sizeof value), 1)); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/hermes/HeadMMX.h --- a/src/hermes/HeadMMX.h Mon May 29 03:53:21 2006 +0000 +++ b/src/hermes/HeadMMX.h Mon May 29 04:04:35 2006 +0000 @@ -23,21 +23,21 @@ { #endif - void STACKCALL ConvertMMX (HermesConverterInterface *); + void STACKCALL ConvertMMX(HermesConverterInterface *); - void STACKCALL ClearMMX_32 (HermesClearInterface *); - void STACKCALL ClearMMX_24 (HermesClearInterface *); - void STACKCALL ClearMMX_16 (HermesClearInterface *); - void STACKCALL ClearMMX_8 (HermesClearInterface *); + void STACKCALL ClearMMX_32(HermesClearInterface *); + void STACKCALL ClearMMX_24(HermesClearInterface *); + void STACKCALL ClearMMX_16(HermesClearInterface *); + void STACKCALL ClearMMX_8(HermesClearInterface *); - void ConvertMMXpII32_24RGB888 (); - void ConvertMMXpII32_16RGB565 (); - void ConvertMMXpII32_16BGR565 (); - void ConvertMMXpII32_16RGB555 (); - void ConvertMMXpII32_16BGR565 (); - void ConvertMMXpII32_16BGR555 (); + void ConvertMMXpII32_24RGB888(); + void ConvertMMXpII32_16RGB565(); + void ConvertMMXpII32_16BGR565(); + void ConvertMMXpII32_16RGB555(); + void ConvertMMXpII32_16BGR565(); + void ConvertMMXpII32_16BGR555(); - void ConvertMMXp32_16RGB555 (); + void ConvertMMXp32_16RGB555(); #ifdef __cplusplus } @@ -53,12 +53,12 @@ { #endif - extern void _ConvertMMX (HermesConverterInterface *); - extern void _ConvertMMXpII32_24RGB888 (); - extern void _ConvertMMXpII32_16RGB565 (); - extern void _ConvertMMXpII32_16BGR565 (); - extern void _ConvertMMXpII32_16RGB555 (); - extern void _ConvertMMXpII32_16BGR555 (); + extern void _ConvertMMX(HermesConverterInterface *); + extern void _ConvertMMXpII32_24RGB888(); + extern void _ConvertMMXpII32_16RGB565(); + extern void _ConvertMMXpII32_16BGR565(); + extern void _ConvertMMXpII32_16RGB555(); + extern void _ConvertMMXpII32_16BGR555(); #define ConvertMMX _ConvertMMX #define ConvertMMXpII32_24RGB888 _ConvertMMXpII32_24RGB888 diff -r 1fddae038bc8 -r 4da1ee79c9af src/hermes/HeadX86.h --- a/src/hermes/HeadX86.h Mon May 29 03:53:21 2006 +0000 +++ b/src/hermes/HeadX86.h Mon May 29 04:04:35 2006 +0000 @@ -22,44 +22,44 @@ #endif - void STACKCALL ConvertX86 (HermesConverterInterface *); - void STACKCALL ClearX86_32 (HermesClearInterface *); - void STACKCALL ClearX86_24 (HermesClearInterface *); - void STACKCALL ClearX86_16 (HermesClearInterface *); - void STACKCALL ClearX86_8 (HermesClearInterface *); + void STACKCALL ConvertX86(HermesConverterInterface *); + void STACKCALL ClearX86_32(HermesClearInterface *); + void STACKCALL ClearX86_24(HermesClearInterface *); + void STACKCALL ClearX86_16(HermesClearInterface *); + void STACKCALL ClearX86_8(HermesClearInterface *); - int STACKCALL Hermes_X86_CPU (); + int STACKCALL Hermes_X86_CPU(); - void ConvertX86p32_32BGR888 (); - void ConvertX86p32_32RGBA888 (); - void ConvertX86p32_32BGRA888 (); - void ConvertX86p32_24RGB888 (); - void ConvertX86p32_24BGR888 (); - void ConvertX86p32_16RGB565 (); - void ConvertX86p32_16BGR565 (); - void ConvertX86p32_16RGB555 (); - void ConvertX86p32_16BGR555 (); - void ConvertX86p32_8RGB332 (); + void ConvertX86p32_32BGR888(); + void ConvertX86p32_32RGBA888(); + void ConvertX86p32_32BGRA888(); + void ConvertX86p32_24RGB888(); + void ConvertX86p32_24BGR888(); + void ConvertX86p32_16RGB565(); + void ConvertX86p32_16BGR565(); + void ConvertX86p32_16RGB555(); + void ConvertX86p32_16BGR555(); + void ConvertX86p32_8RGB332(); - void ConvertX86p16_32RGB888 (); - void ConvertX86p16_32BGR888 (); - void ConvertX86p16_32RGBA888 (); - void ConvertX86p16_32BGRA888 (); - void ConvertX86p16_24RGB888 (); - void ConvertX86p16_24BGR888 (); - void ConvertX86p16_16BGR565 (); - void ConvertX86p16_16RGB555 (); - void ConvertX86p16_16BGR555 (); - void ConvertX86p16_8RGB332 (); + void ConvertX86p16_32RGB888(); + void ConvertX86p16_32BGR888(); + void ConvertX86p16_32RGBA888(); + void ConvertX86p16_32BGRA888(); + void ConvertX86p16_24RGB888(); + void ConvertX86p16_24BGR888(); + void ConvertX86p16_16BGR565(); + void ConvertX86p16_16RGB555(); + void ConvertX86p16_16BGR555(); + void ConvertX86p16_8RGB332(); - void CopyX86p_4byte (); - void CopyX86p_3byte (); - void CopyX86p_2byte (); - void CopyX86p_1byte (); + void CopyX86p_4byte(); + void CopyX86p_3byte(); + void CopyX86p_2byte(); + void CopyX86p_1byte(); - void ConvertX86pI8_32 (); - void ConvertX86pI8_24 (); - void ConvertX86pI8_16 (); + void ConvertX86pI8_32(); + void ConvertX86pI8_24(); + void ConvertX86pI8_16(); extern int ConvertX86p16_32RGB888_LUT_X86[512]; extern int ConvertX86p16_32BGR888_LUT_X86[512]; @@ -81,25 +81,25 @@ { #endif - extern int _Hermes_X86_CPU (); + extern int _Hermes_X86_CPU(); - extern void _ConvertX86 (HermesConverterInterface *); + extern void _ConvertX86(HermesConverterInterface *); - extern void _ConvertX86p32_32BGR888 (); - extern void _ConvertX86p32_32RGBA888 (); - extern void _ConvertX86p32_32BGRA888 (); - extern void _ConvertX86p32_24RGB888 (); - extern void _ConvertX86p32_24BGR888 (); - extern void _ConvertX86p32_16RGB565 (); - extern void _ConvertX86p32_16BGR565 (); - extern void _ConvertX86p32_16RGB555 (); - extern void _ConvertX86p32_16BGR555 (); - extern void _ConvertX86p32_8RGB332 (); + extern void _ConvertX86p32_32BGR888(); + extern void _ConvertX86p32_32RGBA888(); + extern void _ConvertX86p32_32BGRA888(); + extern void _ConvertX86p32_24RGB888(); + extern void _ConvertX86p32_24BGR888(); + extern void _ConvertX86p32_16RGB565(); + extern void _ConvertX86p32_16BGR565(); + extern void _ConvertX86p32_16RGB555(); + extern void _ConvertX86p32_16BGR555(); + extern void _ConvertX86p32_8RGB332(); - extern void _ConvertX86p16_16BGR565 (); - extern void _ConvertX86p16_16RGB555 (); - extern void _ConvertX86p16_16BGR555 (); - extern void _ConvertX86p16_8RGB332 (); + extern void _ConvertX86p16_16BGR565(); + extern void _ConvertX86p16_16RGB555(); + extern void _ConvertX86p16_16BGR555(); + extern void _ConvertX86p16_8RGB332(); #define Hermes_X86_CPU _Hermes_X86_CPU diff -r 1fddae038bc8 -r 4da1ee79c9af src/joystick/SDL_joystick.c --- a/src/joystick/SDL_joystick.c Mon May 29 03:53:21 2006 +0000 +++ b/src/joystick/SDL_joystick.c Mon May 29 04:04:35 2006 +0000 @@ -41,20 +41,20 @@ static SDL_Joystick *default_joystick = NULL; int -SDL_JoystickInit (void) +SDL_JoystickInit(void) { int arraylen; int status; SDL_numjoysticks = 0; - status = SDL_SYS_JoystickInit (); + status = SDL_SYS_JoystickInit(); if (status >= 0) { - arraylen = (status + 1) * sizeof (*SDL_joysticks); - SDL_joysticks = (SDL_Joystick **) SDL_malloc (arraylen); + arraylen = (status + 1) * sizeof(*SDL_joysticks); + SDL_joysticks = (SDL_Joystick **) SDL_malloc(arraylen); if (SDL_joysticks == NULL) { SDL_numjoysticks = 0; } else { - SDL_memset (SDL_joysticks, 0, arraylen); + SDL_memset(SDL_joysticks, 0, arraylen); SDL_numjoysticks = status; } status = 0; @@ -67,7 +67,7 @@ * Count the number of joysticks attached to the system */ int -SDL_NumJoysticks (void) +SDL_NumJoysticks(void) { return SDL_numjoysticks; } @@ -76,13 +76,13 @@ * Get the implementation dependent name of a joystick */ const char * -SDL_JoystickName (int device_index) +SDL_JoystickName(int device_index) { if ((device_index < 0) || (device_index >= SDL_numjoysticks)) { - SDL_SetError ("There are %d joysticks available", SDL_numjoysticks); + SDL_SetError("There are %d joysticks available", SDL_numjoysticks); return (NULL); } - return (SDL_SYS_JoystickName (device_index)); + return (SDL_SYS_JoystickName(device_index)); } /* @@ -93,13 +93,13 @@ * This function returns a joystick identifier, or NULL if an error occurred. */ SDL_Joystick * -SDL_JoystickOpen (int device_index) +SDL_JoystickOpen(int device_index) { int i; SDL_Joystick *joystick; if ((device_index < 0) || (device_index >= SDL_numjoysticks)) { - SDL_SetError ("There are %d joysticks available", SDL_numjoysticks); + SDL_SetError("There are %d joysticks available", SDL_numjoysticks); return (NULL); } @@ -113,64 +113,64 @@ } /* Create and initialize the joystick */ - joystick = (SDL_Joystick *) SDL_malloc ((sizeof *joystick)); + joystick = (SDL_Joystick *) SDL_malloc((sizeof *joystick)); if (joystick != NULL) { - SDL_memset (joystick, 0, (sizeof *joystick)); + SDL_memset(joystick, 0, (sizeof *joystick)); joystick->index = device_index; - if (SDL_SYS_JoystickOpen (joystick) < 0) { - SDL_free (joystick); + if (SDL_SYS_JoystickOpen(joystick) < 0) { + SDL_free(joystick); joystick = NULL; } else { if (joystick->naxes > 0) { joystick->axes = (Sint16 *) SDL_malloc - (joystick->naxes * sizeof (Sint16)); + (joystick->naxes * sizeof(Sint16)); } if (joystick->nhats > 0) { joystick->hats = (Uint8 *) SDL_malloc - (joystick->nhats * sizeof (Uint8)); + (joystick->nhats * sizeof(Uint8)); } if (joystick->nballs > 0) { joystick->balls = (struct balldelta *) SDL_malloc - (joystick->nballs * sizeof (*joystick->balls)); + (joystick->nballs * sizeof(*joystick->balls)); } if (joystick->nbuttons > 0) { joystick->buttons = (Uint8 *) SDL_malloc - (joystick->nbuttons * sizeof (Uint8)); + (joystick->nbuttons * sizeof(Uint8)); } if (((joystick->naxes > 0) && !joystick->axes) || ((joystick->nhats > 0) && !joystick->hats) || ((joystick->nballs > 0) && !joystick->balls) || ((joystick->nbuttons > 0) && !joystick->buttons)) { - SDL_OutOfMemory (); - SDL_JoystickClose (joystick); + SDL_OutOfMemory(); + SDL_JoystickClose(joystick); joystick = NULL; } if (joystick->axes) { - SDL_memset (joystick->axes, 0, - joystick->naxes * sizeof (Sint16)); + SDL_memset(joystick->axes, 0, + joystick->naxes * sizeof(Sint16)); } if (joystick->hats) { - SDL_memset (joystick->hats, 0, - joystick->nhats * sizeof (Uint8)); + SDL_memset(joystick->hats, 0, + joystick->nhats * sizeof(Uint8)); } if (joystick->balls) { - SDL_memset (joystick->balls, 0, - joystick->nballs * sizeof (*joystick->balls)); + SDL_memset(joystick->balls, 0, + joystick->nballs * sizeof(*joystick->balls)); } if (joystick->buttons) { - SDL_memset (joystick->buttons, 0, - joystick->nbuttons * sizeof (Uint8)); + SDL_memset(joystick->buttons, 0, + joystick->nbuttons * sizeof(Uint8)); } } } if (joystick) { /* Add joystick to list */ ++joystick->ref_count; - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); for (i = 0; SDL_joysticks[i]; ++i) /* Skip to next joystick */ ; SDL_joysticks[i] = joystick; - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); } return (joystick); } @@ -179,7 +179,7 @@ * Returns 1 if the joystick has been opened, or 0 if it has not. */ int -SDL_JoystickOpened (int device_index) +SDL_JoystickOpened(int device_index) { int i, opened; @@ -194,7 +194,7 @@ } static int -ValidJoystick (SDL_Joystick ** joystick) +ValidJoystick(SDL_Joystick ** joystick) { int valid; @@ -202,7 +202,7 @@ *joystick = default_joystick; } if (*joystick == NULL) { - SDL_SetError ("Joystick hasn't been opened yet"); + SDL_SetError("Joystick hasn't been opened yet"); valid = 0; } else { valid = 1; @@ -214,9 +214,9 @@ * Get the device index of an opened joystick. */ int -SDL_JoystickIndex (SDL_Joystick * joystick) +SDL_JoystickIndex(SDL_Joystick * joystick) { - if (!ValidJoystick (&joystick)) { + if (!ValidJoystick(&joystick)) { return (-1); } return (joystick->index); @@ -226,9 +226,9 @@ * Get the number of multi-dimensional axis controls on a joystick */ int -SDL_JoystickNumAxes (SDL_Joystick * joystick) +SDL_JoystickNumAxes(SDL_Joystick * joystick) { - if (!ValidJoystick (&joystick)) { + if (!ValidJoystick(&joystick)) { return (-1); } return (joystick->naxes); @@ -238,9 +238,9 @@ * Get the number of hats on a joystick */ int -SDL_JoystickNumHats (SDL_Joystick * joystick) +SDL_JoystickNumHats(SDL_Joystick * joystick) { - if (!ValidJoystick (&joystick)) { + if (!ValidJoystick(&joystick)) { return (-1); } return (joystick->nhats); @@ -250,9 +250,9 @@ * Get the number of trackballs on a joystick */ int -SDL_JoystickNumBalls (SDL_Joystick * joystick) +SDL_JoystickNumBalls(SDL_Joystick * joystick) { - if (!ValidJoystick (&joystick)) { + if (!ValidJoystick(&joystick)) { return (-1); } return (joystick->nballs); @@ -262,9 +262,9 @@ * Get the number of buttons on a joystick */ int -SDL_JoystickNumButtons (SDL_Joystick * joystick) +SDL_JoystickNumButtons(SDL_Joystick * joystick) { - if (!ValidJoystick (&joystick)) { + if (!ValidJoystick(&joystick)) { return (-1); } return (joystick->nbuttons); @@ -274,17 +274,17 @@ * Get the current state of an axis control on a joystick */ Sint16 -SDL_JoystickGetAxis (SDL_Joystick * joystick, int axis) +SDL_JoystickGetAxis(SDL_Joystick * joystick, int axis) { Sint16 state; - if (!ValidJoystick (&joystick)) { + if (!ValidJoystick(&joystick)) { return (0); } if (axis < joystick->naxes) { state = joystick->axes[axis]; } else { - SDL_SetError ("Joystick only has %d axes", joystick->naxes); + SDL_SetError("Joystick only has %d axes", joystick->naxes); state = 0; } return (state); @@ -294,17 +294,17 @@ * Get the current state of a hat on a joystick */ Uint8 -SDL_JoystickGetHat (SDL_Joystick * joystick, int hat) +SDL_JoystickGetHat(SDL_Joystick * joystick, int hat) { Uint8 state; - if (!ValidJoystick (&joystick)) { + if (!ValidJoystick(&joystick)) { return (0); } if (hat < joystick->nhats) { state = joystick->hats[hat]; } else { - SDL_SetError ("Joystick only has %d hats", joystick->nhats); + SDL_SetError("Joystick only has %d hats", joystick->nhats); state = 0; } return (state); @@ -314,11 +314,11 @@ * Get the ball axis change since the last poll */ int -SDL_JoystickGetBall (SDL_Joystick * joystick, int ball, int *dx, int *dy) +SDL_JoystickGetBall(SDL_Joystick * joystick, int ball, int *dx, int *dy) { int retval; - if (!ValidJoystick (&joystick)) { + if (!ValidJoystick(&joystick)) { return (-1); } @@ -333,7 +333,7 @@ joystick->balls[ball].dx = 0; joystick->balls[ball].dy = 0; } else { - SDL_SetError ("Joystick only has %d balls", joystick->nballs); + SDL_SetError("Joystick only has %d balls", joystick->nballs); retval = -1; } return (retval); @@ -343,17 +343,17 @@ * Get the current state of a button on a joystick */ Uint8 -SDL_JoystickGetButton (SDL_Joystick * joystick, int button) +SDL_JoystickGetButton(SDL_Joystick * joystick, int button) { Uint8 state; - if (!ValidJoystick (&joystick)) { + if (!ValidJoystick(&joystick)) { return (0); } if (button < joystick->nbuttons) { state = joystick->buttons[button]; } else { - SDL_SetError ("Joystick only has %d buttons", joystick->nbuttons); + SDL_SetError("Joystick only has %d buttons", joystick->nbuttons); state = 0; } return (state); @@ -363,11 +363,11 @@ * Close a joystick previously opened with SDL_JoystickOpen() */ void -SDL_JoystickClose (SDL_Joystick * joystick) +SDL_JoystickClose(SDL_Joystick * joystick) { int i; - if (!ValidJoystick (&joystick)) { + if (!ValidJoystick(&joystick)) { return; } @@ -377,53 +377,53 @@ } /* Lock the event queue - prevent joystick polling */ - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); if (joystick == default_joystick) { default_joystick = NULL; } - SDL_SYS_JoystickClose (joystick); + SDL_SYS_JoystickClose(joystick); /* Remove joystick from list */ for (i = 0; SDL_joysticks[i]; ++i) { if (joystick == SDL_joysticks[i]) { - SDL_memcpy (&SDL_joysticks[i], &SDL_joysticks[i + 1], - (SDL_numjoysticks - i) * sizeof (joystick)); + SDL_memcpy(&SDL_joysticks[i], &SDL_joysticks[i + 1], + (SDL_numjoysticks - i) * sizeof(joystick)); break; } } /* Let the event thread keep running */ - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); /* Free the data associated with this joystick */ if (joystick->axes) { - SDL_free (joystick->axes); + SDL_free(joystick->axes); } if (joystick->hats) { - SDL_free (joystick->hats); + SDL_free(joystick->hats); } if (joystick->balls) { - SDL_free (joystick->balls); + SDL_free(joystick->balls); } if (joystick->buttons) { - SDL_free (joystick->buttons); + SDL_free(joystick->buttons); } - SDL_free (joystick); + SDL_free(joystick); } void -SDL_JoystickQuit (void) +SDL_JoystickQuit(void) { /* Stop the event polling */ - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); SDL_numjoysticks = 0; - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); /* Quit the joystick setup */ - SDL_SYS_JoystickQuit (); + SDL_SYS_JoystickQuit(); if (SDL_joysticks) { - SDL_free (SDL_joysticks); + SDL_free(SDL_joysticks); SDL_joysticks = NULL; } } @@ -432,7 +432,7 @@ /* These are global for SDL_sysjoystick.c and SDL_events.c */ int -SDL_PrivateJoystickAxis (SDL_Joystick * joystick, Uint8 axis, Sint16 value) +SDL_PrivateJoystickAxis(SDL_Joystick * joystick, Uint8 axis, Sint16 value) { int posted; @@ -450,7 +450,7 @@ event.jaxis.value = value; if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) { posted = 1; - SDL_PushEvent (&event); + SDL_PushEvent(&event); } } #endif /* !SDL_EVENTS_DISABLED */ @@ -458,7 +458,7 @@ } int -SDL_PrivateJoystickHat (SDL_Joystick * joystick, Uint8 hat, Uint8 value) +SDL_PrivateJoystickHat(SDL_Joystick * joystick, Uint8 hat, Uint8 value) { int posted; @@ -476,7 +476,7 @@ event.jhat.value = value; if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) { posted = 1; - SDL_PushEvent (&event); + SDL_PushEvent(&event); } } #endif /* !SDL_EVENTS_DISABLED */ @@ -484,8 +484,8 @@ } int -SDL_PrivateJoystickBall (SDL_Joystick * joystick, Uint8 ball, - Sint16 xrel, Sint16 yrel) +SDL_PrivateJoystickBall(SDL_Joystick * joystick, Uint8 ball, + Sint16 xrel, Sint16 yrel) { int posted; @@ -505,7 +505,7 @@ event.jball.yrel = yrel; if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) { posted = 1; - SDL_PushEvent (&event); + SDL_PushEvent(&event); } } #endif /* !SDL_EVENTS_DISABLED */ @@ -513,7 +513,7 @@ } int -SDL_PrivateJoystickButton (SDL_Joystick * joystick, Uint8 button, Uint8 state) +SDL_PrivateJoystickButton(SDL_Joystick * joystick, Uint8 button, Uint8 state) { int posted; #if !SDL_EVENTS_DISABLED @@ -544,7 +544,7 @@ event.jbutton.state = state; if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) { posted = 1; - SDL_PushEvent (&event); + SDL_PushEvent(&event); } } #endif /* !SDL_EVENTS_DISABLED */ @@ -552,17 +552,17 @@ } void -SDL_JoystickUpdate (void) +SDL_JoystickUpdate(void) { int i; for (i = 0; SDL_joysticks[i]; ++i) { - SDL_SYS_JoystickUpdate (SDL_joysticks[i]); + SDL_SYS_JoystickUpdate(SDL_joysticks[i]); } } int -SDL_JoystickEventState (int state) +SDL_JoystickEventState(int state) { #if SDL_EVENTS_DISABLED return SDL_IGNORE; @@ -576,16 +576,16 @@ switch (state) { case SDL_QUERY: state = SDL_IGNORE; - for (i = 0; i < SDL_arraysize (event_list); ++i) { - state = SDL_EventState (event_list[i], SDL_QUERY); + for (i = 0; i < SDL_arraysize(event_list); ++i) { + state = SDL_EventState(event_list[i], SDL_QUERY); if (state == SDL_ENABLE) { break; } } break; default: - for (i = 0; i < SDL_arraysize (event_list); ++i) { - SDL_EventState (event_list[i], state); + for (i = 0; i < SDL_arraysize(event_list); ++i) { + SDL_EventState(event_list[i], state); } break; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/joystick/SDL_joystick_c.h --- a/src/joystick/SDL_joystick_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/joystick/SDL_joystick_c.h Mon May 29 04:04:35 2006 +0000 @@ -28,12 +28,12 @@ extern Uint8 SDL_numjoysticks; /* Internal event queueing functions */ -extern int SDL_PrivateJoystickAxis (SDL_Joystick * joystick, - Uint8 axis, Sint16 value); -extern int SDL_PrivateJoystickBall (SDL_Joystick * joystick, - Uint8 ball, Sint16 xrel, Sint16 yrel); -extern int SDL_PrivateJoystickHat (SDL_Joystick * joystick, - Uint8 hat, Uint8 value); -extern int SDL_PrivateJoystickButton (SDL_Joystick * joystick, - Uint8 button, Uint8 state); +extern int SDL_PrivateJoystickAxis(SDL_Joystick * joystick, + Uint8 axis, Sint16 value); +extern int SDL_PrivateJoystickBall(SDL_Joystick * joystick, + Uint8 ball, Sint16 xrel, Sint16 yrel); +extern int SDL_PrivateJoystickHat(SDL_Joystick * joystick, + Uint8 hat, Uint8 value); +extern int SDL_PrivateJoystickButton(SDL_Joystick * joystick, + Uint8 button, Uint8 state); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/joystick/SDL_sysjoystick.h --- a/src/joystick/SDL_sysjoystick.h Mon May 29 03:53:21 2006 +0000 +++ b/src/joystick/SDL_sysjoystick.h Mon May 29 04:04:35 2006 +0000 @@ -57,28 +57,28 @@ * This function should return the number of available joysticks, or -1 * on an unrecoverable fatal error. */ -extern int SDL_SYS_JoystickInit (void); +extern int SDL_SYS_JoystickInit(void); /* Function to get the device-dependent name of a joystick */ -extern const char *SDL_SYS_JoystickName (int index); +extern const char *SDL_SYS_JoystickName(int index); /* 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. */ -extern int SDL_SYS_JoystickOpen (SDL_Joystick * joystick); +extern int SDL_SYS_JoystickOpen(SDL_Joystick * joystick); /* 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. */ -extern void SDL_SYS_JoystickUpdate (SDL_Joystick * joystick); +extern void SDL_SYS_JoystickUpdate(SDL_Joystick * joystick); /* Function to close a joystick after use */ -extern void SDL_SYS_JoystickClose (SDL_Joystick * joystick); +extern void SDL_SYS_JoystickClose(SDL_Joystick * joystick); /* Function to perform any system-specific joystick related cleanup */ -extern void SDL_SYS_JoystickQuit (void); +extern void SDL_SYS_JoystickQuit(void); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/joystick/amigaos/SDL_sysjoystick.c --- a/src/joystick/amigaos/SDL_sysjoystick.c Mon May 29 03:53:21 2006 +0000 +++ b/src/joystick/amigaos/SDL_sysjoystick.c Mon May 29 04:04:35 2006 +0000 @@ -70,22 +70,22 @@ }; int -SDL_SYS_JoystickInit (void) +SDL_SYS_JoystickInit(void) { if (!LowLevelBase) { - if (LowLevelBase = OpenLibrary ("lowlevel.library", 37)) + if (LowLevelBase = OpenLibrary("lowlevel.library", 37)) return 2; } else return 2; - D (bug ("%ld joysticks available.\n", SDL_numjoysticks)); + D(bug("%ld joysticks available.\n", SDL_numjoysticks)); return 0; } /* Function to get the device-dependent name of a joystick */ const char * -SDL_SYS_JoystickName (int index) +SDL_SYS_JoystickName(int index) { if (index < 2 && LowLevelBase) { switch (index) { @@ -96,7 +96,7 @@ } } - SDL_SetError ("No joystick available with that index"); + SDL_SetError("No joystick available with that index"); return (NULL); } @@ -107,19 +107,19 @@ */ int -SDL_SYS_JoystickOpen (SDL_Joystick * joystick) +SDL_SYS_JoystickOpen(SDL_Joystick * joystick) { ULONG temp, i; - D (bug ("Opening joystick %ld\n", joystick->index)); + D(bug("Opening joystick %ld\n", joystick->index)); - if (!(joystick->hwdata = SDL_malloc (sizeof (struct joystick_hwdata)))) + if (!(joystick->hwdata = SDL_malloc(sizeof(struct joystick_hwdata)))) return -1; /* This loop is to check if the controller is a joypad */ for (i = 0; i < 20; i++) { - temp = ReadJoyPort (joystick->index ^ 1); // fix to invert amiga joyports - WaitTOF (); + temp = ReadJoyPort(joystick->index ^ 1); // fix to invert amiga joyports + WaitTOF(); } if ((temp & JP_TYPE_MASK) == JP_TYPE_GAMECTLR) @@ -141,39 +141,39 @@ * and update joystick device state. */ void -SDL_SYS_JoystickUpdate (SDL_Joystick * joystick) +SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) { ULONG data; int i; if (joystick->index < 2) { - data = ReadJoyPort (joystick->index); + data = ReadJoyPort(joystick->index); if (data & JP_DIRECTION_MASK) { if (data & JPF_JOY_DOWN) { if (!(joystick->hwdata->joystate & JPF_JOY_DOWN)) - SDL_PrivateJoystickAxis (joystick, 0, 127); + SDL_PrivateJoystickAxis(joystick, 0, 127); } else if (data & JPF_JOY_UP) { if (!(joystick->hwdata->joystate & JPF_JOY_UP)) - SDL_PrivateJoystickAxis (joystick, 0, -127); + SDL_PrivateJoystickAxis(joystick, 0, -127); } else if (joystick->hwdata-> joystate & (JPF_JOY_UP | JPF_JOY_DOWN)) - SDL_PrivateJoystickAxis (joystick, 0, 0); + SDL_PrivateJoystickAxis(joystick, 0, 0); if (data & JPF_JOY_LEFT) { if (!(joystick->hwdata->joystate & JPF_JOY_LEFT)) - SDL_PrivateJoystickAxis (joystick, 1, -127); + SDL_PrivateJoystickAxis(joystick, 1, -127); } else if (data & JPF_JOY_RIGHT) { if (!(joystick->hwdata->joystate & JPF_JOY_RIGHT)) - SDL_PrivateJoystickAxis (joystick, 1, 127); + SDL_PrivateJoystickAxis(joystick, 1, 127); } else if (joystick->hwdata-> joystate & (JPF_JOY_LEFT | JPF_JOY_RIGHT)) - SDL_PrivateJoystickAxis (joystick, 1, 0); + SDL_PrivateJoystickAxis(joystick, 1, 0); } else if (joystick->hwdata-> joystate & (JPF_JOY_LEFT | JPF_JOY_RIGHT)) { - SDL_PrivateJoystickAxis (joystick, 1, 0); + SDL_PrivateJoystickAxis(joystick, 1, 0); } else if (joystick->hwdata->joystate & (JPF_JOY_UP | JPF_JOY_DOWN)) { - SDL_PrivateJoystickAxis (joystick, 0, 0); + SDL_PrivateJoystickAxis(joystick, 0, 0); } for (i = 0; i < joystick->nbuttons; i++) { @@ -182,9 +182,9 @@ data &= (~(joybut[2])); if (!(joystick->hwdata->joystate & joybut[i])) - SDL_PrivateJoystickButton (joystick, i, SDL_PRESSED); + SDL_PrivateJoystickButton(joystick, i, SDL_PRESSED); } else if (joystick->hwdata->joystate & joybut[i]) - SDL_PrivateJoystickButton (joystick, i, SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, i, SDL_RELEASED); } joystick->hwdata->joystate = data; @@ -195,20 +195,20 @@ /* Function to close a joystick after use */ void -SDL_SYS_JoystickClose (SDL_Joystick * joystick) +SDL_SYS_JoystickClose(SDL_Joystick * joystick) { if (joystick->hwdata) - SDL_free (joystick->hwdata); + SDL_free(joystick->hwdata); return; } /* Function to perform any system-specific joystick related cleanup */ void -SDL_SYS_JoystickQuit (void) +SDL_SYS_JoystickQuit(void) { if (LowLevelBase) { - CloseLibrary (LowLevelBase); + CloseLibrary(LowLevelBase); LowLevelBase = NULL; SDL_numjoysticks = 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/joystick/beos/SDL_bejoystick.cc --- a/src/joystick/beos/SDL_bejoystick.cc Mon May 29 03:53:21 2006 +0000 +++ b/src/joystick/beos/SDL_bejoystick.cc Mon May 29 04:04:35 2006 +0000 @@ -56,7 +56,7 @@ * 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) + int SDL_SYS_JoystickInit(void) { BJoystick joystick; int numjoysticks; @@ -65,21 +65,20 @@ char name[B_OS_NAME_LENGTH]; /* Search for attached joysticks */ - nports = joystick.CountDevices (); + nports = joystick.CountDevices(); numjoysticks = 0; - SDL_memset (SDL_joyport, 0, (sizeof SDL_joyport)); - SDL_memset (SDL_joyname, 0, (sizeof SDL_joyname)); + SDL_memset(SDL_joyport, 0, (sizeof SDL_joyport)); + SDL_memset(SDL_joyname, 0, (sizeof SDL_joyname)); for (i = 0; (SDL_numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i) { - if (joystick.GetDeviceName (i, name) == B_OK) { - if (joystick.Open (name) != B_ERROR) { + if (joystick.GetDeviceName(i, name) == B_OK) { + if (joystick.Open(name) != B_ERROR) { BString stick_name; - joystick.GetControllerName (&stick_name); - SDL_joyport[numjoysticks] = strdup (name); - SDL_joyname[numjoysticks] = - strdup (stick_name.String ()); + joystick.GetControllerName(&stick_name); + SDL_joyport[numjoysticks] = strdup(name); + SDL_joyname[numjoysticks] = strdup(stick_name.String()); numjoysticks++; - joystick.Close (); + joystick.Close(); } } } @@ -87,7 +86,7 @@ } /* Function to get the device-dependent name of a joystick */ - const char *SDL_SYS_JoystickName (int index) + const char *SDL_SYS_JoystickName(int index) { return SDL_joyname[index]; } @@ -97,43 +96,43 @@ 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) + int SDL_SYS_JoystickOpen(SDL_Joystick * joystick) { BJoystick *stick; /* Create the joystick data structure */ joystick->hwdata = (struct joystick_hwdata *) - SDL_malloc (sizeof (*joystick->hwdata)); + SDL_malloc(sizeof(*joystick->hwdata)); if (joystick->hwdata == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } - SDL_memset (joystick->hwdata, 0, sizeof (*joystick->hwdata)); + SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); stick = new BJoystick; joystick->hwdata->stick = stick; /* Open the requested joystick for use */ - if (stick->Open (SDL_joyport[joystick->index]) == B_ERROR) { - SDL_SetError ("Unable to open joystick"); - SDL_SYS_JoystickClose (joystick); + if (stick->Open(SDL_joyport[joystick->index]) == B_ERROR) { + SDL_SetError("Unable to open joystick"); + SDL_SYS_JoystickClose(joystick); return (-1); } /* Set the joystick to calibrated mode */ - stick->EnableCalibration (); + stick->EnableCalibration(); /* Get the number of buttons, hats, and axes on the joystick */ - joystick->nbuttons = stick->CountButtons (); - joystick->naxes = stick->CountAxes (); - joystick->nhats = stick->CountHats (); + joystick->nbuttons = stick->CountButtons(); + joystick->naxes = stick->CountAxes(); + joystick->nhats = stick->CountHats(); joystick->hwdata->new_axes = (int16 *) - SDL_malloc (joystick->naxes * sizeof (int16)); + SDL_malloc(joystick->naxes * sizeof(int16)); joystick->hwdata->new_hats = (uint8 *) - SDL_malloc (joystick->nhats * sizeof (uint8)); + SDL_malloc(joystick->nhats * sizeof(uint8)); if (!joystick->hwdata->new_hats || !joystick->hwdata->new_axes) { - SDL_OutOfMemory (); - SDL_SYS_JoystickClose (joystick); + SDL_OutOfMemory(); + SDL_SYS_JoystickClose(joystick); return (-1); } @@ -146,7 +145,7 @@ * but instead should call SDL_PrivateJoystick*() to deliver events * and update joystick device state. */ - void SDL_SYS_JoystickUpdate (SDL_Joystick * joystick) + void SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) { static const Uint8 hat_map[9] = { SDL_HAT_CENTERED, @@ -173,64 +172,64 @@ hats = joystick->hwdata->new_hats; /* Get the new joystick state */ - stick->Update (); - stick->GetAxisValues (axes); - stick->GetHatValues (hats); - buttons = stick->ButtonValues (); + stick->Update(); + stick->GetAxisValues(axes); + stick->GetHatValues(hats); + buttons = stick->ButtonValues(); /* Generate axis motion events */ for (i = 0; i < joystick->naxes; ++i) { change = ((int32) axes[i] - joystick->axes[i]); if ((change > JITTER) || (change < -JITTER)) { - SDL_PrivateJoystickAxis (joystick, i, axes[i]); + SDL_PrivateJoystickAxis(joystick, i, axes[i]); } } /* Generate hat change events */ for (i = 0; i < joystick->nhats; ++i) { if (hats[i] != joystick->hats[i]) { - SDL_PrivateJoystickHat (joystick, i, hat_map[hats[i]]); + SDL_PrivateJoystickHat(joystick, i, hat_map[hats[i]]); } } /* Generate button events */ for (i = 0; i < joystick->nbuttons; ++i) { if ((buttons & 0x01) != joystick->buttons[i]) { - SDL_PrivateJoystickButton (joystick, i, (buttons & 0x01)); + SDL_PrivateJoystickButton(joystick, i, (buttons & 0x01)); } buttons >>= 1; } } /* Function to close a joystick after use */ - void SDL_SYS_JoystickClose (SDL_Joystick * joystick) + void SDL_SYS_JoystickClose(SDL_Joystick * joystick) { if (joystick->hwdata) { - joystick->hwdata->stick->Close (); + joystick->hwdata->stick->Close(); delete joystick->hwdata->stick; if (joystick->hwdata->new_hats) { - SDL_free (joystick->hwdata->new_hats); + SDL_free(joystick->hwdata->new_hats); } if (joystick->hwdata->new_axes) { - SDL_free (joystick->hwdata->new_axes); + SDL_free(joystick->hwdata->new_axes); } - SDL_free (joystick->hwdata); + SDL_free(joystick->hwdata); joystick->hwdata = NULL; } } /* Function to perform any system-specific joystick related cleanup */ - void SDL_SYS_JoystickQuit (void) + void SDL_SYS_JoystickQuit(void) { int i; for (i = 0; SDL_joyport[i]; ++i) { - SDL_free (SDL_joyport[i]); + SDL_free(SDL_joyport[i]); } SDL_joyport[0] = NULL; for (i = 0; SDL_joyname[i]; ++i) { - SDL_free (SDL_joyname[i]); + SDL_free(SDL_joyname[i]); } SDL_joyname[0] = NULL; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/joystick/bsd/SDL_sysjoystick.c --- a/src/joystick/bsd/SDL_sysjoystick.c Mon May 29 03:53:21 2006 +0000 +++ b/src/joystick/bsd/SDL_sysjoystick.c Mon May 29 04:04:35 2006 +0000 @@ -135,8 +135,8 @@ static char *joynames[MAX_JOYS]; static char *joydevnames[MAX_JOYS]; -static int report_alloc (struct report *, struct report_desc *, int); -static void report_free (struct report *); +static int report_alloc(struct report *, struct report_desc *, int); +static void report_free(struct report *); #ifdef USBHID_UCR_DATA #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data) @@ -145,49 +145,49 @@ #endif int -SDL_SYS_JoystickInit (void) +SDL_SYS_JoystickInit(void) { char s[16]; int i, fd; SDL_numjoysticks = 0; - SDL_memset (joynames, 0, sizeof (joynames)); - SDL_memset (joydevnames, 0, sizeof (joydevnames)); + SDL_memset(joynames, 0, sizeof(joynames)); + SDL_memset(joydevnames, 0, sizeof(joydevnames)); for (i = 0; i < MAX_UHID_JOYS; i++) { SDL_Joystick nj; - SDL_snprintf (s, SDL_arraysize (s), "/dev/uhid%d", i); + SDL_snprintf(s, SDL_arraysize(s), "/dev/uhid%d", i); nj.index = SDL_numjoysticks; - joynames[nj.index] = strdup (s); + joynames[nj.index] = strdup(s); - if (SDL_SYS_JoystickOpen (&nj) == 0) { - SDL_SYS_JoystickClose (&nj); + if (SDL_SYS_JoystickOpen(&nj) == 0) { + SDL_SYS_JoystickClose(&nj); SDL_numjoysticks++; } else { - SDL_free (joynames[nj.index]); + SDL_free(joynames[nj.index]); joynames[nj.index] = NULL; } } for (i = 0; i < MAX_JOY_JOYS; i++) { - SDL_snprintf (s, SDL_arraysize (s), "/dev/joy%d", i); - fd = open (s, O_RDONLY); + SDL_snprintf(s, SDL_arraysize(s), "/dev/joy%d", i); + fd = open(s, O_RDONLY); if (fd != -1) { - joynames[SDL_numjoysticks++] = strdup (s); - close (fd); + joynames[SDL_numjoysticks++] = strdup(s); + close(fd); } } /* Read the default USB HID usage table. */ - hid_init (NULL); + hid_init(NULL); return (SDL_numjoysticks); } const char * -SDL_SYS_JoystickName (int index) +SDL_SYS_JoystickName(int index) { if (joydevnames[index] != NULL) { return (joydevnames[index]); @@ -196,7 +196,7 @@ } static int -usage_to_joyaxe (unsigned usage) +usage_to_joyaxe(unsigned usage) { int joyaxe; switch (usage) { @@ -231,7 +231,7 @@ } static unsigned -hatval_to_sdl (Sint32 hatval) +hatval_to_sdl(Sint32 hatval) { static const unsigned hat_dir_map[8] = { SDL_HAT_UP, SDL_HAT_RIGHTUP, SDL_HAT_RIGHT, SDL_HAT_RIGHTDOWN, @@ -247,7 +247,7 @@ int -SDL_SYS_JoystickOpen (SDL_Joystick * joy) +SDL_SYS_JoystickOpen(SDL_Joystick * joy) { char *path = joynames[joy->index]; struct joystick_hwdata *hw; @@ -257,29 +257,29 @@ int fd; int i; - fd = open (path, O_RDONLY); + fd = open(path, O_RDONLY); if (fd == -1) { - SDL_SetError ("%s: %s", path, strerror (errno)); + SDL_SetError("%s: %s", path, strerror(errno)); return (-1); } hw = (struct joystick_hwdata *) - SDL_malloc (sizeof (struct joystick_hwdata)); + SDL_malloc(sizeof(struct joystick_hwdata)); if (hw == NULL) { - SDL_OutOfMemory (); - close (fd); + SDL_OutOfMemory(); + close(fd); return (-1); } joy->hwdata = hw; hw->fd = fd; - hw->path = strdup (path); - if (!SDL_strncmp (path, "/dev/joy", 8)) { + hw->path = strdup(path); + if (!SDL_strncmp(path, "/dev/joy", 8)) { hw->type = BSDJOY_JOY; joy->naxes = 2; joy->nbuttons = 2; joy->nhats = 0; joy->nballs = 0; - joydevnames[joy->index] = strdup ("Gameport joystick"); + joydevnames[joy->index] = strdup("Gameport joystick"); goto usbend; } else { hw->type = BSDJOY_UHID; @@ -290,32 +290,32 @@ for (ax = 0; ax < JOYAXE_count; ax++) hw->axis_map[ax] = -1; } - hw->repdesc = hid_get_report_desc (fd); + hw->repdesc = hid_get_report_desc(fd); if (hw->repdesc == NULL) { - SDL_SetError ("%s: USB_GET_REPORT_DESC: %s", hw->path, - strerror (errno)); + SDL_SetError("%s: USB_GET_REPORT_DESC: %s", hw->path, + strerror(errno)); goto usberr; } rep = &hw->inreport; - if (ioctl (fd, USB_GET_REPORT_ID, &rep->rid) < 0) { + if (ioctl(fd, USB_GET_REPORT_ID, &rep->rid) < 0) { rep->rid = -1; /* XXX */ } - if (report_alloc (rep, hw->repdesc, REPORT_INPUT) < 0) { + if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) { goto usberr; } if (rep->size <= 0) { - SDL_SetError ("%s: Input report descriptor has invalid length", - hw->path); + SDL_SetError("%s: Input report descriptor has invalid length", + hw->path); goto usberr; } #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_version >= 500111) - hdata = hid_start_parse (hw->repdesc, 1 << hid_input, rep->rid); + hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid); #else - hdata = hid_start_parse (hw->repdesc, 1 << hid_input); + hdata = hid_start_parse(hw->repdesc, 1 << hid_input); #endif if (hdata == NULL) { - SDL_SetError ("%s: Cannot start HID parser", hw->path); + SDL_SetError("%s: Cannot start HID parser", hw->path); goto usberr; } joy->naxes = 0; @@ -325,31 +325,31 @@ for (i = 0; i < JOYAXE_count; i++) hw->axis_map[i] = -1; - while (hid_get_item (hdata, &hitem) > 0) { + while (hid_get_item(hdata, &hitem) > 0) { char *sp; const char *s; switch (hitem.kind) { case hid_collection: - switch (HID_PAGE (hitem.usage)) { + switch (HID_PAGE(hitem.usage)) { case HUP_GENERIC_DESKTOP: - switch (HID_USAGE (hitem.usage)) { + switch (HID_USAGE(hitem.usage)) { case HUG_JOYSTICK: case HUG_GAME_PAD: - s = hid_usage_in_page (hitem.usage); - sp = SDL_malloc (SDL_strlen (s) + 5); - SDL_snprintf (sp, SDL_strlen (s) + 5, "%s (%d)", - s, joy->index); + s = hid_usage_in_page(hitem.usage); + sp = SDL_malloc(SDL_strlen(s) + 5); + SDL_snprintf(sp, SDL_strlen(s) + 5, "%s (%d)", + s, joy->index); joydevnames[joy->index] = sp; } } break; case hid_input: - switch (HID_PAGE (hitem.usage)) { + switch (HID_PAGE(hitem.usage)) { case HUP_GENERIC_DESKTOP: { - unsigned usage = HID_USAGE (hitem.usage); - int joyaxe = usage_to_joyaxe (usage); + unsigned usage = HID_USAGE(hitem.usage); + int joyaxe = usage_to_joyaxe(usage); if (joyaxe >= 0) { hw->axis_map[joyaxe] = 1; } else if (usage == HUG_HAT_SWITCH) { @@ -368,25 +368,25 @@ break; } } - hid_end_parse (hdata); + hid_end_parse(hdata); for (i = 0; i < JOYAXE_count; i++) if (hw->axis_map[i] > 0) hw->axis_map[i] = joy->naxes++; usbend: /* The poll blocks the event thread. */ - fcntl (fd, F_SETFL, O_NONBLOCK); + fcntl(fd, F_SETFL, O_NONBLOCK); return (0); usberr: - close (hw->fd); - SDL_free (hw->path); - SDL_free (hw); + close(hw->fd); + SDL_free(hw->path); + SDL_free(hw); return (-1); } void -SDL_SYS_JoystickUpdate (SDL_Joystick * joy) +SDL_SYS_JoystickUpdate(SDL_Joystick * joy) { struct hid_item hitem; struct hid_data *hdata; @@ -399,10 +399,10 @@ static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0; if (joy->hwdata->type == BSDJOY_JOY) { - if (read (joy->hwdata->fd, &gameport, sizeof gameport) != + if (read(joy->hwdata->fd, &gameport, sizeof gameport) != sizeof gameport) return; - if (abs (x - gameport.x) > 8) { + if (abs(x - gameport.x) > 8) { x = gameport.x; if (x < xmin) { xmin = x; @@ -417,9 +417,9 @@ v = (Sint32) x; v -= (xmax + xmin + 1) / 2; v *= 32768 / ((xmax - xmin + 1) / 2); - SDL_PrivateJoystickAxis (joy, 0, v); + SDL_PrivateJoystickAxis(joy, 0, v); } - if (abs (y - gameport.y) > 8) { + if (abs(y - gameport.y) > 8) { y = gameport.y; if (y < ymin) { ymin = y; @@ -434,13 +434,13 @@ v = (Sint32) y; v -= (ymax + ymin + 1) / 2; v *= 32768 / ((ymax - ymin + 1) / 2); - SDL_PrivateJoystickAxis (joy, 1, v); + SDL_PrivateJoystickAxis(joy, 1, v); } if (gameport.b1 != joy->buttons[0]) { - SDL_PrivateJoystickButton (joy, 0, gameport.b1); + SDL_PrivateJoystickButton(joy, 0, gameport.b1); } if (gameport.b2 != joy->buttons[1]) { - SDL_PrivateJoystickButton (joy, 1, gameport.b2); + SDL_PrivateJoystickButton(joy, 1, gameport.b2); } return; } @@ -448,53 +448,51 @@ rep = &joy->hwdata->inreport; - if (read (joy->hwdata->fd, REP_BUF_DATA (rep), rep->size) != rep->size) { + if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) { return; } #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_version >= 500111) - hdata = hid_start_parse (joy->hwdata->repdesc, 1 << hid_input, rep->rid); + hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid); #else - hdata = hid_start_parse (joy->hwdata->repdesc, 1 << hid_input); + hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input); #endif if (hdata == NULL) { - fprintf (stderr, "%s: Cannot start HID parser\n", joy->hwdata->path); + fprintf(stderr, "%s: Cannot start HID parser\n", joy->hwdata->path); return; } - for (nbutton = 0; hid_get_item (hdata, &hitem) > 0;) { + for (nbutton = 0; hid_get_item(hdata, &hitem) > 0;) { switch (hitem.kind) { case hid_input: - switch (HID_PAGE (hitem.usage)) { + switch (HID_PAGE(hitem.usage)) { case HUP_GENERIC_DESKTOP: { - unsigned usage = HID_USAGE (hitem.usage); - int joyaxe = usage_to_joyaxe (usage); + unsigned usage = HID_USAGE(hitem.usage); + int joyaxe = usage_to_joyaxe(usage); if (joyaxe >= 0) { naxe = joy->hwdata->axis_map[joyaxe]; /* scaleaxe */ - v = (Sint32) hid_get_data (REP_BUF_DATA (rep), - &hitem); + v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); v -= (hitem.logical_maximum + hitem.logical_minimum + 1) / 2; v *= 32768 / ((hitem.logical_maximum - hitem.logical_minimum + 1) / 2); if (v != joy->axes[naxe]) { - SDL_PrivateJoystickAxis (joy, naxe, v); + SDL_PrivateJoystickAxis(joy, naxe, v); } } else if (usage == HUG_HAT_SWITCH) { - v = (Sint32) hid_get_data (REP_BUF_DATA (rep), - &hitem); - SDL_PrivateJoystickHat (joy, 0, - hatval_to_sdl (v) - - hitem.logical_minimum); + v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); + SDL_PrivateJoystickHat(joy, 0, + hatval_to_sdl(v) - + hitem.logical_minimum); } break; } case HUP_BUTTON: - v = (Sint32) hid_get_data (REP_BUF_DATA (rep), &hitem); + v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); if (joy->buttons[nbutton] != v) { - SDL_PrivateJoystickButton (joy, nbutton, v); + SDL_PrivateJoystickButton(joy, nbutton, v); } nbutton++; break; @@ -506,77 +504,77 @@ break; } } - hid_end_parse (hdata); + hid_end_parse(hdata); return; } /* Function to close a joystick after use */ void -SDL_SYS_JoystickClose (SDL_Joystick * joy) +SDL_SYS_JoystickClose(SDL_Joystick * joy) { - if (SDL_strncmp (joy->hwdata->path, "/dev/joy", 8)) { - report_free (&joy->hwdata->inreport); - hid_dispose_report_desc (joy->hwdata->repdesc); + if (SDL_strncmp(joy->hwdata->path, "/dev/joy", 8)) { + report_free(&joy->hwdata->inreport); + hid_dispose_report_desc(joy->hwdata->repdesc); } - close (joy->hwdata->fd); - SDL_free (joy->hwdata->path); - SDL_free (joy->hwdata); + close(joy->hwdata->fd); + SDL_free(joy->hwdata->path); + SDL_free(joy->hwdata); return; } void -SDL_SYS_JoystickQuit (void) +SDL_SYS_JoystickQuit(void) { int i; for (i = 0; i < MAX_JOYS; i++) { if (joynames[i] != NULL) - SDL_free (joynames[i]); + SDL_free(joynames[i]); if (joydevnames[i] != NULL) - SDL_free (joydevnames[i]); + SDL_free(joydevnames[i]); } return; } static int -report_alloc (struct report *r, struct report_desc *rd, int repind) +report_alloc(struct report *r, struct report_desc *rd, int repind) { int len; #ifdef __DragonFly__ - len = hid_report_size (rd, r->rid, repinfo[repind].kind); + len = hid_report_size(rd, r->rid, repinfo[repind].kind); #elif __FREEBSD__ # if (__FreeBSD_version >= 460000) # if (__FreeBSD_version <= 500111) - len = hid_report_size (rd, r->rid, repinfo[repind].kind); + len = hid_report_size(rd, r->rid, repinfo[repind].kind); # else - len = hid_report_size (rd, repinfo[repind].kind, r->rid); + len = hid_report_size(rd, repinfo[repind].kind, r->rid); # endif # else - len = hid_report_size (rd, repinfo[repind].kind, &r->rid); + len = hid_report_size(rd, repinfo[repind].kind, &r->rid); # endif #else # ifdef USBHID_NEW - len = hid_report_size (rd, repinfo[repind].kind, r->rid); + len = hid_report_size(rd, repinfo[repind].kind, r->rid); # else - len = hid_report_size (rd, repinfo[repind].kind, &r->rid); + len = hid_report_size(rd, repinfo[repind].kind, &r->rid); # endif #endif if (len < 0) { - SDL_SetError ("Negative HID report size"); + SDL_SetError("Negative HID report size"); return (-1); } r->size = len; if (r->size > 0) { - r->buf = SDL_malloc (sizeof (*r->buf) - sizeof (REP_BUF_DATA (r)) + - r->size); + r->buf = SDL_malloc(sizeof(*r->buf) - sizeof(REP_BUF_DATA(r)) + + r->size); if (r->buf == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } } else { @@ -588,10 +586,10 @@ } static void -report_free (struct report *r) +report_free(struct report *r) { if (r->buf != NULL) { - SDL_free (r->buf); + SDL_free(r->buf); } r->status = SREPORT_UNINIT; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/joystick/darwin/SDL_sysjoystick.c --- a/src/joystick/darwin/SDL_sysjoystick.c Mon May 29 03:53:21 2006 +0000 +++ b/src/joystick/darwin/SDL_sysjoystick.c Mon May 29 04:04:35 2006 +0000 @@ -104,20 +104,20 @@ static void -HIDReportErrorNum (char *strError, long numError) +HIDReportErrorNum(char *strError, long numError) { - SDL_SetError (strError); + SDL_SetError(strError); } -static void HIDGetCollectionElements (CFMutableDictionaryRef deviceProperties, - recDevice * pDevice); +static void HIDGetCollectionElements(CFMutableDictionaryRef deviceProperties, + recDevice * pDevice); /* returns current value for element, polling element * will return 0 on error conditions which should be accounted for by application */ static SInt32 -HIDGetElementValue (recDevice * pDevice, recElement * pElement) +HIDGetElementValue(recDevice * pDevice, recElement * pElement) { IOReturn result = kIOReturnSuccess; IOHIDEventStruct hidEvent; @@ -125,9 +125,9 @@ if (NULL != pDevice && NULL != pElement && NULL != pDevice->interface) { result = - (*(pDevice->interface))->getElementValue (pDevice->interface, - pElement->cookie, - &hidEvent); + (*(pDevice->interface))->getElementValue(pDevice->interface, + pElement->cookie, + &hidEvent); if (kIOReturnSuccess == result) { /* record min and max for auto calibration */ if (hidEvent.value < pElement->minReport) @@ -142,12 +142,12 @@ } static SInt32 -HIDScaledCalibratedValue (recDevice * pDevice, recElement * pElement, - long min, long max) +HIDScaledCalibratedValue(recDevice * pDevice, recElement * pElement, + long min, long max) { float deviceScale = max - min; float readScale = pElement->maxReport - pElement->minReport; - SInt32 value = HIDGetElementValue (pDevice, pElement); + SInt32 value = HIDGetElementValue(pDevice, pElement); if (readScale == 0) return value; /* no scaling at all */ else @@ -157,7 +157,7 @@ static void -HIDRemovalCallback (void *target, IOReturn result, void *refcon, void *sender) +HIDRemovalCallback(void *target, IOReturn result, void *refcon, void *sender) { recDevice *device = (recDevice *) refcon; device->removed = 1; @@ -171,7 +171,7 @@ */ static IOReturn -HIDCreateOpenDeviceInterface (io_object_t hidDevice, recDevice * pDevice) +HIDCreateOpenDeviceInterface(io_object_t hidDevice, recDevice * pDevice) { IOReturn result = kIOReturnSuccess; HRESULT plugInResult = S_OK; @@ -180,37 +180,37 @@ if (NULL == pDevice->interface) { result = - IOCreatePlugInInterfaceForService (hidDevice, - kIOHIDDeviceUserClientTypeID, - kIOCFPlugInInterfaceID, - &ppPlugInInterface, &score); + IOCreatePlugInInterfaceForService(hidDevice, + kIOHIDDeviceUserClientTypeID, + kIOCFPlugInInterfaceID, + &ppPlugInInterface, &score); if (kIOReturnSuccess == result) { /* Call a method of the intermediate plug-in to create the device interface */ plugInResult = - (*ppPlugInInterface)->QueryInterface (ppPlugInInterface, - CFUUIDGetUUIDBytes - (kIOHIDDeviceInterfaceID), - (void *) &(pDevice-> - interface)); + (*ppPlugInInterface)->QueryInterface(ppPlugInInterface, + CFUUIDGetUUIDBytes + (kIOHIDDeviceInterfaceID), + (void *) &(pDevice-> + interface)); if (S_OK != plugInResult) HIDReportErrorNum ("CouldnÕt query HID class device interface from plugInInterface", plugInResult); - (*ppPlugInInterface)->Release (ppPlugInInterface); + (*ppPlugInInterface)->Release(ppPlugInInterface); } else HIDReportErrorNum ("Failed to create **plugInInterface via IOCreatePlugInInterfaceForService.", result); } if (NULL != pDevice->interface) { - result = (*(pDevice->interface))->open (pDevice->interface, 0); + result = (*(pDevice->interface))->open(pDevice->interface, 0); if (kIOReturnSuccess != result) HIDReportErrorNum ("Failed to open pDevice->interface via open.", result); else - (*(pDevice->interface))->setRemovalCallback (pDevice->interface, - HIDRemovalCallback, - pDevice, pDevice); + (*(pDevice->interface))->setRemovalCallback(pDevice->interface, + HIDRemovalCallback, + pDevice, pDevice); } return result; @@ -223,23 +223,23 @@ */ static IOReturn -HIDCloseReleaseInterface (recDevice * pDevice) +HIDCloseReleaseInterface(recDevice * pDevice) { IOReturn result = kIOReturnSuccess; if ((NULL != pDevice) && (NULL != pDevice->interface)) { /* close the interface */ - result = (*(pDevice->interface))->close (pDevice->interface); + result = (*(pDevice->interface))->close(pDevice->interface); if (kIOReturnNotOpen == result) { /* do nothing as device was not opened, thus can't be closed */ } else if (kIOReturnSuccess != result) - HIDReportErrorNum ("Failed to close IOHIDDeviceInterface.", - result); + HIDReportErrorNum("Failed to close IOHIDDeviceInterface.", + result); /* release the interface */ - result = (*(pDevice->interface))->Release (pDevice->interface); + result = (*(pDevice->interface))->Release(pDevice->interface); if (kIOReturnSuccess != result) - HIDReportErrorNum ("Failed to release IOHIDDeviceInterface.", - result); + HIDReportErrorNum("Failed to release IOHIDDeviceInterface.", + result); pDevice->interface = NULL; } return result; @@ -248,21 +248,20 @@ /* extracts actual specific element information from each element CF dictionary entry */ static void -HIDGetElementInfo (CFTypeRef refElement, recElement * pElement) +HIDGetElementInfo(CFTypeRef refElement, recElement * pElement) { long number; CFTypeRef refType; - refType = - CFDictionaryGetValue (refElement, CFSTR (kIOHIDElementCookieKey)); - if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number)) + refType = CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementCookieKey)); + if (refType && CFNumberGetValue(refType, kCFNumberLongType, &number)) pElement->cookie = (IOHIDElementCookie) number; - refType = CFDictionaryGetValue (refElement, CFSTR (kIOHIDElementMinKey)); - if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number)) + refType = CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementMinKey)); + if (refType && CFNumberGetValue(refType, kCFNumberLongType, &number)) pElement->min = number; pElement->maxReport = pElement->min; - refType = CFDictionaryGetValue (refElement, CFSTR (kIOHIDElementMaxKey)); - if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number)) + refType = CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementMaxKey)); + if (refType && CFNumberGetValue(refType, kCFNumberLongType, &number)) pElement->max = number; pElement->minReport = pElement->max; /* @@ -301,31 +300,30 @@ */ static void -HIDAddElement (CFTypeRef refElement, recDevice * pDevice) +HIDAddElement(CFTypeRef refElement, recDevice * pDevice) { recElement *element = NULL; recElement **headElement = NULL; long elementType, usagePage, usage; CFTypeRef refElementType = - CFDictionaryGetValue (refElement, CFSTR (kIOHIDElementTypeKey)); + CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementTypeKey)); CFTypeRef refUsagePage = - CFDictionaryGetValue (refElement, CFSTR (kIOHIDElementUsagePageKey)); + CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementUsagePageKey)); CFTypeRef refUsage = - CFDictionaryGetValue (refElement, CFSTR (kIOHIDElementUsageKey)); + CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementUsageKey)); if ((refElementType) && - (CFNumberGetValue (refElementType, kCFNumberLongType, &elementType))) - { + (CFNumberGetValue(refElementType, kCFNumberLongType, &elementType))) { /* look at types of interest */ if ((elementType == kIOHIDElementTypeInput_Misc) || (elementType == kIOHIDElementTypeInput_Button) || (elementType == kIOHIDElementTypeInput_Axis)) { if (refUsagePage - && CFNumberGetValue (refUsagePage, kCFNumberLongType, - &usagePage) && refUsage - && CFNumberGetValue (refUsage, kCFNumberLongType, &usage)) { + && CFNumberGetValue(refUsagePage, kCFNumberLongType, + &usagePage) && refUsage + && CFNumberGetValue(refUsage, kCFNumberLongType, &usage)) { switch (usagePage) { /* only interested in kHIDPage_GenericDesktop and kHIDPage_Button */ case kHIDPage_GenericDesktop: { @@ -340,7 +338,7 @@ case kHIDUsage_GD_Dial: case kHIDUsage_GD_Wheel: element = (recElement *) - NewPtrClear (sizeof (recElement)); + NewPtrClear(sizeof(recElement)); if (element) { pDevice->axes++; headElement = &(pDevice->firstAxis); @@ -348,7 +346,7 @@ break; case kHIDUsage_GD_Hatswitch: element = (recElement *) - NewPtrClear (sizeof (recElement)); + NewPtrClear(sizeof(recElement)); if (element) { pDevice->hats++; headElement = &(pDevice->firstHat); @@ -359,7 +357,7 @@ break; case kHIDPage_Button: element = (recElement *) - NewPtrClear (sizeof (recElement)); + NewPtrClear(sizeof(recElement)); if (element) { pDevice->buttons++; headElement = &(pDevice->firstButton); @@ -370,8 +368,8 @@ } } } else if (kIOHIDElementTypeCollection == elementType) - HIDGetCollectionElements ((CFMutableDictionaryRef) refElement, - pDevice); + HIDGetCollectionElements((CFMutableDictionaryRef) refElement, + pDevice); } if (element && headElement) { /* add to list */ @@ -388,30 +386,30 @@ elementPrevious->pNext = element; } element->pNext = NULL; - HIDGetElementInfo (refElement, element); + HIDGetElementInfo(refElement, element); } } /* collects information from each array member in device element list (each array memeber = element) */ static void -HIDGetElementsCFArrayHandler (const void *value, void *parameter) +HIDGetElementsCFArrayHandler(const void *value, void *parameter) { - if (CFGetTypeID (value) == CFDictionaryGetTypeID ()) - HIDAddElement ((CFTypeRef) value, (recDevice *) parameter); + if (CFGetTypeID(value) == CFDictionaryGetTypeID()) + HIDAddElement((CFTypeRef) value, (recDevice *) parameter); } /* handles retrieval of element information from arrays of elements in device IO registry information */ static void -HIDGetElements (CFTypeRef refElementCurrent, recDevice * pDevice) +HIDGetElements(CFTypeRef refElementCurrent, recDevice * pDevice) { - CFTypeID type = CFGetTypeID (refElementCurrent); - if (type == CFArrayGetTypeID ()) { /* if element is an array */ - CFRange range = { 0, CFArrayGetCount (refElementCurrent) }; + CFTypeID type = CFGetTypeID(refElementCurrent); + if (type == CFArrayGetTypeID()) { /* if element is an array */ + CFRange range = { 0, CFArrayGetCount(refElementCurrent) }; /* CountElementsCFArrayHandler called for each array member */ - CFArrayApplyFunction (refElementCurrent, range, - HIDGetElementsCFArrayHandler, pDevice); + CFArrayApplyFunction(refElementCurrent, range, + HIDGetElementsCFArrayHandler, pDevice); } } @@ -420,39 +418,38 @@ */ static void -HIDGetCollectionElements (CFMutableDictionaryRef deviceProperties, - recDevice * pDevice) +HIDGetCollectionElements(CFMutableDictionaryRef deviceProperties, + recDevice * pDevice) { CFTypeRef refElementTop = - CFDictionaryGetValue (deviceProperties, CFSTR (kIOHIDElementKey)); + CFDictionaryGetValue(deviceProperties, CFSTR(kIOHIDElementKey)); if (refElementTop) - HIDGetElements (refElementTop, pDevice); + HIDGetElements(refElementTop, pDevice); } /* use top level element usage page and usage to discern device usage page and usage setting appropriate vlaues in device record */ static void -HIDTopLevelElementHandler (const void *value, void *parameter) +HIDTopLevelElementHandler(const void *value, void *parameter) { CFTypeRef refCF = 0; - if (CFGetTypeID (value) != CFDictionaryGetTypeID ()) + if (CFGetTypeID(value) != CFDictionaryGetTypeID()) return; - refCF = CFDictionaryGetValue (value, CFSTR (kIOHIDElementUsagePageKey)); + refCF = CFDictionaryGetValue(value, CFSTR(kIOHIDElementUsagePageKey)); if (!CFNumberGetValue (refCF, kCFNumberLongType, &((recDevice *) parameter)->usagePage)) - SDL_SetError - ("CFNumberGetValue error retrieving pDevice->usagePage."); - refCF = CFDictionaryGetValue (value, CFSTR (kIOHIDElementUsageKey)); + SDL_SetError("CFNumberGetValue error retrieving pDevice->usagePage."); + refCF = CFDictionaryGetValue(value, CFSTR(kIOHIDElementUsageKey)); if (!CFNumberGetValue (refCF, kCFNumberLongType, &((recDevice *) parameter)->usage)) - SDL_SetError ("CFNumberGetValue error retrieving pDevice->usage."); + SDL_SetError("CFNumberGetValue error retrieving pDevice->usage."); } /* extracts device info from CF dictionary records in IO registry */ static void -HIDGetDeviceInfo (io_object_t hidDevice, CFMutableDictionaryRef hidProperties, - recDevice * pDevice) +HIDGetDeviceInfo(io_object_t hidDevice, CFMutableDictionaryRef hidProperties, + recDevice * pDevice) { CFMutableDictionaryRef usbProperties = 0; io_registry_entry_t parent1, parent2; @@ -461,14 +458,13 @@ * get dictionary for usb properties: step up two levels and get CF dictionary for USB properties */ if ((KERN_SUCCESS == - IORegistryEntryGetParentEntry (hidDevice, kIOServicePlane, &parent1)) + IORegistryEntryGetParentEntry(hidDevice, kIOServicePlane, &parent1)) + && (KERN_SUCCESS == + IORegistryEntryGetParentEntry(parent1, kIOServicePlane, &parent2)) && (KERN_SUCCESS == - IORegistryEntryGetParentEntry (parent1, kIOServicePlane, - &parent2)) - && (KERN_SUCCESS == - IORegistryEntryCreateCFProperties (parent2, &usbProperties, - kCFAllocatorDefault, - kNilOptions))) { + IORegistryEntryCreateCFProperties(parent2, &usbProperties, + kCFAllocatorDefault, + kNilOptions))) { if (usbProperties) { CFTypeRef refCF = 0; /* get device info @@ -478,32 +474,31 @@ /* get product name */ refCF = - CFDictionaryGetValue (hidProperties, - CFSTR (kIOHIDProductKey)); + CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey)); if (!refCF) refCF = - CFDictionaryGetValue (usbProperties, - CFSTR ("USB Product Name")); + CFDictionaryGetValue(usbProperties, + CFSTR("USB Product Name")); if (refCF) { if (!CFStringGetCString (refCF, pDevice->product, 256, - CFStringGetSystemEncoding ())) + CFStringGetSystemEncoding())) SDL_SetError ("CFStringGetCString error retrieving pDevice->product."); } /* get usage page and usage */ refCF = - CFDictionaryGetValue (hidProperties, - CFSTR (kIOHIDPrimaryUsagePageKey)); + CFDictionaryGetValue(hidProperties, + CFSTR(kIOHIDPrimaryUsagePageKey)); if (refCF) { if (!CFNumberGetValue (refCF, kCFNumberLongType, &pDevice->usagePage)) SDL_SetError ("CFNumberGetValue error retrieving pDevice->usagePage."); refCF = - CFDictionaryGetValue (hidProperties, - CFSTR (kIOHIDPrimaryUsageKey)); + CFDictionaryGetValue(hidProperties, + CFSTR(kIOHIDPrimaryUsageKey)); if (refCF) if (!CFNumberGetValue (refCF, kCFNumberLongType, &pDevice->usage)) @@ -515,53 +510,53 @@ /* use top level element instead */ CFTypeRef refCFTopElement = 0; refCFTopElement = - CFDictionaryGetValue (hidProperties, - CFSTR (kIOHIDElementKey)); + CFDictionaryGetValue(hidProperties, + CFSTR(kIOHIDElementKey)); { /* refCFTopElement points to an array of element dictionaries */ - CFRange range = { 0, CFArrayGetCount (refCFTopElement) }; - CFArrayApplyFunction (refCFTopElement, range, - HIDTopLevelElementHandler, pDevice); + CFRange range = { 0, CFArrayGetCount(refCFTopElement) }; + CFArrayApplyFunction(refCFTopElement, range, + HIDTopLevelElementHandler, pDevice); } } - CFRelease (usbProperties); + CFRelease(usbProperties); } else SDL_SetError ("IORegistryEntryCreateCFProperties failed to create usbProperties."); - if (kIOReturnSuccess != IOObjectRelease (parent2)) - SDL_SetError ("IOObjectRelease error with parent2."); - if (kIOReturnSuccess != IOObjectRelease (parent1)) - SDL_SetError ("IOObjectRelease error with parent1."); + if (kIOReturnSuccess != IOObjectRelease(parent2)) + SDL_SetError("IOObjectRelease error with parent2."); + if (kIOReturnSuccess != IOObjectRelease(parent1)) + SDL_SetError("IOObjectRelease error with parent1."); } } static recDevice * -HIDBuildDevice (io_object_t hidDevice) +HIDBuildDevice(io_object_t hidDevice) { - recDevice *pDevice = (recDevice *) NewPtrClear (sizeof (recDevice)); + recDevice *pDevice = (recDevice *) NewPtrClear(sizeof(recDevice)); if (pDevice) { /* get dictionary for HID properties */ CFMutableDictionaryRef hidProperties = 0; kern_return_t result = - IORegistryEntryCreateCFProperties (hidDevice, &hidProperties, - kCFAllocatorDefault, - kNilOptions); + IORegistryEntryCreateCFProperties(hidDevice, &hidProperties, + kCFAllocatorDefault, + kNilOptions); if ((result == KERN_SUCCESS) && hidProperties) { /* create device interface */ - result = HIDCreateOpenDeviceInterface (hidDevice, pDevice); + result = HIDCreateOpenDeviceInterface(hidDevice, pDevice); if (kIOReturnSuccess == result) { - HIDGetDeviceInfo (hidDevice, hidProperties, pDevice); /* hidDevice used to find parents in registry tree */ - HIDGetCollectionElements (hidProperties, pDevice); + HIDGetDeviceInfo(hidDevice, hidProperties, pDevice); /* hidDevice used to find parents in registry tree */ + HIDGetCollectionElements(hidProperties, pDevice); } else { - DisposePtr ((Ptr) pDevice); + DisposePtr((Ptr) pDevice); pDevice = NULL; } - CFRelease (hidProperties); + CFRelease(hidProperties); } else { - DisposePtr ((Ptr) pDevice); + DisposePtr((Ptr) pDevice); pDevice = NULL; } } @@ -572,12 +567,12 @@ */ static void -HIDDisposeElementList (recElement ** elementList) +HIDDisposeElementList(recElement ** elementList) { recElement *pElement = *elementList; while (pElement) { recElement *pElementNext = pElement->pNext; - DisposePtr ((Ptr) pElement); + DisposePtr((Ptr) pElement); pElement = pElementNext; } *elementList = NULL; @@ -588,7 +583,7 @@ */ static recDevice * -HIDDisposeDevice (recDevice ** ppDevice) +HIDDisposeDevice(recDevice ** ppDevice) { kern_return_t result = KERN_SUCCESS; recDevice *pDeviceNext = NULL; @@ -597,16 +592,16 @@ pDeviceNext = (*ppDevice)->pNext; /* free element lists */ - HIDDisposeElementList (&(*ppDevice)->firstAxis); - HIDDisposeElementList (&(*ppDevice)->firstButton); - HIDDisposeElementList (&(*ppDevice)->firstHat); + HIDDisposeElementList(&(*ppDevice)->firstAxis); + HIDDisposeElementList(&(*ppDevice)->firstButton); + HIDDisposeElementList(&(*ppDevice)->firstHat); - result = HIDCloseReleaseInterface (*ppDevice); /* function sanity checks interface value (now application does not own device) */ + result = HIDCloseReleaseInterface(*ppDevice); /* function sanity checks interface value (now application does not own device) */ if (kIOReturnSuccess != result) HIDReportErrorNum ("HIDCloseReleaseInterface failed when trying to dipose device.", result); - DisposePtr ((Ptr) * ppDevice); + DisposePtr((Ptr) * ppDevice); *ppDevice = NULL; } return pDeviceNext; @@ -619,7 +614,7 @@ * on an unrecoverable fatal error. */ int -SDL_SYS_JoystickInit (void) +SDL_SYS_JoystickInit(void) { IOReturn result = kIOReturnSuccess; mach_port_t masterPort = 0; @@ -631,18 +626,18 @@ SDL_numjoysticks = 0; if (gpDeviceList) { - SDL_SetError ("Joystick: Device list already inited."); + SDL_SetError("Joystick: Device list already inited."); return -1; } - result = IOMasterPort (bootstrap_port, &masterPort); + result = IOMasterPort(bootstrap_port, &masterPort); if (kIOReturnSuccess != result) { - SDL_SetError ("Joystick: IOMasterPort error with bootstrap_port."); + SDL_SetError("Joystick: IOMasterPort error with bootstrap_port."); return -1; } /* Set up a matching dictionary to search I/O Registry by class name for all HID class devices. */ - hidMatchDictionary = IOServiceMatching (kIOHIDDeviceKey); + hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey); if (hidMatchDictionary) { /* Add key for device type (joystick, in this case) to refine the matching dictionary. */ @@ -664,11 +659,11 @@ /*/ Now search I/O Registry for matching devices. */ result = - IOServiceGetMatchingServices (masterPort, hidMatchDictionary, - &hidObjectIterator); + IOServiceGetMatchingServices(masterPort, hidMatchDictionary, + &hidObjectIterator); /* Check for errors */ if (kIOReturnSuccess != result) { - SDL_SetError ("Joystick: Couldn't create a HID object iterator."); + SDL_SetError("Joystick: Couldn't create a HID object iterator."); return -1; } if (!hidObjectIterator) { /* there are no joysticks */ @@ -682,14 +677,14 @@ gpDeviceList = lastDevice = NULL; - while ((ioHIDDeviceObject = IOIteratorNext (hidObjectIterator))) { + while ((ioHIDDeviceObject = IOIteratorNext(hidObjectIterator))) { /* build a device record */ - device = HIDBuildDevice (ioHIDDeviceObject); + device = HIDBuildDevice(ioHIDDeviceObject); if (!device) continue; /* dump device object, it is no longer needed */ - result = IOObjectRelease (ioHIDDeviceObject); + result = IOObjectRelease(ioHIDDeviceObject); /* if (KERN_SUCCESS != result) HIDReportErrorNum ("IOObjectRelease error with ioHIDDeviceObject.", result); */ @@ -700,8 +695,8 @@ device->usage != kHIDUsage_GD_GamePad))) { /* release memory for the device */ - HIDDisposeDevice (&device); - DisposePtr ((Ptr) device); + HIDDisposeDevice(&device); + DisposePtr((Ptr) device); continue; } @@ -712,7 +707,7 @@ gpDeviceList = device; lastDevice = device; } - result = IOObjectRelease (hidObjectIterator); /* release the iterator */ + result = IOObjectRelease(hidObjectIterator); /* release the iterator */ /* Count the total number of devices we found */ device = gpDeviceList; @@ -726,7 +721,7 @@ /* Function to get the device-dependent name of a joystick */ const char * -SDL_SYS_JoystickName (int index) +SDL_SYS_JoystickName(int index) { recDevice *device = gpDeviceList; @@ -742,7 +737,7 @@ * It returns 0, or -1 if there is an error. */ int -SDL_SYS_JoystickOpen (SDL_Joystick * joystick) +SDL_SYS_JoystickOpen(SDL_Joystick * joystick) { recDevice *device = gpDeviceList; int index; @@ -767,7 +762,7 @@ * and update joystick device state. */ void -SDL_SYS_JoystickUpdate (SDL_Joystick * joystick) +SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) { recDevice *device = joystick->hwdata; recElement *element; @@ -780,13 +775,13 @@ /* Tell the app that everything is centered/unpressed... */ for (i = 0; i < device->axes; i++) - SDL_PrivateJoystickAxis (joystick, i, 0); + SDL_PrivateJoystickAxis(joystick, i, 0); for (i = 0; i < device->buttons; i++) - SDL_PrivateJoystickButton (joystick, i, 0); + SDL_PrivateJoystickButton(joystick, i, 0); for (i = 0; i < device->hats; i++) - SDL_PrivateJoystickHat (joystick, i, SDL_HAT_CENTERED); + SDL_PrivateJoystickHat(joystick, i, SDL_HAT_CENTERED); } return; @@ -795,9 +790,9 @@ element = device->firstAxis; i = 0; while (element) { - value = HIDScaledCalibratedValue (device, element, -32768, 32767); + value = HIDScaledCalibratedValue(device, element, -32768, 32767); if (value != joystick->axes[i]) - SDL_PrivateJoystickAxis (joystick, i, value); + SDL_PrivateJoystickAxis(joystick, i, value); element = element->pNext; ++i; } @@ -805,11 +800,11 @@ element = device->firstButton; i = 0; while (element) { - value = HIDGetElementValue (device, element); + value = HIDGetElementValue(device, element); if (value > 1) /* handle pressure-sensitive buttons */ value = 1; if (value != joystick->buttons[i]) - SDL_PrivateJoystickButton (joystick, i, value); + SDL_PrivateJoystickButton(joystick, i, value); element = element->pNext; ++i; } @@ -819,7 +814,7 @@ while (element) { Uint8 pos = 0; - value = HIDGetElementValue (device, element); + value = HIDGetElementValue(device, element); if (element->max == 3) /* 4 position hatswitch - scale up value */ value *= 2; else if (element->max != 7) /* Neither a 4 nor 8 positions - fall back to default position (centered) */ @@ -858,7 +853,7 @@ break; } if (pos != joystick->hats[i]) - SDL_PrivateJoystickHat (joystick, i, pos); + SDL_PrivateJoystickHat(joystick, i, pos); element = element->pNext; ++i; } @@ -868,7 +863,7 @@ /* Function to close a joystick after use */ void -SDL_SYS_JoystickClose (SDL_Joystick * joystick) +SDL_SYS_JoystickClose(SDL_Joystick * joystick) { /* Should we do anything here? */ return; @@ -876,10 +871,10 @@ /* Function to perform any system-specific joystick related cleanup */ void -SDL_SYS_JoystickQuit (void) +SDL_SYS_JoystickQuit(void) { while (NULL != gpDeviceList) - gpDeviceList = HIDDisposeDevice (&gpDeviceList); + gpDeviceList = HIDDisposeDevice(&gpDeviceList); } #endif /* SDL_JOYSTICK_IOKIT */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/joystick/dc/SDL_sysjoystick.c --- a/src/joystick/dc/SDL_sysjoystick.c Mon May 29 03:53:21 2006 +0000 +++ b/src/joystick/dc/SDL_sysjoystick.c Mon May 29 04:04:35 2006 +0000 @@ -54,7 +54,7 @@ * It should return 0, or -1 on an unrecoverable fatal error. */ int -SDL_SYS_JoystickInit (void) +SDL_SYS_JoystickInit(void) { int numdevs; @@ -63,8 +63,8 @@ numdevs = 0; for (p = 0; p < MAPLE_PORT_COUNT; p++) { for (u = 0; u < MAPLE_UNIT_COUNT; u++) { - if (maple_device_func (p, u) & MAPLE_FUNC_CONTROLLER) { - SYS_Joystick_addr[numdevs] = maple_addr (p, u); + if (maple_device_func(p, u) & MAPLE_FUNC_CONTROLLER) { + SYS_Joystick_addr[numdevs] = maple_addr(p, u); numdevs++; } } @@ -75,7 +75,7 @@ /* Function to get the device-dependent name of a joystick */ const char * -SDL_SYS_JoystickName (int index) +SDL_SYS_JoystickName(int index) { maple_device_t *dev; if (maple_compat_resolve @@ -90,16 +90,16 @@ It returns 0, or -1 if there is an error. */ int -SDL_SYS_JoystickOpen (SDL_Joystick * joystick) +SDL_SYS_JoystickOpen(SDL_Joystick * joystick) { /* allocate memory for system specific hardware data */ joystick->hwdata = - (struct joystick_hwdata *) SDL_malloc (sizeof (*joystick->hwdata)); + (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata)); if (joystick->hwdata == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } - SDL_memset (joystick->hwdata, 0, sizeof (*joystick->hwdata)); + SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); /* fill nbuttons, naxes, and nhats fields */ joystick->nbuttons = MAX_BUTTONS; @@ -116,7 +116,7 @@ */ void -SDL_SYS_JoystickUpdate (SDL_Joystick * joystick) +SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) { const int sdl_buttons[] = { CONT_C, @@ -134,7 +134,7 @@ int buttons, prev_buttons, i, changed; addr = SYS_Joystick_addr[joystick->index]; - if (cont_get_cond (addr, &cond) < 0) + if (cont_get_cond(addr, &cond) < 0) return; buttons = cond.buttons; @@ -152,7 +152,7 @@ hat |= SDL_HAT_LEFT; if (buttons & CONT_DPAD_RIGHT) hat |= SDL_HAT_RIGHT; - SDL_PrivateJoystickHat (joystick, 0, hat); + SDL_PrivateJoystickHat(joystick, 0, hat); } if ((changed) & (CONT_DPAD2_UP | CONT_DPAD2_DOWN | CONT_DPAD2_LEFT | @@ -166,30 +166,30 @@ hat |= SDL_HAT_LEFT; if (buttons & CONT_DPAD2_RIGHT) hat |= SDL_HAT_RIGHT; - SDL_PrivateJoystickHat (joystick, 1, hat); + SDL_PrivateJoystickHat(joystick, 1, hat); } - for (i = 0; i < sizeof (sdl_buttons) / sizeof (sdl_buttons[0]); i++) { + for (i = 0; i < sizeof(sdl_buttons) / sizeof(sdl_buttons[0]); i++) { if (changed & sdl_buttons[i]) { - SDL_PrivateJoystickButton (joystick, i, - (buttons & sdl_buttons[i]) ? - SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, i, + (buttons & sdl_buttons[i]) ? + SDL_PRESSED : SDL_RELEASED); } } prev_cond = &joystick->hwdata->prev_cond; if (cond.joyx != prev_cond->joyx) - SDL_PrivateJoystickAxis (joystick, 0, cond.joyx - 128); + SDL_PrivateJoystickAxis(joystick, 0, cond.joyx - 128); if (cond.joyy != prev_cond->joyy) - SDL_PrivateJoystickAxis (joystick, 1, cond.joyy - 128); + SDL_PrivateJoystickAxis(joystick, 1, cond.joyy - 128); if (cond.rtrig != prev_cond->rtrig) - SDL_PrivateJoystickAxis (joystick, 2, cond.rtrig); + SDL_PrivateJoystickAxis(joystick, 2, cond.rtrig); if (cond.ltrig != prev_cond->ltrig) - SDL_PrivateJoystickAxis (joystick, 3, cond.ltrig); + SDL_PrivateJoystickAxis(joystick, 3, cond.ltrig); if (cond.joy2x != prev_cond->joy2x) - SDL_PrivateJoystickAxis (joystick, 4, cond.joy2x - 128); + SDL_PrivateJoystickAxis(joystick, 4, cond.joy2x - 128); if (cond.joy2y != prev_cond->joy2y) - SDL_PrivateJoystickAxis (joystick, 5, cond.joy2y - 128); + SDL_PrivateJoystickAxis(joystick, 5, cond.joy2y - 128); joystick->hwdata->prev_buttons = buttons; joystick->hwdata->prev_cond = cond; @@ -197,17 +197,17 @@ /* Function to close a joystick after use */ void -SDL_SYS_JoystickClose (SDL_Joystick * joystick) +SDL_SYS_JoystickClose(SDL_Joystick * joystick) { if (joystick->hwdata != NULL) { /* free system specific hardware data */ - SDL_free (joystick->hwdata); + SDL_free(joystick->hwdata); } } /* Function to perform any system-specific joystick related cleanup */ void -SDL_SYS_JoystickQuit (void) +SDL_SYS_JoystickQuit(void) { return; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/joystick/dummy/SDL_sysjoystick.c --- a/src/joystick/dummy/SDL_sysjoystick.c Mon May 29 03:53:21 2006 +0000 +++ b/src/joystick/dummy/SDL_sysjoystick.c Mon May 29 04:04:35 2006 +0000 @@ -35,7 +35,7 @@ * It should return 0, or -1 on an unrecoverable fatal error. */ int -SDL_SYS_JoystickInit (void) +SDL_SYS_JoystickInit(void) { SDL_numjoysticks = 0; return (0); @@ -43,9 +43,9 @@ /* Function to get the device-dependent name of a joystick */ const char * -SDL_SYS_JoystickName (int index) +SDL_SYS_JoystickName(int index) { - SDL_SetError ("Logic error: No joysticks available"); + SDL_SetError("Logic error: No joysticks available"); return (NULL); } @@ -55,9 +55,9 @@ It returns 0, or -1 if there is an error. */ int -SDL_SYS_JoystickOpen (SDL_Joystick * joystick) +SDL_SYS_JoystickOpen(SDL_Joystick * joystick) { - SDL_SetError ("Logic error: No joysticks available"); + SDL_SetError("Logic error: No joysticks available"); return (-1); } @@ -67,21 +67,21 @@ * and update joystick device state. */ void -SDL_SYS_JoystickUpdate (SDL_Joystick * joystick) +SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) { return; } /* Function to close a joystick after use */ void -SDL_SYS_JoystickClose (SDL_Joystick * joystick) +SDL_SYS_JoystickClose(SDL_Joystick * joystick) { return; } /* Function to perform any system-specific joystick related cleanup */ void -SDL_SYS_JoystickQuit (void) +SDL_SYS_JoystickQuit(void) { return; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/joystick/linux/SDL_sysjoystick.c --- a/src/joystick/linux/SDL_sysjoystick.c Mon May 29 03:53:21 2006 +0000 +++ b/src/joystick/linux/SDL_sysjoystick.c Mon May 29 04:04:35 2006 +0000 @@ -309,7 +309,7 @@ #ifndef NO_LOGICAL_JOYSTICKS static int -CountLogicalJoysticks (int max) +CountLogicalJoysticks(int max) { register int i, j, k, ret, prev; const char *name; @@ -319,23 +319,23 @@ ret = 0; for (i = 0; i < max; i++) { - name = SDL_SYS_JoystickName (i); + name = SDL_SYS_JoystickName(i); - fd = open (SDL_joylist[i].fname, O_RDONLY, 0); + fd = open(SDL_joylist[i].fname, O_RDONLY, 0); if (fd >= 0) { - if (ioctl (fd, JSIOCGBUTTONS, &n) < 0) { + if (ioctl(fd, JSIOCGBUTTONS, &n) < 0) { nbuttons = -1; } else { nbuttons = n; } - close (fd); + close(fd); } else { nbuttons = -1; } if (name) { - for (j = 0; j < SDL_arraysize (joystick_logicalmap); j++) { - if (!SDL_strcmp (name, joystick_logicalmap[j].name) + for (j = 0; j < SDL_arraysize(joystick_logicalmap); j++) { + if (!SDL_strcmp(name, joystick_logicalmap[j].name) && (nbuttons == -1 || nbuttons == joystick_logicalmap[j].nbuttons)) { prev = i; @@ -361,16 +361,16 @@ } static void -LogicalSuffix (int logicalno, char *namebuf, int len) +LogicalSuffix(int logicalno, char *namebuf, int len) { register int slen; const static char suffixs[] = "01020304050607080910111213141516171819" "20212223242526272829303132"; const char *suffix; - slen = SDL_strlen (namebuf); + slen = SDL_strlen(namebuf); suffix = NULL; - if (logicalno * 2 < sizeof (suffixs)) + if (logicalno * 2 < sizeof(suffixs)) suffix = suffixs + (logicalno * 2); if (slen + 4 < len && suffix) { @@ -389,21 +389,21 @@ (((1UL << ((nr) & 31)) & (((const unsigned int *) addr)[(nr) >> 5])) != 0) static int -EV_IsJoystick (int fd) +EV_IsJoystick(int fd) { unsigned long evbit[40]; unsigned long keybit[40]; unsigned long absbit[40]; - if ((ioctl (fd, EVIOCGBIT (0, sizeof (evbit)), evbit) < 0) || - (ioctl (fd, EVIOCGBIT (EV_KEY, sizeof (keybit)), keybit) < 0) || - (ioctl (fd, EVIOCGBIT (EV_ABS, sizeof (absbit)), absbit) < 0)) { + if ((ioctl(fd, EVIOCGBIT(0, sizeof(evbit)), evbit) < 0) || + (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) < 0) || + (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) < 0)) { return (0); } - if (!(test_bit (EV_KEY, evbit) && test_bit (EV_ABS, evbit) && - test_bit (ABS_X, absbit) && test_bit (ABS_Y, absbit) && - (test_bit (BTN_TRIGGER, keybit) || test_bit (BTN_A, keybit) - || test_bit (BTN_1, keybit)))) + if (!(test_bit(EV_KEY, evbit) && test_bit(EV_ABS, evbit) && + test_bit(ABS_X, absbit) && test_bit(ABS_Y, absbit) && + (test_bit(BTN_TRIGGER, keybit) || test_bit(BTN_A, keybit) + || test_bit(BTN_1, keybit)))) return 0; return (1); } @@ -412,7 +412,7 @@ /* Function to scan the system for joysticks */ int -SDL_SYS_JoystickInit (void) +SDL_SYS_JoystickInit(void) { /* The base path of the joystick devices */ const char *joydev_pattern[] = { @@ -433,31 +433,31 @@ numjoysticks = 0; /* First see if the user specified a joystick to use */ - if (SDL_getenv ("SDL_JOYSTICK_DEVICE") != NULL) { - SDL_strlcpy (path, SDL_getenv ("SDL_JOYSTICK_DEVICE"), sizeof (path)); - if (stat (path, &sb) == 0) { - fd = open (path, O_RDONLY, 0); + if (SDL_getenv("SDL_JOYSTICK_DEVICE") != NULL) { + SDL_strlcpy(path, SDL_getenv("SDL_JOYSTICK_DEVICE"), sizeof(path)); + if (stat(path, &sb) == 0) { + fd = open(path, O_RDONLY, 0); if (fd >= 0) { /* Assume the user knows what they're doing. */ - SDL_joylist[numjoysticks].fname = SDL_strdup (path); + SDL_joylist[numjoysticks].fname = SDL_strdup(path); if (SDL_joylist[numjoysticks].fname) { dev_nums[numjoysticks] = sb.st_rdev; ++numjoysticks; } - close (fd); + close(fd); } } } - for (i = 0; i < SDL_arraysize (joydev_pattern); ++i) { + for (i = 0; i < SDL_arraysize(joydev_pattern); ++i) { for (j = 0; j < MAX_JOYSTICKS; ++j) { - SDL_snprintf (path, SDL_arraysize (path), joydev_pattern[i], j); + SDL_snprintf(path, SDL_arraysize(path), joydev_pattern[i], j); /* rcg06302000 replaced access(F_OK) call with stat(). * stat() will fail if the file doesn't exist, so it's * equivalent behaviour. */ - if (stat (path, &sb) == 0) { + if (stat(path, &sb) == 0) { /* Check to make sure it's not already in list. * This happens when we see a stick via symlink. */ @@ -471,23 +471,23 @@ continue; } - fd = open (path, O_RDONLY, 0); + fd = open(path, O_RDONLY, 0); if (fd < 0) { continue; } #if SDL_INPUT_LINUXEV #ifdef DEBUG_INPUT_EVENTS - printf ("Checking %s\n", path); + printf("Checking %s\n", path); #endif - if ((i == 0) && !EV_IsJoystick (fd)) { - close (fd); + if ((i == 0) && !EV_IsJoystick(fd)) { + close(fd); continue; } #endif - close (fd); + close(fd); /* We're fine, add this joystick */ - SDL_joylist[numjoysticks].fname = SDL_strdup (path); + SDL_joylist[numjoysticks].fname = SDL_strdup(path); if (SDL_joylist[numjoysticks].fname) { dev_nums[numjoysticks] = sb.st_rdev; ++numjoysticks; @@ -509,7 +509,7 @@ #endif } #ifndef NO_LOGICAL_JOYSTICKS - numjoysticks += CountLogicalJoysticks (numjoysticks); + numjoysticks += CountLogicalJoysticks(numjoysticks); #endif return (numjoysticks); @@ -517,35 +517,35 @@ /* Function to get the device-dependent name of a joystick */ const char * -SDL_SYS_JoystickName (int index) +SDL_SYS_JoystickName(int index) { int fd; static char namebuf[128]; char *name; - SDL_logical_joydecl (int oindex = index); + SDL_logical_joydecl(int oindex = index); #ifndef NO_LOGICAL_JOYSTICKS - SDL_joylist_head (index, index); + SDL_joylist_head(index, index); #endif name = NULL; - fd = open (SDL_joylist[index].fname, O_RDONLY, 0); + fd = open(SDL_joylist[index].fname, O_RDONLY, 0); if (fd >= 0) { if ( #if SDL_INPUT_LINUXEV - (ioctl (fd, EVIOCGNAME (sizeof (namebuf)), namebuf) <= 0) && + (ioctl(fd, EVIOCGNAME(sizeof(namebuf)), namebuf) <= 0) && #endif - (ioctl (fd, JSIOCGNAME (sizeof (namebuf)), namebuf) <= 0)) { + (ioctl(fd, JSIOCGNAME(sizeof(namebuf)), namebuf) <= 0)) { name = SDL_joylist[index].fname; } else { name = namebuf; } - close (fd); + close(fd); #ifndef NO_LOGICAL_JOYSTICKS if (SDL_joylist[oindex].prev || SDL_joylist[oindex].next || index != oindex) { - LogicalSuffix (SDL_joylist[oindex].logicalno, namebuf, 128); + LogicalSuffix(SDL_joylist[oindex].logicalno, namebuf, 128); } #endif } @@ -553,13 +553,13 @@ } static int -allocate_hatdata (SDL_Joystick * joystick) +allocate_hatdata(SDL_Joystick * joystick) { int i; joystick->hwdata->hats = - (struct hwdata_hat *) SDL_malloc (joystick->nhats * - sizeof (struct hwdata_hat)); + (struct hwdata_hat *) SDL_malloc(joystick->nhats * + sizeof(struct hwdata_hat)); if (joystick->hwdata->hats == NULL) { return (-1); } @@ -571,13 +571,13 @@ } static int -allocate_balldata (SDL_Joystick * joystick) +allocate_balldata(SDL_Joystick * joystick) { int i; joystick->hwdata->balls = - (struct hwdata_ball *) SDL_malloc (joystick->nballs * - sizeof (struct hwdata_ball)); + (struct hwdata_ball *) SDL_malloc(joystick->nballs * + sizeof(struct hwdata_ball)); if (joystick->hwdata->balls == NULL) { return (-1); } @@ -589,7 +589,7 @@ } static SDL_bool -JS_ConfigJoystick (SDL_Joystick * joystick, int fd) +JS_ConfigJoystick(SDL_Joystick * joystick, int fd) { SDL_bool handled; unsigned char n; @@ -601,24 +601,24 @@ handled = SDL_FALSE; /* Default joystick device settings */ - if (ioctl (fd, JSIOCGAXES, &n) < 0) { + if (ioctl(fd, JSIOCGAXES, &n) < 0) { joystick->naxes = 2; } else { joystick->naxes = n; } - if (ioctl (fd, JSIOCGBUTTONS, &n) < 0) { + if (ioctl(fd, JSIOCGBUTTONS, &n) < 0) { joystick->nbuttons = 2; } else { joystick->nbuttons = n; } - name = SDL_SYS_JoystickName (joystick->index); + name = SDL_SYS_JoystickName(joystick->index); old_axes = joystick->naxes; /* Generic analog joystick support */ - if (SDL_strstr (name, "Analog") == name && SDL_strstr (name, "-hat")) { - if (SDL_sscanf (name, "Analog %d-axis %*d-button %d-hat", - &tmp_naxes, &tmp_nhats) == 2) { + if (SDL_strstr(name, "Analog") == name && SDL_strstr(name, "-hat")) { + if (SDL_sscanf(name, "Analog %d-axis %*d-button %d-hat", + &tmp_naxes, &tmp_nhats) == 2) { joystick->naxes = tmp_naxes; joystick->nhats = tmp_nhats; @@ -628,8 +628,8 @@ } /* Special joystick support */ - for (i = 0; i < SDL_arraysize (special_joysticks); ++i) { - if (SDL_strcmp (name, special_joysticks[i].name) == 0) { + for (i = 0; i < SDL_arraysize(special_joysticks); ++i) { + if (SDL_strcmp(name, special_joysticks[i].name) == 0) { joystick->naxes = special_joysticks[i].naxes; joystick->nhats = special_joysticks[i].nhats; @@ -641,17 +641,17 @@ } /* User environment joystick support */ - if ((env = SDL_getenv ("SDL_LINUX_JOYSTICK"))) { + if ((env = SDL_getenv("SDL_LINUX_JOYSTICK"))) { *env_name = '\0'; - if (*env == '\'' && SDL_sscanf (env, "'%[^']s'", env_name) == 1) - env += SDL_strlen (env_name) + 2; - else if (SDL_sscanf (env, "%s", env_name) == 1) - env += SDL_strlen (env_name); + if (*env == '\'' && SDL_sscanf(env, "'%[^']s'", env_name) == 1) + env += SDL_strlen(env_name) + 2; + else if (SDL_sscanf(env, "%s", env_name) == 1) + env += SDL_strlen(env_name); - if (SDL_strcmp (name, env_name) == 0) { + if (SDL_strcmp(name, env_name) == 0) { - if (SDL_sscanf (env, "%d %d %d", &tmp_naxes, &tmp_nhats, - &tmp_nballs) == 3) { + if (SDL_sscanf(env, "%d %d %d", &tmp_naxes, &tmp_nhats, + &tmp_nballs) == 3) { joystick->naxes = tmp_naxes; joystick->nhats = tmp_nhats; @@ -665,12 +665,12 @@ /* Remap hats and balls */ if (handled) { if (joystick->nhats > 0) { - if (allocate_hatdata (joystick) < 0) { + if (allocate_hatdata(joystick) < 0) { joystick->nhats = 0; } } if (joystick->nballs > 0) { - if (allocate_balldata (joystick) < 0) { + if (allocate_balldata(joystick) < 0) { joystick->nballs = 0; } } @@ -682,7 +682,7 @@ #if SDL_INPUT_LINUXEV static SDL_bool -EV_ConfigJoystick (SDL_Joystick * joystick, int fd) +EV_ConfigJoystick(SDL_Joystick * joystick, int fd) { int i, t; unsigned long keybit[40]; @@ -690,25 +690,25 @@ unsigned long relbit[40]; /* See if this device uses the new unified event API */ - if ((ioctl (fd, EVIOCGBIT (EV_KEY, sizeof (keybit)), keybit) >= 0) && - (ioctl (fd, EVIOCGBIT (EV_ABS, sizeof (absbit)), absbit) >= 0) && - (ioctl (fd, EVIOCGBIT (EV_REL, sizeof (relbit)), relbit) >= 0)) { + if ((ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) >= 0) && + (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) >= 0) && + (ioctl(fd, EVIOCGBIT(EV_REL, sizeof(relbit)), relbit) >= 0)) { joystick->hwdata->is_hid = SDL_TRUE; /* Get the number of buttons, axes, and other thingamajigs */ for (i = BTN_JOYSTICK; i < KEY_MAX; ++i) { - if (test_bit (i, keybit)) { + if (test_bit(i, keybit)) { #ifdef DEBUG_INPUT_EVENTS - printf ("Joystick has button: 0x%x\n", i); + printf("Joystick has button: 0x%x\n", i); #endif joystick->hwdata->key_map[i - BTN_MISC] = joystick->nbuttons; ++joystick->nbuttons; } } for (i = BTN_MISC; i < BTN_JOYSTICK; ++i) { - if (test_bit (i, keybit)) { + if (test_bit(i, keybit)) { #ifdef DEBUG_INPUT_EVENTS - printf ("Joystick has button: 0x%x\n", i); + printf("Joystick has button: 0x%x\n", i); #endif joystick->hwdata->key_map[i - BTN_MISC] = joystick->nbuttons; ++joystick->nbuttons; @@ -720,16 +720,15 @@ i = ABS_HAT3Y; continue; } - if (test_bit (i, absbit)) { + if (test_bit(i, absbit)) { int values[5]; - if (ioctl (fd, EVIOCGABS (i), values) < 0) + if (ioctl(fd, EVIOCGABS(i), values) < 0) continue; #ifdef DEBUG_INPUT_EVENTS - printf ("Joystick has absolute axis: %x\n", i); - printf ("Values = { %d, %d, %d, %d, %d }\n", - values[0], values[1], - values[2], values[3], values[4]); + printf("Joystick has absolute axis: %x\n", i); + printf("Values = { %d, %d, %d, %d, %d }\n", + values[0], values[1], values[2], values[3], values[4]); #endif /* DEBUG_INPUT_EVENTS */ joystick->hwdata->abs_map[i] = joystick->naxes; if (values[1] == values[2]) { @@ -752,25 +751,25 @@ } } for (i = ABS_HAT0X; i <= ABS_HAT3Y; i += 2) { - if (test_bit (i, absbit) || test_bit (i + 1, absbit)) { + if (test_bit(i, absbit) || test_bit(i + 1, absbit)) { #ifdef DEBUG_INPUT_EVENTS - printf ("Joystick has hat %d\n", (i - ABS_HAT0X) / 2); + printf("Joystick has hat %d\n", (i - ABS_HAT0X) / 2); #endif ++joystick->nhats; } } - if (test_bit (REL_X, relbit) || test_bit (REL_Y, relbit)) { + if (test_bit(REL_X, relbit) || test_bit(REL_Y, relbit)) { ++joystick->nballs; } /* Allocate data to keep track of these thingamajigs */ if (joystick->nhats > 0) { - if (allocate_hatdata (joystick) < 0) { + if (allocate_hatdata(joystick) < 0) { joystick->nhats = 0; } } if (joystick->nballs > 0) { - if (allocate_balldata (joystick) < 0) { + if (allocate_balldata(joystick) < 0) { joystick->nballs = 0; } } @@ -782,7 +781,7 @@ #ifndef NO_LOGICAL_JOYSTICKS static void -ConfigLogicalJoystick (SDL_Joystick * joystick) +ConfigLogicalJoystick(SDL_Joystick * joystick) { struct joystick_logical_layout *layout; @@ -803,17 +802,17 @@ It returns 0, or -1 if there is an error. */ int -SDL_SYS_JoystickOpen (SDL_Joystick * joystick) +SDL_SYS_JoystickOpen(SDL_Joystick * joystick) { int fd; - SDL_logical_joydecl (int realindex); - SDL_logical_joydecl (SDL_Joystick * realjoy = NULL); + SDL_logical_joydecl(int realindex); + SDL_logical_joydecl(SDL_Joystick * realjoy = NULL); /* Open the joystick and set the joystick file descriptor */ #ifndef NO_LOGICAL_JOYSTICKS if (SDL_joylist[joystick->index].fname == NULL) { - SDL_joylist_head (realindex, joystick->index); - realjoy = SDL_JoystickOpen (realindex); + SDL_joylist_head(realindex, joystick->index); + realjoy = SDL_JoystickOpen(realindex); if (realjoy == NULL) return (-1); @@ -821,40 +820,40 @@ fd = realjoy->hwdata->fd; } else { - fd = open (SDL_joylist[joystick->index].fname, O_RDONLY, 0); + fd = open(SDL_joylist[joystick->index].fname, O_RDONLY, 0); } SDL_joylist[joystick->index].joy = joystick; #else - fd = open (SDL_joylist[joystick->index].fname, O_RDONLY, 0); + fd = open(SDL_joylist[joystick->index].fname, O_RDONLY, 0); #endif if (fd < 0) { - SDL_SetError ("Unable to open %s\n", SDL_joylist[joystick->index]); + SDL_SetError("Unable to open %s\n", SDL_joylist[joystick->index]); return (-1); } joystick->hwdata = (struct joystick_hwdata *) - SDL_malloc (sizeof (*joystick->hwdata)); + SDL_malloc(sizeof(*joystick->hwdata)); if (joystick->hwdata == NULL) { - SDL_OutOfMemory (); - close (fd); + SDL_OutOfMemory(); + close(fd); return (-1); } - SDL_memset (joystick->hwdata, 0, sizeof (*joystick->hwdata)); + SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); joystick->hwdata->fd = fd; /* Set the joystick to non-blocking read mode */ - fcntl (fd, F_SETFL, O_NONBLOCK); + fcntl(fd, F_SETFL, O_NONBLOCK); /* Get the number of buttons and axes on the joystick */ #ifndef NO_LOGICAL_JOYSTICKS if (realjoy) - ConfigLogicalJoystick (joystick); + ConfigLogicalJoystick(joystick); else #endif #if SDL_INPUT_LINUXEV - if (!EV_ConfigJoystick (joystick, fd)) + if (!EV_ConfigJoystick(joystick, fd)) #endif - JS_ConfigJoystick (joystick, fd); + JS_ConfigJoystick(joystick, fd); return (0); } @@ -862,8 +861,8 @@ #ifndef NO_LOGICAL_JOYSTICKS static SDL_Joystick * -FindLogicalJoystick (SDL_Joystick * joystick, - struct joystick_logical_mapping *v) +FindLogicalJoystick(SDL_Joystick * joystick, + struct joystick_logical_mapping *v) { SDL_Joystick *logicaljoy; register int i; @@ -891,7 +890,7 @@ } static int -LogicalJoystickButton (SDL_Joystick * joystick, Uint8 button, Uint8 state) +LogicalJoystickButton(SDL_Joystick * joystick, Uint8 button, Uint8 state) { struct joystick_logical_mapping *buttons; SDL_Joystick *logicaljoy = NULL; @@ -904,18 +903,18 @@ /* get the logical joystick that will receive the event */ buttons = SDL_joylist[joystick->index].map->buttonmap + button; - logicaljoy = FindLogicalJoystick (joystick, buttons); + logicaljoy = FindLogicalJoystick(joystick, buttons); if (logicaljoy == NULL) return 1; - SDL_PrivateJoystickButton (logicaljoy, buttons->nthing, state); + SDL_PrivateJoystickButton(logicaljoy, buttons->nthing, state); return 1; } static int -LogicalJoystickAxis (SDL_Joystick * joystick, Uint8 axis, Sint16 value) +LogicalJoystickAxis(SDL_Joystick * joystick, Uint8 axis, Sint16 value) { struct joystick_logical_mapping *axes; SDL_Joystick *logicaljoy = NULL; @@ -928,19 +927,19 @@ /* get the logical joystick that will receive the event */ axes = SDL_joylist[joystick->index].map->axismap + axis; - logicaljoy = FindLogicalJoystick (joystick, axes); + logicaljoy = FindLogicalJoystick(joystick, axes); if (logicaljoy == NULL) return 1; - SDL_PrivateJoystickAxis (logicaljoy, axes->nthing, value); + SDL_PrivateJoystickAxis(logicaljoy, axes->nthing, value); return 1; } #endif /* USE_LOGICAL_JOYSTICKS */ static __inline__ void -HandleHat (SDL_Joystick * stick, Uint8 hat, int axis, int value) +HandleHat(SDL_Joystick * stick, Uint8 hat, int axis, int value) { struct hwdata_hat *the_hat; const Uint8 position_map[3][3] = { @@ -948,8 +947,8 @@ {SDL_HAT_LEFT, SDL_HAT_CENTERED, SDL_HAT_RIGHT}, {SDL_HAT_LEFTDOWN, SDL_HAT_DOWN, SDL_HAT_RIGHTDOWN} }; - SDL_logical_joydecl (SDL_Joystick * logicaljoy = NULL); - SDL_logical_joydecl (struct joystick_logical_mapping *hats = NULL); + SDL_logical_joydecl(SDL_Joystick * logicaljoy = NULL); + SDL_logical_joydecl(struct joystick_logical_mapping *hats = NULL); the_hat = &stick->hwdata->hats[hat]; if (value < 0) { @@ -970,7 +969,7 @@ /* get the fake joystick that will receive the event */ hats = SDL_joylist[stick->index].map->hatmap + hat; - logicaljoy = FindLogicalJoystick (stick, hats); + logicaljoy = FindLogicalJoystick(stick, hats); } if (logicaljoy) { @@ -979,14 +978,14 @@ } #endif /* USE_LOGICAL_JOYSTICKS */ - SDL_PrivateJoystickHat (stick, hat, - position_map[the_hat->axis[1]][the_hat-> - axis[0]]); + SDL_PrivateJoystickHat(stick, hat, + position_map[the_hat->axis[1]][the_hat-> + axis[0]]); } } static __inline__ void -HandleBall (SDL_Joystick * stick, Uint8 ball, int axis, int value) +HandleBall(SDL_Joystick * stick, Uint8 ball, int axis, int value) { stick->hwdata->balls[ball].axis[axis] += value; } @@ -997,7 +996,7 @@ * and update joystick device state. */ static __inline__ void -JS_HandleEvents (SDL_Joystick * joystick) +JS_HandleEvents(SDL_Joystick * joystick) { struct js_event events[32]; int i, len; @@ -1005,52 +1004,51 @@ #ifndef NO_LOGICAL_JOYSTICKS if (SDL_joylist[joystick->index].fname == NULL) { - SDL_joylist_head (i, joystick->index); - JS_HandleEvents (SDL_joylist[i].joy); + SDL_joylist_head(i, joystick->index); + JS_HandleEvents(SDL_joylist[i].joy); return; } #endif - while ((len = read (joystick->hwdata->fd, events, (sizeof events))) > 0) { - len /= sizeof (events[0]); + while ((len = read(joystick->hwdata->fd, events, (sizeof events))) > 0) { + len /= sizeof(events[0]); for (i = 0; i < len; ++i) { switch (events[i].type & ~JS_EVENT_INIT) { case JS_EVENT_AXIS: if (events[i].number < joystick->naxes) { #ifndef NO_LOGICAL_JOYSTICKS - if (!LogicalJoystickAxis (joystick, - events[i].number, - events[i].value)) + if (!LogicalJoystickAxis(joystick, + events[i].number, + events[i].value)) #endif - SDL_PrivateJoystickAxis (joystick, - events[i].number, - events[i].value); + SDL_PrivateJoystickAxis(joystick, + events[i].number, + events[i].value); break; } events[i].number -= joystick->naxes; other_axis = (events[i].number / 2); if (other_axis < joystick->nhats) { - HandleHat (joystick, other_axis, - events[i].number % 2, events[i].value); + HandleHat(joystick, other_axis, + events[i].number % 2, events[i].value); break; } events[i].number -= joystick->nhats * 2; other_axis = (events[i].number / 2); if (other_axis < joystick->nballs) { - HandleBall (joystick, other_axis, - events[i].number % 2, events[i].value); + HandleBall(joystick, other_axis, + events[i].number % 2, events[i].value); break; } break; case JS_EVENT_BUTTON: #ifndef NO_LOGICAL_JOYSTICKS - if (!LogicalJoystickButton (joystick, - events[i].number, - events[i].value)) + if (!LogicalJoystickButton(joystick, + events[i].number, events[i].value)) #endif - SDL_PrivateJoystickButton (joystick, - events[i].number, - events[i].value); + SDL_PrivateJoystickButton(joystick, + events[i].number, + events[i].value); break; default: /* ?? */ @@ -1062,7 +1060,7 @@ #if SDL_INPUT_LINUXEV static __inline__ int -EV_AxisCorrect (SDL_Joystick * joystick, int which, int value) +EV_AxisCorrect(SDL_Joystick * joystick, int which, int value) { struct axis_correct *correct; @@ -1090,7 +1088,7 @@ } static __inline__ void -EV_HandleEvents (SDL_Joystick * joystick) +EV_HandleEvents(SDL_Joystick * joystick) { struct input_event events[32]; int i, len; @@ -1098,13 +1096,13 @@ #ifndef NO_LOGICAL_JOYSTICKS if (SDL_joylist[joystick->index].fname == NULL) { - SDL_joylist_head (i, joystick->index); - return EV_HandleEvents (SDL_joylist[i].joy); + SDL_joylist_head(i, joystick->index); + return EV_HandleEvents(SDL_joylist[i].joy); } #endif - while ((len = read (joystick->hwdata->fd, events, (sizeof events))) > 0) { - len /= sizeof (events[0]); + while ((len = read(joystick->hwdata->fd, events, (sizeof events))) > 0) { + len /= sizeof(events[0]); for (i = 0; i < len; ++i) { code = events[i].code; switch (events[i].type) { @@ -1112,15 +1110,15 @@ if (code >= BTN_MISC) { code -= BTN_MISC; #ifndef NO_LOGICAL_JOYSTICKS - if (!LogicalJoystickButton (joystick, - joystick->hwdata-> - key_map[code], - events[i].value)) + if (!LogicalJoystickButton(joystick, + joystick->hwdata-> + key_map[code], + events[i].value)) #endif - SDL_PrivateJoystickButton (joystick, - joystick->hwdata-> - key_map[code], - events[i].value); + SDL_PrivateJoystickButton(joystick, + joystick->hwdata-> + key_map[code], + events[i].value); } break; case EV_ABS: @@ -1134,20 +1132,20 @@ case ABS_HAT3X: case ABS_HAT3Y: code -= ABS_HAT0X; - HandleHat (joystick, code / 2, code % 2, events[i].value); + HandleHat(joystick, code / 2, code % 2, events[i].value); break; default: events[i].value = - EV_AxisCorrect (joystick, code, events[i].value); + EV_AxisCorrect(joystick, code, events[i].value); #ifndef NO_LOGICAL_JOYSTICKS - if (!LogicalJoystickAxis (joystick, - joystick->hwdata-> - abs_map[code], events[i].value)) + if (!LogicalJoystickAxis(joystick, + joystick->hwdata-> + abs_map[code], events[i].value)) #endif - SDL_PrivateJoystickAxis (joystick, - joystick->hwdata-> - abs_map[code], - events[i].value); + SDL_PrivateJoystickAxis(joystick, + joystick->hwdata-> + abs_map[code], + events[i].value); break; } break; @@ -1156,8 +1154,7 @@ case REL_X: case REL_Y: code -= REL_X; - HandleBall (joystick, code / 2, code % 2, - events[i].value); + HandleBall(joystick, code / 2, code % 2, events[i].value); break; default: break; @@ -1172,16 +1169,16 @@ #endif /* SDL_INPUT_LINUXEV */ void -SDL_SYS_JoystickUpdate (SDL_Joystick * joystick) +SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) { int i; #if SDL_INPUT_LINUXEV if (joystick->hwdata->is_hid) - EV_HandleEvents (joystick); + EV_HandleEvents(joystick); else #endif - JS_HandleEvents (joystick); + JS_HandleEvents(joystick); /* Deliver ball motion updates */ for (i = 0; i < joystick->nballs; ++i) { @@ -1192,20 +1189,20 @@ if (xrel || yrel) { joystick->hwdata->balls[i].axis[0] = 0; joystick->hwdata->balls[i].axis[1] = 0; - SDL_PrivateJoystickBall (joystick, (Uint8) i, xrel, yrel); + SDL_PrivateJoystickBall(joystick, (Uint8) i, xrel, yrel); } } } /* Function to close a joystick after use */ void -SDL_SYS_JoystickClose (SDL_Joystick * joystick) +SDL_SYS_JoystickClose(SDL_Joystick * joystick) { #ifndef NO_LOGICAL_JOYSTICKS register int i; if (SDL_joylist[joystick->index].fname == NULL) { - SDL_joylist_head (i, joystick->index); - SDL_JoystickClose (SDL_joylist[i].joy); + SDL_joylist_head(i, joystick->index); + SDL_JoystickClose(SDL_joylist[i].joy); } #endif @@ -1213,26 +1210,26 @@ #ifndef NO_LOGICAL_JOYSTICKS if (SDL_joylist[joystick->index].fname != NULL) #endif - close (joystick->hwdata->fd); + close(joystick->hwdata->fd); if (joystick->hwdata->hats) { - SDL_free (joystick->hwdata->hats); + SDL_free(joystick->hwdata->hats); } if (joystick->hwdata->balls) { - SDL_free (joystick->hwdata->balls); + SDL_free(joystick->hwdata->balls); } - SDL_free (joystick->hwdata); + SDL_free(joystick->hwdata); joystick->hwdata = NULL; } } /* Function to perform any system-specific joystick related cleanup */ void -SDL_SYS_JoystickQuit (void) +SDL_SYS_JoystickQuit(void) { int i; for (i = 0; SDL_joylist[i].fname; ++i) { - SDL_free (SDL_joylist[i].fname); + SDL_free(SDL_joylist[i].fname); } SDL_joylist[0].fname = NULL; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/joystick/macos/SDL_sysjoystick.c --- a/src/joystick/macos/SDL_sysjoystick.c Mon May 29 03:53:21 2006 +0000 +++ b/src/joystick/macos/SDL_sysjoystick.c Mon May 29 04:04:35 2006 +0000 @@ -64,7 +64,7 @@ * on an unrecoverable fatal error. */ int -SDL_SYS_JoystickInit (void) +SDL_SYS_JoystickInit(void) { static ISpDeviceClass classes[4] = { kISpDeviceClass_Joystick, @@ -79,61 +79,59 @@ UInt32 count, numJoysticks; if ((Ptr) 0 == (Ptr) ISpStartup) { - SDL_SetError ("InputSprocket not installed"); + SDL_SetError("InputSprocket not installed"); return -1; // InputSprocket not installed } if ((Ptr) 0 == (Ptr) ISpGetVersion) { - SDL_SetError ("InputSprocket not version 1.1 or newer"); + SDL_SetError("InputSprocket not version 1.1 or newer"); return -1; // old version of ISp (not at least 1.1) } - ISpStartup (); + ISpStartup(); /* Get all the joysticks */ numJoysticks = 0; for (i = 0; classes[i]; ++i) { count = 0; - err = ISpDevices_ExtractByClass (classes[i], - MAX_JOYSTICKS - numJoysticks, - &count, - &SYS_Joysticks[numJoysticks]); + err = ISpDevices_ExtractByClass(classes[i], + MAX_JOYSTICKS - numJoysticks, + &count, &SYS_Joysticks[numJoysticks]); numJoysticks += count; } for (i = 0; i < numJoysticks; i++) { - ISpDevice_GetDefinition (SYS_Joysticks[i], - sizeof (ISpDeviceDefinition), - &SYS_DevDef[i]); + ISpDevice_GetDefinition(SYS_Joysticks[i], + sizeof(ISpDeviceDefinition), &SYS_DevDef[i]); - err = ISpElementList_New (0, NULL, &SYS_Elements[i], 0); + err = ISpElementList_New(0, NULL, &SYS_Elements[i], 0); if (err) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return -1; } - ISpDevice_GetElementList (SYS_Joysticks[i], &SYS_Elements[i]); + ISpDevice_GetElementList(SYS_Joysticks[i], &SYS_Elements[i]); } - ISpDevices_Deactivate (numJoysticks, SYS_Joysticks); + ISpDevices_Deactivate(numJoysticks, SYS_Joysticks); return numJoysticks; } /* Function to get the device-dependent name of a joystick */ const char * -SDL_SYS_JoystickName (int index) +SDL_SYS_JoystickName(int index) { static char name[64]; int len; /* convert pascal string to c-string */ len = SYS_DevDef[index].deviceName[0]; - if (len >= sizeof (name)) { - len = (sizeof (name) - 1); + if (len >= sizeof(name)) { + len = (sizeof(name) - 1); } - SDL_memcpy (name, &SYS_DevDef[index].deviceName[1], len); + SDL_memcpy(name, &SYS_DevDef[index].deviceName[1], len); name[len] = '\0'; return name; @@ -145,7 +143,7 @@ It returns 0, or -1 if there is an error. */ int -SDL_SYS_JoystickOpen (SDL_Joystick * joystick) +SDL_SYS_JoystickOpen(SDL_Joystick * joystick) { int index; UInt32 count, gotCount, count2; @@ -159,39 +157,39 @@ /* allocate memory for system specific hardware data */ joystick->hwdata = - (struct joystick_hwdata *) SDL_malloc (sizeof (*joystick->hwdata)); + (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata)); if (joystick->hwdata == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } - SDL_memset (joystick->hwdata, 0, sizeof (*joystick->hwdata)); - SDL_strlcpy (joystick->hwdata->name, SDL_SYS_JoystickName (index), - SDL_arraysize (joystick->hwdata->name)); + SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); + SDL_strlcpy(joystick->hwdata->name, SDL_SYS_JoystickName(index), + SDL_arraysize(joystick->hwdata->name)); joystick->name = joystick->hwdata->name; - ISpElementList_ExtractByKind (SYS_Elements[index], - kISpElementKind_Axis, - count, &gotCount, joystick->hwdata->refs); + ISpElementList_ExtractByKind(SYS_Elements[index], + kISpElementKind_Axis, + count, &gotCount, joystick->hwdata->refs); numAxis = gotCount; count -= gotCount; count2 += gotCount; - ISpElementList_ExtractByKind (SYS_Elements[index], - kISpElementKind_DPad, - count, - &gotCount, - &(joystick->hwdata->refs[count2])); + ISpElementList_ExtractByKind(SYS_Elements[index], + kISpElementKind_DPad, + count, + &gotCount, + &(joystick->hwdata->refs[count2])); numHats = gotCount; count -= gotCount; count2 += gotCount; - ISpElementList_ExtractByKind (SYS_Elements[index], - kISpElementKind_Button, - count, - &gotCount, - &(joystick->hwdata->refs[count2])); + ISpElementList_ExtractByKind(SYS_Elements[index], + kISpElementKind_Button, + count, + &gotCount, + &(joystick->hwdata->refs[count2])); numButtons = gotCount; count -= gotCount; @@ -202,7 +200,7 @@ joystick->nballs = numBalls; joystick->nbuttons = numButtons; - ISpDevices_Activate (1, &SYS_Joysticks[index]); + ISpDevices_Activate(1, &SYS_Joysticks[index]); return 0; } @@ -213,7 +211,7 @@ * and update joystick device state. */ void -SDL_SYS_JoystickUpdate (SDL_Joystick * joystick) +SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) { int i, j; ISpAxisData a; @@ -224,17 +222,17 @@ for (i = 0, j = 0; i < joystick->naxes; i++, j++) { Sint16 value; - ISpElement_GetSimpleState (joystick->hwdata->refs[j], &a); - value = (ISpSymmetricAxisToFloat (a) * 32767.0); + ISpElement_GetSimpleState(joystick->hwdata->refs[j], &a); + value = (ISpSymmetricAxisToFloat(a) * 32767.0); if (value != joystick->axes[i]) { - SDL_PrivateJoystickAxis (joystick, i, value); + SDL_PrivateJoystickAxis(joystick, i, value); } } for (i = 0; i < joystick->nhats; i++, j++) { Uint8 pos; - ISpElement_GetSimpleState (joystick->hwdata->refs[j], &b); + ISpElement_GetSimpleState(joystick->hwdata->refs[j], &b); switch (b) { case kISpPadIdle: pos = SDL_HAT_CENTERED; @@ -265,7 +263,7 @@ break; } if (pos != joystick->hats[i]) { - SDL_PrivateJoystickHat (joystick, i, pos); + SDL_PrivateJoystickHat(joystick, i, pos); } } @@ -274,29 +272,29 @@ } for (i = 0; i < joystick->nbuttons; i++, j++) { - ISpElement_GetSimpleState (joystick->hwdata->refs[j], &d); + ISpElement_GetSimpleState(joystick->hwdata->refs[j], &d); if (d != joystick->buttons[i]) { - SDL_PrivateJoystickButton (joystick, i, d); + SDL_PrivateJoystickButton(joystick, i, d); } } } /* Function to close a joystick after use */ void -SDL_SYS_JoystickClose (SDL_Joystick * joystick) +SDL_SYS_JoystickClose(SDL_Joystick * joystick) { int index; index = joystick->index; - ISpDevices_Deactivate (1, &SYS_Joysticks[index]); + ISpDevices_Deactivate(1, &SYS_Joysticks[index]); } /* Function to perform any system-specific joystick related cleanup */ void -SDL_SYS_JoystickQuit (void) +SDL_SYS_JoystickQuit(void) { - ISpShutdown (); + ISpShutdown(); } #endif /* SDL_JOYSTICK_MACOS */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/joystick/mint/SDL_sysjoystick.c --- a/src/joystick/mint/SDL_sysjoystick.c Mon May 29 03:53:21 2006 +0000 +++ b/src/joystick/mint/SDL_sysjoystick.c Mon May 29 04:04:35 2006 +0000 @@ -154,17 +154,17 @@ /*--- Functions prototypes ---*/ -static int GetEnabledAtariJoystick (int index); -static void UpdateJoypads (void); +static int GetEnabledAtariJoystick(int index); +static void UpdateJoypads(void); /*--- Functions ---*/ int -SDL_SYS_JoystickInit (void) +SDL_SYS_JoystickInit(void) { int i; unsigned long cookie_mch; - const char *envr = SDL_getenv ("SDL_JOYSTICK_ATARI"); + const char *envr = SDL_getenv("SDL_JOYSTICK_ATARI"); #define TEST_JOY_ENABLED(env,idstring,num) \ if (SDL_strstr(env,idstring"-off")) { \ @@ -175,7 +175,7 @@ } /* Cookie _MCH present ? if not, assume ST machine */ - if (Getcookie (C__MCH, &cookie_mch) != C_FOUND) { + if (Getcookie(C__MCH, &cookie_mch) != C_FOUND) { cookie_mch = MCH_ST << 16; } @@ -200,38 +200,38 @@ || (cookie_mch == MCH_TT << 16) || (cookie_mch == MCH_F30 << 16) || (cookie_mch == MCH_ARANYM << 16)) { if (SDL_AtariIkbd_enabled != 0) { - TEST_JOY_ENABLED (envr, "ikbd-joy1", IKBD_JOY1); + TEST_JOY_ENABLED(envr, "ikbd-joy1", IKBD_JOY1); } } /* Joypads ports only on STE and Falcon */ if ((cookie_mch == MCH_STE << 16) || (cookie_mch == MCH_F30 << 16)) { - TEST_JOY_ENABLED (envr, "porta-pad", PORTA_PAD); + TEST_JOY_ENABLED(envr, "porta-pad", PORTA_PAD); if (!atarijoysticks[PORTA_PAD].enabled) { - TEST_JOY_ENABLED (envr, "porta-joy0", PORTA_JOY0); - TEST_JOY_ENABLED (envr, "porta-joy1", PORTA_JOY1); + TEST_JOY_ENABLED(envr, "porta-joy0", PORTA_JOY0); + TEST_JOY_ENABLED(envr, "porta-joy1", PORTA_JOY1); if (!(atarijoysticks[PORTA_JOY0].enabled) && !(atarijoysticks[PORTA_JOY1].enabled)) { - TEST_JOY_ENABLED (envr, "porta-lp", PORTA_LP); + TEST_JOY_ENABLED(envr, "porta-lp", PORTA_LP); if (!atarijoysticks[PORTA_LP].enabled) { - TEST_JOY_ENABLED (envr, "porta-anpad", PORTA_ANPAD); + TEST_JOY_ENABLED(envr, "porta-anpad", PORTA_ANPAD); } } } - TEST_JOY_ENABLED (envr, "portb-pad", PORTB_PAD); + TEST_JOY_ENABLED(envr, "portb-pad", PORTB_PAD); if (!atarijoysticks[PORTB_PAD].enabled) { - TEST_JOY_ENABLED (envr, "portb-joy0", PORTB_JOY0); - TEST_JOY_ENABLED (envr, "portb-joy1", PORTB_JOY1); + TEST_JOY_ENABLED(envr, "portb-joy0", PORTB_JOY0); + TEST_JOY_ENABLED(envr, "portb-joy1", PORTB_JOY1); if (!(atarijoysticks[PORTB_JOY0].enabled) && !(atarijoysticks[PORTB_JOY1].enabled)) { - TEST_JOY_ENABLED (envr, "portb-anpad", PORTB_ANPAD); + TEST_JOY_ENABLED(envr, "portb-anpad", PORTB_ANPAD); } } } if (!atarijoysticks[IKBD_JOY1].enabled) { if (SDL_AtariXbios_enabled != 0) { - TEST_JOY_ENABLED (envr, "xbios-joy1", XBIOS_JOY1); + TEST_JOY_ENABLED(envr, "xbios-joy1", XBIOS_JOY1); } } #if 0 @@ -239,8 +239,8 @@ if ((cookie_mch == MCH_ST << 16) || ((cookie_mch >> 16) == MCH_STE) || (cookie_mch == MCH_TT << 16) || (cookie_mch == MCH_F30 << 16)) { - TEST_JOY_ENABLED (envr, "para-joy0", PARA_JOY0); - TEST_JOY_ENABLED (envr, "para-joy1", PARA_JOY1); + TEST_JOY_ENABLED(envr, "para-joy0", PARA_JOY0); + TEST_JOY_ENABLED(envr, "para-joy1", PARA_JOY1); } #endif } @@ -265,7 +265,7 @@ } static int -GetEnabledAtariJoystick (int index) +GetEnabledAtariJoystick(int index) { int i, j; @@ -289,11 +289,11 @@ } const char * -SDL_SYS_JoystickName (int index) +SDL_SYS_JoystickName(int index) { int numjoystick; - numjoystick = GetEnabledAtariJoystick (index); + numjoystick = GetEnabledAtariJoystick(index); if (numjoystick == -1) return NULL; @@ -301,11 +301,11 @@ } int -SDL_SYS_JoystickOpen (SDL_Joystick * joystick) +SDL_SYS_JoystickOpen(SDL_Joystick * joystick) { int numjoystick; - numjoystick = GetEnabledAtariJoystick (joystick->index); + numjoystick = GetEnabledAtariJoystick(joystick->index); if (numjoystick == -1) return -1; @@ -335,20 +335,20 @@ } void -SDL_SYS_JoystickUpdate (SDL_Joystick * joystick) +SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) { int numjoystick; Uint8 hatstate; Uint32 curstate, prevstate; - numjoystick = GetEnabledAtariJoystick (joystick->index); + numjoystick = GetEnabledAtariJoystick(joystick->index); if (numjoystick == -1) return; prevstate = atarijoysticks[numjoystick].prevstate; if (joypad_ports_enabled) { - Supexec (UpdateJoypads); + Supexec(UpdateJoypads); } switch (numjoystick) { @@ -378,16 +378,16 @@ if (curstate & IKBD_JOY_DOWN) { hatstate |= SDL_HAT_DOWN; } - SDL_PrivateJoystickHat (joystick, 0, hatstate); + SDL_PrivateJoystickHat(joystick, 0, hatstate); /* Button */ if ((curstate & IKBD_JOY_FIRE) && !(prevstate & IKBD_JOY_FIRE)) { - SDL_PrivateJoystickButton (joystick, 0, SDL_PRESSED); + SDL_PrivateJoystickButton(joystick, 0, SDL_PRESSED); } if (!(curstate & IKBD_JOY_FIRE) && (prevstate & IKBD_JOY_FIRE)) { - SDL_PrivateJoystickButton (joystick, 0, SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, 0, SDL_RELEASED); } } atarijoysticks[numjoystick].prevstate = curstate; @@ -417,7 +417,7 @@ if (curstate & (1 << JP_DOWN)) { hatstate |= SDL_HAT_DOWN; } - SDL_PrivateJoystickHat (joystick, 0, hatstate); + SDL_PrivateJoystickHat(joystick, 0, hatstate); /* Buttons */ for (i = 0; i < JP_NUM_BUTTONS; i++) { @@ -426,10 +426,10 @@ button = 1 << jp_buttons[i]; if ((curstate & button) && !(prevstate & button)) { - SDL_PrivateJoystickButton (joystick, i, SDL_PRESSED); + SDL_PrivateJoystickButton(joystick, i, SDL_PRESSED); } if (!(curstate & button) && (prevstate & button)) { - SDL_PrivateJoystickButton (joystick, i, SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, i, SDL_RELEASED); } } } @@ -477,16 +477,16 @@ if (curstate & PORT_JS_DOWN) { hatstate |= SDL_HAT_DOWN; } - SDL_PrivateJoystickHat (joystick, 0, hatstate); + SDL_PrivateJoystickHat(joystick, 0, hatstate); /* Button */ if ((curstate & PORT_JS_FIRE) && !(prevstate & PORT_JS_FIRE)) { - SDL_PrivateJoystickButton (joystick, 0, SDL_PRESSED); + SDL_PrivateJoystickButton(joystick, 0, SDL_PRESSED); } if (!(curstate & PORT_JS_FIRE) && (prevstate & PORT_JS_FIRE)) { - SDL_PrivateJoystickButton (joystick, 0, SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, 0, SDL_RELEASED); } } atarijoysticks[numjoystick].prevstate = curstate; @@ -502,11 +502,11 @@ if (curstate != prevstate) { /* X axis */ - SDL_PrivateJoystickAxis (joystick, 0, - jp_lightpens[0] ^ 0x8000); + SDL_PrivateJoystickAxis(joystick, 0, + jp_lightpens[0] ^ 0x8000); /* Y axis */ - SDL_PrivateJoystickAxis (joystick, 1, - jp_lightpens[1] ^ 0x8000); + SDL_PrivateJoystickAxis(joystick, 1, + jp_lightpens[1] ^ 0x8000); /* Buttons */ for (i = 0; i < 2; i++) { int button; @@ -514,10 +514,10 @@ button = 1 << (30 + i); if ((curstate & button) && !(prevstate & button)) { - SDL_PrivateJoystickButton (joystick, i, SDL_PRESSED); + SDL_PrivateJoystickButton(joystick, i, SDL_PRESSED); } if (!(curstate & button) && (prevstate & button)) { - SDL_PrivateJoystickButton (joystick, i, SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, i, SDL_RELEASED); } } } @@ -539,11 +539,11 @@ if (curstate != prevstate) { /* X axis */ - SDL_PrivateJoystickAxis (joystick, 0, - jp_paddles[numpaddle] ^ 0x8000); + SDL_PrivateJoystickAxis(joystick, 0, + jp_paddles[numpaddle] ^ 0x8000); /* Y axis */ - SDL_PrivateJoystickAxis (joystick, 1, - jp_paddles[numpaddle + 1] ^ 0x8000); + SDL_PrivateJoystickAxis(joystick, 1, + jp_paddles[numpaddle + 1] ^ 0x8000); /* Buttons */ for (i = 0; i < 2; i++) { int button; @@ -551,10 +551,10 @@ button = 1 << (30 + i); if ((curstate & button) && !(prevstate & button)) { - SDL_PrivateJoystickButton (joystick, i, SDL_PRESSED); + SDL_PrivateJoystickButton(joystick, i, SDL_PRESSED); } if (!(curstate & button) && (prevstate & button)) { - SDL_PrivateJoystickButton (joystick, i, SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, i, SDL_RELEASED); } } } @@ -572,13 +572,13 @@ } void -SDL_SYS_JoystickClose (SDL_Joystick * joystick) +SDL_SYS_JoystickClose(SDL_Joystick * joystick) { return; } void -SDL_SYS_JoystickQuit (void) +SDL_SYS_JoystickQuit(void) { SDL_numjoysticks = 0; return; @@ -599,7 +599,7 @@ #define JOYPAD_IO ((*(volatile struct JOYPAD_IO_S *)JOYPAD_IO_BASE)) static void -UpdateJoypads (void) +UpdateJoypads(void) { Uint16 tmp; diff -r 1fddae038bc8 -r 4da1ee79c9af src/joystick/os2/SDL_sysjoystick.c --- a/src/joystick/os2/SDL_sysjoystick.c Mon May 29 03:53:21 2006 +0000 +++ b/src/joystick/os2/SDL_sysjoystick.c Mon May 29 04:04:35 2006 +0000 @@ -93,10 +93,10 @@ }; /* OS/2 Implementation Function Prototypes */ -APIRET joyPortOpen (HFILE * hGame); -void joyPortClose (HFILE * hGame); -int joyGetData (char *joyenv, char *name, char stopchar, size_t maxchars); -int joyGetEnv (struct _joycfg *joydata); +APIRET joyPortOpen(HFILE * hGame); +void joyPortClose(HFILE * hGame); +int joyGetData(char *joyenv, char *name, char stopchar, size_t maxchars); +int joyGetEnv(struct _joycfg *joydata); @@ -107,7 +107,7 @@ /* It should return 0, or -1 on an unrecoverable fatal error. */ /************************************************************************/ int -SDL_SYS_JoystickInit (void) +SDL_SYS_JoystickInit(void) { APIRET rc; /* Generic OS/2 return code */ GAME_PORT_STRUCT stJoyStatus; /* Joystick Status Structure */ @@ -124,14 +124,14 @@ /* Get Max Number of Devices */ - rc = joyPortOpen (&hJoyPort); /* Open GAME$ port */ + rc = joyPortOpen(&hJoyPort); /* Open GAME$ port */ if (rc != 0) return 0; /* Cannot open... report no joystick */ - ulDataLen = sizeof (stGameParms); - rc = DosDevIOCtl (hJoyPort, IOCTL_CAT_USER, GAME_GET_PARMS, NULL, 0, NULL, &stGameParms, ulDataLen, &ulDataLen); /* Ask device info */ + ulDataLen = sizeof(stGameParms); + rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_GET_PARMS, NULL, 0, NULL, &stGameParms, ulDataLen, &ulDataLen); /* Ask device info */ if (rc != 0) { - joyPortClose (&hJoyPort); - SDL_SetError ("Could not read joystick port."); + joyPortClose(&hJoyPort); + SDL_SetError("Could not read joystick port."); return -1; } if (stGameParms.useA != 0) @@ -142,36 +142,36 @@ maxdevs = MAX_JOYSTICKS; /* Defines min/max axes values (callibration) */ - ulDataLen = sizeof (stGameCalib); - rc = DosDevIOCtl (hJoyPort, IOCTL_CAT_USER, GAME_GET_CALIB, - NULL, 0, NULL, &stGameCalib, ulDataLen, &ulDataLen); + ulDataLen = sizeof(stGameCalib); + rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_GET_CALIB, + NULL, 0, NULL, &stGameCalib, ulDataLen, &ulDataLen); if (rc != 0) { - joyPortClose (&hJoyPort); - SDL_SetError ("Could not read callibration data."); + joyPortClose(&hJoyPort); + SDL_SetError("Could not read callibration data."); return -1; } /* Determine how many joysticks are active */ numdevs = 0; /* Points no device */ ucNewJoystickMask = 0x0F; /* read all 4 joystick axis */ - ulDataLen = sizeof (ucNewJoystickMask); - rc = DosDevIOCtl (hJoyPort, IOCTL_CAT_USER, GAME_PORT_RESET, - &ucNewJoystickMask, ulDataLen, &ulDataLen, NULL, 0, - NULL); + ulDataLen = sizeof(ucNewJoystickMask); + rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_PORT_RESET, + &ucNewJoystickMask, ulDataLen, &ulDataLen, NULL, 0, + NULL); if (rc == 0) { - ulDataLen = sizeof (stJoyStatus); - rc = DosDevIOCtl (hJoyPort, IOCTL_CAT_USER, GAME_PORT_GET, - NULL, 0, NULL, &stJoyStatus, ulDataLen, &ulDataLen); + ulDataLen = sizeof(stJoyStatus); + rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_PORT_GET, + NULL, 0, NULL, &stJoyStatus, ulDataLen, &ulDataLen); if (rc != 0) { - joyPortClose (&hJoyPort); - SDL_SetError ("Could not call joystick port."); + joyPortClose(&hJoyPort); + SDL_SetError("Could not call joystick port."); return -1; } ulLastTick = stJoyStatus.ulJs_Ticks; while (stJoyStatus.ulJs_Ticks == ulLastTick) { - rc = DosDevIOCtl (hJoyPort, IOCTL_CAT_USER, GAME_PORT_GET, - NULL, 0, NULL, &stJoyStatus, ulDataLen, - &ulDataLen); + rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_PORT_GET, + NULL, 0, NULL, &stJoyStatus, ulDataLen, + &ulDataLen); } if ((stJoyStatus.ucJs_JoyStickMask & 0x03) > 0) numdevs++; @@ -185,7 +185,7 @@ /* If *any* joystick was detected... Let's configure SDL for them */ if (numdevs > 0) { /* Verify if it is a "user defined" joystick */ - if (joyGetEnv (&joycfg)) { + if (joyGetEnv(&joycfg)) { GAME_3POS_STRUCT *axis[4]; axis[0] = &stGameCalib.Ax; axis[1] = &stGameCalib.Ay; @@ -234,8 +234,8 @@ SYS_JoyData[0].buttoncalc[3] = ((axis[3]->upper + axis[3]->centre) >> 1); /* Intialize Joystick Name */ - SDL_strlcpy (SYS_JoyData[0].szDeviceName, joycfg.name, - SDL_arraysize (SYS_JoyData[0].szDeviceName)); + SDL_strlcpy(SYS_JoyData[0].szDeviceName, joycfg.name, + SDL_arraysize(SYS_JoyData[0].szDeviceName)); } /* Default Init ... autoconfig */ else { @@ -309,9 +309,9 @@ if (numdevs > maxdevs) numdevs = maxdevs; for (i = 0; i < numdevs; i++) - SDL_snprintf (SYS_JoyData[i].szDeviceName, - SDL_arraysize (SYS_JoyData[i].szDeviceName), - "Default Joystick %c", 'A' + SYS_JoyData[i].id); + SDL_snprintf(SYS_JoyData[i].szDeviceName, + SDL_arraysize(SYS_JoyData[i].szDeviceName), + "Default Joystick %c", 'A' + SYS_JoyData[i].id); } } @@ -324,7 +324,7 @@ /* Function to get the device-dependent name of a joystick */ /***********************************************************/ const char * -SDL_SYS_JoystickName (int index) +SDL_SYS_JoystickName(int index) { /* No need to verify if device exists, already done in upper layer */ return (SYS_JoyData[index].szDeviceName); @@ -339,20 +339,20 @@ /* It returns 0, or -1 if there is an error. */ /******************************************************************************/ int -SDL_SYS_JoystickOpen (SDL_Joystick * joystick) +SDL_SYS_JoystickOpen(SDL_Joystick * joystick) { int index; /* Index shortcut for index in joystick structure */ int i; /* Generic Counter */ /* allocate memory for system specific hardware data */ joystick->hwdata = - (struct joystick_hwdata *) SDL_malloc (sizeof (*joystick->hwdata)); + (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata)); if (joystick->hwdata == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } /* Reset Hardware Data */ - SDL_memset (joystick->hwdata, 0, sizeof (*joystick->hwdata)); + SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); /* ShortCut Pointer */ index = joystick->index; @@ -364,9 +364,9 @@ ((AXIS_MAX + AXIS_MIN) >> 1) - SYS_JoyData[index].axes_med[i]; //joystick->hwdata->transaxes[i].scale = (float)((AXIS_MAX - AXIS_MIN)/(SYS_JoyData[index].axes_max[i]-SYS_JoyData[index].axes_min[i])); joystick->hwdata->transaxes[i].scale1 = - (float) abs ((AXIS_MIN / SYS_JoyData[index].axes_min[i])); + (float) abs((AXIS_MIN / SYS_JoyData[index].axes_min[i])); joystick->hwdata->transaxes[i].scale2 = - (float) abs ((AXIS_MAX / SYS_JoyData[index].axes_max[i])); + (float) abs((AXIS_MAX / SYS_JoyData[index].axes_max[i])); } else { joystick->hwdata->transaxes[i].offset = 0; //joystick->hwdata->transaxes[i].scale = 1.0; /* Just in case */ @@ -394,7 +394,7 @@ /* and update joystick device state. */ /***************************************************************************/ void -SDL_SYS_JoystickUpdate (SDL_Joystick * joystick) +SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) { APIRET rc; /* Generic OS/2 return code */ int index; /* index shortcurt to joystick index */ @@ -407,11 +407,11 @@ ULONG ulDataLen; /* Size of data */ GAME_STATUS_STRUCT stGameStatus; /* Joystick Status Structure */ - ulDataLen = sizeof (stGameStatus); - rc = DosDevIOCtl (hJoyPort, IOCTL_CAT_USER, GAME_GET_STATUS, - NULL, 0, NULL, &stGameStatus, ulDataLen, &ulDataLen); + ulDataLen = sizeof(stGameStatus); + rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_GET_STATUS, + NULL, 0, NULL, &stGameStatus, ulDataLen, &ulDataLen); if (rc != 0) { - SDL_SetError ("Could not read joystick status."); + SDL_SetError("Could not read joystick status."); return; /* Could not read data */ } @@ -456,7 +456,7 @@ } change = (value - joystick->axes[i]); if ((change < -JOY_AXIS_THRESHOLD) || (change > JOY_AXIS_THRESHOLD)) { - SDL_PrivateJoystickAxis (joystick, (Uint8) i, (Sint16) value); + SDL_PrivateJoystickAxis(joystick, (Uint8) i, (Sint16) value); } } @@ -475,15 +475,15 @@ Button C: 1011 0000 Button D: 0111 0000 */ - if ((~stGameStatus.curdata.butMask) >> 4 & JOY_BUTTON_FLAG (i)) { + if ((~stGameStatus.curdata.butMask) >> 4 & JOY_BUTTON_FLAG(i)) { if (!joystick->buttons[i - corr]) { - SDL_PrivateJoystickButton (joystick, (Uint8) (i - corr), - SDL_PRESSED); + SDL_PrivateJoystickButton(joystick, (Uint8) (i - corr), + SDL_PRESSED); } } else { if (joystick->buttons[i - corr]) { - SDL_PrivateJoystickButton (joystick, (Uint8) (i - corr), - SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, (Uint8) (i - corr), + SDL_RELEASED); } } } @@ -497,27 +497,27 @@ */ if (joystick->nbuttons >= 5) { if (stGameStatus.curdata.B.x < SYS_JoyData[index].buttoncalc[0]) - SDL_PrivateJoystickButton (joystick, (Uint8) 4, SDL_PRESSED); + SDL_PrivateJoystickButton(joystick, (Uint8) 4, SDL_PRESSED); else - SDL_PrivateJoystickButton (joystick, (Uint8) 4, SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, (Uint8) 4, SDL_RELEASED); } if (joystick->nbuttons >= 6) { if (stGameStatus.curdata.B.y < SYS_JoyData[index].buttoncalc[1]) - SDL_PrivateJoystickButton (joystick, (Uint8) 5, SDL_PRESSED); + SDL_PrivateJoystickButton(joystick, (Uint8) 5, SDL_PRESSED); else - SDL_PrivateJoystickButton (joystick, (Uint8) 5, SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, (Uint8) 5, SDL_RELEASED); } if (joystick->nbuttons >= 7) { if (stGameStatus.curdata.B.x > SYS_JoyData[index].buttoncalc[2]) - SDL_PrivateJoystickButton (joystick, (Uint8) 6, SDL_PRESSED); + SDL_PrivateJoystickButton(joystick, (Uint8) 6, SDL_PRESSED); else - SDL_PrivateJoystickButton (joystick, (Uint8) 6, SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, (Uint8) 6, SDL_RELEASED); } if (joystick->nbuttons >= 8) { if (stGameStatus.curdata.B.y > SYS_JoyData[index].buttoncalc[3]) - SDL_PrivateJoystickButton (joystick, (Uint8) 7, SDL_PRESSED); + SDL_PrivateJoystickButton(joystick, (Uint8) 7, SDL_PRESSED); else - SDL_PrivateJoystickButton (joystick, (Uint8) 7, SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, (Uint8) 7, SDL_RELEASED); } /* joystick hat events */ @@ -532,11 +532,11 @@ /* Function to close a joystick after use */ /******************************************/ void -SDL_SYS_JoystickClose (SDL_Joystick * joystick) +SDL_SYS_JoystickClose(SDL_Joystick * joystick) { if (joystick->hwdata != NULL) { /* free system specific hardware data */ - SDL_free (joystick->hwdata); + SDL_free(joystick->hwdata); } } @@ -546,9 +546,9 @@ /* Function to perform any system-specific joystick related cleanup */ /********************************************************************/ void -SDL_SYS_JoystickQuit (void) +SDL_SYS_JoystickQuit(void) { - joyPortClose (&hJoyPort); + joyPortClose(&hJoyPort); } @@ -564,7 +564,7 @@ /* Open Joystick Port, if not opened yet */ /*****************************************/ APIRET -joyPortOpen (HFILE * hGame) +joyPortOpen(HFILE * hGame) { APIRET rc; /* Generic Return Code */ ULONG ulAction; /* ? */ @@ -575,26 +575,25 @@ if (*hGame != NULL) return 0; /* Open GAME$ for read */ - rc = DosOpen ((PSZ) GAMEPDDNAME, hGame, &ulAction, 0, FILE_READONLY, - FILE_OPEN, OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, - NULL); + rc = DosOpen((PSZ) GAMEPDDNAME, hGame, &ulAction, 0, FILE_READONLY, + FILE_OPEN, OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, NULL); if (rc != 0) { - SDL_SetError ("Could not open Joystick Port."); + SDL_SetError("Could not open Joystick Port."); return -1; } /* Get Joystick Driver Version... must be 2.0 or higher */ ulVersion = 0; - ulDataLen = sizeof (ulVersion); - rc = DosDevIOCtl (*hGame, IOCTL_CAT_USER, GAME_GET_VERSION, - NULL, 0, NULL, &ulVersion, ulDataLen, &ulDataLen); + ulDataLen = sizeof(ulVersion); + rc = DosDevIOCtl(*hGame, IOCTL_CAT_USER, GAME_GET_VERSION, + NULL, 0, NULL, &ulVersion, ulDataLen, &ulDataLen); if (rc != 0) { - joyPortClose (hGame); - SDL_SetError ("Could not get Joystick Driver version."); + joyPortClose(hGame); + SDL_SetError("Could not get Joystick Driver version."); return -1; } if (ulVersion < GAME_VERSION) { - joyPortClose (hGame); + joyPortClose(hGame); SDL_SetError ("Driver too old. At least IBM driver version 2.0 required."); return -1; @@ -608,10 +607,10 @@ /* Close JoyPort, if opened */ /****************************/ void -joyPortClose (HFILE * hGame) +joyPortClose(HFILE * hGame) { if (*hGame != NULL) - DosClose (*hGame); + DosClose(*hGame); *hGame = NULL; } @@ -621,12 +620,12 @@ /* Get SDL Joystick EnvVar */ /***************************/ int -joyGetEnv (struct _joycfg *joydata) +joyGetEnv(struct _joycfg *joydata) { char *joyenv; /* Pointer to tested character */ char tempnumber[5]; /* Temporary place to put numeric texts */ - joyenv = SDL_getenv ("SDL_OS2_JOYSTICK"); + joyenv = SDL_getenv("SDL_OS2_JOYSTICK"); if (joyenv == NULL) return 0; /* Joystick Environment is defined! */ @@ -635,36 +634,34 @@ /* If the string name starts with '... get if fully */ if (*joyenv == '\'') joyenv += - joyGetData (++joyenv, joydata->name, '\'', - sizeof (joydata->name)); + joyGetData(++joyenv, joydata->name, '\'', sizeof(joydata->name)); /* If not, get it until the next space */ else if (*joyenv == '\"') joyenv += - joyGetData (++joyenv, joydata->name, '\"', - sizeof (joydata->name)); + joyGetData(++joyenv, joydata->name, '\"', sizeof(joydata->name)); else joyenv += - joyGetData (joyenv, joydata->name, ' ', sizeof (joydata->name)); + joyGetData(joyenv, joydata->name, ' ', sizeof(joydata->name)); /* Now get the number of axes */ while (*joyenv == ' ' && *joyenv != 0) joyenv++; /* jump spaces... */ - joyenv += joyGetData (joyenv, tempnumber, ' ', sizeof (tempnumber)); - joydata->axes = atoi (tempnumber); + joyenv += joyGetData(joyenv, tempnumber, ' ', sizeof(tempnumber)); + joydata->axes = atoi(tempnumber); /* Now get the number of buttons */ while (*joyenv == ' ' && *joyenv != 0) joyenv++; /* jump spaces... */ - joyenv += joyGetData (joyenv, tempnumber, ' ', sizeof (tempnumber)); - joydata->buttons = atoi (tempnumber); + joyenv += joyGetData(joyenv, tempnumber, ' ', sizeof(tempnumber)); + joydata->buttons = atoi(tempnumber); /* Now get the number of hats */ while (*joyenv == ' ' && *joyenv != 0) joyenv++; /* jump spaces... */ - joyenv += joyGetData (joyenv, tempnumber, ' ', sizeof (tempnumber)); - joydata->hats = atoi (tempnumber); + joyenv += joyGetData(joyenv, tempnumber, ' ', sizeof(tempnumber)); + joydata->hats = atoi(tempnumber); /* Now get the number of balls */ while (*joyenv == ' ' && *joyenv != 0) joyenv++; /* jump spaces... */ - joyenv += joyGetData (joyenv, tempnumber, ' ', sizeof (tempnumber)); - joydata->balls = atoi (tempnumber); + joyenv += joyGetData(joyenv, tempnumber, ' ', sizeof(tempnumber)); + joydata->balls = atoi(tempnumber); return 1; } @@ -675,7 +672,7 @@ /* the stopchar or maxchars is reached. The result is placed in name. */ /************************************************************************/ int -joyGetData (char *joyenv, char *name, char stopchar, size_t maxchars) +joyGetData(char *joyenv, char *name, char stopchar, size_t maxchars) { char *nameptr; /* Pointer to the selected character */ int chcnt = 0; /* Count how many characters where copied */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/joystick/riscos/SDL_sysjoystick.c --- a/src/joystick/riscos/SDL_sysjoystick.c Mon May 29 03:53:21 2006 +0000 +++ b/src/joystick/riscos/SDL_sysjoystick.c Mon May 29 04:04:35 2006 +0000 @@ -53,13 +53,13 @@ * It should return number of joysticks, or -1 on an unrecoverable fatal error. */ int -SDL_SYS_JoystickInit (void) +SDL_SYS_JoystickInit(void) { _kernel_swi_regs regs; /* Try to read joystick 0 */ regs.r[0] = 0; - if (_kernel_swi (JOYSTICK_READ, ®s, ®s) == NULL) { + if (_kernel_swi(JOYSTICK_READ, ®s, ®s) == NULL) { /* Switch works so assume we've got a joystick */ return 1; } @@ -70,13 +70,13 @@ /* Function to get the device-dependent name of a joystick */ const char * -SDL_SYS_JoystickName (int index) +SDL_SYS_JoystickName(int index) { if (index == 0) { return "RISC OS Joystick 0"; } - SDL_SetError ("No joystick available with that index"); + SDL_SetError("No joystick available with that index"); return (NULL); } @@ -86,11 +86,11 @@ It returns 0, or -1 if there is an error. */ int -SDL_SYS_JoystickOpen (SDL_Joystick * joystick) +SDL_SYS_JoystickOpen(SDL_Joystick * joystick) { _kernel_swi_regs regs; - if (!(joystick->hwdata = SDL_malloc (sizeof (struct joystick_hwdata)))) + if (!(joystick->hwdata = SDL_malloc(sizeof(struct joystick_hwdata)))) return -1; regs.r[0] = joystick->index; @@ -113,12 +113,12 @@ * and update joystick device state. */ void -SDL_SYS_JoystickUpdate (SDL_Joystick * joystick) +SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) { _kernel_swi_regs regs; regs.r[0] = joystick->index; - if (_kernel_swi (JOYSTICK_READ, ®s, ®s) == NULL) { + if (_kernel_swi(JOYSTICK_READ, ®s, ®s) == NULL) { int newstate = regs.r[0]; int oldstate = joystick->hwdata->joystate; if (newstate != oldstate) { @@ -127,13 +127,13 @@ /* Convert to signed values */ if (y >= 128) y -= 256; - SDL_PrivateJoystickAxis (joystick, 1, -y * 256); /* Up and down opposite to result in SDL */ + SDL_PrivateJoystickAxis(joystick, 1, -y * 256); /* Up and down opposite to result in SDL */ } if ((newstate & 0xFF00) != (oldstate & 0xFF00)) { int x = (regs.r[0] & 0xFF00) >> 8; if (x >= 128) x -= 256; - SDL_PrivateJoystickAxis (joystick, 0, x * 256); + SDL_PrivateJoystickAxis(joystick, 0, x * 256); } if ((newstate & 0xFF0000) != (oldstate & 0xFF0000)) { @@ -143,11 +143,11 @@ for (i = 0; i < joystick->nbuttons; i++) { if ((buttons & (1 << i)) != (oldbuttons & (1 << i))) { if (buttons & (1 << i)) - SDL_PrivateJoystickButton (joystick, i, - SDL_PRESSED); + SDL_PrivateJoystickButton(joystick, i, + SDL_PRESSED); else - SDL_PrivateJoystickButton (joystick, i, - SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, i, + SDL_RELEASED); } } } @@ -160,16 +160,16 @@ /* Function to close a joystick after use */ void -SDL_SYS_JoystickClose (SDL_Joystick * joystick) +SDL_SYS_JoystickClose(SDL_Joystick * joystick) { if (joystick->hwdata) - SDL_free (joystick->hwdata); + SDL_free(joystick->hwdata); return; } /* Function to perform any system-specific joystick related cleanup */ void -SDL_SYS_JoystickQuit (void) +SDL_SYS_JoystickQuit(void) { SDL_numjoysticks = 0; diff -r 1fddae038bc8 -r 4da1ee79c9af src/joystick/win32/SDL_dxjoystick.c --- a/src/joystick/win32/SDL_dxjoystick.c Mon May 29 03:53:21 2006 +0000 +++ b/src/joystick/win32/SDL_dxjoystick.c Mon May 29 04:04:35 2006 +0000 @@ -48,11 +48,11 @@ #define INPUT_QSIZE 32 /* Buffer up to 32 input messages */ extern HINSTANCE SDL_Instance; -extern int DX5_Load (); -extern void DX5_Unload (); -extern HRESULT (WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion, - LPDIRECTINPUT * ppDI, - LPUNKNOWN punkOuter); +extern int DX5_Load(); +extern void DX5_Unload(); +extern HRESULT(WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion, + LPDIRECTINPUT * ppDI, + LPUNKNOWN punkOuter); static LPDIRECTINPUT dinput = NULL; @@ -95,7 +95,7 @@ /* Convert a DirectInput return code to a text message */ static void -SetDIerror (char *function, int code) +SetDIerror(char *function, int code) { static char *error; static char errbuf[1024]; @@ -124,23 +124,23 @@ error = "Device not initialized"; break; default: - sprintf (errbuf, "%s: Unknown DirectInput error: 0x%x", - function, code); + sprintf(errbuf, "%s: Unknown DirectInput error: 0x%x", + function, code); break; } if (!errbuf[0]) { - sprintf (errbuf, "%s: %s", function, error); + sprintf(errbuf, "%s: %s", function, error); } - SDL_SetError ("%s", errbuf); + SDL_SetError("%s", errbuf); return; } BOOL CALLBACK -EnumJoysticksCallback (const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) +EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) { - memcpy (&SYS_Joystick[SYS_NumJoysticks], pdidInstance, - sizeof (DIDEVICEINSTANCE)); + memcpy(&SYS_Joystick[SYS_NumJoysticks], pdidInstance, + sizeof(DIDEVICEINSTANCE)); SYS_NumJoysticks++; if (SYS_NumJoysticks >= MAX_JOYSTICKS) @@ -150,7 +150,7 @@ } static BOOL CALLBACK -DIJoystick_EnumDevObjectsProc (LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef) +DIJoystick_EnumDevObjectsProc(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef) { SDL_Joystick *joystick = (SDL_Joystick *) pvRef; HRESULT result; @@ -176,28 +176,28 @@ in->type = AXIS; in->num = joystick->naxes; - diprg.diph.dwSize = sizeof (diprg); - diprg.diph.dwHeaderSize = sizeof (diprg.diph); + diprg.diph.dwSize = sizeof(diprg); + diprg.diph.dwHeaderSize = sizeof(diprg.diph); diprg.diph.dwObj = dev->dwOfs; diprg.diph.dwHow = DIPH_BYOFFSET; diprg.lMin = AXIS_MIN; diprg.lMax = AXIS_MAX; result = - IDirectInputDevice2_SetProperty (joystick->hwdata->InputDevice, - DIPROP_RANGE, &diprg.diph); + IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice, + DIPROP_RANGE, &diprg.diph); if (result != DI_OK) return DIENUM_CONTINUE; /* don't use this axis */ /* Set dead zone to 0. */ - dilong.diph.dwSize = sizeof (dilong); - dilong.diph.dwHeaderSize = sizeof (dilong.diph); + dilong.diph.dwSize = sizeof(dilong); + dilong.diph.dwHeaderSize = sizeof(dilong.diph); dilong.diph.dwObj = dev->dwOfs; dilong.diph.dwHow = DIPH_BYOFFSET; dilong.dwData = 0; result = - IDirectInputDevice2_SetProperty (joystick->hwdata->InputDevice, - DIPROP_DEADZONE, &dilong.diph); + IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice, + DIPROP_DEADZONE, &dilong.diph); if (result != DI_OK) return DIENUM_CONTINUE; /* don't use this axis */ @@ -218,35 +218,35 @@ * It should return 0, or -1 on an unrecoverable fatal error. */ int -SDL_SYS_JoystickInit (void) +SDL_SYS_JoystickInit(void) { HRESULT result; SYS_NumJoysticks = 0; /* Create the DirectInput object */ - if (DX5_Load () < 0) { - SDL_SetError ("Couldn't load DirectInput"); + if (DX5_Load() < 0) { + SDL_SetError("Couldn't load DirectInput"); return (-1); } - result = DInputCreate (SDL_Instance, DIRECTINPUT_VERSION, &dinput, NULL); + result = DInputCreate(SDL_Instance, DIRECTINPUT_VERSION, &dinput, NULL); if (result != DI_OK) { - DX5_Unload (); - SetDIerror ("DirectInputCreate", result); + DX5_Unload(); + SetDIerror("DirectInputCreate", result); return (-1); } - result = IDirectInput_EnumDevices (dinput, - DIDEVTYPE_JOYSTICK, - EnumJoysticksCallback, - NULL, DIEDFL_ATTACHEDONLY); + result = IDirectInput_EnumDevices(dinput, + DIDEVTYPE_JOYSTICK, + EnumJoysticksCallback, + NULL, DIEDFL_ATTACHEDONLY); return SYS_NumJoysticks; } /* Function to get the device-dependent name of a joystick */ const char * -SDL_SYS_JoystickName (int index) +SDL_SYS_JoystickName(int index) { /***-> test for invalid index ? */ return (SYS_Joystick[index].tszProductName); @@ -258,81 +258,81 @@ It returns 0, or -1 if there is an error. */ int -SDL_SYS_JoystickOpen (SDL_Joystick * joystick) +SDL_SYS_JoystickOpen(SDL_Joystick * joystick) { HRESULT result; LPDIRECTINPUTDEVICE device; /* allocate memory for system specific hardware data */ joystick->hwdata = - (struct joystick_hwdata *) malloc (sizeof (*joystick->hwdata)); + (struct joystick_hwdata *) malloc(sizeof(*joystick->hwdata)); if (joystick->hwdata == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } - memset (joystick->hwdata, 0, sizeof (*joystick->hwdata)); + memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); joystick->hwdata->buffered = 1; result = - IDirectInput_CreateDevice (dinput, - &SYS_Joystick[joystick->index]. - guidInstance, &device, NULL); + IDirectInput_CreateDevice(dinput, + &SYS_Joystick[joystick->index]. + guidInstance, &device, NULL); if (result != DI_OK) { - SetDIerror ("DirectInput::CreateDevice", result); + SetDIerror("DirectInput::CreateDevice", result); return (-1); } - result = IDirectInputDevice_QueryInterface (device, - &IID_IDirectInputDevice2, - (LPVOID *) & joystick-> - hwdata->InputDevice); - IDirectInputDevice_Release (device); + result = IDirectInputDevice_QueryInterface(device, + &IID_IDirectInputDevice2, + (LPVOID *) & joystick-> + hwdata->InputDevice); + IDirectInputDevice_Release(device); if (result != DI_OK) { - SetDIerror ("DirectInputDevice::QueryInterface", result); + SetDIerror("DirectInputDevice::QueryInterface", result); return (-1); } result = - IDirectInputDevice2_SetCooperativeLevel (joystick->hwdata-> - InputDevice, SDL_Window, - DISCL_NONEXCLUSIVE | - DISCL_BACKGROUND); + IDirectInputDevice2_SetCooperativeLevel(joystick->hwdata-> + InputDevice, SDL_Window, + DISCL_NONEXCLUSIVE | + DISCL_BACKGROUND); if (result != DI_OK) { - SetDIerror ("DirectInputDevice::SetCooperativeLevel", result); + SetDIerror("DirectInputDevice::SetCooperativeLevel", result); return (-1); } result = - IDirectInputDevice2_SetDataFormat (joystick->hwdata->InputDevice, - &c_dfDIJoystick); + IDirectInputDevice2_SetDataFormat(joystick->hwdata->InputDevice, + &c_dfDIJoystick); if (result != DI_OK) { - SetDIerror ("DirectInputDevice::SetDataFormat", result); + SetDIerror("DirectInputDevice::SetDataFormat", result); return (-1); } - IDirectInputDevice2_EnumObjects (joystick->hwdata->InputDevice, - DIJoystick_EnumDevObjectsProc, - joystick, - DIDFT_BUTTON | DIDFT_AXIS | DIDFT_POV); + IDirectInputDevice2_EnumObjects(joystick->hwdata->InputDevice, + DIJoystick_EnumDevObjectsProc, + joystick, + DIDFT_BUTTON | DIDFT_AXIS | DIDFT_POV); { DIPROPDWORD dipdw; - memset (&dipdw, 0, sizeof (dipdw)); - dipdw.diph.dwSize = sizeof (dipdw); - dipdw.diph.dwHeaderSize = sizeof (dipdw.diph); + memset(&dipdw, 0, sizeof(dipdw)); + dipdw.diph.dwSize = sizeof(dipdw); + dipdw.diph.dwHeaderSize = sizeof(dipdw.diph); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = INPUT_QSIZE; result = - IDirectInputDevice2_SetProperty (joystick->hwdata->InputDevice, - DIPROP_BUFFERSIZE, &dipdw.diph); + IDirectInputDevice2_SetProperty(joystick->hwdata->InputDevice, + DIPROP_BUFFERSIZE, &dipdw.diph); if (result == DI_POLLEDDEVICE) { /* This device doesn't support buffering, so we're forced * to use less reliable polling. */ joystick->hwdata->buffered = 0; } else if (result != DI_OK) { - SetDIerror ("DirectInputDevice::SetProperty", result); + SetDIerror("DirectInputDevice::SetProperty", result); return (-1); } } @@ -341,7 +341,7 @@ } static Uint8 -TranslatePOV (DWORD value) +TranslatePOV(DWORD value) { const int HAT_VALS[] = { SDL_HAT_UP, @@ -354,7 +354,7 @@ SDL_HAT_UP | SDL_HAT_LEFT }; - if (LOWORD (value) == 0xFFFF) + if (LOWORD(value) == 0xFFFF) return SDL_HAT_CENTERED; /* Round the value up: */ @@ -371,28 +371,27 @@ /* SDL_PrivateJoystick* doesn't discard duplicate events, so we need to * do it. */ static int -SDL_PrivateJoystickAxis_Int (SDL_Joystick * joystick, Uint8 axis, - Sint16 value) +SDL_PrivateJoystickAxis_Int(SDL_Joystick * joystick, Uint8 axis, Sint16 value) { if (joystick->axes[axis] != value) - return SDL_PrivateJoystickAxis (joystick, axis, value); + return SDL_PrivateJoystickAxis(joystick, axis, value); return 0; } static int -SDL_PrivateJoystickHat_Int (SDL_Joystick * joystick, Uint8 hat, Uint8 value) +SDL_PrivateJoystickHat_Int(SDL_Joystick * joystick, Uint8 hat, Uint8 value) { if (joystick->hats[hat] != value) - return SDL_PrivateJoystickHat (joystick, hat, value); + return SDL_PrivateJoystickHat(joystick, hat, value); return 0; } static int -SDL_PrivateJoystickButton_Int (SDL_Joystick * joystick, Uint8 button, - Uint8 state) +SDL_PrivateJoystickButton_Int(SDL_Joystick * joystick, Uint8 button, + Uint8 state) { if (joystick->buttons[button] != state) - return SDL_PrivateJoystickButton (joystick, button, state); + return SDL_PrivateJoystickButton(joystick, button, state); return 0; } @@ -402,21 +401,21 @@ * and update joystick device state. */ void -SDL_SYS_JoystickUpdate_Polled (SDL_Joystick * joystick) +SDL_SYS_JoystickUpdate_Polled(SDL_Joystick * joystick) { DIJOYSTATE state; HRESULT result; int i; result = - IDirectInputDevice2_GetDeviceState (joystick->hwdata->InputDevice, - sizeof (state), &state); + IDirectInputDevice2_GetDeviceState(joystick->hwdata->InputDevice, + sizeof(state), &state); if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) { - IDirectInputDevice2_Acquire (joystick->hwdata->InputDevice); + IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice); result = - IDirectInputDevice2_GetDeviceState (joystick->hwdata-> - InputDevice, sizeof (state), - &state); + IDirectInputDevice2_GetDeviceState(joystick->hwdata-> + InputDevice, sizeof(state), + &state); } /* Set each known axis, button and POV. */ @@ -427,54 +426,54 @@ case AXIS: switch (in->ofs) { case DIJOFS_X: - SDL_PrivateJoystickAxis_Int (joystick, in->num, - (Sint16) state.lX); + SDL_PrivateJoystickAxis_Int(joystick, in->num, + (Sint16) state.lX); break; case DIJOFS_Y: - SDL_PrivateJoystickAxis_Int (joystick, in->num, - (Sint16) state.lY); + SDL_PrivateJoystickAxis_Int(joystick, in->num, + (Sint16) state.lY); break; case DIJOFS_Z: - SDL_PrivateJoystickAxis_Int (joystick, in->num, - (Sint16) state.lZ); + SDL_PrivateJoystickAxis_Int(joystick, in->num, + (Sint16) state.lZ); break; case DIJOFS_RX: - SDL_PrivateJoystickAxis_Int (joystick, in->num, - (Sint16) state.lRx); + SDL_PrivateJoystickAxis_Int(joystick, in->num, + (Sint16) state.lRx); break; case DIJOFS_RY: - SDL_PrivateJoystickAxis_Int (joystick, in->num, - (Sint16) state.lRy); + SDL_PrivateJoystickAxis_Int(joystick, in->num, + (Sint16) state.lRy); break; case DIJOFS_RZ: - SDL_PrivateJoystickAxis_Int (joystick, in->num, - (Sint16) state.lRz); + SDL_PrivateJoystickAxis_Int(joystick, in->num, + (Sint16) state.lRz); break; - case DIJOFS_SLIDER (0): - SDL_PrivateJoystickAxis_Int (joystick, in->num, - (Sint16) state.rglSlider[0]); + case DIJOFS_SLIDER(0): + SDL_PrivateJoystickAxis_Int(joystick, in->num, + (Sint16) state.rglSlider[0]); break; - case DIJOFS_SLIDER (1): - SDL_PrivateJoystickAxis_Int (joystick, in->num, - (Sint16) state.rglSlider[0]); + case DIJOFS_SLIDER(1): + SDL_PrivateJoystickAxis_Int(joystick, in->num, + (Sint16) state.rglSlider[0]); break; } break; case BUTTON: - SDL_PrivateJoystickButton_Int (joystick, in->num, - (Uint8) (state. - rgbButtons[in->ofs - - DIJOFS_BUTTON0] - ? SDL_PRESSED : - SDL_RELEASED)); + SDL_PrivateJoystickButton_Int(joystick, in->num, + (Uint8) (state. + rgbButtons[in->ofs - + DIJOFS_BUTTON0] + ? SDL_PRESSED : + SDL_RELEASED)); break; case HAT: { Uint8 pos = - TranslatePOV (state.rgdwPOV[in->ofs - DIJOFS_POV (0)]); - SDL_PrivateJoystickHat_Int (joystick, in->num, pos); + TranslatePOV(state.rgdwPOV[in->ofs - DIJOFS_POV(0)]); + SDL_PrivateJoystickHat_Int(joystick, in->num, pos); break; } } @@ -482,7 +481,7 @@ } void -SDL_SYS_JoystickUpdate_Buffered (SDL_Joystick * joystick) +SDL_SYS_JoystickUpdate_Buffered(SDL_Joystick * joystick) { int i; HRESULT result; @@ -491,16 +490,16 @@ numevents = INPUT_QSIZE; result = - IDirectInputDevice2_GetDeviceData (joystick->hwdata->InputDevice, - sizeof (DIDEVICEOBJECTDATA), - evtbuf, &numevents, 0); + IDirectInputDevice2_GetDeviceData(joystick->hwdata->InputDevice, + sizeof(DIDEVICEOBJECTDATA), + evtbuf, &numevents, 0); if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) { - IDirectInputDevice2_Acquire (joystick->hwdata->InputDevice); + IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice); result = - IDirectInputDevice2_GetDeviceData (joystick->hwdata-> - InputDevice, - sizeof (DIDEVICEOBJECTDATA), - evtbuf, &numevents, 0); + IDirectInputDevice2_GetDeviceData(joystick->hwdata-> + InputDevice, + sizeof(DIDEVICEOBJECTDATA), + evtbuf, &numevents, 0); } /* Handle the events */ @@ -518,19 +517,19 @@ switch (in->type) { case AXIS: - SDL_PrivateJoystickAxis (joystick, in->num, - (Sint16) evtbuf[i].dwData); + SDL_PrivateJoystickAxis(joystick, in->num, + (Sint16) evtbuf[i].dwData); break; case BUTTON: - SDL_PrivateJoystickButton (joystick, in->num, - (Uint8) (evtbuf[i]. - dwData ? SDL_PRESSED - : SDL_RELEASED)); + SDL_PrivateJoystickButton(joystick, in->num, + (Uint8) (evtbuf[i]. + dwData ? SDL_PRESSED + : SDL_RELEASED)); break; case HAT: { - Uint8 pos = TranslatePOV (evtbuf[i].dwData); - SDL_PrivateJoystickHat (joystick, in->num, pos); + Uint8 pos = TranslatePOV(evtbuf[i].dwData); + SDL_PrivateJoystickHat(joystick, in->num, pos); } } } @@ -538,42 +537,42 @@ } void -SDL_SYS_JoystickUpdate (SDL_Joystick * joystick) +SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) { HRESULT result; - result = IDirectInputDevice2_Poll (joystick->hwdata->InputDevice); + result = IDirectInputDevice2_Poll(joystick->hwdata->InputDevice); if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) { - IDirectInputDevice2_Acquire (joystick->hwdata->InputDevice); - IDirectInputDevice2_Poll (joystick->hwdata->InputDevice); + IDirectInputDevice2_Acquire(joystick->hwdata->InputDevice); + IDirectInputDevice2_Poll(joystick->hwdata->InputDevice); } if (joystick->hwdata->buffered) - SDL_SYS_JoystickUpdate_Buffered (joystick); + SDL_SYS_JoystickUpdate_Buffered(joystick); else - SDL_SYS_JoystickUpdate_Polled (joystick); + SDL_SYS_JoystickUpdate_Polled(joystick); } /* Function to close a joystick after use */ void -SDL_SYS_JoystickClose (SDL_Joystick * joystick) +SDL_SYS_JoystickClose(SDL_Joystick * joystick) { - IDirectInputDevice2_Unacquire (joystick->hwdata->InputDevice); - IDirectInputDevice2_Release (joystick->hwdata->InputDevice); + IDirectInputDevice2_Unacquire(joystick->hwdata->InputDevice); + IDirectInputDevice2_Release(joystick->hwdata->InputDevice); if (joystick->hwdata != NULL) { /* free system specific hardware data */ - free (joystick->hwdata); + free(joystick->hwdata); } } /* Function to perform any system-specific joystick related cleanup */ void -SDL_SYS_JoystickQuit (void) +SDL_SYS_JoystickQuit(void) { - IDirectInput_Release (dinput); + IDirectInput_Release(dinput); dinput = NULL; - DX5_Unload (); + DX5_Unload(); } #endif /* SDL_JOYSTICK_DINPUT */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/joystick/win32/SDL_mmjoystick.c --- a/src/joystick/win32/SDL_mmjoystick.c Mon May 29 03:53:21 2006 +0000 +++ b/src/joystick/win32/SDL_mmjoystick.c Mon May 29 04:04:35 2006 +0000 @@ -66,11 +66,11 @@ }; /* Convert a win32 Multimedia API return code to a text message */ -static void SetMMerror (char *function, int code); +static void SetMMerror(char *function, int code); static char * -GetJoystickName (int index, const char *szRegKey) +GetJoystickName(int index, const char *szRegKey) { /* added 7/24/2004 by Eckhard Stolberg */ /* @@ -85,49 +85,48 @@ unsigned char regvalue[256]; unsigned char regname[256]; - SDL_snprintf ((char *) regkey, SDL_arraysize (regkey), "%s\\%s\\%s", - REGSTR_PATH_JOYCONFIG, szRegKey, REGSTR_KEY_JOYCURR); - regresult = RegOpenKeyExA (HKEY_LOCAL_MACHINE, - (LPTSTR) & regkey, 0, KEY_READ, &hKey); + SDL_snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s\\%s", + REGSTR_PATH_JOYCONFIG, szRegKey, REGSTR_KEY_JOYCURR); + regresult = RegOpenKeyExA(HKEY_LOCAL_MACHINE, + (LPTSTR) & regkey, 0, KEY_READ, &hKey); if (regresult == ERROR_SUCCESS) { /* find the registry key name for the joystick's properties */ - regsize = sizeof (regname); - SDL_snprintf ((char *) regvalue, SDL_arraysize (regvalue), - "Joystick%d%s", index + 1, REGSTR_VAL_JOYOEMNAME); - regresult = RegQueryValueExA (hKey, - (char *) regvalue, 0, 0, - (LPBYTE) & regname, - (LPDWORD) & regsize); - RegCloseKey (hKey); + regsize = sizeof(regname); + SDL_snprintf((char *) regvalue, SDL_arraysize(regvalue), + "Joystick%d%s", index + 1, REGSTR_VAL_JOYOEMNAME); + regresult = RegQueryValueExA(hKey, + (char *) regvalue, 0, 0, + (LPBYTE) & regname, (LPDWORD) & regsize); + RegCloseKey(hKey); if (regresult == ERROR_SUCCESS) { /* open that registry key */ - SDL_snprintf ((char *) regkey, SDL_arraysize (regkey), - "%s\\%s", REGSTR_PATH_JOYOEM, regname); + SDL_snprintf((char *) regkey, SDL_arraysize(regkey), + "%s\\%s", REGSTR_PATH_JOYOEM, regname); regresult = - RegOpenKeyExA (HKEY_LOCAL_MACHINE, (char *) regkey, 0, - KEY_READ, &hKey); + RegOpenKeyExA(HKEY_LOCAL_MACHINE, (char *) regkey, 0, + KEY_READ, &hKey); if (regresult == ERROR_SUCCESS) { /* find the size for the OEM name text */ - regsize = sizeof (regvalue); + regsize = sizeof(regvalue); regresult = - RegQueryValueExA (hKey, - REGSTR_VAL_JOYOEMNAME, - 0, 0, NULL, (LPDWORD) & regsize); + RegQueryValueExA(hKey, + REGSTR_VAL_JOYOEMNAME, + 0, 0, NULL, (LPDWORD) & regsize); if (regresult == ERROR_SUCCESS) { /* allocate enough memory for the OEM name text ... */ - name = (char *) SDL_malloc (regsize); + name = (char *) SDL_malloc(regsize); /* ... and read it from the registry */ regresult = - RegQueryValueExA (hKey, - REGSTR_VAL_JOYOEMNAME, 0, 0, - (LPBYTE) name, (LPDWORD) & regsize); - RegCloseKey (hKey); + RegQueryValueExA(hKey, + REGSTR_VAL_JOYOEMNAME, 0, 0, + (LPBYTE) name, (LPDWORD) & regsize); + RegCloseKey(hKey); } } } @@ -141,7 +140,7 @@ * It should return 0, or -1 on an unrecoverable fatal error. */ int -SDL_SYS_JoystickInit (void) +SDL_SYS_JoystickInit(void) { int i; int maxdevs; @@ -158,19 +157,19 @@ /* Loop over all potential joystick devices */ numdevs = 0; - maxdevs = joyGetNumDevs (); + maxdevs = joyGetNumDevs(); for (i = JOYSTICKID1; i < maxdevs && numdevs < MAX_JOYSTICKS; ++i) { - joyinfo.dwSize = sizeof (joyinfo); + joyinfo.dwSize = sizeof(joyinfo); joyinfo.dwFlags = JOY_RETURNALL; - result = joyGetPosEx (SYS_JoystickID[i], &joyinfo); + result = joyGetPosEx(SYS_JoystickID[i], &joyinfo); if (result == JOYERR_NOERROR) { - result = joyGetDevCaps (i, &joycaps, sizeof (joycaps)); + result = joyGetDevCaps(i, &joycaps, sizeof(joycaps)); if (result == JOYERR_NOERROR) { SYS_JoystickID[numdevs] = i; SYS_Joystick[numdevs] = joycaps; SYS_JoystickName[numdevs] = - GetJoystickName (i, joycaps.szRegKey); + GetJoystickName(i, joycaps.szRegKey); numdevs++; } } @@ -180,7 +179,7 @@ /* Function to get the device-dependent name of a joystick */ const char * -SDL_SYS_JoystickName (int index) +SDL_SYS_JoystickName(int index) { if (SYS_JoystickName[index] != NULL) { return (SYS_JoystickName[index]); @@ -195,7 +194,7 @@ It returns 0, or -1 if there is an error. */ int -SDL_SYS_JoystickOpen (SDL_Joystick * joystick) +SDL_SYS_JoystickOpen(SDL_Joystick * joystick) { int index, i; int caps_flags[MAX_AXES - 2] = @@ -220,12 +219,12 @@ /* allocate memory for system specific hardware data */ joystick->hwdata = - (struct joystick_hwdata *) SDL_malloc (sizeof (*joystick->hwdata)); + (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata)); if (joystick->hwdata == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } - SDL_memset (joystick->hwdata, 0, sizeof (*joystick->hwdata)); + SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); /* set hardware data */ joystick->hwdata->id = SYS_JoystickID[index]; @@ -252,7 +251,7 @@ } static Uint8 -TranslatePOV (DWORD value) +TranslatePOV(DWORD value) { Uint8 pos; @@ -280,7 +279,7 @@ * and update joystick device state. */ void -SDL_SYS_JoystickUpdate (SDL_Joystick * joystick) +SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) { MMRESULT result; int i; @@ -292,14 +291,14 @@ int value, change; JOYINFOEX joyinfo; - joyinfo.dwSize = sizeof (joyinfo); + joyinfo.dwSize = sizeof(joyinfo); joyinfo.dwFlags = JOY_RETURNALL | JOY_RETURNPOVCTS; if (!joystick->hats) { joyinfo.dwFlags &= ~(JOY_RETURNPOV | JOY_RETURNPOVCTS); } - result = joyGetPosEx (joystick->hwdata->id, &joyinfo); + result = joyGetPosEx(joystick->hwdata->id, &joyinfo); if (result != JOYERR_NOERROR) { - SetMMerror ("joyGetPosEx", result); + SetMMerror("joyGetPosEx", result); return; } @@ -320,7 +319,7 @@ change = (value - joystick->axes[i]); if ((change < -JOY_AXIS_THRESHOLD) || (change > JOY_AXIS_THRESHOLD)) { - SDL_PrivateJoystickAxis (joystick, (Uint8) i, (Sint16) value); + SDL_PrivateJoystickAxis(joystick, (Uint8) i, (Sint16) value); } } } @@ -328,15 +327,15 @@ /* joystick button events */ if (joyinfo.dwFlags & JOY_RETURNBUTTONS) { for (i = 0; i < joystick->nbuttons; ++i) { - if (joyinfo.dwButtons & JOY_BUTTON_FLAG (i)) { + if (joyinfo.dwButtons & JOY_BUTTON_FLAG(i)) { if (!joystick->buttons[i]) { - SDL_PrivateJoystickButton (joystick, (Uint8) i, - SDL_PRESSED); + SDL_PrivateJoystickButton(joystick, (Uint8) i, + SDL_PRESSED); } } else { if (joystick->buttons[i]) { - SDL_PrivateJoystickButton (joystick, (Uint8) i, - SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, (Uint8) i, + SDL_RELEASED); } } } @@ -346,31 +345,31 @@ if (joyinfo.dwFlags & JOY_RETURNPOV) { Uint8 pos; - pos = TranslatePOV (joyinfo.dwPOV); + pos = TranslatePOV(joyinfo.dwPOV); if (pos != joystick->hats[0]) { - SDL_PrivateJoystickHat (joystick, 0, pos); + SDL_PrivateJoystickHat(joystick, 0, pos); } } } /* Function to close a joystick after use */ void -SDL_SYS_JoystickClose (SDL_Joystick * joystick) +SDL_SYS_JoystickClose(SDL_Joystick * joystick) { if (joystick->hwdata != NULL) { /* free system specific hardware data */ - SDL_free (joystick->hwdata); + SDL_free(joystick->hwdata); } } /* Function to perform any system-specific joystick related cleanup */ void -SDL_SYS_JoystickQuit (void) +SDL_SYS_JoystickQuit(void) { int i; for (i = 0; i < MAX_JOYSTICKS; i++) { if (SYS_JoystickName[i] != NULL) { - SDL_free (SYS_JoystickName[i]); + SDL_free(SYS_JoystickName[i]); } } } @@ -378,7 +377,7 @@ /* implementation functions */ void -SetMMerror (char *function, int code) +SetMMerror(char *function, int code) { static char *error; static char errbuf[1024]; @@ -407,17 +406,17 @@ break; default: - SDL_snprintf (errbuf, SDL_arraysize (errbuf), - "%s: Unknown Multimedia system error: 0x%x", - function, code); + SDL_snprintf(errbuf, SDL_arraysize(errbuf), + "%s: Unknown Multimedia system error: 0x%x", + function, code); break; } if (!errbuf[0]) { - SDL_snprintf (errbuf, SDL_arraysize (errbuf), "%s: %s", function, - error); + SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, + error); } - SDL_SetError ("%s", errbuf); + SDL_SetError("%s", errbuf); } #endif /* SDL_JOYSTICK_WINMM */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/loadso/beos/SDL_sysloadso.c --- a/src/loadso/beos/SDL_sysloadso.c Mon May 29 03:53:21 2006 +0000 +++ b/src/loadso/beos/SDL_sysloadso.c Mon May 29 04:04:35 2006 +0000 @@ -32,11 +32,11 @@ #include "SDL_loadso.h" void * -SDL_LoadObject (const char *sofile) +SDL_LoadObject(const char *sofile) { void *handle = NULL; const char *loaderror = "Unknown error"; - image_id library_id = load_add_on (sofile); + image_id library_id = load_add_on(sofile); if (library_id == B_ERROR) { loaderror = "BeOS error"; } else { @@ -44,35 +44,35 @@ } if (handle == NULL) { - SDL_SetError ("Failed loading %s: %s", sofile, loaderror); + SDL_SetError("Failed loading %s: %s", sofile, loaderror); } return (handle); } void * -SDL_LoadFunction (void *handle, const char *name) +SDL_LoadFunction(void *handle, const char *name) { void *symbol = NULL; const char *loaderror = "Unknown error"; image_id library_id = (image_id) handle; - if (get_image_symbol (library_id, - name, B_SYMBOL_TYPE_TEXT, &symbol) != B_NO_ERROR) { + if (get_image_symbol(library_id, + name, B_SYMBOL_TYPE_TEXT, &symbol) != B_NO_ERROR) { loaderror = "Symbol not found"; } if (symbol == NULL) { - SDL_SetError ("Failed loading %s: %s", name, loaderror); + SDL_SetError("Failed loading %s: %s", name, loaderror); } return (symbol); } void -SDL_UnloadObject (void *handle) +SDL_UnloadObject(void *handle) { image_id library_id; if (handle != NULL) { library_id = (image_id) handle; - unload_add_on (library_id); + unload_add_on(library_id); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/loadso/dlopen/SDL_sysloadso.c --- a/src/loadso/dlopen/SDL_sysloadso.c Mon May 29 03:53:21 2006 +0000 +++ b/src/loadso/dlopen/SDL_sysloadso.c Mon May 29 04:04:35 2006 +0000 @@ -32,40 +32,40 @@ #include "SDL_loadso.h" void * -SDL_LoadObject (const char *sofile) +SDL_LoadObject(const char *sofile) { - void *handle = dlopen (sofile, RTLD_NOW); - const char *loaderror = (char *) dlerror (); + void *handle = dlopen(sofile, RTLD_NOW); + const char *loaderror = (char *) dlerror(); if (handle == NULL) { - SDL_SetError ("Failed loading %s: %s", sofile, loaderror); + SDL_SetError("Failed loading %s: %s", sofile, loaderror); } return (handle); } void * -SDL_LoadFunction (void *handle, const char *name) +SDL_LoadFunction(void *handle, const char *name) { - void *symbol = dlsym (handle, name); + void *symbol = dlsym(handle, name); if (symbol == NULL) { - size_t len = 1 + SDL_strlen (name) + 1; - char *_name = SDL_stack_alloc (char, len); + size_t len = 1 + SDL_strlen(name) + 1; + char *_name = SDL_stack_alloc(char, len); _name[0] = '_'; - SDL_strlcpy (&_name[1], name, len); - symbol = dlsym (handle, name); - SDL_stack_free (_name); + SDL_strlcpy(&_name[1], name, len); + symbol = dlsym(handle, name); + SDL_stack_free(_name); if (symbol == NULL) { - SDL_SetError ("Failed loading %s: %s", name, - (const char *) dlerror ()); + SDL_SetError("Failed loading %s: %s", name, + (const char *) dlerror()); } } return (symbol); } void -SDL_UnloadObject (void *handle) +SDL_UnloadObject(void *handle) { if (handle != NULL) { - dlclose (handle); + dlclose(handle); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/loadso/dummy/SDL_sysloadso.c --- a/src/loadso/dummy/SDL_sysloadso.c Mon May 29 03:53:21 2006 +0000 +++ b/src/loadso/dummy/SDL_sysloadso.c Mon May 29 04:04:35 2006 +0000 @@ -29,23 +29,23 @@ #include "SDL_loadso.h" void * -SDL_LoadObject (const char *sofile) +SDL_LoadObject(const char *sofile) { const char *loaderror = "SDL_LoadObject() not implemented"; - SDL_SetError ("Failed loading %s: %s", sofile, loaderror); + SDL_SetError("Failed loading %s: %s", sofile, loaderror); return (NULL); } void * -SDL_LoadFunction (void *handle, const char *name) +SDL_LoadFunction(void *handle, const char *name) { const char *loaderror = "SDL_LoadFunction() not implemented"; - SDL_SetError ("Failed loading %s: %s", name, loaderror); + SDL_SetError("Failed loading %s: %s", name, loaderror); return (NULL); } void -SDL_UnloadObject (void *handle) +SDL_UnloadObject(void *handle) { /* no-op. */ } diff -r 1fddae038bc8 -r 4da1ee79c9af src/loadso/macos/SDL_sysloadso.c --- a/src/loadso/macos/SDL_sysloadso.c Mon May 29 03:53:21 2006 +0000 +++ b/src/loadso/macos/SDL_sysloadso.c Mon May 29 04:04:35 2006 +0000 @@ -36,7 +36,7 @@ #include "SDL_loadso.h" void * -SDL_LoadObject (const char *sofile) +SDL_LoadObject(const char *sofile) { void *handle = NULL; const char *loaderror = NULL; @@ -46,9 +46,9 @@ OSErr error; char psofile[512]; - SDL_strlcpy (psofile, sofile, SDL_arraysize (psofile)); - error = GetSharedLibrary (C2PStr (psofile), kCompiledCFragArch, - kLoadCFrag, &library_id, &mainAddr, errName); + SDL_strlcpy(psofile, sofile, SDL_arraysize(psofile)); + error = GetSharedLibrary(C2PStr(psofile), kCompiledCFragArch, + kLoadCFrag, &library_id, &mainAddr, errName); switch (error) { case noErr: loaderror = NULL; @@ -70,13 +70,13 @@ if (loaderror == NULL) { handle = (void *) (library_id); } else { - SDL_SetError ("Failed loading %s: %s", sofile, loaderror); + SDL_SetError("Failed loading %s: %s", sofile, loaderror); } return (handle); } void * -SDL_LoadFunction (void *handle, const char *name) +SDL_LoadFunction(void *handle, const char *name) { void *symbol = NULL; const char *loaderror = NULL; @@ -84,25 +84,25 @@ CFragConnectionID library_id = (CFragConnectionID) handle; char pname[512]; - SDL_strlcpy (pname, name, SDL_arraysize (pname)); - if (FindSymbol (library_id, C2PStr (pname), - (char **) &symbol, &class) != noErr) { + SDL_strlcpy(pname, name, SDL_arraysize(pname)); + if (FindSymbol(library_id, C2PStr(pname), + (char **) &symbol, &class) != noErr) { loaderror = "Symbol not found"; } if (symbol == NULL) { - SDL_SetError ("Failed loading %s: %s", name, loaderror); + SDL_SetError("Failed loading %s: %s", name, loaderror); } return (symbol); } void -SDL_UnloadObject (void *handle) +SDL_UnloadObject(void *handle) { CFragConnectionID library_id; if (handle != NULL) { library_id = (CFragConnectionID) handle; - CloseConnection (&library_id); + CloseConnection(&library_id); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/loadso/macosx/SDL_dlcompat.c --- a/src/loadso/macosx/SDL_dlcompat.c Mon May 29 03:53:21 2006 +0000 +++ b/src/loadso/macosx/SDL_dlcompat.c Mon May 29 04:04:35 2006 +0000 @@ -108,16 +108,16 @@ void *dli_saddr; /* Address of nearest symbol */ } SDL_OSX_Dl_info; - static int SDL_OSX_dladdr (const void *dl_restrict, - SDL_OSX_Dl_info * dl_restrict); + static int SDL_OSX_dladdr(const void *dl_restrict, + SDL_OSX_Dl_info * dl_restrict); #endif /* ! _POSIX_SOURCE */ #endif /* 0 */ - static int SDL_OSX_dlclose (void *handle); - static const char *SDL_OSX_dlerror (void); - static void *SDL_OSX_dlopen (const char *path, int mode); - static void *SDL_OSX_dlsym (void *dl_restrict handle, - const char *dl_restrict symbol); + static int SDL_OSX_dlclose(void *handle); + static const char *SDL_OSX_dlerror(void); + static void *SDL_OSX_dlopen(const char *path, int mode); + static void *SDL_OSX_dlsym(void *dl_restrict handle, + const char *dl_restrict symbol); #define RTLD_LAZY 0x1 #define RTLD_NOW 0x2 @@ -170,8 +170,8 @@ unsigned long) = 0; static int (*dyld_NSIsSymbolNameDefinedInImage) (const struct mach_header *, const char *) = 0; -static NSSymbol (*dyld_NSLookupSymbolInImage) (const struct mach_header *, - const char *, unsigned long) = +static NSSymbol(*dyld_NSLookupSymbolInImage) (const struct mach_header *, + const char *, unsigned long) = 0; /* Define this to make dlcompat reuse data block. This way in theory we save @@ -232,93 +232,93 @@ /* static int err_filled = 0; */ /* Prototypes to internal functions */ -static void debug (const char *fmt, ...); -static void error (const char *str, ...); -static const char *safegetenv (const char *s); -static const char *searchList (void); -static const char *getSearchPath (int i); -static const char *getFullPath (int i, const char *file); -static const struct stat *findFile (const char *file, const char **fullPath); -static int isValidStatus (struct dlstatus *status); -static inline int isFlagSet (int mode, int flag); -static struct dlstatus *lookupStatus (const struct stat *sbuf); -static void insertStatus (struct dlstatus *dls, const struct stat *sbuf); -static int promoteLocalToGlobal (struct dlstatus *dls); -static void *reference (struct dlstatus *dls, int mode); -static void *dlsymIntern (struct dlstatus *dls, const char *symbol, - int canSetError); -static struct dlstatus *allocStatus (void); -static struct dlstatus *loadModule (const char *path, const struct stat *sbuf, - int mode); -static NSSymbol search_linked_libs (const struct mach_header *mh, - const char *symbol); -static const char *get_lib_name (const struct mach_header *mh); -static const struct mach_header *get_mach_header_from_NSModule (NSModule mod); -static void dlcompat_init_func (void); -static inline void dlcompat_init_check (void); -static inline void dolock (void); -static inline void dounlock (void); -static void dlerrorfree (void *data); -static void resetdlerror (void); -static const struct mach_header *my_find_image (const char *name); -static const struct mach_header *image_for_address (const void *address); -static inline char *dyld_error_str (void); +static void debug(const char *fmt, ...); +static void error(const char *str, ...); +static const char *safegetenv(const char *s); +static const char *searchList(void); +static const char *getSearchPath(int i); +static const char *getFullPath(int i, const char *file); +static const struct stat *findFile(const char *file, const char **fullPath); +static int isValidStatus(struct dlstatus *status); +static inline int isFlagSet(int mode, int flag); +static struct dlstatus *lookupStatus(const struct stat *sbuf); +static void insertStatus(struct dlstatus *dls, const struct stat *sbuf); +static int promoteLocalToGlobal(struct dlstatus *dls); +static void *reference(struct dlstatus *dls, int mode); +static void *dlsymIntern(struct dlstatus *dls, const char *symbol, + int canSetError); +static struct dlstatus *allocStatus(void); +static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, + int mode); +static NSSymbol search_linked_libs(const struct mach_header *mh, + const char *symbol); +static const char *get_lib_name(const struct mach_header *mh); +static const struct mach_header *get_mach_header_from_NSModule(NSModule mod); +static void dlcompat_init_func(void); +static inline void dlcompat_init_check(void); +static inline void dolock(void); +static inline void dounlock(void); +static void dlerrorfree(void *data); +static void resetdlerror(void); +static const struct mach_header *my_find_image(const char *name); +static const struct mach_header *image_for_address(const void *address); +static inline char *dyld_error_str(void); #if FINK_BUILD /* Two Global Functions */ -static void *dlsym_prepend_underscore (void *handle, const char *symbol); -static void *dlsym_auto_underscore (void *handle, const char *symbol); +static void *dlsym_prepend_underscore(void *handle, const char *symbol); +static void *dlsym_auto_underscore(void *handle, const char *symbol); /* And their _intern counterparts */ -static void *dlsym_prepend_underscore_intern (void *handle, - const char *symbol); -static void *dlsym_auto_underscore_intern (void *handle, const char *symbol); +static void *dlsym_prepend_underscore_intern(void *handle, + const char *symbol); +static void *dlsym_auto_underscore_intern(void *handle, const char *symbol); #endif /* Functions */ static void -debug (const char *fmt, ...) +debug(const char *fmt, ...) { #if DEBUG > 1 va_list arg; - va_start (arg, fmt); - fprintf (stderr, "DLDEBUG: "); - vfprintf (stderr, fmt, arg); - fprintf (stderr, "\n"); - fflush (stderr); - va_end (arg); + va_start(arg, fmt); + fprintf(stderr, "DLDEBUG: "); + vfprintf(stderr, fmt, arg); + fprintf(stderr, "\n"); + fflush(stderr); + va_end(arg); #endif } static void -error (const char *str, ...) +error(const char *str, ...) { va_list arg; struct dlthread *tss; char *err_str; - va_start (arg, str); - tss = pthread_getspecific (dlerror_key); + va_start(arg, str); + tss = pthread_getspecific(dlerror_key); err_str = tss->errstr; - SDL_strlcpy (err_str, "dlcompat: ", ERR_STR_LEN); - vsnprintf (err_str + 10, ERR_STR_LEN - 10, str, arg); - va_end (arg); - debug ("ERROR: %s\n", err_str); + SDL_strlcpy(err_str, "dlcompat: ", ERR_STR_LEN); + vsnprintf(err_str + 10, ERR_STR_LEN - 10, str, arg); + va_end(arg); + debug("ERROR: %s\n", err_str); tss->errset = 1; } static void -warning (const char *str) +warning(const char *str) { #if DEBUG > 0 - fprintf (stderr, "WARNING: dlcompat: %s\n", str); + fprintf(stderr, "WARNING: dlcompat: %s\n", str); #endif } static const char * -safegetenv (const char *s) +safegetenv(const char *s) { - const char *ss = SDL_getenv (s); + const char *ss = SDL_getenv(s); return ss ? ss : ""; } @@ -327,15 +327,15 @@ * commands to find the install name of the library, but... */ static const char * -get_lib_name (const struct mach_header *mh) +get_lib_name(const struct mach_header *mh) { - unsigned long count = _dyld_image_count (); + unsigned long count = _dyld_image_count(); unsigned long i; const char *val = NULL; if (mh) { for (i = 0; i < count; i++) { - if (mh == _dyld_get_image_header (i)) { - val = _dyld_get_image_name (i); + if (mh == _dyld_get_image_header(i)) { + val = _dyld_get_image_name(i); break; } } @@ -348,16 +348,16 @@ * an api for doing this, would be faster, but there isn't one right now */ static const struct mach_header * -get_mach_header_from_NSModule (NSModule mod) +get_mach_header_from_NSModule(NSModule mod) { - const char *mod_name = NSNameOfModule (mod); + const char *mod_name = NSNameOfModule(mod); const struct mach_header *mh = NULL; - unsigned long count = _dyld_image_count (); + unsigned long count = _dyld_image_count(); unsigned long i; - debug ("Module name: %s", mod_name); + debug("Module name: %s", mod_name); for (i = 0; i < count; i++) { - if (!SDL_strcmp (mod_name, _dyld_get_image_name (i))) { - mh = _dyld_get_image_header (i); + if (!SDL_strcmp(mod_name, _dyld_get_image_name(i))) { + mh = _dyld_get_image_header(i); break; } } @@ -374,30 +374,29 @@ * Splitting this string into the actual path list is done by getSearchPath() */ static const char * -searchList () +searchList() { size_t buf_size; static char *buf = NULL; - const char *ldlp = safegetenv ("LD_LIBRARY_PATH"); - const char *dyldlp = safegetenv ("DYLD_LIBRARY_PATH"); - const char *stdpath = SDL_getenv ("DYLD_FALLBACK_LIBRARY_PATH"); + const char *ldlp = safegetenv("LD_LIBRARY_PATH"); + const char *dyldlp = safegetenv("DYLD_LIBRARY_PATH"); + const char *stdpath = SDL_getenv("DYLD_FALLBACK_LIBRARY_PATH"); if (!stdpath) stdpath = "/usr/local/lib:/lib:/usr/lib"; if (!buf) { buf_size = - SDL_strlen (ldlp) + SDL_strlen (dyldlp) + SDL_strlen (stdpath) + - 4; - buf = SDL_malloc (buf_size); - SDL_snprintf (buf, buf_size, "%s%s%s%s%s%c", dyldlp, - (dyldlp[0] ? ":" : ""), ldlp, (ldlp[0] ? ":" : ""), - stdpath, '\0'); + SDL_strlen(ldlp) + SDL_strlen(dyldlp) + SDL_strlen(stdpath) + 4; + buf = SDL_malloc(buf_size); + SDL_snprintf(buf, buf_size, "%s%s%s%s%s%c", dyldlp, + (dyldlp[0] ? ":" : ""), ldlp, (ldlp[0] ? ":" : ""), + stdpath, '\0'); } return buf; } /* Returns the ith search path from the list as computed by searchList() */ static const char * -getSearchPath (int i) +getSearchPath(int i) { static const char *list = 0; static char **path = (char **) 0; @@ -409,18 +408,18 @@ return (const char *) path; } if (!path) { - path = (char **) SDL_calloc (MAX_SEARCH_PATHS, sizeof (char **)); + path = (char **) SDL_calloc(MAX_SEARCH_PATHS, sizeof(char **)); } if (!list && !end) - list = searchList (); + list = searchList(); if (i >= (numsize)) { - debug ("Increasing size for long PATH"); + debug("Increasing size for long PATH"); tmp = - (char **) SDL_calloc ((MAX_SEARCH_PATHS + numsize), - sizeof (char **)); + (char **) SDL_calloc((MAX_SEARCH_PATHS + numsize), + sizeof(char **)); if (tmp) { - SDL_memcpy (tmp, path, sizeof (char **) * numsize); - SDL_free (path); + SDL_memcpy(tmp, path, sizeof(char **) * numsize); + SDL_free(path); path = tmp; numsize += MAX_SEARCH_PATHS; } else { @@ -429,7 +428,7 @@ } while (!path[i] && !end) { - path[i] = strsep ((char **) &list, ":"); + path[i] = strsep((char **) &list, ":"); if (path[i][0] == 0) path[i] = 0; @@ -439,12 +438,12 @@ } static const char * -getFullPath (int i, const char *file) +getFullPath(int i, const char *file) { static char buf[PATH_MAX]; - const char *path = getSearchPath (i); + const char *path = getSearchPath(i); if (path) { - SDL_snprintf (buf, PATH_MAX, "%s/%s", path, file); + SDL_snprintf(buf, PATH_MAX, "%s/%s", path, file); } return path ? buf : 0; } @@ -454,22 +453,22 @@ * search list in the order they are specified there. */ static const struct stat * -findFile (const char *file, const char **fullPath) +findFile(const char *file, const char **fullPath) { int i = 0; static struct stat sbuf; char *fileName; - debug ("finding file %s", file); + debug("finding file %s", file); *fullPath = file; - if (0 == stat (file, &sbuf)) + if (0 == stat(file, &sbuf)) return &sbuf; - if (SDL_strchr (file, '/')) + if (SDL_strchr(file, '/')) return 0; /* If the path had a / we don't look in env var places */ fileName = NULL; if (!fileName) fileName = (char *) file; - while ((*fullPath = getFullPath (i++, fileName))) { - if (0 == stat (*fullPath, &sbuf)) + while ((*fullPath = getFullPath(i++, fileName))) { + if (0 == stat(*fullPath, &sbuf)) return &sbuf; } ; @@ -478,32 +477,32 @@ /* Determine whether a given dlstatus is valid or not */ static int -isValidStatus (struct dlstatus *status) +isValidStatus(struct dlstatus *status) { /* Walk the list to verify status is contained in it */ struct dlstatus *dls = stqueue; while (dls && status != dls) dls = dls->next; if (dls == 0) - error ("invalid handle"); + error("invalid handle"); else if ((dls->module == 0) || (dls->refs == 0)) - error ("handle to closed library"); + error("handle to closed library"); else return TRUE; return FALSE; } static inline int -isFlagSet (int mode, int flag) +isFlagSet(int mode, int flag) { return (mode & flag) == flag; } static struct dlstatus * -lookupStatus (const struct stat *sbuf) +lookupStatus(const struct stat *sbuf) { struct dlstatus *dls = stqueue; - debug ("looking for status"); + debug("looking for status"); while (dls && ( /* isFlagSet(dls->mode, RTLD_UNSHARED) */ 0 || sbuf->st_dev != dls->device || sbuf->st_ino != dls->inode)) @@ -512,9 +511,9 @@ } static void -insertStatus (struct dlstatus *dls, const struct stat *sbuf) +insertStatus(struct dlstatus *dls, const struct stat *sbuf) { - debug ("inserting status"); + debug("inserting status"); dls->inode = sbuf->st_ino; dls->device = sbuf->st_dev; dls->refs = 0; @@ -527,7 +526,7 @@ } static struct dlstatus * -allocStatus () +allocStatus() { struct dlstatus *dls; #ifdef REUSE_STATUS @@ -536,58 +535,57 @@ dls = dls->next; if (!dls) #endif - dls = SDL_calloc (sizeof (*dls), 1); + dls = SDL_calloc(sizeof(*dls), 1); return dls; } static int -promoteLocalToGlobal (struct dlstatus *dls) +promoteLocalToGlobal(struct dlstatus *dls) { static int (*p) (NSModule module) = 0; - debug ("promoting"); + debug("promoting"); if (!p) - _dyld_func_lookup ("__dyld_NSMakePrivateModulePublic", (void **) &p); - return (dls->module == MAGIC_DYLIB_MOD) || (p && p (dls->module)); + _dyld_func_lookup("__dyld_NSMakePrivateModulePublic", (void **) &p); + return (dls->module == MAGIC_DYLIB_MOD) || (p && p(dls->module)); } static void * -reference (struct dlstatus *dls, int mode) +reference(struct dlstatus *dls, int mode) { if (dls) { - if (dls->module == MAGIC_DYLIB_MOD && isFlagSet (mode, RTLD_LOCAL)) { - warning ("trying to open a .dylib with RTLD_LOCAL"); - error ("unable to open a .dylib with RTLD_LOCAL"); + if (dls->module == MAGIC_DYLIB_MOD && isFlagSet(mode, RTLD_LOCAL)) { + warning("trying to open a .dylib with RTLD_LOCAL"); + error("unable to open a .dylib with RTLD_LOCAL"); return NULL; } - if (isFlagSet (mode, RTLD_GLOBAL) && - !isFlagSet (dls->mode, RTLD_GLOBAL) - && !promoteLocalToGlobal (dls)) { - error ("unable to promote local module to global"); + if (isFlagSet(mode, RTLD_GLOBAL) && !isFlagSet(dls->mode, RTLD_GLOBAL) + && !promoteLocalToGlobal(dls)) { + error("unable to promote local module to global"); return NULL; } dls->mode |= mode; dls->refs++; } else - debug ("reference called with NULL argument"); + debug("reference called with NULL argument"); return dls; } static const struct mach_header * -my_find_image (const char *name) +my_find_image(const char *name) { const struct mach_header *mh = 0; const char *id = NULL; - int i = _dyld_image_count (); + int i = _dyld_image_count(); int j; mh = (struct mach_header *) - dyld_NSAddImage (name, NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED | - NSADDIMAGE_OPTION_RETURN_ON_ERROR); + dyld_NSAddImage(name, NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED | + NSADDIMAGE_OPTION_RETURN_ON_ERROR); if (!mh) { for (j = 0; j < i; j++) { - id = _dyld_get_image_name (j); - if (!SDL_strcmp (id, name)) { - mh = _dyld_get_image_header (j); + id = _dyld_get_image_name(j); + if (!SDL_strcmp(id, name)) { + mh = _dyld_get_image_header(j); break; } } @@ -602,7 +600,7 @@ * any of it's direct dependencies, then it probably isn't there. */ static NSSymbol -search_linked_libs (const struct mach_header *mh, const char *symbol) +search_linked_libs(const struct mach_header *mh, const char *symbol) { unsigned int n; struct load_command *lc = 0; @@ -611,29 +609,29 @@ if (dyld_NSAddImage && dyld_NSIsSymbolNameDefinedInImage && dyld_NSLookupSymbolInImage) { lc = (struct load_command *) ((char *) mh + - sizeof (struct mach_header)); + sizeof(struct mach_header)); for (n = 0; n < mh->ncmds; n++, lc = (struct load_command *) ((char *) lc + lc->cmdsize)) { if ((LC_LOAD_DYLIB == lc->cmd) || (LC_LOAD_WEAK_DYLIB == lc->cmd)) { if ((wh = (struct mach_header *) - my_find_image ((char - *) (((struct dylib_command *) lc)-> - dylib.name.offset + (char *) lc)))) { - if (dyld_NSIsSymbolNameDefinedInImage (wh, symbol)) { - nssym = dyld_NSLookupSymbolInImage (wh, - symbol, - NSLOOKUPSYMBOLINIMAGE_OPTION_BIND - | - NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); + my_find_image((char + *) (((struct dylib_command *) lc)-> + dylib.name.offset + (char *) lc)))) { + if (dyld_NSIsSymbolNameDefinedInImage(wh, symbol)) { + nssym = dyld_NSLookupSymbolInImage(wh, + symbol, + NSLOOKUPSYMBOLINIMAGE_OPTION_BIND + | + NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); break; } } } } - if ((!nssym) && NSIsSymbolNameDefined (symbol)) { + if ((!nssym) && NSIsSymbolNameDefined(symbol)) { /* I've never seen this debug message... */ - debug ("Symbol \"%s\" is defined but was not found", symbol); + debug("Symbol \"%s\" is defined but was not found", symbol); } } return nssym; @@ -641,32 +639,32 @@ /* Up to the caller to SDL_free() returned string */ static inline char * -dyld_error_str () +dyld_error_str() { NSLinkEditErrors dylder; int dylderno; const char *dylderrstr; const char *dyldfile; char *retStr = NULL; - NSLinkEditError (&dylder, &dylderno, &dyldfile, &dylderrstr); + NSLinkEditError(&dylder, &dylderno, &dyldfile, &dylderrstr); if (dylderrstr && *dylderrstr) { - retStr = SDL_strdup (dylderrstr); + retStr = SDL_strdup(dylderrstr); } return retStr; } static void * -dlsymIntern (struct dlstatus *dls, const char *symbol, int canSetError) +dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetError) { NSSymbol nssym = 0; #ifdef __GCC__ - void *caller = __builtin_return_address (1); /* Be *very* careful about inlining */ + void *caller = __builtin_return_address(1); /* Be *very* careful about inlining */ #else void *caller = NULL; #endif const struct mach_header *caller_mh = 0; char *savedErrorStr = NULL; - resetdlerror (); + resetdlerror(); #ifndef RTLD_SELF #define RTLD_SELF ((void *) -3) #endif @@ -675,28 +673,28 @@ if ((RTLD_NEXT == dls) || (RTLD_SELF == dls)) { if (dyld_NSIsSymbolNameDefinedInImage && dyld_NSLookupSymbolInImage && caller) { - caller_mh = image_for_address (caller); + caller_mh = image_for_address(caller); if (RTLD_SELF == dls) { /* FIXME: We should be using the NSModule api, if SELF is an MH_BUNDLE * But it appears to work anyway, and looking at the code in dyld_libfuncs.c * this is acceptable. */ - if (dyld_NSIsSymbolNameDefinedInImage (caller_mh, symbol)) { - nssym = dyld_NSLookupSymbolInImage (caller_mh, - symbol, - NSLOOKUPSYMBOLINIMAGE_OPTION_BIND - | - NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); + if (dyld_NSIsSymbolNameDefinedInImage(caller_mh, symbol)) { + nssym = dyld_NSLookupSymbolInImage(caller_mh, + symbol, + NSLOOKUPSYMBOLINIMAGE_OPTION_BIND + | + NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); } } if (!nssym) { if (RTLD_SELF == dls) - savedErrorStr = dyld_error_str (); - nssym = search_linked_libs (caller_mh, symbol); + savedErrorStr = dyld_error_str(); + nssym = search_linked_libs(caller_mh, symbol); } } else { if (canSetError) - error ("RTLD_SELF and RTLD_NEXT are not supported"); + error("RTLD_SELF and RTLD_NEXT are not supported"); return NULL; } } @@ -705,70 +703,70 @@ if (RTLD_DEFAULT == dls) { dls = &mainStatus; } - if (!isValidStatus (dls)) + if (!isValidStatus(dls)) return NULL; if (dls->module != MAGIC_DYLIB_MOD) { - nssym = NSLookupSymbolInModule (dls->module, symbol); - if (!nssym && NSIsSymbolNameDefined (symbol)) { - debug ("Searching dependencies"); - savedErrorStr = dyld_error_str (); + nssym = NSLookupSymbolInModule(dls->module, symbol); + if (!nssym && NSIsSymbolNameDefined(symbol)) { + debug("Searching dependencies"); + savedErrorStr = dyld_error_str(); nssym = - search_linked_libs (get_mach_header_from_NSModule - (dls->module), symbol); + search_linked_libs(get_mach_header_from_NSModule + (dls->module), symbol); } } else if (dls->lib && dyld_NSIsSymbolNameDefinedInImage && dyld_NSLookupSymbolInImage) { - if (dyld_NSIsSymbolNameDefinedInImage (dls->lib, symbol)) { - nssym = dyld_NSLookupSymbolInImage (dls->lib, - symbol, - NSLOOKUPSYMBOLINIMAGE_OPTION_BIND - | - NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); - } else if (NSIsSymbolNameDefined (symbol)) { - debug ("Searching dependencies"); - savedErrorStr = dyld_error_str (); - nssym = search_linked_libs (dls->lib, symbol); + if (dyld_NSIsSymbolNameDefinedInImage(dls->lib, symbol)) { + nssym = dyld_NSLookupSymbolInImage(dls->lib, + symbol, + NSLOOKUPSYMBOLINIMAGE_OPTION_BIND + | + NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); + } else if (NSIsSymbolNameDefined(symbol)) { + debug("Searching dependencies"); + savedErrorStr = dyld_error_str(); + nssym = search_linked_libs(dls->lib, symbol); } } else if (dls->module == MAGIC_DYLIB_MOD) { /* Global context, use NSLookupAndBindSymbol */ - if (NSIsSymbolNameDefined (symbol)) { + if (NSIsSymbolNameDefined(symbol)) { /* There doesn't seem to be a return on error option for this call??? this is potentially broken, if binding fails, it will improperly exit the application. */ - nssym = NSLookupAndBindSymbol (symbol); + nssym = NSLookupAndBindSymbol(symbol); } else { if (savedErrorStr) - SDL_free (savedErrorStr); - savedErrorStr = SDL_malloc (256); - SDL_snprintf (savedErrorStr, 256, - "Symbol \"%s\" not in global context", symbol); + SDL_free(savedErrorStr); + savedErrorStr = SDL_malloc(256); + SDL_snprintf(savedErrorStr, 256, + "Symbol \"%s\" not in global context", symbol); } } } /* Error reporting */ if (!nssym) { - if (!savedErrorStr || !SDL_strlen (savedErrorStr)) { + if (!savedErrorStr || !SDL_strlen(savedErrorStr)) { if (savedErrorStr) - SDL_free (savedErrorStr); - savedErrorStr = SDL_malloc (256); - SDL_snprintf (savedErrorStr, 256, "Symbol \"%s\" not found", - symbol); + SDL_free(savedErrorStr); + savedErrorStr = SDL_malloc(256); + SDL_snprintf(savedErrorStr, 256, "Symbol \"%s\" not found", + symbol); } if (canSetError) { - error (savedErrorStr); + error(savedErrorStr); } else { - debug (savedErrorStr); + debug(savedErrorStr); } if (savedErrorStr) - SDL_free (savedErrorStr); + SDL_free(savedErrorStr); return NULL; } - return NSAddressOfSymbol (nssym); + return NSAddressOfSymbol(nssym); } static struct dlstatus * -loadModule (const char *path, const struct stat *sbuf, int mode) +loadModule(const char *path, const struct stat *sbuf, int mode) { NSObjectFileImage ofi = 0; NSObjectFileImageReturnCode ofirc; @@ -779,52 +777,52 @@ const char *file; void (*init) (void); - ofirc = NSCreateObjectFileImageFromFile (path, &ofi); + ofirc = NSCreateObjectFileImageFromFile(path, &ofi); switch (ofirc) { case NSObjectFileImageSuccess: break; case NSObjectFileImageInappropriateFile: if (dyld_NSAddImage && dyld_NSIsSymbolNameDefinedInImage && dyld_NSLookupSymbolInImage) { - if (isFlagSet (mode, RTLD_LOCAL)) { - warning ("trying to open a .dylib with RTLD_LOCAL"); - error ("unable to open this file with RTLD_LOCAL"); + if (isFlagSet(mode, RTLD_LOCAL)) { + warning("trying to open a .dylib with RTLD_LOCAL"); + error("unable to open this file with RTLD_LOCAL"); return NULL; } } else { - error ("opening this file is unsupported on this system"); + error("opening this file is unsupported on this system"); return NULL; } break; case NSObjectFileImageFailure: - error ("object file setup failure"); + error("object file setup failure"); return NULL; case NSObjectFileImageArch: - error ("no object for this architecture"); + error("no object for this architecture"); return NULL; case NSObjectFileImageFormat: - error ("bad object file format"); + error("bad object file format"); return NULL; case NSObjectFileImageAccess: - error ("can't read object file"); + error("can't read object file"); return NULL; default: - error ("unknown error from NSCreateObjectFileImageFromFile()"); + error("unknown error from NSCreateObjectFileImageFromFile()"); return NULL; } - dls = lookupStatus (sbuf); + dls = lookupStatus(sbuf); if (!dls) { - dls = allocStatus (); + dls = allocStatus(); } if (!dls) { - error ("unable to allocate memory"); + error("unable to allocate memory"); return NULL; } // dls->lib = 0; if (ofirc == NSObjectFileImageInappropriateFile) { if ((dls->lib = - dyld_NSAddImage (path, NSADDIMAGE_OPTION_RETURN_ON_ERROR))) { - debug ("Dynamic lib loaded at %ld", dls->lib); + dyld_NSAddImage(path, NSADDIMAGE_OPTION_RETURN_ON_ERROR))) { + debug("Dynamic lib loaded at %ld", dls->lib); ofi = MAGIC_DYLIB_OFI; dls->module = MAGIC_DYLIB_MOD; ofirc = NSObjectFileImageSuccess; @@ -832,85 +830,85 @@ functions with RTLD_NOW, I don't deem it necessary at the moment */ } if (!(dls->module)) { - NSLinkEditError (&ler, &lerno, &file, &errstr); - if (!errstr || (!SDL_strlen (errstr))) - error ("Can't open this file type"); + NSLinkEditError(&ler, &lerno, &file, &errstr); + if (!errstr || (!SDL_strlen(errstr))) + error("Can't open this file type"); else - error (errstr); + error(errstr); if ((dls->flags & DL_IN_LIST) == 0) { - SDL_free (dls); + SDL_free(dls); } return NULL; } } else { - dls->module = NSLinkModule (ofi, path, - NSLINKMODULE_OPTION_RETURN_ON_ERROR | - NSLINKMODULE_OPTION_PRIVATE | - (isFlagSet (mode, RTLD_NOW) ? - NSLINKMODULE_OPTION_BINDNOW : 0)); - NSDestroyObjectFileImage (ofi); + dls->module = NSLinkModule(ofi, path, + NSLINKMODULE_OPTION_RETURN_ON_ERROR | + NSLINKMODULE_OPTION_PRIVATE | + (isFlagSet(mode, RTLD_NOW) ? + NSLINKMODULE_OPTION_BINDNOW : 0)); + NSDestroyObjectFileImage(ofi); if (dls->module) { - dls->lib = get_mach_header_from_NSModule (dls->module); + dls->lib = get_mach_header_from_NSModule(dls->module); } } if (!dls->module) { - NSLinkEditError (&ler, &lerno, &file, &errstr); + NSLinkEditError(&ler, &lerno, &file, &errstr); if ((dls->flags & DL_IN_LIST) == 0) { - SDL_free (dls); + SDL_free(dls); } - error (errstr); + error(errstr); return NULL; } - insertStatus (dls, sbuf); - dls = reference (dls, mode); - if ((init = dlsymIntern (dls, "__init", 0))) { - debug ("calling _init()"); - init (); + insertStatus(dls, sbuf); + dls = reference(dls, mode); + if ((init = dlsymIntern(dls, "__init", 0))) { + debug("calling _init()"); + init(); } return dls; } inline static void -dlcompat_init_check (void) +dlcompat_init_check(void) { static pthread_mutex_t l = PTHREAD_MUTEX_INITIALIZER; static int init_done = 0; - pthread_mutex_lock (&l); + pthread_mutex_lock(&l); if (!init_done) { - dlcompat_init_func (); + dlcompat_init_func(); init_done = 1; } - pthread_mutex_unlock (&l); + pthread_mutex_unlock(&l); } static void -dlcompat_init_func (void) +dlcompat_init_func(void) { - _dyld_func_lookup ("__dyld_NSAddImage", (void **) &dyld_NSAddImage); - _dyld_func_lookup ("__dyld_NSIsSymbolNameDefinedInImage", - (void **) &dyld_NSIsSymbolNameDefinedInImage); - _dyld_func_lookup ("__dyld_NSLookupSymbolInImage", - (void **) &dyld_NSLookupSymbolInImage); - if (pthread_mutex_init (&dlcompat_mutex, NULL)) - exit (1); - if (pthread_key_create (&dlerror_key, &dlerrorfree)) - exit (1); + _dyld_func_lookup("__dyld_NSAddImage", (void **) &dyld_NSAddImage); + _dyld_func_lookup("__dyld_NSIsSymbolNameDefinedInImage", + (void **) &dyld_NSIsSymbolNameDefinedInImage); + _dyld_func_lookup("__dyld_NSLookupSymbolInImage", + (void **) &dyld_NSLookupSymbolInImage); + if (pthread_mutex_init(&dlcompat_mutex, NULL)) + exit(1); + if (pthread_key_create(&dlerror_key, &dlerrorfree)) + exit(1); } static void -resetdlerror () +resetdlerror() { struct dlthread *tss; - tss = pthread_getspecific (dlerror_key); + tss = pthread_getspecific(dlerror_key); tss->errset = 0; } static void -dlerrorfree (void *data) +dlerrorfree(void *data) { - SDL_free (data); + SDL_free(data); } /* We kind of want a recursive lock here, but meet a little trouble @@ -918,105 +916,105 @@ * using thread specific storage to keep a lock count */ static inline void -dolock (void) +dolock(void) { int err = 0; struct dlthread *tss; - dlcompat_init_check (); - tss = pthread_getspecific (dlerror_key); + dlcompat_init_check(); + tss = pthread_getspecific(dlerror_key); if (!tss) { - tss = SDL_malloc (sizeof (struct dlthread)); + tss = SDL_malloc(sizeof(struct dlthread)); tss->lockcnt = 0; tss->errset = 0; - if (pthread_setspecific (dlerror_key, tss)) { - fprintf (stderr, "dlcompat: pthread_setspecific failed\n"); - exit (1); + if (pthread_setspecific(dlerror_key, tss)) { + fprintf(stderr, "dlcompat: pthread_setspecific failed\n"); + exit(1); } } if (!tss->lockcnt) - err = pthread_mutex_lock (&dlcompat_mutex); + err = pthread_mutex_lock(&dlcompat_mutex); tss->lockcnt = tss->lockcnt + 1; if (err) - exit (err); + exit(err); } static inline void -dounlock (void) +dounlock(void) { int err = 0; struct dlthread *tss; - tss = pthread_getspecific (dlerror_key); + tss = pthread_getspecific(dlerror_key); tss->lockcnt = tss->lockcnt - 1; if (!tss->lockcnt) - err = pthread_mutex_unlock (&dlcompat_mutex); + err = pthread_mutex_unlock(&dlcompat_mutex); if (err) - exit (err); + exit(err); } static void * -SDL_OSX_dlopen (const char *path, int mode) +SDL_OSX_dlopen(const char *path, int mode) { const struct stat *sbuf; struct dlstatus *dls; const char *fullPath; - dolock (); - resetdlerror (); + dolock(); + resetdlerror(); if (!path) { dls = &mainStatus; goto dlopenok; } - if (!(sbuf = findFile (path, &fullPath))) { - error ("file \"%s\" not found", path); + if (!(sbuf = findFile(path, &fullPath))) { + error("file \"%s\" not found", path); goto dlopenerror; } /* Now checks that it hasn't been closed already */ - if ((dls = lookupStatus (sbuf)) && (dls->refs > 0)) { + if ((dls = lookupStatus(sbuf)) && (dls->refs > 0)) { /* debug("status found"); */ - dls = reference (dls, mode); + dls = reference(dls, mode); goto dlopenok; } #ifdef RTLD_NOLOAD - if (isFlagSet (mode, RTLD_NOLOAD)) { - error ("no existing handle and RTLD_NOLOAD specified"); + if (isFlagSet(mode, RTLD_NOLOAD)) { + error("no existing handle and RTLD_NOLOAD specified"); goto dlopenerror; } #endif - if (isFlagSet (mode, RTLD_LAZY) && isFlagSet (mode, RTLD_NOW)) { - error ("how can I load something both RTLD_LAZY and RTLD_NOW?"); + if (isFlagSet(mode, RTLD_LAZY) && isFlagSet(mode, RTLD_NOW)) { + error("how can I load something both RTLD_LAZY and RTLD_NOW?"); goto dlopenerror; } - dls = loadModule (fullPath, sbuf, mode); + dls = loadModule(fullPath, sbuf, mode); dlopenok: - dounlock (); + dounlock(); return (void *) dls; dlopenerror: - dounlock (); + dounlock(); return NULL; } #if !FINK_BUILD static void * -SDL_OSX_dlsym (void *dl_restrict handle, const char *dl_restrict symbol) +SDL_OSX_dlsym(void *dl_restrict handle, const char *dl_restrict symbol) { - int sym_len = SDL_strlen (symbol); + int sym_len = SDL_strlen(symbol); void *value = NULL; char *malloc_sym = NULL; - dolock (); - malloc_sym = SDL_malloc (sym_len + 2); + dolock(); + malloc_sym = SDL_malloc(sym_len + 2); if (malloc_sym) { - SDL_snprintf (malloc_sym, sym_len + 2, "_%s", symbol); - value = dlsymIntern (handle, malloc_sym, 1); - SDL_free (malloc_sym); + SDL_snprintf(malloc_sym, sym_len + 2, "_%s", symbol); + value = dlsymIntern(handle, malloc_sym, 1); + SDL_free(malloc_sym); } else { - error ("Unable to allocate memory"); + error("Unable to allocate memory"); goto dlsymerror; } - dounlock (); + dounlock(); return value; dlsymerror: - dounlock (); + dounlock(); return NULL; } #endif @@ -1024,17 +1022,17 @@ #if FINK_BUILD static void * -dlsym_prepend_underscore (void *handle, const char *symbol) +dlsym_prepend_underscore(void *handle, const char *symbol) { void *answer; - dolock (); - answer = dlsym_prepend_underscore_intern (handle, symbol); - dounlock (); + dolock(); + answer = dlsym_prepend_underscore_intern(handle, symbol); + dounlock(); return answer; } static void * -dlsym_prepend_underscore_intern (void *handle, const char *symbol) +dlsym_prepend_underscore_intern(void *handle, const char *symbol) { /* * A quick and easy way for porting packages which call dlsym(handle,"sym") @@ -1045,61 +1043,61 @@ * the underscore always, or not at all. These global functions need to go away * for opendarwin. */ - int sym_len = SDL_strlen (symbol); + int sym_len = SDL_strlen(symbol); void *value = NULL; char *malloc_sym = NULL; - malloc_sym = SDL_malloc (sym_len + 2); + malloc_sym = SDL_malloc(sym_len + 2); if (malloc_sym) { - SDL_snprintf (malloc_sym, sym_len + 2, "_%s", symbol); - value = dlsymIntern (handle, malloc_sym, 1); - SDL_free (malloc_sym); + SDL_snprintf(malloc_sym, sym_len + 2, "_%s", symbol); + value = dlsymIntern(handle, malloc_sym, 1); + SDL_free(malloc_sym); } else { - error ("Unable to allocate memory"); + error("Unable to allocate memory"); } return value; } static void * -dlsym_auto_underscore (void *handle, const char *symbol) +dlsym_auto_underscore(void *handle, const char *symbol) { void *answer; - dolock (); - answer = dlsym_auto_underscore_intern (handle, symbol); - dounlock (); + dolock(); + answer = dlsym_auto_underscore_intern(handle, symbol); + dounlock(); return answer; } static void * -dlsym_auto_underscore_intern (void *handle, const char *symbol) +dlsym_auto_underscore_intern(void *handle, const char *symbol) { struct dlstatus *dls = handle; void *addr = 0; - addr = dlsymIntern (dls, symbol, 0); + addr = dlsymIntern(dls, symbol, 0); if (!addr) - addr = dlsym_prepend_underscore_intern (handle, symbol); + addr = dlsym_prepend_underscore_intern(handle, symbol); return addr; } static void * -SDL_OSX_dlsym (void *dl_restrict handle, const char *dl_restrict symbol) +SDL_OSX_dlsym(void *dl_restrict handle, const char *dl_restrict symbol) { struct dlstatus *dls = handle; void *addr = 0; - dolock (); - addr = dlsymIntern (dls, symbol, 1); - dounlock (); + dolock(); + addr = dlsymIntern(dls, symbol, 1); + dounlock(); return addr; } #endif static int -SDL_OSX_dlclose (void *handle) +SDL_OSX_dlclose(void *handle) { struct dlstatus *dls = handle; - dolock (); - resetdlerror (); - if (!isValidStatus (dls)) { + dolock(); + resetdlerror(); + if (!isValidStatus(dls)) { goto dlcloseerror; } if (dls->module == MAGIC_DYLIB_MOD) { @@ -1107,32 +1105,32 @@ if (!dls->lib) { name = "global context"; } else { - name = get_lib_name (dls->lib); + name = get_lib_name(dls->lib); } - warning ("trying to close a .dylib!"); - error ("Not closing \"%s\" - dynamic libraries cannot be closed", - name); + warning("trying to close a .dylib!"); + error("Not closing \"%s\" - dynamic libraries cannot be closed", + name); goto dlcloseerror; } if (!dls->module) { - error ("module already closed"); + error("module already closed"); goto dlcloseerror; } if (dls->refs == 1) { unsigned long options = 0; void (*fini) (void); - if ((fini = dlsymIntern (dls, "__fini", 0))) { - debug ("calling _fini()"); - fini (); + if ((fini = dlsymIntern(dls, "__fini", 0))) { + debug("calling _fini()"); + fini(); } options |= NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES; #ifdef RTLD_NODELETE - if (isFlagSet (dls->mode, RTLD_NODELETE)) + if (isFlagSet(dls->mode, RTLD_NODELETE)) options |= NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED; #endif - if (!NSUnLinkModule (dls->module, options)) { - error ("unable to unlink module"); + if (!NSUnLinkModule(dls->module, options)) { + error("unable to unlink module"); goto dlcloseerror; } dls->refs--; @@ -1142,20 +1140,20 @@ * problem in mostly all cases, though. */ } - dounlock (); + dounlock(); return 0; dlcloseerror: - dounlock (); + dounlock(); return 1; } static const char * -SDL_OSX_dlerror (void) +SDL_OSX_dlerror(void) { struct dlthread *tss; const char *err_str = NULL; - dlcompat_init_check (); - tss = pthread_getspecific (dlerror_key); + dlcompat_init_check(); + tss = pthread_getspecific(dlerror_key); if (tss != NULL && tss->errset != 0) { tss->errset = 0; err_str = tss->errstr; @@ -1167,20 +1165,20 @@ * or zero if the given address is not contained in any loaded images. */ static const struct mach_header * -image_for_address (const void *address) +image_for_address(const void *address) { unsigned long i; unsigned long j; - unsigned long count = _dyld_image_count (); + unsigned long count = _dyld_image_count(); const struct mach_header *mh = 0; struct load_command *lc = 0; unsigned long addr = 0; for (i = 0; i < count; i++) { - addr = (unsigned long) address - _dyld_get_image_vmaddr_slide (i); - mh = _dyld_get_image_header (i); + addr = (unsigned long) address - _dyld_get_image_vmaddr_slide(i); + mh = _dyld_get_image_header(i); if (mh) { lc = (struct load_command *) ((char *) mh + - sizeof (struct mach_header)); + sizeof(struct mach_header)); for (j = 0; j < mh->ncmds; j++, lc = (struct load_command *) ((char *) lc + lc->cmdsize)) { @@ -1201,14 +1199,14 @@ #if 0 /* unused */ static int -SDL_OSX_dladdr (const void *dl_restrict p, SDL_OSX_Dl_info * dl_restrict info) +SDL_OSX_dladdr(const void *dl_restrict p, SDL_OSX_Dl_info * dl_restrict info) { /* FIXME: USe the routine image_for_address. */ unsigned long i; unsigned long j; - unsigned long count = _dyld_image_count (); + unsigned long count = _dyld_image_count(); struct mach_header *mh = 0; struct load_command *lc = 0; unsigned long addr = NULL; @@ -1216,8 +1214,8 @@ int found = 0; if (!info) return 0; - dolock (); - resetdlerror (); + dolock(); + resetdlerror(); info->dli_fname = 0; info->dli_fbase = 0; info->dli_sname = 0; @@ -1226,11 +1224,11 @@ * to darwin-development AT lists DOT apple DOT com and slightly modified */ for (i = 0; i < count; i++) { - addr = (unsigned long) p - _dyld_get_image_vmaddr_slide (i); - mh = _dyld_get_image_header (i); + addr = (unsigned long) p - _dyld_get_image_vmaddr_slide(i); + mh = _dyld_get_image_header(i); if (mh) { lc = (struct load_command *) ((char *) mh + - sizeof (struct mach_header)); + sizeof(struct mach_header)); for (j = 0; j < mh->ncmds; j++, lc = (struct load_command *) ((char *) lc + lc->cmdsize)) { @@ -1239,7 +1237,7 @@ addr < ((struct segment_command *) lc)->vmaddr + ((struct segment_command *) lc)->vmsize) { - info->dli_fname = _dyld_get_image_name (i); + info->dli_fname = _dyld_get_image_name(i); info->dli_fbase = (void *) mh; found = 1; break; @@ -1250,10 +1248,10 @@ } } if (!found) { - dounlock (); + dounlock(); return 0; } - lc = (struct load_command *) ((char *) mh + sizeof (struct mach_header)); + lc = (struct load_command *) ((char *) mh + sizeof(struct mach_header)); for (j = 0; j < mh->ncmds; j++, lc = (struct load_command *) ((char *) lc + lc->cmdsize)) { if (LC_SEGMENT == lc->cmd) { @@ -1265,10 +1263,10 @@ table_off = ((unsigned long) ((struct segment_command *) lc)->vmaddr) - ((unsigned long) ((struct segment_command *) lc)->fileoff) + - _dyld_get_image_vmaddr_slide (i); - debug ("table off %x", table_off); + _dyld_get_image_vmaddr_slide(i); + debug("table off %x", table_off); - lc = (struct load_command *) ((char *) mh + sizeof (struct mach_header)); + lc = (struct load_command *) ((char *) mh + sizeof(struct mach_header)); for (j = 0; j < mh->ncmds; j++, lc = (struct load_command *) ((char *) lc + lc->cmdsize)) { if (LC_SYMTAB == lc->cmd) { @@ -1282,7 +1280,7 @@ unsigned long strtable = (unsigned long) (((struct symtab_command *) lc)->stroff + table_off); - debug ("symtable %x", symtable); + debug("symtable %x", symtable); for (i = 0; i < numsyms; i++) { /* Ignore the following kinds of Symbols */ if ((!symtable->n_value) /* Undefined */ @@ -1305,7 +1303,7 @@ } } } - dounlock (); + dounlock(); return 1; } #endif @@ -1321,29 +1319,29 @@ */ #if 0 static dlfunc_t -SDL_OSX_dlfunc (void *dl_restrict handle, const char *dl_restrict symbol) +SDL_OSX_dlfunc(void *dl_restrict handle, const char *dl_restrict symbol) { union { void *d; dlfunc_t f; } rv; - int sym_len = SDL_strlen (symbol); + int sym_len = SDL_strlen(symbol); char *malloc_sym = NULL; - dolock (); - malloc_sym = SDL_malloc (sym_len + 2); + dolock(); + malloc_sym = SDL_malloc(sym_len + 2); if (malloc_sym) { - SDL_snprintf (malloc_sym, sym_len + 2, "_%s", symbol); - rv.d = dlsymIntern (handle, malloc_sym, 1); - SDL_free (malloc_sym); + SDL_snprintf(malloc_sym, sym_len + 2, "_%s", symbol); + rv.d = dlsymIntern(handle, malloc_sym, 1); + SDL_free(malloc_sym); } else { - error ("Unable to allocate memory"); + error("Unable to allocate memory"); goto dlfuncerror; } - dounlock (); + dounlock(); return rv.f; dlfuncerror: - dounlock (); + dounlock(); return NULL; } #endif @@ -1359,31 +1357,31 @@ #include "SDL_loadso.h" void * -SDL_LoadObject (const char *sofile) +SDL_LoadObject(const char *sofile) { - void *handle = SDL_OSX_dlopen (sofile, RTLD_NOW); - const char *loaderror = SDL_OSX_dlerror (); + void *handle = SDL_OSX_dlopen(sofile, RTLD_NOW); + const char *loaderror = SDL_OSX_dlerror(); if (handle == NULL) { - SDL_SetError ("Failed loading %s: %s", sofile, loaderror); + SDL_SetError("Failed loading %s: %s", sofile, loaderror); } return (handle); } void * -SDL_LoadFunction (void *handle, const char *name) +SDL_LoadFunction(void *handle, const char *name) { - void *symbol = SDL_OSX_dlsym (handle, name); + void *symbol = SDL_OSX_dlsym(handle, name); if (symbol == NULL) { - SDL_SetError ("Failed loading %s: %s", name, SDL_OSX_dlerror ()); + SDL_SetError("Failed loading %s: %s", name, SDL_OSX_dlerror()); } return (symbol); } void -SDL_UnloadObject (void *handle) +SDL_UnloadObject(void *handle) { if (handle != NULL) { - SDL_OSX_dlclose (handle); + SDL_OSX_dlclose(handle); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/loadso/mint/SDL_sysloadso.c --- a/src/loadso/mint/SDL_sysloadso.c Mon May 29 03:53:21 2006 +0000 +++ b/src/loadso/mint/SDL_sysloadso.c Mon May 29 04:04:35 2006 +0000 @@ -33,32 +33,32 @@ #include "SDL_loadso.h" void * -SDL_LoadObject (const char *sofile) +SDL_LoadObject(const char *sofile) { const char *loaderror = "Unknown error"; - void *handle = (void *) ldg_open ((char *) sofile, ldg_global); + void *handle = (void *) ldg_open((char *) sofile, ldg_global); if (handle == NULL) { - SDL_SetError ("Failed loading %s: %s", sofile, loaderror); + SDL_SetError("Failed loading %s: %s", sofile, loaderror); } return (handle); } void * -SDL_LoadFunction (void *handle, const char *name) +SDL_LoadFunction(void *handle, const char *name) { const char *loaderror = "Unknown error"; - void *symbol = (void *) ldg_find ((char *) name, (LDG *) handle); + void *symbol = (void *) ldg_find((char *) name, (LDG *) handle); if (symbol == NULL) { - SDL_SetError ("Failed loading %s: %s", name, loaderror); + SDL_SetError("Failed loading %s: %s", name, loaderror); } return (symbol); } void -SDL_UnloadObject (void *handle) +SDL_UnloadObject(void *handle) { if (handle != NULL) { - ldg_close ((LDG *) handle, ldg_global); + ldg_close((LDG *) handle, ldg_global); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/loadso/os2/SDL_sysloadso.c --- a/src/loadso/os2/SDL_sysloadso.c Mon May 29 03:53:21 2006 +0000 +++ b/src/loadso/os2/SDL_sysloadso.c Mon May 29 04:04:35 2006 +0000 @@ -34,42 +34,42 @@ #include "SDL_loadso.h" void * -SDL_LoadObject (const char *sofile) +SDL_LoadObject(const char *sofile) { HMODULE handle = NULL; char buf[512]; - APIRET ulrc = DosLoadModule (buf, sizeof (buf), (char *) sofile, &handle); + APIRET ulrc = DosLoadModule(buf, sizeof(buf), (char *) sofile, &handle); /* Generate an error message if all loads failed */ if ((ulrc != NO_ERROR) || (handle == NULL)) - SDL_SetError ("Failed loading %s: %s", sofile, buf); + SDL_SetError("Failed loading %s: %s", sofile, buf); return ((void *) handle); } void * -SDL_LoadFunction (void *handle, const char *name) +SDL_LoadFunction(void *handle, const char *name) { const char *loaderror = "Unknown error"; void *symbol = NULL; APIRET ulrc = - DosQueryProcAddr ((HMODULE) handle, 0, (char *) name, &symbol); + DosQueryProcAddr((HMODULE) handle, 0, (char *) name, &symbol); if (ulrc == ERROR_INVALID_HANDLE) loaderror = "Invalid module handle"; else if (ulrc == ERROR_INVALID_NAME) loaderror = "Symbol not found"; if (symbol == NULL) - SDL_SetError ("Failed loading %s: %s", name, loaderror); + SDL_SetError("Failed loading %s: %s", name, loaderror); return (symbol); } void -SDL_UnloadObject (void *handle) +SDL_UnloadObject(void *handle) { if (handle != NULL) - DosFreeModule ((HMODULE) handle); + DosFreeModule((HMODULE) handle); } #endif /* SDL_LOADSO_OS2 */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/loadso/win32/SDL_sysloadso.c --- a/src/loadso/win32/SDL_sysloadso.c Mon May 29 03:53:21 2006 +0000 +++ b/src/loadso/win32/SDL_sysloadso.c Mon May 29 04:04:35 2006 +0000 @@ -32,7 +32,7 @@ #include "SDL_loadso.h" void * -SDL_LoadObject (const char *sofile) +SDL_LoadObject(const char *sofile) { void *handle = NULL; const char *loaderror = "Unknown error"; @@ -40,105 +40,103 @@ #if defined(_WIN32_WCE) char errbuf[512]; - wchar_t *errbuf_t = SDL_malloc (512 * sizeof (wchar_t)); - wchar_t *sofile_t = SDL_malloc ((MAX_PATH + 1) * sizeof (wchar_t)); + wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t)); + wchar_t *sofile_t = SDL_malloc((MAX_PATH + 1) * sizeof(wchar_t)); - MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t, - MAX_PATH); - handle = (void *) LoadLibrary (sofile_t); + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t, + MAX_PATH); + handle = (void *) LoadLibrary(sofile_t); /* Generate an error message if all loads failed */ if (handle == NULL) { - FormatMessage ((FORMAT_MESSAGE_IGNORE_INSERTS | - FORMAT_MESSAGE_FROM_SYSTEM), - NULL, GetLastError (), - MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - errbuf_t, SDL_arraysize (errbuf), NULL); - WideCharToMultiByte (CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, - NULL); + FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | + FORMAT_MESSAGE_FROM_SYSTEM), + NULL, GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + errbuf_t, SDL_arraysize(errbuf), NULL); + WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL); loaderror = errbuf; } - SDL_free (sofile_t); - SDL_free (errbuf_t); + SDL_free(sofile_t); + SDL_free(errbuf_t); #else /*if defined(__WIN32__) */ char errbuf[512]; - handle = (void *) LoadLibrary (sofile); + handle = (void *) LoadLibrary(sofile); /* Generate an error message if all loads failed */ if (handle == NULL) { - FormatMessage ((FORMAT_MESSAGE_IGNORE_INSERTS | - FORMAT_MESSAGE_FROM_SYSTEM), - NULL, GetLastError (), - MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - errbuf, SDL_arraysize (errbuf), NULL); + FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | + FORMAT_MESSAGE_FROM_SYSTEM), + NULL, GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + errbuf, SDL_arraysize(errbuf), NULL); loaderror = errbuf; } #endif if (handle == NULL) { - SDL_SetError ("Failed loading %s: %s", sofile, loaderror); + SDL_SetError("Failed loading %s: %s", sofile, loaderror); } return (handle); } void * -SDL_LoadFunction (void *handle, const char *name) +SDL_LoadFunction(void *handle, const char *name) { void *symbol = NULL; const char *loaderror = "Unknown error"; #if defined(_WIN32_WCE) char errbuf[512]; - int length = SDL_strlen (name); + int length = SDL_strlen(name); - wchar_t *name_t = SDL_malloc ((length + 1) * sizeof (wchar_t)); - wchar_t *errbuf_t = SDL_malloc (512 * sizeof (wchar_t)); + wchar_t *name_t = SDL_malloc((length + 1) * sizeof(wchar_t)); + wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t)); - MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length); + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length); - symbol = (void *) GetProcAddress ((HMODULE) handle, name_t); + symbol = (void *) GetProcAddress((HMODULE) handle, name_t); if (symbol == NULL) { - FormatMessage ((FORMAT_MESSAGE_IGNORE_INSERTS | - FORMAT_MESSAGE_FROM_SYSTEM), - NULL, GetLastError (), - MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - errbuf_t, SDL_arraysize (errbuf), NULL); - WideCharToMultiByte (CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, - NULL); + FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | + FORMAT_MESSAGE_FROM_SYSTEM), + NULL, GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + errbuf_t, SDL_arraysize(errbuf), NULL); + WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL); loaderror = errbuf; } - SDL_free (name_t); - SDL_free (errbuf_t); + SDL_free(name_t); + SDL_free(errbuf_t); #else /*if defined(WIN32) */ char errbuf[512]; - symbol = (void *) GetProcAddress ((HMODULE) handle, name); + symbol = (void *) GetProcAddress((HMODULE) handle, name); if (symbol == NULL) { - FormatMessage ((FORMAT_MESSAGE_IGNORE_INSERTS | - FORMAT_MESSAGE_FROM_SYSTEM), - NULL, GetLastError (), - MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - errbuf, SDL_arraysize (errbuf), NULL); + FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | + FORMAT_MESSAGE_FROM_SYSTEM), + NULL, GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + errbuf, SDL_arraysize(errbuf), NULL); loaderror = errbuf; } #endif if (symbol == NULL) { - SDL_SetError ("Failed loading %s: %s", name, loaderror); + SDL_SetError("Failed loading %s: %s", name, loaderror); } return (symbol); } void -SDL_UnloadObject (void *handle) +SDL_UnloadObject(void *handle) { if (handle != NULL) { - FreeLibrary ((HMODULE) handle); + FreeLibrary((HMODULE) handle); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/main/beos/SDL_BeApp.cc --- a/src/main/beos/SDL_BeApp.cc Mon May 29 03:53:21 2006 +0000 +++ b/src/main/beos/SDL_BeApp.cc Mon May 29 04:04:35 2006 +0000 @@ -38,48 +38,48 @@ static SDL_Thread *SDL_AppThread = NULL; static int -StartBeApp (void *unused) +StartBeApp(void *unused) { BApplication *App; - App = new BApplication ("application/x-SDL-executable"); + App = new BApplication("application/x-SDL-executable"); - App->Run (); + App->Run(); delete App; return (0); } /* Initialize the Be Application, if it's not already started */ int -SDL_InitBeApp (void) +SDL_InitBeApp(void) { /* Create the BApplication that handles appserver interaction */ if (SDL_BeAppActive <= 0) { - SDL_AppThread = SDL_CreateThread (StartBeApp, NULL); + SDL_AppThread = SDL_CreateThread(StartBeApp, NULL); if (SDL_AppThread == NULL) { - SDL_SetError ("Couldn't create BApplication thread"); + SDL_SetError("Couldn't create BApplication thread"); return (-1); } /* Change working to directory to that of executable */ app_info info; - if (B_OK == be_app->GetAppInfo (&info)) { + if (B_OK == be_app->GetAppInfo(&info)) { entry_ref ref = info.ref; BEntry entry; - if (B_OK == entry.SetTo (&ref)) { + if (B_OK == entry.SetTo(&ref)) { BPath path; - if (B_OK == path.SetTo (&entry)) { - if (B_OK == path.GetParent (&path)) { - chdir (path.Path ()); + if (B_OK == path.SetTo(&entry)) { + if (B_OK == path.GetParent(&path)) { + chdir(path.Path()); } } } } do { - SDL_Delay (10); + SDL_Delay(10); } - while ((be_app == NULL) || be_app->IsLaunching ()); + while ((be_app == NULL) || be_app->IsLaunching()); /* Mark the application active */ SDL_BeAppActive = 0; @@ -94,7 +94,7 @@ /* Quit the Be Application, if there's nothing left to do */ void -SDL_QuitBeApp (void) +SDL_QuitBeApp(void) { /* Decrement the application reference count */ --SDL_BeAppActive; @@ -103,9 +103,9 @@ if (SDL_BeAppActive == 0) { if (SDL_AppThread != NULL) { if (be_app != NULL) { /* Not tested */ - be_app->PostMessage (B_QUIT_REQUESTED); + be_app->PostMessage(B_QUIT_REQUESTED); } - SDL_WaitThread (SDL_AppThread, NULL); + SDL_WaitThread(SDL_AppThread, NULL); SDL_AppThread = NULL; } /* be_app should now be NULL since be_app has quit */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/main/beos/SDL_BeApp.h --- a/src/main/beos/SDL_BeApp.h Mon May 29 03:53:21 2006 +0000 +++ b/src/main/beos/SDL_BeApp.h Mon May 29 04:04:35 2006 +0000 @@ -24,10 +24,10 @@ /* Handle the BeApp specific portions of the application */ /* Initialize the Be Application, if it's not already started */ -extern int SDL_InitBeApp (void); +extern int SDL_InitBeApp(void); /* Quit the Be Application, if there's nothing left to do */ -extern void SDL_QuitBeApp (void); +extern void SDL_QuitBeApp(void); /* Flag to tell whether the app is active or not */ extern int SDL_BeAppActive; diff -r 1fddae038bc8 -r 4da1ee79c9af src/main/dummy/SDL_dummy_main.c --- a/src/main/dummy/SDL_dummy_main.c Mon May 29 03:53:21 2006 +0000 +++ b/src/main/dummy/SDL_dummy_main.c Mon May 29 04:04:35 2006 +0000 @@ -5,9 +5,9 @@ #ifdef main #undef main int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { - return (SDL_main (argc, argv)); + return (SDL_main(argc, argv)); } #else /* Nothing to do on this platform */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/main/macos/SDL_main.c --- a/src/main/macos/SDL_main.c Mon May 29 03:53:21 2006 +0000 +++ b/src/main/macos/SDL_main.c Mon May 29 04:04:35 2006 +0000 @@ -64,11 +64,11 @@ /* See if the command key is held down at startup */ static Boolean -CommandKeyIsDown (void) +CommandKeyIsDown(void) { KeyMap theKeyMap; - GetKeys (theKeyMap); + GetKeys(theKeyMap); if (((unsigned char *) theKeyMap)[6] & 0x80) { return (true); @@ -80,7 +80,7 @@ /* Parse a command line buffer into arguments */ static int -ParseCommandLine (char *cmdline, char **argv) +ParseCommandLine(char *cmdline, char **argv) { char *bufp; int argc; @@ -88,7 +88,7 @@ argc = 0; for (bufp = cmdline; *bufp;) { /* Skip leading whitespace */ - while (SDL_isspace (*bufp)) { + while (SDL_isspace(*bufp)) { ++bufp; } /* Skip over argument */ @@ -112,7 +112,7 @@ ++argc; } /* Skip over word */ - while (*bufp && !SDL_isspace (*bufp)) { + while (*bufp && !SDL_isspace(*bufp)) { ++bufp; } } @@ -131,30 +131,30 @@ /* Remove the output files if there was no output written */ static void -cleanup_output (void) +cleanup_output(void) { FILE *file; int empty; /* Flush the output in case anything is queued */ - fclose (stdout); - fclose (stderr); + fclose(stdout); + fclose(stderr); /* See if the files have any output in them */ - file = fopen (STDOUT_FILE, "rb"); + file = fopen(STDOUT_FILE, "rb"); if (file) { - empty = (fgetc (file) == EOF) ? 1 : 0; - fclose (file); + empty = (fgetc(file) == EOF) ? 1 : 0; + fclose(file); if (empty) { - remove (STDOUT_FILE); + remove(STDOUT_FILE); } } - file = fopen (STDERR_FILE, "rb"); + file = fopen(STDERR_FILE, "rb"); if (file) { - empty = (fgetc (file) == EOF) ? 1 : 0; - fclose (file); + empty = (fgetc(file) == EOF) ? 1 : 0; + fclose(file); if (empty) { - remove (STDERR_FILE); + remove(STDERR_FILE); } } } @@ -162,7 +162,7 @@ #endif //!(defined(__APPLE__) && defined(__MACH__)) static int -getCurrentAppName (StrFileName name) +getCurrentAppName(StrFileName name) { ProcessSerialNumber process; @@ -171,19 +171,19 @@ process.highLongOfPSN = 0; process.lowLongOfPSN = kCurrentProcess; - process_info.processInfoLength = sizeof (process_info); + process_info.processInfoLength = sizeof(process_info); process_info.processName = NULL; process_info.processAppSpec = &process_fsp; - if (noErr != GetProcessInformation (&process, &process_info)) + if (noErr != GetProcessInformation(&process, &process_info)) return 0; - SDL_memcpy (name, process_fsp.name, process_fsp.name[0] + 1); + SDL_memcpy(name, process_fsp.name, process_fsp.name[0] + 1); return 1; } static int -getPrefsFile (FSSpec * prefs_fsp, int create) +getPrefsFile(FSSpec * prefs_fsp, int create) { /* The prefs file name is the application name, possibly truncated, */ @@ -199,36 +199,36 @@ /* Get Preferences folder - works with Multiple Users */ if (noErr != - FindFolder (kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder, - &volume_ref_number, &directory_id)) - exit (-1); + FindFolder(kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder, + &volume_ref_number, &directory_id)) + exit(-1); - if (!getCurrentAppName (app_name)) - exit (-1); + if (!getCurrentAppName(app_name)) + exit(-1); /* Truncate if name is too long */ if (app_name[0] > MAX_NAME) app_name[0] = MAX_NAME; - SDL_memcpy (prefs_name + 1, app_name + 1, app_name[0]); - SDL_memcpy (prefs_name + app_name[0] + 1, SUFFIX, strlen (SUFFIX)); - prefs_name[0] = app_name[0] + strlen (SUFFIX); + SDL_memcpy(prefs_name + 1, app_name + 1, app_name[0]); + SDL_memcpy(prefs_name + app_name[0] + 1, SUFFIX, strlen(SUFFIX)); + prefs_name[0] = app_name[0] + strlen(SUFFIX); /* Make the file spec for prefs file */ if (noErr != - FSMakeFSSpec (volume_ref_number, directory_id, prefs_name, prefs_fsp)) + FSMakeFSSpec(volume_ref_number, directory_id, prefs_name, prefs_fsp)) { if (!create) return 0; else { /* Create the prefs file */ - SDL_memcpy (prefs_fsp->name, prefs_name, prefs_name[0] + 1); + SDL_memcpy(prefs_fsp->name, prefs_name, prefs_name[0] + 1); prefs_fsp->parID = directory_id; prefs_fsp->vRefNum = volume_ref_number; - FSpCreateResFile (prefs_fsp, 0x3f3f3f3f, 'pref', 0); // '????' parsed as trigraph + FSpCreateResFile(prefs_fsp, 0x3f3f3f3f, 'pref', 0); // '????' parsed as trigraph - if (noErr != ResError ()) + if (noErr != ResError()) return 0; } } @@ -236,133 +236,133 @@ } static int -readPrefsResource (PrefsRecord * prefs) +readPrefsResource(PrefsRecord * prefs) { Handle prefs_handle; - prefs_handle = Get1Resource ('CLne', 128); + prefs_handle = Get1Resource('CLne', 128); if (prefs_handle != NULL) { int offset = 0; // int j = 0; - HLock (prefs_handle); + HLock(prefs_handle); /* Get command line string */ - SDL_memcpy (prefs->command_line, *prefs_handle, - (*prefs_handle)[0] + 1); + SDL_memcpy(prefs->command_line, *prefs_handle, + (*prefs_handle)[0] + 1); /* Get video driver name */ offset += (*prefs_handle)[0] + 1; - SDL_memcpy (prefs->video_driver_name, *prefs_handle + offset, - (*prefs_handle)[offset] + 1); + SDL_memcpy(prefs->video_driver_name, *prefs_handle + offset, + (*prefs_handle)[offset] + 1); /* Get save-to-file option (1 or 0) */ offset += (*prefs_handle)[offset] + 1; prefs->output_to_file = (*prefs_handle)[offset]; - ReleaseResource (prefs_handle); + ReleaseResource(prefs_handle); - return ResError () == noErr; + return ResError() == noErr; } return 0; } static int -writePrefsResource (PrefsRecord * prefs, short resource_file) +writePrefsResource(PrefsRecord * prefs, short resource_file) { Handle prefs_handle; - UseResFile (resource_file); + UseResFile(resource_file); - prefs_handle = Get1Resource ('CLne', 128); + prefs_handle = Get1Resource('CLne', 128); if (prefs_handle != NULL) - RemoveResource (prefs_handle); + RemoveResource(prefs_handle); prefs_handle = - NewHandle (prefs->command_line[0] + prefs->video_driver_name[0] + 4); + NewHandle(prefs->command_line[0] + prefs->video_driver_name[0] + 4); if (prefs_handle != NULL) { int offset; - HLock (prefs_handle); + HLock(prefs_handle); /* Command line text */ offset = 0; - SDL_memcpy (*prefs_handle, prefs->command_line, - prefs->command_line[0] + 1); + SDL_memcpy(*prefs_handle, prefs->command_line, + prefs->command_line[0] + 1); /* Video driver name */ offset += prefs->command_line[0] + 1; - SDL_memcpy (*prefs_handle + offset, prefs->video_driver_name, - prefs->video_driver_name[0] + 1); + SDL_memcpy(*prefs_handle + offset, prefs->video_driver_name, + prefs->video_driver_name[0] + 1); /* Output-to-file option */ offset += prefs->video_driver_name[0] + 1; *(*((char **) prefs_handle) + offset) = (char) prefs->output_to_file; *(*((char **) prefs_handle) + offset + 1) = 0; - AddResource (prefs_handle, 'CLne', 128, "\pCommand Line"); - WriteResource (prefs_handle); - UpdateResFile (resource_file); - DisposeHandle (prefs_handle); + AddResource(prefs_handle, 'CLne', 128, "\pCommand Line"); + WriteResource(prefs_handle); + UpdateResFile(resource_file); + DisposeHandle(prefs_handle); - return ResError () == noErr; + return ResError() == noErr; } return 0; } static int -readPreferences (PrefsRecord * prefs) +readPreferences(PrefsRecord * prefs) { int no_error = 1; FSSpec prefs_fsp; /* Check for prefs file first */ - if (getPrefsFile (&prefs_fsp, 0)) { + if (getPrefsFile(&prefs_fsp, 0)) { short prefs_resource; - prefs_resource = FSpOpenResFile (&prefs_fsp, fsRdPerm); + prefs_resource = FSpOpenResFile(&prefs_fsp, fsRdPerm); if (prefs_resource == -1) /* this shouldn't happen, but... */ return 0; - UseResFile (prefs_resource); - no_error = readPrefsResource (prefs); - CloseResFile (prefs_resource); + UseResFile(prefs_resource); + no_error = readPrefsResource(prefs); + CloseResFile(prefs_resource); } /* Fall back to application's resource fork (reading only, so this is safe) */ else { - no_error = readPrefsResource (prefs); + no_error = readPrefsResource(prefs); } return no_error; } static int -writePreferences (PrefsRecord * prefs) +writePreferences(PrefsRecord * prefs) { int no_error = 1; FSSpec prefs_fsp; /* Get prefs file, create if it doesn't exist */ - if (getPrefsFile (&prefs_fsp, 1)) { + if (getPrefsFile(&prefs_fsp, 1)) { short prefs_resource; - prefs_resource = FSpOpenResFile (&prefs_fsp, fsRdWrPerm); + prefs_resource = FSpOpenResFile(&prefs_fsp, fsRdWrPerm); if (prefs_resource == -1) return 0; - no_error = writePrefsResource (prefs, prefs_resource); - CloseResFile (prefs_resource); + no_error = writePrefsResource(prefs, prefs_resource); + CloseResFile(prefs_resource); } return no_error; @@ -370,7 +370,7 @@ /* This is where execution begins */ int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { #if !(defined(__APPLE__) && defined(__MACH__)) @@ -401,22 +401,22 @@ /* Kyle's SDL command-line dialog code ... */ #if !TARGET_API_MAC_CARBON - InitGraf (&qd.thePort); - InitFonts (); - InitWindows (); - InitMenus (); - InitDialogs (nil); + InitGraf(&qd.thePort); + InitFonts(); + InitWindows(); + InitMenus(); + InitDialogs(nil); #endif - InitCursor (); - FlushEvents (everyEvent, 0); + InitCursor(); + FlushEvents(everyEvent, 0); #if !TARGET_API_MAC_CARBON - MaxApplZone (); + MaxApplZone(); #endif - MoreMasters (); - MoreMasters (); + MoreMasters(); + MoreMasters(); #if 0 /* Intialize SDL, and put up a dialog if we fail */ - if (SDL_Init (0) < 0) { + if (SDL_Init(0) < 0) { #define kErr_OK 1 #define kErr_Text 2 @@ -427,46 +427,46 @@ Handle dummyHandle; short itemHit; - errorDialog = GetNewDialog (1001, nil, (WindowPtr) - 1); + errorDialog = GetNewDialog(1001, nil, (WindowPtr) - 1); if (errorDialog == NULL) return -1; - DrawDialog (errorDialog); + DrawDialog(errorDialog); - GetDialogItem (errorDialog, kErr_Text, &dummyType, &dummyHandle, - &dummyRect); - SetDialogItemText (dummyHandle, "\pError Initializing SDL"); + GetDialogItem(errorDialog, kErr_Text, &dummyType, &dummyHandle, + &dummyRect); + SetDialogItemText(dummyHandle, "\pError Initializing SDL"); #if TARGET_API_MAC_CARBON - SetPort (GetDialogPort (errorDialog)); + SetPort(GetDialogPort(errorDialog)); #else - SetPort (errorDialog); + SetPort(errorDialog); #endif do { - ModalDialog (nil, &itemHit); + ModalDialog(nil, &itemHit); } while (itemHit != kErr_OK); - DisposeDialog (errorDialog); - exit (-1); + DisposeDialog(errorDialog); + exit(-1); } - atexit (cleanup_output); - atexit (SDL_Quit); + atexit(cleanup_output); + atexit(SDL_Quit); #endif /* Set up SDL's QuickDraw environment */ #if !TARGET_API_MAC_CARBON - SDL_InitQuickDraw (&qd); + SDL_InitQuickDraw(&qd); #endif - if (readPreferences (&prefs)) { + if (readPreferences(&prefs)) { - if (SDL_memcmp (prefs.video_driver_name + 1, "DSp", 3) == 0) + if (SDL_memcmp(prefs.video_driver_name + 1, "DSp", 3) == 0) videodriver = 1; - else if (SDL_memcmp (prefs.video_driver_name + 1, "toolbox", 7) == 0) + else if (SDL_memcmp(prefs.video_driver_name + 1, "toolbox", 7) == 0) videodriver = 2; } - if (CommandKeyIsDown ()) { + if (CommandKeyIsDown()) { #define kCL_OK 1 #define kCL_Cancel 2 @@ -487,52 +487,52 @@ settingsChanged = 1; /* Create dialog and display it */ - commandDialog = GetNewDialog (1000, nil, (WindowPtr) - 1); + commandDialog = GetNewDialog(1000, nil, (WindowPtr) - 1); #if TARGET_API_MAC_CARBON - SetPort (GetDialogPort (commandDialog)); + SetPort(GetDialogPort(commandDialog)); #else - SetPort (commandDialog); + SetPort(commandDialog); #endif /* Setup controls */ #if TARGET_API_MAC_CARBON - GetDialogItemAsControl (commandDialog, kCL_File, &control); - SetControlValue (control, prefs.output_to_file); + GetDialogItemAsControl(commandDialog, kCL_File, &control); + SetControlValue(control, prefs.output_to_file); #else - GetDialogItem (commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect); /* MJS */ - SetControlValue ((ControlHandle) dummyHandle, prefs.output_to_file); + GetDialogItem(commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect); /* MJS */ + SetControlValue((ControlHandle) dummyHandle, prefs.output_to_file); #endif - GetDialogItem (commandDialog, kCL_Text, &dummyType, &dummyHandle, - &dummyRect); - SetDialogItemText (dummyHandle, prefs.command_line); + GetDialogItem(commandDialog, kCL_Text, &dummyType, &dummyHandle, + &dummyRect); + SetDialogItemText(dummyHandle, prefs.command_line); #if TARGET_API_MAC_CARBON - GetDialogItemAsControl (commandDialog, kCL_Video, &control); - SetControlValue (control, videodriver); + GetDialogItemAsControl(commandDialog, kCL_Video, &control); + SetControlValue(control, videodriver); #else - GetDialogItem (commandDialog, kCL_Video, &dummyType, &dummyHandle, - &dummyRect); - SetControlValue ((ControlRef) dummyHandle, videodriver); + GetDialogItem(commandDialog, kCL_Video, &dummyType, &dummyHandle, + &dummyRect); + SetControlValue((ControlRef) dummyHandle, videodriver); #endif - SetDialogDefaultItem (commandDialog, kCL_OK); - SetDialogCancelItem (commandDialog, kCL_Cancel); + SetDialogDefaultItem(commandDialog, kCL_OK); + SetDialogCancelItem(commandDialog, kCL_Cancel); do { - ModalDialog (nil, &itemHit); /* wait for user response */ + ModalDialog(nil, &itemHit); /* wait for user response */ /* Toggle command-line output checkbox */ if (itemHit == kCL_File) { #if TARGET_API_MAC_CARBON - GetDialogItemAsControl (commandDialog, kCL_File, &control); - SetControlValue (control, !GetControlValue (control)); + GetDialogItemAsControl(commandDialog, kCL_File, &control); + SetControlValue(control, !GetControlValue(control)); #else - GetDialogItem (commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect); /* MJS */ - SetControlValue ((ControlHandle) dummyHandle, - !GetControlValue ((ControlHandle) - dummyHandle)); + GetDialogItem(commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect); /* MJS */ + SetControlValue((ControlHandle) dummyHandle, + !GetControlValue((ControlHandle) + dummyHandle)); #endif } @@ -540,69 +540,68 @@ while (itemHit != kCL_OK && itemHit != kCL_Cancel); /* Get control values, even if they did not change */ - GetDialogItem (commandDialog, kCL_Text, &dummyType, &dummyHandle, &dummyRect); /* MJS */ - GetDialogItemText (dummyHandle, prefs.command_line); + GetDialogItem(commandDialog, kCL_Text, &dummyType, &dummyHandle, &dummyRect); /* MJS */ + GetDialogItemText(dummyHandle, prefs.command_line); #if TARGET_API_MAC_CARBON - GetDialogItemAsControl (commandDialog, kCL_File, &control); - prefs.output_to_file = GetControlValue (control); + GetDialogItemAsControl(commandDialog, kCL_File, &control); + prefs.output_to_file = GetControlValue(control); #else - GetDialogItem (commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect); /* MJS */ - prefs.output_to_file = GetControlValue ((ControlHandle) dummyHandle); + GetDialogItem(commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect); /* MJS */ + prefs.output_to_file = GetControlValue((ControlHandle) dummyHandle); #endif #if TARGET_API_MAC_CARBON - GetDialogItemAsControl (commandDialog, kCL_Video, &control); - videodriver = GetControlValue (control); + GetDialogItemAsControl(commandDialog, kCL_Video, &control); + videodriver = GetControlValue(control); #else - GetDialogItem (commandDialog, kCL_Video, &dummyType, &dummyHandle, - &dummyRect); - videodriver = GetControlValue ((ControlRef) dummyHandle); + GetDialogItem(commandDialog, kCL_Video, &dummyType, &dummyHandle, + &dummyRect); + videodriver = GetControlValue((ControlRef) dummyHandle); #endif - DisposeDialog (commandDialog); + DisposeDialog(commandDialog); if (itemHit == kCL_Cancel) { - exit (0); + exit(0); } } /* Set pseudo-environment variables for video driver, update prefs */ switch (videodriver) { case VIDEO_ID_DRAWSPROCKET: - SDL_putenv ("SDL_VIDEODRIVER=DSp"); - SDL_memcpy (prefs.video_driver_name, "\pDSp", 4); + SDL_putenv("SDL_VIDEODRIVER=DSp"); + SDL_memcpy(prefs.video_driver_name, "\pDSp", 4); break; case VIDEO_ID_TOOLBOX: - SDL_putenv ("SDL_VIDEODRIVER=toolbox"); - SDL_memcpy (prefs.video_driver_name, "\ptoolbox", 8); + SDL_putenv("SDL_VIDEODRIVER=toolbox"); + SDL_memcpy(prefs.video_driver_name, "\ptoolbox", 8); break; } #if !(defined(__APPLE__) && defined(__MACH__)) /* Redirect standard I/O to files */ if (prefs.output_to_file) { - freopen (STDOUT_FILE, "w", stdout); - freopen (STDERR_FILE, "w", stderr); + freopen(STDOUT_FILE, "w", stdout); + freopen(STDERR_FILE, "w", stderr); } else { - fclose (stdout); - fclose (stderr); + fclose(stdout); + fclose(stderr); } #endif if (settingsChanged) { /* Save the prefs, even if they might not have changed (but probably did) */ - if (!writePreferences (&prefs)) - fprintf (stderr, "WARNING: Could not save preferences!\n"); + if (!writePreferences(&prefs)) + fprintf(stderr, "WARNING: Could not save preferences!\n"); } #if !(defined(__APPLE__) && defined(__MACH__)) appNameText[0] = 0; - getCurrentAppName (appNameText); /* check for error here ? */ + getCurrentAppName(appNameText); /* check for error here ? */ - commandLine = - (char *) malloc (appNameText[0] + prefs.command_line[0] + 2); + commandLine = (char *) malloc(appNameText[0] + prefs.command_line[0] + 2); if (commandLine == NULL) { - exit (-1); + exit(-1); } /* Rather than rewrite ParseCommandLine method, let's replace */ @@ -613,33 +612,33 @@ appNameText[i] = '_'; /* Copy app name & full command text to command-line C-string */ - SDL_memcpy (commandLine, appNameText + 1, appNameText[0]); + SDL_memcpy(commandLine, appNameText + 1, appNameText[0]); commandLine[appNameText[0]] = ' '; - SDL_memcpy (commandLine + appNameText[0] + 1, prefs.command_line + 1, - prefs.command_line[0]); + SDL_memcpy(commandLine + appNameText[0] + 1, prefs.command_line + 1, + prefs.command_line[0]); commandLine[appNameText[0] + 1 + prefs.command_line[0]] = '\0'; /* Parse C-string into argv and argc */ - nargs = ParseCommandLine (commandLine, NULL); - args = (char **) malloc ((nargs + 1) * (sizeof *args)); + nargs = ParseCommandLine(commandLine, NULL); + args = (char **) malloc((nargs + 1) * (sizeof *args)); if (args == NULL) { - exit (-1); + exit(-1); } - ParseCommandLine (commandLine, args); + ParseCommandLine(commandLine, args); /* Run the main application code */ - SDL_main (nargs, args); - free (args); - free (commandLine); + SDL_main(nargs, args); + free(args); + free(commandLine); /* Remove useless stdout.txt and stderr.txt */ - cleanup_output (); + cleanup_output(); #else // defined(__APPLE__) && defined(__MACH__) - SDL_main (argc, argv); + SDL_main(argc, argv); #endif /* Exit cleanly, calling atexit() functions */ - exit (0); + exit(0); /* Never reached, but keeps the compiler quiet */ return (0); diff -r 1fddae038bc8 -r 4da1ee79c9af src/main/qtopia/SDL_qtopia_main.cc --- a/src/main/qtopia/SDL_qtopia_main.cc Mon May 29 03:53:21 2006 +0000 +++ b/src/main/qtopia/SDL_qtopia_main.cc Mon May 29 04:04:35 2006 +0000 @@ -17,40 +17,40 @@ // I'm guessing this will also clean up the taskbar in the Sharp version // of Qtopia. static inline void -cleanupQCop () +cleanupQCop() { - QString appname (qApp->argv ()[0]); - int slash = appname.findRev ("/"); + QString appname(qApp->argv()[0]); + int slash = appname.findRev("/"); if (slash != -1) { - appname = appname.mid (slash + 1); + appname = appname.mid(slash + 1); } QString cmd = - QPEApplication::qpeDir () + + QPEApplication::qpeDir() + "bin/qcop QPE/System 'closing(QString)' '" + appname + "'"; - system (cmd.latin1 ()); + system(cmd.latin1()); cmd = "/tmp/qcop-msg-" + appname; - unlink (cmd.latin1 ()); + unlink(cmd.latin1()); } static QPEApplication *app; #endif -extern int SDL_main (int argc, char *argv[]); +extern int SDL_main(int argc, char *argv[]); int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { #ifdef QWS // This initializes the Qtopia application. It needs to be done here // because it parses command line options. - app = new QPEApplication (argc, argv); + app = new QPEApplication(argc, argv); QWidget dummy; - app->showMainWidget (&dummy); - atexit (cleanupQCop); + app->showMainWidget(&dummy); + atexit(cleanupQCop); #endif // Exit here because if return is used, the application // doesn't seem to quit correctly. - exit (SDL_main (argc, argv)); + exit(SDL_main(argc, argv)); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/main/win32/SDL_win32_main.c --- a/src/main/win32/SDL_win32_main.c Mon May 29 03:53:21 2006 +0000 +++ b/src/main/win32/SDL_win32_main.c Mon May 29 04:04:35 2006 +0000 @@ -55,7 +55,7 @@ /* Parse a command line buffer into arguments */ static int -ParseCommandLine (char *cmdline, char **argv) +ParseCommandLine(char *cmdline, char **argv) { char *bufp; int argc; @@ -63,7 +63,7 @@ argc = 0; for (bufp = cmdline; *bufp;) { /* Skip leading whitespace */ - while (isspace (*bufp)) { + while (isspace(*bufp)) { ++bufp; } /* Skip over argument */ @@ -87,7 +87,7 @@ ++argc; } /* Skip over word */ - while (*bufp && !isspace (*bufp)) { + while (*bufp && !isspace(*bufp)) { ++bufp; } } @@ -106,35 +106,35 @@ /* Show an error message */ static void -ShowError (const char *title, const char *message) +ShowError(const char *title, const char *message) { /* If USE_MESSAGEBOX is defined, you need to link with user32.lib */ #ifdef USE_MESSAGEBOX - MessageBox (NULL, message, title, MB_ICONEXCLAMATION | MB_OK); + MessageBox(NULL, message, title, MB_ICONEXCLAMATION | MB_OK); #else - fprintf (stderr, "%s: %s\n", title, message); + fprintf(stderr, "%s: %s\n", title, message); #endif } /* Pop up an out of memory message, returns to Windows */ static BOOL -OutOfMemory (void) +OutOfMemory(void) { - ShowError ("Fatal Error", "Out of memory - aborting"); + ShowError("Fatal Error", "Out of memory - aborting"); return FALSE; } /* SDL_Quit() shouldn't be used with atexit() directly because calling conventions may differ... */ static void -cleanup (void) +cleanup(void) { - SDL_Quit (); + SDL_Quit(); } /* Remove the output files if there was no output written */ static void -cleanup_output (void) +cleanup_output(void) { #ifndef NO_STDIO_REDIRECT FILE *file; @@ -142,28 +142,28 @@ #endif /* Flush the output in case anything is queued */ - fclose (stdout); - fclose (stderr); + fclose(stdout); + fclose(stderr); #ifndef NO_STDIO_REDIRECT /* See if the files have any output in them */ if (stdoutPath[0]) { - file = fopen (stdoutPath, TEXT ("rb")); + file = fopen(stdoutPath, TEXT("rb")); if (file) { - empty = (fgetc (file) == EOF) ? 1 : 0; - fclose (file); + empty = (fgetc(file) == EOF) ? 1 : 0; + fclose(file); if (empty) { - remove (stdoutPath); + remove(stdoutPath); } } } if (stderrPath[0]) { - file = fopen (stderrPath, TEXT ("rb")); + file = fopen(stderrPath, TEXT("rb")); if (file) { - empty = (fgetc (file) == EOF) ? 1 : 0; - fclose (file); + empty = (fgetc(file) == EOF) ? 1 : 0; + fclose(file); if (empty) { - remove (stderrPath); + remove(stderrPath); } } } @@ -177,7 +177,7 @@ /* This is where execution begins [console apps] */ int -console_main (int argc, char *argv[]) +console_main(int argc, char *argv[]) { size_t n; char *bufp, *appname; @@ -185,44 +185,44 @@ /* Get the class name from argv[0] */ appname = argv[0]; - if ((bufp = SDL_strrchr (argv[0], '\\')) != NULL) { + if ((bufp = SDL_strrchr(argv[0], '\\')) != NULL) { appname = bufp + 1; - } else if ((bufp = SDL_strrchr (argv[0], '/')) != NULL) { + } else if ((bufp = SDL_strrchr(argv[0], '/')) != NULL) { appname = bufp + 1; } - if ((bufp = SDL_strrchr (appname, '.')) == NULL) - n = SDL_strlen (appname); + if ((bufp = SDL_strrchr(appname, '.')) == NULL) + n = SDL_strlen(appname); else n = (bufp - appname); - bufp = SDL_stack_alloc (char, n + 1); + bufp = SDL_stack_alloc(char, n + 1); if (bufp == NULL) { - return OutOfMemory (); + return OutOfMemory(); } - SDL_strlcpy (bufp, appname, n + 1); + SDL_strlcpy(bufp, appname, n + 1); appname = bufp; /* Load SDL dynamic link library */ - if (SDL_Init (SDL_INIT_NOPARACHUTE) < 0) { - ShowError ("WinMain() error", SDL_GetError ()); + if (SDL_Init(SDL_INIT_NOPARACHUTE) < 0) { + ShowError("WinMain() error", SDL_GetError()); return (FALSE); } - atexit (cleanup_output); - atexit (cleanup); + atexit(cleanup_output); + atexit(cleanup); /* Sam: We still need to pass in the application handle so that DirectInput will initialize properly when SDL_RegisterApp() is called later in the video initialization. */ - SDL_SetModuleHandle (GetModuleHandle (NULL)); + SDL_SetModuleHandle(GetModuleHandle(NULL)); /* Run the application main() code */ - status = SDL_main (argc, argv); + status = SDL_main(argc, argv); /* Exit cleanly, calling atexit() functions */ - exit (status); + exit(status); /* Hush little compiler, don't you cry... */ return 0; @@ -231,10 +231,10 @@ /* This is where execution begins [windowed apps] */ #ifdef _WIN32_WCE int WINAPI -WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPWSTR szCmdLine, int sw) +WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPWSTR szCmdLine, int sw) #else int WINAPI -WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) +WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) #endif { HINSTANCE handle; @@ -262,36 +262,35 @@ keep them open. This is a hack.. hopefully it will be fixed someday. DDHELP.EXE starts up the first time DDRAW.DLL is loaded. */ - handle = LoadLibrary (TEXT ("DDRAW.DLL")); + handle = LoadLibrary(TEXT("DDRAW.DLL")); if (handle != NULL) { - FreeLibrary (handle); + FreeLibrary(handle); } #ifndef NO_STDIO_REDIRECT - pathlen = GetModuleFileName (NULL, path, SDL_arraysize (path)); + pathlen = GetModuleFileName(NULL, path, SDL_arraysize(path)); while (pathlen > 0 && path[pathlen] != '\\') { --pathlen; } path[pathlen] = '\0'; #ifdef _WIN32_WCE - wcsncpy (stdoutPath, path, SDL_arraysize (stdoutPath)); - wcsncat (stdoutPath, DIR_SEPERATOR STDOUT_FILE, - SDL_arraysize (stdoutPath)); + wcsncpy(stdoutPath, path, SDL_arraysize(stdoutPath)); + wcsncat(stdoutPath, DIR_SEPERATOR STDOUT_FILE, SDL_arraysize(stdoutPath)); #else - SDL_strlcpy (stdoutPath, path, SDL_arraysize (stdoutPath)); - SDL_strlcat (stdoutPath, DIR_SEPERATOR STDOUT_FILE, - SDL_arraysize (stdoutPath)); + SDL_strlcpy(stdoutPath, path, SDL_arraysize(stdoutPath)); + SDL_strlcat(stdoutPath, DIR_SEPERATOR STDOUT_FILE, + SDL_arraysize(stdoutPath)); #endif /* Redirect standard input and standard output */ - newfp = freopen (stdoutPath, TEXT ("w"), stdout); + newfp = freopen(stdoutPath, TEXT("w"), stdout); #ifndef _WIN32_WCE if (newfp == NULL) { /* This happens on NT */ #if !defined(stdout) - stdout = fopen (stdoutPath, TEXT ("w")); + stdout = fopen(stdoutPath, TEXT("w")); #else - newfp = fopen (stdoutPath, TEXT ("w")); + newfp = fopen(stdoutPath, TEXT("w")); if (newfp) { *stdout = *newfp; } @@ -300,22 +299,21 @@ #endif /* _WIN32_WCE */ #ifdef _WIN32_WCE - wcsncpy (stderrPath, path, SDL_arraysize (stdoutPath)); - wcsncat (stderrPath, DIR_SEPERATOR STDOUT_FILE, - SDL_arraysize (stdoutPath)); + wcsncpy(stderrPath, path, SDL_arraysize(stdoutPath)); + wcsncat(stderrPath, DIR_SEPERATOR STDOUT_FILE, SDL_arraysize(stdoutPath)); #else - SDL_strlcpy (stderrPath, path, SDL_arraysize (stderrPath)); - SDL_strlcat (stderrPath, DIR_SEPERATOR STDERR_FILE, - SDL_arraysize (stderrPath)); + SDL_strlcpy(stderrPath, path, SDL_arraysize(stderrPath)); + SDL_strlcat(stderrPath, DIR_SEPERATOR STDERR_FILE, + SDL_arraysize(stderrPath)); #endif - newfp = freopen (stderrPath, TEXT ("w"), stderr); + newfp = freopen(stderrPath, TEXT("w"), stderr); #ifndef _WIN32_WCE if (newfp == NULL) { /* This happens on NT */ #if !defined(stderr) - stderr = fopen (stderrPath, TEXT ("w")); + stderr = fopen(stderrPath, TEXT("w")); #else - newfp = fopen (stderrPath, TEXT ("w")); + newfp = fopen(stderrPath, TEXT("w")); if (newfp) { *stderr = *newfp; } @@ -323,44 +321,44 @@ } #endif /* _WIN32_WCE */ - setvbuf (stdout, NULL, _IOLBF, BUFSIZ); /* Line buffered */ - setbuf (stderr, NULL); /* No buffering */ + setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* Line buffered */ + setbuf(stderr, NULL); /* No buffering */ #endif /* !NO_STDIO_REDIRECT */ #ifdef _WIN32_WCE - nLen = wcslen (szCmdLine) + 128 + 1; - bufp = SDL_stack_alloc (wchar_t, nLen * 2); - wcscpy (bufp, TEXT ("\"")); - GetModuleFileName (NULL, bufp + 1, 128 - 3); - wcscpy (bufp + wcslen (bufp), TEXT ("\" ")); - wcsncpy (bufp + wcslen (bufp), szCmdLine, nLen - wcslen (bufp)); - nLen = wcslen (bufp) + 1; - cmdline = SDL_stack_alloc (char, nLen); + nLen = wcslen(szCmdLine) + 128 + 1; + bufp = SDL_stack_alloc(wchar_t, nLen * 2); + wcscpy(bufp, TEXT("\"")); + GetModuleFileName(NULL, bufp + 1, 128 - 3); + wcscpy(bufp + wcslen(bufp), TEXT("\" ")); + wcsncpy(bufp + wcslen(bufp), szCmdLine, nLen - wcslen(bufp)); + nLen = wcslen(bufp) + 1; + cmdline = SDL_stack_alloc(char, nLen); if (cmdline == NULL) { - return OutOfMemory (); + return OutOfMemory(); } - WideCharToMultiByte (CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL); #else /* Grab the command line */ - bufp = GetCommandLine (); - nLen = SDL_strlen (bufp) + 1; - cmdline = SDL_stack_alloc (char, nLen); + bufp = GetCommandLine(); + nLen = SDL_strlen(bufp) + 1; + cmdline = SDL_stack_alloc(char, nLen); if (cmdline == NULL) { - return OutOfMemory (); + return OutOfMemory(); } - SDL_strlcpy (cmdline, bufp, nLen); + SDL_strlcpy(cmdline, bufp, nLen); #endif /* Parse it into argv and argc */ - argc = ParseCommandLine (cmdline, NULL); - argv = SDL_stack_alloc (char *, argc + 1); + argc = ParseCommandLine(cmdline, NULL); + argv = SDL_stack_alloc(char *, argc + 1); if (argv == NULL) { - return OutOfMemory (); + return OutOfMemory(); } - ParseCommandLine (cmdline, argv); + ParseCommandLine(cmdline, argv); /* Run the main program (after a little SDL initialization) */ - console_main (argc, argv); + console_main(argc, argv); /* Hush little compiler, don't you cry... */ return 0; diff -r 1fddae038bc8 -r 4da1ee79c9af src/stdlib/SDL_getenv.c --- a/src/stdlib/SDL_getenv.c Mon May 29 03:53:21 2006 +0000 +++ b/src/stdlib/SDL_getenv.c Mon May 29 04:04:35 2006 +0000 @@ -37,29 +37,29 @@ /* Put a variable of the form "name=value" into the environment */ int -SDL_putenv (const char *variable) +SDL_putenv(const char *variable) { size_t bufferlen; char *value; const char *sep; - sep = SDL_strchr (variable, '='); + sep = SDL_strchr(variable, '='); if (sep == NULL) { return -1; } - bufferlen = SDL_strlen (variable) + 1; + bufferlen = SDL_strlen(variable) + 1; if (bufferlen > SDL_envmemlen) { - char *newmem = (char *) SDL_realloc (SDL_envmem, bufferlen); + char *newmem = (char *) SDL_realloc(SDL_envmem, bufferlen); if (newmem == NULL) { return -1; } SDL_envmem = newmem; SDL_envmemlen = bufferlen; } - SDL_strlcpy (SDL_envmem, variable, bufferlen); + SDL_strlcpy(SDL_envmem, variable, bufferlen); value = SDL_envmem + (sep - variable); *value++ = '\0'; - if (!SetEnvironmentVariable (SDL_envmem, *value ? value : NULL)) { + if (!SetEnvironmentVariable(SDL_envmem, *value ? value : NULL)) { return -1; } return 0; @@ -67,23 +67,23 @@ /* Retrieve a variable named "name" from the environment */ char * -SDL_getenv (const char *name) +SDL_getenv(const char *name) { size_t bufferlen; bufferlen = - GetEnvironmentVariable (name, SDL_envmem, (DWORD) SDL_envmemlen); + GetEnvironmentVariable(name, SDL_envmem, (DWORD) SDL_envmemlen); if (bufferlen == 0) { return NULL; } if (bufferlen > SDL_envmemlen) { - char *newmem = (char *) SDL_realloc (SDL_envmem, bufferlen); + char *newmem = (char *) SDL_realloc(SDL_envmem, bufferlen); if (newmem == NULL) { return NULL; } SDL_envmem = newmem; SDL_envmemlen = bufferlen; - GetEnvironmentVariable (name, SDL_envmem, (DWORD) SDL_envmemlen); + GetEnvironmentVariable(name, SDL_envmem, (DWORD) SDL_envmemlen); } return SDL_envmem; } @@ -94,7 +94,7 @@ /* Put a variable of the form "name=value" into the environment */ int -SDL_putenv (const char *variable) +SDL_putenv(const char *variable) { const char *name, *value; int added; @@ -117,7 +117,7 @@ } /* Allocate memory for the variable */ - new_variable = SDL_strdup (variable); + new_variable = SDL_strdup(variable); if (!new_variable) { return (-1); } @@ -129,13 +129,13 @@ /* Check to see if it's already there... */ len = (value - name); for (; SDL_env[i]; ++i) { - if (SDL_strncmp (SDL_env[i], name, len) == 0) { + if (SDL_strncmp(SDL_env[i], name, len) == 0) { break; } } /* If we found it, just replace the entry */ if (SDL_env[i]) { - SDL_free (SDL_env[i]); + SDL_free(SDL_env[i]); SDL_env[i] = new_variable; added = 1; } @@ -143,14 +143,14 @@ /* Didn't find it in the environment, expand and add */ if (!added) { - new_env = SDL_realloc (SDL_env, (i + 2) * sizeof (char *)); + new_env = SDL_realloc(SDL_env, (i + 2) * sizeof(char *)); if (new_env) { SDL_env = new_env; SDL_env[i++] = new_variable; SDL_env[i++] = (char *) 0; added = 1; } else { - SDL_free (new_variable); + SDL_free(new_variable); } } return (added ? 0 : -1); @@ -158,16 +158,16 @@ /* Retrieve a variable named "name" from the environment */ char * -SDL_getenv (const char *name) +SDL_getenv(const char *name) { int len, i; char *value; value = (char *) 0; if (SDL_env) { - len = SDL_strlen (name); + len = SDL_strlen(name); for (i = 0; SDL_env[i] && !value; ++i) { - if ((SDL_strncmp (SDL_env[i], name, len) == 0) && + if ((SDL_strncmp(SDL_env[i], name, len) == 0) && (SDL_env[i][len] == '=')) { value = &SDL_env[i][len + 1]; } @@ -184,68 +184,68 @@ #include int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { char *value; - printf ("Checking for non-existent variable... "); - fflush (stdout); - if (!SDL_getenv ("EXISTS")) { - printf ("okay\n"); + printf("Checking for non-existent variable... "); + fflush(stdout); + if (!SDL_getenv("EXISTS")) { + printf("okay\n"); } else { - printf ("failed\n"); + printf("failed\n"); } - printf ("Setting FIRST=VALUE1 in the environment... "); - fflush (stdout); - if (SDL_putenv ("FIRST=VALUE1") == 0) { - printf ("okay\n"); + printf("Setting FIRST=VALUE1 in the environment... "); + fflush(stdout); + if (SDL_putenv("FIRST=VALUE1") == 0) { + printf("okay\n"); } else { - printf ("failed\n"); + printf("failed\n"); } - printf ("Getting FIRST from the environment... "); - fflush (stdout); - value = SDL_getenv ("FIRST"); - if (value && (SDL_strcmp (value, "VALUE1") == 0)) { - printf ("okay\n"); + printf("Getting FIRST from the environment... "); + fflush(stdout); + value = SDL_getenv("FIRST"); + if (value && (SDL_strcmp(value, "VALUE1") == 0)) { + printf("okay\n"); } else { - printf ("failed\n"); + printf("failed\n"); } - printf ("Setting SECOND=VALUE2 in the environment... "); - fflush (stdout); - if (SDL_putenv ("SECOND=VALUE2") == 0) { - printf ("okay\n"); + printf("Setting SECOND=VALUE2 in the environment... "); + fflush(stdout); + if (SDL_putenv("SECOND=VALUE2") == 0) { + printf("okay\n"); } else { - printf ("failed\n"); + printf("failed\n"); } - printf ("Getting SECOND from the environment... "); - fflush (stdout); - value = SDL_getenv ("SECOND"); - if (value && (SDL_strcmp (value, "VALUE2") == 0)) { - printf ("okay\n"); + printf("Getting SECOND from the environment... "); + fflush(stdout); + value = SDL_getenv("SECOND"); + if (value && (SDL_strcmp(value, "VALUE2") == 0)) { + printf("okay\n"); } else { - printf ("failed\n"); + printf("failed\n"); } - printf ("Setting FIRST=NOVALUE in the environment... "); - fflush (stdout); - if (SDL_putenv ("FIRST=NOVALUE") == 0) { - printf ("okay\n"); + printf("Setting FIRST=NOVALUE in the environment... "); + fflush(stdout); + if (SDL_putenv("FIRST=NOVALUE") == 0) { + printf("okay\n"); } else { - printf ("failed\n"); + printf("failed\n"); } - printf ("Getting FIRST from the environment... "); - fflush (stdout); - value = SDL_getenv ("FIRST"); - if (value && (SDL_strcmp (value, "NOVALUE") == 0)) { - printf ("okay\n"); + printf("Getting FIRST from the environment... "); + fflush(stdout); + value = SDL_getenv("FIRST"); + if (value && (SDL_strcmp(value, "NOVALUE") == 0)) { + printf("okay\n"); } else { - printf ("failed\n"); + printf("failed\n"); } - printf ("Checking for non-existent variable... "); - fflush (stdout); - if (!SDL_getenv ("EXISTS")) { - printf ("okay\n"); + printf("Checking for non-existent variable... "); + fflush(stdout); + if (!SDL_getenv("EXISTS")) { + printf("okay\n"); } else { - printf ("failed\n"); + printf("failed\n"); } return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af src/stdlib/SDL_iconv.c --- a/src/stdlib/SDL_iconv.c Mon May 29 03:53:21 2006 +0000 +++ b/src/stdlib/SDL_iconv.c Mon May 29 04:04:35 2006 +0000 @@ -31,11 +31,11 @@ #include size_t -SDL_iconv (SDL_iconv_t cd, - char **inbuf, size_t * inbytesleft, - char **outbuf, size_t * outbytesleft) +SDL_iconv(SDL_iconv_t cd, + char **inbuf, size_t * inbytesleft, + char **outbuf, size_t * outbytesleft) { - size_t retCode = iconv (cd, inbuf, inbytesleft, outbuf, outbytesleft); + size_t retCode = iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft); if (retCode == (size_t) - 1) { switch (errno) { case E2BIG: @@ -121,20 +121,20 @@ "UCS-4", ENCODING_UCS4},}; SDL_iconv_t -SDL_iconv_open (const char *tocode, const char *fromcode) +SDL_iconv_open(const char *tocode, const char *fromcode) { int src_fmt = ENCODING_UNKNOWN; int dst_fmt = ENCODING_UNKNOWN; int i; - for (i = 0; i < SDL_arraysize (encodings); ++i) { - if (SDL_strcasecmp (fromcode, encodings[i].name) == 0) { + for (i = 0; i < SDL_arraysize(encodings); ++i) { + if (SDL_strcasecmp(fromcode, encodings[i].name) == 0) { src_fmt = encodings[i].format; if (dst_fmt != ENCODING_UNKNOWN) { break; } } - if (SDL_strcasecmp (tocode, encodings[i].name) == 0) { + if (SDL_strcasecmp(tocode, encodings[i].name) == 0) { dst_fmt = encodings[i].format; if (src_fmt != ENCODING_UNKNOWN) { break; @@ -142,7 +142,7 @@ } } if (src_fmt != ENCODING_UNKNOWN && dst_fmt != ENCODING_UNKNOWN) { - SDL_iconv_t cd = (SDL_iconv_t) SDL_malloc (sizeof (*cd)); + SDL_iconv_t cd = (SDL_iconv_t) SDL_malloc(sizeof(*cd)); if (cd) { cd->src_fmt = src_fmt; cd->dst_fmt = dst_fmt; @@ -153,9 +153,9 @@ } size_t -SDL_iconv (SDL_iconv_t cd, - char **inbuf, size_t * inbytesleft, - char **outbuf, size_t * outbytesleft) +SDL_iconv(SDL_iconv_t cd, + char **inbuf, size_t * inbytesleft, + char **outbuf, size_t * outbytesleft) { /* For simplicity, we'll convert everything to and from UCS-4 */ char *src, *dst; @@ -744,10 +744,10 @@ } int -SDL_iconv_close (SDL_iconv_t cd) +SDL_iconv_close(SDL_iconv_t cd) { if (cd && cd != (SDL_iconv_t) - 1) { - SDL_free (cd); + SDL_free(cd); } return 0; } @@ -755,8 +755,8 @@ #endif /* !HAVE_ICONV */ char * -SDL_iconv_string (const char *tocode, const char *fromcode, char *inbuf, - size_t inbytesleft) +SDL_iconv_string(const char *tocode, const char *fromcode, char *inbuf, + size_t inbytesleft) { SDL_iconv_t cd; char *string; @@ -765,37 +765,36 @@ size_t outbytesleft; size_t retCode = 0; - cd = SDL_iconv_open (tocode, fromcode); + cd = SDL_iconv_open(tocode, fromcode); if (cd == (SDL_iconv_t) - 1) { return NULL; } stringsize = inbytesleft > 4 ? inbytesleft : 4; - string = SDL_malloc (stringsize); + string = SDL_malloc(stringsize); if (!string) { - SDL_iconv_close (cd); + SDL_iconv_close(cd); return NULL; } outbuf = string; outbytesleft = stringsize; - SDL_memset (outbuf, 0, 4); + SDL_memset(outbuf, 0, 4); while (inbytesleft > 0) { - retCode = - SDL_iconv (cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); + retCode = SDL_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); switch (retCode) { case SDL_ICONV_E2BIG: { char *oldstring = string; stringsize *= 2; - string = SDL_realloc (string, stringsize); + string = SDL_realloc(string, stringsize); if (!string) { - SDL_iconv_close (cd); + SDL_iconv_close(cd); return NULL; } outbuf = string + (outbuf - oldstring); outbytesleft = stringsize - (outbuf - string); - SDL_memset (outbuf, 0, 4); + SDL_memset(outbuf, 0, 4); } break; case SDL_ICONV_EILSEQ: @@ -810,7 +809,7 @@ break; } } - SDL_iconv_close (cd); + SDL_iconv_close(cd); return string; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/stdlib/SDL_malloc.c --- a/src/stdlib/SDL_malloc.c Mon May 29 03:53:21 2006 +0000 +++ b/src/stdlib/SDL_malloc.c Mon May 29 04:04:35 2006 +0000 @@ -718,7 +718,7 @@ maximum supported value of n differs across systems, but is in all cases less than the maximum representable value of a size_t. */ - void *dlmalloc (size_t); + void *dlmalloc(size_t); /* free(void* p) @@ -727,14 +727,14 @@ It has no effect if p is null. If p was not malloced or already freed, free(p) will by default cause the current program to abort. */ - void dlfree (void *); + void dlfree(void *); /* calloc(size_t n_elements, size_t element_size); Returns a pointer to n_elements * element_size bytes, with all locations set to zero. */ - void *dlcalloc (size_t, size_t); + void *dlcalloc(size_t, size_t); /* realloc(void* p, size_t n) @@ -759,7 +759,7 @@ to be used as an argument to realloc is not supported. */ - void *dlrealloc (void *, size_t); + void *dlrealloc(void *, size_t); /* memalign(size_t alignment, size_t n); @@ -773,14 +773,14 @@ Overreliance on memalign is a sure way to fragment space. */ - void *dlmemalign (size_t, size_t); + void *dlmemalign(size_t, size_t); /* valloc(size_t n); Equivalent to memalign(pagesize, n), where pagesize is the page size of the system. If the pagesize is unknown, 4096 is used. */ - void *dlvalloc (size_t); + void *dlvalloc(size_t); /* mallopt(int parameter_number, int parameter_value) @@ -800,7 +800,7 @@ M_GRANULARITY -2 page size any power of 2 >= page size M_MMAP_THRESHOLD -3 256*1024 any (or 0 if no MMAP support) */ - int dlmallopt (int, int); + int dlmallopt(int, int); /* malloc_footprint(); @@ -811,7 +811,7 @@ Even if locks are otherwise defined, this function does not use them, so results might not be up to date. */ - size_t dlmalloc_footprint (void); + size_t dlmalloc_footprint(void); /* malloc_max_footprint(); @@ -824,7 +824,7 @@ otherwise defined, this function does not use them, so results might not be up to date. */ - size_t dlmalloc_max_footprint (void); + size_t dlmalloc_max_footprint(void); #if !NO_MALLINFO /* @@ -849,7 +849,7 @@ be kept as longs, the reported values may wrap around zero and thus be inaccurate. */ - struct mallinfo dlmallinfo (void); + struct mallinfo dlmallinfo(void); #endif /* NO_MALLINFO */ /* @@ -904,7 +904,7 @@ return first; } */ - void **dlindependent_calloc (size_t, size_t, void **); + void **dlindependent_calloc(size_t, size_t, void **); /* independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]); @@ -965,7 +965,7 @@ since it cannot reuse existing noncontiguous small chunks that might be available for some of the elements. */ - void **dlindependent_comalloc (size_t, size_t *, void **); + void **dlindependent_comalloc(size_t, size_t *, void **); /* @@ -973,7 +973,7 @@ Equivalent to valloc(minimum-page-that-holds(n)), that is, round up n to nearest pagesize. */ - void *dlpvalloc (size_t); + void *dlpvalloc(size_t); /* malloc_trim(size_t pad); @@ -996,7 +996,7 @@ Malloc_trim returns 1 if it actually released any memory, else 0. */ - int dlmalloc_trim (size_t); + int dlmalloc_trim(size_t); /* malloc_usable_size(void* p); @@ -1012,7 +1012,7 @@ p = malloc(n); assert(malloc_usable_size(p) >= 256); */ - size_t dlmalloc_usable_size (void *); + size_t dlmalloc_usable_size(void *); /* malloc_stats(); @@ -1033,7 +1033,7 @@ malloc_stats prints only the most commonly interesting statistics. More information can be obtained by calling mallinfo. */ - void dlmalloc_stats (void); + void dlmalloc_stats(void); #endif /* ONLY_MSPACES */ @@ -1056,7 +1056,7 @@ compiling with a different DEFAULT_GRANULARITY or dynamically setting with mallopt(M_GRANULARITY, value). */ - mspace create_mspace (size_t capacity, int locked); + mspace create_mspace(size_t capacity, int locked); /* destroy_mspace destroys the given space, and attempts to return all @@ -1064,7 +1064,7 @@ bytes freed. After destruction, the results of access to all memory used by the space become undefined. */ - size_t destroy_mspace (mspace msp); + size_t destroy_mspace(mspace msp); /* create_mspace_with_base uses the memory supplied as the initial base @@ -1075,13 +1075,13 @@ Destroying this space will deallocate all additionally allocated space (if possible) but not the initial base. */ - mspace create_mspace_with_base (void *base, size_t capacity, int locked); + mspace create_mspace_with_base(void *base, size_t capacity, int locked); /* mspace_malloc behaves as malloc, but operates within the given space. */ - void *mspace_malloc (mspace msp, size_t bytes); + void *mspace_malloc(mspace msp, size_t bytes); /* mspace_free behaves as free, but operates within @@ -1091,7 +1091,7 @@ free may be called instead of mspace_free because freed chunks from any space are handled by their originating spaces. */ - void mspace_free (mspace msp, void *mem); + void mspace_free(mspace msp, void *mem); /* mspace_realloc behaves as realloc, but operates within @@ -1102,45 +1102,45 @@ realloced chunks from any space are handled by their originating spaces. */ - void *mspace_realloc (mspace msp, void *mem, size_t newsize); + void *mspace_realloc(mspace msp, void *mem, size_t newsize); /* mspace_calloc behaves as calloc, but operates within the given space. */ - void *mspace_calloc (mspace msp, size_t n_elements, size_t elem_size); + void *mspace_calloc(mspace msp, size_t n_elements, size_t elem_size); /* mspace_memalign behaves as memalign, but operates within the given space. */ - void *mspace_memalign (mspace msp, size_t alignment, size_t bytes); + void *mspace_memalign(mspace msp, size_t alignment, size_t bytes); /* mspace_independent_calloc behaves as independent_calloc, but operates within the given space. */ - void **mspace_independent_calloc (mspace msp, size_t n_elements, - size_t elem_size, void *chunks[]); + void **mspace_independent_calloc(mspace msp, size_t n_elements, + size_t elem_size, void *chunks[]); /* mspace_independent_comalloc behaves as independent_comalloc, but operates within the given space. */ - void **mspace_independent_comalloc (mspace msp, size_t n_elements, - size_t sizes[], void *chunks[]); + void **mspace_independent_comalloc(mspace msp, size_t n_elements, + size_t sizes[], void *chunks[]); /* mspace_footprint() returns the number of bytes obtained from the system for this space. */ - size_t mspace_footprint (mspace msp); + size_t mspace_footprint(mspace msp); /* mspace_max_footprint() returns the peak number of bytes obtained from the system for this space. */ - size_t mspace_max_footprint (mspace msp); + size_t mspace_max_footprint(mspace msp); #if !NO_MALLINFO @@ -1148,25 +1148,25 @@ mspace_mallinfo behaves as mallinfo, but reports properties of the given space. */ - struct mallinfo mspace_mallinfo (mspace msp); + struct mallinfo mspace_mallinfo(mspace msp); #endif /* NO_MALLINFO */ /* mspace_malloc_stats behaves as malloc_stats, but reports properties of the given space. */ - void mspace_malloc_stats (mspace msp); + void mspace_malloc_stats(mspace msp); /* mspace_trim behaves as malloc_trim, but operates within the given space. */ - int mspace_trim (mspace msp, size_t pad); + int mspace_trim(mspace msp, size_t pad); /* An alias for mallopt. */ - int mspace_mallopt (int, int); + int mspace_mallopt(int, int); #endif /* MSPACES */ @@ -1233,7 +1233,7 @@ #include /* for sbrk */ #else /* LACKS_UNISTD_H */ #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) -extern void *sbrk (ptrdiff_t); +extern void *sbrk(ptrdiff_t); #endif /* FreeBSD etc */ #endif /* LACKS_UNISTD_H */ #endif /* HAVE_MMAP */ @@ -1249,7 +1249,7 @@ # define malloc_getpagesize sysconf(_SC_PAGE_SIZE) # else # if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) -extern size_t getpagesize (); +extern size_t getpagesize(); # define malloc_getpagesize getpagesize() # else # ifdef WIN32 /* use supplied emulation of getpagesize */ @@ -1363,36 +1363,35 @@ /* Win32 MMAP via VirtualAlloc */ static void * -win32mmap (size_t size) +win32mmap(size_t size) { void *ptr = - VirtualAlloc (0, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + VirtualAlloc(0, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); return (ptr != 0) ? ptr : MFAIL; } /* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ static void * -win32direct_mmap (size_t size) +win32direct_mmap(size_t size) { - void *ptr = - VirtualAlloc (0, size, MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, - PAGE_READWRITE); + void *ptr = VirtualAlloc(0, size, MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, + PAGE_READWRITE); return (ptr != 0) ? ptr : MFAIL; } /* This function supports releasing coalesed segments */ static int -win32munmap (void *ptr, size_t size) +win32munmap(void *ptr, size_t size) { MEMORY_BASIC_INFORMATION minfo; char *cptr = ptr; while (size) { - if (VirtualQuery (cptr, &minfo, sizeof (minfo)) == 0) + if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) return -1; if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || minfo.State != MEM_COMMIT || minfo.RegionSize > size) return -1; - if (VirtualFree (cptr, 0, MEM_RELEASE) == 0) + if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) return -1; cptr += minfo.RegionSize; size -= minfo.RegionSize; @@ -1465,25 +1464,24 @@ #define MLOCK_T long static int -win32_acquire_lock (MLOCK_T * sl) +win32_acquire_lock(MLOCK_T * sl) { for (;;) { #ifdef InterlockedCompareExchangePointer - if (!InterlockedCompareExchange (sl, 1, 0)) + if (!InterlockedCompareExchange(sl, 1, 0)) return 0; #else /* Use older void* version */ - if (!InterlockedCompareExchange - ((void **) sl, (void *) 1, (void *) 0)) + if (!InterlockedCompareExchange((void **) sl, (void *) 1, (void *) 0)) return 0; #endif /* InterlockedCompareExchangePointer */ - Sleep (0); + Sleep(0); } } static void -win32_release_lock (MLOCK_T * sl) +win32_release_lock(MLOCK_T * sl) { - InterlockedExchange (sl, 0); + InterlockedExchange(sl, 0); } #define INITIAL_LOCK(l) *(l)=0 @@ -2126,7 +2124,7 @@ /* Return segment holding given address */ static msegmentptr -segment_holding (mstate m, char *addr) +segment_holding(mstate m, char *addr) { msegmentptr sp = &m->seg; for (;;) { @@ -2139,7 +2137,7 @@ /* Return true if segment contains a segment link */ static int -has_segment_link (mstate m, msegmentptr ss) +has_segment_link(mstate m, msegmentptr ss) { msegmentptr sp = &m->seg; for (;;) { @@ -2206,7 +2204,7 @@ int malloc_corruption_error_count; /* default corruption action */ -static void reset_on_error (mstate m); +static void reset_on_error(mstate m); #define CORRUPTION_ERROR_ACTION(m) reset_on_error(m) #define USAGE_ERROR_ACTION(m, p) @@ -2242,18 +2240,18 @@ #define check_mmapped_chunk(M,P) do_check_mmapped_chunk(M,P) #define check_malloc_state(M) do_check_malloc_state(M) -static void do_check_any_chunk (mstate m, mchunkptr p); -static void do_check_top_chunk (mstate m, mchunkptr p); -static void do_check_mmapped_chunk (mstate m, mchunkptr p); -static void do_check_inuse_chunk (mstate m, mchunkptr p); -static void do_check_free_chunk (mstate m, mchunkptr p); -static void do_check_malloced_chunk (mstate m, void *mem, size_t s); -static void do_check_tree (mstate m, tchunkptr t); -static void do_check_treebin (mstate m, bindex_t i); -static void do_check_smallbin (mstate m, bindex_t i); -static void do_check_malloc_state (mstate m); -static int bin_find (mstate m, mchunkptr x); -static size_t traverse_and_check (mstate m); +static void do_check_any_chunk(mstate m, mchunkptr p); +static void do_check_top_chunk(mstate m, mchunkptr p); +static void do_check_mmapped_chunk(mstate m, mchunkptr p); +static void do_check_inuse_chunk(mstate m, mchunkptr p); +static void do_check_free_chunk(mstate m, mchunkptr p); +static void do_check_malloced_chunk(mstate m, void *mem, size_t s); +static void do_check_tree(mstate m, tchunkptr t); +static void do_check_treebin(mstate m, bindex_t i); +static void do_check_smallbin(mstate m, bindex_t i); +static void do_check_malloc_state(mstate m); +static int bin_find(mstate m, mchunkptr x); +static size_t traverse_and_check(mstate m); #endif /* DEBUG */ /* ---------------------------- Indexing Bins ---------------------------- */ @@ -2484,7 +2482,7 @@ /* Initialize mparams */ static int -init_mparams (void) +init_mparams(void) { if (mparams.page_size == 0) { size_t s; @@ -2502,15 +2500,15 @@ { #if USE_DEV_RANDOM int fd; - unsigned char buf[sizeof (size_t)]; + unsigned char buf[sizeof(size_t)]; /* Try to use /dev/urandom, else fall back on using time */ - if ((fd = open ("/dev/urandom", O_RDONLY)) >= 0 && - read (fd, buf, sizeof (buf)) == sizeof (buf)) { + if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 && + read(fd, buf, sizeof(buf)) == sizeof(buf)) { s = *((size_t *) buf); - close (fd); + close(fd); } else #endif /* USE_DEV_RANDOM */ - s = (size_t) (time (0) ^ (size_t) 0x55555555U); + s = (size_t) (time(0) ^ (size_t) 0x55555555U); s |= (size_t) 8U; /* ensure nonzero */ s &= ~(size_t) 7U; /* improve chances of fault for bad values */ @@ -2519,14 +2517,14 @@ #else /* (FOOTERS && !INSECURE) */ s = (size_t) 0x58585858U; #endif /* (FOOTERS && !INSECURE) */ - ACQUIRE_MAGIC_INIT_LOCK (); + ACQUIRE_MAGIC_INIT_LOCK(); if (mparams.magic == 0) { mparams.magic = s; /* Set up lock for main malloc area */ - INITIAL_LOCK (&gm->mutex); + INITIAL_LOCK(&gm->mutex); gm->mflags = mparams.default_mflags; } - RELEASE_MAGIC_INIT_LOCK (); + RELEASE_MAGIC_INIT_LOCK(); #ifndef WIN32 mparams.page_size = malloc_getpagesize; @@ -2535,7 +2533,7 @@ #else /* WIN32 */ { SYSTEM_INFO system_info; - GetSystemInfo (&system_info); + GetSystemInfo(&system_info); mparams.page_size = system_info.dwPageSize; mparams.granularity = system_info.dwAllocationGranularity; } @@ -2547,9 +2545,9 @@ alignment must be at least 8. Alignment, min chunk size, and page size must all be powers of 2. */ - if ((sizeof (size_t) != sizeof (char *)) || + if ((sizeof(size_t) != sizeof(char *)) || (MAX_SIZE_T < MIN_CHUNK_SIZE) || - (sizeof (int) < 4) || + (sizeof(int) < 4) || (MALLOC_ALIGNMENT < (size_t) 8U) || ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT - SIZE_T_ONE)) != 0) || ((MCHUNK_SIZE & (MCHUNK_SIZE - SIZE_T_ONE)) != 0) || @@ -2562,10 +2560,10 @@ /* support for mallopt */ static int -change_mparam (int param_number, int value) +change_mparam(int param_number, int value) { size_t val = (size_t) value; - init_mparams (); + init_mparams(); switch (param_number) { case M_TRIM_THRESHOLD: mparams.trim_threshold = val; @@ -2589,199 +2587,199 @@ /* Check properties of any chunk, whether free, inuse, mmapped etc */ static void -do_check_any_chunk (mstate m, mchunkptr p) +do_check_any_chunk(mstate m, mchunkptr p) { - assert ((is_aligned (chunk2mem (p))) || (p->head == FENCEPOST_HEAD)); - assert (ok_address (m, p)); + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); } /* Check properties of top chunk */ static void -do_check_top_chunk (mstate m, mchunkptr p) +do_check_top_chunk(mstate m, mchunkptr p) { - msegmentptr sp = segment_holding (m, (char *) p); - size_t sz = chunksize (p); - assert (sp != 0); - assert ((is_aligned (chunk2mem (p))) || (p->head == FENCEPOST_HEAD)); - assert (ok_address (m, p)); - assert (sz == m->topsize); - assert (sz > 0); - assert (sz == ((sp->base + sp->size) - (char *) p) - TOP_FOOT_SIZE); - assert (pinuse (p)); - assert (!next_pinuse (p)); + msegmentptr sp = segment_holding(m, (char *) p); + size_t sz = chunksize(p); + assert(sp != 0); + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); + assert(sz == m->topsize); + assert(sz > 0); + assert(sz == ((sp->base + sp->size) - (char *) p) - TOP_FOOT_SIZE); + assert(pinuse(p)); + assert(!next_pinuse(p)); } /* Check properties of (inuse) mmapped chunks */ static void -do_check_mmapped_chunk (mstate m, mchunkptr p) +do_check_mmapped_chunk(mstate m, mchunkptr p) { - size_t sz = chunksize (p); + size_t sz = chunksize(p); size_t len = (sz + (p->prev_foot & ~IS_MMAPPED_BIT) + MMAP_FOOT_PAD); - assert (is_mmapped (p)); - assert (use_mmap (m)); - assert ((is_aligned (chunk2mem (p))) || (p->head == FENCEPOST_HEAD)); - assert (ok_address (m, p)); - assert (!is_small (sz)); - assert ((len & (mparams.page_size - SIZE_T_ONE)) == 0); - assert (chunk_plus_offset (p, sz)->head == FENCEPOST_HEAD); - assert (chunk_plus_offset (p, sz + SIZE_T_SIZE)->head == 0); + assert(is_mmapped(p)); + assert(use_mmap(m)); + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); + assert(!is_small(sz)); + assert((len & (mparams.page_size - SIZE_T_ONE)) == 0); + assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD); + assert(chunk_plus_offset(p, sz + SIZE_T_SIZE)->head == 0); } /* Check properties of inuse chunks */ static void -do_check_inuse_chunk (mstate m, mchunkptr p) +do_check_inuse_chunk(mstate m, mchunkptr p) { - do_check_any_chunk (m, p); - assert (cinuse (p)); - assert (next_pinuse (p)); + do_check_any_chunk(m, p); + assert(cinuse(p)); + assert(next_pinuse(p)); /* If not pinuse and not mmapped, previous chunk has OK offset */ - assert (is_mmapped (p) || pinuse (p) || next_chunk (prev_chunk (p)) == p); - if (is_mmapped (p)) - do_check_mmapped_chunk (m, p); + assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p); + if (is_mmapped(p)) + do_check_mmapped_chunk(m, p); } /* Check properties of free chunks */ static void -do_check_free_chunk (mstate m, mchunkptr p) +do_check_free_chunk(mstate m, mchunkptr p) { size_t sz = p->head & ~(PINUSE_BIT | CINUSE_BIT); - mchunkptr next = chunk_plus_offset (p, sz); - do_check_any_chunk (m, p); - assert (!cinuse (p)); - assert (!next_pinuse (p)); - assert (!is_mmapped (p)); + mchunkptr next = chunk_plus_offset(p, sz); + do_check_any_chunk(m, p); + assert(!cinuse(p)); + assert(!next_pinuse(p)); + assert(!is_mmapped(p)); if (p != m->dv && p != m->top) { if (sz >= MIN_CHUNK_SIZE) { - assert ((sz & CHUNK_ALIGN_MASK) == 0); - assert (is_aligned (chunk2mem (p))); - assert (next->prev_foot == sz); - assert (pinuse (p)); - assert (next == m->top || cinuse (next)); - assert (p->fd->bk == p); - assert (p->bk->fd == p); + assert((sz & CHUNK_ALIGN_MASK) == 0); + assert(is_aligned(chunk2mem(p))); + assert(next->prev_foot == sz); + assert(pinuse(p)); + assert(next == m->top || cinuse(next)); + assert(p->fd->bk == p); + assert(p->bk->fd == p); } else /* markers are always of size SIZE_T_SIZE */ - assert (sz == SIZE_T_SIZE); + assert(sz == SIZE_T_SIZE); } } /* Check properties of malloced chunks at the point they are malloced */ static void -do_check_malloced_chunk (mstate m, void *mem, size_t s) +do_check_malloced_chunk(mstate m, void *mem, size_t s) { if (mem != 0) { - mchunkptr p = mem2chunk (mem); + mchunkptr p = mem2chunk(mem); size_t sz = p->head & ~(PINUSE_BIT | CINUSE_BIT); - do_check_inuse_chunk (m, p); - assert ((sz & CHUNK_ALIGN_MASK) == 0); - assert (sz >= MIN_CHUNK_SIZE); - assert (sz >= s); + do_check_inuse_chunk(m, p); + assert((sz & CHUNK_ALIGN_MASK) == 0); + assert(sz >= MIN_CHUNK_SIZE); + assert(sz >= s); /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */ - assert (is_mmapped (p) || sz < (s + MIN_CHUNK_SIZE)); + assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE)); } } /* Check a tree and its subtrees. */ static void -do_check_tree (mstate m, tchunkptr t) +do_check_tree(mstate m, tchunkptr t) { tchunkptr head = 0; tchunkptr u = t; bindex_t tindex = t->index; - size_t tsize = chunksize (t); + size_t tsize = chunksize(t); bindex_t idx; - compute_tree_index (tsize, idx); - assert (tindex == idx); - assert (tsize >= MIN_LARGE_SIZE); - assert (tsize >= minsize_for_tree_index (idx)); - assert ((idx == NTREEBINS - 1) - || (tsize < minsize_for_tree_index ((idx + 1)))); + compute_tree_index(tsize, idx); + assert(tindex == idx); + assert(tsize >= MIN_LARGE_SIZE); + assert(tsize >= minsize_for_tree_index(idx)); + assert((idx == NTREEBINS - 1) + || (tsize < minsize_for_tree_index((idx + 1)))); do { /* traverse through chain of same-sized nodes */ - do_check_any_chunk (m, ((mchunkptr) u)); - assert (u->index == tindex); - assert (chunksize (u) == tsize); - assert (!cinuse (u)); - assert (!next_pinuse (u)); - assert (u->fd->bk == u); - assert (u->bk->fd == u); + do_check_any_chunk(m, ((mchunkptr) u)); + assert(u->index == tindex); + assert(chunksize(u) == tsize); + assert(!cinuse(u)); + assert(!next_pinuse(u)); + assert(u->fd->bk == u); + assert(u->bk->fd == u); if (u->parent == 0) { - assert (u->child[0] == 0); - assert (u->child[1] == 0); + assert(u->child[0] == 0); + assert(u->child[1] == 0); } else { - assert (head == 0); /* only one node on chain has parent */ + assert(head == 0); /* only one node on chain has parent */ head = u; - assert (u->parent != u); - assert (u->parent->child[0] == u || - u->parent->child[1] == u || - *((tbinptr *) (u->parent)) == u); + assert(u->parent != u); + assert(u->parent->child[0] == u || + u->parent->child[1] == u || + *((tbinptr *) (u->parent)) == u); if (u->child[0] != 0) { - assert (u->child[0]->parent == u); - assert (u->child[0] != u); - do_check_tree (m, u->child[0]); + assert(u->child[0]->parent == u); + assert(u->child[0] != u); + do_check_tree(m, u->child[0]); } if (u->child[1] != 0) { - assert (u->child[1]->parent == u); - assert (u->child[1] != u); - do_check_tree (m, u->child[1]); + assert(u->child[1]->parent == u); + assert(u->child[1] != u); + do_check_tree(m, u->child[1]); } if (u->child[0] != 0 && u->child[1] != 0) { - assert (chunksize (u->child[0]) < chunksize (u->child[1])); + assert(chunksize(u->child[0]) < chunksize(u->child[1])); } } u = u->fd; } while (u != t); - assert (head != 0); + assert(head != 0); } /* Check all the chunks in a treebin. */ static void -do_check_treebin (mstate m, bindex_t i) +do_check_treebin(mstate m, bindex_t i) { - tbinptr *tb = treebin_at (m, i); + tbinptr *tb = treebin_at(m, i); tchunkptr t = *tb; int empty = (m->treemap & (1U << i)) == 0; if (t == 0) - assert (empty); + assert(empty); if (!empty) - do_check_tree (m, t); + do_check_tree(m, t); } /* Check all the chunks in a smallbin. */ static void -do_check_smallbin (mstate m, bindex_t i) +do_check_smallbin(mstate m, bindex_t i) { - sbinptr b = smallbin_at (m, i); + sbinptr b = smallbin_at(m, i); mchunkptr p = b->bk; unsigned int empty = (m->smallmap & (1U << i)) == 0; if (p == b) - assert (empty); + assert(empty); if (!empty) { for (; p != b; p = p->bk) { - size_t size = chunksize (p); + size_t size = chunksize(p); mchunkptr q; /* each chunk claims to be free */ - do_check_free_chunk (m, p); + do_check_free_chunk(m, p); /* chunk belongs in bin */ - assert (small_index (size) == i); - assert (p->bk == b || chunksize (p->bk) == chunksize (p)); + assert(small_index(size) == i); + assert(p->bk == b || chunksize(p->bk) == chunksize(p)); /* chunk is followed by an inuse chunk */ - q = next_chunk (p); + q = next_chunk(p); if (q->head != FENCEPOST_HEAD) - do_check_inuse_chunk (m, q); + do_check_inuse_chunk(m, q); } } } /* Find x in a bin. Used in other check functions. */ static int -bin_find (mstate m, mchunkptr x) +bin_find(mstate m, mchunkptr x) { - size_t size = chunksize (x); - if (is_small (size)) { - bindex_t sidx = small_index (size); - sbinptr b = smallbin_at (m, sidx); - if (smallmap_is_marked (m, sidx)) { + size_t size = chunksize(x); + if (is_small(size)) { + bindex_t sidx = small_index(size); + sbinptr b = smallbin_at(m, sidx); + if (smallmap_is_marked(m, sidx)) { mchunkptr p = b; do { if (p == x) @@ -2791,11 +2789,11 @@ } } else { bindex_t tidx; - compute_tree_index (size, tidx); - if (treemap_is_marked (m, tidx)) { - tchunkptr t = *treebin_at (m, tidx); - size_t sizebits = size << leftshift_for_tree_index (tidx); - while (t != 0 && chunksize (t) != size) { + compute_tree_index(size, tidx); + if (treemap_is_marked(m, tidx)) { + tchunkptr t = *treebin_at(m, tidx); + size_t sizebits = size << leftshift_for_tree_index(tidx); + while (t != 0 && chunksize(t) != size) { t = t->child[(sizebits >> (SIZE_T_BITSIZE - SIZE_T_ONE)) & 1]; sizebits <<= 1; } @@ -2814,29 +2812,29 @@ /* Traverse each chunk and check it; return total */ static size_t -traverse_and_check (mstate m) +traverse_and_check(mstate m) { size_t sum = 0; - if (is_initialized (m)) { + if (is_initialized(m)) { msegmentptr s = &m->seg; sum += m->topsize + TOP_FOOT_SIZE; while (s != 0) { - mchunkptr q = align_as_chunk (s->base); + mchunkptr q = align_as_chunk(s->base); mchunkptr lastq = 0; - assert (pinuse (q)); - while (segment_holds (s, q) && + assert(pinuse(q)); + while (segment_holds(s, q) && q != m->top && q->head != FENCEPOST_HEAD) { - sum += chunksize (q); - if (cinuse (q)) { - assert (!bin_find (m, q)); - do_check_inuse_chunk (m, q); + sum += chunksize(q); + if (cinuse(q)) { + assert(!bin_find(m, q)); + do_check_inuse_chunk(m, q); } else { - assert (q == m->dv || bin_find (m, q)); - assert (lastq == 0 || cinuse (lastq)); /* Not 2 consecutive free */ - do_check_free_chunk (m, q); + assert(q == m->dv || bin_find(m, q)); + assert(lastq == 0 || cinuse(lastq)); /* Not 2 consecutive free */ + do_check_free_chunk(m, q); } lastq = q; - q = next_chunk (q); + q = next_chunk(q); } s = s->next; } @@ -2846,33 +2844,33 @@ /* Check all properties of malloc_state. */ static void -do_check_malloc_state (mstate m) +do_check_malloc_state(mstate m) { bindex_t i; size_t total; /* check bins */ for (i = 0; i < NSMALLBINS; ++i) - do_check_smallbin (m, i); + do_check_smallbin(m, i); for (i = 0; i < NTREEBINS; ++i) - do_check_treebin (m, i); + do_check_treebin(m, i); if (m->dvsize != 0) { /* check dv chunk */ - do_check_any_chunk (m, m->dv); - assert (m->dvsize == chunksize (m->dv)); - assert (m->dvsize >= MIN_CHUNK_SIZE); - assert (bin_find (m, m->dv) == 0); + do_check_any_chunk(m, m->dv); + assert(m->dvsize == chunksize(m->dv)); + assert(m->dvsize >= MIN_CHUNK_SIZE); + assert(bin_find(m, m->dv) == 0); } if (m->top != 0) { /* check top chunk */ - do_check_top_chunk (m, m->top); - assert (m->topsize == chunksize (m->top)); - assert (m->topsize > 0); - assert (bin_find (m, m->top) == 0); + do_check_top_chunk(m, m->top); + assert(m->topsize == chunksize(m->top)); + assert(m->topsize > 0); + assert(bin_find(m, m->top) == 0); } - total = traverse_and_check (m); - assert (total <= m->footprint); - assert (m->footprint <= m->max_footprint); + total = traverse_and_check(m); + assert(total <= m->footprint); + assert(m->footprint <= m->max_footprint); } #endif /* DEBUG */ @@ -2880,27 +2878,27 @@ #if !NO_MALLINFO static struct mallinfo -internal_mallinfo (mstate m) +internal_mallinfo(mstate m) { struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - if (!PREACTION (m)) { - check_malloc_state (m); - if (is_initialized (m)) { + if (!PREACTION(m)) { + check_malloc_state(m); + if (is_initialized(m)) { size_t nfree = SIZE_T_ONE; /* top always free */ size_t mfree = m->topsize + TOP_FOOT_SIZE; size_t sum = mfree; msegmentptr s = &m->seg; while (s != 0) { - mchunkptr q = align_as_chunk (s->base); - while (segment_holds (s, q) && + mchunkptr q = align_as_chunk(s->base); + while (segment_holds(s, q) && q != m->top && q->head != FENCEPOST_HEAD) { - size_t sz = chunksize (q); + size_t sz = chunksize(q); sum += sz; - if (!cinuse (q)) { + if (!cinuse(q)) { mfree += sz; ++nfree; } - q = next_chunk (q); + q = next_chunk(q); } s = s->next; } @@ -2914,46 +2912,45 @@ nm.keepcost = m->topsize; } - POSTACTION (m); + POSTACTION(m); } return nm; } #endif /* !NO_MALLINFO */ static void -internal_malloc_stats (mstate m) +internal_malloc_stats(mstate m) { - if (!PREACTION (m)) { + if (!PREACTION(m)) { size_t maxfp = 0; size_t fp = 0; size_t used = 0; - check_malloc_state (m); - if (is_initialized (m)) { + check_malloc_state(m); + if (is_initialized(m)) { msegmentptr s = &m->seg; maxfp = m->max_footprint; fp = m->footprint; used = fp - (m->topsize + TOP_FOOT_SIZE); while (s != 0) { - mchunkptr q = align_as_chunk (s->base); - while (segment_holds (s, q) && + mchunkptr q = align_as_chunk(s->base); + while (segment_holds(s, q) && q != m->top && q->head != FENCEPOST_HEAD) { - if (!cinuse (q)) - used -= chunksize (q); - q = next_chunk (q); + if (!cinuse(q)) + used -= chunksize(q); + q = next_chunk(q); } s = s->next; } } #ifndef LACKS_STDIO_H - fprintf (stderr, "max system bytes = %10lu\n", - (unsigned long) (maxfp)); - fprintf (stderr, "system bytes = %10lu\n", (unsigned long) (fp)); - fprintf (stderr, "in use bytes = %10lu\n", - (unsigned long) (used)); + fprintf(stderr, "max system bytes = %10lu\n", + (unsigned long) (maxfp)); + fprintf(stderr, "system bytes = %10lu\n", (unsigned long) (fp)); + fprintf(stderr, "in use bytes = %10lu\n", (unsigned long) (used)); #endif - POSTACTION (m); + POSTACTION(m); } } @@ -3219,29 +3216,29 @@ /* Malloc using mmap */ static void * -mmap_alloc (mstate m, size_t nb) +mmap_alloc(mstate m, size_t nb) { size_t mmsize = - granularity_align (nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + granularity_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); if (mmsize > nb) { /* Check for wrap around 0 */ - char *mm = (char *) (DIRECT_MMAP (mmsize)); + char *mm = (char *) (DIRECT_MMAP(mmsize)); if (mm != CMFAIL) { - size_t offset = align_offset (chunk2mem (mm)); + size_t offset = align_offset(chunk2mem(mm)); size_t psize = mmsize - offset - MMAP_FOOT_PAD; mchunkptr p = (mchunkptr) (mm + offset); p->prev_foot = offset | IS_MMAPPED_BIT; (p)->head = (psize | CINUSE_BIT); - mark_inuse_foot (m, p, psize); - chunk_plus_offset (p, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset (p, psize + SIZE_T_SIZE)->head = 0; + mark_inuse_foot(m, p, psize); + chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; + chunk_plus_offset(p, psize + SIZE_T_SIZE)->head = 0; if (mm < m->least_addr) m->least_addr = mm; if ((m->footprint += mmsize) > m->max_footprint) m->max_footprint = m->footprint; - assert (is_aligned (chunk2mem (p))); - check_mmapped_chunk (m, p); - return chunk2mem (p); + assert(is_aligned(chunk2mem(p))); + check_mmapped_chunk(m, p); + return chunk2mem(p); } } return 0; @@ -3249,10 +3246,10 @@ /* Realloc using mmap */ static mchunkptr -mmap_resize (mstate m, mchunkptr oldp, size_t nb) +mmap_resize(mstate m, mchunkptr oldp, size_t nb) { - size_t oldsize = chunksize (oldp); - if (is_small (nb)) /* Can't shrink mmap regions below small size */ + size_t oldsize = chunksize(oldp); + if (is_small(nb)) /* Can't shrink mmap regions below small size */ return 0; /* Keep old chunk if big enough but not too big */ if (oldsize >= nb + SIZE_T_SIZE && @@ -3261,23 +3258,23 @@ else { size_t offset = oldp->prev_foot & ~IS_MMAPPED_BIT; size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; - size_t newmmsize = granularity_align (nb + SIX_SIZE_T_SIZES + - CHUNK_ALIGN_MASK); - char *cp = (char *) CALL_MREMAP ((char *) oldp - offset, - oldmmsize, newmmsize, 1); + size_t newmmsize = granularity_align(nb + SIX_SIZE_T_SIZES + + CHUNK_ALIGN_MASK); + char *cp = (char *) CALL_MREMAP((char *) oldp - offset, + oldmmsize, newmmsize, 1); if (cp != CMFAIL) { mchunkptr newp = (mchunkptr) (cp + offset); size_t psize = newmmsize - offset - MMAP_FOOT_PAD; newp->head = (psize | CINUSE_BIT); - mark_inuse_foot (m, newp, psize); - chunk_plus_offset (newp, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset (newp, psize + SIZE_T_SIZE)->head = 0; + mark_inuse_foot(m, newp, psize); + chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; + chunk_plus_offset(newp, psize + SIZE_T_SIZE)->head = 0; if (cp < m->least_addr) m->least_addr = cp; if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) m->max_footprint = m->footprint; - check_mmapped_chunk (m, newp); + check_mmapped_chunk(m, newp); return newp; } } @@ -3288,10 +3285,10 @@ /* Initialize top chunk and its size */ static void -init_top (mstate m, mchunkptr p, size_t psize) +init_top(mstate m, mchunkptr p, size_t psize) { /* Ensure alignment */ - size_t offset = align_offset (chunk2mem (p)); + size_t offset = align_offset(chunk2mem(p)); p = (mchunkptr) ((char *) p + offset); psize -= offset; @@ -3299,18 +3296,18 @@ m->topsize = psize; p->head = psize | PINUSE_BIT; /* set size of fake trailing chunk holding overhead space only once */ - chunk_plus_offset (p, psize)->head = TOP_FOOT_SIZE; + chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; m->trim_check = mparams.trim_threshold; /* reset on each update */ } /* Initialize bins for a new mstate that is otherwise zeroed out */ static void -init_bins (mstate m) +init_bins(mstate m) { /* Establish circular links for smallbins */ bindex_t i; for (i = 0; i < NSMALLBINS; ++i) { - sbinptr bin = smallbin_at (m, i); + sbinptr bin = smallbin_at(m, i); bin->fd = bin->bk = bin; } } @@ -3319,7 +3316,7 @@ /* default corruption action */ static void -reset_on_error (mstate m) +reset_on_error(mstate m) { int i; ++malloc_corruption_error_count; @@ -3331,78 +3328,78 @@ m->seg.next = 0; m->top = m->dv = 0; for (i = 0; i < NTREEBINS; ++i) - *treebin_at (m, i) = 0; - init_bins (m); + *treebin_at(m, i) = 0; + init_bins(m); } #endif /* PROCEED_ON_ERROR */ /* Allocate chunk and prepend remainder with chunk in successor base. */ static void * -prepend_alloc (mstate m, char *newbase, char *oldbase, size_t nb) +prepend_alloc(mstate m, char *newbase, char *oldbase, size_t nb) { - mchunkptr p = align_as_chunk (newbase); - mchunkptr oldfirst = align_as_chunk (oldbase); + mchunkptr p = align_as_chunk(newbase); + mchunkptr oldfirst = align_as_chunk(oldbase); size_t psize = (char *) oldfirst - (char *) p; - mchunkptr q = chunk_plus_offset (p, nb); + mchunkptr q = chunk_plus_offset(p, nb); size_t qsize = psize - nb; - set_size_and_pinuse_of_inuse_chunk (m, p, nb); - - assert ((char *) oldfirst > (char *) q); - assert (pinuse (oldfirst)); - assert (qsize >= MIN_CHUNK_SIZE); + set_size_and_pinuse_of_inuse_chunk(m, p, nb); + + assert((char *) oldfirst > (char *) q); + assert(pinuse(oldfirst)); + assert(qsize >= MIN_CHUNK_SIZE); /* consolidate remainder with first chunk of old base */ if (oldfirst == m->top) { size_t tsize = m->topsize += qsize; m->top = q; q->head = tsize | PINUSE_BIT; - check_top_chunk (m, q); + check_top_chunk(m, q); } else if (oldfirst == m->dv) { size_t dsize = m->dvsize += qsize; m->dv = q; - set_size_and_pinuse_of_free_chunk (q, dsize); + set_size_and_pinuse_of_free_chunk(q, dsize); } else { - if (!cinuse (oldfirst)) { - size_t nsize = chunksize (oldfirst); - unlink_chunk (m, oldfirst, nsize); - oldfirst = chunk_plus_offset (oldfirst, nsize); + if (!cinuse(oldfirst)) { + size_t nsize = chunksize(oldfirst); + unlink_chunk(m, oldfirst, nsize); + oldfirst = chunk_plus_offset(oldfirst, nsize); qsize += nsize; } - set_free_with_pinuse (q, qsize, oldfirst); - insert_chunk (m, q, qsize); - check_free_chunk (m, q); + set_free_with_pinuse(q, qsize, oldfirst); + insert_chunk(m, q, qsize); + check_free_chunk(m, q); } - check_malloced_chunk (m, chunk2mem (p), nb); - return chunk2mem (p); + check_malloced_chunk(m, chunk2mem(p), nb); + return chunk2mem(p); } /* Add a segment to hold a new noncontiguous region */ static void -add_segment (mstate m, char *tbase, size_t tsize, flag_t mmapped) +add_segment(mstate m, char *tbase, size_t tsize, flag_t mmapped) { /* Determine locations and sizes of segment, fenceposts, old top */ char *old_top = (char *) m->top; - msegmentptr oldsp = segment_holding (m, old_top); + msegmentptr oldsp = segment_holding(m, old_top); char *old_end = oldsp->base + oldsp->size; - size_t ssize = pad_request (sizeof (struct malloc_segment)); + size_t ssize = pad_request(sizeof(struct malloc_segment)); char *rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - size_t offset = align_offset (chunk2mem (rawsp)); + size_t offset = align_offset(chunk2mem(rawsp)); char *asp = rawsp + offset; char *csp = (asp < (old_top + MIN_CHUNK_SIZE)) ? old_top : asp; mchunkptr sp = (mchunkptr) csp; - msegmentptr ss = (msegmentptr) (chunk2mem (sp)); - mchunkptr tnext = chunk_plus_offset (sp, ssize); + msegmentptr ss = (msegmentptr) (chunk2mem(sp)); + mchunkptr tnext = chunk_plus_offset(sp, ssize); mchunkptr p = tnext; int nfences = 0; /* reset top to new space */ - init_top (m, (mchunkptr) tbase, tsize - TOP_FOOT_SIZE); + init_top(m, (mchunkptr) tbase, tsize - TOP_FOOT_SIZE); /* Set up segment record */ - assert (is_aligned (ss)); - set_size_and_pinuse_of_inuse_chunk (m, sp, ssize); + assert(is_aligned(ss)); + set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); *ss = m->seg; /* Push current record */ m->seg.base = tbase; m->seg.size = tsize; @@ -3411,7 +3408,7 @@ /* Insert trailing fenceposts */ for (;;) { - mchunkptr nextp = chunk_plus_offset (p, SIZE_T_SIZE); + mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); p->head = FENCEPOST_HEAD; ++nfences; if ((char *) (&(nextp->head)) < old_end) @@ -3419,35 +3416,35 @@ else break; } - assert (nfences >= 2); + assert(nfences >= 2); /* Insert the rest of old top into a bin as an ordinary free chunk */ if (csp != old_top) { mchunkptr q = (mchunkptr) old_top; size_t psize = csp - old_top; - mchunkptr tn = chunk_plus_offset (q, psize); - set_free_with_pinuse (q, psize, tn); - insert_chunk (m, q, psize); + mchunkptr tn = chunk_plus_offset(q, psize); + set_free_with_pinuse(q, psize, tn); + insert_chunk(m, q, psize); } - check_top_chunk (m, m->top); + check_top_chunk(m, m->top); } /* -------------------------- System allocation -------------------------- */ /* Get memory from system using MORECORE or MMAP */ static void * -sys_alloc (mstate m, size_t nb) +sys_alloc(mstate m, size_t nb) { char *tbase = CMFAIL; size_t tsize = 0; flag_t mmap_flag = 0; - init_mparams (); + init_mparams(); /* Directly map large chunks */ - if (use_mmap (m) && nb >= mparams.mmap_threshold) { - void *mem = mmap_alloc (m, nb); + if (use_mmap(m) && nb >= mparams.mmap_threshold) { + void *mem = mmap_alloc(m, nb); if (mem != 0) return mem; } @@ -3469,23 +3466,23 @@ (disabled if not HAVE_MORECORE) */ - if (MORECORE_CONTIGUOUS && !use_noncontiguous (m)) { + if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) { char *br = CMFAIL; msegmentptr ss = - (m->top == 0) ? 0 : segment_holding (m, (char *) m->top); + (m->top == 0) ? 0 : segment_holding(m, (char *) m->top); size_t asize = 0; - ACQUIRE_MORECORE_LOCK (); + ACQUIRE_MORECORE_LOCK(); if (ss == 0) { /* First time through or recovery */ - char *base = (char *) CALL_MORECORE (0); + char *base = (char *) CALL_MORECORE(0); if (base != CMFAIL) { - asize = granularity_align (nb + TOP_FOOT_SIZE + SIZE_T_ONE); + asize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE); /* Adjust to end on a page boundary */ - if (!is_page_aligned (base)) - asize += (page_align ((size_t) base) - (size_t) base); + if (!is_page_aligned(base)) + asize += (page_align((size_t) base) - (size_t) base); /* Can't call MORECORE if size is negative when treated as signed */ if (asize < HALF_MAX_SIZE_T && - (br = (char *) (CALL_MORECORE (asize))) == base) { + (br = (char *) (CALL_MORECORE(asize))) == base) { tbase = base; tsize = asize; } @@ -3493,12 +3490,12 @@ } else { /* Subtract out existing available top space from MORECORE request. */ asize = - granularity_align (nb - m->topsize + TOP_FOOT_SIZE + - SIZE_T_ONE); + granularity_align(nb - m->topsize + TOP_FOOT_SIZE + + SIZE_T_ONE); /* Use mem here only if it did continuously extend old space */ if (asize < HALF_MAX_SIZE_T && (br = - (char *) (CALL_MORECORE (asize))) == ss->base + ss->size) { + (char *) (CALL_MORECORE(asize))) == ss->base + ss->size) { tbase = br; tsize = asize; } @@ -3509,14 +3506,14 @@ if (asize < HALF_MAX_SIZE_T && asize < nb + TOP_FOOT_SIZE + SIZE_T_ONE) { size_t esize = - granularity_align (nb + TOP_FOOT_SIZE + - SIZE_T_ONE - asize); + granularity_align(nb + TOP_FOOT_SIZE + + SIZE_T_ONE - asize); if (esize < HALF_MAX_SIZE_T) { - char *end = (char *) CALL_MORECORE (esize); + char *end = (char *) CALL_MORECORE(esize); if (end != CMFAIL) asize += esize; else { /* Can't use; try to release */ - end = (char *) CALL_MORECORE (-asize); + end = (char *) CALL_MORECORE(-asize); br = CMFAIL; } } @@ -3526,17 +3523,17 @@ tbase = br; tsize = asize; } else - disable_contiguous (m); /* Don't try contiguous path in the future */ + disable_contiguous(m); /* Don't try contiguous path in the future */ } - RELEASE_MORECORE_LOCK (); + RELEASE_MORECORE_LOCK(); } if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ size_t req = nb + TOP_FOOT_SIZE + SIZE_T_ONE; - size_t rsize = granularity_align (req); + size_t rsize = granularity_align(req); if (rsize > nb) { /* Fail if wraps around zero */ - char *mp = (char *) (CALL_MMAP (rsize)); + char *mp = (char *) (CALL_MMAP(rsize)); if (mp != CMFAIL) { tbase = mp; tsize = rsize; @@ -3546,14 +3543,14 @@ } if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ - size_t asize = granularity_align (nb + TOP_FOOT_SIZE + SIZE_T_ONE); + size_t asize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE); if (asize < HALF_MAX_SIZE_T) { char *br = CMFAIL; char *end = CMFAIL; - ACQUIRE_MORECORE_LOCK (); - br = (char *) (CALL_MORECORE (asize)); - end = (char *) (CALL_MORECORE (0)); - RELEASE_MORECORE_LOCK (); + ACQUIRE_MORECORE_LOCK(); + br = (char *) (CALL_MORECORE(asize)); + end = (char *) (CALL_MORECORE(0)); + RELEASE_MORECORE_LOCK(); if (br != CMFAIL && end != CMFAIL && br < end) { size_t ssize = end - br; if (ssize > nb + TOP_FOOT_SIZE) { @@ -3569,20 +3566,20 @@ if ((m->footprint += tsize) > m->max_footprint) m->max_footprint = m->footprint; - if (!is_initialized (m)) { /* first-time initialization */ + if (!is_initialized(m)) { /* first-time initialization */ m->seg.base = m->least_addr = tbase; m->seg.size = tsize; m->seg.sflags = mmap_flag; m->magic = mparams.magic; - init_bins (m); - if (is_global (m)) - init_top (m, (mchunkptr) tbase, tsize - TOP_FOOT_SIZE); + init_bins(m); + if (is_global(m)) + init_top(m, (mchunkptr) tbase, tsize - TOP_FOOT_SIZE); else { /* Offset top by embedded malloc_state */ - mchunkptr mn = next_chunk (mem2chunk (m)); - init_top (m, mn, - (size_t) ((tbase + tsize) - (char *) mn) - - TOP_FOOT_SIZE); + mchunkptr mn = next_chunk(mem2chunk(m)); + init_top(m, mn, + (size_t) ((tbase + tsize) - (char *) mn) - + TOP_FOOT_SIZE); } } @@ -3591,9 +3588,9 @@ msegmentptr sp = &m->seg; while (sp != 0 && tbase != sp->base + sp->size) sp = sp->next; - if (sp != 0 && !is_extern_segment (sp) && (sp->sflags & IS_MMAPPED_BIT) == mmap_flag && segment_holds (sp, m->top)) { /* append */ + if (sp != 0 && !is_extern_segment(sp) && (sp->sflags & IS_MMAPPED_BIT) == mmap_flag && segment_holds(sp, m->top)) { /* append */ sp->size += tsize; - init_top (m, m->top, m->topsize + tsize); + init_top(m, m->top, m->topsize + tsize); } else { if (tbase < m->least_addr) m->least_addr = tbase; @@ -3601,26 +3598,26 @@ while (sp != 0 && sp->base != tbase + tsize) sp = sp->next; if (sp != 0 && - !is_extern_segment (sp) && + !is_extern_segment(sp) && (sp->sflags & IS_MMAPPED_BIT) == mmap_flag) { char *oldbase = sp->base; sp->base = tbase; sp->size += tsize; - return prepend_alloc (m, tbase, oldbase, nb); + return prepend_alloc(m, tbase, oldbase, nb); } else - add_segment (m, tbase, tsize, mmap_flag); + add_segment(m, tbase, tsize, mmap_flag); } } if (nb < m->topsize) { /* Allocate from new or extended top space */ size_t rsize = m->topsize -= nb; mchunkptr p = m->top; - mchunkptr r = m->top = chunk_plus_offset (p, nb); + mchunkptr r = m->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk (m, p, nb); - check_top_chunk (m, m->top); - check_malloced_chunk (m, chunk2mem (p), nb); - return chunk2mem (p); + set_size_and_pinuse_of_inuse_chunk(m, p, nb); + check_top_chunk(m, m->top); + check_malloced_chunk(m, chunk2mem(p), nb); + return chunk2mem(p); } } @@ -3632,7 +3629,7 @@ /* Unmap and unlink any mmapped segments that don't contain used chunks */ static size_t -release_unused_segments (mstate m) +release_unused_segments(mstate m) { size_t released = 0; msegmentptr pred = &m->seg; @@ -3641,28 +3638,28 @@ char *base = sp->base; size_t size = sp->size; msegmentptr next = sp->next; - if (is_mmapped_segment (sp) && !is_extern_segment (sp)) { - mchunkptr p = align_as_chunk (base); - size_t psize = chunksize (p); + if (is_mmapped_segment(sp) && !is_extern_segment(sp)) { + mchunkptr p = align_as_chunk(base); + size_t psize = chunksize(p); /* Can unmap if first chunk holds entire segment and not pinned */ - if (!cinuse (p) + if (!cinuse(p) && (char *) p + psize >= base + size - TOP_FOOT_SIZE) { tchunkptr tp = (tchunkptr) p; - assert (segment_holds (sp, (char *) sp)); + assert(segment_holds(sp, (char *) sp)); if (p == m->dv) { m->dv = 0; m->dvsize = 0; } else { - unlink_large_chunk (m, tp); + unlink_large_chunk(m, tp); } - if (CALL_MUNMAP (base, size) == 0) { + if (CALL_MUNMAP(base, size) == 0) { released += size; m->footprint -= size; /* unlink obsoleted record */ sp = pred; sp->next = next; } else { /* back out if cannot unmap */ - insert_large_chunk (m, tp, psize); + insert_large_chunk(m, tp, psize); } } } @@ -3673,10 +3670,10 @@ } static int -sys_trim (mstate m, size_t pad) +sys_trim(mstate m, size_t pad) { size_t released = 0; - if (pad < MAX_REQUEST && is_initialized (m)) { + if (pad < MAX_REQUEST && is_initialized(m)) { pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ if (m->topsize > pad) { @@ -3685,16 +3682,16 @@ size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - SIZE_T_ONE) * unit; - msegmentptr sp = segment_holding (m, (char *) m->top); - - if (!is_extern_segment (sp)) { - if (is_mmapped_segment (sp)) { - if (HAVE_MMAP && sp->size >= extra && !has_segment_link (m, sp)) { /* can't shrink if pinned */ + msegmentptr sp = segment_holding(m, (char *) m->top); + + if (!is_extern_segment(sp)) { + if (is_mmapped_segment(sp)) { + if (HAVE_MMAP && sp->size >= extra && !has_segment_link(m, sp)) { /* can't shrink if pinned */ size_t newsize = sp->size - extra; /* Prefer mremap, fall back to munmap */ if ((CALL_MREMAP (sp->base, sp->size, newsize, 0) != MFAIL) - || (CALL_MUNMAP (sp->base + newsize, extra) + || (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { released = extra; } @@ -3702,32 +3699,32 @@ } else if (HAVE_MORECORE) { if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit; - ACQUIRE_MORECORE_LOCK (); + ACQUIRE_MORECORE_LOCK(); { /* Make sure end of memory is where we last set it. */ - char *old_br = (char *) (CALL_MORECORE (0)); + char *old_br = (char *) (CALL_MORECORE(0)); if (old_br == sp->base + sp->size) { - char *rel_br = (char *) (CALL_MORECORE (-extra)); - char *new_br = (char *) (CALL_MORECORE (0)); + char *rel_br = (char *) (CALL_MORECORE(-extra)); + char *new_br = (char *) (CALL_MORECORE(0)); if (rel_br != CMFAIL && new_br < old_br) released = old_br - new_br; } } - RELEASE_MORECORE_LOCK (); + RELEASE_MORECORE_LOCK(); } } if (released != 0) { sp->size -= released; m->footprint -= released; - init_top (m, m->top, m->topsize - released); - check_top_chunk (m, m->top); + init_top(m, m->top, m->topsize - released); + check_top_chunk(m, m->top); } } /* Unmap any unused mmapped segments */ if (HAVE_MMAP) - released += release_unused_segments (m); + released += release_unused_segments(m); /* On failure, disable autotrim to avoid repeated failed future calls */ if (released == 0) @@ -3741,21 +3738,21 @@ /* allocate a large request from the best fitting chunk in a treebin */ static void * -tmalloc_large (mstate m, size_t nb) +tmalloc_large(mstate m, size_t nb) { tchunkptr v = 0; size_t rsize = -nb; /* Unsigned negation */ tchunkptr t; bindex_t idx; - compute_tree_index (nb, idx); - - if ((t = *treebin_at (m, idx)) != 0) { + compute_tree_index(nb, idx); + + if ((t = *treebin_at(m, idx)) != 0) { /* Traverse tree for this bin looking for node with size == nb */ - size_t sizebits = nb << leftshift_for_tree_index (idx); + size_t sizebits = nb << leftshift_for_tree_index(idx); tchunkptr rst = 0; /* The deepest untaken right subtree */ for (;;) { tchunkptr rt; - size_t trem = chunksize (t) - nb; + size_t trem = chunksize(t) - nb; if (trem < rsize) { v = t; if ((rsize = trem) == 0) @@ -3774,150 +3771,150 @@ } if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ - binmap_t leftbits = left_bits (idx2bit (idx)) & m->treemap; + binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; if (leftbits != 0) { bindex_t i; - binmap_t leastbit = least_bit (leftbits); - compute_bit2idx (leastbit, i); - t = *treebin_at (m, i); + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + t = *treebin_at(m, i); } } while (t != 0) { /* find smallest of tree or subtree */ - size_t trem = chunksize (t) - nb; + size_t trem = chunksize(t) - nb; if (trem < rsize) { rsize = trem; v = t; } - t = leftmost_child (t); + t = leftmost_child(t); } /* If dv is a better fit, return 0 so malloc will use it */ if (v != 0 && rsize < (size_t) (m->dvsize - nb)) { - if (RTCHECK (ok_address (m, v))) { /* split */ - mchunkptr r = chunk_plus_offset (v, nb); - assert (chunksize (v) == rsize + nb); - if (RTCHECK (ok_next (v, r))) { - unlink_large_chunk (m, v); + if (RTCHECK(ok_address(m, v))) { /* split */ + mchunkptr r = chunk_plus_offset(v, nb); + assert(chunksize(v) == rsize + nb); + if (RTCHECK(ok_next(v, r))) { + unlink_large_chunk(m, v); if (rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse (m, v, (rsize + nb)); + set_inuse_and_pinuse(m, v, (rsize + nb)); else { - set_size_and_pinuse_of_inuse_chunk (m, v, nb); - set_size_and_pinuse_of_free_chunk (r, rsize); - insert_chunk (m, r, rsize); + set_size_and_pinuse_of_inuse_chunk(m, v, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + insert_chunk(m, r, rsize); } - return chunk2mem (v); + return chunk2mem(v); } } - CORRUPTION_ERROR_ACTION (m); + CORRUPTION_ERROR_ACTION(m); } return 0; } /* allocate a small request from the best fitting chunk in a treebin */ static void * -tmalloc_small (mstate m, size_t nb) +tmalloc_small(mstate m, size_t nb) { tchunkptr t, v; size_t rsize; bindex_t i; - binmap_t leastbit = least_bit (m->treemap); - compute_bit2idx (leastbit, i); - - v = t = *treebin_at (m, i); - rsize = chunksize (t) - nb; - - while ((t = leftmost_child (t)) != 0) { - size_t trem = chunksize (t) - nb; + binmap_t leastbit = least_bit(m->treemap); + compute_bit2idx(leastbit, i); + + v = t = *treebin_at(m, i); + rsize = chunksize(t) - nb; + + while ((t = leftmost_child(t)) != 0) { + size_t trem = chunksize(t) - nb; if (trem < rsize) { rsize = trem; v = t; } } - if (RTCHECK (ok_address (m, v))) { - mchunkptr r = chunk_plus_offset (v, nb); - assert (chunksize (v) == rsize + nb); - if (RTCHECK (ok_next (v, r))) { - unlink_large_chunk (m, v); + if (RTCHECK(ok_address(m, v))) { + mchunkptr r = chunk_plus_offset(v, nb); + assert(chunksize(v) == rsize + nb); + if (RTCHECK(ok_next(v, r))) { + unlink_large_chunk(m, v); if (rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse (m, v, (rsize + nb)); + set_inuse_and_pinuse(m, v, (rsize + nb)); else { - set_size_and_pinuse_of_inuse_chunk (m, v, nb); - set_size_and_pinuse_of_free_chunk (r, rsize); - replace_dv (m, r, rsize); + set_size_and_pinuse_of_inuse_chunk(m, v, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(m, r, rsize); } - return chunk2mem (v); + return chunk2mem(v); } } - CORRUPTION_ERROR_ACTION (m); + CORRUPTION_ERROR_ACTION(m); return 0; } /* --------------------------- realloc support --------------------------- */ static void * -internal_realloc (mstate m, void *oldmem, size_t bytes) +internal_realloc(mstate m, void *oldmem, size_t bytes) { if (bytes >= MAX_REQUEST) { MALLOC_FAILURE_ACTION; return 0; } - if (!PREACTION (m)) { - mchunkptr oldp = mem2chunk (oldmem); - size_t oldsize = chunksize (oldp); - mchunkptr next = chunk_plus_offset (oldp, oldsize); + if (!PREACTION(m)) { + mchunkptr oldp = mem2chunk(oldmem); + size_t oldsize = chunksize(oldp); + mchunkptr next = chunk_plus_offset(oldp, oldsize); mchunkptr newp = 0; void *extra = 0; /* Try to either shrink or extend into top. Else malloc-copy-free */ - if (RTCHECK (ok_address (m, oldp) && ok_cinuse (oldp) && - ok_next (oldp, next) && ok_pinuse (next))) { - size_t nb = request2size (bytes); - if (is_mmapped (oldp)) - newp = mmap_resize (m, oldp, nb); + if (RTCHECK(ok_address(m, oldp) && ok_cinuse(oldp) && + ok_next(oldp, next) && ok_pinuse(next))) { + size_t nb = request2size(bytes); + if (is_mmapped(oldp)) + newp = mmap_resize(m, oldp, nb); else if (oldsize >= nb) { /* already big enough */ size_t rsize = oldsize - nb; newp = oldp; if (rsize >= MIN_CHUNK_SIZE) { - mchunkptr remainder = chunk_plus_offset (newp, nb); - set_inuse (m, newp, nb); - set_inuse (m, remainder, rsize); - extra = chunk2mem (remainder); + mchunkptr remainder = chunk_plus_offset(newp, nb); + set_inuse(m, newp, nb); + set_inuse(m, remainder, rsize); + extra = chunk2mem(remainder); } } else if (next == m->top && oldsize + m->topsize > nb) { /* Expand into top */ size_t newsize = oldsize + m->topsize; size_t newtopsize = newsize - nb; - mchunkptr newtop = chunk_plus_offset (oldp, nb); - set_inuse (m, oldp, nb); + mchunkptr newtop = chunk_plus_offset(oldp, nb); + set_inuse(m, oldp, nb); newtop->head = newtopsize | PINUSE_BIT; m->top = newtop; m->topsize = newtopsize; newp = oldp; } } else { - USAGE_ERROR_ACTION (m, oldmem); - POSTACTION (m); + USAGE_ERROR_ACTION(m, oldmem); + POSTACTION(m); return 0; } - POSTACTION (m); + POSTACTION(m); if (newp != 0) { if (extra != 0) { - internal_free (m, extra); + internal_free(m, extra); } - check_inuse_chunk (m, newp); - return chunk2mem (newp); + check_inuse_chunk(m, newp); + return chunk2mem(newp); } else { - void *newmem = internal_malloc (m, bytes); + void *newmem = internal_malloc(m, bytes); if (newmem != 0) { - size_t oc = oldsize - overhead_for (oldp); - memcpy (newmem, oldmem, (oc < bytes) ? oc : bytes); - internal_free (m, oldmem); + size_t oc = oldsize - overhead_for(oldp); + memcpy(newmem, oldmem, (oc < bytes) ? oc : bytes); + internal_free(m, oldmem); } return newmem; } @@ -3928,10 +3925,10 @@ /* --------------------------- memalign support -------------------------- */ static void * -internal_memalign (mstate m, size_t alignment, size_t bytes) +internal_memalign(mstate m, size_t alignment, size_t bytes) { if (alignment <= MALLOC_ALIGNMENT) /* Can just use malloc */ - return internal_malloc (m, bytes); + return internal_malloc(m, bytes); if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ alignment = MIN_CHUNK_SIZE; if ((alignment & (alignment - SIZE_T_ONE)) != 0) { /* Ensure a power of 2 */ @@ -3946,15 +3943,15 @@ MALLOC_FAILURE_ACTION; } } else { - size_t nb = request2size (bytes); + size_t nb = request2size(bytes); size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; - char *mem = (char *) internal_malloc (m, req); + char *mem = (char *) internal_malloc(m, req); if (mem != 0) { void *leader = 0; void *trailer = 0; - mchunkptr p = mem2chunk (mem); - - if (PREACTION (m)) + mchunkptr p = mem2chunk(mem); + + if (PREACTION(m)) return 0; if ((((size_t) (mem)) % alignment) != 0) { /* misaligned */ /* @@ -3966,51 +3963,51 @@ possible. */ char *br = (char *) - mem2chunk ((size_t) - (((size_t) - (mem + alignment - - SIZE_T_ONE)) & -alignment)); + mem2chunk((size_t) + (((size_t) + (mem + alignment - + SIZE_T_ONE)) & -alignment)); char *pos = ((size_t) (br - (char *) (p)) >= MIN_CHUNK_SIZE) ? br : br + alignment; mchunkptr newp = (mchunkptr) pos; size_t leadsize = pos - (char *) (p); - size_t newsize = chunksize (p) - leadsize; - - if (is_mmapped (p)) { /* For mmapped chunks, just adjust offset */ + size_t newsize = chunksize(p) - leadsize; + + if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ newp->prev_foot = p->prev_foot + leadsize; newp->head = (newsize | CINUSE_BIT); } else { /* Otherwise, give back leader, use the rest */ - set_inuse (m, newp, newsize); - set_inuse (m, p, leadsize); - leader = chunk2mem (p); + set_inuse(m, newp, newsize); + set_inuse(m, p, leadsize); + leader = chunk2mem(p); } p = newp; } /* Give back spare room at the end */ - if (!is_mmapped (p)) { - size_t size = chunksize (p); + if (!is_mmapped(p)) { + size_t size = chunksize(p); if (size > nb + MIN_CHUNK_SIZE) { size_t remainder_size = size - nb; - mchunkptr remainder = chunk_plus_offset (p, nb); - set_inuse (m, p, nb); - set_inuse (m, remainder, remainder_size); - trailer = chunk2mem (remainder); + mchunkptr remainder = chunk_plus_offset(p, nb); + set_inuse(m, p, nb); + set_inuse(m, remainder, remainder_size); + trailer = chunk2mem(remainder); } } - assert (chunksize (p) >= nb); - assert ((((size_t) (chunk2mem (p))) % alignment) == 0); - check_inuse_chunk (m, p); - POSTACTION (m); + assert(chunksize(p) >= nb); + assert((((size_t) (chunk2mem(p))) % alignment) == 0); + check_inuse_chunk(m, p); + POSTACTION(m); if (leader != 0) { - internal_free (m, leader); + internal_free(m, leader); } if (trailer != 0) { - internal_free (m, trailer); + internal_free(m, trailer); } - return chunk2mem (p); + return chunk2mem(p); } } return 0; @@ -4019,7 +4016,7 @@ /* ------------------------ comalloc/coalloc support --------------------- */ static void ** -ialloc (mstate m, size_t n_elements, size_t * sizes, int opts, void *chunks[]) +ialloc(mstate m, size_t n_elements, size_t * sizes, int opts, void *chunks[]) { /* This provides common support for independent_X routines, handling @@ -4051,20 +4048,20 @@ } else { /* if empty req, must still return chunk representing empty array */ if (n_elements == 0) - return (void **) internal_malloc (m, 0); + return (void **) internal_malloc(m, 0); marray = 0; - array_size = request2size (n_elements * (sizeof (void *))); + array_size = request2size(n_elements * (sizeof(void *))); } /* compute total element size */ if (opts & 0x1) { /* all-same-size */ - element_size = request2size (*sizes); + element_size = request2size(*sizes); contents_size = n_elements * element_size; } else { /* add up all the sizes */ element_size = 0; contents_size = 0; for (i = 0; i != n_elements; ++i) - contents_size += request2size (sizes[i]); + contents_size += request2size(sizes[i]); } size = contents_size + array_size; @@ -4074,48 +4071,48 @@ malloc won't use it, since we would not be able to later free/realloc space internal to a segregated mmap region. */ - was_enabled = use_mmap (m); - disable_mmap (m); - mem = internal_malloc (m, size - CHUNK_OVERHEAD); + was_enabled = use_mmap(m); + disable_mmap(m); + mem = internal_malloc(m, size - CHUNK_OVERHEAD); if (was_enabled) - enable_mmap (m); + enable_mmap(m); if (mem == 0) return 0; - if (PREACTION (m)) + if (PREACTION(m)) return 0; - p = mem2chunk (mem); - remainder_size = chunksize (p); - - assert (!is_mmapped (p)); + p = mem2chunk(mem); + remainder_size = chunksize(p); + + assert(!is_mmapped(p)); if (opts & 0x2) { /* optionally clear the elements */ - memset ((size_t *) mem, 0, remainder_size - SIZE_T_SIZE - array_size); + memset((size_t *) mem, 0, remainder_size - SIZE_T_SIZE - array_size); } /* If not provided, allocate the pointer array as final part of chunk */ if (marray == 0) { size_t array_chunk_size; - array_chunk = chunk_plus_offset (p, contents_size); + array_chunk = chunk_plus_offset(p, contents_size); array_chunk_size = remainder_size - contents_size; - marray = (void **) (chunk2mem (array_chunk)); - set_size_and_pinuse_of_inuse_chunk (m, array_chunk, array_chunk_size); + marray = (void **) (chunk2mem(array_chunk)); + set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size); remainder_size = contents_size; } /* split out elements */ for (i = 0;; ++i) { - marray[i] = chunk2mem (p); + marray[i] = chunk2mem(p); if (i != n_elements - 1) { if (element_size != 0) size = element_size; else - size = request2size (sizes[i]); + size = request2size(sizes[i]); remainder_size -= size; - set_size_and_pinuse_of_inuse_chunk (m, p, size); - p = chunk_plus_offset (p, size); + set_size_and_pinuse_of_inuse_chunk(m, p, size); + p = chunk_plus_offset(p, size); } else { /* the final element absorbs any overallocation slop */ - set_size_and_pinuse_of_inuse_chunk (m, p, remainder_size); + set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size); break; } } @@ -4124,18 +4121,18 @@ if (marray != chunks) { /* final element must have exactly exhausted chunk */ if (element_size != 0) { - assert (remainder_size == element_size); + assert(remainder_size == element_size); } else { - assert (remainder_size == request2size (sizes[i])); + assert(remainder_size == request2size(sizes[i])); } - check_inuse_chunk (m, mem2chunk (marray)); + check_inuse_chunk(m, mem2chunk(marray)); } for (i = 0; i != n_elements; ++i) - check_inuse_chunk (m, mem2chunk (marray[i])); + check_inuse_chunk(m, mem2chunk(marray[i])); #endif /* DEBUG */ - POSTACTION (m); + POSTACTION(m); return marray; } @@ -4145,7 +4142,7 @@ #if !ONLY_MSPACES void * -dlmalloc (size_t bytes) +dlmalloc(size_t bytes) { /* Basic algorithm: @@ -4170,26 +4167,26 @@ The ugly goto's here ensure that postaction occurs along all paths. */ - if (!PREACTION (gm)) { + if (!PREACTION(gm)) { void *mem; size_t nb; if (bytes <= MAX_SMALL_REQUEST) { bindex_t idx; binmap_t smallbits; - nb = (bytes < MIN_REQUEST) ? MIN_CHUNK_SIZE : pad_request (bytes); - idx = small_index (nb); + nb = (bytes < MIN_REQUEST) ? MIN_CHUNK_SIZE : pad_request(bytes); + idx = small_index(nb); smallbits = gm->smallmap >> idx; if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ mchunkptr b, p; idx += ~smallbits & 1; /* Uses next bin if idx empty */ - b = smallbin_at (gm, idx); + b = smallbin_at(gm, idx); p = b->fd; - assert (chunksize (p) == small_index2size (idx)); - unlink_first_small_chunk (gm, b, p, idx); - set_inuse_and_pinuse (gm, p, small_index2size (idx)); - mem = chunk2mem (p); - check_malloced_chunk (gm, mem, nb); + assert(chunksize(p) == small_index2size(idx)); + unlink_first_small_chunk(gm, b, p, idx); + set_inuse_and_pinuse(gm, p, small_index2size(idx)); + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); goto postaction; } @@ -4199,40 +4196,40 @@ size_t rsize; bindex_t i; binmap_t leftbits = - (smallbits << idx) & left_bits (idx2bit (idx)); - binmap_t leastbit = least_bit (leftbits); - compute_bit2idx (leastbit, i); - b = smallbin_at (gm, i); + (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + b = smallbin_at(gm, i); p = b->fd; - assert (chunksize (p) == small_index2size (i)); - unlink_first_small_chunk (gm, b, p, i); - rsize = small_index2size (i) - nb; + assert(chunksize(p) == small_index2size(i)); + unlink_first_small_chunk(gm, b, p, i); + rsize = small_index2size(i) - nb; /* Fit here cannot be remainderless if 4byte sizes */ if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse (gm, p, small_index2size (i)); + set_inuse_and_pinuse(gm, p, small_index2size(i)); else { - set_size_and_pinuse_of_inuse_chunk (gm, p, nb); - r = chunk_plus_offset (p, nb); - set_size_and_pinuse_of_free_chunk (r, rsize); - replace_dv (gm, r, rsize); + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + r = chunk_plus_offset(p, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(gm, r, rsize); } - mem = chunk2mem (p); - check_malloced_chunk (gm, mem, nb); + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); goto postaction; } else if (gm->treemap != 0 - && (mem = tmalloc_small (gm, nb)) != 0) { - check_malloced_chunk (gm, mem, nb); + && (mem = tmalloc_small(gm, nb)) != 0) { + check_malloced_chunk(gm, mem, nb); goto postaction; } } } else if (bytes >= MAX_REQUEST) nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ else { - nb = pad_request (bytes); - if (gm->treemap != 0 && (mem = tmalloc_large (gm, nb)) != 0) { - check_malloced_chunk (gm, mem, nb); + nb = pad_request(bytes); + if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) { + check_malloced_chunk(gm, mem, nb); goto postaction; } } @@ -4241,37 +4238,37 @@ size_t rsize = gm->dvsize - nb; mchunkptr p = gm->dv; if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ - mchunkptr r = gm->dv = chunk_plus_offset (p, nb); + mchunkptr r = gm->dv = chunk_plus_offset(p, nb); gm->dvsize = rsize; - set_size_and_pinuse_of_free_chunk (r, rsize); - set_size_and_pinuse_of_inuse_chunk (gm, p, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); } else { /* exhaust dv */ size_t dvs = gm->dvsize; gm->dvsize = 0; gm->dv = 0; - set_inuse_and_pinuse (gm, p, dvs); + set_inuse_and_pinuse(gm, p, dvs); } - mem = chunk2mem (p); - check_malloced_chunk (gm, mem, nb); + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); goto postaction; } else if (nb < gm->topsize) { /* Split top */ size_t rsize = gm->topsize -= nb; mchunkptr p = gm->top; - mchunkptr r = gm->top = chunk_plus_offset (p, nb); + mchunkptr r = gm->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk (gm, p, nb); - mem = chunk2mem (p); - check_top_chunk (gm, gm->top); - check_malloced_chunk (gm, mem, nb); + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + mem = chunk2mem(p); + check_top_chunk(gm, gm->top); + check_malloced_chunk(gm, mem, nb); goto postaction; } - mem = sys_alloc (gm, nb); + mem = sys_alloc(gm, nb); postaction: - POSTACTION (gm); + POSTACTION(gm); return mem; } @@ -4279,7 +4276,7 @@ } void -dlfree (void *mem) +dlfree(void *mem) { /* Consolidate freed chunks with preceeding or succeeding bordering @@ -4288,40 +4285,40 @@ */ if (mem != 0) { - mchunkptr p = mem2chunk (mem); + mchunkptr p = mem2chunk(mem); #if FOOTERS - mstate fm = get_mstate_for (p); - if (!ok_magic (fm)) { - USAGE_ERROR_ACTION (fm, p); + mstate fm = get_mstate_for(p); + if (!ok_magic(fm)) { + USAGE_ERROR_ACTION(fm, p); return; } #else /* FOOTERS */ #define fm gm #endif /* FOOTERS */ - if (!PREACTION (fm)) { - check_inuse_chunk (fm, p); - if (RTCHECK (ok_address (fm, p) && ok_cinuse (p))) { - size_t psize = chunksize (p); - mchunkptr next = chunk_plus_offset (p, psize); - if (!pinuse (p)) { + if (!PREACTION(fm)) { + check_inuse_chunk(fm, p); + if (RTCHECK(ok_address(fm, p) && ok_cinuse(p))) { + size_t psize = chunksize(p); + mchunkptr next = chunk_plus_offset(p, psize); + if (!pinuse(p)) { size_t prevsize = p->prev_foot; if ((prevsize & IS_MMAPPED_BIT) != 0) { prevsize &= ~IS_MMAPPED_BIT; psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP ((char *) p - prevsize, psize) == 0) + if (CALL_MUNMAP((char *) p - prevsize, psize) == 0) fm->footprint -= psize; goto postaction; } else { - mchunkptr prev = chunk_minus_offset (p, prevsize); + mchunkptr prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; - if (RTCHECK (ok_address (fm, prev))) { /* consolidate backward */ + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ if (p != fm->dv) { - unlink_chunk (fm, p, prevsize); + unlink_chunk(fm, p, prevsize); } else if ((next->head & INUSE_BITS) == INUSE_BITS) { fm->dvsize = psize; - set_free_with_pinuse (p, psize, next); + set_free_with_pinuse(p, psize, next); goto postaction; } } else @@ -4329,8 +4326,8 @@ } } - if (RTCHECK (ok_next (p, next) && ok_pinuse (next))) { - if (!cinuse (next)) { /* consolidate forward */ + if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { + if (!cinuse(next)) { /* consolidate forward */ if (next == fm->top) { size_t tsize = fm->topsize += psize; fm->top = p; @@ -4339,35 +4336,35 @@ fm->dv = 0; fm->dvsize = 0; } - if (should_trim (fm, tsize)) - sys_trim (fm, 0); + if (should_trim(fm, tsize)) + sys_trim(fm, 0); goto postaction; } else if (next == fm->dv) { size_t dsize = fm->dvsize += psize; fm->dv = p; - set_size_and_pinuse_of_free_chunk (p, dsize); + set_size_and_pinuse_of_free_chunk(p, dsize); goto postaction; } else { - size_t nsize = chunksize (next); + size_t nsize = chunksize(next); psize += nsize; - unlink_chunk (fm, next, nsize); - set_size_and_pinuse_of_free_chunk (p, psize); + unlink_chunk(fm, next, nsize); + set_size_and_pinuse_of_free_chunk(p, psize); if (p == fm->dv) { fm->dvsize = psize; goto postaction; } } } else - set_free_with_pinuse (p, psize, next); - insert_chunk (fm, p, psize); - check_free_chunk (fm, p); + set_free_with_pinuse(p, psize, next); + insert_chunk(fm, p, psize); + check_free_chunk(fm, p); goto postaction; } } erroraction: - USAGE_ERROR_ACTION (fm, p); + USAGE_ERROR_ACTION(fm, p); postaction: - POSTACTION (fm); + POSTACTION(fm); } } #if !FOOTERS @@ -4376,7 +4373,7 @@ } void * -dlcalloc (size_t n_elements, size_t elem_size) +dlcalloc(size_t n_elements, size_t elem_size) { void *mem; size_t req = 0; @@ -4386,20 +4383,20 @@ (req / n_elements != elem_size)) req = MAX_SIZE_T; /* force downstream failure on overflow */ } - mem = dlmalloc (req); - if (mem != 0 && calloc_must_clear (mem2chunk (mem))) - memset (mem, 0, req); + mem = dlmalloc(req); + if (mem != 0 && calloc_must_clear(mem2chunk(mem))) + memset(mem, 0, req); return mem; } void * -dlrealloc (void *oldmem, size_t bytes) +dlrealloc(void *oldmem, size_t bytes) { if (oldmem == 0) - return dlmalloc (bytes); + return dlmalloc(bytes); #ifdef REALLOC_ZERO_BYTES_FREES if (bytes == 0) { - dlfree (oldmem); + dlfree(oldmem); return 0; } #endif /* REALLOC_ZERO_BYTES_FREES */ @@ -4407,107 +4404,106 @@ #if ! FOOTERS mstate m = gm; #else /* FOOTERS */ - mstate m = get_mstate_for (mem2chunk (oldmem)); - if (!ok_magic (m)) { - USAGE_ERROR_ACTION (m, oldmem); + mstate m = get_mstate_for(mem2chunk(oldmem)); + if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); return 0; } #endif /* FOOTERS */ - return internal_realloc (m, oldmem, bytes); + return internal_realloc(m, oldmem, bytes); } } void * -dlmemalign (size_t alignment, size_t bytes) +dlmemalign(size_t alignment, size_t bytes) { - return internal_memalign (gm, alignment, bytes); + return internal_memalign(gm, alignment, bytes); } void ** -dlindependent_calloc (size_t n_elements, size_t elem_size, void *chunks[]) +dlindependent_calloc(size_t n_elements, size_t elem_size, void *chunks[]) { size_t sz = elem_size; /* serves as 1-element array */ - return ialloc (gm, n_elements, &sz, 3, chunks); + return ialloc(gm, n_elements, &sz, 3, chunks); } void ** -dlindependent_comalloc (size_t n_elements, size_t sizes[], void *chunks[]) +dlindependent_comalloc(size_t n_elements, size_t sizes[], void *chunks[]) { - return ialloc (gm, n_elements, sizes, 0, chunks); + return ialloc(gm, n_elements, sizes, 0, chunks); } void * -dlvalloc (size_t bytes) +dlvalloc(size_t bytes) { size_t pagesz; - init_mparams (); + init_mparams(); pagesz = mparams.page_size; - return dlmemalign (pagesz, bytes); + return dlmemalign(pagesz, bytes); } void * -dlpvalloc (size_t bytes) +dlpvalloc(size_t bytes) { size_t pagesz; - init_mparams (); + init_mparams(); pagesz = mparams.page_size; - return dlmemalign (pagesz, - (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - - SIZE_T_ONE)); + return dlmemalign(pagesz, + (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); } int -dlmalloc_trim (size_t pad) +dlmalloc_trim(size_t pad) { int result = 0; - if (!PREACTION (gm)) { - result = sys_trim (gm, pad); - POSTACTION (gm); + if (!PREACTION(gm)) { + result = sys_trim(gm, pad); + POSTACTION(gm); } return result; } size_t -dlmalloc_footprint (void) +dlmalloc_footprint(void) { return gm->footprint; } size_t -dlmalloc_max_footprint (void) +dlmalloc_max_footprint(void) { return gm->max_footprint; } #if !NO_MALLINFO struct mallinfo -dlmallinfo (void) +dlmallinfo(void) { - return internal_mallinfo (gm); + return internal_mallinfo(gm); } #endif /* NO_MALLINFO */ void -dlmalloc_stats () +dlmalloc_stats() { - internal_malloc_stats (gm); + internal_malloc_stats(gm); } size_t -dlmalloc_usable_size (void *mem) +dlmalloc_usable_size(void *mem) { if (mem != 0) { - mchunkptr p = mem2chunk (mem); - if (cinuse (p)) - return chunksize (p) - overhead_for (p); + mchunkptr p = mem2chunk(mem); + if (cinuse(p)) + return chunksize(p) - overhead_for(p); } return 0; } int -dlmallopt (int param_number, int value) +dlmallopt(int param_number, int value) { - return change_mparam (param_number, value); + return change_mparam(param_number, value); } #endif /* !ONLY_MSPACES */ @@ -4517,71 +4513,70 @@ #if MSPACES static mstate -init_user_mstate (char *tbase, size_t tsize) +init_user_mstate(char *tbase, size_t tsize) { - size_t msize = pad_request (sizeof (struct malloc_state)); + size_t msize = pad_request(sizeof(struct malloc_state)); mchunkptr mn; - mchunkptr msp = align_as_chunk (tbase); - mstate m = (mstate) (chunk2mem (msp)); - memset (m, 0, msize); - INITIAL_LOCK (&m->mutex); + mchunkptr msp = align_as_chunk(tbase); + mstate m = (mstate) (chunk2mem(msp)); + memset(m, 0, msize); + INITIAL_LOCK(&m->mutex); msp->head = (msize | PINUSE_BIT | CINUSE_BIT); m->seg.base = m->least_addr = tbase; m->seg.size = m->footprint = m->max_footprint = tsize; m->magic = mparams.magic; m->mflags = mparams.default_mflags; - disable_contiguous (m); - init_bins (m); - mn = next_chunk (mem2chunk (m)); - init_top (m, mn, - (size_t) ((tbase + tsize) - (char *) mn) - TOP_FOOT_SIZE); - check_top_chunk (m, m->top); + disable_contiguous(m); + init_bins(m); + mn = next_chunk(mem2chunk(m)); + init_top(m, mn, (size_t) ((tbase + tsize) - (char *) mn) - TOP_FOOT_SIZE); + check_top_chunk(m, m->top); return m; } mspace -create_mspace (size_t capacity, int locked) +create_mspace(size_t capacity, int locked) { mstate m = 0; - size_t msize = pad_request (sizeof (struct malloc_state)); - init_mparams (); /* Ensure pagesize etc initialized */ + size_t msize = pad_request(sizeof(struct malloc_state)); + init_mparams(); /* Ensure pagesize etc initialized */ if (capacity < (size_t) - (msize + TOP_FOOT_SIZE + mparams.page_size)) { size_t rs = ((capacity == 0) ? mparams.granularity : (capacity + TOP_FOOT_SIZE + msize)); - size_t tsize = granularity_align (rs); - char *tbase = (char *) (CALL_MMAP (tsize)); + size_t tsize = granularity_align(rs); + char *tbase = (char *) (CALL_MMAP(tsize)); if (tbase != CMFAIL) { - m = init_user_mstate (tbase, tsize); + m = init_user_mstate(tbase, tsize); m->seg.sflags = IS_MMAPPED_BIT; - set_lock (m, locked); + set_lock(m, locked); } } return (mspace) m; } mspace -create_mspace_with_base (void *base, size_t capacity, int locked) +create_mspace_with_base(void *base, size_t capacity, int locked) { mstate m = 0; - size_t msize = pad_request (sizeof (struct malloc_state)); - init_mparams (); /* Ensure pagesize etc initialized */ + size_t msize = pad_request(sizeof(struct malloc_state)); + init_mparams(); /* Ensure pagesize etc initialized */ if (capacity > msize + TOP_FOOT_SIZE && capacity < (size_t) - (msize + TOP_FOOT_SIZE + mparams.page_size)) { - m = init_user_mstate ((char *) base, capacity); + m = init_user_mstate((char *) base, capacity); m->seg.sflags = EXTERN_BIT; - set_lock (m, locked); + set_lock(m, locked); } return (mspace) m; } size_t -destroy_mspace (mspace msp) +destroy_mspace(mspace msp) { size_t freed = 0; mstate ms = (mstate) msp; - if (ok_magic (ms)) { + if (ok_magic(ms)) { msegmentptr sp = &ms->seg; while (sp != 0) { char *base = sp->base; @@ -4589,11 +4584,11 @@ flag_t flag = sp->sflags; sp = sp->next; if ((flag & IS_MMAPPED_BIT) && !(flag & EXTERN_BIT) && - CALL_MUNMAP (base, size) == 0) + CALL_MUNMAP(base, size) == 0) freed += size; } } else { - USAGE_ERROR_ACTION (ms, ms); + USAGE_ERROR_ACTION(ms, ms); } return freed; } @@ -4605,33 +4600,33 @@ void * -mspace_malloc (mspace msp, size_t bytes) +mspace_malloc(mspace msp, size_t bytes) { mstate ms = (mstate) msp; - if (!ok_magic (ms)) { - USAGE_ERROR_ACTION (ms, ms); + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms, ms); return 0; } - if (!PREACTION (ms)) { + if (!PREACTION(ms)) { void *mem; size_t nb; if (bytes <= MAX_SMALL_REQUEST) { bindex_t idx; binmap_t smallbits; - nb = (bytes < MIN_REQUEST) ? MIN_CHUNK_SIZE : pad_request (bytes); - idx = small_index (nb); + nb = (bytes < MIN_REQUEST) ? MIN_CHUNK_SIZE : pad_request(bytes); + idx = small_index(nb); smallbits = ms->smallmap >> idx; if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ mchunkptr b, p; idx += ~smallbits & 1; /* Uses next bin if idx empty */ - b = smallbin_at (ms, idx); + b = smallbin_at(ms, idx); p = b->fd; - assert (chunksize (p) == small_index2size (idx)); - unlink_first_small_chunk (ms, b, p, idx); - set_inuse_and_pinuse (ms, p, small_index2size (idx)); - mem = chunk2mem (p); - check_malloced_chunk (ms, mem, nb); + assert(chunksize(p) == small_index2size(idx)); + unlink_first_small_chunk(ms, b, p, idx); + set_inuse_and_pinuse(ms, p, small_index2size(idx)); + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); goto postaction; } @@ -4641,40 +4636,40 @@ size_t rsize; bindex_t i; binmap_t leftbits = - (smallbits << idx) & left_bits (idx2bit (idx)); - binmap_t leastbit = least_bit (leftbits); - compute_bit2idx (leastbit, i); - b = smallbin_at (ms, i); + (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + b = smallbin_at(ms, i); p = b->fd; - assert (chunksize (p) == small_index2size (i)); - unlink_first_small_chunk (ms, b, p, i); - rsize = small_index2size (i) - nb; + assert(chunksize(p) == small_index2size(i)); + unlink_first_small_chunk(ms, b, p, i); + rsize = small_index2size(i) - nb; /* Fit here cannot be remainderless if 4byte sizes */ if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) - set_inuse_and_pinuse (ms, p, small_index2size (i)); + set_inuse_and_pinuse(ms, p, small_index2size(i)); else { - set_size_and_pinuse_of_inuse_chunk (ms, p, nb); - r = chunk_plus_offset (p, nb); - set_size_and_pinuse_of_free_chunk (r, rsize); - replace_dv (ms, r, rsize); + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + r = chunk_plus_offset(p, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(ms, r, rsize); } - mem = chunk2mem (p); - check_malloced_chunk (ms, mem, nb); + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); goto postaction; } else if (ms->treemap != 0 - && (mem = tmalloc_small (ms, nb)) != 0) { - check_malloced_chunk (ms, mem, nb); + && (mem = tmalloc_small(ms, nb)) != 0) { + check_malloced_chunk(ms, mem, nb); goto postaction; } } } else if (bytes >= MAX_REQUEST) nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ else { - nb = pad_request (bytes); - if (ms->treemap != 0 && (mem = tmalloc_large (ms, nb)) != 0) { - check_malloced_chunk (ms, mem, nb); + nb = pad_request(bytes); + if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { + check_malloced_chunk(ms, mem, nb); goto postaction; } } @@ -4683,37 +4678,37 @@ size_t rsize = ms->dvsize - nb; mchunkptr p = ms->dv; if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ - mchunkptr r = ms->dv = chunk_plus_offset (p, nb); + mchunkptr r = ms->dv = chunk_plus_offset(p, nb); ms->dvsize = rsize; - set_size_and_pinuse_of_free_chunk (r, rsize); - set_size_and_pinuse_of_inuse_chunk (ms, p, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); } else { /* exhaust dv */ size_t dvs = ms->dvsize; ms->dvsize = 0; ms->dv = 0; - set_inuse_and_pinuse (ms, p, dvs); + set_inuse_and_pinuse(ms, p, dvs); } - mem = chunk2mem (p); - check_malloced_chunk (ms, mem, nb); + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); goto postaction; } else if (nb < ms->topsize) { /* Split top */ size_t rsize = ms->topsize -= nb; mchunkptr p = ms->top; - mchunkptr r = ms->top = chunk_plus_offset (p, nb); + mchunkptr r = ms->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; - set_size_and_pinuse_of_inuse_chunk (ms, p, nb); - mem = chunk2mem (p); - check_top_chunk (ms, ms->top); - check_malloced_chunk (ms, mem, nb); + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + mem = chunk2mem(p); + check_top_chunk(ms, ms->top); + check_malloced_chunk(ms, mem, nb); goto postaction; } - mem = sys_alloc (ms, nb); + mem = sys_alloc(ms, nb); postaction: - POSTACTION (ms); + POSTACTION(ms); return mem; } @@ -4721,43 +4716,43 @@ } void -mspace_free (mspace msp, void *mem) +mspace_free(mspace msp, void *mem) { if (mem != 0) { - mchunkptr p = mem2chunk (mem); + mchunkptr p = mem2chunk(mem); #if FOOTERS - mstate fm = get_mstate_for (p); + mstate fm = get_mstate_for(p); #else /* FOOTERS */ mstate fm = (mstate) msp; #endif /* FOOTERS */ - if (!ok_magic (fm)) { - USAGE_ERROR_ACTION (fm, p); + if (!ok_magic(fm)) { + USAGE_ERROR_ACTION(fm, p); return; } - if (!PREACTION (fm)) { - check_inuse_chunk (fm, p); - if (RTCHECK (ok_address (fm, p) && ok_cinuse (p))) { - size_t psize = chunksize (p); - mchunkptr next = chunk_plus_offset (p, psize); - if (!pinuse (p)) { + if (!PREACTION(fm)) { + check_inuse_chunk(fm, p); + if (RTCHECK(ok_address(fm, p) && ok_cinuse(p))) { + size_t psize = chunksize(p); + mchunkptr next = chunk_plus_offset(p, psize); + if (!pinuse(p)) { size_t prevsize = p->prev_foot; if ((prevsize & IS_MMAPPED_BIT) != 0) { prevsize &= ~IS_MMAPPED_BIT; psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP ((char *) p - prevsize, psize) == 0) + if (CALL_MUNMAP((char *) p - prevsize, psize) == 0) fm->footprint -= psize; goto postaction; } else { - mchunkptr prev = chunk_minus_offset (p, prevsize); + mchunkptr prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; - if (RTCHECK (ok_address (fm, prev))) { /* consolidate backward */ + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ if (p != fm->dv) { - unlink_chunk (fm, p, prevsize); + unlink_chunk(fm, p, prevsize); } else if ((next->head & INUSE_BITS) == INUSE_BITS) { fm->dvsize = psize; - set_free_with_pinuse (p, psize, next); + set_free_with_pinuse(p, psize, next); goto postaction; } } else @@ -4765,8 +4760,8 @@ } } - if (RTCHECK (ok_next (p, next) && ok_pinuse (next))) { - if (!cinuse (next)) { /* consolidate forward */ + if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { + if (!cinuse(next)) { /* consolidate forward */ if (next == fm->top) { size_t tsize = fm->topsize += psize; fm->top = p; @@ -4775,47 +4770,47 @@ fm->dv = 0; fm->dvsize = 0; } - if (should_trim (fm, tsize)) - sys_trim (fm, 0); + if (should_trim(fm, tsize)) + sys_trim(fm, 0); goto postaction; } else if (next == fm->dv) { size_t dsize = fm->dvsize += psize; fm->dv = p; - set_size_and_pinuse_of_free_chunk (p, dsize); + set_size_and_pinuse_of_free_chunk(p, dsize); goto postaction; } else { - size_t nsize = chunksize (next); + size_t nsize = chunksize(next); psize += nsize; - unlink_chunk (fm, next, nsize); - set_size_and_pinuse_of_free_chunk (p, psize); + unlink_chunk(fm, next, nsize); + set_size_and_pinuse_of_free_chunk(p, psize); if (p == fm->dv) { fm->dvsize = psize; goto postaction; } } } else - set_free_with_pinuse (p, psize, next); - insert_chunk (fm, p, psize); - check_free_chunk (fm, p); + set_free_with_pinuse(p, psize, next); + insert_chunk(fm, p, psize); + check_free_chunk(fm, p); goto postaction; } } erroraction: - USAGE_ERROR_ACTION (fm, p); + USAGE_ERROR_ACTION(fm, p); postaction: - POSTACTION (fm); + POSTACTION(fm); } } } void * -mspace_calloc (mspace msp, size_t n_elements, size_t elem_size) +mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) { void *mem; size_t req = 0; mstate ms = (mstate) msp; - if (!ok_magic (ms)) { - USAGE_ERROR_ACTION (ms, ms); + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms, ms); return 0; } if (n_elements != 0) { @@ -4824,143 +4819,143 @@ (req / n_elements != elem_size)) req = MAX_SIZE_T; /* force downstream failure on overflow */ } - mem = internal_malloc (ms, req); - if (mem != 0 && calloc_must_clear (mem2chunk (mem))) - memset (mem, 0, req); + mem = internal_malloc(ms, req); + if (mem != 0 && calloc_must_clear(mem2chunk(mem))) + memset(mem, 0, req); return mem; } void * -mspace_realloc (mspace msp, void *oldmem, size_t bytes) +mspace_realloc(mspace msp, void *oldmem, size_t bytes) { if (oldmem == 0) - return mspace_malloc (msp, bytes); + return mspace_malloc(msp, bytes); #ifdef REALLOC_ZERO_BYTES_FREES if (bytes == 0) { - mspace_free (msp, oldmem); + mspace_free(msp, oldmem); return 0; } #endif /* REALLOC_ZERO_BYTES_FREES */ else { #if FOOTERS - mchunkptr p = mem2chunk (oldmem); - mstate ms = get_mstate_for (p); + mchunkptr p = mem2chunk(oldmem); + mstate ms = get_mstate_for(p); #else /* FOOTERS */ mstate ms = (mstate) msp; #endif /* FOOTERS */ - if (!ok_magic (ms)) { - USAGE_ERROR_ACTION (ms, ms); + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms, ms); return 0; } - return internal_realloc (ms, oldmem, bytes); + return internal_realloc(ms, oldmem, bytes); } } void * -mspace_memalign (mspace msp, size_t alignment, size_t bytes) +mspace_memalign(mspace msp, size_t alignment, size_t bytes) { mstate ms = (mstate) msp; - if (!ok_magic (ms)) { - USAGE_ERROR_ACTION (ms, ms); + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms, ms); return 0; } - return internal_memalign (ms, alignment, bytes); + return internal_memalign(ms, alignment, bytes); } void ** -mspace_independent_calloc (mspace msp, size_t n_elements, - size_t elem_size, void *chunks[]) +mspace_independent_calloc(mspace msp, size_t n_elements, + size_t elem_size, void *chunks[]) { size_t sz = elem_size; /* serves as 1-element array */ mstate ms = (mstate) msp; - if (!ok_magic (ms)) { - USAGE_ERROR_ACTION (ms, ms); + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms, ms); return 0; } - return ialloc (ms, n_elements, &sz, 3, chunks); + return ialloc(ms, n_elements, &sz, 3, chunks); } void ** -mspace_independent_comalloc (mspace msp, size_t n_elements, - size_t sizes[], void *chunks[]) +mspace_independent_comalloc(mspace msp, size_t n_elements, + size_t sizes[], void *chunks[]) { mstate ms = (mstate) msp; - if (!ok_magic (ms)) { - USAGE_ERROR_ACTION (ms, ms); + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms, ms); return 0; } - return ialloc (ms, n_elements, sizes, 0, chunks); + return ialloc(ms, n_elements, sizes, 0, chunks); } int -mspace_trim (mspace msp, size_t pad) +mspace_trim(mspace msp, size_t pad) { int result = 0; mstate ms = (mstate) msp; - if (ok_magic (ms)) { - if (!PREACTION (ms)) { - result = sys_trim (ms, pad); - POSTACTION (ms); + if (ok_magic(ms)) { + if (!PREACTION(ms)) { + result = sys_trim(ms, pad); + POSTACTION(ms); } } else { - USAGE_ERROR_ACTION (ms, ms); + USAGE_ERROR_ACTION(ms, ms); } return result; } void -mspace_malloc_stats (mspace msp) +mspace_malloc_stats(mspace msp) { mstate ms = (mstate) msp; - if (ok_magic (ms)) { - internal_malloc_stats (ms); + if (ok_magic(ms)) { + internal_malloc_stats(ms); } else { - USAGE_ERROR_ACTION (ms, ms); + USAGE_ERROR_ACTION(ms, ms); } } size_t -mspace_footprint (mspace msp) +mspace_footprint(mspace msp) { size_t result; mstate ms = (mstate) msp; - if (ok_magic (ms)) { + if (ok_magic(ms)) { result = ms->footprint; } - USAGE_ERROR_ACTION (ms, ms); + USAGE_ERROR_ACTION(ms, ms); return result; } size_t -mspace_max_footprint (mspace msp) +mspace_max_footprint(mspace msp) { size_t result; mstate ms = (mstate) msp; - if (ok_magic (ms)) { + if (ok_magic(ms)) { result = ms->max_footprint; } - USAGE_ERROR_ACTION (ms, ms); + USAGE_ERROR_ACTION(ms, ms); return result; } #if !NO_MALLINFO struct mallinfo -mspace_mallinfo (mspace msp) +mspace_mallinfo(mspace msp) { mstate ms = (mstate) msp; - if (!ok_magic (ms)) { - USAGE_ERROR_ACTION (ms, ms); + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms, ms); } - return internal_mallinfo (ms); + return internal_mallinfo(ms); } #endif /* NO_MALLINFO */ int -mspace_mallopt (int param_number, int value) +mspace_mallopt(int param_number, int value) { - return change_mparam (param_number, value); + return change_mparam(param_number, value); } #endif /* MSPACES */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/stdlib/SDL_qsort.c --- a/src/stdlib/SDL_qsort.c Mon May 29 03:53:21 2006 +0000 +++ b/src/stdlib/SDL_qsort.c Mon May 29 04:04:35 2006 +0000 @@ -266,59 +266,59 @@ /* ---------------------------------------------------------------------- */ static char * -pivot_big (char *first, char *mid, char *last, size_t size, - int compare (const void *, const void *)) +pivot_big(char *first, char *mid, char *last, size_t size, + int compare(const void *, const void *)) { size_t d = (((last - first) / size) >> 3) * size; char *m1, *m2, *m3; { char *a = first, *b = first + d, *c = first + 2 * d; #ifdef DEBUG_QSORT - fprintf (stderr, "< %d %d %d\n", *(int *) a, *(int *) b, *(int *) c); + fprintf(stderr, "< %d %d %d\n", *(int *) a, *(int *) b, *(int *) c); #endif - m1 = compare (a, b) < 0 ? - (compare (b, c) < 0 ? b : (compare (a, c) < 0 ? c : a)) - : (compare (a, c) < 0 ? a : (compare (b, c) < 0 ? c : b)); + m1 = compare(a, b) < 0 ? + (compare(b, c) < 0 ? b : (compare(a, c) < 0 ? c : a)) + : (compare(a, c) < 0 ? a : (compare(b, c) < 0 ? c : b)); } { char *a = mid - d, *b = mid, *c = mid + d; #ifdef DEBUG_QSORT - fprintf (stderr, ". %d %d %d\n", *(int *) a, *(int *) b, *(int *) c); + fprintf(stderr, ". %d %d %d\n", *(int *) a, *(int *) b, *(int *) c); #endif - m2 = compare (a, b) < 0 ? - (compare (b, c) < 0 ? b : (compare (a, c) < 0 ? c : a)) - : (compare (a, c) < 0 ? a : (compare (b, c) < 0 ? c : b)); + m2 = compare(a, b) < 0 ? + (compare(b, c) < 0 ? b : (compare(a, c) < 0 ? c : a)) + : (compare(a, c) < 0 ? a : (compare(b, c) < 0 ? c : b)); } { char *a = last - 2 * d, *b = last - d, *c = last; #ifdef DEBUG_QSORT - fprintf (stderr, "> %d %d %d\n", *(int *) a, *(int *) b, *(int *) c); + fprintf(stderr, "> %d %d %d\n", *(int *) a, *(int *) b, *(int *) c); #endif - m3 = compare (a, b) < 0 ? - (compare (b, c) < 0 ? b : (compare (a, c) < 0 ? c : a)) - : (compare (a, c) < 0 ? a : (compare (b, c) < 0 ? c : b)); + m3 = compare(a, b) < 0 ? + (compare(b, c) < 0 ? b : (compare(a, c) < 0 ? c : a)) + : (compare(a, c) < 0 ? a : (compare(b, c) < 0 ? c : b)); } #ifdef DEBUG_QSORT - fprintf (stderr, "-> %d %d %d\n", *(int *) m1, *(int *) m2, *(int *) m3); + fprintf(stderr, "-> %d %d %d\n", *(int *) m1, *(int *) m2, *(int *) m3); #endif - return compare (m1, m2) < 0 ? - (compare (m2, m3) < 0 ? m2 : (compare (m1, m3) < 0 ? m3 : m1)) - : (compare (m1, m3) < 0 ? m1 : (compare (m2, m3) < 0 ? m3 : m2)); + return compare(m1, m2) < 0 ? + (compare(m2, m3) < 0 ? m2 : (compare(m1, m3) < 0 ? m3 : m1)) + : (compare(m1, m3) < 0 ? m1 : (compare(m2, m3) < 0 ? m3 : m2)); } /* ---------------------------------------------------------------------- */ static void -qsort_nonaligned (void *base, size_t nmemb, size_t size, - int (*compare) (const void *, const void *)) +qsort_nonaligned(void *base, size_t nmemb, size_t size, + int (*compare) (const void *, const void *)) { stack_entry stack[STACK_SIZE]; int stacktop = 0; char *first, *last; - char *pivot = malloc (size); + char *pivot = malloc(size); size_t trunc = TRUNC_nonaligned * size; - assert (pivot != 0); + assert(pivot != 0); first = (char *) base; last = first + (nmemb - 1) * size; @@ -329,30 +329,30 @@ /* Select pivot */ { char *mid = first + size * ((last - first) / size >> 1); - Pivot (SWAP_nonaligned, size); - memcpy (pivot, mid, size); + Pivot(SWAP_nonaligned, size); + memcpy(pivot, mid, size); } /* Partition. */ - Partition (SWAP_nonaligned, size); + Partition(SWAP_nonaligned, size); /* Prepare to recurse/iterate. */ - Recurse (trunc)} + Recurse(trunc)} } - PreInsertion (SWAP_nonaligned, TRUNC_nonaligned, size); - Insertion (SWAP_nonaligned); - free (pivot); + PreInsertion(SWAP_nonaligned, TRUNC_nonaligned, size); + Insertion(SWAP_nonaligned); + free(pivot); } static void -qsort_aligned (void *base, size_t nmemb, size_t size, - int (*compare) (const void *, const void *)) +qsort_aligned(void *base, size_t nmemb, size_t size, + int (*compare) (const void *, const void *)) { stack_entry stack[STACK_SIZE]; int stacktop = 0; char *first, *last; - char *pivot = malloc (size); + char *pivot = malloc(size); size_t trunc = TRUNC_aligned * size; - assert (pivot != 0); + assert(pivot != 0); first = (char *) base; last = first + (nmemb - 1) * size; @@ -363,29 +363,29 @@ /* Select pivot */ { char *mid = first + size * ((last - first) / size >> 1); - Pivot (SWAP_aligned, size); - memcpy (pivot, mid, size); + Pivot(SWAP_aligned, size); + memcpy(pivot, mid, size); } /* Partition. */ - Partition (SWAP_aligned, size); + Partition(SWAP_aligned, size); /* Prepare to recurse/iterate. */ - Recurse (trunc)} + Recurse(trunc)} } - PreInsertion (SWAP_aligned, TRUNC_aligned, size); - Insertion (SWAP_aligned); - free (pivot); + PreInsertion(SWAP_aligned, TRUNC_aligned, size); + Insertion(SWAP_aligned); + free(pivot); } static void -qsort_words (void *base, size_t nmemb, - int (*compare) (const void *, const void *)) +qsort_words(void *base, size_t nmemb, + int (*compare) (const void *, const void *)) { stack_entry stack[STACK_SIZE]; int stacktop = 0; char *first, *last; - char *pivot = malloc (WORD_BYTES); - assert (pivot != 0); + char *pivot = malloc(WORD_BYTES); + assert(pivot != 0); first = (char *) base; last = first + (nmemb - 1) * WORD_BYTES; @@ -394,26 +394,26 @@ char *ffirst = first, *llast = last; while (1) { #ifdef DEBUG_QSORT - fprintf (stderr, "Doing %d:%d: ", - (first - (char *) base) / WORD_BYTES, - (last - (char *) base) / WORD_BYTES); + fprintf(stderr, "Doing %d:%d: ", + (first - (char *) base) / WORD_BYTES, + (last - (char *) base) / WORD_BYTES); #endif /* Select pivot */ { char *mid = first + WORD_BYTES * ((last - first) / (2 * WORD_BYTES)); - Pivot (SWAP_words, WORD_BYTES); + Pivot(SWAP_words, WORD_BYTES); *(int *) pivot = *(int *) mid; } #ifdef DEBUG_QSORT - fprintf (stderr, "pivot=%d\n", *(int *) pivot); + fprintf(stderr, "pivot=%d\n", *(int *) pivot); #endif /* Partition. */ - Partition (SWAP_words, WORD_BYTES); + Partition(SWAP_words, WORD_BYTES); /* Prepare to recurse/iterate. */ - Recurse (TRUNC_words)} + Recurse(TRUNC_words)} } - PreInsertion (SWAP_words, (TRUNC_words / WORD_BYTES), WORD_BYTES); + PreInsertion(SWAP_words, (TRUNC_words / WORD_BYTES), WORD_BYTES); /* Now do insertion sort. */ last = ((char *) base) + nmemb * WORD_BYTES; for (first = ((char *) base) + WORD_BYTES; first != last; @@ -421,30 +421,30 @@ /* Find the right place for |first|. My apologies for var reuse */ int *pl = (int *) (first - WORD_BYTES), *pr = (int *) first; *(int *) pivot = *(int *) first; - for (; compare (pl, pivot) > 0; pr = pl, --pl) { + for (; compare(pl, pivot) > 0; pr = pl, --pl) { *pr = *pl; } if (pr != (int *) first) *pr = *(int *) pivot; } - free (pivot); + free(pivot); } /* ---------------------------------------------------------------------- */ void -qsort (void *base, size_t nmemb, size_t size, - int (*compare) (const void *, const void *)) +qsort(void *base, size_t nmemb, size_t size, + int (*compare) (const void *, const void *)) { if (nmemb <= 1) return; if (((uintptr_t) base | size) & (WORD_BYTES - 1)) - qsort_nonaligned (base, nmemb, size, compare); + qsort_nonaligned(base, nmemb, size, compare); else if (size != WORD_BYTES) - qsort_aligned (base, nmemb, size, compare); + qsort_aligned(base, nmemb, size, compare); else - qsort_words (base, nmemb, compare); + qsort_words(base, nmemb, compare); } #endif /* !HAVE_QSORT */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/stdlib/SDL_stdlib.c --- a/src/stdlib/SDL_stdlib.c Mon May 29 03:53:21 2006 +0000 +++ b/src/stdlib/SDL_stdlib.c Mon May 29 04:04:35 2006 +0000 @@ -35,12 +35,12 @@ #ifdef __cplusplus extern "C" #endif -__declspec (selectany) +__declspec(selectany) int _fltused = 1; #endif /* Float to long */ - void __declspec (naked) _ftol () + void __declspec(naked) _ftol() { /* *INDENT-OFF* */ __asm { @@ -90,16 +90,16 @@ } void -__declspec (naked) -_ftol2_sse () +__declspec(naked) +_ftol2_sse() { - _ftol (); + _ftol(); } /* 64-bit math operators for 32-bit systems */ void -__declspec (naked) -_allmul () +__declspec(naked) +_allmul() { /* *INDENT-OFF* */ __asm { @@ -136,8 +136,8 @@ /* *INDENT-ON* */ } void -__declspec (naked) -_alldiv () +__declspec(naked) +_alldiv() { /* *INDENT-OFF* */ __asm { @@ -223,8 +223,8 @@ /* *INDENT-ON* */ } void -__declspec (naked) -_aulldiv () +__declspec(naked) +_aulldiv() { /* *INDENT-OFF* */ __asm { @@ -280,8 +280,8 @@ /* *INDENT-ON* */ } void -__declspec (naked) -_allrem () +__declspec(naked) +_allrem() { /* *INDENT-OFF* */ __asm { @@ -366,8 +366,8 @@ /* *INDENT-ON* */ } void -__declspec (naked) -_aullrem () +__declspec(naked) +_aullrem() { /* *INDENT-OFF* */ __asm { @@ -424,8 +424,8 @@ /* *INDENT-ON* */ } void -__declspec (naked) -_alldvrm () +__declspec(naked) +_alldvrm() { /* *INDENT-OFF* */ __asm { @@ -533,8 +533,8 @@ /* *INDENT-ON* */ } void -__declspec (naked) -_aulldvrm () +__declspec(naked) +_aulldvrm() { /* *INDENT-OFF* */ __asm { @@ -605,8 +605,8 @@ /* *INDENT-ON* */ } void -__declspec (naked) -_allshl () +__declspec(naked) +_allshl() { /* *INDENT-OFF* */ __asm { @@ -631,8 +631,8 @@ /* *INDENT-ON* */ } void -__declspec (naked) -_aullshr () +__declspec(naked) +_aullshr() { /* *INDENT-OFF* */ __asm { diff -r 1fddae038bc8 -r 4da1ee79c9af src/stdlib/SDL_string.c --- a/src/stdlib/SDL_string.c Mon May 29 03:53:21 2006 +0000 +++ b/src/stdlib/SDL_string.c Mon May 29 04:04:35 2006 +0000 @@ -31,7 +31,7 @@ #if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOL) static size_t -SDL_ScanLong (const char *text, int radix, long *valuep) +SDL_ScanLong(const char *text, int radix, long *valuep) { const char *textstart = text; long value = 0; @@ -41,16 +41,16 @@ negative = SDL_TRUE; ++text; } - if (radix == 16 && SDL_strncmp (text, "0x", 2) == 0) { + if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) { text += 2; } for (;;) { int v; - if (SDL_isdigit (*text)) { + if (SDL_isdigit(*text)) { v = *text - '0'; - } else if (radix == 16 && SDL_isupperhex (*text)) { + } else if (radix == 16 && SDL_isupperhex(*text)) { v = 10 + (*text - 'A'); - } else if (radix == 16 && SDL_islowerhex (*text)) { + } else if (radix == 16 && SDL_islowerhex(*text)) { v = 10 + (*text - 'a'); } else { break; @@ -72,21 +72,21 @@ #if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOUL) || !defined(HAVE_STRTOD) static size_t -SDL_ScanUnsignedLong (const char *text, int radix, unsigned long *valuep) +SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep) { const char *textstart = text; unsigned long value = 0; - if (radix == 16 && SDL_strncmp (text, "0x", 2) == 0) { + if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) { text += 2; } for (;;) { int v; - if (SDL_isdigit (*text)) { + if (SDL_isdigit(*text)) { v = *text - '0'; - } else if (radix == 16 && SDL_isupperhex (*text)) { + } else if (radix == 16 && SDL_isupperhex(*text)) { v = 10 + (*text - 'A'); - } else if (radix == 16 && SDL_islowerhex (*text)) { + } else if (radix == 16 && SDL_islowerhex(*text)) { v = 10 + (*text - 'a'); } else { break; @@ -104,21 +104,21 @@ #ifndef HAVE_SSCANF static size_t -SDL_ScanUintPtrT (const char *text, int radix, uintptr_t * valuep) +SDL_ScanUintPtrT(const char *text, int radix, uintptr_t * valuep) { const char *textstart = text; uintptr_t value = 0; - if (radix == 16 && SDL_strncmp (text, "0x", 2) == 0) { + if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) { text += 2; } for (;;) { int v; - if (SDL_isdigit (*text)) { + if (SDL_isdigit(*text)) { v = *text - '0'; - } else if (radix == 16 && SDL_isupperhex (*text)) { + } else if (radix == 16 && SDL_isupperhex(*text)) { v = 10 + (*text - 'A'); - } else if (radix == 16 && SDL_islowerhex (*text)) { + } else if (radix == 16 && SDL_islowerhex(*text)) { v = 10 + (*text - 'a'); } else { break; @@ -137,7 +137,7 @@ #ifdef SDL_HAS_64BIT_TYPE #if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOLL) static size_t -SDL_ScanLongLong (const char *text, int radix, Sint64 * valuep) +SDL_ScanLongLong(const char *text, int radix, Sint64 * valuep) { const char *textstart = text; Sint64 value = 0; @@ -147,16 +147,16 @@ negative = SDL_TRUE; ++text; } - if (radix == 16 && SDL_strncmp (text, "0x", 2) == 0) { + if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) { text += 2; } for (;;) { int v; - if (SDL_isdigit (*text)) { + if (SDL_isdigit(*text)) { v = *text - '0'; - } else if (radix == 16 && SDL_isupperhex (*text)) { + } else if (radix == 16 && SDL_isupperhex(*text)) { v = 10 + (*text - 'A'); - } else if (radix == 16 && SDL_islowerhex (*text)) { + } else if (radix == 16 && SDL_islowerhex(*text)) { v = 10 + (*text - 'a'); } else { break; @@ -178,21 +178,21 @@ #if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOULL) static size_t -SDL_ScanUnsignedLongLong (const char *text, int radix, Uint64 * valuep) +SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 * valuep) { const char *textstart = text; Uint64 value = 0; - if (radix == 16 && SDL_strncmp (text, "0x", 2) == 0) { + if (radix == 16 && SDL_strncmp(text, "0x", 2) == 0) { text += 2; } for (;;) { int v; - if (SDL_isdigit (*text)) { + if (SDL_isdigit(*text)) { v = *text - '0'; - } else if (radix == 16 && SDL_isupperhex (*text)) { + } else if (radix == 16 && SDL_isupperhex(*text)) { v = 10 + (*text - 'A'); - } else if (radix == 16 && SDL_islowerhex (*text)) { + } else if (radix == 16 && SDL_islowerhex(*text)) { v = 10 + (*text - 'a'); } else { break; @@ -211,7 +211,7 @@ #if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOD) static size_t -SDL_ScanFloat (const char *text, double *valuep) +SDL_ScanFloat(const char *text, double *valuep) { const char *textstart = text; unsigned long lvalue = 0; @@ -222,12 +222,12 @@ negative = SDL_TRUE; ++text; } - text += SDL_ScanUnsignedLong (text, 10, &lvalue); + text += SDL_ScanUnsignedLong(text, 10, &lvalue); value += lvalue; if (*text == '.') { int mult = 10; ++text; - while (SDL_isdigit (*text)) { + while (SDL_isdigit(*text)) { lvalue = *text - '0'; value += (double) lvalue / mult; mult *= 10; @@ -247,7 +247,7 @@ #ifndef SDL_memset void * -SDL_memset (void *dst, int c, size_t len) +SDL_memset(void *dst, int c, size_t len) { size_t left = (len % 4); if (len >= 4) { @@ -281,7 +281,7 @@ #ifndef SDL_memcpy void * -SDL_memcpy (void *dst, const void *src, size_t len) +SDL_memcpy(void *dst, const void *src, size_t len) { char *srcp = (char *) src; char *dstp = (char *) dst; @@ -294,7 +294,7 @@ #ifndef SDL_revcpy void * -SDL_revcpy (void *dst, const void *src, size_t len) +SDL_revcpy(void *dst, const void *src, size_t len) { char *srcp = (char *) src; char *dstp = (char *) dst; @@ -309,7 +309,7 @@ #ifndef SDL_memcmp int -SDL_memcmp (const void *s1, const void *s2, size_t len) +SDL_memcmp(const void *s1, const void *s2, size_t len) { char *s1p = (char *) s1; char *s2p = (char *) s2; @@ -326,7 +326,7 @@ #ifndef HAVE_STRLEN size_t -SDL_strlen (const char *string) +SDL_strlen(const char *string) { size_t len = 0; while (*string++) { @@ -338,12 +338,12 @@ #ifndef HAVE_STRLCPY size_t -SDL_strlcpy (char *dst, const char *src, size_t maxlen) +SDL_strlcpy(char *dst, const char *src, size_t maxlen) { - size_t srclen = SDL_strlen (src); + size_t srclen = SDL_strlen(src); if (maxlen > 0) { - size_t len = SDL_min (srclen, maxlen - 1); - SDL_memcpy (dst, src, len); + size_t len = SDL_min(srclen, maxlen - 1); + SDL_memcpy(dst, src, len); dst[len] = '\0'; } return srclen; @@ -352,12 +352,12 @@ #ifndef HAVE_STRLCAT size_t -SDL_strlcat (char *dst, const char *src, size_t maxlen) +SDL_strlcat(char *dst, const char *src, size_t maxlen) { - size_t dstlen = SDL_strlen (dst); - size_t srclen = SDL_strlen (src); + size_t dstlen = SDL_strlen(dst); + size_t srclen = SDL_strlen(src); if (dstlen < maxlen) { - SDL_strlcpy (dst + dstlen, src, maxlen - dstlen); + SDL_strlcpy(dst + dstlen, src, maxlen - dstlen); } return dstlen + srclen; } @@ -365,12 +365,12 @@ #ifndef HAVE_STRDUP char * -SDL_strdup (const char *string) +SDL_strdup(const char *string) { - size_t len = SDL_strlen (string) + 1; - char *newstr = SDL_malloc (len); + size_t len = SDL_strlen(string) + 1; + char *newstr = SDL_malloc(len); if (newstr) { - SDL_strlcpy (newstr, string, len); + SDL_strlcpy(newstr, string, len); } return newstr; } @@ -378,9 +378,9 @@ #ifndef HAVE__STRREV char * -SDL_strrev (char *string) +SDL_strrev(char *string) { - size_t len = SDL_strlen (string); + size_t len = SDL_strlen(string); char *a = &string[0]; char *b = &string[len - 1]; len /= 2; @@ -395,11 +395,11 @@ #ifndef HAVE__STRUPR char * -SDL_strupr (char *string) +SDL_strupr(char *string) { char *bufp = string; while (*bufp) { - *bufp = SDL_toupper (*bufp); + *bufp = SDL_toupper(*bufp); ++bufp; } return string; @@ -408,11 +408,11 @@ #ifndef HAVE__STRLWR char * -SDL_strlwr (char *string) +SDL_strlwr(char *string) { char *bufp = string; while (*bufp) { - *bufp = SDL_tolower (*bufp); + *bufp = SDL_tolower(*bufp); ++bufp; } return string; @@ -421,7 +421,7 @@ #ifndef HAVE_STRCHR char * -SDL_strchr (const char *string, int c) +SDL_strchr(const char *string, int c) { while (*string) { if (*string == c) { @@ -435,9 +435,9 @@ #ifndef HAVE_STRRCHR char * -SDL_strrchr (const char *string, int c) +SDL_strrchr(const char *string, int c) { - const char *bufp = string + SDL_strlen (string) - 1; + const char *bufp = string + SDL_strlen(string) - 1; while (bufp >= string) { if (*bufp == c) { return (char *) bufp; @@ -450,11 +450,11 @@ #ifndef HAVE_STRSTR char * -SDL_strstr (const char *haystack, const char *needle) +SDL_strstr(const char *haystack, const char *needle) { - size_t length = SDL_strlen (needle); + size_t length = SDL_strlen(needle); while (*haystack) { - if (SDL_strncmp (haystack, needle, length) == 0) { + if (SDL_strncmp(haystack, needle, length) == 0) { return (char *) haystack; } ++haystack; @@ -475,7 +475,7 @@ #ifndef HAVE__LTOA char * -SDL_ltoa (long value, char *string, int radix) +SDL_ltoa(long value, char *string, int radix) { char *bufp = string; @@ -495,9 +495,9 @@ /* The numbers went into the string backwards. :) */ if (*string == '-') { - SDL_strrev (string + 1); + SDL_strrev(string + 1); } else { - SDL_strrev (string); + SDL_strrev(string); } return string; @@ -506,7 +506,7 @@ #ifndef HAVE__ULTOA char * -SDL_ultoa (unsigned long value, char *string, int radix) +SDL_ultoa(unsigned long value, char *string, int radix) { char *bufp = string; @@ -521,7 +521,7 @@ *bufp = '\0'; /* The numbers went into the string backwards. :) */ - SDL_strrev (string); + SDL_strrev(string); return string; } @@ -529,12 +529,12 @@ #ifndef HAVE_STRTOL long -SDL_strtol (const char *string, char **endp, int base) +SDL_strtol(const char *string, char **endp, int base) { size_t len; long value; - len = SDL_ScanLong (string, base ? base : 10, &value); + len = SDL_ScanLong(string, base ? base : 10, &value); if (endp) { *endp = (char *) string + len; } @@ -544,12 +544,12 @@ #ifndef HAVE_STRTOUL unsigned long -SDL_strtoul (const char *string, char **endp, int base) +SDL_strtoul(const char *string, char **endp, int base) { size_t len; unsigned long value; - len = SDL_ScanUnsignedLong (string, base ? base : 10, &value); + len = SDL_ScanUnsignedLong(string, base ? base : 10, &value); if (endp) { *endp = (char *) string + len; } @@ -561,7 +561,7 @@ #ifndef HAVE__I64TOA char * -SDL_lltoa (Sint64 value, char *string, int radix) +SDL_lltoa(Sint64 value, char *string, int radix) { char *bufp = string; @@ -581,9 +581,9 @@ /* The numbers went into the string backwards. :) */ if (*string == '-') { - SDL_strrev (string + 1); + SDL_strrev(string + 1); } else { - SDL_strrev (string); + SDL_strrev(string); } return string; @@ -592,7 +592,7 @@ #ifndef HAVE__UI64TOA char * -SDL_ulltoa (Uint64 value, char *string, int radix) +SDL_ulltoa(Uint64 value, char *string, int radix) { char *bufp = string; @@ -607,7 +607,7 @@ *bufp = '\0'; /* The numbers went into the string backwards. :) */ - SDL_strrev (string); + SDL_strrev(string); return string; } @@ -615,12 +615,12 @@ #ifndef HAVE_STRTOLL Sint64 -SDL_strtoll (const char *string, char **endp, int base) +SDL_strtoll(const char *string, char **endp, int base) { size_t len; Sint64 value; - len = SDL_ScanLongLong (string, base ? base : 10, &value); + len = SDL_ScanLongLong(string, base ? base : 10, &value); if (endp) { *endp = (char *) string + len; } @@ -630,12 +630,12 @@ #ifndef HAVE_STRTOULL Uint64 -SDL_strtoull (const char *string, char **endp, int base) +SDL_strtoull(const char *string, char **endp, int base) { size_t len; Uint64 value; - len = SDL_ScanUnsignedLongLong (string, base ? base : 10, &value); + len = SDL_ScanUnsignedLongLong(string, base ? base : 10, &value); if (endp) { *endp = (char *) string + len; } @@ -647,12 +647,12 @@ #ifndef HAVE_STRTOD double -SDL_strtod (const char *string, char **endp) +SDL_strtod(const char *string, char **endp) { size_t len; double value; - len = SDL_ScanFloat (string, &value); + len = SDL_ScanFloat(string, &value); if (endp) { *endp = (char *) string + len; } @@ -662,7 +662,7 @@ #ifndef HAVE_STRCMP int -SDL_strcmp (const char *str1, const char *str2) +SDL_strcmp(const char *str1, const char *str2) { while (*str1 && *str2) { if (*str1 != *str2) @@ -676,7 +676,7 @@ #ifndef HAVE_STRNCMP int -SDL_strncmp (const char *str1, const char *str2, size_t maxlen) +SDL_strncmp(const char *str1, const char *str2, size_t maxlen) { while (*str1 && *str2 && maxlen) { if (*str1 != *str2) @@ -694,13 +694,13 @@ #if !defined(HAVE_STRCASECMP) && !defined(HAVE__STRICMP) int -SDL_strcasecmp (const char *str1, const char *str2) +SDL_strcasecmp(const char *str1, const char *str2) { char a = 0; char b = 0; while (*str1 && *str2) { - a = SDL_tolower (*str1); - b = SDL_tolower (*str2); + a = SDL_tolower(*str1); + b = SDL_tolower(*str2); if (a != b) break; ++str1; @@ -712,13 +712,13 @@ #if !defined(HAVE_STRNCASECMP) && !defined(HAVE__STRNICMP) int -SDL_strncasecmp (const char *str1, const char *str2, size_t maxlen) +SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen) { char a = 0; char b = 0; while (*str1 && *str2 && maxlen) { - a = SDL_tolower (*str1); - b = SDL_tolower (*str2); + a = SDL_tolower(*str1); + b = SDL_tolower(*str2); if (a != b) break; ++str1; @@ -731,15 +731,15 @@ #ifndef HAVE_SSCANF int -SDL_sscanf (const char *text, const char *fmt, ...) +SDL_sscanf(const char *text, const char *fmt, ...) { va_list ap; int retval = 0; - va_start (ap, fmt); + va_start(ap, fmt); while (*fmt) { if (*fmt == ' ') { - while (SDL_isspace (*text)) { + while (SDL_isspace(*text)) { ++text; } ++fmt; @@ -771,7 +771,7 @@ suppress = SDL_TRUE; ++fmt; } - fmt += SDL_ScanLong (fmt, 10, &count); + fmt += SDL_ScanLong(fmt, 10, &count); if (*fmt == 'c') { if (!count) { @@ -782,7 +782,7 @@ ++text; } } else { - char *valuep = va_arg (ap, char *); + char *valuep = va_arg(ap, char *); while (count--) { *valuep++ = *text++; } @@ -791,7 +791,7 @@ continue; } - while (SDL_isspace (*text)) { + while (SDL_isspace(*text)) { ++text; } @@ -812,7 +812,7 @@ } break; case 'I': - if (SDL_strncmp (fmt, "I64", 3) == 0) { + if (SDL_strncmp(fmt, "I64", 3) == 0) { fmt += 2; inttype = DO_LONGLONG; } @@ -824,7 +824,7 @@ ++index; } if (text[index] == '0') { - if (SDL_tolower (text[index + 1]) == 'x') { + if (SDL_tolower(text[index + 1]) == 'x') { radix = 16; } else { radix = 8; @@ -836,9 +836,9 @@ #ifdef SDL_HAS_64BIT_TYPE if (inttype == DO_LONGLONG) { Sint64 value; - text += SDL_ScanLongLong (text, radix, &value); + text += SDL_ScanLongLong(text, radix, &value); if (!suppress) { - Sint64 *valuep = va_arg (ap, Sint64 *); + Sint64 *valuep = va_arg(ap, Sint64 *); *valuep = value; ++retval; } @@ -846,24 +846,24 @@ #endif /* SDL_HAS_64BIT_TYPE */ { long value; - text += SDL_ScanLong (text, radix, &value); + text += SDL_ScanLong(text, radix, &value); if (!suppress) { switch (inttype) { case DO_SHORT: { - short *valuep = va_arg (ap, short *); + short *valuep = va_arg(ap, short *); *valuep = (short) value; } break; case DO_INT: { - int *valuep = va_arg (ap, int *); + int *valuep = va_arg(ap, int *); *valuep = (int) value; } break; case DO_LONG: { - long *valuep = va_arg (ap, long *); + long *valuep = va_arg(ap, long *); *valuep = value; } break; @@ -891,10 +891,9 @@ #ifdef SDL_HAS_64BIT_TYPE if (inttype == DO_LONGLONG) { Uint64 value; - text += - SDL_ScanUnsignedLongLong (text, radix, &value); + text += SDL_ScanUnsignedLongLong(text, radix, &value); if (!suppress) { - Uint64 *valuep = va_arg (ap, Uint64 *); + Uint64 *valuep = va_arg(ap, Uint64 *); *valuep = value; ++retval; } @@ -902,24 +901,24 @@ #endif /* SDL_HAS_64BIT_TYPE */ { unsigned long value; - text += SDL_ScanUnsignedLong (text, radix, &value); + text += SDL_ScanUnsignedLong(text, radix, &value); if (!suppress) { switch (inttype) { case DO_SHORT: { - short *valuep = va_arg (ap, short *); + short *valuep = va_arg(ap, short *); *valuep = (short) value; } break; case DO_INT: { - int *valuep = va_arg (ap, int *); + int *valuep = va_arg(ap, int *); *valuep = (int) value; } break; case DO_LONG: { - long *valuep = va_arg (ap, long *); + long *valuep = va_arg(ap, long *); *valuep = value; } break; @@ -935,9 +934,9 @@ case 'p': { uintptr_t value; - text += SDL_ScanUintPtrT (text, 16, &value); + text += SDL_ScanUintPtrT(text, 16, &value); if (!suppress) { - void **valuep = va_arg (ap, void **); + void **valuep = va_arg(ap, void **); *valuep = (void *) value; ++retval; } @@ -947,9 +946,9 @@ case 'f': { double value; - text += SDL_ScanFloat (text, &value); + text += SDL_ScanFloat(text, &value); if (!suppress) { - float *valuep = va_arg (ap, float *); + float *valuep = va_arg(ap, float *); *valuep = (float) value; ++retval; } @@ -958,7 +957,7 @@ break; case 's': if (suppress) { - while (!SDL_isspace (*text)) { + while (!SDL_isspace(*text)) { ++text; if (count) { if (--count == 0) { @@ -967,8 +966,8 @@ } } } else { - char *valuep = va_arg (ap, char *); - while (!SDL_isspace (*text)) { + char *valuep = va_arg(ap, char *); + while (!SDL_isspace(*text)) { *valuep++ = *text++; if (count) { if (--count == 0) { @@ -997,7 +996,7 @@ /* Text didn't match format specifier */ break; } - va_end (ap); + va_end(ap); return retval; } @@ -1005,14 +1004,14 @@ #ifndef HAVE_SNPRINTF int -SDL_snprintf (char *text, size_t maxlen, const char *fmt, ...) +SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...) { va_list ap; int retval; - va_start (ap, fmt); - retval = SDL_vsnprintf (text, maxlen, fmt, ap); - va_end (ap); + va_start(ap, fmt); + retval = SDL_vsnprintf(text, maxlen, fmt, ap); + va_end(ap); return retval; } @@ -1020,73 +1019,73 @@ #ifndef HAVE_VSNPRINTF static size_t -SDL_PrintLong (char *text, long value, int radix, size_t maxlen) +SDL_PrintLong(char *text, long value, int radix, size_t maxlen) { char num[130]; size_t size; - SDL_ltoa (value, num, radix); - size = SDL_strlen (num); + SDL_ltoa(value, num, radix); + size = SDL_strlen(num); if (size >= maxlen) { size = maxlen - 1; } - SDL_strlcpy (text, num, size + 1); + SDL_strlcpy(text, num, size + 1); return size; } static size_t -SDL_PrintUnsignedLong (char *text, unsigned long value, int radix, - size_t maxlen) +SDL_PrintUnsignedLong(char *text, unsigned long value, int radix, + size_t maxlen) { char num[130]; size_t size; - SDL_ultoa (value, num, radix); - size = SDL_strlen (num); + SDL_ultoa(value, num, radix); + size = SDL_strlen(num); if (size >= maxlen) { size = maxlen - 1; } - SDL_strlcpy (text, num, size + 1); + SDL_strlcpy(text, num, size + 1); return size; } #ifdef SDL_HAS_64BIT_TYPE static size_t -SDL_PrintLongLong (char *text, Sint64 value, int radix, size_t maxlen) +SDL_PrintLongLong(char *text, Sint64 value, int radix, size_t maxlen) { char num[130]; size_t size; - SDL_lltoa (value, num, radix); - size = SDL_strlen (num); + SDL_lltoa(value, num, radix); + size = SDL_strlen(num); if (size >= maxlen) { size = maxlen - 1; } - SDL_strlcpy (text, num, size + 1); + SDL_strlcpy(text, num, size + 1); return size; } static size_t -SDL_PrintUnsignedLongLong (char *text, Uint64 value, int radix, size_t maxlen) +SDL_PrintUnsignedLongLong(char *text, Uint64 value, int radix, size_t maxlen) { char num[130]; size_t size; - SDL_ulltoa (value, num, radix); - size = SDL_strlen (num); + SDL_ulltoa(value, num, radix); + size = SDL_strlen(num); if (size >= maxlen) { size = maxlen - 1; } - SDL_strlcpy (text, num, size + 1); + SDL_strlcpy(text, num, size + 1); return size; } #endif /* SDL_HAS_64BIT_TYPE */ static size_t -SDL_PrintFloat (char *text, double arg, size_t maxlen) +SDL_PrintFloat(char *text, double arg, size_t maxlen) { char *textstart = text; if (arg) { @@ -1101,7 +1100,7 @@ arg = -arg; } value = (unsigned long) arg; - len = SDL_PrintUnsignedLong (text, value, 10, maxlen); + len = SDL_PrintUnsignedLong(text, value, 10, maxlen); text += len; maxlen -= len; arg -= value; @@ -1110,7 +1109,7 @@ *text++ = '.'; while ((arg > precision) && maxlen) { value = (unsigned long) (arg * mult); - len = SDL_PrintUnsignedLong (text, value, 10, maxlen); + len = SDL_PrintUnsignedLong(text, value, 10, maxlen); text += len; maxlen -= len; arg -= (double) value / mult; @@ -1124,7 +1123,7 @@ } static size_t -SDL_PrintString (char *text, const char *string, size_t maxlen) +SDL_PrintString(char *text, const char *string, size_t maxlen) { char *textstart = text; while (*string && maxlen--) { @@ -1134,7 +1133,7 @@ } int -SDL_vsnprintf (char *text, size_t maxlen, const char *fmt, va_list ap) +SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap) { char *textstart = text; if (maxlen <= 0) { @@ -1168,7 +1167,7 @@ break; case 'c': /* char is promoted to int when passed through (...) */ - *text = (char) va_arg (ap, int); + *text = (char) va_arg(ap, int); len = 1; done = SDL_TRUE; break; @@ -1181,7 +1180,7 @@ } break; case 'I': - if (SDL_strncmp (fmt, "I64", 3) == 0) { + if (SDL_strncmp(fmt, "I64", 3) == 0) { fmt += 2; inttype = DO_LONGLONG; } @@ -1191,25 +1190,25 @@ switch (inttype) { case DO_INT: len = - SDL_PrintLong (text, - (long) va_arg (ap, int), - radix, maxlen); + SDL_PrintLong(text, + (long) va_arg(ap, int), + radix, maxlen); break; case DO_LONG: len = - SDL_PrintLong (text, va_arg (ap, long), - radix, maxlen); + SDL_PrintLong(text, va_arg(ap, long), + radix, maxlen); break; case DO_LONGLONG: #ifdef SDL_HAS_64BIT_TYPE len = - SDL_PrintLongLong (text, - va_arg (ap, Sint64), - radix, maxlen); + SDL_PrintLongLong(text, + va_arg(ap, Sint64), + radix, maxlen); #else len = - SDL_PrintLong (text, va_arg (ap, long), - radix, maxlen); + SDL_PrintLong(text, va_arg(ap, long), + radix, maxlen); #endif break; } @@ -1235,48 +1234,48 @@ case 'u': switch (inttype) { case DO_INT: - len = SDL_PrintUnsignedLong (text, (unsigned long) - va_arg (ap, - unsigned - int), - radix, maxlen); + len = SDL_PrintUnsignedLong(text, (unsigned long) + va_arg(ap, + unsigned + int), + radix, maxlen); break; case DO_LONG: len = - SDL_PrintUnsignedLong (text, - va_arg (ap, - unsigned - long), - radix, maxlen); + SDL_PrintUnsignedLong(text, + va_arg(ap, + unsigned + long), + radix, maxlen); break; case DO_LONGLONG: #ifdef SDL_HAS_64BIT_TYPE len = - SDL_PrintUnsignedLongLong (text, - va_arg (ap, - Uint64), - radix, maxlen); + SDL_PrintUnsignedLongLong(text, + va_arg(ap, + Uint64), + radix, maxlen); #else len = - SDL_PrintUnsignedLong (text, - va_arg (ap, - unsigned - long), - radix, maxlen); + SDL_PrintUnsignedLong(text, + va_arg(ap, + unsigned + long), + radix, maxlen); #endif break; } if (do_lowercase) { - SDL_strlwr (text); + SDL_strlwr(text); } done = SDL_TRUE; break; case 'f': - len = SDL_PrintFloat (text, va_arg (ap, double), maxlen); + len = SDL_PrintFloat(text, va_arg(ap, double), maxlen); done = SDL_TRUE; break; case 's': - len = SDL_PrintString (text, va_arg (ap, char *), maxlen); + len = SDL_PrintString(text, va_arg(ap, char *), maxlen); done = SDL_TRUE; break; default: diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/SDL_systhread.h --- a/src/thread/SDL_systhread.h Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/SDL_systhread.h Mon May 29 04:04:35 2006 +0000 @@ -33,23 +33,23 @@ on success. */ #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD -extern int SDL_SYS_CreateThread (SDL_Thread * thread, void *args, - pfnSDL_CurrentBeginThread pfnBeginThread, - pfnSDL_CurrentEndThread pfnEndThread); +extern int SDL_SYS_CreateThread(SDL_Thread * thread, void *args, + pfnSDL_CurrentBeginThread pfnBeginThread, + pfnSDL_CurrentEndThread pfnEndThread); #else -extern int SDL_SYS_CreateThread (SDL_Thread * thread, void *args); +extern int SDL_SYS_CreateThread(SDL_Thread * thread, void *args); #endif /* This function does any necessary setup in the child thread */ -extern void SDL_SYS_SetupThread (void); +extern void SDL_SYS_SetupThread(void); /* This function waits for the thread to finish and frees any data allocated by SDL_SYS_CreateThread() */ -extern void SDL_SYS_WaitThread (SDL_Thread * thread); +extern void SDL_SYS_WaitThread(SDL_Thread * thread); /* This function kills the thread and returns */ -extern void SDL_SYS_KillThread (SDL_Thread * thread); +extern void SDL_SYS_KillThread(SDL_Thread * thread); #endif /* _SDL_systhread_h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/SDL_thread.c --- a/src/thread/SDL_thread.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/SDL_thread.c Mon May 29 04:04:35 2006 +0000 @@ -39,12 +39,12 @@ static SDL_mutex *thread_lock = NULL; int -SDL_ThreadsInit (void) +SDL_ThreadsInit(void) { int retval; retval = 0; - thread_lock = SDL_CreateMutex (); + thread_lock = SDL_CreateMutex(); if (thread_lock == NULL) { retval = -1; } @@ -57,20 +57,20 @@ they will no longer have access to any per-thread data. */ void -SDL_ThreadsQuit (void) +SDL_ThreadsQuit(void) { SDL_mutex *mutex; mutex = thread_lock; thread_lock = NULL; if (mutex != NULL) { - SDL_DestroyMutex (mutex); + SDL_DestroyMutex(mutex); } } /* Routines for manipulating the thread list */ static void -SDL_AddThread (SDL_Thread * thread) +SDL_AddThread(SDL_Thread * thread) { /* WARNING: If the very first threads are created simultaneously, then @@ -79,25 +79,25 @@ is only one thread running the first time this is called. */ if (!thread_lock) { - if (SDL_ThreadsInit () < 0) { + if (SDL_ThreadsInit() < 0) { return; } } - SDL_mutexP (thread_lock); + SDL_mutexP(thread_lock); /* Expand the list of threads, if necessary */ #ifdef DEBUG_THREADS - printf ("Adding thread (%d already - %d max)\n", - SDL_numthreads, SDL_maxthreads); + printf("Adding thread (%d already - %d max)\n", + SDL_numthreads, SDL_maxthreads); #endif if (SDL_numthreads == SDL_maxthreads) { SDL_Thread **threads; - threads = (SDL_Thread **) SDL_realloc (SDL_Threads, - (SDL_maxthreads + - ARRAY_CHUNKSIZE) * - (sizeof *threads)); + threads = (SDL_Thread **) SDL_realloc(SDL_Threads, + (SDL_maxthreads + + ARRAY_CHUNKSIZE) * + (sizeof *threads)); if (threads == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); goto done; } SDL_maxthreads += ARRAY_CHUNKSIZE; @@ -105,18 +105,18 @@ } SDL_Threads[SDL_numthreads++] = thread; done: - SDL_mutexV (thread_lock); + SDL_mutexV(thread_lock); } static void -SDL_DelThread (SDL_Thread * thread) +SDL_DelThread(SDL_Thread * thread) { int i; if (!thread_lock) { return; } - SDL_mutexP (thread_lock); + SDL_mutexP(thread_lock); for (i = 0; i < SDL_numthreads; ++i) { if (thread == SDL_Threads[i]) { break; @@ -130,18 +130,18 @@ } } else { SDL_maxthreads = 0; - SDL_free (SDL_Threads); + SDL_free(SDL_Threads); SDL_Threads = NULL; } #ifdef DEBUG_THREADS - printf ("Deleting thread (%d left - %d max)\n", - SDL_numthreads, SDL_maxthreads); + printf("Deleting thread (%d left - %d max)\n", + SDL_numthreads, SDL_maxthreads); #endif } - SDL_mutexV (thread_lock); + SDL_mutexV(thread_lock); if (SDL_Threads == NULL) { - SDL_ThreadsQuit (); + SDL_ThreadsQuit(); } } @@ -150,7 +150,7 @@ /* Routine to get the thread-specific error variable */ SDL_error * -SDL_GetErrBuf (void) +SDL_GetErrBuf(void) { SDL_error *errbuf; @@ -159,15 +159,15 @@ int i; Uint32 this_thread; - this_thread = SDL_ThreadID (); - SDL_mutexP (thread_lock); + this_thread = SDL_ThreadID(); + SDL_mutexP(thread_lock); for (i = 0; i < SDL_numthreads; ++i) { if (this_thread == SDL_Threads[i]->threadid) { errbuf = &SDL_Threads[i]->errbuf; break; } } - SDL_mutexV (thread_lock); + SDL_mutexV(thread_lock); } return (errbuf); } @@ -183,7 +183,7 @@ } thread_args; void -SDL_RunThread (void *data) +SDL_RunThread(void *data) { thread_args *args; int (SDLCALL * userfunc) (void *); @@ -193,11 +193,11 @@ /* Perform any system-dependent setup - this function cannot fail, and cannot use SDL_SetError() */ - SDL_SYS_SetupThread (); + SDL_SYS_SetupThread(); /* Get the thread id */ args = (thread_args *) data; - args->info->threadid = SDL_ThreadID (); + args->info->threadid = SDL_ThreadID(); /* Figure out what function to run */ userfunc = args->func; @@ -205,21 +205,21 @@ statusloc = &args->info->status; /* Wake up the parent thread */ - SDL_SemPost (args->wait); + SDL_SemPost(args->wait); /* Run the function */ - *statusloc = userfunc (userdata); + *statusloc = userfunc(userdata); } #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD #undef SDL_CreateThread DECLSPEC SDL_Thread *SDLCALL -SDL_CreateThread (int (SDLCALL * fn) (void *), void *data, - pfnSDL_CurrentBeginThread pfnBeginThread, - pfnSDL_CurrentEndThread pfnEndThread) +SDL_CreateThread(int (SDLCALL * fn) (void *), void *data, + pfnSDL_CurrentBeginThread pfnBeginThread, + pfnSDL_CurrentEndThread pfnEndThread) #else DECLSPEC SDL_Thread *SDLCALL -SDL_CreateThread (int (SDLCALL * fn) (void *), void *data) +SDL_CreateThread(int (SDLCALL * fn) (void *), void *data) #endif { SDL_Thread *thread; @@ -227,88 +227,88 @@ int ret; /* Allocate memory for the thread info structure */ - thread = (SDL_Thread *) SDL_malloc (sizeof (*thread)); + thread = (SDL_Thread *) SDL_malloc(sizeof(*thread)); if (thread == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } - SDL_memset (thread, 0, (sizeof *thread)); + SDL_memset(thread, 0, (sizeof *thread)); thread->status = -1; /* Set up the arguments for the thread */ - args = (thread_args *) SDL_malloc (sizeof (*args)); + args = (thread_args *) SDL_malloc(sizeof(*args)); if (args == NULL) { - SDL_OutOfMemory (); - SDL_free (thread); + SDL_OutOfMemory(); + SDL_free(thread); return (NULL); } args->func = fn; args->data = data; args->info = thread; - args->wait = SDL_CreateSemaphore (0); + args->wait = SDL_CreateSemaphore(0); if (args->wait == NULL) { - SDL_free (thread); - SDL_free (args); + SDL_free(thread); + SDL_free(args); return (NULL); } /* Add the thread to the list of available threads */ - SDL_AddThread (thread); + SDL_AddThread(thread); /* Create the thread and go! */ #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD - ret = SDL_SYS_CreateThread (thread, args, pfnBeginThread, pfnEndThread); + ret = SDL_SYS_CreateThread(thread, args, pfnBeginThread, pfnEndThread); #else - ret = SDL_SYS_CreateThread (thread, args); + ret = SDL_SYS_CreateThread(thread, args); #endif if (ret >= 0) { /* Wait for the thread function to use arguments */ - SDL_SemWait (args->wait); + SDL_SemWait(args->wait); } else { /* Oops, failed. Gotta free everything */ - SDL_DelThread (thread); - SDL_free (thread); + SDL_DelThread(thread); + SDL_free(thread); thread = NULL; } - SDL_DestroySemaphore (args->wait); - SDL_free (args); + SDL_DestroySemaphore(args->wait); + SDL_free(args); /* Everything is running now */ return (thread); } void -SDL_WaitThread (SDL_Thread * thread, int *status) +SDL_WaitThread(SDL_Thread * thread, int *status) { if (thread) { - SDL_SYS_WaitThread (thread); + SDL_SYS_WaitThread(thread); if (status) { *status = thread->status; } - SDL_DelThread (thread); - SDL_free (thread); + SDL_DelThread(thread); + SDL_free(thread); } } Uint32 -SDL_GetThreadID (SDL_Thread * thread) +SDL_GetThreadID(SDL_Thread * thread) { Uint32 id; if (thread) { id = thread->threadid; } else { - id = SDL_ThreadID (); + id = SDL_ThreadID(); } return (id); } void -SDL_KillThread (SDL_Thread * thread) +SDL_KillThread(SDL_Thread * thread) { if (thread) { - SDL_SYS_KillThread (thread); - SDL_WaitThread (thread, NULL); + SDL_SYS_KillThread(thread); + SDL_WaitThread(thread, NULL); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/SDL_thread_c.h --- a/src/thread/SDL_thread_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/SDL_thread_c.h Mon May 29 04:04:35 2006 +0000 @@ -62,7 +62,7 @@ }; /* This is the function called to run a thread */ -extern void SDL_RunThread (void *data); +extern void SDL_RunThread(void *data); #endif /* _SDL_thread_c_h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/amigaos/SDL_syssem.c --- a/src/thread/amigaos/SDL_syssem.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/amigaos/SDL_syssem.c Mon May 29 04:04:35 2006 +0000 @@ -37,74 +37,74 @@ #define D(x) SDL_sem * -SDL_CreateSemaphore (Uint32 initial_value) +SDL_CreateSemaphore(Uint32 initial_value) { SDL_sem *sem; - sem = (SDL_sem *) SDL_malloc (sizeof (*sem)); + sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); if (!sem) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (0); } - D (bug ("Creating semaphore %lx...\n", sem)); + D(bug("Creating semaphore %lx...\n", sem)); - SDL_memset (sem, 0, sizeof (*sem)); + SDL_memset(sem, 0, sizeof(*sem)); - InitSemaphore (&sem->Sem); + InitSemaphore(&sem->Sem); return (sem); } void -SDL_DestroySemaphore (SDL_sem * sem) +SDL_DestroySemaphore(SDL_sem * sem) { - D (bug ("Destroying semaphore %lx...\n", sem)); + D(bug("Destroying semaphore %lx...\n", sem)); if (sem) { // Condizioni per liberare i task in attesa? - SDL_free (sem); + SDL_free(sem); } } int -SDL_SemTryWait (SDL_sem * sem) +SDL_SemTryWait(SDL_sem * sem) { if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } - D (bug ("TryWait semaphore...%lx\n", sem)); + D(bug("TryWait semaphore...%lx\n", sem)); - ObtainSemaphore (&sem->Sem); + ObtainSemaphore(&sem->Sem); // ReleaseSemaphore(&sem->Sem); return 1; } int -SDL_SemWaitTimeout (SDL_sem * sem, Uint32 timeout) +SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } - D (bug ("WaitTimeout (%ld) semaphore...%lx\n", timeout, sem)); + D(bug("WaitTimeout (%ld) semaphore...%lx\n", timeout, sem)); /* A timeout of 0 is an easy case */ if (timeout == 0) { - ObtainSemaphore (&sem->Sem); + ObtainSemaphore(&sem->Sem); return 1; } - if (!(retval = AttemptSemaphore (&sem->Sem))) { - SDL_Delay (timeout); - retval = AttemptSemaphore (&sem->Sem); + if (!(retval = AttemptSemaphore(&sem->Sem))) { + SDL_Delay(timeout); + retval = AttemptSemaphore(&sem->Sem); } if (retval == TRUE) { @@ -116,14 +116,14 @@ } int -SDL_SemWait (SDL_sem * sem) +SDL_SemWait(SDL_sem * sem) { - ObtainSemaphore (&sem->Sem); + ObtainSemaphore(&sem->Sem); return 0; } Uint32 -SDL_SemValue (SDL_sem * sem) +SDL_SemValue(SDL_sem * sem) { Uint32 value; @@ -139,15 +139,15 @@ } int -SDL_SemPost (SDL_sem * sem) +SDL_SemPost(SDL_sem * sem) { if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } - D (bug ("SemPost semaphore...%lx\n", sem)); + D(bug("SemPost semaphore...%lx\n", sem)); - ReleaseSemaphore (&sem->Sem); + ReleaseSemaphore(&sem->Sem); return 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/amigaos/SDL_systhread.c --- a/src/thread/amigaos/SDL_systhread.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/amigaos/SDL_systhread.c Mon May 29 04:04:35 2006 +0000 @@ -41,30 +41,30 @@ #if defined(__SASC) && !defined(__PPC__) __saveds __asm Uint32 -RunThread (register __a0 char *args) +RunThread(register __a0 char *args) #elif defined(__PPC__) Uint32 -RunThread (char *args) +RunThread(char *args) #else Uint32 __saveds -RunThread (char *args __asm ("a0")) +RunThread(char *args __asm("a0")) #endif { #ifdef STORMC4_WOS thread_args *data = (thread_args *) args; #else - thread_args *data = (thread_args *) atol (args); + thread_args *data = (thread_args *) atol(args); #endif struct Task *Father; - D (bug ("Received data: %lx\n", data)); + D(bug("Received data: %lx\n", data)); Father = data->wait; - SDL_RunThread (data); + SDL_RunThread(data); - Signal (Father, SIGBREAKF_CTRL_F); - D (bug ("Thread with data %lx ended\n", data)); + Signal(Father, SIGBREAKF_CTRL_F); + D(bug("Thread with data %lx ended\n", data)); return (0); } @@ -73,18 +73,18 @@ #include Uint32 -RunTheThread (void) +RunTheThread(void) { - thread_args *data = (thread_args *) atol ((char *) REG_A0); + thread_args *data = (thread_args *) atol((char *) REG_A0); struct Task *Father; - D (bug ("Received data: %lx\n", data)); + D(bug("Received data: %lx\n", data)); Father = data->wait; - SDL_RunThread (data); + SDL_RunThread(data); - Signal (Father, SIGBREAKF_CTRL_F); - D (bug ("Thread with data %lx ended\n", data)); + Signal(Father, SIGBREAKF_CTRL_F); + D(bug("Thread with data %lx ended\n", data)); return (0); } @@ -99,39 +99,39 @@ int -SDL_SYS_CreateThread (SDL_Thread * thread, void *args) +SDL_SYS_CreateThread(SDL_Thread * thread, void *args) { /* Create the thread and go! */ char buffer[20]; - D (bug ("Sending %lx to the new thread...\n", args)); + D(bug("Sending %lx to the new thread...\n", args)); if (args) - SDL_snprintf (buffer, SDL_arraysize (buffer), "%ld", args); + SDL_snprintf(buffer, SDL_arraysize(buffer), "%ld", args); #ifdef STORMC4_WOS - thread->handle = CreateTaskPPCTags (TASKATTR_CODE, RunThread, - TASKATTR_NAME, "SDL subtask", - TASKATTR_STACKSIZE, 100000, - (args ? TASKATTR_R3 : TAG_IGNORE), - args, TASKATTR_INHERITR2, TRUE, - TAG_DONE); + thread->handle = CreateTaskPPCTags(TASKATTR_CODE, RunThread, + TASKATTR_NAME, "SDL subtask", + TASKATTR_STACKSIZE, 100000, + (args ? TASKATTR_R3 : TAG_IGNORE), + args, TASKATTR_INHERITR2, TRUE, + TAG_DONE); #else - thread->handle = (struct Task *) CreateNewProcTags (NP_Output, Output (), - NP_Name, - (ULONG) "SDL subtask", - NP_CloseOutput, FALSE, - NP_StackSize, 20000, - NP_Entry, - (ULONG) RunThread, - args ? NP_Arguments : - TAG_IGNORE, - (ULONG) buffer, - TAG_DONE); + thread->handle = (struct Task *) CreateNewProcTags(NP_Output, Output(), + NP_Name, + (ULONG) "SDL subtask", + NP_CloseOutput, FALSE, + NP_StackSize, 20000, + NP_Entry, + (ULONG) RunThread, + args ? NP_Arguments : + TAG_IGNORE, + (ULONG) buffer, + TAG_DONE); #endif if (!thread->handle) { - SDL_SetError ("Not enough resources to create thread"); + SDL_SetError("Not enough resources to create thread"); return (-1); } @@ -139,27 +139,27 @@ } void -SDL_SYS_SetupThread (void) +SDL_SYS_SetupThread(void) { } Uint32 -SDL_ThreadID (void) +SDL_ThreadID(void) { - return ((Uint32) FindTask (NULL)); + return ((Uint32) FindTask(NULL)); } void -SDL_SYS_WaitThread (SDL_Thread * thread) +SDL_SYS_WaitThread(SDL_Thread * thread) { - SetSignal (0L, SIGBREAKF_CTRL_F | SIGBREAKF_CTRL_C); - Wait (SIGBREAKF_CTRL_F | SIGBREAKF_CTRL_C); + SetSignal(0L, SIGBREAKF_CTRL_F | SIGBREAKF_CTRL_C); + Wait(SIGBREAKF_CTRL_F | SIGBREAKF_CTRL_C); } void -SDL_SYS_KillThread (SDL_Thread * thread) +SDL_SYS_KillThread(SDL_Thread * thread) { - Signal ((struct Task *) thread->handle, SIGBREAKF_CTRL_C); + Signal((struct Task *) thread->handle, SIGBREAKF_CTRL_C); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/amigaos/SDL_thread.c --- a/src/thread/amigaos/SDL_thread.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/amigaos/SDL_thread.c Mon May 29 04:04:35 2006 +0000 @@ -40,9 +40,9 @@ int thread_lock_created = 0; int -SDL_ThreadsInit (void) +SDL_ThreadsInit(void) { - InitSemaphore (&thread_lock); + InitSemaphore(&thread_lock); thread_lock_created = 1; return 0; } @@ -53,14 +53,14 @@ they will no longer have access to any per-thread data. */ void -SDL_ThreadsQuit () +SDL_ThreadsQuit() { thread_lock_created = 0; } /* Routines for manipulating the thread list */ static void -SDL_AddThread (SDL_Thread * thread) +SDL_AddThread(SDL_Thread * thread) { SDL_Thread **threads; @@ -71,44 +71,44 @@ is only one thread running the first time this is called. */ if (!thread_lock_created) { - if (SDL_ThreadsInit () < 0) { + if (SDL_ThreadsInit() < 0) { return; } } - ObtainSemaphore (&thread_lock); + ObtainSemaphore(&thread_lock); /* Expand the list of threads, if necessary */ #ifdef DEBUG_THREADS - printf ("Adding thread (%d already - %d max)\n", - SDL_numthreads, SDL_maxthreads); + printf("Adding thread (%d already - %d max)\n", + SDL_numthreads, SDL_maxthreads); #endif if (SDL_numthreads == SDL_maxthreads) { threads = - (SDL_Thread **) SDL_malloc ((SDL_maxthreads + ARRAY_CHUNKSIZE) * - (sizeof *threads)); + (SDL_Thread **) SDL_malloc((SDL_maxthreads + ARRAY_CHUNKSIZE) * + (sizeof *threads)); if (threads == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); goto done; } - SDL_memcpy (threads, SDL_Threads, SDL_numthreads * (sizeof *threads)); + SDL_memcpy(threads, SDL_Threads, SDL_numthreads * (sizeof *threads)); SDL_maxthreads += ARRAY_CHUNKSIZE; if (SDL_Threads) { - SDL_free (SDL_Threads); + SDL_free(SDL_Threads); } SDL_Threads = threads; } SDL_Threads[SDL_numthreads++] = thread; done: - ReleaseSemaphore (&thread_lock); + ReleaseSemaphore(&thread_lock); } static void -SDL_DelThread (SDL_Thread * thread) +SDL_DelThread(SDL_Thread * thread) { int i; if (thread_lock_created) { - ObtainSemaphore (&thread_lock); + ObtainSemaphore(&thread_lock); for (i = 0; i < SDL_numthreads; ++i) { if (thread == SDL_Threads[i]) { break; @@ -121,11 +121,11 @@ ++i; } #ifdef DEBUG_THREADS - printf ("Deleting thread (%d left - %d max)\n", - SDL_numthreads, SDL_maxthreads); + printf("Deleting thread (%d left - %d max)\n", + SDL_numthreads, SDL_maxthreads); #endif } - ReleaseSemaphore (&thread_lock); + ReleaseSemaphore(&thread_lock); } } @@ -134,7 +134,7 @@ /* Routine to get the thread-specific error variable */ SDL_error * -SDL_GetErrBuf (void) +SDL_GetErrBuf(void) { SDL_error *errbuf; @@ -143,15 +143,15 @@ int i; Uint32 this_thread; - this_thread = SDL_ThreadID (); - ObtainSemaphore (&thread_lock); + this_thread = SDL_ThreadID(); + ObtainSemaphore(&thread_lock); for (i = 0; i < SDL_numthreads; ++i) { if (this_thread == SDL_Threads[i]->threadid) { errbuf = &SDL_Threads[i]->errbuf; break; } } - ReleaseSemaphore (&thread_lock); + ReleaseSemaphore(&thread_lock); } return (errbuf); } @@ -167,7 +167,7 @@ } thread_args; void -SDL_RunThread (void *data) +SDL_RunThread(void *data) { thread_args *args; int (*userfunc) (void *); @@ -177,11 +177,11 @@ /* Perform any system-dependent setup - this function cannot fail, and cannot use SDL_SetError() */ - SDL_SYS_SetupThread (); + SDL_SYS_SetupThread(); /* Get the thread id */ args = (thread_args *) data; - args->info->threadid = SDL_ThreadID (); + args->info->threadid = SDL_ThreadID(); /* Figure out what function to run */ userfunc = args->func; @@ -189,102 +189,102 @@ statusloc = &args->info->status; /* Wake up the parent thread */ - Signal (args->wait, SIGBREAKF_CTRL_E); + Signal(args->wait, SIGBREAKF_CTRL_E); /* Run the function */ - *statusloc = userfunc (userdata); + *statusloc = userfunc(userdata); } SDL_Thread * -SDL_CreateThread (int (*fn) (void *), void *data) +SDL_CreateThread(int (*fn) (void *), void *data) { SDL_Thread *thread; thread_args *args; int ret; /* Allocate memory for the thread info structure */ - thread = (SDL_Thread *) SDL_malloc (sizeof (*thread)); + thread = (SDL_Thread *) SDL_malloc(sizeof(*thread)); if (thread == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } - SDL_memset (thread, 0, (sizeof *thread)); + SDL_memset(thread, 0, (sizeof *thread)); thread->status = -1; /* Set up the arguments for the thread */ - args = (thread_args *) SDL_malloc (sizeof (*args)); + args = (thread_args *) SDL_malloc(sizeof(*args)); if (args == NULL) { - SDL_OutOfMemory (); - SDL_free (thread); + SDL_OutOfMemory(); + SDL_free(thread); return (NULL); } args->func = fn; args->data = data; args->info = thread; - args->wait = FindTask (NULL); + args->wait = FindTask(NULL); if (args->wait == NULL) { - SDL_free (thread); - SDL_free (args); - SDL_OutOfMemory (); + SDL_free(thread); + SDL_free(args); + SDL_OutOfMemory(); return (NULL); } /* Add the thread to the list of available threads */ - SDL_AddThread (thread); + SDL_AddThread(thread); - D (bug ("Starting thread...\n")); + D(bug("Starting thread...\n")); /* Create the thread and go! */ - ret = SDL_SYS_CreateThread (thread, args); + ret = SDL_SYS_CreateThread(thread, args); if (ret >= 0) { - D (bug ("Waiting for thread CTRL_E...\n")); + D(bug("Waiting for thread CTRL_E...\n")); /* Wait for the thread function to use arguments */ - Wait (SIGBREAKF_CTRL_E); - D (bug (" Arrived.")); + Wait(SIGBREAKF_CTRL_E); + D(bug(" Arrived.")); } else { /* Oops, failed. Gotta free everything */ - SDL_DelThread (thread); - SDL_free (thread); + SDL_DelThread(thread); + SDL_free(thread); thread = NULL; } - SDL_free (args); + SDL_free(args); /* Everything is running now */ return (thread); } void -SDL_WaitThread (SDL_Thread * thread, int *status) +SDL_WaitThread(SDL_Thread * thread, int *status) { if (thread) { - SDL_SYS_WaitThread (thread); + SDL_SYS_WaitThread(thread); if (status) { *status = thread->status; } - SDL_DelThread (thread); - SDL_free (thread); + SDL_DelThread(thread); + SDL_free(thread); } } Uint32 -SDL_GetThreadID (SDL_Thread * thread) +SDL_GetThreadID(SDL_Thread * thread) { Uint32 id; if (thread) { id = thread->threadid; } else { - id = SDL_ThreadID (); + id = SDL_ThreadID(); } return (id); } void -SDL_KillThread (SDL_Thread * thread) +SDL_KillThread(SDL_Thread * thread) { if (thread) { - SDL_SYS_KillThread (thread); - SDL_WaitThread (thread, NULL); + SDL_SYS_KillThread(thread); + SDL_WaitThread(thread, NULL); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/beos/SDL_syssem.c --- a/src/thread/beos/SDL_syssem.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/beos/SDL_syssem.c Mon May 29 04:04:35 2006 +0000 @@ -35,53 +35,53 @@ /* Create a counting semaphore */ SDL_sem * -SDL_CreateSemaphore (Uint32 initial_value) +SDL_CreateSemaphore(Uint32 initial_value) { SDL_sem *sem; - sem = (SDL_sem *) SDL_malloc (sizeof (*sem)); + sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); if (sem) { - sem->id = create_sem (initial_value, "SDL semaphore"); + sem->id = create_sem(initial_value, "SDL semaphore"); if (sem->id < B_NO_ERROR) { - SDL_SetError ("create_sem() failed"); - SDL_free (sem); + SDL_SetError("create_sem() failed"); + SDL_free(sem); sem = NULL; } } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return (sem); } /* Free the semaphore */ void -SDL_DestroySemaphore (SDL_sem * sem) +SDL_DestroySemaphore(SDL_sem * sem) { if (sem) { if (sem->id >= B_NO_ERROR) { - delete_sem (sem->id); + delete_sem(sem->id); } - SDL_free (sem); + SDL_free(sem); } } int -SDL_SemWaitTimeout (SDL_sem * sem, Uint32 timeout) +SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) { int32 val; int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } tryagain: if (timeout == SDL_MUTEX_MAXWAIT) { - val = acquire_sem (sem->id); + val = acquire_sem(sem->id); } else { timeout *= 1000; /* BeOS uses a timeout in microseconds */ - val = acquire_sem_etc (sem->id, 1, B_RELATIVE_TIMEOUT, timeout); + val = acquire_sem_etc(sem->id, 1, B_RELATIVE_TIMEOUT, timeout); } switch (val) { case B_INTERRUPTED: @@ -96,7 +96,7 @@ retval = SDL_MUTEX_TIMEDOUT; break; default: - SDL_SetError ("acquire_sem() failed"); + SDL_SetError("acquire_sem() failed"); retval = -1; break; } @@ -105,27 +105,27 @@ } int -SDL_SemTryWait (SDL_sem * sem) +SDL_SemTryWait(SDL_sem * sem) { - return SDL_SemWaitTimeout (sem, 0); + return SDL_SemWaitTimeout(sem, 0); } int -SDL_SemWait (SDL_sem * sem) +SDL_SemWait(SDL_sem * sem) { - return SDL_SemWaitTimeout (sem, SDL_MUTEX_MAXWAIT); + return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); } /* Returns the current count of the semaphore */ Uint32 -SDL_SemValue (SDL_sem * sem) +SDL_SemValue(SDL_sem * sem) { int32 count; Uint32 value; value = 0; if (sem) { - get_sem_count (sem->id, &count); + get_sem_count(sem->id, &count); if (count > 0) { value = (Uint32) count; } @@ -135,15 +135,15 @@ /* Atomically increases the semaphore's count (not blocking) */ int -SDL_SemPost (SDL_sem * sem) +SDL_SemPost(SDL_sem * sem) { if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } - if (release_sem (sem->id) != B_NO_ERROR) { - SDL_SetError ("release_sem() failed"); + if (release_sem(sem->id) != B_NO_ERROR) { + SDL_SetError("release_sem() failed"); return -1; } return 0; diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/beos/SDL_systhread.c --- a/src/thread/beos/SDL_systhread.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/beos/SDL_systhread.c Mon May 29 04:04:35 2006 +0000 @@ -38,70 +38,70 @@ }; void -SDL_MaskSignals (sigset_t * omask) +SDL_MaskSignals(sigset_t * omask) { sigset_t mask; int i; - sigemptyset (&mask); + sigemptyset(&mask); for (i = 0; sig_list[i]; ++i) { - sigaddset (&mask, sig_list[i]); + sigaddset(&mask, sig_list[i]); } - sigprocmask (SIG_BLOCK, &mask, omask); + sigprocmask(SIG_BLOCK, &mask, omask); } void -SDL_UnmaskSignals (sigset_t * omask) +SDL_UnmaskSignals(sigset_t * omask) { - sigprocmask (SIG_SETMASK, omask, NULL); + sigprocmask(SIG_SETMASK, omask, NULL); } static int32 -RunThread (void *data) +RunThread(void *data) { - SDL_RunThread (data); + SDL_RunThread(data); return (0); } int -SDL_SYS_CreateThread (SDL_Thread * thread, void *args) +SDL_SYS_CreateThread(SDL_Thread * thread, void *args) { /* Create the thread and go! */ - thread->handle = spawn_thread (RunThread, "SDL", B_NORMAL_PRIORITY, args); + thread->handle = spawn_thread(RunThread, "SDL", B_NORMAL_PRIORITY, args); if ((thread->handle == B_NO_MORE_THREADS) || (thread->handle == B_NO_MEMORY)) { - SDL_SetError ("Not enough resources to create thread"); + SDL_SetError("Not enough resources to create thread"); return (-1); } - resume_thread (thread->handle); + resume_thread(thread->handle); return (0); } void -SDL_SYS_SetupThread (void) +SDL_SYS_SetupThread(void) { /* Mask asynchronous signals for this thread */ - SDL_MaskSignals (NULL); + SDL_MaskSignals(NULL); } Uint32 -SDL_ThreadID (void) +SDL_ThreadID(void) { - return ((Uint32) find_thread (NULL)); + return ((Uint32) find_thread(NULL)); } void -SDL_SYS_WaitThread (SDL_Thread * thread) +SDL_SYS_WaitThread(SDL_Thread * thread) { status_t the_status; - wait_for_thread (thread->handle, &the_status); + wait_for_thread(thread->handle, &the_status); } void -SDL_SYS_KillThread (SDL_Thread * thread) +SDL_SYS_KillThread(SDL_Thread * thread) { - kill_thread (thread->handle); + kill_thread(thread->handle); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/beos/SDL_systhread_c.h --- a/src/thread/beos/SDL_systhread_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/beos/SDL_systhread_c.h Mon May 29 04:04:35 2006 +0000 @@ -27,7 +27,7 @@ typedef thread_id SYS_ThreadHandle; /* Functions needed to work with system threads in other portions of SDL */ -extern void SDL_MaskSignals (sigset_t * omask); -extern void SDL_UnmaskSignals (sigset_t * omask); +extern void SDL_MaskSignals(sigset_t * omask); +extern void SDL_UnmaskSignals(sigset_t * omask); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/dc/SDL_syscond.c --- a/src/thread/dc/SDL_syscond.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/dc/SDL_syscond.c Mon May 29 04:04:35 2006 +0000 @@ -40,64 +40,64 @@ /* Create a condition variable */ SDL_cond * -SDL_CreateCond (void) +SDL_CreateCond(void) { SDL_cond *cond; - cond = (SDL_cond *) SDL_malloc (sizeof (SDL_cond)); + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); if (cond) { - cond->lock = SDL_CreateMutex (); - cond->wait_sem = SDL_CreateSemaphore (0); - cond->wait_done = SDL_CreateSemaphore (0); + cond->lock = SDL_CreateMutex(); + cond->wait_sem = SDL_CreateSemaphore(0); + cond->wait_done = SDL_CreateSemaphore(0); cond->waiting = cond->signals = 0; if (!cond->lock || !cond->wait_sem || !cond->wait_done) { - SDL_DestroyCond (cond); + SDL_DestroyCond(cond); cond = NULL; } } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return (cond); } /* Destroy a condition variable */ void -SDL_DestroyCond (SDL_cond * cond) +SDL_DestroyCond(SDL_cond * cond) { if (cond) { if (cond->wait_sem) { - SDL_DestroySemaphore (cond->wait_sem); + SDL_DestroySemaphore(cond->wait_sem); } if (cond->wait_done) { - SDL_DestroySemaphore (cond->wait_done); + SDL_DestroySemaphore(cond->wait_done); } if (cond->lock) { - SDL_DestroyMutex (cond->lock); + SDL_DestroyMutex(cond->lock); } - SDL_free (cond); + SDL_free(cond); } } /* Restart one of the threads that are waiting on the condition variable */ int -SDL_CondSignal (SDL_cond * cond) +SDL_CondSignal(SDL_cond * cond) { if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } /* If there are waiting threads not already signalled, then signal the condition and wait for the thread to respond. */ - SDL_LockMutex (cond->lock); + SDL_LockMutex(cond->lock); if (cond->waiting > cond->signals) { ++cond->signals; - SDL_SemPost (cond->wait_sem); - SDL_UnlockMutex (cond->lock); - SDL_SemWait (cond->wait_done); + SDL_SemPost(cond->wait_sem); + SDL_UnlockMutex(cond->lock); + SDL_SemWait(cond->wait_done); } else { - SDL_UnlockMutex (cond->lock); + SDL_UnlockMutex(cond->lock); } return 0; @@ -105,34 +105,34 @@ /* Restart all threads that are waiting on the condition variable */ int -SDL_CondBroadcast (SDL_cond * cond) +SDL_CondBroadcast(SDL_cond * cond) { if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } /* If there are waiting threads not already signalled, then signal the condition and wait for the thread to respond. */ - SDL_LockMutex (cond->lock); + SDL_LockMutex(cond->lock); if (cond->waiting > cond->signals) { int i, num_waiting; num_waiting = (cond->waiting - cond->signals); cond->signals = cond->waiting; for (i = 0; i < num_waiting; ++i) { - SDL_SemPost (cond->wait_sem); + SDL_SemPost(cond->wait_sem); } /* Now all released threads are blocked here, waiting for us. Collect them all (and win fabulous prizes!) :-) */ - SDL_UnlockMutex (cond->lock); + SDL_UnlockMutex(cond->lock); for (i = 0; i < num_waiting; ++i) { - SDL_SemWait (cond->wait_done); + SDL_SemWait(cond->wait_done); } } else { - SDL_UnlockMutex (cond->lock); + SDL_UnlockMutex(cond->lock); } return 0; @@ -159,12 +159,12 @@ SDL_UnlockMutex(lock); */ int -SDL_CondWaitTimeout (SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) +SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) { int retval; if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } @@ -172,18 +172,18 @@ This allows the signal mechanism to only perform a signal if there are waiting threads. */ - SDL_LockMutex (cond->lock); + SDL_LockMutex(cond->lock); ++cond->waiting; - SDL_UnlockMutex (cond->lock); + SDL_UnlockMutex(cond->lock); /* Unlock the mutex, as is required by condition variable semantics */ - SDL_UnlockMutex (mutex); + SDL_UnlockMutex(mutex); /* Wait for a signal */ if (ms == SDL_MUTEX_MAXWAIT) { - retval = SDL_SemWait (cond->wait_sem); + retval = SDL_SemWait(cond->wait_sem); } else { - retval = SDL_SemWaitTimeout (cond->wait_sem, ms); + retval = SDL_SemWaitTimeout(cond->wait_sem, ms); } /* Let the signaler know we have completed the wait, otherwise @@ -192,32 +192,32 @@ giving a deadlock. See the following URL for details: http://www-classic.be.com/aboutbe/benewsletter/volume_III/Issue40.html */ - SDL_LockMutex (cond->lock); + SDL_LockMutex(cond->lock); if (cond->signals > 0) { /* If we timed out, we need to eat a condition signal */ if (retval > 0) { - SDL_SemWait (cond->wait_sem); + SDL_SemWait(cond->wait_sem); } /* We always notify the signal thread that we are done */ - SDL_SemPost (cond->wait_done); + SDL_SemPost(cond->wait_done); /* Signal handshake complete */ --cond->signals; } --cond->waiting; - SDL_UnlockMutex (cond->lock); + SDL_UnlockMutex(cond->lock); /* Lock the mutex, as is required by condition variable semantics */ - SDL_LockMutex (mutex); + SDL_LockMutex(mutex); return retval; } /* Wait on the condition variable forever */ int -SDL_CondWait (SDL_cond * cond, SDL_mutex * mutex) +SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) { - return SDL_CondWaitTimeout (cond, mutex, SDL_MUTEX_MAXWAIT); + return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/dc/SDL_sysmutex.c --- a/src/thread/dc/SDL_sysmutex.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/dc/SDL_sysmutex.c Mon May 29 04:04:35 2006 +0000 @@ -37,46 +37,46 @@ /* Create a mutex */ SDL_mutex * -SDL_CreateMutex (void) +SDL_CreateMutex(void) { SDL_mutex *mutex; /* Allocate mutex memory */ - mutex = (SDL_mutex *) SDL_malloc (sizeof (*mutex)); + mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); if (mutex) { - spinlock_init (&mutex->mutex); + spinlock_init(&mutex->mutex); mutex->recursive = 0; mutex->owner = 0; } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return mutex; } /* Free the mutex */ void -SDL_DestroyMutex (SDL_mutex * mutex) +SDL_DestroyMutex(SDL_mutex * mutex) { if (mutex) { - SDL_free (mutex); + SDL_free(mutex); } } /* Lock the semaphore */ int -SDL_mutexP (SDL_mutex * mutex) +SDL_mutexP(SDL_mutex * mutex) { #if SDL_THREADS_DISABLED - return SDL_arraysize (return), 0; + return SDL_arraysize(return), 0; #else Uint32 this_thread; if (mutex == NULL) { - SDL_SetError ("Passed a NULL mutex"); + SDL_SetError("Passed a NULL mutex"); return -1; } - this_thread = SDL_ThreadID (); + this_thread = SDL_ThreadID(); if (mutex->owner == this_thread) { ++mutex->recursive; } else { @@ -84,7 +84,7 @@ We set the locking thread id after we obtain the lock so unlocks from other threads will fail. */ - spinlock_lock (&mutex->mutex); + spinlock_lock(&mutex->mutex); mutex->owner = this_thread; mutex->recursive = 0; } @@ -95,19 +95,19 @@ /* Unlock the mutex */ int -SDL_mutexV (SDL_mutex * mutex) +SDL_mutexV(SDL_mutex * mutex) { #if SDL_THREADS_DISABLED return 0; #else if (mutex == NULL) { - SDL_SetError ("Passed a NULL mutex"); + SDL_SetError("Passed a NULL mutex"); return -1; } /* If we don't own the mutex, we can't unlock it */ - if (SDL_ThreadID () != mutex->owner) { - SDL_SetError ("mutex not owned by this thread"); + if (SDL_ThreadID() != mutex->owner) { + SDL_SetError("mutex not owned by this thread"); return -1; } @@ -120,7 +120,7 @@ then release the lock semaphore. */ mutex->owner = 0; - spinlock_unlock (&mutex->mutex); + spinlock_unlock(&mutex->mutex); } return 0; #endif /* SDL_THREADS_DISABLED */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/dc/SDL_syssem.c --- a/src/thread/dc/SDL_syssem.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/dc/SDL_syssem.c Mon May 29 04:04:35 2006 +0000 @@ -31,49 +31,49 @@ #if SDL_THREADS_DISABLED SDL_sem * -SDL_CreateSemaphore (Uint32 initial_value) +SDL_CreateSemaphore(Uint32 initial_value) { - SDL_SetError ("SDL not configured with thread support"); + SDL_SetError("SDL not configured with thread support"); return (SDL_sem *) 0; } void -SDL_DestroySemaphore (SDL_sem * sem) +SDL_DestroySemaphore(SDL_sem * sem) { return; } int -SDL_SemTryWait (SDL_sem * sem) +SDL_SemTryWait(SDL_sem * sem) { - SDL_SetError ("SDL not configured with thread support"); + SDL_SetError("SDL not configured with thread support"); return -1; } int -SDL_SemWaitTimeout (SDL_sem * sem, Uint32 timeout) +SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) { - SDL_SetError ("SDL not configured with thread support"); + SDL_SetError("SDL not configured with thread support"); return -1; } int -SDL_SemWait (SDL_sem * sem) +SDL_SemWait(SDL_sem * sem) { - SDL_SetError ("SDL not configured with thread support"); + SDL_SetError("SDL not configured with thread support"); return -1; } Uint32 -SDL_SemValue (SDL_sem * sem) +SDL_SemValue(SDL_sem * sem) { return 0; } int -SDL_SemPost (SDL_sem * sem) +SDL_SemPost(SDL_sem * sem) { - SDL_SetError ("SDL not configured with thread support"); + SDL_SetError("SDL not configured with thread support"); return -1; } @@ -87,36 +87,36 @@ }; SDL_sem * -SDL_CreateSemaphore (Uint32 initial_value) +SDL_CreateSemaphore(Uint32 initial_value) { - return (SDL_sem *) sem_create (initial_value); + return (SDL_sem *) sem_create(initial_value); } /* WARNING: You cannot call this function when another thread is using the semaphore. */ void -SDL_DestroySemaphore (SDL_sem * sem) +SDL_DestroySemaphore(SDL_sem * sem) { if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return; } - sem_destroy (&sem->sem); + sem_destroy(&sem->sem); } int -SDL_SemTryWait (SDL_sem * sem) +SDL_SemTryWait(SDL_sem * sem) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } - retval = sem_trywait (&sem->sem); + retval = sem_trywait(&sem->sem); if (retval == 0) return 0; else @@ -126,21 +126,21 @@ } int -SDL_SemWaitTimeout (SDL_sem * sem, Uint32 timeout) +SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } /* A timeout of 0 is an easy case */ if (timeout == 0) { - return SDL_SemTryWait (sem); + return SDL_SemTryWait(sem); } - retval = sem_wait_timed (&sem->sem, timeout); + retval = sem_wait_timed(&sem->sem, timeout); if (retval == -1) retval = SDL_MUTEX_TIMEDOUT; @@ -148,37 +148,37 @@ } int -SDL_SemWait (SDL_sem * sem) +SDL_SemWait(SDL_sem * sem) { if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } - sem_wait (&sem->sem); + sem_wait(&sem->sem); return 0; } Uint32 -SDL_SemValue (SDL_sem * sem) +SDL_SemValue(SDL_sem * sem) { if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } - return sem_count (&sem->sem); + return sem_count(&sem->sem); } int -SDL_SemPost (SDL_sem * sem) +SDL_SemPost(SDL_sem * sem) { if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } - sem_signal (&sem->sem); + sem_signal(&sem->sem); return 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/dc/SDL_systhread.c --- a/src/thread/dc/SDL_systhread.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/dc/SDL_systhread.c Mon May 29 04:04:35 2006 +0000 @@ -30,38 +30,38 @@ #include int -SDL_SYS_CreateThread (SDL_Thread * thread, void *args) +SDL_SYS_CreateThread(SDL_Thread * thread, void *args) { - thread->handle = thd_create (SDL_RunThread, args); + thread->handle = thd_create(SDL_RunThread, args); if (thread->handle == NULL) { - SDL_SetError ("Not enough resources to create thread"); + SDL_SetError("Not enough resources to create thread"); return (-1); } return (0); } void -SDL_SYS_SetupThread (void) +SDL_SYS_SetupThread(void) { return; } Uint32 -SDL_ThreadID (void) +SDL_ThreadID(void) { - return (Uint32) thd_get_current (); + return (Uint32) thd_get_current(); } void -SDL_SYS_WaitThread (SDL_Thread * thread) +SDL_SYS_WaitThread(SDL_Thread * thread) { - thd_wait (thread->handle); + thd_wait(thread->handle); } void -SDL_SYS_KillThread (SDL_Thread * thread) +SDL_SYS_KillThread(SDL_Thread * thread) { - thd_destroy (thread->handle); + thd_destroy(thread->handle); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/generic/SDL_syscond.c --- a/src/thread/generic/SDL_syscond.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/generic/SDL_syscond.c Mon May 29 04:04:35 2006 +0000 @@ -40,64 +40,64 @@ /* Create a condition variable */ SDL_cond * -SDL_CreateCond (void) +SDL_CreateCond(void) { SDL_cond *cond; - cond = (SDL_cond *) SDL_malloc (sizeof (SDL_cond)); + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); if (cond) { - cond->lock = SDL_CreateMutex (); - cond->wait_sem = SDL_CreateSemaphore (0); - cond->wait_done = SDL_CreateSemaphore (0); + cond->lock = SDL_CreateMutex(); + cond->wait_sem = SDL_CreateSemaphore(0); + cond->wait_done = SDL_CreateSemaphore(0); cond->waiting = cond->signals = 0; if (!cond->lock || !cond->wait_sem || !cond->wait_done) { - SDL_DestroyCond (cond); + SDL_DestroyCond(cond); cond = NULL; } } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return (cond); } /* Destroy a condition variable */ void -SDL_DestroyCond (SDL_cond * cond) +SDL_DestroyCond(SDL_cond * cond) { if (cond) { if (cond->wait_sem) { - SDL_DestroySemaphore (cond->wait_sem); + SDL_DestroySemaphore(cond->wait_sem); } if (cond->wait_done) { - SDL_DestroySemaphore (cond->wait_done); + SDL_DestroySemaphore(cond->wait_done); } if (cond->lock) { - SDL_DestroyMutex (cond->lock); + SDL_DestroyMutex(cond->lock); } - SDL_free (cond); + SDL_free(cond); } } /* Restart one of the threads that are waiting on the condition variable */ int -SDL_CondSignal (SDL_cond * cond) +SDL_CondSignal(SDL_cond * cond) { if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } /* If there are waiting threads not already signalled, then signal the condition and wait for the thread to respond. */ - SDL_LockMutex (cond->lock); + SDL_LockMutex(cond->lock); if (cond->waiting > cond->signals) { ++cond->signals; - SDL_SemPost (cond->wait_sem); - SDL_UnlockMutex (cond->lock); - SDL_SemWait (cond->wait_done); + SDL_SemPost(cond->wait_sem); + SDL_UnlockMutex(cond->lock); + SDL_SemWait(cond->wait_done); } else { - SDL_UnlockMutex (cond->lock); + SDL_UnlockMutex(cond->lock); } return 0; @@ -105,34 +105,34 @@ /* Restart all threads that are waiting on the condition variable */ int -SDL_CondBroadcast (SDL_cond * cond) +SDL_CondBroadcast(SDL_cond * cond) { if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } /* If there are waiting threads not already signalled, then signal the condition and wait for the thread to respond. */ - SDL_LockMutex (cond->lock); + SDL_LockMutex(cond->lock); if (cond->waiting > cond->signals) { int i, num_waiting; num_waiting = (cond->waiting - cond->signals); cond->signals = cond->waiting; for (i = 0; i < num_waiting; ++i) { - SDL_SemPost (cond->wait_sem); + SDL_SemPost(cond->wait_sem); } /* Now all released threads are blocked here, waiting for us. Collect them all (and win fabulous prizes!) :-) */ - SDL_UnlockMutex (cond->lock); + SDL_UnlockMutex(cond->lock); for (i = 0; i < num_waiting; ++i) { - SDL_SemWait (cond->wait_done); + SDL_SemWait(cond->wait_done); } } else { - SDL_UnlockMutex (cond->lock); + SDL_UnlockMutex(cond->lock); } return 0; @@ -159,12 +159,12 @@ SDL_UnlockMutex(lock); */ int -SDL_CondWaitTimeout (SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) +SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) { int retval; if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } @@ -172,18 +172,18 @@ This allows the signal mechanism to only perform a signal if there are waiting threads. */ - SDL_LockMutex (cond->lock); + SDL_LockMutex(cond->lock); ++cond->waiting; - SDL_UnlockMutex (cond->lock); + SDL_UnlockMutex(cond->lock); /* Unlock the mutex, as is required by condition variable semantics */ - SDL_UnlockMutex (mutex); + SDL_UnlockMutex(mutex); /* Wait for a signal */ if (ms == SDL_MUTEX_MAXWAIT) { - retval = SDL_SemWait (cond->wait_sem); + retval = SDL_SemWait(cond->wait_sem); } else { - retval = SDL_SemWaitTimeout (cond->wait_sem, ms); + retval = SDL_SemWaitTimeout(cond->wait_sem, ms); } /* Let the signaler know we have completed the wait, otherwise @@ -192,32 +192,32 @@ giving a deadlock. See the following URL for details: http://www-classic.be.com/aboutbe/benewsletter/volume_III/Issue40.html */ - SDL_LockMutex (cond->lock); + SDL_LockMutex(cond->lock); if (cond->signals > 0) { /* If we timed out, we need to eat a condition signal */ if (retval > 0) { - SDL_SemWait (cond->wait_sem); + SDL_SemWait(cond->wait_sem); } /* We always notify the signal thread that we are done */ - SDL_SemPost (cond->wait_done); + SDL_SemPost(cond->wait_done); /* Signal handshake complete */ --cond->signals; } --cond->waiting; - SDL_UnlockMutex (cond->lock); + SDL_UnlockMutex(cond->lock); /* Lock the mutex, as is required by condition variable semantics */ - SDL_LockMutex (mutex); + SDL_LockMutex(mutex); return retval; } /* Wait on the condition variable forever */ int -SDL_CondWait (SDL_cond * cond, SDL_mutex * mutex) +SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) { - return SDL_CondWaitTimeout (cond, mutex, SDL_MUTEX_MAXWAIT); + return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/generic/SDL_sysmutex.c --- a/src/thread/generic/SDL_sysmutex.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/generic/SDL_sysmutex.c Mon May 29 04:04:35 2006 +0000 @@ -36,42 +36,42 @@ /* Create a mutex */ SDL_mutex * -SDL_CreateMutex (void) +SDL_CreateMutex(void) { SDL_mutex *mutex; /* Allocate mutex memory */ - mutex = (SDL_mutex *) SDL_malloc (sizeof (*mutex)); + mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); if (mutex) { /* Create the mutex semaphore, with initial value 1 */ - mutex->sem = SDL_CreateSemaphore (1); + mutex->sem = SDL_CreateSemaphore(1); mutex->recursive = 0; mutex->owner = 0; if (!mutex->sem) { - SDL_free (mutex); + SDL_free(mutex); mutex = NULL; } } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return mutex; } /* Free the mutex */ void -SDL_DestroyMutex (SDL_mutex * mutex) +SDL_DestroyMutex(SDL_mutex * mutex) { if (mutex) { if (mutex->sem) { - SDL_DestroySemaphore (mutex->sem); + SDL_DestroySemaphore(mutex->sem); } - SDL_free (mutex); + SDL_free(mutex); } } /* Lock the semaphore */ int -SDL_mutexP (SDL_mutex * mutex) +SDL_mutexP(SDL_mutex * mutex) { #if SDL_THREADS_DISABLED return 0; @@ -79,11 +79,11 @@ Uint32 this_thread; if (mutex == NULL) { - SDL_SetError ("Passed a NULL mutex"); + SDL_SetError("Passed a NULL mutex"); return -1; } - this_thread = SDL_ThreadID (); + this_thread = SDL_ThreadID(); if (mutex->owner == this_thread) { ++mutex->recursive; } else { @@ -91,7 +91,7 @@ We set the locking thread id after we obtain the lock so unlocks from other threads will fail. */ - SDL_SemWait (mutex->sem); + SDL_SemWait(mutex->sem); mutex->owner = this_thread; mutex->recursive = 0; } @@ -102,19 +102,19 @@ /* Unlock the mutex */ int -SDL_mutexV (SDL_mutex * mutex) +SDL_mutexV(SDL_mutex * mutex) { #if SDL_THREADS_DISABLED return 0; #else if (mutex == NULL) { - SDL_SetError ("Passed a NULL mutex"); + SDL_SetError("Passed a NULL mutex"); return -1; } /* If we don't own the mutex, we can't unlock it */ - if (SDL_ThreadID () != mutex->owner) { - SDL_SetError ("mutex not owned by this thread"); + if (SDL_ThreadID() != mutex->owner) { + SDL_SetError("mutex not owned by this thread"); return -1; } @@ -127,7 +127,7 @@ then release the lock semaphore. */ mutex->owner = 0; - SDL_SemPost (mutex->sem); + SDL_SemPost(mutex->sem); } return 0; #endif /* SDL_THREADS_DISABLED */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/generic/SDL_syssem.c --- a/src/thread/generic/SDL_syssem.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/generic/SDL_syssem.c Mon May 29 04:04:35 2006 +0000 @@ -31,49 +31,49 @@ #if SDL_THREADS_DISABLED SDL_sem * -SDL_CreateSemaphore (Uint32 initial_value) +SDL_CreateSemaphore(Uint32 initial_value) { - SDL_SetError ("SDL not configured with thread support"); + SDL_SetError("SDL not configured with thread support"); return (SDL_sem *) 0; } void -SDL_DestroySemaphore (SDL_sem * sem) +SDL_DestroySemaphore(SDL_sem * sem) { return; } int -SDL_SemTryWait (SDL_sem * sem) +SDL_SemTryWait(SDL_sem * sem) { - SDL_SetError ("SDL not configured with thread support"); + SDL_SetError("SDL not configured with thread support"); return -1; } int -SDL_SemWaitTimeout (SDL_sem * sem, Uint32 timeout) +SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) { - SDL_SetError ("SDL not configured with thread support"); + SDL_SetError("SDL not configured with thread support"); return -1; } int -SDL_SemWait (SDL_sem * sem) +SDL_SemWait(SDL_sem * sem) { - SDL_SetError ("SDL not configured with thread support"); + SDL_SetError("SDL not configured with thread support"); return -1; } Uint32 -SDL_SemValue (SDL_sem * sem) +SDL_SemValue(SDL_sem * sem) { return 0; } int -SDL_SemPost (SDL_sem * sem) +SDL_SemPost(SDL_sem * sem) { - SDL_SetError ("SDL not configured with thread support"); + SDL_SetError("SDL not configured with thread support"); return -1; } @@ -88,22 +88,22 @@ }; SDL_sem * -SDL_CreateSemaphore (Uint32 initial_value) +SDL_CreateSemaphore(Uint32 initial_value) { SDL_sem *sem; - sem = (SDL_sem *) SDL_malloc (sizeof (*sem)); + sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); if (!sem) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return NULL; } sem->count = initial_value; sem->waiters_count = 0; - sem->count_lock = SDL_CreateMutex (); - sem->count_nonzero = SDL_CreateCond (); + sem->count_lock = SDL_CreateMutex(); + sem->count_nonzero = SDL_CreateCond(); if (!sem->count_lock || !sem->count_nonzero) { - SDL_DestroySemaphore (sem); + SDL_DestroySemaphore(sem); return NULL; } @@ -114,108 +114,108 @@ You cannot call this function when another thread is using the semaphore. */ void -SDL_DestroySemaphore (SDL_sem * sem) +SDL_DestroySemaphore(SDL_sem * sem) { if (sem) { sem->count = 0xFFFFFFFF; while (sem->waiters_count > 0) { - SDL_CondSignal (sem->count_nonzero); - SDL_Delay (10); + SDL_CondSignal(sem->count_nonzero); + SDL_Delay(10); } - SDL_DestroyCond (sem->count_nonzero); + SDL_DestroyCond(sem->count_nonzero); if (sem->count_lock) { - SDL_mutexP (sem->count_lock); - SDL_mutexV (sem->count_lock); - SDL_DestroyMutex (sem->count_lock); + SDL_mutexP(sem->count_lock); + SDL_mutexV(sem->count_lock); + SDL_DestroyMutex(sem->count_lock); } - SDL_free (sem); + SDL_free(sem); } } int -SDL_SemTryWait (SDL_sem * sem) +SDL_SemTryWait(SDL_sem * sem) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } retval = SDL_MUTEX_TIMEDOUT; - SDL_LockMutex (sem->count_lock); + SDL_LockMutex(sem->count_lock); if (sem->count > 0) { --sem->count; retval = 0; } - SDL_UnlockMutex (sem->count_lock); + SDL_UnlockMutex(sem->count_lock); return retval; } int -SDL_SemWaitTimeout (SDL_sem * sem, Uint32 timeout) +SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } /* A timeout of 0 is an easy case */ if (timeout == 0) { - return SDL_SemTryWait (sem); + return SDL_SemTryWait(sem); } - SDL_LockMutex (sem->count_lock); + SDL_LockMutex(sem->count_lock); ++sem->waiters_count; retval = 0; while ((sem->count == 0) && (retval != SDL_MUTEX_TIMEDOUT)) { - retval = SDL_CondWaitTimeout (sem->count_nonzero, - sem->count_lock, timeout); + retval = SDL_CondWaitTimeout(sem->count_nonzero, + sem->count_lock, timeout); } --sem->waiters_count; --sem->count; - SDL_UnlockMutex (sem->count_lock); + SDL_UnlockMutex(sem->count_lock); return retval; } int -SDL_SemWait (SDL_sem * sem) +SDL_SemWait(SDL_sem * sem) { - return SDL_SemWaitTimeout (sem, SDL_MUTEX_MAXWAIT); + return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); } Uint32 -SDL_SemValue (SDL_sem * sem) +SDL_SemValue(SDL_sem * sem) { Uint32 value; value = 0; if (sem) { - SDL_LockMutex (sem->count_lock); + SDL_LockMutex(sem->count_lock); value = sem->count; - SDL_UnlockMutex (sem->count_lock); + SDL_UnlockMutex(sem->count_lock); } return value; } int -SDL_SemPost (SDL_sem * sem) +SDL_SemPost(SDL_sem * sem) { if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } - SDL_LockMutex (sem->count_lock); + SDL_LockMutex(sem->count_lock); if (sem->waiters_count > 0) { - SDL_CondSignal (sem->count_nonzero); + SDL_CondSignal(sem->count_nonzero); } ++sem->count; - SDL_UnlockMutex (sem->count_lock); + SDL_UnlockMutex(sem->count_lock); return 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/generic/SDL_systhread.c --- a/src/thread/generic/SDL_systhread.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/generic/SDL_systhread.c Mon May 29 04:04:35 2006 +0000 @@ -27,32 +27,32 @@ #include "../SDL_systhread.h" int -SDL_SYS_CreateThread (SDL_Thread * thread, void *args) +SDL_SYS_CreateThread(SDL_Thread * thread, void *args) { - SDL_SetError ("Threads are not supported on this platform"); + SDL_SetError("Threads are not supported on this platform"); return (-1); } void -SDL_SYS_SetupThread (void) +SDL_SYS_SetupThread(void) { return; } Uint32 -SDL_ThreadID (void) +SDL_ThreadID(void) { return (0); } void -SDL_SYS_WaitThread (SDL_Thread * thread) +SDL_SYS_WaitThread(SDL_Thread * thread) { return; } void -SDL_SYS_KillThread (SDL_Thread * thread) +SDL_SYS_KillThread(SDL_Thread * thread) { return; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/irix/SDL_syssem.c --- a/src/thread/irix/SDL_syssem.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/irix/SDL_syssem.c Mon May 29 04:04:35 2006 +0000 @@ -64,56 +64,56 @@ /* Create a blockable semaphore */ SDL_sem * -SDL_CreateSemaphore (Uint32 initial_value) +SDL_CreateSemaphore(Uint32 initial_value) { extern int _creating_thread_lock; /* SDL_threads.c */ SDL_sem *sem; union semun init; - sem = (SDL_sem *) SDL_malloc (sizeof (*sem)); + sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); if (sem == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } - sem->id = semget (IPC_PRIVATE, 1, (0600 | IPC_CREAT)); + sem->id = semget(IPC_PRIVATE, 1, (0600 | IPC_CREAT)); if (sem->id < 0) { - SDL_SetError ("Couldn't create semaphore"); - SDL_free (sem); + SDL_SetError("Couldn't create semaphore"); + SDL_free(sem); return (NULL); } init.val = initial_value; /* Initialize semaphore */ - semctl (sem->id, 0, SETVAL, init); + semctl(sem->id, 0, SETVAL, init); return (sem); } void -SDL_DestroySemaphore (SDL_sem * sem) +SDL_DestroySemaphore(SDL_sem * sem) { if (sem) { #ifdef __IRIX__ - semctl (sem->id, 0, IPC_RMID); + semctl(sem->id, 0, IPC_RMID); #else union semun dummy; dummy.val = 0; - semctl (sem->id, 0, IPC_RMID, dummy); + semctl(sem->id, 0, IPC_RMID, dummy); #endif - SDL_free (sem); + SDL_free(sem); } } int -SDL_SemTryWait (SDL_sem * sem) +SDL_SemTryWait(SDL_sem * sem) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } retval = 0; tryagain: - if (semop (sem->id, op_trywait, 1) < 0) { + if (semop(sem->id, op_trywait, 1) < 0) { if (errno == EINTR) { goto tryagain; } @@ -123,61 +123,61 @@ } int -SDL_SemWait (SDL_sem * sem) +SDL_SemWait(SDL_sem * sem) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } retval = 0; tryagain: - if (semop (sem->id, op_wait, 1) < 0) { + if (semop(sem->id, op_wait, 1) < 0) { if (errno == EINTR) { goto tryagain; } - SDL_SetError ("Semaphore operation error"); + SDL_SetError("Semaphore operation error"); retval = -1; } return retval; } int -SDL_SemWaitTimeout (SDL_sem * sem, Uint32 timeout) +SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } /* Try the easy cases first */ if (timeout == 0) { - return SDL_SemTryWait (sem); + return SDL_SemTryWait(sem); } if (timeout == SDL_MUTEX_MAXWAIT) { - return SDL_SemWait (sem); + return SDL_SemWait(sem); } /* Ack! We have to busy wait... */ - timeout += SDL_GetTicks (); + timeout += SDL_GetTicks(); do { - retval = SDL_SemTryWait (sem); + retval = SDL_SemTryWait(sem); if (retval == 0) { break; } - SDL_Delay (1); + SDL_Delay(1); } - while (SDL_GetTicks () < timeout); + while (SDL_GetTicks() < timeout); return retval; } Uint32 -SDL_SemValue (SDL_sem * sem) +SDL_SemValue(SDL_sem * sem) { int semval; Uint32 value; @@ -186,12 +186,12 @@ if (sem) { tryagain: #ifdef __IRIX__ - semval = semctl (sem->id, 0, GETVAL); + semval = semctl(sem->id, 0, GETVAL); #else { union semun arg; arg.val = 0; - semval = semctl (sem->id, 0, GETVAL, arg); + semval = semctl(sem->id, 0, GETVAL, arg); } #endif if (semval < 0) { @@ -206,22 +206,22 @@ } int -SDL_SemPost (SDL_sem * sem) +SDL_SemPost(SDL_sem * sem) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } retval = 0; tryagain: - if (semop (sem->id, op_post, 1) < 0) { + if (semop(sem->id, op_post, 1) < 0) { if (errno == EINTR) { goto tryagain; } - SDL_SetError ("Semaphore operation error"); + SDL_SetError("Semaphore operation error"); retval = -1; } return retval; diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/irix/SDL_systhread.c --- a/src/thread/irix/SDL_systhread.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/irix/SDL_systhread.c Mon May 29 04:04:35 2006 +0000 @@ -40,52 +40,52 @@ int -SDL_SYS_CreateThread (SDL_Thread * thread, void *args) +SDL_SYS_CreateThread(SDL_Thread * thread, void *args) { /* Create the thread and go! */ - if (sproc (SDL_RunThread, PR_SALL, args) < 0) { - SDL_SetError ("Not enough resources to create thread"); + if (sproc(SDL_RunThread, PR_SALL, args) < 0) { + SDL_SetError("Not enough resources to create thread"); return (-1); } return (0); } void -SDL_SYS_SetupThread (void) +SDL_SYS_SetupThread(void) { int i; sigset_t mask; /* Mask asynchronous signals for this thread */ - sigemptyset (&mask); + sigemptyset(&mask); for (i = 0; sig_list[i]; ++i) { - sigaddset (&mask, sig_list[i]); + sigaddset(&mask, sig_list[i]); } - sigprocmask (SIG_BLOCK, &mask, NULL); + sigprocmask(SIG_BLOCK, &mask, NULL); } /* WARNING: This may not work for systems with 64-bit pid_t */ Uint32 -SDL_ThreadID (void) +SDL_ThreadID(void) { - return ((Uint32) getpid ()); + return ((Uint32) getpid()); } /* WARNING: This may not work for systems with 64-bit pid_t */ void -SDL_WaitThread (SDL_Thread * thread, int *status) +SDL_WaitThread(SDL_Thread * thread, int *status) { errno = 0; while (errno != ECHILD) { - waitpid (thread->handle, NULL, 0); + waitpid(thread->handle, NULL, 0); } } /* WARNING: This may not work for systems with 64-bit pid_t */ void -SDL_KillThread (SDL_Thread * thread) +SDL_KillThread(SDL_Thread * thread) { - kill (thread->handle, SIGKILL); + kill(thread->handle, SIGKILL); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/os2/SDL_syscond.c --- a/src/thread/os2/SDL_syscond.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/os2/SDL_syscond.c Mon May 29 04:04:35 2006 +0000 @@ -40,64 +40,64 @@ /* Create a condition variable */ DECLSPEC SDL_cond *SDLCALL -SDL_CreateCond (void) +SDL_CreateCond(void) { SDL_cond *cond; - cond = (SDL_cond *) SDL_malloc (sizeof (SDL_cond)); + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); if (cond) { - cond->lock = SDL_CreateMutex (); - cond->wait_sem = SDL_CreateSemaphore (0); - cond->wait_done = SDL_CreateSemaphore (0); + cond->lock = SDL_CreateMutex(); + cond->wait_sem = SDL_CreateSemaphore(0); + cond->wait_done = SDL_CreateSemaphore(0); cond->waiting = cond->signals = 0; if (!cond->lock || !cond->wait_sem || !cond->wait_done) { - SDL_DestroyCond (cond); + SDL_DestroyCond(cond); cond = NULL; } } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return (cond); } /* Destroy a condition variable */ DECLSPEC void SDLCALL -SDL_DestroyCond (SDL_cond * cond) +SDL_DestroyCond(SDL_cond * cond) { if (cond) { if (cond->wait_sem) { - SDL_DestroySemaphore (cond->wait_sem); + SDL_DestroySemaphore(cond->wait_sem); } if (cond->wait_done) { - SDL_DestroySemaphore (cond->wait_done); + SDL_DestroySemaphore(cond->wait_done); } if (cond->lock) { - SDL_DestroyMutex (cond->lock); + SDL_DestroyMutex(cond->lock); } - SDL_free (cond); + SDL_free(cond); } } /* Restart one of the threads that are waiting on the condition variable */ DECLSPEC int SDLCALL -SDL_CondSignal (SDL_cond * cond) +SDL_CondSignal(SDL_cond * cond) { if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } /* If there are waiting threads not already signalled, then signal the condition and wait for the thread to respond. */ - SDL_LockMutex (cond->lock); + SDL_LockMutex(cond->lock); if (cond->waiting > cond->signals) { ++cond->signals; - SDL_SemPost (cond->wait_sem); - SDL_UnlockMutex (cond->lock); - SDL_SemWait (cond->wait_done); + SDL_SemPost(cond->wait_sem); + SDL_UnlockMutex(cond->lock); + SDL_SemWait(cond->wait_done); } else { - SDL_UnlockMutex (cond->lock); + SDL_UnlockMutex(cond->lock); } return 0; @@ -105,34 +105,34 @@ /* Restart all threads that are waiting on the condition variable */ DECLSPEC int SDLCALL -SDL_CondBroadcast (SDL_cond * cond) +SDL_CondBroadcast(SDL_cond * cond) { if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } /* If there are waiting threads not already signalled, then signal the condition and wait for the thread to respond. */ - SDL_LockMutex (cond->lock); + SDL_LockMutex(cond->lock); if (cond->waiting > cond->signals) { int i, num_waiting; num_waiting = (cond->waiting - cond->signals); cond->signals = cond->waiting; for (i = 0; i < num_waiting; ++i) { - SDL_SemPost (cond->wait_sem); + SDL_SemPost(cond->wait_sem); } /* Now all released threads are blocked here, waiting for us. Collect them all (and win fabulous prizes!) :-) */ - SDL_UnlockMutex (cond->lock); + SDL_UnlockMutex(cond->lock); for (i = 0; i < num_waiting; ++i) { - SDL_SemWait (cond->wait_done); + SDL_SemWait(cond->wait_done); } } else { - SDL_UnlockMutex (cond->lock); + SDL_UnlockMutex(cond->lock); } return 0; @@ -159,12 +159,12 @@ SDL_UnlockMutex(lock); */ DECLSPEC int SDLCALL -SDL_CondWaitTimeout (SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) +SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) { int retval; if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } @@ -172,18 +172,18 @@ This allows the signal mechanism to only perform a signal if there are waiting threads. */ - SDL_LockMutex (cond->lock); + SDL_LockMutex(cond->lock); ++cond->waiting; - SDL_UnlockMutex (cond->lock); + SDL_UnlockMutex(cond->lock); /* Unlock the mutex, as is required by condition variable semantics */ - SDL_UnlockMutex (mutex); + SDL_UnlockMutex(mutex); /* Wait for a signal */ if (ms == SDL_MUTEX_MAXWAIT) { - retval = SDL_SemWait (cond->wait_sem); + retval = SDL_SemWait(cond->wait_sem); } else { - retval = SDL_SemWaitTimeout (cond->wait_sem, ms); + retval = SDL_SemWaitTimeout(cond->wait_sem, ms); } /* Let the signaler know we have completed the wait, otherwise @@ -192,32 +192,32 @@ giving a deadlock. See the following URL for details: http://www-classic.be.com/aboutbe/benewsletter/volume_III/Issue40.html */ - SDL_LockMutex (cond->lock); + SDL_LockMutex(cond->lock); if (cond->signals > 0) { /* If we timed out, we need to eat a condition signal */ if (retval > 0) { - SDL_SemWait (cond->wait_sem); + SDL_SemWait(cond->wait_sem); } /* We always notify the signal thread that we are done */ - SDL_SemPost (cond->wait_done); + SDL_SemPost(cond->wait_done); /* Signal handshake complete */ --cond->signals; } --cond->waiting; - SDL_UnlockMutex (cond->lock); + SDL_UnlockMutex(cond->lock); /* Lock the mutex, as is required by condition variable semantics */ - SDL_LockMutex (mutex); + SDL_LockMutex(mutex); return retval; } /* Wait on the condition variable forever */ DECLSPEC int SDLCALL -SDL_CondWait (SDL_cond * cond, SDL_mutex * mutex) +SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) { - return SDL_CondWaitTimeout (cond, mutex, SDL_MUTEX_MAXWAIT); + return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/os2/SDL_sysmutex.c --- a/src/thread/os2/SDL_sysmutex.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/os2/SDL_sysmutex.c Mon May 29 04:04:35 2006 +0000 @@ -37,53 +37,53 @@ /* Create a mutex */ DECLSPEC SDL_mutex *SDLCALL -SDL_CreateMutex (void) +SDL_CreateMutex(void) { SDL_mutex *mutex; APIRET ulrc; /* Allocate mutex memory */ - mutex = (SDL_mutex *) SDL_malloc (sizeof (*mutex)); + mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); if (mutex) { /* Create the mutex, with initial value signaled */ - ulrc = DosCreateMutexSem (NULL, // Create unnamed semaphore - &(mutex->hmtxID), // Pointer to handle - 0L, // Flags: create it private (not shared) - FALSE); // Initial value: unowned + ulrc = DosCreateMutexSem(NULL, // Create unnamed semaphore + &(mutex->hmtxID), // Pointer to handle + 0L, // Flags: create it private (not shared) + FALSE); // Initial value: unowned if (ulrc != NO_ERROR) { - SDL_SetError ("Couldn't create mutex"); - SDL_free (mutex); + SDL_SetError("Couldn't create mutex"); + SDL_free(mutex); mutex = NULL; } } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return (mutex); } /* Free the mutex */ DECLSPEC void SDLCALL -SDL_DestroyMutex (SDL_mutex * mutex) +SDL_DestroyMutex(SDL_mutex * mutex) { if (mutex) { if (mutex->hmtxID) { - DosCloseMutexSem (mutex->hmtxID); + DosCloseMutexSem(mutex->hmtxID); mutex->hmtxID = 0; } - SDL_free (mutex); + SDL_free(mutex); } } /* Lock the mutex */ DECLSPEC int SDLCALL -SDL_mutexP (SDL_mutex * mutex) +SDL_mutexP(SDL_mutex * mutex) { if (mutex == NULL) { - SDL_SetError ("Passed a NULL mutex"); + SDL_SetError("Passed a NULL mutex"); return -1; } - if (DosRequestMutexSem (mutex->hmtxID, SEM_INDEFINITE_WAIT) != NO_ERROR) { - SDL_SetError ("Couldn't wait on mutex"); + if (DosRequestMutexSem(mutex->hmtxID, SEM_INDEFINITE_WAIT) != NO_ERROR) { + SDL_SetError("Couldn't wait on mutex"); return -1; } return (0); @@ -91,14 +91,14 @@ /* Unlock the mutex */ DECLSPEC int SDLCALL -SDL_mutexV (SDL_mutex * mutex) +SDL_mutexV(SDL_mutex * mutex) { if (mutex == NULL) { - SDL_SetError ("Passed a NULL mutex"); + SDL_SetError("Passed a NULL mutex"); return -1; } - if (DosReleaseMutexSem (mutex->hmtxID) != NO_ERROR) { - SDL_SetError ("Couldn't release mutex"); + if (DosReleaseMutexSem(mutex->hmtxID) != NO_ERROR) { + SDL_SetError("Couldn't release mutex"); return -1; } return (0); diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/os2/SDL_syssem.c --- a/src/thread/os2/SDL_syssem.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/os2/SDL_syssem.c Mon May 29 04:04:35 2006 +0000 @@ -42,105 +42,105 @@ /* Create a semaphore */ DECLSPEC SDL_sem *SDLCALL -SDL_CreateSemaphore (Uint32 initial_value) +SDL_CreateSemaphore(Uint32 initial_value) { SDL_sem *sem; ULONG ulrc; /* Allocate sem memory */ - sem = (SDL_sem *) SDL_malloc (sizeof (*sem)); + sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); if (sem) { /* Create the mutex semaphore */ - ulrc = DosCreateMutexSem (NULL, &(sem->id), 0, TRUE); + ulrc = DosCreateMutexSem(NULL, &(sem->id), 0, TRUE); if (ulrc) { - SDL_SetError ("Couldn't create semaphore"); - SDL_free (sem); + SDL_SetError("Couldn't create semaphore"); + SDL_free(sem); sem = NULL; } else { - DosCreateEventSem (NULL, &(sem->changed), 0, FALSE); + DosCreateEventSem(NULL, &(sem->changed), 0, FALSE); sem->value = initial_value; - DosReleaseMutexSem (sem->id); + DosReleaseMutexSem(sem->id); } } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return (sem); } /* Free the semaphore */ DECLSPEC void SDLCALL -SDL_DestroySemaphore (SDL_sem * sem) +SDL_DestroySemaphore(SDL_sem * sem) { if (sem) { if (sem->id) { - DosCloseEventSem (sem->changed); - DosCloseMutexSem (sem->id); + DosCloseEventSem(sem->changed); + DosCloseMutexSem(sem->id); sem->id = 0; } - SDL_free (sem); + SDL_free(sem); } } DECLSPEC int SDLCALL -SDL_SemWaitTimeout (SDL_sem * sem, Uint32 timeout) +SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) { ULONG ulrc; if (!sem) { - SDL_SetError ("Passed a NULL sem"); + SDL_SetError("Passed a NULL sem"); return -1; } if (timeout == SDL_MUTEX_MAXWAIT) { while (1) { - ulrc = DosRequestMutexSem (sem->id, SEM_INDEFINITE_WAIT); + ulrc = DosRequestMutexSem(sem->id, SEM_INDEFINITE_WAIT); if (ulrc) { /* if error waiting mutex */ - SDL_SetError ("DosRequestMutexSem() failed"); + SDL_SetError("DosRequestMutexSem() failed"); return -1; } else if (sem->value) { sem->value--; - DosReleaseMutexSem (sem->id); + DosReleaseMutexSem(sem->id); return 0; } else { ULONG ulPostCount; - DosResetEventSem (sem->changed, &ulPostCount); - DosReleaseMutexSem (sem->id); + DosResetEventSem(sem->changed, &ulPostCount); + DosReleaseMutexSem(sem->id); /* continue waiting until somebody posts the semaphore */ - DosWaitEventSem (sem->changed, SEM_INDEFINITE_WAIT); + DosWaitEventSem(sem->changed, SEM_INDEFINITE_WAIT); } } } else if (timeout == 0) { - ulrc = DosRequestMutexSem (sem->id, SEM_INDEFINITE_WAIT); + ulrc = DosRequestMutexSem(sem->id, SEM_INDEFINITE_WAIT); if (ulrc == NO_ERROR) { if (sem->value) { sem->value--; - DosReleaseMutexSem (sem->id); + DosReleaseMutexSem(sem->id); return 0; } else { - DosReleaseMutexSem (sem->id); + DosReleaseMutexSem(sem->id); return SDL_MUTEX_TIMEDOUT; } } else { - SDL_SetError ("DosRequestMutexSem() failed"); + SDL_SetError("DosRequestMutexSem() failed"); return -1; } } else { - ulrc = DosRequestMutexSem (sem->id, SEM_INDEFINITE_WAIT); + ulrc = DosRequestMutexSem(sem->id, SEM_INDEFINITE_WAIT); if (ulrc) { /* if error waiting mutex */ - SDL_SetError ("DosRequestMutexSem() failed"); + SDL_SetError("DosRequestMutexSem() failed"); return -1; } else if (sem->value) { sem->value--; - DosReleaseMutexSem (sem->id); + DosReleaseMutexSem(sem->id); return 0; } else { ULONG ulPostCount; - DosResetEventSem (sem->changed, &ulPostCount); - DosReleaseMutexSem (sem->id); + DosResetEventSem(sem->changed, &ulPostCount); + DosReleaseMutexSem(sem->id); /* continue waiting until somebody posts the semaphore */ - ulrc = DosWaitEventSem (sem->changed, timeout); + ulrc = DosWaitEventSem(sem->changed, timeout); if (ulrc == NO_ERROR) return 0; else @@ -152,42 +152,42 @@ } DECLSPEC int SDLCALL -SDL_SemTryWait (SDL_sem * sem) +SDL_SemTryWait(SDL_sem * sem) { - return SDL_SemWaitTimeout (sem, 0); + return SDL_SemWaitTimeout(sem, 0); } DECLSPEC int SDLCALL -SDL_SemWait (SDL_sem * sem) +SDL_SemWait(SDL_sem * sem) { - return SDL_SemWaitTimeout (sem, SDL_MUTEX_MAXWAIT); + return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); } /* Returns the current count of the semaphore */ DECLSPEC Uint32 SDLCALL -SDL_SemValue (SDL_sem * sem) +SDL_SemValue(SDL_sem * sem) { if (!sem) { - SDL_SetError ("Passed a NULL sem"); + SDL_SetError("Passed a NULL sem"); return 0; } return sem->value; } DECLSPEC int SDLCALL -SDL_SemPost (SDL_sem * sem) +SDL_SemPost(SDL_sem * sem) { if (!sem) { - SDL_SetError ("Passed a NULL sem"); + SDL_SetError("Passed a NULL sem"); return -1; } - if (DosRequestMutexSem (sem->id, SEM_INDEFINITE_WAIT)) { - SDL_SetError ("DosRequestMutexSem() failed"); + if (DosRequestMutexSem(sem->id, SEM_INDEFINITE_WAIT)) { + SDL_SetError("DosRequestMutexSem() failed"); return -1; } sem->value++; - DosPostEventSem (sem->changed); - DosReleaseMutexSem (sem->id); + DosPostEventSem(sem->changed); + DosReleaseMutexSem(sem->id); return 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/os2/SDL_systhread.c --- a/src/thread/os2/SDL_systhread.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/os2/SDL_systhread.c Mon May 29 04:04:35 2006 +0000 @@ -39,18 +39,18 @@ } tThreadStartParms, *pThreadStartParms; static void -threadfunc (void *pparm) +threadfunc(void *pparm) { pThreadStartParms pThreadParms = pparm; pfnSDL_CurrentEndThread pfnCurrentEndThread = NULL; // Call the thread function! - SDL_RunThread (pThreadParms->args); + SDL_RunThread(pThreadParms->args); // Get the current endthread we have to use! if (pThreadParms) { pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread; - SDL_free (pThreadParms); + SDL_free(pThreadParms); } // Call endthread! if (pfnCurrentEndThread) @@ -58,13 +58,13 @@ } int -SDL_SYS_CreateThread (SDL_Thread * thread, void *args, - pfnSDL_CurrentBeginThread pfnBeginThread, - pfnSDL_CurrentEndThread pfnEndThread) +SDL_SYS_CreateThread(SDL_Thread * thread, void *args, + pfnSDL_CurrentBeginThread pfnBeginThread, + pfnSDL_CurrentEndThread pfnEndThread) { - pThreadStartParms pThreadParms = SDL_malloc (sizeof (tThreadStartParms)); + pThreadStartParms pThreadParms = SDL_malloc(sizeof(tThreadStartParms)); if (!pThreadParms) { - SDL_SetError ("Not enough memory to create thread"); + SDL_SetError("Not enough memory to create thread"); return (-1); } // Save the function which we will have to call to clear the RTL of calling app! @@ -75,31 +75,31 @@ thread->threadid = thread->handle = (*pfnBeginThread) (threadfunc, NULL, 512 * 1024, pThreadParms); if ((int) thread->threadid <= 0) { - SDL_SetError ("Not enough resources to create thread"); + SDL_SetError("Not enough resources to create thread"); return (-1); } return (0); } void -SDL_SYS_SetupThread (void) +SDL_SYS_SetupThread(void) { return; } DECLSPEC Uint32 SDLCALL -SDL_ThreadID (void) +SDL_ThreadID(void) { PTIB tib; - DosGetInfoBlocks (&tib, NULL); + DosGetInfoBlocks(&tib, NULL); return ((Uint32) (tib->tib_ptib2->tib2_ultid)); } void -SDL_SYS_WaitThread (SDL_Thread * thread) +SDL_SYS_WaitThread(SDL_Thread * thread) { TID tid = thread->handle; - DosWaitThread (&tid, DCWW_WAIT); + DosWaitThread(&tid, DCWW_WAIT); } /* WARNING: This function is really a last resort. @@ -107,9 +107,9 @@ * TerminateThread() doesn't perform stack and DLL cleanup. */ void -SDL_SYS_KillThread (SDL_Thread * thread) +SDL_SYS_KillThread(SDL_Thread * thread) { - DosKillThread (thread->handle); + DosKillThread(thread->handle); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/pth/SDL_syscond.c --- a/src/thread/pth/SDL_syscond.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/pth/SDL_syscond.c Mon May 29 04:04:35 2006 +0000 @@ -39,46 +39,46 @@ /* Create a condition variable */ SDL_cond * -SDL_CreateCond (void) +SDL_CreateCond(void) { SDL_cond *cond; - cond = (SDL_cond *) SDL_malloc (sizeof (SDL_cond)); + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); if (cond) { - if (pth_cond_init (&(cond->condpth_p)) < 0) { - SDL_SetError ("pthread_cond_init() failed"); - SDL_free (cond); + if (pth_cond_init(&(cond->condpth_p)) < 0) { + SDL_SetError("pthread_cond_init() failed"); + SDL_free(cond); cond = NULL; } } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return (cond); } /* Destroy a condition variable */ void -SDL_DestroyCond (SDL_cond * cond) +SDL_DestroyCond(SDL_cond * cond) { if (cond) { - SDL_free (cond); + SDL_free(cond); } } /* Restart one of the threads that are waiting on the condition variable */ int -SDL_CondSignal (SDL_cond * cond) +SDL_CondSignal(SDL_cond * cond) { int retval; if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } retval = 0; - if (pth_cond_notify (&(cond->condpth_p), FALSE) != 0) { - SDL_SetError ("pth_cond_notify() failed"); + if (pth_cond_notify(&(cond->condpth_p), FALSE) != 0) { + SDL_SetError("pth_cond_notify() failed"); retval = -1; } return retval; @@ -86,18 +86,18 @@ /* Restart all threads that are waiting on the condition variable */ int -SDL_CondBroadcast (SDL_cond * cond) +SDL_CondBroadcast(SDL_cond * cond) { int retval; if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } retval = 0; - if (pth_cond_notify (&(cond->condpth_p), TRUE) != 0) { - SDL_SetError ("pth_cond_notify() failed"); + if (pth_cond_notify(&(cond->condpth_p), TRUE) != 0) { + SDL_SetError("pth_cond_notify() failed"); retval = -1; } return retval; @@ -124,47 +124,47 @@ SDL_UnlockMutex(lock); */ int -SDL_CondWaitTimeout (SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) +SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) { int retval; pth_event_t ev; int sec; if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } retval = 0; sec = ms / 1000; - ev = pth_event (PTH_EVENT_TIME, - pth_timeout (sec, (ms - sec * 1000) * 1000)); + ev = pth_event(PTH_EVENT_TIME, + pth_timeout(sec, (ms - sec * 1000) * 1000)); - if (pth_cond_await (&(cond->condpth_p), &(mutex->mutexpth_p), ev) != 0) { - SDL_SetError ("pth_cond_await() failed"); + if (pth_cond_await(&(cond->condpth_p), &(mutex->mutexpth_p), ev) != 0) { + SDL_SetError("pth_cond_await() failed"); retval = -1; } - pth_event_free (ev, PTH_FREE_ALL); + pth_event_free(ev, PTH_FREE_ALL); return retval; } /* Wait on the condition variable forever */ int -SDL_CondWait (SDL_cond * cond, SDL_mutex * mutex) +SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) { int retval; if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } retval = 0; - if (pth_cond_await (&(cond->condpth_p), &(mutex->mutexpth_p), NULL) != 0) { - SDL_SetError ("pth_cond_await() failed"); + if (pth_cond_await(&(cond->condpth_p), &(mutex->mutexpth_p), NULL) != 0) { + SDL_SetError("pth_cond_await() failed"); retval = -1; } return retval; diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/pth/SDL_sysmutex.c --- a/src/thread/pth/SDL_sysmutex.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/pth/SDL_sysmutex.c Mon May 29 04:04:35 2006 +0000 @@ -34,58 +34,58 @@ /* Create a mutex */ SDL_mutex * -SDL_CreateMutex (void) +SDL_CreateMutex(void) { SDL_mutex *mutex; /* Allocate mutex memory */ - mutex = (SDL_mutex *) SDL_malloc (sizeof (*mutex)); + mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); if (mutex) { /* Create the mutex, with initial value signaled */ - if (!pth_mutex_init (&(mutex->mutexpth_p))) { - SDL_SetError ("Couldn't create mutex"); - SDL_free (mutex); + if (!pth_mutex_init(&(mutex->mutexpth_p))) { + SDL_SetError("Couldn't create mutex"); + SDL_free(mutex); mutex = NULL; } } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return (mutex); } /* Free the mutex */ void -SDL_DestroyMutex (SDL_mutex * mutex) +SDL_DestroyMutex(SDL_mutex * mutex) { if (mutex) { - SDL_free (mutex); + SDL_free(mutex); } } /* Lock the mutex */ int -SDL_mutexP (SDL_mutex * mutex) +SDL_mutexP(SDL_mutex * mutex) { if (mutex == NULL) { - SDL_SetError ("Passed a NULL mutex"); + SDL_SetError("Passed a NULL mutex"); return -1; } - pth_mutex_acquire (&(mutex->mutexpth_p), FALSE, NULL); + pth_mutex_acquire(&(mutex->mutexpth_p), FALSE, NULL); return (0); } /* Unlock the mutex */ int -SDL_mutexV (SDL_mutex * mutex) +SDL_mutexV(SDL_mutex * mutex) { if (mutex == NULL) { - SDL_SetError ("Passed a NULL mutex"); + SDL_SetError("Passed a NULL mutex"); return -1; } - pth_mutex_release (&(mutex->mutexpth_p)); + pth_mutex_release(&(mutex->mutexpth_p)); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/pth/SDL_systhread.c --- a/src/thread/pth/SDL_systhread.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/pth/SDL_systhread.c Mon May 29 04:04:35 2006 +0000 @@ -41,71 +41,71 @@ }; static void * -RunThread (void *data) +RunThread(void *data) { - SDL_RunThread (data); - pth_exit ((void *) 0); + SDL_RunThread(data); + pth_exit((void *) 0); return ((void *) 0); /* Prevent compiler warning */ } int -SDL_SYS_CreateThread (SDL_Thread * thread, void *args) +SDL_SYS_CreateThread(SDL_Thread * thread, void *args) { pth_attr_t type; /* Create a new attribute */ - type = pth_attr_new (); + type = pth_attr_new(); if (type == NULL) { - SDL_SetError ("Couldn't initialize pth attributes"); + SDL_SetError("Couldn't initialize pth attributes"); return (-1); } - pth_attr_set (type, PTH_ATTR_JOINABLE, TRUE); + pth_attr_set(type, PTH_ATTR_JOINABLE, TRUE); /* Create the thread and go! */ - thread->handle = pth_spawn (type, RunThread, args); + thread->handle = pth_spawn(type, RunThread, args); if (thread->handle == NULL) { - SDL_SetError ("Not enough resources to create thread"); + SDL_SetError("Not enough resources to create thread"); return (-1); } return (0); } void -SDL_SYS_SetupThread (void) +SDL_SYS_SetupThread(void) { int i; sigset_t mask; int oldstate; /* Mask asynchronous signals for this thread */ - sigemptyset (&mask); + sigemptyset(&mask); for (i = 0; sig_list[i]; ++i) { - sigaddset (&mask, sig_list[i]); + sigaddset(&mask, sig_list[i]); } - pth_sigmask (SIG_BLOCK, &mask, 0); + pth_sigmask(SIG_BLOCK, &mask, 0); /* Allow ourselves to be asynchronously cancelled */ - pth_cancel_state (PTH_CANCEL_ASYNCHRONOUS, &oldstate); + pth_cancel_state(PTH_CANCEL_ASYNCHRONOUS, &oldstate); } /* WARNING: This may not work for systems with 64-bit pid_t */ Uint32 -SDL_ThreadID (void) +SDL_ThreadID(void) { - return ((Uint32) pth_self ()); + return ((Uint32) pth_self()); } void -SDL_SYS_WaitThread (SDL_Thread * thread) +SDL_SYS_WaitThread(SDL_Thread * thread) { - pth_join (thread->handle, NULL); + pth_join(thread->handle, NULL); } void -SDL_SYS_KillThread (SDL_Thread * thread) +SDL_SYS_KillThread(SDL_Thread * thread) { - pth_cancel (thread->handle); - pth_join (thread->handle, NULL); + pth_cancel(thread->handle); + pth_join(thread->handle, NULL); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/pthread/SDL_syscond.c --- a/src/thread/pthread/SDL_syscond.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/pthread/SDL_syscond.c Mon May 29 04:04:35 2006 +0000 @@ -36,15 +36,15 @@ /* Create a condition variable */ SDL_cond * -SDL_CreateCond (void) +SDL_CreateCond(void) { SDL_cond *cond; - cond = (SDL_cond *) SDL_malloc (sizeof (SDL_cond)); + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); if (cond) { - if (pthread_cond_init (&cond->cond, NULL) < 0) { - SDL_SetError ("pthread_cond_init() failed"); - SDL_free (cond); + if (pthread_cond_init(&cond->cond, NULL) < 0) { + SDL_SetError("pthread_cond_init() failed"); + SDL_free(cond); cond = NULL; } } @@ -53,28 +53,28 @@ /* Destroy a condition variable */ void -SDL_DestroyCond (SDL_cond * cond) +SDL_DestroyCond(SDL_cond * cond) { if (cond) { - pthread_cond_destroy (&cond->cond); - SDL_free (cond); + pthread_cond_destroy(&cond->cond); + SDL_free(cond); } } /* Restart one of the threads that are waiting on the condition variable */ int -SDL_CondSignal (SDL_cond * cond) +SDL_CondSignal(SDL_cond * cond) { int retval; if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } retval = 0; - if (pthread_cond_signal (&cond->cond) != 0) { - SDL_SetError ("pthread_cond_signal() failed"); + if (pthread_cond_signal(&cond->cond) != 0) { + SDL_SetError("pthread_cond_signal() failed"); retval = -1; } return retval; @@ -82,36 +82,36 @@ /* Restart all threads that are waiting on the condition variable */ int -SDL_CondBroadcast (SDL_cond * cond) +SDL_CondBroadcast(SDL_cond * cond) { int retval; if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } retval = 0; - if (pthread_cond_broadcast (&cond->cond) != 0) { - SDL_SetError ("pthread_cond_broadcast() failed"); + if (pthread_cond_broadcast(&cond->cond) != 0) { + SDL_SetError("pthread_cond_broadcast() failed"); retval = -1; } return retval; } int -SDL_CondWaitTimeout (SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) +SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) { int retval; struct timeval delta; struct timespec abstime; if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } - gettimeofday (&delta, NULL); + gettimeofday(&delta, NULL); abstime.tv_sec = delta.tv_sec + (ms / 1000); abstime.tv_nsec = (delta.tv_usec + (ms % 1000) * 1000) * 1000; @@ -121,7 +121,7 @@ } tryagain: - retval = pthread_cond_timedwait (&cond->cond, &mutex->id, &abstime); + retval = pthread_cond_timedwait(&cond->cond, &mutex->id, &abstime); switch (retval) { case EINTR: goto tryagain; @@ -132,7 +132,7 @@ case 0: break; default: - SDL_SetError ("pthread_cond_timedwait() failed"); + SDL_SetError("pthread_cond_timedwait() failed"); retval = -1; break; } @@ -143,18 +143,18 @@ The mutex must be locked before entering this function! */ int -SDL_CondWait (SDL_cond * cond, SDL_mutex * mutex) +SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) { int retval; if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } retval = 0; - if (pthread_cond_wait (&cond->cond, &mutex->id) != 0) { - SDL_SetError ("pthread_cond_wait() failed"); + if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) { + SDL_SetError("pthread_cond_wait() failed"); retval = -1; } return retval; diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/pthread/SDL_sysmutex.c --- a/src/thread/pthread/SDL_sysmutex.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/pthread/SDL_sysmutex.c Mon May 29 04:04:35 2006 +0000 @@ -40,45 +40,45 @@ }; SDL_mutex * -SDL_CreateMutex (void) +SDL_CreateMutex(void) { SDL_mutex *mutex; pthread_mutexattr_t attr; /* Allocate the structure */ - mutex = (SDL_mutex *) SDL_calloc (1, sizeof (*mutex)); + mutex = (SDL_mutex *) SDL_calloc(1, sizeof(*mutex)); if (mutex) { - pthread_mutexattr_init (&attr); + pthread_mutexattr_init(&attr); #if SDL_THREAD_PTHREAD_RECURSIVE_MUTEX - pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); #elif SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP - pthread_mutexattr_setkind_np (&attr, PTHREAD_MUTEX_RECURSIVE_NP); + pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP); #else /* No extra attributes necessary */ #endif - if (pthread_mutex_init (&mutex->id, &attr) != 0) { - SDL_SetError ("pthread_mutex_init() failed"); - SDL_free (mutex); + if (pthread_mutex_init(&mutex->id, &attr) != 0) { + SDL_SetError("pthread_mutex_init() failed"); + SDL_free(mutex); mutex = NULL; } } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return (mutex); } void -SDL_DestroyMutex (SDL_mutex * mutex) +SDL_DestroyMutex(SDL_mutex * mutex) { if (mutex) { - pthread_mutex_destroy (&mutex->id); - SDL_free (mutex); + pthread_mutex_destroy(&mutex->id); + SDL_free(mutex); } } /* Lock the mutex */ int -SDL_mutexP (SDL_mutex * mutex) +SDL_mutexP(SDL_mutex * mutex) { int retval; #if FAKE_RECURSIVE_MUTEX @@ -86,13 +86,13 @@ #endif if (mutex == NULL) { - SDL_SetError ("Passed a NULL mutex"); + SDL_SetError("Passed a NULL mutex"); return -1; } retval = 0; #if FAKE_RECURSIVE_MUTEX - this_thread = pthread_self (); + this_thread = pthread_self(); if (mutex->owner == this_thread) { ++mutex->recursive; } else { @@ -100,17 +100,17 @@ We set the locking thread id after we obtain the lock so unlocks from other threads will fail. */ - if (pthread_mutex_lock (&mutex->id) == 0) { + if (pthread_mutex_lock(&mutex->id) == 0) { mutex->owner = this_thread; mutex->recursive = 0; } else { - SDL_SetError ("pthread_mutex_lock() failed"); + SDL_SetError("pthread_mutex_lock() failed"); retval = -1; } } #else - if (pthread_mutex_lock (&mutex->id) < 0) { - SDL_SetError ("pthread_mutex_lock() failed"); + if (pthread_mutex_lock(&mutex->id) < 0) { + SDL_SetError("pthread_mutex_lock() failed"); retval = -1; } #endif @@ -118,19 +118,19 @@ } int -SDL_mutexV (SDL_mutex * mutex) +SDL_mutexV(SDL_mutex * mutex) { int retval; if (mutex == NULL) { - SDL_SetError ("Passed a NULL mutex"); + SDL_SetError("Passed a NULL mutex"); return -1; } retval = 0; #if FAKE_RECURSIVE_MUTEX /* We can only unlock the mutex if we own it */ - if (pthread_self () == mutex->owner) { + if (pthread_self() == mutex->owner) { if (mutex->recursive) { --mutex->recursive; } else { @@ -140,16 +140,16 @@ then release the lock semaphore. */ mutex->owner = 0; - pthread_mutex_unlock (&mutex->id); + pthread_mutex_unlock(&mutex->id); } } else { - SDL_SetError ("mutex not owned by this thread"); + SDL_SetError("mutex not owned by this thread"); retval = -1; } #else - if (pthread_mutex_unlock (&mutex->id) < 0) { - SDL_SetError ("pthread_mutex_unlock() failed"); + if (pthread_mutex_unlock(&mutex->id) < 0) { + SDL_SetError("pthread_mutex_unlock() failed"); retval = -1; } #endif /* FAKE_RECURSIVE_MUTEX */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/pthread/SDL_syssem.c --- a/src/thread/pthread/SDL_syssem.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/pthread/SDL_syssem.c Mon May 29 04:04:35 2006 +0000 @@ -41,102 +41,102 @@ /* Create a semaphore, initialized with value */ SDL_sem * -SDL_CreateSemaphore (Uint32 initial_value) +SDL_CreateSemaphore(Uint32 initial_value) { - SDL_sem *sem = (SDL_sem *) SDL_malloc (sizeof (SDL_sem)); + SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem)); if (sem) { - if (sem_init (&sem->sem, 0, initial_value) < 0) { - SDL_SetError ("sem_init() failed"); - SDL_free (sem); + if (sem_init(&sem->sem, 0, initial_value) < 0) { + SDL_SetError("sem_init() failed"); + SDL_free(sem); sem = NULL; } } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return sem; } void -SDL_DestroySemaphore (SDL_sem * sem) +SDL_DestroySemaphore(SDL_sem * sem) { if (sem) { - sem_destroy (&sem->sem); - SDL_free (sem); + sem_destroy(&sem->sem); + SDL_free(sem); } } int -SDL_SemTryWait (SDL_sem * sem) +SDL_SemTryWait(SDL_sem * sem) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } retval = SDL_MUTEX_TIMEDOUT; - if (sem_trywait (&sem->sem) == 0) { + if (sem_trywait(&sem->sem) == 0) { retval = 0; } return retval; } int -SDL_SemWait (SDL_sem * sem) +SDL_SemWait(SDL_sem * sem) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } - retval = sem_wait (&sem->sem); + retval = sem_wait(&sem->sem); if (retval < 0) { - SDL_SetError ("sem_wait() failed"); + SDL_SetError("sem_wait() failed"); } return retval; } int -SDL_SemWaitTimeout (SDL_sem * sem, Uint32 timeout) +SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } /* Try the easy cases first */ if (timeout == 0) { - return SDL_SemTryWait (sem); + return SDL_SemTryWait(sem); } if (timeout == SDL_MUTEX_MAXWAIT) { - return SDL_SemWait (sem); + return SDL_SemWait(sem); } /* Ack! We have to busy wait... */ /* FIXME: Use sem_timedwait()? */ - timeout += SDL_GetTicks (); + timeout += SDL_GetTicks(); do { - retval = SDL_SemTryWait (sem); + retval = SDL_SemTryWait(sem); if (retval == 0) { break; } - SDL_Delay (1); + SDL_Delay(1); } - while (SDL_GetTicks () < timeout); + while (SDL_GetTicks() < timeout); return retval; } Uint32 -SDL_SemValue (SDL_sem * sem) +SDL_SemValue(SDL_sem * sem) { int ret = 0; if (sem) { - sem_getvalue (&sem->sem, &ret); + sem_getvalue(&sem->sem, &ret); if (ret < 0) { ret = 0; } @@ -145,18 +145,18 @@ } int -SDL_SemPost (SDL_sem * sem) +SDL_SemPost(SDL_sem * sem) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } - retval = sem_post (&sem->sem); + retval = sem_post(&sem->sem); if (retval < 0) { - SDL_SetError ("sem_post() failed"); + SDL_SetError("sem_post() failed"); } return retval; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/pthread/SDL_systhread.c --- a/src/thread/pthread/SDL_systhread.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/pthread/SDL_systhread.c Mon May 29 04:04:35 2006 +0000 @@ -43,34 +43,34 @@ static void * -RunThread (void *data) +RunThread(void *data) { - SDL_RunThread (data); - pthread_exit ((void *) 0); + SDL_RunThread(data); + pthread_exit((void *) 0); return ((void *) 0); /* Prevent compiler warning */ } int -SDL_SYS_CreateThread (SDL_Thread * thread, void *args) +SDL_SYS_CreateThread(SDL_Thread * thread, void *args) { pthread_attr_t type; /* Set the thread attributes */ - if (pthread_attr_init (&type) != 0) { - SDL_SetError ("Couldn't initialize pthread attributes"); + if (pthread_attr_init(&type) != 0) { + SDL_SetError("Couldn't initialize pthread attributes"); return (-1); } - pthread_attr_setdetachstate (&type, PTHREAD_CREATE_JOINABLE); + pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE); /* Create the thread and go! */ - if (pthread_create (&thread->handle, &type, RunThread, args) != 0) { - SDL_SetError ("Not enough resources to create thread"); + if (pthread_create(&thread->handle, &type, RunThread, args) != 0) { + SDL_SetError("Not enough resources to create thread"); return (-1); } #ifdef __RISCOS__ if (riscos_using_threads == 0) { riscos_using_threads = 1; - riscos_main_thread = SDL_ThreadID (); + riscos_main_thread = SDL_ThreadID(); } #endif @@ -78,50 +78,50 @@ } void -SDL_SYS_SetupThread (void) +SDL_SYS_SetupThread(void) { int i; sigset_t mask; /* Mask asynchronous signals for this thread */ - sigemptyset (&mask); + sigemptyset(&mask); for (i = 0; sig_list[i]; ++i) { - sigaddset (&mask, sig_list[i]); + sigaddset(&mask, sig_list[i]); } - pthread_sigmask (SIG_BLOCK, &mask, 0); + pthread_sigmask(SIG_BLOCK, &mask, 0); #ifdef PTHREAD_CANCEL_ASYNCHRONOUS /* Allow ourselves to be asynchronously cancelled */ { int oldstate; - pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate); + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate); } #endif } /* WARNING: This may not work for systems with 64-bit pid_t */ Uint32 -SDL_ThreadID (void) +SDL_ThreadID(void) { - return ((Uint32) pthread_self ()); + return ((Uint32) pthread_self()); } void -SDL_SYS_WaitThread (SDL_Thread * thread) +SDL_SYS_WaitThread(SDL_Thread * thread) { - pthread_join (thread->handle, 0); + pthread_join(thread->handle, 0); } void -SDL_SYS_KillThread (SDL_Thread * thread) +SDL_SYS_KillThread(SDL_Thread * thread) { #ifdef PTHREAD_CANCEL_ASYNCHRONOUS - pthread_cancel (thread->handle); + pthread_cancel(thread->handle); #else #ifdef __FREEBSD__ #warning For some reason, this doesnt actually kill a thread - FreeBSD 3.2 #endif - pthread_kill (thread->handle, SIGKILL); + pthread_kill(thread->handle, SIGKILL); #endif } diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/riscos/SDL_syscond.c --- a/src/thread/riscos/SDL_syscond.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/riscos/SDL_syscond.c Mon May 29 04:04:35 2006 +0000 @@ -40,15 +40,15 @@ /* Create a condition variable */ SDL_cond * -SDL_CreateCond (void) +SDL_CreateCond(void) { SDL_cond *cond; - cond = (SDL_cond *) SDL_malloc (sizeof (SDL_cond)); + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); if (cond) { - if (pthread_cond_init (&cond->cond, NULL) < 0) { - SDL_SetError ("pthread_cond_init() failed"); - SDL_free (cond); + if (pthread_cond_init(&cond->cond, NULL) < 0) { + SDL_SetError("pthread_cond_init() failed"); + SDL_free(cond); cond = NULL; } } @@ -57,28 +57,28 @@ /* Destroy a condition variable */ void -SDL_DestroyCond (SDL_cond * cond) +SDL_DestroyCond(SDL_cond * cond) { if (cond) { - pthread_cond_destroy (&cond->cond); - SDL_free (cond); + pthread_cond_destroy(&cond->cond); + SDL_free(cond); } } /* Restart one of the threads that are waiting on the condition variable */ int -SDL_CondSignal (SDL_cond * cond) +SDL_CondSignal(SDL_cond * cond) { int retval; if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } retval = 0; - if (pthread_cond_signal (&cond->cond) != 0) { - SDL_SetError ("pthread_cond_signal() failed"); + if (pthread_cond_signal(&cond->cond) != 0) { + SDL_SetError("pthread_cond_signal() failed"); retval = -1; } return retval; @@ -86,36 +86,36 @@ /* Restart all threads that are waiting on the condition variable */ int -SDL_CondBroadcast (SDL_cond * cond) +SDL_CondBroadcast(SDL_cond * cond) { int retval; if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } retval = 0; - if (pthread_cond_broadcast (&cond->cond) != 0) { - SDL_SetError ("pthread_cond_broadcast() failed"); + if (pthread_cond_broadcast(&cond->cond) != 0) { + SDL_SetError("pthread_cond_broadcast() failed"); retval = -1; } return retval; } int -SDL_CondWaitTimeout (SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) +SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) { int retval; struct timeval delta; struct timespec abstime; if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } - gettimeofday (&delta, NULL); + gettimeofday(&delta, NULL); abstime.tv_sec = delta.tv_sec + (ms / 1000); abstime.tv_nsec = (delta.tv_usec + (ms % 1000) * 1000) * 1000; @@ -125,7 +125,7 @@ } tryagain: - retval = pthread_cond_timedwait (&cond->cond, &mutex->id, &abstime); + retval = pthread_cond_timedwait(&cond->cond, &mutex->id, &abstime); switch (retval) { case EINTR: goto tryagain; @@ -136,7 +136,7 @@ case 0: break; default: - SDL_SetError ("pthread_cond_timedwait() failed"); + SDL_SetError("pthread_cond_timedwait() failed"); retval = -1; break; } @@ -147,18 +147,18 @@ The mutex must be locked before entering this function! */ int -SDL_CondWait (SDL_cond * cond, SDL_mutex * mutex) +SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) { int retval; if (!cond) { - SDL_SetError ("Passed a NULL condition variable"); + SDL_SetError("Passed a NULL condition variable"); return -1; } retval = 0; - if (pthread_cond_wait (&cond->cond, &mutex->id) != 0) { - SDL_SetError ("pthread_cond_wait() failed"); + if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) { + SDL_SetError("pthread_cond_wait() failed"); retval = -1; } return retval; diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/riscos/SDL_sysmutex.c --- a/src/thread/riscos/SDL_sysmutex.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/riscos/SDL_sysmutex.c Mon May 29 04:04:35 2006 +0000 @@ -41,43 +41,43 @@ }; SDL_mutex * -SDL_CreateMutex (void) +SDL_CreateMutex(void) { SDL_mutex *mutex; pthread_mutexattr_t attr; /* Allocate the structure */ - mutex = (SDL_mutex *) SDL_calloc (1, sizeof (*mutex)); + mutex = (SDL_mutex *) SDL_calloc(1, sizeof(*mutex)); if (mutex) { - pthread_mutexattr_init (&attr); + pthread_mutexattr_init(&attr); #if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX /* No extra attributes necessary */ #else - pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); #endif /* SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX */ - if (pthread_mutex_init (&mutex->id, &attr) != 0) { - SDL_SetError ("pthread_mutex_init() failed"); - SDL_free (mutex); + if (pthread_mutex_init(&mutex->id, &attr) != 0) { + SDL_SetError("pthread_mutex_init() failed"); + SDL_free(mutex); mutex = NULL; } } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return (mutex); } void -SDL_DestroyMutex (SDL_mutex * mutex) +SDL_DestroyMutex(SDL_mutex * mutex) { if (mutex) { - pthread_mutex_destroy (&mutex->id); - SDL_free (mutex); + pthread_mutex_destroy(&mutex->id); + SDL_free(mutex); } } /* Lock the mutex */ int -SDL_mutexP (SDL_mutex * mutex) +SDL_mutexP(SDL_mutex * mutex) { int retval; #if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX @@ -85,13 +85,13 @@ #endif if (mutex == NULL) { - SDL_SetError ("Passed a NULL mutex"); + SDL_SetError("Passed a NULL mutex"); return -1; } retval = 0; #if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX - this_thread = pthread_self (); + this_thread = pthread_self(); if (mutex->owner == this_thread) { ++mutex->recursive; } else { @@ -99,17 +99,17 @@ We set the locking thread id after we obtain the lock so unlocks from other threads will fail. */ - if (pthread_mutex_lock (&mutex->id) == 0) { + if (pthread_mutex_lock(&mutex->id) == 0) { mutex->owner = this_thread; mutex->recursive = 0; } else { - SDL_SetError ("pthread_mutex_lock() failed"); + SDL_SetError("pthread_mutex_lock() failed"); retval = -1; } } #else - if (pthread_mutex_lock (&mutex->id) < 0) { - SDL_SetError ("pthread_mutex_lock() failed"); + if (pthread_mutex_lock(&mutex->id) < 0) { + SDL_SetError("pthread_mutex_lock() failed"); retval = -1; } #endif @@ -117,19 +117,19 @@ } int -SDL_mutexV (SDL_mutex * mutex) +SDL_mutexV(SDL_mutex * mutex) { int retval; if (mutex == NULL) { - SDL_SetError ("Passed a NULL mutex"); + SDL_SetError("Passed a NULL mutex"); return -1; } retval = 0; #if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX /* We can only unlock the mutex if we own it */ - if (pthread_self () == mutex->owner) { + if (pthread_self() == mutex->owner) { if (mutex->recursive) { --mutex->recursive; } else { @@ -139,16 +139,16 @@ then release the lock semaphore. */ mutex->owner = 0; - pthread_mutex_unlock (&mutex->id); + pthread_mutex_unlock(&mutex->id); } } else { - SDL_SetError ("mutex not owned by this thread"); + SDL_SetError("mutex not owned by this thread"); retval = -1; } #else - if (pthread_mutex_unlock (&mutex->id) < 0) { - SDL_SetError ("pthread_mutex_unlock() failed"); + if (pthread_mutex_unlock(&mutex->id) < 0) { + SDL_SetError("pthread_mutex_unlock() failed"); retval = -1; } #endif /* SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/riscos/SDL_syssem.c --- a/src/thread/riscos/SDL_syssem.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/riscos/SDL_syssem.c Mon May 29 04:04:35 2006 +0000 @@ -31,49 +31,49 @@ #if !SDL_THREADS_DISABLED SDL_sem * -SDL_CreateSemaphore (Uint32 initial_value) +SDL_CreateSemaphore(Uint32 initial_value) { - SDL_SetError ("SDL not configured with thread support"); + SDL_SetError("SDL not configured with thread support"); return (SDL_sem *) 0; } void -SDL_DestroySemaphore (SDL_sem * sem) +SDL_DestroySemaphore(SDL_sem * sem) { return; } int -SDL_SemTryWait (SDL_sem * sem) +SDL_SemTryWait(SDL_sem * sem) { - SDL_SetError ("SDL not configured with thread support"); + SDL_SetError("SDL not configured with thread support"); return -1; } int -SDL_SemWaitTimeout (SDL_sem * sem, Uint32 timeout) +SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) { - SDL_SetError ("SDL not configured with thread support"); + SDL_SetError("SDL not configured with thread support"); return -1; } int -SDL_SemWait (SDL_sem * sem) +SDL_SemWait(SDL_sem * sem) { - SDL_SetError ("SDL not configured with thread support"); + SDL_SetError("SDL not configured with thread support"); return -1; } Uint32 -SDL_SemValue (SDL_sem * sem) +SDL_SemValue(SDL_sem * sem) { return 0; } int -SDL_SemPost (SDL_sem * sem) +SDL_SemPost(SDL_sem * sem) { - SDL_SetError ("SDL not configured with thread support"); + SDL_SetError("SDL not configured with thread support"); return -1; } @@ -92,103 +92,103 @@ /* Create a semaphore, initialized with value */ SDL_sem * -SDL_CreateSemaphore (Uint32 initial_value) +SDL_CreateSemaphore(Uint32 initial_value) { - SDL_sem *sem = (SDL_sem *) SDL_malloc (sizeof (SDL_sem)); + SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem)); if (sem) { - if (sem_init (&sem->sem_data, 0, initial_value) < 0) { - SDL_SetError ("sem_init() failed"); - SDL_free (sem); + if (sem_init(&sem->sem_data, 0, initial_value) < 0) { + SDL_SetError("sem_init() failed"); + SDL_free(sem); sem = NULL; } else { sem->sem = &sem->sem_data; } } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return sem; } void -SDL_DestroySemaphore (SDL_sem * sem) +SDL_DestroySemaphore(SDL_sem * sem) { if (sem) { - sem_destroy (sem->sem); - SDL_free (sem); + sem_destroy(sem->sem); + SDL_free(sem); } } int -SDL_SemTryWait (SDL_sem * sem) +SDL_SemTryWait(SDL_sem * sem) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } retval = SDL_MUTEX_TIMEDOUT; - if (sem_trywait (sem->sem) == 0) { + if (sem_trywait(sem->sem) == 0) { retval = 0; } return retval; } int -SDL_SemWait (SDL_sem * sem) +SDL_SemWait(SDL_sem * sem) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } - retval = sem_wait (sem->sem); + retval = sem_wait(sem->sem); if (retval < 0) { - SDL_SetError ("sem_wait() failed"); + SDL_SetError("sem_wait() failed"); } return retval; } int -SDL_SemWaitTimeout (SDL_sem * sem, Uint32 timeout) +SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } /* Try the easy cases first */ if (timeout == 0) { - return SDL_SemTryWait (sem); + return SDL_SemTryWait(sem); } if (timeout == SDL_MUTEX_MAXWAIT) { - return SDL_SemWait (sem); + return SDL_SemWait(sem); } /* Ack! We have to busy wait... */ - timeout += SDL_GetTicks (); + timeout += SDL_GetTicks(); do { - retval = SDL_SemTryWait (sem); + retval = SDL_SemTryWait(sem); if (retval == 0) { break; } - SDL_Delay (1); + SDL_Delay(1); } - while (SDL_GetTicks () < timeout); + while (SDL_GetTicks() < timeout); return retval; } Uint32 -SDL_SemValue (SDL_sem * sem) +SDL_SemValue(SDL_sem * sem) { int ret = 0; if (sem) { - sem_getvalue (sem->sem, &ret); + sem_getvalue(sem->sem, &ret); if (ret < 0) { ret = 0; } @@ -197,18 +197,18 @@ } int -SDL_SemPost (SDL_sem * sem) +SDL_SemPost(SDL_sem * sem) { int retval; if (!sem) { - SDL_SetError ("Passed a NULL semaphore"); + SDL_SetError("Passed a NULL semaphore"); return -1; } - retval = sem_post (sem->sem); + retval = sem_post(sem->sem); if (retval < 0) { - SDL_SetError ("sem_post() failed"); + SDL_SetError("sem_post() failed"); } return retval; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/riscos/SDL_systhread.c --- a/src/thread/riscos/SDL_systhread.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/riscos/SDL_systhread.c Mon May 29 04:04:35 2006 +0000 @@ -29,7 +29,7 @@ #if SDL_THREADS_DISABLED int -SDL_SYS_CreateThread (SDL_Thread * thread, void *args) +SDL_SYS_CreateThread(SDL_Thread * thread, void *args) { SDL_SetError ("Threads have not been compiled into this version of the library"); @@ -37,25 +37,25 @@ } void -SDL_SYS_SetupThread (void) +SDL_SYS_SetupThread(void) { return; } Uint32 -SDL_ThreadID (void) +SDL_ThreadID(void) { return (0); } void -SDL_SYS_WaitThread (SDL_Thread * thread) +SDL_SYS_WaitThread(SDL_Thread * thread) { return; } void -SDL_SYS_KillThread (SDL_Thread * thread) +SDL_SYS_KillThread(SDL_Thread * thread) { return; } @@ -76,80 +76,80 @@ Uint32 riscos_main_thread = 0; /* Thread running events */ static void * -RunThread (void *data) +RunThread(void *data) { - SDL_RunThread (data); - pthread_exit ((void *) 0); + SDL_RunThread(data); + pthread_exit((void *) 0); return ((void *) 0); /* Prevent compiler warning */ } int -SDL_SYS_CreateThread (SDL_Thread * thread, void *args) +SDL_SYS_CreateThread(SDL_Thread * thread, void *args) { pthread_attr_t type; /* Set the thread attributes */ - if (pthread_attr_init (&type) != 0) { - SDL_SetError ("Couldn't initialize pthread attributes"); + if (pthread_attr_init(&type) != 0) { + SDL_SetError("Couldn't initialize pthread attributes"); return (-1); } - pthread_attr_setdetachstate (&type, PTHREAD_CREATE_JOINABLE); + pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE); /* Create the thread and go! */ - if (pthread_create (&thread->handle, &type, RunThread, args) != 0) { - SDL_SetError ("Not enough resources to create thread"); + if (pthread_create(&thread->handle, &type, RunThread, args) != 0) { + SDL_SetError("Not enough resources to create thread"); return (-1); } if (riscos_using_threads == 0) { riscos_using_threads = 1; - riscos_main_thread = SDL_ThreadID (); + riscos_main_thread = SDL_ThreadID(); } return (0); } void -SDL_SYS_SetupThread (void) +SDL_SYS_SetupThread(void) { int i; sigset_t mask; /* Mask asynchronous signals for this thread */ - sigemptyset (&mask); + sigemptyset(&mask); for (i = 0; sig_list[i]; ++i) { - sigaddset (&mask, sig_list[i]); + sigaddset(&mask, sig_list[i]); } - pthread_sigmask (SIG_BLOCK, &mask, 0); + pthread_sigmask(SIG_BLOCK, &mask, 0); #ifdef PTHREAD_CANCEL_ASYNCHRONOUS /* Allow ourselves to be asynchronously cancelled */ { int oldstate; - pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate); + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate); } #endif } Uint32 -SDL_ThreadID (void) +SDL_ThreadID(void) { - return ((Uint32) pthread_self ()); + return ((Uint32) pthread_self()); } void -SDL_SYS_WaitThread (SDL_Thread * thread) +SDL_SYS_WaitThread(SDL_Thread * thread) { - pthread_join (thread->handle, 0); + pthread_join(thread->handle, 0); } void -SDL_SYS_KillThread (SDL_Thread * thread) +SDL_SYS_KillThread(SDL_Thread * thread) { #ifdef PTHREAD_CANCEL_ASYNCHRONOUS - pthread_cancel (thread->handle); + pthread_cancel(thread->handle); #else - pthread_kill (thread->handle, SIGKILL); + pthread_kill(thread->handle, SIGKILL); #endif } diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/win32/SDL_sysmutex.c --- a/src/thread/win32/SDL_sysmutex.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/win32/SDL_sysmutex.c Mon May 29 04:04:35 2006 +0000 @@ -36,49 +36,49 @@ /* Create a mutex */ SDL_mutex * -SDL_CreateMutex (void) +SDL_CreateMutex(void) { SDL_mutex *mutex; /* Allocate mutex memory */ - mutex = (SDL_mutex *) SDL_malloc (sizeof (*mutex)); + mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); if (mutex) { /* Create the mutex, with initial value signaled */ - mutex->id = CreateMutex (NULL, FALSE, NULL); + mutex->id = CreateMutex(NULL, FALSE, NULL); if (!mutex->id) { - SDL_SetError ("Couldn't create mutex"); - SDL_free (mutex); + SDL_SetError("Couldn't create mutex"); + SDL_free(mutex); mutex = NULL; } } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return (mutex); } /* Free the mutex */ void -SDL_DestroyMutex (SDL_mutex * mutex) +SDL_DestroyMutex(SDL_mutex * mutex) { if (mutex) { if (mutex->id) { - CloseHandle (mutex->id); + CloseHandle(mutex->id); mutex->id = 0; } - SDL_free (mutex); + SDL_free(mutex); } } /* Lock the mutex */ int -SDL_mutexP (SDL_mutex * mutex) +SDL_mutexP(SDL_mutex * mutex) { if (mutex == NULL) { - SDL_SetError ("Passed a NULL mutex"); + SDL_SetError("Passed a NULL mutex"); return -1; } - if (WaitForSingleObject (mutex->id, INFINITE) == WAIT_FAILED) { - SDL_SetError ("Couldn't wait on mutex"); + if (WaitForSingleObject(mutex->id, INFINITE) == WAIT_FAILED) { + SDL_SetError("Couldn't wait on mutex"); return -1; } return (0); @@ -86,14 +86,14 @@ /* Unlock the mutex */ int -SDL_mutexV (SDL_mutex * mutex) +SDL_mutexV(SDL_mutex * mutex) { if (mutex == NULL) { - SDL_SetError ("Passed a NULL mutex"); + SDL_SetError("Passed a NULL mutex"); return -1; } - if (ReleaseMutex (mutex->id) == FALSE) { - SDL_SetError ("Couldn't release mutex"); + if (ReleaseMutex(mutex->id) == FALSE) { + SDL_SetError("Couldn't release mutex"); return -1; } return (0); diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/win32/SDL_syssem.c --- a/src/thread/win32/SDL_syssem.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/win32/SDL_syssem.c Mon May 29 04:04:35 2006 +0000 @@ -45,56 +45,56 @@ /* Create a semaphore */ SDL_sem * -SDL_CreateSemaphore (Uint32 initial_value) +SDL_CreateSemaphore(Uint32 initial_value) { SDL_sem *sem; /* Allocate sem memory */ - sem = (SDL_sem *) SDL_malloc (sizeof (*sem)); + sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); if (sem) { /* Create the semaphore, with max value 32K */ #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) - sem->id = CreateSemaphoreCE (NULL, initial_value, 32 * 1024, NULL); + sem->id = CreateSemaphoreCE(NULL, initial_value, 32 * 1024, NULL); #else - sem->id = CreateSemaphore (NULL, initial_value, 32 * 1024, NULL); + sem->id = CreateSemaphore(NULL, initial_value, 32 * 1024, NULL); #endif sem->count = initial_value; if (!sem->id) { - SDL_SetError ("Couldn't create semaphore"); - SDL_free (sem); + SDL_SetError("Couldn't create semaphore"); + SDL_free(sem); sem = NULL; } } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return (sem); } /* Free the semaphore */ void -SDL_DestroySemaphore (SDL_sem * sem) +SDL_DestroySemaphore(SDL_sem * sem) { if (sem) { if (sem->id) { #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) - CloseSynchHandle (sem->id); + CloseSynchHandle(sem->id); #else - CloseHandle (sem->id); + CloseHandle(sem->id); #endif sem->id = 0; } - SDL_free (sem); + SDL_free(sem); } } int -SDL_SemWaitTimeout (SDL_sem * sem, Uint32 timeout) +SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) { int retval; DWORD dwMilliseconds; if (!sem) { - SDL_SetError ("Passed a NULL sem"); + SDL_SetError("Passed a NULL sem"); return -1; } @@ -104,9 +104,9 @@ dwMilliseconds = (DWORD) timeout; } #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) - switch (WaitForSemaphoreCE (sem->id, dwMilliseconds)) { + switch (WaitForSemaphoreCE(sem->id, dwMilliseconds)) { #else - switch (WaitForSingleObject (sem->id, dwMilliseconds)) { + switch (WaitForSingleObject(sem->id, dwMilliseconds)) { #endif case WAIT_OBJECT_0: --sem->count; @@ -116,7 +116,7 @@ retval = SDL_MUTEX_TIMEDOUT; break; default: - SDL_SetError ("WaitForSingleObject() failed"); + SDL_SetError("WaitForSingleObject() failed"); retval = -1; break; } @@ -124,33 +124,33 @@ } int -SDL_SemTryWait (SDL_sem * sem) +SDL_SemTryWait(SDL_sem * sem) { - return SDL_SemWaitTimeout (sem, 0); + return SDL_SemWaitTimeout(sem, 0); } int -SDL_SemWait (SDL_sem * sem) +SDL_SemWait(SDL_sem * sem) { - return SDL_SemWaitTimeout (sem, SDL_MUTEX_MAXWAIT); + return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); } /* Returns the current count of the semaphore */ Uint32 -SDL_SemValue (SDL_sem * sem) +SDL_SemValue(SDL_sem * sem) { if (!sem) { - SDL_SetError ("Passed a NULL sem"); + SDL_SetError("Passed a NULL sem"); return 0; } return sem->count; } int -SDL_SemPost (SDL_sem * sem) +SDL_SemPost(SDL_sem * sem) { if (!sem) { - SDL_SetError ("Passed a NULL sem"); + SDL_SetError("Passed a NULL sem"); return -1; } /* Increase the counter in the first place, because @@ -160,12 +160,12 @@ */ ++sem->count; #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) - if (ReleaseSemaphoreCE (sem->id, 1, NULL) == FALSE) { + if (ReleaseSemaphoreCE(sem->id, 1, NULL) == FALSE) { #else - if (ReleaseSemaphore (sem->id, 1, NULL) == FALSE) { + if (ReleaseSemaphore(sem->id, 1, NULL) == FALSE) { #endif --sem->count; /* restore */ - SDL_SetError ("ReleaseSemaphore() failed"); + SDL_SetError("ReleaseSemaphore() failed"); return -1; } return 0; diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/win32/SDL_systhread.c --- a/src/thread/win32/SDL_systhread.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/win32/SDL_systhread.c Mon May 29 04:04:35 2006 +0000 @@ -63,12 +63,12 @@ *threadID); typedef void (__watcall * pfnSDL_CurrentEndThread) (unsigned code); #else -typedef uintptr_t (__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, - unsigned (__stdcall * - func) (void - *), - void *arg, unsigned, - unsigned *threadID); +typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, + unsigned (__stdcall * + func) (void + *), + void *arg, unsigned, + unsigned *threadID); typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); #endif #endif /* !SDL_PASSED_BEGINTHREAD_ENDTHREAD */ @@ -81,18 +81,18 @@ } tThreadStartParms, *pThreadStartParms; static unsigned __stdcall -RunThread (void *data) +RunThread(void *data) { pThreadStartParms pThreadParms = (pThreadStartParms) data; pfnSDL_CurrentEndThread pfnCurrentEndThread = NULL; // Call the thread function! - SDL_RunThread (pThreadParms->args); + SDL_RunThread(pThreadParms->args); // Get the current endthread we have to use! if (pThreadParms) { pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread; - SDL_free (pThreadParms); + SDL_free(pThreadParms); } // Call endthread! if (pfnCurrentEndThread) @@ -102,13 +102,13 @@ #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD int -SDL_SYS_CreateThread (SDL_Thread * thread, void *args, - pfnSDL_CurrentBeginThread pfnBeginThread, - pfnSDL_CurrentEndThread pfnEndThread) +SDL_SYS_CreateThread(SDL_Thread * thread, void *args, + pfnSDL_CurrentBeginThread pfnBeginThread, + pfnSDL_CurrentEndThread pfnEndThread) { #else int -SDL_SYS_CreateThread (SDL_Thread * thread, void *args) +SDL_SYS_CreateThread(SDL_Thread * thread, void *args) { #ifdef _WIN32_WCE pfnSDL_CurrentBeginThread pfnBeginThread = NULL; @@ -120,9 +120,9 @@ #endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */ unsigned threadid; pThreadStartParms pThreadParms = - (pThreadStartParms) SDL_malloc (sizeof (tThreadStartParms)); + (pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms)); if (!pThreadParms) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } // Save the function which we will have to call to clear the RTL of calling app! @@ -132,36 +132,36 @@ if (pfnBeginThread) { thread->handle = - (SYS_ThreadHandle) pfnBeginThread (NULL, 0, RunThread, - pThreadParms, 0, &threadid); + (SYS_ThreadHandle) pfnBeginThread(NULL, 0, RunThread, + pThreadParms, 0, &threadid); } else { thread->handle = - CreateThread (NULL, 0, RunThread, pThreadParms, 0, &threadid); + CreateThread(NULL, 0, RunThread, pThreadParms, 0, &threadid); } if (thread->handle == NULL) { - SDL_SetError ("Not enough resources to create thread"); + SDL_SetError("Not enough resources to create thread"); return (-1); } return (0); } void -SDL_SYS_SetupThread (void) +SDL_SYS_SetupThread(void) { return; } Uint32 -SDL_ThreadID (void) +SDL_ThreadID(void) { - return ((Uint32) GetCurrentThreadId ()); + return ((Uint32) GetCurrentThreadId()); } void -SDL_SYS_WaitThread (SDL_Thread * thread) +SDL_SYS_WaitThread(SDL_Thread * thread) { - WaitForSingleObject (thread->handle, INFINITE); - CloseHandle (thread->handle); + WaitForSingleObject(thread->handle, INFINITE); + CloseHandle(thread->handle); } /* WARNING: This function is really a last resort. @@ -169,9 +169,9 @@ * TerminateThread() doesn't perform stack and DLL cleanup. */ void -SDL_SYS_KillThread (SDL_Thread * thread) +SDL_SYS_KillThread(SDL_Thread * thread) { - TerminateThread (thread->handle, FALSE); + TerminateThread(thread->handle, FALSE); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/win32/win_ce_semaphore.c --- a/src/thread/win32/win_ce_semaphore.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/win32/win_ce_semaphore.c Mon May 29 04:04:35 2006 +0000 @@ -33,13 +33,13 @@ #include "win_ce_semaphore.h" -static SYNCHHANDLE CleanUp (SYNCHHANDLE hSynch, DWORD Flags); +static SYNCHHANDLE CleanUp(SYNCHHANDLE hSynch, DWORD Flags); SYNCHHANDLE -CreateSemaphoreCE (LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, /* pointer to security attributes */ - LONG lInitialCount, /* initial count */ - LONG lMaximumCount, /* maximum count */ - LPCTSTR lpName) +CreateSemaphoreCE(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, /* pointer to security attributes */ + LONG lInitialCount, /* initial count */ + LONG lMaximumCount, /* maximum count */ + LPCTSTR lpName) /* Semaphore for use with Windows CE that does not support them directly. Requires a counter, a mutex to protect the counter, and an autoreset event. @@ -62,13 +62,12 @@ if (lInitialCount > lMaximumCount || lMaximumCount < 0 || lInitialCount < 0) { /* Bad parameters */ - SetLastError (SYNCH_ERROR); + SetLastError(SYNCH_ERROR); __leave; } hSynch = - HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, - SYNCH_HANDLE_SIZE); + HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SYNCH_HANDLE_SIZE); if (hSynch == NULL) __leave; @@ -76,30 +75,29 @@ hSynch->CurCount = lInitialCount; hSynch->lpName = lpName; - hSynch->hMutex = CreateMutex (lpSemaphoreAttributes, FALSE, NULL); + hSynch->hMutex = CreateMutex(lpSemaphoreAttributes, FALSE, NULL); - WaitForSingleObject (hSynch->hMutex, INFINITE); + WaitForSingleObject(hSynch->hMutex, INFINITE); /* Create the event. It is initially signaled if and only if the initial count is > 0 */ - hSynch->hEvent = CreateEvent (lpSemaphoreAttributes, FALSE, - lInitialCount > 0, NULL); - ReleaseMutex (hSynch->hMutex); + hSynch->hEvent = CreateEvent(lpSemaphoreAttributes, FALSE, + lInitialCount > 0, NULL); + ReleaseMutex(hSynch->hMutex); hSynch->hSemph = NULL; } __finally { /* Return with the handle, or, if there was any error, return a null after closing any open handles and freeing any allocated memory. */ result = - CleanUp (hSynch, - 6 /* An event and a mutex, but no semaphore. */ ); + CleanUp(hSynch, 6 /* An event and a mutex, but no semaphore. */ ); } return result; } BOOL -ReleaseSemaphoreCE (SYNCHHANDLE hSemCE, LONG cReleaseCount, - LPLONG lpPreviousCount) +ReleaseSemaphoreCE(SYNCHHANDLE hSemCE, LONG cReleaseCount, + LPLONG lpPreviousCount) /* Windows CE equivalent to ReleaseSemaphore. */ { BOOL Result = TRUE; @@ -108,13 +106,13 @@ would not cause the total count to exceed the maximum. */ __try { - WaitForSingleObject (hSemCE->hMutex, INFINITE); + WaitForSingleObject(hSemCE->hMutex, INFINITE); /* reply only if asked to */ if (lpPreviousCount != NULL) *lpPreviousCount = hSemCE->CurCount; if (hSemCE->CurCount + cReleaseCount > hSemCE->MaxCount || cReleaseCount <= 0) { - SetLastError (SYNCH_ERROR); + SetLastError(SYNCH_ERROR); Result = FALSE; __leave; } @@ -123,22 +121,22 @@ /* Set the autoreset event, releasing exactly one waiting thread, now or in the future. */ - SetEvent (hSemCE->hEvent); + SetEvent(hSemCE->hEvent); } __finally { - ReleaseMutex (hSemCE->hMutex); + ReleaseMutex(hSemCE->hMutex); } return Result; } DWORD -WaitForSemaphoreCE (SYNCHHANDLE hSemCE, DWORD dwMilliseconds) +WaitForSemaphoreCE(SYNCHHANDLE hSemCE, DWORD dwMilliseconds) /* Windows CE semaphore equivalent of WaitForSingleObject. */ { DWORD WaitResult; - WaitResult = WaitForSingleObject (hSemCE->hMutex, dwMilliseconds); + WaitResult = WaitForSingleObject(hSemCE->hMutex, dwMilliseconds); if (WaitResult != WAIT_OBJECT_0 && WaitResult != WAIT_ABANDONED_0) return WaitResult; while (hSemCE->CurCount <= 0) { @@ -148,14 +146,14 @@ available. First, of course, the mutex must be released so that another thread will be capable of setting the event. */ - ReleaseMutex (hSemCE->hMutex); + ReleaseMutex(hSemCE->hMutex); /* Wait for the event to be signaled, indicating a semaphore state change. The event is autoreset and signaled with a SetEvent (not PulseEvent) so exactly one waiting thread (whether or not there is currently a waiting thread) is released as a result of the SetEvent. */ - WaitResult = WaitForSingleObject (hSemCE->hEvent, dwMilliseconds); + WaitResult = WaitForSingleObject(hSemCE->hEvent, dwMilliseconds); if (WaitResult != WAIT_OBJECT_0) return WaitResult; @@ -168,7 +166,7 @@ a defect which could appear if the semaphore state changed between the two waits. */ - WaitResult = WaitForSingleObject (hSemCE->hMutex, dwMilliseconds); + WaitResult = WaitForSingleObject(hSemCE->hMutex, dwMilliseconds); if (WaitResult != WAIT_OBJECT_0 && WaitResult != WAIT_ABANDONED_0) return WaitResult; @@ -181,29 +179,29 @@ before releasing the mutex. */ if (hSemCE->CurCount > 0) - SetEvent (hSemCE->hEvent); - ReleaseMutex (hSemCE->hMutex); + SetEvent(hSemCE->hEvent); + ReleaseMutex(hSemCE->hMutex); return WaitResult; } BOOL -CloseSynchHandle (SYNCHHANDLE hSynch) +CloseSynchHandle(SYNCHHANDLE hSynch) /* Close a synchronization handle. Improvement: Test for a valid handle before dereferencing the handle. */ { BOOL Result = TRUE; if (hSynch->hEvent != NULL) - Result = Result && CloseHandle (hSynch->hEvent); + Result = Result && CloseHandle(hSynch->hEvent); if (hSynch->hMutex != NULL) - Result = Result && CloseHandle (hSynch->hMutex); + Result = Result && CloseHandle(hSynch->hMutex); if (hSynch->hSemph != NULL) - Result = Result && CloseHandle (hSynch->hSemph); - HeapFree (GetProcessHeap (), 0, hSynch); + Result = Result && CloseHandle(hSynch->hSemph); + HeapFree(GetProcessHeap(), 0, hSynch); return (Result); } static SYNCHHANDLE -CleanUp (SYNCHHANDLE hSynch, DWORD Flags) +CleanUp(SYNCHHANDLE hSynch, DWORD Flags) { /* Prepare to return from a create of a synchronization handle. If there was any failure, free any allocated resources. "Flags" indicates which Win32 objects are required in the @@ -220,7 +218,7 @@ if ((Flags & 1) == 1 && (hSynch->hEvent == NULL)) ok = FALSE; if (!ok) { - CloseSynchHandle (hSynch); + CloseSynchHandle(hSynch); return NULL; } /* Everything worked */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/thread/win32/win_ce_semaphore.h --- a/src/thread/win32/win_ce_semaphore.h Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/win32/win_ce_semaphore.h Mon May 29 04:04:35 2006 +0000 @@ -15,11 +15,11 @@ /* Error codes - all must have bit 29 set */ #define SYNCH_ERROR 0X20000000 /* EXERCISE - REFINE THE ERROR NUMBERS */ -extern SYNCHHANDLE CreateSemaphoreCE (LPSECURITY_ATTRIBUTES, LONG, LONG, - LPCTSTR); +extern SYNCHHANDLE CreateSemaphoreCE(LPSECURITY_ATTRIBUTES, LONG, LONG, + LPCTSTR); -extern BOOL ReleaseSemaphoreCE (SYNCHHANDLE, LONG, LPLONG); -extern DWORD WaitForSemaphoreCE (SYNCHHANDLE, DWORD); +extern BOOL ReleaseSemaphoreCE(SYNCHHANDLE, LONG, LPLONG); +extern DWORD WaitForSemaphoreCE(SYNCHHANDLE, DWORD); -extern BOOL CloseSynchHandle (SYNCHHANDLE); +extern BOOL CloseSynchHandle(SYNCHHANDLE); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/SDL_systimer.h --- a/src/timer/SDL_systimer.h Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/SDL_systimer.h Mon May 29 04:04:35 2006 +0000 @@ -28,14 +28,14 @@ /* Initialize the system dependent timer subsystem */ -extern int SDL_SYS_TimerInit (void); +extern int SDL_SYS_TimerInit(void); /* Quit the system dependent timer subsystem */ -extern void SDL_SYS_TimerQuit (void); +extern void SDL_SYS_TimerQuit(void); /* Start a timer set up by SDL_SetTimer() */ -extern int SDL_SYS_StartTimer (void); +extern int SDL_SYS_StartTimer(void); /* Stop a previously started timer */ -extern void SDL_SYS_StopTimer (void); +extern void SDL_SYS_StopTimer(void); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/SDL_timer.c --- a/src/timer/SDL_timer.c Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/SDL_timer.c Mon May 29 04:04:35 2006 +0000 @@ -55,12 +55,12 @@ This should not be called while the timer subsystem is running. */ int -SDL_SetTimerThreaded (int value) +SDL_SetTimerThreaded(int value) { int retval; if (SDL_timer_started) { - SDL_SetError ("Timer already initialized"); + SDL_SetError("Timer already initialized"); retval = -1; } else { retval = 0; @@ -70,19 +70,19 @@ } int -SDL_TimerInit (void) +SDL_TimerInit(void) { int retval; retval = 0; if (SDL_timer_started) { - SDL_TimerQuit (); + SDL_TimerQuit(); } if (!SDL_timer_threaded) { - retval = SDL_SYS_TimerInit (); + retval = SDL_SYS_TimerInit(); } if (SDL_timer_threaded) { - SDL_timer_mutex = SDL_CreateMutex (); + SDL_timer_mutex = SDL_CreateMutex(); } if (retval == 0) { SDL_timer_started = 1; @@ -91,14 +91,14 @@ } void -SDL_TimerQuit (void) +SDL_TimerQuit(void) { - SDL_SetTimer (0, NULL); + SDL_SetTimer(0, NULL); if (SDL_timer_threaded < 2) { - SDL_SYS_TimerQuit (); + SDL_SYS_TimerQuit(); } if (SDL_timer_threaded) { - SDL_DestroyMutex (SDL_timer_mutex); + SDL_DestroyMutex(SDL_timer_mutex); SDL_timer_mutex = NULL; } SDL_timer_started = 0; @@ -106,15 +106,15 @@ } void -SDL_ThreadedTimerCheck (void) +SDL_ThreadedTimerCheck(void) { Uint32 now, ms; SDL_TimerID t, prev, next; SDL_bool removed; - SDL_mutexP (SDL_timer_mutex); + SDL_mutexP(SDL_timer_mutex); list_changed = SDL_FALSE; - now = SDL_GetTicks (); + now = SDL_GetTicks(); for (prev = NULL, t = SDL_timers; t; t = next) { removed = SDL_FALSE; ms = t->interval - SDL_TIMESLICE; @@ -128,12 +128,12 @@ t->last_alarm = now; } #ifdef DEBUG_TIMERS - printf ("Executing timer %p (thread = %d)\n", t, SDL_ThreadID ()); + printf("Executing timer %p (thread = %d)\n", t, SDL_ThreadID()); #endif timer = *t; - SDL_mutexV (SDL_timer_mutex); - ms = timer.cb (timer.interval, timer.param); - SDL_mutexP (SDL_timer_mutex); + SDL_mutexV(SDL_timer_mutex); + ms = timer.cb(timer.interval, timer.param); + SDL_mutexP(SDL_timer_mutex); if (list_changed) { /* Abort, list of timers modified */ /* FIXME: what if ms was changed? */ @@ -141,18 +141,18 @@ } if (ms != t->interval) { if (ms) { - t->interval = ROUND_RESOLUTION (ms); + t->interval = ROUND_RESOLUTION(ms); } else { /* Remove timer from the list */ #ifdef DEBUG_TIMERS - printf ("SDL: Removing timer %p\n", t); + printf("SDL: Removing timer %p\n", t); #endif if (prev) { prev->next = next; } else { SDL_timers = next; } - SDL_free (t); + SDL_free(t); --SDL_timer_running; removed = SDL_TRUE; } @@ -163,62 +163,62 @@ prev = t; } } - SDL_mutexV (SDL_timer_mutex); + SDL_mutexV(SDL_timer_mutex); } static SDL_TimerID -SDL_AddTimerInternal (Uint32 interval, SDL_NewTimerCallback callback, - void *param) +SDL_AddTimerInternal(Uint32 interval, SDL_NewTimerCallback callback, + void *param) { SDL_TimerID t; - t = (SDL_TimerID) SDL_malloc (sizeof (struct _SDL_TimerID)); + t = (SDL_TimerID) SDL_malloc(sizeof(struct _SDL_TimerID)); if (t) { - t->interval = ROUND_RESOLUTION (interval); + t->interval = ROUND_RESOLUTION(interval); t->cb = callback; t->param = param; - t->last_alarm = SDL_GetTicks (); + t->last_alarm = SDL_GetTicks(); t->next = SDL_timers; SDL_timers = t; ++SDL_timer_running; list_changed = SDL_TRUE; } #ifdef DEBUG_TIMERS - printf ("SDL_AddTimer(%d) = %08x num_timers = %d\n", interval, (Uint32) t, - SDL_timer_running); + printf("SDL_AddTimer(%d) = %08x num_timers = %d\n", interval, (Uint32) t, + SDL_timer_running); #endif return t; } SDL_TimerID -SDL_AddTimer (Uint32 interval, SDL_NewTimerCallback callback, void *param) +SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param) { SDL_TimerID t; if (!SDL_timer_mutex) { if (SDL_timer_started) { - SDL_SetError ("This platform doesn't support multiple timers"); + SDL_SetError("This platform doesn't support multiple timers"); } else { - SDL_SetError ("You must call SDL_Init(SDL_INIT_TIMER) first"); + SDL_SetError("You must call SDL_Init(SDL_INIT_TIMER) first"); } return NULL; } if (!SDL_timer_threaded) { - SDL_SetError ("Multiple timers require threaded events!"); + SDL_SetError("Multiple timers require threaded events!"); return NULL; } - SDL_mutexP (SDL_timer_mutex); - t = SDL_AddTimerInternal (interval, callback, param); - SDL_mutexV (SDL_timer_mutex); + SDL_mutexP(SDL_timer_mutex); + t = SDL_AddTimerInternal(interval, callback, param); + SDL_mutexV(SDL_timer_mutex); return t; } SDL_bool -SDL_RemoveTimer (SDL_TimerID id) +SDL_RemoveTimer(SDL_TimerID id) { SDL_TimerID t, prev = NULL; SDL_bool removed; removed = SDL_FALSE; - SDL_mutexP (SDL_timer_mutex); + SDL_mutexP(SDL_timer_mutex); /* Look for id in the linked list of timers */ for (t = SDL_timers; t; prev = t, t = t->next) { if (t == id) { @@ -227,7 +227,7 @@ } else { SDL_timers = t->next; } - SDL_free (t); + SDL_free(t); --SDL_timer_running; removed = SDL_TRUE; list_changed = SDL_TRUE; @@ -235,45 +235,45 @@ } } #ifdef DEBUG_TIMERS - printf ("SDL_RemoveTimer(%08x) = %d num_timers = %d thread = %d\n", - (Uint32) id, removed, SDL_timer_running, SDL_ThreadID ()); + printf("SDL_RemoveTimer(%08x) = %d num_timers = %d thread = %d\n", + (Uint32) id, removed, SDL_timer_running, SDL_ThreadID()); #endif - SDL_mutexV (SDL_timer_mutex); + SDL_mutexV(SDL_timer_mutex); return removed; } /* Old style callback functions are wrapped through this */ static Uint32 SDLCALL -callback_wrapper (Uint32 ms, void *param) +callback_wrapper(Uint32 ms, void *param) { SDL_TimerCallback func = (SDL_TimerCallback) param; return (*func) (ms); } int -SDL_SetTimer (Uint32 ms, SDL_TimerCallback callback) +SDL_SetTimer(Uint32 ms, SDL_TimerCallback callback) { int retval; #ifdef DEBUG_TIMERS - printf ("SDL_SetTimer(%d)\n", ms); + printf("SDL_SetTimer(%d)\n", ms); #endif retval = 0; if (SDL_timer_threaded) { - SDL_mutexP (SDL_timer_mutex); + SDL_mutexP(SDL_timer_mutex); } if (SDL_timer_running) { /* Stop any currently running timer */ if (SDL_timer_threaded) { while (SDL_timers) { SDL_TimerID freeme = SDL_timers; SDL_timers = SDL_timers->next; - SDL_free (freeme); + SDL_free(freeme); } SDL_timer_running = 0; list_changed = SDL_TRUE; } else { - SDL_SYS_StopTimer (); + SDL_SYS_StopTimer(); SDL_timer_running = 0; } } @@ -287,11 +287,11 @@ SDL_timer_running = 1; SDL_alarm_interval = ms; SDL_alarm_callback = callback; - retval = SDL_SYS_StartTimer (); + retval = SDL_SYS_StartTimer(); } } if (SDL_timer_threaded) { - SDL_mutexV (SDL_timer_mutex); + SDL_mutexV(SDL_timer_mutex); } return retval; diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/SDL_timer_c.h --- a/src/timer/SDL_timer_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/SDL_timer_c.h Mon May 29 04:04:35 2006 +0000 @@ -37,11 +37,11 @@ /* Set whether or not the timer should use a thread. This should be called while the timer subsystem is running. */ -extern int SDL_SetTimerThreaded (int value); +extern int SDL_SetTimerThreaded(int value); -extern int SDL_TimerInit (void); -extern void SDL_TimerQuit (void); +extern int SDL_TimerInit(void); +extern void SDL_TimerQuit(void); /* This function is called from the SDL event thread if it is available */ -extern void SDL_ThreadedTimerCheck (void); +extern void SDL_ThreadedTimerCheck(void); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/amigaos/SDL_systimer.c --- a/src/timer/amigaos/SDL_systimer.c Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/amigaos/SDL_systimer.c Mon May 29 04:04:35 2006 +0000 @@ -60,18 +60,18 @@ static clock_t start; void -SDL_StartTicks (void) +SDL_StartTicks(void) { /* Set first ticks value */ - start = clock (); + start = clock(); } Uint32 -SDL_GetTicks (void) +SDL_GetTicks(void) { clock_t ticks; - ticks = clock () - start; + ticks = clock() - start; #ifdef __SASC // CLOCKS_PER_SEC == 1000 ! @@ -85,21 +85,21 @@ } void -SDL_Delay (Uint32 ms) +SDL_Delay(Uint32 ms) { // Do a busy wait if time is less than 50ms if (ms < 50) { - clock_t to_wait = clock (); + clock_t to_wait = clock(); #ifndef __SASC ms *= (CLOCKS_PER_SEC / 1000); #endif to_wait += ms; - while (clock () < to_wait); + while (clock() < to_wait); } else { - Delay (ms / 20); + Delay(ms / 20); } } @@ -107,29 +107,29 @@ ULONG MY_CLOCKS_PER_SEC; -void PPC_TimerInit (void); +void PPC_TimerInit(void); APTR MyTimer; ULONG start[2]; void -SDL_StartTicks (void) +SDL_StartTicks(void) { /* Set first ticks value */ if (!MyTimer) - PPC_TimerInit (); + PPC_TimerInit(); - PPCGetTimerObject (MyTimer, PPCTIMERTAG_CURRENTTICKS, start); + PPCGetTimerObject(MyTimer, PPCTIMERTAG_CURRENTTICKS, start); start[1] >>= 10; start[1] |= ((result[0] & 0x3ff) << 22); start[0] >>= 10; } Uint32 -SDL_GetTicks (void) +SDL_GetTicks(void) { ULONG result[2]; - PPCGetTimerObject (MyTimer, PPCTIMERTAG_CURRENTTICKS, result); + PPCGetTimerObject(MyTimer, PPCTIMERTAG_CURRENTTICKS, result); // PPCAsr64p(result,10); // Non va, la emulo: @@ -143,26 +143,26 @@ } void -SDL_Delay (Uint32 ms) +SDL_Delay(Uint32 ms) { // Do a busy wait if time is less than 50ms if (ms < 50) { ULONG to_wait[2], actual[2]; - PPCGetTimerObject (MyTimer, PPCTIMERTAG_CURRENTTICKS, result); + PPCGetTimerObject(MyTimer, PPCTIMERTAG_CURRENTTICKS, result); actual[1] = 0; to_wait[1] += ms * 1000 / MY_CLOCKS_PER_SEC; while (actual[1] < to_wait[1]) { - PPCGetTimerObject (MyTimer, PPCTIMERTAG_CURRENTTICKS, actual); + PPCGetTimerObject(MyTimer, PPCTIMERTAG_CURRENTTICKS, actual); } } else { - Delay (ms / 50); + Delay(ms / 50); } } void -PPC_TimerInit (void) +PPC_TimerInit(void) { struct TagItem tags[] = { PPCTIMERTAG_CPU, TRUE, @@ -170,30 +170,29 @@ }; - if (MyTimer = PPCCreateTimerObject (tags)) { + if (MyTimer = PPCCreateTimerObject(tags)) { ULONG result[2]; - PPCGetTimerObject (MyTimer, PPCTIMERTAG_TICKSPERSEC, result); - D (bug - ("Timer inizializzato, TPS: %lu - %lu\n", result[0], result[1])); + PPCGetTimerObject(MyTimer, PPCTIMERTAG_TICKSPERSEC, result); + D(bug("Timer inizializzato, TPS: %lu - %lu\n", result[0], result[1])); // PPCAsr64p(result,10); result[1] >>= 10; result[1] |= ((result[0] & 0x3ff) << 22); result[0] >>= 10; - D (bug ("Shiftato TPS: %lu - %lu\n", result[0], result[1])); + D(bug("Shiftato TPS: %lu - %lu\n", result[0], result[1])); MY_CLOCKS_PER_SEC = result[1]; - PPCGetTimerObject (MyTimer, PPCTIMERTAG_CURRENTTICKS, result); + PPCGetTimerObject(MyTimer, PPCTIMERTAG_CURRENTTICKS, result); - D (bug ("Current ticks: %lu - %lu\n", result[0], result[1])); + D(bug("Current ticks: %lu - %lu\n", result[0], result[1])); result[1] >>= 10; result[1] |= ((result[0] & 0x3ff) << 22); result[0] >>= 10; // PPCAsr64p(result,10); - D (bug ("Shiftato: %lu - %lu\n", result[0], result[1])); + D(bug("Shiftato: %lu - %lu\n", result[0], result[1])); } else { - D (bug ("Errore nell'inizializzazione del timer!\n")); + D(bug("Errore nell'inizializzazione del timer!\n")); } } @@ -206,61 +205,61 @@ static SDL_Thread *timer_thread = NULL; static int -RunTimer (void *unused) +RunTimer(void *unused) { - D (bug ("SYSTimer: Entering RunTimer loop...")); + D(bug("SYSTimer: Entering RunTimer loop...")); if (GfxBase == NULL) - GfxBase = (struct GfxBase *) OpenLibrary ("graphics.library", 37); + GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 37); while (timer_alive) { if (SDL_timer_running) { - SDL_ThreadedTimerCheck (); + SDL_ThreadedTimerCheck(); } if (GfxBase) - WaitTOF (); // Check the timer every fifth of seconds. Was SDL_Delay(1)->BusyWait! + WaitTOF(); // Check the timer every fifth of seconds. Was SDL_Delay(1)->BusyWait! else - Delay (1); + Delay(1); } - D (bug ("SYSTimer: EXITING RunTimer loop...")); + D(bug("SYSTimer: EXITING RunTimer loop...")); return (0); } /* This is only called if the event thread is not running */ int -SDL_SYS_TimerInit (void) +SDL_SYS_TimerInit(void) { - D (bug ("Creating thread for the timer (NOITIMER)...\n")); + D(bug("Creating thread for the timer (NOITIMER)...\n")); timer_alive = 1; - timer_thread = SDL_CreateThread (RunTimer, NULL); + timer_thread = SDL_CreateThread(RunTimer, NULL); if (timer_thread == NULL) { - D (bug ("Creazione del thread fallita...\n")); + D(bug("Creazione del thread fallita...\n")); return (-1); } - return (SDL_SetTimerThreaded (1)); + return (SDL_SetTimerThreaded(1)); } void -SDL_SYS_TimerQuit (void) +SDL_SYS_TimerQuit(void) { timer_alive = 0; if (timer_thread) { - SDL_WaitThread (timer_thread, NULL); + SDL_WaitThread(timer_thread, NULL); timer_thread = NULL; } } int -SDL_SYS_StartTimer (void) +SDL_SYS_StartTimer(void) { - SDL_SetError ("Internal logic error: AmigaOS uses threaded timer"); + SDL_SetError("Internal logic error: AmigaOS uses threaded timer"); return (-1); } void -SDL_SYS_StopTimer (void) +SDL_SYS_StopTimer(void) { return; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/beos/SDL_systimer.c --- a/src/timer/beos/SDL_systimer.c Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/beos/SDL_systimer.c Mon May 29 04:04:35 2006 +0000 @@ -32,22 +32,22 @@ static bigtime_t start; void -SDL_StartTicks (void) +SDL_StartTicks(void) { /* Set first ticks value */ - start = system_time (); + start = system_time(); } Uint32 -SDL_GetTicks (void) +SDL_GetTicks(void) { - return ((system_time () - start) / 1000); + return ((system_time() - start) / 1000); } void -SDL_Delay (Uint32 ms) +SDL_Delay(Uint32 ms) { - snooze (ms * 1000); + snooze(ms * 1000); } /* Data to handle a single periodic alarm */ @@ -55,47 +55,47 @@ static SDL_Thread *timer = NULL; static int -RunTimer (void *unused) +RunTimer(void *unused) { while (timer_alive) { if (SDL_timer_running) { - SDL_ThreadedTimerCheck (); + SDL_ThreadedTimerCheck(); } - SDL_Delay (10); + SDL_Delay(10); } return (0); } /* This is only called if the event thread is not running */ int -SDL_SYS_TimerInit (void) +SDL_SYS_TimerInit(void) { timer_alive = 1; - timer = SDL_CreateThread (RunTimer, NULL); + timer = SDL_CreateThread(RunTimer, NULL); if (timer == NULL) return (-1); - return (SDL_SetTimerThreaded (1)); + return (SDL_SetTimerThreaded(1)); } void -SDL_SYS_TimerQuit (void) +SDL_SYS_TimerQuit(void) { timer_alive = 0; if (timer) { - SDL_WaitThread (timer, NULL); + SDL_WaitThread(timer, NULL); timer = NULL; } } int -SDL_SYS_StartTimer (void) +SDL_SYS_StartTimer(void) { - SDL_SetError ("Internal logic error: BeOS uses threaded timer"); + SDL_SetError("Internal logic error: BeOS uses threaded timer"); return (-1); } void -SDL_SYS_StopTimer (void) +SDL_SYS_StopTimer(void) { return; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/dc/SDL_systimer.c --- a/src/timer/dc/SDL_systimer.c Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/dc/SDL_systimer.c Mon May 29 04:04:35 2006 +0000 @@ -37,22 +37,22 @@ */ void -SDL_StartTicks (void) +SDL_StartTicks(void) { /* Set first ticks value */ start = jiffies; } Uint32 -SDL_GetTicks (void) +SDL_GetTicks(void) { return ((jiffies - start) * 1000 / HZ); } void -SDL_Delay (Uint32 ms) +SDL_Delay(Uint32 ms) { - thd_sleep (ms); + thd_sleep(ms); } /* Data to handle a single periodic alarm */ @@ -60,47 +60,47 @@ static SDL_Thread *timer = NULL; static int -RunTimer (void *unused) +RunTimer(void *unused) { while (timer_alive) { if (SDL_timer_running) { - SDL_ThreadedTimerCheck (); + SDL_ThreadedTimerCheck(); } - SDL_Delay (10); + SDL_Delay(10); } return (0); } /* This is only called if the event thread is not running */ int -SDL_SYS_TimerInit (void) +SDL_SYS_TimerInit(void) { timer_alive = 1; - timer = SDL_CreateThread (RunTimer, NULL); + timer = SDL_CreateThread(RunTimer, NULL); if (timer == NULL) return (-1); - return (SDL_SetTimerThreaded (1)); + return (SDL_SetTimerThreaded(1)); } void -SDL_SYS_TimerQuit (void) +SDL_SYS_TimerQuit(void) { timer_alive = 0; if (timer) { - SDL_WaitThread (timer, NULL); + SDL_WaitThread(timer, NULL); timer = NULL; } } int -SDL_SYS_StartTimer (void) +SDL_SYS_StartTimer(void) { - SDL_SetError ("Internal logic error: DC uses threaded timer"); + SDL_SetError("Internal logic error: DC uses threaded timer"); return (-1); } void -SDL_SYS_StopTimer (void) +SDL_SYS_StopTimer(void) { return; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/dummy/SDL_systimer.c --- a/src/timer/dummy/SDL_systimer.c Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/dummy/SDL_systimer.c Mon May 29 04:04:35 2006 +0000 @@ -27,21 +27,21 @@ #include "../SDL_timer_c.h" void -SDL_StartTicks (void) +SDL_StartTicks(void) { } Uint32 -SDL_GetTicks (void) +SDL_GetTicks(void) { - SDL_Unsupported (); + SDL_Unsupported(); return 0; } void -SDL_Delay (Uint32 ms) +SDL_Delay(Uint32 ms) { - SDL_Unsupported (); + SDL_Unsupported(); } #include "SDL_thread.h" @@ -51,47 +51,47 @@ static SDL_Thread *timer = NULL; static int -RunTimer (void *unused) +RunTimer(void *unused) { while (timer_alive) { if (SDL_timer_running) { - SDL_ThreadedTimerCheck (); + SDL_ThreadedTimerCheck(); } - SDL_Delay (1); + SDL_Delay(1); } return (0); } /* This is only called if the event thread is not running */ int -SDL_SYS_TimerInit (void) +SDL_SYS_TimerInit(void) { timer_alive = 1; - timer = SDL_CreateThread (RunTimer, NULL); + timer = SDL_CreateThread(RunTimer, NULL); if (timer == NULL) return (-1); - return (SDL_SetTimerThreaded (1)); + return (SDL_SetTimerThreaded(1)); } void -SDL_SYS_TimerQuit (void) +SDL_SYS_TimerQuit(void) { timer_alive = 0; if (timer) { - SDL_WaitThread (timer, NULL); + SDL_WaitThread(timer, NULL); timer = NULL; } } int -SDL_SYS_StartTimer (void) +SDL_SYS_StartTimer(void) { - SDL_SetError ("Internal logic error: threaded timer in use"); + SDL_SetError("Internal logic error: threaded timer in use"); return (-1); } void -SDL_SYS_StopTimer (void) +SDL_SYS_StopTimer(void) { return; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/macos/FastTimes.c --- a/src/timer/macos/FastTimes.c Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/macos/FastTimes.c Mon May 29 04:04:35 2006 +0000 @@ -78,9 +78,9 @@ #if GENERATINGPOWERPC -static asm UnsignedWide PollRTC (void); -static asm UnsignedWide PollTBR (void); -static Ptr FindFunctionInSharedLib (StringPtr libName, StringPtr funcName); +static asm UnsignedWide PollRTC(void); +static asm UnsignedWide PollTBR(void); +static Ptr FindFunctionInSharedLib(StringPtr libName, StringPtr funcName); static Boolean gInited = false; static Boolean gNative = false; @@ -90,8 +90,8 @@ static double gScaleMSec = 1.0 / 1000000.0; /* 1 / ( nsec / msec) */ /* Functions loaded from DriverServicesLib */ -typedef AbsoluteTime (*UpTimeProcPtr) (void); -typedef Nanoseconds (*A2NSProcPtr) (AbsoluteTime); +typedef AbsoluteTime(*UpTimeProcPtr) (void); +typedef Nanoseconds(*A2NSProcPtr) (AbsoluteTime); static UpTimeProcPtr gUpTime = NULL; static A2NSProcPtr gA2NS = NULL; @@ -101,7 +101,7 @@ /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ void -FastInitialize () +FastInitialize() { SInt32 result; @@ -115,12 +115,12 @@ /* We use CFM to find and load needed symbols from shared libraries, so the application doesn't have to weak-link them, for convenience. */ gUpTime = - (UpTimeProcPtr) FindFunctionInSharedLib ("\pDriverServicesLib", - "\pUpTime"); + (UpTimeProcPtr) FindFunctionInSharedLib("\pDriverServicesLib", + "\pUpTime"); if (gUpTime) gA2NS = (A2NSProcPtr) - FindFunctionInSharedLib ("\pDriverServicesLib", - "\pAbsoluteToNanoseconds"); + FindFunctionInSharedLib("\pDriverServicesLib", + "\pAbsoluteToNanoseconds"); if (!gA2NS) gUpTime = nil; /* Pedantic but necessary */ @@ -130,7 +130,7 @@ pointless to calculate a scale factor against the missing VIA */ /* gestaltNativeTimeMgr = 4 in some future version of the headers */ - if (!Gestalt (gestaltTimeMgrVersion, &result) && + if (!Gestalt(gestaltTimeMgrVersion, &result) && (result > gestaltExtendedTimeMgr)) gNative = true; } else { @@ -139,7 +139,7 @@ we know it should either be a 601 or 603. */ /* Use the processor gestalt to determine which register to use */ - if (!Gestalt (gestaltNativeCPUtype, &result)) { + if (!Gestalt(gestaltNativeCPUtype, &result)) { if (result == gestaltCPU601) gUseRTC = true; else if (result > gestaltCPU601) @@ -153,20 +153,20 @@ UnsignedWide wide; /* Wait for the beginning of the very next tick */ - for (tick = MyLMGetTicks () + 1; tick > MyLMGetTicks ();); + for (tick = MyLMGetTicks() + 1; tick > MyLMGetTicks();); /* Poll the selected timer and prepare it (since we have time) */ wide = (gUpTime) ? (*gA2NS) ((*gUpTime) ()) : - ((gUseRTC) ? PollRTC () : PollTBR ()); - usec1 = (gUseRTC) ? RTCToNano (wide) : WideTo64bit (wide); + ((gUseRTC) ? PollRTC() : PollTBR()); + usec1 = (gUseRTC) ? RTCToNano(wide) : WideTo64bit(wide); /* Wait for the exact 60th tick to roll over */ - while (tick + 60 > MyLMGetTicks ()); + while (tick + 60 > MyLMGetTicks()); /* Poll the selected timer again and prepare it */ wide = (gUpTime) ? (*gA2NS) ((*gUpTime) ()) : - ((gUseRTC) ? PollRTC () : PollTBR ()); - usec2 = (gUseRTC) ? RTCToNano (wide) : WideTo64bit (wide); + ((gUseRTC) ? PollRTC() : PollTBR()); + usec2 = (gUseRTC) ? RTCToNano(wide) : WideTo64bit(wide); /* Calculate a scale value that will give microseconds per second. Remember, there are actually 60.15 ticks in a second, not 60. */ @@ -184,7 +184,7 @@ /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ UInt64 -FastMicroseconds () +FastMicroseconds() { UnsignedWide wide; UInt64 usec; @@ -192,30 +192,30 @@ #if GENERATINGPOWERPC /* Initialize globals the first time we are called */ if (!gInited) - FastInitialize (); + FastInitialize(); if (gNative) { /* Use DriverServices if it's available -- it's fast and compatible */ wide = (*gA2NS) ((*gUpTime) ()); - usec = (double) WideTo64bit (wide) * gScaleUSec + 0.5; + usec = (double) WideTo64bit(wide) * gScaleUSec + 0.5; } else if (gUpTime) { /* Use DriverServices if it's available -- it's fast and compatible */ wide = (*gA2NS) ((*gUpTime) ()); - usec = (double) WideTo64bit (wide) * gScaleUSec + 0.5; + usec = (double) WideTo64bit(wide) * gScaleUSec + 0.5; } else if (gUseTBR) { /* On a recent PowerPC, we poll the TBR directly */ - wide = PollTBR (); - usec = (double) WideTo64bit (wide) * gScaleUSec + 0.5; + wide = PollTBR(); + usec = (double) WideTo64bit(wide) * gScaleUSec + 0.5; } else if (gUseRTC) { /* On a 601, we can poll the RTC instead */ - wide = PollRTC (); - usec = (double) RTCToNano (wide) * gScaleUSec + 0.5; + wide = PollRTC(); + usec = (double) RTCToNano(wide) * gScaleUSec + 0.5; } else #endif /* GENERATINGPOWERPC */ { /* If all else fails, suffer the mixed mode overhead */ - Microseconds (&wide); - usec = WideTo64bit (wide); + Microseconds(&wide); + usec = WideTo64bit(wide); } return (usec); @@ -225,7 +225,7 @@ /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ UInt64 -FastMilliseconds () +FastMilliseconds() { UnsignedWide wide; UInt64 msec; @@ -233,30 +233,30 @@ #if GENERATINGPOWERPC /* Initialize globals the first time we are called */ if (!gInited) - FastInitialize (); + FastInitialize(); if (gNative) { /* Use DriverServices if it's available -- it's fast and compatible */ wide = (*gA2NS) ((*gUpTime) ()); - msec = (double) WideTo64bit (wide) * gScaleMSec + 0.5; + msec = (double) WideTo64bit(wide) * gScaleMSec + 0.5; } else if (gUpTime) { /* Use DriverServices if it's available -- it's fast and compatible */ wide = (*gA2NS) ((*gUpTime) ()); - msec = (double) WideTo64bit (wide) * gScaleMSec + 0.5; + msec = (double) WideTo64bit(wide) * gScaleMSec + 0.5; } else if (gUseTBR) { /* On a recent PowerPC, we poll the TBR directly */ - wide = PollTBR (); - msec = (double) WideTo64bit (wide) * gScaleMSec + 0.5; + wide = PollTBR(); + msec = (double) WideTo64bit(wide) * gScaleMSec + 0.5; } else if (gUseRTC) { /* On a 601, we can poll the RTC instead */ - wide = PollRTC (); - msec = (double) RTCToNano (wide) * gScaleMSec + 0.5; + wide = PollRTC(); + msec = (double) RTCToNano(wide) * gScaleMSec + 0.5; } else #endif /* GENERATINGPOWERPC */ { /* If all else fails, suffer the mixed mode overhead */ - Microseconds (&wide); - msec = ((double) WideTo64bit (wide) + 500.0) / 1000.0; + Microseconds(&wide); + msec = ((double) WideTo64bit(wide) + 500.0) / 1000.0; } return (msec); @@ -266,14 +266,14 @@ /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ StringPtr -FastMethod () +FastMethod() { StringPtr method = "\p"; #if GENERATINGPOWERPC /* Initialize globals the first time we are called */ if (!gInited) - FastInitialize (); + FastInitialize(); if (gNative) { /* The Time Manager and UpTime() are entirely native on this machine */ @@ -303,29 +303,29 @@ #if GENERATINGPOWERPC asm static UnsignedWide -PollRTC_ () +PollRTC_() { entry PollRTC /* Avoid CodeWarrior glue */ machine 601 @ AGAIN:mfrtcu r4 /* RTCU = SPR 4 */ mfrtcl r5 /* RTCL = SPR 5 */ - mfrtcu r6 cmpw r4, r6 bne @ AGAIN stw r4, 0 (r3) stw r5, 4 (r3) blr} + mfrtcu r6 cmpw r4, r6 bne @ AGAIN stw r4, 0(r3) stw r5, 4(r3) blr} /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ asm static UnsignedWide -PollTBR_ () +PollTBR_() { entry PollTBR /* Avoid CodeWarrior glue */ machine 604 @ AGAIN:mftbu r4 /* TBRU = SPR 268 */ mftb r5 /* TBRL = SPR 269 */ - mftbu r6 cmpw r4, r6 bne @ AGAIN stw r4, 0 (r3) stw r5, 4 (r3) blr} + mftbu r6 cmpw r4, r6 bne @ AGAIN stw r4, 0(r3) stw r5, 4(r3) blr} /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ static Ptr -FindFunctionInSharedLib (StringPtr libName, StringPtr funcName) +FindFunctionInSharedLib(StringPtr libName, StringPtr funcName) { OSErr error = noErr; Str255 errorStr; @@ -335,11 +335,11 @@ CFragConnectionID connID; /* Find CFM containers for the current archecture -- CFM-PPC or CFM-68K */ - if ( /* error = */ GetSharedLibrary (libName, kCompiledCFragArch, - kLoadCFrag, &connID, &entry, - errorStr)) + if ( /* error = */ GetSharedLibrary(libName, kCompiledCFragArch, + kLoadCFrag, &connID, &entry, + errorStr)) return (NULL); - if ( /* error = */ FindSymbol (connID, funcName, &func, &symClass)) + if ( /* error = */ FindSymbol(connID, funcName, &func, &symClass)) return (NULL); return (func); diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/macos/FastTimes.h --- a/src/timer/macos/FastTimes.h Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/macos/FastTimes.h Mon May 29 04:04:35 2006 +0000 @@ -16,10 +16,10 @@ /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ -extern void FastInitialize (void); -extern UInt64 FastMicroseconds (void); -extern UInt64 FastMilliseconds (void); -extern StringPtr FastMethod (void); +extern void FastInitialize(void); +extern UInt64 FastMicroseconds(void); +extern UInt64 FastMilliseconds(void); +extern StringPtr FastMethod(void); /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/macos/SDL_MPWtimer.c --- a/src/timer/macos/SDL_MPWtimer.c Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/macos/SDL_MPWtimer.c Mon May 29 04:04:35 2006 +0000 @@ -45,45 +45,45 @@ UInt64 start; void -SDL_StartTicks (void) +SDL_StartTicks(void) { #ifdef USE_MICROSECONDS UnsignedWide now; - Microseconds (&now); - start = WideTo64bit (now); + Microseconds(&now); + start = WideTo64bit(now); #else /* FIXME: Should we implement a wrapping algorithm, like Win32? */ #endif } Uint32 -SDL_GetTicks (void) +SDL_GetTicks(void) { #ifdef USE_MICROSECONDS UnsignedWide now; - Microseconds (&now); - return (Uint32) ((WideTo64bit (now) - start) / 1000); + Microseconds(&now); + return (Uint32) ((WideTo64bit(now) - start) / 1000); #else - return (LMGetTicks () * MS_PER_TICK); + return (LMGetTicks() * MS_PER_TICK); #endif } void -SDL_Delay (Uint32 ms) +SDL_Delay(Uint32 ms) { #ifdef USE_MICROSECONDS Uint32 end_ms; - end_ms = SDL_GetTicks () + ms; + end_ms = SDL_GetTicks() + ms; do { /* FIXME: Yield CPU? */ ; } - while (SDL_GetTicks () < end_ms); + while (SDL_GetTicks() < end_ms); #else UInt32 unused; /* MJS */ - Delay (ms / MS_PER_TICK, &unused); + Delay(ms / MS_PER_TICK, &unused); #endif } @@ -99,14 +99,14 @@ int -SDL_SYS_TimerInit (void) +SDL_SYS_TimerInit(void) { /* We don't need a setup? */ return (0); } void -SDL_SYS_TimerQuit (void) +SDL_SYS_TimerQuit(void) { /* We don't need a cleanup? */ return; @@ -114,47 +114,47 @@ /* Our Stub routine to set up and then call the real routine. */ pascal void -TimerCallbackProc (TMTaskPtr tmTaskPtr) +TimerCallbackProc(TMTaskPtr tmTaskPtr) { Uint32 ms; - WakeUpProcess (&((ExtendedTimerPtr) tmTaskPtr)->taskPSN); + WakeUpProcess(&((ExtendedTimerPtr) tmTaskPtr)->taskPSN); - ms = SDL_alarm_callback (SDL_alarm_interval); + ms = SDL_alarm_callback(SDL_alarm_interval); if (ms) { - SDL_alarm_interval = ROUND_RESOLUTION (ms); - PrimeTime ((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval); + SDL_alarm_interval = ROUND_RESOLUTION(ms); + PrimeTime((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval); } else { SDL_alarm_interval = 0; } } int -SDL_SYS_StartTimer (void) +SDL_SYS_StartTimer(void) { /* * Configure the global structure that stores the timing information. */ gExtendedTimerRec.tmTask.qLink = NULL; gExtendedTimerRec.tmTask.qType = 0; - gExtendedTimerRec.tmTask.tmAddr = NewTimerUPP (TimerCallbackProc); + gExtendedTimerRec.tmTask.tmAddr = NewTimerUPP(TimerCallbackProc); gExtendedTimerRec.tmTask.tmCount = 0; gExtendedTimerRec.tmTask.tmWakeUp = 0; gExtendedTimerRec.tmTask.tmReserved = 0; - GetCurrentProcess (&gExtendedTimerRec.taskPSN); + GetCurrentProcess(&gExtendedTimerRec.taskPSN); /* Install the task record */ - InsXTime ((QElemPtr) & gExtendedTimerRec.tmTask); + InsXTime((QElemPtr) & gExtendedTimerRec.tmTask); /* Go! */ - PrimeTime ((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval); + PrimeTime((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval); return (0); } void -SDL_SYS_StopTimer (void) +SDL_SYS_StopTimer(void) { - RmvTime ((QElemPtr) & gExtendedTimerRec.tmTask); + RmvTime((QElemPtr) & gExtendedTimerRec.tmTask); } #endif /* SDL_TIMER_MACOS */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/macos/SDL_systimer.c --- a/src/timer/macos/SDL_systimer.c Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/macos/SDL_systimer.c Mon May 29 04:04:35 2006 +0000 @@ -49,38 +49,38 @@ static int is_fast_inited = 0; void -SDL_StartTicks (void) +SDL_StartTicks(void) { if (!is_fast_inited) // important to check or FastTime may hang machine! - SDL_SYS_TimerInit (); + SDL_SYS_TimerInit(); - start_tick = FastMicroseconds (); + start_tick = FastMicroseconds(); } Uint32 -SDL_GetTicks (void) +SDL_GetTicks(void) { if (!is_fast_inited) - SDL_SYS_TimerInit (); + SDL_SYS_TimerInit(); - return FastMilliseconds (); + return FastMilliseconds(); } void -SDL_Delay (Uint32 ms) +SDL_Delay(Uint32 ms) { Uint32 stop, now; - stop = SDL_GetTicks () + ms; + stop = SDL_GetTicks() + ms; do { #if TARGET_API_MAC_CARBON - MPYield (); + MPYield(); #else - SystemTask (); + SystemTask(); #endif - now = SDL_GetTicks (); + now = SDL_GetTicks(); } while (stop > now); @@ -131,16 +131,16 @@ int -SDL_SYS_TimerInit (void) +SDL_SYS_TimerInit(void) { - FastInitialize (); + FastInitialize(); is_fast_inited = 1; return (0); } void -SDL_SYS_TimerQuit (void) +SDL_SYS_TimerQuit(void) { /* We don't need a cleanup? */ return; @@ -148,47 +148,47 @@ /* Our Stub routine to set up and then call the real routine. */ pascal void -TimerCallbackProc (TMTaskPtr tmTaskPtr) +TimerCallbackProc(TMTaskPtr tmTaskPtr) { Uint32 ms; - WakeUpProcess (&((ExtendedTimerPtr) tmTaskPtr)->taskPSN); + WakeUpProcess(&((ExtendedTimerPtr) tmTaskPtr)->taskPSN); - ms = SDL_alarm_callback (SDL_alarm_interval); + ms = SDL_alarm_callback(SDL_alarm_interval); if (ms) { - SDL_alarm_interval = ROUND_RESOLUTION (ms); - PrimeTime ((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval); + SDL_alarm_interval = ROUND_RESOLUTION(ms); + PrimeTime((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval); } else { SDL_alarm_interval = 0; } } int -SDL_SYS_StartTimer (void) +SDL_SYS_StartTimer(void) { /* * Configure the global structure that stores the timing information. */ gExtendedTimerRec.tmTask.qLink = NULL; gExtendedTimerRec.tmTask.qType = 0; - gExtendedTimerRec.tmTask.tmAddr = NewTimerProc (TimerCallbackProc); + gExtendedTimerRec.tmTask.tmAddr = NewTimerProc(TimerCallbackProc); gExtendedTimerRec.tmTask.tmCount = 0; gExtendedTimerRec.tmTask.tmWakeUp = 0; gExtendedTimerRec.tmTask.tmReserved = 0; - GetCurrentProcess (&gExtendedTimerRec.taskPSN); + GetCurrentProcess(&gExtendedTimerRec.taskPSN); /* Install the task record */ - InsXTime ((QElemPtr) & gExtendedTimerRec.tmTask); + InsXTime((QElemPtr) & gExtendedTimerRec.tmTask); /* Go! */ - PrimeTime ((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval); + PrimeTime((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval); return (0); } void -SDL_SYS_StopTimer (void) +SDL_SYS_StopTimer(void) { - RmvTime ((QElemPtr) & gExtendedTimerRec.tmTask); + RmvTime((QElemPtr) & gExtendedTimerRec.tmTask); } #endif /* SDL_TIMER_MACOS */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/mint/SDL_systimer.c --- a/src/timer/mint/SDL_systimer.c Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/mint/SDL_systimer.c Mon May 29 04:04:35 2006 +0000 @@ -54,23 +54,23 @@ static int mint_present; /* can we use Syield() ? */ void -SDL_StartTicks (void) +SDL_StartTicks(void) { void *oldpile; unsigned long dummy; /* Set first ticks value */ - oldpile = (void *) Super (0); + oldpile = (void *) Super(0); start = *((volatile long *) _hz_200); - Super (oldpile); + Super(oldpile); start *= 5; /* One _hz_200 tic is 5ms */ - mint_present = (Getcookie (C_MiNT, &dummy) == C_FOUND); + mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); } Uint32 -SDL_GetTicks (void) +SDL_GetTicks(void) { Uint32 now; void *oldpile = NULL; @@ -80,27 +80,27 @@ which is called from RunTimer, running in the vbl vector) */ if (!supervisor) { - oldpile = (void *) Super (0); + oldpile = (void *) Super(0); } now = *((volatile long *) _hz_200); if (!supervisor) { - Super (oldpile); + Super(oldpile); } return ((now * 5) - start); } void -SDL_Delay (Uint32 ms) +SDL_Delay(Uint32 ms) { Uint32 now; - now = SDL_GetTicks (); - while ((SDL_GetTicks () - now) < ms) { + now = SDL_GetTicks(); + while ((SDL_GetTicks() - now) < ms) { if (mint_present) { - Syield (); + Syield(); } } } @@ -109,55 +109,55 @@ static SDL_bool timer_installed = SDL_FALSE; static void -RunTimer (void) +RunTimer(void) { supervisor = SDL_TRUE; - SDL_ThreadedTimerCheck (); + SDL_ThreadedTimerCheck(); supervisor = SDL_FALSE; } /* This is only called if the event thread is not running */ int -SDL_SYS_TimerInit (void) +SDL_SYS_TimerInit(void) { void *oldpile; supervisor = SDL_FALSE; /* Install RunTimer in vbl vector */ - oldpile = (void *) Super (0); - timer_installed = !SDL_AtariVblInstall (RunTimer); - Super (oldpile); + oldpile = (void *) Super(0); + timer_installed = !SDL_AtariVblInstall(RunTimer); + Super(oldpile); if (!timer_installed) { return (-1); } - return (SDL_SetTimerThreaded (0)); + return (SDL_SetTimerThreaded(0)); } void -SDL_SYS_TimerQuit (void) +SDL_SYS_TimerQuit(void) { void *oldpile; if (timer_installed) { /* Uninstall RunTimer vbl vector */ - oldpile = (void *) Super (0); - SDL_AtariVblUninstall (RunTimer); - Super (oldpile); + oldpile = (void *) Super(0); + SDL_AtariVblUninstall(RunTimer); + Super(oldpile); timer_installed = SDL_FALSE; } } int -SDL_SYS_StartTimer (void) +SDL_SYS_StartTimer(void) { - SDL_SetError ("Internal logic error: MiNT uses vbl timer"); + SDL_SetError("Internal logic error: MiNT uses vbl timer"); return (-1); } void -SDL_SYS_StopTimer (void) +SDL_SYS_StopTimer(void) { return; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/mint/SDL_vbltimer_s.h --- a/src/timer/mint/SDL_vbltimer_s.h Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/mint/SDL_vbltimer_s.h Mon May 29 04:04:35 2006 +0000 @@ -29,6 +29,6 @@ */ /* Functions prototypes */ -extern int SDL_AtariVblInstall (void *newvector); -extern void SDL_AtariVblUninstall (void *newvector); +extern int SDL_AtariVblInstall(void *newvector); +extern void SDL_AtariVblUninstall(void *newvector); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/os2/SDL_systimer.c --- a/src/timer/os2/SDL_systimer.c Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/os2/SDL_systimer.c Mon May 29 04:04:35 2006 +0000 @@ -45,19 +45,19 @@ static ULONG hires_ticks_per_second; void -SDL_StartTicks (void) +SDL_StartTicks(void) { - DosTmrQueryFreq (&hires_ticks_per_second); - DosTmrQueryTime ((PQWORD) & hires_start_ticks); + DosTmrQueryFreq(&hires_ticks_per_second); + DosTmrQueryTime((PQWORD) & hires_start_ticks); } DECLSPEC Uint32 SDLCALL -SDL_GetTicks (void) +SDL_GetTicks(void) { long long hires_now; ULONG ticks = ticks; - DosTmrQueryTime ((PQWORD) & hires_now); + DosTmrQueryTime((PQWORD) & hires_now); /* hires_now -= hires_start_ticks; hires_now *= 1000; @@ -90,7 +90,7 @@ /* High resolution sleep, originally made by Ilya Zakharevich */ DECLSPEC void SDLCALL -SDL_Delay (Uint32 ms) +SDL_Delay(Uint32 ms) { /* This is similar to DosSleep(), but has 8ms granularity in time-critical threads even on Warp3. */ @@ -105,15 +105,15 @@ APIRET badrc; int switch_priority = 50; - DosCreateEventSem (NULL, /* Unnamed */ - &hevEvent1, /* Handle of semaphore returned */ - DC_SEM_SHARED, /* Shared needed for DosAsyncTimer */ - FALSE); /* Semaphore is in RESET state */ + DosCreateEventSem(NULL, /* Unnamed */ + &hevEvent1, /* Handle of semaphore returned */ + DC_SEM_SHARED, /* Shared needed for DosAsyncTimer */ + FALSE); /* Semaphore is in RESET state */ if (ms >= switch_priority) switch_priority = 0; if (switch_priority) { - if (DosGetInfoBlocks (&tib, &pib) != NO_ERROR) + if (DosGetInfoBlocks(&tib, &pib) != NO_ERROR) switch_priority = 0; else { /* In Warp3, to switch scheduling to 8ms step, one needs to do @@ -131,47 +131,46 @@ /* tib->tib_ptib2->tib2_ulpri = 0x0300; */ /* We do not want to run at high priority if a signal causes us to longjmp() out of this section... */ - if (DosEnterMustComplete (&nesting)) + if (DosEnterMustComplete(&nesting)) switch_priority = 0; else - DosSetPriority (PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0); + DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0); } } - if ((badrc = DosAsyncTimer (ms, (HSEM) hevEvent1, /* Semaphore to post */ - &htimerEvent1))) /* Timer handler (returned) */ + if ((badrc = DosAsyncTimer(ms, (HSEM) hevEvent1, /* Semaphore to post */ + &htimerEvent1))) /* Timer handler (returned) */ e = "DosAsyncTimer"; if (switch_priority && tib->tib_ptib2->tib2_ulpri == 0x0300) { /* Nobody switched priority while we slept... Ignore errors... */ /* tib->tib_ptib2->tib2_ulpri = priority; *//* Get back... */ if (! - (rc = - DosSetPriority (PRTYS_THREAD, (priority >> 8) & 0xFF, 0, 0))) - rc = DosSetPriority (PRTYS_THREAD, 0, priority & 0xFF, 0); + (rc = DosSetPriority(PRTYS_THREAD, (priority >> 8) & 0xFF, 0, 0))) + rc = DosSetPriority(PRTYS_THREAD, 0, priority & 0xFF, 0); } if (switch_priority) - rc = DosExitMustComplete (&nesting); /* Ignore errors */ + rc = DosExitMustComplete(&nesting); /* Ignore errors */ /* The actual blocking call is made with "normal" priority. This way we should not bother with DosSleep(0) etc. to compensate for us interrupting higher-priority threads. The goal is to prohibit the system spending too much time halt()ing, not to run us "no matter what". */ if (!e) /* Wait for AsyncTimer event */ - badrc = DosWaitEventSem (hevEvent1, SEM_INDEFINITE_WAIT); + badrc = DosWaitEventSem(hevEvent1, SEM_INDEFINITE_WAIT); if (e); /* Do nothing */ else if (badrc == ERROR_INTERRUPT) ret = 0; else if (badrc) e = "DosWaitEventSem"; - if ((rc = DosCloseEventSem (hevEvent1)) && !e) { /* Get rid of semaphore */ + if ((rc = DosCloseEventSem(hevEvent1)) && !e) { /* Get rid of semaphore */ e = "DosCloseEventSem"; badrc = rc; } if (e) { - SDL_SetError ("[SDL_Delay] : Had error in %s(), rc is 0x%x\n", e, - badrc); + SDL_SetError("[SDL_Delay] : Had error in %s(), rc is 0x%x\n", e, + badrc); } } @@ -180,48 +179,48 @@ static SDL_Thread *timer = NULL; static int -RunTimer (void *unused) +RunTimer(void *unused) { - DosSetPriority (PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0); + DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0); while (timer_alive) { if (SDL_timer_running) { - SDL_ThreadedTimerCheck (); + SDL_ThreadedTimerCheck(); } - SDL_Delay (10); + SDL_Delay(10); } return (0); } /* This is only called if the event thread is not running */ int -SDL_SYS_TimerInit (void) +SDL_SYS_TimerInit(void) { timer_alive = 1; - timer = SDL_CreateThread (RunTimer, NULL); + timer = SDL_CreateThread(RunTimer, NULL); if (timer == NULL) return (-1); - return (SDL_SetTimerThreaded (1)); + return (SDL_SetTimerThreaded(1)); } void -SDL_SYS_TimerQuit (void) +SDL_SYS_TimerQuit(void) { timer_alive = 0; if (timer) { - SDL_WaitThread (timer, NULL); + SDL_WaitThread(timer, NULL); timer = NULL; } } int -SDL_SYS_StartTimer (void) +SDL_SYS_StartTimer(void) { - SDL_SetError ("Internal logic error: OS/2 uses threaded timer"); + SDL_SetError("Internal logic error: OS/2 uses threaded timer"); return (-1); } void -SDL_SYS_StopTimer (void) +SDL_SYS_StopTimer(void) { return; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/riscos/SDL_systimer.c --- a/src/timer/riscos/SDL_systimer.c Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/riscos/SDL_systimer.c Mon May 29 04:04:35 2006 +0000 @@ -37,34 +37,34 @@ /* Timer SDL_arraysize(Timer ),start/reset time */ static Uint32 timerStart; /* Timer running function */ -void RISCOS_CheckTimer (); +void RISCOS_CheckTimer(); #else #include extern Uint32 riscos_main_thread; extern int riscos_using_threads; -extern Uint32 SDL_ThreadID (); -extern Uint32 SDL_EventThreadID (void); +extern Uint32 SDL_ThreadID(); +extern Uint32 SDL_EventThreadID(void); #endif -extern void RISCOS_BackgroundTasks (void); +extern void RISCOS_BackgroundTasks(void); /* The first ticks value of the application */ clock_t start; void -SDL_StartTicks (void) +SDL_StartTicks(void) { /* Set first ticks value */ - start = clock (); + start = clock(); } Uint32 -SDL_GetTicks (void) +SDL_GetTicks(void) { clock_t ticks; - ticks = clock () - start; + ticks = clock() - start; #if CLOCKS_PER_SEC == 1000 @@ -84,17 +84,17 @@ } void -SDL_Delay (Uint32 ms) +SDL_Delay(Uint32 ms) { Uint32 now, then, elapsed; #if !SDL_THREADS_DISABLED int is_event_thread; if (riscos_using_threads) { is_event_thread = 0; - if (SDL_EventThreadID ()) { - if (SDL_EventThreadID () == SDL_ThreadID ()) + if (SDL_EventThreadID()) { + if (SDL_EventThreadID() == SDL_ThreadID()) is_event_thread = 1; - } else if (SDL_ThreadID () == riscos_main_thread) + } else if (SDL_ThreadID() == riscos_main_thread) is_event_thread = 1; } else is_event_thread = 1; @@ -104,20 +104,20 @@ /* for non event threads */ /* Set the timeout interval - Linux only needs to do this once */ - then = SDL_GetTicks (); + then = SDL_GetTicks(); do { /* Do background tasks required while sleeping as we are not multithreaded */ #if SDL_THREADS_DISABLED - RISCOS_BackgroundTasks (); + RISCOS_BackgroundTasks(); #else /* For threaded build only run background tasks in event thread */ if (is_event_thread) - RISCOS_BackgroundTasks (); + RISCOS_BackgroundTasks(); #endif /* Calculate the time interval left (in case of interrupt) */ - now = SDL_GetTicks (); + now = SDL_GetTicks(); elapsed = (now - then); then = now; if (elapsed >= ms) { @@ -127,7 +127,7 @@ #if !SDL_THREADS_DISABLED /* Need to yield to let other threads have a go */ if (riscos_using_threads) - pthread_yield (); + pthread_yield(); #endif } @@ -139,27 +139,27 @@ /* Non-threaded version of timer */ int -SDL_SYS_TimerInit (void) +SDL_SYS_TimerInit(void) { return (0); } void -SDL_SYS_TimerQuit (void) +SDL_SYS_TimerQuit(void) { - SDL_SetTimer (0, NULL); + SDL_SetTimer(0, NULL); } int -SDL_SYS_StartTimer (void) +SDL_SYS_StartTimer(void) { - timerStart = SDL_GetTicks (); + timerStart = SDL_GetTicks(); return (0); } void -SDL_SYS_StopTimer (void) +SDL_SYS_StopTimer(void) { /* Don't need to do anything as we use SDL_timer_running to detect if we need to check the timer */ @@ -167,23 +167,23 @@ void -RISCOS_CheckTimer () +RISCOS_CheckTimer() { if (SDL_timer_running - && SDL_GetTicks () - timerStart >= SDL_alarm_interval) { + && SDL_GetTicks() - timerStart >= SDL_alarm_interval) { Uint32 ms; - ms = SDL_alarm_callback (SDL_alarm_interval); + ms = SDL_alarm_callback(SDL_alarm_interval); if (ms != SDL_alarm_interval) { if (ms) { - SDL_alarm_interval = ROUND_RESOLUTION (ms); + SDL_alarm_interval = ROUND_RESOLUTION(ms); } else { SDL_alarm_interval = 0; SDL_timer_running = 0; } } if (SDL_alarm_interval) - timerStart = SDL_GetTicks (); + timerStart = SDL_GetTicks(); } } @@ -198,47 +198,47 @@ static SDL_Thread *timer = NULL; static int -RunTimer (void *unused) +RunTimer(void *unused) { while (timer_alive) { if (SDL_timer_running) { - SDL_ThreadedTimerCheck (); + SDL_ThreadedTimerCheck(); } - SDL_Delay (1); + SDL_Delay(1); } return (0); } /* This is only called if the event thread is not running */ int -SDL_SYS_TimerInit (void) +SDL_SYS_TimerInit(void) { timer_alive = 1; - timer = SDL_CreateThread (RunTimer, NULL); + timer = SDL_CreateThread(RunTimer, NULL); if (timer == NULL) return (-1); - return (SDL_SetTimerThreaded (1)); + return (SDL_SetTimerThreaded(1)); } void -SDL_SYS_TimerQuit (void) +SDL_SYS_TimerQuit(void) { timer_alive = 0; if (timer) { - SDL_WaitThread (timer, NULL); + SDL_WaitThread(timer, NULL); timer = NULL; } } int -SDL_SYS_StartTimer (void) +SDL_SYS_StartTimer(void) { - SDL_SetError ("Internal logic error: RISC OS uses threaded timer"); + SDL_SetError("Internal logic error: RISC OS uses threaded timer"); return (-1); } void -SDL_SYS_StopTimer (void) +SDL_SYS_StopTimer(void) { return; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/unix/SDL_systimer.c --- a/src/timer/unix/SDL_systimer.c Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/unix/SDL_systimer.c Mon May 29 04:04:35 2006 +0000 @@ -59,23 +59,23 @@ void -SDL_StartTicks (void) +SDL_StartTicks(void) { /* Set first ticks value */ #if HAVE_CLOCK_GETTIME - clock_gettime (CLOCK_MONOTONIC, &start); + clock_gettime(CLOCK_MONOTONIC, &start); #else - gettimeofday (&start, NULL); + gettimeofday(&start, NULL); #endif } Uint32 -SDL_GetTicks (void) +SDL_GetTicks(void) { #if HAVE_CLOCK_GETTIME Uint32 ticks; struct timespec now; - clock_gettime (CLOCK_MONOTONIC, &now); + clock_gettime(CLOCK_MONOTONIC, &now); ticks = (now.tv_sec - start.tv_sec) * 1000 + (now.tv_nsec - start.tv_nsec) / 1000000; @@ -83,7 +83,7 @@ #else Uint32 ticks; struct timeval now; - gettimeofday (&now, NULL); + gettimeofday(&now, NULL); ticks = (now.tv_sec - start.tv_sec) * 1000 + (now.tv_usec - start.tv_usec) / 1000; @@ -92,13 +92,13 @@ } void -SDL_Delay (Uint32 ms) +SDL_Delay(Uint32 ms) { #if SDL_THREAD_PTH pth_time_t tv; tv.tv_sec = ms / 1000; tv.tv_usec = (ms % 1000) * 1000; - pth_nap (tv); + pth_nap(tv); #else int was_error; @@ -114,7 +114,7 @@ elapsed.tv_sec = ms / 1000; elapsed.tv_nsec = (ms % 1000) * 1000000; #else - then = SDL_GetTicks (); + then = SDL_GetTicks(); #endif do { errno = 0; @@ -122,10 +122,10 @@ #if HAVE_NANOSLEEP tv.tv_sec = elapsed.tv_sec; tv.tv_nsec = elapsed.tv_nsec; - was_error = nanosleep (&tv, &elapsed); + was_error = nanosleep(&tv, &elapsed); #else /* Calculate the time interval left (in case of interrupt) */ - now = SDL_GetTicks (); + now = SDL_GetTicks(); elapsed = (now - then); then = now; if (elapsed >= ms) { @@ -135,7 +135,7 @@ tv.tv_sec = ms / 1000; tv.tv_usec = (ms % 1000) * 1000; - was_error = select (0, NULL, NULL, NULL, &tv); + was_error = select(0, NULL, NULL, NULL, &tv); #endif /* HAVE_NANOSLEEP */ } while (was_error && (errno == EINTR)); @@ -145,40 +145,40 @@ #ifdef USE_ITIMER static void -HandleAlarm (int sig) +HandleAlarm(int sig) { Uint32 ms; if (SDL_alarm_callback) { ms = (*SDL_alarm_callback) (SDL_alarm_interval); if (ms != SDL_alarm_interval) { - SDL_SetTimer (ms, SDL_alarm_callback); + SDL_SetTimer(ms, SDL_alarm_callback); } } } int -SDL_SYS_TimerInit (void) +SDL_SYS_TimerInit(void) { struct sigaction action; /* Set the alarm handler (Linux specific) */ - SDL_memset (&action, 0, sizeof (action)); + SDL_memset(&action, 0, sizeof(action)); action.sa_handler = HandleAlarm; action.sa_flags = SA_RESTART; - sigemptyset (&action.sa_mask); - sigaction (SIGALRM, &action, NULL); + sigemptyset(&action.sa_mask); + sigaction(SIGALRM, &action, NULL); return (0); } void -SDL_SYS_TimerQuit (void) +SDL_SYS_TimerQuit(void) { - SDL_SetTimer (0, NULL); + SDL_SetTimer(0, NULL); } int -SDL_SYS_StartTimer (void) +SDL_SYS_StartTimer(void) { struct itimerval timer; @@ -186,17 +186,17 @@ timer.it_value.tv_usec = (SDL_alarm_interval % 1000) * 1000; timer.it_interval.tv_sec = (SDL_alarm_interval / 1000); timer.it_interval.tv_usec = (SDL_alarm_interval % 1000) * 1000; - setitimer (ITIMER_REAL, &timer, NULL); + setitimer(ITIMER_REAL, &timer, NULL); return (0); } void -SDL_SYS_StopTimer (void) +SDL_SYS_StopTimer(void) { struct itimerval timer; - SDL_memset (&timer, 0, (sizeof timer)); - setitimer (ITIMER_REAL, &timer, NULL); + SDL_memset(&timer, 0, (sizeof timer)); + setitimer(ITIMER_REAL, &timer, NULL); } #else /* USE_ITIMER */ @@ -208,47 +208,47 @@ static SDL_Thread *timer = NULL; static int -RunTimer (void *unused) +RunTimer(void *unused) { while (timer_alive) { if (SDL_timer_running) { - SDL_ThreadedTimerCheck (); + SDL_ThreadedTimerCheck(); } - SDL_Delay (1); + SDL_Delay(1); } return (0); } /* This is only called if the event thread is not running */ int -SDL_SYS_TimerInit (void) +SDL_SYS_TimerInit(void) { timer_alive = 1; - timer = SDL_CreateThread (RunTimer, NULL); + timer = SDL_CreateThread(RunTimer, NULL); if (timer == NULL) return (-1); - return (SDL_SetTimerThreaded (1)); + return (SDL_SetTimerThreaded(1)); } void -SDL_SYS_TimerQuit (void) +SDL_SYS_TimerQuit(void) { timer_alive = 0; if (timer) { - SDL_WaitThread (timer, NULL); + SDL_WaitThread(timer, NULL); timer = NULL; } } int -SDL_SYS_StartTimer (void) +SDL_SYS_StartTimer(void) { - SDL_SetError ("Internal logic error: Linux uses threaded timer"); + SDL_SetError("Internal logic error: Linux uses threaded timer"); return (-1); } void -SDL_SYS_StopTimer (void) +SDL_SYS_StopTimer(void) { return; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/win32/SDL_systimer.c --- a/src/timer/win32/SDL_systimer.c Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/win32/SDL_systimer.c Mon May 29 04:04:35 2006 +0000 @@ -49,28 +49,28 @@ #endif void -SDL_StartTicks (void) +SDL_StartTicks(void) { /* Set first ticks value */ #ifdef USE_GETTICKCOUNT - start = GetTickCount (); + start = GetTickCount(); #else #if 0 /* Apparently there are problems with QPC on Win2K */ - if (QueryPerformanceFrequency (&hires_ticks_per_second) == TRUE) { + if (QueryPerformanceFrequency(&hires_ticks_per_second) == TRUE) { hires_timer_available = TRUE; - QueryPerformanceCounter (&hires_start_ticks); + QueryPerformanceCounter(&hires_start_ticks); } else #endif { hires_timer_available = FALSE; - timeBeginPeriod (1); /* use 1 ms timer precision */ - start = timeGetTime (); + timeBeginPeriod(1); /* use 1 ms timer precision */ + start = timeGetTime(); } #endif } Uint32 -SDL_GetTicks (void) +SDL_GetTicks(void) { DWORD now, ticks; #ifndef USE_GETTICKCOUNT @@ -78,10 +78,10 @@ #endif #ifdef USE_GETTICKCOUNT - now = GetTickCount (); + now = GetTickCount(); #else if (hires_timer_available) { - QueryPerformanceCounter (&hires_now); + QueryPerformanceCounter(&hires_now); hires_now.QuadPart -= hires_start_ticks.QuadPart; hires_now.QuadPart *= 1000; @@ -89,7 +89,7 @@ return (DWORD) hires_now.QuadPart; } else { - now = timeGetTime (); + now = timeGetTime(); } #endif @@ -102,61 +102,61 @@ } void -SDL_Delay (Uint32 ms) +SDL_Delay(Uint32 ms) { - Sleep (ms); + Sleep(ms); } /* Data to handle a single periodic alarm */ static UINT timerID = 0; static void CALLBACK -HandleAlarm (UINT uID, UINT uMsg, DWORD_PTR dwUser, - DWORD_PTR dw1, DWORD_PTR dw2) +HandleAlarm(UINT uID, UINT uMsg, DWORD_PTR dwUser, + DWORD_PTR dw1, DWORD_PTR dw2) { - SDL_ThreadedTimerCheck (); + SDL_ThreadedTimerCheck(); } int -SDL_SYS_TimerInit (void) +SDL_SYS_TimerInit(void) { MMRESULT result; /* Set timer resolution */ - result = timeBeginPeriod (TIMER_RESOLUTION); + result = timeBeginPeriod(TIMER_RESOLUTION); if (result != TIMERR_NOERROR) { - SDL_SetError ("Warning: Can't set %d ms timer resolution", - TIMER_RESOLUTION); + SDL_SetError("Warning: Can't set %d ms timer resolution", + TIMER_RESOLUTION); } /* Allow 10 ms of drift so we don't chew on CPU */ timerID = - timeSetEvent (TIMER_RESOLUTION, 1, HandleAlarm, 0, TIME_PERIODIC); + timeSetEvent(TIMER_RESOLUTION, 1, HandleAlarm, 0, TIME_PERIODIC); if (!timerID) { - SDL_SetError ("timeSetEvent() failed"); + SDL_SetError("timeSetEvent() failed"); return (-1); } - return (SDL_SetTimerThreaded (1)); + return (SDL_SetTimerThreaded(1)); } void -SDL_SYS_TimerQuit (void) +SDL_SYS_TimerQuit(void) { if (timerID) { - timeKillEvent (timerID); + timeKillEvent(timerID); } - timeEndPeriod (TIMER_RESOLUTION); + timeEndPeriod(TIMER_RESOLUTION); } int -SDL_SYS_StartTimer (void) +SDL_SYS_StartTimer(void) { - SDL_SetError ("Internal logic error: Win32 uses threaded timer"); + SDL_SetError("Internal logic error: Win32 uses threaded timer"); return (-1); } void -SDL_SYS_StopTimer (void) +SDL_SYS_StopTimer(void) { return; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/timer/wince/SDL_systimer.c --- a/src/timer/wince/SDL_systimer.c Mon May 29 03:53:21 2006 +0000 +++ b/src/timer/wince/SDL_systimer.c Mon May 29 04:04:35 2006 +0000 @@ -35,13 +35,13 @@ static Uint64 start_ticks; static Uint64 -wce_ticks (void) +wce_ticks(void) { - return ((Uint64) GetTickCount ()); + return ((Uint64) GetTickCount()); } static Uint64 -wce_date (void) +wce_date(void) { union { @@ -50,8 +50,8 @@ } ftime; SYSTEMTIME stime; - GetSystemTime (&stime); - SystemTimeToFileTime (&stime, &ftime.ftime); + GetSystemTime(&stime); + SystemTimeToFileTime(&stime, &ftime.ftime); ftime.itime /= 10000; // Convert 100ns intervals to 1ms intervals // Remove ms portion, which can't be relied on ftime.itime -= (ftime.itime % 1000); @@ -59,43 +59,43 @@ } static Sint32 -wce_rel_ticks (void) +wce_rel_ticks(void) { - return ((Sint32) (wce_ticks () - start_ticks)); + return ((Sint32) (wce_ticks() - start_ticks)); } static Sint32 -wce_rel_date (void) +wce_rel_date(void) { - return ((Sint32) (wce_date () - start_date)); + return ((Sint32) (wce_date() - start_date)); } /* Return time in ms relative to when SDL was started */ Uint32 -SDL_GetTicks () +SDL_GetTicks() { - Sint32 offset = wce_rel_date () - wce_rel_ticks (); + Sint32 offset = wce_rel_date() - wce_rel_ticks(); if ((offset < -1000) || (offset > 1000)) { // fprintf(stderr,"Time desync(%+d), resyncing\n",offset/1000); start_ticks -= offset; } - return ((Uint32) wce_rel_ticks ()); + return ((Uint32) wce_rel_ticks()); } /* Give up approx. givem milliseconds to the OS. */ void -SDL_Delay (Uint32 ms) +SDL_Delay(Uint32 ms) { - Sleep (ms); + Sleep(ms); } /* Recard start-time of application for reference */ void -SDL_StartTicks (void) +SDL_StartTicks(void) { - start_date = wce_date (); - start_ticks = wce_ticks (); + start_date = wce_date(); + start_ticks = wce_ticks(); } static UINT WIN_timer; @@ -106,45 +106,45 @@ static HANDLE timersQuitEvent = 0; DWORD -TimersThreadProc (void *data) +TimersThreadProc(void *data) { - while (WaitForSingleObject (timersQuitEvent, 10) == WAIT_TIMEOUT) { - SDL_ThreadedTimerCheck (); + while (WaitForSingleObject(timersQuitEvent, 10) == WAIT_TIMEOUT) { + SDL_ThreadedTimerCheck(); } return 0; } int -SDL_SYS_TimerInit (void) +SDL_SYS_TimerInit(void) { // create a thread to process a threaded timers // SetTimer does not suit the needs because // TimerCallbackProc will be called only when WM_TIMER occured - timersQuitEvent = CreateEvent (0, TRUE, FALSE, 0); + timersQuitEvent = CreateEvent(0, TRUE, FALSE, 0); if (!timersQuitEvent) { - SDL_SetError ("Cannot create event for timers thread"); + SDL_SetError("Cannot create event for timers thread"); return -1; } - timersThread = CreateThread (NULL, 0, TimersThreadProc, 0, 0, 0); + timersThread = CreateThread(NULL, 0, TimersThreadProc, 0, 0, 0); if (!timersThread) { SDL_SetError ("Cannot create timers thread, check amount of RAM available"); return -1; } - SetThreadPriority (timersThread, THREAD_PRIORITY_HIGHEST); + SetThreadPriority(timersThread, THREAD_PRIORITY_HIGHEST); - return (SDL_SetTimerThreaded (1)); + return (SDL_SetTimerThreaded(1)); } void -SDL_SYS_TimerQuit (void) +SDL_SYS_TimerQuit(void) { - SetEvent (timersQuitEvent); - if (WaitForSingleObject (timersThread, 2000) == WAIT_TIMEOUT) - TerminateThread (timersThread, 0); - CloseHandle (timersThread); - CloseHandle (timersQuitEvent); + SetEvent(timersQuitEvent); + if (WaitForSingleObject(timersThread, 2000) == WAIT_TIMEOUT) + TerminateThread(timersThread, 0); + CloseHandle(timersThread); + CloseHandle(timersQuitEvent); return; } @@ -156,53 +156,53 @@ static UINT timerID = 0; static void CALLBACK -HandleAlarm (UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2) +HandleAlarm(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2) { - SDL_ThreadedTimerCheck (); + SDL_ThreadedTimerCheck(); } int -SDL_SYS_TimerInit (void) +SDL_SYS_TimerInit(void) { MMRESULT result; /* Set timer resolution */ - result = timeBeginPeriod (TIMER_RESOLUTION); + result = timeBeginPeriod(TIMER_RESOLUTION); if (result != TIMERR_NOERROR) { - SDL_SetError ("Warning: Can't set %d ms timer resolution", - TIMER_RESOLUTION); + SDL_SetError("Warning: Can't set %d ms timer resolution", + TIMER_RESOLUTION); } /* Allow 10 ms of drift so we don't chew on CPU */ timerID = - timeSetEvent (TIMER_RESOLUTION, 1, HandleAlarm, 0, TIME_PERIODIC); + timeSetEvent(TIMER_RESOLUTION, 1, HandleAlarm, 0, TIME_PERIODIC); if (!timerID) { - SDL_SetError ("timeSetEvent() failed"); + SDL_SetError("timeSetEvent() failed"); return (-1); } - return (SDL_SetTimerThreaded (1)); + return (SDL_SetTimerThreaded(1)); } void -SDL_SYS_TimerQuit (void) +SDL_SYS_TimerQuit(void) { if (timerID) { - timeKillEvent (timerID); + timeKillEvent(timerID); } - timeEndPeriod (TIMER_RESOLUTION); + timeEndPeriod(TIMER_RESOLUTION); } #endif int -SDL_SYS_StartTimer (void) +SDL_SYS_StartTimer(void) { - SDL_SetError ("Internal logic error: WinCE uses threaded timer"); + SDL_SetError("Internal logic error: WinCE uses threaded timer"); return (-1); } void -SDL_SYS_StopTimer (void) +SDL_SYS_StopTimer(void) { return; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_RLEaccel.c --- a/src/video/SDL_RLEaccel.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_RLEaccel.c Mon May 29 04:04:35 2006 +0000 @@ -780,8 +780,8 @@ * right. Top clipping has already been taken care of. */ static void -RLEClipBlit (int w, Uint8 * srcbuf, SDL_Surface * dst, - Uint8 * dstbuf, SDL_Rect * srcrect, unsigned alpha) +RLEClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst, + Uint8 * dstbuf, SDL_Rect * srcrect, unsigned alpha) { SDL_PixelFormat *fmt = dst->format; @@ -829,7 +829,7 @@ } \ } while(0) - CHOOSE_BLIT (RLECLIPBLIT, alpha, fmt); + CHOOSE_BLIT(RLECLIPBLIT, alpha, fmt); #undef RLECLIPBLIT @@ -838,8 +838,8 @@ /* blit a colorkeyed RLE surface */ int -SDL_RLEBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { Uint8 *dstbuf; Uint8 *srcbuf; @@ -848,8 +848,8 @@ unsigned alpha; /* Lock the destination if necessary */ - if (SDL_MUSTLOCK (dst)) { - if (SDL_LockSurface (dst) < 0) { + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { return (-1); } } @@ -887,16 +887,16 @@ switch (src->format->BytesPerPixel) { case 1: - RLESKIP (1, Uint8); + RLESKIP(1, Uint8); break; case 2: - RLESKIP (2, Uint8); + RLESKIP(2, Uint8); break; case 3: - RLESKIP (3, Uint8); + RLESKIP(3, Uint8); break; case 4: - RLESKIP (4, Uint16); + RLESKIP(4, Uint16); break; } @@ -909,7 +909,7 @@ ? src->format->alpha : 255; /* if left or right edge clipping needed, call clip blit */ if (srcrect->x || srcrect->w != src->w) { - RLEClipBlit (w, srcbuf, dst, dstbuf, srcrect, alpha); + RLEClipBlit(w, srcbuf, dst, dstbuf, srcrect, alpha); } else { SDL_PixelFormat *fmt = src->format; @@ -937,15 +937,15 @@ } \ } while(0) - CHOOSE_BLIT (RLEBLIT, alpha, fmt); + CHOOSE_BLIT(RLEBLIT, alpha, fmt); #undef RLEBLIT } done: /* Unlock the destination if necessary */ - if (SDL_MUSTLOCK (dst)) { - SDL_UnlockSurface (dst); + if (SDL_MUSTLOCK(dst)) { + SDL_UnlockSurface(dst); } return (0); } @@ -1023,8 +1023,8 @@ /* blit a pixel-alpha RLE surface clipped at the right and/or left edges */ static void -RLEAlphaClipBlit (int w, Uint8 * srcbuf, SDL_Surface * dst, - Uint8 * dstbuf, SDL_Rect * srcrect) +RLEAlphaClipBlit(int w, Uint8 * srcbuf, SDL_Surface * dst, + Uint8 * dstbuf, SDL_Rect * srcrect) { SDL_PixelFormat *df = dst->format; /* @@ -1103,20 +1103,20 @@ switch (df->BytesPerPixel) { case 2: if (df->Gmask == 0x07e0 || df->Rmask == 0x07e0 || df->Bmask == 0x07e0) - RLEALPHACLIPBLIT (Uint16, Uint8, BLIT_TRANSL_565); + RLEALPHACLIPBLIT(Uint16, Uint8, BLIT_TRANSL_565); else - RLEALPHACLIPBLIT (Uint16, Uint8, BLIT_TRANSL_555); + RLEALPHACLIPBLIT(Uint16, Uint8, BLIT_TRANSL_555); break; case 4: - RLEALPHACLIPBLIT (Uint32, Uint16, BLIT_TRANSL_888); + RLEALPHACLIPBLIT(Uint32, Uint16, BLIT_TRANSL_888); break; } } /* blit a pixel-alpha RLE surface */ int -SDL_RLEAlphaBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { int x, y; int w = src->w; @@ -1124,8 +1124,8 @@ SDL_PixelFormat *df = dst->format; /* Lock the destination if necessary */ - if (SDL_MUSTLOCK (dst)) { - if (SDL_LockSurface (dst) < 0) { + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { return -1; } } @@ -1133,7 +1133,7 @@ x = dstrect->x; y = dstrect->y; dstbuf = (Uint8 *) dst->pixels + y * dst->pitch + x * df->BytesPerPixel; - srcbuf = (Uint8 *) src->map->sw_data->aux_data + sizeof (RLEDestFormat); + srcbuf = (Uint8 *) src->map->sw_data->aux_data + sizeof(RLEDestFormat); { /* skip lines at the top if necessary */ @@ -1198,7 +1198,7 @@ /* if left or right edge clipping needed, call clip blit */ if (srcrect->x || srcrect->w != src->w) { - RLEAlphaClipBlit (w, srcbuf, dst, dstbuf, srcrect); + RLEAlphaClipBlit(w, srcbuf, dst, dstbuf, srcrect); } else { /* @@ -1255,20 +1255,20 @@ case 2: if (df->Gmask == 0x07e0 || df->Rmask == 0x07e0 || df->Bmask == 0x07e0) - RLEALPHABLIT (Uint16, Uint8, BLIT_TRANSL_565); + RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_565); else - RLEALPHABLIT (Uint16, Uint8, BLIT_TRANSL_555); + RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_555); break; case 4: - RLEALPHABLIT (Uint32, Uint16, BLIT_TRANSL_888); + RLEALPHABLIT(Uint32, Uint16, BLIT_TRANSL_888); break; } } done: /* Unlock the destination if necessary */ - if (SDL_MUSTLOCK (dst)) { - SDL_UnlockSurface (dst); + if (SDL_MUSTLOCK(dst)) { + SDL_UnlockSurface(dst); } return 0; } @@ -1285,15 +1285,15 @@ /* encode 32bpp rgb + a into 16bpp rgb, losing alpha */ static int -copy_opaque_16 (void *dst, Uint32 * src, int n, - SDL_PixelFormat * sfmt, SDL_PixelFormat * dfmt) +copy_opaque_16(void *dst, Uint32 * src, int n, + SDL_PixelFormat * sfmt, SDL_PixelFormat * dfmt) { int i; Uint16 *d = dst; for (i = 0; i < n; i++) { unsigned r, g, b; - RGB_FROM_PIXEL (*src, sfmt, r, g, b); - PIXEL_FROM_RGB (*d, dfmt, r, g, b); + RGB_FROM_PIXEL(*src, sfmt, r, g, b); + PIXEL_FROM_RGB(*d, dfmt, r, g, b); src++; d++; } @@ -1302,16 +1302,16 @@ /* decode opaque pixels from 16bpp to 32bpp rgb + a */ static int -uncopy_opaque_16 (Uint32 * dst, void *src, int n, - RLEDestFormat * sfmt, SDL_PixelFormat * dfmt) +uncopy_opaque_16(Uint32 * dst, void *src, int n, + RLEDestFormat * sfmt, SDL_PixelFormat * dfmt) { int i; Uint16 *s = src; unsigned alpha = dfmt->Amask ? 255 : 0; for (i = 0; i < n; i++) { unsigned r, g, b; - RGB_FROM_PIXEL (*s, sfmt, r, g, b); - PIXEL_FROM_RGBA (*dst, dfmt, r, g, b, alpha); + RGB_FROM_PIXEL(*s, sfmt, r, g, b); + PIXEL_FROM_RGBA(*dst, dfmt, r, g, b, alpha); s++; dst++; } @@ -1322,16 +1322,16 @@ /* encode 32bpp rgb + a into 32bpp G0RAB format for blitting into 565 */ static int -copy_transl_565 (void *dst, Uint32 * src, int n, - SDL_PixelFormat * sfmt, SDL_PixelFormat * dfmt) +copy_transl_565(void *dst, Uint32 * src, int n, + SDL_PixelFormat * sfmt, SDL_PixelFormat * dfmt) { int i; Uint32 *d = dst; for (i = 0; i < n; i++) { unsigned r, g, b, a; Uint16 pix; - RGBA_FROM_8888 (*src, sfmt, r, g, b, a); - PIXEL_FROM_RGB (pix, dfmt, r, g, b); + RGBA_FROM_8888(*src, sfmt, r, g, b, a); + PIXEL_FROM_RGB(pix, dfmt, r, g, b); *d = ((pix & 0x7e0) << 16) | (pix & 0xf81f) | ((a << 2) & 0x7e0); src++; d++; @@ -1341,16 +1341,16 @@ /* encode 32bpp rgb + a into 32bpp G0RAB format for blitting into 555 */ static int -copy_transl_555 (void *dst, Uint32 * src, int n, - SDL_PixelFormat * sfmt, SDL_PixelFormat * dfmt) +copy_transl_555(void *dst, Uint32 * src, int n, + SDL_PixelFormat * sfmt, SDL_PixelFormat * dfmt) { int i; Uint32 *d = dst; for (i = 0; i < n; i++) { unsigned r, g, b, a; Uint16 pix; - RGBA_FROM_8888 (*src, sfmt, r, g, b, a); - PIXEL_FROM_RGB (pix, dfmt, r, g, b); + RGBA_FROM_8888(*src, sfmt, r, g, b, a); + PIXEL_FROM_RGB(pix, dfmt, r, g, b); *d = ((pix & 0x3e0) << 16) | (pix & 0xfc1f) | ((a << 2) & 0x3e0); src++; d++; @@ -1360,8 +1360,8 @@ /* decode translucent pixels from 32bpp GORAB to 32bpp rgb + a */ static int -uncopy_transl_16 (Uint32 * dst, void *src, int n, - RLEDestFormat * sfmt, SDL_PixelFormat * dfmt) +uncopy_transl_16(Uint32 * dst, void *src, int n, + RLEDestFormat * sfmt, SDL_PixelFormat * dfmt) { int i; Uint32 *s = src; @@ -1370,8 +1370,8 @@ Uint32 pix = *s++; a = (pix & 0x3e0) >> 2; pix = (pix & ~0x3e0) | pix >> 16; - RGB_FROM_PIXEL (pix, sfmt, r, g, b); - PIXEL_FROM_RGBA (*dst, dfmt, r, g, b, a); + RGB_FROM_PIXEL(pix, sfmt, r, g, b); + PIXEL_FROM_RGBA(*dst, dfmt, r, g, b, a); dst++; } return n * 4; @@ -1379,16 +1379,16 @@ /* encode 32bpp rgba into 32bpp rgba, keeping alpha (dual purpose) */ static int -copy_32 (void *dst, Uint32 * src, int n, - SDL_PixelFormat * sfmt, SDL_PixelFormat * dfmt) +copy_32(void *dst, Uint32 * src, int n, + SDL_PixelFormat * sfmt, SDL_PixelFormat * dfmt) { int i; Uint32 *d = dst; for (i = 0; i < n; i++) { unsigned r, g, b, a; Uint32 pixel; - RGBA_FROM_8888 (*src, sfmt, r, g, b, a); - PIXEL_FROM_RGB (pixel, dfmt, r, g, b); + RGBA_FROM_8888(*src, sfmt, r, g, b, a); + PIXEL_FROM_RGB(pixel, dfmt, r, g, b); *d++ = pixel | a << 24; src++; } @@ -1397,17 +1397,17 @@ /* decode 32bpp rgba into 32bpp rgba, keeping alpha (dual purpose) */ static int -uncopy_32 (Uint32 * dst, void *src, int n, - RLEDestFormat * sfmt, SDL_PixelFormat * dfmt) +uncopy_32(Uint32 * dst, void *src, int n, + RLEDestFormat * sfmt, SDL_PixelFormat * dfmt) { int i; Uint32 *s = src; for (i = 0; i < n; i++) { unsigned r, g, b, a; Uint32 pixel = *s++; - RGB_FROM_PIXEL (pixel, sfmt, r, g, b); + RGB_FROM_PIXEL(pixel, sfmt, r, g, b); a = pixel >> 24; - PIXEL_FROM_RGBA (*dst, dfmt, r, g, b, a); + PIXEL_FROM_RGBA(*dst, dfmt, r, g, b, a); dst++; } return n * 4; @@ -1420,7 +1420,7 @@ /* convert surface to be quickly alpha-blittable onto dest, if possible */ static int -RLEAlphaSurface (SDL_Surface * surface) +RLEAlphaSurface(SDL_Surface * surface) { SDL_Surface *dest; SDL_PixelFormat *df; @@ -1487,10 +1487,10 @@ return -1; /* anything else unsupported right now */ } - maxsize += sizeof (RLEDestFormat); - rlebuf = (Uint8 *) SDL_malloc (maxsize); + maxsize += sizeof(RLEDestFormat); + rlebuf = (Uint8 *) SDL_malloc(maxsize); if (!rlebuf) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return -1; } { @@ -1509,7 +1509,7 @@ r->Bmask = df->Bmask; r->Amask = df->Amask; } - dst = rlebuf + sizeof (RLEDestFormat); + dst = rlebuf + sizeof(RLEDestFormat); /* Do the actual encoding */ { @@ -1543,28 +1543,28 @@ do { int run, skip, len; skipstart = x; - while (x < w && !ISOPAQUE (src[x], sf)) + while (x < w && !ISOPAQUE(src[x], sf)) x++; runstart = x; - while (x < w && ISOPAQUE (src[x], sf)) + while (x < w && ISOPAQUE(src[x], sf)) x++; skip = runstart - skipstart; if (skip == w) blankline = 1; run = x - runstart; while (skip > max_opaque_run) { - ADD_OPAQUE_COUNTS (max_opaque_run, 0); + ADD_OPAQUE_COUNTS(max_opaque_run, 0); skip -= max_opaque_run; } - len = MIN (run, max_opaque_run); - ADD_OPAQUE_COUNTS (skip, len); - dst += copy_opaque (dst, src + runstart, len, sf, df); + len = MIN(run, max_opaque_run); + ADD_OPAQUE_COUNTS(skip, len); + dst += copy_opaque(dst, src + runstart, len, sf, df); runstart += len; run -= len; while (run) { - len = MIN (run, max_opaque_run); - ADD_OPAQUE_COUNTS (0, len); - dst += copy_opaque (dst, src + runstart, len, sf, df); + len = MIN(run, max_opaque_run); + ADD_OPAQUE_COUNTS(0, len); + dst += copy_opaque(dst, src + runstart, len, sf, df); runstart += len; run -= len; } @@ -1579,27 +1579,27 @@ do { int run, skip, len; skipstart = x; - while (x < w && !ISTRANSL (src[x], sf)) + while (x < w && !ISTRANSL(src[x], sf)) x++; runstart = x; - while (x < w && ISTRANSL (src[x], sf)) + while (x < w && ISTRANSL(src[x], sf)) x++; skip = runstart - skipstart; blankline &= (skip == w); run = x - runstart; while (skip > max_transl_run) { - ADD_TRANSL_COUNTS (max_transl_run, 0); + ADD_TRANSL_COUNTS(max_transl_run, 0); skip -= max_transl_run; } - len = MIN (run, max_transl_run); - ADD_TRANSL_COUNTS (skip, len); - dst += copy_transl (dst, src + runstart, len, sf, df); + len = MIN(run, max_transl_run); + ADD_TRANSL_COUNTS(skip, len); + dst += copy_transl(dst, src + runstart, len, sf, df); runstart += len; run -= len; while (run) { - len = MIN (run, max_transl_run); - ADD_TRANSL_COUNTS (0, len); - dst += copy_transl (dst, src + runstart, len, sf, df); + len = MIN(run, max_transl_run); + ADD_TRANSL_COUNTS(0, len); + dst += copy_transl(dst, src + runstart, len, sf, df); runstart += len; run -= len; } @@ -1611,7 +1611,7 @@ src += surface->pitch >> 2; } dst = lastline; /* back up past trailing blank lines */ - ADD_OPAQUE_COUNTS (0, 0); + ADD_OPAQUE_COUNTS(0, 0); } #undef ADD_OPAQUE_COUNTS @@ -1620,13 +1620,13 @@ /* Now that we have it encoded, release the original pixels */ if ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC && (surface->flags & SDL_HWSURFACE) != SDL_HWSURFACE) { - SDL_free (surface->pixels); + SDL_free(surface->pixels); surface->pixels = NULL; } /* realloc the buffer to release unused memory */ { - Uint8 *p = SDL_realloc (rlebuf, dst - rlebuf); + Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf); if (!p) p = rlebuf; surface->map->sw_data->aux_data = p; @@ -1636,19 +1636,19 @@ } static Uint32 -getpix_8 (Uint8 * srcbuf) +getpix_8(Uint8 * srcbuf) { return *srcbuf; } static Uint32 -getpix_16 (Uint8 * srcbuf) +getpix_16(Uint8 * srcbuf) { return *(Uint16 *) srcbuf; } static Uint32 -getpix_24 (Uint8 * srcbuf) +getpix_24(Uint8 * srcbuf) { #if SDL_BYTEORDER == SDL_LIL_ENDIAN return srcbuf[0] + (srcbuf[1] << 8) + (srcbuf[2] << 16); @@ -1658,19 +1658,19 @@ } static Uint32 -getpix_32 (Uint8 * srcbuf) +getpix_32(Uint8 * srcbuf) { return *(Uint32 *) srcbuf; } -typedef Uint32 (*getpix_func) (Uint8 *); +typedef Uint32(*getpix_func) (Uint8 *); static getpix_func getpixes[4] = { getpix_8, getpix_16, getpix_24, getpix_32 }; static int -RLEColorkeySurface (SDL_Surface * surface) +RLEColorkeySurface(SDL_Surface * surface) { Uint8 *rlebuf, *dst; int maxn; @@ -1703,9 +1703,9 @@ break; } - rlebuf = (Uint8 *) SDL_malloc (maxsize); + rlebuf = (Uint8 *) SDL_malloc(maxsize); if (rlebuf == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } @@ -1742,10 +1742,10 @@ int skipstart = x; /* find run of transparent, then opaque pixels */ - while (x < w && (getpix (srcbuf + x * bpp) & rgbmask) == ckey) + while (x < w && (getpix(srcbuf + x * bpp) & rgbmask) == ckey) x++; runstart = x; - while (x < w && (getpix (srcbuf + x * bpp) & rgbmask) != ckey) + while (x < w && (getpix(srcbuf + x * bpp) & rgbmask) != ckey) x++; skip = runstart - skipstart; if (skip == w) @@ -1754,19 +1754,19 @@ /* encode segment */ while (skip > maxn) { - ADD_COUNTS (maxn, 0); + ADD_COUNTS(maxn, 0); skip -= maxn; } - len = MIN (run, maxn); - ADD_COUNTS (skip, len); - SDL_memcpy (dst, srcbuf + runstart * bpp, len * bpp); + len = MIN(run, maxn); + ADD_COUNTS(skip, len); + SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp); dst += len * bpp; run -= len; runstart += len; while (run) { - len = MIN (run, maxn); - ADD_COUNTS (0, len); - SDL_memcpy (dst, srcbuf + runstart * bpp, len * bpp); + len = MIN(run, maxn); + ADD_COUNTS(0, len); + SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp); dst += len * bpp; runstart += len; run -= len; @@ -1779,21 +1779,21 @@ srcbuf += surface->pitch; } dst = lastline; /* back up bast trailing blank lines */ - ADD_COUNTS (0, 0); + ADD_COUNTS(0, 0); #undef ADD_COUNTS /* Now that we have it encoded, release the original pixels */ if ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC && (surface->flags & SDL_HWSURFACE) != SDL_HWSURFACE) { - SDL_free (surface->pixels); + SDL_free(surface->pixels); surface->pixels = NULL; } /* realloc the buffer to release unused memory */ { /* If realloc returns NULL, the original block is left intact */ - Uint8 *p = SDL_realloc (rlebuf, dst - rlebuf); + Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf); if (!p) p = rlebuf; surface->map->sw_data->aux_data = p; @@ -1803,13 +1803,13 @@ } int -SDL_RLESurface (SDL_Surface * surface) +SDL_RLESurface(SDL_Surface * surface) { int retcode; /* Clear any previous RLE conversion */ if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) { - SDL_UnRLESurface (surface, 1); + SDL_UnRLESurface(surface, 1); } /* We don't support RLE encoding of bitmaps */ @@ -1818,26 +1818,26 @@ } /* Lock the surface if it's in hardware */ - if (SDL_MUSTLOCK (surface)) { - if (SDL_LockSurface (surface) < 0) { + if (SDL_MUSTLOCK(surface)) { + if (SDL_LockSurface(surface) < 0) { return (-1); } } /* Encode */ if ((surface->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { - retcode = RLEColorkeySurface (surface); + retcode = RLEColorkeySurface(surface); } else { if ((surface->flags & SDL_SRCALPHA) == SDL_SRCALPHA && surface->format->Amask != 0) - retcode = RLEAlphaSurface (surface); + retcode = RLEAlphaSurface(surface); else retcode = -1; /* no RLE for per-surface alpha sans ckey */ } /* Unlock the surface if it's in hardware */ - if (SDL_MUSTLOCK (surface)) { - SDL_UnlockSurface (surface); + if (SDL_MUSTLOCK(surface)) { + SDL_UnlockSurface(surface); } if (retcode < 0) @@ -1856,7 +1856,7 @@ * may have been reduced (when encoding for 16bpp targets). */ static SDL_bool -UnRLEAlpha (SDL_Surface * surface) +UnRLEAlpha(SDL_Surface * surface) { Uint8 *srcbuf; Uint32 *dst; @@ -1876,12 +1876,12 @@ uncopy_opaque = uncopy_transl = uncopy_32; } - surface->pixels = SDL_malloc (surface->h * surface->pitch); + surface->pixels = SDL_malloc(surface->h * surface->pitch); if (!surface->pixels) { return (SDL_FALSE); } /* fill background with transparent pixels */ - SDL_memset (surface->pixels, 0, surface->h * surface->pitch); + SDL_memset(surface->pixels, 0, surface->h * surface->pitch); dst = surface->pixels; srcbuf = (Uint8 *) (df + 1); @@ -1900,7 +1900,7 @@ srcbuf += 4; } if (run) { - srcbuf += uncopy_opaque (dst + ofs, srcbuf, run, df, sf); + srcbuf += uncopy_opaque(dst + ofs, srcbuf, run, df, sf); ofs += run; } else if (!ofs) return (SDL_TRUE); @@ -1919,7 +1919,7 @@ run = ((Uint16 *) srcbuf)[1]; srcbuf += 4; if (run) { - srcbuf += uncopy_transl (dst + ofs, srcbuf, run, df, sf); + srcbuf += uncopy_transl(dst + ofs, srcbuf, run, df, sf); ofs += run; } } @@ -1931,7 +1931,7 @@ } void -SDL_UnRLESurface (SDL_Surface * surface, int recode) +SDL_UnRLESurface(SDL_Surface * surface, int recode) { if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) { surface->flags &= ~SDL_RLEACCEL; @@ -1943,7 +1943,7 @@ unsigned alpha_flag; /* re-create the original surface */ - surface->pixels = SDL_malloc (surface->h * surface->pitch); + surface->pixels = SDL_malloc(surface->h * surface->pitch); if (!surface->pixels) { /* Oh crap... */ surface->flags |= SDL_RLEACCEL; @@ -1951,7 +1951,7 @@ } /* fill it with the background colour */ - SDL_FillRect (surface, NULL, surface->format->colorkey); + SDL_FillRect(surface, NULL, surface->format->colorkey); /* now render the encoded surface */ full.x = full.y = 0; @@ -1959,10 +1959,10 @@ full.h = surface->h; alpha_flag = surface->flags & SDL_SRCALPHA; surface->flags &= ~SDL_SRCALPHA; /* opaque blit */ - SDL_RLEBlit (surface, &full, surface, &full); + SDL_RLEBlit(surface, &full, surface, &full); surface->flags |= alpha_flag; } else { - if (!UnRLEAlpha (surface)) { + if (!UnRLEAlpha(surface)) { /* Oh crap... */ surface->flags |= SDL_RLEACCEL; return; @@ -1971,7 +1971,7 @@ } if (surface->map && surface->map->sw_data->aux_data) { - SDL_free (surface->map->sw_data->aux_data); + SDL_free(surface->map->sw_data->aux_data); surface->map->sw_data->aux_data = NULL; } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_RLEaccel_c.h --- a/src/video/SDL_RLEaccel_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_RLEaccel_c.h Mon May 29 04:04:35 2006 +0000 @@ -23,10 +23,10 @@ /* Useful functions and variables from SDL_RLEaccel.c */ -extern int SDL_RLESurface (SDL_Surface * surface); -extern int SDL_RLEBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect); -extern int SDL_RLEAlphaBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect); -extern void SDL_UnRLESurface (SDL_Surface * surface, int recode); +extern int SDL_RLESurface(SDL_Surface * surface); +extern int SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); +extern int SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); +extern void SDL_UnRLESurface(SDL_Surface * surface, int recode); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_blit.c --- a/src/video/SDL_blit.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_blit.c Mon May 29 04:04:35 2006 +0000 @@ -38,8 +38,8 @@ /* The general purpose software blit routine */ static int -SDL_SoftBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +SDL_SoftBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { int okay; int src_locked; @@ -50,8 +50,8 @@ /* Lock the destination if it's in hardware */ dst_locked = 0; - if (SDL_MUSTLOCK (dst)) { - if (SDL_LockSurface (dst) < 0) { + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { okay = 0; } else { dst_locked = 1; @@ -59,8 +59,8 @@ } /* Lock the source if it's in hardware */ src_locked = 0; - if (SDL_MUSTLOCK (src)) { - if (SDL_LockSurface (src) < 0) { + if (SDL_MUSTLOCK(src)) { + if (SDL_LockSurface(src) < 0) { okay = 0; } else { src_locked = 1; @@ -92,15 +92,15 @@ RunBlit = src->map->sw_data->blit; /* Run the actual software blit */ - RunBlit (&info); + RunBlit(&info); } /* We need to unlock the surfaces if they're locked */ if (dst_locked) { - SDL_UnlockSurface (dst); + SDL_UnlockSurface(dst); } if (src_locked) { - SDL_UnlockSurface (src); + SDL_UnlockSurface(src); } /* Blit is done! */ return (okay ? 0 : -1); @@ -108,46 +108,46 @@ #ifdef MMX_ASMBLIT static __inline__ void -SDL_memcpyMMX (Uint8 * to, const Uint8 * from, int len) +SDL_memcpyMMX(Uint8 * to, const Uint8 * from, int len) { int i; for (i = 0; i < len / 8; i++) { - __asm__ __volatile__ (" movq (%0), %%mm0\n" - " movq %%mm0, (%1)\n"::"r" (from), - "r" (to):"memory"); + __asm__ __volatile__(" movq (%0), %%mm0\n" + " movq %%mm0, (%1)\n"::"r"(from), + "r"(to):"memory"); from += 8; to += 8; } if (len & 7) - SDL_memcpy (to, from, len & 7); + SDL_memcpy(to, from, len & 7); } static __inline__ void -SDL_memcpySSE (Uint8 * to, const Uint8 * from, int len) +SDL_memcpySSE(Uint8 * to, const Uint8 * from, int len) { int i; - __asm__ __volatile__ (" prefetchnta (%0)\n" - " prefetchnta 64(%0)\n" - " prefetchnta 128(%0)\n" - " prefetchnta 192(%0)\n"::"r" (from)); + __asm__ __volatile__(" prefetchnta (%0)\n" + " prefetchnta 64(%0)\n" + " prefetchnta 128(%0)\n" + " prefetchnta 192(%0)\n"::"r"(from)); for (i = 0; i < len / 8; i++) { - __asm__ __volatile__ (" prefetchnta 256(%0)\n" - " movq (%0), %%mm0\n" - " movntq %%mm0, (%1)\n"::"r" (from), - "r" (to):"memory"); + __asm__ __volatile__(" prefetchnta 256(%0)\n" + " movq (%0), %%mm0\n" + " movntq %%mm0, (%1)\n"::"r"(from), + "r"(to):"memory"); from += 8; to += 8; } if (len & 7) - SDL_memcpy (to, from, len & 7); + SDL_memcpy(to, from, len & 7); } #endif static void -SDL_BlitCopy (SDL_BlitInfo * info) +SDL_BlitCopy(SDL_BlitInfo * info) { Uint8 *src, *dst; int w, h; @@ -160,31 +160,31 @@ srcskip = w + info->s_skip; dstskip = w + info->d_skip; #ifdef MMX_ASMBLIT - if (SDL_HasSSE ()) { + if (SDL_HasSSE()) { while (h--) { - SDL_memcpySSE (dst, src, w); + SDL_memcpySSE(dst, src, w); src += srcskip; dst += dstskip; } - __asm__ __volatile__ (" emms\n"::); - } else if (SDL_HasMMX ()) { + __asm__ __volatile__(" emms\n"::); + } else if (SDL_HasMMX()) { while (h--) { - SDL_memcpyMMX (dst, src, w); + SDL_memcpyMMX(dst, src, w); src += srcskip; dst += dstskip; } - __asm__ __volatile__ (" emms\n"::); + __asm__ __volatile__(" emms\n"::); } else #endif while (h--) { - SDL_memcpy (dst, src, w); + SDL_memcpy(dst, src, w); src += srcskip; dst += dstskip; } } static void -SDL_BlitCopyOverlap (SDL_BlitInfo * info) +SDL_BlitCopyOverlap(SDL_BlitInfo * info) { Uint8 *src, *dst; int w, h; @@ -198,7 +198,7 @@ dstskip = w + info->d_skip; if (dst < src) { while (h--) { - SDL_memcpy (dst, src, w); + SDL_memcpy(dst, src, w); src += srcskip; dst += dstskip; } @@ -206,7 +206,7 @@ src += ((h - 1) * srcskip); dst += ((h - 1) * dstskip); while (h--) { - SDL_revcpy (dst, src, w); + SDL_revcpy(dst, src, w); src -= srcskip; dst -= dstskip; } @@ -215,15 +215,15 @@ /* Figure out which of many blit routines to set up on a surface */ int -SDL_CalculateBlit (SDL_Surface * surface) +SDL_CalculateBlit(SDL_Surface * surface) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); - const SDL_VideoInfo *info = SDL_GetVideoInfo (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + const SDL_VideoInfo *info = SDL_GetVideoInfo(); int blit_index; /* Clean everything out to start */ if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) { - SDL_UnRLESurface (surface, 1); + SDL_UnRLESurface(surface, 1); } surface->map->sw_blit = NULL; @@ -260,7 +260,7 @@ } } if (hw_blit_ok) { - _this->CheckHWBlit (_this, surface, surface->map->dst); + _this->CheckHWBlit(_this, surface, surface->map->dst); } } @@ -269,7 +269,7 @@ && (_this->displayformatalphapixel)) { if ((surface->flags & SDL_SRCALPHA)) if (info->blit_hw_A) { - _this->CheckHWBlit (_this, surface, surface->map->dst); + _this->CheckHWBlit(_this, surface, surface->map->dst); } } @@ -294,18 +294,18 @@ } else { if (surface->format->BitsPerPixel < 8) { surface->map->sw_data->blit = - SDL_CalculateBlit0 (surface, blit_index); + SDL_CalculateBlit0(surface, blit_index); } else { switch (surface->format->BytesPerPixel) { case 1: surface->map->sw_data->blit = - SDL_CalculateBlit1 (surface, blit_index); + SDL_CalculateBlit1(surface, blit_index); break; case 2: case 3: case 4: surface->map->sw_data->blit = - SDL_CalculateBlitN (surface, blit_index); + SDL_CalculateBlitN(surface, blit_index); break; default: surface->map->sw_data->blit = NULL; @@ -315,8 +315,8 @@ } /* Make sure we have a blit function */ if (surface->map->sw_data->blit == NULL) { - SDL_InvalidateMap (surface->map); - SDL_SetError ("Blit combination not supported"); + SDL_InvalidateMap(surface->map); + SDL_SetError("Blit combination not supported"); return (-1); } @@ -327,10 +327,10 @@ if (surface->map->identity && (blit_index == 1 || (blit_index == 3 && !surface->format->Amask))) { - if (SDL_RLESurface (surface) == 0) + if (SDL_RLESurface(surface) == 0) surface->map->sw_blit = SDL_RLEBlit; } else if (blit_index == 2 && surface->format->Amask) { - if (SDL_RLESurface (surface) == 0) + if (SDL_RLESurface(surface) == 0) surface->map->sw_blit = SDL_RLEAlphaBlit; } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_blit.h --- a/src/video/SDL_blit.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_blit.h Mon May 29 04:04:35 2006 +0000 @@ -71,13 +71,13 @@ /* Functions found in SDL_blit.c */ -extern int SDL_CalculateBlit (SDL_Surface * surface); +extern int SDL_CalculateBlit(SDL_Surface * surface); /* Functions found in SDL_blit_{0,1,N,A}.c */ -extern SDL_loblit SDL_CalculateBlit0 (SDL_Surface * surface, int complex); -extern SDL_loblit SDL_CalculateBlit1 (SDL_Surface * surface, int complex); -extern SDL_loblit SDL_CalculateBlitN (SDL_Surface * surface, int complex); -extern SDL_loblit SDL_CalculateAlphaBlit (SDL_Surface * surface, int complex); +extern SDL_loblit SDL_CalculateBlit0(SDL_Surface * surface, int complex); +extern SDL_loblit SDL_CalculateBlit1(SDL_Surface * surface, int complex); +extern SDL_loblit SDL_CalculateBlitN(SDL_Surface * surface, int complex); +extern SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface * surface, int complex); /* * Useful macros for blitting routines diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_blit_0.c --- a/src/video/SDL_blit_0.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_blit_0.c Mon May 29 04:04:35 2006 +0000 @@ -27,7 +27,7 @@ /* Functions to blit from bitmaps to other surfaces */ static void -BlitBto1 (SDL_BlitInfo * info) +BlitBto1(SDL_BlitInfo * info) { int c; int width, height; @@ -81,7 +81,7 @@ } } static void -BlitBto2 (SDL_BlitInfo * info) +BlitBto2(SDL_BlitInfo * info) { int c; int width, height; @@ -117,7 +117,7 @@ } } static void -BlitBto3 (SDL_BlitInfo * info) +BlitBto3(SDL_BlitInfo * info) { int c, o; int width, height; @@ -155,7 +155,7 @@ } } static void -BlitBto4 (SDL_BlitInfo * info) +BlitBto4(SDL_BlitInfo * info) { int width, height; Uint8 *src; @@ -192,7 +192,7 @@ } static void -BlitBto1Key (SDL_BlitInfo * info) +BlitBto1Key(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -245,7 +245,7 @@ } static void -BlitBto2Key (SDL_BlitInfo * info) +BlitBto2Key(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -280,7 +280,7 @@ } static void -BlitBto3Key (SDL_BlitInfo * info) +BlitBto3Key(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -303,7 +303,7 @@ } bit = (byte & 0x80) >> 7; if (bit != ckey) { - SDL_memcpy (dst, &palmap[bit * 4], 3); + SDL_memcpy(dst, &palmap[bit * 4], 3); } byte <<= 1; dst += 3; @@ -314,7 +314,7 @@ } static void -BlitBto4Key (SDL_BlitInfo * info) +BlitBto4Key(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -349,7 +349,7 @@ } static void -BlitBtoNAlpha (SDL_BlitInfo * info) +BlitBtoNAlpha(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -381,9 +381,9 @@ sR = srcpal[bit].r; sG = srcpal[bit].g; sB = srcpal[bit].b; - DISEMBLE_RGB (dst, dstbpp, dstfmt, pixel, dR, dG, dB); - ALPHA_BLEND (sR, sG, sB, A, dR, dG, dB); - ASSEMBLE_RGB (dst, dstbpp, dstfmt, dR, dG, dB); + DISEMBLE_RGB(dst, dstbpp, dstfmt, pixel, dR, dG, dB); + ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB); + ASSEMBLE_RGB(dst, dstbpp, dstfmt, dR, dG, dB); } byte <<= 1; dst += dstbpp; @@ -394,7 +394,7 @@ } static void -BlitBtoNAlphaKey (SDL_BlitInfo * info) +BlitBtoNAlphaKey(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -428,9 +428,9 @@ sR = srcpal[bit].r; sG = srcpal[bit].g; sB = srcpal[bit].b; - DISEMBLE_RGB (dst, dstbpp, dstfmt, pixel, dR, dG, dB); - ALPHA_BLEND (sR, sG, sB, A, dR, dG, dB); - ASSEMBLE_RGB (dst, dstbpp, dstfmt, dR, dG, dB); + DISEMBLE_RGB(dst, dstbpp, dstfmt, pixel, dR, dG, dB); + ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB); + ASSEMBLE_RGB(dst, dstbpp, dstfmt, dR, dG, dB); } byte <<= 1; dst += dstbpp; @@ -449,7 +449,7 @@ }; SDL_loblit -SDL_CalculateBlit0 (SDL_Surface * surface, int blit_index) +SDL_CalculateBlit0(SDL_Surface * surface, int blit_index) { int which; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_blit_1.c --- a/src/video/SDL_blit_1.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_blit_1.c Mon May 29 04:04:35 2006 +0000 @@ -29,7 +29,7 @@ /* Functions to blit from 8-bit surfaces to other surfaces */ static void -Blit1to1 (SDL_BlitInfo * info) +Blit1to1(SDL_BlitInfo * info) { #ifndef USE_DUFFS_LOOP int c; @@ -79,7 +79,7 @@ #define LO 1 #endif static void -Blit1to2 (SDL_BlitInfo * info) +Blit1to2(SDL_BlitInfo * info) { #ifndef USE_DUFFS_LOOP int c; @@ -185,7 +185,7 @@ #endif /* USE_DUFFS_LOOP */ } static void -Blit1to3 (SDL_BlitInfo * info) +Blit1to3(SDL_BlitInfo * info) { #ifndef USE_DUFFS_LOOP int c; @@ -233,7 +233,7 @@ } } static void -Blit1to4 (SDL_BlitInfo * info) +Blit1to4(SDL_BlitInfo * info) { #ifndef USE_DUFFS_LOOP int c; @@ -281,7 +281,7 @@ } static void -Blit1to1Key (SDL_BlitInfo * info) +Blit1to1Key(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -328,7 +328,7 @@ } static void -Blit1to2Key (SDL_BlitInfo * info) +Blit1to2Key(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -360,7 +360,7 @@ } static void -Blit1to3Key (SDL_BlitInfo * info) +Blit1to3Key(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -393,7 +393,7 @@ } static void -Blit1to4Key (SDL_BlitInfo * info) +Blit1to4Key(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -425,7 +425,7 @@ } static void -Blit1toNAlpha (SDL_BlitInfo * info) +Blit1toNAlpha(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -466,7 +466,7 @@ } static void -Blit1toNAlphaKey (SDL_BlitInfo * info) +Blit1toNAlphaKey(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -519,7 +519,7 @@ }; SDL_loblit -SDL_CalculateBlit1 (SDL_Surface * surface, int blit_index) +SDL_CalculateBlit1(SDL_Surface * surface, int blit_index) { int which; SDL_PixelFormat *dstfmt; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_blit_A.c --- a/src/video/SDL_blit_A.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_blit_A.c Mon May 29 04:04:35 2006 +0000 @@ -47,7 +47,7 @@ /* N->1 blending with per-surface alpha */ static void -BlitNto1SurfaceAlpha (SDL_BlitInfo * info) +BlitNto1SurfaceAlpha(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -103,7 +103,7 @@ /* N->1 blending with pixel alpha */ static void -BlitNto1PixelAlpha (SDL_BlitInfo * info) +BlitNto1PixelAlpha(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -159,7 +159,7 @@ /* colorkeyed N->1 blending with per-surface alpha */ static void -BlitNto1SurfaceAlphaKey (SDL_BlitInfo * info) +BlitNto1SurfaceAlphaKey(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -219,7 +219,7 @@ #if GCC_ASMBLIT /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ static void -BlitRGBtoRGBSurfaceAlpha128MMX (SDL_BlitInfo * info) +BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -231,11 +231,11 @@ Uint8 load[8]; *(Uint64 *) load = 0x00fefefe00fefefeULL; /* alpha128 mask */ - movq_m2r (*load, mm4); /* alpha128 mask -> mm4 */ + movq_m2r(*load, mm4); /* alpha128 mask -> mm4 */ *(Uint64 *) load = 0x0001010100010101ULL; /* !alpha128 mask */ - movq_m2r (*load, mm3); /* !alpha128 mask -> mm3 */ - movd_m2r (dalpha, mm7); /* dst alpha mask */ - punpckldq_r2r (mm7, mm7); /* dst alpha mask | dst alpha mask -> mm7 */ + movq_m2r(*load, mm3); /* !alpha128 mask -> mm3 */ + movd_m2r(dalpha, mm7); /* dst alpha mask */ + punpckldq_r2r(mm7, mm7); /* dst alpha mask | dst alpha mask -> mm7 */ while (height--) { /* *INDENT-OFF* */ DUFFS_LOOP_DOUBLE2( @@ -268,19 +268,19 @@ srcp += srcskip; dstp += dstskip; } - emms (); + emms(); } /* fast RGB888->(A)RGB888 blending with surface alpha */ static void -BlitRGBtoRGBSurfaceAlphaMMX (SDL_BlitInfo * info) +BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo * info) { SDL_PixelFormat *df = info->dst; unsigned alpha = info->src->alpha; if (alpha == 128 && (df->Rmask | df->Gmask | df->Bmask) == 0x00FFFFFF) { /* only call a128 version when R,G,B occupy lower bits */ - BlitRGBtoRGBSurfaceAlpha128MMX (info); + BlitRGBtoRGBSurfaceAlpha128MMX(info); } else { int width = info->d_width; int height = info->d_height; @@ -289,20 +289,20 @@ Uint32 *dstp = (Uint32 *) info->d_pixels; int dstskip = info->d_skip >> 2; - pxor_r2r (mm5, mm5); /* 0 -> mm5 */ + pxor_r2r(mm5, mm5); /* 0 -> mm5 */ /* form the alpha mult */ - movd_m2r (alpha, mm4); /* 0000000A -> mm4 */ - punpcklwd_r2r (mm4, mm4); /* 00000A0A -> mm4 */ - punpckldq_r2r (mm4, mm4); /* 0A0A0A0A -> mm4 */ + movd_m2r(alpha, mm4); /* 0000000A -> mm4 */ + punpcklwd_r2r(mm4, mm4); /* 00000A0A -> mm4 */ + punpckldq_r2r(mm4, mm4); /* 0A0A0A0A -> mm4 */ alpha = (0xff << df->Rshift) | (0xff << df->Gshift) | (0xff << df-> Bshift); - movd_m2r (alpha, mm0); /* 00000FFF -> mm0 */ - punpcklbw_r2r (mm0, mm0); /* 00FFFFFF -> mm0 */ - pand_r2r (mm0, mm4); /* 0A0A0A0A -> mm4, minus 1 chan */ + movd_m2r(alpha, mm0); /* 00000FFF -> mm0 */ + punpcklbw_r2r(mm0, mm0); /* 00FFFFFF -> mm0 */ + pand_r2r(mm0, mm4); /* 0A0A0A0A -> mm4, minus 1 chan */ /* at this point mm4 can be 000A0A0A or 0A0A0A00 or another combo */ - movd_m2r (df->Amask, mm7); /* dst alpha mask */ - punpckldq_r2r (mm7, mm7); /* dst alpha mask | dst alpha mask -> mm7 */ + movd_m2r(df->Amask, mm7); /* dst alpha mask */ + punpckldq_r2r(mm7, mm7); /* dst alpha mask | dst alpha mask -> mm7 */ while (height--) { /* *INDENT-OFF* */ @@ -357,13 +357,13 @@ srcp += srcskip; dstp += dstskip; } - emms (); + emms(); } } /* fast ARGB888->(A)RGB888 blending with pixel alpha */ static void -BlitRGBtoRGBPixelAlphaMMX (SDL_BlitInfo * info) +BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -374,20 +374,20 @@ SDL_PixelFormat *sf = info->src; Uint32 amask = sf->Amask; - pxor_r2r (mm6, mm6); /* 0 -> mm6 */ + pxor_r2r(mm6, mm6); /* 0 -> mm6 */ /* form multiplication mask */ - movd_m2r (sf->Amask, mm7); /* 0000F000 -> mm7 */ - punpcklbw_r2r (mm7, mm7); /* FF000000 -> mm7 */ - pcmpeqb_r2r (mm0, mm0); /* FFFFFFFF -> mm0 */ - movq_r2r (mm0, mm3); /* FFFFFFFF -> mm3 (for later) */ - pxor_r2r (mm0, mm7); /* 00FFFFFF -> mm7 (mult mask) */ + movd_m2r(sf->Amask, mm7); /* 0000F000 -> mm7 */ + punpcklbw_r2r(mm7, mm7); /* FF000000 -> mm7 */ + pcmpeqb_r2r(mm0, mm0); /* FFFFFFFF -> mm0 */ + movq_r2r(mm0, mm3); /* FFFFFFFF -> mm3 (for later) */ + pxor_r2r(mm0, mm7); /* 00FFFFFF -> mm7 (mult mask) */ /* form channel masks */ - movq_r2r (mm7, mm0); /* 00FFFFFF -> mm0 */ - packsswb_r2r (mm6, mm0); /* 00000FFF -> mm0 (channel mask) */ - packsswb_r2r (mm6, mm3); /* 0000FFFF -> mm3 */ - pxor_r2r (mm0, mm3); /* 0000F000 -> mm3 (~channel mask) */ + movq_r2r(mm7, mm0); /* 00FFFFFF -> mm0 */ + packsswb_r2r(mm6, mm0); /* 00000FFF -> mm0 (channel mask) */ + packsswb_r2r(mm6, mm3); /* 0000FFFF -> mm3 */ + pxor_r2r(mm0, mm3); /* 0000F000 -> mm3 (~channel mask) */ /* get alpha channel shift */ - movd_m2r (sf->Ashift, mm5); /* Ashift -> mm5 */ + movd_m2r(sf->Ashift, mm5); /* Ashift -> mm5 */ while (height--) { /* *INDENT-OFF* */ @@ -439,7 +439,7 @@ srcp += srcskip; dstp += dstskip; } - emms (); + emms(); } /* End GCC_ASMBLIT */ @@ -447,7 +447,7 @@ #elif MSVC_ASMBLIT /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ static void -BlitRGBtoRGBSurfaceAlpha128MMX (SDL_BlitInfo * info) +BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -459,9 +459,9 @@ __m64 src1, src2, dst1, dst2, lmask, hmask, dsta; - hmask = _mm_set_pi32 (0x00fefefe, 0x00fefefe); /* alpha128 mask -> hmask */ - lmask = _mm_set_pi32 (0x00010101, 0x00010101); /* !alpha128 mask -> lmask */ - dsta = _mm_set_pi32 (dalpha, dalpha); /* dst alpha mask -> dsta */ + hmask = _mm_set_pi32(0x00fefefe, 0x00fefefe); /* alpha128 mask -> hmask */ + lmask = _mm_set_pi32(0x00010101, 0x00010101); /* !alpha128 mask -> lmask */ + dsta = _mm_set_pi32(dalpha, dalpha); /* dst alpha mask -> dsta */ while (height--) { int n = width; @@ -480,15 +480,15 @@ src1 = *(__m64 *) srcp; /* 2 x src -> src1(ARGBARGB) */ src2 = src1; /* 2 x src -> src2(ARGBARGB) */ - dst2 = _mm_and_si64 (dst2, hmask); /* dst & mask -> dst2 */ - src2 = _mm_and_si64 (src2, hmask); /* src & mask -> src2 */ - src2 = _mm_add_pi32 (src2, dst2); /* dst2 + src2 -> src2 */ - src2 = _mm_srli_pi32 (src2, 1); /* src2 >> 1 -> src2 */ + dst2 = _mm_and_si64(dst2, hmask); /* dst & mask -> dst2 */ + src2 = _mm_and_si64(src2, hmask); /* src & mask -> src2 */ + src2 = _mm_add_pi32(src2, dst2); /* dst2 + src2 -> src2 */ + src2 = _mm_srli_pi32(src2, 1); /* src2 >> 1 -> src2 */ - dst1 = _mm_and_si64 (dst1, src1); /* src & dst -> dst1 */ - dst1 = _mm_and_si64 (dst1, lmask); /* dst1 & !mask -> dst1 */ - dst1 = _mm_add_pi32 (dst1, src2); /* src2 + dst1 -> dst1 */ - dst1 = _mm_or_si64 (dst1, dsta); /* dsta(full alpha) | dst1 -> dst1 */ + dst1 = _mm_and_si64(dst1, src1); /* src & dst -> dst1 */ + dst1 = _mm_and_si64(dst1, lmask); /* dst1 & !mask -> dst1 */ + dst1 = _mm_add_pi32(dst1, src2); /* src2 + dst1 -> dst1 */ + dst1 = _mm_or_si64(dst1, dsta); /* dsta(full alpha) | dst1 -> dst1 */ *(__m64 *) dstp = dst1; /* dst1 -> 2 x dst pixels */ dstp += 2; @@ -498,12 +498,12 @@ srcp += srcskip; dstp += dstskip; } - _mm_empty (); + _mm_empty(); } /* fast RGB888->(A)RGB888 blending with surface alpha */ static void -BlitRGBtoRGBSurfaceAlphaMMX (SDL_BlitInfo * info) +BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo * info) { SDL_PixelFormat *df = info->dst; Uint32 chanmask = df->Rmask | df->Gmask | df->Bmask; @@ -511,7 +511,7 @@ if (alpha == 128 && (df->Rmask | df->Gmask | df->Bmask) == 0x00FFFFFF) { /* only call a128 version when R,G,B occupy lower bits */ - BlitRGBtoRGBSurfaceAlpha128MMX (info); + BlitRGBtoRGBSurfaceAlpha128MMX(info); } else { int width = info->d_width; int height = info->d_height; @@ -524,36 +524,36 @@ __m64 src1, src2, dst1, dst2, mm_alpha, mm_zero, dsta; - mm_zero = _mm_setzero_si64 (); /* 0 -> mm_zero */ + mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ /* form the alpha mult */ amult = alpha | (alpha << 8); amult = amult | (amult << 16); chanmask = (0xff << df->Rshift) | (0xff << df->Gshift) | (0xff << df-> Bshift); - mm_alpha = _mm_set_pi32 (0, amult & chanmask); /* 0000AAAA -> mm_alpha, minus 1 chan */ - mm_alpha = _mm_unpacklo_pi8 (mm_alpha, mm_zero); /* 0A0A0A0A -> mm_alpha, minus 1 chan */ + mm_alpha = _mm_set_pi32(0, amult & chanmask); /* 0000AAAA -> mm_alpha, minus 1 chan */ + mm_alpha = _mm_unpacklo_pi8(mm_alpha, mm_zero); /* 0A0A0A0A -> mm_alpha, minus 1 chan */ /* at this point mm_alpha can be 000A0A0A or 0A0A0A00 or another combo */ - dsta = _mm_set_pi32 (dalpha, dalpha); /* dst alpha mask -> dsta */ + dsta = _mm_set_pi32(dalpha, dalpha); /* dst alpha mask -> dsta */ while (height--) { int n = width; if (n & 1) { /* One Pixel Blend */ - src2 = _mm_cvtsi32_si64 (*srcp); /* src(ARGB) -> src2 (0000ARGB) */ - src2 = _mm_unpacklo_pi8 (src2, mm_zero); /* 0A0R0G0B -> src2 */ + src2 = _mm_cvtsi32_si64(*srcp); /* src(ARGB) -> src2 (0000ARGB) */ + src2 = _mm_unpacklo_pi8(src2, mm_zero); /* 0A0R0G0B -> src2 */ - dst1 = _mm_cvtsi32_si64 (*dstp); /* dst(ARGB) -> dst1 (0000ARGB) */ - dst1 = _mm_unpacklo_pi8 (dst1, mm_zero); /* 0A0R0G0B -> dst1 */ + dst1 = _mm_cvtsi32_si64(*dstp); /* dst(ARGB) -> dst1 (0000ARGB) */ + dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* 0A0R0G0B -> dst1 */ - src2 = _mm_sub_pi16 (src2, dst1); /* src2 - dst2 -> src2 */ - src2 = _mm_mullo_pi16 (src2, mm_alpha); /* src2 * alpha -> src2 */ - src2 = _mm_srli_pi16 (src2, 8); /* src2 >> 8 -> src2 */ - dst1 = _mm_add_pi8 (src2, dst1); /* src2 + dst1 -> dst1 */ + src2 = _mm_sub_pi16(src2, dst1); /* src2 - dst2 -> src2 */ + src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ + src2 = _mm_srli_pi16(src2, 8); /* src2 >> 8 -> src2 */ + dst1 = _mm_add_pi8(src2, dst1); /* src2 + dst1 -> dst1 */ - dst1 = _mm_packs_pu16 (dst1, mm_zero); /* 0000ARGB -> dst1 */ - dst1 = _mm_or_si64 (dst1, dsta); /* dsta | dst1 -> dst1 */ - *dstp = _mm_cvtsi64_si32 (dst1); /* dst1 -> pixel */ + dst1 = _mm_packs_pu16(dst1, mm_zero); /* 0000ARGB -> dst1 */ + dst1 = _mm_or_si64(dst1, dsta); /* dsta | dst1 -> dst1 */ + *dstp = _mm_cvtsi64_si32(dst1); /* dst1 -> pixel */ ++srcp; ++dstp; @@ -565,26 +565,26 @@ /* Two Pixels Blend */ src1 = *(__m64 *) srcp; /* 2 x src -> src1(ARGBARGB) */ src2 = src1; /* 2 x src -> src2(ARGBARGB) */ - src1 = _mm_unpacklo_pi8 (src1, mm_zero); /* low - 0A0R0G0B -> src1 */ - src2 = _mm_unpackhi_pi8 (src2, mm_zero); /* high - 0A0R0G0B -> src2 */ + src1 = _mm_unpacklo_pi8(src1, mm_zero); /* low - 0A0R0G0B -> src1 */ + src2 = _mm_unpackhi_pi8(src2, mm_zero); /* high - 0A0R0G0B -> src2 */ dst1 = *(__m64 *) dstp; /* 2 x dst -> dst1(ARGBARGB) */ dst2 = dst1; /* 2 x dst -> dst2(ARGBARGB) */ - dst1 = _mm_unpacklo_pi8 (dst1, mm_zero); /* low - 0A0R0G0B -> dst1 */ - dst2 = _mm_unpackhi_pi8 (dst2, mm_zero); /* high - 0A0R0G0B -> dst2 */ + dst1 = _mm_unpacklo_pi8(dst1, mm_zero); /* low - 0A0R0G0B -> dst1 */ + dst2 = _mm_unpackhi_pi8(dst2, mm_zero); /* high - 0A0R0G0B -> dst2 */ - src1 = _mm_sub_pi16 (src1, dst1); /* src1 - dst1 -> src1 */ - src1 = _mm_mullo_pi16 (src1, mm_alpha); /* src1 * alpha -> src1 */ - src1 = _mm_srli_pi16 (src1, 8); /* src1 >> 8 -> src1 */ - dst1 = _mm_add_pi8 (src1, dst1); /* src1 + dst1(dst1) -> dst1 */ + src1 = _mm_sub_pi16(src1, dst1); /* src1 - dst1 -> src1 */ + src1 = _mm_mullo_pi16(src1, mm_alpha); /* src1 * alpha -> src1 */ + src1 = _mm_srli_pi16(src1, 8); /* src1 >> 8 -> src1 */ + dst1 = _mm_add_pi8(src1, dst1); /* src1 + dst1(dst1) -> dst1 */ - src2 = _mm_sub_pi16 (src2, dst2); /* src2 - dst2 -> src2 */ - src2 = _mm_mullo_pi16 (src2, mm_alpha); /* src2 * alpha -> src2 */ - src2 = _mm_srli_pi16 (src2, 8); /* src2 >> 8 -> src2 */ - dst2 = _mm_add_pi8 (src2, dst2); /* src2 + dst2(dst2) -> dst2 */ + src2 = _mm_sub_pi16(src2, dst2); /* src2 - dst2 -> src2 */ + src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ + src2 = _mm_srli_pi16(src2, 8); /* src2 >> 8 -> src2 */ + dst2 = _mm_add_pi8(src2, dst2); /* src2 + dst2(dst2) -> dst2 */ - dst1 = _mm_packs_pu16 (dst1, dst2); /* 0A0R0G0B(res1), 0A0R0G0B(res2) -> dst1(ARGBARGB) */ - dst1 = _mm_or_si64 (dst1, dsta); /* dsta | dst1 -> dst1 */ + dst1 = _mm_packs_pu16(dst1, dst2); /* 0A0R0G0B(res1), 0A0R0G0B(res2) -> dst1(ARGBARGB) */ + dst1 = _mm_or_si64(dst1, dsta); /* dsta | dst1 -> dst1 */ *(__m64 *) dstp = dst1; /* dst1 -> 2 x pixel */ @@ -594,13 +594,13 @@ srcp += srcskip; dstp += dstskip; } - _mm_empty (); + _mm_empty(); } } /* fast ARGB888->(A)RGB888 blending with pixel alpha */ static void -BlitRGBtoRGBPixelAlphaMMX (SDL_BlitInfo * info) +BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -616,7 +616,7 @@ __m64 src1, dst1, mm_alpha, mm_zero, dmask; - mm_zero = _mm_setzero_si64 (); /* 0 -> mm_zero */ + mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ multmask = ~(0xFFFFi 64 << (ashift * 2)); dmask = *(__m64 *) & multmask; /* dst alpha mask -> dmask */ @@ -658,7 +658,7 @@ srcp += srcskip; dstp += dstskip; } - _mm_empty (); + _mm_empty(); } /* End MSVC_ASMBLIT */ @@ -736,8 +736,7 @@ /* Calculate the permute vector used for 32->32 swizzling */ static vector unsigned char -calc_swizzle32 (const SDL_PixelFormat * srcfmt, - const SDL_PixelFormat * dstfmt) +calc_swizzle32(const SDL_PixelFormat * srcfmt, const SDL_PixelFormat * dstfmt) { /* * We have to assume that the bits that aren't used by other @@ -758,23 +757,23 @@ if (!dstfmt) { dstfmt = &default_pixel_format; } - const vector unsigned char plus = VECUINT8_LITERAL - (0x00, 0x00, 0x00, 0x00, - 0x04, 0x04, 0x04, 0x04, - 0x08, 0x08, 0x08, 0x08, - 0x0C, 0x0C, 0x0C, 0x0C); + const vector unsigned char plus = VECUINT8_LITERAL(0x00, 0x00, 0x00, 0x00, + 0x04, 0x04, 0x04, 0x04, + 0x08, 0x08, 0x08, 0x08, + 0x0C, 0x0C, 0x0C, + 0x0C); vector unsigned char vswiz; vector unsigned int srcvec; #define RESHIFT(X) (3 - ((X) >> 3)) - Uint32 rmask = RESHIFT (srcfmt->Rshift) << (dstfmt->Rshift); - Uint32 gmask = RESHIFT (srcfmt->Gshift) << (dstfmt->Gshift); - Uint32 bmask = RESHIFT (srcfmt->Bshift) << (dstfmt->Bshift); + Uint32 rmask = RESHIFT(srcfmt->Rshift) << (dstfmt->Rshift); + Uint32 gmask = RESHIFT(srcfmt->Gshift) << (dstfmt->Gshift); + Uint32 bmask = RESHIFT(srcfmt->Bshift) << (dstfmt->Bshift); Uint32 amask; /* Use zero for alpha if either surface doesn't have alpha */ if (dstfmt->Amask) { amask = - ((srcfmt->Amask) ? RESHIFT (srcfmt->Ashift) : 0x10) << (dstfmt-> - Ashift); + ((srcfmt->Amask) ? RESHIFT(srcfmt->Ashift) : 0x10) << (dstfmt-> + Ashift); } else { amask = 0x10101010 & ((dstfmt->Rmask | dstfmt->Gmask | dstfmt->Bmask) ^ @@ -782,12 +781,12 @@ } #undef RESHIFT ((unsigned int *) (char *) &srcvec)[0] = (rmask | gmask | bmask | amask); - vswiz = vec_add (plus, (vector unsigned char) vec_splat (srcvec, 0)); + vswiz = vec_add(plus, (vector unsigned char) vec_splat(srcvec, 0)); return (vswiz); } static void -Blit32to565PixelAlphaAltivec (SDL_BlitInfo * info) +Blit32to565PixelAlphaAltivec(SDL_BlitInfo * info) { int height = info->d_height; Uint8 *src = (Uint8 *) info->s_pixels; @@ -796,68 +795,68 @@ int dstskip = info->d_skip; SDL_PixelFormat *srcfmt = info->src; - vector unsigned char v0 = vec_splat_u8 (0); - vector unsigned short v8_16 = vec_splat_u16 (8); - vector unsigned short v1_16 = vec_splat_u16 (1); - vector unsigned short v2_16 = vec_splat_u16 (2); - vector unsigned short v3_16 = vec_splat_u16 (3); - vector unsigned int v8_32 = vec_splat_u32 (8); - vector unsigned int v16_32 = vec_add (v8_32, v8_32); + vector unsigned char v0 = vec_splat_u8(0); + vector unsigned short v8_16 = vec_splat_u16(8); + vector unsigned short v1_16 = vec_splat_u16(1); + vector unsigned short v2_16 = vec_splat_u16(2); + vector unsigned short v3_16 = vec_splat_u16(3); + vector unsigned int v8_32 = vec_splat_u32(8); + vector unsigned int v16_32 = vec_add(v8_32, v8_32); vector unsigned short v3f = - VECUINT16_LITERAL (0x003f, 0x003f, 0x003f, 0x003f, - 0x003f, 0x003f, 0x003f, 0x003f); + VECUINT16_LITERAL(0x003f, 0x003f, 0x003f, 0x003f, + 0x003f, 0x003f, 0x003f, 0x003f); vector unsigned short vfc = - VECUINT16_LITERAL (0x00fc, 0x00fc, 0x00fc, 0x00fc, - 0x00fc, 0x00fc, 0x00fc, 0x00fc); + VECUINT16_LITERAL(0x00fc, 0x00fc, 0x00fc, 0x00fc, + 0x00fc, 0x00fc, 0x00fc, 0x00fc); /* 0x10 - 0x1f is the alpha 0x00 - 0x0e evens are the red 0x01 - 0x0f odds are zero */ - vector unsigned char vredalpha1 = - VECUINT8_LITERAL (0x10, 0x00, 0x01, 0x01, - 0x10, 0x02, 0x01, 0x01, - 0x10, 0x04, 0x01, 0x01, - 0x10, 0x06, 0x01, 0x01); + vector unsigned char vredalpha1 = VECUINT8_LITERAL(0x10, 0x00, 0x01, 0x01, + 0x10, 0x02, 0x01, 0x01, + 0x10, 0x04, 0x01, 0x01, + 0x10, 0x06, 0x01, + 0x01); vector unsigned char vredalpha2 = - (vector unsigned char) (vec_add ((vector unsigned int) vredalpha1, - vec_sl (v8_32, v16_32)) + (vector unsigned char) (vec_add((vector unsigned int) vredalpha1, + vec_sl(v8_32, v16_32)) ); /* 0x00 - 0x0f is ARxx ARxx ARxx ARxx 0x11 - 0x0f odds are blue */ - vector unsigned char vblue1 = VECUINT8_LITERAL (0x00, 0x01, 0x02, 0x11, - 0x04, 0x05, 0x06, 0x13, - 0x08, 0x09, 0x0a, 0x15, - 0x0c, 0x0d, 0x0e, 0x17); + vector unsigned char vblue1 = VECUINT8_LITERAL(0x00, 0x01, 0x02, 0x11, + 0x04, 0x05, 0x06, 0x13, + 0x08, 0x09, 0x0a, 0x15, + 0x0c, 0x0d, 0x0e, 0x17); vector unsigned char vblue2 = - (vector unsigned char) (vec_add ((vector unsigned int) vblue1, v8_32) + (vector unsigned char) (vec_add((vector unsigned int) vblue1, v8_32) ); /* 0x00 - 0x0f is ARxB ARxB ARxB ARxB 0x10 - 0x0e evens are green */ - vector unsigned char vgreen1 = VECUINT8_LITERAL (0x00, 0x01, 0x10, 0x03, - 0x04, 0x05, 0x12, 0x07, - 0x08, 0x09, 0x14, 0x0b, - 0x0c, 0x0d, 0x16, 0x0f); + vector unsigned char vgreen1 = VECUINT8_LITERAL(0x00, 0x01, 0x10, 0x03, + 0x04, 0x05, 0x12, 0x07, + 0x08, 0x09, 0x14, 0x0b, + 0x0c, 0x0d, 0x16, 0x0f); vector unsigned char vgreen2 = (vector unsigned - char) (vec_add ((vector unsigned int) vgreen1, vec_sl (v8_32, v8_32)) + char) (vec_add((vector unsigned int) vgreen1, vec_sl(v8_32, v8_32)) ); - vector unsigned char vgmerge = VECUINT8_LITERAL (0x00, 0x02, 0x00, 0x06, - 0x00, 0x0a, 0x00, 0x0e, - 0x00, 0x12, 0x00, 0x16, - 0x00, 0x1a, 0x00, 0x1e); - vector unsigned char mergePermute = VEC_MERGE_PERMUTE (); - vector unsigned char vpermute = calc_swizzle32 (srcfmt, NULL); + vector unsigned char vgmerge = VECUINT8_LITERAL(0x00, 0x02, 0x00, 0x06, + 0x00, 0x0a, 0x00, 0x0e, + 0x00, 0x12, 0x00, 0x16, + 0x00, 0x1a, 0x00, 0x1e); + vector unsigned char mergePermute = VEC_MERGE_PERMUTE(); + vector unsigned char vpermute = calc_swizzle32(srcfmt, NULL); vector unsigned char valphaPermute = - vec_and (vec_lvsl (0, (int *) NULL), vec_splat_u8 (0xC)); + vec_and(vec_lvsl(0, (int *) NULL), vec_splat_u8(0xC)); - vector unsigned short vf800 = (vector unsigned short) vec_splat_u8 (-7); - vf800 = vec_sl (vf800, vec_splat_u16 (8)); + vector unsigned short vf800 = (vector unsigned short) vec_splat_u8(-7); + vf800 = vec_sl(vf800, vec_splat_u16(8)); while (height--) { int extrawidth; @@ -885,10 +884,10 @@ dst += 2; \ widthvar--; \ } - ONE_PIXEL_BLEND ((UNALIGNED_PTR (dst)) && (width), width); + ONE_PIXEL_BLEND((UNALIGNED_PTR(dst)) && (width), width); extrawidth = (width % 8); - valigner = VEC_ALIGNER (src); - vsrc = (vector unsigned char) vec_ld (0, src); + valigner = VEC_ALIGNER(src); + vsrc = (vector unsigned char) vec_ld(0, src); width -= extrawidth; while (width) { vector unsigned char valpha; @@ -898,65 +897,64 @@ vector unsigned short vpixel, vrpixel, vgpixel, vbpixel; /* Load 8 pixels from src as ARGB */ - voverflow = (vector unsigned char) vec_ld (15, src); - vsrc = vec_perm (vsrc, voverflow, valigner); - vsrc1 = vec_perm (vsrc, vsrc, vpermute); + voverflow = (vector unsigned char) vec_ld(15, src); + vsrc = vec_perm(vsrc, voverflow, valigner); + vsrc1 = vec_perm(vsrc, vsrc, vpermute); src += 16; - vsrc = (vector unsigned char) vec_ld (15, src); - voverflow = vec_perm (voverflow, vsrc, valigner); - vsrc2 = vec_perm (voverflow, voverflow, vpermute); + vsrc = (vector unsigned char) vec_ld(15, src); + voverflow = vec_perm(voverflow, vsrc, valigner); + vsrc2 = vec_perm(voverflow, voverflow, vpermute); src += 16; /* Load 8 pixels from dst as XRGB */ - voverflow = vec_ld (0, dst); - vR = vec_and ((vector unsigned short) voverflow, vf800); - vB = vec_sl ((vector unsigned short) voverflow, v3_16); - vG = vec_sl (vB, v2_16); + voverflow = vec_ld(0, dst); + vR = vec_and((vector unsigned short) voverflow, vf800); + vB = vec_sl((vector unsigned short) voverflow, v3_16); + vG = vec_sl(vB, v2_16); vdst1 = - (vector unsigned char) vec_perm ((vector unsigned char) vR, - (vector unsigned char) vR, - vredalpha1); - vdst1 = vec_perm (vdst1, (vector unsigned char) vB, vblue1); - vdst1 = vec_perm (vdst1, (vector unsigned char) vG, vgreen1); + (vector unsigned char) vec_perm((vector unsigned char) vR, + (vector unsigned char) vR, + vredalpha1); + vdst1 = vec_perm(vdst1, (vector unsigned char) vB, vblue1); + vdst1 = vec_perm(vdst1, (vector unsigned char) vG, vgreen1); vdst2 = - (vector unsigned char) vec_perm ((vector unsigned char) vR, - (vector unsigned char) vR, - vredalpha2); - vdst2 = vec_perm (vdst2, (vector unsigned char) vB, vblue2); - vdst2 = vec_perm (vdst2, (vector unsigned char) vG, vgreen2); + (vector unsigned char) vec_perm((vector unsigned char) vR, + (vector unsigned char) vR, + vredalpha2); + vdst2 = vec_perm(vdst2, (vector unsigned char) vB, vblue2); + vdst2 = vec_perm(vdst2, (vector unsigned char) vG, vgreen2); /* Alpha blend 8 pixels as ARGB */ - valpha = vec_perm (vsrc1, v0, valphaPermute); - VEC_MULTIPLY_ALPHA (vsrc1, vdst1, valpha, mergePermute, v1_16, - v8_16); - valpha = vec_perm (vsrc2, v0, valphaPermute); - VEC_MULTIPLY_ALPHA (vsrc2, vdst2, valpha, mergePermute, v1_16, - v8_16); + valpha = vec_perm(vsrc1, v0, valphaPermute); + VEC_MULTIPLY_ALPHA(vsrc1, vdst1, valpha, mergePermute, v1_16, + v8_16); + valpha = vec_perm(vsrc2, v0, valphaPermute); + VEC_MULTIPLY_ALPHA(vsrc2, vdst2, valpha, mergePermute, v1_16, + v8_16); /* Convert 8 pixels to 565 */ - vpixel = (vector unsigned short) vec_packpx ((vector unsigned int) - vdst1, - (vector unsigned int) - vdst2); - vgpixel = - (vector unsigned short) vec_perm (vdst1, vdst2, vgmerge); - vgpixel = vec_and (vgpixel, vfc); - vgpixel = vec_sl (vgpixel, v3_16); - vrpixel = vec_sl (vpixel, v1_16); - vrpixel = vec_and (vrpixel, vf800); - vbpixel = vec_and (vpixel, v3f); + vpixel = (vector unsigned short) vec_packpx((vector unsigned int) + vdst1, + (vector unsigned int) + vdst2); + vgpixel = (vector unsigned short) vec_perm(vdst1, vdst2, vgmerge); + vgpixel = vec_and(vgpixel, vfc); + vgpixel = vec_sl(vgpixel, v3_16); + vrpixel = vec_sl(vpixel, v1_16); + vrpixel = vec_and(vrpixel, vf800); + vbpixel = vec_and(vpixel, v3f); vdst1 = - vec_or ((vector unsigned char) vrpixel, - (vector unsigned char) vgpixel); - vdst1 = vec_or (vdst1, (vector unsigned char) vbpixel); + vec_or((vector unsigned char) vrpixel, + (vector unsigned char) vgpixel); + vdst1 = vec_or(vdst1, (vector unsigned char) vbpixel); /* Store 8 pixels */ - vec_st (vdst1, 0, dst); + vec_st(vdst1, 0, dst); width -= 8; dst += 16; } - ONE_PIXEL_BLEND ((extrawidth), extrawidth); + ONE_PIXEL_BLEND((extrawidth), extrawidth); #undef ONE_PIXEL_BLEND src += srcskip; dst += dstskip; @@ -964,7 +962,7 @@ } static void -Blit32to32SurfaceAlphaKeyAltivec (SDL_BlitInfo * info) +Blit32to32SurfaceAlphaKeyAltivec(SDL_BlitInfo * info) { unsigned alpha = info->src->alpha; int height = info->d_height; @@ -991,28 +989,28 @@ vector unsigned int vckey; vector unsigned int vrgbmask; - mergePermute = VEC_MERGE_PERMUTE (); - v0 = vec_splat_u8 (0); - v1 = vec_splat_u16 (1); - v8 = vec_splat_u16 (8); + mergePermute = VEC_MERGE_PERMUTE(); + v0 = vec_splat_u8(0); + v1 = vec_splat_u16(1); + v8 = vec_splat_u16(8); /* set the alpha to 255 on the destination surf */ - valphamask = VEC_ALPHA_MASK (); + valphamask = VEC_ALPHA_MASK(); - vsrcPermute = calc_swizzle32 (srcfmt, NULL); - vdstPermute = calc_swizzle32 (NULL, dstfmt); - vsdstPermute = calc_swizzle32 (dstfmt, NULL); + vsrcPermute = calc_swizzle32(srcfmt, NULL); + vdstPermute = calc_swizzle32(NULL, dstfmt); + vsdstPermute = calc_swizzle32(dstfmt, NULL); /* set a vector full of alpha and 255-alpha */ ((unsigned char *) &valpha)[0] = alpha; - valpha = vec_splat (valpha, 0); - vbits = (vector unsigned char) vec_splat_s8 (-1); + valpha = vec_splat(valpha, 0); + vbits = (vector unsigned char) vec_splat_s8(-1); ckey &= rgbmask; ((unsigned int *) (char *) &vckey)[0] = ckey; - vckey = vec_splat (vckey, 0); + vckey = vec_splat(vckey, 0); ((unsigned int *) (char *) &vrgbmask)[0] = rgbmask; - vrgbmask = vec_splat (vrgbmask, 0); + vrgbmask = vec_splat(vrgbmask, 0); while (height--) { int width = info->d_width; @@ -1031,11 +1029,11 @@ srcp++; \ widthvar--; \ } - ONE_PIXEL_BLEND ((UNALIGNED_PTR (dstp)) && (width), width); + ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width); if (width > 0) { int extrawidth = (width % 4); - vector unsigned char valigner = VEC_ALIGNER (srcp); - vector unsigned char vs = (vector unsigned char) vec_ld (0, srcp); + vector unsigned char valigner = VEC_ALIGNER(srcp); + vector unsigned char vs = (vector unsigned char) vec_ld(0, srcp); width -= extrawidth; while (width) { vector unsigned char vsel; @@ -1044,43 +1042,43 @@ vector unsigned char vd_orig; /* s = *srcp */ - voverflow = (vector unsigned char) vec_ld (15, srcp); - vs = vec_perm (vs, voverflow, valigner); + voverflow = (vector unsigned char) vec_ld(15, srcp); + vs = vec_perm(vs, voverflow, valigner); /* vsel is set for items that match the key */ vsel = - (vector unsigned char) vec_and ((vector unsigned int) vs, - vrgbmask); - vsel = (vector unsigned char) vec_cmpeq ((vector unsigned int) - vsel, vckey); + (vector unsigned char) vec_and((vector unsigned int) vs, + vrgbmask); + vsel = (vector unsigned char) vec_cmpeq((vector unsigned int) + vsel, vckey); /* permute to source format */ - vs = vec_perm (vs, valpha, vsrcPermute); + vs = vec_perm(vs, valpha, vsrcPermute); /* d = *dstp */ - vd = (vector unsigned char) vec_ld (0, dstp); - vd_orig = vd = vec_perm (vd, v0, vsdstPermute); + vd = (vector unsigned char) vec_ld(0, dstp); + vd_orig = vd = vec_perm(vd, v0, vsdstPermute); - VEC_MULTIPLY_ALPHA (vs, vd, valpha, mergePermute, v1, v8); + VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1, v8); /* set the alpha channel to full on */ - vd = vec_or (vd, valphamask); + vd = vec_or(vd, valphamask); /* mask out color key */ - vd = vec_sel (vd, vd_orig, vsel); + vd = vec_sel(vd, vd_orig, vsel); /* permute to dest format */ - vd = vec_perm (vd, vbits, vdstPermute); + vd = vec_perm(vd, vbits, vdstPermute); /* *dstp = res */ - vec_st ((vector unsigned int) vd, 0, dstp); + vec_st((vector unsigned int) vd, 0, dstp); srcp += 4; dstp += 4; width -= 4; vs = voverflow; } - ONE_PIXEL_BLEND ((extrawidth), extrawidth); + ONE_PIXEL_BLEND((extrawidth), extrawidth); } #undef ONE_PIXEL_BLEND @@ -1091,7 +1089,7 @@ static void -Blit32to32PixelAlphaAltivec (SDL_BlitInfo * info) +Blit32to32PixelAlphaAltivec(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -1112,16 +1110,16 @@ vector unsigned short v1; vector unsigned short v8; - v0 = vec_splat_u8 (0); - v1 = vec_splat_u16 (1); - v8 = vec_splat_u16 (8); - mergePermute = VEC_MERGE_PERMUTE (); - valphamask = VEC_ALPHA_MASK (); - valphaPermute = vec_and (vec_lvsl (0, (int *) NULL), vec_splat_u8 (0xC)); - vpixelmask = vec_nor (valphamask, v0); - vsrcPermute = calc_swizzle32 (srcfmt, NULL); - vdstPermute = calc_swizzle32 (NULL, dstfmt); - vsdstPermute = calc_swizzle32 (dstfmt, NULL); + v0 = vec_splat_u8(0); + v1 = vec_splat_u16(1); + v8 = vec_splat_u16(8); + mergePermute = VEC_MERGE_PERMUTE(); + valphamask = VEC_ALPHA_MASK(); + valphaPermute = vec_and(vec_lvsl(0, (int *) NULL), vec_splat_u8(0xC)); + vpixelmask = vec_nor(valphamask, v0); + vsrcPermute = calc_swizzle32(srcfmt, NULL); + vdstPermute = calc_swizzle32(NULL, dstfmt); + vsdstPermute = calc_swizzle32(dstfmt, NULL); while (height--) { width = info->d_width; @@ -1138,13 +1136,13 @@ ++dstp; \ widthvar--; \ } - ONE_PIXEL_BLEND ((UNALIGNED_PTR (dstp)) && (width), width); + ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width); if (width > 0) { /* vsrcPermute */ /* vdstPermute */ int extrawidth = (width % 4); - vector unsigned char valigner = VEC_ALIGNER (srcp); - vector unsigned char vs = (vector unsigned char) vec_ld (0, srcp); + vector unsigned char valigner = VEC_ALIGNER(srcp); + vector unsigned char vs = (vector unsigned char) vec_ld(0, srcp); width -= extrawidth; while (width) { vector unsigned char voverflow; @@ -1152,26 +1150,26 @@ vector unsigned char valpha; vector unsigned char vdstalpha; /* s = *srcp */ - voverflow = (vector unsigned char) vec_ld (15, srcp); - vs = vec_perm (vs, voverflow, valigner); - vs = vec_perm (vs, v0, vsrcPermute); + voverflow = (vector unsigned char) vec_ld(15, srcp); + vs = vec_perm(vs, voverflow, valigner); + vs = vec_perm(vs, v0, vsrcPermute); - valpha = vec_perm (vs, v0, valphaPermute); + valpha = vec_perm(vs, v0, valphaPermute); /* d = *dstp */ - vd = (vector unsigned char) vec_ld (0, dstp); - vd = vec_perm (vd, v0, vsdstPermute); - vdstalpha = vec_and (vd, valphamask); + vd = (vector unsigned char) vec_ld(0, dstp); + vd = vec_perm(vd, v0, vsdstPermute); + vdstalpha = vec_and(vd, valphamask); - VEC_MULTIPLY_ALPHA (vs, vd, valpha, mergePermute, v1, v8); + VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1, v8); /* set the alpha to the dest alpha */ - vd = vec_and (vd, vpixelmask); - vd = vec_or (vd, vdstalpha); - vd = vec_perm (vd, v0, vdstPermute); + vd = vec_and(vd, vpixelmask); + vd = vec_or(vd, vdstalpha); + vd = vec_perm(vd, v0, vdstPermute); /* *dstp = res */ - vec_st ((vector unsigned int) vd, 0, dstp); + vec_st((vector unsigned int) vd, 0, dstp); srcp += 4; dstp += 4; @@ -1179,7 +1177,7 @@ vs = voverflow; } - ONE_PIXEL_BLEND ((extrawidth), extrawidth); + ONE_PIXEL_BLEND((extrawidth), extrawidth); } srcp += srcskip; dstp += dstskip; @@ -1189,7 +1187,7 @@ /* fast ARGB888->(A)RGB888 blending with pixel alpha */ static void -BlitRGBtoRGBPixelAlphaAltivec (SDL_BlitInfo * info) +BlitRGBtoRGBPixelAlphaAltivec(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -1204,15 +1202,15 @@ vector unsigned char v0; vector unsigned short v1; vector unsigned short v8; - v0 = vec_splat_u8 (0); - v1 = vec_splat_u16 (1); - v8 = vec_splat_u16 (8); - mergePermute = VEC_MERGE_PERMUTE (); - valphamask = VEC_ALPHA_MASK (); - valphaPermute = vec_and (vec_lvsl (0, (int *) NULL), vec_splat_u8 (0xC)); + v0 = vec_splat_u8(0); + v1 = vec_splat_u16(1); + v8 = vec_splat_u16(8); + mergePermute = VEC_MERGE_PERMUTE(); + valphamask = VEC_ALPHA_MASK(); + valphaPermute = vec_and(vec_lvsl(0, (int *) NULL), vec_splat_u8(0xC)); - vpixelmask = vec_nor (valphamask, v0); + vpixelmask = vec_nor(valphamask, v0); while (height--) { width = info->d_width; #define ONE_PIXEL_BLEND(condition, widthvar) \ @@ -1242,11 +1240,11 @@ ++dstp; \ widthvar--; \ } - ONE_PIXEL_BLEND ((UNALIGNED_PTR (dstp)) && (width), width); + ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width); if (width > 0) { int extrawidth = (width % 4); - vector unsigned char valigner = VEC_ALIGNER (srcp); - vector unsigned char vs = (vector unsigned char) vec_ld (0, srcp); + vector unsigned char valigner = VEC_ALIGNER(srcp); + vector unsigned char vs = (vector unsigned char) vec_ld(0, srcp); width -= extrawidth; while (width) { vector unsigned char voverflow; @@ -1254,30 +1252,30 @@ vector unsigned char valpha; vector unsigned char vdstalpha; /* s = *srcp */ - voverflow = (vector unsigned char) vec_ld (15, srcp); - vs = vec_perm (vs, voverflow, valigner); + voverflow = (vector unsigned char) vec_ld(15, srcp); + vs = vec_perm(vs, voverflow, valigner); - valpha = vec_perm (vs, v0, valphaPermute); + valpha = vec_perm(vs, v0, valphaPermute); /* d = *dstp */ - vd = (vector unsigned char) vec_ld (0, dstp); - vdstalpha = vec_and (vd, valphamask); + vd = (vector unsigned char) vec_ld(0, dstp); + vdstalpha = vec_and(vd, valphamask); - VEC_MULTIPLY_ALPHA (vs, vd, valpha, mergePermute, v1, v8); + VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1, v8); /* set the alpha to the dest alpha */ - vd = vec_and (vd, vpixelmask); - vd = vec_or (vd, vdstalpha); + vd = vec_and(vd, vpixelmask); + vd = vec_or(vd, vdstalpha); /* *dstp = res */ - vec_st ((vector unsigned int) vd, 0, dstp); + vec_st((vector unsigned int) vd, 0, dstp); srcp += 4; dstp += 4; width -= 4; vs = voverflow; } - ONE_PIXEL_BLEND ((extrawidth), extrawidth); + ONE_PIXEL_BLEND((extrawidth), extrawidth); } srcp += srcskip; dstp += dstskip; @@ -1286,7 +1284,7 @@ } static void -Blit32to32SurfaceAlphaAltivec (SDL_BlitInfo * info) +Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo * info) { /* XXX : 6 */ unsigned alpha = info->src->alpha; @@ -1309,21 +1307,21 @@ vector unsigned short v1; vector unsigned short v8; - mergePermute = VEC_MERGE_PERMUTE (); - v1 = vec_splat_u16 (1); - v8 = vec_splat_u16 (8); + mergePermute = VEC_MERGE_PERMUTE(); + v1 = vec_splat_u16(1); + v8 = vec_splat_u16(8); /* set the alpha to 255 on the destination surf */ - valphamask = VEC_ALPHA_MASK (); + valphamask = VEC_ALPHA_MASK(); - vsrcPermute = calc_swizzle32 (srcfmt, NULL); - vdstPermute = calc_swizzle32 (NULL, dstfmt); - vsdstPermute = calc_swizzle32 (dstfmt, NULL); + vsrcPermute = calc_swizzle32(srcfmt, NULL); + vdstPermute = calc_swizzle32(NULL, dstfmt); + vsdstPermute = calc_swizzle32(dstfmt, NULL); /* set a vector full of alpha and 255-alpha */ ((unsigned char *) &valpha)[0] = alpha; - valpha = vec_splat (valpha, 0); - vbits = (vector unsigned char) vec_splat_s8 (-1); + valpha = vec_splat(valpha, 0); + vbits = (vector unsigned char) vec_splat_s8(-1); while (height--) { int width = info->d_width; @@ -1338,40 +1336,40 @@ ++dstp; \ widthvar--; \ } - ONE_PIXEL_BLEND ((UNALIGNED_PTR (dstp)) && (width), width); + ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width); if (width > 0) { int extrawidth = (width % 4); - vector unsigned char valigner = vec_lvsl (0, srcp); - vector unsigned char vs = (vector unsigned char) vec_ld (0, srcp); + vector unsigned char valigner = vec_lvsl(0, srcp); + vector unsigned char vs = (vector unsigned char) vec_ld(0, srcp); width -= extrawidth; while (width) { vector unsigned char voverflow; vector unsigned char vd; /* s = *srcp */ - voverflow = (vector unsigned char) vec_ld (15, srcp); - vs = vec_perm (vs, voverflow, valigner); - vs = vec_perm (vs, valpha, vsrcPermute); + voverflow = (vector unsigned char) vec_ld(15, srcp); + vs = vec_perm(vs, voverflow, valigner); + vs = vec_perm(vs, valpha, vsrcPermute); /* d = *dstp */ - vd = (vector unsigned char) vec_ld (0, dstp); - vd = vec_perm (vd, vd, vsdstPermute); + vd = (vector unsigned char) vec_ld(0, dstp); + vd = vec_perm(vd, vd, vsdstPermute); - VEC_MULTIPLY_ALPHA (vs, vd, valpha, mergePermute, v1, v8); + VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1, v8); /* set the alpha channel to full on */ - vd = vec_or (vd, valphamask); - vd = vec_perm (vd, vbits, vdstPermute); + vd = vec_or(vd, valphamask); + vd = vec_perm(vd, vbits, vdstPermute); /* *dstp = res */ - vec_st ((vector unsigned int) vd, 0, dstp); + vec_st((vector unsigned int) vd, 0, dstp); srcp += 4; dstp += 4; width -= 4; vs = voverflow; } - ONE_PIXEL_BLEND ((extrawidth), extrawidth); + ONE_PIXEL_BLEND((extrawidth), extrawidth); } #undef ONE_PIXEL_BLEND @@ -1384,7 +1382,7 @@ /* fast RGB888->(A)RGB888 blending */ static void -BlitRGBtoRGBSurfaceAlphaAltivec (SDL_BlitInfo * info) +BlitRGBtoRGBSurfaceAlphaAltivec(SDL_BlitInfo * info) { unsigned alpha = info->src->alpha; int height = info->d_height; @@ -1398,16 +1396,16 @@ vector unsigned short v1; vector unsigned short v8; - mergePermute = VEC_MERGE_PERMUTE (); - v1 = vec_splat_u16 (1); - v8 = vec_splat_u16 (8); + mergePermute = VEC_MERGE_PERMUTE(); + v1 = vec_splat_u16(1); + v8 = vec_splat_u16(8); /* set the alpha to 255 on the destination surf */ - valphamask = VEC_ALPHA_MASK (); + valphamask = VEC_ALPHA_MASK(); /* set a vector full of alpha and 255-alpha */ ((unsigned char *) &valpha)[0] = alpha; - valpha = vec_splat (valpha, 0); + valpha = vec_splat(valpha, 0); while (height--) { int width = info->d_width; @@ -1426,37 +1424,37 @@ ++dstp; \ widthvar--; \ } - ONE_PIXEL_BLEND ((UNALIGNED_PTR (dstp)) && (width), width); + ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width); if (width > 0) { int extrawidth = (width % 4); - vector unsigned char valigner = VEC_ALIGNER (srcp); - vector unsigned char vs = (vector unsigned char) vec_ld (0, srcp); + vector unsigned char valigner = VEC_ALIGNER(srcp); + vector unsigned char vs = (vector unsigned char) vec_ld(0, srcp); width -= extrawidth; while (width) { vector unsigned char voverflow; vector unsigned char vd; /* s = *srcp */ - voverflow = (vector unsigned char) vec_ld (15, srcp); - vs = vec_perm (vs, voverflow, valigner); + voverflow = (vector unsigned char) vec_ld(15, srcp); + vs = vec_perm(vs, voverflow, valigner); /* d = *dstp */ - vd = (vector unsigned char) vec_ld (0, dstp); + vd = (vector unsigned char) vec_ld(0, dstp); - VEC_MULTIPLY_ALPHA (vs, vd, valpha, mergePermute, v1, v8); + VEC_MULTIPLY_ALPHA(vs, vd, valpha, mergePermute, v1, v8); /* set the alpha channel to full on */ - vd = vec_or (vd, valphamask); + vd = vec_or(vd, valphamask); /* *dstp = res */ - vec_st ((vector unsigned int) vd, 0, dstp); + vec_st((vector unsigned int) vd, 0, dstp); srcp += 4; dstp += 4; width -= 4; vs = voverflow; } - ONE_PIXEL_BLEND ((extrawidth), extrawidth); + ONE_PIXEL_BLEND((extrawidth), extrawidth); } #undef ONE_PIXEL_BLEND @@ -1472,7 +1470,7 @@ /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */ static void -BlitRGBtoRGBSurfaceAlpha128 (SDL_BlitInfo * info) +BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -1497,11 +1495,11 @@ /* fast RGB888->(A)RGB888 blending with surface alpha */ static void -BlitRGBtoRGBSurfaceAlpha (SDL_BlitInfo * info) +BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info) { unsigned alpha = info->src->alpha; if (alpha == 128) { - BlitRGBtoRGBSurfaceAlpha128 (info); + BlitRGBtoRGBSurfaceAlpha128(info); } else { int width = info->d_width; int height = info->d_height; @@ -1569,7 +1567,7 @@ /* fast ARGB888->(A)RGB888 blending with pixel alpha */ static void -BlitRGBtoRGBPixelAlpha (SDL_BlitInfo * info) +BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -1622,7 +1620,7 @@ #if GCC_ASMBLIT /* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */ inline static void -BlitRGBtoRGBPixelAlphaMMX3DNOW (SDL_BlitInfo * info) +BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -1633,23 +1631,23 @@ SDL_PixelFormat *sf = info->src; Uint32 amask = sf->Amask; - __asm__ ( - /* make mm6 all zeros. */ - "pxor %%mm6, %%mm6\n" - /* Make a mask to preserve the alpha. */ - "movd %0, %%mm7\n\t" /* 0000F000 -> mm7 */ - "punpcklbw %%mm7, %%mm7\n\t" /* FF000000 -> mm7 */ - "pcmpeqb %%mm4, %%mm4\n\t" /* FFFFFFFF -> mm4 */ - "movq %%mm4, %%mm3\n\t" /* FFFFFFFF -> mm3 (for later) */ - "pxor %%mm4, %%mm7\n\t" /* 00FFFFFF -> mm7 (mult mask) */ - /* form channel masks */ - "movq %%mm7, %%mm4\n\t" /* 00FFFFFF -> mm4 */ - "packsswb %%mm6, %%mm4\n\t" /* 00000FFF -> mm4 (channel mask) */ - "packsswb %%mm6, %%mm3\n\t" /* 0000FFFF -> mm3 */ - "pxor %%mm4, %%mm3\n\t" /* 0000F000 -> mm3 (~channel mask) */ - /* get alpha channel shift */ - "movd %1, %%mm5\n\t" /* Ashift -> mm5 */ - : /* nothing */ : "m" (sf->Amask), "m" (sf->Ashift)); + __asm__( + /* make mm6 all zeros. */ + "pxor %%mm6, %%mm6\n" + /* Make a mask to preserve the alpha. */ + "movd %0, %%mm7\n\t" /* 0000F000 -> mm7 */ + "punpcklbw %%mm7, %%mm7\n\t" /* FF000000 -> mm7 */ + "pcmpeqb %%mm4, %%mm4\n\t" /* FFFFFFFF -> mm4 */ + "movq %%mm4, %%mm3\n\t" /* FFFFFFFF -> mm3 (for later) */ + "pxor %%mm4, %%mm7\n\t" /* 00FFFFFF -> mm7 (mult mask) */ + /* form channel masks */ + "movq %%mm7, %%mm4\n\t" /* 00FFFFFF -> mm4 */ + "packsswb %%mm6, %%mm4\n\t" /* 00000FFF -> mm4 (channel mask) */ + "packsswb %%mm6, %%mm3\n\t" /* 0000FFFF -> mm3 */ + "pxor %%mm4, %%mm3\n\t" /* 0000F000 -> mm3 (~channel mask) */ + /* get alpha channel shift */ + "movd %1, %%mm5\n\t" /* Ashift -> mm5 */ + : /* nothing */ : "m"(sf->Amask), "m"(sf->Ashift)); while (height--) { @@ -1730,7 +1728,7 @@ dstp += dstskip; } - __asm__ ("emms\n":); + __asm__("emms\n":); } /* End GCC_ASMBLIT*/ @@ -1738,7 +1736,7 @@ #elif MSVC_ASMBLIT /* fast (as in MMX with prefetch) ARGB888->(A)RGB888 blending with pixel alpha */ static void -BlitRGBtoRGBPixelAlphaMMX3DNOW (SDL_BlitInfo * info) +BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -1754,7 +1752,7 @@ __m64 src1, dst1, mm_alpha, mm_zero, dmask; - mm_zero = _mm_setzero_si64 (); /* 0 -> mm_zero */ + mm_zero = _mm_setzero_si64(); /* 0 -> mm_zero */ multmask = ~(0xFFFFi 64 << (ashift * 2)); dmask = *(__m64 *) & multmask; /* dst alpha mask -> dmask */ @@ -1801,7 +1799,7 @@ srcp += srcskip; dstp += dstskip; } - _mm_empty (); + _mm_empty(); } /* End MSVC_ASMBLIT */ @@ -1820,7 +1818,7 @@ + (s & d & (~(mask | mask << 16)))) static void -Blit16to16SurfaceAlpha128 (SDL_BlitInfo * info, Uint16 mask) +Blit16to16SurfaceAlpha128(SDL_BlitInfo * info, Uint16 mask) { int width = info->d_width; int height = info->d_height; @@ -1842,7 +1840,7 @@ /* handle odd destination */ if ((uintptr_t) dstp & 2) { Uint16 d = *dstp, s = *srcp; - *dstp = BLEND16_50 (d, s, mask); + *dstp = BLEND16_50(d, s, mask); dstp++; srcp++; w--; @@ -1862,7 +1860,7 @@ s = (prev_sw >> 16) + (sw << 16); #endif prev_sw = sw; - *(Uint32 *) dstp = BLEND2x16_50 (dw, s, mask); + *(Uint32 *) dstp = BLEND2x16_50(dw, s, mask); dstp += 2; srcp += 2; w -= 2; @@ -1876,7 +1874,7 @@ #else s = (Uint16) (prev_sw >> 16); #endif - *dstp = BLEND16_50 (d, s, mask); + *dstp = BLEND16_50(d, s, mask); srcp++; dstp++; } @@ -1889,7 +1887,7 @@ /* first odd pixel? */ if ((uintptr_t) srcp & 2) { Uint16 d = *dstp, s = *srcp; - *dstp = BLEND16_50 (d, s, mask); + *dstp = BLEND16_50(d, s, mask); srcp++; dstp++; w--; @@ -1899,7 +1897,7 @@ while (w > 1) { Uint32 sw = *(Uint32 *) srcp; Uint32 dw = *(Uint32 *) dstp; - *(Uint32 *) dstp = BLEND2x16_50 (dw, sw, mask); + *(Uint32 *) dstp = BLEND2x16_50(dw, sw, mask); srcp += 2; dstp += 2; w -= 2; @@ -1908,7 +1906,7 @@ /* last odd pixel? */ if (w) { Uint16 d = *dstp, s = *srcp; - *dstp = BLEND16_50 (d, s, mask); + *dstp = BLEND16_50(d, s, mask); srcp++; dstp++; } @@ -1921,11 +1919,11 @@ #if GCC_ASMBLIT /* fast RGB565->RGB565 blending with surface alpha */ static void -Blit565to565SurfaceAlphaMMX (SDL_BlitInfo * info) +Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info) { unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */ if (alpha == 128) { - Blit16to16SurfaceAlpha128 (info, 0xf7de); + Blit16to16SurfaceAlpha128(info, 0xf7de); } else { int width = info->d_width; int height = info->d_height; @@ -1940,18 +1938,18 @@ *(Uint64 *) load = alpha; alpha >>= 3; /* downscale alpha to 5 bits */ - movq_m2r (*load, mm0); /* alpha(0000000A) -> mm0 */ - punpcklwd_r2r (mm0, mm0); /* 00000A0A -> mm0 */ - punpcklwd_r2r (mm0, mm0); /* 0A0A0A0A -> mm0 */ + movq_m2r(*load, mm0); /* alpha(0000000A) -> mm0 */ + punpcklwd_r2r(mm0, mm0); /* 00000A0A -> mm0 */ + punpcklwd_r2r(mm0, mm0); /* 0A0A0A0A -> mm0 */ /* position alpha to allow for mullo and mulhi on diff channels to reduce the number of operations */ - psllq_i2r (3, mm0); + psllq_i2r(3, mm0); /* Setup the 565 color channel masks */ *(Uint64 *) load = 0x07E007E007E007E0ULL; - movq_m2r (*load, mm4); /* MASKGREEN -> mm4 */ + movq_m2r(*load, mm4); /* MASKGREEN -> mm4 */ *(Uint64 *) load = 0x001F001F001F001FULL; - movq_m2r (*load, mm7); /* MASKBLUE -> mm7 */ + movq_m2r(*load, mm7); /* MASKBLUE -> mm7 */ while (height--) { /* *INDENT-OFF* */ DUFFS_LOOP_QUATRO2( @@ -2057,17 +2055,17 @@ srcp += srcskip; dstp += dstskip; } - emms (); + emms(); } } /* fast RGB555->RGB555 blending with surface alpha */ static void -Blit555to555SurfaceAlphaMMX (SDL_BlitInfo * info) +Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info) { unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */ if (alpha == 128) { - Blit16to16SurfaceAlpha128 (info, 0xfbde); + Blit16to16SurfaceAlpha128(info, 0xfbde); } else { int width = info->d_width; int height = info->d_height; @@ -2082,18 +2080,18 @@ *(Uint64 *) load = alpha; alpha >>= 3; /* downscale alpha to 5 bits */ - movq_m2r (*load, mm0); /* alpha(0000000A) -> mm0 */ - punpcklwd_r2r (mm0, mm0); /* 00000A0A -> mm0 */ - punpcklwd_r2r (mm0, mm0); /* 0A0A0A0A -> mm0 */ + movq_m2r(*load, mm0); /* alpha(0000000A) -> mm0 */ + punpcklwd_r2r(mm0, mm0); /* 00000A0A -> mm0 */ + punpcklwd_r2r(mm0, mm0); /* 0A0A0A0A -> mm0 */ /* position alpha to allow for mullo and mulhi on diff channels to reduce the number of operations */ - psllq_i2r (3, mm0); + psllq_i2r(3, mm0); /* Setup the 555 color channel masks */ *(Uint64 *) load = 0x03E003E003E003E0ULL; - movq_m2r (*load, mm4); /* MASKGREEN -> mm4 */ + movq_m2r(*load, mm4); /* MASKGREEN -> mm4 */ *(Uint64 *) load = 0x001F001F001F001FULL; - movq_m2r (*load, mm7); /* MASKBLUE -> mm7 */ + movq_m2r(*load, mm7); /* MASKBLUE -> mm7 */ while (height--) { /* *INDENT-OFF* */ DUFFS_LOOP_QUATRO2( @@ -2204,7 +2202,7 @@ srcp += srcskip; dstp += dstskip; } - emms (); + emms(); } } @@ -2213,11 +2211,11 @@ #elif MSVC_ASMBLIT /* fast RGB565->RGB565 blending with surface alpha */ static void -Blit565to565SurfaceAlphaMMX (SDL_BlitInfo * info) +Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info) { unsigned alpha = info->src->alpha; if (alpha == 128) { - Blit16to16SurfaceAlpha128 (info, 0xf7de); + Blit16to16SurfaceAlpha128(info, 0xf7de); } else { int width = info->d_width; int height = info->d_height; @@ -2230,18 +2228,18 @@ __m64 src1, dst1, src2, dst2, gmask, bmask, mm_res, mm_alpha; alpha &= ~(1 + 2 + 4); /* cut alpha to get the exact same behaviour */ - mm_alpha = _mm_set_pi32 (0, alpha); /* 0000000A -> mm_alpha */ + mm_alpha = _mm_set_pi32(0, alpha); /* 0000000A -> mm_alpha */ alpha >>= 3; /* downscale alpha to 5 bits */ - mm_alpha = _mm_unpacklo_pi16 (mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ - mm_alpha = _mm_unpacklo_pi32 (mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ + mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ + mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ /* position alpha to allow for mullo and mulhi on diff channels to reduce the number of operations */ - mm_alpha = _mm_slli_si64 (mm_alpha, 3); + mm_alpha = _mm_slli_si64(mm_alpha, 3); /* Setup the 565 color channel masks */ - gmask = _mm_set_pi32 (0x07E007E0, 0x07E007E0); /* MASKGREEN -> gmask */ - bmask = _mm_set_pi32 (0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */ + gmask = _mm_set_pi32(0x07E007E0, 0x07E007E0); /* MASKGREEN -> gmask */ + bmask = _mm_set_pi32(0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */ while (height--) { /* *INDENT-OFF* */ @@ -2344,17 +2342,17 @@ srcp += srcskip; dstp += dstskip; } - _mm_empty (); + _mm_empty(); } } /* fast RGB555->RGB555 blending with surface alpha */ static void -Blit555to555SurfaceAlphaMMX (SDL_BlitInfo * info) +Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info) { unsigned alpha = info->src->alpha; if (alpha == 128) { - Blit16to16SurfaceAlpha128 (info, 0xfbde); + Blit16to16SurfaceAlpha128(info, 0xfbde); } else { int width = info->d_width; int height = info->d_height; @@ -2367,19 +2365,19 @@ __m64 src1, dst1, src2, dst2, rmask, gmask, bmask, mm_res, mm_alpha; alpha &= ~(1 + 2 + 4); /* cut alpha to get the exact same behaviour */ - mm_alpha = _mm_set_pi32 (0, alpha); /* 0000000A -> mm_alpha */ + mm_alpha = _mm_set_pi32(0, alpha); /* 0000000A -> mm_alpha */ alpha >>= 3; /* downscale alpha to 5 bits */ - mm_alpha = _mm_unpacklo_pi16 (mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ - mm_alpha = _mm_unpacklo_pi32 (mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ + mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); /* 00000A0A -> mm_alpha */ + mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); /* 0A0A0A0A -> mm_alpha */ /* position alpha to allow for mullo and mulhi on diff channels to reduce the number of operations */ - mm_alpha = _mm_slli_si64 (mm_alpha, 3); + mm_alpha = _mm_slli_si64(mm_alpha, 3); /* Setup the 555 color channel masks */ - rmask = _mm_set_pi32 (0x7C007C00, 0x7C007C00); /* MASKRED -> rmask */ - gmask = _mm_set_pi32 (0x03E003E0, 0x03E003E0); /* MASKGREEN -> gmask */ - bmask = _mm_set_pi32 (0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */ + rmask = _mm_set_pi32(0x7C007C00, 0x7C007C00); /* MASKRED -> rmask */ + gmask = _mm_set_pi32(0x03E003E0, 0x03E003E0); /* MASKGREEN -> gmask */ + bmask = _mm_set_pi32(0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */ while (height--) { /* *INDENT-OFF* */ @@ -2482,18 +2480,18 @@ srcp += srcskip; dstp += dstskip; } - _mm_empty (); + _mm_empty(); } } #endif /* GCC_ASMBLIT, MSVC_ASMBLIT */ /* fast RGB565->RGB565 blending with surface alpha */ static void -Blit565to565SurfaceAlpha (SDL_BlitInfo * info) +Blit565to565SurfaceAlpha(SDL_BlitInfo * info) { unsigned alpha = info->src->alpha; if (alpha == 128) { - Blit16to16SurfaceAlpha128 (info, 0xf7de); + Blit16to16SurfaceAlpha128(info, 0xf7de); } else { int width = info->d_width; int height = info->d_height; @@ -2528,11 +2526,11 @@ /* fast RGB555->RGB555 blending with surface alpha */ static void -Blit555to555SurfaceAlpha (SDL_BlitInfo * info) +Blit555to555SurfaceAlpha(SDL_BlitInfo * info) { unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */ if (alpha == 128) { - Blit16to16SurfaceAlpha128 (info, 0xfbde); + Blit16to16SurfaceAlpha128(info, 0xfbde); } else { int width = info->d_width; int height = info->d_height; @@ -2567,7 +2565,7 @@ /* fast ARGB8888->RGB565 blending with pixel alpha */ static void -BlitARGBto565PixelAlpha (SDL_BlitInfo * info) +BlitARGBto565PixelAlpha(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -2613,7 +2611,7 @@ /* fast ARGB8888->RGB555 blending with pixel alpha */ static void -BlitARGBto555PixelAlpha (SDL_BlitInfo * info) +BlitARGBto555PixelAlpha(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -2660,7 +2658,7 @@ /* General (slow) N->N blending with per-surface alpha */ static void -BlitNtoNSurfaceAlpha (SDL_BlitInfo * info) +BlitNtoNSurfaceAlpha(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -2704,7 +2702,7 @@ /* General (slow) colorkeyed N->N blending with per-surface alpha */ static void -BlitNtoNSurfaceAlphaKey (SDL_BlitInfo * info) +BlitNtoNSurfaceAlphaKey(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -2750,7 +2748,7 @@ /* General (slow) N->N blending with pixel alpha */ static void -BlitNtoNPixelAlpha (SDL_BlitInfo * info) +BlitNtoNPixelAlpha(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -2804,7 +2802,7 @@ SDL_loblit -SDL_CalculateAlphaBlit (SDL_Surface * surface, int blit_index) +SDL_CalculateAlphaBlit(SDL_Surface * surface, int blit_index) { SDL_PixelFormat *sf = surface->format; SDL_PixelFormat *df = surface->map->dst->format; @@ -2817,7 +2815,7 @@ #if SDL_ALTIVEC_BLITTERS if (sf->BytesPerPixel == 4 && df->BytesPerPixel == 4 && !(surface->map->dst->flags & SDL_HWSURFACE) - && SDL_HasAltiVec ()) + && SDL_HasAltiVec()) return Blit32to32SurfaceAlphaKeyAltivec; else #endif @@ -2832,14 +2830,14 @@ if (surface->map->identity) { if (df->Gmask == 0x7e0) { #if MMX_ASMBLIT - if (SDL_HasMMX ()) + if (SDL_HasMMX()) return Blit565to565SurfaceAlphaMMX; else #endif return Blit565to565SurfaceAlpha; } else if (df->Gmask == 0x3e0) { #if MMX_ASMBLIT - if (SDL_HasMMX ()) + if (SDL_HasMMX()) return Blit555to555SurfaceAlphaMMX; else #endif @@ -2855,13 +2853,13 @@ #if MMX_ASMBLIT if (sf->Rshift % 8 == 0 && sf->Gshift % 8 == 0 - && sf->Bshift % 8 == 0 && SDL_HasMMX ()) + && sf->Bshift % 8 == 0 && SDL_HasMMX()) return BlitRGBtoRGBSurfaceAlphaMMX; #endif if ((sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff) { #if SDL_ALTIVEC_BLITTERS if (!(surface->map->dst->flags & SDL_HWSURFACE) - && SDL_HasAltiVec ()) + && SDL_HasAltiVec()) return BlitRGBtoRGBSurfaceAlphaAltivec; #endif return BlitRGBtoRGBSurfaceAlpha; @@ -2870,7 +2868,7 @@ #if SDL_ALTIVEC_BLITTERS if ((sf->BytesPerPixel == 4) && !(surface->map->dst->flags & SDL_HWSURFACE) - && SDL_HasAltiVec ()) + && SDL_HasAltiVec()) return Blit32to32SurfaceAlphaAltivec; else #endif @@ -2892,7 +2890,7 @@ if (sf->BytesPerPixel == 4 && !(surface->map->dst->flags & SDL_HWSURFACE) && df->Gmask == 0x7e0 && df->Bmask == 0x1f - && SDL_HasAltiVec ()) + && SDL_HasAltiVec()) return Blit32to565PixelAlphaAltivec; else #endif @@ -2916,16 +2914,16 @@ && sf->Gshift % 8 == 0 && sf->Bshift % 8 == 0 && sf->Ashift % 8 == 0 && sf->Aloss == 0) { - if (SDL_Has3DNow ()) + if (SDL_Has3DNow()) return BlitRGBtoRGBPixelAlphaMMX3DNOW; - if (SDL_HasMMX ()) + if (SDL_HasMMX()) return BlitRGBtoRGBPixelAlphaMMX; } #endif if (sf->Amask == 0xff000000) { #if SDL_ALTIVEC_BLITTERS if (!(surface->map->dst->flags & SDL_HWSURFACE) - && SDL_HasAltiVec ()) + && SDL_HasAltiVec()) return BlitRGBtoRGBPixelAlphaAltivec; #endif return BlitRGBtoRGBPixelAlpha; @@ -2934,7 +2932,7 @@ #if SDL_ALTIVEC_BLITTERS if (sf->Amask && sf->BytesPerPixel == 4 && !(surface->map->dst->flags & SDL_HWSURFACE) - && SDL_HasAltiVec ()) + && SDL_HasAltiVec()) return Blit32to32PixelAlphaAltivec; else #endif diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_blit_N.c --- a/src/video/SDL_blit_N.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_blit_N.c Mon May 29 04:04:35 2006 +0000 @@ -39,14 +39,14 @@ #ifdef __MACOSX__ #include static size_t -GetL3CacheSize (void) +GetL3CacheSize(void) { const char key[] = "hw.l3cachesize"; u_int64_t result = 0; - size_t typeSize = sizeof (result); + size_t typeSize = sizeof(result); - int err = sysctlbyname (key, &result, &typeSize, NULL, 0); + int err = sysctlbyname(key, &result, &typeSize, NULL, 0); if (0 != err) return 0; @@ -54,7 +54,7 @@ } #else static size_t -GetL3CacheSize (void) +GetL3CacheSize(void) { /* XXX: Just guess G4 */ return 2097152; @@ -105,8 +105,7 @@ /* Calculate the permute vector used for 32->32 swizzling */ static vector unsigned char -calc_swizzle32 (const SDL_PixelFormat * srcfmt, - const SDL_PixelFormat * dstfmt) +calc_swizzle32(const SDL_PixelFormat * srcfmt, const SDL_PixelFormat * dstfmt) { /* * We have to assume that the bits that aren't used by other @@ -127,23 +126,23 @@ if (!dstfmt) { dstfmt = &default_pixel_format; } - const vector unsigned char plus = - VECUINT8_LITERAL (0x00, 0x00, 0x00, 0x00, - 0x04, 0x04, 0x04, 0x04, - 0x08, 0x08, 0x08, 0x08, - 0x0C, 0x0C, 0x0C, 0x0C); + const vector unsigned char plus = VECUINT8_LITERAL(0x00, 0x00, 0x00, 0x00, + 0x04, 0x04, 0x04, 0x04, + 0x08, 0x08, 0x08, 0x08, + 0x0C, 0x0C, 0x0C, + 0x0C); vector unsigned char vswiz; vector unsigned int srcvec; #define RESHIFT(X) (3 - ((X) >> 3)) - Uint32 rmask = RESHIFT (srcfmt->Rshift) << (dstfmt->Rshift); - Uint32 gmask = RESHIFT (srcfmt->Gshift) << (dstfmt->Gshift); - Uint32 bmask = RESHIFT (srcfmt->Bshift) << (dstfmt->Bshift); + Uint32 rmask = RESHIFT(srcfmt->Rshift) << (dstfmt->Rshift); + Uint32 gmask = RESHIFT(srcfmt->Gshift) << (dstfmt->Gshift); + Uint32 bmask = RESHIFT(srcfmt->Bshift) << (dstfmt->Bshift); Uint32 amask; /* Use zero for alpha if either surface doesn't have alpha */ if (dstfmt->Amask) { amask = - ((srcfmt->Amask) ? RESHIFT (srcfmt->Ashift) : 0x10) << (dstfmt-> - Ashift); + ((srcfmt->Amask) ? RESHIFT(srcfmt->Ashift) : 0x10) << (dstfmt-> + Ashift); } else { amask = 0x10101010 & ((dstfmt->Rmask | dstfmt->Gmask | dstfmt->Bmask) ^ @@ -151,13 +150,13 @@ } #undef RESHIFT ((unsigned int *) (char *) &srcvec)[0] = (rmask | gmask | bmask | amask); - vswiz = vec_add (plus, (vector unsigned char) vec_splat (srcvec, 0)); + vswiz = vec_add(plus, (vector unsigned char) vec_splat(srcvec, 0)); return (vswiz); } -static void Blit_RGB888_RGB565 (SDL_BlitInfo * info); +static void Blit_RGB888_RGB565(SDL_BlitInfo * info); static void -Blit_RGB888_RGB565Altivec (SDL_BlitInfo * info) +Blit_RGB888_RGB565Altivec(SDL_BlitInfo * info) { int height = info->d_height; Uint8 *src = (Uint8 *) info->s_pixels; @@ -165,22 +164,22 @@ Uint8 *dst = (Uint8 *) info->d_pixels; int dstskip = info->d_skip; SDL_PixelFormat *srcfmt = info->src; - vector unsigned char valpha = vec_splat_u8 (0); - vector unsigned char vpermute = calc_swizzle32 (srcfmt, NULL); - vector unsigned char vgmerge = VECUINT8_LITERAL (0x00, 0x02, 0x00, 0x06, - 0x00, 0x0a, 0x00, 0x0e, - 0x00, 0x12, 0x00, 0x16, - 0x00, 0x1a, 0x00, 0x1e); - vector unsigned short v1 = vec_splat_u16 (1); - vector unsigned short v3 = vec_splat_u16 (3); + vector unsigned char valpha = vec_splat_u8(0); + vector unsigned char vpermute = calc_swizzle32(srcfmt, NULL); + vector unsigned char vgmerge = VECUINT8_LITERAL(0x00, 0x02, 0x00, 0x06, + 0x00, 0x0a, 0x00, 0x0e, + 0x00, 0x12, 0x00, 0x16, + 0x00, 0x1a, 0x00, 0x1e); + vector unsigned short v1 = vec_splat_u16(1); + vector unsigned short v3 = vec_splat_u16(3); vector unsigned short v3f = - VECUINT16_LITERAL (0x003f, 0x003f, 0x003f, 0x003f, - 0x003f, 0x003f, 0x003f, 0x003f); + VECUINT16_LITERAL(0x003f, 0x003f, 0x003f, 0x003f, + 0x003f, 0x003f, 0x003f, 0x003f); vector unsigned short vfc = - VECUINT16_LITERAL (0x00fc, 0x00fc, 0x00fc, 0x00fc, - 0x00fc, 0x00fc, 0x00fc, 0x00fc); - vector unsigned short vf800 = (vector unsigned short) vec_splat_u8 (-7); - vf800 = vec_sl (vf800, vec_splat_u16 (8)); + VECUINT16_LITERAL(0x00fc, 0x00fc, 0x00fc, 0x00fc, + 0x00fc, 0x00fc, 0x00fc, 0x00fc); + vector unsigned short vf800 = (vector unsigned short) vec_splat_u8(-7); + vf800 = vec_sl(vf800, vec_splat_u16(8)); while (height--) { vector unsigned char valigner; @@ -205,42 +204,41 @@ widthvar--; \ } - ONE_PIXEL_BLEND (((UNALIGNED_PTR (dst)) && (width)), width); + ONE_PIXEL_BLEND(((UNALIGNED_PTR(dst)) && (width)), width); /* After all that work, here's the vector part! */ extrawidth = (width % 8); /* trailing unaligned stores */ width -= extrawidth; - vsrc = vec_ld (0, src); - valigner = VEC_ALIGNER (src); + vsrc = vec_ld(0, src); + valigner = VEC_ALIGNER(src); while (width) { vector unsigned short vpixel, vrpixel, vgpixel, vbpixel; vector unsigned int vsrc1, vsrc2; vector unsigned char vdst; - voverflow = vec_ld (15, src); - vsrc = vec_perm (vsrc, voverflow, valigner); - vsrc1 = (vector unsigned int) vec_perm (vsrc, valpha, vpermute); + voverflow = vec_ld(15, src); + vsrc = vec_perm(vsrc, voverflow, valigner); + vsrc1 = (vector unsigned int) vec_perm(vsrc, valpha, vpermute); src += 16; vsrc = voverflow; - voverflow = vec_ld (15, src); - vsrc = vec_perm (vsrc, voverflow, valigner); - vsrc2 = (vector unsigned int) vec_perm (vsrc, valpha, vpermute); + voverflow = vec_ld(15, src); + vsrc = vec_perm(vsrc, voverflow, valigner); + vsrc2 = (vector unsigned int) vec_perm(vsrc, valpha, vpermute); /* 1555 */ - vpixel = (vector unsigned short) vec_packpx (vsrc1, vsrc2); - vgpixel = - (vector unsigned short) vec_perm (vsrc1, vsrc2, vgmerge); - vgpixel = vec_and (vgpixel, vfc); - vgpixel = vec_sl (vgpixel, v3); - vrpixel = vec_sl (vpixel, v1); - vrpixel = vec_and (vrpixel, vf800); - vbpixel = vec_and (vpixel, v3f); + vpixel = (vector unsigned short) vec_packpx(vsrc1, vsrc2); + vgpixel = (vector unsigned short) vec_perm(vsrc1, vsrc2, vgmerge); + vgpixel = vec_and(vgpixel, vfc); + vgpixel = vec_sl(vgpixel, v3); + vrpixel = vec_sl(vpixel, v1); + vrpixel = vec_and(vrpixel, vf800); + vbpixel = vec_and(vpixel, v3f); vdst = - vec_or ((vector unsigned char) vrpixel, - (vector unsigned char) vgpixel); + vec_or((vector unsigned char) vrpixel, + (vector unsigned char) vgpixel); /* 565 */ - vdst = vec_or (vdst, (vector unsigned char) vbpixel); - vec_st (vdst, 0, dst); + vdst = vec_or(vdst, (vector unsigned char) vbpixel); + vec_st(vdst, 0, dst); width -= 8; src += 16; @@ -248,10 +246,10 @@ vsrc = voverflow; } - assert (width == 0); + assert(width == 0); /* do scalar until we can align... */ - ONE_PIXEL_BLEND ((extrawidth), extrawidth); + ONE_PIXEL_BLEND((extrawidth), extrawidth); #undef ONE_PIXEL_BLEND src += srcskip; /* move to next row, accounting for pitch. */ @@ -262,7 +260,7 @@ } static void -Blit_RGB565_32Altivec (SDL_BlitInfo * info) +Blit_RGB565_32Altivec(SDL_BlitInfo * info) { int height = info->d_height; Uint8 *src = (Uint8 *) info->s_pixels; @@ -275,64 +273,64 @@ vector unsigned char valpha; vector unsigned char vpermute; vector unsigned short vf800; - vector unsigned int v8 = vec_splat_u32 (8); - vector unsigned int v16 = vec_add (v8, v8); - vector unsigned short v2 = vec_splat_u16 (2); - vector unsigned short v3 = vec_splat_u16 (3); + vector unsigned int v8 = vec_splat_u32(8); + vector unsigned int v16 = vec_add(v8, v8); + vector unsigned short v2 = vec_splat_u16(2); + vector unsigned short v3 = vec_splat_u16(3); /* 0x10 - 0x1f is the alpha 0x00 - 0x0e evens are the red 0x01 - 0x0f odds are zero */ - vector unsigned char vredalpha1 = - VECUINT8_LITERAL (0x10, 0x00, 0x01, 0x01, - 0x10, 0x02, 0x01, 0x01, - 0x10, 0x04, 0x01, 0x01, - 0x10, 0x06, 0x01, 0x01); + vector unsigned char vredalpha1 = VECUINT8_LITERAL(0x10, 0x00, 0x01, 0x01, + 0x10, 0x02, 0x01, 0x01, + 0x10, 0x04, 0x01, 0x01, + 0x10, 0x06, 0x01, + 0x01); vector unsigned char vredalpha2 = (vector unsigned - char) (vec_add ((vector unsigned int) vredalpha1, vec_sl (v8, v16)) + char) (vec_add((vector unsigned int) vredalpha1, vec_sl(v8, v16)) ); /* 0x00 - 0x0f is ARxx ARxx ARxx ARxx 0x11 - 0x0f odds are blue */ - vector unsigned char vblue1 = VECUINT8_LITERAL (0x00, 0x01, 0x02, 0x11, - 0x04, 0x05, 0x06, 0x13, - 0x08, 0x09, 0x0a, 0x15, - 0x0c, 0x0d, 0x0e, 0x17); + vector unsigned char vblue1 = VECUINT8_LITERAL(0x00, 0x01, 0x02, 0x11, + 0x04, 0x05, 0x06, 0x13, + 0x08, 0x09, 0x0a, 0x15, + 0x0c, 0x0d, 0x0e, 0x17); vector unsigned char vblue2 = - (vector unsigned char) (vec_add ((vector unsigned int) vblue1, v8) + (vector unsigned char) (vec_add((vector unsigned int) vblue1, v8) ); /* 0x00 - 0x0f is ARxB ARxB ARxB ARxB 0x10 - 0x0e evens are green */ - vector unsigned char vgreen1 = VECUINT8_LITERAL (0x00, 0x01, 0x10, 0x03, - 0x04, 0x05, 0x12, 0x07, - 0x08, 0x09, 0x14, 0x0b, - 0x0c, 0x0d, 0x16, 0x0f); + vector unsigned char vgreen1 = VECUINT8_LITERAL(0x00, 0x01, 0x10, 0x03, + 0x04, 0x05, 0x12, 0x07, + 0x08, 0x09, 0x14, 0x0b, + 0x0c, 0x0d, 0x16, 0x0f); vector unsigned char vgreen2 = (vector unsigned - char) (vec_add ((vector unsigned int) vgreen1, vec_sl (v8, v8)) + char) (vec_add((vector unsigned int) vgreen1, vec_sl(v8, v8)) ); - assert (srcfmt->BytesPerPixel == 2); - assert (dstfmt->BytesPerPixel == 4); + assert(srcfmt->BytesPerPixel == 2); + assert(dstfmt->BytesPerPixel == 4); - vf800 = (vector unsigned short) vec_splat_u8 (-7); - vf800 = vec_sl (vf800, vec_splat_u16 (8)); + vf800 = (vector unsigned short) vec_splat_u8(-7); + vf800 = vec_sl(vf800, vec_splat_u16(8)); if (dstfmt->Amask && srcfmt->alpha) { ((unsigned char *) &valpha)[0] = alpha = srcfmt->alpha; - valpha = vec_splat (valpha, 0); + valpha = vec_splat(valpha, 0); } else { alpha = 0; - valpha = vec_splat_u8 (0); + valpha = vec_splat_u8(0); } - vpermute = calc_swizzle32 (NULL, dstfmt); + vpermute = calc_swizzle32(NULL, dstfmt); while (height--) { vector unsigned char valigner; vector unsigned char voverflow; @@ -354,40 +352,40 @@ dst += 4; \ widthvar--; \ } - ONE_PIXEL_BLEND (((UNALIGNED_PTR (dst)) && (width)), width); + ONE_PIXEL_BLEND(((UNALIGNED_PTR(dst)) && (width)), width); /* After all that work, here's the vector part! */ extrawidth = (width % 8); /* trailing unaligned stores */ width -= extrawidth; - vsrc = vec_ld (0, src); - valigner = VEC_ALIGNER (src); + vsrc = vec_ld(0, src); + valigner = VEC_ALIGNER(src); while (width) { vector unsigned short vR, vG, vB; vector unsigned char vdst1, vdst2; - voverflow = vec_ld (15, src); - vsrc = vec_perm (vsrc, voverflow, valigner); + voverflow = vec_ld(15, src); + vsrc = vec_perm(vsrc, voverflow, valigner); - vR = vec_and ((vector unsigned short) vsrc, vf800); - vB = vec_sl ((vector unsigned short) vsrc, v3); - vG = vec_sl (vB, v2); + vR = vec_and((vector unsigned short) vsrc, vf800); + vB = vec_sl((vector unsigned short) vsrc, v3); + vG = vec_sl(vB, v2); vdst1 = - (vector unsigned char) vec_perm ((vector unsigned char) vR, - valpha, vredalpha1); - vdst1 = vec_perm (vdst1, (vector unsigned char) vB, vblue1); - vdst1 = vec_perm (vdst1, (vector unsigned char) vG, vgreen1); - vdst1 = vec_perm (vdst1, valpha, vpermute); - vec_st (vdst1, 0, dst); + (vector unsigned char) vec_perm((vector unsigned char) vR, + valpha, vredalpha1); + vdst1 = vec_perm(vdst1, (vector unsigned char) vB, vblue1); + vdst1 = vec_perm(vdst1, (vector unsigned char) vG, vgreen1); + vdst1 = vec_perm(vdst1, valpha, vpermute); + vec_st(vdst1, 0, dst); vdst2 = - (vector unsigned char) vec_perm ((vector unsigned char) vR, - valpha, vredalpha2); - vdst2 = vec_perm (vdst2, (vector unsigned char) vB, vblue2); - vdst2 = vec_perm (vdst2, (vector unsigned char) vG, vgreen2); - vdst2 = vec_perm (vdst2, valpha, vpermute); - vec_st (vdst2, 16, dst); + (vector unsigned char) vec_perm((vector unsigned char) vR, + valpha, vredalpha2); + vdst2 = vec_perm(vdst2, (vector unsigned char) vB, vblue2); + vdst2 = vec_perm(vdst2, (vector unsigned char) vG, vgreen2); + vdst2 = vec_perm(vdst2, valpha, vpermute); + vec_st(vdst2, 16, dst); width -= 8; dst += 32; @@ -395,11 +393,11 @@ vsrc = voverflow; } - assert (width == 0); + assert(width == 0); /* do scalar until we can align... */ - ONE_PIXEL_BLEND ((extrawidth), extrawidth); + ONE_PIXEL_BLEND((extrawidth), extrawidth); #undef ONE_PIXEL_BLEND src += srcskip; /* move to next row, accounting for pitch. */ @@ -410,7 +408,7 @@ static void -Blit_RGB555_32Altivec (SDL_BlitInfo * info) +Blit_RGB555_32Altivec(SDL_BlitInfo * info) { int height = info->d_height; Uint8 *src = (Uint8 *) info->s_pixels; @@ -423,64 +421,64 @@ vector unsigned char valpha; vector unsigned char vpermute; vector unsigned short vf800; - vector unsigned int v8 = vec_splat_u32 (8); - vector unsigned int v16 = vec_add (v8, v8); - vector unsigned short v1 = vec_splat_u16 (1); - vector unsigned short v3 = vec_splat_u16 (3); + vector unsigned int v8 = vec_splat_u32(8); + vector unsigned int v16 = vec_add(v8, v8); + vector unsigned short v1 = vec_splat_u16(1); + vector unsigned short v3 = vec_splat_u16(3); /* 0x10 - 0x1f is the alpha 0x00 - 0x0e evens are the red 0x01 - 0x0f odds are zero */ - vector unsigned char vredalpha1 = - VECUINT8_LITERAL (0x10, 0x00, 0x01, 0x01, - 0x10, 0x02, 0x01, 0x01, - 0x10, 0x04, 0x01, 0x01, - 0x10, 0x06, 0x01, 0x01); + vector unsigned char vredalpha1 = VECUINT8_LITERAL(0x10, 0x00, 0x01, 0x01, + 0x10, 0x02, 0x01, 0x01, + 0x10, 0x04, 0x01, 0x01, + 0x10, 0x06, 0x01, + 0x01); vector unsigned char vredalpha2 = (vector unsigned - char) (vec_add ((vector unsigned int) vredalpha1, vec_sl (v8, v16)) + char) (vec_add((vector unsigned int) vredalpha1, vec_sl(v8, v16)) ); /* 0x00 - 0x0f is ARxx ARxx ARxx ARxx 0x11 - 0x0f odds are blue */ - vector unsigned char vblue1 = VECUINT8_LITERAL (0x00, 0x01, 0x02, 0x11, - 0x04, 0x05, 0x06, 0x13, - 0x08, 0x09, 0x0a, 0x15, - 0x0c, 0x0d, 0x0e, 0x17); + vector unsigned char vblue1 = VECUINT8_LITERAL(0x00, 0x01, 0x02, 0x11, + 0x04, 0x05, 0x06, 0x13, + 0x08, 0x09, 0x0a, 0x15, + 0x0c, 0x0d, 0x0e, 0x17); vector unsigned char vblue2 = - (vector unsigned char) (vec_add ((vector unsigned int) vblue1, v8) + (vector unsigned char) (vec_add((vector unsigned int) vblue1, v8) ); /* 0x00 - 0x0f is ARxB ARxB ARxB ARxB 0x10 - 0x0e evens are green */ - vector unsigned char vgreen1 = VECUINT8_LITERAL (0x00, 0x01, 0x10, 0x03, - 0x04, 0x05, 0x12, 0x07, - 0x08, 0x09, 0x14, 0x0b, - 0x0c, 0x0d, 0x16, 0x0f); + vector unsigned char vgreen1 = VECUINT8_LITERAL(0x00, 0x01, 0x10, 0x03, + 0x04, 0x05, 0x12, 0x07, + 0x08, 0x09, 0x14, 0x0b, + 0x0c, 0x0d, 0x16, 0x0f); vector unsigned char vgreen2 = (vector unsigned - char) (vec_add ((vector unsigned int) vgreen1, vec_sl (v8, v8)) + char) (vec_add((vector unsigned int) vgreen1, vec_sl(v8, v8)) ); - assert (srcfmt->BytesPerPixel == 2); - assert (dstfmt->BytesPerPixel == 4); + assert(srcfmt->BytesPerPixel == 2); + assert(dstfmt->BytesPerPixel == 4); - vf800 = (vector unsigned short) vec_splat_u8 (-7); - vf800 = vec_sl (vf800, vec_splat_u16 (8)); + vf800 = (vector unsigned short) vec_splat_u8(-7); + vf800 = vec_sl(vf800, vec_splat_u16(8)); if (dstfmt->Amask && srcfmt->alpha) { ((unsigned char *) &valpha)[0] = alpha = srcfmt->alpha; - valpha = vec_splat (valpha, 0); + valpha = vec_splat(valpha, 0); } else { alpha = 0; - valpha = vec_splat_u8 (0); + valpha = vec_splat_u8(0); } - vpermute = calc_swizzle32 (NULL, dstfmt); + vpermute = calc_swizzle32(NULL, dstfmt); while (height--) { vector unsigned char valigner; vector unsigned char voverflow; @@ -502,40 +500,40 @@ dst += 4; \ widthvar--; \ } - ONE_PIXEL_BLEND (((UNALIGNED_PTR (dst)) && (width)), width); + ONE_PIXEL_BLEND(((UNALIGNED_PTR(dst)) && (width)), width); /* After all that work, here's the vector part! */ extrawidth = (width % 8); /* trailing unaligned stores */ width -= extrawidth; - vsrc = vec_ld (0, src); - valigner = VEC_ALIGNER (src); + vsrc = vec_ld(0, src); + valigner = VEC_ALIGNER(src); while (width) { vector unsigned short vR, vG, vB; vector unsigned char vdst1, vdst2; - voverflow = vec_ld (15, src); - vsrc = vec_perm (vsrc, voverflow, valigner); + voverflow = vec_ld(15, src); + vsrc = vec_perm(vsrc, voverflow, valigner); - vR = vec_and (vec_sl ((vector unsigned short) vsrc, v1), vf800); - vB = vec_sl ((vector unsigned short) vsrc, v3); - vG = vec_sl (vB, v3); + vR = vec_and(vec_sl((vector unsigned short) vsrc, v1), vf800); + vB = vec_sl((vector unsigned short) vsrc, v3); + vG = vec_sl(vB, v3); vdst1 = - (vector unsigned char) vec_perm ((vector unsigned char) vR, - valpha, vredalpha1); - vdst1 = vec_perm (vdst1, (vector unsigned char) vB, vblue1); - vdst1 = vec_perm (vdst1, (vector unsigned char) vG, vgreen1); - vdst1 = vec_perm (vdst1, valpha, vpermute); - vec_st (vdst1, 0, dst); + (vector unsigned char) vec_perm((vector unsigned char) vR, + valpha, vredalpha1); + vdst1 = vec_perm(vdst1, (vector unsigned char) vB, vblue1); + vdst1 = vec_perm(vdst1, (vector unsigned char) vG, vgreen1); + vdst1 = vec_perm(vdst1, valpha, vpermute); + vec_st(vdst1, 0, dst); vdst2 = - (vector unsigned char) vec_perm ((vector unsigned char) vR, - valpha, vredalpha2); - vdst2 = vec_perm (vdst2, (vector unsigned char) vB, vblue2); - vdst2 = vec_perm (vdst2, (vector unsigned char) vG, vgreen2); - vdst2 = vec_perm (vdst2, valpha, vpermute); - vec_st (vdst2, 16, dst); + (vector unsigned char) vec_perm((vector unsigned char) vR, + valpha, vredalpha2); + vdst2 = vec_perm(vdst2, (vector unsigned char) vB, vblue2); + vdst2 = vec_perm(vdst2, (vector unsigned char) vG, vgreen2); + vdst2 = vec_perm(vdst2, valpha, vpermute); + vec_st(vdst2, 16, dst); width -= 8; dst += 32; @@ -543,11 +541,11 @@ vsrc = voverflow; } - assert (width == 0); + assert(width == 0); /* do scalar until we can align... */ - ONE_PIXEL_BLEND ((extrawidth), extrawidth); + ONE_PIXEL_BLEND((extrawidth), extrawidth); #undef ONE_PIXEL_BLEND src += srcskip; /* move to next row, accounting for pitch. */ @@ -556,10 +554,10 @@ } -static void BlitNtoNKey (SDL_BlitInfo * info); -static void BlitNtoNKeyCopyAlpha (SDL_BlitInfo * info); +static void BlitNtoNKey(SDL_BlitInfo * info); +static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info); static void -Blit32to32KeyAltivec (SDL_BlitInfo * info) +Blit32to32KeyAltivec(SDL_BlitInfo * info) { int height = info->d_height; Uint32 *srcp = (Uint32 *) info->s_pixels; @@ -579,29 +577,28 @@ vector unsigned char vzero; vector unsigned int vckey; vector unsigned int vrgbmask; - vpermute = calc_swizzle32 (srcfmt, dstfmt); + vpermute = calc_swizzle32(srcfmt, dstfmt); if (info->d_width < 16) { if (copy_alpha) { - BlitNtoNKeyCopyAlpha (info); + BlitNtoNKeyCopyAlpha(info); } else { - BlitNtoNKey (info); + BlitNtoNKey(info); } return; } - vzero = vec_splat_u8 (0); + vzero = vec_splat_u8(0); if (alpha) { ((unsigned char *) &valpha)[0] = (unsigned char) alpha; valpha = - (vector unsigned int) vec_splat ((vector unsigned char) valpha, - 0); + (vector unsigned int) vec_splat((vector unsigned char) valpha, 0); } else { valpha = (vector unsigned int) vzero; } ckey &= rgbmask; ((unsigned int *) (char *) &vckey)[0] = ckey; - vckey = vec_splat (vckey, 0); + vckey = vec_splat(vckey, 0); ((unsigned int *) (char *) &vrgbmask)[0] = rgbmask; - vrgbmask = vec_splat (vrgbmask, 0); + vrgbmask = vec_splat(vrgbmask, 0); while (height--) { #define ONE_PIXEL_BLEND(condition, widthvar) \ @@ -635,39 +632,39 @@ } \ } int width = info->d_width; - ONE_PIXEL_BLEND ((UNALIGNED_PTR (dstp)) && (width), width); - assert (width > 0); + ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width); + assert(width > 0); if (width > 0) { int extrawidth = (width % 4); - vector unsigned char valigner = VEC_ALIGNER (srcp); - vector unsigned int vs = vec_ld (0, srcp); + vector unsigned char valigner = VEC_ALIGNER(srcp); + vector unsigned int vs = vec_ld(0, srcp); width -= extrawidth; - assert (width >= 4); + assert(width >= 4); while (width) { vector unsigned char vsel; vector unsigned int vd; - vector unsigned int voverflow = vec_ld (15, srcp); + vector unsigned int voverflow = vec_ld(15, srcp); /* load the source vec */ - vs = vec_perm (vs, voverflow, valigner); + vs = vec_perm(vs, voverflow, valigner); /* vsel is set for items that match the key */ - vsel = (vector unsigned char) vec_and (vs, vrgbmask); - vsel = (vector unsigned char) vec_cmpeq (vs, vckey); + vsel = (vector unsigned char) vec_and(vs, vrgbmask); + vsel = (vector unsigned char) vec_cmpeq(vs, vckey); /* permute the src vec to the dest format */ - vs = vec_perm (vs, valpha, vpermute); + vs = vec_perm(vs, valpha, vpermute); /* load the destination vec */ - vd = vec_ld (0, dstp); + vd = vec_ld(0, dstp); /* select the source and dest into vs */ - vd = (vector unsigned int) vec_sel ((vector unsigned char) vs, - (vector unsigned char) vd, - vsel); + vd = (vector unsigned int) vec_sel((vector unsigned char) vs, + (vector unsigned char) vd, + vsel); - vec_st (vd, 0, dstp); + vec_st(vd, 0, dstp); srcp += 4; width -= 4; dstp += 4; vs = voverflow; } - ONE_PIXEL_BLEND ((extrawidth), extrawidth); + ONE_PIXEL_BLEND((extrawidth), extrawidth); #undef ONE_PIXEL_BLEND srcp += srcskip >> 2; dstp += dstskip >> 2; @@ -678,7 +675,7 @@ /* Altivec code to swizzle one 32-bit surface to a different 32-bit format. */ /* Use this on a G5 */ static void -ConvertAltivec32to32_noprefetch (SDL_BlitInfo * info) +ConvertAltivec32to32_noprefetch(SDL_BlitInfo * info) { int height = info->d_height; Uint32 *src = (Uint32 *) info->s_pixels; @@ -687,18 +684,18 @@ int dstskip = info->d_skip; SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *dstfmt = info->dst; - vector unsigned int vzero = vec_splat_u32 (0); - vector unsigned char vpermute = calc_swizzle32 (srcfmt, dstfmt); + vector unsigned int vzero = vec_splat_u32(0); + vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt); if (dstfmt->Amask && !srcfmt->Amask) { if (srcfmt->alpha) { vector unsigned char valpha; ((unsigned char *) &valpha)[0] = srcfmt->alpha; - vzero = (vector unsigned int) vec_splat (valpha, 0); + vzero = (vector unsigned int) vec_splat(valpha, 0); } } - assert (srcfmt->BytesPerPixel == 4); - assert (dstfmt->BytesPerPixel == 4); + assert(srcfmt->BytesPerPixel == 4); + assert(dstfmt->BytesPerPixel == 4); while (height--) { vector unsigned char valigner; @@ -711,37 +708,37 @@ int extrawidth; /* do scalar until we can align... */ - while ((UNALIGNED_PTR (dst)) && (width)) { + while ((UNALIGNED_PTR(dst)) && (width)) { bits = *(src++); - RGBA_FROM_8888 (bits, srcfmt, r, g, b, a); - *(dst++) = MAKE8888 (dstfmt, r, g, b, a); + RGBA_FROM_8888(bits, srcfmt, r, g, b, a); + *(dst++) = MAKE8888(dstfmt, r, g, b, a); width--; } /* After all that work, here's the vector part! */ extrawidth = (width % 4); width -= extrawidth; - valigner = VEC_ALIGNER (src); - vbits = vec_ld (0, src); + valigner = VEC_ALIGNER(src); + vbits = vec_ld(0, src); while (width) { - voverflow = vec_ld (15, src); + voverflow = vec_ld(15, src); src += 4; width -= 4; - vbits = vec_perm (vbits, voverflow, valigner); /* src is ready. */ - vbits = vec_perm (vbits, vzero, vpermute); /* swizzle it. */ - vec_st (vbits, 0, dst); /* store it back out. */ + vbits = vec_perm(vbits, voverflow, valigner); /* src is ready. */ + vbits = vec_perm(vbits, vzero, vpermute); /* swizzle it. */ + vec_st(vbits, 0, dst); /* store it back out. */ dst += 4; vbits = voverflow; } - assert (width == 0); + assert(width == 0); /* cover pixels at the end of the row that didn't fit in 16 bytes. */ while (extrawidth) { bits = *(src++); /* max 7 pixels, don't bother with prefetch. */ - RGBA_FROM_8888 (bits, srcfmt, r, g, b, a); - *(dst++) = MAKE8888 (dstfmt, r, g, b, a); + RGBA_FROM_8888(bits, srcfmt, r, g, b, a); + *(dst++) = MAKE8888(dstfmt, r, g, b, a); extrawidth--; } @@ -754,10 +751,10 @@ /* Altivec code to swizzle one 32-bit surface to a different 32-bit format. */ /* Use this on a G4 */ static void -ConvertAltivec32to32_prefetch (SDL_BlitInfo * info) +ConvertAltivec32to32_prefetch(SDL_BlitInfo * info) { - const int scalar_dst_lead = sizeof (Uint32) * 4; - const int vector_dst_lead = sizeof (Uint32) * 16; + const int scalar_dst_lead = sizeof(Uint32) * 4; + const int vector_dst_lead = sizeof(Uint32) * 16; int height = info->d_height; Uint32 *src = (Uint32 *) info->s_pixels; @@ -766,18 +763,18 @@ int dstskip = info->d_skip; SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *dstfmt = info->dst; - vector unsigned int vzero = vec_splat_u32 (0); - vector unsigned char vpermute = calc_swizzle32 (srcfmt, dstfmt); + vector unsigned int vzero = vec_splat_u32(0); + vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt); if (dstfmt->Amask && !srcfmt->Amask) { if (srcfmt->alpha) { vector unsigned char valpha; ((unsigned char *) &valpha)[0] = srcfmt->alpha; - vzero = (vector unsigned int) vec_splat (valpha, 0); + vzero = (vector unsigned int) vec_splat(valpha, 0); } } - assert (srcfmt->BytesPerPixel == 4); - assert (dstfmt->BytesPerPixel == 4); + assert(srcfmt->BytesPerPixel == 4); + assert(dstfmt->BytesPerPixel == 4); while (height--) { vector unsigned char valigner; @@ -790,45 +787,45 @@ int extrawidth; /* do scalar until we can align... */ - while ((UNALIGNED_PTR (dst)) && (width)) { - vec_dstt (src + scalar_dst_lead, DST_CTRL (2, 32, 1024), - DST_CHAN_SRC); - vec_dstst (dst + scalar_dst_lead, DST_CTRL (2, 32, 1024), - DST_CHAN_DEST); + while ((UNALIGNED_PTR(dst)) && (width)) { + vec_dstt(src + scalar_dst_lead, DST_CTRL(2, 32, 1024), + DST_CHAN_SRC); + vec_dstst(dst + scalar_dst_lead, DST_CTRL(2, 32, 1024), + DST_CHAN_DEST); bits = *(src++); - RGBA_FROM_8888 (bits, srcfmt, r, g, b, a); - *(dst++) = MAKE8888 (dstfmt, r, g, b, a); + RGBA_FROM_8888(bits, srcfmt, r, g, b, a); + *(dst++) = MAKE8888(dstfmt, r, g, b, a); width--; } /* After all that work, here's the vector part! */ extrawidth = (width % 4); width -= extrawidth; - valigner = VEC_ALIGNER (src); - vbits = vec_ld (0, src); + valigner = VEC_ALIGNER(src); + vbits = vec_ld(0, src); while (width) { - vec_dstt (src + vector_dst_lead, DST_CTRL (2, 32, 1024), - DST_CHAN_SRC); - vec_dstst (dst + vector_dst_lead, DST_CTRL (2, 32, 1024), - DST_CHAN_DEST); - voverflow = vec_ld (15, src); + vec_dstt(src + vector_dst_lead, DST_CTRL(2, 32, 1024), + DST_CHAN_SRC); + vec_dstst(dst + vector_dst_lead, DST_CTRL(2, 32, 1024), + DST_CHAN_DEST); + voverflow = vec_ld(15, src); src += 4; width -= 4; - vbits = vec_perm (vbits, voverflow, valigner); /* src is ready. */ - vbits = vec_perm (vbits, vzero, vpermute); /* swizzle it. */ - vec_st (vbits, 0, dst); /* store it back out. */ + vbits = vec_perm(vbits, voverflow, valigner); /* src is ready. */ + vbits = vec_perm(vbits, vzero, vpermute); /* swizzle it. */ + vec_st(vbits, 0, dst); /* store it back out. */ dst += 4; vbits = voverflow; } - assert (width == 0); + assert(width == 0); /* cover pixels at the end of the row that didn't fit in 16 bytes. */ while (extrawidth) { bits = *(src++); /* max 7 pixels, don't bother with prefetch. */ - RGBA_FROM_8888 (bits, srcfmt, r, g, b, a); - *(dst++) = MAKE8888 (dstfmt, r, g, b, a); + RGBA_FROM_8888(bits, srcfmt, r, g, b, a); + *(dst++) = MAKE8888(dstfmt, r, g, b, a); extrawidth--; } @@ -836,29 +833,29 @@ dst += dstskip >> 2; } - vec_dss (DST_CHAN_SRC); - vec_dss (DST_CHAN_DEST); + vec_dss(DST_CHAN_SRC); + vec_dss(DST_CHAN_DEST); } static Uint32 -GetBlitFeatures (void) +GetBlitFeatures(void) { static Uint32 features = 0xffffffff; if (features == 0xffffffff) { /* Provide an override for testing .. */ - char *override = SDL_getenv ("SDL_ALTIVEC_BLIT_FEATURES"); + char *override = SDL_getenv("SDL_ALTIVEC_BLIT_FEATURES"); if (override) { features = 0; - SDL_sscanf (override, "%u", &features); + SDL_sscanf(override, "%u", &features); } else { features = (0 /* Feature 1 is has-MMX */ - | ((SDL_HasMMX ())? 1 : 0) + | ((SDL_HasMMX())? 1 : 0) /* Feature 2 is has-AltiVec */ - | ((SDL_HasAltiVec ())? 2 : 0) + | ((SDL_HasAltiVec())? 2 : 0) /* Feature 4 is dont-use-prefetch */ /* !!!! FIXME: Check for G5 or later, not the cache size! Always prefetch on a G4. */ - | ((GetL3CacheSize () == 0) ? 4 : 0) + | ((GetL3CacheSize() == 0) ? 4 : 0) ); } } @@ -902,7 +899,7 @@ (((src)&0x000000C0)>>6)); \ } static void -Blit_RGB888_index8 (SDL_BlitInfo * info) +Blit_RGB888_index8(SDL_BlitInfo * info) { #ifndef USE_DUFFS_LOOP int c; @@ -934,22 +931,22 @@ for (c = width / 4; c; --c) { /* Pack RGB into 8bit pixel */ ++src; - RGB888_RGB332 (*dst++, *src); + RGB888_RGB332(*dst++, *src); ++src; - RGB888_RGB332 (*dst++, *src); + RGB888_RGB332(*dst++, *src); ++src; - RGB888_RGB332 (*dst++, *src); + RGB888_RGB332(*dst++, *src); ++src; } switch (width & 3) { case 3: - RGB888_RGB332 (*dst++, *src); + RGB888_RGB332(*dst++, *src); ++src; case 2: - RGB888_RGB332 (*dst++, *src); + RGB888_RGB332(*dst++, *src); ++src; case 1: - RGB888_RGB332 (*dst++, *src); + RGB888_RGB332(*dst++, *src); ++src; } #endif /* USE_DUFFS_LOOP */ @@ -971,30 +968,30 @@ #else for (c = width / 4; c; --c) { /* Pack RGB into 8bit pixel */ - RGB888_RGB332 (Pixel, *src); + RGB888_RGB332(Pixel, *src); *dst++ = map[Pixel]; ++src; - RGB888_RGB332 (Pixel, *src); + RGB888_RGB332(Pixel, *src); *dst++ = map[Pixel]; ++src; - RGB888_RGB332 (Pixel, *src); + RGB888_RGB332(Pixel, *src); *dst++ = map[Pixel]; ++src; - RGB888_RGB332 (Pixel, *src); + RGB888_RGB332(Pixel, *src); *dst++ = map[Pixel]; ++src; } switch (width & 3) { case 3: - RGB888_RGB332 (Pixel, *src); + RGB888_RGB332(Pixel, *src); *dst++ = map[Pixel]; ++src; case 2: - RGB888_RGB332 (Pixel, *src); + RGB888_RGB332(Pixel, *src); *dst++ = map[Pixel]; ++src; case 1: - RGB888_RGB332 (Pixel, *src); + RGB888_RGB332(Pixel, *src); *dst++ = map[Pixel]; ++src; } @@ -1020,7 +1017,7 @@ (((src[LO])&0x000000F8)>>3); \ } static void -Blit_RGB888_RGB555 (SDL_BlitInfo * info) +Blit_RGB888_RGB555(SDL_BlitInfo * info) { #ifndef USE_DUFFS_LOOP int c; @@ -1061,32 +1058,32 @@ while (height--) { /* Perform copy alignment */ - RGB888_RGB555 (dst, src); + RGB888_RGB555(dst, src); ++src; ++dst; /* Copy in 4 pixel chunks */ for (c = width / 4; c; --c) { - RGB888_RGB555_TWO (dst, src); + RGB888_RGB555_TWO(dst, src); src += 2; dst += 2; - RGB888_RGB555_TWO (dst, src); + RGB888_RGB555_TWO(dst, src); src += 2; dst += 2; } /* Get any leftovers */ switch (width & 3) { case 3: - RGB888_RGB555 (dst, src); + RGB888_RGB555(dst, src); ++src; ++dst; case 2: - RGB888_RGB555_TWO (dst, src); + RGB888_RGB555_TWO(dst, src); src += 2; dst += 2; break; case 1: - RGB888_RGB555 (dst, src); + RGB888_RGB555(dst, src); ++src; ++dst; break; @@ -1098,26 +1095,26 @@ while (height--) { /* Copy in 4 pixel chunks */ for (c = width / 4; c; --c) { - RGB888_RGB555_TWO (dst, src); + RGB888_RGB555_TWO(dst, src); src += 2; dst += 2; - RGB888_RGB555_TWO (dst, src); + RGB888_RGB555_TWO(dst, src); src += 2; dst += 2; } /* Get any leftovers */ switch (width & 3) { case 3: - RGB888_RGB555 (dst, src); + RGB888_RGB555(dst, src); ++src; ++dst; case 2: - RGB888_RGB555_TWO (dst, src); + RGB888_RGB555_TWO(dst, src); src += 2; dst += 2; break; case 1: - RGB888_RGB555 (dst, src); + RGB888_RGB555(dst, src); ++src; ++dst; break; @@ -1144,7 +1141,7 @@ (((src[LO])&0x000000F8)>>3); \ } static void -Blit_RGB888_RGB565 (SDL_BlitInfo * info) +Blit_RGB888_RGB565(SDL_BlitInfo * info) { #ifndef USE_DUFFS_LOOP int c; @@ -1185,32 +1182,32 @@ while (height--) { /* Perform copy alignment */ - RGB888_RGB565 (dst, src); + RGB888_RGB565(dst, src); ++src; ++dst; /* Copy in 4 pixel chunks */ for (c = width / 4; c; --c) { - RGB888_RGB565_TWO (dst, src); + RGB888_RGB565_TWO(dst, src); src += 2; dst += 2; - RGB888_RGB565_TWO (dst, src); + RGB888_RGB565_TWO(dst, src); src += 2; dst += 2; } /* Get any leftovers */ switch (width & 3) { case 3: - RGB888_RGB565 (dst, src); + RGB888_RGB565(dst, src); ++src; ++dst; case 2: - RGB888_RGB565_TWO (dst, src); + RGB888_RGB565_TWO(dst, src); src += 2; dst += 2; break; case 1: - RGB888_RGB565 (dst, src); + RGB888_RGB565(dst, src); ++src; ++dst; break; @@ -1222,26 +1219,26 @@ while (height--) { /* Copy in 4 pixel chunks */ for (c = width / 4; c; --c) { - RGB888_RGB565_TWO (dst, src); + RGB888_RGB565_TWO(dst, src); src += 2; dst += 2; - RGB888_RGB565_TWO (dst, src); + RGB888_RGB565_TWO(dst, src); src += 2; dst += 2; } /* Get any leftovers */ switch (width & 3) { case 3: - RGB888_RGB565 (dst, src); + RGB888_RGB565(dst, src); ++src; ++dst; case 2: - RGB888_RGB565_TWO (dst, src); + RGB888_RGB565_TWO(dst, src); src += 2; dst += 2; break; case 1: - RGB888_RGB565 (dst, src); + RGB888_RGB565(dst, src); ++src; ++dst; break; @@ -1259,7 +1256,7 @@ /* Special optimized blit for RGB 5-6-5 --> 32-bit RGB surfaces */ #define RGB565_32(dst, src, map) (map[src[LO]*2] + map[src[HI]*2+1]) static void -Blit_RGB565_32 (SDL_BlitInfo * info, const Uint32 * map) +Blit_RGB565_32(SDL_BlitInfo * info, const Uint32 * map) { #ifndef USE_DUFFS_LOOP int c; @@ -1294,25 +1291,25 @@ while (height--) { /* Copy in 4 pixel chunks */ for (c = width / 4; c; --c) { - *dst++ = RGB565_32 (dst, src, map); + *dst++ = RGB565_32(dst, src, map); src += 2; - *dst++ = RGB565_32 (dst, src, map); + *dst++ = RGB565_32(dst, src, map); src += 2; - *dst++ = RGB565_32 (dst, src, map); + *dst++ = RGB565_32(dst, src, map); src += 2; - *dst++ = RGB565_32 (dst, src, map); + *dst++ = RGB565_32(dst, src, map); src += 2; } /* Get any leftovers */ switch (width & 3) { case 3: - *dst++ = RGB565_32 (dst, src, map); + *dst++ = RGB565_32(dst, src, map); src += 2; case 2: - *dst++ = RGB565_32 (dst, src, map); + *dst++ = RGB565_32(dst, src, map); src += 2; case 1: - *dst++ = RGB565_32 (dst, src, map); + *dst++ = RGB565_32(dst, src, map); src += 2; break; } @@ -1454,9 +1451,9 @@ 0x00001cf6, 0xffffc200, 0x00001cff, 0xffffe200 }; static void -Blit_RGB565_ARGB8888 (SDL_BlitInfo * info) +Blit_RGB565_ARGB8888(SDL_BlitInfo * info) { - Blit_RGB565_32 (info, RGB565_ARGB8888_LUT); + Blit_RGB565_32(info, RGB565_ARGB8888_LUT); } /* Special optimized blit for RGB 5-6-5 --> ABGR 8-8-8-8 */ @@ -1591,9 +1588,9 @@ 0xfff61c00, 0x0000c2ff, 0xffff1c00, 0x0000e2ff }; static void -Blit_RGB565_ABGR8888 (SDL_BlitInfo * info) +Blit_RGB565_ABGR8888(SDL_BlitInfo * info) { - Blit_RGB565_32 (info, RGB565_ABGR8888_LUT); + Blit_RGB565_32(info, RGB565_ABGR8888_LUT); } /* Special optimized blit for RGB 5-6-5 --> RGBA 8-8-8-8 */ @@ -1728,9 +1725,9 @@ 0x001cf6ff, 0xffc20000, 0x001cffff, 0xffe20000, }; static void -Blit_RGB565_RGBA8888 (SDL_BlitInfo * info) +Blit_RGB565_RGBA8888(SDL_BlitInfo * info) { - Blit_RGB565_32 (info, RGB565_RGBA8888_LUT); + Blit_RGB565_32(info, RGB565_RGBA8888_LUT); } /* Special optimized blit for RGB 5-6-5 --> BGRA 8-8-8-8 */ @@ -1865,9 +1862,9 @@ 0xf61c0000, 0x00c2ffff, 0xff1c0000, 0x00e2ffff }; static void -Blit_RGB565_BGRA8888 (SDL_BlitInfo * info) +Blit_RGB565_BGRA8888(SDL_BlitInfo * info) { - Blit_RGB565_32 (info, RGB565_BGRA8888_LUT); + Blit_RGB565_32(info, RGB565_BGRA8888_LUT); } /* Special optimized blit for RGB 8-8-8 --> RGB 3-3-2 */ @@ -1879,7 +1876,7 @@ } #endif static void -Blit_RGB888_index8_map (SDL_BlitInfo * info) +Blit_RGB888_index8_map(SDL_BlitInfo * info) { #ifndef USE_DUFFS_LOOP int c; @@ -1916,30 +1913,30 @@ while (height--) { for (c = width / 4; c; --c) { /* Pack RGB into 8bit pixel */ - RGB888_RGB332 (Pixel, *src); + RGB888_RGB332(Pixel, *src); *dst++ = map[Pixel]; ++src; - RGB888_RGB332 (Pixel, *src); + RGB888_RGB332(Pixel, *src); *dst++ = map[Pixel]; ++src; - RGB888_RGB332 (Pixel, *src); + RGB888_RGB332(Pixel, *src); *dst++ = map[Pixel]; ++src; - RGB888_RGB332 (Pixel, *src); + RGB888_RGB332(Pixel, *src); *dst++ = map[Pixel]; ++src; } switch (width & 3) { case 3: - RGB888_RGB332 (Pixel, *src); + RGB888_RGB332(Pixel, *src); *dst++ = map[Pixel]; ++src; case 2: - RGB888_RGB332 (Pixel, *src); + RGB888_RGB332(Pixel, *src); *dst++ = map[Pixel]; ++src; case 1: - RGB888_RGB332 (Pixel, *src); + RGB888_RGB332(Pixel, *src); *dst++ = map[Pixel]; ++src; } @@ -1949,7 +1946,7 @@ #endif /* USE_DUFFS_LOOP */ } static void -BlitNto1 (SDL_BlitInfo * info) +BlitNto1(SDL_BlitInfo * info) { #ifndef USE_DUFFS_LOOP int c; @@ -1994,7 +1991,7 @@ /* *INDENT-ON* */ #else for (c = width; c; --c) { - DISEMBLE_RGB (src, srcbpp, srcfmt, Pixel, sR, sG, sB); + DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); if (1) { /* Pack RGB into 8bit pixel */ *dst = ((sR >> 5) << (3 + 2)) | @@ -2026,7 +2023,7 @@ /* *INDENT-ON* */ #else for (c = width; c; --c) { - DISEMBLE_RGB (src, srcbpp, srcfmt, Pixel, sR, sG, sB); + DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); if (1) { /* Pack RGB into 8bit pixel */ *dst = map[((sR >> 5) << (3 + 2)) | @@ -2044,7 +2041,7 @@ /* blits 32 bit RGB<->RGBA with both surfaces having the same R,G,B fields */ static void -Blit4to4MaskAlpha (SDL_BlitInfo * info) +Blit4to4MaskAlpha(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -2093,7 +2090,7 @@ } static void -BlitNtoN (SDL_BlitInfo * info) +BlitNtoN(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -2128,7 +2125,7 @@ } static void -BlitNtoNCopyAlpha (SDL_BlitInfo * info) +BlitNtoNCopyAlpha(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -2147,8 +2144,8 @@ for (c = width; c; --c) { Uint32 Pixel; unsigned sR, sG, sB, sA; - DISEMBLE_RGBA (src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA); - ASSEMBLE_RGBA (dst, dstbpp, dstfmt, sR, sG, sB, sA); + DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, sA); dst += dstbpp; src += srcbpp; } @@ -2158,7 +2155,7 @@ } static void -BlitNto1Key (SDL_BlitInfo * info) +BlitNto1Key(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -2224,7 +2221,7 @@ } static void -Blit2to2Key (SDL_BlitInfo * info) +Blit2to2Key(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -2258,7 +2255,7 @@ } static void -BlitNtoNKey (SDL_BlitInfo * info) +BlitNtoNKey(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -2302,7 +2299,7 @@ } static void -BlitNtoNKeyCopyAlpha (SDL_BlitInfo * info) +BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info) { int width = info->d_width; int height = info->d_height; @@ -2478,7 +2475,7 @@ #define MASKOK(x, y) (((x) == (y)) || ((y) == 0x00000000)) SDL_loblit -SDL_CalculateBlitN (SDL_Surface * surface, int blit_index) +SDL_CalculateBlitN(SDL_Surface * surface, int blit_index) { struct private_swaccel *sdata; SDL_PixelFormat *srcfmt; @@ -2494,7 +2491,7 @@ if (blit_index & 2) { /* alpha or alpha+colorkey */ - return SDL_CalculateAlphaBlit (surface, blit_index); + return SDL_CalculateAlphaBlit(surface, blit_index); } /* We don't support destinations less than 8-bits */ @@ -2514,7 +2511,7 @@ else { #if SDL_ALTIVEC_BLITTERS if ((srcfmt->BytesPerPixel == 4) && (dstfmt->BytesPerPixel == 4) - && SDL_HasAltiVec ()) { + && SDL_HasAltiVec()) { return Blit32to32KeyAltivec; } else #endif @@ -2552,15 +2549,15 @@ a_need = srcfmt->Amask ? COPY_ALPHA : SET_ALPHA; table = normal_blit[srcfmt->BytesPerPixel - 1]; for (which = 0; table[which].dstbpp; ++which) { - if (MASKOK (srcfmt->Rmask, table[which].srcR) && - MASKOK (srcfmt->Gmask, table[which].srcG) && - MASKOK (srcfmt->Bmask, table[which].srcB) && - MASKOK (dstfmt->Rmask, table[which].dstR) && - MASKOK (dstfmt->Gmask, table[which].dstG) && - MASKOK (dstfmt->Bmask, table[which].dstB) && + if (MASKOK(srcfmt->Rmask, table[which].srcR) && + MASKOK(srcfmt->Gmask, table[which].srcG) && + MASKOK(srcfmt->Bmask, table[which].srcB) && + MASKOK(dstfmt->Rmask, table[which].dstR) && + MASKOK(dstfmt->Gmask, table[which].dstG) && + MASKOK(dstfmt->Bmask, table[which].dstB) && dstfmt->BytesPerPixel == table[which].dstbpp && (a_need & table[which].alpha) == a_need && - ((table[which].blit_features & GetBlitFeatures ()) == + ((table[which].blit_features & GetBlitFeatures()) == table[which].blit_features)) break; } @@ -2583,15 +2580,15 @@ #ifdef DEBUG_ASM #if SDL_HERMES_BLITTERS if (blitfun == ConvertMMX) - fprintf (stderr, "Using mmx blit\n"); + fprintf(stderr, "Using mmx blit\n"); else if (blitfun == ConvertX86) - fprintf (stderr, "Using asm blit\n"); + fprintf(stderr, "Using asm blit\n"); else #endif if ((blitfun == BlitNtoN) || (blitfun == BlitNto1)) - fprintf (stderr, "Using C blit\n"); + fprintf(stderr, "Using C blit\n"); else - fprintf (stderr, "Using optimized C blit\n"); + fprintf(stderr, "Using optimized C blit\n"); #endif /* DEBUG_ASM */ return (blitfun); diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_bmp.c --- a/src/video/SDL_bmp.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_bmp.c Mon May 29 04:04:35 2006 +0000 @@ -46,7 +46,7 @@ SDL_Surface * -SDL_LoadBMP_RW (SDL_RWops * src, int freesrc) +SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) { int was_error; long fp_offset; @@ -89,30 +89,30 @@ } /* Read in the BMP file header */ - fp_offset = SDL_RWtell (src); - SDL_ClearError (); - if (SDL_RWread (src, magic, 1, 2) != 2) { - SDL_Error (SDL_EFREAD); + fp_offset = SDL_RWtell(src); + SDL_ClearError(); + if (SDL_RWread(src, magic, 1, 2) != 2) { + SDL_Error(SDL_EFREAD); was_error = 1; goto done; } - if (SDL_strncmp (magic, "BM", 2) != 0) { - SDL_SetError ("File is not a Windows BMP file"); + if (SDL_strncmp(magic, "BM", 2) != 0) { + SDL_SetError("File is not a Windows BMP file"); was_error = 1; goto done; } - bfSize = SDL_ReadLE32 (src); - bfReserved1 = SDL_ReadLE16 (src); - bfReserved2 = SDL_ReadLE16 (src); - bfOffBits = SDL_ReadLE32 (src); + bfSize = SDL_ReadLE32(src); + bfReserved1 = SDL_ReadLE16(src); + bfReserved2 = SDL_ReadLE16(src); + bfOffBits = SDL_ReadLE32(src); /* Read the Win32 BITMAPINFOHEADER */ - biSize = SDL_ReadLE32 (src); + biSize = SDL_ReadLE32(src); if (biSize == 12) { - biWidth = (Uint32) SDL_ReadLE16 (src); - biHeight = (Uint32) SDL_ReadLE16 (src); - biPlanes = SDL_ReadLE16 (src); - biBitCount = SDL_ReadLE16 (src); + biWidth = (Uint32) SDL_ReadLE16(src); + biHeight = (Uint32) SDL_ReadLE16(src); + biPlanes = SDL_ReadLE16(src); + biBitCount = SDL_ReadLE16(src); biCompression = BI_RGB; biSizeImage = 0; biXPelsPerMeter = 0; @@ -120,20 +120,20 @@ biClrUsed = 0; biClrImportant = 0; } else { - biWidth = SDL_ReadLE32 (src); - biHeight = SDL_ReadLE32 (src); - biPlanes = SDL_ReadLE16 (src); - biBitCount = SDL_ReadLE16 (src); - biCompression = SDL_ReadLE32 (src); - biSizeImage = SDL_ReadLE32 (src); - biXPelsPerMeter = SDL_ReadLE32 (src); - biYPelsPerMeter = SDL_ReadLE32 (src); - biClrUsed = SDL_ReadLE32 (src); - biClrImportant = SDL_ReadLE32 (src); + biWidth = SDL_ReadLE32(src); + biHeight = SDL_ReadLE32(src); + biPlanes = SDL_ReadLE16(src); + biBitCount = SDL_ReadLE16(src); + biCompression = SDL_ReadLE32(src); + biSizeImage = SDL_ReadLE32(src); + biXPelsPerMeter = SDL_ReadLE32(src); + biYPelsPerMeter = SDL_ReadLE32(src); + biClrUsed = SDL_ReadLE32(src); + biClrImportant = SDL_ReadLE32(src); } /* Check for read error */ - if (SDL_strcmp (SDL_GetError (), "") != 0) { + if (SDL_strcmp(SDL_GetError(), "") != 0) { was_error = 1; goto done; } @@ -188,24 +188,24 @@ case 15: case 16: case 32: - Rmask = SDL_ReadLE32 (src); - Gmask = SDL_ReadLE32 (src); - Bmask = SDL_ReadLE32 (src); + Rmask = SDL_ReadLE32(src); + Gmask = SDL_ReadLE32(src); + Bmask = SDL_ReadLE32(src); break; default: break; } break; default: - SDL_SetError ("Compressed BMP files not supported"); + SDL_SetError("Compressed BMP files not supported"); was_error = 1; goto done; } /* Create a compatible surface, note that the colors are RGB ordered */ - surface = SDL_CreateRGBSurface (SDL_SWSURFACE, - biWidth, biHeight, biBitCount, Rmask, - Gmask, Bmask, 0); + surface = SDL_CreateRGBSurface(SDL_SWSURFACE, + biWidth, biHeight, biBitCount, Rmask, + Gmask, Bmask, 0); if (surface == NULL) { was_error = 1; goto done; @@ -219,25 +219,25 @@ } if (biSize == 12) { for (i = 0; i < (int) biClrUsed; ++i) { - SDL_RWread (src, &palette->colors[i].b, 1, 1); - SDL_RWread (src, &palette->colors[i].g, 1, 1); - SDL_RWread (src, &palette->colors[i].r, 1, 1); + SDL_RWread(src, &palette->colors[i].b, 1, 1); + SDL_RWread(src, &palette->colors[i].g, 1, 1); + SDL_RWread(src, &palette->colors[i].r, 1, 1); palette->colors[i].unused = 0; } } else { for (i = 0; i < (int) biClrUsed; ++i) { - SDL_RWread (src, &palette->colors[i].b, 1, 1); - SDL_RWread (src, &palette->colors[i].g, 1, 1); - SDL_RWread (src, &palette->colors[i].r, 1, 1); - SDL_RWread (src, &palette->colors[i].unused, 1, 1); + SDL_RWread(src, &palette->colors[i].b, 1, 1); + SDL_RWread(src, &palette->colors[i].g, 1, 1); + SDL_RWread(src, &palette->colors[i].r, 1, 1); + SDL_RWread(src, &palette->colors[i].unused, 1, 1); } } palette->ncolors = biClrUsed; } /* Read the surface pixels. Note that the bmp image is upside down */ - if (SDL_RWseek (src, fp_offset + bfOffBits, RW_SEEK_SET) < 0) { - SDL_Error (SDL_EFSEEK); + if (SDL_RWseek(src, fp_offset + bfOffBits, RW_SEEK_SET) < 0) { + SDL_Error(SDL_EFSEEK); was_error = 1; goto done; } @@ -265,8 +265,8 @@ int shift = (8 - ExpandBMP); for (i = 0; i < surface->w; ++i) { if (i % (8 / ExpandBMP) == 0) { - if (!SDL_RWread (src, &pixel, 1, 1)) { - SDL_SetError ("Error reading from BMP"); + if (!SDL_RWread(src, &pixel, 1, 1)) { + SDL_SetError("Error reading from BMP"); was_error = 1; goto done; } @@ -278,9 +278,9 @@ break; default: - if (SDL_RWread (src, bits, 1, surface->pitch) + if (SDL_RWread(src, bits, 1, surface->pitch) != surface->pitch) { - SDL_Error (SDL_EFREAD); + SDL_Error(SDL_EFREAD); was_error = 1; goto done; } @@ -293,7 +293,7 @@ { Uint16 *pix = (Uint16 *) bits; for (i = 0; i < surface->w; i++) - pix[i] = SDL_Swap16 (pix[i]); + pix[i] = SDL_Swap16(pix[i]); break; } @@ -301,7 +301,7 @@ { Uint32 *pix = (Uint32 *) bits; for (i = 0; i < surface->w; i++) - pix[i] = SDL_Swap32 (pix[i]); + pix[i] = SDL_Swap32(pix[i]); break; } } @@ -312,28 +312,28 @@ if (pad) { Uint8 padbyte; for (i = 0; i < pad; ++i) { - SDL_RWread (src, &padbyte, 1, 1); + SDL_RWread(src, &padbyte, 1, 1); } } } done: if (was_error) { if (src) { - SDL_RWseek (src, fp_offset, RW_SEEK_SET); + SDL_RWseek(src, fp_offset, RW_SEEK_SET); } if (surface) { - SDL_FreeSurface (surface); + SDL_FreeSurface(surface); } surface = NULL; } if (freesrc && src) { - SDL_RWclose (src); + SDL_RWclose(src); } return (surface); } int -SDL_SaveBMP_RW (SDL_Surface * saveme, SDL_RWops * dst, int freedst) +SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst) { long fp_offset; int i, pad; @@ -367,8 +367,8 @@ if (saveme->format->BitsPerPixel == 8) { surface = saveme; } else { - SDL_SetError ("%d bpp BMP files not supported", - saveme->format->BitsPerPixel); + SDL_SetError("%d bpp BMP files not supported", + saveme->format->BitsPerPixel); } } else if ((saveme->format->BitsPerPixel == 24) && #if SDL_BYTEORDER == SDL_LIL_ENDIAN @@ -386,31 +386,29 @@ SDL_Rect bounds; /* Convert to 24 bits per pixel */ - surface = SDL_CreateRGBSurface (SDL_SWSURFACE, - saveme->w, saveme->h, 24, + surface = SDL_CreateRGBSurface(SDL_SWSURFACE, + saveme->w, saveme->h, 24, #if SDL_BYTEORDER == SDL_LIL_ENDIAN - 0x00FF0000, 0x0000FF00, - 0x000000FF, + 0x00FF0000, 0x0000FF00, 0x000000FF, #else - 0x000000FF, 0x0000FF00, - 0x00FF0000, + 0x000000FF, 0x0000FF00, 0x00FF0000, #endif - 0); + 0); if (surface != NULL) { bounds.x = 0; bounds.y = 0; bounds.w = saveme->w; bounds.h = saveme->h; - if (SDL_LowerBlit (saveme, &bounds, surface, &bounds) < 0) { - SDL_FreeSurface (surface); - SDL_SetError ("Couldn't convert image to 24 bpp"); + if (SDL_LowerBlit(saveme, &bounds, surface, &bounds) < 0) { + SDL_FreeSurface(surface); + SDL_SetError("Couldn't convert image to 24 bpp"); surface = NULL; } } } } - if (surface && (SDL_LockSurface (surface) == 0)) { + if (surface && (SDL_LockSurface(surface) == 0)) { const int bw = surface->w * surface->format->BytesPerPixel; /* Set the BMP file header values */ @@ -420,13 +418,13 @@ bfOffBits = 0; /* We'll write this when we're done */ /* Write the BMP file header values */ - fp_offset = SDL_RWtell (dst); - SDL_ClearError (); - SDL_RWwrite (dst, magic, 2, 1); - SDL_WriteLE32 (dst, bfSize); - SDL_WriteLE16 (dst, bfReserved1); - SDL_WriteLE16 (dst, bfReserved2); - SDL_WriteLE32 (dst, bfOffBits); + fp_offset = SDL_RWtell(dst); + SDL_ClearError(); + SDL_RWwrite(dst, magic, 2, 1); + SDL_WriteLE32(dst, bfSize); + SDL_WriteLE16(dst, bfReserved1); + SDL_WriteLE16(dst, bfReserved2); + SDL_WriteLE32(dst, bfOffBits); /* Set the BMP info values */ biSize = 40; @@ -446,17 +444,17 @@ biClrImportant = 0; /* Write the BMP info values */ - SDL_WriteLE32 (dst, biSize); - SDL_WriteLE32 (dst, biWidth); - SDL_WriteLE32 (dst, biHeight); - SDL_WriteLE16 (dst, biPlanes); - SDL_WriteLE16 (dst, biBitCount); - SDL_WriteLE32 (dst, biCompression); - SDL_WriteLE32 (dst, biSizeImage); - SDL_WriteLE32 (dst, biXPelsPerMeter); - SDL_WriteLE32 (dst, biYPelsPerMeter); - SDL_WriteLE32 (dst, biClrUsed); - SDL_WriteLE32 (dst, biClrImportant); + SDL_WriteLE32(dst, biSize); + SDL_WriteLE32(dst, biWidth); + SDL_WriteLE32(dst, biHeight); + SDL_WriteLE16(dst, biPlanes); + SDL_WriteLE16(dst, biBitCount); + SDL_WriteLE32(dst, biCompression); + SDL_WriteLE32(dst, biSizeImage); + SDL_WriteLE32(dst, biXPelsPerMeter); + SDL_WriteLE32(dst, biYPelsPerMeter); + SDL_WriteLE32(dst, biClrUsed); + SDL_WriteLE32(dst, biClrImportant); /* Write the palette (in BGR color order) */ if (surface->format->palette) { @@ -466,21 +464,21 @@ colors = surface->format->palette->colors; ncolors = surface->format->palette->ncolors; for (i = 0; i < ncolors; ++i) { - SDL_RWwrite (dst, &colors[i].b, 1, 1); - SDL_RWwrite (dst, &colors[i].g, 1, 1); - SDL_RWwrite (dst, &colors[i].r, 1, 1); - SDL_RWwrite (dst, &colors[i].unused, 1, 1); + SDL_RWwrite(dst, &colors[i].b, 1, 1); + SDL_RWwrite(dst, &colors[i].g, 1, 1); + SDL_RWwrite(dst, &colors[i].r, 1, 1); + SDL_RWwrite(dst, &colors[i].unused, 1, 1); } } /* Write the bitmap offset */ - bfOffBits = SDL_RWtell (dst) - fp_offset; - if (SDL_RWseek (dst, fp_offset + 10, RW_SEEK_SET) < 0) { - SDL_Error (SDL_EFSEEK); + bfOffBits = SDL_RWtell(dst) - fp_offset; + if (SDL_RWseek(dst, fp_offset + 10, RW_SEEK_SET) < 0) { + SDL_Error(SDL_EFSEEK); } - SDL_WriteLE32 (dst, bfOffBits); - if (SDL_RWseek (dst, fp_offset + bfOffBits, RW_SEEK_SET) < 0) { - SDL_Error (SDL_EFSEEK); + SDL_WriteLE32(dst, bfOffBits); + if (SDL_RWseek(dst, fp_offset + bfOffBits, RW_SEEK_SET) < 0) { + SDL_Error(SDL_EFSEEK); } /* Write the bitmap image upside down */ @@ -488,39 +486,39 @@ pad = ((bw % 4) ? (4 - (bw % 4)) : 0); while (bits > (Uint8 *) surface->pixels) { bits -= surface->pitch; - if (SDL_RWwrite (dst, bits, 1, bw) != bw) { - SDL_Error (SDL_EFWRITE); + if (SDL_RWwrite(dst, bits, 1, bw) != bw) { + SDL_Error(SDL_EFWRITE); break; } if (pad) { const Uint8 padbyte = 0; for (i = 0; i < pad; ++i) { - SDL_RWwrite (dst, &padbyte, 1, 1); + SDL_RWwrite(dst, &padbyte, 1, 1); } } } /* Write the BMP file size */ - bfSize = SDL_RWtell (dst) - fp_offset; - if (SDL_RWseek (dst, fp_offset + 2, RW_SEEK_SET) < 0) { - SDL_Error (SDL_EFSEEK); + bfSize = SDL_RWtell(dst) - fp_offset; + if (SDL_RWseek(dst, fp_offset + 2, RW_SEEK_SET) < 0) { + SDL_Error(SDL_EFSEEK); } - SDL_WriteLE32 (dst, bfSize); - if (SDL_RWseek (dst, fp_offset + bfSize, RW_SEEK_SET) < 0) { - SDL_Error (SDL_EFSEEK); + SDL_WriteLE32(dst, bfSize); + if (SDL_RWseek(dst, fp_offset + bfSize, RW_SEEK_SET) < 0) { + SDL_Error(SDL_EFSEEK); } /* Close it up.. */ - SDL_UnlockSurface (surface); + SDL_UnlockSurface(surface); if (surface != saveme) { - SDL_FreeSurface (surface); + SDL_FreeSurface(surface); } } if (freedst && dst) { - SDL_RWclose (dst); + SDL_RWclose(dst); } - return ((SDL_strcmp (SDL_GetError (), "") == 0) ? 0 : -1); + return ((SDL_strcmp(SDL_GetError(), "") == 0) ? 0 : -1); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_cursor.c --- a/src/video/SDL_cursor.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_cursor.c Mon May 29 04:04:35 2006 +0000 @@ -42,29 +42,29 @@ /* Public functions */ void -SDL_CursorQuit (void) +SDL_CursorQuit(void) { if (SDL_cursor != NULL) { SDL_Cursor *cursor; SDL_cursorstate &= ~CURSOR_VISIBLE; if (SDL_cursor != SDL_defcursor) { - SDL_FreeCursor (SDL_cursor); + SDL_FreeCursor(SDL_cursor); } SDL_cursor = NULL; if (SDL_defcursor != NULL) { cursor = SDL_defcursor; SDL_defcursor = NULL; - SDL_FreeCursor (cursor); + SDL_FreeCursor(cursor); } } if (SDL_cursorlock != NULL) { - SDL_DestroyMutex (SDL_cursorlock); + SDL_DestroyMutex(SDL_cursorlock); SDL_cursorlock = NULL; } } int -SDL_CursorInit (Uint32 multithreaded) +SDL_CursorInit(Uint32 multithreaded) { /* We don't have mouse focus, and the cursor isn't drawn yet */ #ifndef IPOD @@ -73,15 +73,15 @@ /* Create the default cursor */ if (SDL_defcursor == NULL) { - SDL_defcursor = SDL_CreateCursor (default_cdata, default_cmask, - DEFAULT_CWIDTH, DEFAULT_CHEIGHT, - DEFAULT_CHOTX, DEFAULT_CHOTY); - SDL_SetCursor (SDL_defcursor); + SDL_defcursor = SDL_CreateCursor(default_cdata, default_cmask, + DEFAULT_CWIDTH, DEFAULT_CHEIGHT, + DEFAULT_CHOTX, DEFAULT_CHOTY); + SDL_SetCursor(SDL_defcursor); } /* Create a lock if necessary */ if (multithreaded) { - SDL_cursorlock = SDL_CreateMutex (); + SDL_cursorlock = SDL_CreateMutex(); } /* That's it! */ @@ -91,29 +91,29 @@ /* Multi-thread support for cursors */ #ifndef SDL_LockCursor void -SDL_LockCursor (void) +SDL_LockCursor(void) { if (SDL_cursorlock) { - SDL_mutexP (SDL_cursorlock); + SDL_mutexP(SDL_cursorlock); } } #endif #ifndef SDL_UnlockCursor void -SDL_UnlockCursor (void) +SDL_UnlockCursor(void) { if (SDL_cursorlock) { - SDL_mutexV (SDL_cursorlock); + SDL_mutexV(SDL_cursorlock); } } #endif /* Software cursor drawing support */ SDL_Cursor * -SDL_CreateCursor (Uint8 * data, Uint8 * mask, - int w, int h, int hot_x, int hot_y) +SDL_CreateCursor(Uint8 * data, Uint8 * mask, + int w, int h, int hot_x, int hot_y) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); int savelen; int i; SDL_Cursor *cursor; @@ -123,14 +123,14 @@ /* Sanity check the hot spot */ if ((hot_x < 0) || (hot_y < 0) || (hot_x >= w) || (hot_y >= h)) { - SDL_SetError ("Cursor hot spot doesn't lie within cursor"); + SDL_SetError("Cursor hot spot doesn't lie within cursor"); return (NULL); } /* Allocate memory for the cursor */ - cursor = (SDL_Cursor *) SDL_malloc (sizeof *cursor); + cursor = (SDL_Cursor *) SDL_malloc(sizeof *cursor); if (cursor == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } savelen = (w * 4) * h; @@ -140,26 +140,26 @@ cursor->area.h = h; cursor->hot_x = hot_x; cursor->hot_y = hot_y; - cursor->data = (Uint8 *) SDL_malloc ((w / 8) * h * 2); + cursor->data = (Uint8 *) SDL_malloc((w / 8) * h * 2); cursor->mask = cursor->data + ((w / 8) * h); - cursor->save[0] = (Uint8 *) SDL_malloc (savelen * 2); + cursor->save[0] = (Uint8 *) SDL_malloc(savelen * 2); cursor->save[1] = cursor->save[0] + savelen; cursor->wm_cursor = NULL; if (!cursor->data || !cursor->save[0]) { - SDL_FreeCursor (cursor); - SDL_OutOfMemory (); + SDL_FreeCursor(cursor); + SDL_OutOfMemory(); return (NULL); } for (i = ((w / 8) * h) - 1; i >= 0; --i) { cursor->data[i] = data[i]; cursor->mask[i] = mask[i] | data[i]; } - SDL_memset (cursor->save[0], 0, savelen * 2); + SDL_memset(cursor->save[0], 0, savelen * 2); /* If the window manager gives us a good cursor, we're done! */ if (_this->CreateWMCursor) { - cursor->wm_cursor = _this->CreateWMCursor (_this, data, mask, - w, h, hot_x, hot_y); + cursor->wm_cursor = _this->CreateWMCursor(_this, data, mask, + w, h, hot_x, hot_y); } else { cursor->wm_cursor = NULL; } @@ -171,9 +171,9 @@ the video mode and when the SDL window gains the mouse focus. */ void -SDL_SetCursor (SDL_Cursor * cursor) +SDL_SetCursor(SDL_Cursor * cursor) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); /* Make sure that the video subsystem has been initialized */ if (!_this) { @@ -181,20 +181,20 @@ } /* Prevent the event thread from moving the mouse */ - SDL_LockCursor (); + SDL_LockCursor(); /* Set the new cursor */ if (cursor && (cursor != SDL_cursor)) { /* Erase the current mouse position */ - if (SHOULD_DRAWCURSOR (SDL_cursorstate)) { - SDL_EraseCursor (SDL_VideoSurface); + if (SHOULD_DRAWCURSOR(SDL_cursorstate)) { + SDL_EraseCursor(SDL_VideoSurface); } else if (_this->MoveWMCursor) { /* If the video driver is moving the cursor directly, it needs to hide the old cursor before (possibly) showing the new one. (But don't erase NULL cursor) */ if (SDL_cursor) { - _this->ShowWMCursor (_this, NULL); + _this->ShowWMCursor(_this, NULL); } } SDL_cursor = cursor; @@ -204,84 +204,84 @@ if (SDL_cursor && (SDL_cursorstate & CURSOR_VISIBLE)) { /* Use window manager cursor if possible */ if (SDL_cursor->wm_cursor && - _this->ShowWMCursor (_this, SDL_cursor->wm_cursor)) { + _this->ShowWMCursor(_this, SDL_cursor->wm_cursor)) { SDL_cursorstate &= ~CURSOR_USINGSW; } else { SDL_cursorstate |= CURSOR_USINGSW; if (_this->ShowWMCursor) { - _this->ShowWMCursor (_this, NULL); + _this->ShowWMCursor(_this, NULL); } { int x, y; - SDL_GetMouseState (&x, &y); + SDL_GetMouseState(&x, &y); SDL_cursor->area.x = (x - SDL_cursor->hot_x); SDL_cursor->area.y = (y - SDL_cursor->hot_y); } - SDL_DrawCursor (SDL_VideoSurface); + SDL_DrawCursor(SDL_VideoSurface); } } else { /* Erase window manager mouse (cursor not visible) */ if (SDL_cursor && (SDL_cursorstate & CURSOR_USINGSW)) { - SDL_EraseCursor (SDL_VideoSurface); + SDL_EraseCursor(SDL_VideoSurface); } else { if (_this) { - _this->ShowWMCursor (_this, NULL); + _this->ShowWMCursor(_this, NULL); } } } - SDL_UnlockCursor (); + SDL_UnlockCursor(); } SDL_Cursor * -SDL_GetCursor (void) +SDL_GetCursor(void) { return (SDL_cursor); } void -SDL_FreeCursor (SDL_Cursor * cursor) +SDL_FreeCursor(SDL_Cursor * cursor) { if (cursor) { if (cursor == SDL_cursor) { - SDL_SetCursor (SDL_defcursor); + SDL_SetCursor(SDL_defcursor); } if (cursor != SDL_defcursor) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); if (cursor->data) { - SDL_free (cursor->data); + SDL_free(cursor->data); } if (cursor->save[0]) { - SDL_free (cursor->save[0]); + SDL_free(cursor->save[0]); } if (_this && cursor->wm_cursor) { - _this->FreeWMCursor (_this, cursor->wm_cursor); + _this->FreeWMCursor(_this, cursor->wm_cursor); } - SDL_free (cursor); + SDL_free(cursor); } } } int -SDL_ShowCursor (int toggle) +SDL_ShowCursor(int toggle) { int showing; showing = (SDL_cursorstate & CURSOR_VISIBLE); if (toggle >= 0) { - SDL_LockCursor (); + SDL_LockCursor(); if (toggle) { SDL_cursorstate |= CURSOR_VISIBLE; } else { SDL_cursorstate &= ~CURSOR_VISIBLE; } - SDL_UnlockCursor (); + SDL_UnlockCursor(); if ((SDL_cursorstate & CURSOR_VISIBLE) != showing) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); - SDL_SetCursor (NULL); + SDL_SetCursor(NULL); if (_this && _this->CheckMouseMode) { - _this->CheckMouseMode (_this); + _this->CheckMouseMode(_this); } } } else { @@ -291,12 +291,12 @@ } void -SDL_WarpMouse (Uint16 x, Uint16 y) +SDL_WarpMouse(Uint16 x, Uint16 y) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); if (!_this || !SDL_PublicSurface) { - SDL_SetError ("A video mode must be set before warping mouse"); + SDL_SetError("A video mode must be set before warping mouse"); return; } @@ -313,28 +313,28 @@ /* This generates a mouse motion event */ if (_this->WarpWMCursor) { - _this->WarpWMCursor (_this, x, y); + _this->WarpWMCursor(_this, x, y); } else { - SDL_PrivateMouseMotion (0, 0, x, y); + SDL_PrivateMouseMotion(0, 0, x, y); } } void -SDL_MoveCursor (int x, int y) +SDL_MoveCursor(int x, int y) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); /* Erase and update the current mouse position */ - if (SHOULD_DRAWCURSOR (SDL_cursorstate)) { + if (SHOULD_DRAWCURSOR(SDL_cursorstate)) { /* Erase and redraw mouse cursor in new position */ - SDL_LockCursor (); - SDL_EraseCursor (SDL_VideoSurface); + SDL_LockCursor(); + SDL_EraseCursor(SDL_VideoSurface); SDL_cursor->area.x = (x - SDL_cursor->hot_x); SDL_cursor->area.y = (y - SDL_cursor->hot_y); - SDL_DrawCursor (SDL_VideoSurface); - SDL_UnlockCursor (); + SDL_DrawCursor(SDL_VideoSurface); + SDL_UnlockCursor(); } else if (_this->MoveWMCursor) { - _this->MoveWMCursor (_this, x, y); + _this->MoveWMCursor(_this, x, y); } } @@ -343,15 +343,15 @@ static Uint8 pixels8[2]; void -SDL_CursorPaletteChanged (void) +SDL_CursorPaletteChanged(void) { palette_changed = 1; } void -SDL_MouseRect (SDL_Rect * area) +SDL_MouseRect(SDL_Rect * area) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); int clip_diff; *area = SDL_cursor->area; @@ -374,7 +374,7 @@ } static void -SDL_DrawCursorFast (SDL_Surface * screen, SDL_Rect * area) +SDL_DrawCursorFast(SDL_Surface * screen, SDL_Rect * area) { const Uint32 pixels[2] = { 0xFFFFFFFF, 0x00000000 }; int i, w, h; @@ -392,8 +392,8 @@ if (palette_changed) { pixels8[0] = - (Uint8) SDL_MapRGB (screen->format, 255, 255, 255); - pixels8[1] = (Uint8) SDL_MapRGB (screen->format, 0, 0, 0); + (Uint8) SDL_MapRGB(screen->format, 255, 255, 255); + pixels8[1] = (Uint8) SDL_MapRGB(screen->format, 0, 0, 0); palette_changed = 0; } dst = (Uint8 *) screen->pixels + @@ -463,7 +463,7 @@ datab = *data++; for (i = 0; i < 8; ++i) { if (maskb & 0x80) { - SDL_memset (dst, pixels[datab >> 7], 3); + SDL_memset(dst, pixels[datab >> 7], 3); } maskb <<= 1; datab <<= 1; @@ -506,7 +506,7 @@ } static void -SDL_DrawCursorSlow (SDL_Surface * screen, SDL_Rect * area) +SDL_DrawCursorSlow(SDL_Surface * screen, SDL_Rect * area) { const Uint32 pixels[2] = { 0xFFFFFF, 0x000000 }; int h; @@ -528,8 +528,8 @@ maxx = area->x + area->w; if (screen->format->BytesPerPixel == 1) { if (palette_changed) { - pixels8[0] = (Uint8) SDL_MapRGB (screen->format, 255, 255, 255); - pixels8[1] = (Uint8) SDL_MapRGB (screen->format, 0, 0, 0); + pixels8[0] = (Uint8) SDL_MapRGB(screen->format, 255, 255, 255); + pixels8[1] = (Uint8) SDL_MapRGB(screen->format, 0, 0, 0); palette_changed = 0; } for (h = area->h; h; h--) { @@ -540,7 +540,7 @@ } if ((x >= minx) && (x < maxx)) { if (maskb & 0x80) { - SDL_memset (dst, pixels8[datab >> 7], dstbpp); + SDL_memset(dst, pixels8[datab >> 7], dstbpp); } } maskb <<= 1; @@ -558,7 +558,7 @@ } if ((x >= minx) && (x < maxx)) { if (maskb & 0x80) { - SDL_memset (dst, pixels[datab >> 7], dstbpp); + SDL_memset(dst, pixels[datab >> 7], dstbpp); } } maskb <<= 1; @@ -576,9 +576,9 @@ pixel format than the video surface, and using a software rendered cursor. */ static void -SDL_ConvertCursorSave (SDL_Surface * screen, int w, int h) +SDL_ConvertCursorSave(SDL_Surface * screen, int w, int h) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); SDL_BlitInfo info; SDL_loblit RunBlit; @@ -603,17 +603,17 @@ RunBlit = screen->map->sw_data->blit; /* Run the actual software blit */ - RunBlit (&info); + RunBlit(&info); } void -SDL_DrawCursorNoLock (SDL_Surface * screen) +SDL_DrawCursorNoLock(SDL_Surface * screen) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); SDL_Rect area; /* Get the mouse rectangle, clipped to the screen */ - SDL_MouseRect (&area); + SDL_MouseRect(&area); if ((area.w == 0) || (area.h == 0)) { return; } @@ -626,7 +626,7 @@ /* Set up the copy pointers */ screenbpp = screen->format->BytesPerPixel; if ((screen == SDL_VideoSurface) || - FORMAT_EQUAL (screen->format, SDL_VideoSurface->format)) { + FORMAT_EQUAL(screen->format, SDL_VideoSurface->format)) { dst = SDL_cursor->save[0]; } else { dst = SDL_cursor->save[1]; @@ -638,7 +638,7 @@ w = area.w * screenbpp; h = area.h; while (h--) { - SDL_memcpy (dst, src, w); + SDL_memcpy(dst, src, w); dst += w; src += screen->pitch; } @@ -648,65 +648,65 @@ area.x -= SDL_cursor->area.x; area.y -= SDL_cursor->area.y; if ((area.x == 0) && (area.w == SDL_cursor->area.w)) { - SDL_DrawCursorFast (screen, &area); + SDL_DrawCursorFast(screen, &area); } else { - SDL_DrawCursorSlow (screen, &area); + SDL_DrawCursorSlow(screen, &area); } } void -SDL_DrawCursor (SDL_Surface * screen) +SDL_DrawCursor(SDL_Surface * screen) { /* Lock the screen if necessary */ if (screen == NULL) { return; } - if (SDL_MUSTLOCK (screen)) { - if (SDL_LockSurface (screen) < 0) { + if (SDL_MUSTLOCK(screen)) { + if (SDL_LockSurface(screen) < 0) { return; } } - SDL_DrawCursorNoLock (screen); + SDL_DrawCursorNoLock(screen); /* Unlock the screen and update if necessary */ - if (SDL_MUSTLOCK (screen)) { - SDL_UnlockSurface (screen); + if (SDL_MUSTLOCK(screen)) { + SDL_UnlockSurface(screen); } if ((screen->flags & SDL_SCREEN_SURFACE) && !(screen->flags & SDL_HWSURFACE)) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); SDL_Window *window; SDL_Rect area; - window = SDL_GetWindowFromSurface (screen); + window = SDL_GetWindowFromSurface(screen); if (!window) { return; } - SDL_MouseRect (&area); + SDL_MouseRect(&area); if (_this->UpdateWindowSurface) { - _this->UpdateWindowSurface (_this, window, 1, &area); + _this->UpdateWindowSurface(_this, window, 1, &area); } } } void -SDL_EraseCursorNoLock (SDL_Surface * screen) +SDL_EraseCursorNoLock(SDL_Surface * screen) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); SDL_Window *window; SDL_Rect area; /* Get the window associated with the surface */ - window = SDL_GetWindowFromSurface (screen); + window = SDL_GetWindowFromSurface(screen); if (!window || !window->surface) { return; } /* Get the mouse rectangle, clipped to the screen */ - SDL_MouseRect (&area); + SDL_MouseRect(&area); if ((area.w == 0) || (area.h == 0)) { return; } @@ -719,7 +719,7 @@ /* Set up the copy pointers */ screenbpp = screen->format->BytesPerPixel; if ((screen->flags & SDL_SCREEN_SURFACE) || - FORMAT_EQUAL (screen->format, window->surface->format)) { + FORMAT_EQUAL(screen->format, window->surface->format)) { src = SDL_cursor->save[0]; } else { src = SDL_cursor->save[1]; @@ -731,52 +731,52 @@ w = area.w * screenbpp; h = area.h; while (h--) { - SDL_memcpy (dst, src, w); + SDL_memcpy(dst, src, w); src += w; dst += screen->pitch; } /* Perform pixel conversion on cursor background */ if (src > SDL_cursor->save[1]) { - SDL_ConvertCursorSave (screen, area.w, area.h); + SDL_ConvertCursorSave(screen, area.w, area.h); } } } void -SDL_EraseCursor (SDL_Surface * screen) +SDL_EraseCursor(SDL_Surface * screen) { /* Lock the screen if necessary */ if (screen == NULL) { return; } - if (SDL_MUSTLOCK (screen)) { - if (SDL_LockSurface (screen) < 0) { + if (SDL_MUSTLOCK(screen)) { + if (SDL_LockSurface(screen) < 0) { return; } } - SDL_EraseCursorNoLock (screen); + SDL_EraseCursorNoLock(screen); /* Unlock the screen and update if necessary */ - if (SDL_MUSTLOCK (screen)) { - SDL_UnlockSurface (screen); + if (SDL_MUSTLOCK(screen)) { + SDL_UnlockSurface(screen); } if ((screen->flags & SDL_SCREEN_SURFACE) && !(screen->flags & SDL_HWSURFACE)) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); SDL_Window *window; SDL_Rect area; - window = SDL_GetWindowFromSurface (screen); + window = SDL_GetWindowFromSurface(screen); if (!window) { return; } - SDL_MouseRect (&area); + SDL_MouseRect(&area); if (_this->UpdateWindowSurface) { - _this->UpdateWindowSurface (_this, window, 1, &area); + _this->UpdateWindowSurface(_this, window, 1, &area); } } } @@ -785,7 +785,7 @@ FIXME: Keep track of all cursors, and reset them all. */ void -SDL_ResetCursor (void) +SDL_ResetCursor(void) { int savelen; @@ -793,7 +793,7 @@ savelen = SDL_cursor->area.w * 4 * SDL_cursor->area.h; SDL_cursor->area.x = 0; SDL_cursor->area.y = 0; - SDL_memset (SDL_cursor->save[0], 0, savelen); + SDL_memset(SDL_cursor->save[0], 0, savelen); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_cursor_c.h --- a/src/video/SDL_cursor_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_cursor_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,16 +24,16 @@ /* Useful variables and functions from SDL_cursor.c */ #include "SDL_mouse.h" -extern int SDL_CursorInit (Uint32 flags); -extern void SDL_CursorPaletteChanged (void); -extern void SDL_DrawCursor (SDL_Surface * screen); -extern void SDL_DrawCursorNoLock (SDL_Surface * screen); -extern void SDL_EraseCursor (SDL_Surface * screen); -extern void SDL_EraseCursorNoLock (SDL_Surface * screen); -extern void SDL_UpdateCursor (SDL_Surface * screen); -extern void SDL_ResetCursor (void); -extern void SDL_MoveCursor (int x, int y); -extern void SDL_CursorQuit (void); +extern int SDL_CursorInit(Uint32 flags); +extern void SDL_CursorPaletteChanged(void); +extern void SDL_DrawCursor(SDL_Surface * screen); +extern void SDL_DrawCursorNoLock(SDL_Surface * screen); +extern void SDL_EraseCursor(SDL_Surface * screen); +extern void SDL_EraseCursorNoLock(SDL_Surface * screen); +extern void SDL_UpdateCursor(SDL_Surface * screen); +extern void SDL_ResetCursor(void); +extern void SDL_MoveCursor(int x, int y); +extern void SDL_CursorQuit(void); #define INLINE_MOUSELOCK #ifdef INLINE_MOUSELOCK @@ -55,13 +55,13 @@ } \ } while ( 0 ) #else -extern void SDL_LockCursor (void); -extern void SDL_UnlockCursor (void); +extern void SDL_LockCursor(void); +extern void SDL_UnlockCursor(void); #endif /* INLINE_MOUSELOCK */ /* Only for low-level mouse cursor drawing */ extern SDL_Cursor *SDL_cursor; -extern void SDL_MouseRect (SDL_Rect * area); +extern void SDL_MouseRect(SDL_Rect * area); /* State definitions for the SDL cursor */ #define CURSOR_VISIBLE 0x01 diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_gamma.c --- a/src/video/SDL_gamma.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_gamma.c Mon May 29 04:04:35 2006 +0000 @@ -39,7 +39,7 @@ static void -CalculateGammaRamp (float gamma, Uint16 * ramp) +CalculateGammaRamp(float gamma, Uint16 * ramp) { int i; @@ -62,7 +62,7 @@ int value; gamma = 1.0f / gamma; for (i = 0; i < 256; ++i) { - value = (int) (pow ((double) i / 256.0, gamma) * 65535.0 + 0.5); + value = (int) (pow((double) i / 256.0, gamma) * 65535.0 + 0.5); if (value > 65535) { value = 65535; } @@ -71,7 +71,7 @@ } } static void -CalculateGammaFromRamp (float *gamma, Uint16 * ramp) +CalculateGammaFromRamp(float *gamma, Uint16 * ramp) { /* The following is adapted from a post by Garrett Bass on OpenGL Gamedev list, March 4, 2000. @@ -84,7 +84,7 @@ if ((ramp[i] != 0) && (ramp[i] != 65535)) { double B = (double) i / 256.0; double A = ramp[i] / 65535.0; - sum += (float) (log (A) / log (B)); + sum += (float) (log(A) / log(B)); count++; } } @@ -94,9 +94,9 @@ } int -SDL_SetGamma (float red, float green, float blue) +SDL_SetGamma(float red, float green, float blue) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); int succeeded; succeeded = -1; @@ -104,14 +104,14 @@ { Uint16 ramp[3][256]; - CalculateGammaRamp (red, ramp[0]); - CalculateGammaRamp (green, ramp[1]); - CalculateGammaRamp (blue, ramp[2]); - succeeded = SDL_SetGammaRamp (ramp[0], ramp[1], ramp[2]); + CalculateGammaRamp(red, ramp[0]); + CalculateGammaRamp(green, ramp[1]); + CalculateGammaRamp(blue, ramp[2]); + succeeded = SDL_SetGammaRamp(ramp[0], ramp[1], ramp[2]); } if ((succeeded < 0) && _this->SetGamma) { - SDL_ClearError (); - succeeded = _this->SetGamma (_this, red, green, blue); + SDL_ClearError(); + succeeded = _this->SetGamma(_this, red, green, blue); } return succeeded; } @@ -120,9 +120,9 @@ so this function isn't officially supported. */ int -SDL_GetGamma (float *red, float *green, float *blue) +SDL_GetGamma(float *red, float *green, float *blue) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); int succeeded; succeeded = -1; @@ -130,79 +130,79 @@ { Uint16 ramp[3][256]; - succeeded = SDL_GetGammaRamp (ramp[0], ramp[1], ramp[2]); + succeeded = SDL_GetGammaRamp(ramp[0], ramp[1], ramp[2]); if (succeeded >= 0) { - CalculateGammaFromRamp (red, ramp[0]); - CalculateGammaFromRamp (green, ramp[1]); - CalculateGammaFromRamp (blue, ramp[2]); + CalculateGammaFromRamp(red, ramp[0]); + CalculateGammaFromRamp(green, ramp[1]); + CalculateGammaFromRamp(blue, ramp[2]); } } if ((succeeded < 0) && _this->GetGamma) { - SDL_ClearError (); - succeeded = _this->GetGamma (_this, red, green, blue); + SDL_ClearError(); + succeeded = _this->GetGamma(_this, red, green, blue); } return succeeded; } int -SDL_SetGammaRamp (const Uint16 * red, const Uint16 * green, - const Uint16 * blue) +SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green, + const Uint16 * blue) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); int succeeded; SDL_Surface *screen = SDL_PublicSurface; /* Verify the screen parameter */ if (!screen) { - SDL_SetError ("No video mode has been set"); + SDL_SetError("No video mode has been set"); return -1; } /* Lazily allocate the gamma tables */ if (!SDL_CurrentWindow.gamma) { - SDL_GetGammaRamp (0, 0, 0); + SDL_GetGammaRamp(0, 0, 0); } /* Fill the gamma table with the new values */ if (red) { - SDL_memcpy (&SDL_CurrentWindow.gamma[0 * 256], red, - 256 * sizeof (*SDL_CurrentWindow.gamma)); + SDL_memcpy(&SDL_CurrentWindow.gamma[0 * 256], red, + 256 * sizeof(*SDL_CurrentWindow.gamma)); } if (green) { - SDL_memcpy (&SDL_CurrentWindow.gamma[1 * 256], green, - 256 * sizeof (*SDL_CurrentWindow.gamma)); + SDL_memcpy(&SDL_CurrentWindow.gamma[1 * 256], green, + 256 * sizeof(*SDL_CurrentWindow.gamma)); } if (blue) { - SDL_memcpy (&SDL_CurrentWindow.gamma[2 * 256], blue, - 256 * sizeof (*SDL_CurrentWindow.gamma)); + SDL_memcpy(&SDL_CurrentWindow.gamma[2 * 256], blue, + 256 * sizeof(*SDL_CurrentWindow.gamma)); } /* Try to set the gamma ramp in the driver */ succeeded = -1; if (_this->SetGammaRamp) { - succeeded = _this->SetGammaRamp (_this, SDL_CurrentWindow.gamma); + succeeded = _this->SetGammaRamp(_this, SDL_CurrentWindow.gamma); } else { - SDL_SetError ("Gamma ramp manipulation not supported"); + SDL_SetError("Gamma ramp manipulation not supported"); } return succeeded; } int -SDL_GetGammaRamp (Uint16 * red, Uint16 * green, Uint16 * blue) +SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); /* Lazily allocate the gamma table */ if (!SDL_CurrentWindow.gamma) { SDL_CurrentWindow.gamma = - SDL_malloc (3 * 256 * sizeof (*SDL_CurrentWindow.gamma)); + SDL_malloc(3 * 256 * sizeof(*SDL_CurrentWindow.gamma)); if (!SDL_CurrentWindow.gamma) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return -1; } if (_this->GetGammaRamp) { /* Get the real hardware gamma */ - _this->GetGammaRamp (_this, SDL_CurrentWindow.gamma); + _this->GetGammaRamp(_this, SDL_CurrentWindow.gamma); } else { /* Assume an identity gamma */ int i; @@ -216,16 +216,16 @@ /* Just copy from our internal table */ if (red) { - SDL_memcpy (red, &SDL_CurrentWindow.gamma[0 * 256], - 256 * sizeof (*red)); + SDL_memcpy(red, &SDL_CurrentWindow.gamma[0 * 256], + 256 * sizeof(*red)); } if (green) { - SDL_memcpy (green, &SDL_CurrentWindow.gamma[1 * 256], - 256 * sizeof (*green)); + SDL_memcpy(green, &SDL_CurrentWindow.gamma[1 * 256], + 256 * sizeof(*green)); } if (blue) { - SDL_memcpy (blue, &SDL_CurrentWindow.gamma[2 * 256], - 256 * sizeof (*blue)); + SDL_memcpy(blue, &SDL_CurrentWindow.gamma[2 * 256], + 256 * sizeof(*blue)); } return 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_glfuncs.h --- a/src/video/SDL_glfuncs.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_glfuncs.h Mon May 29 04:04:35 2006 +0000 @@ -3,457 +3,452 @@ change it's entry from SDL_PROC_UNUSED to SDL_PROC and rebuild. */ #define SDL_PROC_UNUSED(ret,func,params) -SDL_PROC_UNUSED (void, glAccum, (GLenum, GLfloat)) -SDL_PROC_UNUSED (void, glAlphaFunc, (GLenum, GLclampf)) -SDL_PROC_UNUSED (GLboolean, glAreTexturesResident, - (GLsizei, const GLuint *, GLboolean *)) -SDL_PROC_UNUSED (void, glArrayElement, (GLint)) -SDL_PROC (void, glBegin, (GLenum)) -SDL_PROC (void, glBindTexture, (GLenum, GLuint)) -SDL_PROC_UNUSED (void, glBitmap, - (GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, - const GLubyte *)) -SDL_PROC (void, glBlendFunc, (GLenum, GLenum)) -SDL_PROC_UNUSED (void, glCallList, (GLuint)) -SDL_PROC_UNUSED (void, glCallLists, (GLsizei, GLenum, const GLvoid *)) -SDL_PROC_UNUSED (void, glClear, (GLbitfield)) -SDL_PROC_UNUSED (void, glClearAccum, (GLfloat, GLfloat, GLfloat, GLfloat)) -SDL_PROC_UNUSED (void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf)) -SDL_PROC_UNUSED (void, glClearDepth, (GLclampd)) -SDL_PROC_UNUSED (void, glClearIndex, (GLfloat)) -SDL_PROC_UNUSED (void, glClearStencil, (GLint)) -SDL_PROC_UNUSED (void, glClipPlane, (GLenum, const GLdouble *)) -SDL_PROC_UNUSED (void, glColor3b, (GLbyte, GLbyte, GLbyte)) -SDL_PROC_UNUSED (void, glColor3bv, (const GLbyte *)) -SDL_PROC_UNUSED (void, glColor3d, (GLdouble, GLdouble, GLdouble)) -SDL_PROC_UNUSED (void, glColor3dv, (const GLdouble *)) -SDL_PROC_UNUSED (void, glColor3f, (GLfloat, GLfloat, GLfloat)) -SDL_PROC_UNUSED (void, glColor3fv, (const GLfloat *)) -SDL_PROC_UNUSED (void, glColor3i, (GLint, GLint, GLint)) -SDL_PROC_UNUSED (void, glColor3iv, (const GLint *)) -SDL_PROC_UNUSED (void, glColor3s, (GLshort, GLshort, GLshort)) -SDL_PROC_UNUSED (void, glColor3sv, (const GLshort *)) -SDL_PROC (void, glColor3ub, (GLubyte, GLubyte, GLubyte)) -SDL_PROC_UNUSED (void, glColor3ubv, (const GLubyte *)) -SDL_PROC_UNUSED (void, glColor3ui, (GLuint, GLuint, GLuint)) -SDL_PROC_UNUSED (void, glColor3uiv, (const GLuint *)) -SDL_PROC_UNUSED (void, glColor3us, (GLushort, GLushort, GLushort)) -SDL_PROC_UNUSED (void, glColor3usv, (const GLushort *)) -SDL_PROC_UNUSED (void, glColor4b, (GLbyte, GLbyte, GLbyte, GLbyte)) -SDL_PROC_UNUSED (void, glColor4bv, (const GLbyte *)) -SDL_PROC_UNUSED (void, glColor4d, (GLdouble, GLdouble, GLdouble, GLdouble)) -SDL_PROC_UNUSED (void, glColor4dv, (const GLdouble *)) -SDL_PROC (void, glColor4f, (GLfloat, GLfloat, GLfloat, GLfloat)) -SDL_PROC_UNUSED (void, glColor4fv, (const GLfloat *)) -SDL_PROC_UNUSED (void, glColor4i, (GLint, GLint, GLint, GLint)) -SDL_PROC_UNUSED (void, glColor4iv, (const GLint *)) -SDL_PROC_UNUSED (void, glColor4s, (GLshort, GLshort, GLshort, GLshort)) -SDL_PROC_UNUSED (void, glColor4sv, (const GLshort *)) -SDL_PROC (void, glColor4ub, - (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)) -SDL_PROC_UNUSED (void, glColor4ubv, (const GLubyte * v)) -SDL_PROC_UNUSED (void, glColor4ui, - (GLuint red, GLuint green, GLuint blue, GLuint alpha)) -SDL_PROC_UNUSED (void, glColor4uiv, (const GLuint * v)) -SDL_PROC_UNUSED (void, glColor4us, - (GLushort red, GLushort green, GLushort blue, - GLushort alpha)) -SDL_PROC_UNUSED (void, glColor4usv, (const GLushort * v)) -SDL_PROC_UNUSED (void, glColorMask, - (GLboolean red, GLboolean green, GLboolean blue, - GLboolean alpha)) -SDL_PROC_UNUSED (void, glColorMaterial, (GLenum face, GLenum mode)) -SDL_PROC_UNUSED (void, glColorPointer, - (GLint size, GLenum type, GLsizei stride, - const GLvoid * pointer)) -SDL_PROC_UNUSED (void, glCopyPixels, - (GLint x, GLint y, GLsizei width, GLsizei height, - GLenum type)) -SDL_PROC_UNUSED (void, glCopyTexImage1D, - (GLenum target, GLint level, GLenum internalFormat, GLint x, - GLint y, GLsizei width, GLint border)) -SDL_PROC_UNUSED (void, glCopyTexImage2D, - (GLenum target, GLint level, GLenum internalFormat, GLint x, - GLint y, GLsizei width, GLsizei height, GLint border)) -SDL_PROC_UNUSED (void, glCopyTexSubImage1D, - (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, - GLsizei width)) -SDL_PROC_UNUSED (void, glCopyTexSubImage2D, - (GLenum target, GLint level, GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLsizei height)) -SDL_PROC_UNUSED (void, glCullFace, (GLenum mode)) -SDL_PROC_UNUSED (void, glDeleteLists, (GLuint list, GLsizei range)) -SDL_PROC (void, glDeleteTextures, (GLsizei n, const GLuint * textures)) -SDL_PROC_UNUSED (void, glDepthFunc, (GLenum func)) -SDL_PROC_UNUSED (void, glDepthMask, (GLboolean flag)) -SDL_PROC_UNUSED (void, glDepthRange, (GLclampd zNear, GLclampd zFar)) -SDL_PROC (void, glDisable, (GLenum cap)) -SDL_PROC_UNUSED (void, glDisableClientState, (GLenum array)) -SDL_PROC_UNUSED (void, glDrawArrays, - (GLenum mode, GLint first, GLsizei count)) -SDL_PROC (void, glDrawBuffer, (GLenum mode)) -SDL_PROC_UNUSED (void, glDrawElements, - (GLenum mode, GLsizei count, GLenum type, - const GLvoid * indices)) -SDL_PROC_UNUSED (void, glDrawPixels, - (GLsizei width, GLsizei height, GLenum format, GLenum type, - const GLvoid * pixels)) -SDL_PROC_UNUSED (void, glEdgeFlag, (GLboolean flag)) -SDL_PROC_UNUSED (void, glEdgeFlagPointer, - (GLsizei stride, const GLvoid * pointer)) -SDL_PROC_UNUSED (void, glEdgeFlagv, (const GLboolean * flag)) -SDL_PROC (void, glEnable, (GLenum cap)) -SDL_PROC_UNUSED (void, glEnableClientState, (GLenum array)) -SDL_PROC (void, glEnd, (void)) -SDL_PROC_UNUSED (void, glEndList, (void)) -SDL_PROC_UNUSED (void, glEvalCoord1d, (GLdouble u)) -SDL_PROC_UNUSED (void, glEvalCoord1dv, (const GLdouble * u)) -SDL_PROC_UNUSED (void, glEvalCoord1f, (GLfloat u)) -SDL_PROC_UNUSED (void, glEvalCoord1fv, (const GLfloat * u)) -SDL_PROC_UNUSED (void, glEvalCoord2d, (GLdouble u, GLdouble v)) -SDL_PROC_UNUSED (void, glEvalCoord2dv, (const GLdouble * u)) -SDL_PROC_UNUSED (void, glEvalCoord2f, (GLfloat u, GLfloat v)) -SDL_PROC_UNUSED (void, glEvalCoord2fv, (const GLfloat * u)) -SDL_PROC_UNUSED (void, glEvalMesh1, (GLenum mode, GLint i1, GLint i2)) -SDL_PROC_UNUSED (void, glEvalMesh2, - (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)) -SDL_PROC_UNUSED (void, glEvalPoint1, (GLint i)) -SDL_PROC_UNUSED (void, glEvalPoint2, (GLint i, GLint j)) -SDL_PROC_UNUSED (void, glFeedbackBuffer, - (GLsizei size, GLenum type, GLfloat * buffer)) -SDL_PROC (void, glFinish, (void)) -SDL_PROC (void, glFlush, (void)) -SDL_PROC_UNUSED (void, glFogf, (GLenum pname, GLfloat param)) -SDL_PROC_UNUSED (void, glFogfv, (GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED (void, glFogi, (GLenum pname, GLint param)) -SDL_PROC_UNUSED (void, glFogiv, (GLenum pname, const GLint * params)) -SDL_PROC_UNUSED (void, glFrontFace, (GLenum mode)) -SDL_PROC_UNUSED (void, glFrustum, - (GLdouble left, GLdouble right, GLdouble bottom, - GLdouble top, GLdouble zNear, GLdouble zFar)) -SDL_PROC_UNUSED (GLuint, glGenLists, (GLsizei range)) -SDL_PROC (void, glGenTextures, (GLsizei n, GLuint * textures)) -SDL_PROC_UNUSED (void, glGetBooleanv, (GLenum pname, GLboolean * params)) -SDL_PROC_UNUSED (void, glGetClipPlane, (GLenum plane, GLdouble * equation)) -SDL_PROC_UNUSED (void, glGetDoublev, (GLenum pname, GLdouble * params)) -SDL_PROC (GLenum, glGetError, (void)) -SDL_PROC_UNUSED (void, glGetFloatv, (GLenum pname, GLfloat * params)) -SDL_PROC (void, glGetIntegerv, (GLenum pname, GLint * params)) -SDL_PROC_UNUSED (void, glGetLightfv, - (GLenum light, GLenum pname, GLfloat * params)) -SDL_PROC_UNUSED (void, glGetLightiv, - (GLenum light, GLenum pname, GLint * params)) -SDL_PROC_UNUSED (void, glGetMapdv, - (GLenum target, GLenum query, GLdouble * v)) -SDL_PROC_UNUSED (void, glGetMapfv, (GLenum target, GLenum query, GLfloat * v)) -SDL_PROC_UNUSED (void, glGetMapiv, (GLenum target, GLenum query, GLint * v)) -SDL_PROC_UNUSED (void, glGetMaterialfv, - (GLenum face, GLenum pname, GLfloat * params)) -SDL_PROC_UNUSED (void, glGetMaterialiv, - (GLenum face, GLenum pname, GLint * params)) -SDL_PROC_UNUSED (void, glGetPixelMapfv, (GLenum map, GLfloat * values)) -SDL_PROC_UNUSED (void, glGetPixelMapuiv, (GLenum map, GLuint * values)) -SDL_PROC_UNUSED (void, glGetPixelMapusv, (GLenum map, GLushort * values)) -SDL_PROC_UNUSED (void, glGetPointerv, (GLenum pname, GLvoid * *params)) -SDL_PROC_UNUSED (void, glGetPolygonStipple, (GLubyte * mask)) -SDL_PROC (const GLubyte *, glGetString, (GLenum name)) -SDL_PROC_UNUSED (void, glGetTexEnvfv, - (GLenum target, GLenum pname, GLfloat * params)) -SDL_PROC_UNUSED (void, glGetTexEnviv, - (GLenum target, GLenum pname, GLint * params)) -SDL_PROC_UNUSED (void, glGetTexGendv, - (GLenum coord, GLenum pname, GLdouble * params)) -SDL_PROC_UNUSED (void, glGetTexGenfv, - (GLenum coord, GLenum pname, GLfloat * params)) -SDL_PROC_UNUSED (void, glGetTexGeniv, - (GLenum coord, GLenum pname, GLint * params)) -SDL_PROC_UNUSED (void, glGetTexImage, - (GLenum target, GLint level, GLenum format, GLenum type, - GLvoid * pixels)) -SDL_PROC_UNUSED (void, glGetTexLevelParameterfv, - (GLenum target, GLint level, GLenum pname, GLfloat * params)) -SDL_PROC_UNUSED (void, glGetTexLevelParameteriv, - (GLenum target, GLint level, GLenum pname, GLint * params)) -SDL_PROC_UNUSED (void, glGetTexParameterfv, - (GLenum target, GLenum pname, GLfloat * params)) -SDL_PROC_UNUSED (void, glGetTexParameteriv, - (GLenum target, GLenum pname, GLint * params)) -SDL_PROC_UNUSED (void, glHint, (GLenum target, GLenum mode)) -SDL_PROC_UNUSED (void, glIndexMask, (GLuint mask)) -SDL_PROC_UNUSED (void, glIndexPointer, - (GLenum type, GLsizei stride, const GLvoid * pointer)) -SDL_PROC_UNUSED (void, glIndexd, (GLdouble c)) -SDL_PROC_UNUSED (void, glIndexdv, (const GLdouble * c)) -SDL_PROC_UNUSED (void, glIndexf, (GLfloat c)) -SDL_PROC_UNUSED (void, glIndexfv, (const GLfloat * c)) -SDL_PROC_UNUSED (void, glIndexi, (GLint c)) -SDL_PROC_UNUSED (void, glIndexiv, (const GLint * c)) -SDL_PROC_UNUSED (void, glIndexs, (GLshort c)) -SDL_PROC_UNUSED (void, glIndexsv, (const GLshort * c)) -SDL_PROC_UNUSED (void, glIndexub, (GLubyte c)) -SDL_PROC_UNUSED (void, glIndexubv, (const GLubyte * c)) -SDL_PROC_UNUSED (void, glInitNames, (void)) -SDL_PROC_UNUSED (void, glInterleavedArrays, - (GLenum format, GLsizei stride, const GLvoid * pointer)) -SDL_PROC_UNUSED (GLboolean, glIsEnabled, (GLenum cap)) -SDL_PROC_UNUSED (GLboolean, glIsList, (GLuint list)) -SDL_PROC_UNUSED (GLboolean, glIsTexture, (GLuint texture)) -SDL_PROC_UNUSED (void, glLightModelf, (GLenum pname, GLfloat param)) -SDL_PROC_UNUSED (void, glLightModelfv, (GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED (void, glLightModeli, (GLenum pname, GLint param)) -SDL_PROC_UNUSED (void, glLightModeliv, (GLenum pname, const GLint * params)) -SDL_PROC_UNUSED (void, glLightf, (GLenum light, GLenum pname, GLfloat param)) -SDL_PROC_UNUSED (void, glLightfv, - (GLenum light, GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED (void, glLighti, (GLenum light, GLenum pname, GLint param)) -SDL_PROC_UNUSED (void, glLightiv, - (GLenum light, GLenum pname, const GLint * params)) -SDL_PROC_UNUSED (void, glLineStipple, (GLint factor, GLushort pattern)) -SDL_PROC_UNUSED (void, glLineWidth, (GLfloat width)) -SDL_PROC_UNUSED (void, glListBase, (GLuint base)) -SDL_PROC (void, glLoadIdentity, (void)) -SDL_PROC_UNUSED (void, glLoadMatrixd, (const GLdouble * m)) -SDL_PROC_UNUSED (void, glLoadMatrixf, (const GLfloat * m)) -SDL_PROC_UNUSED (void, glLoadName, (GLuint name)) -SDL_PROC_UNUSED (void, glLogicOp, (GLenum opcode)) -SDL_PROC_UNUSED (void, glMap1d, - (GLenum target, GLdouble u1, GLdouble u2, GLint stride, - GLint order, const GLdouble * points)) -SDL_PROC_UNUSED (void, glMap1f, - (GLenum target, GLfloat u1, GLfloat u2, GLint stride, - GLint order, const GLfloat * points)) -SDL_PROC_UNUSED (void, glMap2d, - (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, - GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, - GLint vorder, const GLdouble * points)) -SDL_PROC_UNUSED (void, glMap2f, - (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, - GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, - GLint vorder, const GLfloat * points)) -SDL_PROC_UNUSED (void, glMapGrid1d, (GLint un, GLdouble u1, GLdouble u2)) -SDL_PROC_UNUSED (void, glMapGrid1f, (GLint un, GLfloat u1, GLfloat u2)) -SDL_PROC_UNUSED (void, glMapGrid2d, - (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, - GLdouble v2)) -SDL_PROC_UNUSED (void, glMapGrid2f, - (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, - GLfloat v2)) -SDL_PROC_UNUSED (void, glMaterialf, - (GLenum face, GLenum pname, GLfloat param)) -SDL_PROC_UNUSED (void, glMaterialfv, - (GLenum face, GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED (void, glMateriali, (GLenum face, GLenum pname, GLint param)) -SDL_PROC_UNUSED (void, glMaterialiv, - (GLenum face, GLenum pname, const GLint * params)) -SDL_PROC (void, glMatrixMode, (GLenum mode)) -SDL_PROC_UNUSED (void, glMultMatrixd, (const GLdouble * m)) -SDL_PROC_UNUSED (void, glMultMatrixf, (const GLfloat * m)) -SDL_PROC_UNUSED (void, glNewList, (GLuint list, GLenum mode)) -SDL_PROC_UNUSED (void, glNormal3b, (GLbyte nx, GLbyte ny, GLbyte nz)) -SDL_PROC_UNUSED (void, glNormal3bv, (const GLbyte * v)) -SDL_PROC_UNUSED (void, glNormal3d, (GLdouble nx, GLdouble ny, GLdouble nz)) -SDL_PROC_UNUSED (void, glNormal3dv, (const GLdouble * v)) -SDL_PROC_UNUSED (void, glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz)) -SDL_PROC_UNUSED (void, glNormal3fv, (const GLfloat * v)) -SDL_PROC_UNUSED (void, glNormal3i, (GLint nx, GLint ny, GLint nz)) -SDL_PROC_UNUSED (void, glNormal3iv, (const GLint * v)) -SDL_PROC_UNUSED (void, glNormal3s, (GLshort nx, GLshort ny, GLshort nz)) -SDL_PROC_UNUSED (void, glNormal3sv, (const GLshort * v)) -SDL_PROC_UNUSED (void, glNormalPointer, - (GLenum type, GLsizei stride, const GLvoid * pointer)) -SDL_PROC (void, glOrtho, - (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, - GLdouble zNear, GLdouble zFar)) -SDL_PROC_UNUSED (void, glPassThrough, (GLfloat token)) -SDL_PROC_UNUSED (void, glPixelMapfv, - (GLenum map, GLsizei mapsize, const GLfloat * values)) -SDL_PROC_UNUSED (void, glPixelMapuiv, - (GLenum map, GLsizei mapsize, const GLuint * values)) -SDL_PROC_UNUSED (void, glPixelMapusv, - (GLenum map, GLsizei mapsize, const GLushort * values)) -SDL_PROC_UNUSED (void, glPixelStoref, (GLenum pname, GLfloat param)) -SDL_PROC (void, glPixelStorei, (GLenum pname, GLint param)) -SDL_PROC_UNUSED (void, glPixelTransferf, (GLenum pname, GLfloat param)) -SDL_PROC_UNUSED (void, glPixelTransferi, (GLenum pname, GLint param)) -SDL_PROC_UNUSED (void, glPixelZoom, (GLfloat xfactor, GLfloat yfactor)) -SDL_PROC_UNUSED (void, glPointSize, (GLfloat size)) -SDL_PROC_UNUSED (void, glPolygonMode, (GLenum face, GLenum mode)) -SDL_PROC_UNUSED (void, glPolygonOffset, (GLfloat factor, GLfloat units)) -SDL_PROC_UNUSED (void, glPolygonStipple, (const GLubyte * mask)) -SDL_PROC (void, glPopAttrib, (void)) -SDL_PROC (void, glPopClientAttrib, (void)) -SDL_PROC (void, glPopMatrix, (void)) -SDL_PROC_UNUSED (void, glPopName, (void)) -SDL_PROC_UNUSED (void, glPrioritizeTextures, - (GLsizei n, const GLuint * textures, - const GLclampf * priorities)) -SDL_PROC (void, glPushAttrib, (GLbitfield mask)) -SDL_PROC (void, glPushClientAttrib, (GLbitfield mask)) -SDL_PROC (void, glPushMatrix, (void)) -SDL_PROC_UNUSED (void, glPushName, (GLuint name)) -SDL_PROC_UNUSED (void, glRasterPos2d, (GLdouble x, GLdouble y)) -SDL_PROC_UNUSED (void, glRasterPos2dv, (const GLdouble * v)) -SDL_PROC_UNUSED (void, glRasterPos2f, (GLfloat x, GLfloat y)) -SDL_PROC_UNUSED (void, glRasterPos2fv, (const GLfloat * v)) -SDL_PROC_UNUSED (void, glRasterPos2i, (GLint x, GLint y)) -SDL_PROC_UNUSED (void, glRasterPos2iv, (const GLint * v)) -SDL_PROC_UNUSED (void, glRasterPos2s, (GLshort x, GLshort y)) -SDL_PROC_UNUSED (void, glRasterPos2sv, (const GLshort * v)) -SDL_PROC_UNUSED (void, glRasterPos3d, (GLdouble x, GLdouble y, GLdouble z)) -SDL_PROC_UNUSED (void, glRasterPos3dv, (const GLdouble * v)) -SDL_PROC_UNUSED (void, glRasterPos3f, (GLfloat x, GLfloat y, GLfloat z)) -SDL_PROC_UNUSED (void, glRasterPos3fv, (const GLfloat * v)) -SDL_PROC_UNUSED (void, glRasterPos3i, (GLint x, GLint y, GLint z)) -SDL_PROC_UNUSED (void, glRasterPos3iv, (const GLint * v)) -SDL_PROC_UNUSED (void, glRasterPos3s, (GLshort x, GLshort y, GLshort z)) -SDL_PROC_UNUSED (void, glRasterPos3sv, (const GLshort * v)) -SDL_PROC_UNUSED (void, glRasterPos4d, - (GLdouble x, GLdouble y, GLdouble z, GLdouble w)) -SDL_PROC_UNUSED (void, glRasterPos4dv, (const GLdouble * v)) -SDL_PROC_UNUSED (void, glRasterPos4f, - (GLfloat x, GLfloat y, GLfloat z, GLfloat w)) -SDL_PROC_UNUSED (void, glRasterPos4fv, (const GLfloat * v)) -SDL_PROC_UNUSED (void, glRasterPos4i, (GLint x, GLint y, GLint z, GLint w)) -SDL_PROC_UNUSED (void, glRasterPos4iv, (const GLint * v)) -SDL_PROC_UNUSED (void, glRasterPos4s, - (GLshort x, GLshort y, GLshort z, GLshort w)) -SDL_PROC_UNUSED (void, glRasterPos4sv, (const GLshort * v)) -SDL_PROC_UNUSED (void, glReadBuffer, (GLenum mode)) -SDL_PROC (void, glReadPixels, - (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, - GLenum type, GLvoid * pixels)) -SDL_PROC_UNUSED (void, glRectd, - (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)) -SDL_PROC_UNUSED (void, glRectdv, (const GLdouble * v1, const GLdouble * v2)) -SDL_PROC_UNUSED (void, glRectf, - (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)) -SDL_PROC_UNUSED (void, glRectfv, (const GLfloat * v1, const GLfloat * v2)) -SDL_PROC_UNUSED (void, glRecti, (GLint x1, GLint y1, GLint x2, GLint y2)) -SDL_PROC_UNUSED (void, glRectiv, (const GLint * v1, const GLint * v2)) -SDL_PROC_UNUSED (void, glRects, - (GLshort x1, GLshort y1, GLshort x2, GLshort y2)) -SDL_PROC_UNUSED (void, glRectsv, (const GLshort * v1, const GLshort * v2)) -SDL_PROC_UNUSED (GLint, glRenderMode, (GLenum mode)) -SDL_PROC_UNUSED (void, glRotated, - (GLdouble angle, GLdouble x, GLdouble y, GLdouble z)) -SDL_PROC_UNUSED (void, glRotatef, - (GLfloat angle, GLfloat x, GLfloat y, GLfloat z)) -SDL_PROC_UNUSED (void, glScaled, (GLdouble x, GLdouble y, GLdouble z)) -SDL_PROC_UNUSED (void, glScalef, (GLfloat x, GLfloat y, GLfloat z)) -SDL_PROC_UNUSED (void, glScissor, - (GLint x, GLint y, GLsizei width, GLsizei height)) -SDL_PROC_UNUSED (void, glSelectBuffer, (GLsizei size, GLuint * buffer)) -SDL_PROC_UNUSED (void, glShadeModel, (GLenum mode)) -SDL_PROC_UNUSED (void, glStencilFunc, (GLenum func, GLint ref, GLuint mask)) -SDL_PROC_UNUSED (void, glStencilMask, (GLuint mask)) -SDL_PROC_UNUSED (void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass)) -SDL_PROC_UNUSED (void, glTexCoord1d, (GLdouble s)) -SDL_PROC_UNUSED (void, glTexCoord1dv, (const GLdouble * v)) -SDL_PROC_UNUSED (void, glTexCoord1f, (GLfloat s)) -SDL_PROC_UNUSED (void, glTexCoord1fv, (const GLfloat * v)) -SDL_PROC_UNUSED (void, glTexCoord1i, (GLint s)) -SDL_PROC_UNUSED (void, glTexCoord1iv, (const GLint * v)) -SDL_PROC_UNUSED (void, glTexCoord1s, (GLshort s)) -SDL_PROC_UNUSED (void, glTexCoord1sv, (const GLshort * v)) -SDL_PROC_UNUSED (void, glTexCoord2d, (GLdouble s, GLdouble t)) -SDL_PROC_UNUSED (void, glTexCoord2dv, (const GLdouble * v)) -SDL_PROC (void, glTexCoord2f, (GLfloat s, GLfloat t)) -SDL_PROC_UNUSED (void, glTexCoord2fv, (const GLfloat * v)) -SDL_PROC_UNUSED (void, glTexCoord2i, (GLint s, GLint t)) -SDL_PROC_UNUSED (void, glTexCoord2iv, (const GLint * v)) -SDL_PROC_UNUSED (void, glTexCoord2s, (GLshort s, GLshort t)) -SDL_PROC_UNUSED (void, glTexCoord2sv, (const GLshort * v)) -SDL_PROC_UNUSED (void, glTexCoord3d, (GLdouble s, GLdouble t, GLdouble r)) -SDL_PROC_UNUSED (void, glTexCoord3dv, (const GLdouble * v)) -SDL_PROC_UNUSED (void, glTexCoord3f, (GLfloat s, GLfloat t, GLfloat r)) -SDL_PROC_UNUSED (void, glTexCoord3fv, (const GLfloat * v)) -SDL_PROC_UNUSED (void, glTexCoord3i, (GLint s, GLint t, GLint r)) -SDL_PROC_UNUSED (void, glTexCoord3iv, (const GLint * v)) -SDL_PROC_UNUSED (void, glTexCoord3s, (GLshort s, GLshort t, GLshort r)) -SDL_PROC_UNUSED (void, glTexCoord3sv, (const GLshort * v)) -SDL_PROC_UNUSED (void, glTexCoord4d, - (GLdouble s, GLdouble t, GLdouble r, GLdouble q)) -SDL_PROC_UNUSED (void, glTexCoord4dv, (const GLdouble * v)) -SDL_PROC_UNUSED (void, glTexCoord4f, - (GLfloat s, GLfloat t, GLfloat r, GLfloat q)) -SDL_PROC_UNUSED (void, glTexCoord4fv, (const GLfloat * v)) -SDL_PROC_UNUSED (void, glTexCoord4i, (GLint s, GLint t, GLint r, GLint q)) -SDL_PROC_UNUSED (void, glTexCoord4iv, (const GLint * v)) -SDL_PROC_UNUSED (void, glTexCoord4s, - (GLshort s, GLshort t, GLshort r, GLshort q)) -SDL_PROC_UNUSED (void, glTexCoord4sv, (const GLshort * v)) -SDL_PROC_UNUSED (void, glTexCoordPointer, - (GLint size, GLenum type, GLsizei stride, - const GLvoid * pointer)) -SDL_PROC (void, glTexEnvf, (GLenum target, GLenum pname, GLfloat param)) -SDL_PROC_UNUSED (void, glTexEnvfv, - (GLenum target, GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED (void, glTexEnvi, (GLenum target, GLenum pname, GLint param)) -SDL_PROC_UNUSED (void, glTexEnviv, - (GLenum target, GLenum pname, const GLint * params)) -SDL_PROC_UNUSED (void, glTexGend, - (GLenum coord, GLenum pname, GLdouble param)) -SDL_PROC_UNUSED (void, glTexGendv, - (GLenum coord, GLenum pname, const GLdouble * params)) -SDL_PROC_UNUSED (void, glTexGenf, (GLenum coord, GLenum pname, GLfloat param)) -SDL_PROC_UNUSED (void, glTexGenfv, - (GLenum coord, GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED (void, glTexGeni, (GLenum coord, GLenum pname, GLint param)) -SDL_PROC_UNUSED (void, glTexGeniv, - (GLenum coord, GLenum pname, const GLint * params)) -SDL_PROC_UNUSED (void, glTexImage1D, - (GLenum target, GLint level, GLint internalformat, - GLsizei width, GLint border, GLenum format, GLenum type, - const GLvoid * pixels)) -SDL_PROC (void, glTexImage2D, - (GLenum target, GLint level, GLint internalformat, GLsizei width, - GLsizei height, GLint border, GLenum format, GLenum type, - const GLvoid * pixels)) -SDL_PROC_UNUSED (void, glTexParameterf, - (GLenum target, GLenum pname, GLfloat param)) -SDL_PROC_UNUSED (void, glTexParameterfv, - (GLenum target, GLenum pname, const GLfloat * params)) -SDL_PROC (void, glTexParameteri, (GLenum target, GLenum pname, GLint param)) -SDL_PROC_UNUSED (void, glTexParameteriv, - (GLenum target, GLenum pname, const GLint * params)) -SDL_PROC_UNUSED (void, glTexSubImage1D, - (GLenum target, GLint level, GLint xoffset, GLsizei width, - GLenum format, GLenum type, const GLvoid * pixels)) -SDL_PROC (void, glTexSubImage2D, - (GLenum target, GLint level, GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, GLenum format, GLenum type, - const GLvoid * pixels)) -SDL_PROC (void, glTranslated, (GLdouble x, GLdouble y, GLdouble z)) -SDL_PROC_UNUSED (void, glTranslatef, (GLfloat x, GLfloat y, GLfloat z)) -SDL_PROC_UNUSED (void, glVertex2d, (GLdouble x, GLdouble y)) -SDL_PROC_UNUSED (void, glVertex2dv, (const GLdouble * v)) -SDL_PROC_UNUSED (void, glVertex2f, (GLfloat x, GLfloat y)) -SDL_PROC_UNUSED (void, glVertex2fv, (const GLfloat * v)) -SDL_PROC (void, glVertex2i, (GLint x, GLint y)) -SDL_PROC_UNUSED (void, glVertex2iv, (const GLint * v)) -SDL_PROC_UNUSED (void, glVertex2s, (GLshort x, GLshort y)) -SDL_PROC_UNUSED (void, glVertex2sv, (const GLshort * v)) -SDL_PROC_UNUSED (void, glVertex3d, (GLdouble x, GLdouble y, GLdouble z)) -SDL_PROC_UNUSED (void, glVertex3dv, (const GLdouble * v)) -SDL_PROC_UNUSED (void, glVertex3f, (GLfloat x, GLfloat y, GLfloat z)) -SDL_PROC_UNUSED (void, glVertex3fv, (const GLfloat * v)) -SDL_PROC_UNUSED (void, glVertex3i, (GLint x, GLint y, GLint z)) -SDL_PROC_UNUSED (void, glVertex3iv, (const GLint * v)) -SDL_PROC_UNUSED (void, glVertex3s, (GLshort x, GLshort y, GLshort z)) -SDL_PROC_UNUSED (void, glVertex3sv, (const GLshort * v)) -SDL_PROC_UNUSED (void, glVertex4d, - (GLdouble x, GLdouble y, GLdouble z, GLdouble w)) -SDL_PROC_UNUSED (void, glVertex4dv, (const GLdouble * v)) -SDL_PROC_UNUSED (void, glVertex4f, - (GLfloat x, GLfloat y, GLfloat z, GLfloat w)) -SDL_PROC_UNUSED (void, glVertex4fv, (const GLfloat * v)) -SDL_PROC_UNUSED (void, glVertex4i, (GLint x, GLint y, GLint z, GLint w)) -SDL_PROC_UNUSED (void, glVertex4iv, (const GLint * v)) -SDL_PROC_UNUSED (void, glVertex4s, - (GLshort x, GLshort y, GLshort z, GLshort w)) -SDL_PROC_UNUSED (void, glVertex4sv, (const GLshort * v)) -SDL_PROC_UNUSED (void, glVertexPointer, - (GLint size, GLenum type, GLsizei stride, - const GLvoid * pointer)) -SDL_PROC (void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height)) +SDL_PROC_UNUSED(void, glAccum, (GLenum, GLfloat)) +SDL_PROC_UNUSED(void, glAlphaFunc, (GLenum, GLclampf)) +SDL_PROC_UNUSED(GLboolean, glAreTexturesResident, + (GLsizei, const GLuint *, GLboolean *)) +SDL_PROC_UNUSED(void, glArrayElement, (GLint)) +SDL_PROC(void, glBegin, (GLenum)) +SDL_PROC(void, glBindTexture, (GLenum, GLuint)) +SDL_PROC_UNUSED(void, glBitmap, + (GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, + const GLubyte *)) +SDL_PROC(void, glBlendFunc, (GLenum, GLenum)) +SDL_PROC_UNUSED(void, glCallList, (GLuint)) +SDL_PROC_UNUSED(void, glCallLists, (GLsizei, GLenum, const GLvoid *)) +SDL_PROC_UNUSED(void, glClear, (GLbitfield)) +SDL_PROC_UNUSED(void, glClearAccum, (GLfloat, GLfloat, GLfloat, GLfloat)) +SDL_PROC_UNUSED(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf)) +SDL_PROC_UNUSED(void, glClearDepth, (GLclampd)) +SDL_PROC_UNUSED(void, glClearIndex, (GLfloat)) +SDL_PROC_UNUSED(void, glClearStencil, (GLint)) +SDL_PROC_UNUSED(void, glClipPlane, (GLenum, const GLdouble *)) +SDL_PROC_UNUSED(void, glColor3b, (GLbyte, GLbyte, GLbyte)) +SDL_PROC_UNUSED(void, glColor3bv, (const GLbyte *)) +SDL_PROC_UNUSED(void, glColor3d, (GLdouble, GLdouble, GLdouble)) +SDL_PROC_UNUSED(void, glColor3dv, (const GLdouble *)) +SDL_PROC_UNUSED(void, glColor3f, (GLfloat, GLfloat, GLfloat)) +SDL_PROC_UNUSED(void, glColor3fv, (const GLfloat *)) +SDL_PROC_UNUSED(void, glColor3i, (GLint, GLint, GLint)) +SDL_PROC_UNUSED(void, glColor3iv, (const GLint *)) +SDL_PROC_UNUSED(void, glColor3s, (GLshort, GLshort, GLshort)) +SDL_PROC_UNUSED(void, glColor3sv, (const GLshort *)) +SDL_PROC(void, glColor3ub, (GLubyte, GLubyte, GLubyte)) +SDL_PROC_UNUSED(void, glColor3ubv, (const GLubyte *)) +SDL_PROC_UNUSED(void, glColor3ui, (GLuint, GLuint, GLuint)) +SDL_PROC_UNUSED(void, glColor3uiv, (const GLuint *)) +SDL_PROC_UNUSED(void, glColor3us, (GLushort, GLushort, GLushort)) +SDL_PROC_UNUSED(void, glColor3usv, (const GLushort *)) +SDL_PROC_UNUSED(void, glColor4b, (GLbyte, GLbyte, GLbyte, GLbyte)) +SDL_PROC_UNUSED(void, glColor4bv, (const GLbyte *)) +SDL_PROC_UNUSED(void, glColor4d, (GLdouble, GLdouble, GLdouble, GLdouble)) +SDL_PROC_UNUSED(void, glColor4dv, (const GLdouble *)) +SDL_PROC(void, glColor4f, (GLfloat, GLfloat, GLfloat, GLfloat)) +SDL_PROC_UNUSED(void, glColor4fv, (const GLfloat *)) +SDL_PROC_UNUSED(void, glColor4i, (GLint, GLint, GLint, GLint)) +SDL_PROC_UNUSED(void, glColor4iv, (const GLint *)) +SDL_PROC_UNUSED(void, glColor4s, (GLshort, GLshort, GLshort, GLshort)) +SDL_PROC_UNUSED(void, glColor4sv, (const GLshort *)) +SDL_PROC(void, glColor4ub, + (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)) +SDL_PROC_UNUSED(void, glColor4ubv, (const GLubyte * v)) +SDL_PROC_UNUSED(void, glColor4ui, + (GLuint red, GLuint green, GLuint blue, GLuint alpha)) +SDL_PROC_UNUSED(void, glColor4uiv, (const GLuint * v)) +SDL_PROC_UNUSED(void, glColor4us, + (GLushort red, GLushort green, GLushort blue, GLushort alpha)) +SDL_PROC_UNUSED(void, glColor4usv, (const GLushort * v)) +SDL_PROC_UNUSED(void, glColorMask, + (GLboolean red, GLboolean green, GLboolean blue, + GLboolean alpha)) +SDL_PROC_UNUSED(void, glColorMaterial, (GLenum face, GLenum mode)) +SDL_PROC_UNUSED(void, glColorPointer, + (GLint size, GLenum type, GLsizei stride, + const GLvoid * pointer)) +SDL_PROC_UNUSED(void, glCopyPixels, + (GLint x, GLint y, GLsizei width, GLsizei height, + GLenum type)) +SDL_PROC_UNUSED(void, glCopyTexImage1D, + (GLenum target, GLint level, GLenum internalFormat, GLint x, + GLint y, GLsizei width, GLint border)) +SDL_PROC_UNUSED(void, glCopyTexImage2D, + (GLenum target, GLint level, GLenum internalFormat, GLint x, + GLint y, GLsizei width, GLsizei height, GLint border)) +SDL_PROC_UNUSED(void, glCopyTexSubImage1D, + (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, + GLsizei width)) +SDL_PROC_UNUSED(void, glCopyTexSubImage2D, + (GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLsizei height)) +SDL_PROC_UNUSED(void, glCullFace, (GLenum mode)) +SDL_PROC_UNUSED(void, glDeleteLists, (GLuint list, GLsizei range)) +SDL_PROC(void, glDeleteTextures, (GLsizei n, const GLuint * textures)) +SDL_PROC_UNUSED(void, glDepthFunc, (GLenum func)) +SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag)) +SDL_PROC_UNUSED(void, glDepthRange, (GLclampd zNear, GLclampd zFar)) +SDL_PROC(void, glDisable, (GLenum cap)) +SDL_PROC_UNUSED(void, glDisableClientState, (GLenum array)) +SDL_PROC_UNUSED(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count)) +SDL_PROC(void, glDrawBuffer, (GLenum mode)) +SDL_PROC_UNUSED(void, glDrawElements, + (GLenum mode, GLsizei count, GLenum type, + const GLvoid * indices)) +SDL_PROC_UNUSED(void, glDrawPixels, + (GLsizei width, GLsizei height, GLenum format, GLenum type, + const GLvoid * pixels)) +SDL_PROC_UNUSED(void, glEdgeFlag, (GLboolean flag)) +SDL_PROC_UNUSED(void, glEdgeFlagPointer, + (GLsizei stride, const GLvoid * pointer)) +SDL_PROC_UNUSED(void, glEdgeFlagv, (const GLboolean * flag)) +SDL_PROC(void, glEnable, (GLenum cap)) +SDL_PROC_UNUSED(void, glEnableClientState, (GLenum array)) +SDL_PROC(void, glEnd, (void)) +SDL_PROC_UNUSED(void, glEndList, (void)) +SDL_PROC_UNUSED(void, glEvalCoord1d, (GLdouble u)) +SDL_PROC_UNUSED(void, glEvalCoord1dv, (const GLdouble * u)) +SDL_PROC_UNUSED(void, glEvalCoord1f, (GLfloat u)) +SDL_PROC_UNUSED(void, glEvalCoord1fv, (const GLfloat * u)) +SDL_PROC_UNUSED(void, glEvalCoord2d, (GLdouble u, GLdouble v)) +SDL_PROC_UNUSED(void, glEvalCoord2dv, (const GLdouble * u)) +SDL_PROC_UNUSED(void, glEvalCoord2f, (GLfloat u, GLfloat v)) +SDL_PROC_UNUSED(void, glEvalCoord2fv, (const GLfloat * u)) +SDL_PROC_UNUSED(void, glEvalMesh1, (GLenum mode, GLint i1, GLint i2)) +SDL_PROC_UNUSED(void, glEvalMesh2, + (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)) +SDL_PROC_UNUSED(void, glEvalPoint1, (GLint i)) +SDL_PROC_UNUSED(void, glEvalPoint2, (GLint i, GLint j)) +SDL_PROC_UNUSED(void, glFeedbackBuffer, + (GLsizei size, GLenum type, GLfloat * buffer)) +SDL_PROC(void, glFinish, (void)) +SDL_PROC(void, glFlush, (void)) +SDL_PROC_UNUSED(void, glFogf, (GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glFogfv, (GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glFogi, (GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glFogiv, (GLenum pname, const GLint * params)) +SDL_PROC_UNUSED(void, glFrontFace, (GLenum mode)) +SDL_PROC_UNUSED(void, glFrustum, + (GLdouble left, GLdouble right, GLdouble bottom, + GLdouble top, GLdouble zNear, GLdouble zFar)) +SDL_PROC_UNUSED(GLuint, glGenLists, (GLsizei range)) +SDL_PROC(void, glGenTextures, (GLsizei n, GLuint * textures)) +SDL_PROC_UNUSED(void, glGetBooleanv, (GLenum pname, GLboolean * params)) +SDL_PROC_UNUSED(void, glGetClipPlane, (GLenum plane, GLdouble * equation)) +SDL_PROC_UNUSED(void, glGetDoublev, (GLenum pname, GLdouble * params)) +SDL_PROC(GLenum, glGetError, (void)) +SDL_PROC_UNUSED(void, glGetFloatv, (GLenum pname, GLfloat * params)) +SDL_PROC(void, glGetIntegerv, (GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glGetLightfv, + (GLenum light, GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glGetLightiv, + (GLenum light, GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glGetMapdv, (GLenum target, GLenum query, GLdouble * v)) +SDL_PROC_UNUSED(void, glGetMapfv, (GLenum target, GLenum query, GLfloat * v)) +SDL_PROC_UNUSED(void, glGetMapiv, (GLenum target, GLenum query, GLint * v)) +SDL_PROC_UNUSED(void, glGetMaterialfv, + (GLenum face, GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glGetMaterialiv, + (GLenum face, GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glGetPixelMapfv, (GLenum map, GLfloat * values)) +SDL_PROC_UNUSED(void, glGetPixelMapuiv, (GLenum map, GLuint * values)) +SDL_PROC_UNUSED(void, glGetPixelMapusv, (GLenum map, GLushort * values)) +SDL_PROC_UNUSED(void, glGetPointerv, (GLenum pname, GLvoid * *params)) +SDL_PROC_UNUSED(void, glGetPolygonStipple, (GLubyte * mask)) +SDL_PROC(const GLubyte *, glGetString, (GLenum name)) +SDL_PROC_UNUSED(void, glGetTexEnvfv, + (GLenum target, GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glGetTexEnviv, + (GLenum target, GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glGetTexGendv, + (GLenum coord, GLenum pname, GLdouble * params)) +SDL_PROC_UNUSED(void, glGetTexGenfv, + (GLenum coord, GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glGetTexGeniv, + (GLenum coord, GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glGetTexImage, + (GLenum target, GLint level, GLenum format, GLenum type, + GLvoid * pixels)) +SDL_PROC_UNUSED(void, glGetTexLevelParameterfv, + (GLenum target, GLint level, GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glGetTexLevelParameteriv, + (GLenum target, GLint level, GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glGetTexParameterfv, + (GLenum target, GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glGetTexParameteriv, + (GLenum target, GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glHint, (GLenum target, GLenum mode)) +SDL_PROC_UNUSED(void, glIndexMask, (GLuint mask)) +SDL_PROC_UNUSED(void, glIndexPointer, + (GLenum type, GLsizei stride, const GLvoid * pointer)) +SDL_PROC_UNUSED(void, glIndexd, (GLdouble c)) +SDL_PROC_UNUSED(void, glIndexdv, (const GLdouble * c)) +SDL_PROC_UNUSED(void, glIndexf, (GLfloat c)) +SDL_PROC_UNUSED(void, glIndexfv, (const GLfloat * c)) +SDL_PROC_UNUSED(void, glIndexi, (GLint c)) +SDL_PROC_UNUSED(void, glIndexiv, (const GLint * c)) +SDL_PROC_UNUSED(void, glIndexs, (GLshort c)) +SDL_PROC_UNUSED(void, glIndexsv, (const GLshort * c)) +SDL_PROC_UNUSED(void, glIndexub, (GLubyte c)) +SDL_PROC_UNUSED(void, glIndexubv, (const GLubyte * c)) +SDL_PROC_UNUSED(void, glInitNames, (void)) +SDL_PROC_UNUSED(void, glInterleavedArrays, + (GLenum format, GLsizei stride, const GLvoid * pointer)) +SDL_PROC_UNUSED(GLboolean, glIsEnabled, (GLenum cap)) +SDL_PROC_UNUSED(GLboolean, glIsList, (GLuint list)) +SDL_PROC_UNUSED(GLboolean, glIsTexture, (GLuint texture)) +SDL_PROC_UNUSED(void, glLightModelf, (GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glLightModelfv, (GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glLightModeli, (GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glLightModeliv, (GLenum pname, const GLint * params)) +SDL_PROC_UNUSED(void, glLightf, (GLenum light, GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glLightfv, + (GLenum light, GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glLighti, (GLenum light, GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glLightiv, + (GLenum light, GLenum pname, const GLint * params)) +SDL_PROC_UNUSED(void, glLineStipple, (GLint factor, GLushort pattern)) +SDL_PROC_UNUSED(void, glLineWidth, (GLfloat width)) +SDL_PROC_UNUSED(void, glListBase, (GLuint base)) +SDL_PROC(void, glLoadIdentity, (void)) +SDL_PROC_UNUSED(void, glLoadMatrixd, (const GLdouble * m)) +SDL_PROC_UNUSED(void, glLoadMatrixf, (const GLfloat * m)) +SDL_PROC_UNUSED(void, glLoadName, (GLuint name)) +SDL_PROC_UNUSED(void, glLogicOp, (GLenum opcode)) +SDL_PROC_UNUSED(void, glMap1d, + (GLenum target, GLdouble u1, GLdouble u2, GLint stride, + GLint order, const GLdouble * points)) +SDL_PROC_UNUSED(void, glMap1f, + (GLenum target, GLfloat u1, GLfloat u2, GLint stride, + GLint order, const GLfloat * points)) +SDL_PROC_UNUSED(void, glMap2d, + (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, + GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, + GLint vorder, const GLdouble * points)) +SDL_PROC_UNUSED(void, glMap2f, + (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, + GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, + GLint vorder, const GLfloat * points)) +SDL_PROC_UNUSED(void, glMapGrid1d, (GLint un, GLdouble u1, GLdouble u2)) +SDL_PROC_UNUSED(void, glMapGrid1f, (GLint un, GLfloat u1, GLfloat u2)) +SDL_PROC_UNUSED(void, glMapGrid2d, + (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, + GLdouble v2)) +SDL_PROC_UNUSED(void, glMapGrid2f, + (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, + GLfloat v2)) +SDL_PROC_UNUSED(void, glMaterialf, (GLenum face, GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glMaterialfv, + (GLenum face, GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glMateriali, (GLenum face, GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glMaterialiv, + (GLenum face, GLenum pname, const GLint * params)) +SDL_PROC(void, glMatrixMode, (GLenum mode)) +SDL_PROC_UNUSED(void, glMultMatrixd, (const GLdouble * m)) +SDL_PROC_UNUSED(void, glMultMatrixf, (const GLfloat * m)) +SDL_PROC_UNUSED(void, glNewList, (GLuint list, GLenum mode)) +SDL_PROC_UNUSED(void, glNormal3b, (GLbyte nx, GLbyte ny, GLbyte nz)) +SDL_PROC_UNUSED(void, glNormal3bv, (const GLbyte * v)) +SDL_PROC_UNUSED(void, glNormal3d, (GLdouble nx, GLdouble ny, GLdouble nz)) +SDL_PROC_UNUSED(void, glNormal3dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz)) +SDL_PROC_UNUSED(void, glNormal3fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glNormal3i, (GLint nx, GLint ny, GLint nz)) +SDL_PROC_UNUSED(void, glNormal3iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glNormal3s, (GLshort nx, GLshort ny, GLshort nz)) +SDL_PROC_UNUSED(void, glNormal3sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glNormalPointer, + (GLenum type, GLsizei stride, const GLvoid * pointer)) +SDL_PROC(void, glOrtho, + (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, + GLdouble zNear, GLdouble zFar)) +SDL_PROC_UNUSED(void, glPassThrough, (GLfloat token)) +SDL_PROC_UNUSED(void, glPixelMapfv, + (GLenum map, GLsizei mapsize, const GLfloat * values)) +SDL_PROC_UNUSED(void, glPixelMapuiv, + (GLenum map, GLsizei mapsize, const GLuint * values)) +SDL_PROC_UNUSED(void, glPixelMapusv, + (GLenum map, GLsizei mapsize, const GLushort * values)) +SDL_PROC_UNUSED(void, glPixelStoref, (GLenum pname, GLfloat param)) +SDL_PROC(void, glPixelStorei, (GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glPixelTransferf, (GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glPixelTransferi, (GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glPixelZoom, (GLfloat xfactor, GLfloat yfactor)) +SDL_PROC_UNUSED(void, glPointSize, (GLfloat size)) +SDL_PROC_UNUSED(void, glPolygonMode, (GLenum face, GLenum mode)) +SDL_PROC_UNUSED(void, glPolygonOffset, (GLfloat factor, GLfloat units)) +SDL_PROC_UNUSED(void, glPolygonStipple, (const GLubyte * mask)) +SDL_PROC(void, glPopAttrib, (void)) +SDL_PROC(void, glPopClientAttrib, (void)) +SDL_PROC(void, glPopMatrix, (void)) +SDL_PROC_UNUSED(void, glPopName, (void)) +SDL_PROC_UNUSED(void, glPrioritizeTextures, + (GLsizei n, const GLuint * textures, + const GLclampf * priorities)) +SDL_PROC(void, glPushAttrib, (GLbitfield mask)) +SDL_PROC(void, glPushClientAttrib, (GLbitfield mask)) +SDL_PROC(void, glPushMatrix, (void)) +SDL_PROC_UNUSED(void, glPushName, (GLuint name)) +SDL_PROC_UNUSED(void, glRasterPos2d, (GLdouble x, GLdouble y)) +SDL_PROC_UNUSED(void, glRasterPos2dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glRasterPos2f, (GLfloat x, GLfloat y)) +SDL_PROC_UNUSED(void, glRasterPos2fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glRasterPos2i, (GLint x, GLint y)) +SDL_PROC_UNUSED(void, glRasterPos2iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glRasterPos2s, (GLshort x, GLshort y)) +SDL_PROC_UNUSED(void, glRasterPos2sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glRasterPos3d, (GLdouble x, GLdouble y, GLdouble z)) +SDL_PROC_UNUSED(void, glRasterPos3dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glRasterPos3f, (GLfloat x, GLfloat y, GLfloat z)) +SDL_PROC_UNUSED(void, glRasterPos3fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glRasterPos3i, (GLint x, GLint y, GLint z)) +SDL_PROC_UNUSED(void, glRasterPos3iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glRasterPos3s, (GLshort x, GLshort y, GLshort z)) +SDL_PROC_UNUSED(void, glRasterPos3sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glRasterPos4d, + (GLdouble x, GLdouble y, GLdouble z, GLdouble w)) +SDL_PROC_UNUSED(void, glRasterPos4dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glRasterPos4f, + (GLfloat x, GLfloat y, GLfloat z, GLfloat w)) +SDL_PROC_UNUSED(void, glRasterPos4fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glRasterPos4i, (GLint x, GLint y, GLint z, GLint w)) +SDL_PROC_UNUSED(void, glRasterPos4iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glRasterPos4s, + (GLshort x, GLshort y, GLshort z, GLshort w)) +SDL_PROC_UNUSED(void, glRasterPos4sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glReadBuffer, (GLenum mode)) +SDL_PROC(void, glReadPixels, + (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, + GLenum type, GLvoid * pixels)) +SDL_PROC_UNUSED(void, glRectd, + (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)) +SDL_PROC_UNUSED(void, glRectdv, (const GLdouble * v1, const GLdouble * v2)) +SDL_PROC_UNUSED(void, glRectf, + (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)) +SDL_PROC_UNUSED(void, glRectfv, (const GLfloat * v1, const GLfloat * v2)) +SDL_PROC_UNUSED(void, glRecti, (GLint x1, GLint y1, GLint x2, GLint y2)) +SDL_PROC_UNUSED(void, glRectiv, (const GLint * v1, const GLint * v2)) +SDL_PROC_UNUSED(void, glRects, + (GLshort x1, GLshort y1, GLshort x2, GLshort y2)) +SDL_PROC_UNUSED(void, glRectsv, (const GLshort * v1, const GLshort * v2)) +SDL_PROC_UNUSED(GLint, glRenderMode, (GLenum mode)) +SDL_PROC_UNUSED(void, glRotated, + (GLdouble angle, GLdouble x, GLdouble y, GLdouble z)) +SDL_PROC_UNUSED(void, glRotatef, + (GLfloat angle, GLfloat x, GLfloat y, GLfloat z)) +SDL_PROC_UNUSED(void, glScaled, (GLdouble x, GLdouble y, GLdouble z)) +SDL_PROC_UNUSED(void, glScalef, (GLfloat x, GLfloat y, GLfloat z)) +SDL_PROC_UNUSED(void, glScissor, + (GLint x, GLint y, GLsizei width, GLsizei height)) +SDL_PROC_UNUSED(void, glSelectBuffer, (GLsizei size, GLuint * buffer)) +SDL_PROC_UNUSED(void, glShadeModel, (GLenum mode)) +SDL_PROC_UNUSED(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask)) +SDL_PROC_UNUSED(void, glStencilMask, (GLuint mask)) +SDL_PROC_UNUSED(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass)) +SDL_PROC_UNUSED(void, glTexCoord1d, (GLdouble s)) +SDL_PROC_UNUSED(void, glTexCoord1dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glTexCoord1f, (GLfloat s)) +SDL_PROC_UNUSED(void, glTexCoord1fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glTexCoord1i, (GLint s)) +SDL_PROC_UNUSED(void, glTexCoord1iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glTexCoord1s, (GLshort s)) +SDL_PROC_UNUSED(void, glTexCoord1sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glTexCoord2d, (GLdouble s, GLdouble t)) +SDL_PROC_UNUSED(void, glTexCoord2dv, (const GLdouble * v)) +SDL_PROC(void, glTexCoord2f, (GLfloat s, GLfloat t)) +SDL_PROC_UNUSED(void, glTexCoord2fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glTexCoord2i, (GLint s, GLint t)) +SDL_PROC_UNUSED(void, glTexCoord2iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glTexCoord2s, (GLshort s, GLshort t)) +SDL_PROC_UNUSED(void, glTexCoord2sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glTexCoord3d, (GLdouble s, GLdouble t, GLdouble r)) +SDL_PROC_UNUSED(void, glTexCoord3dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glTexCoord3f, (GLfloat s, GLfloat t, GLfloat r)) +SDL_PROC_UNUSED(void, glTexCoord3fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glTexCoord3i, (GLint s, GLint t, GLint r)) +SDL_PROC_UNUSED(void, glTexCoord3iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glTexCoord3s, (GLshort s, GLshort t, GLshort r)) +SDL_PROC_UNUSED(void, glTexCoord3sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glTexCoord4d, + (GLdouble s, GLdouble t, GLdouble r, GLdouble q)) +SDL_PROC_UNUSED(void, glTexCoord4dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glTexCoord4f, + (GLfloat s, GLfloat t, GLfloat r, GLfloat q)) +SDL_PROC_UNUSED(void, glTexCoord4fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glTexCoord4i, (GLint s, GLint t, GLint r, GLint q)) +SDL_PROC_UNUSED(void, glTexCoord4iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glTexCoord4s, + (GLshort s, GLshort t, GLshort r, GLshort q)) +SDL_PROC_UNUSED(void, glTexCoord4sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glTexCoordPointer, + (GLint size, GLenum type, GLsizei stride, + const GLvoid * pointer)) +SDL_PROC(void, glTexEnvf, (GLenum target, GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glTexEnvfv, + (GLenum target, GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glTexEnvi, (GLenum target, GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glTexEnviv, + (GLenum target, GLenum pname, const GLint * params)) +SDL_PROC_UNUSED(void, glTexGend, (GLenum coord, GLenum pname, GLdouble param)) +SDL_PROC_UNUSED(void, glTexGendv, + (GLenum coord, GLenum pname, const GLdouble * params)) +SDL_PROC_UNUSED(void, glTexGenf, (GLenum coord, GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glTexGenfv, + (GLenum coord, GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glTexGeni, (GLenum coord, GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glTexGeniv, + (GLenum coord, GLenum pname, const GLint * params)) +SDL_PROC_UNUSED(void, glTexImage1D, + (GLenum target, GLint level, GLint internalformat, + GLsizei width, GLint border, GLenum format, GLenum type, + const GLvoid * pixels)) +SDL_PROC(void, glTexImage2D, + (GLenum target, GLint level, GLint internalformat, GLsizei width, + GLsizei height, GLint border, GLenum format, GLenum type, + const GLvoid * pixels)) +SDL_PROC_UNUSED(void, glTexParameterf, + (GLenum target, GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glTexParameterfv, + (GLenum target, GLenum pname, const GLfloat * params)) +SDL_PROC(void, glTexParameteri, (GLenum target, GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glTexParameteriv, + (GLenum target, GLenum pname, const GLint * params)) +SDL_PROC_UNUSED(void, glTexSubImage1D, + (GLenum target, GLint level, GLint xoffset, GLsizei width, + GLenum format, GLenum type, const GLvoid * pixels)) +SDL_PROC(void, glTexSubImage2D, + (GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLenum type, + const GLvoid * pixels)) +SDL_PROC(void, glTranslated, (GLdouble x, GLdouble y, GLdouble z)) +SDL_PROC_UNUSED(void, glTranslatef, (GLfloat x, GLfloat y, GLfloat z)) +SDL_PROC_UNUSED(void, glVertex2d, (GLdouble x, GLdouble y)) +SDL_PROC_UNUSED(void, glVertex2dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glVertex2f, (GLfloat x, GLfloat y)) +SDL_PROC_UNUSED(void, glVertex2fv, (const GLfloat * v)) +SDL_PROC(void, glVertex2i, (GLint x, GLint y)) +SDL_PROC_UNUSED(void, glVertex2iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glVertex2s, (GLshort x, GLshort y)) +SDL_PROC_UNUSED(void, glVertex2sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glVertex3d, (GLdouble x, GLdouble y, GLdouble z)) +SDL_PROC_UNUSED(void, glVertex3dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glVertex3f, (GLfloat x, GLfloat y, GLfloat z)) +SDL_PROC_UNUSED(void, glVertex3fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glVertex3i, (GLint x, GLint y, GLint z)) +SDL_PROC_UNUSED(void, glVertex3iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glVertex3s, (GLshort x, GLshort y, GLshort z)) +SDL_PROC_UNUSED(void, glVertex3sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glVertex4d, + (GLdouble x, GLdouble y, GLdouble z, GLdouble w)) +SDL_PROC_UNUSED(void, glVertex4dv, (const GLdouble * v)) +SDL_PROC_UNUSED(void, glVertex4f, + (GLfloat x, GLfloat y, GLfloat z, GLfloat w)) +SDL_PROC_UNUSED(void, glVertex4fv, (const GLfloat * v)) +SDL_PROC_UNUSED(void, glVertex4i, (GLint x, GLint y, GLint z, GLint w)) +SDL_PROC_UNUSED(void, glVertex4iv, (const GLint * v)) +SDL_PROC_UNUSED(void, glVertex4s, + (GLshort x, GLshort y, GLshort z, GLshort w)) +SDL_PROC_UNUSED(void, glVertex4sv, (const GLshort * v)) +SDL_PROC_UNUSED(void, glVertexPointer, + (GLint size, GLenum type, GLsizei stride, + const GLvoid * pointer)) +SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height)) /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_pixels.c --- a/src/video/SDL_pixels.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_pixels.c Mon May 29 04:04:35 2006 +0000 @@ -33,27 +33,27 @@ /* Helper functions */ SDL_bool -SDL_PixelFormatEnumToMasks (Uint32 format, int *bpp, Uint32 * Rmask, - Uint32 * Gmask, Uint32 * Bmask, Uint32 * Amask) +SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, Uint32 * Rmask, + Uint32 * Gmask, Uint32 * Bmask, Uint32 * Amask) { Uint32 masks[4]; /* Initialize the values here */ - if (SDL_BITSPERPIXEL (format) == 24) { - *bpp = SDL_BYTESPERPIXEL (format) * 8; + if (SDL_BITSPERPIXEL(format) == 24) { + *bpp = SDL_BYTESPERPIXEL(format) * 8; } else { - *bpp = SDL_BITSPERPIXEL (format); + *bpp = SDL_BITSPERPIXEL(format); } *Rmask = *Gmask = *Bmask = *Amask = 0; - if (SDL_PIXELTYPE (format) != SDL_PixelType_Packed8 && - SDL_PIXELTYPE (format) != SDL_PixelType_Packed16 && - SDL_PIXELTYPE (format) != SDL_PixelType_Packed32) { + if (SDL_PIXELTYPE(format) != SDL_PixelType_Packed8 && + SDL_PIXELTYPE(format) != SDL_PixelType_Packed16 && + SDL_PIXELTYPE(format) != SDL_PixelType_Packed32) { /* Not a format that uses masks */ return SDL_TRUE; } - switch (SDL_PIXELLAYOUT (format)) { + switch (SDL_PIXELLAYOUT(format)) { case SDL_PackedLayout_332: masks[0] = 0x00000000; masks[1] = 0x000000E0; @@ -95,7 +95,7 @@ return SDL_FALSE; } - switch (SDL_PIXELORDER (format)) { + switch (SDL_PIXELORDER(format)) { case SDL_PackedOrder_XRGB: *Rmask = masks[1]; *Gmask = masks[2]; @@ -148,8 +148,8 @@ } Uint32 -SDL_MasksToPixelFormatEnum (int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, - Uint32 Amask) +SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, + Uint32 Amask) { switch (bpp) { case 8: @@ -219,19 +219,19 @@ * Allocate a pixel format structure and fill it according to the given info. */ SDL_PixelFormat * -SDL_AllocFormat (int bpp, - Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) +SDL_AllocFormat(int bpp, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { SDL_PixelFormat *format; Uint32 mask; /* Allocate an empty pixel format structure */ - format = SDL_malloc (sizeof (*format)); + format = SDL_malloc(sizeof(*format)); if (format == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } - SDL_memset (format, 0, sizeof (*format)); + SDL_memset(format, 0, sizeof(*format)); format->alpha = SDL_ALPHA_OPAQUE; /* Set up the format */ @@ -306,23 +306,23 @@ if (bpp <= 8) { /* Palettized mode */ int ncolors = 1 << bpp; #ifdef DEBUG_PALETTE - fprintf (stderr, "bpp=%d ncolors=%d\n", bpp, ncolors); + fprintf(stderr, "bpp=%d ncolors=%d\n", bpp, ncolors); #endif - format->palette = (SDL_Palette *) SDL_malloc (sizeof (SDL_Palette)); + format->palette = (SDL_Palette *) SDL_malloc(sizeof(SDL_Palette)); if (format->palette == NULL) { - SDL_FreeFormat (format); - SDL_OutOfMemory (); + SDL_FreeFormat(format); + SDL_OutOfMemory(); return (NULL); } (format->palette)->ncolors = ncolors; - (format->palette)->colors = (SDL_Color *) SDL_malloc ((format-> - palette)-> - ncolors * - sizeof - (SDL_Color)); + (format->palette)->colors = (SDL_Color *) SDL_malloc((format-> + palette)-> + ncolors * + sizeof + (SDL_Color)); if ((format->palette)->colors == NULL) { - SDL_FreeFormat (format); - SDL_OutOfMemory (); + SDL_FreeFormat(format); + SDL_OutOfMemory(); return (NULL); } if (Rmask || Bmask || Gmask) { @@ -339,7 +339,7 @@ Rm |= 1 << i; } #ifdef DEBUG_PALETTE - fprintf (stderr, "Rw=%d Rm=0x%02X\n", Rw, Rm); + fprintf(stderr, "Rw=%d Rm=0x%02X\n", Rw, Rm); #endif if (Gmask) { Gw = 8 - format->Gloss; @@ -347,7 +347,7 @@ Gm |= 1 << i; } #ifdef DEBUG_PALETTE - fprintf (stderr, "Gw=%d Gm=0x%02X\n", Gw, Gm); + fprintf(stderr, "Gw=%d Gm=0x%02X\n", Gw, Gm); #endif if (Bmask) { Bw = 8 - format->Bloss; @@ -355,7 +355,7 @@ Bm |= 1 << i; } #ifdef DEBUG_PALETTE - fprintf (stderr, "Bw=%d Bm=0x%02X\n", Bw, Bm); + fprintf(stderr, "Bw=%d Bm=0x%02X\n", Bw, Bm); #endif #ifdef ENABLE_PALETTE_ALPHA if (Amask) { @@ -364,7 +364,7 @@ Am |= 1 << i; } # ifdef DEBUG_PALETTE - fprintf (stderr, "Aw=%d Am=0x%02X\n", Aw, Am); + fprintf(stderr, "Aw=%d Am=0x%02X\n", Aw, Am); # endif #endif for (i = 0; i < ncolors; ++i) { @@ -399,22 +399,22 @@ format->palette->colors[1].b = 0x00; } else { /* Create an empty palette */ - SDL_memset ((format->palette)->colors, 0, - (format->palette)->ncolors * sizeof (SDL_Color)); + SDL_memset((format->palette)->colors, 0, + (format->palette)->ncolors * sizeof(SDL_Color)); } } return (format); } SDL_PixelFormat * -SDL_ReallocFormat (SDL_Surface * surface, int bpp, - Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) +SDL_ReallocFormat(SDL_Surface * surface, int bpp, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { if (surface->format) { - SDL_FreeFormat (surface->format); - SDL_FormatChanged (surface); + SDL_FreeFormat(surface->format); + SDL_FormatChanged(surface); } - surface->format = SDL_AllocFormat (bpp, Rmask, Gmask, Bmask, Amask); + surface->format = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask); return surface->format; } @@ -422,7 +422,7 @@ * Change any previous mappings from/to the new surface format */ void -SDL_FormatChanged (SDL_Surface * surface) +SDL_FormatChanged(SDL_Surface * surface) { static int format_version = 0; ++format_version; @@ -430,23 +430,23 @@ format_version = 1; } surface->format_version = format_version; - SDL_InvalidateMap (surface->map); + SDL_InvalidateMap(surface->map); } /* * Free a previously allocated format structure */ void -SDL_FreeFormat (SDL_PixelFormat * format) +SDL_FreeFormat(SDL_PixelFormat * format) { if (format) { if (format->palette) { if (format->palette->colors) { - SDL_free (format->palette->colors); + SDL_free(format->palette->colors); } - SDL_free (format->palette); + SDL_free(format->palette); } - SDL_free (format); + SDL_free(format); } } @@ -454,7 +454,7 @@ * Calculate an 8-bit (3 red, 3 green, 2 blue) dithered palette of colors */ void -SDL_DitherColors (SDL_Color * colors, int bpp) +SDL_DitherColors(SDL_Color * colors, int bpp) { int i; if (bpp != 8) @@ -481,7 +481,7 @@ * Calculate the pad-aligned scanline width of a surface */ Uint16 -SDL_CalculatePitch (SDL_Surface * surface) +SDL_CalculatePitch(SDL_Surface * surface) { Uint16 pitch; @@ -505,7 +505,7 @@ * Match an RGB value to a particular palette index */ Uint8 -SDL_FindColor (SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b) +SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b) { /* Do colorspace distance matching */ unsigned int smallest; @@ -533,20 +533,20 @@ /* Find the opaque pixel value corresponding to an RGB triple */ Uint32 -SDL_MapRGB (SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b) +SDL_MapRGB(SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b) { if (format->palette == NULL) { return (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | format->Amask; } else { - return SDL_FindColor (format->palette, r, g, b); + return SDL_FindColor(format->palette, r, g, b); } } /* Find the pixel value corresponding to an RGBA quadruple */ Uint32 -SDL_MapRGBA (SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +SDL_MapRGBA(SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { if (format->palette == NULL) { return (r >> format->Rloss) << format->Rshift @@ -554,13 +554,13 @@ | (b >> format->Bloss) << format->Bshift | ((a >> format->Aloss) << format->Ashift & format->Amask); } else { - return SDL_FindColor (format->palette, r, g, b); + return SDL_FindColor(format->palette, r, g, b); } } void -SDL_GetRGBA (Uint32 pixel, SDL_PixelFormat * fmt, - Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a) +SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat * fmt, + Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a) { if (fmt->palette == NULL) { /* @@ -594,8 +594,8 @@ } void -SDL_GetRGB (Uint32 pixel, SDL_PixelFormat * fmt, Uint8 * r, Uint8 * g, - Uint8 * b) +SDL_GetRGB(Uint32 pixel, SDL_PixelFormat * fmt, Uint8 * r, Uint8 * g, + Uint8 * b) { if (fmt->palette == NULL) { /* the note for SDL_GetRGBA above applies here too */ @@ -615,8 +615,8 @@ /* Apply gamma to a set of colors - this is easy. :) */ void -SDL_ApplyGamma (Uint16 * gamma, SDL_Color * colors, SDL_Color * output, - int ncolors) +SDL_ApplyGamma(Uint16 * gamma, SDL_Color * colors, SDL_Color * output, + int ncolors) { int i; @@ -629,7 +629,7 @@ /* Map from Palette to Palette */ static Uint8 * -Map1to1 (SDL_Palette * src, SDL_Palette * dst, int *identical) +Map1to1(SDL_Palette * src, SDL_Palette * dst, int *identical) { Uint8 *map; int i; @@ -637,30 +637,30 @@ if (identical) { if (src->ncolors <= dst->ncolors) { /* If an identical palette, no need to map */ - if (SDL_memcmp (src->colors, dst->colors, src->ncolors * - sizeof (SDL_Color)) == 0) { + if (SDL_memcmp(src->colors, dst->colors, src->ncolors * + sizeof(SDL_Color)) == 0) { *identical = 1; return (NULL); } } *identical = 0; } - map = (Uint8 *) SDL_malloc (src->ncolors); + map = (Uint8 *) SDL_malloc(src->ncolors); if (map == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } for (i = 0; i < src->ncolors; ++i) { - map[i] = SDL_FindColor (dst, - src->colors[i].r, src->colors[i].g, - src->colors[i].b); + map[i] = SDL_FindColor(dst, + src->colors[i].r, src->colors[i].g, + src->colors[i].b); } return (map); } /* Map from Palette to BitField */ static Uint8 * -Map1toN (SDL_PixelFormat * src, SDL_PixelFormat * dst) +Map1toN(SDL_PixelFormat * src, SDL_PixelFormat * dst) { Uint8 *map; int i; @@ -669,25 +669,25 @@ SDL_Palette *pal = src->palette; bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel); - map = (Uint8 *) SDL_malloc (pal->ncolors * bpp); + map = (Uint8 *) SDL_malloc(pal->ncolors * bpp); if (map == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } alpha = dst->Amask ? src->alpha : 0; /* We memory copy to the pixel map so the endianness is preserved */ for (i = 0; i < pal->ncolors; ++i) { - ASSEMBLE_RGBA (&map[i * bpp], dst->BytesPerPixel, dst, - pal->colors[i].r, pal->colors[i].g, - pal->colors[i].b, alpha); + ASSEMBLE_RGBA(&map[i * bpp], dst->BytesPerPixel, dst, + pal->colors[i].r, pal->colors[i].g, + pal->colors[i].b, alpha); } return (map); } /* Map from BitField to Dithered-Palette to Palette */ static Uint8 * -MapNto1 (SDL_PixelFormat * src, SDL_PixelFormat * dst, int *identical) +MapNto1(SDL_PixelFormat * src, SDL_PixelFormat * dst, int *identical) { /* Generate a 256 color dither palette */ SDL_Palette dithered; @@ -696,43 +696,43 @@ /* SDL_DitherColors does not initialize the 'unused' component of colors, but Map1to1 compares it against pal, so we should initialize it. */ - SDL_memset (colors, 0, sizeof (colors)); + SDL_memset(colors, 0, sizeof(colors)); dithered.ncolors = 256; - SDL_DitherColors (colors, 8); + SDL_DitherColors(colors, 8); dithered.colors = colors; - return (Map1to1 (&dithered, pal, identical)); + return (Map1to1(&dithered, pal, identical)); } SDL_BlitMap * -SDL_AllocBlitMap (void) +SDL_AllocBlitMap(void) { SDL_BlitMap *map; /* Allocate the empty map */ - map = (SDL_BlitMap *) SDL_malloc (sizeof (*map)); + map = (SDL_BlitMap *) SDL_malloc(sizeof(*map)); if (map == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } - SDL_memset (map, 0, sizeof (*map)); + SDL_memset(map, 0, sizeof(*map)); /* Allocate the software blit data */ map->sw_data = - (struct private_swaccel *) SDL_malloc (sizeof (*map->sw_data)); + (struct private_swaccel *) SDL_malloc(sizeof(*map->sw_data)); if (map->sw_data == NULL) { - SDL_FreeBlitMap (map); - SDL_OutOfMemory (); + SDL_FreeBlitMap(map); + SDL_OutOfMemory(); return (NULL); } - SDL_memset (map->sw_data, 0, sizeof (*map->sw_data)); + SDL_memset(map->sw_data, 0, sizeof(*map->sw_data)); /* It's ready to go */ return (map); } void -SDL_InvalidateMap (SDL_BlitMap * map) +SDL_InvalidateMap(SDL_BlitMap * map) { if (!map) { return; @@ -740,12 +740,12 @@ map->dst = NULL; map->format_version = (unsigned int) -1; if (map->table) { - SDL_free (map->table); + SDL_free(map->table); map->table = NULL; } } int -SDL_MapSurface (SDL_Surface * src, SDL_Surface * dst) +SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst) { SDL_PixelFormat *srcfmt; SDL_PixelFormat *dstfmt; @@ -754,9 +754,9 @@ /* Clear out any previous mapping */ map = src->map; if ((src->flags & SDL_RLEACCEL) == SDL_RLEACCEL) { - SDL_UnRLESurface (src, 1); + SDL_UnRLESurface(src, 1); } - SDL_InvalidateMap (map); + SDL_InvalidateMap(map); /* Figure out what kind of mapping we're doing */ map->identity = 0; @@ -772,8 +772,8 @@ ((dst->flags & SDL_HWSURFACE) == SDL_HWSURFACE)) { map->identity = 1; } else { - map->table = Map1to1 (srcfmt->palette, - dstfmt->palette, &map->identity); + map->table = Map1to1(srcfmt->palette, + dstfmt->palette, &map->identity); } if (!map->identity) { if (map->table == NULL) { @@ -786,7 +786,7 @@ default: /* Palette --> BitField */ - map->table = Map1toN (srcfmt, dstfmt); + map->table = Map1toN(srcfmt, dstfmt); if (map->table == NULL) { return (-1); } @@ -797,7 +797,7 @@ switch (dstfmt->BytesPerPixel) { case 1: /* BitField --> Palette */ - map->table = MapNto1 (srcfmt, dstfmt, &map->identity); + map->table = MapNto1(srcfmt, dstfmt, &map->identity); if (!map->identity) { if (map->table == NULL) { return (-1); @@ -807,7 +807,7 @@ break; default: /* BitField --> BitField */ - if (FORMAT_EQUAL (srcfmt, dstfmt)) + if (FORMAT_EQUAL(srcfmt, dstfmt)) map->identity = 1; break; } @@ -818,18 +818,18 @@ map->format_version = dst->format_version; /* Choose your blitters wisely */ - return (SDL_CalculateBlit (src)); + return (SDL_CalculateBlit(src)); } void -SDL_FreeBlitMap (SDL_BlitMap * map) +SDL_FreeBlitMap(SDL_BlitMap * map) { if (map) { - SDL_InvalidateMap (map); + SDL_InvalidateMap(map); if (map->sw_data != NULL) { - SDL_free (map->sw_data); + SDL_free(map->sw_data); } - SDL_free (map); + SDL_free(map); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_pixels_c.h --- a/src/video/SDL_pixels_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_pixels_c.h Mon May 29 04:04:35 2006 +0000 @@ -26,25 +26,25 @@ #include "SDL_blit.h" /* Pixel format functions */ -extern SDL_PixelFormat *SDL_AllocFormat (int bpp, - Uint32 Rmask, Uint32 Gmask, - Uint32 Bmask, Uint32 Amask); -extern SDL_PixelFormat *SDL_ReallocFormat (SDL_Surface * surface, int bpp, - Uint32 Rmask, Uint32 Gmask, - Uint32 Bmask, Uint32 Amask); -extern void SDL_FormatChanged (SDL_Surface * surface); -extern void SDL_FreeFormat (SDL_PixelFormat * format); +extern SDL_PixelFormat *SDL_AllocFormat(int bpp, + Uint32 Rmask, Uint32 Gmask, + Uint32 Bmask, Uint32 Amask); +extern SDL_PixelFormat *SDL_ReallocFormat(SDL_Surface * surface, int bpp, + Uint32 Rmask, Uint32 Gmask, + Uint32 Bmask, Uint32 Amask); +extern void SDL_FormatChanged(SDL_Surface * surface); +extern void SDL_FreeFormat(SDL_PixelFormat * format); /* Blit mapping functions */ -extern SDL_BlitMap *SDL_AllocBlitMap (void); -extern void SDL_InvalidateMap (SDL_BlitMap * map); -extern int SDL_MapSurface (SDL_Surface * src, SDL_Surface * dst); -extern void SDL_FreeBlitMap (SDL_BlitMap * map); +extern SDL_BlitMap *SDL_AllocBlitMap(void); +extern void SDL_InvalidateMap(SDL_BlitMap * map); +extern int SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst); +extern void SDL_FreeBlitMap(SDL_BlitMap * map); /* Miscellaneous functions */ -extern Uint16 SDL_CalculatePitch (SDL_Surface * surface); -extern void SDL_DitherColors (SDL_Color * colors, int bpp); -extern Uint8 SDL_FindColor (SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b); -extern void SDL_ApplyGamma (Uint16 * gamma, SDL_Color * colors, - SDL_Color * output, int ncolors); +extern Uint16 SDL_CalculatePitch(SDL_Surface * surface); +extern void SDL_DitherColors(SDL_Color * colors, int bpp); +extern Uint8 SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b); +extern void SDL_ApplyGamma(Uint16 * gamma, SDL_Color * colors, + SDL_Color * output, int ncolors); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_stretch.c --- a/src/video/SDL_stretch.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_stretch.c Mon May 29 04:04:35 2006 +0000 @@ -56,7 +56,7 @@ static unsigned char copy_row[4096]; static int -generate_rowbytes (int src_w, int dst_w, int bpp) +generate_rowbytes(int src_w, int dst_w, int bpp) { static struct { @@ -89,7 +89,7 @@ store = STORE_WORD; break; default: - SDL_SetError ("ASM stretch of %d bytes isn't supported\n", bpp); + SDL_SetError("ASM stretch of %d bytes isn't supported\n", bpp); return (-1); } pos = 0x10000; @@ -112,8 +112,8 @@ *eip++ = RETURN; /* Verify that we didn't overflow (too late) */ - if (eip > (copy_row + sizeof (copy_row))) { - SDL_SetError ("Copy buffer overflow"); + if (eip > (copy_row + sizeof(copy_row))) { + SDL_SetError("Copy buffer overflow"); return (-1); } return (0); @@ -139,12 +139,12 @@ pos += inc; \ } \ } -DEFINE_COPY_ROW (copy_row1, Uint8) - DEFINE_COPY_ROW (copy_row2, Uint16) DEFINE_COPY_ROW (copy_row4, Uint32) +DEFINE_COPY_ROW(copy_row1, Uint8) + DEFINE_COPY_ROW(copy_row2, Uint16) DEFINE_COPY_ROW(copy_row4, Uint32) #endif /* USE_ASM_STRETCH */ /* The ASM code doesn't handle 24-bpp stretch blits */ void - copy_row3 (Uint8 * src, int src_w, Uint8 * dst, int dst_w) + copy_row3(Uint8 * src, int src_w, Uint8 * dst, int dst_w) { int i; int pos, inc; @@ -170,8 +170,8 @@ NOTE: This function is not safe to call from multiple threads! */ int -SDL_SoftStretch (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +SDL_SoftStretch(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { int src_locked; int dst_locked; @@ -189,7 +189,7 @@ const int bpp = dst->format->BytesPerPixel; if (src->format->BitsPerPixel != dst->format->BitsPerPixel) { - SDL_SetError ("Only works with same format surfaces"); + SDL_SetError("Only works with same format surfaces"); return (-1); } @@ -198,7 +198,7 @@ if ((srcrect->x < 0) || (srcrect->y < 0) || ((srcrect->x + srcrect->w) > src->w) || ((srcrect->y + srcrect->h) > src->h)) { - SDL_SetError ("Invalid source blit rectangle"); + SDL_SetError("Invalid source blit rectangle"); return (-1); } } else { @@ -212,7 +212,7 @@ if ((dstrect->x < 0) || (dstrect->y < 0) || ((dstrect->x + dstrect->w) > dst->w) || ((dstrect->y + dstrect->h) > dst->h)) { - SDL_SetError ("Invalid destination blit rectangle"); + SDL_SetError("Invalid destination blit rectangle"); return (-1); } } else { @@ -225,21 +225,21 @@ /* Lock the destination if it's in hardware */ dst_locked = 0; - if (SDL_MUSTLOCK (dst)) { - if (SDL_LockSurface (dst) < 0) { - SDL_SetError ("Unable to lock destination surface"); + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { + SDL_SetError("Unable to lock destination surface"); return (-1); } dst_locked = 1; } /* Lock the source if it's in hardware */ src_locked = 0; - if (SDL_MUSTLOCK (src)) { - if (SDL_LockSurface (src) < 0) { + if (SDL_MUSTLOCK(src)) { + if (SDL_LockSurface(src) < 0) { if (dst_locked) { - SDL_UnlockSurface (dst); + SDL_UnlockSurface(dst); } - SDL_SetError ("Unable to lock source surface"); + SDL_SetError("Unable to lock source surface"); return (-1); } src_locked = 1; @@ -254,7 +254,7 @@ #ifdef USE_ASM_STRETCH /* Write the opcodes for this stretch */ - if ((bpp != 3) && (generate_rowbytes (srcrect->w, dstrect->w, bpp) < 0)) { + if ((bpp != 3) && (generate_rowbytes(srcrect->w, dstrect->w, bpp) < 0)) { return (-1); } #endif @@ -272,11 +272,11 @@ #ifdef USE_ASM_STRETCH switch (bpp) { case 3: - copy_row3 (srcp, srcrect->w, dstp, dstrect->w); + copy_row3(srcp, srcrect->w, dstp, dstrect->w); break; default: #ifdef __GNUC__ - __asm__ __volatile__ ("call *%4": "=&D" (u1), "=&S" (u2): "0" (dstp), "1" (srcp), "r" (copy_row):"memory"); + __asm__ __volatile__("call *%4": "=&D"(u1), "=&S"(u2): "0"(dstp), "1"(srcp), "r"(copy_row):"memory"); #elif defined(_MSC_VER) || defined(__WATCOMC__) { void *code = copy_row; @@ -294,18 +294,18 @@ #else switch (bpp) { case 1: - copy_row1 (srcp, srcrect->w, dstp, dstrect->w); + copy_row1(srcp, srcrect->w, dstp, dstrect->w); break; case 2: - copy_row2 ((Uint16 *) srcp, srcrect->w, - (Uint16 *) dstp, dstrect->w); + copy_row2((Uint16 *) srcp, srcrect->w, + (Uint16 *) dstp, dstrect->w); break; case 3: - copy_row3 (srcp, srcrect->w, dstp, dstrect->w); + copy_row3(srcp, srcrect->w, dstp, dstrect->w); break; case 4: - copy_row4 ((Uint32 *) srcp, srcrect->w, - (Uint32 *) dstp, dstrect->w); + copy_row4((Uint32 *) srcp, srcrect->w, + (Uint32 *) dstp, dstrect->w); break; } #endif @@ -314,10 +314,10 @@ /* We need to unlock the surfaces if they're locked */ if (dst_locked) { - SDL_UnlockSurface (dst); + SDL_UnlockSurface(dst); } if (src_locked) { - SDL_UnlockSurface (src); + SDL_UnlockSurface(src); } return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_stretch_c.h --- a/src/video/SDL_stretch_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_stretch_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,6 +24,6 @@ /* Perform a stretch blit between two surfaces of the same format. NOTE: This function is not safe to call from multiple threads! */ -extern int SDL_SoftStretch (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect); +extern int SDL_SoftStretch(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_surface.c --- a/src/video/SDL_surface.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_surface.c Mon May 29 04:04:35 2006 +0000 @@ -35,18 +35,18 @@ * Create an empty RGB surface of the appropriate depth */ SDL_Surface * -SDL_CreateRGBSurface (Uint32 flags, - int width, int height, int depth, - Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) +SDL_CreateRGBSurface(Uint32 flags, + int width, int height, int depth, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); SDL_Surface *screen; SDL_Surface *surface; /* Make sure the size requested doesn't overflow our datatypes */ /* Next time I write a library like SDL, I'll use int for size. :) */ if (width >= 16384 || height >= 65536) { - SDL_SetError ("Width or height is too large"); + SDL_SetError("Width or height is too large"); return (NULL); } @@ -75,9 +75,9 @@ } /* Allocate the surface */ - surface = (SDL_Surface *) SDL_malloc (sizeof (*surface)); + surface = (SDL_Surface *) SDL_malloc(sizeof(*surface)); if (surface == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } surface->flags = SDL_SWSURFACE; @@ -96,9 +96,9 @@ Amask = screen->format->Amask; } } - surface->format = SDL_AllocFormat (depth, Rmask, Gmask, Bmask, Amask); + surface->format = SDL_AllocFormat(depth, Rmask, Gmask, Bmask, Amask); if (surface->format == NULL) { - SDL_free (surface); + SDL_free(surface); return (NULL); } if (Amask) { @@ -106,35 +106,35 @@ } surface->w = width; surface->h = height; - surface->pitch = SDL_CalculatePitch (surface); + surface->pitch = SDL_CalculatePitch(surface); surface->pixels = NULL; surface->offset = 0; surface->hwdata = NULL; surface->locked = 0; surface->map = NULL; surface->unused1 = 0; - SDL_SetClipRect (surface, NULL); - SDL_FormatChanged (surface); + SDL_SetClipRect(surface, NULL); + SDL_FormatChanged(surface); /* Get the pixels */ if (((flags & SDL_HWSURFACE) == SDL_SWSURFACE) || - (_this->AllocHWSurface (_this, surface) < 0)) { + (_this->AllocHWSurface(_this, surface) < 0)) { if (surface->w && surface->h) { - surface->pixels = SDL_malloc (surface->h * surface->pitch); + surface->pixels = SDL_malloc(surface->h * surface->pitch); if (surface->pixels == NULL) { - SDL_FreeSurface (surface); - SDL_OutOfMemory (); + SDL_FreeSurface(surface); + SDL_OutOfMemory(); return (NULL); } /* This is important for bitmaps */ - SDL_memset (surface->pixels, 0, surface->h * surface->pitch); + SDL_memset(surface->pixels, 0, surface->h * surface->pitch); } } /* Allocate an empty mapping */ - surface->map = SDL_AllocBlitMap (); + surface->map = SDL_AllocBlitMap(); if (surface->map == NULL) { - SDL_FreeSurface (surface); + SDL_FreeSurface(surface); return (NULL); } @@ -150,22 +150,22 @@ * Create an RGB surface from an existing memory buffer */ SDL_Surface * -SDL_CreateRGBSurfaceFrom (void *pixels, - int width, int height, int depth, int pitch, - Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, - Uint32 Amask) +SDL_CreateRGBSurfaceFrom(void *pixels, + int width, int height, int depth, int pitch, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, + Uint32 Amask) { SDL_Surface *surface; - surface = SDL_CreateRGBSurface (SDL_SWSURFACE, 0, 0, depth, - Rmask, Gmask, Bmask, Amask); + surface = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, depth, + Rmask, Gmask, Bmask, Amask); if (surface != NULL) { surface->flags |= SDL_PREALLOC; surface->pixels = pixels; surface->w = width; surface->h = height; surface->pitch = pitch; - SDL_SetClipRect (surface, NULL); + SDL_SetClipRect(surface, NULL); } return (surface); } @@ -174,7 +174,7 @@ * Set the color key in a blittable surface */ int -SDL_SetColorKey (SDL_Surface * surface, Uint32 flag, Uint32 key) +SDL_SetColorKey(SDL_Surface * surface, Uint32 flag, Uint32 key) { /* Sanity check the flag as it gets passed in */ if (flag & SDL_SRCCOLORKEY) { @@ -195,17 +195,17 @@ /* UnRLE surfaces before we change the colorkey */ if (surface->flags & SDL_RLEACCEL) { - SDL_UnRLESurface (surface, 1); + SDL_UnRLESurface(surface, 1); } if (flag) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); surface->flags |= SDL_SRCCOLORKEY; surface->format->colorkey = key; if ((surface->flags & SDL_HWACCEL) == SDL_HWACCEL) { if ((_this->SetHWColorKey == NULL) || - (_this->SetHWColorKey (_this, surface, key) < 0)) { + (_this->SetHWColorKey(_this, surface, key) < 0)) { surface->flags &= ~SDL_HWACCEL; } } @@ -218,13 +218,13 @@ surface->flags &= ~(SDL_SRCCOLORKEY | SDL_RLEACCELOK); surface->format->colorkey = 0; } - SDL_InvalidateMap (surface->map); + SDL_InvalidateMap(surface->map); return (0); } /* This function sets the alpha channel of a surface */ int -SDL_SetAlpha (SDL_Surface * surface, Uint32 flag, Uint8 value) +SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, Uint8 value) { Uint32 oldflags = surface->flags; Uint32 oldalpha = surface->format->alpha; @@ -247,16 +247,16 @@ } if (!(flag & SDL_RLEACCELOK) && (surface->flags & SDL_RLEACCEL)) - SDL_UnRLESurface (surface, 1); + SDL_UnRLESurface(surface, 1); if (flag) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); surface->flags |= SDL_SRCALPHA; surface->format->alpha = value; if ((surface->flags & SDL_HWACCEL) == SDL_HWACCEL) { if ((_this->SetHWAlpha == NULL) || - (_this->SetHWAlpha (_this, surface, value) < 0)) { + (_this->SetHWAlpha(_this, surface, value) < 0)) { surface->flags &= ~SDL_HWACCEL; } } @@ -278,12 +278,12 @@ if ((surface->flags & SDL_HWACCEL) == SDL_HWACCEL || oldflags != surface->flags || (((oldalpha + 1) ^ (value + 1)) & 0x100)) - SDL_InvalidateMap (surface->map); + SDL_InvalidateMap(surface->map); return (0); } int -SDL_SetAlphaChannel (SDL_Surface * surface, Uint8 value) +SDL_SetAlphaChannel(SDL_Surface * surface, Uint8 value) { int row, col; int offset; @@ -291,7 +291,7 @@ if ((surface->format->Amask != 0xFF000000) && (surface->format->Amask != 0x000000FF)) { - SDL_SetError ("Unsupported surface alpha mask format"); + SDL_SetError("Unsupported surface alpha mask format"); return -1; } #if SDL_BYTEORDER == SDL_LIL_ENDIAN @@ -309,8 +309,8 @@ #endif /* Byte ordering */ /* Quickly set the alpha channel of an RGBA or ARGB surface */ - if (SDL_MUSTLOCK (surface)) { - if (SDL_LockSurface (surface) < 0) { + if (SDL_MUSTLOCK(surface)) { + if (SDL_LockSurface(surface) < 0) { return -1; } } @@ -323,8 +323,8 @@ buf += 4; } } - if (SDL_MUSTLOCK (surface)) { - SDL_UnlockSurface (surface); + if (SDL_MUSTLOCK(surface)) { + SDL_UnlockSurface(surface); } return 0; } @@ -334,8 +334,8 @@ * return true if the rectangles intersect, false otherwise */ static __inline__ SDL_bool -SDL_IntersectRect (const SDL_Rect * A, const SDL_Rect * B, - SDL_Rect * intersection) +SDL_IntersectRect(const SDL_Rect * A, const SDL_Rect * B, + SDL_Rect * intersection) { int Amin, Amax, Bmin, Bmax; @@ -370,7 +370,7 @@ * Set the clipping rectangle for a blittable surface */ SDL_bool -SDL_SetClipRect (SDL_Surface * surface, const SDL_Rect * rect) +SDL_SetClipRect(SDL_Surface * surface, const SDL_Rect * rect) { SDL_Rect full_rect; @@ -390,11 +390,11 @@ surface->clip_rect = full_rect; return 1; } - return SDL_IntersectRect (rect, &full_rect, &surface->clip_rect); + return SDL_IntersectRect(rect, &full_rect, &surface->clip_rect); } void -SDL_GetClipRect (SDL_Surface * surface, SDL_Rect * rect) +SDL_GetClipRect(SDL_Surface * surface, SDL_Rect * rect) { if (surface && rect) { *rect = surface->clip_rect; @@ -413,15 +413,15 @@ * by calling the one(s) you need. */ int -SDL_LowerBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +SDL_LowerBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { SDL_blit do_blit; /* Check to make sure the blit mapping is valid */ if ((src->map->dst != dst) || (src->map->dst->format_version != src->map->format_version)) { - if (SDL_MapSurface (src, dst) < 0) { + if (SDL_MapSurface(src, dst) < 0) { return (-1); } } @@ -432,24 +432,24 @@ } else { do_blit = src->map->sw_blit; } - return (do_blit (src, srcrect, dst, dstrect)); + return (do_blit(src, srcrect, dst, dstrect)); } int -SDL_UpperBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +SDL_UpperBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { SDL_Rect fulldst; int srcx, srcy, w, h; /* Make sure the surfaces aren't locked */ if (!src || !dst) { - SDL_SetError ("SDL_UpperBlit: passed a NULL surface"); + SDL_SetError("SDL_UpperBlit: passed a NULL surface"); return (-1); } if (src->locked || dst->locked) { - SDL_SetError ("Surfaces must not be locked during blit"); + SDL_SetError("Surfaces must not be locked during blit"); return (-1); } @@ -523,25 +523,25 @@ sr.y = srcy; sr.w = dstrect->w = w; sr.h = dstrect->h = h; - return SDL_LowerBlit (src, &sr, dst, dstrect); + return SDL_LowerBlit(src, &sr, dst, dstrect); } dstrect->w = dstrect->h = 0; return 0; } static int -SDL_FillRect1 (SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color) +SDL_FillRect1(SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color) { /* FIXME: We have to worry about packing order.. *sigh* */ - SDL_SetError ("1-bpp rect fill not yet implemented"); + SDL_SetError("1-bpp rect fill not yet implemented"); return -1; } static int -SDL_FillRect4 (SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color) +SDL_FillRect4(SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color) { /* FIXME: We have to worry about packing order.. *sigh* */ - SDL_SetError ("4-bpp rect fill not yet implemented"); + SDL_SetError("4-bpp rect fill not yet implemented"); return -1; } @@ -549,9 +549,9 @@ * This function performs a fast fill of the given rectangle with 'color' */ int -SDL_FillRect (SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color) +SDL_FillRect(SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); int x, y; Uint8 *row; @@ -559,13 +559,13 @@ if (dst->format->BitsPerPixel < 8) { switch (dst->format->BitsPerPixel) { case 1: - return SDL_FillRect1 (dst, dstrect, color); + return SDL_FillRect1(dst, dstrect, color); break; case 4: - return SDL_FillRect4 (dst, dstrect, color); + return SDL_FillRect4(dst, dstrect, color); break; default: - SDL_SetError ("Fill rect on unsupported surface format"); + SDL_SetError("Fill rect on unsupported surface format"); return (-1); break; } @@ -574,7 +574,7 @@ /* If 'dstrect' == NULL, then fill the whole surface */ if (dstrect) { /* Perform clipping */ - if (!SDL_IntersectRect (dstrect, &dst->clip_rect, dstrect)) { + if (!SDL_IntersectRect(dstrect, &dst->clip_rect, dstrect)) { return (0); } } else { @@ -584,11 +584,11 @@ /* Check for hardware acceleration */ if (((dst->flags & SDL_HWSURFACE) == SDL_HWSURFACE) && _this->info.blit_fill) { - return (_this->FillHWRect (_this, dst, dstrect, color)); + return (_this->FillHWRect(_this, dst, dstrect, color)); } /* Perform software fill */ - if (SDL_LockSurface (dst) != 0) { + if (SDL_LockSurface(dst) != 0) { return (-1); } row = (Uint8 *) dst->pixels + dstrect->y * dst->pitch + @@ -599,7 +599,7 @@ && !(dst->pitch & 3)) { int n = x >> 2; for (y = dstrect->h; y; --y) { - SDL_memset4 (row, 0, n); + SDL_memset4(row, 0, n); row += dst->pitch; } } else { @@ -617,34 +617,34 @@ * efficient to uncached video memory */ double fill; - SDL_memset (&fill, color, (sizeof fill)); + SDL_memset(&fill, color, (sizeof fill)); for (y = dstrect->h; y; y--) { Uint8 *d = row; unsigned n = x; unsigned nn; Uint8 c = color; double f = fill; - while ((unsigned long) d & (sizeof (double) - 1)) { + while ((unsigned long) d & (sizeof(double) - 1)) { *d++ = c; n--; } - nn = n / (sizeof (double) * 4); + nn = n / (sizeof(double) * 4); while (nn) { ((double *) d)[0] = f; ((double *) d)[1] = f; ((double *) d)[2] = f; ((double *) d)[3] = f; - d += 4 * sizeof (double); + d += 4 * sizeof(double); nn--; } - n &= ~(sizeof (double) * 4 - 1); - nn = n / sizeof (double); + n &= ~(sizeof(double) * 4 - 1); + nn = n / sizeof(double); while (nn) { *(double *) d = f; - d += sizeof (double); + d += sizeof(double); nn--; } - n &= ~(sizeof (double) - 1); + n &= ~(sizeof(double) - 1); while (n) { *d++ = c; n--; @@ -668,7 +668,7 @@ #endif /* __powerpc__ */ { for (y = dstrect->h; y; y--) { - SDL_memset (row, color, x); + SDL_memset(row, color, x); row += dst->pitch; } } @@ -686,7 +686,7 @@ n--; } if (n >> 1) - SDL_memset4 (pixels, cc, n >> 1); + SDL_memset4(pixels, cc, n >> 1); if (n & 1) pixels[n - 1] = c; row += dst->pitch; @@ -700,7 +700,7 @@ for (y = dstrect->h; y; --y) { Uint8 *pixels = row; for (x = dstrect->w; x; --x) { - SDL_memcpy (pixels, &color, 3); + SDL_memcpy(pixels, &color, 3); pixels += 3; } row += dst->pitch; @@ -709,13 +709,13 @@ case 4: for (y = dstrect->h; y; --y) { - SDL_memset4 (row, color, dstrect->w); + SDL_memset4(row, color, dstrect->w); row += dst->pitch; } break; } } - SDL_UnlockSurface (dst); + SDL_UnlockSurface(dst); /* We're done! */ return (0); @@ -725,18 +725,18 @@ * Lock a surface to directly access the pixels */ int -SDL_LockSurface (SDL_Surface * surface) +SDL_LockSurface(SDL_Surface * surface) { if (!surface->locked) { /* Perform the lock */ if (surface->flags & SDL_HWSURFACE) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); - if (_this->LockHWSurface (_this, surface) < 0) { + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + if (_this->LockHWSurface(_this, surface) < 0) { return (-1); } } if (surface->flags & SDL_RLEACCEL) { - SDL_UnRLESurface (surface, 1); + SDL_UnRLESurface(surface, 1); surface->flags |= SDL_RLEACCEL; /* save accel'd state */ } /* This needs to be done here in case pixels changes value */ @@ -754,7 +754,7 @@ * Unlock a previously locked surface */ void -SDL_UnlockSurface (SDL_Surface * surface) +SDL_UnlockSurface(SDL_Surface * surface) { /* Only perform an unlock if we are locked */ if (!surface->locked || (--surface->locked > 0)) { @@ -766,13 +766,13 @@ /* Unlock hardware or accelerated surfaces */ if (surface->flags & SDL_HWSURFACE) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); - _this->UnlockHWSurface (_this, surface); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + _this->UnlockHWSurface(_this, surface); } else { /* Update RLE encoded surface with new data */ if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) { surface->flags &= ~SDL_RLEACCEL; /* stop lying */ - SDL_RLESurface (surface); + SDL_RLESurface(surface); } } } @@ -781,8 +781,8 @@ * Convert a surface into the specified pixel format. */ SDL_Surface * -SDL_ConvertSurface (SDL_Surface * surface, - SDL_PixelFormat * format, Uint32 flags) +SDL_ConvertSurface(SDL_Surface * surface, + SDL_PixelFormat * format, Uint32 flags) { SDL_Surface *convert; Uint32 colorkey = 0; @@ -800,7 +800,7 @@ break; } if (i == format->palette->ncolors) { - SDL_SetError ("Empty destination palette"); + SDL_SetError("Empty destination palette"); return (NULL); } } @@ -808,26 +808,26 @@ /* Only create hw surfaces with alpha channel if hw alpha blits are supported */ if (format->Amask != 0 && (flags & SDL_HWSURFACE)) { - const SDL_VideoInfo *vi = SDL_GetVideoInfo (); + const SDL_VideoInfo *vi = SDL_GetVideoInfo(); if (!vi || !vi->blit_hw_A) flags &= ~SDL_HWSURFACE; } /* Create a new surface with the desired format */ - convert = SDL_CreateRGBSurface (flags, - surface->w, surface->h, - format->BitsPerPixel, format->Rmask, - format->Gmask, format->Bmask, - format->Amask); + convert = SDL_CreateRGBSurface(flags, + surface->w, surface->h, + format->BitsPerPixel, format->Rmask, + format->Gmask, format->Bmask, + format->Amask); if (convert == NULL) { return (NULL); } /* Copy the palette if any */ if (format->palette && convert->format->palette) { - SDL_memcpy (convert->format->palette->colors, - format->palette->colors, - format->palette->ncolors * sizeof (SDL_Color)); + SDL_memcpy(convert->format->palette->colors, + format->palette->colors, + format->palette->ncolors * sizeof(SDL_Color)); convert->format->palette->ncolors = format->palette->ncolors; } @@ -839,7 +839,7 @@ surface_flags &= ~SDL_SRCCOLORKEY; } else { colorkey = surface->format->colorkey; - SDL_SetColorKey (surface, 0, 0); + SDL_SetColorKey(surface, 0, 0); } } if ((surface_flags & SDL_SRCALPHA) == SDL_SRCALPHA) { @@ -848,7 +848,7 @@ surface->flags &= ~SDL_SRCALPHA; } else { alpha = surface->format->alpha; - SDL_SetAlpha (surface, 0, 0); + SDL_SetAlpha(surface, 0, 0); } } @@ -857,32 +857,32 @@ bounds.y = 0; bounds.w = surface->w; bounds.h = surface->h; - SDL_LowerBlit (surface, &bounds, convert, &bounds); + SDL_LowerBlit(surface, &bounds, convert, &bounds); /* Clean up the original surface, and update converted surface */ if (convert != NULL) { - SDL_SetClipRect (convert, &surface->clip_rect); + SDL_SetClipRect(convert, &surface->clip_rect); } if ((surface_flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { Uint32 cflags = surface_flags & (SDL_SRCCOLORKEY | SDL_RLEACCELOK); if (convert != NULL) { Uint8 keyR, keyG, keyB; - SDL_GetRGB (colorkey, surface->format, &keyR, &keyG, &keyB); - SDL_SetColorKey (convert, cflags | (flags & SDL_RLEACCELOK), - SDL_MapRGB (convert->format, keyR, keyG, keyB)); + SDL_GetRGB(colorkey, surface->format, &keyR, &keyG, &keyB); + SDL_SetColorKey(convert, cflags | (flags & SDL_RLEACCELOK), + SDL_MapRGB(convert->format, keyR, keyG, keyB)); } - SDL_SetColorKey (surface, cflags, colorkey); + SDL_SetColorKey(surface, cflags, colorkey); } if ((surface_flags & SDL_SRCALPHA) == SDL_SRCALPHA) { Uint32 aflags = surface_flags & (SDL_SRCALPHA | SDL_RLEACCELOK); if (convert != NULL) { - SDL_SetAlpha (convert, aflags | (flags & SDL_RLEACCELOK), alpha); + SDL_SetAlpha(convert, aflags | (flags & SDL_RLEACCELOK), alpha); } if (format->Amask) { surface->flags |= SDL_SRCALPHA; } else { - SDL_SetAlpha (surface, aflags, alpha); + SDL_SetAlpha(surface, aflags, alpha); } } @@ -894,7 +894,7 @@ * Free a surface created by the above function. */ void -SDL_FreeSurface (SDL_Surface * surface) +SDL_FreeSurface(SDL_Surface * surface) { if (surface == NULL) { return; @@ -903,27 +903,27 @@ return; } while (surface->locked > 0) { - SDL_UnlockSurface (surface); + SDL_UnlockSurface(surface); } if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) { - SDL_UnRLESurface (surface, 0); + SDL_UnRLESurface(surface, 0); } if (surface->format) { - SDL_FreeFormat (surface->format); + SDL_FreeFormat(surface->format); surface->format = NULL; } if (surface->map != NULL) { - SDL_FreeBlitMap (surface->map); + SDL_FreeBlitMap(surface->map); surface->map = NULL; } if (surface->hwdata) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); - _this->FreeHWSurface (_this, surface); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + _this->FreeHWSurface(_this, surface); } if (surface->pixels && ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC)) { - SDL_free (surface->pixels); + SDL_free(surface->pixels); } - SDL_free (surface); + SDL_free(surface); #ifdef CHECK_LEAKS --surfaces_allocated; #endif diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_sysvideo.h --- a/src/video/SDL_sysvideo.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_sysvideo.h Mon May 29 04:04:35 2006 +0000 @@ -139,8 +139,8 @@ int firstcolor, int ncolors, SDL_Color * colors); /* Get some platform dependent window information */ - SDL_bool (*GetWindowWMInfo) (_THIS, SDL_Window * window, - SDL_SysWMinfo * info); + SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window, + SDL_SysWMinfo * info); /* Create a YUV video surface (possibly overlay) of the given format. The hardware should be able to perform at least 2x @@ -432,11 +432,11 @@ #define SDL_ShadowSurface ((_this && SDL_CurrentDisplay.num_windows > 0) ? SDL_CurrentWindow.shadow : NULL) #define SDL_PublicSurface (SDL_ShadowSurface ? SDL_ShadowSurface : SDL_VideoSurface) -extern SDL_VideoDevice *SDL_GetVideoDevice (); -extern void SDL_AddBasicVideoDisplay (const SDL_DisplayMode * desktop_mode); -extern void SDL_AddVideoDisplay (SDL_VideoDisplay * display); -extern void SDL_AddDisplayMode (int display, const SDL_DisplayMode * mode); -extern SDL_Window *SDL_GetWindowFromSurface (SDL_Surface * surface); +extern SDL_VideoDevice *SDL_GetVideoDevice(); +extern void SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode); +extern void SDL_AddVideoDisplay(SDL_VideoDisplay * display); +extern void SDL_AddDisplayMode(int display, const SDL_DisplayMode * mode); +extern SDL_Window *SDL_GetWindowFromSurface(SDL_Surface * surface); #endif /* _SDL_sysvideo_h */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_video.c --- a/src/video/SDL_video.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_video.c Mon May 29 04:04:35 2006 +0000 @@ -132,11 +132,11 @@ static SDL_VideoDevice *_this = NULL; /* Various local functions */ -int SDL_VideoInit (const char *driver_name, Uint32 flags); -void SDL_VideoQuit (void); +int SDL_VideoInit(const char *driver_name, Uint32 flags); +void SDL_VideoQuit(void); static int -cmpmodes (const void *A, const void *B) +cmpmodes(const void *A, const void *B) { SDL_DisplayMode a = *(const SDL_DisplayMode *) A; SDL_DisplayMode b = *(const SDL_DisplayMode *) B; @@ -147,8 +147,8 @@ if (a.h != b.h) { return b.h - a.h; } - if (SDL_BITSPERPIXEL (a.format) != SDL_BITSPERPIXEL (b.format)) { - return SDL_BITSPERPIXEL (b.format) - SDL_BITSPERPIXEL (a.format); + if (SDL_BITSPERPIXEL(a.format) != SDL_BITSPERPIXEL(b.format)) { + return SDL_BITSPERPIXEL(b.format) - SDL_BITSPERPIXEL(a.format); } if (a.refresh_rate != b.refresh_rate) { return b.refresh_rate - a.refresh_rate; @@ -157,15 +157,15 @@ } int -SDL_GetNumVideoDrivers (void) +SDL_GetNumVideoDrivers(void) { - return SDL_arraysize (bootstrap) - 1; + return SDL_arraysize(bootstrap) - 1; } const char * -SDL_GetVideoDriver (int index) +SDL_GetVideoDriver(int index) { - if (index >= 0 && index < SDL_GetNumVideoDrivers ()) { + if (index >= 0 && index < SDL_GetNumVideoDrivers()) { return bootstrap[index]->name; } return NULL; @@ -175,7 +175,7 @@ * Initialize the video and event subsystems -- determine native pixel format */ int -SDL_VideoInit (const char *driver_name, Uint32 flags) +SDL_VideoInit(const char *driver_name, Uint32 flags) { SDL_VideoDevice *video; int index; @@ -188,14 +188,14 @@ flags |= SDL_INIT_EVENTTHREAD; #elif defined(CANT_THREAD_EVENTS) if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) { - SDL_SetError ("OS doesn't support threaded events"); + SDL_SetError("OS doesn't support threaded events"); return -1; } #endif /* Check to make sure we don't overwrite '_this' */ if (_this != NULL) { - SDL_VideoQuit (); + SDL_VideoQuit(); } /* Select the proper video driver */ @@ -203,18 +203,18 @@ video = NULL; if (driver_name != NULL) { for (i = 0; bootstrap[i]; ++i) { - if (SDL_strncmp (bootstrap[i]->name, driver_name, - SDL_strlen (bootstrap[i]->name)) == 0) { - if (bootstrap[i]->available ()) { - video = bootstrap[i]->create (index); + if (SDL_strncmp(bootstrap[i]->name, driver_name, + SDL_strlen(bootstrap[i]->name)) == 0) { + if (bootstrap[i]->available()) { + video = bootstrap[i]->create(index); } break; } } } else { for (i = 0; bootstrap[i]; ++i) { - if (bootstrap[i]->available ()) { - video = bootstrap[i]->create (index); + if (bootstrap[i]->available()) { + video = bootstrap[i]->create(index); if (video != NULL) { break; } @@ -223,9 +223,9 @@ } if (video == NULL) { if (driver_name) { - SDL_SetError ("%s not available", driver_name); + SDL_SetError("%s not available", driver_name); } else { - SDL_SetError ("No available video device"); + SDL_SetError("No available video device"); } return -1; } @@ -255,38 +255,38 @@ _this->gl_config.swap_control = -1; /* not known, don't set */ /* Initialize the video subsystem */ - if (_this->VideoInit (_this) < 0) { - SDL_VideoQuit (); + if (_this->VideoInit(_this) < 0) { + SDL_VideoQuit(); return -1; } /* Make sure some displays were added */ if (_this->num_displays == 0) { - SDL_SetError ("The video driver did not add any displays"); - SDL_VideoQuit (); + SDL_SetError("The video driver did not add any displays"); + SDL_VideoQuit(); return (-1); } /* Sort the video modes */ for (i = 0; i < _this->num_displays; ++i) { - SDL_qsort (_this->displays[i].display_modes, - _this->displays[i].num_display_modes, - sizeof (SDL_DisplayMode), cmpmodes); + SDL_qsort(_this->displays[i].display_modes, + _this->displays[i].num_display_modes, + sizeof(SDL_DisplayMode), cmpmodes); } /* Start the event loop */ - if (SDL_StartEventLoop (flags) < 0) { - SDL_VideoQuit (); + if (SDL_StartEventLoop(flags) < 0) { + SDL_VideoQuit(); return -1; } - SDL_CursorInit (flags & SDL_INIT_EVENTTHREAD); + SDL_CursorInit(flags & SDL_INIT_EVENTTHREAD); /* We're ready to go! */ return 0; } const char * -SDL_GetCurrentVideoDriver () +SDL_GetCurrentVideoDriver() { if (!_this) { return NULL; @@ -295,13 +295,13 @@ } SDL_VideoDevice * -SDL_GetVideoDevice () +SDL_GetVideoDevice() { return _this; } const SDL_VideoInfo * -SDL_GetVideoInfo (void) +SDL_GetVideoInfo(void) { if (!_this) { return NULL; @@ -310,28 +310,28 @@ } void -SDL_AddBasicVideoDisplay (const SDL_DisplayMode * desktop_mode) +SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode) { SDL_VideoDisplay display; - SDL_zero (display); + SDL_zero(display); if (desktop_mode) { display.desktop_mode = *desktop_mode; } display.current_mode = display.desktop_mode; display.max_windows = 1; - SDL_AddVideoDisplay (&display); + SDL_AddVideoDisplay(&display); } void -SDL_AddVideoDisplay (SDL_VideoDisplay * display) +SDL_AddVideoDisplay(SDL_VideoDisplay * display) { SDL_VideoDisplay *displays; displays = - SDL_realloc (_this->displays, - (_this->num_displays + 1) * sizeof (*displays)); + SDL_realloc(_this->displays, + (_this->num_displays + 1) * sizeof(*displays)); if (displays) { displays[_this->num_displays] = *display; _this->displays = displays; @@ -340,7 +340,7 @@ } int -SDL_GetNumVideoDisplays (void) +SDL_GetNumVideoDisplays(void) { if (!_this) { return 0; @@ -349,16 +349,16 @@ } int -SDL_SelectVideoDisplay (int index) +SDL_SelectVideoDisplay(int index) { if (!_this) { - SDL_SetError ("Video subsystem has not been initialized"); + SDL_SetError("Video subsystem has not been initialized"); return (-1); } if (index >= 0) { if (index >= _this->num_displays) { - SDL_SetError ("index must be in the range 0 - %d", - _this->num_displays - 1); + SDL_SetError("index must be in the range 0 - %d", + _this->num_displays - 1); return -1; } _this->current_display = index; @@ -367,7 +367,7 @@ } void -SDL_AddDisplayMode (int display, const SDL_DisplayMode * mode) +SDL_AddDisplayMode(int display, const SDL_DisplayMode * mode) { SDL_DisplayMode *modes; int i, nmodes; @@ -376,13 +376,13 @@ modes = SDL_CurrentDisplay.display_modes; nmodes = SDL_CurrentDisplay.num_display_modes; for (i = 0; i < nmodes; ++i) { - if (SDL_memcmp (mode, &modes[i], sizeof (*mode)) == 0) { + if (SDL_memcmp(mode, &modes[i], sizeof(*mode)) == 0) { return; } } /* Go ahead and add the new mode */ - modes = SDL_realloc (modes, (nmodes + 1) * sizeof (*mode)); + modes = SDL_realloc(modes, (nmodes + 1) * sizeof(*mode)); if (modes) { SDL_CurrentDisplay.display_modes = modes; modes[nmodes] = *mode; @@ -391,7 +391,7 @@ } int -SDL_GetNumDisplayModes () +SDL_GetNumDisplayModes() { if (_this) { return SDL_CurrentDisplay.num_display_modes; @@ -400,18 +400,18 @@ } const SDL_DisplayMode * -SDL_GetDisplayMode (int index) +SDL_GetDisplayMode(int index) { - if (index < 0 || index >= SDL_GetNumDisplayModes ()) { - SDL_SetError ("index must be in the range of 0 - %d", - SDL_GetNumDisplayModes ()); + if (index < 0 || index >= SDL_GetNumDisplayModes()) { + SDL_SetError("index must be in the range of 0 - %d", + SDL_GetNumDisplayModes()); return NULL; } return &SDL_CurrentDisplay.display_modes[index]; } const SDL_DisplayMode * -SDL_GetDesktopDisplayMode (void) +SDL_GetDesktopDisplayMode(void) { if (_this) { return &SDL_CurrentDisplay.desktop_mode; @@ -420,7 +420,7 @@ } const SDL_DisplayMode * -SDL_GetCurrentDisplayMode (void) +SDL_GetCurrentDisplayMode(void) { if (_this) { return &SDL_CurrentDisplay.current_mode; @@ -429,8 +429,8 @@ } SDL_DisplayMode * -SDL_GetClosestDisplayMode (const SDL_DisplayMode * mode, - SDL_DisplayMode * closest) +SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode, + SDL_DisplayMode * closest) { Uint32 target_format; int target_refresh_rate; @@ -471,10 +471,10 @@ if (current->format != match->format) { /* Sorted highest depth to lowest */ if (current->format == target_format || - (SDL_BITSPERPIXEL (current->format) >= - SDL_BITSPERPIXEL (target_format) - && SDL_PIXELTYPE (current->format) == - SDL_PIXELTYPE (target_format))) { + (SDL_BITSPERPIXEL(current->format) >= + SDL_BITSPERPIXEL(target_format) + && SDL_PIXELTYPE(current->format) == + SDL_PIXELTYPE(target_format))) { match = current; } continue; @@ -510,20 +510,20 @@ } int -SDL_SetDisplayMode (const SDL_DisplayMode * mode) +SDL_SetDisplayMode(const SDL_DisplayMode * mode) { SDL_VideoDisplay *display; SDL_DisplayMode display_mode; int i; if (!_this) { - SDL_SetError ("Video subsystem has not been initialized"); + SDL_SetError("Video subsystem has not been initialized"); return -1; } /* Make sure there's an actual display mode to set */ if (!mode) { - SDL_SetError ("No mode passed to SDL_SetDisplayMode"); + SDL_SetError("No mode passed to SDL_SetDisplayMode"); return -1; } display = &SDL_CurrentDisplay; @@ -544,16 +544,16 @@ } /* Get a good video mode, the closest one possible */ - if (!SDL_GetClosestDisplayMode (&display_mode, &display_mode)) { - SDL_SetError ("No video mode large enough for %dx%d", - display_mode.w, display_mode.h); + if (!SDL_GetClosestDisplayMode(&display_mode, &display_mode)) { + SDL_SetError("No video mode large enough for %dx%d", + display_mode.w, display_mode.h); return -1; } /* See if there's anything left to do */ if (SDL_memcmp - (&display_mode, SDL_GetCurrentDisplayMode (), - sizeof (display_mode)) == 0) { + (&display_mode, SDL_GetCurrentDisplayMode(), + sizeof(display_mode)) == 0) { return 0; } @@ -561,20 +561,20 @@ for (i = 0; i < display->num_windows; ++i) { SDL_Window *window = &display->windows[i]; if (window->shadow) { - SDL_FreeSurface (window->shadow); + SDL_FreeSurface(window->shadow); window->shadow = NULL; } if (window->surface) { - SDL_FreeSurface (window->surface); + SDL_FreeSurface(window->surface); window->surface = NULL; } } - return _this->SetDisplayMode (_this, &display_mode); + return _this->SetDisplayMode(_this, &display_mode); } SDL_WindowID -SDL_CreateWindow (const char *title, int x, int y, int w, int h, Uint32 flags) +SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) { const Uint32 allowed_flags = (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS | @@ -589,36 +589,36 @@ SDL_Window *windows; if (!_this) { - SDL_SetError ("Video subsystem has not been initialized"); + SDL_SetError("Video subsystem has not been initialized"); return 0; } - SDL_zero (window); + SDL_zero(window); window.id = _this->next_window_id++; - window.title = title ? SDL_strdup (title) : NULL; + window.title = title ? SDL_strdup(title) : NULL; window.x = x; window.y = y; window.w = w; window.h = h; window.flags = (flags & allowed_flags); - if (_this->CreateWindow && _this->CreateWindow (_this, &window) < 0) { + if (_this->CreateWindow && _this->CreateWindow(_this, &window) < 0) { if (window.title) { - SDL_free (window.title); + SDL_free(window.title); } return 0; } num_windows = SDL_CurrentDisplay.num_windows; windows = - SDL_realloc (SDL_CurrentDisplay.windows, - (num_windows + 1) * sizeof (*windows)); + SDL_realloc(SDL_CurrentDisplay.windows, + (num_windows + 1) * sizeof(*windows)); if (!windows) { if (_this->DestroyWindow) { - _this->DestroyWindow (_this, &window); + _this->DestroyWindow(_this, &window); } if (window.title) { - SDL_free (window.title); + SDL_free(window.title); } return 0; } @@ -630,35 +630,35 @@ } SDL_WindowID -SDL_CreateWindowFrom (void *data) +SDL_CreateWindowFrom(void *data) { SDL_Window window; int num_windows; SDL_Window *windows; if (!_this) { - SDL_SetError ("Video subsystem has not been initialized"); + SDL_SetError("Video subsystem has not been initialized"); return (0); } - SDL_zero (window); + SDL_zero(window); window.id = _this->next_window_id++; if (!_this->CreateWindowFrom || - _this->CreateWindowFrom (_this, &window, data) < 0) { + _this->CreateWindowFrom(_this, &window, data) < 0) { return 0; } num_windows = SDL_CurrentDisplay.num_windows; windows = - SDL_realloc (SDL_CurrentDisplay.windows, - (num_windows + 1) * sizeof (*windows)); + SDL_realloc(SDL_CurrentDisplay.windows, + (num_windows + 1) * sizeof(*windows)); if (!windows) { if (_this->DestroyWindow) { - _this->DestroyWindow (_this, &window); + _this->DestroyWindow(_this, &window); } if (window.title) { - SDL_free (window.title); + SDL_free(window.title); } return 0; } @@ -670,7 +670,7 @@ } static __inline__ SDL_Window * -SDL_GetWindowFromID (SDL_WindowID windowID) +SDL_GetWindowFromID(SDL_WindowID windowID) { int i, j; @@ -691,7 +691,7 @@ } SDL_Window * -SDL_GetWindowFromSurface (SDL_Surface * surface) +SDL_GetWindowFromSurface(SDL_Surface * surface) { int i, j; @@ -713,9 +713,9 @@ Uint32 -SDL_GetWindowFlags (SDL_WindowID windowID) +SDL_GetWindowFlags(SDL_WindowID windowID) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window) { return 0; @@ -724,27 +724,27 @@ } void -SDL_SetWindowTitle (SDL_WindowID windowID, const char *title) +SDL_SetWindowTitle(SDL_WindowID windowID, const char *title) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window) { return; } if (window->title) { - SDL_free (window->title); + SDL_free(window->title); } - window->title = SDL_strdup (title); + window->title = SDL_strdup(title); if (_this->SetWindowTitle) { - _this->SetWindowTitle (_this, window); + _this->SetWindowTitle(_this, window); } } const char * -SDL_GetWindowTitle (SDL_WindowID windowID) +SDL_GetWindowTitle(SDL_WindowID windowID) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window) { return NULL; @@ -753,9 +753,9 @@ } void -SDL_SetWindowData (SDL_WindowID windowID, void *userdata) +SDL_SetWindowData(SDL_WindowID windowID, void *userdata) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window) { return; @@ -764,9 +764,9 @@ } void * -SDL_GetWindowData (SDL_WindowID windowID) +SDL_GetWindowData(SDL_WindowID windowID) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window) { return NULL; @@ -775,9 +775,9 @@ } void -SDL_SetWindowPosition (SDL_WindowID windowID, int x, int y) +SDL_SetWindowPosition(SDL_WindowID windowID, int x, int y) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window) { return; @@ -787,14 +787,14 @@ window->y = y; if (_this->SetWindowPosition) { - _this->SetWindowPosition (_this, window); + _this->SetWindowPosition(_this, window); } } void -SDL_GetWindowPosition (SDL_WindowID windowID, int *x, int *y) +SDL_GetWindowPosition(SDL_WindowID windowID, int *x, int *y) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window) { return; @@ -808,9 +808,9 @@ } void -SDL_SetWindowSize (SDL_WindowID windowID, int w, int h) +SDL_SetWindowSize(SDL_WindowID windowID, int w, int h) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window) { return; @@ -820,14 +820,14 @@ window->h = h; if (_this->SetWindowSize) { - _this->SetWindowSize (_this, window); + _this->SetWindowSize(_this, window); } } void -SDL_GetWindowSize (SDL_WindowID windowID, int *w, int *h) +SDL_GetWindowSize(SDL_WindowID windowID, int *w, int *h) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window) { return; @@ -841,9 +841,9 @@ } void -SDL_ShowWindow (SDL_WindowID windowID) +SDL_ShowWindow(SDL_WindowID windowID) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window || (window->flags & SDL_WINDOW_SHOWN)) { return; @@ -852,14 +852,14 @@ window->flags |= SDL_WINDOW_SHOWN; if (_this->ShowWindow) { - _this->ShowWindow (_this, window); + _this->ShowWindow(_this, window); } } void -SDL_HideWindow (SDL_WindowID windowID) +SDL_HideWindow(SDL_WindowID windowID) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window || !(window->flags & SDL_WINDOW_SHOWN)) { return; @@ -868,28 +868,28 @@ window->flags &= ~SDL_WINDOW_SHOWN; if (_this->HideWindow) { - _this->HideWindow (_this, window); + _this->HideWindow(_this, window); } } void -SDL_RaiseWindow (SDL_WindowID windowID) +SDL_RaiseWindow(SDL_WindowID windowID) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window) { return; } if (_this->RaiseWindow) { - _this->RaiseWindow (_this, window); + _this->RaiseWindow(_this, window); } } void -SDL_MaximizeWindow (SDL_WindowID windowID) +SDL_MaximizeWindow(SDL_WindowID windowID) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window || (window->flags & SDL_WINDOW_MAXIMIZED)) { return; @@ -898,14 +898,14 @@ window->flags |= SDL_WINDOW_MAXIMIZED; if (_this->MaximizeWindow) { - _this->MaximizeWindow (_this, window); + _this->MaximizeWindow(_this, window); } } void -SDL_MinimizeWindow (SDL_WindowID windowID) +SDL_MinimizeWindow(SDL_WindowID windowID) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window || (window->flags & SDL_WINDOW_MINIMIZED)) { return; @@ -914,14 +914,14 @@ window->flags |= SDL_WINDOW_MINIMIZED; if (_this->MinimizeWindow) { - _this->MinimizeWindow (_this, window); + _this->MinimizeWindow(_this, window); } } void -SDL_RestoreWindow (SDL_WindowID windowID) +SDL_RestoreWindow(SDL_WindowID windowID) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window || (window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) { @@ -931,14 +931,14 @@ window->flags &= ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED); if (_this->RestoreWindow) { - _this->RestoreWindow (_this, window); + _this->RestoreWindow(_this, window); } } void -SDL_SetWindowGrab (SDL_WindowID windowID, int mode) +SDL_SetWindowGrab(SDL_WindowID windowID, int mode) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window || (!!mode == !!(window->flags & SDL_WINDOW_INPUT_GRABBED))) { return; @@ -951,14 +951,14 @@ } if (_this->SetWindowGrab) { - _this->SetWindowGrab (_this, window); + _this->SetWindowGrab(_this, window); } } int -SDL_GetWindowGrab (SDL_WindowID windowID) +SDL_GetWindowGrab(SDL_WindowID windowID) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window) { return 0; @@ -968,7 +968,7 @@ } void -SDL_DestroyWindow (SDL_WindowID windowID) +SDL_DestroyWindow(SDL_WindowID windowID) { int i, j; @@ -985,28 +985,27 @@ } if (window->flags & SDL_WINDOW_INPUT_GRABBED) { window->flags &= ~SDL_WINDOW_INPUT_GRABBED; - _this->SetWindowGrab (_this, window); + _this->SetWindowGrab(_this, window); } if (window->shadow) { - SDL_FreeSurface (window->shadow); + SDL_FreeSurface(window->shadow); } if (window->surface) { - SDL_FreeSurface (window->surface); + SDL_FreeSurface(window->surface); } if (_this->DestroyWindow) { - _this->DestroyWindow (_this, window); + _this->DestroyWindow(_this, window); } if (window->title) { - SDL_free (window->title); + SDL_free(window->title); } if (window->gamma) { - SDL_free (window->gamma); + SDL_free(window->gamma); } if (j != display->num_windows - 1) { - SDL_memcpy (&display->windows[i], - &display->windows[i + 1], - (display->num_windows - i - - 1) * sizeof (*window)); + SDL_memcpy(&display->windows[i], + &display->windows[i + 1], + (display->num_windows - i - 1) * sizeof(*window)); } --display->num_windows; return; @@ -1015,9 +1014,9 @@ } SDL_Surface * -SDL_CreateWindowSurface (SDL_WindowID windowID, Uint32 format, Uint32 flags) +SDL_CreateWindowSurface(SDL_WindowID windowID, Uint32 format, Uint32 flags) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); Uint32 black; SDL_Surface *surface; @@ -1030,7 +1029,7 @@ } if (!window->surface) { - _this->CreateWindowSurface (_this, window, flags); + _this->CreateWindowSurface(_this, window, flags); if (!window->surface) { return NULL; } @@ -1039,23 +1038,23 @@ surface = window->surface; if (window->shadow) { - SDL_FreeSurface (window->shadow); + SDL_FreeSurface(window->shadow); window->shadow = NULL; } /* Create a shadow surface if necessary */ if ((!(flags & SDL_ANYFORMAT) - && (format != SDL_GetCurrentDisplayMode ()->format)) + && (format != SDL_GetCurrentDisplayMode()->format)) || ((flags & SDL_HWPALETTE) && !(window->surface->flags & SDL_HWPALETTE))) { int bpp; Uint32 Rmask, Gmask, Bmask, Amask; - SDL_PixelFormatEnumToMasks (format, &bpp, &Amask, &Gmask, &Bmask, - &Amask); + SDL_PixelFormatEnumToMasks(format, &bpp, &Amask, &Gmask, &Bmask, + &Amask); window->shadow = - SDL_CreateRGBSurface (SDL_SWSURFACE, surface->w, surface->h, bpp, - Rmask, Gmask, Bmask, Amask); + SDL_CreateRGBSurface(SDL_SWSURFACE, surface->w, surface->h, bpp, + Rmask, Gmask, Bmask, Amask); if (window->shadow == NULL) { return NULL; } @@ -1065,26 +1064,26 @@ /* 8-bit shadow surfaces report that they have exclusive palette */ if (surface->format->palette) { surface->flags |= SDL_HWPALETTE; - if (format == SDL_GetCurrentDisplayMode ()->format) { - SDL_memcpy (surface->format->palette->colors, - window->surface->format->palette->colors, - window->surface->format->palette->ncolors * - sizeof (SDL_Color)); + if (format == SDL_GetCurrentDisplayMode()->format) { + SDL_memcpy(surface->format->palette->colors, + window->surface->format->palette->colors, + window->surface->format->palette->ncolors * + sizeof(SDL_Color)); } else { - SDL_DitherColors (surface->format->palette->colors, bpp); + SDL_DitherColors(surface->format->palette->colors, bpp); } } } /* Clear the surface for display */ { - Uint32 black = SDL_MapRGB (surface->format, 0, 0, 0); - SDL_FillRect (surface, NULL, black); + Uint32 black = SDL_MapRGB(surface->format, 0, 0, 0); + SDL_FillRect(surface, NULL, black); if (surface->flags & SDL_DOUBLEBUF) { - SDL_Flip (surface); - SDL_FillRect (surface, NULL, black); + SDL_Flip(surface); + SDL_FillRect(surface, NULL, black); } - SDL_Flip (surface); + SDL_Flip(surface); } return surface; @@ -1094,12 +1093,12 @@ * Convert a surface into the video pixel format. */ SDL_Surface * -SDL_DisplayFormat (SDL_Surface * surface) +SDL_DisplayFormat(SDL_Surface * surface) { Uint32 flags; if (!SDL_PublicSurface) { - SDL_SetError ("No video mode has been set"); + SDL_SetError("No video mode has been set"); return (NULL); } /* Set the flags appropriate for copying to display surface */ @@ -1115,7 +1114,7 @@ flags |= surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA | SDL_RLEACCELOK); #endif - return (SDL_ConvertSurface (surface, SDL_PublicSurface->format, flags)); + return (SDL_ConvertSurface(surface, SDL_PublicSurface->format, flags)); } /* @@ -1123,7 +1122,7 @@ * the screen, but including an alpha channel. */ SDL_Surface * -SDL_DisplayFormatAlpha (SDL_Surface * surface) +SDL_DisplayFormatAlpha(SDL_Surface * surface) { SDL_PixelFormat *vf; SDL_PixelFormat *format; @@ -1136,7 +1135,7 @@ Uint32 bmask = 0x000000ff; if (!SDL_PublicSurface) { - SDL_SetError ("No video mode has been set"); + SDL_SetError("No video mode has been set"); return (NULL); } vf = SDL_PublicSurface->format; @@ -1168,11 +1167,11 @@ optimised alpha format is written, add the converter here */ break; } - format = SDL_AllocFormat (32, rmask, gmask, bmask, amask); + format = SDL_AllocFormat(32, rmask, gmask, bmask, amask); flags = SDL_PublicSurface->flags & SDL_HWSURFACE; flags |= surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK); - converted = SDL_ConvertSurface (surface, format, flags); - SDL_FreeFormat (format); + converted = SDL_ConvertSurface(surface, format, flags); + SDL_FreeFormat(format); return (converted); } @@ -1180,7 +1179,7 @@ * Update a specific portion of the physical screen */ void -SDL_UpdateRect (SDL_Surface * screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) +SDL_UpdateRect(SDL_Surface * screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) { if (screen) { SDL_Rect rect; @@ -1200,34 +1199,34 @@ rect.y = (Sint16) y; rect.w = (Uint16) w; rect.h = (Uint16) h; - SDL_UpdateRects (screen, 1, &rect); + SDL_UpdateRects(screen, 1, &rect); } } void -SDL_UpdateRects (SDL_Surface * screen, int numrects, SDL_Rect * rects) +SDL_UpdateRects(SDL_Surface * screen, int numrects, SDL_Rect * rects) { int i; SDL_Window *window; /* Find the window corresponding to this surface */ - window = SDL_GetWindowFromSurface (screen); + window = SDL_GetWindowFromSurface(screen); if (!window) { - SDL_SetError ("Couldn't find window associated with surface"); + SDL_SetError("Couldn't find window associated with surface"); return; } if (screen->flags & SDL_SHADOW_SURFACE) { - if (SHOULD_DRAWCURSOR (SDL_cursorstate)) { - SDL_LockCursor (); - SDL_DrawCursor (screen); + if (SHOULD_DRAWCURSOR(SDL_cursorstate)) { + SDL_LockCursor(); + SDL_DrawCursor(screen); for (i = 0; i < numrects; ++i) { - SDL_LowerBlit (screen, &rects[i], window->surface, &rects[i]); + SDL_LowerBlit(screen, &rects[i], window->surface, &rects[i]); } - SDL_EraseCursor (screen); - SDL_UnlockCursor (); + SDL_EraseCursor(screen); + SDL_UnlockCursor(); } else { for (i = 0; i < numrects; ++i) { - SDL_LowerBlit (screen, &rects[i], window->surface, &rects[i]); + SDL_LowerBlit(screen, &rects[i], window->surface, &rects[i]); } } @@ -1243,13 +1242,13 @@ rects[i].x += offset_x; rects[i].y += offset_y; } - _this->UpdateWindowSurface (_this, window, numrects, rects); + _this->UpdateWindowSurface(_this, window, numrects, rects); for (i = 0; i < numrects; ++i) { rects[i].x -= offset_x; rects[i].y -= offset_y; } } else { - _this->UpdateWindowSurface (_this, window, numrects, rects); + _this->UpdateWindowSurface(_this, window, numrects, rects); } } } @@ -1258,14 +1257,14 @@ * Performs hardware double buffering, if possible, or a full update if not. */ int -SDL_Flip (SDL_Surface * screen) +SDL_Flip(SDL_Surface * screen) { SDL_Window *window; /* Find the window corresponding to this surface */ - window = SDL_GetWindowFromSurface (screen); + window = SDL_GetWindowFromSurface(screen); if (!window) { - SDL_SetError ("Couldn't find window associated with surface"); + SDL_SetError("Couldn't find window associated with surface"); return; } @@ -1277,30 +1276,30 @@ rect.y = 0; rect.w = screen->w; rect.h = screen->h; - if (SHOULD_DRAWCURSOR (SDL_cursorstate)) { - SDL_LockCursor (); - SDL_DrawCursor (screen); - SDL_LowerBlit (screen, &rect, window->surface, &rect); - SDL_EraseCursor (screen); - SDL_UnlockCursor (); + if (SHOULD_DRAWCURSOR(SDL_cursorstate)) { + SDL_LockCursor(); + SDL_DrawCursor(screen); + SDL_LowerBlit(screen, &rect, window->surface, &rect); + SDL_EraseCursor(screen); + SDL_UnlockCursor(); } else { - SDL_LowerBlit (screen, &rect, window->surface, &rect); + SDL_LowerBlit(screen, &rect, window->surface, &rect); } /* Fall through to video surface update */ screen = window->surface; } if (screen->flags & SDL_DOUBLEBUF) { - _this->FlipWindowSurface (_this, window); + _this->FlipWindowSurface(_this, window); } else { - SDL_UpdateRect (screen, 0, 0, 0, 0); + SDL_UpdateRect(screen, 0, 0, 0, 0); } return (0); } int -SDL_SetColors (SDL_Surface * screen, SDL_Color * colors, int firstcolor, - int ncolors) +SDL_SetColors(SDL_Surface * screen, SDL_Color * colors, int firstcolor, + int ncolors) { SDL_Window *window = NULL; SDL_Palette *pal; @@ -1320,13 +1319,13 @@ } if (colors != (pal->colors + firstcolor)) { - SDL_memcpy (pal->colors + firstcolor, colors, - ncolors * sizeof (*colors)); + SDL_memcpy(pal->colors + firstcolor, colors, + ncolors * sizeof(*colors)); } - SDL_FormatChanged (screen); + SDL_FormatChanged(screen); if (screen->flags & (SDL_SHADOW_SURFACE | SDL_SCREEN_SURFACE)) { - window = SDL_GetWindowFromSurface (screen); + window = SDL_GetWindowFromSurface(screen); if (!window) { return 0; } @@ -1342,22 +1341,22 @@ * changes to its logical palette so that * updates are always identity blits */ - SDL_memcpy (vidpal->colors + firstcolor, colors, - ncolors * sizeof (*colors)); + SDL_memcpy(vidpal->colors + firstcolor, colors, + ncolors * sizeof(*colors)); } if (window->surface->flags & SDL_HWPALETTE) { /* Set the physical palette */ screen = window->surface; } else { - SDL_UpdateRect (screen, 0, 0, 0, 0); + SDL_UpdateRect(screen, 0, 0, 0, 0); } } if (screen->flags & SDL_SCREEN_SURFACE) { if (_this->SetWindowColors) { gotall = - _this->SetWindowColors (_this, window, firstcolor, ncolors, - colors); + _this->SetWindowColors(_this, window, firstcolor, ncolors, + colors); if (!gotall) { /* The video flags shouldn't have SDL_HWPALETTE, and the video driver is responsible for copying back the @@ -1366,14 +1365,14 @@ ; } } - SDL_CursorPaletteChanged (); + SDL_CursorPaletteChanged(); } return gotall; } void -SDL_VideoQuit (void) +SDL_VideoQuit(void) { int i, j; @@ -1382,70 +1381,70 @@ } /* Halt event processing before doing anything else */ - SDL_StopEventLoop (); + SDL_StopEventLoop(); /* Clean up allocated window manager items */ - SDL_CursorQuit (); + SDL_CursorQuit(); /* Clean up the system video */ for (i = _this->num_displays; i--;) { SDL_VideoDisplay *display = &_this->displays[i]; for (j = display->num_windows; j--;) { - SDL_DestroyWindow (display->windows[i].id); + SDL_DestroyWindow(display->windows[i].id); } if (display->windows) { - SDL_free (display->windows); + SDL_free(display->windows); display->windows = NULL; } } - _this->VideoQuit (_this); + _this->VideoQuit(_this); if (_this->displays) { - SDL_free (_this->displays); + SDL_free(_this->displays); } - _this->free (_this); + _this->free(_this); _this = NULL; } /* Load the GL driver library */ int -SDL_GL_LoadLibrary (const char *path) +SDL_GL_LoadLibrary(const char *path) { int retval; retval = -1; if (_this == NULL) { - SDL_SetError ("Video subsystem has not been initialized"); + SDL_SetError("Video subsystem has not been initialized"); } else { if (_this->GL_LoadLibrary) { - retval = _this->GL_LoadLibrary (_this, path); + retval = _this->GL_LoadLibrary(_this, path); } else { - SDL_SetError ("No dynamic GL support in video driver"); + SDL_SetError("No dynamic GL support in video driver"); } } return (retval); } void * -SDL_GL_GetProcAddress (const char *proc) +SDL_GL_GetProcAddress(const char *proc) { void *func; func = NULL; if (_this->GL_GetProcAddress) { if (_this->gl_config.driver_loaded) { - func = _this->GL_GetProcAddress (_this, proc); + func = _this->GL_GetProcAddress(_this, proc); } else { - SDL_SetError ("No GL driver has been loaded"); + SDL_SetError("No GL driver has been loaded"); } } else { - SDL_SetError ("No dynamic GL support in video driver"); + SDL_SetError("No dynamic GL support in video driver"); } return func; } /* Set the specified GL attribute for setting up a GL video mode */ int -SDL_GL_SetAttribute (SDL_GLattr attr, int value) +SDL_GL_SetAttribute(SDL_GLattr attr, int value) { int retval; @@ -1503,7 +1502,7 @@ _this->gl_config.swap_control = value; break; default: - SDL_SetError ("Unknown OpenGL attribute"); + SDL_SetError("Unknown OpenGL attribute"); retval = -1; break; } @@ -1512,27 +1511,27 @@ /* Retrieve an attribute value from the windowing system. */ int -SDL_GL_GetAttribute (SDL_GLattr attr, int *value) +SDL_GL_GetAttribute(SDL_GLattr attr, int *value) { int retval = -1; if (_this->GL_GetAttribute) { - retval = _this->GL_GetAttribute (_this, attr, value); + retval = _this->GL_GetAttribute(_this, attr, value); } else { *value = 0; - SDL_SetError ("GL_GetAttribute not supported"); + SDL_SetError("GL_GetAttribute not supported"); } return retval; } /* Perform a GL buffer swap on the current GL context */ void -SDL_GL_SwapBuffers (void) +SDL_GL_SwapBuffers(void) { if (SDL_VideoSurface->flags & SDL_INTERNALOPENGL) { - _this->GL_SwapBuffers (_this); + _this->GL_SwapBuffers(_this); } else { - SDL_SetError ("OpenGL video mode has not been set"); + SDL_SetError("OpenGL video mode has not been set"); } } @@ -1540,7 +1539,7 @@ /* Utility function used by SDL_WM_SetIcon(); * flags & 1 for color key, flags & 2 for alpha channel. */ static void -CreateMaskFromColorKeyOrAlpha (SDL_Surface * icon, Uint8 * mask, int flags) +CreateMaskFromColorKeyOrAlpha(SDL_Surface * icon, Uint8 * mask, int flags) { int x, y; Uint32 colorkey; @@ -1556,7 +1555,7 @@ pixels = (Uint8 *) icon->pixels + y * icon->pitch; for (x = 0; x < icon->w; ++x) { if (*pixels++ == colorkey) { - SET_MASKBIT (icon, x, y, mask); + SET_MASKBIT(icon, x, y, mask); } } } @@ -1570,10 +1569,10 @@ pixels = (Uint16 *) icon->pixels + y * icon->pitch / 2; for (x = 0; x < icon->w; ++x) { if ((flags & 1) && *pixels == colorkey) { - SET_MASKBIT (icon, x, y, mask); + SET_MASKBIT(icon, x, y, mask); } else if ((flags & 2) && (*pixels & icon->format->Amask) == 0) { - SET_MASKBIT (icon, x, y, mask); + SET_MASKBIT(icon, x, y, mask); } pixels++; } @@ -1588,10 +1587,10 @@ pixels = (Uint32 *) icon->pixels + y * icon->pitch / 4; for (x = 0; x < icon->w; ++x) { if ((flags & 1) && *pixels == colorkey) { - SET_MASKBIT (icon, x, y, mask); + SET_MASKBIT(icon, x, y, mask); } else if ((flags & 2) && (*pixels & icon->format->Amask) == 0) { - SET_MASKBIT (icon, x, y, mask); + SET_MASKBIT(icon, x, y, mask); } pixels++; } @@ -1605,43 +1604,43 @@ * Sets the window manager icon for the display window. */ void -SDL_WM_SetIcon (SDL_Surface * icon, Uint8 * mask) +SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask) { if (icon && _this->SetIcon) { /* Generate a mask if necessary, and create the icon! */ if (mask == NULL) { int mask_len = icon->h * (icon->w + 7) / 8; int flags = 0; - mask = (Uint8 *) SDL_malloc (mask_len); + mask = (Uint8 *) SDL_malloc(mask_len); if (mask == NULL) { return; } - SDL_memset (mask, ~0, mask_len); + SDL_memset(mask, ~0, mask_len); if (icon->flags & SDL_SRCCOLORKEY) flags |= 1; if (icon->flags & SDL_SRCALPHA) flags |= 2; if (flags) { - CreateMaskFromColorKeyOrAlpha (icon, mask, flags); + CreateMaskFromColorKeyOrAlpha(icon, mask, flags); } - _this->SetIcon (_this, icon, mask); - SDL_free (mask); + _this->SetIcon(_this, icon, mask); + SDL_free(mask); } else { - _this->SetIcon (_this, icon, mask); + _this->SetIcon(_this, icon, mask); } } } #endif SDL_bool -SDL_GetWindowWMInfo (SDL_WindowID windowID, SDL_SysWMinfo * info) +SDL_GetWindowWMInfo(SDL_WindowID windowID, SDL_SysWMinfo * info) { - SDL_Window *window = SDL_GetWindowFromID (windowID); + SDL_Window *window = SDL_GetWindowFromID(windowID); if (!window || !_this->GetWindowWMInfo) { return SDL_FALSE; } - return (_this->GetWindowWMInfo (_this, window, info)); + return (_this->GetWindowWMInfo(_this, window, info)); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_yuv.c --- a/src/video/SDL_yuv.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_yuv.c Mon May 29 04:04:35 2006 +0000 @@ -30,21 +30,21 @@ SDL_Overlay * -SDL_CreateYUVOverlay (int w, int h, Uint32 format, SDL_Surface * display) +SDL_CreateYUVOverlay(int w, int h, Uint32 format, SDL_Surface * display) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); SDL_Window *window; const char *yuv_hwaccel; SDL_Overlay *overlay; - window = SDL_GetWindowFromSurface (display); + window = SDL_GetWindowFromSurface(display); if (window && (window->flags & SDL_WINDOW_OPENGL)) { - SDL_SetError ("YUV overlays are not supported in OpenGL mode"); + SDL_SetError("YUV overlays are not supported in OpenGL mode"); return NULL; } /* Display directly on video surface, if possible */ - if (SDL_getenv ("SDL_VIDEO_YUV_DIRECT")) { + if (SDL_getenv("SDL_VIDEO_YUV_DIRECT")) { if (window && ((window->surface->format->BytesPerPixel == 2) || (window->surface->format->BytesPerPixel == 4))) { @@ -52,36 +52,36 @@ } } overlay = NULL; - yuv_hwaccel = SDL_getenv ("SDL_VIDEO_YUV_HWACCEL"); + yuv_hwaccel = SDL_getenv("SDL_VIDEO_YUV_HWACCEL"); if (((display->flags & SDL_SCREEN_SURFACE) && _this->CreateYUVOverlay) && - (!yuv_hwaccel || (SDL_atoi (yuv_hwaccel) > 0))) { - overlay = _this->CreateYUVOverlay (_this, w, h, format, display); + (!yuv_hwaccel || (SDL_atoi(yuv_hwaccel) > 0))) { + overlay = _this->CreateYUVOverlay(_this, w, h, format, display); } /* If hardware YUV overlay failed ... */ if (overlay == NULL) { - overlay = SDL_CreateYUV_SW (_this, w, h, format, display); + overlay = SDL_CreateYUV_SW(_this, w, h, format, display); } return overlay; } int -SDL_LockYUVOverlay (SDL_Overlay * overlay) +SDL_LockYUVOverlay(SDL_Overlay * overlay) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); - return overlay->hwfuncs->Lock (_this, overlay); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + return overlay->hwfuncs->Lock(_this, overlay); } void -SDL_UnlockYUVOverlay (SDL_Overlay * overlay) +SDL_UnlockYUVOverlay(SDL_Overlay * overlay) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); - overlay->hwfuncs->Unlock (_this, overlay); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + overlay->hwfuncs->Unlock(_this, overlay); } int -SDL_DisplayYUVOverlay (SDL_Overlay * overlay, SDL_Rect * dstrect) +SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); SDL_Rect src, dst; int srcx, srcy, srcw, srch; int dstx, dsty, dstw, dsth; @@ -129,18 +129,18 @@ dst.y = dsty; dst.w = dstw; dst.h = dsth; - return overlay->hwfuncs->Display (_this, overlay, &src, &dst); + return overlay->hwfuncs->Display(_this, overlay, &src, &dst); } void -SDL_FreeYUVOverlay (SDL_Overlay * overlay) +SDL_FreeYUVOverlay(SDL_Overlay * overlay) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); if (overlay) { if (overlay->hwfuncs) { - overlay->hwfuncs->FreeHW (_this, overlay); + overlay->hwfuncs->FreeHW(_this, overlay); } - SDL_free (overlay); + SDL_free(overlay); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_yuv_mmx.c --- a/src/video/SDL_yuv_mmx.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_yuv_mmx.c Mon May 29 04:04:35 2006 +0000 @@ -28,47 +28,47 @@ #define ASM_ARRAY(x) x[] __asm__("_" #x) __attribute__((used)) -static unsigned int ASM_ARRAY (MMX_0080w) = { +static unsigned int ASM_ARRAY(MMX_0080w) = { 0x00800080, 0x00800080}; -static unsigned int ASM_ARRAY (MMX_00FFw) = { +static unsigned int ASM_ARRAY(MMX_00FFw) = { 0x00ff00ff, 0x00ff00ff}; -static unsigned int ASM_ARRAY (MMX_FF00w) = { +static unsigned int ASM_ARRAY(MMX_FF00w) = { 0xff00ff00, 0xff00ff00}; -static unsigned short ASM_ARRAY (MMX_Ycoeff) = { +static unsigned short ASM_ARRAY(MMX_Ycoeff) = { 0x004a, 0x004a, 0x004a, 0x004a}; -static unsigned short ASM_ARRAY (MMX_UbluRGB) = { +static unsigned short ASM_ARRAY(MMX_UbluRGB) = { 0x0072, 0x0072, 0x0072, 0x0072}; -static unsigned short ASM_ARRAY (MMX_VredRGB) = { +static unsigned short ASM_ARRAY(MMX_VredRGB) = { 0x0059, 0x0059, 0x0059, 0x0059}; -static unsigned short ASM_ARRAY (MMX_UgrnRGB) = { +static unsigned short ASM_ARRAY(MMX_UgrnRGB) = { 0xffea, 0xffea, 0xffea, 0xffea}; -static unsigned short ASM_ARRAY (MMX_VgrnRGB) = { +static unsigned short ASM_ARRAY(MMX_VgrnRGB) = { 0xffd2, 0xffd2, 0xffd2, 0xffd2}; -static unsigned short ASM_ARRAY (MMX_Ublu5x5) = { +static unsigned short ASM_ARRAY(MMX_Ublu5x5) = { 0x0081, 0x0081, 0x0081, 0x0081}; -static unsigned short ASM_ARRAY (MMX_Vred5x5) = { +static unsigned short ASM_ARRAY(MMX_Vred5x5) = { 0x0066, 0x0066, 0x0066, 0x0066}; -static unsigned short ASM_ARRAY (MMX_Ugrn555) = { +static unsigned short ASM_ARRAY(MMX_Ugrn555) = { 0xffe7, 0xffe7, 0xffe7, 0xffe7}; -static unsigned short ASM_ARRAY (MMX_Vgrn555) = { +static unsigned short ASM_ARRAY(MMX_Vgrn555) = { 0xffcc, 0xffcc, 0xffcc, 0xffcc}; -static unsigned short ASM_ARRAY (MMX_Ugrn565) = { +static unsigned short ASM_ARRAY(MMX_Ugrn565) = { 0xffe8, 0xffe8, 0xffe8, 0xffe8}; -static unsigned short ASM_ARRAY (MMX_Vgrn565) = { +static unsigned short ASM_ARRAY(MMX_Vgrn565) = { 0xffcd, 0xffcd, 0xffcd, 0xffcd}; -static unsigned short ASM_ARRAY (MMX_red555) = { +static unsigned short ASM_ARRAY(MMX_red555) = { 0x7c00, 0x7c00, 0x7c00, 0x7c00}; -static unsigned short ASM_ARRAY (MMX_red565) = { +static unsigned short ASM_ARRAY(MMX_red565) = { 0xf800, 0xf800, 0xf800, 0xf800}; -static unsigned short ASM_ARRAY (MMX_grn555) = { +static unsigned short ASM_ARRAY(MMX_grn555) = { 0x03e0, 0x03e0, 0x03e0, 0x03e0}; -static unsigned short ASM_ARRAY (MMX_grn565) = { +static unsigned short ASM_ARRAY(MMX_grn565) = { 0x07e0, 0x07e0, 0x07e0, 0x07e0}; -static unsigned short ASM_ARRAY (MMX_blu5x5) = { +static unsigned short ASM_ARRAY(MMX_blu5x5) = { 0x001f, 0x001f, 0x001f, 0x001f}; /** @@ -101,10 +101,10 @@ */ void -ColorRGBDitherYV12MMX1X (int *colortab, Uint32 * rgb_2_pix, - unsigned char *lum, unsigned char *cr, - unsigned char *cb, unsigned char *out, - int rows, int cols, int mod) +ColorRGBDitherYV12MMX1X(int *colortab, Uint32 * rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod) { Uint32 *row1; Uint32 *row2; @@ -115,128 +115,128 @@ row2 = (Uint32 *) out + cols + mod; // start of second row mod = (mod + cols + mod) * 4; // increment for row1 in byte - __asm__ __volatile__ ( + __asm__ __volatile__( /* We don't really care about PIC - the code should be rewritten to use relative addressing for the static tables, so right now we take the COW hit on the pages this code resides. Big deal. This spill is just to reduce register pressure in the PIC case. */ - "pushl %%ebx\n" - "movl %0, %%ebx\n" ".align 8\n" "1:\n" - // create Cr (result in mm1) - "movd (%%ebx), %%mm1\n" // 0 0 0 0 v3 v2 v1 v0 - "pxor %%mm7,%%mm7\n" // 00 00 00 00 00 00 00 00 - "movd (%2), %%mm2\n" // 0 0 0 0 l3 l2 l1 l0 - "punpcklbw %%mm7,%%mm1\n" // 0 v3 0 v2 00 v1 00 v0 - "punpckldq %%mm1,%%mm1\n" // 00 v1 00 v0 00 v1 00 v0 - "psubw _MMX_0080w,%%mm1\n" // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 - // create Cr_g (result in mm0) - "movq %%mm1,%%mm0\n" // r1 r1 r0 r0 r1 r1 r0 r0 - "pmullw _MMX_VgrnRGB,%%mm0\n" // red*-46dec=0.7136*64 - "pmullw _MMX_VredRGB,%%mm1\n" // red*89dec=1.4013*64 - "psraw $6, %%mm0\n" // red=red/64 - "psraw $6, %%mm1\n" // red=red/64 - // create L1 L2 (result in mm2,mm4) - // L2=lum+cols - "movq (%2,%4),%%mm3\n" // 0 0 0 0 L3 L2 L1 L0 - "punpckldq %%mm3,%%mm2\n" // L3 L2 L1 L0 l3 l2 l1 l0 - "movq %%mm2,%%mm4\n" // L3 L2 L1 L0 l3 l2 l1 l0 - "pand _MMX_FF00w,%%mm2\n" // L3 0 L1 0 l3 0 l1 0 - "pand _MMX_00FFw,%%mm4\n" // 0 L2 0 L0 0 l2 0 l0 - "psrlw $8,%%mm2\n" // 0 L3 0 L1 0 l3 0 l1 - // create R (result in mm6) - "movq %%mm2,%%mm5\n" // 0 L3 0 L1 0 l3 0 l1 - "movq %%mm4,%%mm6\n" // 0 L2 0 L0 0 l2 0 l0 - "paddsw %%mm1, %%mm5\n" // lum1+red:x R3 x R1 x r3 x r1 - "paddsw %%mm1, %%mm6\n" // lum1+red:x R2 x R0 x r2 x r0 - "packuswb %%mm5,%%mm5\n" // R3 R1 r3 r1 R3 R1 r3 r1 - "packuswb %%mm6,%%mm6\n" // R2 R0 r2 r0 R2 R0 r2 r0 - "pxor %%mm7,%%mm7\n" // 00 00 00 00 00 00 00 00 - "punpcklbw %%mm5,%%mm6\n" // R3 R2 R1 R0 r3 r2 r1 r0 - // create Cb (result in mm1) - "movd (%1), %%mm1\n" // 0 0 0 0 u3 u2 u1 u0 - "punpcklbw %%mm7,%%mm1\n" // 0 u3 0 u2 00 u1 00 u0 - "punpckldq %%mm1,%%mm1\n" // 00 u1 00 u0 00 u1 00 u0 - "psubw _MMX_0080w,%%mm1\n" // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 - // create Cb_g (result in mm5) - "movq %%mm1,%%mm5\n" // u1 u1 u0 u0 u1 u1 u0 u0 - "pmullw _MMX_UgrnRGB,%%mm5\n" // blue*-109dec=1.7129*64 - "pmullw _MMX_UbluRGB,%%mm1\n" // blue*114dec=1.78125*64 - "psraw $6, %%mm5\n" // blue=red/64 - "psraw $6, %%mm1\n" // blue=blue/64 - // create G (result in mm7) - "movq %%mm2,%%mm3\n" // 0 L3 0 L1 0 l3 0 l1 - "movq %%mm4,%%mm7\n" // 0 L2 0 L0 0 l2 0 l1 - "paddsw %%mm5, %%mm3\n" // lum1+Cb_g:x G3t x G1t x g3t x g1t - "paddsw %%mm5, %%mm7\n" // lum1+Cb_g:x G2t x G0t x g2t x g0t - "paddsw %%mm0, %%mm3\n" // lum1+Cr_g:x G3 x G1 x g3 x g1 - "paddsw %%mm0, %%mm7\n" // lum1+blue:x G2 x G0 x g2 x g0 - "packuswb %%mm3,%%mm3\n" // G3 G1 g3 g1 G3 G1 g3 g1 - "packuswb %%mm7,%%mm7\n" // G2 G0 g2 g0 G2 G0 g2 g0 - "punpcklbw %%mm3,%%mm7\n" // G3 G2 G1 G0 g3 g2 g1 g0 - // create B (result in mm5) - "movq %%mm2,%%mm3\n" // 0 L3 0 L1 0 l3 0 l1 - "movq %%mm4,%%mm5\n" // 0 L2 0 L0 0 l2 0 l1 - "paddsw %%mm1, %%mm3\n" // lum1+blue:x B3 x B1 x b3 x b1 - "paddsw %%mm1, %%mm5\n" // lum1+blue:x B2 x B0 x b2 x b0 - "packuswb %%mm3,%%mm3\n" // B3 B1 b3 b1 B3 B1 b3 b1 - "packuswb %%mm5,%%mm5\n" // B2 B0 b2 b0 B2 B0 b2 b0 - "punpcklbw %%mm3,%%mm5\n" // B3 B2 B1 B0 b3 b2 b1 b0 - // fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb) - "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 - "pxor %%mm4,%%mm4\n" // 0 0 0 0 0 0 0 0 - "movq %%mm6,%%mm1\n" // R3 R2 R1 R0 r3 r2 r1 r0 - "movq %%mm5,%%mm3\n" // B3 B2 B1 B0 b3 b2 b1 b0 - // process lower lum - "punpcklbw %%mm4,%%mm1\n" // 0 r3 0 r2 0 r1 0 r0 - "punpcklbw %%mm4,%%mm3\n" // 0 b3 0 b2 0 b1 0 b0 - "movq %%mm1,%%mm2\n" // 0 r3 0 r2 0 r1 0 r0 - "movq %%mm3,%%mm0\n" // 0 b3 0 b2 0 b1 0 b0 - "punpcklwd %%mm1,%%mm3\n" // 0 r1 0 b1 0 r0 0 b0 - "punpckhwd %%mm2,%%mm0\n" // 0 r3 0 b3 0 r2 0 b2 - "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 - "movq %%mm7,%%mm1\n" // G3 G2 G1 G0 g3 g2 g1 g0 - "punpcklbw %%mm1,%%mm2\n" // g3 0 g2 0 g1 0 g0 0 - "punpcklwd %%mm4,%%mm2\n" // 0 0 g1 0 0 0 g0 0 - "por %%mm3, %%mm2\n" // 0 r1 g1 b1 0 r0 g0 b0 - "movq %%mm2,(%3)\n" // wrote out ! row1 - "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 - "punpcklbw %%mm1,%%mm4\n" // g3 0 g2 0 g1 0 g0 0 - "punpckhwd %%mm2,%%mm4\n" // 0 0 g3 0 0 0 g2 0 - "por %%mm0, %%mm4\n" // 0 r3 g3 b3 0 r2 g2 b2 - "movq %%mm4,8(%3)\n" // wrote out ! row1 - // fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb) - // this can be done "destructive" - "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 - "punpckhbw %%mm2,%%mm6\n" // 0 R3 0 R2 0 R1 0 R0 - "punpckhbw %%mm1,%%mm5\n" // G3 B3 G2 B2 G1 B1 G0 B0 - "movq %%mm5,%%mm1\n" // G3 B3 G2 B2 G1 B1 G0 B0 - "punpcklwd %%mm6,%%mm1\n" // 0 R1 G1 B1 0 R0 G0 B0 - "movq %%mm1,(%5)\n" // wrote out ! row2 - "punpckhwd %%mm6,%%mm5\n" // 0 R3 G3 B3 0 R2 G2 B2 - "movq %%mm5,8(%5)\n" // wrote out ! row2 - "addl $4,%2\n" // lum+4 - "leal 16(%3),%3\n" // row1+16 - "leal 16(%5),%5\n" // row2+16 - "addl $2, %%ebx\n" // cr+2 - "addl $2, %1\n" // cb+2 - "addl $4,%6\n" // x+4 - "cmpl %4,%6\n" "jl 1b\n" "addl %4, %2\n" // lum += cols - "addl %8, %3\n" // row1+= mod - "addl %8, %5\n" // row2+= mod - "movl $0, %6\n" // x=0 - "cmpl %7, %2\n" - "jl 1b\n" - "emms\n" - "popl %%ebx\n"::"m" (cr), "r" (cb), "r" (lum), - "r" (row1), "r" (cols), "r" (row2), "m" (x), - "m" (y), "m" (mod)); + "pushl %%ebx\n" + "movl %0, %%ebx\n" ".align 8\n" "1:\n" + // create Cr (result in mm1) + "movd (%%ebx), %%mm1\n" // 0 0 0 0 v3 v2 v1 v0 + "pxor %%mm7,%%mm7\n" // 00 00 00 00 00 00 00 00 + "movd (%2), %%mm2\n" // 0 0 0 0 l3 l2 l1 l0 + "punpcklbw %%mm7,%%mm1\n" // 0 v3 0 v2 00 v1 00 v0 + "punpckldq %%mm1,%%mm1\n" // 00 v1 00 v0 00 v1 00 v0 + "psubw _MMX_0080w,%%mm1\n" // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 + // create Cr_g (result in mm0) + "movq %%mm1,%%mm0\n" // r1 r1 r0 r0 r1 r1 r0 r0 + "pmullw _MMX_VgrnRGB,%%mm0\n" // red*-46dec=0.7136*64 + "pmullw _MMX_VredRGB,%%mm1\n" // red*89dec=1.4013*64 + "psraw $6, %%mm0\n" // red=red/64 + "psraw $6, %%mm1\n" // red=red/64 + // create L1 L2 (result in mm2,mm4) + // L2=lum+cols + "movq (%2,%4),%%mm3\n" // 0 0 0 0 L3 L2 L1 L0 + "punpckldq %%mm3,%%mm2\n" // L3 L2 L1 L0 l3 l2 l1 l0 + "movq %%mm2,%%mm4\n" // L3 L2 L1 L0 l3 l2 l1 l0 + "pand _MMX_FF00w,%%mm2\n" // L3 0 L1 0 l3 0 l1 0 + "pand _MMX_00FFw,%%mm4\n" // 0 L2 0 L0 0 l2 0 l0 + "psrlw $8,%%mm2\n" // 0 L3 0 L1 0 l3 0 l1 + // create R (result in mm6) + "movq %%mm2,%%mm5\n" // 0 L3 0 L1 0 l3 0 l1 + "movq %%mm4,%%mm6\n" // 0 L2 0 L0 0 l2 0 l0 + "paddsw %%mm1, %%mm5\n" // lum1+red:x R3 x R1 x r3 x r1 + "paddsw %%mm1, %%mm6\n" // lum1+red:x R2 x R0 x r2 x r0 + "packuswb %%mm5,%%mm5\n" // R3 R1 r3 r1 R3 R1 r3 r1 + "packuswb %%mm6,%%mm6\n" // R2 R0 r2 r0 R2 R0 r2 r0 + "pxor %%mm7,%%mm7\n" // 00 00 00 00 00 00 00 00 + "punpcklbw %%mm5,%%mm6\n" // R3 R2 R1 R0 r3 r2 r1 r0 + // create Cb (result in mm1) + "movd (%1), %%mm1\n" // 0 0 0 0 u3 u2 u1 u0 + "punpcklbw %%mm7,%%mm1\n" // 0 u3 0 u2 00 u1 00 u0 + "punpckldq %%mm1,%%mm1\n" // 00 u1 00 u0 00 u1 00 u0 + "psubw _MMX_0080w,%%mm1\n" // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 + // create Cb_g (result in mm5) + "movq %%mm1,%%mm5\n" // u1 u1 u0 u0 u1 u1 u0 u0 + "pmullw _MMX_UgrnRGB,%%mm5\n" // blue*-109dec=1.7129*64 + "pmullw _MMX_UbluRGB,%%mm1\n" // blue*114dec=1.78125*64 + "psraw $6, %%mm5\n" // blue=red/64 + "psraw $6, %%mm1\n" // blue=blue/64 + // create G (result in mm7) + "movq %%mm2,%%mm3\n" // 0 L3 0 L1 0 l3 0 l1 + "movq %%mm4,%%mm7\n" // 0 L2 0 L0 0 l2 0 l1 + "paddsw %%mm5, %%mm3\n" // lum1+Cb_g:x G3t x G1t x g3t x g1t + "paddsw %%mm5, %%mm7\n" // lum1+Cb_g:x G2t x G0t x g2t x g0t + "paddsw %%mm0, %%mm3\n" // lum1+Cr_g:x G3 x G1 x g3 x g1 + "paddsw %%mm0, %%mm7\n" // lum1+blue:x G2 x G0 x g2 x g0 + "packuswb %%mm3,%%mm3\n" // G3 G1 g3 g1 G3 G1 g3 g1 + "packuswb %%mm7,%%mm7\n" // G2 G0 g2 g0 G2 G0 g2 g0 + "punpcklbw %%mm3,%%mm7\n" // G3 G2 G1 G0 g3 g2 g1 g0 + // create B (result in mm5) + "movq %%mm2,%%mm3\n" // 0 L3 0 L1 0 l3 0 l1 + "movq %%mm4,%%mm5\n" // 0 L2 0 L0 0 l2 0 l1 + "paddsw %%mm1, %%mm3\n" // lum1+blue:x B3 x B1 x b3 x b1 + "paddsw %%mm1, %%mm5\n" // lum1+blue:x B2 x B0 x b2 x b0 + "packuswb %%mm3,%%mm3\n" // B3 B1 b3 b1 B3 B1 b3 b1 + "packuswb %%mm5,%%mm5\n" // B2 B0 b2 b0 B2 B0 b2 b0 + "punpcklbw %%mm3,%%mm5\n" // B3 B2 B1 B0 b3 b2 b1 b0 + // fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb) + "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 + "pxor %%mm4,%%mm4\n" // 0 0 0 0 0 0 0 0 + "movq %%mm6,%%mm1\n" // R3 R2 R1 R0 r3 r2 r1 r0 + "movq %%mm5,%%mm3\n" // B3 B2 B1 B0 b3 b2 b1 b0 + // process lower lum + "punpcklbw %%mm4,%%mm1\n" // 0 r3 0 r2 0 r1 0 r0 + "punpcklbw %%mm4,%%mm3\n" // 0 b3 0 b2 0 b1 0 b0 + "movq %%mm1,%%mm2\n" // 0 r3 0 r2 0 r1 0 r0 + "movq %%mm3,%%mm0\n" // 0 b3 0 b2 0 b1 0 b0 + "punpcklwd %%mm1,%%mm3\n" // 0 r1 0 b1 0 r0 0 b0 + "punpckhwd %%mm2,%%mm0\n" // 0 r3 0 b3 0 r2 0 b2 + "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 + "movq %%mm7,%%mm1\n" // G3 G2 G1 G0 g3 g2 g1 g0 + "punpcklbw %%mm1,%%mm2\n" // g3 0 g2 0 g1 0 g0 0 + "punpcklwd %%mm4,%%mm2\n" // 0 0 g1 0 0 0 g0 0 + "por %%mm3, %%mm2\n" // 0 r1 g1 b1 0 r0 g0 b0 + "movq %%mm2,(%3)\n" // wrote out ! row1 + "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 + "punpcklbw %%mm1,%%mm4\n" // g3 0 g2 0 g1 0 g0 0 + "punpckhwd %%mm2,%%mm4\n" // 0 0 g3 0 0 0 g2 0 + "por %%mm0, %%mm4\n" // 0 r3 g3 b3 0 r2 g2 b2 + "movq %%mm4,8(%3)\n" // wrote out ! row1 + // fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb) + // this can be done "destructive" + "pxor %%mm2,%%mm2\n" // 0 0 0 0 0 0 0 0 + "punpckhbw %%mm2,%%mm6\n" // 0 R3 0 R2 0 R1 0 R0 + "punpckhbw %%mm1,%%mm5\n" // G3 B3 G2 B2 G1 B1 G0 B0 + "movq %%mm5,%%mm1\n" // G3 B3 G2 B2 G1 B1 G0 B0 + "punpcklwd %%mm6,%%mm1\n" // 0 R1 G1 B1 0 R0 G0 B0 + "movq %%mm1,(%5)\n" // wrote out ! row2 + "punpckhwd %%mm6,%%mm5\n" // 0 R3 G3 B3 0 R2 G2 B2 + "movq %%mm5,8(%5)\n" // wrote out ! row2 + "addl $4,%2\n" // lum+4 + "leal 16(%3),%3\n" // row1+16 + "leal 16(%5),%5\n" // row2+16 + "addl $2, %%ebx\n" // cr+2 + "addl $2, %1\n" // cb+2 + "addl $4,%6\n" // x+4 + "cmpl %4,%6\n" "jl 1b\n" "addl %4, %2\n" // lum += cols + "addl %8, %3\n" // row1+= mod + "addl %8, %5\n" // row2+= mod + "movl $0, %6\n" // x=0 + "cmpl %7, %2\n" + "jl 1b\n" + "emms\n" + "popl %%ebx\n"::"m"(cr), "r"(cb), "r"(lum), + "r"(row1), "r"(cols), "r"(row2), "m"(x), + "m"(y), "m"(mod)); } void -Color565DitherYV12MMX1X (int *colortab, Uint32 * rgb_2_pix, - unsigned char *lum, unsigned char *cr, - unsigned char *cb, unsigned char *out, - int rows, int cols, int mod) +Color565DitherYV12MMX1X(int *colortab, Uint32 * rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod) { Uint16 *row1; Uint16 *row2; @@ -248,84 +248,84 @@ mod = (mod + cols + mod) * 2; /* increment for row1 in byte */ - __asm__ __volatile__ ("pushl %%ebx\n" "movl %0, %%ebx\n" ".align 8\n" "1:\n" "movd (%1), %%mm0\n" // 4 Cb 0 0 0 0 u3 u2 u1 u0 - "pxor %%mm7, %%mm7\n" "movd (%%ebx), %%mm1\n" // 4 Cr 0 0 0 0 v3 v2 v1 v0 - "punpcklbw %%mm7, %%mm0\n" // 4 W cb 0 u3 0 u2 0 u1 0 u0 - "punpcklbw %%mm7, %%mm1\n" // 4 W cr 0 v3 0 v2 0 v1 0 v0 - "psubw _MMX_0080w, %%mm0\n" "psubw _MMX_0080w, %%mm1\n" "movq %%mm0, %%mm2\n" // Cb 0 u3 0 u2 0 u1 0 u0 - "movq %%mm1, %%mm3\n" // Cr - "pmullw _MMX_Ugrn565, %%mm2\n" // Cb2green 0 R3 0 R2 0 R1 0 R0 - "movq (%2), %%mm6\n" // L1 l7 L6 L5 L4 L3 L2 L1 L0 - "pmullw _MMX_Ublu5x5, %%mm0\n" // Cb2blue - "pand _MMX_00FFw, %%mm6\n" // L1 00 L6 00 L4 00 L2 00 L0 - "pmullw _MMX_Vgrn565, %%mm3\n" // Cr2green - "movq (%2), %%mm7\n" // L2 - "pmullw _MMX_Vred5x5, %%mm1\n" // Cr2red - "psrlw $8, %%mm7\n" // L2 00 L7 00 L5 00 L3 00 L1 - "pmullw _MMX_Ycoeff, %%mm6\n" // lum1 - "paddw %%mm3, %%mm2\n" // Cb2green + Cr2green == green - "pmullw _MMX_Ycoeff, %%mm7\n" // lum2 - "movq %%mm6, %%mm4\n" // lum1 - "paddw %%mm0, %%mm6\n" // lum1 +blue 00 B6 00 B4 00 B2 00 B0 - "movq %%mm4, %%mm5\n" // lum1 - "paddw %%mm1, %%mm4\n" // lum1 +red 00 R6 00 R4 00 R2 00 R0 - "paddw %%mm2, %%mm5\n" // lum1 +green 00 G6 00 G4 00 G2 00 G0 - "psraw $6, %%mm4\n" // R1 0 .. 64 - "movq %%mm7, %%mm3\n" // lum2 00 L7 00 L5 00 L3 00 L1 - "psraw $6, %%mm5\n" // G1 - .. + - "paddw %%mm0, %%mm7\n" // Lum2 +blue 00 B7 00 B5 00 B3 00 B1 - "psraw $6, %%mm6\n" // B1 0 .. 64 - "packuswb %%mm4, %%mm4\n" // R1 R1 - "packuswb %%mm5, %%mm5\n" // G1 G1 - "packuswb %%mm6, %%mm6\n" // B1 B1 - "punpcklbw %%mm4, %%mm4\n" "punpcklbw %%mm5, %%mm5\n" "pand _MMX_red565, %%mm4\n" "psllw $3, %%mm5\n" // GREEN 1 - "punpcklbw %%mm6, %%mm6\n" "pand _MMX_grn565, %%mm5\n" "pand _MMX_red565, %%mm6\n" "por %%mm5, %%mm4\n" // - "psrlw $11, %%mm6\n" // BLUE 1 - "movq %%mm3, %%mm5\n" // lum2 - "paddw %%mm1, %%mm3\n" // lum2 +red 00 R7 00 R5 00 R3 00 R1 - "paddw %%mm2, %%mm5\n" // lum2 +green 00 G7 00 G5 00 G3 00 G1 - "psraw $6, %%mm3\n" // R2 - "por %%mm6, %%mm4\n" // MM4 - "psraw $6, %%mm5\n" // G2 - "movq (%2, %4), %%mm6\n" // L3 load lum2 - "psraw $6, %%mm7\n" "packuswb %%mm3, %%mm3\n" "packuswb %%mm5, %%mm5\n" "packuswb %%mm7, %%mm7\n" "pand _MMX_00FFw, %%mm6\n" // L3 - "punpcklbw %%mm3, %%mm3\n" "punpcklbw %%mm5, %%mm5\n" "pmullw _MMX_Ycoeff, %%mm6\n" // lum3 - "punpcklbw %%mm7, %%mm7\n" "psllw $3, %%mm5\n" // GREEN 2 - "pand _MMX_red565, %%mm7\n" "pand _MMX_red565, %%mm3\n" "psrlw $11, %%mm7\n" // BLUE 2 - "pand _MMX_grn565, %%mm5\n" "por %%mm7, %%mm3\n" "movq (%2,%4), %%mm7\n" // L4 load lum2 - "por %%mm5, %%mm3\n" // - "psrlw $8, %%mm7\n" // L4 - "movq %%mm4, %%mm5\n" "punpcklwd %%mm3, %%mm4\n" "pmullw _MMX_Ycoeff, %%mm7\n" // lum4 - "punpckhwd %%mm3, %%mm5\n" "movq %%mm4, (%3)\n" // write row1 - "movq %%mm5, 8(%3)\n" // write row1 - "movq %%mm6, %%mm4\n" // Lum3 - "paddw %%mm0, %%mm6\n" // Lum3 +blue - "movq %%mm4, %%mm5\n" // Lum3 - "paddw %%mm1, %%mm4\n" // Lum3 +red - "paddw %%mm2, %%mm5\n" // Lum3 +green - "psraw $6, %%mm4\n" "movq %%mm7, %%mm3\n" // Lum4 - "psraw $6, %%mm5\n" "paddw %%mm0, %%mm7\n" // Lum4 +blue - "psraw $6, %%mm6\n" // Lum3 +blue - "movq %%mm3, %%mm0\n" // Lum4 - "packuswb %%mm4, %%mm4\n" "paddw %%mm1, %%mm3\n" // Lum4 +red - "packuswb %%mm5, %%mm5\n" "paddw %%mm2, %%mm0\n" // Lum4 +green - "packuswb %%mm6, %%mm6\n" "punpcklbw %%mm4, %%mm4\n" "punpcklbw %%mm5, %%mm5\n" "punpcklbw %%mm6, %%mm6\n" "psllw $3, %%mm5\n" // GREEN 3 - "pand _MMX_red565, %%mm4\n" "psraw $6, %%mm3\n" // psr 6 - "psraw $6, %%mm0\n" "pand _MMX_red565, %%mm6\n" // BLUE - "pand _MMX_grn565, %%mm5\n" "psrlw $11, %%mm6\n" // BLUE 3 - "por %%mm5, %%mm4\n" "psraw $6, %%mm7\n" "por %%mm6, %%mm4\n" "packuswb %%mm3, %%mm3\n" "packuswb %%mm0, %%mm0\n" "packuswb %%mm7, %%mm7\n" "punpcklbw %%mm3, %%mm3\n" "punpcklbw %%mm0, %%mm0\n" "punpcklbw %%mm7, %%mm7\n" "pand _MMX_red565, %%mm3\n" "pand _MMX_red565, %%mm7\n" // BLUE - "psllw $3, %%mm0\n" // GREEN 4 - "psrlw $11, %%mm7\n" "pand _MMX_grn565, %%mm0\n" "por %%mm7, %%mm3\n" "por %%mm0, %%mm3\n" "movq %%mm4, %%mm5\n" "punpcklwd %%mm3, %%mm4\n" "punpckhwd %%mm3, %%mm5\n" "movq %%mm4, (%5)\n" "movq %%mm5, 8(%5)\n" "addl $8, %6\n" "addl $8, %2\n" "addl $4, %%ebx\n" "addl $4, %1\n" "cmpl %4, %6\n" "leal 16(%3), %3\n" "leal 16(%5),%5\n" // row2+16 - "jl 1b\n" "addl %4, %2\n" // lum += cols - "addl %8, %3\n" // row1+= mod - "addl %8, %5\n" // row2+= mod - "movl $0, %6\n" // x=0 - "cmpl %7, %2\n" - "jl 1b\n" - "emms\n" - "popl %%ebx\n"::"m" (cr), "r" (cb), "r" (lum), - "r" (row1), "r" (cols), "r" (row2), "m" (x), - "m" (y), "m" (mod)); + __asm__ __volatile__("pushl %%ebx\n" "movl %0, %%ebx\n" ".align 8\n" "1:\n" "movd (%1), %%mm0\n" // 4 Cb 0 0 0 0 u3 u2 u1 u0 + "pxor %%mm7, %%mm7\n" "movd (%%ebx), %%mm1\n" // 4 Cr 0 0 0 0 v3 v2 v1 v0 + "punpcklbw %%mm7, %%mm0\n" // 4 W cb 0 u3 0 u2 0 u1 0 u0 + "punpcklbw %%mm7, %%mm1\n" // 4 W cr 0 v3 0 v2 0 v1 0 v0 + "psubw _MMX_0080w, %%mm0\n" "psubw _MMX_0080w, %%mm1\n" "movq %%mm0, %%mm2\n" // Cb 0 u3 0 u2 0 u1 0 u0 + "movq %%mm1, %%mm3\n" // Cr + "pmullw _MMX_Ugrn565, %%mm2\n" // Cb2green 0 R3 0 R2 0 R1 0 R0 + "movq (%2), %%mm6\n" // L1 l7 L6 L5 L4 L3 L2 L1 L0 + "pmullw _MMX_Ublu5x5, %%mm0\n" // Cb2blue + "pand _MMX_00FFw, %%mm6\n" // L1 00 L6 00 L4 00 L2 00 L0 + "pmullw _MMX_Vgrn565, %%mm3\n" // Cr2green + "movq (%2), %%mm7\n" // L2 + "pmullw _MMX_Vred5x5, %%mm1\n" // Cr2red + "psrlw $8, %%mm7\n" // L2 00 L7 00 L5 00 L3 00 L1 + "pmullw _MMX_Ycoeff, %%mm6\n" // lum1 + "paddw %%mm3, %%mm2\n" // Cb2green + Cr2green == green + "pmullw _MMX_Ycoeff, %%mm7\n" // lum2 + "movq %%mm6, %%mm4\n" // lum1 + "paddw %%mm0, %%mm6\n" // lum1 +blue 00 B6 00 B4 00 B2 00 B0 + "movq %%mm4, %%mm5\n" // lum1 + "paddw %%mm1, %%mm4\n" // lum1 +red 00 R6 00 R4 00 R2 00 R0 + "paddw %%mm2, %%mm5\n" // lum1 +green 00 G6 00 G4 00 G2 00 G0 + "psraw $6, %%mm4\n" // R1 0 .. 64 + "movq %%mm7, %%mm3\n" // lum2 00 L7 00 L5 00 L3 00 L1 + "psraw $6, %%mm5\n" // G1 - .. + + "paddw %%mm0, %%mm7\n" // Lum2 +blue 00 B7 00 B5 00 B3 00 B1 + "psraw $6, %%mm6\n" // B1 0 .. 64 + "packuswb %%mm4, %%mm4\n" // R1 R1 + "packuswb %%mm5, %%mm5\n" // G1 G1 + "packuswb %%mm6, %%mm6\n" // B1 B1 + "punpcklbw %%mm4, %%mm4\n" "punpcklbw %%mm5, %%mm5\n" "pand _MMX_red565, %%mm4\n" "psllw $3, %%mm5\n" // GREEN 1 + "punpcklbw %%mm6, %%mm6\n" "pand _MMX_grn565, %%mm5\n" "pand _MMX_red565, %%mm6\n" "por %%mm5, %%mm4\n" // + "psrlw $11, %%mm6\n" // BLUE 1 + "movq %%mm3, %%mm5\n" // lum2 + "paddw %%mm1, %%mm3\n" // lum2 +red 00 R7 00 R5 00 R3 00 R1 + "paddw %%mm2, %%mm5\n" // lum2 +green 00 G7 00 G5 00 G3 00 G1 + "psraw $6, %%mm3\n" // R2 + "por %%mm6, %%mm4\n" // MM4 + "psraw $6, %%mm5\n" // G2 + "movq (%2, %4), %%mm6\n" // L3 load lum2 + "psraw $6, %%mm7\n" "packuswb %%mm3, %%mm3\n" "packuswb %%mm5, %%mm5\n" "packuswb %%mm7, %%mm7\n" "pand _MMX_00FFw, %%mm6\n" // L3 + "punpcklbw %%mm3, %%mm3\n" "punpcklbw %%mm5, %%mm5\n" "pmullw _MMX_Ycoeff, %%mm6\n" // lum3 + "punpcklbw %%mm7, %%mm7\n" "psllw $3, %%mm5\n" // GREEN 2 + "pand _MMX_red565, %%mm7\n" "pand _MMX_red565, %%mm3\n" "psrlw $11, %%mm7\n" // BLUE 2 + "pand _MMX_grn565, %%mm5\n" "por %%mm7, %%mm3\n" "movq (%2,%4), %%mm7\n" // L4 load lum2 + "por %%mm5, %%mm3\n" // + "psrlw $8, %%mm7\n" // L4 + "movq %%mm4, %%mm5\n" "punpcklwd %%mm3, %%mm4\n" "pmullw _MMX_Ycoeff, %%mm7\n" // lum4 + "punpckhwd %%mm3, %%mm5\n" "movq %%mm4, (%3)\n" // write row1 + "movq %%mm5, 8(%3)\n" // write row1 + "movq %%mm6, %%mm4\n" // Lum3 + "paddw %%mm0, %%mm6\n" // Lum3 +blue + "movq %%mm4, %%mm5\n" // Lum3 + "paddw %%mm1, %%mm4\n" // Lum3 +red + "paddw %%mm2, %%mm5\n" // Lum3 +green + "psraw $6, %%mm4\n" "movq %%mm7, %%mm3\n" // Lum4 + "psraw $6, %%mm5\n" "paddw %%mm0, %%mm7\n" // Lum4 +blue + "psraw $6, %%mm6\n" // Lum3 +blue + "movq %%mm3, %%mm0\n" // Lum4 + "packuswb %%mm4, %%mm4\n" "paddw %%mm1, %%mm3\n" // Lum4 +red + "packuswb %%mm5, %%mm5\n" "paddw %%mm2, %%mm0\n" // Lum4 +green + "packuswb %%mm6, %%mm6\n" "punpcklbw %%mm4, %%mm4\n" "punpcklbw %%mm5, %%mm5\n" "punpcklbw %%mm6, %%mm6\n" "psllw $3, %%mm5\n" // GREEN 3 + "pand _MMX_red565, %%mm4\n" "psraw $6, %%mm3\n" // psr 6 + "psraw $6, %%mm0\n" "pand _MMX_red565, %%mm6\n" // BLUE + "pand _MMX_grn565, %%mm5\n" "psrlw $11, %%mm6\n" // BLUE 3 + "por %%mm5, %%mm4\n" "psraw $6, %%mm7\n" "por %%mm6, %%mm4\n" "packuswb %%mm3, %%mm3\n" "packuswb %%mm0, %%mm0\n" "packuswb %%mm7, %%mm7\n" "punpcklbw %%mm3, %%mm3\n" "punpcklbw %%mm0, %%mm0\n" "punpcklbw %%mm7, %%mm7\n" "pand _MMX_red565, %%mm3\n" "pand _MMX_red565, %%mm7\n" // BLUE + "psllw $3, %%mm0\n" // GREEN 4 + "psrlw $11, %%mm7\n" "pand _MMX_grn565, %%mm0\n" "por %%mm7, %%mm3\n" "por %%mm0, %%mm3\n" "movq %%mm4, %%mm5\n" "punpcklwd %%mm3, %%mm4\n" "punpckhwd %%mm3, %%mm5\n" "movq %%mm4, (%5)\n" "movq %%mm5, 8(%5)\n" "addl $8, %6\n" "addl $8, %2\n" "addl $4, %%ebx\n" "addl $4, %1\n" "cmpl %4, %6\n" "leal 16(%3), %3\n" "leal 16(%5),%5\n" // row2+16 + "jl 1b\n" "addl %4, %2\n" // lum += cols + "addl %8, %3\n" // row1+= mod + "addl %8, %5\n" // row2+= mod + "movl $0, %6\n" // x=0 + "cmpl %7, %2\n" + "jl 1b\n" + "emms\n" + "popl %%ebx\n"::"m"(cr), "r"(cb), "r"(lum), + "r"(row1), "r"(cols), "r"(row2), "m"(x), + "m"(y), "m"(mod)); } #endif /* GCC i386 inline assembly */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_yuv_sw.c --- a/src/video/SDL_yuv_sw.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_yuv_sw.c Mon May 29 04:04:35 2006 +0000 @@ -123,21 +123,21 @@ /* The colorspace conversion functions */ #if 0 /*defined(__GNUC__) && defined(__i386__) && SDL_ASSEMBLY_ROUTINES */ -extern void Color565DitherYV12MMX1X (int *colortab, Uint32 * rgb_2_pix, - unsigned char *lum, unsigned char *cr, - unsigned char *cb, unsigned char *out, - int rows, int cols, int mod); -extern void ColorRGBDitherYV12MMX1X (int *colortab, Uint32 * rgb_2_pix, - unsigned char *lum, unsigned char *cr, - unsigned char *cb, unsigned char *out, - int rows, int cols, int mod); +extern void Color565DitherYV12MMX1X(int *colortab, Uint32 * rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod); +extern void ColorRGBDitherYV12MMX1X(int *colortab, Uint32 * rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod); #endif static void -Color16DitherYV12Mod1X (int *colortab, Uint32 * rgb_2_pix, - unsigned char *lum, unsigned char *cr, - unsigned char *cb, unsigned char *out, - int rows, int cols, int mod) +Color16DitherYV12Mod1X(int *colortab, Uint32 * rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod) { unsigned short *row1; unsigned short *row2; @@ -204,10 +204,10 @@ } static void -Color24DitherYV12Mod1X (int *colortab, Uint32 * rgb_2_pix, - unsigned char *lum, unsigned char *cr, - unsigned char *cb, unsigned char *out, - int rows, int cols, int mod) +Color24DitherYV12Mod1X(int *colortab, Uint32 * rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod) { unsigned int value; unsigned char *row1; @@ -284,10 +284,10 @@ } static void -Color32DitherYV12Mod1X (int *colortab, Uint32 * rgb_2_pix, - unsigned char *lum, unsigned char *cr, - unsigned char *cb, unsigned char *out, - int rows, int cols, int mod) +Color32DitherYV12Mod1X(int *colortab, Uint32 * rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod) { unsigned int *row1; unsigned int *row2; @@ -355,10 +355,10 @@ * the horisontal doubling for free (almost). */ static void -Color16DitherYV12Mod2X (int *colortab, Uint32 * rgb_2_pix, - unsigned char *lum, unsigned char *cr, - unsigned char *cb, unsigned char *out, - int rows, int cols, int mod) +Color16DitherYV12Mod2X(int *colortab, Uint32 * rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod) { unsigned int *row1 = (unsigned int *) out; const int next_row = cols + (mod / 2); @@ -428,10 +428,10 @@ } static void -Color24DitherYV12Mod2X (int *colortab, Uint32 * rgb_2_pix, - unsigned char *lum, unsigned char *cr, - unsigned char *cb, unsigned char *out, - int rows, int cols, int mod) +Color24DitherYV12Mod2X(int *colortab, Uint32 * rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod) { unsigned int value; unsigned char *row1 = out; @@ -522,10 +522,10 @@ } static void -Color32DitherYV12Mod2X (int *colortab, Uint32 * rgb_2_pix, - unsigned char *lum, unsigned char *cr, - unsigned char *cb, unsigned char *out, - int rows, int cols, int mod) +Color32DitherYV12Mod2X(int *colortab, Uint32 * rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod) { unsigned int *row1 = (unsigned int *) out; const int next_row = cols * 2 + mod; @@ -595,10 +595,10 @@ } static void -Color16DitherYUY2Mod1X (int *colortab, Uint32 * rgb_2_pix, - unsigned char *lum, unsigned char *cr, - unsigned char *cb, unsigned char *out, - int rows, int cols, int mod) +Color16DitherYUY2Mod1X(int *colortab, Uint32 * rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod) { unsigned short *row; int x, y; @@ -641,10 +641,10 @@ } static void -Color24DitherYUY2Mod1X (int *colortab, Uint32 * rgb_2_pix, - unsigned char *lum, unsigned char *cr, - unsigned char *cb, unsigned char *out, - int rows, int cols, int mod) +Color24DitherYUY2Mod1X(int *colortab, Uint32 * rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod) { unsigned int value; unsigned char *row; @@ -691,10 +691,10 @@ } static void -Color32DitherYUY2Mod1X (int *colortab, Uint32 * rgb_2_pix, - unsigned char *lum, unsigned char *cr, - unsigned char *cb, unsigned char *out, - int rows, int cols, int mod) +Color32DitherYUY2Mod1X(int *colortab, Uint32 * rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod) { unsigned int *row; int x, y; @@ -739,10 +739,10 @@ * the horisontal doubling for free (almost). */ static void -Color16DitherYUY2Mod2X (int *colortab, Uint32 * rgb_2_pix, - unsigned char *lum, unsigned char *cr, - unsigned char *cb, unsigned char *out, - int rows, int cols, int mod) +Color16DitherYUY2Mod2X(int *colortab, Uint32 * rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod) { unsigned int *row = (unsigned int *) out; const int next_row = cols + (mod / 2); @@ -785,10 +785,10 @@ } static void -Color24DitherYUY2Mod2X (int *colortab, Uint32 * rgb_2_pix, - unsigned char *lum, unsigned char *cr, - unsigned char *cb, unsigned char *out, - int rows, int cols, int mod) +Color24DitherYUY2Mod2X(int *colortab, Uint32 * rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod) { unsigned int value; unsigned char *row = out; @@ -841,10 +841,10 @@ } static void -Color32DitherYUY2Mod2X (int *colortab, Uint32 * rgb_2_pix, - unsigned char *lum, unsigned char *cr, - unsigned char *cb, unsigned char *out, - int rows, int cols, int mod) +Color32DitherYUY2Mod2X(int *colortab, Uint32 * rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod) { unsigned int *row = (unsigned int *) out; const int next_row = cols * 2 + mod; @@ -893,13 +893,13 @@ * Low performance, do not call often. */ static int -number_of_bits_set (Uint32 a) +number_of_bits_set(Uint32 a) { if (!a) return 0; if (a & 1) - return 1 + number_of_bits_set (a >> 1); - return (number_of_bits_set (a >> 1)); + return 1 + number_of_bits_set(a >> 1); + return (number_of_bits_set(a >> 1)); } /* @@ -907,20 +907,20 @@ * Low performance, do not call often. */ static int -free_bits_at_bottom (Uint32 a) +free_bits_at_bottom(Uint32 a) { /* assume char is 8 bits */ if (!a) - return sizeof (Uint32) * 8; + return sizeof(Uint32) * 8; if (((Sint32) a) & 1l) return 0; - return 1 + free_bits_at_bottom (a >> 1); + return 1 + free_bits_at_bottom(a >> 1); } SDL_Overlay * -SDL_CreateYUV_SW (_THIS, int width, int height, Uint32 format, - SDL_Surface * display) +SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, + SDL_Surface * display) { SDL_Overlay *overlay; struct private_yuvhwdata *swdata; @@ -939,7 +939,7 @@ if ((display->format->BytesPerPixel != 2) && (display->format->BytesPerPixel != 3) && (display->format->BytesPerPixel != 4)) { - SDL_SetError ("Can't use YUV data on non 16/24/32 bit surfaces"); + SDL_SetError("Can't use YUV data on non 16/24/32 bit surfaces"); return (NULL); } @@ -952,17 +952,17 @@ case SDL_YVYU_OVERLAY: break; default: - SDL_SetError ("Unsupported YUV format"); + SDL_SetError("Unsupported YUV format"); return (NULL); } /* Create the overlay structure */ - overlay = (SDL_Overlay *) SDL_malloc (sizeof *overlay); + overlay = (SDL_Overlay *) SDL_malloc(sizeof *overlay); if (overlay == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } - SDL_memset (overlay, 0, (sizeof *overlay)); + SDL_memset(overlay, 0, (sizeof *overlay)); /* Fill in the basic members */ overlay->format = format; @@ -973,28 +973,28 @@ overlay->hwfuncs = &sw_yuvfuncs; /* Create the pixel data and lookup tables */ - swdata = (struct private_yuvhwdata *) SDL_malloc (sizeof *swdata); + swdata = (struct private_yuvhwdata *) SDL_malloc(sizeof *swdata); overlay->hwdata = swdata; if (swdata == NULL) { - SDL_OutOfMemory (); - SDL_FreeYUVOverlay (overlay); + SDL_OutOfMemory(); + SDL_FreeYUVOverlay(overlay); return (NULL); } swdata->stretch = NULL; swdata->display = display; - swdata->pixels = (Uint8 *) SDL_malloc (width * height * 2); - swdata->colortab = (int *) SDL_malloc (4 * 256 * sizeof (int)); + swdata->pixels = (Uint8 *) SDL_malloc(width * height * 2); + swdata->colortab = (int *) SDL_malloc(4 * 256 * sizeof(int)); Cr_r_tab = &swdata->colortab[0 * 256]; Cr_g_tab = &swdata->colortab[1 * 256]; Cb_g_tab = &swdata->colortab[2 * 256]; Cb_b_tab = &swdata->colortab[3 * 256]; - swdata->rgb_2_pix = (Uint32 *) SDL_malloc (3 * 768 * sizeof (Uint32)); + swdata->rgb_2_pix = (Uint32 *) SDL_malloc(3 * 768 * sizeof(Uint32)); r_2_pix_alloc = &swdata->rgb_2_pix[0 * 768]; g_2_pix_alloc = &swdata->rgb_2_pix[1 * 768]; b_2_pix_alloc = &swdata->rgb_2_pix[2 * 768]; if (!swdata->pixels || !swdata->colortab || !swdata->rgb_2_pix) { - SDL_OutOfMemory (); - SDL_FreeYUVOverlay (overlay); + SDL_OutOfMemory(); + SDL_FreeYUVOverlay(overlay); return (NULL); } @@ -1017,12 +1017,12 @@ Gmask = display->format->Gmask; Bmask = display->format->Bmask; for (i = 0; i < 256; ++i) { - r_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set (Rmask)); - r_2_pix_alloc[i + 256] <<= free_bits_at_bottom (Rmask); - g_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set (Gmask)); - g_2_pix_alloc[i + 256] <<= free_bits_at_bottom (Gmask); - b_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set (Bmask)); - b_2_pix_alloc[i + 256] <<= free_bits_at_bottom (Bmask); + r_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(Rmask)); + r_2_pix_alloc[i + 256] <<= free_bits_at_bottom(Rmask); + g_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(Gmask)); + g_2_pix_alloc[i + 256] <<= free_bits_at_bottom(Gmask); + b_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(Bmask)); + b_2_pix_alloc[i + 256] <<= free_bits_at_bottom(Bmask); } /* @@ -1060,7 +1060,7 @@ if (display->format->BytesPerPixel == 2) { #if 0 /*defined(__GNUC__) && defined(__i386__) && SDL_ASSEMBLY_ROUTINES */ /* inline assembly functions */ - if (SDL_HasMMX () && (Rmask == 0xF800) && + if (SDL_HasMMX() && (Rmask == 0xF800) && (Gmask == 0x07E0) && (Bmask == 0x001F) && (width & 15) == 0) { /*printf("Using MMX 16-bit 565 dither\n");*/ swdata->Display1X = Color565DitherYV12MMX1X; @@ -1080,7 +1080,7 @@ if (display->format->BytesPerPixel == 4) { #if 0 /*defined(__GNUC__) && defined(__i386__) && SDL_ASSEMBLY_ROUTINES */ /* inline assembly functions */ - if (SDL_HasMMX () && (Rmask == 0x00FF0000) && + if (SDL_HasMMX() && (Rmask == 0x00FF0000) && (Gmask == 0x0000FF00) && (Bmask == 0x000000FF) && (width & 15) == 0) { /*printf("Using MMX 32-bit dither\n");*/ @@ -1149,20 +1149,20 @@ } int -SDL_LockYUV_SW (_THIS, SDL_Overlay * overlay) +SDL_LockYUV_SW(_THIS, SDL_Overlay * overlay) { return (0); } void -SDL_UnlockYUV_SW (_THIS, SDL_Overlay * overlay) +SDL_UnlockYUV_SW(_THIS, SDL_Overlay * overlay) { return; } int -SDL_DisplayYUV_SW (_THIS, SDL_Overlay * overlay, SDL_Rect * src, - SDL_Rect * dst) +SDL_DisplayYUV_SW(_THIS, SDL_Overlay * overlay, SDL_Rect * src, + SDL_Rect * dst) { struct private_yuvhwdata *swdata; int stretch; @@ -1192,17 +1192,16 @@ if (stretch) { if (!swdata->stretch) { display = swdata->display; - swdata->stretch = SDL_CreateRGBSurface (SDL_SWSURFACE, - overlay->w, - overlay->h, - display->format-> - BitsPerPixel, - display->format-> - Rmask, - display->format-> - Gmask, - display->format-> - Bmask, 0); + swdata->stretch = SDL_CreateRGBSurface(SDL_SWSURFACE, + overlay->w, + overlay->h, + display->format-> + BitsPerPixel, + display->format-> + Rmask, + display->format-> + Gmask, + display->format->Bmask, 0); if (!swdata->stretch) { return (-1); } @@ -1238,11 +1237,11 @@ Cb = lum + 3; break; default: - SDL_SetError ("Unsupported YUV format in blit"); + SDL_SetError("Unsupported YUV format in blit"); return (-1); } - if (SDL_MUSTLOCK (display)) { - if (SDL_LockSurface (display) < 0) { + if (SDL_MUSTLOCK(display)) { + if (SDL_LockSurface(display) < 0) { return (-1); } } @@ -1257,45 +1256,45 @@ if (scale_2x) { mod -= (overlay->w * 2); - swdata->Display2X (swdata->colortab, swdata->rgb_2_pix, - lum, Cr, Cb, dstp, overlay->h, overlay->w, mod); + swdata->Display2X(swdata->colortab, swdata->rgb_2_pix, + lum, Cr, Cb, dstp, overlay->h, overlay->w, mod); } else { mod -= overlay->w; - swdata->Display1X (swdata->colortab, swdata->rgb_2_pix, - lum, Cr, Cb, dstp, overlay->h, overlay->w, mod); + swdata->Display1X(swdata->colortab, swdata->rgb_2_pix, + lum, Cr, Cb, dstp, overlay->h, overlay->w, mod); } - if (SDL_MUSTLOCK (display)) { - SDL_UnlockSurface (display); + if (SDL_MUSTLOCK(display)) { + SDL_UnlockSurface(display); } if (stretch) { display = swdata->display; - SDL_SoftStretch (swdata->stretch, src, display, dst); + SDL_SoftStretch(swdata->stretch, src, display, dst); } - SDL_UpdateRects (display, 1, dst); + SDL_UpdateRects(display, 1, dst); return (0); } void -SDL_FreeYUV_SW (_THIS, SDL_Overlay * overlay) +SDL_FreeYUV_SW(_THIS, SDL_Overlay * overlay) { struct private_yuvhwdata *swdata; swdata = overlay->hwdata; if (swdata) { if (swdata->stretch) { - SDL_FreeSurface (swdata->stretch); + SDL_FreeSurface(swdata->stretch); } if (swdata->pixels) { - SDL_free (swdata->pixels); + SDL_free(swdata->pixels); } if (swdata->colortab) { - SDL_free (swdata->colortab); + SDL_free(swdata->colortab); } if (swdata->rgb_2_pix) { - SDL_free (swdata->rgb_2_pix); + SDL_free(swdata->rgb_2_pix); } - SDL_free (swdata); + SDL_free(swdata); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/SDL_yuv_sw_c.h --- a/src/video/SDL_yuv_sw_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/SDL_yuv_sw_c.h Mon May 29 04:04:35 2006 +0000 @@ -26,15 +26,15 @@ /* This is the software implementation of the YUV video overlay support */ -extern SDL_Overlay *SDL_CreateYUV_SW (_THIS, int width, int height, - Uint32 format, SDL_Surface * display); +extern SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, + Uint32 format, SDL_Surface * display); -extern int SDL_LockYUV_SW (_THIS, SDL_Overlay * overlay); +extern int SDL_LockYUV_SW(_THIS, SDL_Overlay * overlay); -extern void SDL_UnlockYUV_SW (_THIS, SDL_Overlay * overlay); +extern void SDL_UnlockYUV_SW(_THIS, SDL_Overlay * overlay); -extern int SDL_DisplayYUV_SW (_THIS, SDL_Overlay * overlay, SDL_Rect * src, - SDL_Rect * dst); +extern int SDL_DisplayYUV_SW(_THIS, SDL_Overlay * overlay, SDL_Rect * src, + SDL_Rect * dst); -extern void SDL_FreeYUV_SW (_THIS, SDL_Overlay * overlay); +extern void SDL_FreeYUV_SW(_THIS, SDL_Overlay * overlay); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/Xext/XME/xme.c --- a/src/video/Xext/XME/xme.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/Xext/XME/xme.c Mon May 29 04:04:35 2006 +0000 @@ -212,7 +212,7 @@ /* * find_display - locate the display info block */ -static int XiGMiscCloseDisplay (); +static int XiGMiscCloseDisplay(); static XExtensionHooks xigmisc_extension_hooks = { NULL, /* create_gc */ @@ -230,181 +230,180 @@ static -XEXT_GENERATE_CLOSE_DISPLAY (XiGMiscCloseDisplay, xigmisc_info) - static XEXT_GENERATE_FIND_DISPLAY (XiGMiscFindDisplay, xigmisc_info, - xigmisc_extension_name, - &xigmisc_extension_hooks, - XiGMiscNumberEvents, NULL) +XEXT_GENERATE_CLOSE_DISPLAY(XiGMiscCloseDisplay, xigmisc_info) + static XEXT_GENERATE_FIND_DISPLAY(XiGMiscFindDisplay, xigmisc_info, + xigmisc_extension_name, + &xigmisc_extension_hooks, + XiGMiscNumberEvents, NULL) /*****************************************************************************/ - Bool XiGMiscQueryVersion (Display * dpy, int *major, int *minor) + Bool XiGMiscQueryVersion(Display * dpy, int *major, int *minor) { int opcode, event, error; xXiGMiscQueryVersionReq *req; xXiGMiscQueryVersionReply rep; - XExtDisplayInfo *info = XiGMiscFindDisplay (dpy); + XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); - if (!XQueryExtension - (dpy, XIGMISC_PROTOCOL_NAME, &opcode, &event, &error)) + if (!XQueryExtension(dpy, XIGMISC_PROTOCOL_NAME, &opcode, &event, &error)) return xFalse; - XiGMiscCheckExtension (dpy, info, xFalse); + XiGMiscCheckExtension(dpy, info, xFalse); - LockDisplay (dpy); - XiGMiscGetReq (XiGMiscQueryVersion, req, info); + LockDisplay(dpy); + XiGMiscGetReq(XiGMiscQueryVersion, req, info); req->major = XIGMISC_MAJOR_VERSION; req->minor = XIGMISC_MINOR_VERSION; - if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { + UnlockDisplay(dpy); + SyncHandle(); return xFalse; } *major = rep.major; *minor = rep.minor; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return xTrue; } int -XiGMiscQueryViews (Display * dpy, int screen, XiGMiscViewInfo ** pviews) +XiGMiscQueryViews(Display * dpy, int screen, XiGMiscViewInfo ** pviews) { int n, size; XiGMiscViewInfo *views; xXiGMiscQueryViewsReq *req; xXiGMiscQueryViewsReply rep; - XExtDisplayInfo *info = XiGMiscFindDisplay (dpy); - XiGMiscCheckExtension (dpy, info, 0); + XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); + XiGMiscCheckExtension(dpy, info, 0); - LockDisplay (dpy); - XiGMiscGetReq (XiGMiscQueryViews, req, info); + LockDisplay(dpy); + XiGMiscGetReq(XiGMiscQueryViews, req, info); req->screen = screen; - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return 0; } n = rep.nviews; if (n > 0) { - size = sizeof (XiGMiscViewInfo) * n; - views = (XiGMiscViewInfo *) Xmalloc (size); + size = sizeof(XiGMiscViewInfo) * n; + views = (XiGMiscViewInfo *) Xmalloc(size); if (!views) { - _XEatData (dpy, (unsigned long) size); - UnlockDisplay (dpy); - SyncHandle (); + _XEatData(dpy, (unsigned long) size); + UnlockDisplay(dpy); + SyncHandle(); return 0; } - _XReadPad (dpy, (void *) views, size); + _XReadPad(dpy, (void *) views, size); *pviews = views; } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return n; } int -XiGMiscQueryResolutions (Display * dpy, int screen, int view, int *pactive, - XiGMiscResolutionInfo ** presolutions) +XiGMiscQueryResolutions(Display * dpy, int screen, int view, int *pactive, + XiGMiscResolutionInfo ** presolutions) { int n, size; XiGMiscResolutionInfo *resolutions; xXiGMiscQueryResolutionsReq *req; xXiGMiscQueryResolutionsReply rep; - XExtDisplayInfo *info = XiGMiscFindDisplay (dpy); - XiGMiscCheckExtension (dpy, info, 0); + XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); + XiGMiscCheckExtension(dpy, info, 0); - LockDisplay (dpy); - XiGMiscGetReq (XiGMiscQueryResolutions, req, info); + LockDisplay(dpy); + XiGMiscGetReq(XiGMiscQueryResolutions, req, info); req->screen = screen; req->view = view; - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return 0; } n = rep.nresolutions; if (n > 0) { - size = sizeof (XiGMiscResolutionInfo) * n; - resolutions = (XiGMiscResolutionInfo *) Xmalloc (size); + size = sizeof(XiGMiscResolutionInfo) * n; + resolutions = (XiGMiscResolutionInfo *) Xmalloc(size); if (!resolutions) { - _XEatData (dpy, (unsigned long) size); - UnlockDisplay (dpy); - SyncHandle (); + _XEatData(dpy, (unsigned long) size); + UnlockDisplay(dpy); + SyncHandle(); return 0; } - _XReadPad (dpy, (void *) resolutions, size); + _XReadPad(dpy, (void *) resolutions, size); *presolutions = resolutions; *pactive = rep.active; } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return n; } void -XiGMiscChangeResolution (Display * dpy, int screen, int view, int width, - int height, int refresh) +XiGMiscChangeResolution(Display * dpy, int screen, int view, int width, + int height, int refresh) { xXiGMiscChangeResolutionReq *req; - XExtDisplayInfo *info = XiGMiscFindDisplay (dpy); + XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); - XiGMiscSimpleCheckExtension (dpy, info); + XiGMiscSimpleCheckExtension(dpy, info); - LockDisplay (dpy); - XiGMiscGetReq (XiGMiscChangeResolution, req, info); + LockDisplay(dpy); + XiGMiscGetReq(XiGMiscChangeResolution, req, info); req->screen = screen; req->view = view; req->width = width; req->height = height; req->refresh = refresh; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); } Bool -XiGMiscFullScreen (Display * dpy, int screen, XID window, XID cmap) +XiGMiscFullScreen(Display * dpy, int screen, XID window, XID cmap) { xXiGMiscFullScreenReq *req; xXiGMiscFullScreenReply rep; - XExtDisplayInfo *info = XiGMiscFindDisplay (dpy); + XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); - XiGMiscCheckExtension (dpy, info, xFalse); + XiGMiscCheckExtension(dpy, info, xFalse); - LockDisplay (dpy); - XiGMiscGetReq (XiGMiscFullScreen, req, info); + LockDisplay(dpy); + XiGMiscGetReq(XiGMiscFullScreen, req, info); req->screen = screen; req->pad0 = 0; req->pad1 = 0; req->window = window; req->cmap = cmap; - if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { + UnlockDisplay(dpy); + SyncHandle(); return xFalse; } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return (rep.success ? xTrue : xFalse); } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/Xext/Xinerama/Xinerama.c --- a/src/video/Xext/Xinerama/Xinerama.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/Xext/Xinerama/Xinerama.c Mon May 29 04:04:35 2006 +0000 @@ -45,7 +45,7 @@ #define PanoramiXSimpleCheckExtension(dpy,i) \ XextSimpleCheckExtension (dpy, i, panoramiX_extension_name) -static int close_display (); +static int close_display(); static /* const */ XExtensionHooks panoramiX_extension_hooks = { NULL, /* create_gc */ NULL, /* copy_gc */ @@ -61,22 +61,22 @@ }; static -XEXT_GENERATE_FIND_DISPLAY (find_display, panoramiX_ext_info, - panoramiX_extension_name, - &panoramiX_extension_hooks, 0, NULL) - static XEXT_GENERATE_CLOSE_DISPLAY (close_display, panoramiX_ext_info) +XEXT_GENERATE_FIND_DISPLAY(find_display, panoramiX_ext_info, + panoramiX_extension_name, + &panoramiX_extension_hooks, 0, NULL) + static XEXT_GENERATE_CLOSE_DISPLAY(close_display, panoramiX_ext_info) /**************************************************************************** * * * PanoramiX public interfaces * * * ****************************************************************************/ - Bool SDL_NAME (XPanoramiXQueryExtension) (Display * dpy, - int *event_basep, - int *error_basep) + Bool SDL_NAME(XPanoramiXQueryExtension) (Display * dpy, + int *event_basep, + int *error_basep) { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); - if (XextHasExtension (info)) { + if (XextHasExtension(info)) { *event_basep = info->codes->first_event; *error_basep = info->codes->first_error; return True; @@ -86,121 +86,121 @@ } -Status SDL_NAME (XPanoramiXQueryVersion) (Display * dpy, - int *major_versionp, - int *minor_versionp) +Status SDL_NAME(XPanoramiXQueryVersion) (Display * dpy, + int *major_versionp, + int *minor_versionp) { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xPanoramiXQueryVersionReply rep; register xPanoramiXQueryVersionReq *req; - PanoramiXCheckExtension (dpy, info, 0); + PanoramiXCheckExtension(dpy, info, 0); - LockDisplay (dpy); - GetReq (PanoramiXQueryVersion, req); + LockDisplay(dpy); + GetReq(PanoramiXQueryVersion, req); req->reqType = info->codes->major_opcode; req->panoramiXReqType = X_PanoramiXQueryVersion; req->clientMajor = PANORAMIX_MAJOR_VERSION; req->clientMinor = PANORAMIX_MINOR_VERSION; - if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { + UnlockDisplay(dpy); + SyncHandle(); return 0; } *major_versionp = rep.majorVersion; *minor_versionp = rep.minorVersion; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return 1; } -SDL_NAME (XPanoramiXInfo) * SDL_NAME (XPanoramiXAllocInfo) (void) +SDL_NAME(XPanoramiXInfo) * SDL_NAME(XPanoramiXAllocInfo) (void) { - return (SDL_NAME (XPanoramiXInfo) *) - Xmalloc (sizeof (SDL_NAME (XPanoramiXInfo))); + return (SDL_NAME(XPanoramiXInfo) *) + Xmalloc(sizeof(SDL_NAME(XPanoramiXInfo))); } -Status SDL_NAME (XPanoramiXGetState) (Display * dpy, - Drawable drawable, - SDL_NAME (XPanoramiXInfo) * - panoramiX_info) +Status SDL_NAME(XPanoramiXGetState) (Display * dpy, + Drawable drawable, + SDL_NAME(XPanoramiXInfo) * + panoramiX_info) { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xPanoramiXGetStateReply rep; register xPanoramiXGetStateReq *req; - PanoramiXCheckExtension (dpy, info, 0); + PanoramiXCheckExtension(dpy, info, 0); - LockDisplay (dpy); - GetReq (PanoramiXGetState, req); + LockDisplay(dpy); + GetReq(PanoramiXGetState, req); req->reqType = info->codes->major_opcode; req->panoramiXReqType = X_PanoramiXGetState; req->window = drawable; - if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { + UnlockDisplay(dpy); + SyncHandle(); return 0; } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); panoramiX_info->window = rep.window; panoramiX_info->State = rep.state; return 1; } -Status SDL_NAME (XPanoramiXGetScreenCount) (Display * dpy, - Drawable drawable, - SDL_NAME (XPanoramiXInfo) * - panoramiX_info) +Status SDL_NAME(XPanoramiXGetScreenCount) (Display * dpy, + Drawable drawable, + SDL_NAME(XPanoramiXInfo) * + panoramiX_info) { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xPanoramiXGetScreenCountReply rep; register xPanoramiXGetScreenCountReq *req; - PanoramiXCheckExtension (dpy, info, 0); + PanoramiXCheckExtension(dpy, info, 0); - LockDisplay (dpy); - GetReq (PanoramiXGetScreenCount, req); + LockDisplay(dpy); + GetReq(PanoramiXGetScreenCount, req); req->reqType = info->codes->major_opcode; req->panoramiXReqType = X_PanoramiXGetScreenCount; req->window = drawable; - if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { + UnlockDisplay(dpy); + SyncHandle(); return 0; } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); panoramiX_info->window = rep.window; panoramiX_info->ScreenCount = rep.ScreenCount; return 1; } -Status SDL_NAME (XPanoramiXGetScreenSize) (Display * dpy, - Drawable drawable, - int screen_num, - SDL_NAME (XPanoramiXInfo) * - panoramiX_info) +Status SDL_NAME(XPanoramiXGetScreenSize) (Display * dpy, + Drawable drawable, + int screen_num, + SDL_NAME(XPanoramiXInfo) * + panoramiX_info) { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xPanoramiXGetScreenSizeReply rep; register xPanoramiXGetScreenSizeReq *req; - PanoramiXCheckExtension (dpy, info, 0); + PanoramiXCheckExtension(dpy, info, 0); - LockDisplay (dpy); - GetReq (PanoramiXGetScreenSize, req); + LockDisplay(dpy); + GetReq(PanoramiXGetScreenSize, req); req->reqType = info->codes->major_opcode; req->panoramiXReqType = X_PanoramiXGetScreenSize; req->window = drawable; req->screen = screen_num; /* need to define */ - if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { + UnlockDisplay(dpy); + SyncHandle(); return 0; } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); panoramiX_info->window = rep.window; panoramiX_info->screen = rep.screen; panoramiX_info->width = rep.width; @@ -214,70 +214,70 @@ in the "Xinerama" namespace instead of "PanoramiX". \*******************************************************************/ -Bool SDL_NAME (XineramaQueryExtension) (Display * dpy, - int *event_base, int *error_base) +Bool SDL_NAME(XineramaQueryExtension) (Display * dpy, + int *event_base, int *error_base) { - return SDL_NAME (XPanoramiXQueryExtension) (dpy, event_base, error_base); + return SDL_NAME(XPanoramiXQueryExtension) (dpy, event_base, error_base); } -Status SDL_NAME (XineramaQueryVersion) (Display * dpy, int *major, int *minor) +Status SDL_NAME(XineramaQueryVersion) (Display * dpy, int *major, int *minor) { - return SDL_NAME (XPanoramiXQueryVersion) (dpy, major, minor); + return SDL_NAME(XPanoramiXQueryVersion) (dpy, major, minor); } -Bool SDL_NAME (XineramaIsActive) (Display * dpy) +Bool SDL_NAME(XineramaIsActive) (Display * dpy) { xXineramaIsActiveReply rep; xXineramaIsActiveReq *req; - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); - if (!XextHasExtension (info)) + if (!XextHasExtension(info)) return False; /* server doesn't even have the extension */ - LockDisplay (dpy); - GetReq (XineramaIsActive, req); + LockDisplay(dpy); + GetReq(XineramaIsActive, req); req->reqType = info->codes->major_opcode; req->panoramiXReqType = X_XineramaIsActive; - if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return rep.state; } #include -SDL_NAME (XineramaScreenInfo) * -SDL_NAME (XineramaQueryScreens) (Display * dpy, int *number) +SDL_NAME(XineramaScreenInfo) * +SDL_NAME(XineramaQueryScreens) (Display * dpy, int *number) { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXineramaQueryScreensReply rep; xXineramaQueryScreensReq *req; - SDL_NAME (XineramaScreenInfo) * scrnInfo = NULL; + SDL_NAME(XineramaScreenInfo) * scrnInfo = NULL; - PanoramiXCheckExtension (dpy, info, 0); + PanoramiXCheckExtension(dpy, info, 0); - LockDisplay (dpy); - GetReq (XineramaQueryScreens, req); + LockDisplay(dpy); + GetReq(XineramaQueryScreens, req); req->reqType = info->codes->major_opcode; req->panoramiXReqType = X_XineramaQueryScreens; - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return NULL; } if (rep.number) { if ((scrnInfo = - Xmalloc (sizeof (SDL_NAME (XineramaScreenInfo)) * rep.number))) { + Xmalloc(sizeof(SDL_NAME(XineramaScreenInfo)) * rep.number))) { xXineramaScreenInfo scratch; int i; for (i = 0; i < rep.number; i++) { - _XRead (dpy, (char *) (&scratch), sz_XineramaScreenInfo); + _XRead(dpy, (char *) (&scratch), sz_XineramaScreenInfo); scrnInfo[i].screen_number = i; scrnInfo[i].x_org = scratch.x_org; scrnInfo[i].y_org = scratch.y_org; @@ -287,11 +287,11 @@ *number = rep.number; } else - _XEatData (dpy, rep.length << 2); + _XEatData(dpy, rep.length << 2); } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return scrnInfo; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/Xext/Xv/Xv.c --- a/src/video/Xext/Xv/Xv.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/Xext/Xv/Xv.c Mon May 29 04:04:35 2006 +0000 @@ -63,9 +63,9 @@ #define XvCheckExtension(dpy, i, val) \ XextCheckExtension(dpy, i, xv_extension_name, val) -static char *xv_error_string (); -static int xv_close_display (); -static Bool xv_wire_to_event (); +static char *xv_error_string(); +static int xv_close_display(); +static Bool xv_wire_to_event(); static XExtensionHooks xv_extension_hooks = { NULL, /* create_gc */ @@ -89,33 +89,32 @@ }; static -XEXT_GENERATE_CLOSE_DISPLAY (xv_close_display, xv_info) - static XEXT_GENERATE_FIND_DISPLAY (xv_find_display, xv_info, - xv_extension_name, - &xv_extension_hooks, - XvNumEvents, NULL) - static XEXT_GENERATE_ERROR_STRING (xv_error_string, xv_extension_name, - XvNumErrors, xv_error_list) - int SDL_NAME (XvQueryExtension) (Display * dpy, - unsigned int *p_version, - unsigned int *p_revision, - unsigned int *p_requestBase, - unsigned int *p_eventBase, - unsigned int *p_errorBase) +XEXT_GENERATE_CLOSE_DISPLAY(xv_close_display, xv_info) + static XEXT_GENERATE_FIND_DISPLAY(xv_find_display, xv_info, + xv_extension_name, + &xv_extension_hooks, XvNumEvents, NULL) + static XEXT_GENERATE_ERROR_STRING(xv_error_string, xv_extension_name, + XvNumErrors, xv_error_list) + int SDL_NAME(XvQueryExtension) (Display * dpy, + unsigned int *p_version, + unsigned int *p_revision, + unsigned int *p_requestBase, + unsigned int *p_eventBase, + unsigned int *p_errorBase) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvQueryExtensionReq *req; xvQueryExtensionReply rep; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - XvGetReq (QueryExtension, req); + XvGetReq(QueryExtension, req); - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return XvBadExtension; } @@ -125,25 +124,25 @@ *p_eventBase = info->codes->first_event; *p_errorBase = info->codes->first_error; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return Success; } int -SDL_NAME (XvQueryAdaptors) (Display * dpy, - Window window, - unsigned int *p_nAdaptors, - SDL_NAME (XvAdaptorInfo) ** p_pAdaptors) +SDL_NAME(XvQueryAdaptors) (Display * dpy, + Window window, + unsigned int *p_nAdaptors, + SDL_NAME(XvAdaptorInfo) ** p_pAdaptors) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvQueryAdaptorsReq *req; xvQueryAdaptorsReply rep; int size, ii, jj; char *name; - SDL_NAME (XvAdaptorInfo) * pas, *pa; - SDL_NAME (XvFormat) * pfs, *pf; + SDL_NAME(XvAdaptorInfo) * pas, *pa; + SDL_NAME(XvFormat) * pfs, *pf; char *buffer; union { @@ -153,28 +152,28 @@ xvFormat *pf; } u; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - XvGetReq (QueryAdaptors, req); + XvGetReq(QueryAdaptors, req); req->window = window; /* READ THE REPLY */ - if (_XReply (dpy, (xReply *) & rep, 0, xFalse) == 0) { - UnlockDisplay (dpy); - SyncHandle (); + if (_XReply(dpy, (xReply *) & rep, 0, xFalse) == 0) { + UnlockDisplay(dpy); + SyncHandle(); return (XvBadReply); } size = rep.length << 2; - if ((buffer = (char *) Xmalloc ((unsigned) size)) == NULL) { - UnlockDisplay (dpy); - SyncHandle (); + if ((buffer = (char *) Xmalloc((unsigned) size)) == NULL) { + UnlockDisplay(dpy); + SyncHandle(); return (XvBadAlloc); } - _XRead (dpy, buffer, size); + _XRead(dpy, buffer, size); u.buffer = buffer; @@ -183,11 +182,11 @@ if (rep.num_adaptors == 0) { pas = NULL; } else { - size = rep.num_adaptors * sizeof (SDL_NAME (XvAdaptorInfo)); - if ((pas = (SDL_NAME (XvAdaptorInfo) *) Xmalloc (size)) == NULL) { - Xfree (buffer); - UnlockDisplay (dpy); - SyncHandle (); + size = rep.num_adaptors * sizeof(SDL_NAME(XvAdaptorInfo)); + if ((pas = (SDL_NAME(XvAdaptorInfo) *) Xmalloc(size)) == NULL) { + Xfree(buffer); + UnlockDisplay(dpy); + SyncHandle(); return (XvBadAlloc); } } @@ -198,7 +197,7 @@ for (ii = 0; ii < rep.num_adaptors; ii++) { pa->num_adaptors = 0; pa->name = (char *) NULL; - pa->formats = (SDL_NAME (XvFormat) *) NULL; + pa->formats = (SDL_NAME(XvFormat) *) NULL; pa++; } @@ -215,26 +214,26 @@ size = u.pa->name_size; u.buffer += (sz_xvAdaptorInfo + 3) & ~3; - if ((name = (char *) Xmalloc (size + 1)) == NULL) { - SDL_NAME (XvFreeAdaptorInfo) (pas); - Xfree (buffer); - UnlockDisplay (dpy); - SyncHandle (); + if ((name = (char *) Xmalloc(size + 1)) == NULL) { + SDL_NAME(XvFreeAdaptorInfo) (pas); + Xfree(buffer); + UnlockDisplay(dpy); + SyncHandle(); return (XvBadAlloc); } - SDL_strlcpy (name, u.string, size); + SDL_strlcpy(name, u.string, size); pa->name = name; u.buffer += (size + 3) & ~3; /* GET FORMATS */ - size = pa->num_formats * sizeof (SDL_NAME (XvFormat)); - if ((pfs = (SDL_NAME (XvFormat) *) Xmalloc (size)) == NULL) { - SDL_NAME (XvFreeAdaptorInfo) (pas); - Xfree (buffer); - UnlockDisplay (dpy); - SyncHandle (); + size = pa->num_formats * sizeof(SDL_NAME(XvFormat)); + if ((pfs = (SDL_NAME(XvFormat) *) Xmalloc(size)) == NULL) { + SDL_NAME(XvFreeAdaptorInfo) (pas); + Xfree(buffer); + UnlockDisplay(dpy); + SyncHandle(); return (XvBadAlloc); } @@ -256,18 +255,18 @@ *p_nAdaptors = rep.num_adaptors; *p_pAdaptors = pas; - Xfree (buffer); - UnlockDisplay (dpy); - SyncHandle (); + Xfree(buffer); + UnlockDisplay(dpy); + SyncHandle(); return (Success); } -void SDL_NAME (XvFreeAdaptorInfo) (SDL_NAME (XvAdaptorInfo) * pAdaptors) +void SDL_NAME(XvFreeAdaptorInfo) (SDL_NAME(XvAdaptorInfo) * pAdaptors) { - SDL_NAME (XvAdaptorInfo) * pa; + SDL_NAME(XvAdaptorInfo) * pa; int ii; if (!pAdaptors) @@ -277,28 +276,28 @@ for (ii = 0; ii < pAdaptors->num_adaptors; ii++, pa++) { if (pa->name) { - Xfree (pa->name); + Xfree(pa->name); } if (pa->formats) { - Xfree (pa->formats); + Xfree(pa->formats); } } - Xfree (pAdaptors); + Xfree(pAdaptors); } int -SDL_NAME (XvQueryEncodings) (Display * dpy, - XvPortID port, - unsigned int *p_nEncodings, - SDL_NAME (XvEncodingInfo) ** p_pEncodings) +SDL_NAME(XvQueryEncodings) (Display * dpy, + XvPortID port, + unsigned int *p_nEncodings, + SDL_NAME(XvEncodingInfo) ** p_pEncodings) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvQueryEncodingsReq *req; xvQueryEncodingsReply rep; int size, jj; char *name; - SDL_NAME (XvEncodingInfo) * pes, *pe; + SDL_NAME(XvEncodingInfo) * pes, *pe; char *buffer; union { @@ -307,38 +306,38 @@ xvEncodingInfo *pe; } u; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - XvGetReq (QueryEncodings, req); + XvGetReq(QueryEncodings, req); req->port = port; /* READ THE REPLY */ - if (_XReply (dpy, (xReply *) & rep, 0, xFalse) == 0) { - UnlockDisplay (dpy); - SyncHandle (); + if (_XReply(dpy, (xReply *) & rep, 0, xFalse) == 0) { + UnlockDisplay(dpy); + SyncHandle(); return (XvBadReply); } size = rep.length << 2; - if ((buffer = (char *) Xmalloc ((unsigned) size)) == NULL) { - UnlockDisplay (dpy); - SyncHandle (); + if ((buffer = (char *) Xmalloc((unsigned) size)) == NULL) { + UnlockDisplay(dpy); + SyncHandle(); return (XvBadAlloc); } - _XRead (dpy, buffer, size); + _XRead(dpy, buffer, size); u.buffer = buffer; /* GET ENCODINGS */ - size = rep.num_encodings * sizeof (SDL_NAME (XvEncodingInfo)); - if ((pes = (SDL_NAME (XvEncodingInfo) *) Xmalloc (size)) == NULL) { - Xfree (buffer); - UnlockDisplay (dpy); - SyncHandle (); + size = rep.num_encodings * sizeof(SDL_NAME(XvEncodingInfo)); + if ((pes = (SDL_NAME(XvEncodingInfo) *) Xmalloc(size)) == NULL) { + Xfree(buffer); + UnlockDisplay(dpy); + SyncHandle(); return (XvBadAlloc); } @@ -363,13 +362,13 @@ size = u.pe->name_size; u.buffer += (sz_xvEncodingInfo + 3) & ~3; - if ((name = (char *) Xmalloc (size + 1)) == NULL) { - Xfree (buffer); - UnlockDisplay (dpy); - SyncHandle (); + if ((name = (char *) Xmalloc(size + 1)) == NULL) { + Xfree(buffer); + UnlockDisplay(dpy); + SyncHandle(); return (XvBadAlloc); } - SDL_strlcpy (name, u.string, size); + SDL_strlcpy(name, u.string, size); pe->name = name; pe++; @@ -379,17 +378,17 @@ *p_nEncodings = rep.num_encodings; *p_pEncodings = pes; - Xfree (buffer); - UnlockDisplay (dpy); - SyncHandle (); + Xfree(buffer); + UnlockDisplay(dpy); + SyncHandle(); return (Success); } -void SDL_NAME (XvFreeEncodingInfo) (SDL_NAME (XvEncodingInfo) * pEncodings) +void SDL_NAME(XvFreeEncodingInfo) (SDL_NAME(XvEncodingInfo) * pEncodings) { - SDL_NAME (XvEncodingInfo) * pe; + SDL_NAME(XvEncodingInfo) * pe; int ii; if (!pEncodings) @@ -399,31 +398,31 @@ for (ii = 0; ii < pEncodings->num_encodings; ii++, pe++) { if (pe->name) - Xfree (pe->name); + Xfree(pe->name); } - Xfree (pEncodings); + Xfree(pEncodings); } int -SDL_NAME (XvPutVideo) (Display * dpy, - XvPortID port, - Drawable d, - GC gc, - int vx, int vy, - unsigned int vw, unsigned int vh, - int dx, int dy, unsigned int dw, unsigned int dh) +SDL_NAME(XvPutVideo) (Display * dpy, + XvPortID port, + Drawable d, + GC gc, + int vx, int vy, + unsigned int vw, unsigned int vh, + int dx, int dy, unsigned int dw, unsigned int dh) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvPutVideoReq *req; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - FlushGC (dpy, gc); + FlushGC(dpy, gc); - XvGetReq (PutVideo, req); + XvGetReq(PutVideo, req); req->port = port; req->drawable = d; @@ -437,31 +436,31 @@ req->drw_w = dw; req->drw_h = dh; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return Success; } int -SDL_NAME (XvPutStill) (Display * dpy, - XvPortID port, - Drawable d, - GC gc, - int vx, int vy, - unsigned int vw, unsigned int vh, - int dx, int dy, unsigned int dw, unsigned int dh) +SDL_NAME(XvPutStill) (Display * dpy, + XvPortID port, + Drawable d, + GC gc, + int vx, int vy, + unsigned int vw, unsigned int vh, + int dx, int dy, unsigned int dw, unsigned int dh) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvPutStillReq *req; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - FlushGC (dpy, gc); + FlushGC(dpy, gc); - XvGetReq (PutStill, req); + XvGetReq(PutStill, req); req->port = port; req->drawable = d; req->gc = gc->gid; @@ -474,31 +473,31 @@ req->drw_w = dw; req->drw_h = dh; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return Success; } int -SDL_NAME (XvGetVideo) (Display * dpy, - XvPortID port, - Drawable d, - GC gc, - int vx, int vy, - unsigned int vw, unsigned int vh, - int dx, int dy, unsigned int dw, unsigned int dh) +SDL_NAME(XvGetVideo) (Display * dpy, + XvPortID port, + Drawable d, + GC gc, + int vx, int vy, + unsigned int vw, unsigned int vh, + int dx, int dy, unsigned int dw, unsigned int dh) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvGetVideoReq *req; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - FlushGC (dpy, gc); + FlushGC(dpy, gc); - XvGetReq (GetVideo, req); + XvGetReq(GetVideo, req); req->port = port; req->drawable = d; req->gc = gc->gid; @@ -511,31 +510,31 @@ req->drw_w = dw; req->drw_h = dh; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return Success; } int -SDL_NAME (XvGetStill) (Display * dpy, - XvPortID port, - Drawable d, - GC gc, - int vx, int vy, - unsigned int vw, unsigned int vh, - int dx, int dy, unsigned int dw, unsigned int dh) +SDL_NAME(XvGetStill) (Display * dpy, + XvPortID port, + Drawable d, + GC gc, + int vx, int vy, + unsigned int vw, unsigned int vh, + int dx, int dy, unsigned int dw, unsigned int dh) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvGetStillReq *req; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - FlushGC (dpy, gc); + FlushGC(dpy, gc); - XvGetReq (GetStill, req); + XvGetReq(GetStill, req); req->port = port; req->drawable = d; req->gc = gc->gid; @@ -548,189 +547,189 @@ req->drw_w = dw; req->drw_h = dh; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return Success; } -int SDL_NAME (XvStopVideo) (Display * dpy, XvPortID port, Drawable draw) +int SDL_NAME(XvStopVideo) (Display * dpy, XvPortID port, Drawable draw) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvStopVideoReq *req; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - XvGetReq (StopVideo, req); + XvGetReq(StopVideo, req); req->port = port; req->drawable = draw; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return Success; } -int SDL_NAME (XvGrabPort) (Display * dpy, XvPortID port, Time time) +int SDL_NAME(XvGrabPort) (Display * dpy, XvPortID port, Time time) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); int result; xvGrabPortReply rep; xvGrabPortReq *req; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - XvGetReq (GrabPort, req); + XvGetReq(GrabPort, req); req->port = port; req->time = time; - if (_XReply (dpy, (xReply *) & rep, 0, xTrue) == 0) + if (_XReply(dpy, (xReply *) & rep, 0, xTrue) == 0) rep.result = GrabSuccess; result = rep.result; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return result; } -int SDL_NAME (XvUngrabPort) (Display * dpy, XvPortID port, Time time) +int SDL_NAME(XvUngrabPort) (Display * dpy, XvPortID port, Time time) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvUngrabPortReq *req; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - XvGetReq (UngrabPort, req); + XvGetReq(UngrabPort, req); req->port = port; req->time = time; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return Success; } int -SDL_NAME (XvSelectVideoNotify) (Display * dpy, Drawable drawable, Bool onoff) +SDL_NAME(XvSelectVideoNotify) (Display * dpy, Drawable drawable, Bool onoff) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvSelectVideoNotifyReq *req; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - XvGetReq (SelectVideoNotify, req); + XvGetReq(SelectVideoNotify, req); req->drawable = drawable; req->onoff = onoff; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return Success; } -int SDL_NAME (XvSelectPortNotify) (Display * dpy, XvPortID port, Bool onoff) +int SDL_NAME(XvSelectPortNotify) (Display * dpy, XvPortID port, Bool onoff) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvSelectPortNotifyReq *req; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - XvGetReq (SelectPortNotify, req); + XvGetReq(SelectPortNotify, req); req->port = port; req->onoff = onoff; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return Success; } int -SDL_NAME (XvSetPortAttribute) (Display * dpy, - XvPortID port, Atom attribute, int value) +SDL_NAME(XvSetPortAttribute) (Display * dpy, + XvPortID port, Atom attribute, int value) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvSetPortAttributeReq *req; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - XvGetReq (SetPortAttribute, req); + XvGetReq(SetPortAttribute, req); req->port = port; req->attribute = attribute; req->value = value; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return (Success); } int -SDL_NAME (XvGetPortAttribute) (Display * dpy, - XvPortID port, Atom attribute, int *p_value) +SDL_NAME(XvGetPortAttribute) (Display * dpy, + XvPortID port, Atom attribute, int *p_value) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvGetPortAttributeReq *req; xvGetPortAttributeReply rep; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - XvGetReq (GetPortAttribute, req); + XvGetReq(GetPortAttribute, req); req->port = port; req->attribute = attribute; /* READ THE REPLY */ - if (_XReply (dpy, (xReply *) & rep, 0, xFalse) == 0) { - UnlockDisplay (dpy); - SyncHandle (); + if (_XReply(dpy, (xReply *) & rep, 0, xFalse) == 0) { + UnlockDisplay(dpy); + SyncHandle(); return (XvBadReply); } *p_value = rep.value; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return (Success); } int -SDL_NAME (XvQueryBestSize) (Display * dpy, - XvPortID port, - Bool motion, - unsigned int vid_w, - unsigned int vid_h, - unsigned int drw_w, - unsigned int drw_h, - unsigned int *p_actual_width, - unsigned int *p_actual_height) +SDL_NAME(XvQueryBestSize) (Display * dpy, + XvPortID port, + Bool motion, + unsigned int vid_w, + unsigned int vid_h, + unsigned int drw_w, + unsigned int drw_h, + unsigned int *p_actual_width, + unsigned int *p_actual_height) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvQueryBestSizeReq *req; xvQueryBestSizeReply rep; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - XvGetReq (QueryBestSize, req); + XvGetReq(QueryBestSize, req); req->port = port; req->motion = motion; req->vid_w = vid_w; @@ -740,117 +739,116 @@ /* READ THE REPLY */ - if (_XReply (dpy, (xReply *) & rep, 0, xFalse) == 0) { - UnlockDisplay (dpy); - SyncHandle (); + if (_XReply(dpy, (xReply *) & rep, 0, xFalse) == 0) { + UnlockDisplay(dpy); + SyncHandle(); return (XvBadReply); } *p_actual_width = rep.actual_width; *p_actual_height = rep.actual_height; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return (Success); } -SDL_NAME (XvAttribute) * -SDL_NAME (XvQueryPortAttributes) (Display * dpy, XvPortID port, int *num) +SDL_NAME(XvAttribute) * +SDL_NAME(XvQueryPortAttributes) (Display * dpy, XvPortID port, int *num) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvQueryPortAttributesReq *req; xvQueryPortAttributesReply rep; - SDL_NAME (XvAttribute) * ret = NULL; + SDL_NAME(XvAttribute) * ret = NULL; *num = 0; - XvCheckExtension (dpy, info, NULL); + XvCheckExtension(dpy, info, NULL); - LockDisplay (dpy); + LockDisplay(dpy); - XvGetReq (QueryPortAttributes, req); + XvGetReq(QueryPortAttributes, req); req->port = port; /* READ THE REPLY */ - if (_XReply (dpy, (xReply *) & rep, 0, xFalse) == 0) { - UnlockDisplay (dpy); - SyncHandle (); + if (_XReply(dpy, (xReply *) & rep, 0, xFalse) == 0) { + UnlockDisplay(dpy); + SyncHandle(); return ret; } if (rep.num_attributes) { int size = - (rep.num_attributes * sizeof (SDL_NAME (XvAttribute))) + + (rep.num_attributes * sizeof(SDL_NAME(XvAttribute))) + rep.text_size; - if ((ret = Xmalloc (size))) { + if ((ret = Xmalloc(size))) { char *marker = (char *) (&ret[rep.num_attributes]); xvAttributeInfo Info; int i; for (i = 0; i < rep.num_attributes; i++) { - _XRead (dpy, (char *) (&Info), sz_xvAttributeInfo); + _XRead(dpy, (char *) (&Info), sz_xvAttributeInfo); ret[i].flags = (int) Info.flags; ret[i].min_value = Info.min; ret[i].max_value = Info.max; ret[i].name = marker; - _XRead (dpy, marker, Info.size); + _XRead(dpy, marker, Info.size); marker += Info.size; (*num)++; } } else - _XEatData (dpy, rep.length << 2); + _XEatData(dpy, rep.length << 2); } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return ret; } -SDL_NAME (XvImageFormatValues) * SDL_NAME (XvListImageFormats) (Display * dpy, - XvPortID port, - int *num) +SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) (Display * dpy, + XvPortID port, + int *num) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvListImageFormatsReq *req; xvListImageFormatsReply rep; - SDL_NAME (XvImageFormatValues) * ret = NULL; + SDL_NAME(XvImageFormatValues) * ret = NULL; *num = 0; - XvCheckExtension (dpy, info, NULL); + XvCheckExtension(dpy, info, NULL); - LockDisplay (dpy); + LockDisplay(dpy); - XvGetReq (ListImageFormats, req); + XvGetReq(ListImageFormats, req); req->port = port; /* READ THE REPLY */ - if (_XReply (dpy, (xReply *) & rep, 0, xFalse) == 0) { - UnlockDisplay (dpy); - SyncHandle (); + if (_XReply(dpy, (xReply *) & rep, 0, xFalse) == 0) { + UnlockDisplay(dpy); + SyncHandle(); return NULL; } if (rep.num_formats) { - int size = - (rep.num_formats * sizeof (SDL_NAME (XvImageFormatValues))); + int size = (rep.num_formats * sizeof(SDL_NAME(XvImageFormatValues))); - if ((ret = Xmalloc (size))) { + if ((ret = Xmalloc(size))) { xvImageFormatInfo Info; int i; for (i = 0; i < rep.num_formats; i++) { - _XRead (dpy, (char *) (&Info), sz_xvImageFormatInfo); + _XRead(dpy, (char *) (&Info), sz_xvImageFormatInfo); ret[i].id = Info.id; ret[i].type = Info.type; ret[i].byte_order = Info.byte_order; - memcpy (&(ret[i].guid[0]), &(Info.guid[0]), 16); + memcpy(&(ret[i].guid[0]), &(Info.guid[0]), 16); ret[i].bits_per_pixel = Info.bpp; ret[i].format = Info.format; ret[i].num_planes = Info.num_planes; @@ -867,37 +865,37 @@ ret[i].vert_y_period = Info.vert_y_period; ret[i].vert_u_period = Info.vert_u_period; ret[i].vert_v_period = Info.vert_v_period; - memcpy (&(ret[i].component_order[0]), - &(Info.comp_order[0]), 32); + memcpy(&(ret[i].component_order[0]), + &(Info.comp_order[0]), 32); ret[i].scanline_order = Info.scanline_order; (*num)++; } } else - _XEatData (dpy, rep.length << 2); + _XEatData(dpy, rep.length << 2); } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return ret; } -SDL_NAME (XvImage) * SDL_NAME (XvCreateImage) (Display * dpy, - XvPortID port, - int id, - char *data, - int width, int height) +SDL_NAME(XvImage) * SDL_NAME(XvCreateImage) (Display * dpy, + XvPortID port, + int id, + char *data, + int width, int height) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvQueryImageAttributesReq *req; xvQueryImageAttributesReply rep; - SDL_NAME (XvImage) * ret = NULL; + SDL_NAME(XvImage) * ret = NULL; - XvCheckExtension (dpy, info, NULL); + XvCheckExtension(dpy, info, NULL); - LockDisplay (dpy); + LockDisplay(dpy); - XvGetReq (QueryImageAttributes, req); + XvGetReq(QueryImageAttributes, req); req->id = id; req->port = port; req->width = width; @@ -905,15 +903,15 @@ /* READ THE REPLY */ - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return NULL; } if ((ret = - (SDL_NAME (XvImage) *) Xmalloc (sizeof (SDL_NAME (XvImage)) + - (rep.num_planes << 3)))) { + (SDL_NAME(XvImage) *) Xmalloc(sizeof(SDL_NAME(XvImage)) + + (rep.num_planes << 3)))) { ret->id = id; ret->width = rep.width; ret->height = rep.height; @@ -923,27 +921,27 @@ ret->offsets = ret->pitches + rep.num_planes; ret->data = data; ret->obdata = NULL; - _XRead (dpy, (char *) (ret->pitches), rep.num_planes << 2); - _XRead (dpy, (char *) (ret->offsets), rep.num_planes << 2); + _XRead(dpy, (char *) (ret->pitches), rep.num_planes << 2); + _XRead(dpy, (char *) (ret->offsets), rep.num_planes << 2); } else - _XEatData (dpy, rep.length << 2); + _XEatData(dpy, rep.length << 2); - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return ret; } -SDL_NAME (XvImage) * SDL_NAME (XvShmCreateImage) (Display * dpy, - XvPortID port, - int id, - char *data, - int width, - int height, - XShmSegmentInfo * shminfo) +SDL_NAME(XvImage) * SDL_NAME(XvShmCreateImage) (Display * dpy, + XvPortID port, + int id, + char *data, + int width, + int height, + XShmSegmentInfo * shminfo) { - SDL_NAME (XvImage) * ret; + SDL_NAME(XvImage) * ret; - ret = SDL_NAME (XvCreateImage) (dpy, port, id, data, width, height); + ret = SDL_NAME(XvCreateImage) (dpy, port, id, data, width, height); if (ret) ret->obdata = (XPointer) shminfo; @@ -951,30 +949,30 @@ return ret; } -int SDL_NAME (XvPutImage) (Display * dpy, - XvPortID port, - Drawable d, - GC gc, - SDL_NAME (XvImage) * image, - int src_x, - int src_y, - unsigned int src_w, - unsigned int src_h, - int dest_x, - int dest_y, - unsigned int dest_w, unsigned int dest_h) +int SDL_NAME(XvPutImage) (Display * dpy, + XvPortID port, + Drawable d, + GC gc, + SDL_NAME(XvImage) * image, + int src_x, + int src_y, + unsigned int src_w, + unsigned int src_h, + int dest_x, + int dest_y, + unsigned int dest_w, unsigned int dest_h) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); xvPutImageReq *req; int len; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - FlushGC (dpy, gc); + FlushGC(dpy, gc); - XvGetReq (PutImage, req); + XvGetReq(PutImage, req); req->port = port; req->drawable = d; @@ -992,45 +990,45 @@ req->height = image->height; len = (image->data_size + 3) >> 2; - SetReqLen (req, len, len); + SetReqLen(req, len, len); /* Yes it's kindof lame that we are sending the whole thing, but for video all of it may be needed even if displaying only a subsection, and I don't want to go through the trouble of creating subregions to send */ - Data (dpy, (char *) image->data, image->data_size); + Data(dpy, (char *) image->data, image->data_size); - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return Success; } -int SDL_NAME (XvShmPutImage) (Display * dpy, - XvPortID port, - Drawable d, - GC gc, - SDL_NAME (XvImage) * image, - int src_x, - int src_y, - unsigned int src_w, - unsigned int src_h, - int dest_x, - int dest_y, - unsigned int dest_w, - unsigned int dest_h, Bool send_event) +int SDL_NAME(XvShmPutImage) (Display * dpy, + XvPortID port, + Drawable d, + GC gc, + SDL_NAME(XvImage) * image, + int src_x, + int src_y, + unsigned int src_w, + unsigned int src_h, + int dest_x, + int dest_y, + unsigned int dest_w, + unsigned int dest_h, Bool send_event) { - XExtDisplayInfo *info = xv_find_display (dpy); + XExtDisplayInfo *info = xv_find_display(dpy); XShmSegmentInfo *shminfo = (XShmSegmentInfo *) image->obdata; xvShmPutImageReq *req; - XvCheckExtension (dpy, info, XvBadExtension); + XvCheckExtension(dpy, info, XvBadExtension); - LockDisplay (dpy); + LockDisplay(dpy); - FlushGC (dpy, gc); + FlushGC(dpy, gc); - XvGetReq (ShmPutImage, req); + XvGetReq(ShmPutImage, req); req->port = port; req->drawable = d; @@ -1050,27 +1048,27 @@ req->height = image->height; req->send_event = send_event; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return Success; } static Bool -xv_wire_to_event (Display * dpy, XEvent * host, xEvent * wire) +xv_wire_to_event(Display * dpy, XEvent * host, xEvent * wire) { - XExtDisplayInfo *info = xv_find_display (dpy); - SDL_NAME (XvEvent) * re = (SDL_NAME (XvEvent) *) host; + XExtDisplayInfo *info = xv_find_display(dpy); + SDL_NAME(XvEvent) * re = (SDL_NAME(XvEvent) *) host; xvEvent *event = (xvEvent *) wire; - XvCheckExtension (dpy, info, False); + XvCheckExtension(dpy, info, False); switch ((event->u.u.type & 0x7F) - info->codes->first_event) { case XvVideoNotify: re->xvvideo.type = event->u.u.type & 0x7f; re->xvvideo.serial = - _XSetLastRequestRead (dpy, (xGenericReply *) event); + _XSetLastRequestRead(dpy, (xGenericReply *) event); re->xvvideo.send_event = ((event->u.u.type & 0x80) != 0); re->xvvideo.display = dpy; re->xvvideo.time = event->u.videoNotify.time; @@ -1081,7 +1079,7 @@ case XvPortNotify: re->xvport.type = event->u.u.type & 0x7f; re->xvport.serial = - _XSetLastRequestRead (dpy, (xGenericReply *) event); + _XSetLastRequestRead(dpy, (xGenericReply *) event); re->xvport.send_event = ((event->u.u.type & 0x80) != 0); re->xvport.display = dpy; re->xvport.time = event->u.portNotify.time; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/Xext/Xxf86dga/XF86DGA.c --- a/src/video/Xext/Xxf86dga/XF86DGA.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/Xext/Xxf86dga/XF86DGA.c Mon May 29 04:04:35 2006 +0000 @@ -65,8 +65,8 @@ #include "../extensions/Xext.h" #include "../extensions/extutil.h" -extern XExtDisplayInfo *SDL_NAME (xdga_find_display) (Display *); -extern char *SDL_NAME (xdga_extension_name); +extern XExtDisplayInfo *SDL_NAME(xdga_find_display) (Display *); +extern char *SDL_NAME(xdga_extension_name); #define XF86DGACheckExtension(dpy,i,val) \ XextCheckExtension (dpy, i, SDL_NAME(xdga_extension_name), val) @@ -77,37 +77,37 @@ * * *****************************************************************************/ -Bool SDL_NAME (XF86DGAQueryExtension) (Display * dpy, - int *event_basep, int *error_basep) +Bool SDL_NAME(XF86DGAQueryExtension) (Display * dpy, + int *event_basep, int *error_basep) { - return SDL_NAME (XDGAQueryExtension) (dpy, event_basep, error_basep); + return SDL_NAME(XDGAQueryExtension) (dpy, event_basep, error_basep); } -Bool SDL_NAME (XF86DGAQueryVersion) (Display * dpy, - int *majorVersion, int *minorVersion) +Bool SDL_NAME(XF86DGAQueryVersion) (Display * dpy, + int *majorVersion, int *minorVersion) { - return SDL_NAME (XDGAQueryVersion) (dpy, majorVersion, minorVersion); + return SDL_NAME(XDGAQueryVersion) (dpy, majorVersion, minorVersion); } -Bool SDL_NAME (XF86DGAGetVideoLL) (Display * dpy, - int screen, - int *offset, - int *width, int *bank_size, int *ram_size) +Bool SDL_NAME(XF86DGAGetVideoLL) (Display * dpy, + int screen, + int *offset, + int *width, int *bank_size, int *ram_size) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGAGetVideoLLReply rep; xXF86DGAGetVideoLLReq *req; - XF86DGACheckExtension (dpy, info, False); + XF86DGACheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86DGAGetVideoLL, req); + LockDisplay(dpy); + GetReq(XF86DGAGetVideoLL, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGAGetVideoLL; req->screen = screen; - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } @@ -116,192 +116,191 @@ *bank_size = rep.bank_size; *ram_size = rep.ram_size; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } -Bool SDL_NAME (XF86DGADirectVideoLL) (Display * dpy, int screen, int enable) +Bool SDL_NAME(XF86DGADirectVideoLL) (Display * dpy, int screen, int enable) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGADirectVideoReq *req; - XF86DGACheckExtension (dpy, info, False); + XF86DGACheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86DGADirectVideo, req); + LockDisplay(dpy); + GetReq(XF86DGADirectVideo, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGADirectVideo; req->screen = screen; req->enable = enable; - UnlockDisplay (dpy); - SyncHandle (); - XSync (dpy, False); + UnlockDisplay(dpy); + SyncHandle(); + XSync(dpy, False); return True; } -Bool SDL_NAME (XF86DGAGetViewPortSize) (Display * dpy, - int screen, int *width, int *height) +Bool SDL_NAME(XF86DGAGetViewPortSize) (Display * dpy, + int screen, int *width, int *height) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGAGetViewPortSizeReply rep; xXF86DGAGetViewPortSizeReq *req; - XF86DGACheckExtension (dpy, info, False); + XF86DGACheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86DGAGetViewPortSize, req); + LockDisplay(dpy); + GetReq(XF86DGAGetViewPortSize, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGAGetViewPortSize; req->screen = screen; - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } *width = rep.width; *height = rep.height; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } -Bool SDL_NAME (XF86DGASetViewPort) (Display * dpy, int screen, int x, int y) +Bool SDL_NAME(XF86DGASetViewPort) (Display * dpy, int screen, int x, int y) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGASetViewPortReq *req; - XF86DGACheckExtension (dpy, info, False); + XF86DGACheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86DGASetViewPort, req); + LockDisplay(dpy); + GetReq(XF86DGASetViewPort, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGASetViewPort; req->screen = screen; req->x = x; req->y = y; - UnlockDisplay (dpy); - SyncHandle (); - XSync (dpy, False); + UnlockDisplay(dpy); + SyncHandle(); + XSync(dpy, False); return True; } -Bool SDL_NAME (XF86DGAGetVidPage) (Display * dpy, int screen, int *vpage) +Bool SDL_NAME(XF86DGAGetVidPage) (Display * dpy, int screen, int *vpage) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGAGetVidPageReply rep; xXF86DGAGetVidPageReq *req; - XF86DGACheckExtension (dpy, info, False); + XF86DGACheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86DGAGetVidPage, req); + LockDisplay(dpy); + GetReq(XF86DGAGetVidPage, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGAGetVidPage; req->screen = screen; - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } *vpage = rep.vpage; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } -Bool SDL_NAME (XF86DGASetVidPage) (Display * dpy, int screen, int vpage) +Bool SDL_NAME(XF86DGASetVidPage) (Display * dpy, int screen, int vpage) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGASetVidPageReq *req; - XF86DGACheckExtension (dpy, info, False); + XF86DGACheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86DGASetVidPage, req); + LockDisplay(dpy); + GetReq(XF86DGASetVidPage, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGASetVidPage; req->screen = screen; req->vpage = vpage; - UnlockDisplay (dpy); - SyncHandle (); - XSync (dpy, False); + UnlockDisplay(dpy); + SyncHandle(); + XSync(dpy, False); return True; } -Bool SDL_NAME (XF86DGAInstallColormap) (Display * dpy, - int screen, Colormap cmap) +Bool SDL_NAME(XF86DGAInstallColormap) (Display * dpy, + int screen, Colormap cmap) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGAInstallColormapReq *req; - XF86DGACheckExtension (dpy, info, False); + XF86DGACheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86DGAInstallColormap, req); + LockDisplay(dpy); + GetReq(XF86DGAInstallColormap, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGAInstallColormap; req->screen = screen; req->id = cmap; - UnlockDisplay (dpy); - SyncHandle (); - XSync (dpy, False); + UnlockDisplay(dpy); + SyncHandle(); + XSync(dpy, False); return True; } -Bool SDL_NAME (XF86DGAQueryDirectVideo) (Display * dpy, - int screen, int *flags) +Bool SDL_NAME(XF86DGAQueryDirectVideo) (Display * dpy, int screen, int *flags) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGAQueryDirectVideoReply rep; xXF86DGAQueryDirectVideoReq *req; - XF86DGACheckExtension (dpy, info, False); + XF86DGACheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86DGAQueryDirectVideo, req); + LockDisplay(dpy); + GetReq(XF86DGAQueryDirectVideo, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGAQueryDirectVideo; req->screen = screen; - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } *flags = rep.flags; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } -Bool SDL_NAME (XF86DGAViewPortChanged) (Display * dpy, int screen, int n) +Bool SDL_NAME(XF86DGAViewPortChanged) (Display * dpy, int screen, int n) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGAViewPortChangedReply rep; xXF86DGAViewPortChangedReq *req; - XF86DGACheckExtension (dpy, info, False); + XF86DGACheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86DGAViewPortChanged, req); + LockDisplay(dpy); + GetReq(XF86DGAViewPortChanged, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGAViewPortChanged; req->screen = screen; req->n = n; - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return rep.result; } @@ -373,41 +372,41 @@ static ScrPtr *scrList = NULL; static MapPtr -AddMap (void) +AddMap(void) { MapPtr *old; old = mapList; - mapList = realloc (mapList, sizeof (MapPtr) * (numMaps + 1)); + mapList = realloc(mapList, sizeof(MapPtr) * (numMaps + 1)); if (!mapList) { mapList = old; return NULL; } - mapList[numMaps] = malloc (sizeof (MapRec)); + mapList[numMaps] = malloc(sizeof(MapRec)); if (!mapList[numMaps]) return NULL; return mapList[numMaps++]; } static ScrPtr -AddScr (void) +AddScr(void) { ScrPtr *old; old = scrList; - scrList = realloc (scrList, sizeof (ScrPtr) * (numScrs + 1)); + scrList = realloc(scrList, sizeof(ScrPtr) * (numScrs + 1)); if (!scrList) { scrList = old; return NULL; } - scrList[numScrs] = malloc (sizeof (ScrRec)); + scrList[numScrs] = malloc(sizeof(ScrRec)); if (!scrList[numScrs]) return NULL; return scrList[numScrs++]; } static MapPtr -FindMap (unsigned long address, unsigned long size) +FindMap(unsigned long address, unsigned long size) { int i; @@ -419,7 +418,7 @@ } static ScrPtr -FindScr (Display * display, int screen) +FindScr(Display * display, int screen) { int i; @@ -431,7 +430,7 @@ } static void * -MapPhysAddress (unsigned long address, unsigned long size) +MapPhysAddress(unsigned long address, unsigned long size) { unsigned long offset, delta; int pagesize = -1; @@ -445,20 +444,20 @@ HFILE hfd; #endif - if ((mp = FindMap (address, size))) { + if ((mp = FindMap(address, size))) { mp->refcount++; return (void *) ((unsigned long) mp->vaddr + mp->delta); } #if defined(_SC_PAGESIZE) && defined(HAS_SC_PAGESIZE) - pagesize = sysconf (_SC_PAGESIZE); + pagesize = sysconf(_SC_PAGESIZE); #endif #ifdef _SC_PAGE_SIZE if (pagesize == -1) - pagesize = sysconf (_SC_PAGE_SIZE); + pagesize = sysconf(_SC_PAGE_SIZE); #endif #ifdef HAS_GETPAGESIZE if (pagesize == -1) - pagesize = getpagesize (); + pagesize = getpagesize(); #endif #ifdef PAGE_SIZE if (pagesize == -1) @@ -472,7 +471,7 @@ #if defined(ISC) && defined(HAS_SVR3_MMAP) if (mapFd < 0) { - if ((mapFd = open ("/dev/mmap", O_RDWR)) < 0) + if ((mapFd = open("/dev/mmap", O_RDWR)) < 0) return NULL; } mloc.vaddr = (char *) 0; @@ -480,7 +479,7 @@ mloc.length = size + delta; mloc.ioflg = 1; - if ((vaddr = (void *) ioctl (mapFd, MAP, &mloc)) == (void *) -1) + if ((vaddr = (void *) ioctl(mapFd, MAP, &mloc)) == (void *) -1) return NULL; #elif defined (__EMX__) /* @@ -489,8 +488,8 @@ * of memory handles. Some umap/close mechanism should be provided */ - rc = DosOpen ("/dev/pmap$", &hfd, &action, 0, FILE_NORMAL, FILE_OPEN, - OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, (PEAOP2) NULL); + rc = DosOpen("/dev/pmap$", &hfd, &action, 0, FILE_NORMAL, FILE_OPEN, + OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, (PEAOP2) NULL); if (rc != 0) return NULL; { @@ -509,9 +508,9 @@ pmap.a.phys = offset; pmap.size = size + delta; - rc = DosDevIOCtl (hfd, XFREE86_PMAP, PMAP_MAP, - (PULONG) & pmap, sizeof (pmap), &plen, - (PULONG) & dmap, sizeof (dmap), &dlen); + rc = DosDevIOCtl(hfd, XFREE86_PMAP, PMAP_MAP, + (PULONG) & pmap, sizeof(pmap), &plen, + (PULONG) & dmap, sizeof(dmap), &dlen); if (rc == 0) { vaddr = dmap.a.user; } @@ -519,24 +518,24 @@ if (rc != 0) return NULL; #elif defined (Lynx) - vaddr = (void *) smem_create ("XF86DGA", (char *) offset, - size + delta, SM_READ | SM_WRITE); + vaddr = (void *) smem_create("XF86DGA", (char *) offset, + size + delta, SM_READ | SM_WRITE); #else #ifndef MAP_FILE #define MAP_FILE 0 #endif if (mapFd < 0) { - if ((mapFd = open (DEV_MEM, O_RDWR)) < 0) + if ((mapFd = open(DEV_MEM, O_RDWR)) < 0) return NULL; } - vaddr = (void *) mmap (NULL, size + delta, PROT_READ | PROT_WRITE, - MAP_FILE | MAP_SHARED, mapFd, (off_t) offset); + vaddr = (void *) mmap(NULL, size + delta, PROT_READ | PROT_WRITE, + MAP_FILE | MAP_SHARED, mapFd, (off_t) offset); if (vaddr == (void *) -1) return NULL; #endif if (!vaddr) { - if (!(mp = AddMap ())) + if (!(mp = AddMap())) return NULL; mp->physaddr = address; mp->size = size; @@ -554,125 +553,124 @@ * should restore text mode. */ -int SDL_NAME (XF86DGAForkApp) (int screen) +int SDL_NAME(XF86DGAForkApp) (int screen) { pid_t pid; int status; int i; /* fork the app, parent hangs around to clean up */ - if ((pid = fork ()) > 0) { + if ((pid = fork()) > 0) { ScrPtr sp; - waitpid (pid, &status, 0); + waitpid(pid, &status, 0); for (i = 0; i < numScrs; i++) { sp = scrList[i]; - SDL_NAME (XF86DGADirectVideoLL) (sp->display, sp->screen, 0); - XSync (sp->display, False); + SDL_NAME(XF86DGADirectVideoLL) (sp->display, sp->screen, 0); + XSync(sp->display, False); } - if (WIFEXITED (status)) - _exit (0); + if (WIFEXITED(status)) + _exit(0); else - _exit (-1); + _exit(-1); } return pid; } -Bool SDL_NAME (XF86DGADirectVideo) (Display * dis, int screen, int enable) +Bool SDL_NAME(XF86DGADirectVideo) (Display * dis, int screen, int enable) { ScrPtr sp; MapPtr mp = NULL; - if ((sp = FindScr (dis, screen))) + if ((sp = FindScr(dis, screen))) mp = sp->map; if (enable & XF86DGADirectGraphics) { #if !defined(ISC) && !defined(HAS_SVR3_MMAP) && !defined(Lynx) \ && !defined(__EMX__) if (mp && mp->vaddr) - mprotect (mp->vaddr, mp->size + mp->delta, - PROT_READ | PROT_WRITE); + mprotect(mp->vaddr, mp->size + mp->delta, PROT_READ | PROT_WRITE); #endif } else { #if !defined(ISC) && !defined(HAS_SVR3_MMAP) && !defined(Lynx) \ && !defined(__EMX__) if (mp && mp->vaddr) - mprotect (mp->vaddr, mp->size + mp->delta, PROT_READ); + mprotect(mp->vaddr, mp->size + mp->delta, PROT_READ); #elif defined(Lynx) /* XXX this doesn't allow enable after disable */ - smem_create (NULL, mp->vaddr, mp->size + mp->delta, SM_DETACH); - smem_remove ("XF86DGA"); + smem_create(NULL, mp->vaddr, mp->size + mp->delta, SM_DETACH); + smem_remove("XF86DGA"); #endif } - SDL_NAME (XF86DGADirectVideoLL) (dis, screen, enable); + SDL_NAME(XF86DGADirectVideoLL) (dis, screen, enable); return 1; } static void -XF86cleanup (int sig) +XF86cleanup(int sig) { ScrPtr sp; int i; static char beenhere = 0; if (beenhere) - _exit (3); + _exit(3); beenhere = 1; for (i = 0; i < numScrs; i++) { sp = scrList[i]; - SDL_NAME (XF86DGADirectVideo) (sp->display, sp->screen, 0); - XSync (sp->display, False); + SDL_NAME(XF86DGADirectVideo) (sp->display, sp->screen, 0); + XSync(sp->display, False); } - _exit (3); + _exit(3); } Bool -SDL_NAME (XF86DGAGetVideo) (Display * dis, - int screen, - char **addr, int *width, int *bank, int *ram) +SDL_NAME(XF86DGAGetVideo) (Display * dis, + int screen, + char **addr, int *width, int *bank, int *ram) { /*unsigned long */ int offset; static int beenHere = 0; ScrPtr sp; MapPtr mp; - if (!(sp = FindScr (dis, screen))) { - if (!(sp = AddScr ())) { - fprintf (stderr, "XF86DGAGetVideo: malloc failure\n"); - exit (-2); + if (!(sp = FindScr(dis, screen))) { + if (!(sp = AddScr())) { + fprintf(stderr, "XF86DGAGetVideo: malloc failure\n"); + exit(-2); } sp->display = dis; sp->screen = screen; sp->map = NULL; } - SDL_NAME (XF86DGAGetVideoLL) (dis, screen, &offset, width, bank, ram); + SDL_NAME(XF86DGAGetVideoLL) (dis, screen, &offset, width, bank, ram); - *addr = MapPhysAddress (offset, *bank); + *addr = MapPhysAddress(offset, *bank); if (*addr == NULL) { - fprintf (stderr, - "XF86DGAGetVideo: failed to map video memory (%s)\n", - strerror (errno)); - exit (-2); + fprintf(stderr, + "XF86DGAGetVideo: failed to map video memory (%s)\n", + strerror(errno)); + exit(-2); } - if ((mp = FindMap (offset, *bank))) + if ((mp = FindMap(offset, *bank))) sp->map = mp; if (!beenHere) { beenHere = 1; - atexit ((void (*)(void)) XF86cleanup); + atexit((void (*)(void)) XF86cleanup); /* one shot XF86cleanup attempts */ - signal (SIGSEGV, XF86cleanup); + signal(SIGSEGV, XF86cleanup); #ifdef SIGBUS - signal (SIGBUS, XF86cleanup); + signal(SIGBUS, XF86cleanup); #endif - signal (SIGHUP, XF86cleanup); - signal (SIGFPE, XF86cleanup); + signal(SIGHUP, XF86cleanup); + signal(SIGFPE, XF86cleanup); } return 1; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/Xext/Xxf86dga/XF86DGA2.c --- a/src/video/Xext/Xxf86dga/XF86DGA2.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/Xext/Xxf86dga/XF86DGA2.c Mon May 29 04:04:35 2006 +0000 @@ -32,16 +32,16 @@ /* If you change this, change the Bases[] array below as well */ #define MAX_HEADS 16 -char *SDL_NAME (xdga_extension_name) = XF86DGANAME; +char *SDL_NAME(xdga_extension_name) = XF86DGANAME; static XExtensionInfo _xdga_info_data; static XExtensionInfo *xdga_info = &_xdga_info_data; -Bool SDL_NAME (XDGAMapFramebuffer) (int, char *, unsigned char *, CARD32, - CARD32, CARD32); -void SDL_NAME (XDGAUnmapFramebuffer) (int); -unsigned char *SDL_NAME (XDGAGetMappedMemory) (int); +Bool SDL_NAME(XDGAMapFramebuffer) (int, char *, unsigned char *, CARD32, + CARD32, CARD32); +void SDL_NAME(XDGAUnmapFramebuffer) (int); +unsigned char *SDL_NAME(XDGAGetMappedMemory) (int); #define XDGACheckExtension(dpy,i,val) \ XextCheckExtension (dpy, i, SDL_NAME(xdga_extension_name), val) @@ -52,11 +52,11 @@ * * *****************************************************************************/ -static int xdga_close_display (Display * dpy, XExtCodes * codes); -static Bool xdga_wire_to_event (Display * dpy, XEvent * event, - xEvent * wire_ev); -static Status xdga_event_to_wire (Display * dpy, XEvent * event, - xEvent * wire_ev); +static int xdga_close_display(Display * dpy, XExtCodes * codes); +static Bool xdga_wire_to_event(Display * dpy, XEvent * event, + xEvent * wire_ev); +static Status xdga_event_to_wire(Display * dpy, XEvent * event, + xEvent * wire_ev); static XExtensionHooks xdga_extension_hooks = { NULL, /* create_gc */ @@ -73,31 +73,31 @@ }; static -XEXT_GENERATE_CLOSE_DISPLAY (xdga_close_display, xdga_info) -XEXT_GENERATE_FIND_DISPLAY (SDL_NAME (xdga_find_display), xdga_info, - "XFree86-DGA", &xdga_extension_hooks, 0, NULL) +XEXT_GENERATE_CLOSE_DISPLAY(xdga_close_display, xdga_info) +XEXT_GENERATE_FIND_DISPLAY(SDL_NAME(xdga_find_display), xdga_info, + "XFree86-DGA", &xdga_extension_hooks, 0, NULL) static Status - xdga_event_to_wire (Display * dpy, XEvent * event, xEvent * wire_ev) + xdga_event_to_wire(Display * dpy, XEvent * event, xEvent * wire_ev) { return True; } static Bool -xdga_wire_to_event (Display * dpy, XEvent * event, xEvent * wire_ev) +xdga_wire_to_event(Display * dpy, XEvent * event, xEvent * wire_ev) { dgaEvent *wire = (dgaEvent *) wire_ev; - SDL_NAME (XDGAButtonEvent) * bevent; - SDL_NAME (XDGAKeyEvent) * kevent; - SDL_NAME (XDGAMotionEvent) * mevent; - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + SDL_NAME(XDGAButtonEvent) * bevent; + SDL_NAME(XDGAKeyEvent) * kevent; + SDL_NAME(XDGAMotionEvent) * mevent; + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); - XDGACheckExtension (dpy, info, False); + XDGACheckExtension(dpy, info, False); switch ((wire->u.u.type & 0x7f) - info->codes->first_event) { case MotionNotify: - mevent = (SDL_NAME (XDGAMotionEvent) *) event; + mevent = (SDL_NAME(XDGAMotionEvent) *) event; mevent->type = wire->u.u.type & 0x7F; - mevent->serial = _XSetLastRequestRead (dpy, (xGenericReply *) wire); + mevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); mevent->display = dpy; mevent->screen = wire->u.event.screen; mevent->time = wire->u.event.time; @@ -107,9 +107,9 @@ return True; case ButtonPress: case ButtonRelease: - bevent = (SDL_NAME (XDGAButtonEvent) *) event; + bevent = (SDL_NAME(XDGAButtonEvent) *) event; bevent->type = wire->u.u.type & 0x7F; - bevent->serial = _XSetLastRequestRead (dpy, (xGenericReply *) wire); + bevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); bevent->display = dpy; bevent->screen = wire->u.event.screen; bevent->time = wire->u.event.time; @@ -118,9 +118,9 @@ return True; case KeyPress: case KeyRelease: - kevent = (SDL_NAME (XDGAKeyEvent) *) event; + kevent = (SDL_NAME(XDGAKeyEvent) *) event; kevent->type = wire->u.u.type & 0x7F; - kevent->serial = _XSetLastRequestRead (dpy, (xGenericReply *) wire); + kevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); kevent->display = dpy; kevent->screen = wire->u.event.screen; kevent->time = wire->u.event.time; @@ -133,12 +133,12 @@ } -Bool SDL_NAME (XDGAQueryExtension) (Display * dpy, - int *event_basep, int *error_basep) +Bool SDL_NAME(XDGAQueryExtension) (Display * dpy, + int *event_basep, int *error_basep) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); - if (XextHasExtension (info)) { + if (XextHasExtension(info)) { *event_basep = info->codes->first_event; *error_basep = info->codes->first_error; return True; @@ -148,136 +148,136 @@ } -Bool SDL_NAME (XDGAQueryVersion) (Display * dpy, - int *majorVersion, int *minorVersion) +Bool SDL_NAME(XDGAQueryVersion) (Display * dpy, + int *majorVersion, int *minorVersion) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXDGAQueryVersionReply rep; xXDGAQueryVersionReq *req; - XDGACheckExtension (dpy, info, False); + XDGACheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XDGAQueryVersion, req); + LockDisplay(dpy); + GetReq(XDGAQueryVersion, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XDGAQueryVersion; - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } *majorVersion = rep.majorVersion; *minorVersion = rep.minorVersion; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); if (*majorVersion >= 2) { int i, j; for (i = 0, j = info->codes->first_event; i < XF86DGANumberEvents; i++, j++) { - XESetWireToEvent (dpy, j, xdga_wire_to_event); - XESetEventToWire (dpy, j, xdga_event_to_wire); + XESetWireToEvent(dpy, j, xdga_wire_to_event); + XESetEventToWire(dpy, j, xdga_event_to_wire); } - SDL_NAME (XDGASetClientVersion) (dpy); + SDL_NAME(XDGASetClientVersion) (dpy); } return True; } -Bool SDL_NAME (XDGASetClientVersion) (Display * dpy) +Bool SDL_NAME(XDGASetClientVersion) (Display * dpy) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXDGASetClientVersionReq *req; - XDGACheckExtension (dpy, info, False); + XDGACheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XDGASetClientVersion, req); + LockDisplay(dpy); + GetReq(XDGASetClientVersion, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XDGASetClientVersion; req->major = XDGA_MAJOR_VERSION; req->minor = XDGA_MINOR_VERSION; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } -Bool SDL_NAME (XDGAOpenFramebuffer) (Display * dpy, int screen) +Bool SDL_NAME(XDGAOpenFramebuffer) (Display * dpy, int screen) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXDGAOpenFramebufferReply rep; xXDGAOpenFramebufferReq *req; char *deviceName = NULL; Bool ret; - XDGACheckExtension (dpy, info, False); + XDGACheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XDGAOpenFramebuffer, req); + LockDisplay(dpy); + GetReq(XDGAOpenFramebuffer, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XDGAOpenFramebuffer; req->screen = screen; - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } if (rep.length) { - deviceName = Xmalloc (rep.length << 2); - _XRead (dpy, deviceName, rep.length << 2); + deviceName = Xmalloc(rep.length << 2); + _XRead(dpy, deviceName, rep.length << 2); } - ret = SDL_NAME (XDGAMapFramebuffer) (screen, deviceName, - (unsigned char *) (long) rep.mem1, - rep.size, rep.offset, rep.extra); + ret = SDL_NAME(XDGAMapFramebuffer) (screen, deviceName, + (unsigned char *) (long) rep.mem1, + rep.size, rep.offset, rep.extra); if (deviceName) - Xfree (deviceName); + Xfree(deviceName); - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return ret; } -void SDL_NAME (XDGACloseFramebuffer) (Display * dpy, int screen) +void SDL_NAME(XDGACloseFramebuffer) (Display * dpy, int screen) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXDGACloseFramebufferReq *req; - XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); + XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); - SDL_NAME (XDGAUnmapFramebuffer) (screen); + SDL_NAME(XDGAUnmapFramebuffer) (screen); - LockDisplay (dpy); - GetReq (XDGACloseFramebuffer, req); + LockDisplay(dpy); + GetReq(XDGACloseFramebuffer, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XDGACloseFramebuffer; req->screen = screen; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); } -SDL_NAME (XDGAMode) * SDL_NAME (XDGAQueryModes) (Display * dpy, - int screen, int *num) +SDL_NAME(XDGAMode) * SDL_NAME(XDGAQueryModes) (Display * dpy, + int screen, int *num) { - XExtDisplayInfo *dinfo = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *dinfo = SDL_NAME(xdga_find_display) (dpy); xXDGAQueryModesReply rep; xXDGAQueryModesReq *req; - SDL_NAME (XDGAMode) * modes = NULL; + SDL_NAME(XDGAMode) * modes = NULL; *num = 0; - XDGACheckExtension (dpy, dinfo, NULL); + XDGACheckExtension(dpy, dinfo, NULL); - LockDisplay (dpy); - GetReq (XDGAQueryModes, req); + LockDisplay(dpy); + GetReq(XDGAQueryModes, req); req->reqType = dinfo->codes->major_opcode; req->dgaReqType = X_XDGAQueryModes; req->screen = screen; - if (_XReply (dpy, (xReply *) & rep, 0, xFalse)) { + if (_XReply(dpy, (xReply *) & rep, 0, xFalse)) { if (rep.length) { xXDGAModeInfo info; int i, size; @@ -285,14 +285,14 @@ size = rep.length << 2; size -= rep.number * sz_xXDGAModeInfo; /* find text size */ - modes = (SDL_NAME (XDGAMode) *) - Xmalloc ((rep.number * sizeof (SDL_NAME (XDGAMode))) + size); + modes = (SDL_NAME(XDGAMode) *) + Xmalloc((rep.number * sizeof(SDL_NAME(XDGAMode))) + size); offset = (char *) (&modes[rep.number]); /* start of text */ if (modes) { for (i = 0; i < rep.number; i++) { - _XRead (dpy, (char *) (&info), sz_xXDGAModeInfo); + _XRead(dpy, (char *) (&info), sz_xXDGAModeInfo); modes[i].num = info.num; modes[i].verticalRefresh = @@ -320,43 +320,43 @@ modes[i].reserved1 = info.reserved1; modes[i].reserved2 = info.reserved2; - _XRead (dpy, offset, info.name_size); + _XRead(dpy, offset, info.name_size); modes[i].name = offset; offset += info.name_size; } *num = rep.number; } else - _XEatData (dpy, rep.length << 2); + _XEatData(dpy, rep.length << 2); } } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return modes; } -SDL_NAME (XDGADevice) * -SDL_NAME (XDGASetMode) (Display * dpy, int screen, int mode) +SDL_NAME(XDGADevice) * +SDL_NAME(XDGASetMode) (Display * dpy, int screen, int mode) { - XExtDisplayInfo *dinfo = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *dinfo = SDL_NAME(xdga_find_display) (dpy); xXDGASetModeReply rep; xXDGASetModeReq *req; - SDL_NAME (XDGADevice) * dev = NULL; + SDL_NAME(XDGADevice) * dev = NULL; Pixmap pid; - XDGACheckExtension (dpy, dinfo, NULL); + XDGACheckExtension(dpy, dinfo, NULL); - LockDisplay (dpy); - GetReq (XDGASetMode, req); + LockDisplay(dpy); + GetReq(XDGASetMode, req); req->reqType = dinfo->codes->major_opcode; req->dgaReqType = X_XDGASetMode; req->screen = screen; req->mode = mode; - req->pid = pid = XAllocID (dpy); + req->pid = pid = XAllocID(dpy); - if (_XReply (dpy, (xReply *) & rep, 0, xFalse)) { + if (_XReply(dpy, (xReply *) & rep, 0, xFalse)) { if (rep.length) { xXDGAModeInfo info; int size; @@ -364,11 +364,11 @@ size = rep.length << 2; size -= sz_xXDGAModeInfo; /* get text size */ - dev = (SDL_NAME (XDGADevice) *) - Xmalloc (sizeof (SDL_NAME (XDGADevice)) + size); + dev = (SDL_NAME(XDGADevice) *) + Xmalloc(sizeof(SDL_NAME(XDGADevice)) + size); if (dev) { - _XRead (dpy, (char *) (&info), sz_xXDGAModeInfo); + _XRead(dpy, (char *) (&info), sz_xXDGAModeInfo); dev->mode.num = info.num; dev->mode.verticalRefresh = @@ -397,10 +397,10 @@ dev->mode.reserved2 = info.reserved2; dev->mode.name = (char *) (&dev[1]); - _XRead (dpy, dev->mode.name, info.name_size); + _XRead(dpy, dev->mode.name, info.name_size); dev->pixmap = (rep.flags & XDGAPixmap) ? pid : 0; - dev->data = SDL_NAME (XDGAGetMappedMemory) (screen); + dev->data = SDL_NAME(XDGAGetMappedMemory) (screen); if (dev->data) dev->data += rep.offset; @@ -409,82 +409,82 @@ } } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return dev; } -void SDL_NAME (XDGASetViewport) (Display * dpy, - int screen, int x, int y, int flags) +void SDL_NAME(XDGASetViewport) (Display * dpy, + int screen, int x, int y, int flags) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXDGASetViewportReq *req; - XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); + XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); - LockDisplay (dpy); - GetReq (XDGASetViewport, req); + LockDisplay(dpy); + GetReq(XDGASetViewport, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XDGASetViewport; req->screen = screen; req->x = x; req->y = y; req->flags = flags; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); } -void SDL_NAME (XDGAInstallColormap) (Display * dpy, int screen, Colormap cmap) +void SDL_NAME(XDGAInstallColormap) (Display * dpy, int screen, Colormap cmap) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXDGAInstallColormapReq *req; - XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); + XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); - LockDisplay (dpy); - GetReq (XDGAInstallColormap, req); + LockDisplay(dpy); + GetReq(XDGAInstallColormap, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XDGAInstallColormap; req->screen = screen; req->cmap = cmap; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); } -void SDL_NAME (XDGASelectInput) (Display * dpy, int screen, long mask) +void SDL_NAME(XDGASelectInput) (Display * dpy, int screen, long mask) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXDGASelectInputReq *req; - XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); + XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); - LockDisplay (dpy); - GetReq (XDGASelectInput, req); + LockDisplay(dpy); + GetReq(XDGASelectInput, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XDGASelectInput; req->screen = screen; req->mask = mask; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); } -void SDL_NAME (XDGAFillRectangle) (Display * dpy, - int screen, - int x, - int y, - unsigned int width, - unsigned int height, unsigned long color) +void SDL_NAME(XDGAFillRectangle) (Display * dpy, + int screen, + int x, + int y, + unsigned int width, + unsigned int height, unsigned long color) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXDGAFillRectangleReq *req; - XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); + XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); - LockDisplay (dpy); - GetReq (XDGAFillRectangle, req); + LockDisplay(dpy); + GetReq(XDGAFillRectangle, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XDGAFillRectangle; req->screen = screen; @@ -493,24 +493,24 @@ req->width = width; req->height = height; req->color = color; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); } -void SDL_NAME (XDGACopyArea) (Display * dpy, - int screen, - int srcx, - int srcy, - unsigned int width, - unsigned int height, int dstx, int dsty) +void SDL_NAME(XDGACopyArea) (Display * dpy, + int screen, + int srcx, + int srcy, + unsigned int width, + unsigned int height, int dstx, int dsty) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXDGACopyAreaReq *req; - XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); + XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); - LockDisplay (dpy); - GetReq (XDGACopyArea, req); + LockDisplay(dpy); + GetReq(XDGACopyArea, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XDGACopyArea; req->screen = screen; @@ -520,26 +520,25 @@ req->height = height; req->dstx = dstx; req->dsty = dsty; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); } -void SDL_NAME (XDGACopyTransparentArea) (Display * dpy, - int screen, - int srcx, - int srcy, - unsigned int width, - unsigned int height, - int dstx, - int dsty, unsigned long key) +void SDL_NAME(XDGACopyTransparentArea) (Display * dpy, + int screen, + int srcx, + int srcy, + unsigned int width, + unsigned int height, + int dstx, int dsty, unsigned long key) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXDGACopyTransparentAreaReq *req; - XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); + XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); - LockDisplay (dpy); - GetReq (XDGACopyTransparentArea, req); + LockDisplay(dpy); + GetReq(XDGACopyTransparentArea, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XDGACopyTransparentArea; req->screen = screen; @@ -550,109 +549,108 @@ req->dstx = dstx; req->dsty = dsty; req->key = key; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); } -int SDL_NAME (XDGAGetViewportStatus) (Display * dpy, int screen) +int SDL_NAME(XDGAGetViewportStatus) (Display * dpy, int screen) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXDGAGetViewportStatusReply rep; xXDGAGetViewportStatusReq *req; int status = 0; - XDGACheckExtension (dpy, info, 0); + XDGACheckExtension(dpy, info, 0); - LockDisplay (dpy); - GetReq (XDGAGetViewportStatus, req); + LockDisplay(dpy); + GetReq(XDGAGetViewportStatus, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XDGAGetViewportStatus; req->screen = screen; - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) status = rep.status; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return status; } -void SDL_NAME (XDGASync) (Display * dpy, int screen) +void SDL_NAME(XDGASync) (Display * dpy, int screen) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXDGASyncReply rep; xXDGASyncReq *req; - XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); + XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); - LockDisplay (dpy); - GetReq (XDGASync, req); + LockDisplay(dpy); + GetReq(XDGASync, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XDGASync; req->screen = screen; - _XReply (dpy, (xReply *) & rep, 0, xFalse); - UnlockDisplay (dpy); - SyncHandle (); + _XReply(dpy, (xReply *) & rep, 0, xFalse); + UnlockDisplay(dpy); + SyncHandle(); } -void SDL_NAME (XDGAChangePixmapMode) (Display * dpy, - int screen, int *x, int *y, int mode) +void SDL_NAME(XDGAChangePixmapMode) (Display * dpy, + int screen, int *x, int *y, int mode) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXDGAChangePixmapModeReq *req; xXDGAChangePixmapModeReply rep; - XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); + XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); - LockDisplay (dpy); - GetReq (XDGAChangePixmapMode, req); + LockDisplay(dpy); + GetReq(XDGAChangePixmapMode, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XDGAChangePixmapMode; req->screen = screen; req->x = *x; req->y = *y; req->flags = mode; - _XReply (dpy, (xReply *) & rep, 0, xFalse); + _XReply(dpy, (xReply *) & rep, 0, xFalse); *x = rep.x; *y = rep.y; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); } -Colormap SDL_NAME (XDGACreateColormap) (Display * dpy, - int screen, - SDL_NAME (XDGADevice) * dev, - int alloc) +Colormap SDL_NAME(XDGACreateColormap) (Display * dpy, + int screen, + SDL_NAME(XDGADevice) * dev, int alloc) { - XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); + XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXDGACreateColormapReq *req; Colormap cid; - XDGACheckExtension (dpy, info, -1); + XDGACheckExtension(dpy, info, -1); - LockDisplay (dpy); - GetReq (XDGACreateColormap, req); + LockDisplay(dpy); + GetReq(XDGACreateColormap, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XDGACreateColormap; req->screen = screen; req->mode = dev->mode.num; req->alloc = alloc; - cid = req->id = XAllocID (dpy); - UnlockDisplay (dpy); - SyncHandle (); + cid = req->id = XAllocID(dpy); + UnlockDisplay(dpy); + SyncHandle(); return cid; } -void SDL_NAME (XDGAKeyEventToXKeyEvent) (SDL_NAME (XDGAKeyEvent) * dk, - XKeyEvent * xk) +void SDL_NAME(XDGAKeyEventToXKeyEvent) (SDL_NAME(XDGAKeyEvent) * dk, + XKeyEvent * xk) { xk->type = dk->type; xk->serial = dk->serial; xk->send_event = False; xk->display = dk->display; - xk->window = RootWindow (dk->display, dk->screen); + xk->window = RootWindow(dk->display, dk->screen); xk->root = xk->window; xk->subwindow = None; xk->time = dk->time; @@ -715,14 +713,14 @@ } DGAMapRec, *DGAMapPtr; static Bool -DGAMapPhysical (int, char *, unsigned char *, CARD32, CARD32, CARD32, - DGAMapPtr); -static void DGAUnmapPhysical (DGAMapPtr); +DGAMapPhysical(int, char *, unsigned char *, CARD32, CARD32, CARD32, + DGAMapPtr); +static void DGAUnmapPhysical(DGAMapPtr); static DGAMapPtr _Maps = NULL; -unsigned char *SDL_NAME (XDGAGetMappedMemory) (int screen) +unsigned char *SDL_NAME(XDGAGetMappedMemory) (int screen) { DGAMapPtr pMap = _Maps; unsigned char *pntr = NULL; @@ -738,11 +736,11 @@ return pntr; } -Bool SDL_NAME (XDGAMapFramebuffer) (int screen, char *name, /* optional device name */ - unsigned char *base, /* physical memory */ - CARD32 size, /* size */ - CARD32 offset, /* optional offset */ - CARD32 extra /* optional extra data */ +Bool SDL_NAME(XDGAMapFramebuffer) (int screen, char *name, /* optional device name */ + unsigned char *base, /* physical memory */ + CARD32 size, /* size */ + CARD32 offset, /* optional offset */ + CARD32 extra /* optional extra data */ ) { DGAMapPtr pMap = _Maps; @@ -761,20 +759,20 @@ } - pMap = (DGAMapPtr) Xmalloc (sizeof (DGAMapRec)); + pMap = (DGAMapPtr) Xmalloc(sizeof(DGAMapRec)); - result = DGAMapPhysical (screen, name, base, size, offset, extra, pMap); + result = DGAMapPhysical(screen, name, base, size, offset, extra, pMap); if (result) { pMap->next = _Maps; _Maps = pMap; } else - Xfree (pMap); + Xfree(pMap); return result; } -void SDL_NAME (XDGAUnmapFramebuffer) (int screen) +void SDL_NAME(XDGAUnmapFramebuffer) (int screen) { DGAMapPtr pMap = _Maps; DGAMapPtr pPrev = NULL; @@ -790,24 +788,24 @@ if (!pMap) return; - DGAUnmapPhysical (pMap); + DGAUnmapPhysical(pMap); if (!pPrev) _Maps = pMap->next; else pPrev->next = pMap->next; - Xfree (pMap); + Xfree(pMap); } static Bool -DGAMapPhysical (int screen, char *name, /* optional device name */ - unsigned char *base, /* physical memory */ - CARD32 size, /* size */ - CARD32 offset, /* optional offset */ - CARD32 extra, /* optional extra data */ - DGAMapPtr pMap) +DGAMapPhysical(int screen, char *name, /* optional device name */ + unsigned char *base, /* physical memory */ + CARD32 size, /* size */ + CARD32 offset, /* optional offset */ + CARD32 extra, /* optional extra data */ + DGAMapPtr pMap) { #if defined(ISC) && defined(HAS_SVR3_MMAP) struct kd_memloc mloc; @@ -824,15 +822,14 @@ pMap->size = size; #if defined(ISC) && defined(HAS_SVR3_MMAP) - if ((pMap->fd = open ("/dev/mmap", O_RDWR)) < 0) + if ((pMap->fd = open("/dev/mmap", O_RDWR)) < 0) return False; mloc.vaddr = (char *) 0; mloc.physaddr = (char *) base; mloc.length = size; mloc.ioflg = 1; - if ((pMap->virtual = - (void *) ioctl (pMap->fd, MAP, &mloc)) == (void *) -1) + if ((pMap->virtual = (void *) ioctl(pMap->fd, MAP, &mloc)) == (void *) -1) return False; #elif defined (__EMX__) /* @@ -841,8 +838,8 @@ * of memory handles. Some umap/close mechanism should be provided */ - rc = DosOpen ("/dev/pmap$", &hfd, &action, 0, FILE_NORMAL, FILE_OPEN, - OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, (PEAOP2) NULL); + rc = DosOpen("/dev/pmap$", &hfd, &action, 0, FILE_NORMAL, FILE_OPEN, + OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, (PEAOP2) NULL); if (rc != 0) return False; { @@ -861,9 +858,9 @@ pmap.a.phys = base; pmap.size = size; - rc = DosDevIOCtl (hfd, XFREE86_PMAP, PMAP_MAP, - (PULONG) & pmap, sizeof (pmap), &plen, - (PULONG) & dmap, sizeof (dmap), &dlen); + rc = DosDevIOCtl(hfd, XFREE86_PMAP, PMAP_MAP, + (PULONG) & pmap, sizeof(pmap), &plen, + (PULONG) & dmap, sizeof(dmap), &dlen); if (rc == 0) { pMap->virtual = dmap.a.user; } @@ -872,27 +869,27 @@ return False; #elif defined (Lynx) pMap->virtual = - smem_create ("XF86DGA", (char *) base, size, SM_READ | SM_WRITE); + smem_create("XF86DGA", (char *) base, size, SM_READ | SM_WRITE); #else #ifndef MAP_FILE #define MAP_FILE 0 #endif if (!name) name = DEV_MEM; - if ((pMap->fd = open (name, O_RDWR)) < 0) + if ((pMap->fd = open(name, O_RDWR)) < 0) #if defined(ENABLE_FBCON) { /* /dev/fb0 fallback added by Sam Lantinga */ /* Try to fall back to /dev/fb on Linux - FIXME: verify the device */ struct fb_fix_screeninfo finfo; - if ((pMap->fd = open ("/dev/fb0", O_RDWR)) < 0) { + if ((pMap->fd = open("/dev/fb0", O_RDWR)) < 0) { return False; } /* The useable framebuffer console memory may not be the whole framebuffer that X has access to. :-( */ - if (ioctl (pMap->fd, FBIOGET_FSCREENINFO, &finfo) < 0) { - close (pMap->fd); + if (ioctl(pMap->fd, FBIOGET_FSCREENINFO, &finfo) < 0) { + close(pMap->fd); return False; } /* Warning: On PPC, the size and virtual need to be offset by: @@ -905,15 +902,15 @@ #else return False; #endif - pMap->virtual = mmap (NULL, size, PROT_READ | PROT_WRITE, - MAP_FILE | MAP_SHARED, pMap->fd, (off_t) base); + pMap->virtual = mmap(NULL, size, PROT_READ | PROT_WRITE, + MAP_FILE | MAP_SHARED, pMap->fd, (off_t) base); if (pMap->virtual == (void *) -1) return False; #endif #if !defined(ISC) && !defined(HAS_SVR3_MMAP) && !defined(Lynx) \ && !defined(__EMX__) - mprotect (pMap->virtual, size, PROT_READ | PROT_WRITE); + mprotect(pMap->virtual, size, PROT_READ | PROT_WRITE); #endif return True; @@ -922,15 +919,15 @@ static void -DGAUnmapPhysical (DGAMapPtr pMap) +DGAUnmapPhysical(DGAMapPtr pMap) { #if !defined(ISC) && !defined(HAS_SVR3_MMAP) && !defined(Lynx) \ && !defined(__EMX__) - mprotect (pMap->virtual, pMap->size, PROT_READ); + mprotect(pMap->virtual, pMap->size, PROT_READ); #elif defined(Lynx) /* XXX this doesn't allow enable after disable */ - smem_create (NULL, pMap->virtual, pMap->size, SM_DETACH); - smem_remove ("XF86DGA"); + smem_create(NULL, pMap->virtual, pMap->size, SM_DETACH); + smem_remove("XF86DGA"); #endif diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/Xext/Xxf86vm/XF86VMode.c --- a/src/video/Xext/Xxf86vm/XF86VMode.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/Xext/Xxf86vm/XF86VMode.c Mon May 29 04:04:35 2006 +0000 @@ -69,7 +69,7 @@ * * *****************************************************************************/ -static XEXT_CLOSE_DISPLAY_PROTO (close_display); +static XEXT_CLOSE_DISPLAY_PROTO(close_display); static /* const */ XExtensionHooks xf86vidmode_extension_hooks = { NULL, /* create_gc */ NULL, /* copy_gc */ @@ -85,23 +85,23 @@ }; static -XEXT_GENERATE_FIND_DISPLAY (find_display, xf86vidmode_info, - xf86vidmode_extension_name, - &xf86vidmode_extension_hooks, 0, NULL) - static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86vidmode_info) +XEXT_GENERATE_FIND_DISPLAY(find_display, xf86vidmode_info, + xf86vidmode_extension_name, + &xf86vidmode_extension_hooks, 0, NULL) + static XEXT_GENERATE_CLOSE_DISPLAY(close_display, xf86vidmode_info) /***************************************************************************** * * * public XFree86-VidMode Extension routines * * * *****************************************************************************/ Bool -SDL_NAME (XF86VidModeQueryExtension) (dpy, event_basep, error_basep) +SDL_NAME(XF86VidModeQueryExtension) (dpy, event_basep, error_basep) Display *dpy; int *event_basep, *error_basep; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); - if (XextHasExtension (info)) { + if (XextHasExtension(info)) { *event_basep = info->codes->first_event; *error_basep = info->codes->first_error; return True; @@ -110,7 +110,7 @@ } } -Bool SDL_NAME (XF86VidModeQueryVersion) (dpy, majorVersion, minorVersion) +Bool SDL_NAME(XF86VidModeQueryVersion) (dpy, majorVersion, minorVersion) Display * dpy; int * @@ -118,128 +118,128 @@ int * minorVersion; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeQueryVersionReply rep; xXF86VidModeQueryVersionReq *req; - XF86VidModeCheckExtension (dpy, info, False); + XF86VidModeCheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86VidModeQueryVersion, req); + LockDisplay(dpy); + GetReq(XF86VidModeQueryVersion, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeQueryVersion; - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } *majorVersion = rep.majorVersion; *minorVersion = rep.minorVersion; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); if (*majorVersion >= 2) - SDL_NAME (XF86VidModeSetClientVersion) (dpy); + SDL_NAME(XF86VidModeSetClientVersion) (dpy); return True; } -Bool SDL_NAME (XF86VidModeSetClientVersion) (Display * dpy) +Bool SDL_NAME(XF86VidModeSetClientVersion) (Display * dpy) { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeSetClientVersionReq *req; - XF86VidModeCheckExtension (dpy, info, False); + XF86VidModeCheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86VidModeSetClientVersion, req); + LockDisplay(dpy); + GetReq(XF86VidModeSetClientVersion, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeSetClientVersion; req->major = XF86VIDMODE_MAJOR_VERSION; req->minor = XF86VIDMODE_MINOR_VERSION; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } Bool -SDL_NAME (XF86VidModeSetGamma) (Display * dpy, int screen, - SDL_NAME (XF86VidModeGamma) * Gamma) +SDL_NAME(XF86VidModeSetGamma) (Display * dpy, int screen, + SDL_NAME(XF86VidModeGamma) * Gamma) { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeSetGammaReq *req; - XF86VidModeCheckExtension (dpy, info, False); + XF86VidModeCheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86VidModeSetGamma, req); + LockDisplay(dpy); + GetReq(XF86VidModeSetGamma, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeSetGamma; req->screen = screen; req->red = (CARD32) (Gamma->red * 10000.); req->green = (CARD32) (Gamma->green * 10000.); req->blue = (CARD32) (Gamma->blue * 10000.); - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } Bool -SDL_NAME (XF86VidModeGetGamma) (Display * dpy, int screen, - SDL_NAME (XF86VidModeGamma) * Gamma) +SDL_NAME(XF86VidModeGetGamma) (Display * dpy, int screen, + SDL_NAME(XF86VidModeGamma) * Gamma) { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeGetGammaReply rep; xXF86VidModeGetGammaReq *req; - XF86VidModeCheckExtension (dpy, info, False); + XF86VidModeCheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86VidModeGetGamma, req); + LockDisplay(dpy); + GetReq(XF86VidModeGetGamma, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetGamma; req->screen = screen; - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } Gamma->red = ((float) rep.red) / 10000.; Gamma->green = ((float) rep.green) / 10000.; Gamma->blue = ((float) rep.blue) / 10000.; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } -Bool SDL_NAME (XF86VidModeGetModeLine) (dpy, screen, dotclock, modeline) +Bool SDL_NAME(XF86VidModeGetModeLine) (dpy, screen, dotclock, modeline) Display * dpy; int screen; int * dotclock; -SDL_NAME (XF86VidModeModeLine) * modeline; +SDL_NAME(XF86VidModeModeLine) * modeline; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeGetModeLineReply rep; xXF86OldVidModeGetModeLineReply oldrep; xXF86VidModeGetModeLineReq *req; int majorVersion, minorVersion; - XF86VidModeCheckExtension (dpy, info, False); - SDL_NAME (XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); + XF86VidModeCheckExtension(dpy, info, False); + SDL_NAME(XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); - LockDisplay (dpy); - GetReq (XF86VidModeGetModeLine, req); + LockDisplay(dpy); + GetReq(XF86VidModeGetModeLine, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetModeLine; req->screen = screen; if (majorVersion < 2) { - if (!_XReply (dpy, (xReply *) & oldrep, - (SIZEOF (xXF86OldVidModeGetModeLineReply) - - SIZEOF (xReply)) >> 2, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & oldrep, + (SIZEOF(xXF86OldVidModeGetModeLineReply) - + SIZEOF(xReply)) >> 2, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } *dotclock = oldrep.dotclock; @@ -255,11 +255,11 @@ modeline->flags = oldrep.flags; modeline->privsize = oldrep.privsize; } else { - if (!_XReply (dpy, (xReply *) & rep, - (SIZEOF (xXF86VidModeGetModeLineReply) - - SIZEOF (xReply)) >> 2, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, + (SIZEOF(xXF86VidModeGetModeLineReply) - + SIZEOF(xReply)) >> 2, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } *dotclock = rep.dotclock; @@ -277,41 +277,39 @@ } if (modeline->privsize > 0) { - if (! - (modeline->private = - Xcalloc (modeline->privsize, sizeof (INT32)))) { - _XEatData (dpy, (modeline->privsize) * sizeof (INT32)); - Xfree (modeline->private); + if (!(modeline->private = Xcalloc(modeline->privsize, sizeof(INT32)))) { + _XEatData(dpy, (modeline->privsize) * sizeof(INT32)); + Xfree(modeline->private); return False; } - _XRead (dpy, (char *) modeline->private, - modeline->privsize * sizeof (INT32)); + _XRead(dpy, (char *) modeline->private, + modeline->privsize * sizeof(INT32)); } else { modeline->private = NULL; } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } Bool -SDL_NAME (XF86VidModeGetAllModeLines) (dpy, screen, modecount, modelinesPtr) +SDL_NAME(XF86VidModeGetAllModeLines) (dpy, screen, modecount, modelinesPtr) Display *dpy; int screen; int *modecount; -SDL_NAME (XF86VidModeModeInfo) *** modelinesPtr; +SDL_NAME(XF86VidModeModeInfo) *** modelinesPtr; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeGetAllModeLinesReply rep; xXF86VidModeGetAllModeLinesReq *req; - SDL_NAME (XF86VidModeModeInfo) * mdinfptr, **modelines; + SDL_NAME(XF86VidModeModeInfo) * mdinfptr, **modelines; xXF86VidModeModeInfo xmdline; xXF86OldVidModeModeInfo oldxmdline; int i; int majorVersion, minorVersion; Bool protocolBug = False; - XF86VidModeCheckExtension (dpy, info, False); + XF86VidModeCheckExtension(dpy, info, False); /* * Note: There was a bug in the protocol implementation in versions @@ -319,26 +317,26 @@ * Check the server's version, and accept the old format if appropriate. */ - SDL_NAME (XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); + SDL_NAME(XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); if (majorVersion == 0 && minorVersion < 8) { protocolBug = True; #ifdef DEBUG - fprintf (stderr, "XF86VidModeGetAllModeLines: Warning: Xserver is" - "running an old version (%d.%d)\n", majorVersion, - minorVersion); + fprintf(stderr, "XF86VidModeGetAllModeLines: Warning: Xserver is" + "running an old version (%d.%d)\n", majorVersion, + minorVersion); #endif } - LockDisplay (dpy); - GetReq (XF86VidModeGetAllModeLines, req); + LockDisplay(dpy); + GetReq(XF86VidModeGetAllModeLines, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetAllModeLines; req->screen = screen; - if (!_XReply (dpy, (xReply *) & rep, - (SIZEOF (xXF86VidModeGetAllModeLinesReply) - - SIZEOF (xReply)) >> 2, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, + (SIZEOF(xXF86VidModeGetAllModeLinesReply) - + SIZEOF(xReply)) >> 2, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } @@ -346,35 +344,34 @@ if (! (modelines = - (SDL_NAME (XF86VidModeModeInfo) **) Xcalloc (rep.modecount, - sizeof (SDL_NAME - (XF86VidModeModeInfo) - *) + - sizeof (SDL_NAME - (XF86VidModeModeInfo))))) + (SDL_NAME(XF86VidModeModeInfo) **) Xcalloc(rep.modecount, + sizeof(SDL_NAME + (XF86VidModeModeInfo) + *) + + sizeof(SDL_NAME + (XF86VidModeModeInfo))))) { if (majorVersion < 2) - _XEatData (dpy, - (rep.modecount) * sizeof (xXF86OldVidModeModeInfo)); + _XEatData(dpy, (rep.modecount) * sizeof(xXF86OldVidModeModeInfo)); else - _XEatData (dpy, (rep.modecount) * sizeof (xXF86VidModeModeInfo)); - Xfree (modelines); - UnlockDisplay (dpy); - SyncHandle (); + _XEatData(dpy, (rep.modecount) * sizeof(xXF86VidModeModeInfo)); + Xfree(modelines); + UnlockDisplay(dpy); + SyncHandle(); return False; } - mdinfptr = (SDL_NAME (XF86VidModeModeInfo) *) ((char *) modelines - + - rep.modecount * - sizeof (SDL_NAME - (XF86VidModeModeInfo) - *)); + mdinfptr = (SDL_NAME(XF86VidModeModeInfo) *) ((char *) modelines + + + rep.modecount * + sizeof(SDL_NAME + (XF86VidModeModeInfo) + *)); for (i = 0; i < rep.modecount; i++) { modelines[i] = mdinfptr++; if (majorVersion < 2) { - _XRead (dpy, (char *) &oldxmdline, - sizeof (xXF86OldVidModeModeInfo)); + _XRead(dpy, (char *) &oldxmdline, + sizeof(xXF86OldVidModeModeInfo)); modelines[i]->dotclock = oldxmdline.dotclock; modelines[i]->hdisplay = oldxmdline.hdisplay; modelines[i]->hsyncstart = oldxmdline.hsyncstart; @@ -393,20 +390,19 @@ modelines[i]->privsize = oldxmdline.privsize; if (oldxmdline.privsize > 0) { if (!(modelines[i]->private = - Xcalloc (oldxmdline.privsize, sizeof (INT32)))) { - _XEatData (dpy, - (oldxmdline.privsize) * sizeof (INT32)); - Xfree (modelines[i]->private); + Xcalloc(oldxmdline.privsize, sizeof(INT32)))) { + _XEatData(dpy, (oldxmdline.privsize) * sizeof(INT32)); + Xfree(modelines[i]->private); } else { - _XRead (dpy, (char *) modelines[i]->private, - oldxmdline.privsize * sizeof (INT32)); + _XRead(dpy, (char *) modelines[i]->private, + oldxmdline.privsize * sizeof(INT32)); } } else { modelines[i]->private = NULL; } } } else { - _XRead (dpy, (char *) &xmdline, sizeof (xXF86VidModeModeInfo)); + _XRead(dpy, (char *) &xmdline, sizeof(xXF86VidModeModeInfo)); modelines[i]->dotclock = xmdline.dotclock; modelines[i]->hdisplay = xmdline.hdisplay; modelines[i]->hsyncstart = xmdline.hsyncstart; @@ -425,12 +421,12 @@ modelines[i]->privsize = xmdline.privsize; if (xmdline.privsize > 0) { if (!(modelines[i]->private = - Xcalloc (xmdline.privsize, sizeof (INT32)))) { - _XEatData (dpy, (xmdline.privsize) * sizeof (INT32)); - Xfree (modelines[i]->private); + Xcalloc(xmdline.privsize, sizeof(INT32)))) { + _XEatData(dpy, (xmdline.privsize) * sizeof(INT32)); + Xfree(modelines[i]->private); } else { - _XRead (dpy, (char *) modelines[i]->private, - xmdline.privsize * sizeof (INT32)); + _XRead(dpy, (char *) modelines[i]->private, + xmdline.privsize * sizeof(INT32)); } } else { modelines[i]->private = NULL; @@ -439,8 +435,8 @@ } } *modelinesPtr = modelines; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } @@ -471,23 +467,23 @@ #endif Bool -SDL_NAME (XF86VidModeAddModeLine) (dpy, screen, newmodeline, aftermodeline) +SDL_NAME(XF86VidModeAddModeLine) (dpy, screen, newmodeline, aftermodeline) Display *dpy; int screen; -SDL_NAME (XF86VidModeModeInfo) * newmodeline; -SDL_NAME (XF86VidModeModeInfo) * aftermodeline; +SDL_NAME(XF86VidModeModeInfo) * newmodeline; +SDL_NAME(XF86VidModeModeInfo) * aftermodeline; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeAddModeLineReq *req; xXF86OldVidModeAddModeLineReq *oldreq; int majorVersion, minorVersion; - XF86VidModeCheckExtension (dpy, info, False); - SDL_NAME (XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); + XF86VidModeCheckExtension(dpy, info, False); + SDL_NAME(XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); - LockDisplay (dpy); + LockDisplay(dpy); if (majorVersion < 2) { - GetOldReq (XF86VidModeAddModeLine, XF86OldVidModeAddModeLine, oldreq); + GetOldReq(XF86VidModeAddModeLine, XF86OldVidModeAddModeLine, oldreq); oldreq->reqType = info->codes->major_opcode; oldreq->xf86vidmodeReqType = X_XF86VidModeAddModeLine; oldreq->screen = screen; @@ -527,11 +523,11 @@ } if (newmodeline->privsize) { oldreq->length += newmodeline->privsize; - Data32 (dpy, (long *) newmodeline->private, - newmodeline->privsize * sizeof (INT32)); + Data32(dpy, (long *) newmodeline->private, + newmodeline->privsize * sizeof(INT32)); } } else { - GetReq (XF86VidModeAddModeLine, req); + GetReq(XF86VidModeAddModeLine, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeAddModeLine; req->screen = screen; @@ -574,34 +570,34 @@ } if (newmodeline->privsize) { req->length += newmodeline->privsize; - Data32 (dpy, (long *) newmodeline->private, - newmodeline->privsize * sizeof (INT32)); + Data32(dpy, (long *) newmodeline->private, + newmodeline->privsize * sizeof(INT32)); } } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } -Bool SDL_NAME (XF86VidModeDeleteModeLine) (dpy, screen, modeline) +Bool SDL_NAME(XF86VidModeDeleteModeLine) (dpy, screen, modeline) Display * dpy; int screen; -SDL_NAME (XF86VidModeModeInfo) * modeline; +SDL_NAME(XF86VidModeModeInfo) * modeline; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeDeleteModeLineReq *req; xXF86OldVidModeDeleteModeLineReq *oldreq; int majorVersion, minorVersion; - XF86VidModeCheckExtension (dpy, info, 0); - SDL_NAME (XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); + XF86VidModeCheckExtension(dpy, info, 0); + SDL_NAME(XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); - LockDisplay (dpy); + LockDisplay(dpy); if (majorVersion < 2) { - GetOldReq (XF86VidModeDeleteModeLine, XF86OldVidModeDeleteModeLine, - oldreq); + GetOldReq(XF86VidModeDeleteModeLine, XF86OldVidModeDeleteModeLine, + oldreq); oldreq->reqType = info->codes->major_opcode; oldreq->xf86vidmodeReqType = X_XF86VidModeDeleteModeLine; oldreq->screen = screen; @@ -618,11 +614,11 @@ oldreq->privsize = modeline->privsize; if (modeline->privsize) { oldreq->length += modeline->privsize; - Data32 (dpy, (long *) modeline->private, - modeline->privsize * sizeof (INT32)); + Data32(dpy, (long *) modeline->private, + modeline->privsize * sizeof(INT32)); } } else { - GetReq (XF86VidModeDeleteModeLine, req); + GetReq(XF86VidModeDeleteModeLine, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeDeleteModeLine; req->screen = screen; @@ -640,33 +636,33 @@ req->privsize = modeline->privsize; if (modeline->privsize) { req->length += modeline->privsize; - Data32 (dpy, (long *) modeline->private, - modeline->privsize * sizeof (INT32)); + Data32(dpy, (long *) modeline->private, + modeline->privsize * sizeof(INT32)); } } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } -Bool SDL_NAME (XF86VidModeModModeLine) (dpy, screen, modeline) +Bool SDL_NAME(XF86VidModeModModeLine) (dpy, screen, modeline) Display * dpy; int screen; -SDL_NAME (XF86VidModeModeLine) * modeline; +SDL_NAME(XF86VidModeModeLine) * modeline; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeModModeLineReq *req; xXF86OldVidModeModModeLineReq *oldreq; int majorVersion, minorVersion; - XF86VidModeCheckExtension (dpy, info, 0); - SDL_NAME (XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); + XF86VidModeCheckExtension(dpy, info, 0); + SDL_NAME(XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); - LockDisplay (dpy); + LockDisplay(dpy); if (majorVersion < 2) { - GetOldReq (XF86VidModeModModeLine, XF86OldVidModeModModeLine, oldreq); + GetOldReq(XF86VidModeModModeLine, XF86OldVidModeModModeLine, oldreq); oldreq->reqType = info->codes->major_opcode; oldreq->xf86vidmodeReqType = X_XF86VidModeModModeLine; oldreq->screen = screen; @@ -682,11 +678,11 @@ oldreq->privsize = modeline->privsize; if (modeline->privsize) { oldreq->length += modeline->privsize; - Data32 (dpy, (long *) modeline->private, - modeline->privsize * sizeof (INT32)); + Data32(dpy, (long *) modeline->private, + modeline->privsize * sizeof(INT32)); } } else { - GetReq (XF86VidModeModModeLine, req); + GetReq(XF86VidModeModModeLine, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeModModeLine; req->screen = screen; @@ -703,36 +699,36 @@ req->privsize = modeline->privsize; if (modeline->privsize) { req->length += modeline->privsize; - Data32 (dpy, (long *) modeline->private, - modeline->privsize * sizeof (INT32)); + Data32(dpy, (long *) modeline->private, + modeline->privsize * sizeof(INT32)); } } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } -Status SDL_NAME (XF86VidModeValidateModeLine) (dpy, screen, modeline) +Status SDL_NAME(XF86VidModeValidateModeLine) (dpy, screen, modeline) Display * dpy; int screen; -SDL_NAME (XF86VidModeModeInfo) * modeline; +SDL_NAME(XF86VidModeModeInfo) * modeline; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeValidateModeLineReq *req; xXF86OldVidModeValidateModeLineReq *oldreq; xXF86VidModeValidateModeLineReply rep; int majorVersion, minorVersion; - XF86VidModeCheckExtension (dpy, info, 0); - SDL_NAME (XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); + XF86VidModeCheckExtension(dpy, info, 0); + SDL_NAME(XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); - LockDisplay (dpy); + LockDisplay(dpy); if (majorVersion < 2) { - GetOldReq (XF86VidModeValidateModeLine, - XF86OldVidModeValidateModeLine, oldreq); + GetOldReq(XF86VidModeValidateModeLine, + XF86OldVidModeValidateModeLine, oldreq); oldreq->reqType = info->codes->major_opcode; oldreq->xf86vidmodeReqType = X_XF86VidModeValidateModeLine; oldreq->screen = screen; @@ -749,11 +745,11 @@ oldreq->privsize = modeline->privsize; if (modeline->privsize) { oldreq->length += modeline->privsize; - Data32 (dpy, (long *) modeline->private, - modeline->privsize * sizeof (INT32)); + Data32(dpy, (long *) modeline->private, + modeline->privsize * sizeof(INT32)); } } else { - GetReq (XF86VidModeValidateModeLine, req); + GetReq(XF86VidModeValidateModeLine, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeValidateModeLine; req->screen = screen; @@ -771,21 +767,21 @@ req->privsize = modeline->privsize; if (modeline->privsize) { req->length += modeline->privsize; - Data32 (dpy, (long *) modeline->private, - modeline->privsize * sizeof (INT32)); + Data32(dpy, (long *) modeline->private, + modeline->privsize * sizeof(INT32)); } } - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return MODE_BAD; } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return rep.status; } -Bool SDL_NAME (XF86VidModeSwitchMode) (dpy, screen, zoom) +Bool SDL_NAME(XF86VidModeSwitchMode) (dpy, screen, zoom) Display * dpy; int @@ -793,36 +789,36 @@ int zoom; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeSwitchModeReq *req; - XF86VidModeCheckExtension (dpy, info, False); + XF86VidModeCheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86VidModeSwitchMode, req); + LockDisplay(dpy); + GetReq(XF86VidModeSwitchMode, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeSwitchMode; req->screen = screen; req->zoom = zoom; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } -Bool SDL_NAME (XF86VidModeSwitchToMode) (dpy, screen, modeline) +Bool SDL_NAME(XF86VidModeSwitchToMode) (dpy, screen, modeline) Display * dpy; int screen; -SDL_NAME (XF86VidModeModeInfo) * modeline; +SDL_NAME(XF86VidModeModeInfo) * modeline; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeSwitchToModeReq *req; xXF86OldVidModeSwitchToModeReq *oldreq; int majorVersion, minorVersion; Bool protocolBug = False; - XF86VidModeCheckExtension (dpy, info, False); + XF86VidModeCheckExtension(dpy, info, False); /* * Note: There was a bug in the protocol implementation in versions @@ -831,20 +827,20 @@ * if appropriate. */ - SDL_NAME (XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); + SDL_NAME(XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); if (majorVersion == 0 && minorVersion < 8) { protocolBug = True; #ifdef DEBUG - fprintf (stderr, "XF86VidModeSwitchToMode: Warning: Xserver is" - "running an old version (%d.%d)\n", majorVersion, - minorVersion); + fprintf(stderr, "XF86VidModeSwitchToMode: Warning: Xserver is" + "running an old version (%d.%d)\n", majorVersion, + minorVersion); #endif } - LockDisplay (dpy); + LockDisplay(dpy); if (majorVersion < 2) { - GetOldReq (XF86VidModeSwitchToMode, XF86OldVidModeSwitchToMode, - oldreq); + GetOldReq(XF86VidModeSwitchToMode, XF86OldVidModeSwitchToMode, + oldreq); oldreq->reqType = info->codes->major_opcode; oldreq->xf86vidmodeReqType = X_XF86VidModeSwitchToMode; oldreq->screen = screen; @@ -864,12 +860,12 @@ oldreq->privsize = modeline->privsize; if (modeline->privsize) { oldreq->length += modeline->privsize; - Data32 (dpy, (long *) modeline->private, - modeline->privsize * sizeof (INT32)); + Data32(dpy, (long *) modeline->private, + modeline->privsize * sizeof(INT32)); } } } else { - GetReq (XF86VidModeSwitchToMode, req); + GetReq(XF86VidModeSwitchToMode, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeSwitchToMode; req->screen = screen; @@ -890,17 +886,17 @@ req->privsize = modeline->privsize; if (modeline->privsize) { req->length += modeline->privsize; - Data32 (dpy, (long *) modeline->private, - modeline->privsize * sizeof (INT32)); + Data32(dpy, (long *) modeline->private, + modeline->privsize * sizeof(INT32)); } } } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } -Bool SDL_NAME (XF86VidModeLockModeSwitch) (dpy, screen, lock) +Bool SDL_NAME(XF86VidModeLockModeSwitch) (dpy, screen, lock) Display * dpy; int @@ -908,45 +904,45 @@ int lock; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeLockModeSwitchReq *req; - XF86VidModeCheckExtension (dpy, info, False); + XF86VidModeCheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86VidModeLockModeSwitch, req); + LockDisplay(dpy); + GetReq(XF86VidModeLockModeSwitch, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeLockModeSwitch; req->screen = screen; req->lock = lock; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } -Bool SDL_NAME (XF86VidModeGetMonitor) (dpy, screen, monitor) +Bool SDL_NAME(XF86VidModeGetMonitor) (dpy, screen, monitor) Display * dpy; int screen; -SDL_NAME (XF86VidModeMonitor) * monitor; +SDL_NAME(XF86VidModeMonitor) * monitor; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeGetMonitorReply rep; xXF86VidModeGetMonitorReq *req; CARD32 syncrange; int i; - XF86VidModeCheckExtension (dpy, info, False); + XF86VidModeCheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86VidModeGetMonitor, req); + LockDisplay(dpy); + GetReq(XF86VidModeGetMonitor, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetMonitor; req->screen = screen; - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } monitor->nhsync = rep.nhsync; @@ -955,26 +951,26 @@ monitor->bandwidth = (float) rep.bandwidth / 1e6; #endif if (rep.vendorLength) { - if (!(monitor->vendor = (char *) Xcalloc (rep.vendorLength + 1, 1))) { - _XEatData (dpy, (rep.nhsync + rep.nvsync) * 4 + - ((rep.vendorLength + 3) & ~3) + - ((rep.modelLength + 3) & ~3)); - UnlockDisplay (dpy); - SyncHandle (); + if (!(monitor->vendor = (char *) Xcalloc(rep.vendorLength + 1, 1))) { + _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + + ((rep.vendorLength + 3) & ~3) + + ((rep.modelLength + 3) & ~3)); + UnlockDisplay(dpy); + SyncHandle(); return False; } } else { monitor->vendor = NULL; } if (rep.modelLength) { - if (!(monitor->model = Xcalloc (rep.modelLength + 1, 1))) { - _XEatData (dpy, (rep.nhsync + rep.nvsync) * 4 + - ((rep.vendorLength + 3) & ~3) + - ((rep.modelLength + 3) & ~3)); + if (!(monitor->model = Xcalloc(rep.modelLength + 1, 1))) { + _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + + ((rep.vendorLength + 3) & ~3) + + ((rep.modelLength + 3) & ~3)); if (monitor->vendor) - Xfree (monitor->vendor); - UnlockDisplay (dpy); - SyncHandle (); + Xfree(monitor->vendor); + UnlockDisplay(dpy); + SyncHandle(); return False; } } else { @@ -982,59 +978,59 @@ } if (! (monitor->hsync = - Xcalloc (rep.nhsync, sizeof (SDL_NAME (XF86VidModeSyncRange))))) { - _XEatData (dpy, (rep.nhsync + rep.nvsync) * 4 + - ((rep.vendorLength + 3) & ~3) + - ((rep.modelLength + 3) & ~3)); + Xcalloc(rep.nhsync, sizeof(SDL_NAME(XF86VidModeSyncRange))))) { + _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + + ((rep.vendorLength + 3) & ~3) + + ((rep.modelLength + 3) & ~3)); if (monitor->vendor) - Xfree (monitor->vendor); + Xfree(monitor->vendor); if (monitor->model) - Xfree (monitor->model); - UnlockDisplay (dpy); - SyncHandle (); + Xfree(monitor->model); + UnlockDisplay(dpy); + SyncHandle(); return False; } if (! (monitor->vsync = - Xcalloc (rep.nvsync, sizeof (SDL_NAME (XF86VidModeSyncRange))))) { - _XEatData (dpy, (rep.nhsync + rep.nvsync) * 4 + - ((rep.vendorLength + 3) & ~3) + - ((rep.modelLength + 3) & ~3)); + Xcalloc(rep.nvsync, sizeof(SDL_NAME(XF86VidModeSyncRange))))) { + _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + + ((rep.vendorLength + 3) & ~3) + + ((rep.modelLength + 3) & ~3)); if (monitor->vendor) - Xfree (monitor->vendor); + Xfree(monitor->vendor); if (monitor->model) - Xfree (monitor->model); - Xfree (monitor->hsync); - UnlockDisplay (dpy); - SyncHandle (); + Xfree(monitor->model); + Xfree(monitor->hsync); + UnlockDisplay(dpy); + SyncHandle(); return False; } for (i = 0; i < rep.nhsync; i++) { - _XRead (dpy, (char *) &syncrange, 4); + _XRead(dpy, (char *) &syncrange, 4); monitor->hsync[i].lo = (float) (syncrange & 0xFFFF) / 100.0; monitor->hsync[i].hi = (float) (syncrange >> 16) / 100.0; } for (i = 0; i < rep.nvsync; i++) { - _XRead (dpy, (char *) &syncrange, 4); + _XRead(dpy, (char *) &syncrange, 4); monitor->vsync[i].lo = (float) (syncrange & 0xFFFF) / 100.0; monitor->vsync[i].hi = (float) (syncrange >> 16) / 100.0; } if (rep.vendorLength) - _XReadPad (dpy, monitor->vendor, rep.vendorLength); + _XReadPad(dpy, monitor->vendor, rep.vendorLength); else monitor->vendor = ""; if (rep.modelLength) - _XReadPad (dpy, monitor->model, rep.modelLength); + _XReadPad(dpy, monitor->model, rep.modelLength); else monitor->model = ""; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } -Bool SDL_NAME (XF86VidModeGetViewPort) (dpy, screen, x, y) +Bool SDL_NAME(XF86VidModeGetViewPort) (dpy, screen, x, y) Display * dpy; int @@ -1043,13 +1039,13 @@ x, * y; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeGetViewPortReply rep; xXF86VidModeGetViewPortReq *req; int majorVersion, minorVersion; Bool protocolBug = False; - XF86VidModeCheckExtension (dpy, info, False); + XF86VidModeCheckExtension(dpy, info, False); /* * Note: There was a bug in the protocol implementation in versions @@ -1058,17 +1054,17 @@ * versions. */ - SDL_NAME (XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); + SDL_NAME(XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); if (majorVersion == 0 && minorVersion < 8) { protocolBug = True; #ifdef DEBUG - fprintf (stderr, "XF86VidModeGetViewPort: Warning: Xserver is" - "running an old version (%d.%d)\n", majorVersion, - minorVersion); + fprintf(stderr, "XF86VidModeGetViewPort: Warning: Xserver is" + "running an old version (%d.%d)\n", majorVersion, + minorVersion); #endif } - LockDisplay (dpy); - GetReq (XF86VidModeGetViewPort, req); + LockDisplay(dpy); + GetReq(XF86VidModeGetViewPort, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetViewPort; req->screen = screen; @@ -1076,21 +1072,21 @@ *x = 0; *y = 0; } else { - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } *x = rep.x; *y = rep.y; } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } -Bool SDL_NAME (XF86VidModeSetViewPort) (dpy, screen, x, y) +Bool SDL_NAME(XF86VidModeSetViewPort) (dpy, screen, x, y) Display * dpy; int @@ -1099,163 +1095,163 @@ x, y; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeSetViewPortReq *req; - XF86VidModeCheckExtension (dpy, info, False); + XF86VidModeCheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86VidModeSetViewPort, req); + LockDisplay(dpy); + GetReq(XF86VidModeSetViewPort, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeSetViewPort; req->screen = screen; req->x = x; req->y = y; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } Bool -SDL_NAME (XF86VidModeGetDotClocks) (dpy, screen, - flagsPtr, numclocksPtr, maxclocksPtr, - clocksPtr) +SDL_NAME(XF86VidModeGetDotClocks) (dpy, screen, + flagsPtr, numclocksPtr, maxclocksPtr, + clocksPtr) Display *dpy; int screen; int *flagsPtr, *numclocksPtr, *maxclocksPtr, *clocksPtr[]; { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeGetDotClocksReply rep; xXF86VidModeGetDotClocksReq *req; int i, *dotclocks; CARD32 dotclk; - XF86VidModeCheckExtension (dpy, info, False); + XF86VidModeCheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86VidModeGetDotClocks, req); + LockDisplay(dpy); + GetReq(XF86VidModeGetDotClocks, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetDotClocks; req->screen = screen; - if (!_XReply (dpy, (xReply *) & rep, - (SIZEOF (xXF86VidModeGetDotClocksReply) - - SIZEOF (xReply)) >> 2, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, + (SIZEOF(xXF86VidModeGetDotClocksReply) - + SIZEOF(xReply)) >> 2, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } *numclocksPtr = rep.clocks; *maxclocksPtr = rep.maxclocks; *flagsPtr = rep.flags; - if (!(dotclocks = (int *) Xcalloc (rep.clocks, sizeof (int)))) { - _XEatData (dpy, (rep.clocks) * 4); - Xfree (dotclocks); - UnlockDisplay (dpy); - SyncHandle (); + if (!(dotclocks = (int *) Xcalloc(rep.clocks, sizeof(int)))) { + _XEatData(dpy, (rep.clocks) * 4); + Xfree(dotclocks); + UnlockDisplay(dpy); + SyncHandle(); return False; } for (i = 0; i < rep.clocks; i++) { - _XRead (dpy, (char *) &dotclk, 4); + _XRead(dpy, (char *) &dotclk, 4); dotclocks[i] = dotclk; } *clocksPtr = dotclocks; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } Bool -SDL_NAME (XF86VidModeSetGammaRamp) (Display * dpy, - int screen, - int size, - unsigned short *red, - unsigned short *green, - unsigned short *blue) +SDL_NAME(XF86VidModeSetGammaRamp) (Display * dpy, + int screen, + int size, + unsigned short *red, + unsigned short *green, + unsigned short *blue) { int length = (size + 1) & ~1; - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeSetGammaRampReq *req; - XF86VidModeCheckExtension (dpy, info, False); - LockDisplay (dpy); - GetReq (XF86VidModeSetGammaRamp, req); + XF86VidModeCheckExtension(dpy, info, False); + LockDisplay(dpy); + GetReq(XF86VidModeSetGammaRamp, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeSetGammaRamp; req->screen = screen; req->length += (length >> 1) * 3; req->size = size; - _XSend (dpy, (char *) red, size * 2); - _XSend (dpy, (char *) green, size * 2); - _XSend (dpy, (char *) blue, size * 2); - UnlockDisplay (dpy); - SyncHandle (); + _XSend(dpy, (char *) red, size * 2); + _XSend(dpy, (char *) green, size * 2); + _XSend(dpy, (char *) blue, size * 2); + UnlockDisplay(dpy); + SyncHandle(); return True; } Bool -SDL_NAME (XF86VidModeGetGammaRamp) (Display * dpy, - int screen, - int size, - unsigned short *red, - unsigned short *green, - unsigned short *blue) +SDL_NAME(XF86VidModeGetGammaRamp) (Display * dpy, + int screen, + int size, + unsigned short *red, + unsigned short *green, + unsigned short *blue) { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeGetGammaRampReq *req; xXF86VidModeGetGammaRampReply rep; - XF86VidModeCheckExtension (dpy, info, False); + XF86VidModeCheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86VidModeGetGammaRamp, req); + LockDisplay(dpy); + GetReq(XF86VidModeGetGammaRamp, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetGammaRamp; req->screen = screen; req->size = size; - if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } if (rep.size) { - _XRead (dpy, (char *) red, rep.size << 1); - _XRead (dpy, (char *) green, rep.size << 1); - _XRead (dpy, (char *) blue, rep.size << 1); + _XRead(dpy, (char *) red, rep.size << 1); + _XRead(dpy, (char *) green, rep.size << 1); + _XRead(dpy, (char *) blue, rep.size << 1); } - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } -Bool SDL_NAME (XF86VidModeGetGammaRampSize) (Display * dpy, - int screen, int *size) +Bool SDL_NAME(XF86VidModeGetGammaRampSize) (Display * dpy, + int screen, int *size) { - XExtDisplayInfo *info = find_display (dpy); + XExtDisplayInfo *info = find_display(dpy); xXF86VidModeGetGammaRampSizeReq *req; xXF86VidModeGetGammaRampSizeReply rep; *size = 0; - XF86VidModeCheckExtension (dpy, info, False); + XF86VidModeCheckExtension(dpy, info, False); - LockDisplay (dpy); - GetReq (XF86VidModeGetGammaRampSize, req); + LockDisplay(dpy); + GetReq(XF86VidModeGetGammaRampSize, req); req->reqType = info->codes->major_opcode; req->xf86vidmodeReqType = X_XF86VidModeGetGammaRampSize; req->screen = screen; - if (!_XReply (dpy, (xReply *) & rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); + if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { + UnlockDisplay(dpy); + SyncHandle(); return False; } *size = rep.size; - UnlockDisplay (dpy); - SyncHandle (); + UnlockDisplay(dpy); + SyncHandle(); return True; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/Xext/extensions/Xext.h --- a/src/video/Xext/extensions/Xext.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/Xext/extensions/Xext.h Mon May 29 04:04:35 2006 +0000 @@ -33,10 +33,10 @@ _Xconst char *); extern XExtensionErrorHandler -XSetExtensionErrorHandler (XExtensionErrorHandler handler); +XSetExtensionErrorHandler(XExtensionErrorHandler handler); -extern int XMissingExtension (Display * /* dpy */ , - _Xconst char * /* ext_name */ +extern int XMissingExtension(Display * /* dpy */ , + _Xconst char * /* ext_name */ ); _XFUNCPROTOEND diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/Xext/extensions/Xinerama.h --- a/src/video/Xext/extensions/Xinerama.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/Xext/extensions/Xinerama.h Mon May 29 04:04:35 2006 +0000 @@ -12,15 +12,14 @@ short y_org; short width; short height; -} SDL_NAME (XineramaScreenInfo); - -Bool SDL_NAME (XineramaQueryExtension) (Display * dpy, - int *event_base, int *error_base); +} SDL_NAME(XineramaScreenInfo); -Status SDL_NAME (XineramaQueryVersion) (Display * dpy, - int *major, int *minor); +Bool SDL_NAME(XineramaQueryExtension) (Display * dpy, + int *event_base, int *error_base); -Bool SDL_NAME (XineramaIsActive) (Display * dpy); +Status SDL_NAME(XineramaQueryVersion) (Display * dpy, int *major, int *minor); + +Bool SDL_NAME(XineramaIsActive) (Display * dpy); /* @@ -31,8 +30,8 @@ Returned array should be freed with XFree(). */ -SDL_NAME (XineramaScreenInfo) * -SDL_NAME (XineramaQueryScreens) (Display * dpy, int *number); +SDL_NAME(XineramaScreenInfo) * +SDL_NAME(XineramaQueryScreens) (Display * dpy, int *number); #endif /* _Xinerama_h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/Xext/extensions/Xvlib.h --- a/src/video/Xext/extensions/Xvlib.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/Xext/extensions/Xvlib.h Mon May 29 04:04:35 2006 +0000 @@ -61,7 +61,7 @@ { int numerator; int denominator; -} SDL_NAME (XvRational); +} SDL_NAME(XvRational); typedef struct { @@ -69,7 +69,7 @@ int min_value; int max_value; char *name; -} SDL_NAME (XvAttribute); +} SDL_NAME(XvAttribute); typedef struct { @@ -77,15 +77,15 @@ char *name; unsigned long width; unsigned long height; - SDL_NAME (XvRational) rate; + SDL_NAME(XvRational) rate; unsigned long num_encodings; -} SDL_NAME (XvEncodingInfo); +} SDL_NAME(XvEncodingInfo); typedef struct { char depth; unsigned long visual_id; -} SDL_NAME (XvFormat); +} SDL_NAME(XvFormat); typedef struct { @@ -94,9 +94,9 @@ char type; char *name; unsigned long num_formats; - SDL_NAME (XvFormat) * formats; + SDL_NAME(XvFormat) * formats; unsigned long num_adaptors; -} SDL_NAME (XvAdaptorInfo); +} SDL_NAME(XvAdaptorInfo); typedef struct { @@ -108,7 +108,7 @@ unsigned long reason; /* what generated this event */ XvPortID port_id; /* what port */ Time time; /* milliseconds */ -} SDL_NAME (XvVideoNotifyEvent); +} SDL_NAME(XvVideoNotifyEvent); typedef struct { @@ -120,15 +120,15 @@ Time time; /* milliseconds */ Atom attribute; /* atom that identifies attribute */ long value; /* value of attribute */ -} SDL_NAME (XvPortNotifyEvent); +} SDL_NAME(XvPortNotifyEvent); typedef union { int type; - SDL_NAME (XvVideoNotifyEvent) xvvideo; - SDL_NAME (XvPortNotifyEvent) xvport; + SDL_NAME(XvVideoNotifyEvent) xvvideo; + SDL_NAME(XvPortNotifyEvent) xvport; long pad[24]; -} SDL_NAME (XvEvent); +} SDL_NAME(XvEvent); typedef struct { @@ -158,7 +158,7 @@ unsigned int vert_v_period; char component_order[32]; /* eg. UYVY */ int scanline_order; /* XvTopToBottom, XvBottomToTop */ -} SDL_NAME (XvImageFormatValues); +} SDL_NAME(XvImageFormatValues); typedef struct { @@ -170,280 +170,280 @@ int *offsets; /* bytes */ char *data; XPointer obdata; -} SDL_NAME (XvImage); +} SDL_NAME(XvImage); -_XFUNCPROTOBEGIN extern int SDL_NAME (XvQueryExtension) ( +_XFUNCPROTOBEGIN extern int SDL_NAME(XvQueryExtension) ( #if NeedFunctionPrototypes - Display * - /* display */ , - unsigned int * - /* p_version */ , - unsigned int * - /* p_revision */ , - unsigned int * - /* p_requestBase */ - , unsigned int * - /* p_eventBase */ - , unsigned int * /* p_errorBase */ -#endif - ); - -extern int SDL_NAME (XvQueryAdaptors) ( -#if NeedFunctionPrototypes - Display * /* display */ , - Window /* window */ , - unsigned int * /* p_nAdaptors */ , - SDL_NAME (XvAdaptorInfo) ** /* p_pAdaptors */ + Display * + /* display */ , + unsigned int * + /* p_version */ , + unsigned int * + /* p_revision */ , + unsigned int * + /* p_requestBase */ + , unsigned int * + /* p_eventBase */ + , unsigned int * /* p_errorBase */ #endif ); -extern int SDL_NAME (XvQueryEncodings) ( +extern int SDL_NAME(XvQueryAdaptors) ( #if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - unsigned int * /* p_nEncoding */ , - SDL_NAME (XvEncodingInfo) ** /* p_pEncoding */ + Display * /* display */ , + Window /* window */ , + unsigned int * /* p_nAdaptors */ , + SDL_NAME(XvAdaptorInfo) ** /* p_pAdaptors */ #endif ); -extern int SDL_NAME (XvPutVideo) ( +extern int SDL_NAME(XvQueryEncodings) ( #if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Drawable /* d */ , - GC /* gc */ , - int /* vx */ , - int /* vy */ , - unsigned int /* vw */ , - unsigned int /* vh */ , - int /* dx */ , - int /* dy */ , - unsigned int /* dw */ , - unsigned int /* dh */ + Display * /* display */ , + XvPortID /* port */ , + unsigned int * /* p_nEncoding */ , + SDL_NAME(XvEncodingInfo) ** /* p_pEncoding */ #endif ); -extern int SDL_NAME (XvPutStill) ( +extern int SDL_NAME(XvPutVideo) ( #if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Drawable /* d */ , - GC /* gc */ , - int /* vx */ , - int /* vy */ , - unsigned int /* vw */ , - unsigned int /* vh */ , - int /* dx */ , - int /* dy */ , - unsigned int /* dw */ , - unsigned int /* dh */ + Display * /* display */ , + XvPortID /* port */ , + Drawable /* d */ , + GC /* gc */ , + int /* vx */ , + int /* vy */ , + unsigned int /* vw */ , + unsigned int /* vh */ , + int /* dx */ , + int /* dy */ , + unsigned int /* dw */ , + unsigned int /* dh */ #endif ); -extern int SDL_NAME (XvGetVideo) ( +extern int SDL_NAME(XvPutStill) ( #if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Drawable /* d */ , - GC /* gc */ , - int /* vx */ , - int /* vy */ , - unsigned int /* vw */ , - unsigned int /* vh */ , - int /* dx */ , - int /* dy */ , - unsigned int /* dw */ , - unsigned int /* dh */ + Display * /* display */ , + XvPortID /* port */ , + Drawable /* d */ , + GC /* gc */ , + int /* vx */ , + int /* vy */ , + unsigned int /* vw */ , + unsigned int /* vh */ , + int /* dx */ , + int /* dy */ , + unsigned int /* dw */ , + unsigned int /* dh */ #endif ); -extern int SDL_NAME (XvGetStill) ( +extern int SDL_NAME(XvGetVideo) ( #if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Drawable /* d */ , - GC /* gc */ , - int /* vx */ , - int /* vy */ , - unsigned int /* vw */ , - unsigned int /* vh */ , - int /* dx */ , - int /* dy */ , - unsigned int /* dw */ , - unsigned int /* dh */ + Display * /* display */ , + XvPortID /* port */ , + Drawable /* d */ , + GC /* gc */ , + int /* vx */ , + int /* vy */ , + unsigned int /* vw */ , + unsigned int /* vh */ , + int /* dx */ , + int /* dy */ , + unsigned int /* dw */ , + unsigned int /* dh */ #endif ); -extern int SDL_NAME (XvStopVideo) ( +extern int SDL_NAME(XvGetStill) ( #if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Drawable /* drawable */ -#endif - ); - -extern int SDL_NAME (XvGrabPort) ( -#if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Time /* time */ + Display * /* display */ , + XvPortID /* port */ , + Drawable /* d */ , + GC /* gc */ , + int /* vx */ , + int /* vy */ , + unsigned int /* vw */ , + unsigned int /* vh */ , + int /* dx */ , + int /* dy */ , + unsigned int /* dw */ , + unsigned int /* dh */ #endif ); -extern int SDL_NAME (XvUngrabPort) ( +extern int SDL_NAME(XvStopVideo) ( #if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Time /* time */ + Display * /* display */ , + XvPortID /* port */ , + Drawable /* drawable */ #endif ); -extern int SDL_NAME (XvSelectVideoNotify) ( +extern int SDL_NAME(XvGrabPort) ( #if NeedFunctionPrototypes - Display * /* display */ , - Drawable /* drawable */ , - Bool /* onoff */ + Display * /* display */ , + XvPortID /* port */ , + Time /* time */ #endif ); -extern int SDL_NAME (XvSelectPortNotify) ( +extern int SDL_NAME(XvUngrabPort) ( +#if NeedFunctionPrototypes + Display * /* display */ , + XvPortID /* port */ , + Time /* time */ +#endif + ); + +extern int SDL_NAME(XvSelectVideoNotify) ( #if NeedFunctionPrototypes Display * /* display */ , - XvPortID /* port */ , + Drawable /* drawable */ , Bool /* onoff */ #endif ); -extern int SDL_NAME (XvSetPortAttribute) ( +extern int SDL_NAME(XvSelectPortNotify) ( #if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Atom /* attribute */ , - int /* value */ + Display * /* display */ , + XvPortID /* port */ , + Bool /* onoff */ +#endif + ); + +extern int SDL_NAME(XvSetPortAttribute) ( +#if NeedFunctionPrototypes + Display * /* display */ , + XvPortID /* port */ , + Atom /* attribute */ , + int /* value */ #endif ); -extern int SDL_NAME (XvGetPortAttribute) ( +extern int SDL_NAME(XvGetPortAttribute) ( #if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Atom /* attribute */ , - int * /* p_value */ + Display * /* display */ , + XvPortID /* port */ , + Atom /* attribute */ , + int * /* p_value */ #endif ); -extern int SDL_NAME (XvQueryBestSize) ( +extern int SDL_NAME(XvQueryBestSize) ( #if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Bool /* motion */ , - unsigned int /* vid_w */ , - unsigned int /* vid_h */ , - unsigned int /* drw_w */ , - unsigned int /* drw_h */ , - unsigned int * /* p_actual_width */ - , unsigned int * /* p_actual_width */ + Display * /* display */ , + XvPortID /* port */ , + Bool /* motion */ , + unsigned int /* vid_w */ , + unsigned int /* vid_h */ , + unsigned int /* drw_w */ , + unsigned int /* drw_h */ , + unsigned int * /* p_actual_width */ + , unsigned int * /* p_actual_width */ #endif ); extern -SDL_NAME (XvAttribute) * -SDL_NAME (XvQueryPortAttributes) ( +SDL_NAME(XvAttribute) * +SDL_NAME(XvQueryPortAttributes) ( #if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - int * /* number */ -#endif - ); - - - extern void SDL_NAME (XvFreeAdaptorInfo) ( -#if NeedFunctionPrototypes - SDL_NAME (XvAdaptorInfo) * /* adaptors */ -#endif - ); - - extern void SDL_NAME (XvFreeEncodingInfo) ( -#if NeedFunctionPrototypes - SDL_NAME (XvEncodingInfo) * /* encodings */ + Display * /* display */ , + XvPortID /* port */ , + int * /* number */ #endif ); - extern SDL_NAME (XvImageFormatValues) * SDL_NAME (XvListImageFormats) ( + extern void SDL_NAME(XvFreeAdaptorInfo) ( #if NeedFunctionPrototypes - Display - * - display, - XvPortID - port_id, - int - *count_return + SDL_NAME(XvAdaptorInfo) * /* adaptors */ #endif ); - extern SDL_NAME (XvImage) * SDL_NAME (XvCreateImage) ( + extern void SDL_NAME(XvFreeEncodingInfo) ( #if NeedFunctionPrototypes - Display * - display, - XvPortID port, - int id, - char *data, - int width, - int height + SDL_NAME(XvEncodingInfo) * /* encodings */ +#endif + ); + + + extern SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) ( +#if NeedFunctionPrototypes + Display + * + display, + XvPortID + port_id, + int + *count_return #endif ); - extern int SDL_NAME (XvPutImage) ( + extern SDL_NAME(XvImage) * SDL_NAME(XvCreateImage) ( #if NeedFunctionPrototypes - Display * display, - XvPortID id, - Drawable d, - GC gc, - SDL_NAME (XvImage) * image, - int src_x, - int src_y, - unsigned int src_w, - unsigned int src_h, - int dest_x, - int dest_y, - unsigned int dest_w, - unsigned int dest_h + Display * + display, + XvPortID port, + int id, + char *data, + int width, + int height #endif ); - extern int SDL_NAME (XvShmPutImage) ( + extern int SDL_NAME(XvPutImage) ( #if NeedFunctionPrototypes - Display * display, - XvPortID id, - Drawable d, - GC gc, - SDL_NAME (XvImage) * image, - int src_x, - int src_y, - unsigned int src_w, - unsigned int src_h, - int dest_x, - int dest_y, - unsigned int dest_w, - unsigned int dest_h, - Bool send_event + Display * display, + XvPortID id, + Drawable d, + GC gc, + SDL_NAME(XvImage) * image, + int src_x, + int src_y, + unsigned int src_w, + unsigned int src_h, + int dest_x, + int dest_y, + unsigned int dest_w, + unsigned int dest_h +#endif + ); + + extern int SDL_NAME(XvShmPutImage) ( +#if NeedFunctionPrototypes + Display * display, + XvPortID id, + Drawable d, + GC gc, + SDL_NAME(XvImage) * image, + int src_x, + int src_y, + unsigned int src_w, + unsigned int src_h, + int dest_x, + int dest_y, + unsigned int dest_w, + unsigned int dest_h, + Bool send_event #endif ); #ifdef _XSHM_H_ - extern SDL_NAME (XvImage) * SDL_NAME (XvShmCreateImage) ( + extern SDL_NAME(XvImage) * SDL_NAME(XvShmCreateImage) ( #if NeedFunctionPrototypes - Display * - display, - XvPortID - port, int id, - char *data, - int width, - int height, - XShmSegmentInfo - * shminfo + Display * + display, + XvPortID + port, int id, + char *data, + int width, + int height, + XShmSegmentInfo + * shminfo #endif ); diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/Xext/extensions/extutil.h --- a/src/video/Xext/extensions/extutil.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/Xext/extensions/extutil.h Mon May 29 04:04:35 2006 +0000 @@ -110,18 +110,18 @@ XExtCodes * /* codes */ #endif ); - Bool (*wire_to_event) ( + Bool(*wire_to_event) ( #if NeedNestedPrototypes - Display * /* display */ , - XEvent * /* re */ , - xEvent * /* event */ + Display * /* display */ , + XEvent * /* re */ , + xEvent * /* event */ #endif ); - Status (*event_to_wire) ( + Status(*event_to_wire) ( #if NeedNestedPrototypes - Display * /* display */ , - XEvent * /* re */ , - xEvent * /* event */ + Display * /* display */ , + XEvent * /* re */ , + xEvent * /* event */ #endif ); int (*error) ( @@ -143,36 +143,36 @@ ); } XExtensionHooks; -extern XExtensionInfo *XextCreateExtension ( +extern XExtensionInfo *XextCreateExtension( #if NeedFunctionPrototypes - void + void +#endif + ); +extern void XextDestroyExtension( +#if NeedFunctionPrototypes + XExtensionInfo * /* info */ #endif ); -extern void XextDestroyExtension ( +extern XExtDisplayInfo *XextAddDisplay( #if NeedFunctionPrototypes - XExtensionInfo * /* info */ + XExtensionInfo * /* extinfo */ , + Display * /* dpy */ , + char * /* ext_name */ , + XExtensionHooks * /* hooks */ , + int /* nevents */ , + XPointer /* data */ #endif ); -extern XExtDisplayInfo *XextAddDisplay ( +extern int XextRemoveDisplay( +#if NeedFunctionPrototypes + XExtensionInfo * /* extinfo */ , + Display * /* dpy */ +#endif + ); +extern XExtDisplayInfo *XextFindDisplay( #if NeedFunctionPrototypes XExtensionInfo * /* extinfo */ , - Display * /* dpy */ , - char * /* ext_name */ , - XExtensionHooks * /* hooks */ , - int /* nevents */ , - XPointer /* data */ -#endif - ); -extern int XextRemoveDisplay ( -#if NeedFunctionPrototypes - XExtensionInfo * /* extinfo */ , - Display * /* dpy */ -#endif - ); -extern XExtDisplayInfo *XextFindDisplay ( -#if NeedFunctionPrototypes - XExtensionInfo * /* extinfo */ , - Display * /* dpy */ + Display * /* dpy */ #endif ); diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/Xext/extensions/panoramiXext.h --- a/src/video/Xext/extensions/panoramiXext.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/Xext/extensions/panoramiXext.h Mon May 29 04:04:35 2006 +0000 @@ -44,13 +44,13 @@ int height; /* height of this screen */ int ScreenCount; /* real physical number of screens */ XID eventMask; /* selected events for this client */ -} SDL_NAME (XPanoramiXInfo); +} SDL_NAME(XPanoramiXInfo); extern -SDL_NAME (XPanoramiXInfo) * -SDL_NAME (XPanoramiXAllocInfo) ( +SDL_NAME(XPanoramiXInfo) * +SDL_NAME(XPanoramiXAllocInfo) ( #if NeedFunctionPrototypes - void + void #endif ); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/Xext/extensions/xf86dga.h --- a/src/video/Xext/extensions/xf86dga.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/Xext/extensions/xf86dga.h Mon May 29 04:04:35 2006 +0000 @@ -87,15 +87,15 @@ int viewportFlags; /* types of page flipping possible */ int reserved1; int reserved2; -} SDL_NAME (XDGAMode); +} SDL_NAME(XDGAMode); typedef struct { - SDL_NAME (XDGAMode) mode; + SDL_NAME(XDGAMode) mode; unsigned char *data; Pixmap pixmap; -} SDL_NAME (XDGADevice); +} SDL_NAME(XDGADevice); #ifndef _XF86DGA_SERVER_ @@ -108,7 +108,7 @@ Time time; unsigned int state; unsigned int button; -} SDL_NAME (XDGAButtonEvent); +} SDL_NAME(XDGAButtonEvent); typedef struct { @@ -119,7 +119,7 @@ Time time; unsigned int state; unsigned int keycode; -} SDL_NAME (XDGAKeyEvent); +} SDL_NAME(XDGAKeyEvent); typedef struct { @@ -131,88 +131,88 @@ unsigned int state; int dx; int dy; -} SDL_NAME (XDGAMotionEvent); +} SDL_NAME(XDGAMotionEvent); typedef union { int type; - SDL_NAME (XDGAButtonEvent) xbutton; - SDL_NAME (XDGAKeyEvent) xkey; - SDL_NAME (XDGAMotionEvent) xmotion; + SDL_NAME(XDGAButtonEvent) xbutton; + SDL_NAME(XDGAKeyEvent) xkey; + SDL_NAME(XDGAMotionEvent) xmotion; long pad[24]; -} SDL_NAME (XDGAEvent); +} SDL_NAME(XDGAEvent); -Bool SDL_NAME (XDGAQueryExtension) (Display * dpy, - int *eventBase, int *erroBase); +Bool SDL_NAME(XDGAQueryExtension) (Display * dpy, + int *eventBase, int *erroBase); -Bool SDL_NAME (XDGAQueryVersion) (Display * dpy, - int *majorVersion, int *minorVersion); +Bool SDL_NAME(XDGAQueryVersion) (Display * dpy, + int *majorVersion, int *minorVersion); -SDL_NAME (XDGAMode) * SDL_NAME (XDGAQueryModes) (Display * dpy, - int screen, int *num); +SDL_NAME(XDGAMode) * SDL_NAME(XDGAQueryModes) (Display * dpy, + int screen, int *num); -SDL_NAME (XDGADevice) * SDL_NAME (XDGASetMode) (Display * dpy, - int screen, int mode); +SDL_NAME(XDGADevice) * SDL_NAME(XDGASetMode) (Display * dpy, + int screen, int mode); Bool -SDL_NAME (XDGAOpenFramebuffer) (Display * dpy, int screen); +SDL_NAME(XDGAOpenFramebuffer) (Display * dpy, int screen); - void SDL_NAME (XDGACloseFramebuffer) (Display * dpy, int screen); + void SDL_NAME(XDGACloseFramebuffer) (Display * dpy, int screen); - void SDL_NAME (XDGASetViewport) (Display * dpy, - int screen, int x, int y, int flags); + void SDL_NAME(XDGASetViewport) (Display * dpy, + int screen, int x, int y, int flags); - void SDL_NAME (XDGAInstallColormap) (Display * dpy, - int screen, Colormap cmap); + void SDL_NAME(XDGAInstallColormap) (Display * dpy, + int screen, Colormap cmap); Colormap -SDL_NAME (XDGACreateColormap) (Display * dpy, - int screen, - SDL_NAME (XDGADevice) * device, int alloc); +SDL_NAME(XDGACreateColormap) (Display * dpy, + int screen, + SDL_NAME(XDGADevice) * device, int alloc); - void SDL_NAME (XDGASelectInput) (Display * dpy, int screen, - long event_mask); + void SDL_NAME(XDGASelectInput) (Display * dpy, int screen, + long event_mask); - void SDL_NAME (XDGAFillRectangle) (Display * dpy, - int screen, - int x, - int y, - unsigned int width, - unsigned int height, - unsigned long color); + void SDL_NAME(XDGAFillRectangle) (Display * dpy, + int screen, + int x, + int y, + unsigned int width, + unsigned int height, + unsigned long color); - void SDL_NAME (XDGACopyArea) (Display * dpy, - int screen, - int srcx, - int srcy, - unsigned int width, - unsigned int height, int dstx, int dsty); + void SDL_NAME(XDGACopyArea) (Display * dpy, + int screen, + int srcx, + int srcy, + unsigned int width, + unsigned int height, int dstx, int dsty); - void SDL_NAME (XDGACopyTransparentArea) (Display * dpy, - int screen, - int srcx, - int srcy, - unsigned int width, - unsigned int height, - int dstx, - int dsty, unsigned long key); + void SDL_NAME(XDGACopyTransparentArea) (Display * dpy, + int screen, + int srcx, + int srcy, + unsigned int width, + unsigned int height, + int dstx, + int dsty, unsigned long key); - int SDL_NAME (XDGAGetViewportStatus) (Display * dpy, int screen); + int SDL_NAME(XDGAGetViewportStatus) (Display * dpy, int screen); - void SDL_NAME (XDGASync) (Display * dpy, int screen); + void SDL_NAME(XDGASync) (Display * dpy, int screen); Bool -SDL_NAME (XDGASetClientVersion) (Display * dpy); +SDL_NAME(XDGASetClientVersion) (Display * dpy); - void SDL_NAME (XDGAChangePixmapMode) (Display * dpy, - int screen, int *x, int *y, - int mode); + void SDL_NAME(XDGAChangePixmapMode) (Display * dpy, + int screen, int *x, int *y, + int mode); - void SDL_NAME (XDGAKeyEventToXKeyEvent) (SDL_NAME (XDGAKeyEvent) * dk, - XKeyEvent * xk); + void SDL_NAME(XDGAKeyEventToXKeyEvent) (SDL_NAME(XDGAKeyEvent) * dk, + XKeyEvent * xk); _XFUNCPROTOEND diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/Xext/extensions/xf86dga1.h --- a/src/video/Xext/extensions/xf86dga1.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/Xext/extensions/xf86dga1.h Mon May 29 04:04:35 2006 +0000 @@ -41,122 +41,122 @@ #ifndef _XF86DGA_SERVER_ -_XFUNCPROTOBEGIN Bool SDL_NAME (XF86DGAQueryVersion) ( +_XFUNCPROTOBEGIN Bool SDL_NAME(XF86DGAQueryVersion) ( #if NeedFunctionPrototypes - Display * /* dpy */ , - int * - /* majorVersion */ , - int * /* minorVersion */ + Display * /* dpy */ , + int * + /* majorVersion */ , + int * /* minorVersion */ +#endif + ); + +Bool SDL_NAME(XF86DGAQueryExtension) ( +#if NeedFunctionPrototypes + Display * /* dpy */ , + int * /* event_base */ , + int * /* error_base */ #endif ); -Bool SDL_NAME (XF86DGAQueryExtension) ( +Status SDL_NAME(XF86DGAGetVideoLL) ( #if NeedFunctionPrototypes - Display * /* dpy */ , - int * /* event_base */ , - int * /* error_base */ + Display * /* dpy */ , + int /* screen */ , + int * /* base addr */ , + int * /* width */ , + int * /* bank_size */ , + int * /* ram_size */ #endif ); -Status SDL_NAME (XF86DGAGetVideoLL) ( +Status SDL_NAME(XF86DGAGetVideo) ( +#if NeedFunctionPrototypes + Display * /* dpy */ , + int /* screen */ , + char ** /* base addr */ , + int * /* width */ , + int * /* bank_size */ , + int * /* ram_size */ +#endif + ); + +Status SDL_NAME(XF86DGADirectVideo) ( #if NeedFunctionPrototypes Display * /* dpy */ , int /* screen */ , - int * /* base addr */ , - int * /* width */ , - int * /* bank_size */ , - int * /* ram_size */ + int /* enable */ #endif ); -Status SDL_NAME (XF86DGAGetVideo) ( +Status SDL_NAME(XF86DGADirectVideoLL) ( #if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - char ** /* base addr */ , - int * /* width */ , - int * /* bank_size */ , - int * /* ram_size */ -#endif - ); - -Status SDL_NAME (XF86DGADirectVideo) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - int /* enable */ -#endif - ); - -Status SDL_NAME (XF86DGADirectVideoLL) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - int /* enable */ + Display * /* dpy */ , + int /* screen */ , + int /* enable */ #endif ); -Status SDL_NAME (XF86DGAGetViewPortSize) ( +Status SDL_NAME(XF86DGAGetViewPortSize) ( #if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - int * /* width */ , - int * /* height */ + Display * /* dpy */ , + int /* screen */ , + int * /* width */ , + int * /* height */ #endif ); -Status SDL_NAME (XF86DGASetViewPort) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - int x /* X */ , - int y /* Y */ -#endif - ); - -Status SDL_NAME (XF86DGAGetVidPage) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - int * /* vid page */ -#endif - ); - -Status SDL_NAME (XF86DGASetVidPage) ( +Status SDL_NAME(XF86DGASetViewPort) ( #if NeedFunctionPrototypes Display * /* dpy */ , int /* screen */ , - int /* vid page */ + int x /* X */ , + int y /* Y */ #endif ); -Status SDL_NAME (XF86DGAInstallColormap) ( +Status SDL_NAME(XF86DGAGetVidPage) ( #if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - Colormap /*Colormap */ + Display * /* dpy */ , + int /* screen */ , + int * /* vid page */ +#endif + ); + +Status SDL_NAME(XF86DGASetVidPage) ( +#if NeedFunctionPrototypes + Display * /* dpy */ , + int /* screen */ , + int /* vid page */ #endif ); -int SDL_NAME (XF86DGAForkApp) ( +Status SDL_NAME(XF86DGAInstallColormap) ( #if NeedFunctionPrototypes - int screen + Display * /* dpy */ , + int /* screen */ , + Colormap /*Colormap */ +#endif + ); + +int SDL_NAME(XF86DGAForkApp) ( +#if NeedFunctionPrototypes + int screen #endif ); -Status SDL_NAME (XF86DGAQueryDirectVideo) ( +Status SDL_NAME(XF86DGAQueryDirectVideo) ( #if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - int * /* flags */ + Display * /* dpy */ , + int /* screen */ , + int * /* flags */ #endif ); -Bool SDL_NAME (XF86DGAViewPortChanged) ( +Bool SDL_NAME(XF86DGAViewPortChanged) ( #if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - int /* n */ + Display * /* dpy */ , + int /* screen */ , + int /* n */ #endif ); diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/Xext/extensions/xf86vmode.h --- a/src/video/Xext/extensions/xf86vmode.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/Xext/extensions/xf86vmode.h Mon May 29 04:04:35 2006 +0000 @@ -105,7 +105,7 @@ #else INT32 *private; #endif -} SDL_NAME (XF86VidModeModeLine); +} SDL_NAME(XF86VidModeModeLine); typedef struct { @@ -127,13 +127,13 @@ #else INT32 *private; #endif -} SDL_NAME (XF86VidModeModeInfo); +} SDL_NAME(XF86VidModeModeInfo); typedef struct { float hi; float lo; -} SDL_NAME (XF86VidModeSyncRange); +} SDL_NAME(XF86VidModeSyncRange); typedef struct { @@ -141,10 +141,10 @@ char *model; float EMPTY; unsigned char nhsync; - SDL_NAME (XF86VidModeSyncRange) * hsync; + SDL_NAME(XF86VidModeSyncRange) * hsync; unsigned char nvsync; - SDL_NAME (XF86VidModeSyncRange) * vsync; -} SDL_NAME (XF86VidModeMonitor); + SDL_NAME(XF86VidModeSyncRange) * vsync; +} SDL_NAME(XF86VidModeMonitor); typedef struct { @@ -157,14 +157,14 @@ int kind; /* What happened */ Bool forced; /* extents of new region */ Time time; /* event timestamp */ -} SDL_NAME (XF86VidModeNotifyEvent); +} SDL_NAME(XF86VidModeNotifyEvent); typedef struct { float red; /* Red Gamma value */ float green; /* Green Gamma value */ float blue; /* Blue Gamma value */ -} SDL_NAME (XF86VidModeGamma); +} SDL_NAME(XF86VidModeGamma); #define SDL_XF86VidModeSelectNextMode(disp, scr) \ @@ -172,123 +172,123 @@ #define SDL_XF86VidModeSelectPrevMode(disp, scr) \ SDL_NAME(XF86VidModeSwitchMode)(disp, scr, -1) -_XFUNCPROTOBEGIN - Bool SDL_NAME (XF86VidModeQueryVersion) (Display * /* dpy */ , - int * /* majorVersion */ , - int * /* minorVersion */ +_XFUNCPROTOBEGIN Bool SDL_NAME(XF86VidModeQueryVersion) (Display * /* dpy */ , + int * + /* majorVersion */ , + int * /* minorVersion */ ); -Bool SDL_NAME (XF86VidModeQueryExtension) (Display * /* dpy */ , - int * /* event_base */ , - int * /* error_base */ +Bool SDL_NAME(XF86VidModeQueryExtension) (Display * /* dpy */ , + int * /* event_base */ , + int * /* error_base */ ); -Bool SDL_NAME (XF86VidModeSetClientVersion) (Display * /* dpy */ +Bool SDL_NAME(XF86VidModeSetClientVersion) (Display * /* dpy */ ); -Bool SDL_NAME (XF86VidModeGetModeLine) (Display * /* dpy */ , - int /* screen */ , - int * /* dotclock */ , - SDL_NAME (XF86VidModeModeLine) * /* modeline */ +Bool SDL_NAME(XF86VidModeGetModeLine) (Display * /* dpy */ , + int /* screen */ , + int * /* dotclock */ , + SDL_NAME(XF86VidModeModeLine) * /* modeline */ ); -Bool SDL_NAME (XF86VidModeGetAllModeLines) (Display * /* dpy */ , - int /* screen */ , - int * /* modecount */ , - SDL_NAME (XF86VidModeModeInfo) *** /* modelinesPtr */ +Bool SDL_NAME(XF86VidModeGetAllModeLines) (Display * /* dpy */ , + int /* screen */ , + int * /* modecount */ , + SDL_NAME(XF86VidModeModeInfo) *** /* modelinesPtr */ ); -Bool SDL_NAME (XF86VidModeAddModeLine) (Display * /* dpy */ , - int /* screen */ , - SDL_NAME (XF86VidModeModeInfo) * - /* new modeline */ , - SDL_NAME (XF86VidModeModeInfo) * /* after modeline */ +Bool SDL_NAME(XF86VidModeAddModeLine) (Display * /* dpy */ , + int /* screen */ , + SDL_NAME(XF86VidModeModeInfo) * + /* new modeline */ , + SDL_NAME(XF86VidModeModeInfo) * /* after modeline */ ); -Bool SDL_NAME (XF86VidModeDeleteModeLine) (Display * /* dpy */ , - int /* screen */ , - SDL_NAME (XF86VidModeModeInfo) * /* modeline */ +Bool SDL_NAME(XF86VidModeDeleteModeLine) (Display * /* dpy */ , + int /* screen */ , + SDL_NAME(XF86VidModeModeInfo) * /* modeline */ ); -Bool SDL_NAME (XF86VidModeModModeLine) (Display * /* dpy */ , - int /* screen */ , - SDL_NAME (XF86VidModeModeLine) * /* modeline */ +Bool SDL_NAME(XF86VidModeModModeLine) (Display * /* dpy */ , + int /* screen */ , + SDL_NAME(XF86VidModeModeLine) * /* modeline */ ); -Status SDL_NAME (XF86VidModeValidateModeLine) (Display * /* dpy */ , - int /* screen */ , - SDL_NAME (XF86VidModeModeInfo) * /* modeline */ +Status SDL_NAME(XF86VidModeValidateModeLine) (Display * /* dpy */ , + int /* screen */ , + SDL_NAME(XF86VidModeModeInfo) * /* modeline */ ); -Bool SDL_NAME (XF86VidModeSwitchMode) (Display * /* dpy */ , - int /* screen */ , - int /* zoom */ +Bool SDL_NAME(XF86VidModeSwitchMode) (Display * /* dpy */ , + int /* screen */ , + int /* zoom */ ); -Bool SDL_NAME (XF86VidModeSwitchToMode) (Display * /* dpy */ , - int /* screen */ , - SDL_NAME (XF86VidModeModeInfo) * /* modeline */ +Bool SDL_NAME(XF86VidModeSwitchToMode) (Display * /* dpy */ , + int /* screen */ , + SDL_NAME(XF86VidModeModeInfo) * /* modeline */ ); -Bool SDL_NAME (XF86VidModeLockModeSwitch) (Display * /* dpy */ , - int /* screen */ , - int /* lock */ +Bool SDL_NAME(XF86VidModeLockModeSwitch) (Display * /* dpy */ , + int /* screen */ , + int /* lock */ ); -Bool SDL_NAME (XF86VidModeGetMonitor) (Display * /* dpy */ , - int /* screen */ , - SDL_NAME (XF86VidModeMonitor) * /* monitor */ +Bool SDL_NAME(XF86VidModeGetMonitor) (Display * /* dpy */ , + int /* screen */ , + SDL_NAME(XF86VidModeMonitor) * /* monitor */ ); -Bool SDL_NAME (XF86VidModeGetViewPort) (Display * /* dpy */ , - int /* screen */ , - int * /* x return */ , - int * /* y return */ +Bool SDL_NAME(XF86VidModeGetViewPort) (Display * /* dpy */ , + int /* screen */ , + int * /* x return */ , + int * /* y return */ ); -Bool SDL_NAME (XF86VidModeSetViewPort) (Display * /* dpy */ , - int /* screen */ , - int /* x */ , - int /* y */ +Bool SDL_NAME(XF86VidModeSetViewPort) (Display * /* dpy */ , + int /* screen */ , + int /* x */ , + int /* y */ ); -Bool SDL_NAME (XF86VidModeGetDotClocks) (Display * /* dpy */ , - int /* screen */ , - int * /* flags return */ , - int * /* number of clocks return */ , - int * /* max dot clock return */ , - int ** /* clocks return */ +Bool SDL_NAME(XF86VidModeGetDotClocks) (Display * /* dpy */ , + int /* screen */ , + int * /* flags return */ , + int * /* number of clocks return */ , + int * /* max dot clock return */ , + int ** /* clocks return */ ); -Bool SDL_NAME (XF86VidModeGetGamma) (Display * /* dpy */ , - int /* screen */ , - SDL_NAME (XF86VidModeGamma) * /* Gamma */ +Bool SDL_NAME(XF86VidModeGetGamma) (Display * /* dpy */ , + int /* screen */ , + SDL_NAME(XF86VidModeGamma) * /* Gamma */ ); -Bool SDL_NAME (XF86VidModeSetGamma) (Display * /* dpy */ , - int /* screen */ , - SDL_NAME (XF86VidModeGamma) * /* Gamma */ +Bool SDL_NAME(XF86VidModeSetGamma) (Display * /* dpy */ , + int /* screen */ , + SDL_NAME(XF86VidModeGamma) * /* Gamma */ ); -Bool SDL_NAME (XF86VidModeSetGammaRamp) (Display * /* dpy */ , - int /* screen */ , - int /* size */ , - unsigned short * /* red array */ , - unsigned short * /* green array */ , - unsigned short * /* blue array */ +Bool SDL_NAME(XF86VidModeSetGammaRamp) (Display * /* dpy */ , + int /* screen */ , + int /* size */ , + unsigned short * /* red array */ , + unsigned short * /* green array */ , + unsigned short * /* blue array */ ); -Bool SDL_NAME (XF86VidModeGetGammaRamp) (Display * /* dpy */ , - int /* screen */ , - int /* size */ , - unsigned short * /* red array */ , - unsigned short * /* green array */ , - unsigned short * /* blue array */ +Bool SDL_NAME(XF86VidModeGetGammaRamp) (Display * /* dpy */ , + int /* screen */ , + int /* size */ , + unsigned short * /* red array */ , + unsigned short * /* green array */ , + unsigned short * /* blue array */ ); -Bool SDL_NAME (XF86VidModeGetGammaRampSize) (Display * /* dpy */ , - int /* screen */ , - int * /* size */ +Bool SDL_NAME(XF86VidModeGetGammaRampSize) (Display * /* dpy */ , + int /* screen */ , + int * /* size */ ); diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/Xext/extensions/xme.h --- a/src/video/Xext/extensions/xme.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/Xext/extensions/xme.h Mon May 29 04:04:35 2006 +0000 @@ -30,13 +30,13 @@ int refresh; } XiGMiscResolutionInfo; -extern Bool XiGMiscQueryVersion (Display * dpy, int *major, int *minor); -extern int XiGMiscQueryViews (Display * dpy, int screen, - XiGMiscViewInfo ** pviews); -extern int XiGMiscQueryResolutions (Display * dpy, int screen, int view, - int *pactive, - XiGMiscResolutionInfo ** presolutions); -extern void XiGMiscChangeResolution (Display * dpy, int screen, int view, - int width, int height, int refresh); +extern Bool XiGMiscQueryVersion(Display * dpy, int *major, int *minor); +extern int XiGMiscQueryViews(Display * dpy, int screen, + XiGMiscViewInfo ** pviews); +extern int XiGMiscQueryResolutions(Display * dpy, int screen, int view, + int *pactive, + XiGMiscResolutionInfo ** presolutions); +extern void XiGMiscChangeResolution(Display * dpy, int screen, int view, + int width, int height, int refresh); #endif /* _XME_H_INCLUDED */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/aalib/SDL_aaevents.c --- a/src/video/aalib/SDL_aaevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/aalib/SDL_aaevents.c Mon May 29 04:04:35 2006 +0000 @@ -36,11 +36,11 @@ /* The translation tables from a console scancode to a SDL keysym */ static SDLKey keymap[401]; -static SDL_keysym *TranslateKey (int scancode, SDL_keysym * keysym); +static SDL_keysym *TranslateKey(int scancode, SDL_keysym * keysym); void -AA_PumpEvents (_THIS) +AA_PumpEvents(_THIS) { int posted = 0; int mouse_button, mouse_x, mouse_y; @@ -57,44 +57,44 @@ /* Gather events */ /* Get mouse status */ - SDL_mutexP (AA_mutex); - aa_getmouse (AA_context, &mouse_x, &mouse_y, &mouse_button); - SDL_mutexV (AA_mutex); - mouse_x = mouse_x * this->screen->w / aa_scrwidth (AA_context); - mouse_y = mouse_y * this->screen->h / aa_scrheight (AA_context); + SDL_mutexP(AA_mutex); + aa_getmouse(AA_context, &mouse_x, &mouse_y, &mouse_button); + SDL_mutexV(AA_mutex); + mouse_x = mouse_x * this->screen->w / aa_scrwidth(AA_context); + mouse_y = mouse_y * this->screen->h / aa_scrheight(AA_context); /* Compare against previous state and generate events */ if (prev_button != mouse_button) { if (mouse_button & AA_BUTTON1) { if (!(prev_button & AA_BUTTON1)) { - posted += SDL_PrivateMouseButton (SDL_PRESSED, 1, 0, 0); + posted += SDL_PrivateMouseButton(SDL_PRESSED, 1, 0, 0); } } else { if (prev_button & AA_BUTTON1) { - posted += SDL_PrivateMouseButton (SDL_RELEASED, 1, 0, 0); + posted += SDL_PrivateMouseButton(SDL_RELEASED, 1, 0, 0); } } if (mouse_button & AA_BUTTON2) { if (!(prev_button & AA_BUTTON2)) { - posted += SDL_PrivateMouseButton (SDL_PRESSED, 2, 0, 0); + posted += SDL_PrivateMouseButton(SDL_PRESSED, 2, 0, 0); } } else { if (prev_button & AA_BUTTON2) { - posted += SDL_PrivateMouseButton (SDL_RELEASED, 2, 0, 0); + posted += SDL_PrivateMouseButton(SDL_RELEASED, 2, 0, 0); } } if (mouse_button & AA_BUTTON3) { if (!(prev_button & AA_BUTTON3)) { - posted += SDL_PrivateMouseButton (SDL_PRESSED, 3, 0, 0); + posted += SDL_PrivateMouseButton(SDL_PRESSED, 3, 0, 0); } } else { if (prev_button & AA_BUTTON3) { - posted += SDL_PrivateMouseButton (SDL_RELEASED, 3, 0, 0); + posted += SDL_PrivateMouseButton(SDL_RELEASED, 3, 0, 0); } } } if (prev_x != mouse_x || prev_y != mouse_y) { - posted += SDL_PrivateMouseMotion (0, 0, mouse_x, mouse_y); + posted += SDL_PrivateMouseMotion(0, 0, mouse_x, mouse_y); } prev_button = mouse_button; @@ -102,30 +102,28 @@ prev_y = mouse_y; /* Get keyboard event */ - SDL_mutexP (AA_mutex); - evt = aa_getevent (AA_context, 0); - SDL_mutexV (AA_mutex); + SDL_mutexP(AA_mutex); + evt = aa_getevent(AA_context, 0); + SDL_mutexV(AA_mutex); if ((evt > AA_NONE) && (evt < AA_RELEASE) && (evt != AA_MOUSE) && (evt != AA_RESIZE)) { /* Key pressed */ /* printf("Key pressed: %d (%c)\n", evt, evt); */ posted += - SDL_PrivateKeyboard (SDL_PRESSED, - TranslateKey (evt, &keysym)); + SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(evt, &keysym)); } else if (evt >= AA_RELEASE) { /* Key released */ evt &= ~AA_RELEASE; /* printf("Key released: %d (%c)\n", evt, evt); */ posted += - SDL_PrivateKeyboard (SDL_RELEASED, - TranslateKey (evt, &keysym)); + SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(evt, &keysym)); } } while (posted); } void -AA_InitOSKeymap (_THIS) +AA_InitOSKeymap(_THIS) { int i; static const char *std_keys = @@ -133,7 +131,7 @@ const char *std; /* Initialize the AAlib key translation table */ - for (i = 0; i < SDL_arraysize (keymap); ++i) + for (i = 0; i < SDL_arraysize(keymap); ++i) keymap[i] = SDLK_UNKNOWN; /* Alphabet keys */ @@ -192,10 +190,10 @@ } static SDL_keysym * -TranslateKey (int scancode, SDL_keysym * keysym) +TranslateKey(int scancode, SDL_keysym * keysym) { /* Sanity check */ - if (scancode >= SDL_arraysize (keymap)) + if (scancode >= SDL_arraysize(keymap)) scancode = AA_UNKNOWN; /* Set the keysym information */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/aalib/SDL_aaevents_c.h --- a/src/video/aalib/SDL_aaevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/aalib/SDL_aaevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -26,11 +26,11 @@ /* Variables and functions exported by SDL_sysevents.c to other parts of the native video subsystem (SDL_sysvideo.c) */ -extern void AA_initkeymaps (int fd); -extern void AA_mousecallback (int button, int dx, int dy, - int u1, int u2, int u3, int u4); -extern void AA_keyboardcallback (int scancode, int pressed); +extern void AA_initkeymaps(int fd); +extern void AA_mousecallback(int button, int dx, int dy, + int u1, int u2, int u3, int u4); +extern void AA_keyboardcallback(int scancode, int pressed); -extern void AA_InitOSKeymap (_THIS); -extern void AA_PumpEvents (_THIS); +extern void AA_InitOSKeymap(_THIS); +extern void AA_PumpEvents(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/aalib/SDL_aavideo.c --- a/src/video/aalib/SDL_aavideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/aalib/SDL_aavideo.c Mon May 29 04:04:35 2006 +0000 @@ -41,21 +41,20 @@ #include /* Initialization/Query functions */ -static int AA_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **AA_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *AA_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int AA_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void AA_VideoQuit (_THIS); +static int AA_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **AA_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags); +static SDL_Surface *AA_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +static int AA_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void AA_VideoQuit(_THIS); /* Hardware surface functions */ -static int AA_AllocHWSurface (_THIS, SDL_Surface * surface); -static int AA_LockHWSurface (_THIS, SDL_Surface * surface); -static int AA_FlipHWSurface (_THIS, SDL_Surface * surface); -static void AA_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void AA_FreeHWSurface (_THIS, SDL_Surface * surface); +static int AA_AllocHWSurface(_THIS, SDL_Surface * surface); +static int AA_LockHWSurface(_THIS, SDL_Surface * surface); +static int AA_FlipHWSurface(_THIS, SDL_Surface * surface); +static void AA_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void AA_FreeHWSurface(_THIS, SDL_Surface * surface); /* Cache the VideoDevice struct */ static struct SDL_VideoDevice *local_this; @@ -63,38 +62,38 @@ /* AAlib driver bootstrap functions */ static int -AA_Available (void) +AA_Available(void) { return 1; /* Always available ! */ } static void -AA_DeleteDevice (SDL_VideoDevice * device) +AA_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -AA_CreateDevice (int devindex) +AA_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = AA_VideoInit; @@ -131,17 +130,17 @@ AA_Available, AA_CreateDevice }; -static void AA_ResizeHandler (aa_context *); +static void AA_ResizeHandler(aa_context *); int -AA_VideoInit (_THIS, SDL_PixelFormat * vformat) +AA_VideoInit(_THIS, SDL_PixelFormat * vformat) { int keyboard; int i; /* Initialize all variables that we clean on shutdown */ for (i = 0; i < SDL_NUMMODES; ++i) { - SDL_modelist[i] = SDL_malloc (sizeof (SDL_Rect)); + SDL_modelist[i] = SDL_malloc(sizeof(SDL_Rect)); SDL_modelist[i]->x = SDL_modelist[i]->y = 0; } /* Modes sorted largest to smallest */ @@ -161,35 +160,35 @@ /* Initialize the library */ - AA_mutex = SDL_CreateMutex (); + AA_mutex = SDL_CreateMutex(); - aa_parseoptions (NULL, NULL, NULL, NULL); + aa_parseoptions(NULL, NULL, NULL, NULL); - AA_context = aa_autoinit (&aa_defparams); + AA_context = aa_autoinit(&aa_defparams); if (!AA_context) { - SDL_SetError ("Unable to initialize AAlib"); + SDL_SetError("Unable to initialize AAlib"); return (-1); } /* Enable mouse and keyboard support */ - if (!aa_autoinitkbd (AA_context, AA_SENDRELEASE)) { - SDL_SetError ("Unable to initialize AAlib keyboard"); + if (!aa_autoinitkbd(AA_context, AA_SENDRELEASE)) { + SDL_SetError("Unable to initialize AAlib keyboard"); return (-1); } - if (!aa_autoinitmouse (AA_context, AA_SENDRELEASE)) { - fprintf (stderr, "Warning: Unable to initialize AAlib mouse"); + if (!aa_autoinitmouse(AA_context, AA_SENDRELEASE)) { + fprintf(stderr, "Warning: Unable to initialize AAlib mouse"); } - AA_rparams = aa_getrenderparams (); + AA_rparams = aa_getrenderparams(); local_this = this; - aa_resizehandler (AA_context, AA_ResizeHandler); + aa_resizehandler(AA_context, AA_ResizeHandler); - fprintf (stderr, "Using AAlib driver: %s (%s)\n", - AA_context->driver->name, AA_context->driver->shortname); + fprintf(stderr, "Using AAlib driver: %s (%s)\n", + AA_context->driver->name, AA_context->driver->shortname); - AA_in_x11 = (SDL_strcmp (AA_context->driver->shortname, "X11") == 0); + AA_in_x11 = (SDL_strcmp(AA_context->driver->shortname, "X11") == 0); /* Determine the screen depth (use default 8-bit depth) */ vformat->BitsPerPixel = 8; vformat->BytesPerPixel = 1; @@ -199,7 +198,7 @@ } SDL_Rect ** -AA_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +AA_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { if (format->BitsPerPixel != 8) return NULL; @@ -216,8 +215,8 @@ resolution by scaling down manually each frame */ static void -fastscale (register char *b1, register char *b2, int x1, int x2, int y1, - int y2) +fastscale(register char *b1, register char *b2, int x1, int x2, int y1, + int y2) { register int ex, spx = 0, ddx, ddx1; int ddy1, ddy, spy = 0, ey; @@ -257,32 +256,32 @@ } /* Various screen update functions available */ -static void AA_DirectUpdate (_THIS, int numrects, SDL_Rect * rects); +static void AA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects); SDL_Surface * -AA_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +AA_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { int mode; if (AA_buffer) { - SDL_free (AA_buffer); + SDL_free(AA_buffer); } - AA_buffer = SDL_malloc (width * height); + AA_buffer = SDL_malloc(width * height); if (!AA_buffer) { - SDL_SetError ("Couldn't allocate buffer for requested mode"); + SDL_SetError("Couldn't allocate buffer for requested mode"); return (NULL); } /* printf("Setting mode %dx%d\n", width, height); */ - SDL_memset (aa_image (AA_context), 0, - aa_imgwidth (AA_context) * aa_imgheight (AA_context)); - SDL_memset (AA_buffer, 0, width * height); + SDL_memset(aa_image(AA_context), 0, + aa_imgwidth(AA_context) * aa_imgheight(AA_context)); + SDL_memset(AA_buffer, 0, width * height); /* Allocate the new pixel format for the screen */ - if (!SDL_ReallocFormat (current, 8, 0, 0, 0, 0)) { + if (!SDL_ReallocFormat(current, 8, 0, 0, 0, 0)) { return (NULL); } @@ -293,8 +292,8 @@ current->pitch = current->w; current->pixels = AA_buffer; - AA_x_ratio = ((double) aa_imgwidth (AA_context)) / ((double) width); - AA_y_ratio = ((double) aa_imgheight (AA_context)) / ((double) height); + AA_x_ratio = ((double) aa_imgwidth(AA_context)) / ((double) width); + AA_y_ratio = ((double) aa_imgheight(AA_context)) / ((double) height); /* Set the blit function */ this->UpdateRects = AA_DirectUpdate; @@ -304,95 +303,95 @@ } static void -AA_ResizeHandler (aa_context * context) +AA_ResizeHandler(aa_context * context) { - aa_resize (context); + aa_resize(context); local_this->hidden->x_ratio = - ((double) aa_imgwidth (context)) / ((double) local_this->screen->w); + ((double) aa_imgwidth(context)) / ((double) local_this->screen->w); local_this->hidden->y_ratio = - ((double) aa_imgheight (context)) / ((double) local_this->screen->h); + ((double) aa_imgheight(context)) / ((double) local_this->screen->h); - fastscale (local_this->hidden->buffer, aa_image (context), - local_this->hidden->w, aa_imgwidth (context), - local_this->hidden->h, aa_imgheight (context)); - aa_renderpalette (context, local_this->hidden->palette, - local_this->hidden->rparams, 0, 0, - aa_scrwidth (context), aa_scrheight (context)); - aa_flush (context); + fastscale(local_this->hidden->buffer, aa_image(context), + local_this->hidden->w, aa_imgwidth(context), + local_this->hidden->h, aa_imgheight(context)); + aa_renderpalette(context, local_this->hidden->palette, + local_this->hidden->rparams, 0, 0, + aa_scrwidth(context), aa_scrheight(context)); + aa_flush(context); } /* We don't actually allow hardware surfaces other than the main one */ static int -AA_AllocHWSurface (_THIS, SDL_Surface * surface) +AA_AllocHWSurface(_THIS, SDL_Surface * surface) { return (-1); } static void -AA_FreeHWSurface (_THIS, SDL_Surface * surface) +AA_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } /* We need to wait for vertical retrace on page flipped displays */ static int -AA_LockHWSurface (_THIS, SDL_Surface * surface) +AA_LockHWSurface(_THIS, SDL_Surface * surface) { /* TODO ? */ return (0); } static void -AA_UnlockHWSurface (_THIS, SDL_Surface * surface) +AA_UnlockHWSurface(_THIS, SDL_Surface * surface) { return; } /* FIXME: How is this done with AAlib? */ static int -AA_FlipHWSurface (_THIS, SDL_Surface * surface) +AA_FlipHWSurface(_THIS, SDL_Surface * surface) { - SDL_mutexP (AA_mutex); - aa_flush (AA_context); - SDL_mutexV (AA_mutex); + SDL_mutexP(AA_mutex); + aa_flush(AA_context); + SDL_mutexV(AA_mutex); return (0); } static void -AA_DirectUpdate (_THIS, int numrects, SDL_Rect * rects) +AA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects) { int i; SDL_Rect *rect; - fastscale (AA_buffer, aa_image (AA_context), AA_w, - aa_imgwidth (AA_context), AA_h, aa_imgheight (AA_context)); + fastscale(AA_buffer, aa_image(AA_context), AA_w, + aa_imgwidth(AA_context), AA_h, aa_imgheight(AA_context)); #if 1 - aa_renderpalette (AA_context, AA_palette, AA_rparams, 0, 0, - aa_scrwidth (AA_context), aa_scrheight (AA_context)); + aa_renderpalette(AA_context, AA_palette, AA_rparams, 0, 0, + aa_scrwidth(AA_context), aa_scrheight(AA_context)); #else /* Render only the rectangles in the list */ - printf ("Update rects : "); + printf("Update rects : "); for (i = 0; i < numrects; ++i) { rect = &rects[i]; - printf ("(%d,%d-%d,%d)", rect->x, rect->y, rect->w, rect->h); - aa_renderpalette (AA_context, AA_palette, AA_rparams, - rect->x * AA_x_ratio, rect->y * AA_y_ratio, - rect->w * AA_x_ratio, rect->h * AA_y_ratio); + printf("(%d,%d-%d,%d)", rect->x, rect->y, rect->w, rect->h); + aa_renderpalette(AA_context, AA_palette, AA_rparams, + rect->x * AA_x_ratio, rect->y * AA_y_ratio, + rect->w * AA_x_ratio, rect->h * AA_y_ratio); } - printf ("\n"); + printf("\n"); #endif - SDL_mutexP (AA_mutex); - aa_flush (AA_context); - SDL_mutexV (AA_mutex); + SDL_mutexP(AA_mutex); + aa_flush(AA_context); + SDL_mutexV(AA_mutex); return; } int -AA_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +AA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { int i; for (i = 0; i < ncolors; i++) { - aa_setpalette (AA_palette, firstcolor + i, - colors[i].r >> 2, colors[i].g >> 2, colors[i].b >> 2); + aa_setpalette(AA_palette, firstcolor + i, + colors[i].r >> 2, colors[i].g >> 2, colors[i].b >> 2); } return (1); } @@ -401,24 +400,24 @@ another SDL video routine -- notably UpdateRects. */ void -AA_VideoQuit (_THIS) +AA_VideoQuit(_THIS) { int i; - aa_uninitkbd (AA_context); - aa_uninitmouse (AA_context); + aa_uninitkbd(AA_context); + aa_uninitmouse(AA_context); /* Free video mode lists */ for (i = 0; i < SDL_NUMMODES; ++i) { if (SDL_modelist[i] != NULL) { - SDL_free (SDL_modelist[i]); + SDL_free(SDL_modelist[i]); SDL_modelist[i] = NULL; } } - aa_close (AA_context); + aa_close(AA_context); - SDL_DestroyMutex (AA_mutex); + SDL_DestroyMutex(AA_mutex); this->screen->pixels = NULL; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_ataric2p_s.h --- a/src/video/ataricommon/SDL_ataric2p_s.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_ataric2p_s.h Mon May 29 04:04:35 2006 +0000 @@ -42,29 +42,29 @@ /* Convert a chunky screen to bitplane screen */ -void SDL_Atari_C2pConvert8 (Uint8 * src, /* Source screen (one byte=one pixel) */ - Uint8 * dest, /* Destination (8 bits planes) */ - Uint32 width, /* Dimensions of screen to convert */ - Uint32 height, Uint32 dblligne, /* Double the lines when converting ? */ - Uint32 srcpitch, /* Length of one source line in bytes */ - Uint32 dstpitch /* Length of one destination line in bytes */ +void SDL_Atari_C2pConvert8(Uint8 * src, /* Source screen (one byte=one pixel) */ + Uint8 * dest, /* Destination (8 bits planes) */ + Uint32 width, /* Dimensions of screen to convert */ + Uint32 height, Uint32 dblligne, /* Double the lines when converting ? */ + Uint32 srcpitch, /* Length of one source line in bytes */ + Uint32 dstpitch /* Length of one destination line in bytes */ ); /*--- 4 bits functions ---*/ /* Convert a chunky screen to bitplane screen */ -void SDL_Atari_C2pConvert4 (Uint8 * src, /* Source screen (one byte=one pixel) */ - Uint8 * dest, /* Destination (4 bits planes) */ - Uint32 width, /* Dimensions of screen to convert */ - Uint32 height, Uint32 dblligne, /* Double the lines when converting ? */ - Uint32 srcpitch, /* Length of one source line in bytes */ - Uint32 dstpitch /* Length of one destination line in bytes */ +void SDL_Atari_C2pConvert4(Uint8 * src, /* Source screen (one byte=one pixel) */ + Uint8 * dest, /* Destination (4 bits planes) */ + Uint32 width, /* Dimensions of screen to convert */ + Uint32 height, Uint32 dblligne, /* Double the lines when converting ? */ + Uint32 srcpitch, /* Length of one source line in bytes */ + Uint32 dstpitch /* Length of one destination line in bytes */ ); /* Conversion palette */ -void SDL_Atari_C2pConvert4_pal (Uint16 * lightpalette); +void SDL_Atari_C2pConvert4_pal(Uint16 * lightpalette); #endif /* _ATARI_C2P_h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_ataridevmouse.c --- a/src/video/ataricommon/SDL_ataridevmouse.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_ataridevmouse.c Mon May 29 04:04:35 2006 +0000 @@ -45,7 +45,7 @@ /* Functions */ int -SDL_AtariDevMouse_Open (void) +SDL_AtariDevMouse_Open(void) { int r; const char *mousedev; @@ -57,14 +57,14 @@ return 0; /* First, try SDL_MOUSEDEV device */ - mousedev = SDL_getenv ("SDL_MOUSEDEV"); + mousedev = SDL_getenv("SDL_MOUSEDEV"); if (!mousedev) { - handle = open (mousedev, 0); + handle = open(mousedev, 0); } /* Failed, try default device */ if (handle < 0) { - handle = open (DEVICE_NAME, 0); + handle = open(DEVICE_NAME, 0); } if (handle < 0) { @@ -73,18 +73,18 @@ } /* Set non blocking mode */ - r = fcntl (handle, F_GETFL, 0); + r = fcntl(handle, F_GETFL, 0); if (r < 0) { - close (handle); + close(handle); handle = -1; return 0; } r |= O_NDELAY; - r = fcntl (handle, F_SETFL, r); + r = fcntl(handle, F_SETFL, r); if (r < 0) { - close (handle); + close(handle); handle = -1; return 0; } @@ -94,16 +94,16 @@ } void -SDL_AtariDevMouse_Close (void) +SDL_AtariDevMouse_Close(void) { if (handle > 0) { - close (handle); + close(handle); handle = -1; } } static int -atari_GetButton (int button) +atari_GetButton(int button) { switch (button) { case 0: @@ -118,7 +118,7 @@ } void -SDL_AtariDevMouse_PostMouseEvents (_THIS, SDL_bool buttonEvents) +SDL_AtariDevMouse_PostMouseEvents(_THIS, SDL_bool buttonEvents) { unsigned char buffer[3]; int mousex, mousey; @@ -128,7 +128,7 @@ } mousex = mousey = 0; - while (read (handle, buffer, sizeof (buffer)) == sizeof (buffer)) { + while (read(handle, buffer, sizeof(buffer)) == sizeof(buffer)) { mouseb = buffer[0] & 7; mousex += (char) buffer[1]; mousey += (char) buffer[2]; @@ -144,12 +144,12 @@ prevbutton = prev_mouseb & (1 << i); if (curbutton && !prevbutton) { - SDL_PrivateMouseButton (SDL_RELEASED, - atari_GetButton (i), 0, 0); + SDL_PrivateMouseButton(SDL_RELEASED, + atari_GetButton(i), 0, 0); } if (!curbutton && prevbutton) { - SDL_PrivateMouseButton (SDL_PRESSED, - atari_GetButton (i), 0, 0); + SDL_PrivateMouseButton(SDL_PRESSED, + atari_GetButton(i), 0, 0); } } @@ -159,7 +159,7 @@ /* Mouse motion event */ if (mousex || mousey) { - SDL_PrivateMouseMotion (0, 1, mousex, -mousey); + SDL_PrivateMouseMotion(0, 1, mousex, -mousey); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_ataridevmouse_c.h --- a/src/video/ataricommon/SDL_ataridevmouse_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_ataridevmouse_c.h Mon May 29 04:04:35 2006 +0000 @@ -35,9 +35,9 @@ /* Hidden "this" pointer for the video functions */ #define _THIS SDL_VideoDevice *this -extern int SDL_AtariDevMouse_Open (void); -extern void SDL_AtariDevMouse_Close (void); -extern void SDL_AtariDevMouse_PostMouseEvents (_THIS, SDL_bool buttonEvents); +extern int SDL_AtariDevMouse_Open(void); +extern void SDL_AtariDevMouse_Close(void); +extern void SDL_AtariDevMouse_PostMouseEvents(_THIS, SDL_bool buttonEvents); #endif /* _SDL_ATARI_DEVMOUSE_H_ */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_atarieddi_s.h --- a/src/video/ataricommon/SDL_atarieddi_s.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_atarieddi_s.h Mon May 29 04:04:35 2006 +0000 @@ -51,7 +51,7 @@ /*--- Functions ---*/ -unsigned long Atari_get_EdDI_version (void *function_pointer); +unsigned long Atari_get_EdDI_version(void *function_pointer); #endif /* _SDL_Atari_eddi_s_h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_atarievents.c --- a/src/video/ataricommon/SDL_atarievents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_atarievents.c Mon May 29 04:04:35 2006 +0000 @@ -52,13 +52,13 @@ void (*Atari_ShutdownEvents) (void); static void -Atari_InitializeEvents (_THIS) +Atari_InitializeEvents(_THIS) { const char *envr; unsigned long cookie_mch; /* Test if we are on an Atari machine or not */ - if (Getcookie (C__MCH, &cookie_mch) == C_NOTFOUND) { + if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) { cookie_mch = 0; } cookie_mch >>= 16; @@ -81,25 +81,25 @@ break; } - envr = SDL_getenv ("SDL_ATARI_EVENTSDRIVER"); + envr = SDL_getenv("SDL_ATARI_EVENTSDRIVER"); if (!envr) { return; } - if (SDL_strcmp (envr, "ikbd") == 0) { + if (SDL_strcmp(envr, "ikbd") == 0) { this->InitOSKeymap = AtariIkbd_InitOSKeymap; this->PumpEvents = AtariIkbd_PumpEvents; Atari_ShutdownEvents = AtariIkbd_ShutdownEvents; } - if (SDL_strcmp (envr, "gemdos") == 0) { + if (SDL_strcmp(envr, "gemdos") == 0) { this->InitOSKeymap = AtariGemdos_InitOSKeymap; this->PumpEvents = AtariGemdos_PumpEvents; Atari_ShutdownEvents = AtariGemdos_ShutdownEvents; } - if (SDL_strcmp (envr, "bios") == 0) { + if (SDL_strcmp(envr, "bios") == 0) { this->InitOSKeymap = AtariBios_InitOSKeymap; this->PumpEvents = AtariBios_PumpEvents; Atari_ShutdownEvents = AtariBios_ShutdownEvents; @@ -107,21 +107,21 @@ } void -Atari_InitOSKeymap (_THIS) +Atari_InitOSKeymap(_THIS) { - Atari_InitializeEvents (this); + Atari_InitializeEvents(this); /* Call choosen routine */ - this->InitOSKeymap (this); + this->InitOSKeymap(this); } void -Atari_PumpEvents (_THIS) +Atari_PumpEvents(_THIS) { - Atari_InitializeEvents (this); + Atari_InitializeEvents(this); /* Call choosen routine */ - this->PumpEvents (this); + this->PumpEvents(this); } /* Atari to Unicode charset translation table */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_atarievents_c.h --- a/src/video/ataricommon/SDL_atarievents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_atarievents_c.h Mon May 29 04:04:35 2006 +0000 @@ -37,8 +37,8 @@ extern void (*Atari_ShutdownEvents) (void); -extern void Atari_InitOSKeymap (_THIS); -extern void Atari_PumpEvents (_THIS); +extern void Atari_InitOSKeymap(_THIS); +extern void Atari_PumpEvents(_THIS); /* Atari to Unicode charset translation table */ extern Uint16 SDL_AtariToUnicodeTable[256]; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_atarigl.c --- a/src/video/ataricommon/SDL_atarigl.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_atarigl.c Mon May 29 04:04:35 2006 +0000 @@ -48,41 +48,41 @@ /*--- Functions prototypes ---*/ -static void SDL_AtariGL_UnloadLibrary (_THIS); +static void SDL_AtariGL_UnloadLibrary(_THIS); #if SDL_VIDEO_OPENGL -static void CopyShadowNull (_THIS, SDL_Surface * surface); -static void CopyShadowDirect (_THIS, SDL_Surface * surface); -static void CopyShadowRGBTo555 (_THIS, SDL_Surface * surface); -static void CopyShadowRGBTo565 (_THIS, SDL_Surface * surface); -static void CopyShadowRGBSwap (_THIS, SDL_Surface * surface); -static void CopyShadowRGBToARGB (_THIS, SDL_Surface * surface); -static void CopyShadowRGBToABGR (_THIS, SDL_Surface * surface); -static void CopyShadowRGBToBGRA (_THIS, SDL_Surface * surface); -static void CopyShadowRGBToRGBA (_THIS, SDL_Surface * surface); -static void CopyShadow8888To555 (_THIS, SDL_Surface * surface); -static void CopyShadow8888To565 (_THIS, SDL_Surface * surface); +static void CopyShadowNull(_THIS, SDL_Surface * surface); +static void CopyShadowDirect(_THIS, SDL_Surface * surface); +static void CopyShadowRGBTo555(_THIS, SDL_Surface * surface); +static void CopyShadowRGBTo565(_THIS, SDL_Surface * surface); +static void CopyShadowRGBSwap(_THIS, SDL_Surface * surface); +static void CopyShadowRGBToARGB(_THIS, SDL_Surface * surface); +static void CopyShadowRGBToABGR(_THIS, SDL_Surface * surface); +static void CopyShadowRGBToBGRA(_THIS, SDL_Surface * surface); +static void CopyShadowRGBToRGBA(_THIS, SDL_Surface * surface); +static void CopyShadow8888To555(_THIS, SDL_Surface * surface); +static void CopyShadow8888To565(_THIS, SDL_Surface * surface); -static void ConvertNull (_THIS, SDL_Surface * surface); -static void Convert565To555be (_THIS, SDL_Surface * surface); -static void Convert565To555le (_THIS, SDL_Surface * surface); -static void Convert565le (_THIS, SDL_Surface * surface); -static void ConvertBGRAToABGR (_THIS, SDL_Surface * surface); +static void ConvertNull(_THIS, SDL_Surface * surface); +static void Convert565To555be(_THIS, SDL_Surface * surface); +static void Convert565To555le(_THIS, SDL_Surface * surface); +static void Convert565le(_THIS, SDL_Surface * surface); +static void ConvertBGRAToABGR(_THIS, SDL_Surface * surface); -static int InitNew (_THIS, SDL_Surface * current); -static int InitOld (_THIS, SDL_Surface * current); +static int InitNew(_THIS, SDL_Surface * current); +static int InitOld(_THIS, SDL_Surface * current); #endif /*--- Public functions ---*/ int -SDL_AtariGL_Init (_THIS, SDL_Surface * current) +SDL_AtariGL_Init(_THIS, SDL_Surface * current) { #if SDL_VIDEO_OPENGL if (gl_oldmesa) { - gl_active = InitOld (this, current); + gl_active = InitOld(this, current); } else { - gl_active = InitNew (this, current); + gl_active = InitNew(this, current); } #endif @@ -90,37 +90,37 @@ } void -SDL_AtariGL_Quit (_THIS, SDL_bool unload) +SDL_AtariGL_Quit(_THIS, SDL_bool unload) { #if SDL_VIDEO_OPENGL if (gl_oldmesa) { /* Old mesa implementations */ if (this->gl_data->OSMesaDestroyLDG) { - this->gl_data->OSMesaDestroyLDG (); + this->gl_data->OSMesaDestroyLDG(); } if (gl_shadow) { - Mfree (gl_shadow); + Mfree(gl_shadow); gl_shadow = NULL; } } else { /* New mesa implementation */ if (gl_ctx) { if (this->gl_data->OSMesaDestroyContext) { - this->gl_data->OSMesaDestroyContext (gl_ctx); + this->gl_data->OSMesaDestroyContext(gl_ctx); } gl_ctx = NULL; } } if (unload) { - SDL_AtariGL_UnloadLibrary (this); + SDL_AtariGL_UnloadLibrary(this); } #endif /* SDL_VIDEO_OPENGL */ gl_active = 0; } int -SDL_AtariGL_LoadLibrary (_THIS, const char *path) +SDL_AtariGL_LoadLibrary(_THIS, const char *path) { #if SDL_VIDEO_OPENGL @@ -129,47 +129,47 @@ SDL_bool cancel_load; if (gl_active) { - SDL_SetError ("OpenGL context already created"); + SDL_SetError("OpenGL context already created"); return -1; } /* Unload previous driver */ - SDL_AtariGL_UnloadLibrary (this); + SDL_AtariGL_UnloadLibrary(this); /* Load library given by path */ - handle = SDL_LoadObject (path); + handle = SDL_LoadObject(path); if (handle == NULL) { /* Try to load another one */ - path = SDL_getenv ("SDL_VIDEO_GL_DRIVER"); + path = SDL_getenv("SDL_VIDEO_GL_DRIVER"); if (path != NULL) { - handle = SDL_LoadObject (path); + handle = SDL_LoadObject(path); } /* If it does not work, try some other */ if (handle == NULL) { path = PATH_OSMESA_LDG; - handle = SDL_LoadObject (path); + handle = SDL_LoadObject(path); } if (handle == NULL) { path = PATH_MESAGL_LDG; - handle = SDL_LoadObject (path); + handle = SDL_LoadObject(path); } if (handle == NULL) { path = PATH_TINYGL_LDG; - handle = SDL_LoadObject (path); + handle = SDL_LoadObject(path); } } if (handle == NULL) { - SDL_SetError ("Could not load OpenGL library"); + SDL_SetError("Could not load OpenGL library"); return -1; } - this->gl_data->glGetIntegerv = SDL_LoadFunction (handle, "glGetIntegerv"); - this->gl_data->glFinish = SDL_LoadFunction (handle, "glFinish"); - this->gl_data->glFlush = SDL_LoadFunction (handle, "glFlush"); + this->gl_data->glGetIntegerv = SDL_LoadFunction(handle, "glGetIntegerv"); + this->gl_data->glFinish = SDL_LoadFunction(handle, "glFinish"); + this->gl_data->glFlush = SDL_LoadFunction(handle, "glFlush"); cancel_load = SDL_FALSE; if (this->gl_data->glGetIntegerv == NULL) { @@ -182,30 +182,30 @@ } } if (cancel_load) { - SDL_SetError ("Could not retrieve OpenGL functions"); - SDL_UnloadObject (handle); + SDL_SetError("Could not retrieve OpenGL functions"); + SDL_UnloadObject(handle); /* Restore pointers to static library */ - SDL_AtariGL_InitPointers (this); + SDL_AtariGL_InitPointers(this); return -1; } /* Load functions pointers (osmesa.ldg) */ this->gl_data->OSMesaCreateContextExt = - SDL_LoadFunction (handle, "OSMesaCreateContextExt"); + SDL_LoadFunction(handle, "OSMesaCreateContextExt"); this->gl_data->OSMesaDestroyContext = - SDL_LoadFunction (handle, "OSMesaDestroyContext"); + SDL_LoadFunction(handle, "OSMesaDestroyContext"); this->gl_data->OSMesaMakeCurrent = - SDL_LoadFunction (handle, "OSMesaMakeCurrent"); + SDL_LoadFunction(handle, "OSMesaMakeCurrent"); this->gl_data->OSMesaPixelStore = - SDL_LoadFunction (handle, "OSMesaPixelStore"); + SDL_LoadFunction(handle, "OSMesaPixelStore"); this->gl_data->OSMesaGetProcAddress = - SDL_LoadFunction (handle, "OSMesaGetProcAddress"); + SDL_LoadFunction(handle, "OSMesaGetProcAddress"); /* Load old functions pointers (mesa_gl.ldg, tiny_gl.ldg) */ this->gl_data->OSMesaCreateLDG = - SDL_LoadFunction (handle, "OSMesaCreateLDG"); + SDL_LoadFunction(handle, "OSMesaCreateLDG"); this->gl_data->OSMesaDestroyLDG = - SDL_LoadFunction (handle, "OSMesaDestroyLDG"); + SDL_LoadFunction(handle, "OSMesaDestroyLDG"); gl_oldmesa = 0; @@ -217,10 +217,10 @@ /* Hum, maybe old library ? */ if ((this->gl_data->OSMesaCreateLDG == NULL) || (this->gl_data->OSMesaDestroyLDG == NULL)) { - SDL_SetError ("Could not retrieve OSMesa functions"); - SDL_UnloadObject (handle); + SDL_SetError("Could not retrieve OSMesa functions"); + SDL_UnloadObject(handle); /* Restore pointers to static library */ - SDL_AtariGL_InitPointers (this); + SDL_AtariGL_InitPointers(this); return -1; } else { gl_oldmesa = 1; @@ -229,8 +229,8 @@ this->gl_config.dll_handle = handle; if (path) { - SDL_strlcpy (this->gl_config.driver_path, path, - SDL_arraysize (this->gl_config.driver_path)); + SDL_strlcpy(this->gl_config.driver_path, path, + SDL_arraysize(this->gl_config.driver_path)); } else { *this->gl_config.driver_path = '\0'; } @@ -245,22 +245,22 @@ } void * -SDL_AtariGL_GetProcAddress (_THIS, const char *proc) +SDL_AtariGL_GetProcAddress(_THIS, const char *proc) { void *func = NULL; #if SDL_VIDEO_OPENGL if (this->gl_config.dll_handle) { - func = SDL_LoadFunction (this->gl_config.dll_handle, (void *) proc); + func = SDL_LoadFunction(this->gl_config.dll_handle, (void *) proc); } else if (this->gl_data->OSMesaGetProcAddress) { - func = this->gl_data->OSMesaGetProcAddress (proc); + func = this->gl_data->OSMesaGetProcAddress(proc); } #endif return func; } int -SDL_AtariGL_GetAttribute (_THIS, SDL_GLattr attrib, int *value) +SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) { #if SDL_VIDEO_OPENGL GLenum mesa_attrib; @@ -309,7 +309,7 @@ return -1; } - this->gl_data->glGetIntegerv (mesa_attrib, value); + this->gl_data->glGetIntegerv(mesa_attrib, value); return 0; #else return -1; @@ -317,7 +317,7 @@ } int -SDL_AtariGL_MakeCurrent (_THIS) +SDL_AtariGL_MakeCurrent(_THIS) { #if SDL_VIDEO_OPENGL SDL_Surface *surface; @@ -335,7 +335,7 @@ } if (!gl_active) { - SDL_SetError ("Invalid OpenGL context"); + SDL_SetError("Invalid OpenGL context"); return -1; } @@ -350,14 +350,14 @@ if (! (this->gl_data-> - OSMesaMakeCurrent (gl_ctx, surface->pixels, type, surface->w, - surface->h))) { - SDL_SetError ("Can not make OpenGL context current"); + OSMesaMakeCurrent(gl_ctx, surface->pixels, type, surface->w, + surface->h))) { + SDL_SetError("Can not make OpenGL context current"); return -1; } /* OSMesa draws upside down */ - this->gl_data->OSMesaPixelStore (OSMESA_Y_UP, 0); + this->gl_data->OSMesaPixelStore(OSMESA_Y_UP, 0); return 0; #else @@ -366,27 +366,27 @@ } void -SDL_AtariGL_SwapBuffers (_THIS) +SDL_AtariGL_SwapBuffers(_THIS) { #if SDL_VIDEO_OPENGL if (gl_active) { if (this->gl_config.dll_handle) { if (this->gl_data->glFinish) { - this->gl_data->glFinish (); + this->gl_data->glFinish(); } else if (this->gl_data->glFlush) { - this->gl_data->glFlush (); + this->gl_data->glFlush(); } } else { - this->gl_data->glFinish (); + this->gl_data->glFinish(); } - gl_copyshadow (this, this->screen); - gl_convert (this, this->screen); + gl_copyshadow(this, this->screen); + gl_convert(this, this->screen); } #endif } void -SDL_AtariGL_InitPointers (_THIS) +SDL_AtariGL_InitPointers(_THIS) { #if SDL_VIDEO_OPENGL this->gl_data->OSMesaCreateContextExt = OSMesaCreateContextExt; @@ -407,15 +407,15 @@ /*--- Private functions ---*/ static void -SDL_AtariGL_UnloadLibrary (_THIS) +SDL_AtariGL_UnloadLibrary(_THIS) { #if SDL_VIDEO_OPENGL if (this->gl_config.dll_handle) { - SDL_UnloadObject (this->gl_config.dll_handle); + SDL_UnloadObject(this->gl_config.dll_handle); this->gl_config.dll_handle = NULL; /* Restore pointers to static library */ - SDL_AtariGL_InitPointers (this); + SDL_AtariGL_InitPointers(this); } #endif } @@ -424,7 +424,7 @@ #if SDL_VIDEO_OPENGL static int -InitNew (_THIS, SDL_Surface * current) +InitNew(_THIS, SDL_Surface * current) { GLenum osmesa_format; SDL_PixelFormat *pixel_format; @@ -508,15 +508,15 @@ recreatecontext = 0; } if (recreatecontext) { - SDL_AtariGL_Quit (this, SDL_FALSE); + SDL_AtariGL_Quit(this, SDL_FALSE); gl_ctx = - this->gl_data->OSMesaCreateContextExt (osmesa_format, - this->gl_config. - depth_size, - this->gl_config. - stencil_size, - newaccumsize, NULL); + this->gl_data->OSMesaCreateContextExt(osmesa_format, + this->gl_config. + depth_size, + this->gl_config. + stencil_size, + newaccumsize, NULL); if (gl_ctx) { gl_curformat = osmesa_format; @@ -536,7 +536,7 @@ static int -InitOld (_THIS, SDL_Surface * current) +InitOld(_THIS, SDL_Surface * current) { GLenum osmesa_format; SDL_PixelFormat *pixel_format; @@ -658,7 +658,7 @@ break; default: if (tinygl_present) { - SDL_AtariGL_Quit (this, SDL_FALSE); + SDL_AtariGL_Quit(this, SDL_FALSE); return 0; } gl_pixelsize = 1; @@ -675,11 +675,11 @@ recreatecontext = 0; } if (recreatecontext) { - SDL_AtariGL_Quit (this, SDL_FALSE); + SDL_AtariGL_Quit(this, SDL_FALSE); gl_shadow = - this->gl_data->OSMesaCreateLDG (osmesa_format, GL_UNSIGNED_BYTE, - current->w, current->h); + this->gl_data->OSMesaCreateLDG(osmesa_format, GL_UNSIGNED_BYTE, + current->w, current->h); if (gl_shadow) { gl_curformat = osmesa_format; @@ -698,12 +698,12 @@ /*--- Conversions routines from shadow buffer to the screen ---*/ static void -CopyShadowNull (_THIS, SDL_Surface * surface) +CopyShadowNull(_THIS, SDL_Surface * surface) { } static void -CopyShadowDirect (_THIS, SDL_Surface * surface) +CopyShadowDirect(_THIS, SDL_Surface * surface) { int y, srcpitch, dstpitch; Uint8 *srcline, *dstline; @@ -718,7 +718,7 @@ } for (y = 0; y < surface->h; y++) { - SDL_memcpy (dstline, srcline, srcpitch); + SDL_memcpy(dstline, srcline, srcpitch); srcline += srcpitch; dstline += dstpitch; @@ -726,7 +726,7 @@ } static void -CopyShadowRGBTo555 (_THIS, SDL_Surface * surface) +CopyShadowRGBTo555(_THIS, SDL_Surface * surface) { int x, y, srcpitch, dstpitch; Uint16 *dstline, *dstcol; @@ -759,7 +759,7 @@ } static void -CopyShadowRGBTo565 (_THIS, SDL_Surface * surface) +CopyShadowRGBTo565(_THIS, SDL_Surface * surface) { int x, y, srcpitch, dstpitch; Uint16 *dstline, *dstcol; @@ -793,7 +793,7 @@ } static void -CopyShadowRGBSwap (_THIS, SDL_Surface * surface) +CopyShadowRGBSwap(_THIS, SDL_Surface * surface) { int x, y, srcpitch, dstpitch; Uint8 *dstline, *dstcol; @@ -825,7 +825,7 @@ } static void -CopyShadowRGBToARGB (_THIS, SDL_Surface * surface) +CopyShadowRGBToARGB(_THIS, SDL_Surface * surface) { int x, y, srcpitch, dstpitch; Uint32 *dstline, *dstcol; @@ -860,7 +860,7 @@ } static void -CopyShadowRGBToABGR (_THIS, SDL_Surface * surface) +CopyShadowRGBToABGR(_THIS, SDL_Surface * surface) { int x, y, srcpitch, dstpitch; Uint32 *dstline, *dstcol; @@ -895,7 +895,7 @@ } static void -CopyShadowRGBToBGRA (_THIS, SDL_Surface * surface) +CopyShadowRGBToBGRA(_THIS, SDL_Surface * surface) { int x, y, srcpitch, dstpitch; Uint32 *dstline, *dstcol; @@ -930,7 +930,7 @@ } static void -CopyShadowRGBToRGBA (_THIS, SDL_Surface * surface) +CopyShadowRGBToRGBA(_THIS, SDL_Surface * surface) { int x, y, srcpitch, dstpitch; Uint32 *dstline, *dstcol; @@ -965,7 +965,7 @@ } static void -CopyShadow8888To555 (_THIS, SDL_Surface * surface) +CopyShadow8888To555(_THIS, SDL_Surface * surface) { int x, y, srcpitch, dstpitch; Uint16 *dstline, *dstcol; @@ -1000,7 +1000,7 @@ } static void -CopyShadow8888To565 (_THIS, SDL_Surface * surface) +CopyShadow8888To565(_THIS, SDL_Surface * surface) { int x, y, srcpitch, dstpitch; Uint16 *dstline, *dstcol; @@ -1038,12 +1038,12 @@ /*--- Conversions routines in the screen ---*/ static void -ConvertNull (_THIS, SDL_Surface * surface) +ConvertNull(_THIS, SDL_Surface * surface) { } static void -Convert565To555be (_THIS, SDL_Surface * surface) +Convert565To555be(_THIS, SDL_Surface * surface) { int x, y, pitch; unsigned short *line, *pixel; @@ -1063,7 +1063,7 @@ } static void -Convert565To555le (_THIS, SDL_Surface * surface) +Convert565To555le(_THIS, SDL_Surface * surface) { int x, y, pitch; unsigned short *line, *pixel; @@ -1076,7 +1076,7 @@ unsigned short color = *pixel; color = (color & 0x1f) | ((color >> 1) & 0xffe0); - *pixel++ = SDL_Swap16 (color); + *pixel++ = SDL_Swap16(color); } line += pitch; @@ -1084,7 +1084,7 @@ } static void -Convert565le (_THIS, SDL_Surface * surface) +Convert565le(_THIS, SDL_Surface * surface) { int x, y, pitch; unsigned short *line, *pixel; @@ -1096,7 +1096,7 @@ for (x = 0; x < surface->w; x++) { unsigned short color = *pixel; - *pixel++ = SDL_Swap16 (color); + *pixel++ = SDL_Swap16(color); } line += pitch; @@ -1104,7 +1104,7 @@ } static void -ConvertBGRAToABGR (_THIS, SDL_Surface * surface) +ConvertBGRAToABGR(_THIS, SDL_Surface * surface) { int x, y, pitch; unsigned long *line, *pixel; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_atarigl_c.h --- a/src/video/ataricommon/SDL_atarigl_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_atarigl_c.h Mon May 29 04:04:35 2006 +0000 @@ -63,14 +63,14 @@ void (*glFlush) (void); /* osmesa.ldg */ - OSMesaContext (*OSMesaCreateContextExt) (GLenum format, GLint depthBits, - GLint stencilBits, - GLint accumBits, - OSMesaContext sharelist); + OSMesaContext(*OSMesaCreateContextExt) (GLenum format, GLint depthBits, + GLint stencilBits, + GLint accumBits, + OSMesaContext sharelist); void (*OSMesaDestroyContext) (OSMesaContext ctx); - GLboolean (*OSMesaMakeCurrent) (OSMesaContext ctx, void *buffer, - GLenum type, GLsizei width, - GLsizei height); + GLboolean(*OSMesaMakeCurrent) (OSMesaContext ctx, void *buffer, + GLenum type, GLsizei width, + GLsizei height); void (*OSMesaPixelStore) (GLint pname, GLint value); void *(*OSMesaGetProcAddress) (const char *funcName); @@ -103,15 +103,15 @@ #define gl_curheight (this->gl_data->height) /* OpenGL functions */ -extern int SDL_AtariGL_Init (_THIS, SDL_Surface * current); -extern void SDL_AtariGL_Quit (_THIS, SDL_bool unload); -extern void SDL_AtariGL_InitPointers (_THIS); +extern int SDL_AtariGL_Init(_THIS, SDL_Surface * current); +extern void SDL_AtariGL_Quit(_THIS, SDL_bool unload); +extern void SDL_AtariGL_InitPointers(_THIS); -extern int SDL_AtariGL_LoadLibrary (_THIS, const char *path); -extern void *SDL_AtariGL_GetProcAddress (_THIS, const char *proc); -extern int SDL_AtariGL_GetAttribute (_THIS, SDL_GLattr attrib, int *value); -extern int SDL_AtariGL_MakeCurrent (_THIS); -extern void SDL_AtariGL_SwapBuffers (_THIS); +extern int SDL_AtariGL_LoadLibrary(_THIS, const char *path); +extern void *SDL_AtariGL_GetProcAddress(_THIS, const char *proc); +extern int SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int *value); +extern int SDL_AtariGL_MakeCurrent(_THIS); +extern void SDL_AtariGL_SwapBuffers(_THIS); #endif /* _SDL_ATARIGL_H_ */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_atarimxalloc.c --- a/src/video/ataricommon/SDL_atarimxalloc.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_atarimxalloc.c Mon May 29 04:04:35 2006 +0000 @@ -38,18 +38,18 @@ /*--- Functions ---*/ void * -Atari_SysMalloc (Uint32 size, Uint16 alloc_type) +Atari_SysMalloc(Uint32 size, Uint16 alloc_type) { /* Test if Mxalloc() available */ if (atari_mxalloc_avail < 0) { atari_mxalloc_avail = - ((Sversion () & 0xFF) >= 0x01) | (Sversion () >= 0x1900); + ((Sversion() & 0xFF) >= 0x01) | (Sversion() >= 0x1900); } if (atari_mxalloc_avail) { - return (void *) Mxalloc (size, alloc_type); + return (void *) Mxalloc(size, alloc_type); } else { - return (void *) Malloc (size); + return (void *) Malloc(size); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_atarimxalloc_c.h --- a/src/video/ataricommon/SDL_atarimxalloc_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_atarimxalloc_c.h Mon May 29 04:04:35 2006 +0000 @@ -40,7 +40,7 @@ /*--- Functions ---*/ -extern void *Atari_SysMalloc (Uint32 size, Uint16 alloc_type); +extern void *Atari_SysMalloc(Uint32 size, Uint16 alloc_type); #endif /* _SDL_ATARI_MXALLOC_H_ */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_biosevents.c --- a/src/video/ataricommon/SDL_biosevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_biosevents.c Mon May 29 04:04:35 2006 +0000 @@ -62,21 +62,21 @@ /* The translation tables from a console scancode to a SDL keysym */ static SDLKey keymap[ATARIBIOS_MAXKEYS]; -static SDL_keysym *TranslateKey (int scancode, int asciicode, - SDL_keysym * keysym, SDL_bool pressed); -static void UpdateSpecialKeys (int special_keys_state); +static SDL_keysym *TranslateKey(int scancode, int asciicode, + SDL_keysym * keysym, SDL_bool pressed); +static void UpdateSpecialKeys(int special_keys_state); void -AtariBios_InitOSKeymap (_THIS) +AtariBios_InitOSKeymap(_THIS) { int i, vectors_mask; unsigned long dummy; - SDL_memset (bios_currentkeyboard, 0, sizeof (bios_currentkeyboard)); - SDL_memset (bios_previouskeyboard, 0, sizeof (bios_previouskeyboard)); + SDL_memset(bios_currentkeyboard, 0, sizeof(bios_currentkeyboard)); + SDL_memset(bios_previouskeyboard, 0, sizeof(bios_previouskeyboard)); /* Initialize keymap */ - for (i = 0; i < sizeof (keymap); i++) + for (i = 0; i < sizeof(keymap); i++) keymap[i] = SDLK_UNKNOWN; /* Functions keys */ @@ -105,33 +105,33 @@ keymap[SCANCODE_LEFTALT] = SDLK_LALT; keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK; - use_dev_mouse = (SDL_AtariDevMouse_Open () != 0) ? SDL_TRUE : SDL_FALSE; + use_dev_mouse = (SDL_AtariDevMouse_Open() != 0) ? SDL_TRUE : SDL_FALSE; vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS; /* XBIOS joystick events */ if (!use_dev_mouse) { vectors_mask |= ATARI_XBIOS_MOUSEEVENTS; /* XBIOS mouse events */ } - if (Getcookie (C_MiNT, &dummy) == C_FOUND) { + if (Getcookie(C_MiNT, &dummy) == C_FOUND) { vectors_mask = 0; } - SDL_AtariXbios_InstallVectors (vectors_mask); + SDL_AtariXbios_InstallVectors(vectors_mask); } void -AtariBios_PumpEvents (_THIS) +AtariBios_PumpEvents(_THIS) { int i; SDL_keysym keysym; /* Update pressed keys */ - SDL_memset (bios_currentkeyboard, 0, ATARIBIOS_MAXKEYS); + SDL_memset(bios_currentkeyboard, 0, ATARIBIOS_MAXKEYS); - while (Bconstat (_CON)) { + while (Bconstat(_CON)) { unsigned long key_pressed; unsigned char asciicode, scancode; - key_pressed = Bconin (_CON); + key_pressed = Bconin(_CON); asciicode = key_pressed; scancode = key_pressed >> 16; @@ -141,36 +141,36 @@ } /* Read special keys */ - UpdateSpecialKeys (Kbshift (-1)); + UpdateSpecialKeys(Kbshift(-1)); /* Now generate events */ for (i = 0; i < ATARIBIOS_MAXKEYS; i++) { /* Key pressed ? */ if (bios_currentkeyboard[i] && !bios_previouskeyboard[i]) - SDL_PrivateKeyboard (SDL_PRESSED, - TranslateKey (i, bios_currentascii[i], - &keysym, SDL_TRUE)); + SDL_PrivateKeyboard(SDL_PRESSED, + TranslateKey(i, bios_currentascii[i], + &keysym, SDL_TRUE)); /* Key unpressed ? */ if (bios_previouskeyboard[i] && !bios_currentkeyboard[i]) - SDL_PrivateKeyboard (SDL_RELEASED, - TranslateKey (i, bios_currentascii[i], - &keysym, SDL_FALSE)); + SDL_PrivateKeyboard(SDL_RELEASED, + TranslateKey(i, bios_currentascii[i], + &keysym, SDL_FALSE)); } if (use_dev_mouse) { - SDL_AtariDevMouse_PostMouseEvents (this, SDL_TRUE); + SDL_AtariDevMouse_PostMouseEvents(this, SDL_TRUE); } else { - SDL_AtariXbios_PostMouseEvents (this, SDL_TRUE); + SDL_AtariXbios_PostMouseEvents(this, SDL_TRUE); } /* Will be previous table */ - SDL_memcpy (bios_previouskeyboard, bios_currentkeyboard, - ATARIBIOS_MAXKEYS); + SDL_memcpy(bios_previouskeyboard, bios_currentkeyboard, + ATARIBIOS_MAXKEYS); } static void -UpdateSpecialKeys (int special_keys_state) +UpdateSpecialKeys(int special_keys_state) { #define UPDATE_SPECIAL_KEYS(numbit,scancode) \ { \ @@ -180,16 +180,16 @@ } \ } - UPDATE_SPECIAL_KEYS (K_RSHIFT, SCANCODE_RIGHTSHIFT); - UPDATE_SPECIAL_KEYS (K_LSHIFT, SCANCODE_LEFTSHIFT); - UPDATE_SPECIAL_KEYS (K_CTRL, SCANCODE_LEFTCONTROL); - UPDATE_SPECIAL_KEYS (K_ALT, SCANCODE_LEFTALT); - UPDATE_SPECIAL_KEYS (K_CAPSLOCK, SCANCODE_CAPSLOCK); + UPDATE_SPECIAL_KEYS(K_RSHIFT, SCANCODE_RIGHTSHIFT); + UPDATE_SPECIAL_KEYS(K_LSHIFT, SCANCODE_LEFTSHIFT); + UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL); + UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT); + UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK); } static SDL_keysym * -TranslateKey (int scancode, int asciicode, SDL_keysym * keysym, - SDL_bool pressed) +TranslateKey(int scancode, int asciicode, SDL_keysym * keysym, + SDL_bool pressed) { /* Set the keysym information */ keysym->scancode = scancode; @@ -209,11 +209,11 @@ } void -AtariBios_ShutdownEvents (void) +AtariBios_ShutdownEvents(void) { - SDL_AtariXbios_RestoreVectors (); + SDL_AtariXbios_RestoreVectors(); if (use_dev_mouse) { - SDL_AtariDevMouse_Close (); + SDL_AtariDevMouse_Close(); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_biosevents_c.h --- a/src/video/ataricommon/SDL_biosevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_biosevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -35,9 +35,9 @@ /* Hidden "this" pointer for the video functions */ #define _THIS SDL_VideoDevice *this -extern void AtariBios_InitOSKeymap (_THIS); -extern void AtariBios_PumpEvents (_THIS); -extern void AtariBios_ShutdownEvents (void); +extern void AtariBios_InitOSKeymap(_THIS); +extern void AtariBios_PumpEvents(_THIS); +extern void AtariBios_ShutdownEvents(void); #endif /* _SDL_ATARI_BIOSEVENTS_H_ */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_gemdosevents.c --- a/src/video/ataricommon/SDL_gemdosevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_gemdosevents.c Mon May 29 04:04:35 2006 +0000 @@ -68,21 +68,21 @@ /* The translation tables from a console scancode to a SDL keysym */ static SDLKey keymap[ATARIBIOS_MAXKEYS]; -static SDL_keysym *TranslateKey (int scancode, int asciicode, - SDL_keysym * keysym, SDL_bool pressed); -static void UpdateSpecialKeys (int special_keys_state); +static SDL_keysym *TranslateKey(int scancode, int asciicode, + SDL_keysym * keysym, SDL_bool pressed); +static void UpdateSpecialKeys(int special_keys_state); void -AtariGemdos_InitOSKeymap (_THIS) +AtariGemdos_InitOSKeymap(_THIS) { int i, vectors_mask; unsigned long dummy; - SDL_memset (gemdos_currentkeyboard, 0, sizeof (gemdos_currentkeyboard)); - SDL_memset (gemdos_previouskeyboard, 0, sizeof (gemdos_previouskeyboard)); + SDL_memset(gemdos_currentkeyboard, 0, sizeof(gemdos_currentkeyboard)); + SDL_memset(gemdos_previouskeyboard, 0, sizeof(gemdos_previouskeyboard)); /* Initialize keymap */ - for (i = 0; i < sizeof (keymap); i++) + for (i = 0; i < sizeof(keymap); i++) keymap[i] = SDLK_UNKNOWN; /* Functions keys */ @@ -111,32 +111,32 @@ keymap[SCANCODE_LEFTALT] = SDLK_LALT; keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK; - use_dev_mouse = (SDL_AtariDevMouse_Open () != 0) ? SDL_TRUE : SDL_FALSE; + use_dev_mouse = (SDL_AtariDevMouse_Open() != 0) ? SDL_TRUE : SDL_FALSE; vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS; /* XBIOS joystick events */ if (!use_dev_mouse) { vectors_mask |= ATARI_XBIOS_MOUSEEVENTS; /* XBIOS mouse events */ } - if (Getcookie (C_MiNT, &dummy) == C_FOUND) { + if (Getcookie(C_MiNT, &dummy) == C_FOUND) { vectors_mask = 0; } - SDL_AtariXbios_InstallVectors (vectors_mask); + SDL_AtariXbios_InstallVectors(vectors_mask); } void -AtariGemdos_PumpEvents (_THIS) +AtariGemdos_PumpEvents(_THIS) { int i; SDL_keysym keysym; /* Update pressed keys */ - SDL_memset (gemdos_currentkeyboard, 0, ATARIBIOS_MAXKEYS); + SDL_memset(gemdos_currentkeyboard, 0, ATARIBIOS_MAXKEYS); - while (Cconis () != DEV_BUSY) { + while (Cconis() != DEV_BUSY) { unsigned long key_pressed; unsigned char scancode, asciicode; - key_pressed = Cnecin (); + key_pressed = Cnecin(); asciicode = key_pressed; scancode = key_pressed >> 16; @@ -146,36 +146,36 @@ } /* Read special keys */ - UpdateSpecialKeys (Kbshift (-1)); + UpdateSpecialKeys(Kbshift(-1)); /* Now generate events */ for (i = 0; i < ATARIBIOS_MAXKEYS; i++) { /* Key pressed ? */ if (gemdos_currentkeyboard[i] && !gemdos_previouskeyboard[i]) - SDL_PrivateKeyboard (SDL_PRESSED, - TranslateKey (i, gemdos_currentascii[i], - &keysym, SDL_TRUE)); + SDL_PrivateKeyboard(SDL_PRESSED, + TranslateKey(i, gemdos_currentascii[i], + &keysym, SDL_TRUE)); /* Key unpressed ? */ if (gemdos_previouskeyboard[i] && !gemdos_currentkeyboard[i]) - SDL_PrivateKeyboard (SDL_RELEASED, - TranslateKey (i, gemdos_currentascii[i], - &keysym, SDL_FALSE)); + SDL_PrivateKeyboard(SDL_RELEASED, + TranslateKey(i, gemdos_currentascii[i], + &keysym, SDL_FALSE)); } if (use_dev_mouse) { - SDL_AtariDevMouse_PostMouseEvents (this, SDL_TRUE); + SDL_AtariDevMouse_PostMouseEvents(this, SDL_TRUE); } else { - SDL_AtariXbios_PostMouseEvents (this, SDL_TRUE); + SDL_AtariXbios_PostMouseEvents(this, SDL_TRUE); } /* Will be previous table */ - SDL_memcpy (gemdos_previouskeyboard, gemdos_currentkeyboard, - ATARIBIOS_MAXKEYS); + SDL_memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard, + ATARIBIOS_MAXKEYS); } static void -UpdateSpecialKeys (int special_keys_state) +UpdateSpecialKeys(int special_keys_state) { #define UPDATE_SPECIAL_KEYS(numbit,scancode) \ { \ @@ -185,16 +185,16 @@ } \ } - UPDATE_SPECIAL_KEYS (K_RSHIFT, SCANCODE_RIGHTSHIFT); - UPDATE_SPECIAL_KEYS (K_LSHIFT, SCANCODE_LEFTSHIFT); - UPDATE_SPECIAL_KEYS (K_CTRL, SCANCODE_LEFTCONTROL); - UPDATE_SPECIAL_KEYS (K_ALT, SCANCODE_LEFTALT); - UPDATE_SPECIAL_KEYS (K_CAPSLOCK, SCANCODE_CAPSLOCK); + UPDATE_SPECIAL_KEYS(K_RSHIFT, SCANCODE_RIGHTSHIFT); + UPDATE_SPECIAL_KEYS(K_LSHIFT, SCANCODE_LEFTSHIFT); + UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL); + UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT); + UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK); } static SDL_keysym * -TranslateKey (int scancode, int asciicode, SDL_keysym * keysym, - SDL_bool pressed) +TranslateKey(int scancode, int asciicode, SDL_keysym * keysym, + SDL_bool pressed) { /* Set the keysym information */ keysym->scancode = scancode; @@ -214,11 +214,11 @@ } void -AtariGemdos_ShutdownEvents (void) +AtariGemdos_ShutdownEvents(void) { - SDL_AtariXbios_RestoreVectors (); + SDL_AtariXbios_RestoreVectors(); if (use_dev_mouse) { - SDL_AtariDevMouse_Close (); + SDL_AtariDevMouse_Close(); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_gemdosevents_c.h --- a/src/video/ataricommon/SDL_gemdosevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_gemdosevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -35,9 +35,9 @@ /* Hidden "this" pointer for the video functions */ #define _THIS SDL_VideoDevice *this -extern void AtariGemdos_InitOSKeymap (_THIS); -extern void AtariGemdos_PumpEvents (_THIS); -extern void AtariGemdos_ShutdownEvents (void); +extern void AtariGemdos_InitOSKeymap(_THIS); +extern void AtariGemdos_PumpEvents(_THIS); +extern void AtariGemdos_ShutdownEvents(void); #endif /* _SDL_ATARI_GEMDOSEVENTS_H_ */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_ikbdevents.c --- a/src/video/ataricommon/SDL_ikbdevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_ikbdevents.c Mon May 29 04:04:35 2006 +0000 @@ -71,18 +71,18 @@ static unsigned char *tab_unshift, *tab_shift, *tab_caps; static SDLKey keymap[ATARIBIOS_MAXKEYS]; -static SDL_keysym *TranslateKey (int scancode, int numkeytable, - SDL_keysym * keysym, SDL_bool pressed); +static SDL_keysym *TranslateKey(int scancode, int numkeytable, + SDL_keysym * keysym, SDL_bool pressed); void -AtariIkbd_InitOSKeymap (_THIS) +AtariIkbd_InitOSKeymap(_THIS) { int i; - SDL_memset (SDL_AtariIkbd_keyboard, KEY_UNDEFINED, ATARIBIOS_MAXKEYS); + SDL_memset(SDL_AtariIkbd_keyboard, KEY_UNDEFINED, ATARIBIOS_MAXKEYS); /* Initialize keymap */ - for (i = 0; i < sizeof (keymap); i++) + for (i = 0; i < sizeof(keymap); i++) keymap[i] = SDLK_UNKNOWN; /* Functions keys */ @@ -112,23 +112,23 @@ keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK; /* Read XBIOS tables for scancode -> ascii translation */ - curtables = Keytbl (KT_NOCHANGE, KT_NOCHANGE, KT_NOCHANGE); + curtables = Keytbl(KT_NOCHANGE, KT_NOCHANGE, KT_NOCHANGE); tab_unshift = curtables->unshift; tab_shift = curtables->shift; tab_caps = curtables->caps; /* Set Caps lock initial state */ - caps_state = (Kbshift (-1) & (1 << K_CAPSLOCK)); + caps_state = (Kbshift(-1) & (1 << K_CAPSLOCK)); /* Now install our handler */ SDL_AtariIkbd_mouseb = SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0; atari_prevmouseb = 0; - Supexec (SDL_AtariIkbdInstall); + Supexec(SDL_AtariIkbdInstall); } static int -atari_GetButton (int button) +atari_GetButton(int button) { switch (button) { case 0: @@ -142,7 +142,7 @@ } void -AtariIkbd_PumpEvents (_THIS) +AtariIkbd_PumpEvents(_THIS) { int i; SDL_keysym keysym; @@ -169,17 +169,17 @@ for (i = 0; i < ATARIBIOS_MAXKEYS; i++) { /* Key pressed ? */ if (SDL_AtariIkbd_keyboard[i] == KEY_PRESSED) { - SDL_PrivateKeyboard (SDL_PRESSED, - TranslateKey (i, specialkeys, &keysym, - SDL_TRUE)); + SDL_PrivateKeyboard(SDL_PRESSED, + TranslateKey(i, specialkeys, &keysym, + SDL_TRUE)); SDL_AtariIkbd_keyboard[i] = KEY_UNDEFINED; } /* Key released ? */ if (SDL_AtariIkbd_keyboard[i] == KEY_RELEASED) { - SDL_PrivateKeyboard (SDL_RELEASED, - TranslateKey (i, specialkeys, &keysym, - SDL_FALSE)); + SDL_PrivateKeyboard(SDL_RELEASED, + TranslateKey(i, specialkeys, &keysym, + SDL_FALSE)); SDL_AtariIkbd_keyboard[i] = KEY_UNDEFINED; } } @@ -188,8 +188,8 @@ /* Mouse motion ? */ if (SDL_AtariIkbd_mousex || SDL_AtariIkbd_mousey) { - SDL_PrivateMouseMotion (0, 1, SDL_AtariIkbd_mousex, - SDL_AtariIkbd_mousey); + SDL_PrivateMouseMotion(0, 1, SDL_AtariIkbd_mousex, + SDL_AtariIkbd_mousey); SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0; } @@ -202,12 +202,11 @@ prevbutton = atari_prevmouseb & (1 << i); if (curbutton && !prevbutton) { - SDL_PrivateMouseButton (SDL_PRESSED, - atari_GetButton (i), 0, 0); + SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0); } if (!curbutton && prevbutton) { - SDL_PrivateMouseButton (SDL_RELEASED, - atari_GetButton (i), 0, 0); + SDL_PrivateMouseButton(SDL_RELEASED, + atari_GetButton(i), 0, 0); } } atari_prevmouseb = SDL_AtariIkbd_mouseb; @@ -215,8 +214,8 @@ } static SDL_keysym * -TranslateKey (int scancode, int numkeytable, SDL_keysym * keysym, - SDL_bool pressed) +TranslateKey(int scancode, int numkeytable, SDL_keysym * keysym, + SDL_bool pressed) { unsigned char asciicode; @@ -251,9 +250,9 @@ } void -AtariIkbd_ShutdownEvents (void) +AtariIkbd_ShutdownEvents(void) { - Supexec (SDL_AtariIkbdUninstall); + Supexec(SDL_AtariIkbdUninstall); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_ikbdevents_c.h --- a/src/video/ataricommon/SDL_ikbdevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_ikbdevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -35,9 +35,9 @@ /* Hidden "this" pointer for the video functions */ #define _THIS SDL_VideoDevice *this -extern void AtariIkbd_InitOSKeymap (_THIS); -extern void AtariIkbd_PumpEvents (_THIS); -extern void AtariIkbd_ShutdownEvents (void); +extern void AtariIkbd_InitOSKeymap(_THIS); +extern void AtariIkbd_PumpEvents(_THIS); +extern void AtariIkbd_ShutdownEvents(void); #endif /* _SDL_ATARI_IKBDEVENTS_H_ */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_ikbdinterrupt_s.h --- a/src/video/ataricommon/SDL_ikbdinterrupt_s.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_ikbdinterrupt_s.h Mon May 29 04:04:35 2006 +0000 @@ -55,8 +55,8 @@ /* Functions */ -extern void SDL_AtariIkbdInstall (void); -extern void SDL_AtariIkbdUninstall (void); +extern void SDL_AtariIkbdInstall(void); +extern void SDL_AtariIkbdUninstall(void); #endif /* _SDL_IKBDINTERRUPT_S_H_ */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_xbiosevents.c --- a/src/video/ataricommon/SDL_xbiosevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_xbiosevents.c Mon May 29 04:04:35 2006 +0000 @@ -45,7 +45,7 @@ /* Functions */ void -SDL_AtariXbios_InstallVectors (int vectors_mask) +SDL_AtariXbios_InstallVectors(int vectors_mask) { void *oldpile; @@ -61,26 +61,26 @@ } /* Read IKBD vectors base */ - kbdvecs = Kbdvbase (); + kbdvecs = Kbdvbase(); /* Go to supervisor mode */ - oldpile = (void *) Super (0); + oldpile = (void *) Super(0); /* Install our vectors */ - SDL_AtariXbios_Install (kbdvecs, - (vectors_mask & ATARI_XBIOS_MOUSEEVENTS) ? - SDL_AtariXbios_MouseVector : NULL, - (vectors_mask & ATARI_XBIOS_JOYSTICKEVENTS) ? - SDL_AtariXbios_JoystickVector : NULL); + SDL_AtariXbios_Install(kbdvecs, + (vectors_mask & ATARI_XBIOS_MOUSEEVENTS) ? + SDL_AtariXbios_MouseVector : NULL, + (vectors_mask & ATARI_XBIOS_JOYSTICKEVENTS) ? + SDL_AtariXbios_JoystickVector : NULL); /* Back to user mode */ - Super (oldpile); + Super(oldpile); SDL_AtariXbios_enabled = 1; } void -SDL_AtariXbios_RestoreVectors (void) +SDL_AtariXbios_RestoreVectors(void) { void *oldpile; @@ -89,20 +89,20 @@ } /* Read IKBD vectors base */ - kbdvecs = Kbdvbase (); + kbdvecs = Kbdvbase(); /* Go to supervisor mode */ - oldpile = (void *) Super (NULL); + oldpile = (void *) Super(NULL); /* Reinstall system vector */ - SDL_AtariXbios_Restore (kbdvecs); + SDL_AtariXbios_Restore(kbdvecs); /* Back to user mode */ - Super (oldpile); + Super(oldpile); } static int -atari_GetButton (int button) +atari_GetButton(int button) { switch (button) { case 0: @@ -116,7 +116,7 @@ } void -SDL_AtariXbios_PostMouseEvents (_THIS, SDL_bool buttonEvents) +SDL_AtariXbios_PostMouseEvents(_THIS, SDL_bool buttonEvents) { if (SDL_AtariXbios_enabled == 0) { return; @@ -124,8 +124,8 @@ /* Mouse motion ? */ if (SDL_AtariXbios_mousex || SDL_AtariXbios_mousey) { - SDL_PrivateMouseMotion (0, 1, SDL_AtariXbios_mousex, - SDL_AtariXbios_mousey); + SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, + SDL_AtariXbios_mousey); SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0; } @@ -140,12 +140,11 @@ prevbutton = atari_prevmouseb & (1 << i); if (curbutton && !prevbutton) { - SDL_PrivateMouseButton (SDL_PRESSED, - atari_GetButton (i), 0, 0); + SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0); } if (!curbutton && prevbutton) { - SDL_PrivateMouseButton (SDL_RELEASED, - atari_GetButton (i), 0, 0); + SDL_PrivateMouseButton(SDL_RELEASED, + atari_GetButton(i), 0, 0); } } atari_prevmouseb = SDL_AtariXbios_mouseb; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_xbiosevents_c.h --- a/src/video/ataricommon/SDL_xbiosevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_xbiosevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -40,9 +40,9 @@ extern int SDL_AtariXbios_enabled; -extern void SDL_AtariXbios_InstallVectors (int vectors_mask); -extern void SDL_AtariXbios_RestoreVectors (void); -extern void SDL_AtariXbios_PostMouseEvents (_THIS, SDL_bool buttonEvents); +extern void SDL_AtariXbios_InstallVectors(int vectors_mask); +extern void SDL_AtariXbios_RestoreVectors(void); +extern void SDL_AtariXbios_PostMouseEvents(_THIS, SDL_bool buttonEvents); #endif /* _SDL_XBIOSEVENTS_H_ */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ataricommon/SDL_xbiosinterrupt_s.h --- a/src/video/ataricommon/SDL_xbiosinterrupt_s.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ataricommon/SDL_xbiosinterrupt_s.h Mon May 29 04:04:35 2006 +0000 @@ -43,11 +43,11 @@ /* Functions */ -extern void SDL_AtariXbios_Install (_KBDVECS * kbdvecs, void *newmousevector, - void *newjoystickvector); -extern void SDL_AtariXbios_Restore (_KBDVECS * kbdvecs); -extern void SDL_AtariXbios_MouseVector (void *buf); -extern void SDL_AtariXbios_JoystickVector (void *buf); +extern void SDL_AtariXbios_Install(_KBDVECS * kbdvecs, void *newmousevector, + void *newjoystickvector); +extern void SDL_AtariXbios_Restore(_KBDVECS * kbdvecs); +extern void SDL_AtariXbios_MouseVector(void *buf); +extern void SDL_AtariXbios_JoystickVector(void *buf); #endif /* _SDL_XBIOSINTERRUPT_S_H_ */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/bwindow/SDL_BView.h --- a/src/video/bwindow/SDL_BView.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/bwindow/SDL_BView.h Mon May 29 04:04:35 2006 +0000 @@ -34,25 +34,25 @@ class SDL_BView:public BView { public: - SDL_BView (BRect frame):BView (frame, "SDL View", B_FOLLOW_ALL_SIDES, - (B_WILL_DRAW | B_FRAME_EVENTS)) + SDL_BView(BRect frame):BView(frame, "SDL View", B_FOLLOW_ALL_SIDES, + (B_WILL_DRAW | B_FRAME_EVENTS)) { image = NULL; xoff = yoff = 0; - SetViewColor (0, 0, 0, 0); - SetHighColor (0, 0, 0, 0); + SetViewColor(0, 0, 0, 0); + SetHighColor(0, 0, 0, 0); } - virtual ~ SDL_BView () + virtual ~ SDL_BView() { - SetBitmap (NULL); + SetBitmap(NULL); } /* Set drawing offsets for fullscreen mode */ - virtual void SetXYOffset (int x, int y) + virtual void SetXYOffset(int x, int y) { xoff = x; yoff = y; } - virtual void GetXYOffset (int &x, int &y) + virtual void GetXYOffset(int &x, int &y) { x = xoff; y = yoff; @@ -60,30 +60,30 @@ /* The view changed size. If it means we're in fullscreen, we * draw a nice black box in the entire view to get black borders. */ - virtual void FrameResized (float width, float height) + virtual void FrameResized(float width, float height) { BRect bounds; bounds.top = bounds.left = 0; bounds.right = width; bounds.bottom = height; /* Fill the entire view with black */ - FillRect (bounds, B_SOLID_HIGH); + FillRect(bounds, B_SOLID_HIGH); /* And if there's an image, redraw it. */ if (image) { - bounds = image->Bounds (); - Draw (bounds); + bounds = image->Bounds(); + Draw(bounds); } } /* Drawing portion of this complete breakfast. :) */ - virtual void SetBitmap (BBitmap * bitmap) + virtual void SetBitmap(BBitmap * bitmap) { if (image) { delete image; } image = bitmap; } - virtual void Draw (BRect updateRect) + virtual void Draw(BRect updateRect) { if (image) { if (xoff || yoff) { @@ -92,13 +92,13 @@ dest.left = updateRect.left + xoff; dest.bottom = updateRect.bottom + yoff; dest.right = updateRect.right + xoff; - DrawBitmap (image, updateRect, dest); + DrawBitmap(image, updateRect, dest); } else { - DrawBitmap (image, updateRect, updateRect); + DrawBitmap(image, updateRect, updateRect); } } } - virtual void DrawAsync (BRect updateRect) + virtual void DrawAsync(BRect updateRect) { if (xoff || yoff) { BRect dest; @@ -106,9 +106,9 @@ dest.left = updateRect.left + xoff; dest.bottom = updateRect.bottom + yoff; dest.right = updateRect.right + xoff;; - DrawBitmapAsync (image, updateRect, dest); + DrawBitmapAsync(image, updateRect, dest); } else { - DrawBitmapAsync (image, updateRect, updateRect); + DrawBitmapAsync(image, updateRect, updateRect); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/bwindow/SDL_BWin.h --- a/src/video/bwindow/SDL_BWin.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/bwindow/SDL_BWin.h Mon May 29 04:04:35 2006 +0000 @@ -46,10 +46,10 @@ class SDL_BWin:public BDirectWindow { public: - SDL_BWin (BRect bounds):BDirectWindow (bounds, "Untitled", - B_TITLED_WINDOW, 0) + SDL_BWin(BRect bounds):BDirectWindow(bounds, "Untitled", + B_TITLED_WINDOW, 0) { - InitKeyboard (); + InitKeyboard(); last_buttons = 0; the_view = NULL; @@ -57,24 +57,24 @@ SDL_GLView = NULL; #endif SDL_View = NULL; - Unlock (); + Unlock(); shown = false; inhibit_resize = false; } - virtual ~ SDL_BWin () + virtual ~ SDL_BWin() { - Lock (); + Lock(); if (the_view) { #if SDL_VIDEO_OPENGL if (the_view == SDL_GLView) { - SDL_GLView->UnlockGL (); + SDL_GLView->UnlockGL(); } #endif - RemoveChild (the_view); + RemoveChild(the_view); the_view = NULL; } - Unlock (); + Unlock(); #if SDL_VIDEO_OPENGL if (SDL_GLView) { delete SDL_GLView; @@ -85,9 +85,9 @@ } } - virtual void InitKeyboard (void) + virtual void InitKeyboard(void) { - for (uint i = 0; i < SDL_TABLESIZE (keymap); ++i) + for (uint i = 0; i < SDL_TABLESIZE(keymap); ++i) keymap[i] = SDLK_UNKNOWN; keymap[0x01] = SDLK_ESCAPE; @@ -200,88 +200,88 @@ } /* Override the Show() method so we can tell when we've been shown */ - virtual void Show (void) + virtual void Show(void) { - BWindow::Show (); + BWindow::Show(); shown = true; } - virtual bool Shown (void) + virtual bool Shown(void) { return (shown); } /* If called, the next resize event will not be forwarded to SDL. */ - virtual void InhibitResize (void) + virtual void InhibitResize(void) { inhibit_resize = true; } /* Handle resizing of the window */ - virtual void FrameResized (float width, float height) + virtual void FrameResized(float width, float height) { if (inhibit_resize) inhibit_resize = false; else - SDL_PrivateResize ((int) width, (int) height); + SDL_PrivateResize((int) width, (int) height); } - virtual int CreateView (Uint32 flags, Uint32 gl_flags) + virtual int CreateView(Uint32 flags, Uint32 gl_flags) { int retval; retval = 0; - Lock (); + Lock(); if (flags & SDL_INTERNALOPENGL) { #if SDL_VIDEO_OPENGL if (SDL_GLView == NULL) { - SDL_GLView = new BGLView (Bounds (), "SDL GLView", - B_FOLLOW_ALL_SIDES, - (B_WILL_DRAW | B_FRAME_EVENTS), - gl_flags); + SDL_GLView = new BGLView(Bounds(), "SDL GLView", + B_FOLLOW_ALL_SIDES, + (B_WILL_DRAW | B_FRAME_EVENTS), + gl_flags); } if (the_view != SDL_GLView) { if (the_view) { - RemoveChild (the_view); + RemoveChild(the_view); } - AddChild (SDL_GLView); - SDL_GLView->LockGL (); + AddChild(SDL_GLView); + SDL_GLView->LockGL(); the_view = SDL_GLView; } #else - SDL_SetError ("OpenGL support not enabled"); + SDL_SetError("OpenGL support not enabled"); retval = -1; #endif } else { if (SDL_View == NULL) { - SDL_View = new SDL_BView (Bounds ()); + SDL_View = new SDL_BView(Bounds()); } if (the_view != SDL_View) { if (the_view) { #if SDL_VIDEO_OPENGL if (the_view == SDL_GLView) { - SDL_GLView->UnlockGL (); + SDL_GLView->UnlockGL(); } #endif - RemoveChild (the_view); + RemoveChild(the_view); } - AddChild (SDL_View); + AddChild(SDL_View); the_view = SDL_View; } } - Unlock (); + Unlock(); return (retval); } - virtual void SetBitmap (BBitmap * bitmap) + virtual void SetBitmap(BBitmap * bitmap) { - SDL_View->SetBitmap (bitmap); + SDL_View->SetBitmap(bitmap); } - virtual void SetXYOffset (int x, int y) + virtual void SetXYOffset(int x, int y) { #if SDL_VIDEO_OPENGL if (the_view == SDL_GLView) { return; } #endif - SDL_View->SetXYOffset (x, y); + SDL_View->SetXYOffset(x, y); } - virtual void GetXYOffset (int &x, int &y) + virtual void GetXYOffset(int &x, int &y) { #if SDL_VIDEO_OPENGL if (the_view == SDL_GLView) { @@ -290,49 +290,49 @@ return; } #endif - SDL_View->GetXYOffset (x, y); + SDL_View->GetXYOffset(x, y); } - virtual bool BeginDraw (void) + virtual bool BeginDraw(void) { - return (Lock ()); + return (Lock()); } - virtual void DrawAsync (BRect updateRect) + virtual void DrawAsync(BRect updateRect) { - SDL_View->DrawAsync (updateRect); + SDL_View->DrawAsync(updateRect); } - virtual void EndDraw (void) + virtual void EndDraw(void) { - SDL_View->Sync (); - Unlock (); + SDL_View->Sync(); + Unlock(); } #if SDL_VIDEO_OPENGL - virtual void SwapBuffers (void) + virtual void SwapBuffers(void) { - SDL_GLView->UnlockGL (); - SDL_GLView->LockGL (); - SDL_GLView->SwapBuffers (); + SDL_GLView->UnlockGL(); + SDL_GLView->LockGL(); + SDL_GLView->SwapBuffers(); } #endif - virtual BView *View (void) + virtual BView *View(void) { return (the_view); } /* Hook functions -- overridden */ - virtual void Minimize (bool minimize) + virtual void Minimize(bool minimize) { /* This is only called when mimimized, not when restored */ //SDL_PrivateAppActive(minimize, SDL_APPACTIVE); - BWindow::Minimize (minimize); + BWindow::Minimize(minimize); } - virtual void WindowActivated (bool active) + virtual void WindowActivated(bool active) { - SDL_PrivateAppActive (active, SDL_APPINPUTFOCUS); + SDL_PrivateAppActive(active, SDL_APPINPUTFOCUS); } - virtual bool QuitRequested (void) + virtual bool QuitRequested(void) { if (SDL_BeAppActive > 0) { - SDL_PrivateQuit (); + SDL_PrivateQuit(); /* We don't ever actually close the window here because the application should respond to the quit request, or ignore it as desired. @@ -341,14 +341,14 @@ } return (true); /* Close the app window */ } - virtual void Quit () + virtual void Quit() { - if (!IsLocked ()) - Lock (); - BDirectWindow::Quit (); + if (!IsLocked()) + Lock(); + BDirectWindow::Quit(); } - virtual int16 Translate2Unicode (const char *buf) + virtual int16 Translate2Unicode(const char *buf) { int32 state, srclen, dstlen; unsigned char destbuf[2]; @@ -356,10 +356,10 @@ if ((uchar) buf[0] > 127) { state = 0; - srclen = SDL_strlen (buf); - dstlen = sizeof (destbuf); - convert_from_utf8 (B_UNICODE_CONVERSION, buf, &srclen, - (char *) destbuf, &dstlen, &state); + srclen = SDL_strlen(buf); + dstlen = sizeof(destbuf); + convert_from_utf8(B_UNICODE_CONVERSION, buf, &srclen, + (char *) destbuf, &dstlen, &state); unicode = destbuf[0]; unicode <<= 8; unicode |= destbuf[1]; @@ -369,15 +369,15 @@ /* For some reason function keys map to control characters */ # define CTRL(X) ((X)-'@') switch (unicode) { - case CTRL ('A'): - case CTRL ('B'): - case CTRL ('C'): - case CTRL ('D'): - case CTRL ('E'): - case CTRL ('K'): - case CTRL ('L'): - case CTRL ('P'): - if (!(SDL_GetModState () & KMOD_CTRL)) + case CTRL('A'): + case CTRL('B'): + case CTRL('C'): + case CTRL('D'): + case CTRL('E'): + case CTRL('K'): + case CTRL('L'): + case CTRL('P'): + if (!(SDL_GetModState() & KMOD_CTRL)) unicode = 0; break; /* Keyboard input maps newline to carriage return */ @@ -391,30 +391,30 @@ return unicode; } - virtual void DispatchMessage (BMessage * msg, BHandler * target) + virtual void DispatchMessage(BMessage * msg, BHandler * target) { switch (msg->what) { case B_MOUSE_MOVED: { BPoint where; int32 transit; - if (msg->FindPoint ("where", &where) == B_OK - && msg->FindInt32 ("be:transit", &transit) == B_OK) { + if (msg->FindPoint("where", &where) == B_OK + && msg->FindInt32("be:transit", &transit) == B_OK) { if (transit == B_EXITED_VIEW) { - if (SDL_GetAppState () & SDL_APPMOUSEFOCUS) { - SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); - be_app->SetCursor (B_HAND_CURSOR); + if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) { + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); + be_app->SetCursor(B_HAND_CURSOR); } } else { int x, y; - if (!(SDL_GetAppState () & SDL_APPMOUSEFOCUS)) { - SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); - SDL_SetCursor (NULL); + if (!(SDL_GetAppState() & SDL_APPMOUSEFOCUS)) { + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); + SDL_SetCursor(NULL); } - GetXYOffset (x, y); + GetXYOffset(x, y); x = (int) where.x - x; y = (int) where.y - y; - SDL_PrivateMouseMotion (0, 0, x, y); + SDL_PrivateMouseMotion(0, 0, x, y); } } break; @@ -426,7 +426,7 @@ button, each next is not send while last one is holded */ int32 buttons; int sdl_buttons = 0; - if (msg->FindInt32 ("buttons", &buttons) == B_OK) { + if (msg->FindInt32("buttons", &buttons) == B_OK) { /* Add any mouse button events */ if (buttons & B_PRIMARY_MOUSE_BUTTON) { sdl_buttons |= SDL_BUTTON_LEFT; @@ -437,7 +437,7 @@ if (buttons & B_TERTIARY_MOUSE_BUTTON) { sdl_buttons |= SDL_BUTTON_MIDDLE; } - SDL_PrivateMouseButton (SDL_PRESSED, sdl_buttons, 0, 0); + SDL_PrivateMouseButton(SDL_PRESSED, sdl_buttons, 0, 0); last_buttons = buttons; } @@ -457,7 +457,7 @@ because of how drivers are written?, not BeOS itself. */ int32 buttons; int sdl_buttons = 0; - if (msg->FindInt32 ("buttons", &buttons) == B_OK) { + if (msg->FindInt32("buttons", &buttons) == B_OK) { /* Add any mouse button events */ if ((buttons ^ B_PRIMARY_MOUSE_BUTTON) & last_buttons) { sdl_buttons |= SDL_BUTTON_LEFT; @@ -468,7 +468,7 @@ if ((buttons ^ B_TERTIARY_MOUSE_BUTTON) & last_buttons) { sdl_buttons |= SDL_BUTTON_MIDDLE; } - SDL_PrivateMouseButton (SDL_RELEASED, sdl_buttons, 0, 0); + SDL_PrivateMouseButton(SDL_RELEASED, sdl_buttons, 0, 0); last_buttons = buttons; } @@ -479,18 +479,18 @@ { float x, y; x = y = 0; - if (msg->FindFloat ("be:wheel_delta_x", &x) == B_OK - && msg->FindFloat ("be:wheel_delta_y", &y) == B_OK) { + if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK + && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) { if (x < 0 || y < 0) { - SDL_PrivateMouseButton (SDL_PRESSED, - SDL_BUTTON_WHEELDOWN, 0, 0); - SDL_PrivateMouseButton (SDL_RELEASED, - SDL_BUTTON_WHEELDOWN, 0, 0); + SDL_PrivateMouseButton(SDL_PRESSED, + SDL_BUTTON_WHEELDOWN, 0, 0); + SDL_PrivateMouseButton(SDL_RELEASED, + SDL_BUTTON_WHEELDOWN, 0, 0); } else if (x > 0 || y > 0) { - SDL_PrivateMouseButton (SDL_PRESSED, - SDL_BUTTON_WHEELUP, 0, 0); - SDL_PrivateMouseButton (SDL_RELEASED, - SDL_BUTTON_WHEELUP, 0, 0); + SDL_PrivateMouseButton(SDL_PRESSED, + SDL_BUTTON_WHEELUP, 0, 0); + SDL_PrivateMouseButton(SDL_RELEASED, + SDL_BUTTON_WHEELUP, 0, 0); } } break; @@ -503,12 +503,12 @@ int32 modifiers; int32 key_repeat; /* Workaround for SDL message queue being filled too fast because of BeOS own key-repeat mechanism */ - if (msg->FindInt32 ("be:key_repeat", &key_repeat) == B_OK + if (msg->FindInt32("be:key_repeat", &key_repeat) == B_OK && key_repeat > 0) break; - if (msg->FindInt32 ("key", &key) == B_OK - && msg->FindInt32 ("modifiers", &modifiers) == B_OK) { + if (msg->FindInt32("key", &key) == B_OK + && msg->FindInt32("modifiers", &modifiers) == B_OK) { SDL_keysym keysym; keysym.scancode = key; if ((key > 0) && (key < 128)) { @@ -523,15 +523,15 @@ keysym.unicode = 0; if (SDL_TranslateUNICODE) { const char *bytes; - if (msg->FindString ("bytes", &bytes) == B_OK) { + if (msg->FindString("bytes", &bytes) == B_OK) { /* FIX THIS? this cares only about first "letter", so if someone maps some key to print "BeOS rulez!" only "B" will be used. */ - keysym.unicode = Translate2Unicode (bytes); + keysym.unicode = Translate2Unicode(bytes); } } - SDL_PrivateKeyboard (SDL_PRESSED, &keysym); + SDL_PrivateKeyboard(SDL_PRESSED, &keysym); } break; } @@ -541,8 +541,8 @@ { int32 key; int32 modifiers; - if (msg->FindInt32 ("key", &key) == B_OK - && msg->FindInt32 ("modifiers", &modifiers) == B_OK) { + if (msg->FindInt32("key", &key) == B_OK + && msg->FindInt32("modifiers", &modifiers) == B_OK) { SDL_keysym keysym; keysym.scancode = key; if ((key > 0) && (key < 128)) { @@ -554,11 +554,11 @@ keysym.unicode = 0; if (SDL_TranslateUNICODE) { const char *bytes; - if (msg->FindString ("bytes", &bytes) == B_OK) { - keysym.unicode = Translate2Unicode (bytes); + if (msg->FindString("bytes", &bytes) == B_OK) { + keysym.unicode = Translate2Unicode(bytes); } } - SDL_PrivateKeyboard (SDL_RELEASED, &keysym); + SDL_PrivateKeyboard(SDL_RELEASED, &keysym); } break; } @@ -572,7 +572,7 @@ //BDirectWindow::DispatchMessage(msg, target); break; } - BDirectWindow::DispatchMessage (msg, target); + BDirectWindow::DispatchMessage(msg, target); } private: diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/bwindow/SDL_sysevents.cc --- a/src/video/bwindow/SDL_sysevents.cc Mon May 29 03:53:21 2006 +0000 +++ b/src/video/bwindow/SDL_sysevents.cc Mon May 29 04:04:35 2006 +0000 @@ -36,11 +36,11 @@ #include "../../events/SDL_events_c.h" #include "SDL_sysevents_c.h" - void BE_PumpEvents (_THIS) + void BE_PumpEvents(_THIS) { } - void BE_InitOSKeymap (_THIS) + void BE_InitOSKeymap(_THIS) { } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/bwindow/SDL_sysevents_c.h --- a/src/video/bwindow/SDL_sysevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/bwindow/SDL_sysevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -27,6 +27,6 @@ of the native video subsystem (SDL_sysvideo.c) */ -extern void BE_InitOSKeymap (_THIS); -extern void BE_PumpEvents (_THIS); +extern void BE_InitOSKeymap(_THIS); +extern void BE_PumpEvents(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/bwindow/SDL_sysmouse.cc --- a/src/video/bwindow/SDL_sysmouse.cc Mon May 29 03:53:21 2006 +0000 +++ b/src/video/bwindow/SDL_sysmouse.cc Mon May 29 04:04:35 2006 +0000 @@ -41,9 +41,9 @@ }; /* Can this be done in the BeOS? */ - WMcursor *BE_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, - int hot_x, int hot_y) + WMcursor *BE_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, + int hot_x, int hot_y) { WMcursor *cursor; int allowed_x; @@ -55,22 +55,22 @@ allowed_y = 16; /* BeOS limitation */ if ((w > allowed_x) || (h > allowed_y)) { - SDL_SetError ("Only cursors of dimension (%dx%d) are allowed", - allowed_x, allowed_y); + SDL_SetError("Only cursors of dimension (%dx%d) are allowed", + allowed_x, allowed_y); return (NULL); } /* Allocate the cursor */ - cursor = (WMcursor *) SDL_malloc (sizeof (WMcursor)); + cursor = (WMcursor *) SDL_malloc(sizeof(WMcursor)); if (cursor == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } cursor->bits = - (char *) SDL_malloc (4 + 2 * ((allowed_x / 8) * allowed_y)); + (char *) SDL_malloc(4 + 2 * ((allowed_x / 8) * allowed_y)); if (cursor->bits == NULL) { - SDL_free (cursor); - SDL_OutOfMemory (); + SDL_free(cursor); + SDL_OutOfMemory(); return (NULL); } cursor->bits[0] = allowed_y; /* Size of the cursor */ @@ -80,16 +80,16 @@ cptr = &cursor->bits[4]; /* Pad out to the normal cursor size */ - run = PADDED_BITS (w); - pad = PADDED_BITS (allowed_x) - run; + run = PADDED_BITS(w); + pad = PADDED_BITS(allowed_x) - run; for (i = 0; i < h; ++i) { - SDL_memcpy (cptr, data, run); - SDL_memset (cptr + run, 0, pad); + SDL_memcpy(cptr, data, run); + SDL_memset(cptr + run, 0, pad); data += run; cptr += (run + pad); } for (; i < allowed_y; ++i) { - SDL_memset (cptr, 0, run + pad); + SDL_memset(cptr, 0, run + pad); cptr += (run + pad); } for (i = 0; i < h; ++i) { @@ -97,47 +97,47 @@ inverted color pixels black, since inverted color pixels aren't supported under BeOS. */ - SDL_memcpy (cptr, mask, run); - SDL_memset (cptr + run, 0, pad); + SDL_memcpy(cptr, mask, run); + SDL_memset(cptr + run, 0, pad); mask += run; cptr += (run + pad); } for (; i < allowed_y; ++i) { - SDL_memset (cptr, 0, run + pad); + SDL_memset(cptr, 0, run + pad); cptr += (run + pad); } return (cursor); } - int BE_ShowWMCursor (_THIS, WMcursor * cursor) + int BE_ShowWMCursor(_THIS, WMcursor * cursor) { - if (be_app->Lock ()) { + if (be_app->Lock()) { if (cursor == NULL) { if (SDL_BlankCursor != NULL) { - be_app->SetCursor (SDL_BlankCursor->bits); + be_app->SetCursor(SDL_BlankCursor->bits); } } else { - be_app->SetCursor (cursor->bits); + be_app->SetCursor(cursor->bits); } - be_app->Unlock (); + be_app->Unlock(); } return (1); } - void BE_FreeWMCursor (_THIS, WMcursor * cursor) + void BE_FreeWMCursor(_THIS, WMcursor * cursor) { - SDL_free (cursor->bits); - SDL_free (cursor); + SDL_free(cursor->bits); + SDL_free(cursor); } /* Implementation by Christian Bauer */ - void BE_WarpWMCursor (_THIS, Uint16 x, Uint16 y) + void BE_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { - BPoint pt (x, y); - SDL_Win->Lock (); - SDL_Win->ConvertToScreen (&pt); - SDL_Win->Unlock (); - set_mouse_position ((int32) pt.x, (int32) pt.y); + BPoint pt(x, y); + SDL_Win->Lock(); + SDL_Win->ConvertToScreen(&pt); + SDL_Win->Unlock(); + set_mouse_position((int32) pt.x, (int32) pt.y); } }; /* Extern C */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/bwindow/SDL_sysmouse_c.h --- a/src/video/bwindow/SDL_sysmouse_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/bwindow/SDL_sysmouse_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,10 +24,10 @@ #include "SDL_lowvideo.h" /* Functions to be exported */ -extern void BE_FreeWMCursor (_THIS, WMcursor * cursor); -extern WMcursor *BE_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, - int hot_x, int hot_y); -extern int BE_ShowWMCursor (_THIS, WMcursor * cursor); -extern void BE_WarpWMCursor (_THIS, Uint16 x, Uint16 y); +extern void BE_FreeWMCursor(_THIS, WMcursor * cursor); +extern WMcursor *BE_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, + int hot_x, int hot_y); +extern int BE_ShowWMCursor(_THIS, WMcursor * cursor); +extern void BE_WarpWMCursor(_THIS, Uint16 x, Uint16 y); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/bwindow/SDL_sysvideo.cc --- a/src/video/bwindow/SDL_sysvideo.cc Mon May 29 03:53:21 2006 +0000 +++ b/src/video/bwindow/SDL_sysvideo.cc Mon May 29 04:04:35 2006 +0000 @@ -44,69 +44,69 @@ #define BEOS_HIDDEN_SIZE 32 /* starting hidden window size */ /* Initialization/Query functions */ - static int BE_VideoInit (_THIS, SDL_PixelFormat * vformat); - static SDL_Rect **BE_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); - static SDL_Surface *BE_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); - static void BE_UpdateMouse (_THIS); - static int BE_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); - static void BE_VideoQuit (_THIS); + static int BE_VideoInit(_THIS, SDL_PixelFormat * vformat); + static SDL_Rect **BE_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); + static SDL_Surface *BE_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, + Uint32 flags); + static void BE_UpdateMouse(_THIS); + static int BE_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); + static void BE_VideoQuit(_THIS); /* Hardware surface functions */ - static int BE_AllocHWSurface (_THIS, SDL_Surface * surface); - static int BE_LockHWSurface (_THIS, SDL_Surface * surface); - static void BE_UnlockHWSurface (_THIS, SDL_Surface * surface); - static void BE_FreeHWSurface (_THIS, SDL_Surface * surface); + static int BE_AllocHWSurface(_THIS, SDL_Surface * surface); + static int BE_LockHWSurface(_THIS, SDL_Surface * surface); + static void BE_UnlockHWSurface(_THIS, SDL_Surface * surface); + static void BE_FreeHWSurface(_THIS, SDL_Surface * surface); - static int BE_ToggleFullScreen (_THIS, int fullscreen); - static SDL_Overlay *BE_CreateYUVOverlay (_THIS, int width, int height, - Uint32 format, - SDL_Surface * display); + static int BE_ToggleFullScreen(_THIS, int fullscreen); + static SDL_Overlay *BE_CreateYUVOverlay(_THIS, int width, int height, + Uint32 format, + SDL_Surface * display); /* OpenGL functions */ #if SDL_VIDEO_OPENGL - static int BE_GL_LoadLibrary (_THIS, const char *path); - static void *BE_GL_GetProcAddress (_THIS, const char *proc); - static int BE_GL_GetAttribute (_THIS, SDL_GLattr attrib, int *value); - static int BE_GL_MakeCurrent (_THIS); - static void BE_GL_SwapBuffers (_THIS); + static int BE_GL_LoadLibrary(_THIS, const char *path); + static void *BE_GL_GetProcAddress(_THIS, const char *proc); + static int BE_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value); + static int BE_GL_MakeCurrent(_THIS); + static void BE_GL_SwapBuffers(_THIS); #endif /* FB driver bootstrap functions */ - static int BE_Available (void) + static int BE_Available(void) { return (1); } - static void BE_DeleteDevice (SDL_VideoDevice * device) + static void BE_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } - static SDL_VideoDevice *BE_CreateDevice (int devindex) + static SDL_VideoDevice *BE_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ /* Initialization/Query functions */ @@ -168,7 +168,7 @@ BE_Available, BE_CreateDevice }; - static inline int ColorSpaceToBitsPerPixel (uint32 colorspace) + static inline int ColorSpaceToBitsPerPixel(uint32 colorspace) { int bitsperpixel; @@ -200,7 +200,7 @@ } /* Function to sort the display_list in bscreen */ - static int CompareModes (const void *A, const void *B) + static int CompareModes(const void *A, const void *B) { const display_mode *a = (display_mode *) A; const display_mode *b = (display_mode *) B; @@ -209,13 +209,13 @@ return ((b->virtual_width * b->virtual_height) - (a->virtual_width * a->virtual_height)); } else { - return (ColorSpaceToBitsPerPixel (b->space) - - ColorSpaceToBitsPerPixel (a->space)); + return (ColorSpaceToBitsPerPixel(b->space) - + ColorSpaceToBitsPerPixel(a->space)); } } /* Yes, this isn't the fastest it could be, but it works nicely */ - static int BE_AddMode (_THIS, int index, unsigned int w, unsigned int h) + static int BE_AddMode(_THIS, int index, unsigned int w, unsigned int h) { SDL_Rect *mode; int i; @@ -227,9 +227,9 @@ mode = SDL_modelist[index][i]; if ((mode->w == w) && (mode->h == h)) { #ifdef BWINDOW_DEBUG - fprintf (stderr, - "We already have mode %dx%d at %d bytes per pixel\n", - w, h, index + 1); + fprintf(stderr, + "We already have mode %dx%d at %d bytes per pixel\n", + w, h, index + 1); #endif return (0); } @@ -237,9 +237,9 @@ } /* Set up the new video mode rectangle */ - mode = (SDL_Rect *) SDL_malloc (sizeof *mode); + mode = (SDL_Rect *) SDL_malloc(sizeof *mode); if (mode == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } mode->x = 0; @@ -247,19 +247,19 @@ mode->w = w; mode->h = h; #ifdef BWINDOW_DEBUG - fprintf (stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, - index + 1); + fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, + index + 1); #endif /* Allocate the new list of modes, and fill in the new mode */ next_mode = SDL_nummodes[index]; SDL_modelist[index] = (SDL_Rect **) - SDL_realloc (SDL_modelist[index], - (1 + next_mode + 1) * sizeof (SDL_Rect *)); + SDL_realloc(SDL_modelist[index], + (1 + next_mode + 1) * sizeof(SDL_Rect *)); if (SDL_modelist[index] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); SDL_nummodes[index] = 0; - SDL_free (mode); + SDL_free(mode); return (-1); } SDL_modelist[index][next_mode] = mode; @@ -269,7 +269,7 @@ return (0); } - int BE_VideoInit (_THIS, SDL_PixelFormat * vformat) + int BE_VideoInit(_THIS, SDL_PixelFormat * vformat) { display_mode *modes; uint32 i, nmodes; @@ -277,7 +277,7 @@ BRect bounds; /* Initialize the Be Application for appserver interaction */ - if (SDL_InitBeApp () < 0) { + if (SDL_InitBeApp() < 0) { return (-1); } @@ -285,28 +285,28 @@ BScreen bscreen; /* Save the current display mode */ - bscreen.GetMode (&saved_mode); + bscreen.GetMode(&saved_mode); _this->info.current_w = saved_mode.virtual_width; _this->info.current_h = saved_mode.virtual_height; /* Determine the screen depth */ vformat->BitsPerPixel = - ColorSpaceToBitsPerPixel (bscreen.ColorSpace ()); + ColorSpaceToBitsPerPixel(bscreen.ColorSpace()); if (vformat->BitsPerPixel == 0) { - SDL_SetError ("Unknown BScreen colorspace: 0x%x", - bscreen.ColorSpace ()); + SDL_SetError("Unknown BScreen colorspace: 0x%x", + bscreen.ColorSpace()); return (-1); } /* Get the video modes we can switch to in fullscreen mode */ - bscreen.GetModeList (&modes, &nmodes); - SDL_qsort (modes, nmodes, sizeof *modes, CompareModes); + bscreen.GetModeList(&modes, &nmodes); + SDL_qsort(modes, nmodes, sizeof *modes, CompareModes); for (i = 0; i < nmodes; ++i) { - bpp = ColorSpaceToBitsPerPixel (modes[i].space); + bpp = ColorSpaceToBitsPerPixel(modes[i].space); //if ( bpp != 0 ) { // There are bugs in changing colorspace if (modes[i].space == saved_mode.space) { - BE_AddMode (_this, ((bpp + 7) / 8) - 1, - modes[i].virtual_width, modes[i].virtual_height); + BE_AddMode(_this, ((bpp + 7) / 8) - 1, + modes[i].virtual_width, modes[i].virtual_height); } } @@ -315,18 +315,18 @@ bounds.left = 0; bounds.right = BEOS_HIDDEN_SIZE; bounds.bottom = BEOS_HIDDEN_SIZE; - SDL_Win = new SDL_BWin (bounds); + SDL_Win = new SDL_BWin(bounds); #if SDL_VIDEO_OPENGL /* testgl application doesn't load library, just tries to load symbols */ /* is it correct? if so we have to load library here */ - BE_GL_LoadLibrary (_this, NULL); + BE_GL_LoadLibrary(_this, NULL); #endif /* Create the clear cursor */ - SDL_BlankCursor = BE_CreateWMCursor (_this, blank_cdata, blank_cmask, - BLANK_CWIDTH, BLANK_CHEIGHT, - BLANK_CHOTX, BLANK_CHOTY); + SDL_BlankCursor = BE_CreateWMCursor(_this, blank_cdata, blank_cmask, + BLANK_CWIDTH, BLANK_CHEIGHT, + BLANK_CHOTX, BLANK_CHOTY); /* Fill in some window manager capabilities */ _this->info.wm_available = 1; @@ -336,7 +336,7 @@ } /* We support any dimension at our bit-depth */ - SDL_Rect **BE_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) + SDL_Rect **BE_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { SDL_Rect **modes; @@ -352,12 +352,12 @@ } /* Various screen update functions available */ - static void BE_NormalUpdate (_THIS, int numrects, SDL_Rect * rects); + static void BE_NormalUpdate(_THIS, int numrects, SDL_Rect * rects); /* Find the closest display mode for fullscreen */ - static bool BE_FindClosestFSMode (_THIS, int width, int height, int bpp, - display_mode * mode) + static bool BE_FindClosestFSMode(_THIS, int width, int height, int bpp, + display_mode * mode) { BScreen bscreen; uint32 i, nmodes; @@ -365,7 +365,7 @@ display_mode *dmodes; display_mode current; float current_refresh; - bscreen.GetMode (¤t); + bscreen.GetMode(¤t); current_refresh = (1000 * current.timing.pixel_clock) / (current.timing.h_total * current.timing.v_total); @@ -379,9 +379,9 @@ } width = modes[i]->w; height = modes[i]->h; - bscreen.GetModeList (&dmodes, &nmodes); + bscreen.GetModeList(&dmodes, &nmodes); for (i = 0; i < nmodes; ++i) { - if ((bpp == ColorSpaceToBitsPerPixel (dmodes[i].space)) && + if ((bpp == ColorSpaceToBitsPerPixel(dmodes[i].space)) && (width == dmodes[i].virtual_width) && (height == dmodes[i].virtual_height)) { break; @@ -406,7 +406,7 @@ } } - static int BE_SetFullScreen (_THIS, SDL_Surface * screen, int fullscreen) + static int BE_SetFullScreen(_THIS, SDL_Surface * screen, int fullscreen) { int was_fullscreen; bool needs_unlock; @@ -416,9 +416,9 @@ int width, height, bpp; /* Set the fullscreen mode */ - was_fullscreen = SDL_Win->IsFullScreen (); - SDL_Win->SetFullScreen (fullscreen); - fullscreen = SDL_Win->IsFullScreen (); + was_fullscreen = SDL_Win->IsFullScreen(); + SDL_Win->SetFullScreen(fullscreen); + fullscreen = SDL_Win->IsFullScreen(); width = screen->w; height = screen->h; @@ -426,31 +426,31 @@ /* Set the appropriate video mode */ if (fullscreen) { bpp = screen->format->BitsPerPixel; - bscreen.GetMode (&mode); - if ((bpp != ColorSpaceToBitsPerPixel (mode.space)) || + bscreen.GetMode(&mode); + if ((bpp != ColorSpaceToBitsPerPixel(mode.space)) || (width != mode.virtual_width) || (height != mode.virtual_height)) { - if (BE_FindClosestFSMode (_this, width, height, bpp, &mode)) { - bscreen.SetMode (&mode); + if (BE_FindClosestFSMode(_this, width, height, bpp, &mode)) { + bscreen.SetMode(&mode); /* This simply stops the next resize event from being * sent to the SDL handler. */ - SDL_Win->InhibitResize (); + SDL_Win->InhibitResize(); } else { fullscreen = 0; - SDL_Win->SetFullScreen (fullscreen); + SDL_Win->SetFullScreen(fullscreen); } } } if (was_fullscreen && !fullscreen) { - bscreen.SetMode (&saved_mode); + bscreen.SetMode(&saved_mode); } - if (SDL_Win->Lock ()) { + if (SDL_Win->Lock()) { int xoff, yoff; - if (SDL_Win->Shown ()) { + if (SDL_Win->Shown()) { needs_unlock = 1; - SDL_Win->Hide (); + SDL_Win->Hide(); } else { needs_unlock = 0; } @@ -458,30 +458,30 @@ * of the BBitmap due to the InhibitResize call above. Thus the * bitmap (pixel data) never changes. */ - SDL_Win->ResizeTo (width, height); - bounds = bscreen.Frame (); + SDL_Win->ResizeTo(width, height); + bounds = bscreen.Frame(); /* Calculate offsets - used either to center window * (windowed mode) or to set drawing offsets (fullscreen mode) */ - xoff = (bounds.IntegerWidth () - width) / 2; - yoff = (bounds.IntegerHeight () - height) / 2; + xoff = (bounds.IntegerWidth() - width) / 2; + yoff = (bounds.IntegerHeight() - height) / 2; if (fullscreen) { /* Set offset for drawing */ - SDL_Win->SetXYOffset (xoff, yoff); + SDL_Win->SetXYOffset(xoff, yoff); } else { /* Center window and reset the drawing offset */ - SDL_Win->SetXYOffset (0, 0); + SDL_Win->SetXYOffset(0, 0); } if (!needs_unlock || was_fullscreen) { /* Center the window the first time */ - SDL_Win->MoveTo (xoff > 0 ? (float) xoff : 0.0f, - yoff > 0 ? (float) yoff : 0.0f); + SDL_Win->MoveTo(xoff > 0 ? (float) xoff : 0.0f, + yoff > 0 ? (float) yoff : 0.0f); } - SDL_Win->Show (); + SDL_Win->Show(); /* Unlock the window manually after the first Show() */ if (needs_unlock) { - SDL_Win->Unlock (); + SDL_Win->Unlock(); } } @@ -494,15 +494,14 @@ return (1); } - static int BE_ToggleFullScreen (_THIS, int fullscreen) + static int BE_ToggleFullScreen(_THIS, int fullscreen) { - return BE_SetFullScreen (_this, _this->screen, fullscreen); + return BE_SetFullScreen(_this, _this->screen, fullscreen); } /* FIXME: check return values and cleanup here */ - SDL_Surface *BE_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags) + SDL_Surface *BE_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { BScreen bscreen; BBitmap *bbitmap; @@ -528,24 +527,24 @@ gl_flags |= BGL_ACCUM; /* Create the view for this window, using found flags */ - if (SDL_Win->CreateView (flags, gl_flags) < 0) { + if (SDL_Win->CreateView(flags, gl_flags) < 0) { return (NULL); } current->flags = 0; /* Clear flags */ current->w = width; current->h = height; - SDL_Win->SetType (B_TITLED_WINDOW); + SDL_Win->SetType(B_TITLED_WINDOW); if (flags & SDL_NOFRAME) { current->flags |= SDL_NOFRAME; - SDL_Win->SetLook (B_NO_BORDER_WINDOW_LOOK); + SDL_Win->SetLook(B_NO_BORDER_WINDOW_LOOK); } else { if ((flags & SDL_RESIZABLE) && !(flags & SDL_INTERNALOPENGL)) { current->flags |= SDL_RESIZABLE; /* We don't want opaque resizing (TM). :-) */ - SDL_Win->SetFlags (B_OUTLINE_RESIZE); + SDL_Win->SetFlags(B_OUTLINE_RESIZE); } else { - SDL_Win->SetFlags (B_NOT_RESIZABLE | B_NOT_ZOOMABLE); + SDL_Win->SetFlags(B_NOT_RESIZABLE | B_NOT_ZOOMABLE); } } @@ -560,73 +559,73 @@ bounds.left = 0; bounds.right = width - 1; bounds.bottom = height - 1; - bbitmap = new BBitmap (bounds, bscreen.ColorSpace ()); - if (!bbitmap->IsValid ()) { - SDL_SetError ("Couldn't create screen bitmap"); + bbitmap = new BBitmap(bounds, bscreen.ColorSpace()); + if (!bbitmap->IsValid()) { + SDL_SetError("Couldn't create screen bitmap"); delete bbitmap; return (NULL); } - current->pitch = bbitmap->BytesPerRow (); - current->pixels = (void *) bbitmap->Bits (); - SDL_Win->SetBitmap (bbitmap); + current->pitch = bbitmap->BytesPerRow(); + current->pixels = (void *) bbitmap->Bits(); + SDL_Win->SetBitmap(bbitmap); _this->UpdateRects = BE_NormalUpdate; } /* Set the correct fullscreen mode */ - BE_SetFullScreen (_this, current, flags & SDL_FULLSCREEN ? 1 : 0); + BE_SetFullScreen(_this, current, flags & SDL_FULLSCREEN ? 1 : 0); /* We're done */ return (current); } /* Update the current mouse state and position */ - void BE_UpdateMouse (_THIS) + void BE_UpdateMouse(_THIS) { BPoint point; uint32 buttons; - if (SDL_Win->Lock ()) { + if (SDL_Win->Lock()) { /* Get new input state, if still active */ - if (SDL_Win->IsActive ()) { - (SDL_Win->View ())->GetMouse (&point, &buttons, true); + if (SDL_Win->IsActive()) { + (SDL_Win->View())->GetMouse(&point, &buttons, true); } else { point.x = -1; point.y = -1; } - SDL_Win->Unlock (); + SDL_Win->Unlock(); if ((point.x >= 0) && (point.x < SDL_VideoSurface->w) && (point.y >= 0) && (point.y < SDL_VideoSurface->h)) { - SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); - SDL_PrivateMouseMotion (0, 0, - (Sint16) point.x, (Sint16) point.y); + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); + SDL_PrivateMouseMotion(0, 0, + (Sint16) point.x, (Sint16) point.y); } else { - SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } } } /* We don't actually allow hardware surfaces other than the main one */ - static int BE_AllocHWSurface (_THIS, SDL_Surface * surface) + static int BE_AllocHWSurface(_THIS, SDL_Surface * surface) { return (-1); } - static void BE_FreeHWSurface (_THIS, SDL_Surface * surface) + static void BE_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } - static int BE_LockHWSurface (_THIS, SDL_Surface * surface) + static int BE_LockHWSurface(_THIS, SDL_Surface * surface) { return (0); } - static void BE_UnlockHWSurface (_THIS, SDL_Surface * surface) + static void BE_UnlockHWSurface(_THIS, SDL_Surface * surface) { return; } - static void BE_NormalUpdate (_THIS, int numrects, SDL_Rect * rects) + static void BE_NormalUpdate(_THIS, int numrects, SDL_Rect * rects) { - if (SDL_Win->BeginDraw ()) { + if (SDL_Win->BeginDraw()) { int i; for (i = 0; i < numrects; ++i) { @@ -636,31 +635,31 @@ rect.left = rects[i].x; rect.bottom = rect.top + rects[i].h - 1; rect.right = rect.left + rects[i].w - 1; - SDL_Win->DrawAsync (rect); + SDL_Win->DrawAsync(rect); } - SDL_Win->EndDraw (); + SDL_Win->EndDraw(); } } #if SDL_VIDEO_OPENGL /* Passing a NULL path means load pointers from the application */ - int BE_GL_LoadLibrary (_THIS, const char *path) + int BE_GL_LoadLibrary(_THIS, const char *path) { if (path == NULL) { if (_this->gl_config.dll_handle == NULL) { image_info info; int32 cookie = 0; - while (get_next_image_info (0, &cookie, &info) == B_OK) { + while (get_next_image_info(0, &cookie, &info) == B_OK) { void *location = NULL; if (get_image_symbol ((image_id) cookie, "glBegin", B_SYMBOL_TYPE_ANY, &location) == B_OK) { _this->gl_config.dll_handle = (void *) cookie; _this->gl_config.driver_loaded = 1; - SDL_strlcpy (_this->gl_config.driver_path, - "libGL.so", - SDL_arraysize (_this->gl_config. - driver_path)); + SDL_strlcpy(_this->gl_config.driver_path, + "libGL.so", + SDL_arraysize(_this->gl_config. + driver_path)); } } } @@ -671,7 +670,7 @@ So for now just "load" linked libGL.so :( */ if (_this->gl_config.dll_handle == NULL) { - return BE_GL_LoadLibrary (_this, NULL); + return BE_GL_LoadLibrary(_this, NULL); } /* Unload old first */ @@ -702,75 +701,75 @@ } } - void *BE_GL_GetProcAddress (_THIS, const char *proc) + void *BE_GL_GetProcAddress(_THIS, const char *proc) { if (_this->gl_config.dll_handle != NULL) { void *location = NULL; status_t err; if ((err = - get_image_symbol ((image_id) _this->gl_config.dll_handle, - proc, B_SYMBOL_TYPE_ANY, - &location)) == B_OK) { + get_image_symbol((image_id) _this->gl_config.dll_handle, + proc, B_SYMBOL_TYPE_ANY, + &location)) == B_OK) { return location; } else { - SDL_SetError ("Couldn't find OpenGL symbol"); + SDL_SetError("Couldn't find OpenGL symbol"); return NULL; } } else { - SDL_SetError ("OpenGL library not loaded"); + SDL_SetError("OpenGL library not loaded"); return NULL; } } - int BE_GL_GetAttribute (_THIS, SDL_GLattr attrib, int *value) + int BE_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) { /* FIXME? Right now BE_GL_GetAttribute shouldn't be called between glBegin() and glEnd() - it doesn't use "cached" values */ switch (attrib) { case SDL_GL_RED_SIZE: - glGetIntegerv (GL_RED_BITS, (GLint *) value); + glGetIntegerv(GL_RED_BITS, (GLint *) value); break; case SDL_GL_GREEN_SIZE: - glGetIntegerv (GL_GREEN_BITS, (GLint *) value); + glGetIntegerv(GL_GREEN_BITS, (GLint *) value); break; case SDL_GL_BLUE_SIZE: - glGetIntegerv (GL_BLUE_BITS, (GLint *) value); + glGetIntegerv(GL_BLUE_BITS, (GLint *) value); break; case SDL_GL_ALPHA_SIZE: - glGetIntegerv (GL_ALPHA_BITS, (GLint *) value); + glGetIntegerv(GL_ALPHA_BITS, (GLint *) value); break; case SDL_GL_DOUBLEBUFFER: - glGetBooleanv (GL_DOUBLEBUFFER, (GLboolean *) value); + glGetBooleanv(GL_DOUBLEBUFFER, (GLboolean *) value); break; case SDL_GL_BUFFER_SIZE: int v; - glGetIntegerv (GL_RED_BITS, (GLint *) & v); + glGetIntegerv(GL_RED_BITS, (GLint *) & v); *value = v; - glGetIntegerv (GL_GREEN_BITS, (GLint *) & v); + glGetIntegerv(GL_GREEN_BITS, (GLint *) & v); *value += v; - glGetIntegerv (GL_BLUE_BITS, (GLint *) & v); + glGetIntegerv(GL_BLUE_BITS, (GLint *) & v); *value += v; - glGetIntegerv (GL_ALPHA_BITS, (GLint *) & v); + glGetIntegerv(GL_ALPHA_BITS, (GLint *) & v); *value += v; break; case SDL_GL_DEPTH_SIZE: - glGetIntegerv (GL_DEPTH_BITS, (GLint *) value); /* Mesa creates 16 only? r5 always 32 */ + glGetIntegerv(GL_DEPTH_BITS, (GLint *) value); /* Mesa creates 16 only? r5 always 32 */ break; case SDL_GL_STENCIL_SIZE: - glGetIntegerv (GL_STENCIL_BITS, (GLint *) value); + glGetIntegerv(GL_STENCIL_BITS, (GLint *) value); break; case SDL_GL_ACCUM_RED_SIZE: - glGetIntegerv (GL_ACCUM_RED_BITS, (GLint *) value); + glGetIntegerv(GL_ACCUM_RED_BITS, (GLint *) value); break; case SDL_GL_ACCUM_GREEN_SIZE: - glGetIntegerv (GL_ACCUM_GREEN_BITS, (GLint *) value); + glGetIntegerv(GL_ACCUM_GREEN_BITS, (GLint *) value); break; case SDL_GL_ACCUM_BLUE_SIZE: - glGetIntegerv (GL_ACCUM_BLUE_BITS, (GLint *) value); + glGetIntegerv(GL_ACCUM_BLUE_BITS, (GLint *) value); break; case SDL_GL_ACCUM_ALPHA_SIZE: - glGetIntegerv (GL_ACCUM_ALPHA_BITS, (GLint *) value); + glGetIntegerv(GL_ACCUM_ALPHA_BITS, (GLint *) value); break; case SDL_GL_STEREO: case SDL_GL_MULTISAMPLEBUFFERS: @@ -782,24 +781,24 @@ return 0; } - int BE_GL_MakeCurrent (_THIS) + int BE_GL_MakeCurrent(_THIS) { /* FIXME: should we glview->unlock and then glview->lock()? */ return 0; } - void BE_GL_SwapBuffers (_THIS) + void BE_GL_SwapBuffers(_THIS) { - SDL_Win->SwapBuffers (); + SDL_Win->SwapBuffers(); } #endif /* Is the system palette settable? */ - int BE_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) + int BE_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { int i; SDL_Palette *palette; - const color_map *cmap = BScreen ().ColorMap (); + const color_map *cmap = BScreen().ColorMap(); /* Get the screen colormap */ palette = _this->screen->format->palette; @@ -811,23 +810,23 @@ return (0); } - void BE_VideoQuit (_THIS) + void BE_VideoQuit(_THIS) { int i, j; - SDL_Win->Quit (); + SDL_Win->Quit(); SDL_Win = NULL; if (SDL_BlankCursor != NULL) { - BE_FreeWMCursor (_this, SDL_BlankCursor); + BE_FreeWMCursor(_this, SDL_BlankCursor); SDL_BlankCursor = NULL; } for (i = 0; i < NUM_MODELISTS; ++i) { if (SDL_modelist[i]) { for (j = 0; SDL_modelist[i][j]; ++j) { - SDL_free (SDL_modelist[i][j]); + SDL_free(SDL_modelist[i][j]); } - SDL_free (SDL_modelist[i]); + SDL_free(SDL_modelist[i]); SDL_modelist[i] = NULL; } } @@ -835,16 +834,16 @@ if (_this->screen) { if ((_this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { BScreen bscreen; - bscreen.SetMode (&saved_mode); + bscreen.SetMode(&saved_mode); } _this->screen->pixels = NULL; } #if SDL_VIDEO_OPENGL if (_this->gl_config.dll_handle != NULL) - unload_add_on ((image_id) _this->gl_config.dll_handle); + unload_add_on((image_id) _this->gl_config.dll_handle); #endif - SDL_QuitBeApp (); + SDL_QuitBeApp(); } }; /* Extern C */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/bwindow/SDL_syswm.cc --- a/src/video/bwindow/SDL_syswm.cc Mon May 29 03:53:21 2006 +0000 +++ b/src/video/bwindow/SDL_syswm.cc Mon May 29 04:04:35 2006 +0000 @@ -29,23 +29,23 @@ #include "SDL_syswm_c.h" #include "SDL_error.h" - void BE_SetWMCaption (_THIS, const char *title, const char *icon) + void BE_SetWMCaption(_THIS, const char *title, const char *icon) { - SDL_Win->SetTitle (title); + SDL_Win->SetTitle(title); } - int BE_IconifyWindow (_THIS) + int BE_IconifyWindow(_THIS) { - SDL_Win->Minimize (true); + SDL_Win->Minimize(true); } - int BE_GetWMInfo (_THIS, SDL_SysWMinfo * info) + int BE_GetWMInfo(_THIS, SDL_SysWMinfo * info) { if (info->version.major <= SDL_MAJOR_VERSION) { return 1; } else { - SDL_SetError ("Application not compiled with SDL %d.%d\n", - SDL_MAJOR_VERSION, SDL_MINOR_VERSION); + SDL_SetError("Application not compiled with SDL %d.%d\n", + SDL_MAJOR_VERSION, SDL_MINOR_VERSION); return -1; } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/bwindow/SDL_syswm_c.h --- a/src/video/bwindow/SDL_syswm_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/bwindow/SDL_syswm_c.h Mon May 29 04:04:35 2006 +0000 @@ -26,7 +26,7 @@ /* Functions to be exported */ -extern void BE_SetWMCaption (_THIS, const char *title, const char *icon); -extern int BE_IconifyWindow (_THIS); -extern int BE_GetWMInfo (_THIS, SDL_SysWMinfo * info); +extern void BE_SetWMCaption(_THIS, const char *title, const char *icon); +extern int BE_IconifyWindow(_THIS); +extern int BE_GetWMInfo(_THIS, SDL_SysWMinfo * info); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/bwindow/SDL_sysyuv.cc --- a/src/video/bwindow/SDL_sysyuv.cc Mon May 29 03:53:21 2006 +0000 +++ b/src/video/bwindow/SDL_sysyuv.cc Mon May 29 04:04:35 2006 +0000 @@ -38,18 +38,18 @@ BE_FreeYUVOverlay }; - BBitmap *BE_GetOverlayBitmap (BRect bounds, color_space cs) + BBitmap *BE_GetOverlayBitmap(BRect bounds, color_space cs) { BBitmap *bbitmap; - bbitmap = new BBitmap (bounds, B_BITMAP_WILL_OVERLAY, cs); - if (!bbitmap || bbitmap->InitCheck () != B_OK) { + bbitmap = new BBitmap(bounds, B_BITMAP_WILL_OVERLAY, cs); + if (!bbitmap || bbitmap->InitCheck() != B_OK) { delete bbitmap; return 0; } overlay_restrictions r; - bbitmap->GetOverlayRestrictions (&r); - uint32 width = bounds.IntegerWidth () + 1; - uint32 height = bounds.IntegerHeight () + 1; + bbitmap->GetOverlayRestrictions(&r); + uint32 width = bounds.IntegerWidth() + 1; + uint32 height = bounds.IntegerHeight() + 1; uint32 width_padding = 0; uint32 height_padding = 0; if ((r.source.horizontal_alignment != 0) || @@ -66,10 +66,9 @@ if (r.source.height_alignment != 0) { uint32 aligned_height = r.source.height_alignment + 1; if (height % aligned_height > 0) { - fprintf (stderr, - "GetOverlayBitmap failed height alignment\n"); - fprintf (stderr, "- height = %lu, aligned_height = %lu\n", - height, aligned_height); + fprintf(stderr, "GetOverlayBitmap failed height alignment\n"); + fprintf(stderr, "- height = %lu, aligned_height = %lu\n", + height, aligned_height); delete bbitmap; return 0; } @@ -77,18 +76,18 @@ if ((r.source.min_width > width) || (r.source.min_height > height) || (r.source.max_width < width) || (r.source.max_height < height)) { - fprintf (stderr, "GetOverlayBitmap failed bounds tests\n"); + fprintf(stderr, "GetOverlayBitmap failed bounds tests\n"); delete bbitmap; return 0; } if ((width_padding != 0) || (height_padding != 0)) { delete bbitmap; - bounds.Set (bounds.left, bounds.top, - bounds.right + width_padding, - bounds.bottom + height_padding); - bbitmap = new BBitmap (bounds, B_BITMAP_WILL_OVERLAY, cs); - if (!bbitmap || bbitmap->InitCheck () != B_OK) { - fprintf (stderr, "GetOverlayBitmap failed late\n"); + bounds.Set(bounds.left, bounds.top, + bounds.right + width_padding, + bounds.bottom + height_padding); + bbitmap = new BBitmap(bounds, B_BITMAP_WILL_OVERLAY, cs); + if (!bbitmap || bbitmap->InitCheck() != B_OK) { + fprintf(stderr, "GetOverlayBitmap failed late\n"); delete bbitmap; return 0; } @@ -98,7 +97,7 @@ // See [btw: Cb=U, Cr=V] // See also http://www.fourcc.org/indexyuv.htm - enum color_space convert_color_space (Uint32 format) + enum color_space convert_color_space(Uint32 format) { switch (format) { case SDL_YV12_OVERLAY: @@ -117,7 +116,7 @@ } // See SDL_video.h - int count_planes (Uint32 format) + int count_planes(Uint32 format) { switch (format) { case SDL_YV12_OVERLAY: @@ -132,8 +131,8 @@ } } - SDL_Overlay *BE_CreateYUVOverlay (_THIS, int width, int height, - Uint32 format, SDL_Surface * display) + SDL_Overlay *BE_CreateYUVOverlay(_THIS, int width, int height, + Uint32 format, SDL_Surface * display) { SDL_Overlay *overlay; struct private_yuvhwdata *hwdata; @@ -143,13 +142,13 @@ color_space cs; /* find the appropriate BeOS colorspace descriptor */ - cs = convert_color_space (format); + cs = convert_color_space(format); if (cs == B_NO_COLOR_SPACE) { return NULL; } /* count planes */ - planes = count_planes (format); + planes = count_planes(format); if (planes == 0) { return NULL; } @@ -159,10 +158,10 @@ } /* Create the overlay structure */ - overlay = (SDL_Overlay *) SDL_calloc (1, sizeof (SDL_Overlay)); + overlay = (SDL_Overlay *) SDL_calloc(1, sizeof(SDL_Overlay)); if (overlay == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return NULL; } @@ -177,13 +176,13 @@ /* Create the pixel data and lookup tables */ hwdata = - (struct private_yuvhwdata *) SDL_calloc (1, - sizeof (struct - private_yuvhwdata)); + (struct private_yuvhwdata *) SDL_calloc(1, + sizeof(struct + private_yuvhwdata)); if (hwdata == NULL) { - SDL_OutOfMemory (); - SDL_FreeYUVOverlay (overlay); + SDL_OutOfMemory(); + SDL_FreeYUVOverlay(overlay); return NULL; } @@ -200,60 +199,60 @@ bounds.bottom = height - 1; BView *bview = - new BView (bounds, "overlay", B_FOLLOW_NONE, B_WILL_DRAW); + new BView(bounds, "overlay", B_FOLLOW_NONE, B_WILL_DRAW); if (!bview) { - SDL_OutOfMemory (); - SDL_FreeYUVOverlay (overlay); + SDL_OutOfMemory(); + SDL_FreeYUVOverlay(overlay); return NULL; } overlay->hwdata->bview = bview; overlay->hwdata->first_display = true; - bview->Hide (); + bview->Hide(); - bbitmap = BE_GetOverlayBitmap (bounds, cs); + bbitmap = BE_GetOverlayBitmap(bounds, cs); if (!bbitmap) { overlay->hwdata->bbitmap = NULL; - SDL_FreeYUVOverlay (overlay); + SDL_FreeYUVOverlay(overlay); return NULL; } overlay->hwdata->bbitmap = bbitmap; overlay->planes = planes; overlay->pitches = - (Uint16 *) SDL_calloc (overlay->planes, sizeof (Uint16)); + (Uint16 *) SDL_calloc(overlay->planes, sizeof(Uint16)); overlay->pixels = - (Uint8 **) SDL_calloc (overlay->planes, sizeof (Uint8 *)); + (Uint8 **) SDL_calloc(overlay->planes, sizeof(Uint8 *)); if (!overlay->pitches || !overlay->pixels) { - SDL_OutOfMemory (); - SDL_FreeYUVOverlay (overlay); + SDL_OutOfMemory(); + SDL_FreeYUVOverlay(overlay); return (NULL); } - overlay->pitches[0] = bbitmap->BytesPerRow (); - overlay->pixels[0] = (Uint8 *) bbitmap->Bits (); + overlay->pitches[0] = bbitmap->BytesPerRow(); + overlay->pixels[0] = (Uint8 *) bbitmap->Bits(); overlay->hw_overlay = 1; - if (SDL_Win->LockWithTimeout (1000000) != B_OK) { - SDL_FreeYUVOverlay (overlay); + if (SDL_Win->LockWithTimeout(1000000) != B_OK) { + SDL_FreeYUVOverlay(overlay); return (NULL); } - BView *view = SDL_Win->View (); - view->AddChild (bview); + BView *view = SDL_Win->View(); + view->AddChild(bview); rgb_color key; - bview->SetViewOverlay (bbitmap, bounds, bview->Bounds (), &key, - B_FOLLOW_ALL, - B_OVERLAY_FILTER_HORIZONTAL | - B_OVERLAY_FILTER_VERTICAL); - bview->SetViewColor (key); - bview->Flush (); - SDL_Win->Unlock (); + bview->SetViewOverlay(bbitmap, bounds, bview->Bounds(), &key, + B_FOLLOW_ALL, + B_OVERLAY_FILTER_HORIZONTAL | + B_OVERLAY_FILTER_VERTICAL); + bview->SetViewColor(key); + bview->Flush(); + SDL_Win->Unlock(); current_overlay = overlay; return overlay; } - int BE_LockYUVOverlay (_THIS, SDL_Overlay * overlay) + int BE_LockYUVOverlay(_THIS, SDL_Overlay * overlay) { if (overlay == NULL) { return 0; @@ -263,7 +262,7 @@ return 0; } - void BE_UnlockYUVOverlay (_THIS, SDL_Overlay * overlay) + void BE_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay) { if (overlay == NULL) { return; @@ -272,36 +271,36 @@ overlay->hwdata->locked = 0; } - int BE_DisplayYUVOverlay (_THIS, SDL_Overlay * overlay, SDL_Rect * src, - SDL_Rect * dst) + int BE_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, SDL_Rect * src, + SDL_Rect * dst) { if ((overlay == NULL) || (overlay->hwdata == NULL) - || (overlay->hwdata->bview == NULL) || (SDL_Win->View () == NULL)) { + || (overlay->hwdata->bview == NULL) || (SDL_Win->View() == NULL)) { return -1; } - if (SDL_Win->LockWithTimeout (50000) != B_OK) { + if (SDL_Win->LockWithTimeout(50000) != B_OK) { return 0; } BView *bview = overlay->hwdata->bview; - if (SDL_Win->IsFullScreen ()) { + if (SDL_Win->IsFullScreen()) { int left, top; - SDL_Win->GetXYOffset (left, top); - bview->MoveTo (left + dst->x, top + dst->y); + SDL_Win->GetXYOffset(left, top); + bview->MoveTo(left + dst->x, top + dst->y); } else { - bview->MoveTo (dst->x, dst->y); + bview->MoveTo(dst->x, dst->y); } - bview->ResizeTo (dst->w, dst->h); - bview->Flush (); + bview->ResizeTo(dst->w, dst->h); + bview->Flush(); if (overlay->hwdata->first_display) { - bview->Show (); + bview->Show(); overlay->hwdata->first_display = false; } - SDL_Win->Unlock (); + SDL_Win->Unlock(); return 0; } - void BE_FreeYUVOverlay (_THIS, SDL_Overlay * overlay) + void BE_FreeYUVOverlay(_THIS, SDL_Overlay * overlay) { if (overlay == NULL) { return; @@ -315,7 +314,7 @@ delete overlay->hwdata->bbitmap; - SDL_free (overlay->hwdata); + SDL_free(overlay->hwdata); } }; // extern "C" diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/bwindow/SDL_sysyuv.h --- a/src/video/bwindow/SDL_sysyuv.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/bwindow/SDL_sysyuv.h Mon May 29 04:04:35 2006 +0000 @@ -62,15 +62,15 @@ int locked; }; - extern BBitmap *BE_GetOverlayBitmap (BRect bounds, color_space cs); - extern SDL_Overlay *BE_CreateYUVOverlay (_THIS, int width, int height, - Uint32 format, - SDL_Surface * display); - extern int BE_LockYUVOverlay (_THIS, SDL_Overlay * overlay); - extern void BE_UnlockYUVOverlay (_THIS, SDL_Overlay * overlay); - extern int BE_DisplayYUVOverlay (_THIS, SDL_Overlay * overlay, - SDL_Rect * src, SDL_Rect * dst); - extern void BE_FreeYUVOverlay (_THIS, SDL_Overlay * overlay); + extern BBitmap *BE_GetOverlayBitmap(BRect bounds, color_space cs); + extern SDL_Overlay *BE_CreateYUVOverlay(_THIS, int width, int height, + Uint32 format, + SDL_Surface * display); + extern int BE_LockYUVOverlay(_THIS, SDL_Overlay * overlay); + extern void BE_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay); + extern int BE_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, + SDL_Rect * src, SDL_Rect * dst); + extern void BE_FreeYUVOverlay(_THIS, SDL_Overlay * overlay); }; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/cybergfx/SDL_amigaevents.c --- a/src/video/cybergfx/SDL_amigaevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/cybergfx/SDL_amigaevents.c Mon May 29 04:04:35 2006 +0000 @@ -37,7 +37,7 @@ /* The translation tables from an Amiga keysym to a SDL keysym */ static SDLKey MISC_keymap[256]; -SDL_keysym *amiga_TranslateKey (int code, SDL_keysym * keysym); +SDL_keysym *amiga_TranslateKey(int code, SDL_keysym * keysym); struct IOStdReq *ConReq = NULL; struct MsgPort *ConPort = NULL; @@ -51,7 +51,7 @@ #if 0 static inline int -amiga_WarpedMotion (_THIS, struct IntuiMessage *m) +amiga_WarpedMotion(_THIS, struct IntuiMessage *m) { int w, h, i; int deltax, deltay; @@ -62,33 +62,33 @@ deltax = xevent->xmotion.x - mouse_last.x; deltay = xevent->xmotion.y - mouse_last.y; #ifdef DEBUG_MOTION - printf ("Warped mouse motion: %d,%d\n", deltax, deltay); + printf("Warped mouse motion: %d,%d\n", deltax, deltay); #endif mouse_last.x = xevent->xmotion.x; mouse_last.y = xevent->xmotion.y; - posted = SDL_PrivateMouseMotion (0, 1, deltax, deltay); + posted = SDL_PrivateMouseMotion(0, 1, deltax, deltay); if ((xevent->xmotion.x < MOUSE_FUDGE_FACTOR) || (xevent->xmotion.x > (w - MOUSE_FUDGE_FACTOR)) || (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) || (xevent->xmotion.y > (h - MOUSE_FUDGE_FACTOR))) { /* Get the events that have accumulated */ - while (XCheckTypedEvent (SDL_Display, MotionNotify, xevent)) { + while (XCheckTypedEvent(SDL_Display, MotionNotify, xevent)) { deltax = xevent->xmotion.x - mouse_last.x; deltay = xevent->xmotion.y - mouse_last.y; #ifdef DEBUG_MOTION - printf ("Extra mouse motion: %d,%d\n", deltax, deltay); + printf("Extra mouse motion: %d,%d\n", deltax, deltay); #endif mouse_last.x = xevent->xmotion.x; mouse_last.y = xevent->xmotion.y; - posted += SDL_PrivateMouseMotion (0, 1, deltax, deltay); + posted += SDL_PrivateMouseMotion(0, 1, deltax, deltay); } mouse_last.x = w / 2; mouse_last.y = h / 2; - XWarpPointer (SDL_Display, None, SDL_Window, 0, 0, 0, 0, - mouse_last.x, mouse_last.y); + XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, + mouse_last.x, mouse_last.y); for (i = 0; i < 10; ++i) { - XMaskEvent (SDL_Display, PointerMotionMask, xevent); + XMaskEvent(SDL_Display, PointerMotionMask, xevent); if ((xevent->xmotion.x > (mouse_last.x - MOUSE_FUDGE_FACTOR)) && (xevent->xmotion.x < @@ -99,13 +99,13 @@ break; } #ifdef DEBUG_XEVENTS - printf ("Lost mouse motion: %d,%d\n", xevent->xmotion.x, - xevent->xmotion.y); + printf("Lost mouse motion: %d,%d\n", xevent->xmotion.x, + xevent->xmotion.y); #endif } #ifdef DEBUG_XEVENTS if (i == 10) { - printf ("Warning: didn't detect mouse warp motion\n"); + printf("Warning: didn't detect mouse warp motion\n"); } #endif } @@ -115,7 +115,7 @@ #endif static int -amiga_GetButton (int code) +amiga_GetButton(int code) { switch (code) { case IECODE_MBUTTON: @@ -128,7 +128,7 @@ } static int -amiga_DispatchEvent (_THIS, struct IntuiMessage *msg) +amiga_DispatchEvent(_THIS, struct IntuiMessage *msg) { int class = msg->Class, code = msg->Code; int posted; @@ -137,40 +137,40 @@ switch (class) { /* Gaining mouse coverage? */ case IDCMP_ACTIVEWINDOW: - posted = SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); + posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); break; /* Losing mouse coverage? */ case IDCMP_INACTIVEWINDOW: - posted = SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); + posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); break; #if 0 /* Gaining input focus? */ case IDCMP_ACTIVEWINDOW: - posted = SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS); + posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); /* Queue entry into fullscreen mode */ switch_waiting = 0x01 | SDL_FULLSCREEN; - switch_time = SDL_GetTicks () + 1500; + switch_time = SDL_GetTicks() + 1500; break; /* Losing input focus? */ case IDCMP_INACTIVEWINDOW: - posted = SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS); + posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); /* Queue leaving fullscreen mode */ switch_waiting = 0x01; - switch_time = SDL_GetTicks () + 200; + switch_time = SDL_GetTicks() + 200; break; #endif /* Mouse motion? */ case IDCMP_MOUSEMOVE: if (SDL_VideoSurface) { - posted = SDL_PrivateMouseMotion (0, 0, - msg->MouseX - - SDL_Window->BorderLeft, - msg->MouseY - - SDL_Window->BorderTop); + posted = SDL_PrivateMouseMotion(0, 0, + msg->MouseX - + SDL_Window->BorderLeft, + msg->MouseY - + SDL_Window->BorderTop); } break; @@ -178,14 +178,14 @@ case IDCMP_MOUSEBUTTONS: if (!(code & IECODE_UP_PREFIX)) { - posted = SDL_PrivateMouseButton (SDL_PRESSED, - amiga_GetButton (code), 0, 0); + posted = SDL_PrivateMouseButton(SDL_PRESSED, + amiga_GetButton(code), 0, 0); } /* Mouse button release? */ else { code &= ~IECODE_UP_PREFIX; - posted = SDL_PrivateMouseButton (SDL_RELEASED, - amiga_GetButton (code), 0, 0); + posted = SDL_PrivateMouseButton(SDL_RELEASED, + amiga_GetButton(code), 0, 0); } break; @@ -195,8 +195,8 @@ if (!(code & IECODE_UP_PREFIX)) { SDL_keysym keysym; - posted = SDL_PrivateKeyboard (SDL_PRESSED, - amiga_TranslateKey (code, &keysym)); + posted = SDL_PrivateKeyboard(SDL_PRESSED, + amiga_TranslateKey(code, &keysym)); } else { /* Key release? */ @@ -206,8 +206,8 @@ /* Check to see if this is a repeated key */ /* if ( ! X11_KeyRepeat(SDL_Display, &xevent) ) */ - posted = SDL_PrivateKeyboard (SDL_RELEASED, - amiga_TranslateKey (code, &keysym)); + posted = SDL_PrivateKeyboard(SDL_RELEASED, + amiga_TranslateKey(code, &keysym)); } break; /* Have we been iconified? */ @@ -215,10 +215,10 @@ case UnmapNotify: { #ifdef DEBUG_XEVENTS - printf ("UnmapNotify!\n"); + printf("UnmapNotify!\n"); #endif posted = - SDL_PrivateAppActive (0, SDL_APPACTIVE | SDL_APPINPUTFOCUS); + SDL_PrivateAppActive(0, SDL_APPACTIVE | SDL_APPINPUTFOCUS); } break; @@ -227,41 +227,41 @@ case MapNotify: { #ifdef DEBUG_XEVENTS - printf ("MapNotify!\n"); + printf("MapNotify!\n"); #endif - posted = SDL_PrivateAppActive (1, SDL_APPACTIVE); + posted = SDL_PrivateAppActive(1, SDL_APPACTIVE); if (SDL_VideoSurface && (SDL_VideoSurface->flags & SDL_FULLSCREEN)) { - CGX_EnterFullScreen (this); + CGX_EnterFullScreen(this); } else { - X11_GrabInputNoLock (this, this->input_grab); + X11_GrabInputNoLock(this, this->input_grab); } if (SDL_VideoSurface) { - CGX_RefreshDisplay (this); + CGX_RefreshDisplay(this); } } break; case Expose: if (SDL_VideoSurface && (xevent.xexpose.count == 0)) { - CGX_RefreshDisplay (this); + CGX_RefreshDisplay(this); } break; #endif /* Have we been resized? */ case IDCMP_NEWSIZE: - SDL_PrivateResize (SDL_Window->Width - SDL_Window->BorderLeft - - SDL_Window->BorderRight, - SDL_Window->Height - SDL_Window->BorderTop - - SDL_Window->BorderBottom); + SDL_PrivateResize(SDL_Window->Width - SDL_Window->BorderLeft - + SDL_Window->BorderRight, + SDL_Window->Height - SDL_Window->BorderTop - + SDL_Window->BorderBottom); break; /* Have we been requested to quit? */ case IDCMP_CLOSEWINDOW: - posted = SDL_PrivateQuit (); + posted = SDL_PrivateQuit(); break; /* Do we need to refresh ourselves? */ @@ -272,43 +272,43 @@ if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) { SDL_SysWMmsg wmmsg; - SDL_VERSION (&wmmsg.version); + SDL_VERSION(&wmmsg.version); #if 0 wmmsg.subsystem = SDL_SYSWM_CGX; wmmsg.event.xevent = xevent; #endif - posted = SDL_PrivateSysWMEvent (&wmmsg); + posted = SDL_PrivateSysWMEvent(&wmmsg); } } break; } - ReplyMsg ((struct Message *) msg); + ReplyMsg((struct Message *) msg); return (posted); } void -amiga_PumpEvents (_THIS) +amiga_PumpEvents(_THIS) { int pending; struct IntuiMessage *m; /* Keep processing pending events */ pending = 0; - while (m = (struct IntuiMessage *) GetMsg (SDL_Window->UserPort)) { - amiga_DispatchEvent (this, m); + while (m = (struct IntuiMessage *) GetMsg(SDL_Window->UserPort)) { + amiga_DispatchEvent(this, m); ++pending; } } void -amiga_InitKeymap (void) +amiga_InitKeymap(void) { int i; /* Map the miscellaneous keys */ - for (i = 0; i < SDL_arraysize (MISC_keymap); ++i) + for (i = 0; i < SDL_arraysize(MISC_keymap); ++i) MISC_keymap[i] = SDLK_UNKNOWN; /* These X keysyms have 0xFF as the high byte */ @@ -430,7 +430,7 @@ } SDL_keysym * -amiga_TranslateKey (int code, SDL_keysym * keysym) +amiga_TranslateKey(int code, SDL_keysym * keysym) { #ifdef STORMC4_WOS static struct Library *KeymapBase = NULL; /* Linking failed in WOS version if ConsoleDevice was used */ @@ -443,7 +443,7 @@ keysym->sym = MISC_keymap[code]; #ifdef DEBUG_KEYS - fprintf (stderr, "Translating key 0x%.4x (%d)\n", xsym, xkey->keycode); + fprintf(stderr, "Translating key 0x%.4x (%d)\n", xsym, xkey->keycode); #endif /* Get the translated SDL virtual keysym */ if (keysym->sym == SDLK_UNKNOWN) { @@ -454,21 +454,21 @@ #endif { #ifdef STORMC4_WOS - KeymapBase = OpenLibrary ("keymap.library", 0L); + KeymapBase = OpenLibrary("keymap.library", 0L); #else - if (ConPort = CreateMsgPort ()) { + if (ConPort = CreateMsgPort()) { if (ConReq = - CreateIORequest (ConPort, sizeof (struct IOStdReq))) { + CreateIORequest(ConPort, sizeof(struct IOStdReq))) { if (!OpenDevice ("console.device", -1, (struct IORequest *) ConReq, 0)) ConsoleDevice = (struct Library *) ConReq->io_Device; else { - DeleteIORequest (ConReq); + DeleteIORequest(ConReq); ConReq = NULL; } } else { - DeleteMsgPort (ConPort); + DeleteMsgPort(ConPort); ConPort = NULL; } } @@ -495,17 +495,16 @@ event.ie_Prev2DownCode = event.ie_Prev2DownQual = 0; #ifdef STORMC4_WOS - if ((actual = MapRawKey (&event, buffer, 5, NULL)) >= 0) + if ((actual = MapRawKey(&event, buffer, 5, NULL)) >= 0) #else - if ((actual = RawKeyConvert (&event, buffer, 5, NULL)) >= 0) + if ((actual = RawKeyConvert(&event, buffer, 5, NULL)) >= 0) #endif { if (actual > 1) { - D (bug ("Warning (%ld) character conversion!\n", actual)); + D(bug("Warning (%ld) character conversion!\n", actual)); } else if (actual == 1) { keysym->sym = *buffer; - D (bug - ("Converted rawcode %ld to <%lc>\n", code, *buffer)); + D(bug("Converted rawcode %ld to <%lc>\n", code, *buffer)); // Bufferizzo x le successive chiamate! MISC_keymap[code] = *buffer; } @@ -522,8 +521,8 @@ static XComposeStatus state; /* Until we handle the IM protocol, use XLookupString() */ unsigned char keybuf[32]; - if (XLookupString (xkey, (char *) keybuf, sizeof (keybuf), - NULL, &state)) { + if (XLookupString(xkey, (char *) keybuf, sizeof(keybuf), + NULL, &state)) { keysym->unicode = keybuf[0]; } #endif @@ -532,9 +531,9 @@ } void -amiga_InitOSKeymap (_THIS) +amiga_InitOSKeymap(_THIS) { - amiga_InitKeymap (); + amiga_InitKeymap(); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/cybergfx/SDL_amigaevents_c.h --- a/src/video/cybergfx/SDL_amigaevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/cybergfx/SDL_amigaevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,6 +24,6 @@ #include "SDL_cgxvideo.h" /* Functions to be exported */ -extern void amiga_InitOSKeymap (_THIS); -extern void amiga_PumpEvents (_THIS); +extern void amiga_InitOSKeymap(_THIS); +extern void amiga_PumpEvents(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/cybergfx/SDL_amigamouse.c --- a/src/video/cybergfx/SDL_amigamouse.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/cybergfx/SDL_amigamouse.c Mon May 29 04:04:35 2006 +0000 @@ -32,20 +32,20 @@ typedef void *WMCursor; void -amiga_FreeWMCursor (_THIS, WMcursor * cursor) +amiga_FreeWMCursor(_THIS, WMcursor * cursor) { } WMcursor * -amiga_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, int hot_x, - int hot_y) +amiga_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, int hot_x, + int hot_y) { return (WMcursor *) 1; // Amiga has an Hardware cursor, so it's ok to return something unuseful but true } int -amiga_ShowWMCursor (_THIS, WMcursor * cursor) +amiga_ShowWMCursor(_THIS, WMcursor * cursor) { /* Don't do anything if the display is gone */ if (SDL_Display == NULL) { @@ -55,31 +55,30 @@ /* Set the Amiga prefs cursor cursor, or blank if cursor is NULL */ if (SDL_Window) { - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); if (cursor == NULL) { if (SDL_BlankCursor != NULL) { // Hide cursor HERE - SetPointer (SDL_Window, (UWORD *) SDL_BlankCursor, 1, 1, - 0, 0); + SetPointer(SDL_Window, (UWORD *) SDL_BlankCursor, 1, 1, 0, 0); } } else { // Show cursor - ClearPointer (SDL_Window); + ClearPointer(SDL_Window); } - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); } return (1); } void -amiga_WarpWMCursor (_THIS, Uint16 x, Uint16 y) +amiga_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { /* FIXME: Not implemented */ } /* Check to see if we need to enter or leave mouse relative mode */ void -amiga_CheckMouseMode (_THIS) +amiga_CheckMouseMode(_THIS) { } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/cybergfx/SDL_amigamouse_c.h --- a/src/video/cybergfx/SDL_amigamouse_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/cybergfx/SDL_amigamouse_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,11 +24,11 @@ #include "SDL_cgxvideo.h" /* Functions to be exported */ -extern void amiga_FreeWMCursor (_THIS, WMcursor * cursor); -extern WMcursor *amiga_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, - int h, int hot_x, int hot_y); -extern int amiga_ShowWMCursor (_THIS, WMcursor * cursor); -extern void amiga_WarpWMCursor (_THIS, Uint16 x, Uint16 y); -extern void amiga_CheckMouseMode (_THIS); +extern void amiga_FreeWMCursor(_THIS, WMcursor * cursor); +extern WMcursor *amiga_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, + int h, int hot_x, int hot_y); +extern int amiga_ShowWMCursor(_THIS, WMcursor * cursor); +extern void amiga_WarpWMCursor(_THIS, Uint16 x, Uint16 y); +extern void amiga_CheckMouseMode(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/cybergfx/SDL_cgxaccel.c --- a/src/video/cybergfx/SDL_cgxaccel.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/cybergfx/SDL_cgxaccel.c Mon May 29 04:04:35 2006 +0000 @@ -27,8 +27,8 @@ #include "../SDL_blit.h" #include "SDL_cgxvideo.h" -static int CGX_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect); +static int CGX_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); // These are needed to avoid register troubles with gcc -O2! @@ -38,53 +38,52 @@ #define BBB(a,b,c,d,e,f,g,h,i,j,k) BltBitMap(a,b,c,d,e,f,g,h,i,j,k) #else void -BMKBRP (struct BitMap *a, WORD b, WORD c, struct RastPort *d, WORD e, WORD f, - WORD g, WORD h, UBYTE i, APTR j) +BMKBRP(struct BitMap *a, WORD b, WORD c, struct RastPort *d, WORD e, WORD f, + WORD g, WORD h, UBYTE i, APTR j) { - BltMaskBitMapRastPort (a, b, c, d, e, f, g, h, i, j); + BltMaskBitMapRastPort(a, b, c, d, e, f, g, h, i, j); } void -BBRP (struct BitMap *a, WORD b, WORD c, struct RastPort *d, WORD e, WORD f, - WORD g, WORD h, UBYTE i) +BBRP(struct BitMap *a, WORD b, WORD c, struct RastPort *d, WORD e, WORD f, + WORD g, WORD h, UBYTE i) { - BltBitMapRastPort (a, b, c, d, e, f, g, h, i); + BltBitMapRastPort(a, b, c, d, e, f, g, h, i); } void -BBB (struct BitMap *a, WORD b, WORD c, struct BitMap *d, WORD e, WORD f, - WORD g, WORD h, UBYTE i, UBYTE j, UWORD * k) +BBB(struct BitMap *a, WORD b, WORD c, struct BitMap *d, WORD e, WORD f, + WORD g, WORD h, UBYTE i, UBYTE j, UWORD * k) { - BltBitMap (a, b, c, d, e, f, g, h, i, j, k); + BltBitMap(a, b, c, d, e, f, g, h, i, j, k); } #endif int -CGX_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key) +CGX_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key) { if (surface->hwdata) { if (surface->hwdata->mask) - SDL_free (surface->hwdata->mask); + SDL_free(surface->hwdata->mask); if (surface->hwdata->mask = - SDL_malloc (RASSIZE (surface->w, surface->h))) { + SDL_malloc(RASSIZE(surface->w, surface->h))) { Uint32 pitch, ok = 0; APTR lock; - SDL_memset (surface->hwdata->mask, 255, - RASSIZE (surface->w, surface->h)); + SDL_memset(surface->hwdata->mask, 255, + RASSIZE(surface->w, surface->h)); - D (bug - ("Building colorkey mask: color: %ld, size: %ld x %ld, %ld bytes...Bpp:%ld\n", - key, surface->w, surface->h, RASSIZE (surface->w, - surface->h), - surface->format->BytesPerPixel)); + D(bug + ("Building colorkey mask: color: %ld, size: %ld x %ld, %ld bytes...Bpp:%ld\n", + key, surface->w, surface->h, RASSIZE(surface->w, + surface->h), + surface->format->BytesPerPixel)); if (lock = - LockBitMapTags (surface->hwdata->bmap, LBMI_BASEADDRESS, - (ULONG) & surface->pixels, - LBMI_BYTESPERROW, (ULONG) & pitch, - TAG_DONE)) { + LockBitMapTags(surface->hwdata->bmap, LBMI_BASEADDRESS, + (ULONG) & surface->pixels, + LBMI_BYTESPERROW, (ULONG) & pitch, TAG_DONE)) { switch (surface->format->BytesPerPixel) { case 1: { @@ -166,32 +165,32 @@ } break; default: - D (bug ("Pixel mode non supported for color key...")); - SDL_free (surface->hwdata->mask); + D(bug("Pixel mode non supported for color key...")); + SDL_free(surface->hwdata->mask); surface->hwdata->mask = NULL; ok = -1; } - UnLockBitMap (lock); - D (bug ("...Colorkey built!\n")); + UnLockBitMap(lock); + D(bug("...Colorkey built!\n")); return ok; } } } - D (bug ("HW colorkey not supported for this depth\n")); + D(bug("HW colorkey not supported for this depth\n")); return -1; } int -CGX_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst) +CGX_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst) { // Doesn't support yet alpha blitting if (src->hwdata && !(src->flags & (SDL_SRCALPHA))) { - D (bug ("CheckHW blit... OK!\n")); + D(bug("CheckHW blit... OK!\n")); if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { - if (CGX_SetHWColorKey (this, src, src->format->colorkey) < 0) { + if (CGX_SetHWColorKey(this, src, src->format->colorkey) < 0) { src->flags &= ~SDL_HWACCEL; return -1; } @@ -203,7 +202,7 @@ } else src->flags &= ~SDL_HWACCEL; - D (bug ("CheckHW blit... NO!\n")); + D(bug("CheckHW blit... NO!\n")); return 0; } @@ -212,8 +211,8 @@ static struct RastPort temprp; static int -CGX_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +CGX_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { struct SDL_VideoDevice *this = src->hwdata->videodata; @@ -221,52 +220,51 @@ if (src->flags & SDL_SRCCOLORKEY && src->hwdata->mask) { if (dst == SDL_VideoSurface) { - BMKBRP (src->hwdata->bmap, srcrect->x, srcrect->y, - SDL_RastPort, dstrect->x + SDL_Window->BorderLeft, - dstrect->y + SDL_Window->BorderTop, srcrect->w, - srcrect->h, 0xc0, src->hwdata->mask); + BMKBRP(src->hwdata->bmap, srcrect->x, srcrect->y, + SDL_RastPort, dstrect->x + SDL_Window->BorderLeft, + dstrect->y + SDL_Window->BorderTop, srcrect->w, + srcrect->h, 0xc0, src->hwdata->mask); } else if (dst->hwdata) { if (!temprp_init) { - InitRastPort (&temprp); + InitRastPort(&temprp); temprp_init = 1; } temprp.BitMap = (struct BitMap *) dst->hwdata->bmap; - BMKBRP (src->hwdata->bmap, srcrect->x, srcrect->y, - &temprp, dstrect->x, dstrect->y, - srcrect->w, srcrect->h, 0xc0, src->hwdata->mask); + BMKBRP(src->hwdata->bmap, srcrect->x, srcrect->y, + &temprp, dstrect->x, dstrect->y, + srcrect->w, srcrect->h, 0xc0, src->hwdata->mask); } } else if (dst == SDL_VideoSurface) { - BBRP (src->hwdata->bmap, srcrect->x, srcrect->y, SDL_RastPort, - dstrect->x + SDL_Window->BorderLeft, - dstrect->y + SDL_Window->BorderTop, srcrect->w, srcrect->h, - 0xc0); + BBRP(src->hwdata->bmap, srcrect->x, srcrect->y, SDL_RastPort, + dstrect->x + SDL_Window->BorderLeft, + dstrect->y + SDL_Window->BorderTop, srcrect->w, srcrect->h, + 0xc0); } else if (dst->hwdata) - BBB (src->hwdata->bmap, srcrect->x, srcrect->y, dst->hwdata->bmap, - dstrect->x, dstrect->y, srcrect->w, srcrect->h, 0xc0, 0xff, - NULL); + BBB(src->hwdata->bmap, srcrect->x, srcrect->y, dst->hwdata->bmap, + dstrect->x, dstrect->y, srcrect->w, srcrect->h, 0xc0, 0xff, NULL); return 0; } int -CGX_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color) +CGX_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color) { if (dst == SDL_VideoSurface) { - FillPixelArray (SDL_RastPort, dstrect->x + SDL_Window->BorderLeft, - dstrect->y + SDL_Window->BorderTop, dstrect->w, - dstrect->h, color); + FillPixelArray(SDL_RastPort, dstrect->x + SDL_Window->BorderLeft, + dstrect->y + SDL_Window->BorderTop, dstrect->w, + dstrect->h, color); } else if (dst->hwdata) { if (!temprp_init) { - InitRastPort (&temprp); + InitRastPort(&temprp); temprp_init = 1; } temprp.BitMap = (struct BitMap *) dst->hwdata->bmap; - FillPixelArray (&temprp, dstrect->x, dstrect->y, dstrect->w, - dstrect->h, color); + FillPixelArray(&temprp, dstrect->x, dstrect->y, dstrect->w, + dstrect->h, color); } return 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/cybergfx/SDL_cgxgl.c --- a/src/video/cybergfx/SDL_cgxgl.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/cybergfx/SDL_cgxgl.c Mon May 29 04:04:35 2006 +0000 @@ -32,7 +32,7 @@ /* Init OpenGL */ int -CGX_GL_Init (_THIS) +CGX_GL_Init(_THIS) { #if SDL_VIDEO_OPENGL int i = 0; @@ -89,9 +89,9 @@ // done... attributes[i].ti_Tag = TAG_DONE; - glcont = AmigaMesaCreateContext (attributes); + glcont = AmigaMesaCreateContext(attributes); if (glcont == NULL) { - SDL_SetError ("Couldn't create OpenGL context"); + SDL_SetError("Couldn't create OpenGL context"); return (-1); } this->gl_data->gl_active = 1; @@ -99,18 +99,18 @@ return (0); #else - SDL_SetError ("OpenGL support not configured"); + SDL_SetError("OpenGL support not configured"); return (-1); #endif } /* Quit OpenGL */ void -CGX_GL_Quit (_THIS) +CGX_GL_Quit(_THIS) { #if SDL_VIDEO_OPENGL if (glcont != NULL) { - AmigaMesaDestroyContext (glcont); + AmigaMesaDestroyContext(glcont); glcont = NULL; this->gl_data->gl_active = 0; this->gl_config.driver_loaded = 0; @@ -120,7 +120,7 @@ /* Attach context to another window */ int -CGX_GL_Update (_THIS) +CGX_GL_Update(_THIS) { #if SDL_VIDEO_OPENGL struct TagItem tags[2]; @@ -131,11 +131,11 @@ tags[0].ti_Tag = AMA_Window; tags[0].ti_Data = (unsigned long) win; tags[1].ti_Tag = TAG_DONE; - AmigaMesaSetRast (glcont, tags); + AmigaMesaSetRast(glcont, tags); return 0; #else - SDL_SetError ("OpenGL support not configured"); + SDL_SetError("OpenGL support not configured"); return -1; #endif } @@ -144,23 +144,23 @@ /* Make the current context active */ int -CGX_GL_MakeCurrent (_THIS) +CGX_GL_MakeCurrent(_THIS) { if (glcont == NULL) return -1; - AmigaMesaMakeCurrent (glcont, glcont->buffer); + AmigaMesaMakeCurrent(glcont, glcont->buffer); return 0; } void -CGX_GL_SwapBuffers (_THIS) +CGX_GL_SwapBuffers(_THIS) { - AmigaMesaSwapBuffers (glcont); + AmigaMesaSwapBuffers(glcont); } int -CGX_GL_GetAttribute (_THIS, SDL_GLattr attrib, int *value) +CGX_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) { GLenum mesa_attrib; @@ -202,20 +202,20 @@ return -1; } - AmigaMesaGetConfig (glcont->visual, mesa_attrib, value); + AmigaMesaGetConfig(glcont->visual, mesa_attrib, value); return 0; } void * -CGX_GL_GetProcAddress (_THIS, const char *proc) +CGX_GL_GetProcAddress(_THIS, const char *proc) { void *func = NULL; - func = AmiGetGLProc (proc); + func = AmiGetGLProc(proc); return func; } int -CGX_GL_LoadLibrary (_THIS, const char *path) +CGX_GL_LoadLibrary(_THIS, const char *path) { /* Library is always open */ this->gl_config.driver_loaded = 1; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/cybergfx/SDL_cgxgl_c.h --- a/src/video/cybergfx/SDL_cgxgl_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/cybergfx/SDL_cgxgl_c.h Mon May 29 04:04:35 2006 +0000 @@ -29,7 +29,7 @@ #if SDL_VIDEO_OPENGL #include -extern void *AmiGetGLProc (const char *proc); +extern void *AmiGetGLProc(const char *proc); #endif /* SDL_VIDEO_OPENGL */ struct SDL_PrivateGLData @@ -38,15 +38,15 @@ }; /* OpenGL functions */ -extern int CGX_GL_Init (_THIS); -extern void CGX_GL_Quit (_THIS); -extern int CGX_GL_Update (_THIS); +extern int CGX_GL_Init(_THIS); +extern void CGX_GL_Quit(_THIS); +extern int CGX_GL_Update(_THIS); #if SDL_VIDEO_OPENGL -extern int CGX_GL_MakeCurrent (_THIS); -extern int CGX_GL_GetAttribute (_THIS, SDL_GLattr attrib, int *value); -extern void CGX_GL_SwapBuffers (_THIS); -extern void *CGX_GL_GetProcAddress (_THIS, const char *proc); -extern int CGX_GL_LoadLibrary (_THIS, const char *path); +extern int CGX_GL_MakeCurrent(_THIS); +extern int CGX_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value); +extern void CGX_GL_SwapBuffers(_THIS); +extern void *CGX_GL_GetProcAddress(_THIS, const char *proc); +extern int CGX_GL_LoadLibrary(_THIS, const char *path); #endif #undef _THIS diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/cybergfx/SDL_cgximage.c --- a/src/video/cybergfx/SDL_cgximage.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/cybergfx/SDL_cgximage.c Mon May 29 04:04:35 2006 +0000 @@ -33,18 +33,18 @@ #define WLUT WriteLUTPixelArray #else void -WLUT (APTR a, UWORD b, UWORD c, UWORD d, struct RastPort *e, APTR f, UWORD g, - UWORD h, UWORD i, UWORD l, UBYTE m) +WLUT(APTR a, UWORD b, UWORD c, UWORD d, struct RastPort *e, APTR f, UWORD g, + UWORD h, UWORD i, UWORD l, UBYTE m) { - WriteLUTPixelArray (a, b, c, d, e, f, g, h, i, l, m); + WriteLUTPixelArray(a, b, c, d, e, f, g, h, i, l, m); } #endif #endif /* Various screen update functions available */ -static void CGX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects); -static void CGX_FakeUpdate (_THIS, int numrects, SDL_Rect * rects); +static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect * rects); +static void CGX_FakeUpdate(_THIS, int numrects, SDL_Rect * rects); BOOL SafeDisp = TRUE, SafeChange = TRUE; struct MsgPort *safeport = NULL, *dispport = NULL; @@ -52,7 +52,7 @@ int use_picasso96 = 1; int -CGX_SetupImage (_THIS, SDL_Surface * screen) +CGX_SetupImage(_THIS, SDL_Surface * screen) { SDL_Ximage = NULL; @@ -60,12 +60,10 @@ ULONG pitch; if (!screen->hwdata) { - if (! - (screen->hwdata = - SDL_malloc (sizeof (struct private_hwdata)))) + if (!(screen->hwdata = SDL_malloc(sizeof(struct private_hwdata)))) return -1; - D (bug ("Creating system accel struct\n")); + D(bug("Creating system accel struct\n")); } screen->hwdata->lock = NULL; screen->hwdata->allocated = 0; @@ -73,18 +71,18 @@ screen->hwdata->bmap = SDL_RastPort->BitMap; screen->hwdata->videodata = this; - if (!(screen->hwdata->lock = LockBitMapTags (screen->hwdata->bmap, - LBMI_BASEADDRESS, - (ULONG) & screen-> - pixels, - LBMI_BYTESPERROW, - (ULONG) & pitch, - TAG_DONE))) { - SDL_free (screen->hwdata); + if (!(screen->hwdata->lock = LockBitMapTags(screen->hwdata->bmap, + LBMI_BASEADDRESS, + (ULONG) & screen-> + pixels, + LBMI_BYTESPERROW, + (ULONG) & pitch, + TAG_DONE))) { + SDL_free(screen->hwdata); screen->hwdata = NULL; return -1; } else { - UnLockBitMap (screen->hwdata->lock); + UnLockBitMap(screen->hwdata->lock); screen->hwdata->lock = NULL; } @@ -92,23 +90,23 @@ this->UpdateRects = CGX_FakeUpdate; - D (bug - ("Accel video image configured (%lx, pitch %ld).\n", - screen->pixels, screen->pitch)); + D(bug + ("Accel video image configured (%lx, pitch %ld).\n", + screen->pixels, screen->pitch)); return 0; } - screen->pixels = SDL_malloc (screen->h * screen->pitch); + screen->pixels = SDL_malloc(screen->h * screen->pitch); if (screen->pixels == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } SDL_Ximage = screen->pixels; if (SDL_Ximage == NULL) { - SDL_SetError ("Couldn't create XImage"); + SDL_SetError("Couldn't create XImage"); return (-1); } @@ -118,17 +116,17 @@ } void -CGX_DestroyImage (_THIS, SDL_Surface * screen) +CGX_DestroyImage(_THIS, SDL_Surface * screen) { if (SDL_Ximage) { - SDL_free (SDL_Ximage); + SDL_free(SDL_Ximage); SDL_Ximage = NULL; } if (screen) { screen->pixels = NULL; if (screen->hwdata) { - SDL_free (screen->hwdata); + SDL_free(screen->hwdata); screen->hwdata = NULL; } } @@ -136,27 +134,27 @@ /* This is a hack to see whether this system has more than 1 CPU */ static int -num_CPU (void) +num_CPU(void) { return 1; } int -CGX_ResizeImage (_THIS, SDL_Surface * screen, Uint32 flags) +CGX_ResizeImage(_THIS, SDL_Surface * screen, Uint32 flags) { int retval; - D (bug ("Calling ResizeImage()\n")); + D(bug("Calling ResizeImage()\n")); - CGX_DestroyImage (this, screen); + CGX_DestroyImage(this, screen); if (flags & SDL_INTERNALOPENGL) { /* No image when using GL */ retval = 0; } else { - retval = CGX_SetupImage (this, screen); + retval = CGX_SetupImage(this, screen); /* We support asynchronous blitting on the display */ if (flags & SDL_ASYNCBLIT) { - if (num_CPU () > 1) { + if (num_CPU() > 1) { screen->flags |= SDL_ASYNCBLIT; } } @@ -165,19 +163,19 @@ } int -CGX_AllocHWSurface (_THIS, SDL_Surface * surface) +CGX_AllocHWSurface(_THIS, SDL_Surface * surface) { - D (bug - ("Alloc HW surface...%ld x %ld x %ld!\n", surface->w, surface->h, - this->hidden->depth)); + D(bug + ("Alloc HW surface...%ld x %ld x %ld!\n", surface->w, surface->h, + this->hidden->depth)); if (surface == SDL_VideoSurface) { - D (bug ("Allocation skipped, it's system one!\n")); + D(bug("Allocation skipped, it's system one!\n")); return 0; } if (!surface->hwdata) { - if (!(surface->hwdata = SDL_malloc (sizeof (struct private_hwdata)))) + if (!(surface->hwdata = SDL_malloc(sizeof(struct private_hwdata)))) return -1; } @@ -187,14 +185,14 @@ surface->hwdata->allocated = 0; if (surface->hwdata->bmap = - AllocBitMap (surface->w, surface->h, this->hidden->depth, - BMF_MINPLANES, SDL_Display->RastPort.BitMap)) { + AllocBitMap(surface->w, surface->h, this->hidden->depth, + BMF_MINPLANES, SDL_Display->RastPort.BitMap)) { surface->hwdata->allocated = 1; surface->flags |= SDL_HWSURFACE; - D (bug ("...OK\n")); + D(bug("...OK\n")); return 0; } else { - SDL_free (surface->hwdata); + SDL_free(surface->hwdata); surface->hwdata = NULL; } @@ -202,27 +200,27 @@ } void -CGX_FreeHWSurface (_THIS, SDL_Surface * surface) +CGX_FreeHWSurface(_THIS, SDL_Surface * surface) { if (surface && surface != SDL_VideoSurface && surface->hwdata) { - D (bug ("Free hw surface.\n")); + D(bug("Free hw surface.\n")); if (surface->hwdata->mask) - SDL_free (surface->hwdata->mask); + SDL_free(surface->hwdata->mask); if (surface->hwdata->bmap && surface->hwdata->allocated) - FreeBitMap (surface->hwdata->bmap); + FreeBitMap(surface->hwdata->bmap); - SDL_free (surface->hwdata); + SDL_free(surface->hwdata); surface->hwdata = NULL; surface->pixels = NULL; - D (bug ("end of free hw surface\n")); + D(bug("end of free hw surface\n")); } return; } int -CGX_LockHWSurface (_THIS, SDL_Surface * surface) +CGX_LockHWSurface(_THIS, SDL_Surface * surface) { if (surface->hwdata) { // D(bug("Locking a bitmap...\n")); @@ -231,10 +229,9 @@ if (! (surface->hwdata->lock = - LockBitMapTags (surface->hwdata->bmap, LBMI_BASEADDRESS, - (ULONG) & surface->pixels, - LBMI_BYTESPERROW, (ULONG) & pitch, - TAG_DONE))) + LockBitMapTags(surface->hwdata->bmap, LBMI_BASEADDRESS, + (ULONG) & surface->pixels, + LBMI_BYTESPERROW, (ULONG) & pitch, TAG_DONE))) return -1; // surface->pitch e' a 16bit! @@ -249,37 +246,37 @@ surface->format->BytesPerPixel * (SDL_Window->BorderLeft + SDL_Window->LeftEdge)); } - D ( - else - bug ("Already locked!!!\n")); + D( + else + bug("Already locked!!!\n")); } return (0); } void -CGX_UnlockHWSurface (_THIS, SDL_Surface * surface) +CGX_UnlockHWSurface(_THIS, SDL_Surface * surface) { if (surface->hwdata && surface->hwdata->lock) { - UnLockBitMap (surface->hwdata->lock); + UnLockBitMap(surface->hwdata->lock); surface->hwdata->lock = NULL; // surface->pixels=NULL; } } int -CGX_FlipHWSurface (_THIS, SDL_Surface * surface) +CGX_FlipHWSurface(_THIS, SDL_Surface * surface) { static int current = 0; if (this->hidden->dbuffer) { if (!SafeChange) { - Wait (disp_sigbit); + Wait(disp_sigbit); // Non faccio nulla, vuoto solo la porta - while (GetMsg (dispport) != NULL); + while (GetMsg(dispport) != NULL); SafeChange = TRUE; } - if (ChangeScreenBuffer (SDL_Display, this->hidden->SB[current ^ 1])) { + if (ChangeScreenBuffer(SDL_Display, this->hidden->SB[current ^ 1])) { surface->hwdata->bmap = SDL_RastPort->BitMap = this->hidden->SB[current]->sb_BitMap; SafeChange = FALSE; @@ -288,8 +285,8 @@ } if (!SafeDisp) { - Wait (safe_sigbit); - while (GetMsg (safeport) != NULL); + Wait(safe_sigbit); + while (GetMsg(safeport) != NULL); SafeDisp = TRUE; } @@ -299,7 +296,7 @@ /* Byte-swap the pixels in the display image */ static void -CGX_SwapAllPixels (SDL_Surface * screen) +CGX_SwapAllPixels(SDL_Surface * screen) { int x, y; @@ -311,7 +308,7 @@ spot = (Uint16 *) ((Uint8 *) screen->pixels + y * screen->pitch); for (x = 0; x < screen->w; ++x, ++spot) { - *spot = SDL_Swap16 (*spot); + *spot = SDL_Swap16(*spot); } } } @@ -324,7 +321,7 @@ spot = (Uint32 *) ((Uint8 *) screen->pixels + y * screen->pitch); for (x = 0; x < screen->w; ++x, ++spot) { - *spot = SDL_Swap32 (*spot); + *spot = SDL_Swap32(*spot); } } } @@ -336,7 +333,7 @@ } } static void -CGX_SwapPixels (SDL_Surface * screen, int numrects, SDL_Rect * rects) +CGX_SwapPixels(SDL_Surface * screen, int numrects, SDL_Rect * rects) { int i; int x, minx, maxx; @@ -355,7 +352,7 @@ spot = (Uint16 *) ((Uint8 *) screen->pixels + y * screen->pitch + minx * 2); for (x = minx; x < maxx; ++x, ++spot) { - *spot = SDL_Swap16 (*spot); + *spot = SDL_Swap16(*spot); } } } @@ -374,7 +371,7 @@ spot = (Uint32 *) ((Uint8 *) screen->pixels + y * screen->pitch + minx * 4); for (x = minx; x < maxx; ++x, ++spot) { - *spot = SDL_Swap32 (*spot); + *spot = SDL_Swap32(*spot); } } } @@ -393,21 +390,21 @@ #else void -USE_WPA (char *a, int b, int c, int d, struct RastPort *e, int f, int g, - int h, int i, Uint32 l) +USE_WPA(char *a, int b, int c, int d, struct RastPort *e, int f, int g, + int h, int i, Uint32 l) { - WritePixelArray (a, b, c, d, e, f, g, h, i, l); + WritePixelArray(a, b, c, d, e, f, g, h, i, l); } #endif static void -CGX_FakeUpdate (_THIS, int numrects, SDL_Rect * rects) +CGX_FakeUpdate(_THIS, int numrects, SDL_Rect * rects) { } static void -CGX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects) +CGX_NormalUpdate(_THIS, int numrects, SDL_Rect * rects) { int i, format, customroutine = 0; #ifndef USE_CGX_WRITELUTPIXEL @@ -447,25 +444,25 @@ customroutine = 1; break; default: - D (bug ("Unable to blit this surface!\n")); + D(bug("Unable to blit this surface!\n")); return; } /* Check for endian-swapped X server, swap if necessary (VERY slow!) */ if (swap_pixels && ((this->screen->format->BytesPerPixel % 2) == 0)) { - D (bug ("Software Swapping! SLOOOW!\n")); - CGX_SwapPixels (this->screen, numrects, rects); + D(bug("Software Swapping! SLOOOW!\n")); + CGX_SwapPixels(this->screen, numrects, rects); for (i = 0; i < numrects; ++i) { if (!rects[i].w) { /* Clipped? */ continue; } - USE_WPA (this->screen->pixels, rects[i].x, rects[i].y, - this->screen->pitch, SDL_RastPort, - SDL_Window->BorderLeft + rects[i].x, - SDL_Window->BorderTop + rects[i].y, rects[i].w, - rects[i].h, format); + USE_WPA(this->screen->pixels, rects[i].x, rects[i].y, + this->screen->pitch, SDL_RastPort, + SDL_Window->BorderLeft + rects[i].x, + SDL_Window->BorderTop + rects[i].y, rects[i].w, + rects[i].h, format); } - CGX_SwapPixels (this->screen, numrects, rects); + CGX_SwapPixels(this->screen, numrects, rects); } else if (customroutine == 2) { #ifdef USE_CGX_WRITELUTPIXEL for (i = 0; i < numrects; ++i) { @@ -473,11 +470,11 @@ continue; } - WLUT (this->screen->pixels, rects[i].x, rects[i].y, - this->screen->pitch, SDL_RastPort, SDL_XPixels, - SDL_Window->BorderLeft + rects[i].x, - SDL_Window->BorderTop + rects[i].y, rects[i].w, - rects[i].h, CTABFMT_XRGB8); + WLUT(this->screen->pixels, rects[i].x, rects[i].y, + this->screen->pitch, SDL_RastPort, SDL_XPixels, + SDL_Window->BorderLeft + rects[i].x, + SDL_Window->BorderTop + rects[i].y, rects[i].w, + rects[i].h, CTABFMT_XRGB8); } #else unsigned char *bm_address; @@ -485,9 +482,9 @@ APTR handle; if (handle = - LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS, - &bm_address, LBMI_BYTESPERROW, &destpitch, - TAG_DONE)) { + LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, + &bm_address, LBMI_BYTESPERROW, &destpitch, + TAG_DONE)) { int srcwidth; unsigned char *destbase; register int j, k, t; @@ -530,7 +527,7 @@ dest += destpitch; } } - UnLockBitMap (handle); + UnLockBitMap(handle); } } else if (customroutine == 3) { unsigned char *bm_address; @@ -538,9 +535,9 @@ APTR handle; if (handle = - LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS, - &bm_address, LBMI_BYTESPERROW, &destpitch, - TAG_DONE)) { + LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, + &bm_address, LBMI_BYTESPERROW, &destpitch, + TAG_DONE)) { int srcwidth; unsigned char *destbase; register int j, k; @@ -582,7 +579,7 @@ dest += destpitch; } } - UnLockBitMap (handle); + UnLockBitMap(handle); } } else if (customroutine == 4) { unsigned char *bm_address; @@ -590,9 +587,9 @@ APTR handle; if (handle = - LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS, - &bm_address, LBMI_BYTESPERROW, &destpitch, - TAG_DONE)) { + LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, + &bm_address, LBMI_BYTESPERROW, &destpitch, + TAG_DONE)) { int srcwidth; unsigned char *destbase; register int j, k; @@ -634,7 +631,7 @@ dest += destpitch; } } - UnLockBitMap (handle); + UnLockBitMap(handle); } #endif } else if (customroutine) { @@ -645,9 +642,9 @@ // D(bug("Using customroutine!\n")); if (handle = - LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS, - (ULONG) & bm_address, LBMI_BYTESPERROW, - (ULONG) & destpitch, TAG_DONE)) { + LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, + (ULONG) & bm_address, LBMI_BYTESPERROW, + (ULONG) & destpitch, TAG_DONE)) { unsigned char *destbase; register int j, srcwidth; register unsigned char *src, *dest; @@ -684,12 +681,12 @@ // D(bug("Rects: %ld,%ld %ld,%ld Src:%lx Dest:%lx\n",rects[i].x,rects[i].y,rects[i].w,rects[i].h,src,dest)); for (j = rects[i].h; j; --j) { - SDL_memcpy (dest, src, srcwidth); + SDL_memcpy(dest, src, srcwidth); src += this->screen->pitch; dest += destpitch; } } - UnLockBitMap (handle); + UnLockBitMap(handle); // D(bug("Rectblit addr: %lx pitch: %ld rects:%ld srcptr: %lx srcpitch: %ld\n",bm_address,destpitch,numrects,this->screen->pixels,this->screen->pitch)); } } else { @@ -697,17 +694,17 @@ if (!rects[i].w) { /* Clipped? */ continue; } - USE_WPA (this->screen->pixels, rects[i].x, rects[i].y, - this->screen->pitch, SDL_RastPort, - SDL_Window->BorderLeft + rects[i].x, - SDL_Window->BorderTop + rects[i].y, rects[i].w, - rects[i].h, format); + USE_WPA(this->screen->pixels, rects[i].x, rects[i].y, + this->screen->pitch, SDL_RastPort, + SDL_Window->BorderLeft + rects[i].x, + SDL_Window->BorderTop + rects[i].y, rects[i].w, + rects[i].h, format); } } } void -CGX_RefreshDisplay (_THIS) +CGX_RefreshDisplay(_THIS) { int format, customroutine = 0; #ifndef USE_CGX_WRITELUTPIXEL @@ -755,27 +752,27 @@ /* Check for endian-swapped X server, swap if necessary */ if (swap_pixels && ((this->screen->format->BytesPerPixel % 2) == 0)) { - CGX_SwapAllPixels (this->screen); - USE_WPA (this->screen->pixels, 0, 0, this->screen->pitch, - SDL_RastPort, SDL_Window->BorderLeft, - SDL_Window->BorderTop, this->screen->w, this->screen->h, - format); - CGX_SwapAllPixels (this->screen); + CGX_SwapAllPixels(this->screen); + USE_WPA(this->screen->pixels, 0, 0, this->screen->pitch, + SDL_RastPort, SDL_Window->BorderLeft, + SDL_Window->BorderTop, this->screen->w, this->screen->h, + format); + CGX_SwapAllPixels(this->screen); } else if (customroutine == 2) { #ifdef USE_CGX_WRITELUTPIXEL - WLUT (this->screen->pixels, 0, 0, this->screen->pitch, - SDL_RastPort, SDL_XPixels, SDL_Window->BorderLeft, - SDL_Window->BorderTop, this->screen->w, this->screen->h, - CTABFMT_XRGB8); + WLUT(this->screen->pixels, 0, 0, this->screen->pitch, + SDL_RastPort, SDL_XPixels, SDL_Window->BorderLeft, + SDL_Window->BorderTop, this->screen->w, this->screen->h, + CTABFMT_XRGB8); #else unsigned char *bm_address; Uint32 destpitch; APTR handle; if (handle = - LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS, - (ULONG) & bm_address, LBMI_BYTESPERROW, - (ULONG) & destpitch, TAG_DONE)) { + LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, + (ULONG) & bm_address, LBMI_BYTESPERROW, + (ULONG) & destpitch, TAG_DONE)) { register int j, k, t; register unsigned char *mask, *dst; register unsigned char *src, *dest; @@ -805,7 +802,7 @@ src += this->screen->pitch; dest += destpitch; } - UnLockBitMap (handle); + UnLockBitMap(handle); } } else if (customroutine == 3) { unsigned char *bm_address; @@ -813,9 +810,9 @@ APTR handle; if (handle = - LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS, - (ULONG) & bm_address, LBMI_BYTESPERROW, - (ULONG) & destpitch, TAG_DONE)) { + LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, + (ULONG) & bm_address, LBMI_BYTESPERROW, + (ULONG) & destpitch, TAG_DONE)) { register int j, k; register unsigned char *src, *dest; register Uint16 *destl, *srcl; @@ -844,7 +841,7 @@ src += this->screen->pitch; dest += destpitch; } - UnLockBitMap (handle); + UnLockBitMap(handle); } } else if (customroutine == 4) { unsigned char *bm_address; @@ -852,9 +849,9 @@ APTR handle; if (handle = - LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS, - (ULONG) & bm_address, LBMI_BYTESPERROW, - (ULONG) & destpitch, TAG_DONE)) { + LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, + (ULONG) & bm_address, LBMI_BYTESPERROW, + (ULONG) & destpitch, TAG_DONE)) { register int j, k; register unsigned char *src, *dest; register Uint32 *destl, *srcl; @@ -883,7 +880,7 @@ src += this->screen->pitch; dest += destpitch; } - UnLockBitMap (handle); + UnLockBitMap(handle); } #endif } else if (customroutine) { @@ -891,10 +888,10 @@ Uint32 destpitch; APTR handle; - if (handle = LockBitMapTags (SDL_RastPort->BitMap, - LBMI_BASEADDRESS, (ULONG) & bm_address, - LBMI_BYTESPERROW, (ULONG) & destpitch, - TAG_DONE)) { + if (handle = LockBitMapTags(SDL_RastPort->BitMap, + LBMI_BASEADDRESS, (ULONG) & bm_address, + LBMI_BYTESPERROW, (ULONG) & destpitch, + TAG_DONE)) { register int j; register unsigned char *src, *dest; @@ -913,22 +910,22 @@ // D(bug("addr: %lx pitch: %ld src:%lx srcpitch: %ld\n",dest,destpitch,this->screen->pixels,this->screen->pitch)); if (this->screen->pitch == destpitch) { - SDL_memcpy (dest, src, this->screen->pitch * this->screen->h); + SDL_memcpy(dest, src, this->screen->pitch * this->screen->h); } else { for (j = this->screen->h; j; --j) { - SDL_memcpy (dest, src, this->screen->pitch); + SDL_memcpy(dest, src, this->screen->pitch); src += this->screen->pitch; dest += destpitch; } } - UnLockBitMap (handle); + UnLockBitMap(handle); } } else { - USE_WPA (this->screen->pixels, 0, 0, this->screen->pitch, - SDL_RastPort, SDL_Window->BorderLeft, - SDL_Window->BorderTop, this->screen->w, this->screen->h, - format); + USE_WPA(this->screen->pixels, 0, 0, this->screen->pitch, + SDL_RastPort, SDL_Window->BorderLeft, + SDL_Window->BorderTop, this->screen->w, this->screen->h, + format); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/cybergfx/SDL_cgximage_c.h --- a/src/video/cybergfx/SDL_cgximage_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/cybergfx/SDL_cgximage_c.h Mon May 29 04:04:35 2006 +0000 @@ -23,15 +23,15 @@ #include "SDL_cgxvideo.h" -extern int CGX_SetupImage (_THIS, SDL_Surface * screen); -extern void CGX_DestroyImage (_THIS, SDL_Surface * screen); -extern int CGX_ResizeImage (_THIS, SDL_Surface * screen, Uint32 flags); +extern int CGX_SetupImage(_THIS, SDL_Surface * screen); +extern void CGX_DestroyImage(_THIS, SDL_Surface * screen); +extern int CGX_ResizeImage(_THIS, SDL_Surface * screen, Uint32 flags); -extern int CGX_AllocHWSurface (_THIS, SDL_Surface * surface); -extern void CGX_FreeHWSurface (_THIS, SDL_Surface * surface); -extern int CGX_LockHWSurface (_THIS, SDL_Surface * surface); -extern void CGX_UnlockHWSurface (_THIS, SDL_Surface * surface); -extern int CGX_FlipHWSurface (_THIS, SDL_Surface * surface); +extern int CGX_AllocHWSurface(_THIS, SDL_Surface * surface); +extern void CGX_FreeHWSurface(_THIS, SDL_Surface * surface); +extern int CGX_LockHWSurface(_THIS, SDL_Surface * surface); +extern void CGX_UnlockHWSurface(_THIS, SDL_Surface * surface); +extern int CGX_FlipHWSurface(_THIS, SDL_Surface * surface); -extern void CGX_RefreshDisplay (_THIS); +extern void CGX_RefreshDisplay(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/cybergfx/SDL_cgxmodes.c --- a/src/video/cybergfx/SDL_cgxmodes.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/cybergfx/SDL_cgxmodes.c Mon May 29 04:04:35 2006 +0000 @@ -33,35 +33,35 @@ #define CGX_DEBUG static void -set_best_resolution (_THIS, int width, int height) +set_best_resolution(_THIS, int width, int height) { Uint32 idok; int depth = 8; if (SDL_Display) depth = - GetCyberMapAttr (SDL_Display->RastPort.BitMap, CYBRMATTR_DEPTH); + GetCyberMapAttr(SDL_Display->RastPort.BitMap, CYBRMATTR_DEPTH); - idok = BestCModeIDTags (CYBRBIDTG_NominalWidth, width, - CYBRBIDTG_NominalHeight, height, - CYBRBIDTG_Depth, depth, TAG_DONE); + idok = BestCModeIDTags(CYBRBIDTG_NominalWidth, width, + CYBRBIDTG_NominalHeight, height, + CYBRBIDTG_Depth, depth, TAG_DONE); if (idok != INVALID_ID) { if (SDL_Display) { if (currently_fullscreen) - CloseScreen (SDL_Display); + CloseScreen(SDL_Display); else - UnlockPubScreen (NULL, SDL_Display); + UnlockPubScreen(NULL, SDL_Display); } SDL_Display = GFX_Display = - OpenScreenTags (NULL, SA_Width, width, SA_Height, height, - SA_Depth, depth, SA_DisplayID, idok, - SA_ShowTitle, FALSE, TAG_DONE); + OpenScreenTags(NULL, SA_Width, width, SA_Height, height, + SA_Depth, depth, SA_DisplayID, idok, + SA_ShowTitle, FALSE, TAG_DONE); } } static void -get_real_resolution (_THIS, int *w, int *h) +get_real_resolution(_THIS, int *w, int *h) { *w = /*SDL_Display->Width */ SDL_Window->Width - SDL_Window->BorderLeft - SDL_Window->BorderRight; @@ -70,7 +70,7 @@ } static void -move_cursor_to (_THIS, int x, int y) +move_cursor_to(_THIS, int x, int y) { /* XWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y); */ @@ -78,20 +78,20 @@ } static void -add_visual (_THIS, int depth, int class) +add_visual(_THIS, int depth, int class) { Uint32 tID; - tID = BestCModeIDTags (CYBRBIDTG_Depth, depth, - CYBRBIDTG_NominalWidth, 640, - CYBRBIDTG_NominalHeight, 480, TAG_DONE); + tID = BestCModeIDTags(CYBRBIDTG_Depth, depth, + CYBRBIDTG_NominalWidth, 640, + CYBRBIDTG_NominalHeight, 480, TAG_DONE); if (tID != INVALID_ID) { int n = this->hidden->nvisuals; this->hidden->visuals[n].depth = depth; this->hidden->visuals[n].visual = tID; - this->hidden->visuals[n].bpp = GetCyberIDAttr (CYBRIDATTR_BPPIX, tID); + this->hidden->visuals[n].bpp = GetCyberIDAttr(CYBRIDATTR_BPPIX, tID); this->hidden->nvisuals++; } } @@ -100,7 +100,7 @@ #define PseudoColor 2 int -CGX_GetVideoModes (_THIS) +CGX_GetVideoModes(_THIS) { int i; ULONG nextid; @@ -108,17 +108,17 @@ SDL_modelist = NULL; - nextid = NextDisplayInfo (INVALID_ID); + nextid = NextDisplayInfo(INVALID_ID); while (nextid != INVALID_ID) { - if (IsCyberModeID (nextid)) { + if (IsCyberModeID(nextid)) { DisplayInfoHandle h; - if (h = FindDisplayInfo (nextid)) { + if (h = FindDisplayInfo(nextid)) { struct DimensionInfo info; if (GetDisplayInfoData - (h, (char *) &info, sizeof (struct DimensionInfo), + (h, (char *) &info, sizeof(struct DimensionInfo), DTAG_DIMS, NULL)) { int ok = 0; @@ -132,15 +132,15 @@ nmodes++; SDL_modelist = - (SDL_Rect **) SDL_realloc (SDL_modelist, - (nmodes + - 1) * - sizeof (SDL_Rect *)); + (SDL_Rect **) SDL_realloc(SDL_modelist, + (nmodes + + 1) * + sizeof(SDL_Rect *)); SDL_modelist[nmodes] = NULL; if (SDL_modelist) { SDL_modelist[nmodes - 1] = (SDL_Rect *) - SDL_malloc (sizeof (SDL_Rect)); + SDL_malloc(sizeof(SDL_Rect)); if (SDL_modelist[nmodes - 1] == NULL) break; @@ -156,30 +156,29 @@ } } } - nextid = NextDisplayInfo (nextid); + nextid = NextDisplayInfo(nextid); } this->hidden->nvisuals = 0; /* Search for the visuals in deepest-first order, so that the first will be the richest one */ - add_visual (this, 32, TrueColor); - add_visual (this, 24, TrueColor); - add_visual (this, 16, TrueColor); - add_visual (this, 15, TrueColor); - add_visual (this, 8, PseudoColor); + add_visual(this, 32, TrueColor); + add_visual(this, 24, TrueColor); + add_visual(this, 16, TrueColor); + add_visual(this, 15, TrueColor); + add_visual(this, 8, PseudoColor); if (this->hidden->nvisuals == 0) { - SDL_SetError ("Found no sufficiently capable CGX visuals"); + SDL_SetError("Found no sufficiently capable CGX visuals"); return -1; } if (SDL_modelist == NULL) { - SDL_modelist = - (SDL_Rect **) SDL_malloc ((1 + 1) * sizeof (SDL_Rect *)); + SDL_modelist = (SDL_Rect **) SDL_malloc((1 + 1) * sizeof(SDL_Rect *)); i = 0; if (SDL_modelist) { - SDL_modelist[i] = (SDL_Rect *) SDL_malloc (sizeof (SDL_Rect)); + SDL_modelist[i] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect)); if (SDL_modelist[i]) { SDL_modelist[i]->x = 0; SDL_modelist[i]->y = 0; @@ -191,25 +190,25 @@ } } - D (if (SDL_modelist) { - bug ("CGX video mode list: (%ld)\n", nmodes); - for (i = 0; SDL_modelist[i]; ++i) { - bug ("\t%ld x %ld\n", SDL_modelist[i]->w, SDL_modelist[i]->h);} - } + D(if (SDL_modelist) { + bug("CGX video mode list: (%ld)\n", nmodes); + for (i = 0; SDL_modelist[i]; ++i) { + bug("\t%ld x %ld\n", SDL_modelist[i]->w, SDL_modelist[i]->h);} + } ); - D ( { - bug ("CGX visuals list: (%ld)\n", this->hidden->nvisuals); - for (i = 0; i < this->hidden->nvisuals; i++) - bug ("\t%lx - depth: %ld bpp: %ld\n", - this->hidden->visuals[i].visual, - this->hidden->visuals[i].depth, this->hidden->visuals[i].bpp);} + D( { + bug("CGX visuals list: (%ld)\n", this->hidden->nvisuals); + for (i = 0; i < this->hidden->nvisuals; i++) + bug("\t%lx - depth: %ld bpp: %ld\n", + this->hidden->visuals[i].visual, + this->hidden->visuals[i].depth, this->hidden->visuals[i].bpp);} ); return 0; } int -CGX_SupportedVisual (_THIS, SDL_PixelFormat * format) +CGX_SupportedVisual(_THIS, SDL_PixelFormat * format) { int i; for (i = 0; i < this->hidden->nvisuals; i++) { @@ -220,9 +219,9 @@ } SDL_Rect ** -CGX_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +CGX_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { - if (CGX_SupportedVisual (this, format)) { + if (CGX_SupportedVisual(this, format)) { if (flags & SDL_FULLSCREEN) { return (SDL_modelist); } else { @@ -234,21 +233,21 @@ } void -CGX_FreeVideoModes (_THIS) +CGX_FreeVideoModes(_THIS) { int i; if (SDL_modelist) { for (i = 0; SDL_modelist[i]; ++i) { - SDL_free (SDL_modelist[i]); + SDL_free(SDL_modelist[i]); } - SDL_free (SDL_modelist); + SDL_free(SDL_modelist); SDL_modelist = NULL; } } int -CGX_ResizeFullScreen (_THIS) +CGX_ResizeFullScreen(_THIS) { int x, y; int real_w, real_h; @@ -260,12 +259,12 @@ } void -_QueueEnterFullScreen (_THIS) +_QueueEnterFullScreen(_THIS) { } int -CGX_EnterFullScreen (_THIS) +CGX_EnterFullScreen(_THIS) { int okay; Uint32 saved_flags; @@ -277,23 +276,23 @@ int real_w, real_h; /* Map the fullscreen window to blank the screen */ - get_real_resolution (this, &real_w, &real_h); + get_real_resolution(this, &real_w, &real_h); - CGX_DestroyWindow (this, this->screen); - set_best_resolution (this, real_w, real_h); + CGX_DestroyWindow(this, this->screen); + set_best_resolution(this, real_w, real_h); currently_fullscreen = 1; this->screen->flags = saved_flags; - CGX_CreateWindow (this, this->screen, real_w, real_h, - GetCyberMapAttr (SDL_Display->RastPort.BitMap, - CYBRMATTR_DEPTH), - this->screen->flags); + CGX_CreateWindow(this, this->screen, real_w, real_h, + GetCyberMapAttr(SDL_Display->RastPort.BitMap, + CYBRMATTR_DEPTH), + this->screen->flags); /* Set the new resolution */ - okay = CGX_ResizeFullScreen (this); + okay = CGX_ResizeFullScreen(this); if (!okay) { - CGX_LeaveFullScreen (this); + CGX_LeaveFullScreen(this); } /* Set the colormap */ /* @@ -307,26 +306,26 @@ } int -CGX_LeaveFullScreen (_THIS) +CGX_LeaveFullScreen(_THIS) { if (currently_fullscreen) { int width, height; if (SDL_Window) { - CloseWindow (SDL_Window); + CloseWindow(SDL_Window); SDL_Window = NULL; } - CloseScreen (SDL_Display); + CloseScreen(SDL_Display); - GFX_Display = SDL_Display = LockPubScreen (NULL); + GFX_Display = SDL_Display = LockPubScreen(NULL); currently_fullscreen = 0; - CGX_CreateWindow (this, this->screen, this->screen->w, - this->screen->h, - GetCyberMapAttr (SDL_Display->RastPort.BitMap, - CYBRMATTR_DEPTH), - this->screen->flags); - CGX_ResizeImage (this, this->screen, 0L); + CGX_CreateWindow(this, this->screen, this->screen->w, + this->screen->h, + GetCyberMapAttr(SDL_Display->RastPort.BitMap, + CYBRMATTR_DEPTH), + this->screen->flags); + CGX_ResizeImage(this, this->screen, 0L); } return (0); diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/cybergfx/SDL_cgxmodes_c.h --- a/src/video/cybergfx/SDL_cgxmodes_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/cybergfx/SDL_cgxmodes_c.h Mon May 29 04:04:35 2006 +0000 @@ -32,16 +32,16 @@ */ #define GRAB_FULLSCREEN -extern int CGX_GetVideoModes (_THIS); -extern SDL_Rect **CGX_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -extern void CGX_FreeVideoModes (_THIS); -extern int CGX_ResizeFullScreen (_THIS); +extern int CGX_GetVideoModes(_THIS); +extern SDL_Rect **CGX_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +extern void CGX_FreeVideoModes(_THIS); +extern int CGX_ResizeFullScreen(_THIS); /* extern void CGX_WaitMapped(_THIS, Window win); extern void CGX_WaitUnmapped(_THIS, Window win); extern void CGX_QueueEnterFullScreen(_THIS); */ -extern int CGX_EnterFullScreen (_THIS); -extern int CGX_LeaveFullScreen (_THIS); +extern int CGX_EnterFullScreen(_THIS); +extern int CGX_LeaveFullScreen(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/cybergfx/SDL_cgxvideo.c --- a/src/video/cybergfx/SDL_cgxvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/cybergfx/SDL_cgxvideo.c Mon May 29 04:04:35 2006 +0000 @@ -43,14 +43,14 @@ #include "SDL_cgximage_c.h" /* Initialization/Query functions */ -static int CGX_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Surface *CGX_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int CGX_ToggleFullScreen (_THIS, int on); -static void CGX_UpdateMouse (_THIS); -static int CGX_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void CGX_VideoQuit (_THIS); +static int CGX_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +static int CGX_ToggleFullScreen(_THIS, int on); +static void CGX_UpdateMouse(_THIS); +static int CGX_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void CGX_VideoQuit(_THIS); /* CGX driver bootstrap functions */ @@ -59,21 +59,21 @@ struct GfxBase *GfxBase = NULL; int -CGX_SetGamma (_THIS, float red, float green, float blue) +CGX_SetGamma(_THIS, float red, float green, float blue) { - SDL_SetError ("Gamma correction not supported"); + SDL_SetError("Gamma correction not supported"); return -1; } int -CGX_GetGamma (_THIS, float red, float green, float blue) +CGX_GetGamma(_THIS, float red, float green, float blue) { - SDL_SetError ("Gamma correction not supported"); + SDL_SetError("Gamma correction not supported"); return -1; } int -CGX_SetGammaRamp (_THIS, Uint16 * ramp) +CGX_SetGammaRamp(_THIS, Uint16 * ramp) { #if 0 Int i, ncolors; @@ -81,7 +81,7 @@ /* See if actually setting the gamma is supported */ if (SDL_Visual->class != DirectColor) { - SDL_SetError ("Gamma correction not supported on this visual"); + SDL_SetError("Gamma correction not supported on this visual"); return (-1); } @@ -89,26 +89,26 @@ ncolors = SDL_Visual->map_entries; for (i = 0; i < ncolors; ++i) { Uint8 c = (256 * i / ncolors); - xcmap[i].pixel = SDL_MapRGB (this->screen->format, c, c, c); + xcmap[i].pixel = SDL_MapRGB(this->screen->format, c, c, c); xcmap[i].red = ramp[0 * 256 + c]; xcmap[i].green = ramp[1 * 256 + c]; xcmap[i].blue = ramp[2 * 256 + c]; xcmap[i].flags = (DoRed | DoGreen | DoBlue); } - XStoreColors (GFX_Display, SDL_XColorMap, xcmap, ncolors); - XSync (GFX_Display, False); + XStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors); + XSync(GFX_Display, False); return (0); #else - SDL_SetError ("Gamma correction not supported on this visual"); + SDL_SetError("Gamma correction not supported on this visual"); return (-1); #endif } static void -DestroyScreen (_THIS) +DestroyScreen(_THIS) { if (currently_fullscreen) { if (this->hidden->dbuffer) { @@ -117,12 +117,12 @@ this->hidden->dbuffer = 0; if (safeport) { - while (GetMsg (safeport) != NULL); - DeleteMsgPort (safeport); + while (GetMsg(safeport) != NULL); + DeleteMsgPort(safeport); } if (dispport) { - while (GetMsg (dispport) != NULL); - DeleteMsgPort (dispport); + while (GetMsg(dispport) != NULL); + DeleteMsgPort(dispport); } this->hidden->SB[0]->sb_DBufInfo->dbi_SafeMessage. @@ -135,81 +135,81 @@ mn_ReplyPort = NULL; if (this->hidden->SB[1]) - FreeScreenBuffer (SDL_Display, this->hidden->SB[1]); + FreeScreenBuffer(SDL_Display, this->hidden->SB[1]); if (this->hidden->SB[0]) - FreeScreenBuffer (SDL_Display, this->hidden->SB[0]); + FreeScreenBuffer(SDL_Display, this->hidden->SB[0]); this->hidden->SB[0] = this->hidden->SB[1] = NULL; if (SDL_RastPort && SDL_RastPort != &SDL_Display->RastPort) - SDL_free (SDL_RastPort); + SDL_free(SDL_RastPort); SDL_RastPort = NULL; } - CloseScreen (GFX_Display); + CloseScreen(GFX_Display); currently_fullscreen = 0; } else if (GFX_Display) - UnlockPubScreen (NULL, GFX_Display); + UnlockPubScreen(NULL, GFX_Display); GFX_Display = NULL; } static int -CGX_Available (void) +CGX_Available(void) { struct Library *l; - l = OpenLibrary ("cybergraphics.library", 0L); + l = OpenLibrary("cybergraphics.library", 0L); if (l != NULL) { - D (bug ("CGX video device AVAILABLE\n")); - CloseLibrary (l); + D(bug("CGX video device AVAILABLE\n")); + CloseLibrary(l); } - D ( - else - bug ("**CGX video device UNAVAILABLE\n")); + D( + else + bug("**CGX video device UNAVAILABLE\n")); return (l != NULL); } static void -CGX_DeleteDevice (SDL_VideoDevice * device) +CGX_DeleteDevice(SDL_VideoDevice * device) { if (device) { if (device->hidden) { - SDL_free (device->hidden); + SDL_free(device->hidden); } if (device->gl_data) { - SDL_free (device->gl_data); + SDL_free(device->gl_data); } - SDL_free (device); + SDL_free(device); } } static SDL_VideoDevice * -CGX_CreateDevice (int devindex) +CGX_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); device->gl_data = (struct SDL_PrivateGLData *) - SDL_malloc ((sizeof *device->gl_data)); + SDL_malloc((sizeof *device->gl_data)); } if ((device == NULL) || (device->hidden == NULL) || (device->gl_data == NULL)) { - D (bug ("Unable to create video device!\n")); - SDL_OutOfMemory (); - CGX_DeleteDevice (device); + D(bug("Unable to create video device!\n")); + SDL_OutOfMemory(); + CGX_DeleteDevice(device); return (0); } - SDL_memset (device->hidden, 0, sizeof (*device->hidden)); - SDL_memset (device->gl_data, 0, sizeof (*device->gl_data)); + SDL_memset(device->hidden, 0, sizeof(*device->hidden)); + SDL_memset(device->gl_data, 0, sizeof(*device->gl_data)); /* Set the driver flags */ device->handles_any_size = 1; @@ -266,21 +266,21 @@ }; Uint32 -MakeBitMask (_THIS, int type, int format, int *bpp) +MakeBitMask(_THIS, int type, int format, int *bpp) { - D (if (type == 0) bug ("REAL pixel format: ")); + D(if (type == 0) bug("REAL pixel format: ")); if (this->hidden->depth == *bpp) { switch (format) { case PIXFMT_LUT8: - D (if (type == 0) bug ("LUT8\n")); + D(if (type == 0) bug("LUT8\n")); return 0; case PIXFMT_BGR15: case PIXFMT_RGB15PC: switch (type) { case 0: - D (bug ("RGB15PC/BGR15\n")); + D(bug("RGB15PC/BGR15\n")); return 31; case 1: return 992; @@ -291,7 +291,7 @@ case PIXFMT_BGR15PC: switch (type) { case 0: - D (bug ("RGB15/BGR15PC\n")); + D(bug("RGB15/BGR15PC\n")); return 31744; case 1: return 992; @@ -302,7 +302,7 @@ case PIXFMT_RGB16: switch (type) { case 0: - D (bug ("RGB16PC\n")); + D(bug("RGB16PC\n")); return 63488; case 1: return 2016; @@ -313,7 +313,7 @@ case PIXFMT_RGB16PC: switch (type) { case 0: - D (bug ("RGB16PC/BGR16\n")); + D(bug("RGB16PC/BGR16\n")); return 31; case 1: return 2016; @@ -324,7 +324,7 @@ case PIXFMT_RGB24: switch (type) { case 0: - D (bug ("RGB24/BGR24\n")); + D(bug("RGB24/BGR24\n")); return 0xff0000; case 1: return 0xff00; @@ -334,7 +334,7 @@ case PIXFMT_BGR24: switch (type) { case 0: - D (bug ("BGR24\n")); + D(bug("BGR24\n")); return 0xff; case 1: return 0xff00; @@ -344,7 +344,7 @@ case PIXFMT_ARGB32: switch (type) { case 0: - D (bug ("ARGB32\n")); + D(bug("ARGB32\n")); return 0xff0000; case 1: return 0xff00; @@ -354,7 +354,7 @@ case PIXFMT_BGRA32: switch (type) { case 0: - D (bug ("BGRA32\n")); + D(bug("BGRA32\n")); return 0xff00; case 1: return 0xff0000; @@ -364,7 +364,7 @@ case PIXFMT_RGBA32: switch (type) { case 0: - D (bug ("RGBA32\n")); + D(bug("RGBA32\n")); return 0xff000000; case 1: return 0xff0000; @@ -372,16 +372,16 @@ return 0xff00; } default: - D (bug ("Unknown pixel format! Default to 24bit\n")); + D(bug("Unknown pixel format! Default to 24bit\n")); return (Uint32) (255 << (type * 8)); } } else { - D (if (type == 0) - bug ("DIFFERENT from screen.\nAllocated screen format: ")); + D(if (type == 0) + bug("DIFFERENT from screen.\nAllocated screen format: ")); switch (*bpp) { case 32: - D (if (type == 0) bug ("RGBA32\n")); + D(if (type == 0) bug("RGBA32\n")); switch (type) { case 0: return 0xff000000; @@ -395,7 +395,7 @@ use_truecolor: switch (type) { case 0: - D (bug ("RGB24\n")); + D(bug("RGB24\n")); return 0xff0000; case 1: return 0xff00; @@ -404,13 +404,13 @@ } case 16: case 15: - D (if (type == 0) - bug ("Not supported, switching to 24bit!\n")); + D(if (type == 0) + bug("Not supported, switching to 24bit!\n")); *bpp = 24; goto use_truecolor; break; default: - D (if (type == 0) bug ("This is a chunky display\n")); + D(if (type == 0) bug("This is a chunky display\n")); // For chunky display mask is always 0; return 0; } @@ -419,19 +419,19 @@ } static int -CGX_VideoInit (_THIS, SDL_PixelFormat * vformat) +CGX_VideoInit(_THIS, SDL_PixelFormat * vformat) { int i; struct Library *RTGBase; - D (bug ("VideoInit... Opening libraries\n")); + D(bug("VideoInit... Opening libraries\n")); if (!IntuitionBase) { if (! (IntuitionBase = - (struct IntuitionBase *) OpenLibrary ("intuition.library", - 39L))) { - SDL_SetError ("Couldn't open intuition V39+"); + (struct IntuitionBase *) OpenLibrary("intuition.library", + 39L))) { + SDL_SetError("Couldn't open intuition V39+"); return -1; } } @@ -439,64 +439,64 @@ if (!GfxBase) { if (! (GfxBase = - (struct GfxBase *) OpenLibrary ("graphics.library", 39L))) { - SDL_SetError ("Couldn't open graphics V39+"); + (struct GfxBase *) OpenLibrary("graphics.library", 39L))) { + SDL_SetError("Couldn't open graphics V39+"); return -1; } } if (!CyberGfxBase) { - if (!(CyberGfxBase = OpenLibrary ("cybergraphics.library", 40L))) { - SDL_SetError ("Couldn't open cybergraphics."); + if (!(CyberGfxBase = OpenLibrary("cybergraphics.library", 40L))) { + SDL_SetError("Couldn't open cybergraphics."); return (-1); } } - if (RTGBase = OpenLibrary ("libs:picasso96/rtg.library", 0L)) { + if (RTGBase = OpenLibrary("libs:picasso96/rtg.library", 0L)) { extern int use_picasso96; - CloseLibrary (RTGBase); + CloseLibrary(RTGBase); use_picasso96 = 1; } - D (bug ("Library intialized, locking screen...\n")); + D(bug("Library intialized, locking screen...\n")); - SDL_Display = LockPubScreen (NULL); + SDL_Display = LockPubScreen(NULL); if (SDL_Display == NULL) { - D (bug ("Cannot lock display...\n")); - SDL_SetError ("Couldn't lock the display"); + D(bug("Cannot lock display...\n")); + SDL_SetError("Couldn't lock the display"); return (-1); } this->info.current_w = SDL_Display->Width; this->info.current_h = SDL_Display->Height; - D (bug ("Checking if we are using a CGX native display...\n")); + D(bug("Checking if we are using a CGX native display...\n")); - if (!IsCyberModeID (GetVPModeID (&SDL_Display->ViewPort))) { + if (!IsCyberModeID(GetVPModeID(&SDL_Display->ViewPort))) { Uint32 okid = - BestCModeIDTags (CYBRBIDTG_NominalWidth, SDL_Display->Width, - CYBRBIDTG_NominalHeight, SDL_Display->Height, - CYBRBIDTG_Depth, 8, - TAG_DONE); + BestCModeIDTags(CYBRBIDTG_NominalWidth, SDL_Display->Width, + CYBRBIDTG_NominalHeight, SDL_Display->Height, + CYBRBIDTG_Depth, 8, + TAG_DONE); - D (bug ("Default visual is not CGX native!\n")); + D(bug("Default visual is not CGX native!\n")); - UnlockPubScreen (NULL, SDL_Display); + UnlockPubScreen(NULL, SDL_Display); GFX_Display = NULL; if (okid != INVALID_ID) { - GFX_Display = OpenScreenTags (NULL, - SA_Width, SDL_Display->Width, - SA_Height, SDL_Display->Height, - SA_Depth, 8, SA_Quiet, TRUE, - SA_ShowTitle, FALSE, - SA_DisplayID, okid, TAG_DONE); + GFX_Display = OpenScreenTags(NULL, + SA_Width, SDL_Display->Width, + SA_Height, SDL_Display->Height, + SA_Depth, 8, SA_Quiet, TRUE, + SA_ShowTitle, FALSE, + SA_DisplayID, okid, TAG_DONE); } if (!GFX_Display) { - SDL_SetError ("Unable to open a suited CGX display"); + SDL_SetError("Unable to open a suited CGX display"); return -1; } else SDL_Display = GFX_Display; @@ -515,10 +515,10 @@ swap_pixels = 1; } - D (bug ("Before GetVideoModes....\n")); + D(bug("Before GetVideoModes....\n")); /* Get the available video modes */ - if (CGX_GetVideoModes (this) < 0) + if (CGX_GetVideoModes(this) < 0) return -1; /* Determine the default screen depth: @@ -526,7 +526,7 @@ for (i = 0; i < this->hidden->nvisuals; i++) if (this->hidden->visuals[i].depth == - GetCyberMapAttr (SDL_Display->RastPort.BitMap, CYBRMATTR_DEPTH)) + GetCyberMapAttr(SDL_Display->RastPort.BitMap, CYBRMATTR_DEPTH)) break; if (i == this->hidden->nvisuals) { /* default visual was useless, take the deepest one instead */ @@ -537,7 +537,7 @@ // SDL_XColorMap = SDL_DisplayColormap; this->hidden->depth = this->hidden->visuals[i].depth; - D (bug ("Init: Setting screen depth to: %ld\n", this->hidden->depth)); + D(bug("Init: Setting screen depth to: %ld\n", this->hidden->depth)); vformat->BitsPerPixel = this->hidden->visuals[i].depth; /* this->hidden->visuals[i].bpp; */ { @@ -545,29 +545,26 @@ APTR handle; struct DisplayInfo info; - if (!(handle = FindDisplayInfo (this->hidden->visuals[i].visual))) { - D (bug ("Unable to get visual info...\n")); + if (!(handle = FindDisplayInfo(this->hidden->visuals[i].visual))) { + D(bug("Unable to get visual info...\n")); return -1; } if (!GetDisplayInfoData - (handle, (char *) &info, sizeof (struct DisplayInfo), DTAG_DISP, + (handle, (char *) &info, sizeof(struct DisplayInfo), DTAG_DISP, NULL)) { - D (bug ("Unable to get visual info data...\n")); + D(bug("Unable to get visual info data...\n")); return -1; } - form = GetCyberIDAttr (CYBRIDATTR_PIXFMT, SDL_Visual); + form = GetCyberIDAttr(CYBRIDATTR_PIXFMT, SDL_Visual); // In this case I use makebitmask in a way that I'm sure I'll get PIXFMT pixel mask if (vformat->BitsPerPixel > 8) { - vformat->Rmask = - MakeBitMask (this, 0, form, &this->hidden->depth); - vformat->Gmask = - MakeBitMask (this, 1, form, &this->hidden->depth); - vformat->Bmask = - MakeBitMask (this, 2, form, &this->hidden->depth); + vformat->Rmask = MakeBitMask(this, 0, form, &this->hidden->depth); + vformat->Gmask = MakeBitMask(this, 1, form, &this->hidden->depth); + vformat->Bmask = MakeBitMask(this, 2, form, &this->hidden->depth); } } @@ -576,7 +573,7 @@ SDL_windowid = NULL; /* Create the blank cursor */ - SDL_BlankCursor = AllocMem (16, MEMF_CHIP | MEMF_CLEAR); + SDL_BlankCursor = AllocMem(16, MEMF_CHIP | MEMF_CLEAR); /* Fill in some window manager capabilities */ this->info.wm_available = 1; @@ -589,15 +586,15 @@ this->hidden->same_format = 0; SDL_RastPort = &SDL_Display->RastPort; /* We're done! */ - D (bug ("End of CGX_VideoInit\n")); + D(bug("End of CGX_VideoInit\n")); return (0); } void -CGX_DestroyWindow (_THIS, SDL_Surface * screen) +CGX_DestroyWindow(_THIS, SDL_Surface * screen) { - D (bug ("Destroy Window...\n")); + D(bug("Destroy Window...\n")); if (!SDL_windowid) { /* Hide the managed window */ @@ -616,7 +613,7 @@ /* Destroy the output window */ if (SDL_Window) { - CloseWindow (SDL_Window); + CloseWindow(SDL_Window); SDL_Window = NULL; } @@ -635,62 +632,61 @@ if (!was_fullscreen && this->hidden->depth == 8) { for (pixel = 0; pixel < numcolors; pixel++) { if (SDL_XPixels[pixel] >= 0) - ReleasePen (GFX_Display->ViewPort. - ColorMap, SDL_XPixels[pixel]); + ReleasePen(GFX_Display->ViewPort. + ColorMap, SDL_XPixels[pixel]); } } } - SDL_free (SDL_XPixels); + SDL_free(SDL_XPixels); SDL_XPixels = NULL; } } } static void -CGX_SetSizeHints (_THIS, int w, int h, Uint32 flags) +CGX_SetSizeHints(_THIS, int w, int h, Uint32 flags) { if (flags & SDL_RESIZABLE) { - WindowLimits (SDL_Window, 32, 32, 4096, 4096); + WindowLimits(SDL_Window, 32, 32, 4096, 4096); } else { - WindowLimits (SDL_Window, w, h, w, h); + WindowLimits(SDL_Window, w, h, w, h); } if (flags & SDL_FULLSCREEN) { flags &= ~SDL_RESIZABLE; - } else if (SDL_getenv ("SDL_VIDEO_CENTERED")) { + } else if (SDL_getenv("SDL_VIDEO_CENTERED")) { int display_w, display_h; display_w = SDL_Display->Width; display_h = SDL_Display->Height; - ChangeWindowBox (SDL_Window, - (display_w - w - SDL_Window->BorderLeft - - SDL_Window->BorderRight) / 2, - (display_h - h - SDL_Window->BorderTop - - SDL_Window->BorderBottom) / 2, - w + SDL_Window->BorderLeft + - SDL_Window->BorderRight, - h + SDL_Window->BorderTop + - SDL_Window->BorderBottom); + ChangeWindowBox(SDL_Window, + (display_w - w - SDL_Window->BorderLeft - + SDL_Window->BorderRight) / 2, + (display_h - h - SDL_Window->BorderTop - + SDL_Window->BorderBottom) / 2, + w + SDL_Window->BorderLeft + + SDL_Window->BorderRight, + h + SDL_Window->BorderTop + SDL_Window->BorderBottom); } } int -CGX_CreateWindow (_THIS, SDL_Surface * screen, - int w, int h, int bpp, Uint32 flags) +CGX_CreateWindow(_THIS, SDL_Surface * screen, + int w, int h, int bpp, Uint32 flags) { #if 0 int i, depth; Uint32 vis; #endif - D (bug ("CGX_CreateWindow\n")); + D(bug("CGX_CreateWindow\n")); /* If a window is already present, destroy it and start fresh */ if (SDL_Window) { - CGX_DestroyWindow (this, screen); + CGX_DestroyWindow(this, screen); } /* See if we have been given a window id */ if (SDL_windowid) { - SDL_Window = (struct Window *) atol (SDL_windowid); + SDL_Window = (struct Window *) atol(SDL_windowid); } else { SDL_Window = 0; } @@ -710,7 +706,7 @@ break; } if (i == this->hidden->nvisuals) { - SDL_SetError ("No matching visual for requested depth"); + SDL_SetError("No matching visual for requested depth"); return -1; /* should never happen */ } vis = this->hidden->visuals[i].visual; @@ -718,7 +714,7 @@ // } SDL_Visual = vis; this->hidden->depth = depth; - D (bug ("Setting screen depth to: %ld\n", this->hidden->depth)); + D(bug("Setting screen depth to: %ld\n", this->hidden->depth)); #endif /* Allocate the new pixel format for this video mode */ @@ -727,40 +723,40 @@ APTR handle; struct DisplayInfo info; - if (!(handle = FindDisplayInfo (SDL_Visual))) + if (!(handle = FindDisplayInfo(SDL_Visual))) return -1; if (!GetDisplayInfoData - (handle, (char *) &info, sizeof (struct DisplayInfo), DTAG_DISP, + (handle, (char *) &info, sizeof(struct DisplayInfo), DTAG_DISP, NULL)) return -1; - form = GetCyberIDAttr (CYBRIDATTR_PIXFMT, SDL_Visual); + form = GetCyberIDAttr(CYBRIDATTR_PIXFMT, SDL_Visual); if (flags & SDL_HWSURFACE) { if (bpp != this->hidden->depth) { bpp = this->hidden->depth; - D (bug ("Accel forces bpp to be equal (%ld)\n", bpp)); + D(bug("Accel forces bpp to be equal (%ld)\n", bpp)); } } - D (bug - ("BEFORE screen allocation: bpp:%ld (real:%ld)\n", bpp, - this->hidden->depth)); + D(bug + ("BEFORE screen allocation: bpp:%ld (real:%ld)\n", bpp, + this->hidden->depth)); /* With this call if needed I'll revert the wanted bpp to a bpp best suited for the display, actually occurs only with requested format 15/16bit and display format != 15/16bit */ - if (!SDL_ReallocFormat (screen, bpp, - MakeBitMask (this, 0, form, &bpp), - MakeBitMask (this, 1, form, &bpp), - MakeBitMask (this, 2, form, &bpp), 0)) + if (!SDL_ReallocFormat(screen, bpp, + MakeBitMask(this, 0, form, &bpp), + MakeBitMask(this, 1, form, &bpp), + MakeBitMask(this, 2, form, &bpp), 0)) return -1; - D (bug - ("AFTER screen allocation: bpp:%ld (real:%ld)\n", bpp, - this->hidden->depth)); + D(bug + ("AFTER screen allocation: bpp:%ld (real:%ld)\n", bpp, + this->hidden->depth)); } @@ -770,10 +766,10 @@ XFreeColormap(SDL_Display, SDL_XColorMap); } */ - if (GetCyberMapAttr (SDL_Display->RastPort.BitMap, CYBRMATTR_PIXFMT) == + if (GetCyberMapAttr(SDL_Display->RastPort.BitMap, CYBRMATTR_PIXFMT) == PIXFMT_LUT8 || bpp == 8) { int ncolors, i; - D (bug ("XPixels palette allocation...\n")); + D(bug("XPixels palette allocation...\n")); /* Allocate the pixel flags */ @@ -782,10 +778,10 @@ else ncolors = 1 << screen->format->BitsPerPixel; - SDL_XPixels = (Sint32 *) SDL_malloc (ncolors * sizeof (Sint32)); + SDL_XPixels = (Sint32 *) SDL_malloc(ncolors * sizeof(Sint32)); if (SDL_XPixels == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return -1; } @@ -807,19 +803,19 @@ if (!SDL_windowid) { if (flags & SDL_FULLSCREEN) { - SDL_Window = OpenWindowTags (NULL, WA_Width, w, WA_Height, h, - WA_Flags, - WFLG_ACTIVATE | WFLG_RMBTRAP | - WFLG_BORDERLESS | WFLG_BACKDROP | - WFLG_REPORTMOUSE, WA_IDCMP, - IDCMP_RAWKEY | IDCMP_MOUSEBUTTONS - | IDCMP_MOUSEMOVE, - WA_CustomScreen, - (ULONG) SDL_Display, TAG_DONE); + SDL_Window = OpenWindowTags(NULL, WA_Width, w, WA_Height, h, + WA_Flags, + WFLG_ACTIVATE | WFLG_RMBTRAP | + WFLG_BORDERLESS | WFLG_BACKDROP | + WFLG_REPORTMOUSE, WA_IDCMP, + IDCMP_RAWKEY | IDCMP_MOUSEBUTTONS + | IDCMP_MOUSEMOVE, + WA_CustomScreen, + (ULONG) SDL_Display, TAG_DONE); - D (bug - ("Opening backdrop window %ldx%ld on display %lx!\n", w, h, - SDL_Display)); + D(bug + ("Opening backdrop window %ldx%ld on display %lx!\n", w, h, + SDL_Display)); } else { /* Create GimmeZeroZero window when OpenGL is used */ unsigned long gzz = FALSE; @@ -828,24 +824,24 @@ } SDL_Window = - OpenWindowTags (NULL, WA_InnerWidth, w, WA_InnerHeight, h, - WA_Flags, - WFLG_REPORTMOUSE | WFLG_ACTIVATE | - WFLG_RMBTRAP | ((flags & SDL_NOFRAME) ? 0 - : (WFLG_DEPTHGADGET | - WFLG_CLOSEGADGET | - WFLG_DRAGBAR | - ((flags & - SDL_RESIZABLE) ? - WFLG_SIZEGADGET | - WFLG_SIZEBBOTTOM : - 0))), WA_IDCMP, - IDCMP_RAWKEY | IDCMP_CLOSEWINDOW | - IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | - IDCMP_MOUSEMOVE, WA_PubScreen, - (ULONG) SDL_Display, WA_GimmeZeroZero, - gzz, TAG_DONE); - D (bug ("Opening WB window of size: %ldx%ld!\n", w, h)); + OpenWindowTags(NULL, WA_InnerWidth, w, WA_InnerHeight, h, + WA_Flags, + WFLG_REPORTMOUSE | WFLG_ACTIVATE | + WFLG_RMBTRAP | ((flags & SDL_NOFRAME) ? 0 + : (WFLG_DEPTHGADGET | + WFLG_CLOSEGADGET | + WFLG_DRAGBAR | + ((flags & + SDL_RESIZABLE) ? + WFLG_SIZEGADGET | + WFLG_SIZEBBOTTOM : + 0))), WA_IDCMP, + IDCMP_RAWKEY | IDCMP_CLOSEWINDOW | + IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | + IDCMP_MOUSEMOVE, WA_PubScreen, + (ULONG) SDL_Display, WA_GimmeZeroZero, + gzz, TAG_DONE); + D(bug("Opening WB window of size: %ldx%ld!\n", w, h)); } if (!SDL_Window) @@ -853,11 +849,11 @@ } this->hidden->BytesPerPixel = - GetCyberMapAttr (SDL_Window->RPort->BitMap, CYBRMATTR_BPPIX); + GetCyberMapAttr(SDL_Window->RPort->BitMap, CYBRMATTR_BPPIX); if (screen->flags & SDL_DOUBLEBUF) { - if (SDL_RastPort = SDL_malloc (sizeof (struct RastPort))) { - InitRastPort (SDL_RastPort); + if (SDL_RastPort = SDL_malloc(sizeof(struct RastPort))) { + InitRastPort(SDL_RastPort); SDL_RastPort->BitMap = this->hidden->SB[1]->sb_BitMap; } else return -1; @@ -868,7 +864,7 @@ screen->flags |= SDL_HWSURFACE; if (!SDL_windowid) { - CGX_SetSizeHints (this, w, h, flags); + CGX_SetSizeHints(this, w, h, flags); } /* Set our colormaps when not setting a GL mode */ @@ -890,18 +886,18 @@ } screen->w = w; screen->h = h; - screen->pitch = SDL_CalculatePitch (screen); - CGX_ResizeImage (this, screen, flags); + screen->pitch = SDL_CalculatePitch(screen); + CGX_ResizeImage(this, screen, flags); /* Make OpenGL Context if needed */ if (flags & SDL_INTERNALOPENGL) { if (this->gl_data->gl_active == 0) { - if (CGX_GL_Init (this) < 0) + if (CGX_GL_Init(this) < 0) return -1; else screen->flags |= SDL_INTERNALOPENGL; } else { - if (CGX_GL_Update (this) < 0) + if (CGX_GL_Update(this) < 0) return -1; else screen->flags |= SDL_INTERNALOPENGL; @@ -910,40 +906,39 @@ } int -CGX_ResizeWindow (_THIS, SDL_Surface * screen, int w, int h, Uint32 flags) +CGX_ResizeWindow(_THIS, SDL_Surface * screen, int w, int h, Uint32 flags) { - D (bug ("CGX_ResizeWindow\n")); + D(bug("CGX_ResizeWindow\n")); if (!SDL_windowid) { /* Resize the window manager window */ - CGX_SetSizeHints (this, w, h, flags); + CGX_SetSizeHints(this, w, h, flags); - ChangeWindowBox (SDL_Window, SDL_Window->LeftEdge, - SDL_Window->TopEdge, - w + SDL_Window->BorderLeft + - SDL_Window->BorderRight, - h + SDL_Window->BorderTop + - SDL_Window->BorderBottom); + ChangeWindowBox(SDL_Window, SDL_Window->LeftEdge, + SDL_Window->TopEdge, + w + SDL_Window->BorderLeft + + SDL_Window->BorderRight, + h + SDL_Window->BorderTop + SDL_Window->BorderBottom); screen->w = w; screen->h = h; - screen->pitch = SDL_CalculatePitch (screen); - CGX_ResizeImage (this, screen, flags); + screen->pitch = SDL_CalculatePitch(screen); + CGX_ResizeImage(this, screen, flags); } return (0); } static SDL_Surface * -CGX_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +CGX_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { Uint32 saved_flags; int needcreate = 0; - D (bug ("CGX_SetVideoMode current:%lx\n", current)); + D(bug("CGX_SetVideoMode current:%lx\n", current)); /* Lock the event thread, in multi-threading environments */ - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); // Check if the window needs to be closed or can be resized @@ -957,27 +952,27 @@ if (current && current->flags & SDL_FULLSCREEN && !(flags & SDL_FULLSCREEN)) { unsigned long i; - D (bug ("Destroying image, window & screen!\n")); + D(bug("Destroying image, window & screen!\n")); - CGX_DestroyImage (this, current); - CGX_DestroyWindow (this, current); - DestroyScreen (this); - GFX_Display = SDL_Display = LockPubScreen (NULL); + CGX_DestroyImage(this, current); + CGX_DestroyWindow(this, current); + DestroyScreen(this); + GFX_Display = SDL_Display = LockPubScreen(NULL); bpp = this->hidden->depth = - GetCyberMapAttr (SDL_Display->RastPort.BitMap, CYBRMATTR_DEPTH); + GetCyberMapAttr(SDL_Display->RastPort.BitMap, CYBRMATTR_DEPTH); for (i = 0; i < this->hidden->nvisuals; i++) { if (this->hidden->visuals[i].depth == bpp) /* era .depth */ break; } if (i == this->hidden->nvisuals) { - SDL_SetError ("No matching visual for requested depth"); + SDL_SetError("No matching visual for requested depth"); return NULL; /* should never happen */ } SDL_Visual = this->hidden->visuals[i].visual; - D (bug ("Setting screen depth to: %ld\n", this->hidden->depth)); + D(bug("Setting screen depth to: %ld\n", this->hidden->depth)); } /* Check the combination of flags we were passed */ @@ -991,72 +986,72 @@ if (current->w != width || current->h != height || (this->hidden && this->hidden->depth != bpp)) { - D (bug ("Deleting previous window...\n")); - CGX_DestroyImage (this, current); - CGX_DestroyWindow (this, current); - DestroyScreen (this); + D(bug("Deleting previous window...\n")); + CGX_DestroyImage(this, current); + CGX_DestroyWindow(this, current); + DestroyScreen(this); goto buildnewscreen; } } else buildnewscreen: { - Uint32 okid = BestCModeIDTags (CYBRBIDTG_NominalWidth, width, - CYBRBIDTG_NominalHeight, - height, - CYBRBIDTG_Depth, bpp, - TAG_DONE); + Uint32 okid = BestCModeIDTags(CYBRBIDTG_NominalWidth, width, + CYBRBIDTG_NominalHeight, + height, + CYBRBIDTG_Depth, bpp, + TAG_DONE); GFX_Display = NULL; - D (bug ("Opening screen...\n")); + D(bug("Opening screen...\n")); if (okid != INVALID_ID) - GFX_Display = OpenScreenTags (NULL, - SA_Width, width, - SA_Height, height, - SA_Quiet, TRUE, - SA_ShowTitle, FALSE, - SA_Depth, bpp, SA_DisplayID, - okid, TAG_DONE); + GFX_Display = OpenScreenTags(NULL, + SA_Width, width, + SA_Height, height, + SA_Quiet, TRUE, + SA_ShowTitle, FALSE, + SA_Depth, bpp, SA_DisplayID, + okid, TAG_DONE); if (!GFX_Display) { GFX_Display = SDL_Display; flags &= ~SDL_FULLSCREEN; flags &= ~SDL_DOUBLEBUF; } else { - UnlockPubScreen (NULL, SDL_Display); + UnlockPubScreen(NULL, SDL_Display); SDL_Display = GFX_Display; - D (bug ("Screen opened.\n")); + D(bug("Screen opened.\n")); if (flags & SDL_DOUBLEBUF) { int ok = 0; - D (bug ("Start of DBuffering allocations...\n")); + D(bug("Start of DBuffering allocations...\n")); if (this->hidden->SB[0] = - AllocScreenBuffer (SDL_Display, NULL, - SB_SCREEN_BITMAP)) { + AllocScreenBuffer(SDL_Display, NULL, + SB_SCREEN_BITMAP)) { if (this->hidden->SB[1] = - AllocScreenBuffer (SDL_Display, NULL, 0L)) { + AllocScreenBuffer(SDL_Display, NULL, 0L)) { extern struct MsgPort *safeport, *dispport; - safeport = CreateMsgPort (); - dispport = CreateMsgPort (); + safeport = CreateMsgPort(); + dispport = CreateMsgPort(); if (!safeport || !dispport) { if (safeport) { - DeleteMsgPort (safeport); + DeleteMsgPort(safeport); safeport = NULL; } if (dispport) { - DeleteMsgPort (dispport); + DeleteMsgPort(dispport); dispport = NULL; } - FreeScreenBuffer (SDL_Display, - this->hidden->SB[0]); - FreeScreenBuffer (SDL_Display, - this->hidden->SB[1]); + FreeScreenBuffer(SDL_Display, + this->hidden->SB[0]); + FreeScreenBuffer(SDL_Display, + this->hidden->SB[1]); } else { extern ULONG safe_sigbit, disp_sigbit; int i; @@ -1076,13 +1071,13 @@ } ok = 1; - D (bug ("Dbuffering enabled!\n")); + D(bug("Dbuffering enabled!\n")); this->hidden->dbuffer = 1; current->flags |= SDL_DOUBLEBUF; } } else { - FreeScreenBuffer (SDL_Display, - this->hidden->SB[1]); + FreeScreenBuffer(SDL_Display, + this->hidden->SB[1]); this->hidden->SB[0] = NULL; } } @@ -1098,15 +1093,15 @@ } bpp = this->hidden->depth = - GetCyberMapAttr (SDL_Display->RastPort.BitMap, CYBRMATTR_DEPTH); - D (bug ("Setting screen depth to: %ld\n", this->hidden->depth)); + GetCyberMapAttr(SDL_Display->RastPort.BitMap, CYBRMATTR_DEPTH); + D(bug("Setting screen depth to: %ld\n", this->hidden->depth)); for (i = 0; i < this->hidden->nvisuals; i++) if (this->hidden->visuals[i].depth == bpp) /* era .depth */ break; if (i == this->hidden->nvisuals) { - SDL_SetError ("No matching visual for requested depth"); + SDL_SetError("No matching visual for requested depth"); return NULL; /* should never happen */ } SDL_Visual = this->hidden->visuals[i].visual; @@ -1119,12 +1114,12 @@ if (SDL_Window && (saved_flags & SDL_INTERNALOPENGL) == (flags & SDL_INTERNALOPENGL) && bpp == current->format->BitsPerPixel && !needcreate) { - if (CGX_ResizeWindow (this, current, width, height, flags) < 0) { + if (CGX_ResizeWindow(this, current, width, height, flags) < 0) { current = NULL; goto done; } } else { - if (CGX_CreateWindow (this, current, width, height, bpp, flags) < 0) { + if (CGX_CreateWindow(this, current, width, height, bpp, flags) < 0) { current = NULL; goto done; } @@ -1137,8 +1132,8 @@ { current->w = width; current->h = height; - current->pitch = SDL_CalculatePitch (current); - CGX_ResizeImage (this, current, flags); + current->pitch = SDL_CalculatePitch(current); + CGX_ResizeImage(this, current, flags); } #endif @@ -1146,14 +1141,14 @@ done: /* Release the event thread */ - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); /* We're done! */ return (current); } static int -CGX_ToggleFullScreen (_THIS, int on) +CGX_ToggleFullScreen(_THIS, int on) { Uint32 event_thread; @@ -1163,34 +1158,34 @@ } /* Don't lock if we are the event thread */ - event_thread = SDL_EventThreadID (); - if (event_thread && (SDL_ThreadID () == event_thread)) { + event_thread = SDL_EventThreadID(); + if (event_thread && (SDL_ThreadID() == event_thread)) { event_thread = 0; } if (event_thread) { - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); } if (on) { this->screen->flags |= SDL_FULLSCREEN; - CGX_EnterFullScreen (this); + CGX_EnterFullScreen(this); } else { this->screen->flags &= ~SDL_FULLSCREEN; - CGX_LeaveFullScreen (this); + CGX_LeaveFullScreen(this); } - CGX_RefreshDisplay (this); + CGX_RefreshDisplay(this); if (event_thread) { - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); } - SDL_ResetKeyboard (); + SDL_ResetKeyboard(); return (1); } static void -SetSingleColor (Uint32 fmt, unsigned char r, unsigned char g, unsigned char b, - unsigned char *c) +SetSingleColor(Uint32 fmt, unsigned char r, unsigned char g, unsigned char b, + unsigned char *c) { switch (fmt) { case PIXFMT_BGR15: @@ -1253,21 +1248,21 @@ break; default: - D (bug ("Error, SetSingleColor with PIXFMT %ld!\n", fmt)); + D(bug("Error, SetSingleColor with PIXFMT %ld!\n", fmt)); } } /* Update the current mouse state and position */ static void -CGX_UpdateMouse (_THIS) +CGX_UpdateMouse(_THIS) { /* Lock the event thread, in multi-threading environments */ - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); if (currently_fullscreen) { - SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); - SDL_PrivateMouseMotion (0, 0, SDL_Display->MouseX, - SDL_Display->MouseY); + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); + SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX, + SDL_Display->MouseY); } else { if (SDL_Display->MouseX >= (SDL_Window->LeftEdge + SDL_Window->BorderLeft) @@ -1279,23 +1274,23 @@ && SDL_Display->MouseY < (SDL_Window->TopEdge + SDL_Window->Height - SDL_Window->BorderBottom)) { - SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); - SDL_PrivateMouseMotion (0, 0, - SDL_Display->MouseX - - SDL_Window->LeftEdge - - SDL_Window->BorderLeft, - SDL_Display->MouseY - - SDL_Window->TopEdge - - SDL_Window->BorderTop); + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); + SDL_PrivateMouseMotion(0, 0, + SDL_Display->MouseX - + SDL_Window->LeftEdge - + SDL_Window->BorderLeft, + SDL_Display->MouseY - + SDL_Window->TopEdge - + SDL_Window->BorderTop); } else { - SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } } - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); } static int -CGX_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +CGX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { int i; @@ -1316,50 +1311,50 @@ xcmap[i * 3 + 3] = colors[i + firstcolor].b << 24; } xcmap[ncolors * 3 + 1] = 0; - LoadRGB32 (&GFX_Display->ViewPort, xcmap); + LoadRGB32(&GFX_Display->ViewPort, xcmap); } else { // XPixels are not needed on 8bit screen with hwpalette unsigned long pixel; if (SDL_XPixels == NULL) { - D (bug ("SetColors without colormap!")); + D(bug("SetColors without colormap!")); return (0); } if (this->hidden->depth == 8) { // In this case I have to unalloc and realloc the full palette - D (bug ("Obtaining %ld colors on the screen\n", ncolors)); + D(bug("Obtaining %ld colors on the screen\n", ncolors)); /* Free existing allocated colors */ for (pixel = 0; pixel < this->screen->format->palette->ncolors; ++pixel) { if (SDL_XPixels[pixel] >= 0) - ReleasePen (GFX_Display->ViewPort.ColorMap, - SDL_XPixels[pixel]); + ReleasePen(GFX_Display->ViewPort.ColorMap, + SDL_XPixels[pixel]); } /* Try to allocate all the colors */ for (i = 0; i < this->screen->format->palette->ncolors; ++i) { SDL_XPixels[i] = - ObtainBestPenA (GFX_Display->ViewPort.ColorMap, - colors[i].r << 24, - colors[i].g << 24, - colors[i].b << 24, NULL); + ObtainBestPenA(GFX_Display->ViewPort.ColorMap, + colors[i].r << 24, + colors[i].g << 24, + colors[i].b << 24, NULL); } } else { #ifndef USE_CGX_WRITELUTPIXEL Uint32 fmt; - D (bug ("Preparing a conversion pixel table...\n")); + D(bug("Preparing a conversion pixel table...\n")); fmt = - GetCyberMapAttr (SDL_Display->RastPort.BitMap, - CYBRMATTR_PIXFMT); + GetCyberMapAttr(SDL_Display->RastPort.BitMap, + CYBRMATTR_PIXFMT); for (i = 0; i < ncolors; i++) { - SetSingleColor (fmt, colors[firstcolor + i].r, - colors[firstcolor + i].g, - colors[firstcolor + i].b, (unsigned char *) - &SDL_XPixels[firstcolor + i]); + SetSingleColor(fmt, colors[firstcolor + i].r, + colors[firstcolor + i].g, + colors[firstcolor + i].b, (unsigned char *) + &SDL_XPixels[firstcolor + i]); } #else // D(bug("Executing XPixel(%lx) remapping: (from %ld, %ld colors) first: r%ld g%ld b%ld\n",SDL_XPixels,firstcolor,ncolors,colors[firstcolor].r,colors[firstcolor].g,colors[firstcolor].b)); @@ -1381,40 +1376,40 @@ another SDL video routine -- notably UpdateRects. */ static void -CGX_VideoQuit (_THIS) +CGX_VideoQuit(_THIS) { /* Shutdown everything that's still up */ /* The event thread should be done, so we can touch SDL_Display */ - D (bug ("CGX_VideoQuit\n")); + D(bug("CGX_VideoQuit\n")); if (SDL_Display != NULL) { /* Clean up OpenGL */ if (this->gl_data->gl_active == 1) { - CGX_GL_Quit (this); + CGX_GL_Quit(this); } /* Start shutting down the windows */ - D (bug ("Destroying image...\n")); - CGX_DestroyImage (this, this->screen); - D (bug ("Destroying window...\n")); - CGX_DestroyWindow (this, this->screen); + D(bug("Destroying image...\n")); + CGX_DestroyImage(this, this->screen); + D(bug("Destroying window...\n")); + CGX_DestroyWindow(this, this->screen); // Otherwise SDL_VideoQuit will try to free it! SDL_VideoSurface = NULL; - CGX_FreeVideoModes (this); + CGX_FreeVideoModes(this); /* Free that blank cursor */ if (SDL_BlankCursor != NULL) { - FreeMem (SDL_BlankCursor, 16); + FreeMem(SDL_BlankCursor, 16); SDL_BlankCursor = NULL; } /* Close the X11 graphics connection */ this->hidden->same_format = 0; - D (bug ("Destroying screen...\n")); + D(bug("Destroying screen...\n")); if (GFX_Display != NULL) - DestroyScreen (this); + DestroyScreen(this); /* Close the X11 display connection */ SDL_Display = NULL; @@ -1422,19 +1417,19 @@ /* Unload GL library after X11 shuts down */ } - D (bug ("Closing libraries...\n")); + D(bug("Closing libraries...\n")); if (CyberGfxBase) { - CloseLibrary (CyberGfxBase); + CloseLibrary(CyberGfxBase); CyberGfxBase = NULL; } if (IntuitionBase) { - CloseLibrary ((struct Library *) IntuitionBase); + CloseLibrary((struct Library *) IntuitionBase); IntuitionBase = NULL; } if (GfxBase) { - CloseLibrary ((struct Library *) GfxBase); + CloseLibrary((struct Library *) GfxBase); GfxBase = NULL; } @@ -1442,7 +1437,7 @@ /* Direct screen access, no memory buffer */ this->screen->pixels = NULL; } - D (bug ("End of CGX_VideoQuit.\n")); + D(bug("End of CGX_VideoQuit.\n")); } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/cybergfx/SDL_cgxvideo.h --- a/src/video/cybergfx/SDL_cgxvideo.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/cybergfx/SDL_cgxvideo.h Mon May 29 04:04:35 2006 +0000 @@ -148,13 +148,12 @@ /* Used to get the X cursor from a window-manager specific cursor */ // extern Cursor SDL_GetWMXCursor(WMcursor *cursor); -extern int CGX_CreateWindow (_THIS, SDL_Surface * screen, - int w, int h, int bpp, Uint32 flags); -extern int CGX_ResizeWindow (_THIS, - SDL_Surface * screen, int w, int h, - Uint32 flags); +extern int CGX_CreateWindow(_THIS, SDL_Surface * screen, + int w, int h, int bpp, Uint32 flags); +extern int CGX_ResizeWindow(_THIS, + SDL_Surface * screen, int w, int h, Uint32 flags); -extern void CGX_DestroyWindow (_THIS, SDL_Surface * screen); +extern void CGX_DestroyWindow(_THIS, SDL_Surface * screen); extern struct Library *CyberGfxBase; extern struct IntuitionBase *IntuitionBase; @@ -171,9 +170,9 @@ int allocated; }; -int CGX_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst); -int CGX_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * dstrect, - Uint32 color); -int CGX_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key); +int CGX_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst); +int CGX_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * dstrect, + Uint32 color); +int CGX_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key); #endif /* _SDL_x11video_h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/cybergfx/SDL_cgxwm.c --- a/src/video/cybergfx/SDL_cgxwm.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/cybergfx/SDL_cgxwm.c Mon May 29 04:04:35 2006 +0000 @@ -34,34 +34,34 @@ #define USE_ICON_WINDOW void -CGX_SetIcon (_THIS, SDL_Surface * icon, Uint8 * mask) +CGX_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask) { /* Not yet implemented */ } void -CGX_SetCaption (_THIS, const char *title, const char *icon) +CGX_SetCaption(_THIS, const char *title, const char *icon) { if (SDL_Window) - SetWindowTitles (SDL_Window, (char *) title, NULL); + SetWindowTitles(SDL_Window, (char *) title, NULL); } /* Iconify the window */ int -CGX_IconifyWindow (_THIS) +CGX_IconifyWindow(_THIS) { /* Not yet implemented */ return 0; } int -CGX_GetWMInfo (_THIS, SDL_SysWMinfo * info) +CGX_GetWMInfo(_THIS, SDL_SysWMinfo * info) { if (info->version.major <= SDL_MAJOR_VERSION) { return (1); } else { - SDL_SetError ("Application not compiled with SDL %d.%d\n", - SDL_MAJOR_VERSION, SDL_MINOR_VERSION); + SDL_SetError("Application not compiled with SDL %d.%d\n", + SDL_MAJOR_VERSION, SDL_MINOR_VERSION); return (-1); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/cybergfx/SDL_cgxwm_c.h --- a/src/video/cybergfx/SDL_cgxwm_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/cybergfx/SDL_cgxwm_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,10 +24,10 @@ #include "SDL_cgxvideo.h" /* Functions to be exported */ -extern void CGX_SetCaption (_THIS, const char *title, const char *icon); -extern void CGX_SetIcon (_THIS, SDL_Surface * icon, Uint8 * mask); -extern int CGX_IconifyWindow (_THIS); -extern SDL_GrabMode CGX_GrabInputNoLock (_THIS, SDL_GrabMode mode); -extern SDL_GrabMode CGX_GrabInput (_THIS, SDL_GrabMode mode); -extern int CGX_GetWMInfo (_THIS, SDL_SysWMinfo * info); +extern void CGX_SetCaption(_THIS, const char *title, const char *icon); +extern void CGX_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask); +extern int CGX_IconifyWindow(_THIS); +extern SDL_GrabMode CGX_GrabInputNoLock(_THIS, SDL_GrabMode mode); +extern SDL_GrabMode CGX_GrabInput(_THIS, SDL_GrabMode mode); +extern int CGX_GetWMInfo(_THIS, SDL_SysWMinfo * info); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/dc/SDL_dcevents.c --- a/src/video/dc/SDL_dcevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/dc/SDL_dcevents.c Mon May 29 04:04:35 2006 +0000 @@ -61,7 +61,7 @@ #define MOUSE_WHEELDOWN (1<<5) static void -mouse_update (void) +mouse_update(void) { const static char sdl_mousebtn[] = { MOUSE_LEFTBUTTON, @@ -78,8 +78,7 @@ int buttons, changed; int i; - if ((addr = maple_first_mouse ()) == 0 - || mouse_get_cond (addr, &cond) < 0) + if ((addr = maple_first_mouse()) == 0 || mouse_get_cond(addr, &cond) < 0) return; buttons = cond.buttons ^ 0xff; @@ -89,20 +88,20 @@ buttons |= MOUSE_WHEELDOWN; if (cond.dx || cond.dy) - SDL_PrivateMouseMotion (0, 1, cond.dx, cond.dy); + SDL_PrivateMouseMotion(0, 1, cond.dx, cond.dy); changed = buttons ^ prev_buttons; - for (i = 0; i < sizeof (sdl_mousebtn); i++) { + for (i = 0; i < sizeof(sdl_mousebtn); i++) { if (changed & sdl_mousebtn[i]) { - SDL_PrivateMouseButton ((buttons & sdl_mousebtn[i]) ? - SDL_PRESSED : SDL_RELEASED, i, 0, 0); + SDL_PrivateMouseButton((buttons & sdl_mousebtn[i]) ? + SDL_PRESSED : SDL_RELEASED, i, 0, 0); } } prev_buttons = buttons; } static void -keyboard_update (void) +keyboard_update(void) { static kbd_state_t old_state; static uint8 old_addr; @@ -116,40 +115,40 @@ int i; - addr = maple_first_kb (); + addr = maple_first_kb(); if (addr == 0) return; if (addr != old_addr) { old_addr = addr; - SDL_memset (&old_state, 0, sizeof (old_state)); + SDL_memset(&old_state, 0, sizeof(old_state)); } - maple_raddr (addr, &port, &unit); + maple_raddr(addr, &port, &unit); - state = maple_dev_state (port, unit); + state = maple_dev_state(port, unit); if (!state) return; shiftkeys = state->shift_keys ^ old_state.shift_keys; - for (i = 0; i < sizeof (sdl_shift); i++) { + for (i = 0; i < sizeof(sdl_shift); i++) { if ((shiftkeys >> i) & 1) { keysym.sym = sdl_shift[i]; - SDL_PrivateKeyboard (((state-> - shift_keys >> i) & 1) ? SDL_PRESSED : - SDL_RELEASED, &keysym); + SDL_PrivateKeyboard(((state-> + shift_keys >> i) & 1) ? SDL_PRESSED : + SDL_RELEASED, &keysym); } } - for (i = 0; i < sizeof (sdl_key); i++) { + for (i = 0; i < sizeof(sdl_key); i++) { if (state->matrix[i] != old_state.matrix[i]) { int key = sdl_key[i]; if (key) { keysym.sym = key; - SDL_PrivateKeyboard (state-> - matrix[i] ? SDL_PRESSED : - SDL_RELEASED, &keysym); + SDL_PrivateKeyboard(state-> + matrix[i] ? SDL_PRESSED : + SDL_RELEASED, &keysym); } } } @@ -158,14 +157,14 @@ } void -DC_PumpEvents (_THIS) +DC_PumpEvents(_THIS) { - keyboard_update (); - mouse_update (); + keyboard_update(); + mouse_update(); } void -DC_InitOSKeymap (_THIS) +DC_InitOSKeymap(_THIS) { /* do nothing. */ } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/dc/SDL_dcevents_c.h --- a/src/video/dc/SDL_dcevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/dc/SDL_dcevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -26,8 +26,8 @@ /* Variables and functions exported by SDL_sysevents.c to other parts of the native video subsystem (SDL_sysvideo.c) */ -extern void DC_InitOSKeymap (_THIS); -extern void DC_PumpEvents (_THIS); +extern void DC_InitOSKeymap(_THIS); +extern void DC_PumpEvents(_THIS); /* end of SDL_dcevents_c.h ... */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/dc/SDL_dcvideo.c --- a/src/video/dc/SDL_dcvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/dc/SDL_dcvideo.c Mon May 29 04:04:35 2006 +0000 @@ -36,68 +36,67 @@ /* Initialization/Query functions */ -static int DC_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **DC_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *DC_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int DC_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void DC_VideoQuit (_THIS); +static int DC_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **DC_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags); +static SDL_Surface *DC_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +static int DC_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void DC_VideoQuit(_THIS); /* Hardware surface functions */ -static int DC_AllocHWSurface (_THIS, SDL_Surface * surface); -static int DC_LockHWSurface (_THIS, SDL_Surface * surface); -static void DC_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void DC_FreeHWSurface (_THIS, SDL_Surface * surface); -static int DC_FlipHWSurface (_THIS, SDL_Surface * surface); +static int DC_AllocHWSurface(_THIS, SDL_Surface * surface); +static int DC_LockHWSurface(_THIS, SDL_Surface * surface); +static void DC_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void DC_FreeHWSurface(_THIS, SDL_Surface * surface); +static int DC_FlipHWSurface(_THIS, SDL_Surface * surface); /* etc. */ -static void DC_UpdateRects (_THIS, int numrects, SDL_Rect * rects); +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); +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 */ static int -DC_Available (void) +DC_Available(void) { return 1; } static void -DC_DeleteDevice (SDL_VideoDevice * device) +DC_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -DC_CreateDevice (int devindex) +DC_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = DC_VideoInit; @@ -143,7 +142,7 @@ int -DC_VideoInit (_THIS, SDL_PixelFormat * vformat) +DC_VideoInit(_THIS, SDL_PixelFormat * vformat) { /* Determine the screen depth (use default 16-bit depth) */ /* we change this during the SDL_SetVideoMode implementation... */ @@ -167,7 +166,7 @@ }; SDL_Rect ** -DC_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +DC_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { switch (format->BitsPerPixel) { case 15: @@ -197,8 +196,8 @@ #endif SDL_Surface * -DC_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +DC_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { int disp_mode, pixel_mode, pitch; Uint32 Rmask, Gmask, Bmask; @@ -210,7 +209,7 @@ else if (width == 800 && height == 600) disp_mode = DM_800x608; else { - SDL_SetError ("Couldn't find requested mode in list"); + SDL_SetError("Couldn't find requested mode in list"); return (NULL); } @@ -244,12 +243,12 @@ #endif break; default: - SDL_SetError ("Couldn't find requested mode in list"); + SDL_SetError("Couldn't find requested mode in list"); return (NULL); } // if ( bpp != current->format->BitsPerPixel ) { - if (!SDL_ReallocFormat (current, bpp, Rmask, Gmask, Bmask, 0)) { + if (!SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0)) { return (NULL); } // } @@ -263,11 +262,11 @@ #if SDL_VIDEO_OPENGL if (pvr_inited) { pvr_inited = 0; - pvr_shutdown (); + pvr_shutdown(); } #endif - vid_set_mode (disp_mode, pixel_mode); + vid_set_mode(disp_mode, pixel_mode); current->pixels = vram_s; @@ -277,9 +276,9 @@ current->flags = SDL_FULLSCREEN | SDL_INTERNALOPENGL; current->pixels = NULL; pvr_inited = 1; - pvr_init (¶ms); - glKosInit (); - glKosBeginFrame (); + pvr_init(¶ms); + glKosInit(); + glKosBeginFrame(); } else #endif if (flags | SDL_DOUBLEBUF) { @@ -293,47 +292,47 @@ /* We don't actually allow hardware surfaces other than the main one */ static int -DC_AllocHWSurface (_THIS, SDL_Surface * surface) +DC_AllocHWSurface(_THIS, SDL_Surface * surface) { return (-1); } static void -DC_FreeHWSurface (_THIS, SDL_Surface * surface) +DC_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } /* We need to wait for vertical retrace on page flipped displays */ static int -DC_LockHWSurface (_THIS, SDL_Surface * surface) +DC_LockHWSurface(_THIS, SDL_Surface * surface) { return (0); } static void -DC_UnlockHWSurface (_THIS, SDL_Surface * surface) +DC_UnlockHWSurface(_THIS, SDL_Surface * surface) { return; } static int -DC_FlipHWSurface (_THIS, SDL_Surface * surface) +DC_FlipHWSurface(_THIS, SDL_Surface * surface) { if (surface->flags & SDL_DOUBLEBUF) { - vid_set_start ((int) surface->pixels & 0xffffff); + vid_set_start((int) surface->pixels & 0xffffff); surface->pixels = (void *) ((int) surface->pixels ^ 0x400000); } return (0); } static void -DC_UpdateRects (_THIS, int numrects, SDL_Rect * rects) +DC_UpdateRects(_THIS, int numrects, SDL_Rect * rects) { /* do nothing. */ } static int -DC_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +DC_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { /* do nothing of note. */ return (1); @@ -343,12 +342,12 @@ another SDL video routine -- notably UpdateRects. */ static void -DC_VideoQuit (_THIS) +DC_VideoQuit(_THIS) { #if SDL_VIDEO_OPENGL if (pvr_inited) { pvr_inited = 0; - pvr_shutdown (); + pvr_shutdown(); } #endif } @@ -356,7 +355,7 @@ #if SDL_VIDEO_OPENGL void -dmyfunc (void) +dmyfunc(void) { } @@ -367,47 +366,47 @@ funcptr addr; } glfuncs[] = { #define DEF(func) {#func,&func} - DEF (glBegin), DEF (glBindTexture), DEF (glBlendFunc), DEF (glColor4f), + DEF(glBegin), DEF(glBindTexture), DEF(glBlendFunc), DEF(glColor4f), // DEF(glCopyImageID), - DEF (glDisable), - DEF (glEnable), - DEF (glEnd), - DEF (glFlush), - DEF (glGenTextures), - DEF (glGetString), - DEF (glLoadIdentity), - DEF (glMatrixMode), DEF (glOrtho), DEF (glPixelStorei), + DEF(glDisable), + DEF(glEnable), + DEF(glEnd), + DEF(glFlush), + DEF(glGenTextures), + DEF(glGetString), + DEF(glLoadIdentity), + DEF(glMatrixMode), DEF(glOrtho), DEF(glPixelStorei), // DEF(glPopAttrib), // DEF(glPopClientAttrib), { "glPopAttrib", &dmyfunc}, { - "glPopClientAttrib", &dmyfunc}, DEF (glPopMatrix), + "glPopClientAttrib", &dmyfunc}, DEF(glPopMatrix), // DEF(glPushAttrib), // DEF(glPushClientAttrib), { "glPushAttrib", &dmyfunc}, { "glPushClientAttrib", &dmyfunc}, - DEF (glPushMatrix), - DEF (glTexCoord2f), - DEF (glTexEnvf), - DEF (glTexImage2D), - DEF (glTexParameteri), - DEF (glTexSubImage2D), DEF (glVertex2i), DEF (glViewport), + DEF(glPushMatrix), + DEF(glTexCoord2f), + DEF(glTexEnvf), + DEF(glTexImage2D), + DEF(glTexParameteri), + DEF(glTexSubImage2D), DEF(glVertex2i), DEF(glViewport), #undef DEF }; static void * -DC_GL_GetProcAddress (_THIS, const char *proc) +DC_GL_GetProcAddress(_THIS, const char *proc) { void *ret; int i; - ret = glKosGetProcAddress (proc); + ret = glKosGetProcAddress(proc); if (ret) return ret; - for (i = 0; i < sizeof (glfuncs) / sizeof (glfuncs[0]); i++) { - if (SDL_strcmp (proc, glfuncs[i].name) == 0) + for (i = 0; i < sizeof(glfuncs) / sizeof(glfuncs[0]); i++) { + if (SDL_strcmp(proc, glfuncs[i].name) == 0) return glfuncs[i].addr; } @@ -415,7 +414,7 @@ } static int -DC_GL_LoadLibrary (_THIS, const char *path) +DC_GL_LoadLibrary(_THIS, const char *path) { this->gl_config.driver_loaded = 1; @@ -423,7 +422,7 @@ } static int -DC_GL_GetAttribute (_THIS, SDL_GLattr attrib, int *value) +DC_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) { GLenum mesa_attrib; int val; @@ -469,10 +468,10 @@ } static void -DC_GL_SwapBuffers (_THIS) +DC_GL_SwapBuffers(_THIS) { - glKosFinishFrame (); - glKosBeginFrame (); + glKosFinishFrame(); + glKosBeginFrame(); } #endif /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/dga/SDL_dgaevents.c --- a/src/video/dga/SDL_dgaevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/dga/SDL_dgaevents.c Mon May 29 04:04:35 2006 +0000 @@ -36,17 +36,17 @@ #include "../x11/SDL_x11dyn.h" /* Heheh we're using X11 event code */ -extern int X11_Pending (Display * display); -extern void X11_InitKeymap (void); -extern SDLKey X11_TranslateKeycode (Display * display, KeyCode kc); +extern int X11_Pending(Display * display); +extern void X11_InitKeymap(void); +extern SDLKey X11_TranslateKeycode(Display * display, KeyCode kc); static int -DGA_DispatchEvent (_THIS) +DGA_DispatchEvent(_THIS) { int posted; - SDL_NAME (XDGAEvent) xevent; + SDL_NAME(XDGAEvent) xevent; - XNextEvent (DGA_Display, (XEvent *) & xevent); + XNextEvent(DGA_Display, (XEvent *) & xevent); posted = 0; xevent.type -= DGA_event_base; @@ -56,9 +56,9 @@ case MotionNotify: { if (SDL_VideoSurface) { - posted = SDL_PrivateMouseMotion (0, 1, - xevent.xmotion.dx, - xevent.xmotion.dy); + posted = SDL_PrivateMouseMotion(0, 1, + xevent.xmotion.dx, + xevent.xmotion.dy); } } break; @@ -66,16 +66,16 @@ /* Mouse button press? */ case ButtonPress: { - posted = SDL_PrivateMouseButton (SDL_PRESSED, - xevent.xbutton.button, 0, 0); + posted = SDL_PrivateMouseButton(SDL_PRESSED, + xevent.xbutton.button, 0, 0); } break; /* Mouse button release? */ case ButtonRelease: { - posted = SDL_PrivateMouseButton (SDL_RELEASED, - xevent.xbutton.button, 0, 0); + posted = SDL_PrivateMouseButton(SDL_RELEASED, + xevent.xbutton.button, 0, 0); } break; @@ -86,14 +86,14 @@ KeyCode keycode; XKeyEvent xkey; - SDL_NAME (XDGAKeyEventToXKeyEvent) (&xevent.xkey, &xkey); + SDL_NAME(XDGAKeyEventToXKeyEvent) (&xevent.xkey, &xkey); keycode = xkey.keycode; #ifdef DEBUG_XEVENTS - printf ("KeyPress (X11 keycode = 0x%X)\n", xkey.keycode); + printf("KeyPress (X11 keycode = 0x%X)\n", xkey.keycode); #endif /* Get the translated SDL virtual keysym */ keysym.scancode = keycode; - keysym.sym = X11_TranslateKeycode (DGA_Display, keycode); + keysym.sym = X11_TranslateKeycode(DGA_Display, keycode); keysym.mod = KMOD_NONE; keysym.unicode = 0; @@ -103,7 +103,7 @@ char keybuf[32]; if (XLookupString - (&xkey, keybuf, sizeof (keybuf), NULL, &state)) { + (&xkey, keybuf, sizeof(keybuf), NULL, &state)) { /* * FIXME: XLookupString() may yield more than one * character, so we need a mechanism to allow for @@ -113,7 +113,7 @@ keysym.unicode = (Uint8) keybuf[0]; } } - posted = SDL_PrivateKeyboard (SDL_PRESSED, &keysym); + posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym); } break; @@ -124,17 +124,17 @@ KeyCode keycode; XKeyEvent xkey; - SDL_NAME (XDGAKeyEventToXKeyEvent) (&xevent.xkey, &xkey); + SDL_NAME(XDGAKeyEventToXKeyEvent) (&xevent.xkey, &xkey); keycode = xkey.keycode; #ifdef DEBUG_XEVENTS - printf ("KeyRelease (X11 keycode = 0x%X)\n", xkey.keycode); + printf("KeyRelease (X11 keycode = 0x%X)\n", xkey.keycode); #endif /* Get the translated SDL virtual keysym */ keysym.scancode = keycode; - keysym.sym = X11_TranslateKeycode (DGA_Display, keycode); + keysym.sym = X11_TranslateKeycode(DGA_Display, keycode); keysym.mod = KMOD_NONE; keysym.unicode = 0; - posted = SDL_PrivateKeyboard (SDL_RELEASED, &keysym); + posted = SDL_PrivateKeyboard(SDL_RELEASED, &keysym); } break; @@ -145,20 +145,20 @@ } void -DGA_PumpEvents (_THIS) +DGA_PumpEvents(_THIS) { /* Keep processing pending events */ - LOCK_DISPLAY (); - while (X11_Pending (DGA_Display)) { - DGA_DispatchEvent (this); + LOCK_DISPLAY(); + while (X11_Pending(DGA_Display)) { + DGA_DispatchEvent(this); } - UNLOCK_DISPLAY (); + UNLOCK_DISPLAY(); } void -DGA_InitOSKeymap (_THIS) +DGA_InitOSKeymap(_THIS) { - X11_InitKeymap (); + X11_InitKeymap(); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/dga/SDL_dgaevents_c.h --- a/src/video/dga/SDL_dgaevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/dga/SDL_dgaevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,6 +24,6 @@ #include "SDL_dgavideo.h" /* Functions to be exported */ -extern void DGA_PumpEvents (_THIS); -extern void DGA_InitOSKeymap (_THIS); +extern void DGA_PumpEvents(_THIS); +extern void DGA_InitOSKeymap(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/dga/SDL_dgavideo.c --- a/src/video/dga/SDL_dgavideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/dga/SDL_dgavideo.c Mon May 29 04:04:35 2006 +0000 @@ -44,40 +44,40 @@ /*#define DGA_DEBUG*/ /* Heheh we're using X11 event code */ -extern void X11_SaveScreenSaver (Display * display, int *saved_timeout, - BOOL * dpms); -extern void X11_DisableScreenSaver (Display * display); -extern void X11_RestoreScreenSaver (Display * display, int saved_timeout, - BOOL dpms); +extern void X11_SaveScreenSaver(Display * display, int *saved_timeout, + BOOL * dpms); +extern void X11_DisableScreenSaver(Display * display); +extern void X11_RestoreScreenSaver(Display * display, int saved_timeout, + BOOL dpms); /* Initialization/Query functions */ -static int DGA_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **DGA_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *DGA_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int DGA_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static int DGA_SetGammaRamp (_THIS, Uint16 * ramp); -static void DGA_VideoQuit (_THIS); +static int DGA_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **DGA_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +static SDL_Surface *DGA_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +static int DGA_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static int DGA_SetGammaRamp(_THIS, Uint16 * ramp); +static void DGA_VideoQuit(_THIS); /* Hardware surface functions */ -static int DGA_InitHWSurfaces (_THIS, SDL_Surface * screen, Uint8 * base, - int size); -static void DGA_FreeHWSurfaces (_THIS); -static int DGA_AllocHWSurface (_THIS, SDL_Surface * surface); -static int DGA_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * rect, - Uint32 color); -static int DGA_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst); -static int DGA_LockHWSurface (_THIS, SDL_Surface * surface); -static void DGA_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void DGA_FreeHWSurface (_THIS, SDL_Surface * surface); -static int DGA_FlipHWSurface (_THIS, SDL_Surface * surface); +static int DGA_InitHWSurfaces(_THIS, SDL_Surface * screen, Uint8 * base, + int size); +static void DGA_FreeHWSurfaces(_THIS); +static int DGA_AllocHWSurface(_THIS, SDL_Surface * surface); +static int DGA_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, + Uint32 color); +static int DGA_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst); +static int DGA_LockHWSurface(_THIS, SDL_Surface * surface); +static void DGA_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void DGA_FreeHWSurface(_THIS, SDL_Surface * surface); +static int DGA_FlipHWSurface(_THIS, SDL_Surface * surface); /* DGA driver bootstrap functions */ static int -DGA_Available (void) +DGA_Available(void) { const char *display = NULL; Display *dpy = NULL; @@ -86,65 +86,65 @@ /* The driver is available is available if the display is local and the DGA 2.0+ extension is available, and we can map mem. */ - if (SDL_X11_LoadSymbols ()) { - if ((SDL_strncmp (XDisplayName (display), ":", 1) == 0) || - (SDL_strncmp (XDisplayName (display), "unix:", 5) == 0)) { - dpy = XOpenDisplay (display); + if (SDL_X11_LoadSymbols()) { + if ((SDL_strncmp(XDisplayName(display), ":", 1) == 0) || + (SDL_strncmp(XDisplayName(display), "unix:", 5) == 0)) { + dpy = XOpenDisplay(display); if (dpy) { int events, errors, major, minor; - if (SDL_NAME (XDGAQueryExtension) + if (SDL_NAME(XDGAQueryExtension) (dpy, &events, &errors) - && SDL_NAME (XDGAQueryVersion) (dpy, &major, &minor)) { + && SDL_NAME(XDGAQueryVersion) (dpy, &major, &minor)) { int screen; - screen = DefaultScreen (dpy); + screen = DefaultScreen(dpy); if ((major >= 2) && - SDL_NAME (XDGAOpenFramebuffer) (dpy, screen)) { + SDL_NAME(XDGAOpenFramebuffer) (dpy, screen)) { available = 1; - SDL_NAME (XDGACloseFramebuffer) (dpy, screen); + SDL_NAME(XDGACloseFramebuffer) (dpy, screen); } } - XCloseDisplay (dpy); + XCloseDisplay(dpy); } } - SDL_X11_UnloadSymbols (); + SDL_X11_UnloadSymbols(); } return (available); } static void -DGA_DeleteDevice (SDL_VideoDevice * device) +DGA_DeleteDevice(SDL_VideoDevice * device) { if (device != NULL) { - SDL_free (device->hidden); - SDL_free (device); - SDL_X11_UnloadSymbols (); + SDL_free(device->hidden); + SDL_free(device); + SDL_X11_UnloadSymbols(); } } static SDL_VideoDevice * -DGA_CreateDevice (int devindex) +DGA_CreateDevice(int devindex) { SDL_VideoDevice *device = NULL; /* Initialize all variables that we clean on shutdown */ - if (SDL_X11_LoadSymbols ()) { - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + if (SDL_X11_LoadSymbols()) { + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } - SDL_X11_UnloadSymbols (); + SDL_X11_UnloadSymbols(); return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = DGA_VideoInit; @@ -184,7 +184,7 @@ }; static int -DGA_AddMode (_THIS, int bpp, int w, int h) +DGA_AddMode(_THIS, int bpp, int w, int h) { SDL_Rect *mode; int index; @@ -203,9 +203,9 @@ } /* Set up the new video mode rectangle */ - mode = (SDL_Rect *) SDL_malloc (sizeof *mode); + mode = (SDL_Rect *) SDL_malloc(sizeof *mode); if (mode == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } mode->x = 0; @@ -216,12 +216,12 @@ /* Allocate the new list of modes, and fill in the new mode */ next_mode = SDL_nummodes[index]; SDL_modelist[index] = (SDL_Rect **) - SDL_realloc (SDL_modelist[index], - (1 + next_mode + 1) * sizeof (SDL_Rect *)); + SDL_realloc(SDL_modelist[index], + (1 + next_mode + 1) * sizeof(SDL_Rect *)); if (SDL_modelist[index] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); SDL_nummodes[index] = 0; - SDL_free (mode); + SDL_free(mode); return (-1); } SDL_modelist[index][next_mode] = mode; @@ -233,75 +233,75 @@ /* This whole function is a hack. :) */ static Uint32 -get_video_size (_THIS) +get_video_size(_THIS) { /* This is a non-exported function from libXxf86dga.a */ - extern unsigned char *SDL_NAME (XDGAGetMappedMemory) (int screen); + extern unsigned char *SDL_NAME(XDGAGetMappedMemory) (int screen); FILE *proc; unsigned long mem; unsigned start, stop; char line[BUFSIZ]; Uint32 size; - mem = (unsigned long) SDL_NAME (XDGAGetMappedMemory) (DGA_Screen); + mem = (unsigned long) SDL_NAME(XDGAGetMappedMemory) (DGA_Screen); size = 0; - proc = fopen ("/proc/self/maps", "r"); + proc = fopen("/proc/self/maps", "r"); if (proc) { - while (fgets (line, sizeof (line) - 1, proc)) { - SDL_sscanf (line, "%x-%x", &start, &stop); + while (fgets(line, sizeof(line) - 1, proc)) { + SDL_sscanf(line, "%x-%x", &start, &stop); if (start == mem) { size = (Uint32) ((stop - start) / 1024); break; } } - fclose (proc); + fclose(proc); } return (size); } #ifdef DGA_DEBUG static void -PrintMode (SDL_NAME (XDGAMode) * mode) +PrintMode(SDL_NAME(XDGAMode) * mode) { - printf ("Mode: %s (%dx%d) at %d bpp (%f refresh, %d pitch) num: %d\n", - mode->name, - mode->viewportWidth, mode->viewportHeight, - mode->depth == 24 ? mode->bitsPerPixel : mode->depth, - mode->verticalRefresh, mode->bytesPerScanline, mode->num); - printf ("\tRGB: 0x%8.8x 0x%8.8x 0x%8.8x (%d - %s)\n", - mode->redMask, mode->greenMask, mode->blueMask, - mode->visualClass, - mode->visualClass == TrueColor ? "truecolor" : - mode->visualClass == DirectColor ? "directcolor" : - mode->visualClass == PseudoColor ? "pseudocolor" : "unknown"); - printf ("\tFlags: "); + printf("Mode: %s (%dx%d) at %d bpp (%f refresh, %d pitch) num: %d\n", + mode->name, + mode->viewportWidth, mode->viewportHeight, + mode->depth == 24 ? mode->bitsPerPixel : mode->depth, + mode->verticalRefresh, mode->bytesPerScanline, mode->num); + printf("\tRGB: 0x%8.8x 0x%8.8x 0x%8.8x (%d - %s)\n", + mode->redMask, mode->greenMask, mode->blueMask, + mode->visualClass, + mode->visualClass == TrueColor ? "truecolor" : + mode->visualClass == DirectColor ? "directcolor" : + mode->visualClass == PseudoColor ? "pseudocolor" : "unknown"); + printf("\tFlags: "); if (mode->flags & XDGAConcurrentAccess) - printf (" XDGAConcurrentAccess"); + printf(" XDGAConcurrentAccess"); if (mode->flags & XDGASolidFillRect) - printf (" XDGASolidFillRect"); + printf(" XDGASolidFillRect"); if (mode->flags & XDGABlitRect) - printf (" XDGABlitRect"); + printf(" XDGABlitRect"); if (mode->flags & XDGABlitTransRect) - printf (" XDGABlitTransRect"); + printf(" XDGABlitTransRect"); if (mode->flags & XDGAPixmap) - printf (" XDGAPixmap"); + printf(" XDGAPixmap"); if (mode->flags & XDGAInterlaced) - printf (" XDGAInterlaced"); + printf(" XDGAInterlaced"); if (mode->flags & XDGADoublescan) - printf (" XDGADoublescan"); + printf(" XDGADoublescan"); if (mode->viewportFlags & XDGAFlipRetrace) - printf (" XDGAFlipRetrace"); + printf(" XDGAFlipRetrace"); if (mode->viewportFlags & XDGAFlipImmediate) - printf (" XDGAFlipImmediate"); - printf ("\n"); + printf(" XDGAFlipImmediate"); + printf("\n"); } #endif /* DGA_DEBUG */ static int -cmpmodes (const void *va, const void *vb) +cmpmodes(const void *va, const void *vb) { - const SDL_NAME (XDGAMode) * a = (const SDL_NAME (XDGAMode) *) va; - const SDL_NAME (XDGAMode) * b = (const SDL_NAME (XDGAMode) *) vb; + const SDL_NAME(XDGAMode) * a = (const SDL_NAME(XDGAMode) *) va; + const SDL_NAME(XDGAMode) * b = (const SDL_NAME(XDGAMode) *) vb; if ((a->viewportWidth == b->viewportWidth) && (b->viewportHeight == a->viewportHeight)) { @@ -325,7 +325,7 @@ } } static void -UpdateHWInfo (_THIS, SDL_NAME (XDGAMode) * mode) +UpdateHWInfo(_THIS, SDL_NAME(XDGAMode) * mode) { this->info.wm_available = 0; this->info.hw_available = 1; @@ -344,58 +344,58 @@ } else { this->info.blit_fill = 0; } - this->info.video_mem = get_video_size (this); + this->info.video_mem = get_video_size(this); } static int -DGA_VideoInit (_THIS, SDL_PixelFormat * vformat) +DGA_VideoInit(_THIS, SDL_PixelFormat * vformat) { const char *display; int event_base, error_base; int major_version, minor_version; Visual *visual; - SDL_NAME (XDGAMode) * modes; + SDL_NAME(XDGAMode) * modes; int i, num_modes; /* Open the X11 display */ display = NULL; /* Get it from DISPLAY environment variable */ - DGA_Display = XOpenDisplay (display); + DGA_Display = XOpenDisplay(display); if (DGA_Display == NULL) { - SDL_SetError ("Couldn't open X11 display"); + SDL_SetError("Couldn't open X11 display"); return (-1); } /* Check for the DGA extension */ - if (!SDL_NAME (XDGAQueryExtension) (DGA_Display, &event_base, &error_base) - || !SDL_NAME (XDGAQueryVersion) (DGA_Display, &major_version, - &minor_version)) { - SDL_SetError ("DGA extension not available"); - XCloseDisplay (DGA_Display); + if (!SDL_NAME(XDGAQueryExtension) (DGA_Display, &event_base, &error_base) + || !SDL_NAME(XDGAQueryVersion) (DGA_Display, &major_version, + &minor_version)) { + SDL_SetError("DGA extension not available"); + XCloseDisplay(DGA_Display); return (-1); } if (major_version < 2) { - SDL_SetError ("DGA driver requires DGA 2.0 or newer"); - XCloseDisplay (DGA_Display); + SDL_SetError("DGA driver requires DGA 2.0 or newer"); + XCloseDisplay(DGA_Display); return (-1); } DGA_event_base = event_base; /* Determine the current screen size */ - this->info.current_w = DisplayWidth (DGA_Display, DGA_Screen); - this->info.current_h = DisplayHeight (DGA_Display, DGA_Screen); + this->info.current_w = DisplayWidth(DGA_Display, DGA_Screen); + this->info.current_h = DisplayHeight(DGA_Display, DGA_Screen); /* Determine the current screen depth */ - visual = DefaultVisual (DGA_Display, DGA_Screen); + visual = DefaultVisual(DGA_Display, DGA_Screen); { XPixmapFormatValues *pix_format; int i, num_formats; - vformat->BitsPerPixel = DefaultDepth (DGA_Display, DGA_Screen); - pix_format = XListPixmapFormats (DGA_Display, &num_formats); + vformat->BitsPerPixel = DefaultDepth(DGA_Display, DGA_Screen); + pix_format = XListPixmapFormats(DGA_Display, &num_formats); if (pix_format == NULL) { - SDL_SetError ("Couldn't determine screen formats"); - XCloseDisplay (DGA_Display); + SDL_SetError("Couldn't determine screen formats"); + XCloseDisplay(DGA_Display); return (-1); } for (i = 0; i < num_formats; ++i) { @@ -404,7 +404,7 @@ } if (i != num_formats) vformat->BitsPerPixel = pix_format[i].bits_per_pixel; - XFree ((char *) pix_format); + XFree((char *) pix_format); } if (vformat->BitsPerPixel > 8) { vformat->Rmask = visual->red_mask; @@ -413,44 +413,44 @@ } /* Open access to the framebuffer */ - if (!SDL_NAME (XDGAOpenFramebuffer) (DGA_Display, DGA_Screen)) { - SDL_SetError ("Unable to map the video memory"); - XCloseDisplay (DGA_Display); + if (!SDL_NAME(XDGAOpenFramebuffer) (DGA_Display, DGA_Screen)) { + SDL_SetError("Unable to map the video memory"); + XCloseDisplay(DGA_Display); return (-1); } /* Save DPMS and screensaver settings */ - X11_SaveScreenSaver (DGA_Display, &screensaver_timeout, &dpms_enabled); - X11_DisableScreenSaver (DGA_Display); + X11_SaveScreenSaver(DGA_Display, &screensaver_timeout, &dpms_enabled); + X11_DisableScreenSaver(DGA_Display); /* Query for the list of available video modes */ - modes = SDL_NAME (XDGAQueryModes) (DGA_Display, DGA_Screen, &num_modes); - SDL_qsort (modes, num_modes, sizeof *modes, cmpmodes); + modes = SDL_NAME(XDGAQueryModes) (DGA_Display, DGA_Screen, &num_modes); + SDL_qsort(modes, num_modes, sizeof *modes, cmpmodes); for (i = 0; i < num_modes; ++i) { if (((modes[i].visualClass == PseudoColor) || (modes[i].visualClass == DirectColor) || (modes[i].visualClass == TrueColor)) && !(modes[i].flags & (XDGAInterlaced | XDGADoublescan))) { #ifdef DGA_DEBUG - PrintMode (&modes[i]); + PrintMode(&modes[i]); #endif - DGA_AddMode (this, modes[i].bitsPerPixel, - modes[i].viewportWidth, modes[i].viewportHeight); + DGA_AddMode(this, modes[i].bitsPerPixel, + modes[i].viewportWidth, modes[i].viewportHeight); } } - UpdateHWInfo (this, modes); - XFree (modes); + UpdateHWInfo(this, modes); + XFree(modes); /* Create the hardware surface lock mutex */ - hw_lock = SDL_CreateMutex (); + hw_lock = SDL_CreateMutex(); if (hw_lock == NULL) { - SDL_SetError ("Unable to create lock mutex"); - DGA_VideoQuit (this); + SDL_SetError("Unable to create lock mutex"); + DGA_VideoQuit(this); return (-1); } #ifdef LOCK_DGA_DISPLAY /* Create the event lock so we're thread-safe.. :-/ */ - event_lock = SDL_CreateMutex (); + event_lock = SDL_CreateMutex(); #endif /* LOCK_DGA_DISPLAY */ /* We're done! */ @@ -458,34 +458,34 @@ } SDL_Rect ** -DGA_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +DGA_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]); } /* Various screen update functions available */ -static void DGA_DirectUpdate (_THIS, int numrects, SDL_Rect * rects); +static void DGA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects); SDL_Surface * -DGA_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +DGA_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { - SDL_NAME (XDGAMode) * modes; + SDL_NAME(XDGAMode) * modes; int i, num_modes; - SDL_NAME (XDGADevice) * mode; + SDL_NAME(XDGADevice) * mode; int screen_len; Uint8 *surfaces_mem; int surfaces_len; /* Free any previous colormap */ if (DGA_colormap) { - XFreeColormap (DGA_Display, DGA_colormap); + XFreeColormap(DGA_Display, DGA_colormap); DGA_colormap = 0; } /* Search for a matching video mode */ - modes = SDL_NAME (XDGAQueryModes) (DGA_Display, DGA_Screen, &num_modes); - SDL_qsort (modes, num_modes, sizeof *modes, cmpmodes); + modes = SDL_NAME(XDGAQueryModes) (DGA_Display, DGA_Screen, &num_modes); + SDL_qsort(modes, num_modes, sizeof *modes, cmpmodes); for (i = 0; i < num_modes; ++i) { int depth; @@ -504,18 +504,18 @@ } } if (i == num_modes) { - SDL_SetError ("No matching video mode found"); + SDL_SetError("No matching video mode found"); return (NULL); } #ifdef DGA_DEBUG - PrintMode (&modes[i]); + PrintMode(&modes[i]); #endif /* Set the video mode */ - mode = SDL_NAME (XDGASetMode) (DGA_Display, DGA_Screen, modes[i].num); - XFree (modes); + mode = SDL_NAME(XDGASetMode) (DGA_Display, DGA_Screen, modes[i].num); + XFree(modes); if (mode == NULL) { - SDL_SetError ("Unable to switch to requested mode"); + SDL_SetError("Unable to switch to requested mode"); return (NULL); } DGA_visualClass = mode->mode.visualClass; @@ -528,9 +528,9 @@ current->h = mode->mode.viewportHeight; current->pitch = memory_pitch; current->pixels = memory_base; - if (!SDL_ReallocFormat (current, mode->mode.bitsPerPixel, - mode->mode.redMask, - mode->mode.greenMask, mode->mode.blueMask, 0)) { + if (!SDL_ReallocFormat(current, mode->mode.bitsPerPixel, + mode->mode.redMask, + mode->mode.greenMask, mode->mode.blueMask, 0)) { return (NULL); } screen_len = current->h * current->pitch; @@ -538,34 +538,34 @@ /* Create a colormap if necessary */ if ((DGA_visualClass == PseudoColor) || (DGA_visualClass == DirectColor)) { DGA_colormap = - SDL_NAME (XDGACreateColormap) (DGA_Display, DGA_Screen, mode, - AllocAll); + SDL_NAME(XDGACreateColormap) (DGA_Display, DGA_Screen, mode, + AllocAll); if (DGA_visualClass == PseudoColor) { current->flags |= SDL_HWPALETTE; } else { /* Initialize the colormap to the identity mapping */ - SDL_GetGammaRamp (0, 0, 0); + SDL_GetGammaRamp(0, 0, 0); this->screen = current; - DGA_SetGammaRamp (this, this->gamma); + DGA_SetGammaRamp(this, this->gamma); this->screen = NULL; } } else { DGA_colormap = - SDL_NAME (XDGACreateColormap) (DGA_Display, DGA_Screen, mode, - AllocNone); + SDL_NAME(XDGACreateColormap) (DGA_Display, DGA_Screen, mode, + AllocNone); } - SDL_NAME (XDGAInstallColormap) (DGA_Display, DGA_Screen, DGA_colormap); + SDL_NAME(XDGAInstallColormap) (DGA_Display, DGA_Screen, DGA_colormap); /* Update the hardware capabilities */ - UpdateHWInfo (this, &mode->mode); + UpdateHWInfo(this, &mode->mode); /* Set up the information for hardware surfaces */ surfaces_mem = (Uint8 *) current->pixels + screen_len; surfaces_len = (mode->mode.imageHeight * current->pitch - screen_len); /* Update for double-buffering, if we can */ - SDL_NAME (XDGASetViewport) (DGA_Display, DGA_Screen, 0, 0, - XDGAFlipRetrace); + SDL_NAME(XDGASetViewport) (DGA_Display, DGA_Screen, 0, 0, + XDGAFlipRetrace); if (flags & SDL_DOUBLEBUF) { if (mode->mode.imageHeight >= (current->h * 2)) { current->flags |= SDL_DOUBLEBUF; @@ -580,16 +580,16 @@ } /* Allocate memory tracking for hardware surfaces */ - DGA_FreeHWSurfaces (this); + DGA_FreeHWSurfaces(this); if (surfaces_len < 0) { surfaces_len = 0; } - DGA_InitHWSurfaces (this, current, surfaces_mem, surfaces_len); + DGA_InitHWSurfaces(this, current, surfaces_mem, surfaces_len); /* Expose the back buffer as surface memory */ if (current->flags & SDL_DOUBLEBUF) { this->screen = current; - DGA_FlipHWSurface (this, current); + DGA_FlipHWSurface(this, current); this->screen = NULL; } @@ -602,7 +602,7 @@ input_mask = (KeyPressMask | KeyReleaseMask); input_mask |= (ButtonPressMask | ButtonReleaseMask); input_mask |= PointerMotionMask; - SDL_NAME (XDGASelectInput) (DGA_Display, DGA_Screen, input_mask); + SDL_NAME(XDGASelectInput) (DGA_Display, DGA_Screen, input_mask); } /* We're done */ @@ -611,38 +611,38 @@ #ifdef DGA_DEBUG static void -DGA_DumpHWSurfaces (_THIS) +DGA_DumpHWSurfaces(_THIS) { vidmem_bucket *bucket; - printf ("Memory left: %d (%d total)\n", surfaces_memleft, - surfaces_memtotal); - printf ("\n"); - printf (" Base Size\n"); + printf("Memory left: %d (%d total)\n", surfaces_memleft, + surfaces_memtotal); + printf("\n"); + printf(" Base Size\n"); for (bucket = &surfaces; bucket; bucket = bucket->next) { - printf ("Bucket: %p, %d (%s)\n", bucket->base, bucket->size, - bucket->used ? "used" : "free"); + printf("Bucket: %p, %d (%s)\n", bucket->base, bucket->size, + bucket->used ? "used" : "free"); if (bucket->prev) { if (bucket->base != bucket->prev->base + bucket->prev->size) { - printf ("Warning, corrupt bucket list! (prev)\n"); + printf("Warning, corrupt bucket list! (prev)\n"); } } else { if (bucket != &surfaces) { - printf ("Warning, corrupt bucket list! (!prev)\n"); + printf("Warning, corrupt bucket list! (!prev)\n"); } } if (bucket->next) { if (bucket->next->base != bucket->base + bucket->size) { - printf ("Warning, corrupt bucket list! (next)\n"); + printf("Warning, corrupt bucket list! (next)\n"); } } } - printf ("\n"); + printf("\n"); } #endif static int -DGA_InitHWSurfaces (_THIS, SDL_Surface * screen, Uint8 * base, int size) +DGA_InitHWSurfaces(_THIS, SDL_Surface * screen, Uint8 * base, int size) { vidmem_bucket *bucket; @@ -650,9 +650,9 @@ surfaces_memleft = size; if (surfaces_memleft > 0) { - bucket = (vidmem_bucket *) SDL_malloc (sizeof (*bucket)); + bucket = (vidmem_bucket *) SDL_malloc(sizeof(*bucket)); if (bucket == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } bucket->prev = &surfaces; @@ -675,7 +675,7 @@ return (0); } static void -DGA_FreeHWSurfaces (_THIS) +DGA_FreeHWSurfaces(_THIS) { vidmem_bucket *bucket, *freeable; @@ -683,30 +683,30 @@ while (bucket) { freeable = bucket; bucket = bucket->next; - SDL_free (freeable); + SDL_free(freeable); } surfaces.next = NULL; } static __inline__ void -DGA_AddBusySurface (SDL_Surface * surface) +DGA_AddBusySurface(SDL_Surface * surface) { ((vidmem_bucket *) surface->hwdata)->dirty = 1; } static __inline__ int -DGA_IsSurfaceBusy (SDL_Surface * surface) +DGA_IsSurfaceBusy(SDL_Surface * surface) { return ((vidmem_bucket *) surface->hwdata)->dirty; } static __inline__ void -DGA_WaitBusySurfaces (_THIS) +DGA_WaitBusySurfaces(_THIS) { vidmem_bucket *bucket; /* Wait for graphic operations to complete */ - SDL_NAME (XDGASync) (DGA_Display, DGA_Screen); + SDL_NAME(XDGASync) (DGA_Display, DGA_Screen); /* Clear all surface dirty bits */ for (bucket = &surfaces; bucket; bucket = bucket->next) { @@ -715,7 +715,7 @@ } static int -DGA_AllocHWSurface (_THIS, SDL_Surface * surface) +DGA_AllocHWSurface(_THIS, SDL_Surface * surface) { vidmem_bucket *bucket; int size; @@ -727,19 +727,19 @@ to be the same. Others have interesting alignment restrictions. */ if (surface->pitch > SDL_VideoSurface->pitch) { - SDL_SetError ("Surface requested wider than screen"); + SDL_SetError("Surface requested wider than screen"); return (-1); } surface->pitch = SDL_VideoSurface->pitch; size = surface->h * surface->pitch; #ifdef DGA_DEBUG - fprintf (stderr, "Allocating bucket of %d bytes\n", size); + fprintf(stderr, "Allocating bucket of %d bytes\n", size); #endif - LOCK_DISPLAY (); + LOCK_DISPLAY(); /* Quick check for available mem */ if (size > surfaces_memleft) { - SDL_SetError ("Not enough video memory"); + SDL_SetError("Not enough video memory"); retval = -1; goto done; } @@ -751,7 +751,7 @@ } } if (bucket == NULL) { - SDL_SetError ("Video memory too fragmented"); + SDL_SetError("Video memory too fragmented"); retval = -1; goto done; } @@ -762,11 +762,11 @@ vidmem_bucket *newbucket; #ifdef DGA_DEBUG - fprintf (stderr, "Adding new free bucket of %d bytes\n", extra); + fprintf(stderr, "Adding new free bucket of %d bytes\n", extra); #endif - newbucket = (vidmem_bucket *) SDL_malloc (sizeof (*newbucket)); + newbucket = (vidmem_bucket *) SDL_malloc(sizeof(*newbucket)); if (newbucket == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); retval = -1; goto done; } @@ -786,27 +786,26 @@ bucket->size = size; bucket->dirty = 0; #ifdef DGA_DEBUG - fprintf (stderr, "Allocated %d bytes at %p\n", bucket->size, - bucket->base); + fprintf(stderr, "Allocated %d bytes at %p\n", bucket->size, bucket->base); #endif surfaces_memleft -= size; surface->flags |= SDL_HWSURFACE; surface->pixels = bucket->base; surface->hwdata = (struct private_hwdata *) bucket; done: - UNLOCK_DISPLAY (); + UNLOCK_DISPLAY(); return (retval); } static void -DGA_FreeHWSurface (_THIS, SDL_Surface * surface) +DGA_FreeHWSurface(_THIS, SDL_Surface * surface) { vidmem_bucket *bucket, *freeable; /* Wait for any pending operations involving this surface */ - if (DGA_IsSurfaceBusy (surface)) { - LOCK_DISPLAY (); - DGA_WaitBusySurfaces (this); - UNLOCK_DISPLAY (); + if (DGA_IsSurfaceBusy(surface)) { + LOCK_DISPLAY(); + DGA_WaitBusySurfaces(this); + UNLOCK_DISPLAY(); } /* Look for the bucket in the current list */ @@ -818,7 +817,7 @@ if (bucket && bucket->used) { /* Add the memory back to the total */ #ifdef DGA_DEBUG - printf ("Freeing bucket of %d bytes\n", bucket->size); + printf("Freeing bucket of %d bytes\n", bucket->size); #endif surfaces_memleft += bucket->size; @@ -826,8 +825,8 @@ bucket->used = 0; if (bucket->next && !bucket->next->used) { #ifdef DGA_DEBUG - printf ("Merging with next bucket, for %d total bytes\n", - bucket->size + bucket->next->size); + printf("Merging with next bucket, for %d total bytes\n", + bucket->size + bucket->next->size); #endif freeable = bucket->next; bucket->size += bucket->next->size; @@ -835,12 +834,12 @@ if (bucket->next) { bucket->next->prev = bucket; } - SDL_free (freeable); + SDL_free(freeable); } if (bucket->prev && !bucket->prev->used) { #ifdef DGA_DEBUG - printf ("Merging with previous bucket, for %d total bytes\n", - bucket->prev->size + bucket->size); + printf("Merging with previous bucket, for %d total bytes\n", + bucket->prev->size + bucket->size); #endif freeable = bucket; bucket->prev->size += bucket->size; @@ -848,7 +847,7 @@ if (bucket->next) { bucket->next->prev = bucket->prev; } - SDL_free (freeable); + SDL_free(freeable); } } surface->pixels = NULL; @@ -856,46 +855,46 @@ } static __inline__ void -DGA_dst_to_xy (_THIS, SDL_Surface * dst, int *x, int *y) +DGA_dst_to_xy(_THIS, SDL_Surface * dst, int *x, int *y) { *x = (long) ((Uint8 *) dst->pixels - memory_base) % memory_pitch; *y = (long) ((Uint8 *) dst->pixels - memory_base) / memory_pitch; } static int -DGA_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) +DGA_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) { int x, y; unsigned int w, h; /* Don't fill the visible part of the screen, wait until flipped */ - LOCK_DISPLAY (); + LOCK_DISPLAY(); if (was_flipped && (dst == this->screen)) { - while (SDL_NAME (XDGAGetViewportStatus) (DGA_Display, DGA_Screen)) + while (SDL_NAME(XDGAGetViewportStatus) (DGA_Display, DGA_Screen)) /* Keep waiting for the hardware ... */ ; was_flipped = 0; } - DGA_dst_to_xy (this, dst, &x, &y); + DGA_dst_to_xy(this, dst, &x, &y); x += rect->x; y += rect->y; w = rect->w; h = rect->h; #if 0 - printf ("Hardware accelerated rectangle fill: %dx%d at %d,%d\n", w, h, x, - y); + printf("Hardware accelerated rectangle fill: %dx%d at %d,%d\n", w, h, x, + y); #endif - SDL_NAME (XDGAFillRectangle) (DGA_Display, DGA_Screen, x, y, w, h, color); + SDL_NAME(XDGAFillRectangle) (DGA_Display, DGA_Screen, x, y, w, h, color); if (!(this->screen->flags & SDL_DOUBLEBUF)) { - XFlush (DGA_Display); + XFlush(DGA_Display); } - DGA_AddBusySurface (dst); - UNLOCK_DISPLAY (); + DGA_AddBusySurface(dst); + UNLOCK_DISPLAY(); return (0); } static int -HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { SDL_VideoDevice *this; int srcx, srcy; @@ -904,43 +903,43 @@ this = current_video; /* Don't blit to the visible part of the screen, wait until flipped */ - LOCK_DISPLAY (); + LOCK_DISPLAY(); if (was_flipped && (dst == this->screen)) { - while (SDL_NAME (XDGAGetViewportStatus) (DGA_Display, DGA_Screen)) + while (SDL_NAME(XDGAGetViewportStatus) (DGA_Display, DGA_Screen)) /* Keep waiting for the hardware ... */ ; was_flipped = 0; } - DGA_dst_to_xy (this, src, &srcx, &srcy); + DGA_dst_to_xy(this, src, &srcx, &srcy); srcx += srcrect->x; srcy += srcrect->y; - DGA_dst_to_xy (this, dst, &dstx, &dsty); + DGA_dst_to_xy(this, dst, &dstx, &dsty); dstx += dstrect->x; dsty += dstrect->y; w = srcrect->w; h = srcrect->h; #if 0 - printf ("Blitting %dx%d from %d,%d to %d,%d\n", w, h, srcx, srcy, dstx, - dsty); + printf("Blitting %dx%d from %d,%d to %d,%d\n", w, h, srcx, srcy, dstx, + dsty); #endif if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { - SDL_NAME (XDGACopyTransparentArea) (DGA_Display, DGA_Screen, - srcx, srcy, w, h, dstx, dsty, - src->format->colorkey); + SDL_NAME(XDGACopyTransparentArea) (DGA_Display, DGA_Screen, + srcx, srcy, w, h, dstx, dsty, + src->format->colorkey); } else { - SDL_NAME (XDGACopyArea) (DGA_Display, DGA_Screen, - srcx, srcy, w, h, dstx, dsty); + SDL_NAME(XDGACopyArea) (DGA_Display, DGA_Screen, + srcx, srcy, w, h, dstx, dsty); } if (!(this->screen->flags & SDL_DOUBLEBUF)) { - XFlush (DGA_Display); + XFlush(DGA_Display); } - DGA_AddBusySurface (src); - DGA_AddBusySurface (dst); - UNLOCK_DISPLAY (); + DGA_AddBusySurface(src); + DGA_AddBusySurface(dst); + UNLOCK_DISPLAY(); return (0); } static int -DGA_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst) +DGA_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst) { int accelerated; @@ -968,56 +967,56 @@ } static __inline__ void -DGA_WaitFlip (_THIS) +DGA_WaitFlip(_THIS) { if (was_flipped) { - while (SDL_NAME (XDGAGetViewportStatus) (DGA_Display, DGA_Screen)) + while (SDL_NAME(XDGAGetViewportStatus) (DGA_Display, DGA_Screen)) /* Keep waiting for the hardware ... */ ; was_flipped = 0; } } static int -DGA_LockHWSurface (_THIS, SDL_Surface * surface) +DGA_LockHWSurface(_THIS, SDL_Surface * surface) { if (surface == this->screen) { - SDL_mutexP (hw_lock); - LOCK_DISPLAY (); - if (DGA_IsSurfaceBusy (surface)) { - DGA_WaitBusySurfaces (this); + SDL_mutexP(hw_lock); + LOCK_DISPLAY(); + if (DGA_IsSurfaceBusy(surface)) { + DGA_WaitBusySurfaces(this); } - DGA_WaitFlip (this); - UNLOCK_DISPLAY (); + DGA_WaitFlip(this); + UNLOCK_DISPLAY(); } else { - if (DGA_IsSurfaceBusy (surface)) { - LOCK_DISPLAY (); - DGA_WaitBusySurfaces (this); - UNLOCK_DISPLAY (); + if (DGA_IsSurfaceBusy(surface)) { + LOCK_DISPLAY(); + DGA_WaitBusySurfaces(this); + UNLOCK_DISPLAY(); } } return (0); } static void -DGA_UnlockHWSurface (_THIS, SDL_Surface * surface) +DGA_UnlockHWSurface(_THIS, SDL_Surface * surface) { if (surface == this->screen) { - SDL_mutexV (hw_lock); + SDL_mutexV(hw_lock); } } static int -DGA_FlipHWSurface (_THIS, SDL_Surface * surface) +DGA_FlipHWSurface(_THIS, SDL_Surface * surface) { /* Wait for vertical retrace and then flip display */ - LOCK_DISPLAY (); - if (DGA_IsSurfaceBusy (this->screen)) { - DGA_WaitBusySurfaces (this); + LOCK_DISPLAY(); + if (DGA_IsSurfaceBusy(this->screen)) { + DGA_WaitBusySurfaces(this); } - DGA_WaitFlip (this); - SDL_NAME (XDGASetViewport) (DGA_Display, DGA_Screen, - 0, flip_yoffset[flip_page], XDGAFlipRetrace); - XFlush (DGA_Display); - UNLOCK_DISPLAY (); + DGA_WaitFlip(this); + SDL_NAME(XDGASetViewport) (DGA_Display, DGA_Screen, + 0, flip_yoffset[flip_page], XDGAFlipRetrace); + XFlush(DGA_Display); + UNLOCK_DISPLAY(); was_flipped = 1; flip_page = !flip_page; @@ -1026,14 +1025,14 @@ } static void -DGA_DirectUpdate (_THIS, int numrects, SDL_Rect * rects) +DGA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects) { /* The application is already updating the visible video memory */ return; } static int -DGA_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +DGA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { int i; XColor *xcmap; @@ -1042,7 +1041,7 @@ if (!DGA_colormap) { return (0); } - xcmap = SDL_stack_alloc (XColor, ncolors); + xcmap = SDL_stack_alloc(XColor, ncolors); for (i = 0; i < ncolors; ++i) { xcmap[i].pixel = firstcolor + i; xcmap[i].red = (colors[i].r << 8) | colors[i].r; @@ -1050,25 +1049,25 @@ xcmap[i].blue = (colors[i].b << 8) | colors[i].b; xcmap[i].flags = (DoRed | DoGreen | DoBlue); } - LOCK_DISPLAY (); - XStoreColors (DGA_Display, DGA_colormap, xcmap, ncolors); - XSync (DGA_Display, False); - UNLOCK_DISPLAY (); - SDL_stack_free (xcmap); + LOCK_DISPLAY(); + XStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors); + XSync(DGA_Display, False); + UNLOCK_DISPLAY(); + SDL_stack_free(xcmap); /* That was easy. :) */ return (1); } int -DGA_SetGammaRamp (_THIS, Uint16 * ramp) +DGA_SetGammaRamp(_THIS, Uint16 * ramp) { int i, ncolors; XColor xcmap[256]; /* See if actually setting the gamma is supported */ if (DGA_visualClass != DirectColor) { - SDL_SetError ("Gamma correction not supported on this visual"); + SDL_SetError("Gamma correction not supported on this visual"); return (-1); } @@ -1080,47 +1079,47 @@ } for (i = 0; i < ncolors; ++i) { Uint8 c = (256 * i / ncolors); - xcmap[i].pixel = SDL_MapRGB (this->screen->format, c, c, c); + xcmap[i].pixel = SDL_MapRGB(this->screen->format, c, c, c); xcmap[i].red = ramp[0 * 256 + c]; xcmap[i].green = ramp[1 * 256 + c]; xcmap[i].blue = ramp[2 * 256 + c]; xcmap[i].flags = (DoRed | DoGreen | DoBlue); } - LOCK_DISPLAY (); - XStoreColors (DGA_Display, DGA_colormap, xcmap, ncolors); - XSync (DGA_Display, False); - UNLOCK_DISPLAY (); + LOCK_DISPLAY(); + XStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors); + XSync(DGA_Display, False); + UNLOCK_DISPLAY(); return (0); } void -DGA_VideoQuit (_THIS) +DGA_VideoQuit(_THIS) { int i, j; if (DGA_Display) { /* Free colormap, if necessary */ if (DGA_colormap) { - XFreeColormap (DGA_Display, DGA_colormap); + XFreeColormap(DGA_Display, DGA_colormap); DGA_colormap = 0; } /* Unmap memory and reset video mode */ - SDL_NAME (XDGACloseFramebuffer) (DGA_Display, DGA_Screen); + SDL_NAME(XDGACloseFramebuffer) (DGA_Display, DGA_Screen); if (this->screen) { /* Tell SDL not to free the pixels */ - DGA_FreeHWSurface (this, this->screen); + DGA_FreeHWSurface(this, this->screen); } - SDL_NAME (XDGASetMode) (DGA_Display, DGA_Screen, 0); + SDL_NAME(XDGASetMode) (DGA_Display, DGA_Screen, 0); /* Clear the lock mutex */ if (hw_lock != NULL) { - SDL_DestroyMutex (hw_lock); + SDL_DestroyMutex(hw_lock); hw_lock = NULL; } #ifdef LOCK_DGA_DISPLAY if (event_lock != NULL) { - SDL_DestroyMutex (event_lock); + SDL_DestroyMutex(event_lock); event_lock = NULL; } #endif /* LOCK_DGA_DISPLAY */ @@ -1129,22 +1128,22 @@ for (i = 0; i < NUM_MODELISTS; ++i) { if (SDL_modelist[i] != NULL) { for (j = 0; SDL_modelist[i][j]; ++j) { - SDL_free (SDL_modelist[i][j]); + SDL_free(SDL_modelist[i][j]); } - SDL_free (SDL_modelist[i]); + SDL_free(SDL_modelist[i]); SDL_modelist[i] = NULL; } } /* Clean up the memory bucket list */ - DGA_FreeHWSurfaces (this); + DGA_FreeHWSurfaces(this); /* Restore DPMS and screensaver settings */ - X11_RestoreScreenSaver (DGA_Display, screensaver_timeout, - dpms_enabled); + X11_RestoreScreenSaver(DGA_Display, screensaver_timeout, + dpms_enabled); /* Close up the display */ - XCloseDisplay (DGA_Display); + XCloseDisplay(DGA_Display); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/directfb/SDL_DirectFB_events.c --- a/src/video/directfb/SDL_DirectFB_events.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/directfb/SDL_DirectFB_events.c Mon May 29 04:04:35 2006 +0000 @@ -40,49 +40,49 @@ /* The translation tables from a DirectFB keycode to a SDL keysym */ static SDLKey keymap[256]; -static SDL_keysym *DirectFB_TranslateKey (DFBInputEvent * ev, - SDL_keysym * keysym); -static int DirectFB_TranslateButton (DFBInputEvent * ev); +static SDL_keysym *DirectFB_TranslateKey(DFBInputEvent * ev, + SDL_keysym * keysym); +static int DirectFB_TranslateButton(DFBInputEvent * ev); static int posted = 0; void -DirectFB_PumpEvents (_THIS) +DirectFB_PumpEvents(_THIS) { DFBInputEvent evt; - while (HIDDEN->eventbuffer->GetEvent (HIDDEN->eventbuffer, - DFB_EVENT (&evt)) == DFB_OK) { + while (HIDDEN->eventbuffer->GetEvent(HIDDEN->eventbuffer, + DFB_EVENT(&evt)) == DFB_OK) { SDL_keysym keysym; switch (evt.type) { case DIET_BUTTONPRESS: - posted += SDL_PrivateMouseButton (SDL_PRESSED, - DirectFB_TranslateButton - (&evt), 0, 0); + posted += SDL_PrivateMouseButton(SDL_PRESSED, + DirectFB_TranslateButton + (&evt), 0, 0); break; case DIET_BUTTONRELEASE: - posted += SDL_PrivateMouseButton (SDL_RELEASED, - DirectFB_TranslateButton - (&evt), 0, 0); + posted += SDL_PrivateMouseButton(SDL_RELEASED, + DirectFB_TranslateButton + (&evt), 0, 0); break; case DIET_KEYPRESS: posted += - SDL_PrivateKeyboard (SDL_PRESSED, - DirectFB_TranslateKey (&evt, &keysym)); + SDL_PrivateKeyboard(SDL_PRESSED, + DirectFB_TranslateKey(&evt, &keysym)); break; case DIET_KEYRELEASE: posted += - SDL_PrivateKeyboard (SDL_RELEASED, - DirectFB_TranslateKey (&evt, &keysym)); + SDL_PrivateKeyboard(SDL_RELEASED, + DirectFB_TranslateKey(&evt, &keysym)); break; case DIET_AXISMOTION: if (evt.flags & DIEF_AXISREL) { if (evt.axis == DIAI_X) - posted += SDL_PrivateMouseMotion (0, 1, evt.axisrel, 0); + posted += SDL_PrivateMouseMotion(0, 1, evt.axisrel, 0); else if (evt.axis == DIAI_Y) - posted += SDL_PrivateMouseMotion (0, 1, 0, evt.axisrel); + posted += SDL_PrivateMouseMotion(0, 1, 0, evt.axisrel); } break; default: @@ -92,12 +92,12 @@ } void -DirectFB_InitOSKeymap (_THIS) +DirectFB_InitOSKeymap(_THIS) { int i; /* Initialize the DirectFB key translation table */ - for (i = 0; i < SDL_arraysize (keymap); ++i) + for (i = 0; i < SDL_arraysize(keymap); ++i) keymap[i] = SDLK_UNKNOWN; keymap[DIKI_A - DIKI_UNKNOWN] = SDLK_a; @@ -186,13 +186,13 @@ static SDL_keysym * -DirectFB_TranslateKey (DFBInputEvent * ev, SDL_keysym * keysym) +DirectFB_TranslateKey(DFBInputEvent * ev, SDL_keysym * keysym) { /* Set the keysym information */ keysym->scancode = ev->key_id; keysym->mod = KMOD_NONE; /* FIXME */ keysym->unicode = - (DFB_KEY_TYPE (ev->key_symbol) == DIKT_UNICODE) ? ev->key_symbol : 0; + (DFB_KEY_TYPE(ev->key_symbol) == DIKT_UNICODE) ? ev->key_symbol : 0; if (ev->key_symbol > 0 && ev->key_symbol < 128) keysym->sym = ev->key_symbol; @@ -203,7 +203,7 @@ } static int -DirectFB_TranslateButton (DFBInputEvent * ev) +DirectFB_TranslateButton(DFBInputEvent * ev) { switch (ev->button) { case DIBI_LEFT: diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/directfb/SDL_DirectFB_events.h --- a/src/video/directfb/SDL_DirectFB_events.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/directfb/SDL_DirectFB_events.h Mon May 29 04:04:35 2006 +0000 @@ -24,6 +24,6 @@ #include "SDL_DirectFB_video.h" /* Functions to be exported */ -extern void DirectFB_InitOSKeymap (_THIS); -extern void DirectFB_PumpEvents (_THIS); +extern void DirectFB_InitOSKeymap(_THIS); +extern void DirectFB_PumpEvents(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/directfb/SDL_DirectFB_video.c --- a/src/video/directfb/SDL_DirectFB_video.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/directfb/SDL_DirectFB_video.c Mon May 29 04:04:35 2006 +0000 @@ -52,34 +52,34 @@ /* Initialization/Query functions */ -static int DirectFB_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **DirectFB_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *DirectFB_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); -static int DirectFB_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void DirectFB_VideoQuit (_THIS); +static int DirectFB_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **DirectFB_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +static SDL_Surface *DirectFB_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, + Uint32 flags); +static int DirectFB_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void DirectFB_VideoQuit(_THIS); /* Hardware surface functions */ -static int DirectFB_AllocHWSurface (_THIS, SDL_Surface * surface); -static int DirectFB_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * dstrect, - Uint32 color); -static int DirectFB_LockHWSurface (_THIS, SDL_Surface * surface); -static void DirectFB_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void DirectFB_FreeHWSurface (_THIS, SDL_Surface * surface); -static int DirectFB_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst); -static int DirectFB_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect); -static int DirectFB_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key); -static int DirectFB_SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 alpha); -static int DirectFB_FlipHWSurface (_THIS, SDL_Surface * surface); -static int DirectFB_ShowWMCursor (_THIS, WMcursor * cursor); +static int DirectFB_AllocHWSurface(_THIS, SDL_Surface * surface); +static int DirectFB_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * dstrect, + Uint32 color); +static int DirectFB_LockHWSurface(_THIS, SDL_Surface * surface); +static void DirectFB_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void DirectFB_FreeHWSurface(_THIS, SDL_Surface * surface); +static int DirectFB_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst); +static int DirectFB_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); +static int DirectFB_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key); +static int DirectFB_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha); +static int DirectFB_FlipHWSurface(_THIS, SDL_Surface * surface); +static int DirectFB_ShowWMCursor(_THIS, WMcursor * cursor); /* Various screen update functions available */ -static void DirectFB_DirectUpdate (_THIS, int numrects, SDL_Rect * rects); -static void DirectFB_WindowedUpdate (_THIS, int numrects, SDL_Rect * rects); +static void DirectFB_DirectUpdate(_THIS, int numrects, SDL_Rect * rects); +static void DirectFB_WindowedUpdate(_THIS, int numrects, SDL_Rect * rects); /* This is the rect EnumModes2 uses */ struct DirectFBEnumRect @@ -94,38 +94,38 @@ /* DirectFB driver bootstrap functions */ static int -DirectFB_Available (void) +DirectFB_Available(void) { return 1; } static void -DirectFB_DeleteDevice (SDL_VideoDevice * device) +DirectFB_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -DirectFB_CreateDevice (int devindex) +DirectFB_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - malloc (sizeof (*device->hidden)); + malloc(sizeof(*device->hidden)); } if (device == NULL || device->hidden == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - free (device); + free(device); } return (0); } - SDL_memset (device->hidden, 0, sizeof (*device->hidden)); + SDL_memset(device->hidden, 0, sizeof(*device->hidden)); /* Set the function pointers */ device->VideoInit = DirectFB_VideoInit; @@ -164,14 +164,14 @@ }; static DFBSurfacePixelFormat -GetFormatForBpp (int bpp, IDirectFBDisplayLayer * layer) +GetFormatForBpp(int bpp, IDirectFBDisplayLayer * layer) { DFBDisplayLayerConfig dlc; int bytes = (bpp + 7) / 8; - layer->GetConfiguration (layer, &dlc); + layer->GetConfiguration(layer, &dlc); - if (bytes == DFB_BYTES_PER_PIXEL (dlc.pixelformat) && bytes > 1) + if (bytes == DFB_BYTES_PER_PIXEL(dlc.pixelformat) && bytes > 1) return dlc.pixelformat; switch (bytes) { @@ -189,7 +189,7 @@ } static DFBEnumerationResult -EnumModesCallback (int width, int height, int bpp, void *data) +EnumModesCallback(int width, int height, int bpp, void *data) { SDL_VideoDevice *this = (SDL_VideoDevice *) data; struct DirectFBEnumRect *enumrect; @@ -199,9 +199,9 @@ if (enumlist && enumlist->r.w == width && enumlist->r.h == height) return DFENUM_OK; - enumrect = SDL_calloc (1, sizeof (struct DirectFBEnumRect)); + enumrect = SDL_calloc(1, sizeof(struct DirectFBEnumRect)); if (!enumrect) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return DFENUM_CANCEL; } @@ -221,18 +221,18 @@ }; void -SetDirectFBerror (const char *function, DFBResult code) +SetDirectFBerror(const char *function, DFBResult code) { - const char *error = DirectFBErrorString (code); + const char *error = DirectFBErrorString(code); if (error) - SDL_SetError ("%s: %s", function, error); + SDL_SetError("%s: %s", function, error); else - SDL_SetError ("Unknown error code from %s", function); + SDL_SetError("Unknown error code from %s", function); } static DFBSurfacePixelFormat -SDLToDFBPixelFormat (SDL_PixelFormat * format) +SDLToDFBPixelFormat(SDL_PixelFormat * format) { if (format->Rmask && format->Gmask && format->Bmask) { switch (format->BitsPerPixel) { @@ -286,20 +286,20 @@ } static SDL_Palette * -AllocatePalette (int size) +AllocatePalette(int size) { SDL_Palette *palette; SDL_Color *colors; - palette = SDL_calloc (1, sizeof (SDL_Palette)); + palette = SDL_calloc(1, sizeof(SDL_Palette)); if (!palette) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return NULL; } - colors = SDL_calloc (size, sizeof (SDL_Color)); + colors = SDL_calloc(size, sizeof(SDL_Color)); if (!colors) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return NULL; } @@ -310,8 +310,8 @@ } static int -DFBToSDLPixelFormat (DFBSurfacePixelFormat pixelformat, - SDL_PixelFormat * format) +DFBToSDLPixelFormat(DFBSurfacePixelFormat pixelformat, + SDL_PixelFormat * format) { format->Amask = format->Rmask = format->Gmask = format->Bmask = 0; format->BitsPerPixel = format->BytesPerPixel = 0; @@ -349,25 +349,25 @@ format->Bmask = 0x000000FF; if (!format->palette) - format->palette = AllocatePalette (256); + format->palette = AllocatePalette(256); break; default: - fprintf (stderr, - "SDL_DirectFB: Unsupported pixelformat (0x%08x)!\n", - pixelformat); + fprintf(stderr, + "SDL_DirectFB: Unsupported pixelformat (0x%08x)!\n", + pixelformat); return -1; } - format->BitsPerPixel = DFB_BYTES_PER_PIXEL (pixelformat) * 8; - format->BytesPerPixel = DFB_BYTES_PER_PIXEL (pixelformat); + format->BitsPerPixel = DFB_BYTES_PER_PIXEL(pixelformat) * 8; + format->BytesPerPixel = DFB_BYTES_PER_PIXEL(pixelformat); return 0; } int -DirectFB_VideoInit (_THIS, SDL_PixelFormat * vformat) +DirectFB_VideoInit(_THIS, SDL_PixelFormat * vformat) { int i; DFBResult ret; @@ -386,49 +386,49 @@ HIDDEN->enable_mga_crtc2 = 0; HIDDEN->mga_crtc2_stretch_overscan = 1; - ret = DirectFBInit (NULL, NULL); + ret = DirectFBInit(NULL, NULL); if (ret) { - SetDirectFBerror ("DirectFBInit", ret); + SetDirectFBerror("DirectFBInit", ret); goto error; } - ret = DirectFBCreate (&dfb); + ret = DirectFBCreate(&dfb); if (ret) { - SetDirectFBerror ("DirectFBCreate", ret); + SetDirectFBerror("DirectFBCreate", ret); goto error; } - ret = dfb->GetDisplayLayer (dfb, DLID_PRIMARY, &layer); + ret = dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &layer); if (ret) { - SetDirectFBerror ("dfb->GetDisplayLayer", ret); + SetDirectFBerror("dfb->GetDisplayLayer", ret); goto error; } - ret = dfb->CreateInputEventBuffer (dfb, DICAPS_ALL, DFB_FALSE, &events); + ret = dfb->CreateInputEventBuffer(dfb, DICAPS_ALL, DFB_FALSE, &events); if (ret) { - SetDirectFBerror ("dfb->CreateEventBuffer", ret); + SetDirectFBerror("dfb->CreateEventBuffer", ret); goto error; } - layer->EnableCursor (layer, 1); + layer->EnableCursor(layer, 1); /* Query layer configuration to determine the current mode and pixelformat */ - layer->GetConfiguration (layer, &dlc); + layer->GetConfiguration(layer, &dlc); /* If current format is not supported use LUT8 as the default */ - if (DFBToSDLPixelFormat (dlc.pixelformat, vformat)) - DFBToSDLPixelFormat (DSPF_LUT8, vformat); + if (DFBToSDLPixelFormat(dlc.pixelformat, vformat)) + DFBToSDLPixelFormat(DSPF_LUT8, vformat); /* Enumerate the available fullscreen modes */ - ret = dfb->EnumVideoModes (dfb, EnumModesCallback, this); + ret = dfb->EnumVideoModes(dfb, EnumModesCallback, this); if (ret) { - SetDirectFBerror ("dfb->EnumVideoModes", ret); + SetDirectFBerror("dfb->EnumVideoModes", ret); goto error; } - HIDDEN->modelist = SDL_calloc (HIDDEN->nummodes + 1, sizeof (SDL_Rect *)); + HIDDEN->modelist = SDL_calloc(HIDDEN->nummodes + 1, sizeof(SDL_Rect *)); if (!HIDDEN->modelist) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); goto error; } @@ -441,9 +441,9 @@ /* Query card capabilities to get the video memory size */ #if (DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23) - dfb->GetCardCapabilities (dfb, &caps); + dfb->GetCardCapabilities(dfb, &caps); #else - dfb->GetDeviceDescription (dfb, &caps); + dfb->GetDeviceDescription(dfb, &caps); #endif this->info.wm_available = 1; @@ -459,22 +459,22 @@ HIDDEN->layer = layer; HIDDEN->eventbuffer = events; - if (SDL_getenv ("SDL_DIRECTFB_MGA_CRTC2") != NULL) + if (SDL_getenv("SDL_DIRECTFB_MGA_CRTC2") != NULL) HIDDEN->enable_mga_crtc2 = 1; if (HIDDEN->enable_mga_crtc2) { DFBDisplayLayerConfig dlc; DFBDisplayLayerConfigFlags failed; - ret = dfb->GetDisplayLayer (dfb, 2, &HIDDEN->c2layer); + ret = dfb->GetDisplayLayer(dfb, 2, &HIDDEN->c2layer); if (ret) { - SetDirectFBerror ("dfb->GetDisplayLayer(CRTC2)", ret); + SetDirectFBerror("dfb->GetDisplayLayer(CRTC2)", ret); goto error; } ret = - HIDDEN->layer->SetCooperativeLevel (HIDDEN->layer, - DLSCL_EXCLUSIVE); + HIDDEN->layer->SetCooperativeLevel(HIDDEN->layer, + DLSCL_EXCLUSIVE); if (ret) { SetDirectFBerror ("layer->SetCooperativeLevel(CRTC2, EXCLUSIVE)", ret); @@ -482,15 +482,15 @@ } ret = - HIDDEN->c2layer->SetCooperativeLevel (HIDDEN->c2layer, - DLSCL_EXCLUSIVE); + HIDDEN->c2layer->SetCooperativeLevel(HIDDEN->c2layer, + DLSCL_EXCLUSIVE); if (ret) { SetDirectFBerror ("c2layer->SetCooperativeLevel(CRTC2, EXCLUSIVE)", ret); goto error; } - HIDDEN->c2layer->SetOpacity (HIDDEN->c2layer, 0x0); + HIDDEN->c2layer->SetOpacity(HIDDEN->c2layer, 0x0); /* Init the surface here as it got a fixed size */ dlc.flags = DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE; @@ -498,53 +498,53 @@ dlc.pixelformat = DSPF_RGB32; ret = - HIDDEN->c2layer->TestConfiguration (HIDDEN->c2layer, &dlc, - &failed); + HIDDEN->c2layer->TestConfiguration(HIDDEN->c2layer, &dlc, + &failed); if (ret) { - SetDirectFBerror ("c2layer->TestConfiguration", ret); + SetDirectFBerror("c2layer->TestConfiguration", ret); goto error; } - ret = HIDDEN->c2layer->SetConfiguration (HIDDEN->c2layer, &dlc); + ret = HIDDEN->c2layer->SetConfiguration(HIDDEN->c2layer, &dlc); if (ret) { - SetDirectFBerror ("c2layer->SetConfiguration", ret); + SetDirectFBerror("c2layer->SetConfiguration", ret); goto error; } - ret = HIDDEN->c2layer->GetSurface (HIDDEN->c2layer, &HIDDEN->c2frame); + ret = HIDDEN->c2layer->GetSurface(HIDDEN->c2layer, &HIDDEN->c2frame); if (ret) { - SetDirectFBerror ("c2layer->GetSurface", ret); + SetDirectFBerror("c2layer->GetSurface", ret); goto error; } HIDDEN->c2framesize.x = 0; HIDDEN->c2framesize.y = 0; - HIDDEN->c2frame->GetSize (HIDDEN->c2frame, &HIDDEN->c2framesize.w, - &HIDDEN->c2framesize.h); + HIDDEN->c2frame->GetSize(HIDDEN->c2frame, &HIDDEN->c2framesize.w, + &HIDDEN->c2framesize.h); - HIDDEN->c2frame->SetBlittingFlags (HIDDEN->c2frame, DSBLIT_NOFX); - HIDDEN->c2frame->SetColor (HIDDEN->c2frame, 0, 0, 0, 0xff); + HIDDEN->c2frame->SetBlittingFlags(HIDDEN->c2frame, DSBLIT_NOFX); + HIDDEN->c2frame->SetColor(HIDDEN->c2frame, 0, 0, 0, 0xff); /* Clear CRTC2 */ - HIDDEN->c2frame->Clear (HIDDEN->c2frame, 0, 0, 0, 0xff); - HIDDEN->c2frame->Flip (HIDDEN->c2frame, NULL, 0); - HIDDEN->c2frame->Clear (HIDDEN->c2frame, 0, 0, 0, 0xff); - HIDDEN->c2frame->Flip (HIDDEN->c2frame, NULL, 0); - HIDDEN->c2frame->Clear (HIDDEN->c2frame, 0, 0, 0, 0xff); + HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff); + HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, 0); + HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff); + HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, 0); + HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff); - HIDDEN->c2layer->SetOpacity (HIDDEN->c2layer, 0xFF); + HIDDEN->c2layer->SetOpacity(HIDDEN->c2layer, 0xFF); /* Check if overscan is possibly set */ - if (SDL_getenv ("SDL_DIRECTFB_MGA_OVERSCAN") != NULL) { + if (SDL_getenv("SDL_DIRECTFB_MGA_OVERSCAN") != NULL) { float overscan = 0; if (SDL_sscanf - (SDL_getenv ("SDL_DIRECTFB_MGA_OVERSCAN"), "%f", + (SDL_getenv("SDL_DIRECTFB_MGA_OVERSCAN"), "%f", &overscan) == 1) if (overscan > 0 && overscan < 2) HIDDEN->mga_crtc2_stretch_overscan = overscan; } #ifdef DIRECTFB_CRTC2_DEBUG - printf ("CRTC2 overscan: %f\n", HIDDEN->mga_crtc2_stretch_overscan); + printf("CRTC2 overscan: %f\n", HIDDEN->mga_crtc2_stretch_overscan); #endif } @@ -552,91 +552,89 @@ error: if (events) - events->Release (events); + events->Release(events); if (HIDDEN->c2frame) - HIDDEN->c2frame->Release (HIDDEN->c2frame); + HIDDEN->c2frame->Release(HIDDEN->c2frame); if (HIDDEN->c2layer) - HIDDEN->c2layer->Release (HIDDEN->c2layer); + HIDDEN->c2layer->Release(HIDDEN->c2layer); if (layer) - layer->Release (layer); + layer->Release(layer); if (dfb) - dfb->Release (dfb); + dfb->Release(dfb); return -1; } static SDL_Rect ** -DirectFB_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +DirectFB_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { if (flags & SDL_FULLSCREEN) return HIDDEN->modelist; - else if (SDLToDFBPixelFormat (format) != DSPF_UNKNOWN) + else if (SDLToDFBPixelFormat(format) != DSPF_UNKNOWN) return (SDL_Rect **) - 1; return NULL; } static SDL_Surface * -DirectFB_SetVideoMode (_THIS, SDL_Surface * current, int width, int height, - int bpp, Uint32 flags) +DirectFB_SetVideoMode(_THIS, SDL_Surface * current, int width, int height, + int bpp, Uint32 flags) { DFBResult ret; DFBSurfaceDescription dsc; DFBSurfacePixelFormat pixelformat; IDirectFBSurface *surface; - fprintf (stderr, "SDL DirectFB_SetVideoMode: %dx%d@%d, flags: 0x%08x\n", - width, height, bpp, flags); + fprintf(stderr, "SDL DirectFB_SetVideoMode: %dx%d@%d, flags: 0x%08x\n", + width, height, bpp, flags); flags |= SDL_FULLSCREEN; /* Release previous primary surface */ if (current->hwdata && current->hwdata->surface) { - current->hwdata->surface->Release (current->hwdata->surface); + current->hwdata->surface->Release(current->hwdata->surface); current->hwdata->surface = NULL; /* And its palette if present */ if (current->hwdata->palette) { - current->hwdata->palette->Release (current->hwdata->palette); + current->hwdata->palette->Release(current->hwdata->palette); current->hwdata->palette = NULL; } } else if (!current->hwdata) { /* Allocate the hardware acceleration data */ current->hwdata = - (struct private_hwdata *) SDL_calloc (1, - sizeof (*current->hwdata)); + (struct private_hwdata *) SDL_calloc(1, sizeof(*current->hwdata)); if (!current->hwdata) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return NULL; } } /* Set cooperative level depending on flag SDL_FULLSCREEN */ if (flags & SDL_FULLSCREEN) { - ret = - HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_FULLSCREEN); + ret = HIDDEN->dfb->SetCooperativeLevel(HIDDEN->dfb, DFSCL_FULLSCREEN); if (ret && !HIDDEN->enable_mga_crtc2) { - DirectFBError ("dfb->SetCooperativeLevel", ret); + DirectFBError("dfb->SetCooperativeLevel", ret); flags &= ~SDL_FULLSCREEN; } } else - HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_NORMAL); + HIDDEN->dfb->SetCooperativeLevel(HIDDEN->dfb, DFSCL_NORMAL); /* Set video mode */ - ret = HIDDEN->dfb->SetVideoMode (HIDDEN->dfb, width, height, bpp); + ret = HIDDEN->dfb->SetVideoMode(HIDDEN->dfb, width, height, bpp); if (ret) { if (flags & SDL_FULLSCREEN) { flags &= ~SDL_FULLSCREEN; - HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_NORMAL); - ret = HIDDEN->dfb->SetVideoMode (HIDDEN->dfb, width, height, bpp); + HIDDEN->dfb->SetCooperativeLevel(HIDDEN->dfb, DFSCL_NORMAL); + ret = HIDDEN->dfb->SetVideoMode(HIDDEN->dfb, width, height, bpp); } if (ret) { - SetDirectFBerror ("dfb->SetVideoMode", ret); + SetDirectFBerror("dfb->SetVideoMode", ret); return NULL; } } @@ -645,16 +643,16 @@ dsc.flags = DSDESC_CAPS | DSDESC_PIXELFORMAT; dsc.caps = DSCAPS_PRIMARY | ((flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0); - dsc.pixelformat = GetFormatForBpp (bpp, HIDDEN->layer); + dsc.pixelformat = GetFormatForBpp(bpp, HIDDEN->layer); - ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, &surface); + ret = HIDDEN->dfb->CreateSurface(HIDDEN->dfb, &dsc, &surface); if (ret && (flags & SDL_DOUBLEBUF)) { /* Try without double buffering */ dsc.caps &= ~DSCAPS_FLIPPING; - ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, &surface); + ret = HIDDEN->dfb->CreateSurface(HIDDEN->dfb, &dsc, &surface); } if (ret) { - SetDirectFBerror ("dfb->CreateSurface", ret); + SetDirectFBerror("dfb->CreateSurface", ret); return NULL; } @@ -671,13 +669,13 @@ if (dsc.caps & DSCAPS_FLIPPING) current->flags |= SDL_DOUBLEBUF; - surface->GetPixelFormat (surface, &pixelformat); + surface->GetPixelFormat(surface, &pixelformat); - DFBToSDLPixelFormat (pixelformat, current->format); + DFBToSDLPixelFormat(pixelformat, current->format); /* Get the surface palette (if supported) */ - if (DFB_PIXELFORMAT_IS_INDEXED (pixelformat)) { - surface->GetPalette (surface, ¤t->hwdata->palette); + if (DFB_PIXELFORMAT_IS_INDEXED(pixelformat)) { + surface->GetPalette(surface, ¤t->hwdata->palette); current->flags |= SDL_HWPALETTE; } @@ -697,7 +695,7 @@ HIDDEN->mga_crtc2_stretch = 0; - if (SDL_getenv ("SDL_DIRECTFB_MGA_STRETCH") != NULL) { + if (SDL_getenv("SDL_DIRECTFB_MGA_STRETCH") != NULL) { /* Normally assume a picture aspect ratio of 4:3 */ int zoom_aspect_x = 4, zoom_aspect_y = 3, i, j; @@ -718,8 +716,8 @@ printf ("Source resolution: X: %d, Y: %d, Aspect ratio: %d:%d\n", width, height, zoom_aspect_x, zoom_aspect_y); - printf ("CRTC2 resolution: X: %d, Y: %d\n", - HIDDEN->c2framesize.w, HIDDEN->c2framesize.h); + printf("CRTC2 resolution: X: %d, Y: %d\n", + HIDDEN->c2framesize.w, HIDDEN->c2framesize.h); #endif /* don't stretch only slightly smaller/larger images */ @@ -740,8 +738,8 @@ HIDDEN->c2dsize.h -= zoom_aspect_y; #ifdef DIRECTFB_CRTC2_DEBUG - printf ("Stretched resolution: X: %d, Y: %d\n", - HIDDEN->c2dsize.w, HIDDEN->c2dsize.h); + printf("Stretched resolution: X: %d, Y: %d\n", + HIDDEN->c2dsize.w, HIDDEN->c2dsize.h); #endif HIDDEN->mga_crtc2_stretch = 1; @@ -759,14 +757,14 @@ } #ifdef DIRECTFB_CRTC2_DEBUG - printf ("Down-Stretched resolution: X: %d, Y: %d\n", - HIDDEN->c2dsize.w, HIDDEN->c2dsize.h); + printf("Down-Stretched resolution: X: %d, Y: %d\n", + HIDDEN->c2dsize.w, HIDDEN->c2dsize.h); #endif HIDDEN->mga_crtc2_stretch = 1; } else { #ifdef DIRECTFB_CRTC2_DEBUG - printf ("Not stretching image\n"); + printf("Not stretching image\n"); #endif } @@ -786,8 +784,8 @@ (HIDDEN->c2dsize.h - HIDDEN->c2framesize.h) / 2; #ifdef DIRECTFB_CRTC2_DEBUG - printf ("CRTC2 position X: %d, Y: %d\n", HIDDEN->c2dsize.x, - HIDDEN->c2dsize.y); + printf("CRTC2 position X: %d, Y: %d\n", HIDDEN->c2dsize.x, + HIDDEN->c2dsize.y); #endif } } @@ -796,7 +794,7 @@ } static int -DirectFB_AllocHWSurface (_THIS, SDL_Surface * surface) +DirectFB_AllocHWSurface(_THIS, SDL_Surface * surface) { DFBResult ret; DFBSurfaceDescription dsc; @@ -815,25 +813,25 @@ dsc.caps = (surface->flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0; /* find the right pixelformat */ - dsc.pixelformat = SDLToDFBPixelFormat (surface->format); + dsc.pixelformat = SDLToDFBPixelFormat(surface->format); if (dsc.pixelformat == DSPF_UNKNOWN) return -1; /* Allocate the hardware acceleration data */ surface->hwdata = - (struct private_hwdata *) SDL_calloc (1, sizeof (*surface->hwdata)); + (struct private_hwdata *) SDL_calloc(1, sizeof(*surface->hwdata)); if (surface->hwdata == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return -1; } /* Create the surface */ ret = - HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, - &surface->hwdata->surface); + HIDDEN->dfb->CreateSurface(HIDDEN->dfb, &dsc, + &surface->hwdata->surface); if (ret) { - SetDirectFBerror ("dfb->CreateSurface", ret); - free (surface->hwdata); + SetDirectFBerror("dfb->CreateSurface", ret); + free(surface->hwdata); surface->hwdata = NULL; return -1; } @@ -844,17 +842,17 @@ } static void -DirectFB_FreeHWSurface (_THIS, SDL_Surface * surface) +DirectFB_FreeHWSurface(_THIS, SDL_Surface * surface) { if (surface->hwdata && HIDDEN->initialized) { - surface->hwdata->surface->Release (surface->hwdata->surface); - free (surface->hwdata); + surface->hwdata->surface->Release(surface->hwdata->surface); + free(surface->hwdata); surface->hwdata = NULL; } } static int -DirectFB_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst) +DirectFB_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst) { /* fprintf(stderr, "SDL: DirectFB_CheckHWBlit (src->hwdata: %p, dst->hwdata: %p)\n", src->hwdata, dst->hwdata); */ @@ -869,8 +867,8 @@ } static int -DirectFB_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +DirectFB_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { DFBSurfaceBlittingFlags flags = DSBLIT_NOFX; @@ -881,104 +879,104 @@ if (src->flags & SDL_SRCCOLORKEY) { flags |= DSBLIT_SRC_COLORKEY; - DirectFB_SetHWColorKey (NULL, src, src->format->colorkey); + DirectFB_SetHWColorKey(NULL, src, src->format->colorkey); } if (src->flags & SDL_SRCALPHA) { flags |= DSBLIT_BLEND_COLORALPHA; - surface->SetColor (surface, 0xff, 0xff, 0xff, src->format->alpha); + surface->SetColor(surface, 0xff, 0xff, 0xff, src->format->alpha); } - surface->SetBlittingFlags (surface, flags); + surface->SetBlittingFlags(surface, flags); if (sr.w == dr.w && sr.h == dr.h) - surface->Blit (surface, src->hwdata->surface, &sr, dr.x, dr.y); + surface->Blit(surface, src->hwdata->surface, &sr, dr.x, dr.y); else - surface->StretchBlit (surface, src->hwdata->surface, &sr, &dr); + surface->StretchBlit(surface, src->hwdata->surface, &sr, &dr); return 0; } static int -DirectFB_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * dstrect, - Uint32 color) +DirectFB_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * dstrect, + Uint32 color) { SDL_PixelFormat *fmt = dst->format; IDirectFBSurface *surface = dst->hwdata->surface; /* ugly */ - surface->SetColor (surface, - (color & fmt->Rmask) >> (fmt->Rshift - fmt->Rloss), - (color & fmt->Gmask) >> (fmt->Gshift - fmt->Gloss), - (color & fmt->Bmask) << (fmt->Bloss - fmt->Bshift), - 0xFF); - surface->FillRectangle (surface, dstrect->x, dstrect->y, dstrect->w, - dstrect->h); + surface->SetColor(surface, + (color & fmt->Rmask) >> (fmt->Rshift - fmt->Rloss), + (color & fmt->Gmask) >> (fmt->Gshift - fmt->Gloss), + (color & fmt->Bmask) << (fmt->Bloss - fmt->Bshift), + 0xFF); + surface->FillRectangle(surface, dstrect->x, dstrect->y, dstrect->w, + dstrect->h); return 0; } static int -DirectFB_SetHWColorKey (_THIS, SDL_Surface * src, Uint32 key) +DirectFB_SetHWColorKey(_THIS, SDL_Surface * src, Uint32 key) { SDL_PixelFormat *fmt = src->format; IDirectFBSurface *surface = src->hwdata->surface; if (fmt->BitsPerPixel == 8) - surface->SetSrcColorKeyIndex (surface, key); + surface->SetSrcColorKeyIndex(surface, key); else /* ugly */ - surface->SetSrcColorKey (surface, - (key & fmt->Rmask) >> (fmt->Rshift - - fmt->Rloss), - (key & fmt->Gmask) >> (fmt->Gshift - - fmt->Gloss), - (key & fmt->Bmask) << (fmt->Bloss - - fmt->Bshift)); + surface->SetSrcColorKey(surface, + (key & fmt->Rmask) >> (fmt->Rshift - + fmt->Rloss), + (key & fmt->Gmask) >> (fmt->Gshift - + fmt->Gloss), + (key & fmt->Bmask) << (fmt->Bloss - + fmt->Bshift)); return 0; } static int -DirectFB_SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 alpha) +DirectFB_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha) { return 0; } static int -DirectFB_FlipHWSurface (_THIS, SDL_Surface * surface) +DirectFB_FlipHWSurface(_THIS, SDL_Surface * surface) { if (HIDDEN->enable_mga_crtc2) { int rtn = - surface->hwdata->surface->Flip (surface->hwdata->surface, NULL, - 0); + surface->hwdata->surface->Flip(surface->hwdata->surface, NULL, + 0); if (HIDDEN->mga_crtc2_stretch) - HIDDEN->c2frame->StretchBlit (HIDDEN->c2frame, - surface->hwdata->surface, - &HIDDEN->c2ssize, &HIDDEN->c2dsize); + HIDDEN->c2frame->StretchBlit(HIDDEN->c2frame, + surface->hwdata->surface, + &HIDDEN->c2ssize, &HIDDEN->c2dsize); else - HIDDEN->c2frame->Blit (HIDDEN->c2frame, - surface->hwdata->surface, NULL, - HIDDEN->c2dsize.x, HIDDEN->c2dsize.y); + HIDDEN->c2frame->Blit(HIDDEN->c2frame, + surface->hwdata->surface, NULL, + HIDDEN->c2dsize.x, HIDDEN->c2dsize.y); - HIDDEN->c2frame->Flip (HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC); + HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC); return rtn; } else - return surface->hwdata->surface->Flip (surface->hwdata->surface, NULL, - DSFLIP_WAITFORSYNC); + return surface->hwdata->surface->Flip(surface->hwdata->surface, NULL, + DSFLIP_WAITFORSYNC); } static int -DirectFB_LockHWSurface (_THIS, SDL_Surface * surface) +DirectFB_LockHWSurface(_THIS, SDL_Surface * surface) { DFBResult ret; void *data; int pitch; - ret = surface->hwdata->surface->Lock (surface->hwdata->surface, - DSLF_WRITE, &data, &pitch); + ret = surface->hwdata->surface->Lock(surface->hwdata->surface, + DSLF_WRITE, &data, &pitch); if (ret) { - SetDirectFBerror ("surface->Lock", ret); + SetDirectFBerror("surface->Lock", ret); return -1; } @@ -989,31 +987,31 @@ } static void -DirectFB_UnlockHWSurface (_THIS, SDL_Surface * surface) +DirectFB_UnlockHWSurface(_THIS, SDL_Surface * surface) { - surface->hwdata->surface->Unlock (surface->hwdata->surface); + surface->hwdata->surface->Unlock(surface->hwdata->surface); surface->pixels = NULL; } static void -DirectFB_DirectUpdate (_THIS, int numrects, SDL_Rect * rects) +DirectFB_DirectUpdate(_THIS, int numrects, SDL_Rect * rects) { if (HIDDEN->enable_mga_crtc2) { if (HIDDEN->mga_crtc2_stretch) - HIDDEN->c2frame->StretchBlit (HIDDEN->c2frame, - this->screen->hwdata->surface, - &HIDDEN->c2ssize, &HIDDEN->c2dsize); + HIDDEN->c2frame->StretchBlit(HIDDEN->c2frame, + this->screen->hwdata->surface, + &HIDDEN->c2ssize, &HIDDEN->c2dsize); else - HIDDEN->c2frame->Blit (HIDDEN->c2frame, - this->screen->hwdata->surface, NULL, - HIDDEN->c2dsize.x, HIDDEN->c2dsize.y); + HIDDEN->c2frame->Blit(HIDDEN->c2frame, + this->screen->hwdata->surface, NULL, + HIDDEN->c2dsize.x, HIDDEN->c2dsize.y); - HIDDEN->c2frame->Flip (HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC); + HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC); } } static void -DirectFB_WindowedUpdate (_THIS, int numrects, SDL_Rect * rects) +DirectFB_WindowedUpdate(_THIS, int numrects, SDL_Rect * rects) { DFBRegion region; int i; @@ -1054,21 +1052,21 @@ if (region_valid) { if (HIDDEN->enable_mga_crtc2) { if (HIDDEN->mga_crtc2_stretch) - HIDDEN->c2frame->StretchBlit (HIDDEN->c2frame, surface, - &HIDDEN->c2ssize, - &HIDDEN->c2dsize); + HIDDEN->c2frame->StretchBlit(HIDDEN->c2frame, surface, + &HIDDEN->c2ssize, + &HIDDEN->c2dsize); else - HIDDEN->c2frame->Blit (HIDDEN->c2frame, surface, NULL, - HIDDEN->c2dsize.x, HIDDEN->c2dsize.y); + HIDDEN->c2frame->Blit(HIDDEN->c2frame, surface, NULL, + HIDDEN->c2dsize.x, HIDDEN->c2dsize.y); - HIDDEN->c2frame->Flip (HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC); + HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC); } else - surface->Flip (surface, ®ion, DSFLIP_WAITFORSYNC); + surface->Flip(surface, ®ion, DSFLIP_WAITFORSYNC); } } int -DirectFB_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +DirectFB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { IDirectFBPalette *palette = this->screen->hwdata->palette; @@ -1092,14 +1090,14 @@ entries[i].b = colors[i].b; } - palette->SetEntries (palette, entries, ncolors, firstcolor); + palette->SetEntries(palette, entries, ncolors, firstcolor); } return 1; } void -DirectFB_VideoQuit (_THIS) +DirectFB_VideoQuit(_THIS) { struct DirectFBEnumRect *rect = enumlist; @@ -1108,50 +1106,50 @@ IDirectFBPalette *palette = this->screen->hwdata->palette; if (palette) - palette->Release (palette); + palette->Release(palette); if (surface) - surface->Release (surface); + surface->Release(surface); this->screen->hwdata->surface = NULL; this->screen->hwdata->palette = NULL; } if (HIDDEN->c2frame) { - HIDDEN->c2frame->Release (HIDDEN->c2frame); + HIDDEN->c2frame->Release(HIDDEN->c2frame); HIDDEN->c2frame = NULL; } if (HIDDEN->eventbuffer) { - HIDDEN->eventbuffer->Release (HIDDEN->eventbuffer); + HIDDEN->eventbuffer->Release(HIDDEN->eventbuffer); HIDDEN->eventbuffer = NULL; } if (HIDDEN->c2layer) { - HIDDEN->c2layer->Release (HIDDEN->c2layer); + HIDDEN->c2layer->Release(HIDDEN->c2layer); HIDDEN->c2layer = NULL; } if (HIDDEN->layer) { - HIDDEN->layer->Release (HIDDEN->layer); + HIDDEN->layer->Release(HIDDEN->layer); HIDDEN->layer = NULL; } if (HIDDEN->dfb) { - HIDDEN->dfb->Release (HIDDEN->dfb); + HIDDEN->dfb->Release(HIDDEN->dfb); HIDDEN->dfb = NULL; } /* Free video mode list */ if (HIDDEN->modelist) { - free (HIDDEN->modelist); + free(HIDDEN->modelist); HIDDEN->modelist = NULL; } /* Free mode enumeration list */ while (rect) { struct DirectFBEnumRect *next = rect->next; - free (rect); + free(rect); rect = next; } enumlist = NULL; @@ -1161,19 +1159,19 @@ int -DirectFB_ShowWMCursor (_THIS, WMcursor * cursor) +DirectFB_ShowWMCursor(_THIS, WMcursor * cursor) { /* We can only hide or show the default cursor */ if (cursor == NULL) { - HIDDEN->layer->SetCursorOpacity (HIDDEN->layer, 0x00); + HIDDEN->layer->SetCursorOpacity(HIDDEN->layer, 0x00); } else { - HIDDEN->layer->SetCursorOpacity (HIDDEN->layer, 0xFF); + HIDDEN->layer->SetCursorOpacity(HIDDEN->layer, 0xFF); } return 1; } void -DirectFB_FinalQuit (void) +DirectFB_FinalQuit(void) { } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/directfb/SDL_DirectFB_video.h --- a/src/video/directfb/SDL_DirectFB_video.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/directfb/SDL_DirectFB_video.h Mon May 29 04:04:35 2006 +0000 @@ -57,7 +57,7 @@ #define HIDDEN (this->hidden) -void SetDirectFBerror (const char *function, DFBResult code); +void SetDirectFBerror(const char *function, DFBResult code); #endif /* _SDL_DirectFB_video_h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/directfb/SDL_DirectFB_yuv.c --- a/src/video/directfb/SDL_DirectFB_yuv.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/directfb/SDL_DirectFB_yuv.c Mon May 29 04:04:35 2006 +0000 @@ -49,8 +49,8 @@ }; static DFBEnumerationResult -enum_layers_callback (DFBDisplayLayerID id, - DFBDisplayLayerDescription desc, void *data) +enum_layers_callback(DFBDisplayLayerID id, + DFBDisplayLayerDescription desc, void *data) { struct private_yuvhwdata *hwdata = (struct private_yuvhwdata *) data; @@ -70,26 +70,26 @@ static DFBResult -CreateYUVSurface (_THIS, struct private_yuvhwdata *hwdata, - int width, int height, Uint32 format) +CreateYUVSurface(_THIS, struct private_yuvhwdata *hwdata, + int width, int height, Uint32 format) { DFBResult ret; IDirectFB *dfb = HIDDEN->dfb; IDirectFBDisplayLayer *layer; DFBDisplayLayerConfig conf; - ret = dfb->EnumDisplayLayers (dfb, enum_layers_callback, hwdata); + ret = dfb->EnumDisplayLayers(dfb, enum_layers_callback, hwdata); if (ret) { - SetDirectFBerror ("IDirectFB::EnumDisplayLayers", ret); + SetDirectFBerror("IDirectFB::EnumDisplayLayers", ret); return ret; } if (!hwdata->layer_id) return DFB_UNSUPPORTED; - ret = dfb->GetDisplayLayer (dfb, hwdata->layer_id, &layer); + ret = dfb->GetDisplayLayer(dfb, hwdata->layer_id, &layer); if (ret) { - SetDirectFBerror ("IDirectFB::GetDisplayLayer", ret); + SetDirectFBerror("IDirectFB::GetDisplayLayer", ret); return ret; } @@ -111,22 +111,22 @@ conf.pixelformat = DSPF_UYVY; break; default: - fprintf (stderr, "SDL_DirectFB: Unsupported YUV format (0x%08x)!\n", - format); + fprintf(stderr, "SDL_DirectFB: Unsupported YUV format (0x%08x)!\n", + format); break; } - ret = layer->SetConfiguration (layer, &conf); + ret = layer->SetConfiguration(layer, &conf); if (ret) { - SetDirectFBerror ("IDirectFBDisplayLayer::SetConfiguration", ret); - layer->Release (layer); + SetDirectFBerror("IDirectFBDisplayLayer::SetConfiguration", ret); + layer->Release(layer); return ret; } - ret = layer->GetSurface (layer, &hwdata->surface); + ret = layer->GetSurface(layer, &hwdata->surface); if (ret) { - SetDirectFBerror ("IDirectFBDisplayLayer::GetSurface", ret); - layer->Release (layer); + SetDirectFBerror("IDirectFBDisplayLayer::GetSurface", ret); + layer->Release(layer); return ret; } @@ -136,16 +136,16 @@ } SDL_Overlay * -DirectFB_CreateYUVOverlay (_THIS, int width, int height, Uint32 format, - SDL_Surface * display) +DirectFB_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, + SDL_Surface * display) { SDL_Overlay *overlay; struct private_yuvhwdata *hwdata; /* Create the overlay structure */ - overlay = SDL_calloc (1, sizeof (SDL_Overlay)); + overlay = SDL_calloc(1, sizeof(SDL_Overlay)); if (!overlay) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return NULL; } @@ -158,16 +158,16 @@ overlay->hwfuncs = &directfb_yuvfuncs; /* Create the pixel data and lookup tables */ - hwdata = SDL_calloc (1, sizeof (struct private_yuvhwdata)); + hwdata = SDL_calloc(1, sizeof(struct private_yuvhwdata)); overlay->hwdata = hwdata; if (!hwdata) { - SDL_OutOfMemory (); - SDL_FreeYUVOverlay (overlay); + SDL_OutOfMemory(); + SDL_FreeYUVOverlay(overlay); return NULL; } - if (CreateYUVSurface (this, hwdata, width, height, format)) { - SDL_FreeYUVOverlay (overlay); + if (CreateYUVSurface(this, hwdata, width, height, format)) { + SDL_FreeYUVOverlay(overlay); return NULL; } @@ -191,16 +191,16 @@ } int -DirectFB_LockYUVOverlay (_THIS, SDL_Overlay * overlay) +DirectFB_LockYUVOverlay(_THIS, SDL_Overlay * overlay) { DFBResult ret; void *data; int pitch; IDirectFBSurface *surface = overlay->hwdata->surface; - ret = surface->Lock (surface, DSLF_READ | DSLF_WRITE, &data, &pitch); + ret = surface->Lock(surface, DSLF_READ | DSLF_WRITE, &data, &pitch); if (ret) { - SetDirectFBerror ("IDirectFBSurface::Lock", ret); + SetDirectFBerror("IDirectFBSurface::Lock", ret); return -1; } @@ -228,33 +228,33 @@ } void -DirectFB_UnlockYUVOverlay (_THIS, SDL_Overlay * overlay) +DirectFB_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay) { IDirectFBSurface *surface = overlay->hwdata->surface; overlay->pixels[0] = overlay->pixels[1] = overlay->pixels[2] = NULL; - surface->Unlock (surface); + surface->Unlock(surface); } int -DirectFB_DisplayYUVOverlay (_THIS, SDL_Overlay * overlay, SDL_Rect * src, - SDL_Rect * dst) +DirectFB_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, SDL_Rect * src, + SDL_Rect * dst) { DFBResult ret; DFBDisplayLayerConfig conf; IDirectFBDisplayLayer *primary = HIDDEN->layer; IDirectFBDisplayLayer *layer = overlay->hwdata->layer; - primary->GetConfiguration (primary, &conf); + primary->GetConfiguration(primary, &conf); - ret = layer->SetScreenLocation (layer, - dst->x / (float) conf.width, - dst->y / (float) conf.height, - dst->w / (float) conf.width, - dst->h / (float) conf.height); + ret = layer->SetScreenLocation(layer, + dst->x / (float) conf.width, + dst->y / (float) conf.height, + dst->w / (float) conf.width, + dst->h / (float) conf.height); if (ret) { - SetDirectFBerror ("IDirectFBDisplayLayer::SetScreenLocation", ret); + SetDirectFBerror("IDirectFBDisplayLayer::SetScreenLocation", ret); return -1; } @@ -262,19 +262,19 @@ } void -DirectFB_FreeYUVOverlay (_THIS, SDL_Overlay * overlay) +DirectFB_FreeYUVOverlay(_THIS, SDL_Overlay * overlay) { struct private_yuvhwdata *hwdata; hwdata = overlay->hwdata; if (hwdata) { if (hwdata->surface) - hwdata->surface->Release (hwdata->surface); + hwdata->surface->Release(hwdata->surface); if (hwdata->layer) - hwdata->layer->Release (hwdata->layer); + hwdata->layer->Release(hwdata->layer); - free (hwdata); + free(hwdata); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/directfb/SDL_DirectFB_yuv.h --- a/src/video/directfb/SDL_DirectFB_yuv.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/directfb/SDL_DirectFB_yuv.h Mon May 29 04:04:35 2006 +0000 @@ -26,16 +26,16 @@ #include "SDL_video.h" #include "SDL_DirectFB_video.h" -extern SDL_Overlay *DirectFB_CreateYUVOverlay (_THIS, int width, int height, - Uint32 format, - SDL_Surface * display); +extern SDL_Overlay *DirectFB_CreateYUVOverlay(_THIS, int width, int height, + Uint32 format, + SDL_Surface * display); -extern int DirectFB_LockYUVOverlay (_THIS, SDL_Overlay * overlay); +extern int DirectFB_LockYUVOverlay(_THIS, SDL_Overlay * overlay); -extern void DirectFB_UnlockYUVOverlay (_THIS, SDL_Overlay * overlay); +extern void DirectFB_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay); -extern int DirectFB_DisplayYUVOverlay (_THIS, SDL_Overlay * overlay, - SDL_Rect * src, SDL_Rect * dst); +extern int DirectFB_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, + SDL_Rect * src, SDL_Rect * dst); -extern void DirectFB_FreeYUVOverlay (_THIS, SDL_Overlay * overlay); +extern void DirectFB_FreeYUVOverlay(_THIS, SDL_Overlay * overlay); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/dummy/SDL_nullevents.c --- a/src/video/dummy/SDL_nullevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/dummy/SDL_nullevents.c Mon May 29 04:04:35 2006 +0000 @@ -32,13 +32,13 @@ #include "SDL_nullevents_c.h" void -DUMMY_PumpEvents (_THIS) +DUMMY_PumpEvents(_THIS) { /* do nothing. */ } void -DUMMY_InitOSKeymap (_THIS) +DUMMY_InitOSKeymap(_THIS) { /* do nothing. */ } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/dummy/SDL_nullevents_c.h --- a/src/video/dummy/SDL_nullevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/dummy/SDL_nullevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -26,8 +26,8 @@ /* Variables and functions exported by SDL_sysevents.c to other parts of the native video subsystem (SDL_sysvideo.c) */ -extern void DUMMY_InitOSKeymap (_THIS); -extern void DUMMY_PumpEvents (_THIS); +extern void DUMMY_InitOSKeymap(_THIS); +extern void DUMMY_PumpEvents(_THIS); /* end of SDL_nullevents_c.h ... */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/dummy/SDL_nullvideo.c --- a/src/video/dummy/SDL_nullvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/dummy/SDL_nullvideo.c Mon May 29 04:04:35 2006 +0000 @@ -49,19 +49,19 @@ #define DUMMYVID_DRIVER_NAME "dummy" /* Initialization/Query functions */ -static int DUMMY_VideoInit (_THIS); -static int DUMMY_SetDisplayMode (_THIS, const SDL_DisplayMode * mode); -static void DUMMY_CreateWindowSurface (_THIS, SDL_Window * window, - Uint32 flags); -static void DUMMY_VideoQuit (_THIS); +static int DUMMY_VideoInit(_THIS); +static int DUMMY_SetDisplayMode(_THIS, const SDL_DisplayMode * mode); +static void DUMMY_CreateWindowSurface(_THIS, SDL_Window * window, + Uint32 flags); +static void DUMMY_VideoQuit(_THIS); /* DUMMY driver bootstrap functions */ static int -DUMMY_Available (void) +DUMMY_Available(void) { - const char *envr = SDL_getenv ("SDL_VIDEODRIVER"); - if ((envr) && (SDL_strcmp (envr, DUMMYVID_DRIVER_NAME) == 0)) { + const char *envr = SDL_getenv("SDL_VIDEODRIVER"); + if ((envr) && (SDL_strcmp(envr, DUMMYVID_DRIVER_NAME) == 0)) { return (1); } @@ -69,32 +69,32 @@ } static void -DUMMY_DeleteDevice (SDL_VideoDevice * device) +DUMMY_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -DUMMY_CreateDevice (int devindex) +DUMMY_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = DUMMY_VideoInit; @@ -116,11 +116,11 @@ int -DUMMY_VideoInit (_THIS) +DUMMY_VideoInit(_THIS) { SDL_DisplayMode mode; - SDL_AddBasicVideoDisplay (NULL); + SDL_AddBasicVideoDisplay(NULL); SDL_zero(mode); SDL_AddDisplayMode(0, &mode); @@ -130,29 +130,29 @@ } static int -DUMMY_SetDisplayMode (_THIS, const SDL_DisplayMode * mode) +DUMMY_SetDisplayMode(_THIS, const SDL_DisplayMode * mode) { return 0; } static void -DUMMY_CreateWindowSurface (_THIS, SDL_Window * window, Uint32 flags) +DUMMY_CreateWindowSurface(_THIS, SDL_Window * window, Uint32 flags) { int bpp; Uint32 Rmask, Gmask, Bmask, Amask; - SDL_PixelFormatEnumToMasks (SDL_GetCurrentDisplayMode ()->format, &bpp, - &Rmask, &Gmask, &Bmask, &Amask); + SDL_PixelFormatEnumToMasks(SDL_GetCurrentDisplayMode()->format, &bpp, + &Rmask, &Gmask, &Bmask, &Amask); window->surface = - SDL_CreateRGBSurface (flags, window->w, window->h, bpp, Rmask, Gmask, - Bmask, Amask); + SDL_CreateRGBSurface(flags, window->w, window->h, bpp, Rmask, Gmask, + Bmask, Amask); } /* Note: If we are terminated, this could be called in the middle of another SDL video routine -- notably UpdateRects. */ void -DUMMY_VideoQuit (_THIS) +DUMMY_VideoQuit(_THIS) { } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/e_log.h --- a/src/video/e_log.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/e_log.h Mon May 29 04:04:35 2006 +0000 @@ -85,10 +85,10 @@ #ifdef __STDC__ double -__ieee754_log (double x) +__ieee754_log(double x) #else double -__ieee754_log (x) +__ieee754_log(x) double x; #endif { @@ -96,7 +96,7 @@ int32_t k, hx, i, j; u_int32_t lx; - EXTRACT_WORDS (hx, lx, x); + EXTRACT_WORDS(hx, lx, x); k = 0; if (hx < 0x00100000) { /* x < 2**-1022 */ @@ -106,14 +106,14 @@ return (x - x) / zero; /* log(-#) = NaN */ k -= 54; x *= two54; /* subnormal number, scale up x */ - GET_HIGH_WORD (hx, x); + GET_HIGH_WORD(hx, x); } if (hx >= 0x7ff00000) return x + x; k += (hx >> 20) - 1023; hx &= 0x000fffff; i = (hx + 0x95f64) & 0x100000; - SET_HIGH_WORD (x, hx | (i ^ 0x3ff00000)); /* normalize x or x/2 */ + SET_HIGH_WORD(x, hx | (i ^ 0x3ff00000)); /* normalize x or x/2 */ k += (i >> 20); f = x - 1.0; if ((0x000fffff & (2 + hx)) < 3) { /* |f| < 2**-20 */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/e_pow.h --- a/src/video/e_pow.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/e_pow.h Mon May 29 04:04:35 2006 +0000 @@ -98,10 +98,10 @@ #ifdef __STDC__ double -__ieee754_pow (double x, double y) +__ieee754_pow(double x, double y) #else double -__ieee754_pow (x, y) +__ieee754_pow(x, y) double x, y; #endif { @@ -111,8 +111,8 @@ int32_t hx, hy, ix, iy; u_int32_t lx, ly; - EXTRACT_WORDS (hx, lx, x); - EXTRACT_WORDS (hy, ly, y); + EXTRACT_WORDS(hx, lx, x); + EXTRACT_WORDS(hy, ly, y); ix = hx & 0x7fffffff; iy = hy & 0x7fffffff; @@ -168,7 +168,7 @@ return x * x; /* y is 2 */ if (hy == 0x3fe00000) { /* y is 0.5 */ if (hx >= 0) /* x >= +0 */ - return __ieee754_sqrt (x); + return __ieee754_sqrt(x); } } @@ -213,7 +213,7 @@ u = ivln2_h * t; /* ivln2_h has 21 sig. bits */ v = t * ivln2_l - w * ivln2; t1 = u + v; - SET_LOW_WORD (t1, 0); + SET_LOW_WORD(t1, 0); t2 = v - (t1 - u); } else { double s2, s_h, s_l, t_h, t_l; @@ -222,7 +222,7 @@ if (ix < 0x00100000) { ax *= two53; n -= 53; - GET_HIGH_WORD (ix, ax); + GET_HIGH_WORD(ix, ax); } n += ((ix) >> 20) - 0x3ff; j = ix & 0x000fffff; @@ -237,18 +237,17 @@ n += 1; ix -= 0x00100000; } - SET_HIGH_WORD (ax, ix); + SET_HIGH_WORD(ax, ix); /* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */ u = ax - bp[k]; /* bp[0]=1.0, bp[1]=1.5 */ v = one / (ax + bp[k]); s = u * v; s_h = s; - SET_LOW_WORD (s_h, 0); + SET_LOW_WORD(s_h, 0); /* t_h=ax+bp[k] High */ t_h = zero; - SET_HIGH_WORD (t_h, - ((ix >> 1) | 0x20000000) + 0x00080000 + (k << 18)); + SET_HIGH_WORD(t_h, ((ix >> 1) | 0x20000000) + 0x00080000 + (k << 18)); t_l = ax - (t_h - bp[k]); s_l = v * ((u - s_h * t_h) - s_h * t_l); /* compute log(ax) */ @@ -259,21 +258,21 @@ r += s_l * (s_h + s); s2 = s_h * s_h; t_h = 3.0 + s2 + r; - SET_LOW_WORD (t_h, 0); + SET_LOW_WORD(t_h, 0); t_l = r - ((t_h - 3.0) - s2); /* u+v = s*(1+...) */ u = s_h * t_h; v = s_l * t_h + t_l * s; /* 2/(3log2)*(s+...) */ p_h = u + v; - SET_LOW_WORD (p_h, 0); + SET_LOW_WORD(p_h, 0); p_l = v - (p_h - u); z_h = cp_h * p_h; /* cp_h+cp_l = 2/(3*log2) */ z_l = cp_l * p_h + p_l * cp + dp_l[k]; /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ t = (double) n; t1 = (((z_h + z_l) + dp_h[k]) + t); - SET_LOW_WORD (t1, 0); + SET_LOW_WORD(t1, 0); t2 = z_l - (((t1 - t) - dp_h[k]) - z_h); } @@ -283,11 +282,11 @@ /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ y1 = y; - SET_LOW_WORD (y1, 0); + SET_LOW_WORD(y1, 0); p_l = (y - y1) * t1 + y * t2; p_h = y1 * t1; z = p_l + p_h; - EXTRACT_WORDS (j, i, z); + EXTRACT_WORDS(j, i, z); if (j >= 0x40900000) { /* z >= 1024 */ if (((j - 0x40900000) | i) != 0) /* if z > 1024 */ return s * huge * huge; /* overflow */ @@ -313,14 +312,14 @@ n = j + (0x00100000 >> (k + 1)); k = ((n & 0x7fffffff) >> 20) - 0x3ff; /* new k for n */ t = zero; - SET_HIGH_WORD (t, n & ~(0x000fffff >> k)); + SET_HIGH_WORD(t, n & ~(0x000fffff >> k)); n = ((n & 0x000fffff) | 0x00100000) >> (20 - k); if (j < 0) n = -n; p_h -= t; } t = p_l + p_h; - SET_LOW_WORD (t, 0); + SET_LOW_WORD(t, 0); u = t * lg2_h; v = (p_l - (t - p_h)) * lg2 + t * lg2_l; z = u + v; @@ -329,12 +328,12 @@ t1 = z - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5)))); r = (z * t1) / (t1 - two) - (w + z * w); z = one - (r - z); - GET_HIGH_WORD (j, z); + GET_HIGH_WORD(j, z); j += (n << 20); if ((j >> 20) <= 0) - z = SDL_NAME (scalbn) (z, n); /* subnormal output */ + z = SDL_NAME(scalbn) (z, n); /* subnormal output */ else - SET_HIGH_WORD (z, j); + SET_HIGH_WORD(z, j); return s * z; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/e_sqrt.h --- a/src/video/e_sqrt.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/e_sqrt.h Mon May 29 04:04:35 2006 +0000 @@ -88,25 +88,25 @@ #include "math_private.h" #ifdef __STDC__ -double SDL_NAME (copysign) (double x, double y) +double SDL_NAME(copysign) (double x, double y) #else -double SDL_NAME (copysign) (x, y) +double SDL_NAME(copysign) (x, y) double x, y; #endif { u_int32_t hx, hy; - GET_HIGH_WORD (hx, x); - GET_HIGH_WORD (hy, y); - SET_HIGH_WORD (x, (hx & 0x7fffffff) | (hy & 0x80000000)); + GET_HIGH_WORD(hx, x); + GET_HIGH_WORD(hy, y); + SET_HIGH_WORD(x, (hx & 0x7fffffff) | (hy & 0x80000000)); return x; } #ifdef __STDC__ -double SDL_NAME (scalbn) (double x, int n) +double SDL_NAME(scalbn) (double x, int n) #else -double SDL_NAME (scalbn) (x, n) +double SDL_NAME(scalbn) (x, n) double x; int @@ -114,13 +114,13 @@ #endif { int32_t k, hx, lx; - EXTRACT_WORDS (hx, lx, x); + EXTRACT_WORDS(hx, lx, x); k = (hx & 0x7ff00000) >> 20; /* extract exponent */ if (k == 0) { /* 0 or subnormal x */ if ((lx | (hx & 0x7fffffff)) == 0) return x; /* +-0 */ x *= two54; - GET_HIGH_WORD (hx, x); + GET_HIGH_WORD(hx, x); k = ((hx & 0x7ff00000) >> 20) - 54; if (n < -50000) return tiny * x; /*underflow */ @@ -129,28 +129,28 @@ return x + x; /* NaN or Inf */ k = k + n; if (k > 0x7fe) - return huge * SDL_NAME (copysign) (huge, x); /* overflow */ + return huge * SDL_NAME(copysign) (huge, x); /* overflow */ if (k > 0) { /* normal result */ - SET_HIGH_WORD (x, (hx & 0x800fffff) | (k << 20)); + SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20)); return x; } if (k <= -54) { if (n > 50000) /* in case integer overflow in n+k */ - return huge * SDL_NAME (copysign) (huge, x); /*overflow */ + return huge * SDL_NAME(copysign) (huge, x); /*overflow */ else - return tiny * SDL_NAME (copysign) (tiny, x); /*underflow */ + return tiny * SDL_NAME(copysign) (tiny, x); /*underflow */ } k += 54; /* subnormal result */ - SET_HIGH_WORD (x, (hx & 0x800fffff) | (k << 20)); + SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20)); return x * twom54; } #ifdef __STDC__ double -__ieee754_sqrt (double x) +__ieee754_sqrt(double x) #else double -__ieee754_sqrt (x) +__ieee754_sqrt(x) double x; #endif { @@ -159,7 +159,7 @@ int32_t ix0, s0, q, m, t, i; u_int32_t r, t1, s1, ix1, q1; - EXTRACT_WORDS (ix0, ix1, x); + EXTRACT_WORDS(ix0, ix1, x); /* take care of Inf and NaN */ if ((ix0 & 0x7ff00000) == 0x7ff00000) { @@ -253,7 +253,7 @@ if ((q & 1) == 1) ix1 |= sign; ix0 += (m << 20); - INSERT_WORDS (z, ix0, ix1); + INSERT_WORDS(z, ix0, ix1); return z; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/epoc/SDL_epocevents_c.h --- a/src/video/epoc/SDL_epocevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/epoc/SDL_epocevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -42,7 +42,7 @@ extern "C" { - extern void EPOC_InitOSKeymap (_THIS); - extern void EPOC_PumpEvents (_THIS); + extern void EPOC_InitOSKeymap(_THIS); + extern void EPOC_PumpEvents(_THIS); }; /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/epoc/SDL_epocvideo.h --- a/src/video/epoc/SDL_epocvideo.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/epoc/SDL_epocvideo.h Mon May 29 04:04:35 2006 +0000 @@ -86,7 +86,7 @@ extern "C" { - extern void RedrawWindowL (_THIS); + extern void RedrawWindowL(_THIS); }; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/fbcon/SDL_fb3dfx.c --- a/src/video/fbcon/SDL_fb3dfx.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/fbcon/SDL_fb3dfx.c Mon May 29 04:04:35 2006 +0000 @@ -29,29 +29,29 @@ /* Wait for vertical retrace */ static void -WaitVBL (_THIS) +WaitVBL(_THIS) { /* find start of retrace */ - tdfx_waitidle (); - while ((tdfx_in32 (TDFX_STATUS) & STATUS_RETRACE) == STATUS_RETRACE); + tdfx_waitidle(); + while ((tdfx_in32(TDFX_STATUS) & STATUS_RETRACE) == STATUS_RETRACE); /* wait until we're past the start */ - while ((tdfx_in32 (TDFX_STATUS) & STATUS_RETRACE) == 0); + while ((tdfx_in32(TDFX_STATUS) & STATUS_RETRACE) == 0); } static void -WaitIdle (_THIS) +WaitIdle(_THIS) { - tdfx_waitidle (); + tdfx_waitidle(); } /* Sets video mem colorkey and accelerated blit function */ static int -SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key) +SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key) { return (0); } static int -FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) +FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) { int bpp; char *dst_base; @@ -63,7 +63,7 @@ return -2; /* no hardware access */ } if (dst == this->screen) { - SDL_mutexP (hw_lock); + SDL_mutexP(hw_lock); } /* Set the destination pixel format */ @@ -76,25 +76,25 @@ dstY = rect->y; /* Execute the fill command */ - tdfx_wait (6); - tdfx_out32 (DSTBASE, (Uint32) dst_base); - tdfx_out32 (DSTFORMAT, format); - tdfx_out32 (COLORFORE, color); - tdfx_out32 (COMMAND_2D, COMMAND_2D_FILLRECT); - tdfx_out32 (DSTSIZE, rect->w | (rect->h << 16)); - tdfx_out32 (LAUNCH_2D, dstX | (dstY << 16)); + tdfx_wait(6); + tdfx_out32(DSTBASE, (Uint32) dst_base); + tdfx_out32(DSTFORMAT, format); + tdfx_out32(COLORFORE, color); + tdfx_out32(COMMAND_2D, COMMAND_2D_FILLRECT); + tdfx_out32(DSTSIZE, rect->w | (rect->h << 16)); + tdfx_out32(LAUNCH_2D, dstX | (dstY << 16)); - FB_AddBusySurface (dst); + FB_AddBusySurface(dst); if (dst == this->screen) { - SDL_mutexV (hw_lock); + SDL_mutexV(hw_lock); } return (0); } static int -HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { SDL_VideoDevice *this = current_video; int bpp; @@ -112,7 +112,7 @@ return -2; /* no hardware access */ } if (dst == this->screen) { - SDL_mutexP (hw_lock); + SDL_mutexP(hw_lock); } /* Set the source and destination pixel format */ @@ -131,48 +131,48 @@ /* Assemble the blit operation */ blitop = COMMAND_2D_BITBLT | (0xCC << 24); if (srcX <= dstX) { - blitop |= BIT (14); + blitop |= BIT(14); srcX += (dstrect->w - 1); dstX += (dstrect->w - 1); } if (srcY <= dstY) { - blitop |= BIT (15); + blitop |= BIT(15); srcY += (dstrect->h - 1); dstY += (dstrect->h - 1); } /* Perform the blit! */ if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { - tdfx_wait (3); - tdfx_out32 (SRCCOLORKEYMIN, src->format->colorkey); - tdfx_out32 (SRCCOLORKEYMAX, src->format->colorkey); - tdfx_out32 (ROP_2D, 0xAA00); + tdfx_wait(3); + tdfx_out32(SRCCOLORKEYMIN, src->format->colorkey); + tdfx_out32(SRCCOLORKEYMAX, src->format->colorkey); + tdfx_out32(ROP_2D, 0xAA00); use_colorkey = 1; } else { use_colorkey = 0; } - tdfx_wait (9); - tdfx_out32 (SRCBASE, (Uint32) src_base); - tdfx_out32 (SRCFORMAT, src_format); - tdfx_out32 (DSTBASE, (Uint32) dst_base); - tdfx_out32 (DSTFORMAT, src_format); - tdfx_out32 (COMMAND_2D, blitop); - tdfx_out32 (COMMANDEXTRA_2D, use_colorkey); - tdfx_out32 (DSTSIZE, dstrect->w | (dstrect->h << 16)); - tdfx_out32 (DSTXY, dstX | (dstY << 16)); - tdfx_out32 (LAUNCH_2D, srcX | (srcY << 16)); + tdfx_wait(9); + tdfx_out32(SRCBASE, (Uint32) src_base); + tdfx_out32(SRCFORMAT, src_format); + tdfx_out32(DSTBASE, (Uint32) dst_base); + tdfx_out32(DSTFORMAT, src_format); + tdfx_out32(COMMAND_2D, blitop); + tdfx_out32(COMMANDEXTRA_2D, use_colorkey); + tdfx_out32(DSTSIZE, dstrect->w | (dstrect->h << 16)); + tdfx_out32(DSTXY, dstX | (dstY << 16)); + tdfx_out32(LAUNCH_2D, srcX | (srcY << 16)); - FB_AddBusySurface (src); - FB_AddBusySurface (dst); + FB_AddBusySurface(src); + FB_AddBusySurface(dst); if (dst == this->screen) { - SDL_mutexV (hw_lock); + SDL_mutexV(hw_lock); } return (0); } static int -CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst) +CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst) { int accelerated; @@ -200,7 +200,7 @@ } void -FB_3DfxAccel (_THIS, __u32 card) +FB_3DfxAccel(_THIS, __u32 card) { /* We have hardware accelerated surface functions */ this->CheckHWBlit = CheckHWBlit; @@ -208,8 +208,8 @@ wait_idle = WaitIdle; /* Reset the 3Dfx controller */ - tdfx_out32 (BRESERROR0, 0); - tdfx_out32 (BRESERROR1, 0); + tdfx_out32(BRESERROR0, 0); + tdfx_out32(BRESERROR1, 0); /* The 3Dfx has an accelerated color fill */ this->info.blit_fill = 1; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/fbcon/SDL_fb3dfx.h --- a/src/video/fbcon/SDL_fb3dfx.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/fbcon/SDL_fb3dfx.h Mon May 29 04:04:35 2006 +0000 @@ -26,5 +26,5 @@ #include "SDL_fbvideo.h" /* Set up the driver for 3Dfx acceleration */ -extern void FB_3DfxAccel (_THIS, __u32 card); +extern void FB_3DfxAccel(_THIS, __u32 card); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/fbcon/SDL_fbelo.c --- a/src/video/fbcon/SDL_fbelo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/fbcon/SDL_fbelo.c Mon May 29 04:04:35 2006 +0000 @@ -79,7 +79,7 @@ /* eloParsePacket */ int -eloParsePacket (unsigned char *mousebuf, int *dx, int *dy, int *button_state) +eloParsePacket(unsigned char *mousebuf, int *dx, int *dy, int *button_state) { static int elo_button = 0; static int last_x = 0; @@ -94,8 +94,8 @@ x = ((mousebuf[4] << 8) | mousebuf[3]); y = ((mousebuf[6] << 8) | mousebuf[5]); - if ((SDL_abs (x - last_x) > ELO_SNAP_SIZE) - || (SDL_abs (y - last_y) > ELO_SNAP_SIZE)) { + if ((SDL_abs(x - last_x) > ELO_SNAP_SIZE) + || (SDL_abs(y - last_y) > ELO_SNAP_SIZE)) { *dx = ((mousebuf[4] << 8) | mousebuf[3]); *dy = ((mousebuf[6] << 8) | mousebuf[5]); } else { @@ -121,7 +121,7 @@ to a screen position. */ void -eloConvertXY (_THIS, int *dx, int *dy) +eloConvertXY(_THIS, int *dx, int *dy) { int input_x = *dx; int input_y = *dy; @@ -138,7 +138,7 @@ /* eloGetPacket */ int -eloGetPacket (unsigned char *buffer, int *buffer_p, int *checksum, int fd) +eloGetPacket(unsigned char *buffer, int *buffer_p, int *checksum, int fd) { int num_bytes; int ok; @@ -146,22 +146,22 @@ if (fd == 0) { num_bytes = ELO_PACKET_SIZE; } else { - num_bytes = read (fd, - (char *) (buffer + *buffer_p), - ELO_PACKET_SIZE - *buffer_p); + num_bytes = read(fd, + (char *) (buffer + *buffer_p), + ELO_PACKET_SIZE - *buffer_p); } if (num_bytes < 0) { #ifdef DEBUG_MOUSE - fprintf (stderr, - "System error while reading from Elographics touchscreen.\n"); + fprintf(stderr, + "System error while reading from Elographics touchscreen.\n"); #endif return 0; } while (num_bytes) { if ((*buffer_p == 0) && (buffer[0] != ELO_START_BYTE)) { - SDL_memcpy (&buffer[0], &buffer[1], num_bytes - 1); + SDL_memcpy(&buffer[0], &buffer[1], num_bytes - 1); } else { if (*buffer_p < ELO_PACKET_SIZE - 1) { *checksum = *checksum + buffer[*buffer_p]; @@ -191,7 +191,7 @@ */ int -eloSendPacket (unsigned char *packet, int fd) +eloSendPacket(unsigned char *packet, int fd) { int i, result; int sum = ELO_INIT_CHECKSUM; @@ -203,11 +203,11 @@ } packet[ELO_PACKET_SIZE - 1] = sum; - result = write (fd, packet, ELO_PACKET_SIZE); + result = write(fd, packet, ELO_PACKET_SIZE); if (result != ELO_PACKET_SIZE) { #ifdef DEBUG_MOUSE - printf ("System error while sending to Elographics touchscreen.\n"); + printf("System error while sending to Elographics touchscreen.\n"); #endif return 0; } else { @@ -219,25 +219,25 @@ /* eloWaitForInput */ int -eloWaitForInput (int fd, int timeout) +eloWaitForInput(int fd, int timeout) { fd_set readfds; struct timeval to; int r; - FD_ZERO (&readfds); - FD_SET (fd, &readfds); + FD_ZERO(&readfds); + FD_SET(fd, &readfds); to.tv_sec = 0; to.tv_usec = timeout; - r = select (FD_SETSIZE, &readfds, NULL, NULL, &to); + r = select(FD_SETSIZE, &readfds, NULL, NULL, &to); return r; } /* eloWaitReply */ int -eloWaitReply (unsigned char type, unsigned char *reply, int fd) +eloWaitReply(unsigned char type, unsigned char *reply, int fd) { int ok; int i, result; @@ -248,20 +248,20 @@ do { ok = 0; - result = eloWaitForInput (fd, ELO_MAX_WAIT); + result = eloWaitForInput(fd, ELO_MAX_WAIT); if (result > 0) { - ok = eloGetPacket (reply, &reply_p, &sum, fd); + ok = eloGetPacket(reply, &reply_p, &sum, fd); if (ok && reply[1] != type && type != ELO_PARAMETER) { #ifdef DEBUG_MOUSE - fprintf (stderr, "Wrong reply received\n"); + fprintf(stderr, "Wrong reply received\n"); #endif ok = 0; } } else { #ifdef DEBUG_MOUSE - fprintf (stderr, "No input!\n"); + fprintf(stderr, "No input!\n"); #endif } @@ -279,12 +279,12 @@ */ int -eloWaitAck (int fd) +eloWaitAck(int fd) { unsigned char packet[ELO_PACKET_SIZE]; int i, nb_errors; - if (eloWaitReply (ELO_ACK, packet, fd)) { + if (eloWaitReply(ELO_ACK, packet, fd)) { for (i = 0, nb_errors = 0; i < 4; i++) { if (packet[2 + i] != '0') { nb_errors++; @@ -293,9 +293,9 @@ if (nb_errors != 0) { #ifdef DEBUG_MOUSE - fprintf (stderr, - "Elographics acknowledge packet reports %d errors\n", - nb_errors); + fprintf(stderr, + "Elographics acknowledge packet reports %d errors\n", + nb_errors); #endif } return 1; @@ -308,14 +308,14 @@ /* eloSendQuery -- */ int -eloSendQuery (unsigned char *request, unsigned char *reply, int fd) +eloSendQuery(unsigned char *request, unsigned char *reply, int fd) { int ok; - if (eloSendPacket (request, fd)) { - ok = eloWaitReply (toupper (request[1]), reply, fd); + if (eloSendPacket(request, fd)) { + ok = eloWaitReply(toupper(request[1]), reply, fd); if (ok) { - ok = eloWaitAck (fd); + ok = eloWaitAck(fd); } return ok; } else { @@ -327,10 +327,10 @@ /* eloSendControl */ int -eloSendControl (unsigned char *control, int fd) +eloSendControl(unsigned char *control, int fd) { - if (eloSendPacket (control, fd)) { - return eloWaitAck (fd); + if (eloSendPacket(control, fd)) { + return eloWaitAck(fd); } else { return 0; } @@ -339,7 +339,7 @@ /* eloInitController */ int -eloInitController (int fd) +eloInitController(int fd) { unsigned char req[ELO_PACKET_SIZE]; unsigned char reply[ELO_PACKET_SIZE]; @@ -349,85 +349,84 @@ struct termios mouse_termios; /* try to read the calibration values */ - buffer = SDL_getenv ("SDL_ELO_MIN_X"); + buffer = SDL_getenv("SDL_ELO_MIN_X"); if (buffer) { - ELO_MIN_X = SDL_atoi (buffer); + ELO_MIN_X = SDL_atoi(buffer); } - buffer = SDL_getenv ("SDL_ELO_MAX_X"); + buffer = SDL_getenv("SDL_ELO_MAX_X"); if (buffer) { - ELO_MAX_X = SDL_atoi (buffer); + ELO_MAX_X = SDL_atoi(buffer); } - buffer = SDL_getenv ("SDL_ELO_MIN_Y"); + buffer = SDL_getenv("SDL_ELO_MIN_Y"); if (buffer) { - ELO_MIN_Y = SDL_atoi (buffer); + ELO_MIN_Y = SDL_atoi(buffer); } - buffer = SDL_getenv ("SDL_ELO_MAX_Y"); + buffer = SDL_getenv("SDL_ELO_MAX_Y"); if (buffer) { - ELO_MAX_Y = SDL_atoi (buffer); + ELO_MAX_Y = SDL_atoi(buffer); } #ifdef DEBUG_MOUSE - fprintf (stderr, - "ELO calibration values:\nmin_x: %i\nmax_x: %i\nmin_y: %i\nmax_y: %i\n", - ELO_MIN_X, ELO_MAX_X, ELO_MIN_Y, ELO_MAX_Y); + fprintf(stderr, + "ELO calibration values:\nmin_x: %i\nmax_x: %i\nmin_y: %i\nmax_y: %i\n", + ELO_MIN_X, ELO_MAX_X, ELO_MIN_Y, ELO_MAX_Y); #endif /* set comm params */ - SDL_memset (&mouse_termios, 0, sizeof (mouse_termios)); + SDL_memset(&mouse_termios, 0, sizeof(mouse_termios)); mouse_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL; mouse_termios.c_cc[VMIN] = 1; - result = tcsetattr (fd, TCSANOW, &mouse_termios); + result = tcsetattr(fd, TCSANOW, &mouse_termios); if (result < 0) { #ifdef DEBUG_MOUSE - fprintf (stderr, - "Unable to configure Elographics touchscreen port\n"); + fprintf(stderr, "Unable to configure Elographics touchscreen port\n"); #endif return 0; } - SDL_memset (req, 0, ELO_PACKET_SIZE); - req[1] = tolower (ELO_PARAMETER); - if (!eloSendQuery (req, reply, fd)) { + SDL_memset(req, 0, ELO_PACKET_SIZE); + req[1] = tolower(ELO_PARAMETER); + if (!eloSendQuery(req, reply, fd)) { #ifdef DEBUG_MOUSE - fprintf (stderr, - "Not at the specified rate or model 2310, will continue\n"); + fprintf(stderr, + "Not at the specified rate or model 2310, will continue\n"); #endif } - SDL_memset (req, 0, ELO_PACKET_SIZE); - req[1] = tolower (ELO_ID); - if (eloSendQuery (req, reply, fd)) { + SDL_memset(req, 0, ELO_PACKET_SIZE); + req[1] = tolower(ELO_ID); + if (eloSendQuery(req, reply, fd)) { #ifdef DEBUG_MOUSE - fprintf (stderr, "Ok, controller configured!\n"); + fprintf(stderr, "Ok, controller configured!\n"); #endif } else { #ifdef DEBUG_MOUSE - fprintf (stderr, - "Unable to ask Elographics touchscreen identification\n"); + fprintf(stderr, + "Unable to ask Elographics touchscreen identification\n"); #endif return 0; } - SDL_memset (req, 0, ELO_PACKET_SIZE); + SDL_memset(req, 0, ELO_PACKET_SIZE); req[1] = ELO_MODE; req[3] = ELO_TOUCH_MODE | ELO_STREAM_MODE | ELO_UNTOUCH_MODE; req[4] = ELO_TRACKING_MODE; - if (!eloSendControl (req, fd)) { + if (!eloSendControl(req, fd)) { #ifdef DEBUG_MOUSE - fprintf (stderr, - "Unable to change Elographics touchscreen operating mode\n"); + fprintf(stderr, + "Unable to change Elographics touchscreen operating mode\n"); #endif return 0; } - SDL_memset (req, 0, ELO_PACKET_SIZE); + SDL_memset(req, 0, ELO_PACKET_SIZE); req[1] = ELO_REPORT; req[2] = ELO_UNTOUCH_DELAY; req[3] = ELO_REPORT_DELAY; - if (!eloSendControl (req, fd)) { + if (!eloSendControl(req, fd)) { #ifdef DEBUG_MOUSE - fprintf (stderr, - "Unable to change Elographics touchscreen reports timings\n"); + fprintf(stderr, + "Unable to change Elographics touchscreen reports timings\n"); #endif return 0; } @@ -436,27 +435,27 @@ } int -eloReadPosition (_THIS, int fd, int *x, int *y, int *button_state, int *realx, - int *realy) +eloReadPosition(_THIS, int fd, int *x, int *y, int *button_state, int *realx, + int *realy) { unsigned char buffer[ELO_PACKET_SIZE]; int pointer = 0; int checksum = ELO_INIT_CHECKSUM; while (pointer < ELO_PACKET_SIZE) { - if (eloGetPacket (buffer, &pointer, &checksum, fd)) { + if (eloGetPacket(buffer, &pointer, &checksum, fd)) { break; } } - if (!eloParsePacket (buffer, realx, realy, button_state)) { + if (!eloParsePacket(buffer, realx, realy, button_state)) { return 0; } *x = *realx; *y = *realy; - eloConvertXY (this, x, y); + eloConvertXY(this, x, y); return 1; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/fbcon/SDL_fbelo.h --- a/src/video/fbcon/SDL_fbelo.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/fbcon/SDL_fbelo.h Mon May 29 04:04:35 2006 +0000 @@ -34,25 +34,25 @@ Convert the raw coordinates from the ELO controller to a screen position. */ -void eloConvertXY (_THIS, int *dx, int *dy); +void eloConvertXY(_THIS, int *dx, int *dy); /* eloInitController(int fd) Initialize the ELO serial touchscreen controller */ -int eloInitController (int fd); +int eloInitController(int fd); /* eloParsePacket extract position and button state from a packet */ -int eloParsePacket (unsigned char *mousebuf, int *dx, int *dy, - int *button_state); +int eloParsePacket(unsigned char *mousebuf, int *dx, int *dy, + int *button_state); /* eloReadPosition read a packet and get the cursor position */ -int eloReadPosition (_THIS, int fd, int *x, int *y, int *button_state, - int *realx, int *realy); +int eloReadPosition(_THIS, int fd, int *x, int *y, int *button_state, + int *realx, int *realy); #endif /* SDL_fbelo_h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/fbcon/SDL_fbevents.c --- a/src/video/fbcon/SDL_fbevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/fbcon/SDL_fbevents.c Mon May 29 04:04:35 2006 +0000 @@ -63,7 +63,7 @@ static Uint16 vga_keymap[NUM_VGAKEYMAPS][NR_KEYS]; static SDLKey keymap[128]; static Uint16 keymap_temp[128]; /* only used at startup */ -static SDL_keysym *TranslateKey (int scancode, SDL_keysym * keysym); +static SDL_keysym *TranslateKey(int scancode, SDL_keysym * keysym); /* Ugh, we have to duplicate the kernel's keysym mapping code... Oh, it's not so bad. :-) @@ -71,7 +71,7 @@ FIXME: Add keyboard LED handling code */ static void -FB_vgainitkeymaps (int fd) +FB_vgainitkeymaps(int fd) { struct kbentry entry; int map, i; @@ -83,21 +83,21 @@ /* Load all the keysym mappings */ for (map = 0; map < NUM_VGAKEYMAPS; ++map) { - SDL_memset (vga_keymap[map], 0, NR_KEYS * sizeof (Uint16)); + SDL_memset(vga_keymap[map], 0, NR_KEYS * sizeof(Uint16)); for (i = 0; i < NR_KEYS; ++i) { entry.kb_table = map; entry.kb_index = i; - if (ioctl (fd, KDGKBENT, &entry) == 0) { + if (ioctl(fd, KDGKBENT, &entry) == 0) { /* fill keytemp. This replaces SDL_fbkeys.h */ if ((map == 0) && (i < 128)) { keymap_temp[i] = entry.kb_value; } /* The "Enter" key is a special case */ if (entry.kb_value == K_ENTER) { - entry.kb_value = K (KT_ASCII, 13); + entry.kb_value = K(KT_ASCII, 13); } /* Handle numpad specially as well */ - if (KTYP (entry.kb_value) == KT_PAD) { + if (KTYP(entry.kb_value) == KT_PAD) { switch (entry.kb_value) { case K_P0: case K_P1: @@ -113,34 +113,34 @@ vga_keymap[map][i] += '0'; break; case K_PPLUS: - vga_keymap[map][i] = K (KT_ASCII, '+'); + vga_keymap[map][i] = K(KT_ASCII, '+'); break; case K_PMINUS: - vga_keymap[map][i] = K (KT_ASCII, '-'); + vga_keymap[map][i] = K(KT_ASCII, '-'); break; case K_PSTAR: - vga_keymap[map][i] = K (KT_ASCII, '*'); + vga_keymap[map][i] = K(KT_ASCII, '*'); break; case K_PSLASH: - vga_keymap[map][i] = K (KT_ASCII, '/'); + vga_keymap[map][i] = K(KT_ASCII, '/'); break; case K_PENTER: - vga_keymap[map][i] = K (KT_ASCII, '\r'); + vga_keymap[map][i] = K(KT_ASCII, '\r'); break; case K_PCOMMA: - vga_keymap[map][i] = K (KT_ASCII, ','); + vga_keymap[map][i] = K(KT_ASCII, ','); break; case K_PDOT: - vga_keymap[map][i] = K (KT_ASCII, '.'); + vga_keymap[map][i] = K(KT_ASCII, '.'); break; default: break; } } /* Do the normal key translation */ - if ((KTYP (entry.kb_value) == KT_LATIN) || - (KTYP (entry.kb_value) == KT_ASCII) || - (KTYP (entry.kb_value) == KT_LETTER)) { + if ((KTYP(entry.kb_value) == KT_LATIN) || + (KTYP(entry.kb_value) == KT_ASCII) || + (KTYP(entry.kb_value) == KT_LETTER)) { vga_keymap[map][i] = entry.kb_value; } } @@ -149,44 +149,44 @@ } int -FB_InGraphicsMode (_THIS) +FB_InGraphicsMode(_THIS) { return ((keyboard_fd >= 0) && (saved_kbd_mode >= 0)); } int -FB_EnterGraphicsMode (_THIS) +FB_EnterGraphicsMode(_THIS) { struct termios keyboard_termios; /* Set medium-raw keyboard mode */ - if ((keyboard_fd >= 0) && !FB_InGraphicsMode (this)) { + if ((keyboard_fd >= 0) && !FB_InGraphicsMode(this)) { /* Switch to the correct virtual terminal */ if (current_vt > 0) { struct vt_stat vtstate; - if (ioctl (keyboard_fd, VT_GETSTATE, &vtstate) == 0) { + if (ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0) { saved_vt = vtstate.v_active; } - if (ioctl (keyboard_fd, VT_ACTIVATE, current_vt) == 0) { - ioctl (keyboard_fd, VT_WAITACTIVE, current_vt); + if (ioctl(keyboard_fd, VT_ACTIVATE, current_vt) == 0) { + ioctl(keyboard_fd, VT_WAITACTIVE, current_vt); } } /* Set the terminal input mode */ - if (tcgetattr (keyboard_fd, &saved_kbd_termios) < 0) { - SDL_SetError ("Unable to get terminal attributes"); + if (tcgetattr(keyboard_fd, &saved_kbd_termios) < 0) { + SDL_SetError("Unable to get terminal attributes"); if (keyboard_fd > 0) { - close (keyboard_fd); + close(keyboard_fd); } keyboard_fd = -1; return (-1); } - if (ioctl (keyboard_fd, KDGKBMODE, &saved_kbd_mode) < 0) { - SDL_SetError ("Unable to get current keyboard mode"); + if (ioctl(keyboard_fd, KDGKBMODE, &saved_kbd_mode) < 0) { + SDL_SetError("Unable to get current keyboard mode"); if (keyboard_fd > 0) { - close (keyboard_fd); + close(keyboard_fd); } keyboard_fd = -1; return (-1); @@ -197,59 +197,59 @@ ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON); keyboard_termios.c_cc[VMIN] = 0; keyboard_termios.c_cc[VTIME] = 0; - if (tcsetattr (keyboard_fd, TCSAFLUSH, &keyboard_termios) < 0) { - FB_CloseKeyboard (this); - SDL_SetError ("Unable to set terminal attributes"); + if (tcsetattr(keyboard_fd, TCSAFLUSH, &keyboard_termios) < 0) { + FB_CloseKeyboard(this); + SDL_SetError("Unable to set terminal attributes"); return (-1); } /* This will fail if we aren't root or this isn't our tty */ - if (ioctl (keyboard_fd, KDSKBMODE, K_MEDIUMRAW) < 0) { - FB_CloseKeyboard (this); - SDL_SetError ("Unable to set keyboard in raw mode"); + if (ioctl(keyboard_fd, KDSKBMODE, K_MEDIUMRAW) < 0) { + FB_CloseKeyboard(this); + SDL_SetError("Unable to set keyboard in raw mode"); return (-1); } - if (ioctl (keyboard_fd, KDSETMODE, KD_GRAPHICS) < 0) { - FB_CloseKeyboard (this); - SDL_SetError ("Unable to set keyboard in graphics mode"); + if (ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS) < 0) { + FB_CloseKeyboard(this); + SDL_SetError("Unable to set keyboard in graphics mode"); return (-1); } /* Prevent switching the virtual terminal */ - ioctl (keyboard_fd, VT_LOCKSWITCH, 1); + ioctl(keyboard_fd, VT_LOCKSWITCH, 1); } return (keyboard_fd); } void -FB_LeaveGraphicsMode (_THIS) +FB_LeaveGraphicsMode(_THIS) { - if (FB_InGraphicsMode (this)) { - ioctl (keyboard_fd, KDSETMODE, KD_TEXT); - ioctl (keyboard_fd, KDSKBMODE, saved_kbd_mode); - tcsetattr (keyboard_fd, TCSAFLUSH, &saved_kbd_termios); + if (FB_InGraphicsMode(this)) { + ioctl(keyboard_fd, KDSETMODE, KD_TEXT); + ioctl(keyboard_fd, KDSKBMODE, saved_kbd_mode); + tcsetattr(keyboard_fd, TCSAFLUSH, &saved_kbd_termios); saved_kbd_mode = -1; /* Head back over to the original virtual terminal */ - ioctl (keyboard_fd, VT_UNLOCKSWITCH, 1); + ioctl(keyboard_fd, VT_UNLOCKSWITCH, 1); if (saved_vt > 0) { - ioctl (keyboard_fd, VT_ACTIVATE, saved_vt); + ioctl(keyboard_fd, VT_ACTIVATE, saved_vt); } } } void -FB_CloseKeyboard (_THIS) +FB_CloseKeyboard(_THIS) { if (keyboard_fd >= 0) { - FB_LeaveGraphicsMode (this); + FB_LeaveGraphicsMode(this); if (keyboard_fd > 0) { - close (keyboard_fd); + close(keyboard_fd); } } keyboard_fd = -1; } int -FB_OpenKeyboard (_THIS) +FB_OpenKeyboard(_THIS) { /* Open only if not already opened */ if (keyboard_fd < 0) { @@ -260,33 +260,33 @@ /* Try to query for a free virtual terminal */ tty0_fd = -1; for (i = 0; tty0[i] && (tty0_fd < 0); ++i) { - tty0_fd = open (tty0[i], O_WRONLY, 0); + tty0_fd = open(tty0[i], O_WRONLY, 0); } if (tty0_fd < 0) { - tty0_fd = dup (0); /* Maybe stdin is a VT? */ + tty0_fd = dup(0); /* Maybe stdin is a VT? */ } - ioctl (tty0_fd, VT_OPENQRY, ¤t_vt); - close (tty0_fd); - if ((geteuid () == 0) && (current_vt > 0)) { + ioctl(tty0_fd, VT_OPENQRY, ¤t_vt); + close(tty0_fd); + if ((geteuid() == 0) && (current_vt > 0)) { for (i = 0; vcs[i] && (keyboard_fd < 0); ++i) { char vtpath[12]; - SDL_snprintf (vtpath, SDL_arraysize (vtpath), vcs[i], - current_vt); - keyboard_fd = open (vtpath, O_RDWR, 0); + SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i], + current_vt); + keyboard_fd = open(vtpath, O_RDWR, 0); #ifdef DEBUG_KEYBOARD - fprintf (stderr, "vtpath = %s, fd = %d\n", - vtpath, keyboard_fd); + fprintf(stderr, "vtpath = %s, fd = %d\n", + vtpath, keyboard_fd); #endif /* DEBUG_KEYBOARD */ /* This needs to be our controlling tty so that the kernel ioctl() calls work */ if (keyboard_fd >= 0) { - tty0_fd = open ("/dev/tty", O_RDWR, 0); + tty0_fd = open("/dev/tty", O_RDWR, 0); if (tty0_fd >= 0) { - ioctl (tty0_fd, TIOCNOTTY, 0); - close (tty0_fd); + ioctl(tty0_fd, TIOCNOTTY, 0); + close(tty0_fd); } } } @@ -295,31 +295,31 @@ /* Last resort, maybe our tty is a usable VT */ struct vt_stat vtstate; - keyboard_fd = open ("/dev/tty", O_RDWR); + keyboard_fd = open("/dev/tty", O_RDWR); - if (ioctl (keyboard_fd, VT_GETSTATE, &vtstate) == 0) { + if (ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0) { current_vt = vtstate.v_active; } else { current_vt = 0; } } #ifdef DEBUG_KEYBOARD - fprintf (stderr, "Current VT: %d\n", current_vt); + fprintf(stderr, "Current VT: %d\n", current_vt); #endif saved_kbd_mode = -1; /* Make sure that our input is a console terminal */ { int dummy; - if (ioctl (keyboard_fd, KDGKBMODE, &dummy) < 0) { - close (keyboard_fd); + if (ioctl(keyboard_fd, KDGKBMODE, &dummy) < 0) { + close(keyboard_fd); keyboard_fd = -1; - SDL_SetError ("Unable to open a console terminal"); + SDL_SetError("Unable to open a console terminal"); } } /* Set up keymap */ - FB_vgainitkeymaps (keyboard_fd); + FB_vgainitkeymaps(keyboard_fd); } return (keyboard_fd); } @@ -338,46 +338,46 @@ } mouse_drv = MOUSE_NONE; void -FB_CloseMouse (_THIS) +FB_CloseMouse(_THIS) { #if SDL_INPUT_TSLIB if (ts_dev != NULL) { - ts_close (ts_dev); + ts_close(ts_dev); ts_dev = NULL; mouse_fd = -1; } #endif /* SDL_INPUT_TSLIB */ if (mouse_fd > 0) { - close (mouse_fd); + close(mouse_fd); } mouse_fd = -1; } /* Returns processes listed in /proc with the desired name */ static int -find_pid (DIR * proc, const char *wanted_name) +find_pid(DIR * proc, const char *wanted_name) { struct dirent *entry; int pid; /* First scan proc for the gpm process */ pid = 0; - while ((pid == 0) && ((entry = readdir (proc)) != NULL)) { - if (isdigit (entry->d_name[0])) { + while ((pid == 0) && ((entry = readdir(proc)) != NULL)) { + if (isdigit(entry->d_name[0])) { FILE *status; char path[PATH_MAX]; char name[PATH_MAX]; - SDL_snprintf (path, SDL_arraysize (path), "/proc/%s/status", - entry->d_name); - status = fopen (path, "r"); + SDL_snprintf(path, SDL_arraysize(path), "/proc/%s/status", + entry->d_name); + status = fopen(path, "r"); if (status) { name[0] = '\0'; - fscanf (status, "Name: %s", name); - if (SDL_strcmp (name, wanted_name) == 0) { - pid = SDL_atoi (entry->d_name); + fscanf(status, "Name: %s", name); + if (SDL_strcmp(name, wanted_name) == 0) { + pid = SDL_atoi(entry->d_name); } - fclose (status); + fclose(status); } } } @@ -386,7 +386,7 @@ /* Returns true if /dev/gpmdata is being written to by gpm */ static int -gpm_available (char *proto, size_t protolen) +gpm_available(char *proto, size_t protolen) { int available; DIR *proc; @@ -397,67 +397,66 @@ /* Don't bother looking if the fifo isn't there */ #ifdef DEBUG_MOUSE - fprintf (stderr, "testing gpm\n"); + fprintf(stderr, "testing gpm\n"); #endif - if (access (GPM_NODE_FIFO, F_OK) < 0) { + if (access(GPM_NODE_FIFO, F_OK) < 0) { return (0); } available = 0; - proc = opendir ("/proc"); + proc = opendir("/proc"); if (proc) { char raw_proto[10] = { '\0' }; char repeat_proto[10] = { '\0' }; - while (!available && (pid = find_pid (proc, "gpm")) > 0) { - SDL_snprintf (path, SDL_arraysize (path), "/proc/%d/cmdline", - pid); - cmdline = open (path, O_RDONLY, 0); + while (!available && (pid = find_pid(proc, "gpm")) > 0) { + SDL_snprintf(path, SDL_arraysize(path), "/proc/%d/cmdline", pid); + cmdline = open(path, O_RDONLY, 0); if (cmdline >= 0) { - len = read (cmdline, args, sizeof (args)); + len = read(cmdline, args, sizeof(args)); arg = args; while (len > 0) { - arglen = SDL_strlen (arg) + 1; + arglen = SDL_strlen(arg) + 1; #ifdef DEBUG_MOUSE - fprintf (stderr, "gpm arg %s len %d\n", arg, arglen); + fprintf(stderr, "gpm arg %s len %d\n", arg, arglen); #endif - if (SDL_strcmp (arg, "-t") == 0) { + if (SDL_strcmp(arg, "-t") == 0) { /* protocol string, keep it for later */ char *t, *s; t = arg + arglen; - s = SDL_strchr (t, ' '); + s = SDL_strchr(t, ' '); if (s) *s = 0; - SDL_strlcpy (raw_proto, t, SDL_arraysize (raw_proto)); + SDL_strlcpy(raw_proto, t, SDL_arraysize(raw_proto)); if (s) *s = ' '; } - if (SDL_strncmp (arg, "-R", 2) == 0) { + if (SDL_strncmp(arg, "-R", 2) == 0) { char *t, *s; available = 1; t = arg + 2; - s = SDL_strchr (t, ' '); + s = SDL_strchr(t, ' '); if (s) *s = 0; - SDL_strlcpy (repeat_proto, t, - SDL_arraysize (repeat_proto)); + SDL_strlcpy(repeat_proto, t, + SDL_arraysize(repeat_proto)); if (s) *s = ' '; } len -= arglen; arg += arglen; } - close (cmdline); + close(cmdline); } } - closedir (proc); + closedir(proc); if (available) { - if (SDL_strcmp (repeat_proto, "raw") == 0) { - SDL_strlcpy (proto, raw_proto, protolen); + if (SDL_strcmp(repeat_proto, "raw") == 0) { + SDL_strlcpy(proto, raw_proto, protolen); } else if (*repeat_proto) { - SDL_strlcpy (proto, repeat_proto, protolen); + SDL_strlcpy(proto, repeat_proto, protolen); } else { - SDL_strlcpy (proto, "msc", protolen); + SDL_strlcpy(proto, "msc", protolen); } } } @@ -471,7 +470,7 @@ * device to see which mode it's actually in. */ static int -set_imps2_mode (int fd) +set_imps2_mode(int fd) { /* If you wanted to control the mouse mode (and we do :) ) ... Set IMPS/2 protocol: @@ -485,7 +484,7 @@ struct timeval tv; int retval = 0; - if (write (fd, &set_imps2, sizeof (set_imps2)) == sizeof (set_imps2)) { + if (write(fd, &set_imps2, sizeof(set_imps2)) == sizeof(set_imps2)) { /* Don't reset it, that'll clear IMPS/2 mode on some mice if (write(fd, &reset, sizeof (reset)) == sizeof (reset) ) { retval = 1; @@ -494,13 +493,13 @@ } /* Get rid of any chatter from the above */ - FD_ZERO (&fdset); - FD_SET (fd, &fdset); + FD_ZERO(&fdset); + FD_SET(fd, &fdset); tv.tv_sec = 0; tv.tv_usec = 0; - while (select (fd + 1, &fdset, 0, 0, &tv) > 0) { + while (select(fd + 1, &fdset, 0, 0, &tv) > 0) { char temp[32]; - read (fd, temp, sizeof (temp)); + read(fd, temp, sizeof(temp)); } return retval; @@ -509,13 +508,13 @@ /* Returns true if the mouse uses the IMPS/2 protocol */ static int -detect_imps2 (int fd) +detect_imps2(int fd) { int imps2; imps2 = 0; - if (SDL_getenv ("SDL_MOUSEDEV_IMPS2")) { + if (SDL_getenv("SDL_MOUSEDEV_IMPS2")) { imps2 = 1; } if (!imps2) { @@ -524,35 +523,35 @@ struct timeval tv; /* Get rid of any mouse motion noise */ - FD_ZERO (&fdset); - FD_SET (fd, &fdset); + FD_ZERO(&fdset); + FD_SET(fd, &fdset); tv.tv_sec = 0; tv.tv_usec = 0; - while (select (fd + 1, &fdset, 0, 0, &tv) > 0) { + while (select(fd + 1, &fdset, 0, 0, &tv) > 0) { char temp[32]; - read (fd, temp, sizeof (temp)); + read(fd, temp, sizeof(temp)); } /* Query for the type of mouse protocol */ - if (write (fd, &query_ps2, sizeof (query_ps2)) == sizeof (query_ps2)) { + if (write(fd, &query_ps2, sizeof(query_ps2)) == sizeof(query_ps2)) { Uint8 ch = 0; /* Get the mouse protocol response */ do { - FD_ZERO (&fdset); - FD_SET (fd, &fdset); + FD_ZERO(&fdset); + FD_SET(fd, &fdset); tv.tv_sec = 1; tv.tv_usec = 0; - if (select (fd + 1, &fdset, 0, 0, &tv) < 1) { + if (select(fd + 1, &fdset, 0, 0, &tv) < 1) { break; } } - while ((read (fd, &ch, sizeof (ch)) == sizeof (ch)) && + while ((read(fd, &ch, sizeof(ch)) == sizeof(ch)) && ((ch == 0xFA) || (ch == 0xAA))); /* Experimental values (Logitech wheelmouse) */ #ifdef DEBUG_MOUSE - fprintf (stderr, "Last mouse mode: 0x%x\n", ch); + fprintf(stderr, "Last mouse mode: 0x%x\n", ch); #endif if ((ch == 3) || (ch == 4)) { imps2 = 1; @@ -563,28 +562,28 @@ } int -FB_OpenMouse (_THIS) +FB_OpenMouse(_THIS) { int i; const char *mousedev; const char *mousedrv; - mousedrv = SDL_getenv ("SDL_MOUSEDRV"); - mousedev = SDL_getenv ("SDL_MOUSEDEV"); + mousedrv = SDL_getenv("SDL_MOUSEDRV"); + mousedev = SDL_getenv("SDL_MOUSEDEV"); mouse_fd = -1; #if SDL_INPUT_TSLIB - if (mousedrv && (SDL_strcmp (mousedrv, "TSLIB") == 0)) { + if (mousedrv && (SDL_strcmp(mousedrv, "TSLIB") == 0)) { if (mousedev == NULL) - mousedev = SDL_getenv ("TSLIB_TSDEVICE"); + mousedev = SDL_getenv("TSLIB_TSDEVICE"); if (mousedev != NULL) { - ts_dev = ts_open (mousedev, 1); - if ((ts_dev != NULL) && (ts_config (ts_dev) >= 0)) { + ts_dev = ts_open(mousedev, 1); + if ((ts_dev != NULL) && (ts_config(ts_dev) >= 0)) { #ifdef DEBUG_MOUSE - fprintf (stderr, "Using tslib touchscreen\n"); + fprintf(stderr, "Using tslib touchscreen\n"); #endif mouse_drv = MOUSE_TSLIB; - mouse_fd = ts_fd (ts_dev); + mouse_fd = ts_fd(ts_dev); return mouse_fd; } } @@ -595,12 +594,12 @@ /* ELO TOUCHSCREEN SUPPORT */ - if (mousedrv && (SDL_strcmp (mousedrv, "ELO") == 0)) { - mouse_fd = open (mousedev, O_RDWR); + if (mousedrv && (SDL_strcmp(mousedrv, "ELO") == 0)) { + mouse_fd = open(mousedev, O_RDWR); if (mouse_fd >= 0) { - if (eloInitController (mouse_fd)) { + if (eloInitController(mouse_fd)) { #ifdef DEBUG_MOUSE - fprintf (stderr, "Using ELO touchscreen\n"); + fprintf(stderr, "Using ELO touchscreen\n"); #endif mouse_drv = MOUSE_ELO; } @@ -622,56 +621,56 @@ /* First try to use GPM in repeater mode */ if (mouse_fd < 0) { char proto[10]; - if (gpm_available (proto, SDL_arraysize (proto))) { - mouse_fd = open (GPM_NODE_FIFO, O_RDONLY, 0); + if (gpm_available(proto, SDL_arraysize(proto))) { + mouse_fd = open(GPM_NODE_FIFO, O_RDONLY, 0); if (mouse_fd >= 0) { - if (SDL_strcmp (proto, "msc") == 0) { + if (SDL_strcmp(proto, "msc") == 0) { mouse_drv = MOUSE_MSC; - } else if (SDL_strcmp (proto, "ps2") == 0) { + } else if (SDL_strcmp(proto, "ps2") == 0) { mouse_drv = MOUSE_PS2; - } else if (SDL_strcmp (proto, "imps2") == 0) { + } else if (SDL_strcmp(proto, "imps2") == 0) { mouse_drv = MOUSE_IMPS2; - } else if (SDL_strcmp (proto, "ms") == 0 || - SDL_strcmp (proto, "bare") == 0) { + } else if (SDL_strcmp(proto, "ms") == 0 || + SDL_strcmp(proto, "bare") == 0) { mouse_drv = MOUSE_MS; - } else if (SDL_strcmp (proto, "bm") == 0) { + } else if (SDL_strcmp(proto, "bm") == 0) { mouse_drv = MOUSE_BM; } else { /* Unknown protocol... */ #ifdef DEBUG_MOUSE - fprintf (stderr, - "GPM mouse using unknown protocol = %s\n", - proto); + fprintf(stderr, + "GPM mouse using unknown protocol = %s\n", + proto); #endif - close (mouse_fd); + close(mouse_fd); mouse_fd = -1; } } #ifdef DEBUG_MOUSE if (mouse_fd >= 0) { - fprintf (stderr, - "Using GPM mouse, protocol = %s\n", proto); + fprintf(stderr, + "Using GPM mouse, protocol = %s\n", proto); } #endif /* DEBUG_MOUSE */ } } /* Now try to use a modern PS/2 mouse */ for (i = 0; (mouse_fd < 0) && ps2mice[i]; ++i) { - mouse_fd = open (ps2mice[i], O_RDWR, 0); + mouse_fd = open(ps2mice[i], O_RDWR, 0); if (mouse_fd < 0) { - mouse_fd = open (ps2mice[i], O_RDONLY, 0); + mouse_fd = open(ps2mice[i], O_RDONLY, 0); } if (mouse_fd >= 0) { /* rcg06112001 Attempt to set IMPS/2 mode */ - set_imps2_mode (mouse_fd); - if (detect_imps2 (mouse_fd)) { + set_imps2_mode(mouse_fd); + if (detect_imps2(mouse_fd)) { #ifdef DEBUG_MOUSE - fprintf (stderr, "Using IMPS2 mouse\n"); + fprintf(stderr, "Using IMPS2 mouse\n"); #endif mouse_drv = MOUSE_IMPS2; } else { #ifdef DEBUG_MOUSE - fprintf (stderr, "Using PS2 mouse\n"); + fprintf(stderr, "Using PS2 mouse\n"); #endif mouse_drv = MOUSE_PS2; } @@ -679,10 +678,10 @@ } /* Next try to use a PPC ADB port mouse */ if (mouse_fd < 0) { - mouse_fd = open ("/dev/adbmouse", O_RDONLY, 0); + mouse_fd = open("/dev/adbmouse", O_RDONLY, 0); if (mouse_fd >= 0) { #ifdef DEBUG_MOUSE - fprintf (stderr, "Using ADB mouse\n"); + fprintf(stderr, "Using ADB mouse\n"); #endif mouse_drv = MOUSE_BM; } @@ -693,12 +692,12 @@ if (mousedev == NULL) { mousedev = "/dev/mouse"; } - mouse_fd = open (mousedev, O_RDONLY, 0); + mouse_fd = open(mousedev, O_RDONLY, 0); if (mouse_fd >= 0) { struct termios mouse_termios; /* Set the sampling speed to 1200 baud */ - tcgetattr (mouse_fd, &mouse_termios); + tcgetattr(mouse_fd, &mouse_termios); mouse_termios.c_iflag = IGNBRK | IGNPAR; mouse_termios.c_oflag = 0; mouse_termios.c_lflag = 0; @@ -708,18 +707,16 @@ mouse_termios.c_cflag = CREAD | CLOCAL | HUPCL; mouse_termios.c_cflag |= CS8; mouse_termios.c_cflag |= B1200; - tcsetattr (mouse_fd, TCSAFLUSH, &mouse_termios); - if (mousedrv && (SDL_strcmp (mousedrv, "PS2") == 0)) { + tcsetattr(mouse_fd, TCSAFLUSH, &mouse_termios); + if (mousedrv && (SDL_strcmp(mousedrv, "PS2") == 0)) { #ifdef DEBUG_MOUSE - fprintf (stderr, - "Using (user specified) PS2 mouse on %s\n", - mousedev); + fprintf(stderr, + "Using (user specified) PS2 mouse on %s\n", mousedev); #endif mouse_drv = MOUSE_PS2; } else { #ifdef DEBUG_MOUSE - fprintf (stderr, "Using (default) MS mouse on %s\n", - mousedev); + fprintf(stderr, "Using (default) MS mouse on %s\n", mousedev); #endif mouse_drv = MOUSE_MS; } @@ -734,7 +731,7 @@ static int posted = 0; void -FB_vgamousecallback (int button, int relative, int dx, int dy) +FB_vgamousecallback(int button, int relative, int dx, int dy) { int button_1, button_3; int button_state; @@ -743,7 +740,7 @@ Uint8 state; if (dx || dy) { - posted += SDL_PrivateMouseMotion (0, relative, dx, dy); + posted += SDL_PrivateMouseMotion(0, relative, dx, dy); } /* Swap button 1 and 3 */ @@ -753,7 +750,7 @@ button |= (button_1 | button_3); /* See what changed */ - button_state = SDL_GetMouseState (NULL, NULL); + button_state = SDL_GetMouseState(NULL, NULL); state_changed = button_state ^ button; for (i = 0; i < 8; ++i) { if (state_changed & (1 << i)) { @@ -762,7 +759,7 @@ } else { state = SDL_RELEASED; } - posted += SDL_PrivateMouseButton (state, i + 1, 0, 0); + posted += SDL_PrivateMouseButton(state, i + 1, 0, 0); } } } @@ -770,15 +767,15 @@ /* Handle input from tslib */ #if SDL_INPUT_TSLIB static void -handle_tslib (_THIS) +handle_tslib(_THIS) { struct ts_sample sample; int button; - while (ts_read (ts_dev, &sample, 1) > 0) { + while (ts_read(ts_dev, &sample, 1) > 0) { button = (sample.pressure > 0) ? 1 : 0; button <<= 2; /* must report it as button 3 */ - FB_vgamousecallback (button, 0, sample.x, sample.y); + FB_vgamousecallback(button, 0, sample.x, sample.y); } return; } @@ -788,7 +785,7 @@ Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.) */ static void -handle_mouse (_THIS) +handle_mouse(_THIS) { static int start = 0; static unsigned char mousebuf[BUFSIZ]; @@ -804,7 +801,7 @@ switch (mouse_drv) { case MOUSE_NONE: /* Ack! */ - read (mouse_fd, mousebuf, BUFSIZ); + read(mouse_fd, mousebuf, BUFSIZ); return; case MOUSE_MSC: packetsize = 5; @@ -822,12 +819,12 @@ if (eloReadPosition (this, mouse_fd, &dx, &dy, &button, &realx, &realy)) { button = (button & 0x01) << 2; - FB_vgamousecallback (button, 0, dx, dy); + FB_vgamousecallback(button, 0, dx, dy); } return; /* nothing left to do */ case MOUSE_TSLIB: #if SDL_INPUT_TSLIB - handle_tslib (this); + handle_tslib(this); #endif return; /* nothing left to do */ default: @@ -842,13 +839,13 @@ } /* Read as many packets as possible */ - nread = read (mouse_fd, &mousebuf[start], BUFSIZ - start); + nread = read(mouse_fd, &mousebuf[start], BUFSIZ - start); if (nread < 0) { return; } nread += start; #ifdef DEBUG_MOUSE - fprintf (stderr, "Read %d bytes from mouse, start = %d\n", nread, start); + fprintf(stderr, "Read %d bytes from mouse, start = %d\n", nread, start); #endif for (i = 0; i < (nread - (packetsize - 1)); i += packetsize) { switch (mouse_drv) { @@ -900,10 +897,10 @@ case 0x02: /* DX = -1 */ break; case 0x0F: /* DY = +1 (map button 4) */ - FB_vgamousecallback (button | (1 << 3), 1, 0, 0); + FB_vgamousecallback(button | (1 << 3), 1, 0, 0); break; case 0x01: /* DY = -1 (map button 5) */ - FB_vgamousecallback (button | (1 << 4), 1, 0, 0); + FB_vgamousecallback(button | (1 << 4), 1, 0, 0); break; } break; @@ -940,10 +937,10 @@ dy = 0; break; } - FB_vgamousecallback (button, relative, dx, dy); + FB_vgamousecallback(button, relative, dx, dy); } if (i < nread) { - SDL_memcpy (mousebuf, &mousebuf[i], (nread - i)); + SDL_memcpy(mousebuf, &mousebuf[i], (nread - i)); start = (nread - i); } else { start = 0; @@ -953,76 +950,76 @@ /* Handle switching to another VC, returns when our VC is back */ static void -switch_vt_prep (_THIS) +switch_vt_prep(_THIS) { SDL_Surface *screen = SDL_VideoSurface; - SDL_PrivateAppActive (0, - (SDL_APPACTIVE | SDL_APPINPUTFOCUS | - SDL_APPMOUSEFOCUS)); + SDL_PrivateAppActive(0, + (SDL_APPACTIVE | SDL_APPINPUTFOCUS | + SDL_APPMOUSEFOCUS)); /* Save the contents of the screen, and go to text mode */ - wait_idle (this); + wait_idle(this); screen_arealen = ((screen->h + (2 * this->offset_y)) * screen->pitch); - screen_contents = (Uint8 *) SDL_malloc (screen_arealen); + screen_contents = (Uint8 *) SDL_malloc(screen_arealen); if (screen_contents) { - SDL_memcpy (screen_contents, screen->pixels, screen_arealen); + SDL_memcpy(screen_contents, screen->pixels, screen_arealen); } - FB_SavePaletteTo (this, 256, screen_palette); - ioctl (console_fd, FBIOGET_VSCREENINFO, &screen_vinfo); - ioctl (keyboard_fd, KDSETMODE, KD_TEXT); - ioctl (keyboard_fd, VT_UNLOCKSWITCH, 1); + FB_SavePaletteTo(this, 256, screen_palette); + ioctl(console_fd, FBIOGET_VSCREENINFO, &screen_vinfo); + ioctl(keyboard_fd, KDSETMODE, KD_TEXT); + ioctl(keyboard_fd, VT_UNLOCKSWITCH, 1); } static void -switch_vt_done (_THIS) +switch_vt_done(_THIS) { SDL_Surface *screen = SDL_VideoSurface; /* Restore graphics mode and the contents of the screen */ - ioctl (keyboard_fd, VT_LOCKSWITCH, 1); - ioctl (keyboard_fd, KDSETMODE, KD_GRAPHICS); - ioctl (console_fd, FBIOPUT_VSCREENINFO, &screen_vinfo); - FB_RestorePaletteFrom (this, 256, screen_palette); + ioctl(keyboard_fd, VT_LOCKSWITCH, 1); + ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS); + ioctl(console_fd, FBIOPUT_VSCREENINFO, &screen_vinfo); + FB_RestorePaletteFrom(this, 256, screen_palette); if (screen_contents) { - SDL_memcpy (screen->pixels, screen_contents, screen_arealen); - SDL_free (screen_contents); + SDL_memcpy(screen->pixels, screen_contents, screen_arealen); + SDL_free(screen_contents); screen_contents = NULL; } /* Get updates to the shadow surface while switched away */ if (SDL_ShadowSurface) { - SDL_UpdateRect (SDL_ShadowSurface, 0, 0, 0, 0); + SDL_UpdateRect(SDL_ShadowSurface, 0, 0, 0, 0); } - SDL_PrivateAppActive (1, - (SDL_APPACTIVE | SDL_APPINPUTFOCUS | - SDL_APPMOUSEFOCUS)); + SDL_PrivateAppActive(1, + (SDL_APPACTIVE | SDL_APPINPUTFOCUS | + SDL_APPMOUSEFOCUS)); } static void -switch_vt (_THIS, unsigned short which) +switch_vt(_THIS, unsigned short which) { struct vt_stat vtstate; /* Figure out whether or not we're switching to a new console */ - if ((ioctl (keyboard_fd, VT_GETSTATE, &vtstate) < 0) || + if ((ioctl(keyboard_fd, VT_GETSTATE, &vtstate) < 0) || (which == vtstate.v_active)) { return; } /* New console, switch to it */ - SDL_mutexP (hw_lock); - switch_vt_prep (this); - if (ioctl (keyboard_fd, VT_ACTIVATE, which) == 0) { - ioctl (keyboard_fd, VT_WAITACTIVE, which); + SDL_mutexP(hw_lock); + switch_vt_prep(this); + if (ioctl(keyboard_fd, VT_ACTIVATE, which) == 0) { + ioctl(keyboard_fd, VT_WAITACTIVE, which); switched_away = 1; } else { - switch_vt_done (this); + switch_vt_done(this); } - SDL_mutexV (hw_lock); + SDL_mutexV(hw_lock); } static void -handle_keyboard (_THIS) +handle_keyboard(_THIS) { unsigned char keybuf[BUFSIZ]; int i, nread; @@ -1030,7 +1027,7 @@ int scancode; SDL_keysym keysym; - nread = read (keyboard_fd, keybuf, BUFSIZ); + nread = read(keyboard_fd, keybuf, BUFSIZ); for (i = 0; i < nread; ++i) { scancode = keybuf[i] & 0x7F; if (keybuf[i] & 0x80) { @@ -1038,7 +1035,7 @@ } else { pressed = SDL_PRESSED; } - TranslateKey (scancode, &keysym); + TranslateKey(scancode, &keysym); /* Handle Ctrl-Alt-FN for vt switch */ switch (keysym.sym) { case SDLK_F1: @@ -1053,23 +1050,23 @@ case SDLK_F10: case SDLK_F11: case SDLK_F12: - if ((SDL_GetModState () & KMOD_CTRL) && - (SDL_GetModState () & KMOD_ALT)) { + if ((SDL_GetModState() & KMOD_CTRL) && + (SDL_GetModState() & KMOD_ALT)) { if (pressed) { - switch_vt (this, (keysym.sym - SDLK_F1) + 1); + switch_vt(this, (keysym.sym - SDLK_F1) + 1); } break; } /* Fall through to normal processing */ default: - posted += SDL_PrivateKeyboard (pressed, &keysym); + posted += SDL_PrivateKeyboard(pressed, &keysym); break; } } } void -FB_PumpEvents (_THIS) +FB_PumpEvents(_THIS) { fd_set fdset; int max_fd; @@ -1079,40 +1076,40 @@ if (switched_away) { struct vt_stat vtstate; - SDL_mutexP (hw_lock); - if ((ioctl (keyboard_fd, VT_GETSTATE, &vtstate) == 0) && + SDL_mutexP(hw_lock); + if ((ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0) && vtstate.v_active == current_vt) { switched_away = 0; - switch_vt_done (this); + switch_vt_done(this); } - SDL_mutexV (hw_lock); + SDL_mutexV(hw_lock); } posted = 0; - FD_ZERO (&fdset); + FD_ZERO(&fdset); max_fd = 0; if (keyboard_fd >= 0) { - FD_SET (keyboard_fd, &fdset); + FD_SET(keyboard_fd, &fdset); if (max_fd < keyboard_fd) { max_fd = keyboard_fd; } } if (mouse_fd >= 0) { - FD_SET (mouse_fd, &fdset); + FD_SET(mouse_fd, &fdset); if (max_fd < mouse_fd) { max_fd = mouse_fd; } } - if (select (max_fd + 1, &fdset, NULL, NULL, &zero) > 0) { + if (select(max_fd + 1, &fdset, NULL, NULL, &zero) > 0) { if (keyboard_fd >= 0) { - if (FD_ISSET (keyboard_fd, &fdset)) { - handle_keyboard (this); + if (FD_ISSET(keyboard_fd, &fdset)) { + handle_keyboard(this); } } if (mouse_fd >= 0) { - if (FD_ISSET (mouse_fd, &fdset)) { - handle_mouse (this); + if (FD_ISSET(mouse_fd, &fdset)) { + handle_mouse(this); } } } @@ -1121,14 +1118,14 @@ } void -FB_InitOSKeymap (_THIS) +FB_InitOSKeymap(_THIS) { int i; /* Initialize the Linux key translation table */ /* First get the ascii keys and others not well handled */ - for (i = 0; i < SDL_arraysize (keymap); ++i) { + for (i = 0; i < SDL_arraysize(keymap); ++i) { switch (i) { /* These aren't handled by the x86 kernel keymapping (?) */ case SCANCODE_PRINTSCREEN: @@ -1169,11 +1166,11 @@ break; /* this should take care of all standard ascii keys */ default: - keymap[i] = KVAL (vga_keymap[0][i]); + keymap[i] = KVAL(vga_keymap[0][i]); break; } } - for (i = 0; i < SDL_arraysize (keymap); ++i) { + for (i = 0; i < SDL_arraysize(keymap); ++i) { switch (keymap_temp[i]) { case K_F1: keymap[i] = SDLK_F1; @@ -1348,7 +1345,7 @@ } static SDL_keysym * -TranslateKey (int scancode, SDL_keysym * keysym) +TranslateKey(int scancode, SDL_keysym * keysym) { /* Set the keysym information */ keysym->scancode = scancode; @@ -1361,7 +1358,7 @@ int map; SDLMod modstate; - modstate = SDL_GetModState (); + modstate = SDL_GetModState(); map = 0; if (modstate & KMOD_SHIFT) { map |= (1 << KG_SHIFT); @@ -1375,17 +1372,17 @@ if (modstate & KMOD_RALT) { map |= (1 << KG_ALTGR); } - if (KTYP (vga_keymap[map][scancode]) == KT_LETTER) { + if (KTYP(vga_keymap[map][scancode]) == KT_LETTER) { if (modstate & KMOD_CAPS) { map ^= (1 << KG_SHIFT); } } - if (KTYP (vga_keymap[map][scancode]) == KT_PAD) { + if (KTYP(vga_keymap[map][scancode]) == KT_PAD) { if (modstate & KMOD_NUM) { - keysym->unicode = KVAL (vga_keymap[map][scancode]); + keysym->unicode = KVAL(vga_keymap[map][scancode]); } } else { - keysym->unicode = KVAL (vga_keymap[map][scancode]); + keysym->unicode = KVAL(vga_keymap[map][scancode]); } } return (keysym); diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/fbcon/SDL_fbevents_c.h --- a/src/video/fbcon/SDL_fbevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/fbcon/SDL_fbevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -26,14 +26,14 @@ /* Variables and functions exported by SDL_sysevents.c to other parts of the native video subsystem (SDL_sysvideo.c) */ -extern int FB_OpenKeyboard (_THIS); -extern void FB_CloseKeyboard (_THIS); -extern int FB_OpenMouse (_THIS); -extern void FB_CloseMouse (_THIS); -extern int FB_EnterGraphicsMode (_THIS); -extern int FB_InGraphicsMode (_THIS); -extern void FB_LeaveGraphicsMode (_THIS); +extern int FB_OpenKeyboard(_THIS); +extern void FB_CloseKeyboard(_THIS); +extern int FB_OpenMouse(_THIS); +extern void FB_CloseMouse(_THIS); +extern int FB_EnterGraphicsMode(_THIS); +extern int FB_InGraphicsMode(_THIS); +extern void FB_LeaveGraphicsMode(_THIS); -extern void FB_InitOSKeymap (_THIS); -extern void FB_PumpEvents (_THIS); +extern void FB_InitOSKeymap(_THIS); +extern void FB_PumpEvents(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/fbcon/SDL_fbmatrox.c --- a/src/video/fbcon/SDL_fbmatrox.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/fbcon/SDL_fbmatrox.c Mon May 29 04:04:35 2006 +0000 @@ -29,27 +29,27 @@ /* Wait for vertical retrace - taken from the XFree86 Matrox driver */ static void -WaitVBL (_THIS) +WaitVBL(_THIS) { int count; /* find start of retrace */ - mga_waitidle (); - while ((mga_in8 (0x1FDA) & 0x08)); - while (!(mga_in8 (0x1FDA) & 0x08)); + mga_waitidle(); + while ((mga_in8(0x1FDA) & 0x08)); + while (!(mga_in8(0x1FDA) & 0x08)); /* wait until we're past the start */ - count = mga_in32 (0x1E20) + 2; - while (mga_in32 (0x1E20) < count); + count = mga_in32(0x1E20) + 2; + while (mga_in32(0x1E20) < count); } static void -WaitIdle (_THIS) +WaitIdle(_THIS) { - mga_waitidle (); + mga_waitidle(); } /* Sets video mem colorkey and accelerated blit function */ static int -SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key) +SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key) { return (0); } @@ -57,14 +57,14 @@ /* Sets per surface hardware alpha value */ #if 0 static int -SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 value) +SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 value) { return (0); } #endif static int -FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) +FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) { int dstX, dstY; Uint32 fxbndry; @@ -76,7 +76,7 @@ return -2; /* no hardware access */ } if (dst == this->screen) { - SDL_mutexP (hw_lock); + SDL_mutexP(hw_lock); } switch (dst->format->BytesPerPixel) { @@ -88,7 +88,7 @@ } /* Set up the X/Y base coordinates */ - FB_dst_to_xy (this, dst, &dstX, &dstY); + FB_dst_to_xy(this, dst, &dstX, &dstY); /* Adjust for the current rectangle */ dstX += rect->x; @@ -105,23 +105,23 @@ MGADWG_ARZERO | MGADWG_SGNZERO | MGADWG_SHIFTZERO; /* Execute the operations! */ - mga_wait (5); - mga_out32 (MGAREG_DWGCTL, fillop | MGADWG_REPLACE); - mga_out32 (MGAREG_FCOL, color); - mga_out32 (MGAREG_FXBNDRY, fxbndry); - mga_out32 (MGAREG_YDSTLEN + MGAREG_EXEC, ydstlen); + mga_wait(5); + mga_out32(MGAREG_DWGCTL, fillop | MGADWG_REPLACE); + mga_out32(MGAREG_FCOL, color); + mga_out32(MGAREG_FXBNDRY, fxbndry); + mga_out32(MGAREG_YDSTLEN + MGAREG_EXEC, ydstlen); - FB_AddBusySurface (dst); + FB_AddBusySurface(dst); if (dst == this->screen) { - SDL_mutexV (hw_lock); + SDL_mutexV(hw_lock); } return (0); } static int -HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { SDL_VideoDevice *this = current_video; int pitch, w, h; @@ -134,7 +134,7 @@ /* FIXME: For now, only blit to display surface */ if (dst->pitch != SDL_VideoSurface->pitch) { - return (src->map->sw_blit (src, srcrect, dst, dstrect)); + return (src->map->sw_blit(src, srcrect, dst, dstrect)); } /* Don't blit to the display surface when switched away */ @@ -142,14 +142,14 @@ return -2; /* no hardware access */ } if (dst == this->screen) { - SDL_mutexP (hw_lock); + SDL_mutexP(hw_lock); } /* Calculate source and destination base coordinates (in pixels) */ w = dstrect->w; h = dstrect->h; - FB_dst_to_xy (this, src, &srcX, &srcY); - FB_dst_to_xy (this, dst, &dstX, &dstY); + FB_dst_to_xy(this, src, &srcX, &srcY); + FB_dst_to_xy(this, dst, &dstX, &dstY); /* Adjust for the current blit rectangles */ srcX += srcrect->x; @@ -197,33 +197,33 @@ colorkey |= (colorkey << 16); break; } - mga_wait (2); - mga_out32 (MGAREG_FCOL, colorkey); - mga_out32 (MGAREG_BCOL, 0xFFFFFFFF); + mga_wait(2); + mga_out32(MGAREG_FCOL, colorkey); + mga_out32(MGAREG_BCOL, 0xFFFFFFFF); } else { blitop = MGADWG_BFCOL | MGADWG_BITBLT | MGADWG_SHIFTZERO | MGADWG_RSTR | (0x0C << 16); } - mga_wait (7); - mga_out32 (MGAREG_SGN, sign); - mga_out32 (MGAREG_AR3, start); - mga_out32 (MGAREG_AR0, stop); - mga_out32 (MGAREG_AR5, skip); - mga_out32 (MGAREG_FXBNDRY, (dstX | ((dstX + w - 1) << 16))); - mga_out32 (MGAREG_YDSTLEN, (dstY << 16) | h); - mga_out32 (MGAREG_DWGCTL + MGAREG_EXEC, blitop); + mga_wait(7); + mga_out32(MGAREG_SGN, sign); + mga_out32(MGAREG_AR3, start); + mga_out32(MGAREG_AR0, stop); + mga_out32(MGAREG_AR5, skip); + mga_out32(MGAREG_FXBNDRY, (dstX | ((dstX + w - 1) << 16))); + mga_out32(MGAREG_YDSTLEN, (dstY << 16) | h); + mga_out32(MGAREG_DWGCTL + MGAREG_EXEC, blitop); - FB_AddBusySurface (src); - FB_AddBusySurface (dst); + FB_AddBusySurface(src); + FB_AddBusySurface(dst); if (dst == this->screen) { - SDL_mutexV (hw_lock); + SDL_mutexV(hw_lock); } return (0); } static int -CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst) +CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst) { int accelerated; @@ -251,7 +251,7 @@ } void -FB_MatroxAccel (_THIS, __u32 card) +FB_MatroxAccel(_THIS, __u32 card) { /* We have hardware accelerated surface functions */ this->CheckHWBlit = CheckHWBlit; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/fbcon/SDL_fbmatrox.h --- a/src/video/fbcon/SDL_fbmatrox.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/fbcon/SDL_fbmatrox.h Mon May 29 04:04:35 2006 +0000 @@ -26,5 +26,5 @@ #include "SDL_fbvideo.h" /* Set up the driver for Matrox acceleration */ -extern void FB_MatroxAccel (_THIS, __u32 card); +extern void FB_MatroxAccel(_THIS, __u32 card); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/fbcon/SDL_fbriva.c --- a/src/video/fbcon/SDL_fbriva.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/fbcon/SDL_fbriva.c Mon May 29 04:04:35 2006 +0000 @@ -33,7 +33,7 @@ /* Wait for vertical retrace */ static void -WaitVBL (_THIS) +WaitVBL(_THIS) { volatile Uint8 *port = (Uint8 *) (mapped_io + PCIO_OFFSET + 0x3DA); @@ -41,14 +41,14 @@ while (!(*port & 0x08)); } static void -NV3WaitIdle (_THIS) +NV3WaitIdle(_THIS) { RivaRop *Rop = (RivaRop *) (mapped_io + ROP_OFFSET); while ((Rop->FifoFree < FifoEmptyCount) || (*(mapped_io + PGRAPH_OFFSET + 0x000006B0) & 0x01)); } static void -NV4WaitIdle (_THIS) +NV4WaitIdle(_THIS) { RivaRop *Rop = (RivaRop *) (mapped_io + ROP_OFFSET); while ((Rop->FifoFree < FifoEmptyCount) || @@ -58,21 +58,21 @@ #if 0 /* Not yet implemented? */ /* Sets video mem colorkey and accelerated blit function */ static int -SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key) +SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key) { return (0); } /* Sets per surface hardware alpha value */ static int -SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 value) +SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 value) { return (0); } #endif /* Not yet implemented */ static int -FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) +FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) { int dstX, dstY; int dstW, dstH; @@ -83,36 +83,36 @@ return -2; /* no hardware access */ } if (dst == this->screen) { - SDL_mutexP (hw_lock); + SDL_mutexP(hw_lock); } /* Set up the X/Y base coordinates */ dstW = rect->w; dstH = rect->h; - FB_dst_to_xy (this, dst, &dstX, &dstY); + FB_dst_to_xy(this, dst, &dstX, &dstY); /* Adjust for the current rectangle */ dstX += rect->x; dstY += rect->y; - RIVA_FIFO_FREE (Bitmap, 1); + RIVA_FIFO_FREE(Bitmap, 1); Bitmap->Color1A = color; - RIVA_FIFO_FREE (Bitmap, 2); + RIVA_FIFO_FREE(Bitmap, 2); Bitmap->UnclippedRectangle[0].TopLeft = (dstX << 16) | dstY; Bitmap->UnclippedRectangle[0].WidthHeight = (dstW << 16) | dstH; - FB_AddBusySurface (dst); + FB_AddBusySurface(dst); if (dst == this->screen) { - SDL_mutexV (hw_lock); + SDL_mutexV(hw_lock); } return (0); } static int -HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { SDL_VideoDevice *this = current_video; int srcX, srcY; @@ -122,7 +122,7 @@ /* FIXME: For now, only blit to display surface */ if (dst->pitch != SDL_VideoSurface->pitch) { - return (src->map->sw_blit (src, srcrect, dst, dstrect)); + return (src->map->sw_blit(src, srcrect, dst, dstrect)); } /* Don't blit to the display surface when switched away */ @@ -130,14 +130,14 @@ return -2; /* no hardware access */ } if (dst == this->screen) { - SDL_mutexP (hw_lock); + SDL_mutexP(hw_lock); } /* Calculate source and destination base coordinates (in pixels) */ dstW = dstrect->w; dstH = dstrect->h; - FB_dst_to_xy (this, src, &srcX, &srcY); - FB_dst_to_xy (this, dst, &dstX, &dstY); + FB_dst_to_xy(this, src, &srcX, &srcY); + FB_dst_to_xy(this, dst, &dstX, &dstY); /* Adjust for the current blit rectangles */ srcX += srcrect->x; @@ -145,22 +145,22 @@ dstX += dstrect->x; dstY += dstrect->y; - RIVA_FIFO_FREE (Blt, 3); + RIVA_FIFO_FREE(Blt, 3); Blt->TopLeftSrc = (srcY << 16) | srcX; Blt->TopLeftDst = (dstY << 16) | dstX; Blt->WidthHeight = (dstH << 16) | dstW; - FB_AddBusySurface (src); - FB_AddBusySurface (dst); + FB_AddBusySurface(src); + FB_AddBusySurface(dst); if (dst == this->screen) { - SDL_mutexV (hw_lock); + SDL_mutexV(hw_lock); } return (0); } static int -CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst) +CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst) { int accelerated; @@ -188,7 +188,7 @@ } void -FB_RivaAccel (_THIS, __u32 card) +FB_RivaAccel(_THIS, __u32 card) { RivaRop *Rop = (RivaRop *) (mapped_io + ROP_OFFSET); diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/fbcon/SDL_fbriva.h --- a/src/video/fbcon/SDL_fbriva.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/fbcon/SDL_fbriva.h Mon May 29 04:04:35 2006 +0000 @@ -33,5 +33,5 @@ #endif /* Set up the driver for Riva acceleration */ -extern void FB_RivaAccel (_THIS, __u32 card); +extern void FB_RivaAccel(_THIS, __u32 card); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/fbcon/SDL_fbvideo.c --- a/src/video/fbcon/SDL_fbvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/fbcon/SDL_fbvideo.c Mon May 29 04:04:35 2006 +0000 @@ -148,48 +148,46 @@ }; /* Initialization/Query functions */ -static int FB_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **FB_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *FB_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); +static int FB_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **FB_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags); +static SDL_Surface *FB_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); #ifdef VGA16_FBCON_SUPPORT -static SDL_Surface *FB_SetVGA16Mode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); +static SDL_Surface *FB_SetVGA16Mode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); #endif -static int FB_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void FB_VideoQuit (_THIS); +static int FB_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void FB_VideoQuit(_THIS); /* Hardware surface functions */ -static int FB_InitHWSurfaces (_THIS, SDL_Surface * screen, char *base, - int size); -static void FB_FreeHWSurfaces (_THIS); -static int FB_AllocHWSurface (_THIS, SDL_Surface * surface); -static int FB_LockHWSurface (_THIS, SDL_Surface * surface); -static void FB_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void FB_FreeHWSurface (_THIS, SDL_Surface * surface); -static void FB_WaitVBL (_THIS); -static void FB_WaitIdle (_THIS); -static int FB_FlipHWSurface (_THIS, SDL_Surface * surface); +static int FB_InitHWSurfaces(_THIS, SDL_Surface * screen, char *base, + int size); +static void FB_FreeHWSurfaces(_THIS); +static int FB_AllocHWSurface(_THIS, SDL_Surface * surface); +static int FB_LockHWSurface(_THIS, SDL_Surface * surface); +static void FB_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void FB_FreeHWSurface(_THIS, SDL_Surface * surface); +static void FB_WaitVBL(_THIS); +static void FB_WaitIdle(_THIS); +static int FB_FlipHWSurface(_THIS, SDL_Surface * surface); /* Internal palette functions */ -static void FB_SavePalette (_THIS, struct fb_fix_screeninfo *finfo, - struct fb_var_screeninfo *vinfo); -static void FB_RestorePalette (_THIS); +static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo, + struct fb_var_screeninfo *vinfo); +static void FB_RestorePalette(_THIS); /* Small wrapper for mmap() so we can play nicely with no-mmu hosts * (non-mmu hosts disallow the MAP_SHARED flag) */ static void * -do_mmap (void *start, size_t length, int prot, int flags, int fd, - off_t offset) +do_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) { void *ret; - ret = mmap (start, length, prot, flags, fd, offset); + ret = mmap(start, length, prot, flags, fd, offset); if (ret == (char *) -1 && (flags & MAP_SHARED)) { - ret = mmap (start, length, prot, - (flags & ~MAP_SHARED) | MAP_PRIVATE, fd, offset); + ret = mmap(start, length, prot, + (flags & ~MAP_SHARED) | MAP_PRIVATE, fd, offset); } return ret; } @@ -197,7 +195,7 @@ /* FB driver bootstrap functions */ static int -FB_Available (void) +FB_Available(void) { int console = -1; /* Added check for /fb/0 (devfs) */ @@ -205,13 +203,13 @@ int idx = 0; const char *SDL_fbdevs[4] = { NULL, "/dev/fb0", "/dev/fb/0", NULL }; - SDL_fbdevs[0] = SDL_getenv ("SDL_FBDEV"); + SDL_fbdevs[0] = SDL_getenv("SDL_FBDEV"); if (!SDL_fbdevs[0]) idx++; for (; SDL_fbdevs[idx]; idx++) { - console = open (SDL_fbdevs[idx], O_RDWR, 0); + console = open(SDL_fbdevs[idx], O_RDWR, 0); if (console >= 0) { - close (console); + close(console); break; } } @@ -219,32 +217,32 @@ } static void -FB_DeleteDevice (SDL_VideoDevice * device) +FB_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -FB_CreateDevice (int devindex) +FB_CreateDevice(int devindex) { SDL_VideoDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + this = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); wait_vbl = FB_WaitVBL; wait_idle = FB_WaitIdle; mouse_fd = -1; @@ -287,7 +285,7 @@ #define FB_MODES_DB "/etc/fb.modes" static int -read_fbmodes_line (FILE * f, char *line, int length) +read_fbmodes_line(FILE * f, char *line, int length) { int blank; char *c; @@ -296,7 +294,7 @@ blank = 0; /* find a relevant line */ do { - if (fgets (line, length, f) <= 0) + if (fgets(line, length, f) <= 0) return 0; c = line; while (((*c == '\t') || (*c == ' ')) && (*c != 0)) @@ -319,73 +317,73 @@ } static int -read_fbmodes_mode (FILE * f, struct fb_var_screeninfo *vinfo) +read_fbmodes_mode(FILE * f, struct fb_var_screeninfo *vinfo) { char line[1024]; char option[256]; /* Find a "geometry" */ do { - if (read_fbmodes_line (f, line, sizeof (line)) == 0) + if (read_fbmodes_line(f, line, sizeof(line)) == 0) return 0; - if (SDL_strncmp (line, "geometry", 8) == 0) + if (SDL_strncmp(line, "geometry", 8) == 0) break; } while (1); - SDL_sscanf (line, "geometry %d %d %d %d %d", &vinfo->xres, &vinfo->yres, - &vinfo->xres_virtual, &vinfo->yres_virtual, - &vinfo->bits_per_pixel); - if (read_fbmodes_line (f, line, sizeof (line)) == 0) + SDL_sscanf(line, "geometry %d %d %d %d %d", &vinfo->xres, &vinfo->yres, + &vinfo->xres_virtual, &vinfo->yres_virtual, + &vinfo->bits_per_pixel); + if (read_fbmodes_line(f, line, sizeof(line)) == 0) return 0; - SDL_sscanf (line, "timings %d %d %d %d %d %d %d", &vinfo->pixclock, - &vinfo->left_margin, &vinfo->right_margin, - &vinfo->upper_margin, &vinfo->lower_margin, &vinfo->hsync_len, - &vinfo->vsync_len); + SDL_sscanf(line, "timings %d %d %d %d %d %d %d", &vinfo->pixclock, + &vinfo->left_margin, &vinfo->right_margin, + &vinfo->upper_margin, &vinfo->lower_margin, &vinfo->hsync_len, + &vinfo->vsync_len); vinfo->sync = 0; vinfo->vmode = FB_VMODE_NONINTERLACED; /* Parse misc options */ do { - if (read_fbmodes_line (f, line, sizeof (line)) == 0) + if (read_fbmodes_line(f, line, sizeof(line)) == 0) return 0; - if (SDL_strncmp (line, "hsync", 5) == 0) { - SDL_sscanf (line, "hsync %s", option); - if (SDL_strncmp (option, "high", 4) == 0) + if (SDL_strncmp(line, "hsync", 5) == 0) { + SDL_sscanf(line, "hsync %s", option); + if (SDL_strncmp(option, "high", 4) == 0) vinfo->sync |= FB_SYNC_HOR_HIGH_ACT; - } else if (SDL_strncmp (line, "vsync", 5) == 0) { - SDL_sscanf (line, "vsync %s", option); - if (SDL_strncmp (option, "high", 4) == 0) + } else if (SDL_strncmp(line, "vsync", 5) == 0) { + SDL_sscanf(line, "vsync %s", option); + if (SDL_strncmp(option, "high", 4) == 0) vinfo->sync |= FB_SYNC_VERT_HIGH_ACT; - } else if (SDL_strncmp (line, "csync", 5) == 0) { - SDL_sscanf (line, "csync %s", option); - if (SDL_strncmp (option, "high", 4) == 0) + } else if (SDL_strncmp(line, "csync", 5) == 0) { + SDL_sscanf(line, "csync %s", option); + if (SDL_strncmp(option, "high", 4) == 0) vinfo->sync |= FB_SYNC_COMP_HIGH_ACT; - } else if (SDL_strncmp (line, "extsync", 5) == 0) { - SDL_sscanf (line, "extsync %s", option); - if (SDL_strncmp (option, "true", 4) == 0) + } else if (SDL_strncmp(line, "extsync", 5) == 0) { + SDL_sscanf(line, "extsync %s", option); + if (SDL_strncmp(option, "true", 4) == 0) vinfo->sync |= FB_SYNC_EXT; - } else if (SDL_strncmp (line, "laced", 5) == 0) { - SDL_sscanf (line, "laced %s", option); - if (SDL_strncmp (option, "true", 4) == 0) + } else if (SDL_strncmp(line, "laced", 5) == 0) { + SDL_sscanf(line, "laced %s", option); + if (SDL_strncmp(option, "true", 4) == 0) vinfo->vmode |= FB_VMODE_INTERLACED; - } else if (SDL_strncmp (line, "double", 6) == 0) { - SDL_sscanf (line, "double %s", option); - if (SDL_strncmp (option, "true", 4) == 0) + } else if (SDL_strncmp(line, "double", 6) == 0) { + SDL_sscanf(line, "double %s", option); + if (SDL_strncmp(option, "true", 4) == 0) vinfo->vmode |= FB_VMODE_DOUBLE; } } - while (SDL_strncmp (line, "endmode", 7) != 0); + while (SDL_strncmp(line, "endmode", 7) != 0); return 1; } static int -FB_CheckMode (_THIS, struct fb_var_screeninfo *vinfo, - int index, unsigned int *w, unsigned int *h) +FB_CheckMode(_THIS, struct fb_var_screeninfo *vinfo, + int index, unsigned int *w, unsigned int *h) { int mode_okay; @@ -396,12 +394,12 @@ vinfo->yres = *h; vinfo->yres_virtual = *h; vinfo->activate = FB_ACTIVATE_TEST; - if (ioctl (console_fd, FBIOPUT_VSCREENINFO, vinfo) == 0) { + if (ioctl(console_fd, FBIOPUT_VSCREENINFO, vinfo) == 0) { #ifdef FBCON_DEBUG - fprintf (stderr, - "Checked mode %dx%d at %d bpp, got mode %dx%d at %d bpp\n", - *w, *h, (index + 1) * 8, vinfo->xres, vinfo->yres, - vinfo->bits_per_pixel); + fprintf(stderr, + "Checked mode %dx%d at %d bpp, got mode %dx%d at %d bpp\n", + *w, *h, (index + 1) * 8, vinfo->xres, vinfo->yres, + vinfo->bits_per_pixel); #endif if ((((vinfo->bits_per_pixel + 7) / 8) - 1) == index) { *w = vinfo->xres; @@ -413,8 +411,8 @@ } static int -FB_AddMode (_THIS, int index, unsigned int w, unsigned int h, - int check_timings) +FB_AddMode(_THIS, int index, unsigned int w, unsigned int h, + int check_timings) { SDL_Rect *mode; int i; @@ -425,9 +423,9 @@ mode = SDL_modelist[index][SDL_nummodes[index] - 1]; if ((mode->w == w) && (mode->h == h)) { #ifdef FBCON_DEBUG - fprintf (stderr, - "We already have mode %dx%d at %d bytes per pixel\n", - w, h, index + 1); + fprintf(stderr, + "We already have mode %dx%d at %d bytes per pixel\n", + w, h, index + 1); #endif return (0); } @@ -436,8 +434,7 @@ /* Only allow a mode if we have a valid timing for it */ if (check_timings) { int found_timing = 0; - for (i = 0; i < (sizeof (vesa_timings) / sizeof (vesa_timings[0])); - ++i) { + for (i = 0; i < (sizeof(vesa_timings) / sizeof(vesa_timings[0])); ++i) { if ((w == vesa_timings[i].xres) && (h == vesa_timings[i].yres) && vesa_timings[i].pixclock) { found_timing = 1; @@ -446,16 +443,16 @@ } if (!found_timing) { #ifdef FBCON_DEBUG - fprintf (stderr, "No valid timing line for mode %dx%d\n", w, h); + fprintf(stderr, "No valid timing line for mode %dx%d\n", w, h); #endif return (0); } } /* Set up the new video mode rectangle */ - mode = (SDL_Rect *) SDL_malloc (sizeof *mode); + mode = (SDL_Rect *) SDL_malloc(sizeof *mode); if (mode == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } mode->x = 0; @@ -463,19 +460,19 @@ mode->w = w; mode->h = h; #ifdef FBCON_DEBUG - fprintf (stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, - index + 1); + fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, + index + 1); #endif /* Allocate the new list of modes, and fill in the new mode */ next_mode = SDL_nummodes[index]; SDL_modelist[index] = (SDL_Rect **) - SDL_realloc (SDL_modelist[index], - (1 + next_mode + 1) * sizeof (SDL_Rect *)); + SDL_realloc(SDL_modelist[index], + (1 + next_mode + 1) * sizeof(SDL_Rect *)); if (SDL_modelist[index] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); SDL_nummodes[index] = 0; - SDL_free (mode); + SDL_free(mode); return (-1); } SDL_modelist[index][next_mode] = mode; @@ -486,7 +483,7 @@ } static int -cmpmodes (const void *va, const void *vb) +cmpmodes(const void *va, const void *vb) { const SDL_Rect *a = *(const SDL_Rect **) va; const SDL_Rect *b = *(const SDL_Rect **) vb; @@ -497,19 +494,19 @@ } static void -FB_SortModes (_THIS) +FB_SortModes(_THIS) { int i; for (i = 0; i < NUM_MODELISTS; ++i) { if (SDL_nummodes[i] > 0) { - SDL_qsort (SDL_modelist[i], SDL_nummodes[i], - sizeof *SDL_modelist[i], cmpmodes); + SDL_qsort(SDL_modelist[i], SDL_nummodes[i], + sizeof *SDL_modelist[i], cmpmodes); } } } static int -FB_VideoInit (_THIS, SDL_PixelFormat * vformat) +FB_VideoInit(_THIS, SDL_PixelFormat * vformat) { struct fb_fix_screeninfo finfo; struct fb_var_screeninfo vinfo; @@ -521,29 +518,29 @@ FILE *modesdb; /* Initialize the library */ - SDL_fbdev = SDL_getenv ("SDL_FBDEV"); + SDL_fbdev = SDL_getenv("SDL_FBDEV"); if (SDL_fbdev == NULL) { SDL_fbdev = "/dev/fb0"; } - console_fd = open (SDL_fbdev, O_RDWR, 0); + console_fd = open(SDL_fbdev, O_RDWR, 0); if (console_fd < 0) { - SDL_SetError ("Unable to open %s", SDL_fbdev); + SDL_SetError("Unable to open %s", SDL_fbdev); return (-1); } #if !SDL_THREADS_DISABLED /* Create the hardware surface lock mutex */ - hw_lock = SDL_CreateMutex (); + hw_lock = SDL_CreateMutex(); if (hw_lock == NULL) { - SDL_SetError ("Unable to create lock mutex"); - FB_VideoQuit (this); + SDL_SetError("Unable to create lock mutex"); + FB_VideoQuit(this); return (-1); } #endif /* Get the type of video hardware */ - if (ioctl (console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) { - SDL_SetError ("Couldn't get console hardware info"); - FB_VideoQuit (this); + if (ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) { + SDL_SetError("Couldn't get console hardware info"); + FB_VideoQuit(this); return (-1); } switch (finfo.type) { @@ -554,9 +551,9 @@ case FB_TYPE_VGA_PLANES: /* VGA16 is supported, but that's it */ if (finfo.type_aux == FB_AUX_VGA_PLANES_VGA4) { - if (ioperm (0x3b4, 0x3df - 0x3b4 + 1, 1) < 0) { - SDL_SetError ("No I/O port permissions"); - FB_VideoQuit (this); + if (ioperm(0x3b4, 0x3df - 0x3b4 + 1, 1) < 0) { + SDL_SetError("No I/O port permissions"); + FB_VideoQuit(this); return (-1); } this->SetVideoMode = FB_SetVGA16Mode; @@ -565,8 +562,8 @@ /* Fall through to unsupported case */ #endif /* VGA16_FBCON_SUPPORT */ default: - SDL_SetError ("Unsupported console hardware"); - FB_VideoQuit (this); + SDL_SetError("Unsupported console hardware"); + FB_VideoQuit(this); return (-1); } switch (finfo.visual) { @@ -576,17 +573,17 @@ case FB_VISUAL_DIRECTCOLOR: break; default: - SDL_SetError ("Unsupported console hardware"); - FB_VideoQuit (this); + SDL_SetError("Unsupported console hardware"); + FB_VideoQuit(this); return (-1); } /* Check if the user wants to disable hardware acceleration */ { const char *fb_accel; - fb_accel = SDL_getenv ("SDL_FBACCEL"); + fb_accel = SDL_getenv("SDL_FBACCEL"); if (fb_accel) { - finfo.accel = SDL_atoi (fb_accel); + finfo.accel = SDL_atoi(fb_accel); } } @@ -594,19 +591,19 @@ mapped_offset = (((long) finfo.smem_start) - (((long) finfo.smem_start) & ~(PAGE_SIZE - 1))); mapped_memlen = finfo.smem_len + mapped_offset; - mapped_mem = do_mmap (NULL, mapped_memlen, - PROT_READ | PROT_WRITE, MAP_SHARED, console_fd, 0); + mapped_mem = do_mmap(NULL, mapped_memlen, + PROT_READ | PROT_WRITE, MAP_SHARED, console_fd, 0); if (mapped_mem == (char *) -1) { - SDL_SetError ("Unable to memory map the video hardware"); + SDL_SetError("Unable to memory map the video hardware"); mapped_mem = NULL; - FB_VideoQuit (this); + FB_VideoQuit(this); return (-1); } /* Determine the current screen depth */ - if (ioctl (console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0) { - SDL_SetError ("Couldn't get console pixel format"); - FB_VideoQuit (this); + if (ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0) { + SDL_SetError("Couldn't get console pixel format"); + FB_VideoQuit(this); return (-1); } vformat->BitsPerPixel = vinfo.bits_per_pixel; @@ -629,17 +626,17 @@ saved_vinfo = vinfo; /* Save hardware palette, if needed */ - FB_SavePalette (this, &finfo, &vinfo); + FB_SavePalette(this, &finfo, &vinfo); /* If the I/O registers are available, memory map them so we can take advantage of any supported hardware acceleration. */ vinfo.accel_flags = 0; /* Temporarily reserve registers */ - ioctl (console_fd, FBIOPUT_VSCREENINFO, &vinfo); + ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo); if (finfo.accel && finfo.mmio_len) { mapped_iolen = finfo.mmio_len; - mapped_io = do_mmap (NULL, mapped_iolen, PROT_READ | PROT_WRITE, - MAP_SHARED, console_fd, mapped_memlen); + mapped_io = do_mmap(NULL, mapped_iolen, PROT_READ | PROT_WRITE, + MAP_SHARED, console_fd, mapped_memlen); if (mapped_io == (char *) -1) { /* Hmm, failed to memory map I/O registers */ mapped_io = NULL; @@ -650,15 +647,15 @@ current_w = vinfo.xres; current_h = vinfo.yres; current_index = ((vinfo.bits_per_pixel + 7) / 8) - 1; - modesdb = fopen (FB_MODES_DB, "r"); + modesdb = fopen(FB_MODES_DB, "r"); for (i = 0; i < NUM_MODELISTS; ++i) { SDL_nummodes[i] = 0; SDL_modelist[i] = NULL; } - if (SDL_getenv ("SDL_FB_BROKEN_MODES") != NULL) { - FB_AddMode (this, current_index, current_w, current_h, 0); + if (SDL_getenv("SDL_FB_BROKEN_MODES") != NULL) { + FB_AddMode(this, current_index, current_w, current_h, 0); } else if (modesdb) { - while (read_fbmodes_mode (modesdb, &vinfo)) { + while (read_fbmodes_mode(modesdb, &vinfo)) { for (i = 0; i < NUM_MODELISTS; ++i) { unsigned int w, h; @@ -668,20 +665,20 @@ if (i == current_index) { if ((current_w > w) || (current_h > h)) { /* Only check once */ - FB_AddMode (this, i, current_w, current_h, 0); + FB_AddMode(this, i, current_w, current_h, 0); current_index = -1; } } - if (FB_CheckMode (this, &vinfo, i, &w, &h)) { - FB_AddMode (this, i, w, h, 0); + if (FB_CheckMode(this, &vinfo, i, &w, &h)) { + FB_AddMode(this, i, w, h, 0); } } } - fclose (modesdb); - FB_SortModes (this); + fclose(modesdb); + FB_SortModes(this); } else { for (i = 0; i < NUM_MODELISTS; ++i) { - for (j = 0; j < (sizeof (checkres) / sizeof (checkres[0])); ++j) { + for (j = 0; j < (sizeof(checkres) / sizeof(checkres[0])); ++j) { unsigned int w, h; /* See if we are querying for the current mode */ @@ -690,12 +687,12 @@ if (i == current_index) { if ((current_w > w) || (current_h > h)) { /* Only check once */ - FB_AddMode (this, i, current_w, current_h, 0); + FB_AddMode(this, i, current_w, current_h, 0); current_index = -1; } } - if (FB_CheckMode (this, &vinfo, i, &w, &h)) { - FB_AddMode (this, i, w, h, 1); + if (FB_CheckMode(this, &vinfo, i, &w, &h)) { + FB_AddMode(this, i, w, h, 1); } } } @@ -717,43 +714,43 @@ /*case FB_ACCEL_MATROX_MGAG200: G200 acceleration broken! */ case FB_ACCEL_MATROX_MGAG400: #ifdef FBACCEL_DEBUG - printf ("Matrox hardware accelerator!\n"); + printf("Matrox hardware accelerator!\n"); #endif - FB_MatroxAccel (this, finfo.accel); + FB_MatroxAccel(this, finfo.accel); break; case FB_ACCEL_3DFX_BANSHEE: #ifdef FBACCEL_DEBUG - printf ("3DFX hardware accelerator!\n"); + printf("3DFX hardware accelerator!\n"); #endif - FB_3DfxAccel (this, finfo.accel); + FB_3DfxAccel(this, finfo.accel); break; case FB_ACCEL_NV3: case FB_ACCEL_NV4: #ifdef FBACCEL_DEBUG - printf ("NVidia hardware accelerator!\n"); + printf("NVidia hardware accelerator!\n"); #endif - FB_RivaAccel (this, finfo.accel); + FB_RivaAccel(this, finfo.accel); break; default: #ifdef FBACCEL_DEBUG - printf ("Unknown hardware accelerator.\n"); + printf("Unknown hardware accelerator.\n"); #endif break; } } /* Enable mouse and keyboard support */ - if (FB_OpenKeyboard (this) < 0) { - FB_VideoQuit (this); + if (FB_OpenKeyboard(this) < 0) { + FB_VideoQuit(this); return (-1); } - if (FB_OpenMouse (this) < 0) { + if (FB_OpenMouse(this) < 0) { const char *sdl_nomouse; - sdl_nomouse = SDL_getenv ("SDL_NOMOUSE"); + sdl_nomouse = SDL_getenv("SDL_NOMOUSE"); if (!sdl_nomouse) { - SDL_SetError ("Unable to open mouse"); - FB_VideoQuit (this); + SDL_SetError("Unable to open mouse"); + FB_VideoQuit(this); return (-1); } } @@ -763,83 +760,83 @@ } static SDL_Rect ** -FB_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +FB_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]); } /* Various screen update functions available */ -static void FB_DirectUpdate (_THIS, int numrects, SDL_Rect * rects); +static void FB_DirectUpdate(_THIS, int numrects, SDL_Rect * rects); #ifdef VGA16_FBCON_SUPPORT -static void FB_VGA16Update (_THIS, int numrects, SDL_Rect * rects); +static void FB_VGA16Update(_THIS, int numrects, SDL_Rect * rects); #endif #ifdef FBCON_DEBUG static void -print_vinfo (struct fb_var_screeninfo *vinfo) +print_vinfo(struct fb_var_screeninfo *vinfo) { - fprintf (stderr, "Printing vinfo:\n"); - fprintf (stderr, "\txres: %d\n", vinfo->xres); - fprintf (stderr, "\tyres: %d\n", vinfo->yres); - fprintf (stderr, "\txres_virtual: %d\n", vinfo->xres_virtual); - fprintf (stderr, "\tyres_virtual: %d\n", vinfo->yres_virtual); - fprintf (stderr, "\txoffset: %d\n", vinfo->xoffset); - fprintf (stderr, "\tyoffset: %d\n", vinfo->yoffset); - fprintf (stderr, "\tbits_per_pixel: %d\n", vinfo->bits_per_pixel); - fprintf (stderr, "\tgrayscale: %d\n", vinfo->grayscale); - fprintf (stderr, "\tnonstd: %d\n", vinfo->nonstd); - fprintf (stderr, "\tactivate: %d\n", vinfo->activate); - fprintf (stderr, "\theight: %d\n", vinfo->height); - fprintf (stderr, "\twidth: %d\n", vinfo->width); - fprintf (stderr, "\taccel_flags: %d\n", vinfo->accel_flags); - fprintf (stderr, "\tpixclock: %d\n", vinfo->pixclock); - fprintf (stderr, "\tleft_margin: %d\n", vinfo->left_margin); - fprintf (stderr, "\tright_margin: %d\n", vinfo->right_margin); - fprintf (stderr, "\tupper_margin: %d\n", vinfo->upper_margin); - fprintf (stderr, "\tlower_margin: %d\n", vinfo->lower_margin); - fprintf (stderr, "\thsync_len: %d\n", vinfo->hsync_len); - fprintf (stderr, "\tvsync_len: %d\n", vinfo->vsync_len); - fprintf (stderr, "\tsync: %d\n", vinfo->sync); - fprintf (stderr, "\tvmode: %d\n", vinfo->vmode); - fprintf (stderr, "\tred: %d/%d\n", vinfo->red.length, vinfo->red.offset); - fprintf (stderr, "\tgreen: %d/%d\n", vinfo->green.length, - vinfo->green.offset); - fprintf (stderr, "\tblue: %d/%d\n", vinfo->blue.length, - vinfo->blue.offset); - fprintf (stderr, "\talpha: %d/%d\n", vinfo->transp.length, - vinfo->transp.offset); + fprintf(stderr, "Printing vinfo:\n"); + fprintf(stderr, "\txres: %d\n", vinfo->xres); + fprintf(stderr, "\tyres: %d\n", vinfo->yres); + fprintf(stderr, "\txres_virtual: %d\n", vinfo->xres_virtual); + fprintf(stderr, "\tyres_virtual: %d\n", vinfo->yres_virtual); + fprintf(stderr, "\txoffset: %d\n", vinfo->xoffset); + fprintf(stderr, "\tyoffset: %d\n", vinfo->yoffset); + fprintf(stderr, "\tbits_per_pixel: %d\n", vinfo->bits_per_pixel); + fprintf(stderr, "\tgrayscale: %d\n", vinfo->grayscale); + fprintf(stderr, "\tnonstd: %d\n", vinfo->nonstd); + fprintf(stderr, "\tactivate: %d\n", vinfo->activate); + fprintf(stderr, "\theight: %d\n", vinfo->height); + fprintf(stderr, "\twidth: %d\n", vinfo->width); + fprintf(stderr, "\taccel_flags: %d\n", vinfo->accel_flags); + fprintf(stderr, "\tpixclock: %d\n", vinfo->pixclock); + fprintf(stderr, "\tleft_margin: %d\n", vinfo->left_margin); + fprintf(stderr, "\tright_margin: %d\n", vinfo->right_margin); + fprintf(stderr, "\tupper_margin: %d\n", vinfo->upper_margin); + fprintf(stderr, "\tlower_margin: %d\n", vinfo->lower_margin); + fprintf(stderr, "\thsync_len: %d\n", vinfo->hsync_len); + fprintf(stderr, "\tvsync_len: %d\n", vinfo->vsync_len); + fprintf(stderr, "\tsync: %d\n", vinfo->sync); + fprintf(stderr, "\tvmode: %d\n", vinfo->vmode); + fprintf(stderr, "\tred: %d/%d\n", vinfo->red.length, vinfo->red.offset); + fprintf(stderr, "\tgreen: %d/%d\n", vinfo->green.length, + vinfo->green.offset); + fprintf(stderr, "\tblue: %d/%d\n", vinfo->blue.length, + vinfo->blue.offset); + fprintf(stderr, "\talpha: %d/%d\n", vinfo->transp.length, + vinfo->transp.offset); } static void -print_finfo (struct fb_fix_screeninfo *finfo) +print_finfo(struct fb_fix_screeninfo *finfo) { - fprintf (stderr, "Printing finfo:\n"); - fprintf (stderr, "\tsmem_start = %p\n", (char *) finfo->smem_start); - fprintf (stderr, "\tsmem_len = %d\n", finfo->smem_len); - fprintf (stderr, "\ttype = %d\n", finfo->type); - fprintf (stderr, "\ttype_aux = %d\n", finfo->type_aux); - fprintf (stderr, "\tvisual = %d\n", finfo->visual); - fprintf (stderr, "\txpanstep = %d\n", finfo->xpanstep); - fprintf (stderr, "\typanstep = %d\n", finfo->ypanstep); - fprintf (stderr, "\tywrapstep = %d\n", finfo->ywrapstep); - fprintf (stderr, "\tline_length = %d\n", finfo->line_length); - fprintf (stderr, "\tmmio_start = %p\n", (char *) finfo->mmio_start); - fprintf (stderr, "\tmmio_len = %d\n", finfo->mmio_len); - fprintf (stderr, "\taccel = %d\n", finfo->accel); + fprintf(stderr, "Printing finfo:\n"); + fprintf(stderr, "\tsmem_start = %p\n", (char *) finfo->smem_start); + fprintf(stderr, "\tsmem_len = %d\n", finfo->smem_len); + fprintf(stderr, "\ttype = %d\n", finfo->type); + fprintf(stderr, "\ttype_aux = %d\n", finfo->type_aux); + fprintf(stderr, "\tvisual = %d\n", finfo->visual); + fprintf(stderr, "\txpanstep = %d\n", finfo->xpanstep); + fprintf(stderr, "\typanstep = %d\n", finfo->ypanstep); + fprintf(stderr, "\tywrapstep = %d\n", finfo->ywrapstep); + fprintf(stderr, "\tline_length = %d\n", finfo->line_length); + fprintf(stderr, "\tmmio_start = %p\n", (char *) finfo->mmio_start); + fprintf(stderr, "\tmmio_len = %d\n", finfo->mmio_len); + fprintf(stderr, "\taccel = %d\n", finfo->accel); } #endif static int -choose_fbmodes_mode (struct fb_var_screeninfo *vinfo) +choose_fbmodes_mode(struct fb_var_screeninfo *vinfo) { int matched; FILE *modesdb; struct fb_var_screeninfo cinfo; matched = 0; - modesdb = fopen (FB_MODES_DB, "r"); + modesdb = fopen(FB_MODES_DB, "r"); if (modesdb) { /* Parse the mode definition file */ - while (read_fbmodes_mode (modesdb, &cinfo)) { + while (read_fbmodes_mode(modesdb, &cinfo)) { if ((vinfo->xres == cinfo.xres && vinfo->yres == cinfo.yres) && (!matched || (vinfo->bits_per_pixel == cinfo.bits_per_pixel))) { @@ -856,25 +853,25 @@ matched = 1; } } - fclose (modesdb); + fclose(modesdb); } return (matched); } static int -choose_vesa_mode (struct fb_var_screeninfo *vinfo) +choose_vesa_mode(struct fb_var_screeninfo *vinfo) { int matched; int i; /* Check for VESA timings */ matched = 0; - for (i = 0; i < (sizeof (vesa_timings) / sizeof (vesa_timings[0])); ++i) { + for (i = 0; i < (sizeof(vesa_timings) / sizeof(vesa_timings[0])); ++i) { if ((vinfo->xres == vesa_timings[i].xres) && (vinfo->yres == vesa_timings[i].yres)) { #ifdef FBCON_DEBUG - fprintf (stderr, "Using VESA timings for %dx%d\n", - vinfo->xres, vinfo->yres); + fprintf(stderr, "Using VESA timings for %dx%d\n", + vinfo->xres, vinfo->yres); #endif if (vesa_timings[i].pixclock) { vinfo->pixclock = vesa_timings[i].pixclock; @@ -896,31 +893,31 @@ #ifdef VGA16_FBCON_SUPPORT static SDL_Surface * -FB_SetVGA16Mode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +FB_SetVGA16Mode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { struct fb_fix_screeninfo finfo; struct fb_var_screeninfo vinfo; /* Set the terminal into graphics mode */ - if (FB_EnterGraphicsMode (this) < 0) { + if (FB_EnterGraphicsMode(this) < 0) { return (NULL); } /* Restore the original palette */ - FB_RestorePalette (this); + FB_RestorePalette(this); /* Set the video mode and get the final screen format */ - if (ioctl (console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0) { - SDL_SetError ("Couldn't get console screen info"); + if (ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0) { + SDL_SetError("Couldn't get console screen info"); return (NULL); } cache_vinfo = vinfo; #ifdef FBCON_DEBUG - fprintf (stderr, "Printing actual vinfo:\n"); - print_vinfo (&vinfo); + fprintf(stderr, "Printing actual vinfo:\n"); + print_vinfo(&vinfo); #endif - if (!SDL_ReallocFormat (current, bpp, 0, 0, 0, 0)) { + if (!SDL_ReallocFormat(current, bpp, 0, 0, 0, 0)) { return (NULL); } current->format->palette->ncolors = 16; @@ -928,24 +925,24 @@ /* Get the fixed information about the console hardware. This is necessary since finfo.line_length changes. */ - if (ioctl (console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) { - SDL_SetError ("Couldn't get console hardware info"); + if (ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) { + SDL_SetError("Couldn't get console hardware info"); return (NULL); } #ifdef FBCON_DEBUG - fprintf (stderr, "Printing actual finfo:\n"); - print_finfo (&finfo); + fprintf(stderr, "Printing actual finfo:\n"); + print_finfo(&finfo); #endif /* Save hardware palette, if needed */ - FB_SavePalette (this, &finfo, &vinfo); + FB_SavePalette(this, &finfo, &vinfo); /* Set up the new mode framebuffer */ current->flags = SDL_FULLSCREEN; current->w = vinfo.xres; current->h = vinfo.yres; current->pitch = current->w; - current->pixels = SDL_malloc (current->h * current->pitch); + current->pixels = SDL_malloc(current->h * current->pitch); /* Set the update rectangle function */ this->UpdateRects = FB_VGA16Update; @@ -956,8 +953,8 @@ #endif /* VGA16_FBCON_SUPPORT */ static SDL_Surface * -FB_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +FB_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { struct fb_fix_screeninfo finfo; struct fb_var_screeninfo vinfo; @@ -969,21 +966,21 @@ int surfaces_len; /* Set the terminal into graphics mode */ - if (FB_EnterGraphicsMode (this) < 0) { + if (FB_EnterGraphicsMode(this) < 0) { return (NULL); } /* Restore the original palette */ - FB_RestorePalette (this); + FB_RestorePalette(this); /* Set the video mode and get the final screen format */ - if (ioctl (console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0) { - SDL_SetError ("Couldn't get console screen info"); + if (ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0) { + SDL_SetError("Couldn't get console screen info"); return (NULL); } #ifdef FBCON_DEBUG - fprintf (stderr, "Printing original vinfo:\n"); - print_vinfo (&vinfo); + fprintf(stderr, "Printing original vinfo:\n"); + print_vinfo(&vinfo); #endif if ((vinfo.xres != width) || (vinfo.yres != height) || (vinfo.bits_per_pixel != bpp) || (flags & SDL_DOUBLEBUF)) { @@ -1004,17 +1001,17 @@ vinfo.green.length = vinfo.green.offset = 0; vinfo.blue.length = vinfo.blue.offset = 0; vinfo.transp.length = vinfo.transp.offset = 0; - if (!choose_fbmodes_mode (&vinfo)) { - choose_vesa_mode (&vinfo); + if (!choose_fbmodes_mode(&vinfo)) { + choose_vesa_mode(&vinfo); } #ifdef FBCON_DEBUG - fprintf (stderr, "Printing wanted vinfo:\n"); - print_vinfo (&vinfo); + fprintf(stderr, "Printing wanted vinfo:\n"); + print_vinfo(&vinfo); #endif - if (ioctl (console_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0) { + if (ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0) { vinfo.yres_virtual = height; - if (ioctl (console_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0) { - SDL_SetError ("Couldn't set console screen info"); + if (ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0) { + SDL_SetError("Couldn't set console screen info"); return (NULL); } } @@ -1033,8 +1030,8 @@ } cache_vinfo = vinfo; #ifdef FBCON_DEBUG - fprintf (stderr, "Printing actual vinfo:\n"); - print_vinfo (&vinfo); + fprintf(stderr, "Printing actual vinfo:\n"); + print_vinfo(&vinfo); #endif Rmask = 0; for (i = 0; i < vinfo.red.length; ++i) { @@ -1051,21 +1048,21 @@ Bmask <<= 1; Bmask |= (0x00000001 << vinfo.blue.offset); } - if (!SDL_ReallocFormat (current, vinfo.bits_per_pixel, - Rmask, Gmask, Bmask, 0)) { + if (!SDL_ReallocFormat(current, vinfo.bits_per_pixel, + Rmask, Gmask, Bmask, 0)) { return (NULL); } /* Get the fixed information about the console hardware. This is necessary since finfo.line_length changes. */ - if (ioctl (console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) { - SDL_SetError ("Couldn't get console hardware info"); + if (ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) { + SDL_SetError("Couldn't get console hardware info"); return (NULL); } /* Save hardware palette, if needed */ - FB_SavePalette (this, &finfo, &vinfo); + FB_SavePalette(this, &finfo, &vinfo); /* Set up the new mode framebuffer */ current->flags = (SDL_FULLSCREEN | SDL_HWSURFACE); @@ -1078,8 +1075,8 @@ surfaces_mem = (char *) current->pixels + vinfo.yres_virtual * current->pitch; surfaces_len = (mapped_memlen - (surfaces_mem - mapped_mem)); - FB_FreeHWSurfaces (this); - FB_InitHWSurfaces (this, current, surfaces_mem, surfaces_len); + FB_FreeHWSurfaces(this); + FB_InitHWSurfaces(this, current, surfaces_mem, surfaces_len); /* Let the application know we have a hardware palette */ switch (finfo.visual) { @@ -1099,7 +1096,7 @@ flip_address[1] = (char *) current->pixels + current->h * current->pitch; this->screen = current; - FB_FlipHWSurface (this, current); + FB_FlipHWSurface(this, current); this->screen = NULL; } } @@ -1113,38 +1110,38 @@ #ifdef FBCON_DEBUG void -FB_DumpHWSurfaces (_THIS) +FB_DumpHWSurfaces(_THIS) { vidmem_bucket *bucket; - printf ("Memory left: %d (%d total)\n", surfaces_memleft, - surfaces_memtotal); - printf ("\n"); - printf (" Base Size\n"); + printf("Memory left: %d (%d total)\n", surfaces_memleft, + surfaces_memtotal); + printf("\n"); + printf(" Base Size\n"); for (bucket = &surfaces; bucket; bucket = bucket->next) { - printf ("Bucket: %p, %d (%s)\n", bucket->base, bucket->size, - bucket->used ? "used" : "free"); + printf("Bucket: %p, %d (%s)\n", bucket->base, bucket->size, + bucket->used ? "used" : "free"); if (bucket->prev) { if (bucket->base != bucket->prev->base + bucket->prev->size) { - printf ("Warning, corrupt bucket list! (prev)\n"); + printf("Warning, corrupt bucket list! (prev)\n"); } } else { if (bucket != &surfaces) { - printf ("Warning, corrupt bucket list! (!prev)\n"); + printf("Warning, corrupt bucket list! (!prev)\n"); } } if (bucket->next) { if (bucket->next->base != bucket->base + bucket->size) { - printf ("Warning, corrupt bucket list! (next)\n"); + printf("Warning, corrupt bucket list! (next)\n"); } } } - printf ("\n"); + printf("\n"); } #endif static int -FB_InitHWSurfaces (_THIS, SDL_Surface * screen, char *base, int size) +FB_InitHWSurfaces(_THIS, SDL_Surface * screen, char *base, int size) { vidmem_bucket *bucket; @@ -1152,9 +1149,9 @@ surfaces_memleft = size; if (surfaces_memleft > 0) { - bucket = (vidmem_bucket *) SDL_malloc (sizeof (*bucket)); + bucket = (vidmem_bucket *) SDL_malloc(sizeof(*bucket)); if (bucket == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } bucket->prev = &surfaces; @@ -1177,7 +1174,7 @@ return (0); } static void -FB_FreeHWSurfaces (_THIS) +FB_FreeHWSurfaces(_THIS) { vidmem_bucket *bucket, *freeable; @@ -1185,13 +1182,13 @@ while (bucket) { freeable = bucket; bucket = bucket->next; - SDL_free (freeable); + SDL_free(freeable); } surfaces.next = NULL; } static int -FB_AllocHWSurface (_THIS, SDL_Surface * surface) +FB_AllocHWSurface(_THIS, SDL_Surface * surface) { vidmem_bucket *bucket; int size; @@ -1203,18 +1200,18 @@ Until someone who knows these details looks at the code... */ if (surface->pitch > SDL_VideoSurface->pitch) { - SDL_SetError ("Surface requested wider than screen"); + SDL_SetError("Surface requested wider than screen"); return (-1); } surface->pitch = SDL_VideoSurface->pitch; size = surface->h * surface->pitch; #ifdef FBCON_DEBUG - fprintf (stderr, "Allocating bucket of %d bytes\n", size); + fprintf(stderr, "Allocating bucket of %d bytes\n", size); #endif /* Quick check for available mem */ if (size > surfaces_memleft) { - SDL_SetError ("Not enough video memory"); + SDL_SetError("Not enough video memory"); return (-1); } @@ -1225,7 +1222,7 @@ } } if (bucket == NULL) { - SDL_SetError ("Video memory too fragmented"); + SDL_SetError("Video memory too fragmented"); return (-1); } @@ -1235,11 +1232,11 @@ vidmem_bucket *newbucket; #ifdef FBCON_DEBUG - fprintf (stderr, "Adding new free bucket of %d bytes\n", extra); + fprintf(stderr, "Adding new free bucket of %d bytes\n", extra); #endif - newbucket = (vidmem_bucket *) SDL_malloc (sizeof (*newbucket)); + newbucket = (vidmem_bucket *) SDL_malloc(sizeof(*newbucket)); if (newbucket == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } newbucket->prev = bucket; @@ -1258,8 +1255,7 @@ bucket->size = size; bucket->dirty = 0; #ifdef FBCON_DEBUG - fprintf (stderr, "Allocated %d bytes at %p\n", bucket->size, - bucket->base); + fprintf(stderr, "Allocated %d bytes at %p\n", bucket->size, bucket->base); #endif surfaces_memleft -= size; surface->flags |= SDL_HWSURFACE; @@ -1268,7 +1264,7 @@ return (0); } static void -FB_FreeHWSurface (_THIS, SDL_Surface * surface) +FB_FreeHWSurface(_THIS, SDL_Surface * surface) { vidmem_bucket *bucket, *freeable; @@ -1281,7 +1277,7 @@ if (bucket && bucket->used) { /* Add the memory back to the total */ #ifdef DGA_DEBUG - printf ("Freeing bucket of %d bytes\n", bucket->size); + printf("Freeing bucket of %d bytes\n", bucket->size); #endif surfaces_memleft += bucket->size; @@ -1289,8 +1285,8 @@ bucket->used = 0; if (bucket->next && !bucket->next->used) { #ifdef DGA_DEBUG - printf ("Merging with next bucket, for %d total bytes\n", - bucket->size + bucket->next->size); + printf("Merging with next bucket, for %d total bytes\n", + bucket->size + bucket->next->size); #endif freeable = bucket->next; bucket->size += bucket->next->size; @@ -1298,12 +1294,12 @@ if (bucket->next) { bucket->next->prev = bucket; } - SDL_free (freeable); + SDL_free(freeable); } if (bucket->prev && !bucket->prev->used) { #ifdef DGA_DEBUG - printf ("Merging with previous bucket, for %d total bytes\n", - bucket->prev->size + bucket->size); + printf("Merging with previous bucket, for %d total bytes\n", + bucket->prev->size + bucket->size); #endif freeable = bucket; bucket->prev->size += bucket->size; @@ -1311,7 +1307,7 @@ if (bucket->next) { bucket->next->prev = bucket->prev; } - SDL_free (freeable); + SDL_free(freeable); } } surface->pixels = NULL; @@ -1319,48 +1315,48 @@ } static int -FB_LockHWSurface (_THIS, SDL_Surface * surface) +FB_LockHWSurface(_THIS, SDL_Surface * surface) { if (switched_away) { return -2; /* no hardware access */ } if (surface == this->screen) { - SDL_mutexP (hw_lock); - if (FB_IsSurfaceBusy (surface)) { - FB_WaitBusySurfaces (this); + SDL_mutexP(hw_lock); + if (FB_IsSurfaceBusy(surface)) { + FB_WaitBusySurfaces(this); } } else { - if (FB_IsSurfaceBusy (surface)) { - FB_WaitBusySurfaces (this); + if (FB_IsSurfaceBusy(surface)) { + FB_WaitBusySurfaces(this); } } return (0); } static void -FB_UnlockHWSurface (_THIS, SDL_Surface * surface) +FB_UnlockHWSurface(_THIS, SDL_Surface * surface) { if (surface == this->screen) { - SDL_mutexV (hw_lock); + SDL_mutexV(hw_lock); } } static void -FB_WaitVBL (_THIS) +FB_WaitVBL(_THIS) { #ifdef FBIOWAITRETRACE /* Heheh, this didn't make it into the main kernel */ - ioctl (console_fd, FBIOWAITRETRACE, 0); + ioctl(console_fd, FBIOWAITRETRACE, 0); #endif return; } static void -FB_WaitIdle (_THIS) +FB_WaitIdle(_THIS) { return; } static int -FB_FlipHWSurface (_THIS, SDL_Surface * surface) +FB_FlipHWSurface(_THIS, SDL_Surface * surface) { if (switched_away) { return -2; /* no hardware access */ @@ -1368,12 +1364,12 @@ /* Wait for vertical retrace and then flip display */ cache_vinfo.yoffset = flip_page * surface->h; - if (FB_IsSurfaceBusy (this->screen)) { - FB_WaitBusySurfaces (this); + if (FB_IsSurfaceBusy(this->screen)) { + FB_WaitBusySurfaces(this); } - wait_vbl (this); - if (ioctl (console_fd, FBIOPAN_DISPLAY, &cache_vinfo) < 0) { - SDL_SetError ("ioctl(FBIOPAN_DISPLAY) failed"); + wait_vbl(this); + if (ioctl(console_fd, FBIOPAN_DISPLAY, &cache_vinfo) < 0) { + SDL_SetError("ioctl(FBIOPAN_DISPLAY) failed"); return (-1); } flip_page = !flip_page; @@ -1383,7 +1379,7 @@ } static void -FB_DirectUpdate (_THIS, int numrects, SDL_Rect * rects) +FB_DirectUpdate(_THIS, int numrects, SDL_Rect * rects) { /* The application is already updating the visible video memory */ return; @@ -1399,7 +1395,7 @@ outb(value, 0x3C5); static void -FB_VGA16Update (_THIS, int numrects, SDL_Rect * rects) +FB_VGA16Update(_THIS, int numrects, SDL_Rect * rects) { SDL_Surface *screen; int width, height, FBPitch, left, i, j, SRCPitch, phase; @@ -1416,10 +1412,10 @@ FBPitch = screen->w >> 3; SRCPitch = screen->pitch >> 2; - writeGr (0x03, 0x00); - writeGr (0x05, 0x00); - writeGr (0x01, 0x00); - writeGr (0x08, 0xFF); + writeGr(0x03, 0x00); + writeGr(0x05, 0x00); + writeGr(0x01, 0x00); + writeGr(0x08, 0xFF); while (numrects--) { left = rects->x & ~7; @@ -1436,7 +1432,7 @@ } while (height--) { - writeSeq (0x02, 1 << 0); + writeSeq(0x02, 1 << 0); dstPtr = dst; srcPtr = src; i = width; @@ -1473,7 +1469,7 @@ srcPtr += 2; } - writeSeq (0x02, 1 << 1); + writeSeq(0x02, 1 << 1); dstPtr = dst; srcPtr = src; i = width; @@ -1510,7 +1506,7 @@ srcPtr += 2; } - writeSeq (0x02, 1 << 2); + writeSeq(0x02, 1 << 2); dstPtr = dst; srcPtr = src; i = width; @@ -1547,7 +1543,7 @@ srcPtr += 2; } - writeSeq (0x02, 1 << 3); + writeSeq(0x02, 1 << 3); dstPtr = dst; srcPtr = src; i = width; @@ -1593,7 +1589,7 @@ #endif /* VGA16_FBCON_SUPPORT */ void -FB_SavePaletteTo (_THIS, int palette_len, __u16 * area) +FB_SavePaletteTo(_THIS, int palette_len, __u16 * area) { struct fb_cmap cmap; @@ -1603,11 +1599,11 @@ cmap.green = &area[1 * palette_len]; cmap.blue = &area[2 * palette_len]; cmap.transp = NULL; - ioctl (console_fd, FBIOGETCMAP, &cmap); + ioctl(console_fd, FBIOGETCMAP, &cmap); } void -FB_RestorePaletteFrom (_THIS, int palette_len, __u16 * area) +FB_RestorePaletteFrom(_THIS, int palette_len, __u16 * area) { struct fb_cmap cmap; @@ -1617,12 +1613,12 @@ cmap.green = &area[1 * palette_len]; cmap.blue = &area[2 * palette_len]; cmap.transp = NULL; - ioctl (console_fd, FBIOPUTCMAP, &cmap); + ioctl(console_fd, FBIOPUTCMAP, &cmap); } static void -FB_SavePalette (_THIS, struct fb_fix_screeninfo *finfo, - struct fb_var_screeninfo *vinfo) +FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo, + struct fb_var_screeninfo *vinfo) { int i; @@ -1630,9 +1626,9 @@ if (finfo->visual == FB_VISUAL_PSEUDOCOLOR) { saved_cmaplen = 1 << vinfo->bits_per_pixel; saved_cmap = - (__u16 *) SDL_malloc (3 * saved_cmaplen * sizeof (*saved_cmap)); + (__u16 *) SDL_malloc(3 * saved_cmaplen * sizeof(*saved_cmap)); if (saved_cmap != NULL) { - FB_SavePaletteTo (this, saved_cmaplen, saved_cmap); + FB_SavePaletteTo(this, saved_cmaplen, saved_cmap); } } @@ -1651,9 +1647,9 @@ /* Save the colormap */ saved_cmaplen = 256; saved_cmap = - (__u16 *) SDL_malloc (3 * saved_cmaplen * sizeof (*saved_cmap)); + (__u16 *) SDL_malloc(3 * saved_cmaplen * sizeof(*saved_cmap)); if (saved_cmap != NULL) { - FB_SavePaletteTo (this, saved_cmaplen, saved_cmap); + FB_SavePaletteTo(this, saved_cmaplen, saved_cmap); } /* Allocate new identity colormap */ @@ -1662,23 +1658,23 @@ new_entries[(1 * 256) + i] = new_entries[(2 * 256) + i] = (i << 8) | i; } - FB_RestorePaletteFrom (this, 256, new_entries); + FB_RestorePaletteFrom(this, 256, new_entries); } } static void -FB_RestorePalette (_THIS) +FB_RestorePalette(_THIS) { /* Restore the original palette */ if (saved_cmap) { - FB_RestorePaletteFrom (this, saved_cmaplen, saved_cmap); - SDL_free (saved_cmap); + FB_RestorePaletteFrom(this, saved_cmaplen, saved_cmap); + SDL_free(saved_cmap); saved_cmap = NULL; } } static int -FB_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +FB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { int i; __u16 r[256]; @@ -1699,16 +1695,16 @@ cmap.blue = b; cmap.transp = NULL; - if ((ioctl (console_fd, FBIOPUTCMAP, &cmap) < 0) || + if ((ioctl(console_fd, FBIOPUTCMAP, &cmap) < 0) || !(this->screen->flags & SDL_HWPALETTE)) { colors = this->screen->format->palette->colors; ncolors = this->screen->format->palette->ncolors; cmap.start = 0; cmap.len = ncolors; - SDL_memset (r, 0, sizeof (r)); - SDL_memset (g, 0, sizeof (g)); - SDL_memset (b, 0, sizeof (b)); - if (ioctl (console_fd, FBIOGETCMAP, &cmap) == 0) { + SDL_memset(r, 0, sizeof(r)); + SDL_memset(g, 0, sizeof(g)); + SDL_memset(b, 0, sizeof(b)); + if (ioctl(console_fd, FBIOGETCMAP, &cmap) == 0) { for (i = ncolors - 1; i >= 0; --i) { colors[i].r = (r[i] >> 8); colors[i].g = (g[i] >> 8); @@ -1724,13 +1720,13 @@ another SDL video routine -- notably UpdateRects. */ static void -FB_VideoQuit (_THIS) +FB_VideoQuit(_THIS) { int i, j; if (this->screen) { /* Clear screen and tell SDL not to free the pixels */ - if (this->screen->pixels && FB_InGraphicsMode (this)) { + if (this->screen->pixels && FB_InGraphicsMode(this)) { #if defined(__powerpc__) || defined(__ia64__) /* SIGBUS when using SDL_memset() ?? */ Uint8 *rowp = (Uint8 *) this->screen->pixels; int left = this->screen->pitch * this->screen->h; @@ -1738,8 +1734,8 @@ *rowp++ = 0; } #else - SDL_memset (this->screen->pixels, 0, - this->screen->h * this->screen->pitch); + SDL_memset(this->screen->pixels, 0, + this->screen->h * this->screen->pitch); #endif } /* This test fails when using the VGA16 shadow memory */ @@ -1751,7 +1747,7 @@ /* Clear the lock mutex */ if (hw_lock) { - SDL_DestroyMutex (hw_lock); + SDL_DestroyMutex(hw_lock); hw_lock = NULL; } @@ -1759,40 +1755,40 @@ for (i = 0; i < NUM_MODELISTS; ++i) { if (SDL_modelist[i] != NULL) { for (j = 0; SDL_modelist[i][j]; ++j) { - SDL_free (SDL_modelist[i][j]); + SDL_free(SDL_modelist[i][j]); } - SDL_free (SDL_modelist[i]); + SDL_free(SDL_modelist[i]); SDL_modelist[i] = NULL; } } /* Clean up the memory bucket list */ - FB_FreeHWSurfaces (this); + FB_FreeHWSurfaces(this); /* Close console and input file descriptors */ if (console_fd > 0) { /* Unmap the video framebuffer and I/O registers */ if (mapped_mem) { - munmap (mapped_mem, mapped_memlen); + munmap(mapped_mem, mapped_memlen); mapped_mem = NULL; } if (mapped_io) { - munmap (mapped_io, mapped_iolen); + munmap(mapped_io, mapped_iolen); mapped_io = NULL; } /* Restore the original video mode and palette */ - if (FB_InGraphicsMode (this)) { - FB_RestorePalette (this); - ioctl (console_fd, FBIOPUT_VSCREENINFO, &saved_vinfo); + if (FB_InGraphicsMode(this)) { + FB_RestorePalette(this); + ioctl(console_fd, FBIOPUT_VSCREENINFO, &saved_vinfo); } /* We're all done with the framebuffer */ - close (console_fd); + close(console_fd); console_fd = -1; } - FB_CloseMouse (this); - FB_CloseKeyboard (this); + FB_CloseMouse(this); + FB_CloseKeyboard(this); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/fbcon/SDL_fbvideo.h --- a/src/video/fbcon/SDL_fbvideo.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/fbcon/SDL_fbvideo.h Mon May 29 04:04:35 2006 +0000 @@ -143,30 +143,30 @@ #endif /* These functions are defined in SDL_fbvideo.c */ -extern void FB_SavePaletteTo (_THIS, int palette_len, __u16 * area); -extern void FB_RestorePaletteFrom (_THIS, int palette_len, __u16 * area); +extern void FB_SavePaletteTo(_THIS, int palette_len, __u16 * area); +extern void FB_RestorePaletteFrom(_THIS, int palette_len, __u16 * area); /* These are utility functions for working with video surfaces */ static __inline__ void -FB_AddBusySurface (SDL_Surface * surface) +FB_AddBusySurface(SDL_Surface * surface) { ((vidmem_bucket *) surface->hwdata)->dirty = 1; } static __inline__ int -FB_IsSurfaceBusy (SDL_Surface * surface) +FB_IsSurfaceBusy(SDL_Surface * surface) { return ((vidmem_bucket *) surface->hwdata)->dirty; } static __inline__ void -FB_WaitBusySurfaces (_THIS) +FB_WaitBusySurfaces(_THIS) { vidmem_bucket *bucket; /* Wait for graphic operations to complete */ - wait_idle (this); + wait_idle(this); /* Clear all surface dirty bits */ for (bucket = &surfaces; bucket; bucket = bucket->next) { @@ -175,7 +175,7 @@ } static __inline__ void -FB_dst_to_xy (_THIS, SDL_Surface * dst, int *x, int *y) +FB_dst_to_xy(_THIS, SDL_Surface * dst, int *x, int *y) { *x = (long) ((char *) dst->pixels - mapped_mem) % this->screen->pitch; *y = (long) ((char *) dst->pixels - mapped_mem) / this->screen->pitch; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/gapi/SDL_gapivideo.c --- a/src/video/gapi/SDL_gapivideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/gapi/SDL_gapivideo.c Mon May 29 04:04:35 2006 +0000 @@ -73,33 +73,33 @@ // defined and used in SDL_sysevents.c extern HINSTANCE aygshell; -extern void SDL_UnregisterApp (); -extern int DIB_AddMode (_THIS, int bpp, int w, int h); +extern void SDL_UnregisterApp(); +extern int DIB_AddMode(_THIS, int bpp, int w, int h); /* Initialization/Query functions */ -static int GAPI_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **GAPI_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *GAPI_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); -static int GAPI_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void GAPI_VideoQuit (_THIS); +static int GAPI_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **GAPI_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +static SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, + Uint32 flags); +static int GAPI_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void GAPI_VideoQuit(_THIS); /* Hardware surface functions */ -static int GAPI_AllocHWSurface (_THIS, SDL_Surface * surface); -static int GAPI_LockHWSurface (_THIS, SDL_Surface * surface); -static void GAPI_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void GAPI_FreeHWSurface (_THIS, SDL_Surface * surface); +static int GAPI_AllocHWSurface(_THIS, SDL_Surface * surface); +static int GAPI_LockHWSurface(_THIS, SDL_Surface * surface); +static void GAPI_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void GAPI_FreeHWSurface(_THIS, SDL_Surface * surface); /* Windows message handling functions, will not be processed */ -static void GAPI_RealizePalette (_THIS); -static void GAPI_PaletteChanged (_THIS, HWND window); -static void GAPI_WinPAINT (_THIS, HDC hdc); +static void GAPI_RealizePalette(_THIS); +static void GAPI_PaletteChanged(_THIS, HWND window); +static void GAPI_WinPAINT(_THIS, HDC hdc); /* etc. */ -static void GAPI_UpdateRects (_THIS, int numrects, SDL_Rect * rects); +static void GAPI_UpdateRects(_THIS, int numrects, SDL_Rect * rects); static HMODULE g_hGapiLib = 0; #define LINK(type,name,import) \ @@ -149,14 +149,14 @@ } GXDeviceInfo; static int -GAPI_Available (void) +GAPI_Available(void) { // try to use VGA display, even on emulator - HDC hdc = GetDC (NULL); - int result = ExtEscape (hdc, GETRAWFRAMEBUFFER, 0, NULL, - sizeof (RawFrameBufferInfo), - (char *) &g_RawFrameBufferInfo); - ReleaseDC (NULL, hdc); + HDC hdc = GetDC(NULL); + int result = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, + sizeof(RawFrameBufferInfo), + (char *) &g_RawFrameBufferInfo); + ReleaseDC(NULL, hdc); g_bRawBufferAvailable = result > 0; #if WITHOUT_GAPI @@ -164,17 +164,17 @@ #endif #if USE_GAPI_EMU - g_hGapiLib = LoadLibrary (_T ("GAPI_Emu.dll")); + g_hGapiLib = LoadLibrary(_T("GAPI_Emu.dll")); if (!g_hGapiLib) { - SDL_SetError ("Gapi Emu not found!"); + SDL_SetError("Gapi Emu not found!"); } return g_hGapiLib != 0; #endif // try to find gx.dll - g_hGapiLib = LoadLibrary (_T ("\\Windows\\gx.dll")); + g_hGapiLib = LoadLibrary(_T("\\Windows\\gx.dll")); if (!g_hGapiLib) { - g_hGapiLib = LoadLibrary (_T ("gx.dll")); + g_hGapiLib = LoadLibrary(_T("gx.dll")); if (!g_hGapiLib) return g_bRawBufferAvailable; } @@ -183,7 +183,7 @@ } static int -cmpmodes (const void *va, const void *vb) +cmpmodes(const void *va, const void *vb) { SDL_Rect *a = *(SDL_Rect **) va; SDL_Rect *b = *(SDL_Rect **) vb; @@ -194,7 +194,7 @@ } static int -GAPI_AddMode (_THIS, int bpp, int w, int h) +GAPI_AddMode(_THIS, int bpp, int w, int h) { SDL_Rect *mode; int i, index; @@ -213,9 +213,9 @@ } /* Set up the new video mode rectangle */ - mode = (SDL_Rect *) SDL_malloc (sizeof *mode); + mode = (SDL_Rect *) SDL_malloc(sizeof *mode); if (mode == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } mode->x = 0; @@ -226,12 +226,12 @@ /* Allocate the new list of modes, and fill in the new mode */ next_mode = gapi->SDL_nummodes[index]; gapi->SDL_modelist[index] = (SDL_Rect **) - SDL_realloc (gapi->SDL_modelist[index], - (1 + next_mode + 1) * sizeof (SDL_Rect *)); + SDL_realloc(gapi->SDL_modelist[index], + (1 + next_mode + 1) * sizeof(SDL_Rect *)); if (gapi->SDL_modelist[index] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); gapi->SDL_nummodes[index] = 0; - SDL_free (mode); + SDL_free(mode); return (-1); } gapi->SDL_modelist[index][next_mode] = mode; @@ -242,23 +242,23 @@ } static void -GAPI_DeleteDevice (SDL_VideoDevice * device) +GAPI_DeleteDevice(SDL_VideoDevice * device) { if (g_hGapiLib) { - FreeLibrary (g_hGapiLib); + FreeLibrary(g_hGapiLib); g_hGapiLib = 0; } - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -GAPI_CreateDevice (int devindex) +GAPI_CreateDevice(int devindex) { SDL_VideoDevice *device; if (!g_hGapiLib && !g_bRawBufferAvailable) { - if (!GAPI_Available ()) { + if (!GAPI_Available()) { SDL_SetError ("GAPI dll is not found and VGA mode is not available!"); return 0; @@ -266,20 +266,20 @@ } /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = GAPI_VideoInit; @@ -323,39 +323,39 @@ /* Load gapi library */ #define gx device->hidden->gxFunc - LINK (GXOpenDisplay, gx.GXOpenDisplay, - "?GXOpenDisplay@@YAHPAUHWND__@@K@Z") LINK (GXCloseDisplay, - gx.GXCloseDisplay, - "?GXCloseDisplay@@YAHXZ") - LINK (GXBeginDraw, gx.GXBeginDraw, - "?GXBeginDraw@@YAPAXXZ") LINK (GXEndDraw, gx.GXEndDraw, - "?GXEndDraw@@YAHXZ") - LINK (GXOpenInput, gx.GXOpenInput, - "?GXOpenInput@@YAHXZ") LINK (GXCloseInput, gx.GXCloseInput, - "?GXCloseInput@@YAHXZ") - LINK (GXGetDisplayProperties, gx.GXGetDisplayProperties, - "?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ") - LINK (GXGetDefaultKeys, gx.GXGetDefaultKeys, - "?GXGetDefaultKeys@@YA?AUGXKeyList@@H@Z") LINK (GXSuspend, - gx.GXSuspend, - "?GXSuspend@@YAHXZ") - LINK (GXResume, gx.GXResume, "?GXResume@@YAHXZ") LINK (GXSetViewport, - gx. - GXSetViewport, - "?GXSetViewport@@YAHKKKK@Z") - LINK (GXIsDisplayDRAMBuffer, gx.GXIsDisplayDRAMBuffer, - "?GXIsDisplayDRAMBuffer@@YAHXZ") + LINK(GXOpenDisplay, gx.GXOpenDisplay, + "?GXOpenDisplay@@YAHPAUHWND__@@K@Z") LINK(GXCloseDisplay, + gx.GXCloseDisplay, + "?GXCloseDisplay@@YAHXZ") + LINK(GXBeginDraw, gx.GXBeginDraw, + "?GXBeginDraw@@YAPAXXZ") LINK(GXEndDraw, gx.GXEndDraw, + "?GXEndDraw@@YAHXZ") + LINK(GXOpenInput, gx.GXOpenInput, + "?GXOpenInput@@YAHXZ") LINK(GXCloseInput, gx.GXCloseInput, + "?GXCloseInput@@YAHXZ") + LINK(GXGetDisplayProperties, gx.GXGetDisplayProperties, + "?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ") + LINK(GXGetDefaultKeys, gx.GXGetDefaultKeys, + "?GXGetDefaultKeys@@YA?AUGXKeyList@@H@Z") LINK(GXSuspend, + gx.GXSuspend, + "?GXSuspend@@YAHXZ") + LINK(GXResume, gx.GXResume, "?GXResume@@YAHXZ") LINK(GXSetViewport, + gx. + GXSetViewport, + "?GXSetViewport@@YAHKKKK@Z") + LINK(GXIsDisplayDRAMBuffer, gx.GXIsDisplayDRAMBuffer, + "?GXIsDisplayDRAMBuffer@@YAHXZ") /* wrong gapi.dll */ if (!gx.GXOpenDisplay) { if (g_hGapiLib) { - FreeLibrary (g_hGapiLib); + FreeLibrary(g_hGapiLib); g_hGapiLib = 0; } } if (!gx.GXOpenDisplay && !g_bRawBufferAvailable) { - SDL_SetError ("Error: damaged or unknown gapi.dll!\n"); - GAPI_DeleteDevice (device); + SDL_SetError("Error: damaged or unknown gapi.dll!\n"); + GAPI_DeleteDevice(device); return 0; } @@ -368,7 +368,7 @@ }; static void -FillStructs (_THIS, BOOL useVga) +FillStructs(_THIS, BOOL useVga) { #ifdef _ARM_ WCHAR oemstr[100]; @@ -377,7 +377,7 @@ if (!useVga) { this->hidden->gxProperties = - this->hidden->gxFunc.GXGetDisplayProperties (); + this->hidden->gxFunc.GXGetDisplayProperties(); this->hidden->needUpdate = 1; this->hidden->hiresFix = 0; this->hidden->useVga = 0; @@ -385,7 +385,7 @@ #ifdef _ARM_ /* check some devices and extract addition info */ - SystemParametersInfo (SPI_GETOEMINFO, sizeof (oemstr), oemstr, 0); + SystemParametersInfo(SPI_GETOEMINFO, sizeof(oemstr), oemstr, 0); // buggy iPaq38xx if ((oemstr[12] == 'H') && (oemstr[13] == '3') @@ -398,17 +398,17 @@ } #if (EMULATE_AXIM_X30 == 0) // buggy Dell Axim X30 - if (_tcsncmp (oemstr, L"Dell Axim X30", 13) == 0) + if (_tcsncmp(oemstr, L"Dell Axim X30", 13) == 0) #endif { GXDeviceInfo gxInfo = { 0 }; - HDC hdc = GetDC (NULL); + HDC hdc = GetDC(NULL); int result; gxInfo.Version = 100; result = - ExtEscape (hdc, GETGXINFO, 0, NULL, sizeof (gxInfo), - (char *) &gxInfo); + ExtEscape(hdc, GETGXINFO, 0, NULL, sizeof(gxInfo), + (char *) &gxInfo); if (result > 0) { this->hidden->useGXOpenDisplay = 0; this->hidden->videoMem = gxInfo.pvFrameBuffer; @@ -469,10 +469,10 @@ } static void -GAPI_CreatePalette (int ncolors, SDL_Color * colors) +GAPI_CreatePalette(int ncolors, SDL_Color * colors) { // Setup a custom color palette - BYTE buffer[sizeof (LOGPALETTE) + 255 * sizeof (PALETTEENTRY)]; + BYTE buffer[sizeof(LOGPALETTE) + 255 * sizeof(PALETTEENTRY)]; int i; LOGPALETTE *pLogical = (LOGPALETTE *) buffer; PALETTEENTRY *entries = pLogical->palPalEntry; @@ -491,41 +491,41 @@ pLogical->palVersion = 0x0300; pLogical->palNumEntries = ncolors; - hPalette = CreatePalette (pLogical); - ASSERT (hPalette); + hPalette = CreatePalette(pLogical); + ASSERT(hPalette); // Realize the palette - hdc = GetDC (0); + hdc = GetDC(0); - SelectPalette (hdc, hPalette, FALSE); - RealizePalette (hdc); + SelectPalette(hdc, hPalette, FALSE); + RealizePalette(hdc); - ReleaseDC (0, hdc); - DeleteObject (hPalette); + ReleaseDC(0, hdc); + DeleteObject(hPalette); } int -GAPI_VideoInit (_THIS, SDL_PixelFormat * vformat) +GAPI_VideoInit(_THIS, SDL_PixelFormat * vformat) { int i, bpp; /* Create the window */ - if (DIB_CreateWindow (this) < 0) { + if (DIB_CreateWindow(this) < 0) { return (-1); } if (g_hGapiLib) { - FillStructs (this, 0); + FillStructs(this, 0); // SDL does not supports 2/4bpp mode, so use 16 bpp bpp = gapi->gxProperties.cBPP < 8 ? 16 : gapi->gxProperties.cBPP; /* set up normal and landscape mode */ - GAPI_AddMode (this, bpp, gapi->gxProperties.cyHeight, - gapi->gxProperties.cxWidth); - GAPI_AddMode (this, bpp, gapi->gxProperties.cxWidth, - gapi->gxProperties.cyHeight); + GAPI_AddMode(this, bpp, gapi->gxProperties.cyHeight, + gapi->gxProperties.cxWidth); + GAPI_AddMode(this, bpp, gapi->gxProperties.cxWidth, + gapi->gxProperties.cyHeight); } /* add hi-res mode */ @@ -534,16 +534,16 @@ (unsigned) g_RawFrameBufferInfo.cxPixels) && (gapi->gxProperties.cyHeight == (unsigned) g_RawFrameBufferInfo.cyPixels))) { - FillStructs (this, 1); + FillStructs(this, 1); // SDL does not supports 2/4bpp mode, so use 16 bpp bpp = gapi->gxProperties.cBPP < 8 ? 16 : gapi->gxProperties.cBPP; /* set up normal and landscape mode */ - GAPI_AddMode (this, bpp, gapi->gxProperties.cyHeight, - gapi->gxProperties.cxWidth); - GAPI_AddMode (this, bpp, gapi->gxProperties.cxWidth, - gapi->gxProperties.cyHeight); + GAPI_AddMode(this, bpp, gapi->gxProperties.cyHeight, + gapi->gxProperties.cxWidth); + GAPI_AddMode(this, bpp, gapi->gxProperties.cxWidth, + gapi->gxProperties.cyHeight); } /* Determine the current screen size */ @@ -553,8 +553,8 @@ /* Sort the mode lists */ for (i = 0; i < NUM_MODELISTS; ++i) { if (gapi->SDL_nummodes[i] > 0) { - SDL_qsort (gapi->SDL_modelist[i], gapi->SDL_nummodes[i], - sizeof *gapi->SDL_modelist[i], cmpmodes); + SDL_qsort(gapi->SDL_modelist[i], gapi->SDL_nummodes[i], + sizeof *gapi->SDL_modelist[i], cmpmodes); } } @@ -597,15 +597,15 @@ } SDL_Rect ** -GAPI_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +GAPI_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { return (this->hidden->SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]); // return (SDL_Rect **) -1; } SDL_Surface * -GAPI_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +GAPI_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { SDL_Surface *video; Uint32 Rmask, Gmask, Bmask; @@ -613,7 +613,7 @@ SDL_Rect allScreen; if (bpp < 4) { - SDL_SetError ("1 bpp and 2 bpp modes is not implemented yet!"); + SDL_SetError("1 bpp and 2 bpp modes is not implemented yet!"); return 0; } @@ -647,13 +647,13 @@ Bmask = 0x000000ff; break; default: - SDL_SetError ("Unsupported Bits Per Pixel format requested"); + SDL_SetError("Unsupported Bits Per Pixel format requested"); return NULL; } - video = SDL_CreateRGBSurface (SDL_SWSURFACE, - 0, 0, bpp, Rmask, Gmask, Bmask, 0); + video = SDL_CreateRGBSurface(SDL_SWSURFACE, + 0, 0, bpp, Rmask, Gmask, Bmask, 0); if (video == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } } @@ -663,14 +663,14 @@ /* GAPI or VGA? */ if (g_hGapiLib) { - FillStructs (this, 0); + FillStructs(this, 0); if ((((unsigned) width != gapi->gxProperties.cxWidth) || ((unsigned) height != gapi->gxProperties.cyHeight)) && (((unsigned) width != gapi->gxProperties.cyHeight) || ((unsigned) height != gapi->gxProperties.cxWidth))) - FillStructs (this, 1); // gapi is found but we use VGA resolution + FillStructs(this, 1); // gapi is found but we use VGA resolution } else - FillStructs (this, 1); + FillStructs(this, 1); if (!this->hidden->needUpdate && !this->hidden->videoMem) { SDL_SetError @@ -680,18 +680,18 @@ /* detect user landscape mode */ if ((width > height) - && (GetSystemMetrics (SM_CXSCREEN) < GetSystemMetrics (SM_CYSCREEN))) + && (GetSystemMetrics(SM_CXSCREEN) < GetSystemMetrics(SM_CYSCREEN))) gapi->userOrientation = SDL_ORIENTATION_RIGHT; /* shall we apply hires fix? for example when we do not use hires resource */ gapi->hiresFix = 0; if (gapi->userOrientation == SDL_ORIENTATION_RIGHT) { - if ((width > GetSystemMetrics (SM_CYSCREEN)) - || (height > GetSystemMetrics (SM_CXSCREEN))) + if ((width > GetSystemMetrics(SM_CYSCREEN)) + || (height > GetSystemMetrics(SM_CXSCREEN))) gapi->hiresFix = 1; - } else if ((width > GetSystemMetrics (SM_CXSCREEN)) - || (height > GetSystemMetrics (SM_CYSCREEN))) - if (!((width == GetSystemMetrics (SM_CYSCREEN)) && (height == GetSystemMetrics (SM_CXSCREEN)))) // user portrait, device landscape + } else if ((width > GetSystemMetrics(SM_CXSCREEN)) + || (height > GetSystemMetrics(SM_CYSCREEN))) + if (!((width == GetSystemMetrics(SM_CYSCREEN)) && (height == GetSystemMetrics(SM_CXSCREEN)))) // user portrait, device landscape gapi->hiresFix = 1; switch (gapi->userOrientation) { @@ -720,7 +720,7 @@ video->w = this->hidden->w = width; video->h = this->hidden->h = height; - video->pitch = SDL_CalculatePitch (video); + video->pitch = SDL_CalculatePitch(video); /* Small fix for WinCE/Win32 - when activating window SDL_VideoSurface is equal to zero, so activating code @@ -733,61 +733,61 @@ style = 0; if (!SDL_windowid) - SetWindowLong (SDL_Window, GWL_STYLE, style); + SetWindowLong(SDL_Window, GWL_STYLE, style); /* Allocate bitmap */ if (gapiBuffer) { - SDL_free (gapiBuffer); + SDL_free(gapiBuffer); gapiBuffer = NULL; } - gapiBuffer = SDL_malloc (video->h * video->pitch); + gapiBuffer = SDL_malloc(video->h * video->pitch); video->pixels = gapiBuffer; if (!this->hidden->buffer) { - SDL_SetError ("Couldn't allocate buffer for requested mode"); + SDL_SetError("Couldn't allocate buffer for requested mode"); return (NULL); } - SDL_memset (gapiBuffer, 255, video->h * video->pitch); - MoveWindow (SDL_Window, 0, 0, GetSystemMetrics (SM_CXSCREEN), - GetSystemMetrics (SM_CYSCREEN), FALSE); - ShowWindow (SDL_Window, SW_SHOW); - SetForegroundWindow (SDL_Window); + SDL_memset(gapiBuffer, 255, video->h * video->pitch); + MoveWindow(SDL_Window, 0, 0, GetSystemMetrics(SM_CXSCREEN), + GetSystemMetrics(SM_CYSCREEN), FALSE); + ShowWindow(SDL_Window, SW_SHOW); + SetForegroundWindow(SDL_Window); /* JC 14 Mar 2006 Flush the message loop or this can cause big problems later Especially if the user decides to use dialog boxes or assert()! */ - WIN_FlushMessageQueue (); + WIN_FlushMessageQueue(); /* Open GAPI display */ if (!gapi->useVga && this->hidden->useGXOpenDisplay) - if (!gapi->gxFunc.GXOpenDisplay (SDL_Window, GX_FULLSCREEN)) { - SDL_SetError ("Couldn't initialize GAPI"); + if (!gapi->gxFunc.GXOpenDisplay(SDL_Window, GX_FULLSCREEN)) { + SDL_SetError("Couldn't initialize GAPI"); return (NULL); } #if REPORT_VIDEO_INFO - printf ("Video properties:\n"); - printf ("display bpp: %d\n", gapi->gxProperties.cBPP); - printf ("display width: %d\n", gapi->gxProperties.cxWidth); - printf ("display height: %d\n", gapi->gxProperties.cyHeight); - printf ("x pitch: %d\n", gapi->gxProperties.cbxPitch); - printf ("y pitch: %d\n", gapi->gxProperties.cbyPitch); - printf ("gapi flags: 0x%x\n", gapi->gxProperties.ffFormat); + printf("Video properties:\n"); + printf("display bpp: %d\n", gapi->gxProperties.cBPP); + printf("display width: %d\n", gapi->gxProperties.cxWidth); + printf("display height: %d\n", gapi->gxProperties.cyHeight); + printf("x pitch: %d\n", gapi->gxProperties.cbxPitch); + printf("y pitch: %d\n", gapi->gxProperties.cbyPitch); + printf("gapi flags: 0x%x\n", gapi->gxProperties.ffFormat); if (!gapi->useVga && this->hidden->useGXOpenDisplay && gapi->needUpdate) { - gapi->videoMem = gapi->gxFunc.GXBeginDraw (); - gapi->gxFunc.GXEndDraw (); + gapi->videoMem = gapi->gxFunc.GXBeginDraw(); + gapi->gxFunc.GXEndDraw(); } - printf ("video memory: 0x%x\n", gapi->videoMem); - printf ("need update: %d\n", gapi->needUpdate); - printf ("hi-res fix: %d\n", gapi->hiresFix); - printf ("VGA is available on the device: %d\n", g_bRawBufferAvailable); - printf ("use raw framebuffer: %d\n", gapi->useVga); - printf ("video surface bpp: %d\n", video->format->BitsPerPixel); - printf ("video surface width: %d\n", video->w); - printf ("video surface height: %d\n", video->h); + printf("video memory: 0x%x\n", gapi->videoMem); + printf("need update: %d\n", gapi->needUpdate); + printf("hi-res fix: %d\n", gapi->hiresFix); + printf("VGA is available on the device: %d\n", g_bRawBufferAvailable); + printf("use raw framebuffer: %d\n", gapi->useVga); + printf("video surface bpp: %d\n", video->format->BitsPerPixel); + printf("video surface width: %d\n", video->w); + printf("video surface height: %d\n", video->h); #endif @@ -795,7 +795,7 @@ allScreen.x = allScreen.y = 0; allScreen.w = video->w - 1; allScreen.h = video->h - 1; - GAPI_UpdateRects (this, 1, &allScreen); + GAPI_UpdateRects(this, 1, &allScreen); /* We're done */ return (video); @@ -803,35 +803,35 @@ /* We don't actually allow hardware surfaces other than the main one */ static int -GAPI_AllocHWSurface (_THIS, SDL_Surface * surface) +GAPI_AllocHWSurface(_THIS, SDL_Surface * surface) { return (-1); } static void -GAPI_FreeHWSurface (_THIS, SDL_Surface * surface) +GAPI_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } /* We need to wait for vertical retrace on page flipped displays */ static int -GAPI_LockHWSurface (_THIS, SDL_Surface * surface) +GAPI_LockHWSurface(_THIS, SDL_Surface * surface) { return (0); } static void -GAPI_UnlockHWSurface (_THIS, SDL_Surface * surface) +GAPI_UnlockHWSurface(_THIS, SDL_Surface * surface) { return; } static int -updateLine8to8 (_THIS, unsigned char *srcPointer, unsigned char *destPointer, - int width, int height, int lines) +updateLine8to8(_THIS, unsigned char *srcPointer, unsigned char *destPointer, + int width, int height, int lines) { if (gapi->dstPixelStep == 1) { /* optimized blitting on most devices */ - SDL_memcpy (destPointer, srcPointer, width); + SDL_memcpy(destPointer, srcPointer, width); return 1; } else { // TODO: read 4 pixels, write DWORD @@ -846,14 +846,14 @@ /* Video memory is very slow so lets optimize as much as possible */ static int -updateLine16to16 (_THIS, PIXEL * srcPointer, PIXEL * destPointer, int width, - int height, int lines) +updateLine16to16(_THIS, PIXEL * srcPointer, PIXEL * destPointer, int width, + int height, int lines) { PIXEL *line1, *line2; int step = gapi->dstPixelStep / 2; if (step == 1) { /* optimized blitting on most devices */ - SDL_memcpy (destPointer, srcPointer, width * sizeof (PIXEL)); + SDL_memcpy(destPointer, srcPointer, width * sizeof(PIXEL)); return 1; } else { if ((gapi->gapiOrientation != SDL_ORIENTATION_UP) && (gapi->userOrientation == SDL_ORIENTATION_UP)) // iPaq 3660/3800 and user orientation up @@ -950,8 +950,8 @@ static int -updateLine16to4 (_THIS, PIXEL * srcPointer, unsigned char *destPointer, - int width, int height, int lines, int yNibble, int xNibble) +updateLine16to4(_THIS, PIXEL * srcPointer, unsigned char *destPointer, + int width, int height, int lines, int yNibble, int xNibble) { PIXEL *line1, *line2; int step = gapi->dstPixelStep; @@ -1031,7 +1031,7 @@ } static void -GAPI_UpdateRectsMono (_THIS, int numrects, SDL_Rect * rects) +GAPI_UpdateRectsMono(_THIS, int numrects, SDL_Rect * rects) { int i, height; int linesProcessed; @@ -1063,9 +1063,9 @@ case 2: // TODO case 4: linesProcessed = - updateLine16to4 (this, (PIXEL *) srcPointer, - destPointer, rects[i].w, - rects[i].h, height, yNibble, xNibble); + updateLine16to4(this, (PIXEL *) srcPointer, + destPointer, rects[i].w, + rects[i].h, height, yNibble, xNibble); yNibble = 0; } height -= linesProcessed; @@ -1079,7 +1079,7 @@ } static void -GAPI_UpdateRectsColor (_THIS, int numrects, SDL_Rect * rects) +GAPI_UpdateRectsColor(_THIS, int numrects, SDL_Rect * rects) { int i, height; int bytesPerPixel = (gapi->gxProperties.cBPP + 1) / 8; @@ -1101,16 +1101,16 @@ switch (bytesPerPixel) { case 1: linesProcessed = - updateLine8to8 (this, srcPointer, - (unsigned char *) destPointer, - rects[i].w, rects[i].h, height); + updateLine8to8(this, srcPointer, + (unsigned char *) destPointer, + rects[i].w, rects[i].h, height); break; case 2: #pragma warning(disable: 4133) linesProcessed = - updateLine16to16 (this, (PIXEL *) srcPointer, - destPointer, rects[i].w, - rects[i].h, height); + updateLine16to16(this, (PIXEL *) srcPointer, + destPointer, rects[i].w, + rects[i].h, height); break; } height -= linesProcessed; @@ -1124,55 +1124,55 @@ static void -GAPI_UpdateRects (_THIS, int numrects, SDL_Rect * rects) +GAPI_UpdateRects(_THIS, int numrects, SDL_Rect * rects) { // we do not want to corrupt video memory if (gapi->suspended) return; if (gapi->needUpdate) - gapi->videoMem = gapi->gxFunc.GXBeginDraw (); + gapi->videoMem = gapi->gxFunc.GXBeginDraw(); if (gapi->gxProperties.cBPP < 8) - GAPI_UpdateRectsMono (this, numrects, rects); + GAPI_UpdateRectsMono(this, numrects, rects); else - GAPI_UpdateRectsColor (this, numrects, rects); + GAPI_UpdateRectsColor(this, numrects, rects); if (gapi->needUpdate) - gapi->gxFunc.GXEndDraw (); + gapi->gxFunc.GXEndDraw(); } /* Note: If we are terminated, this could be called in the middle of another SDL video routine -- notably UpdateRects. */ void -GAPI_VideoQuit (_THIS) +GAPI_VideoQuit(_THIS) { int i, j; /* Destroy the window and everything associated with it */ if (SDL_Window) { if ((g_hGapiLib != 0) && this && this->hidden && this->hidden->gxFunc.GXCloseDisplay && !this->hidden->useVga) - this->hidden->gxFunc.GXCloseDisplay (); + this->hidden->gxFunc.GXCloseDisplay(); if (this->screen->pixels != NULL) { - SDL_free (this->screen->pixels); + SDL_free(this->screen->pixels); this->screen->pixels = NULL; } if (screen_icn) { - DestroyIcon (screen_icn); + DestroyIcon(screen_icn); screen_icn = NULL; } - DIB_DestroyWindow (this); - SDL_UnregisterApp (); + DIB_DestroyWindow(this); + SDL_UnregisterApp(); SDL_Window = NULL; #if defined(_WIN32_WCE) // Unload wince aygshell library to prevent leak if (aygshell) { - FreeLibrary (aygshell); + FreeLibrary(aygshell); aygshell = NULL; } #endif @@ -1181,8 +1181,8 @@ for (i = 0; i < NUM_MODELISTS; ++i) { if (gapi->SDL_modelist[i] != NULL) { for (j = 0; gapi->SDL_modelist[i][j]; ++j) - SDL_free (gapi->SDL_modelist[i][j]); - SDL_free (gapi->SDL_modelist[i]); + SDL_free(gapi->SDL_modelist[i][j]); + SDL_free(gapi->SDL_modelist[i]); gapi->SDL_modelist[i] = NULL; } } @@ -1192,19 +1192,19 @@ } static void -GAPI_RealizePalette (_THIS) +GAPI_RealizePalette(_THIS) { - OutputDebugString (TEXT ("GAPI_RealizePalette NOT IMPLEMENTED !\r\n")); + OutputDebugString(TEXT("GAPI_RealizePalette NOT IMPLEMENTED !\r\n")); } static void -GAPI_PaletteChanged (_THIS, HWND window) +GAPI_PaletteChanged(_THIS, HWND window) { - OutputDebugString (TEXT ("GAPI_PaletteChanged NOT IMPLEMENTED !\r\n")); + OutputDebugString(TEXT("GAPI_PaletteChanged NOT IMPLEMENTED !\r\n")); } static void -GAPI_WinPAINT (_THIS, HDC hdc) +GAPI_WinPAINT(_THIS, HDC hdc) { // draw current offscreen buffer on hdc @@ -1215,7 +1215,7 @@ HDC srcDC; // Create a DIB - BYTE buffer[sizeof (BITMAPINFOHEADER) + 3 * sizeof (RGBQUAD)] = { 0 }; + BYTE buffer[sizeof(BITMAPINFOHEADER) + 3 * sizeof(RGBQUAD)] = { 0 }; BITMAPINFO *pBMI = (BITMAPINFO *) buffer; BITMAPINFOHEADER *pHeader = &pBMI->bmiHeader; DWORD *pColors = (DWORD *) & pBMI->bmiColors; @@ -1225,7 +1225,7 @@ return; // DIB Header - pHeader->biSize = sizeof (BITMAPINFOHEADER); + pHeader->biSize = sizeof(BITMAPINFOHEADER); pHeader->biWidth = this->hidden->w; pHeader->biHeight = -this->hidden->h; pHeader->biPlanes = 1; @@ -1241,26 +1241,25 @@ pHeader->biCompression = BI_BITFIELDS; } // Create the DIB - hb = CreateDIBSection (0, pBMI, DIB_RGB_COLORS, (void **) &bitmapData, 0, - 0); + hb = CreateDIBSection(0, pBMI, DIB_RGB_COLORS, (void **) &bitmapData, 0, + 0); // copy data // FIXME: prevent misalignment, but I've never seen non aligned width of screen - memcpy (bitmapData, this->hidden->buffer, pHeader->biSizeImage); - srcDC = CreateCompatibleDC (hdc); - SelectObject (srcDC, hb); + memcpy(bitmapData, this->hidden->buffer, pHeader->biSizeImage); + srcDC = CreateCompatibleDC(hdc); + SelectObject(srcDC, hb); - BitBlt (hdc, 0, 0, this->hidden->w, this->hidden->h, srcDC, 0, 0, - SRCCOPY); + BitBlt(hdc, 0, 0, this->hidden->w, this->hidden->h, srcDC, 0, 0, SRCCOPY); - DeleteObject (hb); - DeleteDC (srcDC); + DeleteObject(hb); + DeleteDC(srcDC); } int -GAPI_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +GAPI_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { - GAPI_CreatePalette (ncolors, colors); + GAPI_CreatePalette(ncolors, colors); return 1; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/gapi/SDL_gapivideo.h --- a/src/video/gapi/SDL_gapivideo.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/gapi/SDL_gapivideo.h Mon May 29 04:04:35 2006 +0000 @@ -72,7 +72,7 @@ typedef int (*PFNGXResume) (); typedef int (*PFNGXSetViewport) (DWORD dwTop, DWORD dwHeight, DWORD dwReserved1, DWORD dwReserved2); -typedef BOOL (*PFNGXIsDisplayDRAMBuffer) (); +typedef BOOL(*PFNGXIsDisplayDRAMBuffer) (); struct GapiFunc { diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/gem/SDL_gemevents.c --- a/src/video/gem/SDL_gemevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/gem/SDL_gemevents.c Mon May 29 04:04:35 2006 +0000 @@ -56,17 +56,17 @@ /* Functions prototypes */ -static SDL_keysym *TranslateKey (int scancode, int asciicode, - SDL_keysym * keysym, SDL_bool pressed); -static int do_messages (_THIS, short *message); -static void do_keyboard (short kc, short ks); -static void do_mouse (_THIS, short mx, short my, short mb, short ks); +static SDL_keysym *TranslateKey(int scancode, int asciicode, + SDL_keysym * keysym, SDL_bool pressed); +static int do_messages(_THIS, short *message); +static void do_keyboard(short kc, short ks); +static void do_mouse(_THIS, short mx, short my, short mb, short ks); /* Functions */ static SDL_keysym * -TranslateKey (int scancode, int asciicode, SDL_keysym * keysym, - SDL_bool pressed) +TranslateKey(int scancode, int asciicode, SDL_keysym * keysym, + SDL_bool pressed) { /* Set the keysym information */ keysym->scancode = scancode; @@ -86,16 +86,16 @@ } void -GEM_InitOSKeymap (_THIS) +GEM_InitOSKeymap(_THIS) { int i; - SDL_memset (gem_currentkeyboard, 0, sizeof (gem_currentkeyboard)); - SDL_memset (gem_previouskeyboard, 0, sizeof (gem_previouskeyboard)); - SDL_memset (gem_currentascii, 0, sizeof (gem_currentascii)); + SDL_memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard)); + SDL_memset(gem_previouskeyboard, 0, sizeof(gem_previouskeyboard)); + SDL_memset(gem_currentascii, 0, sizeof(gem_currentascii)); /* Initialize keymap */ - for (i = 0; i < sizeof (keymap); i++) + for (i = 0; i < sizeof(keymap); i++) keymap[i] = SDLK_UNKNOWN; /* Functions keys */ @@ -129,14 +129,14 @@ } void -GEM_PumpEvents (_THIS) +GEM_PumpEvents(_THIS) { short mousex, mousey, mouseb, dummy; short kstate, prevkc, prevks; int i; SDL_keysym keysym; - SDL_memset (gem_currentkeyboard, 0, sizeof (gem_currentkeyboard)); + SDL_memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard)); prevkc = prevks = 0; for (;;) { @@ -148,31 +148,31 @@ event_mask = MU_MESAG | MU_TIMER | MU_KEYBD; if (!GEM_fullscreen && (GEM_handle >= 0)) { - wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2); + wind_get(GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2); event_mask |= MU_M1; - if ((SDL_GetAppState () & SDL_APPMOUSEFOCUS)) { + if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS)) { mouse_event = MO_LEAVE; } else { mouse_event = MO_ENTER; } } - resultat = evnt_multi (event_mask, - 0, 0, 0, - mouse_event, x2, y2, w2, h2, - 0, 0, 0, 0, 0, - buffer, - 10, - &dummy, &dummy, &dummy, &kstate, &kc, &dummy); + resultat = evnt_multi(event_mask, + 0, 0, 0, + mouse_event, x2, y2, w2, h2, + 0, 0, 0, 0, 0, + buffer, + 10, + &dummy, &dummy, &dummy, &kstate, &kc, &dummy); /* Message event ? */ if (resultat & MU_MESAG) - quit = do_messages (this, buffer); + quit = do_messages(this, buffer); /* Keyboard event ? */ if (resultat & MU_KEYBD) { if ((prevkc != kc) || (prevks != kstate)) { - do_keyboard (kc, kstate); + do_keyboard(kc, kstate); } else { /* Avoid looping, if repeating same key */ break; @@ -182,10 +182,10 @@ /* Mouse entering/leaving window */ if (resultat & MU_M1) { if (this->input_grab == SDL_GRAB_OFF) { - if (SDL_GetAppState () & SDL_APPMOUSEFOCUS) { - SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); + if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) { + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } else { - SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); } } } @@ -196,46 +196,46 @@ } /* Update mouse */ - graf_mkstate (&mousex, &mousey, &mouseb, &kstate); - do_mouse (this, mousex, mousey, mouseb, kstate); + graf_mkstate(&mousex, &mousey, &mouseb, &kstate); + do_mouse(this, mousex, mousey, mouseb, kstate); /* Now generate keyboard events */ for (i = 0; i < ATARIBIOS_MAXKEYS; i++) { /* Key pressed ? */ if (gem_currentkeyboard[i] && !gem_previouskeyboard[i]) - SDL_PrivateKeyboard (SDL_PRESSED, - TranslateKey (i, gem_currentascii[i], - &keysym, SDL_TRUE)); + SDL_PrivateKeyboard(SDL_PRESSED, + TranslateKey(i, gem_currentascii[i], + &keysym, SDL_TRUE)); /* Key unpressed ? */ if (gem_previouskeyboard[i] && !gem_currentkeyboard[i]) - SDL_PrivateKeyboard (SDL_RELEASED, - TranslateKey (i, gem_currentascii[i], - &keysym, SDL_FALSE)); + SDL_PrivateKeyboard(SDL_RELEASED, + TranslateKey(i, gem_currentascii[i], + &keysym, SDL_FALSE)); } - SDL_memcpy (gem_previouskeyboard, gem_currentkeyboard, - sizeof (gem_previouskeyboard)); + SDL_memcpy(gem_previouskeyboard, gem_currentkeyboard, + sizeof(gem_previouskeyboard)); /* Refresh window name ? */ if (GEM_refresh_name) { - if (SDL_GetAppState () & SDL_APPACTIVE) { + if (SDL_GetAppState() & SDL_APPACTIVE) { /* Fullscreen/windowed */ if (GEM_title_name) { - wind_set (GEM_handle, WF_NAME, - (short) (((unsigned long) GEM_title_name) >> - 16), - (short) (((unsigned long) GEM_title_name) & - 0xffff), 0, 0); + wind_set(GEM_handle, WF_NAME, + (short) (((unsigned long) GEM_title_name) >> + 16), + (short) (((unsigned long) GEM_title_name) & + 0xffff), 0, 0); } } else { /* Iconified */ if (GEM_icon_name) { - wind_set (GEM_handle, WF_NAME, - (short) (((unsigned long) GEM_icon_name) >> - 16), - (short) (((unsigned long) GEM_icon_name) & - 0xffff), 0, 0); + wind_set(GEM_handle, WF_NAME, + (short) (((unsigned long) GEM_icon_name) >> + 16), + (short) (((unsigned long) GEM_icon_name) & + 0xffff), 0, 0); } } GEM_refresh_name = SDL_FALSE; @@ -243,7 +243,7 @@ } static int -do_messages (_THIS, short *message) +do_messages(_THIS, short *message) { int quit, posted; short x2, y2, w2, h2; @@ -252,75 +252,75 @@ switch (message[0]) { case WM_CLOSED: case AP_TERM: - posted = SDL_PrivateQuit (); + posted = SDL_PrivateQuit(); quit = 1; break; case WM_MOVED: - wind_set (message[3], WF_CURRXYWH, message[4], message[5], - message[6], message[7]); + wind_set(message[3], WF_CURRXYWH, message[4], message[5], + message[6], message[7]); break; case WM_TOPPED: - wind_set (message[3], WF_TOP, message[4], 0, 0, 0); + wind_set(message[3], WF_TOP, message[4], 0, 0, 0); /* Continue with TOP event processing */ case WM_ONTOP: - SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS); + SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); if (VDI_setpalette) { - VDI_setpalette (this, VDI_curpalette); + VDI_setpalette(this, VDI_curpalette); } break; case WM_REDRAW: if (!GEM_lock_redraw) { - GEM_wind_redraw (this, message[3], &message[4]); + GEM_wind_redraw(this, message[3], &message[4]); } break; case WM_ICONIFY: case WM_ALLICONIFY: - wind_set (message[3], WF_ICONIFY, message[4], message[5], - message[6], message[7]); + wind_set(message[3], WF_ICONIFY, message[4], message[5], + message[6], message[7]); /* If we're active, make ourselves inactive */ - if (SDL_GetAppState () & SDL_APPACTIVE) { + if (SDL_GetAppState() & SDL_APPACTIVE) { /* Send an internal deactivate event */ - SDL_PrivateAppActive (0, SDL_APPACTIVE); + SDL_PrivateAppActive(0, SDL_APPACTIVE); } /* Update window title */ if (GEM_refresh_name && GEM_icon_name) { - wind_set (GEM_handle, WF_NAME, - (short) (((unsigned long) GEM_icon_name) >> 16), - (short) (((unsigned long) GEM_icon_name) & 0xffff), - 0, 0); + wind_set(GEM_handle, WF_NAME, + (short) (((unsigned long) GEM_icon_name) >> 16), + (short) (((unsigned long) GEM_icon_name) & 0xffff), + 0, 0); GEM_refresh_name = SDL_FALSE; } break; case WM_UNICONIFY: - wind_set (message[3], WF_UNICONIFY, message[4], message[5], - message[6], message[7]); + wind_set(message[3], WF_UNICONIFY, message[4], message[5], + message[6], message[7]); /* If we're not active, make ourselves active */ - if (!(SDL_GetAppState () & SDL_APPACTIVE)) { + if (!(SDL_GetAppState() & SDL_APPACTIVE)) { /* Send an internal activate event */ - SDL_PrivateAppActive (1, SDL_APPACTIVE); + SDL_PrivateAppActive(1, SDL_APPACTIVE); } if (GEM_refresh_name && GEM_title_name) { - wind_set (GEM_handle, WF_NAME, - (short) (((unsigned long) GEM_title_name) >> 16), - (short) (((unsigned long) GEM_title_name) & 0xffff), - 0, 0); + wind_set(GEM_handle, WF_NAME, + (short) (((unsigned long) GEM_title_name) >> 16), + (short) (((unsigned long) GEM_title_name) & 0xffff), + 0, 0); GEM_refresh_name = SDL_FALSE; } break; case WM_SIZED: - wind_set (message[3], WF_CURRXYWH, message[4], message[5], - message[6], message[7]); - wind_get (message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2); + wind_set(message[3], WF_CURRXYWH, message[4], message[5], + message[6], message[7]); + wind_get(message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2); GEM_win_fulled = SDL_FALSE; /* Cancel maximized flag */ GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers resized */ - SDL_PrivateResize (w2, h2); + SDL_PrivateResize(w2, h2); break; case WM_FULLED: { short x, y, w, h; if (GEM_win_fulled) { - wind_get (message[3], WF_PREVXYWH, &x, &y, &w, &h); + wind_get(message[3], WF_PREVXYWH, &x, &y, &w, &h); GEM_win_fulled = SDL_FALSE; } else { x = GEM_desk_x; @@ -329,19 +329,19 @@ h = GEM_desk_h; GEM_win_fulled = SDL_TRUE; } - wind_set (message[3], WF_CURRXYWH, x, y, w, h); - wind_get (message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2); + wind_set(message[3], WF_CURRXYWH, x, y, w, h); + wind_get(message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2); GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers resized */ - SDL_PrivateResize (w2, h2); + SDL_PrivateResize(w2, h2); } break; case WM_BOTTOMED: - wind_set (message[3], WF_BOTTOM, 0, 0, 0, 0); + wind_set(message[3], WF_BOTTOM, 0, 0, 0, 0); /* Continue with BOTTOM event processing */ case WM_UNTOPPED: - SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS); + SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); if (VDI_setpalette) { - VDI_setpalette (this, VDI_oldpalette); + VDI_setpalette(this, VDI_oldpalette); } break; } @@ -350,7 +350,7 @@ } static void -do_keyboard (short kc, short ks) +do_keyboard(short kc, short ks) { int scancode, asciicode; @@ -374,13 +374,13 @@ } static void -do_mouse (_THIS, short mx, short my, short mb, short ks) +do_mouse(_THIS, short mx, short my, short mb, short ks) { static short prevmousex = 0, prevmousey = 0, prevmouseb = 0; short x2, y2, w2, h2; /* Don't return mouse events if out of window */ - if ((SDL_GetAppState () & SDL_APPMOUSEFOCUS) == 0) { + if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) == 0) { return; } @@ -389,7 +389,7 @@ w2 = VDI_w; h2 = VDI_h; if ((!GEM_fullscreen) && (GEM_handle >= 0)) { - wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2); + wind_get(GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2); /* Do not generate mouse button event if out of window working area */ if ((mx < x2) || (mx >= x2 + w2) || (my < y2) || (my >= y2 + h2)) { @@ -400,9 +400,9 @@ /* Mouse motion ? */ if (GEM_mouse_relative) { if (GEM_usedevmouse) { - SDL_AtariDevMouse_PostMouseEvents (this, SDL_FALSE); + SDL_AtariDevMouse_PostMouseEvents(this, SDL_FALSE); } else { - SDL_AtariXbios_PostMouseEvents (this, SDL_FALSE); + SDL_AtariXbios_PostMouseEvents(this, SDL_FALSE); } } else { if ((prevmousex != mx) || (prevmousey != my)) { @@ -420,7 +420,7 @@ if (posy > h2) posy = h2 - 1; - SDL_PrivateMouseMotion (0, 0, posx, posy); + SDL_PrivateMouseMotion(0, 0, posx, posy); } prevmousex = mx; prevmousey = my; @@ -437,10 +437,10 @@ prevbutton = prevmouseb & (1 << i); if (curbutton && !prevbutton) { - SDL_PrivateMouseButton (SDL_PRESSED, i + 1, 0, 0); + SDL_PrivateMouseButton(SDL_PRESSED, i + 1, 0, 0); } if (!curbutton && prevbutton) { - SDL_PrivateMouseButton (SDL_RELEASED, i + 1, 0, 0); + SDL_PrivateMouseButton(SDL_RELEASED, i + 1, 0, 0); } } prevmouseb = mb; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/gem/SDL_gemevents_c.h --- a/src/video/gem/SDL_gemevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/gem/SDL_gemevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -26,8 +26,8 @@ /* Variables and functions exported by SDL_sysevents.c to other parts of the native video subsystem (SDL_sysvideo.c) */ -extern void GEM_InitOSKeymap (_THIS); -extern void GEM_PumpEvents (_THIS); +extern void GEM_InitOSKeymap(_THIS); +extern void GEM_PumpEvents(_THIS); /* end of SDL_gemevents_c.h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/gem/SDL_gemmouse.c --- a/src/video/gem/SDL_gemmouse.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/gem/SDL_gemmouse.c Mon May 29 04:04:35 2006 +0000 @@ -49,23 +49,23 @@ void -GEM_FreeWMCursor (_THIS, WMcursor * cursor) +GEM_FreeWMCursor(_THIS, WMcursor * cursor) { if (cursor == NULL) return; - graf_mouse (ARROW, NULL); + graf_mouse(ARROW, NULL); if (cursor->mform_p != NULL) - SDL_free (cursor->mform_p); + SDL_free(cursor->mform_p); - SDL_free (cursor); + SDL_free(cursor); } WMcursor * -GEM_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, int hot_x, - int hot_y) +GEM_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, int hot_x, + int hot_y) { WMcursor *cursor; MFORM *new_mform; @@ -73,23 +73,23 @@ /* Check the size */ if ((w > MAXCURWIDTH) || (h > MAXCURHEIGHT)) { - SDL_SetError ("Only cursors of dimension (%dx%d) are allowed", - MAXCURWIDTH, MAXCURHEIGHT); + SDL_SetError("Only cursors of dimension (%dx%d) are allowed", + MAXCURWIDTH, MAXCURHEIGHT); return (NULL); } /* Allocate the cursor memory */ - cursor = (WMcursor *) SDL_malloc (sizeof (WMcursor)); + cursor = (WMcursor *) SDL_malloc(sizeof(WMcursor)); if (cursor == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } /* Allocate mform */ - new_mform = (MFORM *) SDL_malloc (sizeof (MFORM)); + new_mform = (MFORM *) SDL_malloc(sizeof(MFORM)); if (new_mform == NULL) { - SDL_free (cursor); - SDL_OutOfMemory (); + SDL_free(cursor); + SDL_OutOfMemory(); return (NULL); } @@ -120,18 +120,18 @@ #ifdef DEBUG_VIDEO_GEM for (i = 0; i < h; i++) { - printf ("sdl:video:gem: cursor, line %d = 0x%04x\n", i, - new_mform->mf_mask[i]); + printf("sdl:video:gem: cursor, line %d = 0x%04x\n", i, + new_mform->mf_mask[i]); } - printf ("sdl:video:gem: CreateWMCursor(): done\n"); + printf("sdl:video:gem: CreateWMCursor(): done\n"); #endif return cursor; } int -GEM_ShowWMCursor (_THIS, WMcursor * cursor) +GEM_ShowWMCursor(_THIS, WMcursor * cursor) { /* if (cursor == NULL) { @@ -141,7 +141,7 @@ } */ #ifdef DEBUG_VIDEO_GEM - printf ("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor); + printf("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor); #endif return 1; @@ -149,7 +149,7 @@ #if 0 void -GEM_WarpWMCursor (_THIS, Uint16 x, Uint16 y) +GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { /* This seems to work only on AES 3.4 (Falcon) */ @@ -158,17 +158,17 @@ warpevent.ap_event = APPEVNT_MOUSE; warpevent.ap_value = (x << 16) | y; - appl_tplay (&warpevent, 1, 1000); + appl_tplay(&warpevent, 1, 1000); } #endif void -GEM_CheckMouseMode (_THIS) +GEM_CheckMouseMode(_THIS) { /* If the mouse is hidden and input is grabbed, we use relative mode */ if ((!(SDL_cursorstate & CURSOR_VISIBLE)) && /*(this->input_grab != SDL_GRAB_OFF) && *//* Damn GEM can not grab */ - (SDL_GetAppState () & SDL_APPACTIVE)) { + (SDL_GetAppState() & SDL_APPACTIVE)) { GEM_mouse_relative = SDL_TRUE; } else { GEM_mouse_relative = SDL_FALSE; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/gem/SDL_gemmouse_c.h --- a/src/video/gem/SDL_gemmouse_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/gem/SDL_gemmouse_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,13 +24,13 @@ #include "SDL_gemvideo.h" /* Functions to be exported */ -extern void GEM_FreeWMCursor (_THIS, WMcursor * cursor); -extern WMcursor *GEM_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, - int hot_x, int hot_y); -extern int GEM_ShowWMCursor (_THIS, WMcursor * cursor); +extern void GEM_FreeWMCursor(_THIS, WMcursor * cursor); +extern WMcursor *GEM_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, + int hot_x, int hot_y); +extern int GEM_ShowWMCursor(_THIS, WMcursor * cursor); #if 0 -extern void GEM_WarpWMCursor (_THIS, Uint16 x, Uint16 y); +extern void GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y); #endif -extern void GEM_CheckMouseMode (_THIS); +extern void GEM_CheckMouseMode(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/gem/SDL_gemvideo.c --- a/src/video/gem/SDL_gemvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/gem/SDL_gemvideo.c Mon May 29 04:04:35 2006 +0000 @@ -76,85 +76,85 @@ static const unsigned char empty_name[] = ""; /* Initialization/Query functions */ -static int GEM_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **GEM_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *GEM_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int GEM_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void GEM_VideoQuit (_THIS); +static int GEM_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **GEM_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +static SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +static int GEM_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void GEM_VideoQuit(_THIS); /* Hardware surface functions */ -static int GEM_AllocHWSurface (_THIS, SDL_Surface * surface); -static int GEM_LockHWSurface (_THIS, SDL_Surface * surface); -static int GEM_FlipHWSurface (_THIS, SDL_Surface * surface); -static void GEM_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void GEM_FreeHWSurface (_THIS, SDL_Surface * surface); -static void GEM_UpdateRects (_THIS, int numrects, SDL_Rect * rects); +static int GEM_AllocHWSurface(_THIS, SDL_Surface * surface); +static int GEM_LockHWSurface(_THIS, SDL_Surface * surface); +static int GEM_FlipHWSurface(_THIS, SDL_Surface * surface); +static void GEM_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void GEM_FreeHWSurface(_THIS, SDL_Surface * surface); +static void GEM_UpdateRects(_THIS, int numrects, SDL_Rect * rects); #if 0 -static int GEM_ToggleFullScreen (_THIS, int on); +static int GEM_ToggleFullScreen(_THIS, int on); #endif /* Internal functions */ -static void GEM_FreeBuffers (_THIS); -static void GEM_ClearScreen (_THIS); -static void GEM_ClearRect (_THIS, short *rect); -static void GEM_SetNewPalette (_THIS, Uint16 newpal[256][3]); -static void GEM_LockScreen (_THIS); -static void GEM_UnlockScreen (_THIS); -static void refresh_window (_THIS, int winhandle, short *rect); +static void GEM_FreeBuffers(_THIS); +static void GEM_ClearScreen(_THIS); +static void GEM_ClearRect(_THIS, short *rect); +static void GEM_SetNewPalette(_THIS, Uint16 newpal[256][3]); +static void GEM_LockScreen(_THIS); +static void GEM_UnlockScreen(_THIS); +static void refresh_window(_THIS, int winhandle, short *rect); #if SDL_VIDEO_OPENGL /* OpenGL functions */ -static void GEM_GL_SwapBuffers (_THIS); +static void GEM_GL_SwapBuffers(_THIS); #endif /* GEM driver bootstrap functions */ static int -GEM_Available (void) +GEM_Available(void) { /* Test if AES available */ - if (appl_init () == -1) + if (appl_init() == -1) return 0; - appl_exit (); + appl_exit(); return 1; } static void -GEM_DeleteDevice (SDL_VideoDevice * device) +GEM_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -GEM_CreateDevice (int devindex) +GEM_CreateDevice(int devindex) { SDL_VideoDevice *device; int vectors_mask; unsigned long dummy; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); device->gl_data = (struct SDL_PrivateGLData *) - SDL_malloc ((sizeof *device->gl_data)); + SDL_malloc((sizeof *device->gl_data)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); - SDL_memset (device->gl_data, 0, sizeof (*device->gl_data)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->gl_data, 0, sizeof(*device->gl_data)); /* Set the function pointers */ device->VideoInit = GEM_VideoInit; @@ -197,17 +197,17 @@ #endif device->hidden->use_dev_mouse = - (SDL_AtariDevMouse_Open () != 0) ? SDL_TRUE : SDL_FALSE; + (SDL_AtariDevMouse_Open() != 0) ? SDL_TRUE : SDL_FALSE; vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS; /* XBIOS joystick events */ if (!(device->hidden->use_dev_mouse)) { vectors_mask |= ATARI_XBIOS_MOUSEEVENTS; /* XBIOS mouse events */ } - if (Getcookie (C_MiNT, &dummy) == C_FOUND) { + if (Getcookie(C_MiNT, &dummy) == C_FOUND) { vectors_mask = 0; } - SDL_AtariXbios_InstallVectors (vectors_mask); + SDL_AtariXbios_InstallVectors(vectors_mask); device->free = GEM_DeleteDevice; @@ -220,7 +220,7 @@ }; static void -VDI_ReadExtInfo (_THIS, short *work_out) +VDI_ReadExtInfo(_THIS, short *work_out) { unsigned long EdDI_version; unsigned long cookie_EdDI; @@ -228,13 +228,13 @@ Uint16 clut_type, num_bits; /* Read EdDI informations */ - if (Getcookie (C_EdDI, &cookie_EdDI) == C_NOTFOUND) { + if (Getcookie(C_EdDI, &cookie_EdDI) == C_NOTFOUND) { return; } - EdDI_version = Atari_get_EdDI_version ((void *) cookie_EdDI); + EdDI_version = Atari_get_EdDI_version((void *) cookie_EdDI); - vq_scrninfo (VDI_handle, work_out); + vq_scrninfo(VDI_handle, work_out); VDI_format = work_out[0]; clut_type = work_out[1]; @@ -310,14 +310,14 @@ } int -GEM_VideoInit (_THIS, SDL_PixelFormat * vformat) +GEM_VideoInit(_THIS, SDL_PixelFormat * vformat) { int i, menubar_size; short work_in[12], work_out[272], dummy; /* Open AES (Application Environment Services) */ - if (appl_init () == -1) { - fprintf (stderr, "Can not open AES\n"); + if (appl_init() == -1) { + fprintf(stderr, "Can not open AES\n"); return 1; } @@ -328,8 +328,8 @@ GEM_wfeatures = 0; errorcode = - appl_getinfo (AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2], - &ap_gout[3]); + appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2], + &ap_gout[3]); if (errorcode == 0) { GEM_wfeatures = ap_gout[0]; @@ -337,21 +337,21 @@ } /* Ask VDI physical workstation handle opened by AES */ - VDI_handle = graf_handle (&dummy, &dummy, &dummy, &dummy); + VDI_handle = graf_handle(&dummy, &dummy, &dummy, &dummy); if (VDI_handle < 1) { - fprintf (stderr, "Wrong VDI handle %d returned by AES\n", VDI_handle); + fprintf(stderr, "Wrong VDI handle %d returned by AES\n", VDI_handle); return 1; } /* Open virtual VDI workstation */ - work_in[0] = Getrez () + 2; + work_in[0] = Getrez() + 2; for (i = 1; i < 10; i++) work_in[i] = 1; work_in[10] = 2; - v_opnvwk (work_in, &VDI_handle, work_out); + v_opnvwk(work_in, &VDI_handle, work_out); if (VDI_handle == 0) { - fprintf (stderr, "Can not open VDI virtual workstation\n"); + fprintf(stderr, "Can not open VDI virtual workstation\n"); return 1; } @@ -363,12 +363,12 @@ if (!wind_get (DESKTOP_HANDLE, WF_WORKXYWH, &GEM_desk_x, &GEM_desk_y, &GEM_desk_w, &GEM_desk_h)) { - fprintf (stderr, "Can not read desktop properties\n"); + fprintf(stderr, "Can not read desktop properties\n"); return 1; } /* Read bit depth */ - vq_extnd (VDI_handle, 1, work_out); + vq_extnd(VDI_handle, 1, work_out); VDI_bpp = work_out[4]; VDI_oldnumcolors = 0; @@ -387,7 +387,7 @@ VDI_pixelsize = 4; break; default: - fprintf (stderr, "%d bits colour depth not supported\n", VDI_bpp); + fprintf(stderr, "%d bits colour depth not supported\n", VDI_bpp); return 1; } @@ -407,14 +407,14 @@ for (i = 0; i < VDI_oldnumcolors; i++) { short rgb[3]; - vq_color (VDI_handle, i, 0, rgb); + vq_color(VDI_handle, i, 0, rgb); VDI_oldpalette[i][0] = rgb[0]; VDI_oldpalette[i][1] = rgb[1]; VDI_oldpalette[i][2] = rgb[2]; } VDI_setpalette = GEM_SetNewPalette; - SDL_memcpy (VDI_curpalette, VDI_oldpalette, sizeof (VDI_curpalette)); + SDL_memcpy(VDI_curpalette, VDI_oldpalette, sizeof(VDI_curpalette)); /* Setup screen info */ GEM_title_name = empty_name; @@ -430,14 +430,14 @@ VDI_pitch = VDI_w * VDI_pixelsize; VDI_format = ((VDI_bpp <= 8) ? VDI_FORMAT_INTER : VDI_FORMAT_PACK); VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0; - VDI_ReadExtInfo (this, work_out); + VDI_ReadExtInfo(this, work_out); #ifdef DEBUG_VIDEO_GEM - printf ("sdl:video:gem: screen: address=0x%08x, pitch=%d\n", VDI_screen, - VDI_pitch); - printf ("sdl:video:gem: format=%d\n", VDI_format); - printf ("sdl:video:gem: masks: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", - VDI_alphamask, VDI_redmask, VDI_greenmask, VDI_bluemask); + printf("sdl:video:gem: screen: address=0x%08x, pitch=%d\n", VDI_screen, + VDI_pitch); + printf("sdl:video:gem: format=%d\n", VDI_format); + printf("sdl:video:gem: masks: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", + VDI_alphamask, VDI_redmask, VDI_greenmask, VDI_bluemask); #endif /* Setup destination mfdb */ @@ -452,22 +452,22 @@ vformat->BitsPerPixel = VDI_bpp; /* Set mouse cursor to arrow */ - graf_mouse (ARROW, NULL); + graf_mouse(ARROW, NULL); /* Init chunky to planar routine */ SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8; /* Setup VDI fill functions */ - vsf_color (VDI_handle, 0); - vsf_interior (VDI_handle, 1); - vsf_perimeter (VDI_handle, 0); + vsf_color(VDI_handle, 0); + vsf_interior(VDI_handle, 1); + vsf_perimeter(VDI_handle, 0); /* Menu bar save buffer */ menubar_size = GEM_desk_w * GEM_desk_y * VDI_pixelsize; - GEM_menubar = Atari_SysMalloc (menubar_size, MX_PREFTTRAM); + GEM_menubar = Atari_SysMalloc(menubar_size, MX_PREFTTRAM); /* Fill video modes list */ - SDL_modelist[0] = SDL_malloc (sizeof (SDL_Rect)); + SDL_modelist[0] = SDL_malloc(sizeof(SDL_Rect)); SDL_modelist[0]->x = 0; SDL_modelist[0]->y = 0; SDL_modelist[0]->w = VDI_w; @@ -476,7 +476,7 @@ SDL_modelist[1] = NULL; #if SDL_VIDEO_OPENGL - SDL_AtariGL_InitPointers (this); + SDL_AtariGL_InitPointers(this); #endif /* We're done! */ @@ -484,7 +484,7 @@ } SDL_Rect ** -GEM_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +GEM_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { if (format->BitsPerPixel != VDI_bpp) { return ((SDL_Rect **) NULL); @@ -498,53 +498,53 @@ } static void -GEM_FreeBuffers (_THIS) +GEM_FreeBuffers(_THIS) { /* Release buffer */ if (GEM_buffer2) { - Mfree (GEM_buffer2); + Mfree(GEM_buffer2); GEM_buffer2 = NULL; } if (GEM_buffer1) { - Mfree (GEM_buffer1); + Mfree(GEM_buffer1); GEM_buffer1 = NULL; } } static void -GEM_ClearRect (_THIS, short *rect) +GEM_ClearRect(_THIS, short *rect) { short oldrgb[3], rgb[3] = { 0, 0, 0 }; - vq_color (VDI_handle, vdi_index[0], 0, oldrgb); - vs_color (VDI_handle, vdi_index[0], rgb); + vq_color(VDI_handle, vdi_index[0], 0, oldrgb); + vs_color(VDI_handle, vdi_index[0], rgb); - vsf_color (VDI_handle, 0); - vsf_interior (VDI_handle, 1); - vsf_perimeter (VDI_handle, 0); - v_bar (VDI_handle, rect); + vsf_color(VDI_handle, 0); + vsf_interior(VDI_handle, 1); + vsf_perimeter(VDI_handle, 0); + v_bar(VDI_handle, rect); - vs_color (VDI_handle, vdi_index[0], oldrgb); + vs_color(VDI_handle, vdi_index[0], oldrgb); } static void -GEM_ClearScreen (_THIS) +GEM_ClearScreen(_THIS) { short pxy[4]; - v_hide_c (VDI_handle); + v_hide_c(VDI_handle); pxy[0] = pxy[1] = 0; pxy[2] = VDI_w - 1; pxy[3] = VDI_h - 1; - GEM_ClearRect (this, pxy); + GEM_ClearRect(this, pxy); - v_show_c (VDI_handle, 1); + v_show_c(VDI_handle, 1); } static void -GEM_SetNewPalette (_THIS, Uint16 newpal[256][3]) +GEM_SetNewPalette(_THIS, Uint16 newpal[256][3]) { int i; short rgb[3]; @@ -557,19 +557,19 @@ rgb[1] = newpal[i][1]; rgb[2] = newpal[i][2]; - vs_color (VDI_handle, i, rgb); + vs_color(VDI_handle, i, rgb); } } static void -GEM_LockScreen (_THIS) +GEM_LockScreen(_THIS) { if (!GEM_locked) { /* Lock AES */ - wind_update (BEG_UPDATE); - wind_update (BEG_MCTRL); + wind_update(BEG_UPDATE); + wind_update(BEG_MCTRL); /* Reserve memory space, used to be sure of compatibility */ - form_dial (FMD_START, 0, 0, 0, 0, 0, 0, VDI_w, VDI_h); + form_dial(FMD_START, 0, 0, 0, 0, 0, 0, VDI_w, VDI_h); /* Save menu bar */ if (GEM_menubar) { @@ -589,8 +589,8 @@ blitcoords[2] = blitcoords[6] = GEM_desk_w - 1; blitcoords[3] = blitcoords[7] = GEM_desk_y - 1; - vro_cpyfm (VDI_handle, S_ONLY, blitcoords, &VDI_dst_mfdb, - &mfdb_src); + vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &VDI_dst_mfdb, + &mfdb_src); } GEM_locked = SDL_TRUE; @@ -598,7 +598,7 @@ } static void -GEM_UnlockScreen (_THIS) +GEM_UnlockScreen(_THIS) { if (GEM_locked) { /* Restore menu bar */ @@ -619,23 +619,23 @@ blitcoords[2] = blitcoords[6] = GEM_desk_w - 1; blitcoords[3] = blitcoords[7] = GEM_desk_y - 1; - vro_cpyfm (VDI_handle, S_ONLY, blitcoords, &mfdb_src, - &VDI_dst_mfdb); + vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, + &VDI_dst_mfdb); } /* Restore screen memory, and send REDRAW to all apps */ - form_dial (FMD_FINISH, 0, 0, 0, 0, 0, 0, VDI_w, VDI_h); + form_dial(FMD_FINISH, 0, 0, 0, 0, 0, 0, VDI_w, VDI_h); /* Unlock AES */ - wind_update (END_MCTRL); - wind_update (END_UPDATE); + wind_update(END_MCTRL); + wind_update(END_UPDATE); GEM_locked = SDL_FALSE; } } SDL_Surface * -GEM_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +GEM_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { int maxwidth, maxheight; Uint32 modeflags, screensize; @@ -657,7 +657,7 @@ } if ((maxwidth < width) || (maxheight < height) || (VDI_bpp != bpp)) { - SDL_SetError ("Couldn't find requested mode in list"); + SDL_SetError("Couldn't find requested mode in list"); return (NULL); } @@ -665,20 +665,19 @@ if (!SDL_ReallocFormat (current, VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, VDI_alphamask)) { - SDL_SetError - ("Couldn't allocate new pixel format for requested mode"); + SDL_SetError("Couldn't allocate new pixel format for requested mode"); return (NULL); } screensize = width * height * VDI_pixelsize; #ifdef DEBUG_VIDEO_GEM - printf ("sdl:video:gem: setvideomode(): %dx%dx%d = %d\n", width, height, - bpp, screensize); + printf("sdl:video:gem: setvideomode(): %dx%dx%d = %d\n", width, height, + bpp, screensize); #endif /*--- Allocate shadow buffers if needed, and conversion operations ---*/ - GEM_FreeBuffers (this); + GEM_FreeBuffers(this); GEM_bufops = 0; use_shadow1 = use_shadow2 = SDL_FALSE; @@ -698,28 +697,28 @@ } if (use_shadow1) { - GEM_buffer1 = Atari_SysMalloc (screensize, MX_PREFTTRAM); + GEM_buffer1 = Atari_SysMalloc(screensize, MX_PREFTTRAM); if (GEM_buffer1 == NULL) { - SDL_SetError ("Can not allocate %d KB for frame buffer", - screensize >> 10); + SDL_SetError("Can not allocate %d KB for frame buffer", + screensize >> 10); return NULL; } - SDL_memset (GEM_buffer1, 0, screensize); + SDL_memset(GEM_buffer1, 0, screensize); #ifdef DEBUG_VIDEO_GEM - printf ("sdl:video:gem: setvideomode(): allocated buffer 1\n"); + printf("sdl:video:gem: setvideomode(): allocated buffer 1\n"); #endif } if (use_shadow2) { - GEM_buffer2 = Atari_SysMalloc (screensize, MX_PREFTTRAM); + GEM_buffer2 = Atari_SysMalloc(screensize, MX_PREFTTRAM); if (GEM_buffer2 == NULL) { - SDL_SetError ("Can not allocate %d KB for shadow buffer", - screensize >> 10); + SDL_SetError("Can not allocate %d KB for shadow buffer", + screensize >> 10); return NULL; } - SDL_memset (GEM_buffer2, 0, screensize); + SDL_memset(GEM_buffer2, 0, screensize); #ifdef DEBUG_VIDEO_GEM - printf ("sdl:video:gem: setvideomode(): allocated buffer 2\n"); + printf("sdl:video:gem: setvideomode(): allocated buffer 2\n"); #endif } @@ -730,9 +729,9 @@ } if (flags & SDL_FULLSCREEN) { - GEM_LockScreen (this); + GEM_LockScreen(this); - GEM_ClearScreen (this); + GEM_ClearScreen(this); modeflags |= SDL_FULLSCREEN; if (VDI_screen && (VDI_format == VDI_FORMAT_PACK) && !use_shadow1) { @@ -746,7 +745,7 @@ int old_win_type; short x2, y2, w2, h2; - GEM_UnlockScreen (this); + GEM_UnlockScreen(this); /* Set window gadgets */ old_win_type = GEM_win_type; @@ -768,8 +767,8 @@ if (!wind_calc (WC_BORDER, GEM_win_type, 0, 0, width, height, &x2, &y2, &w2, &h2)) { - GEM_FreeBuffers (this); - SDL_SetError ("Can not calculate window attributes"); + GEM_FreeBuffers(this); + SDL_SetError("Can not calculate window attributes"); return NULL; } @@ -779,34 +778,34 @@ /* Destroy existing window */ if (GEM_handle >= 0) { - wind_close (GEM_handle); - wind_delete (GEM_handle); + wind_close(GEM_handle); + wind_delete(GEM_handle); } /* Create window */ - GEM_handle = wind_create (GEM_win_type, x2, y2, w2, h2); + GEM_handle = wind_create(GEM_win_type, x2, y2, w2, h2); if (GEM_handle < 0) { - GEM_FreeBuffers (this); - SDL_SetError ("Can not create window"); + GEM_FreeBuffers(this); + SDL_SetError("Can not create window"); return NULL; } #ifdef DEBUG_VIDEO_GEM - printf ("sdl:video:gem: handle=%d\n", GEM_handle); + printf("sdl:video:gem: handle=%d\n", GEM_handle); #endif /* Setup window name */ - wind_set (GEM_handle, WF_NAME, - (short) (((unsigned long) GEM_title_name) >> 16), - (short) (((unsigned long) GEM_title_name) & 0xffff), - 0, 0); + wind_set(GEM_handle, WF_NAME, + (short) (((unsigned long) GEM_title_name) >> 16), + (short) (((unsigned long) GEM_title_name) & 0xffff), + 0, 0); GEM_refresh_name = SDL_FALSE; /* Open the window */ - wind_open (GEM_handle, x2, y2, w2, h2); + wind_open(GEM_handle, x2, y2, w2, h2); } else { /* Resize window if needed, to fit asked video mode */ if (modeflags & SDL_RESIZABLE) { - wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2); + wind_get(GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2); if ((w2 & 15) != 0) { w2 = (w2 | 15) + 1; } @@ -814,7 +813,7 @@ if (wind_calc (WC_BORDER, GEM_win_type, x2, y2, width, height, &x2, &y2, &w2, &h2)) { - wind_set (GEM_handle, WF_CURRXYWH, x2, y2, w2, h2); + wind_set(GEM_handle, WF_CURRXYWH, x2, y2, w2, h2); } } } @@ -836,9 +835,9 @@ #if SDL_VIDEO_OPENGL if (flags & SDL_INTERNALOPENGL) { - if (!SDL_AtariGL_Init (this, current)) { - GEM_FreeBuffers (this); - SDL_SetError ("Can not create OpenGL context"); + if (!SDL_AtariGL_Init(this, current)) { + GEM_FreeBuffers(this); + SDL_SetError("Can not create OpenGL context"); return NULL; } @@ -849,7 +848,7 @@ current->flags = modeflags; #ifdef DEBUG_VIDEO_GEM - printf ("sdl:video:gem: surface: %dx%d\n", current->w, current->h); + printf("sdl:video:gem: surface: %dx%d\n", current->w, current->h); #endif this->UpdateRects = GEM_UpdateRects; @@ -860,31 +859,31 @@ } static int -GEM_AllocHWSurface (_THIS, SDL_Surface * surface) +GEM_AllocHWSurface(_THIS, SDL_Surface * surface) { return -1; } static void -GEM_FreeHWSurface (_THIS, SDL_Surface * surface) +GEM_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } static int -GEM_LockHWSurface (_THIS, SDL_Surface * surface) +GEM_LockHWSurface(_THIS, SDL_Surface * surface) { return (0); } static void -GEM_UnlockHWSurface (_THIS, SDL_Surface * surface) +GEM_UnlockHWSurface(_THIS, SDL_Surface * surface) { return; } static void -GEM_UpdateRectsFullscreen (_THIS, int numrects, SDL_Rect * rects) +GEM_UpdateRectsFullscreen(_THIS, int numrects, SDL_Rect * rects) { SDL_Surface *surface; int i, surf_width; @@ -926,9 +925,9 @@ destination += destpitch * rects[i].y; destination += x1; - SDL_Atari_C2pConvert (source, destination, - x2 - x1, rects[i].h, - SDL_FALSE, surface->pitch, destpitch); + SDL_Atari_C2pConvert(source, destination, + x2 - x1, rects[i].h, + SDL_FALSE, surface->pitch, destpitch); } } @@ -953,14 +952,14 @@ blitcoords[2] = blitcoords[6] = rects[i].x + rects[i].w - 1; blitcoords[3] = blitcoords[7] = rects[i].y + rects[i].h - 1; - vro_cpyfm (VDI_handle, S_ONLY, blitcoords, &mfdb_src, - &VDI_dst_mfdb); + vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, + &VDI_dst_mfdb); } } } static void -GEM_UpdateRectsWindowed (_THIS, int numrects, SDL_Rect * rects) +GEM_UpdateRectsWindowed(_THIS, int numrects, SDL_Rect * rects) { short pxy[4], wind_pxy[4]; int i; @@ -977,12 +976,12 @@ pxy[2] = rects[i].w; pxy[3] = rects[i].h; - GEM_wind_redraw (this, GEM_handle, pxy); + GEM_wind_redraw(this, GEM_handle, pxy); } } static void -GEM_UpdateRects (_THIS, int numrects, SDL_Rect * rects) +GEM_UpdateRects(_THIS, int numrects, SDL_Rect * rects) { SDL_Surface *surface; @@ -993,14 +992,14 @@ surface = this->screen; if (surface->flags & SDL_FULLSCREEN) { - GEM_UpdateRectsFullscreen (this, numrects, rects); + GEM_UpdateRectsFullscreen(this, numrects, rects); } else { - GEM_UpdateRectsWindowed (this, numrects, rects); + GEM_UpdateRectsWindowed(this, numrects, rects); } } static int -GEM_FlipHWSurfaceFullscreen (_THIS, SDL_Surface * surface) +GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface * surface) { int surf_width; @@ -1022,9 +1021,9 @@ destpitch = surface->pitch; } - SDL_Atari_C2pConvert (surface->pixels, destscr, - surf_width, surface->h, - SDL_FALSE, surface->pitch, destpitch); + SDL_Atari_C2pConvert(surface->pixels, destscr, + surf_width, surface->h, + SDL_FALSE, surface->pitch, destpitch); } if (GEM_bufops & (B2S_VROCPYFM_1TOS | B2S_VROCPYFM_2TOS)) { @@ -1048,47 +1047,47 @@ blitcoords[2] = blitcoords[6] = surface->w - 1; blitcoords[3] = blitcoords[7] = surface->h - 1; - vro_cpyfm (VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb); + vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb); } return (0); } static int -GEM_FlipHWSurfaceWindowed (_THIS, SDL_Surface * surface) +GEM_FlipHWSurfaceWindowed(_THIS, SDL_Surface * surface) { short pxy[8]; /* Update the whole window */ - wind_get (GEM_handle, WF_WORKXYWH, &pxy[0], &pxy[1], &pxy[2], &pxy[3]); + wind_get(GEM_handle, WF_WORKXYWH, &pxy[0], &pxy[1], &pxy[2], &pxy[3]); - GEM_wind_redraw (this, GEM_handle, pxy); + GEM_wind_redraw(this, GEM_handle, pxy); return (0); } static int -GEM_FlipHWSurface (_THIS, SDL_Surface * surface) +GEM_FlipHWSurface(_THIS, SDL_Surface * surface) { if (GEM_lock_redraw) { return (0); } if (surface->flags & SDL_FULLSCREEN) { - return GEM_FlipHWSurfaceFullscreen (this, surface); + return GEM_FlipHWSurfaceFullscreen(this, surface); } else { - return GEM_FlipHWSurfaceWindowed (this, surface); + return GEM_FlipHWSurfaceWindowed(this, surface); } } static int -GEM_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +GEM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { int i; SDL_Surface *surface; #ifdef DEBUG_VIDEO_GEM - printf ("sdl:video:gem: setcolors()\n"); + printf("sdl:video:gem: setcolors()\n"); #endif /* Do not change palette in True Colour */ @@ -1109,7 +1108,7 @@ rgb[1] = VDI_curpalette[i][1] = (1000 * g) / 255; rgb[2] = VDI_curpalette[i][2] = (1000 * b) / 255; - vs_color (VDI_handle, vdi_index[firstcolor + i], rgb); + vs_color(VDI_handle, vdi_index[firstcolor + i], rgb); } return (1); @@ -1117,12 +1116,12 @@ #if 0 static int -GEM_ToggleFullScreen (_THIS, int on) +GEM_ToggleFullScreen(_THIS, int on) { if (on) { - GEM_LockScreen (this); + GEM_LockScreen(this); } else { - GEM_UnlockScreen (this); + GEM_UnlockScreen(this); } return (1); @@ -1133,46 +1132,46 @@ another SDL video routine -- notably UpdateRects. */ void -GEM_VideoQuit (_THIS) +GEM_VideoQuit(_THIS) { - SDL_AtariXbios_RestoreVectors (); + SDL_AtariXbios_RestoreVectors(); if (GEM_usedevmouse) { - SDL_AtariDevMouse_Close (); + SDL_AtariDevMouse_Close(); } - GEM_FreeBuffers (this); + GEM_FreeBuffers(this); #if SDL_VIDEO_OPENGL if (gl_active) { - SDL_AtariGL_Quit (this, SDL_TRUE); + SDL_AtariGL_Quit(this, SDL_TRUE); } #endif /* Destroy window */ if (GEM_handle >= 0) { - wind_close (GEM_handle); - wind_delete (GEM_handle); + wind_close(GEM_handle); + wind_delete(GEM_handle); GEM_handle = -1; } - GEM_UnlockScreen (this); + GEM_UnlockScreen(this); if (GEM_menubar) { - Mfree (GEM_menubar); + Mfree(GEM_menubar); GEM_menubar = NULL; } - appl_exit (); + appl_exit(); - GEM_SetNewPalette (this, VDI_oldpalette); + GEM_SetNewPalette(this, VDI_oldpalette); /* Close VDI workstation */ if (VDI_handle) { - v_clsvwk (VDI_handle); + v_clsvwk(VDI_handle); } /* Free mode list */ if (SDL_modelist[0]) { - SDL_free (SDL_modelist[0]); + SDL_free(SDL_modelist[0]); SDL_modelist[0] = NULL; } @@ -1180,14 +1179,14 @@ } void -GEM_wind_redraw (_THIS, int winhandle, short *inside) +GEM_wind_redraw(_THIS, int winhandle, short *inside) { short todo[4]; /* Tell AES we are going to update */ - wind_update (BEG_UPDATE); + wind_update(BEG_UPDATE); - v_hide_c (VDI_handle); + v_hide_c(VDI_handle); /* Browse the rectangle list to redraw */ if (wind_get @@ -1196,10 +1195,10 @@ while (todo[2] && todo[3]) { - if (rc_intersect ((GRECT *) inside, (GRECT *) todo)) { + if (rc_intersect((GRECT *) inside, (GRECT *) todo)) { todo[2] += todo[0] - 1; todo[3] += todo[1] - 1; - refresh_window (this, winhandle, todo); + refresh_window(this, winhandle, todo); } if (wind_get @@ -1212,13 +1211,13 @@ } /* Update finished */ - wind_update (END_UPDATE); + wind_update(END_UPDATE); - v_show_c (VDI_handle, 1); + v_show_c(VDI_handle, 1); } static void -refresh_window (_THIS, int winhandle, short *rect) +refresh_window(_THIS, int winhandle, short *rect) { MFDB mfdb_src; short pxy[8], wind_pxy[8]; @@ -1248,7 +1247,7 @@ surface = GEM_icon; - GEM_ClearRect (this, rect); + GEM_ClearRect(this, rect); /* Calculate centered icon(x,y,w,h) relative to window */ iconx = (wind_pxy[2] - surface->w) >> 1; @@ -1266,16 +1265,16 @@ dst_rect[3] = rect[3] - rect[1] + 1; /* Does the icon rectangle must be redrawn ? */ - if (!rc_intersect ((GRECT *) icon_rect, (GRECT *) dst_rect)) { + if (!rc_intersect((GRECT *) icon_rect, (GRECT *) dst_rect)) { return; } #if DEBUG_VIDEO_GEM - printf ("sdl:video:gem: clip(0,0,%d,%d) to (%d,%d,%d,%d)\n", - surface->w - 1, surface->h - 1, dst_rect[0], dst_rect[1], - dst_rect[2], dst_rect[3]); - printf ("sdl:video:gem: icon(%d,%d,%d,%d)\n", icon_rect[0], - icon_rect[1], icon_rect[2], icon_rect[3]); - printf ("sdl:video:gem: refresh_window(): draw icon\n"); + printf("sdl:video:gem: clip(0,0,%d,%d) to (%d,%d,%d,%d)\n", + surface->w - 1, surface->h - 1, dst_rect[0], dst_rect[1], + dst_rect[2], dst_rect[3]); + printf("sdl:video:gem: icon(%d,%d,%d,%d)\n", icon_rect[0], + icon_rect[1], icon_rect[2], icon_rect[3]); + printf("sdl:video:gem: refresh_window(): draw icon\n"); #endif /* Calculate icon(x1,y1,x2,y2) relative to screen */ @@ -1285,10 +1284,10 @@ icon_rect[3] += icon_rect[1] - 1; /* Calculate intersection rectangle to redraw */ - pxy[4] = pxy[0] = MAX (icon_rect[0], rect[0]); - pxy[5] = pxy[1] = MAX (icon_rect[1], rect[1]); - pxy[6] = pxy[2] = MIN (icon_rect[2], rect[2]); - pxy[7] = pxy[3] = MIN (icon_rect[3], rect[3]); + pxy[4] = pxy[0] = MAX(icon_rect[0], rect[0]); + pxy[5] = pxy[1] = MAX(icon_rect[1], rect[1]); + pxy[6] = pxy[2] = MIN(icon_rect[2], rect[2]); + pxy[7] = pxy[3] = MIN(icon_rect[3], rect[3]); /* Calculate icon source image pos relative to window */ pxy[0] -= wind_pxy[0] + iconx; @@ -1300,7 +1299,7 @@ surface = this->screen; #if DEBUG_VIDEO_GEM - printf ("sdl:video:gem: refresh_window(): draw frame buffer\n"); + printf("sdl:video:gem: refresh_window(): draw frame buffer\n"); #endif /* Redraw all window content */ @@ -1333,9 +1332,9 @@ dest += surface->pitch * (rect[1] - wind_pxy[1]); dest += x1; - SDL_Atari_C2pConvert (src, dest, - x2 - x1, rect[3] - rect[1] + 1, - SDL_FALSE, surface->pitch, surface->pitch); + SDL_Atari_C2pConvert(src, dest, + x2 - x1, rect[3] - rect[1] + 1, + SDL_FALSE, surface->pitch, surface->pitch); } mfdb_src.fd_addr = surface->pixels; @@ -1358,21 +1357,21 @@ mfdb_src.fd_addr = GEM_buffer2; } #if DEBUG_VIDEO_GEM - printf ("sdl:video:gem: redraw %dx%d: (%d,%d,%d,%d) to (%d,%d,%d,%d)\n", - surface->w, surface->h, - pxy[0], pxy[1], pxy[2], pxy[3], pxy[4], pxy[5], pxy[6], pxy[7]); + printf("sdl:video:gem: redraw %dx%d: (%d,%d,%d,%d) to (%d,%d,%d,%d)\n", + surface->w, surface->h, + pxy[0], pxy[1], pxy[2], pxy[3], pxy[4], pxy[5], pxy[6], pxy[7]); #endif - vro_cpyfm (VDI_handle, S_ONLY, pxy, &mfdb_src, &VDI_dst_mfdb); + vro_cpyfm(VDI_handle, S_ONLY, pxy, &mfdb_src, &VDI_dst_mfdb); } #if SDL_VIDEO_OPENGL static void -GEM_GL_SwapBuffers (_THIS) +GEM_GL_SwapBuffers(_THIS) { - SDL_AtariGL_SwapBuffers (this); - GEM_FlipHWSurface (this, this->screen); + SDL_AtariGL_SwapBuffers(this); + GEM_FlipHWSurface(this, this->screen); } #endif diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/gem/SDL_gemvideo.h --- a/src/video/gem/SDL_gemvideo.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/gem/SDL_gemvideo.h Mon May 29 04:04:35 2006 +0000 @@ -31,7 +31,7 @@ #define _THIS SDL_VideoDevice *this /* Functions prototypes */ -void GEM_wind_redraw (_THIS, int winhandle, short *inside); +void GEM_wind_redraw(_THIS, int winhandle, short *inside); /* Private display data */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/gem/SDL_gemwm.c --- a/src/video/gem/SDL_gemwm.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/gem/SDL_gemwm.c Mon May 29 04:04:35 2006 +0000 @@ -41,7 +41,7 @@ /* Functions */ void -GEM_SetCaption (_THIS, const char *title, const char *icon) +GEM_SetCaption(_THIS, const char *title, const char *icon) { if (title) { GEM_title_name = title; @@ -55,7 +55,7 @@ } void -GEM_SetIcon (_THIS, SDL_Surface * icon, Uint8 * mask) +GEM_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask) { SDL_Surface *sicon; SDL_Rect bounds; @@ -71,9 +71,9 @@ } /* Convert icon to the screen format */ - sicon = SDL_CreateRGBSurface (SDL_SWSURFACE, icon->w, icon->h, - VDI_bpp, VDI_redmask, VDI_greenmask, - VDI_bluemask, 0); + sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h, + VDI_bpp, VDI_redmask, VDI_greenmask, + VDI_bluemask, 0); if (sicon == NULL) { return; } @@ -82,8 +82,8 @@ bounds.y = 0; bounds.w = icon->w; bounds.h = icon->h; - if (SDL_LowerBlit (icon, &bounds, sicon, &bounds) < 0) { - SDL_FreeSurface (sicon); + if (SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0) { + SDL_FreeSurface(sicon); return; } @@ -91,7 +91,7 @@ } int -GEM_IconifyWindow (_THIS) +GEM_IconifyWindow(_THIS) { if ((GEM_wfeatures & (1 << WF_ICONIFY)) == 0) return 0; @@ -105,13 +105,13 @@ GEM_message[6] = ICONWIDTH; GEM_message[7] = ICONHEIGHT; - appl_write (gl_apid, sizeof (GEM_message), GEM_message); + appl_write(gl_apid, sizeof(GEM_message), GEM_message); return 1; } SDL_GrabMode -GEM_GrabInput (_THIS, SDL_GrabMode mode) +GEM_GrabInput(_THIS, SDL_GrabMode mode) { return SDL_GRAB_OFF; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/gem/SDL_gemwm_c.h --- a/src/video/gem/SDL_gemwm_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/gem/SDL_gemwm_c.h Mon May 29 04:04:35 2006 +0000 @@ -31,8 +31,8 @@ #include "SDL_gemvideo.h" /* Functions prototypes */ -extern void GEM_SetCaption (_THIS, const char *title, const char *icon); -extern void GEM_SetIcon (_THIS, SDL_Surface * icon, Uint8 * mask); -extern int GEM_IconifyWindow (_THIS); -extern SDL_GrabMode GEM_GrabInput (_THIS, SDL_GrabMode mode); +extern void GEM_SetCaption(_THIS, const char *title, const char *icon); +extern void GEM_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask); +extern int GEM_IconifyWindow(_THIS); +extern SDL_GrabMode GEM_GrabInput(_THIS, SDL_GrabMode mode); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ggi/SDL_ggievents.c --- a/src/video/ggi/SDL_ggievents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ggi/SDL_ggievents.c Mon May 29 04:04:35 2006 +0000 @@ -42,12 +42,12 @@ /* The translation tables from a GGI keycode to a SDL keysym */ static SDLKey keymap[128]; -static SDL_keysym *GGI_TranslateKey (ggi_event * ev, SDL_keysym * keysym); +static SDL_keysym *GGI_TranslateKey(ggi_event * ev, SDL_keysym * keysym); static int posted = 0; void -GGI_PumpEvents (_THIS) +GGI_PumpEvents(_THIS) { struct timeval *tvp, tv = { 0, 0 }; ggi_event ev; @@ -56,7 +56,7 @@ /* ggiFlush(VIS); */ - while (ggiEventPoll (VIS, emAll, tvp)) + while (ggiEventPoll(VIS, emAll, tvp)) /* while (ggiEventPoll(VIS, (emKeyboard | emPointer | emCommand), tvp)) */ { int queueevent_mouse = 0, queueevent_kbd = 0; @@ -73,7 +73,7 @@ * mouse and keyboard events. Having to handle all * events will slow things down. */ - ggiEventRead (VIS, &ev, emAll); + ggiEventRead(VIS, &ev, emAll); /* ggiEventRead(VIS, &ev, (emKeyboard | emPointer | emCommand)); */ switch (ev.any.type) { @@ -81,7 +81,7 @@ x = ev.pmove.x; y = ev.pmove.y; z = ev.pmove.wheel; - posted += SDL_PrivateMouseMotion (0, 1, x, y); + posted += SDL_PrivateMouseMotion(0, 1, x, y); break; case evPtrAbsolute: if (mouse_x != ev.pmove.x || mouse_y != ev.pmove.y @@ -92,34 +92,33 @@ mouse_x = ev.pmove.x; mouse_y = ev.pmove.y; mouse_z = ev.pmove.wheel; - posted += SDL_PrivateMouseMotion (0, 1, x, y); + posted += SDL_PrivateMouseMotion(0, 1, x, y); } break; case evPtrButtonPress: posted += - SDL_PrivateMouseButton (SDL_PRESSED, ev.pbutton.button, 0, 0); + SDL_PrivateMouseButton(SDL_PRESSED, ev.pbutton.button, 0, 0); break; case evPtrButtonRelease: posted += - SDL_PrivateMouseButton (SDL_RELEASED, ev.pbutton.button, - 0, 0); + SDL_PrivateMouseButton(SDL_RELEASED, ev.pbutton.button, 0, 0); break; case evKeyPress: case evKeyRepeat: posted += - SDL_PrivateKeyboard (SDL_PRESSED, - GGI_TranslateKey (&ev, &keysym)); + SDL_PrivateKeyboard(SDL_PRESSED, + GGI_TranslateKey(&ev, &keysym)); break; case evKeyRelease: posted += - SDL_PrivateKeyboard (SDL_RELEASED, - GGI_TranslateKey (&ev, &keysym)); + SDL_PrivateKeyboard(SDL_RELEASED, + GGI_TranslateKey(&ev, &keysym)); break; case evCommand: - fprintf (stderr, "Command event %x recieved\n", ev.cmd.code); + fprintf(stderr, "Command event %x recieved\n", ev.cmd.code); break; default: - fprintf (stderr, "Unhandled event type %d\n", ev.any.type); + fprintf(stderr, "Unhandled event type %d\n", ev.any.type); break; } } @@ -127,12 +126,12 @@ } void -GGI_InitOSKeymap (_THIS) +GGI_InitOSKeymap(_THIS) { int i; /* Initialize the GGI key translation table */ - for (i = 0; i < SDL_arraysize (keymap); ++i) + for (i = 0; i < SDL_arraysize(keymap); ++i) keymap[i] = SDLK_UNKNOWN; keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE; @@ -256,7 +255,7 @@ static SDL_keysym * -GGI_TranslateKey (gii_event * ev, SDL_keysym * keysym) +GGI_TranslateKey(gii_event * ev, SDL_keysym * keysym) { /* Set the keysym information */ keysym->scancode = ev->key.button; @@ -266,7 +265,7 @@ /* If UNICODE is on, get the UNICODE value for the key */ keysym->unicode = 0; if (SDL_TranslateUNICODE) { - keysym->unicode = GII_UNICODE (ev->key.sym); + keysym->unicode = GII_UNICODE(ev->key.sym); } return keysym; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ggi/SDL_ggievents_c.h --- a/src/video/ggi/SDL_ggievents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ggi/SDL_ggievents_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,6 +24,6 @@ #include "SDL_ggivideo.h" /* Functions to be exported */ -extern void GGI_InitOSKeymap (_THIS); -extern void GGI_PumpEvents (_THIS); +extern void GGI_InitOSKeymap(_THIS); +extern void GGI_PumpEvents(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ggi/SDL_ggivideo.c --- a/src/video/ggi/SDL_ggivideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ggi/SDL_ggivideo.c Mon May 29 04:04:35 2006 +0000 @@ -49,65 +49,65 @@ ggi_visual_t VIS; /* Initialization/Query functions */ -static int GGI_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **GGI_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *GGI_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int GGI_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void GGI_VideoQuit (_THIS); +static int GGI_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **GGI_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +static SDL_Surface *GGI_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +static int GGI_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void GGI_VideoQuit(_THIS); /* Hardware surface functions */ -static int GGI_AllocHWSurface (_THIS, SDL_Surface * surface); -static int GGI_LockHWSurface (_THIS, SDL_Surface * surface); -static void GGI_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void GGI_FreeHWSurface (_THIS, SDL_Surface * surface); +static int GGI_AllocHWSurface(_THIS, SDL_Surface * surface); +static int GGI_LockHWSurface(_THIS, SDL_Surface * surface); +static void GGI_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void GGI_FreeHWSurface(_THIS, SDL_Surface * surface); /* GGI driver bootstrap functions */ static int -GGI_Available (void) +GGI_Available(void) { ggi_visual_t *vis; vis = NULL; - if (ggiInit () == 0) { - vis = ggiOpen (NULL); + if (ggiInit() == 0) { + vis = ggiOpen(NULL); if (vis != NULL) { - ggiClose (vis); + ggiClose(vis); } } return (vis != NULL); } static void -GGI_DeleteDevice (SDL_VideoDevice * device) +GGI_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -GGI_CreateDevice (int devindex) +GGI_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = GGI_VideoInit; @@ -148,7 +148,7 @@ static SDL_Rect *SDL_modelist[4] = { NULL, NULL, NULL, NULL }; int -GGI_VideoInit (_THIS, SDL_PixelFormat * vformat) +GGI_VideoInit(_THIS, SDL_PixelFormat * vformat) { ggi_mode mode = { 1, @@ -164,38 +164,38 @@ int err, num_bufs; ggi_pixel white, black; - priv = SDL_malloc (sizeof (struct private_hwdata)); + priv = SDL_malloc(sizeof(struct private_hwdata)); if (priv == NULL) { - SDL_SetError ("Unhandled GGI mode type!\n"); - GGI_VideoQuit (NULL); + SDL_SetError("Unhandled GGI mode type!\n"); + GGI_VideoQuit(NULL); } - if (ggiInit () != 0) { - SDL_SetError ("Unable to initialize GGI!\n"); - GGI_VideoQuit (NULL); + if (ggiInit() != 0) { + SDL_SetError("Unable to initialize GGI!\n"); + GGI_VideoQuit(NULL); } - VIS = ggiOpen (NULL); + VIS = ggiOpen(NULL); if (VIS == NULL) { - SDL_SetError ("Unable to open default GGI visual!\n"); - ggiExit (); - GGI_VideoQuit (NULL); + SDL_SetError("Unable to open default GGI visual!\n"); + ggiExit(); + GGI_VideoQuit(NULL); } - ggiSetFlags (VIS, GGIFLAG_ASYNC); + ggiSetFlags(VIS, GGIFLAG_ASYNC); /* Validate mode, autodetecting any GGI_AUTO or GT_AUTO fields */ - ggiCheckMode (VIS, &mode); + ggiCheckMode(VIS, &mode); /* At this point we should have a valid mode - try to set it */ - err = ggiSetMode (VIS, &mode); + err = ggiSetMode(VIS, &mode); /* If we couldn't set _any_ modes, something is very wrong */ if (err) { - SDL_SetError ("Can't set a mode!\n"); - ggiClose (VIS); - ggiExit (); - GGI_VideoQuit (NULL); + SDL_SetError("Can't set a mode!\n"); + ggiClose(VIS); + ggiExit(); + GGI_VideoQuit(NULL); } /* Determine the current screen size */ @@ -203,18 +203,18 @@ this->info.current_h = mode.virt.y; /* Set a palette for palletized modes */ - if (GT_SCHEME (mode.graphtype) == GT_PALETTE) { - ggiSetColorfulPalette (VIS); - ggiGetPalette (VIS, 0, 1 << vformat->BitsPerPixel, pal); + if (GT_SCHEME(mode.graphtype) == GT_PALETTE) { + ggiSetColorfulPalette(VIS); + ggiGetPalette(VIS, 0, 1 << vformat->BitsPerPixel, pal); } /* Now we try to get the DirectBuffer info, which determines whether * SDL can access hardware surfaces directly. */ - num_bufs = ggiDBGetNumBuffers (VIS); + num_bufs = ggiDBGetNumBuffers(VIS); if (num_bufs > 0) { - db = ggiDBGetBuffer (VIS, 0); /* Only handle one DB for now */ + db = ggiDBGetBuffer(VIS, 0); /* Only handle one DB for now */ vformat->BitsPerPixel = db->buffer.plb.pixelformat->depth; @@ -240,17 +240,17 @@ } static SDL_Rect ** -GGI_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +GGI_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { return (&SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]); } /* Various screen update functions available */ -static void GGI_DirectUpdate (_THIS, int numrects, SDL_Rect * rects); +static void GGI_DirectUpdate(_THIS, int numrects, SDL_Rect * rects); SDL_Surface * -GGI_SetVideoMode (_THIS, SDL_Surface * current, int width, int height, - int bpp, Uint32 flags) +GGI_SetVideoMode(_THIS, SDL_Surface * current, int width, int height, + int bpp, Uint32 flags) { ggi_mode mode = { 1, @@ -264,7 +264,7 @@ ggi_color pal[256]; int err; - fprintf (stderr, "GGI_SetVideoMode()\n"); + fprintf(stderr, "GGI_SetVideoMode()\n"); mode.visible.x = mode.virt.x = width; mode.visible.y = mode.virt.y = height; @@ -296,31 +296,31 @@ mode.graphtype = GT_32BIT; break; default: - SDL_SetError ("Unknown SDL bit depth, using GT_AUTO....\n"); + SDL_SetError("Unknown SDL bit depth, using GT_AUTO....\n"); mode.graphtype = GT_AUTO; } /* Validate mode, autodetecting any GGI_AUTO or GT_AUTO fields */ - ggiCheckMode (VIS, &mode); + ggiCheckMode(VIS, &mode); /* At this point we should have a valid mode - try to set it */ - err = ggiSetMode (VIS, &mode); + err = ggiSetMode(VIS, &mode); /* If we couldn't set _any_ modes, something is very wrong */ if (err) { - SDL_SetError ("Can't set a mode!\n"); - ggiClose (VIS); - ggiExit (); - GGI_VideoQuit (NULL); + SDL_SetError("Can't set a mode!\n"); + ggiClose(VIS); + ggiExit(); + GGI_VideoQuit(NULL); } /* Set a palette for palletized modes */ - if (GT_SCHEME (mode.graphtype) == GT_PALETTE) { - ggiSetColorfulPalette (VIS); - ggiGetPalette (VIS, 0, 1 << bpp, pal); + if (GT_SCHEME(mode.graphtype) == GT_PALETTE) { + ggiSetColorfulPalette(VIS); + ggiGetPalette(VIS, 0, 1 << bpp, pal); } - db = ggiDBGetBuffer (VIS, 0); + db = ggiDBGetBuffer(VIS, 0); /* Set up the new mode framebuffer */ current->flags = (SDL_FULLSCREEN | SDL_HWSURFACE); @@ -337,41 +337,41 @@ } static int -GGI_AllocHWSurface (_THIS, SDL_Surface * surface) +GGI_AllocHWSurface(_THIS, SDL_Surface * surface) { return (-1); } static void -GGI_FreeHWSurface (_THIS, SDL_Surface * surface) +GGI_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } static int -GGI_LockHWSurface (_THIS, SDL_Surface * surface) +GGI_LockHWSurface(_THIS, SDL_Surface * surface) { return (0); } static void -GGI_UnlockHWSurface (_THIS, SDL_Surface * surface) +GGI_UnlockHWSurface(_THIS, SDL_Surface * surface) { return; } static void -GGI_DirectUpdate (_THIS, int numrects, SDL_Rect * rects) +GGI_DirectUpdate(_THIS, int numrects, SDL_Rect * rects) { int i; /* ggiFlush(VIS); */ for (i = 0; i < numrects; i++) { - ggiFlushRegion (VIS, rects[i].x, rects[i].y, rects[i].w, rects[i].h); + ggiFlushRegion(VIS, rects[i].x, rects[i].y, rects[i].w, rects[i].h); } return; } int -GGI_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +GGI_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { int i; ggi_color pal[256]; @@ -383,17 +383,17 @@ pal[i].b = (colors[i].b << 8) | colors[i].b; } - ggiSetPalette (VIS, firstcolor, ncolors, pal); + ggiSetPalette(VIS, firstcolor, ncolors, pal); return 1; } void -GGI_VideoQuit (_THIS) +GGI_VideoQuit(_THIS) { } void -GGI_FinalQuit (void) +GGI_FinalQuit(void) { } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ggi/SDL_ggivideo.h --- a/src/video/ggi/SDL_ggivideo.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ggi/SDL_ggivideo.h Mon May 29 04:04:35 2006 +0000 @@ -40,10 +40,10 @@ extern ggi_visual_t VIS; /* FIXME: use the private data struct */ -extern int SDL_OpenKeyboard (void); -extern void SDL_CloseKeyboard (void); -extern int SDL_OpenMouse (void); -extern void SDL_CloseMouse (void); +extern int SDL_OpenKeyboard(void); +extern void SDL_CloseKeyboard(void); +extern int SDL_OpenMouse(void); +extern void SDL_CloseMouse(void); #endif /* _SDL_ggivideo_h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/glsdl/SDL_glsdl.c --- a/src/video/glsdl/SDL_glsdl.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/glsdl/SDL_glsdl.c Mon May 29 04:04:35 2006 +0000 @@ -45,26 +45,26 @@ /* Initialization/Query functions */ /* Hardware surface functions */ -static int glSDL_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static int glSDL_AllocHWSurface (_THIS, SDL_Surface * surface); -static int glSDL_LockHWSurface (_THIS, SDL_Surface * surface); -static int glSDL_FlipHWSurface (_THIS, SDL_Surface * surface); -static void glSDL_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void glSDL_FreeHWSurface (_THIS, SDL_Surface * surface); -static int glSDL_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * rect, - Uint32 color); -static int glSDL_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst); -static int glSDL_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key); -static int glSDL_SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 alpha); -static int glSDL_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **glSDL_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static void glSDL_VideoQuit (_THIS); -static void glSDL_UpdateRects (_THIS, int numrects, SDL_Rect * rects); -static SDL_Surface *glSDL_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); +static int glSDL_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static int glSDL_AllocHWSurface(_THIS, SDL_Surface * surface); +static int glSDL_LockHWSurface(_THIS, SDL_Surface * surface); +static int glSDL_FlipHWSurface(_THIS, SDL_Surface * surface); +static void glSDL_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void glSDL_FreeHWSurface(_THIS, SDL_Surface * surface); +static int glSDL_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, + Uint32 color); +static int glSDL_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst); +static int glSDL_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key); +static int glSDL_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha); +static int glSDL_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **glSDL_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +static void glSDL_VideoQuit(_THIS); +static void glSDL_UpdateRects(_THIS, int numrects, SDL_Rect * rects); +static SDL_Surface *glSDL_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, + Uint32 flags); #define IS_GLSDL_SURFACE(s) ((s) && glSDL_GetTexInfo(s)) @@ -79,8 +79,8 @@ * do some internal blitting... */ static void -glSDL_SoftBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +glSDL_SoftBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { SDL_BlitInfo info; @@ -91,7 +91,7 @@ /* Check to make sure the blit mapping is valid */ if ((src->map->dst != dst) || (src->map->dst->format_version != src->map->format_version)) - if (SDL_MapSurface (src, dst) < 0) + if (SDL_MapSurface(src, dst) < 0) return; /* Set up the blit information */ @@ -128,7 +128,7 @@ info.table = src->map->table; info.dst = dst->format; - src->map->sw_data->blit (&info); + src->map->sw_data->blit(&info); } @@ -138,8 +138,8 @@ * Does not convert into palletized formats. */ static SDL_Surface * -glSDL_ConvertSurface (SDL_Surface * surface, - SDL_PixelFormat * format, Uint32 flags) +glSDL_ConvertSurface(SDL_Surface * surface, + SDL_PixelFormat * format, Uint32 flags) { SDL_Surface *convert; Uint32 colorkey = 0; @@ -148,11 +148,11 @@ SDL_Rect bounds; /* Create a new surface with the desired format */ - convert = SDL_CreateRGBSurface (flags, - surface->w, surface->h, - format->BitsPerPixel, format->Rmask, - format->Gmask, format->Bmask, - format->Amask); + convert = SDL_CreateRGBSurface(flags, + surface->w, surface->h, + format->BitsPerPixel, format->Rmask, + format->Gmask, format->Bmask, + format->Amask); if (convert == NULL) { return (NULL); } @@ -165,7 +165,7 @@ surface_flags &= ~SDL_SRCCOLORKEY; } else { colorkey = surface->format->colorkey; - SDL_SetColorKey (surface, 0, 0); + SDL_SetColorKey(surface, 0, 0); } } if ((surface_flags & SDL_SRCALPHA) == SDL_SRCALPHA) { @@ -174,7 +174,7 @@ surface->flags &= ~SDL_SRCALPHA; } else { alpha = surface->format->alpha; - SDL_SetAlpha (surface, 0, 0); + SDL_SetAlpha(surface, 0, 0); } } @@ -183,32 +183,32 @@ bounds.y = 0; bounds.w = surface->w; bounds.h = surface->h; - glSDL_SoftBlit (surface, &bounds, convert, &bounds); + glSDL_SoftBlit(surface, &bounds, convert, &bounds); /* Clean up the original surface, and update converted surface */ if (convert != NULL) { - SDL_SetClipRect (convert, &surface->clip_rect); + SDL_SetClipRect(convert, &surface->clip_rect); } if ((surface_flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { Uint32 cflags = surface_flags & (SDL_SRCCOLORKEY | SDL_RLEACCELOK); if (convert != NULL) { Uint8 keyR, keyG, keyB; - SDL_GetRGB (colorkey, surface->format, &keyR, &keyG, &keyB); - SDL_SetColorKey (convert, cflags | (flags & SDL_RLEACCELOK), - SDL_MapRGB (convert->format, keyR, keyG, keyB)); + SDL_GetRGB(colorkey, surface->format, &keyR, &keyG, &keyB); + SDL_SetColorKey(convert, cflags | (flags & SDL_RLEACCELOK), + SDL_MapRGB(convert->format, keyR, keyG, keyB)); } - SDL_SetColorKey (surface, cflags, colorkey); + SDL_SetColorKey(surface, cflags, colorkey); } if ((surface_flags & SDL_SRCALPHA) == SDL_SRCALPHA) { Uint32 aflags = surface_flags & (SDL_SRCALPHA | SDL_RLEACCELOK); if (convert != NULL) { - SDL_SetAlpha (convert, aflags | (flags & SDL_RLEACCELOK), alpha); + SDL_SetAlpha(convert, aflags | (flags & SDL_RLEACCELOK), alpha); } if (format->Amask) { surface->flags |= SDL_SRCALPHA; } else { - SDL_SetAlpha (surface, aflags, alpha); + SDL_SetAlpha(surface, aflags, alpha); } } @@ -230,7 +230,7 @@ } glstate; static void -glSDL_reset (void) +glSDL_reset(void) { glstate.do_blend = -1; glstate.do_blend = -1; @@ -240,50 +240,50 @@ } static __inline__ void -glSDL_do_blend (_THIS, int on) +glSDL_do_blend(_THIS, int on) { if (glstate.do_blend == on) return; if (on) - this->glEnable (GL_BLEND); + this->glEnable(GL_BLEND); else - this->glDisable (GL_BLEND); + this->glDisable(GL_BLEND); glstate.do_blend = on; } static __inline__ void -glSDL_do_texture (_THIS, int on) +glSDL_do_texture(_THIS, int on) { if (glstate.do_texture == on) return; if (on) - this->glEnable (GL_TEXTURE_2D); + this->glEnable(GL_TEXTURE_2D); else - this->glDisable (GL_TEXTURE_2D); + this->glDisable(GL_TEXTURE_2D); glstate.do_texture = on; } static __inline__ void -glSDL_blendfunc (_THIS, GLenum sfactor, GLenum dfactor) +glSDL_blendfunc(_THIS, GLenum sfactor, GLenum dfactor) { if ((sfactor == glstate.sfactor) && (dfactor == glstate.dfactor)) return; - this->glBlendFunc (sfactor, dfactor); + this->glBlendFunc(sfactor, dfactor); glstate.sfactor = sfactor; glstate.dfactor = dfactor; } static __inline__ void -glSDL_texture (_THIS, GLuint tx) +glSDL_texture(_THIS, GLuint tx) { if (tx == glstate.texture) return; - this->glBindTexture (GL_TEXTURE_2D, tx); + this->glBindTexture(GL_TEXTURE_2D, tx); glstate.texture = tx; } @@ -326,16 +326,16 @@ } private_hwdata; /* some function prototypes */ -static void glSDL_Invalidate (SDL_Surface * surface, SDL_Rect * area); -static void glSDL_SetLogicSize (_THIS, SDL_Surface * surface, int w, int h); -static private_hwdata *glSDL_UploadSurface (_THIS, SDL_Surface * surface); -static private_hwdata *glSDL_GetTexInfo (SDL_Surface * surface); -static void glSDL_init_formats (_THIS); -static private_hwdata *glSDL_AddTexInfo (_THIS, SDL_Surface * surface); -static void glSDL_RemoveTexInfo (_THIS, SDL_Surface * surface); -static void glSDL_UnloadTexture (_THIS, private_hwdata * txi); -static int glSDL_BlitGL (_THIS, SDL_Surface * src, - SDL_Rect * srcrect, SDL_Rect * dstrect); +static void glSDL_Invalidate(SDL_Surface * surface, SDL_Rect * area); +static void glSDL_SetLogicSize(_THIS, SDL_Surface * surface, int w, int h); +static private_hwdata *glSDL_UploadSurface(_THIS, SDL_Surface * surface); +static private_hwdata *glSDL_GetTexInfo(SDL_Surface * surface); +static void glSDL_init_formats(_THIS); +static private_hwdata *glSDL_AddTexInfo(_THIS, SDL_Surface * surface); +static void glSDL_RemoveTexInfo(_THIS, SDL_Surface * surface); +static void glSDL_UnloadTexture(_THIS, private_hwdata * txi); +static int glSDL_BlitGL(_THIS, SDL_Surface * src, + SDL_Rect * srcrect, SDL_Rect * dstrect); /* some variables */ static GLint maxtexsize = -1; @@ -350,15 +350,15 @@ #ifdef DEBUG_GLSDL static __inline__ int -GLERET (const char *txt) +GLERET(const char *txt) { - fprintf (stderr, "glSDL ERROR: '%s'\n", txt); + fprintf(stderr, "glSDL ERROR: '%s'\n", txt); return -1; } static __inline__ void -GLERR (const char *txt) +GLERR(const char *txt) { - fprintf (stderr, "glSDL ERROR: '%s'\n", txt); + fprintf(stderr, "glSDL ERROR: '%s'\n", txt); } #else #define GLERET(x) (-1) @@ -395,37 +395,37 @@ #endif static int -glSDL_Available (void) +glSDL_Available(void) { #ifdef DEBUG_GLSDL - fprintf (stderr, "available\n"); + fprintf(stderr, "available\n"); #endif if (opengl_bootstrap == NULL) return 0; - return (opengl_bootstrap->available ()); + return (opengl_bootstrap->available()); } static void -glSDL_DeleteDevice (SDL_VideoDevice * device) +glSDL_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } /* Create a glSDL device */ static SDL_VideoDevice * -glSDL_CreateDevice (int devindex) +glSDL_CreateDevice(int devindex) { SDL_VideoDevice *device; #ifdef DEBUG_GLSDL - fprintf (stderr, "entering createdevice\n"); + fprintf(stderr, "entering createdevice\n"); #endif /* Create the device with the underlying driver */ - device = opengl_bootstrap->create (devindex); + device = opengl_bootstrap->create(devindex); /* Save the video device contents for future use */ - SDL_memcpy (&underlying_device, device, sizeof (SDL_VideoDevice)); + SDL_memcpy(&underlying_device, device, sizeof(SDL_VideoDevice)); /* Hook glSDL on the video device */ device->VideoInit = glSDL_VideoInit; @@ -462,7 +462,7 @@ device->free = glSDL_DeleteDevice; #ifdef DEBUG_GLSDL - fprintf (stderr, "leaving createdevice\n"); + fprintf(stderr, "leaving createdevice\n"); #endif return device; @@ -475,14 +475,14 @@ }; static int -glSDL_VideoInit (_THIS, SDL_PixelFormat * vformat) +glSDL_VideoInit(_THIS, SDL_PixelFormat * vformat) { int r; - printf ("glSDL videoinit\n"); + printf("glSDL videoinit\n"); #ifdef DEBUG_GLSDL - fprintf (stderr, "videoinit\n"); + fprintf(stderr, "videoinit\n"); #endif - r = underlying_device.VideoInit (this, vformat); + r = underlying_device.VideoInit(this, vformat); this->info.hw_available = 1; this->info.blit_hw = 1; this->info.blit_hw_CC = 1; @@ -496,31 +496,31 @@ } SDL_Rect ** -glSDL_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +glSDL_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { return ((SDL_Rect **) - 1); } static void -glSDL_VideoQuit (_THIS) +glSDL_VideoQuit(_THIS) { SDL_Surface *scr; /* free all hwdata structures */ while (first != NULL) - glSDL_RemoveTexInfo (this, first); + glSDL_RemoveTexInfo(this, first); - SDL_free (mirrorbuf); + SDL_free(mirrorbuf); mirrorbuf = NULL; - SDL_FreeFormat (RGBfmt); - SDL_FreeFormat (RGBAfmt); + SDL_FreeFormat(RGBfmt); + SDL_FreeFormat(RGBAfmt); RGBfmt = RGBAfmt = NULL; - SDL_FreeFormat (this->displayformatalphapixel); + SDL_FreeFormat(this->displayformatalphapixel); this->displayformatalphapixel = NULL; - SDL_FreeSurface (OpenGL_Surface); + SDL_FreeSurface(OpenGL_Surface); OpenGL_Surface = NULL; /* restore the flags to gracefully exit from fullscreen */ @@ -530,30 +530,30 @@ scr = this->screen; /* we cleaned up our stuff, now restore the underlying video driver */ - SDL_memcpy (this, &underlying_device, sizeof (SDL_VideoDevice)); + SDL_memcpy(this, &underlying_device, sizeof(SDL_VideoDevice)); this->screen = scr; /* call the underlying video driver's VideoQuit function */ - this->VideoQuit (this); + this->VideoQuit(this); } static SDL_Surface * -glSDL_SetVideoMode (_THIS, SDL_Surface * current, int width, int height, - int bpp, Uint32 flags) +glSDL_SetVideoMode(_THIS, SDL_Surface * current, int width, int height, + int bpp, Uint32 flags) { SDL_Surface *hooked_screen; int i; int flag_doublebuf = 0; if (opengl_bootstrap == NULL) { - GLERR ("No bootstrap for glSDL compiled in !\n"); + GLERR("No bootstrap for glSDL compiled in !\n"); return NULL; } /* we don't have OpenGL */ if ((flags & SDL_INTERNALOPENGL) == SDL_INTERNALOPENGL) { - GLERR ("OpenGL video modes are not supported by glSDL !\n"); + GLERR("OpenGL video modes are not supported by glSDL !\n"); return (NULL); } @@ -566,19 +566,19 @@ /* remember whether the user requested DOUBLEBUF */ if (flags & SDL_DOUBLEBUF) { - SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); flag_doublebuf = 1; } else { - SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 0); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0); flag_doublebuf = 0; } hooked_screen = - underlying_device.SetVideoMode (this, current, width, height, 0, - flags); + underlying_device.SetVideoMode(this, current, width, height, 0, + flags); if (!hooked_screen) { - GLERR ("Unable to open an OpenGL window !\n"); + GLERR("Unable to open an OpenGL window !\n"); return (NULL); } @@ -586,7 +586,7 @@ old_screen_flags = hooked_screen->flags; #ifdef DEBUG_GLSDL - fprintf (stderr, "got %d bpp\n", bpp); + fprintf(stderr, "got %d bpp\n", bpp); #endif /* setup the public surface format @@ -595,57 +595,49 @@ switch (bpp) { case 32: this->is_32bit = 1; - this->screen = SDL_CreateRGBSurface (flags, width, height, bpp, + this->screen = SDL_CreateRGBSurface(flags, width, height, bpp, #if SDL_BYTEORDER == SDL_LIL_ENDIAN - 0x00FF0000, - 0x0000FF00, - 0x000000FF, 0x00000000 + 0x00FF0000, + 0x0000FF00, 0x000000FF, 0x00000000 #else - 0x0000FF00, - 0x00FF0000, - 0xFF000000, 0x00000000 + 0x0000FF00, + 0x00FF0000, 0xFF000000, 0x00000000 #endif ); break; case 24: this->is_32bit = 0; - this->screen = SDL_CreateRGBSurface (flags, width, height, bpp, + this->screen = SDL_CreateRGBSurface(flags, width, height, bpp, #if SDL_BYTEORDER == SDL_LIL_ENDIAN - 0x00FF0000, - 0x0000FF00, - 0x000000FF, 0x00000000 + 0x00FF0000, + 0x0000FF00, 0x000000FF, 0x00000000 #else - 0x0000FF00, - 0x00FF0000, - 0xFF000000, 0x00000000 + 0x0000FF00, + 0x00FF0000, 0xFF000000, 0x00000000 #endif ); break; case 16: this->is_32bit = 0; - this->screen = SDL_CreateRGBSurface (flags, width, height, bpp, + this->screen = SDL_CreateRGBSurface(flags, width, height, bpp, #if SDL_BYTEORDER == SDL_LIL_ENDIAN - 0x0000F800, - 0x000007E0, - 0x0000001F, 0x00000000 + 0x0000F800, + 0x000007E0, 0x0000001F, 0x00000000 #else - 0x0000001F, - 0x000007E0, - 0x0000F800, 0x00000000 + 0x0000001F, + 0x000007E0, 0x0000F800, 0x00000000 #endif ); break; case 15: this->is_32bit = 0; - this->screen = SDL_CreateRGBSurface (flags, width, height, bpp, + this->screen = SDL_CreateRGBSurface(flags, width, height, bpp, #if SDL_BYTEORDER == SDL_LIL_ENDIAN - 0x00007C00, - 0x000003E0, - 0x0000001F, 0x00000000 + 0x00007C00, + 0x000003E0, 0x0000001F, 0x00000000 #else - 0x0000001F, - 0x000003E0, - 0x00007C00, 0x00000000 + 0x0000001F, + 0x000003E0, 0x00007C00, 0x00000000 #endif ); break; @@ -653,7 +645,7 @@ default: this->is_32bit = 0; this->screen = - SDL_CreateRGBSurface (flags, width, height, bpp, 0, 0, 0, 0); + SDL_CreateRGBSurface(flags, width, height, bpp, 0, 0, 0, 0); /* give it a default palette if 8 bpp * note : SDL already takes care of the palette for 4 bits & 1 bit surfaces */ @@ -673,26 +665,26 @@ this->screen->flags |= SDL_DOUBLEBUF; /* Tell SDL the alpha pixel format we'd like to have */ - this->displayformatalphapixel = SDL_AllocFormat (32, + this->displayformatalphapixel = SDL_AllocFormat(32, #if SDL_BYTEORDER == SDL_BIG_ENDIAN - 0xFF000000, - 0x00FF0000, - 0x0000FF00, 0x000000FF + 0xFF000000, + 0x00FF0000, + 0x0000FF00, 0x000000FF #else - 0x000000FF, - 0x0000FF00, - 0x00FF0000, 0xFF000000 + 0x000000FF, + 0x0000FF00, + 0x00FF0000, 0xFF000000 #endif ); /* Now create the raw OpenGL surface */ - OpenGL_Surface = SDL_CreateRGBSurface (flags, width, height, 24, + OpenGL_Surface = SDL_CreateRGBSurface(flags, width, height, 24, #if SDL_BYTEORDER == SDL_LIL_ENDIAN - 0x000000FF, - 0x0000FF00, 0x00FF0000, 0x00000000 + 0x000000FF, + 0x0000FF00, 0x00FF0000, 0x00000000 #else - 0xFF000000, - 0x00FF0000, 0x0000FF00, 0x00000000 + 0xFF000000, + 0x00FF0000, 0x0000FF00, 0x00000000 #endif ); @@ -712,7 +704,7 @@ #include "../SDL_glfuncs.h" #undef SDL_PROC - if (this->GL_MakeCurrent (this) < 0) + if (this->GL_MakeCurrent(this) < 0) return (NULL); #define SDL_PROC(ret,func,params) \ do { \ @@ -729,46 +721,46 @@ #ifdef FAKE_MAXTEXSIZE maxtexsize = FAKE_MAXTEXSIZE; #else - this->glGetIntegerv (GL_MAX_TEXTURE_SIZE, &maxtexsize); + this->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxtexsize); #endif #ifdef DEBUG_GLSDL - fprintf (stderr, "glSDL: Max texture size: %d\n", maxtexsize); + fprintf(stderr, "glSDL: Max texture size: %d\n", maxtexsize); #endif - glSDL_init_formats (this); + glSDL_init_formats(this); if (flag_doublebuf) - this->glDrawBuffer (GL_BACK); + this->glDrawBuffer(GL_BACK); else - this->glDrawBuffer (GL_FRONT); + this->glDrawBuffer(GL_FRONT); - this->glDisable (GL_DITHER); + this->glDisable(GL_DITHER); - if (glSDL_AddTexInfo (this, this->screen) < 0) { - GLERR ("HookDevice() failed to add info to screen surface!"); + if (glSDL_AddTexInfo(this, this->screen) < 0) { + GLERR("HookDevice() failed to add info to screen surface!"); return NULL; } - glSDL_SetLogicSize (this, this->screen, this->screen->w, this->screen->h); + glSDL_SetLogicSize(this, this->screen, this->screen->w, this->screen->h); - glSDL_do_texture (this, 0); - glSDL_do_blend (this, 0); + glSDL_do_texture(this, 0); + glSDL_do_blend(this, 0); for (i = 0; i < 1 + flag_doublebuf; ++i) { - this->glBegin (GL_TRIANGLE_FAN); - this->glColor3ub (0, 0, 0); - this->glVertex2i (0, 0); - this->glVertex2i (this->screen->w, 0); - this->glVertex2i (this->screen->w, this->screen->h); - this->glVertex2i (0, this->screen->h); - this->glEnd (); + this->glBegin(GL_TRIANGLE_FAN); + this->glColor3ub(0, 0, 0); + this->glVertex2i(0, 0); + this->glVertex2i(this->screen->w, 0); + this->glVertex2i(this->screen->w, this->screen->h); + this->glVertex2i(0, this->screen->h); + this->glEnd(); if (!i) - this->GL_SwapBuffers (this); + this->GL_SwapBuffers(this); } - mirrorbuf = SDL_malloc (this->screen->h * this->screen->pitch); + mirrorbuf = SDL_malloc(this->screen->h * this->screen->pitch); if (!mirrorbuf) { - GLERR ("HookDevice() failed to allocate temp buffer for mirroring!"); + GLERR("HookDevice() failed to allocate temp buffer for mirroring!"); return NULL; } @@ -776,7 +768,7 @@ } static int -glSDL_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +glSDL_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { /* We don't need to fill this one */ return 0; @@ -785,10 +777,10 @@ #ifdef DEBUG_GLSDL static void -glSDL_print_glerror (_THIS, int point) +glSDL_print_glerror(_THIS, int point) { const char *err = ""; - switch (this->glGetError ()) { + switch (this->glGetError()) { case GL_NO_ERROR: return; case GL_INVALID_ENUM: @@ -811,13 +803,13 @@ default: break; } - fprintf (stderr, "OpenGL error \"%s\" at point %d.\n", err, point); + fprintf(stderr, "OpenGL error \"%s\" at point %d.\n", err, point); } #endif /* Get texinfo for a surface. */ static __inline__ private_hwdata * -glSDL_GetTexInfo (SDL_Surface * surface) +glSDL_GetTexInfo(SDL_Surface * surface) { if (!surface) return NULL; @@ -827,51 +819,51 @@ /* Allocate a "blank" texinfo for a suface. */ static private_hwdata * -glSDL_AllocTexInfo (SDL_Surface * surface) +glSDL_AllocTexInfo(SDL_Surface * surface) { private_hwdata *txi; if (!surface) return NULL; - txi = glSDL_GetTexInfo (surface); + txi = glSDL_GetTexInfo(surface); if (txi) return txi; /* There already is one! --> */ /* ...and hook a new texinfo struct up to it. */ - txi = (private_hwdata *) SDL_calloc (1, sizeof (private_hwdata)); + txi = (private_hwdata *) SDL_calloc(1, sizeof(private_hwdata)); if (!txi) { - GLERR ("AllocTexInfo(): Failed allocating TexInfo struct!"); + GLERR("AllocTexInfo(): Failed allocating TexInfo struct!"); return NULL; } txi->temporary = 1; #ifdef DEBUG_GLSDL - fprintf (stderr, "glSDL: Allocated TexInfo %p.\n", txi); + fprintf(stderr, "glSDL: Allocated TexInfo %p.\n", txi); #endif return txi; } static void -glSDL_FreeTexInfo (_THIS, private_hwdata * txi) +glSDL_FreeTexInfo(_THIS, private_hwdata * txi) { if (!txi) return; - glSDL_UnloadTexture (this, txi); - SDL_free (txi->texture); - SDL_free (txi); + glSDL_UnloadTexture(this, txi); + SDL_free(txi->texture); + SDL_free(txi); #ifdef DEBUG_GLSDL - fprintf (stderr, "glSDL: Freed TexInfo %p.\n", txi); + fprintf(stderr, "glSDL: Freed TexInfo %p.\n", txi); #endif } /* Detach and free the texinfo of a surface. */ static void -glSDL_RemoveTexInfo (_THIS, SDL_Surface * surface) +glSDL_RemoveTexInfo(_THIS, SDL_Surface * surface) { SDL_Surface *next, *prev; - if (!glSDL_GetTexInfo (surface)) + if (!glSDL_GetTexInfo(surface)) return; /* maintain our doubly linked list */ @@ -886,7 +878,7 @@ next->hwdata->prev = prev; } - glSDL_FreeTexInfo (this, surface->hwdata); + glSDL_FreeTexInfo(this, surface->hwdata); surface->hwdata = NULL; } @@ -897,7 +889,7 @@ * texture. */ static int -glSDL_CalcChop (private_hwdata * txi) +glSDL_CalcChop(private_hwdata * txi) { int rows, vw, vh; int vertical = 0; @@ -908,7 +900,7 @@ vh = txi->virt.h; #ifdef DEBUG_GLSDL_CHOP - fprintf (stderr, "w=%d, h=%d ", vw, vh); + fprintf(stderr, "w=%d, h=%d ", vw, vh); #endif if (vh > vw) { int t = vw; @@ -916,7 +908,7 @@ vh = t; vertical = 1; #ifdef DEBUG_GLSDL_CHOP - fprintf (stderr, "(vertical) \t"); + fprintf(stderr, "(vertical) \t"); #endif } @@ -927,7 +919,7 @@ */ #ifdef DEBUG_GLSDL if (maxtexsize < 0) - return GLERET ("glSDL_CalcChop() called before OpenGL init!"); + return GLERET("glSDL_CalcChop() called before OpenGL init!"); #endif if (vh > maxtexsize) { /* @@ -945,14 +937,14 @@ /* Calculate number of textures needed */ txi->textures = (vw + texsize - 1) / texsize; txi->textures *= (vh + texsize - 1) / texsize; - txi->texture = SDL_malloc (txi->textures * sizeof (int)); - SDL_memset (txi->texture, -1, txi->textures * sizeof (int)); + txi->texture = SDL_malloc(txi->textures * sizeof(int)); + SDL_memset(txi->texture, -1, txi->textures * sizeof(int)); #ifdef DEBUG_GLSDL - fprintf (stderr, "two-way tiling; textures=%d\n", txi->textures); + fprintf(stderr, "two-way tiling; textures=%d\n", txi->textures); #endif if (!txi->texture) { - fprintf (stderr, "glSDL: INTERNAL ERROR: Failed to allocate" - " texture name table!\n"); + fprintf(stderr, "glSDL: INTERNAL ERROR: Failed to allocate" + " texture name table!\n"); return -3; } return 0; @@ -983,8 +975,8 @@ rows = (vw + minsize - 1) / minsize; } #ifdef DEBUG_GLSDL_CHOP - fprintf (stderr, "==> minsize=%d ", minsize); - fprintf (stderr, "(rows=%d) \t", rows); + fprintf(stderr, "==> minsize=%d ", minsize); + fprintf(stderr, "(rows=%d) \t", rows); #endif /* Recalculate with nearest higher power-of-2 width. */ @@ -992,24 +984,24 @@ txi->texsize = texsize; rows = (vw + texsize - 1) / texsize; #ifdef DEBUG_GLSDL_CHOP - fprintf (stderr, "==> texsize=%d (rows=%d) \t", texsize, rows); + fprintf(stderr, "==> texsize=%d (rows=%d) \t", texsize, rows); #endif /* Calculate number of tiles per texture */ txi->tilespertex = txi->texsize / vh; #ifdef DEBUG_GLSDL_CHOP - fprintf (stderr, "tilespertex=%d \t", txi->tilespertex); + fprintf(stderr, "tilespertex=%d \t", txi->tilespertex); #endif /* Calculate number of textures needed */ txi->textures = (rows + txi->tilespertex - 1) / txi->tilespertex; - txi->texture = (GLuint *) SDL_malloc (txi->textures * sizeof (GLuint)); - SDL_memset (txi->texture, GLSDL_NOTEX, txi->textures * sizeof (GLuint)); + txi->texture = (GLuint *) SDL_malloc(txi->textures * sizeof(GLuint)); + SDL_memset(txi->texture, GLSDL_NOTEX, txi->textures * sizeof(GLuint)); #ifdef DEBUG_GLSDL_CHOP - fprintf (stderr, "textures=%d, ", txi->textures); + fprintf(stderr, "textures=%d, ", txi->textures); #endif if (!txi->texture) - return GLERET ("Failed to allocate texture name table!"); + return GLERET("Failed to allocate texture name table!"); /* Set up tile size. (Only one axis supported here!) */ if (1 == rows) { @@ -1032,7 +1024,7 @@ } #ifdef DEBUG_GLSDL_CHOP - fprintf (stderr, "tilew=%d, tileh=%d\n", txi->tilew, txi->tileh); + fprintf(stderr, "tilew=%d, tileh=%d\n", txi->tilew, txi->tileh); #endif return 0; } @@ -1040,27 +1032,27 @@ /* Create a temporary TexInfo struct for an SDL_Surface */ static private_hwdata * -glSDL_CreateTempTexInfo (_THIS, SDL_Surface * surface) +glSDL_CreateTempTexInfo(_THIS, SDL_Surface * surface) { private_hwdata *txi; if (!surface) { - GLERR ("CreateTempTexInfo(); no surface!"); + GLERR("CreateTempTexInfo(); no surface!"); return NULL; } - if (IS_GLSDL_SURFACE (surface)) - return glSDL_GetTexInfo (surface); /* Do nothing */ + if (IS_GLSDL_SURFACE(surface)) + return glSDL_GetTexInfo(surface); /* Do nothing */ - txi = glSDL_AllocTexInfo (surface); + txi = glSDL_AllocTexInfo(surface); if (!txi) { - GLERR ("CreateTempTexInfo(); Could not alloc TexInfo!"); + GLERR("CreateTempTexInfo(); Could not alloc TexInfo!"); return NULL; } txi->virt.w = txi->lw = surface->w; txi->virt.h = txi->lh = surface->h; - if (glSDL_CalcChop (txi) < 0) { - glSDL_FreeTexInfo (this, txi); - GLERR ("CreateTempTexInfo(); CalcChop() failed!"); + if (glSDL_CalcChop(txi) < 0) { + glSDL_FreeTexInfo(this, txi); + GLERR("CreateTempTexInfo(); CalcChop() failed!"); return NULL; } @@ -1069,9 +1061,9 @@ /* Add a glSDL_TexInfo struct to an SDL_Surface */ static private_hwdata * -glSDL_AddTexInfo (_THIS, SDL_Surface * surface) +glSDL_AddTexInfo(_THIS, SDL_Surface * surface) { - private_hwdata *txi = glSDL_CreateTempTexInfo (this, surface); + private_hwdata *txi = glSDL_CreateTempTexInfo(this, surface); if (!txi) return NULL; @@ -1087,7 +1079,7 @@ txi->next->hwdata->prev = surface; } - SDL_SetClipRect (surface, &txi->virt); + SDL_SetClipRect(surface, &txi->virt); return txi; } @@ -1118,7 +1110,7 @@ /* Create a surface of the prefered OpenGL RGBA texture format */ static SDL_Surface * -glSDL_CreateRGBASurface (int w, int h) +glSDL_CreateRGBASurface(int w, int h) { SDL_Surface *s; Uint32 rmask, gmask, bmask, amask; @@ -1134,8 +1126,8 @@ bmask = 0x0000FF00; amask = 0x000000FF; #endif - s = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h, - bits, rmask, gmask, bmask, amask); + s = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, + bits, rmask, gmask, bmask, amask); if (s) s->flags |= SDL_HWACCEL; @@ -1144,27 +1136,25 @@ static void -glSDL_init_formats (_THIS) +glSDL_init_formats(_THIS) { - RGBfmt = SDL_AllocFormat (24, + RGBfmt = SDL_AllocFormat(24, #if SDL_BYTEORDER == SDL_LIL_ENDIAN - 0x000000FF, 0x0000FF00, 0x00FF0000, 0); + 0x000000FF, 0x0000FF00, 0x00FF0000, 0); #else - 0x00FF0000, 0x0000FF00, 0x000000FF, 0); + 0x00FF0000, 0x0000FF00, 0x000000FF, 0); #endif - RGBAfmt = SDL_AllocFormat (32, + RGBAfmt = SDL_AllocFormat(32, #if SDL_BYTEORDER == SDL_LIL_ENDIAN - 0x000000FF, - 0x0000FF00, 0x00FF0000, 0xFF000000); + 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); #else - 0xFF000000, - 0x00FF0000, 0x0000FF00, 0x000000FF); + 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); #endif } static int -glSDL_FormatIsOk (SDL_Surface * surface) +glSDL_FormatIsOk(SDL_Surface * surface) { SDL_PixelFormat *pf; if (!surface) @@ -1206,13 +1196,13 @@ } static void -glSDL_key2alpha (SDL_Surface * surface) +glSDL_key2alpha(SDL_Surface * surface) { int x, y; Uint32 ckey = surface->format->colorkey; #ifdef DEBUG_GLSDL - fprintf (stderr, "glSDL_key2alpha()\n"); + fprintf(stderr, "glSDL_key2alpha()\n"); #endif for (y = 0; y < surface->h; ++y) { Uint32 *px = @@ -1230,78 +1220,78 @@ ----------------------------------------------------------*/ static int -glSDL_FlipHWSurface (_THIS, SDL_Surface * surface) +glSDL_FlipHWSurface(_THIS, SDL_Surface * surface) { #ifdef GLSDL_GRAPHICAL_DEBUG - this->glDisable (GL_TEXTURE_2D); - this->glBegin (GL_LINE_LOOP); - this->glColor4ub (0, 0, 255, 128); - this->glVertex2i (0, 0); - this->glVertex2i (surface->w, 0); - this->glVertex2i (surface->w, surface->h); - this->glVertex2i (0, surface->h); - this->glEnd (); - this->glEnable (GL_TEXTURE_2D); + this->glDisable(GL_TEXTURE_2D); + this->glBegin(GL_LINE_LOOP); + this->glColor4ub(0, 0, 255, 128); + this->glVertex2i(0, 0); + this->glVertex2i(surface->w, 0); + this->glVertex2i(surface->w, surface->h); + this->glVertex2i(0, surface->h); + this->glEnd(); + this->glEnable(GL_TEXTURE_2D); #endif if (this->screen->flags & SDL_DOUBLEBUF) - this->GL_SwapBuffers (this); + this->GL_SwapBuffers(this); else - this->glFinish (); + this->glFinish(); return 0; } static void -glSDL_UpdateRects (_THIS, int numrects, SDL_Rect * rects) +glSDL_UpdateRects(_THIS, int numrects, SDL_Rect * rects) { #ifdef GLSDL_GRAPHICAL_DEBUG int i; - this->glDisable (GL_TEXTURE_2D); + this->glDisable(GL_TEXTURE_2D); for (i = 0; i < numrects; i++) { - this->glColor4ub (255, 0, 0, 128); - this->glBegin (GL_LINE_LOOP); - this->glVertex2i (rects[i].x, rects[i].y); - this->glVertex2i (rects[i].x + rects[i].w, rects[i].y); - this->glVertex2i (rects[i].x + rects[i].w, rects[i].y + rects[i].h); - this->glVertex2i (rects[i].x, rects[i].y + rects[i].h); - this->glEnd (); + this->glColor4ub(255, 0, 0, 128); + this->glBegin(GL_LINE_LOOP); + this->glVertex2i(rects[i].x, rects[i].y); + this->glVertex2i(rects[i].x + rects[i].w, rects[i].y); + this->glVertex2i(rects[i].x + rects[i].w, rects[i].y + rects[i].h); + this->glVertex2i(rects[i].x, rects[i].y + rects[i].h); + this->glEnd(); } - this->glEnable (GL_TEXTURE_2D); + this->glEnable(GL_TEXTURE_2D); #endif if (this->screen->flags & SDL_DOUBLEBUF) - this->GL_SwapBuffers (this); + this->GL_SwapBuffers(this); else - this->glFinish (); + this->glFinish(); } static int -glSDL_AllocHWSurface (_THIS, SDL_Surface * surface) +glSDL_AllocHWSurface(_THIS, SDL_Surface * surface) { surface->flags |= (SDL_HWSURFACE | SDL_HWACCEL); - surface->pixels = SDL_malloc (surface->h * surface->pitch); + surface->pixels = SDL_malloc(surface->h * surface->pitch); if (surface->pixels == NULL) { - SDL_FreeSurface (surface); - SDL_OutOfMemory (); + SDL_FreeSurface(surface); + SDL_OutOfMemory(); return (-1); } - SDL_memset (surface->pixels, 0, surface->h * surface->pitch); + SDL_memset(surface->pixels, 0, surface->h * surface->pitch); return 0; } static void -glSDL_FreeHWSurface (_THIS, SDL_Surface * surface) +glSDL_FreeHWSurface(_THIS, SDL_Surface * surface) { if (!surface) return; - glSDL_RemoveTexInfo (this, surface); + glSDL_RemoveTexInfo(this, surface); } static int -glSDL_LockHWSurface (_THIS, SDL_Surface * surface) +glSDL_LockHWSurface(_THIS, SDL_Surface * surface) { int y; @@ -1309,43 +1299,43 @@ return -1; #ifdef DEBUG_GLSDL - fprintf (stderr, "glSDL: Lock Surface.\n"); + fprintf(stderr, "glSDL: Lock Surface.\n"); #endif if (SDL_VideoSurface == surface) { - glSDL_Invalidate (surface, NULL); - this->glPixelStorei (GL_UNPACK_ROW_LENGTH, - surface->pitch / surface->format->BytesPerPixel); - this->glReadPixels (0, 0, OpenGL_Surface->w, OpenGL_Surface->h, - GL_RGB, GL_UNSIGNED_BYTE, OpenGL_Surface->pixels); + glSDL_Invalidate(surface, NULL); + this->glPixelStorei(GL_UNPACK_ROW_LENGTH, + surface->pitch / surface->format->BytesPerPixel); + this->glReadPixels(0, 0, OpenGL_Surface->w, OpenGL_Surface->h, + GL_RGB, GL_UNSIGNED_BYTE, OpenGL_Surface->pixels); for (y = 0; y < OpenGL_Surface->h / 2; ++y) { void *upper = (Uint8 *) OpenGL_Surface->pixels + OpenGL_Surface->pitch * y; void *lower = (Uint8 *) OpenGL_Surface->pixels + OpenGL_Surface->pitch * (OpenGL_Surface->h - y - 1); - SDL_memcpy (mirrorbuf, upper, OpenGL_Surface->pitch); - SDL_memcpy (upper, lower, OpenGL_Surface->pitch); - SDL_memcpy (lower, mirrorbuf, OpenGL_Surface->pitch); + SDL_memcpy(mirrorbuf, upper, OpenGL_Surface->pitch); + SDL_memcpy(upper, lower, OpenGL_Surface->pitch); + SDL_memcpy(lower, mirrorbuf, OpenGL_Surface->pitch); } /* the mapping has to be invalidated on 8bpp video surfaces in case of a hw palette change. * Now if someone could tell me why this is not handled by SDL... */ if (SDL_VideoSurface->format->BitsPerPixel == 8) - SDL_InvalidateMap (OpenGL_Surface->map); + SDL_InvalidateMap(OpenGL_Surface->map); /* convert this raw surface to the application-requested format * FIXME this is sometimes overkill, we could use glPixelStore smartly * But this would be slow anyway :) */ - glSDL_SoftBlit (OpenGL_Surface, NULL, SDL_VideoSurface, NULL); + glSDL_SoftBlit(OpenGL_Surface, NULL, SDL_VideoSurface, NULL); } else - glSDL_Invalidate (surface, NULL); + glSDL_Invalidate(surface, NULL); return 0; } static void -glSDL_UnlockHWSurface (_THIS, SDL_Surface * surface) +glSDL_UnlockHWSurface(_THIS, SDL_Surface * surface) { private_hwdata *txi; @@ -1355,17 +1345,17 @@ /* upload this surface ONLY if this is a glSDL surface * because sometimes (during displayformating for ex.) surfaces are unlocked that aren't glSDL */ - if (!IS_GLSDL_SURFACE (surface)) + if (!IS_GLSDL_SURFACE(surface)) return; #ifdef DEBUG_GLSDL - fprintf (stderr, "glSDL: Unlock Surface.\n"); + fprintf(stderr, "glSDL: Unlock Surface.\n"); #endif - txi = glSDL_UploadSurface (this, surface); + txi = glSDL_UploadSurface(this, surface); if (!txi) { - GLERR ("glSDL_UnlockHWSurface() failed to upload surface!"); + GLERR("glSDL_UnlockHWSurface() failed to upload surface!"); return; } if (txi->temporary) { @@ -1374,12 +1364,12 @@ return; } if (surface == SDL_VideoSurface) - glSDL_BlitGL (this, SDL_VideoSurface, NULL, NULL); + glSDL_BlitGL(this, SDL_VideoSurface, NULL, NULL); } static int -glSDL_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key) +glSDL_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key) { /* * If an application does this *after* SDL_DisplayFormat, @@ -1390,14 +1380,14 @@ * deal in most cases, as glSDL only converts once anyway, * *unless* you keep modifying the surface. */ - if (IS_GLSDL_SURFACE (surface)) - glSDL_RemoveTexInfo (this, surface); + if (IS_GLSDL_SURFACE(surface)) + glSDL_RemoveTexInfo(this, surface); return 0; } static int -glSDL_SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 alpha) +glSDL_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha) { /* * If an application does this *after* SDL_DisplayFormat, @@ -1408,19 +1398,19 @@ * deal in most cases, as glSDL only converts once anyway, * *unless* you keep modifying the surface. */ - if (IS_GLSDL_SURFACE (surface)) - glSDL_RemoveTexInfo (this, surface); + if (IS_GLSDL_SURFACE(surface)) + glSDL_RemoveTexInfo(this, surface); return 0; } static SDL_bool -glSDL_SetClipRect (_THIS, SDL_Surface * surface, SDL_Rect * rect) +glSDL_SetClipRect(_THIS, SDL_Surface * surface, SDL_Rect * rect) { SDL_bool res; if (!surface) return SDL_FALSE; - res = SDL_SetClipRect (surface, rect); + res = SDL_SetClipRect(surface, rect); if (!res) return SDL_FALSE; @@ -1435,68 +1425,67 @@ r.y = rect->y; r.w = rect->w; r.h = rect->h; - SDL_SetClipRect (surface, rect); + SDL_SetClipRect(surface, rect); - txi = glSDL_GetTexInfo (surface); + txi = glSDL_GetTexInfo(surface); if (!txi) - return GLERET ("SetClipRect(): Could not get TexInfo!"); + return GLERET("SetClipRect(): Could not get TexInfo!"); - this->glViewport (rect->x, - surface->h - (rect->y + rect->h), rect->w, rect->h); + this->glViewport(rect->x, + surface->h - (rect->y + rect->h), rect->w, rect->h); /* * Note that this projection is upside down in * relation to the OpenGL coordinate system. */ - this->glMatrixMode (GL_PROJECTION); - this->glLoadIdentity (); + this->glMatrixMode(GL_PROJECTION); + this->glLoadIdentity(); xscale = (float) txi->lw / (float) surface->w; yscale = (float) txi->lh / (float) surface->h; - this->glOrtho (xscale * (float) rect->x, - xscale * (float) (rect->w + rect->x), - yscale * (float) (rect->h + rect->y), - yscale * (float) rect->y, -1.0, 1.0); + this->glOrtho(xscale * (float) rect->x, + xscale * (float) (rect->w + rect->x), + yscale * (float) (rect->h + rect->y), + yscale * (float) rect->y, -1.0, 1.0); return SDL_TRUE; } return res; } static int -glSDL_BlitFromGL (_THIS, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +glSDL_BlitFromGL(_THIS, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { SDL_Rect sr, dr; /* In case the destination has an OpenGL texture... */ - glSDL_Invalidate (dst, dstrect); + glSDL_Invalidate(dst, dstrect); /* Abuse the fake screen buffer a little. */ - this->glPixelStorei (GL_UNPACK_ROW_LENGTH, SDL_VideoSurface->pitch / - SDL_VideoSurface->format->BytesPerPixel); + this->glPixelStorei(GL_UNPACK_ROW_LENGTH, SDL_VideoSurface->pitch / + SDL_VideoSurface->format->BytesPerPixel); if (srcrect) - this->glReadPixels (srcrect->x, - OpenGL_Surface->h - (srcrect->y + srcrect->h - 1), - srcrect->w, srcrect->h, GL_RGB, GL_UNSIGNED_BYTE, - OpenGL_Surface->pixels); + this->glReadPixels(srcrect->x, + OpenGL_Surface->h - (srcrect->y + srcrect->h - 1), + srcrect->w, srcrect->h, GL_RGB, GL_UNSIGNED_BYTE, + OpenGL_Surface->pixels); else - this->glReadPixels (0, 0, OpenGL_Surface->w, OpenGL_Surface->h, - GL_RGB, GL_UNSIGNED_BYTE, OpenGL_Surface->pixels); + this->glReadPixels(0, 0, OpenGL_Surface->w, OpenGL_Surface->h, + GL_RGB, GL_UNSIGNED_BYTE, OpenGL_Surface->pixels); sr = *srcrect; dr = *dstrect; - glSDL_SoftBlit (OpenGL_Surface, &sr, dst, &dr); + glSDL_SoftBlit(OpenGL_Surface, &sr, dst, &dr); return 0; } static __inline__ void -glSDL_BlitGL_single (_THIS, private_hwdata * txi, - float sx1, float sy1, SDL_Rect * dst, - unsigned char alpha) +glSDL_BlitGL_single(_THIS, private_hwdata * txi, + float sx1, float sy1, SDL_Rect * dst, unsigned char alpha) { float sx2, sy2, texscale; if (!txi->textures) return; if (-1 == txi->texture[0]) return; - glSDL_texture (this, txi->texture[0]); + glSDL_texture(this, txi->texture[0]); texscale = 1.0 / (float) txi->texsize; sx2 = (sx1 + (float) dst->w) * texscale; @@ -1505,34 +1494,34 @@ sy1 *= texscale; #ifdef GLSDL_GRAPHICAL_DEBUG - this->glDisable (GL_TEXTURE_2D); - this->glBegin (GL_LINE_LOOP); - this->glColor4ub (0, 255, 0, 128); - this->glVertex2i (dst->x, dst->y); - this->glVertex2i (dst->x + dst->w, dst->y); - this->glVertex2i (dst->x + dst->w, dst->y + dst->h); - this->glVertex2i (dst->x, dst->y + dst->h); - this->glEnd (); - this->glEnable (GL_TEXTURE_2D); + this->glDisable(GL_TEXTURE_2D); + this->glBegin(GL_LINE_LOOP); + this->glColor4ub(0, 255, 0, 128); + this->glVertex2i(dst->x, dst->y); + this->glVertex2i(dst->x + dst->w, dst->y); + this->glVertex2i(dst->x + dst->w, dst->y + dst->h); + this->glVertex2i(dst->x, dst->y + dst->h); + this->glEnd(); + this->glEnable(GL_TEXTURE_2D); #endif - this->glBegin (GL_TRIANGLE_FAN); - this->glColor4ub (255, 255, 255, alpha); - this->glTexCoord2f (sx1, sy1); - this->glVertex2i (dst->x, dst->y); - this->glTexCoord2f (sx2, sy1); - this->glVertex2i (dst->x + dst->w, dst->y); - this->glTexCoord2f (sx2, sy2); - this->glVertex2i (dst->x + dst->w, dst->y + dst->h); - this->glTexCoord2f (sx1, sy2); - this->glVertex2i (dst->x, dst->y + dst->h); - this->glEnd (); + this->glBegin(GL_TRIANGLE_FAN); + this->glColor4ub(255, 255, 255, alpha); + this->glTexCoord2f(sx1, sy1); + this->glVertex2i(dst->x, dst->y); + this->glTexCoord2f(sx2, sy1); + this->glVertex2i(dst->x + dst->w, dst->y); + this->glTexCoord2f(sx2, sy2); + this->glVertex2i(dst->x + dst->w, dst->y + dst->h); + this->glTexCoord2f(sx1, sy2); + this->glVertex2i(dst->x, dst->y + dst->h); + this->glEnd(); } static void -glSDL_BlitGL_htile (_THIS, private_hwdata * txi, - float sx1, float sy1, SDL_Rect * dst, unsigned char alpha) +glSDL_BlitGL_htile(_THIS, private_hwdata * txi, + float sx1, float sy1, SDL_Rect * dst, unsigned char alpha) { int tex; float tile, sx2, sy2, yo; @@ -1542,7 +1531,7 @@ sy2 = (sy1 + (float) dst->h) * texscale; sx1 *= texscale; sy1 *= texscale; - tile = floor (sx1); + tile = floor(sx1); tex = (int) tile / txi->tilespertex; yo = ((int) tile % txi->tilespertex) * tileh; @@ -1550,7 +1539,7 @@ return; if (-1 == txi->texture[tex]) return; - glSDL_texture (this, txi->texture[tex]); + glSDL_texture(this, txi->texture[tex]); while (tile < sx2) { int tdx1 = dst->x; @@ -1575,32 +1564,32 @@ return; if (-1 == txi->texture[tex]) return; - glSDL_texture (this, txi->texture[tex]); + glSDL_texture(this, txi->texture[tex]); yo = 0.0; } #ifdef GLSDL_GRAPHICAL_DEBUG - this->glDisable (GL_TEXTURE_2D); - this->glBegin (GL_LINE_LOOP); - this->glColor4ub (0, 255, 0, 128); - this->glVertex2i (tdx1, dst->y); - this->glVertex2i (tdx2, dst->y); - this->glVertex2i (tdx2, dst->y + dst->h); - this->glVertex2i (tdx1, dst->y + dst->h); - this->glEnd (); - this->glEnable (GL_TEXTURE_2D); + this->glDisable(GL_TEXTURE_2D); + this->glBegin(GL_LINE_LOOP); + this->glColor4ub(0, 255, 0, 128); + this->glVertex2i(tdx1, dst->y); + this->glVertex2i(tdx2, dst->y); + this->glVertex2i(tdx2, dst->y + dst->h); + this->glVertex2i(tdx1, dst->y + dst->h); + this->glEnd(); + this->glEnable(GL_TEXTURE_2D); #endif - this->glBegin (GL_TRIANGLE_FAN); - this->glColor4ub (255, 255, 255, alpha); - this->glTexCoord2f (tsx1, yo + sy1); - this->glVertex2i (tdx1, dst->y); - this->glTexCoord2f (tsx2, yo + sy1); - this->glVertex2i (tdx2, dst->y); - this->glTexCoord2f (tsx2, yo + sy2); - this->glVertex2i (tdx2, dst->y + dst->h); - this->glTexCoord2f (tsx1, yo + sy2); - this->glVertex2i (tdx1, dst->y + dst->h); - this->glEnd (); + this->glBegin(GL_TRIANGLE_FAN); + this->glColor4ub(255, 255, 255, alpha); + this->glTexCoord2f(tsx1, yo + sy1); + this->glVertex2i(tdx1, dst->y); + this->glTexCoord2f(tsx2, yo + sy1); + this->glVertex2i(tdx2, dst->y); + this->glTexCoord2f(tsx2, yo + sy2); + this->glVertex2i(tdx2, dst->y + dst->h); + this->glTexCoord2f(tsx1, yo + sy2); + this->glVertex2i(tdx1, dst->y + dst->h); + this->glEnd(); tile += 1.0; yo += tileh; } @@ -1608,8 +1597,8 @@ static void -glSDL_BlitGL_vtile (_THIS, private_hwdata * txi, - float sx1, float sy1, SDL_Rect * dst, unsigned char alpha) +glSDL_BlitGL_vtile(_THIS, private_hwdata * txi, + float sx1, float sy1, SDL_Rect * dst, unsigned char alpha) { int tex; float tile, sx2, sy2, xo; @@ -1619,7 +1608,7 @@ sy2 = (sy1 + (float) dst->h) * texscale; sx1 *= texscale; sy1 *= texscale; - tile = floor (sy1); + tile = floor(sy1); tex = (int) tile / txi->tilespertex; xo = ((int) tile % txi->tilespertex) * tilew; @@ -1627,7 +1616,7 @@ return; if (-1 == txi->texture[tex]) return; - glSDL_texture (this, txi->texture[tex]); + glSDL_texture(this, txi->texture[tex]); while (tile < sy2) { int tdy1 = dst->y; @@ -1652,32 +1641,32 @@ return; if (-1 == txi->texture[tex]) return; - glSDL_texture (this, txi->texture[tex]); + glSDL_texture(this, txi->texture[tex]); xo = 0.0; } #ifdef GLSDL_GRAPHICAL_DEBUG - this->glDisable (GL_TEXTURE_2D); - this->glBegin (GL_LINE_LOOP); - this->glColor4ub (0, 255, 0, 128); - this->glVertex2i (dst->x, tdy1); - this->glVertex2i (dst->x + dst->w, tdy1); - this->glVertex2i (dst->x + dst->w, tdy2); - this->glVertex2i (dst->x, tdy2); - this->glEnd (); - this->glEnable (GL_TEXTURE_2D); + this->glDisable(GL_TEXTURE_2D); + this->glBegin(GL_LINE_LOOP); + this->glColor4ub(0, 255, 0, 128); + this->glVertex2i(dst->x, tdy1); + this->glVertex2i(dst->x + dst->w, tdy1); + this->glVertex2i(dst->x + dst->w, tdy2); + this->glVertex2i(dst->x, tdy2); + this->glEnd(); + this->glEnable(GL_TEXTURE_2D); #endif - this->glBegin (GL_TRIANGLE_FAN); - this->glColor4ub (255, 255, 255, alpha); - this->glTexCoord2f (xo + sx1, tsy1); - this->glVertex2i (dst->x, tdy1); - this->glTexCoord2f (xo + sx2, tsy1); - this->glVertex2i (dst->x + dst->w, tdy1); - this->glTexCoord2f (xo + sx2, tsy2); - this->glVertex2i (dst->x + dst->w, tdy2); - this->glTexCoord2f (xo + sx1, tsy2); - this->glVertex2i (dst->x, tdy2); - this->glEnd (); + this->glBegin(GL_TRIANGLE_FAN); + this->glColor4ub(255, 255, 255, alpha); + this->glTexCoord2f(xo + sx1, tsy1); + this->glVertex2i(dst->x, tdy1); + this->glTexCoord2f(xo + sx2, tsy1); + this->glVertex2i(dst->x + dst->w, tdy1); + this->glTexCoord2f(xo + sx2, tsy2); + this->glVertex2i(dst->x + dst->w, tdy2); + this->glTexCoord2f(xo + sx1, tsy2); + this->glVertex2i(dst->x, tdy2); + this->glEnd(); tile += 1.0; xo += tilew; @@ -1686,9 +1675,8 @@ static void -glSDL_BlitGL_hvtile (_THIS, SDL_Surface * src, private_hwdata * txi, - float sx1, float sy1, SDL_Rect * dst, - unsigned char alpha) +glSDL_BlitGL_hvtile(_THIS, SDL_Surface * src, private_hwdata * txi, + float sx1, float sy1, SDL_Rect * dst, unsigned char alpha) { int x, y, last_tex, tex; float sx2, sy2; @@ -1699,14 +1687,14 @@ sx1 *= texscale; sy1 *= texscale; - last_tex = tex = floor (sy1) * tilesperrow + floor (sx1); + last_tex = tex = floor(sy1) * tilesperrow + floor(sx1); if (tex >= txi->textures) return; if (-1 == txi->texture[tex]) return; - glSDL_texture (this, txi->texture[tex]); + glSDL_texture(this, txi->texture[tex]); - for (y = floor (sy1); y < sy2; ++y) { + for (y = floor(sy1); y < sy2; ++y) { int tdy1 = dst->y; int tdy2 = dst->y + dst->h; float tsy1 = sy1 - y; @@ -1721,7 +1709,7 @@ tdy2 -= (tsy2 - 1.0) * txi->texsize; tsy2 = 1.0; } - for (x = floor (sx1); x < sx2; ++x) { + for (x = floor(sx1); x < sx2; ++x) { int tdx1 = dst->x; int tdx2 = dst->x + dst->w; float tsx1 = sx1 - x; @@ -1744,32 +1732,32 @@ return; if (-1 == txi->texture[tex]) return; - glSDL_texture (this, txi->texture[tex]); + glSDL_texture(this, txi->texture[tex]); last_tex = tex; } #ifdef GLSDL_GRAPHICAL_DEBUG - this->glDisable (GL_TEXTURE_2D); - this->glBegin (GL_LINE_LOOP); - this->glColor4ub (0, 255, 0, 128); - this->glVertex2i (tdx1, tdy1); - this->glVertex2i (tdx2, tdy1); - this->glVertex2i (tdx2, tdy2); - this->glVertex2i (tdx1, tdy2); - this->glEnd (); - this->glEnable (GL_TEXTURE_2D); + this->glDisable(GL_TEXTURE_2D); + this->glBegin(GL_LINE_LOOP); + this->glColor4ub(0, 255, 0, 128); + this->glVertex2i(tdx1, tdy1); + this->glVertex2i(tdx2, tdy1); + this->glVertex2i(tdx2, tdy2); + this->glVertex2i(tdx1, tdy2); + this->glEnd(); + this->glEnable(GL_TEXTURE_2D); #endif - this->glBegin (GL_TRIANGLE_FAN); - this->glColor4ub (255, 255, 255, alpha); - this->glTexCoord2f (tsx1, tsy1); - this->glVertex2i (tdx1, tdy1); - this->glTexCoord2f (tsx2, tsy1); - this->glVertex2i (tdx2, tdy1); - this->glTexCoord2f (tsx2, tsy2); - this->glVertex2i (tdx2, tdy2); - this->glTexCoord2f (tsx1, tsy2); - this->glVertex2i (tdx1, tdy2); - this->glEnd (); + this->glBegin(GL_TRIANGLE_FAN); + this->glColor4ub(255, 255, 255, alpha); + this->glTexCoord2f(tsx1, tsy1); + this->glVertex2i(tdx1, tdy1); + this->glTexCoord2f(tsx2, tsy1); + this->glVertex2i(tdx2, tdy1); + this->glTexCoord2f(tsx2, tsy2); + this->glVertex2i(tdx2, tdy2); + this->glTexCoord2f(tsx1, tsy2); + this->glVertex2i(tdx1, tdy2); + this->glEnd(); } } } @@ -1790,7 +1778,7 @@ * Returns 1 if the result is visible, otherwise 0. */ static __inline__ int -blitclip (SDL_Rect * rect, int w, int h, int *x, int *y, SDL_Rect * clip) +blitclip(SDL_Rect * rect, int w, int h, int *x, int *y, SDL_Rect * clip) { int sx1, sy1, sx2, sy2; int dx1, dy1, dx2, dy2; @@ -1853,8 +1841,7 @@ } static int -glSDL_BlitGL (_THIS, SDL_Surface * src, - SDL_Rect * srcrect, SDL_Rect * dstrect) +glSDL_BlitGL(_THIS, SDL_Surface * src, SDL_Rect * srcrect, SDL_Rect * dstrect) { private_hwdata *txi; float x1, y1; @@ -1864,7 +1851,7 @@ SDL_Rect r; if (!src) - return GLERET ("BlitGL(): No src surface!"); + return GLERET("BlitGL(): No src surface!"); /* Get source and destination coordinates */ if (srcrect) @@ -1881,7 +1868,7 @@ x = y = 0; /* Clip! */ - if (!blitclip (&r, src->w, src->h, &x, &y, &this->screen->clip_rect)) { + if (!blitclip(&r, src->w, src->h, &x, &y, &this->screen->clip_rect)) { if (dstrect) dstrect->w = dstrect->h = 0; return 0; @@ -1892,19 +1879,19 @@ *dstrect = r; /* Make sure we have a source with a valid texture */ - txi = glSDL_UploadSurface (this, src); + txi = glSDL_UploadSurface(this, src); if (!txi) - return GLERET ("BlitGL(): Could not get a TexInfo!"); + return GLERET("BlitGL(): Could not get a TexInfo!"); /* Set up blending */ if (src->flags & (SDL_SRCALPHA | SDL_SRCCOLORKEY)) { - glSDL_blendfunc (this, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glSDL_do_blend (this, 1); + glSDL_blendfunc(this, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glSDL_do_blend(this, 1); } else - glSDL_do_blend (this, 0); + glSDL_do_blend(this, 0); /* Enable texturing */ - glSDL_do_texture (this, 1); + glSDL_do_texture(this, 1); /* Calculate texcoords */ if (!srcrect) @@ -1937,36 +1924,36 @@ /* Render! */ switch (txi->tilemode) { case GLSDL_TM_SINGLE: - glSDL_BlitGL_single (this, txi, x1, y1, &d, alpha); + glSDL_BlitGL_single(this, txi, x1, y1, &d, alpha); break; case GLSDL_TM_HORIZONTAL: - glSDL_BlitGL_htile (this, txi, x1, y1, &d, alpha); + glSDL_BlitGL_htile(this, txi, x1, y1, &d, alpha); break; case GLSDL_TM_VERTICAL: - glSDL_BlitGL_vtile (this, txi, x1, y1, &d, alpha); + glSDL_BlitGL_vtile(this, txi, x1, y1, &d, alpha); break; case GLSDL_TM_HUGE: - glSDL_BlitGL_hvtile (this, src, txi, x1, y1, &d, alpha); + glSDL_BlitGL_hvtile(this, src, txi, x1, y1, &d, alpha); break; } if (txi->temporary) - glSDL_FreeTexInfo (this, txi); + glSDL_FreeTexInfo(this, txi); return 0; } static int -glSDL_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +glSDL_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { SDL_Surface *vs; if (!src) - return GLERET ("HWAccelBlit(): No src surface!"); + return GLERET("HWAccelBlit(): No src surface!"); if (!dst) - return GLERET ("HWAccelBlit(): No dst surface!"); + return GLERET("HWAccelBlit(): No dst surface!"); /* * Figure out what to do: @@ -1981,17 +1968,17 @@ /* FIXME: Try glCopyPixels() instead... */ - glSDL_BlitFromGL (current_video, srcrect, vs, dstrect); - return glSDL_BlitGL (current_video, vs, srcrect, dstrect); + glSDL_BlitFromGL(current_video, srcrect, vs, dstrect); + return glSDL_BlitGL(current_video, vs, srcrect, dstrect); } else { - return glSDL_BlitFromGL (current_video, srcrect, dst, dstrect); + return glSDL_BlitFromGL(current_video, srcrect, dst, dstrect); } } else { if (dst == vs) { - return glSDL_BlitGL (current_video, src, srcrect, dstrect); + return glSDL_BlitGL(current_video, src, srcrect, dstrect); } else { - glSDL_Invalidate (dst, dstrect); - glSDL_SoftBlit (src, srcrect, dst, dstrect); + glSDL_Invalidate(dst, dstrect); + glSDL_SoftBlit(src, srcrect, dst, dstrect); return 0; } } @@ -1999,7 +1986,7 @@ static int -glSDL_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color) +glSDL_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color) { SDL_Surface *vs = SDL_VideoSurface; int dx1, dy1, dx2, dy2; @@ -2015,7 +2002,7 @@ if (dst->format->palette) { /* this a paletted color */ - SDL_GetRGB (color, dst->format, &br, &bg, &bb); + SDL_GetRGB(color, dst->format, &br, &bg, &bb); } else { /* this a RGB color */ r = color & dst->format->Rmask; @@ -2036,34 +2023,34 @@ if (vs != dst) { /* draw a rect offscreen */ - glSDL_Invalidate (dst, dstrect); + glSDL_Invalidate(dst, dstrect); /* software-fill the surface by faking it as a SW_SURFACE */ dst->flags &= ~SDL_HWSURFACE; - SDL_FillRect (dst, dstrect, color); + SDL_FillRect(dst, dstrect, color); dst->flags |= SDL_HWSURFACE; } else { /* draw a rect onscreen */ - glSDL_do_texture (this, 0); - glSDL_do_blend (this, 0); + glSDL_do_texture(this, 0); + glSDL_do_blend(this, 0); dx1 = dstrect->x; dy1 = dstrect->y; dx2 = dx1 + dstrect->w; dy2 = dy1 + dstrect->h; - this->glBegin (GL_TRIANGLE_FAN); - this->glColor3ub (br, bg, bb); - this->glVertex2i (dx1, dy1); - this->glVertex2i (dx2, dy1); - this->glVertex2i (dx2, dy2); - this->glVertex2i (dx1, dy2); - this->glEnd (); + this->glBegin(GL_TRIANGLE_FAN); + this->glColor3ub(br, bg, bb); + this->glVertex2i(dx1, dy1); + this->glVertex2i(dx2, dy1); + this->glVertex2i(dx2, dy2); + this->glVertex2i(dx1, dy2); + this->glEnd(); } return 0; } static int -glSDL_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst) +glSDL_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst) { src->flags |= SDL_HWACCEL; src->map->hw_blit = glSDL_HWAccelBlit; @@ -2072,23 +2059,23 @@ static SDL_Surface * -glSDL_DisplayFormat (SDL_Surface * surface) +glSDL_DisplayFormat(SDL_Surface * surface) { SDL_Surface *tmp; int use_rgba = (surface->flags & SDL_SRCCOLORKEY) || ((surface->flags & SDL_SRCALPHA) && surface->format->Amask); #ifdef DEBUG_GLSDL - fprintf (stderr, "#### glSDL_DisplayFormat()\n"); + fprintf(stderr, "#### glSDL_DisplayFormat()\n"); #endif if (use_rgba) - tmp = glSDL_ConvertSurface (surface, RGBAfmt, SDL_SWSURFACE); + tmp = glSDL_ConvertSurface(surface, RGBAfmt, SDL_SWSURFACE); else - tmp = glSDL_ConvertSurface (surface, RGBfmt, SDL_SWSURFACE); + tmp = glSDL_ConvertSurface(surface, RGBfmt, SDL_SWSURFACE); if (!tmp) { - GLERR ("glSDL_DisplayFormat() could not convert surface!"); + GLERR("glSDL_DisplayFormat() could not convert surface!"); return NULL; } - SDL_SetAlpha (tmp, 0, 0); + SDL_SetAlpha(tmp, 0, 0); if (surface->flags & SDL_SRCCOLORKEY) { /* @@ -2096,9 +2083,9 @@ * or we'll run into trouble when converting, * in particular from indexed color formats. */ - SDL_SetColorKey (tmp, SDL_SRCCOLORKEY, surface->format->colorkey); - glSDL_key2alpha (tmp); - SDL_SetColorKey (tmp, 0, 0); + SDL_SetColorKey(tmp, SDL_SRCCOLORKEY, surface->format->colorkey); + glSDL_key2alpha(tmp); + SDL_SetColorKey(tmp, 0, 0); } return tmp; @@ -2106,34 +2093,34 @@ static SDL_Surface * -glSDL_DisplayFormatAlpha (SDL_Surface * surface) +glSDL_DisplayFormatAlpha(SDL_Surface * surface) { SDL_Surface *s, *tmp; - tmp = glSDL_ConvertSurface (surface, RGBAfmt, SDL_SWSURFACE); + tmp = glSDL_ConvertSurface(surface, RGBAfmt, SDL_SWSURFACE); #ifdef DEBUG_GLSDL - fprintf (stderr, "#### glSDL_DisplayFormatAlpha()\n"); + fprintf(stderr, "#### glSDL_DisplayFormatAlpha()\n"); #endif if (!tmp) return NULL; - SDL_SetAlpha (tmp, 0, 0); - SDL_SetColorKey (tmp, 0, 0); - s = glSDL_CreateRGBASurface (surface->w, surface->h); + SDL_SetAlpha(tmp, 0, 0); + SDL_SetColorKey(tmp, 0, 0); + s = glSDL_CreateRGBASurface(surface->w, surface->h); if (!s) { - SDL_FreeSurface (tmp); + SDL_FreeSurface(tmp); return NULL; } - glSDL_SoftBlit (tmp, NULL, s, NULL); - SDL_FreeSurface (tmp); + glSDL_SoftBlit(tmp, NULL, s, NULL); + SDL_FreeSurface(tmp); if (surface->flags & SDL_SRCCOLORKEY) { - SDL_SetColorKey (s, SDL_SRCCOLORKEY, surface->format->colorkey); - glSDL_key2alpha (s); - SDL_SetColorKey (s, 0, 0); + SDL_SetColorKey(s, SDL_SRCCOLORKEY, surface->format->colorkey); + glSDL_key2alpha(s); + SDL_SetColorKey(s, 0, 0); } if (surface->flags & SDL_SRCALPHA) - SDL_SetAlpha (s, SDL_SRCALPHA, surface->format->alpha); + SDL_SetAlpha(s, SDL_SRCALPHA, surface->format->alpha); return s; } @@ -2143,12 +2130,12 @@ ----------------------------------------------------------*/ static void -glSDL_Invalidate (SDL_Surface * surface, SDL_Rect * area) +glSDL_Invalidate(SDL_Surface * surface, SDL_Rect * area) { private_hwdata *txi; if (!surface) return; - txi = glSDL_GetTexInfo (surface); + txi = glSDL_GetTexInfo(surface); if (!txi) return; if (!area) { @@ -2163,14 +2150,14 @@ static void -glSDL_SetLogicSize (_THIS, SDL_Surface * surface, int w, int h) +glSDL_SetLogicSize(_THIS, SDL_Surface * surface, int w, int h) { SDL_Rect r; private_hwdata *txi; - if (!IS_GLSDL_SURFACE (surface)) + if (!IS_GLSDL_SURFACE(surface)) return; - txi = glSDL_GetTexInfo (surface); + txi = glSDL_GetTexInfo(surface); txi->lw = w; txi->lh = h; @@ -2181,36 +2168,36 @@ r.x = r.y = 0; r.w = w; r.h = h; - glSDL_SetClipRect (this, surface, &r); + glSDL_SetClipRect(this, surface, &r); - this->glMatrixMode (GL_MODELVIEW); - this->glLoadIdentity (); - this->glTranslated (0.0f, 0.0f, 0.0f); + this->glMatrixMode(GL_MODELVIEW); + this->glLoadIdentity(); + this->glTranslated(0.0f, 0.0f, 0.0f); - this->glDisable (GL_DEPTH_TEST); - this->glDisable (GL_CULL_FACE); + this->glDisable(GL_DEPTH_TEST); + this->glDisable(GL_CULL_FACE); - glSDL_reset (); + glSDL_reset(); } static int -glSDL_InitTexture (_THIS, SDL_Surface * datasurf, private_hwdata * txi, - int tex) +glSDL_InitTexture(_THIS, SDL_Surface * datasurf, private_hwdata * txi, + int tex) { - this->glGenTextures (1, (GLuint *) & txi->texture[tex]); - this->glBindTexture (GL_TEXTURE_2D, txi->texture[tex]); + this->glGenTextures(1, (GLuint *) & txi->texture[tex]); + this->glBindTexture(GL_TEXTURE_2D, txi->texture[tex]); glstate.texture = txi->texture[tex]; - this->glPixelStorei (GL_UNPACK_ROW_LENGTH, datasurf->pitch / - datasurf->format->BytesPerPixel); - this->glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - this->glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - this->glTexImage2D (GL_TEXTURE_2D, 0, - datasurf->format->Amask ? GL_RGBA8 : GL_RGB8, - txi->texsize, txi->texsize, 0, - datasurf->format->Amask ? GL_RGBA : GL_RGB, - GL_UNSIGNED_BYTE, NULL); + this->glPixelStorei(GL_UNPACK_ROW_LENGTH, datasurf->pitch / + datasurf->format->BytesPerPixel); + this->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + this->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + this->glTexImage2D(GL_TEXTURE_2D, 0, + datasurf->format->Amask ? GL_RGBA8 : GL_RGB8, + txi->texsize, txi->texsize, 0, + datasurf->format->Amask ? GL_RGBA : GL_RGB, + GL_UNSIGNED_BYTE, NULL); #ifdef DEBUG_GLSDL - glSDL_print_glerror (this, 1); + glSDL_print_glerror(this, 1); #endif return 0; } @@ -2218,7 +2205,7 @@ /* Image tiled horizontally (wide surface), or not at all */ static int -glSDL_UploadHoriz (_THIS, SDL_Surface * datasurf, private_hwdata * txi) +glSDL_UploadHoriz(_THIS, SDL_Surface * datasurf, private_hwdata * txi) { int bpp = datasurf->format->BytesPerPixel; int res; @@ -2233,18 +2220,18 @@ break; if (toy + txi->tileh > txi->texsize) { toy = 0; - res = glSDL_InitTexture (this, datasurf, txi, tex); + res = glSDL_InitTexture(this, datasurf, txi, tex); if (res < 0) return res; ++tex; } - this->glTexSubImage2D (GL_TEXTURE_2D, 0, 0, toy, - thistw, txi->tileh, - datasurf->format->Amask ? GL_RGBA : GL_RGB, - GL_UNSIGNED_BYTE, - (char *) datasurf->pixels + bpp * fromx); + this->glTexSubImage2D(GL_TEXTURE_2D, 0, 0, toy, + thistw, txi->tileh, + datasurf->format->Amask ? GL_RGBA : GL_RGB, + GL_UNSIGNED_BYTE, + (char *) datasurf->pixels + bpp * fromx); #ifdef DEBUG_GLSDL - glSDL_print_glerror (this, 2); + glSDL_print_glerror(this, 2); #endif fromx += txi->tilew; toy += txi->tileh; @@ -2255,7 +2242,7 @@ /* Image tiled vertically (tall surface) */ static int -glSDL_UploadVert (_THIS, SDL_Surface * datasurf, private_hwdata * txi) +glSDL_UploadVert(_THIS, SDL_Surface * datasurf, private_hwdata * txi) { int res; int tex = 0; @@ -2269,19 +2256,19 @@ break; if (tox + txi->tilew > txi->texsize) { tox = 0; - res = glSDL_InitTexture (this, datasurf, txi, tex); + res = glSDL_InitTexture(this, datasurf, txi, tex); if (res < 0) return res; ++tex; } - this->glTexSubImage2D (GL_TEXTURE_2D, 0, tox, 0, - txi->tilew, thisth, - datasurf->format->Amask ? GL_RGBA : GL_RGB, - GL_UNSIGNED_BYTE, - (char *) datasurf->pixels + - datasurf->pitch * fromy); + this->glTexSubImage2D(GL_TEXTURE_2D, 0, tox, 0, + txi->tilew, thisth, + datasurf->format->Amask ? GL_RGBA : GL_RGB, + GL_UNSIGNED_BYTE, + (char *) datasurf->pixels + + datasurf->pitch * fromy); #ifdef DEBUG_GLSDL - glSDL_print_glerror (this, 3); + glSDL_print_glerror(this, 3); #endif fromy += txi->tileh; tox += txi->tilew; @@ -2292,7 +2279,7 @@ /* Image tiled two-way (huge surface) */ static int -glSDL_UploadHuge (_THIS, SDL_Surface * datasurf, private_hwdata * txi) +glSDL_UploadHuge(_THIS, SDL_Surface * datasurf, private_hwdata * txi) { int bpp = datasurf->format->BytesPerPixel; int res; @@ -2308,21 +2295,21 @@ int thistw = datasurf->w - x; if (thistw > txi->tilew) thistw = txi->tilew; - res = glSDL_InitTexture (this, datasurf, txi, tex++); + res = glSDL_InitTexture(this, datasurf, txi, tex++); if (res < 0) return res; - this->glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, - thistw, thisth, - datasurf->format-> - Amask ? GL_RGBA : GL_RGB, - GL_UNSIGNED_BYTE, - (char *) datasurf->pixels + - datasurf->pitch * y + bpp * x); + this->glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, + thistw, thisth, + datasurf->format-> + Amask ? GL_RGBA : GL_RGB, + GL_UNSIGNED_BYTE, + (char *) datasurf->pixels + + datasurf->pitch * y + bpp * x); #ifdef DEBUG_GLSDL - fprintf (stderr, - "glTexSubImage(x = %d, y = %d, w = %d, h = %d)\n", x, - y, thistw, thisth); - glSDL_print_glerror (this, 4); + fprintf(stderr, + "glTexSubImage(x = %d, y = %d, w = %d, h = %d)\n", x, + y, thistw, thisth); + glSDL_print_glerror(this, 4); #endif x += txi->tilew; } @@ -2334,18 +2321,18 @@ /* Upload all textures for a surface. */ static int -glSDL_UploadTextures (_THIS, SDL_Surface * datasurf, private_hwdata * txi) +glSDL_UploadTextures(_THIS, SDL_Surface * datasurf, private_hwdata * txi) { switch (txi->tilemode) { case GLSDL_TM_SINGLE: case GLSDL_TM_HORIZONTAL: - glSDL_UploadHoriz (this, datasurf, txi); + glSDL_UploadHoriz(this, datasurf, txi); break; case GLSDL_TM_VERTICAL: - glSDL_UploadVert (this, datasurf, txi); + glSDL_UploadVert(this, datasurf, txi); break; case GLSDL_TM_HUGE: - glSDL_UploadHuge (this, datasurf, txi); + glSDL_UploadHuge(this, datasurf, txi); break; } return 0; @@ -2364,20 +2351,20 @@ * the pixel data of 'texture'. */ static private_hwdata * -glSDL_UploadSurface (_THIS, SDL_Surface * surface) +glSDL_UploadSurface(_THIS, SDL_Surface * surface) { int i; int converted = 0; - private_hwdata *txi = glSDL_GetTexInfo (surface); + private_hwdata *txi = glSDL_GetTexInfo(surface); - if (IS_GLSDL_SURFACE (surface)) { + if (IS_GLSDL_SURFACE(surface)) { /* * Ok, this is a glSDL surface, and it *might* be * in texture memory already. If so, it may need * an update. */ if (txi->invalid_area.w) { - glSDL_UnloadTexture (this, txi); + glSDL_UnloadTexture(this, txi); } else { int missing = 0; if (txi->textures) { @@ -2397,9 +2384,9 @@ * TexInfo for it, valid for only one blit. */ if ((surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE) { - txi = glSDL_AddTexInfo (this, surface); + txi = glSDL_AddTexInfo(this, surface); if (!txi) { - GLERR ("UploadSurface(): Could not add TexInfo!"); + GLERR("UploadSurface(): Could not add TexInfo!"); return NULL; } surface->flags |= SDL_HWSURFACE; @@ -2411,9 +2398,9 @@ * candidate for a blit using glDrawPixels instead * of a texture blit */ - txi = glSDL_CreateTempTexInfo (this, surface); + txi = glSDL_CreateTempTexInfo(this, surface); if (!txi) { - GLERR ("UploadSurface(): Could not create temp TexInfo!"); + GLERR("UploadSurface(): Could not create temp TexInfo!"); return NULL; } } @@ -2422,8 +2409,8 @@ if (txi->texsize > maxtexsize) { /* This surface wasn't tiled properly... */ if (txi->temporary) - glSDL_FreeTexInfo (this, txi); - GLERR ("UploadSurface(): Too large texture!"); + glSDL_FreeTexInfo(this, txi); + GLERR("UploadSurface(): Too large texture!"); return NULL; } @@ -2438,42 +2425,41 @@ * should already be in the best known OpenGL format - * preferably one that makes DMA w/o conversion possible. */ - if (!glSDL_FormatIsOk (surface)) { + if (!glSDL_FormatIsOk(surface)) { #ifdef DEBUG_GLSDL - fprintf (stderr, - "glSDL: WARNING: On-the-fly conversion performed!\n"); + fprintf(stderr, "glSDL: WARNING: On-the-fly conversion performed!\n"); #endif converted = 1; /* NOTE: We forget about the original surface here. */ if (surface->format->Amask) - surface = glSDL_DisplayFormatAlpha (surface); + surface = glSDL_DisplayFormatAlpha(surface); else - surface = glSDL_DisplayFormat (surface); + surface = glSDL_DisplayFormat(surface); if (!surface) { - GLERR ("UploadSurface(): Could not convert surface!"); + GLERR("UploadSurface(): Could not convert surface!"); if (txi->temporary) - glSDL_FreeTexInfo (this, txi); + glSDL_FreeTexInfo(this, txi); return NULL; } } - glSDL_UploadTextures (this, surface, txi); + glSDL_UploadTextures(this, surface, txi); if (converted) - SDL_FreeSurface (surface); + SDL_FreeSurface(surface); return txi; } static void -glSDL_UnloadTexture (_THIS, private_hwdata * txi) +glSDL_UnloadTexture(_THIS, private_hwdata * txi) { int i; for (i = 0; i < txi->textures; ++i) if (txi->texture[i] != GLSDL_NOTEX) - this->glDeleteTextures (1, &txi->texture[i]); - SDL_memset (&txi->invalid_area, 0, sizeof (txi->invalid_area)); + this->glDeleteTextures(1, &txi->texture[i]); + SDL_memset(&txi->invalid_area, 0, sizeof(txi->invalid_area)); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ipod/SDL_ipodvideo.c --- a/src/video/ipod/SDL_ipodvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ipod/SDL_ipodvideo.c Mon May 29 04:04:35 2006 +0000 @@ -45,19 +45,19 @@ #define _THIS SDL_VideoDevice *this -static int iPod_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **iPod_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *iPod_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); -static int iPod_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void iPod_UpdateRects (_THIS, int nrects, SDL_Rect * rects); -static void iPod_VideoQuit (_THIS); -static void iPod_PumpEvents (_THIS); +static int iPod_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **iPod_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +static SDL_Surface *iPod_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, + Uint32 flags); +static int iPod_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void iPod_UpdateRects(_THIS, int nrects, SDL_Rect * rects); +static void iPod_VideoQuit(_THIS); +static void iPod_PumpEvents(_THIS); -static long iPod_GetGeneration (); +static long iPod_GetGeneration(); static int initd = 0; static int kbfd = -1; @@ -80,64 +80,64 @@ static unsigned long lcd_base, lcd_rtc, lcd_width, lcd_height; static long -iPod_GetGeneration () +iPod_GetGeneration() { int i; char cpuinfo[256]; char *ptr; FILE *file; - if ((file = fopen ("/proc/cpuinfo", "r")) != NULL) { - while (fgets (cpuinfo, sizeof (cpuinfo), file) != NULL) - if (SDL_strncmp (cpuinfo, "Revision", 8) == 0) + if ((file = fopen("/proc/cpuinfo", "r")) != NULL) { + while (fgets(cpuinfo, sizeof(cpuinfo), file) != NULL) + if (SDL_strncmp(cpuinfo, "Revision", 8) == 0) break; - fclose (file); + fclose(file); } - for (i = 0; !isspace (cpuinfo[i]); i++); - for (; isspace (cpuinfo[i]); i++); + for (i = 0; !isspace(cpuinfo[i]); i++); + for (; isspace(cpuinfo[i]); i++); ptr = cpuinfo + i + 2; - return SDL_strtol (ptr, NULL, 10); + return SDL_strtol(ptr, NULL, 10); } static int -iPod_Available () +iPod_Available() { return 1; } static void -iPod_DeleteDevice (SDL_VideoDevice * device) +iPod_DeleteDevice(SDL_VideoDevice * device) { - free (device->hidden); - free (device); + free(device->hidden); + free(device); } void -iPod_InitOSKeymap (_THIS) +iPod_InitOSKeymap(_THIS) { } static SDL_VideoDevice * -iPod_CreateDevice (int devindex) +iPod_CreateDevice(int devindex) { SDL_VideoDevice *this; - this = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + this = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (this) { - memset (this, 0, sizeof *this); + memset(this, 0, sizeof *this); this->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc (sizeof (struct SDL_PrivateVideoData)); + SDL_malloc(sizeof(struct SDL_PrivateVideoData)); } if (!this || !this->hidden) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) - SDL_free (this); + SDL_free(this); return 0; } - memset (this->hidden, 0, sizeof (struct SDL_PrivateVideoData)); + memset(this->hidden, 0, sizeof(struct SDL_PrivateVideoData)); - generation = iPod_GetGeneration (); + generation = iPod_GetGeneration(); this->VideoInit = iPod_VideoInit; this->ListModes = iPod_ListModes; @@ -174,7 +174,7 @@ //--// static int -iPod_VideoInit (_THIS, SDL_PixelFormat * vformat) +iPod_VideoInit(_THIS, SDL_PixelFormat * vformat) { if (!initd) { /*** Code adapted/copied from SDL fbcon driver. ***/ @@ -184,65 +184,65 @@ int i, tty0_fd; dbgout = - fdopen (open ("/etc/sdlpod.log", O_WRONLY | O_SYNC | O_APPEND), - "a"); + fdopen(open("/etc/sdlpod.log", O_WRONLY | O_SYNC | O_APPEND), + "a"); if (dbgout) { - setbuf (dbgout, 0); - fprintf (dbgout, "--> Started SDL <--\n"); + setbuf(dbgout, 0); + fprintf(dbgout, "--> Started SDL <--\n"); } // Try to query for a free VT tty0_fd = -1; for (i = 0; tty0[i] && (tty0_fd < 0); ++i) { - tty0_fd = open (tty0[i], O_WRONLY, 0); + tty0_fd = open(tty0[i], O_WRONLY, 0); } if (tty0_fd < 0) { - tty0_fd = dup (0); /* Maybe stdin is a VT? */ + tty0_fd = dup(0); /* Maybe stdin is a VT? */ } - ioctl (tty0_fd, VT_OPENQRY, &curvt); - close (tty0_fd); + ioctl(tty0_fd, VT_OPENQRY, &curvt); + close(tty0_fd); - tty0_fd = open ("/dev/tty", O_RDWR, 0); + tty0_fd = open("/dev/tty", O_RDWR, 0); if (tty0_fd >= 0) { - ioctl (tty0_fd, TIOCNOTTY, 0); - close (tty0_fd); + ioctl(tty0_fd, TIOCNOTTY, 0); + close(tty0_fd); } - if ((geteuid () == 0) && (curvt > 0)) { + if ((geteuid() == 0) && (curvt > 0)) { for (i = 0; vcs[i] && (kbfd < 0); ++i) { char vtpath[12]; - SDL_snprintf (vtpath, SDL_arraysize (vtpath), vcs[i], curvt); - kbfd = open (vtpath, O_RDWR); + SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i], curvt); + kbfd = open(vtpath, O_RDWR); } } if (kbfd < 0) { if (dbgout) - fprintf (dbgout, "Couldn't open any VC\n"); + fprintf(dbgout, "Couldn't open any VC\n"); return -1; } if (dbgout) - fprintf (stderr, "Current VT: %d\n", curvt); + fprintf(stderr, "Current VT: %d\n", curvt); if (kbfd >= 0) { /* Switch to the correct virtual terminal */ if (curvt > 0) { struct vt_stat vtstate; - if (ioctl (kbfd, VT_GETSTATE, &vtstate) == 0) { + if (ioctl(kbfd, VT_GETSTATE, &vtstate) == 0) { oldvt = vtstate.v_active; } - if (ioctl (kbfd, VT_ACTIVATE, curvt) == 0) { + if (ioctl(kbfd, VT_ACTIVATE, curvt) == 0) { if (dbgout) - fprintf (dbgout, "Waiting for switch to this VT... "); - ioctl (kbfd, VT_WAITACTIVE, curvt); + fprintf(dbgout, "Waiting for switch to this VT... "); + ioctl(kbfd, VT_WAITACTIVE, curvt); if (dbgout) - fprintf (dbgout, "done!\n"); + fprintf(dbgout, "done!\n"); } } // Set terminal input mode - if (tcgetattr (kbfd, &old_termios) < 0) { + if (tcgetattr(kbfd, &old_termios) < 0) { if (dbgout) - fprintf (dbgout, "Can't get termios\n"); + fprintf(dbgout, "Can't get termios\n"); return -1; } cur_termios = old_termios; @@ -257,32 +257,32 @@ cur_termios.c_cc[VMIN] = 0; cur_termios.c_cc[VTIME] = 0; - if (tcsetattr (kbfd, TCSAFLUSH, &cur_termios) < 0) { + if (tcsetattr(kbfd, TCSAFLUSH, &cur_termios) < 0) { if (dbgout) - fprintf (dbgout, "Can't set termios\n"); + fprintf(dbgout, "Can't set termios\n"); return -1; } - if (ioctl (kbfd, KDSKBMODE, K_MEDIUMRAW) < 0) { + if (ioctl(kbfd, KDSKBMODE, K_MEDIUMRAW) < 0) { if (dbgout) - fprintf (dbgout, "Can't set medium-raw mode\n"); + fprintf(dbgout, "Can't set medium-raw mode\n"); return -1; } - if (ioctl (kbfd, KDSETMODE, KD_GRAPHICS) < 0) { + if (ioctl(kbfd, KDSETMODE, KD_GRAPHICS) < 0) { if (dbgout) - fprintf (dbgout, "Can't set graphics\n"); + fprintf(dbgout, "Can't set graphics\n"); return -1; } } // Open the framebuffer - if ((fbfd = open ("/dev/fb0", O_RDWR)) < 0) { + if ((fbfd = open("/dev/fb0", O_RDWR)) < 0) { if (dbgout) - fprintf (dbgout, "Can't open framebuffer\n"); + fprintf(dbgout, "Can't open framebuffer\n"); return -1; } else { struct fb_var_screeninfo vinfo; if (dbgout) - fprintf (dbgout, "Generation: %ld\n", generation); + fprintf(dbgout, "Generation: %ld\n", generation); if (generation >= 40000) { lcd_base = IPOD_NEW_LCD_BASE; @@ -290,15 +290,15 @@ lcd_base = IPOD_OLD_LCD_BASE; } - ioctl (fbfd, FBIOGET_VSCREENINFO, &vinfo); - close (fbfd); + ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo); + close(fbfd); if (lcd_base == IPOD_OLD_LCD_BASE) lcd_rtc = IPOD_OLD_LCD_RTC; else if (lcd_base == IPOD_NEW_LCD_BASE) lcd_rtc = IPOD_NEW_LCD_RTC; else { - SDL_SetError ("Unknown iPod version"); + SDL_SetError("Unknown iPod version"); return -1; } @@ -306,10 +306,10 @@ lcd_height = vinfo.yres; if (dbgout) - fprintf (dbgout, "LCD is %dx%d\n", lcd_width, lcd_height); + fprintf(dbgout, "LCD is %dx%d\n", lcd_width, lcd_height); } - fcntl (kbfd, F_SETFL, O_RDWR | O_NONBLOCK); + fcntl(kbfd, F_SETFL, O_RDWR | O_NONBLOCK); /* Determine the current screen size */ this->info.current_w = lcd_width; @@ -327,25 +327,25 @@ initd = 1; if (dbgout) - fprintf (dbgout, "Initialized.\n\n"); + fprintf(dbgout, "Initialized.\n\n"); } return 0; } static SDL_Rect ** -iPod_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +iPod_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { int width, height, fd; static SDL_Rect r; static SDL_Rect *rs[2] = { &r, 0 }; - if ((fd = open ("/dev/fb0", O_RDWR)) < 0) { + if ((fd = open("/dev/fb0", O_RDWR)) < 0) { return 0; } else { struct fb_var_screeninfo vinfo; - ioctl (fbfd, FBIOGET_VSCREENINFO, &vinfo); - close (fbfd); + ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo); + close(fbfd); width = vinfo.xres; height = vinfo.yres; @@ -358,8 +358,8 @@ static SDL_Surface * -iPod_SetVideoMode (_THIS, SDL_Surface * current, int width, int height, - int bpp, Uint32 flags) +iPod_SetVideoMode(_THIS, SDL_Surface * current, int width, int height, + int bpp, Uint32 flags) { Uint32 Rmask, Gmask, Bmask; if (bpp > 8) { @@ -371,18 +371,18 @@ } if (this->hidden->buffer) - SDL_free (this->hidden->buffer); - this->hidden->buffer = SDL_malloc (width * height * (bpp / 8)); + SDL_free(this->hidden->buffer); + this->hidden->buffer = SDL_malloc(width * height * (bpp / 8)); if (!this->hidden->buffer) { - SDL_SetError ("Couldn't allocate buffer for requested mode"); + SDL_SetError("Couldn't allocate buffer for requested mode"); return 0; } - memset (this->hidden->buffer, 0, width * height * (bpp / 8)); + memset(this->hidden->buffer, 0, width * height * (bpp / 8)); - if (!SDL_ReallocFormat (current, bpp, Rmask, Gmask, Bmask, 0)) { - SDL_SetError ("Couldn't allocate new pixel format"); - SDL_free (this->hidden->buffer); + if (!SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0)) { + SDL_SetError("Couldn't allocate new pixel format"); + SDL_free(this->hidden->buffer); this->hidden->buffer = 0; return 0; } @@ -408,7 +408,7 @@ } static int -iPod_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +iPod_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { if (SDL_VideoSurface && SDL_VideoSurface->format && SDL_VideoSurface->format->palette) { @@ -425,21 +425,21 @@ } static void -iPod_VideoQuit (_THIS) +iPod_VideoQuit(_THIS) { - ioctl (kbfd, KDSETMODE, KD_TEXT); - tcsetattr (kbfd, TCSAFLUSH, &old_termios); + ioctl(kbfd, KDSETMODE, KD_TEXT); + tcsetattr(kbfd, TCSAFLUSH, &old_termios); old_kbmode = -1; if (oldvt > 0) - ioctl (kbfd, VT_ACTIVATE, oldvt); + ioctl(kbfd, VT_ACTIVATE, oldvt); if (kbfd > 0) - close (kbfd); + close(kbfd); if (dbgout) { - fprintf (dbgout, "<-- Ended SDL -->\n"); - fclose (dbgout); + fprintf(dbgout, "<-- Ended SDL -->\n"); + fclose(dbgout); } kbfd = -1; @@ -473,7 +473,7 @@ static void -iPod_keyboard () +iPod_keyboard() { unsigned char keybuf[128]; int i, nread; @@ -482,26 +482,26 @@ keysym.mod = 0; keysym.scancode = 0xff; - memset (&ev, 0, sizeof (SDL_Event)); + memset(&ev, 0, sizeof(SDL_Event)); - nread = read (kbfd, keybuf, 128); + nread = read(kbfd, keybuf, 128); for (i = 0; i < nread; i++) { char ascii = iPod_SC_keymap[keybuf[i] & 0x7f]; if (dbgout) - fprintf (dbgout, "Key! %02x is %c %s", keybuf[i], ascii, - (keybuf[i] & 0x80) ? "up" : "down"); + fprintf(dbgout, "Key! %02x is %c %s", keybuf[i], ascii, + (keybuf[i] & 0x80) ? "up" : "down"); keysym.sym = keysym.unicode = ascii; ev.type = (keybuf[i] & 0x80) ? SDL_KEYUP : SDL_KEYDOWN; ev.key.state = 0; ev.key.keysym = keysym; - SDL_PushEvent (&ev); + SDL_PushEvent(&ev); } } static void -iPod_PumpEvents (_THIS) +iPod_PumpEvents(_THIS) { fd_set fdset; int max_fd = 0; @@ -511,21 +511,21 @@ do { posted = 0; - FD_ZERO (&fdset); + FD_ZERO(&fdset); if (kbfd >= 0) { - FD_SET (kbfd, &fdset); + FD_SET(kbfd, &fdset); max_fd = kbfd; } if (dbgout) - fprintf (dbgout, "Selecting"); - if (select (max_fd + 1, &fdset, 0, 0, &zero) > 0) { + fprintf(dbgout, "Selecting"); + if (select(max_fd + 1, &fdset, 0, 0, &zero) > 0) { if (dbgout) - fprintf (dbgout, " -> match!\n"); - iPod_keyboard (); + fprintf(dbgout, " -> match!\n"); + iPod_keyboard(); posted++; } if (dbgout) - fprintf (dbgout, "\n"); + fprintf(dbgout, "\n"); } while (posted); } @@ -541,17 +541,17 @@ /* get current usec counter */ static int -M_timer_get_current (void) +M_timer_get_current(void) { - return inl (lcd_rtc); + return inl(lcd_rtc); } /* check if number of useconds has past */ static int -M_timer_check (int clock_start, int usecs) +M_timer_check(int clock_start, int usecs) { unsigned long clock; - clock = inl (lcd_rtc); + clock = inl(lcd_rtc); if ((clock - clock_start) >= usecs) { return 1; @@ -562,60 +562,60 @@ /* wait for LCD with timeout */ static void -M_lcd_wait_write (void) +M_lcd_wait_write(void) { - if ((inl (lcd_base) & 0x8000) != 0) { - int start = M_timer_get_current (); + if ((inl(lcd_base) & 0x8000) != 0) { + int start = M_timer_get_current(); do { - if ((inl (lcd_base) & (unsigned int) 0x8000) == 0) + if ((inl(lcd_base) & (unsigned int) 0x8000) == 0) break; } - while (M_timer_check (start, 1000) == 0); + while (M_timer_check(start, 1000) == 0); } } /* send LCD data */ static void -M_lcd_send_data (int data_lo, int data_hi) +M_lcd_send_data(int data_lo, int data_hi) { - M_lcd_wait_write (); + M_lcd_wait_write(); - outl (data_lo, lcd_base + LCD_DATA); + outl(data_lo, lcd_base + LCD_DATA); - M_lcd_wait_write (); + M_lcd_wait_write(); - outl (data_hi, lcd_base + LCD_DATA); + outl(data_hi, lcd_base + LCD_DATA); } /* send LCD command */ static void -M_lcd_prepare_cmd (int cmd) +M_lcd_prepare_cmd(int cmd) { - M_lcd_wait_write (); + M_lcd_wait_write(); - outl (0x0, lcd_base + LCD_CMD); + outl(0x0, lcd_base + LCD_CMD); - M_lcd_wait_write (); + M_lcd_wait_write(); - outl (cmd, lcd_base + LCD_CMD); + outl(cmd, lcd_base + LCD_CMD); } /* send LCD command and data */ static void -M_lcd_cmd_and_data (int cmd, int data_lo, int data_hi) +M_lcd_cmd_and_data(int cmd, int data_lo, int data_hi) { - M_lcd_prepare_cmd (cmd); + M_lcd_prepare_cmd(cmd); - M_lcd_send_data (data_lo, data_hi); + M_lcd_send_data(data_lo, data_hi); } // Copied from uW static void -M_update_display (int sx, int sy, int mx, int my) +M_update_display(int sx, int sy, int mx, int my) { int y; unsigned short cursor_pos; @@ -630,17 +630,17 @@ int x; /* move the cursor */ - M_lcd_cmd_and_data (0x11, cursor_pos >> 8, cursor_pos & 0xff); + M_lcd_cmd_and_data(0x11, cursor_pos >> 8, cursor_pos & 0xff); /* setup for printing */ - M_lcd_prepare_cmd (0x12); + M_lcd_prepare_cmd(0x12); img_data = ipod_scr + (sx << 1) + (y * (lcd_width / 4)); /* loops up to 160 times */ for (x = sx; x <= mx; x++) { /* display eight pixels */ - M_lcd_send_data (*(img_data + 1), *img_data); + M_lcd_send_data(*(img_data + 1), *img_data); img_data += 2; } @@ -652,17 +652,17 @@ /* get current usec counter */ static int -C_timer_get_current (void) +C_timer_get_current(void) { - return inl (0x60005010); + return inl(0x60005010); } /* check if number of useconds has past */ static int -C_timer_check (int clock_start, int usecs) +C_timer_check(int clock_start, int usecs) { unsigned long clock; - clock = inl (0x60005010); + clock = inl(0x60005010); if ((clock - clock_start) >= usecs) { return 1; @@ -673,30 +673,30 @@ /* wait for LCD with timeout */ static void -C_lcd_wait_write (void) +C_lcd_wait_write(void) { - if ((inl (0x70008A0C) & 0x80000000) != 0) { - int start = C_timer_get_current (); + if ((inl(0x70008A0C) & 0x80000000) != 0) { + int start = C_timer_get_current(); do { - if ((inl (0x70008A0C) & 0x80000000) == 0) + if ((inl(0x70008A0C) & 0x80000000) == 0) break; } - while (C_timer_check (start, 1000) == 0); + while (C_timer_check(start, 1000) == 0); } } static void -C_lcd_cmd_data (int cmd, int data) +C_lcd_cmd_data(int cmd, int data) { - C_lcd_wait_write (); - outl (cmd | 0x80000000, 0x70008A0C); + C_lcd_wait_write(); + outl(cmd | 0x80000000, 0x70008A0C); - C_lcd_wait_write (); - outl (data | 0x80000000, 0x70008A0C); + C_lcd_wait_write(); + outl(data | 0x80000000, 0x70008A0C); } static void -C_update_display (int sx, int sy, int mx, int my) +C_update_display(int sx, int sy, int mx, int my) { int height = (my - sy) + 1; int width = (mx - sx) + 1; @@ -707,14 +707,13 @@ width++; /* start X and Y */ - C_lcd_cmd_data (0x12, (sy & 0xff)); - C_lcd_cmd_data (0x13, (((SDL_VideoSurface->w - 1) - sx) & 0xff)); + C_lcd_cmd_data(0x12, (sy & 0xff)); + C_lcd_cmd_data(0x13, (((SDL_VideoSurface->w - 1) - sx) & 0xff)); /* max X and Y */ - C_lcd_cmd_data (0x15, (((sy + height) - 1) & 0xff)); - C_lcd_cmd_data (0x16, - (((((SDL_VideoSurface->w - 1) - sx) - width) + - 1) & 0xff)); + C_lcd_cmd_data(0x15, (((sy + height) - 1) & 0xff)); + C_lcd_cmd_data(0x16, + (((((SDL_VideoSurface->w - 1) - sx) - width) + 1) & 0xff)); addr += sx + sy * SDL_VideoSurface->pitch; @@ -730,9 +729,9 @@ pixels_to_write = (width * h) * 2; } - outl (0x10000080, 0x70008A20); - outl ((pixels_to_write - 1) | 0xC0010000, 0x70008A24); - outl (0x34000000, 0x70008A20); + outl(0x10000080, 0x70008A20); + outl((pixels_to_write - 1) | 0xC0010000, 0x70008A24); + outl(0x34000000, 0x70008A20); /* for each row */ for (x = 0; x < h; x++) { @@ -743,18 +742,18 @@ two_pixels = addr[0] | (addr[1] << 16); addr += 2; - while ((inl (0x70008A20) & 0x1000000) == 0); + while ((inl(0x70008A20) & 0x1000000) == 0); /* output 2 pixels */ - outl (two_pixels, 0x70008B00); + outl(two_pixels, 0x70008B00); } addr += SDL_VideoSurface->w - width; } - while ((inl (0x70008A20) & 0x4000000) == 0); + while ((inl(0x70008A20) & 0x4000000) == 0); - outl (0x0, 0x70008A24); + outl(0x0, 0x70008A24); height = height - h; } @@ -762,10 +761,10 @@ // Should work with photo. However, I don't have one, so I'm not sure. static void -iPod_UpdateRects (_THIS, int nrects, SDL_Rect * rects) +iPod_UpdateRects(_THIS, int nrects, SDL_Rect * rects) { if (SDL_VideoSurface->format->BitsPerPixel == 16) { - C_update_display (0, 0, lcd_width, lcd_height); + C_update_display(0, 0, lcd_width, lcd_height); } else { int i, y, x; for (i = 0; i < nrects; i++) { @@ -789,7 +788,7 @@ } } - M_update_display (0, 0, lcd_width, lcd_height); + M_update_display(0, 0, lcd_width, lcd_height); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/maccommon/SDL_macevents.c --- a/src/video/maccommon/SDL_macevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/maccommon/SDL_macevents.c Mon May 29 04:04:35 2006 +0000 @@ -54,59 +54,59 @@ #define iAbout 1 /* About menu item */ /* Functions to handle the About menu */ -static void Mac_DoAppleMenu (_THIS, long item); +static void Mac_DoAppleMenu(_THIS, long item); /* The translation table from a macintosh key scancode to a SDL keysym */ static SDLKey MAC_keymap[256]; -static SDL_keysym *TranslateKey (int scancode, int modifiers, - SDL_keysym * keysym, int pressed); +static SDL_keysym *TranslateKey(int scancode, int modifiers, + SDL_keysym * keysym, int pressed); /* Handle activation and deactivation -- returns whether an event was posted */ static int -Mac_HandleActivate (int activate) +Mac_HandleActivate(int activate) { if (activate) { /* Show the current SDL application cursor */ - SDL_SetCursor (NULL); + SDL_SetCursor(NULL); /* put our mask back case it changed during context switch */ - SetEventMask (everyEvent & ~autoKeyMask); + SetEventMask(everyEvent & ~autoKeyMask); } else { #if TARGET_API_MAC_CARBON { Cursor cursor; - SetCursor (GetQDGlobalsArrow (&cursor)); + SetCursor(GetQDGlobalsArrow(&cursor)); } #else - SetCursor (&theQD->arrow); + SetCursor(&theQD->arrow); #endif if (!Mac_cursor_showing) { - ShowCursor (); + ShowCursor(); Mac_cursor_showing = 1; } } - return (SDL_PrivateAppActive (activate, SDL_APPINPUTFOCUS)); + return (SDL_PrivateAppActive(activate, SDL_APPINPUTFOCUS)); } static void -myGlobalToLocal (_THIS, Point * pt) +myGlobalToLocal(_THIS, Point * pt) { if (SDL_VideoSurface && !(SDL_VideoSurface->flags & SDL_FULLSCREEN)) { GrafPtr saveport; - GetPort (&saveport); + GetPort(&saveport); #if TARGET_API_MAC_CARBON - SetPort (GetWindowPort (SDL_Window)); + SetPort(GetWindowPort(SDL_Window)); #else - SetPort (SDL_Window); + SetPort(SDL_Window); #endif - GlobalToLocal (pt); - SetPort (saveport); + GlobalToLocal(pt); + SetPort(saveport); } } /* The main MacOS event handler */ static int -Mac_HandleEvents (_THIS, int wait4it) +Mac_HandleEvents(_THIS, int wait4it) { static int mouse_button = 1; int i; @@ -139,28 +139,28 @@ } else { wait_time = 0; } - WaitNextEvent (everyEvent, &event, wait_time, nil); + WaitNextEvent(everyEvent, &event, wait_time, nil); } else { #if ! TARGET_API_MAC_CARBON - GetOSEvent (everyEvent, &event); + GetOSEvent(everyEvent, &event); #endif } #if TARGET_API_MAC_CARBON /* for some reason, event.where isn't set ? */ - GetGlobalMouse (&event.where); + GetGlobalMouse(&event.where); #endif /* Check for mouse motion */ if ((event.where.h != last_where.h) || (event.where.v != last_where.v)) { Point pt; pt = last_where = event.where; - myGlobalToLocal (this, &pt); - SDL_PrivateMouseMotion (0, 0, pt.h, pt.v); + myGlobalToLocal(this, &pt); + SDL_PrivateMouseMotion(0, 0, pt.h, pt.v); } /* Check the current state of the keyboard */ - if (SDL_GetAppState () & SDL_APPINPUTFOCUS) { + if (SDL_GetAppState() & SDL_APPINPUTFOCUS) { KeyMap keys; /* Check for special non-event keys */ @@ -207,7 +207,7 @@ } else { mode = SDL_RELEASED; } - SDL_PrivateKeyboard (mode, &keysym); + SDL_PrivateKeyboard(mode, &keysym); } } @@ -219,15 +219,15 @@ actual keyboard state because on Mac OS X a keydown event is immediately followed by a keyup event. */ - GetKeys (keys); + GetKeys(keys); if ((keys[0] != last_keys[0]) || (keys[1] != last_keys[1]) || (keys[2] != last_keys[2]) || (keys[3] != last_keys[3])) { SDL_keysym keysym; int old_bit, new_bit; #ifdef DEBUG_KEYBOARD - fprintf (sterr, "New keys: 0x%x 0x%x 0x%x 0x%x\n", - new_keys[0], new_keys[1], new_keys[2], new_keys[3]); + fprintf(sterr, "New keys: 0x%x 0x%x 0x%x 0x%x\n", + new_keys[0], new_keys[1], new_keys[2], new_keys[3]); #endif for (i = 0; i < 128; ++i) { old_bit = (((Uint8 *) last_keys)[i / 8] >> (i % 8)) & 0x01; @@ -235,13 +235,13 @@ if (old_bit != new_bit) { /* Post the keyboard event */ #ifdef DEBUG_KEYBOARD - fprintf (stderr, "Scancode: 0x%2.2X\n", i); + fprintf(stderr, "Scancode: 0x%2.2X\n", i); #endif - SDL_PrivateKeyboard (new_bit, - TranslateKey (i, - event. - modifiers, - &keysym, new_bit)); + SDL_PrivateKeyboard(new_bit, + TranslateKey(i, + event. + modifiers, + &keysym, new_bit)); } } @@ -260,32 +260,32 @@ WindowRef win; short area; - area = FindWindow (event.where, &win); + area = FindWindow(event.where, &win); /* Support switching between the SIOUX console and SDL_Window by clicking in the window. */ - if (win && (win != FrontWindow ())) { - SelectWindow (win); + if (win && (win != FrontWindow())) { + SelectWindow(win); } switch (area) { case inMenuBar: /* Only the apple menu exists */ - Mac_DoAppleMenu (this, MenuSelect (event.where)); - HiliteMenu (0); + Mac_DoAppleMenu(this, MenuSelect(event.where)); + HiliteMenu(0); break; case inDrag: #if TARGET_API_MAC_CARBON - DragWindow (win, event.where, NULL); + DragWindow(win, event.where, NULL); #else - DragWindow (win, event.where, &theQD->screenBits.bounds); + DragWindow(win, event.where, &theQD->screenBits.bounds); #endif break; case inGoAway: - if (TrackGoAway (win, event.where)) { - SDL_PrivateQuit (); + if (TrackGoAway(win, event.where)) { + SDL_PrivateQuit(); } break; case inContent: - myGlobalToLocal (this, &event.where); + myGlobalToLocal(this, &event.where); /* Treat command-click as right mouse button */ if (event.modifiers & optionKey) { mouse_button = 2; @@ -294,9 +294,9 @@ } else { mouse_button = 1; } - SDL_PrivateMouseButton (SDL_PRESSED, - mouse_button, event.where.h, - event.where.v); + SDL_PrivateMouseButton(SDL_PRESSED, + mouse_button, event.where.h, + event.where.v); break; case inGrow: { @@ -308,45 +308,43 @@ break; } #if TARGET_API_MAC_CARBON - newSize = GrowWindow (win, event.where, NULL); + newSize = GrowWindow(win, event.where, NULL); #else newSize = - GrowWindow (win, event.where, - &theQD->screenBits.bounds); + GrowWindow(win, event.where, + &theQD->screenBits.bounds); #endif if (newSize) { #if !TARGET_API_MAC_CARBON - EraseRect (&theQD->screenBits.bounds); + EraseRect(&theQD->screenBits.bounds); #endif - SizeWindow (win, LoWord (newSize), - HiWord (newSize), 1); - SDL_PrivateResize (LoWord (newSize), - HiWord (newSize)); + SizeWindow(win, LoWord(newSize), HiWord(newSize), 1); + SDL_PrivateResize(LoWord(newSize), HiWord(newSize)); } } break; case inZoomIn: case inZoomOut: - if (TrackBox (win, event.where, area)) { + if (TrackBox(win, event.where, area)) { Rect rect; #if !TARGET_API_MAC_CARBON - EraseRect (&theQD->screenBits.bounds); + EraseRect(&theQD->screenBits.bounds); #endif - ZoomWindow (win, area, 0); + ZoomWindow(win, area, 0); if (area == inZoomIn) { - GetWindowUserState (SDL_Window, &rect); + GetWindowUserState(SDL_Window, &rect); } else { - GetWindowStandardState (SDL_Window, &rect); + GetWindowStandardState(SDL_Window, &rect); } - SDL_PrivateResize (rect.right - rect.left, - rect.bottom - rect.top); + SDL_PrivateResize(rect.right - rect.left, + rect.bottom - rect.top); } break; #if TARGET_API_MAC_CARBON case inCollapseBox: - if (TrackBox (win, event.where, area)) { - if (IsWindowCollapsable (win)) { - CollapseWindow (win, !IsWindowCollapsed (win)); + if (TrackBox(win, event.where, area)) { + if (IsWindowCollapsable(win)) { + CollapseWindow(win, !IsWindowCollapsed(win)); /* There should be something done like in inGrow case, but... */ } } @@ -356,7 +354,7 @@ #if TARGET_API_MAC_CARBON /* Never happens in Carbon? */ #else - SystemClick (&event, win); + SystemClick(&event, win); #endif break; default: @@ -366,16 +364,16 @@ break; case mouseUp: { - myGlobalToLocal (this, &event.where); + myGlobalToLocal(this, &event.where); /* Release the mouse button we simulated in the last press. The drawback of this methos is we cannot press more than one button. However, this doesn't matter, since there is only a single logical mouse button, even if you have a multi-button mouse, this doesn't matter at all. */ - SDL_PrivateMouseButton (SDL_RELEASED, - mouse_button, event.where.h, - event.where.v); + SDL_PrivateMouseButton(SDL_RELEASED, + mouse_button, event.where.h, + event.where.v); } break; #if 0 /* Handled above the switch statement */ @@ -383,35 +381,35 @@ { SDL_keysym keysym; - SDL_PrivateKeyboard (SDL_PRESSED, - TranslateKey ((event. - message & keyCodeMask) >> 8 - event.modifiers, &keysym, 1)); + SDL_PrivateKeyboard(SDL_PRESSED, + TranslateKey((event. + message & keyCodeMask) >> 8 + event.modifiers, &keysym, 1)); } break; case keyUp: { SDL_keysym keysym; - SDL_PrivateKeyboard (SDL_RELEASED, - TranslateKey ((event. - message & keyCodeMask) >> 8 - event.modifiers, &keysym, 0)); + SDL_PrivateKeyboard(SDL_RELEASED, + TranslateKey((event. + message & keyCodeMask) >> 8 + event.modifiers, &keysym, 0)); } break; #endif case updateEvt: { - BeginUpdate (SDL_Window); + BeginUpdate(SDL_Window); #if SDL_VIDEO_OPENGL if (SDL_VideoSurface->flags & SDL_INTERNALOPENGL) - SDL_GL_SwapBuffers (); + SDL_GL_SwapBuffers(); else #endif if ((SDL_VideoSurface->flags & SDL_HWSURFACE) == SDL_SWSURFACE) { - SDL_UpdateRect (SDL_VideoSurface, 0, 0, 0, 0); + SDL_UpdateRect(SDL_VideoSurface, 0, 0, 0, 0); } - EndUpdate (SDL_Window); + EndUpdate(SDL_Window); } /* If this was an update event for the SIOUX console, we return 0 in order to stop an endless series of updates being triggered. @@ -422,7 +420,7 @@ break; case activateEvt: { - Mac_HandleActivate (!!(event.modifiers & activeFlag)); + Mac_HandleActivate(!!(event.modifiers & activeFlag)); } break; case diskEvt: @@ -432,8 +430,8 @@ #else if (((event.message >> 16) & 0xFFFF) != noErr) { Point spot; - SetPt (&spot, 0x0070, 0x0050); - DIBadMount (spot, event.message); + SetPt(&spot, 0x0070, 0x0050); + DIBadMount(spot, event.message); } #endif } @@ -444,15 +442,15 @@ #if 0 /* Handled above the switch statement */ case mouseMovedMessage: { - myGlobalToLocal (this, &event.where); - SDL_PrivateMouseMotion (0, 0, - event.where.h, event.where.v); + myGlobalToLocal(this, &event.where); + SDL_PrivateMouseMotion(0, 0, + event.where.h, event.where.v); } break; #endif /* 0 */ case suspendResumeMessage: { - Mac_HandleActivate (!!(event.message & resumeFlag)); + Mac_HandleActivate(!!(event.message & resumeFlag)); } break; } @@ -469,16 +467,16 @@ void -Mac_PumpEvents (_THIS) +Mac_PumpEvents(_THIS) { /* Process pending MacOS events */ - while (Mac_HandleEvents (this, 0)) { + while (Mac_HandleEvents(this, 0)) { /* Loop and check again */ ; } } void -Mac_InitOSKeymap (_THIS) +Mac_InitOSKeymap(_THIS) { const void *KCHRPtr; UInt32 state; @@ -487,7 +485,7 @@ int world = SDLK_WORLD_0; /* Map the MAC keysyms */ - for (i = 0; i < SDL_arraysize (MAC_keymap); ++i) + for (i = 0; i < SDL_arraysize(MAC_keymap); ++i) MAC_keymap[i] = SDLK_UNKNOWN; /* Defined MAC_* constants */ @@ -620,7 +618,7 @@ */ /* Get a pointer to the systems cached KCHR */ - KCHRPtr = (void *) GetScriptManagerVariable (smKCHRCache); + KCHRPtr = (void *) GetScriptManagerVariable(smKCHRCache); if (KCHRPtr) { /* Loop over all 127 possible scan codes */ for (i = 0; i < 0x7F; i++) { @@ -628,12 +626,12 @@ state = 0; /* Now translate the key code to a key value */ - value = KeyTranslate (KCHRPtr, i, &state) & 0xff; + value = KeyTranslate(KCHRPtr, i, &state) & 0xff; /* If the state become 0, it was a dead key. We need to translate again, passing in the new state, to get the actual key value */ if (state != 0) - value = KeyTranslate (KCHRPtr, i, &state) & 0xff; + value = KeyTranslate(KCHRPtr, i, &state) & 0xff; /* Now we should have an ascii value, or 0. Try to figure out to which SDL symbol it maps */ if (value >= 128) /* Some non-ASCII char, map it to SDLK_WORLD_* */ @@ -670,7 +668,7 @@ } static SDL_keysym * -TranslateKey (int scancode, int modifiers, SDL_keysym * keysym, int pressed) +TranslateKey(int scancode, int modifiers, SDL_keysym * keysym, int pressed) { /* Set the keysym information */ keysym->scancode = scancode; @@ -683,50 +681,50 @@ Ptr new_keymap; /* Get the current keyboard map resource */ - new_keymap = (Ptr) GetScriptManagerVariable (smKCHRCache); + new_keymap = (Ptr) GetScriptManagerVariable(smKCHRCache); if (new_keymap != keymap) { keymap = new_keymap; state = 0; } - keysym->unicode = KeyTranslate (keymap, - keysym->scancode | modifiers, - &state) & 0xFFFF; + keysym->unicode = KeyTranslate(keymap, + keysym->scancode | modifiers, + &state) & 0xFFFF; } return (keysym); } void -Mac_InitEvents (_THIS) +Mac_InitEvents(_THIS) { /* Create apple menu bar */ - apple_menu = GetMenu (mApple); + apple_menu = GetMenu(mApple); if (apple_menu != nil) { - AppendResMenu (apple_menu, 'DRVR'); - InsertMenu (apple_menu, 0); + AppendResMenu(apple_menu, 'DRVR'); + InsertMenu(apple_menu, 0); } - DrawMenuBar (); + DrawMenuBar(); /* Get rid of spurious events at startup */ - FlushEvents (everyEvent, 0); + FlushEvents(everyEvent, 0); /* Allow every event but keyrepeat */ - SetEventMask (everyEvent & ~autoKeyMask); + SetEventMask(everyEvent & ~autoKeyMask); } void -Mac_QuitEvents (_THIS) +Mac_QuitEvents(_THIS) { - ClearMenuBar (); + ClearMenuBar(); if (apple_menu != nil) { - ReleaseResource ((char **) apple_menu); + ReleaseResource((char **) apple_menu); } /* Clean up pending events */ - FlushEvents (everyEvent, 0); + FlushEvents(everyEvent, 0); } static void -Mac_DoAppleMenu (_THIS, long choice) +Mac_DoAppleMenu(_THIS, long choice) { #if !TARGET_API_MAC_CARBON /* No Apple menu in OS X */ short menu, item; @@ -748,8 +746,8 @@ { Str255 name; - GetMenuItemText (apple_menu, item, name); - OpenDeskAcc (name); + GetMenuItemText(apple_menu, item, name); + OpenDeskAcc(name); } break; } @@ -770,7 +768,7 @@ /* Exported to the macmain code */ void -SDL_InitQuickDraw (struct QDGlobals *the_qd) +SDL_InitQuickDraw(struct QDGlobals *the_qd) { #if !TARGET_API_MAC_CARBON theQD = the_qd; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/maccommon/SDL_macevents_c.h --- a/src/video/maccommon/SDL_macevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/maccommon/SDL_macevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -25,9 +25,9 @@ /* Functions exported by SDL_macevents.c for the video subsystem */ -extern void Mac_InitEvents (_THIS); -extern void Mac_QuitEvents (_THIS); +extern void Mac_InitEvents(_THIS); +extern void Mac_QuitEvents(_THIS); -extern void Mac_InitOSKeymap (_THIS); -extern void Mac_PumpEvents (_THIS); +extern void Mac_InitOSKeymap(_THIS); +extern void Mac_PumpEvents(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/maccommon/SDL_macgl.c --- a/src/video/maccommon/SDL_macgl.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/maccommon/SDL_macgl.c Mon May 29 04:04:35 2006 +0000 @@ -30,7 +30,7 @@ /* krat: adding OpenGL support */ int -Mac_GL_Init (_THIS) +Mac_GL_Init(_THIS) { #if SDL_VIDEO_OPENGL AGLPixelFormat format; @@ -41,7 +41,7 @@ /* load the gl driver from a default path */ if (!this->gl_config.driver_loaded) { /* no driver has been loaded, use default (ourselves) */ - if (Mac_GL_LoadLibrary (this, NULL) < 0) { + if (Mac_GL_LoadLibrary(this, NULL) < 0) { return (-1); } } @@ -103,44 +103,44 @@ attributes[i++] = AGL_ALL_RENDERERS; attributes[i] = AGL_NONE; - format = aglChoosePixelFormat (NULL, 0, attributes); + format = aglChoosePixelFormat(NULL, 0, attributes); if (format == NULL) { - SDL_SetError ("Couldn't match OpenGL desired format"); + SDL_SetError("Couldn't match OpenGL desired format"); return (-1); } - glContext = aglCreateContext (format, NULL); + glContext = aglCreateContext(format, NULL); if (glContext == NULL) { - SDL_SetError ("Couldn't create OpenGL context"); + SDL_SetError("Couldn't create OpenGL context"); return (-1); } - aglDestroyPixelFormat (format); + aglDestroyPixelFormat(format); #if TARGET_API_MAC_CARBON - noerr = aglSetDrawable (glContext, GetWindowPort (SDL_Window)); + noerr = aglSetDrawable(glContext, GetWindowPort(SDL_Window)); #else - noerr = aglSetDrawable (glContext, (AGLDrawable) SDL_Window); + noerr = aglSetDrawable(glContext, (AGLDrawable) SDL_Window); #endif if (!noerr) { - SDL_SetError ("Unable to bind GL context to window"); + SDL_SetError("Unable to bind GL context to window"); return (-1); } return (0); #else - SDL_SetError ("OpenGL support not configured"); + SDL_SetError("OpenGL support not configured"); return (-1); #endif } void -Mac_GL_Quit (_THIS) +Mac_GL_Quit(_THIS) { #if SDL_VIDEO_OPENGL if (glContext != NULL) { - aglSetCurrentContext (NULL); - aglSetDrawable (glContext, NULL); - aglDestroyContext (glContext); + aglSetCurrentContext(NULL); + aglSetDrawable(glContext, NULL); + aglDestroyContext(glContext); glContext = NULL; } #endif @@ -150,26 +150,26 @@ /* Make the current context active */ int -Mac_GL_MakeCurrent (_THIS) +Mac_GL_MakeCurrent(_THIS) { int retval; retval = 0; - if (!aglSetCurrentContext (glContext)) { - SDL_SetError ("Unable to make GL context current"); + if (!aglSetCurrentContext(glContext)) { + SDL_SetError("Unable to make GL context current"); retval = -1; } return (retval); } void -Mac_GL_SwapBuffers (_THIS) +Mac_GL_SwapBuffers(_THIS) { - aglSwapBuffers (glContext); + aglSwapBuffers(glContext); } int -Mac_GL_LoadLibrary (_THIS, const char *location) +Mac_GL_LoadLibrary(_THIS, const char *location) { if (location == NULL) #if __MACH__ @@ -178,25 +178,25 @@ location = "OpenGLLibrary"; #endif - this->hidden->libraryHandle = SDL_LoadObject (location); + this->hidden->libraryHandle = SDL_LoadObject(location); this->gl_config.driver_loaded = 1; return (this->hidden->libraryHandle != NULL) ? 0 : -1; } void -Mac_GL_UnloadLibrary (_THIS) +Mac_GL_UnloadLibrary(_THIS) { - SDL_UnloadObject (this->hidden->libraryHandle); + SDL_UnloadObject(this->hidden->libraryHandle); this->hidden->libraryHandle = NULL; this->gl_config.driver_loaded = 0; } void * -Mac_GL_GetProcAddress (_THIS, const char *proc) +Mac_GL_GetProcAddress(_THIS, const char *proc) { - return SDL_LoadFunction (this->hidden->libraryHandle, proc); + return SDL_LoadFunction(this->hidden->libraryHandle, proc); } #endif /* SDL_VIDEO_OPENGL */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/maccommon/SDL_macgl_c.h --- a/src/video/maccommon/SDL_macgl_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/maccommon/SDL_macgl_c.h Mon May 29 04:04:35 2006 +0000 @@ -34,14 +34,14 @@ #endif /* SDL_VIDEO_OPENGL */ /* OpenGL functions */ -extern int Mac_GL_Init (_THIS); -extern void Mac_GL_Quit (_THIS); +extern int Mac_GL_Init(_THIS); +extern void Mac_GL_Quit(_THIS); #if SDL_VIDEO_OPENGL -extern int Mac_GL_MakeCurrent (_THIS); -extern int Mac_GL_GetAttribute (_THIS, SDL_GLattr attrib, int *value); -extern void Mac_GL_SwapBuffers (_THIS); -extern int Mac_GL_LoadLibrary (_THIS, const char *location); -extern void Mac_GL_UnloadLibrary (_THIS); -extern void *Mac_GL_GetProcAddress (_THIS, const char *proc); +extern int Mac_GL_MakeCurrent(_THIS); +extern int Mac_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value); +extern void Mac_GL_SwapBuffers(_THIS); +extern int Mac_GL_LoadLibrary(_THIS, const char *location); +extern void Mac_GL_UnloadLibrary(_THIS); +extern void *Mac_GL_GetProcAddress(_THIS, const char *proc); #endif /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/maccommon/SDL_macmouse.c --- a/src/video/maccommon/SDL_macmouse.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/maccommon/SDL_macmouse.c Mon May 29 04:04:35 2006 +0000 @@ -46,26 +46,26 @@ void -Mac_FreeWMCursor (_THIS, WMcursor * cursor) +Mac_FreeWMCursor(_THIS, WMcursor * cursor) { - SDL_free (cursor); + SDL_free(cursor); } WMcursor * -Mac_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, int hot_x, - int hot_y) +Mac_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, int hot_x, + int hot_y) { WMcursor *cursor; int row, bytes; /* Allocate the cursor memory */ - cursor = (WMcursor *) SDL_malloc (sizeof (WMcursor)); + cursor = (WMcursor *) SDL_malloc(sizeof(WMcursor)); if (cursor == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } - SDL_memset (cursor, 0, sizeof (*cursor)); + SDL_memset(cursor, 0, sizeof(*cursor)); if (w > 16) w = 16; @@ -76,11 +76,11 @@ bytes = (w + 7) / 8; for (row = 0; row < h; ++row) { - SDL_memcpy (&cursor->curs.data[row], data, bytes); + SDL_memcpy(&cursor->curs.data[row], data, bytes); data += bytes; } for (row = 0; row < h; ++row) { - SDL_memcpy (&cursor->curs.mask[row], mask, bytes); + SDL_memcpy(&cursor->curs.mask[row], mask, bytes); mask += bytes; } cursor->curs.hotSpot.h = hot_x; @@ -93,17 +93,17 @@ int Mac_cursor_showing = 1; int -Mac_ShowWMCursor (_THIS, WMcursor * cursor) +Mac_ShowWMCursor(_THIS, WMcursor * cursor) { if (cursor == NULL) { if (Mac_cursor_showing) { - HideCursor (); + HideCursor(); Mac_cursor_showing = 0; } } else { - SetCursor (&cursor->curs); + SetCursor(&cursor->curs); if (!Mac_cursor_showing) { - ShowCursor (); + ShowCursor(); Mac_cursor_showing = 1; } } @@ -111,24 +111,24 @@ } void -Mac_WarpWMCursor (_THIS, Uint16 x, Uint16 y) +Mac_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { #if !TARGET_API_MAC_CARBON CursorDevice *cursordevice; cursordevice = nil; - CursorDeviceNextDevice (&cursordevice); + CursorDeviceNextDevice(&cursordevice); if (cursordevice != nil) { WindowPtr saveport; Point where; - GetPort (&saveport); - SetPort (SDL_Window); + GetPort(&saveport); + SetPort(SDL_Window); where.h = x; where.v = y; - LocalToGlobal (&where); - SetPort (saveport); - CursorDeviceMoveTo (cursordevice, where.h, where.v); + LocalToGlobal(&where); + SetPort(saveport); + CursorDeviceMoveTo(cursordevice, where.h, where.v); } #endif /* !TARGET_API_MAC_CARBON */ } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/maccommon/SDL_macmouse_c.h --- a/src/video/maccommon/SDL_macmouse_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/maccommon/SDL_macmouse_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,12 +24,12 @@ #include "../macrom/SDL_romvideo.h" /* Functions to be exported */ -extern void Mac_FreeWMCursor (_THIS, WMcursor * cursor); -extern WMcursor *Mac_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, - int hot_x, int hot_y); -extern int Mac_ShowWMCursor (_THIS, WMcursor * cursor); -extern void Mac_WarpWMCursor (_THIS, Uint16 x, Uint16 y); +extern void Mac_FreeWMCursor(_THIS, WMcursor * cursor); +extern WMcursor *Mac_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, + int hot_x, int hot_y); +extern int Mac_ShowWMCursor(_THIS, WMcursor * cursor); +extern void Mac_WarpWMCursor(_THIS, Uint16 x, Uint16 y); /* Data to be exported */ extern int Mac_cursor_showing; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/maccommon/SDL_macwm.c --- a/src/video/maccommon/SDL_macwm.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/maccommon/SDL_macwm.c Mon May 29 04:04:35 2006 +0000 @@ -34,14 +34,14 @@ #include "SDL_macwm_c.h" void -Mac_SetCaption (_THIS, const char *title, const char *icon) +Mac_SetCaption(_THIS, const char *title, const char *icon) { /* Don't convert C to P string in place, because it may be read-only */ Str255 ptitle; /* MJS */ - ptitle[0] = strlen (title); - SDL_memcpy (ptitle + 1, title, ptitle[0]); /* MJS */ + ptitle[0] = strlen(title); + SDL_memcpy(ptitle + 1, title, ptitle[0]); /* MJS */ if (SDL_Window) - SetWTitle (SDL_Window, ptitle); /* MJS */ + SetWTitle(SDL_Window, ptitle); /* MJS */ } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/maccommon/SDL_macwm_c.h --- a/src/video/maccommon/SDL_macwm_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/maccommon/SDL_macwm_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,5 +24,5 @@ #include "../macrom/SDL_romvideo.h" /* Functions to be exported */ -extern void Mac_SetCaption (_THIS, const char *title, const char *icon); +extern void Mac_SetCaption(_THIS, const char *title, const char *icon); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/macdsp/SDL_dspvideo.c --- a/src/video/macdsp/SDL_dspvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/macdsp/SDL_dspvideo.c Mon May 29 04:04:35 2006 +0000 @@ -150,40 +150,40 @@ #include "../maccommon/SDL_macevents_c.h" /* Initialization/Query functions */ -static int DSp_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **DSp_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *DSp_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int DSp_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static int DSp_CreatePalette (_THIS); -static int DSp_DestroyPalette (_THIS); -static void DSp_VideoQuit (_THIS); +static int DSp_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **DSp_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +static SDL_Surface *DSp_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +static int DSp_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static int DSp_CreatePalette(_THIS); +static int DSp_DestroyPalette(_THIS); +static void DSp_VideoQuit(_THIS); -static int DSp_GetMainDevice (_THIS, GDHandle * device); -static void DSp_IsHWAvailable (_THIS, SDL_PixelFormat * vformat); -static void DSp_DSpUpdate (_THIS, int numrects, SDL_Rect * sdl_rects); -static void DSp_DirectUpdate (_THIS, int numrects, SDL_Rect * sdl_rects); +static int DSp_GetMainDevice(_THIS, GDHandle * device); +static void DSp_IsHWAvailable(_THIS, SDL_PixelFormat * vformat); +static void DSp_DSpUpdate(_THIS, int numrects, SDL_Rect * sdl_rects); +static void DSp_DirectUpdate(_THIS, int numrects, SDL_Rect * sdl_rects); /* Hardware surface functions */ -static int DSp_SetHWAlpha (_THIS, SDL_Surface * surface, UInt8 alpha); -static int DSp_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key); -static int DSp_NewHWSurface (_THIS, CGrafPtr * port, int depth, int width, - int height); -static int DSp_AllocHWSurface (_THIS, SDL_Surface * surface); -static int DSp_LockHWSurface (_THIS, SDL_Surface * surface); -static void DSp_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void DSp_FreeHWSurface (_THIS, SDL_Surface * surface); -static int DSp_FlipHWSurface (_THIS, SDL_Surface * surface); -static int DSp_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dest); -static int DSp_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect); -static int DSp_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * rect, - Uint32 color); +static int DSp_SetHWAlpha(_THIS, SDL_Surface * surface, UInt8 alpha); +static int DSp_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key); +static int DSp_NewHWSurface(_THIS, CGrafPtr * port, int depth, int width, + int height); +static int DSp_AllocHWSurface(_THIS, SDL_Surface * surface); +static int DSp_LockHWSurface(_THIS, SDL_Surface * surface); +static void DSp_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void DSp_FreeHWSurface(_THIS, SDL_Surface * surface); +static int DSp_FlipHWSurface(_THIS, SDL_Surface * surface); +static int DSp_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dest); +static int DSp_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); +static int DSp_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, + Uint32 color); #if SDL_VIDEO_OPENGL -static void DSp_GL_SwapBuffers (_THIS); +static void DSp_GL_SwapBuffers(_THIS); #endif #if ! TARGET_API_MAC_CARBON @@ -222,7 +222,7 @@ /* Macintosh toolbox driver bootstrap functions */ static int -DSp_Available (void) +DSp_Available(void) { /* Check for DrawSprocket */ #if ! TARGET_API_MAC_OSX @@ -234,7 +234,7 @@ } static void -DSp_DeleteDevice (SDL_VideoDevice * device) +DSp_DeleteDevice(SDL_VideoDevice * device) { /* -dw- taking no chances with null pointers */ if (device) { @@ -242,54 +242,53 @@ if (device->hidden) { if (device->hidden->dspinfo) - SDL_free (device->hidden->dspinfo); + SDL_free(device->hidden->dspinfo); - SDL_free (device->hidden); + SDL_free(device->hidden); } - SDL_free (device); + SDL_free(device); } } static SDL_VideoDevice * -DSp_CreateDevice (int devindex) +DSp_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, sizeof (*device)); + SDL_memset(device, 0, sizeof(*device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); if (device->hidden) - SDL_memset (device->hidden, 0, sizeof (*(device->hidden))); + SDL_memset(device->hidden, 0, sizeof(*(device->hidden))); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { if (device->hidden) - SDL_free (device->hidden); + SDL_free(device->hidden); - SDL_free (device); + SDL_free(device); } return (NULL); } /* Allocate DrawSprocket information */ - device->hidden->dspinfo = (struct DSpInfo *) SDL_malloc ((sizeof *device-> - hidden-> - dspinfo)); + device->hidden->dspinfo = (struct DSpInfo *) SDL_malloc((sizeof *device-> + hidden-> + dspinfo)); if (device->hidden->dspinfo == NULL) { - SDL_OutOfMemory (); - SDL_free (device->hidden); - SDL_free (device); + SDL_OutOfMemory(); + SDL_free(device->hidden); + SDL_free(device); return (0); } - SDL_memset (device->hidden->dspinfo, 0, - (sizeof *device->hidden->dspinfo)); + SDL_memset(device->hidden->dspinfo, 0, (sizeof *device->hidden->dspinfo)); /* Set the function pointers */ device->VideoInit = DSp_VideoInit; @@ -340,8 +339,8 @@ /* Use DSp/Display Manager to build mode list for given screen */ static SDL_Rect ** -DSp_BuildModeList (const GDHandle gDevice, int *displayWidth, - int *displayHeight) +DSp_BuildModeList(const GDHandle gDevice, int *displayWidth, + int *displayHeight) { DSpContextAttributes attributes; DSpContextReference context; @@ -356,22 +355,22 @@ #else /* Ask Display Manager for integer id of screen device */ - if (DMGetDisplayIDByGDevice (gDevice, &displayID, SDL_TRUE) != noErr) { + if (DMGetDisplayIDByGDevice(gDevice, &displayID, SDL_TRUE) != noErr) { return NULL; } #endif /* Get the first possible DSp context on this device */ - if (DSpGetFirstContext (displayID, &context) != noErr) { + if (DSpGetFirstContext(displayID, &context) != noErr) { return NULL; } - if (DSpContext_GetAttributes (context, &attributes) != noErr) + if (DSpContext_GetAttributes(context, &attributes) != noErr) return NULL; *displayWidth = attributes.displayWidth; *displayHeight = attributes.displayHeight; - for (i = 0; i < SDL_arraysize (temp_list); i++) { + for (i = 0; i < SDL_arraysize(temp_list); i++) { width = attributes.displayWidth; height = attributes.displayHeight; @@ -387,14 +386,14 @@ while (width == attributes.displayWidth && height == attributes.displayHeight) { - OSStatus err = DSpGetNextContext (context, &context); + OSStatus err = DSpGetNextContext(context, &context); if (err != noErr) if (err == kDSpContextNotFoundErr) goto done; else return NULL; - if (DSpContext_GetAttributes (context, &attributes) != noErr) + if (DSpContext_GetAttributes(context, &attributes) != noErr) return NULL; temp_list[i].x |= attributes.displayBestDepth; @@ -403,22 +402,22 @@ done: i++; /* i was not incremented before kicking out of the loop */ - mode_list = (SDL_Rect **) SDL_malloc (sizeof (SDL_Rect *) * (i + 1)); + mode_list = (SDL_Rect **) SDL_malloc(sizeof(SDL_Rect *) * (i + 1)); if (mode_list) { /* -dw- new stuff: build in reverse order so largest sizes list first */ for (j = i - 1; j >= 0; j--) { - mode_list[j] = (SDL_Rect *) SDL_malloc (sizeof (SDL_Rect)); + mode_list[j] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect)); if (mode_list[j]) - SDL_memcpy (mode_list[j], &(temp_list[j]), sizeof (SDL_Rect)); + SDL_memcpy(mode_list[j], &(temp_list[j]), sizeof(SDL_Rect)); else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return NULL; } } mode_list[i] = NULL; /* append null to the end */ } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return NULL; } @@ -426,7 +425,7 @@ } static void -DSp_IsHWAvailable (_THIS, SDL_PixelFormat * vformat) +DSp_IsHWAvailable(_THIS, SDL_PixelFormat * vformat) { /* VRAM GWorlds are only available on OS 9 or later. @@ -439,29 +438,29 @@ dsp_vram_available = SDL_FALSE; dsp_agp_available = SDL_FALSE; - Gestalt ('sysv', &versionSystem); + Gestalt('sysv', &versionSystem); if (0x00000860 < (versionSystem & 0x0000FFFF)) { GWorldPtr offscreen; OSStatus err; Rect bounds; - SetRect (&bounds, 0, 0, 320, 240); + SetRect(&bounds, 0, 0, 320, 240); #if useDistantHdwrMem && useLocalHdwrMem err = - NewGWorld (&offscreen, vformat->BitsPerPixel, &bounds, NULL, - SDL_Display, useDistantHdwrMem | noNewDevice); + NewGWorld(&offscreen, vformat->BitsPerPixel, &bounds, NULL, + SDL_Display, useDistantHdwrMem | noNewDevice); if (err == noErr) { dsp_vram_available = SDL_TRUE; - DisposeGWorld (offscreen); + DisposeGWorld(offscreen); } err = - NewGWorld (&offscreen, vformat->BitsPerPixel, &bounds, NULL, - SDL_Display, useLocalHdwrMem | noNewDevice); + NewGWorld(&offscreen, vformat->BitsPerPixel, &bounds, NULL, + SDL_Display, useLocalHdwrMem | noNewDevice); if (err == noErr) { - DisposeGWorld (offscreen); + DisposeGWorld(offscreen); dsp_agp_available = SDL_TRUE; } #endif @@ -469,12 +468,12 @@ } static int -DSp_GetMainDevice (_THIS, GDHandle * device) +DSp_GetMainDevice(_THIS, GDHandle * device) { #if TARGET_API_MAC_OSX /* DSpUserSelectContext not available on OS X */ - *device = GetMainDevice (); + *device = GetMainDevice(); return 0; #else @@ -484,8 +483,8 @@ GDHandle main_device; GDHandle device_list; - device_list = GetDeviceList (); - main_device = GetMainDevice (); + device_list = GetDeviceList(); + main_device = GetMainDevice(); /* Quick check to avoid slower method when only one display exists */ if ((**device_list).gdNextGD == NULL) { @@ -493,7 +492,7 @@ return 0; } - SDL_memset (&attrib, 0, sizeof (DSpContextAttributes)); + SDL_memset(&attrib, 0, sizeof(DSpContextAttributes)); /* These attributes are hopefully supported on all devices... */ attrib.displayWidth = 640; @@ -505,26 +504,24 @@ attrib.colorNeeds = kDSpColorNeeds_Require; attrib.pageCount = 1; - if (noErr != - DMGetDisplayIDByGDevice (main_device, &display_id, SDL_FALSE)) { + if (noErr != DMGetDisplayIDByGDevice(main_device, &display_id, SDL_FALSE)) { SDL_SetError ("Display Manager couldn't associate GDevice with a Display ID"); return (-1); } /* Put up dialog on main display to select which display to use */ - if (noErr != DSpUserSelectContext (&attrib, display_id, NULL, &context)) { - SDL_SetError ("DrawSprocket couldn't create a context"); + if (noErr != DSpUserSelectContext(&attrib, display_id, NULL, &context)) { + SDL_SetError("DrawSprocket couldn't create a context"); return (-1); } - if (noErr != DSpContext_GetDisplayID (context, &display_id)) { - SDL_SetError ("DrawSprocket couldn't get display ID"); + if (noErr != DSpContext_GetDisplayID(context, &display_id)) { + SDL_SetError("DrawSprocket couldn't get display ID"); return (-1); } - if (noErr != - DMGetGDeviceByDisplayID (display_id, &main_device, SDL_FALSE)) { + if (noErr != DMGetGDeviceByDisplayID(display_id, &main_device, SDL_FALSE)) { SDL_SetError ("Display Manager couldn't associate Display ID with GDevice"); return (-1); @@ -536,12 +533,12 @@ } static int -DSp_VideoInit (_THIS, SDL_PixelFormat * vformat) +DSp_VideoInit(_THIS, SDL_PixelFormat * vformat) { NumVersion dsp_version = { 0x01, 0x00, 0x00, 0x00 }; #if UNIVERSAL_INTERFACES_VERSION > 0x0320 - dsp_version = DSpGetVersion (); + dsp_version = DSpGetVersion(); #endif if ((dsp_version.majorRev == 1 && dsp_version.minorAndBugRev < 0x73) || @@ -552,25 +549,24 @@ "You can find a newer version at http://www.apple.com/swupdates.", NULL, NULL); */ - SDL_SetError - ("DrawSprocket version is too old. Need 1.7.3 or later."); + SDL_SetError("DrawSprocket version is too old. Need 1.7.3 or later."); return (-1); } - if (DSpStartup () != noErr) { - SDL_SetError ("DrawSprocket couldn't startup"); + if (DSpStartup() != noErr) { + SDL_SetError("DrawSprocket couldn't startup"); return (-1); } /* Start DSpintosh events */ - Mac_InitEvents (this); + Mac_InitEvents(this); /* Get a handle to the main monitor, or choose one on multiple monitor setups */ - if (DSp_GetMainDevice (this, &SDL_Display) < 0) + if (DSp_GetMainDevice(this, &SDL_Display) < 0) return (-1); /* Determine pixel format */ - vformat->BitsPerPixel = GetPixDepth ((**SDL_Display).gdPMap); + vformat->BitsPerPixel = GetPixDepth((**SDL_Display).gdPMap); dsp_old_depth = vformat->BitsPerPixel; switch (vformat->BitsPerPixel) { @@ -583,22 +579,22 @@ break; } - if (DSp_CreatePalette (this) < 0) { - SDL_SetError ("Could not create palette"); + if (DSp_CreatePalette(this) < 0) { + SDL_SetError("Could not create palette"); return (-1); } /* Get a list of available fullscreen modes */ - SDL_modelist = DSp_BuildModeList (SDL_Display, - &this->info.current_w, - &this->info.current_h); + SDL_modelist = DSp_BuildModeList(SDL_Display, + &this->info.current_w, + &this->info.current_h); if (SDL_modelist == NULL) { - SDL_SetError ("DrawSprocket could not build a mode list"); + SDL_SetError("DrawSprocket could not build a mode list"); return (-1); } /* Check for VRAM and AGP GWorlds for HW Blitting */ - DSp_IsHWAvailable (this, vformat); + DSp_IsHWAvailable(this, vformat); this->info.wm_available = 0; @@ -626,7 +622,7 @@ } static SDL_Rect ** -DSp_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +DSp_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { static SDL_Rect *dsp_modes[16]; int i = 0, j = 0; @@ -649,14 +645,14 @@ } /* Various screen update functions available */ -static void DSp_DirectUpdate (_THIS, int numrects, SDL_Rect * rects); +static void DSp_DirectUpdate(_THIS, int numrects, SDL_Rect * rects); #if ! TARGET_API_MAC_OSX static volatile unsigned int retrace_count = 0; /* -dw- need volatile because it updates asychronously */ Boolean -DSp_VBLProc (DSpContextReference context, void *ref_con) +DSp_VBLProc(DSpContextReference context, void *ref_con) { retrace_count++; @@ -664,7 +660,7 @@ } static void -DSp_SetHWError (OSStatus err, int is_agp) +DSp_SetHWError(OSStatus err, int is_agp) { char message[1024]; const char *fmt, *mem; @@ -685,14 +681,14 @@ fmt = "Hardware surface could not be allocated in %s - unknown error"; break; } - SDL_snprintf (message, SDL_arraysize (message), fmt, mem); - SDL_SetError (message); + SDL_snprintf(message, SDL_arraysize(message), fmt, mem); + SDL_SetError(message); } #endif // TARGET_API_MAC_OSX /* put up a dialog to verify display change */ static int -DSp_ConfirmSwitch () +DSp_ConfirmSwitch() { /* resource id's for dialog */ @@ -706,77 +702,77 @@ DialogItemIndex item = 0; GrafPtr savePort; - GetPort (&savePort); + GetPort(&savePort); - dialog = GetNewDialog (rDialog, NULL, (WindowPtr) - 1); + dialog = GetNewDialog(rDialog, NULL, (WindowPtr) - 1); if (dialog == NULL) return (0); #if TARGET_API_MAC_CARBON - SetPort (GetDialogPort (dialog)); + SetPort(GetDialogPort(dialog)); #else - SetPort ((WindowPtr) dialog); + SetPort((WindowPtr) dialog); #endif - SetDialogDefaultItem (dialog, bCancel); - SetDialogCancelItem (dialog, bCancel); + SetDialogDefaultItem(dialog, bCancel); + SetDialogCancelItem(dialog, bCancel); - SetEventMask (everyEvent); - FlushEvents (everyEvent, 0); + SetEventMask(everyEvent); + FlushEvents(everyEvent, 0); /* On MacOS 8.5 or later, we can make the dialog go away after 15 seconds */ /* This is good since it's possible user can't even see the dialog! */ /* Requires linking to DialogsLib */ - err = Gestalt (gestaltSystemVersion, &response); + err = Gestalt(gestaltSystemVersion, &response); if (err == noErr && response >= 0x00000850) { - SetDialogTimeout (dialog, bCancel, 15); + SetDialogTimeout(dialog, bCancel, 15); } do { - ModalDialog (NULL, &item); + ModalDialog(NULL, &item); } while (item != bCancel && item != bOK && err != noErr); - DisposeDialog (dialog); - SetPort (savePort); + DisposeDialog(dialog); + SetPort(savePort); - SetEventMask (everyEvent - autoKeyMask); - FlushEvents (everyEvent, 0); + SetEventMask(everyEvent - autoKeyMask); + FlushEvents(everyEvent, 0); return (item - 1); } static void -DSp_UnsetVideoMode (_THIS, SDL_Surface * current) +DSp_UnsetVideoMode(_THIS, SDL_Surface * current) { if (current->flags & SDL_INTERNALOPENGL) { - Mac_GL_Quit (this); + Mac_GL_Quit(this); } if (dsp_context != NULL) { GWorldPtr front; - DSpContext_GetFrontBuffer (dsp_context, &front); + DSpContext_GetFrontBuffer(dsp_context, &front); if (front != dsp_back_buffer) - DisposeGWorld (dsp_back_buffer); + DisposeGWorld(dsp_back_buffer); if (current->hwdata) - SDL_free (current->hwdata); + SDL_free(current->hwdata); - DSpContext_SetState (dsp_context, kDSpContextState_Inactive); - DSpContext_Release (dsp_context); + DSpContext_SetState(dsp_context, kDSpContextState_Inactive); + DSpContext_Release(dsp_context); dsp_context = NULL; } if (SDL_Window != NULL) { - DisposeWindow (SDL_Window); + DisposeWindow(SDL_Window); SDL_Window = NULL; } @@ -785,9 +781,9 @@ } static SDL_Surface * -DSp_SetVideoMode (_THIS, - SDL_Surface * current, int width, int height, int bpp, - Uint32 flags) +DSp_SetVideoMode(_THIS, + SDL_Surface * current, int width, int height, int bpp, + Uint32 flags) { #if !TARGET_API_MAC_OSX @@ -803,10 +799,10 @@ int hw_surface; int use_dsp_back_buffer; - DSp_UnsetVideoMode (this, current); + DSp_UnsetVideoMode(this, current); if (bpp != dsp_old_depth) - DSp_DestroyPalette (this); + DSp_DestroyPalette(this); double_buf = (flags & SDL_DOUBLEBUF) != 0; hw_surface = (flags & SDL_HWSURFACE) != 0; @@ -822,7 +818,7 @@ page_count = 1; } - SDL_memset (&attrib, 0, sizeof (DSpContextAttributes)); + SDL_memset(&attrib, 0, sizeof(DSpContextAttributes)); attrib.displayWidth = width; attrib.displayHeight = height; attrib.displayBestDepth = bpp; @@ -834,48 +830,47 @@ attrib.pageCount = page_count; #if TARGET_API_MAC_OSX || UNIVERSAL_INTERFACES_VERSION == 0x0320 - if (DSpFindBestContext (&attrib, &dsp_context) != noErr) { - SDL_SetError ("DrawSprocket couldn't find a context"); + if (DSpFindBestContext(&attrib, &dsp_context) != noErr) { + SDL_SetError("DrawSprocket couldn't find a context"); return NULL; } #else - if (noErr != - DMGetDisplayIDByGDevice (SDL_Display, &display_id, SDL_FALSE)) { + if (noErr != DMGetDisplayIDByGDevice(SDL_Display, &display_id, SDL_FALSE)) { SDL_SetError ("Display Manager couldn't associate GDevice with display_id"); return NULL; } - if (DSpFindBestContextOnDisplayID (&attrib, &dsp_context, display_id) != + if (DSpFindBestContextOnDisplayID(&attrib, &dsp_context, display_id) != noErr) { SDL_SetError ("DrawSprocket couldn't find a suitable context on given display"); return NULL; } #endif - if (DSpContext_Reserve (dsp_context, &attrib) != noErr) { + if (DSpContext_Reserve(dsp_context, &attrib) != noErr) { SDL_SetError ("DrawSprocket couldn't get the needed resources to build the display"); return NULL; } if ((err = - DSpContext_SetState (dsp_context, kDSpContextState_Active)) != noErr) + DSpContext_SetState(dsp_context, kDSpContextState_Active)) != noErr) { if (err == kDSpConfirmSwitchWarning) { - if (!DSp_ConfirmSwitch ()) { + if (!DSp_ConfirmSwitch()) { - DSpContext_Release (dsp_context); + DSpContext_Release(dsp_context); dsp_context = NULL; - SDL_SetError ("User cancelled display switch"); + SDL_SetError("User cancelled display switch"); return NULL; } else /* Have to reactivate context. Why? */ - DSpContext_SetState (dsp_context, kDSpContextState_Active); + DSpContext_SetState(dsp_context, kDSpContextState_Active); } else { - SDL_SetError ("DrawSprocket couldn't activate the context"); + SDL_SetError("DrawSprocket couldn't activate the context"); return NULL; } } @@ -883,7 +878,7 @@ if (bpp != dsp_old_depth) { - DSp_CreatePalette (this); + DSp_CreatePalette(this); /* update format if display depth changed */ if (bpp == 16) { @@ -892,9 +887,9 @@ gmask = 0x000003e0; bmask = 0x0000001f; } - if (!SDL_ReallocFormat (current, bpp, rmask, gmask, bmask, 0)) { + if (!SDL_ReallocFormat(current, bpp, rmask, gmask, bmask, 0)) { - SDL_SetError ("Could not reallocate video format."); + SDL_SetError("Could not reallocate video format."); return (NULL); } } @@ -902,12 +897,12 @@ if (!double_buf) { /* single-buffer context */ - DSpContext_GetFrontBuffer (dsp_context, &dsp_back_buffer); + DSpContext_GetFrontBuffer(dsp_context, &dsp_back_buffer); current->hwdata = - (private_hwdata *) SDL_malloc (sizeof (private_hwdata)); + (private_hwdata *) SDL_malloc(sizeof(private_hwdata)); if (current->hwdata == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return NULL; } current->hwdata->offscreen = dsp_back_buffer; @@ -915,8 +910,8 @@ this->UpdateRects = DSp_DirectUpdate; } else if (use_dsp_back_buffer) { - DSpContext_GetBackBuffer (dsp_context, kDSpBufferKind_Normal, - &dsp_back_buffer); + DSpContext_GetBackBuffer(dsp_context, kDSpBufferKind_Normal, + &dsp_back_buffer); current->flags |= SDL_DOUBLEBUF | SDL_SWSURFACE; /* only front buffer is in VRAM */ this->UpdateRects = DSp_DSpUpdate; @@ -924,25 +919,25 @@ (this, &dsp_back_buffer, bpp, width - 1, height - 1) == 0) { current->hwdata = - (private_hwdata *) SDL_malloc (sizeof (private_hwdata)); + (private_hwdata *) SDL_malloc(sizeof(private_hwdata)); if (current->hwdata == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return NULL; } - SDL_memset (current->hwdata, 0, sizeof (private_hwdata)); + SDL_memset(current->hwdata, 0, sizeof(private_hwdata)); current->hwdata->offscreen = dsp_back_buffer; current->flags |= SDL_DOUBLEBUF | SDL_HWSURFACE; this->UpdateRects = DSp_DirectUpdate; /* hardware doesn't do update rects, must be page-flipped */ } else { - DSpContext_Release (dsp_context); + DSpContext_Release(dsp_context); use_dsp_back_buffer = SDL_TRUE; goto rebuild; } - current->pitch = GetPortPixRowBytes (dsp_back_buffer) & 0x3FFF; - current->pixels = GetPixBaseAddr (GetPortPixMap (dsp_back_buffer)); + current->pitch = GetPortPixRowBytes(dsp_back_buffer) & 0x3FFF; + current->pixels = GetPixBaseAddr(GetPortPixMap(dsp_back_buffer)); current->w = width; current->h = height; @@ -951,14 +946,14 @@ if (use_dsp_back_buffer) { - DSpContext_GetMonitorFrequency (dsp_context, &freq); - DSpContext_SetMaxFrameRate (dsp_context, freq >> 16); + DSpContext_GetMonitorFrequency(dsp_context, &freq); + DSpContext_SetMaxFrameRate(dsp_context, freq >> 16); } if ((current->flags & SDL_HWSURFACE) || (current->flags & SDL_INTERNALOPENGL)) - DSpContext_SetVBLProc (dsp_context, DSp_VBLProc, NULL); + DSpContext_SetVBLProc(dsp_context, DSp_VBLProc, NULL); #endif if (bpp == 8) @@ -970,10 +965,10 @@ RGBColor rgb = { 0.0, 0.0, 0.0 }; GrafPtr save_port; - SetRect (&rect, 0, 0, width, height); + SetRect(&rect, 0, 0, width, height); SDL_Window = - NewCWindow (nil, &((**SDL_Display).gdRect), "\p", SDL_TRUE, - plainDBox, (WindowPtr) - 1, SDL_FALSE, 0); + NewCWindow(nil, &((**SDL_Display).gdRect), "\p", SDL_TRUE, + plainDBox, (WindowPtr) - 1, SDL_FALSE, 0); if (SDL_Window == NULL) { @@ -983,20 +978,20 @@ } /* Set window color to black to avoid white flash */ - GetPort (&save_port); + GetPort(&save_port); #if TARGET_API_MAC_CARBON - SetPort (GetWindowPort (SDL_Window)); + SetPort(GetWindowPort(SDL_Window)); #else - SetPort (SDL_Window); + SetPort(SDL_Window); #endif - RGBForeColor (&rgb); - PaintRect (&rect); - SetPort (save_port); + RGBForeColor(&rgb); + PaintRect(&rect); + SetPort(save_port); - SetPortWindowPort (SDL_Window); - SelectWindow (SDL_Window); + SetPortWindowPort(SDL_Window); + SelectWindow(SDL_Window); - if (Mac_GL_Init (this) < 0) { + if (Mac_GL_Init(this) < 0) { SDL_SetError ("DSp_SetVideoMode : could not create OpenGL context."); @@ -1012,7 +1007,7 @@ #ifdef DSP_TRY_CC_AND_AA static int -DSp_MakeHWMask (_THIS, SDL_Surface * surface) +DSp_MakeHWMask(_THIS, SDL_Surface * surface) { GDHandle save_device; CGrafPtr save_port; @@ -1021,44 +1016,44 @@ RGBColor white = { 0xFFFF, 0xFFFF, 0xFFFF }; Rect rect; - Uint32 depth = GetPixDepth (GetGDevPixMap (SDL_Display)); + Uint32 depth = GetPixDepth(GetGDevPixMap(SDL_Display)); - SetRect (&rect, 0, 0, surface->w, surface->h); + SetRect(&rect, 0, 0, surface->w, surface->h); if (noErr != - NewGWorld (&(surface->hwdata->mask), depth, &rect, 0, SDL_Display, - 0) < 0) { + NewGWorld(&(surface->hwdata->mask), depth, &rect, 0, SDL_Display, + 0) < 0) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } - if (noErr != NewGWorld (&temp, depth, &rect, 0, SDL_Display, 0)) { + if (noErr != NewGWorld(&temp, depth, &rect, 0, SDL_Display, 0)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } - GetGWorld (&save_port, &save_device); - SetGWorld (surface->hwdata->mask, SDL_Display); + GetGWorld(&save_port, &save_device); + SetGWorld(surface->hwdata->mask, SDL_Display); - RGBForeColor (&white); - PaintRect (&rect); + RGBForeColor(&white); + PaintRect(&rect); - RGBBackColor (&(surface->hwdata->trans)); + RGBBackColor(&(surface->hwdata->trans)); - CopyBits (GetPortBitMapForCopyBits (surface->hwdata->offscreen), - GetPortBitMapForCopyBits (surface->hwdata->mask), - &rect, &rect, transparent, NULL); + CopyBits(GetPortBitMapForCopyBits(surface->hwdata->offscreen), + GetPortBitMapForCopyBits(surface->hwdata->mask), + &rect, &rect, transparent, NULL); - SetGWorld (surface->hwdata->mask, SDL_Display); - SetGWorld (save_port, save_device); + SetGWorld(surface->hwdata->mask, SDL_Display); + SetGWorld(save_port, save_device); return (0); } static int -DSp_SetHWAlpha (_THIS, SDL_Surface * surface, UInt8 alpha) +DSp_SetHWAlpha(_THIS, SDL_Surface * surface, UInt8 alpha) { surface->hwdata->alpha.red = (alpha / 255.0) * 65535; surface->hwdata->alpha.blue = (alpha / 255.0) * 65535; @@ -1067,27 +1062,27 @@ surface->flags |= SDL_SRCALPHA; if (surface->flags & SDL_SRCCOLORKEY) { - return (DSp_MakeHWMask (this, surface)); + return (DSp_MakeHWMask(this, surface)); } return (0); } static int -DSp_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key) +DSp_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key) { CGrafPtr save_port; GDHandle save_device; - GetGWorld (&save_port, &save_device); - SetGWorld (surface->hwdata->offscreen, NULL); + GetGWorld(&save_port, &save_device); + SetGWorld(surface->hwdata->offscreen, NULL); - Index2Color (key, &(surface->hwdata->trans)); + Index2Color(key, &(surface->hwdata->trans)); surface->flags |= SDL_SRCCOLORKEY; - SetGWorld (save_port, save_device); + SetGWorld(save_port, save_device); if (surface->flags & SDL_SRCALPHA) { - return (DSp_MakeHWMask (this, surface)); + return (DSp_MakeHWMask(this, surface)); } return (0); } @@ -1095,22 +1090,22 @@ #endif /* DSP_TRY_CC_AND_AA */ static int -DSp_NewHWSurface (_THIS, CGrafPtr * port, int depth, int width, int height) +DSp_NewHWSurface(_THIS, CGrafPtr * port, int depth, int width, int height) { OSStatus err; Rect bounds; - SetRect (&bounds, 0, 0, width, height); + SetRect(&bounds, 0, 0, width, height); #if useDistantHdwrMem && useLocalHdwrMem if (dsp_vram_available) { /* try VRAM */ err = - NewGWorld (port, depth, &bounds, 0, SDL_Display, - useDistantHdwrMem | noNewDevice); + NewGWorld(port, depth, &bounds, 0, SDL_Display, + useDistantHdwrMem | noNewDevice); if (err != noErr) - DSp_SetHWError (err, SDL_FALSE); + DSp_SetHWError(err, SDL_FALSE); else return (0); } @@ -1118,11 +1113,11 @@ if (dsp_agp_available) { /* try AGP */ err = - NewGWorld (port, depth, &bounds, 0, SDL_Display, - useLocalHdwrMem | noNewDevice); + NewGWorld(port, depth, &bounds, 0, SDL_Display, + useLocalHdwrMem | noNewDevice); if (err != noErr) - DSp_SetHWError (err, SDL_TRUE); + DSp_SetHWError(err, SDL_TRUE); else return (0); } @@ -1132,7 +1127,7 @@ } static int -DSp_AllocHWSurface (_THIS, SDL_Surface * surface) +DSp_AllocHWSurface(_THIS, SDL_Surface * surface) { GWorldPtr temp; @@ -1141,16 +1136,16 @@ surface->h) < 0) return (-1); - surface->hwdata = (private_hwdata *) SDL_malloc (sizeof (private_hwdata)); + surface->hwdata = (private_hwdata *) SDL_malloc(sizeof(private_hwdata)); if (surface->hwdata == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return -1; } - SDL_memset (surface->hwdata, 0, sizeof (private_hwdata)); + SDL_memset(surface->hwdata, 0, sizeof(private_hwdata)); surface->hwdata->offscreen = temp; - surface->pitch = GetPixRowBytes (GetPortPixMap (temp)) & 0x3FFF; - surface->pixels = GetPixBaseAddr (GetPortPixMap (temp)); + surface->pitch = GetPixRowBytes(GetPortPixMap(temp)) & 0x3FFF; + surface->pixels = GetPixBaseAddr(GetPortPixMap(temp)); surface->flags |= SDL_HWSURFACE; #ifdef DSP_TRY_CC_AND_AA surface->flags |= SDL_HWACCEL; @@ -1159,17 +1154,17 @@ } static void -DSp_FreeHWSurface (_THIS, SDL_Surface * surface) +DSp_FreeHWSurface(_THIS, SDL_Surface * surface) { if (surface->hwdata->offscreen != NULL) - DisposeGWorld (surface->hwdata->offscreen); - SDL_free (surface->hwdata); + DisposeGWorld(surface->hwdata->offscreen); + SDL_free(surface->hwdata); surface->pixels = NULL; } static int -DSp_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dest) +DSp_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dest) { int accelerated; @@ -1197,8 +1192,8 @@ } static int -DSp_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +DSp_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { CGrafPtr save_port; GDHandle save_device; @@ -1210,84 +1205,84 @@ UInt32 mode; #endif - SetRect (&src_rect, srcrect->x, srcrect->y, srcrect->x + srcrect->w, - srcrect->y + srcrect->h); - SetRect (&dst_rect, dstrect->x, dstrect->y, dstrect->x + dstrect->w, - dstrect->y + dstrect->h); + SetRect(&src_rect, srcrect->x, srcrect->y, srcrect->x + srcrect->w, + srcrect->y + srcrect->h); + SetRect(&dst_rect, dstrect->x, dstrect->y, dstrect->x + dstrect->w, + dstrect->y + dstrect->h); - GetGWorld (&save_port, &save_device); - SetGWorld (dst->hwdata->offscreen, NULL); + GetGWorld(&save_port, &save_device); + SetGWorld(dst->hwdata->offscreen, NULL); - RGBForeColor (&black); - RGBBackColor (&white); + RGBForeColor(&black); + RGBBackColor(&white); #ifdef DSP_TRY_CC_AND_AA if ((src->flags & SDL_SRCCOLORKEY) && (src->flags & SDL_SRCALPHA)) { - OpColor (&(src->hwdata->alpha)); + OpColor(&(src->hwdata->alpha)); - CopyDeepMask (GetPortBitMapForCopyBits (src->hwdata->offscreen), - GetPortBitMapForCopyBits (src->hwdata->mask), - GetPortBitMapForCopyBits (dst->hwdata->offscreen), - &src_rect, &src_rect, &dst_rect, blend, NULL); + CopyDeepMask(GetPortBitMapForCopyBits(src->hwdata->offscreen), + GetPortBitMapForCopyBits(src->hwdata->mask), + GetPortBitMapForCopyBits(dst->hwdata->offscreen), + &src_rect, &src_rect, &dst_rect, blend, NULL); } else { if (src->flags & SDL_SRCCOLORKEY) { - RGBBackColor (&(src->hwdata->trans)); + RGBBackColor(&(src->hwdata->trans)); mode = transparent; } else if (src->flags & SDL_SRCALPHA) { - OpColor (&(src->hwdata->alpha)); + OpColor(&(src->hwdata->alpha)); mode = blend; } else { mode = srcCopy; } - CopyBits (GetPortBitMapForCopyBits (src->hwdata->offscreen), - GetPortBitMapForCopyBits (dst->hwdata->offscreen), - &src_rect, &dst_rect, mode, NULL); + CopyBits(GetPortBitMapForCopyBits(src->hwdata->offscreen), + GetPortBitMapForCopyBits(dst->hwdata->offscreen), + &src_rect, &dst_rect, mode, NULL); } #else - CopyBits (&(((GrafPtr) (src->hwdata->offscreen))->portBits), - &(((GrafPtr) (dst->hwdata->offscreen))->portBits), - &src_rect, &dst_rect, srcCopy, NULL); + CopyBits(&(((GrafPtr) (src->hwdata->offscreen))->portBits), + &(((GrafPtr) (dst->hwdata->offscreen))->portBits), + &src_rect, &dst_rect, srcCopy, NULL); #endif /* DSP_TRY_CC_AND_AA */ - SetGWorld (save_port, save_device); + SetGWorld(save_port, save_device); return (0); } static int -DSp_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) +DSp_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) { CGrafPtr save_port; GDHandle save_device; Rect fill_rect; RGBColor rgb; - SetRect (&fill_rect, rect->x, rect->y, rect->x + rect->w, - rect->y + rect->h); + SetRect(&fill_rect, rect->x, rect->y, rect->x + rect->w, + rect->y + rect->h); - GetGWorld (&save_port, &save_device); - SetGWorld (dst->hwdata->offscreen, NULL); + GetGWorld(&save_port, &save_device); + SetGWorld(dst->hwdata->offscreen, NULL); - Index2Color (color, &rgb); + Index2Color(color, &rgb); - RGBForeColor (&rgb); - PaintRect (&fill_rect); + RGBForeColor(&rgb); + PaintRect(&fill_rect); - SetGWorld (save_port, save_device); + SetGWorld(save_port, save_device); return (0); } static int -DSp_FlipHWSurface (_THIS, SDL_Surface * surface) +DSp_FlipHWSurface(_THIS, SDL_Surface * surface) { if ((surface->flags & SDL_HWSURFACE)) { CGrafPtr dsp_front_buffer, save_port; @@ -1298,11 +1293,11 @@ #endif /* pseudo page flipping for VRAM back buffer */ - DSpContext_GetFrontBuffer (dsp_context, &dsp_front_buffer); - SetRect (&rect, 0, 0, surface->w - 1, surface->h - 1); + DSpContext_GetFrontBuffer(dsp_context, &dsp_front_buffer); + SetRect(&rect, 0, 0, surface->w - 1, surface->h - 1); - GetPort ((GrafPtr *) & save_port); - SetPort ((GrafPtr) dsp_front_buffer); + GetPort((GrafPtr *) & save_port); + SetPort((GrafPtr) dsp_front_buffer); /* wait for retrace */ /* I have tried doing the swap in interrupt routine (VBL Proc) to do */ @@ -1315,46 +1310,46 @@ #endif #endif - CopyBits (GetPortBitMapForCopyBits (dsp_back_buffer), - GetPortBitMapForCopyBits (dsp_front_buffer), - &rect, &rect, srcCopy, NULL); + CopyBits(GetPortBitMapForCopyBits(dsp_back_buffer), + GetPortBitMapForCopyBits(dsp_front_buffer), + &rect, &rect, srcCopy, NULL); - SetPort ((GrafPtr) save_port); + SetPort((GrafPtr) save_port); } else { /* not really page flipping at all: DSp just blits the dirty rectangles from DSp_UpdateRects */ Boolean busy_flag; - DSpContext_SwapBuffers (dsp_context, NULL, &busy_flag); /* this waits for VBL */ - DSpContext_GetBackBuffer (dsp_context, kDSpBufferKind_Normal, - &dsp_back_buffer); - surface->pixels = GetPixBaseAddr (GetPortPixMap (dsp_back_buffer)); + DSpContext_SwapBuffers(dsp_context, NULL, &busy_flag); /* this waits for VBL */ + DSpContext_GetBackBuffer(dsp_context, kDSpBufferKind_Normal, + &dsp_back_buffer); + surface->pixels = GetPixBaseAddr(GetPortPixMap(dsp_back_buffer)); } return (0); } static int -DSp_LockHWSurface (_THIS, SDL_Surface * surface) +DSp_LockHWSurface(_THIS, SDL_Surface * surface) { - if (LockPixels (GetGWorldPixMap (surface->hwdata->offscreen))) + if (LockPixels(GetGWorldPixMap(surface->hwdata->offscreen))) return 0; else return -1; } static void -DSp_UnlockHWSurface (_THIS, SDL_Surface * surface) +DSp_UnlockHWSurface(_THIS, SDL_Surface * surface) { - UnlockPixels (GetGWorldPixMap (surface->hwdata->offscreen)); + UnlockPixels(GetGWorldPixMap(surface->hwdata->offscreen)); } static void -DSp_DirectUpdate (_THIS, int numrects, SDL_Rect * sdl_rects) +DSp_DirectUpdate(_THIS, int numrects, SDL_Rect * sdl_rects) { return; } static void -DSp_DSpUpdate (_THIS, int numrects, SDL_Rect * sdl_rects) +DSp_DSpUpdate(_THIS, int numrects, SDL_Rect * sdl_rects) { #if ! TARGET_API_MAC_OSX /* Unsupported DSp in here */ int i; @@ -1367,51 +1362,51 @@ rect.bottom = sdl_rects[i].h + sdl_rects[i].y; rect.right = sdl_rects[i].w + sdl_rects[i].x; - DSpContext_InvalBackBufferRect (dsp_context, &rect); + DSpContext_InvalBackBufferRect(dsp_context, &rect); } #endif } static int -DSp_CreatePalette (_THIS) +DSp_CreatePalette(_THIS) { /* Create our palette */ - SDL_CTab = (CTabHandle) NewHandle (sizeof (ColorSpec) * 256 + 8); + SDL_CTab = (CTabHandle) NewHandle(sizeof(ColorSpec) * 256 + 8); if (SDL_CTab == nil) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } - (**SDL_CTab).ctSeed = GetCTSeed (); + (**SDL_CTab).ctSeed = GetCTSeed(); (**SDL_CTab).ctFlags = 0; (**SDL_CTab).ctSize = 255; - CTabChanged (SDL_CTab); - SDL_CPal = NewPalette (256, SDL_CTab, pmExplicit + pmTolerant, 0); + CTabChanged(SDL_CTab); + SDL_CPal = NewPalette(256, SDL_CTab, pmExplicit + pmTolerant, 0); return 0; } static int -DSp_DestroyPalette (_THIS) +DSp_DestroyPalette(_THIS) { /* Free palette and restore original one */ if (SDL_CTab != nil) { - DisposeHandle ((Handle) SDL_CTab); + DisposeHandle((Handle) SDL_CTab); SDL_CTab = nil; } if (SDL_CPal != nil) { - DisposePalette (SDL_CPal); + DisposePalette(SDL_CPal); SDL_CPal = nil; } - RestoreDeviceClut (SDL_Display); + RestoreDeviceClut(SDL_Display); return (0); } static int -DSp_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +DSp_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { CTabHandle cTab; @@ -1433,41 +1428,41 @@ (**cTab).ctTable[j].rgb.blue = colors[i].b << 8 | colors[i].b; } - SetGDevice (SDL_Display); - SetEntries (0, (**cTab).ctSize, (ColorSpec *) & (**cTab).ctTable); + SetGDevice(SDL_Display); + SetEntries(0, (**cTab).ctSize, (ColorSpec *) & (**cTab).ctTable); return (1); } void -DSp_VideoQuit (_THIS) +DSp_VideoQuit(_THIS) { int i; /* Free current video mode */ - DSp_UnsetVideoMode (this, this->screen); + DSp_UnsetVideoMode(this, this->screen); /* Free Palette and restore original */ - DSp_DestroyPalette (this); + DSp_DestroyPalette(this); /* Free list of video modes */ if (SDL_modelist != NULL) { for (i = 0; SDL_modelist[i]; i++) { - SDL_free (SDL_modelist[i]); + SDL_free(SDL_modelist[i]); } - SDL_free (SDL_modelist); + SDL_free(SDL_modelist); SDL_modelist = NULL; } /* Unload DrawSprocket */ - DSpShutdown (); + DSpShutdown(); } #if SDL_VIDEO_OPENGL /* swap buffers with v-sync */ static void -DSp_GL_SwapBuffers (_THIS) +DSp_GL_SwapBuffers(_THIS) { #ifndef DSP_NO_SYNC_OPENGL @@ -1478,7 +1473,7 @@ while (old_count == retrace_count); #endif - aglSwapBuffers (glContext); + aglSwapBuffers(glContext); } #endif diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/macrom/SDL_romvideo.c --- a/src/video/macrom/SDL_romvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/macrom/SDL_romvideo.c Mon May 29 04:04:35 2006 +0000 @@ -53,20 +53,20 @@ #include "../maccommon/SDL_macevents_c.h" /* Initialization/Query functions */ -static int ROM_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **ROM_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *ROM_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int ROM_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void ROM_VideoQuit (_THIS); +static int ROM_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **ROM_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +static SDL_Surface *ROM_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +static int ROM_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void ROM_VideoQuit(_THIS); /* Hardware surface functions */ -static int ROM_AllocHWSurface (_THIS, SDL_Surface * surface); -static int ROM_LockHWSurface (_THIS, SDL_Surface * surface); -static void ROM_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void ROM_FreeHWSurface (_THIS, SDL_Surface * surface); +static int ROM_AllocHWSurface(_THIS, SDL_Surface * surface); +static int ROM_LockHWSurface(_THIS, SDL_Surface * surface); +static void ROM_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void ROM_FreeHWSurface(_THIS, SDL_Surface * surface); #if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */ /* Saved state for the menu bar */ @@ -90,27 +90,27 @@ /* ControlStrip inline glue for PowerPC */ static pascal Boolean -SBIsControlStripVisible (void) +SBIsControlStripVisible(void) { - static short procData[] = TWOWORDSTUB (0x7000, 0xAAF2); + static short procData[] = TWOWORDSTUB(0x7000, 0xAAF2); ProcInfoType procInfo = kD0DispatchedPascalStackBased - | RESULT_SIZE (SIZE_CODE (sizeof (Boolean))) - | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE (kFourByteCode); + | RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) + | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode); return ((Boolean) - CallUniversalProc ((UniversalProcPtr) procData, procInfo, 0x00)); + CallUniversalProc((UniversalProcPtr) procData, procInfo, 0x00)); } static pascal void -SBShowHideControlStrip (Boolean showIt) +SBShowHideControlStrip(Boolean showIt) { - static short procData[] = THREEWORDSTUB (0x303C, 0x0101, 0xAAF2); + static short procData[] = THREEWORDSTUB(0x303C, 0x0101, 0xAAF2); ProcInfoType procInfo = kD0DispatchedPascalStackBased - | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE (kFourByteCode) - | DISPATCHED_STACK_ROUTINE_PARAMETER (1, - SIZE_CODE (sizeof (Boolean))); + | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode) + | DISPATCHED_STACK_ROUTINE_PARAMETER(1, + SIZE_CODE(sizeof(Boolean))); - CallUniversalProc ((UniversalProcPtr) procData, procInfo, 0x01, showIt); + CallUniversalProc((UniversalProcPtr) procData, procInfo, 0x01, showIt); } #endif /* powerc */ #endif /* !TARGET_API_MAC_CARBON */ @@ -118,38 +118,38 @@ /* Macintosh toolbox driver bootstrap functions */ static int -ROM_Available (void) +ROM_Available(void) { return (1); } static void -ROM_DeleteDevice (SDL_VideoDevice * device) +ROM_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -ROM_CreateDevice (int devindex) +ROM_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = ROM_VideoInit; @@ -197,22 +197,22 @@ static int -ROM_VideoInit (_THIS, SDL_PixelFormat * vformat) +ROM_VideoInit(_THIS, SDL_PixelFormat * vformat) { long info; /* Check out some things about the system */ - Gestalt (gestaltQuickdrawVersion, &info); + Gestalt(gestaltQuickdrawVersion, &info); if (info == gestaltOriginalQD) { - SDL_SetError ("Color Quickdraw not available"); + SDL_SetError("Color Quickdraw not available"); return (-1); } /* Start ROMintosh events */ - Mac_InitEvents (this); + Mac_InitEvents(this); /* Get a handle to the main monitor */ - SDL_Display = GetMainDevice (); + SDL_Display = GetMainDevice(); /* Determine the current screen size */ this->info.current_w = (**SDL_Display).gdRect.right; @@ -231,21 +231,21 @@ } /* Create our palette */ - SDL_CTab = (CTabHandle) NewHandle (sizeof (ColorSpec) * 256 + 8); + SDL_CTab = (CTabHandle) NewHandle(sizeof(ColorSpec) * 256 + 8); if (SDL_CTab == nil) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } - (**SDL_CTab).ctSeed = GetCTSeed (); + (**SDL_CTab).ctSeed = GetCTSeed(); (**SDL_CTab).ctFlags = 0; (**SDL_CTab).ctSize = 255; - CTabChanged (SDL_CTab); - SDL_CPal = NewPalette (256, SDL_CTab, pmExplicit + pmTolerant, 0); + CTabChanged(SDL_CTab); + SDL_CPal = NewPalette(256, SDL_CTab, pmExplicit + pmTolerant, 0); /* Get a list of available fullscreen modes */ - SDL_modelist = (SDL_Rect **) SDL_malloc ((1 + 1) * sizeof (SDL_Rect *)); + SDL_modelist = (SDL_Rect **) SDL_malloc((1 + 1) * sizeof(SDL_Rect *)); if (SDL_modelist) { - SDL_modelist[0] = (SDL_Rect *) SDL_malloc (sizeof (SDL_Rect)); + SDL_modelist[0] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect)); if (SDL_modelist[0]) { SDL_modelist[0]->x = 0; SDL_modelist[0]->y = 0; @@ -263,7 +263,7 @@ } static SDL_Rect ** -ROM_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +ROM_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { if (this->screen->format->BitsPerPixel == format->BitsPerPixel) { if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { @@ -277,7 +277,7 @@ } static void -ROM_HideMenuBar (_THIS) +ROM_HideMenuBar(_THIS) { #if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */ RgnHandle drawRgn = nil; @@ -290,79 +290,79 @@ short height; EventRecord theEvent; - height = GetMBarHeight (); + height = GetMBarHeight(); if (height > 0) { - tempRgn = NewRgn (); - drawRgn = NewRgn (); - gSaveGrayRgn = NewRgn (); + tempRgn = NewRgn(); + drawRgn = NewRgn(); + gSaveGrayRgn = NewRgn(); if (!tempRgn || !drawRgn || !gSaveGrayRgn) { goto CLEANUP; } - grayRgn = GetGrayRgn (); /* No need to check for this */ + grayRgn = GetGrayRgn(); /* No need to check for this */ - GetPort (&savePort); + GetPort(&savePort); /* Hide the control strip if it's present, and record its previous position into the dirty region for redrawing. This isn't necessary, but may help catch stray bits. */ - CopyRgn (grayRgn, tempRgn); - if (!Gestalt (gestaltControlStripAttr, &response) && + CopyRgn(grayRgn, tempRgn); + if (!Gestalt(gestaltControlStripAttr, &response) && (response & (1L << gestaltControlStripExists))) { - gSaveCSVis = SBIsControlStripVisible (); + gSaveCSVis = SBIsControlStripVisible(); if (gSaveCSVis) - SBShowHideControlStrip (false); + SBShowHideControlStrip(false); } - DiffRgn (grayRgn, tempRgn, drawRgn); + DiffRgn(grayRgn, tempRgn, drawRgn); /* Save the gray region once the control strip is hidden */ - CopyRgn (grayRgn, gSaveGrayRgn); + CopyRgn(grayRgn, gSaveGrayRgn); /* Change the menu height in lowmem */ gSaveMenuBar = height; - LMSetMBarHeight (0); + LMSetMBarHeight(0); /* Walk the monitor rectangles, and combine any pieces that aren't in GrayRgn: menubar, round corners, fake floaters. */ - for (gd = GetDeviceList (); gd; gd = GetNextDevice (gd)) { - if (!TestDeviceAttribute (gd, screenDevice)) + for (gd = GetDeviceList(); gd; gd = GetNextDevice(gd)) { + if (!TestDeviceAttribute(gd, screenDevice)) continue; - if (!TestDeviceAttribute (gd, screenActive)) + if (!TestDeviceAttribute(gd, screenActive)) continue; - RectRgn (tempRgn, &(*gd)->gdRect); /* Get the whole screen */ - DiffRgn (tempRgn, grayRgn, tempRgn); /* Subtract out GrayRgn */ - UnionRgn (tempRgn, drawRgn, drawRgn); /* Combine all the bits */ + RectRgn(tempRgn, &(*gd)->gdRect); /* Get the whole screen */ + DiffRgn(tempRgn, grayRgn, tempRgn); /* Subtract out GrayRgn */ + UnionRgn(tempRgn, drawRgn, drawRgn); /* Combine all the bits */ } /* Add the bits into the GrayRgn */ - UnionRgn (drawRgn, grayRgn, grayRgn); + UnionRgn(drawRgn, grayRgn, grayRgn); /* Modify the vis regions of exposed windows */ - window = (FrontWindow ())? FrontWindow () : (WindowPtr) - 1L; - PaintBehind (window, drawRgn); - CalcVisBehind (window, drawRgn); + window = (FrontWindow())? FrontWindow() : (WindowPtr) - 1L; + PaintBehind(window, drawRgn); + CalcVisBehind(window, drawRgn); - SetPort (savePort); + SetPort(savePort); /* Yield time so that floaters can catch up */ - EventAvail (0, &theEvent); - EventAvail (0, &theEvent); - EventAvail (0, &theEvent); - EventAvail (0, &theEvent); + EventAvail(0, &theEvent); + EventAvail(0, &theEvent); + EventAvail(0, &theEvent); + EventAvail(0, &theEvent); } CLEANUP: if (tempRgn) - DisposeRgn (tempRgn); + DisposeRgn(tempRgn); if (drawRgn) - DisposeRgn (drawRgn); + DisposeRgn(drawRgn); #endif /* !TARGET_API_MAC_CARBON */ } static void -ROM_ShowMenuBar (_THIS) +ROM_ShowMenuBar(_THIS) { #if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */ RgnHandle drawRgn = nil; @@ -379,112 +379,112 @@ RGBColor saveRGB; RGBColor blackRGB = { 0, 0, 0 }; - height = GetMBarHeight (); + height = GetMBarHeight(); if ((height <= 0) && (gSaveMenuBar > 0)) { - drawRgn = NewRgn (); - menuRgn = NewRgn (); - tempRgn = NewRgn (); + drawRgn = NewRgn(); + menuRgn = NewRgn(); + tempRgn = NewRgn(); if (!tempRgn || !drawRgn || !gSaveGrayRgn) { goto CLEANUP; } - grayRgn = GetGrayRgn (); /* No need to check for this */ + grayRgn = GetGrayRgn(); /* No need to check for this */ - GetPort (&savePort); - GetWMgrPort (&wMgrPort); + GetPort(&savePort); + GetWMgrPort(&wMgrPort); /* Set the height properly */ - LMSetMBarHeight (gSaveMenuBar); + LMSetMBarHeight(gSaveMenuBar); /* Restore the old GrayRgn: rounded corners, etc, but not the menubar -- subtract that out first! */ if (gSaveGrayRgn) { - menuRect = (*GetMainDevice ())->gdRect; + menuRect = (*GetMainDevice())->gdRect; menuRect.bottom = menuRect.top + gSaveMenuBar; - RectRgn (menuRgn, &menuRect); + RectRgn(menuRgn, &menuRect); - DiffRgn (grayRgn, gSaveGrayRgn, drawRgn); /* What do we inval? */ - DiffRgn (drawRgn, menuRgn, drawRgn); /* Clip out the menu */ + DiffRgn(grayRgn, gSaveGrayRgn, drawRgn); /* What do we inval? */ + DiffRgn(drawRgn, menuRgn, drawRgn); /* Clip out the menu */ /* Now redraw the corners and other bits black */ - SetPort (wMgrPort); - GetClip (tempRgn); - SetClip (drawRgn); - GetForeColor (&saveRGB); - RGBForeColor (&blackRGB); - PaintRgn (drawRgn); - RGBForeColor (&saveRGB); - SetClip (tempRgn); - SetPort (savePort); + SetPort(wMgrPort); + GetClip(tempRgn); + SetClip(drawRgn); + GetForeColor(&saveRGB); + RGBForeColor(&blackRGB); + PaintRgn(drawRgn); + RGBForeColor(&saveRGB); + SetClip(tempRgn); + SetPort(savePort); - UnionRgn (drawRgn, menuRgn, drawRgn); /* Put back the menu */ + UnionRgn(drawRgn, menuRgn, drawRgn); /* Put back the menu */ /* Now actually restore the GrayRgn */ - CopyRgn (gSaveGrayRgn, grayRgn); - DisposeRgn (gSaveGrayRgn); + CopyRgn(gSaveGrayRgn, grayRgn); + DisposeRgn(gSaveGrayRgn); gSaveGrayRgn = nil; } /* Modify the vis regions of exposed windows and draw menubar */ - window = (FrontWindow ())? FrontWindow () : (WindowPtr) - 1L; - PaintBehind (window, drawRgn); - CalcVisBehind (window, drawRgn); - DrawMenuBar (); + window = (FrontWindow())? FrontWindow() : (WindowPtr) - 1L; + PaintBehind(window, drawRgn); + CalcVisBehind(window, drawRgn); + DrawMenuBar(); - SetPort (savePort); + SetPort(savePort); gSaveMenuBar = 0; /* Now show the control strip if it's present */ - if (!Gestalt (gestaltControlStripAttr, &response) && + if (!Gestalt(gestaltControlStripAttr, &response) && (response & (1L << gestaltControlStripExists))) { - if (gSaveCSVis && !SBIsControlStripVisible ()) - SBShowHideControlStrip (true); + if (gSaveCSVis && !SBIsControlStripVisible()) + SBShowHideControlStrip(true); gSaveCSVis = true; } /* Yield time so that floaters can catch up */ - EventAvail (0, &theEvent); - EventAvail (0, &theEvent); - EventAvail (0, &theEvent); - EventAvail (0, &theEvent); + EventAvail(0, &theEvent); + EventAvail(0, &theEvent); + EventAvail(0, &theEvent); + EventAvail(0, &theEvent); } CLEANUP: if (drawRgn) - DisposeRgn (drawRgn); + DisposeRgn(drawRgn); if (menuRgn) - DisposeRgn (menuRgn); + DisposeRgn(menuRgn); if (tempRgn) - DisposeRgn (tempRgn); + DisposeRgn(tempRgn); #endif /* !TARGET_API_MAC_CARBON */ } /* Various screen update functions available */ -static void ROM_DirectUpdate (_THIS, int numrects, SDL_Rect * rects); -static void ROM_WindowUpdate (_THIS, int numrects, SDL_Rect * rects); +static void ROM_DirectUpdate(_THIS, int numrects, SDL_Rect * rects); +static void ROM_WindowUpdate(_THIS, int numrects, SDL_Rect * rects); static void -ROM_UnsetVideoMode (_THIS, SDL_Surface * current) +ROM_UnsetVideoMode(_THIS, SDL_Surface * current) { /* Free the current window, if any */ if (SDL_Window != nil) { GWorldPtr memworld; /* Handle OpenGL support */ - Mac_GL_Quit (this); + Mac_GL_Quit(this); - memworld = (GWorldPtr) GetWRefCon (SDL_Window); + memworld = (GWorldPtr) GetWRefCon(SDL_Window); if (memworld != nil) { - UnlockPixels (GetGWorldPixMap (memworld)); - DisposeGWorld (memworld); + UnlockPixels(GetGWorldPixMap(memworld)); + DisposeGWorld(memworld); } if ((current->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { #if USE_QUICKTIME - EndFullScreen (fullscreen_ctx, nil); + EndFullScreen(fullscreen_ctx, nil); SDL_Window = nil; #else - ROM_ShowMenuBar (this); + ROM_ShowMenuBar(this); #endif } } @@ -493,8 +493,8 @@ } static SDL_Surface * -ROM_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +ROM_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { Rect wrect, orect; #if TARGET_API_MAC_CARBON @@ -502,26 +502,26 @@ #endif /* Free any previous video mode */ - ROM_UnsetVideoMode (this, current); + ROM_UnsetVideoMode(this, current); /* Create the ROM window and SDL video surface */ current->flags = 0; /* Clear flags */ current->w = width; current->h = height; - SetRect (&wrect, 0, 0, width, height); + SetRect(&wrect, 0, 0, width, height); if (SDL_Window) { /* If we recreate the window, don't move it around */ #if TARGET_API_MAC_CARBON - orect = *GetWindowPortBounds (SDL_Window, &tmprect); + orect = *GetWindowPortBounds(SDL_Window, &tmprect); #else orect = SDL_Window->portRect; #endif - OffsetRect (&wrect, orect.left, orect.top); + OffsetRect(&wrect, orect.left, orect.top); } else { /* Center the window the first time we show it */ - OffsetRect (&wrect, - (SDL_modelist[0]->w - width) / 2, - (SDL_modelist[0]->h - height) / 2); + OffsetRect(&wrect, + (SDL_modelist[0]->w - width) / 2, + (SDL_modelist[0]->h - height) / 2); } #if defined(__MACOSX__) && !USE_QUICKTIME @@ -532,14 +532,14 @@ /* Create the fullscreen window and use screen bits */ current->flags |= SDL_HWSURFACE | SDL_FULLSCREEN; if (SDL_Window) { - DisposeWindow (SDL_Window); + DisposeWindow(SDL_Window); } #if USE_QUICKTIME - BeginFullScreen (&fullscreen_ctx, nil, 0, 0, &SDL_Window, nil, 0); + BeginFullScreen(&fullscreen_ctx, nil, 0, 0, &SDL_Window, nil, 0); #else - SDL_Window = NewCWindow (nil, &wrect, "\p", true, plainDBox, - (WindowPtr) - 1, false, 0); - ROM_HideMenuBar (this); + SDL_Window = NewCWindow(nil, &wrect, "\p", true, plainDBox, + (WindowPtr) - 1, false, 0); + ROM_HideMenuBar(this); #endif current->pitch = (**(**SDL_Display).gdPMap).rowBytes & 0x3FFF; current->pixels = (**(**SDL_Display).gdPMap).baseAddr; @@ -561,51 +561,51 @@ /* Resize existing window, if necessary */ if (((orect.right - orect.left) != width) || ((orect.bottom - orect.top) != height)) { - SizeWindow (SDL_Window, width, height, false); + SizeWindow(SDL_Window, width, height, false); } } else { /* Recreate the window in the new style */ if (SDL_Window) { - DisposeWindow (SDL_Window); + DisposeWindow(SDL_Window); } - SDL_Window = NewCWindow (nil, &wrect, "\p", true, - style, (WindowPtr) - 1, true, 0); + SDL_Window = NewCWindow(nil, &wrect, "\p", true, + style, (WindowPtr) - 1, true, 0); /* Set the window title, if any */ { char *title; - SDL_WM_GetCaption (&title, NULL); + SDL_WM_GetCaption(&title, NULL); if (title) { - Mac_SetCaption (this, title, NULL); + Mac_SetCaption(this, title, NULL); } } } current_style = style; - SetPalette (SDL_Window, SDL_CPal, false); - ActivatePalette (SDL_Window); - if (NewGWorld (&memworld, 0, + SetPalette(SDL_Window, SDL_CPal, false); + ActivatePalette(SDL_Window); + if (NewGWorld(&memworld, 0, #if TARGET_API_MAC_CARBON - GetWindowPortBounds (SDL_Window, &tmprect), + GetWindowPortBounds(SDL_Window, &tmprect), #else - &SDL_Window->portRect, + &SDL_Window->portRect, #endif - SDL_CTab, nil, 0) != noErr) { - SDL_SetError ("NewGWorld() failed"); + SDL_CTab, nil, 0) != noErr) { + SDL_SetError("NewGWorld() failed"); return (NULL); } - SetWRefCon (SDL_Window, (long) memworld); - pixmap = GetGWorldPixMap (memworld); - LockPixels (pixmap); + SetWRefCon(SDL_Window, (long) memworld); + pixmap = GetGWorldPixMap(memworld); + LockPixels(pixmap); current->pitch = (**pixmap).rowBytes & 0x3FFF; - current->pixels = GetPixBaseAddr (pixmap); + current->pixels = GetPixBaseAddr(pixmap); this->UpdateRects = ROM_WindowUpdate; } - SetPortWindowPort (SDL_Window); - SelectWindow (SDL_Window); + SetPortWindowPort(SDL_Window); + SelectWindow(SDL_Window); /* Handle OpenGL support */ if (flags & SDL_INTERNALOPENGL) { - if (Mac_GL_Init (this) == 0) { + if (Mac_GL_Init(this) == 0) { current->flags |= SDL_INTERNALOPENGL; } else { current = NULL; @@ -621,35 +621,35 @@ /* We don't actually allow hardware surfaces other than the main one */ static int -ROM_AllocHWSurface (_THIS, SDL_Surface * surface) +ROM_AllocHWSurface(_THIS, SDL_Surface * surface) { return (-1); } static void -ROM_FreeHWSurface (_THIS, SDL_Surface * surface) +ROM_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } static int -ROM_LockHWSurface (_THIS, SDL_Surface * surface) +ROM_LockHWSurface(_THIS, SDL_Surface * surface) { return (0); } static void -ROM_UnlockHWSurface (_THIS, SDL_Surface * surface) +ROM_UnlockHWSurface(_THIS, SDL_Surface * surface) { return; } static void -ROM_DirectUpdate (_THIS, int numrects, SDL_Rect * rects) +ROM_DirectUpdate(_THIS, int numrects, SDL_Rect * rects) { /* The application is already updating the visible video memory */ return; } static void -ROM_WindowUpdate (_THIS, int numrects, SDL_Rect * rects) +ROM_WindowUpdate(_THIS, int numrects, SDL_Rect * rects) { GWorldPtr memworld; GrafPtr saveport; @@ -660,17 +660,17 @@ Rect update; /* Copy from the offscreen GWorld to the window port */ - GetPort (&saveport); - SetPortWindowPort (SDL_Window); - thePort = GetWindowPort (SDL_Window); - memworld = (GWorldPtr) GetWRefCon (SDL_Window); + GetPort(&saveport); + SetPortWindowPort(SDL_Window); + thePort = GetWindowPort(SDL_Window); + memworld = (GWorldPtr) GetWRefCon(SDL_Window); #if TARGET_API_MAC_CARBON && ACCESSOR_CALLS_ARE_FUNCTIONS - memBits = GetPortBitMapForCopyBits ((CGrafPtr) memworld); + memBits = GetPortBitMapForCopyBits((CGrafPtr) memworld); #else memBits = &((GrafPtr) memworld)->portBits; #endif #if TARGET_API_MAC_CARBON && ACCESSOR_CALLS_ARE_FUNCTIONS - winBits = GetPortBitMapForCopyBits (thePort); + winBits = GetPortBitMapForCopyBits(thePort); #else winBits = &SDL_Window->portBits; #endif @@ -679,18 +679,18 @@ update.right = rects[i].x + rects[i].w; update.top = rects[i].y; update.bottom = rects[i].y + rects[i].h; - CopyBits (memBits, winBits, &update, &update, srcCopy, nil); + CopyBits(memBits, winBits, &update, &update, srcCopy, nil); } #if TARGET_API_MAC_CARBON - if (QDIsPortBuffered (thePort)) { - QDFlushPortBuffer (thePort, NULL); + if (QDIsPortBuffered(thePort)) { + QDFlushPortBuffer(thePort, NULL); } #endif - SetPort (saveport); + SetPort(saveport); } static int -ROM_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +ROM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { CTabHandle cTab; int i; @@ -718,43 +718,43 @@ // if ( (this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { GDevice **odisplay; - odisplay = GetGDevice (); - SetGDevice (SDL_Display); - SetEntries (0, (**cTab).ctSize, (ColorSpec *) & (**cTab).ctTable); - SetGDevice (odisplay); + odisplay = GetGDevice(); + SetGDevice(SDL_Display); + SetEntries(0, (**cTab).ctSize, (ColorSpec *) & (**cTab).ctTable); + SetGDevice(odisplay); } return (1); } void -ROM_VideoQuit (_THIS) +ROM_VideoQuit(_THIS) { int i; /* Free current video mode */ - ROM_UnsetVideoMode (this, this->screen); + ROM_UnsetVideoMode(this, this->screen); if (SDL_Window) { - DisposeWindow (SDL_Window); + DisposeWindow(SDL_Window); SDL_Window = nil; } /* Free palette and restore original one */ if (SDL_CTab != nil) { - DisposeHandle ((Handle) SDL_CTab); + DisposeHandle((Handle) SDL_CTab); SDL_CTab = nil; } if (SDL_CPal != nil) { - DisposePalette (SDL_CPal); + DisposePalette(SDL_CPal); SDL_CPal = nil; } - RestoreDeviceClut (GetMainDevice ()); + RestoreDeviceClut(GetMainDevice()); /* Free list of video modes */ if (SDL_modelist != NULL) { for (i = 0; SDL_modelist[i]; ++i) { - SDL_free (SDL_modelist[i]); + SDL_free(SDL_modelist[i]); } - SDL_free (SDL_modelist); + SDL_free(SDL_modelist); SDL_modelist = NULL; } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/mmx.h --- a/src/video/mmx.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/mmx.h Mon May 29 04:04:35 2006 +0000 @@ -54,14 +54,14 @@ char b[8]; /* 8 Byte (8-bit) values */ unsigned char ub[8]; /* 8 Unsigned Byte */ float s[2]; /* Single-precision (32-bit) value */ -} __attribute__ ((aligned (8))) mmx_t; /* On an 8-byte (64-bit) boundary */ +} __attribute__ ((aligned(8))) mmx_t; /* On an 8-byte (64-bit) boundary */ #if 0 /* Function to test if multimedia instructions are supported... */ inline extern int -mm_support (void) +mm_support(void) { /* Returns 1 if MMX instructions are supported, 3 if Cyrix MMX and Extended MMX instructions are supported @@ -70,85 +70,85 @@ */ register int rval = 0; - __asm__ __volatile__ ( - /* See if CPUID instruction is supported ... */ - /* ... Get copies of EFLAGS into eax and ecx */ - "pushf\n\t" - "popl %%eax\n\t" "movl %%eax, %%ecx\n\t" - /* ... Toggle the ID bit in one copy and store */ - /* to the EFLAGS reg */ - "xorl $0x200000, %%eax\n\t" - "push %%eax\n\t" "popf\n\t" - /* ... Get the (hopefully modified) EFLAGS */ - "pushf\n\t" "popl %%eax\n\t" - /* ... Compare and test result */ - "xorl %%eax, %%ecx\n\t" "testl $0x200000, %%ecx\n\t" "jz NotSupported1\n\t" /* CPUID not supported */ - /* Get standard CPUID information, and - go to a specific vendor section */ - "movl $0, %%eax\n\t" "cpuid\n\t" - /* Check for Intel */ - "cmpl $0x756e6547, %%ebx\n\t" - "jne TryAMD\n\t" - "cmpl $0x49656e69, %%edx\n\t" - "jne TryAMD\n\t" - "cmpl $0x6c65746e, %%ecx\n" - "jne TryAMD\n\t" "jmp Intel\n\t" - /* Check for AMD */ - "\nTryAMD:\n\t" - "cmpl $0x68747541, %%ebx\n\t" - "jne TryCyrix\n\t" - "cmpl $0x69746e65, %%edx\n\t" - "jne TryCyrix\n\t" - "cmpl $0x444d4163, %%ecx\n" - "jne TryCyrix\n\t" "jmp AMD\n\t" - /* Check for Cyrix */ - "\nTryCyrix:\n\t" - "cmpl $0x69727943, %%ebx\n\t" - "jne NotSupported2\n\t" - "cmpl $0x736e4978, %%edx\n\t" - "jne NotSupported3\n\t" - "cmpl $0x64616574, %%ecx\n\t" - "jne NotSupported4\n\t" - /* Drop through to Cyrix... */ - /* Cyrix Section */ - /* See if extended CPUID level 80000001 is supported */ - /* The value of CPUID/80000001 for the 6x86MX is undefined - according to the Cyrix CPU Detection Guide (Preliminary - Rev. 1.01 table 1), so we'll check the value of eax for - CPUID/0 to see if standard CPUID level 2 is supported. - According to the table, the only CPU which supports level - 2 is also the only one which supports extended CPUID levels. - */ - "cmpl $0x2, %%eax\n\t" "jne MMXtest\n\t" /* Use standard CPUID instead */ - /* Extended CPUID supported (in theory), so get extended - features */ - "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%eax\n\t" /* Test for MMX */ - "jz NotSupported5\n\t" /* MMX not supported */ - "testl $0x01000000, %%eax\n\t" /* Test for Ext'd MMX */ - "jnz EMMXSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */ - "jmp Return\n\n" "EMMXSupported:\n\t" "movl $3, %0:\n\n\t" /* EMMX and MMX Supported */ - "jmp Return\n\t" - /* AMD Section */ - "AMD:\n\t" - /* See if extended CPUID is supported */ - "movl $0x80000000, %%eax\n\t" "cpuid\n\t" "cmpl $0x80000000, %%eax\n\t" "jl MMXtest\n\t" /* Use standard CPUID instead */ - /* Extended CPUID supported, so get extended features */ - "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */ - "jz NotSupported6\n\t" /* MMX not supported */ - "testl $0x80000000, %%edx\n\t" /* Test for 3DNow! */ - "jnz ThreeDNowSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */ - "jmp Return\n\n" "ThreeDNowSupported:\n\t" "movl $5, %0:\n\n\t" /* 3DNow! and MMX Supported */ - "jmp Return\n\t" - /* Intel Section */ - "Intel:\n\t" - /* Check for MMX */ - "MMXtest:\n\t" "movl $1, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */ - "jz NotSupported7\n\t" /* MMX Not supported */ - "movl $1, %0:\n\n\t" /* MMX Supported */ - "jmp Return\n\t" - /* Nothing supported */ - "\nNotSupported1:\n\t" "#movl $101, %0:\n\n\t" "\nNotSupported2:\n\t" "#movl $102, %0:\n\n\t" "\nNotSupported3:\n\t" "#movl $103, %0:\n\n\t" "\nNotSupported4:\n\t" "#movl $104, %0:\n\n\t" "\nNotSupported5:\n\t" "#movl $105, %0:\n\n\t" "\nNotSupported6:\n\t" "#movl $106, %0:\n\n\t" "\nNotSupported7:\n\t" "#movl $107, %0:\n\n\t" "movl $0, %0:\n\n\t" "Return:\n\t":"=a" (rval): /* no input */ - :"eax", "ebx", "ecx", "edx"); + __asm__ __volatile__( + /* See if CPUID instruction is supported ... */ + /* ... Get copies of EFLAGS into eax and ecx */ + "pushf\n\t" + "popl %%eax\n\t" "movl %%eax, %%ecx\n\t" + /* ... Toggle the ID bit in one copy and store */ + /* to the EFLAGS reg */ + "xorl $0x200000, %%eax\n\t" + "push %%eax\n\t" "popf\n\t" + /* ... Get the (hopefully modified) EFLAGS */ + "pushf\n\t" "popl %%eax\n\t" + /* ... Compare and test result */ + "xorl %%eax, %%ecx\n\t" "testl $0x200000, %%ecx\n\t" "jz NotSupported1\n\t" /* CPUID not supported */ + /* Get standard CPUID information, and + go to a specific vendor section */ + "movl $0, %%eax\n\t" "cpuid\n\t" + /* Check for Intel */ + "cmpl $0x756e6547, %%ebx\n\t" + "jne TryAMD\n\t" + "cmpl $0x49656e69, %%edx\n\t" + "jne TryAMD\n\t" + "cmpl $0x6c65746e, %%ecx\n" + "jne TryAMD\n\t" "jmp Intel\n\t" + /* Check for AMD */ + "\nTryAMD:\n\t" + "cmpl $0x68747541, %%ebx\n\t" + "jne TryCyrix\n\t" + "cmpl $0x69746e65, %%edx\n\t" + "jne TryCyrix\n\t" + "cmpl $0x444d4163, %%ecx\n" + "jne TryCyrix\n\t" "jmp AMD\n\t" + /* Check for Cyrix */ + "\nTryCyrix:\n\t" + "cmpl $0x69727943, %%ebx\n\t" + "jne NotSupported2\n\t" + "cmpl $0x736e4978, %%edx\n\t" + "jne NotSupported3\n\t" + "cmpl $0x64616574, %%ecx\n\t" + "jne NotSupported4\n\t" + /* Drop through to Cyrix... */ + /* Cyrix Section */ + /* See if extended CPUID level 80000001 is supported */ + /* The value of CPUID/80000001 for the 6x86MX is undefined + according to the Cyrix CPU Detection Guide (Preliminary + Rev. 1.01 table 1), so we'll check the value of eax for + CPUID/0 to see if standard CPUID level 2 is supported. + According to the table, the only CPU which supports level + 2 is also the only one which supports extended CPUID levels. + */ + "cmpl $0x2, %%eax\n\t" "jne MMXtest\n\t" /* Use standard CPUID instead */ + /* Extended CPUID supported (in theory), so get extended + features */ + "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%eax\n\t" /* Test for MMX */ + "jz NotSupported5\n\t" /* MMX not supported */ + "testl $0x01000000, %%eax\n\t" /* Test for Ext'd MMX */ + "jnz EMMXSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */ + "jmp Return\n\n" "EMMXSupported:\n\t" "movl $3, %0:\n\n\t" /* EMMX and MMX Supported */ + "jmp Return\n\t" + /* AMD Section */ + "AMD:\n\t" + /* See if extended CPUID is supported */ + "movl $0x80000000, %%eax\n\t" "cpuid\n\t" "cmpl $0x80000000, %%eax\n\t" "jl MMXtest\n\t" /* Use standard CPUID instead */ + /* Extended CPUID supported, so get extended features */ + "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */ + "jz NotSupported6\n\t" /* MMX not supported */ + "testl $0x80000000, %%edx\n\t" /* Test for 3DNow! */ + "jnz ThreeDNowSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */ + "jmp Return\n\n" "ThreeDNowSupported:\n\t" "movl $5, %0:\n\n\t" /* 3DNow! and MMX Supported */ + "jmp Return\n\t" + /* Intel Section */ + "Intel:\n\t" + /* Check for MMX */ + "MMXtest:\n\t" "movl $1, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */ + "jz NotSupported7\n\t" /* MMX Not supported */ + "movl $1, %0:\n\n\t" /* MMX Supported */ + "jmp Return\n\t" + /* Nothing supported */ + "\nNotSupported1:\n\t" "#movl $101, %0:\n\n\t" "\nNotSupported2:\n\t" "#movl $102, %0:\n\n\t" "\nNotSupported3:\n\t" "#movl $103, %0:\n\n\t" "\nNotSupported4:\n\t" "#movl $104, %0:\n\n\t" "\nNotSupported5:\n\t" "#movl $105, %0:\n\n\t" "\nNotSupported6:\n\t" "#movl $106, %0:\n\n\t" "\nNotSupported7:\n\t" "#movl $107, %0:\n\n\t" "movl $0, %0:\n\n\t" "Return:\n\t":"=a"(rval): /* no input */ + :"eax", "ebx", "ecx", "edx"); /* Return */ return (rval); @@ -157,10 +157,10 @@ /* Function to test if mmx instructions are supported... */ inline extern int -mmx_ok (void) +mmx_ok(void) { /* Returns 1 if MMX instructions are supported, 0 otherwise */ - return (mm_support () & 0x1); + return (mm_support() & 0x1); } #endif diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/nanox/SDL_nxevents.c --- a/src/video/nanox/SDL_nxevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/nanox/SDL_nxevents.c Mon May 29 04:04:35 2006 +0000 @@ -36,14 +36,14 @@ static SDLKey NX_NONASCII_keymap[MWKEY_LAST + 1]; void -NX_InitOSKeymap (_THIS) +NX_InitOSKeymap(_THIS) { int i; - Dprintf ("enter NX_InitOSKeymap\n"); + Dprintf("enter NX_InitOSKeymap\n"); // Map the nanox scancodes to SDL keysyms - for (i = 0; i < SDL_arraysize (NX_NONASCII_keymap); ++i) + for (i = 0; i < SDL_arraysize(NX_NONASCII_keymap); ++i) NX_NONASCII_keymap[i] = SDLK_UNKNOWN; NX_NONASCII_keymap[MWKEY_LEFT & 0xFF] = SDLK_LEFT; @@ -107,15 +107,15 @@ NX_NONASCII_keymap[MWKEY_BREAK & 0xFF] = SDLK_BREAK; NX_NONASCII_keymap[MWKEY_MENU & 0xFF] = SDLK_MENU; - Dprintf ("leave NX_InitOSKeymap\n"); + Dprintf("leave NX_InitOSKeymap\n"); } SDL_keysym * -NX_TranslateKey (GR_EVENT_KEYSTROKE * keystroke, SDL_keysym * keysym) +NX_TranslateKey(GR_EVENT_KEYSTROKE * keystroke, SDL_keysym * keysym) { GR_KEY ch = keystroke->ch; - Dprintf ("enter NX_TranslateKey\n"); + Dprintf("enter NX_TranslateKey\n"); keysym->scancode = keystroke->scancode; keysym->sym = SDLK_UNKNOWN; @@ -159,12 +159,12 @@ keysym->unicode = ch; - Dprintf ("leave NX_TranslateKey\n"); + Dprintf("leave NX_TranslateKey\n"); return keysym; } static int -check_boundary (_THIS, int x, int y) +check_boundary(_THIS, int x, int y) { if (x < OffsetX || y < OffsetY || x > OffsetX + this->screen->w || y > OffsetY + this->screen->h) @@ -174,60 +174,60 @@ } void -NX_PumpEvents (_THIS) +NX_PumpEvents(_THIS) { GR_EVENT event; static GR_BUTTON last_button_down = 0; - GrCheckNextEvent (&event); + GrCheckNextEvent(&event); while (event.type != GR_EVENT_TYPE_NONE) { // dispatch event switch (event.type) { case GR_EVENT_TYPE_MOUSE_ENTER: { - Dprintf ("mouse enter\n"); - SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); + Dprintf("mouse enter\n"); + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); break; } case GR_EVENT_TYPE_MOUSE_EXIT: { - Dprintf ("mouse exit\n"); - SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); + Dprintf("mouse exit\n"); + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); break; } case GR_EVENT_TYPE_FOCUS_IN: { - Dprintf ("focus in\n"); - SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS); + Dprintf("focus in\n"); + SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); break; } case GR_EVENT_TYPE_FOCUS_OUT: { - Dprintf ("focus out\n"); - SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS); + Dprintf("focus out\n"); + SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); break; } case GR_EVENT_TYPE_MOUSE_MOTION: { - Dprintf ("mouse motion\n"); + Dprintf("mouse motion\n"); if (SDL_VideoSurface) { if (currently_fullscreen) { if (check_boundary (this, event.button.x, event.button.y)) { - SDL_PrivateMouseMotion (0, 0, - event.button.x - - OffsetX, - event.button.y - OffsetY); + SDL_PrivateMouseMotion(0, 0, + event.button.x - + OffsetX, + event.button.y - OffsetY); } } else { - SDL_PrivateMouseMotion (0, 0, event.button.x, - event.button.y); + SDL_PrivateMouseMotion(0, 0, event.button.x, + event.button.y); } } break; @@ -237,7 +237,7 @@ { int button = event.button.buttons; - Dprintf ("button down\n"); + Dprintf("button down\n"); switch (button) { case MWBUTTON_L: @@ -255,15 +255,15 @@ last_button_down = button; if (currently_fullscreen) { - if (check_boundary (this, event.button.x, event.button.y)) { - SDL_PrivateMouseButton (SDL_PRESSED, button, - event.button.x - - OffsetX, - event.button.y - OffsetY); + if (check_boundary(this, event.button.x, event.button.y)) { + SDL_PrivateMouseButton(SDL_PRESSED, button, + event.button.x - + OffsetX, + event.button.y - OffsetY); } } else { - SDL_PrivateMouseButton (SDL_PRESSED, button, - event.button.x, event.button.y); + SDL_PrivateMouseButton(SDL_PRESSED, button, + event.button.x, event.button.y); } break; } @@ -271,20 +271,20 @@ // do not konw which button is released case GR_EVENT_TYPE_BUTTON_UP: { - Dprintf ("button up\n"); + Dprintf("button up\n"); if (currently_fullscreen) { - if (check_boundary (this, event.button.x, event.button.y)) { - SDL_PrivateMouseButton (SDL_RELEASED, - last_button_down, - event.button.x - - OffsetX, - event.button.y - OffsetY); + if (check_boundary(this, event.button.x, event.button.y)) { + SDL_PrivateMouseButton(SDL_RELEASED, + last_button_down, + event.button.x - + OffsetX, + event.button.y - OffsetY); } } else { - SDL_PrivateMouseButton (SDL_RELEASED, - last_button_down, - event.button.x, event.button.y); + SDL_PrivateMouseButton(SDL_RELEASED, + last_button_down, + event.button.x, event.button.y); } last_button_down = 0; break; @@ -294,10 +294,10 @@ { SDL_keysym keysym; - Dprintf ("key down\n"); - SDL_PrivateKeyboard (SDL_PRESSED, - NX_TranslateKey (&event.keystroke, - &keysym)); + Dprintf("key down\n"); + SDL_PrivateKeyboard(SDL_PRESSED, + NX_TranslateKey(&event.keystroke, + &keysym)); break; } @@ -305,25 +305,25 @@ { SDL_keysym keysym; - Dprintf ("key up\n"); - SDL_PrivateKeyboard (SDL_RELEASED, - NX_TranslateKey (&event.keystroke, - &keysym)); + Dprintf("key up\n"); + SDL_PrivateKeyboard(SDL_RELEASED, + NX_TranslateKey(&event.keystroke, + &keysym)); break; } case GR_EVENT_TYPE_CLOSE_REQ: { - Dprintf ("close require\n"); - SDL_PrivateQuit (); + Dprintf("close require\n"); + SDL_PrivateQuit(); break; } case GR_EVENT_TYPE_EXPOSURE: { - Dprintf ("event_type_exposure\n"); + Dprintf("event_type_exposure\n"); if (SDL_VideoSurface) { - NX_RefreshDisplay (this); //, & event.exposure) ; + NX_RefreshDisplay(this); //, & event.exposure) ; } break; } @@ -333,14 +333,14 @@ switch (event.update.utype) { case GR_UPDATE_MAP: { - Dprintf ("GR_UPDATE_MAP\n"); + Dprintf("GR_UPDATE_MAP\n"); // If we're not active, make ourselves active - if (!(SDL_GetAppState () & SDL_APPACTIVE)) { + if (!(SDL_GetAppState() & SDL_APPACTIVE)) { // Send an internal activate event - SDL_PrivateAppActive (1, SDL_APPACTIVE); + SDL_PrivateAppActive(1, SDL_APPACTIVE); } if (SDL_VideoSurface) { - NX_RefreshDisplay (this); + NX_RefreshDisplay(this); } break; } @@ -348,43 +348,43 @@ case GR_UPDATE_UNMAP: case GR_UPDATE_UNMAPTEMP: { - Dprintf ("GR_UPDATE_UNMAP or GR_UPDATE_UNMAPTEMP\n"); + Dprintf("GR_UPDATE_UNMAP or GR_UPDATE_UNMAPTEMP\n"); // If we're active, make ourselves inactive - if (SDL_GetAppState () & SDL_APPACTIVE) { + if (SDL_GetAppState() & SDL_APPACTIVE) { // Send an internal deactivate event - SDL_PrivateAppActive (0, - SDL_APPACTIVE | - SDL_APPINPUTFOCUS); + SDL_PrivateAppActive(0, + SDL_APPACTIVE | + SDL_APPINPUTFOCUS); } break; } case GR_UPDATE_SIZE: { - Dprintf ("GR_UPDATE_SIZE\n"); - SDL_PrivateResize (event.update.width, - event.update.height); + Dprintf("GR_UPDATE_SIZE\n"); + SDL_PrivateResize(event.update.width, + event.update.height); break; } case GR_UPDATE_MOVE: case GR_UPDATE_REPARENT: { - Dprintf ("GR_UPDATE_MOVE or GR_UPDATE_REPARENT\n"); + Dprintf("GR_UPDATE_MOVE or GR_UPDATE_REPARENT\n"); #ifdef ENABLE_NANOX_DIRECT_FB if (Clientfb) { /* Get current window position and fb pointer */ if (currently_fullscreen) - GrGetWindowFBInfo (FSwindow, &fbinfo); + GrGetWindowFBInfo(FSwindow, &fbinfo); else - GrGetWindowFBInfo (SDL_Window, &fbinfo); + GrGetWindowFBInfo(SDL_Window, &fbinfo); } #endif break; } default: - Dprintf ("unknown GR_EVENT_TYPE_UPDATE\n"); + Dprintf("unknown GR_EVENT_TYPE_UPDATE\n"); break; } break; @@ -392,11 +392,11 @@ default: { - Dprintf ("pump event default\n"); + Dprintf("pump event default\n"); } } - GrCheckNextEvent (&event); + GrCheckNextEvent(&event); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/nanox/SDL_nxevents_c.h --- a/src/video/nanox/SDL_nxevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/nanox/SDL_nxevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -28,6 +28,6 @@ #include "SDL_nxvideo.h" // Functions to be exported -extern void NX_InitOSKeymap (_THIS); -extern void NX_PumpEvents (_THIS); +extern void NX_InitOSKeymap(_THIS); +extern void NX_PumpEvents(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/nanox/SDL_nximage.c --- a/src/video/nanox/SDL_nximage.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/nanox/SDL_nximage.c Mon May 29 04:04:35 2006 +0000 @@ -29,13 +29,13 @@ #include "SDL_nximage_c.h" void -NX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects) +NX_NormalUpdate(_THIS, int numrects, SDL_Rect * rects) { int i, j, xinc, yinc, destinc, rowinc; int x, y, w, h; unsigned char *src = NULL, *dest = NULL; - Dprintf ("enter NX_NormalUpdate\n"); + Dprintf("enter NX_NormalUpdate\n"); /* These are the values for the incoming image */ xinc = this->screen->format->BytesPerPixel; @@ -106,38 +106,38 @@ #endif else { for (j = h; j > 0; --j, src += yinc, dest += destinc) - SDL_memcpy (dest, src, rowinc); + SDL_memcpy(dest, src, rowinc); } if (!Clientfb) { if (currently_fullscreen) { - GrArea (FSwindow, SDL_GC, x + OffsetX, y + OffsetY, w, - h, Image_buff, pixel_type); + GrArea(FSwindow, SDL_GC, x + OffsetX, y + OffsetY, w, + h, Image_buff, pixel_type); } else { - GrArea (SDL_Window, SDL_GC, x, y, w, h, Image_buff, - pixel_type); + GrArea(SDL_Window, SDL_GC, x, y, w, h, Image_buff, + pixel_type); } } } - GrFlush (); + GrFlush(); - Dprintf ("leave NX_NormalUpdate\n"); + Dprintf("leave NX_NormalUpdate\n"); } int -NX_SetupImage (_THIS, SDL_Surface * screen) +NX_SetupImage(_THIS, SDL_Surface * screen) { int size = screen->h * screen->pitch; - Dprintf ("enter NX_SetupImage\n"); + Dprintf("enter NX_SetupImage\n"); - screen->pixels = (void *) SDL_malloc (size); + screen->pixels = (void *) SDL_malloc(size); if (!Clientfb) { - Image_buff = (unsigned char *) SDL_malloc (size); + Image_buff = (unsigned char *) SDL_malloc(size); if (screen->pixels == NULL || Image_buff == NULL) { - SDL_free (screen->pixels); - SDL_free (Image_buff); - SDL_OutOfMemory (); + SDL_free(screen->pixels); + SDL_free(Image_buff); + SDL_OutOfMemory(); return -1; } } @@ -146,37 +146,37 @@ this->UpdateRects = NX_NormalUpdate; - Dprintf ("leave NX_SetupImage\n"); + Dprintf("leave NX_SetupImage\n"); return 0; } void -NX_DestroyImage (_THIS, SDL_Surface * screen) +NX_DestroyImage(_THIS, SDL_Surface * screen) { - Dprintf ("enter NX_DestroyImage\n"); + Dprintf("enter NX_DestroyImage\n"); if (SDL_Image) - SDL_free (SDL_Image); + SDL_free(SDL_Image); if (Image_buff) - SDL_free (Image_buff); + SDL_free(Image_buff); if (screen) screen->pixels = NULL; - Dprintf ("leave NX_DestroyImage\n"); + Dprintf("leave NX_DestroyImage\n"); } int -NX_ResizeImage (_THIS, SDL_Surface * screen, Uint32 flags) +NX_ResizeImage(_THIS, SDL_Surface * screen, Uint32 flags) { int retval; GR_SCREEN_INFO si; - Dprintf ("enter NX_ResizeImage\n"); + Dprintf("enter NX_ResizeImage\n"); - NX_DestroyImage (this, screen); - retval = NX_SetupImage (this, screen); + NX_DestroyImage(this, screen); + retval = NX_SetupImage(this, screen); - GrGetScreenInfo (&si); + GrGetScreenInfo(&si); OffsetX = (si.cols - screen->w) / 2; OffsetY = (si.rows - screen->h) / 2; @@ -184,19 +184,19 @@ if (Clientfb) { /* Get current window position and fb pointer */ if (currently_fullscreen) - GrGetWindowFBInfo (FSwindow, &fbinfo); + GrGetWindowFBInfo(FSwindow, &fbinfo); else - GrGetWindowFBInfo (SDL_Window, &fbinfo); + GrGetWindowFBInfo(SDL_Window, &fbinfo); } #endif - Dprintf ("leave NX_ResizeImage\n"); + Dprintf("leave NX_ResizeImage\n"); return retval; } void -NX_RefreshDisplay (_THIS) +NX_RefreshDisplay(_THIS) { - Dprintf ("enter NX_RefreshDisplay\n"); + Dprintf("enter NX_RefreshDisplay\n"); // Don't refresh a display that doesn't have an image (like GL) if (!SDL_Image) { @@ -208,7 +208,7 @@ char *src, *dest = NULL; int xinc, yinc, rowinc; - GrGetWindowFBInfo (SDL_Window, &fbinfo); + GrGetWindowFBInfo(SDL_Window, &fbinfo); xinc = this->screen->format->BytesPerPixel; yinc = this->screen->pitch; @@ -223,21 +223,21 @@ for (j = this->screen->h; j > 0; --j, src += yinc, dest += fbinfo.pitch) - SDL_memcpy (dest, src, rowinc); + SDL_memcpy(dest, src, rowinc); } else #endif { if (currently_fullscreen) { - GrArea (FSwindow, SDL_GC, OffsetX, OffsetY, this->screen->w, - this->screen->h, SDL_Image, pixel_type); + GrArea(FSwindow, SDL_GC, OffsetX, OffsetY, this->screen->w, + this->screen->h, SDL_Image, pixel_type); } else { - GrArea (SDL_Window, SDL_GC, 0, 0, this->screen->w, - this->screen->h, SDL_Image, pixel_type); + GrArea(SDL_Window, SDL_GC, 0, 0, this->screen->w, + this->screen->h, SDL_Image, pixel_type); } } - GrFlush (); + GrFlush(); - Dprintf ("leave NX_RefreshDisplay\n"); + Dprintf("leave NX_RefreshDisplay\n"); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/nanox/SDL_nximage_c.h --- a/src/video/nanox/SDL_nximage_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/nanox/SDL_nximage_c.h Mon May 29 04:04:35 2006 +0000 @@ -27,10 +27,10 @@ #include "SDL_nxvideo.h" -extern int NX_SetupImage (_THIS, SDL_Surface * screen); -extern void NX_DestroyImage (_THIS, SDL_Surface * screen); -extern int NX_ResizeImage (_THIS, SDL_Surface * screen, Uint32 flags); +extern int NX_SetupImage(_THIS, SDL_Surface * screen); +extern void NX_DestroyImage(_THIS, SDL_Surface * screen); +extern int NX_ResizeImage(_THIS, SDL_Surface * screen, Uint32 flags); -extern void NX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects); -extern void NX_RefreshDisplay (_THIS); +extern void NX_NormalUpdate(_THIS, int numrects, SDL_Rect * rects); +extern void NX_RefreshDisplay(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/nanox/SDL_nxmodes.c --- a/src/video/nanox/SDL_nxmodes.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/nanox/SDL_nxmodes.c Mon May 29 04:04:35 2006 +0000 @@ -29,7 +29,7 @@ #include "SDL_nxmodes_c.h" SDL_Rect ** -NX_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +NX_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { if (flags & SDL_FULLSCREEN) return SDL_modelist; @@ -42,31 +42,31 @@ } void -NX_FreeVideoModes (_THIS) +NX_FreeVideoModes(_THIS) { int i; if (SDL_modelist) { for (i = 0; SDL_modelist[i]; ++i) { - SDL_free (SDL_modelist[i]); + SDL_free(SDL_modelist[i]); } - SDL_free (SDL_modelist); + SDL_free(SDL_modelist); SDL_modelist = NULL; } } int -NX_EnterFullScreen (_THIS) +NX_EnterFullScreen(_THIS) { if (!currently_fullscreen) { GR_SCREEN_INFO si; - GrGetScreenInfo (&si); - GrResizeWindow (FSwindow, si.cols, si.rows); - GrUnmapWindow (SDL_Window); - GrMapWindow (FSwindow); - GrRaiseWindow (FSwindow); - GrSetFocus (FSwindow); + GrGetScreenInfo(&si); + GrResizeWindow(FSwindow, si.cols, si.rows); + GrUnmapWindow(SDL_Window); + GrMapWindow(FSwindow); + GrRaiseWindow(FSwindow); + GrSetFocus(FSwindow); currently_fullscreen = 1; } @@ -74,13 +74,13 @@ } int -NX_LeaveFullScreen (_THIS) +NX_LeaveFullScreen(_THIS) { if (currently_fullscreen) { - GrUnmapWindow (FSwindow); - GrMapWindow (SDL_Window); - GrRaiseWindow (SDL_Window); - GrSetFocus (SDL_Window); + GrUnmapWindow(FSwindow); + GrMapWindow(SDL_Window); + GrRaiseWindow(SDL_Window); + GrSetFocus(SDL_Window); currently_fullscreen = 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/nanox/SDL_nxmodes_c.h --- a/src/video/nanox/SDL_nxmodes_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/nanox/SDL_nxmodes_c.h Mon May 29 04:04:35 2006 +0000 @@ -28,9 +28,8 @@ #include "SDL_nxvideo.h" #include -extern SDL_Rect **NX_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -extern void NX_FreeVideoModes (_THIS); -extern int NX_EnterFullScreen (_THIS); -extern int NX_LeaveFullScreen (_THIS); +extern SDL_Rect **NX_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags); +extern void NX_FreeVideoModes(_THIS); +extern int NX_EnterFullScreen(_THIS); +extern int NX_LeaveFullScreen(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/nanox/SDL_nxmouse.c --- a/src/video/nanox/SDL_nxmouse.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/nanox/SDL_nxmouse.c Mon May 29 04:04:35 2006 +0000 @@ -36,51 +36,51 @@ }; WMcursor * -NX_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, int hot_x, - int hot_y) +NX_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, int hot_x, + int hot_y) { WMcursor *cursor; - Dprintf ("enter NX_CreateWMCursor\n"); + Dprintf("enter NX_CreateWMCursor\n"); - cursor = (WMcursor *) SDL_malloc (sizeof (WMcursor)); + cursor = (WMcursor *) SDL_malloc(sizeof(WMcursor)); if (cursor == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return NULL; } - Dprintf ("leave NX_CreateWMCursor\n"); + Dprintf("leave NX_CreateWMCursor\n"); return cursor; } void -NX_FreeWMCursor (_THIS, WMcursor * cursor) +NX_FreeWMCursor(_THIS, WMcursor * cursor) { - Dprintf ("NX_FreeWMCursor\n"); - SDL_free (cursor); + Dprintf("NX_FreeWMCursor\n"); + SDL_free(cursor); return; } void -NX_WarpWMCursor (_THIS, Uint16 x, Uint16 y) +NX_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { GR_WINDOW_INFO info; - Dprintf ("enter NX_WarpWMCursor\n"); - SDL_Lock_EventThread (); + Dprintf("enter NX_WarpWMCursor\n"); + SDL_Lock_EventThread(); - GrGetWindowInfo (SDL_Window, &info); - GrMoveCursor (info.x + x, info.y + y); + GrGetWindowInfo(SDL_Window, &info); + GrMoveCursor(info.x + x, info.y + y); - SDL_Unlock_EventThread (); - Dprintf ("leave NX_WarpWMCursor\n"); + SDL_Unlock_EventThread(); + Dprintf("leave NX_WarpWMCursor\n"); } int -NX_ShowWMCursor (_THIS, WMcursor * cursor) +NX_ShowWMCursor(_THIS, WMcursor * cursor) { - Dprintf ("NX_ShowWMCursor\n"); + Dprintf("NX_ShowWMCursor\n"); return 1; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/nanox/SDL_nxmouse_c.h --- a/src/video/nanox/SDL_nxmouse_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/nanox/SDL_nxmouse_c.h Mon May 29 04:04:35 2006 +0000 @@ -23,9 +23,9 @@ #include "SDL_nxvideo.h" -extern WMcursor *NX_CreateWMCursor (_THIS, Uint8 * data, Uint8 * mask, int w, - int h, int hot_x, int hot_y); -void NX_FreeWMCursor (_THIS, WMcursor * cursor); -extern void NX_WarpWMCursor (_THIS, Uint16 x, Uint16 y); -extern int NX_ShowWMCursor (_THIS, WMcursor * cursor); +extern WMcursor *NX_CreateWMCursor(_THIS, Uint8 * data, Uint8 * mask, int w, + int h, int hot_x, int hot_y); +void NX_FreeWMCursor(_THIS, WMcursor * cursor); +extern void NX_WarpWMCursor(_THIS, Uint16 x, Uint16 y); +extern int NX_ShowWMCursor(_THIS, WMcursor * cursor); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/nanox/SDL_nxvideo.c --- a/src/video/nanox/SDL_nxvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/nanox/SDL_nxvideo.c Mon May 29 04:04:35 2006 +0000 @@ -40,69 +40,69 @@ #include "SDL_nxevents_c.h" // Initialization/Query functions -static int NX_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Surface *NX_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int NX_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void NX_VideoQuit (_THIS); -static void NX_DestroyWindow (_THIS, SDL_Surface * screen); -static int NX_ToggleFullScreen (_THIS, int on); -static void NX_UpdateMouse (_THIS); -static int NX_SetGammaRamp (_THIS, Uint16 * ramp); -static int NX_GetGammaRamp (_THIS, Uint16 * ramp); +static int NX_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Surface *NX_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +static int NX_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void NX_VideoQuit(_THIS); +static void NX_DestroyWindow(_THIS, SDL_Surface * screen); +static int NX_ToggleFullScreen(_THIS, int on); +static void NX_UpdateMouse(_THIS); +static int NX_SetGammaRamp(_THIS, Uint16 * ramp); +static int NX_GetGammaRamp(_THIS, Uint16 * ramp); // Microwin driver bootstrap functions static int -NX_Available () +NX_Available() { - Dprintf ("enter NX_Available\n"); + Dprintf("enter NX_Available\n"); - if (GrOpen () < 0) + if (GrOpen() < 0) return 0; - GrClose (); + GrClose(); - Dprintf ("leave NX_Available\n"); + Dprintf("leave NX_Available\n"); return 1; } static void -NX_DeleteDevice (SDL_VideoDevice * device) +NX_DeleteDevice(SDL_VideoDevice * device) { - Dprintf ("enter NX_DeleteDevice\n"); + Dprintf("enter NX_DeleteDevice\n"); if (device) { if (device->hidden) - SDL_free (device->hidden); + SDL_free(device->hidden); if (device->gl_data) - SDL_free (device->gl_data); - SDL_free (device); + SDL_free(device->gl_data); + SDL_free(device); } - Dprintf ("leave NX_DeleteDevice\n"); + Dprintf("leave NX_DeleteDevice\n"); } static SDL_VideoDevice * -NX_CreateDevice (int devindex) +NX_CreateDevice(int devindex) { SDL_VideoDevice *device; - Dprintf ("enter NX_CreateDevice\n"); + Dprintf("enter NX_CreateDevice\n"); // Initialize all variables that we clean on shutdown - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); device->gl_data = NULL; } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); - NX_DeleteDevice (device); + SDL_OutOfMemory(); + NX_DeleteDevice(device); return 0; } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); // Set the function pointers device->VideoInit = NX_VideoInit; @@ -151,7 +151,7 @@ device->free = NX_DeleteDevice; - Dprintf ("leave NX_CreateDevice\n"); + Dprintf("leave NX_CreateDevice\n"); return device; } @@ -160,11 +160,11 @@ }; static void -create_aux_windows (_THIS) +create_aux_windows(_THIS) { GR_WM_PROPERTIES props; - Dprintf ("enter create_aux_windows\n"); + Dprintf("enter create_aux_windows\n"); // Don't create any extra windows if we are being managed if (SDL_windowid) { @@ -173,43 +173,43 @@ } if (FSwindow && FSwindow != GR_ROOT_WINDOW_ID) { - GrDestroyWindow (FSwindow); + GrDestroyWindow(FSwindow); } - FSwindow = GrNewWindow (GR_ROOT_WINDOW_ID, 0, 0, 1, 1, 0, BLACK, BLACK); + FSwindow = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, 1, 1, 0, BLACK, BLACK); props.flags = GR_WM_FLAGS_PROPS; props.props = GR_WM_PROPS_NODECORATE; - GrSetWMProperties (FSwindow, &props); + GrSetWMProperties(FSwindow, &props); - GrSelectEvents (FSwindow, (GR_EVENT_MASK_EXPOSURE | - GR_EVENT_MASK_BUTTON_DOWN | - GR_EVENT_MASK_BUTTON_UP | - GR_EVENT_MASK_FOCUS_IN | - GR_EVENT_MASK_FOCUS_OUT | - GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP | - GR_EVENT_MASK_MOUSE_ENTER | - GR_EVENT_MASK_MOUSE_EXIT | - GR_EVENT_MASK_MOUSE_MOTION | - GR_EVENT_MASK_UPDATE | - GR_EVENT_MASK_CLOSE_REQ)); + GrSelectEvents(FSwindow, (GR_EVENT_MASK_EXPOSURE | + GR_EVENT_MASK_BUTTON_DOWN | + GR_EVENT_MASK_BUTTON_UP | + GR_EVENT_MASK_FOCUS_IN | + GR_EVENT_MASK_FOCUS_OUT | + GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP | + GR_EVENT_MASK_MOUSE_ENTER | + GR_EVENT_MASK_MOUSE_EXIT | + GR_EVENT_MASK_MOUSE_MOTION | + GR_EVENT_MASK_UPDATE | + GR_EVENT_MASK_CLOSE_REQ)); - Dprintf ("leave create_aux_windows\n"); + Dprintf("leave create_aux_windows\n"); } int -NX_VideoInit (_THIS, SDL_PixelFormat * vformat) +NX_VideoInit(_THIS, SDL_PixelFormat * vformat) { GR_SCREEN_INFO si; - Dprintf ("enter NX_VideoInit\n"); + Dprintf("enter NX_VideoInit\n"); - if (GrOpen () < 0) { - SDL_SetError ("GrOpen() fail"); + if (GrOpen() < 0) { + SDL_SetError("GrOpen() fail"); return -1; } // use share memory to speed up #ifdef NANOX_SHARE_MEMORY - GrReqShmCmds (0xFFFF); + GrReqShmCmds(0xFFFF); #endif SDL_Window = 0; @@ -219,7 +219,7 @@ GammaRamp_G = NULL; GammaRamp_B = NULL; - GrGetScreenInfo (&si); + GrGetScreenInfo(&si); SDL_Visual.bpp = si.bpp; /* Determine the current screen size */ @@ -227,9 +227,9 @@ this->info.current_h = si.rows; // GetVideoMode - SDL_modelist = (SDL_Rect **) SDL_malloc (sizeof (SDL_Rect *) * 2); + SDL_modelist = (SDL_Rect **) SDL_malloc(sizeof(SDL_Rect *) * 2); if (SDL_modelist) { - SDL_modelist[0] = (SDL_Rect *) SDL_malloc (sizeof (SDL_Rect)); + SDL_modelist[0] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect)); if (SDL_modelist[0]) { SDL_modelist[0]->x = 0; SDL_modelist[0]->y = 0; @@ -251,142 +251,142 @@ vformat->Bmask = SDL_Visual.blue_mask; } // See if we have been passed a window to use - SDL_windowid = getenv ("SDL_WINDOWID"); + SDL_windowid = getenv("SDL_WINDOWID"); // Create the fullscreen (and managed windows : no implement) - create_aux_windows (this); + create_aux_windows(this); - Dprintf ("leave NX_VideoInit\n"); + Dprintf("leave NX_VideoInit\n"); return 0; } void -NX_VideoQuit (_THIS) +NX_VideoQuit(_THIS) { - Dprintf ("enter NX_VideoQuit\n"); + Dprintf("enter NX_VideoQuit\n"); // Start shutting down the windows - NX_DestroyImage (this, this->screen); - NX_DestroyWindow (this, this->screen); + NX_DestroyImage(this, this->screen); + NX_DestroyWindow(this, this->screen); if (FSwindow && FSwindow != GR_ROOT_WINDOW_ID) { - GrDestroyWindow (FSwindow); + GrDestroyWindow(FSwindow); } - NX_FreeVideoModes (this); - SDL_free (GammaRamp_R); - SDL_free (GammaRamp_G); - SDL_free (GammaRamp_B); + NX_FreeVideoModes(this); + SDL_free(GammaRamp_R); + SDL_free(GammaRamp_G); + SDL_free(GammaRamp_B); #ifdef ENABLE_NANOX_DIRECT_FB if (Clientfb) - GrCloseClientFramebuffer (); + GrCloseClientFramebuffer(); #endif - GrClose (); + GrClose(); - Dprintf ("leave NX_VideoQuit\n"); + Dprintf("leave NX_VideoQuit\n"); } static void -NX_DestroyWindow (_THIS, SDL_Surface * screen) +NX_DestroyWindow(_THIS, SDL_Surface * screen) { - Dprintf ("enter NX_DestroyWindow\n"); + Dprintf("enter NX_DestroyWindow\n"); if (!SDL_windowid) { if (screen && (screen->flags & SDL_FULLSCREEN)) { screen->flags &= ~SDL_FULLSCREEN; - NX_LeaveFullScreen (this); + NX_LeaveFullScreen(this); } // Destroy the output window if (SDL_Window && SDL_Window != GR_ROOT_WINDOW_ID) { - GrDestroyWindow (SDL_Window); + GrDestroyWindow(SDL_Window); } } // Free the graphics context if (!SDL_GC) { - GrDestroyGC (SDL_GC); + GrDestroyGC(SDL_GC); SDL_GC = 0; } - Dprintf ("leave NX_DestroyWindow\n"); + Dprintf("leave NX_DestroyWindow\n"); } static int -NX_CreateWindow (_THIS, SDL_Surface * screen, - int w, int h, int bpp, Uint32 flags) +NX_CreateWindow(_THIS, SDL_Surface * screen, + int w, int h, int bpp, Uint32 flags) { - Dprintf ("enter NX_CreateWindow\n"); + Dprintf("enter NX_CreateWindow\n"); // If a window is already present, destroy it and start fresh if (SDL_Window && SDL_Window != GR_ROOT_WINDOW_ID) { - NX_DestroyWindow (this, screen); + NX_DestroyWindow(this, screen); } // See if we have been given a window id if (SDL_windowid) { - SDL_Window = SDL_strtol (SDL_windowid, NULL, 0); + SDL_Window = SDL_strtol(SDL_windowid, NULL, 0); } else { SDL_Window = 0; } - if (!SDL_ReallocFormat (screen, bpp, SDL_Visual.red_mask, - SDL_Visual.green_mask, SDL_Visual.blue_mask, 0)) + if (!SDL_ReallocFormat(screen, bpp, SDL_Visual.red_mask, + SDL_Visual.green_mask, SDL_Visual.blue_mask, 0)) return -1; // Create (or use) the nanox display window if (!SDL_windowid) { SDL_Window = - GrNewWindow (GR_ROOT_WINDOW_ID, 0, 0, w, h, 0, BLACK, WHITE); + GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, w, h, 0, BLACK, WHITE); - GrSelectEvents (SDL_Window, (GR_EVENT_MASK_EXPOSURE | - GR_EVENT_MASK_BUTTON_DOWN | - GR_EVENT_MASK_BUTTON_UP | - GR_EVENT_MASK_FOCUS_IN | - GR_EVENT_MASK_FOCUS_OUT | - GR_EVENT_MASK_KEY_DOWN | - GR_EVENT_MASK_KEY_UP | - GR_EVENT_MASK_MOUSE_ENTER | - GR_EVENT_MASK_MOUSE_EXIT | - GR_EVENT_MASK_MOUSE_MOTION | - GR_EVENT_MASK_UPDATE | - GR_EVENT_MASK_CLOSE_REQ)); + GrSelectEvents(SDL_Window, (GR_EVENT_MASK_EXPOSURE | + GR_EVENT_MASK_BUTTON_DOWN | + GR_EVENT_MASK_BUTTON_UP | + GR_EVENT_MASK_FOCUS_IN | + GR_EVENT_MASK_FOCUS_OUT | + GR_EVENT_MASK_KEY_DOWN | + GR_EVENT_MASK_KEY_UP | + GR_EVENT_MASK_MOUSE_ENTER | + GR_EVENT_MASK_MOUSE_EXIT | + GR_EVENT_MASK_MOUSE_MOTION | + GR_EVENT_MASK_UPDATE | + GR_EVENT_MASK_CLOSE_REQ)); } /* Create the graphics context here, once we have a window */ - SDL_GC = GrNewGC (); + SDL_GC = GrNewGC(); if (SDL_GC == 0) { - SDL_SetError ("Couldn't create graphics context"); + SDL_SetError("Couldn't create graphics context"); return (-1); } // Map them both and go fullscreen, if requested if (!SDL_windowid) { - GrMapWindow (SDL_Window); + GrMapWindow(SDL_Window); if (flags & SDL_FULLSCREEN) { screen->flags |= SDL_FULLSCREEN; - NX_EnterFullScreen (this); + NX_EnterFullScreen(this); } else { screen->flags &= ~SDL_FULLSCREEN; } } #ifdef ENABLE_NANOX_DIRECT_FB /* attempt allocating the client side framebuffer */ - Clientfb = GrOpenClientFramebuffer (); + Clientfb = GrOpenClientFramebuffer(); /* NULL return will default to using GrArea() */ #endif - Dprintf ("leave NX_CreateWindow\n"); + Dprintf("leave NX_CreateWindow\n"); return 0; } SDL_Surface * -NX_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +NX_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { - Dprintf ("enter NX_SetVideoMode\n"); + Dprintf("enter NX_SetVideoMode\n"); // Lock the event thread, in multi-threading environments - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); bpp = SDL_Visual.bpp; - if (NX_CreateWindow (this, current, width, height, bpp, flags) < 0) { + if (NX_CreateWindow(this, current, width, height, bpp, flags) < 0) { current = NULL; goto done; } @@ -394,15 +394,15 @@ if (current->w != width || current->h != height) { current->w = width; current->h = height; - current->pitch = SDL_CalculatePitch (current); - NX_ResizeImage (this, current, flags); + current->pitch = SDL_CalculatePitch(current); + NX_ResizeImage(this, current, flags); } current->flags |= (flags & (SDL_RESIZABLE | SDL_NOFRAME)); done: - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); - Dprintf ("leave NX_SetVideoMode\n"); + Dprintf("leave NX_SetVideoMode\n"); // We're done! return current; @@ -410,12 +410,12 @@ // ncolors <= 256 int -NX_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +NX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { int i; GR_PALETTE pal; - Dprintf ("enter NX_SetColors\n"); + Dprintf("enter NX_SetColors\n"); if (ncolors > 256) return 0; @@ -426,100 +426,100 @@ pal.palette[i].g = colors[i].g; pal.palette[i].b = colors[i].b; } - GrSetSystemPalette (firstcolor, &pal); + GrSetSystemPalette(firstcolor, &pal); - Dprintf ("leave NX_SetColors\n"); + Dprintf("leave NX_SetColors\n"); return 1; } static int -NX_ToggleFullScreen (_THIS, int on) +NX_ToggleFullScreen(_THIS, int on) { SDL_Rect rect; Uint32 event_thread; - Dprintf ("enter NX_ToggleFullScreen\n"); + Dprintf("enter NX_ToggleFullScreen\n"); // Don't switch if we don't own the window if (SDL_windowid) return 0; // Don't lock if we are the event thread - event_thread = SDL_EventThreadID (); - if (event_thread && (SDL_ThreadID () == event_thread)) { + event_thread = SDL_EventThreadID(); + if (event_thread && (SDL_ThreadID() == event_thread)) { event_thread = 0; } if (event_thread) { - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); } if (on) { - NX_EnterFullScreen (this); + NX_EnterFullScreen(this); } else { this->screen->flags &= ~SDL_FULLSCREEN; - NX_LeaveFullScreen (this); + NX_LeaveFullScreen(this); } rect.x = rect.y = 0; rect.w = this->screen->w, rect.h = this->screen->h; - NX_NormalUpdate (this, 1, &rect); + NX_NormalUpdate(this, 1, &rect); if (event_thread) { - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); } - Dprintf ("leave NX_ToggleFullScreen\n"); + Dprintf("leave NX_ToggleFullScreen\n"); return 1; } // Update the current mouse state and position static void -NX_UpdateMouse (_THIS) +NX_UpdateMouse(_THIS) { int x, y; GR_WINDOW_INFO info; GR_SCREEN_INFO si; - Dprintf ("enter NX_UpdateMouse\n"); + Dprintf("enter NX_UpdateMouse\n"); // Lock the event thread, in multi-threading environments - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); - GrGetScreenInfo (&si); - GrGetWindowInfo (SDL_Window, &info); + GrGetScreenInfo(&si); + GrGetWindowInfo(SDL_Window, &info); x = si.xpos - info.x; y = si.ypos - info.y; if (x >= 0 && x <= info.width && y >= 0 && y <= info.height) { - SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); - SDL_PrivateMouseMotion (0, 0, x, y); + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); + SDL_PrivateMouseMotion(0, 0, x, y); } else { - SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } - SDL_Unlock_EventThread (); - Dprintf ("leave NX_UpdateMouse\n"); + SDL_Unlock_EventThread(); + Dprintf("leave NX_UpdateMouse\n"); } static int -NX_SetGammaRamp (_THIS, Uint16 * ramp) +NX_SetGammaRamp(_THIS, Uint16 * ramp) { int i; Uint16 *red, *green, *blue; - Dprintf ("enter NX_SetGammaRamp\n"); + Dprintf("enter NX_SetGammaRamp\n"); if (SDL_Visual.bpp != 32 && SDL_Visual.bpp != 24) return -1; if (!GammaRamp_R) - GammaRamp_R = (Uint16 *) SDL_malloc (sizeof (Uint16) * CI_SIZE); + GammaRamp_R = (Uint16 *) SDL_malloc(sizeof(Uint16) * CI_SIZE); if (!GammaRamp_G) - GammaRamp_G = (Uint16 *) SDL_malloc (sizeof (Uint16) * CI_SIZE); + GammaRamp_G = (Uint16 *) SDL_malloc(sizeof(Uint16) * CI_SIZE); if (!GammaRamp_B) - GammaRamp_B = (Uint16 *) SDL_malloc (sizeof (Uint16) * CI_SIZE); + GammaRamp_B = (Uint16 *) SDL_malloc(sizeof(Uint16) * CI_SIZE); if ((!GammaRamp_R) || (!GammaRamp_G) || (!GammaRamp_B)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return -1; } @@ -535,19 +535,19 @@ GammaRamp_G[i] = green[i]; GammaRamp_B[i] = blue[i]; } - SDL_UpdateRect (this->screen, 0, 0, 0, 0); + SDL_UpdateRect(this->screen, 0, 0, 0, 0); - Dprintf ("leave NX_SetGammaRamp\n"); + Dprintf("leave NX_SetGammaRamp\n"); return 0; } static int -NX_GetGammaRamp (_THIS, Uint16 * ramp) +NX_GetGammaRamp(_THIS, Uint16 * ramp) { int i; Uint16 *red, *green, *blue; - Dprintf ("enter NX_GetGammaRamp\n"); + Dprintf("enter NX_GetGammaRamp\n"); if (SDL_Visual.bpp != 32 && SDL_Visual.bpp != 24) return -1; @@ -565,7 +565,7 @@ red[i] = green[i] = blue[i] = i; } - Dprintf ("leave NX_GetGammaRamp\n"); + Dprintf("leave NX_GetGammaRamp\n"); return 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/nanox/SDL_nxwm.c --- a/src/video/nanox/SDL_nxwm.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/nanox/SDL_nxwm.c Mon May 29 04:04:35 2006 +0000 @@ -31,35 +31,35 @@ #include "SDL_nxwm_c.h" void -NX_SetCaption (_THIS, const char *title, const char *icon) +NX_SetCaption(_THIS, const char *title, const char *icon) { - Dprintf ("enter NX_SetCaption\n"); + Dprintf("enter NX_SetCaption\n"); // Lock the event thread, in multi-threading environments - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); if (SDL_Window) - GrSetWindowTitle (SDL_Window, title); + GrSetWindowTitle(SDL_Window, title); - SDL_Unlock_EventThread (); - Dprintf ("leave NX_SetCaption\n"); + SDL_Unlock_EventThread(); + Dprintf("leave NX_SetCaption\n"); } int -NX_GetWMInfo (_THIS, SDL_SysWMinfo * info) +NX_GetWMInfo(_THIS, SDL_SysWMinfo * info) { - Dprintf ("enter NX_GetWMInfo\n"); + Dprintf("enter NX_GetWMInfo\n"); if (info->version.major <= SDL_MAJOR_VERSION) { info->window = SDL_Window; return 1; } else { - SDL_SetError ("Application not compiled with SDL %d.%d\n", - SDL_MAJOR_VERSION, SDL_MINOR_VERSION); + SDL_SetError("Application not compiled with SDL %d.%d\n", + SDL_MAJOR_VERSION, SDL_MINOR_VERSION); return -1; } - Dprintf ("leave NX_GetWMInfo\n"); + Dprintf("leave NX_GetWMInfo\n"); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/nanox/SDL_nxwm_c.h --- a/src/video/nanox/SDL_nxwm_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/nanox/SDL_nxwm_c.h Mon May 29 04:04:35 2006 +0000 @@ -28,6 +28,6 @@ #include "SDL_nxvideo.h" // Functions to be exported -extern void NX_SetCaption (_THIS, const char *title, const char *icon); -extern int NX_GetWMInfo (_THIS, SDL_SysWMinfo * info); +extern void NX_SetCaption(_THIS, const char *title, const char *icon); +extern int NX_GetWMInfo(_THIS, SDL_SysWMinfo * info); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/os2fslib/SDL_os2fslib.c --- a/src/video/os2fslib/SDL_os2fslib.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/os2fslib/SDL_os2fslib.c Mon May 29 04:04:35 2006 +0000 @@ -62,7 +62,7 @@ // Backdoors: DECLSPEC void SDLCALL -SDL_OS2FSLIB_SetFCFToUse (ULONG ulFCF) +SDL_OS2FSLIB_SetFCFToUse(ULONG ulFCF) { ulFCFToUse = ulFCF; } @@ -90,8 +90,8 @@ /* The translation table from a VK keysym to a SDL keysym */ static SDLKey HWScanKeyMap[256]; -static SDL_keysym *TranslateKey (int vkey, int chcode, int scancode, - SDL_keysym * keysym, int iPressed); +static SDL_keysym *TranslateKey(int vkey, int chcode, int scancode, + SDL_keysym * keysym, int iPressed); static int iShiftIsPressed; #ifdef BITBLT_IN_WINMESSAGEPROC @@ -119,12 +119,12 @@ // ///////////////////////////////////////////////////////////////////// static BOOL -SetAccessableWindowPos (HWND hwnd, HWND hwndInsertBehind, - LONG x, LONG y, LONG cx, LONG cy, ULONG fl) +SetAccessableWindowPos(HWND hwnd, HWND hwndInsertBehind, + LONG x, LONG y, LONG cx, LONG cy, ULONG fl) { SWP swpDesktop, swp; // Get desktop area - WinQueryWindowPos (HWND_DESKTOP, &swpDesktop); + WinQueryWindowPos(HWND_DESKTOP, &swpDesktop); if ((fl & SWP_MOVE) && (fl & SWP_SIZE)) { // If both moving and sizing, then change size and pos now!! @@ -136,10 +136,10 @@ y = 0; if (y + cy > swpDesktop.cy) y = swpDesktop.cy - cy; - return WinSetWindowPos (hwnd, hwndInsertBehind, x, y, cx, cy, fl); + return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl); } else if (fl & SWP_MOVE) { // Just moving - WinQueryWindowPos (hwnd, &swp); + WinQueryWindowPos(hwnd, &swp); if (x + swp.cx > swpDesktop.cx) x = swpDesktop.cx - swp.cx; if (x < 0) @@ -148,10 +148,10 @@ y = 0; if (y + swp.cy > swpDesktop.cy) y = swpDesktop.cy - swp.cy; - return WinSetWindowPos (hwnd, hwndInsertBehind, x, y, cx, cy, fl); + return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl); } else if (fl & SWP_SIZE) { // Just sizing - WinQueryWindowPos (hwnd, &swp); + WinQueryWindowPos(hwnd, &swp); x = swp.x; y = swp.y; if (x + cx > swpDesktop.cx) @@ -162,14 +162,14 @@ y = 0; if (y + cy > swpDesktop.cy) y = swpDesktop.cy - cy; - return WinSetWindowPos (hwnd, hwndInsertBehind, x, y, cx, cy, - fl | SWP_MOVE); + return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, + fl | SWP_MOVE); } else - return WinSetWindowPos (hwnd, hwndInsertBehind, x, y, cx, cy, fl); + return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl); } static UniChar -NativeCharToUniChar (int chcode) +NativeCharToUniChar(int chcode) { UniChar ucResult = (UniChar) chcode; int rc; @@ -183,7 +183,7 @@ size_t iNonIdentical; // Create unicode convert object - rc = UniCreateUconvObject (L"", &ucoTemp); + rc = UniCreateUconvObject(L"", &ucoTemp); if (rc != ULS_SUCCESS) { // Could not create convert object! return ucResult; @@ -191,25 +191,25 @@ // Convert language code string to unicode string achFrom[0] = (char) chcode; achFrom[1] = 0; - iFromCount = sizeof (char) * 2; - iToCount = sizeof (UniChar) * 2; + iFromCount = sizeof(char) * 2; + iToCount = sizeof(UniChar) * 2; pucTo = &(aucTo[0]); pchFrom = &(achFrom[0]); - rc = UniUconvToUcs (ucoTemp, - &pchFrom, - &iFromCount, &pucTo, &iToCount, &iNonIdentical); + rc = UniUconvToUcs(ucoTemp, + &pchFrom, + &iFromCount, &pucTo, &iToCount, &iNonIdentical); if (rc != ULS_SUCCESS) { // Could not convert language code to UCS string! - UniFreeUconvObject (ucoTemp); + UniFreeUconvObject(ucoTemp); return ucResult; } - UniFreeUconvObject (ucoTemp); + UniFreeUconvObject(ucoTemp); #ifdef DEBUG_BUILD - printf ("%02x converted to %02x\n", (int) chcode, (int) (aucTo[0])); + printf("%02x converted to %02x\n", (int) chcode, (int) (aucTo[0])); #endif return aucTo[0]; @@ -223,8 +223,8 @@ // ///////////////////////////////////////////////////////////////////// static SDL_keysym * -TranslateKey (int vkey, int chcode, int scancode, SDL_keysym * keysym, - int iPressed) +TranslateKey(int vkey, int chcode, int scancode, SDL_keysym * keysym, + int iPressed) { keysym->scancode = (unsigned char) scancode; keysym->mod = KMOD_NONE; @@ -232,7 +232,7 @@ if (iPressed && SDL_TranslateUNICODE) { if (chcode) - keysym->unicode = NativeCharToUniChar (chcode); + keysym->unicode = NativeCharToUniChar(chcode); else keysym->unicode = vkey; } @@ -367,7 +367,7 @@ // ///////////////////////////////////////////////////////////////////// static MRESULT EXPENTRY -WndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) +WndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { HPS ps; RECTL rcl; @@ -378,7 +378,7 @@ #ifdef DEBUG_BUILD // printf("WM_CHAR\n"); fflush(stdout); #endif - pVideo = WinQueryWindowPtr (hwnd, 0); + pVideo = WinQueryWindowPtr(hwnd, 0); if (pVideo) { /* // We skip repeated keys: @@ -392,7 +392,7 @@ */ // If it's not repeated, then let's see if its pressed or released! - if (SHORT1FROMMP (mp1) & KC_KEYUP) { + if (SHORT1FROMMP(mp1) & KC_KEYUP) { // A key has been released SDL_keysym keysym; @@ -415,10 +415,10 @@ &keysym,0)); } */ - SDL_PrivateKeyboard (SDL_RELEASED, TranslateKey (SHORT2FROMMP (mp2), // VK_ code - SHORT1FROMMP (mp2), // Character code - CHAR4FROMMP (mp1), // HW Scan code - &keysym, 0)); + SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(SHORT2FROMMP(mp2), // VK_ code + SHORT1FROMMP(mp2), // Character code + CHAR4FROMMP(mp1), // HW Scan code + &keysym, 0)); } else { // A key has been pressed @@ -429,11 +429,11 @@ #endif // Check for fastkeys: ALT+HOME to toggle FS mode // ALT+END to close app - if ((SHORT1FROMMP (mp1) & KC_ALT) && - (SHORT2FROMMP (mp2) == VK_HOME)) { + if ((SHORT1FROMMP(mp1) & KC_ALT) && + (SHORT2FROMMP(mp2) == VK_HOME)) { #ifdef DEBUG_BUILD - printf (" Pressed ALT+HOME!\n"); - fflush (stdout); + printf(" Pressed ALT+HOME!\n"); + fflush(stdout); #endif // Only switch between fullscreen and back if it's not // a resizable mode! @@ -442,30 +442,30 @@ && ((pVideo->hidden->pSDLSurface-> flags & SDL_RESIZABLE) == 0))) - FSLib_ToggleFSMode (hwnd, !FSLib_QueryFSMode (hwnd)); + FSLib_ToggleFSMode(hwnd, !FSLib_QueryFSMode(hwnd)); #ifdef DEBUG_BUILD else - printf (" Resizable mode, so discarding ALT+HOME!\n"); - fflush (stdout); + printf(" Resizable mode, so discarding ALT+HOME!\n"); + fflush(stdout); #endif - } else if ((SHORT1FROMMP (mp1) & KC_ALT) && - (SHORT2FROMMP (mp2) == VK_END)) { + } else if ((SHORT1FROMMP(mp1) & KC_ALT) && + (SHORT2FROMMP(mp2) == VK_END)) { #ifdef DEBUG_BUILD - printf (" Pressed ALT+END!\n"); - fflush (stdout); + printf(" Pressed ALT+END!\n"); + fflush(stdout); #endif // Close window, and get out of loop! // Also send event to SDL application, but we won't // wait for it to be processed! - SDL_PrivateQuit (); - WinPostMsg (hwnd, WM_QUIT, 0, 0); + SDL_PrivateQuit(); + WinPostMsg(hwnd, WM_QUIT, 0, 0); } else { - SDL_PrivateKeyboard (SDL_PRESSED, TranslateKey (SHORT2FROMMP (mp2), // VK_ code - SHORT1FROMMP (mp2), // Character code - CHAR4FROMMP (mp1), // HW Scan code - &keysym, - 1)); + SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(SHORT2FROMMP(mp2), // VK_ code + SHORT1FROMMP(mp2), // Character code + CHAR4FROMMP(mp1), // HW Scan code + &keysym, + 1)); } } @@ -488,22 +488,22 @@ case WM_PAINT: // Window redraw! #ifdef DEBUG_BUILD - printf ("WM_PAINT (0x%x)\n", hwnd); - fflush (stdout); + printf("WM_PAINT (0x%x)\n", hwnd); + fflush(stdout); #endif - ps = WinBeginPaint (hwnd, 0, &rcl); - pVideo = FSLib_GetUserParm (hwnd); + ps = WinBeginPaint(hwnd, 0, &rcl); + pVideo = FSLib_GetUserParm(hwnd); if (pVideo) { if (!pVideo->hidden->pSDLSurface) { RECTL rclRect; // So, don't blit now! #ifdef DEBUG_BUILD - printf ("WM_PAINT : Skipping blit while resizing (Pre!)!\n"); - fflush (stdout); + printf("WM_PAINT : Skipping blit while resizing (Pre!)!\n"); + fflush(stdout); #endif - WinQueryWindowRect (hwnd, &rclRect); + WinQueryWindowRect(hwnd, &rclRect); // Fill with black - WinFillRect (ps, &rclRect, CLR_BLACK); + WinFillRect(ps, &rclRect, CLR_BLACK); } else { if (DosRequestMutexSem (pVideo->hidden->hmtxUseSrcBuffer, 1000) == NO_ERROR) { @@ -514,14 +514,14 @@ // Re-blit the modified area! // For this, we have to calculate the points, scaled! - WinQueryWindowPos (hwnd, &swp); + WinQueryWindowPos(hwnd, &swp); #ifdef DEBUG_BUILD printf ("WM_PAINT : WinSize: %d %d, BufSize: %d %d\n", swp.cx, swp.cy, pVideo->hidden->SrcBufferDesc.uiXResolution, pVideo->hidden->SrcBufferDesc.uiYResolution); - fflush (stdout); + fflush(stdout); #endif #ifndef RESIZE_EVEN_IF_RESIZABLE @@ -536,17 +536,17 @@ pVideo->hidden->SrcBufferDesc.uiXResolution) || (swp.cy != pVideo->hidden->SrcBufferDesc.uiYResolution)) - && (!FSLib_QueryFSMode (hwnd)))) { + && (!FSLib_QueryFSMode(hwnd)))) { RECTL rclRect; // Resizable surface and in resizing! // So, don't blit now! #ifdef DEBUG_BUILD - printf ("WM_PAINT : Skipping blit while resizing!\n"); - fflush (stdout); + printf("WM_PAINT : Skipping blit while resizing!\n"); + fflush(stdout); #endif - WinQueryWindowRect (hwnd, &rclRect); + WinQueryWindowRect(hwnd, &rclRect); // Fill with black - WinFillRect (ps, &rclRect, CLR_BLACK); + WinFillRect(ps, &rclRect, CLR_BLACK); } else #endif { @@ -621,55 +621,55 @@ pVideo->hidden->SrcBufferDesc. uiXResolution, pVideo->hidden->SrcBufferDesc.uiYResolution); - fflush (stdout); + fflush(stdout); #endif - FSLIB_BITBLT (hwnd, - pVideo->hidden->pchSrcBuffer, - iTop, iLeft, iWidth, iHeight); + FSLIB_BITBLT(hwnd, + pVideo->hidden->pchSrcBuffer, + iTop, iLeft, iWidth, iHeight); } - DosReleaseMutexSem (pVideo->hidden->hmtxUseSrcBuffer); + DosReleaseMutexSem(pVideo->hidden->hmtxUseSrcBuffer); } } } #ifdef DEBUG_BUILD else { - printf ("WM_PAINT : No pVideo!\n"); - fflush (stdout); + printf("WM_PAINT : No pVideo!\n"); + fflush(stdout); } #endif - WinEndPaint (ps); + WinEndPaint(ps); #ifdef DEBUG_BUILD - printf ("WM_PAINT : Done.\n"); - fflush (stdout); + printf("WM_PAINT : Done.\n"); + fflush(stdout); #endif return 0; case WM_SIZE: { #ifdef DEBUG_BUILD - printf ("WM_SIZE : (%d %d)\n", - SHORT1FROMMP (mp2), SHORT2FROMMP (mp2)); - fflush (stdout); + printf("WM_SIZE : (%d %d)\n", + SHORT1FROMMP(mp2), SHORT2FROMMP(mp2)); + fflush(stdout); #endif - iWindowSizeX = SHORT1FROMMP (mp2); - iWindowSizeY = SHORT2FROMMP (mp2); + iWindowSizeX = SHORT1FROMMP(mp2); + iWindowSizeY = SHORT2FROMMP(mp2); bWindowResized = 1; // Make sure the window will be redrawn - WinInvalidateRegion (hwnd, NULL, TRUE); + WinInvalidateRegion(hwnd, NULL, TRUE); } break; case WM_FSLIBNOTIFICATION: #ifdef DEBUG_BUILD - printf ("WM_FSLIBNOTIFICATION\n"); - fflush (stdout); + printf("WM_FSLIBNOTIFICATION\n"); + fflush(stdout); #endif if ((int) mp1 == FSLN_TOGGLEFSMODE) { // FS mode changed, reblit image! - pVideo = FSLib_GetUserParm (hwnd); + pVideo = FSLib_GetUserParm(hwnd); if (pVideo) { if (!pVideo->hidden->pSDLSurface) { // Resizable surface and in resizing! @@ -677,7 +677,7 @@ #ifdef DEBUG_BUILD printf ("WM_FSLIBNOTIFICATION : Can not blit if there is no surface, doing nothing.\n"); - fflush (stdout); + fflush(stdout); #endif } else { if (DosRequestMutexSem @@ -690,7 +690,7 @@ // But only blit if the window is not resizable, or if // the window is resizable and the source buffer size is the // same as the destination buffer size! - WinQueryWindowPos (hwnd, &swp); + WinQueryWindowPos(hwnd, &swp); if ((!pVideo->hidden->pSDLSurface) || ((pVideo->hidden->pSDLSurface) && (pVideo->hidden->pSDLSurface-> @@ -702,40 +702,40 @@ || (swp.cy != pVideo->hidden-> SrcBufferDesc.uiYResolution)) - && (!FSLib_QueryFSMode (hwnd)))) { + && (!FSLib_QueryFSMode(hwnd)))) { // Resizable surface and in resizing! // So, don't blit now! #ifdef DEBUG_BUILD printf ("WM_FSLIBNOTIFICATION : Cannot blit while resizing, doing nothing.\n"); - fflush (stdout); + fflush(stdout); #endif } else #endif { #ifdef DEBUG_BUILD - printf ("WM_FSLIBNOTIFICATION : Blitting!\n"); - fflush (stdout); + printf("WM_FSLIBNOTIFICATION : Blitting!\n"); + fflush(stdout); #endif - FSLIB_BITBLT (hwnd, - pVideo->hidden-> - pchSrcBuffer, 0, - 0, - pVideo->hidden-> - SrcBufferDesc. - uiXResolution, - pVideo->hidden-> - SrcBufferDesc.uiYResolution); + FSLIB_BITBLT(hwnd, + pVideo->hidden-> + pchSrcBuffer, 0, + 0, + pVideo->hidden-> + SrcBufferDesc. + uiXResolution, + pVideo->hidden-> + SrcBufferDesc.uiYResolution); } } #ifdef DEBUG_BUILD else printf ("WM_FSLIBNOTIFICATION : No public surface!\n"); - fflush (stdout); + fflush(stdout); #endif - DosReleaseMutexSem (pVideo->hidden->hmtxUseSrcBuffer); + DosReleaseMutexSem(pVideo->hidden->hmtxUseSrcBuffer); } } } @@ -744,95 +744,93 @@ case WM_ACTIVATE: #ifdef DEBUG_BUILD - printf ("WM_ACTIVATE\n"); - fflush (stdout); + printf("WM_ACTIVATE\n"); + fflush(stdout); #endif - pVideo = FSLib_GetUserParm (hwnd); + pVideo = FSLib_GetUserParm(hwnd); if (pVideo) { pVideo->hidden->fInFocus = (int) mp1; if (pVideo->hidden->fInFocus) { // Went into focus if ((pVideo->hidden->iMouseVisible) && (!bMouseCaptured)) - WinSetPointer (HWND_DESKTOP, - WinQuerySysPointer (HWND_DESKTOP, - SPTR_ARROW, FALSE)); + WinSetPointer(HWND_DESKTOP, + WinQuerySysPointer(HWND_DESKTOP, + SPTR_ARROW, FALSE)); else - WinSetPointer (HWND_DESKTOP, NULL); + WinSetPointer(HWND_DESKTOP, NULL); if (bMouseCapturable) { // Re-capture the mouse, if we captured it before! - WinSetCapture (HWND_DESKTOP, hwnd); + WinSetCapture(HWND_DESKTOP, hwnd); bMouseCaptured = 1; { SWP swpClient; POINTL ptl; // Center the mouse to the middle of the window! - WinQueryWindowPos (pVideo->hidden->hwndClient, - &swpClient); + WinQueryWindowPos(pVideo->hidden->hwndClient, + &swpClient); ptl.x = 0; ptl.y = 0; - WinMapWindowPoints (pVideo->hidden-> - hwndClient, HWND_DESKTOP, - &ptl, 1); + WinMapWindowPoints(pVideo->hidden-> + hwndClient, HWND_DESKTOP, &ptl, 1); pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ - WinSetPointerPos (HWND_DESKTOP, - ptl.x + swpClient.cx / 2, - ptl.y + swpClient.cy / 2); + WinSetPointerPos(HWND_DESKTOP, + ptl.x + swpClient.cx / 2, + ptl.y + swpClient.cy / 2); } } } else { // Went out of focus - WinSetPointer (HWND_DESKTOP, - WinQuerySysPointer (HWND_DESKTOP, - SPTR_ARROW, FALSE)); + WinSetPointer(HWND_DESKTOP, + WinQuerySysPointer(HWND_DESKTOP, + SPTR_ARROW, FALSE)); if (bMouseCaptured) { // Release the mouse - WinSetCapture (HWND_DESKTOP, hwnd); + WinSetCapture(HWND_DESKTOP, hwnd); bMouseCaptured = 0; } } } #ifdef DEBUG_BUILD - printf ("WM_ACTIVATE done\n"); - fflush (stdout); + printf("WM_ACTIVATE done\n"); + fflush(stdout); #endif break; case WM_BUTTON1DOWN: #ifdef DEBUG_BUILD - printf ("WM_BUTTON1DOWN\n"); - fflush (stdout); + printf("WM_BUTTON1DOWN\n"); + fflush(stdout); #endif - pVideo = FSLib_GetUserParm (hwnd); + pVideo = FSLib_GetUserParm(hwnd); if (pVideo) { - SDL_PrivateMouseButton (SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); // Don't report mouse movement! + SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); // Don't report mouse movement! if (bMouseCapturable) { // We should capture the mouse! if (!bMouseCaptured) { - WinSetCapture (HWND_DESKTOP, hwnd); - WinSetPointer (HWND_DESKTOP, NULL); + WinSetCapture(HWND_DESKTOP, hwnd); + WinSetPointer(HWND_DESKTOP, NULL); bMouseCaptured = 1; { SWP swpClient; POINTL ptl; // Center the mouse to the middle of the window! - WinQueryWindowPos (pVideo->hidden->hwndClient, - &swpClient); + WinQueryWindowPos(pVideo->hidden->hwndClient, + &swpClient); ptl.x = 0; ptl.y = 0; - WinMapWindowPoints (pVideo->hidden-> - hwndClient, HWND_DESKTOP, - &ptl, 1); + WinMapWindowPoints(pVideo->hidden-> + hwndClient, HWND_DESKTOP, &ptl, 1); pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ - WinSetPointerPos (HWND_DESKTOP, - ptl.x + swpClient.cx / 2, - ptl.y + swpClient.cy / 2); + WinSetPointerPos(HWND_DESKTOP, + ptl.x + swpClient.cx / 2, + ptl.y + swpClient.cy / 2); } } } @@ -840,42 +838,41 @@ break; case WM_BUTTON1UP: #ifdef DEBUG_BUILD - printf ("WM_BUTTON1UP\n"); - fflush (stdout); + printf("WM_BUTTON1UP\n"); + fflush(stdout); #endif - SDL_PrivateMouseButton (SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); // Don't report mouse movement! + SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); // Don't report mouse movement! break; case WM_BUTTON2DOWN: #ifdef DEBUG_BUILD - printf ("WM_BUTTON2DOWN\n"); - fflush (stdout); + printf("WM_BUTTON2DOWN\n"); + fflush(stdout); #endif - pVideo = FSLib_GetUserParm (hwnd); + pVideo = FSLib_GetUserParm(hwnd); if (pVideo) { - SDL_PrivateMouseButton (SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0); // Don't report mouse movement! + SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0); // Don't report mouse movement! if (bMouseCapturable) { // We should capture the mouse! if (!bMouseCaptured) { - WinSetCapture (HWND_DESKTOP, hwnd); - WinSetPointer (HWND_DESKTOP, NULL); + WinSetCapture(HWND_DESKTOP, hwnd); + WinSetPointer(HWND_DESKTOP, NULL); bMouseCaptured = 1; { SWP swpClient; POINTL ptl; // Center the mouse to the middle of the window! - WinQueryWindowPos (pVideo->hidden->hwndClient, - &swpClient); + WinQueryWindowPos(pVideo->hidden->hwndClient, + &swpClient); ptl.x = 0; ptl.y = 0; - WinMapWindowPoints (pVideo->hidden-> - hwndClient, HWND_DESKTOP, - &ptl, 1); + WinMapWindowPoints(pVideo->hidden-> + hwndClient, HWND_DESKTOP, &ptl, 1); pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ - WinSetPointerPos (HWND_DESKTOP, - ptl.x + swpClient.cx / 2, - ptl.y + swpClient.cy / 2); + WinSetPointerPos(HWND_DESKTOP, + ptl.x + swpClient.cx / 2, + ptl.y + swpClient.cy / 2); } } } @@ -884,42 +881,41 @@ break; case WM_BUTTON2UP: #ifdef DEBUG_BUILD - printf ("WM_BUTTON2UP\n"); - fflush (stdout); + printf("WM_BUTTON2UP\n"); + fflush(stdout); #endif - SDL_PrivateMouseButton (SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0); // Don't report mouse movement! + SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0); // Don't report mouse movement! break; case WM_BUTTON3DOWN: #ifdef DEBUG_BUILD - printf ("WM_BUTTON3DOWN\n"); - fflush (stdout); + printf("WM_BUTTON3DOWN\n"); + fflush(stdout); #endif - pVideo = FSLib_GetUserParm (hwnd); + pVideo = FSLib_GetUserParm(hwnd); if (pVideo) { - SDL_PrivateMouseButton (SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0); // Don't report mouse movement! + SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0); // Don't report mouse movement! if (bMouseCapturable) { // We should capture the mouse! if (!bMouseCaptured) { - WinSetCapture (HWND_DESKTOP, hwnd); - WinSetPointer (HWND_DESKTOP, NULL); + WinSetCapture(HWND_DESKTOP, hwnd); + WinSetPointer(HWND_DESKTOP, NULL); bMouseCaptured = 1; { SWP swpClient; POINTL ptl; // Center the mouse to the middle of the window! - WinQueryWindowPos (pVideo->hidden->hwndClient, - &swpClient); + WinQueryWindowPos(pVideo->hidden->hwndClient, + &swpClient); ptl.x = 0; ptl.y = 0; - WinMapWindowPoints (pVideo->hidden-> - hwndClient, HWND_DESKTOP, - &ptl, 1); + WinMapWindowPoints(pVideo->hidden-> + hwndClient, HWND_DESKTOP, &ptl, 1); pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ - WinSetPointerPos (HWND_DESKTOP, - ptl.x + swpClient.cx / 2, - ptl.y + swpClient.cy / 2); + WinSetPointerPos(HWND_DESKTOP, + ptl.x + swpClient.cx / 2, + ptl.y + swpClient.cy / 2); } } } @@ -927,17 +923,17 @@ break; case WM_BUTTON3UP: #ifdef DEBUG_BUILD - printf ("WM_BUTTON3UP\n"); - fflush (stdout); + printf("WM_BUTTON3UP\n"); + fflush(stdout); #endif - SDL_PrivateMouseButton (SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0); // Don't report mouse movement! + SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0); // Don't report mouse movement! break; case WM_MOUSEMOVE: #ifdef DEBUG_BUILD // printf("WM_MOUSEMOVE\n"); fflush(stdout); #endif - pVideo = FSLib_GetUserParm (hwnd); + pVideo = FSLib_GetUserParm(hwnd); if (pVideo) { if (pVideo->hidden->iSkipWMMOUSEMOVE) { pVideo->hidden->iSkipWMMOUSEMOVE--; @@ -948,33 +944,32 @@ if (bMouseCaptured) { SWP swpClient; - WinQueryWindowPos (pVideo->hidden->hwndClient, - &swpClient); + WinQueryWindowPos(pVideo->hidden->hwndClient, &swpClient); // Send relative mouse position, and re-center the mouse // Reposition the mouse to the center of the screen/window - SDL_PrivateMouseMotion (0, // Buttons not changed - 1, // Relative position - ppts->x - - (swpClient.cx / 2), - (swpClient.cy / 2) - ppts->y); + SDL_PrivateMouseMotion(0, // Buttons not changed + 1, // Relative position + ppts->x - + (swpClient.cx / 2), + (swpClient.cy / 2) - ppts->y); ptl.x = 0; ptl.y = 0; - WinMapWindowPoints (pVideo->hidden->hwndClient, - HWND_DESKTOP, &ptl, 1); + WinMapWindowPoints(pVideo->hidden->hwndClient, + HWND_DESKTOP, &ptl, 1); pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ // Center the mouse to the middle of the window! - WinSetPointerPos (HWND_DESKTOP, - ptl.x + swpClient.cx / 2, - ptl.y + swpClient.cy / 2); + WinSetPointerPos(HWND_DESKTOP, + ptl.x + swpClient.cx / 2, + ptl.y + swpClient.cy / 2); } else { - CONVERTMOUSEPOSITION (); + CONVERTMOUSEPOSITION(); // Send absolute mouse position - SDL_PrivateMouseMotion (0, // Buttons not changed - 0, // Absolute position - ppts->x, ppts->y); + SDL_PrivateMouseMotion(0, // Buttons not changed + 0, // Absolute position + ppts->x, ppts->y); } } if ((pVideo->hidden->iMouseVisible) && (!bMouseCaptured)) { @@ -983,13 +978,13 @@ #endif if (hptrGlobalPointer) - WinSetPointer (HWND_DESKTOP, hptrGlobalPointer); + WinSetPointer(HWND_DESKTOP, hptrGlobalPointer); else - WinSetPointer (HWND_DESKTOP, - WinQuerySysPointer (HWND_DESKTOP, - SPTR_ARROW, FALSE)); + WinSetPointer(HWND_DESKTOP, + WinQuerySysPointer(HWND_DESKTOP, + SPTR_ARROW, FALSE)); } else { - WinSetPointer (HWND_DESKTOP, NULL); + WinSetPointer(HWND_DESKTOP, NULL); } } #ifdef DEBUG_BUILD @@ -999,21 +994,21 @@ return (MRESULT) FALSE; case WM_CLOSE: // Window close #ifdef DEBUG_BUILD - printf ("WM_CLOSE\n"); - fflush (stdout); + printf("WM_CLOSE\n"); + fflush(stdout); #endif - pVideo = FSLib_GetUserParm (hwnd); + pVideo = FSLib_GetUserParm(hwnd); if (pVideo) { // Send Quit message to the SDL application! - SDL_PrivateQuit (); + SDL_PrivateQuit(); return 0; } break; #ifdef BITBLT_IN_WINMESSAGEPROC case WM_UPDATERECTSREQUEST: - pVideo = FSLib_GetUserParm (hwnd); + pVideo = FSLib_GetUserParm(hwnd); if ((pVideo) && (pVideo->hidden->pSDLSurface)) { if (DosRequestMutexSem (pVideo->hidden->hmtxUseSrcBuffer, @@ -1026,7 +1021,7 @@ numrects = (int) mp1; rects = (SDL_Rect *) mp2; - WinQueryWindowPos (hwnd, &swp); + WinQueryWindowPos(hwnd, &swp); #ifndef RESIZE_EVEN_IF_RESIZABLE if ((!pVideo->hidden->pSDLSurface) || ((pVideo->hidden->pSDLSurface) && @@ -1035,30 +1030,30 @@ ((swp.cx != pVideo->hidden->SrcBufferDesc.uiXResolution) || (swp.cy != pVideo->hidden->SrcBufferDesc.uiYResolution)) - && (!FSLib_QueryFSMode (hwnd)))) { + && (!FSLib_QueryFSMode(hwnd)))) { // Resizable surface and in resizing! // So, don't blit now! #ifdef DEBUG_BUILD printf ("[WM_UPDATERECTSREQUEST] : Skipping blit while resizing!\n"); - fflush (stdout); + fflush(stdout); #endif } else #endif { #ifdef DEBUG_BUILD - printf ("[WM_UPDATERECTSREQUEST] : Blitting!\n"); - fflush (stdout); + printf("[WM_UPDATERECTSREQUEST] : Blitting!\n"); + fflush(stdout); #endif // Blit the changed areas for (i = 0; i < numrects; i++) - FSLIB_BITBLT (hwnd, - pVideo->hidden->pchSrcBuffer, - rects[i].y, rects[i].x, - rects[i].w, rects[i].h); + FSLIB_BITBLT(hwnd, + pVideo->hidden->pchSrcBuffer, + rects[i].y, rects[i].x, + rects[i].w, rects[i].h); } - DosReleaseMutexSem (pVideo->hidden->hmtxUseSrcBuffer); + DosReleaseMutexSem(pVideo->hidden->hmtxUseSrcBuffer); } } return 0; @@ -1066,14 +1061,14 @@ default: #ifdef DEBUG_BUILD - printf ("Unhandled: %x\n", msg); - fflush (stdout); + printf("Unhandled: %x\n", msg); + fflush(stdout); #endif break; } // Run the default window procedure for unhandled stuffs - return WinDefWindowProc (hwnd, msg, mp1, mp2); + return WinDefWindowProc(hwnd, msg, mp1, mp2); } ///////////////////////////////////////////////////////////////////// @@ -1085,7 +1080,7 @@ // ///////////////////////////////////////////////////////////////////// static MRESULT EXPENTRY -FrameWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) +FrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { PFNWP pOldFrameProc; MRESULT result; @@ -1096,13 +1091,13 @@ SDL_VideoDevice *pVideo = NULL; - pVideo = (SDL_VideoDevice *) WinQueryWindowULong (hwnd, QWL_USER); + pVideo = (SDL_VideoDevice *) WinQueryWindowULong(hwnd, QWL_USER); pOldFrameProc = pVideo->hidden->pfnOldFrameProc; if ((pVideo->hidden->bProportionalResize) && (msg == WM_ADJUSTWINDOWPOS) && - (!FSLib_QueryFSMode (pVideo->hidden->hwndClient))) { + (!FSLib_QueryFSMode(pVideo->hidden->hwndClient))) { pswpTemp = (PSWP) mp1; /* Resizing? */ @@ -1112,7 +1107,7 @@ rclTemp.xRight = pswpTemp->x + pswpTemp->cx; rclTemp.yBottom = pswpTemp->y; rclTemp.yTop = pswpTemp->y + pswpTemp->cy; - WinCalcFrameRect (hwnd, &rclTemp, TRUE); + WinCalcFrameRect(hwnd, &rclTemp, TRUE); ncx = cx = rclTemp.xRight - rclTemp.xLeft; ncy = cy = rclTemp.yTop - rclTemp.yBottom; @@ -1138,7 +1133,7 @@ rclTemp.xRight = pswpTemp->x + ncx; rclTemp.yBottom = pswpTemp->y; rclTemp.yTop = pswpTemp->y + ncy; - WinCalcFrameRect (hwnd, &rclTemp, FALSE); + WinCalcFrameRect(hwnd, &rclTemp, FALSE); /* Store new size/position info */ pswpTemp->cx = rclTemp.xRight - rclTemp.xLeft; @@ -1178,7 +1173,7 @@ ///////////////////////////////////////////////////////////////////// int iNumOfPMThreadInstances = 0; // Global! static void -PMThreadFunc (void *pParm) +PMThreadFunc(void *pParm) { SDL_VideoDevice *pVideo = pParm; HAB hab; @@ -1187,22 +1182,22 @@ ULONG fcf; #ifdef DEBUG_BUILD - printf ("[PMThreadFunc] : Starting\n"); - fflush (stdout); + printf("[PMThreadFunc] : Starting\n"); + fflush(stdout); #endif iNumOfPMThreadInstances++; // Initialize PM, create a message queue. - hab = WinInitialize (0); - hmq = WinCreateMsgQueue (hab, 0); + hab = WinInitialize(0); + hmq = WinCreateMsgQueue(hab, 0); if (hmq == 0) { #ifdef DEBUG_BUILD - printf ("[PMThreadFunc] : Could not create message queue!\n"); + printf("[PMThreadFunc] : Could not create message queue!\n"); printf (" It might be that the application using SDL is not a PM app!\n"); - fflush (stdout); + fflush(stdout); #endif pVideo->hidden->iPMThreadStatus = 2; } else { @@ -1212,43 +1207,43 @@ fcf = ulFCFToUse; // Get from global setting #ifdef DEBUG_BUILD - printf ("[PMThreadFunc] : FSLib_CreateWindow()!\n"); - fflush (stdout); + printf("[PMThreadFunc] : FSLib_CreateWindow()!\n"); + fflush(stdout); #endif - rc = FSLib_CreateWindow (HWND_DESKTOP, 0, &fcf, - "SDL Application", - NULLHANDLE, 0, - &(pVideo->hidden->SrcBufferDesc), - WndProc, - &(pVideo->hidden->hwndClient), - &(pVideo->hidden->hwndFrame)); + rc = FSLib_CreateWindow(HWND_DESKTOP, 0, &fcf, + "SDL Application", + NULLHANDLE, 0, + &(pVideo->hidden->SrcBufferDesc), + WndProc, + &(pVideo->hidden->hwndClient), + &(pVideo->hidden->hwndFrame)); #ifdef DEBUG_BUILD - printf ("[PMThreadFunc] : FSLib_CreateWindow() rc = %d\n", rc); - fflush (stdout); + printf("[PMThreadFunc] : FSLib_CreateWindow() rc = %d\n", rc); + fflush(stdout); #endif if (!rc) { #ifdef DEBUG_BUILD - printf ("[PMThreadFunc] : Could not create FSLib window!\n"); - fflush (stdout); + printf("[PMThreadFunc] : Could not create FSLib window!\n"); + fflush(stdout); #endif pVideo->hidden->iPMThreadStatus = 3; } else { #ifdef DEBUG_BUILD - printf ("[PMThreadFunc] : FSLib_AddUserParm()!\n"); - fflush (stdout); + printf("[PMThreadFunc] : FSLib_AddUserParm()!\n"); + fflush(stdout); #endif // Store pVideo pointer in window data for client window, so // it will know the instance to which it belongs to. - FSLib_AddUserParm (pVideo->hidden->hwndClient, pVideo); + FSLib_AddUserParm(pVideo->hidden->hwndClient, pVideo); // Now set default image width height and fourcc! #ifdef DEBUG_BUILD - printf ("[PMThreadFunc] : SetWindowPos()!\n"); - fflush (stdout); + printf("[PMThreadFunc] : SetWindowPos()!\n"); + fflush(stdout); #endif // Set the position and size of the main window, @@ -1258,71 +1253,71 @@ rectl.yBottom = 0; rectl.xRight = pVideo->hidden->SrcBufferDesc.uiXResolution; // Noninclusive rectl.yTop = pVideo->hidden->SrcBufferDesc.uiYResolution; // Noninclusive - WinCalcFrameRect (pVideo->hidden->hwndFrame, &rectl, FALSE); - - SetAccessableWindowPos (pVideo->hidden->hwndFrame, - HWND_TOP, - (WinQuerySysValue - (HWND_DESKTOP, - SV_CXSCREEN) - (rectl.xRight - - rectl.xLeft)) / 2, - (WinQuerySysValue - (HWND_DESKTOP, - SV_CYSCREEN) - (rectl.yTop - - rectl.yBottom)) / 2, - (rectl.xRight - rectl.xLeft), - (rectl.yTop - rectl.yBottom), - SWP_SIZE | SWP_ACTIVATE | SWP_SHOW | - SWP_MOVE); + WinCalcFrameRect(pVideo->hidden->hwndFrame, &rectl, FALSE); + + SetAccessableWindowPos(pVideo->hidden->hwndFrame, + HWND_TOP, + (WinQuerySysValue + (HWND_DESKTOP, + SV_CXSCREEN) - (rectl.xRight - + rectl.xLeft)) / 2, + (WinQuerySysValue + (HWND_DESKTOP, + SV_CYSCREEN) - (rectl.yTop - + rectl.yBottom)) / 2, + (rectl.xRight - rectl.xLeft), + (rectl.yTop - rectl.yBottom), + SWP_SIZE | SWP_ACTIVATE | SWP_SHOW | + SWP_MOVE); // Subclass frame procedure and store old window proc address pVideo->hidden->pfnOldFrameProc = - WinSubclassWindow (pVideo->hidden->hwndFrame, FrameWndProc); - WinSetWindowULong (pVideo->hidden->hwndFrame, QWL_USER, - (ULONG) pVideo); + WinSubclassWindow(pVideo->hidden->hwndFrame, FrameWndProc); + WinSetWindowULong(pVideo->hidden->hwndFrame, QWL_USER, + (ULONG) pVideo); #ifdef DEBUG_BUILD - printf ("[PMThreadFunc] : Entering message loop\n"); - fflush (stdout); + printf("[PMThreadFunc] : Entering message loop\n"); + fflush(stdout); #endif pVideo->hidden->iPMThreadStatus = 1; - while (WinGetMsg (hab, (PQMSG) & msg, 0, 0, 0)) - WinDispatchMsg (hab, (PQMSG) & msg); + while (WinGetMsg(hab, (PQMSG) & msg, 0, 0, 0)) + WinDispatchMsg(hab, (PQMSG) & msg); #ifdef DEBUG_BUILD - printf ("[PMThreadFunc] : Leaving message loop\n"); - fflush (stdout); + printf("[PMThreadFunc] : Leaving message loop\n"); + fflush(stdout); #endif // We should release the captured the mouse! if (bMouseCaptured) { - WinSetCapture (HWND_DESKTOP, NULLHANDLE); + WinSetCapture(HWND_DESKTOP, NULLHANDLE); bMouseCaptured = 0; } // Destroy our window - WinDestroyWindow (pVideo->hidden->hwndFrame); + WinDestroyWindow(pVideo->hidden->hwndFrame); pVideo->hidden->hwndFrame = NULL; // Show pointer to make sure it will not be left hidden. - WinSetPointer (HWND_DESKTOP, - WinQuerySysPointer (HWND_DESKTOP, SPTR_ARROW, - FALSE)); - WinShowPointer (HWND_DESKTOP, TRUE); + WinSetPointer(HWND_DESKTOP, + WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, + FALSE)); + WinShowPointer(HWND_DESKTOP, TRUE); } // Uninitialize PM - WinDestroyMsgQueue (hmq); + WinDestroyMsgQueue(hmq); // All done! pVideo->hidden->iPMThreadStatus = 0; } - WinTerminate (hab); + WinTerminate(hab); /* Commented out, should not be needed anymore, because we send it from WM_CLOSE. // Notify SDL that it should really die now... SDL_PrivateQuit(); SDL_PrivateQuit(); SDL_PrivateQuit(); //... :)) */ #ifdef DEBUG_BUILD - printf ("[PMThreadFunc] : End, status is %d!\n", - pVideo->hidden->iPMThreadStatus); - fflush (stdout); + printf("[PMThreadFunc] : End, status is %d!\n", + pVideo->hidden->iPMThreadStatus); + fflush(stdout); #endif iNumOfPMThreadInstances--; @@ -1336,25 +1331,25 @@ // give time to the app to finish its execution. If it does not, I kill it // using DosExit(). Brute force, but should work. if (pVideo->hidden->iPMThreadStatus == 0) { - DosSleep (5000); // Wait 5 secs + DosSleep(5000); // Wait 5 secs // If a new PM thread has been spawned (reinitializing video mode), then all right. // Otherwise, we have a problem, the app doesn't want to stop. Kill! if (iNumOfPMThreadInstances == 0) { #ifdef DEBUG_BUILD printf ("[PMThreadFunc] : It seems that the application haven't terminated itself\n"); - fflush (stdout); + fflush(stdout); printf ("[PMThreadFunc] : in the last 5 seconds, so we go berserk.\n"); - fflush (stdout); + fflush(stdout); printf ("[PMThreadFunc] : Brute force mode. :) Killing process! Dieeeee...\n"); - fflush (stdout); + fflush(stdout); #endif - DosExit (EXIT_PROCESS, -1); + DosExit(EXIT_PROCESS, -1); } } - _endthread (); + _endthread(); } struct WMcursor @@ -1366,25 +1361,25 @@ /* Free a window manager cursor */ void -os2fslib_FreeWMCursor (_THIS, WMcursor * cursor) +os2fslib_FreeWMCursor(_THIS, WMcursor * cursor) { if (cursor) { - GpiDeleteBitmap (cursor->hbm); - WinDestroyPointer (cursor->hptr); - SDL_free (cursor->pchData); - SDL_free (cursor); + GpiDeleteBitmap(cursor->hbm); + WinDestroyPointer(cursor->hptr); + SDL_free(cursor->pchData); + SDL_free(cursor); } } /* Local functions to convert the SDL cursor mask into OS/2 format */ static void -memnot (Uint8 * dst, Uint8 * src, int len) +memnot(Uint8 * dst, Uint8 * src, int len) { while (len-- > 0) *dst++ = ~*src++; } static void -memxor (Uint8 * dst, Uint8 * src1, Uint8 * src2, int len) +memxor(Uint8 * dst, Uint8 * src1, Uint8 * src2, int len) { while (len-- > 0) *dst++ = (*src1++) ^ (*src2++); @@ -1392,8 +1387,8 @@ /* Create a black/white window manager cursor */ WMcursor * -os2fslib_CreateWMCursor_Win (_THIS, Uint8 * data, Uint8 * mask, - int w, int h, int hot_x, int hot_y) +os2fslib_CreateWMCursor_Win(_THIS, Uint8 * data, Uint8 * mask, + int w, int h, int hot_x, int hot_y) { HPOINTER hptr; HBITMAP hbm; @@ -1406,28 +1401,28 @@ int i, run, pad; WMcursor *pResult; - maxx = WinQuerySysValue (HWND_DESKTOP, SV_CXPOINTER); - maxy = WinQuerySysValue (HWND_DESKTOP, SV_CYPOINTER); + maxx = WinQuerySysValue(HWND_DESKTOP, SV_CXPOINTER); + maxy = WinQuerySysValue(HWND_DESKTOP, SV_CYPOINTER); // Check for max size! if ((w > maxx) || (h > maxy)) return (WMcursor *) NULL; - pResult = (WMcursor *) SDL_malloc (sizeof (WMcursor)); + pResult = (WMcursor *) SDL_malloc(sizeof(WMcursor)); if (!pResult) return (WMcursor *) NULL; - pchTemp = (char *) SDL_malloc ((maxx + 7) / 8 * maxy * 2); + pchTemp = (char *) SDL_malloc((maxx + 7) / 8 * maxy * 2); if (!pchTemp) { - SDL_free (pResult); + SDL_free(pResult); return (WMcursor *) NULL; } - SDL_memset (pchTemp, 0, (maxx + 7) / 8 * maxy * 2); - - hps = WinGetPS (_this->hidden->hwndClient); - - bmi.cbFix = sizeof (BITMAPINFOHEADER); + SDL_memset(pchTemp, 0, (maxx + 7) / 8 * maxy * 2); + + hps = WinGetPS(_this->hidden->hwndClient); + + bmi.cbFix = sizeof(BITMAPINFOHEADER); bmi.cx = maxx; bmi.cy = 2 * maxy; bmi.cPlanes = 1; @@ -1439,8 +1434,8 @@ bmi.argbColor[1].bGreen = 0x00; bmi.argbColor[1].bRed = 0xff; - SDL_memset (&bmih, 0, sizeof (BITMAPINFOHEADER)); - bmih.cbFix = sizeof (BITMAPINFOHEADER); + SDL_memset(&bmih, 0, sizeof(BITMAPINFOHEADER)); + bmih.cbFix = sizeof(BITMAPINFOHEADER); bmih.cx = maxx; bmih.cy = 2 * maxy; bmih.cPlanes = 1; @@ -1452,15 +1447,15 @@ for (i = 0; i < h; i++) { xptr = pchTemp + (maxx + 7) / 8 * (maxy - 1 - i); aptr = pchTemp + (maxx + 7) / 8 * (maxy + maxy - 1 - i); - memxor (xptr, data, mask, run); + memxor(xptr, data, mask, run); xptr += run; data += run; - memnot (aptr, mask, run); + memnot(aptr, mask, run); mask += run; aptr += run; - SDL_memset (xptr, 0, pad); + SDL_memset(xptr, 0, pad); xptr += pad; - SDL_memset (aptr, ~0, pad); + SDL_memset(aptr, ~0, pad); aptr += pad; } pad += run; @@ -1468,30 +1463,29 @@ xptr = pchTemp + (maxx + 7) / 8 * (maxy - 1 - i); aptr = pchTemp + (maxx + 7) / 8 * (maxy + maxy - 1 - i); - SDL_memset (xptr, 0, (maxx + 7) / 8); + SDL_memset(xptr, 0, (maxx + 7) / 8); xptr += (maxx + 7) / 8; - SDL_memset (aptr, ~0, (maxx + 7) / 8); + SDL_memset(aptr, ~0, (maxx + 7) / 8); aptr += (maxx + 7) / 8; } hbm = - GpiCreateBitmap (hps, (PBITMAPINFOHEADER2) & bmih, CBM_INIT, - (PBYTE) pchTemp, (PBITMAPINFO2) & bmi); - hptr = - WinCreatePointer (HWND_DESKTOP, hbm, TRUE, hot_x, maxy - hot_y - 1); + GpiCreateBitmap(hps, (PBITMAPINFOHEADER2) & bmih, CBM_INIT, + (PBYTE) pchTemp, (PBITMAPINFO2) & bmi); + hptr = WinCreatePointer(HWND_DESKTOP, hbm, TRUE, hot_x, maxy - hot_y - 1); #ifdef DEBUG_BUILD - printf ("HotSpot : %d ; %d\n", hot_x, hot_y); - printf ("HPS returned : %x\n", (ULONG) hps); - printf ("HBITMAP returned : %x\n", (ULONG) hbm); - printf ("HPOINTER returned: %x\n", (ULONG) hptr); + printf("HotSpot : %d ; %d\n", hot_x, hot_y); + printf("HPS returned : %x\n", (ULONG) hps); + printf("HBITMAP returned : %x\n", (ULONG) hbm); + printf("HPOINTER returned: %x\n", (ULONG) hptr); #endif - WinReleasePS (hps); + WinReleasePS(hps); #ifdef DEBUG_BUILD - printf ("[CreateWMCursor] : ptr = %p\n", hptr); - fflush (stdout); + printf("[CreateWMCursor] : ptr = %p\n", hptr); + fflush(stdout); #endif pResult->hptr = hptr; @@ -1499,20 +1493,20 @@ pResult->pchData = pchTemp; #ifdef DEBUG_BUILD - printf ("[CreateWMCursor] : ptr = %p return.\n", hptr); - fflush (stdout); + printf("[CreateWMCursor] : ptr = %p return.\n", hptr); + fflush(stdout); #endif return (WMcursor *) pResult; } WMcursor * -os2fslib_CreateWMCursor_FS (_THIS, Uint8 * data, Uint8 * mask, - int w, int h, int hot_x, int hot_y) +os2fslib_CreateWMCursor_FS(_THIS, Uint8 * data, Uint8 * mask, + int w, int h, int hot_x, int hot_y) { #ifdef DEBUG_BUILD - printf ("[CreateWMCursor_FS] : returning pointer NULL\n"); - fflush (stdout); + printf("[CreateWMCursor_FS] : returning pointer NULL\n"); + fflush(stdout); #endif // In FS mode we'll use software cursor @@ -1521,26 +1515,26 @@ /* Show the specified cursor, or hide if cursor is NULL */ int -os2fslib_ShowWMCursor (_THIS, WMcursor * cursor) +os2fslib_ShowWMCursor(_THIS, WMcursor * cursor) { #ifdef DEBUG_BUILD - printf ("[ShowWMCursor] : ptr = %p\n", cursor); - fflush (stdout); + printf("[ShowWMCursor] : ptr = %p\n", cursor); + fflush(stdout); #endif if (cursor) { - WinSetPointer (HWND_DESKTOP, cursor->hptr); + WinSetPointer(HWND_DESKTOP, cursor->hptr); hptrGlobalPointer = cursor->hptr; _this->hidden->iMouseVisible = 1; } else { - WinSetPointer (HWND_DESKTOP, FALSE); + WinSetPointer(HWND_DESKTOP, FALSE); hptrGlobalPointer = NULL; _this->hidden->iMouseVisible = 0; } #ifdef DEBUG_BUILD - printf ("[ShowWMCursor] : ptr = %p, DONE\n", cursor); - fflush (stdout); + printf("[ShowWMCursor] : ptr = %p, DONE\n", cursor); + fflush(stdout); #endif return 1; @@ -1550,32 +1544,31 @@ If NULL, a mouse motion event is posted internally. */ void -os2fslib_WarpWMCursor (_THIS, Uint16 x, Uint16 y) +os2fslib_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { LONG lx, ly; SWP swpClient; POINTL ptlPoints; - WinQueryWindowPos (_this->hidden->hwndClient, &swpClient); + WinQueryWindowPos(_this->hidden->hwndClient, &swpClient); ptlPoints.x = swpClient.x; ptlPoints.y = swpClient.y; - WinMapWindowPoints (_this->hidden->hwndFrame, HWND_DESKTOP, &ptlPoints, - 1); + WinMapWindowPoints(_this->hidden->hwndFrame, HWND_DESKTOP, &ptlPoints, 1); lx = ptlPoints.x + (x * swpClient.cx) / _this->hidden->SrcBufferDesc.uiXResolution; ly = ptlPoints.y + swpClient.cy - ((y * swpClient.cy) / _this->hidden->SrcBufferDesc.uiYResolution) - 1; - SDL_PrivateMouseMotion (0, // Buttons not changed - 0, // Absolute position - x, y); - - WinSetPointerPos (HWND_DESKTOP, lx, ly); + SDL_PrivateMouseMotion(0, // Buttons not changed + 0, // Absolute position + x, y); + + WinSetPointerPos(HWND_DESKTOP, lx, ly); } /* If not NULL, this is called when a mouse motion event occurs */ void -os2fslib_MoveWMCursor (_THIS, int x, int y) +os2fslib_MoveWMCursor(_THIS, int x, int y) { /* SDL_Rect rect; @@ -1601,12 +1594,12 @@ in higher accuracy sampling of the pointer motion. */ void -os2fslib_CheckMouseMode (_THIS) +os2fslib_CheckMouseMode(_THIS) { } static void -os2fslib_PumpEvents (_THIS) +os2fslib_PumpEvents(_THIS) { // Notify SDL that if window has been resized! if ((_this->hidden->pSDLSurface) && @@ -1617,8 +1610,8 @@ static time_t prev_time; time_t curr_time; - curr_time = time (NULL); - if ((difftime (curr_time, prev_time) >= 0.25) || (bWindowResized)) { + curr_time = time(NULL); + if ((difftime(curr_time, prev_time) >= 0.25) || (bWindowResized)) { // Make sure we won't flood the event queue with resize events, // only send them at 250 msecs! // (or when the window is resized) @@ -1626,10 +1619,10 @@ printf ("[os2fslib_PumpEvents] : Calling PrivateResize (%d %d).\n", iWindowSizeX, iWindowSizeY); - fflush (stdout); + fflush(stdout); #endif // Tell SDL the new size - SDL_PrivateResize (iWindowSizeX, iWindowSizeY); + SDL_PrivateResize(iWindowSizeX, iWindowSizeY); prev_time = curr_time; bWindowResized = 0; } @@ -1638,53 +1631,53 @@ /* We don't actually allow hardware surfaces other than the main one */ static int -os2fslib_AllocHWSurface (_THIS, SDL_Surface * surface) +os2fslib_AllocHWSurface(_THIS, SDL_Surface * surface) { return (-1); } static void -os2fslib_FreeHWSurface (_THIS, SDL_Surface * surface) +os2fslib_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } /* We need to wait for vertical retrace on page flipped displays */ static int -os2fslib_LockHWSurface (_THIS, SDL_Surface * surface) +os2fslib_LockHWSurface(_THIS, SDL_Surface * surface) { return (0); } static void -os2fslib_UnlockHWSurface (_THIS, SDL_Surface * surface) +os2fslib_UnlockHWSurface(_THIS, SDL_Surface * surface) { return; } static int -os2fslib_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +os2fslib_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { - printf ("[os2fslib_SetColors] : TODO!\n"); - fflush (stdout); + printf("[os2fslib_SetColors] : TODO!\n"); + fflush(stdout); // TODO: Implement paletted modes return (1); } static void -os2fslib_DestroyIcon (HWND hwndFrame) +os2fslib_DestroyIcon(HWND hwndFrame) { if (hptrCurrentIcon) { - WinDestroyPointer (hptrCurrentIcon); + WinDestroyPointer(hptrCurrentIcon); hptrCurrentIcon = NULL; - WinSendMsg (hwndFrame, WM_SETICON, NULL, NULL); + WinSendMsg(hwndFrame, WM_SETICON, NULL, NULL); } } /* Set the window icon image */ void -os2fslib_SetIcon (_THIS, SDL_Surface * icon, Uint8 * mask) +os2fslib_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask) { HWND hwndFrame; SDL_Surface *icon_rgb; @@ -1699,14 +1692,14 @@ SDL_Rect bounds; #ifdef DEBUG_BUILD - printf ("[os2fslib_SetIcon] : Creating and setting new icon\n"); - fflush (stdout); + printf("[os2fslib_SetIcon] : Creating and setting new icon\n"); + fflush(stdout); #endif - hwndFrame = WinQueryWindow (_this->hidden->hwndClient, QW_PARENT); + hwndFrame = WinQueryWindow(_this->hidden->hwndClient, QW_PARENT); // Make sure the old icon resource will be free'd! - os2fslib_DestroyIcon (hwndFrame); + os2fslib_DestroyIcon(hwndFrame); if ((!icon) || (!mask)) return; @@ -1714,33 +1707,33 @@ w = icon->w; h = icon->h; - maxx = WinQuerySysValue (HWND_DESKTOP, SV_CXICON); - maxy = WinQuerySysValue (HWND_DESKTOP, SV_CYICON); + maxx = WinQuerySysValue(HWND_DESKTOP, SV_CXICON); + maxy = WinQuerySysValue(HWND_DESKTOP, SV_CYICON); // Check for max size! if ((w > maxx) || (h > maxy)) return; - pchTemp = (char *) SDL_malloc (w * h * 2 * 4); + pchTemp = (char *) SDL_malloc(w * h * 2 * 4); if (!pchTemp) return; - SDL_memset (pchTemp, 0, w * h * 2 * 4); + SDL_memset(pchTemp, 0, w * h * 2 * 4); // Convert surface to RGB, if it's not RGB yet! - icon_rgb = SDL_CreateRGBSurface (SDL_SWSURFACE, icon->w, icon->h, - 32, 0, 0, 0, 0); + icon_rgb = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h, + 32, 0, 0, 0, 0); if (icon_rgb == NULL) { - SDL_free (pchTemp); + SDL_free(pchTemp); return; } bounds.x = 0; bounds.y = 0; bounds.w = icon->w; bounds.h = icon->h; - if (SDL_LowerBlit (icon, &bounds, icon_rgb, &bounds) < 0) { - SDL_FreeSurface (icon_rgb); - SDL_free (pchTemp); + if (SDL_LowerBlit(icon, &bounds, icon_rgb, &bounds) < 0) { + SDL_FreeSurface(icon_rgb); + SDL_free(pchTemp); return; } @@ -1797,35 +1790,35 @@ } // There is no more need for the RGB surface - SDL_FreeSurface (icon_rgb); - - hps = WinGetPS (_this->hidden->hwndClient); - - bmi.cbFix = sizeof (BITMAPINFOHEADER); + SDL_FreeSurface(icon_rgb); + + hps = WinGetPS(_this->hidden->hwndClient); + + bmi.cbFix = sizeof(BITMAPINFOHEADER); bmi.cx = w; bmi.cy = 2 * h; bmi.cPlanes = 1; bmi.cBitCount = 32; - SDL_memset (&bmih, 0, sizeof (BITMAPINFOHEADER)); - bmih.cbFix = sizeof (BITMAPINFOHEADER); + SDL_memset(&bmih, 0, sizeof(BITMAPINFOHEADER)); + bmih.cbFix = sizeof(BITMAPINFOHEADER); bmih.cx = w; bmih.cy = 2 * h; bmih.cPlanes = 1; bmih.cBitCount = 32; hbm = - GpiCreateBitmap (hps, (PBITMAPINFOHEADER2) & bmih, CBM_INIT, - (PBYTE) pchTemp, (PBITMAPINFO2) & bmi); - hptrIcon = WinCreatePointer (HWND_DESKTOP, hbm, FALSE, 0, 0); - - WinReleasePS (hps); + GpiCreateBitmap(hps, (PBITMAPINFOHEADER2) & bmih, CBM_INIT, + (PBYTE) pchTemp, (PBITMAPINFO2) & bmi); + hptrIcon = WinCreatePointer(HWND_DESKTOP, hbm, FALSE, 0, 0); + + WinReleasePS(hps); // Free pixel array - SDL_free (pchTemp); + SDL_free(pchTemp); // Change icon in frame window - WinSendMsg (hwndFrame, WM_SETICON, (MPARAM) hptrIcon, NULL); + WinSendMsg(hwndFrame, WM_SETICON, (MPARAM) hptrIcon, NULL); /* // Change icon in switchlist @@ -1853,7 +1846,7 @@ static void -os2fslib_SetCursorManagementFunctions (_THIS, int iForWindowedMode) +os2fslib_SetCursorManagementFunctions(_THIS, int iForWindowedMode) { if (iForWindowedMode) { _this->FreeWMCursor = os2fslib_FreeWMCursor; @@ -1874,7 +1867,7 @@ } static void -os2fslib_InitOSKeymap (_THIS) +os2fslib_InitOSKeymap(_THIS) { int i; @@ -2008,7 +2001,7 @@ window was actually iconified, it returns 0 otherwise. */ int -os2fslib_IconifyWindow (_THIS) +os2fslib_IconifyWindow(_THIS) { HAB hab; HMQ hmq; @@ -2019,28 +2012,28 @@ return 0; // Cannot do anything in fullscreen mode! - if (FSLib_QueryFSMode (_this->hidden->hwndClient)) + if (FSLib_QueryFSMode(_this->hidden->hwndClient)) return 0; // Make sure this thread is prepared for using the Presentation Manager! - hab = WinInitialize (0); - hmq = WinCreateMsgQueue (hab, 0); + hab = WinInitialize(0); + hmq = WinCreateMsgQueue(hab, 0); // Remember if there was an error at WinCreateMsgQueue(), because we don't // want to destroy somebody else's queue later. :) - hmqerror = WinGetLastError (hab); - - WinSetWindowPos (_this->hidden->hwndFrame, HWND_TOP, - 0, 0, 0, 0, SWP_MINIMIZE); + hmqerror = WinGetLastError(hab); + + WinSetWindowPos(_this->hidden->hwndFrame, HWND_TOP, + 0, 0, 0, 0, SWP_MINIMIZE); // Now destroy the message queue, if we've created it! - if (ERRORIDERROR (hmqerror) == 0) - WinDestroyMsgQueue (hmq); + if (ERRORIDERROR(hmqerror) == 0) + WinDestroyMsgQueue(hmq); return 1; } static SDL_GrabMode -os2fslib_GrabInput (_THIS, SDL_GrabMode mode) +os2fslib_GrabInput(_THIS, SDL_GrabMode mode) { HAB hab; HMQ hmq; @@ -2052,63 +2045,63 @@ return SDL_GRAB_OFF; // Make sure this thread is prepared for using the Presentation Manager! - hab = WinInitialize (0); - hmq = WinCreateMsgQueue (hab, 0); + hab = WinInitialize(0); + hmq = WinCreateMsgQueue(hab, 0); // Remember if there was an error at WinCreateMsgQueue(), because we don't // want to destroy somebody else's queue later. :) - hmqerror = WinGetLastError (hab); + hmqerror = WinGetLastError(hab); if (mode == SDL_GRAB_OFF) { #ifdef DEBUG_BUILD - printf ("[os2fslib_GrabInput] : Releasing mouse\n"); - fflush (stdout); + printf("[os2fslib_GrabInput] : Releasing mouse\n"); + fflush(stdout); #endif // Release the mouse bMouseCapturable = 0; if (bMouseCaptured) { - WinSetCapture (HWND_DESKTOP, NULLHANDLE); + WinSetCapture(HWND_DESKTOP, NULLHANDLE); bMouseCaptured = 0; } } else { #ifdef DEBUG_BUILD - printf ("[os2fslib_GrabInput] : Capturing mouse\n"); - fflush (stdout); + printf("[os2fslib_GrabInput] : Capturing mouse\n"); + fflush(stdout); #endif // Capture the mouse bMouseCapturable = 1; - if (WinQueryFocus (HWND_DESKTOP) == _this->hidden->hwndClient) { - WinSetCapture (HWND_DESKTOP, _this->hidden->hwndClient); + if (WinQueryFocus(HWND_DESKTOP) == _this->hidden->hwndClient) { + WinSetCapture(HWND_DESKTOP, _this->hidden->hwndClient); bMouseCaptured = 1; { SWP swpClient; POINTL ptl; // Center the mouse to the middle of the window! - WinQueryWindowPos (_this->hidden->hwndClient, &swpClient); + WinQueryWindowPos(_this->hidden->hwndClient, &swpClient); ptl.x = 0; ptl.y = 0; - WinMapWindowPoints (_this->hidden->hwndClient, - HWND_DESKTOP, &ptl, 1); + WinMapWindowPoints(_this->hidden->hwndClient, + HWND_DESKTOP, &ptl, 1); _this->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ - WinSetPointerPos (HWND_DESKTOP, - ptl.x + swpClient.cx / 2, - ptl.y + swpClient.cy / 2); + WinSetPointerPos(HWND_DESKTOP, + ptl.x + swpClient.cx / 2, + ptl.y + swpClient.cy / 2); } } } // Now destroy the message queue, if we've created it! - if (ERRORIDERROR (hmqerror) == 0) - WinDestroyMsgQueue (hmq); + if (ERRORIDERROR(hmqerror) == 0) + WinDestroyMsgQueue(hmq); return mode; } /* Set the title and icon text */ static void -os2fslib_SetCaption (_THIS, const char *title, const char *icon) +os2fslib_SetCaption(_THIS, const char *title, const char *icon) { HAB hab; HMQ hmq; @@ -2119,33 +2112,33 @@ return; // Make sure this thread is prepared for using the Presentation Manager! - hab = WinInitialize (0); - hmq = WinCreateMsgQueue (hab, 0); + hab = WinInitialize(0); + hmq = WinCreateMsgQueue(hab, 0); // Remember if there was an error at WinCreateMsgQueue(), because we don't // want to destroy somebody else's queue later. :) - hmqerror = WinGetLastError (hab); - - WinSetWindowText (_this->hidden->hwndFrame, (char *) title); + hmqerror = WinGetLastError(hab); + + WinSetWindowText(_this->hidden->hwndFrame, (char *) title); // Now destroy the message queue, if we've created it! - if (ERRORIDERROR (hmqerror) == 0) - WinDestroyMsgQueue (hmq); + if (ERRORIDERROR(hmqerror) == 0) + WinDestroyMsgQueue(hmq); } static int -os2fslib_ToggleFullScreen (_THIS, int on) +os2fslib_ToggleFullScreen(_THIS, int on) { #ifdef DEBUG_BUILD - printf ("[os2fslib_ToggleFullScreen] : %d\n", on); - fflush (stdout); + printf("[os2fslib_ToggleFullScreen] : %d\n", on); + fflush(stdout); #endif // If there is no more window, nothing we can do! if (_this->hidden->iPMThreadStatus != 1) return 0; - FSLib_ToggleFSMode (_this->hidden->hwndClient, on); + FSLib_ToggleFSMode(_this->hidden->hwndClient, on); /* Cursor manager functions to Windowed/FS mode */ - os2fslib_SetCursorManagementFunctions (_this, !on); + os2fslib_SetCursorManagementFunctions(_this, !on); return 1; } @@ -2154,7 +2147,7 @@ properly represent the current mouse focus and position. */ static void -os2fslib_UpdateMouse (_THIS) +os2fslib_UpdateMouse(_THIS) { POINTL ptl; HAB hab; @@ -2168,40 +2161,40 @@ // Make sure this thread is prepared for using the Presentation Manager! - hab = WinInitialize (0); - hmq = WinCreateMsgQueue (hab, 0); + hab = WinInitialize(0); + hmq = WinCreateMsgQueue(hab, 0); // Remember if there was an error at WinCreateMsgQueue(), because we don't // want to destroy somebody else's queue later. :) - hmqerror = WinGetLastError (hab); + hmqerror = WinGetLastError(hab); if (_this->hidden->fInFocus) { // If our app is in focus - SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); - SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS); - SDL_PrivateAppActive (1, SDL_APPACTIVE); - WinQueryPointerPos (HWND_DESKTOP, &ptl); - WinMapWindowPoints (HWND_DESKTOP, _this->hidden->hwndClient, &ptl, 1); - WinQueryWindowPos (_this->hidden->hwndClient, &swpClient); + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); + SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); + SDL_PrivateAppActive(1, SDL_APPACTIVE); + WinQueryPointerPos(HWND_DESKTOP, &ptl); + WinMapWindowPoints(HWND_DESKTOP, _this->hidden->hwndClient, &ptl, 1); + WinQueryWindowPos(_this->hidden->hwndClient, &swpClient); // Convert OS/2 mouse position to SDL position, and also scale it! ptl.x = ptl.x * _this->hidden->SrcBufferDesc.uiXResolution / swpClient.cx; ptl.y = ptl.y * _this->hidden->SrcBufferDesc.uiYResolution / swpClient.cy; ptl.y = _this->hidden->SrcBufferDesc.uiYResolution - ptl.y - 1; - SDL_PrivateMouseMotion (0, 0, (Sint16) (ptl.x), (Sint16) (ptl.y)); + SDL_PrivateMouseMotion(0, 0, (Sint16) (ptl.x), (Sint16) (ptl.y)); } else { // If we're not in focus - SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); - SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS); - SDL_PrivateAppActive (0, SDL_APPACTIVE); - SDL_PrivateMouseMotion (0, 0, (Sint16) - 1, (Sint16) - 1); + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); + SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); + SDL_PrivateAppActive(0, SDL_APPACTIVE); + SDL_PrivateMouseMotion(0, 0, (Sint16) - 1, (Sint16) - 1); } // Now destroy the message queue, if we've created it! - if (ERRORIDERROR (hmqerror) == 0) - WinDestroyMsgQueue (hmq); + if (ERRORIDERROR(hmqerror) == 0) + WinDestroyMsgQueue(hmq); } @@ -2209,15 +2202,15 @@ point to an appropriate update function for the current video mode */ static void -os2fslib_UpdateRects (_THIS, int numrects, SDL_Rect * rects) +os2fslib_UpdateRects(_THIS, int numrects, SDL_Rect * rects) { // If there is no more window, nothing we can do! if (_this->hidden->iPMThreadStatus != 1) return; #ifdef BITBLT_IN_WINMESSAGEPROC - WinSendMsg (_this->hidden->hwndClient, - WM_UPDATERECTSREQUEST, (MPARAM) numrects, (MPARAM) rects); + WinSendMsg(_this->hidden->hwndClient, + WM_UPDATERECTSREQUEST, (MPARAM) numrects, (MPARAM) rects); #else if (DosRequestMutexSem (_this->hidden->hmtxUseSrcBuffer, SEM_INDEFINITE_WAIT) == NO_ERROR) { @@ -2229,17 +2222,17 @@ // But only blit if the window is not resizable, or if // the window is resizable and the source buffer size is the // same as the destination buffer size! - WinQueryWindowPos (_this->hidden->hwndClient, &swp); + WinQueryWindowPos(_this->hidden->hwndClient, &swp); if ((_this->hidden->pSDLSurface) && (_this->hidden->pSDLSurface->flags & SDL_RESIZABLE) && ((swp.cx != _this->hidden->SrcBufferDesc.uiXResolution) || (swp.cy != _this->hidden->SrcBufferDesc.uiYResolution)) - && (!FSLib_QueryFSMode (_this->hidden->hwndClient))) { + && (!FSLib_QueryFSMode(_this->hidden->hwndClient))) { // Resizable surface and in resizing! // So, don't blit now! #ifdef DEBUG_BUILD - printf ("[UpdateRects] : Skipping blit while resizing!\n"); - fflush (stdout); + printf("[UpdateRects] : Skipping blit while resizing!\n"); + fflush(stdout); #endif } else #endif @@ -2252,29 +2245,29 @@ _this->hidden->SrcBufferDesc.uiYResolution); */ #ifdef DEBUG_BUILD - printf ("[os2fslib_UpdateRects] : Blitting!\n"); - fflush (stdout); + printf("[os2fslib_UpdateRects] : Blitting!\n"); + fflush(stdout); #endif // Blit the changed areas for (i = 0; i < numrects; i++) - FSLIB_BITBLT (_this->hidden->hwndClient, - _this->hidden->pchSrcBuffer, - rects[i].y, rects[i].x, rects[i].w, - rects[i].h); + FSLIB_BITBLT(_this->hidden->hwndClient, + _this->hidden->pchSrcBuffer, + rects[i].y, rects[i].x, rects[i].w, + rects[i].h); } } #ifdef DEBUG_BUILD else - printf ("[os2fslib_UpdateRects] : No public surface!\n"); - fflush (stdout); + printf("[os2fslib_UpdateRects] : No public surface!\n"); + fflush(stdout); #endif - DosReleaseMutexSem (_this->hidden->hmtxUseSrcBuffer); + DosReleaseMutexSem(_this->hidden->hmtxUseSrcBuffer); } #ifdef DEBUG_BUILD else - printf ("[os2fslib_UpdateRects] : Error in mutex!\n"); - fflush (stdout); + printf("[os2fslib_UpdateRects] : Error in mutex!\n"); + fflush(stdout); #endif #endif } @@ -2284,54 +2277,53 @@ or if the application is shutting down the video subsystem. */ static void -os2fslib_VideoQuit (_THIS) +os2fslib_VideoQuit(_THIS) { #ifdef DEBUG_BUILD - printf ("[os2fslib_VideoQuit]\n"); - fflush (stdout); + printf("[os2fslib_VideoQuit]\n"); + fflush(stdout); #endif // Close PM stuff if running! if (_this->hidden->iPMThreadStatus == 1) { int iTimeout; - WinPostMsg (_this->hidden->hwndFrame, WM_QUIT, (MPARAM) 0, - (MPARAM) 0); + WinPostMsg(_this->hidden->hwndFrame, WM_QUIT, (MPARAM) 0, (MPARAM) 0); // HACK: We had this line before: //DosWaitThread((TID *) &(_this->hidden->tidPMThread), DCWW_WAIT); // We don't use it, because the PMThread will never stop, or if it stops, // it will kill the whole process as a emergency fallback. // So, we only check for the iPMThreadStatus stuff! #ifdef DEBUG_BUILD - printf ("[os2fslib_VideoQuit] : Waiting for PM thread to die\n"); - fflush (stdout); + printf("[os2fslib_VideoQuit] : Waiting for PM thread to die\n"); + fflush(stdout); #endif iTimeout = 0; while ((_this->hidden->iPMThreadStatus == 1) && (iTimeout < 100)) { iTimeout++; - DosSleep (64); + DosSleep(64); } #ifdef DEBUG_BUILD - printf ("[os2fslib_VideoQuit] : End of wait.\n"); - fflush (stdout); + printf("[os2fslib_VideoQuit] : End of wait.\n"); + fflush(stdout); #endif if (_this->hidden->iPMThreadStatus == 1) { #ifdef DEBUG_BUILD - printf ("[os2fslib_VideoQuit] : Killing PM thread!\n"); - fflush (stdout); + printf("[os2fslib_VideoQuit] : Killing PM thread!\n"); + fflush(stdout); #endif _this->hidden->iPMThreadStatus = 0; - DosKillThread (_this->hidden->tidPMThread); + DosKillThread(_this->hidden->tidPMThread); if (_this->hidden->hwndFrame) { #ifdef DEBUG_BUILD - printf ("[os2fslib_VideoQuit] : Destroying PM window!\n"); - fflush (stdout); + printf("[os2fslib_VideoQuit] : Destroying PM window!\n"); + fflush(stdout); #endif - WinDestroyWindow (_this->hidden->hwndFrame); + WinDestroyWindow(_this->hidden->hwndFrame); _this->hidden->hwndFrame = NULL; } } @@ -2340,17 +2332,17 @@ // Free result of an old ListModes() call, because there is // no FreeListModes() call in SDL! if (_this->hidden->pListModesResult) { - SDL_free (_this->hidden->pListModesResult); + SDL_free(_this->hidden->pListModesResult); _this->hidden->pListModesResult = NULL; } // Free list of available fullscreen modes if (_this->hidden->pAvailableFSLibVideoModes) { - FSLib_FreeVideoModeList (_this->hidden->pAvailableFSLibVideoModes); + FSLib_FreeVideoModeList(_this->hidden->pAvailableFSLibVideoModes); _this->hidden->pAvailableFSLibVideoModes = NULL; } // Free application icon if we had one if (hptrCurrentIcon) { - WinDestroyPointer (hptrCurrentIcon); + WinDestroyPointer(hptrCurrentIcon); hptrCurrentIcon = NULL; } } @@ -2364,8 +2356,8 @@ should take care of cleaning up the current mode. */ static SDL_Surface * -os2fslib_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +os2fslib_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { static int bFirstCall = 1; FSLib_VideoMode_p pModeInfo, pModeInfoFound; @@ -2384,7 +2376,7 @@ printf ("[os2fslib_SetVideoMode] : Request for %dx%d @ %dBPP, flags=0x%x\n", width, height, bpp, flags); - fflush (stdout); + fflush(stdout); #endif // We don't support palette modes! @@ -2408,7 +2400,7 @@ printf ("[os2fslib_SetVideoMode] : Changed request to %dx%d @ %dBPP, flags=0x%x\n", width, height, bpp, flags); - fflush (stdout); + fflush(stdout); #endif // First check if there is such a video mode they want! @@ -2439,7 +2431,7 @@ #ifdef DEBUG_BUILD printf ("[os2fslib_SetVideoMode] : Requested video mode not found, looking for a similar one!\n"); - fflush (stdout); + fflush(stdout); #endif // Go through the video modes again, and find a similar resolution! pModeInfo = _this->hidden->pAvailableFSLibVideoModes; @@ -2465,27 +2457,26 @@ // If we did not find a good fullscreen mode, then return NULL if (!pModeInfoFound) { #ifdef DEBUG_BUILD - printf - ("[os2fslib_SetVideoMode] : Requested video mode not found!\n"); - fflush (stdout); + printf("[os2fslib_SetVideoMode] : Requested video mode not found!\n"); + fflush(stdout); #endif return NULL; } #ifdef DEBUG_BUILD - printf ("[os2fslib_SetVideoMode] : Found mode!\n"); - fflush (stdout); + printf("[os2fslib_SetVideoMode] : Found mode!\n"); + fflush(stdout); #endif // We'll possibly adjust the structure, so copy out the values // into TempModeInfo! - SDL_memcpy (&TempModeInfo, pModeInfoFound, sizeof (TempModeInfo)); + SDL_memcpy(&TempModeInfo, pModeInfoFound, sizeof(TempModeInfo)); pModeInfoFound = &TempModeInfo; if (flags & SDL_RESIZABLE) { #ifdef DEBUG_BUILD printf ("[os2fslib_SetVideoMode] : Requested mode is resizable, changing width/height\n"); - fflush (stdout); + fflush(stdout); #endif // Change width and height to requested one! TempModeInfo.uiXResolution = width; @@ -2495,51 +2486,51 @@ // We can try create new surface! // Make sure this thread is prepared for using the Presentation Manager! - hab = WinInitialize (0); - hmq = WinCreateMsgQueue (hab, 0); + hab = WinInitialize(0); + hmq = WinCreateMsgQueue(hab, 0); // Remember if there was an error at WinCreateMsgQueue(), because we don't // want to destroy somebody else's queue later. :) - hmqerror = WinGetLastError (hab); + hmqerror = WinGetLastError(hab); if (DosRequestMutexSem (_this->hidden->hmtxUseSrcBuffer, SEM_INDEFINITE_WAIT) == NO_ERROR) { #ifdef DEBUG_BUILD - printf ("[os2fslib_SetVideoMode] : Creating new SW surface\n"); - fflush (stdout); + printf("[os2fslib_SetVideoMode] : Creating new SW surface\n"); + fflush(stdout); #endif // Create new software surface! - pResult = SDL_CreateRGBSurface (SDL_SWSURFACE, - pModeInfoFound->uiXResolution, - pModeInfoFound->uiYResolution, - pModeInfoFound->uiBPP, - ((unsigned int) pModeInfoFound-> - PixelFormat. - ucRedMask) << pModeInfoFound-> - PixelFormat.ucRedPosition, - ((unsigned int) pModeInfoFound-> - PixelFormat. - ucGreenMask) << pModeInfoFound-> - PixelFormat.ucGreenPosition, - ((unsigned int) pModeInfoFound-> - PixelFormat. - ucBlueMask) << pModeInfoFound-> - PixelFormat.ucBluePosition, - ((unsigned int) pModeInfoFound-> - PixelFormat. - ucAlphaMask) << pModeInfoFound-> - PixelFormat.ucAlphaPosition); + pResult = SDL_CreateRGBSurface(SDL_SWSURFACE, + pModeInfoFound->uiXResolution, + pModeInfoFound->uiYResolution, + pModeInfoFound->uiBPP, + ((unsigned int) pModeInfoFound-> + PixelFormat. + ucRedMask) << pModeInfoFound-> + PixelFormat.ucRedPosition, + ((unsigned int) pModeInfoFound-> + PixelFormat. + ucGreenMask) << pModeInfoFound-> + PixelFormat.ucGreenPosition, + ((unsigned int) pModeInfoFound-> + PixelFormat. + ucBlueMask) << pModeInfoFound-> + PixelFormat.ucBluePosition, + ((unsigned int) pModeInfoFound-> + PixelFormat. + ucAlphaMask) << pModeInfoFound-> + PixelFormat.ucAlphaPosition); if (pResult == NULL) { - DosReleaseMutexSem (_this->hidden->hmtxUseSrcBuffer); - SDL_OutOfMemory (); + DosReleaseMutexSem(_this->hidden->hmtxUseSrcBuffer); + SDL_OutOfMemory(); return NULL; } #ifdef DEBUG_BUILD - printf ("[os2fslib_SetVideoMode] : Adjusting pixel format\n"); - fflush (stdout); + printf("[os2fslib_SetVideoMode] : Adjusting pixel format\n"); + fflush(stdout); #endif // Adjust pixel format mask! @@ -2578,24 +2569,24 @@ pModeInfoFound->uiScanLineSize = pResult->pitch; // Store new source buffer parameters! - SDL_memcpy (&(_this->hidden->SrcBufferDesc), pModeInfoFound, - sizeof (*pModeInfoFound)); + SDL_memcpy(&(_this->hidden->SrcBufferDesc), pModeInfoFound, + sizeof(*pModeInfoFound)); _this->hidden->pchSrcBuffer = pResult->pixels; #ifdef DEBUG_BUILD - printf ("[os2fslib_SetVideoMode] : Telling FSLib the stuffs\n"); - fflush (stdout); + printf("[os2fslib_SetVideoMode] : Telling FSLib the stuffs\n"); + fflush(stdout); #endif // Tell the FSLib window the new source image format - FSLib_SetSrcBufferDesc (_this->hidden->hwndClient, - &(_this->hidden->SrcBufferDesc)); + FSLib_SetSrcBufferDesc(_this->hidden->hwndClient, + &(_this->hidden->SrcBufferDesc)); if (((flags & SDL_RESIZABLE) == 0) || (bFirstCall)) { bFirstCall = 0; #ifdef DEBUG_BUILD - printf ("[os2fslib_SetVideoMode] : Modifying window size\n"); - fflush (stdout); + printf("[os2fslib_SetVideoMode] : Modifying window size\n"); + fflush(stdout); #endif // Calculate frame window size from client window size @@ -2603,45 +2594,44 @@ rectl.yBottom = 0; rectl.xRight = pModeInfoFound->uiXResolution; // Noninclusive rectl.yTop = pModeInfoFound->uiYResolution; // Noninclusive - WinCalcFrameRect (_this->hidden->hwndFrame, &rectl, FALSE); + WinCalcFrameRect(_this->hidden->hwndFrame, &rectl, FALSE); // Set the new size of the main window - SetAccessableWindowPos (_this->hidden->hwndFrame, - HWND_TOP, - 0, 0, - (rectl.xRight - rectl.xLeft), - (rectl.yTop - rectl.yBottom), - SWP_SIZE | SWP_ACTIVATE | SWP_SHOW); + SetAccessableWindowPos(_this->hidden->hwndFrame, + HWND_TOP, + 0, 0, + (rectl.xRight - rectl.xLeft), + (rectl.yTop - rectl.yBottom), + SWP_SIZE | SWP_ACTIVATE | SWP_SHOW); } // Set fullscreen mode flag, and switch to fullscreen if needed! if (flags & SDL_FULLSCREEN) { #ifdef DEBUG_BUILD printf ("[os2fslib_SetVideoMode] : Also trying to switch to fullscreen\n"); - fflush (stdout); + fflush(stdout); #endif - FSLib_ToggleFSMode (_this->hidden->hwndClient, 1); + FSLib_ToggleFSMode(_this->hidden->hwndClient, 1); /* Cursor manager functions to FS mode */ - os2fslib_SetCursorManagementFunctions (_this, 0); + os2fslib_SetCursorManagementFunctions(_this, 0); } else { #ifdef DEBUG_BUILD printf ("[os2fslib_SetVideoMode] : Also trying to switch to desktop mode\n"); - fflush (stdout); + fflush(stdout); #endif - FSLib_ToggleFSMode (_this->hidden->hwndClient, 0); + FSLib_ToggleFSMode(_this->hidden->hwndClient, 0); /* Cursor manager functions to Windowed mode */ - os2fslib_SetCursorManagementFunctions (_this, 1); + os2fslib_SetCursorManagementFunctions(_this, 1); } _this->hidden->pSDLSurface = pResult; - DosReleaseMutexSem (_this->hidden->hmtxUseSrcBuffer); + DosReleaseMutexSem(_this->hidden->hmtxUseSrcBuffer); } else { #ifdef DEBUG_BUILD - printf - ("[os2fslib_SetVideoMode] : Could not get hmtxUseSrcBuffer!\n"); - fflush (stdout); + printf("[os2fslib_SetVideoMode] : Could not get hmtxUseSrcBuffer!\n"); + fflush(stdout); #endif pResult = NULL; @@ -2650,25 +2640,25 @@ // As we have the new surface, we don't need the current one anymore! if ((pResult) && (current)) { #ifdef DEBUG_BUILD - printf ("[os2fslib_SetVideoMode] : Freeing old surface\n"); - fflush (stdout); + printf("[os2fslib_SetVideoMode] : Freeing old surface\n"); + fflush(stdout); #endif - SDL_FreeSurface (current); + SDL_FreeSurface(current); } // Redraw window - WinInvalidateRegion (_this->hidden->hwndClient, NULL, TRUE); + WinInvalidateRegion(_this->hidden->hwndClient, NULL, TRUE); // Now destroy the message queue, if we've created it! - if (ERRORIDERROR (hmqerror) == 0) { + if (ERRORIDERROR(hmqerror) == 0) { #ifdef DEBUG_BUILD - printf ("[os2fslib_SetVideoMode] : Destroying message queue\n"); - fflush (stdout); + printf("[os2fslib_SetVideoMode] : Destroying message queue\n"); + fflush(stdout); #endif - WinDestroyMsgQueue (hmq); + WinDestroyMsgQueue(hmq); } #ifdef DEBUG_BUILD - printf ("[os2fslib_SetVideoMode] : Done\n"); - fflush (stdout); + printf("[os2fslib_SetVideoMode] : Done\n"); + fflush(stdout); #endif /* We're done */ @@ -2681,15 +2671,15 @@ from largest to smallest. */ static SDL_Rect ** -os2fslib_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +os2fslib_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { #ifdef DEBUG_BUILD - printf ("[os2fslib_ListModes] : ListModes of %d Bpp\n", - format->BitsPerPixel); + printf("[os2fslib_ListModes] : ListModes of %d Bpp\n", + format->BitsPerPixel); #endif // Destroy result of previous call, if there is any if (_this->hidden->pListModesResult) { - SDL_free (_this->hidden->pListModesResult); + SDL_free(_this->hidden->pListModesResult); _this->hidden->pListModesResult = NULL; } // For resizable and windowed mode we support every resolution! @@ -2707,7 +2697,7 @@ pFSMode = _this->hidden->pAvailableFSLibVideoModes; while (pFSMode) { if (pFSMode->uiBPP == format->BitsPerPixel) { - SDL_Rect *pRect = (SDL_Rect *) SDL_malloc (sizeof (SDL_Rect)); + SDL_Rect *pRect = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect)); if (pRect) { // Fill description pRect->x = 0; @@ -2726,13 +2716,12 @@ // We're the first one to be inserted! _this->hidden->pListModesResult = - (SDL_Rect **) SDL_malloc (2 * - sizeof (SDL_Rect *)); + (SDL_Rect **) SDL_malloc(2 * sizeof(SDL_Rect *)); if (_this->hidden->pListModesResult) { _this->hidden->pListModesResult[0] = pRect; _this->hidden->pListModesResult[1] = NULL; } else { - SDL_free (pRect); + SDL_free(pRect); } } else { // We're not the first ones, so find the place where we @@ -2766,20 +2755,20 @@ #endif pNewList = - (SDL_Rect **) SDL_realloc (_this-> - hidden-> - pListModesResult, - (iNumOfSlots - + - 1) * - sizeof (SDL_Rect *)); + (SDL_Rect **) SDL_realloc(_this-> + hidden-> + pListModesResult, + (iNumOfSlots + + + 1) * + sizeof(SDL_Rect *)); if (pNewList) { for (i = iNumOfSlots; i > iPlace; i--) pNewList[i] = pNewList[i - 1]; pNewList[iPlace] = pRect; _this->hidden->pListModesResult = pNewList; } else { - SDL_free (pRect); + SDL_free(pRect); } } } @@ -2797,20 +2786,20 @@ "best" display pixel format, returning 0 or -1 if there's an error. */ static int -os2fslib_VideoInit (_THIS, SDL_PixelFormat * vformat) +os2fslib_VideoInit(_THIS, SDL_PixelFormat * vformat) { FSLib_VideoMode_p pDesktopMode; #ifdef DEBUG_BUILD - printf ("[os2fslib_VideoInit] : Enter\n"); - fflush (stdout); + printf("[os2fslib_VideoInit] : Enter\n"); + fflush(stdout); #endif // Report the best pixel format. For this, // we'll use the current desktop format. - pDesktopMode = FSLib_GetDesktopVideoMode (); + pDesktopMode = FSLib_GetDesktopVideoMode(); if (!pDesktopMode) { - SDL_SetError ("Could not query desktop video mode!"); + SDL_SetError("Could not query desktop video mode!"); #ifdef DEBUG_BUILD printf ("[os2fslib_VideoInit] : Could not query desktop video mode!\n"); @@ -2860,7 +2849,7 @@ _this->hidden->iSkipWMMOUSEMOVE = 0; _this->hidden->iMouseVisible = 1; - if (getenv ("SDL_USE_PROPORTIONAL_WINDOW")) + if (getenv("SDL_USE_PROPORTIONAL_WINDOW")) _this->hidden->bProportionalResize = 1; else { PPIB pib; @@ -2874,92 +2863,91 @@ */ _this->hidden->bProportionalResize = 0; - DosGetInfoBlocks (&tib, &pib); + DosGetInfoBlocks(&tib, &pib); pchTemp = pchFileName = pib->pib_pchcmd; while (*pchTemp) { if (*pchTemp == '\\') pchFileName = pchTemp + 1; pchTemp++; } - if (getenv ("HOME")) { - sprintf (achConfigFile, "%s\\.sdl.proportionals", - getenv ("HOME")); - hFile = fopen (achConfigFile, "rt"); + if (getenv("HOME")) { + sprintf(achConfigFile, "%s\\.sdl.proportionals", getenv("HOME")); + hFile = fopen(achConfigFile, "rt"); if (!hFile) { /* Seems like the file cannot be opened or does not exist. * Let's try to create it with defaults! */ - hFile = fopen (achConfigFile, "wt"); + hFile = fopen(achConfigFile, "wt"); if (hFile) { - fprintf (hFile, - "; This file is a config file of SDL/2, containing\n"); - fprintf (hFile, - "; the list of executables that must have proportional\n"); - fprintf (hFile, "; windows.\n"); - fprintf (hFile, ";\n"); - fprintf (hFile, - "; You can add executable filenames into this file,\n"); - fprintf (hFile, - "; one under the other. If SDL finds that a given\n"); - fprintf (hFile, - "; program is in this list, then that application\n"); - fprintf (hFile, - "; will have proportional windows, just like if\n"); - fprintf (hFile, - "; the SET SDL_USE_PROPORTIONAL_WINDOW env. variable\n"); - fprintf (hFile, - "; would have been set for that process.\n"); - fprintf (hFile, ";\n"); - fprintf (hFile, "\n"); - fprintf (hFile, "dosbox.exe\n"); - fclose (hFile); + fprintf(hFile, + "; This file is a config file of SDL/2, containing\n"); + fprintf(hFile, + "; the list of executables that must have proportional\n"); + fprintf(hFile, "; windows.\n"); + fprintf(hFile, ";\n"); + fprintf(hFile, + "; You can add executable filenames into this file,\n"); + fprintf(hFile, + "; one under the other. If SDL finds that a given\n"); + fprintf(hFile, + "; program is in this list, then that application\n"); + fprintf(hFile, + "; will have proportional windows, just like if\n"); + fprintf(hFile, + "; the SET SDL_USE_PROPORTIONAL_WINDOW env. variable\n"); + fprintf(hFile, + "; would have been set for that process.\n"); + fprintf(hFile, ";\n"); + fprintf(hFile, "\n"); + fprintf(hFile, "dosbox.exe\n"); + fclose(hFile); } - hFile = fopen (achConfigFile, "rt"); + hFile = fopen(achConfigFile, "rt"); } if (hFile) { - while (fgets (achConfigFile, sizeof (achConfigFile), hFile)) { + while (fgets(achConfigFile, sizeof(achConfigFile), hFile)) { /* Cut \n from end of string */ - while (achConfigFile[strlen (achConfigFile) - 1] + while (achConfigFile[strlen(achConfigFile) - 1] == '\n') - achConfigFile[strlen (achConfigFile) - 1] = 0; + achConfigFile[strlen(achConfigFile) - 1] = 0; /* Compare... */ - if (stricmp (achConfigFile, pchFileName) == 0) { + if (stricmp(achConfigFile, pchFileName) == 0) { /* Found it in config file! */ _this->hidden->bProportionalResize = 1; break; } } - fclose (hFile); + fclose(hFile); } } } - DosCreateMutexSem (NULL, &(_this->hidden->hmtxUseSrcBuffer), 0, FALSE); + DosCreateMutexSem(NULL, &(_this->hidden->hmtxUseSrcBuffer), 0, FALSE); // Now create our window with a default size // For this, we select the first available fullscreen mode as // current window size! - SDL_memcpy (&(_this->hidden->SrcBufferDesc), - _this->hidden->pAvailableFSLibVideoModes, - sizeof (_this->hidden->SrcBufferDesc)); + SDL_memcpy(&(_this->hidden->SrcBufferDesc), + _this->hidden->pAvailableFSLibVideoModes, + sizeof(_this->hidden->SrcBufferDesc)); // Allocate new video buffer! _this->hidden->pchSrcBuffer = - (char *) SDL_malloc (_this->hidden->pAvailableFSLibVideoModes-> - uiScanLineSize * - _this->hidden->pAvailableFSLibVideoModes-> - uiYResolution); + (char *) SDL_malloc(_this->hidden->pAvailableFSLibVideoModes-> + uiScanLineSize * + _this->hidden->pAvailableFSLibVideoModes-> + uiYResolution); if (!_this->hidden->pchSrcBuffer) { #ifdef DEBUG_BUILD printf ("[os2fslib_VideoInit] : Yikes, not enough memory for new video buffer!\n"); - fflush (stdout); + fflush(stdout); #endif - SDL_SetError ("Not enough memory for new video buffer!\n"); + SDL_SetError("Not enough memory for new video buffer!\n"); return -1; } // For this, we need a message processing thread. @@ -2967,30 +2955,30 @@ // what is related to PM _this->hidden->iPMThreadStatus = 0; _this->hidden->tidPMThread = - _beginthread (PMThreadFunc, NULL, 65536, (void *) _this); + _beginthread(PMThreadFunc, NULL, 65536, (void *) _this); if (_this->hidden->tidPMThread <= 0) { #ifdef DEBUG_BUILD - printf ("[os2fslib_VideoInit] : Could not create PM thread!\n"); + printf("[os2fslib_VideoInit] : Could not create PM thread!\n"); #endif - SDL_SetError ("Could not create PM thread"); + SDL_SetError("Could not create PM thread"); return -1; } #ifdef USE_DOSSETPRIORITY // Burst the priority of PM Thread! - DosSetPriority (PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, - _this->hidden->tidPMThread); + DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, + _this->hidden->tidPMThread); #endif // Wait for the PM thread to initialize! while (_this->hidden->iPMThreadStatus == 0) - DosSleep (32); + DosSleep(32); // If the PM thread could not set up everything, then // report an error! if (_this->hidden->iPMThreadStatus != 1) { #ifdef DEBUG_BUILD - printf ("[os2fslib_VideoInit] : PMThread reported an error : %d\n", - _this->hidden->iPMThreadStatus); + printf("[os2fslib_VideoInit] : PMThread reported an error : %d\n", + _this->hidden->iPMThreadStatus); #endif - SDL_SetError ("Error initializing PM thread"); + SDL_SetError("Error initializing PM thread"); return -1; } @@ -2999,26 +2987,26 @@ static void -os2fslib_DeleteDevice (_THIS) +os2fslib_DeleteDevice(_THIS) { #ifdef DEBUG_BUILD - printf ("[os2fslib_DeleteDevice]\n"); - fflush (stdout); + printf("[os2fslib_DeleteDevice]\n"); + fflush(stdout); #endif // Free used memory - FSLib_FreeVideoModeList (_this->hidden->pAvailableFSLibVideoModes); + FSLib_FreeVideoModeList(_this->hidden->pAvailableFSLibVideoModes); if (_this->hidden->pListModesResult) - SDL_free (_this->hidden->pListModesResult); + SDL_free(_this->hidden->pListModesResult); if (_this->hidden->pchSrcBuffer) - SDL_free (_this->hidden->pchSrcBuffer); - DosCloseMutexSem (_this->hidden->hmtxUseSrcBuffer); - SDL_free (_this->hidden); - SDL_free (_this); - FSLib_Uninitialize (); + SDL_free(_this->hidden->pchSrcBuffer); + DosCloseMutexSem(_this->hidden->hmtxUseSrcBuffer); + SDL_free(_this->hidden); + SDL_free(_this); + FSLib_Uninitialize(); } static int -os2fslib_Available (void) +os2fslib_Available(void) { // If we can run, it means that we could load FSLib, @@ -3027,12 +3015,12 @@ } static void -os2fslib_MorphToPM () +os2fslib_MorphToPM() { PPIB pib; PTIB tib; - DosGetInfoBlocks (&tib, &pib); + DosGetInfoBlocks(&tib, &pib); // Change flag from VIO to PM: if (pib->pib_ultype == 2) @@ -3040,36 +3028,35 @@ } static SDL_VideoDevice * -os2fslib_CreateDevice (int devindex) +os2fslib_CreateDevice(int devindex) { SDL_VideoDevice *device; #ifdef DEBUG_BUILD - printf ("[os2fslib_CreateDevice] : Enter\n"); - fflush (stdout); + printf("[os2fslib_CreateDevice] : Enter\n"); + fflush(stdout); #endif /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); // Also allocate memory for private data device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof (struct SDL_PrivateVideoData))); + SDL_malloc((sizeof(struct SDL_PrivateVideoData))); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) - SDL_free (device); + SDL_free(device); return NULL; } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ #ifdef DEBUG_BUILD - printf ("[os2fslib_CreateDevice] : VideoInit is %p\n", - os2fslib_VideoInit); - fflush (stdout); + printf("[os2fslib_CreateDevice] : VideoInit is %p\n", os2fslib_VideoInit); + fflush(stdout); #endif /* Initialization/Query functions */ @@ -3099,7 +3086,7 @@ device->GrabInput = os2fslib_GrabInput; device->GetWMInfo = NULL; /* Cursor manager functions to Windowed mode */ - os2fslib_SetCursorManagementFunctions (device, 1); + os2fslib_SetCursorManagementFunctions(device, 1); /* Event manager functions */ device->InitOSKeymap = os2fslib_InitOSKeymap; device->PumpEvents = os2fslib_PumpEvents; @@ -3108,20 +3095,20 @@ // Make sure we'll be able to use Win* API even if the application // was linked to be a VIO application! - os2fslib_MorphToPM (); + os2fslib_MorphToPM(); // Now initialize FSLib, and query available video modes! - if (!FSLib_Initialize ()) { + if (!FSLib_Initialize()) { // Could not initialize FSLib! #ifdef DEBUG_BUILD - printf ("[os2fslib_CreateDevice] : Could not initialize FSLib!\n"); + printf("[os2fslib_CreateDevice] : Could not initialize FSLib!\n"); #endif - SDL_SetError ("Could not initialize FSLib!"); - SDL_free (device->hidden); - SDL_free (device); + SDL_SetError("Could not initialize FSLib!"); + SDL_free(device->hidden); + SDL_free(device); return NULL; } - device->hidden->pAvailableFSLibVideoModes = FSLib_GetVideoModeList (); + device->hidden->pAvailableFSLibVideoModes = FSLib_GetVideoModeList(); return device; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/os2fslib/SDL_os2fslib.h --- a/src/video/os2fslib/SDL_os2fslib.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/os2fslib/SDL_os2fslib.h Mon May 29 04:04:35 2006 +0000 @@ -66,7 +66,7 @@ /* OS/2 specific backdoor function to be able to set FrameControlFlags of */ /* the SDL window before creating it. */ -extern DECLSPEC void SDLCALL SDL_OS2FSLIB_SetFCFToUse (ULONG ulFCF); +extern DECLSPEC void SDLCALL SDL_OS2FSLIB_SetFCFToUse(ULONG ulFCF); #endif /* _SDL_os2fslib_h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/photon/SDL_ph_events.c --- a/src/video/photon/SDL_ph_events.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/photon/SDL_ph_events.c Mon May 29 04:04:35 2006 +0000 @@ -44,14 +44,14 @@ /* The translation tables from a photon keysym to a SDL keysym */ static SDLKey ODD_keymap[256]; static SDLKey MISC_keymap[0xFF + 1]; -SDL_keysym *ph_TranslateKey (PhKeyEvent_t * key, SDL_keysym * keysym); +SDL_keysym *ph_TranslateKey(PhKeyEvent_t * key, SDL_keysym * keysym); /* Check to see if this is a repeated key. (idea shamelessly lifted from GII -- thanks guys! :) */ static int -ph_WarpedMotion (_THIS, PhEvent_t * winEvent) +ph_WarpedMotion(_THIS, PhEvent_t * winEvent) { - PhRect_t *rect = PhGetRects (winEvent); + PhRect_t *rect = PhGetRects(winEvent); int centre_x, centre_y; int dx, dy; @@ -64,11 +64,11 @@ dx = rect->ul.x - centre_x; dy = rect->ul.y - centre_y; - posted = SDL_PrivateMouseMotion (0, 1, dx, dy); + posted = SDL_PrivateMouseMotion(0, 1, dx, dy); /* Move mouse cursor to middle of the window */ - PtGetAbsPosition (window, &abs_x, &abs_y); - PhMoveCursorAbs (PhInputGroup (NULL), abs_x + centre_x, abs_y + centre_y); + PtGetAbsPosition(window, &abs_x, &abs_y); + PhMoveCursorAbs(PhInputGroup(NULL), abs_x + centre_x, abs_y + centre_y); return (posted); } @@ -77,25 +77,25 @@ * MOTION_BUTTON and MOTION_NOBUTTON */ static void -set_motion_sensitivity (_THIS, unsigned int flags) +set_motion_sensitivity(_THIS, unsigned int flags) { int rid; int fields = Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON; PhRegion_t region; if (window) { - rid = PtWidgetRid (window); - if (rid != 0 && PhRegionQuery (rid, ®ion, NULL, NULL, 0) == 0) { + rid = PtWidgetRid(window); + if (rid != 0 && PhRegionQuery(rid, ®ion, NULL, NULL, 0) == 0) { region.events_sense = (region.events_sense & ~fields) | (flags & fields); - PhRegionChange (Ph_REGION_EV_SENSE, 0, ®ion, NULL, NULL); + PhRegionChange(Ph_REGION_EV_SENSE, 0, ®ion, NULL, NULL); } } } /* Convert the photon button state value to an SDL value */ static Uint8 -ph2sdl_mousebutton (unsigned short button_state) +ph2sdl_mousebutton(unsigned short button_state) { Uint8 mouse_button = 0; @@ -110,7 +110,7 @@ } static int -ph_DispatchEvent (_THIS) +ph_DispatchEvent(_THIS) { int posted; PhRect_t *rect; @@ -126,9 +126,9 @@ case Ph_EV_BOUNDARY: { if (phevent->subtype == Ph_EV_PTR_ENTER) { - posted = SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); + posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); } else if (phevent->subtype == Ph_EV_PTR_LEAVE) { - posted = SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); + posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } } break; @@ -137,14 +137,14 @@ case Ph_EV_PTR_MOTION_NOBUTTON: { if (SDL_VideoSurface) { - pointerEvent = PhGetData (phevent); - rect = PhGetRects (phevent); + pointerEvent = PhGetData(phevent); + rect = PhGetRects(phevent); if (mouse_relative) { - posted = ph_WarpedMotion (this, phevent); + posted = ph_WarpedMotion(this, phevent); } else { posted = - SDL_PrivateMouseMotion (0, 0, rect->ul.x, rect->ul.y); + SDL_PrivateMouseMotion(0, 0, rect->ul.x, rect->ul.y); } } } @@ -152,20 +152,20 @@ case Ph_EV_BUT_PRESS: { - pointerEvent = PhGetData (phevent); - buttons = ph2sdl_mousebutton (pointerEvent->buttons); + pointerEvent = PhGetData(phevent); + buttons = ph2sdl_mousebutton(pointerEvent->buttons); if (buttons != 0) { - posted = SDL_PrivateMouseButton (SDL_PRESSED, buttons, 0, 0); + posted = SDL_PrivateMouseButton(SDL_PRESSED, buttons, 0, 0); } } break; case Ph_EV_BUT_RELEASE: { - pointerEvent = PhGetData (phevent); - buttons = ph2sdl_mousebutton (pointerEvent->buttons); + pointerEvent = PhGetData(phevent); + buttons = ph2sdl_mousebutton(pointerEvent->buttons); if (phevent->subtype == Ph_EV_RELEASE_REAL && buttons != 0) { - posted = SDL_PrivateMouseButton (SDL_RELEASED, buttons, 0, 0); + posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0); } else if (phevent->subtype == Ph_EV_RELEASE_PHANTOM) { /* If the mouse is outside the window, * only a phantom release event is sent, so @@ -173,9 +173,9 @@ * Not perfect, maybe checking the mouse button * state for Ph_EV_BOUNDARY events would be * better. */ - if ((SDL_GetAppState () & SDL_APPMOUSEFOCUS) == 0) { + if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) == 0) { posted = - SDL_PrivateMouseButton (SDL_RELEASED, buttons, 0, 0); + SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0); } } } @@ -183,23 +183,23 @@ case Ph_EV_WM: { - winEvent = PhGetData (phevent); + winEvent = PhGetData(phevent); /* losing focus */ if ((winEvent->event_f == Ph_WM_FOCUS) && (winEvent->event_state == Ph_WM_EVSTATE_FOCUSLOST)) { - set_motion_sensitivity (this, Ph_EV_PTR_MOTION_BUTTON); - posted = SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS); + set_motion_sensitivity(this, Ph_EV_PTR_MOTION_BUTTON); + posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); } /* gaining focus */ else if ((winEvent->event_f == Ph_WM_FOCUS) && (winEvent->event_state == Ph_WM_EVSTATE_FOCUS)) { - set_motion_sensitivity (this, -1); - posted = SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS); + set_motion_sensitivity(this, -1); + posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); } /* request quit */ else if (winEvent->event_f == Ph_WM_CLOSE) { - posted = SDL_PrivateQuit (); + posted = SDL_PrivateQuit(); } /* request hide/unhide */ else if (winEvent->event_f == Ph_WM_HIDE) { @@ -217,11 +217,10 @@ else if (winEvent->event_f == Ph_WM_RESIZE) { currently_maximized = 0; #if (_NTO_VERSION < 630) - SDL_PrivateResize (winEvent->size.w + 1, - winEvent->size.h + 1); + SDL_PrivateResize(winEvent->size.w + 1, winEvent->size.h + 1); #else /* QNX 6.3.0 have this bug fixed */ - SDL_PrivateResize (winEvent->size.w, winEvent->size.h); + SDL_PrivateResize(winEvent->size.w, winEvent->size.h); #endif /* _NTO_VERSION */ } /* request to move */ @@ -243,8 +242,8 @@ dst.h = current_overlay->hwdata->CurrentViewPort.size.h; current_overlay->hwdata->ischromakey = 0; error = - ph_DisplayYUVOverlay (this, current_overlay, - &src, &dst); + ph_DisplayYUVOverlay(this, current_overlay, + &src, &dst); if (!error) { current_overlay->hwdata->ischromakey = chromastate; current_overlay->hwdata->locked = lockedstate; @@ -271,7 +270,7 @@ int numrects; if (SDL_VideoSurface) { - rect = PhGetRects (phevent); + rect = PhGetRects(phevent); if (phevent->num_rects > PH_SDL_MAX_RECTS) { /* sorry, buffers underrun, we'll update only first PH_SDL_MAX_RECTS rects */ numrects = PH_SDL_MAX_RECTS; @@ -284,7 +283,7 @@ sdlrects[i].h = rect[i].lr.y - rect[i].ul.y + 1; } - this->UpdateRects (this, phevent->num_rects, sdlrects); + this->UpdateRects(this, phevent->num_rects, sdlrects); if (current_overlay != NULL) { int lockedstate = current_overlay->hwdata->locked; @@ -306,9 +305,8 @@ current_overlay->hwdata->CurrentViewPort.size.h; current_overlay->hwdata->forcedredraw = 1; error = - ph_DisplayYUVOverlay (this, - current_overlay, - &src, &dst); + ph_DisplayYUVOverlay(this, + current_overlay, &src, &dst); if (!error) { current_overlay->hwdata->forcedredraw = 0; current_overlay->hwdata->locked = lockedstate; @@ -325,7 +323,7 @@ posted = 0; - keyEvent = PhGetData (phevent); + keyEvent = PhGetData(phevent); if (Pk_KF_Key_Down & keyEvent->key_flags) { /* split the wheel events from real key events */ @@ -334,8 +332,8 @@ && ((keyEvent->key_flags & Pk_KF_Scan_Valid) == Pk_KF_Scan_Valid)) { posted = - SDL_PrivateMouseButton (SDL_PRESSED, - SDL_BUTTON_WHEELUP, 0, 0); + SDL_PrivateMouseButton(SDL_PRESSED, + SDL_BUTTON_WHEELUP, 0, 0); break; } if ((keyEvent->key_cap == Pk_Down) @@ -343,13 +341,13 @@ && ((keyEvent->key_flags & Pk_KF_Scan_Valid) == Pk_KF_Scan_Valid)) { posted = - SDL_PrivateMouseButton (SDL_PRESSED, - SDL_BUTTON_WHEELDOWN, 0, 0); + SDL_PrivateMouseButton(SDL_PRESSED, + SDL_BUTTON_WHEELDOWN, 0, 0); break; } posted = - SDL_PrivateKeyboard (SDL_PRESSED, - ph_TranslateKey (keyEvent, &keysym)); + SDL_PrivateKeyboard(SDL_PRESSED, + ph_TranslateKey(keyEvent, &keysym)); } else { /* must be key release */ /* split the wheel events from real key events */ @@ -358,8 +356,8 @@ && ((keyEvent->key_flags & Pk_KF_Scan_Valid) == Pk_KF_Scan_Valid)) { posted = - SDL_PrivateMouseButton (SDL_RELEASED, - SDL_BUTTON_WHEELUP, 0, 0); + SDL_PrivateMouseButton(SDL_RELEASED, + SDL_BUTTON_WHEELUP, 0, 0); break; } if ((keyEvent->key_cap == Pk_Down) @@ -367,13 +365,13 @@ && ((keyEvent->key_flags & Pk_KF_Scan_Valid) == Pk_KF_Scan_Valid)) { posted = - SDL_PrivateMouseButton (SDL_RELEASED, - SDL_BUTTON_WHEELDOWN, 0, 0); + SDL_PrivateMouseButton(SDL_RELEASED, + SDL_BUTTON_WHEELDOWN, 0, 0); break; } posted = - SDL_PrivateKeyboard (SDL_RELEASED, - ph_TranslateKey (keyEvent, &keysym)); + SDL_PrivateKeyboard(SDL_RELEASED, + ph_TranslateKey(keyEvent, &keysym)); } } break; @@ -383,7 +381,7 @@ if (phevent->subtype == Ph_OFFSCREEN_INVALID) { unsigned long *EvInfoData; - EvInfoData = (unsigned long *) PhGetData (phevent); + EvInfoData = (unsigned long *) PhGetData(phevent); switch (*EvInfoData) { case Pg_VIDEO_MODE_SWITCHED: @@ -413,17 +411,17 @@ /* perform a blocking read if no events available */ int -ph_Pending (_THIS) +ph_Pending(_THIS) { /* Flush the display connection and look to see if events are queued */ - PgFlush (); + PgFlush(); while (1) { - switch (PhEventPeek (phevent, EVENT_SIZE)) { + switch (PhEventPeek(phevent, EVENT_SIZE)) { case Ph_EVENT_MSG: return 1; case -1: - SDL_SetError ("ph_Pending(): PhEventNext failed.\n"); + SDL_SetError("ph_Pending(): PhEventNext failed.\n"); return 0; default: return 0; @@ -435,29 +433,29 @@ } void -ph_PumpEvents (_THIS) +ph_PumpEvents(_THIS) { /* Flush the display connection and look to see if events are queued */ - PgFlush (); + PgFlush(); - while (ph_Pending (this)) { - PtEventHandler (phevent); - ph_DispatchEvent (this); + while (ph_Pending(this)) { + PtEventHandler(phevent); + ph_DispatchEvent(this); } } void -ph_InitKeymap (void) +ph_InitKeymap(void) { int i; /* Odd keys used in international keyboards */ - for (i = 0; i < SDL_arraysize (ODD_keymap); ++i) { + for (i = 0; i < SDL_arraysize(ODD_keymap); ++i) { ODD_keymap[i] = SDLK_UNKNOWN; } /* Map the miscellaneous keys */ - for (i = 0; i < SDL_arraysize (MISC_keymap); ++i) { + for (i = 0; i < SDL_arraysize(MISC_keymap); ++i) { MISC_keymap[i] = SDLK_UNKNOWN; } @@ -543,7 +541,7 @@ static unsigned long cap; SDL_keysym * -ph_TranslateKey (PhKeyEvent_t * key, SDL_keysym * keysym) +ph_TranslateKey(PhKeyEvent_t * key, SDL_keysym * keysym) { /* 'sym' is set to the value of the key with modifiers applied to it. This member is valid only if Pk_KF_Sym_Valid is set in the key_flags. @@ -601,9 +599,9 @@ keysym->unicode = 10; break; default: - utf8len = PhKeyToMb (utf8, key); + utf8len = PhKeyToMb(utf8, key); if (utf8len > 0) { - utf8len = mbtowc (&unicode, utf8, utf8len); + utf8len = mbtowc(&unicode, utf8, utf8len); if (utf8len > 0) { keysym->unicode = unicode; } @@ -617,9 +615,9 @@ } void -ph_InitOSKeymap (_THIS) +ph_InitOSKeymap(_THIS) { - ph_InitKeymap (); + ph_InitKeymap(); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/photon/SDL_ph_events_c.h --- a/src/video/photon/SDL_ph_events_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/photon/SDL_ph_events_c.h Mon May 29 04:04:35 2006 +0000 @@ -31,8 +31,8 @@ #define EVENT_SIZE (sizeof(PhEvent_t) + 1000 + PH_EVENT_SAFETY_POOL) /* Functions to be exported */ -extern void ph_InitOSKeymap (_THIS); -extern void ph_PumpEvents (_THIS); +extern void ph_InitOSKeymap(_THIS); +extern void ph_PumpEvents(_THIS); #endif /* __SDL_PH_EVENTS_H__ */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/photon/SDL_ph_gl.c --- a/src/video/photon/SDL_ph_gl.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/photon/SDL_ph_gl.c Mon May 29 04:04:35 2006 +0000 @@ -34,21 +34,21 @@ #if (_NTO_VERSION < 630) void -ph_GL_SwapBuffers (_THIS) +ph_GL_SwapBuffers(_THIS) { - PgSetRegion (PtWidgetRid (window)); - PdOpenGLContextSwapBuffers (oglctx); + PgSetRegion(PtWidgetRid(window)); + PdOpenGLContextSwapBuffers(oglctx); } #else void -ph_GL_SwapBuffers (_THIS) +ph_GL_SwapBuffers(_THIS) { - qnxgl_swap_buffers (oglbuffers); + qnxgl_swap_buffers(oglbuffers); } #endif /* 6.3.0 */ int -ph_GL_GetAttribute (_THIS, SDL_GLattr attrib, int *value) +ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) { switch (attrib) { case SDL_GL_DOUBLEBUFFER: @@ -98,7 +98,7 @@ #if (_NTO_VERSION < 630) int -ph_GL_LoadLibrary (_THIS, const char *path) +ph_GL_LoadLibrary(_THIS, const char *path) { /* if code compiled with SDL_VIDEO_OPENGL, that mean that library already linked */ this->gl_config.driver_loaded = 1; @@ -107,7 +107,7 @@ } #else int -ph_GL_LoadLibrary (_THIS, const char *path) +ph_GL_LoadLibrary(_THIS, const char *path) { void *handle; int dlopen_flags = RTLD_WORLD | RTLD_GROUP; @@ -116,18 +116,18 @@ return 0; } - handle = dlopen (path, dlopen_flags); + handle = dlopen(path, dlopen_flags); if (handle == NULL) { - SDL_SetError ("ph_GL_LoadLibrary(): Could not load OpenGL library"); + SDL_SetError("ph_GL_LoadLibrary(): Could not load OpenGL library"); return -1; } this->gl_config.dll_handle = handle; this->gl_config.driver_loaded = 1; - SDL_strlcpy (this->gl_config.driver_path, path, - SDL_arraysize (this->gl_config.driver_path)); + SDL_strlcpy(this->gl_config.driver_path, path, + SDL_arraysize(this->gl_config.driver_path)); return 0; } @@ -135,26 +135,26 @@ #if (_NTO_VERSION < 630) void * -ph_GL_GetProcAddress (_THIS, const char *proc) +ph_GL_GetProcAddress(_THIS, const char *proc) { return NULL; } #else void * -ph_GL_GetProcAddress (_THIS, const char *proc) +ph_GL_GetProcAddress(_THIS, const char *proc) { void *function; if (this->gl_config.dll_handle == NULL) { - ph_GL_LoadLibrary (this, DEFAULT_OPENGL); + ph_GL_LoadLibrary(this, DEFAULT_OPENGL); if (this->gl_config.dll_handle == NULL) { return NULL; } } - function = qnxgl_get_func (proc, oglctx, 0); + function = qnxgl_get_func(proc, oglctx, 0); if (function == NULL) { - function = dlsym (this->gl_config.dll_handle, proc); + function = dlsym(this->gl_config.dll_handle, proc); } return function; @@ -163,24 +163,24 @@ #if (_NTO_VERSION < 630) int -ph_GL_MakeCurrent (_THIS) +ph_GL_MakeCurrent(_THIS) { - PgSetRegion (PtWidgetRid (window)); + PgSetRegion(PtWidgetRid(window)); if (oglctx != NULL) { - PhDCSetCurrent (oglctx); + PhDCSetCurrent(oglctx); } return 0; } #else int -ph_GL_MakeCurrent (_THIS) +ph_GL_MakeCurrent(_THIS) { - PgSetRegion (PtWidgetRid (window)); + PgSetRegion(PtWidgetRid(window)); if (oglctx != NULL) { - if (qnxgl_set_current (oglctx) == -1) { + if (qnxgl_set_current(oglctx) == -1) { return -1; } } @@ -194,7 +194,7 @@ /* This code is actual for the Photon3D Runtime which was available prior to 6.3 only */ int -ph_SetupOpenGLContext (_THIS, int width, int height, int bpp, Uint32 flags) +ph_SetupOpenGLContext(_THIS, int width, int height, int bpp, Uint32 flags) { PhDim_t dim; uint64_t OGLAttrib[PH_OGL_MAX_ATTRIBS]; @@ -205,13 +205,13 @@ dim.h = height; if ((oglctx != NULL) && (oglflags == flags) && (oglbpp == bpp)) { - PdOpenGLContextResize (oglctx, &dim); - PhDCSetCurrent (oglctx); + PdOpenGLContextResize(oglctx, &dim); + PhDCSetCurrent(oglctx); return 0; } else { if (oglctx != NULL) { - PhDCSetCurrent (NULL); - PhDCRelease (oglctx); + PhDCSetCurrent(NULL); + PhDCRelease(oglctx); oglctx = NULL; exposepost = 1; } @@ -236,9 +236,9 @@ OGLAttrib[OGLargc++] = PHOGL_ATTRIB_NONE; if (this->gl_config.double_buffer) { - oglctx = PdCreateOpenGLContext (2, &dim, 0, OGLAttrib); + oglctx = PdCreateOpenGLContext(2, &dim, 0, OGLAttrib); } else { - oglctx = PdCreateOpenGLContext (1, &dim, 0, OGLAttrib); + oglctx = PdCreateOpenGLContext(1, &dim, 0, OGLAttrib); } if (oglctx == NULL) { @@ -247,16 +247,16 @@ return -1; } - PhDCSetCurrent (oglctx); + PhDCSetCurrent(oglctx); - PtFlush (); + PtFlush(); oglflags = flags; oglbpp = bpp; if (exposepost != 0) { /* OpenGL context has been recreated, so report about this fact */ - SDL_PrivateExpose (); + SDL_PrivateExpose(); } return 0; @@ -267,7 +267,7 @@ /* This code is actual for the built-in PhGL support, which became available since 6.3 */ int -ph_SetupOpenGLContext (_THIS, int width, int height, int bpp, Uint32 flags) +ph_SetupOpenGLContext(_THIS, int width, int height, int bpp, Uint32 flags) { qnxgl_buf_attrib_t qnxgl_attribs[PH_OGL_MAX_ATTRIBS]; qnxgl_buf_attrib_t *qnxgl_attribs_slide; @@ -276,7 +276,7 @@ /* Initialize the OpenGL subsystem */ - num_interfaces = qnxgl_init (NULL, NULL, 0); + num_interfaces = qnxgl_init(NULL, NULL, 0); if (num_interfaces < 0) { SDL_SetError @@ -297,44 +297,43 @@ /* Depth size */ if (this->gl_config.depth_size) { - fprintf (stderr, "setted depth size %d\n", - this->gl_config.depth_size); + fprintf(stderr, "setted depth size %d\n", this->gl_config.depth_size); qnxgl_attribs_slide = - qnxgl_attrib_set_depth (qnxgl_attribs_slide, - this->gl_config.depth_size); + qnxgl_attrib_set_depth(qnxgl_attribs_slide, + this->gl_config.depth_size); } /* Stencil size */ if (this->gl_config.stencil_size) { qnxgl_attribs_slide = - qnxgl_attrib_set_stencil (qnxgl_attribs_slide, - this->gl_config.stencil_size); + qnxgl_attrib_set_stencil(qnxgl_attribs_slide, + this->gl_config.stencil_size); } /* The sum of the accum bits of each channel */ if ((this->gl_config.accum_red_size != 0) && (this->gl_config.accum_blue_size != 0) && (this->gl_config.accum_green_size != 0)) { - qnxgl_attribs_slide = qnxgl_attrib_set_accum (qnxgl_attribs_slide, - this->gl_config. - accum_red_size + - this->gl_config. - accum_blue_size + - this->gl_config. - accum_green_size + - this->gl_config. - accum_alpha_size); + qnxgl_attribs_slide = qnxgl_attrib_set_accum(qnxgl_attribs_slide, + this->gl_config. + accum_red_size + + this->gl_config. + accum_blue_size + + this->gl_config. + accum_green_size + + this->gl_config. + accum_alpha_size); } /* Stereo mode */ if (this->gl_config.stereo) { - qnxgl_attribs_slide = qnxgl_attrib_set_stereo (qnxgl_attribs_slide); + qnxgl_attribs_slide = qnxgl_attrib_set_stereo(qnxgl_attribs_slide); } /* Fullscreen mode */ if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { qnxgl_attribs_slide = - qnxgl_attrib_set_hint_fullscreen (qnxgl_attribs_slide); + qnxgl_attrib_set_hint_fullscreen(qnxgl_attribs_slide); } /* Double buffering mode */ @@ -345,55 +344,55 @@ } /* Loading the function pointers so we can use the extensions */ - GLPH_LOAD_FUNCS_GC (oglctx); + GLPH_LOAD_FUNCS_GC(oglctx); /* Set the buffers region to be that of our window's region */ qnxgl_attribs_slide = - glph_attrib_set_region (qnxgl_attribs_slide, PtWidgetRid (window)); + glph_attrib_set_region(qnxgl_attribs_slide, PtWidgetRid(window)); /* End of the attributes array */ - qnxgl_attribs_slide = qnxgl_attrib_set_end (qnxgl_attribs_slide); + qnxgl_attribs_slide = qnxgl_attrib_set_end(qnxgl_attribs_slide); /* Create the buffers with the specified color model */ - fprintf (stderr, "ARGB: %d, %d, %d, %d\n", this->gl_config.alpha_size, - this->gl_config.red_size, this->gl_config.green_size, - this->gl_config.blue_size); - oglbuffers = qnxgl_buffers_create (QNXGL_FORMAT_BEST_RGB, + fprintf(stderr, "ARGB: %d, %d, %d, %d\n", this->gl_config.alpha_size, + this->gl_config.red_size, this->gl_config.green_size, + this->gl_config.blue_size); + oglbuffers = qnxgl_buffers_create(QNXGL_FORMAT_BEST_RGB, /* __QNXGL_BUILD_FORMAT(0, __QNXGL_COLOR_MODEL_RGB, this->gl_config.alpha_size, this->gl_config.red_size, this->gl_config.green_size, this->gl_config.blue_size), */ - num_buffers, width, height, - qnxgl_attribs, -1); + num_buffers, width, height, + qnxgl_attribs, -1); if (oglbuffers == NULL) { SDL_SetError ("ph_SetupOpenGLContext(): failed to create OpenGL buffers !\n"); - qnxgl_finish (); + qnxgl_finish(); return -1; } /* Create a QNXGL context for the previously created buffer */ - oglctx = qnxgl_context_create (oglbuffers, NULL); + oglctx = qnxgl_context_create(oglbuffers, NULL); if (oglctx == NULL) { SDL_SetError ("ph_SetupOpenGLContext(): failed to create OpenGL context !\n"); - qnxgl_buffers_destroy (oglbuffers); - qnxgl_finish (); + qnxgl_buffers_destroy(oglbuffers); + qnxgl_finish(); return -1; } /* Attempt to make the context current so we can use OpenGL commands */ - if (qnxgl_set_current (oglctx) == -1) { + if (qnxgl_set_current(oglctx) == -1) { SDL_SetError ("ph_SetupOpenGLContext(): failed to make the OpenGL context current !\n"); - qnxgl_context_destroy (oglctx); - qnxgl_buffers_destroy (oglbuffers); - qnxgl_finish (); + qnxgl_context_destroy(oglctx); + qnxgl_buffers_destroy(oglbuffers); + qnxgl_finish(); return -1; } - PtFlush (); + PtFlush(); oglflags = flags; oglbpp = bpp; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/photon/SDL_ph_gl.h --- a/src/video/photon/SDL_ph_gl.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/photon/SDL_ph_gl.h Mon May 29 04:04:35 2006 +0000 @@ -29,14 +29,14 @@ #define DEFAULT_OPENGL "/usr/lib/libGL.so" #if SDL_VIDEO_OPENGL -void ph_GL_SwapBuffers (_THIS); -int ph_GL_GetAttribute (_THIS, SDL_GLattr attrib, int *value); -int ph_GL_LoadLibrary (_THIS, const char *path); -void *ph_GL_GetProcAddress (_THIS, const char *proc); -int ph_GL_MakeCurrent (_THIS); +void ph_GL_SwapBuffers(_THIS); +int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value); +int ph_GL_LoadLibrary(_THIS, const char *path); +void *ph_GL_GetProcAddress(_THIS, const char *proc); +int ph_GL_MakeCurrent(_THIS); -int ph_SetupOpenGLContext (_THIS, int width, int height, int bpp, - Uint32 flags); +int ph_SetupOpenGLContext(_THIS, int width, int height, int bpp, + Uint32 flags); #endif /* SDL_VIDEO_OPENGL */ #endif /* __SDL_PH_GL_H__ */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/photon/SDL_ph_image.c --- a/src/video/photon/SDL_ph_image.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/photon/SDL_ph_image.c Mon May 29 04:04:35 2006 +0000 @@ -33,7 +33,7 @@ #include "SDL_ph_gl.h" int -ph_SetupImage (_THIS, SDL_Surface * screen) +ph_SetupImage(_THIS, SDL_Surface * screen) { PgColor_t *palette = NULL; int type = 0; @@ -70,7 +70,7 @@ break; default: { - SDL_SetError ("ph_SetupImage(): unsupported bpp=%d !\n", bpp); + SDL_SetError("ph_SetupImage(): unsupported bpp=%d !\n", bpp); return -1; } break; @@ -79,28 +79,28 @@ /* palette emulation code */ if ((bpp == 8) && (desktoppal == SDLPH_PAL_EMULATE)) { /* creating image palette */ - palette = SDL_malloc (_Pg_MAX_PALETTE * sizeof (PgColor_t)); + palette = SDL_malloc(_Pg_MAX_PALETTE * sizeof(PgColor_t)); if (palette == NULL) { SDL_SetError ("ph_SetupImage(): can't allocate memory for palette !\n"); return -1; } - PgGetPalette (palette); + PgGetPalette(palette); /* using shared memory for speed (set last param to 1) */ if ((SDL_Image = - PhCreateImage (NULL, screen->w, screen->h, type, palette, - _Pg_MAX_PALETTE, 1)) == NULL) { + PhCreateImage(NULL, screen->w, screen->h, type, palette, + _Pg_MAX_PALETTE, 1)) == NULL) { SDL_SetError ("ph_SetupImage(): PhCreateImage() failed for bpp=8 !\n"); - SDL_free (palette); + SDL_free(palette); return -1; } } else { /* using shared memory for speed (set last param to 1) */ if ((SDL_Image = - PhCreateImage (NULL, screen->w, screen->h, type, NULL, 0, - 1)) == NULL) { + PhCreateImage(NULL, screen->w, screen->h, type, NULL, 0, + 1)) == NULL) { SDL_SetError ("ph_SetupImage(): PhCreateImage() failed for bpp=%d !\n", bpp); @@ -117,7 +117,7 @@ } int -ph_SetupOCImage (_THIS, SDL_Surface * screen) +ph_SetupOCImage(_THIS, SDL_Surface * screen) { int type = 0; int bpp; @@ -155,7 +155,7 @@ break; default: { - SDL_SetError ("ph_SetupOCImage(): unsupported bpp=%d !\n", bpp); + SDL_SetError("ph_SetupOCImage(): unsupported bpp=%d !\n", bpp); return -1; } break; @@ -163,8 +163,8 @@ /* Currently offscreen contexts with the same bit depth as display bpp only can be created */ OCImage.offscreen_context = - PdCreateOffscreenContext (0, screen->w, screen->h, - Pg_OSC_MEM_PAGE_ALIGN); + PdCreateOffscreenContext(0, screen->w, screen->h, + Pg_OSC_MEM_PAGE_ALIGN); if (OCImage.offscreen_context == NULL) { SDL_SetError @@ -175,13 +175,12 @@ screen->pitch = OCImage.offscreen_context->pitch; OCImage.dc_ptr = - (unsigned char *) PdGetOffscreenContextPtr (OCImage. - offscreen_context); + (unsigned char *) PdGetOffscreenContextPtr(OCImage.offscreen_context); if (OCImage.dc_ptr == NULL) { SDL_SetError ("ph_SetupOCImage(): PdGetOffscreenContextPtr function failed !\n"); - PhDCRelease (OCImage.offscreen_context); + PhDCRelease(OCImage.offscreen_context); return -1; } @@ -189,7 +188,7 @@ OCImage.CurrentFrameData = OCImage.FrameData0; OCImage.current = 0; - PhDCSetCurrent (OCImage.offscreen_context); + PhDCSetCurrent(OCImage.offscreen_context); screen->pixels = OCImage.CurrentFrameData; @@ -199,25 +198,25 @@ } int -ph_SetupFullScreenImage (_THIS, SDL_Surface * screen) +ph_SetupFullScreenImage(_THIS, SDL_Surface * screen) { OCImage.flags = screen->flags; /* Begin direct and fullscreen mode */ - if (!ph_EnterFullScreen (this, screen, PH_ENTER_DIRECTMODE)) { + if (!ph_EnterFullScreen(this, screen, PH_ENTER_DIRECTMODE)) { return -1; } /* store palette for fullscreen */ if ((screen->format->BitsPerPixel == 8) && (desktopbpp != 8)) { - PgGetPalette (savedpal); - PgGetPalette (syspalph); + PgGetPalette(savedpal); + PgGetPalette(syspalph); } OCImage.offscreen_context = - PdCreateOffscreenContext (0, 0, 0, - Pg_OSC_MAIN_DISPLAY | Pg_OSC_MEM_PAGE_ALIGN - | Pg_OSC_CRTC_SAFE); + PdCreateOffscreenContext(0, 0, 0, + Pg_OSC_MAIN_DISPLAY | Pg_OSC_MEM_PAGE_ALIGN + | Pg_OSC_CRTC_SAFE); if (OCImage.offscreen_context == NULL) { SDL_SetError ("ph_SetupFullScreenImage(): PdCreateOffscreenContext() function failed !\n"); @@ -226,8 +225,8 @@ if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { OCImage.offscreen_backcontext = - PdDupOffscreenContext (OCImage.offscreen_context, - Pg_OSC_MEM_PAGE_ALIGN | Pg_OSC_CRTC_SAFE); + PdDupOffscreenContext(OCImage.offscreen_context, + Pg_OSC_MEM_PAGE_ALIGN | Pg_OSC_CRTC_SAFE); if (OCImage.offscreen_backcontext == NULL) { SDL_SetError ("ph_SetupFullScreenImage(): PdCreateOffscreenContext(back) function failed !\n"); @@ -236,34 +235,33 @@ } OCImage.FrameData0 = - (unsigned char *) PdGetOffscreenContextPtr (OCImage. - offscreen_context); + (unsigned char *) PdGetOffscreenContextPtr(OCImage.offscreen_context); if (OCImage.FrameData0 == NULL) { SDL_SetError ("ph_SetupFullScreenImage(): PdGetOffscreenContextPtr() function failed !\n"); - ph_DestroyImage (this, screen); + ph_DestroyImage(this, screen); return -1; } if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { OCImage.FrameData1 = - (unsigned char *) PdGetOffscreenContextPtr (OCImage. - offscreen_backcontext); + (unsigned char *) PdGetOffscreenContextPtr(OCImage. + offscreen_backcontext); if (OCImage.FrameData1 == NULL) { SDL_SetError ("ph_SetupFullScreenImage(back): PdGetOffscreenContextPtr() function failed !\n"); - ph_DestroyImage (this, screen); + ph_DestroyImage(this, screen); return -1; } } /* wait for the hardware */ - PgFlush (); - PgWaitHWIdle (); + PgFlush(); + PgWaitHWIdle(); if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { OCImage.current = 0; - PhDCSetCurrent (OCImage.offscreen_context); + PhDCSetCurrent(OCImage.offscreen_context); screen->pitch = OCImage.offscreen_context->pitch; screen->pixels = OCImage.FrameData0; @@ -272,19 +270,19 @@ int i; for (i = 0; i < 40; i++) { - SDL_memset (screen->pixels + screen->pitch * i, 0x00, - screen->pitch); + SDL_memset(screen->pixels + screen->pitch * i, 0x00, + screen->pitch); } for (i = 440; i < 480; i++) { - SDL_memset (screen->pixels + screen->pitch * i, 0x00, - screen->pitch); + SDL_memset(screen->pixels + screen->pitch * i, 0x00, + screen->pitch); } screen->pixels += screen->pitch * 40; } - PgSwapDisplay (OCImage.offscreen_backcontext, 0); + PgSwapDisplay(OCImage.offscreen_backcontext, 0); } else { OCImage.current = 0; - PhDCSetCurrent (OCImage.offscreen_context); + PhDCSetCurrent(OCImage.offscreen_context); screen->pitch = OCImage.offscreen_context->pitch; screen->pixels = OCImage.FrameData0; @@ -293,12 +291,12 @@ int i; for (i = 0; i < 40; i++) { - SDL_memset (screen->pixels + screen->pitch * i, 0x00, - screen->pitch); + SDL_memset(screen->pixels + screen->pitch * i, 0x00, + screen->pitch); } for (i = 440; i < 480; i++) { - SDL_memset (screen->pixels + screen->pitch * i, 0x00, - screen->pitch); + SDL_memset(screen->pixels + screen->pitch * i, 0x00, + screen->pitch); } screen->pixels += screen->pitch * 40; } @@ -307,8 +305,8 @@ this->UpdateRects = ph_OCDCUpdate; /* wait for the hardware */ - PgFlush (); - PgWaitHWIdle (); + PgFlush(); + PgWaitHWIdle(); return 0; } @@ -316,7 +314,7 @@ #if SDL_VIDEO_OPENGL int -ph_SetupOpenGLImage (_THIS, SDL_Surface * screen) +ph_SetupOpenGLImage(_THIS, SDL_Surface * screen) { this->UpdateRects = ph_OpenGLUpdate; screen->pixels = NULL; @@ -324,7 +322,7 @@ #if (_NTO_VERSION >= 630) if ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { - if (!ph_EnterFullScreen (this, screen, PH_IGNORE_DIRECTMODE)) { + if (!ph_EnterFullScreen(this, screen, PH_IGNORE_DIRECTMODE)) { screen->flags &= ~SDL_FULLSCREEN; return -1; } @@ -344,19 +342,19 @@ #endif /* SDL_VIDEO_OPENGL */ void -ph_DestroyImage (_THIS, SDL_Surface * screen) +ph_DestroyImage(_THIS, SDL_Surface * screen) { #if SDL_VIDEO_OPENGL if (screen->flags & SDL_INTERNALOPENGL) { if (oglctx) { #if (_NTO_VERSION < 630) - PhDCSetCurrent (NULL); - PhDCRelease (oglctx); + PhDCSetCurrent(NULL); + PhDCRelease(oglctx); #else - qnxgl_context_destroy (oglctx); - qnxgl_buffers_destroy (oglbuffers); - qnxgl_finish (); + qnxgl_context_destroy(oglctx); + qnxgl_buffers_destroy(oglbuffers); + qnxgl_finish(); #endif /* 6.3.0 */ oglctx = NULL; oglbuffers = NULL; @@ -365,7 +363,7 @@ } #if (_NTO_VERSION >= 630) if (currently_fullscreen) { - ph_LeaveFullScreen (this); + ph_LeaveFullScreen(this); } #endif /* 6.3.0 */ @@ -376,21 +374,21 @@ if (currently_fullscreen) { /* if we right now in 8bpp fullscreen we must release palette */ if ((screen->format->BitsPerPixel == 8) && (desktopbpp != 8)) { - PgSetPalette (syspalph, 0, -1, 0, 0, 0); - PgSetPalette (savedpal, 0, 0, _Pg_MAX_PALETTE, - Pg_PALSET_GLOBAL | Pg_PALSET_FORCE_EXPOSE, 0); - PgFlush (); + PgSetPalette(syspalph, 0, -1, 0, 0, 0); + PgSetPalette(savedpal, 0, 0, _Pg_MAX_PALETTE, + Pg_PALSET_GLOBAL | Pg_PALSET_FORCE_EXPOSE, 0); + PgFlush(); } - ph_LeaveFullScreen (this); + ph_LeaveFullScreen(this); } if (OCImage.offscreen_context != NULL) { - PhDCRelease (OCImage.offscreen_context); + PhDCRelease(OCImage.offscreen_context); OCImage.offscreen_context = NULL; OCImage.FrameData0 = NULL; } if (OCImage.offscreen_backcontext != NULL) { - PhDCRelease (OCImage.offscreen_backcontext); + PhDCRelease(OCImage.offscreen_backcontext); OCImage.offscreen_backcontext = NULL; OCImage.FrameData1 = NULL; } @@ -399,10 +397,10 @@ if (SDL_Image) { /* if palette allocated, free it */ if (SDL_Image->palette) { - SDL_free (SDL_Image->palette); + SDL_free(SDL_Image->palette); } - PgShmemDestroy (SDL_Image->image); - SDL_free (SDL_Image); + PgShmemDestroy(SDL_Image->image); + SDL_free(SDL_Image); } /* Must be zeroed everytime */ @@ -414,13 +412,13 @@ } int -ph_UpdateHWInfo (_THIS) +ph_UpdateHWInfo(_THIS) { PgVideoModeInfo_t vmode; PgHWCaps_t hwcaps; /* Update video ram amount */ - if (PgGetGraphicsHWCaps (&hwcaps) < 0) { + if (PgGetGraphicsHWCaps(&hwcaps) < 0) { SDL_SetError ("ph_UpdateHWInfo(): GetGraphicsHWCaps() function failed !\n"); return -1; @@ -428,7 +426,7 @@ this->info.video_mem = hwcaps.currently_available_video_ram / 1024; /* obtain current mode capabilities */ - if (PgGetVideoModeInfo (hwcaps.current_video_mode, &vmode) < 0) { + if (PgGetVideoModeInfo(hwcaps.current_video_mode, &vmode) < 0) { SDL_SetError ("ph_UpdateHWInfo(): GetVideoModeInfo() function failed !\n"); return -1; @@ -478,59 +476,58 @@ } int -ph_SetupUpdateFunction (_THIS, SDL_Surface * screen, Uint32 flags) +ph_SetupUpdateFunction(_THIS, SDL_Surface * screen, Uint32 flags) { int setupresult = -1; - ph_DestroyImage (this, screen); + ph_DestroyImage(this, screen); #if SDL_VIDEO_OPENGL if (flags & SDL_INTERNALOPENGL) { - setupresult = ph_SetupOpenGLImage (this, screen); + setupresult = ph_SetupOpenGLImage(this, screen); } else { #endif if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { - setupresult = ph_SetupFullScreenImage (this, screen); + setupresult = ph_SetupFullScreenImage(this, screen); } else { if ((flags & SDL_HWSURFACE) == SDL_HWSURFACE) { - setupresult = ph_SetupOCImage (this, screen); + setupresult = ph_SetupOCImage(this, screen); } else { - setupresult = ph_SetupImage (this, screen); + setupresult = ph_SetupImage(this, screen); } } #if SDL_VIDEO_OPENGL } #endif if (setupresult != -1) { - ph_UpdateHWInfo (this); + ph_UpdateHWInfo(this); } return setupresult; } int -ph_AllocHWSurface (_THIS, SDL_Surface * surface) +ph_AllocHWSurface(_THIS, SDL_Surface * surface) { PgHWCaps_t hwcaps; if (surface->hwdata != NULL) { - SDL_SetError ("ph_AllocHWSurface(): hwdata already exists!\n"); + SDL_SetError("ph_AllocHWSurface(): hwdata already exists!\n"); return -1; } - surface->hwdata = SDL_malloc (sizeof (struct private_hwdata)); - SDL_memset (surface->hwdata, 0x00, sizeof (struct private_hwdata)); + surface->hwdata = SDL_malloc(sizeof(struct private_hwdata)); + SDL_memset(surface->hwdata, 0x00, sizeof(struct private_hwdata)); surface->hwdata->offscreenctx = - PdCreateOffscreenContext (0, surface->w, surface->h, - Pg_OSC_MEM_PAGE_ALIGN); + PdCreateOffscreenContext(0, surface->w, surface->h, + Pg_OSC_MEM_PAGE_ALIGN); if (surface->hwdata->offscreenctx == NULL) { SDL_SetError ("ph_AllocHWSurface(): PdCreateOffscreenContext() function failed !\n"); return -1; } - surface->pixels = - PdGetOffscreenContextPtr (surface->hwdata->offscreenctx); + surface->pixels = PdGetOffscreenContextPtr(surface->hwdata->offscreenctx); if (surface->pixels == NULL) { - PhDCRelease (surface->hwdata->offscreenctx); + PhDCRelease(surface->hwdata->offscreenctx); SDL_SetError ("ph_AllocHWSurface(): PdGetOffscreenContextPtr() function failed !\n"); return -1; @@ -545,16 +542,16 @@ if (PdCreateOffscreenLock (surface->hwdata->offscreenctx, &surface->hwdata->crlockparam) != EOK) { - PhDCRelease (surface->hwdata->offscreenctx); - SDL_SetError ("ph_AllocHWSurface(): Can't create offscreen lock !\n"); + PhDCRelease(surface->hwdata->offscreenctx); + SDL_SetError("ph_AllocHWSurface(): Can't create offscreen lock !\n"); return -1; } #endif /* 0 */ /* Update video ram amount */ - if (PgGetGraphicsHWCaps (&hwcaps) < 0) { - PdDestroyOffscreenLock (surface->hwdata->offscreenctx); - PhDCRelease (surface->hwdata->offscreenctx); + if (PgGetGraphicsHWCaps(&hwcaps) < 0) { + PdDestroyOffscreenLock(surface->hwdata->offscreenctx); + PhDCRelease(surface->hwdata->offscreenctx); SDL_SetError ("ph_AllocHWSurface(): GetGraphicsHWCaps() function failed !\n"); return -1; @@ -565,35 +562,34 @@ } void -ph_FreeHWSurface (_THIS, SDL_Surface * surface) +ph_FreeHWSurface(_THIS, SDL_Surface * surface) { PgHWCaps_t hwcaps; if (surface->hwdata == NULL) { - SDL_SetError ("ph_FreeHWSurface(): no hwdata!\n"); + SDL_SetError("ph_FreeHWSurface(): no hwdata!\n"); return; } if (surface->hwdata->offscreenctx == NULL) { - SDL_SetError - ("ph_FreeHWSurface(): no offscreen context to delete!\n"); + SDL_SetError("ph_FreeHWSurface(): no offscreen context to delete!\n"); return; } #if 0 /* FIXME */ /* unlock the offscreen context if it has been locked before destroy it */ - if (PdIsOffscreenLocked (surface->hwdata->offscreenctx) == Pg_OSC_LOCKED) { - PdUnlockOffscreen (surface->hwdata->offscreenctx); + if (PdIsOffscreenLocked(surface->hwdata->offscreenctx) == Pg_OSC_LOCKED) { + PdUnlockOffscreen(surface->hwdata->offscreenctx); } - PdDestroyOffscreenLock (surface->hwdata->offscreenctx); + PdDestroyOffscreenLock(surface->hwdata->offscreenctx); #endif /* 0 */ - PhDCRelease (surface->hwdata->offscreenctx); + PhDCRelease(surface->hwdata->offscreenctx); - SDL_free (surface->hwdata); + SDL_free(surface->hwdata); surface->hwdata = NULL; /* Update video ram amount */ - if (PgGetGraphicsHWCaps (&hwcaps) < 0) { + if (PgGetGraphicsHWCaps(&hwcaps) < 0) { SDL_SetError ("ph_FreeHWSurface(): GetGraphicsHWCaps() function failed !\n"); return; @@ -604,7 +600,7 @@ } int -ph_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst) +ph_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst) { if ((src->hwdata == NULL) && (src != this->screen)) { SDL_SetError @@ -642,7 +638,7 @@ } PgColor_t -ph_ExpandColor (_THIS, SDL_Surface * surface, Uint32 color) +ph_ExpandColor(_THIS, SDL_Surface * surface, Uint32 color) { Uint32 truecolor; @@ -653,9 +649,9 @@ if ((surface->format->palette) && (color <= surface->format->palette->ncolors)) { truecolor = - PgRGB (surface->format->palette->colors[color].r, - surface->format->palette->colors[color].g, - surface->format->palette->colors[color].b); + PgRGB(surface->format->palette->colors[color].r, + surface->format->palette->colors[color].g, + surface->format->palette->colors[color].b); } else { SDL_SetError ("ph_ExpandColor(): Color out of range for the 8bpp mode !\n"); @@ -706,7 +702,7 @@ } int -ph_FillHWRect (_THIS, SDL_Surface * surface, SDL_Rect * rect, Uint32 color) +ph_FillHWRect(_THIS, SDL_Surface * surface, SDL_Rect * rect, Uint32 color) { PgColor_t oldcolor; Uint32 truecolor; @@ -716,36 +712,36 @@ return -1; } - truecolor = ph_ExpandColor (this, surface, color); + truecolor = ph_ExpandColor(this, surface, color); if (truecolor == 0xFFFFFFFFUL) { return -1; } - oldcolor = PgSetFillColor (truecolor); + oldcolor = PgSetFillColor(truecolor); /* 640x400 videomode emulation */ if (videomode_emulatemode == 1) { ydisp += 40; } - PgDrawIRect (rect->x, rect->y + ydisp, rect->w + rect->x - 1, - rect->h + rect->y + ydisp - 1, Pg_DRAW_FILL); - PgSetFillColor (oldcolor); - PgFlush (); - PgWaitHWIdle (); + PgDrawIRect(rect->x, rect->y + ydisp, rect->w + rect->x - 1, + rect->h + rect->y + ydisp - 1, Pg_DRAW_FILL); + PgSetFillColor(oldcolor); + PgFlush(); + PgWaitHWIdle(); return 0; } int -ph_FlipHWSurface (_THIS, SDL_Surface * screen) +ph_FlipHWSurface(_THIS, SDL_Surface * screen) { PhArea_t farea; if ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { /* flush all drawing ops before blitting */ - PgFlush (); - PgWaitHWIdle (); + PgFlush(); + PgWaitHWIdle(); farea.pos.x = 0; farea.pos.y = 0; @@ -757,18 +753,18 @@ farea.pos.y += 40; } - PgContextBlitArea (OCImage.offscreen_context, &farea, - OCImage.offscreen_backcontext, &farea); + PgContextBlitArea(OCImage.offscreen_context, &farea, + OCImage.offscreen_backcontext, &farea); /* flush the blitting */ - PgFlush (); - PgWaitHWIdle (); + PgFlush(); + PgWaitHWIdle(); } return 0; } int -ph_LockHWSurface (_THIS, SDL_Surface * surface) +ph_LockHWSurface(_THIS, SDL_Surface * surface) { #if 0 /* FIXME */ @@ -781,20 +777,20 @@ surface->hwdata->lockparam.flags = 0; surface->hwdata->lockparam.time_out = NULL; lockresult = - PdLockOffscreen (surface->hwdata->offscreenctx, - &surface->hwdata->lockparam); + PdLockOffscreen(surface->hwdata->offscreenctx, + &surface->hwdata->lockparam); switch (lockresult) { case EOK: break; case Pg_OSC_LOCK_DEADLOCK: - SDL_SetError ("ph_LockHWSurface(): Deadlock detected !\n"); + SDL_SetError("ph_LockHWSurface(): Deadlock detected !\n"); return -1; case Pg_OSC_LOCK_INVALID: - SDL_SetError ("ph_LockHWSurface(): Lock invalid !\n"); + SDL_SetError("ph_LockHWSurface(): Lock invalid !\n"); return -1; default: - SDL_SetError ("ph_LockHWSurface(): Can't lock the surface !\n"); + SDL_SetError("ph_LockHWSurface(): Can't lock the surface !\n"); return -1; } #endif /* 0 */ @@ -803,7 +799,7 @@ } void -ph_UnlockHWSurface (_THIS, SDL_Surface * surface) +ph_UnlockHWSurface(_THIS, SDL_Surface * surface) { #if 0 /* FIXME */ @@ -813,8 +809,8 @@ return; } - if (PdIsOffscreenLocked (surface->hwdata->offscreenctx) == Pg_OSC_LOCKED) { - unlockresult = PdUnlockOffscreen (surface->hwdata->offscreenctx); + if (PdIsOffscreenLocked(surface->hwdata->offscreenctx) == Pg_OSC_LOCKED) { + unlockresult = PdUnlockOffscreen(surface->hwdata->offscreenctx); } #endif /* 0 */ @@ -822,8 +818,8 @@ } int -ph_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, - SDL_Rect * dstrect) +ph_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, + SDL_Rect * dstrect) { SDL_VideoDevice *this = current_video; PhArea_t srcarea; @@ -848,13 +844,13 @@ if (((src == this->screen) || (src->hwdata != NULL)) && ((dst == this->screen) || (dst->hwdata != NULL))) { if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { - ph_SetHWColorKey (this, src, src->format->colorkey); - PgChromaOn (); + ph_SetHWColorKey(this, src, src->format->colorkey); + PgChromaOn(); } if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) { - ph_SetHWAlpha (this, src, src->format->alpha); - PgAlphaOn (); + ph_SetHWAlpha(this, src, src->format->alpha); + PgAlphaOn(); } if (dst == this->screen) { @@ -862,33 +858,33 @@ /* blitting from main screen to main screen */ dstarea.pos.y += ydisp; srcarea.pos.y += ydisp; - PgContextBlitArea (OCImage.offscreen_context, &srcarea, - OCImage.offscreen_context, &dstarea); + PgContextBlitArea(OCImage.offscreen_context, &srcarea, + OCImage.offscreen_context, &dstarea); } else { /* blitting from offscreen to main screen */ dstarea.pos.y += ydisp; - PgContextBlitArea (src->hwdata->offscreenctx, &srcarea, - OCImage.offscreen_context, &dstarea); + PgContextBlitArea(src->hwdata->offscreenctx, &srcarea, + OCImage.offscreen_context, &dstarea); } } else { if (src == this->screen) { /* blitting from main screen to offscreen */ srcarea.pos.y += ydisp; - PgContextBlitArea (OCImage.offscreen_context, &srcarea, - dst->hwdata->offscreenctx, &dstarea); + PgContextBlitArea(OCImage.offscreen_context, &srcarea, + dst->hwdata->offscreenctx, &dstarea); } else { /* blitting offscreen to offscreen */ - PgContextBlitArea (src->hwdata->offscreenctx, &srcarea, - dst->hwdata->offscreenctx, &dstarea); + PgContextBlitArea(src->hwdata->offscreenctx, &srcarea, + dst->hwdata->offscreenctx, &dstarea); } } if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) { - PgAlphaOff (); + PgAlphaOff(); } if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { - PgChromaOff (); + PgChromaOff(); } } else { SDL_SetError @@ -896,55 +892,55 @@ return -1; } - PgFlush (); - PgWaitHWIdle (); + PgFlush(); + PgWaitHWIdle(); return 0; } int -ph_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key) +ph_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key) { if (this->info.blit_hw_CC != 1) { return -1; } if (surface->hwdata != NULL) { - surface->hwdata->colorkey = ph_ExpandColor (this, surface, key); + surface->hwdata->colorkey = ph_ExpandColor(this, surface, key); if (surface->hwdata->colorkey == 0xFFFFFFFFUL) { return -1; } } - PgSetChroma (surface->hwdata->colorkey, - Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW); + PgSetChroma(surface->hwdata->colorkey, + Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW); return 0; } int -ph_SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 alpha) +ph_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha) { if (this->info.blit_hw_A != 1) { return -1; } - PgSetAlphaBlend (NULL, alpha); + PgSetAlphaBlend(NULL, alpha); return 0; } #if SDL_VIDEO_OPENGL void -ph_OpenGLUpdate (_THIS, int numrects, SDL_Rect * rects) +ph_OpenGLUpdate(_THIS, int numrects, SDL_Rect * rects) { - this->GL_SwapBuffers (this); + this->GL_SwapBuffers(this); return; } #endif /* SDL_VIDEO_OPENGL */ void -ph_NormalUpdate (_THIS, int numrects, SDL_Rect * rects) +ph_NormalUpdate(_THIS, int numrects, SDL_Rect * rects) { PhPoint_t ph_pos; PhRect_t ph_rect; @@ -966,19 +962,19 @@ ph_rect.lr.x = rects[i].x + rects[i].w; ph_rect.lr.y = rects[i].y + rects[i].h; - if (PgDrawPhImageRectmx (&ph_pos, SDL_Image, &ph_rect, 0) < 0) { - SDL_SetError ("ph_NormalUpdate(): PgDrawPhImageRectmx failed!\n"); + if (PgDrawPhImageRectmx(&ph_pos, SDL_Image, &ph_rect, 0) < 0) { + SDL_SetError("ph_NormalUpdate(): PgDrawPhImageRectmx failed!\n"); return; } } - if (PgFlush () < 0) { - SDL_SetError ("ph_NormalUpdate(): PgFlush() function failed!\n"); + if (PgFlush() < 0) { + SDL_SetError("ph_NormalUpdate(): PgFlush() function failed!\n"); } } void -ph_OCUpdate (_THIS, int numrects, SDL_Rect * rects) +ph_OCUpdate(_THIS, int numrects, SDL_Rect * rects) { int i; @@ -986,12 +982,12 @@ PhArea_t src_rect; PhArea_t dest_rect; - PgSetTranslation (&zero, 0); - PgSetRegion (PtWidgetRid (window)); - PgSetClipping (0, NULL); + PgSetTranslation(&zero, 0); + PgSetRegion(PtWidgetRid(window)); + PgSetClipping(0, NULL); - PgFlush (); - PgWaitHWIdle (); + PgFlush(); + PgWaitHWIdle(); for (i = 0; i < numrects; ++i) { if (rects[i].w == 0) { /* Clipped? */ @@ -1012,22 +1008,22 @@ dest_rect.size.w = rects[i].w; dest_rect.size.h = rects[i].h; - PgContextBlitArea (OCImage.offscreen_context, &src_rect, NULL, - &dest_rect); + PgContextBlitArea(OCImage.offscreen_context, &src_rect, NULL, + &dest_rect); } - if (PgFlush () < 0) { - SDL_SetError ("ph_OCUpdate(): PgFlush failed.\n"); + if (PgFlush() < 0) { + SDL_SetError("ph_OCUpdate(): PgFlush failed.\n"); } } void -ph_OCDCUpdate (_THIS, int numrects, SDL_Rect * rects) +ph_OCDCUpdate(_THIS, int numrects, SDL_Rect * rects) { - PgWaitHWIdle (); + PgWaitHWIdle(); - if (PgFlush () < 0) { - SDL_SetError ("ph_OCDCUpdate(): PgFlush failed.\n"); + if (PgFlush() < 0) { + SDL_SetError("ph_OCDCUpdate(): PgFlush failed.\n"); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/photon/SDL_ph_image_c.h --- a/src/video/photon/SDL_ph_image_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/photon/SDL_ph_image_c.h Mon May 29 04:04:35 2006 +0000 @@ -35,28 +35,28 @@ Uint32 colorkey; }; -extern int ph_SetupImage (_THIS, SDL_Surface * screen); -extern void ph_DestroyImage (_THIS, SDL_Surface * screen); -extern int ph_SetupUpdateFunction (_THIS, SDL_Surface * screen, Uint32 flags); +extern int ph_SetupImage(_THIS, SDL_Surface * screen); +extern void ph_DestroyImage(_THIS, SDL_Surface * screen); +extern int ph_SetupUpdateFunction(_THIS, SDL_Surface * screen, Uint32 flags); -extern int ph_AllocHWSurface (_THIS, SDL_Surface * surface); -extern void ph_FreeHWSurface (_THIS, SDL_Surface * surface); -extern int ph_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst); -extern int ph_FillHWRect (_THIS, SDL_Surface * surface, SDL_Rect * rect, - Uint32 color); -extern int ph_LockHWSurface (_THIS, SDL_Surface * surface); -extern void ph_UnlockHWSurface (_THIS, SDL_Surface * surface); -extern int ph_FlipHWSurface (_THIS, SDL_Surface * surface); -extern int ph_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key); -extern int ph_SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 alpha); -extern int ph_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect); -extern int ph_UpdateHWInfo (_THIS); +extern int ph_AllocHWSurface(_THIS, SDL_Surface * surface); +extern void ph_FreeHWSurface(_THIS, SDL_Surface * surface); +extern int ph_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst); +extern int ph_FillHWRect(_THIS, SDL_Surface * surface, SDL_Rect * rect, + Uint32 color); +extern int ph_LockHWSurface(_THIS, SDL_Surface * surface); +extern void ph_UnlockHWSurface(_THIS, SDL_Surface * surface); +extern int ph_FlipHWSurface(_THIS, SDL_Surface * surface); +extern int ph_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key); +extern int ph_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha); +extern int ph_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); +extern int ph_UpdateHWInfo(_THIS); -extern void ph_NormalUpdate (_THIS, int numrects, SDL_Rect * rects); -extern void ph_OCUpdate (_THIS, int numrects, SDL_Rect * rects); -extern void ph_OCDCUpdate (_THIS, int numrects, SDL_Rect * rects); -extern void ph_OpenGLUpdate (_THIS, int numrects, SDL_Rect * rects); +extern void ph_NormalUpdate(_THIS, int numrects, SDL_Rect * rects); +extern void ph_OCUpdate(_THIS, int numrects, SDL_Rect * rects); +extern void ph_OCDCUpdate(_THIS, int numrects, SDL_Rect * rects); +extern void ph_OpenGLUpdate(_THIS, int numrects, SDL_Rect * rects); #endif /* __SDL_PH_IMAGE_H__ */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/photon/SDL_ph_modes.c --- a/src/video/photon/SDL_ph_modes.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/photon/SDL_ph_modes.c Mon May 29 04:04:35 2006 +0000 @@ -31,16 +31,16 @@ SDL_Rect *SDL_modearray[PH_MAX_VIDEOMODES]; static int -compare_modes_by_res (const void *mode1, const void *mode2) +compare_modes_by_res(const void *mode1, const void *mode2) { PgVideoModeInfo_t mode1_info; PgVideoModeInfo_t mode2_info; - if (PgGetVideoModeInfo (*(unsigned short *) mode1, &mode1_info) < 0) { + if (PgGetVideoModeInfo(*(unsigned short *) mode1, &mode1_info) < 0) { return 0; } - if (PgGetVideoModeInfo (*(unsigned short *) mode2, &mode2_info) < 0) { + if (PgGetVideoModeInfo(*(unsigned short *) mode2, &mode2_info) < 0) { return 0; } @@ -52,7 +52,7 @@ } SDL_Rect ** -ph_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +ph_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { int i = 0; int j = 0; @@ -62,7 +62,7 @@ SDL_modearray[i] = &SDL_modelist[i]; } - if (PgGetVideoModeList (&mode_list) < 0) { + if (PgGetVideoModeList(&mode_list) < 0) { SDL_SetError ("ph_ListModes(): PgGetVideoModeList() function failed !\n"); return NULL; @@ -71,7 +71,7 @@ mode_info.bits_per_pixel = 0; for (i = 0; i < mode_list.num_modes; i++) { - if (PgGetVideoModeInfo (mode_list.modes[i], &mode_info) < 0) { + if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) { SDL_SetError ("ph_ListModes(): PgGetVideoModeInfo() function failed on mode: 0x%X.\n", mode_list.modes[i]); @@ -100,7 +100,7 @@ } void -ph_FreeVideoModes (_THIS) +ph_FreeVideoModes(_THIS) { return; } @@ -108,13 +108,13 @@ /* return the mode associated with width, height and bpp */ /* if there is no mode then zero is returned */ int -ph_GetVideoMode (int width, int height, int bpp) +ph_GetVideoMode(int width, int height, int bpp) { int i; int modestage = 0; int closestmode = 0; - if (PgGetVideoModeList (&mode_list) < 0) { + if (PgGetVideoModeList(&mode_list) < 0) { return -1; } @@ -125,7 +125,7 @@ /* search list for exact match */ for (i = 0; i < mode_list.num_modes; i++) { - if (PgGetVideoModeInfo (mode_list.modes[i], &mode_info) < 0) { + if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) { return 0; } @@ -153,19 +153,19 @@ /* return the mode associated with width, height and bpp */ /* if requested bpp is not found the mode with closest bpp is returned */ int -get_mode_any_format (int width, int height, int bpp) +get_mode_any_format(int width, int height, int bpp) { int i, closest, delta, min_delta; - if (PgGetVideoModeList (&mode_list) < 0) { + if (PgGetVideoModeList(&mode_list) < 0) { return -1; } - SDL_qsort (mode_list.modes, mode_list.num_modes, sizeof (unsigned short), - compare_modes_by_res); + SDL_qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), + compare_modes_by_res); for (i = 0; i < mode_list.num_modes; i++) { - if (PgGetVideoModeInfo (mode_list.modes[i], &mode_info) < 0) { + if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) { return 0; } if ((mode_info.width == width) && (mode_info.height == height)) { @@ -180,10 +180,10 @@ return mode_list.modes[closest]; } - min_delta = abs (mode_info.bits_per_pixel - bpp); + min_delta = abs(mode_info.bits_per_pixel - bpp); while (1) { - if (PgGetVideoModeInfo (mode_list.modes[i], &mode_info) < 0) { + if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) { return 0; } @@ -195,7 +195,7 @@ closest = i; break; } else { - delta = abs (mode_info.bits_per_pixel - bpp); + delta = abs(mode_info.bits_per_pixel - bpp); if (delta < min_delta) { closest = i; min_delta = delta; @@ -211,13 +211,13 @@ } int -ph_ToggleFullScreen (_THIS, int on) +ph_ToggleFullScreen(_THIS, int on) { return -1; } int -ph_EnterFullScreen (_THIS, SDL_Surface * screen, int fmode) +ph_EnterFullScreen(_THIS, SDL_Surface * screen, int fmode) { PgDisplaySettings_t settings; int mode; @@ -228,21 +228,21 @@ /* Get the video mode and set it */ if (screen->flags & SDL_ANYFORMAT) { if ((mode = - get_mode_any_format (screen->w, screen->h, - screen->format->BitsPerPixel)) == 0) { + get_mode_any_format(screen->w, screen->h, + screen->format->BitsPerPixel)) == 0) { SDL_SetError ("ph_EnterFullScreen(): can't find appropriate video mode !\n"); return 0; } } else { if ((mode = - ph_GetVideoMode (screen->w, screen->h, - screen->format->BitsPerPixel)) == 0) { + ph_GetVideoMode(screen->w, screen->h, + screen->format->BitsPerPixel)) == 0) { SDL_SetError ("ph_EnterFullScreen(): can't find appropriate video mode !\n"); return 0; } - if (PgGetVideoModeInfo (mode, &mode_info) < 0) { + if (PgGetVideoModeInfo(mode, &mode_info) < 0) { SDL_SetError ("ph_EnterFullScreen(): can't get video mode capabilities !\n"); return 0; @@ -257,7 +257,7 @@ } /* save old video mode caps */ - PgGetVideoMode (&settings); + PgGetVideoMode(&settings); old_video_mode = settings.mode; old_refresh_rate = settings.refresh; @@ -266,14 +266,14 @@ settings.refresh = 0; settings.flags = 0; - refreshrate = SDL_getenv ("SDL_PHOTON_FULLSCREEN_REFRESH"); + refreshrate = SDL_getenv("SDL_PHOTON_FULLSCREEN_REFRESH"); if (refreshrate != NULL) { - if (SDL_sscanf (refreshrate, "%d", &refreshratenum) == 1) { + if (SDL_sscanf(refreshrate, "%d", &refreshratenum) == 1) { settings.refresh = refreshratenum; } } - if (PgSetVideoMode (&settings) < 0) { + if (PgSetVideoMode(&settings) < 0) { SDL_SetError ("ph_EnterFullScreen(): PgSetVideoMode() call failed !\n"); return 0; @@ -290,26 +290,26 @@ if (fmode == 0) { if (OCImage.direct_context == NULL) { OCImage.direct_context = - (PdDirectContext_t *) PdCreateDirectContext (); + (PdDirectContext_t *) PdCreateDirectContext(); if (!OCImage.direct_context) { SDL_SetError ("ph_EnterFullScreen(): Can't create direct context !\n"); - ph_LeaveFullScreen (this); + ph_LeaveFullScreen(this); return 0; } } - OCImage.oldDC = PdDirectStart (OCImage.direct_context); + OCImage.oldDC = PdDirectStart(OCImage.direct_context); } currently_fullscreen = 1; } - PgFlush (); + PgFlush(); return 1; } int -ph_LeaveFullScreen (_THIS) +ph_LeaveFullScreen(_THIS) { PgDisplaySettings_t oldmode_settings; @@ -323,12 +323,12 @@ /* release routines starts here */ { if (OCImage.direct_context) { - PdDirectStop (OCImage.direct_context); - PdReleaseDirectContext (OCImage.direct_context); + PdDirectStop(OCImage.direct_context); + PdReleaseDirectContext(OCImage.direct_context); OCImage.direct_context = NULL; } if (OCImage.oldDC) { - PhDCSetCurrent (OCImage.oldDC); + PhDCSetCurrent(OCImage.oldDC); OCImage.oldDC = NULL; } @@ -340,7 +340,7 @@ oldmode_settings.refresh = (unsigned short) old_refresh_rate; oldmode_settings.flags = 0; - if (PgSetVideoMode (&oldmode_settings) < 0) { + if (PgSetVideoMode(&oldmode_settings) < 0) { SDL_SetError ("Ph_LeaveFullScreen(): PgSetVideoMode() function failed !\n"); return 0; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/photon/SDL_ph_modes_c.h --- a/src/video/photon/SDL_ph_modes_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/photon/SDL_ph_modes_c.h Mon May 29 04:04:35 2006 +0000 @@ -31,15 +31,14 @@ #define PH_ENTER_DIRECTMODE 0 #define PH_IGNORE_DIRECTMODE 1 -extern SDL_Rect **ph_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -extern void ph_FreeVideoModes (_THIS); -extern int ph_ResizeFullScreen (_THIS); -extern int ph_EnterFullScreen (_THIS, SDL_Surface * screen, int fmode); -extern int ph_LeaveFullScreen (_THIS); -extern int ph_GetVideoMode (int width, int height, int bpp); -extern int get_mode_any_format (int width, int height, int bpp); -extern int ph_ToggleFullScreen (_THIS, int on); +extern SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags); +extern void ph_FreeVideoModes(_THIS); +extern int ph_ResizeFullScreen(_THIS); +extern int ph_EnterFullScreen(_THIS, SDL_Surface * screen, int fmode); +extern int ph_LeaveFullScreen(_THIS); +extern int ph_GetVideoMode(int width, int height, int bpp); +extern int get_mode_any_format(int width, int height, int bpp); +extern int ph_ToggleFullScreen(_THIS, int on); #endif /* __SDL_PH_MODES_H__ */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/photon/SDL_ph_mouse.c --- a/src/video/photon/SDL_ph_mouse.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/photon/SDL_ph_mouse.c Mon May 29 04:04:35 2006 +0000 @@ -32,46 +32,46 @@ }; void -ph_FreeWMCursor (_THIS, WMcursor * cursor) +ph_FreeWMCursor(_THIS, WMcursor * cursor) { if (window != NULL) { - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); - if (PtSetResource (window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_INHERIT, 0) + if (PtSetResource(window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_INHERIT, 0) < 0) { /* TODO: output error msg */ } - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); } - SDL_free (cursor); + SDL_free(cursor); } WMcursor * -ph_CreateWMCursor (_THIS, Uint8 * data, Uint8 * mask, int w, int h, int hot_x, - int hot_y) +ph_CreateWMCursor(_THIS, Uint8 * data, Uint8 * mask, int w, int h, int hot_x, + int hot_y) { WMcursor *cursor; int clen, i; unsigned char bit, databit, maskbit; /* Allocate and initialize the cursor memory */ - if ((cursor = (WMcursor *) SDL_malloc (sizeof (WMcursor))) == NULL) { - SDL_OutOfMemory (); + if ((cursor = (WMcursor *) SDL_malloc(sizeof(WMcursor))) == NULL) { + SDL_OutOfMemory(); return (NULL); } - SDL_memset (cursor, 0, sizeof (WMcursor)); + SDL_memset(cursor, 0, sizeof(WMcursor)); cursor->ph_cursor = - (PhCursorDef_t *) SDL_malloc (sizeof (PhCursorDef_t) + 32 * 4 * 2); + (PhCursorDef_t *) SDL_malloc(sizeof(PhCursorDef_t) + 32 * 4 * 2); if (cursor->ph_cursor == NULL) { - SDL_SetError ("ph_CreateWMCursor(): cursor malloc failed !\n"); + SDL_SetError("ph_CreateWMCursor(): cursor malloc failed !\n"); return NULL; } - SDL_memset (cursor->ph_cursor, 0, (sizeof (PhCursorDef_t) + 32 * 4 * 2)); + SDL_memset(cursor->ph_cursor, 0, (sizeof(PhCursorDef_t) + 32 * 4 * 2)); cursor->ph_cursor->hdr.type = Ph_RDATA_CURSOR; cursor->ph_cursor->size1.x = (short) w; @@ -104,19 +104,19 @@ /* #bytes following the hdr struct */ cursor->ph_cursor->hdr.len = - sizeof (PhCursorDef_t) + clen * 2 - sizeof (PhRegionDataHdr_t); + sizeof(PhCursorDef_t) + clen * 2 - sizeof(PhRegionDataHdr_t); return (cursor); } PhCursorDef_t -ph_GetWMPhCursor (WMcursor * cursor) +ph_GetWMPhCursor(WMcursor * cursor) { return (*cursor->ph_cursor); } int -ph_ShowWMCursor (_THIS, WMcursor * cursor) +ph_ShowWMCursor(_THIS, WMcursor * cursor) { PtArg_t args[3]; int nargs = 0; @@ -138,44 +138,44 @@ /* Set the photon cursor, or blank if cursor is NULL */ if (cursor != NULL) { - PtSetArg (&args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0); + PtSetArg(&args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0); /* Could set next to any PgColor_t value */ - PtSetArg (&args[1], Pt_ARG_CURSOR_COLOR, Ph_CURSOR_DEFAULT_COLOR, 0); - PtSetArg (&args[2], Pt_ARG_BITMAP_CURSOR, cursor->ph_cursor, - (cursor->ph_cursor->hdr.len + sizeof (PhRegionDataHdr_t))); + PtSetArg(&args[1], Pt_ARG_CURSOR_COLOR, Ph_CURSOR_DEFAULT_COLOR, 0); + PtSetArg(&args[2], Pt_ARG_BITMAP_CURSOR, cursor->ph_cursor, + (cursor->ph_cursor->hdr.len + sizeof(PhRegionDataHdr_t))); nargs = 3; } else { /* Ph_CURSOR_NONE */ - PtSetArg (&args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0); + PtSetArg(&args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0); nargs = 1; } - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); - if (PtSetResources (window, nargs, args) < 0) { + if (PtSetResources(window, nargs, args) < 0) { return (0); } - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); return (1); } void -ph_WarpWMCursor (_THIS, Uint16 x, Uint16 y) +ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { short abs_x, abs_y; - SDL_Lock_EventThread (); - PtGetAbsPosition (window, &abs_x, &abs_y); - PhMoveCursorAbs (PhInputGroup (NULL), x + abs_x, y + abs_y); - SDL_Unlock_EventThread (); + SDL_Lock_EventThread(); + PtGetAbsPosition(window, &abs_x, &abs_y); + PhMoveCursorAbs(PhInputGroup(NULL), x + abs_x, y + abs_y); + SDL_Unlock_EventThread(); } void -ph_CheckMouseMode (_THIS) +ph_CheckMouseMode(_THIS) { /* If the mouse is hidden and input is grabbed, we use relative mode */ if (!(SDL_cursorstate & CURSOR_VISIBLE) @@ -188,31 +188,31 @@ void -ph_UpdateMouse (_THIS) +ph_UpdateMouse(_THIS) { PhCursorInfo_t phcursor; short abs_x; short abs_y; /* Lock the event thread, in multi-threading environments */ - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); /* synchronizing photon mouse cursor position and SDL mouse position, if cursor appears over window. */ - PtGetAbsPosition (window, &abs_x, &abs_y); - PhQueryCursor (PhInputGroup (NULL), &phcursor); + PtGetAbsPosition(window, &abs_x, &abs_y); + PhQueryCursor(PhInputGroup(NULL), &phcursor); if (((phcursor.pos.x >= abs_x) && (phcursor.pos.x <= abs_x + this->screen->w)) && ((phcursor.pos.y >= abs_y) && (phcursor.pos.y <= abs_y + this->screen->h))) { - SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); - SDL_PrivateMouseMotion (0, 0, phcursor.pos.x - abs_x, - phcursor.pos.y - abs_y); + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); + SDL_PrivateMouseMotion(0, 0, phcursor.pos.x - abs_x, + phcursor.pos.y - abs_y); } else { - SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } /* Unlock the event thread, in multi-threading environments */ - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/photon/SDL_ph_mouse_c.h --- a/src/video/photon/SDL_ph_mouse_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/photon/SDL_ph_mouse_c.h Mon May 29 04:04:35 2006 +0000 @@ -27,15 +27,15 @@ #include "SDL_ph_video.h" /* Functions to be exported */ -extern void ph_FreeWMCursor (_THIS, WMcursor * cursor); -extern WMcursor *ph_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, - int hot_x, int hot_y); -extern PhCursorDef_t ph_GetWMPhCursor (WMcursor * cursor); -extern int ph_ShowWMCursor (_THIS, WMcursor * cursor); -extern void ph_WarpWMCursor (_THIS, Uint16 x, Uint16 y); -extern void ph_CheckMouseMode (_THIS); -extern void ph_UpdateMouse (_THIS); +extern void ph_FreeWMCursor(_THIS, WMcursor * cursor); +extern WMcursor *ph_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, + int hot_x, int hot_y); +extern PhCursorDef_t ph_GetWMPhCursor(WMcursor * cursor); +extern int ph_ShowWMCursor(_THIS, WMcursor * cursor); +extern void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y); +extern void ph_CheckMouseMode(_THIS); +extern void ph_UpdateMouse(_THIS); #endif /* __SDL_PH_MOUSE_H__ */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/photon/SDL_ph_video.c --- a/src/video/photon/SDL_ph_video.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/photon/SDL_ph_video.c Mon May 29 04:04:35 2006 +0000 @@ -42,21 +42,21 @@ #include "SDL_phyuv_c.h" #include "../blank_cursor.h" -static int ph_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Surface *ph_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int ph_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void ph_VideoQuit (_THIS); -static void ph_DeleteDevice (SDL_VideoDevice * device); +static int ph_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +static int ph_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void ph_VideoQuit(_THIS); +static void ph_DeleteDevice(SDL_VideoDevice * device); static int phstatus = -1; static int -ph_Available (void) +ph_Available(void) { if (phstatus != 0) { - phstatus = PtInit (NULL); + phstatus = PtInit(NULL); if (phstatus == 0) { return 1; } else { @@ -67,24 +67,24 @@ } static SDL_VideoDevice * -ph_CreateDevice (int devindex) +ph_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); device->gl_data = NULL; } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); - ph_DeleteDevice (device); + SDL_OutOfMemory(); + ph_DeleteDevice(device); return NULL; } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the driver flags */ device->handles_any_size = 1; @@ -142,34 +142,34 @@ }; static void -ph_DeleteDevice (SDL_VideoDevice * device) +ph_DeleteDevice(SDL_VideoDevice * device) { if (device) { if (device->hidden) { - SDL_free (device->hidden); + SDL_free(device->hidden); device->hidden = NULL; } if (device->gl_data) { - SDL_free (device->gl_data); + SDL_free(device->gl_data); device->gl_data = NULL; } - SDL_free (device); + SDL_free(device); device = NULL; } } static PtWidget_t * -ph_CreateWindow (_THIS) +ph_CreateWindow(_THIS) { PtWidget_t *widget; - widget = PtCreateWidget (PtWindow, NULL, 0, NULL); + widget = PtCreateWidget(PtWindow, NULL, 0, NULL); return widget; } static int -ph_SetupWindow (_THIS, int w, int h, int flags) +ph_SetupWindow(_THIS, int w, int h, int flags) { PtArg_t args[32]; PhPoint_t pos = { 0, 0 }; @@ -182,86 +182,86 @@ int x, y; /* check if window size has been changed by Window Manager */ - PtGetResource (window, Pt_ARG_DIM, &olddim, 0); + PtGetResource(window, Pt_ARG_DIM, &olddim, 0); if ((olddim->w != w) || (olddim->h != h)) { - PtSetArg (&args[nargs++], Pt_ARG_DIM, &dim, 0); + PtSetArg(&args[nargs++], Pt_ARG_DIM, &dim, 0); } if ((flags & SDL_RESIZABLE) == SDL_RESIZABLE) { - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, - Ph_WM_CLOSE); - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, - Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_RESIZE); - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, - Ph_WM_RESIZE | Ph_WM_MOVE | Ph_WM_CLOSE | Ph_WM_MAX | - Ph_WM_RESTORE); - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, - Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | - Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN); - PtSetArg (&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, - Pt_RESIZE_XY_AS_REQUIRED); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, + Ph_WM_CLOSE); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, + Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_RESIZE); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, + Ph_WM_RESIZE | Ph_WM_MOVE | Ph_WM_CLOSE | Ph_WM_MAX | + Ph_WM_RESTORE); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, + Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | + Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN); + PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, + Pt_RESIZE_XY_AS_REQUIRED); } else { - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, - Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_CLOSE); - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE, - Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE); - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, - Ph_WM_MOVE | Ph_WM_CLOSE); - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, - Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | - Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN); - PtSetArg (&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, - Pt_RESIZE_XY_AS_REQUIRED); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, + Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_CLOSE); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE, + Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, + Ph_WM_MOVE | Ph_WM_CLOSE); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, + Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | + Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN); + PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, + Pt_RESIZE_XY_AS_REQUIRED); } if (((flags & SDL_NOFRAME) == SDL_NOFRAME) || ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)) { if ((flags & SDL_RESIZABLE) != SDL_RESIZABLE) { - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, - Pt_FALSE, Pt_TRUE); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, + Pt_FALSE, Pt_TRUE); } else { - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, - Pt_FALSE, Pt_TRUE); - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, - Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_BORDER); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, + Pt_FALSE, Pt_TRUE); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, + Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_BORDER); } } else { - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, - Ph_WM_RENDER_BORDER | Ph_WM_RENDER_TITLE | - Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_MENU | Ph_WM_RENDER_MIN); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, + Ph_WM_RENDER_BORDER | Ph_WM_RENDER_TITLE | + Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_MENU | Ph_WM_RENDER_MIN); } if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { - PtSetArg (&args[nargs++], Pt_ARG_POS, &pos, 0); - PtSetArg (&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, - Pt_BASIC_PREVENT_FILL); - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, - Ph_WM_FFRONT | Ph_WM_MAX | Ph_WM_TOFRONT | Ph_WM_CONSWITCH); - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, - Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS | - Ph_WM_STATE_ISALTKEY); + PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0); + PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, + Pt_BASIC_PREVENT_FILL); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, + Ph_WM_FFRONT | Ph_WM_MAX | Ph_WM_TOFRONT | Ph_WM_CONSWITCH); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, + Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS | + Ph_WM_STATE_ISALTKEY); } else { - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, - Ph_WM_FFRONT | Ph_WM_CONSWITCH); - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, - Ph_WM_STATE_ISFRONT); - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, - Ph_WM_STATE_ISALTKEY); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, + Ph_WM_FFRONT | Ph_WM_CONSWITCH); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, + Ph_WM_STATE_ISFRONT); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, + Ph_WM_STATE_ISALTKEY); if ((flags & SDL_HWSURFACE) == SDL_HWSURFACE) { - PtSetArg (&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, - Pt_BASIC_PREVENT_FILL); + PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, + Pt_BASIC_PREVENT_FILL); } else { - PtSetArg (&args[nargs++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0); + PtSetArg(&args[nargs++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0); } if (!currently_maximized) { - windowpos = SDL_getenv ("SDL_VIDEO_WINDOW_POS"); - iscentered = SDL_getenv ("SDL_VIDEO_CENTERED"); + windowpos = SDL_getenv("SDL_VIDEO_WINDOW_POS"); + iscentered = SDL_getenv("SDL_VIDEO_CENTERED"); if ((iscentered) || ((windowpos) - && (SDL_strcmp (windowpos, "center") == 0))) { - PhWindowQueryVisible (Ph_QUERY_CONSOLE, 0, 0, &desktopextent); + && (SDL_strcmp(windowpos, "center") == 0))) { + PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, 0, &desktopextent); if (desktop_mode.width > w) { pos.x = (desktop_mode.width - w) / 2; } @@ -271,10 +271,10 @@ pos.x += desktopextent.ul.x; pos.y += desktopextent.ul.y; - PtSetArg (&args[nargs++], Pt_ARG_POS, &pos, 0); + PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0); } else { if (windowpos) { - if (SDL_sscanf (windowpos, "%d,%d", &x, &y) == 2) { + if (SDL_sscanf(windowpos, "%d,%d", &x, &y) == 2) { if ((x < desktop_mode.width) && (y < desktop_mode.height)) { PhWindowQueryVisible @@ -282,7 +282,7 @@ pos.x = x + desktopextent.ul.x; pos.y = y + desktopextent.ul.y; } - PtSetArg (&args[nargs++], Pt_ARG_POS, &pos, 0); + PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0); } } } @@ -290,42 +290,42 @@ /* if window is maximized render it as maximized */ if (currently_maximized) { - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, - Ph_WM_STATE_ISMAX); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, + Ph_WM_STATE_ISMAX); } else { - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, - Ph_WM_STATE_ISMAX); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, + Ph_WM_STATE_ISMAX); } /* do not grab the keyboard by default */ - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, - Ph_WM_STATE_ISALTKEY); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, + Ph_WM_STATE_ISALTKEY); /* bring the focus to the window */ - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, - Ph_WM_STATE_ISFOCUS); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, + Ph_WM_STATE_ISFOCUS); /* allow to catch hide event */ - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, - Ph_WM_HIDE); - PtSetArg (&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, - Ph_WM_HIDE); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, + Ph_WM_HIDE); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, + Ph_WM_HIDE); } - PtSetResources (window, nargs, args); - PtRealizeWidget (window); - PtWindowToFront (window); + PtSetResources(window, nargs, args); + PtRealizeWidget(window); + PtWindowToFront(window); #if 0 /* FIXME */ - PtGetResource (window, Pt_ARG_POS, &olddim, 0); - fprintf (stderr, "POSITION: %d, %d\n", olddim->w, olddim->h); + PtGetResource(window, Pt_ARG_POS, &olddim, 0); + fprintf(stderr, "POSITION: %d, %d\n", olddim->w, olddim->h); #endif return 0; } static const struct ColourMasks * -ph_GetColourMasks (int bpp) +ph_GetColourMasks(int bpp) { /* The alpha mask doesn't appears to be needed */ static const struct ColourMasks phColorMasks[5] = { @@ -353,7 +353,7 @@ } static int -ph_VideoInit (_THIS, SDL_PixelFormat * vformat) +ph_VideoInit(_THIS, SDL_PixelFormat * vformat) { PgHWCaps_t hwcaps; int i; @@ -371,40 +371,39 @@ old_video_mode = -1; old_refresh_rate = -1; - if (NULL == (phevent = SDL_malloc (EVENT_SIZE))) { - SDL_OutOfMemory (); + if (NULL == (phevent = SDL_malloc(EVENT_SIZE))) { + SDL_OutOfMemory(); return -1; } - SDL_memset (phevent, 0x00, EVENT_SIZE); + SDL_memset(phevent, 0x00, EVENT_SIZE); - window = ph_CreateWindow (this); + window = ph_CreateWindow(this); if (window == NULL) { - SDL_SetError ("ph_VideoInit(): Couldn't create video window !\n"); + SDL_SetError("ph_VideoInit(): Couldn't create video window !\n"); return -1; } /* Create the blank cursor */ - SDL_BlankCursor = this->CreateWMCursor (this, blank_cdata, blank_cmask, - (int) BLANK_CWIDTH, - (int) BLANK_CHEIGHT, - (int) BLANK_CHOTX, - (int) BLANK_CHOTY); + SDL_BlankCursor = this->CreateWMCursor(this, blank_cdata, blank_cmask, + (int) BLANK_CWIDTH, + (int) BLANK_CHEIGHT, + (int) BLANK_CHOTX, + (int) BLANK_CHOTY); if (SDL_BlankCursor == NULL) { return -1; } - if (PgGetGraphicsHWCaps (&hwcaps) < 0) { - SDL_SetError - ("ph_VideoInit(): GetGraphicsHWCaps function failed !\n"); - this->FreeWMCursor (this, SDL_BlankCursor); + if (PgGetGraphicsHWCaps(&hwcaps) < 0) { + SDL_SetError("ph_VideoInit(): GetGraphicsHWCaps function failed !\n"); + this->FreeWMCursor(this, SDL_BlankCursor); return -1; } - if (PgGetVideoModeInfo (hwcaps.current_video_mode, &desktop_mode) < 0) { + if (PgGetVideoModeInfo(hwcaps.current_video_mode, &desktop_mode) < 0) { SDL_SetError ("ph_VideoInit(): PgGetVideoModeInfo function failed !\n"); - this->FreeWMCursor (this, SDL_BlankCursor); + this->FreeWMCursor(this, SDL_BlankCursor); return -1; } @@ -420,12 +419,12 @@ /* save current palette */ if (desktopbpp == 8) { - PgGetPalette (savedpal); - PgGetPalette (syspalph); + PgGetPalette(savedpal); + PgGetPalette(syspalph); } else { for (i = 0; i < _Pg_MAX_PALETTE; i++) { - savedpal[i] = PgRGB (0, 0, 0); - syspalph[i] = PgRGB (0, 0, 0); + savedpal[i] = PgRGB(0, 0, 0); + syspalph[i] = PgRGB(0, 0, 0); } } @@ -445,36 +444,36 @@ this->info.wm_available = 1; - ph_UpdateHWInfo (this); + ph_UpdateHWInfo(this); return 0; } static SDL_Surface * -ph_SetVideoMode (_THIS, SDL_Surface * current, int width, int height, int bpp, - Uint32 flags) +ph_SetVideoMode(_THIS, SDL_Surface * current, int width, int height, int bpp, + Uint32 flags) { const struct ColourMasks *mask; /* Lock the event thread, in multi-threading environments */ - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); current->flags = flags; /* if we do not have desired fullscreen mode, then fallback into window mode */ if (((current->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) - && (ph_GetVideoMode (width, height, bpp) == 0)) { + && (ph_GetVideoMode(width, height, bpp) == 0)) { current->flags &= ~SDL_FULLSCREEN; current->flags &= ~SDL_NOFRAME; current->flags &= ~SDL_RESIZABLE; } - ph_SetupWindow (this, width, height, current->flags); + ph_SetupWindow(this, width, height, current->flags); - mask = ph_GetColourMasks (bpp); + mask = ph_GetColourMasks(bpp); if (mask != NULL) { - SDL_ReallocFormat (current, mask->bpp, mask->red, mask->green, - mask->blue, 0); + SDL_ReallocFormat(current, mask->bpp, mask->red, mask->green, + mask->blue, 0); } else { SDL_SetError ("ph_SetVideoMode(): desired bpp is not supported by photon !\n"); @@ -530,55 +529,55 @@ } /* Must call at least once for setup image planes */ - if (ph_SetupUpdateFunction (this, current, current->flags) == -1) { + if (ph_SetupUpdateFunction(this, current, current->flags) == -1) { /* Error string was filled in the ph_SetupUpdateFunction() */ return NULL; } /* finish window drawing, if we are not in fullscreen, of course */ if ((current->flags & SDL_FULLSCREEN) != SDL_FULLSCREEN) { - PtFlush (); + PtFlush(); } else { - PgFlush (); + PgFlush(); } visualbpp = bpp; - ph_UpdateHWInfo (this); + ph_UpdateHWInfo(this); - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); /* We've done! */ return (current); } static void -ph_VideoQuit (_THIS) +ph_VideoQuit(_THIS) { /* restore palette */ if (desktopbpp == 8) { - PgSetPalette (syspalph, 0, -1, 0, 0, 0); - PgSetPalette (savedpal, 0, 0, _Pg_MAX_PALETTE, - Pg_PALSET_GLOBAL | Pg_PALSET_FORCE_EXPOSE, 0); - PgFlush (); + PgSetPalette(syspalph, 0, -1, 0, 0, 0); + PgSetPalette(savedpal, 0, 0, _Pg_MAX_PALETTE, + Pg_PALSET_GLOBAL | Pg_PALSET_FORCE_EXPOSE, 0); + PgFlush(); } - ph_DestroyImage (this, SDL_VideoSurface); + ph_DestroyImage(this, SDL_VideoSurface); if (window) { - PtUnrealizeWidget (window); - PtDestroyWidget (window); + PtUnrealizeWidget(window); + PtDestroyWidget(window); window = NULL; } if (phevent != NULL) { - SDL_free (phevent); + SDL_free(phevent); phevent = NULL; } } static int -ph_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { int i; SDL_Rect updaterect; @@ -592,34 +591,32 @@ if ((SDL_Image) && (SDL_Image->palette)) { for (i = firstcolor; i < firstcolor + ncolors; i++) { syspalph[i] = - PgRGB (colors[i - firstcolor].r, - colors[i - firstcolor].g, - colors[i - firstcolor].b); + PgRGB(colors[i - firstcolor].r, + colors[i - firstcolor].g, colors[i - firstcolor].b); SDL_Image->palette[i] = syspalph[i]; } /* image needs to be redrawn */ - this->UpdateRects (this, 1, &updaterect); + this->UpdateRects(this, 1, &updaterect); } } else { if (desktoppal == SDLPH_PAL_SYSTEM) { for (i = firstcolor; i < firstcolor + ncolors; i++) { syspalph[i] = - PgRGB (colors[i - firstcolor].r, - colors[i - firstcolor].g, - colors[i - firstcolor].b); + PgRGB(colors[i - firstcolor].r, + colors[i - firstcolor].g, colors[i - firstcolor].b); } if ((this->screen->flags & SDL_FULLSCREEN) != SDL_FULLSCREEN) { /* window mode must use soft palette */ - PgSetPalette (&syspalph[firstcolor], 0, firstcolor, - ncolors, Pg_PALSET_GLOBAL, 0); + PgSetPalette(&syspalph[firstcolor], 0, firstcolor, + ncolors, Pg_PALSET_GLOBAL, 0); /* image needs to be redrawn */ - this->UpdateRects (this, 1, &updaterect); + this->UpdateRects(this, 1, &updaterect); } else { /* fullscreen mode must use hardware palette */ - PgSetPalette (&syspalph[firstcolor], 0, firstcolor, - ncolors, Pg_PALSET_GLOBAL, 0); + PgSetPalette(&syspalph[firstcolor], 0, firstcolor, + ncolors, Pg_PALSET_GLOBAL, 0); } } else { /* SDLPH_PAL_NONE do nothing */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/photon/SDL_ph_wm.c --- a/src/video/photon/SDL_ph_wm.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/photon/SDL_ph_wm.c Mon May 29 04:04:35 2006 +0000 @@ -36,86 +36,86 @@ #include "SDL_ph_wm_c.h" void -ph_SetIcon (_THIS, SDL_Surface * icon, Uint8 * mask) +ph_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask) { return; } /* Set window caption */ void -ph_SetCaption (_THIS, const char *title, const char *icon) +ph_SetCaption(_THIS, const char *title, const char *icon) { - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); /* sanity check for set caption call before window init */ if (window != NULL) { - PtSetResource (window, Pt_ARG_WINDOW_TITLE, title, 0); + PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0); } - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); } /* Iconify current window */ int -ph_IconifyWindow (_THIS) +ph_IconifyWindow(_THIS) { PhWindowEvent_t windowevent; - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); - SDL_memset (&windowevent, 0, sizeof (windowevent)); + SDL_memset(&windowevent, 0, sizeof(windowevent)); windowevent.event_f = Ph_WM_HIDE; windowevent.event_state = Ph_WM_EVSTATE_HIDE; - windowevent.rid = PtWidgetRid (window); - PtForwardWindowEvent (&windowevent); + windowevent.rid = PtWidgetRid(window); + PtForwardWindowEvent(&windowevent); - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); return 0; } SDL_GrabMode -ph_GrabInputNoLock (_THIS, SDL_GrabMode mode) +ph_GrabInputNoLock(_THIS, SDL_GrabMode mode) { short abs_x, abs_y; if (mode == SDL_GRAB_OFF) { - PtSetResource (window, Pt_ARG_WINDOW_STATE, Pt_FALSE, - Ph_WM_STATE_ISALTKEY); + PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_FALSE, + Ph_WM_STATE_ISALTKEY); } else { - PtSetResource (window, Pt_ARG_WINDOW_STATE, Pt_TRUE, - Ph_WM_STATE_ISALTKEY); + PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_TRUE, + Ph_WM_STATE_ISALTKEY); - PtGetAbsPosition (window, &abs_x, &abs_y); - PhMoveCursorAbs (PhInputGroup (NULL), - abs_x + SDL_VideoSurface->w / 2, - abs_y + SDL_VideoSurface->h / 2); + PtGetAbsPosition(window, &abs_x, &abs_y); + PhMoveCursorAbs(PhInputGroup(NULL), + abs_x + SDL_VideoSurface->w / 2, + abs_y + SDL_VideoSurface->h / 2); } - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); return (mode); } SDL_GrabMode -ph_GrabInput (_THIS, SDL_GrabMode mode) +ph_GrabInput(_THIS, SDL_GrabMode mode) { - SDL_Lock_EventThread (); - mode = ph_GrabInputNoLock (this, mode); - SDL_Unlock_EventThread (); + SDL_Lock_EventThread(); + mode = ph_GrabInputNoLock(this, mode); + SDL_Unlock_EventThread(); return (mode); } int -ph_GetWMInfo (_THIS, SDL_SysWMinfo * info) +ph_GetWMInfo(_THIS, SDL_SysWMinfo * info) { if (info->version.major <= SDL_MAJOR_VERSION) { return 1; } else { - SDL_SetError ("Application not compiled with SDL %d.%d\n", - SDL_MAJOR_VERSION, SDL_MINOR_VERSION); + SDL_SetError("Application not compiled with SDL %d.%d\n", + SDL_MAJOR_VERSION, SDL_MINOR_VERSION); return -1; } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/photon/SDL_ph_wm_c.h --- a/src/video/photon/SDL_ph_wm_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/photon/SDL_ph_wm_c.h Mon May 29 04:04:35 2006 +0000 @@ -27,12 +27,12 @@ #include "SDL_ph_video.h" /* Functions to be exported */ -extern void ph_SetCaption (_THIS, const char *title, const char *icon); -extern void ph_SetIcon (_THIS, SDL_Surface * icon, Uint8 * mask); -extern int ph_IconifyWindow (_THIS); -extern SDL_GrabMode ph_GrabInputNoLock (_THIS, SDL_GrabMode mode); -extern SDL_GrabMode ph_GrabInput (_THIS, SDL_GrabMode mode); -extern int ph_GetWMInfo (_THIS, SDL_SysWMinfo * info); +extern void ph_SetCaption(_THIS, const char *title, const char *icon); +extern void ph_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask); +extern int ph_IconifyWindow(_THIS); +extern SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode); +extern SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode); +extern int ph_GetWMInfo(_THIS, SDL_SysWMinfo * info); #endif /* __SDL_PH_WM_H__ */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/photon/SDL_phyuv.c --- a/src/video/photon/SDL_phyuv.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/photon/SDL_phyuv.c Mon May 29 04:04:35 2006 +0000 @@ -44,18 +44,17 @@ }; int -grab_ptrs2 (PgVideoChannel_t * channel, FRAMEDATA * Frame0, - FRAMEDATA * Frame1) +grab_ptrs2(PgVideoChannel_t * channel, FRAMEDATA * Frame0, FRAMEDATA * Frame1) { int planes = 0; /* Buffers have moved; re-obtain the pointers */ - Frame0->Y = (unsigned char *) PdGetOffscreenContextPtr (channel->yplane1); - Frame1->Y = (unsigned char *) PdGetOffscreenContextPtr (channel->yplane2); - Frame0->U = (unsigned char *) PdGetOffscreenContextPtr (channel->vplane1); - Frame1->U = (unsigned char *) PdGetOffscreenContextPtr (channel->vplane2); - Frame0->V = (unsigned char *) PdGetOffscreenContextPtr (channel->uplane1); - Frame1->V = (unsigned char *) PdGetOffscreenContextPtr (channel->uplane2); + Frame0->Y = (unsigned char *) PdGetOffscreenContextPtr(channel->yplane1); + Frame1->Y = (unsigned char *) PdGetOffscreenContextPtr(channel->yplane2); + Frame0->U = (unsigned char *) PdGetOffscreenContextPtr(channel->vplane1); + Frame1->U = (unsigned char *) PdGetOffscreenContextPtr(channel->vplane2); + Frame0->V = (unsigned char *) PdGetOffscreenContextPtr(channel->uplane1); + Frame1->V = (unsigned char *) PdGetOffscreenContextPtr(channel->uplane2); if (Frame0->Y) planes++; @@ -70,8 +69,8 @@ } SDL_Overlay * -ph_CreateYUVOverlay (_THIS, int width, int height, Uint32 format, - SDL_Surface * display) +ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, + SDL_Surface * display) { SDL_Overlay *overlay; struct private_yuvhwdata *hwdata; @@ -82,10 +81,10 @@ PhPoint_t pos; /* Create the overlay structure */ - overlay = SDL_calloc (1, sizeof (SDL_Overlay)); + overlay = SDL_calloc(1, sizeof(SDL_Overlay)); if (overlay == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return NULL; } @@ -99,24 +98,24 @@ overlay->hwfuncs = &ph_yuvfuncs; /* Create the pixel data and lookup tables */ - hwdata = SDL_calloc (1, sizeof (struct private_yuvhwdata)); + hwdata = SDL_calloc(1, sizeof(struct private_yuvhwdata)); if (hwdata == NULL) { - SDL_OutOfMemory (); - SDL_FreeYUVOverlay (overlay); + SDL_OutOfMemory(); + SDL_FreeYUVOverlay(overlay); return NULL; } overlay->hwdata = hwdata; - PhDCSetCurrent (0); + PhDCSetCurrent(0); if (overlay->hwdata->channel == NULL) { if ((overlay->hwdata->channel = - PgCreateVideoChannel (Pg_VIDEO_CHANNEL_SCALER, 0)) == NULL) { + PgCreateVideoChannel(Pg_VIDEO_CHANNEL_SCALER, 0)) == NULL) { SDL_SetError ("ph_CreateYUVOverlay(): Create channel failed: %s\n", - strerror (errno)); - SDL_FreeYUVOverlay (overlay); + strerror(errno)); + SDL_FreeYUVOverlay(overlay); return NULL; } @@ -124,7 +123,7 @@ overlay->hwdata->forcedredraw = 0; - PtGetAbsPosition (window, &pos.x, &pos.y); + PtGetAbsPosition(window, &pos.x, &pos.y); overlay->hwdata->CurrentWindowPos.x = pos.x; overlay->hwdata->CurrentWindowPos.y = pos.y; overlay->hwdata->CurrentViewPort.pos.x = 0; @@ -133,9 +132,9 @@ overlay->hwdata->CurrentViewPort.size.h = height; overlay->hwdata->State = OVERLAY_STATE_UNINIT; overlay->hwdata->FrameData0 = - (FRAMEDATA *) SDL_calloc (1, sizeof (FRAMEDATA)); + (FRAMEDATA *) SDL_calloc(1, sizeof(FRAMEDATA)); overlay->hwdata->FrameData1 = - (FRAMEDATA *) SDL_calloc (1, sizeof (FRAMEDATA)); + (FRAMEDATA *) SDL_calloc(1, sizeof(FRAMEDATA)); vidport = -1; i = 0; @@ -143,11 +142,11 @@ overlay->hwdata->ischromakey = 0; do { - SDL_memset (&overlay->hwdata->caps, 0x00, sizeof (PgScalerCaps_t)); - overlay->hwdata->caps.size = sizeof (PgScalerCaps_t); + SDL_memset(&overlay->hwdata->caps, 0x00, sizeof(PgScalerCaps_t)); + overlay->hwdata->caps.size = sizeof(PgScalerCaps_t); rtncode = - PgGetScalerCapabilities (overlay->hwdata->channel, i, - &overlay->hwdata->caps); + PgGetScalerCapabilities(overlay->hwdata->channel, i, + &overlay->hwdata->caps); if (rtncode == 0) { if (overlay->hwdata->caps.format == format) { if ((overlay->hwdata->caps. @@ -167,23 +166,23 @@ if (vidport == -1) { - SDL_SetError ("No available video ports for requested format\n"); - SDL_FreeYUVOverlay (overlay); + SDL_SetError("No available video ports for requested format\n"); + SDL_FreeYUVOverlay(overlay); return NULL; } overlay->hwdata->format = format; overlay->hwdata->props.format = format; - overlay->hwdata->props.size = sizeof (PgScalerProps_t); + overlay->hwdata->props.size = sizeof(PgScalerProps_t); overlay->hwdata->props.src_dim.w = width; overlay->hwdata->props.src_dim.h = height; /* overlay->hwdata->chromakey = PgGetOverlayChromaColor(); */ - overlay->hwdata->chromakey = PgRGB (12, 6, 12); /* very dark pink color */ + overlay->hwdata->chromakey = PgRGB(12, 6, 12); /* very dark pink color */ overlay->hwdata->props.color_key = overlay->hwdata->chromakey; - PhAreaToRect (&overlay->hwdata->CurrentViewPort, - &overlay->hwdata->props.viewport); + PhAreaToRect(&overlay->hwdata->CurrentViewPort, + &overlay->hwdata->props.viewport); overlay->hwdata->props.flags = Pg_SCALER_PROP_DOUBLE_BUFFER; @@ -196,13 +195,13 @@ } rtncode = - PgConfigScalerChannel (overlay->hwdata->channel, - &overlay->hwdata->props); + PgConfigScalerChannel(overlay->hwdata->channel, + &overlay->hwdata->props); switch (rtncode) { case -1: - SDL_SetError ("PgConfigScalerChannel failed\n"); - SDL_FreeYUVOverlay (overlay); + SDL_SetError("PgConfigScalerChannel failed\n"); + SDL_FreeYUVOverlay(overlay); return NULL; case 1: case 0: @@ -211,8 +210,8 @@ } planes = - grab_ptrs2 (overlay->hwdata->channel, overlay->hwdata->FrameData0, - overlay->hwdata->FrameData1); + grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, + overlay->hwdata->FrameData1); if (overlay->hwdata->channel->yplane1 != NULL) overlay->hwdata->YStride = overlay->hwdata->channel->yplane1->pitch; @@ -225,8 +224,8 @@ if ((overlay->hwdata->channel->yplane1 == NULL) && (overlay->hwdata->channel->uplane1 == NULL) && (overlay->hwdata->channel->vplane1 == NULL)) { - SDL_FreeYUVOverlay (overlay); - SDL_SetError ("PgConfigScaler() returns all planes equal NULL\n"); + SDL_FreeYUVOverlay(overlay); + SDL_SetError("PgConfigScaler() returns all planes equal NULL\n"); return NULL; } /* @@ -249,11 +248,11 @@ /* Find the pitch and offset values for the overlay */ overlay->planes = planes; - overlay->pitches = SDL_calloc (overlay->planes, sizeof (Uint16)); - overlay->pixels = SDL_calloc (overlay->planes, sizeof (Uint8 *)); + overlay->pitches = SDL_calloc(overlay->planes, sizeof(Uint16)); + overlay->pixels = SDL_calloc(overlay->planes, sizeof(Uint8 *)); if (!overlay->pitches || !overlay->pixels) { - SDL_OutOfMemory (); - SDL_FreeYUVOverlay (overlay); + SDL_OutOfMemory(); + SDL_FreeYUVOverlay(overlay); return (NULL); } @@ -280,7 +279,7 @@ } int -ph_LockYUVOverlay (_THIS, SDL_Overlay * overlay) +ph_LockYUVOverlay(_THIS, SDL_Overlay * overlay) { if (overlay == NULL) { return -1; @@ -326,7 +325,7 @@ } void -ph_UnlockYUVOverlay (_THIS, SDL_Overlay * overlay) +ph_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay) { if (overlay == NULL) { return; @@ -336,8 +335,8 @@ } int -ph_DisplayYUVOverlay (_THIS, SDL_Overlay * overlay, SDL_Rect * src, - SDL_Rect * dst) +ph_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, SDL_Rect * src, + SDL_Rect * dst) { int rtncode; PhPoint_t pos; @@ -353,7 +352,7 @@ return -1; } - PtGetAbsPosition (window, &pos.x, &pos.y); + PtGetAbsPosition(window, &pos.x, &pos.y); if ((pos.x != overlay->hwdata->CurrentWindowPos.x) || (pos.y != overlay->hwdata->CurrentWindowPos.y)) { winchanged = 1; @@ -375,44 +374,44 @@ backrect.y = overlay->hwdata->CurrentViewPort.pos.y; backrect.w = overlay->hwdata->CurrentViewPort.size.w; backrect.h = overlay->hwdata->CurrentViewPort.size.h; - this->UpdateRects (this, 1, &backrect); + this->UpdateRects(this, 1, &backrect); /* Draw the new rectangle of the chroma color at the viewport position */ - PgSetFillColor (overlay->hwdata->chromakey); - PgDrawIRect (dst->x, dst->y, dst->x + dst->w - 1, - dst->y + dst->h - 1, Pg_DRAW_FILL); - PgFlush (); + PgSetFillColor(overlay->hwdata->chromakey); + PgDrawIRect(dst->x, dst->y, dst->x + dst->w - 1, + dst->y + dst->h - 1, Pg_DRAW_FILL); + PgFlush(); } overlay->hwdata->props.flags |= Pg_SCALER_PROP_SCALER_ENABLE; overlay->hwdata->scaler_on = 1; - PhWindowQueryVisible (Ph_QUERY_CONSOLE, 0, PtWidgetRid (window), - &windowextent); + PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, PtWidgetRid(window), + &windowextent); overlay->hwdata->CurrentViewPort.pos.x = pos.x - windowextent.ul.x + dst->x; overlay->hwdata->CurrentViewPort.pos.y = pos.y - windowextent.ul.y + dst->y; overlay->hwdata->CurrentViewPort.size.w = dst->w; overlay->hwdata->CurrentViewPort.size.h = dst->h; - PhAreaToRect (&overlay->hwdata->CurrentViewPort, - &overlay->hwdata->props.viewport); + PhAreaToRect(&overlay->hwdata->CurrentViewPort, + &overlay->hwdata->props.viewport); overlay->hwdata->CurrentViewPort.pos.x = dst->x; overlay->hwdata->CurrentViewPort.pos.y = dst->y; rtncode = - PgConfigScalerChannel (overlay->hwdata->channel, - &(overlay->hwdata->props)); + PgConfigScalerChannel(overlay->hwdata->channel, + &(overlay->hwdata->props)); switch (rtncode) { case -1: - SDL_SetError ("PgConfigScalerChannel() function failed\n"); - SDL_FreeYUVOverlay (overlay); + SDL_SetError("PgConfigScalerChannel() function failed\n"); + SDL_FreeYUVOverlay(overlay); return -1; case 1: - grab_ptrs2 (overlay->hwdata->channel, - overlay->hwdata->FrameData0, - overlay->hwdata->FrameData1); + grab_ptrs2(overlay->hwdata->channel, + overlay->hwdata->FrameData0, + overlay->hwdata->FrameData1); break; case 0: default: @@ -463,7 +462,7 @@ } void -ph_FreeYUVOverlay (_THIS, SDL_Overlay * overlay) +ph_FreeYUVOverlay(_THIS, SDL_Overlay * overlay) { SDL_Rect backrect; @@ -482,30 +481,30 @@ backrect.y = overlay->hwdata->CurrentViewPort.pos.y; backrect.w = overlay->hwdata->CurrentViewPort.size.w; backrect.h = overlay->hwdata->CurrentViewPort.size.h; - this->UpdateRects (this, 1, &backrect); + this->UpdateRects(this, 1, &backrect); /* it is need for some buggy drivers, that can't hide overlay before */ /* freeing buffer, so we got trash on the srceen */ overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_SCALER_ENABLE; - PgConfigScalerChannel (overlay->hwdata->channel, - &(overlay->hwdata->props)); + PgConfigScalerChannel(overlay->hwdata->channel, + &(overlay->hwdata->props)); overlay->hwdata->scaler_on = 0; overlay->hwdata->State = OVERLAY_STATE_UNINIT; if (overlay->hwdata->channel != NULL) { - PgDestroyVideoChannel (overlay->hwdata->channel); + PgDestroyVideoChannel(overlay->hwdata->channel); overlay->hwdata->channel = NULL; return; } overlay->hwdata->CurrentFrameData = NULL; - SDL_free (overlay->hwdata->FrameData0); - SDL_free (overlay->hwdata->FrameData1); + SDL_free(overlay->hwdata->FrameData0); + SDL_free(overlay->hwdata->FrameData1); overlay->hwdata->FrameData0 = NULL; overlay->hwdata->FrameData1 = NULL; - SDL_free (overlay->hwdata); + SDL_free(overlay->hwdata); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/photon/SDL_phyuv_c.h --- a/src/video/photon/SDL_phyuv_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/photon/SDL_phyuv_c.h Mon May 29 04:04:35 2006 +0000 @@ -53,14 +53,13 @@ int locked; }; -extern SDL_Overlay *ph_CreateYUVOverlay (_THIS, int width, int height, - Uint32 format, - SDL_Surface * display); -extern int ph_LockYUVOverlay (_THIS, SDL_Overlay * overlay); -extern void ph_UnlockYUVOverlay (_THIS, SDL_Overlay * overlay); -extern int ph_DisplayYUVOverlay (_THIS, SDL_Overlay * overlay, SDL_Rect * src, - SDL_Rect * dst); -extern void ph_FreeYUVOverlay (_THIS, SDL_Overlay * overlay); +extern SDL_Overlay *ph_CreateYUVOverlay(_THIS, int width, int height, + Uint32 format, SDL_Surface * display); +extern int ph_LockYUVOverlay(_THIS, SDL_Overlay * overlay); +extern void ph_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay); +extern int ph_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, SDL_Rect * src, + SDL_Rect * dst); +extern void ph_FreeYUVOverlay(_THIS, SDL_Overlay * overlay); #endif /* __SDL_PH_YUV_H__ */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/picogui/SDL_pgevents.c --- a/src/video/picogui/SDL_pgevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/picogui/SDL_pgevents.c Mon May 29 04:04:35 2006 +0000 @@ -31,99 +31,98 @@ #include "SDL_pgevents_c.h" int -PG_HandleClose (struct pgEvent *evt) +PG_HandleClose(struct pgEvent *evt) { - SDL_PrivateQuit (); + SDL_PrivateQuit(); return 1; /* Intercept the event's normal quit handling */ } int -PG_HandleResize (struct pgEvent *evt) +PG_HandleResize(struct pgEvent *evt) { - SDL_PrivateResize (evt->e.size.w, evt->e.size.h); + SDL_PrivateResize(evt->e.size.w, evt->e.size.h); return 0; } int -PG_HandleKey (struct pgEvent *evt) +PG_HandleKey(struct pgEvent *evt) { SDL_keysym sym; - SDL_memset (&sym, 0, sizeof (sym)); + SDL_memset(&sym, 0, sizeof(sym)); sym.sym = evt->e.kbd.key; sym.mod = evt->e.kbd.mods; - SDL_PrivateKeyboard (evt->type == PG_WE_KBD_KEYDOWN, &sym); + SDL_PrivateKeyboard(evt->type == PG_WE_KBD_KEYDOWN, &sym); return 0; } int -PG_HandleChar (struct pgEvent *evt) +PG_HandleChar(struct pgEvent *evt) { SDL_keysym sym; - SDL_memset (&sym, 0, sizeof (sym)); + SDL_memset(&sym, 0, sizeof(sym)); sym.unicode = evt->e.kbd.key; sym.mod = evt->e.kbd.mods; - SDL_PrivateKeyboard (evt->type == PG_WE_KBD_KEYDOWN, &sym); + SDL_PrivateKeyboard(evt->type == PG_WE_KBD_KEYDOWN, &sym); return 0; } int -PG_HandleMouseButton (struct pgEvent *evt) +PG_HandleMouseButton(struct pgEvent *evt) { /* We need to focus the canvas when it's clicked */ if (evt->extra) { SDL_VideoDevice *this = (SDL_VideoDevice *) evt->extra; - pgFocus (this->hidden->wCanvas); + pgFocus(this->hidden->wCanvas); } - SDL_PrivateMouseButton (evt->type == PG_WE_PNTR_DOWN, evt->e.pntr.chbtn, - evt->e.pntr.x, evt->e.pntr.y); + SDL_PrivateMouseButton(evt->type == PG_WE_PNTR_DOWN, evt->e.pntr.chbtn, + evt->e.pntr.x, evt->e.pntr.y); return 0; } int -PG_HandleMouseMotion (struct pgEvent *evt) +PG_HandleMouseMotion(struct pgEvent *evt) { - SDL_PrivateMouseMotion (evt->e.pntr.btn, 0, evt->e.pntr.x, evt->e.pntr.y); + SDL_PrivateMouseMotion(evt->e.pntr.btn, 0, evt->e.pntr.x, evt->e.pntr.y); return 0; } void -PG_PumpEvents (_THIS) +PG_PumpEvents(_THIS) { /* Process all pending events */ - pgEventPoll (); + pgEventPoll(); } void -PG_InitOSKeymap (_THIS) +PG_InitOSKeymap(_THIS) { /* We need no keymap */ } void -PG_InitEvents (_THIS) +PG_InitEvents(_THIS) { /* Turn on all the mouse and keyboard triggers for our canvas, normally less important * events like mouse movement are ignored to save bandwidth. */ - pgSetWidget (this->hidden->wCanvas, PG_WP_TRIGGERMASK, - pgGetWidget (this->hidden->wCanvas, PG_WP_TRIGGERMASK) | - PG_TRIGGER_UP | PG_TRIGGER_DOWN | PG_TRIGGER_MOVE | - PG_TRIGGER_KEYUP | PG_TRIGGER_KEYDOWN | PG_TRIGGER_CHAR, 0); + pgSetWidget(this->hidden->wCanvas, PG_WP_TRIGGERMASK, + pgGetWidget(this->hidden->wCanvas, PG_WP_TRIGGERMASK) | + PG_TRIGGER_UP | PG_TRIGGER_DOWN | PG_TRIGGER_MOVE | + PG_TRIGGER_KEYUP | PG_TRIGGER_KEYDOWN | PG_TRIGGER_CHAR, 0); /* Start our canvas out focused, so we get keyboard input */ - pgFocus (this->hidden->wCanvas); + pgFocus(this->hidden->wCanvas); /* Set up bindings for all the above event handlers */ - pgBind (this->hidden->wApp, PG_WE_CLOSE, &PG_HandleClose, NULL); - pgBind (this->hidden->wCanvas, PG_WE_BUILD, &PG_HandleResize, NULL); - pgBind (this->hidden->wCanvas, PG_WE_KBD_CHAR, &PG_HandleChar, NULL); - pgBind (this->hidden->wCanvas, PG_WE_KBD_KEYUP, &PG_HandleKey, NULL); - pgBind (this->hidden->wCanvas, PG_WE_KBD_KEYDOWN, &PG_HandleKey, NULL); - pgBind (this->hidden->wCanvas, PG_WE_PNTR_MOVE, &PG_HandleMouseMotion, - NULL); - pgBind (this->hidden->wCanvas, PG_WE_PNTR_UP, &PG_HandleMouseButton, - NULL); - pgBind (this->hidden->wCanvas, PG_WE_PNTR_DOWN, &PG_HandleMouseButton, - this); + pgBind(this->hidden->wApp, PG_WE_CLOSE, &PG_HandleClose, NULL); + pgBind(this->hidden->wCanvas, PG_WE_BUILD, &PG_HandleResize, NULL); + pgBind(this->hidden->wCanvas, PG_WE_KBD_CHAR, &PG_HandleChar, NULL); + pgBind(this->hidden->wCanvas, PG_WE_KBD_KEYUP, &PG_HandleKey, NULL); + pgBind(this->hidden->wCanvas, PG_WE_KBD_KEYDOWN, &PG_HandleKey, NULL); + pgBind(this->hidden->wCanvas, PG_WE_PNTR_MOVE, &PG_HandleMouseMotion, + NULL); + pgBind(this->hidden->wCanvas, PG_WE_PNTR_UP, &PG_HandleMouseButton, NULL); + pgBind(this->hidden->wCanvas, PG_WE_PNTR_DOWN, &PG_HandleMouseButton, + this); } /* end of SDL_pgevents.c ... */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/picogui/SDL_pgevents_c.h --- a/src/video/picogui/SDL_pgevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/picogui/SDL_pgevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -29,9 +29,9 @@ /* Variables and functions exported by SDL_sysevents.c to other parts of the native video subsystem (SDL_sysvideo.c) */ -extern void PG_PumpEvents (_THIS); -extern void PG_InitEvents (_THIS); -extern void PG_InitOSKeymap (_THIS); +extern void PG_PumpEvents(_THIS); +extern void PG_InitEvents(_THIS); +extern void PG_InitOSKeymap(_THIS); /* end of SDL_pgevents_c.h ... */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/picogui/SDL_pgvideo.c --- a/src/video/picogui/SDL_pgvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/picogui/SDL_pgvideo.c Mon May 29 04:04:35 2006 +0000 @@ -36,23 +36,22 @@ #define PGVID_DRIVER_NAME "picogui" /* Initialization/Query functions */ -static int PG_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **PG_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *PG_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int PG_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void PG_VideoQuit (_THIS); +static int PG_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **PG_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags); +static SDL_Surface *PG_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +static int PG_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void PG_VideoQuit(_THIS); /* Hardware surface functions */ -static int PG_AllocHWSurface (_THIS, SDL_Surface * surface); -static int PG_LockHWSurface (_THIS, SDL_Surface * surface); -static void PG_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void PG_FreeHWSurface (_THIS, SDL_Surface * surface); +static int PG_AllocHWSurface(_THIS, SDL_Surface * surface); +static int PG_LockHWSurface(_THIS, SDL_Surface * surface); +static void PG_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void PG_FreeHWSurface(_THIS, SDL_Surface * surface); /* etc. */ -static void PG_UpdateRects (_THIS, int numrects, SDL_Rect * rects); +static void PG_UpdateRects(_THIS, int numrects, SDL_Rect * rects); // The implementation dependent data for the window manager cursor struct WMcursor @@ -62,17 +61,17 @@ }; /* WM functions */ -void PG_SetCaption (_THIS, const char *title, const char *icon); -WMcursor *PG_CreateWMCursor (_THIS, Uint8 * data, Uint8 * mask, - int w, int h, int hot_x, int hot_y); -void PG_FreeWMCursor (_THIS, WMcursor * cursor); -void PG_WarpWMCursor (_THIS, Uint16 x, Uint16 y); -int PG_ShowWMCursor (_THIS, WMcursor * cursor); +void PG_SetCaption(_THIS, const char *title, const char *icon); +WMcursor *PG_CreateWMCursor(_THIS, Uint8 * data, Uint8 * mask, + int w, int h, int hot_x, int hot_y); +void PG_FreeWMCursor(_THIS, WMcursor * cursor); +void PG_WarpWMCursor(_THIS, Uint16 x, Uint16 y); +int PG_ShowWMCursor(_THIS, WMcursor * cursor); /* PicoGUI driver bootstrap functions */ static int -PG_Available (void) +PG_Available(void) { /* FIXME: The current client lib doesn't give a way to see if the picogui * server is reachable without causing a fatal error if it isn't. @@ -84,32 +83,32 @@ } static void -PG_DeleteDevice (SDL_VideoDevice * device) +PG_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -PG_CreateDevice (int devindex) +PG_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = PG_VideoInit; @@ -153,7 +152,7 @@ int -PG_VideoInit (_THIS, SDL_PixelFormat * vformat) +PG_VideoInit(_THIS, SDL_PixelFormat * vformat) { /* Connect to the PicoGUI server. No way to process command line args yet, * but since this is based on SHM it's not important to be able to specify @@ -162,15 +161,15 @@ * FIXME: Another nitpick about the current client lib is there's no * clean way to indicate that command line args are not available. */ - pgInit (0, (char **) ""); - this->hidden->mi = *pgGetVideoMode (); + pgInit(0, (char **) ""); + this->hidden->mi = *pgGetVideoMode(); /* Create a picogui application and canvas. We'll populate the canvas later. */ - this->hidden->wApp = pgRegisterApp (PG_APP_NORMAL, "SDL", 0); - this->hidden->wCanvas = pgNewWidget (PG_WIDGET_CANVAS, 0, 0); - pgSetWidget (PGDEFAULT, PG_WP_SIDE, PG_S_ALL, 0); + this->hidden->wApp = pgRegisterApp(PG_APP_NORMAL, "SDL", 0); + this->hidden->wCanvas = pgNewWidget(PG_WIDGET_CANVAS, 0, 0); + pgSetWidget(PGDEFAULT, PG_WP_SIDE, PG_S_ALL, 0); - PG_InitEvents (this); + PG_InitEvents(this); /* Determine the current screen size */ this->info.current_w = this->hidden->mi.lxres; @@ -190,63 +189,61 @@ } SDL_Rect ** -PG_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +PG_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { return (SDL_Rect **) - 1; } SDL_Surface * -PG_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +PG_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { if (this->hidden->bitmap) { /* Free old bitmap */ if (current->pixels) { - shmdt (current->pixels); + shmdt(current->pixels); current->pixels = NULL; } - pgDelete (this->hidden->bitmap); + pgDelete(this->hidden->bitmap); } /* Allocate the new pixel format for the screen */ - if (!SDL_ReallocFormat (current, bpp, 0, 0, 0, 0)) { - SDL_SetError - ("Couldn't allocate new pixel format for requested mode"); + if (!SDL_ReallocFormat(current, bpp, 0, 0, 0, 0)) { + SDL_SetError("Couldn't allocate new pixel format for requested mode"); return (NULL); } /* Create a new picogui bitmap */ - this->hidden->bitmap = pgCreateBitmap (width, height); - this->hidden->shm = *pgMakeSHMBitmap (this->hidden->bitmap); - current->pixels = shmat (shmget (this->hidden->shm.shm_key, - this->hidden->shm.shm_length, 0), NULL, - 0); + this->hidden->bitmap = pgCreateBitmap(width, height); + this->hidden->shm = *pgMakeSHMBitmap(this->hidden->bitmap); + current->pixels = shmat(shmget(this->hidden->shm.shm_key, + this->hidden->shm.shm_length, 0), NULL, 0); /* Reset the canvas, and draw persistent and incremental grops. * Use mapping and offsets to center it. */ - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_NUKE, 0); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_NUKE, 0); /* 0. Set the source position during incremental rendering */ - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_GROP, 5, PG_GROP_SETSRC, 0, 0, - 0, 0); - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_GROPFLAGS, 1, - PG_GROPF_INCREMENTAL); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 5, PG_GROP_SETSRC, 0, 0, + 0, 0); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROPFLAGS, 1, + PG_GROPF_INCREMENTAL); /* 1. Incremental bitmap rendering */ - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_GROP, 6, PG_GROP_BITMAP, - 0, 0, 0, 0, this->hidden->bitmap); - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_GROPFLAGS, 1, - PG_GROPF_INCREMENTAL); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 6, PG_GROP_BITMAP, + 0, 0, 0, 0, this->hidden->bitmap); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROPFLAGS, 1, + PG_GROPF_INCREMENTAL); /* 2. Normal bitmap rendering */ - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_GROP, 6, PG_GROP_BITMAP, - 0, 0, this->hidden->shm.width, this->hidden->shm.height, - this->hidden->bitmap); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 6, PG_GROP_BITMAP, + 0, 0, this->hidden->shm.width, this->hidden->shm.height, + this->hidden->bitmap); /* Set up the new mode framebuffer */ current->flags = 0; @@ -274,7 +271,7 @@ current->format->Aloss = 8 - this->hidden->shm.alpha_length; /* Draw the app */ - pgUpdate (); + pgUpdate(); /* We're done */ return (current); @@ -282,31 +279,31 @@ /* We don't actually allow hardware surfaces other than the main one */ static int -PG_AllocHWSurface (_THIS, SDL_Surface * surface) +PG_AllocHWSurface(_THIS, SDL_Surface * surface) { return (-1); } static void -PG_FreeHWSurface (_THIS, SDL_Surface * surface) +PG_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } /* We need to wait for vertical retrace on page flipped displays */ static int -PG_LockHWSurface (_THIS, SDL_Surface * surface) +PG_LockHWSurface(_THIS, SDL_Surface * surface) { return (0); } static void -PG_UnlockHWSurface (_THIS, SDL_Surface * surface) +PG_UnlockHWSurface(_THIS, SDL_Surface * surface) { return; } static void -PG_UpdateRects (_THIS, int numrects, SDL_Rect * rects) +PG_UpdateRects(_THIS, int numrects, SDL_Rect * rects) { int i; @@ -317,21 +314,21 @@ /* Schedule an incremental update for this rectangle, using * the canvas gropnodes we've loaded beforehand. */ - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_FINDGROP, 1, 0); - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_MOVEGROP, 4, - rects[i].x, rects[i].y, rects[i].w, rects[i].h); - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_FINDGROP, 1, 1); - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_MOVEGROP, 4, - rects[i].x, rects[i].y, rects[i].w, rects[i].h); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_FINDGROP, 1, 0); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_MOVEGROP, 4, + rects[i].x, rects[i].y, rects[i].w, rects[i].h); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_FINDGROP, 1, 1); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_MOVEGROP, 4, + rects[i].x, rects[i].y, rects[i].w, rects[i].h); /* Go perform the update */ - pgWriteCmd (this->hidden->wCanvas, PGCANVAS_INCREMENTAL, 0); - pgSubUpdate (this->hidden->wCanvas); + pgWriteCmd(this->hidden->wCanvas, PGCANVAS_INCREMENTAL, 0); + pgSubUpdate(this->hidden->wCanvas); } } int -PG_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +PG_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { /* do nothing of note. */ return (1); @@ -341,47 +338,47 @@ another SDL video routine -- notably UpdateRects. */ void -PG_VideoQuit (_THIS) +PG_VideoQuit(_THIS) { if (this->screen->pixels != NULL) { - shmdt (this->screen->pixels); + shmdt(this->screen->pixels); this->screen->pixels = NULL; - pgDelete (this->hidden->bitmap); + pgDelete(this->hidden->bitmap); } - pgDelete (this->hidden->wCanvas); - pgDelete (this->hidden->wApp); + pgDelete(this->hidden->wCanvas); + pgDelete(this->hidden->wApp); } void -PG_SetCaption (_THIS, const char *title, const char *icon) +PG_SetCaption(_THIS, const char *title, const char *icon) { if (title != NULL) - pgReplaceText (this->hidden->wApp, title); - pgUpdate (); + pgReplaceText(this->hidden->wApp, title); + pgUpdate(); } /* FIXME: The cursor stuff isn't implemented yet! */ WMcursor * -PG_CreateWMCursor (_THIS, Uint8 * data, Uint8 * mask, - int w, int h, int hot_x, int hot_y) +PG_CreateWMCursor(_THIS, Uint8 * data, Uint8 * mask, + int w, int h, int hot_x, int hot_y) { static WMcursor dummy; return &dummy; } void -PG_FreeWMCursor (_THIS, WMcursor * cursor) +PG_FreeWMCursor(_THIS, WMcursor * cursor) { } void -PG_WarpWMCursor (_THIS, Uint16 x, Uint16 y) +PG_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { } int -PG_ShowWMCursor (_THIS, WMcursor * cursor) +PG_ShowWMCursor(_THIS, WMcursor * cursor) { return 1; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ps2gs/SDL_gsevents.c --- a/src/video/ps2gs/SDL_gsevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ps2gs/SDL_gsevents.c Mon May 29 04:04:35 2006 +0000 @@ -56,7 +56,7 @@ static Uint16 vga_keymap[NUM_VGAKEYMAPS][NR_KEYS]; static SDLKey keymap[128]; static Uint16 keymap_temp[128]; /* only used at startup */ -static SDL_keysym *TranslateKey (int scancode, SDL_keysym * keysym); +static SDL_keysym *TranslateKey(int scancode, SDL_keysym * keysym); /* Ugh, we have to duplicate the kernel's keysym mapping code... Oh, it's not so bad. :-) @@ -64,7 +64,7 @@ FIXME: Add keyboard LED handling code */ static void -GS_vgainitkeymaps (int fd) +GS_vgainitkeymaps(int fd) { struct kbentry entry; int map, i; @@ -76,21 +76,21 @@ /* Load all the keysym mappings */ for (map = 0; map < NUM_VGAKEYMAPS; ++map) { - SDL_memset (vga_keymap[map], 0, NR_KEYS * sizeof (Uint16)); + SDL_memset(vga_keymap[map], 0, NR_KEYS * sizeof(Uint16)); for (i = 0; i < NR_KEYS; ++i) { entry.kb_table = map; entry.kb_index = i; - if (ioctl (fd, KDGKBENT, &entry) == 0) { + if (ioctl(fd, KDGKBENT, &entry) == 0) { /* fill keytemp. This replaces SDL_fbkeys.h */ if ((map == 0) && (i < 128)) { keymap_temp[i] = entry.kb_value; } /* The "Enter" key is a special case */ if (entry.kb_value == K_ENTER) { - entry.kb_value = K (KT_ASCII, 13); + entry.kb_value = K(KT_ASCII, 13); } /* Handle numpad specially as well */ - if (KTYP (entry.kb_value) == KT_PAD) { + if (KTYP(entry.kb_value) == KT_PAD) { switch (entry.kb_value) { case K_P0: case K_P1: @@ -106,34 +106,34 @@ vga_keymap[map][i] += '0'; break; case K_PPLUS: - vga_keymap[map][i] = K (KT_ASCII, '+'); + vga_keymap[map][i] = K(KT_ASCII, '+'); break; case K_PMINUS: - vga_keymap[map][i] = K (KT_ASCII, '-'); + vga_keymap[map][i] = K(KT_ASCII, '-'); break; case K_PSTAR: - vga_keymap[map][i] = K (KT_ASCII, '*'); + vga_keymap[map][i] = K(KT_ASCII, '*'); break; case K_PSLASH: - vga_keymap[map][i] = K (KT_ASCII, '/'); + vga_keymap[map][i] = K(KT_ASCII, '/'); break; case K_PENTER: - vga_keymap[map][i] = K (KT_ASCII, '\r'); + vga_keymap[map][i] = K(KT_ASCII, '\r'); break; case K_PCOMMA: - vga_keymap[map][i] = K (KT_ASCII, ','); + vga_keymap[map][i] = K(KT_ASCII, ','); break; case K_PDOT: - vga_keymap[map][i] = K (KT_ASCII, '.'); + vga_keymap[map][i] = K(KT_ASCII, '.'); break; default: break; } } /* Do the normal key translation */ - if ((KTYP (entry.kb_value) == KT_LATIN) || - (KTYP (entry.kb_value) == KT_ASCII) || - (KTYP (entry.kb_value) == KT_LETTER)) { + if ((KTYP(entry.kb_value) == KT_LATIN) || + (KTYP(entry.kb_value) == KT_ASCII) || + (KTYP(entry.kb_value) == KT_LETTER)) { vga_keymap[map][i] = entry.kb_value; } } @@ -142,44 +142,44 @@ } int -GS_InGraphicsMode (_THIS) +GS_InGraphicsMode(_THIS) { return ((keyboard_fd >= 0) && (saved_kbd_mode >= 0)); } int -GS_EnterGraphicsMode (_THIS) +GS_EnterGraphicsMode(_THIS) { struct termios keyboard_termios; /* Set medium-raw keyboard mode */ - if ((keyboard_fd >= 0) && !GS_InGraphicsMode (this)) { + if ((keyboard_fd >= 0) && !GS_InGraphicsMode(this)) { /* Switch to the correct virtual terminal */ if (current_vt > 0) { struct vt_stat vtstate; - if (ioctl (keyboard_fd, VT_GETSTATE, &vtstate) == 0) { + if (ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0) { saved_vt = vtstate.v_active; } - if (ioctl (keyboard_fd, VT_ACTIVATE, current_vt) == 0) { - ioctl (keyboard_fd, VT_WAITACTIVE, current_vt); + if (ioctl(keyboard_fd, VT_ACTIVATE, current_vt) == 0) { + ioctl(keyboard_fd, VT_WAITACTIVE, current_vt); } } /* Set the terminal input mode */ - if (tcgetattr (keyboard_fd, &saved_kbd_termios) < 0) { - SDL_SetError ("Unable to get terminal attributes"); + if (tcgetattr(keyboard_fd, &saved_kbd_termios) < 0) { + SDL_SetError("Unable to get terminal attributes"); if (keyboard_fd > 0) { - close (keyboard_fd); + close(keyboard_fd); } keyboard_fd = -1; return (-1); } - if (ioctl (keyboard_fd, KDGKBMODE, &saved_kbd_mode) < 0) { - SDL_SetError ("Unable to get current keyboard mode"); + if (ioctl(keyboard_fd, KDGKBMODE, &saved_kbd_mode) < 0) { + SDL_SetError("Unable to get current keyboard mode"); if (keyboard_fd > 0) { - close (keyboard_fd); + close(keyboard_fd); } keyboard_fd = -1; return (-1); @@ -190,20 +190,20 @@ ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON); keyboard_termios.c_cc[VMIN] = 0; keyboard_termios.c_cc[VTIME] = 0; - if (tcsetattr (keyboard_fd, TCSAFLUSH, &keyboard_termios) < 0) { - GS_CloseKeyboard (this); - SDL_SetError ("Unable to set terminal attributes"); + if (tcsetattr(keyboard_fd, TCSAFLUSH, &keyboard_termios) < 0) { + GS_CloseKeyboard(this); + SDL_SetError("Unable to set terminal attributes"); return (-1); } /* This will fail if we aren't root or this isn't our tty */ - if (ioctl (keyboard_fd, KDSKBMODE, K_MEDIUMRAW) < 0) { - GS_CloseKeyboard (this); - SDL_SetError ("Unable to set keyboard in raw mode"); + if (ioctl(keyboard_fd, KDSKBMODE, K_MEDIUMRAW) < 0) { + GS_CloseKeyboard(this); + SDL_SetError("Unable to set keyboard in raw mode"); return (-1); } - if (ioctl (keyboard_fd, KDSETMODE, KD_GRAPHICS) < 0) { - GS_CloseKeyboard (this); - SDL_SetError ("Unable to set keyboard in graphics mode"); + if (ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS) < 0) { + GS_CloseKeyboard(this); + SDL_SetError("Unable to set keyboard in graphics mode"); return (-1); } } @@ -211,35 +211,35 @@ } void -GS_LeaveGraphicsMode (_THIS) +GS_LeaveGraphicsMode(_THIS) { - if (GS_InGraphicsMode (this)) { - ioctl (keyboard_fd, KDSETMODE, KD_TEXT); - ioctl (keyboard_fd, KDSKBMODE, saved_kbd_mode); - tcsetattr (keyboard_fd, TCSAFLUSH, &saved_kbd_termios); + if (GS_InGraphicsMode(this)) { + ioctl(keyboard_fd, KDSETMODE, KD_TEXT); + ioctl(keyboard_fd, KDSKBMODE, saved_kbd_mode); + tcsetattr(keyboard_fd, TCSAFLUSH, &saved_kbd_termios); saved_kbd_mode = -1; /* Head back over to the original virtual terminal */ if (saved_vt > 0) { - ioctl (keyboard_fd, VT_ACTIVATE, saved_vt); + ioctl(keyboard_fd, VT_ACTIVATE, saved_vt); } } } void -GS_CloseKeyboard (_THIS) +GS_CloseKeyboard(_THIS) { if (keyboard_fd >= 0) { - GS_LeaveGraphicsMode (this); + GS_LeaveGraphicsMode(this); if (keyboard_fd > 0) { - close (keyboard_fd); + close(keyboard_fd); } } keyboard_fd = -1; } int -GS_OpenKeyboard (_THIS) +GS_OpenKeyboard(_THIS) { /* Open only if not already opened */ if (keyboard_fd < 0) { @@ -250,33 +250,33 @@ /* Try to query for a free virtual terminal */ tty0_fd = -1; for (i = 0; tty0[i] && (tty0_fd < 0); ++i) { - tty0_fd = open (tty0[i], O_WRONLY, 0); + tty0_fd = open(tty0[i], O_WRONLY, 0); } if (tty0_fd < 0) { - tty0_fd = dup (0); /* Maybe stdin is a VT? */ + tty0_fd = dup(0); /* Maybe stdin is a VT? */ } - ioctl (tty0_fd, VT_OPENQRY, ¤t_vt); - close (tty0_fd); - if ((geteuid () == 0) && (current_vt > 0)) { + ioctl(tty0_fd, VT_OPENQRY, ¤t_vt); + close(tty0_fd); + if ((geteuid() == 0) && (current_vt > 0)) { for (i = 0; vcs[i] && (keyboard_fd < 0); ++i) { char vtpath[12]; - SDL_snprintf (vtpath, SDL_arraysize (vtpath), vcs[i], - current_vt); - keyboard_fd = open (vtpath, O_RDWR, 0); + SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i], + current_vt); + keyboard_fd = open(vtpath, O_RDWR, 0); #ifdef DEBUG_KEYBOARD - fprintf (stderr, "vtpath = %s, fd = %d\n", - vtpath, keyboard_fd); + fprintf(stderr, "vtpath = %s, fd = %d\n", + vtpath, keyboard_fd); #endif /* DEBUG_KEYBOARD */ /* This needs to be our controlling tty so that the kernel ioctl() calls work */ if (keyboard_fd >= 0) { - tty0_fd = open ("/dev/tty", O_RDWR, 0); + tty0_fd = open("/dev/tty", O_RDWR, 0); if (tty0_fd >= 0) { - ioctl (tty0_fd, TIOCNOTTY, 0); - close (tty0_fd); + ioctl(tty0_fd, TIOCNOTTY, 0); + close(tty0_fd); } } } @@ -284,25 +284,25 @@ if (keyboard_fd < 0) { /* Last resort, maybe our tty is a usable VT */ current_vt = 0; - keyboard_fd = open ("/dev/tty", O_RDWR); + keyboard_fd = open("/dev/tty", O_RDWR); } #ifdef DEBUG_KEYBOARD - fprintf (stderr, "Current VT: %d\n", current_vt); + fprintf(stderr, "Current VT: %d\n", current_vt); #endif saved_kbd_mode = -1; /* Make sure that our input is a console terminal */ { int dummy; - if (ioctl (keyboard_fd, KDGKBMODE, &dummy) < 0) { - close (keyboard_fd); + if (ioctl(keyboard_fd, KDGKBMODE, &dummy) < 0) { + close(keyboard_fd); keyboard_fd = -1; - SDL_SetError ("Unable to open a console terminal"); + SDL_SetError("Unable to open a console terminal"); } } /* Set up keymap */ - GS_vgainitkeymaps (keyboard_fd); + GS_vgainitkeymaps(keyboard_fd); } return (keyboard_fd); } @@ -319,39 +319,39 @@ } mouse_drv = MOUSE_NONE; void -GS_CloseMouse (_THIS) +GS_CloseMouse(_THIS) { if (mouse_fd > 0) { - close (mouse_fd); + close(mouse_fd); } mouse_fd = -1; } /* Returns processes listed in /proc with the desired name */ static int -find_pid (DIR * proc, const char *wanted_name) +find_pid(DIR * proc, const char *wanted_name) { struct dirent *entry; int pid; /* First scan proc for the gpm process */ pid = 0; - while ((pid == 0) && ((entry = readdir (proc)) != NULL)) { - if (isdigit (entry->d_name[0])) { + while ((pid == 0) && ((entry = readdir(proc)) != NULL)) { + if (isdigit(entry->d_name[0])) { FILE *status; char path[PATH_MAX]; char name[PATH_MAX]; - SDL_snprintf (path, SDL_arraysize (path), "/proc/%s/status", - entry->d_name); - status = fopen (path, "r"); + SDL_snprintf(path, SDL_arraysize(path), "/proc/%s/status", + entry->d_name); + status = fopen(path, "r"); if (status) { name[0] = '\0'; - fscanf (status, "Name: %s", name); - if (SDL_strcmp (name, wanted_name) == 0) { - pid = atoi (entry->d_name); + fscanf(status, "Name: %s", name); + if (SDL_strcmp(name, wanted_name) == 0) { + pid = atoi(entry->d_name); } - fclose (status); + fclose(status); } } } @@ -360,7 +360,7 @@ /* Returns true if /dev/gpmdata is being written to by gpm */ static int -gpm_available (void) +gpm_available(void) { int available; DIR *proc; @@ -370,32 +370,31 @@ char args[PATH_MAX], *arg; /* Don't bother looking if the fifo isn't there */ - if (access (GPM_NODE_FIFO, F_OK) < 0) { + if (access(GPM_NODE_FIFO, F_OK) < 0) { return (0); } available = 0; - proc = opendir ("/proc"); + proc = opendir("/proc"); if (proc) { - while ((pid = find_pid (proc, "gpm")) > 0) { - SDL_snprintf (path, SDL_arraysize (path), "/proc/%d/cmdline", - pid); - cmdline = open (path, O_RDONLY, 0); + while ((pid = find_pid(proc, "gpm")) > 0) { + SDL_snprintf(path, SDL_arraysize(path), "/proc/%d/cmdline", pid); + cmdline = open(path, O_RDONLY, 0); if (cmdline >= 0) { - len = read (cmdline, args, sizeof (args)); + len = read(cmdline, args, sizeof(args)); arg = args; while (len > 0) { - if (SDL_strcmp (arg, "-R") == 0) { + if (SDL_strcmp(arg, "-R") == 0) { available = 1; } - arglen = SDL_strlen (arg) + 1; + arglen = SDL_strlen(arg) + 1; len -= arglen; arg += arglen; } - close (cmdline); + close(cmdline); } } - closedir (proc); + closedir(proc); } return available; } @@ -407,7 +406,7 @@ * device to see which mode it's actually in. */ static int -set_imps2_mode (int fd) +set_imps2_mode(int fd) { /* If you wanted to control the mouse mode (and we do :) ) ... Set IMPS/2 protocol: @@ -421,20 +420,20 @@ struct timeval tv; int retval = 0; - if (write (fd, &set_imps2, sizeof (set_imps2)) == sizeof (set_imps2)) { - if (write (fd, &reset, sizeof (reset)) == sizeof (reset)) { + if (write(fd, &set_imps2, sizeof(set_imps2)) == sizeof(set_imps2)) { + if (write(fd, &reset, sizeof(reset)) == sizeof(reset)) { retval = 1; } } /* Get rid of any chatter from the above */ - FD_ZERO (&fdset); - FD_SET (fd, &fdset); + FD_ZERO(&fdset); + FD_SET(fd, &fdset); tv.tv_sec = 0; tv.tv_usec = 0; - while (select (fd + 1, &fdset, 0, 0, &tv) > 0) { + while (select(fd + 1, &fdset, 0, 0, &tv) > 0) { char temp[32]; - read (fd, temp, sizeof (temp)); + read(fd, temp, sizeof(temp)); } return retval; @@ -443,13 +442,13 @@ /* Returns true if the mouse uses the IMPS/2 protocol */ static int -detect_imps2 (int fd) +detect_imps2(int fd) { int imps2; imps2 = 0; - if (SDL_getenv ("SDL_MOUSEDEV_IMPS2")) { + if (SDL_getenv("SDL_MOUSEDEV_IMPS2")) { imps2 = 1; } if (!imps2) { @@ -458,35 +457,35 @@ struct timeval tv; /* Get rid of any mouse motion noise */ - FD_ZERO (&fdset); - FD_SET (fd, &fdset); + FD_ZERO(&fdset); + FD_SET(fd, &fdset); tv.tv_sec = 0; tv.tv_usec = 0; - while (select (fd + 1, &fdset, 0, 0, &tv) > 0) { + while (select(fd + 1, &fdset, 0, 0, &tv) > 0) { char temp[32]; - read (fd, temp, sizeof (temp)); + read(fd, temp, sizeof(temp)); } /* Query for the type of mouse protocol */ - if (write (fd, &query_ps2, sizeof (query_ps2)) == sizeof (query_ps2)) { + if (write(fd, &query_ps2, sizeof(query_ps2)) == sizeof(query_ps2)) { Uint8 ch = 0; /* Get the mouse protocol response */ do { - FD_ZERO (&fdset); - FD_SET (fd, &fdset); + FD_ZERO(&fdset); + FD_SET(fd, &fdset); tv.tv_sec = 1; tv.tv_usec = 0; - if (select (fd + 1, &fdset, 0, 0, &tv) < 1) { + if (select(fd + 1, &fdset, 0, 0, &tv) < 1) { break; } } - while ((read (fd, &ch, sizeof (ch)) == sizeof (ch)) && + while ((read(fd, &ch, sizeof(ch)) == sizeof(ch)) && ((ch == 0xFA) || (ch == 0xAA))); /* Experimental values (Logitech wheelmouse) */ #ifdef DEBUG_MOUSE - fprintf (stderr, "Last mouse mode: 0x%x\n", ch); + fprintf(stderr, "Last mouse mode: 0x%x\n", ch); #endif if (ch == 3) { imps2 = 1; @@ -497,14 +496,14 @@ } int -GS_OpenMouse (_THIS) +GS_OpenMouse(_THIS) { int i; const char *mousedev; const char *mousedrv; - mousedrv = SDL_getenv ("SDL_MOUSEDRV"); - mousedev = SDL_getenv ("SDL_MOUSEDEV"); + mousedrv = SDL_getenv("SDL_MOUSEDRV"); + mousedev = SDL_getenv("SDL_MOUSEDEV"); mouse_fd = -1; /* STD MICE */ @@ -516,11 +515,11 @@ }; /* First try to use GPM in repeater mode */ if (mouse_fd < 0) { - if (gpm_available ()) { - mouse_fd = open (GPM_NODE_FIFO, O_RDONLY, 0); + if (gpm_available()) { + mouse_fd = open(GPM_NODE_FIFO, O_RDONLY, 0); if (mouse_fd >= 0) { #ifdef DEBUG_MOUSE - fprintf (stderr, "Using GPM mouse\n"); + fprintf(stderr, "Using GPM mouse\n"); #endif mouse_drv = MOUSE_GPM; } @@ -528,34 +527,34 @@ } /* Now try to use a modern PS/2 mouse */ for (i = 0; (mouse_fd < 0) && ps2mice[i]; ++i) { - mouse_fd = open (ps2mice[i], O_RDWR, 0); + mouse_fd = open(ps2mice[i], O_RDWR, 0); if (mouse_fd < 0) { - mouse_fd = open (ps2mice[i], O_RDONLY, 0); + mouse_fd = open(ps2mice[i], O_RDONLY, 0); } if (mouse_fd >= 0) { /* rcg06112001 Attempt to set IMPS/2 mode */ if (i == 0) { - set_imps2_mode (mouse_fd); + set_imps2_mode(mouse_fd); } - if (detect_imps2 (mouse_fd)) { + if (detect_imps2(mouse_fd)) { #ifdef DEBUG_MOUSE - fprintf (stderr, "Using IMPS2 mouse\n"); + fprintf(stderr, "Using IMPS2 mouse\n"); #endif mouse_drv = MOUSE_IMPS2; } else { mouse_drv = MOUSE_PS2; #ifdef DEBUG_MOUSE - fprintf (stderr, "Using PS2 mouse\n"); + fprintf(stderr, "Using PS2 mouse\n"); #endif } } } /* Next try to use a PPC ADB port mouse */ if (mouse_fd < 0) { - mouse_fd = open ("/dev/adbmouse", O_RDONLY, 0); + mouse_fd = open("/dev/adbmouse", O_RDONLY, 0); if (mouse_fd >= 0) { #ifdef DEBUG_MOUSE - fprintf (stderr, "Using ADB mouse\n"); + fprintf(stderr, "Using ADB mouse\n"); #endif mouse_drv = MOUSE_BM; } @@ -566,12 +565,12 @@ if (mousedev == NULL) { mousedev = "/dev/mouse"; } - mouse_fd = open (mousedev, O_RDONLY, 0); + mouse_fd = open(mousedev, O_RDONLY, 0); if (mouse_fd >= 0) { struct termios mouse_termios; /* Set the sampling speed to 1200 baud */ - tcgetattr (mouse_fd, &mouse_termios); + tcgetattr(mouse_fd, &mouse_termios); mouse_termios.c_iflag = IGNBRK | IGNPAR; mouse_termios.c_oflag = 0; mouse_termios.c_lflag = 0; @@ -581,9 +580,9 @@ mouse_termios.c_cflag = CREAD | CLOCAL | HUPCL; mouse_termios.c_cflag |= CS8; mouse_termios.c_cflag |= B1200; - tcsetattr (mouse_fd, TCSAFLUSH, &mouse_termios); + tcsetattr(mouse_fd, TCSAFLUSH, &mouse_termios); #ifdef DEBUG_MOUSE - fprintf (stderr, "Using Microsoft mouse on %s\n", mousedev); + fprintf(stderr, "Using Microsoft mouse on %s\n", mousedev); #endif mouse_drv = MOUSE_MS; } @@ -597,7 +596,7 @@ static int posted = 0; void -GS_vgamousecallback (int button, int dx, int dy) +GS_vgamousecallback(int button, int dx, int dy) { int button_1, button_3; int button_state; @@ -606,7 +605,7 @@ Uint8 state; if (dx || dy) { - posted += SDL_PrivateMouseMotion (0, 1, dx, dy); + posted += SDL_PrivateMouseMotion(0, 1, dx, dy); } /* Swap button 1 and 3 */ @@ -616,7 +615,7 @@ button |= (button_1 | button_3); /* See what changed */ - button_state = SDL_GetMouseState (NULL, NULL); + button_state = SDL_GetMouseState(NULL, NULL); state_changed = button_state ^ button; for (i = 0; i < 8; ++i) { if (state_changed & (1 << i)) { @@ -625,7 +624,7 @@ } else { state = SDL_RELEASED; } - posted += SDL_PrivateMouseButton (state, i + 1, 0, 0); + posted += SDL_PrivateMouseButton(state, i + 1, 0, 0); } } } @@ -634,7 +633,7 @@ Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.) */ static void -handle_mouse (_THIS) +handle_mouse(_THIS) { static int start = 0; static unsigned char mousebuf[BUFSIZ]; @@ -647,7 +646,7 @@ switch (mouse_drv) { case MOUSE_NONE: /* Ack! */ - read (mouse_fd, mousebuf, BUFSIZ); + read(mouse_fd, mousebuf, BUFSIZ); return; case MOUSE_GPM: packetsize = 5; @@ -667,13 +666,13 @@ } /* Read as many packets as possible */ - nread = read (mouse_fd, &mousebuf[start], BUFSIZ - start); + nread = read(mouse_fd, &mousebuf[start], BUFSIZ - start); if (nread < 0) { return; } nread += start; #ifdef DEBUG_MOUSE - fprintf (stderr, "Read %d bytes from mouse, start = %d\n", nread, start); + fprintf(stderr, "Read %d bytes from mouse, start = %d\n", nread, start); #endif for (i = 0; i < (nread - (packetsize - 1)); i += packetsize) { switch (mouse_drv) { @@ -725,10 +724,10 @@ case 0x02: /* DX = -1 */ break; case 0x0F: /* DY = +1 (map button 4) */ - FB_vgamousecallback (button | (1 << 3), 1, 0, 0); + FB_vgamousecallback(button | (1 << 3), 1, 0, 0); break; case 0x01: /* DY = -1 (map button 5) */ - FB_vgamousecallback (button | (1 << 4), 1, 0, 0); + FB_vgamousecallback(button | (1 << 4), 1, 0, 0); break; } break; @@ -765,10 +764,10 @@ dy = 0; break; } - GS_vgamousecallback (button, dx, dy); + GS_vgamousecallback(button, dx, dy); } if (i < nread) { - SDL_memcpy (mousebuf, &mousebuf[i], (nread - i)); + SDL_memcpy(mousebuf, &mousebuf[i], (nread - i)); start = (nread - i); } else { start = 0; @@ -777,7 +776,7 @@ } static void -handle_keyboard (_THIS) +handle_keyboard(_THIS) { unsigned char keybuf[BUFSIZ]; int i, nread; @@ -785,7 +784,7 @@ int scancode; SDL_keysym keysym; - nread = read (keyboard_fd, keybuf, BUFSIZ); + nread = read(keyboard_fd, keybuf, BUFSIZ); for (i = 0; i < nread; ++i) { scancode = keybuf[i] & 0x7F; if (keybuf[i] & 0x80) { @@ -793,13 +792,13 @@ } else { pressed = SDL_PRESSED; } - TranslateKey (scancode, &keysym); - posted += SDL_PrivateKeyboard (pressed, &keysym); + TranslateKey(scancode, &keysym); + posted += SDL_PrivateKeyboard(pressed, &keysym); } } void -GS_PumpEvents (_THIS) +GS_PumpEvents(_THIS) { fd_set fdset; int max_fd; @@ -808,29 +807,29 @@ do { posted = 0; - FD_ZERO (&fdset); + FD_ZERO(&fdset); max_fd = 0; if (keyboard_fd >= 0) { - FD_SET (keyboard_fd, &fdset); + FD_SET(keyboard_fd, &fdset); if (max_fd < keyboard_fd) { max_fd = keyboard_fd; } } if (mouse_fd >= 0) { - FD_SET (mouse_fd, &fdset); + FD_SET(mouse_fd, &fdset); if (max_fd < mouse_fd) { max_fd = mouse_fd; } } - if (select (max_fd + 1, &fdset, NULL, NULL, &zero) > 0) { + if (select(max_fd + 1, &fdset, NULL, NULL, &zero) > 0) { if (keyboard_fd >= 0) { - if (FD_ISSET (keyboard_fd, &fdset)) { - handle_keyboard (this); + if (FD_ISSET(keyboard_fd, &fdset)) { + handle_keyboard(this); } } if (mouse_fd >= 0) { - if (FD_ISSET (mouse_fd, &fdset)) { - handle_mouse (this); + if (FD_ISSET(mouse_fd, &fdset)) { + handle_mouse(this); } } } @@ -839,14 +838,14 @@ } void -GS_InitOSKeymap (_THIS) +GS_InitOSKeymap(_THIS) { int i; /* Initialize the Linux key translation table */ /* First get the ascii keys and others not well handled */ - for (i = 0; i < SDL_arraysize (keymap); ++i) { + for (i = 0; i < SDL_arraysize(keymap); ++i) { switch (i) { /* These aren't handled by the x86 kernel keymapping (?) */ case SCANCODE_PRINTSCREEN: @@ -881,11 +880,11 @@ break; /* this should take care of all standard ascii keys */ default: - keymap[i] = KVAL (vga_keymap[0][i]); + keymap[i] = KVAL(vga_keymap[0][i]); break; } } - for (i = 0; i < SDL_arraysize (keymap); ++i) { + for (i = 0; i < SDL_arraysize(keymap); ++i) { switch (keymap_temp[i]) { case K_F1: keymap[i] = SDLK_F1; @@ -1060,7 +1059,7 @@ } static SDL_keysym * -TranslateKey (int scancode, SDL_keysym * keysym) +TranslateKey(int scancode, SDL_keysym * keysym) { /* Set the keysym information */ keysym->scancode = scancode; @@ -1073,7 +1072,7 @@ int map; SDLMod modstate; - modstate = SDL_GetModState (); + modstate = SDL_GetModState(); map = 0; if (modstate & KMOD_SHIFT) { map |= (1 << KG_SHIFT); @@ -1087,17 +1086,17 @@ if (modstate & KMOD_MODE) { map |= (1 << KG_ALTGR); } - if (KTYP (vga_keymap[map][scancode]) == KT_LETTER) { + if (KTYP(vga_keymap[map][scancode]) == KT_LETTER) { if (modstate & KMOD_CAPS) { map ^= (1 << KG_SHIFT); } } - if (KTYP (vga_keymap[map][scancode]) == KT_PAD) { + if (KTYP(vga_keymap[map][scancode]) == KT_PAD) { if (modstate & KMOD_NUM) { - keysym->unicode = KVAL (vga_keymap[map][scancode]); + keysym->unicode = KVAL(vga_keymap[map][scancode]); } } else { - keysym->unicode = KVAL (vga_keymap[map][scancode]); + keysym->unicode = KVAL(vga_keymap[map][scancode]); } } return (keysym); diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ps2gs/SDL_gsevents_c.h --- a/src/video/ps2gs/SDL_gsevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ps2gs/SDL_gsevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -26,14 +26,14 @@ /* Variables and functions exported by SDL_sysevents.c to other parts of the native video subsystem (SDL_sysvideo.c) */ -extern int GS_OpenKeyboard (_THIS); -extern void GS_CloseKeyboard (_THIS); -extern int GS_OpenMouse (_THIS); -extern void GS_CloseMouse (_THIS); -extern int GS_EnterGraphicsMode (_THIS); -extern int GS_InGraphicsMode (_THIS); -extern void GS_LeaveGraphicsMode (_THIS); +extern int GS_OpenKeyboard(_THIS); +extern void GS_CloseKeyboard(_THIS); +extern int GS_OpenMouse(_THIS); +extern void GS_CloseMouse(_THIS); +extern int GS_EnterGraphicsMode(_THIS); +extern int GS_InGraphicsMode(_THIS); +extern void GS_LeaveGraphicsMode(_THIS); -extern void GS_InitOSKeymap (_THIS); -extern void GS_PumpEvents (_THIS); +extern void GS_InitOSKeymap(_THIS); +extern void GS_PumpEvents(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ps2gs/SDL_gsmouse.c --- a/src/video/ps2gs/SDL_gsmouse.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ps2gs/SDL_gsmouse.c Mon May 29 04:04:35 2006 +0000 @@ -38,22 +38,22 @@ /* There isn't any implementation dependent data */ void -GS_FreeWMCursor (_THIS, WMcursor * cursor) +GS_FreeWMCursor(_THIS, WMcursor * cursor) { return; } /* There isn't any implementation dependent data */ WMcursor * -GS_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, int hot_x, - int hot_y) +GS_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, int hot_x, + int hot_y) { return ((WMcursor *) 0x01); } static void -GS_MoveCursor (_THIS, SDL_Cursor * cursor, int x, int y) +GS_MoveCursor(_THIS, SDL_Cursor * cursor, int x, int y) { SDL_Surface *screen; struct ps2_image image; @@ -63,11 +63,11 @@ int screen_updated; /* Lock so we don't interrupt an update with mouse motion */ - SDL_LockCursor (); + SDL_LockCursor(); /* Make sure any pending DMA has completed */ if (dma_pending) { - ioctl (console_fd, PS2IOC_SENDQCT, 1); + ioctl(console_fd, PS2IOC_SENDQCT, 1); dma_pending = 0; } @@ -77,13 +77,13 @@ screen->pixels = mapped_mem + screen->offset; screen_updated = 0; if (cursor_drawn) { - SDL_EraseCursorNoLock (screen); + SDL_EraseCursorNoLock(screen); cursor_drawn = 0; screen_updated = 1; } /* Save the current mouse area */ - SDL_MouseRect (&area); + SDL_MouseRect(&area); mouse_y1 = area.y; mouse_y2 = area.y + area.h; @@ -95,7 +95,7 @@ /* Draw the cursor at the new location */ if ((SDL_cursorstate & CURSOR_VISIBLE) && screen->pixels) { - SDL_DrawCursorNoLock (screen); + SDL_DrawCursorNoLock(screen); cursor_drawn = 1; screen_updated = 1; } @@ -104,7 +104,7 @@ /* Update the affected area of the screen */ if (screen_updated) { - SDL_MouseRect (&area); + SDL_MouseRect(&area); if (area.y < mouse_y1) { mouse_y1 = area.y; } @@ -115,38 +115,38 @@ image.y += screen->offset / screen->pitch + mouse_y1; image.h = mouse_y2 - mouse_y1; image.ptr = mapped_mem + (image.y - screen_image.y) * screen->pitch; - ioctl (console_fd, PS2IOC_LOADIMAGE, &image); + ioctl(console_fd, PS2IOC_LOADIMAGE, &image); /* Need to scale offscreen image to TV output */ if (image.y > 0) { - scaleimage_nonblock (console_fd, tex_tags_mem, scale_tags_mem); + scaleimage_nonblock(console_fd, tex_tags_mem, scale_tags_mem); } } /* We're finished */ - SDL_UnlockCursor (); + SDL_UnlockCursor(); } void -GS_MoveWMCursor (_THIS, int x, int y) +GS_MoveWMCursor(_THIS, int x, int y) { - GS_MoveCursor (this, SDL_cursor, x, y); + GS_MoveCursor(this, SDL_cursor, x, y); } int -GS_ShowWMCursor (_THIS, WMcursor * wmcursor) +GS_ShowWMCursor(_THIS, WMcursor * wmcursor) { SDL_Cursor *cursor; int x, y; /* Draw the cursor at the appropriate location */ - SDL_GetMouseState (&x, &y); + SDL_GetMouseState(&x, &y); if (wmcursor) { cursor = SDL_cursor; } else { cursor = NULL; } - GS_MoveCursor (this, cursor, x, y); + GS_MoveCursor(this, cursor, x, y); return (1); } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ps2gs/SDL_gsmouse_c.h --- a/src/video/ps2gs/SDL_gsmouse_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ps2gs/SDL_gsmouse_c.h Mon May 29 04:04:35 2006 +0000 @@ -30,10 +30,10 @@ #define CURSOR_H_POW 5 /* 32 = 2^5 */ /* Functions to be exported */ -extern void GS_FreeWMCursor (_THIS, WMcursor * cursor); -extern WMcursor *GS_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, - int hot_x, int hot_y); -extern void GS_MoveWMCursor (_THIS, int x, int y); -extern int GS_ShowWMCursor (_THIS, WMcursor * cursor); +extern void GS_FreeWMCursor(_THIS, WMcursor * cursor); +extern WMcursor *GS_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, + int hot_x, int hot_y); +extern void GS_MoveWMCursor(_THIS, int x, int y); +extern int GS_ShowWMCursor(_THIS, WMcursor * cursor); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ps2gs/SDL_gsvideo.c --- a/src/video/ps2gs/SDL_gsvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ps2gs/SDL_gsvideo.c Mon May 29 04:04:35 2006 +0000 @@ -42,66 +42,65 @@ /* Initialization/Query functions */ -static int GS_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **GS_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *GS_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int GS_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void GS_VideoQuit (_THIS); +static int GS_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **GS_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags); +static SDL_Surface *GS_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +static int GS_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void GS_VideoQuit(_THIS); /* Hardware surface functions */ -static int GS_AllocHWSurface (_THIS, SDL_Surface * surface); -static int GS_LockHWSurface (_THIS, SDL_Surface * surface); -static void GS_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void GS_FreeHWSurface (_THIS, SDL_Surface * surface); +static int GS_AllocHWSurface(_THIS, SDL_Surface * surface); +static int GS_LockHWSurface(_THIS, SDL_Surface * surface); +static void GS_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void GS_FreeHWSurface(_THIS, SDL_Surface * surface); /* GS driver bootstrap functions */ static int -GS_Available (void) +GS_Available(void) { int console, memory; - console = open (PS2_DEV_GS, O_RDWR, 0); + console = open(PS2_DEV_GS, O_RDWR, 0); if (console >= 0) { - close (console); + close(console); } - memory = open (PS2_DEV_MEM, O_RDWR, 0); + memory = open(PS2_DEV_MEM, O_RDWR, 0); if (memory >= 0) { - close (memory); + close(memory); } return ((console >= 0) && (memory >= 0)); } static void -GS_DeleteDevice (SDL_VideoDevice * device) +GS_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -GS_CreateDevice (int devindex) +GS_CreateDevice(int devindex) { SDL_VideoDevice *this; /* Initialize all variables that we clean on shutdown */ - this = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + this = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (this) { - SDL_memset (this, 0, (sizeof *this)); + SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *this->hidden)); + SDL_malloc((sizeof *this->hidden)); } if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (this) { - SDL_free (this); + SDL_free(this); } return (0); } - SDL_memset (this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); mouse_fd = -1; keyboard_fd = -1; @@ -167,7 +166,7 @@ PS2_GS_PSMCT32 /* 32 bpp */ }; -static unsigned long long head_tags[] __attribute__ ((aligned (16))) = { +static unsigned long long head_tags[] __attribute__ ((aligned(16))) = { 4 | (1LL << 60), /* GIFtag */ 0x0e, /* A+D */ 0, /* 2 */ @@ -180,8 +179,8 @@ #define MAXTAGS 8 static inline int -loadimage_nonblock (int fd, struct ps2_image *image, int size, - unsigned long long *hm, unsigned long long *im) +loadimage_nonblock(int fd, struct ps2_image *image, int size, + unsigned long long *hm, unsigned long long *im) { struct ps2_plist plist; struct ps2_packet packet[1 + MAXTAGS * 2]; @@ -196,7 +195,7 @@ /* make BITBLT packet */ packet[pnum].ptr = hm; - packet[pnum].len = sizeof (head_tags); + packet[pnum].len = sizeof(head_tags); pnum++; hm[2] = ((unsigned long long) image->fbp << 32) | ((unsigned long long) image->fbw << 48) | @@ -213,7 +212,7 @@ eop = (size == 0); packet[pnum].ptr = &im[it]; - packet[pnum].len = sizeof (unsigned long long) * 2; + packet[pnum].len = sizeof(unsigned long long) * 2; pnum++; im[it++] = (isize >> 4) | (eop ? (1 << 15) : 0) | (2LL << 58); im[it++] = 0; @@ -225,15 +224,15 @@ } plist.num = pnum; - return ioctl (fd, PS2IOC_SENDL, &plist); + return ioctl(fd, PS2IOC_SENDL, &plist); } -static unsigned long long tex_tags[] __attribute__ ((aligned (16))) = { +static unsigned long long tex_tags[] __attribute__ ((aligned(16))) = { 3 | (1LL << 60), /* GIFtag */ 0x0e, /* A+D */ 0, /* 2 */ PS2_GS_TEX0_1, (1 << 5) + (1 << 6), PS2_GS_TEX1_1, 0, PS2_GS_TEXFLUSH}; -static unsigned long long scale_tags[] __attribute__ ((aligned (16))) = { +static unsigned long long scale_tags[] __attribute__ ((aligned(16))) = { 5 | (1LL << 60), /* GIFtag */ 0x0e, /* A+D */ 6 + (1 << 4) + (1 << 8), PS2_GS_PRIM, ((unsigned long long) 0 * 16) + (((unsigned long long) 0 * 16) << 16), PS2_GS_UV, ((unsigned long long) 0 * 16) + (((unsigned long long) 0 * 16) << 16), PS2_GS_XYZ2, 0, /* 8 */ @@ -242,7 +241,7 @@ int -scaleimage_nonblock (int fd, unsigned long long *tm, unsigned long long *sm) +scaleimage_nonblock(int fd, unsigned long long *tm, unsigned long long *sm) { struct ps2_plist plist; struct ps2_packet packet[2]; @@ -252,15 +251,15 @@ plist.packet = packet; packet[0].ptr = tm; - packet[0].len = sizeof (tex_tags); + packet[0].len = sizeof(tex_tags); packet[1].ptr = sm; - packet[1].len = sizeof (scale_tags); + packet[1].len = sizeof(scale_tags); - return ioctl (fd, PS2IOC_SENDL, &plist); + return ioctl(fd, PS2IOC_SENDL, &plist); } static int -power_of_2 (int value) +power_of_2(int value) { int shift; @@ -271,29 +270,29 @@ } static int -GS_VideoInit (_THIS, SDL_PixelFormat * vformat) +GS_VideoInit(_THIS, SDL_PixelFormat * vformat) { struct ps2_screeninfo vinfo; /* Initialize the library */ - console_fd = open (PS2_DEV_GS, O_RDWR, 0); + console_fd = open(PS2_DEV_GS, O_RDWR, 0); if (console_fd < 0) { - SDL_SetError ("Unable to open %s", PS2_DEV_GS); + SDL_SetError("Unable to open %s", PS2_DEV_GS); return (-1); } - memory_fd = open (PS2_DEV_MEM, O_RDWR, 0); + memory_fd = open(PS2_DEV_MEM, O_RDWR, 0); if (memory_fd < 0) { - close (console_fd); + close(console_fd); console_fd = -1; - SDL_SetError ("Unable to open %s", PS2_DEV_MEM); + SDL_SetError("Unable to open %s", PS2_DEV_MEM); return (-1); } - if (ioctl (console_fd, PS2IOC_GSCREENINFO, &vinfo) < 0) { - close (memory_fd); - close (console_fd); + if (ioctl(console_fd, PS2IOC_GSCREENINFO, &vinfo) < 0) { + close(memory_fd); + close(console_fd); console_fd = -1; - SDL_SetError ("Couldn't get console pixel format"); + SDL_SetError("Couldn't get console pixel format"); return (-1); } @@ -309,8 +308,8 @@ case PS2_GS_PSMCT16: break; default: - GS_VideoQuit (this); - SDL_SetError ("Unknown console pixel format: %d", vinfo.psm); + GS_VideoQuit(this); + SDL_SetError("Unknown console pixel format: %d", vinfo.psm); return (-1); } vformat->BitsPerPixel = GS_pixelmasks[vinfo.psm].bpp; @@ -320,18 +319,18 @@ saved_vinfo = vinfo; /* Enable mouse and keyboard support */ - if (GS_OpenKeyboard (this) < 0) { - GS_VideoQuit (this); - SDL_SetError ("Unable to open keyboard"); + if (GS_OpenKeyboard(this) < 0) { + GS_VideoQuit(this); + SDL_SetError("Unable to open keyboard"); return (-1); } - if (GS_OpenMouse (this) < 0) { + if (GS_OpenMouse(this) < 0) { const char *sdl_nomouse; - sdl_nomouse = SDL_getenv ("SDL_NOMOUSE"); + sdl_nomouse = SDL_getenv("SDL_NOMOUSE"); if (!sdl_nomouse) { - GS_VideoQuit (this); - SDL_SetError ("Unable to open mouse"); + GS_VideoQuit(this); + SDL_SetError("Unable to open mouse"); return (-1); } } @@ -341,7 +340,7 @@ } static SDL_Rect ** -GS_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +GS_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { static SDL_Rect GS_vesa_mode_list[] = { {0, 0, 1280, 1024}, @@ -400,22 +399,22 @@ } /* Various screen update functions available */ -static void GS_DMAFullUpdate (_THIS, int numrects, SDL_Rect * rects); +static void GS_DMAFullUpdate(_THIS, int numrects, SDL_Rect * rects); static SDL_Surface * -GS_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +GS_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { struct ps2_screeninfo vinfo; /* Set the terminal into graphics mode */ - if (GS_EnterGraphicsMode (this) < 0) { + if (GS_EnterGraphicsMode(this) < 0) { return (NULL); } /* Set the video mode and get the final screen format */ - if (ioctl (console_fd, PS2IOC_GSCREENINFO, &vinfo) < 0) { - SDL_SetError ("Couldn't get console screen info"); + if (ioctl(console_fd, PS2IOC_GSCREENINFO, &vinfo) < 0) { + SDL_SetError("Couldn't get console screen info"); return (NULL); } if ((vinfo.w != width) || (vinfo.h != height) || @@ -436,8 +435,8 @@ vinfo.res = PS2_GS_1280x1024; break; default: - SDL_SetError ("Unsupported resolution: %dx%d\n", - width, height); + SDL_SetError("Unsupported resolution: %dx%d\n", + width, height); return (NULL); } vinfo.res |= (PS2_GS_75Hz << 8); @@ -447,24 +446,24 @@ vinfo.fbp = 0; vinfo.psm = GS_formatmap[bpp / 8]; if (vinfo.psm < 0) { - SDL_SetError ("Unsupported depth: %d bpp\n", bpp); + SDL_SetError("Unsupported depth: %d bpp\n", bpp); return (NULL); } - if (ioctl (console_fd, PS2IOC_SSCREENINFO, &vinfo) < 0) { - SDL_SetError ("Couldn't set console screen info"); + if (ioctl(console_fd, PS2IOC_SSCREENINFO, &vinfo) < 0) { + SDL_SetError("Couldn't set console screen info"); return (NULL); } /* Unmap the previous DMA buffer */ if (mapped_mem) { - munmap (mapped_mem, mapped_len); + munmap(mapped_mem, mapped_len); mapped_mem = NULL; } } - if (!SDL_ReallocFormat (current, GS_pixelmasks[vinfo.psm].bpp, - GS_pixelmasks[vinfo.psm].r, - GS_pixelmasks[vinfo.psm].g, - GS_pixelmasks[vinfo.psm].b, 0)) { + if (!SDL_ReallocFormat(current, GS_pixelmasks[vinfo.psm].bpp, + GS_pixelmasks[vinfo.psm].r, + GS_pixelmasks[vinfo.psm].g, + GS_pixelmasks[vinfo.psm].b, 0)) { return (NULL); } @@ -472,21 +471,21 @@ current->flags = SDL_FULLSCREEN; current->w = width; current->h = height; - current->pitch = SDL_CalculatePitch (current); + current->pitch = SDL_CalculatePitch(current); /* Memory map the DMA area for block memory transfer */ if (!mapped_mem) { pixels_len = height * current->pitch; mapped_len = pixels_len + /* Screen update DMA command area */ - sizeof (head_tags) + ((2 * MAXTAGS) * 16); + sizeof(head_tags) + ((2 * MAXTAGS) * 16); if (saved_vinfo.mode != PS2_GS_VESA) { - mapped_len += sizeof (tex_tags) + sizeof (scale_tags); + mapped_len += sizeof(tex_tags) + sizeof(scale_tags); } - mapped_mem = mmap (0, mapped_len, PROT_READ | PROT_WRITE, - MAP_SHARED, memory_fd, 0); + mapped_mem = mmap(0, mapped_len, PROT_READ | PROT_WRITE, + MAP_SHARED, memory_fd, 0); if (mapped_mem == MAP_FAILED) { - SDL_SetError ("Unable to map %d bytes for DMA", mapped_len); + SDL_SetError("Unable to map %d bytes for DMA", mapped_len); mapped_mem = NULL; return (NULL); } @@ -524,23 +523,23 @@ /* Set up the memory for screen update DMA commands */ head_tags_mem = (unsigned long long *) (mapped_mem + pixels_len); image_tags_mem = (unsigned long long *) - ((caddr_t) head_tags_mem + sizeof (head_tags)); - SDL_memcpy (head_tags_mem, head_tags, sizeof (head_tags)); + ((caddr_t) head_tags_mem + sizeof(head_tags)); + SDL_memcpy(head_tags_mem, head_tags, sizeof(head_tags)); if (saved_vinfo.mode != PS2_GS_VESA) { tex_tags_mem = (unsigned long long *) ((caddr_t) image_tags_mem + ((2 * MAXTAGS) * 16)); scale_tags_mem = (unsigned long long *) - ((caddr_t) tex_tags_mem + sizeof (tex_tags)); - SDL_memcpy (tex_tags_mem, tex_tags, sizeof (tex_tags)); + ((caddr_t) tex_tags_mem + sizeof(tex_tags)); + SDL_memcpy(tex_tags_mem, tex_tags, sizeof(tex_tags)); tex_tags_mem[2] = (vinfo.h * vinfo.w) / 64 + ((unsigned long long) screen_image.fbw << 14) + ((unsigned long long) screen_image.psm << 20) + - ((unsigned long long) power_of_2 (screen_image.w) << 26) + - ((unsigned long long) power_of_2 (screen_image.h) << 30) + + ((unsigned long long) power_of_2(screen_image.w) << 26) + + ((unsigned long long) power_of_2(screen_image.h) << 30) + ((unsigned long long) 1 << 34) + ((unsigned long long) 1 << 35); - SDL_memcpy (scale_tags_mem, scale_tags, sizeof (scale_tags)); + SDL_memcpy(scale_tags_mem, scale_tags, sizeof(scale_tags)); scale_tags_mem[8] = ((unsigned long long) screen_image.w * 16) + (((unsigned long long) screen_image.h * 16) << 16); @@ -550,7 +549,7 @@ } } current->pixels = NULL; - if (SDL_getenv ("SDL_FULLSCREEN_UPDATE")) { + if (SDL_getenv("SDL_FULLSCREEN_UPDATE")) { /* Correct semantics */ current->flags |= SDL_ASYNCBLIT; } else { @@ -570,32 +569,32 @@ /* We don't support hardware surfaces yet */ static int -GS_AllocHWSurface (_THIS, SDL_Surface * surface) +GS_AllocHWSurface(_THIS, SDL_Surface * surface) { return (-1); } static void -GS_FreeHWSurface (_THIS, SDL_Surface * surface) +GS_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } static int -GS_LockHWSurface (_THIS, SDL_Surface * surface) +GS_LockHWSurface(_THIS, SDL_Surface * surface) { if (surface == this->screen) { /* Since mouse motion affects 'pixels', lock it */ - SDL_LockCursor (); + SDL_LockCursor(); /* Make sure any pending DMA has completed */ if (dma_pending) { - ioctl (console_fd, PS2IOC_SENDQCT, 1); + ioctl(console_fd, PS2IOC_SENDQCT, 1); dma_pending = 0; } /* If the cursor is drawn on the DMA area, remove it */ if (cursor_drawn) { surface->pixels = mapped_mem + surface->offset; - SDL_EraseCursorNoLock (this->screen); + SDL_EraseCursorNoLock(this->screen); cursor_drawn = 0; } @@ -603,88 +602,88 @@ surface->pixels = mapped_mem; /* We're finished! */ - SDL_UnlockCursor (); + SDL_UnlockCursor(); } return (0); } static void -GS_UnlockHWSurface (_THIS, SDL_Surface * surface) +GS_UnlockHWSurface(_THIS, SDL_Surface * surface) { if (surface == this->screen) { /* Since mouse motion affects 'pixels', lock it */ - SDL_LockCursor (); + SDL_LockCursor(); surface->pixels = NULL; - SDL_UnlockCursor (); + SDL_UnlockCursor(); } } static void -GS_DMAFullUpdate (_THIS, int numrects, SDL_Rect * rects) +GS_DMAFullUpdate(_THIS, int numrects, SDL_Rect * rects) { /* Lock so we aren't interrupted by a mouse update */ - SDL_LockCursor (); + SDL_LockCursor(); /* Make sure any pending DMA has completed */ if (dma_pending) { - ioctl (console_fd, PS2IOC_SENDQCT, 1); + ioctl(console_fd, PS2IOC_SENDQCT, 1); dma_pending = 0; } /* If the mouse is visible, draw it on the DMA area */ if ((SDL_cursorstate & CURSOR_VISIBLE) && !cursor_drawn) { this->screen->pixels = mapped_mem + this->screen->offset; - SDL_DrawCursorNoLock (this->screen); + SDL_DrawCursorNoLock(this->screen); this->screen->pixels = NULL; cursor_drawn = 1; } /* Put the image onto the screen */ - loadimage_nonblock (console_fd, - &screen_image, screen_image_size, - head_tags_mem, image_tags_mem); + loadimage_nonblock(console_fd, + &screen_image, screen_image_size, + head_tags_mem, image_tags_mem); if (screen_image.y > 0) { /* Need to scale offscreen image to TV output */ - ioctl (console_fd, PS2IOC_SENDQCT, 1); + ioctl(console_fd, PS2IOC_SENDQCT, 1); dma_pending = 0; - scaleimage_nonblock (console_fd, tex_tags_mem, scale_tags_mem); + scaleimage_nonblock(console_fd, tex_tags_mem, scale_tags_mem); } else { dma_pending = 1; } /* We're finished! */ - SDL_UnlockCursor (); + SDL_UnlockCursor(); } static int -GS_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +GS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { return (0); } static void -GS_VideoQuit (_THIS) +GS_VideoQuit(_THIS) { /* Close console and input file descriptors */ if (console_fd > 0) { /* Unmap the video framebuffer */ if (mapped_mem) { /* Unmap the video framebuffer */ - munmap (mapped_mem, mapped_len); + munmap(mapped_mem, mapped_len); mapped_mem = NULL; } - close (memory_fd); + close(memory_fd); /* Restore the original video mode */ - if (GS_InGraphicsMode (this)) { - ioctl (console_fd, PS2IOC_SSCREENINFO, &saved_vinfo); + if (GS_InGraphicsMode(this)) { + ioctl(console_fd, PS2IOC_SSCREENINFO, &saved_vinfo); } /* We're all done with the graphics device */ - close (console_fd); + close(console_fd); console_fd = -1; } - GS_CloseMouse (this); - GS_CloseKeyboard (this); + GS_CloseMouse(this); + GS_CloseKeyboard(this); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ps2gs/SDL_gsvideo.h --- a/src/video/ps2gs/SDL_gsvideo.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ps2gs/SDL_gsvideo.h Mon May 29 04:04:35 2006 +0000 @@ -91,8 +91,8 @@ #define dma_pending (this->hidden->dma_pending) /* Shared between the mouse and video code for screen update scaling */ -extern int scaleimage_nonblock (int fd, - unsigned long long *tm, - unsigned long long *sm); +extern int scaleimage_nonblock(int fd, + unsigned long long *tm, + unsigned long long *sm); #endif /* _SDL_gsvideo_h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ps2gs/SDL_gsyuv.c --- a/src/video/ps2gs/SDL_gsyuv.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ps2gs/SDL_gsyuv.c Mon May 29 04:04:35 2006 +0000 @@ -64,7 +64,7 @@ }; static int -power_of_2 (int value) +power_of_2(int value) { int shift; @@ -75,8 +75,8 @@ } SDL_Overlay * -GS_CreateYUVOverlay (_THIS, int width, int height, Uint32 format, - SDL_Surface * display) +GS_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, + SDL_Surface * display) { SDL_Overlay *overlay; struct private_yuvhwdata *hwdata; @@ -92,13 +92,13 @@ /* We can only decode blocks of 16x16 pixels */ if ((width & 15) || (height & 15)) { - SDL_SetError ("Overlay width/height must be multiples of 16"); + SDL_SetError("Overlay width/height must be multiples of 16"); return (NULL); } /* Make sure the image isn't too large for a single DMA transfer */ if (((width / 16) * (height / 16)) > MAX_MACROBLOCKS) { - SDL_SetError ("Overlay too large (maximum size: %d pixels)", - MAX_MACROBLOCKS * 16 * 16); + SDL_SetError("Overlay too large (maximum size: %d pixels)", + MAX_MACROBLOCKS * 16 * 16); return (NULL); } @@ -111,17 +111,17 @@ /* Supported planar YUV format */ break; default: - SDL_SetError ("Unsupported YUV format"); + SDL_SetError("Unsupported YUV format"); return (NULL); } /* Create the overlay structure */ - overlay = (SDL_Overlay *) SDL_malloc (sizeof *overlay); + overlay = (SDL_Overlay *) SDL_malloc(sizeof *overlay); if (overlay == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } - SDL_memset (overlay, 0, (sizeof *overlay)); + SDL_memset(overlay, 0, (sizeof *overlay)); /* Fill in the basic members */ overlay->format = format; @@ -133,18 +133,18 @@ overlay->hw_overlay = 1; /* Create the pixel data */ - hwdata = (struct private_yuvhwdata *) SDL_malloc (sizeof *hwdata); + hwdata = (struct private_yuvhwdata *) SDL_malloc(sizeof *hwdata); overlay->hwdata = hwdata; if (hwdata == NULL) { - SDL_FreeYUVOverlay (overlay); - SDL_OutOfMemory (); + SDL_FreeYUVOverlay(overlay); + SDL_OutOfMemory(); return (NULL); } hwdata->ipu_fd = -1; - hwdata->pixels = (Uint8 *) SDL_malloc (width * height * 2); + hwdata->pixels = (Uint8 *) SDL_malloc(width * height * 2); if (hwdata->pixels == NULL) { - SDL_FreeYUVOverlay (overlay); - SDL_OutOfMemory (); + SDL_FreeYUVOverlay(overlay); + SDL_OutOfMemory(); return (NULL); } hwdata->macroblocks = (width / 16) * (height / 16); @@ -175,10 +175,10 @@ simplicity we'll support only one. Opening the IPU more than once will fail with EBUSY. */ - hwdata->ipu_fd = open ("/dev/ps2ipu", O_RDWR); + hwdata->ipu_fd = open("/dev/ps2ipu", O_RDWR); if (hwdata->ipu_fd < 0) { - SDL_FreeYUVOverlay (overlay); - SDL_SetError ("Playstation 2 IPU busy"); + SDL_FreeYUVOverlay(overlay); + SDL_SetError("Playstation 2 IPU busy"); return (NULL); } @@ -187,14 +187,14 @@ map_offset = (mapped_len + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); hwdata->dma_len = hwdata->macroblocks * (16 * 16 + 8 * 8 + 8 * 8) + width * height * bpp + - hwdata->macroblocks * (16 * sizeof (long long)) + - 12 * sizeof (long long); - hwdata->dma_mem = mmap (0, hwdata->dma_len, PROT_READ | PROT_WRITE, - MAP_SHARED, memory_fd, map_offset); + hwdata->macroblocks * (16 * sizeof(long long)) + + 12 * sizeof(long long); + hwdata->dma_mem = mmap(0, hwdata->dma_len, PROT_READ | PROT_WRITE, + MAP_SHARED, memory_fd, map_offset); if (hwdata->dma_mem == MAP_FAILED) { hwdata->ipu_imem = (caddr_t) 0; - SDL_FreeYUVOverlay (overlay); - SDL_SetError ("Unable to map %d bytes for DMA", hwdata->dma_len); + SDL_FreeYUVOverlay(overlay); + SDL_SetError("Unable to map %d bytes for DMA", hwdata->dma_len); return (NULL); } hwdata->ipu_imem = hwdata->dma_mem; @@ -205,11 +205,11 @@ /* Allocate memory for the DMA packets */ hwdata->plist.num = hwdata->macroblocks * 4 + 1; hwdata->plist.packet = - (struct ps2_packet *) SDL_malloc (hwdata->plist.num * - sizeof (struct ps2_packet)); + (struct ps2_packet *) SDL_malloc(hwdata->plist.num * + sizeof(struct ps2_packet)); if (!hwdata->plist.packet) { - SDL_FreeYUVOverlay (overlay); - SDL_OutOfMemory (); + SDL_FreeYUVOverlay(overlay); + SDL_OutOfMemory(); return (NULL); } pnum = 0; @@ -227,7 +227,7 @@ for (w = width / 16; w; --w) { /* The head tag */ packet[pnum].ptr = &tags[0]; - packet[pnum].len = 10 * sizeof (*tags); + packet[pnum].len = 10 * sizeof(*tags); ++pnum; tags[0] = 4 | (1LL << 60); /* GIFtag */ tags[1] = 0x0e; /* A+D */ @@ -245,7 +245,7 @@ tags[9] = PS2_GS_TRXDIR; /* Now the actual image data */ packet[pnum].ptr = &tags[10]; - packet[pnum].len = 2 * sizeof (*tags); + packet[pnum].len = 2 * sizeof(*tags); ++pnum; tags[10] = ((16 * 16 * bpp) >> 4) | (2LL << 58); tags[11] = 0; @@ -253,7 +253,7 @@ packet[pnum].len = 16 * 16 * bpp; ++pnum; packet[pnum].ptr = &tags[12]; - packet[pnum].len = 2 * sizeof (*tags); + packet[pnum].len = 2 * sizeof(*tags); ++pnum; tags[12] = (0 >> 4) | (1 << 15) | (2LL << 58); tags[13] = 0; @@ -268,25 +268,25 @@ /* Set up the texture memory area for the video */ tex_packet.ptr = tags; - tex_packet.len = 8 * sizeof (*tags); + tex_packet.len = 8 * sizeof(*tags); tags[0] = 3 | (1LL << 60); /* GIFtag */ tags[1] = 0x0e; /* A+D */ tags[2] = ((screen_image.y + screen_image.h) * screen_image.w) / 64 + ((unsigned long long) fbw << 14) + ((unsigned long long) psm << 20) + - ((unsigned long long) power_of_2 (width) << 26) + - ((unsigned long long) power_of_2 (height) << 30) + + ((unsigned long long) power_of_2(width) << 26) + + ((unsigned long long) power_of_2(height) << 30) + ((unsigned long long) 1 << 34) + ((unsigned long long) 1 << 35); tags[3] = PS2_GS_TEX0_1; tags[4] = (1 << 5) + (1 << 6); tags[5] = PS2_GS_TEX1_1; tags[6] = 0; tags[7] = PS2_GS_TEXFLUSH; - ioctl (console_fd, PS2IOC_SEND, &tex_packet); + ioctl(console_fd, PS2IOC_SEND, &tex_packet); /* Set up the tags for scaling the image */ packet[pnum].ptr = tags; - packet[pnum].len = 12 * sizeof (*tags); + packet[pnum].len = 12 * sizeof(*tags); ++pnum; tags[0] = 5 | (1LL << 60); /* GIFtag */ tags[1] = 0x0e; /* A+D */ @@ -310,20 +310,20 @@ } int -GS_LockYUVOverlay (_THIS, SDL_Overlay * overlay) +GS_LockYUVOverlay(_THIS, SDL_Overlay * overlay) { return (0); } void -GS_UnlockYUVOverlay (_THIS, SDL_Overlay * overlay) +GS_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay) { return; } int -GS_DisplayYUVOverlay (_THIS, SDL_Overlay * overlay, SDL_Rect * src, - SDL_Rect * dst) +GS_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, SDL_Rect * src, + SDL_Rect * dst) { struct private_yuvhwdata *hwdata; __u32 cmd; @@ -350,7 +350,7 @@ Cr = (Uint32 *) overlay->pixels[2]; Cb = (Uint32 *) overlay->pixels[1]; default: - SDL_SetError ("Unsupported YUV format in blit (?)"); + SDL_SetError("Unsupported YUV format in blit (?)"); return (-1); } dstp = (Uint32 *) hwdata->ipu_imem; @@ -397,37 +397,37 @@ /* Send the macroblock data to the IPU */ #ifdef DEBUG_YUV - fprintf (stderr, "Sending data to IPU..\n"); + fprintf(stderr, "Sending data to IPU..\n"); #endif packet.ptr = hwdata->ipu_imem; packet.len = hwdata->macroblocks * (16 * 16 + 8 * 8 + 8 * 8); - ioctl (hwdata->ipu_fd, PS2IOC_SENDA, &packet); + ioctl(hwdata->ipu_fd, PS2IOC_SENDA, &packet); /* Trigger the DMA to the IPU for conversion */ #ifdef DEBUG_YUV - fprintf (stderr, "Trigging conversion command\n"); + fprintf(stderr, "Trigging conversion command\n"); #endif cmd = (7 << 28) + hwdata->macroblocks; if (screen_image.psm == PS2_GS_PSMCT16) { cmd += (1 << 27) + /* Output RGB 555 */ (1 << 26); /* Dither output */ } - ioctl (hwdata->ipu_fd, PS2IOC_SIPUCMD, &cmd); + ioctl(hwdata->ipu_fd, PS2IOC_SIPUCMD, &cmd); /* Retrieve the converted image from the IPU */ #ifdef DEBUG_YUV - fprintf (stderr, "Retrieving data from IPU..\n"); + fprintf(stderr, "Retrieving data from IPU..\n"); #endif packet.ptr = hwdata->ipu_omem; packet.len = overlay->w * overlay->h * this->screen->format->BytesPerPixel; - ioctl (hwdata->ipu_fd, PS2IOC_RECV, &packet); + ioctl(hwdata->ipu_fd, PS2IOC_RECV, &packet); #ifdef DEBUG_YUV - fprintf (stderr, "Copying image to screen..\n"); + fprintf(stderr, "Copying image to screen..\n"); #endif /* Wait for previous DMA to complete */ - ioctl (console_fd, PS2IOC_SENDQCT, 1); + ioctl(console_fd, PS2IOC_SENDQCT, 1); /* Send the current image to the screen and scale it */ screen = this->screen; @@ -442,29 +442,29 @@ x += (unsigned int) dst->w; y += (unsigned int) dst->h; *hwdata->stretch_x2y2 = (x * 16) + ((y * 16) << 16); - return ioctl (console_fd, PS2IOC_SENDL, &hwdata->plist); + return ioctl(console_fd, PS2IOC_SENDL, &hwdata->plist); } void -GS_FreeYUVOverlay (_THIS, SDL_Overlay * overlay) +GS_FreeYUVOverlay(_THIS, SDL_Overlay * overlay) { struct private_yuvhwdata *hwdata; hwdata = overlay->hwdata; if (hwdata) { if (hwdata->ipu_fd >= 0) { - close (hwdata->ipu_fd); + close(hwdata->ipu_fd); } if (hwdata->dma_mem) { - munmap (hwdata->dma_mem, hwdata->dma_len); + munmap(hwdata->dma_mem, hwdata->dma_len); } if (hwdata->plist.packet) { - SDL_free (hwdata->plist.packet); + SDL_free(hwdata->plist.packet); } if (hwdata->pixels) { - SDL_free (hwdata->pixels); + SDL_free(hwdata->pixels); } - SDL_free (hwdata); + SDL_free(hwdata); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/ps2gs/SDL_gsyuv_c.h --- a/src/video/ps2gs/SDL_gsyuv_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/ps2gs/SDL_gsyuv_c.h Mon May 29 04:04:35 2006 +0000 @@ -26,16 +26,15 @@ #include "SDL_video.h" #include "SDL_gsvideo.h" -extern SDL_Overlay *GS_CreateYUVOverlay (_THIS, int width, int height, - Uint32 format, - SDL_Surface * display); +extern SDL_Overlay *GS_CreateYUVOverlay(_THIS, int width, int height, + Uint32 format, SDL_Surface * display); -extern int GS_LockYUVOverlay (_THIS, SDL_Overlay * overlay); +extern int GS_LockYUVOverlay(_THIS, SDL_Overlay * overlay); -extern void GS_UnlockYUVOverlay (_THIS, SDL_Overlay * overlay); +extern void GS_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay); -extern int GS_DisplayYUVOverlay (_THIS, SDL_Overlay * overlay, SDL_Rect * src, - SDL_Rect * dst); +extern int GS_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, SDL_Rect * src, + SDL_Rect * dst); -extern void GS_FreeYUVOverlay (_THIS, SDL_Overlay * overlay); +extern void GS_FreeYUVOverlay(_THIS, SDL_Overlay * overlay); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/qtopia/SDL_QPEApp.cc --- a/src/video/qtopia/SDL_QPEApp.cc Mon May 29 03:53:21 2006 +0000 +++ b/src/video/qtopia/SDL_QPEApp.cc Mon May 29 04:04:35 2006 +0000 @@ -34,15 +34,15 @@ static QPEApplication *app; int -SDL_InitQPEApp () +SDL_InitQPEApp() { if (SDL_QPEAppActive <= 0) { if (!qApp) { int argc = 1; char *argv[] = { {"SDLApp"} }; - app = new QPEApplication (argc, argv); + app = new QPEApplication(argc, argv); QWidget dummy; - app->showMainWidget (&dummy); + app->showMainWidget(&dummy); } else { app = (QPEApplication *) qApp; } @@ -53,7 +53,7 @@ /* Quit the QPE Application, if there's nothing left to do */ void -SDL_QuitQPEApp (void) +SDL_QuitQPEApp(void) { /* Decrement the application reference count */ SDL_QPEAppActive--; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/qtopia/SDL_QPEApp.h --- a/src/video/qtopia/SDL_QPEApp.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/qtopia/SDL_QPEApp.h Mon May 29 04:04:35 2006 +0000 @@ -24,10 +24,10 @@ /* Handle the QPE application loop */ /* Initialize the QPE Application, if it's not already started */ -extern int SDL_InitQPEApp (void); +extern int SDL_InitQPEApp(void); /* Quit the QPE Application, if there's nothing left to do */ -extern void SDL_QuitQPEApp (void); +extern void SDL_QuitQPEApp(void); /* Flag to tell whether the app is active or not */ extern int SDL_QPEAppActive; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/qtopia/SDL_QWin.cc --- a/src/video/qtopia/SDL_QWin.cc Mon May 29 03:53:21 2006 +0000 +++ b/src/video/qtopia/SDL_QWin.cc Mon May 29 04:04:35 2006 +0000 @@ -27,20 +27,20 @@ screenRotationT screenRotation = SDL_QT_NO_ROTATION; -SDL_QWin::SDL_QWin (const QSize & size): -QWidget (0, "SDL_main"), -my_painter (0), -my_image (0), -my_inhibit_resize (false), -my_mouse_pos (-1, -1), -my_flags (0), -my_has_fullscreen (false), -my_locked (0) +SDL_QWin::SDL_QWin(const QSize & size): +QWidget(0, "SDL_main"), +my_painter(0), +my_image(0), +my_inhibit_resize(false), +my_mouse_pos(-1, -1), +my_flags(0), +my_has_fullscreen(false), +my_locked(0) { - setBackgroundMode (NoBackground); + setBackgroundMode(NoBackground); } -SDL_QWin::~SDL_QWin () +SDL_QWin::~SDL_QWin() { // Nothing to do yet. if (my_image) { @@ -49,7 +49,7 @@ } void -SDL_QWin::setImage (QImage * image) +SDL_QWin::setImage(QImage * image) { if (my_image) { delete my_image; @@ -59,59 +59,59 @@ } void -SDL_QWin::resizeEvent (QResizeEvent * e) +SDL_QWin::resizeEvent(QResizeEvent * e) { - if (size () != qApp->desktop ()->size ()) { + if (size() != qApp->desktop()->size()) { // Widget is not the correct size, so do the fullscreen magic my_has_fullscreen = false; - enableFullscreen (); + enableFullscreen(); } if (my_inhibit_resize) { my_inhibit_resize = false; } else { - SDL_PrivateResize (e->size ().width (), e->size ().height ()); + SDL_PrivateResize(e->size().width(), e->size().height()); } } void -SDL_QWin::focusInEvent (QFocusEvent *) +SDL_QWin::focusInEvent(QFocusEvent *) { // Always do it here, no matter the size. - enableFullscreen (); - SDL_PrivateAppActive (true, SDL_APPINPUTFOCUS); + enableFullscreen(); + SDL_PrivateAppActive(true, SDL_APPINPUTFOCUS); } void -SDL_QWin::focusOutEvent (QFocusEvent *) +SDL_QWin::focusOutEvent(QFocusEvent *) { my_has_fullscreen = false; - SDL_PrivateAppActive (false, SDL_APPINPUTFOCUS); + SDL_PrivateAppActive(false, SDL_APPINPUTFOCUS); } void -SDL_QWin::closeEvent (QCloseEvent * e) +SDL_QWin::closeEvent(QCloseEvent * e) { - SDL_PrivateQuit (); - e->ignore (); + SDL_PrivateQuit(); + e->ignore(); } void -SDL_QWin::setMousePos (const QPoint & pos) +SDL_QWin::setMousePos(const QPoint & pos) { - if (my_image->width () == height ()) { + if (my_image->width() == height()) { if (screenRotation == SDL_QT_ROTATION_90) - my_mouse_pos = QPoint (height () - pos.y (), pos.x ()); + my_mouse_pos = QPoint(height() - pos.y(), pos.x()); else if (screenRotation == SDL_QT_ROTATION_270) - my_mouse_pos = QPoint (pos.y (), width () - pos.x ()); + my_mouse_pos = QPoint(pos.y(), width() - pos.x()); } else { my_mouse_pos = pos; } } void -SDL_QWin::mouseMoveEvent (QMouseEvent * e) +SDL_QWin::mouseMoveEvent(QMouseEvent * e) { - Qt::ButtonState button = e->button (); + Qt::ButtonState button = e->button(); int sdlstate = 0; if ((button & Qt::LeftButton)) { sdlstate |= SDL_BUTTON_LMASK; @@ -122,46 +122,45 @@ if ((button & Qt::MidButton)) { sdlstate |= SDL_BUTTON_MMASK; } - setMousePos (e->pos ()); - SDL_PrivateMouseMotion (sdlstate, 0, my_mouse_pos.x (), - my_mouse_pos.y ()); + setMousePos(e->pos()); + SDL_PrivateMouseMotion(sdlstate, 0, my_mouse_pos.x(), my_mouse_pos.y()); } void -SDL_QWin::mousePressEvent (QMouseEvent * e) +SDL_QWin::mousePressEvent(QMouseEvent * e) { - mouseMoveEvent (e); - Qt::ButtonState button = e->button (); - SDL_PrivateMouseButton (SDL_PRESSED, - (button & Qt::LeftButton) ? 1 : - ((button & Qt::RightButton) ? 2 : 3), - my_mouse_pos.x (), my_mouse_pos.y ()); + mouseMoveEvent(e); + Qt::ButtonState button = e->button(); + SDL_PrivateMouseButton(SDL_PRESSED, + (button & Qt::LeftButton) ? 1 : + ((button & Qt::RightButton) ? 2 : 3), + my_mouse_pos.x(), my_mouse_pos.y()); } void -SDL_QWin::mouseReleaseEvent (QMouseEvent * e) +SDL_QWin::mouseReleaseEvent(QMouseEvent * e) { - setMousePos (e->pos ()); - Qt::ButtonState button = e->button (); - SDL_PrivateMouseButton (SDL_RELEASED, - (button & Qt::LeftButton) ? 1 : - ((button & Qt::RightButton) ? 2 : 3), - my_mouse_pos.x (), my_mouse_pos.y ()); - my_mouse_pos = QPoint (-1, -1); + setMousePos(e->pos()); + Qt::ButtonState button = e->button(); + SDL_PrivateMouseButton(SDL_RELEASED, + (button & Qt::LeftButton) ? 1 : + ((button & Qt::RightButton) ? 2 : 3), + my_mouse_pos.x(), my_mouse_pos.y()); + my_mouse_pos = QPoint(-1, -1); } static inline void -gs_fastRotateBlit_3 (unsigned short *fb, - unsigned short *bits, const QRect & rect) +gs_fastRotateBlit_3(unsigned short *fb, + unsigned short *bits, const QRect & rect) { // FIXME: this only works correctly for 240x320 displays int startx, starty; int width, height; - startx = rect.left () >> 1; - starty = rect.top () >> 1; - width = ((rect.right () - rect.left ()) >> 1) + 2; - height = ((rect.bottom () - rect.top ()) >> 1) + 2; + startx = rect.left() >> 1; + starty = rect.top() >> 1; + width = ((rect.right() - rect.left()) >> 1) + 2; + height = ((rect.bottom() - rect.top()) >> 1) + 2; if ((startx + width) > 120) { width = 120 - startx; // avoid horizontal overflow @@ -208,17 +207,17 @@ } static inline void -gs_fastRotateBlit_1 (unsigned short *fb, - unsigned short *bits, const QRect & rect) +gs_fastRotateBlit_1(unsigned short *fb, + unsigned short *bits, const QRect & rect) { // FIXME: this only works correctly for 240x320 displays int startx, starty; int width, height; - startx = rect.left () >> 1; - starty = rect.top () >> 1; - width = ((rect.right () - rect.left ()) >> 1) + 2; - height = ((rect.bottom () - rect.top ()) >> 1) + 2; + startx = rect.left() >> 1; + starty = rect.top() >> 1; + width = ((rect.right() - rect.left()) >> 1) + 2; + height = ((rect.bottom() - rect.top()) >> 1) + 2; if ((startx + width) > 120) { width = 120 - startx; // avoid horizontal overflow @@ -381,42 +380,42 @@ /* *INDENT-ON* */ void -SDL_QWin::repaintRect (const QRect & rect) +SDL_QWin::repaintRect(const QRect & rect) { - if (!my_painter || !rect.width () || !rect.height ()) { + if (!my_painter || !rect.width() || !rect.height()) { return; } - if (QPixmap::defaultDepth () == 16) { - switch (my_painter->transformOrientation ()) { + if (QPixmap::defaultDepth() == 16) { + switch (my_painter->transformOrientation()) { case 3: - if (repaintRotation3 (rect)) { + if (repaintRotation3(rect)) { return; } break; case 1: - if (repaintRotation1 (rect)) { + if (repaintRotation1(rect)) { return; } break; case 0: - if (repaintRotation0 (rect)) { + if (repaintRotation0(rect)) { return; } break; } } - my_painter->drawImage (rect.topLeft (), *my_image, rect); + my_painter->drawImage(rect.topLeft(), *my_image, rect); } // This paints the current buffer to the screen, when desired. void -SDL_QWin::paintEvent (QPaintEvent * ev) +SDL_QWin::paintEvent(QPaintEvent * ev) { if (my_image) { - lockScreen (true); - repaintRect (ev->rect ()); - unlockScreen (); + lockScreen(true); + repaintRect(ev->rect()); + unlockScreen(); } } @@ -425,10 +424,10 @@ * slow. */ void -SDL_QWin::QueueKey (QKeyEvent * e, int pressed) +SDL_QWin::QueueKey(QKeyEvent * e, int pressed) { SDL_keysym keysym; - int scancode = e->key (); + int scancode = e->key(); /* Set the keysym information */ if (scancode >= 'A' && scancode <= 'Z') { // Qt sends uppercase, SDL wants lowercase @@ -607,7 +606,7 @@ } keysym.scancode = scancode; keysym.mod = KMOD_NONE; - ButtonState st = e->state (); + ButtonState st = e->state(); if ((st & ShiftButton)) { keysym.mod = static_cast < SDLMod > (keysym.mod | KMOD_LSHIFT); } @@ -618,8 +617,8 @@ keysym.mod = static_cast < SDLMod > (keysym.mod | KMOD_LALT); } if (SDL_TranslateUNICODE) { - QChar qchar = e->text ()[0]; - keysym.unicode = qchar.unicode (); + QChar qchar = e->text()[0]; + keysym.unicode = qchar.unicode(); } else { keysym.unicode = 0; } @@ -631,33 +630,33 @@ /* Queue the key event */ if (pressed) { - SDL_PrivateKeyboard (SDL_PRESSED, &keysym); + SDL_PrivateKeyboard(SDL_PRESSED, &keysym); } else { - SDL_PrivateKeyboard (SDL_RELEASED, &keysym); + SDL_PrivateKeyboard(SDL_RELEASED, &keysym); } } void -SDL_QWin::setFullscreen (bool fs_on) +SDL_QWin::setFullscreen(bool fs_on) { my_has_fullscreen = false; - enableFullscreen (); + enableFullscreen(); } void -SDL_QWin::enableFullscreen () +SDL_QWin::enableFullscreen() { // Make sure size is correct if (!my_has_fullscreen) { - setFixedSize (qApp->desktop ()->size ()); + setFixedSize(qApp->desktop()->size()); // This call is needed because showFullScreen won't work // correctly if the widget already considers itself to be fullscreen. - showNormal (); + showNormal(); // This is needed because showNormal() forcefully changes the window // style to WSTyle_TopLevel. - setWFlags (WStyle_Customize | WStyle_NoBorder); + setWFlags(WStyle_Customize | WStyle_NoBorder); // Enable fullscreen. - showFullScreen (); + showFullScreen(); my_has_fullscreen = true; } } @@ -679,13 +678,13 @@ /* *INDENT-ON* */ void -SDL_QWin::unlockScreen () +SDL_QWin::unlockScreen() { if (my_locked > 0) { my_locked--; // decrease lock refcount; } if (!my_locked && my_painter) { - my_painter->end (); + my_painter->end(); delete my_painter; my_painter = 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/qtopia/SDL_QWin.h --- a/src/video/qtopia/SDL_QWin.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/qtopia/SDL_QWin.h Mon May 29 04:04:35 2006 +0000 @@ -50,72 +50,72 @@ class SDL_QWin:public QWidget { - void QueueKey (QKeyEvent * e, int pressed); + void QueueKey(QKeyEvent * e, int pressed); public: - SDL_QWin (const QSize & size); - virtual ~ SDL_QWin (); - virtual bool shown (void) + SDL_QWin(const QSize & size); + virtual ~ SDL_QWin(); + virtual bool shown(void) { - return isVisible (); + return isVisible(); } /* If called, the next resize event will not be forwarded to SDL. */ - virtual void inhibitResize (void) + virtual void inhibitResize(void) { my_inhibit_resize = true; } - void setImage (QImage * image); - void setOffset (int x, int y) + void setImage(QImage * image); + void setOffset(int x, int y) { - my_offset = QPoint (x, y); + my_offset = QPoint(x, y); } - void GetXYOffset (int &x, int &y) + void GetXYOffset(int &x, int &y) { - x = my_offset.x (); - y = my_offset.y (); + x = my_offset.x(); + y = my_offset.y(); } - QImage *image (void) + QImage *image(void) { return my_image; } - void setWFlags (WFlags flags) + void setWFlags(WFlags flags) { - QWidget::setWFlags (flags); + QWidget::setWFlags(flags); my_flags = flags; } - const QPoint & mousePos () const + const QPoint & mousePos() const { return my_mouse_pos; } - void setMousePos (const QPoint & newpos); - void setFullscreen (bool); + void setMousePos(const QPoint & newpos); + void setFullscreen(bool); - bool lockScreen (bool force = false); - void unlockScreen (); - void repaintRect (const QRect & rect); + bool lockScreen(bool force = false); + void unlockScreen(); + void repaintRect(const QRect & rect); protected: /* Handle resizing of the window */ - virtual void resizeEvent (QResizeEvent * e); - void focusInEvent (QFocusEvent *); - void focusOutEvent (QFocusEvent *); - void closeEvent (QCloseEvent * e); - void mouseMoveEvent (QMouseEvent * e); - void mousePressEvent (QMouseEvent * e); - void mouseReleaseEvent (QMouseEvent * e); - void paintEvent (QPaintEvent * ev); - void keyPressEvent (QKeyEvent * e) + virtual void resizeEvent(QResizeEvent * e); + void focusInEvent(QFocusEvent *); + void focusOutEvent(QFocusEvent *); + void closeEvent(QCloseEvent * e); + void mouseMoveEvent(QMouseEvent * e); + void mousePressEvent(QMouseEvent * e); + void mouseReleaseEvent(QMouseEvent * e); + void paintEvent(QPaintEvent * ev); + void keyPressEvent(QKeyEvent * e) { - QueueKey (e, 1); + QueueKey(e, 1); } - void keyReleaseEvent (QKeyEvent * e) + void keyReleaseEvent(QKeyEvent * e) { - QueueKey (e, 0); + QueueKey(e, 0); } private: - bool repaintRotation0 (const QRect & rect); - bool repaintRotation1 (const QRect & rect); - bool repaintRotation3 (const QRect & rect); - void enableFullscreen (); + bool repaintRotation0(const QRect & rect); + bool repaintRotation1(const QRect & rect); + bool repaintRotation3(const QRect & rect); + void enableFullscreen(); QDirectPainter *my_painter; QImage *my_image; bool my_inhibit_resize; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/qtopia/SDL_sysevents.cc --- a/src/video/qtopia/SDL_sysevents.cc Mon May 29 03:53:21 2006 +0000 +++ b/src/video/qtopia/SDL_sysevents.cc Mon May 29 04:04:35 2006 +0000 @@ -42,14 +42,14 @@ thread. Normally this function should loop as long as there are input states changing, i.e. new events arriving. */ - void QT_PumpEvents (_THIS) + void QT_PumpEvents(_THIS) { if (!qApp) { return; } // printf("processing events: %p\n", qApp); //qApp->processOneEvent(); // wait for a event - qApp->processEvents (); // and process all outstanding ones + qApp->processEvents(); // and process all outstanding ones #if 0 BView *view; BRect bounds; @@ -63,32 +63,31 @@ unsigned int i, j; /* Check out the mouse buttons and position (slight race condition) */ - if (SDL_Win->Lock ()) { + if (SDL_Win->Lock()) { /* Don't do anything if we have no view */ - view = SDL_Win->View (); + view = SDL_Win->View(); if (!view) { - SDL_Win->Unlock (); + SDL_Win->Unlock(); return; } - bounds = view->Bounds (); + bounds = view->Bounds(); /* Get new input state, if still active */ - if (SDL_Win->IsActive ()) { + if (SDL_Win->IsActive()) { key_flip = !key_flip; - get_key_info (&keyinfo[key_flip]); - view->GetMouse (&point, &buttons, true); + get_key_info(&keyinfo[key_flip]); + view->GetMouse(&point, &buttons, true); } else { key_flip = key_flip; point = last_point; buttons = last_buttons; } - SDL_Win->Unlock (); + SDL_Win->Unlock(); } else { return; } /* If our view is active, we'll find key changes here */ - if (SDL_memcmp (keyinfo[0].key_states, keyinfo[1].key_states, 16) != - 0) { + if (SDL_memcmp(keyinfo[0].key_states, keyinfo[1].key_states, 16) != 0) { for (i = 0; i < 16; ++i) { Uint8 new_state, transition; @@ -97,7 +96,7 @@ keyinfo[key_flip].key_states[i]; for (j = 0; j < 8; ++j) { if (transition & 0x80) - QueueKey (i * 8 + j, new_state & 0x80); + QueueKey(i * 8 + j, new_state & 0x80); transition <<= 1; new_state <<= 1; } @@ -105,39 +104,39 @@ } /* We check keyboard, but not mouse if mouse isn't in window */ - if (!bounds.Contains (point)) { + if (!bounds.Contains(point)) { /* Mouse moved outside our view? */ - if (SDL_GetAppState () & SDL_APPMOUSEFOCUS) { - SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); - be_app->SetCursor (B_HAND_CURSOR); + if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) { + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); + be_app->SetCursor(B_HAND_CURSOR); } return; } /* Has the mouse moved back into our view? */ - if (!(SDL_GetAppState () & SDL_APPMOUSEFOCUS)) { + if (!(SDL_GetAppState() & SDL_APPMOUSEFOCUS)) { /* Reset the B_HAND_CURSOR to our own */ - SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); - SDL_SetCursor (NULL); + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); + SDL_SetCursor(NULL); } /* Check for mouse motion */ if (point != last_point) { int x, y; - SDL_Win->GetXYOffset (x, y); + SDL_Win->GetXYOffset(x, y); x = (int) point.x - x; y = (int) point.y - y; - SDL_PrivateMouseMotion (0, 0, x, y); + SDL_PrivateMouseMotion(0, 0, x, y); } last_point = point; /* Add any mouse button events */ - for (i = 0; i < SDL_TABLESIZE (button_masks); ++i) { + for (i = 0; i < SDL_TABLESIZE(button_masks); ++i) { if ((buttons ^ last_buttons) & button_masks[i]) { if (buttons & button_masks[i]) { - SDL_PrivateMouseButton (SDL_PRESSED, 1 + i, 0, 0); + SDL_PrivateMouseButton(SDL_PRESSED, 1 + i, 0, 0); } else { - SDL_PrivateMouseButton (SDL_RELEASED, 1 + i, 0, 0); + SDL_PrivateMouseButton(SDL_RELEASED, 1 + i, 0, 0); } } } @@ -145,17 +144,17 @@ #endif } - void QT_InitOSKeymap (_THIS) + void QT_InitOSKeymap(_THIS) { #if 0 unsigned int i; /* Initialize all the key states as "up" */ key_flip = 0; - SDL_memset (keyinfo[key_flip].key_states, 0, 16); + SDL_memset(keyinfo[key_flip].key_states, 0, 16); /* Initialize the key translation table */ - for (i = 0; i < SDL_TABLESIZE (keymap); ++i) + for (i = 0; i < SDL_TABLESIZE(keymap); ++i) keymap[i] = SDLK_UNKNOWN; // keymap[0x01] = SDLK_ESCAPE; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/qtopia/SDL_sysevents_c.h --- a/src/video/qtopia/SDL_sysevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/qtopia/SDL_sysevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -27,6 +27,6 @@ of the native video subsystem (SDL_sysvideo.c) */ -extern void QT_InitOSKeymap (_THIS); -extern void QT_PumpEvents (_THIS); +extern void QT_InitOSKeymap(_THIS); +extern void QT_PumpEvents(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/qtopia/SDL_sysmouse.cc --- a/src/video/qtopia/SDL_sysmouse.cc Mon May 29 03:53:21 2006 +0000 +++ b/src/video/qtopia/SDL_sysmouse.cc Mon May 29 04:04:35 2006 +0000 @@ -33,27 +33,27 @@ { char *bits; }; - WMcursor *QT_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, - int hot_x, int hot_y) + WMcursor *QT_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, + int hot_x, int hot_y) { static WMcursor dummy; dummy.bits = 0; return &dummy; } - int QT_ShowWMCursor (_THIS, WMcursor * cursor) + int QT_ShowWMCursor(_THIS, WMcursor * cursor) { return 1; } - void QT_FreeWMCursor (_THIS, WMcursor * cursor) + void QT_FreeWMCursor(_THIS, WMcursor * cursor) { } - void QT_WarpWMCursor (_THIS, Uint16 x, Uint16 y) + void QT_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { - SDL_Win->setMousePos (QPoint (x, y)); + SDL_Win->setMousePos(QPoint(x, y)); } }; /* Extern C */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/qtopia/SDL_sysmouse_c.h --- a/src/video/qtopia/SDL_sysmouse_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/qtopia/SDL_sysmouse_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,10 +24,10 @@ #include "SDL_lowvideo.h" /* Functions to be exported */ -extern void QT_FreeWMCursor (_THIS, WMcursor * cursor); -extern WMcursor *QT_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, - int hot_x, int hot_y); -extern int QT_ShowWMCursor (_THIS, WMcursor * cursor); -extern void QT_WarpWMCursor (_THIS, Uint16 x, Uint16 y); +extern void QT_FreeWMCursor(_THIS, WMcursor * cursor); +extern WMcursor *QT_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, + int hot_x, int hot_y); +extern int QT_ShowWMCursor(_THIS, WMcursor * cursor); +extern void QT_WarpWMCursor(_THIS, Uint16 x, Uint16 y); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/qtopia/SDL_sysvideo.cc --- a/src/video/qtopia/SDL_sysvideo.cc Mon May 29 03:53:21 2006 +0000 +++ b/src/video/qtopia/SDL_sysvideo.cc Mon May 29 04:04:35 2006 +0000 @@ -52,60 +52,60 @@ #define SDL_QT_ROTATION_ENV_NAME "SDL_QT_INVERT_ROTATION" /* Initialization/Query functions */ - static int QT_VideoInit (_THIS, SDL_PixelFormat * vformat); - static SDL_Rect **QT_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); - static SDL_Surface *QT_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); - static void QT_UpdateMouse (_THIS); - static int QT_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); - static void QT_VideoQuit (_THIS); + static int QT_VideoInit(_THIS, SDL_PixelFormat * vformat); + static SDL_Rect **QT_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); + static SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, + Uint32 flags); + static void QT_UpdateMouse(_THIS); + static int QT_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); + static void QT_VideoQuit(_THIS); /* Hardware surface functions */ - static int QT_AllocHWSurface (_THIS, SDL_Surface * surface); - static int QT_LockHWSurface (_THIS, SDL_Surface * surface); - static void QT_UnlockHWSurface (_THIS, SDL_Surface * surface); - static void QT_FreeHWSurface (_THIS, SDL_Surface * surface); + static int QT_AllocHWSurface(_THIS, SDL_Surface * surface); + static int QT_LockHWSurface(_THIS, SDL_Surface * surface); + static void QT_UnlockHWSurface(_THIS, SDL_Surface * surface); + static void QT_FreeHWSurface(_THIS, SDL_Surface * surface); - static int QT_ToggleFullScreen (_THIS, int fullscreen); + static int QT_ToggleFullScreen(_THIS, int fullscreen); - static int QT_IconifyWindow (_THIS); - static SDL_GrabMode QT_GrabInput (_THIS, SDL_GrabMode mode); + static int QT_IconifyWindow(_THIS); + static SDL_GrabMode QT_GrabInput(_THIS, SDL_GrabMode mode); /* FB driver bootstrap functions */ - static int QT_Available (void) + static int QT_Available(void) { return (1); } - static void QT_DeleteDevice (SDL_VideoDevice * device) + static void QT_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } - static SDL_VideoDevice *QT_CreateDevice (int devindex) + static SDL_VideoDevice *QT_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = QT_VideoInit; @@ -151,7 +151,7 @@ }; /* Function to sort the display_list */ - static int CompareModes (const void *A, const void *B) + static int CompareModes(const void *A, const void *B) { #if 0 const display_mode *a = (display_mode *) A; @@ -161,15 +161,15 @@ return ((b->virtual_width * b->virtual_height) - (a->virtual_width * a->virtual_height)); } else { - return (ColorSpaceToBitsPerPixel (b->space) - - ColorSpaceToBitsPerPixel (a->space)); + return (ColorSpaceToBitsPerPixel(b->space) - + ColorSpaceToBitsPerPixel(a->space)); } #endif return 0; } /* Yes, this isn't the fastest it could be, but it works nicely */ - static int QT_AddMode (_THIS, int index, unsigned int w, unsigned int h) + static int QT_AddMode(_THIS, int index, unsigned int w, unsigned int h) { SDL_Rect *mode; int i; @@ -186,9 +186,9 @@ } /* Set up the new video mode rectangle */ - mode = (SDL_Rect *) SDL_malloc (sizeof *mode); + mode = (SDL_Rect *) SDL_malloc(sizeof *mode); if (mode == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } mode->x = 0; @@ -196,19 +196,19 @@ mode->w = w; mode->h = h; #ifdef QTOPIA_DEBUG - fprintf (stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, - index + 1); + fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, + index + 1); #endif /* Allocate the new list of modes, and fill in the new mode */ next_mode = SDL_nummodes[index]; SDL_modelist[index] = (SDL_Rect **) - SDL_realloc (SDL_modelist[index], - (1 + next_mode + 1) * sizeof (SDL_Rect *)); + SDL_realloc(SDL_modelist[index], + (1 + next_mode + 1) * sizeof(SDL_Rect *)); if (SDL_modelist[index] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); SDL_nummodes[index] = 0; - SDL_free (mode); + SDL_free(mode); return (-1); } SDL_modelist[index][next_mode] = mode; @@ -218,28 +218,28 @@ return (0); } - int QT_VideoInit (_THIS, SDL_PixelFormat * vformat) + int QT_VideoInit(_THIS, SDL_PixelFormat * vformat) { /* Initialize the QPE Application */ /* Determine the screen depth */ - vformat->BitsPerPixel = QPixmap::defaultDepth (); + vformat->BitsPerPixel = QPixmap::defaultDepth(); // For now we hardcode the current depth because anything else // might as well be emulated by SDL rather than by Qtopia. - QSize desktop_size = qApp->desktop ()->size (); - QT_AddMode (_this, ((vformat->BitsPerPixel + 7) / 8) - 1, - desktop_size.width (), desktop_size.height ()); - QT_AddMode (_this, ((vformat->BitsPerPixel + 7) / 8) - 1, - desktop_size.height (), desktop_size.width ()); + QSize desktop_size = qApp->desktop()->size(); + QT_AddMode(_this, ((vformat->BitsPerPixel + 7) / 8) - 1, + desktop_size.width(), desktop_size.height()); + QT_AddMode(_this, ((vformat->BitsPerPixel + 7) / 8) - 1, + desktop_size.height(), desktop_size.width()); /* Determine the current screen size */ - this->info.current_w = desktop_size.width (); - this->info.current_h = desktop_size.height (); + this->info.current_w = desktop_size.width(); + this->info.current_h = desktop_size.height(); /* Create the window / widget */ - SDL_Win = new SDL_QWin (QSize (QT_HIDDEN_SIZE, QT_HIDDEN_SIZE)); - ((QPEApplication *) qApp)->showMainWidget (SDL_Win); + SDL_Win = new SDL_QWin(QSize(QT_HIDDEN_SIZE, QT_HIDDEN_SIZE)); + ((QPEApplication *) qApp)->showMainWidget(SDL_Win); /* Fill in some window manager capabilities */ _this->info.wm_available = 0; @@ -248,7 +248,7 @@ } /* We support any dimension at our bit-depth */ - SDL_Rect **QT_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) + SDL_Rect **QT_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { SDL_Rect **modes; @@ -264,120 +264,119 @@ } /* Various screen update functions available */ - static void QT_NormalUpdate (_THIS, int numrects, SDL_Rect * rects); + static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect * rects); - static int QT_SetFullScreen (_THIS, SDL_Surface * screen, int fullscreen) + static int QT_SetFullScreen(_THIS, SDL_Surface * screen, int fullscreen) { return -1; } - static int QT_ToggleFullScreen (_THIS, int fullscreen) + static int QT_ToggleFullScreen(_THIS, int fullscreen) { return -1; } /* FIXME: check return values and cleanup here */ - SDL_Surface *QT_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags) + SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { QImage *qimage; - QSize desktop_size = qApp->desktop ()->size (); + QSize desktop_size = qApp->desktop()->size(); current->flags = 0; //SDL_FULLSCREEN; // We always run fullscreen. - if (width <= desktop_size.width () - && height <= desktop_size.height ()) { - current->w = desktop_size.width (); - current->h = desktop_size.height (); - } else if (width <= desktop_size.height () - && height <= desktop_size.width ()) { + if (width <= desktop_size.width() + && height <= desktop_size.height()) { + current->w = desktop_size.width(); + current->h = desktop_size.height(); + } else if (width <= desktop_size.height() + && height <= desktop_size.width()) { // Landscape mode - char *envString = SDL_getenv (SDL_QT_ROTATION_ENV_NAME); - int envValue = envString ? atoi (envString) : 0; + char *envString = SDL_getenv(SDL_QT_ROTATION_ENV_NAME); + int envValue = envString ? atoi(envString) : 0; screenRotation = envValue ? SDL_QT_ROTATION_270 : SDL_QT_ROTATION_90; - current->h = desktop_size.width (); - current->w = desktop_size.height (); + current->h = desktop_size.width(); + current->w = desktop_size.height(); } else { - SDL_SetError ("Unsupported resolution, %dx%d\n", width, height); + SDL_SetError("Unsupported resolution, %dx%d\n", width, height); } if (flags & SDL_INTERNALOPENGL) { - SDL_SetError ("OpenGL not supported"); + SDL_SetError("OpenGL not supported"); return (NULL); } /* Create the QImage framebuffer */ - qimage = new QImage (current->w, current->h, bpp); - if (qimage->isNull ()) { - SDL_SetError ("Couldn't create screen bitmap"); + qimage = new QImage(current->w, current->h, bpp); + if (qimage->isNull()) { + SDL_SetError("Couldn't create screen bitmap"); delete qimage; return (NULL); } - current->pitch = qimage->bytesPerLine (); - current->pixels = (void *) qimage->bits (); - SDL_Win->setImage (qimage); + current->pitch = qimage->bytesPerLine(); + current->pixels = (void *) qimage->bits(); + SDL_Win->setImage(qimage); _this->UpdateRects = QT_NormalUpdate; - SDL_Win->setFullscreen (true); + SDL_Win->setFullscreen(true); /* We're done */ return (current); } /* Update the current mouse state and position */ - void QT_UpdateMouse (_THIS) + void QT_UpdateMouse(_THIS) { - QPoint point (-1, -1); - if (SDL_Win->isActiveWindow ()) { - point = SDL_Win->mousePos (); + QPoint point(-1, -1); + if (SDL_Win->isActiveWindow()) { + point = SDL_Win->mousePos(); } - if ((point.x () >= 0) && (point.x () < SDL_VideoSurface->w) && - (point.y () >= 0) && (point.y () < SDL_VideoSurface->h)) { - SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); - SDL_PrivateMouseMotion (0, 0, - (Sint16) point.x (), (Sint16) point.y ()); + if ((point.x() >= 0) && (point.x() < SDL_VideoSurface->w) && + (point.y() >= 0) && (point.y() < SDL_VideoSurface->h)) { + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); + SDL_PrivateMouseMotion(0, 0, + (Sint16) point.x(), (Sint16) point.y()); } else { - SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } } /* We don't actually allow hardware surfaces other than the main one */ - static int QT_AllocHWSurface (_THIS, SDL_Surface * surface) + static int QT_AllocHWSurface(_THIS, SDL_Surface * surface) { return (-1); } - static void QT_FreeHWSurface (_THIS, SDL_Surface * surface) + static void QT_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } - static int QT_LockHWSurface (_THIS, SDL_Surface * surface) + static int QT_LockHWSurface(_THIS, SDL_Surface * surface) { return (0); } - static void QT_UnlockHWSurface (_THIS, SDL_Surface * surface) + static void QT_UnlockHWSurface(_THIS, SDL_Surface * surface) { return; } - static void QT_NormalUpdate (_THIS, int numrects, SDL_Rect * rects) + static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect * rects) { - if (SDL_Win->lockScreen ()) { + if (SDL_Win->lockScreen()) { for (int i = 0; i < numrects; ++i) { - QRect rect (rects[i].x, rects[i].y, rects[i].w, rects[i].h); - SDL_Win->repaintRect (rect); + QRect rect(rects[i].x, rects[i].y, rects[i].w, rects[i].h); + SDL_Win->repaintRect(rect); } - SDL_Win->unlockScreen (); + SDL_Win->unlockScreen(); } } /* Is the system palette settable? */ - int QT_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) + int QT_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { return -1; } - void QT_VideoQuit (_THIS) + void QT_VideoQuit(_THIS) { // This is dumb, but if I free this, the app doesn't exit correctly. // Of course, this will leak memory if init video is done more than once. @@ -387,26 +386,26 @@ // delete SDL_Win; // SDL_Win = 0; _this->screen->pixels = NULL; - QT_GrabInput (_this, SDL_GRAB_OFF); + QT_GrabInput(_this, SDL_GRAB_OFF); } - static int QT_IconifyWindow (_THIS) + static int QT_IconifyWindow(_THIS) { - SDL_Win->hide (); + SDL_Win->hide(); return true; } - static SDL_GrabMode QT_GrabInput (_THIS, SDL_GrabMode mode) + static SDL_GrabMode QT_GrabInput(_THIS, SDL_GrabMode mode) { if (mode == SDL_GRAB_OFF) { - QPEApplication::grabKeyboard (); - qApp->processEvents (); - QPEApplication::ungrabKeyboard (); + QPEApplication::grabKeyboard(); + qApp->processEvents(); + QPEApplication::ungrabKeyboard(); } else { - QPEApplication::grabKeyboard (); + QPEApplication::grabKeyboard(); } - qApp->processEvents (); + qApp->processEvents(); return mode; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/qtopia/SDL_syswm.cc --- a/src/video/qtopia/SDL_syswm.cc Mon May 29 03:53:21 2006 +0000 +++ b/src/video/qtopia/SDL_syswm.cc Mon May 29 04:04:35 2006 +0000 @@ -28,9 +28,9 @@ #include "SDL_syswm_c.h" - void QT_SetWMCaption (_THIS, const char *title, const char *icon) + void QT_SetWMCaption(_THIS, const char *title, const char *icon) { - SDL_Win->setCaption (title); + SDL_Win->setCaption(title); } }; /* Extern C */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/qtopia/SDL_syswm_c.h --- a/src/video/qtopia/SDL_syswm_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/qtopia/SDL_syswm_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,5 +24,5 @@ #include "SDL_lowvideo.h" /* Functions to be exported */ -extern void QT_SetWMCaption (_THIS, const char *title, const char *icon); +extern void QT_SetWMCaption(_THIS, const char *title, const char *icon); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/quartz/CGS.h --- a/src/video/quartz/CGS.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/quartz/CGS.h Mon May 29 04:04:35 2006 +0000 @@ -57,29 +57,29 @@ typedef CGWindowLevel CGSWindowLevel; typedef NSRect CGSRect; -extern CGSConnectionID _CGSDefaultConnection (); +extern CGSConnectionID _CGSDefaultConnection(); -extern CGSError CGSGetOnScreenWindowList (CGSConnectionID cid, - CGSConnectionID owner, - CGSWindowCount listCapacity, - CGSWindowIDList list, - CGSWindowCount * listCount); +extern CGSError CGSGetOnScreenWindowList(CGSConnectionID cid, + CGSConnectionID owner, + CGSWindowCount listCapacity, + CGSWindowIDList list, + CGSWindowCount * listCount); -extern CGSError CGSGetScreenRectForWindow (CGSConnectionID cid, - CGSWindowID wid, CGSRect * rect); +extern CGSError CGSGetScreenRectForWindow(CGSConnectionID cid, + CGSWindowID wid, CGSRect * rect); -extern CGWindowLevel CGSGetWindowLevel (CGSConnectionID cid, - CGSWindowID wid, - CGSWindowLevel * level); +extern CGWindowLevel CGSGetWindowLevel(CGSConnectionID cid, + CGSWindowID wid, + CGSWindowLevel * level); -extern CGSError CGSDisplayHWFill (CGDirectDisplayID id, unsigned int x, - unsigned int y, unsigned int w, - unsigned int h, unsigned int color); +extern CGSError CGSDisplayHWFill(CGDirectDisplayID id, unsigned int x, + unsigned int y, unsigned int w, + unsigned int h, unsigned int color); -extern CGSError CGSDisplayCanHWFill (CGDirectDisplayID id); +extern CGSError CGSDisplayCanHWFill(CGDirectDisplayID id); -extern CGSError CGSGetMouseEnabledFlags (CGSConnectionID cid, CGSWindowID wid, - int *flags); +extern CGSError CGSGetMouseEnabledFlags(CGSConnectionID cid, CGSWindowID wid, + int *flags); -int CGSDisplayHWSync (CGDirectDisplayID id); +int CGSDisplayHWSync(CGDirectDisplayID id); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/quartz/SDL_QuartzVideo.h --- a/src/video/quartz/SDL_QuartzVideo.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/quartz/SDL_QuartzVideo.h Mon May 29 04:04:35 2006 +0000 @@ -72,7 +72,7 @@ This is a workaround to directly access NSOpenGLContext's CGL context We need this to check for errors NSOpenGLContext doesn't support */ -@ interface NSOpenGLContext (CGLContextAccess) - (CGLContextObj) cglContext; +@ interface NSOpenGLContext(CGLContextAccess) - (CGLContextObj) cglContext; @end /* Main driver structure to store required state information */ typedef struct SDL_PrivateVideoData @@ -220,79 +220,79 @@ /* Gamma Functions */ int - QZ_SetGamma (_THIS, float red, float green, float blue); + QZ_SetGamma(_THIS, float red, float green, float blue); int - QZ_GetGamma (_THIS, float *red, float *green, float *blue); + QZ_GetGamma(_THIS, float *red, float *green, float *blue); int - QZ_SetGammaRamp (_THIS, Uint16 * ramp); + QZ_SetGammaRamp(_THIS, Uint16 * ramp); int - QZ_GetGammaRamp (_THIS, Uint16 * ramp); + QZ_GetGammaRamp(_THIS, Uint16 * ramp); /* OpenGL functions */ int - QZ_SetupOpenGL (_THIS, int bpp, Uint32 flags); + QZ_SetupOpenGL(_THIS, int bpp, Uint32 flags); void - QZ_TearDownOpenGL (_THIS); + QZ_TearDownOpenGL(_THIS); void * - QZ_GL_GetProcAddress (_THIS, const char *proc); + QZ_GL_GetProcAddress(_THIS, const char *proc); int - QZ_GL_GetAttribute (_THIS, SDL_GLattr attrib, int *value); + QZ_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value); int - QZ_GL_MakeCurrent (_THIS); + QZ_GL_MakeCurrent(_THIS); void - QZ_GL_SwapBuffers (_THIS); + QZ_GL_SwapBuffers(_THIS); int - QZ_GL_LoadLibrary (_THIS, const char *location); + QZ_GL_LoadLibrary(_THIS, const char *location); /* Cursor and Mouse functions */ void - QZ_FreeWMCursor (_THIS, WMcursor * cursor); + QZ_FreeWMCursor(_THIS, WMcursor * cursor); WMcursor * - QZ_CreateWMCursor (_THIS, Uint8 * data, Uint8 * mask, - int w, int h, int hot_x, int hot_y); + QZ_CreateWMCursor(_THIS, Uint8 * data, Uint8 * mask, + int w, int h, int hot_x, int hot_y); int - QZ_ShowWMCursor (_THIS, WMcursor * cursor); + QZ_ShowWMCursor(_THIS, WMcursor * cursor); void - QZ_WarpWMCursor (_THIS, Uint16 x, Uint16 y); + QZ_WarpWMCursor(_THIS, Uint16 x, Uint16 y); void - QZ_MoveWMCursor (_THIS, int x, int y); + QZ_MoveWMCursor(_THIS, int x, int y); void - QZ_CheckMouseMode (_THIS); + QZ_CheckMouseMode(_THIS); void - QZ_UpdateMouse (_THIS); + QZ_UpdateMouse(_THIS); /* Event functions */ void - QZ_InitOSKeymap (_THIS); + QZ_InitOSKeymap(_THIS); void - QZ_PumpEvents (_THIS); + QZ_PumpEvents(_THIS); /* Window Manager functions */ void - QZ_SetCaption (_THIS, const char *title, const char *icon); + QZ_SetCaption(_THIS, const char *title, const char *icon); void - QZ_SetIcon (_THIS, SDL_Surface * icon, Uint8 * mask); + QZ_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask); int - QZ_IconifyWindow (_THIS); + QZ_IconifyWindow(_THIS); SDL_GrabMode -QZ_GrabInput (_THIS, SDL_GrabMode grab_mode); +QZ_GrabInput(_THIS, SDL_GrabMode grab_mode); /*int QZ_GetWMInfo (_THIS, SDL_SysWMinfo *info);*/ /* YUV functions */ - SDL_Overlay *QZ_CreateYUVOverlay (_THIS, int width, int height, - Uint32 format, SDL_Surface * display); + SDL_Overlay *QZ_CreateYUVOverlay(_THIS, int width, int height, + Uint32 format, SDL_Surface * display); /* Private functions (used internally) */ - void QZ_PrivateWarpCursor (_THIS, int x, int y); - void QZ_ChangeGrabState (_THIS, int action); - void QZ_RegisterForSleepNotifications (_THIS); - void QZ_ShowMouse (_THIS); - void QZ_HideMouse (_THIS); - void QZ_PrivateGlobalToLocal (_THIS, NSPoint * p); - void QZ_PrivateCocoaToSDL (_THIS, NSPoint * p); + void QZ_PrivateWarpCursor(_THIS, int x, int y); + void QZ_ChangeGrabState(_THIS, int action); + void QZ_RegisterForSleepNotifications(_THIS); + void QZ_ShowMouse(_THIS); + void QZ_HideMouse(_THIS); + void QZ_PrivateGlobalToLocal(_THIS, NSPoint * p); + void QZ_PrivateCocoaToSDL(_THIS, NSPoint * p); BOOL -QZ_IsMouseInWindow (_THIS); - void QZ_DoActivate (_THIS); - void QZ_DoDeactivate (_THIS); +QZ_IsMouseInWindow(_THIS); + void QZ_DoActivate(_THIS); + void QZ_DoDeactivate(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/riscos/SDL_riscosFullScreenVideo.c --- a/src/video/riscos/SDL_riscosFullScreenVideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/riscos/SDL_riscosFullScreenVideo.c Mon May 29 04:04:35 2006 +0000 @@ -57,51 +57,50 @@ /* Helper functions */ -void FULLSCREEN_SetDeviceMode (_THIS); -int FULLSCREEN_SetMode (int width, int height, int bpp); -void FULLSCREEN_SetupBanks (_THIS); +void FULLSCREEN_SetDeviceMode(_THIS); +int FULLSCREEN_SetMode(int width, int height, int bpp); +void FULLSCREEN_SetupBanks(_THIS); /* SDL video device functions for fullscreen mode */ -static int FULLSCREEN_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static int FULLSCREEN_FlipHWSurface (_THIS, SDL_Surface * surface); -void FULLSCREEN_SetWMCaption (_THIS, const char *title, const char *icon); -extern int RISCOS_GetWmInfo (_THIS, SDL_SysWMinfo * info); +static int FULLSCREEN_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static int FULLSCREEN_FlipHWSurface(_THIS, SDL_Surface * surface); +void FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon); +extern int RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo * info); /* UpdateRects variants */ -static void FULLSCREEN_UpdateRects (_THIS, int numrects, SDL_Rect * rects); -static void FULLSCREEN_UpdateRectsMemCpy (_THIS, int numrects, - SDL_Rect * rects); -static void FULLSCREEN_UpdateRects8bpp (_THIS, int numrects, +static void FULLSCREEN_UpdateRects(_THIS, int numrects, SDL_Rect * rects); +static void FULLSCREEN_UpdateRectsMemCpy(_THIS, int numrects, + SDL_Rect * rects); +static void FULLSCREEN_UpdateRects8bpp(_THIS, int numrects, SDL_Rect * rects); +static void FULLSCREEN_UpdateRects16bpp(_THIS, int numrects, SDL_Rect * rects); -static void FULLSCREEN_UpdateRects16bpp (_THIS, int numrects, - SDL_Rect * rects); -static void FULLSCREEN_UpdateRects32bpp (_THIS, int numrects, - SDL_Rect * rects); -static void FULLSCREEN_UpdateRectsOS (_THIS, int numrects, SDL_Rect * rects); +static void FULLSCREEN_UpdateRects32bpp(_THIS, int numrects, + SDL_Rect * rects); +static void FULLSCREEN_UpdateRectsOS(_THIS, int numrects, SDL_Rect * rects); /* Local helper functions */ -static int cmpmodes (const void *va, const void *vb); -static int FULLSCREEN_AddMode (_THIS, int bpp, int w, int h); -void FULLSCREEN_SetWriteBank (int bank); -void FULLSCREEN_SetDisplayBank (int bank); -static void FULLSCREEN_DisableEscape (); -static void FULLSCREEN_EnableEscape (); -void FULLSCREEN_BuildModeList (_THIS); +static int cmpmodes(const void *va, const void *vb); +static int FULLSCREEN_AddMode(_THIS, int bpp, int w, int h); +void FULLSCREEN_SetWriteBank(int bank); +void FULLSCREEN_SetDisplayBank(int bank); +static void FULLSCREEN_DisableEscape(); +static void FULLSCREEN_EnableEscape(); +void FULLSCREEN_BuildModeList(_THIS); /* Following variable is set up in riskosTask.c */ extern int riscos_backbuffer; /* Create a back buffer in system memory for full screen mode */ /* Following is used to create a sprite back buffer */ -extern unsigned char *WIMP_CreateBuffer (int width, int height, int bpp); +extern unsigned char *WIMP_CreateBuffer(int width, int height, int bpp); /* Fast assembler copy */ -extern void RISCOS_Put32 (void *to, int pixels, int pitch, int rows, - void *from, int src_skip_bytes); +extern void RISCOS_Put32(void *to, int pixels, int pitch, int rows, + void *from, int src_skip_bytes); SDL_Surface * -FULLSCREEN_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +FULLSCREEN_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { _kernel_swi_regs regs; Uint32 Rmask = 0; @@ -128,23 +127,22 @@ break; default: - SDL_SetError ("Pixel depth not supported"); + SDL_SetError("Pixel depth not supported"); return NULL; break; } - if (FULLSCREEN_SetMode (width, height, bpp) == 0) { - SDL_SetError ("Couldn't set requested mode"); + if (FULLSCREEN_SetMode(width, height, bpp) == 0) { + SDL_SetError("Couldn't set requested mode"); return (NULL); } /* printf("Setting mode %dx%d\n", width, height); */ /* Allocate the new pixel format for the screen */ - if (!SDL_ReallocFormat (current, bpp, Rmask, Gmask, Bmask, 0)) { - RISCOS_RestoreWimpMode (); - SDL_SetError - ("Couldn't allocate new pixel format for requested mode"); + if (!SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0)) { + RISCOS_RestoreWimpMode(); + SDL_SetError("Couldn't allocate new pixel format for requested mode"); return (NULL); } @@ -156,18 +154,18 @@ /* Get screen width in bytes */ regs.r[1] = 6; // Screen Width in bytes - _kernel_swi (OS_ReadModeVariable, ®s, ®s); + _kernel_swi(OS_ReadModeVariable, ®s, ®s); current->pitch = regs.r[2]; if (flags & SDL_DOUBLEBUF) { regs.r[0] = 2; /* Screen area */ - _kernel_swi (OS_ReadDynamicArea, ®s, ®s); + _kernel_swi(OS_ReadDynamicArea, ®s, ®s); /* Reg 1 has amount of memory currently used for display */ regs.r[0] = 2; /* Screen area */ regs.r[1] = (current->pitch * height * 2) - regs.r[1]; - if (_kernel_swi (OS_ChangeDynamicArea, ®s, ®s) != NULL) { + if (_kernel_swi(OS_ChangeDynamicArea, ®s, ®s) != NULL) { /* Can't allocate enough screen memory for double buffer */ flags &= ~SDL_DOUBLEBUF; } @@ -178,13 +176,13 @@ /* Need to set display banks here for double buffering */ if (flags & SDL_DOUBLEBUF) { - FULLSCREEN_SetWriteBank (0); - FULLSCREEN_SetDisplayBank (1); + FULLSCREEN_SetWriteBank(0); + FULLSCREEN_SetDisplayBank(1); create_back_buffer = 0; /* Don't need a back buffer for a double buffered display */ } - FULLSCREEN_SetupBanks (this); + FULLSCREEN_SetupBanks(this); if (create_back_buffer) { /* If not double buffered we may need to create a memory @@ -193,12 +191,12 @@ ** SDL$$BackBuffer >= 1 */ if (riscos_backbuffer == 3) - this->hidden->bank[0] = WIMP_CreateBuffer (width, height, bpp); + this->hidden->bank[0] = WIMP_CreateBuffer(width, height, bpp); else - this->hidden->bank[0] = SDL_malloc (height * current->pitch); + this->hidden->bank[0] = SDL_malloc(height * current->pitch); if (this->hidden->bank[0] == 0) { - RISCOS_RestoreWimpMode (); - SDL_SetError ("Couldnt allocate memory for back buffer"); + RISCOS_RestoreWimpMode(); + SDL_SetError("Couldnt allocate memory for back buffer"); return (NULL); } /* Surface updated in programs is now a software surface */ @@ -207,7 +205,7 @@ /* Store address of allocated screen bank to be freed later */ if (this->hidden->alloc_bank) - SDL_free (this->hidden->alloc_bank); + SDL_free(this->hidden->alloc_bank); if (create_back_buffer) { this->hidden->alloc_bank = this->hidden->bank[0]; if (riscos_backbuffer == 3) { @@ -219,8 +217,8 @@ this->hidden->alloc_bank = 0; // Clear both banks to black - SDL_memset (this->hidden->bank[0], 0, height * current->pitch); - SDL_memset (this->hidden->bank[1], 0, height * current->pitch); + SDL_memset(this->hidden->bank[0], 0, height * current->pitch); + SDL_memset(this->hidden->bank[1], 0, height * current->pitch); this->hidden->current_bank = 0; current->pixels = this->hidden->bank[0]; @@ -229,7 +227,7 @@ this->screen = current; /* Reset device functions for the wimp */ - FULLSCREEN_SetDeviceMode (this); + FULLSCREEN_SetDeviceMode(this); /* FULLSCREEN_DisableEscape(); */ @@ -239,7 +237,7 @@ /* Reset any device functions that have been changed because we have run in WIMP mode */ void -FULLSCREEN_SetDeviceMode (_THIS) +FULLSCREEN_SetDeviceMode(_THIS) { /* Update rects is different if we have a backbuffer */ @@ -290,7 +288,7 @@ /* Query for the list of available video modes */ void -FULLSCREEN_BuildModeList (_THIS) +FULLSCREEN_BuildModeList(_THIS) { _kernel_swi_regs regs; char *enumInfo = NULL; @@ -304,23 +302,23 @@ regs.r[2] = 0; /* Number of modes to skip */ regs.r[6] = 0; /* pointer to block or 0 for count */ regs.r[7] = 0; /* Size of block in bytes */ - _kernel_swi (OS_ScreenMode, ®s, ®s); + _kernel_swi(OS_ScreenMode, ®s, ®s); num_modes = -regs.r[2]; /* Video memory should be in r[5] */ this->info.video_mem = regs.r[5] / 1024; - enumInfo = (unsigned char *) SDL_malloc (-regs.r[7]); + enumInfo = (unsigned char *) SDL_malloc(-regs.r[7]); if (enumInfo == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return; } /* Read mode information into block */ regs.r[2] = 0; regs.r[6] = (int) enumInfo; regs.r[7] = -regs.r[7]; - _kernel_swi (OS_ScreenMode, ®s, ®s); + _kernel_swi(OS_ScreenMode, ®s, ®s); enum_ptr = enumInfo; @@ -329,13 +327,13 @@ if ((blockInfo[1] & 255) == 1) { /* We understand this format */ switch (blockInfo[4]) { case 3: /* 8 bits per pixel */ - FULLSCREEN_AddMode (this, 8, blockInfo[2], blockInfo[3]); + FULLSCREEN_AddMode(this, 8, blockInfo[2], blockInfo[3]); break; case 4: /* 15 bits per pixel */ - FULLSCREEN_AddMode (this, 15, blockInfo[2], blockInfo[3]); + FULLSCREEN_AddMode(this, 15, blockInfo[2], blockInfo[3]); break; case 5: /* 32 bits per pixel */ - FULLSCREEN_AddMode (this, 32, blockInfo[2], blockInfo[3]); + FULLSCREEN_AddMode(this, 32, blockInfo[2], blockInfo[3]); break; } } @@ -343,43 +341,43 @@ enum_ptr += blockInfo[0]; } - SDL_free (enumInfo); + SDL_free(enumInfo); /* Sort the mode lists */ for (j = 0; j < NUM_MODELISTS; ++j) { if (SDL_nummodes[j] > 0) { - SDL_qsort (SDL_modelist[j], SDL_nummodes[j], - sizeof *SDL_modelist[j], cmpmodes); + SDL_qsort(SDL_modelist[j], SDL_nummodes[j], + sizeof *SDL_modelist[j], cmpmodes); } } } static int -FULLSCREEN_FlipHWSurface (_THIS, SDL_Surface * surface) +FULLSCREEN_FlipHWSurface(_THIS, SDL_Surface * surface) { _kernel_swi_regs regs; regs.r[0] = 19; - FULLSCREEN_SetDisplayBank (this->hidden->current_bank); + FULLSCREEN_SetDisplayBank(this->hidden->current_bank); this->hidden->current_bank ^= 1; - FULLSCREEN_SetWriteBank (this->hidden->current_bank); + FULLSCREEN_SetWriteBank(this->hidden->current_bank); surface->pixels = this->hidden->bank[this->hidden->current_bank]; /* Wait for Vsync */ - _kernel_swi (OS_Byte, ®s, ®s); + _kernel_swi(OS_Byte, ®s, ®s); return (0); } /* Nothing to do if we are writing direct to hardware */ static void -FULLSCREEN_UpdateRects (_THIS, int numrects, SDL_Rect * rects) +FULLSCREEN_UpdateRects(_THIS, int numrects, SDL_Rect * rects) { } /* Safe but slower Memory copy from our allocated back buffer */ static void -FULLSCREEN_UpdateRectsMemCpy (_THIS, int numrects, SDL_Rect * rects) +FULLSCREEN_UpdateRectsMemCpy(_THIS, int numrects, SDL_Rect * rects) { int j; char *to, *from; @@ -390,7 +388,7 @@ from = this->hidden->bank[0] + rects->x * xmult + rects->y * pitch; to = this->hidden->bank[1] + rects->x * xmult + rects->y * pitch; for (row = 0; row < rects->h; row++) { - SDL_memcpy (to, from, rects->w * xmult); + SDL_memcpy(to, from, rects->w * xmult); from += pitch; to += pitch; } @@ -401,7 +399,7 @@ /* Use optimized assembler memory copy. Deliberately copies extra columns if necessary to ensure the rectangle is word aligned. */ static void -FULLSCREEN_UpdateRects8bpp (_THIS, int numrects, SDL_Rect * rects) +FULLSCREEN_UpdateRects8bpp(_THIS, int numrects, SDL_Rect * rects) { int j; char *to, *from; @@ -423,8 +421,8 @@ width_bytes += 4 - (width_bytes & 3); src_skip_bytes = pitch - width_bytes; - RISCOS_Put32 (to, (width_bytes >> 2), pitch, (int) rects->h, from, - src_skip_bytes); + RISCOS_Put32(to, (width_bytes >> 2), pitch, (int) rects->h, from, + src_skip_bytes); rects++; } } @@ -432,7 +430,7 @@ /* Use optimized assembler memory copy. Deliberately copies extra columns if necessary to ensure the rectangle is word aligned. */ static void -FULLSCREEN_UpdateRects16bpp (_THIS, int numrects, SDL_Rect * rects) +FULLSCREEN_UpdateRects16bpp(_THIS, int numrects, SDL_Rect * rects) { int j; char *to, *from; @@ -453,15 +451,15 @@ width_bytes += 2; src_skip_bytes = pitch - width_bytes; - RISCOS_Put32 (to, (width_bytes >> 2), pitch, (int) rects->h, from, - src_skip_bytes); + RISCOS_Put32(to, (width_bytes >> 2), pitch, (int) rects->h, from, + src_skip_bytes); rects++; } } /* Use optimized assembler memory copy. 32 bpp modes are always word aligned */ static void -FULLSCREEN_UpdateRects32bpp (_THIS, int numrects, SDL_Rect * rects) +FULLSCREEN_UpdateRects32bpp(_THIS, int numrects, SDL_Rect * rects) { int j; char *to, *from; @@ -473,8 +471,8 @@ to = this->hidden->bank[1] + (rects->x << 2) + rects->y * pitch; width = (int) rects->w; - RISCOS_Put32 (to, width, pitch, (int) rects->h, from, - pitch - (width << 2)); + RISCOS_Put32(to, width, pitch, (int) rects->h, from, + pitch - (width << 2)); rects++; } } @@ -483,7 +481,7 @@ other variants however accelerated sprite plotting can be seen on the horizon so this prepares for it. */ static void -FULLSCREEN_UpdateRectsOS (_THIS, int numrects, SDL_Rect * rects) +FULLSCREEN_UpdateRectsOS(_THIS, int numrects, SDL_Rect * rects) { _kernel_swi_regs regs; _kernel_oserror *err; @@ -497,44 +495,44 @@ for (j = 0; j < numrects; j++) { y = this->screen->h - rects->y; /* top of clipping region */ - _kernel_oswrch (24); /* Set graphics clip region */ - _kernel_oswrch ((rects->x << this->hidden->xeig) & 0xFF); /* left */ - _kernel_oswrch (((rects->x << this->hidden->xeig) >> 8) & 0xFF); - _kernel_oswrch (((y - rects->h) << this->hidden->yeig) & 0xFF); /* bottom */ - _kernel_oswrch ((((y - rects->h) << this->hidden->yeig) >> 8) & 0xFF); - _kernel_oswrch (((rects->x + rects->w - 1) << this->hidden->xeig) & 0xFF); /* right */ - _kernel_oswrch ((((rects->x + rects->w - - 1) << this->hidden->xeig) >> 8) & 0xFF); - _kernel_oswrch (((y - 1) << this->hidden->yeig) & 0xFF); /* top */ - _kernel_oswrch ((((y - 1) << this->hidden->yeig) >> 8) & 0xFF); + _kernel_oswrch(24); /* Set graphics clip region */ + _kernel_oswrch((rects->x << this->hidden->xeig) & 0xFF); /* left */ + _kernel_oswrch(((rects->x << this->hidden->xeig) >> 8) & 0xFF); + _kernel_oswrch(((y - rects->h) << this->hidden->yeig) & 0xFF); /* bottom */ + _kernel_oswrch((((y - rects->h) << this->hidden->yeig) >> 8) & 0xFF); + _kernel_oswrch(((rects->x + rects->w - 1) << this->hidden->xeig) & 0xFF); /* right */ + _kernel_oswrch((((rects->x + rects->w - + 1) << this->hidden->xeig) >> 8) & 0xFF); + _kernel_oswrch(((y - 1) << this->hidden->yeig) & 0xFF); /* top */ + _kernel_oswrch((((y - 1) << this->hidden->yeig) >> 8) & 0xFF); regs.r[3] = 0; regs.r[4] = 0; - if ((err = _kernel_swi (OS_SpriteOp, ®s, ®s)) != 0) { - printf ("OS_SpriteOp failed \n%s\n", err->errmess); + if ((err = _kernel_swi(OS_SpriteOp, ®s, ®s)) != 0) { + printf("OS_SpriteOp failed \n%s\n", err->errmess); } rects++; /* Reset to full screen clipping */ - _kernel_oswrch (24); /* Set graphics clip region */ - _kernel_oswrch (0); /* left */ - _kernel_oswrch (0); - _kernel_oswrch (0); /* bottom */ - _kernel_oswrch (0); - _kernel_oswrch (((this->screen->w - 1) << this->hidden->xeig) & 0xFF); /* right */ - _kernel_oswrch ((((this->screen->w - - 1) << this->hidden->xeig) >> 8) & 0xFF); - _kernel_oswrch (((this->screen->h - 1) << this->hidden->yeig) & 0xFF); /* top */ - _kernel_oswrch ((((this->screen->h - - 1) << this->hidden->yeig) >> 8) & 0xFF); + _kernel_oswrch(24); /* Set graphics clip region */ + _kernel_oswrch(0); /* left */ + _kernel_oswrch(0); + _kernel_oswrch(0); /* bottom */ + _kernel_oswrch(0); + _kernel_oswrch(((this->screen->w - 1) << this->hidden->xeig) & 0xFF); /* right */ + _kernel_oswrch((((this->screen->w - + 1) << this->hidden->xeig) >> 8) & 0xFF); + _kernel_oswrch(((this->screen->h - 1) << this->hidden->yeig) & 0xFF); /* top */ + _kernel_oswrch((((this->screen->h - + 1) << this->hidden->yeig) >> 8) & 0xFF); } } int -FULLSCREEN_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +FULLSCREEN_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { _kernel_swi_regs regs; int palette[256]; @@ -544,7 +542,7 @@ regs.r[2] = (int) palette; regs.r[3] = 1024; regs.r[4] = 0; - _kernel_swi (ColourTrans_ReadPalette, ®s, ®s); + _kernel_swi(ColourTrans_ReadPalette, ®s, ®s); while (ncolors--) { palette[firstcolor] = @@ -558,14 +556,14 @@ regs.r[2] = (int) palette; regs.r[3] = 0; regs.r[4] = 0; - _kernel_swi (ColourTrans_WritePalette, ®s, ®s); + _kernel_swi(ColourTrans_WritePalette, ®s, ®s); return (1); } static int -cmpmodes (const void *va, const void *vb) +cmpmodes(const void *va, const void *vb) { SDL_Rect *a = *(SDL_Rect **) va; SDL_Rect *b = *(SDL_Rect **) vb; @@ -576,7 +574,7 @@ } static int -FULLSCREEN_AddMode (_THIS, int bpp, int w, int h) +FULLSCREEN_AddMode(_THIS, int bpp, int w, int h) { SDL_Rect *mode; int i, index; @@ -595,9 +593,9 @@ } /* Set up the new video mode rectangle */ - mode = (SDL_Rect *) SDL_malloc (sizeof *mode); + mode = (SDL_Rect *) SDL_malloc(sizeof *mode); if (mode == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } mode->x = 0; @@ -608,12 +606,12 @@ /* Allocate the new list of modes, and fill in the new mode */ next_mode = SDL_nummodes[index]; SDL_modelist[index] = (SDL_Rect **) - SDL_realloc (SDL_modelist[index], - (1 + next_mode + 1) * sizeof (SDL_Rect *)); + SDL_realloc(SDL_modelist[index], + (1 + next_mode + 1) * sizeof(SDL_Rect *)); if (SDL_modelist[index] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); SDL_nummodes[index] = 0; - SDL_free (mode); + SDL_free(mode); return (-1); } SDL_modelist[index][next_mode] = mode; @@ -624,54 +622,54 @@ } void -FULLSCREEN_SetWriteBank (int bank) +FULLSCREEN_SetWriteBank(int bank) { _kernel_swi_regs regs; regs.r[0] = 112; regs.r[1] = bank + 1; - _kernel_swi (OS_Byte, ®s, ®s); + _kernel_swi(OS_Byte, ®s, ®s); } void -FULLSCREEN_SetDisplayBank (int bank) +FULLSCREEN_SetDisplayBank(int bank) { _kernel_swi_regs regs; regs.r[0] = 113; regs.r[1] = bank + 1; - _kernel_swi (OS_Byte, ®s, ®s); + _kernel_swi(OS_Byte, ®s, ®s); } /** Disable special escape key processing */ static void -FULLSCREEN_DisableEscape () +FULLSCREEN_DisableEscape() { _kernel_swi_regs regs; regs.r[0] = 229; regs.r[1] = 1; regs.r[2] = 0; - _kernel_swi (OS_Byte, ®s, ®s); + _kernel_swi(OS_Byte, ®s, ®s); } /** Enable special escape key processing */ static void -FULLSCREEN_EnableEscape () +FULLSCREEN_EnableEscape() { _kernel_swi_regs regs; regs.r[0] = 229; regs.r[1] = 0; regs.r[2] = 0; - _kernel_swi (OS_Byte, ®s, ®s); + _kernel_swi(OS_Byte, ®s, ®s); } /** Store caption in case this is called before we create a window */ void -FULLSCREEN_SetWMCaption (_THIS, const char *title, const char *icon) +FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon) { - SDL_strlcpy (this->hidden->title, title, - SDL_arraysize (this->hidden->title)); + SDL_strlcpy(this->hidden->title, title, + SDL_arraysize(this->hidden->title)); } /* Set screen mode @@ -680,7 +678,7 @@ */ int -FULLSCREEN_SetMode (int width, int height, int bpp) +FULLSCREEN_SetMode(int width, int height, int bpp) { SCREENMODEBLOCK smb; _kernel_swi_regs regs; @@ -711,7 +709,7 @@ break; default: - SDL_SetError ("Pixel depth not supported"); + SDL_SetError("Pixel depth not supported"); return 0; break; } @@ -721,30 +719,30 @@ regs.r[0] = 0; regs.r[1] = (int) &smb; - if (_kernel_swi (OS_ScreenMode, ®s, ®s) != 0) { - SDL_SetError ("Couldn't set requested mode"); + if (_kernel_swi(OS_ScreenMode, ®s, ®s) != 0) { + SDL_SetError("Couldn't set requested mode"); return 0; } /* Turn cursor off */ - _kernel_oswrch (23); - _kernel_oswrch (1); - _kernel_oswrch (0); - _kernel_oswrch (0); - _kernel_oswrch (0); - _kernel_oswrch (0); - _kernel_oswrch (0); - _kernel_oswrch (0); - _kernel_oswrch (0); - _kernel_oswrch (0); - _kernel_oswrch (0); + _kernel_oswrch(23); + _kernel_oswrch(1); + _kernel_oswrch(0); + _kernel_oswrch(0); + _kernel_oswrch(0); + _kernel_oswrch(0); + _kernel_oswrch(0); + _kernel_oswrch(0); + _kernel_oswrch(0); + _kernel_oswrch(0); + _kernel_oswrch(0); return 1; } /* Get Start addresses for the screen banks */ void -FULLSCREEN_SetupBanks (_THIS) +FULLSCREEN_SetupBanks(_THIS) { _kernel_swi_regs regs; int block[5]; @@ -756,7 +754,7 @@ regs.r[0] = (int) block; regs.r[1] = (int) block; - _kernel_swi (OS_ReadVduVariables, ®s, ®s); + _kernel_swi(OS_ReadVduVariables, ®s, ®s); this->hidden->bank[0] = (void *) block[0]; this->hidden->bank[1] = (void *) block[1]; @@ -767,20 +765,20 @@ /* Toggle to full screen mode from the WIMP */ int -FULLSCREEN_ToggleFromWimp (_THIS) +FULLSCREEN_ToggleFromWimp(_THIS) { int width = this->screen->w; int height = this->screen->h; int bpp = this->screen->format->BitsPerPixel; - RISCOS_StoreWimpMode (); - if (FULLSCREEN_SetMode (width, height, bpp)) { + RISCOS_StoreWimpMode(); + if (FULLSCREEN_SetMode(width, height, bpp)) { char *buffer = this->hidden->alloc_bank; /* This is start of sprite data */ /* Support back buffer mode only */ if (riscos_backbuffer == 0) riscos_backbuffer = 1; - FULLSCREEN_SetupBanks (this); + FULLSCREEN_SetupBanks(this); this->hidden->bank[0] = buffer + 60; /* Start of sprite data */ if (bpp == 8) @@ -790,13 +788,13 @@ this->screen->pixels = this->hidden->bank[0]; /* Copy back buffer to screen memory */ - SDL_memcpy (this->hidden->bank[1], this->hidden->bank[0], - width * height * this->screen->format->BytesPerPixel); + SDL_memcpy(this->hidden->bank[1], this->hidden->bank[0], + width * height * this->screen->format->BytesPerPixel); - FULLSCREEN_SetDeviceMode (this); + FULLSCREEN_SetDeviceMode(this); return 1; } else - RISCOS_RestoreWimpMode (); + RISCOS_RestoreWimpMode(); return 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/riscos/SDL_riscosevents.c --- a/src/video/riscos/SDL_riscosevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/riscos/SDL_riscosevents.c Mon May 29 04:04:35 2006 +0000 @@ -70,43 +70,42 @@ static char RO_pressed[ROKEYBD_ARRAYSIZE]; -static SDL_keysym *TranslateKey (int intkey, SDL_keysym * keysym, - int pressed); +static SDL_keysym *TranslateKey(int intkey, SDL_keysym * keysym, int pressed); -void RISCOS_PollMouse (_THIS); -void RISCOS_PollKeyboard (); +void RISCOS_PollMouse(_THIS); +void RISCOS_PollKeyboard(); -void RISCOS_PollMouseHelper (_THIS, int fullscreen); +void RISCOS_PollMouseHelper(_THIS, int fullscreen); #if SDL_THREADS_DISABLED -extern void DRenderer_FillBuffers (); +extern void DRenderer_FillBuffers(); /* Timer running function */ -extern void RISCOS_CheckTimer (); +extern void RISCOS_CheckTimer(); #endif void -FULLSCREEN_PumpEvents (_THIS) +FULLSCREEN_PumpEvents(_THIS) { /* Current implementation requires keyboard and mouse polling */ - RISCOS_PollKeyboard (); - RISCOS_PollMouse (this); + RISCOS_PollKeyboard(); + RISCOS_PollMouse(this); #if SDL_THREADS_DISABLED // DRenderer_FillBuffers(); if (SDL_timer_running) - RISCOS_CheckTimer (); + RISCOS_CheckTimer(); #endif } void -RISCOS_InitOSKeymap (_THIS) +RISCOS_InitOSKeymap(_THIS) { int i; /* Map the VK keysyms */ - for (i = 0; i < SDL_arraysize (RO_keymap); ++i) + for (i = 0; i < SDL_arraysize(RO_keymap); ++i) RO_keymap[i] = SDLK_UNKNOWN; RO_keymap[3] = SDLK_LSHIFT; @@ -214,7 +213,7 @@ RO_keymap[123] = SDLK_KP5; RO_keymap[124] = SDLK_KP2; - SDL_memset (RO_pressed, 0, ROKEYBD_ARRAYSIZE); + SDL_memset(RO_pressed, 0, ROKEYBD_ARRAYSIZE); } @@ -224,7 +223,7 @@ /* Check to see if we need to enter or leave mouse relative mode */ void -RISCOS_CheckMouseMode (_THIS) +RISCOS_CheckMouseMode(_THIS) { /* If the mouse is hidden and input is grabbed, we use relative mode */ if (!(SDL_cursorstate & CURSOR_VISIBLE) && @@ -237,21 +236,21 @@ void -RISCOS_PollMouse (_THIS) +RISCOS_PollMouse(_THIS) { - RISCOS_PollMouseHelper (this, 1); + RISCOS_PollMouseHelper(this, 1); } extern int mouseInWindow; void -WIMP_PollMouse (_THIS) +WIMP_PollMouse(_THIS) { /* Only poll when mouse is over the window */ if (!mouseInWindow) return; - RISCOS_PollMouseHelper (this, 0); + RISCOS_PollMouseHelper(this, 0); } /* Static variables so only changes are reported */ @@ -261,12 +260,12 @@ /* Share routine between WIMP and FULLSCREEN for polling mouse and passing on events */ void -RISCOS_PollMouseHelper (_THIS, int fullscreen) +RISCOS_PollMouseHelper(_THIS, int fullscreen) { _kernel_swi_regs regs; static int starting = 1; - if (_kernel_swi (OS_Mouse, ®s, ®s) == NULL) { + if (_kernel_swi(OS_Mouse, ®s, ®s) == NULL) { Sint16 new_x = regs.r[0]; /* Initialy get as OS units */ Sint16 new_y = regs.r[1]; @@ -290,7 +289,7 @@ /* Get current window state */ window_state[0] = this->hidden->window_handle; regs.r[1] = (unsigned int) window_state; - _kernel_swi (Wimp_GetWindowState, ®s, ®s); + _kernel_swi(Wimp_GetWindowState, ®s, ®s); topLeftX = window_state[1]; topLeftY = window_state[4]; @@ -311,9 +310,9 @@ if (centre_x != x || centre_y != y) { if (SDL_VideoSurface) - SDL_PrivateMouseMotion (0, 1, - x - centre_x, - y - centre_y); + SDL_PrivateMouseMotion(0, 1, + x - centre_x, + y - centre_y); last_x = topLeftX + (centre_x << this->hidden->xeig); last_y = topLeftY - (centre_y << this->hidden->yeig); @@ -332,13 +331,13 @@ regs.r[0] = 21; /* OSWORD pointer stuff code */ regs.r[1] = (int) block; - _kernel_swi (OS_Word, ®s, ®s); + _kernel_swi(OS_Word, ®s, ®s); } } } else { last_x = new_x; last_y = new_y; - SDL_PrivateMouseMotion (0, 0, x, y); + SDL_PrivateMouseMotion(0, 0, x, y); } } @@ -346,24 +345,24 @@ int changed = last_buttons ^ regs.r[2]; last_buttons = regs.r[2]; if (changed & 4) - SDL_PrivateMouseButton ((last_buttons & 4) ? - SDL_PRESSED : SDL_RELEASED, - SDL_BUTTON_LEFT, 0, 0); + SDL_PrivateMouseButton((last_buttons & 4) ? + SDL_PRESSED : SDL_RELEASED, + SDL_BUTTON_LEFT, 0, 0); if (changed & 2) - SDL_PrivateMouseButton ((last_buttons & 2) ? - SDL_PRESSED : SDL_RELEASED, - SDL_BUTTON_MIDDLE, 0, 0); + SDL_PrivateMouseButton((last_buttons & 2) ? + SDL_PRESSED : SDL_RELEASED, + SDL_BUTTON_MIDDLE, 0, 0); if (changed & 1) - SDL_PrivateMouseButton ((last_buttons & 1) ? - SDL_PRESSED : SDL_RELEASED, - SDL_BUTTON_RIGHT, 0, 0); + SDL_PrivateMouseButton((last_buttons & 1) ? + SDL_PRESSED : SDL_RELEASED, + SDL_BUTTON_RIGHT, 0, 0); } } } } void -RISCOS_PollKeyboard () +RISCOS_PollKeyboard() { int which_key = ROKEY_LEFT_SHIFT; int j; @@ -372,7 +371,7 @@ /* Scan the keyboard to see what is pressed */ while (which_key <= ROKEY_LAST_KEY) { - which_key = (_kernel_osbyte (121, which_key, 0) & 0xFF); + which_key = (_kernel_osbyte(121, which_key, 0) & 0xFF); if (which_key != ROKEY_NONE) { switch (which_key) { /* Skip over mouse keys */ @@ -409,7 +408,7 @@ if (RO_pressed[j]) { if (RO_pressed[j] == 1) { RO_pressed[j] = 0; - SDL_PrivateKeyboard (SDL_RELEASED, TranslateKey (j, &key, 0)); + SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(j, &key, 0)); } else { if (j < min_key) min_key = j; @@ -423,7 +422,7 @@ for (j = min_key; j <= max_key; j++) { if (RO_pressed[j]) { if (RO_pressed[j] == 2) { - SDL_PrivateKeyboard (SDL_PRESSED, TranslateKey (j, &key, 1)); + SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(j, &key, 1)); } RO_pressed[j] = 1; } @@ -431,7 +430,7 @@ } static SDL_keysym * -TranslateKey (int intkey, SDL_keysym * keysym, int pressed) +TranslateKey(int intkey, SDL_keysym * keysym, int pressed) { /* Set the keysym information */ keysym->scancode = (unsigned char) intkey; @@ -442,7 +441,7 @@ int state; int ch; - state = (_kernel_osbyte (202, 0, 255) & 0xFF); + state = (_kernel_osbyte(202, 0, 255) & 0xFF); /*TODO: Take into account other keyboard layouts */ @@ -477,7 +476,7 @@ /* Letters just give upper case version */ if (ch >= SDLK_a && ch <= SDLK_z) - ch = toupper (ch); + ch = toupper(ch); else { switch (ch) { case SDLK_HASH: diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/riscos/SDL_riscosevents_c.h --- a/src/video/riscos/SDL_riscosevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/riscos/SDL_riscosevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -26,9 +26,9 @@ /* Variables and functions exported by SDL_sysevents.c to other parts of the native video subsystem (SDL_sysvideo.c) */ -extern void RISCOS_InitOSKeymap (_THIS); -extern void FULLSCREEN_PumpEvents (_THIS); -extern void WIMP_PumpEvents (_THIS); +extern void RISCOS_InitOSKeymap(_THIS); +extern void FULLSCREEN_PumpEvents(_THIS); +extern void WIMP_PumpEvents(_THIS); /* end of SDL_nullevents_c.h ... */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/riscos/SDL_riscosmouse.c --- a/src/video/riscos/SDL_riscosmouse.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/riscos/SDL_riscosmouse.c Mon May 29 04:04:35 2006 +0000 @@ -50,22 +50,22 @@ static int cursor_palette_saved = 0; -void WIMP_SaveCursorPalette (); -void WIMP_RestoreWimpCursor (); -void WIMP_SetSDLCursorPalette (); +void WIMP_SaveCursorPalette(); +void WIMP_RestoreWimpCursor(); +void WIMP_SetSDLCursorPalette(); void -RISCOS_FreeWMCursor (_THIS, WMcursor * cursor) +RISCOS_FreeWMCursor(_THIS, WMcursor * cursor) { - SDL_free (cursor->data); - SDL_free (cursor); + SDL_free(cursor->data); + SDL_free(cursor); } WMcursor * -RISCOS_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, int hot_x, - int hot_y) +RISCOS_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, int hot_x, + int hot_y) { WMcursor *cursor; Uint8 *cursor_data; @@ -75,22 +75,22 @@ /* Check to make sure the cursor size is okay */ if ((w > 32) || (h > 32)) { - SDL_SetError ("Only with width and height <= 32 pixels are allowed"); + SDL_SetError("Only with width and height <= 32 pixels are allowed"); return (NULL); } /* Allocate the cursor */ - cursor = (WMcursor *) SDL_malloc (sizeof (*cursor)); + cursor = (WMcursor *) SDL_malloc(sizeof(*cursor)); if (cursor == NULL) { - SDL_SetError ("Out of memory"); + SDL_SetError("Out of memory"); return (NULL); } /* Note: SDL says width must be a multiple of 8 */ - cursor_data = SDL_malloc (w / 4 * h); + cursor_data = SDL_malloc(w / 4 * h); if (cursor_data == NULL) { - SDL_free (cursor); - SDL_SetError ("Out of memory"); + SDL_free(cursor); + SDL_SetError("Out of memory"); return (NULL); } @@ -137,12 +137,12 @@ } int -RISCOS_ShowWMCursor (_THIS, WMcursor * cursor) +RISCOS_ShowWMCursor(_THIS, WMcursor * cursor) { current_cursor = cursor; if (cursor == NULL) { - _kernel_osbyte (106, 0, 0); + _kernel_osbyte(106, 0, 0); defined_cursor = NULL; } else { WMcursor *old_cursor = defined_cursor; @@ -161,8 +161,8 @@ cursor_def[8] = ((int) (cursor->data) >> 16) & 0xFF; /* ... */ cursor_def[9] = ((int) (cursor->data) >> 24) & 0xFF; /* Most significant byte of pointer to data */ - if (_kernel_osword (21, (int *) cursor_def) != 0) { - SDL_SetError ("RISCOS couldn't create the cursor to show"); + if (_kernel_osword(21, (int *) cursor_def) != 0) { + SDL_SetError("RISCOS couldn't create the cursor to show"); return (0); } defined_cursor = cursor; @@ -171,19 +171,19 @@ if (old_cursor == NULL) { /* First time or reshow in window, so save/setup palette */ if (!cursor_palette_saved) { - WIMP_SaveCursorPalette (); + WIMP_SaveCursorPalette(); } - WIMP_SetSDLCursorPalette (); + WIMP_SetSDLCursorPalette(); } - _kernel_osbyte (106, 2, 0); + _kernel_osbyte(106, 2, 0); } return (1); } void -FULLSCREEN_WarpWMCursor (_THIS, Uint16 x, Uint16 y) +FULLSCREEN_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { Uint8 move_block[5]; int eig_block[3]; @@ -196,7 +196,7 @@ regs.r[0] = (int) eig_block; regs.r[1] = (int) eig_block; - _kernel_swi (OS_ReadVduVariables, ®s, ®s); + _kernel_swi(OS_ReadVduVariables, ®s, ®s); os_x = x << eig_block[0]; os_y = y << eig_block[1]; @@ -207,22 +207,22 @@ move_block[3] = os_y & 0xFF; move_block[4] = (os_y >> 8) & 0xFF; - _kernel_osword (21, (int *) move_block); - SDL_PrivateMouseMotion (0, 0, x, y); + _kernel_osword(21, (int *) move_block); + SDL_PrivateMouseMotion(0, 0, x, y); } /* Reshow cursor when mouse re-enters the window */ void -WIMP_ReshowCursor (_THIS) +WIMP_ReshowCursor(_THIS) { defined_cursor = NULL; cursor_palette_saved = 0; - RISCOS_ShowWMCursor (this, current_cursor); + RISCOS_ShowWMCursor(this, current_cursor); } void -WIMP_WarpWMCursor (_THIS, Uint16 x, Uint16 y) +WIMP_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { _kernel_swi_regs regs; int window_state[9]; @@ -231,7 +231,7 @@ window_state[0] = this->hidden->window_handle; regs.r[1] = (unsigned int) window_state; - _kernel_swi (Wimp_GetWindowState, ®s, ®s); + _kernel_swi(Wimp_GetWindowState, ®s, ®s); osX = (x << this->hidden->xeig) + window_state[1]; osY = window_state[4] - (y << this->hidden->yeig); @@ -244,15 +244,15 @@ regs.r[0] = 21; regs.r[1] = (int) block; - _kernel_swi (OS_Word, ®s, ®s); - SDL_PrivateMouseMotion (0, 0, x, y); + _kernel_swi(OS_Word, ®s, ®s); + SDL_PrivateMouseMotion(0, 0, x, y); } int -WIMP_ShowWMCursor (_THIS, WMcursor * cursor) +WIMP_ShowWMCursor(_THIS, WMcursor * cursor) { if (mouseInWindow) - return RISCOS_ShowWMCursor (this, cursor); + return RISCOS_ShowWMCursor(this, cursor); else current_cursor = cursor; @@ -260,7 +260,7 @@ } SDL_GrabMode -RISCOS_GrabInput (_THIS, SDL_GrabMode mode) +RISCOS_GrabInput(_THIS, SDL_GrabMode mode) { /* In fullscreen mode we don't need to do anything */ if (mode < SDL_GRAB_FULLSCREEN) { @@ -288,7 +288,7 @@ *((int *) window_state) = this->hidden->window_handle; regs.r[1] = (unsigned int) window_state; - _kernel_swi (Wimp_GetWindowState, ®s, ®s); + _kernel_swi(Wimp_GetWindowState, ®s, ®s); block[1] = window_state[4]; block[2] = window_state[5]; @@ -303,7 +303,7 @@ regs.r[0] = 21; /* OS word code */ regs.r[1] = (int) block; - _kernel_swi (OS_Word, ®s, ®s); + _kernel_swi(OS_Word, ®s, ®s); } return mode; @@ -313,7 +313,7 @@ defining a cursor */ void -WIMP_SaveCursorPalette () +WIMP_SaveCursorPalette() { _kernel_swi_regs regs; int colour; @@ -322,7 +322,7 @@ regs.r[0] = (int) wimp_cursor_palette[colour][0]; regs.r[1] = 25; /* Read settings with OS_ReadPalette */ - if (_kernel_swi (0x2f, ®s, ®s) == NULL) { + if (_kernel_swi(0x2f, ®s, ®s) == NULL) { wimp_cursor_palette[colour][2] = (unsigned char) ((regs.r[2] >> 8) & 0xFF); wimp_cursor_palette[colour][3] = @@ -337,17 +337,17 @@ /* Restore the WIMP's cursor when we leave the SDL window */ void -WIMP_RestoreWimpCursor () +WIMP_RestoreWimpCursor() { int colour; /* Reset to pointer shape 1 */ - _kernel_osbyte (106, 1, 0); + _kernel_osbyte(106, 1, 0); /* Reset pointer colours */ if (cursor_palette_saved) { for (colour = 0; colour < 2; colour++) { - _kernel_osword (12, (int *) wimp_cursor_palette[colour]); + _kernel_osword(12, (int *) wimp_cursor_palette[colour]); } } cursor_palette_saved = 0; @@ -355,7 +355,7 @@ /* Set palette used for SDL mouse cursors */ void -WIMP_SetSDLCursorPalette () +WIMP_SetSDLCursorPalette() { /* First time set up the mouse colours */ Uint8 block[5]; @@ -366,7 +366,7 @@ block[2] = 255; /* red component */ block[3] = 255; /* green component */ block[4] = 255; /* blue component */ - _kernel_osword (12, (int *) block); + _kernel_osword(12, (int *) block); /* Set colour 3 to back */ block[0] = 3; /* Colour to change 1 - 3 */ @@ -374,7 +374,7 @@ block[2] = 0; /* red component */ block[3] = 0; /* green component */ block[4] = 0; /* blue component */ - _kernel_osword (12, (int *) block); + _kernel_osword(12, (int *) block); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/riscos/SDL_riscosmouse_c.h --- a/src/video/riscos/SDL_riscosmouse_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/riscos/SDL_riscosmouse_c.h Mon May 29 04:04:35 2006 +0000 @@ -34,13 +34,13 @@ }; /* Functions to be exported */ -void RISCOS_FreeWMCursor (_THIS, WMcursor * cursor); -WMcursor *RISCOS_CreateWMCursor (_THIS, Uint8 * data, Uint8 * mask, int w, - int h, int hot_x, int hot_y); +void RISCOS_FreeWMCursor(_THIS, WMcursor * cursor); +WMcursor *RISCOS_CreateWMCursor(_THIS, Uint8 * data, Uint8 * mask, int w, + int h, int hot_x, int hot_y); -int RISCOS_ShowWMCursor (_THIS, WMcursor * cursor); -void FULLSCREEN_WarpWMCursor (_THIS, Uint16 x, Uint16 y); +int RISCOS_ShowWMCursor(_THIS, WMcursor * cursor); +void FULLSCREEN_WarpWMCursor(_THIS, Uint16 x, Uint16 y); -int WIMP_ShowWMCursor (_THIS, WMcursor * cursor); -void WIMP_WarpWMCursor (_THIS, Uint16 x, Uint16 y); +int WIMP_ShowWMCursor(_THIS, WMcursor * cursor); +void WIMP_WarpWMCursor(_THIS, Uint16 x, Uint16 y); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/riscos/SDL_riscossprite.c --- a/src/video/riscos/SDL_riscossprite.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/riscos/SDL_riscossprite.c Mon May 29 04:04:35 2006 +0000 @@ -34,15 +34,15 @@ #include "SDL_stdinc.h" #include "SDL_riscosvideo.h" -extern void WIMP_ReadModeInfo (_THIS); +extern void WIMP_ReadModeInfo(_THIS); -void WIMP_PaletteChanged (_THIS); +void WIMP_PaletteChanged(_THIS); /* Create sprite buffer for screen */ unsigned char * -WIMP_CreateBuffer (int width, int height, int bpp) +WIMP_CreateBuffer(int width, int height, int bpp) { int size; char sprite_name[12] = "display"; @@ -75,7 +75,7 @@ } size = bytesPerRow * height; - buffer = SDL_malloc ((size_t) size + offsetToSpriteData); + buffer = SDL_malloc((size_t) size + offsetToSpriteData); if (!buffer) return NULL; @@ -86,7 +86,7 @@ regs.r[0] = 256 + 9; regs.r[1] = (unsigned int) buffer; - _kernel_swi (OS_SpriteOp, ®s, ®s); + _kernel_swi(OS_SpriteOp, ®s, ®s); regs.r[0] = 256 + 15; regs.r[1] = (unsigned int) buffer; @@ -103,7 +103,7 @@ |(90 << 1) /* Horizontal dpi */ |1; /* Marker to distinguish between mode selectors and sprite modes */ } - if (_kernel_swi (OS_SpriteOp, ®s, ®s) == NULL) { + if (_kernel_swi(OS_SpriteOp, ®s, ®s) == NULL) { if (bpp == 8) { /* Modify sprite to take into account 256 colour palette */ int *sprite = (int *) (buffer + 16); @@ -130,7 +130,7 @@ */ } } else { - SDL_free (buffer); + SDL_free(buffer); buffer = NULL; } @@ -141,7 +141,7 @@ /* Setup translation buffers for the sprite plotting */ void -WIMP_SetupPlotInfo (_THIS) +WIMP_SetupPlotInfo(_THIS) { _kernel_swi_regs regs; int *sprite = ((int *) this->hidden->bank[1]) + 4; @@ -156,23 +156,23 @@ regs.r[7] = 0; if (this->hidden->pixtrans) - SDL_free (this->hidden->pixtrans); + SDL_free(this->hidden->pixtrans); this->hidden->pixtrans = 0; /* Get the size required for the buffer */ - _kernel_swi (ColourTrans_GenerateTable, ®s, ®s); + _kernel_swi(ColourTrans_GenerateTable, ®s, ®s); if (regs.r[4]) { - this->hidden->pixtrans = SDL_malloc (regs.r[4]); + this->hidden->pixtrans = SDL_malloc(regs.r[4]); regs.r[4] = (unsigned int) this->hidden->pixtrans; /* Actually read the buffer */ - _kernel_swi (ColourTrans_GenerateTable, ®s, ®s); + _kernel_swi(ColourTrans_GenerateTable, ®s, ®s); } } /* Plot the sprite in the given context */ void -WIMP_PlotSprite (_THIS, int x, int y) +WIMP_PlotSprite(_THIS, int x, int y) { _kernel_swi_regs regs; _kernel_oserror *err; @@ -186,11 +186,11 @@ regs.r[6] = 0; /* No scale factors i.e. 1:1 */ regs.r[7] = (int) this->hidden->pixtrans; - if ((err = _kernel_swi (OS_SpriteOp, ®s, ®s)) != 0) { + if ((err = _kernel_swi(OS_SpriteOp, ®s, ®s)) != 0) { int *p = (int *) this->hidden->pixtrans; - printf ("OS_SpriteOp failed \n%s\n", err->errmess); - printf ("pixtrans %d\n", (int) this->hidden->pixtrans); - printf ("%x %x %x\n", p[0], p[1], p[2]); + printf("OS_SpriteOp failed \n%s\n", err->errmess); + printf("pixtrans %d\n", (int) this->hidden->pixtrans); + printf("%x %x %x\n", p[0], p[1], p[2]); } } @@ -199,16 +199,16 @@ of windows and the sprites they plot */ void -WIMP_ModeChanged (_THIS) +WIMP_ModeChanged(_THIS) { int oldXeig = this->hidden->xeig; int oldYeig = this->hidden->yeig; - WIMP_ReadModeInfo (this); + WIMP_ReadModeInfo(this); if (oldXeig == this->hidden->xeig && oldYeig == this->hidden->yeig) { /* Only need to update the palette */ - WIMP_PaletteChanged (this); + WIMP_PaletteChanged(this); } else { _kernel_swi_regs regs; int window_state[9]; @@ -217,12 +217,12 @@ int newWidth, newHeight; /* Need to resize windows and update the palette */ - WIMP_SetupPlotInfo (this); + WIMP_SetupPlotInfo(this); window_state[0] = this->hidden->window_handle; regs.r[1] = (unsigned int) window_state; - _kernel_swi (Wimp_GetWindowState, ®s, ®s); + _kernel_swi(Wimp_GetWindowState, ®s, ®s); currWidth = window_state[3] - window_state[1]; currHeight = window_state[4] - window_state[2]; @@ -246,7 +246,7 @@ regs.r[0] = this->hidden->window_handle; regs.r[1] = (int) extent; - _kernel_swi (Wimp_SetExtent, ®s, ®s); + _kernel_swi(Wimp_SetExtent, ®s, ®s); /*TODO: May need to set flag to resize window on next open */ } @@ -255,9 +255,9 @@ /* Palette has changed so update palettes used for windows sprites */ void -WIMP_PaletteChanged (_THIS) +WIMP_PaletteChanged(_THIS) { - WIMP_SetupPlotInfo (this); + WIMP_SetupPlotInfo(this); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/riscos/SDL_riscostask.c --- a/src/video/riscos/SDL_riscostask.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/riscos/SDL_riscostask.c Mon May 29 04:04:35 2006 +0000 @@ -58,22 +58,22 @@ /* Local function */ -static int RISCOS_GetTaskName (char *task_name, size_t maxlen); +static int RISCOS_GetTaskName(char *task_name, size_t maxlen); /* Uncomment next line to copy mode changes/restores to stderr */ /* #define DUMP_MODE */ #ifdef DUMP_MODE #include "stdio.h" static void -dump_mode () +dump_mode() { - fprintf (stderr, "mode %d\n", stored_mode); + fprintf(stderr, "mode %d\n", stored_mode); if (stored_mode < -1 || stored_mode >= 256) { int blockSize = 0; int *storeBlock = (int *) stored_mode; while (blockSize < 5 || storeBlock[blockSize] != -1) { - fprintf (stderr, " %d\n", storeBlock[blockSize++]); + fprintf(stderr, " %d\n", storeBlock[blockSize++]); } } } @@ -86,13 +86,13 @@ *******************************************************************/ int -RISCOS_InitTask () +RISCOS_InitTask() { char task_name[32]; _kernel_swi_regs regs; int messages[4]; - if (RISCOS_GetTaskName (task_name, SDL_arraysize (task_name)) == 0) + if (RISCOS_GetTaskName(task_name, SDL_arraysize(task_name)) == 0) return 0; messages[0] = 9; /* Palette changed */ @@ -105,13 +105,13 @@ regs.r[2] = (unsigned int) task_name; regs.r[3] = (unsigned int) messages; - if (_kernel_swi (Wimp_Initialise, ®s, ®s) == 0) { + if (_kernel_swi(Wimp_Initialise, ®s, ®s) == 0) { wimp_version = regs.r[0]; task_handle = regs.r[1]; return 1; } #if !SDL_THREADS_DISABLED - main_thread = pthread_self (); + main_thread = pthread_self(); #endif return 0; @@ -124,23 +124,23 @@ **********************************************************************/ void -RISCOS_ExitTask () +RISCOS_ExitTask() { _kernel_swi_regs regs; if (stored_mode == -1) { /* Ensure cursor is put back to standard pointer shape if we have been running in a window */ - _kernel_osbyte (106, 1, 0); + _kernel_osbyte(106, 1, 0); } /* Ensure we end up back in the wimp */ - RISCOS_RestoreWimpMode (); + RISCOS_RestoreWimpMode(); /* Neatly exit the task */ regs.r[0] = task_handle; regs.r[1] = (unsigned int) 0x4b534154; - _kernel_swi (Wimp_CloseDown, ®s, ®s); + _kernel_swi(Wimp_CloseDown, ®s, ®s); task_handle = 0; } @@ -178,30 +178,30 @@ ***************************************************************************/ int -RISCOS_GetTaskName (char *task_name, size_t maxlen) +RISCOS_GetTaskName(char *task_name, size_t maxlen) { _kernel_swi_regs regs; task_name[0] = 0; /* Figure out a sensible task name */ - if (_kernel_swi (OS_GetEnv, ®s, ®s) == 0) { + if (_kernel_swi(OS_GetEnv, ®s, ®s) == 0) { char *command_line = (char *) regs.r[0]; - size_t len = SDL_strlen (command_line) + 1; - char *buffer = SDL_stack_alloc (char, len); + size_t len = SDL_strlen(command_line) + 1; + char *buffer = SDL_stack_alloc(char, len); char *env_var; char *p; - SDL_strlcpy (buffer, command_line, len); - p = SDL_strchr (buffer, ' '); + SDL_strlcpy(buffer, command_line, len); + p = SDL_strchr(buffer, ' '); if (p) *p = 0; - p = SDL_strrchr (buffer, '.'); + p = SDL_strrchr(buffer, '.'); if (p == 0) p = buffer; - if (stricmp (p + 1, "!RunImage") == 0) { + if (stricmp(p + 1, "!RunImage") == 0) { *p = 0; - p = SDL_strrchr (buffer, '.'); + p = SDL_strrchr(buffer, '.'); if (p == 0) p = buffer; } @@ -212,9 +212,9 @@ if (*p == '<') { // Probably in the form - char *q = SDL_strchr (p, '$'); + char *q = SDL_strchr(p, '$'); if (q == 0) - q = SDL_strchr (p, '>'); /* Use variable name if not */ + q = SDL_strchr(p, '>'); /* Use variable name if not */ if (q) *q = 0; p++; /* Move over the < */ @@ -222,49 +222,49 @@ if (*p) { /* Read variables that effect the RISC OS SDL engine for this task */ - len = SDL_strlen (p) + 18; /* 18 is larger than the biggest variable name */ - env_var = SDL_stack_alloc (char, len); + len = SDL_strlen(p) + 18; /* 18 is larger than the biggest variable name */ + env_var = SDL_stack_alloc(char, len); if (env_var) { char *env_val; /* See if a variable of form SDL$$TaskName exists */ - SDL_strlcpy (env_var, "SDL$", len); - SDL_strlcat (env_var, p, len); - SDL_strlcat (env_var, "$TaskName", len); + SDL_strlcpy(env_var, "SDL$", len); + SDL_strlcat(env_var, p, len); + SDL_strlcat(env_var, "$TaskName", len); - env_val = SDL_getenv (env_var); + env_val = SDL_getenv(env_var); if (env_val) - SDL_strlcpy (task_name, env_val, maxlen); + SDL_strlcpy(task_name, env_val, maxlen); - SDL_strlcpy (env_var, "SDL$", len); - SDL_strlcat (env_var, p, len); - SDL_strlcat (env_var, "$BackBuffer", len); + SDL_strlcpy(env_var, "SDL$", len); + SDL_strlcat(env_var, p, len); + SDL_strlcat(env_var, "$BackBuffer", len); - env_val = SDL_getenv (env_var); + env_val = SDL_getenv(env_var); if (env_val) - riscos_backbuffer = atoi (env_val); + riscos_backbuffer = atoi(env_val); - SDL_strlcpy (env_var, "SDL$", len); - SDL_strlcat (env_var, p, len); - SDL_strlcat (env_var, "$CloseAction", len); + SDL_strlcpy(env_var, "SDL$", len); + SDL_strlcat(env_var, p, len); + SDL_strlcat(env_var, "$CloseAction", len); - env_val = SDL_getenv (env_var); - if (env_val && SDL_strcmp (env_val, "0") == 0) + env_val = SDL_getenv(env_var); + if (env_val && SDL_strcmp(env_val, "0") == 0) riscos_closeaction = 0; - SDL_stack_free (env_var); + SDL_stack_free(env_var); } if (!*task_name) - SDL_strlcpy (task_name, p, maxlen); + SDL_strlcpy(task_name, p, maxlen); } - SDL_stack_free (buffer); + SDL_stack_free(buffer); } if (task_name[0] == 0) - SDL_strlcpy (task_name, "SDL Task", maxlen); + SDL_strlcpy(task_name, "SDL Task", maxlen); return 1; } @@ -276,7 +276,7 @@ ******************************************************************/ void -RISCOS_StoreWimpMode () +RISCOS_StoreWimpMode() { _kernel_swi_regs regs; @@ -285,7 +285,7 @@ return; regs.r[0] = 1; - _kernel_swi (OS_ScreenMode, ®s, ®s); + _kernel_swi(OS_ScreenMode, ®s, ®s); if (regs.r[1] >= 0 && regs.r[1] < 256) stored_mode = regs.r[1]; else { @@ -297,7 +297,7 @@ while (blockSize < 5 || retBlock[blockSize] != -1) blockSize++; blockSize++; - storeBlock = (int *) SDL_malloc (blockSize * sizeof (int)); + storeBlock = (int *) SDL_malloc(blockSize * sizeof(int)); retBlock = (int *) regs.r[1]; for (j = 0; j < blockSize; j++) storeBlock[j] = retBlock[j]; @@ -305,8 +305,8 @@ stored_mode = (int) storeBlock; } #if DUMP_MODE - fprintf (stderr, "Stored "); - dump_mode (); + fprintf(stderr, "Stored "); + dump_mode(); #endif } @@ -317,7 +317,7 @@ *****************************************************************/ void -RISCOS_RestoreWimpMode () +RISCOS_RestoreWimpMode() { _kernel_swi_regs regs; @@ -326,21 +326,21 @@ return; #if DUMP_MODE - fprintf (stderr, "Restored"); - dump_mode (); + fprintf(stderr, "Restored"); + dump_mode(); #endif regs.r[0] = stored_mode; - _kernel_swi (Wimp_SetMode, ®s, ®s); + _kernel_swi(Wimp_SetMode, ®s, ®s); if (stored_mode < 0 || stored_mode > 256) { - SDL_free ((int *) stored_mode); + SDL_free((int *) stored_mode); } stored_mode = -1; /* Flush keyboard buffer to dump the keystrokes we've already polled */ regs.r[0] = 21; regs.r[1] = 0; /* Keyboard buffer number */ - _kernel_swi (OS_Byte, ®s, ®s); + _kernel_swi(OS_Byte, ®s, ®s); mouseInWindow = 0; @@ -353,13 +353,13 @@ *********************************************************************/ int -RISCOS_GetWimpVersion () +RISCOS_GetWimpVersion() { return wimp_version; } int -RISCOS_GetTaskHandle () +RISCOS_GetTaskHandle() { return task_handle; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/riscos/SDL_riscostask.h --- a/src/video/riscos/SDL_riscostask.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/riscos/SDL_riscostask.h Mon May 29 04:04:35 2006 +0000 @@ -28,13 +28,13 @@ /* Task initialisation/Clean up */ -extern int RISCOS_InitTask (); -extern void RISCOS_ExitTask (); -extern int RISCOS_GetWimpVersion (); -extern int RISCOS_GetTaskHandle (); +extern int RISCOS_InitTask(); +extern void RISCOS_ExitTask(); +extern int RISCOS_GetWimpVersion(); +extern int RISCOS_GetTaskHandle(); /* Wimp mode saveing/restoring */ -extern void RISCOS_StoreWimpMode (); -extern void RISCOS_RestoreWimpMode (); +extern void RISCOS_StoreWimpMode(); +extern void RISCOS_RestoreWimpMode(); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/riscos/SDL_riscosvideo.c --- a/src/video/riscos/SDL_riscosvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/riscos/SDL_riscosvideo.c Mon May 29 04:04:35 2006 +0000 @@ -48,78 +48,78 @@ #define RISCOSVID_DRIVER_NAME "riscos" /* Initialization/Query functions */ -static int RISCOS_VideoInit (_THIS, SDL_PixelFormat * vformat); -static void RISCOS_VideoQuit (_THIS); +static int RISCOS_VideoInit(_THIS, SDL_PixelFormat * vformat); +static void RISCOS_VideoQuit(_THIS); -static SDL_Rect **RISCOS_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *RISCOS_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); +static SDL_Rect **RISCOS_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +static SDL_Surface *RISCOS_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, + Uint32 flags); -int RISCOS_GetWmInfo (_THIS, SDL_SysWMinfo * info); +int RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo * info); -int RISCOS_ToggleFullScreen (_THIS, int fullscreen); +int RISCOS_ToggleFullScreen(_THIS, int fullscreen); /* Mouse checking */ -void RISCOS_CheckMouseMode (_THIS); -extern SDL_GrabMode RISCOS_GrabInput (_THIS, SDL_GrabMode mode); +void RISCOS_CheckMouseMode(_THIS); +extern SDL_GrabMode RISCOS_GrabInput(_THIS, SDL_GrabMode mode); /* Fullscreen mode functions */ -extern SDL_Surface *FULLSCREEN_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); -extern void FULLSCREEN_BuildModeList (_THIS); -extern void FULLSCREEN_SetDeviceMode (_THIS); -extern int FULLSCREEN_ToggleFromWimp (_THIS); +extern SDL_Surface *FULLSCREEN_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, + Uint32 flags); +extern void FULLSCREEN_BuildModeList(_THIS); +extern void FULLSCREEN_SetDeviceMode(_THIS); +extern int FULLSCREEN_ToggleFromWimp(_THIS); /* Wimp mode functions */ -extern SDL_Surface *WIMP_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); -extern void WIMP_DeleteWindow (_THIS); -extern int WIMP_ToggleFromFullScreen (_THIS); +extern SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, + Uint32 flags); +extern void WIMP_DeleteWindow(_THIS); +extern int WIMP_ToggleFromFullScreen(_THIS); /* Hardware surface functions - common to WIMP and FULLSCREEN */ -static int RISCOS_AllocHWSurface (_THIS, SDL_Surface * surface); -static int RISCOS_LockHWSurface (_THIS, SDL_Surface * surface); -static void RISCOS_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void RISCOS_FreeHWSurface (_THIS, SDL_Surface * surface); +static int RISCOS_AllocHWSurface(_THIS, SDL_Surface * surface); +static int RISCOS_LockHWSurface(_THIS, SDL_Surface * surface); +static void RISCOS_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void RISCOS_FreeHWSurface(_THIS, SDL_Surface * surface); /* RISC OS driver bootstrap functions */ static int -RISCOS_Available (void) +RISCOS_Available(void) { return (1); } static void -RISCOS_DeleteDevice (SDL_VideoDevice * device) +RISCOS_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -RISCOS_CreateDevice (int devindex) +RISCOS_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = RISCOS_VideoInit; @@ -153,7 +153,7 @@ device->ToggleFullScreen = NULL; /*RISCOS_ToggleFullScreen; */ /* Set other entries for fullscreen mode */ - FULLSCREEN_SetDeviceMode (device); + FULLSCREEN_SetDeviceMode(device); /* Mouse pointer needs to use the WIMP ShowCursor version so that it doesn't modify the pointer until the SDL Window is @@ -170,13 +170,13 @@ int -RISCOS_VideoInit (_THIS, SDL_PixelFormat * vformat) +RISCOS_VideoInit(_THIS, SDL_PixelFormat * vformat) { _kernel_swi_regs regs; int vars[4], vals[3]; - if (RISCOS_InitTask () == 0) { - SDL_SetError ("Unable to start task"); + if (RISCOS_InitTask() == 0) { + SDL_SetError("Unable to start task"); return 0; } @@ -187,7 +187,7 @@ regs.r[0] = (int) vars; regs.r[1] = (int) vals; - _kernel_swi (OS_ReadVduVariables, ®s, ®s); + _kernel_swi(OS_ReadVduVariables, ®s, ®s); vformat->BitsPerPixel = (1 << vals[0]); /* Determine the current screen size */ @@ -236,23 +236,23 @@ another SDL video routine -- notably UpdateRects. */ void -RISCOS_VideoQuit (_THIS) +RISCOS_VideoQuit(_THIS) { - RISCOS_ExitTask (); + RISCOS_ExitTask(); if (this->hidden->alloc_bank) - SDL_free (this->hidden->alloc_bank); + SDL_free(this->hidden->alloc_bank); this->hidden->alloc_bank = 0; } SDL_Rect ** -RISCOS_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +RISCOS_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { if (flags & SDL_FULLSCREEN) { /* Build mode list when first required. */ if (SDL_nummodes[0] == 0) - FULLSCREEN_BuildModeList (this); + FULLSCREEN_BuildModeList(this); return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]); } else @@ -262,56 +262,56 @@ /* Set up video mode */ SDL_Surface * -RISCOS_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +RISCOS_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { if (flags & SDL_FULLSCREEN) { - RISCOS_StoreWimpMode (); + RISCOS_StoreWimpMode(); /* Dump wimp window on switch to full screen */ if (this->hidden->window_handle) - WIMP_DeleteWindow (this); + WIMP_DeleteWindow(this); - return FULLSCREEN_SetVideoMode (this, current, width, height, bpp, - flags); + return FULLSCREEN_SetVideoMode(this, current, width, height, bpp, + flags); } else { - RISCOS_RestoreWimpMode (); - return WIMP_SetVideoMode (this, current, width, height, bpp, flags); + RISCOS_RestoreWimpMode(); + return WIMP_SetVideoMode(this, current, width, height, bpp, flags); } } /* We don't actually allow hardware surfaces other than the main one */ static int -RISCOS_AllocHWSurface (_THIS, SDL_Surface * surface) +RISCOS_AllocHWSurface(_THIS, SDL_Surface * surface) { return (-1); } static void -RISCOS_FreeHWSurface (_THIS, SDL_Surface * surface) +RISCOS_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } /* We need to wait for vertical retrace on page flipped displays */ static int -RISCOS_LockHWSurface (_THIS, SDL_Surface * surface) +RISCOS_LockHWSurface(_THIS, SDL_Surface * surface) { return (0); } static void -RISCOS_UnlockHWSurface (_THIS, SDL_Surface * surface) +RISCOS_UnlockHWSurface(_THIS, SDL_Surface * surface) { return; } int -RISCOS_GetWmInfo (_THIS, SDL_SysWMinfo * info) +RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo * info) { - SDL_VERSION (&(info->version)); - info->wimpVersion = RISCOS_GetWimpVersion (); - info->taskHandle = RISCOS_GetTaskHandle (); + SDL_VERSION(&(info->version)); + info->wimpVersion = RISCOS_GetWimpVersion(); + info->taskHandle = RISCOS_GetTaskHandle(); info->window = this->hidden->window_handle; return 1; @@ -322,12 +322,12 @@ */ int -RISCOS_ToggleFullScreen (_THIS, int fullscreen) +RISCOS_ToggleFullScreen(_THIS, int fullscreen) { if (fullscreen) { - return FULLSCREEN_ToggleFromWimp (this); + return FULLSCREEN_ToggleFromWimp(this); } else { - return WIMP_ToggleFromFullScreen (this); + return WIMP_ToggleFromFullScreen(this); } return 0; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/riscos/SDL_wimppoll.c --- a/src/video/riscos/SDL_wimppoll.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/riscos/SDL_wimppoll.c Mon May 29 04:04:35 2006 +0000 @@ -50,28 +50,28 @@ #endif /* Local functions */ -void WIMP_Poll (_THIS, int waitTime); -void WIMP_SetFocus (int win); +void WIMP_Poll(_THIS, int waitTime); +void WIMP_SetFocus(int win); /* SDL_riscossprite functions */ -void WIMP_PlotSprite (_THIS, int x, int y); -void WIMP_ModeChanged (_THIS); -void WIMP_PaletteChanged (_THIS); +void WIMP_PlotSprite(_THIS, int x, int y); +void WIMP_ModeChanged(_THIS); +void WIMP_PaletteChanged(_THIS); -extern void WIMP_PollMouse (_THIS); -extern void RISCOS_PollKeyboard (); +extern void WIMP_PollMouse(_THIS); +extern void RISCOS_PollKeyboard(); #if SDL_THREADS_DISABLED /* Timer running function */ -extern void RISCOS_CheckTimer (); +extern void RISCOS_CheckTimer(); #else extern int riscos_using_threads; #endif /* Mouse cursor handling */ -extern void WIMP_ReshowCursor (_THIS); -extern void WIMP_RestoreWimpCursor (); +extern void WIMP_ReshowCursor(_THIS); +extern void WIMP_RestoreWimpCursor(); int hasFocus = 0; int mouseInWindow = 0; @@ -80,22 +80,22 @@ static int resizeOnOpen = 0; void -WIMP_PumpEvents (_THIS) +WIMP_PumpEvents(_THIS) { - WIMP_Poll (this, 0); + WIMP_Poll(this, 0); if (hasFocus) - RISCOS_PollKeyboard (); + RISCOS_PollKeyboard(); if (mouseInWindow) - WIMP_PollMouse (this); + WIMP_PollMouse(this); #if SDL_THREADS_DISABLED if (SDL_timer_running) - RISCOS_CheckTimer (); + RISCOS_CheckTimer(); #endif } void -WIMP_Poll (_THIS, int waitTime) +WIMP_Poll(_THIS, int waitTime) { _kernel_swi_regs regs; int message[64]; @@ -109,7 +109,7 @@ return; if (waitTime > 0) { - _kernel_swi (OS_ReadMonotonicTime, ®s, ®s); + _kernel_swi(OS_ReadMonotonicTime, ®s, ®s); waitTime += regs.r[0]; } @@ -117,7 +117,7 @@ #if !SDL_THREADS_DISABLED /* Stop thread callbacks while program is paged out */ if (riscos_using_threads) - __pthread_stop_ticker (); + __pthread_stop_ticker(); #endif if (waitTime <= 0) { @@ -126,12 +126,12 @@ if (waitTime < 0) regs.r[0] |= 1; regs.r[1] = (int) message; - _kernel_swi (Wimp_Poll, ®s, ®s); + _kernel_swi(Wimp_Poll, ®s, ®s); } else { regs.r[0] = pollMask; regs.r[1] = (int) message; regs.r[2] = waitTime; - _kernel_swi (Wimp_PollIdle, ®s, ®s); + _kernel_swi(Wimp_PollIdle, ®s, ®s); } /* Flag to specify if we post a SDL_SysWMEvent */ @@ -145,16 +145,16 @@ break; case 1: /* Redraw window */ - _kernel_swi (Wimp_RedrawWindow, ®s, ®s); + _kernel_swi(Wimp_RedrawWindow, ®s, ®s); if (message[0] == sdlWindow) { while (regs.r[0]) { - WIMP_PlotSprite (this, message[1], message[2]); - _kernel_swi (Wimp_GetRectangle, ®s, ®s); + WIMP_PlotSprite(this, message[1], message[2]); + _kernel_swi(Wimp_GetRectangle, ®s, ®s); } } else { /* TODO: Currently we just eat them - we may need to pass them on */ while (regs.r[0]) { - _kernel_swi (Wimp_GetRectangle, ®s, ®s); + _kernel_swi(Wimp_GetRectangle, ®s, ®s); } } break; @@ -168,7 +168,7 @@ message[4] = message[2] + (this->screen->h << this->hidden->yeig); } - _kernel_swi (Wimp_OpenWindow, ®s, ®s); + _kernel_swi(Wimp_OpenWindow, ®s, ®s); break; case 3: /* Close window */ @@ -179,7 +179,7 @@ ** in the background so I just post the quit message and hope the application ** does the correct thing. */ - SDL_PrivateQuit (); + SDL_PrivateQuit(); } else sysEvent = 1; doPoll = 0; @@ -190,8 +190,8 @@ mouseInWindow = 0; //TODO: Lose buttons / dragging /* Reset to default pointer */ - WIMP_RestoreWimpCursor (); - SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); + WIMP_RestoreWimpCursor(); + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } else sysEvent = 1; break; @@ -199,8 +199,8 @@ case 5: /* Pointer_Entering_Window */ if (message[0] == sdlWindow) { mouseInWindow = 1; - WIMP_ReshowCursor (this); - SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); + WIMP_ReshowCursor(this); + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); } else sysEvent = 1; break; @@ -209,7 +209,7 @@ if (hasFocus == 0) { /* First click gives focus if it's not a menu */ /* we only count non-menu clicks on a window that has the focus */ - WIMP_SetFocus (message[3]); + WIMP_SetFocus(message[3]); } else doPoll = 0; // So PollMouse gets a chance to pick it up break; @@ -234,7 +234,7 @@ case 11: /* Lose Caret */ hasFocus = 0; if (message[0] == sdlWindow) - SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS); + SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); else sysEvent = 1; break; @@ -242,7 +242,7 @@ case 12: /* Gain Caret */ hasFocus = 1; if (message[0] == sdlWindow) - SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS); + SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); else sysEvent = 1; break; @@ -254,21 +254,21 @@ switch (message[4]) { case 0: /* Quit Event */ /* No choice - have to quit */ - SDL_Quit (); - exit (0); + SDL_Quit(); + exit(0); break; case 8: /* Pre Quit */ - SDL_PrivateQuit (); + SDL_PrivateQuit(); break; case 0x400c1: /* Mode change */ - WIMP_ModeChanged (this); + WIMP_ModeChanged(this); resizeOnOpen = 1; break; case 9: /* Palette changed */ - WIMP_PaletteChanged (this); + WIMP_PaletteChanged(this); break; } break; @@ -282,12 +282,12 @@ if (sysEvent) { SDL_SysWMmsg wmmsg; - SDL_VERSION (&wmmsg.version); + SDL_VERSION(&wmmsg.version); wmmsg.eventCode = code; - SDL_memcpy (wmmsg.pollBlock, message, 64 * sizeof (int)); + SDL_memcpy(wmmsg.pollBlock, message, 64 * sizeof(int)); /* Fall out of polling loop if message is successfully posted */ - if (SDL_PrivateSysWMEvent (&wmmsg)) + if (SDL_PrivateSysWMEvent(&wmmsg)) doPoll = 0; } #if !SDL_THREADS_DISABLED @@ -295,9 +295,9 @@ /* Restart ticker here so other thread can not interfere with the Redraw processing */ if (riscos_using_threads) - __pthread_start_ticker (); + __pthread_start_ticker(); /* Give other threads a better chance of running */ - pthread_yield (); + pthread_yield(); } #endif } @@ -305,7 +305,7 @@ /* Set focus to specified window */ void -WIMP_SetFocus (int win) +WIMP_SetFocus(int win) { _kernel_swi_regs regs; @@ -316,19 +316,19 @@ regs.r[4] = 1 << 25; /* Caret is invisible */ regs.r[5] = 0; /* index into string */ - _kernel_swi (Wimp_SetCaretPosition, ®s, ®s); + _kernel_swi(Wimp_SetCaretPosition, ®s, ®s); } /** Run background task while in a sleep command */ void -RISCOS_BackgroundTasks (void) +RISCOS_BackgroundTasks(void) { if (current_video && current_video->hidden->window_handle) { - WIMP_Poll (current_video, 0); + WIMP_Poll(current_video, 0); } #if SDL_THREADS_DISABLED if (SDL_timer_running) - RISCOS_CheckTimer (); + RISCOS_CheckTimer(); #endif } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/riscos/SDL_wimpvideo.c --- a/src/video/riscos/SDL_wimpvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/riscos/SDL_wimpvideo.c Mon May 29 04:04:35 2006 +0000 @@ -43,34 +43,34 @@ #include "swis.h" /* Initialization/Query functions */ -SDL_Rect **WIMP_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags); -SDL_Surface *WIMP_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -int WIMP_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors); -void WIMP_SetWMCaption (_THIS, const char *title, const char *icon); +SDL_Rect **WIMP_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags); +SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +int WIMP_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors); +void WIMP_SetWMCaption(_THIS, const char *title, const char *icon); -extern unsigned char *WIMP_CreateBuffer (int width, int height, int bpp); -extern void WIMP_PumpEvents (_THIS); -extern void WIMP_PlotSprite (_THIS, int x, int y); -extern void WIMP_SetupPlotInfo (_THIS); -extern void WIMP_SetFocus (int win); +extern unsigned char *WIMP_CreateBuffer(int width, int height, int bpp); +extern void WIMP_PumpEvents(_THIS); +extern void WIMP_PlotSprite(_THIS, int x, int y); +extern void WIMP_SetupPlotInfo(_THIS); +extern void WIMP_SetFocus(int win); /* etc. */ -static void WIMP_UpdateRects (_THIS, int numrects, SDL_Rect * rects); +static void WIMP_UpdateRects(_THIS, int numrects, SDL_Rect * rects); /* RISC OS Wimp handling helpers */ -void WIMP_ReadModeInfo (_THIS); -unsigned int WIMP_SetupWindow (_THIS, SDL_Surface * surface); -void WIMP_SetDeviceMode (_THIS); -void WIMP_DeleteWindow (_THIS); +void WIMP_ReadModeInfo(_THIS); +unsigned int WIMP_SetupWindow(_THIS, SDL_Surface * surface); +void WIMP_SetDeviceMode(_THIS); +void WIMP_DeleteWindow(_THIS); /* FULLSCREEN function required for wimp/fullscreen toggling */ -extern int FULLSCREEN_SetMode (int width, int height, int bpp); +extern int FULLSCREEN_SetMode(int width, int height, int bpp); /* Currently need to set this up here as it only works if you start up in a Wimp mode */ -extern int RISCOS_ToggleFullScreen (_THIS, int fullscreen); +extern int RISCOS_ToggleFullScreen(_THIS, int fullscreen); extern int riscos_backbuffer; extern int mouseInWindow; @@ -78,11 +78,11 @@ /* Following needed to ensure window is shown immediately */ extern int hasFocus; -extern void WIMP_Poll (_THIS, int waitTime); +extern void WIMP_Poll(_THIS, int waitTime); SDL_Surface * -WIMP_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +WIMP_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { Uint32 Rmask = 0; Uint32 Gmask = 0; @@ -116,7 +116,7 @@ break; default: - SDL_SetError ("Pixel depth not supported"); + SDL_SetError("Pixel depth not supported"); return NULL; break; } @@ -124,9 +124,8 @@ /* printf("Setting mode %dx%d\n", width, height);*/ /* Allocate the new pixel format for the screen */ - if (!SDL_ReallocFormat (current, bpp, Rmask, Gmask, Bmask, 0)) { - SDL_SetError - ("Couldn't allocate new pixel format for requested mode"); + if (!SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0)) { + SDL_SetError("Couldn't allocate new pixel format for requested mode"); return (NULL); } @@ -136,9 +135,9 @@ if (bpp == 15) bpp = 16; - buffer = WIMP_CreateBuffer (width, height, bpp); + buffer = WIMP_CreateBuffer(width, height, bpp); if (buffer == NULL) { - SDL_SetError ("Couldn't create sprite for video memory"); + SDL_SetError("Couldn't create sprite for video memory"); return (NULL); } @@ -150,7 +149,7 @@ /* Remember sprite buffer so it can be freed later */ if (this->hidden->alloc_bank) - SDL_free (this->hidden->alloc_bank); + SDL_free(this->hidden->alloc_bank); this->hidden->alloc_bank = buffer; current->pitch = width * bytesPerPixel; @@ -161,34 +160,34 @@ current->flags = flags | SDL_PREALLOC; - WIMP_ReadModeInfo (this); + WIMP_ReadModeInfo(this); - SDL_memset (this->hidden->bank[0], 0, height * current->pitch); + SDL_memset(this->hidden->bank[0], 0, height * current->pitch); this->hidden->current_bank = 0; current->pixels = this->hidden->bank[0]; - if (WIMP_SetupWindow (this, current) == 0) { - SDL_SetError ("Unable to create window to display surface"); + if (WIMP_SetupWindow(this, current) == 0) { + SDL_SetError("Unable to create window to display surface"); return NULL; } /* Reset device functions for the wimp */ - WIMP_SetDeviceMode (this); + WIMP_SetDeviceMode(this); /* Needs to set up plot info after window has been created */ /* Not sure why, but plots don't work if I do it earlier */ - WIMP_SetupPlotInfo (this); + WIMP_SetupPlotInfo(this); /* Poll until window is shown */ { /* We wait until it gets the focus, but give up after 5 seconds in case the focus is prevented in any way. */ - Uint32 now = SDL_GetTicks (); - while (!hasFocus && SDL_GetTicks () - now < 5000) { - WIMP_Poll (this, 0); + Uint32 now = SDL_GetTicks(); + while (!hasFocus && SDL_GetTicks() - now < 5000) { + WIMP_Poll(this, 0); } } @@ -198,7 +197,7 @@ void -WIMP_ReadModeInfo (_THIS) +WIMP_ReadModeInfo(_THIS) { _kernel_swi_regs regs; int vars[6]; @@ -213,7 +212,7 @@ regs.r[0] = (int) vars; regs.r[1] = (int) vals; - _kernel_swi (OS_ReadVduVariables, ®s, ®s); + _kernel_swi(OS_ReadVduVariables, ®s, ®s); this->hidden->xeig = vals[0]; this->hidden->yeig = vals[1]; this->hidden->screen_bpp = 1 << vals[2]; @@ -225,7 +224,7 @@ in a wimp window */ void -WIMP_SetDeviceMode (_THIS) +WIMP_SetDeviceMode(_THIS) { if (this->UpdateRects == WIMP_UpdateRects) return; /* Already set up */ @@ -249,7 +248,7 @@ /* Setup the Window to display the surface */ unsigned int -WIMP_SetupWindow (_THIS, SDL_Surface * surface) +WIMP_SetupWindow(_THIS, SDL_Surface * surface) { _kernel_swi_regs regs; int window_data[23]; @@ -263,7 +262,7 @@ /* Always delete the window and recreate on a change */ if (this->hidden->window_handle) - WIMP_DeleteWindow (this); + WIMP_DeleteWindow(this); /* Setup window co-ordinates */ window_block[0] = x << xeig; @@ -300,15 +299,15 @@ regs.r[1] = (unsigned int) (window_block); /* Create the window */ - if (_kernel_swi (Wimp_CreateWindow, ®s, ®s) == NULL) { + if (_kernel_swi(Wimp_CreateWindow, ®s, ®s) == NULL) { this->hidden->window_handle = window_data[0] = regs.r[0]; /* Show the window on the screen */ regs.r[1] = (unsigned int) window_data; - if (_kernel_swi (Wimp_OpenWindow, ®s, ®s) == NULL) { - WIMP_SetFocus (this->hidden->window_handle); + if (_kernel_swi(Wimp_OpenWindow, ®s, ®s) == NULL) { + WIMP_SetFocus(this->hidden->window_handle); } else { - WIMP_DeleteWindow (this); + WIMP_DeleteWindow(this); } } @@ -318,17 +317,17 @@ /* Destroy the Window */ void -WIMP_DeleteWindow (_THIS) +WIMP_DeleteWindow(_THIS) { _kernel_swi_regs regs; regs.r[1] = (unsigned int) &(this->hidden->window_handle); - _kernel_swi (Wimp_DeleteWindow, ®s, ®s); + _kernel_swi(Wimp_DeleteWindow, ®s, ®s); this->hidden->window_handle = 0; } void -WIMP_UpdateRects (_THIS, int numrects, SDL_Rect * rects) +WIMP_UpdateRects(_THIS, int numrects, SDL_Rect * rects) { _kernel_swi_regs regs; int update_block[12]; @@ -345,10 +344,10 @@ regs.r[1] = (int) update_block; /* Update window can fail if called before first poll */ - if (_kernel_swi (Wimp_UpdateWindow, ®s, ®s) == 0) { + if (_kernel_swi(Wimp_UpdateWindow, ®s, ®s) == 0) { while (regs.r[0]) { - WIMP_PlotSprite (this, update_block[1], update_block[2]); - _kernel_swi (Wimp_GetRectangle, ®s, ®s); + WIMP_PlotSprite(this, update_block[1], update_block[2]); + _kernel_swi(Wimp_GetRectangle, ®s, ®s); } } } @@ -356,7 +355,7 @@ int -WIMP_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +WIMP_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { unsigned int *pal = (unsigned int *) (this->hidden->bank[1] + 60); int j; @@ -372,40 +371,40 @@ colors++; } - WIMP_SetupPlotInfo (this); + WIMP_SetupPlotInfo(this); /* Need to refresh the window */ update.x = 0; update.y = 0; update.w = SDL_VideoSurface->w; update.h = SDL_VideoSurface->h; - WIMP_UpdateRects (this, 1, &update); + WIMP_UpdateRects(this, 1, &update); return 1; } void -WIMP_SetWMCaption (_THIS, const char *title, const char *icon) +WIMP_SetWMCaption(_THIS, const char *title, const char *icon) { _kernel_swi_regs regs; - SDL_strlcpy (this->hidden->title, title, - SDL_arraysize (this->hidden->title)); + SDL_strlcpy(this->hidden->title, title, + SDL_arraysize(this->hidden->title)); - if (RISCOS_GetWimpVersion () < 380) { + if (RISCOS_GetWimpVersion() < 380) { int block[6]; regs.r[1] = (int) block; - _kernel_swi (Wimp_GetCaretPosition, ®s, ®s); + _kernel_swi(Wimp_GetCaretPosition, ®s, ®s); if (block[0] == (int) this->hidden->window_handle) { regs.r[0] = -1; - _kernel_swi (Wimp_SetCaretPosition, ®s, ®s); + _kernel_swi(Wimp_SetCaretPosition, ®s, ®s); } else { regs.r[0] = this->hidden->window_handle; regs.r[1] = -1; regs.r[2] = -1; regs.r[3] = -1; - _kernel_swi (Wimp_SetCaretPosition, ®s, ®s); + _kernel_swi(Wimp_SetCaretPosition, ®s, ®s); } regs.r[0] = block[0]; regs.r[1] = block[1]; @@ -413,17 +412,17 @@ regs.r[3] = block[3]; regs.r[4] = block[4]; regs.r[5] = block[5]; - _kernel_swi (Wimp_SetCaretPosition, ®s, ®s); + _kernel_swi(Wimp_SetCaretPosition, ®s, ®s); } else { regs.r[0] = this->hidden->window_handle; regs.r[1] = 0x4b534154; /* "TASK" */ regs.r[2] = 3; /* Redraw title */ - _kernel_swi (Wimp_ForceRedraw, ®s, ®s); + _kernel_swi(Wimp_ForceRedraw, ®s, ®s); } } void -WIMP_RefreshDesktop (_THIS) +WIMP_RefreshDesktop(_THIS) { int width = this->hidden->screen_width << this->hidden->xeig; int height = this->hidden->screen_height << this->hidden->yeig; @@ -433,12 +432,12 @@ regs.r[2] = 0; regs.r[3] = width; regs.r[4] = height; - _kernel_swi (Wimp_ForceRedraw, ®s, ®s); + _kernel_swi(Wimp_ForceRedraw, ®s, ®s); } /* Toggle to window from full screen */ int -WIMP_ToggleFromFullScreen (_THIS) +WIMP_ToggleFromFullScreen(_THIS) { int width = this->screen->w; int height = this->screen->h; @@ -454,15 +453,15 @@ || riscos_backbuffer == 0) { /* Need to create a sprite for the screen and copy the data to it */ char *data; - buffer = WIMP_CreateBuffer (width, height, bpp); + buffer = WIMP_CreateBuffer(width, height, bpp); data = buffer + 60; /* Start of sprite data */ if (bpp == 8) data += 2048; /* 8bpp sprite have palette first */ if (buffer == NULL) return 0; - SDL_memcpy (data, this->hidden->bank[0], - width * height * this->screen->format->BytesPerPixel); + SDL_memcpy(data, this->hidden->bank[0], + width * height * this->screen->format->BytesPerPixel); } /* else We've switch to full screen before so we already have a sprite */ @@ -481,17 +480,17 @@ this->hidden->current_bank = 0; this->screen->pixels = this->hidden->bank[0]; - RISCOS_RestoreWimpMode (); - WIMP_ReadModeInfo (this); - if (WIMP_SetupWindow (this, this->screen)) { - WIMP_SetDeviceMode (this); - WIMP_SetupPlotInfo (this); + RISCOS_RestoreWimpMode(); + WIMP_ReadModeInfo(this); + if (WIMP_SetupWindow(this, this->screen)) { + WIMP_SetDeviceMode(this); + WIMP_SetupPlotInfo(this); if (riscos_backbuffer == 0) riscos_backbuffer = 1; if (buffer && old_alloc_bank) - SDL_free (old_alloc_bank); + SDL_free(old_alloc_bank); return 1; } else { @@ -500,10 +499,10 @@ this->hidden->bank[1] = old_bank[1]; this->hidden->alloc_bank = old_alloc_bank; if (buffer) - SDL_free (buffer); + SDL_free(buffer); - RISCOS_StoreWimpMode (); - FULLSCREEN_SetMode (width, height, bpp); + RISCOS_StoreWimpMode(); + FULLSCREEN_SetMode(width, height, bpp); } return 0; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/svga/SDL_svgaevents.c --- a/src/video/svga/SDL_svgaevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/svga/SDL_svgaevents.c Mon May 29 04:04:35 2006 +0000 @@ -51,7 +51,7 @@ #error You must choose your operating system here #endif static SDLKey keymap[128]; -static SDL_keysym *TranslateKey (int scancode, SDL_keysym * keysym); +static SDL_keysym *TranslateKey(int scancode, SDL_keysym * keysym); /* Ugh, we have to duplicate the kernel's keysym mapping code... Oh, it's not so bad. :-) @@ -60,24 +60,24 @@ */ #if defined(linux) int -SVGA_initkeymaps (int fd) +SVGA_initkeymaps(int fd) { struct kbentry entry; int map, i; /* Load all the keysym mappings */ for (map = 0; map < NUM_VGAKEYMAPS; ++map) { - SDL_memset (vga_keymap[map], 0, NR_KEYS * sizeof (Uint16)); + SDL_memset(vga_keymap[map], 0, NR_KEYS * sizeof(Uint16)); for (i = 0; i < NR_KEYS; ++i) { entry.kb_table = map; entry.kb_index = i; - if (ioctl (fd, KDGKBENT, &entry) == 0) { + if (ioctl(fd, KDGKBENT, &entry) == 0) { /* The "Enter" key is a special case */ if (entry.kb_value == K_ENTER) { - entry.kb_value = K (KT_ASCII, 13); + entry.kb_value = K(KT_ASCII, 13); } /* Handle numpad specially as well */ - if (KTYP (entry.kb_value) == KT_PAD) { + if (KTYP(entry.kb_value) == KT_PAD) { switch (entry.kb_value) { case K_P0: case K_P1: @@ -93,34 +93,34 @@ vga_keymap[map][i] += '0'; break; case K_PPLUS: - vga_keymap[map][i] = K (KT_ASCII, '+'); + vga_keymap[map][i] = K(KT_ASCII, '+'); break; case K_PMINUS: - vga_keymap[map][i] = K (KT_ASCII, '-'); + vga_keymap[map][i] = K(KT_ASCII, '-'); break; case K_PSTAR: - vga_keymap[map][i] = K (KT_ASCII, '*'); + vga_keymap[map][i] = K(KT_ASCII, '*'); break; case K_PSLASH: - vga_keymap[map][i] = K (KT_ASCII, '/'); + vga_keymap[map][i] = K(KT_ASCII, '/'); break; case K_PENTER: - vga_keymap[map][i] = K (KT_ASCII, '\r'); + vga_keymap[map][i] = K(KT_ASCII, '\r'); break; case K_PCOMMA: - vga_keymap[map][i] = K (KT_ASCII, ','); + vga_keymap[map][i] = K(KT_ASCII, ','); break; case K_PDOT: - vga_keymap[map][i] = K (KT_ASCII, '.'); + vga_keymap[map][i] = K(KT_ASCII, '.'); break; default: break; } } /* Do the normal key translation */ - if ((KTYP (entry.kb_value) == KT_LATIN) || - (KTYP (entry.kb_value) == KT_ASCII) || - (KTYP (entry.kb_value) == KT_LETTER)) { + if ((KTYP(entry.kb_value) == KT_LATIN) || + (KTYP(entry.kb_value) == KT_ASCII) || + (KTYP(entry.kb_value) == KT_LETTER)) { vga_keymap[map][i] = entry.kb_value; } } @@ -130,17 +130,17 @@ } #elif defined(__FREEBSD__) int -SVGA_initkeymaps (int fd) +SVGA_initkeymaps(int fd) { - vga_keymap = SDL_malloc (sizeof (keymap_t)); + vga_keymap = SDL_malloc(sizeof(keymap_t)); if (!vga_keymap) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } - if (ioctl (fd, GIO_KEYMAP, vga_keymap) == -1) { - SDL_free (vga_keymap); + if (ioctl(fd, GIO_KEYMAP, vga_keymap) == -1) { + SDL_free(vga_keymap); vga_keymap = NULL; - SDL_SetError ("Unable to get keyboard map"); + SDL_SetError("Unable to get keyboard map"); return (-1); } return (0); @@ -152,73 +152,72 @@ int posted = 0; void -SVGA_mousecallback (int button, int dx, int dy, - int u1, int u2, int u3, int u4) +SVGA_mousecallback(int button, int dx, int dy, int u1, int u2, int u3, int u4) { if (dx || dy) { - posted += SDL_PrivateMouseMotion (0, 1, dx, dy); + posted += SDL_PrivateMouseMotion(0, 1, dx, dy); } if (button & MOUSE_LEFTBUTTON) { - if (!(SDL_GetMouseState (NULL, NULL) & SDL_BUTTON (1))) { - posted += SDL_PrivateMouseButton (SDL_PRESSED, 1, 0, 0); + if (!(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1))) { + posted += SDL_PrivateMouseButton(SDL_PRESSED, 1, 0, 0); } } else { - if ((SDL_GetMouseState (NULL, NULL) & SDL_BUTTON (1))) { - posted += SDL_PrivateMouseButton (SDL_RELEASED, 1, 0, 0); + if ((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1))) { + posted += SDL_PrivateMouseButton(SDL_RELEASED, 1, 0, 0); } } if (button & MOUSE_MIDDLEBUTTON) { - if (!(SDL_GetMouseState (NULL, NULL) & SDL_BUTTON (2))) { - posted += SDL_PrivateMouseButton (SDL_PRESSED, 2, 0, 0); + if (!(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(2))) { + posted += SDL_PrivateMouseButton(SDL_PRESSED, 2, 0, 0); } } else { - if ((SDL_GetMouseState (NULL, NULL) & SDL_BUTTON (2))) { - posted += SDL_PrivateMouseButton (SDL_RELEASED, 2, 0, 0); + if ((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(2))) { + posted += SDL_PrivateMouseButton(SDL_RELEASED, 2, 0, 0); } } if (button & MOUSE_RIGHTBUTTON) { - if (!(SDL_GetMouseState (NULL, NULL) & SDL_BUTTON (3))) { - posted += SDL_PrivateMouseButton (SDL_PRESSED, 3, 0, 0); + if (!(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3))) { + posted += SDL_PrivateMouseButton(SDL_PRESSED, 3, 0, 0); } } else { - if ((SDL_GetMouseState (NULL, NULL) & SDL_BUTTON (3))) { - posted += SDL_PrivateMouseButton (SDL_RELEASED, 3, 0, 0); + if ((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3))) { + posted += SDL_PrivateMouseButton(SDL_RELEASED, 3, 0, 0); } } } void -SVGA_keyboardcallback (int scancode, int pressed) +SVGA_keyboardcallback(int scancode, int pressed) { SDL_keysym keysym; if (pressed) { - posted += SDL_PrivateKeyboard (SDL_PRESSED, - TranslateKey (scancode, &keysym)); + posted += SDL_PrivateKeyboard(SDL_PRESSED, + TranslateKey(scancode, &keysym)); } else { - posted += SDL_PrivateKeyboard (SDL_RELEASED, - TranslateKey (scancode, &keysym)); + posted += SDL_PrivateKeyboard(SDL_RELEASED, + TranslateKey(scancode, &keysym)); } } void -SVGA_PumpEvents (_THIS) +SVGA_PumpEvents(_THIS) { do { posted = 0; - mouse_update (); - keyboard_update (); + mouse_update(); + keyboard_update(); } while (posted); } void -SVGA_InitOSKeymap (_THIS) +SVGA_InitOSKeymap(_THIS) { int i; /* Initialize the BeOS key translation table */ - for (i = 0; i < SDL_arraysize (keymap); ++i) + for (i = 0; i < SDL_arraysize(keymap); ++i) keymap[i] = SDLK_UNKNOWN; keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE; @@ -341,7 +340,7 @@ #if defined(linux) static SDL_keysym * -TranslateKey (int scancode, SDL_keysym * keysym) +TranslateKey(int scancode, SDL_keysym * keysym) { /* Set the keysym information */ keysym->scancode = scancode; @@ -354,7 +353,7 @@ int map; SDLMod modstate; - modstate = SDL_GetModState (); + modstate = SDL_GetModState(); map = 0; if (modstate & KMOD_SHIFT) { map |= (1 << KG_SHIFT); @@ -368,24 +367,24 @@ if (modstate & KMOD_MODE) { map |= (1 << KG_ALTGR); } - if (KTYP (vga_keymap[map][scancode]) == KT_LETTER) { + if (KTYP(vga_keymap[map][scancode]) == KT_LETTER) { if (modstate & KMOD_CAPS) { map ^= (1 << KG_SHIFT); } } - if (KTYP (vga_keymap[map][scancode]) == KT_PAD) { + if (KTYP(vga_keymap[map][scancode]) == KT_PAD) { if (modstate & KMOD_NUM) { - keysym->unicode = KVAL (vga_keymap[map][scancode]); + keysym->unicode = KVAL(vga_keymap[map][scancode]); } } else { - keysym->unicode = KVAL (vga_keymap[map][scancode]); + keysym->unicode = KVAL(vga_keymap[map][scancode]); } } return (keysym); } #elif defined(__FREEBSD__) static SDL_keysym * -TranslateKey (int scancode, SDL_keysym * keysym) +TranslateKey(int scancode, SDL_keysym * keysym) { /* Set the keysym information */ keysym->scancode = scancode; @@ -398,7 +397,7 @@ int map; SDLMod modstate; - modstate = SDL_GetModState (); + modstate = SDL_GetModState(); map = 0; if (modstate & KMOD_SHIFT) { map += 1; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/svga/SDL_svgaevents_c.h --- a/src/video/svga/SDL_svgaevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/svga/SDL_svgaevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -26,11 +26,11 @@ /* Variables and functions exported by SDL_sysevents.c to other parts of the native video subsystem (SDL_sysvideo.c) */ -extern int SVGA_initkeymaps (int fd); -extern void SVGA_mousecallback (int button, int dx, int dy, - int u1, int u2, int u3, int u4); -extern void SVGA_keyboardcallback (int scancode, int pressed); +extern int SVGA_initkeymaps(int fd); +extern void SVGA_mousecallback(int button, int dx, int dy, + int u1, int u2, int u3, int u4); +extern void SVGA_keyboardcallback(int scancode, int pressed); -extern void SVGA_InitOSKeymap (_THIS); -extern void SVGA_PumpEvents (_THIS); +extern void SVGA_InitOSKeymap(_THIS); +extern void SVGA_PumpEvents(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/svga/SDL_svgavideo.c --- a/src/video/svga/SDL_svgavideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/svga/SDL_svgavideo.c Mon May 29 04:04:35 2006 +0000 @@ -51,27 +51,27 @@ #include "SDL_svgamouse_c.h" /* Initialization/Query functions */ -static int SVGA_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **SVGA_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *SVGA_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); -static int SVGA_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void SVGA_VideoQuit (_THIS); +static int SVGA_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **SVGA_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +static SDL_Surface *SVGA_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, + Uint32 flags); +static int SVGA_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void SVGA_VideoQuit(_THIS); /* Hardware surface functions */ -static int SVGA_AllocHWSurface (_THIS, SDL_Surface * surface); -static int SVGA_LockHWSurface (_THIS, SDL_Surface * surface); -static int SVGA_FlipHWSurface (_THIS, SDL_Surface * surface); -static void SVGA_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void SVGA_FreeHWSurface (_THIS, SDL_Surface * surface); +static int SVGA_AllocHWSurface(_THIS, SDL_Surface * surface); +static int SVGA_LockHWSurface(_THIS, SDL_Surface * surface); +static int SVGA_FlipHWSurface(_THIS, SDL_Surface * surface); +static void SVGA_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void SVGA_FreeHWSurface(_THIS, SDL_Surface * surface); /* SVGAlib driver bootstrap functions */ static int -SVGA_Available (void) +SVGA_Available(void) { /* Check to see if we are root and stdin is a virtual console */ int console; @@ -86,49 +86,49 @@ struct stat sb; struct vt_mode dummy; - if ((fstat (console, &sb) < 0) || - (ioctl (console, VT_GETMODE, &dummy) < 0)) { + if ((fstat(console, &sb) < 0) || + (ioctl(console, VT_GETMODE, &dummy) < 0)) { console = -1; } } #endif /* 0 */ /* See if SVGAlib 2.0 is available */ - svgalib2 = open ("/dev/svga", O_RDONLY); + svgalib2 = open("/dev/svga", O_RDONLY); if (svgalib2 != -1) { - close (svgalib2); + close(svgalib2); } - return (((svgalib2 != -1) || (geteuid () == 0)) && (console >= 0)); + return (((svgalib2 != -1) || (geteuid() == 0)) && (console >= 0)); } static void -SVGA_DeleteDevice (SDL_VideoDevice * device) +SVGA_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -SVGA_CreateDevice (int devindex) +SVGA_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = SVGA_VideoInit; @@ -165,12 +165,12 @@ }; static int -SVGA_AddMode (_THIS, int mode, int actually_add) +SVGA_AddMode(_THIS, int mode, int actually_add) { int i, j; vga_modeinfo *modeinfo; - modeinfo = vga_getmodeinfo (mode); + modeinfo = vga_getmodeinfo(mode); i = modeinfo->bytesperpixel - 1; if (i < 0) { @@ -218,23 +218,23 @@ } static void -SVGA_UpdateVideoInfo (_THIS) +SVGA_UpdateVideoInfo(_THIS) { vga_modeinfo *modeinfo; this->info.wm_available = 0; this->info.hw_available = (banked ? 0 : 1); - modeinfo = vga_getmodeinfo (vga_getcurrentmode ()); + modeinfo = vga_getmodeinfo(vga_getcurrentmode()); this->info.video_mem = modeinfo->memory; /* FIXME: Add hardware accelerated blit information */ #ifdef SVGALIB_DEBUG - printf ("Hardware accelerated blit: %savailable\n", - modeinfo->haveblit ? "" : "not "); + printf("Hardware accelerated blit: %savailable\n", + modeinfo->haveblit ? "" : "not "); #endif } int -SVGA_VideoInit (_THIS, SDL_PixelFormat * vformat) +SVGA_VideoInit(_THIS, SDL_PixelFormat * vformat) { int keyboard; int i, j; @@ -248,24 +248,24 @@ } /* Initialize the library */ - vga_disabledriverreport (); - if (vga_init () < 0) { - SDL_SetError ("Unable to initialize SVGAlib"); + vga_disabledriverreport(); + if (vga_init() < 0) { + SDL_SetError("Unable to initialize SVGAlib"); return (-1); } - vga_setmode (TEXT); + vga_setmode(TEXT); /* Enable mouse and keyboard support */ - vga_setmousesupport (1); - keyboard = keyboard_init_return_fd (); + vga_setmousesupport(1); + keyboard = keyboard_init_return_fd(); if (keyboard < 0) { - SDL_SetError ("Unable to initialize keyboard"); + SDL_SetError("Unable to initialize keyboard"); return (-1); } - if (SVGA_initkeymaps (keyboard) < 0) { + if (SVGA_initkeymaps(keyboard) < 0) { return (-1); } - keyboard_seteventhandler (SVGA_keyboardcallback); + keyboard_seteventhandler(SVGA_keyboardcallback); /* Determine the current screen size */ this->info.current_w = 0; @@ -276,47 +276,47 @@ /* Enumerate the available fullscreen modes */ total_modes = 0; - for (mode = vga_lastmodenumber (); mode; --mode) { - if (vga_hasmode (mode)) { - if (SVGA_AddMode (this, mode, 0)) { + for (mode = vga_lastmodenumber(); mode; --mode) { + if (vga_hasmode(mode)) { + if (SVGA_AddMode(this, mode, 0)) { ++total_modes; } } } - if (SVGA_AddMode (this, G320x200x256, 0)) + if (SVGA_AddMode(this, G320x200x256, 0)) ++total_modes; if (total_modes == 0) { - SDL_SetError ("No linear video modes available"); + SDL_SetError("No linear video modes available"); return (-1); } for (i = 0; i < NUM_MODELISTS; ++i) { - SDL_vgamode[i] = (int *) SDL_malloc (SDL_nummodes[i] * sizeof (int)); + SDL_vgamode[i] = (int *) SDL_malloc(SDL_nummodes[i] * sizeof(int)); if (SDL_vgamode[i] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } SDL_modelist[i] = (SDL_Rect **) - SDL_malloc ((SDL_nummodes[i] + 1) * sizeof (SDL_Rect *)); + SDL_malloc((SDL_nummodes[i] + 1) * sizeof(SDL_Rect *)); if (SDL_modelist[i] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } for (j = 0; j < SDL_nummodes[i]; ++j) { - SDL_modelist[i][j] = (SDL_Rect *) SDL_malloc (sizeof (SDL_Rect)); + SDL_modelist[i][j] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect)); if (SDL_modelist[i][j] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } - SDL_memset (SDL_modelist[i][j], 0, sizeof (SDL_Rect)); + SDL_memset(SDL_modelist[i][j], 0, sizeof(SDL_Rect)); } SDL_modelist[i][j] = NULL; } - for (mode = vga_lastmodenumber (); mode; --mode) { - if (vga_hasmode (mode)) { - SVGA_AddMode (this, mode, 1); + for (mode = vga_lastmodenumber(); mode; --mode) { + if (vga_hasmode(mode)) { + SVGA_AddMode(this, mode, 1); } } - SVGA_AddMode (this, G320x200x256, 1); + SVGA_AddMode(this, G320x200x256, 1); /* Free extra (duplicated) modes */ for (i = 0; i < NUM_MODELISTS; ++i) { @@ -325,32 +325,32 @@ j++; } while (SDL_modelist[i][j]) { - SDL_free (SDL_modelist[i][j]); + SDL_free(SDL_modelist[i][j]); SDL_modelist[i][j] = NULL; j++; } } /* Fill in our hardware acceleration capabilities */ - SVGA_UpdateVideoInfo (this); + SVGA_UpdateVideoInfo(this); /* We're done! */ return (0); } SDL_Rect ** -SVGA_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +SVGA_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]); } /* Various screen update functions available */ -static void SVGA_DirectUpdate (_THIS, int numrects, SDL_Rect * rects); -static void SVGA_BankedUpdate (_THIS, int numrects, SDL_Rect * rects); +static void SVGA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects); +static void SVGA_BankedUpdate(_THIS, int numrects, SDL_Rect * rects); SDL_Surface * -SVGA_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +SVGA_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { int mode; int vgamode; @@ -359,7 +359,7 @@ /* Free old pixels if we were in banked mode */ if (banked && current->pixels) { - free (current->pixels); + free(current->pixels); current->pixels = NULL; } @@ -372,30 +372,30 @@ } } if (SDL_modelist[bpp][mode] == NULL) { - SDL_SetError ("Couldn't find requested mode in list"); + SDL_SetError("Couldn't find requested mode in list"); return (NULL); } vgamode = SDL_vgamode[bpp][mode]; - vga_setmode (vgamode); - vga_setpage (0); + vga_setmode(vgamode); + vga_setpage(0); - if ((vga_setlinearaddressing () < 0) && (vgamode != G320x200x256)) { + if ((vga_setlinearaddressing() < 0) && (vgamode != G320x200x256)) { banked = 1; } else { banked = 0; } - modeinfo = vga_getmodeinfo (SDL_vgamode[bpp][mode]); + modeinfo = vga_getmodeinfo(SDL_vgamode[bpp][mode]); /* Update hardware acceleration info */ - SVGA_UpdateVideoInfo (this); + SVGA_UpdateVideoInfo(this); /* Allocate the new pixel format for the screen */ bpp = (bpp + 1) * 8; if ((bpp == 16) && (modeinfo->colors == 32768)) { bpp = 15; } - if (!SDL_ReallocFormat (current, bpp, 0, 0, 0, 0)) { + if (!SDL_ReallocFormat(current, bpp, 0, 0, 0, 0)) { return (NULL); } @@ -412,13 +412,13 @@ current->h = height; current->pitch = modeinfo->linewidth; if (banked) { - current->pixels = SDL_malloc (current->h * current->pitch); + current->pixels = SDL_malloc(current->h * current->pitch); if (!current->pixels) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } } else { - current->pixels = vga_getgraphmem (); + current->pixels = vga_getgraphmem(); } /* set double-buffering */ @@ -441,9 +441,9 @@ flip_page = 0; flip_offset[0] = 0; flip_offset[1] = screenpage_len; - flip_address[0] = vga_getgraphmem (); + flip_address[0] = vga_getgraphmem(); flip_address[1] = flip_address[0] + screenpage_len; - SVGA_FlipHWSurface (this, current); + SVGA_FlipHWSurface(this, current); } } @@ -455,7 +455,7 @@ } /* Set up the mouse handler again (buggy SVGAlib 1.40) */ - mouse_seteventhandler (SVGA_mousecallback); + mouse_seteventhandler(SVGA_mousecallback); /* We're done */ return (current); @@ -463,49 +463,49 @@ /* We don't actually allow hardware surfaces other than the main one */ static int -SVGA_AllocHWSurface (_THIS, SDL_Surface * surface) +SVGA_AllocHWSurface(_THIS, SDL_Surface * surface) { return (-1); } static void -SVGA_FreeHWSurface (_THIS, SDL_Surface * surface) +SVGA_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } /* We need to wait for vertical retrace on page flipped displays */ static int -SVGA_LockHWSurface (_THIS, SDL_Surface * surface) +SVGA_LockHWSurface(_THIS, SDL_Surface * surface) { /* The waiting is done in SVGA_FlipHWSurface() */ return (0); } static void -SVGA_UnlockHWSurface (_THIS, SDL_Surface * surface) +SVGA_UnlockHWSurface(_THIS, SDL_Surface * surface) { return; } static int -SVGA_FlipHWSurface (_THIS, SDL_Surface * surface) +SVGA_FlipHWSurface(_THIS, SDL_Surface * surface) { if (!banked) { - vga_setdisplaystart (flip_offset[flip_page]); + vga_setdisplaystart(flip_offset[flip_page]); flip_page = !flip_page; surface->pixels = flip_address[flip_page]; - vga_waitretrace (); + vga_waitretrace(); } return (0); } static void -SVGA_DirectUpdate (_THIS, int numrects, SDL_Rect * rects) +SVGA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects) { return; } static void -SVGA_BankedUpdate (_THIS, int numrects, SDL_Rect * rects) +SVGA_BankedUpdate(_THIS, int numrects, SDL_Rect * rects) { int i, j; SDL_Rect *rect; @@ -516,7 +516,7 @@ int bpp = this->screen->format->BytesPerPixel; int pitch = this->screen->pitch; - dst = vga_getgraphmem (); + dst = vga_getgraphmem(); for (i = 0; i < numrects; ++i) { rect = &rects[i]; x = rect->x; @@ -528,24 +528,24 @@ src = (unsigned char *) this->screen->pixels + vp; page = vp >> 16; vp &= 0xffff; - vga_setpage (page); + vga_setpage(page); for (j = 0; j < h; j++) { if (vp + w > 0x10000) { if (vp >= 0x10000) { page++; - vga_setpage (page); + vga_setpage(page); vp &= 0xffff; } else { - SDL_memcpy (dst + vp, src, 0x10000 - vp); + SDL_memcpy(dst + vp, src, 0x10000 - vp); page++; - vga_setpage (page); - SDL_memcpy (dst, src + 0x10000 - vp, (vp + w) & 0xffff); + vga_setpage(page); + SDL_memcpy(dst, src + 0x10000 - vp, (vp + w) & 0xffff); vp = (vp + pitch) & 0xffff; src += pitch; continue; } } - SDL_memcpy (dst + vp, src, w); + SDL_memcpy(dst + vp, src, w); src += pitch; vp += pitch; } @@ -553,13 +553,13 @@ } int -SVGA_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +SVGA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { int i; for (i = 0; i < ncolors; i++) { - vga_setpalette (firstcolor + i, - colors[i].r >> 2, colors[i].g >> 2, colors[i].b >> 2); + vga_setpalette(firstcolor + i, + colors[i].r >> 2, colors[i].g >> 2, colors[i].b >> 2); } return (1); } @@ -568,32 +568,32 @@ another SDL video routine -- notably UpdateRects. */ void -SVGA_VideoQuit (_THIS) +SVGA_VideoQuit(_THIS) { int i, j; /* Reset the console video mode */ if (this->screen && (this->screen->w && this->screen->h)) { - vga_setmode (TEXT); + vga_setmode(TEXT); } - keyboard_close (); + keyboard_close(); /* Free video mode lists */ for (i = 0; i < NUM_MODELISTS; ++i) { if (SDL_modelist[i] != NULL) { for (j = 0; SDL_modelist[i][j]; ++j) - SDL_free (SDL_modelist[i][j]); - SDL_free (SDL_modelist[i]); + SDL_free(SDL_modelist[i][j]); + SDL_free(SDL_modelist[i]); SDL_modelist[i] = NULL; } if (SDL_vgamode[i] != NULL) { - SDL_free (SDL_vgamode[i]); + SDL_free(SDL_vgamode[i]); SDL_vgamode[i] = NULL; } } if (this->screen) { if (banked && this->screen->pixels) { - SDL_free (this->screen->pixels); + SDL_free(this->screen->pixels); } this->screen->pixels = NULL; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/vgl/SDL_vglevents.c --- a/src/video/vgl/SDL_vglevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/vgl/SDL_vglevents.c Mon May 29 04:04:35 2006 +0000 @@ -41,7 +41,7 @@ /* FIXME: Free the keymap when we shut down the video mode */ static keymap_t *vga_keymap = NULL; static SDLKey keymap[128]; -static SDL_keysym *TranslateKey (int scancode, SDL_keysym * keysym); +static SDL_keysym *TranslateKey(int scancode, SDL_keysym * keysym); static int posted = 0; static int oldx = -1; @@ -54,29 +54,29 @@ FIXME: Add keyboard LED handling code */ int -VGL_initkeymaps (int fd) +VGL_initkeymaps(int fd) { - vga_keymap = SDL_malloc (sizeof (keymap_t)); + vga_keymap = SDL_malloc(sizeof(keymap_t)); if (!vga_keymap) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } - if (ioctl (fd, GIO_KEYMAP, vga_keymap) == -1) { - SDL_free (vga_keymap); + if (ioctl(fd, GIO_KEYMAP, vga_keymap) == -1) { + SDL_free(vga_keymap); vga_keymap = NULL; - SDL_SetError ("Unable to get keyboard map"); + SDL_SetError("Unable to get keyboard map"); return (-1); } return (0); } static void -handle_keyboard (_THIS) +handle_keyboard(_THIS) { SDL_keysym keysym; int c, pressed, scancode; - while ((c = VGLKeyboardGetCh ()) != 0) { + while ((c = VGLKeyboardGetCh()) != 0) { scancode = c & 0x7F; if (c & 0x80) { pressed = SDL_RELEASED; @@ -84,42 +84,42 @@ pressed = SDL_PRESSED; } - posted += SDL_PrivateKeyboard (pressed, - TranslateKey (scancode, &keysym)); + posted += SDL_PrivateKeyboard(pressed, + TranslateKey(scancode, &keysym)); } } int -VGL_initmouse (int fd) +VGL_initmouse(int fd) { mouseinfo.operation = MOUSE_GETINFO; - if (ioctl (fd, CONS_MOUSECTL, &mouseinfo) != 0) + if (ioctl(fd, CONS_MOUSECTL, &mouseinfo) != 0) return -1; return 0; } static void -handle_mouse (_THIS) +handle_mouse(_THIS) { char buttons; int x, y; int button_state, state_changed, state; int i; - ioctl (0, CONS_MOUSECTL, &mouseinfo); + ioctl(0, CONS_MOUSECTL, &mouseinfo); x = mouseinfo.u.data.x; y = mouseinfo.u.data.y; buttons = mouseinfo.u.data.buttons; if ((x != oldx) || (y != oldy)) { - posted += SDL_PrivateMouseMotion (0, 0, x, y); + posted += SDL_PrivateMouseMotion(0, 0, x, y); oldx = x; oldy = y; } /* See what's changed */ - button_state = SDL_GetMouseState (NULL, NULL); + button_state = SDL_GetMouseState(NULL, NULL); state_changed = button_state ^ buttons; for (i = 0; i < 8; i++) { if (state_changed & (1 << i)) { @@ -128,30 +128,30 @@ } else { state = SDL_RELEASED; } - posted += SDL_PrivateMouseButton (state, i + 1, 0, 0); + posted += SDL_PrivateMouseButton(state, i + 1, 0, 0); } } } void -VGL_PumpEvents (_THIS) +VGL_PumpEvents(_THIS) { do { posted = 0; - handle_keyboard (this); - handle_mouse (this); + handle_keyboard(this); + handle_mouse(this); } while (posted != 0); } void -VGL_InitOSKeymap (_THIS) +VGL_InitOSKeymap(_THIS) { int i; /* Initialize the BeOS key translation table */ - for (i = 0; i < SDL_arraysize (keymap); ++i) + for (i = 0; i < SDL_arraysize(keymap); ++i) keymap[i] = SDLK_UNKNOWN; keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE; @@ -273,7 +273,7 @@ } static SDL_keysym * -TranslateKey (int scancode, SDL_keysym * keysym) +TranslateKey(int scancode, SDL_keysym * keysym) { /* Set the keysym information */ keysym->scancode = scancode; @@ -286,7 +286,7 @@ int map; SDLMod modstate; - modstate = SDL_GetModState (); + modstate = SDL_GetModState(); map = 0; if (modstate & KMOD_SHIFT) { map += 1; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/vgl/SDL_vglevents_c.h --- a/src/video/vgl/SDL_vglevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/vgl/SDL_vglevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -26,12 +26,12 @@ /* Variables and functions exported by SDL_sysevents.c to other parts of the native video subsystem (SDL_sysvideo.c) */ -extern int VGL_initkeymaps (int fd); -extern int VGL_initmouse (int fd); -extern void VGL_keyboardcallback (int scancode, int pressed); +extern int VGL_initkeymaps(int fd); +extern int VGL_initmouse(int fd); +extern void VGL_keyboardcallback(int scancode, int pressed); -extern void VGL_InitOSKeymap (_THIS); -extern void VGL_PumpEvents (_THIS); +extern void VGL_InitOSKeymap(_THIS); +extern void VGL_PumpEvents(_THIS); /* Mouse buttons */ #define MOUSE_LEFTBUTTON 0x01 diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/vgl/SDL_vglmouse.c --- a/src/video/vgl/SDL_vglmouse.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/vgl/SDL_vglmouse.c Mon May 29 04:04:35 2006 +0000 @@ -35,29 +35,29 @@ void -VGL_FreeWMCursor (_THIS, WMcursor * cursor) +VGL_FreeWMCursor(_THIS, WMcursor * cursor) { return; } WMcursor * -VGL_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, int hot_x, - int hot_y) +VGL_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, int hot_x, + int hot_y) { return (NULL); } int -VGL_ShowWMCursor (_THIS, WMcursor * cursor) +VGL_ShowWMCursor(_THIS, WMcursor * cursor) { return (0); } void -VGL_WarpWMCursor (_THIS, Uint16 x, Uint16 y) +VGL_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { - SDL_PrivateMouseMotion (0, 0, x, y); + SDL_PrivateMouseMotion(0, 0, x, y); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/vgl/SDL_vglmouse_c.h --- a/src/video/vgl/SDL_vglmouse_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/vgl/SDL_vglmouse_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,10 +24,10 @@ #include "SDL_vglvideo.h" /* Functions to be exported */ -extern void VGL_FreeWMCursor (_THIS, WMcursor * cursor); -extern WMcursor *VGL_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, - int hot_x, int hot_y); -extern int VGL_ShowWMCursor (_THIS, WMcursor * cursor); -extern void VGL_WarpWMCursor (_THIS, Uint16 x, Uint16 y); +extern void VGL_FreeWMCursor(_THIS, WMcursor * cursor); +extern WMcursor *VGL_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, + int hot_x, int hot_y); +extern int VGL_ShowWMCursor(_THIS, WMcursor * cursor); +extern void VGL_WarpWMCursor(_THIS, Uint16 x, Uint16 y); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/vgl/SDL_vglvideo.c --- a/src/video/vgl/SDL_vglvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/vgl/SDL_vglvideo.c Mon May 29 04:04:35 2006 +0000 @@ -45,30 +45,30 @@ /* Initialization/Query functions */ -static int VGL_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **VGL_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *VGL_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int VGL_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void VGL_VideoQuit (_THIS); +static int VGL_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **VGL_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +static SDL_Surface *VGL_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +static int VGL_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void VGL_VideoQuit(_THIS); /* Hardware surface functions */ -static int VGL_AllocHWSurface (_THIS, SDL_Surface * surface); -static int VGL_LockHWSurface (_THIS, SDL_Surface * surface); -static int VGL_FlipHWSurface (_THIS, SDL_Surface * surface); -static void VGL_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void VGL_FreeHWSurface (_THIS, SDL_Surface * surface); +static int VGL_AllocHWSurface(_THIS, SDL_Surface * surface); +static int VGL_LockHWSurface(_THIS, SDL_Surface * surface); +static int VGL_FlipHWSurface(_THIS, SDL_Surface * surface); +static void VGL_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void VGL_FreeHWSurface(_THIS, SDL_Surface * surface); /* Misc function */ -static VGLMode **VGLListModes (int depth, int mem_model); -static void VGLWaitRetrace (void); +static VGLMode **VGLListModes(int depth, int mem_model); +static void VGLWaitRetrace(void); /* VGL driver bootstrap functions */ static int -VGL_Available (void) +VGL_Available(void) { /* * Check to see if we are root and stdin is a @@ -83,15 +83,15 @@ struct stat sb; struct vt_mode dummy; - if ((fstat (console, &sb) < 0) || - (ioctl (console, VT_GETMODE, &dummy) < 0)) { + if ((fstat(console, &sb) < 0) || + (ioctl(console, VT_GETMODE, &dummy) < 0)) { console = -1; } } - if (geteuid () != 0 && console == -1) + if (geteuid() != 0 && console == -1) return 0; - modes = VGLListModes (8, V_INFO_MM_DIRECT | V_INFO_MM_PACKED); + modes = VGLListModes(8, V_INFO_MM_DIRECT | V_INFO_MM_PACKED); hires_available = 0; for (i = 0; modes[i] != NULL; i++) { if ((modes[i]->ModeInfo.Xsize > 320) && @@ -107,32 +107,32 @@ } static void -VGL_DeleteDevice (SDL_VideoDevice * device) +VGL_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -VGL_CreateDevice (int devindex) +VGL_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); /* Set the function pointers */ device->VideoInit = VGL_VideoInit; @@ -171,7 +171,7 @@ }; static int -VGL_AddMode (_THIS, VGLMode * inmode) +VGL_AddMode(_THIS, VGLMode * inmode) { SDL_Rect *mode; @@ -191,9 +191,9 @@ } /* Set up the new video mode rectangle */ - mode = (SDL_Rect *) SDL_malloc (sizeof *mode); + mode = (SDL_Rect *) SDL_malloc(sizeof *mode); if (mode == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return -1; } mode->x = 0; @@ -204,12 +204,12 @@ /* Allocate the new list of modes, and fill in the new mode */ next_mode = SDL_nummodes[index]; SDL_modelist[index] = (SDL_Rect **) - SDL_realloc (SDL_modelist[index], - (1 + next_mode + 1) * sizeof (SDL_Rect *)); + SDL_realloc(SDL_modelist[index], + (1 + next_mode + 1) * sizeof(SDL_Rect *)); if (SDL_modelist[index] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); SDL_nummodes[index] = 0; - SDL_free (mode); + SDL_free(mode); return -1; } SDL_modelist[index][next_mode] = mode; @@ -220,7 +220,7 @@ } static void -VGL_UpdateVideoInfo (_THIS) +VGL_UpdateVideoInfo(_THIS) { this->info.wm_available = 0; this->info.hw_available = 1; @@ -235,7 +235,7 @@ } int -VGL_VideoInit (_THIS, SDL_PixelFormat * vformat) +VGL_VideoInit(_THIS, SDL_PixelFormat * vformat) { int i; int total_modes; @@ -248,20 +248,20 @@ } /* Enable mouse and keyboard support */ - if (SDL_getenv ("SDL_NO_RAWKBD") == NULL) { - if (VGLKeyboardInit (VGL_CODEKEYS) != 0) { - SDL_SetError ("Unable to initialize keyboard"); + if (SDL_getenv("SDL_NO_RAWKBD") == NULL) { + if (VGLKeyboardInit(VGL_CODEKEYS) != 0) { + SDL_SetError("Unable to initialize keyboard"); return -1; } } else { - warnx ("Requiest to put keyboard into a raw mode ignored"); + warnx("Requiest to put keyboard into a raw mode ignored"); } - if (VGL_initkeymaps (STDIN_FILENO) != 0) { - SDL_SetError ("Unable to initialize keymap"); + if (VGL_initkeymaps(STDIN_FILENO) != 0) { + SDL_SetError("Unable to initialize keymap"); return -1; } - if (VGL_initmouse (STDIN_FILENO) != 0) { - SDL_SetError ("Unable to initialize mouse"); + if (VGL_initmouse(STDIN_FILENO) != 0) { + SDL_SetError("Unable to initialize mouse"); return -1; } @@ -279,28 +279,28 @@ /* Query for the list of available video modes */ total_modes = 0; - modes = VGLListModes (-1, V_INFO_MM_DIRECT | V_INFO_MM_PACKED); + modes = VGLListModes(-1, V_INFO_MM_DIRECT | V_INFO_MM_PACKED); for (i = 0; modes[i] != NULL; i++) { if ((modes[i]->ModeInfo.Type == VIDBUF8) || (modes[i]->ModeInfo.Type == VIDBUF16) || (modes[i]->ModeInfo.Type == VIDBUF32)) { - VGL_AddMode (this, modes[i]); + VGL_AddMode(this, modes[i]); total_modes++; } } if (total_modes == 0) { - SDL_SetError ("No linear video modes available"); + SDL_SetError("No linear video modes available"); return -1; } /* Fill in our hardware acceleration capabilities */ - VGL_UpdateVideoInfo (this); + VGL_UpdateVideoInfo(this); /* Create the hardware surface lock mutex */ - hw_lock = SDL_CreateMutex (); + hw_lock = SDL_CreateMutex(); if (hw_lock == NULL) { - SDL_SetError ("Unable to create lock mutex"); - VGL_VideoQuit (this); + SDL_SetError("Unable to create lock mutex"); + VGL_VideoQuit(this); return -1; } @@ -309,24 +309,24 @@ } SDL_Rect ** -VGL_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +VGL_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { return SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]; } /* Various screen update functions available */ -static void VGL_DirectUpdate (_THIS, int numrects, SDL_Rect * rects); -static void VGL_BankedUpdate (_THIS, int numrects, SDL_Rect * rects); +static void VGL_DirectUpdate(_THIS, int numrects, SDL_Rect * rects); +static void VGL_BankedUpdate(_THIS, int numrects, SDL_Rect * rects); SDL_Surface * -VGL_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +VGL_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { int mode_found; int i; VGLMode **modes; - modes = VGLListModes (bpp, V_INFO_MM_DIRECT | V_INFO_MM_PACKED); + modes = VGLListModes(bpp, V_INFO_MM_DIRECT | V_INFO_MM_PACKED); mode_found = 0; for (i = 0; modes[i] != NULL; i++) { if ((modes[i]->ModeInfo.Xsize == width) && @@ -339,21 +339,21 @@ } } if (mode_found == 0) { - SDL_SetError ("No matching video mode found"); + SDL_SetError("No matching video mode found"); return NULL; } /* Shutdown previous videomode (if any) */ if (VGLCurMode != NULL) - VGLEnd (); + VGLEnd(); /* Try to set the requested linear video mode */ - if (VGLInit (modes[i]->ModeId) != 0) { - SDL_SetError ("Unable to switch to requested mode"); + if (VGLInit(modes[i]->ModeId) != 0) { + SDL_SetError("Unable to switch to requested mode"); return NULL; } - VGLCurMode = SDL_realloc (VGLCurMode, sizeof (VGLMode)); + VGLCurMode = SDL_realloc(VGLCurMode, sizeof(VGLMode)); VGLCurMode->ModeInfo = *VGLDisplay; VGLCurMode->Depth = modes[i]->Depth; VGLCurMode->ModeId = modes[i]->ModeId; @@ -384,17 +384,17 @@ flip_address[0] = (byte *) current->pixels; flip_address[1] = (byte *) current->pixels + current->h * current->pitch; - VGL_FlipHWSurface (this, current); + VGL_FlipHWSurface(this, current); } } - if (!SDL_ReallocFormat (current, modes[i]->Depth, VGLCurMode->Rmask, - VGLCurMode->Gmask, VGLCurMode->Bmask, 0)) { + if (!SDL_ReallocFormat(current, modes[i]->Depth, VGLCurMode->Rmask, + VGLCurMode->Gmask, VGLCurMode->Bmask, 0)) { return NULL; } /* Update hardware acceleration info */ - VGL_UpdateVideoInfo (this); + VGL_UpdateVideoInfo(this); /* Set the blit function */ this->UpdateRects = VGL_DirectUpdate; @@ -405,39 +405,39 @@ /* We don't actually allow hardware surfaces other than the main one */ static int -VGL_AllocHWSurface (_THIS, SDL_Surface * surface) +VGL_AllocHWSurface(_THIS, SDL_Surface * surface) { return -1; } static void -VGL_FreeHWSurface (_THIS, SDL_Surface * surface) +VGL_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } /* We need to wait for vertical retrace on page flipped displays */ static int -VGL_LockHWSurface (_THIS, SDL_Surface * surface) +VGL_LockHWSurface(_THIS, SDL_Surface * surface) { if (surface == SDL_VideoSurface) { - SDL_mutexP (hw_lock); + SDL_mutexP(hw_lock); } return 0; } static void -VGL_UnlockHWSurface (_THIS, SDL_Surface * surface) +VGL_UnlockHWSurface(_THIS, SDL_Surface * surface) { if (surface == SDL_VideoSurface) { - SDL_mutexV (hw_lock); + SDL_mutexV(hw_lock); } } static int -VGL_FlipHWSurface (_THIS, SDL_Surface * surface) +VGL_FlipHWSurface(_THIS, SDL_Surface * surface) { // VGLWaitRetrace(); - if (VGLPanScreen (VGLDisplay, 0, flip_page * surface->h) < 0) { - SDL_SetError ("VGLPanSreen() failed"); + if (VGLPanScreen(VGLDisplay, 0, flip_page * surface->h) < 0) { + SDL_SetError("VGLPanSreen() failed"); return -1; } @@ -448,26 +448,26 @@ } static void -VGL_DirectUpdate (_THIS, int numrects, SDL_Rect * rects) +VGL_DirectUpdate(_THIS, int numrects, SDL_Rect * rects) { return; } static void -VGL_BankedUpdate (_THIS, int numrects, SDL_Rect * rects) +VGL_BankedUpdate(_THIS, int numrects, SDL_Rect * rects) { return; } int -VGL_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +VGL_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { int i; for (i = 0; i < ncolors; i++) { - VGLSetPaletteIndex (firstcolor + i, - colors[i].r >> 2, - colors[i].g >> 2, colors[i].b >> 2); + VGLSetPaletteIndex(firstcolor + i, + colors[i].r >> 2, + colors[i].g >> 2, colors[i].b >> 2); } return 1; } @@ -476,23 +476,23 @@ another SDL video routine -- notably UpdateRects. */ void -VGL_VideoQuit (_THIS) +VGL_VideoQuit(_THIS) { int i, j; /* Return the keyboard to the normal state */ - VGLKeyboardEnd (); + VGLKeyboardEnd(); /* Reset the console video mode if we actually initialised one */ if (VGLCurMode != NULL) { - VGLEnd (); - SDL_free (VGLCurMode); + VGLEnd(); + SDL_free(VGLCurMode); VGLCurMode = NULL; } /* Clear the lock mutex */ if (hw_lock != NULL) { - SDL_DestroyMutex (hw_lock); + SDL_DestroyMutex(hw_lock); hw_lock = NULL; } @@ -500,9 +500,9 @@ for (i = 0; i < NUM_MODELISTS; i++) { if (SDL_modelist[i] != NULL) { for (j = 0; SDL_modelist[i][j] != NULL; ++j) { - SDL_free (SDL_modelist[i][j]); + SDL_free(SDL_modelist[i][j]); } - SDL_free (SDL_modelist[i]); + SDL_free(SDL_modelist[i]); SDL_modelist[i] = NULL; } } @@ -518,7 +518,7 @@ #define VGL_BLUE_INDEX 2 static VGLMode ** -VGLListModes (int depth, int mem_model) +VGLListModes(int depth, int mem_model) { static VGLMode **modes = NULL; @@ -528,15 +528,15 @@ int adptype, i, modenum; if (modes == NULL) { - modes = SDL_malloc (sizeof (VGLMode *) * M_VESA_MODE_MAX); - bzero (modes, sizeof (VGLMode *) * M_VESA_MODE_MAX); + modes = SDL_malloc(sizeof(VGLMode *) * M_VESA_MODE_MAX); + bzero(modes, sizeof(VGLMode *) * M_VESA_MODE_MAX); } modesp = modes; for (modenum = 0; modenum < M_VESA_MODE_MAX; modenum++) { minfo.vi_mode = modenum; - if (ioctl (0, CONS_MODEINFO, &minfo) - || ioctl (0, CONS_CURRENT, &adptype)) + if (ioctl(0, CONS_MODEINFO, &minfo) + || ioctl(0, CONS_CURRENT, &adptype)) continue; if (minfo.vi_mode != modenum) continue; @@ -548,12 +548,12 @@ continue; /* reallocf can fail */ - if ((*modesp = reallocf (*modesp, sizeof (VGLMode))) == NULL) + if ((*modesp = reallocf(*modesp, sizeof(VGLMode))) == NULL) return NULL; modescp = *modesp; vminfop = &(modescp->ModeInfo); - bzero (vminfop, sizeof (VGLBitmap)); + bzero(vminfop, sizeof(VGLBitmap)); vminfop->Type = NOBUF; @@ -622,9 +622,9 @@ /* XXX */ if (minfo.vi_mode >= M_VESA_BASE) - modescp->ModeId = _IO ('V', minfo.vi_mode - M_VESA_BASE); + modescp->ModeId = _IO('V', minfo.vi_mode - M_VESA_BASE); else - modescp->ModeId = _IO ('S', minfo.vi_mode); + modescp->ModeId = _IO('S', minfo.vi_mode); /* Sort list */ for (i = 0; modes + i < modesp; i++) { @@ -645,7 +645,7 @@ } if (*modesp != NULL) { - SDL_free (*modesp); + SDL_free(*modesp); *modesp = NULL; } @@ -653,10 +653,10 @@ } static void -VGLWaitRetrace (void) +VGLWaitRetrace(void) { - while (!(inb (0x3DA) & 8)); - while (inb (0x3DA) & 8); + while (!(inb(0x3DA) & 8)); + while (inb(0x3DA) & 8); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/wincommon/SDL_lowvideo.h --- a/src/video/wincommon/SDL_lowvideo.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/wincommon/SDL_lowvideo.h Mon May 29 04:04:35 2006 +0000 @@ -79,7 +79,7 @@ /* Variables and functions exported to other parts of the native video subsystem (SDL_sysevents.c) */ -extern void WIN_FlushMessageQueue (); +extern void WIN_FlushMessageQueue(); /* Called by windows message loop when system palette is available */ extern void (*WIN_RealizePalette) (_THIS); @@ -91,8 +91,8 @@ extern void (*WIN_WinPAINT) (_THIS, HDC hdc); /* Called by windows message loop when the message isn't handled */ -extern LONG (*HandleMessage) (_THIS, HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam); +extern LONG(*HandleMessage) (_THIS, HWND hwnd, UINT msg, WPARAM wParam, + LPARAM lParam); /* The window cursor (from SDL_sysmouse.c) */ extern HCURSOR SDL_hcursor; @@ -120,12 +120,12 @@ extern WORD *gamma_saved; /* This is really from SDL_dx5audio.c */ -extern void DX5_SoundFocus (HWND window); +extern void DX5_SoundFocus(HWND window); /* DJM: This is really from SDL_sysevents.c, we need it in GDL_CreateWindow as well */ -LRESULT CALLBACK WinMessage (HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam); +LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, + LPARAM lParam); /* JFP: Implementation of ToUnicode() that works on 9x/ME/2K/XP */ typedef int (WINAPI * ToUnicodeFN) (UINT, UINT, PBYTE, LPWSTR, int, UINT); diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/wincommon/SDL_sysevents.c --- a/src/video/wincommon/SDL_sysevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/wincommon/SDL_sysevents.c Mon May 29 04:04:35 2006 +0000 @@ -72,20 +72,20 @@ /* Functions called by the message processing function */ -LONG (*HandleMessage) (_THIS, HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam) = NULL; +LONG(*HandleMessage) (_THIS, HWND hwnd, UINT msg, WPARAM wParam, + LPARAM lParam) = NULL; void (*WIN_RealizePalette) (_THIS); void (*WIN_PaletteChanged) (_THIS, HWND window); void (*WIN_WinPAINT) (_THIS, HDC hdc); -extern void DIB_SwapGamma (_THIS); +extern void DIB_SwapGamma(_THIS); #ifndef NO_GETKEYBOARDSTATE /* Variables and support functions for SDL_ToUnicode() */ static int codepage; -static int Is9xME (); -static int GetCodePage (); -static int WINAPI ToUnicode9xME (UINT vkey, UINT scancode, BYTE * keystate, - LPWSTR wchars, int wsize, UINT flags); +static int Is9xME(); +static int GetCodePage(); +static int WINAPI ToUnicode9xME(UINT vkey, UINT scancode, BYTE * keystate, + LPWSTR wchars, int wsize, UINT flags); ToUnicodeFN SDL_ToUnicode = ToUnicode9xME; #endif /* !NO_GETKEYBOARDSTATE */ @@ -95,7 +95,7 @@ // dynamically load aygshell dll because we want SDL to work on HPC and be300 HINSTANCE aygshell = NULL; -BOOL (WINAPI * SHFullScreen) (HWND hwndRequester, DWORD dwState) = 0; +BOOL(WINAPI * SHFullScreen) (HWND hwndRequester, DWORD dwState) = 0; #define SHFS_SHOWTASKBAR 0x0001 #define SHFS_HIDETASKBAR 0x0002 @@ -105,20 +105,20 @@ #define SHFS_HIDESTARTICON 0x0020 static void -LoadAygshell (void) +LoadAygshell(void) { if (!aygshell) - aygshell = SDL_LoadObject ("aygshell.dll"); + aygshell = SDL_LoadObject("aygshell.dll"); if ((aygshell != 0) && (SHFullScreen == 0)) { SHFullScreen = (int (WINAPI *) (struct HWND__ *, unsigned long)) - SDL_LoadFunction (aygshell, "SHFullScreen"); + SDL_LoadFunction(aygshell, "SHFullScreen"); } } /* for gapi landscape mode */ static void -GapiTransform (SDL_ScreenOrientation rotate, char hires, Sint16 * x, - Sint16 * y) +GapiTransform(SDL_ScreenOrientation rotate, char hires, Sint16 * x, + Sint16 * y) { Sint16 rotatedX; Sint16 rotatedY; @@ -181,56 +181,56 @@ about */ void -WIN_FlushMessageQueue () +WIN_FlushMessageQueue() { MSG msg; - while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) { + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) break; - TranslateMessage (&msg); - DispatchMessage (&msg); + TranslateMessage(&msg); + DispatchMessage(&msg); } } static void -SDL_RestoreGameMode (void) +SDL_RestoreGameMode(void) { #ifdef _WIN32_WCE SDL_VideoDevice *this = current_video; - if (SDL_strcmp (this->name, "gapi") == 0) { + if (SDL_strcmp(this->name, "gapi") == 0) { if (this->hidden->suspended) { this->hidden->suspended = 0; } } #else - ShowWindow (SDL_Window, SW_RESTORE); + ShowWindow(SDL_Window, SW_RESTORE); #endif #ifndef NO_CHANGEDISPLAYSETTINGS #ifndef _WIN32_WCE - ChangeDisplaySettings (&SDL_fullscreen_mode, CDS_FULLSCREEN); + ChangeDisplaySettings(&SDL_fullscreen_mode, CDS_FULLSCREEN); #endif #endif /* NO_CHANGEDISPLAYSETTINGS */ } static void -SDL_RestoreDesktopMode (void) +SDL_RestoreDesktopMode(void) { #ifdef _WIN32_WCE SDL_VideoDevice *this = current_video; - if (SDL_strcmp (this->name, "gapi") == 0) { + if (SDL_strcmp(this->name, "gapi") == 0) { if (!this->hidden->suspended) { this->hidden->suspended = 1; } } #else /* WinCE does not have a taskbar, so minimizing is not convenient */ - ShowWindow (SDL_Window, SW_MINIMIZE); + ShowWindow(SDL_Window, SW_MINIMIZE); #endif #ifndef NO_CHANGEDISPLAYSETTINGS #ifndef _WIN32_WCE - ChangeDisplaySettings (NULL, 0); + ChangeDisplaySettings(NULL, 0); #endif #endif /* NO_CHANGEDISPLAYSETTINGS */ } @@ -247,30 +247,30 @@ Therefore, we implement our own version of _TrackMouseEvent() which uses our own implementation if TrackMouseEvent() is not available. */ -static BOOL (WINAPI * _TrackMouseEvent) (TRACKMOUSEEVENT * ptme) = NULL; +static BOOL(WINAPI * _TrackMouseEvent) (TRACKMOUSEEVENT * ptme) = NULL; static VOID CALLBACK -TrackMouseTimerProc (HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime) +TrackMouseTimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime) { RECT rect; POINT pt; - GetClientRect (hWnd, &rect); - MapWindowPoints (hWnd, NULL, (LPPOINT) & rect, 2); - GetCursorPos (&pt); - if (!PtInRect (&rect, pt) || (WindowFromPoint (pt) != hWnd)) { - if (!KillTimer (hWnd, idEvent)) { + GetClientRect(hWnd, &rect); + MapWindowPoints(hWnd, NULL, (LPPOINT) & rect, 2); + GetCursorPos(&pt); + if (!PtInRect(&rect, pt) || (WindowFromPoint(pt) != hWnd)) { + if (!KillTimer(hWnd, idEvent)) { /* Error killing the timer! */ } - PostMessage (hWnd, WM_MOUSELEAVE, 0, 0); + PostMessage(hWnd, WM_MOUSELEAVE, 0, 0); } } static BOOL WINAPI -WIN_TrackMouseEvent (TRACKMOUSEEVENT * ptme) +WIN_TrackMouseEvent(TRACKMOUSEEVENT * ptme) { if (ptme->dwFlags == TME_LEAVE) { - return SetTimer (ptme->hwndTrack, ptme->dwFlags, 100, - (TIMERPROC) TrackMouseTimerProc) != 0; + return SetTimer(ptme->hwndTrack, ptme->dwFlags, 100, + (TIMERPROC) TrackMouseTimerProc) != 0; } return FALSE; } @@ -278,15 +278,15 @@ /* Function to retrieve the current keyboard modifiers */ static void -WIN_GetKeyboardState (void) +WIN_GetKeyboardState(void) { #ifndef NO_GETKEYBOARDSTATE SDLMod state; BYTE keyboard[256]; - Uint8 *kstate = SDL_GetKeyState (NULL); + Uint8 *kstate = SDL_GetKeyState(NULL); state = KMOD_NONE; - if (GetKeyboardState (keyboard)) { + if (GetKeyboardState(keyboard)) { if (keyboard[VK_LSHIFT] & 0x80) { state |= KMOD_LSHIFT; kstate[SDLK_LSHIFT] = SDL_PRESSED; @@ -320,7 +320,7 @@ kstate[SDLK_CAPSLOCK] = SDL_PRESSED; } } - SDL_SetModState (state); + SDL_SetModState(state); #endif /* !NO_GETKEYBOARDSTATE */ } @@ -328,19 +328,19 @@ DJM: This is no longer static as (DX5/DIB)_CreateWindow needs it */ LRESULT CALLBACK -WinMessage (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { SDL_VideoDevice *this = current_video; static int mouse_pressed = 0; static int in_window = 0; #ifdef WMMSG_DEBUG - fprintf (stderr, "Received windows message: "); + fprintf(stderr, "Received windows message: "); if (msg > MAX_WMMSG) { - fprintf (stderr, "%d", msg); + fprintf(stderr, "%d", msg); } else { - fprintf (stderr, "%s", wmtab[msg]); + fprintf(stderr, "%s", wmtab[msg]); } - fprintf (stderr, " -- 0x%X, 0x%X\n", wParam, lParam); + fprintf(stderr, " -- 0x%X, 0x%X\n", wParam, lParam); #endif switch (msg) { @@ -350,37 +350,37 @@ BOOL minimized; Uint8 appstate; - minimized = HIWORD (wParam); - if (!minimized && (LOWORD (wParam) != WA_INACTIVE)) { + minimized = HIWORD(wParam); + if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) { /* Gain the following states */ appstate = SDL_APPACTIVE | SDL_APPINPUTFOCUS; if (this->input_grab != SDL_GRAB_OFF) { - WIN_GrabInput (this, SDL_GRAB_ON); + WIN_GrabInput(this, SDL_GRAB_ON); } - if (!(SDL_GetAppState () & SDL_APPINPUTFOCUS)) { - if (!DDRAW_FULLSCREEN ()) { - DIB_SwapGamma (this); + if (!(SDL_GetAppState() & SDL_APPINPUTFOCUS)) { + if (!DDRAW_FULLSCREEN()) { + DIB_SwapGamma(this); } - if (WINDIB_FULLSCREEN ()) { - SDL_RestoreGameMode (); + if (WINDIB_FULLSCREEN()) { + SDL_RestoreGameMode(); } } #if defined(_WIN32_WCE) - if (WINDIB_FULLSCREEN ()) { - LoadAygshell (); + if (WINDIB_FULLSCREEN()) { + LoadAygshell(); if (SHFullScreen) - SHFullScreen (SDL_Window, - SHFS_HIDESTARTICON | - SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON); + SHFullScreen(SDL_Window, + SHFS_HIDESTARTICON | + SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON); else - ShowWindow (FindWindow - (TEXT ("HHTaskBar"), NULL), SW_HIDE); + ShowWindow(FindWindow + (TEXT("HHTaskBar"), NULL), SW_HIDE); } #endif - posted = SDL_PrivateAppActive (1, appstate); - WIN_GetKeyboardState (); + posted = SDL_PrivateAppActive(1, appstate); + WIN_GetKeyboardState(); } else { /* Lose the following states */ appstate = SDL_APPINPUTFOCUS; @@ -388,29 +388,29 @@ appstate |= SDL_APPACTIVE; } if (this->input_grab != SDL_GRAB_OFF) { - WIN_GrabInput (this, SDL_GRAB_OFF); + WIN_GrabInput(this, SDL_GRAB_OFF); } - if (SDL_GetAppState () & SDL_APPINPUTFOCUS) { - if (!DDRAW_FULLSCREEN ()) { - DIB_SwapGamma (this); + if (SDL_GetAppState() & SDL_APPINPUTFOCUS) { + if (!DDRAW_FULLSCREEN()) { + DIB_SwapGamma(this); } - if (WINDIB_FULLSCREEN ()) { - SDL_RestoreDesktopMode (); + if (WINDIB_FULLSCREEN()) { + SDL_RestoreDesktopMode(); #if defined(_WIN32_WCE) - LoadAygshell (); + LoadAygshell(); if (SHFullScreen) - SHFullScreen (SDL_Window, - SHFS_SHOWSTARTICON | - SHFS_SHOWTASKBAR | - SHFS_SHOWSIPBUTTON); + SHFullScreen(SDL_Window, + SHFS_SHOWSTARTICON | + SHFS_SHOWTASKBAR | + SHFS_SHOWSIPBUTTON); else - ShowWindow (FindWindow - (TEXT ("HHTaskBar"), NULL), SW_SHOW); + ShowWindow(FindWindow + (TEXT("HHTaskBar"), NULL), SW_SHOW); #endif } } - posted = SDL_PrivateAppActive (0, appstate); + posted = SDL_PrivateAppActive(0, appstate); } return (0); } @@ -420,7 +420,7 @@ { /* Mouse is handled by DirectInput when fullscreen */ - if (SDL_VideoSurface && !DINPUT_FULLSCREEN ()) { + if (SDL_VideoSurface && !DINPUT_FULLSCREEN()) { Sint16 x, y; /* mouse has entered the window */ @@ -428,19 +428,19 @@ #ifdef WM_MOUSELEAVE TRACKMOUSEEVENT tme; - tme.cbSize = sizeof (tme); + tme.cbSize = sizeof(tme); tme.dwFlags = TME_LEAVE; tme.hwndTrack = SDL_Window; - _TrackMouseEvent (&tme); + _TrackMouseEvent(&tme); #endif /* WM_MOUSELEAVE */ in_window = TRUE; - posted = SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); + posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); } /* mouse has moved within the window */ - x = LOWORD (lParam); - y = HIWORD (lParam); + x = LOWORD(lParam); + y = HIWORD(lParam); if (mouse_relative) { POINT center; center.x = (SDL_VideoSurface->w / 2); @@ -448,17 +448,17 @@ x -= (Sint16) center.x; y -= (Sint16) center.y; if (x || y) { - ClientToScreen (SDL_Window, ¢er); - SetCursorPos (center.x, center.y); - posted = SDL_PrivateMouseMotion (0, 1, x, y); + ClientToScreen(SDL_Window, ¢er); + SetCursorPos(center.x, center.y); + posted = SDL_PrivateMouseMotion(0, 1, x, y); } } else { #ifdef _WIN32_WCE if (SDL_VideoSurface) - GapiTransform (this->hidden->userOrientation, - this->hidden->hiresFix, &x, &y); + GapiTransform(this->hidden->userOrientation, + this->hidden->hiresFix, &x, &y); #endif - posted = SDL_PrivateMouseMotion (0, 0, x, y); + posted = SDL_PrivateMouseMotion(0, 0, x, y); } } } @@ -469,11 +469,11 @@ { /* Mouse is handled by DirectInput when fullscreen */ - if (SDL_VideoSurface && !DINPUT_FULLSCREEN ()) { + if (SDL_VideoSurface && !DINPUT_FULLSCREEN()) { /* mouse has left the window */ /* or */ /* Elvis has left the building! */ - posted = SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); + posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } in_window = FALSE; } @@ -488,7 +488,7 @@ case WM_RBUTTONUP: { /* Mouse is handled by DirectInput when fullscreen */ - if (SDL_VideoSurface && !DINPUT_FULLSCREEN ()) { + if (SDL_VideoSurface && !DINPUT_FULLSCREEN()) { Sint16 x, y; Uint8 button, state; @@ -497,7 +497,7 @@ it acts like a normal windows "component" (e.g. gains keyboard focus on a mouse click). */ - SetFocus (SDL_Window); + SetFocus(SDL_Window); /* Figure out which button to use */ switch (msg) { @@ -532,12 +532,12 @@ if (state == SDL_PRESSED) { /* Grab mouse so we get up events */ if (++mouse_pressed > 0) { - SetCapture (hwnd); + SetCapture(hwnd); } } else { /* Release mouse after all up events */ if (--mouse_pressed <= 0) { - ReleaseCapture (); + ReleaseCapture(); mouse_pressed = 0; } } @@ -547,15 +547,15 @@ x = 0; y = 0; } else { - x = (Sint16) LOWORD (lParam); - y = (Sint16) HIWORD (lParam); + x = (Sint16) LOWORD(lParam); + y = (Sint16) HIWORD(lParam); #ifdef _WIN32_WCE if (SDL_VideoSurface) - GapiTransform (this->hidden->userOrientation, - this->hidden->hiresFix, &x, &y); + GapiTransform(this->hidden->userOrientation, + this->hidden->hiresFix, &x, &y); #endif } - posted = SDL_PrivateMouseButton (state, button, x, y); + posted = SDL_PrivateMouseButton(state, button, x, y); } } return (0); @@ -563,16 +563,16 @@ #if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400) case WM_MOUSEWHEEL: - if (SDL_VideoSurface && !DINPUT_FULLSCREEN ()) { - int move = (short) HIWORD (wParam); + if (SDL_VideoSurface && !DINPUT_FULLSCREEN()) { + int move = (short) HIWORD(wParam); if (move) { Uint8 button; if (move > 0) button = SDL_BUTTON_WHEELUP; else button = SDL_BUTTON_WHEELDOWN; - posted = SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0); - posted |= SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0); + posted = SDL_PrivateMouseButton(SDL_PRESSED, button, 0, 0); + posted |= SDL_PrivateMouseButton(SDL_RELEASED, button, 0, 0); } } return (0); @@ -603,7 +603,7 @@ } /* Get the current position of our window */ - GetWindowRect (SDL_Window, &size); + GetWindowRect(SDL_Window, &size); x = size.left; y = size.top; @@ -623,11 +623,11 @@ Aparently it's too difficult for MS to check inside their function, so I have to do it here. */ - style = GetWindowLong (hwnd, GWL_STYLE); - AdjustWindowRect (&size, - style, - style & WS_CHILDWINDOW ? FALSE - : GetMenu (hwnd) != NULL); + style = GetWindowLong(hwnd, GWL_STYLE); + AdjustWindowRect(&size, + style, + style & WS_CHILDWINDOW ? FALSE + : GetMenu(hwnd) != NULL); width = size.right - size.left; height = size.bottom - size.top; @@ -651,10 +651,10 @@ SDL_VideoDevice *this = current_video; int w, h; - GetClientRect (SDL_Window, &SDL_bounds); - ClientToScreen (SDL_Window, (LPPOINT) & SDL_bounds); - ClientToScreen (SDL_Window, (LPPOINT) & SDL_bounds + 1); - if (!SDL_resizing && !IsZoomed (SDL_Window) && + GetClientRect(SDL_Window, &SDL_bounds); + ClientToScreen(SDL_Window, (LPPOINT) & SDL_bounds); + ClientToScreen(SDL_Window, (LPPOINT) & SDL_bounds + 1); + if (!SDL_resizing && !IsZoomed(SDL_Window) && SDL_PublicSurface && !(SDL_PublicSurface->flags & SDL_FULLSCREEN)) { SDL_windowX = SDL_bounds.left; @@ -663,11 +663,11 @@ w = SDL_bounds.right - SDL_bounds.left; h = SDL_bounds.bottom - SDL_bounds.top; if (this->input_grab != SDL_GRAB_OFF) { - ClipCursor (&SDL_bounds); + ClipCursor(&SDL_bounds); } if (SDL_PublicSurface && (SDL_PublicSurface->flags & SDL_RESIZABLE)) { - SDL_PrivateResize (w, h); + SDL_PrivateResize(w, h); } } break; @@ -677,9 +677,9 @@ { Uint16 hittest; - hittest = LOWORD (lParam); + hittest = LOWORD(lParam); if (hittest == HTCLIENT) { - SetCursor (SDL_hcursor); + SetCursor(SDL_hcursor); return (TRUE); } } @@ -688,7 +688,7 @@ /* We are about to get palette focus! */ case WM_QUERYNEWPALETTE: { - WIN_RealizePalette (current_video); + WIN_RealizePalette(current_video); return (TRUE); } break; @@ -696,7 +696,7 @@ /* Another application changed the palette */ case WM_PALETTECHANGED: { - WIN_PaletteChanged (current_video, (HWND) wParam); + WIN_PaletteChanged(current_video, (HWND) wParam); } break; @@ -706,39 +706,39 @@ HDC hdc; PAINTSTRUCT ps; - hdc = BeginPaint (SDL_Window, &ps); + hdc = BeginPaint(SDL_Window, &ps); if (current_video->screen && !(current_video->screen->flags & SDL_INTERNALOPENGL)) { - WIN_WinPAINT (current_video, hdc); + WIN_WinPAINT(current_video, hdc); } - EndPaint (SDL_Window, &ps); + EndPaint(SDL_Window, &ps); } return (0); /* DJM: Send an expose event in this case */ case WM_ERASEBKGND: { - posted = SDL_PrivateExpose (); + posted = SDL_PrivateExpose(); } return (0); case WM_CLOSE: { - if ((posted = SDL_PrivateQuit ())) - PostQuitMessage (0); + if ((posted = SDL_PrivateQuit())) + PostQuitMessage(0); } return (0); case WM_DESTROY: { - PostQuitMessage (0); + PostQuitMessage(0); } return (0); #ifndef NO_GETKEYBOARDSTATE case WM_INPUTLANGCHANGE: { - codepage = GetCodePage (); + codepage = GetCodePage(); } return (TRUE); #endif @@ -747,33 +747,33 @@ { /* Special handling by the video driver */ if (HandleMessage) { - return (HandleMessage (current_video, - hwnd, msg, wParam, lParam)); + return (HandleMessage(current_video, + hwnd, msg, wParam, lParam)); } } break; } - return (DefWindowProc (hwnd, msg, wParam, lParam)); + return (DefWindowProc(hwnd, msg, wParam, lParam)); } /* Allow the application handle to be stored and retrieved later */ static void *SDL_handle = NULL; void -SDL_SetModuleHandle (void *handle) +SDL_SetModuleHandle(void *handle) { SDL_handle = handle; } void * -SDL_GetModuleHandle (void) +SDL_GetModuleHandle(void) { void *handle; if (SDL_handle) { handle = SDL_handle; } else { - handle = GetModuleHandle (NULL); + handle = GetModuleHandle(NULL); } return (handle); } @@ -785,7 +785,7 @@ /* Register the class for this application -- exported for winmain.c */ int -SDL_RegisterApp (char *name, Uint32 style, void *hInst) +SDL_RegisterApp(char *name, Uint32 style, void *hInst) { WNDCLASS class; #ifdef WM_MOUSELEAVE @@ -803,24 +803,24 @@ if (!name && !SDL_Appname) { name = "SDL_app"; SDL_Appstyle = CS_BYTEALIGNCLIENT; - SDL_Instance = hInst ? hInst : SDL_GetModuleHandle (); + SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); } if (name) { #ifdef _WIN32_WCE /* WinCE uses the UNICODE version */ - SDL_Appname = SDL_iconv_utf8_ucs2 (name); + SDL_Appname = SDL_iconv_utf8_ucs2(name); #else - SDL_Appname = SDL_iconv_utf8_latin1 (name); + SDL_Appname = SDL_iconv_utf8_latin1(name); #endif /* _WIN32_WCE */ SDL_Appstyle = style; - SDL_Instance = hInst ? hInst : SDL_GetModuleHandle (); + SDL_Instance = hInst ? hInst : SDL_GetModuleHandle(); } /* Register the application class */ class.hCursor = NULL; - class.hIcon = LoadImage (SDL_Instance, SDL_Appname, - IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); + class.hIcon = LoadImage(SDL_Instance, SDL_Appname, + IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); class.lpszMenuName = NULL; class.lpszClassName = SDL_Appname; class.hbrBackground = NULL; @@ -832,18 +832,18 @@ class.lpfnWndProc = WinMessage; class.cbWndExtra = 0; class.cbClsExtra = 0; - if (!RegisterClass (&class)) { - SDL_SetError ("Couldn't register application class"); + if (!RegisterClass(&class)) { + SDL_SetError("Couldn't register application class"); return (-1); } #ifdef WM_MOUSELEAVE /* Get the version of TrackMouseEvent() we use */ _TrackMouseEvent = NULL; - handle = GetModuleHandle ("USER32.DLL"); + handle = GetModuleHandle("USER32.DLL"); if (handle) { _TrackMouseEvent = - (BOOL (WINAPI *) (TRACKMOUSEEVENT *)) GetProcAddress (handle, - "TrackMouseEvent"); + (BOOL(WINAPI *) (TRACKMOUSEEVENT *)) GetProcAddress(handle, + "TrackMouseEvent"); } if (_TrackMouseEvent == NULL) { _TrackMouseEvent = WIN_TrackMouseEvent; @@ -852,8 +852,8 @@ #ifndef NO_GETKEYBOARDSTATE /* Initialise variables for SDL_ToUnicode() */ - codepage = GetCodePage (); - SDL_ToUnicode = Is9xME ()? ToUnicode9xME : ToUnicode; + codepage = GetCodePage(); + SDL_ToUnicode = Is9xME()? ToUnicode9xME : ToUnicode; #endif app_registered = 1; @@ -862,7 +862,7 @@ /* Unregisters the windowclass registered in SDL_RegisterApp above. */ void -SDL_UnregisterApp () +SDL_UnregisterApp() { WNDCLASS class; @@ -873,10 +873,10 @@ --app_registered; if (app_registered == 0) { /* Check for any registered window classes. */ - if (GetClassInfo (SDL_Instance, SDL_Appname, &class)) { - UnregisterClass (SDL_Appname, SDL_Instance); + if (GetClassInfo(SDL_Instance, SDL_Appname, &class)) { + UnregisterClass(SDL_Appname, SDL_Instance); } - SDL_free (SDL_Appname); + SDL_free(SDL_Appname); SDL_Appname = NULL; } } @@ -885,42 +885,41 @@ /* JFP: Implementation of ToUnicode() that works on 9x/ME/2K/XP */ static int -Is9xME () +Is9xME() { OSVERSIONINFO info; - SDL_memset (&info, 0, sizeof (info)); - info.dwOSVersionInfoSize = sizeof (info); - if (!GetVersionEx (&info)) { + SDL_memset(&info, 0, sizeof(info)); + info.dwOSVersionInfoSize = sizeof(info); + if (!GetVersionEx(&info)) { return 0; } return (info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); } static int -GetCodePage () +GetCodePage() { char buff[8]; - int lcid = MAKELCID (LOWORD (GetKeyboardLayout (0)), SORT_DEFAULT); - int cp = GetACP (); + int lcid = MAKELCID(LOWORD(GetKeyboardLayout(0)), SORT_DEFAULT); + int cp = GetACP(); - if (GetLocaleInfo - (lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof (buff))) { - cp = SDL_atoi (buff); + if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buff, sizeof(buff))) { + cp = SDL_atoi(buff); } return cp; } static int WINAPI -ToUnicode9xME (UINT vkey, UINT scancode, PBYTE keystate, LPWSTR wchars, - int wsize, UINT flags) +ToUnicode9xME(UINT vkey, UINT scancode, PBYTE keystate, LPWSTR wchars, + int wsize, UINT flags) { BYTE chars[2]; if (ToAsciiEx (vkey, scancode, keystate, (WORD *) chars, 0, - GetKeyboardLayout (0)) == 1) { - return MultiByteToWideChar (codepage, 0, chars, 1, wchars, wsize); + GetKeyboardLayout(0)) == 1) { + return MultiByteToWideChar(codepage, 0, chars, 1, wchars, wsize); } return 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/wincommon/SDL_sysmouse.c --- a/src/video/wincommon/SDL_sysmouse.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/wincommon/SDL_sysmouse.c Mon May 29 04:04:35 2006 +0000 @@ -55,7 +55,7 @@ #ifdef CURSOR_DEBUG static void -PrintBITMAP (FILE * out, char *bits, int w, int h) +PrintBITMAP(FILE * out, char *bits, int w, int h) { int i; unsigned char ch; @@ -65,12 +65,12 @@ if ((i % 8) == 0) ch = *bits++; if (ch & 0x80) - fprintf (out, "X"); + fprintf(out, "X"); else - fprintf (out, " "); + fprintf(out, " "); ch <<= 1; } - fprintf (out, "\n"); + fprintf(out, "\n"); } } #endif @@ -78,13 +78,13 @@ #ifndef USE_STATIC_CURSOR /* Local functions to convert the SDL cursor mask into Windows format */ static void -memnot (Uint8 * dst, Uint8 * src, int len) +memnot(Uint8 * dst, Uint8 * src, int len) { while (len-- > 0) *dst++ = ~*src++; } static void -memxor (Uint8 * dst, Uint8 * src1, Uint8 * src2, int len) +memxor(Uint8 * dst, Uint8 * src1, Uint8 * src2, int len) { while (len-- > 0) *dst++ = (*src1++) ^ (*src2++); @@ -92,33 +92,33 @@ #endif /* !USE_STATIC_CURSOR */ void -WIN_FreeWMCursor (_THIS, WMcursor * cursor) +WIN_FreeWMCursor(_THIS, WMcursor * cursor) { #ifndef USE_STATIC_CURSOR - if (cursor->curs == GetCursor ()) - SetCursor (NULL); + if (cursor->curs == GetCursor()) + SetCursor(NULL); if (cursor->curs != NULL) - DestroyCursor (cursor->curs); + DestroyCursor(cursor->curs); if (cursor->ands != NULL) - SDL_free (cursor->ands); + SDL_free(cursor->ands); if (cursor->xors != NULL) - SDL_free (cursor->xors); + SDL_free(cursor->xors); #endif /* !USE_STATIC_CURSOR */ - SDL_free (cursor); + SDL_free(cursor); } WMcursor * -WIN_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, int hot_x, - int hot_y) +WIN_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, int hot_x, + int hot_y) { #ifdef USE_STATIC_CURSOR WMcursor *cursor; /* Allocate the cursor */ - cursor = (WMcursor *) SDL_malloc (sizeof (*cursor)); + cursor = (WMcursor *) SDL_malloc(sizeof(*cursor)); if (cursor) { - cursor->curs = LoadCursor (NULL, IDC_ARROW); + cursor->curs = LoadCursor(NULL, IDC_ARROW); } return (cursor); #else @@ -129,18 +129,18 @@ Uint8 *aptr, *xptr; /* Check to make sure the cursor size is okay */ - allowed_x = GetSystemMetrics (SM_CXCURSOR); - allowed_y = GetSystemMetrics (SM_CYCURSOR); + allowed_x = GetSystemMetrics(SM_CXCURSOR); + allowed_y = GetSystemMetrics(SM_CYCURSOR); if ((w > allowed_x) || (h > allowed_y)) { - SDL_SetError ("Only cursors of dimension (%dx%d) are allowed", - allowed_x, allowed_y); + SDL_SetError("Only cursors of dimension (%dx%d) are allowed", + allowed_x, allowed_y); return (NULL); } /* Allocate the cursor */ - cursor = (WMcursor *) SDL_malloc (sizeof (*cursor)); + cursor = (WMcursor *) SDL_malloc(sizeof(*cursor)); if (cursor == NULL) { - SDL_SetError ("Out of memory"); + SDL_SetError("Out of memory"); return (NULL); } cursor->curs = NULL; @@ -148,44 +148,44 @@ cursor->xors = NULL; /* Pad out to the normal cursor size */ - run = PAD_BITS (w); - pad = PAD_BITS (allowed_x) - run; - aptr = cursor->ands = (Uint8 *) SDL_malloc ((run + pad) * allowed_y); - xptr = cursor->xors = (Uint8 *) SDL_malloc ((run + pad) * allowed_y); + run = PAD_BITS(w); + pad = PAD_BITS(allowed_x) - run; + aptr = cursor->ands = (Uint8 *) SDL_malloc((run + pad) * allowed_y); + xptr = cursor->xors = (Uint8 *) SDL_malloc((run + pad) * allowed_y); if ((aptr == NULL) || (xptr == NULL)) { - WIN_FreeWMCursor (NULL, cursor); - SDL_OutOfMemory (); + WIN_FreeWMCursor(NULL, cursor); + SDL_OutOfMemory(); return (NULL); } for (i = 0; i < h; ++i) { - memxor (xptr, data, mask, run); + memxor(xptr, data, mask, run); xptr += run; data += run; - memnot (aptr, mask, run); + memnot(aptr, mask, run); mask += run; aptr += run; - SDL_memset (xptr, 0, pad); + SDL_memset(xptr, 0, pad); xptr += pad; - SDL_memset (aptr, ~0, pad); + SDL_memset(aptr, ~0, pad); aptr += pad; } pad += run; for (; i < allowed_y; ++i) { - SDL_memset (xptr, 0, pad); + SDL_memset(xptr, 0, pad); xptr += pad; - SDL_memset (aptr, ~0, pad); + SDL_memset(aptr, ~0, pad); aptr += pad; } /* Create the cursor */ - cursor->curs = CreateCursor ((HINSTANCE) - GetWindowLongPtr (SDL_Window, - GWLP_HINSTANCE), hot_x, - hot_y, allowed_x, allowed_y, cursor->ands, - cursor->xors); + cursor->curs = CreateCursor((HINSTANCE) + GetWindowLongPtr(SDL_Window, + GWLP_HINSTANCE), hot_x, + hot_y, allowed_x, allowed_y, cursor->ands, + cursor->xors); if (cursor->curs == NULL) { - WIN_FreeWMCursor (NULL, cursor); - SDL_SetError ("Windows couldn't create the requested cursor"); + WIN_FreeWMCursor(NULL, cursor); + SDL_SetError("Windows couldn't create the requested cursor"); return (NULL); } return (cursor); @@ -193,12 +193,12 @@ } int -WIN_ShowWMCursor (_THIS, WMcursor * cursor) +WIN_ShowWMCursor(_THIS, WMcursor * cursor) { POINT mouse_pos; /* The fullscreen cursor must be done in software with DirectInput */ - if (!this->screen || DDRAW_FULLSCREEN ()) { + if (!this->screen || DDRAW_FULLSCREEN()) { return (0); } @@ -208,55 +208,55 @@ } else { SDL_hcursor = NULL; } - GetCursorPos (&mouse_pos); - if (PtInRect (&SDL_bounds, mouse_pos)) { - SetCursor (SDL_hcursor); + GetCursorPos(&mouse_pos); + if (PtInRect(&SDL_bounds, mouse_pos)) { + SetCursor(SDL_hcursor); } return (1); } void -WIN_WarpWMCursor (_THIS, Uint16 x, Uint16 y) +WIN_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { - if (DDRAW_FULLSCREEN ()) { - SDL_PrivateMouseMotion (0, 0, x, y); + if (DDRAW_FULLSCREEN()) { + SDL_PrivateMouseMotion(0, 0, x, y); } else if (mouse_relative) { /* RJR: March 28, 2000 leave physical cursor at center of screen if mouse hidden and grabbed */ - SDL_PrivateMouseMotion (0, 0, x, y); + SDL_PrivateMouseMotion(0, 0, x, y); } else { POINT pt; pt.x = x; pt.y = y; - ClientToScreen (SDL_Window, &pt); - SetCursorPos (pt.x, pt.y); + ClientToScreen(SDL_Window, &pt); + SetCursorPos(pt.x, pt.y); } } /* Update the current mouse state and position */ void -WIN_UpdateMouse (_THIS) +WIN_UpdateMouse(_THIS) { RECT rect; POINT pt; - if (!DDRAW_FULLSCREEN ()) { - GetClientRect (SDL_Window, &rect); - GetCursorPos (&pt); - MapWindowPoints (NULL, SDL_Window, &pt, 1); - if (PtInRect (&rect, pt) && (WindowFromPoint (pt) == SDL_Window)) { - SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); - SDL_PrivateMouseMotion (0, 0, (Sint16) pt.x, (Sint16) pt.y); + if (!DDRAW_FULLSCREEN()) { + GetClientRect(SDL_Window, &rect); + GetCursorPos(&pt); + MapWindowPoints(NULL, SDL_Window, &pt, 1); + if (PtInRect(&rect, pt) && (WindowFromPoint(pt) == SDL_Window)) { + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); + SDL_PrivateMouseMotion(0, 0, (Sint16) pt.x, (Sint16) pt.y); } else { - SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } } } /* Check to see if we need to enter or leave mouse relative mode */ void -WIN_CheckMouseMode (_THIS) +WIN_CheckMouseMode(_THIS) { #ifndef _WIN32_WCE /* If the mouse is hidden and input is grabbed, we use relative mode */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/wincommon/SDL_sysmouse_c.h --- a/src/video/wincommon/SDL_sysmouse_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/wincommon/SDL_sysmouse_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,12 +24,12 @@ #include "SDL_lowvideo.h" /* Functions to be exported */ -extern void WIN_FreeWMCursor (_THIS, WMcursor * cursor); -extern WMcursor *WIN_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, - int hot_x, int hot_y); -extern int WIN_ShowWMCursor (_THIS, WMcursor * cursor); -extern void WIN_WarpWMCursor (_THIS, Uint16 x, Uint16 y); -extern void WIN_UpdateMouse (_THIS); -extern void WIN_CheckMouseMode (_THIS); +extern void WIN_FreeWMCursor(_THIS, WMcursor * cursor); +extern WMcursor *WIN_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, + int hot_x, int hot_y); +extern int WIN_ShowWMCursor(_THIS, WMcursor * cursor); +extern void WIN_WarpWMCursor(_THIS, Uint16 x, Uint16 y); +extern void WIN_UpdateMouse(_THIS); +extern void WIN_CheckMouseMode(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/wincommon/SDL_syswm.c --- a/src/video/wincommon/SDL_syswm.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/wincommon/SDL_syswm.c Mon May 29 04:04:35 2006 +0000 @@ -43,20 +43,20 @@ #ifdef _WIN32_WCE -BOOL (WINAPI * CoreCatchInput) (int flag) = NULL; +BOOL(WINAPI * CoreCatchInput) (int flag) = NULL; int input_catched = 0; HINSTANCE coredll = NULL; // the same API call that gx.dll does to catch the input void -LoadInputCatchFunc () +LoadInputCatchFunc() { - coredll = SDL_LoadObject ("coredll.dll"); + coredll = SDL_LoadObject("coredll.dll"); if (coredll) { CoreCatchInput = - (int (WINAPI *) (int)) GetProcAddress (coredll, - (const unsigned short *) - 1453); + (int (WINAPI *) (int)) GetProcAddress(coredll, + (const unsigned short *) + 1453); } } @@ -70,7 +70,7 @@ then inverted and passed to Win32. */ void -WIN_SetWMIcon (_THIS, SDL_Surface * icon, Uint8 * mask) +WIN_SetWMIcon(_THIS, SDL_Surface * icon, Uint8 * mask) { #ifdef DISABLE_ICON_SUPPORT return; @@ -120,15 +120,15 @@ mask_pitch = ((icon->w + 7) / 8); icon_plen = icon->h * icon_pitch; icon_mlen = icon->h * mask_pitch; - icon_len = sizeof (*icon_win32) + icon_plen + icon_mlen; - icon_win32 = (struct Win32Icon *) SDL_stack_alloc (Uint8, icon_len); + icon_len = sizeof(*icon_win32) + icon_plen + icon_mlen; + icon_win32 = (struct Win32Icon *) SDL_stack_alloc(Uint8, icon_len); if (icon_win32 == NULL) { return; } - SDL_memset (icon_win32, 0, icon_len); + SDL_memset(icon_win32, 0, icon_len); /* Set the basic BMP parameters */ - icon_win32->biSize = sizeof (*icon_win32) - sizeof (icon_win32->biColors); + icon_win32->biSize = sizeof(*icon_win32) - sizeof(icon_win32->biColors); icon_win32->biWidth = icon->w; icon_win32->biHeight = icon->h * 2; icon_win32->biPlanes = 1; @@ -136,26 +136,26 @@ icon_win32->biSizeImage = icon_plen + icon_mlen; /* Allocate a standard 256 color icon surface */ - icon_256 = SDL_CreateRGBSurface (SDL_SWSURFACE, icon->w, icon->h, - icon_win32->biBitCount, 0, 0, 0, 0); + icon_256 = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h, + icon_win32->biBitCount, 0, 0, 0, 0); if (icon_256 == NULL) { - SDL_stack_free (icon_win32); + SDL_stack_free(icon_win32); return; } pal_256 = icon_256->format->palette; if (icon->format->palette && (icon->format->BitsPerPixel == icon_256->format->BitsPerPixel)) { Uint8 black; - SDL_memcpy (pal_256->colors, icon->format->palette->colors, - pal_256->ncolors * sizeof (SDL_Color)); + SDL_memcpy(pal_256->colors, icon->format->palette->colors, + pal_256->ncolors * sizeof(SDL_Color)); /* Make sure that 0 is black! */ - black = SDL_FindColor (pal_256, 0x00, 0x00, 0x00); + black = SDL_FindColor(pal_256, 0x00, 0x00, 0x00); pal_256->colors[black] = pal_256->colors[0]; pal_256->colors[0].r = 0x00; pal_256->colors[0].g = 0x00; pal_256->colors[0].b = 0x00; } else { - SDL_DitherColors (pal_256->colors, icon_256->format->BitsPerPixel); + SDL_DitherColors(pal_256->colors, icon_256->format->BitsPerPixel); } /* Now copy color data to the icon BMP */ @@ -173,23 +173,23 @@ bounds.y = 0; bounds.w = icon->w; bounds.h = icon->h; - if (SDL_LowerBlit (icon, &bounds, icon_256, &bounds) < 0) { - SDL_stack_free (icon_win32); - SDL_FreeSurface (icon_256); + if (SDL_LowerBlit(icon, &bounds, icon_256, &bounds) < 0) { + SDL_stack_free(icon_win32); + SDL_FreeSurface(icon_256); return; } /* Copy pixels upside-down to icon BMP, masked with the icon mask */ - if (SDL_MUSTLOCK (icon_256) || (icon_256->pitch != icon_pitch)) { - SDL_stack_free (icon_win32); - SDL_FreeSurface (icon_256); - SDL_SetError ("Warning: Unexpected icon_256 characteristics"); + if (SDL_MUSTLOCK(icon_256) || (icon_256->pitch != icon_pitch)) { + SDL_stack_free(icon_win32); + SDL_FreeSurface(icon_256); + SDL_SetError("Warning: Unexpected icon_256 characteristics"); return; } pdata = (Uint8 *) icon_256->pixels; mdata = mask; pwin32 = - (Uint8 *) icon_win32 + sizeof (*icon_win32) + icon_plen - icon_pitch; + (Uint8 *) icon_win32 + sizeof(*icon_win32) + icon_plen - icon_pitch; skip = icon_pitch - icon->w; for (row = 0; row < icon->h; ++row) { for (col = 0; col < icon->w; ++col) { @@ -207,12 +207,12 @@ pwin32 += skip; pwin32 -= 2 * icon_pitch; } - SDL_FreeSurface (icon_256); + SDL_FreeSurface(icon_256); /* Copy mask inverted and upside-down to icon BMP */ mdata = mask; mwin32 = (Uint8 *) icon_win32 - + sizeof (*icon_win32) + icon_plen + icon_mlen - mask_pitch; + + sizeof(*icon_win32) + icon_plen + icon_mlen - mask_pitch; for (row = 0; row < icon->h; ++row) { for (col = 0; col < mask_pitch; ++col) { *mwin32++ = ~*mdata++; @@ -221,68 +221,68 @@ } /* Finally, create the icon handle and set the window icon */ - screen_icn = CreateIconFromResourceEx ((Uint8 *) icon_win32, icon_len, - TRUE, 0x00030000, icon->w, icon->h, - LR_DEFAULTCOLOR); + screen_icn = CreateIconFromResourceEx((Uint8 *) icon_win32, icon_len, + TRUE, 0x00030000, icon->w, icon->h, + LR_DEFAULTCOLOR); if (screen_icn == NULL) { - SDL_SetError ("Couldn't create Win32 icon handle"); + SDL_SetError("Couldn't create Win32 icon handle"); } else { - SetClassLongPtr (SDL_Window, GCLP_HICON, (LONG_PTR) screen_icn); + SetClassLongPtr(SDL_Window, GCLP_HICON, (LONG_PTR) screen_icn); } - SDL_stack_free (icon_win32); + SDL_stack_free(icon_win32); #endif /* DISABLE_ICON_SUPPORT */ } void -WIN_SetWMCaption (_THIS, const char *title, const char *icon) +WIN_SetWMCaption(_THIS, const char *title, const char *icon) { #ifdef _WIN32_WCE /* WinCE uses the UNICODE version */ - LPWSTR lpszW = SDL_iconv_utf8_ucs2 ((char *) title); - SetWindowText (SDL_Window, lpszW); - SDL_free (lpszW); + LPWSTR lpszW = SDL_iconv_utf8_ucs2((char *) title); + SetWindowText(SDL_Window, lpszW); + SDL_free(lpszW); #else - char *lpsz = SDL_iconv_utf8_latin1 ((char *) title); - SetWindowText (SDL_Window, lpsz); - SDL_free (lpsz); + char *lpsz = SDL_iconv_utf8_latin1((char *) title); + SetWindowText(SDL_Window, lpsz); + SDL_free(lpsz); #endif } int -WIN_IconifyWindow (_THIS) +WIN_IconifyWindow(_THIS) { - ShowWindow (SDL_Window, SW_MINIMIZE); + ShowWindow(SDL_Window, SW_MINIMIZE); return (1); } SDL_GrabMode -WIN_GrabInput (_THIS, SDL_GrabMode mode) +WIN_GrabInput(_THIS, SDL_GrabMode mode) { if (mode == SDL_GRAB_OFF) { - ClipCursor (NULL); + ClipCursor(NULL); if (!(SDL_cursorstate & CURSOR_VISIBLE)) { /* RJR: March 28, 2000 must be leaving relative mode, move mouse from center of window to where it belongs ... */ POINT pt; int x, y; - SDL_GetMouseState (&x, &y); + SDL_GetMouseState(&x, &y); pt.x = x; pt.y = y; - ClientToScreen (SDL_Window, &pt); - SetCursorPos (pt.x, pt.y); + ClientToScreen(SDL_Window, &pt); + SetCursorPos(pt.x, pt.y); } #ifdef _WIN32_WCE if (input_catched) { if (!CoreCatchInput) - LoadInputCatchFunc (); + LoadInputCatchFunc(); if (CoreCatchInput) - CoreCatchInput (0); + CoreCatchInput(0); } #endif } else { - ClipCursor (&SDL_bounds); + ClipCursor(&SDL_bounds); if (!(SDL_cursorstate & CURSOR_VISIBLE)) { /* RJR: March 28, 2000 must be entering relative mode, get ready by @@ -290,16 +290,16 @@ POINT pt; pt.x = (SDL_VideoSurface->w / 2); pt.y = (SDL_VideoSurface->h / 2); - ClientToScreen (SDL_Window, &pt); - SetCursorPos (pt.x, pt.y); + ClientToScreen(SDL_Window, &pt); + SetCursorPos(pt.x, pt.y); } #ifdef _WIN32_WCE if (!input_catched) { if (!CoreCatchInput) - LoadInputCatchFunc (); + LoadInputCatchFunc(); if (CoreCatchInput) - CoreCatchInput (1); + CoreCatchInput(1); } #endif } @@ -310,14 +310,13 @@ Otherwise, in case of a version mismatch, it returns -1. */ int -WIN_GetWMInfo (_THIS, SDL_SysWMinfo * info) +WIN_GetWMInfo(_THIS, SDL_SysWMinfo * info) { if (info->version.major <= SDL_MAJOR_VERSION) { info->window = SDL_Window; - if (SDL_VERSIONNUM (info->version.major, - info->version.minor, - info->version.patch) >= - SDL_VERSIONNUM (1, 2, 5)) { + if (SDL_VERSIONNUM(info->version.major, + info->version.minor, + info->version.patch) >= SDL_VERSIONNUM(1, 2, 5)) { #if SDL_VIDEO_OPENGL info->hglrc = GL_hrc; #else @@ -326,8 +325,8 @@ } return (1); } else { - SDL_SetError ("Application not compiled with SDL %d.%d\n", - SDL_MAJOR_VERSION, SDL_MINOR_VERSION); + SDL_SetError("Application not compiled with SDL %d.%d\n", + SDL_MAJOR_VERSION, SDL_MINOR_VERSION); return (-1); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/wincommon/SDL_syswm_c.h --- a/src/video/wincommon/SDL_syswm_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/wincommon/SDL_syswm_c.h Mon May 29 04:04:35 2006 +0000 @@ -27,9 +27,9 @@ extern HICON screen_icn; /* Functions to be exported */ -extern void WIN_SetWMIcon (_THIS, SDL_Surface * icon, Uint8 * mask); -extern void WIN_SetWMCaption (_THIS, const char *title, const char *icon); -extern int WIN_IconifyWindow (_THIS); -extern SDL_GrabMode WIN_GrabInput (_THIS, SDL_GrabMode mode); -extern int WIN_GetWMInfo (_THIS, SDL_SysWMinfo * info); +extern void WIN_SetWMIcon(_THIS, SDL_Surface * icon, Uint8 * mask); +extern void WIN_SetWMCaption(_THIS, const char *title, const char *icon); +extern int WIN_IconifyWindow(_THIS); +extern SDL_GrabMode WIN_GrabInput(_THIS, SDL_GrabMode mode); +extern int WIN_GetWMInfo(_THIS, SDL_SysWMinfo * info); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/wincommon/SDL_wingl.c --- a/src/video/wincommon/SDL_wingl.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/wincommon/SDL_wingl.c Mon May 29 04:04:35 2006 +0000 @@ -35,40 +35,40 @@ /* If setting the HDC fails, we may need to recreate the window (MSDN) */ static int -WIN_GL_ResetWindow (_THIS) +WIN_GL_ResetWindow(_THIS) { int status = 0; #ifndef _WIN32_WCE /* FIXME WinCE needs the UNICODE version of CreateWindow() */ /* This doesn't work with DirectX code (see CVS comments) */ /* If we were passed a window, then we can't create a new one */ - if (!SDL_windowid && SDL_strcmp (this->name, "windib") == 0) { + if (!SDL_windowid && SDL_strcmp(this->name, "windib") == 0) { /* Save the existing window attributes */ LONG style; RECT rect = { 0, 0, 0, 0 }; - style = GetWindowLong (SDL_Window, GWL_STYLE); - GetWindowRect (SDL_Window, &rect); - DestroyWindow (SDL_Window); - WIN_FlushMessageQueue (); + style = GetWindowLong(SDL_Window, GWL_STYLE); + GetWindowRect(SDL_Window, &rect); + DestroyWindow(SDL_Window); + WIN_FlushMessageQueue(); - SDL_Window = CreateWindow (SDL_Appname, SDL_Appname, - style, - rect.left, rect.top, - (rect.right - rect.left) + 1, - (rect.top - rect.bottom) + 1, - NULL, NULL, SDL_Instance, NULL); - WIN_FlushMessageQueue (); + SDL_Window = CreateWindow(SDL_Appname, SDL_Appname, + style, + rect.left, rect.top, + (rect.right - rect.left) + 1, + (rect.top - rect.bottom) + 1, + NULL, NULL, SDL_Instance, NULL); + WIN_FlushMessageQueue(); if (SDL_Window) { - this->SetCaption (this, this->wm_title, this->wm_icon); + this->SetCaption(this, this->wm_title, this->wm_icon); } else { - SDL_SetError ("Couldn't create window"); + SDL_SetError("Couldn't create window"); status = -1; } } else #endif /* !_WIN32_WCE */ { - SDL_SetError ("Unable to reset window for OpenGL context"); + SDL_SetError("Unable to reset window for OpenGL context"); status = -1; } return (status); @@ -77,13 +77,13 @@ #if SDL_VIDEO_OPENGL static int -ExtensionSupported (const char *extension, const char *extensions) +ExtensionSupported(const char *extension, const char *extensions) { const char *start; const char *where, *terminator; /* Extension names should not have spaces. */ - where = SDL_strchr (extension, ' '); + where = SDL_strchr(extension, ' '); if (where || *extension == '\0') return 0; @@ -97,11 +97,11 @@ start = extensions; for (;;) { - where = SDL_strstr (start, extension); + where = SDL_strstr(start, extension); if (!where) break; - terminator = where + SDL_strlen (extension); + terminator = where + SDL_strlen(extension); if (where == start || *(where - 1) == ' ') if (*terminator == ' ' || *terminator == '\0') return 1; @@ -113,7 +113,7 @@ } static void -Init_WGL_ARB_extensions (_THIS) +Init_WGL_ARB_extensions(_THIS) { HWND hwnd; HDC hdc; @@ -122,39 +122,39 @@ const char *(WINAPI * wglGetExtensionsStringARB) (HDC) = 0; const char *extensions; - hwnd = CreateWindow (SDL_Appname, SDL_Appname, WS_POPUP | WS_DISABLED, - 0, 0, 10, 10, NULL, NULL, SDL_Instance, NULL); - WIN_FlushMessageQueue (); + hwnd = CreateWindow(SDL_Appname, SDL_Appname, WS_POPUP | WS_DISABLED, + 0, 0, 10, 10, NULL, NULL, SDL_Instance, NULL); + WIN_FlushMessageQueue(); - hdc = GetDC (hwnd); + hdc = GetDC(hwnd); - pformat = ChoosePixelFormat (hdc, &GL_pfd); - SetPixelFormat (hdc, pformat, &GL_pfd); + pformat = ChoosePixelFormat(hdc, &GL_pfd); + SetPixelFormat(hdc, pformat, &GL_pfd); - hglrc = this->gl_data->wglCreateContext (hdc); + hglrc = this->gl_data->wglCreateContext(hdc); if (hglrc) { - this->gl_data->wglMakeCurrent (hdc, hglrc); + this->gl_data->wglMakeCurrent(hdc, hglrc); } wglGetExtensionsStringARB = (const char *(WINAPI *) (HDC)) - this->gl_data->wglGetProcAddress ("wglGetExtensionsStringARB"); + this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB"); if (wglGetExtensionsStringARB) { - extensions = wglGetExtensionsStringARB (hdc); + extensions = wglGetExtensionsStringARB(hdc); } else { extensions = NULL; } this->gl_data->WGL_ARB_pixel_format = 0; - if (ExtensionSupported ("WGL_ARB_pixel_format", extensions)) { - this->gl_data->wglChoosePixelFormatARB = (BOOL (WINAPI *) + if (ExtensionSupported("WGL_ARB_pixel_format", extensions)) { + this->gl_data->wglChoosePixelFormatARB = (BOOL(WINAPI *) (HDC, const int *, const FLOAT *, UINT, int *, UINT *)) this->gl_data-> - wglGetProcAddress ("wglChoosePixelFormatARB"); + wglGetProcAddress("wglChoosePixelFormatARB"); this->gl_data->wglGetPixelFormatAttribivARB = - (BOOL (WINAPI *) (HDC, int, int, UINT, const int *, int *)) - this->gl_data->wglGetProcAddress ("wglGetPixelFormatAttribivARB"); + (BOOL(WINAPI *) (HDC, int, int, UINT, const int *, int *)) + this->gl_data->wglGetProcAddress("wglGetPixelFormatAttribivARB"); if ((this->gl_data->wglChoosePixelFormatARB != NULL) && (this->gl_data->wglGetPixelFormatAttribivARB != NULL)) { @@ -163,18 +163,18 @@ } if (hglrc) { - this->gl_data->wglMakeCurrent (NULL, NULL); - this->gl_data->wglDeleteContext (hglrc); + this->gl_data->wglMakeCurrent(NULL, NULL); + this->gl_data->wglDeleteContext(hglrc); } - ReleaseDC (hwnd, hdc); - DestroyWindow (hwnd); - WIN_FlushMessageQueue (); + ReleaseDC(hwnd, hdc); + DestroyWindow(hwnd); + WIN_FlushMessageQueue(); } #endif /* SDL_VIDEO_OPENGL */ int -WIN_GL_SetupWindow (_THIS) +WIN_GL_SetupWindow(_THIS) { int retval; #if SDL_VIDEO_OPENGL @@ -189,22 +189,22 @@ /* load the gl driver from a default path */ if (!this->gl_config.driver_loaded) { /* no driver has been loaded, use default (ourselves) */ - if (WIN_GL_LoadLibrary (this, NULL) < 0) { + if (WIN_GL_LoadLibrary(this, NULL) < 0) { return (-1); } } for (i = 0;; ++i) { /* Get the window device context for our OpenGL drawing */ - GL_hdc = GetDC (SDL_Window); + GL_hdc = GetDC(SDL_Window); if (GL_hdc == NULL) { - SDL_SetError ("Unable to get DC for SDL_Window"); + SDL_SetError("Unable to get DC for SDL_Window"); return (-1); } /* Set up the pixel format descriptor with our needed format */ - SDL_memset (&GL_pfd, 0, sizeof (GL_pfd)); - GL_pfd.nSize = sizeof (GL_pfd); + SDL_memset(&GL_pfd, 0, sizeof(GL_pfd)); + GL_pfd.nSize = sizeof(GL_pfd); GL_pfd.nVersion = 1; GL_pfd.dwFlags = (PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL); if (this->gl_config.double_buffer) { @@ -230,7 +230,7 @@ GL_pfd.cStencilBits = this->gl_config.stencil_size; /* initialize WGL_ARB_pixel_format */ - Init_WGL_ARB_extensions (this); + Init_WGL_ARB_extensions(this); /* setup WGL_ARB_pixel_format attribs */ iAttr = &iAttribs[0]; @@ -309,39 +309,39 @@ /* Choose and set the closest available pixel format */ if (!this->gl_data->WGL_ARB_pixel_format || - !this->gl_data->wglChoosePixelFormatARB (GL_hdc, iAttribs, - fAttribs, 1, - &pixel_format, &matching) + !this->gl_data->wglChoosePixelFormatARB(GL_hdc, iAttribs, + fAttribs, 1, + &pixel_format, &matching) || !matching) { - pixel_format = ChoosePixelFormat (GL_hdc, &GL_pfd); + pixel_format = ChoosePixelFormat(GL_hdc, &GL_pfd); this->gl_data->WGL_ARB_pixel_format = 0; } if (!pixel_format) { - SDL_SetError ("No matching GL pixel format available"); + SDL_SetError("No matching GL pixel format available"); return (-1); } - if (!SetPixelFormat (GL_hdc, pixel_format, &GL_pfd)) { + if (!SetPixelFormat(GL_hdc, pixel_format, &GL_pfd)) { if (i == 0) { /* First time through, try resetting the window */ - if (WIN_GL_ResetWindow (this) < 0) { + if (WIN_GL_ResetWindow(this) < 0) { return (-1); } continue; } - SDL_SetError ("Unable to set HDC pixel format"); + SDL_SetError("Unable to set HDC pixel format"); return (-1); } /* We either succeeded or failed by this point */ break; } - DescribePixelFormat (GL_hdc, pixel_format, sizeof (GL_pfd), &GL_pfd); + DescribePixelFormat(GL_hdc, pixel_format, sizeof(GL_pfd), &GL_pfd); - GL_hrc = this->gl_data->wglCreateContext (GL_hdc); + GL_hrc = this->gl_data->wglCreateContext(GL_hdc); if (GL_hrc == NULL) { - SDL_SetError ("Unable to create GL context"); + SDL_SetError("Unable to create GL context"); return (-1); } - if (WIN_GL_MakeCurrent (this) < 0) { + if (WIN_GL_MakeCurrent(this) < 0) { return (-1); } gl_active = 1; @@ -350,24 +350,24 @@ * somewhat a documented and reliable hack - it was originally * as a feature added by mistake, but since so many people rely * on it, it will not be removed. strstr should be safe here.*/ - glGetStringFunc = WIN_GL_GetProcAddress (this, "glGetString"); + glGetStringFunc = WIN_GL_GetProcAddress(this, "glGetString"); if (glGetStringFunc) { - wglext = (const char *) glGetStringFunc (GL_EXTENSIONS); + wglext = (const char *) glGetStringFunc(GL_EXTENSIONS); } else { /* Uh oh, something is seriously wrong here... */ wglext = NULL; } - if (!wglext || !SDL_strstr (wglext, "WGL_EXT_swap_control")) { + if (!wglext || !SDL_strstr(wglext, "WGL_EXT_swap_control")) { this->gl_data->wglSwapIntervalEXT = NULL; this->gl_data->wglGetSwapIntervalEXT = NULL; } if (this->gl_config.swap_control >= 0) { if (this->gl_data->wglSwapIntervalEXT) { - this->gl_data->wglSwapIntervalEXT (this->gl_config.swap_control); + this->gl_data->wglSwapIntervalEXT(this->gl_config.swap_control); } } #else - SDL_SetError ("WIN driver not configured with OpenGL"); + SDL_SetError("WIN driver not configured with OpenGL"); #endif if (gl_active) { retval = 0; @@ -378,22 +378,22 @@ } void -WIN_GL_ShutDown (_THIS) +WIN_GL_ShutDown(_THIS) { #if SDL_VIDEO_OPENGL /* Clean up OpenGL */ if (GL_hrc) { - this->gl_data->wglMakeCurrent (NULL, NULL); - this->gl_data->wglDeleteContext (GL_hrc); + this->gl_data->wglMakeCurrent(NULL, NULL); + this->gl_data->wglDeleteContext(GL_hrc); GL_hrc = NULL; } if (GL_hdc) { - ReleaseDC (SDL_Window, GL_hdc); + ReleaseDC(SDL_Window, GL_hdc); GL_hdc = NULL; } gl_active = 0; - WIN_GL_UnloadLibrary (this); + WIN_GL_UnloadLibrary(this); #endif /* SDL_VIDEO_OPENGL */ } @@ -401,13 +401,13 @@ /* Make the current context active */ int -WIN_GL_MakeCurrent (_THIS) +WIN_GL_MakeCurrent(_THIS) { int retval; retval = 0; - if (!this->gl_data->wglMakeCurrent (GL_hdc, GL_hrc)) { - SDL_SetError ("Unable to make GL context current"); + if (!this->gl_data->wglMakeCurrent(GL_hdc, GL_hrc)) { + SDL_SetError("Unable to make GL context current"); retval = -1; } return (retval); @@ -415,7 +415,7 @@ /* Get attribute data from glX. */ int -WIN_GL_GetAttribute (_THIS, SDL_GLattr attrib, int *value) +WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) { int retval; @@ -470,10 +470,10 @@ break; case SDL_GL_ACCELERATED_VISUAL: wgl_attrib = WGL_ACCELERATION_ARB; - this->gl_data->wglGetPixelFormatAttribivARB (GL_hdc, - pixel_format, 0, - 1, &wgl_attrib, - value); + this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, + pixel_format, 0, + 1, &wgl_attrib, + value); if (*value == WGL_NO_ACCELERATION_ARB) { *value = SDL_FALSE; } else { @@ -483,16 +483,15 @@ break; case SDL_GL_SWAP_CONTROL: if (this->gl_data->wglGetSwapIntervalEXT) { - return this->gl_data->wglGetSwapIntervalEXT (); + return this->gl_data->wglGetSwapIntervalEXT(); } else { return -1; } default: return (-1); } - this->gl_data->wglGetPixelFormatAttribivARB (GL_hdc, pixel_format, - 0, 1, &wgl_attrib, - value); + this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, pixel_format, + 0, 1, &wgl_attrib, value); return 0; } @@ -560,16 +559,16 @@ } void -WIN_GL_SwapBuffers (_THIS) +WIN_GL_SwapBuffers(_THIS) { - SwapBuffers (GL_hdc); + SwapBuffers(GL_hdc); } void -WIN_GL_UnloadLibrary (_THIS) +WIN_GL_UnloadLibrary(_THIS) { if (this->gl_config.driver_loaded) { - FreeLibrary ((HMODULE) this->gl_config.dll_handle); + FreeLibrary((HMODULE) this->gl_config.dll_handle); this->gl_data->wglGetProcAddress = NULL; this->gl_data->wglCreateContext = NULL; @@ -587,68 +586,68 @@ /* Passing a NULL path means load pointers from the application */ int -WIN_GL_LoadLibrary (_THIS, const char *path) +WIN_GL_LoadLibrary(_THIS, const char *path) { HMODULE handle; if (gl_active) { - SDL_SetError ("OpenGL context already created"); + SDL_SetError("OpenGL context already created"); return -1; } if (path == NULL) { path = DEFAULT_GL_DRIVER_PATH; } - handle = LoadLibrary (path); + handle = LoadLibrary(path); if (handle == NULL) { - SDL_SetError ("Could not load OpenGL library"); + SDL_SetError("Could not load OpenGL library"); return -1; } /* Unload the old driver and reset the pointers */ - WIN_GL_UnloadLibrary (this); + WIN_GL_UnloadLibrary(this); /* Load new function pointers */ - SDL_memset (this->gl_data, 0, sizeof (*this->gl_data)); + SDL_memset(this->gl_data, 0, sizeof(*this->gl_data)); this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *)) - GetProcAddress (handle, "wglGetProcAddress"); - this->gl_data->wglCreateContext = (HGLRC (WINAPI *) (HDC)) - GetProcAddress (handle, "wglCreateContext"); - this->gl_data->wglDeleteContext = (BOOL (WINAPI *) (HGLRC)) - GetProcAddress (handle, "wglDeleteContext"); - this->gl_data->wglMakeCurrent = (BOOL (WINAPI *) (HDC, HGLRC)) - GetProcAddress (handle, "wglMakeCurrent"); + GetProcAddress(handle, "wglGetProcAddress"); + this->gl_data->wglCreateContext = (HGLRC(WINAPI *) (HDC)) + GetProcAddress(handle, "wglCreateContext"); + this->gl_data->wglDeleteContext = (BOOL(WINAPI *) (HGLRC)) + GetProcAddress(handle, "wglDeleteContext"); + this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC)) + GetProcAddress(handle, "wglMakeCurrent"); this->gl_data->wglSwapIntervalEXT = (void (WINAPI *) (int)) - GetProcAddress (handle, "wglSwapIntervalEXT"); + GetProcAddress(handle, "wglSwapIntervalEXT"); this->gl_data->wglGetSwapIntervalEXT = (int (WINAPI *) (void)) - GetProcAddress (handle, "wglGetSwapIntervalEXT"); + GetProcAddress(handle, "wglGetSwapIntervalEXT"); if ((this->gl_data->wglGetProcAddress == NULL) || (this->gl_data->wglCreateContext == NULL) || (this->gl_data->wglDeleteContext == NULL) || (this->gl_data->wglMakeCurrent == NULL)) { - SDL_SetError ("Could not retrieve OpenGL functions"); - FreeLibrary (handle); + SDL_SetError("Could not retrieve OpenGL functions"); + FreeLibrary(handle); return -1; } this->gl_config.dll_handle = handle; - SDL_strlcpy (this->gl_config.driver_path, path, - SDL_arraysize (this->gl_config.driver_path)); + SDL_strlcpy(this->gl_config.driver_path, path, + SDL_arraysize(this->gl_config.driver_path)); this->gl_config.driver_loaded = 1; return 0; } void * -WIN_GL_GetProcAddress (_THIS, const char *proc) +WIN_GL_GetProcAddress(_THIS, const char *proc) { void *func; /* This is to pick up extensions */ - func = this->gl_data->wglGetProcAddress (proc); + func = this->gl_data->wglGetProcAddress(proc); if (!func) { /* This is probably a normal GL function */ - func = GetProcAddress (this->gl_config.dll_handle, proc); + func = GetProcAddress(this->gl_config.dll_handle, proc); } return func; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/wincommon/SDL_wingl_c.h --- a/src/video/wincommon/SDL_wingl_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/wincommon/SDL_wingl_c.h Mon May 29 04:04:35 2006 +0000 @@ -39,23 +39,23 @@ void *(WINAPI * wglGetProcAddress) (const char *proc); - HGLRC (WINAPI * wglCreateContext) (HDC hdc); + HGLRC(WINAPI * wglCreateContext) (HDC hdc); - BOOL (WINAPI * wglDeleteContext) (HGLRC hglrc); + BOOL(WINAPI * wglDeleteContext) (HGLRC hglrc); - BOOL (WINAPI * wglMakeCurrent) (HDC hdc, HGLRC hglrc); + BOOL(WINAPI * wglMakeCurrent) (HDC hdc, HGLRC hglrc); - BOOL (WINAPI * wglChoosePixelFormatARB) (HDC hdc, - const int *piAttribIList, - const FLOAT * pfAttribFList, - UINT nMaxFormats, - int *piFormats, - UINT * nNumFormats); - BOOL (WINAPI * wglGetPixelFormatAttribivARB) (HDC hdc, int iPixelFormat, - int iLayerPlane, - UINT nAttributes, - const int *piAttributes, - int *piValues); + BOOL(WINAPI * wglChoosePixelFormatARB) (HDC hdc, + const int *piAttribIList, + const FLOAT * pfAttribFList, + UINT nMaxFormats, + int *piFormats, + UINT * nNumFormats); + BOOL(WINAPI * wglGetPixelFormatAttribivARB) (HDC hdc, int iPixelFormat, + int iLayerPlane, + UINT nAttributes, + const int *piAttributes, + int *piValues); void (WINAPI * wglSwapIntervalEXT) (int interval); int (WINAPI * wglGetSwapIntervalEXT) (void); #endif /* SDL_VIDEO_OPENGL */ @@ -69,15 +69,15 @@ #define pixel_format (this->gl_data->pixel_format) /* OpenGL functions */ -extern int WIN_GL_SetupWindow (_THIS); -extern void WIN_GL_ShutDown (_THIS); +extern int WIN_GL_SetupWindow(_THIS); +extern void WIN_GL_ShutDown(_THIS); #if SDL_VIDEO_OPENGL -extern int WIN_GL_MakeCurrent (_THIS); -extern int WIN_GL_GetAttribute (_THIS, SDL_GLattr attrib, int *value); -extern void WIN_GL_SwapBuffers (_THIS); -extern void WIN_GL_UnloadLibrary (_THIS); -extern int WIN_GL_LoadLibrary (_THIS, const char *path); -extern void *WIN_GL_GetProcAddress (_THIS, const char *proc); +extern int WIN_GL_MakeCurrent(_THIS); +extern int WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value); +extern void WIN_GL_SwapBuffers(_THIS); +extern void WIN_GL_UnloadLibrary(_THIS); +extern int WIN_GL_LoadLibrary(_THIS, const char *path); +extern void *WIN_GL_GetProcAddress(_THIS, const char *proc); #endif #if SDL_VIDEO_OPENGL diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/windib/SDL_dibevents.c --- a/src/video/windib/SDL_dibevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/windib/SDL_dibevents.c Mon May 29 04:04:35 2006 +0000 @@ -43,8 +43,8 @@ /* The translation table from a Microsoft VK keysym to a SDL keysym */ static SDLKey VK_keymap[SDLK_LAST]; -static SDL_keysym *TranslateKey (WPARAM vkey, UINT scancode, - SDL_keysym * keysym, int pressed); +static SDL_keysym *TranslateKey(WPARAM vkey, UINT scancode, + SDL_keysym * keysym, int pressed); /* Masks for processing the windows KEYDOWN and KEYUP messages */ #define REPEATED_KEYMASK (1<<30) @@ -63,7 +63,7 @@ #ifdef _WIN32_WCE WPARAM -rotateKey (WPARAM key, SDL_ScreenOrientation direction) +rotateKey(WPARAM key, SDL_ScreenOrientation direction) { if (direction != SDL_ORIENTATION_LEFT) return key; @@ -87,7 +87,7 @@ /* The main Win32 event handler */ LRESULT -DIB_HandleMessage (_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { extern int posted; @@ -104,7 +104,7 @@ // Rotate key if necessary if (this->hidden->orientation != SDL_ORIENTATION_UP) - wParam = rotateKey (wParam, this->hidden->orientation); + wParam = rotateKey(wParam, this->hidden->orientation); #endif /* Ignore repeated keys */ if (lParam & REPEATED_KEYMASK) { @@ -120,12 +120,12 @@ case VK_SHIFT: /* EXTENDED trick doesn't work here */ { - Uint8 *state = SDL_GetKeyState (NULL); + Uint8 *state = SDL_GetKeyState(NULL); if (state[SDLK_LSHIFT] == SDL_RELEASED - && (GetKeyState (VK_LSHIFT) & 0x8000)) { + && (GetKeyState(VK_LSHIFT) & 0x8000)) { wParam = VK_LSHIFT; } else if (state[SDLK_RSHIFT] == SDL_RELEASED - && (GetKeyState (VK_RSHIFT) & 0x8000)) { + && (GetKeyState(VK_RSHIFT) & 0x8000)) { wParam = VK_RSHIFT; } else { /* Probably a key repeat */ @@ -150,18 +150,18 @@ m.wParam = wParam; m.lParam = lParam; m.time = 0; - if (TranslateMessage (&m) - && PeekMessage (&m, hwnd, 0, WM_USER, PM_NOREMOVE) + if (TranslateMessage(&m) + && PeekMessage(&m, hwnd, 0, WM_USER, PM_NOREMOVE) && (m.message == WM_CHAR)) { - GetMessage (&m, hwnd, 0, WM_USER); + GetMessage(&m, hwnd, 0, WM_USER); wParam = m.wParam; } } #endif /* NO_GETKEYBOARDSTATE */ - posted = SDL_PrivateKeyboard (SDL_PRESSED, - TranslateKey (wParam, - HIWORD (lParam), - &keysym, 1)); + posted = SDL_PrivateKeyboard(SDL_PRESSED, + TranslateKey(wParam, + HIWORD(lParam), + &keysym, 1)); } return (0); @@ -177,7 +177,7 @@ // Rotate key if necessary if (this->hidden->orientation != SDL_ORIENTATION_UP) - wParam = rotateKey (wParam, this->hidden->orientation); + wParam = rotateKey(wParam, this->hidden->orientation); #endif switch (wParam) { @@ -190,12 +190,12 @@ case VK_SHIFT: /* EXTENDED trick doesn't work here */ { - Uint8 *state = SDL_GetKeyState (NULL); + Uint8 *state = SDL_GetKeyState(NULL); if (state[SDLK_LSHIFT] == SDL_PRESSED - && !(GetKeyState (VK_LSHIFT) & 0x8000)) { + && !(GetKeyState(VK_LSHIFT) & 0x8000)) { wParam = VK_LSHIFT; } else if (state[SDLK_RSHIFT] == SDL_PRESSED - && !(GetKeyState (VK_RSHIFT) & 0x8000)) { + && !(GetKeyState(VK_RSHIFT) & 0x8000)) { wParam = VK_RSHIFT; } else { /* Probably a key repeat */ @@ -212,17 +212,17 @@ } /* Windows only reports keyup for print screen */ if (wParam == VK_SNAPSHOT - && SDL_GetKeyState (NULL)[SDLK_PRINT] == SDL_RELEASED) { - posted = SDL_PrivateKeyboard (SDL_PRESSED, - TranslateKey (wParam, - HIWORD - (lParam), - &keysym, 1)); + && SDL_GetKeyState(NULL)[SDLK_PRINT] == SDL_RELEASED) { + posted = SDL_PrivateKeyboard(SDL_PRESSED, + TranslateKey(wParam, + HIWORD + (lParam), + &keysym, 1)); } - posted = SDL_PrivateKeyboard (SDL_RELEASED, - TranslateKey (wParam, - HIWORD (lParam), - &keysym, 0)); + posted = SDL_PrivateKeyboard(SDL_RELEASED, + TranslateKey(wParam, + HIWORD(lParam), + &keysym, 0)); } return (0); @@ -242,46 +242,46 @@ if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) { SDL_SysWMmsg wmmsg; - SDL_VERSION (&wmmsg.version); + SDL_VERSION(&wmmsg.version); wmmsg.hwnd = hwnd; wmmsg.msg = msg; wmmsg.wParam = wParam; wmmsg.lParam = lParam; - posted = SDL_PrivateSysWMEvent (&wmmsg); + posted = SDL_PrivateSysWMEvent(&wmmsg); /* DJM: If the user isn't watching for private messages in her SDL event loop, then pass it along to any win32 specific window proc. */ } else if (userWindowProc) { - return CallWindowProc (userWindowProc, hwnd, msg, wParam, - lParam); + return CallWindowProc(userWindowProc, hwnd, msg, wParam, + lParam); } } break; } - return (DefWindowProc (hwnd, msg, wParam, lParam)); + return (DefWindowProc(hwnd, msg, wParam, lParam)); } void -DIB_PumpEvents (_THIS) +DIB_PumpEvents(_THIS) { MSG msg; - while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)) { - if (GetMessage (&msg, NULL, 0, 0) > 0) { - DispatchMessage (&msg); + while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { + if (GetMessage(&msg, NULL, 0, 0) > 0) { + DispatchMessage(&msg); } } } void -DIB_InitOSKeymap (_THIS) +DIB_InitOSKeymap(_THIS) { int i; /* Map the VK keysyms */ - for (i = 0; i < SDL_arraysize (VK_keymap); ++i) + for (i = 0; i < SDL_arraysize(VK_keymap); ++i) VK_keymap[i] = SDLK_UNKNOWN; VK_keymap[VK_BACK] = SDLK_BACKSPACE; @@ -406,7 +406,7 @@ } static SDL_keysym * -TranslateKey (WPARAM vkey, UINT scancode, SDL_keysym * keysym, int pressed) +TranslateKey(WPARAM vkey, UINT scancode, SDL_keysym * keysym, int pressed) { /* Set the keysym information */ keysym->scancode = (unsigned char) scancode; @@ -421,10 +421,10 @@ BYTE keystate[256]; Uint16 wchars[2]; - GetKeyboardState (keystate); + GetKeyboardState(keystate); if (SDL_ToUnicode ((UINT) vkey, scancode, keystate, wchars, - sizeof (wchars) / sizeof (wchars[0]), 0) == 1) { + sizeof(wchars) / sizeof(wchars[0]), 0) == 1) { keysym->unicode = wchars[0]; } #endif /* NO_GETKEYBOARDSTATE */ @@ -433,27 +433,27 @@ } int -DIB_CreateWindow (_THIS) +DIB_CreateWindow(_THIS) { - char *windowid = SDL_getenv ("SDL_WINDOWID"); + char *windowid = SDL_getenv("SDL_WINDOWID"); - SDL_RegisterApp (NULL, 0, 0); + SDL_RegisterApp(NULL, 0, 0); SDL_windowid = (windowid != NULL); if (SDL_windowid) { #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) /* wince 2.1 does not have strtol */ wchar_t *windowid_t = - SDL_malloc ((SDL_strlen (windowid) + 1) * sizeof (wchar_t)); - MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, windowid, -1, - windowid_t, SDL_strlen (windowid) + 1); - SDL_Window = (HWND) wcstol (windowid_t, NULL, 0); - SDL_free (windowid_t); + SDL_malloc((SDL_strlen(windowid) + 1) * sizeof(wchar_t)); + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, windowid, -1, + windowid_t, SDL_strlen(windowid) + 1); + SDL_Window = (HWND) wcstol(windowid_t, NULL, 0); + SDL_free(windowid_t); #else - SDL_Window = (HWND) SDL_strtoull (windowid, NULL, 0); + SDL_Window = (HWND) SDL_strtoull(windowid, NULL, 0); #endif if (SDL_Window == NULL) { - SDL_SetError ("Couldn't get user specified window"); + SDL_SetError("Couldn't get user specified window"); return (-1); } @@ -461,46 +461,45 @@ window to be handled by SDL. */ userWindowProc = - (WNDPROCTYPE) GetWindowLongPtr (SDL_Window, GWLP_WNDPROC); - SetWindowLongPtr (SDL_Window, GWLP_WNDPROC, (LONG_PTR) WinMessage); + (WNDPROCTYPE) GetWindowLongPtr(SDL_Window, GWLP_WNDPROC); + SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR) WinMessage); } else { - SDL_Window = CreateWindow (SDL_Appname, SDL_Appname, - (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU - | WS_MINIMIZEBOX), CW_USEDEFAULT, - CW_USEDEFAULT, 0, 0, NULL, NULL, - SDL_Instance, NULL); + SDL_Window = CreateWindow(SDL_Appname, SDL_Appname, + (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU + | WS_MINIMIZEBOX), CW_USEDEFAULT, + CW_USEDEFAULT, 0, 0, NULL, NULL, + SDL_Instance, NULL); if (SDL_Window == NULL) { - SDL_SetError ("Couldn't create window"); + SDL_SetError("Couldn't create window"); return (-1); } - ShowWindow (SDL_Window, SW_HIDE); + ShowWindow(SDL_Window, SW_HIDE); } /* JC 14 Mar 2006 Flush the message loop or this can cause big problems later Especially if the user decides to use dialog boxes or assert()! */ - WIN_FlushMessageQueue (); + WIN_FlushMessageQueue(); return (0); } void -DIB_DestroyWindow (_THIS) +DIB_DestroyWindow(_THIS) { if (SDL_windowid) { - SetWindowLongPtr (SDL_Window, GWLP_WNDPROC, - (LONG_PTR) userWindowProc); + SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR) userWindowProc); } else { - DestroyWindow (SDL_Window); + DestroyWindow(SDL_Window); } - SDL_UnregisterApp (); + SDL_UnregisterApp(); /* JC 14 Mar 2006 Flush the message loop or this can cause big problems later Especially if the user decides to use dialog boxes or assert()! */ - WIN_FlushMessageQueue (); + WIN_FlushMessageQueue(); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/windib/SDL_dibevents_c.h --- a/src/video/windib/SDL_dibevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/windib/SDL_dibevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -27,10 +27,10 @@ of the native video subsystem (SDL_dibvideo.c) */ extern LONG -DIB_HandleMessage (_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -extern int DIB_CreateWindow (_THIS); -extern void DIB_DestroyWindow (_THIS); +DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +extern int DIB_CreateWindow(_THIS); +extern void DIB_DestroyWindow(_THIS); -extern void DIB_PumpEvents (_THIS); -extern void DIB_InitOSKeymap (_THIS); +extern void DIB_PumpEvents(_THIS); +extern void DIB_InitOSKeymap(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/windib/SDL_dibvideo.c --- a/src/video/windib/SDL_dibvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/windib/SDL_dibvideo.c Mon May 29 04:04:35 2006 +0000 @@ -68,78 +68,78 @@ #endif /* Initialization/Query functions */ -static int DIB_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **DIB_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -SDL_Surface *DIB_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int DIB_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void DIB_CheckGamma (_THIS); -void DIB_SwapGamma (_THIS); -void DIB_QuitGamma (_THIS); -int DIB_SetGammaRamp (_THIS, Uint16 * ramp); -int DIB_GetGammaRamp (_THIS, Uint16 * ramp); -static void DIB_VideoQuit (_THIS); +static int DIB_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **DIB_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +static int DIB_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void DIB_CheckGamma(_THIS); +void DIB_SwapGamma(_THIS); +void DIB_QuitGamma(_THIS); +int DIB_SetGammaRamp(_THIS, Uint16 * ramp); +int DIB_GetGammaRamp(_THIS, Uint16 * ramp); +static void DIB_VideoQuit(_THIS); /* Hardware surface functions */ -static int DIB_AllocHWSurface (_THIS, SDL_Surface * surface); -static int DIB_LockHWSurface (_THIS, SDL_Surface * surface); -static void DIB_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void DIB_FreeHWSurface (_THIS, SDL_Surface * surface); +static int DIB_AllocHWSurface(_THIS, SDL_Surface * surface); +static int DIB_LockHWSurface(_THIS, SDL_Surface * surface); +static void DIB_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void DIB_FreeHWSurface(_THIS, SDL_Surface * surface); /* Windows message handling functions */ -static void DIB_RealizePalette (_THIS); -static void DIB_PaletteChanged (_THIS, HWND window); -static void DIB_WinPAINT (_THIS, HDC hdc); +static void DIB_RealizePalette(_THIS); +static void DIB_PaletteChanged(_THIS, HWND window); +static void DIB_WinPAINT(_THIS, HDC hdc); /* helper fn */ -static int DIB_SussScreenDepth (); +static int DIB_SussScreenDepth(); /* DIB driver bootstrap functions */ static int -DIB_Available (void) +DIB_Available(void) { return (1); } static void -DIB_DeleteDevice (SDL_VideoDevice * device) +DIB_DeleteDevice(SDL_VideoDevice * device) { if (device) { if (device->hidden) { - SDL_free (device->hidden); + SDL_free(device->hidden); } if (device->gl_data) { - SDL_free (device->gl_data); + SDL_free(device->gl_data); } - SDL_free (device); + SDL_free(device); } } static SDL_VideoDevice * -DIB_CreateDevice (int devindex) +DIB_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); device->gl_data = (struct SDL_PrivateGLData *) - SDL_malloc ((sizeof *device->gl_data)); + SDL_malloc((sizeof *device->gl_data)); } if ((device == NULL) || (device->hidden == NULL) || (device->gl_data == NULL)) { - SDL_OutOfMemory (); - DIB_DeleteDevice (device); + SDL_OutOfMemory(); + DIB_DeleteDevice(device); return (NULL); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); - SDL_memset (device->gl_data, 0, (sizeof *device->gl_data)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->gl_data, 0, (sizeof *device->gl_data)); /* Set the function pointers */ device->VideoInit = DIB_VideoInit; @@ -198,7 +198,7 @@ }; static int -cmpmodes (const void *va, const void *vb) +cmpmodes(const void *va, const void *vb) { SDL_Rect *a = *(SDL_Rect **) va; SDL_Rect *b = *(SDL_Rect **) vb; @@ -209,7 +209,7 @@ } static int -DIB_AddMode (_THIS, int bpp, int w, int h) +DIB_AddMode(_THIS, int bpp, int w, int h) { SDL_Rect *mode; int i, index; @@ -228,9 +228,9 @@ } /* Set up the new video mode rectangle */ - mode = (SDL_Rect *) SDL_malloc (sizeof *mode); + mode = (SDL_Rect *) SDL_malloc(sizeof *mode); if (mode == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } mode->x = 0; @@ -241,12 +241,12 @@ /* Allocate the new list of modes, and fill in the new mode */ next_mode = SDL_nummodes[index]; SDL_modelist[index] = (SDL_Rect **) - SDL_realloc (SDL_modelist[index], - (1 + next_mode + 1) * sizeof (SDL_Rect *)); + SDL_realloc(SDL_modelist[index], + (1 + next_mode + 1) * sizeof(SDL_Rect *)); if (SDL_modelist[index] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); SDL_nummodes[index] = 0; - SDL_free (mode); + SDL_free(mode); return (-1); } SDL_modelist[index][next_mode] = mode; @@ -257,7 +257,7 @@ } static HPALETTE -DIB_CreatePalette (int bpp) +DIB_CreatePalette(int bpp) { /* RJR: March 28, 2000 moved palette creation here from "DIB_VideoInit" */ @@ -274,22 +274,22 @@ for (i = 0; i < bpp; ++i) { ncolors *= 2; } - palette = (LOGPALETTE *) SDL_malloc (sizeof (*palette) + - ncolors * sizeof (PALETTEENTRY)); + palette = (LOGPALETTE *) SDL_malloc(sizeof(*palette) + + ncolors * sizeof(PALETTEENTRY)); palette->palVersion = 0x300; palette->palNumEntries = ncolors; - hdc = GetDC (SDL_Window); - GetSystemPaletteEntries (hdc, 0, ncolors, palette->palPalEntry); - ReleaseDC (SDL_Window, hdc); - handle = CreatePalette (palette); - SDL_free (palette); + hdc = GetDC(SDL_Window); + GetSystemPaletteEntries(hdc, 0, ncolors, palette->palPalEntry); + ReleaseDC(SDL_Window, hdc); + handle = CreatePalette(palette); + SDL_free(palette); } return handle; } int -DIB_VideoInit (_THIS, SDL_PixelFormat * vformat) +DIB_VideoInit(_THIS, SDL_PixelFormat * vformat) { #ifndef NO_CHANGEDISPLAYSETTINGS int i; @@ -297,15 +297,15 @@ #endif /* Create the window */ - if (DIB_CreateWindow (this) < 0) { + if (DIB_CreateWindow(this) < 0) { return (-1); } #if !SDL_AUDIO_DISABLED - DX5_SoundFocus (SDL_Window); + DX5_SoundFocus(SDL_Window); #endif /* Determine the screen depth */ - vformat->BitsPerPixel = DIB_SussScreenDepth (); + vformat->BitsPerPixel = DIB_SussScreenDepth(); switch (vformat->BitsPerPixel) { case 15: vformat->Rmask = 0x00007c00; @@ -330,38 +330,38 @@ } /* See if gamma is supported on this screen */ - DIB_CheckGamma (this); + DIB_CheckGamma(this); #ifndef NO_CHANGEDISPLAYSETTINGS - settings.dmSize = sizeof (DEVMODE); + settings.dmSize = sizeof(DEVMODE); settings.dmDriverExtra = 0; #ifdef _WIN32_WCE settings.dmFields = DM_DISPLAYQUERYORIENTATION; this->hidden->supportRotation = - ChangeDisplaySettingsEx (NULL, &settings, NULL, CDS_TEST, - NULL) == DISP_CHANGE_SUCCESSFUL; + ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, + NULL) == DISP_CHANGE_SUCCESSFUL; #endif /* Query for the desktop resolution */ - EnumDisplaySettings (NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode); + EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode); this->info.current_w = SDL_desktop_mode.dmPelsWidth; this->info.current_h = SDL_desktop_mode.dmPelsHeight; /* Query for the list of available video modes */ - for (i = 0; EnumDisplaySettings (NULL, i, &settings); ++i) { - DIB_AddMode (this, settings.dmBitsPerPel, - settings.dmPelsWidth, settings.dmPelsHeight); + for (i = 0; EnumDisplaySettings(NULL, i, &settings); ++i) { + DIB_AddMode(this, settings.dmBitsPerPel, + settings.dmPelsWidth, settings.dmPelsHeight); #ifdef _WIN32_WCE if (this->hidden->supportRotation) - DIB_AddMode (this, settings.dmBitsPerPel, - settings.dmPelsHeight, settings.dmPelsWidth); + DIB_AddMode(this, settings.dmBitsPerPel, + settings.dmPelsHeight, settings.dmPelsWidth); #endif } /* Sort the mode lists */ for (i = 0; i < NUM_MODELISTS; ++i) { if (SDL_nummodes[i] > 0) { - SDL_qsort (SDL_modelist[i], SDL_nummodes[i], - sizeof *SDL_modelist[i], cmpmodes); + SDL_qsort(SDL_modelist[i], SDL_nummodes[i], + sizeof *SDL_modelist[i], cmpmodes); } } #else @@ -371,9 +371,9 @@ // because SDL surface conversion is much faster than the WinCE one. // Although it should be tested on devices with graphics accelerator. - DIB_AddMode (this, vformat->BitsPerPixel, - GetDeviceCaps (GetDC (NULL), HORZRES), - GetDeviceCaps (GetDC (NULL), VERTRES)); + DIB_AddMode(this, vformat->BitsPerPixel, + GetDeviceCaps(GetDC(NULL), HORZRES), + GetDeviceCaps(GetDC(NULL), VERTRES)); #endif /* !NO_CHANGEDISPLAYSETTINGS */ @@ -381,7 +381,7 @@ if (vformat->BitsPerPixel <= 8) { /* RJR: March 28, 2000 moved palette creation to "DIB_CreatePalette" */ - screen_pal = DIB_CreatePalette (vformat->BitsPerPixel); + screen_pal = DIB_CreatePalette(vformat->BitsPerPixel); } /* Fill in some window manager capabilities */ @@ -397,7 +397,7 @@ /* We support any format at any dimension */ SDL_Rect ** -DIB_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +DIB_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]); @@ -415,15 +415,15 @@ http://www.wdj.com/code/archive.html) */ static int -DIB_SussScreenDepth () +DIB_SussScreenDepth() { #ifdef NO_GETDIBITS int depth; HDC hdc; - hdc = GetDC (SDL_Window); - depth = GetDeviceCaps (hdc, PLANES) * GetDeviceCaps (hdc, BITSPIXEL); - ReleaseDC (SDL_Window, hdc); + hdc = GetDC(SDL_Window); + depth = GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL); + ReleaseDC(SDL_Window, hdc); return (depth); #else int dib_size; @@ -434,25 +434,25 @@ /* Allocate enough space for a DIB header plus palette (for * 8-bit modes) or bitfields (for 16- and 32-bit modes) */ - dib_size = sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD); - dib_hdr = (LPBITMAPINFOHEADER) SDL_malloc (dib_size); - SDL_memset (dib_hdr, 0, dib_size); - dib_hdr->biSize = sizeof (BITMAPINFOHEADER); + dib_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD); + dib_hdr = (LPBITMAPINFOHEADER) SDL_malloc(dib_size); + SDL_memset(dib_hdr, 0, dib_size); + dib_hdr->biSize = sizeof(BITMAPINFOHEADER); /* Get a device-dependent bitmap that's compatible with the screen. */ - hdc = GetDC (NULL); - hbm = CreateCompatibleBitmap (hdc, 1, 1); + hdc = GetDC(NULL); + hbm = CreateCompatibleBitmap(hdc, 1, 1); /* Convert the DDB to a DIB. We need to call GetDIBits twice: * the first call just fills in the BITMAPINFOHEADER; the * second fills in the bitfields or palette. */ - GetDIBits (hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS); - GetDIBits (hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS); - DeleteObject (hbm); - ReleaseDC (NULL, hdc); + GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS); + GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS); + DeleteObject(hbm); + ReleaseDC(NULL, hdc); switch (dib_hdr->biBitCount) { case 8: @@ -478,11 +478,11 @@ /* Various screen update functions available */ -static void DIB_NormalUpdate (_THIS, int numrects, SDL_Rect * rects); +static void DIB_NormalUpdate(_THIS, int numrects, SDL_Rect * rects); SDL_Surface * -DIB_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +DIB_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { SDL_Surface *video; Uint32 prev_flags; @@ -500,7 +500,7 @@ /* Clean up any GL context that may be hanging around */ if (current->flags & SDL_INTERNALOPENGL) { - WIN_GL_ShutDown (this); + WIN_GL_ShutDown(this); } SDL_resizing = 1; @@ -511,7 +511,7 @@ switch (bpp) { case 15: case 16: - if (DIB_SussScreenDepth () == 15) { + if (DIB_SussScreenDepth() == 15) { /* 5-5-5 */ Rmask = 0x00007c00; Gmask = 0x000003e0; @@ -536,10 +536,10 @@ Bmask = 0x00000000; break; } - video = SDL_CreateRGBSurface (SDL_SWSURFACE, - 0, 0, bpp, Rmask, Gmask, Bmask, 0); + video = SDL_CreateRGBSurface(SDL_SWSURFACE, + 0, 0, bpp, Rmask, Gmask, Bmask, 0); if (video == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } } @@ -549,7 +549,7 @@ video->flags = 0; /* Clear flags */ video->w = width; video->h = height; - video->pitch = SDL_CalculatePitch (video); + video->pitch = SDL_CalculatePitch(video); /* Small fix for WinCE/Win32 - when activating window SDL_VideoSurface is equal to zero, so activating code @@ -569,8 +569,8 @@ DEVMODE settings; BOOL changed; - SDL_memset (&settings, 0, sizeof (DEVMODE)); - settings.dmSize = sizeof (DEVMODE); + SDL_memset(&settings, 0, sizeof(DEVMODE)); + settings.dmSize = sizeof(DEVMODE); #ifdef _WIN32_WCE // try to rotate screen to fit requested resolution @@ -579,11 +579,11 @@ // ask current mode settings.dmFields = DM_DISPLAYORIENTATION; - ChangeDisplaySettingsEx (NULL, &settings, NULL, CDS_TEST, NULL); + ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, NULL); rotation = settings.dmDisplayOrientation; - if ((width > GetDeviceCaps (GetDC (NULL), HORZRES)) - && (height < GetDeviceCaps (GetDC (NULL), VERTRES))) { + if ((width > GetDeviceCaps(GetDC(NULL), HORZRES)) + && (height < GetDeviceCaps(GetDC(NULL), VERTRES))) { switch (rotation) { case DMDO_0: settings.dmDisplayOrientation = DMDO_90; @@ -595,12 +595,12 @@ if (settings.dmDisplayOrientation != rotation) { // go to landscape this->hidden->origRotation = rotation; - ChangeDisplaySettingsEx (NULL, &settings, NULL, - CDS_RESET, NULL); + ChangeDisplaySettingsEx(NULL, &settings, NULL, + CDS_RESET, NULL); } } - if ((width < GetDeviceCaps (GetDC (NULL), HORZRES)) - && (height > GetDeviceCaps (GetDC (NULL), VERTRES))) { + if ((width < GetDeviceCaps(GetDC(NULL), HORZRES)) + && (height > GetDeviceCaps(GetDC(NULL), VERTRES))) { switch (rotation) { case DMDO_90: settings.dmDisplayOrientation = DMDO_0; @@ -612,8 +612,8 @@ if (settings.dmDisplayOrientation != rotation) { // go to portrait this->hidden->origRotation = rotation; - ChangeDisplaySettingsEx (NULL, &settings, NULL, - CDS_RESET, NULL); + ChangeDisplaySettingsEx(NULL, &settings, NULL, + CDS_RESET, NULL); } } @@ -631,12 +631,12 @@ settings.dmFields |= DM_DISPLAYFREQUENCY; } changed = - (ChangeDisplaySettings (&settings, CDS_FULLSCREEN) == + (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL); if (!changed && (settings.dmFields & DM_DISPLAYFREQUENCY)) { settings.dmFields &= ~DM_DISPLAYFREQUENCY; changed = - (ChangeDisplaySettings (&settings, CDS_FULLSCREEN) == + (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL); } #else @@ -654,16 +654,16 @@ if (screen_pal != NULL) { /* RJR: March 28, 2000 delete identity palette if switching from a palettized mode */ - DeleteObject (screen_pal); + DeleteObject(screen_pal); screen_pal = NULL; } if (bpp <= 8) { /* RJR: March 28, 2000 create identity palette switching to a palettized mode */ - screen_pal = DIB_CreatePalette (bpp); + screen_pal = DIB_CreatePalette(bpp); } - style = GetWindowLong (SDL_Window, GWL_STYLE); + style = GetWindowLong(SDL_Window, GWL_STYLE); style &= ~(resizestyle | WS_MAXIMIZE); if ((video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { style &= ~windowstyle; @@ -671,7 +671,7 @@ } else { #ifndef NO_CHANGEDISPLAYSETTINGS if ((prev_flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { - ChangeDisplaySettings (NULL, 0); + ChangeDisplaySettings(NULL, 0); } #endif if (flags & SDL_NOFRAME) { @@ -687,40 +687,40 @@ } } #if WS_MAXIMIZE - if (IsZoomed (SDL_Window)) + if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; #endif } /* DJM: Don't piss of anyone who has setup his own window */ if (!SDL_windowid) - SetWindowLong (SDL_Window, GWL_STYLE, style); + SetWindowLong(SDL_Window, GWL_STYLE, style); /* Delete the old bitmap if necessary */ if (screen_bmp != NULL) { - DeleteObject (screen_bmp); + DeleteObject(screen_bmp); } if (!(flags & SDL_INTERNALOPENGL)) { BOOL is16bitmode = (video->format->BytesPerPixel == 2); /* Suss out the bitmap info header */ - binfo_size = sizeof (*binfo); + binfo_size = sizeof(*binfo); if (is16bitmode) { /* 16bit modes, palette area used for rgb bitmasks */ - binfo_size += 3 * sizeof (DWORD); + binfo_size += 3 * sizeof(DWORD); } else if (video->format->palette) { - binfo_size += video->format->palette->ncolors * sizeof (RGBQUAD); + binfo_size += video->format->palette->ncolors * sizeof(RGBQUAD); } - binfo = (BITMAPINFO *) SDL_malloc (binfo_size); + binfo = (BITMAPINFO *) SDL_malloc(binfo_size); if (!binfo) { if (video != current) { - SDL_FreeSurface (video); + SDL_FreeSurface(video); } - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } - binfo->bmiHeader.biSize = sizeof (BITMAPINFOHEADER); + binfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); binfo->bmiHeader.biWidth = video->w; binfo->bmiHeader.biHeight = -video->h; /* -ve for topdown bitmap */ binfo->bmiHeader.biPlanes = 1; @@ -740,23 +740,22 @@ } else { binfo->bmiHeader.biCompression = BI_RGB; /* BI_BITFIELDS for 565 vs 555 */ if (video->format->palette) { - SDL_memset (binfo->bmiColors, 0, - video->format->palette->ncolors * - sizeof (RGBQUAD)); + SDL_memset(binfo->bmiColors, 0, + video->format->palette->ncolors * sizeof(RGBQUAD)); } } /* Create the offscreen bitmap buffer */ - hdc = GetDC (SDL_Window); - screen_bmp = CreateDIBSection (hdc, binfo, DIB_RGB_COLORS, - (void **) (&video->pixels), NULL, 0); - ReleaseDC (SDL_Window, hdc); - SDL_free (binfo); + hdc = GetDC(SDL_Window); + screen_bmp = CreateDIBSection(hdc, binfo, DIB_RGB_COLORS, + (void **) (&video->pixels), NULL, 0); + ReleaseDC(SDL_Window, hdc); + SDL_free(binfo); if (screen_bmp == NULL) { if (video != current) { - SDL_FreeSurface (video); + SDL_FreeSurface(video); } - SDL_SetError ("Couldn't create DIB section"); + SDL_SetError("Couldn't create DIB section"); return (NULL); } this->UpdateRects = DIB_NormalUpdate; @@ -769,7 +768,7 @@ } #ifndef _WIN32_WCE /* Resize the window */ - if (!SDL_windowid && !IsZoomed (SDL_Window)) { + if (!SDL_windowid && !IsZoomed(SDL_Window)) { #else if (!SDL_windowid) { #endif @@ -779,14 +778,14 @@ const char *center = NULL; if (!SDL_windowX && !SDL_windowY) { - window = SDL_getenv ("SDL_VIDEO_WINDOW_POS"); - center = SDL_getenv ("SDL_VIDEO_CENTERED"); + window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); + center = SDL_getenv("SDL_VIDEO_CENTERED"); if (window) { - if (SDL_sscanf (window, "%d,%d", &x, &y) == 2) { + if (SDL_sscanf(window, "%d,%d", &x, &y) == 2) { SDL_windowX = x; SDL_windowY = y; } - if (SDL_strcmp (window, "center") == 0) { + if (SDL_strcmp(window, "center") == 0) { center = window; } } @@ -797,16 +796,16 @@ bounds.top = SDL_windowY; bounds.right = SDL_windowX + video->w; bounds.bottom = SDL_windowY + video->h; - AdjustWindowRectEx (&bounds, GetWindowLong (SDL_Window, GWL_STYLE), - FALSE, 0); + AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), + FALSE, 0); width = bounds.right - bounds.left; height = bounds.bottom - bounds.top; if ((flags & SDL_FULLSCREEN)) { - x = (GetSystemMetrics (SM_CXSCREEN) - width) / 2; - y = (GetSystemMetrics (SM_CYSCREEN) - height) / 2; + x = (GetSystemMetrics(SM_CXSCREEN) - width) / 2; + y = (GetSystemMetrics(SM_CYSCREEN) - height) / 2; } else if (center) { - x = (GetSystemMetrics (SM_CXSCREEN) - width) / 2; - y = (GetSystemMetrics (SM_CYSCREEN) - height) / 2; + x = (GetSystemMetrics(SM_CXSCREEN) - width) / 2; + y = (GetSystemMetrics(SM_CYSCREEN) - height) / 2; } else if (SDL_windowX || SDL_windowY || window) { x = bounds.left; y = bounds.top; @@ -819,18 +818,18 @@ } else { top = HWND_NOTOPMOST; } - SetWindowPos (SDL_Window, top, x, y, width, height, swp_flags); + SetWindowPos(SDL_Window, top, x, y, width, height, swp_flags); if (!(flags & SDL_FULLSCREEN)) { SDL_windowX = SDL_bounds.left; SDL_windowY = SDL_bounds.top; } - SetForegroundWindow (SDL_Window); + SetForegroundWindow(SDL_Window); } SDL_resizing = 0; /* Set up for OpenGL */ if (flags & SDL_INTERNALOPENGL) { - if (WIN_GL_SetupWindow (this) < 0) { + if (WIN_GL_SetupWindow(this) < 0) { return (NULL); } video->flags |= SDL_INTERNALOPENGL; @@ -840,7 +839,7 @@ Flush the message loop or this can cause big problems later Especially if the user decides to use dialog boxes or assert()! */ - WIN_FlushMessageQueue (); + WIN_FlushMessageQueue(); /* We're live! */ return (video); @@ -848,49 +847,49 @@ /* We don't actually allow hardware surfaces in the DIB driver */ static int -DIB_AllocHWSurface (_THIS, SDL_Surface * surface) +DIB_AllocHWSurface(_THIS, SDL_Surface * surface) { return (-1); } static void -DIB_FreeHWSurface (_THIS, SDL_Surface * surface) +DIB_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } static int -DIB_LockHWSurface (_THIS, SDL_Surface * surface) +DIB_LockHWSurface(_THIS, SDL_Surface * surface) { return (0); } static void -DIB_UnlockHWSurface (_THIS, SDL_Surface * surface) +DIB_UnlockHWSurface(_THIS, SDL_Surface * surface) { return; } static void -DIB_NormalUpdate (_THIS, int numrects, SDL_Rect * rects) +DIB_NormalUpdate(_THIS, int numrects, SDL_Rect * rects) { HDC hdc, mdc; int i; - hdc = GetDC (SDL_Window); + hdc = GetDC(SDL_Window); if (screen_pal) { - SelectPalette (hdc, screen_pal, FALSE); + SelectPalette(hdc, screen_pal, FALSE); } - mdc = CreateCompatibleDC (hdc); - SelectObject (mdc, screen_bmp); + mdc = CreateCompatibleDC(hdc); + SelectObject(mdc, screen_bmp); for (i = 0; i < numrects; ++i) { - BitBlt (hdc, rects[i].x, rects[i].y, rects[i].w, rects[i].h, - mdc, rects[i].x, rects[i].y, SRCCOPY); + BitBlt(hdc, rects[i].x, rects[i].y, rects[i].w, rects[i].h, + mdc, rects[i].x, rects[i].y, SRCCOPY); } - DeleteDC (mdc); - ReleaseDC (SDL_Window, hdc); + DeleteDC(mdc); + ReleaseDC(SDL_Window, hdc); } int -DIB_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) HDC hdc, mdc; @@ -901,25 +900,25 @@ int i; /* Update the display palette */ - hdc = GetDC (SDL_Window); + hdc = GetDC(SDL_Window); if (screen_pal) { PALETTEENTRY *entries; - entries = SDL_stack_alloc (PALETTEENTRY, ncolors); + entries = SDL_stack_alloc(PALETTEENTRY, ncolors); for (i = 0; i < ncolors; ++i) { entries[i].peRed = colors[i].r; entries[i].peGreen = colors[i].g; entries[i].peBlue = colors[i].b; entries[i].peFlags = PC_NOCOLLAPSE; } - SetPaletteEntries (screen_pal, firstcolor, ncolors, entries); - SelectPalette (hdc, screen_pal, FALSE); - RealizePalette (hdc); - SDL_stack_free (entries); + SetPaletteEntries(screen_pal, firstcolor, ncolors, entries); + SelectPalette(hdc, screen_pal, FALSE); + RealizePalette(hdc); + SDL_stack_free(entries); } #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) /* Copy palette colors into DIB palette */ - pal = SDL_stack_alloc (RGBQUAD, ncolors); + pal = SDL_stack_alloc(RGBQUAD, ncolors); for (i = 0; i < ncolors; ++i) { pal[i].rgbRed = colors[i].r; pal[i].rgbGreen = colors[i].g; @@ -928,81 +927,81 @@ } /* Set the DIB palette and update the display */ - mdc = CreateCompatibleDC (hdc); - SelectObject (mdc, screen_bmp); - SetDIBColorTable (mdc, firstcolor, ncolors, pal); - BitBlt (hdc, 0, 0, this->screen->w, this->screen->h, mdc, 0, 0, SRCCOPY); - DeleteDC (mdc); - SDL_stack_free (pal); + mdc = CreateCompatibleDC(hdc); + SelectObject(mdc, screen_bmp); + SetDIBColorTable(mdc, firstcolor, ncolors, pal); + BitBlt(hdc, 0, 0, this->screen->w, this->screen->h, mdc, 0, 0, SRCCOPY); + DeleteDC(mdc); + SDL_stack_free(pal); #endif - ReleaseDC (SDL_Window, hdc); + ReleaseDC(SDL_Window, hdc); return (1); } static void -DIB_CheckGamma (_THIS) +DIB_CheckGamma(_THIS) { #ifndef NO_GAMMA_SUPPORT HDC hdc; WORD ramp[3 * 256]; /* If we fail to get gamma, disable gamma control */ - hdc = GetDC (SDL_Window); - if (!GetDeviceGammaRamp (hdc, ramp)) { + hdc = GetDC(SDL_Window); + if (!GetDeviceGammaRamp(hdc, ramp)) { this->GetGammaRamp = NULL; this->SetGammaRamp = NULL; } - ReleaseDC (SDL_Window, hdc); + ReleaseDC(SDL_Window, hdc); #endif /* !NO_GAMMA_SUPPORT */ } void -DIB_SwapGamma (_THIS) +DIB_SwapGamma(_THIS) { #ifndef NO_GAMMA_SUPPORT HDC hdc; if (gamma_saved) { - hdc = GetDC (SDL_Window); - if (SDL_GetAppState () & SDL_APPINPUTFOCUS) { + hdc = GetDC(SDL_Window); + if (SDL_GetAppState() & SDL_APPINPUTFOCUS) { /* About to leave active state, restore gamma */ - SetDeviceGammaRamp (hdc, gamma_saved); + SetDeviceGammaRamp(hdc, gamma_saved); } else { /* About to enter active state, set game gamma */ - GetDeviceGammaRamp (hdc, gamma_saved); - SetDeviceGammaRamp (hdc, this->gamma); + GetDeviceGammaRamp(hdc, gamma_saved); + SetDeviceGammaRamp(hdc, this->gamma); } - ReleaseDC (SDL_Window, hdc); + ReleaseDC(SDL_Window, hdc); } #endif /* !NO_GAMMA_SUPPORT */ } void -DIB_QuitGamma (_THIS) +DIB_QuitGamma(_THIS) { #ifndef NO_GAMMA_SUPPORT if (gamma_saved) { /* Restore the original gamma if necessary */ - if (SDL_GetAppState () & SDL_APPINPUTFOCUS) { + if (SDL_GetAppState() & SDL_APPINPUTFOCUS) { HDC hdc; - hdc = GetDC (SDL_Window); - SetDeviceGammaRamp (hdc, gamma_saved); - ReleaseDC (SDL_Window, hdc); + hdc = GetDC(SDL_Window); + SetDeviceGammaRamp(hdc, gamma_saved); + ReleaseDC(SDL_Window, hdc); } /* Free the saved gamma memory */ - SDL_free (gamma_saved); + SDL_free(gamma_saved); gamma_saved = 0; } #endif /* !NO_GAMMA_SUPPORT */ } int -DIB_SetGammaRamp (_THIS, Uint16 * ramp) +DIB_SetGammaRamp(_THIS, Uint16 * ramp) { #ifdef NO_GAMMA_SUPPORT - SDL_SetError ("SDL compiled without gamma ramp support"); + SDL_SetError("SDL compiled without gamma ramp support"); return -1; #else HDC hdc; @@ -1010,19 +1009,19 @@ /* Set the ramp for the display */ if (!gamma_saved) { - gamma_saved = (WORD *) SDL_malloc (3 * 256 * sizeof (*gamma_saved)); + gamma_saved = (WORD *) SDL_malloc(3 * 256 * sizeof(*gamma_saved)); if (!gamma_saved) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return -1; } - hdc = GetDC (SDL_Window); - GetDeviceGammaRamp (hdc, gamma_saved); - ReleaseDC (SDL_Window, hdc); + hdc = GetDC(SDL_Window); + GetDeviceGammaRamp(hdc, gamma_saved); + ReleaseDC(SDL_Window, hdc); } - if (SDL_GetAppState () & SDL_APPINPUTFOCUS) { - hdc = GetDC (SDL_Window); - succeeded = SetDeviceGammaRamp (hdc, ramp); - ReleaseDC (SDL_Window, hdc); + if (SDL_GetAppState() & SDL_APPINPUTFOCUS) { + hdc = GetDC(SDL_Window); + succeeded = SetDeviceGammaRamp(hdc, ramp); + ReleaseDC(SDL_Window, hdc); } else { succeeded = TRUE; } @@ -1031,25 +1030,25 @@ } int -DIB_GetGammaRamp (_THIS, Uint16 * ramp) +DIB_GetGammaRamp(_THIS, Uint16 * ramp) { #ifdef NO_GAMMA_SUPPORT - SDL_SetError ("SDL compiled without gamma ramp support"); + SDL_SetError("SDL compiled without gamma ramp support"); return -1; #else HDC hdc; BOOL succeeded; /* Get the ramp from the display */ - hdc = GetDC (SDL_Window); - succeeded = GetDeviceGammaRamp (hdc, ramp); - ReleaseDC (SDL_Window, hdc); + hdc = GetDC(SDL_Window); + succeeded = GetDeviceGammaRamp(hdc, ramp); + ReleaseDC(SDL_Window, hdc); return succeeded ? 0 : -1; #endif /* !NO_GAMMA_SUPPORT */ } void -DIB_VideoQuit (_THIS) +DIB_VideoQuit(_THIS) { /* Destroy the window and everything associated with it */ if (SDL_Window) { @@ -1057,25 +1056,25 @@ if (this->screen) { #ifndef NO_CHANGEDISPLAYSETTINGS if (this->screen->flags & SDL_FULLSCREEN) { - ChangeDisplaySettings (NULL, 0); - ShowWindow (SDL_Window, SW_HIDE); + ChangeDisplaySettings(NULL, 0); + ShowWindow(SDL_Window, SW_HIDE); } #endif if (this->screen->flags & SDL_INTERNALOPENGL) { - WIN_GL_ShutDown (this); + WIN_GL_ShutDown(this); } this->screen->pixels = NULL; } if (screen_bmp) { - DeleteObject (screen_bmp); + DeleteObject(screen_bmp); screen_bmp = NULL; } if (screen_icn) { - DestroyIcon (screen_icn); + DestroyIcon(screen_icn); screen_icn = NULL; } - DIB_QuitGamma (this); - DIB_DestroyWindow (this); + DIB_QuitGamma(this); + DIB_DestroyWindow(this); SDL_Window = NULL; @@ -1083,7 +1082,7 @@ // Unload wince aygshell library to prevent leak if (aygshell) { - FreeLibrary (aygshell); + FreeLibrary(aygshell); aygshell = NULL; } #endif @@ -1093,51 +1092,51 @@ /* Exported for the windows message loop only */ static void -DIB_FocusPalette (_THIS, int foreground) +DIB_FocusPalette(_THIS, int foreground) { if (screen_pal != NULL) { HDC hdc; - hdc = GetDC (SDL_Window); - SelectPalette (hdc, screen_pal, FALSE); - if (RealizePalette (hdc)) - InvalidateRect (SDL_Window, NULL, FALSE); - ReleaseDC (SDL_Window, hdc); + hdc = GetDC(SDL_Window); + SelectPalette(hdc, screen_pal, FALSE); + if (RealizePalette(hdc)) + InvalidateRect(SDL_Window, NULL, FALSE); + ReleaseDC(SDL_Window, hdc); } } static void -DIB_RealizePalette (_THIS) +DIB_RealizePalette(_THIS) { - DIB_FocusPalette (this, 1); + DIB_FocusPalette(this, 1); } static void -DIB_PaletteChanged (_THIS, HWND window) +DIB_PaletteChanged(_THIS, HWND window) { if (window != SDL_Window) { - DIB_FocusPalette (this, 0); + DIB_FocusPalette(this, 0); } } /* Exported for the windows message loop only */ static void -DIB_WinPAINT (_THIS, HDC hdc) +DIB_WinPAINT(_THIS, HDC hdc) { HDC mdc; if (screen_pal) { - SelectPalette (hdc, screen_pal, FALSE); + SelectPalette(hdc, screen_pal, FALSE); } - mdc = CreateCompatibleDC (hdc); - SelectObject (mdc, screen_bmp); - BitBlt (hdc, 0, 0, SDL_VideoSurface->w, SDL_VideoSurface->h, - mdc, 0, 0, SRCCOPY); - DeleteDC (mdc); + mdc = CreateCompatibleDC(hdc); + SelectObject(mdc, screen_bmp); + BitBlt(hdc, 0, 0, SDL_VideoSurface->w, SDL_VideoSurface->h, + mdc, 0, 0, SRCCOPY); + DeleteDC(mdc); } /* Stub in case DirectX isn't available */ #if !SDL_AUDIO_DRIVER_DSOUND void -DX5_SoundFocus (HWND hwnd) +DX5_SoundFocus(HWND hwnd) { return; } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/windx5/SDL_dx5events.c --- a/src/video/windx5/SDL_dx5events.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/windx5/SDL_dx5events.c Mon May 29 04:04:35 2006 +0000 @@ -57,8 +57,8 @@ /* The translation table from a DirectInput scancode to an SDL keysym */ static SDLKey DIK_keymap[256]; -static SDL_keysym *TranslateKey (UINT scancode, SDL_keysym * keysym, - int pressed); +static SDL_keysym *TranslateKey(UINT scancode, SDL_keysym * keysym, + int pressed); /* DJM: If the user setup the window for us, we want to save his window proc, and give him a chance to handle some messages. */ @@ -70,11 +70,11 @@ static WNDPROCTYPE userWindowProc = NULL; static HWND -GetTopLevelParent (HWND hWnd) +GetTopLevelParent(HWND hWnd) { HWND hParentWnd; while (1) { - hParentWnd = GetParent (hWnd); + hParentWnd = GetParent(hWnd); if (hParentWnd == NULL) break; hWnd = hParentWnd; @@ -84,7 +84,7 @@ /* Convert a DirectInput return code to a text message */ static void -SetDIerror (char *function, int code) +SetDIerror(char *function, int code) { static char *error; static char errbuf[1024]; @@ -113,15 +113,15 @@ error = "Device not initialized"; break; default: - SDL_snprintf (errbuf, SDL_arraysize (errbuf), - "%s: Unknown DirectInput error: 0x%x", function, code); + SDL_snprintf(errbuf, SDL_arraysize(errbuf), + "%s: Unknown DirectInput error: 0x%x", function, code); break; } if (!errbuf[0]) { - SDL_snprintf (errbuf, SDL_arraysize (errbuf), "%s: %s", function, - error); + SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, + error); } - SDL_SetError ("%s", errbuf); + SDL_SetError("%s", errbuf); return; } @@ -130,9 +130,8 @@ windows input messages will continue to be generated for that input device, in addition to DirectInput messages. */ -static void handle_keyboard (const int numevents, - DIDEVICEOBJECTDATA * events); -static void handle_mouse (const int numevents, DIDEVICEOBJECTDATA * events); +static void handle_keyboard(const int numevents, DIDEVICEOBJECTDATA * events); +static void handle_mouse(const int numevents, DIDEVICEOBJECTDATA * events); struct { char *name; @@ -155,7 +154,7 @@ }; static int -DX5_DInputInit (_THIS) +DX5_DInputInit(_THIS) { int i; LPDIRECTINPUTDEVICE device; @@ -164,9 +163,9 @@ HWND topwnd; /* Create the DirectInput object */ - result = DInputCreate (SDL_Instance, DIRECTINPUT_VERSION, &dinput, NULL); + result = DInputCreate(SDL_Instance, DIRECTINPUT_VERSION, &dinput, NULL); if (result != DI_OK) { - SetDIerror ("DirectInputCreate", result); + SetDIerror("DirectInputCreate", result); return (-1); } @@ -174,74 +173,72 @@ SDL_DIndev = 0; for (i = 0; inputs[i].name; ++i) { /* Create the DirectInput device */ - result = IDirectInput_CreateDevice (dinput, inputs[i].guid, - &device, NULL); + result = IDirectInput_CreateDevice(dinput, inputs[i].guid, + &device, NULL); if (result != DI_OK) { - SetDIerror ("DirectInput::CreateDevice", result); + SetDIerror("DirectInput::CreateDevice", result); return (-1); } - result = IDirectInputDevice_QueryInterface (device, - &IID_IDirectInputDevice2, - (LPVOID *) & - SDL_DIdev[i]); - IDirectInputDevice_Release (device); + result = IDirectInputDevice_QueryInterface(device, + &IID_IDirectInputDevice2, + (LPVOID *) & SDL_DIdev[i]); + IDirectInputDevice_Release(device); if (result != DI_OK) { - SetDIerror ("DirectInputDevice::QueryInterface", result); + SetDIerror("DirectInputDevice::QueryInterface", result); return (-1); } - topwnd = GetTopLevelParent (SDL_Window); - result = IDirectInputDevice2_SetCooperativeLevel (SDL_DIdev[i], - topwnd, - inputs[i]. - win_level); + topwnd = GetTopLevelParent(SDL_Window); + result = IDirectInputDevice2_SetCooperativeLevel(SDL_DIdev[i], + topwnd, + inputs[i].win_level); if (result != DI_OK) { - SetDIerror ("DirectInputDevice::SetCooperativeLevel", result); + SetDIerror("DirectInputDevice::SetCooperativeLevel", result); return (-1); } - result = IDirectInputDevice2_SetDataFormat (SDL_DIdev[i], - inputs[i].format); + result = IDirectInputDevice2_SetDataFormat(SDL_DIdev[i], + inputs[i].format); if (result != DI_OK) { - SetDIerror ("DirectInputDevice::SetDataFormat", result); + SetDIerror("DirectInputDevice::SetDataFormat", result); return (-1); } /* Set buffered input -- we aren't polling */ - SDL_memset (&dipdw, 0, sizeof (dipdw)); - dipdw.diph.dwSize = sizeof (dipdw); - dipdw.diph.dwHeaderSize = sizeof (dipdw.diph); + SDL_memset(&dipdw, 0, sizeof(dipdw)); + dipdw.diph.dwSize = sizeof(dipdw); + dipdw.diph.dwHeaderSize = sizeof(dipdw.diph); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = INPUT_QSIZE; - result = IDirectInputDevice2_SetProperty (SDL_DIdev[i], - DIPROP_BUFFERSIZE, - &dipdw.diph); + result = IDirectInputDevice2_SetProperty(SDL_DIdev[i], + DIPROP_BUFFERSIZE, + &dipdw.diph); if (result != DI_OK) { - SetDIerror ("DirectInputDevice::SetProperty", result); + SetDIerror("DirectInputDevice::SetProperty", result); return (-1); } /* Create an event to be signaled when input is ready */ - SDL_DIevt[i] = CreateEvent (NULL, FALSE, FALSE, NULL); + SDL_DIevt[i] = CreateEvent(NULL, FALSE, FALSE, NULL); if (SDL_DIevt[i] == NULL) { - SDL_SetError ("Couldn't create DirectInput event"); + SDL_SetError("Couldn't create DirectInput event"); return (-1); } - result = IDirectInputDevice2_SetEventNotification (SDL_DIdev[i], - SDL_DIevt[i]); + result = IDirectInputDevice2_SetEventNotification(SDL_DIdev[i], + SDL_DIevt[i]); if (result != DI_OK) { - SetDIerror ("DirectInputDevice::SetEventNotification", result); + SetDIerror("DirectInputDevice::SetEventNotification", result); return (-1); } SDL_DIfun[i] = inputs[i].fun; /* Acquire the device for input */ - IDirectInputDevice2_Acquire (SDL_DIdev[i]); + IDirectInputDevice2_Acquire(SDL_DIdev[i]); /* Increment the number of devices we have */ ++SDL_DIndev; } mouse_pressed = 0; - mouse_buttons_swapped = GetSystemMetrics (SM_SWAPBUTTON); + mouse_buttons_swapped = GetSystemMetrics(SM_SWAPBUTTON); /* DirectInput is ready! */ return (0); @@ -249,7 +246,7 @@ /* Clean up DirectInput */ static void -DX5_DInputQuit (_THIS) +DX5_DInputQuit(_THIS) { int i; @@ -257,18 +254,18 @@ /* Close and release all DirectInput devices */ for (i = 0; i < MAX_INPUTS; ++i) { if (SDL_DIdev[i] != NULL) { - IDirectInputDevice2_Unacquire (SDL_DIdev[i]); - IDirectInputDevice2_SetEventNotification (SDL_DIdev[i], NULL); + IDirectInputDevice2_Unacquire(SDL_DIdev[i]); + IDirectInputDevice2_SetEventNotification(SDL_DIdev[i], NULL); if (SDL_DIevt[i] != NULL) { - CloseHandle (SDL_DIevt[i]); + CloseHandle(SDL_DIevt[i]); SDL_DIevt[i] = NULL; } - IDirectInputDevice2_Release (SDL_DIdev[i]); + IDirectInputDevice2_Release(SDL_DIdev[i]); SDL_DIdev[i] = NULL; } } /* Release DirectInput */ - IDirectInput_Release (dinput); + IDirectInput_Release(dinput); dinput = NULL; } } @@ -278,7 +275,7 @@ /* Input event handler functions */ static void -handle_keyboard (const int numevents, DIDEVICEOBJECTDATA * keybuf) +handle_keyboard(const int numevents, DIDEVICEOBJECTDATA * keybuf) { int i; SDL_keysym keysym; @@ -286,18 +283,18 @@ /* Translate keyboard messages */ for (i = 0; i < numevents; ++i) { if (keybuf[i].dwData & 0x80) { - posted = SDL_PrivateKeyboard (SDL_PRESSED, - TranslateKey (keybuf[i].dwOfs, - &keysym, 1)); + posted = SDL_PrivateKeyboard(SDL_PRESSED, + TranslateKey(keybuf[i].dwOfs, + &keysym, 1)); } else { - posted = SDL_PrivateKeyboard (SDL_RELEASED, - TranslateKey (keybuf[i].dwOfs, - &keysym, 0)); + posted = SDL_PrivateKeyboard(SDL_RELEASED, + TranslateKey(keybuf[i].dwOfs, + &keysym, 0)); } } } static void -handle_mouse (const int numevents, DIDEVICEOBJECTDATA * ptrbuf) +handle_mouse(const int numevents, DIDEVICEOBJECTDATA * ptrbuf) { int i; Sint16 xrel, yrel; @@ -323,25 +320,25 @@ Uint8 new_state; /* Set ourselves up with the current cursor position */ - GetCursorPos (&mouse_pos); - ScreenToClient (SDL_Window, &mouse_pos); - posted = SDL_PrivateMouseMotion (0, 0, - (Sint16) mouse_pos.x, - (Sint16) mouse_pos.y); + GetCursorPos(&mouse_pos); + ScreenToClient(SDL_Window, &mouse_pos); + posted = SDL_PrivateMouseMotion(0, 0, + (Sint16) mouse_pos.x, + (Sint16) mouse_pos.y); /* Check for mouse button changes */ - old_state = SDL_GetMouseState (NULL, NULL); + old_state = SDL_GetMouseState(NULL, NULL); new_state = 0; { /* Get the new DirectInput button state for the mouse */ DIMOUSESTATE distate; HRESULT result; - result = IDirectInputDevice2_GetDeviceState (SDL_DIdev[1], - sizeof (distate), - &distate); + result = IDirectInputDevice2_GetDeviceState(SDL_DIdev[1], + sizeof(distate), + &distate); if (result != DI_OK) { /* Try again next time */ - SetDIerror ("IDirectInputDevice2::GetDeviceState", result); + SetDIerror("IDirectInputDevice2::GetDeviceState", result); return; } for (i = 3; i >= 0; --i) { @@ -365,13 +362,13 @@ if (new_state & 0x01) { /* Grab mouse so we get mouse-up */ if (++mouse_pressed > 0) { - SetCapture (SDL_Window); + SetCapture(SDL_Window); } state = SDL_PRESSED; } else { /* Release mouse after all mouse-ups */ if (--mouse_pressed <= 0) { - ReleaseCapture (); + ReleaseCapture(); mouse_pressed = 0; } state = SDL_RELEASED; @@ -382,7 +379,7 @@ else if (button == 3) button = 1; } - posted = SDL_PrivateMouseButton (state, button, 0, 0); + posted = SDL_PrivateMouseButton(state, button, 0, 0); } old_state >>= 1; new_state >>= 1; @@ -399,7 +396,7 @@ case DIMOFS_X: if (timestamp != ptrbuf[i].dwTimeStamp) { if (xrel || yrel) { - posted = SDL_PrivateMouseMotion (0, 1, xrel, yrel); + posted = SDL_PrivateMouseMotion(0, 1, xrel, yrel); xrel = 0; yrel = 0; } @@ -410,7 +407,7 @@ case DIMOFS_Y: if (timestamp != ptrbuf[i].dwTimeStamp) { if (xrel || yrel) { - posted = SDL_PrivateMouseMotion (0, 1, xrel, yrel); + posted = SDL_PrivateMouseMotion(0, 1, xrel, yrel); xrel = 0; yrel = 0; } @@ -420,7 +417,7 @@ break; case DIMOFS_Z: if (xrel || yrel) { - posted = SDL_PrivateMouseMotion (0, 1, xrel, yrel); + posted = SDL_PrivateMouseMotion(0, 1, xrel, yrel); xrel = 0; yrel = 0; } @@ -429,15 +426,15 @@ button = SDL_BUTTON_WHEELUP; else button = SDL_BUTTON_WHEELDOWN; - posted = SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0); - posted |= SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0); + posted = SDL_PrivateMouseButton(SDL_PRESSED, button, 0, 0); + posted |= SDL_PrivateMouseButton(SDL_RELEASED, button, 0, 0); break; case DIMOFS_BUTTON0: case DIMOFS_BUTTON1: case DIMOFS_BUTTON2: case DIMOFS_BUTTON3: if (xrel || yrel) { - posted = SDL_PrivateMouseMotion (0, 1, xrel, yrel); + posted = SDL_PrivateMouseMotion(0, 1, xrel, yrel); xrel = 0; yrel = 0; } @@ -454,13 +451,13 @@ if (ptrbuf[i].dwData & 0x80) { /* Grab mouse so we get mouse-up */ if (++mouse_pressed > 0) { - SetCapture (SDL_Window); + SetCapture(SDL_Window); } state = SDL_PRESSED; } else { /* Release mouse after all mouse-ups */ if (--mouse_pressed <= 0) { - ReleaseCapture (); + ReleaseCapture(); mouse_pressed = 0; } state = SDL_RELEASED; @@ -471,18 +468,18 @@ else if (button == 3) button = 1; } - posted = SDL_PrivateMouseButton (state, button, 0, 0); + posted = SDL_PrivateMouseButton(state, button, 0, 0); break; } } if (xrel || yrel) { - posted = SDL_PrivateMouseMotion (0, 1, xrel, yrel); + posted = SDL_PrivateMouseMotion(0, 1, xrel, yrel); } } /* The main Win32 event handler */ LRESULT -DX5_HandleMessage (_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +DX5_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { #ifdef WM_ACTIVATEAPP @@ -490,14 +487,14 @@ { int i, active; - active = (wParam && (GetForegroundWindow () == hwnd)); + active = (wParam && (GetForegroundWindow() == hwnd)); if (active) { for (i = 0; SDL_DIdev[i]; ++i) { - IDirectInputDevice2_Acquire (SDL_DIdev[i]); + IDirectInputDevice2_Acquire(SDL_DIdev[i]); } } else { for (i = 0; SDL_DIdev[i]; ++i) { - IDirectInputDevice2_Unacquire (SDL_DIdev[i]); + IDirectInputDevice2_Unacquire(SDL_DIdev[i]); } mouse_lost = 1; } @@ -512,8 +509,8 @@ WORD SizeX, SizeY; /* Ack! The display changed size and/or depth! */ - SizeX = LOWORD (lParam); - SizeY = HIWORD (lParam); + SizeX = LOWORD(lParam); + SizeY = HIWORD(lParam); BitsPerPixel = wParam; /* We cause this message when we go fullscreen */ } @@ -558,25 +555,25 @@ if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) { SDL_SysWMmsg wmmsg; - SDL_VERSION (&wmmsg.version); + SDL_VERSION(&wmmsg.version); wmmsg.hwnd = hwnd; wmmsg.msg = msg; wmmsg.wParam = wParam; wmmsg.lParam = lParam; - posted = SDL_PrivateSysWMEvent (&wmmsg); + posted = SDL_PrivateSysWMEvent(&wmmsg); /* DJM: If the user isn't watching for private messages in her SDL event loop, then pass it along to any win32 specific window proc. */ } else if (userWindowProc) { - return CallWindowProc (userWindowProc, hwnd, msg, wParam, - lParam); + return CallWindowProc(userWindowProc, hwnd, msg, wParam, + lParam); } } break; } - return (DefWindowProc (hwnd, msg, wParam, lParam)); + return (DefWindowProc(hwnd, msg, wParam, lParam)); } /* This function checks the windows message queue and DirectInput and returns @@ -584,7 +581,7 @@ posted a quit message. */ static int -DX5_CheckInput (_THIS, int timeout, BOOL processInput) +DX5_CheckInput(_THIS, int timeout, BOOL processInput) { MSG msg; int i; @@ -593,9 +590,9 @@ /* Check the normal windows queue (highest preference) */ posted = 0; - while (!posted && PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)) { - if (GetMessage (&msg, NULL, 0, 0) > 0) { - DispatchMessage (&msg); + while (!posted && PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { + if (GetMessage(&msg, NULL, 0, 0) > 0) { + DispatchMessage(&msg); } else { return (-1); } @@ -605,22 +602,22 @@ } /* Pump the DirectInput flow */ - if (SDL_GetAppState () & SDL_APPINPUTFOCUS) { + if (SDL_GetAppState() & SDL_APPINPUTFOCUS) { for (i = 0; i < SDL_DIndev; ++i) { - result = IDirectInputDevice2_Poll (SDL_DIdev[i]); + result = IDirectInputDevice2_Poll(SDL_DIdev[i]); if ((result == DIERR_INPUTLOST) || (result == DIERR_NOTACQUIRED)) { - if (SDL_strcmp (inputs[i].name, "mouse") == 0) { + if (SDL_strcmp(inputs[i].name, "mouse") == 0) { mouse_lost = 1; } - IDirectInputDevice2_Acquire (SDL_DIdev[i]); - IDirectInputDevice2_Poll (SDL_DIdev[i]); + IDirectInputDevice2_Acquire(SDL_DIdev[i]); + IDirectInputDevice2_Poll(SDL_DIdev[i]); } } } /* Wait for messages and input events */ - event = MsgWaitForMultipleObjects (SDL_DIndev, SDL_DIevt, FALSE, - timeout, QS_ALLEVENTS); + event = MsgWaitForMultipleObjects(SDL_DIndev, SDL_DIevt, FALSE, + timeout, QS_ALLEVENTS); if ((event >= WAIT_OBJECT_0) && (event < (WAIT_OBJECT_0 + SDL_DIndev))) { DWORD numevents; static DIDEVICEOBJECTDATA evtbuf[INPUT_QSIZE]; @@ -628,19 +625,19 @@ event -= WAIT_OBJECT_0; numevents = INPUT_QSIZE; result = - IDirectInputDevice2_GetDeviceData (SDL_DIdev[event], - sizeof (DIDEVICEOBJECTDATA), - evtbuf, &numevents, 0); + IDirectInputDevice2_GetDeviceData(SDL_DIdev[event], + sizeof(DIDEVICEOBJECTDATA), + evtbuf, &numevents, 0); if ((result == DIERR_INPUTLOST) || (result == DIERR_NOTACQUIRED)) { - if (SDL_strcmp (inputs[event].name, "mouse") == 0) { + if (SDL_strcmp(inputs[event].name, "mouse") == 0) { mouse_lost = 1; } - IDirectInputDevice2_Acquire (SDL_DIdev[event]); + IDirectInputDevice2_Acquire(SDL_DIdev[event]); result = - IDirectInputDevice2_GetDeviceData (SDL_DIdev[event], - sizeof - (DIDEVICEOBJECTDATA), - evtbuf, &numevents, 0); + IDirectInputDevice2_GetDeviceData(SDL_DIdev[event], + sizeof + (DIDEVICEOBJECTDATA), + evtbuf, &numevents, 0); } /* Handle the events */ if (result == DI_OK && processInput) { @@ -652,9 +649,9 @@ } if (event != WAIT_TIMEOUT) { /* Maybe there was a windows message? */ - if (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)) { - if (GetMessage (&msg, NULL, 0, 0) > 0) { - DispatchMessage (&msg); + if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { + if (GetMessage(&msg, NULL, 0, 0) > 0) { + DispatchMessage(&msg); } else { return (-1); } @@ -666,7 +663,7 @@ /* Change cooperative level based on whether or not we are fullscreen */ void -DX5_DInputReset (_THIS, int fullscreen) +DX5_DInputReset(_THIS, int fullscreen) { DWORD level; int i; @@ -680,34 +677,34 @@ } else { level = inputs[i].win_level; } - IDirectInputDevice2_Unacquire (SDL_DIdev[i]); - topwnd = GetTopLevelParent (SDL_Window); + IDirectInputDevice2_Unacquire(SDL_DIdev[i]); + topwnd = GetTopLevelParent(SDL_Window); result = - IDirectInputDevice2_SetCooperativeLevel (SDL_DIdev[i], - topwnd, level); - IDirectInputDevice2_Acquire (SDL_DIdev[i]); + IDirectInputDevice2_SetCooperativeLevel(SDL_DIdev[i], + topwnd, level); + IDirectInputDevice2_Acquire(SDL_DIdev[i]); if (result != DI_OK) { - SetDIerror ("DirectInputDevice::SetCooperativeLevel", result); + SetDIerror("DirectInputDevice::SetCooperativeLevel", result); } } } mouse_lost = 1; /* Flush pending input */ - DX5_CheckInput (this, 0, FALSE); + DX5_CheckInput(this, 0, FALSE); } void -DX5_PumpEvents (_THIS) +DX5_PumpEvents(_THIS) { /* Wait for messages and DirectInput */ - while (DX5_CheckInput (this, 0, TRUE) > 0) { + while (DX5_CheckInput(this, 0, TRUE) > 0) { /* Loop and check again */ ; } } void -DX5_InitOSKeymap (_THIS) +DX5_InitOSKeymap(_THIS) { #ifndef DIK_PAUSE #define DIK_PAUSE 0xC5 @@ -718,7 +715,7 @@ int i; /* Map the DIK scancodes to SDL keysyms */ - for (i = 0; i < SDL_arraysize (DIK_keymap); ++i) + for (i = 0; i < SDL_arraysize(DIK_keymap); ++i) DIK_keymap[i] = 0; /* Defined DIK_* constants */ @@ -836,7 +833,7 @@ } static SDL_keysym * -TranslateKey (UINT scancode, SDL_keysym * keysym, int pressed) +TranslateKey(UINT scancode, SDL_keysym * keysym, int pressed) { /* Set the keysym information */ keysym->scancode = (unsigned char) scancode; @@ -850,15 +847,15 @@ Uint16 wchars[2]; #endif - vkey = MapVirtualKey (scancode, 1); + vkey = MapVirtualKey(scancode, 1); #ifdef NO_GETKEYBOARDSTATE /* Uh oh, better hope the vkey is close enough.. */ keysym->unicode = vkey; #else - GetKeyboardState (keystate); + GetKeyboardState(keystate); if (SDL_ToUnicode (vkey, scancode, keystate, wchars, - sizeof (wchars) / sizeof (wchars[0]), 0) == 1) { + sizeof(wchars) / sizeof(wchars[0]), 0) == 1) { keysym->unicode = wchars[0]; } #endif /* NO_GETKEYBOARDSTATE */ @@ -867,9 +864,9 @@ } int -DX5_CreateWindow (_THIS) +DX5_CreateWindow(_THIS) { - char *windowid = SDL_getenv ("SDL_WINDOWID"); + char *windowid = SDL_getenv("SDL_WINDOWID"); int i; /* Clear out DirectInput variables in case we fail */ @@ -879,13 +876,13 @@ SDL_DIfun[i] = NULL; } - SDL_RegisterApp (NULL, 0, 0); + SDL_RegisterApp(NULL, 0, 0); SDL_windowid = (windowid != NULL); if (SDL_windowid) { - SDL_Window = (HWND) SDL_strtoull (windowid, NULL, 0); + SDL_Window = (HWND) SDL_strtoull(windowid, NULL, 0); if (SDL_Window == NULL) { - SDL_SetError ("Couldn't get user specified window"); + SDL_SetError("Couldn't get user specified window"); return (-1); } @@ -893,23 +890,23 @@ window to be handled by SDL. */ userWindowProc = - (WNDPROCTYPE) GetWindowLongPtr (SDL_Window, GWLP_WNDPROC); - SetWindowLongPtr (SDL_Window, GWLP_WNDPROC, (LONG_PTR) WinMessage); + (WNDPROCTYPE) GetWindowLongPtr(SDL_Window, GWLP_WNDPROC); + SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR) WinMessage); } else { - SDL_Window = CreateWindow (SDL_Appname, SDL_Appname, - (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU - | WS_MINIMIZEBOX), CW_USEDEFAULT, - CW_USEDEFAULT, 0, 0, NULL, NULL, - SDL_Instance, NULL); + SDL_Window = CreateWindow(SDL_Appname, SDL_Appname, + (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU + | WS_MINIMIZEBOX), CW_USEDEFAULT, + CW_USEDEFAULT, 0, 0, NULL, NULL, + SDL_Instance, NULL); if (SDL_Window == NULL) { - SDL_SetError ("Couldn't create window"); + SDL_SetError("Couldn't create window"); return (-1); } - ShowWindow (SDL_Window, SW_HIDE); + ShowWindow(SDL_Window, SW_HIDE); } /* Initialize DirectInput */ - if (DX5_DInputInit (this) < 0) { + if (DX5_DInputInit(this) < 0) { return (-1); } @@ -917,32 +914,31 @@ Flush the message loop or this can cause big problems later Especially if the user decides to use dialog boxes or assert()! */ - WIN_FlushMessageQueue (); + WIN_FlushMessageQueue(); /* Ready to roll */ return (0); } void -DX5_DestroyWindow (_THIS) +DX5_DestroyWindow(_THIS) { /* Close down DirectInput */ - DX5_DInputQuit (this); + DX5_DInputQuit(this); /* Destroy our window */ if (SDL_windowid) { - SetWindowLongPtr (SDL_Window, GWLP_WNDPROC, - (LONG_PTR) userWindowProc); + SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR) userWindowProc); } else { - DestroyWindow (SDL_Window); + DestroyWindow(SDL_Window); } - SDL_UnregisterApp (); + SDL_UnregisterApp(); /* JC 14 Mar 2006 Flush the message loop or this can cause big problems later Especially if the user decides to use dialog boxes or assert()! */ - WIN_FlushMessageQueue (); + WIN_FlushMessageQueue(); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/windx5/SDL_dx5events_c.h --- a/src/video/windx5/SDL_dx5events_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/windx5/SDL_dx5events_c.h Mon May 29 04:04:35 2006 +0000 @@ -27,11 +27,11 @@ of the native video subsystem (SDL_dx5video.c) */ extern LONG -DX5_HandleMessage (_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -extern int DX5_CreateWindow (_THIS); -extern void DX5_DestroyWindow (_THIS); +DX5_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +extern int DX5_CreateWindow(_THIS); +extern void DX5_DestroyWindow(_THIS); -extern void DX5_PumpEvents (_THIS); -extern void DX5_InitOSKeymap (_THIS); -extern void DX5_DInputReset (_THIS, int fullscreen); +extern void DX5_PumpEvents(_THIS); +extern void DX5_InitOSKeymap(_THIS); +extern void DX5_DInputReset(_THIS, int fullscreen); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/windx5/SDL_dx5video.c --- a/src/video/windx5/SDL_dx5video.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/windx5/SDL_dx5video.c Mon May 29 04:04:35 2006 +0000 @@ -56,10 +56,10 @@ /* DirectX function pointers for video and events */ -HRESULT (WINAPI * DDrawCreate) (GUID FAR * lpGUID, LPDIRECTDRAW FAR * lplpDD, - IUnknown FAR * pUnkOuter); -HRESULT (WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion, - LPDIRECTINPUT * ppDI, LPUNKNOWN punkOuter); +HRESULT(WINAPI * DDrawCreate) (GUID FAR * lpGUID, LPDIRECTDRAW FAR * lplpDD, + IUnknown FAR * pUnkOuter); +HRESULT(WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion, + LPDIRECTINPUT * ppDI, LPUNKNOWN punkOuter); /* This is the rect EnumModes2 uses */ struct DX5EnumRect @@ -406,41 +406,41 @@ /* Initialization/Query functions */ -static int DX5_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **DX5_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *DX5_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int DX5_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static int DX5_SetGammaRamp (_THIS, Uint16 * ramp); -static int DX5_GetGammaRamp (_THIS, Uint16 * ramp); -static void DX5_VideoQuit (_THIS); +static int DX5_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **DX5_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +static SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +static int DX5_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static int DX5_SetGammaRamp(_THIS, Uint16 * ramp); +static int DX5_GetGammaRamp(_THIS, Uint16 * ramp); +static void DX5_VideoQuit(_THIS); /* Hardware surface functions */ -static int DX5_AllocHWSurface (_THIS, SDL_Surface * surface); -static int DX5_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst); -static int DX5_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * dstrect, - Uint32 color); -static int DX5_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key); -static int DX5_SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 alpha); -static int DX5_LockHWSurface (_THIS, SDL_Surface * surface); -static void DX5_UnlockHWSurface (_THIS, SDL_Surface * surface); -static int DX5_FlipHWSurface (_THIS, SDL_Surface * surface); -static void DX5_FreeHWSurface (_THIS, SDL_Surface * surface); +static int DX5_AllocHWSurface(_THIS, SDL_Surface * surface); +static int DX5_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst); +static int DX5_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * dstrect, + Uint32 color); +static int DX5_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key); +static int DX5_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha); +static int DX5_LockHWSurface(_THIS, SDL_Surface * surface); +static void DX5_UnlockHWSurface(_THIS, SDL_Surface * surface); +static int DX5_FlipHWSurface(_THIS, SDL_Surface * surface); +static void DX5_FreeHWSurface(_THIS, SDL_Surface * surface); -static int DX5_AllocDDSurface (_THIS, SDL_Surface * surface, - LPDIRECTDRAWSURFACE3 requested, Uint32 flag); +static int DX5_AllocDDSurface(_THIS, SDL_Surface * surface, + LPDIRECTDRAWSURFACE3 requested, Uint32 flag); /* Windows message handling functions */ -static void DX5_RealizePalette (_THIS); -static void DX5_PaletteChanged (_THIS, HWND window); -static void DX5_WinPAINT (_THIS, HDC hdc); +static void DX5_RealizePalette(_THIS); +static void DX5_PaletteChanged(_THIS, HWND window); +static void DX5_WinPAINT(_THIS, HDC hdc); /* WinDIB driver functions for manipulating gamma ramps */ -extern int DIB_SetGammaRamp (_THIS, Uint16 * ramp); -extern int DIB_GetGammaRamp (_THIS, Uint16 * ramp); -extern void DIB_QuitGamma (_THIS); +extern int DIB_SetGammaRamp(_THIS, Uint16 * ramp); +extern int DIB_GetGammaRamp(_THIS, Uint16 * ramp); +extern void DIB_QuitGamma(_THIS); /* Functions for loading the DirectX functions dynamically */ static int DX5_loaded = 0; @@ -448,42 +448,42 @@ static HINSTANCE DInputDLL = NULL; void -DX5_Unload (void) +DX5_Unload(void) { if (--DX5_loaded == 0) { if (DDrawDLL != NULL) { - FreeLibrary (DDrawDLL); + FreeLibrary(DDrawDLL); DDrawCreate = NULL; DDrawDLL = NULL; } if (DInputDLL != NULL) { - FreeLibrary (DInputDLL); + FreeLibrary(DInputDLL); DInputCreate = NULL; DInputDLL = NULL; } } } int -DX5_Load (void) +DX5_Load(void) { int status = 0; if (++DX5_loaded == 1) { - DDrawDLL = LoadLibrary (TEXT ("DDRAW.DLL")); + DDrawDLL = LoadLibrary(TEXT("DDRAW.DLL")); if (DDrawDLL != NULL) { - DDrawCreate = (void *) GetProcAddress (DDrawDLL, - TEXT ("DirectDrawCreate")); + DDrawCreate = (void *) GetProcAddress(DDrawDLL, + TEXT("DirectDrawCreate")); } - DInputDLL = LoadLibrary (TEXT ("DINPUT.DLL")); + DInputDLL = LoadLibrary(TEXT("DINPUT.DLL")); if (DInputDLL != NULL) { - DInputCreate = (void *) GetProcAddress (DInputDLL, - TEXT - ("DirectInputCreateA")); + DInputCreate = (void *) GetProcAddress(DInputDLL, + TEXT + ("DirectInputCreateA")); } if (DDrawDLL && DDrawCreate && DInputDLL && DInputCreate) { status = 0; } else { - DX5_Unload (); + DX5_Unload(); status = -1; } } @@ -493,36 +493,34 @@ /* DX5 driver bootstrap functions */ static int -DX5_Available (void) +DX5_Available(void) { int ddraw_ok = 0; - HRESULT (WINAPI * DDrawCreate) (GUID *, LPDIRECTDRAW *, IUnknown *); + HRESULT(WINAPI * DDrawCreate) (GUID *, LPDIRECTDRAW *, IUnknown *); LPDIRECTDRAW DDraw; /* Version check DINPUT.DLL and DDRAW.DLL (Is DirectX okay?) */ - if (DX5_Load () < 0) { + if (DX5_Load() < 0) { return -1; } /* Try to create a valid DirectDraw object */ - DDrawCreate = - (void *) GetProcAddress (DDrawDLL, TEXT ("DirectDrawCreate")); - if ((DDrawCreate != NULL) && !FAILED (DDrawCreate (NULL, &DDraw, NULL))) { - if (!FAILED (IDirectDraw_SetCooperativeLevel (DDraw, - NULL, DDSCL_NORMAL))) { + DDrawCreate = (void *) GetProcAddress(DDrawDLL, TEXT("DirectDrawCreate")); + if ((DDrawCreate != NULL) && !FAILED(DDrawCreate(NULL, &DDraw, NULL))) { + if (!FAILED(IDirectDraw_SetCooperativeLevel(DDraw, + NULL, DDSCL_NORMAL))) { DDSURFACEDESC desc; LPDIRECTDRAWSURFACE DDrawSurf; LPDIRECTDRAWSURFACE3 DDrawSurf3; /* Try to create a DirectDrawSurface3 object */ - SDL_memset (&desc, 0, sizeof (desc)); - desc.dwSize = sizeof (desc); + SDL_memset(&desc, 0, sizeof(desc)); + desc.dwSize = sizeof(desc); desc.dwFlags = DDSD_CAPS; desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_VIDEOMEMORY; if (!FAILED - (IDirectDraw_CreateSurface - (DDraw, &desc, &DDrawSurf, NULL))) { + (IDirectDraw_CreateSurface(DDraw, &desc, &DDrawSurf, NULL))) { if (!FAILED (IDirectDrawSurface_QueryInterface (DDrawSurf, &IID_IDirectDrawSurface3, @@ -531,66 +529,66 @@ ddraw_ok = 1; /* Clean up.. */ - IDirectDrawSurface3_Release (DDrawSurf3); + IDirectDrawSurface3_Release(DDrawSurf3); } - IDirectDrawSurface_Release (DDrawSurf); + IDirectDrawSurface_Release(DDrawSurf); } } - IDirectDraw_Release (DDraw); + IDirectDraw_Release(DDraw); } - DX5_Unload (); + DX5_Unload(); return ddraw_ok; } static void -DX5_DeleteDevice (SDL_VideoDevice * this) +DX5_DeleteDevice(SDL_VideoDevice * this) { /* Free DirectDraw object */ if (ddraw2 != NULL) { - IDirectDraw2_Release (ddraw2); + IDirectDraw2_Release(ddraw2); } - DX5_Unload (); + DX5_Unload(); if (this) { if (this->hidden) { - SDL_free (this->hidden); + SDL_free(this->hidden); } if (this->gl_data) { - SDL_free (this->gl_data); + SDL_free(this->gl_data); } - SDL_free (this); + SDL_free(this); } } static SDL_VideoDevice * -DX5_CreateDevice (int devindex) +DX5_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Load DirectX */ - if (DX5_Load () < 0) { + if (DX5_Load() < 0) { return (NULL); } /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); device->gl_data = (struct SDL_PrivateGLData *) - SDL_malloc ((sizeof *device->gl_data)); + SDL_malloc((sizeof *device->gl_data)); } if ((device == NULL) || (device->hidden == NULL) || (device->gl_data == NULL)) { - SDL_OutOfMemory (); - DX5_DeleteDevice (device); + SDL_OutOfMemory(); + DX5_DeleteDevice(device); return (NULL); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); - SDL_memset (device->gl_data, 0, (sizeof *device->gl_data)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->gl_data, 0, (sizeof *device->gl_data)); /* Set the function pointers */ device->VideoInit = DX5_VideoInit; @@ -650,7 +648,7 @@ }; static int -cmpmodes (const void *va, const void *vb) +cmpmodes(const void *va, const void *vb) { SDL_Rect *a = *(SDL_Rect **) va; SDL_Rect *b = *(SDL_Rect **) vb; @@ -661,7 +659,7 @@ } static HRESULT WINAPI -EnumModes2 (DDSURFACEDESC * desc, VOID * udata) +EnumModes2(DDSURFACEDESC * desc, VOID * udata) { SDL_VideoDevice *this = (SDL_VideoDevice *) udata; struct DX5EnumRect *enumrect; @@ -695,19 +693,19 @@ refreshRate <= maxRefreshRate) { enumlists[bpp]->refreshRate = refreshRate; #ifdef DDRAW_DEBUG - fprintf (stderr, - "New refresh rate for %d bpp: %dx%d at %d Hz\n", - (bpp + 1) * 8, (int) desc->dwWidth, - (int) desc->dwHeight, refreshRate); + fprintf(stderr, + "New refresh rate for %d bpp: %dx%d at %d Hz\n", + (bpp + 1) * 8, (int) desc->dwWidth, + (int) desc->dwHeight, refreshRate); #endif } break; } ++SDL_nummodes[bpp]; enumrect = - (struct DX5EnumRect *) SDL_malloc (sizeof (struct DX5EnumRect)); + (struct DX5EnumRect *) SDL_malloc(sizeof(struct DX5EnumRect)); if (!enumrect) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (DDENUMRET_CANCEL); } enumrect->refreshRate = refreshRate; @@ -718,9 +716,9 @@ enumrect->next = enumlists[bpp]; enumlists[bpp] = enumrect; #ifdef DDRAW_DEBUG - fprintf (stderr, "New mode for %d bpp: %dx%d at %d Hz\n", - (bpp + 1) * 8, (int) desc->dwWidth, (int) desc->dwHeight, - refreshRate); + fprintf(stderr, "New mode for %d bpp: %dx%d at %d Hz\n", + (bpp + 1) * 8, (int) desc->dwWidth, (int) desc->dwHeight, + refreshRate); #endif break; } @@ -729,7 +727,7 @@ } void -SetDDerror (const char *function, int code) +SetDDerror(const char *function, int code) { static char *error; static char errbuf[1024]; @@ -839,21 +837,21 @@ error = "Interface not present"; break; default: - SDL_snprintf (errbuf, SDL_arraysize (errbuf), - "%s: Unknown DirectDraw error: 0x%x", function, code); + SDL_snprintf(errbuf, SDL_arraysize(errbuf), + "%s: Unknown DirectDraw error: 0x%x", function, code); break; } if (!errbuf[0]) { - SDL_snprintf (errbuf, SDL_arraysize (errbuf), "%s: %s", function, - error); + SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, + error); } - SDL_SetError ("%s", errbuf); + SDL_SetError("%s", errbuf); return; } static int -DX5_UpdateVideoInfo (_THIS) +DX5_UpdateVideoInfo(_THIS) { /* This needs to be DDCAPS_DX5 for the DirectDraw2 interface */ #if DIRECTDRAW_VERSION <= 0x300 @@ -868,11 +866,11 @@ HRESULT result; /* Fill in our hardware acceleration capabilities */ - SDL_memset (&DDCaps, 0, sizeof (DDCaps)); - DDCaps.dwSize = sizeof (DDCaps); - result = IDirectDraw2_GetCaps (ddraw2, (DDCAPS *) & DDCaps, NULL); + SDL_memset(&DDCaps, 0, sizeof(DDCaps)); + DDCaps.dwSize = sizeof(DDCaps); + result = IDirectDraw2_GetCaps(ddraw2, (DDCAPS *) & DDCaps, NULL); if (result != DD_OK) { - SetDDerror ("DirectDraw2::GetCaps", result); + SetDDerror("DirectDraw2::GetCaps", result); return (-1); } this->info.hw_available = 1; @@ -904,8 +902,8 @@ DDSCAPS ddsCaps; DWORD total_mem; ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY; - result = IDirectDraw2_GetAvailableVidMem (ddraw2, - &ddsCaps, &total_mem, NULL); + result = IDirectDraw2_GetAvailableVidMem(ddraw2, + &ddsCaps, &total_mem, NULL); if (result != DD_OK) { total_mem = DDCaps.dwVidMemTotal; } @@ -915,7 +913,7 @@ } int -DX5_VideoInit (_THIS, SDL_PixelFormat * vformat) +DX5_VideoInit(_THIS, SDL_PixelFormat * vformat) { HRESULT result; LPDIRECTDRAW ddraw; @@ -935,36 +933,36 @@ colorchange_expected = 0; /* Create the window */ - if (DX5_CreateWindow (this) < 0) { + if (DX5_CreateWindow(this) < 0) { return (-1); } #if !SDL_AUDIO_DISABLED - DX5_SoundFocus (SDL_Window); + DX5_SoundFocus(SDL_Window); #endif /* Create the DirectDraw object */ - result = DDrawCreate (NULL, &ddraw, NULL); + result = DDrawCreate(NULL, &ddraw, NULL); if (result != DD_OK) { - SetDDerror ("DirectDrawCreate", result); + SetDDerror("DirectDrawCreate", result); return (-1); } - result = IDirectDraw_QueryInterface (ddraw, &IID_IDirectDraw2, - (LPVOID *) & ddraw2); - IDirectDraw_Release (ddraw); + result = IDirectDraw_QueryInterface(ddraw, &IID_IDirectDraw2, + (LPVOID *) & ddraw2); + IDirectDraw_Release(ddraw); if (result != DD_OK) { - SetDDerror ("DirectDraw::QueryInterface", result); + SetDDerror("DirectDraw::QueryInterface", result); return (-1); } /* Determine the screen depth */ - hdc = GetDC (SDL_Window); - vformat->BitsPerPixel = GetDeviceCaps (hdc, PLANES) * - GetDeviceCaps (hdc, BITSPIXEL); - ReleaseDC (SDL_Window, hdc); + hdc = GetDC(SDL_Window); + vformat->BitsPerPixel = GetDeviceCaps(hdc, PLANES) * + GetDeviceCaps(hdc, BITSPIXEL); + ReleaseDC(SDL_Window, hdc); #ifndef NO_CHANGEDISPLAYSETTINGS /* Query for the desktop resolution */ - EnumDisplaySettings (NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode); + EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode); this->info.current_w = SDL_desktop_mode.dmPelsWidth; this->info.current_h = SDL_desktop_mode.dmPelsHeight; #endif @@ -974,18 +972,18 @@ enumlists[i] = NULL; result = - IDirectDraw2_EnumDisplayModes (ddraw2, DDEDM_REFRESHRATES, NULL, this, - EnumModes2); + IDirectDraw2_EnumDisplayModes(ddraw2, DDEDM_REFRESHRATES, NULL, this, + EnumModes2); if (result != DD_OK) { - SetDDerror ("DirectDraw2::EnumDisplayModes", result); + SetDDerror("DirectDraw2::EnumDisplayModes", result); return (-1); } for (i = 0; i < NUM_MODELISTS; ++i) { struct DX5EnumRect *rect; SDL_modelist[i] = (SDL_Rect **) - SDL_malloc ((SDL_nummodes[i] + 1) * sizeof (SDL_Rect *)); + SDL_malloc((SDL_nummodes[i] + 1) * sizeof(SDL_Rect *)); if (SDL_modelist[i] == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } for (j = 0, rect = enumlists[i]; rect; ++j, rect = rect->next) { @@ -994,8 +992,8 @@ SDL_modelist[i][j] = NULL; if (SDL_nummodes[i] > 0) { - SDL_qsort (SDL_modelist[i], SDL_nummodes[i], - sizeof *SDL_modelist[i], cmpmodes); + SDL_qsort(SDL_modelist[i], SDL_nummodes[i], + sizeof *SDL_modelist[i], cmpmodes); } } @@ -1003,13 +1001,13 @@ this->info.wm_available = 1; /* Fill in the video hardware capabilities */ - DX5_UpdateVideoInfo (this); + DX5_UpdateVideoInfo(this); return (0); } SDL_Rect ** -DX5_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +DX5_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { int bpp; @@ -1038,12 +1036,12 @@ } /* Various screen update functions available */ -static void DX5_WindowUpdate (_THIS, int numrects, SDL_Rect * rects); -static void DX5_DirectUpdate (_THIS, int numrects, SDL_Rect * rects); +static void DX5_WindowUpdate(_THIS, int numrects, SDL_Rect * rects); +static void DX5_DirectUpdate(_THIS, int numrects, SDL_Rect * rects); SDL_Surface * -DX5_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +DX5_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { SDL_Surface *video; HRESULT result; @@ -1059,28 +1057,28 @@ SDL_resizing = 1; #ifdef DDRAW_DEBUG - fprintf (stderr, "Setting %dx%dx%d video mode\n", width, height, bpp); + fprintf(stderr, "Setting %dx%dx%d video mode\n", width, height, bpp); #endif /* Clean up any previous DirectDraw surfaces */ if (current->hwdata) { - this->FreeHWSurface (this, current); + this->FreeHWSurface(this, current); current->hwdata = NULL; } if (SDL_primary != NULL) { - IDirectDrawSurface3_Release (SDL_primary); + IDirectDrawSurface3_Release(SDL_primary); SDL_primary = NULL; } #ifndef NO_CHANGEDISPLAYSETTINGS /* Unset any previous OpenGL fullscreen mode */ if ((current->flags & (SDL_INTERNALOPENGL | SDL_FULLSCREEN)) == (SDL_INTERNALOPENGL | SDL_FULLSCREEN)) { - ChangeDisplaySettings (NULL, 0); + ChangeDisplaySettings(NULL, 0); } #endif /* Clean up any GL context that may be hanging around */ if (current->flags & SDL_INTERNALOPENGL) { - WIN_GL_ShutDown (this); + WIN_GL_ShutDown(this); } /* If we are setting a GL mode, use GDI, not DirectX (yuck) */ @@ -1119,10 +1117,10 @@ Bmask = 0x00000000; break; } - video = SDL_CreateRGBSurface (SDL_SWSURFACE, 0, 0, bpp, - Rmask, Gmask, Bmask, 0); + video = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, bpp, + Rmask, Gmask, Bmask, 0); if (video == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } } @@ -1131,7 +1129,7 @@ video->flags = 0; /* Clear flags */ video->w = width; video->h = height; - video->pitch = SDL_CalculatePitch (video); + video->pitch = SDL_CalculatePitch(video); #ifndef NO_CHANGEDISPLAYSETTINGS /* Set fullscreen mode if appropriate. @@ -1144,8 +1142,8 @@ DEVMODE settings; BOOL changed; - SDL_memset (&settings, 0, sizeof (DEVMODE)); - settings.dmSize = sizeof (DEVMODE); + SDL_memset(&settings, 0, sizeof(DEVMODE)); + settings.dmSize = sizeof(DEVMODE); settings.dmBitsPerPel = video->format->BitsPerPixel; settings.dmPelsWidth = width; settings.dmPelsHeight = height; @@ -1157,11 +1155,11 @@ settings.dmFields |= DM_DISPLAYFREQUENCY; } changed = - (ChangeDisplaySettings (&settings, CDS_FULLSCREEN) == + (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL); if (!changed && (settings.dmFields & DM_DISPLAYFREQUENCY)) { settings.dmFields &= ~DM_DISPLAYFREQUENCY; - changed = (ChangeDisplaySettings (&settings, CDS_FULLSCREEN) + changed = (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL); } if (changed) { @@ -1171,7 +1169,7 @@ } #endif /* !NO_CHANGEDISPLAYSETTINGS */ - style = GetWindowLong (SDL_Window, GWL_STYLE); + style = GetWindowLong(SDL_Window, GWL_STYLE); style &= ~(resizestyle | WS_MAXIMIZE); if (video->flags & SDL_FULLSCREEN) { style &= ~windowstyle; @@ -1190,17 +1188,17 @@ } } #if WS_MAXIMIZE - if (IsZoomed (SDL_Window)) + if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; #endif } /* DJM: Don't piss of anyone who has setup his own window */ if (!SDL_windowid) - SetWindowLong (SDL_Window, GWL_STYLE, style); + SetWindowLong(SDL_Window, GWL_STYLE, style); /* Resize the window (copied from SDL WinDIB driver) */ - if (!SDL_windowid && !IsZoomed (SDL_Window)) { + if (!SDL_windowid && !IsZoomed(SDL_Window)) { RECT bounds; int x, y; HWND top; @@ -1209,14 +1207,14 @@ const char *center = NULL; if (!SDL_windowX && !SDL_windowY) { - window = SDL_getenv ("SDL_VIDEO_WINDOW_POS"); - center = SDL_getenv ("SDL_VIDEO_CENTERED"); + window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); + center = SDL_getenv("SDL_VIDEO_CENTERED"); if (window) { - if (SDL_sscanf (window, "%d,%d", &x, &y) == 2) { + if (SDL_sscanf(window, "%d,%d", &x, &y) == 2) { SDL_windowX = x; SDL_windowY = y; } - if (SDL_strcmp (window, "center") == 0) { + if (SDL_strcmp(window, "center") == 0) { center = window; } } @@ -1227,17 +1225,17 @@ bounds.top = SDL_windowY; bounds.right = SDL_windowX + video->w; bounds.bottom = SDL_windowY + video->h; - AdjustWindowRectEx (&bounds, - GetWindowLong (SDL_Window, GWL_STYLE), - FALSE, 0); + AdjustWindowRectEx(&bounds, + GetWindowLong(SDL_Window, GWL_STYLE), + FALSE, 0); width = bounds.right - bounds.left; height = bounds.bottom - bounds.top; if ((flags & SDL_FULLSCREEN)) { - x = (GetSystemMetrics (SM_CXSCREEN) - width) / 2; - y = (GetSystemMetrics (SM_CYSCREEN) - height) / 2; + x = (GetSystemMetrics(SM_CXSCREEN) - width) / 2; + y = (GetSystemMetrics(SM_CYSCREEN) - height) / 2; } else if (center) { - x = (GetSystemMetrics (SM_CXSCREEN) - width) / 2; - y = (GetSystemMetrics (SM_CYSCREEN) - height) / 2; + x = (GetSystemMetrics(SM_CXSCREEN) - width) / 2; + y = (GetSystemMetrics(SM_CYSCREEN) - height) / 2; } else if (SDL_windowX || SDL_windowY || window) { x = bounds.left; y = bounds.top; @@ -1250,17 +1248,17 @@ } else { top = HWND_NOTOPMOST; } - SetWindowPos (SDL_Window, top, x, y, width, height, swp_flags); + SetWindowPos(SDL_Window, top, x, y, width, height, swp_flags); if (!(flags & SDL_FULLSCREEN)) { SDL_windowX = SDL_bounds.left; SDL_windowY = SDL_bounds.top; } - SetForegroundWindow (SDL_Window); + SetForegroundWindow(SDL_Window); } SDL_resizing = 0; /* Set up for OpenGL */ - if (WIN_GL_SetupWindow (this) < 0) { + if (WIN_GL_SetupWindow(this) < 0) { return (NULL); } video->flags |= SDL_INTERNALOPENGL; @@ -1268,7 +1266,7 @@ } /* Set the appropriate window style */ - style = GetWindowLong (SDL_Window, GWL_STYLE); + style = GetWindowLong(SDL_Window, GWL_STYLE); style &= ~(resizestyle | WS_MAXIMIZE); if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { style &= ~windowstyle; @@ -1285,13 +1283,13 @@ } } #if WS_MAXIMIZE - if (IsZoomed (SDL_Window)) + if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; #endif } /* DJM: Don't piss of anyone who has setup his own window */ if (!SDL_windowid) - SetWindowLong (SDL_Window, GWL_STYLE, style); + SetWindowLong(SDL_Window, GWL_STYLE, style); /* Set DirectDraw sharing mode.. exclusive when fullscreen */ if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { @@ -1299,9 +1297,9 @@ } else { sharemode = DDSCL_NORMAL; } - result = IDirectDraw2_SetCooperativeLevel (ddraw2, SDL_Window, sharemode); + result = IDirectDraw2_SetCooperativeLevel(ddraw2, SDL_Window, sharemode); if (result != DD_OK) { - SetDDerror ("DirectDraw2::SetCooperativeLevel", result); + SetDDerror("DirectDraw2::SetCooperativeLevel", result); return (NULL); } @@ -1314,17 +1312,17 @@ /* Cover up desktop during mode change */ bounds.left = 0; bounds.top = 0; - bounds.right = GetSystemMetrics (SM_CXSCREEN); - bounds.bottom = GetSystemMetrics (SM_CYSCREEN); - AdjustWindowRectEx (&bounds, GetWindowLong (SDL_Window, GWL_STYLE), - FALSE, 0); - SetWindowPos (SDL_Window, HWND_TOPMOST, bounds.left, bounds.top, - bounds.right - bounds.left, - bounds.bottom - bounds.top, SWP_NOCOPYBITS); - ShowWindow (SDL_Window, SW_SHOW); - while (GetForegroundWindow () != SDL_Window) { - SetForegroundWindow (SDL_Window); - SDL_Delay (100); + bounds.right = GetSystemMetrics(SM_CXSCREEN); + bounds.bottom = GetSystemMetrics(SM_CYSCREEN); + AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), + FALSE, 0); + SetWindowPos(SDL_Window, HWND_TOPMOST, bounds.left, bounds.top, + bounds.right - bounds.left, + bounds.bottom - bounds.top, SWP_NOCOPYBITS); + ShowWindow(SDL_Window, SW_SHOW); + while (GetForegroundWindow() != SDL_Window) { + SetForegroundWindow(SDL_Window); + SDL_Delay(100); } /* find maximum monitor refresh rate for this resolution */ @@ -1337,16 +1335,15 @@ } } #ifdef DDRAW_DEBUG - fprintf (stderr, "refresh rate = %d Hz\n", maxRefreshRate); + fprintf(stderr, "refresh rate = %d Hz\n", maxRefreshRate); #endif result = - IDirectDraw2_SetDisplayMode (ddraw2, width, height, bpp, - maxRefreshRate, 0); + IDirectDraw2_SetDisplayMode(ddraw2, width, height, bpp, + maxRefreshRate, 0); if (result != DD_OK) { result = - IDirectDraw2_SetDisplayMode (ddraw2, width, height, bpp, - 0, 0); + IDirectDraw2_SetDisplayMode(ddraw2, width, height, bpp, 0, 0); if (result != DD_OK) { /* We couldn't set fullscreen mode, try window */ return (DX5_SetVideoMode @@ -1354,15 +1351,15 @@ flags & ~SDL_FULLSCREEN)); } } - DX5_DInputReset (this, 1); + DX5_DInputReset(this, 1); } else { - DX5_DInputReset (this, 0); + DX5_DInputReset(this, 0); } - DX5_UpdateVideoInfo (this); + DX5_UpdateVideoInfo(this); /* Create a primary DirectDraw surface */ - SDL_memset (&ddsd, 0, sizeof (ddsd)); - ddsd.dwSize = sizeof (ddsd); + SDL_memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = (DDSCAPS_PRIMARYSURFACE | DDSCAPS_VIDEOMEMORY); if ((flags & SDL_FULLSCREEN) != SDL_FULLSCREEN) { @@ -1374,44 +1371,44 @@ ddsd.ddsCaps.dwCaps |= (DDSCAPS_COMPLEX | DDSCAPS_FLIP); ddsd.dwBackBufferCount = 1; } - result = IDirectDraw2_CreateSurface (ddraw2, &ddsd, &dd_surface1, NULL); + result = IDirectDraw2_CreateSurface(ddraw2, &ddsd, &dd_surface1, NULL); if ((result != DD_OK) && ((flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF)) { ddsd.dwFlags &= ~DDSD_BACKBUFFERCOUNT; ddsd.ddsCaps.dwCaps &= ~(DDSCAPS_COMPLEX | DDSCAPS_FLIP); ddsd.dwBackBufferCount = 0; - result = IDirectDraw2_CreateSurface (ddraw2, - &ddsd, &dd_surface1, NULL); + result = IDirectDraw2_CreateSurface(ddraw2, + &ddsd, &dd_surface1, NULL); } if (result != DD_OK) { - SetDDerror ("DirectDraw2::CreateSurface(PRIMARY)", result); + SetDDerror("DirectDraw2::CreateSurface(PRIMARY)", result); return (NULL); } - result = IDirectDrawSurface_QueryInterface (dd_surface1, - &IID_IDirectDrawSurface3, - (LPVOID *) & SDL_primary); + result = IDirectDrawSurface_QueryInterface(dd_surface1, + &IID_IDirectDrawSurface3, + (LPVOID *) & SDL_primary); if (result != DD_OK) { - SetDDerror ("DirectDrawSurface::QueryInterface", result); + SetDDerror("DirectDrawSurface::QueryInterface", result); return (NULL); } - IDirectDrawSurface_Release (dd_surface1); + IDirectDrawSurface_Release(dd_surface1); /* Get the format of the primary DirectDraw surface */ - SDL_memset (&ddsd, 0, sizeof (ddsd)); - ddsd.dwSize = sizeof (ddsd); + SDL_memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_CAPS; - result = IDirectDrawSurface3_GetSurfaceDesc (SDL_primary, &ddsd); + result = IDirectDrawSurface3_GetSurfaceDesc(SDL_primary, &ddsd); if (result != DD_OK) { - SetDDerror ("DirectDrawSurface::GetSurfaceDesc", result); + SetDDerror("DirectDrawSurface::GetSurfaceDesc", result); return (NULL); } if (!(ddsd.ddpfPixelFormat.dwFlags & DDPF_RGB)) { - SDL_SetError ("Primary DDRAW surface is not RGB format"); + SDL_SetError("Primary DDRAW surface is not RGB format"); return (NULL); } /* Free old palette and create a new one if we're in 8-bit mode */ if (SDL_palette != NULL) { - IDirectDrawPalette_Release (SDL_palette); + IDirectDrawPalette_Release(SDL_palette); SDL_palette = NULL; } #if defined(NONAMELESSUNION) @@ -1451,17 +1448,17 @@ SDL_colors[i].peBlue = 0; } } - result = IDirectDraw2_CreatePalette (ddraw2, - (DDPCAPS_8BIT | - DDPCAPS_ALLOW256), SDL_colors, - &SDL_palette, NULL); + result = IDirectDraw2_CreatePalette(ddraw2, + (DDPCAPS_8BIT | + DDPCAPS_ALLOW256), SDL_colors, + &SDL_palette, NULL); if (result != DD_OK) { - SetDDerror ("DirectDraw2::CreatePalette", result); + SetDDerror("DirectDraw2::CreatePalette", result); return (NULL); } - result = IDirectDrawSurface3_SetPalette (SDL_primary, SDL_palette); + result = IDirectDrawSurface3_SetPalette(SDL_primary, SDL_palette); if (result != DD_OK) { - SetDDerror ("DirectDrawSurface3::SetPalette", result); + SetDDerror("DirectDrawSurface3::SetPalette", result); return (NULL); } } @@ -1475,22 +1472,22 @@ #else ddsd.ddpfPixelFormat.dwRGBBitCount)) { #endif - SDL_FreeSurface (video); - video = SDL_CreateRGBSurface (SDL_SWSURFACE, 0, 0, + SDL_FreeSurface(video); + video = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, #if defined(NONAMELESSUNION) - ddsd.ddpfPixelFormat.u1.dwRGBBitCount, - ddsd.ddpfPixelFormat.u2.dwRBitMask, - ddsd.ddpfPixelFormat.u3.dwGBitMask, - ddsd.ddpfPixelFormat.u4.dwBBitMask, + ddsd.ddpfPixelFormat.u1.dwRGBBitCount, + ddsd.ddpfPixelFormat.u2.dwRBitMask, + ddsd.ddpfPixelFormat.u3.dwGBitMask, + ddsd.ddpfPixelFormat.u4.dwBBitMask, #else - ddsd.ddpfPixelFormat.dwRGBBitCount, - ddsd.ddpfPixelFormat.dwRBitMask, - ddsd.ddpfPixelFormat.dwGBitMask, - ddsd.ddpfPixelFormat.dwBBitMask, + ddsd.ddpfPixelFormat.dwRGBBitCount, + ddsd.ddpfPixelFormat.dwRBitMask, + ddsd.ddpfPixelFormat.dwGBitMask, + ddsd.ddpfPixelFormat.dwBBitMask, #endif - 0); + 0); if (video == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } video->w = width; @@ -1520,12 +1517,12 @@ video->pitch = (width * video->format->BytesPerPixel); /* Pitch needs to be QWORD (8-byte) aligned */ video->pitch = (video->pitch + 7) & ~7; - video->pixels = (void *) SDL_malloc (video->h * video->pitch); + video->pixels = (void *) SDL_malloc(video->h * video->pitch); if (video->pixels == NULL) { if (video != current) { - SDL_FreeSurface (video); + SDL_FreeSurface(video); } - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } } @@ -1548,7 +1545,7 @@ } else { /* Necessary if we're going from window to fullscreen */ if (video->pixels != NULL) { - SDL_free (video->pixels); + SDL_free(video->pixels); video->pixels = NULL; } dd_surface3 = SDL_primary; @@ -1561,10 +1558,10 @@ } /* Allocate the SDL surface associated with the primary surface */ - if (DX5_AllocDDSurface (this, video, dd_surface3, - video->flags & SDL_HWSURFACE) < 0) { + if (DX5_AllocDDSurface(this, video, dd_surface3, + video->flags & SDL_HWSURFACE) < 0) { if (video != current) { - SDL_FreeSurface (video); + SDL_FreeSurface(video); } return (NULL); } @@ -1584,35 +1581,35 @@ if ((flags & SDL_FULLSCREEN) != SDL_FULLSCREEN) { /* Create and set a clipper on our primary surface */ if (SDL_clipper == NULL) { - result = IDirectDraw2_CreateClipper (ddraw2, - 0, &SDL_clipper, NULL); + result = IDirectDraw2_CreateClipper(ddraw2, + 0, &SDL_clipper, NULL); if (result != DD_OK) { if (video != current) { - SDL_FreeSurface (video); + SDL_FreeSurface(video); } - SetDDerror ("DirectDraw2::CreateClipper", result); + SetDDerror("DirectDraw2::CreateClipper", result); return (NULL); } } - result = IDirectDrawClipper_SetHWnd (SDL_clipper, 0, SDL_Window); + result = IDirectDrawClipper_SetHWnd(SDL_clipper, 0, SDL_Window); if (result != DD_OK) { if (video != current) { - SDL_FreeSurface (video); + SDL_FreeSurface(video); } - SetDDerror ("DirectDrawClipper::SetHWnd", result); + SetDDerror("DirectDrawClipper::SetHWnd", result); return (NULL); } - result = IDirectDrawSurface3_SetClipper (SDL_primary, SDL_clipper); + result = IDirectDrawSurface3_SetClipper(SDL_primary, SDL_clipper); if (result != DD_OK) { if (video != current) { - SDL_FreeSurface (video); + SDL_FreeSurface(video); } - SetDDerror ("DirectDrawSurface3::SetClipper", result); + SetDDerror("DirectDrawSurface3::SetClipper", result); return (NULL); } /* Resize the window (copied from SDL WinDIB driver) */ - if (!SDL_windowid && !IsZoomed (SDL_Window)) { + if (!SDL_windowid && !IsZoomed(SDL_Window)) { RECT bounds; int x, y; UINT swp_flags; @@ -1620,14 +1617,14 @@ const char *center = NULL; if (!SDL_windowX && !SDL_windowY) { - window = SDL_getenv ("SDL_VIDEO_WINDOW_POS"); - center = SDL_getenv ("SDL_VIDEO_CENTERED"); + window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); + center = SDL_getenv("SDL_VIDEO_CENTERED"); if (window) { - if (SDL_sscanf (window, "%d,%d", &x, &y) == 2) { + if (SDL_sscanf(window, "%d,%d", &x, &y) == 2) { SDL_windowX = x; SDL_windowY = y; } - if (SDL_strcmp (window, "center") == 0) { + if (SDL_strcmp(window, "center") == 0) { center = window; } } @@ -1638,14 +1635,14 @@ bounds.top = SDL_windowY; bounds.right = SDL_windowX + video->w; bounds.bottom = SDL_windowY + video->h; - AdjustWindowRectEx (&bounds, - GetWindowLong (SDL_Window, GWL_STYLE), - FALSE, 0); + AdjustWindowRectEx(&bounds, + GetWindowLong(SDL_Window, GWL_STYLE), + FALSE, 0); width = bounds.right - bounds.left; height = bounds.bottom - bounds.top; if (center) { - x = (GetSystemMetrics (SM_CXSCREEN) - width) / 2; - y = (GetSystemMetrics (SM_CYSCREEN) - height) / 2; + x = (GetSystemMetrics(SM_CXSCREEN) - width) / 2; + y = (GetSystemMetrics(SM_CYSCREEN) - height) / 2; } else if (SDL_windowX || SDL_windowY || window) { x = bounds.left; y = bounds.top; @@ -1653,22 +1650,22 @@ x = y = -1; swp_flags |= SWP_NOMOVE; } - SetWindowPos (SDL_Window, HWND_NOTOPMOST, x, y, width, height, - swp_flags); + SetWindowPos(SDL_Window, HWND_NOTOPMOST, x, y, width, height, + swp_flags); SDL_windowX = SDL_bounds.left; SDL_windowY = SDL_bounds.top; } } - ShowWindow (SDL_Window, SW_SHOW); - SetForegroundWindow (SDL_Window); + ShowWindow(SDL_Window, SW_SHOW); + SetForegroundWindow(SDL_Window); SDL_resizing = 0; /* JC 14 Mar 2006 Flush the message loop or this can cause big problems later Especially if the user decides to use dialog boxes or assert()! */ - WIN_FlushMessageQueue (); + WIN_FlushMessageQueue(); /* We're live! */ return (video); @@ -1681,8 +1678,8 @@ }; static int -DX5_AllocDDSurface (_THIS, SDL_Surface * surface, - LPDIRECTDRAWSURFACE3 requested, Uint32 flag) +DX5_AllocDDSurface(_THIS, SDL_Surface * surface, + LPDIRECTDRAWSURFACE3 requested, Uint32 flag) { LPDIRECTDRAWSURFACE dd_surface1; LPDIRECTDRAWSURFACE3 dd_surface3; @@ -1694,16 +1691,16 @@ /* Allocate the hardware acceleration data */ surface->hwdata = (struct private_hwdata *) - SDL_malloc (sizeof (*surface->hwdata)); + SDL_malloc(sizeof(*surface->hwdata)); if (surface->hwdata == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (-1); } dd_surface3 = NULL; /* Set up the surface description */ - SDL_memset (&ddsd, 0, sizeof (ddsd)); - ddsd.dwSize = sizeof (ddsd); + SDL_memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = (DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PITCH | DDSD_PIXELFORMAT); ddsd.dwWidth = surface->w; @@ -1718,7 +1715,7 @@ } else { ddsd.ddsCaps.dwCaps = (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY); } - ddsd.ddpfPixelFormat.dwSize = sizeof (ddsd.ddpfPixelFormat); + ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat); ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB; if (surface->format->palette) { ddsd.ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8; @@ -1739,18 +1736,18 @@ if (requested != NULL) { dd_surface3 = requested; } else { - result = IDirectDraw2_CreateSurface (ddraw2, - &ddsd, &dd_surface1, NULL); + result = IDirectDraw2_CreateSurface(ddraw2, + &ddsd, &dd_surface1, NULL); if (result != DD_OK) { - SetDDerror ("DirectDraw2::CreateSurface", result); + SetDDerror("DirectDraw2::CreateSurface", result); goto error_end; } - result = IDirectDrawSurface_QueryInterface (dd_surface1, - &IID_IDirectDrawSurface3, - (LPVOID *) & dd_surface3); - IDirectDrawSurface_Release (dd_surface1); + result = IDirectDrawSurface_QueryInterface(dd_surface1, + &IID_IDirectDrawSurface3, + (LPVOID *) & dd_surface3); + IDirectDrawSurface_Release(dd_surface1); if (result != DD_OK) { - SetDDerror ("DirectDrawSurface::QueryInterface", result); + SetDDerror("DirectDrawSurface::QueryInterface", result); goto error_end; } } @@ -1760,44 +1757,43 @@ in video memory, and fail if not. We expect the surfaces we create here to actually be in hardware! */ - result = IDirectDrawSurface3_GetCaps (dd_surface3, &ddsd.ddsCaps); + result = IDirectDrawSurface3_GetCaps(dd_surface3, &ddsd.ddsCaps); if (result != DD_OK) { - SetDDerror ("DirectDrawSurface3::GetCaps", result); + SetDDerror("DirectDrawSurface3::GetCaps", result); goto error_end; } if ((ddsd.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY) != DDSCAPS_VIDEOMEMORY) { - SDL_SetError ("No room in video memory"); + SDL_SetError("No room in video memory"); goto error_end; } } else { /* Try to hook our surface memory */ ddsd.dwFlags = DDSD_LPSURFACE; ddsd.lpSurface = surface->pixels; - result = IDirectDrawSurface3_SetSurfaceDesc (dd_surface3, &ddsd, 0); + result = IDirectDrawSurface3_SetSurfaceDesc(dd_surface3, &ddsd, 0); if (result != DD_OK) { - SetDDerror ("DirectDraw2::SetSurfaceDesc", result); + SetDDerror("DirectDraw2::SetSurfaceDesc", result); goto error_end; } } /* Make sure the surface format was set properly */ - SDL_memset (&ddsd, 0, sizeof (ddsd)); - ddsd.dwSize = sizeof (ddsd); - result = IDirectDrawSurface3_Lock (dd_surface3, NULL, - &ddsd, - (DDLOCK_NOSYSLOCK | DDLOCK_WAIT), - NULL); + SDL_memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + result = IDirectDrawSurface3_Lock(dd_surface3, NULL, + &ddsd, + (DDLOCK_NOSYSLOCK | DDLOCK_WAIT), NULL); if (result != DD_OK) { - SetDDerror ("DirectDrawSurface3::Lock", result); + SetDDerror("DirectDrawSurface3::Lock", result); goto error_end; } - IDirectDrawSurface3_Unlock (dd_surface3, NULL); + IDirectDrawSurface3_Unlock(dd_surface3, NULL); if ((flag & SDL_HWSURFACE) == SDL_SWSURFACE) { if (ddsd.lpSurface != surface->pixels) { - SDL_SetError ("DDraw didn't use SDL surface memory"); + SDL_SetError("DDraw didn't use SDL surface memory"); goto error_end; } if ( @@ -1807,7 +1803,7 @@ ddsd.lPitch #endif != (LONG) surface->pitch) { - SDL_SetError ("DDraw created surface with wrong pitch"); + SDL_SetError("DDraw created surface with wrong pitch"); goto error_end; } } else { @@ -1830,12 +1826,12 @@ (ddsd.ddpfPixelFormat.dwGBitMask != surface->format->Gmask) || (ddsd.ddpfPixelFormat.dwBBitMask != surface->format->Bmask)) { #endif - SDL_SetError ("DDraw didn't use SDL surface description"); + SDL_SetError("DDraw didn't use SDL surface description"); goto error_end; } if ((ddsd.dwWidth != (DWORD) surface->w) || (ddsd.dwHeight != (DWORD) surface->h)) { - SDL_SetError ("DDraw created surface with wrong size"); + SDL_SetError("DDraw created surface with wrong size"); goto error_end; } @@ -1846,11 +1842,11 @@ LPDIRECTDRAWSURFACE3 dd_writebuf; ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER; - result = IDirectDrawSurface3_GetAttachedSurface (dd_surface3, - &ddsd.ddsCaps, - &dd_writebuf); + result = IDirectDrawSurface3_GetAttachedSurface(dd_surface3, + &ddsd.ddsCaps, + &dd_writebuf); if (result != DD_OK) { - SetDDerror ("DirectDrawSurface3::GetAttachedSurface", result); + SetDDerror("DirectDrawSurface3::GetAttachedSurface", result); } else { dd_surface3 = dd_writebuf; } @@ -1867,65 +1863,64 @@ */ error_end: if ((dd_surface3 != NULL) && (dd_surface3 != requested)) { - IDirectDrawSurface_Release (dd_surface3); + IDirectDrawSurface_Release(dd_surface3); } - SDL_free (surface->hwdata); + SDL_free(surface->hwdata); surface->hwdata = NULL; return (-1); } static int -DX5_AllocHWSurface (_THIS, SDL_Surface * surface) +DX5_AllocHWSurface(_THIS, SDL_Surface * surface) { /* DDraw limitation -- you need to set cooperative level first */ if (SDL_primary == NULL) { - SDL_SetError ("You must set a non-GL video mode first"); + SDL_SetError("You must set a non-GL video mode first"); return (-1); } - return (DX5_AllocDDSurface (this, surface, NULL, SDL_HWSURFACE)); + return (DX5_AllocDDSurface(this, surface, NULL, SDL_HWSURFACE)); } #ifdef DDRAW_DEBUG void -PrintSurface (char *title, LPDIRECTDRAWSURFACE3 surface, Uint32 flags) +PrintSurface(char *title, LPDIRECTDRAWSURFACE3 surface, Uint32 flags) { DDSURFACEDESC ddsd; /* Lock and load! */ - SDL_memset (&ddsd, 0, sizeof (ddsd)); - ddsd.dwSize = sizeof (ddsd); - if (IDirectDrawSurface3_Lock (surface, NULL, &ddsd, - (DDLOCK_NOSYSLOCK | DDLOCK_WAIT), - NULL) != DD_OK) { + SDL_memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + if (IDirectDrawSurface3_Lock(surface, NULL, &ddsd, + (DDLOCK_NOSYSLOCK | DDLOCK_WAIT), + NULL) != DD_OK) { return; } - IDirectDrawSurface3_Unlock (surface, NULL); + IDirectDrawSurface3_Unlock(surface, NULL); - fprintf (stderr, "%s:\n", title); - fprintf (stderr, "\tSize: %dx%d in %s at %ld bpp (pitch = %ld)\n", - ddsd.dwWidth, ddsd.dwHeight, - (flags & SDL_HWSURFACE) ? "hardware" : "software", + fprintf(stderr, "%s:\n", title); + fprintf(stderr, "\tSize: %dx%d in %s at %ld bpp (pitch = %ld)\n", + ddsd.dwWidth, ddsd.dwHeight, + (flags & SDL_HWSURFACE) ? "hardware" : "software", #if defined(NONAMELESSUNION) - ddsd.ddpfPixelFormat.u1.dwRGBBitCount, ddsd.u1.lPitch); + ddsd.ddpfPixelFormat.u1.dwRGBBitCount, ddsd.u1.lPitch); #else - ddsd.ddpfPixelFormat.dwRGBBitCount, ddsd.lPitch); + ddsd.ddpfPixelFormat.dwRGBBitCount, ddsd.lPitch); #endif - fprintf (stderr, "\tR = 0x%X, G = 0x%X, B = 0x%X\n", + fprintf(stderr, "\tR = 0x%X, G = 0x%X, B = 0x%X\n", #if defined(NONAMELESSUNION) - ddsd.ddpfPixelFormat.u2.dwRBitMask, - ddsd.ddpfPixelFormat.u3.dwGBitMask, - ddsd.ddpfPixelFormat.u4.dwBBitMask); + ddsd.ddpfPixelFormat.u2.dwRBitMask, + ddsd.ddpfPixelFormat.u3.dwGBitMask, + ddsd.ddpfPixelFormat.u4.dwBBitMask); #else - ddsd.ddpfPixelFormat.dwRBitMask, - ddsd.ddpfPixelFormat.dwGBitMask, - ddsd.ddpfPixelFormat.dwBBitMask); + ddsd.ddpfPixelFormat.dwRBitMask, + ddsd.ddpfPixelFormat.dwGBitMask, ddsd.ddpfPixelFormat.dwBBitMask); #endif } #endif /* DDRAW_DEBUG */ static int -DX5_HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +DX5_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) { LPDIRECTDRAWSURFACE3 src_surface; LPDIRECTDRAWSURFACE3 dst_surface; @@ -1950,38 +1945,38 @@ flags |= DDBLTFAST_WAIT; /* Do the blit! */ - result = IDirectDrawSurface3_BltFast (dst_surface, - dstrect->x, dstrect->y, src_surface, - &rect, flags); + result = IDirectDrawSurface3_BltFast(dst_surface, + dstrect->x, dstrect->y, src_surface, + &rect, flags); if (result != DD_OK) { if (result == DDERR_SURFACELOST) { - result = IDirectDrawSurface3_Restore (src_surface); - result = IDirectDrawSurface3_Restore (dst_surface); + result = IDirectDrawSurface3_Restore(src_surface); + result = IDirectDrawSurface3_Restore(dst_surface); /* The surfaces need to be reloaded with artwork */ - SDL_SetError ("Blit surfaces were lost, reload them"); + SDL_SetError("Blit surfaces were lost, reload them"); return (-2); } - SetDDerror ("IDirectDrawSurface3::BltFast", result); + SetDDerror("IDirectDrawSurface3::BltFast", result); #ifdef DDRAW_DEBUG - fprintf (stderr, "Original dest rect: %dx%d at %d,%d\n", dstrect->w, - dstrect->h, dstrect->x, dstrect->y); - fprintf (stderr, - "HW accelerated %sblit to from 0x%p to 0x%p at (%d,%d)\n", - (src->flags & SDL_SRCCOLORKEY) ? "colorkey " : "", src, - dst, dstrect->x, dstrect->y); - PrintSurface ("SRC", src_surface, src->flags); - PrintSurface ("DST", dst_surface, dst->flags); - fprintf (stderr, "Source rectangle: (%d,%d) - (%d,%d)\n", - rect.left, rect.top, rect.right, rect.bottom); + fprintf(stderr, "Original dest rect: %dx%d at %d,%d\n", dstrect->w, + dstrect->h, dstrect->x, dstrect->y); + fprintf(stderr, + "HW accelerated %sblit to from 0x%p to 0x%p at (%d,%d)\n", + (src->flags & SDL_SRCCOLORKEY) ? "colorkey " : "", src, + dst, dstrect->x, dstrect->y); + PrintSurface("SRC", src_surface, src->flags); + PrintSurface("DST", dst_surface, dst->flags); + fprintf(stderr, "Source rectangle: (%d,%d) - (%d,%d)\n", + rect.left, rect.top, rect.right, rect.bottom); #endif /* Unexpected error, fall back to software blit */ - return (src->map->sw_blit (src, srcrect, dst, dstrect)); + return (src->map->sw_blit(src, srcrect, dst, dstrect)); } return (0); } static int -DX5_CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst) +DX5_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst) { int accelerated; @@ -1989,7 +1984,7 @@ if ((src->flags & SDL_HWSURFACE) == SDL_SWSURFACE) { /* Allocate a DDraw surface for the blit */ if (src->hwdata == NULL) { - DX5_AllocDDSurface (this, src, NULL, SDL_SWSURFACE); + DX5_AllocDDSurface(this, src, NULL, SDL_SWSURFACE); } } if (src->hwdata == NULL) { @@ -2001,12 +1996,12 @@ /* Set the surface attributes */ if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { - if (DX5_SetHWColorKey (this, src, src->format->colorkey) < 0) { + if (DX5_SetHWColorKey(this, src, src->format->colorkey) < 0) { src->flags &= ~SDL_HWACCEL; } } if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) { - if (DX5_SetHWAlpha (this, src, src->format->alpha) < 0) { + if (DX5_SetHWAlpha(this, src, src->format->alpha) < 0) { src->flags &= ~SDL_HWACCEL; } } @@ -2015,7 +2010,7 @@ accelerated = !!(src->flags & SDL_HWACCEL); if (accelerated) { #ifdef DDRAW_DEBUG - fprintf (stderr, "Setting accelerated blit on 0x%p\n", src); + fprintf(stderr, "Setting accelerated blit on 0x%p\n", src); #endif src->map->hw_blit = DX5_HWAccelBlit; } @@ -2023,7 +2018,7 @@ } static int -DX5_FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color) +DX5_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color) { LPDIRECTDRAWSURFACE3 dst_surface; RECT area; @@ -2031,39 +2026,39 @@ HRESULT result; #ifdef DDRAW_DEBUG - fprintf (stderr, "HW accelerated fill at (%d,%d)\n", dstrect->x, - dstrect->y); + fprintf(stderr, "HW accelerated fill at (%d,%d)\n", dstrect->x, + dstrect->y); #endif dst_surface = dst->hwdata->dd_writebuf; area.top = (LONG) dstrect->y; area.bottom = (LONG) dstrect->y + dstrect->h; area.left = (LONG) dstrect->x; area.right = (LONG) dstrect->x + dstrect->w; - bltfx.dwSize = sizeof (bltfx); + bltfx.dwSize = sizeof(bltfx); #if defined(NONAMELESSUNION) bltfx.u5.dwFillColor = color; #else bltfx.dwFillColor = color; #endif - result = IDirectDrawSurface3_Blt (dst_surface, - &area, NULL, NULL, - DDBLT_COLORFILL | DDBLT_WAIT, &bltfx); + result = IDirectDrawSurface3_Blt(dst_surface, + &area, NULL, NULL, + DDBLT_COLORFILL | DDBLT_WAIT, &bltfx); if (result == DDERR_SURFACELOST) { - IDirectDrawSurface3_Restore (dst_surface); - result = IDirectDrawSurface3_Blt (dst_surface, - &area, NULL, NULL, - DDBLT_COLORFILL | DDBLT_WAIT, - &bltfx); + IDirectDrawSurface3_Restore(dst_surface); + result = IDirectDrawSurface3_Blt(dst_surface, + &area, NULL, NULL, + DDBLT_COLORFILL | DDBLT_WAIT, + &bltfx); } if (result != DD_OK) { - SetDDerror ("IDirectDrawSurface3::Blt", result); + SetDDerror("IDirectDrawSurface3::Blt", result); return (-1); } return (0); } static int -DX5_SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key) +DX5_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key) { DDCOLORKEY colorkey; HRESULT result; @@ -2072,22 +2067,22 @@ colorkey.dwColorSpaceLowValue = key; colorkey.dwColorSpaceHighValue = key; result = - IDirectDrawSurface3_SetColorKey (surface->hwdata->dd_surface, - DDCKEY_SRCBLT, &colorkey); + IDirectDrawSurface3_SetColorKey(surface->hwdata->dd_surface, + DDCKEY_SRCBLT, &colorkey); if (result != DD_OK) { - SetDDerror ("IDirectDrawSurface3::SetColorKey", result); + SetDDerror("IDirectDrawSurface3::SetColorKey", result); return (-1); } return (0); } static int -DX5_SetHWAlpha (_THIS, SDL_Surface * surface, Uint8 alpha) +DX5_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha) { return (-1); } static int -DX5_LockHWSurface (_THIS, SDL_Surface * surface) +DX5_LockHWSurface(_THIS, SDL_Surface * surface) { HRESULT result; LPDIRECTDRAWSURFACE3 dd_surface; @@ -2095,19 +2090,18 @@ /* Lock and load! */ dd_surface = surface->hwdata->dd_writebuf; - SDL_memset (&ddsd, 0, sizeof (ddsd)); - ddsd.dwSize = sizeof (ddsd); - result = IDirectDrawSurface3_Lock (dd_surface, NULL, &ddsd, - (DDLOCK_NOSYSLOCK | DDLOCK_WAIT), - NULL); + SDL_memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + result = IDirectDrawSurface3_Lock(dd_surface, NULL, &ddsd, + (DDLOCK_NOSYSLOCK | DDLOCK_WAIT), NULL); if (result == DDERR_SURFACELOST) { - result = IDirectDrawSurface3_Restore (surface->hwdata->dd_surface); - result = IDirectDrawSurface3_Lock (dd_surface, NULL, &ddsd, - (DDLOCK_NOSYSLOCK | DDLOCK_WAIT), - NULL); + result = IDirectDrawSurface3_Restore(surface->hwdata->dd_surface); + result = IDirectDrawSurface3_Lock(dd_surface, NULL, &ddsd, + (DDLOCK_NOSYSLOCK | DDLOCK_WAIT), + NULL); } if (result != DD_OK) { - SetDDerror ("DirectDrawSurface3::Lock", result); + SetDDerror("DirectDrawSurface3::Lock", result); return (-1); } /* Pitch might have changed -- recalculate pitch and offset */ @@ -2128,14 +2122,14 @@ } static void -DX5_UnlockHWSurface (_THIS, SDL_Surface * surface) +DX5_UnlockHWSurface(_THIS, SDL_Surface * surface) { - IDirectDrawSurface3_Unlock (surface->hwdata->dd_writebuf, NULL); + IDirectDrawSurface3_Unlock(surface->hwdata->dd_writebuf, NULL); surface->pixels = NULL; } static int -DX5_FlipHWSurface (_THIS, SDL_Surface * surface) +DX5_FlipHWSurface(_THIS, SDL_Surface * surface) { HRESULT result; LPDIRECTDRAWSURFACE3 dd_surface; @@ -2144,37 +2138,37 @@ /* to prevent big slowdown on fast computers, wait here instead of driver ring 0 code */ /* Dmitry Yakimov (ftech@tula.net) */ - while (IDirectDrawSurface3_GetFlipStatus (dd_surface, DDGBS_ISBLTDONE) == + while (IDirectDrawSurface3_GetFlipStatus(dd_surface, DDGBS_ISBLTDONE) == DDERR_WASSTILLDRAWING); - result = IDirectDrawSurface3_Flip (dd_surface, NULL, DDFLIP_WAIT); + result = IDirectDrawSurface3_Flip(dd_surface, NULL, DDFLIP_WAIT); if (result == DDERR_SURFACELOST) { - result = IDirectDrawSurface3_Restore (surface->hwdata->dd_surface); + result = IDirectDrawSurface3_Restore(surface->hwdata->dd_surface); while (IDirectDrawSurface3_GetFlipStatus (dd_surface, DDGBS_ISBLTDONE) == DDERR_WASSTILLDRAWING); - result = IDirectDrawSurface3_Flip (dd_surface, NULL, DDFLIP_WAIT); + result = IDirectDrawSurface3_Flip(dd_surface, NULL, DDFLIP_WAIT); } if (result != DD_OK) { - SetDDerror ("DirectDrawSurface3::Flip", result); + SetDDerror("DirectDrawSurface3::Flip", result); return (-1); } return (0); } static void -DX5_FreeHWSurface (_THIS, SDL_Surface * surface) +DX5_FreeHWSurface(_THIS, SDL_Surface * surface) { if (surface->hwdata) { if (surface->hwdata->dd_surface != SDL_primary) { - IDirectDrawSurface3_Release (surface->hwdata->dd_surface); + IDirectDrawSurface3_Release(surface->hwdata->dd_surface); } - SDL_free (surface->hwdata); + SDL_free(surface->hwdata); surface->hwdata = NULL; } } void -DX5_WindowUpdate (_THIS, int numrects, SDL_Rect * rects) +DX5_WindowUpdate(_THIS, int numrects, SDL_Rect * rects) { HRESULT result; int i; @@ -2189,21 +2183,21 @@ dst.left = SDL_bounds.left + src.left; dst.bottom = SDL_bounds.top + src.bottom; dst.right = SDL_bounds.left + src.right; - result = IDirectDrawSurface3_Blt (SDL_primary, &dst, - this->screen->hwdata->dd_surface, - &src, DDBLT_WAIT, NULL); + result = IDirectDrawSurface3_Blt(SDL_primary, &dst, + this->screen->hwdata->dd_surface, + &src, DDBLT_WAIT, NULL); /* Doh! Check for lost surface and restore it */ if (result == DDERR_SURFACELOST) { - IDirectDrawSurface3_Restore (SDL_primary); - IDirectDrawSurface3_Blt (SDL_primary, &dst, - this->screen->hwdata->dd_surface, - &src, DDBLT_WAIT, NULL); + IDirectDrawSurface3_Restore(SDL_primary); + IDirectDrawSurface3_Blt(SDL_primary, &dst, + this->screen->hwdata->dd_surface, + &src, DDBLT_WAIT, NULL); } } } void -DX5_DirectUpdate (_THIS, int numrects, SDL_Rect * rects) +DX5_DirectUpdate(_THIS, int numrects, SDL_Rect * rects) { } @@ -2234,7 +2228,7 @@ (r*r + g*g + b*b); \ }) static void -DX5_CompressPalette (_THIS, SDL_Color * colors, int ncolors, int maxcolors) +DX5_CompressPalette(_THIS, SDL_Color * colors, int ncolors, int maxcolors) { #ifdef SIMPLE_COMPRESSION int i, j; @@ -2260,19 +2254,19 @@ } #else /* Allocate memory for the arrays we use */ - pool = SDL_stack_alloc (int, 2 * ncolors); + pool = SDL_stack_alloc(int, 2 * ncolors); if (pool == NULL) { /* No worries, just return */ ; return; } seen = pool; - SDL_memset (seen, 0, ncolors * sizeof (int)); + SDL_memset(seen, 0, ncolors * sizeof(int)); order = pool + ncolors; /* Start with the brightest color */ max = 0; for (i = 0; i < ncolors; ++i) { - dist = CS_CS_DIST (zero, colors[i]); + dist = CS_CS_DIST(zero, colors[i]); if (dist >= max) { max = dist; next = i; @@ -2290,7 +2284,7 @@ if (seen[i]) { continue; } - dist = CS_CS_DIST (colors[i], colors[prev]); + dist = CS_CS_DIST(colors[i], colors[prev]); if (dist >= max) { max = dist; next = i; @@ -2307,13 +2301,13 @@ SDL_colors[j].peGreen = colors[order[i]].g; SDL_colors[j].peBlue = colors[order[i]].b; } - SDL_stack_free (pool); + SDL_stack_free(pool); #endif /* SIMPLE_COMPRESSION */ } /* Set the system colormap in both fullscreen and windowed modes */ int -DX5_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +DX5_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { int i; int alloct_all; @@ -2329,17 +2323,16 @@ SDL_colors[j].peGreen = colors[i].g; SDL_colors[j].peBlue = colors[i].b; } - IDirectDrawPalette_SetEntries (SDL_palette, 0, - firstcolor, ncolors, - &SDL_colors[firstcolor]); + IDirectDrawPalette_SetEntries(SDL_palette, 0, + firstcolor, ncolors, + &SDL_colors[firstcolor]); alloct_all = 1; } else { /* Grab the 236 most diverse colors in the palette */ - DX5_CompressPalette (this, colors, ncolors, 236); + DX5_CompressPalette(this, colors, ncolors, 236); /* This sends an WM_PALETTECHANGED message to us */ colorchange_expected = 1; - IDirectDrawPalette_SetEntries (SDL_palette, 0, - 0, 256, SDL_colors); + IDirectDrawPalette_SetEntries(SDL_palette, 0, 0, 256, SDL_colors); } } return (alloct_all); @@ -2347,7 +2340,7 @@ /* Gamma code is only available on DirectX 7 and newer */ static int -DX5_SetGammaRamp (_THIS, Uint16 * ramp) +DX5_SetGammaRamp(_THIS, Uint16 * ramp) { #ifdef IDirectDrawGammaControl_SetGammaRamp LPDIRECTDRAWGAMMACONTROL gamma; @@ -2356,45 +2349,45 @@ #endif /* In windowed or OpenGL mode, use windib gamma code */ - if (!DDRAW_FULLSCREEN ()) { - return DIB_SetGammaRamp (this, ramp); + if (!DDRAW_FULLSCREEN()) { + return DIB_SetGammaRamp(this, ramp); } #ifndef IDirectDrawGammaControl_SetGammaRamp - SDL_SetError ("SDL compiled without DirectX gamma ramp support"); + SDL_SetError("SDL compiled without DirectX gamma ramp support"); return -1; #else /* Check for a video mode! */ if (!SDL_primary) { - SDL_SetError ("A video mode must be set for gamma correction"); + SDL_SetError("A video mode must be set for gamma correction"); return (-1); } /* Get the gamma control object */ - result = IDirectDrawSurface3_QueryInterface (SDL_primary, - &IID_IDirectDrawGammaControl, - (LPVOID *) & gamma); + result = IDirectDrawSurface3_QueryInterface(SDL_primary, + &IID_IDirectDrawGammaControl, + (LPVOID *) & gamma); if (result != DD_OK) { - SetDDerror ("DirectDrawSurface3::QueryInterface(GAMMA)", result); + SetDDerror("DirectDrawSurface3::QueryInterface(GAMMA)", result); return (-1); } /* Set up the gamma ramp */ - SDL_memcpy (gamma_ramp.red, &ramp[0 * 256], 256 * sizeof (*ramp)); - SDL_memcpy (gamma_ramp.green, &ramp[1 * 256], 256 * sizeof (*ramp)); - SDL_memcpy (gamma_ramp.blue, &ramp[2 * 256], 256 * sizeof (*ramp)); - result = IDirectDrawGammaControl_SetGammaRamp (gamma, 0, &gamma_ramp); + SDL_memcpy(gamma_ramp.red, &ramp[0 * 256], 256 * sizeof(*ramp)); + SDL_memcpy(gamma_ramp.green, &ramp[1 * 256], 256 * sizeof(*ramp)); + SDL_memcpy(gamma_ramp.blue, &ramp[2 * 256], 256 * sizeof(*ramp)); + result = IDirectDrawGammaControl_SetGammaRamp(gamma, 0, &gamma_ramp); if (result != DD_OK) { - SetDDerror ("DirectDrawGammaControl::SetGammaRamp()", result); + SetDDerror("DirectDrawGammaControl::SetGammaRamp()", result); } /* Release the interface and return */ - IDirectDrawGammaControl_Release (gamma); + IDirectDrawGammaControl_Release(gamma); return (result == DD_OK) ? 0 : -1; #endif /* !IDirectDrawGammaControl_SetGammaRamp */ } static int -DX5_GetGammaRamp (_THIS, Uint16 * ramp) +DX5_GetGammaRamp(_THIS, Uint16 * ramp) { #ifdef IDirectDrawGammaControl_SetGammaRamp LPDIRECTDRAWGAMMACONTROL gamma; @@ -2403,46 +2396,46 @@ #endif /* In windowed or OpenGL mode, use windib gamma code */ - if (!DDRAW_FULLSCREEN ()) { - return DIB_GetGammaRamp (this, ramp); + if (!DDRAW_FULLSCREEN()) { + return DIB_GetGammaRamp(this, ramp); } #ifndef IDirectDrawGammaControl_SetGammaRamp - SDL_SetError ("SDL compiled without DirectX gamma ramp support"); + SDL_SetError("SDL compiled without DirectX gamma ramp support"); return -1; #else /* Check for a video mode! */ if (!SDL_primary) { - SDL_SetError ("A video mode must be set for gamma correction"); + SDL_SetError("A video mode must be set for gamma correction"); return (-1); } /* Get the gamma control object */ - result = IDirectDrawSurface3_QueryInterface (SDL_primary, - &IID_IDirectDrawGammaControl, - (LPVOID *) & gamma); + result = IDirectDrawSurface3_QueryInterface(SDL_primary, + &IID_IDirectDrawGammaControl, + (LPVOID *) & gamma); if (result != DD_OK) { - SetDDerror ("DirectDrawSurface3::QueryInterface(GAMMA)", result); + SetDDerror("DirectDrawSurface3::QueryInterface(GAMMA)", result); return (-1); } /* Set up the gamma ramp */ - result = IDirectDrawGammaControl_GetGammaRamp (gamma, 0, &gamma_ramp); + result = IDirectDrawGammaControl_GetGammaRamp(gamma, 0, &gamma_ramp); if (result == DD_OK) { - SDL_memcpy (&ramp[0 * 256], gamma_ramp.red, 256 * sizeof (*ramp)); - SDL_memcpy (&ramp[1 * 256], gamma_ramp.green, 256 * sizeof (*ramp)); - SDL_memcpy (&ramp[2 * 256], gamma_ramp.blue, 256 * sizeof (*ramp)); + SDL_memcpy(&ramp[0 * 256], gamma_ramp.red, 256 * sizeof(*ramp)); + SDL_memcpy(&ramp[1 * 256], gamma_ramp.green, 256 * sizeof(*ramp)); + SDL_memcpy(&ramp[2 * 256], gamma_ramp.blue, 256 * sizeof(*ramp)); } else { - SetDDerror ("DirectDrawGammaControl::GetGammaRamp()", result); + SetDDerror("DirectDrawGammaControl::GetGammaRamp()", result); } /* Release the interface and return */ - IDirectDrawGammaControl_Release (gamma); + IDirectDrawGammaControl_Release(gamma); return (result == DD_OK) ? 0 : -1; #endif /* !IDirectDrawGammaControl_SetGammaRamp */ } void -DX5_VideoQuit (_THIS) +DX5_VideoQuit(_THIS) { int i, j; @@ -2451,18 +2444,18 @@ #ifndef NO_CHANGEDISPLAYSETTINGS if ((this->screen->flags & (SDL_INTERNALOPENGL | SDL_FULLSCREEN)) == (SDL_INTERNALOPENGL | SDL_FULLSCREEN)) { - ChangeDisplaySettings (NULL, 0); - ShowWindow (SDL_Window, SW_HIDE); + ChangeDisplaySettings(NULL, 0); + ShowWindow(SDL_Window, SW_HIDE); } #endif if (this->screen->flags & SDL_INTERNALOPENGL) { - WIN_GL_ShutDown (this); + WIN_GL_ShutDown(this); } } /* Free any palettes we used */ if (SDL_palette != NULL) { - IDirectDrawPalette_Release (SDL_palette); + IDirectDrawPalette_Release(SDL_palette); SDL_palette = NULL; } @@ -2475,42 +2468,42 @@ for (i = 0; i < NUM_MODELISTS; ++i) { if (SDL_modelist[i] != NULL) { for (j = 0; SDL_modelist[i][j]; ++j) - SDL_free (SDL_modelist[i][j]); - SDL_free (SDL_modelist[i]); + SDL_free(SDL_modelist[i][j]); + SDL_free(SDL_modelist[i]); SDL_modelist[i] = NULL; } } /* Free the window */ - DIB_QuitGamma (this); + DIB_QuitGamma(this); if (SDL_Window) { - DX5_DestroyWindow (this); + DX5_DestroyWindow(this); } /* Free our window icon */ if (screen_icn) { - DestroyIcon (screen_icn); + DestroyIcon(screen_icn); screen_icn = NULL; } } /* Exported for the windows message loop only */ void -DX5_RealizePalette (_THIS) +DX5_RealizePalette(_THIS) { if (SDL_palette) { - IDirectDrawSurface3_SetPalette (SDL_primary, SDL_palette); + IDirectDrawSurface3_SetPalette(SDL_primary, SDL_palette); } } static void -DX5_Recolor8Bit (_THIS, SDL_Surface * surface, Uint8 * mapping) +DX5_Recolor8Bit(_THIS, SDL_Surface * surface, Uint8 * mapping) { int row, col; Uint8 *pixels; if (surface->w && surface->h) { if ((surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE) { - if (this->LockHWSurface (this, surface) < 0) { + if (this->LockHWSurface(this, surface) < 0) { return; } } @@ -2521,13 +2514,13 @@ } } if ((surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE) { - this->UnlockHWSurface (this, surface); + this->UnlockHWSurface(this, surface); } - SDL_UpdateRect (surface, 0, 0, 0, 0); + SDL_UpdateRect(surface, 0, 0, 0, 0); } } void -DX5_PaletteChanged (_THIS, HWND window) +DX5_PaletteChanged(_THIS, HWND window) { SDL_Palette *palette; SDL_Color *saved = NULL; @@ -2546,43 +2539,43 @@ if (palette == NULL) { /* Sometimes we don't have a palette */ return; } - entries = SDL_stack_alloc (PALETTEENTRY, palette->ncolors); - hdc = GetDC (window); - GetSystemPaletteEntries (hdc, 0, palette->ncolors, entries); - ReleaseDC (window, hdc); + entries = SDL_stack_alloc(PALETTEENTRY, palette->ncolors); + hdc = GetDC(window); + GetSystemPaletteEntries(hdc, 0, palette->ncolors, entries); + ReleaseDC(window, hdc); if (!colorchange_expected) { - saved = SDL_stack_alloc (SDL_Color, palette->ncolors); - SDL_memcpy (saved, palette->colors, - palette->ncolors * sizeof (SDL_Color)); + saved = SDL_stack_alloc(SDL_Color, palette->ncolors); + SDL_memcpy(saved, palette->colors, + palette->ncolors * sizeof(SDL_Color)); } for (i = 0; i < palette->ncolors; ++i) { palette->colors[i].r = entries[i].peRed; palette->colors[i].g = entries[i].peGreen; palette->colors[i].b = entries[i].peBlue; } - SDL_stack_free (entries); + SDL_stack_free(entries); if (!colorchange_expected) { Uint8 mapping[256]; - SDL_memset (mapping, 0, sizeof (mapping)); + SDL_memset(mapping, 0, sizeof(mapping)); for (i = 0; i < palette->ncolors; ++i) { - mapping[i] = SDL_FindColor (palette, - saved[i].r, saved[i].g, saved[i].b); + mapping[i] = SDL_FindColor(palette, + saved[i].r, saved[i].g, saved[i].b); } - DX5_Recolor8Bit (this, SDL_VideoSurface, mapping); - SDL_stack_free (saved); + DX5_Recolor8Bit(this, SDL_VideoSurface, mapping); + SDL_stack_free(saved); } colorchange_expected = 0; /* Notify all mapped surfaces of the change */ - SDL_FormatChanged (SDL_VideoSurface); + SDL_FormatChanged(SDL_VideoSurface); } /* Exported for the windows message loop only */ void -DX5_WinPAINT (_THIS, HDC hdc) +DX5_WinPAINT(_THIS, HDC hdc) { - SDL_UpdateRect (SDL_PublicSurface, 0, 0, 0, 0); + SDL_UpdateRect(SDL_PublicSurface, 0, 0, 0, 0); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/windx5/SDL_dx5video.h --- a/src/video/windx5/SDL_dx5video.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/windx5/SDL_dx5video.h Mon May 29 04:04:35 2006 +0000 @@ -53,15 +53,15 @@ #define SDL_modeindex (this->hidden->SDL_modeindex) /* DirectX function pointers for video and events */ -extern HRESULT (WINAPI * DDrawCreate) (GUID FAR * lpGUID, - LPDIRECTDRAW FAR * lplpDD, - IUnknown FAR * pUnkOuter); -extern HRESULT (WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion, - LPDIRECTINPUT * ppDI, - LPUNKNOWN punkOuter); +extern HRESULT(WINAPI * DDrawCreate) (GUID FAR * lpGUID, + LPDIRECTDRAW FAR * lplpDD, + IUnknown FAR * pUnkOuter); +extern HRESULT(WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion, + LPDIRECTINPUT * ppDI, + LPUNKNOWN punkOuter); /* DirectDraw error reporting function */ -extern void SetDDerror (const char *function, int code); +extern void SetDDerror(const char *function, int code); #endif /* _SDL_dx5video_h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/windx5/SDL_dx5yuv.c --- a/src/video/windx5/SDL_dx5yuv.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/windx5/SDL_dx5yuv.c Mon May 29 04:04:35 2006 +0000 @@ -48,7 +48,7 @@ static LPDIRECTDRAWSURFACE3 -CreateYUVSurface (_THIS, int width, int height, Uint32 format) +CreateYUVSurface(_THIS, int width, int height, Uint32 format) { HRESULT result; LPDIRECTDRAWSURFACE dd_surface1; @@ -56,8 +56,8 @@ DDSURFACEDESC ddsd; /* Set up the surface description */ - SDL_memset (&ddsd, 0, sizeof (ddsd)); - ddsd.dwSize = sizeof (ddsd); + SDL_memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = (DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT); ddsd.dwWidth = width; ddsd.dwHeight = height; @@ -66,41 +66,41 @@ #else ddsd.ddsCaps.dwCaps = (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY); #endif - ddsd.ddpfPixelFormat.dwSize = sizeof (ddsd.ddpfPixelFormat); + ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat); ddsd.ddpfPixelFormat.dwFlags = DDPF_FOURCC; ddsd.ddpfPixelFormat.dwFourCC = format; /* Create the DirectDraw video surface */ - result = IDirectDraw2_CreateSurface (ddraw2, &ddsd, &dd_surface1, NULL); + result = IDirectDraw2_CreateSurface(ddraw2, &ddsd, &dd_surface1, NULL); if (result != DD_OK) { - SetDDerror ("DirectDraw2::CreateSurface", result); + SetDDerror("DirectDraw2::CreateSurface", result); return (NULL); } - result = IDirectDrawSurface_QueryInterface (dd_surface1, - &IID_IDirectDrawSurface3, - (LPVOID *) & dd_surface3); - IDirectDrawSurface_Release (dd_surface1); + result = IDirectDrawSurface_QueryInterface(dd_surface1, + &IID_IDirectDrawSurface3, + (LPVOID *) & dd_surface3); + IDirectDrawSurface_Release(dd_surface1); if (result != DD_OK) { - SetDDerror ("DirectDrawSurface::QueryInterface", result); + SetDDerror("DirectDrawSurface::QueryInterface", result); return (NULL); } /* Make sure the surface format was set properly */ - SDL_memset (&ddsd, 0, sizeof (ddsd)); - ddsd.dwSize = sizeof (ddsd); - result = IDirectDrawSurface3_Lock (dd_surface3, NULL, - &ddsd, DDLOCK_NOSYSLOCK, NULL); + SDL_memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + result = IDirectDrawSurface3_Lock(dd_surface3, NULL, + &ddsd, DDLOCK_NOSYSLOCK, NULL); if (result != DD_OK) { - SetDDerror ("DirectDrawSurface3::Lock", result); - IDirectDrawSurface_Release (dd_surface3); + SetDDerror("DirectDrawSurface3::Lock", result); + IDirectDrawSurface_Release(dd_surface3); return (NULL); } - IDirectDrawSurface3_Unlock (dd_surface3, NULL); + IDirectDrawSurface3_Unlock(dd_surface3, NULL); if (!(ddsd.ddpfPixelFormat.dwFlags & DDPF_FOURCC) || (ddsd.ddpfPixelFormat.dwFourCC != format)) { - SDL_SetError ("DDraw didn't use requested FourCC format"); - IDirectDrawSurface_Release (dd_surface3); + SDL_SetError("DDraw didn't use requested FourCC format"); + IDirectDrawSurface_Release(dd_surface3); return (NULL); } @@ -110,7 +110,7 @@ #ifdef DEBUG_YUV static char * -PrintFOURCC (Uint32 code) +PrintFOURCC(Uint32 code) { static char buf[5]; @@ -123,8 +123,8 @@ #endif SDL_Overlay * -DX5_CreateYUVOverlay (_THIS, int width, int height, Uint32 format, - SDL_Surface * display) +DX5_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, + SDL_Surface * display) { SDL_Overlay *overlay; struct private_yuvhwdata *hwdata; @@ -133,31 +133,30 @@ DWORD numcodes; DWORD *codes; - printf ("FOURCC format requested: 0x%x\n", PrintFOURCC (format)); - IDirectDraw2_GetFourCCCodes (ddraw2, &numcodes, NULL); + printf("FOURCC format requested: 0x%x\n", PrintFOURCC(format)); + IDirectDraw2_GetFourCCCodes(ddraw2, &numcodes, NULL); if (numcodes) { DWORD i; - codes = SDL_malloc (numcodes * sizeof (*codes)); + codes = SDL_malloc(numcodes * sizeof(*codes)); if (codes) { - IDirectDraw2_GetFourCCCodes (ddraw2, &numcodes, codes); + IDirectDraw2_GetFourCCCodes(ddraw2, &numcodes, codes); for (i = 0; i < numcodes; ++i) { - fprintf (stderr, "Code %d: 0x%x\n", i, - PrintFOURCC (codes[i])); + fprintf(stderr, "Code %d: 0x%x\n", i, PrintFOURCC(codes[i])); } - SDL_free (codes); + SDL_free(codes); } } else { - fprintf (stderr, "No FOURCC codes supported\n"); + fprintf(stderr, "No FOURCC codes supported\n"); } #endif /* Create the overlay structure */ - overlay = (SDL_Overlay *) SDL_malloc (sizeof *overlay); + overlay = (SDL_Overlay *) SDL_malloc(sizeof *overlay); if (overlay == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } - SDL_memset (overlay, 0, (sizeof *overlay)); + SDL_memset(overlay, 0, (sizeof *overlay)); /* Fill in the basic members */ overlay->format = format; @@ -168,16 +167,16 @@ overlay->hwfuncs = &dx5_yuvfuncs; /* Create the pixel data and lookup tables */ - hwdata = (struct private_yuvhwdata *) SDL_malloc (sizeof *hwdata); + hwdata = (struct private_yuvhwdata *) SDL_malloc(sizeof *hwdata); overlay->hwdata = hwdata; if (hwdata == NULL) { - SDL_OutOfMemory (); - SDL_FreeYUVOverlay (overlay); + SDL_OutOfMemory(); + SDL_FreeYUVOverlay(overlay); return (NULL); } - hwdata->surface = CreateYUVSurface (this, width, height, format); + hwdata->surface = CreateYUVSurface(this, width, height, format); if (hwdata->surface == NULL) { - SDL_FreeYUVOverlay (overlay); + SDL_FreeYUVOverlay(overlay); return (NULL); } overlay->hw_overlay = 1; @@ -200,25 +199,25 @@ } int -DX5_LockYUVOverlay (_THIS, SDL_Overlay * overlay) +DX5_LockYUVOverlay(_THIS, SDL_Overlay * overlay) { HRESULT result; LPDIRECTDRAWSURFACE3 surface; DDSURFACEDESC ddsd; surface = overlay->hwdata->surface; - SDL_memset (&ddsd, 0, sizeof (ddsd)); - ddsd.dwSize = sizeof (ddsd); - result = IDirectDrawSurface3_Lock (surface, NULL, - &ddsd, DDLOCK_NOSYSLOCK, NULL); + SDL_memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + result = IDirectDrawSurface3_Lock(surface, NULL, + &ddsd, DDLOCK_NOSYSLOCK, NULL); if (result == DDERR_SURFACELOST) { - result = IDirectDrawSurface3_Restore (surface); - result = IDirectDrawSurface3_Lock (surface, NULL, &ddsd, - (DDLOCK_NOSYSLOCK | DDLOCK_WAIT), - NULL); + result = IDirectDrawSurface3_Restore(surface); + result = IDirectDrawSurface3_Lock(surface, NULL, &ddsd, + (DDLOCK_NOSYSLOCK | DDLOCK_WAIT), + NULL); } if (result != DD_OK) { - SetDDerror ("DirectDrawSurface3::Lock", result); + SetDDerror("DirectDrawSurface3::Lock", result); return (-1); } @@ -248,17 +247,17 @@ } void -DX5_UnlockYUVOverlay (_THIS, SDL_Overlay * overlay) +DX5_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay) { LPDIRECTDRAWSURFACE3 surface; surface = overlay->hwdata->surface; - IDirectDrawSurface3_Unlock (surface, NULL); + IDirectDrawSurface3_Unlock(surface, NULL); } int -DX5_DisplayYUVOverlay (_THIS, SDL_Overlay * overlay, SDL_Rect * src, - SDL_Rect * dst) +DX5_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, SDL_Rect * src, + SDL_Rect * dst) { HRESULT result; LPDIRECTDRAWSURFACE3 surface; @@ -274,19 +273,19 @@ dstrect.bottom = dstrect.top + dst->h; dstrect.right = dstrect.left + dst->w; #ifdef USE_DIRECTX_OVERLAY - result = IDirectDrawSurface3_UpdateOverlay (surface, &srcrect, - SDL_primary, &dstrect, - DDOVER_SHOW, NULL); + result = IDirectDrawSurface3_UpdateOverlay(surface, &srcrect, + SDL_primary, &dstrect, + DDOVER_SHOW, NULL); if (result != DD_OK) { - SetDDerror ("DirectDrawSurface3::UpdateOverlay", result); + SetDDerror("DirectDrawSurface3::UpdateOverlay", result); return (-1); } #else result = - IDirectDrawSurface3_Blt (SDL_primary, &dstrect, surface, &srcrect, - DDBLT_WAIT, NULL); + IDirectDrawSurface3_Blt(SDL_primary, &dstrect, surface, &srcrect, + DDBLT_WAIT, NULL); if (result != DD_OK) { - SetDDerror ("DirectDrawSurface3::Blt", result); + SetDDerror("DirectDrawSurface3::Blt", result); return (-1); } #endif @@ -294,16 +293,16 @@ } void -DX5_FreeYUVOverlay (_THIS, SDL_Overlay * overlay) +DX5_FreeYUVOverlay(_THIS, SDL_Overlay * overlay) { struct private_yuvhwdata *hwdata; hwdata = overlay->hwdata; if (hwdata) { if (hwdata->surface) { - IDirectDrawSurface_Release (hwdata->surface); + IDirectDrawSurface_Release(hwdata->surface); } - SDL_free (hwdata); + SDL_free(hwdata); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/windx5/SDL_dx5yuv_c.h --- a/src/video/windx5/SDL_dx5yuv_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/windx5/SDL_dx5yuv_c.h Mon May 29 04:04:35 2006 +0000 @@ -27,16 +27,16 @@ #include "../wincommon/SDL_lowvideo.h" #include "SDL_dx5video.h" -extern SDL_Overlay *DX5_CreateYUVOverlay (_THIS, int width, int height, - Uint32 format, - SDL_Surface * display); +extern SDL_Overlay *DX5_CreateYUVOverlay(_THIS, int width, int height, + Uint32 format, + SDL_Surface * display); -extern int DX5_LockYUVOverlay (_THIS, SDL_Overlay * overlay); +extern int DX5_LockYUVOverlay(_THIS, SDL_Overlay * overlay); -extern void DX5_UnlockYUVOverlay (_THIS, SDL_Overlay * overlay); +extern void DX5_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay); -extern int DX5_DisplayYUVOverlay (_THIS, SDL_Overlay * overlay, - SDL_Rect * src, SDL_Rect * dst); +extern int DX5_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, + SDL_Rect * src, SDL_Rect * dst); -extern void DX5_FreeYUVOverlay (_THIS, SDL_Overlay * overlay); +extern void DX5_FreeYUVOverlay(_THIS, SDL_Overlay * overlay); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/wscons/SDL_wsconsevents.c --- a/src/video/wscons/SDL_wsconsevents.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/wscons/SDL_wsconsevents.c Mon May 29 04:04:35 2006 +0000 @@ -39,18 +39,18 @@ static int posted = 0; int -WSCONS_InitKeyboard (_THIS) +WSCONS_InitKeyboard(_THIS) { struct termios tty; - if (ioctl (private->fd, WSKBDIO_GTYPE, &private->kbdType) == -1) { - WSCONS_ReportError ("cannot get keyboard type: %s", strerror (errno)); + if (ioctl(private->fd, WSKBDIO_GTYPE, &private->kbdType) == -1) { + WSCONS_ReportError("cannot get keyboard type: %s", strerror(errno)); return -1; } - if (tcgetattr (private->fd, &private->saved_tty) == -1) { - WSCONS_ReportError ("cannot get terminal attributes: %s", - strerror (errno)); + if (tcgetattr(private->fd, &private->saved_tty) == -1) { + WSCONS_ReportError("cannot get terminal attributes: %s", + strerror(errno)); return -1; } private->did_save_tty = 1; @@ -61,16 +61,16 @@ tty.c_lflag = 0; tty.c_cc[VTIME] = 0; tty.c_cc[VMIN] = 1; - cfsetispeed (&tty, 9600); - cfsetospeed (&tty, 9600); - if (tcsetattr (private->fd, TCSANOW, &tty) < 0) { - WSCONS_ReportError ("cannot set terminal attributes: %s", - strerror (errno)); + cfsetispeed(&tty, 9600); + cfsetospeed(&tty, 9600); + if (tcsetattr(private->fd, TCSANOW, &tty) < 0) { + WSCONS_ReportError("cannot set terminal attributes: %s", + strerror(errno)); return -1; } - if (ioctl (private->fd, KDSKBMODE, K_RAW) == -1) { - WSCONS_ReportError ("cannot set raw keyboard mode: %s", - strerror (errno)); + if (ioctl(private->fd, KDSKBMODE, K_RAW) == -1) { + WSCONS_ReportError("cannot set raw keyboard mode: %s", + strerror(errno)); return -1; } @@ -78,84 +78,84 @@ } void -WSCONS_ReleaseKeyboard (_THIS) +WSCONS_ReleaseKeyboard(_THIS) { if (private->fd != -1) { - if (ioctl (private->fd, KDSKBMODE, K_XLATE) == -1) { + if (ioctl(private->fd, KDSKBMODE, K_XLATE) == -1) { WSCONS_ReportError ("cannot restore keyboard to translated mode: %s", - strerror (errno)); + strerror(errno)); } if (private->did_save_tty) { - if (tcsetattr (private->fd, TCSANOW, &private->saved_tty) < 0) { + if (tcsetattr(private->fd, TCSANOW, &private->saved_tty) < 0) { WSCONS_ReportError ("cannot restore keynoard attributes: %s", - strerror (errno)); + strerror(errno)); } } } } static void -updateMouse () +updateMouse() { } static SDLKey keymap[128]; static SDL_keysym * -TranslateKey (int scancode, SDL_keysym * keysym) +TranslateKey(int scancode, SDL_keysym * keysym) { keysym->scancode = scancode; keysym->sym = SDLK_UNKNOWN; keysym->mod = KMOD_NONE; - if (scancode < SDL_arraysize (keymap)) + if (scancode < SDL_arraysize(keymap)) keysym->sym = keymap[scancode]; if (keysym->sym == SDLK_UNKNOWN) - printf ("Unknown mapping for scancode %d\n", scancode); + printf("Unknown mapping for scancode %d\n", scancode); return keysym; } static void -updateKeyboard (_THIS) +updateKeyboard(_THIS) { unsigned char buf[100]; SDL_keysym keysym; int n, i; - if ((n = read (private->fd, buf, sizeof (buf))) > 0) { + if ((n = read(private->fd, buf, sizeof(buf))) > 0) { for (i = 0; i < n; i++) { unsigned char c = buf[i] & 0x7f; if (c == 224) // special key prefix -- what should we do with it? continue; posted += - SDL_PrivateKeyboard ((buf[i] & 0x80) ? SDL_RELEASED : - SDL_PRESSED, TranslateKey (c, &keysym)); + SDL_PrivateKeyboard((buf[i] & 0x80) ? SDL_RELEASED : + SDL_PRESSED, TranslateKey(c, &keysym)); } } } void -WSCONS_PumpEvents (_THIS) +WSCONS_PumpEvents(_THIS) { do { posted = 0; - updateMouse (); - updateKeyboard (this); + updateMouse(); + updateKeyboard(this); } while (posted); } void -WSCONS_InitOSKeymap (_THIS) +WSCONS_InitOSKeymap(_THIS) { int i; /* Make sure unknown keys are mapped correctly */ - for (i = 0; i < SDL_arraysize (keymap); i++) { + for (i = 0; i < SDL_arraysize(keymap); i++) { keymap[i] = SDLK_UNKNOWN; } @@ -237,8 +237,8 @@ #endif /* WSKBD_TYPE_ZAURUS */ default: - WSCONS_ReportError ("Unable to map keys for keyboard type %u", - private->kbdType); + WSCONS_ReportError("Unable to map keys for keyboard type %u", + private->kbdType); break; } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/wscons/SDL_wsconsevents_c.h --- a/src/video/wscons/SDL_wsconsevents_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/wscons/SDL_wsconsevents_c.h Mon May 29 04:04:35 2006 +0000 @@ -23,14 +23,14 @@ #include "SDL_wsconsvideo.h" -int WSCONS_InitKeyboard (_THIS); -void WSCONS_ReleaseKeyboard (_THIS); +int WSCONS_InitKeyboard(_THIS); +void WSCONS_ReleaseKeyboard(_THIS); /* Variables and functions exported by SDL_sysevents.c to other parts of the native video subsystem (SDL_sysvideo.c) */ -extern void WSCONS_InitOSKeymap (_THIS); -extern void WSCONS_PumpEvents (_THIS); +extern void WSCONS_InitOSKeymap(_THIS); +extern void WSCONS_PumpEvents(_THIS); /* end of SDL_wsconsevents_c.h ... */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/wscons/SDL_wsconsvideo.c --- a/src/video/wscons/SDL_wsconsvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/wscons/SDL_wsconsvideo.c Mon May 29 04:04:35 2006 +0000 @@ -51,78 +51,78 @@ #define min(a,b) ((a)<(b)?(a):(b)) /* Initialization/Query functions */ -static int WSCONS_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **WSCONS_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *WSCONS_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); -static int WSCONS_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void WSCONS_VideoQuit (_THIS); +static int WSCONS_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **WSCONS_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +static SDL_Surface *WSCONS_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, + Uint32 flags); +static int WSCONS_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void WSCONS_VideoQuit(_THIS); /* Hardware surface functions */ -static int WSCONS_AllocHWSurface (_THIS, SDL_Surface * surface); -static int WSCONS_LockHWSurface (_THIS, SDL_Surface * surface); -static void WSCONS_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void WSCONS_FreeHWSurface (_THIS, SDL_Surface * surface); +static int WSCONS_AllocHWSurface(_THIS, SDL_Surface * surface); +static int WSCONS_LockHWSurface(_THIS, SDL_Surface * surface); +static void WSCONS_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void WSCONS_FreeHWSurface(_THIS, SDL_Surface * surface); /* etc. */ static WSCONS_bitBlit WSCONS_blit16; static WSCONS_bitBlit WSCONS_blit16blocked; -static void WSCONS_UpdateRects (_THIS, int numrects, SDL_Rect * rects); +static void WSCONS_UpdateRects(_THIS, int numrects, SDL_Rect * rects); void -WSCONS_ReportError (char *fmt, ...) +WSCONS_ReportError(char *fmt, ...) { char message[200]; va_list vaArgs; message[199] = '\0'; - va_start (vaArgs, fmt); - vsnprintf (message, 199, fmt, vaArgs); - va_end (vaArgs); + va_start(vaArgs, fmt); + vsnprintf(message, 199, fmt, vaArgs); + va_end(vaArgs); - SDL_SetError (message); - fprintf (stderr, "WSCONS error: %s\n", message); + SDL_SetError(message); + fprintf(stderr, "WSCONS error: %s\n", message); } /* WSCONS driver bootstrap functions */ static int -WSCONS_Available (void) +WSCONS_Available(void) { return 1; } static void -WSCONS_DeleteDevice (SDL_VideoDevice * device) +WSCONS_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -WSCONS_CreateDevice (int devindex) +WSCONS_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return 0; } - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = - (struct SDL_PrivateVideoData *) SDL_malloc ((sizeof *device->hidden)); + (struct SDL_PrivateVideoData *) SDL_malloc((sizeof *device->hidden)); if (device->hidden == NULL) { - SDL_OutOfMemory (); - SDL_free (device); + SDL_OutOfMemory(); + SDL_free(device); return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); device->hidden->fd = -1; /* Set the function pointers */ @@ -153,7 +153,7 @@ #define WSCONSDEV_FORMAT "/dev/ttyC%01x" int -WSCONS_VideoInit (_THIS, SDL_PixelFormat * vformat) +WSCONS_VideoInit(_THIS, SDL_PixelFormat * vformat) { char devnamebuf[30]; char *devname; @@ -164,36 +164,36 @@ int pagemask; int width, height; - devname = SDL_getenv ("SDL_WSCONSDEV"); + devname = SDL_getenv("SDL_WSCONSDEV"); if (devname == NULL) { int activeVT; - if (ioctl (STDIN_FILENO, VT_GETACTIVE, &activeVT) == -1) { - WSCONS_ReportError ("Unable to determine active terminal: %s", - strerror (errno)); + if (ioctl(STDIN_FILENO, VT_GETACTIVE, &activeVT) == -1) { + WSCONS_ReportError("Unable to determine active terminal: %s", + strerror(errno)); return -1; } - SDL_snprintf (devnamebuf, sizeof (devnamebuf), WSCONSDEV_FORMAT, - activeVT - 1); + SDL_snprintf(devnamebuf, sizeof(devnamebuf), WSCONSDEV_FORMAT, + activeVT - 1); devname = devnamebuf; } - private->fd = open (devname, O_RDWR | O_NONBLOCK, 0); + private->fd = open(devname, O_RDWR | O_NONBLOCK, 0); if (private->fd == -1) { - WSCONS_ReportError ("open %s: %s", devname, strerror (errno)); + WSCONS_ReportError("open %s: %s", devname, strerror(errno)); return -1; } - if (ioctl (private->fd, WSDISPLAYIO_GINFO, &private->info) == -1) { - WSCONS_ReportError ("ioctl WSDISPLAY_GINFO: %s", strerror (errno)); + if (ioctl(private->fd, WSDISPLAYIO_GINFO, &private->info) == -1) { + WSCONS_ReportError("ioctl WSDISPLAY_GINFO: %s", strerror(errno)); return -1; } - if (ioctl (private->fd, WSDISPLAYIO_GTYPE, &wstype) == -1) { - WSCONS_ReportError ("ioctl WSDISPLAY_GTYPE: %s", strerror (errno)); + if (ioctl(private->fd, WSDISPLAYIO_GTYPE, &wstype) == -1) { + WSCONS_ReportError("ioctl WSDISPLAY_GTYPE: %s", strerror(errno)); return -1; } - if (ioctl (private->fd, WSDISPLAYIO_LINEBYTES, &private->physlinebytes) == + if (ioctl(private->fd, WSDISPLAYIO_LINEBYTES, &private->physlinebytes) == -1) { - WSCONS_ReportError ("ioctl WSDISPLAYIO_LINEBYTES: %s", - strerror (errno)); + WSCONS_ReportError("ioctl WSDISPLAYIO_LINEBYTES: %s", + strerror(errno)); return -1; } if (private->info.depth > 8) { @@ -212,40 +212,40 @@ private->blueMask = 0x1f; #endif } else { - WSCONS_ReportError ("Unknown video hardware"); + WSCONS_ReportError("Unknown video hardware"); return -1; } } else { - WSCONS_ReportError ("Displays with 8 bpp or less are not supported"); + WSCONS_ReportError("Displays with 8 bpp or less are not supported"); return -1; } private->rotate = WSCONS_ROTATE_NONE; - rotation = SDL_getenv ("SDL_VIDEO_WSCONS_ROTATION"); + rotation = SDL_getenv("SDL_VIDEO_WSCONS_ROTATION"); if (rotation != NULL) { - if (SDL_strlen (rotation) == 0) { + if (SDL_strlen(rotation) == 0) { private->shadowFB = 0; private->rotate = WSCONS_ROTATE_NONE; - printf ("Not rotating, no shadow\n"); - } else if (!SDL_strcmp (rotation, "NONE")) { + printf("Not rotating, no shadow\n"); + } else if (!SDL_strcmp(rotation, "NONE")) { private->shadowFB = 1; private->rotate = WSCONS_ROTATE_NONE; - printf ("Not rotating, but still using shadow\n"); - } else if (!SDL_strcmp (rotation, "CW")) { + printf("Not rotating, but still using shadow\n"); + } else if (!SDL_strcmp(rotation, "CW")) { private->shadowFB = 1; private->rotate = WSCONS_ROTATE_CW; - printf ("Rotating screen clockwise\n"); - } else if (!SDL_strcmp (rotation, "CCW")) { + printf("Rotating screen clockwise\n"); + } else if (!SDL_strcmp(rotation, "CCW")) { private->shadowFB = 1; private->rotate = WSCONS_ROTATE_CCW; - printf ("Rotating screen counter clockwise\n"); - } else if (!SDL_strcmp (rotation, "UD")) { + printf("Rotating screen counter clockwise\n"); + } else if (!SDL_strcmp(rotation, "UD")) { private->shadowFB = 1; private->rotate = WSCONS_ROTATE_UD; - printf ("Rotating screen upside down\n"); + printf("Rotating screen upside down\n"); } else { - WSCONS_ReportError ("\"%s\" is not a valid value for " - "SDL_VIDEO_WSCONS_ROTATION", rotation); + WSCONS_ReportError("\"%s\" is not a valid value for " + "SDL_VIDEO_WSCONS_ROTATION", rotation); return -1; } } @@ -258,7 +258,7 @@ break; case 16: if (private->physlinebytes == private->info.width) { - len = private->info.width * private->info.height * sizeof (short); + len = private->info.width * private->info.height * sizeof(short); } else { len = private->physlinebytes * private->info.height; } @@ -271,13 +271,13 @@ break; case 32: if (private->physlinebytes == private->info.width) { - len = private->info.width * private->info.height * sizeof (int); + len = private->info.width * private->info.height * sizeof(int); } else { len = private->physlinebytes * private->info.height; } break; default: - WSCONS_ReportError ("unsupported depth %d", private->info.depth); + WSCONS_ReportError("unsupported depth %d", private->info.depth); return -1; } @@ -288,19 +288,19 @@ return -1; } - if (ioctl (private->fd, WSDISPLAYIO_SMODE, &wsmode) == -1) { - WSCONS_ReportError ("ioctl SMODE"); + if (ioctl(private->fd, WSDISPLAYIO_SMODE, &wsmode) == -1) { + WSCONS_ReportError("ioctl SMODE"); return -1; } - pagemask = getpagesize () - 1; + pagemask = getpagesize() - 1; mapsize = ((int) len + pagemask) & ~pagemask; - private->physmem = (Uint8 *) mmap (NULL, mapsize, - PROT_READ | PROT_WRITE, MAP_SHARED, - private->fd, (off_t) 0); + private->physmem = (Uint8 *) mmap(NULL, mapsize, + PROT_READ | PROT_WRITE, MAP_SHARED, + private->fd, (off_t) 0); if (private->physmem == (Uint8 *) MAP_FAILED) { private->physmem = NULL; - WSCONS_ReportError ("mmap: %s", strerror (errno)); + WSCONS_ReportError("mmap: %s", strerror(errno)); return -1; } private->fbmem_len = len; @@ -318,9 +318,9 @@ this->info.current_h = height; if (private->shadowFB) { - private->shadowmem = (Uint8 *) SDL_malloc (len); + private->shadowmem = (Uint8 *) SDL_malloc(len); if (private->shadowmem == NULL) { - WSCONS_ReportError ("No memory for shadow"); + WSCONS_ReportError("No memory for shadow"); return -1; } private->fbstart = private->shadowmem; @@ -330,14 +330,14 @@ private->fblinebytes = private->physlinebytes; } - private->SDL_modelist[0] = (SDL_Rect *) SDL_malloc (sizeof (SDL_Rect)); + private->SDL_modelist[0] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect)); private->SDL_modelist[0]->w = width; private->SDL_modelist[0]->h = height; vformat->BitsPerPixel = private->info.depth; vformat->BytesPerPixel = private->info.depth / 8; - if (WSCONS_InitKeyboard (this) == -1) { + if (WSCONS_InitKeyboard(this) == -1) { return -1; } @@ -345,7 +345,7 @@ } SDL_Rect ** -WSCONS_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +WSCONS_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { if (format->BitsPerPixel == private->info.depth) { return private->SDL_modelist; @@ -355,26 +355,26 @@ } SDL_Surface * -WSCONS_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +WSCONS_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { if (width != private->SDL_modelist[0]->w || height != private->SDL_modelist[0]->h) { - WSCONS_ReportError ("Requested video mode %dx%d not supported.", - width, height); + WSCONS_ReportError("Requested video mode %dx%d not supported.", + width, height); return NULL; } if (bpp != private->info.depth) { - WSCONS_ReportError ("Requested video depth %d bpp not supported.", - bpp); + WSCONS_ReportError("Requested video depth %d bpp not supported.", + bpp); return NULL; } - if (!SDL_ReallocFormat (current, - bpp, - private->redMask, - private->greenMask, private->blueMask, 0)) { - WSCONS_ReportError ("Couldn't allocate new pixel format"); + if (!SDL_ReallocFormat(current, + bpp, + private->redMask, + private->greenMask, private->blueMask, 0)) { + WSCONS_ReportError("Couldn't allocate new pixel format"); return NULL; } @@ -389,37 +389,37 @@ current->pitch = private->fblinebytes; current->pixels = private->fbstart; - SDL_memset (private->fbstart, 0, private->fbmem_len); + SDL_memset(private->fbstart, 0, private->fbmem_len); return current; } static int -WSCONS_AllocHWSurface (_THIS, SDL_Surface * surface) +WSCONS_AllocHWSurface(_THIS, SDL_Surface * surface) { return -1; } static void -WSCONS_FreeHWSurface (_THIS, SDL_Surface * surface) +WSCONS_FreeHWSurface(_THIS, SDL_Surface * surface) { } static int -WSCONS_LockHWSurface (_THIS, SDL_Surface * surface) +WSCONS_LockHWSurface(_THIS, SDL_Surface * surface) { return 0; } static void -WSCONS_UnlockHWSurface (_THIS, SDL_Surface * surface) +WSCONS_UnlockHWSurface(_THIS, SDL_Surface * surface) { } static void -WSCONS_blit16 (Uint8 * byte_src_pos, - int srcRightDelta, - int srcDownDelta, - Uint8 * byte_dst_pos, int dst_linebytes, int width, int height) +WSCONS_blit16(Uint8 * byte_src_pos, + int srcRightDelta, + int srcDownDelta, + Uint8 * byte_dst_pos, int dst_linebytes, int width, int height) { int w; Uint16 *src_pos = (Uint16 *) byte_src_pos; @@ -443,11 +443,11 @@ #define BLOCKSIZE_H 32 static void -WSCONS_blit16blocked (Uint8 * byte_src_pos, - int srcRightDelta, - int srcDownDelta, - Uint8 * byte_dst_pos, - int dst_linebytes, int width, int height) +WSCONS_blit16blocked(Uint8 * byte_src_pos, + int srcRightDelta, + int srcDownDelta, + Uint8 * byte_dst_pos, + int dst_linebytes, int width, int height) { int w; Uint16 *src_pos = (Uint16 *) byte_src_pos; @@ -457,12 +457,12 @@ Uint16 *src = src_pos; Uint16 *dst = dst_pos; for (w = width; w > 0; w -= BLOCKSIZE_W) { - WSCONS_blit16 ((Uint8 *) src, - srcRightDelta, - srcDownDelta, - (Uint8 *) dst, - dst_linebytes, - min (w, BLOCKSIZE_W), min (height, BLOCKSIZE_H)); + WSCONS_blit16((Uint8 *) src, + srcRightDelta, + srcDownDelta, + (Uint8 *) dst, + dst_linebytes, + min(w, BLOCKSIZE_W), min(height, BLOCKSIZE_H)); src += srcRightDelta * BLOCKSIZE_W; dst += BLOCKSIZE_W; } @@ -474,7 +474,7 @@ } static void -WSCONS_UpdateRects (_THIS, int numrects, SDL_Rect * rects) +WSCONS_UpdateRects(_THIS, int numrects, SDL_Rect * rects) { int width = private->SDL_modelist[0]->w; int height = private->SDL_modelist[0]->h; @@ -486,7 +486,7 @@ } if (private->info.depth != 16) { - WSCONS_ReportError ("Shadow copy only implemented for 16 bpp"); + WSCONS_ReportError("Shadow copy only implemented for 16 bpp"); return; } @@ -568,7 +568,7 @@ shadowDownDelta = 1; break; default: - WSCONS_ReportError ("Unknown rotation"); + WSCONS_ReportError("Unknown rotation"); return; } @@ -578,17 +578,17 @@ private->physmem + scr_y1 * private->physlinebytes + scr_x1 * bytesPerPixel; - private->blitFunc (src_start, - shadowRightDelta, - shadowDownDelta, - dst_start, - private->physlinebytes, - scr_x2 - scr_x1, scr_y2 - scr_y1); + private->blitFunc(src_start, + shadowRightDelta, + shadowDownDelta, + dst_start, + private->physlinebytes, + scr_x2 - scr_x1, scr_y2 - scr_y1); } } int -WSCONS_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +WSCONS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { return 0; } @@ -598,12 +598,12 @@ * another SDL video routine -- notably UpdateRects. */ void -WSCONS_VideoQuit (_THIS) +WSCONS_VideoQuit(_THIS) { int mode = WSDISPLAYIO_MODE_EMUL; if (private->shadowmem != NULL) { - SDL_free (private->shadowmem); + SDL_free(private->shadowmem); private->shadowmem = NULL; } private->fbstart = NULL; @@ -612,18 +612,18 @@ } if (private->SDL_modelist[0] != NULL) { - SDL_free (private->SDL_modelist[0]); + SDL_free(private->SDL_modelist[0]); private->SDL_modelist[0] = NULL; } - if (ioctl (private->fd, WSDISPLAYIO_SMODE, &mode) == -1) { - WSCONS_ReportError ("ioctl SMODE"); + if (ioctl(private->fd, WSDISPLAYIO_SMODE, &mode) == -1) { + WSCONS_ReportError("ioctl SMODE"); } - WSCONS_ReleaseKeyboard (this); + WSCONS_ReleaseKeyboard(this); if (private->fd != -1) { - close (private->fd); + close(private->fd); private->fd = -1; } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/wscons/SDL_wsconsvideo.h --- a/src/video/wscons/SDL_wsconsvideo.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/wscons/SDL_wsconsvideo.h Mon May 29 04:04:35 2006 +0000 @@ -32,7 +32,7 @@ #include "SDL_mutex.h" #include "../SDL_sysvideo.h" -void WSCONS_ReportError (char *fmt, ...); +void WSCONS_ReportError(char *fmt, ...); /* Hidden "this" pointer for the video functions */ #define _THIS SDL_VideoDevice *this @@ -40,10 +40,10 @@ /* Private display data */ -typedef void WSCONS_bitBlit (Uint8 * src_pos, int srcRightDelta, // pixels, not bytes - int srcDownDelta, // pixels, not bytes - Uint8 * dst_pos, - int dst_linebytes, int width, int height); +typedef void WSCONS_bitBlit(Uint8 * src_pos, int srcRightDelta, // pixels, not bytes + int srcDownDelta, // pixels, not bytes + Uint8 * dst_pos, + int dst_linebytes, int width, int height); struct SDL_PrivateVideoData { diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11dga.c --- a/src/video/x11/SDL_x11dga.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11dga.c Mon May 29 04:04:35 2006 +0000 @@ -34,7 +34,7 @@ int dga_event, dga_error = -1; void -X11_EnableDGAMouse (_THIS) +X11_EnableDGAMouse(_THIS) { #if SDL_VIDEO_DRIVER_X11_DGAMOUSE int dga_major, dga_minor; @@ -43,20 +43,20 @@ /* Check configuration to see if we should use DGA mouse */ use_dgamouse = 1; - env_use_dgamouse = SDL_getenv ("SDL_VIDEO_X11_DGAMOUSE"); + env_use_dgamouse = SDL_getenv("SDL_VIDEO_X11_DGAMOUSE"); if (env_use_dgamouse) { - use_dgamouse = atoi (env_use_dgamouse); + use_dgamouse = atoi(env_use_dgamouse); } /* Check for buggy X servers */ - if (use_dgamouse && BUGGY_XFREE86 ( ==, 4000)) { + if (use_dgamouse && BUGGY_XFREE86( ==, 4000)) { use_dgamouse = 0; } /* Only use DGA mouse if the cursor is not showing (in relative mode) */ if (use_dgamouse && local_X11 && !(using_dga & DGA_MOUSE) && - SDL_NAME (XF86DGAQueryExtension) (SDL_Display, &dga_event, &dga_error) - && SDL_NAME (XF86DGAQueryVersion) (SDL_Display, &dga_major, - &dga_minor)) { - if (SDL_NAME (XF86DGADirectVideo) + SDL_NAME(XF86DGAQueryExtension) (SDL_Display, &dga_event, &dga_error) + && SDL_NAME(XF86DGAQueryVersion) (SDL_Display, &dga_major, + &dga_minor)) { + if (SDL_NAME(XF86DGADirectVideo) (SDL_Display, SDL_Screen, XF86DGADirectMouse)) { using_dga |= DGA_MOUSE; } @@ -66,27 +66,27 @@ /* Argh. Glide resets DGA mouse mode when it makes the context current! */ void -X11_CheckDGAMouse (_THIS) +X11_CheckDGAMouse(_THIS) { #if SDL_VIDEO_DRIVER_X11_DGAMOUSE int flags; if (using_dga & DGA_MOUSE) { - SDL_NAME (XF86DGAQueryDirectVideo) (SDL_Display, SDL_Screen, &flags); + SDL_NAME(XF86DGAQueryDirectVideo) (SDL_Display, SDL_Screen, &flags); if (!(flags & XF86DGADirectMouse)) { - SDL_NAME (XF86DGADirectVideo) (SDL_Display, SDL_Screen, - XF86DGADirectMouse); + SDL_NAME(XF86DGADirectVideo) (SDL_Display, SDL_Screen, + XF86DGADirectMouse); } } #endif } void -X11_DisableDGAMouse (_THIS) +X11_DisableDGAMouse(_THIS) { #if SDL_VIDEO_DRIVER_X11_DGAMOUSE if (using_dga & DGA_MOUSE) { - SDL_NAME (XF86DGADirectVideo) (SDL_Display, SDL_Screen, 0); + SDL_NAME(XF86DGADirectVideo) (SDL_Display, SDL_Screen, 0); using_dga &= ~DGA_MOUSE; } #endif /* SDL_VIDEO_DRIVER_X11_DGAMOUSE */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11dga_c.h --- a/src/video/x11/SDL_x11dga_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11dga_c.h Mon May 29 04:04:35 2006 +0000 @@ -28,7 +28,7 @@ #define DGA_KEYBOARD 0x02 #define DGA_MOUSE 0x04 -extern void X11_EnableDGAMouse (_THIS); -extern void X11_CheckDGAMouse (_THIS); -extern void X11_DisableDGAMouse (_THIS); +extern void X11_EnableDGAMouse(_THIS); +extern void X11_CheckDGAMouse(_THIS); +extern void X11_DisableDGAMouse(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11dyn.c --- a/src/video/x11/SDL_x11dyn.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11dyn.c Mon May 29 04:04:35 2006 +0000 @@ -61,12 +61,12 @@ }; static void -X11_GetSym (const char *fnname, int *rc, void **fn) +X11_GetSym(const char *fnname, int *rc, void **fn) { int i; - for (i = 0; i < SDL_TABLESIZE (x11libs); i++) { + for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { if (x11libs[i].lib != NULL) { - *fn = SDL_LoadFunction (x11libs[i].lib, fnname); + *fn = SDL_LoadFunction(x11libs[i].lib, fnname); if (*fn != NULL) break; } @@ -74,10 +74,10 @@ #if DEBUG_DYNAMIC_X11 if (*fn != NULL) - printf ("X11: Found '%s' in %s (%p)\n", fnname, x11libs[i].libname, - *fn); + printf("X11: Found '%s' in %s (%p)\n", fnname, x11libs[i].libname, + *fn); else - printf ("X11: Symbol '%s' NOT FOUND!\n", fnname); + printf("X11: Symbol '%s' NOT FOUND!\n", fnname); #endif if (*fn == NULL) @@ -97,7 +97,7 @@ /* Annoying varargs entry point... */ #ifdef X_HAVE_UTF8_STRING -XIC (*pXCreateIC) (XIM,...) = NULL; +XIC(*pXCreateIC) (XIM,...) = NULL; #endif /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */ @@ -111,7 +111,7 @@ static int x11_load_refcount = 0; void -SDL_X11_UnloadSymbols (void) +SDL_X11_UnloadSymbols(void) { #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC /* Don't actually unload if more than one module is using the libs... */ @@ -130,9 +130,9 @@ pXCreateIC = NULL; #endif - for (i = 0; i < SDL_TABLESIZE (x11libs); i++) { + for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { if (x11libs[i].lib != NULL) { - SDL_UnloadObject (x11libs[i].lib); + SDL_UnloadObject(x11libs[i].lib); x11libs[i].lib = NULL; } } @@ -143,7 +143,7 @@ /* returns non-zero if all needed symbols were loaded. */ int -SDL_X11_LoadSymbols (void) +SDL_X11_LoadSymbols(void) { int rc = 1; /* always succeed if not using Dynamic X11 stuff. */ @@ -152,9 +152,9 @@ if (x11_load_refcount++ == 0) { int i; int *thismod = NULL; - for (i = 0; i < SDL_TABLESIZE (x11libs); i++) { + for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { if (x11libs[i].libname != NULL) { - x11libs[i].lib = SDL_LoadObject (x11libs[i].libname); + x11libs[i].lib = SDL_LoadObject(x11libs[i].libname); } } #define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname; @@ -164,11 +164,11 @@ #undef SDL_X11_SYM #ifdef X_HAVE_UTF8_STRING - X11_GetSym ("XCreateIC", &SDL_X11_HAVE_UTF8, (void **) &pXCreateIC); + X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8, (void **) &pXCreateIC); #endif if (!SDL_X11_HAVE_BASEXLIB) { /* some required symbol didn't load. */ - SDL_X11_UnloadSymbols (); /* in case something got loaded... */ + SDL_X11_UnloadSymbols(); /* in case something got loaded... */ rc = 0; } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11dyn.h --- a/src/video/x11/SDL_x11dyn.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11dyn.h Mon May 29 04:04:35 2006 +0000 @@ -59,18 +59,18 @@ #endif /* evil function signatures... */ - typedef Bool (*SDL_X11_XESetWireToEventRetType) (Display *, XEvent *, - xEvent *); + typedef Bool(*SDL_X11_XESetWireToEventRetType) (Display *, XEvent *, + xEvent *); typedef int (*SDL_X11_XSynchronizeRetType) (Display *); - typedef Status (*SDL_X11_XESetEventToWireRetType) (Display *, XEvent *, - xEvent *); + typedef Status(*SDL_X11_XESetEventToWireRetType) (Display *, XEvent *, + xEvent *); - int SDL_X11_LoadSymbols (void); - void SDL_X11_UnloadSymbols (void); + int SDL_X11_LoadSymbols(void); + void SDL_X11_UnloadSymbols(void); /* That's really annoying...make this a function pointer no matter what. */ #ifdef X_HAVE_UTF8_STRING - extern XIC (*pXCreateIC) (XIM, ...); + extern XIC(*pXCreateIC) (XIM, ...); #endif /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11events.c --- a/src/video/x11/SDL_x11events.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11events.c Mon May 29 04:04:35 2006 +0000 @@ -55,12 +55,12 @@ /* The translation tables from an X11 keysym to a SDL keysym */ static SDLKey ODD_keymap[256]; static SDLKey MISC_keymap[256]; -SDLKey X11_TranslateKeycode (Display * display, KeyCode kc); +SDLKey X11_TranslateKeycode(Display * display, KeyCode kc); #ifdef X_HAVE_UTF8_STRING Uint32 -Utf8ToUcs4 (const Uint8 * utf8) +Utf8ToUcs4(const Uint8 * utf8) { Uint32 c; int i = 1; @@ -184,19 +184,19 @@ (idea shamelessly lifted from GII -- thanks guys! :) */ static int -X11_KeyRepeat (Display * display, XEvent * event) +X11_KeyRepeat(Display * display, XEvent * event) { XEvent peekevent; int repeated; repeated = 0; - if (XPending (display)) { - XPeekEvent (display, &peekevent); + if (XPending(display)) { + XPeekEvent(display, &peekevent); if ((peekevent.type == KeyPress) && (peekevent.xkey.keycode == event->xkey.keycode) && ((peekevent.xkey.time - event->xkey.time) < 2)) { repeated = 1; - XNextEvent (display, &peekevent); + XNextEvent(display, &peekevent); } } return (repeated); @@ -210,7 +210,7 @@ #define MOUSE_FUDGE_FACTOR 8 static __inline__ int -X11_WarpedMotion (_THIS, XEvent * xevent) +X11_WarpedMotion(_THIS, XEvent * xevent) { int w, h, i; int deltax, deltay; @@ -221,33 +221,33 @@ deltax = xevent->xmotion.x - mouse_last.x; deltay = xevent->xmotion.y - mouse_last.y; #ifdef DEBUG_MOTION - printf ("Warped mouse motion: %d,%d\n", deltax, deltay); + printf("Warped mouse motion: %d,%d\n", deltax, deltay); #endif mouse_last.x = xevent->xmotion.x; mouse_last.y = xevent->xmotion.y; - posted = SDL_PrivateMouseMotion (0, 1, deltax, deltay); + posted = SDL_PrivateMouseMotion(0, 1, deltax, deltay); if ((xevent->xmotion.x < MOUSE_FUDGE_FACTOR) || (xevent->xmotion.x > (w - MOUSE_FUDGE_FACTOR)) || (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) || (xevent->xmotion.y > (h - MOUSE_FUDGE_FACTOR))) { /* Get the events that have accumulated */ - while (XCheckTypedEvent (SDL_Display, MotionNotify, xevent)) { + while (XCheckTypedEvent(SDL_Display, MotionNotify, xevent)) { deltax = xevent->xmotion.x - mouse_last.x; deltay = xevent->xmotion.y - mouse_last.y; #ifdef DEBUG_MOTION - printf ("Extra mouse motion: %d,%d\n", deltax, deltay); + printf("Extra mouse motion: %d,%d\n", deltax, deltay); #endif mouse_last.x = xevent->xmotion.x; mouse_last.y = xevent->xmotion.y; - posted += SDL_PrivateMouseMotion (0, 1, deltax, deltay); + posted += SDL_PrivateMouseMotion(0, 1, deltax, deltay); } mouse_last.x = w / 2; mouse_last.y = h / 2; - XWarpPointer (SDL_Display, None, SDL_Window, 0, 0, 0, 0, - mouse_last.x, mouse_last.y); + XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, + mouse_last.x, mouse_last.y); for (i = 0; i < 10; ++i) { - XMaskEvent (SDL_Display, PointerMotionMask, xevent); + XMaskEvent(SDL_Display, PointerMotionMask, xevent); if ((xevent->xmotion.x > (mouse_last.x - MOUSE_FUDGE_FACTOR)) && (xevent->xmotion.x < @@ -258,13 +258,13 @@ break; } #ifdef DEBUG_XEVENTS - printf ("Lost mouse motion: %d,%d\n", xevent->xmotion.x, - xevent->xmotion.y); + printf("Lost mouse motion: %d,%d\n", xevent->xmotion.x, + xevent->xmotion.y); #endif } #ifdef DEBUG_XEVENTS if (i == 10) { - printf ("Warning: didn't detect mouse warp motion\n"); + printf("Warning: didn't detect mouse warp motion\n"); } #endif } @@ -272,13 +272,13 @@ } static int -X11_DispatchEvent (_THIS) +X11_DispatchEvent(_THIS) { int posted; XEvent xevent; - SDL_memset (&xevent, '\0', sizeof (XEvent)); /* valgrind fix. --ryan. */ - XNextEvent (SDL_Display, &xevent); + SDL_memset(&xevent, '\0', sizeof(XEvent)); /* valgrind fix. --ryan. */ + XNextEvent(SDL_Display, &xevent); posted = 0; switch (xevent.type) { @@ -287,21 +287,21 @@ case EnterNotify: { #ifdef DEBUG_XEVENTS - printf ("EnterNotify! (%d,%d)\n", xevent.xcrossing.x, - xevent.xcrossing.y); + printf("EnterNotify! (%d,%d)\n", xevent.xcrossing.x, + xevent.xcrossing.y); if (xevent.xcrossing.mode == NotifyGrab) - printf ("Mode: NotifyGrab\n"); + printf("Mode: NotifyGrab\n"); if (xevent.xcrossing.mode == NotifyUngrab) - printf ("Mode: NotifyUngrab\n"); + printf("Mode: NotifyUngrab\n"); #endif if ((xevent.xcrossing.mode != NotifyGrab) && (xevent.xcrossing.mode != NotifyUngrab)) { if (SDL_CurrentWindow.input_grab == SDL_GRAB_OFF) { - posted = SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); + posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); } - posted = SDL_PrivateMouseMotion (0, 0, - xevent.xcrossing.x, - xevent.xcrossing.y); + posted = SDL_PrivateMouseMotion(0, 0, + xevent.xcrossing.x, + xevent.xcrossing.y); } } break; @@ -310,22 +310,22 @@ case LeaveNotify: { #ifdef DEBUG_XEVENTS - printf ("LeaveNotify! (%d,%d)\n", xevent.xcrossing.x, - xevent.xcrossing.y); + printf("LeaveNotify! (%d,%d)\n", xevent.xcrossing.x, + xevent.xcrossing.y); if (xevent.xcrossing.mode == NotifyGrab) - printf ("Mode: NotifyGrab\n"); + printf("Mode: NotifyGrab\n"); if (xevent.xcrossing.mode == NotifyUngrab) - printf ("Mode: NotifyUngrab\n"); + printf("Mode: NotifyUngrab\n"); #endif if ((xevent.xcrossing.mode != NotifyGrab) && (xevent.xcrossing.mode != NotifyUngrab) && (xevent.xcrossing.detail != NotifyInferior)) { if (SDL_CurrentWindow.input_grab == SDL_GRAB_OFF) { - posted = SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); + posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } else { - posted = SDL_PrivateMouseMotion (0, 0, - xevent.xcrossing.x, - xevent.xcrossing.y); + posted = SDL_PrivateMouseMotion(0, 0, + xevent.xcrossing.x, + xevent.xcrossing.y); } } } @@ -335,18 +335,18 @@ case FocusIn: { #ifdef DEBUG_XEVENTS - printf ("FocusIn!\n"); + printf("FocusIn!\n"); #endif - posted = SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS); + posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); #ifdef X_HAVE_UTF8_STRING if (SDL_IC != NULL) { - XSetICFocus (SDL_IC); + XSetICFocus(SDL_IC); } #endif /* Queue entry into fullscreen mode */ switch_waiting = 0x01 | SDL_FULLSCREEN; - switch_time = SDL_GetTicks () + 1500; + switch_time = SDL_GetTicks() + 1500; } break; @@ -354,18 +354,18 @@ case FocusOut: { #ifdef DEBUG_XEVENTS - printf ("FocusOut!\n"); + printf("FocusOut!\n"); #endif - posted = SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS); + posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); #ifdef X_HAVE_UTF8_STRING if (SDL_IC != NULL) { - XUnsetICFocus (SDL_IC); + XUnsetICFocus(SDL_IC); } #endif /* Queue leaving fullscreen mode */ switch_waiting = 0x01; - switch_time = SDL_GetTicks () + 200; + switch_time = SDL_GetTicks() + 200; } break; @@ -373,9 +373,9 @@ case KeymapNotify: { #ifdef DEBUG_XEVENTS - printf ("KeymapNotify!\n"); + printf("KeymapNotify!\n"); #endif - X11_SetKeyboardState (SDL_Display, xevent.xkeymap.key_vector); + X11_SetKeyboardState(SDL_Display, xevent.xkeymap.key_vector); } break; @@ -386,26 +386,26 @@ if (mouse_relative) { if (using_dga & DGA_MOUSE) { #ifdef DEBUG_MOTION - printf ("DGA motion: %d,%d\n", - xevent.xmotion.x_root, xevent.xmotion.y_root); + printf("DGA motion: %d,%d\n", + xevent.xmotion.x_root, xevent.xmotion.y_root); #endif - posted = SDL_PrivateMouseMotion (0, 1, - xevent. - xmotion. - x_root, - xevent. - xmotion.y_root); + posted = SDL_PrivateMouseMotion(0, 1, + xevent. + xmotion. + x_root, + xevent. + xmotion.y_root); } else { - posted = X11_WarpedMotion (_this, &xevent); + posted = X11_WarpedMotion(_this, &xevent); } } else { #ifdef DEBUG_MOTION - printf ("X11 motion: %d,%d\n", xevent.xmotion.x, - xevent.xmotion.y); + printf("X11 motion: %d,%d\n", xevent.xmotion.x, + xevent.xmotion.y); #endif - posted = SDL_PrivateMouseMotion (0, 0, - xevent.xmotion.x, - xevent.xmotion.y); + posted = SDL_PrivateMouseMotion(0, 0, + xevent.xmotion.x, + xevent.xmotion.y); } } } @@ -414,16 +414,16 @@ /* Mouse button press? */ case ButtonPress: { - posted = SDL_PrivateMouseButton (SDL_PRESSED, - xevent.xbutton.button, 0, 0); + posted = SDL_PrivateMouseButton(SDL_PRESSED, + xevent.xbutton.button, 0, 0); } break; /* Mouse button release? */ case ButtonRelease: { - posted = SDL_PrivateMouseButton (SDL_RELEASED, - xevent.xbutton.button, 0, 0); + posted = SDL_PrivateMouseButton(SDL_RELEASED, + xevent.xbutton.button, 0, 0); } break; @@ -435,12 +435,12 @@ KeyCode keycode = xevent.xkey.keycode; #ifdef DEBUG_XEVENTS - printf ("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode); + printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode); #endif /* Get the translated SDL virtual keysym */ if (keycode) { keysym.scancode = keycode; - keysym.sym = X11_TranslateKeycode (SDL_Display, keycode); + keysym.sym = X11_TranslateKeycode(SDL_Display, keycode); keysym.mod = KMOD_NONE; keysym.unicode = 0; } else { @@ -449,13 +449,13 @@ /* If we're not doing translation, we're done! */ if (!SDL_TranslateUNICODE) { - posted = SDL_PrivateKeyboard (SDL_PRESSED, &keysym); + posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym); break; } - if (XFilterEvent (&xevent, None)) { + if (XFilterEvent(&xevent, None)) { if (xevent.xkey.keycode) { - posted = SDL_PrivateKeyboard (SDL_PRESSED, &keysym); + posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym); } else { /* Save event to be associated with IM text In 1.3 we'll have a text event instead.. */ @@ -470,10 +470,9 @@ static Status state; /* A UTF-8 character can be at most 6 bytes */ char keybuf[6]; - if (Xutf8LookupString (SDL_IC, &xevent.xkey, - keybuf, sizeof (keybuf), - NULL, &state)) { - keysym.unicode = Utf8ToUcs4 ((Uint8 *) keybuf); + if (Xutf8LookupString(SDL_IC, &xevent.xkey, + keybuf, sizeof(keybuf), NULL, &state)) { + keysym.unicode = Utf8ToUcs4((Uint8 *) keybuf); } } else #endif @@ -481,8 +480,8 @@ static XComposeStatus state; char keybuf[32]; - if (XLookupString (&xevent.xkey, - keybuf, sizeof (keybuf), NULL, &state)) { + if (XLookupString(&xevent.xkey, + keybuf, sizeof(keybuf), NULL, &state)) { /* * FIXME: XLookupString() may yield more than one * character, so we need a mechanism to allow for @@ -492,7 +491,7 @@ keysym.unicode = (Uint8) keybuf[0]; } } - posted = SDL_PrivateKeyboard (SDL_PRESSED, &keysym); + posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym); } break; @@ -503,20 +502,20 @@ KeyCode keycode = xevent.xkey.keycode; #ifdef DEBUG_XEVENTS - printf ("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode); + printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode); #endif /* Check to see if this is a repeated key */ - if (X11_KeyRepeat (SDL_Display, &xevent)) { + if (X11_KeyRepeat(SDL_Display, &xevent)) { break; } /* Get the translated SDL virtual keysym */ keysym.scancode = keycode; - keysym.sym = X11_TranslateKeycode (SDL_Display, keycode); + keysym.sym = X11_TranslateKeycode(SDL_Display, keycode); keysym.mod = KMOD_NONE; keysym.unicode = 0; - posted = SDL_PrivateKeyboard (SDL_RELEASED, &keysym); + posted = SDL_PrivateKeyboard(SDL_RELEASED, &keysym); } break; @@ -524,17 +523,17 @@ case UnmapNotify: { #ifdef DEBUG_XEVENTS - printf ("UnmapNotify!\n"); + printf("UnmapNotify!\n"); #endif /* If we're active, make ourselves inactive */ - if (SDL_GetAppState () & SDL_APPACTIVE) { + if (SDL_GetAppState() & SDL_APPACTIVE) { /* Swap out the gamma before we go inactive */ - X11_SwapVidModeGamma (_this); + X11_SwapVidModeGamma(_this); /* Send an internal deactivate event */ - posted = SDL_PrivateAppActive (0, - SDL_APPACTIVE | - SDL_APPINPUTFOCUS); + posted = SDL_PrivateAppActive(0, + SDL_APPACTIVE | + SDL_APPINPUTFOCUS); } } break; @@ -543,27 +542,27 @@ case MapNotify: { #ifdef DEBUG_XEVENTS - printf ("MapNotify!\n"); + printf("MapNotify!\n"); #endif /* If we're not active, make ourselves active */ - if (!(SDL_GetAppState () & SDL_APPACTIVE)) { + if (!(SDL_GetAppState() & SDL_APPACTIVE)) { /* Send an internal activate event */ - posted = SDL_PrivateAppActive (1, SDL_APPACTIVE); + posted = SDL_PrivateAppActive(1, SDL_APPACTIVE); /* Now that we're active, swap the gamma back */ - X11_SwapVidModeGamma (_this); + X11_SwapVidModeGamma(_this); } if (SDL_VideoSurface && (SDL_VideoSurface->flags & SDL_FULLSCREEN)) { - X11_EnterFullScreen (_this); + X11_EnterFullScreen(_this); } else { - X11_GrabInputNoLock (_this, SDL_CurrentWindow.input_grab); + X11_GrabInputNoLock(_this, SDL_CurrentWindow.input_grab); } - X11_CheckMouseModeNoLock (_this); + X11_CheckMouseModeNoLock(_this); if (SDL_VideoSurface) { - X11_RefreshDisplay (_this); + X11_RefreshDisplay(_this); } } break; @@ -572,8 +571,8 @@ case ConfigureNotify: { #ifdef DEBUG_XEVENTS - printf ("ConfigureNotify! (resize: %dx%d)\n", - xevent.xconfigure.width, xevent.xconfigure.height); + printf("ConfigureNotify! (resize: %dx%d)\n", + xevent.xconfigure.width, xevent.xconfigure.height); #endif if (SDL_VideoSurface) { if ((xevent.xconfigure.width != SDL_VideoSurface->w) || @@ -581,13 +580,13 @@ /* FIXME: Find a better fix for the bug with KDE 1.2 */ if (!((xevent.xconfigure.width == 32) && (xevent.xconfigure.height == 32))) { - SDL_PrivateResize (xevent.xconfigure.width, - xevent.xconfigure.height); + SDL_PrivateResize(xevent.xconfigure.width, + xevent.xconfigure.height); } } else { /* OpenGL windows need to know about the change */ if (SDL_VideoSurface->flags & SDL_INTERNALOPENGL) { - SDL_PrivateExpose (); + SDL_PrivateExpose(); } } } @@ -599,14 +598,14 @@ { if ((xevent.xclient.format == 32) && (xevent.xclient.data.l[0] == WM_DELETE_WINDOW)) { - posted = SDL_PrivateQuit (); + posted = SDL_PrivateQuit(); } else if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) { SDL_SysWMmsg wmmsg; - SDL_VERSION (&wmmsg.version); + SDL_VERSION(&wmmsg.version); wmmsg.subsystem = SDL_SYSWM_X11; wmmsg.event.xevent = xevent; - posted = SDL_PrivateSysWMEvent (&wmmsg); + posted = SDL_PrivateSysWMEvent(&wmmsg); } } break; @@ -615,10 +614,10 @@ case Expose: { #ifdef DEBUG_XEVENTS - printf ("Expose (count = %d)\n", xevent.xexpose.count); + printf("Expose (count = %d)\n", xevent.xexpose.count); #endif if (SDL_VideoSurface && (xevent.xexpose.count == 0)) { - X11_RefreshDisplay (_this); + X11_RefreshDisplay(_this); } } break; @@ -626,16 +625,16 @@ default: { #ifdef DEBUG_XEVENTS - printf ("Unhandled event %d\n", xevent.type); + printf("Unhandled event %d\n", xevent.type); #endif /* Only post the event if we're watching for it */ if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) { SDL_SysWMmsg wmmsg; - SDL_VERSION (&wmmsg.version); + SDL_VERSION(&wmmsg.version); wmmsg.subsystem = SDL_SYSWM_X11; wmmsg.event.xevent = xevent; - posted = SDL_PrivateSysWMEvent (&wmmsg); + posted = SDL_PrivateSysWMEvent(&wmmsg); } } break; @@ -645,11 +644,11 @@ /* Ack! XPending() actually performs a blocking read if no events available */ int -X11_Pending (Display * display) +X11_Pending(Display * display) { /* Flush the display connection and look to see if events are queued */ - XFlush (display); - if (XEventsQueued (display, QueuedAlready)) { + XFlush(display); + if (XEventsQueued(display, QueuedAlready)) { return (1); } @@ -659,11 +658,11 @@ int x11_fd; fd_set fdset; - x11_fd = ConnectionNumber (display); - FD_ZERO (&fdset); - FD_SET (x11_fd, &fdset); - if (select (x11_fd + 1, &fdset, NULL, NULL, &zero_time) == 1) { - return (XPending (display)); + x11_fd = ConnectionNumber(display); + FD_ZERO(&fdset); + FD_SET(x11_fd, &fdset); + if (select(x11_fd + 1, &fdset, NULL, NULL, &zero_time) == 1) { + return (XPending(display)); } } @@ -672,20 +671,20 @@ } void -X11_PumpEvents (_THIS) +X11_PumpEvents(_THIS) { int pending; /* Keep processing pending events */ pending = 0; - while (X11_Pending (SDL_Display)) { - X11_DispatchEvent (_this); + while (X11_Pending(SDL_Display)) { + X11_DispatchEvent(_this); ++pending; } if (switch_waiting) { Uint32 now; - now = SDL_GetTicks (); + now = SDL_GetTicks(); if (pending || !SDL_VideoSurface) { /* Try again later... */ if (switch_waiting & SDL_FULLSCREEN) { @@ -700,29 +699,29 @@ switch_waiting = 0; if (SDL_VideoSurface->flags & SDL_FULLSCREEN) { if (go_fullscreen) { - X11_EnterFullScreen (_this); + X11_EnterFullScreen(_this); } else { - X11_LeaveFullScreen (_this); + X11_LeaveFullScreen(_this); } } /* Handle focus in/out when grabbed */ if (go_fullscreen) { - X11_GrabInputNoLock (_this, SDL_CurrentWindow.input_grab); + X11_GrabInputNoLock(_this, SDL_CurrentWindow.input_grab); } else { - X11_GrabInputNoLock (_this, SDL_GRAB_OFF); + X11_GrabInputNoLock(_this, SDL_GRAB_OFF); } - X11_CheckMouseModeNoLock (_this); + X11_CheckMouseModeNoLock(_this); } } } void -X11_InitKeymap (void) +X11_InitKeymap(void) { int i; /* Odd keys used in international keyboards */ - for (i = 0; i < SDL_arraysize (ODD_keymap); ++i) + for (i = 0; i < SDL_arraysize(ODD_keymap); ++i) ODD_keymap[i] = SDLK_UNKNOWN; /* Some of these might be mappable to an existing SDLK_ code */ @@ -758,7 +757,7 @@ #endif /* Map the miscellaneous keys */ - for (i = 0; i < SDL_arraysize (MISC_keymap); ++i) + for (i = 0; i < SDL_arraysize(MISC_keymap); ++i) MISC_keymap[i] = SDLK_UNKNOWN; /* These X keysyms have 0xFF as the high byte */ @@ -851,14 +850,14 @@ /* Get the translated SDL virtual keysym */ SDLKey -X11_TranslateKeycode (Display * display, KeyCode kc) +X11_TranslateKeycode(Display * display, KeyCode kc) { KeySym xsym; SDLKey key; - xsym = XKeycodeToKeysym (display, kc, 0); + xsym = XKeycodeToKeysym(display, kc, 0); #ifdef DEBUG_KEYS - fprintf (stderr, "Translating key code %d -> 0x%.4x\n", kc, xsym); + fprintf(stderr, "Translating key code %d -> 0x%.4x\n", kc, xsym); #endif key = SDLK_UNKNOWN; if (xsym) { @@ -934,7 +933,7 @@ static unsigned num_mask, mode_switch_mask; static void -get_modifier_masks (Display * display) +get_modifier_masks(Display * display) { static unsigned got_masks; int i, j; @@ -944,12 +943,12 @@ if (got_masks) return; - xmods = XGetModifierMapping (display); + xmods = XGetModifierMapping(display); n = xmods->max_keypermod; for (i = 3; i < 8; i++) { for (j = 0; j < n; j++) { KeyCode kc = xmods->modifiermap[i * n + j]; - KeySym ks = XKeycodeToKeysym (display, kc, 0); + KeySym ks = XKeycodeToKeysym(display, kc, 0); unsigned mask = 1 << i; switch (ks) { case XK_Num_Lock: @@ -973,7 +972,7 @@ } } } - XFreeModifiermap (xmods); + XFreeModifiermap(xmods); got_masks = 1; } @@ -989,9 +988,9 @@ * state has been irrevocably lost. */ Uint16 -X11_KeyToUnicode (SDLKey keysym, SDLMod modifiers) +X11_KeyToUnicode(SDLKey keysym, SDLMod modifiers) { - SDL_VideoDevice *_this = SDL_GetVideoDevice (); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); char keybuf[32]; int i; KeySym xsym = 0; @@ -1002,7 +1001,7 @@ return 0; } - SDL_memset (&xkey, 0, sizeof (xkey)); + SDL_memset(&xkey, 0, sizeof(xkey)); xkey.display = SDL_Display; xsym = keysym; /* last resort if not found */ @@ -1016,9 +1015,9 @@ } } - xkey.keycode = XKeysymToKeycode (xkey.display, xsym); + xkey.keycode = XKeysymToKeycode(xkey.display, xsym); - get_modifier_masks (SDL_Display); + get_modifier_masks(SDL_Display); if (modifiers & KMOD_SHIFT) xkey.state |= ShiftMask; if (modifiers & KMOD_CAPS) @@ -1039,7 +1038,7 @@ xkey.state |= num_mask; unicode = 0; - if (XLookupString (&xkey, keybuf, sizeof (keybuf), NULL, NULL)) + if (XLookupString(&xkey, keybuf, sizeof(keybuf), NULL, NULL)) unicode = (unsigned char) keybuf[0]; return (unicode); } @@ -1051,11 +1050,11 @@ * key_vec is a bit vector of keycodes (256 bits) */ void -X11_SetKeyboardState (Display * display, const char *key_vec) +X11_SetKeyboardState(Display * display, const char *key_vec) { char keys_return[32]; int i; - Uint8 *kstate = SDL_GetKeyState (NULL); + Uint8 *kstate = SDL_GetKeyState(NULL); SDLMod modstate; Window junk_window; int x, y; @@ -1063,15 +1062,15 @@ /* The first time the window is mapped, we initialize key state */ if (!key_vec) { - XQueryKeymap (display, keys_return); + XQueryKeymap(display, keys_return); key_vec = keys_return; } /* Get the keyboard modifier state */ modstate = 0; - get_modifier_masks (display); - if (XQueryPointer (display, DefaultRootWindow (display), - &junk_window, &junk_window, &x, &y, &x, &y, &mask)) { + get_modifier_masks(display); + if (XQueryPointer(display, DefaultRootWindow(display), + &junk_window, &junk_window, &x, &y, &x, &y, &mask)) { if (mask & LockMask) { modstate |= KMOD_CAPS; } @@ -1084,7 +1083,7 @@ } /* Zero the new keyboard state and generate it */ - SDL_memset (kstate, 0, SDLK_LAST); + SDL_memset(kstate, 0, SDLK_LAST); /* * An obvious optimisation is to check entire longwords at a time in * both loops, but we can't be sure the arrays are aligned so it's not @@ -1098,7 +1097,7 @@ if (key_vec[i] & (1 << j)) { SDLKey key; KeyCode kc = (i << 3 | j); - key = X11_TranslateKeycode (display, kc); + key = X11_TranslateKeycode(display, kc); if (key == SDLK_UNKNOWN) { continue; } @@ -1148,28 +1147,28 @@ } /* Set the final modifier state */ - SDL_SetModState (modstate); + SDL_SetModState(modstate); } void -X11_InitOSKeymap (_THIS) +X11_InitOSKeymap(_THIS) { - X11_InitKeymap (); + X11_InitKeymap(); } void -X11_SaveScreenSaver (Display * display, int *saved_timeout, BOOL * dpms) +X11_SaveScreenSaver(Display * display, int *saved_timeout, BOOL * dpms) { int timeout, interval, prefer_blank, allow_exp; - XGetScreenSaver (display, &timeout, &interval, &prefer_blank, &allow_exp); + XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp); *saved_timeout = timeout; #if SDL_VIDEO_DRIVER_X11_DPMS if (SDL_X11_HAVE_DPMS) { int dummy; - if (DPMSQueryExtension (display, &dummy, &dummy)) { + if (DPMSQueryExtension(display, &dummy, &dummy)) { CARD16 state; - DPMSInfo (display, &state, dpms); + DPMSInfo(display, &state, dpms); } } #else @@ -1178,37 +1177,37 @@ } void -X11_DisableScreenSaver (Display * display) +X11_DisableScreenSaver(Display * display) { int timeout, interval, prefer_blank, allow_exp; - XGetScreenSaver (display, &timeout, &interval, &prefer_blank, &allow_exp); + XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp); timeout = 0; - XSetScreenSaver (display, timeout, interval, prefer_blank, allow_exp); + XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp); #if SDL_VIDEO_DRIVER_X11_DPMS if (SDL_X11_HAVE_DPMS) { int dummy; - if (DPMSQueryExtension (display, &dummy, &dummy)) { - DPMSDisable (display); + if (DPMSQueryExtension(display, &dummy, &dummy)) { + DPMSDisable(display); } } #endif /* SDL_VIDEO_DRIVER_X11_DPMS */ } void -X11_RestoreScreenSaver (Display * display, int saved_timeout, BOOL dpms) +X11_RestoreScreenSaver(Display * display, int saved_timeout, BOOL dpms) { int timeout, interval, prefer_blank, allow_exp; - XGetScreenSaver (display, &timeout, &interval, &prefer_blank, &allow_exp); + XGetScreenSaver(display, &timeout, &interval, &prefer_blank, &allow_exp); timeout = saved_timeout; - XSetScreenSaver (display, timeout, interval, prefer_blank, allow_exp); + XSetScreenSaver(display, timeout, interval, prefer_blank, allow_exp); #if SDL_VIDEO_DRIVER_X11_DPMS if (SDL_X11_HAVE_DPMS) { int dummy; - if (DPMSQueryExtension (display, &dummy, &dummy)) { + if (DPMSQueryExtension(display, &dummy, &dummy)) { if (dpms) { - DPMSEnable (display); + DPMSEnable(display); } } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11events_c.h --- a/src/video/x11/SDL_x11events_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11events_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,13 +24,13 @@ #include "SDL_x11video.h" /* Functions to be exported */ -extern void X11_InitOSKeymap (_THIS); -extern void X11_PumpEvents (_THIS); -extern void X11_SetKeyboardState (Display * display, const char *key_vec); +extern void X11_InitOSKeymap(_THIS); +extern void X11_PumpEvents(_THIS); +extern void X11_SetKeyboardState(Display * display, const char *key_vec); -extern void X11_SaveScreenSaver (Display * display, int *saved_timeout, - BOOL * dpms); -extern void X11_DisableScreenSaver (Display * display); -extern void X11_RestoreScreenSaver (Display * display, int saved_timeout, - BOOL dpms); +extern void X11_SaveScreenSaver(Display * display, int *saved_timeout, + BOOL * dpms); +extern void X11_DisableScreenSaver(Display * display); +extern void X11_RestoreScreenSaver(Display * display, int saved_timeout, + BOOL dpms); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11gamma.c --- a/src/video/x11/SDL_x11gamma.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11gamma.c Mon May 29 04:04:35 2006 +0000 @@ -31,11 +31,11 @@ #define MIN_GAMMA (1.0/MAX_GAMMA) static int -X11_SetGammaNoLock (_THIS, float red, float green, float blue) +X11_SetGammaNoLock(_THIS, float red, float green, float blue) { #if SDL_VIDEO_DRIVER_X11_VIDMODE if (use_vidmode >= 200) { - SDL_NAME (XF86VidModeGamma) gamma; + SDL_NAME(XF86VidModeGamma) gamma; Bool succeeded; /* Clamp the gamma values */ @@ -60,11 +60,11 @@ } else { gamma.blue = blue; } - if (SDL_GetAppState () & SDL_APPACTIVE) { + if (SDL_GetAppState() & SDL_APPACTIVE) { succeeded = - SDL_NAME (XF86VidModeSetGamma) (SDL_Display, SDL_Screen, - &gamma); - XSync (SDL_Display, False); + SDL_NAME(XF86VidModeSetGamma) (SDL_Display, SDL_Screen, + &gamma); + XSync(SDL_Display, False); } else { gamma_saved[0] = gamma.red; gamma_saved[1] = gamma.green; @@ -77,29 +77,29 @@ return succeeded ? 0 : -1; } #endif - SDL_SetError ("Gamma correction not supported"); + SDL_SetError("Gamma correction not supported"); return -1; } int -X11_SetVidModeGamma (_THIS, float red, float green, float blue) +X11_SetVidModeGamma(_THIS, float red, float green, float blue) { int result; - SDL_Lock_EventThread (); - result = X11_SetGammaNoLock (this, red, green, blue); - SDL_Unlock_EventThread (); + SDL_Lock_EventThread(); + result = X11_SetGammaNoLock(this, red, green, blue); + SDL_Unlock_EventThread(); return (result); } static int -X11_GetGammaNoLock (_THIS, float *red, float *green, float *blue) +X11_GetGammaNoLock(_THIS, float *red, float *green, float *blue) { #if SDL_VIDEO_DRIVER_X11_VIDMODE if (use_vidmode >= 200) { - SDL_NAME (XF86VidModeGamma) gamma; - if (SDL_NAME (XF86VidModeGetGamma) + SDL_NAME(XF86VidModeGamma) gamma; + if (SDL_NAME(XF86VidModeGetGamma) (SDL_Display, SDL_Screen, &gamma)) { *red = gamma.red; *green = gamma.green; @@ -113,24 +113,24 @@ } int -X11_GetVidModeGamma (_THIS, float *red, float *green, float *blue) +X11_GetVidModeGamma(_THIS, float *red, float *green, float *blue) { int result; - SDL_Lock_EventThread (); - result = X11_GetGammaNoLock (this, red, green, blue); - SDL_Unlock_EventThread (); + SDL_Lock_EventThread(); + result = X11_GetGammaNoLock(this, red, green, blue); + SDL_Unlock_EventThread(); return (result); } void -X11_SaveVidModeGamma (_THIS) +X11_SaveVidModeGamma(_THIS) { /* Try to save the current gamma, otherwise disable gamma control */ - if (X11_GetGammaNoLock (this, - &gamma_saved[0], &gamma_saved[1], - &gamma_saved[2]) < 0) { + if (X11_GetGammaNoLock(this, + &gamma_saved[0], &gamma_saved[1], + &gamma_saved[2]) < 0) { this->SetGamma = 0; this->GetGamma = 0; } @@ -138,7 +138,7 @@ } void -X11_SwapVidModeGamma (_THIS) +X11_SwapVidModeGamma(_THIS) { float new_gamma[3]; @@ -146,9 +146,9 @@ new_gamma[0] = gamma_saved[0]; new_gamma[1] = gamma_saved[1]; new_gamma[2] = gamma_saved[2]; - X11_GetGammaNoLock (this, &gamma_saved[0], &gamma_saved[1], - &gamma_saved[2]); - X11_SetGammaNoLock (this, new_gamma[0], new_gamma[1], new_gamma[2]); + X11_GetGammaNoLock(this, &gamma_saved[0], &gamma_saved[1], + &gamma_saved[2]); + X11_SetGammaNoLock(this, new_gamma[0], new_gamma[1], new_gamma[2]); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11gamma_c.h --- a/src/video/x11/SDL_x11gamma_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11gamma_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,10 +24,10 @@ #ifndef _SDL_x11gamma_h #define _SDL_x11gamma_h -extern int X11_SetVidModeGamma (_THIS, float red, float green, float blue); -extern int X11_GetVidModeGamma (_THIS, float *red, float *green, float *blue); -extern void X11_SaveVidModeGamma (_THIS); -extern void X11_SwapVidModeGamma (_THIS); +extern int X11_SetVidModeGamma(_THIS, float red, float green, float blue); +extern int X11_GetVidModeGamma(_THIS, float *red, float *green, float *blue); +extern void X11_SaveVidModeGamma(_THIS); +extern void X11_SwapVidModeGamma(_THIS); #endif /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11gl.c --- a/src/video/x11/SDL_x11gl.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11gl.c Mon May 29 04:04:35 2006 +0000 @@ -53,20 +53,20 @@ #if SDL_VIDEO_OPENGL_GLX static int -glXExtensionSupported (_THIS, const char *extension) +glXExtensionSupported(_THIS, const char *extension) { const char *extensions; const char *start; const char *where, *terminator; /* Extension names should not have spaces. */ - where = SDL_strchr (extension, ' '); + where = SDL_strchr(extension, ' '); if (where || *extension == '\0') { return 0; } extensions = - this->gl_data->glXQueryExtensionsString (GFX_Display, SDL_Screen); + this->gl_data->glXQueryExtensionsString(GFX_Display, SDL_Screen); /* It takes a bit of care to be fool-proof about parsing the * OpenGL extensions string. Don't be fooled by sub-strings, etc. */ @@ -74,11 +74,11 @@ start = extensions; for (;;) { - where = SDL_strstr (start, extension); + where = SDL_strstr(start, extension); if (!where) break; - terminator = where + strlen (extension); + terminator = where + strlen(extension); if (where == start || *(where - 1) == ' ') if (*terminator == ' ' || *terminator == '\0') return 1; @@ -90,7 +90,7 @@ #endif /* SDL_VIDEO_OPENGL_GLX */ XVisualInfo * -X11_GL_GetVisual (_THIS) +X11_GL_GetVisual(_THIS) { #if SDL_VIDEO_OPENGL_GLX /* 64 seems nice. */ @@ -100,7 +100,7 @@ /* load the gl driver from a default path */ if (!this->gl_config.driver_loaded) { /* no driver has been loaded, use default (ourselves) */ - if (X11_GL_LoadLibrary (this, NULL) < 0) { + if (X11_GL_LoadLibrary(this, NULL) < 0) { return NULL; } } @@ -111,12 +111,12 @@ XVisualInfo vi_in; int out_count; - XGetWindowAttributes (SDL_Display, SDL_Window, &a); + XGetWindowAttributes(SDL_Display, SDL_Window, &a); vi_in.screen = SDL_Screen; - vi_in.visualid = XVisualIDFromVisual (a.visual); - glx_visualinfo = XGetVisualInfo (SDL_Display, - VisualScreenMask | VisualIDMask, - &vi_in, &out_count); + vi_in.visualid = XVisualIDFromVisual(a.visual); + glx_visualinfo = XGetVisualInfo(SDL_Display, + VisualScreenMask | VisualIDMask, + &vi_in, &out_count); return glx_visualinfo; } @@ -187,29 +187,29 @@ } if (this->gl_config.accelerated >= 0 && - glXExtensionSupported (this, "GLX_EXT_visual_rating")) { + glXExtensionSupported(this, "GLX_EXT_visual_rating")) { attribs[i++] = GLX_VISUAL_CAVEAT_EXT; attribs[i++] = GLX_NONE_EXT; } #ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */ - if (!SDL_getenv ("SDL_VIDEO_X11_NODIRECTCOLOR")) { + if (!SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR")) { attribs[i++] = GLX_X_VISUAL_TYPE; attribs[i++] = GLX_DIRECT_COLOR; } #endif attribs[i++] = None; - glx_visualinfo = this->gl_data->glXChooseVisual (GFX_Display, - SDL_Screen, attribs); + glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display, + SDL_Screen, attribs); #ifdef GLX_DIRECT_COLOR - if (!glx_visualinfo && !SDL_getenv ("SDL_VIDEO_X11_NODIRECTCOLOR")) { /* No DirectColor visual? Try again.. */ + if (!glx_visualinfo && !SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR")) { /* No DirectColor visual? Try again.. */ attribs[i - 3] = None; - glx_visualinfo = this->gl_data->glXChooseVisual (GFX_Display, - SDL_Screen, attribs); + glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display, + SDL_Screen, attribs); } #endif if (!glx_visualinfo) { - SDL_SetError ("Couldn't find matching GLX visual"); + SDL_SetError("Couldn't find matching GLX visual"); return NULL; } /* @@ -217,13 +217,13 @@ */ return glx_visualinfo; #else - SDL_SetError ("X11 driver not configured with OpenGL"); + SDL_SetError("X11 driver not configured with OpenGL"); return NULL; #endif } int -X11_GL_CreateWindow (_THIS, int w, int h) +X11_GL_CreateWindow(_THIS, int w, int h) { int retval; #if SDL_VIDEO_OPENGL_GLX @@ -231,68 +231,66 @@ unsigned long mask; unsigned long black; - black = (glx_visualinfo->visual == DefaultVisual (SDL_Display, - SDL_Screen)) - ? BlackPixel (SDL_Display, SDL_Screen) : 0; + black = (glx_visualinfo->visual == DefaultVisual(SDL_Display, SDL_Screen)) + ? BlackPixel(SDL_Display, SDL_Screen) : 0; attributes.background_pixel = black; attributes.border_pixel = black; attributes.colormap = SDL_XColorMap; mask = CWBackPixel | CWBorderPixel | CWColormap; - SDL_Window = XCreateWindow (SDL_Display, WMwindow, - 0, 0, w, h, 0, glx_visualinfo->depth, - InputOutput, glx_visualinfo->visual, - mask, &attributes); + SDL_Window = XCreateWindow(SDL_Display, WMwindow, + 0, 0, w, h, 0, glx_visualinfo->depth, + InputOutput, glx_visualinfo->visual, + mask, &attributes); if (!SDL_Window) { - SDL_SetError ("Could not create window"); + SDL_SetError("Could not create window"); return -1; } retval = 0; #else - SDL_SetError ("X11 driver not configured with OpenGL"); + SDL_SetError("X11 driver not configured with OpenGL"); retval = -1; #endif return (retval); } int -X11_GL_CreateContext (_THIS) +X11_GL_CreateContext(_THIS) { int retval; #if SDL_VIDEO_OPENGL_GLX /* We do this to create a clean separation between X and GLX errors. */ - XSync (SDL_Display, False); - glx_context = this->gl_data->glXCreateContext (GFX_Display, - glx_visualinfo, NULL, - True); - XSync (GFX_Display, False); + XSync(SDL_Display, False); + glx_context = this->gl_data->glXCreateContext(GFX_Display, + glx_visualinfo, NULL, True); + XSync(GFX_Display, False); if (glx_context == NULL) { - SDL_SetError ("Could not create GL context"); + SDL_SetError("Could not create GL context"); return (-1); } - if (X11_GL_MakeCurrent (this) < 0) { + if (X11_GL_MakeCurrent(this) < 0) { return (-1); } gl_active = 1; - if (!glXExtensionSupported (this, "SGI_swap_control")) { + if (!glXExtensionSupported(this, "SGI_swap_control")) { this->gl_data->glXSwapIntervalSGI = NULL; } - if (!glXExtensionSupported (this, "GLX_MESA_swap_control")) { + if (!glXExtensionSupported(this, "GLX_MESA_swap_control")) { this->gl_data->glXSwapIntervalMESA = NULL; this->gl_data->glXGetSwapIntervalMESA = NULL; } if (this->gl_config.swap_control >= 0) { if (this->gl_data->glXSwapIntervalMESA) { - this->gl_data->glXSwapIntervalMESA (this->gl_config.swap_control); + this->gl_data->glXSwapIntervalMESA(this->gl_config.swap_control); } else if (this->gl_data->glXSwapIntervalSGI) { - this->gl_data->glXSwapIntervalSGI (this->gl_config.swap_control); + this->gl_data->glXSwapIntervalSGI(this->gl_config.swap_control); } } #else - SDL_SetError ("X11 driver not configured with OpenGL"); + SDL_SetError("X11 driver not configured with OpenGL"); #endif if (gl_active) { retval = 0; @@ -303,15 +301,15 @@ } void -X11_GL_Shutdown (_THIS) +X11_GL_Shutdown(_THIS) { #if SDL_VIDEO_OPENGL_GLX /* Clean up OpenGL */ if (glx_context) { - this->gl_data->glXMakeCurrent (GFX_Display, None, NULL); + this->gl_data->glXMakeCurrent(GFX_Display, None, NULL); if (glx_context != NULL) - this->gl_data->glXDestroyContext (GFX_Display, glx_context); + this->gl_data->glXDestroyContext(GFX_Display, glx_context); glx_context = NULL; } @@ -323,28 +321,28 @@ /* Make the current context active */ int -X11_GL_MakeCurrent (_THIS) +X11_GL_MakeCurrent(_THIS) { int retval; retval = 0; - if (!this->gl_data->glXMakeCurrent (GFX_Display, SDL_Window, glx_context)) { - SDL_SetError ("Unable to make GL context current"); + if (!this->gl_data->glXMakeCurrent(GFX_Display, SDL_Window, glx_context)) { + SDL_SetError("Unable to make GL context current"); retval = -1; } - XSync (GFX_Display, False); + XSync(GFX_Display, False); /* More Voodoo X server workarounds... Grr... */ - SDL_Lock_EventThread (); - X11_CheckDGAMouse (this); - SDL_Unlock_EventThread (); + SDL_Lock_EventThread(); + X11_CheckDGAMouse(this); + SDL_Unlock_EventThread(); return (retval); } /* Get attribute data from glX. */ int -X11_GL_GetAttribute (_THIS, SDL_GLattr attrib, int *value) +X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) { int retval; int glx_attrib = None; @@ -396,11 +394,11 @@ glx_attrib = GLX_SAMPLES_ARB; break; case SDL_GL_ACCELERATED_VISUAL: - if (glXExtensionSupported (this, "GLX_EXT_visual_rating")) { + if (glXExtensionSupported(this, "GLX_EXT_visual_rating")) { glx_attrib = GLX_VISUAL_CAVEAT_EXT; retval = - this->gl_data->glXGetConfig (GFX_Display, glx_visualinfo, - glx_attrib, value); + this->gl_data->glXGetConfig(GFX_Display, glx_visualinfo, + glx_attrib, value); if (*value == GLX_SLOW_VISUAL_EXT) { *value = SDL_FALSE; } else { @@ -413,7 +411,7 @@ break; case SDL_GL_SWAP_CONTROL: if (this->gl_data->glXGetSwapIntervalMESA) { - return this->gl_data->glXGetSwapIntervalMESA (); + return this->gl_data->glXGetSwapIntervalMESA(); } else { return (-1) /*(this->gl_config.swap_control > 0) */ ; } @@ -423,27 +421,27 @@ } retval = - this->gl_data->glXGetConfig (GFX_Display, glx_visualinfo, glx_attrib, - value); + this->gl_data->glXGetConfig(GFX_Display, glx_visualinfo, glx_attrib, + value); return retval; } void -X11_GL_SwapBuffers (_THIS) +X11_GL_SwapBuffers(_THIS) { - this->gl_data->glXSwapBuffers (GFX_Display, SDL_Window); + this->gl_data->glXSwapBuffers(GFX_Display, SDL_Window); } #endif /* SDL_VIDEO_OPENGL_GLX */ void -X11_GL_UnloadLibrary (_THIS) +X11_GL_UnloadLibrary(_THIS) { #if SDL_VIDEO_OPENGL_GLX if (this->gl_config.driver_loaded) { - SDL_UnloadObject (this->gl_config.dll_handle); + SDL_UnloadObject(this->gl_config.dll_handle); this->gl_data->glXGetProcAddress = NULL; this->gl_data->glXChooseVisual = NULL; @@ -465,63 +463,62 @@ /* Passing a NULL path means load pointers from the application */ int -X11_GL_LoadLibrary (_THIS, const char *path) +X11_GL_LoadLibrary(_THIS, const char *path) { void *handle = NULL; if (gl_active) { - SDL_SetError ("OpenGL context already created"); + SDL_SetError("OpenGL context already created"); return -1; } if (path == NULL) { - path = SDL_getenv ("SDL_VIDEO_GL_DRIVER"); + path = SDL_getenv("SDL_VIDEO_GL_DRIVER"); if (path == NULL) { path = DEFAULT_OPENGL; } } - handle = SDL_LoadObject (path); + handle = SDL_LoadObject(path); if (handle == NULL) { /* SDL_LoadObject() will call SDL_SetError() for us. */ return -1; } /* Unload the old driver and reset the pointers */ - X11_GL_UnloadLibrary (this); + X11_GL_UnloadLibrary(this); /* Load new function pointers */ this->gl_data->glXGetProcAddress = - (void *(*)(const GLubyte *)) SDL_LoadFunction (handle, - "glXGetProcAddressARB"); + (void *(*)(const GLubyte *)) SDL_LoadFunction(handle, + "glXGetProcAddressARB"); this->gl_data->glXChooseVisual = - (XVisualInfo * (*)(Display *, int, int *)) SDL_LoadFunction (handle, - "glXChooseVisual"); + (XVisualInfo * (*)(Display *, int, int *)) SDL_LoadFunction(handle, + "glXChooseVisual"); this->gl_data->glXCreateContext = - (GLXContext (*)(Display *, XVisualInfo *, GLXContext, int)) - SDL_LoadFunction (handle, "glXCreateContext"); + (GLXContext(*)(Display *, XVisualInfo *, GLXContext, int)) + SDL_LoadFunction(handle, "glXCreateContext"); this->gl_data->glXDestroyContext = - (void (*)(Display *, GLXContext)) SDL_LoadFunction (handle, - "glXDestroyContext"); + (void (*)(Display *, GLXContext)) SDL_LoadFunction(handle, + "glXDestroyContext"); this->gl_data->glXMakeCurrent = (int (*)(Display *, GLXDrawable, GLXContext)) - SDL_LoadFunction (handle, "glXMakeCurrent"); + SDL_LoadFunction(handle, "glXMakeCurrent"); this->gl_data->glXSwapBuffers = - (void (*)(Display *, GLXDrawable)) SDL_LoadFunction (handle, - "glXSwapBuffers"); + (void (*)(Display *, GLXDrawable)) SDL_LoadFunction(handle, + "glXSwapBuffers"); this->gl_data->glXGetConfig = (int (*)(Display *, XVisualInfo *, int, int *)) - SDL_LoadFunction (handle, "glXGetConfig"); + SDL_LoadFunction(handle, "glXGetConfig"); this->gl_data->glXQueryExtensionsString = - (const char *(*)(Display *, int)) SDL_LoadFunction (handle, - "glXQueryExtensionsString"); + (const char *(*)(Display *, int)) SDL_LoadFunction(handle, + "glXQueryExtensionsString"); this->gl_data->glXSwapIntervalSGI = - (int (*)(int)) SDL_LoadFunction (handle, "glXSwapIntervalSGI"); + (int (*)(int)) SDL_LoadFunction(handle, "glXSwapIntervalSGI"); this->gl_data->glXSwapIntervalMESA = - (GLint (*)(unsigned)) SDL_LoadFunction (handle, - "glXSwapIntervalMESA"); + (GLint(*)(unsigned)) SDL_LoadFunction(handle, "glXSwapIntervalMESA"); this->gl_data->glXGetSwapIntervalMESA = - (GLint (*)(void)) SDL_LoadFunction (handle, "glXGetSwapIntervalMESA"); + (GLint(*)(void)) SDL_LoadFunction(handle, "glXGetSwapIntervalMESA"); if ((this->gl_data->glXChooseVisual == NULL) || (this->gl_data->glXCreateContext == NULL) || @@ -530,15 +527,15 @@ (this->gl_data->glXSwapBuffers == NULL) || (this->gl_data->glXGetConfig == NULL) || (this->gl_data->glXQueryExtensionsString == NULL)) { - SDL_SetError ("Could not retrieve OpenGL functions"); + SDL_SetError("Could not retrieve OpenGL functions"); return -1; } this->gl_config.dll_handle = handle; this->gl_config.driver_loaded = 1; if (path) { - SDL_strlcpy (this->gl_config.driver_path, path, - SDL_arraysize (this->gl_config.driver_path)); + SDL_strlcpy(this->gl_config.driver_path, path, + SDL_arraysize(this->gl_config.driver_path)); } else { *this->gl_config.driver_path = '\0'; } @@ -546,15 +543,15 @@ } void * -X11_GL_GetProcAddress (_THIS, const char *proc) +X11_GL_GetProcAddress(_THIS, const char *proc) { void *handle; handle = this->gl_config.dll_handle; if (this->gl_data->glXGetProcAddress) { - return this->gl_data->glXGetProcAddress ((const GLubyte *) proc); + return this->gl_data->glXGetProcAddress((const GLubyte *) proc); } - return SDL_LoadFunction (handle, proc); + return SDL_LoadFunction(handle, proc); } #endif /* SDL_VIDEO_OPENGL_GLX */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11gl_c.h --- a/src/video/x11/SDL_x11gl_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11gl_c.h Mon May 29 04:04:35 2006 +0000 @@ -41,12 +41,12 @@ XVisualInfo *(*glXChooseVisual) (Display * dpy, int screen, int *attribList); - GLXContext (*glXCreateContext) + GLXContext(*glXCreateContext) (Display * dpy, XVisualInfo * vis, GLXContext shareList, Bool direct); void (*glXDestroyContext) (Display * dpy, GLXContext ctx); - Bool (*glXMakeCurrent) + Bool(*glXMakeCurrent) (Display * dpy, GLXDrawable drawable, GLXContext ctx); void (*glXSwapBuffers) (Display * dpy, GLXDrawable drawable); @@ -57,8 +57,8 @@ const char *(*glXQueryExtensionsString) (Display * dpy, int screen); int (*glXSwapIntervalSGI) (int interval); - GLint (*glXSwapIntervalMESA) (unsigned interval); - GLint (*glXGetSwapIntervalMESA) (void); + GLint(*glXSwapIntervalMESA) (unsigned interval); + GLint(*glXGetSwapIntervalMESA) (void); #endif /* SDL_VIDEO_OPENGL_GLX */ }; @@ -69,16 +69,16 @@ #define glx_visualinfo (this->gl_data->glx_visualinfo) /* OpenGL functions */ -extern XVisualInfo *X11_GL_GetVisual (_THIS); -extern int X11_GL_CreateWindow (_THIS, int w, int h); -extern int X11_GL_CreateContext (_THIS); -extern void X11_GL_Shutdown (_THIS); +extern XVisualInfo *X11_GL_GetVisual(_THIS); +extern int X11_GL_CreateWindow(_THIS, int w, int h); +extern int X11_GL_CreateContext(_THIS); +extern void X11_GL_Shutdown(_THIS); #if SDL_VIDEO_OPENGL_GLX -extern int X11_GL_MakeCurrent (_THIS); -extern int X11_GL_GetAttribute (_THIS, SDL_GLattr attrib, int *value); -extern void X11_GL_SwapBuffers (_THIS); -extern int X11_GL_LoadLibrary (_THIS, const char *path); -extern void *X11_GL_GetProcAddress (_THIS, const char *proc); +extern int X11_GL_MakeCurrent(_THIS); +extern int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value); +extern void X11_GL_SwapBuffers(_THIS); +extern int X11_GL_LoadLibrary(_THIS, const char *path); +extern void *X11_GL_GetProcAddress(_THIS, const char *proc); #endif -extern void X11_GL_UnloadLibrary (_THIS); +extern void X11_GL_UnloadLibrary(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11image.c --- a/src/video/x11/SDL_x11image.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11image.c Mon May 29 04:04:35 2006 +0000 @@ -34,17 +34,17 @@ static int shm_error; static int (*X_handler) (Display *, XErrorEvent *) = NULL; static int -shm_errhandler (Display * d, XErrorEvent * e) +shm_errhandler(Display * d, XErrorEvent * e) { if (e->error_code == BadAccess) { shm_error = True; return (0); } else - return (X_handler (d, e)); + return (X_handler(d, e)); } static void -try_mitshm (_THIS, SDL_Surface * screen) +try_mitshm(_THIS, SDL_Surface * screen) { /* Dynamic X11 may not have SHM entry points on this box. */ if ((use_mitshm) && (!SDL_X11_HAVE_SHM)) @@ -52,23 +52,23 @@ if (!use_mitshm) return; - shminfo.shmid = shmget (IPC_PRIVATE, screen->h * screen->pitch, - IPC_CREAT | 0777); + shminfo.shmid = shmget(IPC_PRIVATE, screen->h * screen->pitch, + IPC_CREAT | 0777); if (shminfo.shmid >= 0) { - shminfo.shmaddr = (char *) shmat (shminfo.shmid, 0, 0); + shminfo.shmaddr = (char *) shmat(shminfo.shmid, 0, 0); shminfo.readOnly = False; if (shminfo.shmaddr != (char *) -1) { shm_error = False; - X_handler = XSetErrorHandler (shm_errhandler); - XShmAttach (SDL_Display, &shminfo); - XSync (SDL_Display, True); - XSetErrorHandler (X_handler); + X_handler = XSetErrorHandler(shm_errhandler); + XShmAttach(SDL_Display, &shminfo); + XSync(SDL_Display, True); + XSetErrorHandler(X_handler); if (shm_error) - shmdt (shminfo.shmaddr); + shmdt(shminfo.shmaddr); } else { shm_error = True; } - shmctl (shminfo.shmid, IPC_RMID, NULL); + shmctl(shminfo.shmid, IPC_RMID, NULL); } else { shm_error = True; } @@ -80,23 +80,23 @@ #endif /* ! NO_SHARED_MEMORY */ /* Various screen update functions available */ -static void X11_NormalUpdate (_THIS, int numrects, SDL_Rect * rects); -static void X11_MITSHMUpdate (_THIS, int numrects, SDL_Rect * rects); +static void X11_NormalUpdate(_THIS, int numrects, SDL_Rect * rects); +static void X11_MITSHMUpdate(_THIS, int numrects, SDL_Rect * rects); int -X11_SetupImage (_THIS, SDL_Surface * screen) +X11_SetupImage(_THIS, SDL_Surface * screen) { #ifndef NO_SHARED_MEMORY - try_mitshm (this, screen); + try_mitshm(this, screen); if (use_mitshm) { - SDL_Ximage = XShmCreateImage (SDL_Display, SDL_Visual, - this->hidden->depth, ZPixmap, - shminfo.shmaddr, &shminfo, - screen->w, screen->h); + SDL_Ximage = XShmCreateImage(SDL_Display, SDL_Visual, + this->hidden->depth, ZPixmap, + shminfo.shmaddr, &shminfo, + screen->w, screen->h); if (!SDL_Ximage) { - XShmDetach (SDL_Display, &shminfo); - XSync (SDL_Display, False); - shmdt (shminfo.shmaddr); + XShmDetach(SDL_Display, &shminfo); + XSync(SDL_Display, False); + shmdt(shminfo.shmaddr); screen->pixels = NULL; goto error; } @@ -106,16 +106,16 @@ #endif /* not NO_SHARED_MEMORY */ { int bpp; - screen->pixels = SDL_malloc (screen->h * screen->pitch); + screen->pixels = SDL_malloc(screen->h * screen->pitch); if (screen->pixels == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return -1; } bpp = screen->format->BytesPerPixel; - SDL_Ximage = XCreateImage (SDL_Display, SDL_Visual, - this->hidden->depth, ZPixmap, 0, - (char *) screen->pixels, - screen->w, screen->h, 32, 0); + SDL_Ximage = XCreateImage(SDL_Display, SDL_Visual, + this->hidden->depth, ZPixmap, 0, + (char *) screen->pixels, + screen->w, screen->h, 32, 0); if (SDL_Ximage == NULL) goto error; /* XPutImage will convert byte sex automatically */ @@ -127,20 +127,20 @@ return (0); error: - SDL_SetError ("Couldn't create XImage"); + SDL_SetError("Couldn't create XImage"); return 1; } void -X11_DestroyImage (_THIS, SDL_Surface * screen) +X11_DestroyImage(_THIS, SDL_Surface * screen) { if (SDL_Ximage) { - XDestroyImage (SDL_Ximage); + XDestroyImage(SDL_Ximage); #ifndef NO_SHARED_MEMORY if (use_mitshm) { - XShmDetach (SDL_Display, &shminfo); - XSync (SDL_Display, False); - shmdt (shminfo.shmaddr); + XShmDetach(SDL_Display, &shminfo); + XSync(SDL_Display, False); + shmdt(shminfo.shmaddr); } #endif /* ! NO_SHARED_MEMORY */ SDL_Ximage = NULL; @@ -152,30 +152,30 @@ /* Determine the number of CPUs in the system */ static int -num_CPU (void) +num_CPU(void) { static int num_cpus = 0; if (!num_cpus) { #if defined(__LINUX__) char line[BUFSIZ]; - FILE *pstat = fopen ("/proc/stat", "r"); + FILE *pstat = fopen("/proc/stat", "r"); if (pstat) { - while (fgets (line, sizeof (line), pstat)) { - if (SDL_memcmp (line, "cpu", 3) == 0 && line[3] != ' ') { + while (fgets(line, sizeof(line), pstat)) { + if (SDL_memcmp(line, "cpu", 3) == 0 && line[3] != ' ') { ++num_cpus; } } - fclose (pstat); + fclose(pstat); } #elif defined(__IRIX__) - num_cpus = sysconf (_SC_NPROC_ONLN); + num_cpus = sysconf(_SC_NPROC_ONLN); #elif defined(_SC_NPROCESSORS_ONLN) /* number of processors online (SVR4.0MP compliant machines) */ - num_cpus = sysconf (_SC_NPROCESSORS_ONLN); + num_cpus = sysconf(_SC_NPROCESSORS_ONLN); #elif defined(_SC_NPROCESSORS_CONF) /* number of processors configured (SVR4.0MP compliant machines) */ - num_cpus = sysconf (_SC_NPROCESSORS_CONF); + num_cpus = sysconf(_SC_NPROCESSORS_CONF); #endif if (num_cpus <= 0) { num_cpus = 1; @@ -185,15 +185,15 @@ } int -X11_ResizeImage (_THIS, SDL_Surface * screen, Uint32 flags) +X11_ResizeImage(_THIS, SDL_Surface * screen, Uint32 flags) { int retval; - X11_DestroyImage (this, screen); + X11_DestroyImage(this, screen); if (flags & SDL_INTERNALOPENGL) { /* No image when using GL */ retval = 0; } else { - retval = X11_SetupImage (this, screen); + retval = X11_SetupImage(this, screen); /* We support asynchronous blitting on the display */ if (flags & SDL_ASYNCBLIT) { /* This is actually slower on single-CPU systems, @@ -201,7 +201,7 @@ X server and the application. Note: Is this still true with XFree86 4.0? */ - if (num_CPU () > 1) { + if (num_CPU() > 1) { screen->flags |= SDL_ASYNCBLIT; } } @@ -211,41 +211,41 @@ /* We don't actually allow hardware surfaces other than the main one */ int -X11_AllocHWSurface (_THIS, SDL_Surface * surface) +X11_AllocHWSurface(_THIS, SDL_Surface * surface) { return (-1); } void -X11_FreeHWSurface (_THIS, SDL_Surface * surface) +X11_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } int -X11_LockHWSurface (_THIS, SDL_Surface * surface) +X11_LockHWSurface(_THIS, SDL_Surface * surface) { if ((surface == SDL_VideoSurface) && blit_queued) { - XSync (GFX_Display, False); + XSync(GFX_Display, False); blit_queued = 0; } return (0); } void -X11_UnlockHWSurface (_THIS, SDL_Surface * surface) +X11_UnlockHWSurface(_THIS, SDL_Surface * surface) { return; } int -X11_FlipHWSurface (_THIS, SDL_Surface * surface) +X11_FlipHWSurface(_THIS, SDL_Surface * surface) { return (0); } static void -X11_NormalUpdate (_THIS, int numrects, SDL_Rect * rects) +X11_NormalUpdate(_THIS, int numrects, SDL_Rect * rects) { int i; @@ -253,20 +253,20 @@ if (rects[i].w == 0 || rects[i].h == 0) { /* Clipped? */ continue; } - XPutImage (GFX_Display, SDL_Window, SDL_GC, SDL_Ximage, - rects[i].x, rects[i].y, - rects[i].x, rects[i].y, rects[i].w, rects[i].h); + XPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage, + rects[i].x, rects[i].y, + rects[i].x, rects[i].y, rects[i].w, rects[i].h); } if (SDL_VideoSurface->flags & SDL_ASYNCBLIT) { - XFlush (GFX_Display); + XFlush(GFX_Display); blit_queued = 1; } else { - XSync (GFX_Display, False); + XSync(GFX_Display, False); } } static void -X11_MITSHMUpdate (_THIS, int numrects, SDL_Rect * rects) +X11_MITSHMUpdate(_THIS, int numrects, SDL_Rect * rects) { #ifndef NO_SHARED_MEMORY int i; @@ -275,15 +275,15 @@ if (rects[i].w == 0 || rects[i].h == 0) { /* Clipped? */ continue; } - XShmPutImage (GFX_Display, SDL_Window, SDL_GC, SDL_Ximage, - rects[i].x, rects[i].y, - rects[i].x, rects[i].y, rects[i].w, rects[i].h, False); + XShmPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage, + rects[i].x, rects[i].y, + rects[i].x, rects[i].y, rects[i].w, rects[i].h, False); } if (SDL_VideoSurface->flags & SDL_ASYNCBLIT) { - XFlush (GFX_Display); + XFlush(GFX_Display); blit_queued = 1; } else { - XSync (GFX_Display, False); + XSync(GFX_Display, False); } #endif /* ! NO_SHARED_MEMORY */ } @@ -297,44 +297,44 @@ static int enable_autorefresh = 1; void -X11_DisableAutoRefresh (_THIS) +X11_DisableAutoRefresh(_THIS) { --enable_autorefresh; } void -X11_EnableAutoRefresh (_THIS) +X11_EnableAutoRefresh(_THIS) { ++enable_autorefresh; } void -X11_RefreshDisplay (_THIS) +X11_RefreshDisplay(_THIS) { /* Don't refresh a display that doesn't have an image (like GL) Instead, post an expose event so the application can refresh. */ if (!SDL_Ximage || (enable_autorefresh <= 0)) { - SDL_PrivateExpose (); + SDL_PrivateExpose(); return; } #ifndef NO_SHARED_MEMORY if (this->UpdateRects == X11_MITSHMUpdate) { - XShmPutImage (SDL_Display, SDL_Window, SDL_GC, SDL_Ximage, - 0, 0, SDL_CurrentWindow.offset_x, - SDL_CurrentWindow.offset_y, - SDL_CurrentDisplay.current_mode.w, - SDL_CurrentDisplay.current_mode.h, False); + XShmPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage, + 0, 0, SDL_CurrentWindow.offset_x, + SDL_CurrentWindow.offset_y, + SDL_CurrentDisplay.current_mode.w, + SDL_CurrentDisplay.current_mode.h, False); } else #endif /* ! NO_SHARED_MEMORY */ { - XPutImage (SDL_Display, SDL_Window, SDL_GC, SDL_Ximage, - 0, 0, SDL_CurrentWindow.offset_x, - SDL_CurrentWindow.offset_y, - SDL_CurrentDisplay.current_mode.w, - SDL_CurrentDisplay.current_mode.h); + XPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage, + 0, 0, SDL_CurrentWindow.offset_x, + SDL_CurrentWindow.offset_y, + SDL_CurrentDisplay.current_mode.w, + SDL_CurrentDisplay.current_mode.h); } - XSync (SDL_Display, False); + XSync(SDL_Display, False); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11image_c.h --- a/src/video/x11/SDL_x11image_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11image_c.h Mon May 29 04:04:35 2006 +0000 @@ -23,17 +23,17 @@ #include "SDL_x11video.h" -extern int X11_SetupImage (_THIS, SDL_Surface * screen); -extern void X11_DestroyImage (_THIS, SDL_Surface * screen); -extern int X11_ResizeImage (_THIS, SDL_Surface * screen, Uint32 flags); +extern int X11_SetupImage(_THIS, SDL_Surface * screen); +extern void X11_DestroyImage(_THIS, SDL_Surface * screen); +extern int X11_ResizeImage(_THIS, SDL_Surface * screen, Uint32 flags); -extern int X11_AllocHWSurface (_THIS, SDL_Surface * surface); -extern void X11_FreeHWSurface (_THIS, SDL_Surface * surface); -extern int X11_LockHWSurface (_THIS, SDL_Surface * surface); -extern void X11_UnlockHWSurface (_THIS, SDL_Surface * surface); -extern int X11_FlipHWSurface (_THIS, SDL_Surface * surface); +extern int X11_AllocHWSurface(_THIS, SDL_Surface * surface); +extern void X11_FreeHWSurface(_THIS, SDL_Surface * surface); +extern int X11_LockHWSurface(_THIS, SDL_Surface * surface); +extern void X11_UnlockHWSurface(_THIS, SDL_Surface * surface); +extern int X11_FlipHWSurface(_THIS, SDL_Surface * surface); -extern void X11_DisableAutoRefresh (_THIS); -extern void X11_EnableAutoRefresh (_THIS); -extern void X11_RefreshDisplay (_THIS); +extern void X11_DisableAutoRefresh(_THIS); +extern void X11_EnableAutoRefresh(_THIS); +extern void X11_RefreshDisplay(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11modes.c --- a/src/video/x11/SDL_x11modes.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11modes.c Mon May 29 04:04:35 2006 +0000 @@ -39,7 +39,7 @@ #if SDL_VIDEO_DRIVER_X11_VIDMODE int -vidmode_refreshrate (SDL_NAME (XF86VidModeModeInfo) * mode) +vidmode_refreshrate(SDL_NAME(XF86VidModeModeInfo) * mode) { return (mode->htotal && mode->vtotal) ? (1000 * mode->dotclock / (mode->htotal * @@ -48,54 +48,54 @@ #endif #if SDL_VIDEO_DRIVER_X11_VIDMODE -Bool SDL_NAME (XF86VidModeGetModeInfo) (Display * dpy, int scr, - SDL_NAME (XF86VidModeModeInfo) * info) +Bool SDL_NAME(XF86VidModeGetModeInfo) (Display * dpy, int scr, + SDL_NAME(XF86VidModeModeInfo) * info) { - SDL_NAME (XF86VidModeModeLine) * l = - (SDL_NAME (XF86VidModeModeLine) *) ((char *) info + - sizeof info->dotclock); - return SDL_NAME (XF86VidModeGetModeLine) (dpy, scr, - (int *) &info->dotclock, l); + SDL_NAME(XF86VidModeModeLine) * l = + (SDL_NAME(XF86VidModeModeLine) *) ((char *) info + + sizeof info->dotclock); + return SDL_NAME(XF86VidModeGetModeLine) (dpy, scr, + (int *) &info->dotclock, l); } #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ #if SDL_VIDEO_DRIVER_X11_VIDMODE static void -save_mode (_THIS) +save_mode(_THIS) { - SDL_memset (&saved_mode, 0, sizeof (saved_mode)); - SDL_NAME (XF86VidModeGetModeInfo) (SDL_Display, SDL_Screen, &saved_mode); - SDL_NAME (XF86VidModeGetViewPort) (SDL_Display, SDL_Screen, &saved_view.x, - &saved_view.y); + SDL_memset(&saved_mode, 0, sizeof(saved_mode)); + SDL_NAME(XF86VidModeGetModeInfo) (SDL_Display, SDL_Screen, &saved_mode); + SDL_NAME(XF86VidModeGetViewPort) (SDL_Display, SDL_Screen, &saved_view.x, + &saved_view.y); } #endif #if SDL_VIDEO_DRIVER_X11_VIDMODE static void -restore_mode (_THIS) +restore_mode(_THIS) { - SDL_NAME (XF86VidModeModeLine) mode; + SDL_NAME(XF86VidModeModeLine) mode; int unused; - if (SDL_NAME (XF86VidModeGetModeLine) + if (SDL_NAME(XF86VidModeGetModeLine) (SDL_Display, SDL_Screen, &unused, &mode)) { if ((saved_mode.hdisplay != mode.hdisplay) || (saved_mode.vdisplay != mode.vdisplay)) { - SDL_NAME (XF86VidModeSwitchToMode) (SDL_Display, SDL_Screen, - &saved_mode); + SDL_NAME(XF86VidModeSwitchToMode) (SDL_Display, SDL_Screen, + &saved_mode); } } if ((saved_view.x != 0) || (saved_view.y != 0)) { - SDL_NAME (XF86VidModeSetViewPort) (SDL_Display, SDL_Screen, - saved_view.x, saved_view.y); + SDL_NAME(XF86VidModeSetViewPort) (SDL_Display, SDL_Screen, + saved_view.x, saved_view.y); } } #endif -static void get_real_resolution (_THIS, int *w, int *h); +static void get_real_resolution(_THIS, int *w, int *h); static void -set_best_resolution (_THIS, int width, int height) +set_best_resolution(_THIS, int width, int height) { SDL_DisplayMode mode; @@ -103,29 +103,29 @@ mode.w = width; mode.h = height; mode.refresh_rate = 0; - SDL_GetClosestDisplayMode (&mode, &mode, SDL_FULLSCREEN); + SDL_GetClosestDisplayMode(&mode, &mode, SDL_FULLSCREEN); #if SDL_VIDEO_DRIVER_X11_VIDMODE if (use_vidmode) { - SDL_NAME (XF86VidModeModeLine) vmode; - SDL_NAME (XF86VidModeModeInfo) vinfo; - SDL_NAME (XF86VidModeModeInfo) ** modes; + SDL_NAME(XF86VidModeModeLine) vmode; + SDL_NAME(XF86VidModeModeInfo) vinfo; + SDL_NAME(XF86VidModeModeInfo) ** modes; int i, dotclock; int nmodes; int best = -1; - if (SDL_NAME (XF86VidModeGetModeLine) + if (SDL_NAME(XF86VidModeGetModeLine) (SDL_Display, SDL_Screen, &dotclock, &vmode) - && SDL_NAME (XF86VidModeGetAllModeLines) (SDL_Display, - SDL_Screen, &nmodes, - &modes)) { + && SDL_NAME(XF86VidModeGetAllModeLines) (SDL_Display, + SDL_Screen, &nmodes, + &modes)) { vinfo.dotclock = dotclock; - SDL_memcpy (&vinfo.hdisplay, &vmode, sizeof (vmode)); + SDL_memcpy(&vinfo.hdisplay, &vmode, sizeof(vmode)); for (i = 0; i < nmodes; i++) { if ((modes[i]->hdisplay == mode.w) && (modes[i]->vdisplay == mode.h) && - (vidmode_refreshrate (modes[i]) == mode.refresh_rate)) { + (vidmode_refreshrate(modes[i]) == mode.refresh_rate)) { best = i; break; } @@ -133,17 +133,17 @@ if (best >= 0 && ((modes[best]->hdisplay != vmode.hdisplay) || (modes[best]->vdisplay != vmode.vdisplay) || - (vidmode_refreshrate (modes[best]) != - vidmode_refreshrate (&vinfo)))) { + (vidmode_refreshrate(modes[best]) != + vidmode_refreshrate(&vinfo)))) { #ifdef X11MODES_DEBUG - printf ("Best Mode %d: %d x %d @ %d\n", best, - modes[best]->hdisplay, modes[best]->vdisplay, - vidmode_refreshrate (modes[best])); + printf("Best Mode %d: %d x %d @ %d\n", best, + modes[best]->hdisplay, modes[best]->vdisplay, + vidmode_refreshrate(modes[best])); #endif - SDL_NAME (XF86VidModeSwitchToMode) (SDL_Display, - SDL_Screen, modes[best]); + SDL_NAME(XF86VidModeSwitchToMode) (SDL_Display, + SDL_Screen, modes[best]); } - XFree (modes); + XFree(modes); } } #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ @@ -155,16 +155,16 @@ int w, h; /* check current mode so we can avoid uneccessary mode changes */ - get_real_resolution (this, &w, &h); + get_real_resolution(this, &w, &h); if ((mode.w != w) || (mode.h != h)) { #ifdef X11MODES_DEBUG - fprintf (stderr, "XME: set_best_resolution: " - "XiGMiscChangeResolution: %d %d\n", mode.w, mode.h); + fprintf(stderr, "XME: set_best_resolution: " + "XiGMiscChangeResolution: %d %d\n", mode.w, mode.h); #endif - XiGMiscChangeResolution (SDL_Display, SDL_Screen, 0, /* view */ - mode.w, mode.h, 0); - XSync (SDL_Display, False); + XiGMiscChangeResolution(SDL_Display, SDL_Screen, 0, /* view */ + mode.w, mode.h, 0); + XSync(SDL_Display, False); } } #endif /* SDL_VIDEO_DRIVER_X11_XME */ @@ -175,7 +175,7 @@ XRRScreenSize *sizes; /* find the smallest resolution that is at least as big as the user requested */ - sizes = XRRConfigSizes (screen_config, &nsizes); + sizes = XRRConfigSizes(screen_config, &nsizes); for (i = (nsizes - 1); i >= 0; i--) { if ((mode.w >= width) && (mode.h >= height)) { break; @@ -186,14 +186,14 @@ int w, h; /* check current mode so we can avoid uneccessary mode changes */ - get_real_resolution (this, &w, &h); + get_real_resolution(this, &w, &h); if ((mode.w != w) || (mode.h != h)) { int size_id; #ifdef X11MODES_DEBUG - fprintf (stderr, "XRANDR: set_best_resolution: " - "XXRSetScreenConfig: %d %d\n", mode.w, mode.h); + fprintf(stderr, "XRANDR: set_best_resolution: " + "XXRSetScreenConfig: %d %d\n", mode.w, mode.h); #endif /* find the matching size entry index */ @@ -203,9 +203,9 @@ break; } - XRRSetScreenConfig (SDL_Display, screen_config, - SDL_Root, size_id, saved_rotation, - CurrentTime); + XRRSetScreenConfig(SDL_Display, screen_config, + SDL_Root, size_id, saved_rotation, + CurrentTime); } } } @@ -213,31 +213,31 @@ } static void -get_real_resolution (_THIS, int *w, int *h) +get_real_resolution(_THIS, int *w, int *h) { #if SDL_VIDEO_DRIVER_X11_XME if (use_xme) { int ractive; XiGMiscResolutionInfo *modelist; - XiGMiscQueryResolutions (SDL_Display, SDL_Screen, 0, /* view */ - &ractive, &modelist); + XiGMiscQueryResolutions(SDL_Display, SDL_Screen, 0, /* view */ + &ractive, &modelist); *w = modelist[ractive].width; *h = modelist[ractive].height; #ifdef X11MODES_DEBUG - fprintf (stderr, "XME: get_real_resolution: w = %d h = %d\n", *w, *h); + fprintf(stderr, "XME: get_real_resolution: w = %d h = %d\n", *w, *h); #endif - XFree (modelist); + XFree(modelist); return; } #endif /* SDL_VIDEO_DRIVER_X11_XME */ #if SDL_VIDEO_DRIVER_X11_VIDMODE if (use_vidmode) { - SDL_NAME (XF86VidModeModeLine) mode; + SDL_NAME(XF86VidModeModeLine) mode; int unused; - if (SDL_NAME (XF86VidModeGetModeLine) + if (SDL_NAME(XF86VidModeGetModeLine) (SDL_Display, SDL_Screen, &unused, &mode)) { *w = mode.hdisplay; *h = mode.vdisplay; @@ -251,20 +251,20 @@ int nsizes; XRRScreenSize *sizes; - sizes = XRRConfigSizes (screen_config, &nsizes); + sizes = XRRConfigSizes(screen_config, &nsizes); if (nsizes > 0) { int cur_size; Rotation cur_rotation; cur_size = - XRRConfigCurrentConfiguration (screen_config, &cur_rotation); + XRRConfigCurrentConfiguration(screen_config, &cur_rotation); if (cur_size >= 0 && cur_size < nsizes) { *w = sizes[cur_size].width; *h = sizes[cur_size].height; } #ifdef X11MODES_DEBUG - fprintf (stderr, - "XRANDR: get_real_resolution: w = %d h = %d\n", *w, *h); + fprintf(stderr, + "XRANDR: get_real_resolution: w = %d h = %d\n", *w, *h); #endif return; } @@ -279,43 +279,43 @@ } #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */ - *w = DisplayWidth (SDL_Display, SDL_Screen); - *h = DisplayHeight (SDL_Display, SDL_Screen); + *w = DisplayWidth(SDL_Display, SDL_Screen); + *h = DisplayHeight(SDL_Display, SDL_Screen); } /* Called after mapping a window - waits until the window is mapped */ void -X11_WaitMapped (_THIS, Window win) +X11_WaitMapped(_THIS, Window win) { XEvent event; do { - XMaskEvent (SDL_Display, StructureNotifyMask, &event); + XMaskEvent(SDL_Display, StructureNotifyMask, &event); } while ((event.type != MapNotify) || (event.xmap.event != win)); } /* Called after unmapping a window - waits until the window is unmapped */ void -X11_WaitUnmapped (_THIS, Window win) +X11_WaitUnmapped(_THIS, Window win) { XEvent event; do { - XMaskEvent (SDL_Display, StructureNotifyMask, &event); + XMaskEvent(SDL_Display, StructureNotifyMask, &event); } while ((event.type != UnmapNotify) || (event.xunmap.event != win)); } static void -move_cursor_to (_THIS, int x, int y) +move_cursor_to(_THIS, int x, int y) { - XWarpPointer (SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y); + XWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y); } static int -add_visual (_THIS, int depth, int class) +add_visual(_THIS, int depth, int class) { XVisualInfo vi; - if (XMatchVisualInfo (SDL_Display, SDL_Screen, depth, class, &vi)) { + if (XMatchVisualInfo(SDL_Display, SDL_Screen, depth, class, &vi)) { int n = this->hidden->nvisuals; this->hidden->visuals[n].depth = vi.depth; this->hidden->visuals[n].visual = vi.visual; @@ -324,28 +324,28 @@ return (this->hidden->nvisuals); } static int -add_visual_byid (_THIS, const char *visual_id) +add_visual_byid(_THIS, const char *visual_id) { XVisualInfo *vi, template; int nvis; if (visual_id) { - SDL_memset (&template, 0, (sizeof template)); - template.visualid = SDL_strtol (visual_id, NULL, 0); - vi = XGetVisualInfo (SDL_Display, VisualIDMask, &template, &nvis); + SDL_memset(&template, 0, (sizeof template)); + template.visualid = SDL_strtol(visual_id, NULL, 0); + vi = XGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis); if (vi) { int n = this->hidden->nvisuals; this->hidden->visuals[n].depth = vi->depth; this->hidden->visuals[n].visual = vi->visual; this->hidden->nvisuals++; - XFree (vi); + XFree(vi); } } return (this->hidden->nvisuals); } int -X11_GetVisuals (_THIS) +X11_GetVisuals(_THIS) { /* It's interesting to note that if we allow 32 bit depths, we get a visual with an alpha mask on composite servers. @@ -358,30 +358,30 @@ /* Search for the visuals in deepest-first order, so that the first will be the richest one */ - if (SDL_getenv ("SDL_VIDEO_X11_NODIRECTCOLOR")) { + if (SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR")) { use_directcolor = 0; } this->hidden->nvisuals = 0; - if (!add_visual_byid (this, SDL_getenv ("SDL_VIDEO_X11_VISUALID"))) { - for (i = 0; i < SDL_arraysize (depth_list); ++i) { + if (!add_visual_byid(this, SDL_getenv("SDL_VIDEO_X11_VISUALID"))) { + for (i = 0; i < SDL_arraysize(depth_list); ++i) { if (depth_list[i] > 8) { if (use_directcolor) { - add_visual (this, depth_list[i], DirectColor); + add_visual(this, depth_list[i], DirectColor); } - add_visual (this, depth_list[i], TrueColor); + add_visual(this, depth_list[i], TrueColor); } else { - add_visual (this, depth_list[i], PseudoColor); - add_visual (this, depth_list[i], StaticColor); + add_visual(this, depth_list[i], PseudoColor); + add_visual(this, depth_list[i], StaticColor); } } } if (this->hidden->nvisuals == 0) { - SDL_SetError ("Found no sufficiently capable X11 visuals"); + SDL_SetError("Found no sufficiently capable X11 visuals"); return -1; } /* look up the pixel quantum for each depth */ - pf = XListPixmapFormats (SDL_Display, &np); + pf = XListPixmapFormats(SDL_Display, &np); for (i = 0; i < this->hidden->nvisuals; i++) { int d = this->hidden->visuals[i].depth; for (j = 0; j < np; j++) @@ -390,7 +390,7 @@ this->hidden->visuals[i].bpp = j < np ? pf[j].bits_per_pixel : d; } - XFree (pf); + XFree(pf); return 0; } @@ -399,7 +399,7 @@ #if SDL_VIDEO_DRIVER_X11_XINERAMA static int -CheckXinerama (_THIS, int *major, int *minor) +CheckXinerama(_THIS, int *major, int *minor) { const char *env; @@ -407,14 +407,14 @@ *major = *minor = 0; /* Allow environment override */ - env = getenv ("SDL_VIDEO_X11_XINERAMA"); - if (env && !SDL_atoi (env)) { + env = getenv("SDL_VIDEO_X11_XINERAMA"); + if (env && !SDL_atoi(env)) { return 0; } /* Query the extension version */ - if (!SDL_NAME (XineramaQueryExtension) (SDL_Display, major, minor) || - !SDL_NAME (XineramaIsActive) (SDL_Display)) { + if (!SDL_NAME(XineramaQueryExtension) (SDL_Display, major, minor) || + !SDL_NAME(XineramaIsActive) (SDL_Display)) { return 0; } return 1; @@ -423,7 +423,7 @@ #if SDL_VIDEO_DRIVER_X11_XRANDR static int -CheckXRandR (_THIS, int *major, int *minor) +CheckXRandR(_THIS, int *major, int *minor) { const char *env; @@ -431,8 +431,8 @@ *major = *minor = 0; /* Allow environment override */ - env = getenv ("SDL_VIDEO_X11_XRANDR"); - if (env && !SDL_atoi (env)) { + env = getenv("SDL_VIDEO_X11_XRANDR"); + if (env && !SDL_atoi(env)) { return 0; } @@ -446,7 +446,7 @@ } /* Query the extension version */ - if (!XRRQueryVersion (SDL_Display, major, minor)) { + if (!XRRQueryVersion(SDL_Display, major, minor)) { return 0; } return 1; @@ -455,7 +455,7 @@ #if SDL_VIDEO_DRIVER_X11_VIDMODE static int -CheckVidMode (_THIS, int *major, int *minor) +CheckVidMode(_THIS, int *major, int *minor) { const char *env; @@ -463,26 +463,25 @@ *major = *minor = 0; /* Allow environment override */ - env = getenv ("SDL_VIDEO_X11_VIDMODE"); - if (env && !SDL_atoi (env)) { + env = getenv("SDL_VIDEO_X11_VIDMODE"); + if (env && !SDL_atoi(env)) { return 0; } /* Metro-X 4.3.0 and earlier has a broken implementation of XF86VidModeGetAllModeLines() - it hangs the client. */ - if (SDL_strcmp (ServerVendor (SDL_Display), "Metro Link Incorporated") == - 0) { + if (SDL_strcmp(ServerVendor(SDL_Display), "Metro Link Incorporated") == 0) { FILE *metro_fp; - metro_fp = fopen ("/usr/X11R6/lib/X11/Metro/.version", "r"); + metro_fp = fopen("/usr/X11R6/lib/X11/Metro/.version", "r"); if (metro_fp != NULL) { int major, minor, patch, version; major = 0; minor = 0; patch = 0; - fscanf (metro_fp, "%d.%d.%d", &major, &minor, &patch); - fclose (metro_fp); + fscanf(metro_fp, "%d.%d.%d", &major, &minor, &patch); + fclose(metro_fp); version = major * 100 + minor * 10 + patch; if (version < 431) { return 0; @@ -492,9 +491,9 @@ /* Query the extension version */ vm_error = -1; - if (!SDL_NAME (XF86VidModeQueryExtension) + if (!SDL_NAME(XF86VidModeQueryExtension) (SDL_Display, &vm_event, &vm_error) - || !SDL_NAME (XF86VidModeQueryVersion) (SDL_Display, major, minor)) { + || !SDL_NAME(XF86VidModeQueryVersion) (SDL_Display, major, minor)) { return 0; } return 1; @@ -503,7 +502,7 @@ #if SDL_VIDEO_DRIVER_X11_XME static int -CheckXME (_THIS, int *major, int *minor) +CheckXME(_THIS, int *major, int *minor) { const char *env; @@ -511,13 +510,13 @@ *major = *minor = 0; /* Allow environment override */ - env = getenv ("SDL_VIDEO_X11_VIDMODE"); - if (env && !SDL_atoi (env)) { + env = getenv("SDL_VIDEO_X11_VIDMODE"); + if (env && !SDL_atoi(env)) { return 0; } /* Query the extension version */ - if (!XiGMiscQueryVersion (SDL_Display, major, minor)) { + if (!XiGMiscQueryVersion(SDL_Display, major, minor)) { return 0; } return 1; @@ -525,7 +524,7 @@ #endif /* SDL_VIDEO_DRIVER_X11_XME */ int -X11_GetVideoModes (_THIS) +X11_GetVideoModes(_THIS) { #if SDL_VIDEO_DRIVER_X11_XINERAMA int xinerama_major, xinerama_minor; @@ -540,7 +539,7 @@ #if SDL_VIDEO_DRIVER_X11_VIDMODE int vm_major, vm_minor; int nmodes; - SDL_NAME (XF86VidModeModeInfo) ** modes; + SDL_NAME(XF86VidModeModeInfo) ** modes; #endif #if SDL_VIDEO_DRIVER_X11_XME int xme_major, xme_minor; @@ -556,37 +555,37 @@ use_xrandr = 0; use_vidmode = 0; use_xme = 0; - screen_w = DisplayWidth (SDL_Display, SDL_Screen); - screen_h = DisplayHeight (SDL_Display, SDL_Screen); + screen_w = DisplayWidth(SDL_Display, SDL_Screen); + screen_h = DisplayHeight(SDL_Display, SDL_Screen); mode.format = this->displays[this->current_display].desktop_mode.format; mode.w = screen_w; mode.h = screen_h; mode.refresh_rate = 0; - SDL_AddDisplayMode (0, &mode); + SDL_AddDisplayMode(0, &mode); #if SDL_VIDEO_DRIVER_X11_XINERAMA /* Query Xinerama extention */ - if (CheckXinerama (this, &xinerama_major, &xinerama_minor)) { + if (CheckXinerama(this, &xinerama_major, &xinerama_minor)) { int screens; #ifdef X11MODES_DEBUG - printf ("X11 detected Xinerama:\n"); + printf("X11 detected Xinerama:\n"); #endif - xinerama = SDL_NAME (XineramaQueryScreens) (SDL_Display, &screens); + xinerama = SDL_NAME(XineramaQueryScreens) (SDL_Display, &screens); for (i = 0; i < screens; i++) { #ifdef X11MODES_DEBUG - printf ("xinerama %d: %dx%d+%d+%d\n", - xinerama[i].screen_number, - xinerama[i].width, xinerama[i].height, - xinerama[i].x_org, xinerama[i].y_org); + printf("xinerama %d: %dx%d+%d+%d\n", + xinerama[i].screen_number, + xinerama[i].width, xinerama[i].height, + xinerama[i].x_org, xinerama[i].y_org); #endif if (xinerama[i].screen_number != 0) { - SDL_AddVideoDisplay (&mode); + SDL_AddVideoDisplay(&mode); } mode.w = xinerama[i].width; mode.h = xinerama[i].height; - SDL_AddDisplayMode (xinerama[i].screen_number, &mode); + SDL_AddDisplayMode(xinerama[i].screen_number, &mode); } use_xinerama = 1; } @@ -595,42 +594,41 @@ #if SDL_VIDEO_DRIVER_X11_XRANDR /* XRandR */ /* require at least XRandR v1.0 (arbitrary) */ - if (CheckXRandR (this, &xrandr_major, &xrandr_minor) + if (CheckXRandR(this, &xrandr_major, &xrandr_minor) && (xrandr_major >= 1)) { #ifdef X11MODES_DEBUG - fprintf (stderr, "XRANDR: XRRQueryVersion: V%d.%d\n", - xrandr_major, xrandr_minor); + fprintf(stderr, "XRANDR: XRRQueryVersion: V%d.%d\n", + xrandr_major, xrandr_minor); #endif /* save the screen configuration since we must reference it each time we toggle modes. */ - screen_config = XRRGetScreenInfo (SDL_Display, SDL_Root); + screen_config = XRRGetScreenInfo(SDL_Display, SDL_Root); /* retrieve the list of resolution */ - sizes = XRRConfigSizes (screen_config, &nsizes); + sizes = XRRConfigSizes(screen_config, &nsizes); if (nsizes > 0) { for (i = 0; i < nsizes; i++) { mode.w = sizes[i].width; mode.h = sizes[i].height; - rates = XRRConfigRates (screen_config, i, &nrates); + rates = XRRConfigRates(screen_config, i, &nrates); if (nrates == 0) { mode.refresh_rate = 0; - SDL_AddDisplayMode (0, &mode); + SDL_AddDisplayMode(0, &mode); } else { int j; for (j = 0; j < nrates; ++j) { mode.refresh_rate = rates[j]; - SDL_AddDisplayMode (0, &mode); + SDL_AddDisplayMode(0, &mode); } } } use_xrandr = xrandr_major * 100 + xrandr_minor; saved_size_id = - XRRConfigCurrentConfiguration (screen_config, - &saved_rotation); + XRRConfigCurrentConfiguration(screen_config, &saved_rotation); } } #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ @@ -638,27 +636,27 @@ #if SDL_VIDEO_DRIVER_X11_VIDMODE /* XVidMode */ if (!use_xrandr && - CheckVidMode (this, &vm_major, &vm_minor) && - SDL_NAME (XF86VidModeGetAllModeLines) (SDL_Display, SDL_Screen, - &nmodes, &modes)) { + CheckVidMode(this, &vm_major, &vm_minor) && + SDL_NAME(XF86VidModeGetAllModeLines) (SDL_Display, SDL_Screen, + &nmodes, &modes)) { #ifdef X11MODES_DEBUG - printf ("VidMode modes: (unsorted)\n"); + printf("VidMode modes: (unsorted)\n"); for (i = 0; i < nmodes; ++i) { - printf ("Mode %d: %d x %d @ %d\n", i, - modes[i]->hdisplay, modes[i]->vdisplay, - vidmode_refreshrate (modes[i])); + printf("Mode %d: %d x %d @ %d\n", i, + modes[i]->hdisplay, modes[i]->vdisplay, + vidmode_refreshrate(modes[i])); } #endif for (i = 0; i < nmodes; ++i) { mode.w = modes[i]->hdisplay; mode.h = modes[i]->vdisplay; - mode.refresh_rate = vidmode_refreshrate (modes[i]); - SDL_AddDisplayMode (0, &mode); + mode.refresh_rate = vidmode_refreshrate(modes[i]); + SDL_AddDisplayMode(0, &mode); } - XFree (modes); + XFree(modes); use_vidmode = vm_major * 100 + vm_minor; - save_mode (this); + save_mode(this); } #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ @@ -666,50 +664,50 @@ /* XiG */ modelist = NULL; /* first lets make sure we have the extension, and it's at least v2.0 */ - if (CheckXME (this, &xme_major, &xme_minor) && xme_major >= 2 && (nummodes = XiGMiscQueryResolutions (SDL_Display, SDL_Screen, 0, /* view */ - &ractive, - &modelist)) + if (CheckXME(this, &xme_major, &xme_minor) && xme_major >= 2 && (nummodes = XiGMiscQueryResolutions(SDL_Display, SDL_Screen, 0, /* view */ + &ractive, + &modelist)) > 1) { /* then we actually have some */ /* We get the list already sorted in descending order. We'll copy it in reverse order so SDL is happy */ #ifdef X11MODES_DEBUG - fprintf (stderr, "XME: nummodes = %d, active mode = %d\n", - nummodes, ractive); + fprintf(stderr, "XME: nummodes = %d, active mode = %d\n", + nummodes, ractive); #endif mode.refresh_rate = 0; for (i = 0; i < nummodes; ++i) { #ifdef X11MODES_DEBUG - fprintf (stderr, "XME: mode = %4d, w = %4d, h = %4d\n", - i, modelist[i].width, modelist[i].height); + fprintf(stderr, "XME: mode = %4d, w = %4d, h = %4d\n", + i, modelist[i].width, modelist[i].height); #endif mode.w = modelist[i].width; mode.h = modelist[i].height; - SDL_AddDisplayMode (0, &mode); + SDL_AddDisplayMode(0, &mode); } use_xme = xme_major * 100 + xme_minor; saved_res = modelist[ractive]; /* save the current resolution */ } if (modelist) { - XFree (modelist); + XFree(modelist); } #endif /* SDL_VIDEO_DRIVER_X11_XME */ #ifdef X11MODES_DEBUG if (use_xinerama) { - printf ("Xinerama is enabled\n"); + printf("Xinerama is enabled\n"); } if (use_xrandr) { - printf ("XRandR is enabled\n"); + printf("XRandR is enabled\n"); } if (use_vidmode) { - printf ("VidMode is enabled\n"); + printf("VidMode is enabled\n"); } if (use_xme) { - printf ("Xi Graphics XME fullscreen is enabled\n"); + printf("Xi Graphics XME fullscreen is enabled\n"); } #endif /* X11MODES_DEBUG */ @@ -717,27 +715,27 @@ } void -X11_FreeVideoModes (_THIS) +X11_FreeVideoModes(_THIS) { #if SDL_VIDEO_DRIVER_X11_XRANDR /* Free the Xrandr screen configuration */ if (screen_config) { - XRRFreeScreenConfigInfo (screen_config); + XRRFreeScreenConfigInfo(screen_config); screen_config = NULL; } #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ } int -X11_ResizeFullScreen (_THIS) +X11_ResizeFullScreen(_THIS) { int x = 0, y = 0; int real_w, real_h; int screen_w; int screen_h; - screen_w = DisplayWidth (SDL_Display, SDL_Screen); - screen_h = DisplayHeight (SDL_Display, SDL_Screen); + screen_w = DisplayWidth(SDL_Display, SDL_Screen); + screen_h = DisplayHeight(SDL_Display, SDL_Screen); #if SDL_VIDEO_DRIVER_X11_VIDMODE if (use_xinerama && @@ -749,41 +747,41 @@ #endif if (currently_fullscreen) { /* Switch resolution and cover it with the FSwindow */ - move_cursor_to (this, x, y); - set_best_resolution (this, window_w, window_h); - move_cursor_to (this, x, y); - get_real_resolution (this, &real_w, &real_h); + move_cursor_to(this, x, y); + set_best_resolution(this, window_w, window_h); + move_cursor_to(this, x, y); + get_real_resolution(this, &real_w, &real_h); if (window_w > real_w) { - real_w = MAX (real_w, screen_w); + real_w = MAX(real_w, screen_w); } if (window_h > real_h) { - real_h = MAX (real_h, screen_h); + real_h = MAX(real_h, screen_h); } - XMoveResizeWindow (SDL_Display, FSwindow, x, y, real_w, real_h); - move_cursor_to (this, real_w / 2, real_h / 2); + XMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h); + move_cursor_to(this, real_w / 2, real_h / 2); /* Center and reparent the drawing window */ x = (real_w - window_w) / 2; y = (real_h - window_h) / 2; - XReparentWindow (SDL_Display, SDL_Window, FSwindow, x, y); + XReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y); /* FIXME: move the mouse to the old relative location */ - XSync (SDL_Display, True); /* Flush spurious mode change events */ + XSync(SDL_Display, True); /* Flush spurious mode change events */ } return (1); } void -X11_QueueEnterFullScreen (_THIS) +X11_QueueEnterFullScreen(_THIS) { switch_waiting = 0x01 | SDL_FULLSCREEN; - switch_time = SDL_GetTicks () + 1500; + switch_time = SDL_GetTicks() + 1500; #if 0 /* This causes a BadMatch error if the window is iconified (not needed) */ - XSetInputFocus (SDL_Display, WMwindow, RevertToNone, CurrentTime); + XSetInputFocus(SDL_Display, WMwindow, RevertToNone, CurrentTime); #endif } int -X11_EnterFullScreen (_THIS) +X11_EnterFullScreen(_THIS) { int okay; #if 0 @@ -801,7 +799,7 @@ } /* Ungrab the input so that we can move the mouse around */ - X11_GrabInputNoLock (this, SDL_GRAB_OFF); + X11_GrabInputNoLock(this, SDL_GRAB_OFF); #if SDL_VIDEO_DRIVER_X11_VIDMODE if (use_xinerama && @@ -812,73 +810,73 @@ } #endif /* Map the fullscreen window to blank the screen */ - screen_w = DisplayWidth (SDL_Display, SDL_Screen); - screen_h = DisplayHeight (SDL_Display, SDL_Screen); - get_real_resolution (this, &real_w, &real_h); + screen_w = DisplayWidth(SDL_Display, SDL_Screen); + screen_h = DisplayHeight(SDL_Display, SDL_Screen); + get_real_resolution(this, &real_w, &real_h); if (window_w > real_w) { - real_w = MAX (real_w, screen_w); + real_w = MAX(real_w, screen_w); } if (window_h > real_h) { - real_h = MAX (real_h, screen_h); + real_h = MAX(real_h, screen_h); } - XMoveResizeWindow (SDL_Display, FSwindow, x, y, real_w, real_h); - XMapRaised (SDL_Display, FSwindow); - X11_WaitMapped (this, FSwindow); + XMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h); + XMapRaised(SDL_Display, FSwindow); + X11_WaitMapped(this, FSwindow); #if 0 /* This seems to break WindowMaker in focus-follows-mouse mode */ /* Make sure we got to the top of the window stack */ - if (XQueryTree (SDL_Display, SDL_Root, &tmpwin, &tmpwin, - &windows, &nwindows) && windows) { + if (XQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin, + &windows, &nwindows) && windows) { /* If not, try to put us there - if fail... oh well */ if (windows[nwindows - 1] != FSwindow) { tmpwin = windows[nwindows - 1]; for (i = 0; i < nwindows; ++i) { if (windows[i] == FSwindow) { - SDL_memcpy (&windows[i], &windows[i + 1], - (nwindows - i - 1) * sizeof (windows[i])); + SDL_memcpy(&windows[i], &windows[i + 1], + (nwindows - i - 1) * sizeof(windows[i])); break; } } windows[nwindows - 1] = FSwindow; - XRestackWindows (SDL_Display, windows, nwindows); - XSync (SDL_Display, False); + XRestackWindows(SDL_Display, windows, nwindows); + XSync(SDL_Display, False); } - XFree (windows); + XFree(windows); } #else - XRaiseWindow (SDL_Display, FSwindow); + XRaiseWindow(SDL_Display, FSwindow); #endif #if SDL_VIDEO_DRIVER_X11_VIDMODE /* Save the current video mode */ if (use_vidmode) { - SDL_NAME (XF86VidModeLockModeSwitch) (SDL_Display, SDL_Screen, True); + SDL_NAME(XF86VidModeLockModeSwitch) (SDL_Display, SDL_Screen, True); } #endif currently_fullscreen = 1; /* Set the new resolution */ - okay = X11_ResizeFullScreen (this); + okay = X11_ResizeFullScreen(this); if (!okay) { - X11_LeaveFullScreen (this); + X11_LeaveFullScreen(this); } /* Set the colormap */ if (SDL_XColorMap) { - XInstallColormap (SDL_Display, SDL_XColorMap); + XInstallColormap(SDL_Display, SDL_XColorMap); } if (okay) { - X11_GrabInputNoLock (this, - SDL_CurrentWindow. - input_grab | SDL_GRAB_FULLSCREEN); + X11_GrabInputNoLock(this, + SDL_CurrentWindow. + input_grab | SDL_GRAB_FULLSCREEN); } /* We may need to refresh the screen at this point (no backing store) We also don't get an event, which is why we explicitly refresh. */ if (SDL_VideoSurface) { if (SDL_VideoSurface->flags & SDL_INTERNALOPENGL) { - SDL_PrivateExpose (); + SDL_PrivateExpose(); } else { - X11_RefreshDisplay (this); + X11_RefreshDisplay(this); } } @@ -886,15 +884,15 @@ } int -X11_LeaveFullScreen (_THIS) +X11_LeaveFullScreen(_THIS) { if (currently_fullscreen) { - XReparentWindow (SDL_Display, SDL_Window, WMwindow, 0, 0); + XReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0); #if SDL_VIDEO_DRIVER_X11_VIDMODE if (use_vidmode) { - restore_mode (this); - SDL_NAME (XF86VidModeLockModeSwitch) (SDL_Display, SDL_Screen, - False); + restore_mode(this); + SDL_NAME(XF86VidModeLockModeSwitch) (SDL_Display, SDL_Screen, + False); } #endif @@ -903,27 +901,26 @@ int rw, rh; /* check current mode so we can avoid uneccessary mode changes */ - get_real_resolution (this, &rw, &rh); + get_real_resolution(this, &rw, &rh); if (rw != saved_res.width || rh != saved_res.height) { - XiGMiscChangeResolution (SDL_Display, SDL_Screen, 0, /* view */ - saved_res.width, - saved_res.height, 0); - XSync (SDL_Display, False); + XiGMiscChangeResolution(SDL_Display, SDL_Screen, 0, /* view */ + saved_res.width, saved_res.height, 0); + XSync(SDL_Display, False); } } #endif #if SDL_VIDEO_DRIVER_X11_XRANDR if (use_xrandr) { - XRRSetScreenConfig (SDL_Display, screen_config, SDL_Root, - saved_size_id, saved_rotation, CurrentTime); + XRRSetScreenConfig(SDL_Display, screen_config, SDL_Root, + saved_size_id, saved_rotation, CurrentTime); } #endif - XUnmapWindow (SDL_Display, FSwindow); - X11_WaitUnmapped (this, FSwindow); - XSync (SDL_Display, True); /* Flush spurious mode change events */ + XUnmapWindow(SDL_Display, FSwindow); + X11_WaitUnmapped(this, FSwindow); + XSync(SDL_Display, True); /* Flush spurious mode change events */ currently_fullscreen = 0; } /* If we get popped out of fullscreen mode for some reason, input_grab @@ -931,16 +928,16 @@ temporary. In this case, release the grab unless the input has been explicitly grabbed. */ - X11_GrabInputNoLock (this, - SDL_CurrentWindow.input_grab & ~SDL_GRAB_FULLSCREEN); + X11_GrabInputNoLock(this, + SDL_CurrentWindow.input_grab & ~SDL_GRAB_FULLSCREEN); /* We may need to refresh the screen at this point (no backing store) We also don't get an event, which is why we explicitly refresh. */ if (SDL_VideoSurface) { if (SDL_VideoSurface->flags & SDL_INTERNALOPENGL) { - SDL_PrivateExpose (); + SDL_PrivateExpose(); } else { - X11_RefreshDisplay (this); + X11_RefreshDisplay(this); } } @@ -948,7 +945,7 @@ } Uint32 -X11_VisualToFormat (const Visual * visual, int depth, int bpp) +X11_VisualToFormat(const Visual * visual, int depth, int bpp) { Uint32 Rmask = visual->red_mask; Uint32 Gmask = visual->green_mask; @@ -960,7 +957,7 @@ } else { Amask = 0; } - return (SDL_MasksToPixelFormatEnum (bpp, Rmask, Gmask, Bmask, Amask)); + return (SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask)); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11modes_c.h --- a/src/video/x11/SDL_x11modes_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11modes_c.h Mon May 29 04:04:35 2006 +0000 @@ -32,13 +32,13 @@ */ #define GRAB_FULLSCREEN -extern int X11_GetVisuals (_THIS); -extern int X11_GetVideoModes (_THIS); -extern int X11_ResizeFullScreen (_THIS); -extern void X11_WaitMapped (_THIS, Window win); -extern void X11_WaitUnmapped (_THIS, Window win); -extern void X11_QueueEnterFullScreen (_THIS); -extern int X11_EnterFullScreen (_THIS); -extern int X11_LeaveFullScreen (_THIS); -extern Uint32 X11_VisualToFormat (const Visual * visual, int depth, int bpp); +extern int X11_GetVisuals(_THIS); +extern int X11_GetVideoModes(_THIS); +extern int X11_ResizeFullScreen(_THIS); +extern void X11_WaitMapped(_THIS, Window win); +extern void X11_WaitUnmapped(_THIS, Window win); +extern void X11_QueueEnterFullScreen(_THIS); +extern int X11_EnterFullScreen(_THIS); +extern int X11_LeaveFullScreen(_THIS); +extern Uint32 X11_VisualToFormat(const Visual * visual, int depth, int bpp); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11mouse.c --- a/src/video/x11/SDL_x11mouse.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11mouse.c Mon May 29 04:04:35 2006 +0000 @@ -39,21 +39,21 @@ void -X11_FreeWMCursor (_THIS, WMcursor * cursor) +X11_FreeWMCursor(_THIS, WMcursor * cursor) { if (SDL_Display != NULL) { - SDL_Lock_EventThread (); - XFreeCursor (SDL_Display, cursor->x_cursor); - XSync (SDL_Display, False); - SDL_Unlock_EventThread (); + SDL_Lock_EventThread(); + XFreeCursor(SDL_Display, cursor->x_cursor); + XSync(SDL_Display, False); + SDL_Unlock_EventThread(); } - SDL_free (cursor); + SDL_free(cursor); } WMcursor * -X11_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, int hot_x, - int hot_y) +X11_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, int hot_x, + int hot_y) { WMcursor *cursor; XGCValues GCvalues; @@ -66,25 +66,25 @@ static XColor white = { 0xffff, 0xffff, 0xffff, 0xffff }; /* Allocate the cursor memory */ - cursor = (WMcursor *) SDL_malloc (sizeof (WMcursor)); + cursor = (WMcursor *) SDL_malloc(sizeof(WMcursor)); if (cursor == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return (NULL); } /* Mix the mask and the data */ clen = (w / 8) * h; - x_data = (char *) SDL_malloc (clen); + x_data = (char *) SDL_malloc(clen); if (x_data == NULL) { - SDL_free (cursor); - SDL_OutOfMemory (); + SDL_free(cursor); + SDL_OutOfMemory(); return (NULL); } - x_mask = (char *) SDL_malloc (clen); + x_mask = (char *) SDL_malloc(clen); if (x_mask == NULL) { - SDL_free (cursor); - SDL_free (x_data); - SDL_OutOfMemory (); + SDL_free(cursor); + SDL_free(x_data); + SDL_OutOfMemory(); return (NULL); } for (i = 0; i < clen; ++i) { @@ -97,59 +97,59 @@ } /* Prevent the event thread from running while we use the X server */ - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); /* Create the data image */ - data_image = XCreateImage (SDL_Display, - DefaultVisual (SDL_Display, SDL_Screen), - 1, XYBitmap, 0, x_data, w, h, 8, w / 8); + data_image = XCreateImage(SDL_Display, + DefaultVisual(SDL_Display, SDL_Screen), + 1, XYBitmap, 0, x_data, w, h, 8, w / 8); data_image->byte_order = MSBFirst; data_image->bitmap_bit_order = MSBFirst; - data_pixmap = XCreatePixmap (SDL_Display, SDL_Root, w, h, 1); + data_pixmap = XCreatePixmap(SDL_Display, SDL_Root, w, h, 1); /* Create the data mask */ - mask_image = XCreateImage (SDL_Display, - DefaultVisual (SDL_Display, SDL_Screen), - 1, XYBitmap, 0, x_mask, w, h, 8, w / 8); + mask_image = XCreateImage(SDL_Display, + DefaultVisual(SDL_Display, SDL_Screen), + 1, XYBitmap, 0, x_mask, w, h, 8, w / 8); mask_image->byte_order = MSBFirst; mask_image->bitmap_bit_order = MSBFirst; - mask_pixmap = XCreatePixmap (SDL_Display, SDL_Root, w, h, 1); + mask_pixmap = XCreatePixmap(SDL_Display, SDL_Root, w, h, 1); /* Create the graphics context */ GCvalues.function = GXcopy; GCvalues.foreground = ~0; GCvalues.background = 0; GCvalues.plane_mask = AllPlanes; - GCcursor = XCreateGC (SDL_Display, data_pixmap, - (GCFunction | GCForeground | GCBackground | - GCPlaneMask), &GCvalues); + GCcursor = XCreateGC(SDL_Display, data_pixmap, + (GCFunction | GCForeground | GCBackground | + GCPlaneMask), &GCvalues); /* Blit the images to the pixmaps */ - XPutImage (SDL_Display, data_pixmap, GCcursor, data_image, - 0, 0, 0, 0, w, h); - XPutImage (SDL_Display, mask_pixmap, GCcursor, mask_image, - 0, 0, 0, 0, w, h); - XFreeGC (SDL_Display, GCcursor); + XPutImage(SDL_Display, data_pixmap, GCcursor, data_image, + 0, 0, 0, 0, w, h); + XPutImage(SDL_Display, mask_pixmap, GCcursor, mask_image, + 0, 0, 0, 0, w, h); + XFreeGC(SDL_Display, GCcursor); /* These free the x_data and x_mask memory pointers */ - XDestroyImage (data_image); - XDestroyImage (mask_image); + XDestroyImage(data_image); + XDestroyImage(mask_image); /* Create the cursor */ - cursor->x_cursor = XCreatePixmapCursor (SDL_Display, data_pixmap, - mask_pixmap, &black, &white, - hot_x, hot_y); - XFreePixmap (SDL_Display, data_pixmap); - XFreePixmap (SDL_Display, mask_pixmap); + cursor->x_cursor = XCreatePixmapCursor(SDL_Display, data_pixmap, + mask_pixmap, &black, &white, + hot_x, hot_y); + XFreePixmap(SDL_Display, data_pixmap); + XFreePixmap(SDL_Display, mask_pixmap); /* Release the event thread */ - XSync (SDL_Display, False); - SDL_Unlock_EventThread (); + XSync(SDL_Display, False); + SDL_Unlock_EventThread(); return (cursor); } int -X11_ShowWMCursor (_THIS, WMcursor * cursor) +X11_ShowWMCursor(_THIS, WMcursor * cursor) { /* Don't do anything if the display is gone */ if (SDL_Display == NULL) { @@ -158,36 +158,36 @@ /* Set the X11 cursor cursor, or blank if cursor is NULL */ if (SDL_Window) { - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); if (cursor == NULL) { if (SDL_BlankCursor != NULL) { - XDefineCursor (SDL_Display, SDL_Window, - SDL_BlankCursor->x_cursor); + XDefineCursor(SDL_Display, SDL_Window, + SDL_BlankCursor->x_cursor); } } else { - XDefineCursor (SDL_Display, SDL_Window, cursor->x_cursor); + XDefineCursor(SDL_Display, SDL_Window, cursor->x_cursor); } - XSync (SDL_Display, False); - SDL_Unlock_EventThread (); + XSync(SDL_Display, False); + SDL_Unlock_EventThread(); } return (1); } void -X11_WarpWMCursor (_THIS, Uint16 x, Uint16 y) +X11_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { if (using_dga & DGA_MOUSE) { - SDL_PrivateMouseMotion (0, 0, x, y); + SDL_PrivateMouseMotion(0, 0, x, y); } else if (mouse_relative) { /* RJR: March 28, 2000 leave physical cursor at center of screen if mouse hidden and grabbed */ - SDL_PrivateMouseMotion (0, 0, x, y); + SDL_PrivateMouseMotion(0, 0, x, y); } else { - SDL_Lock_EventThread (); - XWarpPointer (SDL_Display, None, SDL_Window, 0, 0, 0, 0, x, y); - XSync (SDL_Display, False); - SDL_Unlock_EventThread (); + SDL_Lock_EventThread(); + XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, x, y); + XSync(SDL_Display, False); + SDL_Unlock_EventThread(); } } @@ -197,27 +197,27 @@ denumenator and threshold. */ static void -SetMouseAccel (_THIS, const char *accel_param) +SetMouseAccel(_THIS, const char *accel_param) { int i; size_t len; int accel_value[3]; char *mouse_param, *mouse_param_buf, *pin; - len = SDL_strlen (accel_param) + 1; - mouse_param_buf = SDL_stack_alloc (char, len); + len = SDL_strlen(accel_param) + 1; + mouse_param_buf = SDL_stack_alloc(char, len); if (!mouse_param_buf) { return; } - SDL_strlcpy (mouse_param_buf, accel_param, len); + SDL_strlcpy(mouse_param_buf, accel_param, len); mouse_param = mouse_param_buf; for (i = 0; (i < 3) && mouse_param; ++i) { - pin = SDL_strchr (mouse_param, '/'); + pin = SDL_strchr(mouse_param, '/'); if (pin) { *pin = '\0'; } - accel_value[i] = atoi (mouse_param); + accel_value[i] = atoi(mouse_param); if (pin) { mouse_param = pin + 1; } else { @@ -225,16 +225,15 @@ } } if (mouse_param_buf) { - XChangePointerControl (SDL_Display, True, True, - accel_value[0], accel_value[1], - accel_value[2]); - SDL_free (mouse_param_buf); + XChangePointerControl(SDL_Display, True, True, + accel_value[0], accel_value[1], accel_value[2]); + SDL_free(mouse_param_buf); } } /* Check to see if we need to enter or leave mouse relative mode */ void -X11_CheckMouseModeNoLock (_THIS) +X11_CheckMouseModeNoLock(_THIS) { const Uint8 full_focus = (SDL_APPACTIVE | SDL_APPINPUTFOCUS | SDL_APPMOUSEFOCUS); @@ -245,30 +244,30 @@ They almost never want to do this, as it seriously affects applications that rely on continuous relative mouse motion. */ - env_override = SDL_getenv ("SDL_MOUSE_RELATIVE"); + env_override = SDL_getenv("SDL_MOUSE_RELATIVE"); if (env_override) { - enable_relative = atoi (env_override); + enable_relative = atoi(env_override); } /* If the mouse is hidden and input is grabbed, we use relative mode */ if (enable_relative && !(SDL_cursorstate & CURSOR_VISIBLE) && (SDL_CurrentWindow.input_grab != SDL_GRAB_OFF) && - (SDL_GetAppState () & full_focus) == full_focus) { + (SDL_GetAppState() & full_focus) == full_focus) { if (!mouse_relative) { - X11_EnableDGAMouse (this); + X11_EnableDGAMouse(this); if (!(using_dga & DGA_MOUSE)) { char *xmouse_accel; - SDL_GetMouseState (&mouse_last.x, &mouse_last.y); + SDL_GetMouseState(&mouse_last.x, &mouse_last.y); /* Use as raw mouse mickeys as possible */ - XGetPointerControl (SDL_Display, - &mouse_accel.numerator, - &mouse_accel.denominator, - &mouse_accel.threshold); - xmouse_accel = SDL_getenv ("SDL_VIDEO_X11_MOUSEACCEL"); + XGetPointerControl(SDL_Display, + &mouse_accel.numerator, + &mouse_accel.denominator, + &mouse_accel.threshold); + xmouse_accel = SDL_getenv("SDL_VIDEO_X11_MOUSEACCEL"); if (xmouse_accel) { - SetMouseAccel (this, xmouse_accel); + SetMouseAccel(this, xmouse_accel); } } mouse_relative = 1; @@ -276,23 +275,23 @@ } else { if (mouse_relative) { if (using_dga & DGA_MOUSE) { - X11_DisableDGAMouse (this); + X11_DisableDGAMouse(this); } else { - XChangePointerControl (SDL_Display, True, True, - mouse_accel.numerator, - mouse_accel.denominator, - mouse_accel.threshold); + XChangePointerControl(SDL_Display, True, True, + mouse_accel.numerator, + mouse_accel.denominator, + mouse_accel.threshold); } mouse_relative = 0; } } } void -X11_CheckMouseMode (_THIS) +X11_CheckMouseMode(_THIS) { - SDL_Lock_EventThread (); - X11_CheckMouseModeNoLock (this); - SDL_Unlock_EventThread (); + SDL_Lock_EventThread(); + X11_CheckMouseModeNoLock(this); + SDL_Unlock_EventThread(); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11mouse_c.h --- a/src/video/x11/SDL_x11mouse_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11mouse_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,12 +24,12 @@ #include "SDL_x11video.h" /* Functions to be exported */ -extern void X11_FreeWMCursor (_THIS, WMcursor * cursor); -extern WMcursor *X11_CreateWMCursor (_THIS, - Uint8 * data, Uint8 * mask, int w, int h, - int hot_x, int hot_y); -extern int X11_ShowWMCursor (_THIS, WMcursor * cursor); -extern void X11_WarpWMCursor (_THIS, Uint16 x, Uint16 y); -extern void X11_CheckMouseModeNoLock (_THIS); -extern void X11_CheckMouseMode (_THIS); +extern void X11_FreeWMCursor(_THIS, WMcursor * cursor); +extern WMcursor *X11_CreateWMCursor(_THIS, + Uint8 * data, Uint8 * mask, int w, int h, + int hot_x, int hot_y); +extern int X11_ShowWMCursor(_THIS, WMcursor * cursor); +extern void X11_WarpWMCursor(_THIS, Uint16 x, Uint16 y); +extern void X11_CheckMouseModeNoLock(_THIS); +extern void X11_CheckMouseMode(_THIS); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11sym.h --- a/src/video/x11/SDL_x11sym.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11sym.h Mon May 29 04:04:35 2006 +0000 @@ -20,507 +20,499 @@ slouken@libsdl.org */ -SDL_X11_MODULE (BASEXLIB) - SDL_X11_SYM (XClassHint *, XAllocClassHint, (void), (), return) - SDL_X11_SYM (Status, XAllocColor, (Display * a, Colormap b, XColor * c), - (a, b, c), return) SDL_X11_SYM (XSizeHints *, XAllocSizeHints, - (void), (), - return) SDL_X11_SYM (XWMHints *, - XAllocWMHints, - (void), (), - return) - SDL_X11_SYM (int, XChangePointerControl, - (Display * a, Bool b, Bool c, int d, int e, int f), (a, b, c, d, - e, f), - return) SDL_X11_SYM (int, XChangeProperty, (Display * a, - Window b, Atom c, - Atom d, int e, int f, - _Xconst unsigned char - *g, int h), (a, b, c, - d, e, f, - g, h), - return) SDL_X11_SYM (int, - XChangeWindowAttributes, - (Display * a, Window b, - unsigned long c, - XSetWindowAttributes * - d), (a, b, c, d), - return) - SDL_X11_SYM (Bool, XCheckTypedEvent, (Display * a, int b, XEvent * c), - (a, b, c), return) SDL_X11_SYM (int, XClearWindow, (Display * a, - Window b), - (a, b), return) SDL_X11_SYM (int, - XCloseDisplay, - (Display - * - a), - (a), - return) - SDL_X11_SYM (Colormap, XCreateColormap, - (Display * a, Window b, Visual * c, int d), (a, b, c, d), - return) SDL_X11_SYM (Cursor, XCreatePixmapCursor, (Display * a, - Pixmap b, - Pixmap c, - XColor * d, - XColor * e, - unsigned int - f, - unsigned int - g), (a, b, c, - d, e, f, - g), - return) SDL_X11_SYM (GC, XCreateGC, - (Display * a, - Drawable b, - unsigned long c, - XGCValues * d), (a, b, - c, - d), - return) - SDL_X11_SYM (XImage *, XCreateImage, - (Display * a, Visual * b, unsigned int c, int d, int e, char *f, - unsigned int g, unsigned int h, int i, int j), (a, b, c, d, e, - f, g, h, i, j), -return) SDL_X11_SYM (Pixmap, XCreatePixmap, (Display * a, +SDL_X11_MODULE(BASEXLIB) + SDL_X11_SYM(XClassHint *, XAllocClassHint, (void), (), return) + SDL_X11_SYM(Status, XAllocColor, (Display * a, Colormap b, XColor * c), + (a, b, c), return) SDL_X11_SYM(XSizeHints *, XAllocSizeHints, + (void), (), + return) SDL_X11_SYM(XWMHints *, + XAllocWMHints, + (void), (), + return) + SDL_X11_SYM(int, XChangePointerControl, + (Display * a, Bool b, Bool c, int d, int e, int f), (a, b, c, d, + e, f), + return) SDL_X11_SYM(int, XChangeProperty, (Display * a, + Window b, Atom c, + Atom d, int e, int f, + _Xconst unsigned char + *g, int h), (a, b, c, + d, e, f, + g, h), + return) SDL_X11_SYM(int, + XChangeWindowAttributes, + (Display * a, Window b, + unsigned long c, + XSetWindowAttributes * + d), (a, b, c, d), return) + SDL_X11_SYM(Bool, XCheckTypedEvent, (Display * a, int b, XEvent * c), + (a, b, c), return) SDL_X11_SYM(int, XClearWindow, (Display * a, + Window b), + (a, b), return) SDL_X11_SYM(int, + XCloseDisplay, + (Display + * + a), + (a), + return) + SDL_X11_SYM(Colormap, XCreateColormap, + (Display * a, Window b, Visual * c, int d), (a, b, c, d), + return) SDL_X11_SYM(Cursor, XCreatePixmapCursor, (Display * a, + Pixmap b, + Pixmap c, + XColor * d, + XColor * e, + unsigned int + f, + unsigned int + g), (a, b, c, + d, e, f, + g), + return) SDL_X11_SYM(GC, XCreateGC, + (Display * a, + Drawable b, + unsigned long c, + XGCValues * d), (a, b, + c, + d), + return) + SDL_X11_SYM(XImage *, XCreateImage, + (Display * a, Visual * b, unsigned int c, int d, int e, char *f, + unsigned int g, unsigned int h, int i, int j), (a, b, c, d, e, + f, g, h, i, j), +return) SDL_X11_SYM(Pixmap, XCreatePixmap, (Display * a, Drawable b, unsigned int c, unsigned int d, unsigned int e), (a, - b, - c, - d, - e), -return) SDL_X11_SYM (Pixmap, + b, + c, + d, + e), +return) SDL_X11_SYM(Pixmap, XCreatePixmapFromBitmapData, (Display * a, Drawable b, char *c, unsigned int d, unsigned int e, unsigned long f, unsigned long g, unsigned int h), (a, b, c, d, e, f, g, h), return) - SDL_X11_SYM (Window, XCreateSimpleWindow, - (Display * a, Window b, int c, int d, unsigned int e, - unsigned int f, unsigned int g, unsigned long h, - unsigned long i), (a, b, c, d, e, f, g, h, i), -return) SDL_X11_SYM (Window, XCreateWindow, (Display * a, - Window b, int c, - int d, - unsigned int e, - unsigned int f, - unsigned int g, - int h, - unsigned int i, - Visual * j, - unsigned long k, - XSetWindowAttributes - * l), (a, b, c, d, - e, f, g, h, - i, j, k, l), -return) SDL_X11_SYM (int, XDefineCursor, (Display * a, Window b, Cursor c), (a, b, c), return) - SDL_X11_SYM (int, XDeleteProperty, (Display * a, Window b, Atom c), (a, b, c), - return) SDL_X11_SYM (int, XDestroyWindow, (Display * a, - Window b), (a, b), - return) SDL_X11_SYM (char *, XDisplayName, - (_Xconst char *a), (a), - return) - SDL_X11_SYM (int, XEventsQueued, (Display * a, int b), (a, b), - return) SDL_X11_SYM (Bool, XFilterEvent, (XEvent * event, - Window w), (event, w), - return) SDL_X11_SYM (int, XFlush, - (Display * a), (a), - return) - SDL_X11_SYM (int, XFree, (void *a), (a), return) SDL_X11_SYM (int, - XFreeColormap, - (Display * - a, - Colormap - b), (a, b), - return) - SDL_X11_SYM (int, XFreeColors, - (Display * a, Colormap b, unsigned long *c, int d, unsigned long e), - (a, b, c, d, e), return) SDL_X11_SYM (int, XFreeCursor, - (Display * a, Cursor b), - (a, b), return) - SDL_X11_SYM (int, XFreeGC, (Display * a, GC b), (a, b), - return) SDL_X11_SYM (int, XFreeModifiermap, - (XModifierKeymap * a), (a), - return) SDL_X11_SYM (int, XFreePixmap, - (Display * a, - Pixmap b), (a, b), - return) - SDL_X11_SYM (int, XGetErrorDatabaseText, - (Display * a, _Xconst char *b, _Xconst char *c, _Xconst char *d, - char *e, int f), (a, b, c, d, e, f), -return) SDL_X11_SYM (XModifierKeymap *, XGetModifierMapping, (Display * a), (a), return) SDL_X11_SYM (int, XGetPointerControl, - (Display * a, int *b, int *c, - int *d), (a, b, c, d), return) - SDL_X11_SYM (int, XGetScreenSaver, - (Display * a, int *b, int *c, int *d, int *e), (a, b, c, d, e), - return) SDL_X11_SYM (XVisualInfo *, XGetVisualInfo, (Display * a, - long b, - XVisualInfo - * c, - int *d), (a, - b, - c, - d), - return) SDL_X11_SYM (XWMHints *, - XGetWMHints, - (Display * a, - Window b), (a, b), - return) - SDL_X11_SYM (Status, XGetWindowAttributes, - (Display * a, Window b, XWindowAttributes * c), (a, b, c), - return) SDL_X11_SYM (int, XGrabKeyboard, (Display * a, Window b, - Bool c, int d, int e, - Time f), (a, b, c, d, - e, f), - return) SDL_X11_SYM (int, XGrabPointer, - (Display * a, Window b, - Bool c, - unsigned int d, int e, - int f, Window g, - Cursor h, Time i), (a, - b, - c, - d, - e, - f, - g, - h, - i), - return) - SDL_X11_SYM (Status, XIconifyWindow, (Display * a, Window b, int c), - (a, b, c), return) SDL_X11_SYM (int, XInstallColormap, - (Display * a, Colormap b), (a, - b), - return) SDL_X11_SYM (KeyCode, - XKeysymToKeycode, - (Display * - a, - KeySym b), - (a, b), - return) - SDL_X11_SYM (Atom, XInternAtom, (Display * a, _Xconst char *b, Bool c), - (a, b, c), return) SDL_X11_SYM (XPixmapFormatValues *, - XListPixmapFormats, (Display * a, - int *b), (a, - b), - return) SDL_X11_SYM (int, - XLookupString, - (XKeyEvent * - a, char *b, - int c, - KeySym * d, - XComposeStatus - * e), (a, - b, - c, - d, - e), - return) - SDL_X11_SYM (int, XMapRaised, (Display * a, Window b), (a, b), - return) SDL_X11_SYM (int, XMapWindow, (Display * a, Window b), - (a, b), return) SDL_X11_SYM (int, - XMaskEvent, - (Display * a, + SDL_X11_SYM(Window, XCreateSimpleWindow, + (Display * a, Window b, int c, int d, unsigned int e, + unsigned int f, unsigned int g, unsigned long h, + unsigned long i), (a, b, c, d, e, f, g, h, i), +return) SDL_X11_SYM(Window, XCreateWindow, (Display * a, +Window b, int c, +int d, +unsigned int e, +unsigned int f, +unsigned int g, +int h, +unsigned int i, +Visual * j, +unsigned long k, +XSetWindowAttributes +* l), (a, b, c, d, + e, f, g, h, + i, j, k, l), +return) SDL_X11_SYM(int, XDefineCursor, (Display * a, Window b, Cursor c), (a, b, c), return) + SDL_X11_SYM(int, XDeleteProperty, (Display * a, Window b, Atom c), (a, b, c), + return) SDL_X11_SYM(int, XDestroyWindow, (Display * a, + Window b), (a, b), + return) SDL_X11_SYM(char *, XDisplayName, + (_Xconst char *a), (a), + return) + SDL_X11_SYM(int, XEventsQueued, (Display * a, int b), (a, b), + return) SDL_X11_SYM(Bool, XFilterEvent, (XEvent * event, + Window w), (event, w), + return) SDL_X11_SYM(int, XFlush, + (Display * a), (a), + return) + SDL_X11_SYM(int, XFree, (void *a), (a), return) SDL_X11_SYM(int, + XFreeColormap, + (Display * + a, + Colormap + b), (a, b), + return) + SDL_X11_SYM(int, XFreeColors, + (Display * a, Colormap b, unsigned long *c, int d, unsigned long e), + (a, b, c, d, e), return) SDL_X11_SYM(int, XFreeCursor, + (Display * a, Cursor b), + (a, b), return) + SDL_X11_SYM(int, XFreeGC, (Display * a, GC b), (a, b), + return) SDL_X11_SYM(int, XFreeModifiermap, + (XModifierKeymap * a), (a), + return) SDL_X11_SYM(int, XFreePixmap, + (Display * a, + Pixmap b), (a, b), + return) + SDL_X11_SYM(int, XGetErrorDatabaseText, + (Display * a, _Xconst char *b, _Xconst char *c, _Xconst char *d, + char *e, int f), (a, b, c, d, e, f), +return) SDL_X11_SYM(XModifierKeymap *, XGetModifierMapping, (Display * a), (a), return) SDL_X11_SYM(int, XGetPointerControl, + (Display * a, int *b, int *c, + int *d), (a, b, c, d), return) + SDL_X11_SYM(int, XGetScreenSaver, + (Display * a, int *b, int *c, int *d, int *e), (a, b, c, d, e), + return) SDL_X11_SYM(XVisualInfo *, XGetVisualInfo, (Display * a, long b, - XEvent * c), - (a, b, c), - return) - SDL_X11_SYM (Status, XMatchVisualInfo, - (Display * a, int b, int c, int d, XVisualInfo * e), (a, b, c, d, e), - return) SDL_X11_SYM (int, XMissingExtension, (Display * a, - _Xconst char *b), - (a, b), return) SDL_X11_SYM (int, - XMoveResizeWindow, - (Display * a, - Window b, - int c, int d, - unsigned int - e, - unsigned int - f), (a, b, c, - d, e, f), - return) - SDL_X11_SYM (int, XMoveWindow, (Display * a, Window b, int c, int d), - (a, b, c, d), return) SDL_X11_SYM (int, XNextEvent, (Display * a, - XEvent * b), - (a, b), - return) SDL_X11_SYM (Display - *, - XOpenDisplay, - (_Xconst - char - *a), - (a), - return) - SDL_X11_SYM (int, XPeekEvent, (Display * a, XEvent * b), (a, b), - return) SDL_X11_SYM (int, XPending, (Display * a), (a), - return) SDL_X11_SYM (int, XPutImage, - (Display * a, - Drawable b, GC c, - XImage * d, int e, - int f, int g, int h, - unsigned int i, - unsigned int j), (a, - b, - c, - d, - e, - f, - g, - h, - i, - j), - return) - SDL_X11_SYM (int, XQueryColors, (Display * a, Colormap b, XColor * c, int d), - (a, b, c, d), return) SDL_X11_SYM (int, XQueryKeymap, - (Display * a, char *b), (a, - b), - return) SDL_X11_SYM (Bool, - XQueryPointer, - (Display - * a, - Window - b, - Window * - c, - Window * - d, - int *e, - int *f, - int *g, - int *h, - unsigned - int *i), - (a, b, c, - d, e, f, - g, h, - i), - return) - SDL_X11_SYM (int, XRaiseWindow, (Display * a, Window b), (a, b), - return) SDL_X11_SYM (int, XReparentWindow, (Display * a, - Window b, Window c, - int d, int e), (a, b, - c, d, - e), - return) SDL_X11_SYM (int, XResizeWindow, - (Display * a, Window b, - unsigned int c, - unsigned int d), (a, + XVisualInfo + * c, + int *d), (a, b, c, d), - return) - SDL_X11_SYM (int, XSelectInput, (Display * a, Window b, long c), (a, b, c), - return) SDL_X11_SYM (Status, XSendEvent, (Display * a, Window b, - Bool c, long d, - XEvent * e), (a, b, c, - d, e), - return) SDL_X11_SYM (int, XSetClassHint, - (Display * a, Window b, - XClassHint * c), (a, - b, - c), - return) - SDL_X11_SYM (XErrorHandler, XSetErrorHandler, (XErrorHandler a), (a), - return) SDL_X11_SYM (XIOErrorHandler, XSetIOErrorHandler, - (XIOErrorHandler a), (a), - return) SDL_X11_SYM (int, XSetScreenSaver, - (Display * a, int b, - int c, int d, int e), - (a, b, c, d, e), - return) - SDL_X11_SYM (int, XSetTransientForHint, (Display * a, Window b, Window c), - (a, b, c), return) SDL_X11_SYM (int, XSetWMHints, (Display * a, - Window b, - XWMHints * c), - (a, b, c), - return) SDL_X11_SYM (void, - XSetTextProperty, - (Display * - a, - Window b, - XTextProperty - * c, - Atom d), + return) SDL_X11_SYM(XWMHints *, + XGetWMHints, + (Display * a, + Window b), (a, b), + return) + SDL_X11_SYM(Status, XGetWindowAttributes, + (Display * a, Window b, XWindowAttributes * c), (a, b, c), + return) SDL_X11_SYM(int, XGrabKeyboard, (Display * a, Window b, + Bool c, int d, int e, + Time f), (a, b, c, d, + e, f), + return) SDL_X11_SYM(int, XGrabPointer, + (Display * a, Window b, + Bool c, + unsigned int d, int e, + int f, Window g, + Cursor h, Time i), (a, + b, + c, + d, + e, + f, + g, + h, + i), + return) + SDL_X11_SYM(Status, XIconifyWindow, (Display * a, Window b, int c), + (a, b, c), return) SDL_X11_SYM(int, XInstallColormap, + (Display * a, Colormap b), (a, + b), + return) SDL_X11_SYM(KeyCode, + XKeysymToKeycode, + (Display * + a, + KeySym b), + (a, b), return) + SDL_X11_SYM(Atom, XInternAtom, (Display * a, _Xconst char *b, Bool c), + (a, b, c), return) SDL_X11_SYM(XPixmapFormatValues *, + XListPixmapFormats, (Display * a, + int *b), (a, + b), + return) SDL_X11_SYM(int, + XLookupString, + (XKeyEvent * + a, char *b, + int c, + KeySym * d, + XComposeStatus + * e), (a, + b, + c, + d, + e), + return) + SDL_X11_SYM(int, XMapRaised, (Display * a, Window b), (a, b), + return) SDL_X11_SYM(int, XMapWindow, (Display * a, Window b), + (a, b), return) SDL_X11_SYM(int, + XMaskEvent, + (Display * a, + long b, + XEvent * c), + (a, b, c), return) + SDL_X11_SYM(Status, XMatchVisualInfo, + (Display * a, int b, int c, int d, XVisualInfo * e), (a, b, c, d, e), + return) SDL_X11_SYM(int, XMissingExtension, (Display * a, + _Xconst char *b), + (a, b), return) SDL_X11_SYM(int, + XMoveResizeWindow, + (Display * a, + Window b, + int c, int d, + unsigned int + e, + unsigned int + f), (a, b, c, + d, e, f), + return) + SDL_X11_SYM(int, XMoveWindow, (Display * a, Window b, int c, int d), + (a, b, c, d), return) SDL_X11_SYM(int, XNextEvent, (Display * a, + XEvent * b), + (a, b), + return) SDL_X11_SYM(Display + *, + XOpenDisplay, + (_Xconst + char + *a), + (a), return) + SDL_X11_SYM(int, XPeekEvent, (Display * a, XEvent * b), (a, b), + return) SDL_X11_SYM(int, XPending, (Display * a), (a), + return) SDL_X11_SYM(int, XPutImage, + (Display * a, + Drawable b, GC c, + XImage * d, int e, + int f, int g, int h, + unsigned int i, + unsigned int j), (a, + b, + c, + d, + e, + f, + g, + h, + i, + j), + return) + SDL_X11_SYM(int, XQueryColors, (Display * a, Colormap b, XColor * c, int d), + (a, b, c, d), return) SDL_X11_SYM(int, XQueryKeymap, + (Display * a, char *b), (a, + b), + return) SDL_X11_SYM(Bool, + XQueryPointer, + (Display + * a, + Window + b, + Window * + c, + Window * + d, + int *e, + int *f, + int *g, + int *h, + unsigned + int *i), (a, b, c, - d),) -SDL_X11_SYM (void, XSetWMNormalHints, (Display * a, Window b, XSizeHints * c), - (a, b, c),) -SDL_X11_SYM (Status, XSetWMProtocols, - (Display * a, Window b, Atom * c, int d), (a, b, c, d), return) -SDL_X11_SYM (int, XSetWindowBackground, - (Display * a, Window b, unsigned long c), (a, b, c), return) -SDL_X11_SYM (int, XSetWindowBackgroundPixmap, - (Display * a, Window b, Pixmap c), (a, b, c), return) -SDL_X11_SYM (int, XSetWindowColormap, (Display * a, Window b, Colormap c), - (a, b, c), return) -SDL_X11_SYM (int, XStoreColors, (Display * a, Colormap b, XColor * c, int d), - (a, b, c, d), return) -SDL_X11_SYM (Status, XStringListToTextProperty, - (char **a, int b, XTextProperty * c), (a, b, c), return) -SDL_X11_SYM (int, XSync, (Display * a, Bool b), (a, b), return) -SDL_X11_SYM (int, XUngrabKeyboard, (Display * a, Time b), (a, b), return) -SDL_X11_SYM (int, XUngrabPointer, (Display * a, Time b), (a, b), return) -SDL_X11_SYM (int, XUnmapWindow, (Display * a, Window b), (a, b), return) -SDL_X11_SYM (int, XWarpPointer, - (Display * a, Window b, Window c, int d, int e, unsigned int f, - unsigned int g, int h, int i), (a, b, c, d, e, f, g, h, i), - return) -SDL_X11_SYM (VisualID, XVisualIDFromVisual, (Visual * a), (a), return) -SDL_X11_SYM (XExtDisplayInfo *, XextAddDisplay, - (XExtensionInfo * a, Display * b, char *c, XExtensionHooks * d, - int e, XPointer f), (a, b, c, d, e, f), return) -SDL_X11_SYM (XExtensionInfo *, XextCreateExtension, (void), (), return) -SDL_X11_SYM (void, XextDestroyExtension, (XExtensionInfo * a), (a),) -SDL_X11_SYM (XExtDisplayInfo *, XextFindDisplay, - (XExtensionInfo * a, Display * b), (a, b), return) -SDL_X11_SYM (int, XextRemoveDisplay, (XExtensionInfo * a, Display * b), - (a, b), return) -SDL_X11_SYM (Bool, XQueryExtension, - (Display * a, _Xconst char *b, int *c, int *d, int *e), (a, b, c, - d, e), - return) -SDL_X11_SYM (char *, XDisplayString, (Display * a), (a), return) -SDL_X11_SYM (int, XGetErrorText, (Display * a, int b, char *c, int d), - (a, b, c, d), return) -SDL_X11_SYM (void, _XEatData, (Display * a, unsigned long b), (a, b),) -SDL_X11_SYM (void, _XFlush, (Display * a), (a),) -SDL_X11_SYM (void, _XFlushGCCache, (Display * a, GC b), (a, b),) -SDL_X11_SYM (int, _XRead, (Display * a, char *b, long c), (a, b, c), return) -SDL_X11_SYM (void, _XReadPad, (Display * a, char *b, long c), (a, b, c),) -SDL_X11_SYM (void, _XSend, (Display * a, _Xconst char *b, long c), (a, b, c),) -SDL_X11_SYM (Status, _XReply, (Display * a, xReply * b, int c, Bool d), - (a, b, c, d), return) -SDL_X11_SYM (unsigned long, _XSetLastRequestRead, - (Display * a, xGenericReply * b), (a, b), return) -SDL_X11_SYM (SDL_X11_XSynchronizeRetType, XSynchronize, (Display * a, Bool b), - (a, b), return) -SDL_X11_SYM (SDL_X11_XESetWireToEventRetType, XESetWireToEvent, - (Display * a, int b, SDL_X11_XESetWireToEventRetType c), (a, b, + d, e, f, + g, h, + i), return) + SDL_X11_SYM(int, XRaiseWindow, (Display * a, Window b), (a, b), + return) SDL_X11_SYM(int, XReparentWindow, (Display * a, + Window b, Window c, + int d, int e), (a, b, + c, d, + e), + return) SDL_X11_SYM(int, XResizeWindow, + (Display * a, Window b, + unsigned int c, + unsigned int d), (a, + b, + c, + d), + return) + SDL_X11_SYM(int, XSelectInput, (Display * a, Window b, long c), (a, b, c), + return) SDL_X11_SYM(Status, XSendEvent, (Display * a, Window b, + Bool c, long d, + XEvent * e), (a, b, c, + d, e), + return) SDL_X11_SYM(int, XSetClassHint, + (Display * a, Window b, + XClassHint * c), (a, + b, c), - return) -SDL_X11_SYM (SDL_X11_XESetEventToWireRetType, XESetEventToWire, - (Display * a, int b, SDL_X11_XESetEventToWireRetType c), (a, b, - c), - return) -SDL_X11_SYM (XExtensionErrorHandler, XSetExtensionErrorHandler, - (XExtensionErrorHandler a), (a), return) + return) + SDL_X11_SYM(XErrorHandler, XSetErrorHandler, (XErrorHandler a), (a), + return) SDL_X11_SYM(XIOErrorHandler, XSetIOErrorHandler, + (XIOErrorHandler a), (a), + return) SDL_X11_SYM(int, XSetScreenSaver, + (Display * a, int b, + int c, int d, int e), + (a, b, c, d, e), return) + SDL_X11_SYM(int, XSetTransientForHint, (Display * a, Window b, Window c), + (a, b, c), return) SDL_X11_SYM(int, XSetWMHints, (Display * a, + Window b, + XWMHints * c), + (a, b, c), + return) SDL_X11_SYM(void, + XSetTextProperty, + (Display * + a, + Window b, + XTextProperty + * c, + Atom d), + (a, b, c, d),) +SDL_X11_SYM(void, XSetWMNormalHints, (Display * a, Window b, XSizeHints * c), + (a, b, c),) +SDL_X11_SYM(Status, XSetWMProtocols, + (Display * a, Window b, Atom * c, int d), (a, b, c, d), return) +SDL_X11_SYM(int, XSetWindowBackground, + (Display * a, Window b, unsigned long c), (a, b, c), return) +SDL_X11_SYM(int, XSetWindowBackgroundPixmap, + (Display * a, Window b, Pixmap c), (a, b, c), return) +SDL_X11_SYM(int, XSetWindowColormap, (Display * a, Window b, Colormap c), + (a, b, c), return) +SDL_X11_SYM(int, XStoreColors, (Display * a, Colormap b, XColor * c, int d), + (a, b, c, d), return) +SDL_X11_SYM(Status, XStringListToTextProperty, + (char **a, int b, XTextProperty * c), (a, b, c), return) +SDL_X11_SYM(int, XSync, (Display * a, Bool b), (a, b), return) +SDL_X11_SYM(int, XUngrabKeyboard, (Display * a, Time b), (a, b), return) +SDL_X11_SYM(int, XUngrabPointer, (Display * a, Time b), (a, b), return) +SDL_X11_SYM(int, XUnmapWindow, (Display * a, Window b), (a, b), return) +SDL_X11_SYM(int, XWarpPointer, + (Display * a, Window b, Window c, int d, int e, unsigned int f, + unsigned int g, int h, int i), (a, b, c, d, e, f, g, h, i), + return) +SDL_X11_SYM(VisualID, XVisualIDFromVisual, (Visual * a), (a), return) +SDL_X11_SYM(XExtDisplayInfo *, XextAddDisplay, + (XExtensionInfo * a, Display * b, char *c, XExtensionHooks * d, + int e, XPointer f), (a, b, c, d, e, f), return) +SDL_X11_SYM(XExtensionInfo *, XextCreateExtension, (void), (), return) +SDL_X11_SYM(void, XextDestroyExtension, (XExtensionInfo * a), (a),) +SDL_X11_SYM(XExtDisplayInfo *, XextFindDisplay, + (XExtensionInfo * a, Display * b), (a, b), return) +SDL_X11_SYM(int, XextRemoveDisplay, (XExtensionInfo * a, Display * b), + (a, b), return) +SDL_X11_SYM(Bool, XQueryExtension, + (Display * a, _Xconst char *b, int *c, int *d, int *e), (a, b, c, + d, e), + return) +SDL_X11_SYM(char *, XDisplayString, (Display * a), (a), return) +SDL_X11_SYM(int, XGetErrorText, (Display * a, int b, char *c, int d), + (a, b, c, d), return) +SDL_X11_SYM(void, _XEatData, (Display * a, unsigned long b), (a, b),) +SDL_X11_SYM(void, _XFlush, (Display * a), (a),) +SDL_X11_SYM(void, _XFlushGCCache, (Display * a, GC b), (a, b),) +SDL_X11_SYM(int, _XRead, (Display * a, char *b, long c), (a, b, c), return) +SDL_X11_SYM(void, _XReadPad, (Display * a, char *b, long c), (a, b, c),) +SDL_X11_SYM(void, _XSend, (Display * a, _Xconst char *b, long c), (a, b, c),) +SDL_X11_SYM(Status, _XReply, (Display * a, xReply * b, int c, Bool d), + (a, b, c, d), return) +SDL_X11_SYM(unsigned long, _XSetLastRequestRead, + (Display * a, xGenericReply * b), (a, b), return) +SDL_X11_SYM(SDL_X11_XSynchronizeRetType, XSynchronize, (Display * a, Bool b), + (a, b), return) +SDL_X11_SYM(SDL_X11_XESetWireToEventRetType, XESetWireToEvent, + (Display * a, int b, SDL_X11_XESetWireToEventRetType c), (a, b, + c), + return) +SDL_X11_SYM(SDL_X11_XESetEventToWireRetType, XESetEventToWire, + (Display * a, int b, SDL_X11_XESetEventToWireRetType c), (a, b, + c), + return) +SDL_X11_SYM(XExtensionErrorHandler, XSetExtensionErrorHandler, + (XExtensionErrorHandler a), (a), return) #if NeedWidePrototypes -SDL_X11_SYM (KeySym, XKeycodeToKeysym, (Display * a, unsigned int b, int c), - (a, b, c), return) +SDL_X11_SYM(KeySym, XKeycodeToKeysym, (Display * a, unsigned int b, int c), + (a, b, c), return) #else -SDL_X11_SYM (KeySym, XKeycodeToKeysym, (Display * a, KeyCode b, int c), - (a, b, c), return) +SDL_X11_SYM(KeySym, XKeycodeToKeysym, (Display * a, KeyCode b, int c), + (a, b, c), return) #endif #ifdef X_HAVE_UTF8_STRING -SDL_X11_MODULE (UTF8) -SDL_X11_SYM (int, Xutf8TextListToTextProperty, - (Display * a, char **b, int c, XICCEncodingStyle d, - XTextProperty * e), (a, b, c, d, e), return) -SDL_X11_SYM (int, Xutf8LookupString, - (XIC a, XKeyPressedEvent * b, char *c, int d, KeySym * e, - Status * f), (a, b, c, d, e, f), return) +SDL_X11_MODULE(UTF8) +SDL_X11_SYM(int, Xutf8TextListToTextProperty, + (Display * a, char **b, int c, XICCEncodingStyle d, + XTextProperty * e), (a, b, c, d, e), return) +SDL_X11_SYM(int, Xutf8LookupString, + (XIC a, XKeyPressedEvent * b, char *c, int d, KeySym * e, + Status * f), (a, b, c, d, e, f), return) /*SDL_X11_SYM(XIC,XCreateIC,(XIM, ...),return) !!! ARGH! */ -SDL_X11_SYM (void, XDestroyIC, (XIC a), (a),) -SDL_X11_SYM (void, XSetICFocus, (XIC a), (a),) -SDL_X11_SYM (void, XUnsetICFocus, (XIC a), (a),) -SDL_X11_SYM (XIM, XOpenIM, - (Display * a, struct _XrmHashBucketRec * b, char *c, char *d), - (a, b, c, d), return) -SDL_X11_SYM (Status, XCloseIM, (XIM a), (a), return) +SDL_X11_SYM(void, XDestroyIC, (XIC a), (a),) +SDL_X11_SYM(void, XSetICFocus, (XIC a), (a),) +SDL_X11_SYM(void, XUnsetICFocus, (XIC a), (a),) +SDL_X11_SYM(XIM, XOpenIM, + (Display * a, struct _XrmHashBucketRec * b, char *c, char *d), + (a, b, c, d), return) +SDL_X11_SYM(Status, XCloseIM, (XIM a), (a), return) #endif #ifndef NO_SHARED_MEMORY -SDL_X11_MODULE (SHM) -SDL_X11_SYM (Status, XShmAttach, (Display * a, XShmSegmentInfo * b), (a, b), - return) -SDL_X11_SYM (Status, XShmDetach, (Display * a, XShmSegmentInfo * b), (a, b), - return) -SDL_X11_SYM (Status, XShmPutImage, - (Display * a, Drawable b, GC c, XImage * d, int e, int f, int g, - int h, unsigned int i, unsigned int j, Bool k), (a, b, c, d, e, - f, g, h, i, j, - k), return) -SDL_X11_SYM (XImage *, XShmCreateImage, - (Display * a, Visual * b, unsigned int c, int d, char *e, - XShmSegmentInfo * f, unsigned int g, unsigned int h), (a, b, c, - d, e, f, - g, h), - return) -SDL_X11_SYM (Bool, XShmQueryExtension, (Display * a), (a), return) +SDL_X11_MODULE(SHM) +SDL_X11_SYM(Status, XShmAttach, (Display * a, XShmSegmentInfo * b), (a, b), + return) +SDL_X11_SYM(Status, XShmDetach, (Display * a, XShmSegmentInfo * b), (a, b), + return) +SDL_X11_SYM(Status, XShmPutImage, + (Display * a, Drawable b, GC c, XImage * d, int e, int f, int g, + int h, unsigned int i, unsigned int j, Bool k), (a, b, c, d, e, + f, g, h, i, j, + k), return) +SDL_X11_SYM(XImage *, XShmCreateImage, + (Display * a, Visual * b, unsigned int c, int d, char *e, + XShmSegmentInfo * f, unsigned int g, unsigned int h), (a, b, c, + d, e, f, + g, h), + return) +SDL_X11_SYM(Bool, XShmQueryExtension, (Display * a), (a), return) #endif /* * Not required...these only exist in code in headers on some 64-bit platforms, * and are removed via macros elsewhere, so it's safe for them to be missing. */ #ifdef LONG64 -SDL_X11_MODULE (IO_32BIT) -SDL_X11_SYM (int, _XData32, - (Display * dpy, register long *data, unsigned len), (dpy, data, - len), - return) -SDL_X11_SYM (void, _XRead32, (Display * dpy, register long *data, long len), - (dpy, data, len),) +SDL_X11_MODULE(IO_32BIT) +SDL_X11_SYM(int, _XData32, + (Display * dpy, register long *data, unsigned len), (dpy, data, + len), return) +SDL_X11_SYM(void, _XRead32, (Display * dpy, register long *data, long len), + (dpy, data, len),) #endif /* * These only show up on some variants of Unix. */ #if defined(__osf__) -SDL_X11_MODULE (OSF_ENTRY_POINTS) -SDL_X11_SYM (void, _SmtBufferOverflow, - (Display * dpy, register smtDisplayPtr p), (dpy, p),) -SDL_X11_SYM (void, _SmtIpError, - (Display * dpy, register smtDisplayPtr p, int i), (dpy, p, i),) -SDL_X11_SYM (int, ipAllocateData, (ChannelPtr a, IPCard b, IPDataPtr * c), - (a, b, c), return) -SDL_X11_SYM (int, ipUnallocateAndSendData, (ChannelPtr a, IPCard b), (a, b), - return) +SDL_X11_MODULE(OSF_ENTRY_POINTS) +SDL_X11_SYM(void, _SmtBufferOverflow, + (Display * dpy, register smtDisplayPtr p), (dpy, p),) +SDL_X11_SYM(void, _SmtIpError, + (Display * dpy, register smtDisplayPtr p, int i), (dpy, p, i),) +SDL_X11_SYM(int, ipAllocateData, (ChannelPtr a, IPCard b, IPDataPtr * c), + (a, b, c), return) +SDL_X11_SYM(int, ipUnallocateAndSendData, (ChannelPtr a, IPCard b), (a, b), + return) #endif /* Xrandr support. */ #if SDL_VIDEO_DRIVER_X11_XRANDR -SDL_X11_MODULE (XRANDR) -SDL_X11_SYM (Status, XRRQueryVersion, - (Display * dpy, int *major_versionp, int *minor_versionp), (dpy, - major_versionp, - minor_versionp), - return) -SDL_X11_SYM (XRRScreenConfiguration *, XRRGetScreenInfo, - (Display * dpy, Drawable draw), (dpy, draw), return) -SDL_X11_SYM (SizeID, XRRConfigCurrentConfiguration, - (XRRScreenConfiguration * config, Rotation * rotation), (config, - rotation), - return) -SDL_X11_SYM (XRRScreenSize *, XRRConfigSizes, - (XRRScreenConfiguration * config, int *nsizes), (config, nsizes), - return) -SDL_X11_SYM (short *, XRRConfigRates, - (XRRScreenConfiguration * config, int sizeID, int *nrates), - (config, sizeID, nrates), return) -SDL_X11_SYM (Status, XRRSetScreenConfig, - (Display * dpy, XRRScreenConfiguration * config, Drawable draw, - int size_index, Rotation rotation, Time timestamp), (dpy, - config, - draw, - size_index, - rotation, - timestamp), - return) -SDL_X11_SYM (void, XRRFreeScreenConfigInfo, (XRRScreenConfiguration * config), - (config),) +SDL_X11_MODULE(XRANDR) +SDL_X11_SYM(Status, XRRQueryVersion, + (Display * dpy, int *major_versionp, int *minor_versionp), (dpy, + major_versionp, + minor_versionp), + return) +SDL_X11_SYM(XRRScreenConfiguration *, XRRGetScreenInfo, + (Display * dpy, Drawable draw), (dpy, draw), return) +SDL_X11_SYM(SizeID, XRRConfigCurrentConfiguration, + (XRRScreenConfiguration * config, Rotation * rotation), (config, + rotation), + return) +SDL_X11_SYM(XRRScreenSize *, XRRConfigSizes, + (XRRScreenConfiguration * config, int *nsizes), (config, nsizes), + return) +SDL_X11_SYM(short *, XRRConfigRates, + (XRRScreenConfiguration * config, int sizeID, int *nrates), + (config, sizeID, nrates), return) +SDL_X11_SYM(Status, XRRSetScreenConfig, + (Display * dpy, XRRScreenConfiguration * config, Drawable draw, + int size_index, Rotation rotation, Time timestamp), (dpy, + config, + draw, + size_index, + rotation, + timestamp), + return) +SDL_X11_SYM(void, XRRFreeScreenConfigInfo, (XRRScreenConfiguration * config), + (config),) #endif /* DPMS support */ #if SDL_VIDEO_DRIVER_X11_DPMS -SDL_X11_MODULE (DPMS) -SDL_X11_SYM (Status, DPMSQueryExtension, - (Display * dpy, int *major_versionp, int *minor_versionp), (dpy, - major_versionp, - minor_versionp), - return) -SDL_X11_SYM (Status, DPMSInfo, (Display * dpy, CARD16 * state, BOOL * onoff), - (dpy, state, onoff), return) -SDL_X11_SYM (Status, DPMSEnable, (Display * dpy), (dpy), return) -SDL_X11_SYM (Status, DPMSDisable, (Display * dpy), (dpy), return) +SDL_X11_MODULE(DPMS) +SDL_X11_SYM(Status, DPMSQueryExtension, + (Display * dpy, int *major_versionp, int *minor_versionp), (dpy, + major_versionp, + minor_versionp), + return) +SDL_X11_SYM(Status, DPMSInfo, (Display * dpy, CARD16 * state, BOOL * onoff), + (dpy, state, onoff), return) +SDL_X11_SYM(Status, DPMSEnable, (Display * dpy), (dpy), return) +SDL_X11_SYM(Status, DPMSDisable, (Display * dpy), (dpy), return) #endif /* end of SDL_x11sym.h ... */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11video.c --- a/src/video/x11/SDL_x11video.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11video.c Mon May 29 04:04:35 2006 +0000 @@ -55,72 +55,72 @@ #include "../blank_cursor.h" /* Initialization/Query functions */ -static int X11_VideoInit (_THIS); -static SDL_Surface *X11_SetVideoMode (_THIS, SDL_Surface * current, - const SDL_DisplayMode * mode, - Uint32 flags); -static int X11_ToggleFullScreen (_THIS, int on); -static void X11_UpdateMouse (_THIS); -static int X11_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static int X11_SetGammaRamp (_THIS, Uint16 * ramp); -static void X11_VideoQuit (_THIS); +static int X11_VideoInit(_THIS); +static SDL_Surface *X11_SetVideoMode(_THIS, SDL_Surface * current, + const SDL_DisplayMode * mode, + Uint32 flags); +static int X11_ToggleFullScreen(_THIS, int on); +static void X11_UpdateMouse(_THIS); +static int X11_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static int X11_SetGammaRamp(_THIS, Uint16 * ramp); +static void X11_VideoQuit(_THIS); /* X11 driver bootstrap functions */ static int -X11_Available (void) +X11_Available(void) { Display *display = NULL; - if (SDL_X11_LoadSymbols ()) { - display = XOpenDisplay (NULL); + if (SDL_X11_LoadSymbols()) { + display = XOpenDisplay(NULL); if (display != NULL) { - XCloseDisplay (display); + XCloseDisplay(display); } - SDL_X11_UnloadSymbols (); + SDL_X11_UnloadSymbols(); } return (display != NULL); } static void -X11_DeleteDevice (SDL_VideoDevice * device) +X11_DeleteDevice(SDL_VideoDevice * device) { if (device) { if (device->hidden) { - SDL_free (device->hidden); + SDL_free(device->hidden); } if (device->gl_data) { - SDL_free (device->gl_data); + SDL_free(device->gl_data); } - SDL_free (device); - SDL_X11_UnloadSymbols (); + SDL_free(device); + SDL_X11_UnloadSymbols(); } } static SDL_VideoDevice * -X11_CreateDevice (int devindex) +X11_CreateDevice(int devindex) { SDL_VideoDevice *device = NULL; - if (SDL_X11_LoadSymbols ()) { + if (SDL_X11_LoadSymbols()) { /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); device->gl_data = (struct SDL_PrivateGLData *) - SDL_malloc ((sizeof *device->gl_data)); + SDL_malloc((sizeof *device->gl_data)); } if ((device == NULL) || (device->hidden == NULL) || (device->gl_data == NULL)) { - SDL_OutOfMemory (); - X11_DeleteDevice (device); /* calls SDL_X11_UnloadSymbols(). */ + SDL_OutOfMemory(); + X11_DeleteDevice(device); /* calls SDL_X11_UnloadSymbols(). */ return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); - SDL_memset (device->gl_data, 0, (sizeof *device->gl_data)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->gl_data, 0, (sizeof *device->gl_data)); /* Set the driver flags */ device->handles_any_size = 1; @@ -183,7 +183,7 @@ /* Normal X11 error handler routine */ static int (*X_handler) (Display *, XErrorEvent *) = NULL; static int -x_errhandler (Display * d, XErrorEvent * e) +x_errhandler(Display * d, XErrorEvent * e) { #if SDL_VIDEO_DRIVER_X11_VIDMODE extern int vm_error; @@ -205,8 +205,8 @@ #ifdef X11_DEBUG { char errmsg[1024]; - XGetErrorText (d, e->error_code, errmsg, sizeof (errmsg)); - printf ("VidMode error: %s\n", errmsg); + XGetErrorText(d, e->error_code, errmsg, sizeof(errmsg)); + printf("VidMode error: %s\n", errmsg); } #endif return (0); @@ -221,21 +221,21 @@ #ifdef X11_DEBUG { char errmsg[1024]; - XGetErrorText (d, e->error_code, errmsg, sizeof (errmsg)); - printf ("DGA error: %s\n", errmsg); + XGetErrorText(d, e->error_code, errmsg, sizeof(errmsg)); + printf("DGA error: %s\n", errmsg); } #endif return (0); } #endif /* SDL_VIDEO_DRIVER_X11_DGAMOUSE */ - return (X_handler (d, e)); + return (X_handler(d, e)); } /* X11 I/O error handler routine */ static int (*XIO_handler) (Display *) = NULL; static int -xio_errhandler (Display * d) +xio_errhandler(Display * d) { /* Ack! Lost X11 connection! */ @@ -246,20 +246,20 @@ current_video->hidden->X11_Display = NULL; /* Continue with the standard X11 error handler */ - return (XIO_handler (d)); + return (XIO_handler(d)); } static int (*Xext_handler) (Display *, _Xconst char *, _Xconst char *) = NULL; static int -xext_errhandler (Display * d, _Xconst char *ext, _Xconst char *reason) +xext_errhandler(Display * d, _Xconst char *ext, _Xconst char *reason) { #ifdef X11_DEBUG - printf ("Xext error inside SDL (may be harmless):\n"); - printf (" Extension \"%s\" %s on display \"%s\".\n", - ext, reason, XDisplayString (d)); + printf("Xext error inside SDL (may be harmless):\n"); + printf(" Extension \"%s\" %s on display \"%s\".\n", + ext, reason, XDisplayString(d)); #endif - if (SDL_strcmp (reason, "missing") == 0) { + if (SDL_strcmp(reason, "missing") == 0) { /* * Since the query itself, elsewhere, can handle a missing extension * and the default behaviour in Xlib is to write to stderr, which @@ -269,12 +269,12 @@ } /* Everything else goes to the default handler... */ - return Xext_handler (d, ext, reason); + return Xext_handler(d, ext, reason); } /* Find out what class name we should use */ static char * -get_classname (char *classname, int maxlen) +get_classname(char *classname, int maxlen) { char *spot; #if defined(__LINUX__) || defined(__FREEBSD__) @@ -284,63 +284,62 @@ #endif /* First allow environment variable override */ - spot = SDL_getenv ("SDL_VIDEO_X11_WMCLASS"); + spot = SDL_getenv("SDL_VIDEO_X11_WMCLASS"); if (spot) { - SDL_strlcpy (classname, spot, maxlen); + SDL_strlcpy(classname, spot, maxlen); return classname; } /* Next look at the application's executable name */ #if defined(__LINUX__) || defined(__FREEBSD__) #if defined(__LINUX__) - SDL_snprintf (procfile, SDL_arraysize (procfile), "/proc/%d/exe", - getpid ()); + SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/exe", getpid()); #elif defined(__FREEBSD__) - SDL_snprintf (procfile, SDL_arraysize (procfile), "/proc/%d/file", - getpid ()); + SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/file", + getpid()); #else #error Where can we find the executable name? #endif - linksize = readlink (procfile, linkfile, sizeof (linkfile) - 1); + linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1); if (linksize > 0) { linkfile[linksize] = '\0'; - spot = SDL_strrchr (linkfile, '/'); + spot = SDL_strrchr(linkfile, '/'); if (spot) { - SDL_strlcpy (classname, spot + 1, maxlen); + SDL_strlcpy(classname, spot + 1, maxlen); } else { - SDL_strlcpy (classname, linkfile, maxlen); + SDL_strlcpy(classname, linkfile, maxlen); } return classname; } #endif /* __LINUX__ */ /* Finally use the default we've used forever */ - SDL_strlcpy (classname, "SDL_App", maxlen); + SDL_strlcpy(classname, "SDL_App", maxlen); return classname; } /* Create auxiliary (toplevel) windows with the current visual */ static void -create_aux_windows (_THIS) +create_aux_windows(_THIS) { int x = 0, y = 0; char classname[1024]; XSetWindowAttributes xattr; XWMHints *hints; - int def_vis = (SDL_Visual == DefaultVisual (SDL_Display, SDL_Screen)); + int def_vis = (SDL_Visual == DefaultVisual(SDL_Display, SDL_Screen)); /* Look up some useful Atoms */ - WM_DELETE_WINDOW = XInternAtom (SDL_Display, "WM_DELETE_WINDOW", False); + WM_DELETE_WINDOW = XInternAtom(SDL_Display, "WM_DELETE_WINDOW", False); /* Don't create any extra windows if we are being managed */ if (SDL_windowid) { FSwindow = 0; - WMwindow = SDL_strtol (SDL_windowid, NULL, 0); + WMwindow = SDL_strtol(SDL_windowid, NULL, 0); return; } if (FSwindow) - XDestroyWindow (SDL_Display, FSwindow); + XDestroyWindow(SDL_Display, FSwindow); #if SDL_VIDEO_DRIVER_X11_VIDMODE if (use_xinerama) { @@ -350,76 +349,76 @@ #endif xattr.override_redirect = True; xattr.background_pixel = - def_vis ? BlackPixel (SDL_Display, SDL_Screen) : 0; + def_vis ? BlackPixel(SDL_Display, SDL_Screen) : 0; xattr.border_pixel = 0; xattr.colormap = SDL_XColorMap; - FSwindow = XCreateWindow (SDL_Display, SDL_Root, - x, y, 32, 32, 0, - this->hidden->depth, InputOutput, SDL_Visual, - CWOverrideRedirect | CWBackPixel | CWBorderPixel - | CWColormap, &xattr); + FSwindow = XCreateWindow(SDL_Display, SDL_Root, + x, y, 32, 32, 0, + this->hidden->depth, InputOutput, SDL_Visual, + CWOverrideRedirect | CWBackPixel | CWBorderPixel + | CWColormap, &xattr); - XSelectInput (SDL_Display, FSwindow, StructureNotifyMask); + XSelectInput(SDL_Display, FSwindow, StructureNotifyMask); /* Tell KDE to keep the fullscreen window on top */ { XEvent ev; long mask; - SDL_memset (&ev, 0, sizeof (ev)); + SDL_memset(&ev, 0, sizeof(ev)); ev.xclient.type = ClientMessage; ev.xclient.window = SDL_Root; - ev.xclient.message_type = XInternAtom (SDL_Display, - "KWM_KEEP_ON_TOP", False); + ev.xclient.message_type = XInternAtom(SDL_Display, + "KWM_KEEP_ON_TOP", False); ev.xclient.format = 32; ev.xclient.data.l[0] = FSwindow; ev.xclient.data.l[1] = CurrentTime; mask = SubstructureRedirectMask; - XSendEvent (SDL_Display, SDL_Root, False, mask, &ev); + XSendEvent(SDL_Display, SDL_Root, False, mask, &ev); } hints = NULL; if (WMwindow) { /* All window attributes must survive the recreation */ - hints = XGetWMHints (SDL_Display, WMwindow); - XDestroyWindow (SDL_Display, WMwindow); + hints = XGetWMHints(SDL_Display, WMwindow); + XDestroyWindow(SDL_Display, WMwindow); } /* Create the window for windowed management */ /* (reusing the xattr structure above) */ - WMwindow = XCreateWindow (SDL_Display, SDL_Root, - x, y, 32, 32, 0, - this->hidden->depth, InputOutput, SDL_Visual, - CWBackPixel | CWBorderPixel | CWColormap, - &xattr); + WMwindow = XCreateWindow(SDL_Display, SDL_Root, + x, y, 32, 32, 0, + this->hidden->depth, InputOutput, SDL_Visual, + CWBackPixel | CWBorderPixel | CWColormap, + &xattr); /* Set the input hints so we get keyboard input */ if (!hints) { - hints = XAllocWMHints (); + hints = XAllocWMHints(); hints->input = True; hints->flags = InputHint; } - XSetWMHints (SDL_Display, WMwindow, hints); - XFree (hints); - X11_SetCaptionNoLock (this, SDL_CurrentWindow.wm_title, - SDL_CurrentWindow.wm_icon); + XSetWMHints(SDL_Display, WMwindow, hints); + XFree(hints); + X11_SetCaptionNoLock(this, SDL_CurrentWindow.wm_title, + SDL_CurrentWindow.wm_icon); - XSelectInput (SDL_Display, WMwindow, - FocusChangeMask | KeyPressMask | KeyReleaseMask - | PropertyChangeMask | StructureNotifyMask | - KeymapStateMask); + XSelectInput(SDL_Display, WMwindow, + FocusChangeMask | KeyPressMask | KeyReleaseMask + | PropertyChangeMask | StructureNotifyMask | + KeymapStateMask); /* Set the class hints so we can get an icon (AfterStep) */ - get_classname (classname, sizeof (classname)); + get_classname(classname, sizeof(classname)); { XClassHint *classhints; - classhints = XAllocClassHint (); + classhints = XAllocClassHint(); if (classhints != NULL) { classhints->res_name = classname; classhints->res_class = classname; - XSetClassHint (SDL_Display, WMwindow, classhints); - XFree (classhints); + XSetClassHint(SDL_Display, WMwindow, classhints); + XFree(classhints); } } @@ -429,21 +428,21 @@ #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { - SDL_IM = XOpenIM (SDL_Display, NULL, classname, classname); + SDL_IM = XOpenIM(SDL_Display, NULL, classname, classname); if (SDL_IM == NULL) { - SDL_SetError ("no input method could be opened"); + SDL_SetError("no input method could be opened"); } else { - SDL_IC = pXCreateIC (SDL_IM, - XNClientWindow, WMwindow, - XNFocusWindow, WMwindow, - XNInputStyle, - XIMPreeditNothing | XIMStatusNothing, - XNResourceName, classname, - XNResourceClass, classname, NULL); + SDL_IC = pXCreateIC(SDL_IM, + XNClientWindow, WMwindow, + XNFocusWindow, WMwindow, + XNInputStyle, + XIMPreeditNothing | XIMStatusNothing, + XNResourceName, classname, + XNResourceClass, classname, NULL); if (SDL_IC == NULL) { - SDL_SetError ("no input context could be created"); - XCloseIM (SDL_IM); + SDL_SetError("no input context could be created"); + XCloseIM(SDL_IM); SDL_IM = NULL; } } @@ -451,11 +450,11 @@ #endif /* Allow the window to be deleted by the window manager */ - XSetWMProtocols (SDL_Display, WMwindow, &WM_DELETE_WINDOW, 1); + XSetWMProtocols(SDL_Display, WMwindow, &WM_DELETE_WINDOW, 1); } static int -X11_VideoInit (_THIS) +X11_VideoInit(_THIS) { char *display; int i; @@ -464,13 +463,13 @@ /* Open the X11 display */ display = NULL; /* Get it from DISPLAY environment variable */ - if ((SDL_strncmp (XDisplayName (display), ":", 1) == 0) || - (SDL_strncmp (XDisplayName (display), "unix:", 5) == 0)) { + if ((SDL_strncmp(XDisplayName(display), ":", 1) == 0) || + (SDL_strncmp(XDisplayName(display), "unix:", 5) == 0)) { local_X11 = 1; } else { local_X11 = 0; } - SDL_Display = XOpenDisplay (display); + SDL_Display = XOpenDisplay(display); #if defined(__osf__) && defined(SDL_VIDEO_DRIVER_X11_DYNAMIC) /* On Tru64 if linking without -lX11, it fails and you get following message. * Xlib: connection to ":0.0" refused by server @@ -481,130 +480,130 @@ * */ if (SDL_Display == NULL) { - SDL_Delay (1000); - SDL_Display = XOpenDisplay (display); + SDL_Delay(1000); + SDL_Display = XOpenDisplay(display); } #endif if (SDL_Display == NULL) { - SDL_SetError ("Couldn't open X11 display"); + SDL_SetError("Couldn't open X11 display"); return (-1); } #ifdef X11_DEBUG - XSynchronize (SDL_Display, True); + XSynchronize(SDL_Display, True); #endif /* Create an alternate X display for graphics updates -- allows us to do graphics updates in a separate thread from event handling. Thread-safe X11 doesn't seem to exist. */ - GFX_Display = XOpenDisplay (display); + GFX_Display = XOpenDisplay(display); if (GFX_Display == NULL) { - SDL_SetError ("Couldn't open X11 display"); + SDL_SetError("Couldn't open X11 display"); return (-1); } /* Set the normal X error handler */ - X_handler = XSetErrorHandler (x_errhandler); + X_handler = XSetErrorHandler(x_errhandler); /* Set the error handler if we lose the X display */ - XIO_handler = XSetIOErrorHandler (xio_errhandler); + XIO_handler = XSetIOErrorHandler(xio_errhandler); /* Set the X extension error handler */ - Xext_handler = XSetExtensionErrorHandler (xext_errhandler); + Xext_handler = XSetExtensionErrorHandler(xext_errhandler); /* use default screen (from $DISPLAY) */ - SDL_Screen = DefaultScreen (SDL_Display); + SDL_Screen = DefaultScreen(SDL_Display); #ifndef NO_SHARED_MEMORY /* Check for MIT shared memory extension */ use_mitshm = 0; if (local_X11) { - use_mitshm = XShmQueryExtension (SDL_Display); + use_mitshm = XShmQueryExtension(SDL_Display); } #endif /* NO_SHARED_MEMORY */ /* Get the available visuals */ - if (X11_GetVisuals (this) < 0) + if (X11_GetVisuals(this) < 0) return -1; /* Determine the default screen mode: Use the default visual (or at least one with the same depth) */ - SDL_DisplayColormap = DefaultColormap (SDL_Display, SDL_Screen); + SDL_DisplayColormap = DefaultColormap(SDL_Display, SDL_Screen); for (i = 0; i < this->hidden->nvisuals; i++) - if (this->hidden->visuals[i].depth == DefaultDepth (SDL_Display, - SDL_Screen)) + if (this->hidden->visuals[i].depth == DefaultDepth(SDL_Display, + SDL_Screen)) break; if (i == this->hidden->nvisuals) { /* default visual was useless, take the deepest one instead */ i = 0; } SDL_Visual = this->hidden->visuals[i].visual; - if (SDL_Visual == DefaultVisual (SDL_Display, SDL_Screen)) { + if (SDL_Visual == DefaultVisual(SDL_Display, SDL_Screen)) { SDL_XColorMap = SDL_DisplayColormap; } else { - SDL_XColorMap = XCreateColormap (SDL_Display, SDL_Root, - SDL_Visual, AllocNone); + SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root, + SDL_Visual, AllocNone); } desktop_mode.format = - X11_VisualToFormat (this->hidden->visuals[i].visual, - this->hidden->visuals[i].depth, - this->hidden->visuals[i].bpp); - desktop_mode.w = DisplayWidth (SDL_Display, SDL_Screen); - desktop_mode.h = DisplayHeight (SDL_Display, SDL_Screen); + X11_VisualToFormat(this->hidden->visuals[i].visual, + this->hidden->visuals[i].depth, + this->hidden->visuals[i].bpp); + desktop_mode.w = DisplayWidth(SDL_Display, SDL_Screen); + desktop_mode.h = DisplayHeight(SDL_Display, SDL_Screen); desktop_mode.refresh_rate = 0; - SDL_AddVideoDisplay (&desktop_mode); + SDL_AddVideoDisplay(&desktop_mode); /* Get the available video modes */ - if (X11_GetVideoModes (this) < 0) + if (X11_GetVideoModes(this) < 0) return -1; - X11_SaveVidModeGamma (this); + X11_SaveVidModeGamma(this); /* Save DPMS and screensaver settings */ - X11_SaveScreenSaver (SDL_Display, &screensaver_timeout, &dpms_enabled); - X11_DisableScreenSaver (SDL_Display); + X11_SaveScreenSaver(SDL_Display, &screensaver_timeout, &dpms_enabled); + X11_DisableScreenSaver(SDL_Display); /* See if we have been passed a window to use */ - SDL_windowid = SDL_getenv ("SDL_WINDOWID"); + SDL_windowid = SDL_getenv("SDL_WINDOWID"); /* Create the fullscreen and managed windows */ - create_aux_windows (this); + create_aux_windows(this); /* Create the blank cursor */ - SDL_BlankCursor = this->CreateWMCursor (this, blank_cdata, blank_cmask, - BLANK_CWIDTH, BLANK_CHEIGHT, - BLANK_CHOTX, BLANK_CHOTY); + SDL_BlankCursor = this->CreateWMCursor(this, blank_cdata, blank_cmask, + BLANK_CWIDTH, BLANK_CHEIGHT, + BLANK_CHOTX, BLANK_CHOTY); /* Fill in some window manager capabilities */ this->info.wm_available = 1; /* We're done! */ - XFlush (SDL_Display); + XFlush(SDL_Display); return (0); } static void -X11_DestroyWindow (_THIS, SDL_Surface * screen) +X11_DestroyWindow(_THIS, SDL_Surface * screen) { /* Clean up OpenGL */ if (screen) { screen->flags &= ~SDL_INTERNALOPENGL; } - X11_GL_Shutdown (this); + X11_GL_Shutdown(this); if (!SDL_windowid) { /* Hide the managed window */ if (WMwindow) { - XUnmapWindow (SDL_Display, WMwindow); + XUnmapWindow(SDL_Display, WMwindow); } if (screen && (screen->flags & SDL_FULLSCREEN)) { screen->flags &= ~SDL_FULLSCREEN; - X11_LeaveFullScreen (this); + X11_LeaveFullScreen(this); } /* Destroy the output window */ if (SDL_Window) { - XDestroyWindow (SDL_Display, SDL_Window); + XDestroyWindow(SDL_Display, SDL_Window); } /* Free the colormap entries */ @@ -614,50 +613,50 @@ numcolors = SDL_Visual->map_entries; for (pixel = 0; pixel < numcolors; ++pixel) { while (SDL_XPixels[pixel] > 0) { - XFreeColors (GFX_Display, - SDL_DisplayColormap, &pixel, 1, 0); + XFreeColors(GFX_Display, + SDL_DisplayColormap, &pixel, 1, 0); --SDL_XPixels[pixel]; } } - SDL_free (SDL_XPixels); + SDL_free(SDL_XPixels); SDL_XPixels = NULL; } /* Free the graphics context */ if (SDL_GC) { - XFreeGC (SDL_Display, SDL_GC); + XFreeGC(SDL_Display, SDL_GC); SDL_GC = 0; } } } static SDL_bool -X11_WindowPosition (_THIS, int *x, int *y, int w, int h) +X11_WindowPosition(_THIS, int *x, int *y, int w, int h) { - const char *window = SDL_getenv ("SDL_VIDEO_WINDOW_POS"); - const char *center = SDL_getenv ("SDL_VIDEO_CENTERED"); + const char *window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); + const char *center = SDL_getenv("SDL_VIDEO_CENTERED"); if (window) { - if (SDL_sscanf (window, "%d,%d", x, y) == 2) { + if (SDL_sscanf(window, "%d,%d", x, y) == 2) { return SDL_TRUE; } - if (SDL_strcmp (window, "center") == 0) { + if (SDL_strcmp(window, "center") == 0) { center = window; } } if (center) { - *x = (DisplayWidth (SDL_Display, SDL_Screen) - w) / 2; - *y = (DisplayHeight (SDL_Display, SDL_Screen) - h) / 2; + *x = (DisplayWidth(SDL_Display, SDL_Screen) - w) / 2; + *y = (DisplayHeight(SDL_Display, SDL_Screen) - h) / 2; return SDL_TRUE; } return SDL_FALSE; } static void -X11_SetSizeHints (_THIS, int w, int h, Uint32 flags) +X11_SetSizeHints(_THIS, int w, int h, Uint32 flags) { XSizeHints *hints; - hints = XAllocSizeHints (); + hints = XAllocSizeHints(); if (hints) { if (flags & SDL_RESIZABLE) { hints->min_width = 32; @@ -675,15 +674,15 @@ hints->flags |= USPosition; } else /* Center it, if desired */ - if (X11_WindowPosition (this, &hints->x, &hints->y, w, h)) { + if (X11_WindowPosition(this, &hints->x, &hints->y, w, h)) { hints->flags |= USPosition; - XMoveWindow (SDL_Display, WMwindow, hints->x, hints->y); + XMoveWindow(SDL_Display, WMwindow, hints->x, hints->y); /* Flush the resize event so we don't catch it later */ - XSync (SDL_Display, True); + XSync(SDL_Display, True); } - XSetWMNormalHints (SDL_Display, WMwindow, hints); - XFree (hints); + XSetWMNormalHints(SDL_Display, WMwindow, hints); + XFree(hints); } /* Respect the window caption style */ @@ -695,7 +694,7 @@ set = SDL_FALSE; /* First try to set MWM hints */ - WM_HINTS = XInternAtom (SDL_Display, "_MOTIF_WM_HINTS", True); + WM_HINTS = XInternAtom(SDL_Display, "_MOTIF_WM_HINTS", True); if (WM_HINTS != None) { /* Hints used by Motif compliant window managers */ struct @@ -708,40 +707,40 @@ } MWMHints = { (1L << 1), 0, 0, 0, 0}; - XChangeProperty (SDL_Display, WMwindow, - WM_HINTS, WM_HINTS, 32, - PropModeReplace, - (unsigned char *) &MWMHints, - sizeof (MWMHints) / sizeof (long)); + XChangeProperty(SDL_Display, WMwindow, + WM_HINTS, WM_HINTS, 32, + PropModeReplace, + (unsigned char *) &MWMHints, + sizeof(MWMHints) / sizeof(long)); set = SDL_TRUE; } /* Now try to set KWM hints */ - WM_HINTS = XInternAtom (SDL_Display, "KWM_WIN_DECORATION", True); + WM_HINTS = XInternAtom(SDL_Display, "KWM_WIN_DECORATION", True); if (WM_HINTS != None) { long KWMHints = 0; - XChangeProperty (SDL_Display, WMwindow, - WM_HINTS, WM_HINTS, 32, - PropModeReplace, - (unsigned char *) &KWMHints, - sizeof (KWMHints) / sizeof (long)); + XChangeProperty(SDL_Display, WMwindow, + WM_HINTS, WM_HINTS, 32, + PropModeReplace, + (unsigned char *) &KWMHints, + sizeof(KWMHints) / sizeof(long)); set = SDL_TRUE; } /* Now try to set GNOME hints */ - WM_HINTS = XInternAtom (SDL_Display, "_WIN_HINTS", True); + WM_HINTS = XInternAtom(SDL_Display, "_WIN_HINTS", True); if (WM_HINTS != None) { long GNOMEHints = 0; - XChangeProperty (SDL_Display, WMwindow, - WM_HINTS, WM_HINTS, 32, - PropModeReplace, - (unsigned char *) &GNOMEHints, - sizeof (GNOMEHints) / sizeof (long)); + XChangeProperty(SDL_Display, WMwindow, + WM_HINTS, WM_HINTS, 32, + PropModeReplace, + (unsigned char *) &GNOMEHints, + sizeof(GNOMEHints) / sizeof(long)); set = SDL_TRUE; } /* Finally set the transient hints if necessary */ if (!set) { - XSetTransientForHint (SDL_Display, WMwindow, SDL_Root); + XSetTransientForHint(SDL_Display, WMwindow, SDL_Root); } } else { SDL_bool set; @@ -751,34 +750,34 @@ set = SDL_FALSE; /* First try to unset MWM hints */ - WM_HINTS = XInternAtom (SDL_Display, "_MOTIF_WM_HINTS", True); + WM_HINTS = XInternAtom(SDL_Display, "_MOTIF_WM_HINTS", True); if (WM_HINTS != None) { - XDeleteProperty (SDL_Display, WMwindow, WM_HINTS); + XDeleteProperty(SDL_Display, WMwindow, WM_HINTS); set = SDL_TRUE; } /* Now try to unset KWM hints */ - WM_HINTS = XInternAtom (SDL_Display, "KWM_WIN_DECORATION", True); + WM_HINTS = XInternAtom(SDL_Display, "KWM_WIN_DECORATION", True); if (WM_HINTS != None) { - XDeleteProperty (SDL_Display, WMwindow, WM_HINTS); + XDeleteProperty(SDL_Display, WMwindow, WM_HINTS); set = SDL_TRUE; } /* Now try to unset GNOME hints */ - WM_HINTS = XInternAtom (SDL_Display, "_WIN_HINTS", True); + WM_HINTS = XInternAtom(SDL_Display, "_WIN_HINTS", True); if (WM_HINTS != None) { - XDeleteProperty (SDL_Display, WMwindow, WM_HINTS); + XDeleteProperty(SDL_Display, WMwindow, WM_HINTS); set = SDL_TRUE; } /* Finally unset the transient hints if necessary */ if (!set) { /* NOTE: Does this work? */ - XSetTransientForHint (SDL_Display, WMwindow, None); + XSetTransientForHint(SDL_Display, WMwindow, None); } } } static int -X11_CreateWindow (_THIS, SDL_Surface * screen, - const SDL_DisplayMode * mode, Uint32 flags) +X11_CreateWindow(_THIS, SDL_Surface * screen, + const SDL_DisplayMode * mode, Uint32 flags) { int i, depth; Visual *vis; @@ -786,18 +785,18 @@ int bpp; Uint32 Rmask, Gmask, Bmask, Amask; - SDL_PixelFormatEnumToMasks (mode->format, &bpp, &Rmask, &Gmask, &Bmask, - &Amask); + SDL_PixelFormatEnumToMasks(mode->format, &bpp, &Rmask, &Gmask, &Bmask, + &Amask); /* If a window is already present, destroy it and start fresh */ if (SDL_Window) { - X11_DestroyWindow (this, screen); + X11_DestroyWindow(this, screen); switch_waiting = 0; /* Prevent jump back to now-meaningless state. */ } /* See if we have been given a window id */ if (SDL_windowid) { - SDL_Window = SDL_strtol (SDL_windowid, NULL, 0); + SDL_Window = SDL_strtol(SDL_windowid, NULL, 0); } else { SDL_Window = 0; } @@ -806,7 +805,7 @@ if (flags & SDL_INTERNALOPENGL) { XVisualInfo *vi; - vi = X11_GL_GetVisual (this); + vi = X11_GL_GetVisual(this); if (!vi) { return -1; } @@ -815,7 +814,7 @@ } else if (SDL_windowid) { XWindowAttributes a; - XGetWindowAttributes (SDL_Display, SDL_Window, &a); + XGetWindowAttributes(SDL_Display, SDL_Window, &a); vis = a.visual; depth = a.depth; } else { @@ -827,105 +826,105 @@ break; } if (i == this->hidden->nvisuals) { - SDL_SetError ("No matching visual for requested depth"); + SDL_SetError("No matching visual for requested depth"); return -1; /* should never happen */ } vis = this->hidden->visuals[i].visual; depth = this->hidden->visuals[i].depth; } #ifdef X11_DEBUG - printf ("Choosing %s visual at %d bpp - %d colormap entries\n", - vis->class == PseudoColor ? "PseudoColor" : (vis->class == - TrueColor ? - "TrueColor" : (vis-> - class - == - DirectColor - ? - "DirectColor" - : - "Unknown")), - depth, vis->map_entries); + printf("Choosing %s visual at %d bpp - %d colormap entries\n", + vis->class == PseudoColor ? "PseudoColor" : (vis->class == + TrueColor ? + "TrueColor" : (vis-> + class + == + DirectColor + ? + "DirectColor" + : + "Unknown")), + depth, vis->map_entries); #endif vis_change = (vis != SDL_Visual); SDL_Visual = vis; this->hidden->depth = depth; /* Allocate the new pixel format for this video mode */ - if (!SDL_ReallocFormat (screen, bpp, Rmask, Gmask, Bmask, Amask)) { + if (!SDL_ReallocFormat(screen, bpp, Rmask, Gmask, Bmask, Amask)) { return -1; } /* Create the appropriate colormap */ if (SDL_XColorMap != SDL_DisplayColormap) { - XFreeColormap (SDL_Display, SDL_XColorMap); + XFreeColormap(SDL_Display, SDL_XColorMap); } if (SDL_Visual->class == PseudoColor) { int ncolors; /* Allocate the pixel flags */ ncolors = SDL_Visual->map_entries; - SDL_XPixels = SDL_malloc (ncolors * sizeof (int)); + SDL_XPixels = SDL_malloc(ncolors * sizeof(int)); if (SDL_XPixels == NULL) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return -1; } - SDL_memset (SDL_XPixels, 0, ncolors * sizeof (*SDL_XPixels)); + SDL_memset(SDL_XPixels, 0, ncolors * sizeof(*SDL_XPixels)); /* always allocate a private colormap on non-default visuals */ - if (SDL_Visual != DefaultVisual (SDL_Display, SDL_Screen)) { + if (SDL_Visual != DefaultVisual(SDL_Display, SDL_Screen)) { flags |= SDL_HWPALETTE; } if (flags & SDL_HWPALETTE) { screen->flags |= SDL_HWPALETTE; - SDL_XColorMap = XCreateColormap (SDL_Display, SDL_Root, - SDL_Visual, AllocAll); + SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root, + SDL_Visual, AllocAll); } else { SDL_XColorMap = SDL_DisplayColormap; } } else if (SDL_Visual->class == DirectColor) { /* Create a colormap which we can manipulate for gamma */ - SDL_XColorMap = XCreateColormap (SDL_Display, SDL_Root, - SDL_Visual, AllocAll); - XSync (SDL_Display, False); + SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root, + SDL_Visual, AllocAll); + XSync(SDL_Display, False); /* Initialize the colormap to the identity mapping */ - SDL_GetGammaRamp (0, 0, 0); + SDL_GetGammaRamp(0, 0, 0); SDL_VideoSurface = screen; - X11_SetGammaRamp (this, SDL_CurrentWindow.gamma); + X11_SetGammaRamp(this, SDL_CurrentWindow.gamma); SDL_VideoSurface = NULL; } else { /* Create a read-only colormap for our window */ - SDL_XColorMap = XCreateColormap (SDL_Display, SDL_Root, - SDL_Visual, AllocNone); + SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root, + SDL_Visual, AllocNone); } /* Recreate the auxiliary windows, if needed (required for GL) */ if (vis_change) - create_aux_windows (this); + create_aux_windows(this); if (screen->flags & SDL_HWPALETTE) { /* Since the full-screen window might have got a nonzero background colour (0 is white on some displays), we should reset the background to 0 here since that is what the user expects with a private colormap */ - XSetWindowBackground (SDL_Display, FSwindow, 0); - XClearWindow (SDL_Display, FSwindow); + XSetWindowBackground(SDL_Display, FSwindow, 0); + XClearWindow(SDL_Display, FSwindow); } /* resize the (possibly new) window manager window */ if (!SDL_windowid) { - X11_SetSizeHints (this, mode->w, mode->h, flags); + X11_SetSizeHints(this, mode->w, mode->h, flags); window_w = mode->w; window_h = mode->h; - XResizeWindow (SDL_Display, WMwindow, mode->w, mode->h); + XResizeWindow(SDL_Display, WMwindow, mode->w, mode->h); } /* Create (or use) the X11 display window */ if (!SDL_windowid) { if (flags & SDL_INTERNALOPENGL) { - if (X11_GL_CreateWindow (this, mode->w, mode->h) < 0) { + if (X11_GL_CreateWindow(this, mode->w, mode->h) < 0) { return (-1); } } else { @@ -934,21 +933,21 @@ swa.background_pixel = 0; swa.border_pixel = 0; swa.colormap = SDL_XColorMap; - SDL_Window = XCreateWindow (SDL_Display, WMwindow, - 0, 0, mode->w, mode->h, 0, depth, - InputOutput, SDL_Visual, - CWBackPixel | CWBorderPixel - | CWColormap, &swa); + SDL_Window = XCreateWindow(SDL_Display, WMwindow, + 0, 0, mode->w, mode->h, 0, depth, + InputOutput, SDL_Visual, + CWBackPixel | CWBorderPixel + | CWColormap, &swa); } /* Only manage our input if we own the window */ - XSelectInput (SDL_Display, SDL_Window, - (EnterWindowMask | LeaveWindowMask - | ButtonPressMask | ButtonReleaseMask - | PointerMotionMask | ExposureMask)); + XSelectInput(SDL_Display, SDL_Window, + (EnterWindowMask | LeaveWindowMask + | ButtonPressMask | ButtonReleaseMask + | PointerMotionMask | ExposureMask)); } /* Create the graphics context here, once we have a window */ if (flags & SDL_INTERNALOPENGL) { - if (X11_GL_CreateContext (this) < 0) { + if (X11_GL_CreateContext(this) < 0) { return (-1); } else { screen->flags |= SDL_INTERNALOPENGL; @@ -957,44 +956,44 @@ XGCValues gcv; gcv.graphics_exposures = False; - SDL_GC = XCreateGC (SDL_Display, SDL_Window, - GCGraphicsExposures, &gcv); + SDL_GC = XCreateGC(SDL_Display, SDL_Window, + GCGraphicsExposures, &gcv); if (!SDL_GC) { - SDL_SetError ("Couldn't create graphics context"); + SDL_SetError("Couldn't create graphics context"); return (-1); } } /* Set our colormaps when not setting a GL mode */ if (!(flags & SDL_INTERNALOPENGL)) { - XSetWindowColormap (SDL_Display, SDL_Window, SDL_XColorMap); + XSetWindowColormap(SDL_Display, SDL_Window, SDL_XColorMap); if (!SDL_windowid) { - XSetWindowColormap (SDL_Display, FSwindow, SDL_XColorMap); - XSetWindowColormap (SDL_Display, WMwindow, SDL_XColorMap); + XSetWindowColormap(SDL_Display, FSwindow, SDL_XColorMap); + XSetWindowColormap(SDL_Display, WMwindow, SDL_XColorMap); } } #if 0 /* This is an experiment - are the graphics faster now? - nope. */ - if (SDL_getenv ("SDL_VIDEO_X11_BACKINGSTORE")) + if (SDL_getenv("SDL_VIDEO_X11_BACKINGSTORE")) #endif /* Cache the window in the server, when possible */ { Screen *xscreen; XSetWindowAttributes a; - xscreen = ScreenOfDisplay (SDL_Display, SDL_Screen); - a.backing_store = DoesBackingStore (xscreen); + xscreen = ScreenOfDisplay(SDL_Display, SDL_Screen); + a.backing_store = DoesBackingStore(xscreen); if (a.backing_store != NotUseful) { - XChangeWindowAttributes (SDL_Display, SDL_Window, - CWBackingStore, &a); + XChangeWindowAttributes(SDL_Display, SDL_Window, + CWBackingStore, &a); } } /* Update the internal keyboard state */ - X11_SetKeyboardState (SDL_Display, NULL); + X11_SetKeyboardState(SDL_Display, NULL); /* When the window is first mapped, ignore non-modifier keys */ { - Uint8 *keys = SDL_GetKeyState (NULL); + Uint8 *keys = SDL_GetKeyState(NULL); for (i = 0; i < SDLK_LAST; ++i) { switch (i) { case SDLK_NUMLOCK: @@ -1018,12 +1017,12 @@ /* Map them both and go fullscreen, if requested */ if (!SDL_windowid) { - XMapWindow (SDL_Display, SDL_Window); - XMapWindow (SDL_Display, WMwindow); - X11_WaitMapped (this, WMwindow); + XMapWindow(SDL_Display, SDL_Window); + XMapWindow(SDL_Display, WMwindow); + X11_WaitMapped(this, WMwindow); if (flags & SDL_FULLSCREEN) { screen->flags |= SDL_FULLSCREEN; - X11_EnterFullScreen (this); + X11_EnterFullScreen(this); } else { screen->flags &= ~SDL_FULLSCREEN; } @@ -1033,42 +1032,42 @@ } static int -X11_ResizeWindow (_THIS, SDL_Surface * screen, int w, int h, Uint32 flags) +X11_ResizeWindow(_THIS, SDL_Surface * screen, int w, int h, Uint32 flags) { if (!SDL_windowid) { /* Resize the window manager window */ - X11_SetSizeHints (this, w, h, flags); + X11_SetSizeHints(this, w, h, flags); window_w = w; window_h = h; - XResizeWindow (SDL_Display, WMwindow, w, h); + XResizeWindow(SDL_Display, WMwindow, w, h); /* Resize the fullscreen and display windows */ if (flags & SDL_FULLSCREEN) { if (screen->flags & SDL_FULLSCREEN) { - X11_ResizeFullScreen (this); + X11_ResizeFullScreen(this); } else { screen->flags |= SDL_FULLSCREEN; - X11_EnterFullScreen (this); + X11_EnterFullScreen(this); } } else { if (screen->flags & SDL_FULLSCREEN) { screen->flags &= ~SDL_FULLSCREEN; - X11_LeaveFullScreen (this); + X11_LeaveFullScreen(this); } } - XResizeWindow (SDL_Display, SDL_Window, w, h); + XResizeWindow(SDL_Display, SDL_Window, w, h); } return (0); } SDL_Surface * -X11_SetVideoMode (_THIS, SDL_Surface * current, - const SDL_DisplayMode * mode, Uint32 flags) +X11_SetVideoMode(_THIS, SDL_Surface * current, + const SDL_DisplayMode * mode, Uint32 flags) { Uint32 saved_flags; /* Lock the event thread, in multi-threading environments */ - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); /* Check the combination of flags we were passed */ if (flags & SDL_FULLSCREEN) { @@ -1079,7 +1078,7 @@ } /* Flush any delayed updates */ - XSync (GFX_Display, False); + XSync(GFX_Display, False); /* Set up the X11 window */ saved_flags = current->flags; @@ -1088,12 +1087,12 @@ (flags & SDL_INTERNALOPENGL)) && (mode->format == SDL_CurrentDisplay.current_mode.format) && ((saved_flags & SDL_NOFRAME) == (flags & SDL_NOFRAME))) { - if (X11_ResizeWindow (this, current, mode->w, mode->h, flags) < 0) { + if (X11_ResizeWindow(this, current, mode->w, mode->h, flags) < 0) { current = NULL; goto done; } } else { - if (X11_CreateWindow (this, current, mode, flags) < 0) { + if (X11_CreateWindow(this, current, mode, flags) < 0) { current = NULL; goto done; } @@ -1105,22 +1104,22 @@ { current->w = mode->w; current->h = mode->h; - current->pitch = SDL_CalculatePitch (current); - X11_ResizeImage (this, current, flags); + current->pitch = SDL_CalculatePitch(current); + X11_ResizeImage(this, current, flags); } current->flags |= (flags & (SDL_RESIZABLE | SDL_NOFRAME)); done: /* Release the event thread */ - XSync (SDL_Display, False); - SDL_Unlock_EventThread (); + XSync(SDL_Display, False); + SDL_Unlock_EventThread(); /* We're done! */ return (current); } static int -X11_ToggleFullScreen (_THIS, int on) +X11_ToggleFullScreen(_THIS, int on) { Uint32 event_thread; @@ -1130,31 +1129,31 @@ } /* Don't lock if we are the event thread */ - event_thread = SDL_EventThreadID (); - if (event_thread && (SDL_ThreadID () == event_thread)) { + event_thread = SDL_EventThreadID(); + if (event_thread && (SDL_ThreadID() == event_thread)) { event_thread = 0; } if (event_thread) { - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); } if (on) { SDL_VideoSurface->flags |= SDL_FULLSCREEN; - X11_EnterFullScreen (this); + X11_EnterFullScreen(this); } else { SDL_VideoSurface->flags &= ~SDL_FULLSCREEN; - X11_LeaveFullScreen (this); + X11_LeaveFullScreen(this); } - X11_RefreshDisplay (this); + X11_RefreshDisplay(this); if (event_thread) { - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); } - SDL_ResetKeyboard (); + SDL_ResetKeyboard(); return (1); } /* Update the current mouse state and position */ static void -X11_UpdateMouse (_THIS) +X11_UpdateMouse(_THIS) { Window u1; int u2; @@ -1163,18 +1162,18 @@ unsigned int mask; /* Lock the event thread, in multi-threading environments */ - SDL_Lock_EventThread (); - if (XQueryPointer (SDL_Display, SDL_Window, &u1, ¤t_win, - &u2, &u2, &x, &y, &mask)) { + SDL_Lock_EventThread(); + if (XQueryPointer(SDL_Display, SDL_Window, &u1, ¤t_win, + &u2, &u2, &x, &y, &mask)) { if ((x >= 0) && (x < SDL_VideoSurface->w) && (y >= 0) && (y < SDL_VideoSurface->h)) { - SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); - SDL_PrivateMouseMotion (0, 0, x, y); + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); + SDL_PrivateMouseMotion(0, 0, x, y); } else { - SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); } } - SDL_Unlock_EventThread (); + SDL_Unlock_EventThread(); } /* simple colour distance metric. Supposed to be better than a plain @@ -1186,7 +1185,7 @@ + LIGHT_FACTOR * abs(r1 + g1 + b1 - (r2 + g2 + b2))) static void -allocate_nearest (_THIS, SDL_Color * colors, SDL_Color * want, int nwant) +allocate_nearest(_THIS, SDL_Color * colors, SDL_Color * want, int nwant) { /* * There is no way to know which ones to choose from, so we retrieve @@ -1201,7 +1200,7 @@ * XQueryColors sets the flags in the XColor struct, so we use * that to keep track of which colours are available */ - XQueryColors (GFX_Display, SDL_XColorMap, all, 256); + XQueryColors(GFX_Display, SDL_XColorMap, all, 256); for (i = 0; i < nwant; i++) { XColor *c; @@ -1218,7 +1217,7 @@ rj = all[j].red >> 8; gj = all[j].green >> 8; bj = all[j].blue >> 8; - d2 = COLOUR_DIST (ri, gi, bi, rj, gj, bj); + d2 = COLOUR_DIST(ri, gi, bi, rj, gj, bj); if (d2 < mindist) { mindist = d2; best = j; @@ -1227,7 +1226,7 @@ if (SDL_XPixels[best]) continue; /* already allocated, waste no more time */ c = all + best; - if (XAllocColor (GFX_Display, SDL_XColorMap, c)) { + if (XAllocColor(GFX_Display, SDL_XColorMap, c)) { /* got it */ colors[c->pixel].r = c->red >> 8; colors[c->pixel].g = c->green >> 8; @@ -1248,7 +1247,7 @@ } int -X11_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +X11_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { int nrej = 0; @@ -1260,7 +1259,7 @@ /* private writable colormap: just set the colours we need */ XColor *xcmap; int i; - xcmap = SDL_stack_alloc (XColor, ncolors); + xcmap = SDL_stack_alloc(XColor, ncolors); if (xcmap == NULL) return 0; for (i = 0; i < ncolors; ++i) { @@ -1270,9 +1269,9 @@ xcmap[i].blue = (colors[i].b << 8) | colors[i].b; xcmap[i].flags = (DoRed | DoGreen | DoBlue); } - XStoreColors (GFX_Display, SDL_XColorMap, xcmap, ncolors); - XSync (GFX_Display, False); - SDL_stack_free (xcmap); + XStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors); + XSync(GFX_Display, False); + SDL_stack_free(xcmap); } else { /* * Shared colormap: We only allocate read-only cells, which @@ -1290,7 +1289,7 @@ int nfree = 0; int nc = SDL_VideoSurface->format->palette->ncolors; colors = SDL_VideoSurface->format->palette->colors; - freelist = SDL_stack_alloc (unsigned long, nc); + freelist = SDL_stack_alloc(unsigned long, nc); /* make sure multiple allocations of the same cell are freed */ for (i = 0; i < ncolors; i++) { int pixel = firstcolor + i; @@ -1299,15 +1298,15 @@ --SDL_XPixels[pixel]; } } - XFreeColors (GFX_Display, SDL_XColorMap, freelist, nfree, 0); - SDL_stack_free (freelist); + XFreeColors(GFX_Display, SDL_XColorMap, freelist, nfree, 0); + SDL_stack_free(freelist); - want = SDL_stack_alloc (SDL_Color, ncolors); - reject = SDL_stack_alloc (SDL_Color, ncolors); - SDL_memcpy (want, colors + firstcolor, ncolors * sizeof (SDL_Color)); + want = SDL_stack_alloc(SDL_Color, ncolors); + reject = SDL_stack_alloc(SDL_Color, ncolors); + SDL_memcpy(want, colors + firstcolor, ncolors * sizeof(SDL_Color)); /* make sure the user isn't fooled by her own wishes (black is safe, always available in the default colormap) */ - SDL_memset (colors + firstcolor, 0, ncolors * sizeof (SDL_Color)); + SDL_memset(colors + firstcolor, 0, ncolors * sizeof(SDL_Color)); /* now try to allocate the colours */ for (i = 0; i < ncolors; i++) { @@ -1316,7 +1315,7 @@ col.green = want[i].g << 8; col.blue = want[i].b << 8; col.flags = DoRed | DoGreen | DoBlue; - if (XAllocColor (GFX_Display, SDL_XColorMap, &col)) { + if (XAllocColor(GFX_Display, SDL_XColorMap, &col)) { /* We got the colour, or at least the nearest the hardware could get. */ colors[col.pixel].r = col.red >> 8; @@ -1332,22 +1331,22 @@ } } if (nrej) - allocate_nearest (this, colors, reject, nrej); - SDL_stack_free (reject); - SDL_stack_free (want); + allocate_nearest(this, colors, reject, nrej); + SDL_stack_free(reject); + SDL_stack_free(want); } return nrej == 0; } int -X11_SetGammaRamp (_THIS, Uint16 * ramp) +X11_SetGammaRamp(_THIS, Uint16 * ramp) { int i, ncolors; XColor xcmap[256]; /* See if actually setting the gamma is supported */ if (SDL_Visual->class != DirectColor) { - SDL_SetError ("Gamma correction not supported on this visual"); + SDL_SetError("Gamma correction not supported on this visual"); return (-1); } @@ -1355,14 +1354,14 @@ ncolors = SDL_Visual->map_entries; for (i = 0; i < ncolors; ++i) { Uint8 c = (256 * i / ncolors); - xcmap[i].pixel = SDL_MapRGB (SDL_VideoSurface->format, c, c, c); + xcmap[i].pixel = SDL_MapRGB(SDL_VideoSurface->format, c, c, c); xcmap[i].red = ramp[0 * 256 + c]; xcmap[i].green = ramp[1 * 256 + c]; xcmap[i].blue = ramp[2 * 256 + c]; xcmap[i].flags = (DoRed | DoGreen | DoBlue); } - XStoreColors (GFX_Display, SDL_XColorMap, xcmap, ncolors); - XSync (GFX_Display, False); + XStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors); + XSync(GFX_Display, False); return (0); } @@ -1370,85 +1369,85 @@ another SDL video routine -- notably UpdateRects. */ void -X11_VideoQuit (_THIS) +X11_VideoQuit(_THIS) { /* Shutdown everything that's still up */ /* The event thread should be done, so we can touch SDL_Display */ if (SDL_Display != NULL) { /* Flush any delayed updates */ - XSync (GFX_Display, False); + XSync(GFX_Display, False); /* Close the connection with the IM server */ #ifdef X_HAVE_UTF8_STRING if (SDL_IC != NULL) { - XDestroyIC (SDL_IC); + XDestroyIC(SDL_IC); SDL_IC = NULL; } if (SDL_IM != NULL) { - XCloseIM (SDL_IM); + XCloseIM(SDL_IM); SDL_IM = NULL; } #endif /* Start shutting down the windows */ - X11_DestroyImage (this, SDL_VideoSurface); - X11_DestroyWindow (this, SDL_VideoSurface); - X11_FreeVideoModes (this); + X11_DestroyImage(this, SDL_VideoSurface); + X11_DestroyWindow(this, SDL_VideoSurface); + X11_FreeVideoModes(this); if (SDL_XColorMap != SDL_DisplayColormap) { - XFreeColormap (SDL_Display, SDL_XColorMap); + XFreeColormap(SDL_Display, SDL_XColorMap); } if (SDL_iconcolors) { unsigned long pixel; - Colormap dcmap = DefaultColormap (SDL_Display, - SDL_Screen); + Colormap dcmap = DefaultColormap(SDL_Display, + SDL_Screen); for (pixel = 0; pixel < 256; ++pixel) { while (SDL_iconcolors[pixel] > 0) { - XFreeColors (GFX_Display, dcmap, &pixel, 1, 0); + XFreeColors(GFX_Display, dcmap, &pixel, 1, 0); --SDL_iconcolors[pixel]; } } - SDL_free (SDL_iconcolors); + SDL_free(SDL_iconcolors); SDL_iconcolors = NULL; } if (xinerama) { - XFree (xinerama); + XFree(xinerama); } /* Restore gamma settings if they've changed */ - if (SDL_GetAppState () & SDL_APPACTIVE) { - X11_SwapVidModeGamma (this); + if (SDL_GetAppState() & SDL_APPACTIVE) { + X11_SwapVidModeGamma(this); } /* Restore DPMS and screensaver settings */ - X11_RestoreScreenSaver (SDL_Display, screensaver_timeout, - dpms_enabled); + X11_RestoreScreenSaver(SDL_Display, screensaver_timeout, + dpms_enabled); /* Free that blank cursor */ if (SDL_BlankCursor != NULL) { - this->FreeWMCursor (this, SDL_BlankCursor); + this->FreeWMCursor(this, SDL_BlankCursor); SDL_BlankCursor = NULL; } /* Close the X11 graphics connection */ if (GFX_Display != NULL) { - XCloseDisplay (GFX_Display); + XCloseDisplay(GFX_Display); GFX_Display = NULL; } /* Close the X11 display connection */ - XCloseDisplay (SDL_Display); + XCloseDisplay(SDL_Display); SDL_Display = NULL; /* Reset the X11 error handlers */ if (XIO_handler) { - XSetIOErrorHandler (XIO_handler); + XSetIOErrorHandler(XIO_handler); } if (X_handler) { - XSetErrorHandler (X_handler); + XSetErrorHandler(X_handler); } /* Unload GL library after X11 shuts down */ - X11_GL_UnloadLibrary (this); + X11_GL_UnloadLibrary(this); } if (SDL_VideoSurface && (SDL_VideoSurface->flags & SDL_HWSURFACE)) { /* Direct screen access, no memory buffer */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11video.h --- a/src/video/x11/SDL_x11video.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11video.h Mon May 29 04:04:35 2006 +0000 @@ -117,7 +117,7 @@ /* Variables used by the X11 video mode code */ #if SDL_VIDEO_DRIVER_X11_XINERAMA - SDL_NAME (XineramaScreenInfo) * xinerama; + SDL_NAME(XineramaScreenInfo) * xinerama; #endif #if SDL_VIDEO_DRIVER_X11_XRANDR XRRScreenConfiguration *screen_config; @@ -125,7 +125,7 @@ Rotation saved_rotation; #endif #if SDL_VIDEO_DRIVER_X11_VIDMODE - SDL_NAME (XF86VidModeModeInfo) saved_mode; + SDL_NAME(XF86VidModeModeInfo) saved_mode; struct { int x, y; diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11wm.c --- a/src/video/x11/SDL_x11wm.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11wm.c Mon May 29 04:04:35 2006 +0000 @@ -34,7 +34,7 @@ #include "SDL_x11wm_c.h" static Uint8 -reverse_byte (Uint8 x) +reverse_byte(Uint8 x) { x = (x & 0xaa) >> 1 | (x & 0x55) << 1; x = (x & 0xcc) >> 2 | (x & 0x33) << 2; @@ -43,7 +43,7 @@ } void -X11_SetIcon (_THIS, SDL_Surface * icon, Uint8 * mask) +X11_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask) { SDL_Surface *sicon; XWMHints *wmhints; @@ -60,12 +60,12 @@ char *p; int masksize; - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); /* The icon must use the default visual, depth and colormap of the screen, so it might need a conversion */ - dvis = DefaultVisual (SDL_Display, SDL_Screen); - dbpp = DefaultDepth (SDL_Display, SDL_Screen); + dvis = DefaultVisual(SDL_Display, SDL_Screen); + dbpp = DefaultDepth(SDL_Display, SDL_Screen); for (i = 0; i < this->hidden->nvisuals; i++) { if (this->hidden->visuals[i].visual == dvis) { dbpp = this->hidden->visuals[i].bpp; @@ -74,10 +74,10 @@ } /* The Visual struct is supposed to be opaque but we cheat a little */ - sicon = SDL_CreateRGBSurface (SDL_SWSURFACE, icon->w, icon->h, - dbpp, - dvis->red_mask, dvis->green_mask, - dvis->blue_mask, 0); + sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h, + dbpp, + dvis->red_mask, dvis->green_mask, + dvis->blue_mask, 0); if (sicon == NULL) goto done; @@ -88,13 +88,13 @@ int nwant; Colormap dcmap; int missing; - dcmap = DefaultColormap (SDL_Display, SDL_Screen); + dcmap = DefaultColormap(SDL_Display, SDL_Screen); if (icon->format->palette) { /* The icon has a palette as well - we just have to find those colours */ nwant = icon->format->palette->ncolors; - SDL_memcpy (want, icon->format->palette->colors, - nwant * sizeof want[0]); + SDL_memcpy(want, icon->format->palette->colors, + nwant * sizeof want[0]); } else { /* try the standard 6x6x6 cube for lack of better ideas */ @@ -118,14 +118,14 @@ SDL_iconcolors[i]--; } } - XFreeColors (GFX_Display, dcmap, freelist, nfree, 0); + XFreeColors(GFX_Display, dcmap, freelist, nfree, 0); } if (!SDL_iconcolors) - SDL_iconcolors = SDL_malloc (256 * sizeof *SDL_iconcolors); - SDL_memset (SDL_iconcolors, 0, 256 * sizeof *SDL_iconcolors); + SDL_iconcolors = SDL_malloc(256 * sizeof *SDL_iconcolors); + SDL_memset(SDL_iconcolors, 0, 256 * sizeof *SDL_iconcolors); /* try to allocate the colours */ - SDL_memset (got, 0, sizeof got); + SDL_memset(got, 0, sizeof got); missing = 0; for (i = 0; i < nwant; i++) { XColor c; @@ -133,7 +133,7 @@ c.green = want[i].g << 8; c.blue = want[i].b << 8; c.flags = DoRed | DoGreen | DoBlue; - if (XAllocColor (GFX_Display, dcmap, &c)) { + if (XAllocColor(GFX_Display, dcmap, &c)) { /* got the colour */ SDL_iconcolors[c.pixel]++; got[c.pixel] = want[i]; @@ -147,13 +147,13 @@ XColor cols[256]; for (i = 0; i < 256; i++) cols[i].pixel = i; - XQueryColors (GFX_Display, dcmap, cols, 256); + XQueryColors(GFX_Display, dcmap, cols, 256); for (i = 0; i < 256; i++) { got[i].r = cols[i].red >> 8; got[i].g = cols[i].green >> 8; got[i].b = cols[i].blue >> 8; if (!SDL_iconcolors[i]) { - if (XAllocColor (GFX_Display, dcmap, cols + i)) { + if (XAllocColor(GFX_Display, dcmap, cols + i)) { SDL_iconcolors[i] = 1; } else { /* index not available */ @@ -165,62 +165,62 @@ } } - SDL_SetColors (sicon, got, 0, 256); + SDL_SetColors(sicon, got, 0, 256); } bounds.x = 0; bounds.y = 0; bounds.w = icon->w; bounds.h = icon->h; - if (SDL_LowerBlit (icon, &bounds, sicon, &bounds) < 0) + if (SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0) goto done; /* We need the mask as given, except in LSBfirst format instead of MSBfirst. Reverse the bits in each byte. */ masksize = ((sicon->w + 7) >> 3) * sicon->h; - LSBmask = SDL_malloc (masksize); + LSBmask = SDL_malloc(masksize); if (LSBmask == NULL) { goto done; } - SDL_memset (LSBmask, 0, masksize); + SDL_memset(LSBmask, 0, masksize); for (i = 0; i < masksize; i++) - LSBmask[i] = reverse_byte (mask[i]); - mask_pixmap = XCreatePixmapFromBitmapData (SDL_Display, WMwindow, - (char *) LSBmask, - sicon->w, sicon->h, 1L, 0L, 1); + LSBmask[i] = reverse_byte(mask[i]); + mask_pixmap = XCreatePixmapFromBitmapData(SDL_Display, WMwindow, + (char *) LSBmask, + sicon->w, sicon->h, 1L, 0L, 1); /* Transfer the image to an X11 pixmap */ - icon_image = XCreateImage (SDL_Display, - DefaultVisual (SDL_Display, SDL_Screen), - DefaultDepth (SDL_Display, SDL_Screen), - ZPixmap, 0, sicon->pixels, - sicon->w, sicon->h, 32, 0); + icon_image = XCreateImage(SDL_Display, + DefaultVisual(SDL_Display, SDL_Screen), + DefaultDepth(SDL_Display, SDL_Screen), + ZPixmap, 0, sicon->pixels, + sicon->w, sicon->h, 32, 0); icon_image->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN) ? MSBFirst : LSBFirst; - icon_pixmap = XCreatePixmap (SDL_Display, SDL_Root, sicon->w, sicon->h, - DefaultDepth (SDL_Display, SDL_Screen)); - gc = XCreateGC (SDL_Display, icon_pixmap, 0, &GCvalues); - XPutImage (SDL_Display, icon_pixmap, gc, icon_image, - 0, 0, 0, 0, sicon->w, sicon->h); - XFreeGC (SDL_Display, gc); - XDestroyImage (icon_image); - SDL_free (LSBmask); + icon_pixmap = XCreatePixmap(SDL_Display, SDL_Root, sicon->w, sicon->h, + DefaultDepth(SDL_Display, SDL_Screen)); + gc = XCreateGC(SDL_Display, icon_pixmap, 0, &GCvalues); + XPutImage(SDL_Display, icon_pixmap, gc, icon_image, + 0, 0, 0, 0, sicon->w, sicon->h); + XFreeGC(SDL_Display, gc); + XDestroyImage(icon_image); + SDL_free(LSBmask); sicon->pixels = NULL; /* Some buggy window managers (some versions of Enlightenment, it seems) need an icon window *and* icon pixmap to work properly, while it screws up others. The default is only to use a pixmap. */ - p = SDL_getenv ("SDL_VIDEO_X11_ICONWIN"); + p = SDL_getenv("SDL_VIDEO_X11_ICONWIN"); if (p && *p) { - icon_window = XCreateSimpleWindow (SDL_Display, SDL_Root, - 0, 0, sicon->w, sicon->h, 0, - CopyFromParent, CopyFromParent); - XSetWindowBackgroundPixmap (SDL_Display, icon_window, icon_pixmap); - XClearWindow (SDL_Display, icon_window); + icon_window = XCreateSimpleWindow(SDL_Display, SDL_Root, + 0, 0, sicon->w, sicon->h, 0, + CopyFromParent, CopyFromParent); + XSetWindowBackgroundPixmap(SDL_Display, icon_window, icon_pixmap); + XClearWindow(SDL_Display, icon_window); } /* Set the window icon to the icon pixmap (and icon window) */ - wmhints = XAllocWMHints (); + wmhints = XAllocWMHints(); wmhints->flags = (IconPixmapHint | IconMaskHint); wmhints->icon_pixmap = icon_pixmap; wmhints->icon_mask = mask_pixmap; @@ -228,17 +228,17 @@ wmhints->flags |= IconWindowHint; wmhints->icon_window = icon_window; } - XSetWMHints (SDL_Display, WMwindow, wmhints); - XFree (wmhints); - XSync (SDL_Display, False); + XSetWMHints(SDL_Display, WMwindow, wmhints); + XFree(wmhints); + XSync(SDL_Display, False); done: - SDL_Unlock_EventThread (); - SDL_FreeSurface (sicon); + SDL_Unlock_EventThread(); + SDL_FreeSurface(sicon); } void -X11_SetCaptionNoLock (_THIS, const char *title, const char *icon) +X11_SetCaptionNoLock(_THIS, const char *title, const char *icon) { XTextProperty titleprop, iconprop; Status status; @@ -249,91 +249,90 @@ /* Look up some useful Atoms */ if (SDL_X11_HAVE_UTF8) { - _NET_WM_NAME = XInternAtom (SDL_Display, "_NET_WM_NAME", False); + _NET_WM_NAME = XInternAtom(SDL_Display, "_NET_WM_NAME", False); _NET_WM_ICON_NAME = - XInternAtom (SDL_Display, "_NET_WM_ICON_NAME", False); + XInternAtom(SDL_Display, "_NET_WM_ICON_NAME", False); } #endif if (title != NULL) { - char *title_latin1 = SDL_iconv_utf8_latin1 ((char *) title); + char *title_latin1 = SDL_iconv_utf8_latin1((char *) title); if (!title_latin1) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return; } - status = XStringListToTextProperty (&title_latin1, 1, &titleprop); - SDL_free (title_latin1); + status = XStringListToTextProperty(&title_latin1, 1, &titleprop); + SDL_free(title_latin1); if (status) { - XSetTextProperty (SDL_Display, WMwindow, &titleprop, XA_WM_NAME); - XFree (titleprop.value); + XSetTextProperty(SDL_Display, WMwindow, &titleprop, XA_WM_NAME); + XFree(titleprop.value); } #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { - status = Xutf8TextListToTextProperty (SDL_Display, - (char **) &title, 1, - XUTF8StringStyle, - &titleprop); + status = Xutf8TextListToTextProperty(SDL_Display, + (char **) &title, 1, + XUTF8StringStyle, + &titleprop); if (status == Success) { - XSetTextProperty (SDL_Display, WMwindow, &titleprop, - _NET_WM_NAME); - XFree (titleprop.value); + XSetTextProperty(SDL_Display, WMwindow, &titleprop, + _NET_WM_NAME); + XFree(titleprop.value); } } #endif } if (icon != NULL) { - char *icon_latin1 = SDL_iconv_utf8_latin1 ((char *) icon); + char *icon_latin1 = SDL_iconv_utf8_latin1((char *) icon); if (!icon_latin1) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); return; } - status = XStringListToTextProperty (&icon_latin1, 1, &iconprop); - SDL_free (icon_latin1); + status = XStringListToTextProperty(&icon_latin1, 1, &iconprop); + SDL_free(icon_latin1); if (status) { - XSetTextProperty (SDL_Display, WMwindow, &iconprop, - XA_WM_ICON_NAME); - XFree (iconprop.value); + XSetTextProperty(SDL_Display, WMwindow, &iconprop, + XA_WM_ICON_NAME); + XFree(iconprop.value); } #ifdef X_HAVE_UTF8_STRING if (SDL_X11_HAVE_UTF8) { - status = Xutf8TextListToTextProperty (SDL_Display, - (char **) &icon, 1, - XUTF8StringStyle, - &iconprop); + status = Xutf8TextListToTextProperty(SDL_Display, + (char **) &icon, 1, + XUTF8StringStyle, &iconprop); if (status == Success) { - XSetTextProperty (SDL_Display, WMwindow, &iconprop, - _NET_WM_ICON_NAME); - XFree (iconprop.value); + XSetTextProperty(SDL_Display, WMwindow, &iconprop, + _NET_WM_ICON_NAME); + XFree(iconprop.value); } } #endif } - XSync (SDL_Display, False); + XSync(SDL_Display, False); } void -X11_SetCaption (_THIS, const char *title, const char *icon) +X11_SetCaption(_THIS, const char *title, const char *icon) { - SDL_Lock_EventThread (); - X11_SetCaptionNoLock (this, title, icon); - SDL_Unlock_EventThread (); + SDL_Lock_EventThread(); + X11_SetCaptionNoLock(this, title, icon); + SDL_Unlock_EventThread(); } /* Iconify the window */ int -X11_IconifyWindow (_THIS) +X11_IconifyWindow(_THIS) { int result; - SDL_Lock_EventThread (); - result = XIconifyWindow (SDL_Display, WMwindow, SDL_Screen); - XSync (SDL_Display, False); - SDL_Unlock_EventThread (); + SDL_Lock_EventThread(); + result = XIconifyWindow(SDL_Display, WMwindow, SDL_Screen); + XSync(SDL_Display, False); + SDL_Unlock_EventThread(); return (result); } SDL_GrabMode -X11_GrabInputNoLock (_THIS, SDL_GrabMode mode) +X11_GrabInputNoLock(_THIS, SDL_GrabMode mode) { int result; @@ -344,12 +343,12 @@ return (mode); /* Will be set later on mode switch */ } if (mode == SDL_GRAB_OFF) { - XUngrabPointer (SDL_Display, CurrentTime); - XUngrabKeyboard (SDL_Display, CurrentTime); + XUngrabPointer(SDL_Display, CurrentTime); + XUngrabKeyboard(SDL_Display, CurrentTime); } else { if (SDL_VideoSurface->flags & SDL_FULLSCREEN) { /* Unbind the mouse from the fullscreen window */ - XUngrabPointer (SDL_Display, CurrentTime); + XUngrabPointer(SDL_Display, CurrentTime); } /* Try to grab the mouse */ #if 0 /* We'll wait here until we actually grab, otherwise behavior undefined */ @@ -357,39 +356,39 @@ #else for (;;) { #endif - result = XGrabPointer (SDL_Display, SDL_Window, True, 0, - GrabModeAsync, GrabModeAsync, - SDL_Window, None, CurrentTime); + result = XGrabPointer(SDL_Display, SDL_Window, True, 0, + GrabModeAsync, GrabModeAsync, + SDL_Window, None, CurrentTime); if (result == GrabSuccess) { break; } - SDL_Delay (100); + SDL_Delay(100); } if (result != GrabSuccess) { /* Uh, oh, what do we do here? */ ; } /* Now grab the keyboard */ - XGrabKeyboard (SDL_Display, WMwindow, True, - GrabModeAsync, GrabModeAsync, CurrentTime); + XGrabKeyboard(SDL_Display, WMwindow, True, + GrabModeAsync, GrabModeAsync, CurrentTime); /* Raise the window if we grab the mouse */ if (!(SDL_VideoSurface->flags & SDL_FULLSCREEN)) - XRaiseWindow (SDL_Display, WMwindow); + XRaiseWindow(SDL_Display, WMwindow); /* Make sure we register input focus */ - SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS); + SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); } - XSync (SDL_Display, False); + XSync(SDL_Display, False); return (mode); } SDL_GrabMode -X11_GrabInput (_THIS, SDL_GrabMode mode) +X11_GrabInput(_THIS, SDL_GrabMode mode) { - SDL_Lock_EventThread (); - mode = X11_GrabInputNoLock (this, mode); - SDL_Unlock_EventThread (); + SDL_Lock_EventThread(); + mode = X11_GrabInputNoLock(this, mode); + SDL_Unlock_EventThread(); return (mode); } @@ -398,29 +397,29 @@ Otherwise, in case of a version mismatch, it returns -1. */ static void -lock_display (void) +lock_display(void) { - SDL_Lock_EventThread (); + SDL_Lock_EventThread(); } static void -unlock_display (void) +unlock_display(void) { /* Make sure any X11 transactions are completed */ SDL_VideoDevice *this = current_video; - XSync (SDL_Display, False); - SDL_Unlock_EventThread (); + XSync(SDL_Display, False); + SDL_Unlock_EventThread(); } int -X11_GetWMInfo (_THIS, SDL_SysWMinfo * info) +X11_GetWMInfo(_THIS, SDL_SysWMinfo * info) { if (info->version.major <= SDL_MAJOR_VERSION) { info->subsystem = SDL_SYSWM_X11; info->info.x11.display = SDL_Display; info->info.x11.window = SDL_Window; - if (SDL_VERSIONNUM (info->version.major, - info->version.minor, - info->version.patch) >= 1002) { + if (SDL_VERSIONNUM(info->version.major, + info->version.minor, + info->version.patch) >= 1002) { info->info.x11.fswindow = FSwindow; info->info.x11.wmwindow = WMwindow; } @@ -428,8 +427,8 @@ info->info.x11.unlock_func = unlock_display; return (1); } else { - SDL_SetError ("Application not compiled with SDL %d.%d\n", - SDL_MAJOR_VERSION, SDL_MINOR_VERSION); + SDL_SetError("Application not compiled with SDL %d.%d\n", + SDL_MAJOR_VERSION, SDL_MINOR_VERSION); return (-1); } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11wm_c.h --- a/src/video/x11/SDL_x11wm_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11wm_c.h Mon May 29 04:04:35 2006 +0000 @@ -24,11 +24,11 @@ #include "SDL_x11video.h" /* Functions to be exported */ -extern void X11_SetCaptionNoLock (_THIS, const char *title, const char *icon); -extern void X11_SetCaption (_THIS, const char *title, const char *icon); -extern void X11_SetIcon (_THIS, SDL_Surface * icon, Uint8 * mask); -extern int X11_IconifyWindow (_THIS); -extern SDL_GrabMode X11_GrabInputNoLock (_THIS, SDL_GrabMode mode); -extern SDL_GrabMode X11_GrabInput (_THIS, SDL_GrabMode mode); -extern int X11_GetWMInfo (_THIS, SDL_SysWMinfo * info); +extern void X11_SetCaptionNoLock(_THIS, const char *title, const char *icon); +extern void X11_SetCaption(_THIS, const char *title, const char *icon); +extern void X11_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask); +extern int X11_IconifyWindow(_THIS); +extern SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode); +extern SDL_GrabMode X11_GrabInput(_THIS, SDL_GrabMode mode); +extern int X11_GetWMInfo(_THIS, SDL_SysWMinfo * info); /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11yuv.c --- a/src/video/x11/SDL_x11yuv.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11yuv.c Mon May 29 04:04:35 2006 +0000 @@ -64,7 +64,7 @@ int yuv_use_mitshm; XShmSegmentInfo yuvshm; #endif - SDL_NAME (XvImage) * image; + SDL_NAME(XvImage) * image; }; @@ -74,37 +74,37 @@ /* Shared memory error handler routine */ static int shm_error; static int -shm_errhandler (Display * d, XErrorEvent * e) +shm_errhandler(Display * d, XErrorEvent * e) { if (e->error_code == BadAccess) { shm_error = True; return (0); } else - return (X_handler (d, e)); + return (X_handler(d, e)); } #endif /* !NO_SHARED_MEMORY */ static int xv_error; static int -xv_errhandler (Display * d, XErrorEvent * e) +xv_errhandler(Display * d, XErrorEvent * e) { if (e->error_code == BadMatch) { xv_error = True; return (0); } else - return (X_handler (d, e)); + return (X_handler(d, e)); } SDL_Overlay * -X11_CreateYUVOverlay (_THIS, int width, int height, Uint32 format, - SDL_Surface * display) +X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, + SDL_Surface * display) { SDL_Overlay *overlay; struct private_yuvhwdata *hwdata; int xv_port; unsigned int i, j, k; unsigned int adaptors; - SDL_NAME (XvAdaptorInfo) * ainfo; + SDL_NAME(XvAdaptorInfo) * ainfo; int bpp; #ifndef NO_SHARED_MEMORY XShmSegmentInfo *yuvshm; @@ -113,11 +113,11 @@ /* Look for the XVideo extension with a valid port for this format */ xv_port = -1; if ((Success == - SDL_NAME (XvQueryExtension) (GFX_Display, &j, &j, &j, &j, &j)) + SDL_NAME(XvQueryExtension) (GFX_Display, &j, &j, &j, &j, &j)) && (Success == - SDL_NAME (XvQueryAdaptors) (GFX_Display, - RootWindow (GFX_Display, SDL_Screen), - &adaptors, &ainfo))) { + SDL_NAME(XvQueryAdaptors) (GFX_Display, + RootWindow(GFX_Display, SDL_Screen), + &adaptors, &ainfo))) { #ifdef USE_LAST_ADAPTOR for (i = 0; i < adaptors; ++i) #else @@ -125,7 +125,7 @@ #endif /* USE_LAST_ADAPTOR */ { /* Check to see if the visual can be used */ - if (BUGGY_XFREE86 (<=, 4001)) { + if (BUGGY_XFREE86(<=, 4001)) { int visual_ok = 0; for (j = 0; j < ainfo[i].num_formats; ++j) { if (ainfo[i].formats[j].visual_id == SDL_Visual->visualid) { @@ -140,11 +140,11 @@ if ((ainfo[i].type & XvInputMask) && (ainfo[i].type & XvImageMask)) { int num_formats; - SDL_NAME (XvImageFormatValues) * formats; - formats = SDL_NAME (XvListImageFormats) (GFX_Display, - ainfo[i]. - base_id, - &num_formats); + SDL_NAME(XvImageFormatValues) * formats; + formats = SDL_NAME(XvListImageFormats) (GFX_Display, + ainfo[i]. + base_id, + &num_formats); #ifdef USE_LAST_ADAPTOR for (j = 0; j < num_formats; ++j) #else @@ -153,7 +153,7 @@ { if ((Uint32) formats[j].id == format) { for (k = 0; k < ainfo[i].num_ports; ++k) { - if (Success == SDL_NAME (XvGrabPort) + if (Success == SDL_NAME(XvGrabPort) (GFX_Display, ainfo[i].base_id + k, CurrentTime)) { xv_port = ainfo[i].base_id + k; @@ -163,11 +163,11 @@ } } if (formats) { - XFree (formats); + XFree(formats); } } } - SDL_NAME (XvFreeAdaptorInfo) (ainfo); + SDL_NAME(XvFreeAdaptorInfo) (ainfo); } /* Precalculate the bpp for the pitch workaround below */ @@ -196,15 +196,15 @@ */ for (i = 0; i < adaptors; ++i) { if (ainfo[i].name != NULL) - Xfree (ainfo[i].name); + Xfree(ainfo[i].name); if (ainfo[i].formats != NULL) - Xfree (ainfo[i].formats); + Xfree(ainfo[i].formats); } - Xfree (ainfo); + Xfree(ainfo); #endif if (xv_port == -1) { - SDL_SetError ("No available video ports for requested format"); + SDL_SetError("No available video ports for requested format"); return (NULL); } @@ -214,33 +214,33 @@ { "XV_AUTOPAINT_COLORKEY", "XV_AUTOPAINT_COLOURKEY" }; unsigned int i; - SDL_NAME (XvSelectPortNotify) (GFX_Display, xv_port, True); - X_handler = XSetErrorHandler (xv_errhandler); - for (i = 0; i < sizeof (attr) / (sizeof attr[0]); ++i) { + SDL_NAME(XvSelectPortNotify) (GFX_Display, xv_port, True); + X_handler = XSetErrorHandler(xv_errhandler); + for (i = 0; i < sizeof(attr) / (sizeof attr[0]); ++i) { Atom a; xv_error = False; - a = XInternAtom (GFX_Display, attr[i], True); + a = XInternAtom(GFX_Display, attr[i], True); if (a != None) { - SDL_NAME (XvSetPortAttribute) (GFX_Display, xv_port, a, 1); - XSync (GFX_Display, True); + SDL_NAME(XvSetPortAttribute) (GFX_Display, xv_port, a, 1); + XSync(GFX_Display, True); if (!xv_error) { break; } } } - XSetErrorHandler (X_handler); - SDL_NAME (XvSelectPortNotify) (GFX_Display, xv_port, False); + XSetErrorHandler(X_handler); + SDL_NAME(XvSelectPortNotify) (GFX_Display, xv_port, False); } /* Create the overlay structure */ - overlay = (SDL_Overlay *) SDL_malloc (sizeof *overlay); + overlay = (SDL_Overlay *) SDL_malloc(sizeof *overlay); if (overlay == NULL) { - SDL_NAME (XvUngrabPort) (GFX_Display, xv_port, CurrentTime); - SDL_OutOfMemory (); + SDL_NAME(XvUngrabPort) (GFX_Display, xv_port, CurrentTime); + SDL_OutOfMemory(); return (NULL); } - SDL_memset (overlay, 0, (sizeof *overlay)); + SDL_memset(overlay, 0, (sizeof *overlay)); /* Fill in the basic members */ overlay->format = format; @@ -252,54 +252,54 @@ overlay->hw_overlay = 1; /* Create the pixel data and lookup tables */ - hwdata = (struct private_yuvhwdata *) SDL_malloc (sizeof *hwdata); + hwdata = (struct private_yuvhwdata *) SDL_malloc(sizeof *hwdata); overlay->hwdata = hwdata; if (hwdata == NULL) { - SDL_NAME (XvUngrabPort) (GFX_Display, xv_port, CurrentTime); - SDL_OutOfMemory (); - SDL_FreeYUVOverlay (overlay); + SDL_NAME(XvUngrabPort) (GFX_Display, xv_port, CurrentTime); + SDL_OutOfMemory(); + SDL_FreeYUVOverlay(overlay); return (NULL); } hwdata->port = xv_port; #ifndef NO_SHARED_MEMORY yuvshm = &hwdata->yuvshm; - SDL_memset (yuvshm, 0, sizeof (*yuvshm)); - hwdata->image = SDL_NAME (XvShmCreateImage) (GFX_Display, xv_port, format, - 0, width, height, yuvshm); + SDL_memset(yuvshm, 0, sizeof(*yuvshm)); + hwdata->image = SDL_NAME(XvShmCreateImage) (GFX_Display, xv_port, format, + 0, width, height, yuvshm); #ifdef PITCH_WORKAROUND if (hwdata->image != NULL && hwdata->image->pitches[0] != (width * bpp)) { /* Ajust overlay width according to pitch */ - XFree (hwdata->image); + XFree(hwdata->image); width = hwdata->image->pitches[0] / bpp; hwdata->image = - SDL_NAME (XvShmCreateImage) (GFX_Display, xv_port, format, 0, - width, height, yuvshm); + SDL_NAME(XvShmCreateImage) (GFX_Display, xv_port, format, 0, + width, height, yuvshm); } #endif /* PITCH_WORKAROUND */ hwdata->yuv_use_mitshm = (hwdata->image != NULL); if (hwdata->yuv_use_mitshm) { - yuvshm->shmid = shmget (IPC_PRIVATE, hwdata->image->data_size, - IPC_CREAT | 0777); + yuvshm->shmid = shmget(IPC_PRIVATE, hwdata->image->data_size, + IPC_CREAT | 0777); if (yuvshm->shmid >= 0) { - yuvshm->shmaddr = (char *) shmat (yuvshm->shmid, 0, 0); + yuvshm->shmaddr = (char *) shmat(yuvshm->shmid, 0, 0); yuvshm->readOnly = False; if (yuvshm->shmaddr != (char *) -1) { shm_error = False; - X_handler = XSetErrorHandler (shm_errhandler); - XShmAttach (GFX_Display, yuvshm); - XSync (GFX_Display, True); - XSetErrorHandler (X_handler); + X_handler = XSetErrorHandler(shm_errhandler); + XShmAttach(GFX_Display, yuvshm); + XSync(GFX_Display, True); + XSetErrorHandler(X_handler); if (shm_error) - shmdt (yuvshm->shmaddr); + shmdt(yuvshm->shmaddr); } else { shm_error = True; } - shmctl (yuvshm->shmid, IPC_RMID, NULL); + shmctl(yuvshm->shmid, IPC_RMID, NULL); } else { shm_error = True; } if (shm_error) { - XFree (hwdata->image); + XFree(hwdata->image); hwdata->yuv_use_mitshm = 0; } else { hwdata->image->data = yuvshm->shmaddr; @@ -309,29 +309,29 @@ #endif /* NO_SHARED_MEMORY */ { hwdata->image = - SDL_NAME (XvCreateImage) (GFX_Display, xv_port, format, 0, - width, height); + SDL_NAME(XvCreateImage) (GFX_Display, xv_port, format, 0, + width, height); #ifdef PITCH_WORKAROUND if (hwdata->image != NULL && hwdata->image->pitches[0] != (width * bpp)) { /* Ajust overlay width according to pitch */ - XFree (hwdata->image); + XFree(hwdata->image); width = hwdata->image->pitches[0] / bpp; hwdata->image = - SDL_NAME (XvCreateImage) (GFX_Display, xv_port, format, 0, - width, height); + SDL_NAME(XvCreateImage) (GFX_Display, xv_port, format, 0, + width, height); } #endif /* PITCH_WORKAROUND */ if (hwdata->image == NULL) { - SDL_SetError ("Couldn't create XVideo image"); - SDL_FreeYUVOverlay (overlay); + SDL_SetError("Couldn't create XVideo image"); + SDL_FreeYUVOverlay(overlay); return (NULL); } - hwdata->image->data = SDL_malloc (hwdata->image->data_size); + hwdata->image->data = SDL_malloc(hwdata->image->data_size); if (hwdata->image->data == NULL) { - SDL_OutOfMemory (); - SDL_FreeYUVOverlay (overlay); + SDL_OutOfMemory(); + SDL_FreeYUVOverlay(overlay); return (NULL); } } @@ -339,12 +339,12 @@ /* Find the pitch and offset values for the overlay */ overlay->planes = hwdata->image->num_planes; overlay->pitches = - (Uint16 *) SDL_malloc (overlay->planes * sizeof (Uint16)); + (Uint16 *) SDL_malloc(overlay->planes * sizeof(Uint16)); overlay->pixels = - (Uint8 **) SDL_malloc (overlay->planes * sizeof (Uint8 *)); + (Uint8 **) SDL_malloc(overlay->planes * sizeof(Uint8 *)); if (!overlay->pitches || !overlay->pixels) { - SDL_OutOfMemory (); - SDL_FreeYUVOverlay (overlay); + SDL_OutOfMemory(); + SDL_FreeYUVOverlay(overlay); return (NULL); } for (i = 0; i < overlay->planes; ++i) { @@ -358,7 +358,7 @@ We can't perform normal updates in windows that have video being output to them. See SDL_x11image.c for more details. */ - X11_DisableAutoRefresh (this); + X11_DisableAutoRefresh(this); #endif /* We're all done.. */ @@ -366,20 +366,20 @@ } int -X11_LockYUVOverlay (_THIS, SDL_Overlay * overlay) +X11_LockYUVOverlay(_THIS, SDL_Overlay * overlay) { return (0); } void -X11_UnlockYUVOverlay (_THIS, SDL_Overlay * overlay) +X11_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay) { return; } int -X11_DisplayYUVOverlay (_THIS, SDL_Overlay * overlay, SDL_Rect * src, - SDL_Rect * dst) +X11_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, SDL_Rect * src, + SDL_Rect * dst) { struct private_yuvhwdata *hwdata; @@ -387,51 +387,50 @@ #ifndef NO_SHARED_MEMORY if (hwdata->yuv_use_mitshm) { - SDL_NAME (XvShmPutImage) (GFX_Display, hwdata->port, SDL_Window, - SDL_GC, hwdata->image, src->x, src->y, - src->w, src->h, dst->x, dst->y, dst->w, - dst->h, False); + SDL_NAME(XvShmPutImage) (GFX_Display, hwdata->port, SDL_Window, + SDL_GC, hwdata->image, src->x, src->y, + src->w, src->h, dst->x, dst->y, dst->w, + dst->h, False); } else #endif { - SDL_NAME (XvPutImage) (GFX_Display, hwdata->port, SDL_Window, - SDL_GC, hwdata->image, src->x, src->y, - src->w, src->h, dst->x, dst->y, dst->w, - dst->h); + SDL_NAME(XvPutImage) (GFX_Display, hwdata->port, SDL_Window, + SDL_GC, hwdata->image, src->x, src->y, + src->w, src->h, dst->x, dst->y, dst->w, dst->h); } - XSync (GFX_Display, False); + XSync(GFX_Display, False); return (0); } void -X11_FreeYUVOverlay (_THIS, SDL_Overlay * overlay) +X11_FreeYUVOverlay(_THIS, SDL_Overlay * overlay) { struct private_yuvhwdata *hwdata; hwdata = overlay->hwdata; if (hwdata) { - SDL_NAME (XvUngrabPort) (GFX_Display, hwdata->port, CurrentTime); + SDL_NAME(XvUngrabPort) (GFX_Display, hwdata->port, CurrentTime); #ifndef NO_SHARED_MEMORY if (hwdata->yuv_use_mitshm) { - XShmDetach (GFX_Display, &hwdata->yuvshm); - shmdt (hwdata->yuvshm.shmaddr); + XShmDetach(GFX_Display, &hwdata->yuvshm); + shmdt(hwdata->yuvshm.shmaddr); } #endif if (hwdata->image) { - XFree (hwdata->image); + XFree(hwdata->image); } - SDL_free (hwdata); + SDL_free(hwdata); } if (overlay->pitches) { - SDL_free (overlay->pitches); + SDL_free(overlay->pitches); overlay->pitches = NULL; } if (overlay->pixels) { - SDL_free (overlay->pixels); + SDL_free(overlay->pixels); overlay->pixels = NULL; } #ifdef XFREE86_REFRESH_HACK - X11_EnableAutoRefresh (this); + X11_EnableAutoRefresh(this); #endif } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/x11/SDL_x11yuv_c.h --- a/src/video/x11/SDL_x11yuv_c.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/x11/SDL_x11yuv_c.h Mon May 29 04:04:35 2006 +0000 @@ -28,18 +28,18 @@ #if SDL_VIDEO_DRIVER_X11_XV -extern SDL_Overlay *X11_CreateYUVOverlay (_THIS, int width, int height, - Uint32 format, - SDL_Surface * display); +extern SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, + Uint32 format, + SDL_Surface * display); -extern int X11_LockYUVOverlay (_THIS, SDL_Overlay * overlay); +extern int X11_LockYUVOverlay(_THIS, SDL_Overlay * overlay); -extern void X11_UnlockYUVOverlay (_THIS, SDL_Overlay * overlay); +extern void X11_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay); -extern int X11_DisplayYUVOverlay (_THIS, SDL_Overlay * overlay, - SDL_Rect * src, SDL_Rect * dst); +extern int X11_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, + SDL_Rect * src, SDL_Rect * dst); -extern void X11_FreeYUVOverlay (_THIS, SDL_Overlay * overlay); +extern void X11_FreeYUVOverlay(_THIS, SDL_Overlay * overlay); #endif /* SDL_VIDEO_DRIVER_X11_XV */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/xbios/SDL_xbios.c --- a/src/video/xbios/SDL_xbios.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/xbios/SDL_xbios.c Mon May 29 04:04:35 2006 +0000 @@ -65,27 +65,27 @@ #endif /* Initialization/Query functions */ -static int XBIOS_VideoInit (_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **XBIOS_ListModes (_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *XBIOS_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); -static int XBIOS_SetColors (_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void XBIOS_VideoQuit (_THIS); +static int XBIOS_VideoInit(_THIS, SDL_PixelFormat * vformat); +static SDL_Rect **XBIOS_ListModes(_THIS, SDL_PixelFormat * format, + Uint32 flags); +static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, + Uint32 flags); +static int XBIOS_SetColors(_THIS, int firstcolor, int ncolors, + SDL_Color * colors); +static void XBIOS_VideoQuit(_THIS); /* Hardware surface functions */ -static int XBIOS_AllocHWSurface (_THIS, SDL_Surface * surface); -static int XBIOS_LockHWSurface (_THIS, SDL_Surface * surface); -static int XBIOS_FlipHWSurface (_THIS, SDL_Surface * surface); -static void XBIOS_UnlockHWSurface (_THIS, SDL_Surface * surface); -static void XBIOS_FreeHWSurface (_THIS, SDL_Surface * surface); -static void XBIOS_UpdateRects (_THIS, int numrects, SDL_Rect * rects); +static int XBIOS_AllocHWSurface(_THIS, SDL_Surface * surface); +static int XBIOS_LockHWSurface(_THIS, SDL_Surface * surface); +static int XBIOS_FlipHWSurface(_THIS, SDL_Surface * surface); +static void XBIOS_UnlockHWSurface(_THIS, SDL_Surface * surface); +static void XBIOS_FreeHWSurface(_THIS, SDL_Surface * surface); +static void XBIOS_UpdateRects(_THIS, int numrects, SDL_Rect * rects); #if SDL_VIDEO_OPENGL /* OpenGL functions */ -static void XBIOS_GL_SwapBuffers (_THIS); +static void XBIOS_GL_SwapBuffers(_THIS); #endif /* To setup palette */ @@ -96,18 +96,18 @@ /* Xbios driver bootstrap functions */ static int -XBIOS_Available (void) +XBIOS_Available(void) { unsigned long cookie_vdo, cookie_mil, cookie_hade, cookie_scpn; /* Milan/Hades Atari clones do not have an Atari video chip */ - if ((Getcookie (C__MIL, &cookie_mil) == C_FOUND) || - (Getcookie (C_hade, &cookie_hade) == C_FOUND)) { + if ((Getcookie(C__MIL, &cookie_mil) == C_FOUND) || + (Getcookie(C_hade, &cookie_hade) == C_FOUND)) { return 0; } /* Cookie _VDO present ? if not, assume ST machine */ - if (Getcookie (C__VDO, &cookie_vdo) != C_FOUND) { + if (Getcookie(C__VDO, &cookie_vdo) != C_FOUND) { cookie_vdo = VDO_ST << 16; } @@ -115,18 +115,18 @@ switch (cookie_vdo >> 16) { case VDO_ST: case VDO_STE: - if (Getrez () == (ST_HIGH >> 8)) + if (Getrez() == (ST_HIGH >> 8)) return 0; break; case VDO_TT: - if ((EgetShift () & ES_MODE) == TT_HIGH) + if ((EgetShift() & ES_MODE) == TT_HIGH) return 0; break; case VDO_F30: - if (VgetMonitor () == MONITOR_MONO) + if (VgetMonitor() == MONITOR_MONO) return 0; - if (Getcookie (C_SCPN, &cookie_scpn) == C_FOUND) { - if (!SDL_XBIOS_SB3Usable ((scpn_cookie_t *) cookie_scpn)) { + if (Getcookie(C_SCPN, &cookie_scpn) == C_FOUND) { + if (!SDL_XBIOS_SB3Usable((scpn_cookie_t *) cookie_scpn)) { return 0; } } @@ -139,35 +139,35 @@ } static void -XBIOS_DeleteDevice (SDL_VideoDevice * device) +XBIOS_DeleteDevice(SDL_VideoDevice * device) { - SDL_free (device->hidden); - SDL_free (device); + SDL_free(device->hidden); + SDL_free(device); } static SDL_VideoDevice * -XBIOS_CreateDevice (int devindex) +XBIOS_CreateDevice(int devindex) { SDL_VideoDevice *device; /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); + device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); if (device) { - SDL_memset (device, 0, (sizeof *device)); + SDL_memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc ((sizeof *device->hidden)); + SDL_malloc((sizeof *device->hidden)); device->gl_data = (struct SDL_PrivateGLData *) - SDL_malloc ((sizeof *device->gl_data)); + SDL_malloc((sizeof *device->gl_data)); } if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory (); + SDL_OutOfMemory(); if (device) { - SDL_free (device); + SDL_free(device); } return (0); } - SDL_memset (device->hidden, 0, (sizeof *device->hidden)); - SDL_memset (device->gl_data, 0, sizeof (*device->gl_data)); + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + SDL_memset(device->gl_data, 0, sizeof(*device->gl_data)); /* Video functions */ device->VideoInit = XBIOS_VideoInit; @@ -206,8 +206,8 @@ }; void -SDL_XBIOS_AddMode (_THIS, Uint16 modecode, Uint16 width, Uint16 height, - Uint16 depth, SDL_bool flags) +SDL_XBIOS_AddMode(_THIS, Uint16 modecode, Uint16 width, Uint16 height, + Uint16 depth, SDL_bool flags) { int i, curpos; xbiosmode_t *current_mode; @@ -228,8 +228,8 @@ ++XBIOS_nummodes; XBIOS_modelist = - (xbiosmode_t *) SDL_realloc (XBIOS_modelist, - XBIOS_nummodes * sizeof (xbiosmode_t)); + (xbiosmode_t *) SDL_realloc(XBIOS_modelist, + XBIOS_nummodes * sizeof(xbiosmode_t)); /* Keep the list sorted: bpp, width, height */ curpos = 0; @@ -249,8 +249,8 @@ /* Push remaining modes further */ for (i = XBIOS_nummodes - 1; i > curpos; i--) { - SDL_memcpy (&XBIOS_modelist[i], &XBIOS_modelist[i - 1], - sizeof (xbiosmode_t)); + SDL_memcpy(&XBIOS_modelist[i], &XBIOS_modelist[i - 1], + sizeof(xbiosmode_t)); } XBIOS_modelist[curpos].number = modecode; @@ -261,24 +261,24 @@ } static int -XBIOS_VideoInit (_THIS, SDL_PixelFormat * vformat) +XBIOS_VideoInit(_THIS, SDL_PixelFormat * vformat) { int i, j8, j16; xbiosmode_t *current_mode; unsigned long cookie_blow, cookie_scpn, cookie_cnts; /* Initialize all variables that we clean on shutdown */ - memset (SDL_modelist, 0, sizeof (SDL_modelist)); + memset(SDL_modelist, 0, sizeof(SDL_modelist)); /* Cookie _VDO present ? if not, assume ST machine */ - if (Getcookie (C__VDO, &XBIOS_cvdo) != C_FOUND) { + if (Getcookie(C__VDO, &XBIOS_cvdo) != C_FOUND) { XBIOS_cvdo = VDO_ST << 16; } /* Allocate memory for old palette */ - XBIOS_oldpalette = (void *) SDL_malloc (256 * sizeof (long)); + XBIOS_oldpalette = (void *) SDL_malloc(256 * sizeof(long)); if (!XBIOS_oldpalette) { - SDL_SetError ("Unable to allocate memory for old palette\n"); + SDL_SetError("Unable to allocate memory for old palette\n"); return (-1); } @@ -294,10 +294,10 @@ { short *oldpalette; - SDL_XBIOS_AddMode (this, ST_LOW >> 8, 320, 200, 4, SDL_FALSE); + SDL_XBIOS_AddMode(this, ST_LOW >> 8, 320, 200, 4, SDL_FALSE); - XBIOS_oldvbase = Physbase (); - XBIOS_oldvmode = Getrez (); + XBIOS_oldvbase = Physbase(); + XBIOS_oldvmode = Getrez(); switch (XBIOS_oldvmode << 8) { case ST_LOW: XBIOS_oldnumcol = 16; @@ -315,7 +315,7 @@ oldpalette = (short *) XBIOS_oldpalette; for (i = 0; i < XBIOS_oldnumcol; i++) { - *oldpalette++ = Setcolor (i, -1); + *oldpalette++ = Setcolor(i, -1); } vformat->BitsPerPixel = 8; @@ -323,12 +323,12 @@ break; case VDO_TT: - SDL_XBIOS_AddMode (this, TT_LOW, 320, 480, 8, SDL_FALSE); + SDL_XBIOS_AddMode(this, TT_LOW, 320, 480, 8, SDL_FALSE); /* Software double-lined mode */ - SDL_XBIOS_AddMode (this, TT_LOW, 320, 240, 8, SDL_TRUE); + SDL_XBIOS_AddMode(this, TT_LOW, 320, 240, 8, SDL_TRUE); - XBIOS_oldvbase = Logbase (); - XBIOS_oldvmode = EgetShift (); + XBIOS_oldvbase = Logbase(); + XBIOS_oldvmode = EgetShift(); switch (XBIOS_oldvmode & ES_MODE) { case TT_LOW: @@ -350,65 +350,65 @@ break; } if (XBIOS_oldnumcol) { - EgetPalette (0, XBIOS_oldnumcol, XBIOS_oldpalette); + EgetPalette(0, XBIOS_oldnumcol, XBIOS_oldpalette); } vformat->BitsPerPixel = 8; break; case VDO_F30: - switch (VgetMonitor ()) { + switch (VgetMonitor()) { case MONITOR_MONO: /* Not usable */ break; case MONITOR_RGB: case MONITOR_TV: - SDL_XBIOS_AddMode (this, BPS16 | COL80 | OVERSCAN | VERTFLAG, - 768, 480, 16, SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS16 | COL80 | OVERSCAN, 768, 240, - 16, SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS16 | COL80 | VERTFLAG, 640, 400, - 16, SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS16 | COL80, 640, 200, 16, SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS16 | OVERSCAN | VERTFLAG, 384, - 480, 16, SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS16 | OVERSCAN, 384, 240, 16, - SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS16 | VERTFLAG, 320, 400, 16, - SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS16, 320, 200, 16, SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS8 | COL80 | OVERSCAN | VERTFLAG, - 768, 480, 8, SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS8 | COL80 | OVERSCAN, 768, 240, 8, - SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS8 | COL80 | VERTFLAG, 640, 400, 8, - SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS8 | COL80, 640, 200, 8, SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS8 | OVERSCAN | VERTFLAG, 384, 480, - 8, SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS8 | OVERSCAN, 384, 240, 8, SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS8 | VERTFLAG, 320, 400, 8, SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS8, 320, 200, 8, SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS16 | COL80 | OVERSCAN | VERTFLAG, + 768, 480, 16, SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS16 | COL80 | OVERSCAN, 768, 240, + 16, SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS16 | COL80 | VERTFLAG, 640, 400, + 16, SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS16 | COL80, 640, 200, 16, SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS16 | OVERSCAN | VERTFLAG, 384, + 480, 16, SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS16 | OVERSCAN, 384, 240, 16, + SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS16 | VERTFLAG, 320, 400, 16, + SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS16, 320, 200, 16, SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS8 | COL80 | OVERSCAN | VERTFLAG, + 768, 480, 8, SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS8 | COL80 | OVERSCAN, 768, 240, 8, + SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS8 | COL80 | VERTFLAG, 640, 400, 8, + SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS8 | COL80, 640, 200, 8, SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS8 | OVERSCAN | VERTFLAG, 384, 480, + 8, SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS8 | OVERSCAN, 384, 240, 8, SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS8 | VERTFLAG, 320, 400, 8, SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS8, 320, 200, 8, SDL_FALSE); break; case MONITOR_VGA: - SDL_XBIOS_AddMode (this, BPS16, 320, 480, 16, SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS16 | VERTFLAG, 320, 240, 16, - SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS8 | COL80, 640, 480, 8, SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS8 | COL80 | VERTFLAG, 640, 240, 8, - SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS8, 320, 480, 8, SDL_FALSE); - SDL_XBIOS_AddMode (this, BPS8 | VERTFLAG, 320, 240, 8, SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS16, 320, 480, 16, SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS16 | VERTFLAG, 320, 240, 16, + SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS8 | COL80, 640, 480, 8, SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS8 | COL80 | VERTFLAG, 640, 240, 8, + SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS8, 320, 480, 8, SDL_FALSE); + SDL_XBIOS_AddMode(this, BPS8 | VERTFLAG, 320, 240, 8, SDL_FALSE); break; } - XBIOS_oldvbase = Logbase (); - XBIOS_oldvmode = VsetMode (-1); + XBIOS_oldvbase = Logbase(); + XBIOS_oldvmode = VsetMode(-1); XBIOS_oldnumcol = 1 << (1 << (XBIOS_oldvmode & NUMCOLS)); if (XBIOS_oldnumcol > 256) { XBIOS_oldnumcol = 0; } if (XBIOS_oldnumcol) { - VgetRGB (0, XBIOS_oldnumcol, XBIOS_oldpalette); + VgetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette); } vformat->BitsPerPixel = 16; @@ -427,12 +427,12 @@ } /* Initialize BlowUp/SB3/Centscreen stuff if present */ - if (Getcookie (C_BLOW, &cookie_blow) == C_FOUND) { - SDL_XBIOS_BlowupInit (this, (blow_cookie_t *) cookie_blow); - } else if (Getcookie (C_SCPN, &cookie_scpn) == C_FOUND) { - SDL_XBIOS_SB3Init (this, (scpn_cookie_t *) cookie_scpn); - } else if (Getcookie (C_CNTS, &cookie_cnts) == C_FOUND) { - XBIOS_oldvmode = SDL_XBIOS_CentscreenInit (this); + if (Getcookie(C_BLOW, &cookie_blow) == C_FOUND) { + SDL_XBIOS_BlowupInit(this, (blow_cookie_t *) cookie_blow); + } else if (Getcookie(C_SCPN, &cookie_scpn) == C_FOUND) { + SDL_XBIOS_SB3Init(this, (scpn_cookie_t *) cookie_scpn); + } else if (Getcookie(C_CNTS, &cookie_cnts) == C_FOUND) { + XBIOS_oldvmode = SDL_XBIOS_CentscreenInit(this); XBIOS_centscreen = SDL_TRUE; } @@ -452,7 +452,7 @@ switch (current_mode->depth) { case 4: case 8: - SDL_modelist[0][j8] = SDL_malloc (sizeof (SDL_Rect)); + SDL_modelist[0][j8] = SDL_malloc(sizeof(SDL_Rect)); SDL_modelist[0][j8]->x = SDL_modelist[0][j8]->y = 0; SDL_modelist[0][j8]->w = current_mode->width; SDL_modelist[0][j8]->h = current_mode->height; @@ -460,7 +460,7 @@ j8++; break; case 16: - SDL_modelist[1][j16] = SDL_malloc (sizeof (SDL_Rect)); + SDL_modelist[1][j16] = SDL_malloc(sizeof(SDL_Rect)); SDL_modelist[1][j16]->x = SDL_modelist[1][j16]->y = 0; SDL_modelist[1][j16]->w = current_mode->width; SDL_modelist[1][j16]->h = current_mode->height; @@ -478,13 +478,13 @@ /* Update hardware info */ this->info.hw_available = 1; - this->info.video_mem = (Uint32) Atari_SysMalloc (-1L, MX_STRAM); + this->info.video_mem = (Uint32) Atari_SysMalloc(-1L, MX_STRAM); /* Init chunky to planar routine */ SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8; #if SDL_VIDEO_OPENGL - SDL_AtariGL_InitPointers (this); + SDL_AtariGL_InitPointers(this); #endif /* We're done! */ @@ -492,7 +492,7 @@ } static SDL_Rect ** -XBIOS_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) +XBIOS_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) { /* 8 bits -> list 0 */ /* 16 bits -> list 1 */ @@ -504,26 +504,26 @@ } static void -XBIOS_FreeBuffers (_THIS) +XBIOS_FreeBuffers(_THIS) { int i; for (i = 0; i < 2; i++) { if (XBIOS_screensmem[i] != NULL) { - Mfree (XBIOS_screensmem[i]); + Mfree(XBIOS_screensmem[i]); XBIOS_screensmem[i] = NULL; } } if (XBIOS_shadowscreen != NULL) { - Mfree (XBIOS_shadowscreen); + Mfree(XBIOS_shadowscreen); XBIOS_shadowscreen = NULL; } } static SDL_Surface * -XBIOS_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +XBIOS_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { int mode, new_depth; int i; @@ -532,7 +532,7 @@ Uint32 modeflags; /* Free current buffers */ - XBIOS_FreeBuffers (this); + XBIOS_FreeBuffers(this); /* Limit bpp */ if (bpp > 16) { @@ -549,7 +549,7 @@ } } if (SDL_modelist[bpp][mode] == NULL) { - SDL_SetError ("Couldn't find requested mode in list"); + SDL_SetError("Couldn't find requested mode in list"); return (NULL); } @@ -573,14 +573,14 @@ new_screen_size += 256; /* To align on a 256 byte adress */ if (new_depth == 8) { - XBIOS_shadowscreen = Atari_SysMalloc (new_screen_size, MX_PREFTTRAM); + XBIOS_shadowscreen = Atari_SysMalloc(new_screen_size, MX_PREFTTRAM); if (XBIOS_shadowscreen == NULL) { - SDL_SetError ("Can not allocate %d KB for shadow buffer", - new_screen_size >> 10); + SDL_SetError("Can not allocate %d KB for shadow buffer", + new_screen_size >> 10); return (NULL); } - SDL_memset (XBIOS_shadowscreen, 0, new_screen_size); + SDL_memset(XBIOS_shadowscreen, 0, new_screen_size); } /* Output buffer needs to be twice in size for the software double-line mode */ @@ -590,15 +590,15 @@ XBIOS_doubleline = SDL_TRUE; } - XBIOS_screensmem[0] = Atari_SysMalloc (new_screen_size, MX_STRAM); + XBIOS_screensmem[0] = Atari_SysMalloc(new_screen_size, MX_STRAM); if (XBIOS_screensmem[0] == NULL) { - XBIOS_FreeBuffers (this); - SDL_SetError ("Can not allocate %d KB for frame buffer", - new_screen_size >> 10); + XBIOS_FreeBuffers(this); + SDL_SetError("Can not allocate %d KB for frame buffer", + new_screen_size >> 10); return (NULL); } - SDL_memset (XBIOS_screensmem[0], 0, new_screen_size); + SDL_memset(XBIOS_screensmem[0], 0, new_screen_size); XBIOS_screens[0] = (void *) (((long) XBIOS_screensmem[0] + 256) & 0xFFFFFF00UL); @@ -613,15 +613,15 @@ /* Double buffer ? */ if (flags & SDL_DOUBLEBUF) { - XBIOS_screensmem[1] = Atari_SysMalloc (new_screen_size, MX_STRAM); + XBIOS_screensmem[1] = Atari_SysMalloc(new_screen_size, MX_STRAM); if (XBIOS_screensmem[1] == NULL) { - XBIOS_FreeBuffers (this); - SDL_SetError ("Can not allocate %d KB for double buffer", - new_screen_size >> 10); + XBIOS_FreeBuffers(this); + SDL_SetError("Can not allocate %d KB for double buffer", + new_screen_size >> 10); return (NULL); } - SDL_memset (XBIOS_screensmem[1], 0, new_screen_size); + SDL_memset(XBIOS_screensmem[1], 0, new_screen_size); XBIOS_screens[1] = (void *) (((long) XBIOS_screensmem[1] + 256) & 0xFFFFFF00UL); @@ -629,10 +629,9 @@ } /* Allocate the new pixel format for the screen */ - if (!SDL_ReallocFormat (current, new_depth, 0, 0, 0, 0)) { - XBIOS_FreeBuffers (this); - SDL_SetError - ("Couldn't allocate new pixel format for requested mode"); + if (!SDL_ReallocFormat(current, new_depth, 0, 0, 0, 0)) { + XBIOS_FreeBuffers(this); + SDL_SetError("Couldn't allocate new pixel format for requested mode"); return (NULL); } @@ -652,9 +651,9 @@ #if SDL_VIDEO_OPENGL if (flags & SDL_INTERNALOPENGL) { - if (!SDL_AtariGL_Init (this, current)) { - XBIOS_FreeBuffers (this); - SDL_SetError ("Can not create OpenGL context"); + if (!SDL_AtariGL_Init(this, current)) { + XBIOS_FreeBuffers(this); + SDL_SetError("Can not create OpenGL context"); return NULL; } @@ -666,13 +665,13 @@ /* Now set the video mode */ #ifndef DEBUG_VIDEO_XBIOS - Setscreen (-1, XBIOS_screens[0], -1); + Setscreen(-1, XBIOS_screens[0], -1); #endif switch (XBIOS_cvdo >> 16) { case VDO_ST: #ifndef DEBUG_VIDEO_XBIOS - Setscreen (-1, -1, new_video_mode->number); + Setscreen(-1, -1, new_video_mode->number); #endif /* Reset palette */ for (i = 0; i < 16; i++) { @@ -680,12 +679,12 @@ ((i >> 1) << 8) | (((i * 8) / 17) << 4) | (i >> 1); } #ifndef DEBUG_VIDEO_XBIOS - Setpalette (TT_palette); + Setpalette(TT_palette); #endif break; case VDO_STE: #ifndef DEBUG_VIDEO_XBIOS - Setscreen (-1, -1, new_video_mode->number); + Setscreen(-1, -1, new_video_mode->number); #endif /* Reset palette */ for (i = 0; i < 16; i++) { @@ -695,31 +694,31 @@ TT_palette[i] = (c << 8) | (c << 4) | c; } #ifndef DEBUG_VIDEO_XBIOS - Setpalette (TT_palette); + Setpalette(TT_palette); #endif break; case VDO_TT: #ifndef DEBUG_VIDEO_XBIOS - EsetShift (new_video_mode->number); + EsetShift(new_video_mode->number); #endif break; case VDO_F30: #ifndef DEBUG_VIDEO_XBIOS if (XBIOS_centscreen) { - SDL_XBIOS_CentscreenSetmode (this, width, height, new_depth); + SDL_XBIOS_CentscreenSetmode(this, width, height, new_depth); } else { - VsetMode (new_video_mode->number); + VsetMode(new_video_mode->number); } #endif /* Set hardware palette to black in True Colour */ if (new_depth == 16) { - SDL_memset (F30_palette, 0, sizeof (F30_palette)); - VsetRGB (0, 256, F30_palette); + SDL_memset(F30_palette, 0, sizeof(F30_palette)); + VsetRGB(0, 256, F30_palette); } break; } - Vsync (); + Vsync(); this->UpdateRects = XBIOS_UpdateRects; @@ -728,31 +727,31 @@ /* We don't actually allow hardware surfaces other than the main one */ static int -XBIOS_AllocHWSurface (_THIS, SDL_Surface * surface) +XBIOS_AllocHWSurface(_THIS, SDL_Surface * surface) { return (-1); } static void -XBIOS_FreeHWSurface (_THIS, SDL_Surface * surface) +XBIOS_FreeHWSurface(_THIS, SDL_Surface * surface) { return; } static int -XBIOS_LockHWSurface (_THIS, SDL_Surface * surface) +XBIOS_LockHWSurface(_THIS, SDL_Surface * surface) { return (0); } static void -XBIOS_UnlockHWSurface (_THIS, SDL_Surface * surface) +XBIOS_UnlockHWSurface(_THIS, SDL_Surface * surface) { return; } static void -XBIOS_UpdateRects (_THIS, int numrects, SDL_Rect * rects) +XBIOS_UpdateRects(_THIS, int numrects, SDL_Rect * rects) { SDL_Surface *surface; @@ -780,18 +779,18 @@ destination += x1; /* Convert chunky to planar screen */ - SDL_Atari_C2pConvert (source, - destination, - x2 - x1, - rects[i].h, - XBIOS_doubleline, - surface->pitch, XBIOS_pitch); + SDL_Atari_C2pConvert(source, + destination, + x2 - x1, + rects[i].h, + XBIOS_doubleline, + surface->pitch, XBIOS_pitch); } } #ifndef DEBUG_VIDEO_XBIOS - Setscreen (-1, XBIOS_screens[XBIOS_fbnum], -1); + Setscreen(-1, XBIOS_screens[XBIOS_fbnum], -1); #endif - Vsync (); + Vsync(); if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { XBIOS_fbnum ^= 1; @@ -802,7 +801,7 @@ } static int -XBIOS_FlipHWSurface (_THIS, SDL_Surface * surface) +XBIOS_FlipHWSurface(_THIS, SDL_Surface * surface) { if ((surface->format->BitsPerPixel) == 8) { void *destscr; @@ -816,16 +815,16 @@ destscr += destx; /* Convert chunky to planar screen */ - SDL_Atari_C2pConvert (surface->pixels, - destscr, - surface->w, - surface->h, - XBIOS_doubleline, surface->pitch, XBIOS_pitch); + SDL_Atari_C2pConvert(surface->pixels, + destscr, + surface->w, + surface->h, + XBIOS_doubleline, surface->pitch, XBIOS_pitch); } #ifndef DEBUG_VIDEO_XBIOS - Setscreen (-1, XBIOS_screens[XBIOS_fbnum], -1); + Setscreen(-1, XBIOS_screens[XBIOS_fbnum], -1); #endif - Vsync (); + Vsync(); if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { XBIOS_fbnum ^= 1; @@ -838,7 +837,7 @@ } static int -XBIOS_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +XBIOS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { int i; int r, v, b; @@ -854,7 +853,7 @@ TT_palette[firstcolor + i] = ((r * 30) + (v * 59) + (b * 11)) / 100; } - SDL_Atari_C2pConvert4_pal (TT_palette); /* convert the lighting */ + SDL_Atari_C2pConvert4_pal(TT_palette); /* convert the lighting */ break; case VDO_TT: for (i = 0; i < ncolors; i++) { @@ -865,7 +864,7 @@ TT_palette[i] = ((r >> 4) << 8) | ((v >> 4) << 4) | (b >> 4); } #ifndef DEBUG_VIDEO_XBIOS - EsetPalette (firstcolor, ncolors, TT_palette); + EsetPalette(firstcolor, ncolors, TT_palette); #endif break; case VDO_F30: @@ -877,7 +876,7 @@ F30_palette[i] = (r << 16) | (v << 8) | b; } #ifndef DEBUG_VIDEO_XBIOS - VsetRGB (firstcolor, ncolors, F30_palette); + VsetRGB(firstcolor, ncolors, F30_palette); #endif break; } @@ -889,69 +888,69 @@ another SDL video routine -- notably UpdateRects. */ static void -XBIOS_VideoQuit (_THIS) +XBIOS_VideoQuit(_THIS) { int i, j; - Atari_ShutdownEvents (); + Atari_ShutdownEvents(); /* Restore video mode and palette */ #ifndef DEBUG_VIDEO_XBIOS switch (XBIOS_cvdo >> 16) { case VDO_ST: case VDO_STE: - Setscreen (-1, XBIOS_oldvbase, XBIOS_oldvmode); + Setscreen(-1, XBIOS_oldvbase, XBIOS_oldvmode); if (XBIOS_oldnumcol) { - Setpalette (XBIOS_oldpalette); + Setpalette(XBIOS_oldpalette); } break; case VDO_TT: - Setscreen (-1, XBIOS_oldvbase, -1); - EsetShift (XBIOS_oldvmode); + Setscreen(-1, XBIOS_oldvbase, -1); + EsetShift(XBIOS_oldvmode); if (XBIOS_oldnumcol) { - EsetPalette (0, XBIOS_oldnumcol, XBIOS_oldpalette); + EsetPalette(0, XBIOS_oldnumcol, XBIOS_oldpalette); } break; case VDO_F30: - Setscreen (-1, XBIOS_oldvbase, -1); + Setscreen(-1, XBIOS_oldvbase, -1); if (XBIOS_centscreen) { - SDL_XBIOS_CentscreenRestore (this, XBIOS_oldvmode); + SDL_XBIOS_CentscreenRestore(this, XBIOS_oldvmode); } else { - VsetMode (XBIOS_oldvmode); + VsetMode(XBIOS_oldvmode); } if (XBIOS_oldnumcol) { - VsetRGB (0, XBIOS_oldnumcol, XBIOS_oldpalette); + VsetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette); } break; } - Vsync (); + Vsync(); #endif #if SDL_VIDEO_OPENGL if (gl_active) { - SDL_AtariGL_Quit (this, SDL_TRUE); + SDL_AtariGL_Quit(this, SDL_TRUE); } #endif if (XBIOS_oldpalette) { - SDL_free (XBIOS_oldpalette); + SDL_free(XBIOS_oldpalette); XBIOS_oldpalette = NULL; } - XBIOS_FreeBuffers (this); + XBIOS_FreeBuffers(this); /* Free mode list */ for (j = 0; j < NUM_MODELISTS; j++) { for (i = 0; i < SDL_NUMMODES; i++) { if (SDL_modelist[j][i] != NULL) { - SDL_free (SDL_modelist[j][i]); + SDL_free(SDL_modelist[j][i]); SDL_modelist[j][i] = NULL; } } } if (XBIOS_modelist) { - SDL_free (XBIOS_modelist); + SDL_free(XBIOS_modelist); XBIOS_nummodes = 0; XBIOS_modelist = NULL; } @@ -962,11 +961,11 @@ #if SDL_VIDEO_OPENGL static void -XBIOS_GL_SwapBuffers (_THIS) +XBIOS_GL_SwapBuffers(_THIS) { - SDL_AtariGL_SwapBuffers (this); - XBIOS_FlipHWSurface (this, this->screen); - SDL_AtariGL_MakeCurrent (this); + SDL_AtariGL_SwapBuffers(this); + XBIOS_FlipHWSurface(this, this->screen); + SDL_AtariGL_MakeCurrent(this); } #endif diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/xbios/SDL_xbios.h --- a/src/video/xbios/SDL_xbios.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/xbios/SDL_xbios.h Mon May 29 04:04:35 2006 +0000 @@ -128,8 +128,8 @@ /*--- Functions prototypes ---*/ -void SDL_XBIOS_AddMode (_THIS, Uint16 modecode, Uint16 width, Uint16 height, - Uint16 depth, SDL_bool flags); +void SDL_XBIOS_AddMode(_THIS, Uint16 modecode, Uint16 width, Uint16 height, + Uint16 depth, SDL_bool flags); #endif /* _SDL_xbios_h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/xbios/SDL_xbios_blowup.c --- a/src/video/xbios/SDL_xbios_blowup.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/xbios/SDL_xbios_blowup.c Mon May 29 04:04:35 2006 +0000 @@ -33,7 +33,7 @@ #include "SDL_xbios_blowup.h" void -SDL_XBIOS_BlowupInit (_THIS, blow_cookie_t * cookie_blow) +SDL_XBIOS_BlowupInit(_THIS, blow_cookie_t * cookie_blow) { int i, num_mode, bank; blow_mode_t *blow_mode; @@ -57,11 +57,11 @@ || ((blow_mode->monitor == MONITOR_RGB) && (cookie_blow->montype == MONITOR_TV))) { /* we can use this extended mode */ - SDL_XBIOS_AddMode (this, - num_mode == 3 ? BPS8 : BPS16, - blow_mode->width + 1, - blow_mode->height + 1, - num_mode == 3 ? 8 : 16, SDL_FALSE); + SDL_XBIOS_AddMode(this, + num_mode == 3 ? BPS8 : BPS16, + blow_mode->width + 1, + blow_mode->height + 1, + num_mode == 3 ? 8 : 16, SDL_FALSE); } } } diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/xbios/SDL_xbios_blowup.h --- a/src/video/xbios/SDL_xbios_blowup.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/xbios/SDL_xbios_blowup.h Mon May 29 04:04:35 2006 +0000 @@ -83,7 +83,7 @@ /*--- Functions prototypes ---*/ -void SDL_XBIOS_BlowupInit (_THIS, blow_cookie_t * cookie_blow); +void SDL_XBIOS_BlowupInit(_THIS, blow_cookie_t * cookie_blow); #endif /* _SDL_xbios_blowup_h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/xbios/SDL_xbios_centscreen.c --- a/src/video/xbios/SDL_xbios_centscreen.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/xbios/SDL_xbios_centscreen.c Mon May 29 04:04:35 2006 +0000 @@ -33,7 +33,7 @@ #include "SDL_xbios_centscreen.h" int -SDL_XBIOS_CentscreenInit (_THIS) +SDL_XBIOS_CentscreenInit(_THIS) { centscreen_mode_t curmode, listedmode; unsigned long result; @@ -41,44 +41,44 @@ /* Reset current mode list */ if (XBIOS_modelist) { - SDL_free (XBIOS_modelist); + SDL_free(XBIOS_modelist); XBIOS_nummodes = 0; XBIOS_modelist = NULL; } /* Add Centscreen modes */ - Vread (&curmode); + Vread(&curmode); cur_handle = curmode.handle; curmode.mode = curmode.physx = curmode.physy = curmode.plan = curmode.logx = curmode.logy = -1; - result = Vfirst (&curmode, &listedmode); + result = Vfirst(&curmode, &listedmode); if (result == 0) { while (result == 0) { /* Don't add modes with virtual screen */ if ((listedmode.mode & CSCREEN_VIRTUAL) == 0) { /* Don't add modes with bpp<8 */ if (listedmode.plan >= 8) { - SDL_XBIOS_AddMode (this, listedmode.mode, - listedmode.physx, - listedmode.physy, - listedmode.plan, SDL_FALSE); + SDL_XBIOS_AddMode(this, listedmode.mode, + listedmode.physx, + listedmode.physy, + listedmode.plan, SDL_FALSE); } } - SDL_memcpy (&curmode, &listedmode, sizeof (centscreen_mode_t)); + SDL_memcpy(&curmode, &listedmode, sizeof(centscreen_mode_t)); curmode.mode = curmode.physx = curmode.physy = curmode.plan = curmode.logx = curmode.logy = -1; - result = Vnext (&curmode, &listedmode); + result = Vnext(&curmode, &listedmode); } } else { - fprintf (stderr, "No suitable Centscreen modes\n"); + fprintf(stderr, "No suitable Centscreen modes\n"); } return cur_handle; } void -SDL_XBIOS_CentscreenSetmode (_THIS, int width, int height, int planes) +SDL_XBIOS_CentscreenSetmode(_THIS, int width, int height, int planes) { centscreen_mode_t newmode, curmode; @@ -86,16 +86,16 @@ newmode.physx = width; newmode.physy = height; newmode.plan = planes; - Vwrite (0, &newmode, &curmode); + Vwrite(0, &newmode, &curmode); /* Disable screensaver */ - Vread (&newmode); + Vread(&newmode); newmode.mode &= ~(CSCREEN_SAVER | CSCREEN_ENERGYSTAR); - Vwrite (0, &newmode, &curmode); + Vwrite(0, &newmode, &curmode); } void -SDL_XBIOS_CentscreenRestore (_THIS, int prev_handle) +SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle) { centscreen_mode_t newmode, curmode; @@ -103,7 +103,7 @@ newmode.handle = prev_handle; newmode.mode = newmode.physx = newmode.physy = newmode.plan = newmode.logx = newmode.logy = -1; - Vwrite (0, &newmode, &curmode); + Vwrite(0, &newmode, &curmode); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/xbios/SDL_xbios_centscreen.h --- a/src/video/xbios/SDL_xbios_centscreen.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/xbios/SDL_xbios_centscreen.h Mon May 29 04:04:35 2006 +0000 @@ -112,9 +112,9 @@ /*--- Functions prototypes ---*/ -int SDL_XBIOS_CentscreenInit (_THIS); -void SDL_XBIOS_CentscreenSetmode (_THIS, int width, int height, int planes); -void SDL_XBIOS_CentscreenRestore (_THIS, int prev_handle); +int SDL_XBIOS_CentscreenInit(_THIS); +void SDL_XBIOS_CentscreenSetmode(_THIS, int width, int height, int planes); +void SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle); #endif /* _SDL_xbios_centscreen_h */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/xbios/SDL_xbios_sb3.c --- a/src/video/xbios/SDL_xbios_sb3.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/xbios/SDL_xbios_sb3.c Mon May 29 04:04:35 2006 +0000 @@ -48,7 +48,7 @@ /*--- Functions ---*/ int -SDL_XBIOS_SB3Usable (scpn_cookie_t * cookie_scpn) +SDL_XBIOS_SB3Usable(scpn_cookie_t * cookie_scpn) { scpn_screeninfo_t *scrinfo; int bpp; @@ -65,13 +65,13 @@ } void -SDL_XBIOS_SB3Init (_THIS, scpn_cookie_t * cookie_scpn) +SDL_XBIOS_SB3Init(_THIS, scpn_cookie_t * cookie_scpn) { scpn_screeninfo_t *scrinfo; /* SB3 prevent changing video modes, we can only use current one */ if (XBIOS_modelist) { - SDL_free (XBIOS_modelist); + SDL_free(XBIOS_modelist); XBIOS_nummodes = 0; XBIOS_modelist = NULL; } @@ -79,11 +79,11 @@ scrinfo = cookie_scpn->screen_info; scrinfo->h_pos = scrinfo->v_pos = 0; - SDL_XBIOS_AddMode (this, - -1, - scrinfo->virtual_width, scrinfo->virtual_height, - 1 << (SDL_XBIOS_scpn_planes_device[scrinfo->device]), - SDL_FALSE); + SDL_XBIOS_AddMode(this, + -1, + scrinfo->virtual_width, scrinfo->virtual_height, + 1 << (SDL_XBIOS_scpn_planes_device[scrinfo->device]), + SDL_FALSE); } /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af src/video/xbios/SDL_xbios_sb3.h --- a/src/video/xbios/SDL_xbios_sb3.h Mon May 29 03:53:21 2006 +0000 +++ b/src/video/xbios/SDL_xbios_sb3.h Mon May 29 04:04:35 2006 +0000 @@ -77,9 +77,9 @@ /*--- Function prototypes ---*/ -int SDL_XBIOS_SB3Usable (scpn_cookie_t * cookie_scpn); +int SDL_XBIOS_SB3Usable(scpn_cookie_t * cookie_scpn); -void SDL_XBIOS_SB3Init (_THIS, scpn_cookie_t * cookie_scpn); +void SDL_XBIOS_SB3Init(_THIS, scpn_cookie_t * cookie_scpn); #endif /* _SDL_xbios_sb3_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff -r 1fddae038bc8 -r 4da1ee79c9af test/checkkeys.c --- a/test/checkkeys.c Mon May 29 03:53:21 2006 +0000 +++ b/test/checkkeys.c Mon May 29 04:04:35 2006 +0000 @@ -12,128 +12,128 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } static void -print_modifiers (void) +print_modifiers(void) { int mod; - printf (" modifiers:"); - mod = SDL_GetModState (); + printf(" modifiers:"); + mod = SDL_GetModState(); if (!mod) { - printf (" (none)"); + printf(" (none)"); return; } if (mod & KMOD_LSHIFT) - printf (" LSHIFT"); + printf(" LSHIFT"); if (mod & KMOD_RSHIFT) - printf (" RSHIFT"); + printf(" RSHIFT"); if (mod & KMOD_LCTRL) - printf (" LCTRL"); + printf(" LCTRL"); if (mod & KMOD_RCTRL) - printf (" RCTRL"); + printf(" RCTRL"); if (mod & KMOD_LALT) - printf (" LALT"); + printf(" LALT"); if (mod & KMOD_RALT) - printf (" RALT"); + printf(" RALT"); if (mod & KMOD_LMETA) - printf (" LMETA"); + printf(" LMETA"); if (mod & KMOD_RMETA) - printf (" RMETA"); + printf(" RMETA"); if (mod & KMOD_NUM) - printf (" NUM"); + printf(" NUM"); if (mod & KMOD_CAPS) - printf (" CAPS"); + printf(" CAPS"); if (mod & KMOD_MODE) - printf (" MODE"); + printf(" MODE"); } static void -PrintKey (SDL_keysym * sym, int pressed) +PrintKey(SDL_keysym * sym, int pressed) { /* Print the keycode, name and state */ if (sym->sym) { - printf ("Key %s: %d-%s ", pressed ? "pressed" : "released", - sym->sym, SDL_GetKeyName (sym->sym)); + printf("Key %s: %d-%s ", pressed ? "pressed" : "released", + sym->sym, SDL_GetKeyName(sym->sym)); } else { - printf ("Unknown Key (scancode = %d) %s ", sym->scancode, - pressed ? "pressed" : "released"); + printf("Unknown Key (scancode = %d) %s ", sym->scancode, + pressed ? "pressed" : "released"); } /* Print the translated character, if one exists */ if (sym->unicode) { /* Is it a control-character? */ if (sym->unicode < ' ') { - printf (" (^%c)", sym->unicode + '@'); + printf(" (^%c)", sym->unicode + '@'); } else { #ifdef UNICODE - printf (" (%c)", sym->unicode); + printf(" (%c)", sym->unicode); #else /* This is a Latin-1 program, so only show 8-bits */ if (!(sym->unicode & 0xFF00)) - printf (" (%c)", sym->unicode); + printf(" (%c)", sym->unicode); else - printf (" (0x%X)", sym->unicode); + printf(" (0x%X)", sym->unicode); #endif } } - print_modifiers (); - printf ("\n"); + print_modifiers(); + printf("\n"); } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SDL_Event event; int done; Uint32 videoflags; /* Initialize SDL */ - if (SDL_Init (SDL_INIT_VIDEO) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } videoflags = SDL_SWSURFACE; while (argc > 1) { --argc; - if (argv[argc] && !strcmp (argv[argc], "-fullscreen")) { + if (argv[argc] && !strcmp(argv[argc], "-fullscreen")) { videoflags |= SDL_FULLSCREEN; } else { - fprintf (stderr, "Usage: %s [-fullscreen]\n", argv[0]); - quit (1); + fprintf(stderr, "Usage: %s [-fullscreen]\n", argv[0]); + quit(1); } } /* Set 640x480 video mode */ - if (SDL_SetVideoMode (640, 480, 0, videoflags) == NULL) { - fprintf (stderr, "Couldn't set 640x480 video mode: %s\n", - SDL_GetError ()); - quit (2); + if (SDL_SetVideoMode(640, 480, 0, videoflags) == NULL) { + fprintf(stderr, "Couldn't set 640x480 video mode: %s\n", + SDL_GetError()); + quit(2); } /* Enable UNICODE translation for keyboard input */ - SDL_EnableUNICODE (1); + SDL_EnableUNICODE(1); /* Enable auto repeat for keyboard input */ - SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, - SDL_DEFAULT_REPEAT_INTERVAL); + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, + SDL_DEFAULT_REPEAT_INTERVAL); /* Watch keystrokes */ done = 0; while (!done) { /* Check for events */ - SDL_WaitEvent (&event); + SDL_WaitEvent(&event); switch (event.type) { case SDL_KEYDOWN: - PrintKey (&event.key.keysym, 1); + PrintKey(&event.key.keysym, 1); break; case SDL_KEYUP: - PrintKey (&event.key.keysym, 0); + PrintKey(&event.key.keysym, 0); break; case SDL_MOUSEBUTTONDOWN: /* Any button press quits the app... */ @@ -145,6 +145,6 @@ } } - SDL_Quit (); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/graywin.c --- a/test/graywin.c Mon May 29 03:53:21 2006 +0000 +++ b/test/graywin.c Mon May 29 04:04:35 2006 +0000 @@ -16,7 +16,7 @@ /* Draw a randomly sized and colored box centered about (X,Y) */ void -DrawBox (SDL_Surface * screen, int X, int Y, int width, int height) +DrawBox(SDL_Surface * screen, int X, int Y, int width, int height) { static unsigned int seeded = 0; SDL_Rect area; @@ -25,34 +25,34 @@ /* Seed the random number generator */ if (seeded == 0) { - srand (time (NULL)); + srand(time(NULL)); seeded = 1; } /* Get the bounds of the rectangle */ - area.w = (rand () % width); - area.h = (rand () % height); + area.w = (rand() % width); + area.h = (rand() % height); area.x = X - (area.w / 2); area.y = Y - (area.h / 2); - randc = (rand () % NUM_COLORS); + randc = (rand() % NUM_COLORS); if (screen->format->BytesPerPixel == 1) { color = randc; } else { - color = SDL_MapRGB (screen->format, randc, randc, randc); + color = SDL_MapRGB(screen->format, randc, randc, randc); } /* Do it! */ - SDL_FillRect (screen, &area, color); + SDL_FillRect(screen, &area, color); if (screen->flags & SDL_DOUBLEBUF) { - SDL_Flip (screen); + SDL_Flip(screen); } else { - SDL_UpdateRects (screen, 1, &area); + SDL_UpdateRects(screen, 1, &area); } } void -DrawBackground (SDL_Surface * screen) +DrawBackground(SDL_Surface * screen) { int i, j, k; Uint8 *buffer; @@ -64,24 +64,24 @@ /* Use two loops in case the surface is double-buffered (both sides) */ for (j = 0; j < 2; ++j) { - if (SDL_LockSurface (screen) < 0) { - fprintf (stderr, "Couldn't lock display surface: %s\n", - SDL_GetError ()); + if (SDL_LockSurface(screen) < 0) { + fprintf(stderr, "Couldn't lock display surface: %s\n", + SDL_GetError()); return; } buffer = (Uint8 *) screen->pixels; if (screen->format->BytesPerPixel != 2) { for (i = 0; i < screen->h; ++i) { - memset (buffer, (i * (NUM_COLORS - 1)) / screen->h, - screen->w * screen->format->BytesPerPixel); + memset(buffer, (i * (NUM_COLORS - 1)) / screen->h, + screen->w * screen->format->BytesPerPixel); buffer += screen->pitch; } } else { for (i = 0; i < screen->h; ++i) { gradient = ((i * (NUM_COLORS - 1)) / screen->h); color = - SDL_MapRGB (screen->format, gradient, gradient, gradient); + SDL_MapRGB(screen->format, gradient, gradient, gradient); buffer16 = (Uint16 *) buffer; for (k = 0; k < screen->w; k++) { *(buffer16 + k) = color; @@ -90,31 +90,31 @@ } } - SDL_UnlockSurface (screen); + SDL_UnlockSurface(screen); if (screen->flags & SDL_DOUBLEBUF) { - SDL_Flip (screen); + SDL_Flip(screen); } else { - SDL_UpdateRect (screen, 0, 0, 0, 0); + SDL_UpdateRect(screen, 0, 0, 0, 0); break; } } } SDL_Surface * -CreateScreen (Uint16 w, Uint16 h, Uint8 bpp, Uint32 flags) +CreateScreen(Uint16 w, Uint16 h, Uint8 bpp, Uint32 flags) { SDL_Surface *screen; int i; SDL_Color palette[NUM_COLORS]; /* Set the video mode */ - screen = SDL_SetVideoMode (w, h, bpp, flags); + screen = SDL_SetVideoMode(w, h, bpp, flags); if (screen == NULL) { - fprintf (stderr, "Couldn't set display mode: %s\n", SDL_GetError ()); + fprintf(stderr, "Couldn't set display mode: %s\n", SDL_GetError()); return (NULL); } - fprintf (stderr, "Screen is in %s mode\n", - (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed"); + fprintf(stderr, "Screen is in %s mode\n", + (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed"); if (bpp == 8) { /* Set a gray colormap, reverse order from white to black */ @@ -123,14 +123,14 @@ palette[i].g = (NUM_COLORS - 1) - i * (256 / NUM_COLORS); palette[i].b = (NUM_COLORS - 1) - i * (256 / NUM_COLORS); } - SDL_SetColors (screen, palette, 0, NUM_COLORS); + SDL_SetColors(screen, palette, 0, NUM_COLORS); } return (screen); } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SDL_Surface *screen; Uint32 videoflags; @@ -139,9 +139,9 @@ int width, height, bpp; /* Initialize SDL */ - if (SDL_Init (SDL_INIT_VIDEO) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); - exit (1); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + exit(1); } /* See if we try to get a hardware colormap */ @@ -151,50 +151,50 @@ videoflags = SDL_SWSURFACE; while (argc > 1) { --argc; - if (argv[argc - 1] && (strcmp (argv[argc - 1], "-width") == 0)) { - width = atoi (argv[argc]); + if (argv[argc - 1] && (strcmp(argv[argc - 1], "-width") == 0)) { + width = atoi(argv[argc]); --argc; } else if (argv[argc - 1] - && (strcmp (argv[argc - 1], "-height") == 0)) { - height = atoi (argv[argc]); + && (strcmp(argv[argc - 1], "-height") == 0)) { + height = atoi(argv[argc]); --argc; - } else if (argv[argc - 1] && (strcmp (argv[argc - 1], "-bpp") == 0)) { - bpp = atoi (argv[argc]); + } else if (argv[argc - 1] && (strcmp(argv[argc - 1], "-bpp") == 0)) { + bpp = atoi(argv[argc]); --argc; - } else if (argv[argc] && (strcmp (argv[argc], "-hw") == 0)) { + } else if (argv[argc] && (strcmp(argv[argc], "-hw") == 0)) { videoflags |= SDL_HWSURFACE; - } else if (argv[argc] && (strcmp (argv[argc], "-hwpalette") == 0)) { + } else if (argv[argc] && (strcmp(argv[argc], "-hwpalette") == 0)) { videoflags |= SDL_HWPALETTE; - } else if (argv[argc] && (strcmp (argv[argc], "-flip") == 0)) { + } else if (argv[argc] && (strcmp(argv[argc], "-flip") == 0)) { videoflags |= SDL_DOUBLEBUF; - } else if (argv[argc] && (strcmp (argv[argc], "-noframe") == 0)) { + } else if (argv[argc] && (strcmp(argv[argc], "-noframe") == 0)) { videoflags |= SDL_NOFRAME; - } else if (argv[argc] && (strcmp (argv[argc], "-resize") == 0)) { + } else if (argv[argc] && (strcmp(argv[argc], "-resize") == 0)) { videoflags |= SDL_RESIZABLE; - } else if (argv[argc] && (strcmp (argv[argc], "-fullscreen") == 0)) { + } else if (argv[argc] && (strcmp(argv[argc], "-fullscreen") == 0)) { videoflags |= SDL_FULLSCREEN; } else { - fprintf (stderr, - "Usage: %s [-width] [-height] [-bpp] [-hw] [-hwpalette] [-flip] [-noframe] [-fullscreen] [-resize]\n", - argv[0]); - exit (1); + fprintf(stderr, + "Usage: %s [-width] [-height] [-bpp] [-hw] [-hwpalette] [-flip] [-noframe] [-fullscreen] [-resize]\n", + argv[0]); + exit(1); } } /* Set a video mode */ - screen = CreateScreen (width, height, bpp, videoflags); + screen = CreateScreen(width, height, bpp, videoflags); if (screen == NULL) { - exit (2); + exit(2); } - DrawBackground (screen); + DrawBackground(screen); /* Wait for a keystroke */ done = 0; - while (!done && SDL_WaitEvent (&event)) { + while (!done && SDL_WaitEvent(&event)) { switch (event.type) { case SDL_MOUSEBUTTONDOWN: - DrawBox (screen, event.button.x, event.button.y, width, height); + DrawBox(screen, event.button.x, event.button.y, width, height); break; case SDL_KEYDOWN: /* Ignore ALT-TAB for windows */ @@ -204,20 +204,20 @@ } /* Center the mouse on */ if (event.key.keysym.sym == SDLK_SPACE) { - SDL_WarpMouse (width / 2, height / 2); + SDL_WarpMouse(width / 2, height / 2); break; } /* Toggle fullscreen mode on */ if (event.key.keysym.sym == SDLK_RETURN) { videoflags ^= SDL_FULLSCREEN; - screen = CreateScreen (screen->w, screen->h, - screen->format->BitsPerPixel, - videoflags); + screen = CreateScreen(screen->w, screen->h, + screen->format->BitsPerPixel, + videoflags); if (screen == NULL) { - fprintf (stderr, "Couldn't toggle fullscreen mode\n"); + fprintf(stderr, "Couldn't toggle fullscreen mode\n"); done = 1; } - DrawBackground (screen); + DrawBackground(screen); break; } /* Any other key quits the application... */ @@ -225,21 +225,21 @@ done = 1; break; case SDL_VIDEOEXPOSE: - DrawBackground (screen); + DrawBackground(screen); break; case SDL_VIDEORESIZE: - screen = CreateScreen (event.resize.w, event.resize.h, - screen->format->BitsPerPixel, videoflags); + screen = CreateScreen(event.resize.w, event.resize.h, + screen->format->BitsPerPixel, videoflags); if (screen == NULL) { - fprintf (stderr, "Couldn't resize video mode\n"); + fprintf(stderr, "Couldn't resize video mode\n"); done = 1; } - DrawBackground (screen); + DrawBackground(screen); break; default: break; } } - SDL_Quit (); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/loopwave.c --- a/test/loopwave.c Mon May 29 03:53:21 2006 +0000 +++ b/test/loopwave.c Mon May 29 04:04:35 2006 +0000 @@ -27,15 +27,15 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } void SDLCALL -fillerup (void *unused, Uint8 * stream, int len) +fillerup(void *unused, Uint8 * stream, int len) { Uint8 *waveptr; int waveleft; @@ -46,88 +46,87 @@ /* Go! */ while (waveleft <= len) { - SDL_MixAudio (stream, waveptr, waveleft, SDL_MIX_MAXVOLUME); + SDL_MixAudio(stream, waveptr, waveleft, SDL_MIX_MAXVOLUME); stream += waveleft; len -= waveleft; waveptr = wave.sound; waveleft = wave.soundlen; wave.soundpos = 0; } - SDL_MixAudio (stream, waveptr, len, SDL_MIX_MAXVOLUME); + SDL_MixAudio(stream, waveptr, len, SDL_MIX_MAXVOLUME); wave.soundpos += len; } static int done = 0; void -poked (int sig) +poked(int sig) { done = 1; } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { int i, n; /* Print available audio drivers */ - n = SDL_GetNumAudioDrivers (); + n = SDL_GetNumAudioDrivers(); if (n == 0) { - printf ("No built-in audio drivers\n"); + printf("No built-in audio drivers\n"); } else { - printf ("Built-in audio drivers:"); + printf("Built-in audio drivers:"); for (i = 0; i < n; ++i) { if (i > 0) { - printf (","); + printf(","); } - printf (" %s", SDL_GetAudioDriver (i)); + printf(" %s", SDL_GetAudioDriver(i)); } - printf ("\n"); + printf("\n"); } /* Load the SDL library */ - if (SDL_Init (SDL_INIT_AUDIO) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(SDL_INIT_AUDIO) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } if (argv[1] == NULL) { argv[1] = "sample.wav"; } /* Load the wave file into memory */ - if (SDL_LoadWAV (argv[1], - &wave.spec, &wave.sound, &wave.soundlen) == NULL) { - fprintf (stderr, "Couldn't load %s: %s\n", argv[1], SDL_GetError ()); - quit (1); + if (SDL_LoadWAV(argv[1], &wave.spec, &wave.sound, &wave.soundlen) == NULL) { + fprintf(stderr, "Couldn't load %s: %s\n", argv[1], SDL_GetError()); + quit(1); } wave.spec.callback = fillerup; #if HAVE_SIGNAL_H /* Set the signals */ #ifdef SIGHUP - signal (SIGHUP, poked); + signal(SIGHUP, poked); #endif - signal (SIGINT, poked); + signal(SIGINT, poked); #ifdef SIGQUIT - signal (SIGQUIT, poked); + signal(SIGQUIT, poked); #endif - signal (SIGTERM, poked); + signal(SIGTERM, poked); #endif /* HAVE_SIGNAL_H */ /* Initialize fillerup() variables */ - if (SDL_OpenAudio (&wave.spec, NULL) < 0) { - fprintf (stderr, "Couldn't open audio: %s\n", SDL_GetError ()); - SDL_FreeWAV (wave.sound); - quit (2); + if (SDL_OpenAudio(&wave.spec, NULL) < 0) { + fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); + SDL_FreeWAV(wave.sound); + quit(2); } - SDL_PauseAudio (0); + SDL_PauseAudio(0); /* Let the audio run */ - printf ("Using audio driver: %s\n", SDL_GetCurrentAudioDriver ()); - while (!done && (SDL_GetAudioStatus () == SDL_AUDIO_PLAYING)) - SDL_Delay (1000); + printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); + while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING)) + SDL_Delay(1000); /* Clean up on signal */ - SDL_CloseAudio (); - SDL_FreeWAV (wave.sound); - SDL_Quit (); + SDL_CloseAudio(); + SDL_FreeWAV(wave.sound); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testalpha.c --- a/test/testalpha.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testalpha.c Mon May 29 04:04:35 2006 +0000 @@ -14,15 +14,15 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } /* Fill the screen with a gradient */ static void -FillBackground (SDL_Surface * screen) +FillBackground(SDL_Surface * screen) { Uint8 *buffer; Uint16 *buffer16; @@ -31,24 +31,24 @@ int i, k; /* Set the surface pixels and refresh! */ - if (SDL_LockSurface (screen) < 0) { - fprintf (stderr, "Couldn't lock the display surface: %s\n", - SDL_GetError ()); - quit (2); + if (SDL_LockSurface(screen) < 0) { + fprintf(stderr, "Couldn't lock the display surface: %s\n", + SDL_GetError()); + quit(2); } buffer = (Uint8 *) screen->pixels; if (screen->format->BytesPerPixel != 2) { for (i = 0; i < screen->h; ++i) { - memset (buffer, (i * 255) / screen->h, - screen->w * screen->format->BytesPerPixel); + memset(buffer, (i * 255) / screen->h, + screen->w * screen->format->BytesPerPixel); buffer += screen->pitch; } } else { for (i = 0; i < screen->h; ++i) { gradient = ((i * 255) / screen->h); color = - (Uint16) SDL_MapRGB (screen->format, gradient, gradient, - gradient); + (Uint16) SDL_MapRGB(screen->format, gradient, gradient, + gradient); buffer16 = (Uint16 *) buffer; for (k = 0; k < screen->w; k++) { *(buffer16 + k) = color; @@ -57,13 +57,13 @@ } } - SDL_UnlockSurface (screen); - SDL_UpdateRect (screen, 0, 0, 0, 0); + SDL_UnlockSurface(screen); + SDL_UpdateRect(screen, 0, 0, 0, 0); } /* Create a "light" -- a yellowish surface with variable alpha */ SDL_Surface * -CreateLight (int radius) +CreateLight(int radius) { Uint8 trans, alphamask; int range, addition; @@ -79,19 +79,19 @@ /* Create a 16 (4/4/4/4) bpp square with a full 4-bit alpha channel */ /* Note: this isn't any faster than a 32 bit alpha surface */ alphamask = 0x0000000F; - light = SDL_CreateRGBSurface (SDL_SWSURFACE, 2 * radius, 2 * radius, 16, - 0x0000F000, 0x00000F00, 0x000000F0, - alphamask); + light = SDL_CreateRGBSurface(SDL_SWSURFACE, 2 * radius, 2 * radius, 16, + 0x0000F000, 0x00000F00, 0x000000F0, + alphamask); #else Uint32 *buf; /* Create a 32 (8/8/8/8) bpp square with a full 8-bit alpha channel */ alphamask = 0x000000FF; - light = SDL_CreateRGBSurface (SDL_SWSURFACE, 2 * radius, 2 * radius, 32, - 0xFF000000, 0x00FF0000, 0x0000FF00, - alphamask); + light = SDL_CreateRGBSurface(SDL_SWSURFACE, 2 * radius, 2 * radius, 32, + 0xFF000000, 0x00FF0000, 0x0000FF00, + alphamask); if (light == NULL) { - fprintf (stderr, "Couldn't create light: %s\n", SDL_GetError ()); + fprintf(stderr, "Couldn't create light: %s\n", SDL_GetError()); return (NULL); } #endif @@ -104,7 +104,7 @@ buf = (Uint32 *) light->pixels; #endif /* Get a tranparent pixel value - we'll add alpha later */ - pixel = SDL_MapRGBA (light->format, 0xFF, 0xDD, 0x88, 0); + pixel = SDL_MapRGBA(light->format, 0xFF, 0xDD, 0x88, 0); for (y = 0; y < light->h; ++y) { for (x = 0; x < light->w; ++x) { *buf++ = pixel; @@ -123,7 +123,7 @@ /* Slow distance formula (from center of light) */ xdist = x - (light->w / 2); ydist = y - (light->h / 2); - range = (int) sqrt (xdist * xdist + ydist * ydist); + range = (int) sqrt(xdist * xdist + ydist * ydist); /* Scale distance to range of transparency (0-255) */ if (range > radius) { @@ -146,7 +146,7 @@ buf += skip; /* Almost always 0, but just in case... */ } /* Enable RLE acceleration of this alpha surface */ - SDL_SetAlpha (light, SDL_SRCALPHA | SDL_RLEACCEL, 0); + SDL_SetAlpha(light, SDL_SRCALPHA | SDL_RLEACCEL, 0); /* We're done! */ return (light); @@ -156,7 +156,7 @@ static Uint32 flashtime = 0; void -FlashLight (SDL_Surface * screen, SDL_Surface * light, int x, int y) +FlashLight(SDL_Surface * screen, SDL_Surface * light, int x, int y) { SDL_Rect position; Uint32 ticks1; @@ -167,10 +167,10 @@ position.y = y - (light->h / 2); position.w = light->w; position.h = light->h; - ticks1 = SDL_GetTicks (); - SDL_BlitSurface (light, NULL, screen, &position); - ticks2 = SDL_GetTicks (); - SDL_UpdateRects (screen, 1, &position); + ticks1 = SDL_GetTicks(); + SDL_BlitSurface(light, NULL, screen, &position); + ticks2 = SDL_GetTicks(); + SDL_UpdateRects(screen, 1, &position); ++flashes; /* Update time spend doing alpha blitting */ @@ -185,48 +185,46 @@ static int alpha_vel; int -LoadSprite (SDL_Surface * screen, char *file) +LoadSprite(SDL_Surface * screen, char *file) { SDL_Surface *converted; /* Load the sprite image */ - sprite = SDL_LoadBMP (file); + sprite = SDL_LoadBMP(file); if (sprite == NULL) { - fprintf (stderr, "Couldn't load %s: %s", file, SDL_GetError ()); + fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError()); return (-1); } /* Set transparent pixel as the pixel at (0,0) */ if (sprite->format->palette) { - SDL_SetColorKey (sprite, SDL_SRCCOLORKEY, *(Uint8 *) sprite->pixels); + SDL_SetColorKey(sprite, SDL_SRCCOLORKEY, *(Uint8 *) sprite->pixels); } /* Convert sprite to video format */ - converted = SDL_DisplayFormat (sprite); - SDL_FreeSurface (sprite); + converted = SDL_DisplayFormat(sprite); + SDL_FreeSurface(sprite); if (converted == NULL) { - fprintf (stderr, "Couldn't convert background: %s\n", - SDL_GetError ()); + fprintf(stderr, "Couldn't convert background: %s\n", SDL_GetError()); return (-1); } sprite = converted; /* Create the background */ - backing = SDL_CreateRGBSurface (SDL_SWSURFACE, sprite->w, sprite->h, 8, - 0, 0, 0, 0); + backing = SDL_CreateRGBSurface(SDL_SWSURFACE, sprite->w, sprite->h, 8, + 0, 0, 0, 0); if (backing == NULL) { - fprintf (stderr, "Couldn't create background: %s\n", SDL_GetError ()); - SDL_FreeSurface (sprite); + fprintf(stderr, "Couldn't create background: %s\n", SDL_GetError()); + SDL_FreeSurface(sprite); return (-1); } /* Convert background to video format */ - converted = SDL_DisplayFormat (backing); - SDL_FreeSurface (backing); + converted = SDL_DisplayFormat(backing); + SDL_FreeSurface(backing); if (converted == NULL) { - fprintf (stderr, "Couldn't convert background: %s\n", - SDL_GetError ()); - SDL_FreeSurface (sprite); + fprintf(stderr, "Couldn't convert background: %s\n", SDL_GetError()); + SDL_FreeSurface(sprite); return (-1); } backing = converted; @@ -245,14 +243,14 @@ } void -AttractSprite (Uint16 x, Uint16 y) +AttractSprite(Uint16 x, Uint16 y) { x_vel = ((int) x - position.x) / 10; y_vel = ((int) y - position.y) / 10; } void -MoveSprite (SDL_Surface * screen, SDL_Surface * light) +MoveSprite(SDL_Surface * screen, SDL_Surface * light) { SDL_Rect updates[2]; int alpha; @@ -260,7 +258,7 @@ /* Erase the sprite if it was visible */ if (sprite_visible) { updates[0] = position; - SDL_BlitSurface (backing, NULL, screen, &updates[0]); + SDL_BlitSurface(backing, NULL, screen, &updates[0]); } else { updates[0].x = 0; updates[0].y = 0; @@ -275,8 +273,8 @@ if (light != NULL) { int x, y; - SDL_GetMouseState (&x, &y); - FlashLight (screen, light, x, y); + SDL_GetMouseState(&x, &y); + FlashLight(screen, light, x, y); } /* Move the sprite, bounce at the wall */ @@ -298,39 +296,39 @@ } else if ((alpha + alpha_vel) > 255) { alpha_vel = -alpha_vel; } - SDL_SetAlpha (sprite, SDL_SRCALPHA, (Uint8) (alpha + alpha_vel)); + SDL_SetAlpha(sprite, SDL_SRCALPHA, (Uint8) (alpha + alpha_vel)); /* Save the area behind the sprite */ updates[1] = position; - SDL_BlitSurface (screen, &updates[1], backing, NULL); + SDL_BlitSurface(screen, &updates[1], backing, NULL); /* Blit the sprite onto the screen */ updates[1] = position; - SDL_BlitSurface (sprite, NULL, screen, &updates[1]); + SDL_BlitSurface(sprite, NULL, screen, &updates[1]); /* Make it so! */ - SDL_UpdateRects (screen, 2, updates); + SDL_UpdateRects(screen, 2, updates); } void -WarpSprite (SDL_Surface * screen, int x, int y) +WarpSprite(SDL_Surface * screen, int x, int y) { SDL_Rect updates[2]; /* Erase, move, Draw, update */ updates[0] = position; - SDL_BlitSurface (backing, NULL, screen, &updates[0]); + SDL_BlitSurface(backing, NULL, screen, &updates[0]); position.x = x - sprite->w / 2; /* Center about X */ position.y = y - sprite->h / 2; /* Center about Y */ updates[1] = position; - SDL_BlitSurface (screen, &updates[1], backing, NULL); + SDL_BlitSurface(screen, &updates[1], backing, NULL); updates[1] = position; - SDL_BlitSurface (sprite, NULL, screen, &updates[1]); - SDL_UpdateRects (screen, 2, updates); + SDL_BlitSurface(sprite, NULL, screen, &updates[1]); + SDL_UpdateRects(screen, 2, updates); } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { const SDL_VideoInfo *info; SDL_Surface *screen; @@ -345,8 +343,8 @@ /* Initialize SDL */ - if (SDL_Init (SDL_INIT_VIDEO) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } @@ -359,85 +357,85 @@ w = 640; h = 480; #endif - info = SDL_GetVideoInfo (); + info = SDL_GetVideoInfo(); if (info->vfmt->BitsPerPixel > 8) { video_bpp = info->vfmt->BitsPerPixel; } else { video_bpp = 16; - fprintf (stderr, "forced 16 bpp mode\n"); + fprintf(stderr, "forced 16 bpp mode\n"); } videoflags = SDL_SWSURFACE; for (i = 1; argv[i]; ++i) { - if (strcmp (argv[i], "-bpp") == 0) { - video_bpp = atoi (argv[++i]); + if (strcmp(argv[i], "-bpp") == 0) { + video_bpp = atoi(argv[++i]); if (video_bpp <= 8) { video_bpp = 16; - fprintf (stderr, "forced 16 bpp mode\n"); + fprintf(stderr, "forced 16 bpp mode\n"); } - } else if (strcmp (argv[i], "-hw") == 0) { + } else if (strcmp(argv[i], "-hw") == 0) { videoflags |= SDL_HWSURFACE; - } else if (strcmp (argv[i], "-warp") == 0) { + } else if (strcmp(argv[i], "-warp") == 0) { videoflags |= SDL_HWPALETTE; - } else if (strcmp (argv[i], "-width") == 0 && argv[i + 1]) { - w = atoi (argv[++i]); - } else if (strcmp (argv[i], "-height") == 0 && argv[i + 1]) { - h = atoi (argv[++i]); - } else if (strcmp (argv[i], "-resize") == 0) { + } else if (strcmp(argv[i], "-width") == 0 && argv[i + 1]) { + w = atoi(argv[++i]); + } else if (strcmp(argv[i], "-height") == 0 && argv[i + 1]) { + h = atoi(argv[++i]); + } else if (strcmp(argv[i], "-resize") == 0) { videoflags |= SDL_RESIZABLE; - } else if (strcmp (argv[i], "-noframe") == 0) { + } else if (strcmp(argv[i], "-noframe") == 0) { videoflags |= SDL_NOFRAME; - } else if (strcmp (argv[i], "-fullscreen") == 0) { + } else if (strcmp(argv[i], "-fullscreen") == 0) { videoflags |= SDL_FULLSCREEN; } else { - fprintf (stderr, - "Usage: %s [-width N] [-height N] [-bpp N] [-warp] [-hw] [-fullscreen]\n", - argv[0]); - quit (1); + fprintf(stderr, + "Usage: %s [-width N] [-height N] [-bpp N] [-warp] [-hw] [-fullscreen]\n", + argv[0]); + quit(1); } } /* Set video mode */ - if ((screen = SDL_SetVideoMode (w, h, video_bpp, videoflags)) == NULL) { - fprintf (stderr, "Couldn't set %dx%dx%d video mode: %s\n", - w, h, video_bpp, SDL_GetError ()); - quit (2); + if ((screen = SDL_SetVideoMode(w, h, video_bpp, videoflags)) == NULL) { + fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n", + w, h, video_bpp, SDL_GetError()); + quit(2); } - FillBackground (screen); + FillBackground(screen); /* Create the light */ - light = CreateLight (82); + light = CreateLight(82); if (light == NULL) { - quit (1); + quit(1); } /* Load the sprite */ - if (LoadSprite (screen, "icon.bmp") < 0) { - SDL_FreeSurface (light); - quit (1); + if (LoadSprite(screen, "icon.bmp") < 0) { + SDL_FreeSurface(light); + quit(1); } /* Print out information about our surfaces */ - printf ("Screen is at %d bits per pixel\n", screen->format->BitsPerPixel); + printf("Screen is at %d bits per pixel\n", screen->format->BitsPerPixel); if ((screen->flags & SDL_HWSURFACE) == SDL_HWSURFACE) { - printf ("Screen is in video memory\n"); + printf("Screen is in video memory\n"); } else { - printf ("Screen is in system memory\n"); + printf("Screen is in system memory\n"); } if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { - printf ("Screen has double-buffering enabled\n"); + printf("Screen has double-buffering enabled\n"); } if ((sprite->flags & SDL_HWSURFACE) == SDL_HWSURFACE) { - printf ("Sprite is in video memory\n"); + printf("Sprite is in video memory\n"); } else { - printf ("Sprite is in system memory\n"); + printf("Sprite is in system memory\n"); } /* Run a sample blit to trigger blit acceleration */ - MoveSprite (screen, NULL); + MoveSprite(screen, NULL); if ((sprite->flags & SDL_HWACCEL) == SDL_HWACCEL) { - printf ("Sprite blit uses hardware alpha acceleration\n"); + printf("Sprite blit uses hardware alpha acceleration\n"); } else { - printf ("Sprite blit dosn't uses hardware alpha acceleration\n"); + printf("Sprite blit dosn't uses hardware alpha acceleration\n"); } /* Set a clipping rectangle to clip the outside edge of the screen */ @@ -447,57 +445,57 @@ clip.y = 32; clip.w = screen->w - (2 * 32); clip.h = screen->h - (2 * 32); - SDL_SetClipRect (screen, &clip); + SDL_SetClipRect(screen, &clip); } /* Wait for a keystroke */ - lastticks = SDL_GetTicks (); + lastticks = SDL_GetTicks(); done = 0; mouse_pressed = 0; while (!done) { /* Update the frame -- move the sprite */ if (mouse_pressed) { - MoveSprite (screen, light); + MoveSprite(screen, light); mouse_pressed = 0; } else { - MoveSprite (screen, NULL); + MoveSprite(screen, NULL); } /* Slow down the loop to 30 frames/second */ - ticks = SDL_GetTicks (); + ticks = SDL_GetTicks(); if ((ticks - lastticks) < FRAME_TICKS) { #ifdef CHECK_SLEEP_GRANULARITY - fprintf (stderr, "Sleeping %d ticks\n", - FRAME_TICKS - (ticks - lastticks)); + fprintf(stderr, "Sleeping %d ticks\n", + FRAME_TICKS - (ticks - lastticks)); #endif - SDL_Delay (FRAME_TICKS - (ticks - lastticks)); + SDL_Delay(FRAME_TICKS - (ticks - lastticks)); #ifdef CHECK_SLEEP_GRANULARITY - fprintf (stderr, "Slept %d ticks\n", (SDL_GetTicks () - ticks)); + fprintf(stderr, "Slept %d ticks\n", (SDL_GetTicks() - ticks)); #endif } lastticks = ticks; /* Check for events */ - while (SDL_PollEvent (&event)) { + while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_VIDEORESIZE: screen = - SDL_SetVideoMode (event.resize.w, event.resize.h, - video_bpp, videoflags); + SDL_SetVideoMode(event.resize.w, event.resize.h, + video_bpp, videoflags); if (screen) { - FillBackground (screen); + FillBackground(screen); } break; /* Attract sprite while mouse is held down */ case SDL_MOUSEMOTION: if (event.motion.state != 0) { - AttractSprite (event.motion.x, event.motion.y); + AttractSprite(event.motion.x, event.motion.y); mouse_pressed = 1; } break; case SDL_MOUSEBUTTONDOWN: if (event.button.button == 1) { - AttractSprite (event.button.x, event.button.y); + AttractSprite(event.button.x, event.button.y); mouse_pressed = 1; } else { SDL_Rect area; @@ -506,8 +504,8 @@ area.y = event.button.y - 16; area.w = 32; area.h = 32; - SDL_FillRect (screen, &area, 0); - SDL_UpdateRects (screen, 1, &area); + SDL_FillRect(screen, &area, 0); + SDL_UpdateRects(screen, 1, &area); } break; case SDL_KEYDOWN: @@ -523,16 +521,16 @@ } } } - SDL_FreeSurface (light); - SDL_FreeSurface (sprite); - SDL_FreeSurface (backing); + SDL_FreeSurface(light); + SDL_FreeSurface(sprite); + SDL_FreeSurface(backing); /* Print out some timing information */ if (flashes > 0) { - printf ("%d alpha blits, ~%4.4f ms per blit\n", - flashes, (float) flashtime / flashes); + printf("%d alpha blits, ~%4.4f ms per blit\n", + flashes, (float) flashtime / flashes); } - SDL_Quit (); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testbitmap.c --- a/test/testbitmap.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testbitmap.c Mon May 29 04:04:35 2006 +0000 @@ -10,22 +10,22 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } SDL_Surface * -LoadXBM (SDL_Surface * screen, int w, int h, Uint8 * bits) +LoadXBM(SDL_Surface * screen, int w, int h, Uint8 * bits) { SDL_Surface *bitmap; Uint8 *line; /* Allocate the bitmap */ - bitmap = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h, 1, 0, 0, 0, 0); + bitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 1, 0, 0, 0, 0); if (bitmap == NULL) { - fprintf (stderr, "Couldn't allocate bitmap: %s\n", SDL_GetError ()); + fprintf(stderr, "Couldn't allocate bitmap: %s\n", SDL_GetError()); return (NULL); } @@ -33,7 +33,7 @@ line = (Uint8 *) bitmap->pixels; w = (w + 7) / 8; while (h--) { - memcpy (line, bits, w); + memcpy(line, bits, w); /* X11 Bitmap images have the bits reversed */ { int i, j; @@ -54,7 +54,7 @@ } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SDL_Surface *screen; SDL_Surface *bitmap; @@ -70,8 +70,8 @@ /* Initialize SDL */ - if (SDL_Init (SDL_INIT_VIDEO) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } @@ -79,28 +79,28 @@ videoflags = SDL_SWSURFACE; while (argc > 1) { --argc; - if (strcmp (argv[argc - 1], "-bpp") == 0) { - video_bpp = atoi (argv[argc]); + if (strcmp(argv[argc - 1], "-bpp") == 0) { + video_bpp = atoi(argv[argc]); --argc; - } else if (strcmp (argv[argc], "-warp") == 0) { + } else if (strcmp(argv[argc], "-warp") == 0) { videoflags |= SDL_HWPALETTE; - } else if (strcmp (argv[argc], "-hw") == 0) { + } else if (strcmp(argv[argc], "-hw") == 0) { videoflags |= SDL_HWSURFACE; - } else if (strcmp (argv[argc], "-fullscreen") == 0) { + } else if (strcmp(argv[argc], "-fullscreen") == 0) { videoflags |= SDL_FULLSCREEN; } else { - fprintf (stderr, - "Usage: %s [-bpp N] [-warp] [-hw] [-fullscreen]\n", - argv[0]); - quit (1); + fprintf(stderr, + "Usage: %s [-bpp N] [-warp] [-hw] [-fullscreen]\n", + argv[0]); + quit(1); } } /* Set 640x480 video mode */ - if ((screen = SDL_SetVideoMode (640, 480, video_bpp, videoflags)) == NULL) { - fprintf (stderr, "Couldn't set 640x480x%d video mode: %s\n", - video_bpp, SDL_GetError ()); - quit (2); + if ((screen = SDL_SetVideoMode(640, 480, video_bpp, videoflags)) == NULL) { + fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n", + video_bpp, SDL_GetError()); + quit(2); } if (video_bpp == 8) { @@ -110,25 +110,25 @@ palette[i].g = 255 - i; palette[i].b = 255 - i; } - SDL_SetColors (screen, palette, 0, 256); + SDL_SetColors(screen, palette, 0, 256); } /* Set the surface pixels and refresh! */ - if (SDL_LockSurface (screen) < 0) { - fprintf (stderr, "Couldn't lock the display surface: %s\n", - SDL_GetError ()); - quit (2); + if (SDL_LockSurface(screen) < 0) { + fprintf(stderr, "Couldn't lock the display surface: %s\n", + SDL_GetError()); + quit(2); } buffer = (Uint8 *) screen->pixels; if (screen->format->BytesPerPixel != 2) { for (i = 0; i < screen->h; ++i) { - memset (buffer, (i * 255) / screen->h, screen->pitch); + memset(buffer, (i * 255) / screen->h, screen->pitch); buffer += screen->pitch; } } else { for (i = 0; i < screen->h; ++i) { gradient = ((i * 255) / screen->h); - color = SDL_MapRGB (screen->format, gradient, gradient, gradient); + color = SDL_MapRGB(screen->format, gradient, gradient, gradient); buffer16 = (Uint16 *) buffer; for (k = 0; k < screen->w; k++) { *(buffer16 + k) = color; @@ -136,21 +136,21 @@ buffer += screen->pitch; } } - SDL_UnlockSurface (screen); - SDL_UpdateRect (screen, 0, 0, 0, 0); + SDL_UnlockSurface(screen); + SDL_UpdateRect(screen, 0, 0, 0, 0); /* Load the bitmap */ - bitmap = LoadXBM (screen, picture_width, picture_height, - (Uint8 *) picture_bits); + bitmap = LoadXBM(screen, picture_width, picture_height, + (Uint8 *) picture_bits); if (bitmap == NULL) { - quit (1); + quit(1); } /* Wait for a keystroke */ done = 0; while (!done) { /* Check for events */ - while (SDL_PollEvent (&event)) { + while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_MOUSEBUTTONDOWN: { @@ -160,8 +160,8 @@ dst.y = event.button.y - bitmap->h / 2; dst.w = bitmap->w; dst.h = bitmap->h; - SDL_BlitSurface (bitmap, NULL, screen, &dst); - SDL_UpdateRects (screen, 1, &dst); + SDL_BlitSurface(bitmap, NULL, screen, &dst); + SDL_UpdateRects(screen, 1, &dst); } break; case SDL_KEYDOWN: @@ -176,7 +176,7 @@ } } } - SDL_FreeSurface (bitmap); - SDL_Quit (); + SDL_FreeSurface(bitmap); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testblitspeed.c --- a/test/testblitspeed.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testblitspeed.c Mon May 29 04:04:35 2006 +0000 @@ -16,32 +16,32 @@ static int -percent (int val, int total) +percent(int val, int total) { return ((int) ((((float) val) / ((float) total)) * 100.0f)); } static int -randRange (int lo, int hi) +randRange(int lo, int hi) { - return (lo + (int) (((double) hi) * rand () / (RAND_MAX + 1.0))); + return (lo + (int) (((double) hi) * rand() / (RAND_MAX + 1.0))); } static void -copy_trunc_str (char *str, size_t strsize, const char *flagstr) +copy_trunc_str(char *str, size_t strsize, const char *flagstr) { - if ((strlen (str) + strlen (flagstr)) >= (strsize - 1)) - strcpy (str + (strsize - 5), " ..."); + if ((strlen(str) + strlen(flagstr)) >= (strsize - 1)) + strcpy(str + (strsize - 5), " ..."); else - strcat (str, flagstr); + strcat(str, flagstr); } static void -__append_sdl_surface_flag (SDL_Surface * _surface, char *str, - size_t strsize, Uint32 flag, const char *flagstr) +__append_sdl_surface_flag(SDL_Surface * _surface, char *str, + size_t strsize, Uint32 flag, const char *flagstr) { if (_surface->flags & flag) - copy_trunc_str (str, strsize, flagstr); + copy_trunc_str(str, strsize, flagstr); } @@ -49,106 +49,106 @@ #define print_tf_state(str, val) printf("%s: {%s}\n", str, (val) ? "true" : "false" ) static void -output_videoinfo_details (void) +output_videoinfo_details(void) { - const SDL_VideoInfo *info = SDL_GetVideoInfo (); - printf ("SDL_GetVideoInfo():\n"); + const SDL_VideoInfo *info = SDL_GetVideoInfo(); + printf("SDL_GetVideoInfo():\n"); if (info == NULL) - printf (" (null.)\n"); + printf(" (null.)\n"); else { - print_tf_state (" hardware surface available", info->hw_available); - print_tf_state (" window manager available", info->wm_available); - print_tf_state (" accelerated hardware->hardware blits", - info->blit_hw); - print_tf_state (" accelerated hardware->hardware colorkey blits", - info->blit_hw_CC); - print_tf_state (" accelerated hardware->hardware alpha blits", - info->blit_hw_A); - print_tf_state (" accelerated software->hardware blits", - info->blit_sw); - print_tf_state (" accelerated software->hardware colorkey blits", - info->blit_sw_CC); - print_tf_state (" accelerated software->hardware alpha blits", - info->blit_sw_A); - print_tf_state (" accelerated color fills", info->blit_fill); - printf (" video memory: (%d)\n", info->video_mem); + print_tf_state(" hardware surface available", info->hw_available); + print_tf_state(" window manager available", info->wm_available); + print_tf_state(" accelerated hardware->hardware blits", + info->blit_hw); + print_tf_state(" accelerated hardware->hardware colorkey blits", + info->blit_hw_CC); + print_tf_state(" accelerated hardware->hardware alpha blits", + info->blit_hw_A); + print_tf_state(" accelerated software->hardware blits", + info->blit_sw); + print_tf_state(" accelerated software->hardware colorkey blits", + info->blit_sw_CC); + print_tf_state(" accelerated software->hardware alpha blits", + info->blit_sw_A); + print_tf_state(" accelerated color fills", info->blit_fill); + printf(" video memory: (%d)\n", info->video_mem); } - printf ("\n"); + printf("\n"); } static void -output_surface_details (const char *name, SDL_Surface * surface) +output_surface_details(const char *name, SDL_Surface * surface) { - printf ("Details for %s:\n", name); + printf("Details for %s:\n", name); if (surface == NULL) { - printf ("-WARNING- You've got a NULL surface!"); + printf("-WARNING- You've got a NULL surface!"); } else { char f[256]; - printf (" width : %d\n", surface->w); - printf (" height : %d\n", surface->h); - printf (" depth : %d bits per pixel\n", - surface->format->BitsPerPixel); - printf (" pitch : %d\n", (int) surface->pitch); - printf (" alpha : %d\n", (int) surface->format->alpha); - printf (" colorkey : 0x%X\n", - (unsigned int) surface->format->colorkey); + printf(" width : %d\n", surface->w); + printf(" height : %d\n", surface->h); + printf(" depth : %d bits per pixel\n", + surface->format->BitsPerPixel); + printf(" pitch : %d\n", (int) surface->pitch); + printf(" alpha : %d\n", (int) surface->format->alpha); + printf(" colorkey : 0x%X\n", + (unsigned int) surface->format->colorkey); - printf (" red bits : 0x%08X mask, %d shift, %d loss\n", - (int) surface->format->Rmask, - (int) surface->format->Rshift, (int) surface->format->Rloss); - printf (" green bits : 0x%08X mask, %d shift, %d loss\n", - (int) surface->format->Gmask, - (int) surface->format->Gshift, (int) surface->format->Gloss); - printf (" blue bits : 0x%08X mask, %d shift, %d loss\n", - (int) surface->format->Bmask, - (int) surface->format->Bshift, (int) surface->format->Bloss); - printf (" alpha bits : 0x%08X mask, %d shift, %d loss\n", - (int) surface->format->Amask, - (int) surface->format->Ashift, (int) surface->format->Aloss); + printf(" red bits : 0x%08X mask, %d shift, %d loss\n", + (int) surface->format->Rmask, + (int) surface->format->Rshift, (int) surface->format->Rloss); + printf(" green bits : 0x%08X mask, %d shift, %d loss\n", + (int) surface->format->Gmask, + (int) surface->format->Gshift, (int) surface->format->Gloss); + printf(" blue bits : 0x%08X mask, %d shift, %d loss\n", + (int) surface->format->Bmask, + (int) surface->format->Bshift, (int) surface->format->Bloss); + printf(" alpha bits : 0x%08X mask, %d shift, %d loss\n", + (int) surface->format->Amask, + (int) surface->format->Ashift, (int) surface->format->Aloss); f[0] = '\0'; /*append_sdl_surface_flag(surface, f, sizeof (f), SDL_SWSURFACE); */ if ((surface->flags & SDL_HWSURFACE) == 0) - copy_trunc_str (f, sizeof (f), " SDL_SWSURFACE"); + copy_trunc_str(f, sizeof(f), " SDL_SWSURFACE"); - append_sdl_surface_flag (surface, f, sizeof (f), SDL_HWSURFACE); - append_sdl_surface_flag (surface, f, sizeof (f), SDL_ASYNCBLIT); - append_sdl_surface_flag (surface, f, sizeof (f), SDL_ANYFORMAT); - append_sdl_surface_flag (surface, f, sizeof (f), SDL_HWPALETTE); - append_sdl_surface_flag (surface, f, sizeof (f), SDL_DOUBLEBUF); - append_sdl_surface_flag (surface, f, sizeof (f), SDL_FULLSCREEN); - append_sdl_surface_flag (surface, f, sizeof (f), SDL_OPENGL); - append_sdl_surface_flag (surface, f, sizeof (f), SDL_RESIZABLE); - append_sdl_surface_flag (surface, f, sizeof (f), SDL_NOFRAME); - append_sdl_surface_flag (surface, f, sizeof (f), SDL_HWACCEL); - append_sdl_surface_flag (surface, f, sizeof (f), SDL_SRCCOLORKEY); - append_sdl_surface_flag (surface, f, sizeof (f), SDL_RLEACCELOK); - append_sdl_surface_flag (surface, f, sizeof (f), SDL_RLEACCEL); - append_sdl_surface_flag (surface, f, sizeof (f), SDL_SRCALPHA); - append_sdl_surface_flag (surface, f, sizeof (f), SDL_PREALLOC); + append_sdl_surface_flag(surface, f, sizeof(f), SDL_HWSURFACE); + append_sdl_surface_flag(surface, f, sizeof(f), SDL_ASYNCBLIT); + append_sdl_surface_flag(surface, f, sizeof(f), SDL_ANYFORMAT); + append_sdl_surface_flag(surface, f, sizeof(f), SDL_HWPALETTE); + append_sdl_surface_flag(surface, f, sizeof(f), SDL_DOUBLEBUF); + append_sdl_surface_flag(surface, f, sizeof(f), SDL_FULLSCREEN); + append_sdl_surface_flag(surface, f, sizeof(f), SDL_OPENGL); + append_sdl_surface_flag(surface, f, sizeof(f), SDL_RESIZABLE); + append_sdl_surface_flag(surface, f, sizeof(f), SDL_NOFRAME); + append_sdl_surface_flag(surface, f, sizeof(f), SDL_HWACCEL); + append_sdl_surface_flag(surface, f, sizeof(f), SDL_SRCCOLORKEY); + append_sdl_surface_flag(surface, f, sizeof(f), SDL_RLEACCELOK); + append_sdl_surface_flag(surface, f, sizeof(f), SDL_RLEACCEL); + append_sdl_surface_flag(surface, f, sizeof(f), SDL_SRCALPHA); + append_sdl_surface_flag(surface, f, sizeof(f), SDL_PREALLOC); if (f[0] == '\0') - strcpy (f, " (none)"); + strcpy(f, " (none)"); - printf (" flags :%s\n", f); + printf(" flags :%s\n", f); } - printf ("\n"); + printf("\n"); } static void -output_details (void) +output_details(void) { - output_videoinfo_details (); - output_surface_details ("Source Surface", src); - output_surface_details ("Destination Surface", dest); + output_videoinfo_details(); + output_surface_details("Source Surface", src); + output_surface_details("Destination Surface", dest); } static Uint32 -blit (SDL_Surface * dst, SDL_Surface * src, int x, int y) +blit(SDL_Surface * dst, SDL_Surface * src, int x, int y) { Uint32 start = 0; SDL_Rect srcRect; @@ -161,38 +161,38 @@ dstRect.w = srcRect.w = src->w; /* SDL will clip as appropriate. */ dstRect.h = srcRect.h = src->h; - start = SDL_GetTicks (); - SDL_BlitSurface (src, &srcRect, dst, &dstRect); - return (SDL_GetTicks () - start); + start = SDL_GetTicks(); + SDL_BlitSurface(src, &srcRect, dst, &dstRect); + return (SDL_GetTicks() - start); } static void -blitCentered (SDL_Surface * dst, SDL_Surface * src) +blitCentered(SDL_Surface * dst, SDL_Surface * src) { int x = (dst->w - src->w) / 2; int y = (dst->h - src->h) / 2; - blit (dst, src, x, y); + blit(dst, src, x, y); } static int -atoi_hex (const char *str) +atoi_hex(const char *str) { if (str == NULL) return 0; - if (strlen (str) > 2) { + if (strlen(str) > 2) { int retval = 0; if ((str[0] == '0') && (str[1] == 'x')) - sscanf (str + 2, "%X", &retval); + sscanf(str + 2, "%X", &retval); return (retval); } - return (atoi (str)); + return (atoi(str)); } static int -setup_test (int argc, char **argv) +setup_test(int argc, char **argv) { const char *dumpfile = NULL; SDL_Surface *bmp = NULL; @@ -224,60 +224,60 @@ for (i = 1; i < argc; i++) { const char *arg = argv[i]; - if (strcmp (arg, "--dstbpp") == 0) - dstbpp = atoi (argv[++i]); - else if (strcmp (arg, "--dstrmask") == 0) - dstrmask = atoi_hex (argv[++i]); - else if (strcmp (arg, "--dstgmask") == 0) - dstgmask = atoi_hex (argv[++i]); - else if (strcmp (arg, "--dstbmask") == 0) - dstbmask = atoi_hex (argv[++i]); - else if (strcmp (arg, "--dstamask") == 0) - dstamask = atoi_hex (argv[++i]); - else if (strcmp (arg, "--dstwidth") == 0) - dstw = atoi (argv[++i]); - else if (strcmp (arg, "--dstheight") == 0) - dsth = atoi (argv[++i]); - else if (strcmp (arg, "--dsthwsurface") == 0) + if (strcmp(arg, "--dstbpp") == 0) + dstbpp = atoi(argv[++i]); + else if (strcmp(arg, "--dstrmask") == 0) + dstrmask = atoi_hex(argv[++i]); + else if (strcmp(arg, "--dstgmask") == 0) + dstgmask = atoi_hex(argv[++i]); + else if (strcmp(arg, "--dstbmask") == 0) + dstbmask = atoi_hex(argv[++i]); + else if (strcmp(arg, "--dstamask") == 0) + dstamask = atoi_hex(argv[++i]); + else if (strcmp(arg, "--dstwidth") == 0) + dstw = atoi(argv[++i]); + else if (strcmp(arg, "--dstheight") == 0) + dsth = atoi(argv[++i]); + else if (strcmp(arg, "--dsthwsurface") == 0) dstflags |= SDL_HWSURFACE; - else if (strcmp (arg, "--srcbpp") == 0) - srcbpp = atoi (argv[++i]); - else if (strcmp (arg, "--srcrmask") == 0) - srcrmask = atoi_hex (argv[++i]); - else if (strcmp (arg, "--srcgmask") == 0) - srcgmask = atoi_hex (argv[++i]); - else if (strcmp (arg, "--srcbmask") == 0) - srcbmask = atoi_hex (argv[++i]); - else if (strcmp (arg, "--srcamask") == 0) - srcamask = atoi_hex (argv[++i]); - else if (strcmp (arg, "--srcwidth") == 0) - srcw = atoi (argv[++i]); - else if (strcmp (arg, "--srcheight") == 0) - srch = atoi (argv[++i]); - else if (strcmp (arg, "--srchwsurface") == 0) + else if (strcmp(arg, "--srcbpp") == 0) + srcbpp = atoi(argv[++i]); + else if (strcmp(arg, "--srcrmask") == 0) + srcrmask = atoi_hex(argv[++i]); + else if (strcmp(arg, "--srcgmask") == 0) + srcgmask = atoi_hex(argv[++i]); + else if (strcmp(arg, "--srcbmask") == 0) + srcbmask = atoi_hex(argv[++i]); + else if (strcmp(arg, "--srcamask") == 0) + srcamask = atoi_hex(argv[++i]); + else if (strcmp(arg, "--srcwidth") == 0) + srcw = atoi(argv[++i]); + else if (strcmp(arg, "--srcheight") == 0) + srch = atoi(argv[++i]); + else if (strcmp(arg, "--srchwsurface") == 0) srcflags |= SDL_HWSURFACE; - else if (strcmp (arg, "--seconds") == 0) - testSeconds = atoi (argv[++i]); - else if (strcmp (arg, "--screen") == 0) + else if (strcmp(arg, "--seconds") == 0) + testSeconds = atoi(argv[++i]); + else if (strcmp(arg, "--screen") == 0) screenSurface = 1; - else if (strcmp (arg, "--dumpfile") == 0) + else if (strcmp(arg, "--dumpfile") == 0) dumpfile = argv[++i]; /* !!! FIXME: set colorkey. */ else if (0) { /* !!! FIXME: we handle some commandlines elsewhere now */ - fprintf (stderr, "Unknown commandline option: %s\n", arg); + fprintf(stderr, "Unknown commandline option: %s\n", arg); return (0); } } - if (SDL_Init (SDL_INIT_VIDEO) == -1) { - fprintf (stderr, "SDL_Init failed: %s\n", SDL_GetError ()); + if (SDL_Init(SDL_INIT_VIDEO) == -1) { + fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError()); return (0); } - bmp = SDL_LoadBMP ("sample.bmp"); + bmp = SDL_LoadBMP("sample.bmp"); if (bmp == NULL) { - fprintf (stderr, "SDL_LoadBMP failed: %s\n", SDL_GetError ()); - SDL_Quit (); + fprintf(stderr, "SDL_LoadBMP failed: %s\n", SDL_GetError()); + SDL_Quit(); return (0); } @@ -287,25 +287,23 @@ srcflags |= SDL_SWSURFACE; if (screenSurface) - dest = SDL_SetVideoMode (dstw, dsth, dstbpp, dstflags); + dest = SDL_SetVideoMode(dstw, dsth, dstbpp, dstflags); else { - dest = SDL_CreateRGBSurface (dstflags, dstw, dsth, dstbpp, - dstrmask, dstgmask, dstbmask, dstamask); + dest = SDL_CreateRGBSurface(dstflags, dstw, dsth, dstbpp, + dstrmask, dstgmask, dstbmask, dstamask); } if (dest == NULL) { - fprintf (stderr, "dest surface creation failed: %s\n", - SDL_GetError ()); - SDL_Quit (); + fprintf(stderr, "dest surface creation failed: %s\n", SDL_GetError()); + SDL_Quit(); return (0); } - src = SDL_CreateRGBSurface (srcflags, srcw, srch, srcbpp, - srcrmask, srcgmask, srcbmask, srcamask); + src = SDL_CreateRGBSurface(srcflags, srcw, srch, srcbpp, + srcrmask, srcgmask, srcbmask, srcamask); if (src == NULL) { - fprintf (stderr, "src surface creation failed: %s\n", - SDL_GetError ()); - SDL_Quit (); + fprintf(stderr, "src surface creation failed: %s\n", SDL_GetError()); + SDL_Quit(); return (0); } @@ -320,54 +318,54 @@ for (i = 1; i < argc; i++) { const char *arg = argv[i]; - if (strcmp (arg, "--srcalpha") == 0) - srcalpha = atoi (argv[++i]); - else if (strcmp (arg, "--dstalpha") == 0) - dstalpha = atoi (argv[++i]); - else if (strcmp (arg, "--srcsrcalpha") == 0) + if (strcmp(arg, "--srcalpha") == 0) + srcalpha = atoi(argv[++i]); + else if (strcmp(arg, "--dstalpha") == 0) + dstalpha = atoi(argv[++i]); + else if (strcmp(arg, "--srcsrcalpha") == 0) srcalphaflags |= SDL_SRCALPHA; - else if (strcmp (arg, "--srcnosrcalpha") == 0) + else if (strcmp(arg, "--srcnosrcalpha") == 0) srcalphaflags &= ~SDL_SRCALPHA; - else if (strcmp (arg, "--srcrleaccel") == 0) + else if (strcmp(arg, "--srcrleaccel") == 0) srcalphaflags |= SDL_RLEACCEL; - else if (strcmp (arg, "--srcnorleaccel") == 0) + else if (strcmp(arg, "--srcnorleaccel") == 0) srcalphaflags &= ~SDL_RLEACCEL; - else if (strcmp (arg, "--dstsrcalpha") == 0) + else if (strcmp(arg, "--dstsrcalpha") == 0) dstalphaflags |= SDL_SRCALPHA; - else if (strcmp (arg, "--dstnosrcalpha") == 0) + else if (strcmp(arg, "--dstnosrcalpha") == 0) dstalphaflags &= ~SDL_SRCALPHA; - else if (strcmp (arg, "--dstrleaccel") == 0) + else if (strcmp(arg, "--dstrleaccel") == 0) dstalphaflags |= SDL_RLEACCEL; - else if (strcmp (arg, "--dstnorleaccel") == 0) + else if (strcmp(arg, "--dstnorleaccel") == 0) dstalphaflags &= ~SDL_RLEACCEL; } if ((dstalphaflags != origdstalphaflags) || (dstalpha != dest->format->alpha)) - SDL_SetAlpha (dest, dstalphaflags, (Uint8) dstalpha); + SDL_SetAlpha(dest, dstalphaflags, (Uint8) dstalpha); if ((srcalphaflags != origsrcalphaflags) || (srcalpha != src->format->alpha)) - SDL_SetAlpha (src, srcalphaflags, (Uint8) srcalpha); + SDL_SetAlpha(src, srcalphaflags, (Uint8) srcalpha); /* set some sane defaults so we can see if the blit code is broken... */ - SDL_FillRect (dest, NULL, SDL_MapRGB (dest->format, 0, 0, 0)); - SDL_FillRect (src, NULL, SDL_MapRGB (src->format, 0, 0, 0)); + SDL_FillRect(dest, NULL, SDL_MapRGB(dest->format, 0, 0, 0)); + SDL_FillRect(src, NULL, SDL_MapRGB(src->format, 0, 0, 0)); - blitCentered (src, bmp); - SDL_FreeSurface (bmp); + blitCentered(src, bmp); + SDL_FreeSurface(bmp); if (dumpfile) - SDL_SaveBMP (src, dumpfile); /* make sure initial convert is sane. */ + SDL_SaveBMP(src, dumpfile); /* make sure initial convert is sane. */ - output_details (); + output_details(); return (1); } static void -test_blit_speed (void) +test_blit_speed(void) { - Uint32 clearColor = SDL_MapRGB (dest->format, 0, 0, 0); + Uint32 clearColor = SDL_MapRGB(dest->format, 0, 0, 0); Uint32 iterations = 0; Uint32 elasped = 0; Uint32 end = 0; @@ -376,49 +374,49 @@ int testms = testSeconds * 1000; int wmax = (dest->w - src->w); int hmax = (dest->h - src->h); - int isScreen = (SDL_GetVideoSurface () == dest); + int isScreen = (SDL_GetVideoSurface() == dest); SDL_Event event; - printf ("Testing blit speed for %d seconds...\n", testSeconds); + printf("Testing blit speed for %d seconds...\n", testSeconds); - now = SDL_GetTicks (); + now = SDL_GetTicks(); end = now + testms; do { /* pump the event queue occasionally to keep OS happy... */ if (now - last > 1000) { last = now; - while (SDL_PollEvent (&event)) { /* no-op. */ + while (SDL_PollEvent(&event)) { /* no-op. */ } } iterations++; - elasped += blit (dest, src, randRange (0, wmax), randRange (0, hmax)); + elasped += blit(dest, src, randRange(0, wmax), randRange(0, hmax)); if (isScreen) { - SDL_Flip (dest); /* show it! */ - SDL_FillRect (dest, NULL, clearColor); /* blank it for next time! */ + SDL_Flip(dest); /* show it! */ + SDL_FillRect(dest, NULL, clearColor); /* blank it for next time! */ } - now = SDL_GetTicks (); + now = SDL_GetTicks(); } while (now < end); - printf ("Non-blitting crap accounted for %d percent of this run.\n", - percent (testms - elasped, testms)); + printf("Non-blitting crap accounted for %d percent of this run.\n", + percent(testms - elasped, testms)); - printf ("%d blits took %d ms (%d fps).\n", - (int) iterations, - (int) elasped, - (int) (((float) iterations) / (((float) elasped) / 1000.0f))); + printf("%d blits took %d ms (%d fps).\n", + (int) iterations, + (int) elasped, + (int) (((float) iterations) / (((float) elasped) / 1000.0f))); } int -main (int argc, char **argv) +main(int argc, char **argv) { - int initialized = setup_test (argc, argv); + int initialized = setup_test(argc, argv); if (initialized) { - test_blit_speed (); - SDL_Quit (); + test_blit_speed(); + SDL_Quit(); } return (!initialized); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testcdrom.c --- a/test/testcdrom.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testcdrom.c Mon May 29 04:04:35 2006 +0000 @@ -10,19 +10,19 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } static void -PrintStatus (int driveindex, SDL_CD * cdrom) +PrintStatus(int driveindex, SDL_CD * cdrom) { CDstatus status; char *status_str; - status = SDL_CDStatus (cdrom); + status = SDL_CDStatus(cdrom); switch (status) { case CD_TRAYEMPTY: status_str = "tray empty"; @@ -40,26 +40,26 @@ status_str = "error state"; break; } - printf ("Drive %d status: %s\n", driveindex, status_str); + printf("Drive %d status: %s\n", driveindex, status_str); if (status >= CD_PLAYING) { int m, s, f; - FRAMES_TO_MSF (cdrom->cur_frame, &m, &s, &f); - printf ("Currently playing track %d, %d:%2.2d\n", - cdrom->track[cdrom->cur_track].id, m, s); + FRAMES_TO_MSF(cdrom->cur_frame, &m, &s, &f); + printf("Currently playing track %d, %d:%2.2d\n", + cdrom->track[cdrom->cur_track].id, m, s); } } static void -ListTracks (SDL_CD * cdrom) +ListTracks(SDL_CD * cdrom) { int i; int m, s, f; char *trtype; - SDL_CDStatus (cdrom); - printf ("Drive tracks: %d\n", cdrom->numtracks); + SDL_CDStatus(cdrom); + printf("Drive tracks: %d\n", cdrom->numtracks); for (i = 0; i < cdrom->numtracks; ++i) { - FRAMES_TO_MSF (cdrom->track[i].length, &m, &s, &f); + FRAMES_TO_MSF(cdrom->track[i].length, &m, &s, &f); if (f > 0) ++s; switch (cdrom->track[i].type) { @@ -73,61 +73,61 @@ trtype = "unknown"; break; } - printf ("\tTrack (index %d) %d: %d:%2.2d / %d [%s track]\n", i, - cdrom->track[i].id, m, s, cdrom->track[i].length, trtype); + printf("\tTrack (index %d) %d: %d:%2.2d / %d [%s track]\n", i, + cdrom->track[i].id, m, s, cdrom->track[i].length, trtype); } } static void -PrintUsage (char *argv0) +PrintUsage(char *argv0) { - fprintf (stderr, "Usage: %s [drive#] [command] [command] ...\n", argv0); - fprintf (stderr, "Where 'command' is one of:\n"); - fprintf (stderr, " -status\n"); - fprintf (stderr, " -list\n"); - fprintf (stderr, - " -play [first_track] [first_frame] [num_tracks] [num_frames]\n"); - fprintf (stderr, " -pause\n"); - fprintf (stderr, " -resume\n"); - fprintf (stderr, " -stop\n"); - fprintf (stderr, " -eject\n"); - fprintf (stderr, " -sleep \n"); + fprintf(stderr, "Usage: %s [drive#] [command] [command] ...\n", argv0); + fprintf(stderr, "Where 'command' is one of:\n"); + fprintf(stderr, " -status\n"); + fprintf(stderr, " -list\n"); + fprintf(stderr, + " -play [first_track] [first_frame] [num_tracks] [num_frames]\n"); + fprintf(stderr, " -pause\n"); + fprintf(stderr, " -resume\n"); + fprintf(stderr, " -stop\n"); + fprintf(stderr, " -eject\n"); + fprintf(stderr, " -sleep \n"); } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { int drive; int i; SDL_CD *cdrom; /* Initialize SDL first */ - if (SDL_Init (SDL_INIT_CDROM) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(SDL_INIT_CDROM) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } /* Find out how many CD-ROM drives are connected to the system */ - if (SDL_CDNumDrives () == 0) { - printf ("No CD-ROM devices detected\n"); - quit (0); + if (SDL_CDNumDrives() == 0) { + printf("No CD-ROM devices detected\n"); + quit(0); } - printf ("Drives available: %d\n", SDL_CDNumDrives ()); - for (i = 0; i < SDL_CDNumDrives (); ++i) { - printf ("Drive %d: \"%s\"\n", i, SDL_CDName (i)); + printf("Drives available: %d\n", SDL_CDNumDrives()); + for (i = 0; i < SDL_CDNumDrives(); ++i) { + printf("Drive %d: \"%s\"\n", i, SDL_CDName(i)); } /* Open the CD-ROM */ drive = 0; i = 1; - if (argv[i] && isdigit (argv[i][0])) { - drive = atoi (argv[i++]); + if (argv[i] && isdigit(argv[i][0])) { + drive = atoi(argv[i++]); } - cdrom = SDL_CDOpen (drive); + cdrom = SDL_CDOpen(drive); if (cdrom == NULL) { - fprintf (stderr, "Couldn't open drive %d: %s\n", drive, - SDL_GetError ()); - quit (2); + fprintf(stderr, "Couldn't open drive %d: %s\n", drive, + SDL_GetError()); + quit(2); } #ifdef TEST_NULLCD cdrom = NULL; @@ -135,69 +135,69 @@ /* Find out which function to perform */ for (; argv[i]; ++i) { - if (strcmp (argv[i], "-status") == 0) { + if (strcmp(argv[i], "-status") == 0) { /* PrintStatus(drive, cdrom); */ - } else if (strcmp (argv[i], "-list") == 0) { - ListTracks (cdrom); - } else if (strcmp (argv[i], "-play") == 0) { + } else if (strcmp(argv[i], "-list") == 0) { + ListTracks(cdrom); + } else if (strcmp(argv[i], "-play") == 0) { int strack, sframe; int ntrack, nframe; strack = 0; - if (argv[i + 1] && isdigit (argv[i + 1][0])) { - strack = atoi (argv[++i]); + if (argv[i + 1] && isdigit(argv[i + 1][0])) { + strack = atoi(argv[++i]); } sframe = 0; - if (argv[i + 1] && isdigit (argv[i + 1][0])) { - sframe = atoi (argv[++i]); + if (argv[i + 1] && isdigit(argv[i + 1][0])) { + sframe = atoi(argv[++i]); } ntrack = 0; - if (argv[i + 1] && isdigit (argv[i + 1][0])) { - ntrack = atoi (argv[++i]); + if (argv[i + 1] && isdigit(argv[i + 1][0])) { + ntrack = atoi(argv[++i]); } nframe = 0; - if (argv[i + 1] && isdigit (argv[i + 1][0])) { - nframe = atoi (argv[++i]); + if (argv[i + 1] && isdigit(argv[i + 1][0])) { + nframe = atoi(argv[++i]); } - if (CD_INDRIVE (SDL_CDStatus (cdrom))) { - if (SDL_CDPlayTracks (cdrom, strack, sframe, - ntrack, nframe) < 0) { - fprintf (stderr, - "Couldn't play tracks %d/%d for %d/%d: %s\n", - strack, sframe, ntrack, nframe, SDL_GetError ()); + if (CD_INDRIVE(SDL_CDStatus(cdrom))) { + if (SDL_CDPlayTracks(cdrom, strack, sframe, + ntrack, nframe) < 0) { + fprintf(stderr, + "Couldn't play tracks %d/%d for %d/%d: %s\n", + strack, sframe, ntrack, nframe, SDL_GetError()); } } else { - fprintf (stderr, "No CD in drive!\n"); + fprintf(stderr, "No CD in drive!\n"); } - } else if (strcmp (argv[i], "-pause") == 0) { - if (SDL_CDPause (cdrom) < 0) { - fprintf (stderr, "Couldn't pause CD: %s\n", SDL_GetError ()); + } else if (strcmp(argv[i], "-pause") == 0) { + if (SDL_CDPause(cdrom) < 0) { + fprintf(stderr, "Couldn't pause CD: %s\n", SDL_GetError()); } - } else if (strcmp (argv[i], "-resume") == 0) { - if (SDL_CDResume (cdrom) < 0) { - fprintf (stderr, "Couldn't resume CD: %s\n", SDL_GetError ()); + } else if (strcmp(argv[i], "-resume") == 0) { + if (SDL_CDResume(cdrom) < 0) { + fprintf(stderr, "Couldn't resume CD: %s\n", SDL_GetError()); } - } else if (strcmp (argv[i], "-stop") == 0) { - if (SDL_CDStop (cdrom) < 0) { - fprintf (stderr, "Couldn't eject CD: %s\n", SDL_GetError ()); + } else if (strcmp(argv[i], "-stop") == 0) { + if (SDL_CDStop(cdrom) < 0) { + fprintf(stderr, "Couldn't eject CD: %s\n", SDL_GetError()); } - } else if (strcmp (argv[i], "-eject") == 0) { - if (SDL_CDEject (cdrom) < 0) { - fprintf (stderr, "Couldn't eject CD: %s\n", SDL_GetError ()); + } else if (strcmp(argv[i], "-eject") == 0) { + if (SDL_CDEject(cdrom) < 0) { + fprintf(stderr, "Couldn't eject CD: %s\n", SDL_GetError()); } - } else if ((strcmp (argv[i], "-sleep") == 0) && - (argv[i + 1] && isdigit (argv[i + 1][0]))) { - SDL_Delay (atoi (argv[++i])); - printf ("Delayed %d milliseconds\n", atoi (argv[i])); + } else if ((strcmp(argv[i], "-sleep") == 0) && + (argv[i + 1] && isdigit(argv[i + 1][0]))) { + SDL_Delay(atoi(argv[++i])); + printf("Delayed %d milliseconds\n", atoi(argv[i])); } else { - PrintUsage (argv[0]); - SDL_CDClose (cdrom); - quit (1); + PrintUsage(argv[0]); + SDL_CDClose(cdrom); + quit(1); } } - PrintStatus (drive, cdrom); - SDL_CDClose (cdrom); - SDL_Quit (); + PrintStatus(drive, cdrom); + SDL_CDClose(cdrom); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testdyngl.c --- a/test/testdyngl.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testdyngl.c Mon May 29 04:04:35 2006 +0000 @@ -29,21 +29,21 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } void * -get_funcaddr (const char *p) +get_funcaddr(const char *p) { - void *f = SDL_GL_GetProcAddress (p); + void *f = SDL_GL_GetProcAddress(p); if (f) { return f; } else { - printf ("Unable to get function pointer for %s\n", p); - quit (1); + printf("Unable to get function pointer for %s\n", p); + quit(1); } return NULL; } @@ -72,31 +72,31 @@ glfuncs; void -init_glfuncs (glfuncs * f) +init_glfuncs(glfuncs * f) { - f->glBegin = get_funcaddr ("glBegin"); - f->glEnd = get_funcaddr ("glEnd"); - f->glVertex3f = get_funcaddr ("glVertex3f"); - f->glClearColor = get_funcaddr ("glClearColor"); - f->glClear = get_funcaddr ("glClear"); - f->glDisable = get_funcaddr ("glDisable"); - f->glEnable = get_funcaddr ("glEnable"); - f->glColor4ub = get_funcaddr ("glColor4ub"); - f->glPointSize = get_funcaddr ("glPointSize"); - f->glHint = get_funcaddr ("glHint"); - f->glBlendFunc = get_funcaddr ("glBlendFunc"); - f->glMatrixMode = get_funcaddr ("glMatrixMode"); - f->glLoadIdentity = get_funcaddr ("glLoadIdentity"); - f->glOrtho = get_funcaddr ("glOrtho"); - f->glRotatef = get_funcaddr ("glRotatef"); - f->glViewport = get_funcaddr ("glViewport"); - f->glFogf = get_funcaddr ("glFogf"); + f->glBegin = get_funcaddr("glBegin"); + f->glEnd = get_funcaddr("glEnd"); + f->glVertex3f = get_funcaddr("glVertex3f"); + f->glClearColor = get_funcaddr("glClearColor"); + f->glClear = get_funcaddr("glClear"); + f->glDisable = get_funcaddr("glDisable"); + f->glEnable = get_funcaddr("glEnable"); + f->glColor4ub = get_funcaddr("glColor4ub"); + f->glPointSize = get_funcaddr("glPointSize"); + f->glHint = get_funcaddr("glHint"); + f->glBlendFunc = get_funcaddr("glBlendFunc"); + f->glMatrixMode = get_funcaddr("glMatrixMode"); + f->glLoadIdentity = get_funcaddr("glLoadIdentity"); + f->glOrtho = get_funcaddr("glOrtho"); + f->glRotatef = get_funcaddr("glRotatef"); + f->glViewport = get_funcaddr("glViewport"); + f->glFogf = get_funcaddr("glFogf"); } #define NB_PIXELS 1000 int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { glfuncs f; int i; @@ -109,96 +109,95 @@ gl_library = argv[1]; } - if (SDL_Init (SDL_INIT_VIDEO) < 0) { - printf ("Unable to init SDL : %s\n", SDL_GetError ()); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + printf("Unable to init SDL : %s\n", SDL_GetError()); return (1); } - if (SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1) < 0) { - printf ("Unable to set GL attribute : %s\n", SDL_GetError ()); - quit (1); + if (SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) < 0) { + printf("Unable to set GL attribute : %s\n", SDL_GetError()); + quit(1); } - if (SDL_GL_LoadLibrary (gl_library) < 0) { - printf ("Unable to dynamically open GL lib : %s\n", SDL_GetError ()); - quit (1); + if (SDL_GL_LoadLibrary(gl_library) < 0) { + printf("Unable to dynamically open GL lib : %s\n", SDL_GetError()); + quit(1); } - if (SDL_SetVideoMode (640, 480, 0, SDL_OPENGL) == NULL) { - printf ("Unable to open video mode : %s\n", SDL_GetError ()); - quit (1); + if (SDL_SetVideoMode(640, 480, 0, SDL_OPENGL) == NULL) { + printf("Unable to open video mode : %s\n", SDL_GetError()); + quit(1); } /* Set the window manager title bar */ - SDL_WM_SetCaption ("SDL Dynamic OpenGL Loading Test", "testdyngl"); + SDL_WM_SetCaption("SDL Dynamic OpenGL Loading Test", "testdyngl"); - init_glfuncs (&f); + init_glfuncs(&f); for (i = 0; i < NB_PIXELS; i++) { - pixels[3 * i] = rand () % 250 - 125; - pixels[3 * i + 1] = rand () % 250 - 125; - pixels[3 * i + 2] = rand () % 250 - 125; + pixels[3 * i] = rand() % 250 - 125; + pixels[3 * i + 1] = rand() % 250 - 125; + pixels[3 * i + 2] = rand() % 250 - 125; } - f.glViewport (0, 0, 640, 480); + f.glViewport(0, 0, 640, 480); - f.glMatrixMode (GL_PROJECTION); - f.glLoadIdentity (); - f.glOrtho (-100, 100, -100, 100, -500, 500); + f.glMatrixMode(GL_PROJECTION); + f.glLoadIdentity(); + f.glOrtho(-100, 100, -100, 100, -500, 500); - f.glMatrixMode (GL_MODELVIEW); - f.glLoadIdentity (); + f.glMatrixMode(GL_MODELVIEW); + f.glLoadIdentity(); - f.glEnable (GL_DEPTH_TEST); - f.glDisable (GL_TEXTURE_2D); - f.glEnable (GL_BLEND); - f.glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + f.glEnable(GL_DEPTH_TEST); + f.glDisable(GL_TEXTURE_2D); + f.glEnable(GL_BLEND); + f.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - f.glClearColor (0.0f, 0.0f, 0.0f, 0.0f); - f.glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + f.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + f.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - f.glEnable (GL_POINT_SMOOTH); - f.glHint (GL_POINT_SMOOTH_HINT, GL_NICEST); - f.glPointSize (5.0f); - f.glEnable (GL_FOG); - f.glFogf (GL_FOG_START, -500); - f.glFogf (GL_FOG_END, 500); - f.glFogf (GL_FOG_DENSITY, 0.005); + f.glEnable(GL_POINT_SMOOTH); + f.glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); + f.glPointSize(5.0f); + f.glEnable(GL_FOG); + f.glFogf(GL_FOG_START, -500); + f.glFogf(GL_FOG_END, 500); + f.glFogf(GL_FOG_DENSITY, 0.005); do { - f.glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + f.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - f.glRotatef (2.0, 1.0, 1.0, 1.0); - f.glRotatef (1.0, 0.0, 1.0, 1.0); + f.glRotatef(2.0, 1.0, 1.0, 1.0); + f.glRotatef(1.0, 0.0, 1.0, 1.0); - f.glColor4ub (255, 255, 255, 255); - f.glBegin (GL_POINTS); + f.glColor4ub(255, 255, 255, 255); + f.glBegin(GL_POINTS); for (i = 0; i < NB_PIXELS; i++) { - f.glVertex3f (pixels[3 * i], pixels[3 * i + 1], - pixels[3 * i + 2]); + f.glVertex3f(pixels[3 * i], pixels[3 * i + 1], pixels[3 * i + 2]); } - f.glEnd (); - SDL_GL_SwapBuffers (); + f.glEnd(); + SDL_GL_SwapBuffers(); - while (SDL_PollEvent (&event)) { + while (SDL_PollEvent(&event)) { if (event.type & SDL_KEYDOWN) done = 1; } - SDL_Delay (20); + SDL_Delay(20); } while (!done); - SDL_Quit (); + SDL_Quit(); return 0; } #else /* HAVE_OPENGL */ int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { - printf ("No OpenGL support on this system\n"); + printf("No OpenGL support on this system\n"); return 1; } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testerror.c --- a/test/testerror.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testerror.c Mon May 29 04:04:35 2006 +0000 @@ -12,53 +12,53 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } int SDLCALL -ThreadFunc (void *data) +ThreadFunc(void *data) { /* Set the child thread error string */ - SDL_SetError ("Thread %s (%d) had a problem: %s", - (char *) data, SDL_ThreadID (), "nevermind"); + SDL_SetError("Thread %s (%d) had a problem: %s", + (char *) data, SDL_ThreadID(), "nevermind"); while (alive) { - printf ("Thread '%s' is alive!\n", (char *) data); - SDL_Delay (1 * 1000); + printf("Thread '%s' is alive!\n", (char *) data); + SDL_Delay(1 * 1000); } - printf ("Child thread error string: %s\n", SDL_GetError ()); + printf("Child thread error string: %s\n", SDL_GetError()); return (0); } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SDL_Thread *thread; /* Load the SDL library */ - if (SDL_Init (0) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(0) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } /* Set the error value for the main thread */ - SDL_SetError ("No worries"); + SDL_SetError("No worries"); alive = 1; - thread = SDL_CreateThread (ThreadFunc, "#1"); + thread = SDL_CreateThread(ThreadFunc, "#1"); if (thread == NULL) { - fprintf (stderr, "Couldn't create thread: %s\n", SDL_GetError ()); - quit (1); + fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); + quit(1); } - SDL_Delay (5 * 1000); - printf ("Waiting for thread #1\n"); + SDL_Delay(5 * 1000); + printf("Waiting for thread #1\n"); alive = 0; - SDL_WaitThread (thread, NULL); + SDL_WaitThread(thread, NULL); - printf ("Main thread error string: %s\n", SDL_GetError ()); + printf("Main thread error string: %s\n", SDL_GetError()); - SDL_Quit (); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testfile.c --- a/test/testfile.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testfile.c Mon May 29 04:04:35 2006 +0000 @@ -20,23 +20,23 @@ #endif static void -cleanup (void) +cleanup(void) { - unlink (FBASENAME1); - unlink (FBASENAME2); + unlink(FBASENAME1); + unlink(FBASENAME2); } static void -rwops_error_quit (unsigned line, SDL_RWops * rwops) +rwops_error_quit(unsigned line, SDL_RWops * rwops) { - printf ("testfile.c(%d): failed\n", line); + printf("testfile.c(%d): failed\n", line); if (rwops) { - rwops->close (rwops); /* This calls SDL_FreeRW(rwops); */ + rwops->close(rwops); /* This calls SDL_FreeRW(rwops); */ } - cleanup (); - exit (1); /* quit with rwops error (test failed) */ + cleanup(); + exit(1); /* quit with rwops error (test failed) */ } #define RWOP_ERR_QUIT(x) rwops_error_quit( __LINE__, (x) ) @@ -44,218 +44,218 @@ int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SDL_RWops *rwops = NULL; char test_buf[30]; - cleanup (); + cleanup(); /* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */ - rwops = SDL_RWFromFile (NULL, NULL); + rwops = SDL_RWFromFile(NULL, NULL); if (rwops) - RWOP_ERR_QUIT (rwops); - rwops = SDL_RWFromFile (NULL, "ab+"); + RWOP_ERR_QUIT(rwops); + rwops = SDL_RWFromFile(NULL, "ab+"); if (rwops) - RWOP_ERR_QUIT (rwops); - rwops = SDL_RWFromFile (NULL, "sldfkjsldkfj"); + RWOP_ERR_QUIT(rwops); + rwops = SDL_RWFromFile(NULL, "sldfkjsldkfj"); if (rwops) - RWOP_ERR_QUIT (rwops); - rwops = SDL_RWFromFile ("something", ""); + RWOP_ERR_QUIT(rwops); + rwops = SDL_RWFromFile("something", ""); if (rwops) - RWOP_ERR_QUIT (rwops); - rwops = SDL_RWFromFile ("something", NULL); + RWOP_ERR_QUIT(rwops); + rwops = SDL_RWFromFile("something", NULL); if (rwops) - RWOP_ERR_QUIT (rwops); - printf ("test1 OK\n"); + RWOP_ERR_QUIT(rwops); + printf("test1 OK\n"); /* test 2 : check that inexistant file is not successfully opened/created when required */ /* modes : r, r+ implie that file MUST exist modes : a, a+, w, w+ checks that it succeeds (file may not exists) */ - rwops = SDL_RWFromFile (FBASENAME2, "rb"); /* this file doesn't exist that call must fail */ + rwops = SDL_RWFromFile(FBASENAME2, "rb"); /* this file doesn't exist that call must fail */ if (rwops) - RWOP_ERR_QUIT (rwops); - rwops = SDL_RWFromFile (FBASENAME2, "rb+"); /* this file doesn't exist that call must fail */ + RWOP_ERR_QUIT(rwops); + rwops = SDL_RWFromFile(FBASENAME2, "rb+"); /* this file doesn't exist that call must fail */ if (rwops) - RWOP_ERR_QUIT (rwops); - rwops = SDL_RWFromFile (FBASENAME2, "wb"); + RWOP_ERR_QUIT(rwops); + rwops = SDL_RWFromFile(FBASENAME2, "wb"); if (!rwops) - RWOP_ERR_QUIT (rwops); - rwops->close (rwops); - unlink (FBASENAME2); - rwops = SDL_RWFromFile (FBASENAME2, "wb+"); + RWOP_ERR_QUIT(rwops); + rwops->close(rwops); + unlink(FBASENAME2); + rwops = SDL_RWFromFile(FBASENAME2, "wb+"); if (!rwops) - RWOP_ERR_QUIT (rwops); - rwops->close (rwops); - unlink (FBASENAME2); - rwops = SDL_RWFromFile (FBASENAME2, "ab"); + RWOP_ERR_QUIT(rwops); + rwops->close(rwops); + unlink(FBASENAME2); + rwops = SDL_RWFromFile(FBASENAME2, "ab"); if (!rwops) - RWOP_ERR_QUIT (rwops); - rwops->close (rwops); - unlink (FBASENAME2); - rwops = SDL_RWFromFile (FBASENAME2, "ab+"); + RWOP_ERR_QUIT(rwops); + rwops->close(rwops); + unlink(FBASENAME2); + rwops = SDL_RWFromFile(FBASENAME2, "ab+"); if (!rwops) - RWOP_ERR_QUIT (rwops); - rwops->close (rwops); - unlink (FBASENAME2); - printf ("test2 OK\n"); + RWOP_ERR_QUIT(rwops); + rwops->close(rwops); + unlink(FBASENAME2); + printf("test2 OK\n"); /* test 3 : creation, writing , reading, seeking, test : w mode, r mode, w+ mode */ - rwops = SDL_RWFromFile (FBASENAME1, "wb"); /* write only */ + rwops = SDL_RWFromFile(FBASENAME1, "wb"); /* write only */ if (!rwops) - RWOP_ERR_QUIT (rwops); - if (1 != rwops->write (rwops, "1234567890", 10, 1)) - RWOP_ERR_QUIT (rwops); - if (10 != rwops->write (rwops, "1234567890", 1, 10)) - RWOP_ERR_QUIT (rwops); - if (7 != rwops->write (rwops, "1234567", 1, 7)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->read (rwops, test_buf, 1, 1)) - RWOP_ERR_QUIT (rwops); /* we are in write only mode */ - rwops->close (rwops); + RWOP_ERR_QUIT(rwops); + if (1 != rwops->write(rwops, "1234567890", 10, 1)) + RWOP_ERR_QUIT(rwops); + if (10 != rwops->write(rwops, "1234567890", 1, 10)) + RWOP_ERR_QUIT(rwops); + if (7 != rwops->write(rwops, "1234567", 1, 7)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->read(rwops, test_buf, 1, 1)) + RWOP_ERR_QUIT(rwops); /* we are in write only mode */ + rwops->close(rwops); - rwops = SDL_RWFromFile (FBASENAME1, "rb"); /* read mode, file must exists */ + rwops = SDL_RWFromFile(FBASENAME1, "rb"); /* read mode, file must exists */ if (!rwops) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET)) - RWOP_ERR_QUIT (rwops); - if (20 != rwops->seek (rwops, -7, RW_SEEK_END)) - RWOP_ERR_QUIT (rwops); - if (7 != rwops->read (rwops, test_buf, 1, 7)) - RWOP_ERR_QUIT (rwops); - if (SDL_memcmp (test_buf, "1234567", 7)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->read (rwops, test_buf, 1, 1)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->read (rwops, test_buf, 10, 100)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->seek (rwops, -27, RW_SEEK_CUR)) - RWOP_ERR_QUIT (rwops); - if (2 != rwops->read (rwops, test_buf, 10, 3)) - RWOP_ERR_QUIT (rwops); - if (SDL_memcmp (test_buf, "12345678901234567890", 20)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->write (rwops, test_buf, 1, 1)) - RWOP_ERR_QUIT (rwops); /* readonly mode */ - rwops->close (rwops); + RWOP_ERR_QUIT(rwops); + if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) + RWOP_ERR_QUIT(rwops); + if (20 != rwops->seek(rwops, -7, RW_SEEK_END)) + RWOP_ERR_QUIT(rwops); + if (7 != rwops->read(rwops, test_buf, 1, 7)) + RWOP_ERR_QUIT(rwops); + if (SDL_memcmp(test_buf, "1234567", 7)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->read(rwops, test_buf, 1, 1)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->read(rwops, test_buf, 10, 100)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->seek(rwops, -27, RW_SEEK_CUR)) + RWOP_ERR_QUIT(rwops); + if (2 != rwops->read(rwops, test_buf, 10, 3)) + RWOP_ERR_QUIT(rwops); + if (SDL_memcmp(test_buf, "12345678901234567890", 20)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->write(rwops, test_buf, 1, 1)) + RWOP_ERR_QUIT(rwops); /* readonly mode */ + rwops->close(rwops); /* test 3: same with w+ mode */ - rwops = SDL_RWFromFile (FBASENAME1, "wb+"); /* write + read + truncation */ + rwops = SDL_RWFromFile(FBASENAME1, "wb+"); /* write + read + truncation */ if (!rwops) - RWOP_ERR_QUIT (rwops); - if (1 != rwops->write (rwops, "1234567890", 10, 1)) - RWOP_ERR_QUIT (rwops); - if (10 != rwops->write (rwops, "1234567890", 1, 10)) - RWOP_ERR_QUIT (rwops); - if (7 != rwops->write (rwops, "1234567", 1, 7)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET)) - RWOP_ERR_QUIT (rwops); - if (1 != rwops->read (rwops, test_buf, 1, 1)) - RWOP_ERR_QUIT (rwops); /* we are in read/write mode */ - if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET)) - RWOP_ERR_QUIT (rwops); - if (20 != rwops->seek (rwops, -7, RW_SEEK_END)) - RWOP_ERR_QUIT (rwops); - if (7 != rwops->read (rwops, test_buf, 1, 7)) - RWOP_ERR_QUIT (rwops); - if (SDL_memcmp (test_buf, "1234567", 7)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->read (rwops, test_buf, 1, 1)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->read (rwops, test_buf, 10, 100)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->seek (rwops, -27, RW_SEEK_CUR)) - RWOP_ERR_QUIT (rwops); - if (2 != rwops->read (rwops, test_buf, 10, 3)) - RWOP_ERR_QUIT (rwops); - if (SDL_memcmp (test_buf, "12345678901234567890", 20)) - RWOP_ERR_QUIT (rwops); - rwops->close (rwops); - printf ("test3 OK\n"); + RWOP_ERR_QUIT(rwops); + if (1 != rwops->write(rwops, "1234567890", 10, 1)) + RWOP_ERR_QUIT(rwops); + if (10 != rwops->write(rwops, "1234567890", 1, 10)) + RWOP_ERR_QUIT(rwops); + if (7 != rwops->write(rwops, "1234567", 1, 7)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) + RWOP_ERR_QUIT(rwops); + if (1 != rwops->read(rwops, test_buf, 1, 1)) + RWOP_ERR_QUIT(rwops); /* we are in read/write mode */ + if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) + RWOP_ERR_QUIT(rwops); + if (20 != rwops->seek(rwops, -7, RW_SEEK_END)) + RWOP_ERR_QUIT(rwops); + if (7 != rwops->read(rwops, test_buf, 1, 7)) + RWOP_ERR_QUIT(rwops); + if (SDL_memcmp(test_buf, "1234567", 7)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->read(rwops, test_buf, 1, 1)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->read(rwops, test_buf, 10, 100)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->seek(rwops, -27, RW_SEEK_CUR)) + RWOP_ERR_QUIT(rwops); + if (2 != rwops->read(rwops, test_buf, 10, 3)) + RWOP_ERR_QUIT(rwops); + if (SDL_memcmp(test_buf, "12345678901234567890", 20)) + RWOP_ERR_QUIT(rwops); + rwops->close(rwops); + printf("test3 OK\n"); /* test 4: same in r+ mode */ - rwops = SDL_RWFromFile (FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */ + rwops = SDL_RWFromFile(FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */ if (!rwops) - RWOP_ERR_QUIT (rwops); - if (1 != rwops->write (rwops, "1234567890", 10, 1)) - RWOP_ERR_QUIT (rwops); - if (10 != rwops->write (rwops, "1234567890", 1, 10)) - RWOP_ERR_QUIT (rwops); - if (7 != rwops->write (rwops, "1234567", 1, 7)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET)) - RWOP_ERR_QUIT (rwops); - if (1 != rwops->read (rwops, test_buf, 1, 1)) - RWOP_ERR_QUIT (rwops); /* we are in read/write mode */ - if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET)) - RWOP_ERR_QUIT (rwops); - if (20 != rwops->seek (rwops, -7, RW_SEEK_END)) - RWOP_ERR_QUIT (rwops); - if (7 != rwops->read (rwops, test_buf, 1, 7)) - RWOP_ERR_QUIT (rwops); - if (SDL_memcmp (test_buf, "1234567", 7)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->read (rwops, test_buf, 1, 1)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->read (rwops, test_buf, 10, 100)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->seek (rwops, -27, RW_SEEK_CUR)) - RWOP_ERR_QUIT (rwops); - if (2 != rwops->read (rwops, test_buf, 10, 3)) - RWOP_ERR_QUIT (rwops); - if (SDL_memcmp (test_buf, "12345678901234567890", 20)) - RWOP_ERR_QUIT (rwops); - rwops->close (rwops); - printf ("test4 OK\n"); + RWOP_ERR_QUIT(rwops); + if (1 != rwops->write(rwops, "1234567890", 10, 1)) + RWOP_ERR_QUIT(rwops); + if (10 != rwops->write(rwops, "1234567890", 1, 10)) + RWOP_ERR_QUIT(rwops); + if (7 != rwops->write(rwops, "1234567", 1, 7)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) + RWOP_ERR_QUIT(rwops); + if (1 != rwops->read(rwops, test_buf, 1, 1)) + RWOP_ERR_QUIT(rwops); /* we are in read/write mode */ + if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) + RWOP_ERR_QUIT(rwops); + if (20 != rwops->seek(rwops, -7, RW_SEEK_END)) + RWOP_ERR_QUIT(rwops); + if (7 != rwops->read(rwops, test_buf, 1, 7)) + RWOP_ERR_QUIT(rwops); + if (SDL_memcmp(test_buf, "1234567", 7)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->read(rwops, test_buf, 1, 1)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->read(rwops, test_buf, 10, 100)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->seek(rwops, -27, RW_SEEK_CUR)) + RWOP_ERR_QUIT(rwops); + if (2 != rwops->read(rwops, test_buf, 10, 3)) + RWOP_ERR_QUIT(rwops); + if (SDL_memcmp(test_buf, "12345678901234567890", 20)) + RWOP_ERR_QUIT(rwops); + rwops->close(rwops); + printf("test4 OK\n"); /* test5 : append mode */ - rwops = SDL_RWFromFile (FBASENAME1, "ab+"); /* write + read + append */ + rwops = SDL_RWFromFile(FBASENAME1, "ab+"); /* write + read + append */ if (!rwops) - RWOP_ERR_QUIT (rwops); - if (1 != rwops->write (rwops, "1234567890", 10, 1)) - RWOP_ERR_QUIT (rwops); - if (10 != rwops->write (rwops, "1234567890", 1, 10)) - RWOP_ERR_QUIT (rwops); - if (7 != rwops->write (rwops, "1234567", 1, 7)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET)) - RWOP_ERR_QUIT (rwops); + RWOP_ERR_QUIT(rwops); + if (1 != rwops->write(rwops, "1234567890", 10, 1)) + RWOP_ERR_QUIT(rwops); + if (10 != rwops->write(rwops, "1234567890", 1, 10)) + RWOP_ERR_QUIT(rwops); + if (7 != rwops->write(rwops, "1234567", 1, 7)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) + RWOP_ERR_QUIT(rwops); - if (1 != rwops->read (rwops, test_buf, 1, 1)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET)) - RWOP_ERR_QUIT (rwops); + if (1 != rwops->read(rwops, test_buf, 1, 1)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) + RWOP_ERR_QUIT(rwops); - if (20 + 27 != rwops->seek (rwops, -7, RW_SEEK_END)) - RWOP_ERR_QUIT (rwops); - if (7 != rwops->read (rwops, test_buf, 1, 7)) - RWOP_ERR_QUIT (rwops); - if (SDL_memcmp (test_buf, "1234567", 7)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->read (rwops, test_buf, 1, 1)) - RWOP_ERR_QUIT (rwops); - if (0 != rwops->read (rwops, test_buf, 10, 100)) - RWOP_ERR_QUIT (rwops); + if (20 + 27 != rwops->seek(rwops, -7, RW_SEEK_END)) + RWOP_ERR_QUIT(rwops); + if (7 != rwops->read(rwops, test_buf, 1, 7)) + RWOP_ERR_QUIT(rwops); + if (SDL_memcmp(test_buf, "1234567", 7)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->read(rwops, test_buf, 1, 1)) + RWOP_ERR_QUIT(rwops); + if (0 != rwops->read(rwops, test_buf, 10, 100)) + RWOP_ERR_QUIT(rwops); - if (27 != rwops->seek (rwops, -27, RW_SEEK_CUR)) - RWOP_ERR_QUIT (rwops); + if (27 != rwops->seek(rwops, -27, RW_SEEK_CUR)) + RWOP_ERR_QUIT(rwops); - if (0 != rwops->seek (rwops, 0L, RW_SEEK_SET)) - RWOP_ERR_QUIT (rwops); - if (3 != rwops->read (rwops, test_buf, 10, 3)) - RWOP_ERR_QUIT (rwops); - if (SDL_memcmp (test_buf, "123456789012345678901234567123", 30)) - RWOP_ERR_QUIT (rwops); - rwops->close (rwops); - printf ("test5 OK\n"); - cleanup (); + if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) + RWOP_ERR_QUIT(rwops); + if (3 != rwops->read(rwops, test_buf, 10, 3)) + RWOP_ERR_QUIT(rwops); + if (SDL_memcmp(test_buf, "123456789012345678901234567123", 30)) + RWOP_ERR_QUIT(rwops); + rwops->close(rwops); + printf("test5 OK\n"); + cleanup(); return 0; /* all ok */ } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testgamma.c --- a/test/testgamma.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testgamma.c Mon May 29 04:04:35 2006 +0000 @@ -10,21 +10,21 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } /* Turn a normal gamma value into an appropriate gamma ramp */ void -CalculateGamma (double gamma, Uint16 * ramp) +CalculateGamma(double gamma, Uint16 * ramp) { int i, value; gamma = 1.0 / gamma; for (i = 0; i < 256; ++i) { - value = (int) (pow ((double) i / 256.0, gamma) * 65535.0 + 0.5); + value = (int) (pow((double) i / 256.0, gamma) * 65535.0 + 0.5); if (value > 65535) { value = 65535; } @@ -34,7 +34,7 @@ /* This can be used as a general routine for all of the test programs */ int -get_video_args (char *argv[], int *w, int *h, int *bpp, Uint32 * flags) +get_video_args(char *argv[], int *w, int *h, int *bpp, Uint32 * flags) { int i; @@ -44,23 +44,23 @@ *flags = SDL_SWSURFACE; for (i = 1; argv[i]; ++i) { - if (strcmp (argv[i], "-width") == 0) { + if (strcmp(argv[i], "-width") == 0) { if (argv[i + 1]) { - *w = atoi (argv[++i]); + *w = atoi(argv[++i]); } - } else if (strcmp (argv[i], "-height") == 0) { + } else if (strcmp(argv[i], "-height") == 0) { if (argv[i + 1]) { - *h = atoi (argv[++i]); + *h = atoi(argv[++i]); } - } else if (strcmp (argv[i], "-bpp") == 0) { + } else if (strcmp(argv[i], "-bpp") == 0) { if (argv[i + 1]) { - *bpp = atoi (argv[++i]); + *bpp = atoi(argv[++i]); } - } else if (strcmp (argv[i], "-fullscreen") == 0) { + } else if (strcmp(argv[i], "-fullscreen") == 0) { *flags |= SDL_FULLSCREEN; - } else if (strcmp (argv[i], "-hw") == 0) { + } else if (strcmp(argv[i], "-hw") == 0) { *flags |= SDL_HWSURFACE; - } else if (strcmp (argv[i], "-hwpalette") == 0) { + } else if (strcmp(argv[i], "-hwpalette") == 0) { *flags |= SDL_HWPALETTE; } else break; @@ -69,7 +69,7 @@ } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SDL_Surface *screen; SDL_Surface *image; @@ -82,47 +82,47 @@ Uint32 then, timeout; /* Check command line arguments */ - argv += get_video_args (argv, &w, &h, &bpp, &flags); + argv += get_video_args(argv, &w, &h, &bpp, &flags); /* Initialize SDL */ - if (SDL_Init (SDL_INIT_VIDEO) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } /* Initialize the display, always use hardware palette */ - screen = SDL_SetVideoMode (w, h, bpp, flags | SDL_HWPALETTE); + screen = SDL_SetVideoMode(w, h, bpp, flags | SDL_HWPALETTE); if (screen == NULL) { - fprintf (stderr, "Couldn't set %dx%d video mode: %s\n", - w, h, SDL_GetError ()); - quit (1); + fprintf(stderr, "Couldn't set %dx%d video mode: %s\n", + w, h, SDL_GetError()); + quit(1); } /* Set the window manager title bar */ - SDL_WM_SetCaption ("SDL gamma test", "testgamma"); + SDL_WM_SetCaption("SDL gamma test", "testgamma"); /* Set the desired gamma, if any */ gamma = 1.0f; if (*argv) { - gamma = (float) atof (*argv); + gamma = (float) atof(*argv); } - if (SDL_SetGamma (gamma, gamma, gamma) < 0) { - fprintf (stderr, "Unable to set gamma: %s\n", SDL_GetError ()); - quit (1); + if (SDL_SetGamma(gamma, gamma, gamma) < 0) { + fprintf(stderr, "Unable to set gamma: %s\n", SDL_GetError()); + quit(1); } #if 0 /* This isn't supported. Integrating the gamma ramps isn't exact */ /* See what gamma was actually set */ float real[3]; - if (SDL_GetGamma (&real[0], &real[1], &real[2]) < 0) { - printf ("Couldn't get gamma: %s\n", SDL_GetError ()); + if (SDL_GetGamma(&real[0], &real[1], &real[2]) < 0) { + printf("Couldn't get gamma: %s\n", SDL_GetError()); } else { - printf ("Set gamma values: R=%2.2f, G=%2.2f, B=%2.2f\n", - real[0], real[1], real[2]); + printf("Set gamma values: R=%2.2f, G=%2.2f, B=%2.2f\n", + real[0], real[1], real[2]); } #endif /* Do all the drawing work */ - image = SDL_LoadBMP ("sample.bmp"); + image = SDL_LoadBMP("sample.bmp"); if (image) { SDL_Rect dst; @@ -130,17 +130,17 @@ dst.y = (screen->h - image->h) / 2; dst.w = image->w; dst.h = image->h; - SDL_BlitSurface (image, NULL, screen, &dst); - SDL_UpdateRects (screen, 1, &dst); + SDL_BlitSurface(image, NULL, screen, &dst); + SDL_UpdateRects(screen, 1, &dst); } /* Wait a bit, handling events */ - then = SDL_GetTicks (); + then = SDL_GetTicks(); timeout = (5 * 1000); - while ((SDL_GetTicks () - then) < timeout) { + while ((SDL_GetTicks() - then) < timeout) { SDL_Event event; - while (SDL_PollEvent (&event)) { + while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: /* Quit now */ timeout = 0; @@ -152,11 +152,11 @@ break; case SDLK_UP: gamma += 0.2f; - SDL_SetGamma (gamma, gamma, gamma); + SDL_SetGamma(gamma, gamma, gamma); break; case SDLK_DOWN: gamma -= 0.2f; - SDL_SetGamma (gamma, gamma, gamma); + SDL_SetGamma(gamma, gamma, gamma); break; case SDLK_ESCAPE: timeout = 0; @@ -173,22 +173,22 @@ while (gamma < 10.0) { /* Increase the red gamma and decrease everything else... */ gamma += 0.1f; - CalculateGamma (gamma, red_ramp); - CalculateGamma (1.0 / gamma, ramp); - SDL_SetGammaRamp (red_ramp, ramp, ramp); + CalculateGamma(gamma, red_ramp); + CalculateGamma(1.0 / gamma, ramp); + SDL_SetGammaRamp(red_ramp, ramp, ramp); } /* Finish completely red */ - memset (red_ramp, 255, sizeof (red_ramp)); - memset (ramp, 0, sizeof (ramp)); - SDL_SetGammaRamp (red_ramp, ramp, ramp); + memset(red_ramp, 255, sizeof(red_ramp)); + memset(ramp, 0, sizeof(ramp)); + SDL_SetGammaRamp(red_ramp, ramp, ramp); /* Now fade out to black */ for (i = (red_ramp[0] >> 8); i >= 0; --i) { - memset (red_ramp, i, sizeof (red_ramp)); - SDL_SetGammaRamp (red_ramp, NULL, NULL); + memset(red_ramp, i, sizeof(red_ramp)); + SDL_SetGammaRamp(red_ramp, NULL, NULL); } - SDL_Delay (1 * 1000); + SDL_Delay(1 * 1000); - SDL_Quit (); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testgl.c --- a/test/testgl.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testgl.c Mon May 29 04:04:35 2006 +0000 @@ -26,48 +26,48 @@ /**********************************************************************/ void -HotKey_ToggleFullScreen (void) +HotKey_ToggleFullScreen(void) { SDL_Surface *screen; - screen = SDL_GetVideoSurface (); - if (SDL_WM_ToggleFullScreen (screen)) { - printf ("Toggled fullscreen mode - now %s\n", - (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed"); + screen = SDL_GetVideoSurface(); + if (SDL_WM_ToggleFullScreen(screen)) { + printf("Toggled fullscreen mode - now %s\n", + (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed"); } else { - printf ("Unable to toggle fullscreen mode\n"); + printf("Unable to toggle fullscreen mode\n"); } } void -HotKey_ToggleGrab (void) +HotKey_ToggleGrab(void) { SDL_GrabMode mode; - printf ("Ctrl-G: toggling input grab!\n"); - mode = SDL_WM_GrabInput (SDL_GRAB_QUERY); + printf("Ctrl-G: toggling input grab!\n"); + mode = SDL_WM_GrabInput(SDL_GRAB_QUERY); if (mode == SDL_GRAB_ON) { - printf ("Grab was on\n"); + printf("Grab was on\n"); } else { - printf ("Grab was off\n"); + printf("Grab was off\n"); } - mode = SDL_WM_GrabInput (!mode); + mode = SDL_WM_GrabInput(!mode); if (mode == SDL_GRAB_ON) { - printf ("Grab is now on\n"); + printf("Grab is now on\n"); } else { - printf ("Grab is now off\n"); + printf("Grab is now off\n"); } } void -HotKey_Iconify (void) +HotKey_Iconify(void) { - printf ("Ctrl-Z: iconifying window!\n"); - SDL_WM_IconifyWindow (); + printf("Ctrl-Z: iconifying window!\n"); + SDL_WM_IconifyWindow(); } int -HandleEvent (SDL_Event * event) +HandleEvent(SDL_Event * event) { int done; @@ -75,15 +75,15 @@ switch (event->type) { case SDL_ACTIVEEVENT: /* See what happened */ - printf ("app %s ", event->active.gain ? "gained" : "lost"); + printf("app %s ", event->active.gain ? "gained" : "lost"); if (event->active.state & SDL_APPACTIVE) { - printf ("active "); + printf("active "); } else if (event->active.state & SDL_APPMOUSEFOCUS) { - printf ("mouse "); + printf("mouse "); } else if (event->active.state & SDL_APPINPUTFOCUS) { - printf ("input "); + printf("input "); } - printf ("focus\n"); + printf("focus\n"); break; @@ -93,17 +93,17 @@ } if ((event->key.keysym.sym == SDLK_g) && (event->key.keysym.mod & KMOD_CTRL)) { - HotKey_ToggleGrab (); + HotKey_ToggleGrab(); } if ((event->key.keysym.sym == SDLK_z) && (event->key.keysym.mod & KMOD_CTRL)) { - HotKey_Iconify (); + HotKey_Iconify(); } if ((event->key.keysym.sym == SDLK_RETURN) && (event->key.keysym.mod & KMOD_ALT)) { - HotKey_ToggleFullScreen (); + HotKey_ToggleFullScreen(); } - printf ("key '%s' pressed\n", SDL_GetKeyName (event->key.keysym.sym)); + printf("key '%s' pressed\n", SDL_GetKeyName(event->key.keysym.sym)); break; case SDL_QUIT: done = 1; @@ -113,52 +113,52 @@ } void -SDL_GL_Enter2DMode () +SDL_GL_Enter2DMode() { - SDL_Surface *screen = SDL_GetVideoSurface (); + SDL_Surface *screen = SDL_GetVideoSurface(); /* Note, there may be other things you need to change, depending on how you have your OpenGL state set up. */ - glPushAttrib (GL_ENABLE_BIT); - glDisable (GL_DEPTH_TEST); - glDisable (GL_CULL_FACE); - glEnable (GL_TEXTURE_2D); + glPushAttrib(GL_ENABLE_BIT); + glDisable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); + glEnable(GL_TEXTURE_2D); /* This allows alpha blending of 2D textures with the scene */ - glEnable (GL_BLEND); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glViewport (0, 0, screen->w, screen->h); + glViewport(0, 0, screen->w, screen->h); - glMatrixMode (GL_PROJECTION); - glPushMatrix (); - glLoadIdentity (); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); - glOrtho (0.0, (GLdouble) screen->w, (GLdouble) screen->h, 0.0, 0.0, 1.0); + glOrtho(0.0, (GLdouble) screen->w, (GLdouble) screen->h, 0.0, 0.0, 1.0); - glMatrixMode (GL_MODELVIEW); - glPushMatrix (); - glLoadIdentity (); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); - glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); } void -SDL_GL_Leave2DMode () +SDL_GL_Leave2DMode() { - glMatrixMode (GL_MODELVIEW); - glPopMatrix (); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); - glMatrixMode (GL_PROJECTION); - glPopMatrix (); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); - glPopAttrib (); + glPopAttrib(); } /* Quick utility function for texture creation */ static int -power_of_two (int input) +power_of_two(int input) { int value = 1; @@ -169,7 +169,7 @@ } GLuint -SDL_GL_LoadTexture (SDL_Surface * surface, GLfloat * texcoord) +SDL_GL_LoadTexture(SDL_Surface * surface, GLfloat * texcoord) { GLuint texture; int w, h; @@ -179,20 +179,20 @@ Uint8 saved_alpha; /* Use the surface width and height expanded to powers of 2 */ - w = power_of_two (surface->w); - h = power_of_two (surface->h); + w = power_of_two(surface->w); + h = power_of_two(surface->h); texcoord[0] = 0.0f; /* Min X */ texcoord[1] = 0.0f; /* Min Y */ texcoord[2] = (GLfloat) surface->w / w; /* Max X */ texcoord[3] = (GLfloat) surface->h / h; /* Max Y */ - image = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h, 32, + image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ - 0x000000FF, - 0x0000FF00, 0x00FF0000, 0xFF000000 + 0x000000FF, + 0x0000FF00, 0x00FF0000, 0xFF000000 #else - 0xFF000000, - 0x00FF0000, 0x0000FF00, 0x000000FF + 0xFF000000, + 0x00FF0000, 0x0000FF00, 0x000000FF #endif ); if (image == NULL) { @@ -203,7 +203,7 @@ saved_flags = surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK); saved_alpha = surface->format->alpha; if ((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA) { - SDL_SetAlpha (surface, 0, 0); + SDL_SetAlpha(surface, 0, 0); } /* Copy the surface into the GL texture image */ @@ -211,28 +211,28 @@ area.y = 0; area.w = surface->w; area.h = surface->h; - SDL_BlitSurface (surface, &area, image, &area); + SDL_BlitSurface(surface, &area, image, &area); /* Restore the alpha blending attributes */ if ((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA) { - SDL_SetAlpha (surface, saved_flags, saved_alpha); + SDL_SetAlpha(surface, saved_flags, saved_alpha); } /* Create an OpenGL texture for the image */ - glGenTextures (1, &texture); - glBindTexture (GL_TEXTURE_2D, texture); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexImage2D (GL_TEXTURE_2D, - 0, - GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); - SDL_FreeSurface (image); /* No longer needed */ + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, + 0, + GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); + SDL_FreeSurface(image); /* No longer needed */ return texture; } void -DrawLogoCursor (void) +DrawLogoCursor(void) { static GLfloat texMinX, texMinY; static GLfloat texMaxX, texMaxY; @@ -244,7 +244,7 @@ GLfloat texcoord[4]; /* Load the image (could use SDL_image library here) */ - image = SDL_LoadBMP (LOGO_FILE); + image = SDL_LoadBMP(LOGO_FILE); if (image == NULL) { return; } @@ -252,7 +252,7 @@ h = image->h; /* Convert the image into an OpenGL texture */ - cursor_texture = SDL_GL_LoadTexture (image, texcoord); + cursor_texture = SDL_GL_LoadTexture(image, texcoord); /* Make texture coordinates easy to understand */ texMinX = texcoord[0]; @@ -261,7 +261,7 @@ texMaxY = texcoord[3]; /* We don't need the original image anymore */ - SDL_FreeSurface (image); + SDL_FreeSurface(image); /* Make sure that the texture conversion is okay */ if (!cursor_texture) { @@ -270,28 +270,28 @@ } /* Move the image around */ - SDL_GetMouseState (&x, &y); + SDL_GetMouseState(&x, &y); x -= w / 2; y -= h / 2; /* Show the image on the screen */ - SDL_GL_Enter2DMode (); - glBindTexture (GL_TEXTURE_2D, cursor_texture); - glBegin (GL_TRIANGLE_STRIP); - glTexCoord2f (texMinX, texMinY); - glVertex2i (x, y); - glTexCoord2f (texMaxX, texMinY); - glVertex2i (x + w, y); - glTexCoord2f (texMinX, texMaxY); - glVertex2i (x, y + h); - glTexCoord2f (texMaxX, texMaxY); - glVertex2i (x + w, y + h); - glEnd (); - SDL_GL_Leave2DMode (); + SDL_GL_Enter2DMode(); + glBindTexture(GL_TEXTURE_2D, cursor_texture); + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(texMinX, texMinY); + glVertex2i(x, y); + glTexCoord2f(texMaxX, texMinY); + glVertex2i(x + w, y); + glTexCoord2f(texMinX, texMaxY); + glVertex2i(x, y + h); + glTexCoord2f(texMaxX, texMaxY); + glVertex2i(x + w, y + h); + glEnd(); + SDL_GL_Leave2DMode(); } void -DrawLogoTexture (void) +DrawLogoTexture(void) { static GLfloat texMinX, texMinY; static GLfloat texMaxX, texMaxY; @@ -301,14 +301,14 @@ static int delta_x = 1; static int delta_y = 1; - SDL_Surface *screen = SDL_GetVideoSurface (); + SDL_Surface *screen = SDL_GetVideoSurface(); if (!global_texture) { SDL_Surface *image; GLfloat texcoord[4]; /* Load the image (could use SDL_image library here) */ - image = SDL_LoadBMP (LOGO_FILE); + image = SDL_LoadBMP(LOGO_FILE); if (image == NULL) { return; } @@ -316,7 +316,7 @@ h = image->h; /* Convert the image into an OpenGL texture */ - global_texture = SDL_GL_LoadTexture (image, texcoord); + global_texture = SDL_GL_LoadTexture(image, texcoord); /* Make texture coordinates easy to understand */ texMinX = texcoord[0]; @@ -325,7 +325,7 @@ texMaxY = texcoord[3]; /* We don't need the original image anymore */ - SDL_FreeSurface (image); + SDL_FreeSurface(image); /* Make sure that the texture conversion is okay */ if (!global_texture) { @@ -352,25 +352,25 @@ } /* Show the image on the screen */ - SDL_GL_Enter2DMode (); - glBindTexture (GL_TEXTURE_2D, global_texture); - glBegin (GL_TRIANGLE_STRIP); - glTexCoord2f (texMinX, texMinY); - glVertex2i (x, y); - glTexCoord2f (texMaxX, texMinY); - glVertex2i (x + w, y); - glTexCoord2f (texMinX, texMaxY); - glVertex2i (x, y + h); - glTexCoord2f (texMaxX, texMaxY); - glVertex2i (x + w, y + h); - glEnd (); - SDL_GL_Leave2DMode (); + SDL_GL_Enter2DMode(); + glBindTexture(GL_TEXTURE_2D, global_texture); + glBegin(GL_TRIANGLE_STRIP); + glTexCoord2f(texMinX, texMinY); + glVertex2i(x, y); + glTexCoord2f(texMaxX, texMinY); + glVertex2i(x + w, y); + glTexCoord2f(texMinX, texMaxY); + glVertex2i(x, y + h); + glTexCoord2f(texMaxX, texMaxY); + glVertex2i(x + w, y + h); + glEnd(); + SDL_GL_Leave2DMode(); } int -RunGLTest (int argc, char *argv[], - int logo, int logocursor, int slowly, int bpp, float gamma, - int noframe, int fsaa, int sync, int accel) +RunGLTest(int argc, char *argv[], + int logo, int logocursor, int slowly, int bpp, float gamma, + int noframe, int fsaa, int sync, int accel) { int i; int rgb_size[3]; @@ -400,14 +400,14 @@ Uint32 video_flags; int value; - if (SDL_Init (SDL_INIT_VIDEO) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); - exit (1); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + exit(1); } /* See if we should detect the display depth */ if (bpp == 0) { - if (SDL_GetVideoInfo ()->vfmt->BitsPerPixel <= 8) { + if (SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8) { bpp = 8; } else { bpp = 16; /* More doesn't seem to work */ @@ -417,7 +417,7 @@ /* Set the flags we want to use for setting the video mode */ video_flags = SDL_OPENGL; for (i = 1; argv[i]; ++i) { - if (strcmp (argv[i], "-fullscreen") == 0) { + if (strcmp(argv[i], "-fullscreen") == 0) { video_flags |= SDL_FULLSCREEN; } } @@ -445,88 +445,88 @@ rgb_size[2] = 8; break; } - SDL_GL_SetAttribute (SDL_GL_RED_SIZE, rgb_size[0]); - SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, rgb_size[1]); - SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, rgb_size[2]); - SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 16); - SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, rgb_size[0]); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, rgb_size[1]); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, rgb_size[2]); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if (fsaa) { - SDL_GL_SetAttribute (SDL_GL_MULTISAMPLEBUFFERS, 1); - SDL_GL_SetAttribute (SDL_GL_MULTISAMPLESAMPLES, fsaa); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa); } if (accel) { - SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); + SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); } if (sync) { - SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); + SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); } else { - SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 0); + SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0); } - if (SDL_SetVideoMode (w, h, bpp, video_flags) == NULL) { - fprintf (stderr, "Couldn't set GL mode: %s\n", SDL_GetError ()); - SDL_Quit (); - exit (1); + if (SDL_SetVideoMode(w, h, bpp, video_flags) == NULL) { + fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError()); + SDL_Quit(); + exit(1); } - printf ("Screen BPP: %d\n", SDL_GetVideoSurface ()->format->BitsPerPixel); - printf ("\n"); - printf ("Vendor : %s\n", glGetString (GL_VENDOR)); - printf ("Renderer : %s\n", glGetString (GL_RENDERER)); - printf ("Version : %s\n", glGetString (GL_VERSION)); - printf ("Extensions : %s\n", glGetString (GL_EXTENSIONS)); - printf ("\n"); + printf("Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel); + printf("\n"); + printf("Vendor : %s\n", glGetString(GL_VENDOR)); + printf("Renderer : %s\n", glGetString(GL_RENDERER)); + printf("Version : %s\n", glGetString(GL_VERSION)); + printf("Extensions : %s\n", glGetString(GL_EXTENSIONS)); + printf("\n"); - SDL_GL_GetAttribute (SDL_GL_RED_SIZE, &value); - printf ("SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0], value); - SDL_GL_GetAttribute (SDL_GL_GREEN_SIZE, &value); - printf ("SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1], value); - SDL_GL_GetAttribute (SDL_GL_BLUE_SIZE, &value); - printf ("SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2], value); - SDL_GL_GetAttribute (SDL_GL_DEPTH_SIZE, &value); - printf ("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value); - SDL_GL_GetAttribute (SDL_GL_DOUBLEBUFFER, &value); - printf ("SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value); + SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); + printf("SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0], value); + SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); + printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1], value); + SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); + printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2], value); + SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); + printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value); + SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &value); + printf("SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value); if (fsaa) { - SDL_GL_GetAttribute (SDL_GL_MULTISAMPLEBUFFERS, &value); - printf ("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); - SDL_GL_GetAttribute (SDL_GL_MULTISAMPLESAMPLES, &value); - printf ("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, - value); + SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); + printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); + SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); + printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, + value); } if (accel) { - SDL_GL_GetAttribute (SDL_GL_ACCELERATED_VISUAL, &value); - printf ("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); + SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); + printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); } if (sync) { - SDL_GL_GetAttribute (SDL_GL_SWAP_CONTROL, &value); - printf ("SDL_GL_SWAP_CONTROL: requested 1, got %d\n", value); + SDL_GL_GetAttribute(SDL_GL_SWAP_CONTROL, &value); + printf("SDL_GL_SWAP_CONTROL: requested 1, got %d\n", value); } /* Set the window manager title bar */ - SDL_WM_SetCaption ("SDL GL test", "testgl"); + SDL_WM_SetCaption("SDL GL test", "testgl"); /* Set the gamma for the window */ if (gamma != 0.0) { - SDL_SetGamma (gamma, gamma, gamma); + SDL_SetGamma(gamma, gamma, gamma); } - glViewport (0, 0, w, h); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); - glOrtho (-2.0, 2.0, -2.0, 2.0, -20.0, 20.0); + glOrtho(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); - glEnable (GL_DEPTH_TEST); + glEnable(GL_DEPTH_TEST); - glDepthFunc (GL_LESS); + glDepthFunc(GL_LESS); - glShadeModel (GL_SMOOTH); + glShadeModel(GL_SMOOTH); /* Loop until done. */ - start_time = SDL_GetTicks (); + start_time = SDL_GetTicks(); frames = 0; while (!done) { GLenum gl_error; @@ -534,171 +534,171 @@ SDL_Event event; /* Do our drawing, too. */ - glClearColor (0.0, 0.0, 0.0, 1.0); - glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClearColor(0.0, 0.0, 0.0, 1.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glBegin (GL_QUADS); + glBegin(GL_QUADS); #ifdef SHADED_CUBE - glColor3fv (color[0]); - glVertex3fv (cube[0]); - glColor3fv (color[1]); - glVertex3fv (cube[1]); - glColor3fv (color[2]); - glVertex3fv (cube[2]); - glColor3fv (color[3]); - glVertex3fv (cube[3]); + glColor3fv(color[0]); + glVertex3fv(cube[0]); + glColor3fv(color[1]); + glVertex3fv(cube[1]); + glColor3fv(color[2]); + glVertex3fv(cube[2]); + glColor3fv(color[3]); + glVertex3fv(cube[3]); - glColor3fv (color[3]); - glVertex3fv (cube[3]); - glColor3fv (color[4]); - glVertex3fv (cube[4]); - glColor3fv (color[7]); - glVertex3fv (cube[7]); - glColor3fv (color[2]); - glVertex3fv (cube[2]); + glColor3fv(color[3]); + glVertex3fv(cube[3]); + glColor3fv(color[4]); + glVertex3fv(cube[4]); + glColor3fv(color[7]); + glVertex3fv(cube[7]); + glColor3fv(color[2]); + glVertex3fv(cube[2]); - glColor3fv (color[0]); - glVertex3fv (cube[0]); - glColor3fv (color[5]); - glVertex3fv (cube[5]); - glColor3fv (color[6]); - glVertex3fv (cube[6]); - glColor3fv (color[1]); - glVertex3fv (cube[1]); + glColor3fv(color[0]); + glVertex3fv(cube[0]); + glColor3fv(color[5]); + glVertex3fv(cube[5]); + glColor3fv(color[6]); + glVertex3fv(cube[6]); + glColor3fv(color[1]); + glVertex3fv(cube[1]); - glColor3fv (color[5]); - glVertex3fv (cube[5]); - glColor3fv (color[4]); - glVertex3fv (cube[4]); - glColor3fv (color[7]); - glVertex3fv (cube[7]); - glColor3fv (color[6]); - glVertex3fv (cube[6]); + glColor3fv(color[5]); + glVertex3fv(cube[5]); + glColor3fv(color[4]); + glVertex3fv(cube[4]); + glColor3fv(color[7]); + glVertex3fv(cube[7]); + glColor3fv(color[6]); + glVertex3fv(cube[6]); - glColor3fv (color[5]); - glVertex3fv (cube[5]); - glColor3fv (color[0]); - glVertex3fv (cube[0]); - glColor3fv (color[3]); - glVertex3fv (cube[3]); - glColor3fv (color[4]); - glVertex3fv (cube[4]); + glColor3fv(color[5]); + glVertex3fv(cube[5]); + glColor3fv(color[0]); + glVertex3fv(cube[0]); + glColor3fv(color[3]); + glVertex3fv(cube[3]); + glColor3fv(color[4]); + glVertex3fv(cube[4]); - glColor3fv (color[6]); - glVertex3fv (cube[6]); - glColor3fv (color[1]); - glVertex3fv (cube[1]); - glColor3fv (color[2]); - glVertex3fv (cube[2]); - glColor3fv (color[7]); - glVertex3fv (cube[7]); + glColor3fv(color[6]); + glVertex3fv(cube[6]); + glColor3fv(color[1]); + glVertex3fv(cube[1]); + glColor3fv(color[2]); + glVertex3fv(cube[2]); + glColor3fv(color[7]); + glVertex3fv(cube[7]); #else /* flat cube */ - glColor3f (1.0, 0.0, 0.0); - glVertex3fv (cube[0]); - glVertex3fv (cube[1]); - glVertex3fv (cube[2]); - glVertex3fv (cube[3]); + glColor3f(1.0, 0.0, 0.0); + glVertex3fv(cube[0]); + glVertex3fv(cube[1]); + glVertex3fv(cube[2]); + glVertex3fv(cube[3]); - glColor3f (0.0, 1.0, 0.0); - glVertex3fv (cube[3]); - glVertex3fv (cube[4]); - glVertex3fv (cube[7]); - glVertex3fv (cube[2]); + glColor3f(0.0, 1.0, 0.0); + glVertex3fv(cube[3]); + glVertex3fv(cube[4]); + glVertex3fv(cube[7]); + glVertex3fv(cube[2]); - glColor3f (0.0, 0.0, 1.0); - glVertex3fv (cube[0]); - glVertex3fv (cube[5]); - glVertex3fv (cube[6]); - glVertex3fv (cube[1]); + glColor3f(0.0, 0.0, 1.0); + glVertex3fv(cube[0]); + glVertex3fv(cube[5]); + glVertex3fv(cube[6]); + glVertex3fv(cube[1]); - glColor3f (0.0, 1.0, 1.0); - glVertex3fv (cube[5]); - glVertex3fv (cube[4]); - glVertex3fv (cube[7]); - glVertex3fv (cube[6]); + glColor3f(0.0, 1.0, 1.0); + glVertex3fv(cube[5]); + glVertex3fv(cube[4]); + glVertex3fv(cube[7]); + glVertex3fv(cube[6]); - glColor3f (1.0, 1.0, 0.0); - glVertex3fv (cube[5]); - glVertex3fv (cube[0]); - glVertex3fv (cube[3]); - glVertex3fv (cube[4]); + glColor3f(1.0, 1.0, 0.0); + glVertex3fv(cube[5]); + glVertex3fv(cube[0]); + glVertex3fv(cube[3]); + glVertex3fv(cube[4]); - glColor3f (1.0, 0.0, 1.0); - glVertex3fv (cube[6]); - glVertex3fv (cube[1]); - glVertex3fv (cube[2]); - glVertex3fv (cube[7]); + glColor3f(1.0, 0.0, 1.0); + glVertex3fv(cube[6]); + glVertex3fv(cube[1]); + glVertex3fv(cube[2]); + glVertex3fv(cube[7]); #endif /* SHADED_CUBE */ - glEnd (); + glEnd(); - glMatrixMode (GL_MODELVIEW); - glRotatef (5.0, 1.0, 1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glRotatef(5.0, 1.0, 1.0, 1.0); /* Draw 2D logo onto the 3D display */ if (logo) { - DrawLogoTexture (); + DrawLogoTexture(); } if (logocursor) { - DrawLogoCursor (); + DrawLogoCursor(); } - SDL_GL_SwapBuffers (); + SDL_GL_SwapBuffers(); /* Check for error conditions. */ - gl_error = glGetError (); + gl_error = glGetError(); if (gl_error != GL_NO_ERROR) { - fprintf (stderr, "testgl: OpenGL error: %d\n", gl_error); + fprintf(stderr, "testgl: OpenGL error: %d\n", gl_error); } - sdl_error = SDL_GetError (); + sdl_error = SDL_GetError(); if (sdl_error[0] != '\0') { - fprintf (stderr, "testgl: SDL error '%s'\n", sdl_error); - SDL_ClearError (); + fprintf(stderr, "testgl: SDL error '%s'\n", sdl_error); + SDL_ClearError(); } /* Allow the user to see what's happening */ if (slowly) { - SDL_Delay (20); + SDL_Delay(20); } /* Check if there's a pending event. */ - while (SDL_PollEvent (&event)) { - done = HandleEvent (&event); + while (SDL_PollEvent(&event)) { + done = HandleEvent(&event); } ++frames; } /* Print out the frames per second */ - this_time = SDL_GetTicks (); + this_time = SDL_GetTicks(); if (this_time != start_time) { - printf ("%2.2f FPS\n", - ((float) frames / (this_time - start_time)) * 1000.0); + printf("%2.2f FPS\n", + ((float) frames / (this_time - start_time)) * 1000.0); } if (global_image) { - SDL_FreeSurface (global_image); + SDL_FreeSurface(global_image); global_image = NULL; } if (global_texture) { - glDeleteTextures (1, &global_texture); + glDeleteTextures(1, &global_texture); global_texture = 0; } if (cursor_texture) { - glDeleteTextures (1, &cursor_texture); + glDeleteTextures(1, &cursor_texture); cursor_texture = 0; } /* Destroy our GL context, etc. */ - SDL_Quit (); + SDL_Quit(); return (0); } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { int i, logo, logocursor = 0; int numtests; @@ -714,46 +714,46 @@ slowly = 0; numtests = 1; for (i = 1; argv[i]; ++i) { - if (strcmp (argv[i], "-twice") == 0) { + if (strcmp(argv[i], "-twice") == 0) { ++numtests; } - if (strcmp (argv[i], "-logo") == 0) { + if (strcmp(argv[i], "-logo") == 0) { logo = 1; } - if (strcmp (argv[i], "-logocursor") == 0) { + if (strcmp(argv[i], "-logocursor") == 0) { logocursor = 1; } - if (strcmp (argv[i], "-slow") == 0) { + if (strcmp(argv[i], "-slow") == 0) { slowly = 1; } - if (strcmp (argv[i], "-bpp") == 0) { - bpp = atoi (argv[++i]); + if (strcmp(argv[i], "-bpp") == 0) { + bpp = atoi(argv[++i]); } - if (strcmp (argv[i], "-gamma") == 0) { - gamma = (float) atof (argv[++i]); + if (strcmp(argv[i], "-gamma") == 0) { + gamma = (float) atof(argv[++i]); } - if (strcmp (argv[i], "-noframe") == 0) { + if (strcmp(argv[i], "-noframe") == 0) { noframe = 1; } - if (strcmp (argv[i], "-fsaa") == 0) { + if (strcmp(argv[i], "-fsaa") == 0) { ++fsaa; } - if (strcmp (argv[i], "-accel") == 0) { + if (strcmp(argv[i], "-accel") == 0) { ++accel; } - if (strcmp (argv[i], "-sync") == 0) { + if (strcmp(argv[i], "-sync") == 0) { ++sync; } - if (strncmp (argv[i], "-h", 2) == 0) { + if (strncmp(argv[i], "-h", 2) == 0) { printf ("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-fullscreen]\n", argv[0]); - exit (0); + exit(0); } } for (i = 0; i < numtests; ++i) { - RunGLTest (argc, argv, logo, logocursor, slowly, bpp, gamma, - noframe, fsaa, sync, accel); + RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma, + noframe, fsaa, sync, accel); } return 0; } @@ -761,9 +761,9 @@ #else /* HAVE_OPENGL */ int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { - printf ("No OpenGL support on this system\n"); + printf("No OpenGL support on this system\n"); return 1; } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testhread.c --- a/test/testhread.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testhread.c Mon May 29 04:04:35 2006 +0000 @@ -12,75 +12,75 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } int SDLCALL -ThreadFunc (void *data) +ThreadFunc(void *data) { - printf ("Started thread %s: My thread id is %u\n", - (char *) data, SDL_ThreadID ()); + printf("Started thread %s: My thread id is %u\n", + (char *) data, SDL_ThreadID()); while (alive) { - printf ("Thread '%s' is alive!\n", (char *) data); - SDL_Delay (1 * 1000); + printf("Thread '%s' is alive!\n", (char *) data); + SDL_Delay(1 * 1000); } - printf ("Thread '%s' exiting!\n", (char *) data); + printf("Thread '%s' exiting!\n", (char *) data); return (0); } static void -killed (int sig) +killed(int sig) { - printf ("Killed with SIGTERM, waiting 5 seconds to exit\n"); - SDL_Delay (5 * 1000); + printf("Killed with SIGTERM, waiting 5 seconds to exit\n"); + SDL_Delay(5 * 1000); alive = 0; - quit (0); + quit(0); } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SDL_Thread *thread; /* Load the SDL library */ - if (SDL_Init (0) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(0) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } alive = 1; - thread = SDL_CreateThread (ThreadFunc, "#1"); + thread = SDL_CreateThread(ThreadFunc, "#1"); if (thread == NULL) { - fprintf (stderr, "Couldn't create thread: %s\n", SDL_GetError ()); - quit (1); + fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); + quit(1); } - SDL_Delay (5 * 1000); - printf ("Waiting for thread #1\n"); + SDL_Delay(5 * 1000); + printf("Waiting for thread #1\n"); alive = 0; - SDL_WaitThread (thread, NULL); + SDL_WaitThread(thread, NULL); alive = 1; - thread = SDL_CreateThread (ThreadFunc, "#2"); + thread = SDL_CreateThread(ThreadFunc, "#2"); if (thread == NULL) { - fprintf (stderr, "Couldn't create thread: %s\n", SDL_GetError ()); - quit (1); + fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); + quit(1); } - SDL_Delay (5 * 1000); - printf ("Killing thread #2\n"); - SDL_KillThread (thread); + SDL_Delay(5 * 1000); + printf("Killing thread #2\n"); + SDL_KillThread(thread); alive = 1; - signal (SIGTERM, killed); - thread = SDL_CreateThread (ThreadFunc, "#3"); + signal(SIGTERM, killed); + thread = SDL_CreateThread(ThreadFunc, "#3"); if (thread == NULL) { - fprintf (stderr, "Couldn't create thread: %s\n", SDL_GetError ()); - quit (1); + fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); + quit(1); } - raise (SIGTERM); + raise(SIGTERM); - SDL_Quit (); /* Never reached */ + SDL_Quit(); /* Never reached */ return (0); /* Never reached */ } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testiconv.c --- a/test/testiconv.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testiconv.c Mon May 29 04:04:35 2006 +0000 @@ -4,7 +4,7 @@ #include "SDL.h" static size_t -widelen (char *data) +widelen(char *data) { size_t len = 0; Uint32 *p = (Uint32 *) data; @@ -15,7 +15,7 @@ } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { const char *formats[] = { "UTF8", @@ -41,33 +41,33 @@ if (!argv[1]) { argv[1] = "utf8.txt"; } - file = fopen (argv[1], "rb"); + file = fopen(argv[1], "rb"); if (!file) { - fprintf (stderr, "Unable to open %s\n", argv[1]); + fprintf(stderr, "Unable to open %s\n", argv[1]); return (1); } - while (fgets (buffer, sizeof (buffer), file)) { + while (fgets(buffer, sizeof(buffer), file)) { /* Convert to UCS-4 */ size_t len; ucs4 = - SDL_iconv_string ("UCS-4", "UTF-8", buffer, - SDL_strlen (buffer) + 1); - len = (widelen (ucs4) + 1) * 4; - for (i = 0; i < SDL_arraysize (formats); ++i) { - test[0] = SDL_iconv_string (formats[i], "UCS-4", ucs4, len); - test[1] = SDL_iconv_string ("UCS-4", formats[i], test[0], len); - if (SDL_memcmp (test[1], ucs4, len) != 0) { - fprintf (stderr, "FAIL: %s\n", formats[i]); + SDL_iconv_string("UCS-4", "UTF-8", buffer, + SDL_strlen(buffer) + 1); + len = (widelen(ucs4) + 1) * 4; + for (i = 0; i < SDL_arraysize(formats); ++i) { + test[0] = SDL_iconv_string(formats[i], "UCS-4", ucs4, len); + test[1] = SDL_iconv_string("UCS-4", formats[i], test[0], len); + if (SDL_memcmp(test[1], ucs4, len) != 0) { + fprintf(stderr, "FAIL: %s\n", formats[i]); ++errors; } - SDL_free (test[0]); - SDL_free (test[1]); + SDL_free(test[0]); + SDL_free(test[1]); } - test[0] = SDL_iconv_string ("UTF-8", "UCS-4", ucs4, len); - SDL_free (ucs4); - fputs (test[0], stdout); - SDL_free (test[0]); + test[0] = SDL_iconv_string("UTF-8", "UCS-4", ucs4, len); + SDL_free(ucs4); + fputs(test[0], stdout); + SDL_free(test[0]); } return (errors ? errors + 1 : 0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testjoystick.c --- a/test/testjoystick.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testjoystick.c Mon May 29 04:04:35 2006 +0000 @@ -11,7 +11,7 @@ #define SCREEN_HEIGHT 480 void -WatchJoystick (SDL_Joystick * joystick) +WatchJoystick(SDL_Joystick * joystick) { SDL_Surface *screen; const char *name; @@ -21,62 +21,61 @@ SDL_Rect axis_area[6][2]; /* Set a video mode to display joystick axis position */ - screen = SDL_SetVideoMode (SCREEN_WIDTH, SCREEN_HEIGHT, 16, 0); + screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16, 0); if (screen == NULL) { - fprintf (stderr, "Couldn't set video mode: %s\n", SDL_GetError ()); + fprintf(stderr, "Couldn't set video mode: %s\n", SDL_GetError()); return; } /* Print info about the joystick we are watching */ - name = SDL_JoystickName (SDL_JoystickIndex (joystick)); - printf ("Watching joystick %d: (%s)\n", SDL_JoystickIndex (joystick), - name ? name : "Unknown Joystick"); - printf ("Joystick has %d axes, %d hats, %d balls, and %d buttons\n", - SDL_JoystickNumAxes (joystick), SDL_JoystickNumHats (joystick), - SDL_JoystickNumBalls (joystick), - SDL_JoystickNumButtons (joystick)); + name = SDL_JoystickName(SDL_JoystickIndex(joystick)); + printf("Watching joystick %d: (%s)\n", SDL_JoystickIndex(joystick), + name ? name : "Unknown Joystick"); + printf("Joystick has %d axes, %d hats, %d balls, and %d buttons\n", + SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick), + SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick)); /* Initialize drawing rectangles */ - memset (axis_area, 0, (sizeof axis_area)); + memset(axis_area, 0, (sizeof axis_area)); draw = 0; /* Loop, getting joystick events! */ done = 0; while (!done) { - while (SDL_PollEvent (&event)) { + while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_JOYAXISMOTION: - printf ("Joystick %d axis %d value: %d\n", - event.jaxis.which, - event.jaxis.axis, event.jaxis.value); + printf("Joystick %d axis %d value: %d\n", + event.jaxis.which, + event.jaxis.axis, event.jaxis.value); break; case SDL_JOYHATMOTION: - printf ("Joystick %d hat %d value:", - event.jhat.which, event.jhat.hat); + printf("Joystick %d hat %d value:", + event.jhat.which, event.jhat.hat); if (event.jhat.value == SDL_HAT_CENTERED) - printf (" centered"); + printf(" centered"); if (event.jhat.value & SDL_HAT_UP) - printf (" up"); + printf(" up"); if (event.jhat.value & SDL_HAT_RIGHT) - printf (" right"); + printf(" right"); if (event.jhat.value & SDL_HAT_DOWN) - printf (" down"); + printf(" down"); if (event.jhat.value & SDL_HAT_LEFT) - printf (" left"); - printf ("\n"); + printf(" left"); + printf("\n"); break; case SDL_JOYBALLMOTION: - printf ("Joystick %d ball %d delta: (%d,%d)\n", - event.jball.which, - event.jball.ball, event.jball.xrel, event.jball.yrel); + printf("Joystick %d ball %d delta: (%d,%d)\n", + event.jball.which, + event.jball.ball, event.jball.xrel, event.jball.yrel); break; case SDL_JOYBUTTONDOWN: - printf ("Joystick %d button %d down\n", - event.jbutton.which, event.jbutton.button); + printf("Joystick %d button %d down\n", + event.jbutton.which, event.jbutton.button); break; case SDL_JOYBUTTONUP: - printf ("Joystick %d button %d up\n", - event.jbutton.which, event.jbutton.button); + printf("Joystick %d button %d up\n", + event.jbutton.which, event.jbutton.button); break; case SDL_KEYDOWN: if (event.key.keysym.sym != SDLK_ESCAPE) { @@ -91,30 +90,30 @@ } } /* Update visual joystick state */ - for (i = 0; i < SDL_JoystickNumButtons (joystick); ++i) { + for (i = 0; i < SDL_JoystickNumButtons(joystick); ++i) { SDL_Rect area; area.x = i * 34; area.y = SCREEN_HEIGHT - 34; area.w = 32; area.h = 32; - if (SDL_JoystickGetButton (joystick, i) == SDL_PRESSED) { - SDL_FillRect (screen, &area, 0xFFFF); + if (SDL_JoystickGetButton(joystick, i) == SDL_PRESSED) { + SDL_FillRect(screen, &area, 0xFFFF); } else { - SDL_FillRect (screen, &area, 0x0000); + SDL_FillRect(screen, &area, 0x0000); } - SDL_UpdateRects (screen, 1, &area); + SDL_UpdateRects(screen, 1, &area); } for (i = 0; - i < SDL_JoystickNumAxes (joystick) / 2 - && i < SDL_arraysize (axis_area); ++i) { + i < SDL_JoystickNumAxes(joystick) / 2 + && i < SDL_arraysize(axis_area); ++i) { /* Erase previous axes */ - SDL_FillRect (screen, &axis_area[i][draw], 0x0000); + SDL_FillRect(screen, &axis_area[i][draw], 0x0000); /* Draw the X/Y axis */ draw = !draw; - x = (((int) SDL_JoystickGetAxis (joystick, i * 2 + 0)) + 32768); + x = (((int) SDL_JoystickGetAxis(joystick, i * 2 + 0)) + 32768); x *= SCREEN_WIDTH; x /= 65535; if (x < 0) { @@ -122,7 +121,7 @@ } else if (x > (SCREEN_WIDTH - 16)) { x = SCREEN_WIDTH - 16; } - y = (((int) SDL_JoystickGetAxis (joystick, i * 2 + 1)) + 32768); + y = (((int) SDL_JoystickGetAxis(joystick, i * 2 + 1)) + 32768); y *= SCREEN_HEIGHT; y /= 65535; if (y < 0) { @@ -134,44 +133,44 @@ axis_area[i][draw].y = (Sint16) y; axis_area[i][draw].w = 16; axis_area[i][draw].h = 16; - SDL_FillRect (screen, &axis_area[i][draw], 0xFFFF); + SDL_FillRect(screen, &axis_area[i][draw], 0xFFFF); - SDL_UpdateRects (screen, 2, axis_area[i]); + SDL_UpdateRects(screen, 2, axis_area[i]); } } } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { const char *name; int i; SDL_Joystick *joystick; /* Initialize SDL (Note: video is required to start event loop) */ - if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); - exit (1); + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + exit(1); } /* Print information about the joysticks */ - printf ("There are %d joysticks attached\n", SDL_NumJoysticks ()); - for (i = 0; i < SDL_NumJoysticks (); ++i) { - name = SDL_JoystickName (i); - printf ("Joystick %d: %s\n", i, name ? name : "Unknown Joystick"); + printf("There are %d joysticks attached\n", SDL_NumJoysticks()); + for (i = 0; i < SDL_NumJoysticks(); ++i) { + name = SDL_JoystickName(i); + printf("Joystick %d: %s\n", i, name ? name : "Unknown Joystick"); } if (argv[1]) { - joystick = SDL_JoystickOpen (atoi (argv[1])); + joystick = SDL_JoystickOpen(atoi(argv[1])); if (joystick == NULL) { - printf ("Couldn't open joystick %d: %s\n", atoi (argv[1]), - SDL_GetError ()); + printf("Couldn't open joystick %d: %s\n", atoi(argv[1]), + SDL_GetError()); } else { - WatchJoystick (joystick); - SDL_JoystickClose (joystick); + WatchJoystick(joystick); + SDL_JoystickClose(joystick); } } - SDL_QuitSubSystem (SDL_INIT_VIDEO | SDL_INIT_JOYSTICK); + SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testkeys.c --- a/test/testkeys.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testkeys.c Mon May 29 04:04:35 2006 +0000 @@ -9,17 +9,17 @@ #include "SDL.h" int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SDLKey key; - if (SDL_Init (SDL_INIT_VIDEO) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); - exit (1); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + exit(1); } for (key = SDLK_FIRST; key < SDLK_LAST; ++key) { - printf ("Key #%d, \"%s\"\n", key, SDL_GetKeyName (key)); + printf("Key #%d, \"%s\"\n", key, SDL_GetKeyName(key)); } - SDL_Quit (); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testlock.c --- a/test/testlock.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testlock.c Mon May 29 04:04:35 2006 +0000 @@ -20,91 +20,91 @@ * calling conventions may differ... */ static void -SDL_Quit_Wrapper (void) +SDL_Quit_Wrapper(void) { - SDL_Quit (); + SDL_Quit(); } void -printid (void) +printid(void) { - printf ("Process %u: exiting\n", SDL_ThreadID ()); + printf("Process %u: exiting\n", SDL_ThreadID()); } void -terminate (int sig) +terminate(int sig) { - signal (SIGINT, terminate); + signal(SIGINT, terminate); doterminate = 1; } void -closemutex (int sig) +closemutex(int sig) { - Uint32 id = SDL_ThreadID (); + Uint32 id = SDL_ThreadID(); int i; - printf ("Process %u: Cleaning up...\n", id == mainthread ? 0 : id); + printf("Process %u: Cleaning up...\n", id == mainthread ? 0 : id); for (i = 0; i < 6; ++i) - SDL_KillThread (threads[i]); - SDL_DestroyMutex (mutex); - exit (sig); + SDL_KillThread(threads[i]); + SDL_DestroyMutex(mutex); + exit(sig); } int SDLCALL -Run (void *data) +Run(void *data) { - if (SDL_ThreadID () == mainthread) - signal (SIGTERM, closemutex); + if (SDL_ThreadID() == mainthread) + signal(SIGTERM, closemutex); while (1) { - printf ("Process %u ready to work\n", SDL_ThreadID ()); - if (SDL_mutexP (mutex) < 0) { - fprintf (stderr, "Couldn't lock mutex: %s", SDL_GetError ()); - exit (1); + printf("Process %u ready to work\n", SDL_ThreadID()); + if (SDL_mutexP(mutex) < 0) { + fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError()); + exit(1); } - printf ("Process %u, working!\n", SDL_ThreadID ()); - SDL_Delay (1 * 1000); - printf ("Process %u, done!\n", SDL_ThreadID ()); - if (SDL_mutexV (mutex) < 0) { - fprintf (stderr, "Couldn't unlock mutex: %s", SDL_GetError ()); - exit (1); + printf("Process %u, working!\n", SDL_ThreadID()); + SDL_Delay(1 * 1000); + printf("Process %u, done!\n", SDL_ThreadID()); + if (SDL_mutexV(mutex) < 0) { + fprintf(stderr, "Couldn't unlock mutex: %s", SDL_GetError()); + exit(1); } /* If this sleep isn't done, then threads may starve */ - SDL_Delay (10); - if (SDL_ThreadID () == mainthread && doterminate) { - printf ("Process %u: raising SIGTERM\n", SDL_ThreadID ()); - raise (SIGTERM); + SDL_Delay(10); + if (SDL_ThreadID() == mainthread && doterminate) { + printf("Process %u: raising SIGTERM\n", SDL_ThreadID()); + raise(SIGTERM); } } return (0); } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { int i; int maxproc = 6; /* Load the SDL library */ - if (SDL_Init (0) < 0) { - fprintf (stderr, "%s\n", SDL_GetError ()); - exit (1); + if (SDL_Init(0) < 0) { + fprintf(stderr, "%s\n", SDL_GetError()); + exit(1); } - atexit (SDL_Quit_Wrapper); + atexit(SDL_Quit_Wrapper); - if ((mutex = SDL_CreateMutex ()) == NULL) { - fprintf (stderr, "Couldn't create mutex: %s\n", SDL_GetError ()); - exit (1); + if ((mutex = SDL_CreateMutex()) == NULL) { + fprintf(stderr, "Couldn't create mutex: %s\n", SDL_GetError()); + exit(1); } - mainthread = SDL_ThreadID (); - printf ("Main thread: %u\n", mainthread); - atexit (printid); + mainthread = SDL_ThreadID(); + printf("Main thread: %u\n", mainthread); + atexit(printid); for (i = 0; i < maxproc; ++i) { - if ((threads[i] = SDL_CreateThread (Run, NULL)) == NULL) - fprintf (stderr, "Couldn't create thread!\n"); + if ((threads[i] = SDL_CreateThread(Run, NULL)) == NULL) + fprintf(stderr, "Couldn't create thread!\n"); } - signal (SIGINT, terminate); - Run (NULL); + signal(SIGINT, terminate); + Run(NULL); return (0); /* Never reached */ } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testoverlay.c --- a/test/testoverlay.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testoverlay.c Mon May 29 04:04:35 2006 +0000 @@ -23,10 +23,10 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } /* NOTE: These RGB conversion functions are not intended for speed, @@ -34,7 +34,7 @@ */ void -RGBtoYUV (Uint8 * rgb, int *yuv, int monochrome, int luminance) +RGBtoYUV(Uint8 * rgb, int *yuv, int monochrome, int luminance) { if (monochrome) { #if 1 /* these are the two formulas that I found on the FourCC site... */ @@ -77,15 +77,15 @@ } void -ConvertRGBtoYV12 (SDL_Surface * s, SDL_Overlay * o, int monochrome, - int luminance) +ConvertRGBtoYV12(SDL_Surface * s, SDL_Overlay * o, int monochrome, + int luminance) { int x, y; int yuv[3]; Uint8 *p, *op[3]; - SDL_LockSurface (s); - SDL_LockYUVOverlay (o); + SDL_LockSurface(s); + SDL_LockYUVOverlay(o); /* Black initialization */ /* @@ -101,7 +101,7 @@ op[1] = o->pixels[1] + o->pitches[1] * (y / 2); op[2] = o->pixels[2] + o->pitches[2] * (y / 2); for (x = 0; x < s->w && x < o->w; x++) { - RGBtoYUV (p, yuv, monochrome, luminance); + RGBtoYUV(p, yuv, monochrome, luminance); *(op[0]++) = yuv[0]; if (x % 2 == 0 && y % 2 == 0) { *(op[1]++) = yuv[2]; @@ -111,20 +111,20 @@ } } - SDL_UnlockYUVOverlay (o); - SDL_UnlockSurface (s); + SDL_UnlockYUVOverlay(o); + SDL_UnlockSurface(s); } void -ConvertRGBtoIYUV (SDL_Surface * s, SDL_Overlay * o, int monochrome, - int luminance) +ConvertRGBtoIYUV(SDL_Surface * s, SDL_Overlay * o, int monochrome, + int luminance) { int x, y; int yuv[3]; Uint8 *p, *op[3]; - SDL_LockSurface (s); - SDL_LockYUVOverlay (o); + SDL_LockSurface(s); + SDL_LockYUVOverlay(o); /* Black initialization */ /* @@ -140,7 +140,7 @@ op[1] = o->pixels[1] + o->pitches[1] * (y / 2); op[2] = o->pixels[2] + o->pitches[2] * (y / 2); for (x = 0; x < s->w && x < o->w; x++) { - RGBtoYUV (p, yuv, monochrome, luminance); + RGBtoYUV(p, yuv, monochrome, luminance); *(op[0]++) = yuv[0]; if (x % 2 == 0 && y % 2 == 0) { *(op[1]++) = yuv[1]; @@ -150,26 +150,26 @@ } } - SDL_UnlockYUVOverlay (o); - SDL_UnlockSurface (s); + SDL_UnlockYUVOverlay(o); + SDL_UnlockSurface(s); } void -ConvertRGBtoUYVY (SDL_Surface * s, SDL_Overlay * o, int monochrome, - int luminance) +ConvertRGBtoUYVY(SDL_Surface * s, SDL_Overlay * o, int monochrome, + int luminance) { int x, y; int yuv[3]; Uint8 *p, *op; - SDL_LockSurface (s); - SDL_LockYUVOverlay (o); + SDL_LockSurface(s); + SDL_LockYUVOverlay(o); for (y = 0; y < s->h && y < o->h; y++) { p = ((Uint8 *) s->pixels) + s->pitch * y; op = o->pixels[0] + o->pitches[0] * y; for (x = 0; x < s->w && x < o->w; x++) { - RGBtoYUV (p, yuv, monochrome, luminance); + RGBtoYUV(p, yuv, monochrome, luminance); if (x % 2 == 0) { *(op++) = yuv[1]; *(op++) = yuv[0]; @@ -181,26 +181,26 @@ } } - SDL_UnlockYUVOverlay (o); - SDL_UnlockSurface (s); + SDL_UnlockYUVOverlay(o); + SDL_UnlockSurface(s); } void -ConvertRGBtoYVYU (SDL_Surface * s, SDL_Overlay * o, int monochrome, - int luminance) +ConvertRGBtoYVYU(SDL_Surface * s, SDL_Overlay * o, int monochrome, + int luminance) { int x, y; int yuv[3]; Uint8 *p, *op; - SDL_LockSurface (s); - SDL_LockYUVOverlay (o); + SDL_LockSurface(s); + SDL_LockYUVOverlay(o); for (y = 0; y < s->h && y < o->h; y++) { p = ((Uint8 *) s->pixels) + s->pitch * y; op = o->pixels[0] + o->pitches[0] * y; for (x = 0; x < s->w && x < o->w; x++) { - RGBtoYUV (p, yuv, monochrome, luminance); + RGBtoYUV(p, yuv, monochrome, luminance); if (x % 2 == 0) { *(op++) = yuv[0]; *(op++) = yuv[2]; @@ -214,26 +214,26 @@ } } - SDL_UnlockYUVOverlay (o); - SDL_UnlockSurface (s); + SDL_UnlockYUVOverlay(o); + SDL_UnlockSurface(s); } void -ConvertRGBtoYUY2 (SDL_Surface * s, SDL_Overlay * o, int monochrome, - int luminance) +ConvertRGBtoYUY2(SDL_Surface * s, SDL_Overlay * o, int monochrome, + int luminance) { int x, y; int yuv[3]; Uint8 *p, *op; - SDL_LockSurface (s); - SDL_LockYUVOverlay (o); + SDL_LockSurface(s); + SDL_LockYUVOverlay(o); for (y = 0; y < s->h && y < o->h; y++) { p = ((Uint8 *) s->pixels) + s->pitch * y; op = o->pixels[0] + o->pitches[0] * y; for (x = 0; x < s->w && x < o->w; x++) { - RGBtoYUV (p, yuv, monochrome, luminance); + RGBtoYUV(p, yuv, monochrome, luminance); if (x % 2 == 0) { *(op++) = yuv[0]; *(op++) = yuv[1]; @@ -247,12 +247,12 @@ } } - SDL_UnlockYUVOverlay (o); - SDL_UnlockSurface (s); + SDL_UnlockYUVOverlay(o); + SDL_UnlockSurface(s); } void -Draw () +Draw() { SDL_Rect rect; int i; @@ -264,7 +264,7 @@ for (i = 0; i < h - rect.h && i < w - rect.w; i++) { rect.x = i; rect.y = i; - SDL_DisplayYUVOverlay (overlay, &rect); + SDL_DisplayYUVOverlay(overlay, &rect); } } else { rect.w = overlay->w / 2; @@ -277,38 +277,38 @@ rect.h += 2; rect.x--; rect.y--; - SDL_DisplayYUVOverlay (overlay, &rect); + SDL_DisplayYUVOverlay(overlay, &rect); } } - printf ("Displayed %d times.\n", i); + printf("Displayed %d times.\n", i); } static void -PrintUsage (char *argv0) +PrintUsage(char *argv0) { - fprintf (stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0); - fprintf (stderr, "Where 'arg' is one of:\n"); - fprintf (stderr, " -delay \n"); - fprintf (stderr, " -width \n"); - fprintf (stderr, " -height \n"); - fprintf (stderr, " -bpp \n"); - fprintf (stderr, - " -format (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n"); - fprintf (stderr, " -hw\n"); - fprintf (stderr, " -flip\n"); - fprintf (stderr, - " -scale (test scaling features, from 50%% upto window size)\n"); - fprintf (stderr, " -mono (use monochromatic RGB2YUV conversion)\n"); - fprintf (stderr, - " -lum (use luminance correction during RGB2YUV conversion,\n"); - fprintf (stderr, - " from 0%% to unlimited, normal is 100%%)\n"); - fprintf (stderr, " -help (shows this help)\n"); - fprintf (stderr, " -fullscreen (test overlay in fullscreen mode)\n"); + fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0); + fprintf(stderr, "Where 'arg' is one of:\n"); + fprintf(stderr, " -delay \n"); + fprintf(stderr, " -width \n"); + fprintf(stderr, " -height \n"); + fprintf(stderr, " -bpp \n"); + fprintf(stderr, + " -format (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n"); + fprintf(stderr, " -hw\n"); + fprintf(stderr, " -flip\n"); + fprintf(stderr, + " -scale (test scaling features, from 50%% upto window size)\n"); + fprintf(stderr, " -mono (use monochromatic RGB2YUV conversion)\n"); + fprintf(stderr, + " -lum (use luminance correction during RGB2YUV conversion,\n"); + fprintf(stderr, + " from 0%% to unlimited, normal is 100%%)\n"); + fprintf(stderr, " -help (shows this help)\n"); + fprintf(stderr, " -fullscreen (test overlay in fullscreen mode)\n"); } int -main (int argc, char **argv) +main(int argc, char **argv) { char *argv0 = argv[0]; int flip; @@ -334,131 +334,131 @@ overlay_format = SDL_YV12_OVERLAY; while (argc > 1) { - if (strcmp (argv[1], "-delay") == 0) { + if (strcmp(argv[1], "-delay") == 0) { if (argv[2]) { - delay = atoi (argv[2]); + delay = atoi(argv[2]); argv += 2; argc -= 2; } else { - fprintf (stderr, "The -delay option requires an argument\n"); + fprintf(stderr, "The -delay option requires an argument\n"); return (1); } - } else if (strcmp (argv[1], "-width") == 0) { - if (argv[2] && ((w = atoi (argv[2])) > 0)) { + } else if (strcmp(argv[1], "-width") == 0) { + if (argv[2] && ((w = atoi(argv[2])) > 0)) { argv += 2; argc -= 2; } else { - fprintf (stderr, "The -width option requires an argument\n"); + fprintf(stderr, "The -width option requires an argument\n"); return (1); } - } else if (strcmp (argv[1], "-height") == 0) { - if (argv[2] && ((h = atoi (argv[2])) > 0)) { + } else if (strcmp(argv[1], "-height") == 0) { + if (argv[2] && ((h = atoi(argv[2])) > 0)) { argv += 2; argc -= 2; } else { - fprintf (stderr, "The -height option requires an argument\n"); + fprintf(stderr, "The -height option requires an argument\n"); return (1); } - } else if (strcmp (argv[1], "-bpp") == 0) { + } else if (strcmp(argv[1], "-bpp") == 0) { if (argv[2]) { - desired_bpp = atoi (argv[2]); + desired_bpp = atoi(argv[2]); argv += 2; argc -= 2; } else { - fprintf (stderr, "The -bpp option requires an argument\n"); + fprintf(stderr, "The -bpp option requires an argument\n"); return (1); } - } else if (strcmp (argv[1], "-lum") == 0) { + } else if (strcmp(argv[1], "-lum") == 0) { if (argv[2]) { - luminance = atoi (argv[2]); + luminance = atoi(argv[2]); argv += 2; argc -= 2; } else { - fprintf (stderr, "The -lum option requires an argument\n"); + fprintf(stderr, "The -lum option requires an argument\n"); return (1); } - } else if (strcmp (argv[1], "-format") == 0) { + } else if (strcmp(argv[1], "-format") == 0) { if (argv[2]) { - if (!strcmp (argv[2], "YV12")) + if (!strcmp(argv[2], "YV12")) overlay_format = SDL_YV12_OVERLAY; - else if (!strcmp (argv[2], "IYUV")) + else if (!strcmp(argv[2], "IYUV")) overlay_format = SDL_IYUV_OVERLAY; - else if (!strcmp (argv[2], "YUY2")) + else if (!strcmp(argv[2], "YUY2")) overlay_format = SDL_YUY2_OVERLAY; - else if (!strcmp (argv[2], "UYVY")) + else if (!strcmp(argv[2], "UYVY")) overlay_format = SDL_UYVY_OVERLAY; - else if (!strcmp (argv[2], "YVYU")) + else if (!strcmp(argv[2], "YVYU")) overlay_format = SDL_YVYU_OVERLAY; else { - fprintf (stderr, - "The -format option %s is not recognized\n", - argv[2]); + fprintf(stderr, + "The -format option %s is not recognized\n", + argv[2]); return (1); } argv += 2; argc -= 2; } else { - fprintf (stderr, "The -format option requires an argument\n"); + fprintf(stderr, "The -format option requires an argument\n"); return (1); } - } else if (strcmp (argv[1], "-hw") == 0) { + } else if (strcmp(argv[1], "-hw") == 0) { video_flags |= SDL_HWSURFACE; argv += 1; argc -= 1; - } else if (strcmp (argv[1], "-flip") == 0) { + } else if (strcmp(argv[1], "-flip") == 0) { video_flags |= SDL_DOUBLEBUF; argv += 1; argc -= 1; - } else if (strcmp (argv[1], "-scale") == 0) { + } else if (strcmp(argv[1], "-scale") == 0) { scale = 1; argv += 1; argc -= 1; - } else if (strcmp (argv[1], "-mono") == 0) { + } else if (strcmp(argv[1], "-mono") == 0) { monochrome = 1; argv += 1; argc -= 1; - } else if ((strcmp (argv[1], "-help") == 0) - || (strcmp (argv[1], "-h") == 0)) { - PrintUsage (argv0); + } else if ((strcmp(argv[1], "-help") == 0) + || (strcmp(argv[1], "-h") == 0)) { + PrintUsage(argv0); return (1); - } else if (strcmp (argv[1], "-fullscreen") == 0) { + } else if (strcmp(argv[1], "-fullscreen") == 0) { video_flags |= SDL_FULLSCREEN; argv += 1; argc -= 1; } else break; } - if (SDL_Init (SDL_INIT_VIDEO) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } /* Initialize the display */ - screen = SDL_SetVideoMode (w, h, desired_bpp, video_flags); + screen = SDL_SetVideoMode(w, h, desired_bpp, video_flags); if (screen == NULL) { - fprintf (stderr, "Couldn't set %dx%dx%d video mode: %s\n", - w, h, desired_bpp, SDL_GetError ()); - quit (1); + fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n", + w, h, desired_bpp, SDL_GetError()); + quit(1); } - printf ("Set%s %dx%dx%d mode\n", - screen->flags & SDL_FULLSCREEN ? " fullscreen" : "", - screen->w, screen->h, screen->format->BitsPerPixel); - printf ("(video surface located in %s memory)\n", - (screen->flags & SDL_HWSURFACE) ? "video" : "system"); + printf("Set%s %dx%dx%d mode\n", + screen->flags & SDL_FULLSCREEN ? " fullscreen" : "", + screen->w, screen->h, screen->format->BitsPerPixel); + printf("(video surface located in %s memory)\n", + (screen->flags & SDL_HWSURFACE) ? "video" : "system"); if (screen->flags & SDL_DOUBLEBUF) { - printf ("Double-buffering enabled\n"); + printf("Double-buffering enabled\n"); flip = 1; } /* Set the window manager title bar */ - SDL_WM_SetCaption ("SDL test overlay", "testoverlay"); + SDL_WM_SetCaption("SDL test overlay", "testoverlay"); /* Load picture */ bmpfile = (argv[1] ? argv[1] : "sample.bmp"); - pic = SDL_LoadBMP (bmpfile); + pic = SDL_LoadBMP(bmpfile); if (pic == NULL) { - fprintf (stderr, "Couldn't load %s: %s\n", bmpfile, SDL_GetError ()); - quit (1); + fprintf(stderr, "Couldn't load %s: %s\n", bmpfile, SDL_GetError()); + quit(1); } /* Convert the picture to 32bits, for easy conversion */ @@ -490,73 +490,73 @@ format.colorkey = 0; format.alpha = 0; - newsurf = SDL_ConvertSurface (pic, &format, SDL_SWSURFACE); + newsurf = SDL_ConvertSurface(pic, &format, SDL_SWSURFACE); if (!newsurf) { - fprintf (stderr, "Couldn't convert picture to 32bits RGB: %s\n", - SDL_GetError ()); - quit (1); + fprintf(stderr, "Couldn't convert picture to 32bits RGB: %s\n", + SDL_GetError()); + quit(1); } - SDL_FreeSurface (pic); + SDL_FreeSurface(pic); pic = newsurf; } /* Create the overlay */ - overlay = SDL_CreateYUVOverlay (pic->w, pic->h, overlay_format, screen); + overlay = SDL_CreateYUVOverlay(pic->w, pic->h, overlay_format, screen); if (overlay == NULL) { - fprintf (stderr, "Couldn't create overlay: %s\n", SDL_GetError ()); - quit (1); + fprintf(stderr, "Couldn't create overlay: %s\n", SDL_GetError()); + quit(1); } - printf ("Created %dx%dx%d %s %s overlay\n", overlay->w, overlay->h, - overlay->planes, overlay->hw_overlay ? "hardware" : "software", - overlay->format == SDL_YV12_OVERLAY ? "YV12" : overlay->format == - SDL_IYUV_OVERLAY ? "IYUV" : overlay->format == - SDL_YUY2_OVERLAY ? "YUY2" : overlay->format == - SDL_UYVY_OVERLAY ? "UYVY" : overlay->format == - SDL_YVYU_OVERLAY ? "YVYU" : "Unknown"); + printf("Created %dx%dx%d %s %s overlay\n", overlay->w, overlay->h, + overlay->planes, overlay->hw_overlay ? "hardware" : "software", + overlay->format == SDL_YV12_OVERLAY ? "YV12" : overlay->format == + SDL_IYUV_OVERLAY ? "IYUV" : overlay->format == + SDL_YUY2_OVERLAY ? "YUY2" : overlay->format == + SDL_UYVY_OVERLAY ? "UYVY" : overlay->format == + SDL_YVYU_OVERLAY ? "YVYU" : "Unknown"); for (i = 0; i < overlay->planes; i++) { - printf (" plane %d: pitch=%d\n", i, overlay->pitches[i]); + printf(" plane %d: pitch=%d\n", i, overlay->pitches[i]); } /* Convert to YUV, and draw to the overlay */ #ifdef BENCHMARK_SDL - then = SDL_GetTicks (); + then = SDL_GetTicks(); #endif switch (overlay->format) { case SDL_YV12_OVERLAY: - ConvertRGBtoYV12 (pic, overlay, monochrome, luminance); + ConvertRGBtoYV12(pic, overlay, monochrome, luminance); break; case SDL_UYVY_OVERLAY: - ConvertRGBtoUYVY (pic, overlay, monochrome, luminance); + ConvertRGBtoUYVY(pic, overlay, monochrome, luminance); break; case SDL_YVYU_OVERLAY: - ConvertRGBtoYVYU (pic, overlay, monochrome, luminance); + ConvertRGBtoYVYU(pic, overlay, monochrome, luminance); break; case SDL_YUY2_OVERLAY: - ConvertRGBtoYUY2 (pic, overlay, monochrome, luminance); + ConvertRGBtoYUY2(pic, overlay, monochrome, luminance); break; case SDL_IYUV_OVERLAY: - ConvertRGBtoIYUV (pic, overlay, monochrome, luminance); + ConvertRGBtoIYUV(pic, overlay, monochrome, luminance); break; default: - printf ("cannot convert RGB picture to obtained YUV format!\n"); - quit (1); + printf("cannot convert RGB picture to obtained YUV format!\n"); + quit(1); break; } #ifdef BENCHMARK_SDL - now = SDL_GetTicks (); - printf ("Conversion Time: %d milliseconds\n", now - then); + now = SDL_GetTicks(); + printf("Conversion Time: %d milliseconds\n", now - then); #endif /* Do all the drawing work */ #ifdef BENCHMARK_SDL - then = SDL_GetTicks (); + then = SDL_GetTicks(); #endif - Draw (); + Draw(); #ifdef BENCHMARK_SDL - now = SDL_GetTicks (); - printf ("Time: %d milliseconds\n", now - then); + now = SDL_GetTicks(); + printf("Time: %d milliseconds\n", now - then); #endif - SDL_Delay (delay * 1000); - SDL_Quit (); + SDL_Delay(delay * 1000); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testoverlay2.c --- a/test/testoverlay2.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testoverlay2.c Mon May 29 04:04:35 2006 +0000 @@ -127,10 +127,10 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } /* All RGB2YUV conversion code and some other parts of code has been taken from testoverlay.c */ @@ -140,7 +140,7 @@ */ void -RGBtoYUV (Uint8 * rgb, int *yuv, int monochrome, int luminance) +RGBtoYUV(Uint8 * rgb, int *yuv, int monochrome, int luminance) { if (monochrome) { #if 1 /* these are the two formulas that I found on the FourCC site... */ @@ -172,15 +172,15 @@ } void -ConvertRGBtoYV12 (SDL_Surface * s, SDL_Overlay * o, int monochrome, - int luminance) +ConvertRGBtoYV12(SDL_Surface * s, SDL_Overlay * o, int monochrome, + int luminance) { int x, y; int yuv[3]; Uint8 *p, *op[3]; - SDL_LockSurface (s); - SDL_LockYUVOverlay (o); + SDL_LockSurface(s); + SDL_LockYUVOverlay(o); /* Convert */ for (y = 0; y < s->h && y < o->h; y++) { @@ -189,7 +189,7 @@ op[1] = o->pixels[1] + o->pitches[1] * (y / 2); op[2] = o->pixels[2] + o->pitches[2] * (y / 2); for (x = 0; x < s->w && x < o->w; x++) { - RGBtoYUV (p, yuv, monochrome, luminance); + RGBtoYUV(p, yuv, monochrome, luminance); *(op[0]++) = yuv[0]; if (x % 2 == 0 && y % 2 == 0) { *(op[1]++) = yuv[2]; @@ -199,20 +199,20 @@ } } - SDL_UnlockYUVOverlay (o); - SDL_UnlockSurface (s); + SDL_UnlockYUVOverlay(o); + SDL_UnlockSurface(s); } void -ConvertRGBtoIYUV (SDL_Surface * s, SDL_Overlay * o, int monochrome, - int luminance) +ConvertRGBtoIYUV(SDL_Surface * s, SDL_Overlay * o, int monochrome, + int luminance) { int x, y; int yuv[3]; Uint8 *p, *op[3]; - SDL_LockSurface (s); - SDL_LockYUVOverlay (o); + SDL_LockSurface(s); + SDL_LockYUVOverlay(o); /* Convert */ for (y = 0; y < s->h && y < o->h; y++) { @@ -221,7 +221,7 @@ op[1] = o->pixels[1] + o->pitches[1] * (y / 2); op[2] = o->pixels[2] + o->pitches[2] * (y / 2); for (x = 0; x < s->w && x < o->w; x++) { - RGBtoYUV (p, yuv, monochrome, luminance); + RGBtoYUV(p, yuv, monochrome, luminance); *(op[0]++) = yuv[0]; if (x % 2 == 0 && y % 2 == 0) { *(op[1]++) = yuv[1]; @@ -231,26 +231,26 @@ } } - SDL_UnlockYUVOverlay (o); - SDL_UnlockSurface (s); + SDL_UnlockYUVOverlay(o); + SDL_UnlockSurface(s); } void -ConvertRGBtoUYVY (SDL_Surface * s, SDL_Overlay * o, int monochrome, - int luminance) +ConvertRGBtoUYVY(SDL_Surface * s, SDL_Overlay * o, int monochrome, + int luminance) { int x, y; int yuv[3]; Uint8 *p, *op; - SDL_LockSurface (s); - SDL_LockYUVOverlay (o); + SDL_LockSurface(s); + SDL_LockYUVOverlay(o); for (y = 0; y < s->h && y < o->h; y++) { p = ((Uint8 *) s->pixels) + s->pitch * y; op = o->pixels[0] + o->pitches[0] * y; for (x = 0; x < s->w && x < o->w; x++) { - RGBtoYUV (p, yuv, monochrome, luminance); + RGBtoYUV(p, yuv, monochrome, luminance); if (x % 2 == 0) { *(op++) = yuv[1]; *(op++) = yuv[0]; @@ -262,26 +262,26 @@ } } - SDL_UnlockYUVOverlay (o); - SDL_UnlockSurface (s); + SDL_UnlockYUVOverlay(o); + SDL_UnlockSurface(s); } void -ConvertRGBtoYVYU (SDL_Surface * s, SDL_Overlay * o, int monochrome, - int luminance) +ConvertRGBtoYVYU(SDL_Surface * s, SDL_Overlay * o, int monochrome, + int luminance) { int x, y; int yuv[3]; Uint8 *p, *op; - SDL_LockSurface (s); - SDL_LockYUVOverlay (o); + SDL_LockSurface(s); + SDL_LockYUVOverlay(o); for (y = 0; y < s->h && y < o->h; y++) { p = ((Uint8 *) s->pixels) + s->pitch * y; op = o->pixels[0] + o->pitches[0] * y; for (x = 0; x < s->w && x < o->w; x++) { - RGBtoYUV (p, yuv, monochrome, luminance); + RGBtoYUV(p, yuv, monochrome, luminance); if (x % 2 == 0) { *(op++) = yuv[0]; *(op++) = yuv[2]; @@ -295,26 +295,26 @@ } } - SDL_UnlockYUVOverlay (o); - SDL_UnlockSurface (s); + SDL_UnlockYUVOverlay(o); + SDL_UnlockSurface(s); } void -ConvertRGBtoYUY2 (SDL_Surface * s, SDL_Overlay * o, int monochrome, - int luminance) +ConvertRGBtoYUY2(SDL_Surface * s, SDL_Overlay * o, int monochrome, + int luminance) { int x, y; int yuv[3]; Uint8 *p, *op; - SDL_LockSurface (s); - SDL_LockYUVOverlay (o); + SDL_LockSurface(s); + SDL_LockYUVOverlay(o); for (y = 0; y < s->h && y < o->h; y++) { p = ((Uint8 *) s->pixels) + s->pitch * y; op = o->pixels[0] + o->pitches[0] * y; for (x = 0; x < s->w && x < o->w; x++) { - RGBtoYUV (p, yuv, monochrome, luminance); + RGBtoYUV(p, yuv, monochrome, luminance); if (x % 2 == 0) { *(op++) = yuv[0]; *(op++) = yuv[1]; @@ -328,31 +328,31 @@ } } - SDL_UnlockYUVOverlay (o); - SDL_UnlockSurface (s); + SDL_UnlockYUVOverlay(o); + SDL_UnlockSurface(s); } static void -PrintUsage (char *argv0) +PrintUsage(char *argv0) { - fprintf (stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0); - fprintf (stderr, "\n"); - fprintf (stderr, "Where 'arg' is any of the following options:\n"); - fprintf (stderr, "\n"); - fprintf (stderr, " -fps \n"); - fprintf (stderr, - " -format (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n"); - fprintf (stderr, - " -scale (initial scale of the overlay)\n"); - fprintf (stderr, " -help (shows this help)\n"); - fprintf (stderr, "\n"); - fprintf (stderr, - "Press ESC to exit, or SPACE to freeze the movie while application running.\n"); - fprintf (stderr, "\n"); + fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0); + fprintf(stderr, "\n"); + fprintf(stderr, "Where 'arg' is any of the following options:\n"); + fprintf(stderr, "\n"); + fprintf(stderr, " -fps \n"); + fprintf(stderr, + " -format (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n"); + fprintf(stderr, + " -scale (initial scale of the overlay)\n"); + fprintf(stderr, " -help (shows this help)\n"); + fprintf(stderr, "\n"); + fprintf(stderr, + "Press ESC to exit, or SPACE to freeze the movie while application running.\n"); + fprintf(stderr, "\n"); } int -main (int argc, char **argv) +main(int argc, char **argv) { Uint8 *RawMooseData; SDL_RWops *handle; @@ -370,131 +370,131 @@ int overlay_format = SDL_YUY2_OVERLAY; int scale = 5; - if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return 3; } while (argc > 1) { - if (strcmp (argv[1], "-fps") == 0) { + if (strcmp(argv[1], "-fps") == 0) { if (argv[2]) { - fps = atoi (argv[2]); + fps = atoi(argv[2]); if (fps == 0) { - fprintf (stderr, - "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); - quit (10); + fprintf(stderr, + "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); + quit(10); } if ((fps < 0) || (fps > 1000)) { - fprintf (stderr, - "The -fps option must be in range from 1 to 1000, default is 12.\n"); - quit (10); + fprintf(stderr, + "The -fps option must be in range from 1 to 1000, default is 12.\n"); + quit(10); } argv += 2; argc -= 2; } else { - fprintf (stderr, - "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); - quit (10); + fprintf(stderr, + "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); + quit(10); } - } else if (strcmp (argv[1], "-format") == 0) { + } else if (strcmp(argv[1], "-format") == 0) { if (argv[2]) { - if (!strcmp (argv[2], "YV12")) + if (!strcmp(argv[2], "YV12")) overlay_format = SDL_YV12_OVERLAY; - else if (!strcmp (argv[2], "IYUV")) + else if (!strcmp(argv[2], "IYUV")) overlay_format = SDL_IYUV_OVERLAY; - else if (!strcmp (argv[2], "YUY2")) + else if (!strcmp(argv[2], "YUY2")) overlay_format = SDL_YUY2_OVERLAY; - else if (!strcmp (argv[2], "UYVY")) + else if (!strcmp(argv[2], "UYVY")) overlay_format = SDL_UYVY_OVERLAY; - else if (!strcmp (argv[2], "YVYU")) + else if (!strcmp(argv[2], "YVYU")) overlay_format = SDL_YVYU_OVERLAY; else { - fprintf (stderr, - "The -format option %s is not recognized, see help for info.\n", - argv[2]); - quit (10); + fprintf(stderr, + "The -format option %s is not recognized, see help for info.\n", + argv[2]); + quit(10); } argv += 2; argc -= 2; } else { - fprintf (stderr, - "The -format option requires an argument, default is YUY2.\n"); - quit (10); + fprintf(stderr, + "The -format option requires an argument, default is YUY2.\n"); + quit(10); } - } else if (strcmp (argv[1], "-scale") == 0) { + } else if (strcmp(argv[1], "-scale") == 0) { if (argv[2]) { - scale = atoi (argv[2]); + scale = atoi(argv[2]); if (scale == 0) { - fprintf (stderr, - "The -scale option requires an argument [from 1 to 50], default is 5.\n"); - quit (10); + fprintf(stderr, + "The -scale option requires an argument [from 1 to 50], default is 5.\n"); + quit(10); } if ((scale < 0) || (scale > 50)) { - fprintf (stderr, - "The -scale option must be in range from 1 to 50, default is 5.\n"); - quit (10); + fprintf(stderr, + "The -scale option must be in range from 1 to 50, default is 5.\n"); + quit(10); } argv += 2; argc -= 2; } else { - fprintf (stderr, - "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); - quit (10); + fprintf(stderr, + "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); + quit(10); } - } else if ((strcmp (argv[1], "-help") == 0) - || (strcmp (argv[1], "-h") == 0)) { - PrintUsage (argv[0]); - quit (0); + } else if ((strcmp(argv[1], "-help") == 0) + || (strcmp(argv[1], "-h") == 0)) { + PrintUsage(argv[0]); + quit(0); } else { - fprintf (stderr, "Unrecognized option: %s.\n", argv[1]); - quit (10); + fprintf(stderr, "Unrecognized option: %s.\n", argv[1]); + quit(10); } break; } - RawMooseData = (Uint8 *) malloc (MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT); + RawMooseData = (Uint8 *) malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT); if (RawMooseData == NULL) { - fprintf (stderr, "Can't allocate memory for movie !\n"); - free (RawMooseData); - quit (1); + fprintf(stderr, "Can't allocate memory for movie !\n"); + free(RawMooseData); + quit(1); } /* load the trojan moose images */ - handle = SDL_RWFromFile ("moose.dat", "rb"); + handle = SDL_RWFromFile("moose.dat", "rb"); if (handle == NULL) { - fprintf (stderr, "Can't find the file moose.dat !\n"); - free (RawMooseData); - quit (2); + fprintf(stderr, "Can't find the file moose.dat !\n"); + free(RawMooseData); + quit(2); } - SDL_RWread (handle, RawMooseData, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT); + SDL_RWread(handle, RawMooseData, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT); - SDL_RWclose (handle); + SDL_RWclose(handle); /* Set video mode */ if ((screen = - SDL_SetVideoMode (MOOSEPIC_W * scale, MOOSEPIC_H * scale, 0, - SDL_RESIZABLE | SDL_SWSURFACE)) == NULL) { - fprintf (stderr, "Couldn't set video mode: %s\n", SDL_GetError ()); - free (RawMooseData); - quit (4); + SDL_SetVideoMode(MOOSEPIC_W * scale, MOOSEPIC_H * scale, 0, + SDL_RESIZABLE | SDL_SWSURFACE)) == NULL) { + fprintf(stderr, "Couldn't set video mode: %s\n", SDL_GetError()); + free(RawMooseData); + quit(4); } /* Set the window manager title bar */ - SDL_WM_SetCaption ("SDL test overlay: running moose", "testoverlay2"); + SDL_WM_SetCaption("SDL test overlay: running moose", "testoverlay2"); for (i = 0; i < MOOSEFRAMES_COUNT; i++) { MooseFrame[i] = - SDL_CreateRGBSurfaceFrom (RawMooseData + i * MOOSEFRAME_SIZE, - MOOSEPIC_W, MOOSEPIC_H, 8, MOOSEPIC_W, - 0, 0, 0, 0); + SDL_CreateRGBSurfaceFrom(RawMooseData + i * MOOSEFRAME_SIZE, + MOOSEPIC_W, MOOSEPIC_H, 8, MOOSEPIC_W, + 0, 0, 0, 0); if (MooseFrame[i] == NULL) { - fprintf (stderr, "Couldn't create SDL_Surfaces:%s\n", - SDL_GetError ()); - free (RawMooseData); - quit (5); + fprintf(stderr, "Couldn't create SDL_Surfaces:%s\n", + SDL_GetError()); + free(RawMooseData); + quit(5); } - SDL_SetColors (MooseFrame[i], MooseColors, 0, 84); + SDL_SetColors(MooseFrame[i], MooseColors, 0, 84); { SDL_Surface *newsurf; @@ -525,37 +525,37 @@ format.alpha = 0; newsurf = - SDL_ConvertSurface (MooseFrame[i], &format, SDL_SWSURFACE); + SDL_ConvertSurface(MooseFrame[i], &format, SDL_SWSURFACE); if (!newsurf) { - fprintf (stderr, - "Couldn't convert picture to 32bits RGB: %s\n", - SDL_GetError ()); - quit (6); + fprintf(stderr, + "Couldn't convert picture to 32bits RGB: %s\n", + SDL_GetError()); + quit(6); } - SDL_FreeSurface (MooseFrame[i]); + SDL_FreeSurface(MooseFrame[i]); MooseFrame[i] = newsurf; } } - free (RawMooseData); + free(RawMooseData); overlay = - SDL_CreateYUVOverlay (MOOSEPIC_W, MOOSEPIC_H, overlay_format, screen); + SDL_CreateYUVOverlay(MOOSEPIC_W, MOOSEPIC_H, overlay_format, screen); if (!overlay) { - fprintf (stderr, "Couldn't create overlay: %s\n", SDL_GetError ()); - quit (7); + fprintf(stderr, "Couldn't create overlay: %s\n", SDL_GetError()); + quit(7); } - printf ("Created %dx%dx%d %s %s overlay\n", overlay->w, overlay->h, - overlay->planes, overlay->hw_overlay ? "hardware" : "software", - overlay->format == SDL_YV12_OVERLAY ? "YV12" : overlay->format == - SDL_IYUV_OVERLAY ? "IYUV" : overlay->format == - SDL_YUY2_OVERLAY ? "YUY2" : overlay->format == - SDL_UYVY_OVERLAY ? "UYVY" : overlay->format == - SDL_YVYU_OVERLAY ? "YVYU" : "Unknown"); + printf("Created %dx%dx%d %s %s overlay\n", overlay->w, overlay->h, + overlay->planes, overlay->hw_overlay ? "hardware" : "software", + overlay->format == SDL_YV12_OVERLAY ? "YV12" : overlay->format == + SDL_IYUV_OVERLAY ? "IYUV" : overlay->format == + SDL_YUY2_OVERLAY ? "YUY2" : overlay->format == + SDL_UYVY_OVERLAY ? "UYVY" : overlay->format == + SDL_YVYU_OVERLAY ? "YVYU" : "Unknown"); for (i = 0; i < overlay->planes; i++) { - printf (" plane %d: pitch=%d\n", i, overlay->pitches[i]); + printf(" plane %d: pitch=%d\n", i, overlay->pitches[i]); } overlayrect.x = 0; @@ -568,18 +568,18 @@ fpsdelay = 1000 / fps; /* Ignore key up events, they don't even get filtered */ - SDL_EventState (SDL_KEYUP, SDL_IGNORE); + SDL_EventState(SDL_KEYUP, SDL_IGNORE); - lastftick = SDL_GetTicks (); + lastftick = SDL_GetTicks(); /* Loop, waiting for QUIT or RESIZE */ while (1) { - if (SDL_PollEvent (&event)) { + if (SDL_PollEvent(&event)) { switch (event.type) { case SDL_VIDEORESIZE: screen = - SDL_SetVideoMode (event.resize.w, event.resize.h, 0, - SDL_RESIZABLE | SDL_SWSURFACE); + SDL_SetVideoMode(event.resize.w, event.resize.h, 0, + SDL_RESIZABLE | SDL_SWSURFACE); overlayrect.w = event.resize.w; overlayrect.h = event.resize.h; if (paused) { @@ -599,37 +599,37 @@ break; } case SDL_QUIT: - SDL_FreeYUVOverlay (overlay); + SDL_FreeYUVOverlay(overlay); for (i = 0; i < MOOSEFRAMES_COUNT; i++) { - SDL_FreeSurface (MooseFrame[i]); + SDL_FreeSurface(MooseFrame[i]); } - quit (0); + quit(0); } } if ((!paused) || (resized)) { - if (((SDL_GetTicks () - lastftick) > fpsdelay) || (resized)) { - lastftick = SDL_GetTicks (); + if (((SDL_GetTicks() - lastftick) > fpsdelay) || (resized)) { + lastftick = SDL_GetTicks(); switch (overlay_format) { case SDL_YUY2_OVERLAY: - ConvertRGBtoYUY2 (MooseFrame[i], overlay, 0, 100); + ConvertRGBtoYUY2(MooseFrame[i], overlay, 0, 100); break; case SDL_YV12_OVERLAY: - ConvertRGBtoYV12 (MooseFrame[i], overlay, 0, 100); + ConvertRGBtoYV12(MooseFrame[i], overlay, 0, 100); break; case SDL_UYVY_OVERLAY: - ConvertRGBtoUYVY (MooseFrame[i], overlay, 0, 100); + ConvertRGBtoUYVY(MooseFrame[i], overlay, 0, 100); break; case SDL_YVYU_OVERLAY: - ConvertRGBtoYVYU (MooseFrame[i], overlay, 0, 100); + ConvertRGBtoYVYU(MooseFrame[i], overlay, 0, 100); break; case SDL_IYUV_OVERLAY: - ConvertRGBtoIYUV (MooseFrame[i], overlay, 0, 100); + ConvertRGBtoIYUV(MooseFrame[i], overlay, 0, 100); break; } - SDL_DisplayYUVOverlay (overlay, &overlayrect); + SDL_DisplayYUVOverlay(overlay, &overlayrect); if (!resized) { i++; if (i == 10) { @@ -641,9 +641,9 @@ } } /* kind of timeslice to OS */ - SDL_Delay (1); + SDL_Delay(1); } - SDL_Quit (); + SDL_Quit(); return 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testpalette.c --- a/test/testpalette.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testpalette.c Mon May 29 04:04:35 2006 +0000 @@ -56,51 +56,51 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } static void -sdlerr (char *when) +sdlerr(char *when) { - fprintf (stderr, "SDL error: %s: %s\n", when, SDL_GetError ()); - quit (1); + fprintf(stderr, "SDL error: %s: %s\n", when, SDL_GetError()); + quit(1); } /* create a background surface */ static SDL_Surface * -make_bg (SDL_Surface * screen, int startcol) +make_bg(SDL_Surface * screen, int startcol) { int i; SDL_Surface *bg = - SDL_CreateRGBSurface (SDL_SWSURFACE, screen->w, screen->h, - 8, 0, 0, 0, 0); + SDL_CreateRGBSurface(SDL_SWSURFACE, screen->w, screen->h, + 8, 0, 0, 0, 0); if (!bg) - sdlerr ("creating background surface"); + sdlerr("creating background surface"); /* set the palette to the logical screen palette so that blits won't be translated */ - SDL_SetColors (bg, screen->format->palette->colors, 0, 256); + SDL_SetColors(bg, screen->format->palette->colors, 0, 256); /* Make a wavy background pattern using colours 0-63 */ - if (SDL_LockSurface (bg) < 0) - sdlerr ("locking background"); + if (SDL_LockSurface(bg) < 0) + sdlerr("locking background"); for (i = 0; i < SCRH; i++) { Uint8 *p = (Uint8 *) bg->pixels + i * bg->pitch; int j, d; d = 0; for (j = 0; j < SCRW; j++) { - int v = MAX (d, -2); - v = MIN (v, 2); + int v = MAX(d, -2); + v = MIN(v, 2); if (i > 0) v += p[-bg->pitch] + 65 - startcol; p[j] = startcol + (v & 63); - d += ((rand () >> 3) % 3) - 1; + d += ((rand() >> 3) % 3) - 1; } } - SDL_UnlockSurface (bg); + SDL_UnlockSurface(bg); return (bg); } @@ -109,16 +109,16 @@ * extension to arbitrary bitness is left as an exercise for the reader. */ static SDL_Surface * -hflip (SDL_Surface * s) +hflip(SDL_Surface * s) { int i; - SDL_Surface *z = SDL_CreateRGBSurface (SDL_SWSURFACE, s->w, s->h, 8, - 0, 0, 0, 0); + SDL_Surface *z = SDL_CreateRGBSurface(SDL_SWSURFACE, s->w, s->h, 8, + 0, 0, 0, 0); /* copy palette */ - SDL_SetColors (z, s->format->palette->colors, - 0, s->format->palette->ncolors); - if (SDL_LockSurface (s) < 0 || SDL_LockSurface (z) < 0) - sdlerr ("locking flip images"); + SDL_SetColors(z, s->format->palette->colors, + 0, s->format->palette->ncolors); + if (SDL_LockSurface(s) < 0 || SDL_LockSurface(z) < 0) + sdlerr("locking flip images"); for (i = 0; i < s->h; i++) { int j; @@ -128,13 +128,13 @@ to[-j] = from[j]; } - SDL_UnlockSurface (z); - SDL_UnlockSurface (s); + SDL_UnlockSurface(z); + SDL_UnlockSurface(s); return z; } int -main (int argc, char **argv) +main(int argc, char **argv) { SDL_Color cmap[256]; SDL_Surface *screen; @@ -149,57 +149,56 @@ int gamma_fade = 0; int gamma_ramp = 0; - if (SDL_Init (SDL_INIT_VIDEO) < 0) - sdlerr ("initialising SDL"); + if (SDL_Init(SDL_INIT_VIDEO) < 0) + sdlerr("initialising SDL"); while (--argc) { ++argv; - if (strcmp (*argv, "-hw") == 0) + if (strcmp(*argv, "-hw") == 0) vidflags |= SDL_HWSURFACE; - else if (strcmp (*argv, "-fullscreen") == 0) + else if (strcmp(*argv, "-fullscreen") == 0) vidflags |= SDL_FULLSCREEN; - else if (strcmp (*argv, "-nofade") == 0) + else if (strcmp(*argv, "-nofade") == 0) fade_max = 1; - else if (strcmp (*argv, "-gamma") == 0) + else if (strcmp(*argv, "-gamma") == 0) gamma_fade = 1; - else if (strcmp (*argv, "-gammaramp") == 0) + else if (strcmp(*argv, "-gammaramp") == 0) gamma_ramp = 1; else { - fprintf (stderr, - "usage: testpalette " - " [-hw] [-fullscreen] [-nofade] [-gamma] [-gammaramp]\n"); - quit (1); + fprintf(stderr, + "usage: testpalette " + " [-hw] [-fullscreen] [-nofade] [-gamma] [-gammaramp]\n"); + quit(1); } } /* Ask explicitly for 8bpp and a hardware palette */ if ((screen = - SDL_SetVideoMode (SCRW, SCRH, 8, vidflags | SDL_HWPALETTE)) == NULL) - { - fprintf (stderr, "error setting %dx%d 8bpp indexed mode: %s\n", - SCRW, SCRH, SDL_GetError ()); - quit (1); + SDL_SetVideoMode(SCRW, SCRH, 8, vidflags | SDL_HWPALETTE)) == NULL) { + fprintf(stderr, "error setting %dx%d 8bpp indexed mode: %s\n", + SCRW, SCRH, SDL_GetError()); + quit(1); } if (vidflags & SDL_FULLSCREEN) - SDL_ShowCursor (SDL_FALSE); + SDL_ShowCursor(SDL_FALSE); - if ((boat[0] = SDL_LoadBMP ("sail.bmp")) == NULL) - sdlerr ("loading sail.bmp"); + if ((boat[0] = SDL_LoadBMP("sail.bmp")) == NULL) + sdlerr("loading sail.bmp"); /* We've chosen magenta (#ff00ff) as colour key for the boat */ - SDL_SetColorKey (boat[0], SDL_SRCCOLORKEY | SDL_RLEACCEL, - SDL_MapRGB (boat[0]->format, 0xff, 0x00, 0xff)); + SDL_SetColorKey(boat[0], SDL_SRCCOLORKEY | SDL_RLEACCEL, + SDL_MapRGB(boat[0]->format, 0xff, 0x00, 0xff)); boatcols = boat[0]->format->palette->ncolors; - boat[1] = hflip (boat[0]); - SDL_SetColorKey (boat[1], SDL_SRCCOLORKEY | SDL_RLEACCEL, - SDL_MapRGB (boat[1]->format, 0xff, 0x00, 0xff)); + boat[1] = hflip(boat[0]); + SDL_SetColorKey(boat[1], SDL_SRCCOLORKEY | SDL_RLEACCEL, + SDL_MapRGB(boat[1]->format, 0xff, 0x00, 0xff)); /* * First set the physical screen palette to black, so the user won't * see our initial drawing on the screen. */ - memset (cmap, 0, sizeof (cmap)); - SDL_SetPalette (screen, SDL_PHYSPAL, cmap, 0, 256); + memset(cmap, 0, sizeof(cmap)); + SDL_SetPalette(screen, SDL_PHYSPAL, cmap, 0, 256); /* * Proper palette management is important when playing games with the @@ -208,34 +207,34 @@ * index 0..(boatcols-1): used for the boat * index boatcols..(boatcols+63): used for the waves */ - SDL_SetPalette (screen, SDL_LOGPAL, - boat[0]->format->palette->colors, 0, boatcols); - SDL_SetPalette (screen, SDL_LOGPAL, wavemap, boatcols, 64); + SDL_SetPalette(screen, SDL_LOGPAL, + boat[0]->format->palette->colors, 0, boatcols); + SDL_SetPalette(screen, SDL_LOGPAL, wavemap, boatcols, 64); /* * Now the logical screen palette is set, and will remain unchanged. * The boats already have the same palette so fast blits can be used. */ - memcpy (cmap, screen->format->palette->colors, 256 * sizeof (SDL_Color)); + memcpy(cmap, screen->format->palette->colors, 256 * sizeof(SDL_Color)); /* save the index of the red colour for later */ - red = SDL_MapRGB (screen->format, 0xff, 0x00, 0x00); + red = SDL_MapRGB(screen->format, 0xff, 0x00, 0x00); - bg = make_bg (screen, boatcols); /* make a nice wavy background surface */ + bg = make_bg(screen, boatcols); /* make a nice wavy background surface */ /* initial screen contents */ - if (SDL_BlitSurface (bg, NULL, screen, NULL) < 0) - sdlerr ("blitting background to screen"); - SDL_Flip (screen); /* actually put the background on screen */ + if (SDL_BlitSurface(bg, NULL, screen, NULL) < 0) + sdlerr("blitting background to screen"); + SDL_Flip(screen); /* actually put the background on screen */ /* determine initial boat placements */ for (i = 0; i < NBOATS; i++) { - boatx[i] = (rand () % (SCRW + boat[0]->w)) - boat[0]->w; + boatx[i] = (rand() % (SCRW + boat[0]->w)) - boat[0]->w; boaty[i] = i * (SCRH - boat[0]->h) / (NBOATS - 1); - boatdir[i] = ((rand () >> 5) & 1) * 2 - 1; + boatdir[i] = ((rand() >> 5) & 1) * 2 - 1; } - start = SDL_GetTicks (); + start = SDL_GetTicks(); frames = 0; fade_dir = 1; fade_level = 0; @@ -246,7 +245,7 @@ int redphase; /* A small event loop: just exit on any key or mouse button event */ - while (SDL_PollEvent (&e)) { + while (SDL_PollEvent(&e)) { if (e.type == SDL_KEYDOWN || e.type == SDL_QUIT || e.type == SDL_MOUSEBUTTONDOWN) { if (fade_dir < 0) @@ -268,11 +267,11 @@ r.y = boaty[i]; r.w = boat[0]->w; r.h = boat[0]->h; - if (SDL_BlitSurface (bg, &r, screen, &r) < 0) - sdlerr ("blitting background"); + if (SDL_BlitSurface(bg, &r, screen, &r) < 0) + sdlerr("blitting background"); /* construct update rectangle (bounding box of old and new pos) */ - updates[i].x = MIN (old_x, boatx[i]); + updates[i].x = MIN(old_x, boatx[i]); updates[i].y = boaty[i]; updates[i].w = boat[0]->w + SPEED; updates[i].h = boat[0]->h; @@ -289,9 +288,9 @@ /* paint boat on new position */ r.x = boatx[i]; r.y = boaty[i]; - if (SDL_BlitSurface (boat[(boatdir[i] + 1) / 2], NULL, - screen, &r) < 0) - sdlerr ("blitting boat"); + if (SDL_BlitSurface(boat[(boatdir[i] + 1) / 2], NULL, + screen, &r) < 0) + sdlerr("blitting boat"); } /* cycle wave palette */ @@ -305,21 +304,21 @@ if (gamma_fade) { /* Fade linearly in gamma level (lousy) */ float level = (float) fade_level / fade_max; - if (SDL_SetGamma (level, level, level) < 0) - sdlerr ("setting gamma"); + if (SDL_SetGamma(level, level, level) < 0) + sdlerr("setting gamma"); } else if (gamma_ramp) { /* Fade using gamma ramp (better) */ Uint16 ramp[256]; for (i = 0; i < 256; i++) ramp[i] = (i * fade_level / fade_max) << 8; - if (SDL_SetGammaRamp (ramp, ramp, ramp) < 0) - sdlerr ("setting gamma ramp"); + if (SDL_SetGammaRamp(ramp, ramp, ramp) < 0) + sdlerr("setting gamma ramp"); } else { /* Fade using direct palette manipulation (best) */ - memcpy (cmap, screen->format->palette->colors, - boatcols * sizeof (SDL_Color)); + memcpy(cmap, screen->format->palette->colors, + boatcols * sizeof(SDL_Color)); for (i = 0; i < boatcols + 64; i++) { cmap[i].r = cmap[i].r * fade_level / fade_max; cmap[i].g = cmap[i].g * fade_level / fade_max; @@ -332,21 +331,21 @@ /* pulse the red colour (done after the fade, for a night effect) */ redphase = frames % 64; - cmap[red].r = (int) (255 * sin (redphase * M_PI / 63)); + cmap[red].r = (int) (255 * sin(redphase * M_PI / 63)); - SDL_SetPalette (screen, SDL_PHYSPAL, cmap, 0, boatcols + 64); + SDL_SetPalette(screen, SDL_PHYSPAL, cmap, 0, boatcols + 64); /* update changed areas of the screen */ - SDL_UpdateRects (screen, NBOATS, updates); + SDL_UpdateRects(screen, NBOATS, updates); frames++; } while (fade_level > 0); - printf ("%d frames, %.2f fps\n", - frames, 1000.0 * frames / (SDL_GetTicks () - start)); + printf("%d frames, %.2f fps\n", + frames, 1000.0 * frames / (SDL_GetTicks() - start)); if (vidflags & SDL_FULLSCREEN) - SDL_ShowCursor (SDL_TRUE); - SDL_Quit (); + SDL_ShowCursor(SDL_TRUE); + SDL_Quit(); return 0; } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testplatform.c --- a/test/testplatform.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testplatform.c Mon May 29 04:04:35 2006 +0000 @@ -11,50 +11,50 @@ * compiler quiet. --ryan. */ static int -badsize (size_t sizeoftype, size_t hardcodetype) +badsize(size_t sizeoftype, size_t hardcodetype) { return sizeoftype != hardcodetype; } int -TestTypes (SDL_bool verbose) +TestTypes(SDL_bool verbose) { int error = 0; - if (badsize (sizeof (Uint8), 1)) { + if (badsize(sizeof(Uint8), 1)) { if (verbose) - printf ("sizeof(Uint8) != 1, instead = %ul\n", sizeof (Uint8)); + printf("sizeof(Uint8) != 1, instead = %ul\n", sizeof(Uint8)); ++error; } - if (badsize (sizeof (Uint16), 2)) { + if (badsize(sizeof(Uint16), 2)) { if (verbose) - printf ("sizeof(Uint16) != 2, instead = %ul\n", sizeof (Uint16)); + printf("sizeof(Uint16) != 2, instead = %ul\n", sizeof(Uint16)); ++error; } - if (badsize (sizeof (Uint32), 4)) { + if (badsize(sizeof(Uint32), 4)) { if (verbose) - printf ("sizeof(Uint32) != 4, instead = %ul\n", sizeof (Uint32)); + printf("sizeof(Uint32) != 4, instead = %ul\n", sizeof(Uint32)); ++error; } #ifdef SDL_HAS_64BIT_TYPE - if (badsize (sizeof (Uint64), 8)) { + if (badsize(sizeof(Uint64), 8)) { if (verbose) - printf ("sizeof(Uint64) != 8, instead = %ul\n", sizeof (Uint64)); + printf("sizeof(Uint64) != 8, instead = %ul\n", sizeof(Uint64)); ++error; } #else if (verbose) { - printf ("WARNING: No 64-bit datatype on this platform\n"); + printf("WARNING: No 64-bit datatype on this platform\n"); } #endif if (verbose && !error) - printf ("All data types are the expected size.\n"); + printf("All data types are the expected size.\n"); return (error ? 1 : 0); } int -TestEndian (SDL_bool verbose) +TestEndian(SDL_bool verbose) { int error = 0; Uint16 value = 0x1234; @@ -74,8 +74,8 @@ #endif if (verbose) { - printf ("Detected a %s endian machine.\n", - (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big"); + printf("Detected a %s endian machine.\n", + (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big"); } if ((*((char *) &value) >> 4) == 0x1) { real_byteorder = SDL_BIG_ENDIAN; @@ -84,44 +84,44 @@ } if (real_byteorder != SDL_BYTEORDER) { if (verbose) { - printf ("Actually a %s endian machine!\n", - (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big"); + printf("Actually a %s endian machine!\n", + (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big"); } ++error; } if (verbose) { - printf ("Value 16 = 0x%X, swapped = 0x%X\n", value16, - SDL_Swap16 (value16)); + printf("Value 16 = 0x%X, swapped = 0x%X\n", value16, + SDL_Swap16(value16)); } - if (SDL_Swap16 (value16) != swapped16) { + if (SDL_Swap16(value16) != swapped16) { if (verbose) { - printf ("16 bit value swapped incorrectly!\n"); + printf("16 bit value swapped incorrectly!\n"); } ++error; } if (verbose) { - printf ("Value 32 = 0x%X, swapped = 0x%X\n", value32, - SDL_Swap32 (value32)); + printf("Value 32 = 0x%X, swapped = 0x%X\n", value32, + SDL_Swap32(value32)); } - if (SDL_Swap32 (value32) != swapped32) { + if (SDL_Swap32(value32) != swapped32) { if (verbose) { - printf ("32 bit value swapped incorrectly!\n"); + printf("32 bit value swapped incorrectly!\n"); } ++error; } #ifdef SDL_HAS_64BIT_TYPE if (verbose) { #ifdef _MSC_VER - printf ("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64, - SDL_Swap64 (value64)); + printf("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64, + SDL_Swap64(value64)); #else - printf ("Value 64 = 0x%llX, swapped = 0x%llX\n", value64, - SDL_Swap64 (value64)); + printf("Value 64 = 0x%llX, swapped = 0x%llX\n", value64, + SDL_Swap64(value64)); #endif } - if (SDL_Swap64 (value64) != swapped64) { + if (SDL_Swap64(value64) != swapped64) { if (verbose) { - printf ("64 bit value swapped incorrectly!\n"); + printf("64 bit value swapped incorrectly!\n"); } ++error; } @@ -131,87 +131,85 @@ int -TestCPUInfo (SDL_bool verbose) +TestCPUInfo(SDL_bool verbose) { if (verbose) { - printf ("RDTSC %s\n", SDL_HasRDTSC ()? "detected" : "not detected"); - printf ("MMX %s\n", SDL_HasMMX ()? "detected" : "not detected"); - printf ("MMX Ext %s\n", - SDL_HasMMXExt ()? "detected" : "not detected"); - printf ("3DNow %s\n", SDL_Has3DNow ()? "detected" : "not detected"); - printf ("3DNow Ext %s\n", - SDL_Has3DNowExt ()? "detected" : "not detected"); - printf ("SSE %s\n", SDL_HasSSE ()? "detected" : "not detected"); - printf ("SSE2 %s\n", SDL_HasSSE2 ()? "detected" : "not detected"); - printf ("AltiVec %s\n", - SDL_HasAltiVec ()? "detected" : "not detected"); + printf("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected"); + printf("MMX %s\n", SDL_HasMMX()? "detected" : "not detected"); + printf("MMX Ext %s\n", SDL_HasMMXExt()? "detected" : "not detected"); + printf("3DNow %s\n", SDL_Has3DNow()? "detected" : "not detected"); + printf("3DNow Ext %s\n", + SDL_Has3DNowExt()? "detected" : "not detected"); + printf("SSE %s\n", SDL_HasSSE()? "detected" : "not detected"); + printf("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected"); + printf("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected"); } return (0); } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SDL_bool verbose = SDL_TRUE; int status = 0; - if (argv[1] && (SDL_strcmp (argv[1], "-q") == 0)) { + if (argv[1] && (SDL_strcmp(argv[1], "-q") == 0)) { verbose = SDL_FALSE; } if (verbose) { - printf ("This system is running %s\n", + printf("This system is running %s\n", #if __AIX__ - "AIX" + "AIX" #elif __AMIGA__ - "AmigaOS" + "AmigaOS" #elif __BEOS__ - "BeOS" + "BeOS" #elif __BSDI__ - "BSDI" + "BSDI" #elif __DREAMCAST__ - "Dreamcast" + "Dreamcast" #elif __FREEBSD__ - "FreeBSD" + "FreeBSD" #elif __HPUX__ - "HP-UX" + "HP-UX" #elif __IRIX__ - "Irix" + "Irix" #elif __LINUX__ - "Linux" + "Linux" #elif __MINT__ - "Atari MiNT" + "Atari MiNT" #elif __MACOS__ - "MacOS Classic" + "MacOS Classic" #elif __MACOSX__ - "Mac OS X" + "Mac OS X" #elif __NETBSD__ - "NetBSD" + "NetBSD" #elif __OPENBSD__ - "OpenBSD" + "OpenBSD" #elif __OS2__ - "OS/2" + "OS/2" #elif __OSF__ - "OSF/1" + "OSF/1" #elif __QNXNTO__ - "QNX Neutrino" + "QNX Neutrino" #elif __RISCOS__ - "RISC OS" + "RISC OS" #elif __SOLARIS__ - "Solaris" + "Solaris" #elif __WIN32__ #ifdef _WIN32_WCE - "Windows CE" + "Windows CE" #else - "Windows" + "Windows" #endif #else - "an unknown operating system! (see SDL_platform.h)" + "an unknown operating system! (see SDL_platform.h)" #endif ); } - status += TestTypes (verbose); - status += TestEndian (verbose); - status += TestCPUInfo (verbose); + status += TestTypes(verbose); + status += TestEndian(verbose); + status += TestCPUInfo(verbose); return status; } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testsem.c --- a/test/testsem.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testsem.c Mon May 29 04:04:35 2006 +0000 @@ -14,73 +14,73 @@ int alive = 1; int SDLCALL -ThreadFunc (void *data) +ThreadFunc(void *data) { int threadnum = (int) (uintptr_t) data; while (alive) { - SDL_SemWait (sem); - fprintf (stderr, - "Thread number %d has got the semaphore (value = %d)!\n", - threadnum, SDL_SemValue (sem)); - SDL_Delay (200); - SDL_SemPost (sem); - fprintf (stderr, - "Thread number %d has released the semaphore (value = %d)!\n", - threadnum, SDL_SemValue (sem)); - SDL_Delay (1); /* For the scheduler */ + SDL_SemWait(sem); + fprintf(stderr, + "Thread number %d has got the semaphore (value = %d)!\n", + threadnum, SDL_SemValue(sem)); + SDL_Delay(200); + SDL_SemPost(sem); + fprintf(stderr, + "Thread number %d has released the semaphore (value = %d)!\n", + threadnum, SDL_SemValue(sem)); + SDL_Delay(1); /* For the scheduler */ } - printf ("Thread number %d exiting.\n", threadnum); + printf("Thread number %d exiting.\n", threadnum); return 0; } static void -killed (int sig) +killed(int sig) { alive = 0; } int -main (int argc, char **argv) +main(int argc, char **argv) { SDL_Thread *threads[NUM_THREADS]; uintptr_t i; int init_sem; if (argc < 2) { - fprintf (stderr, "Usage: %s init_value\n", argv[0]); + fprintf(stderr, "Usage: %s init_value\n", argv[0]); return (1); } /* Load the SDL library */ - if (SDL_Init (0) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(0) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } - signal (SIGTERM, killed); - signal (SIGINT, killed); + signal(SIGTERM, killed); + signal(SIGINT, killed); - init_sem = atoi (argv[1]); - sem = SDL_CreateSemaphore (init_sem); + init_sem = atoi(argv[1]); + sem = SDL_CreateSemaphore(init_sem); - printf ("Running %d threads, semaphore value = %d\n", NUM_THREADS, - init_sem); + printf("Running %d threads, semaphore value = %d\n", NUM_THREADS, + init_sem); /* Create all the threads */ for (i = 0; i < NUM_THREADS; ++i) { - threads[i] = SDL_CreateThread (ThreadFunc, (void *) i); + threads[i] = SDL_CreateThread(ThreadFunc, (void *) i); } /* Wait 10 seconds */ - SDL_Delay (10 * 1000); + SDL_Delay(10 * 1000); /* Wait for all threads to finish */ - printf ("Waiting for threads to finish\n"); + printf("Waiting for threads to finish\n"); alive = 0; for (i = 0; i < NUM_THREADS; ++i) { - SDL_WaitThread (threads[i], NULL); + SDL_WaitThread(threads[i], NULL); } - printf ("Finished waiting for threads\n"); + printf("Finished waiting for threads\n"); - SDL_DestroySemaphore (sem); - SDL_Quit (); + SDL_DestroySemaphore(sem); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testsprite.c --- a/test/testsprite.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testsprite.c Mon May 29 04:04:35 2006 +0000 @@ -23,36 +23,35 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } int -LoadSprite (char *file) +LoadSprite(char *file) { SDL_Surface *temp; /* Load the sprite image */ - sprite = SDL_LoadBMP (file); + sprite = SDL_LoadBMP(file); if (sprite == NULL) { - fprintf (stderr, "Couldn't load %s: %s", file, SDL_GetError ()); + fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError()); return (-1); } /* Set transparent pixel as the pixel at (0,0) */ if (sprite->format->palette) { - SDL_SetColorKey (sprite, (SDL_SRCCOLORKEY | SDL_RLEACCEL), - *(Uint8 *) sprite->pixels); + SDL_SetColorKey(sprite, (SDL_SRCCOLORKEY | SDL_RLEACCEL), + *(Uint8 *) sprite->pixels); } /* Convert sprite to video format */ - temp = SDL_DisplayFormat (sprite); - SDL_FreeSurface (sprite); + temp = SDL_DisplayFormat(sprite); + SDL_FreeSurface(sprite); if (temp == NULL) { - fprintf (stderr, "Couldn't convert background: %s\n", - SDL_GetError ()); + fprintf(stderr, "Couldn't convert background: %s\n", SDL_GetError()); return (-1); } sprite = temp; @@ -62,7 +61,7 @@ } void -MoveSprites (SDL_Surface * screen, Uint32 background) +MoveSprites(SDL_Surface * screen, Uint32 background) { int i, nupdates; SDL_Rect area, *position, *velocity; @@ -70,7 +69,7 @@ nupdates = 0; /* Erase all the sprites if necessary */ if (sprites_visible) { - SDL_FillRect (screen, NULL, background); + SDL_FillRect(screen, NULL, background); } /* Move the sprite, bounce at the wall, and draw */ @@ -90,7 +89,7 @@ /* Blit the sprite onto the screen */ area = *position; - SDL_BlitSurface (sprite, NULL, screen, &area); + SDL_BlitSurface(sprite, NULL, screen, &area); sprite_rects[nupdates++] = area; } @@ -98,31 +97,31 @@ if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { static int t = 0; - Uint32 color = SDL_MapRGB (screen->format, 255, 0, 0); + Uint32 color = SDL_MapRGB(screen->format, 255, 0, 0); SDL_Rect r; r.x = - (sin ((float) t * 2 * 3.1459) + 1.0) / 2.0 * (screen->w - 20); + (sin((float) t * 2 * 3.1459) + 1.0) / 2.0 * (screen->w - 20); r.y = 0; r.w = 20; r.h = screen->h; - SDL_FillRect (screen, &r, color); + SDL_FillRect(screen, &r, color); t += 2; } } /* Update the screen! */ if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { - SDL_Flip (screen); + SDL_Flip(screen); } else { - SDL_UpdateRects (screen, nupdates, sprite_rects); + SDL_UpdateRects(screen, nupdates, sprite_rects); } sprites_visible = 1; } /* This is a way of telling whether or not to use hardware surfaces */ Uint32 -FastestFlags (Uint32 flags, int width, int height, int bpp) +FastestFlags(Uint32 flags, int width, int height, int bpp) { const SDL_VideoInfo *info; @@ -130,7 +129,7 @@ flags |= SDL_FULLSCREEN; /* Check for various video capabilities */ - info = SDL_GetVideoInfo (); + info = SDL_GetVideoInfo(); if (info->blit_hw_CC && info->blit_fill) { /* We use accelerated colorkeying and color filling */ flags |= SDL_HWSURFACE; @@ -154,7 +153,7 @@ } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SDL_Surface *screen; Uint8 *mem; @@ -167,8 +166,8 @@ Uint32 then, now, frames; /* Initialize SDL */ - if (SDL_Init (SDL_INIT_VIDEO) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } @@ -180,55 +179,55 @@ debug_flip = 0; while (argc > 1) { --argc; - if (strcmp (argv[argc - 1], "-width") == 0) { - width = atoi (argv[argc]); + if (strcmp(argv[argc - 1], "-width") == 0) { + width = atoi(argv[argc]); --argc; - } else if (strcmp (argv[argc - 1], "-height") == 0) { - height = atoi (argv[argc]); + } else if (strcmp(argv[argc - 1], "-height") == 0) { + height = atoi(argv[argc]); --argc; - } else if (strcmp (argv[argc - 1], "-bpp") == 0) { - video_bpp = atoi (argv[argc]); + } else if (strcmp(argv[argc - 1], "-bpp") == 0) { + video_bpp = atoi(argv[argc]); videoflags &= ~SDL_ANYFORMAT; --argc; - } else if (strcmp (argv[argc], "-fast") == 0) { - videoflags = FastestFlags (videoflags, width, height, video_bpp); - } else if (strcmp (argv[argc], "-hw") == 0) { + } else if (strcmp(argv[argc], "-fast") == 0) { + videoflags = FastestFlags(videoflags, width, height, video_bpp); + } else if (strcmp(argv[argc], "-hw") == 0) { videoflags ^= SDL_HWSURFACE; - } else if (strcmp (argv[argc], "-flip") == 0) { + } else if (strcmp(argv[argc], "-flip") == 0) { videoflags ^= SDL_DOUBLEBUF; - } else if (strcmp (argv[argc], "-debugflip") == 0) { + } else if (strcmp(argv[argc], "-debugflip") == 0) { debug_flip ^= 1; - } else if (strcmp (argv[argc], "-fullscreen") == 0) { + } else if (strcmp(argv[argc], "-fullscreen") == 0) { videoflags ^= SDL_FULLSCREEN; - } else if (isdigit (argv[argc][0])) { - numsprites = atoi (argv[argc]); + } else if (isdigit(argv[argc][0])) { + numsprites = atoi(argv[argc]); } else { - fprintf (stderr, - "Usage: %s [-bpp N] [-hw] [-flip] [-fast] [-fullscreen] [numsprites]\n", - argv[0]); - quit (1); + fprintf(stderr, + "Usage: %s [-bpp N] [-hw] [-flip] [-fast] [-fullscreen] [numsprites]\n", + argv[0]); + quit(1); } } /* Set video mode */ - screen = SDL_SetVideoMode (width, height, video_bpp, videoflags); + screen = SDL_SetVideoMode(width, height, video_bpp, videoflags); if (!screen) { - fprintf (stderr, "Couldn't set %dx%d video mode: %s\n", - width, height, SDL_GetError ()); - quit (2); + fprintf(stderr, "Couldn't set %dx%d video mode: %s\n", + width, height, SDL_GetError()); + quit(2); } /* Load the sprite */ - if (LoadSprite ("icon.bmp") < 0) { - quit (1); + if (LoadSprite("icon.bmp") < 0) { + quit(1); } /* Allocate memory for the sprite info */ - mem = (Uint8 *) malloc (4 * sizeof (SDL_Rect) * numsprites); + mem = (Uint8 *) malloc(4 * sizeof(SDL_Rect) * numsprites); if (mem == NULL) { - SDL_FreeSurface (sprite); - fprintf (stderr, "Out of memory!\n"); - quit (2); + SDL_FreeSurface(sprite); + fprintf(stderr, "Out of memory!\n"); + quit(2); } sprite_rects = (SDL_Rect *) mem; positions = sprite_rects; @@ -237,35 +236,35 @@ sprite_rects += numsprites; sprite_w = sprite->w; sprite_h = sprite->h; - srand (time (NULL)); + srand(time(NULL)); for (i = 0; i < numsprites; ++i) { - positions[i].x = rand () % (screen->w - sprite_w); - positions[i].y = rand () % (screen->h - sprite_h); + positions[i].x = rand() % (screen->w - sprite_w); + positions[i].y = rand() % (screen->h - sprite_h); positions[i].w = sprite->w; positions[i].h = sprite->h; velocities[i].x = 0; velocities[i].y = 0; while (!velocities[i].x && !velocities[i].y) { - velocities[i].x = (rand () % (MAX_SPEED * 2 + 1)) - MAX_SPEED; - velocities[i].y = (rand () % (MAX_SPEED * 2 + 1)) - MAX_SPEED; + velocities[i].x = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED; + velocities[i].y = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED; } } - background = SDL_MapRGB (screen->format, 0x00, 0x00, 0x00); + background = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00); /* Print out information about our surfaces */ - printf ("Screen is at %d bits per pixel\n", screen->format->BitsPerPixel); + printf("Screen is at %d bits per pixel\n", screen->format->BitsPerPixel); if ((screen->flags & SDL_HWSURFACE) == SDL_HWSURFACE) { - printf ("Screen is in video memory\n"); + printf("Screen is in video memory\n"); } else { - printf ("Screen is in system memory\n"); + printf("Screen is in system memory\n"); } if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { - printf ("Screen has double-buffering enabled\n"); + printf("Screen has double-buffering enabled\n"); } if ((sprite->flags & SDL_HWSURFACE) == SDL_HWSURFACE) { - printf ("Sprite is in video memory\n"); + printf("Sprite is in video memory\n"); } else { - printf ("Sprite is in system memory\n"); + printf("Sprite is in system memory\n"); } /* Run a sample blit to trigger blit acceleration */ { @@ -274,28 +273,28 @@ dst.y = 0; dst.w = sprite->w; dst.h = sprite->h; - SDL_BlitSurface (sprite, NULL, screen, &dst); - SDL_FillRect (screen, &dst, background); + SDL_BlitSurface(sprite, NULL, screen, &dst); + SDL_FillRect(screen, &dst, background); } if ((sprite->flags & SDL_HWACCEL) == SDL_HWACCEL) { - printf ("Sprite blit uses hardware acceleration\n"); + printf("Sprite blit uses hardware acceleration\n"); } if ((sprite->flags & SDL_RLEACCEL) == SDL_RLEACCEL) { - printf ("Sprite blit uses RLE acceleration\n"); + printf("Sprite blit uses RLE acceleration\n"); } /* Loop, blitting sprites and waiting for a keystroke */ frames = 0; - then = SDL_GetTicks (); + then = SDL_GetTicks(); done = 0; sprites_visible = 0; while (!done) { /* Check for events */ ++frames; - while (SDL_PollEvent (&event)) { + while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_MOUSEBUTTONDOWN: - SDL_WarpMouse (screen->w / 2, screen->h / 2); + SDL_WarpMouse(screen->w / 2, screen->h / 2); break; case SDL_KEYDOWN: /* Any keypress quits the app... */ @@ -306,17 +305,17 @@ break; } } - MoveSprites (screen, background); + MoveSprites(screen, background); } - SDL_FreeSurface (sprite); - free (mem); + SDL_FreeSurface(sprite); + free(mem); /* Print out some timing information */ - now = SDL_GetTicks (); + now = SDL_GetTicks(); if (now > then) { - printf ("%2.2f frames per second\n", - ((double) frames * 1000) / (now - then)); + printf("%2.2f frames per second\n", + ((double) frames * 1000) / (now - then)); } - SDL_Quit (); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testtimer.c --- a/test/testtimer.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testtimer.c Mon May 29 04:04:35 2006 +0000 @@ -13,78 +13,78 @@ static int ticks = 0; static Uint32 SDLCALL -ticktock (Uint32 interval) +ticktock(Uint32 interval) { ++ticks; return (interval); } static Uint32 SDLCALL -callback (Uint32 interval, void *param) +callback(Uint32 interval, void *param) { - printf ("Timer %d : param = %d\n", interval, (int) (uintptr_t) param); + printf("Timer %d : param = %d\n", interval, (int) (uintptr_t) param); return interval; } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { int desired; SDL_TimerID t1, t2, t3; - if (SDL_Init (SDL_INIT_TIMER) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(SDL_INIT_TIMER) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } /* Start the timer */ desired = 0; if (argv[1]) { - desired = atoi (argv[1]); + desired = atoi(argv[1]); } if (desired == 0) { desired = DEFAULT_RESOLUTION; } - SDL_SetTimer (desired, ticktock); + SDL_SetTimer(desired, ticktock); /* Wait 10 seconds */ - printf ("Waiting 10 seconds\n"); - SDL_Delay (10 * 1000); + printf("Waiting 10 seconds\n"); + SDL_Delay(10 * 1000); /* Stop the timer */ - SDL_SetTimer (0, NULL); + SDL_SetTimer(0, NULL); /* Print the results */ if (ticks) { - fprintf (stderr, - "Timer resolution: desired = %d ms, actual = %f ms\n", - desired, (double) (10 * 1000) / ticks); + fprintf(stderr, + "Timer resolution: desired = %d ms, actual = %f ms\n", + desired, (double) (10 * 1000) / ticks); } /* Test multiple timers */ - printf ("Testing multiple timers...\n"); - t1 = SDL_AddTimer (100, callback, (void *) 1); + printf("Testing multiple timers...\n"); + t1 = SDL_AddTimer(100, callback, (void *) 1); if (!t1) - fprintf (stderr, "Could not create timer 1: %s\n", SDL_GetError ()); - t2 = SDL_AddTimer (50, callback, (void *) 2); + fprintf(stderr, "Could not create timer 1: %s\n", SDL_GetError()); + t2 = SDL_AddTimer(50, callback, (void *) 2); if (!t2) - fprintf (stderr, "Could not create timer 2: %s\n", SDL_GetError ()); - t3 = SDL_AddTimer (233, callback, (void *) 3); + fprintf(stderr, "Could not create timer 2: %s\n", SDL_GetError()); + t3 = SDL_AddTimer(233, callback, (void *) 3); if (!t3) - fprintf (stderr, "Could not create timer 3: %s\n", SDL_GetError ()); + fprintf(stderr, "Could not create timer 3: %s\n", SDL_GetError()); /* Wait 10 seconds */ - printf ("Waiting 10 seconds\n"); - SDL_Delay (10 * 1000); + printf("Waiting 10 seconds\n"); + SDL_Delay(10 * 1000); - printf ("Removing timer 1 and waiting 5 more seconds\n"); - SDL_RemoveTimer (t1); + printf("Removing timer 1 and waiting 5 more seconds\n"); + SDL_RemoveTimer(t1); - SDL_Delay (5 * 1000); + SDL_Delay(5 * 1000); - SDL_RemoveTimer (t2); - SDL_RemoveTimer (t3); + SDL_RemoveTimer(t2); + SDL_RemoveTimer(t3); - SDL_Quit (); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testver.c --- a/test/testver.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testver.c Mon May 29 04:04:35 2006 +0000 @@ -9,29 +9,29 @@ #include "SDL.h" int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SDL_version compiled; /* Initialize SDL */ - if (SDL_Init (0) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); - exit (1); + if (SDL_Init(0) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + exit(1); } #ifdef DEBUG - fprintf (stderr, "SDL initialized\n"); + fprintf(stderr, "SDL initialized\n"); #endif #if SDL_VERSION_ATLEAST(1, 2, 0) - printf ("Compiled with SDL 1.2 or newer\n"); + printf("Compiled with SDL 1.2 or newer\n"); #else - printf ("Compiled with SDL older than 1.2\n"); + printf("Compiled with SDL older than 1.2\n"); #endif - SDL_VERSION (&compiled); - printf ("Compiled version: %d.%d.%d\n", - compiled.major, compiled.minor, compiled.patch); - printf ("Linked version: %d.%d.%d\n", - SDL_Linked_Version ()->major, - SDL_Linked_Version ()->minor, SDL_Linked_Version ()->patch); - SDL_Quit (); + SDL_VERSION(&compiled); + printf("Compiled version: %d.%d.%d\n", + compiled.major, compiled.minor, compiled.patch); + printf("Linked version: %d.%d.%d\n", + SDL_Linked_Version()->major, + SDL_Linked_Version()->minor, SDL_Linked_Version()->patch); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testvidinfo.c --- a/test/testvidinfo.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testvidinfo.c Mon May 29 04:04:35 2006 +0000 @@ -17,36 +17,36 @@ #if 0 void -PrintFlags (Uint32 flags) +PrintFlags(Uint32 flags) { - printf ("0x%8.8x", (flags & FLAG_MASK)); + printf("0x%8.8x", (flags & FLAG_MASK)); if (flags & SDL_HWSURFACE) { - printf (" SDL_HWSURFACE"); + printf(" SDL_HWSURFACE"); } else { - printf (" SDL_SWSURFACE"); + printf(" SDL_SWSURFACE"); } if (flags & SDL_FULLSCREEN) { - printf (" | SDL_FULLSCREEN"); + printf(" | SDL_FULLSCREEN"); } if (flags & SDL_DOUBLEBUF) { - printf (" | SDL_DOUBLEBUF"); + printf(" | SDL_DOUBLEBUF"); } if (flags & SDL_SRCCOLORKEY) { - printf (" | SDL_SRCCOLORKEY"); + printf(" | SDL_SRCCOLORKEY"); } if (flags & SDL_SRCALPHA) { - printf (" | SDL_SRCALPHA"); + printf(" | SDL_SRCALPHA"); } if (flags & SDL_RLEACCEL) { - printf (" | SDL_RLEACCEL"); + printf(" | SDL_RLEACCEL"); } if (flags & SDL_RLEACCELOK) { - printf (" | SDL_RLEACCELOK"); + printf(" | SDL_RLEACCELOK"); } } int -RunBlitTests (SDL_Surface * screen, SDL_Surface * bmp, int blitcount) +RunBlitTests(SDL_Surface * screen, SDL_Surface * bmp, int blitcount) { int i, j; int maxx; @@ -58,27 +58,27 @@ for (i = 0; i < NUM_UPDATES; ++i) { for (j = 0; j < blitcount; ++j) { if (maxx) { - dst.x = rand () % maxx; + dst.x = rand() % maxx; } else { dst.x = 0; } if (maxy) { - dst.y = rand () % maxy; + dst.y = rand() % maxy; } else { dst.y = 0; } dst.w = bmp->w; dst.h = bmp->h; - SDL_BlitSurface (bmp, NULL, screen, &dst); + SDL_BlitSurface(bmp, NULL, screen, &dst); } - SDL_Flip (screen); + SDL_Flip(screen); } return i; } int -RunModeTests (SDL_Surface * screen) +RunModeTests(SDL_Surface * screen) { Uint32 then, now; Uint32 frames; @@ -88,212 +88,208 @@ SDL_Surface *bmp, *bmpcc, *tmp; SDL_Event event; - while (SDL_PollEvent (&event)) { + while (SDL_PollEvent(&event)) { if (event.type == SDL_KEYDOWN) return 0; } /* First test fills and screen update speed */ - printf ("Running color fill and fullscreen update test\n"); - then = SDL_GetTicks (); + printf("Running color fill and fullscreen update test\n"); + then = SDL_GetTicks(); frames = 0; for (i = 0; i < 256; ++i) { r = i; g = 0; b = 0; - SDL_FillRect (screen, NULL, SDL_MapRGB (screen->format, r, g, b)); - SDL_Flip (screen); + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, r, g, b)); + SDL_Flip(screen); ++frames; } for (i = 0; i < 256; ++i) { r = 0; g = i; b = 0; - SDL_FillRect (screen, NULL, SDL_MapRGB (screen->format, r, g, b)); - SDL_Flip (screen); + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, r, g, b)); + SDL_Flip(screen); ++frames; } for (i = 0; i < 256; ++i) { r = 0; g = 0; b = i; - SDL_FillRect (screen, NULL, SDL_MapRGB (screen->format, r, g, b)); - SDL_Flip (screen); + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, r, g, b)); + SDL_Flip(screen); ++frames; } - now = SDL_GetTicks (); + now = SDL_GetTicks(); seconds = (float) (now - then) / 1000.0f; if (seconds > 0.0f) { - printf ("%d fills and flips in %2.2f seconds, %2.2f FPS\n", frames, - seconds, (float) frames / seconds); + printf("%d fills and flips in %2.2f seconds, %2.2f FPS\n", frames, + seconds, (float) frames / seconds); } else { - printf ("%d fills and flips in zero seconds!n", frames); + printf("%d fills and flips in zero seconds!n", frames); } /* clear the screen after fill test */ - SDL_FillRect (screen, NULL, SDL_MapRGB (screen->format, 0, 0, 0)); - SDL_Flip (screen); + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); + SDL_Flip(screen); - while (SDL_PollEvent (&event)) { + while (SDL_PollEvent(&event)) { if (event.type == SDL_KEYDOWN) return 0; } /* run the generic blit test */ - bmp = SDL_LoadBMP ("sample.bmp"); + bmp = SDL_LoadBMP("sample.bmp"); if (!bmp) { - printf ("Couldn't load sample.bmp: %s\n", SDL_GetError ()); + printf("Couldn't load sample.bmp: %s\n", SDL_GetError()); return 0; } - printf ("Running freshly loaded blit test: %dx%d at %d bpp, flags: ", - bmp->w, bmp->h, bmp->format->BitsPerPixel); - PrintFlags (bmp->flags); - printf ("\n"); - then = SDL_GetTicks (); - frames = RunBlitTests (screen, bmp, NUM_BLITS); - now = SDL_GetTicks (); + printf("Running freshly loaded blit test: %dx%d at %d bpp, flags: ", + bmp->w, bmp->h, bmp->format->BitsPerPixel); + PrintFlags(bmp->flags); + printf("\n"); + then = SDL_GetTicks(); + frames = RunBlitTests(screen, bmp, NUM_BLITS); + now = SDL_GetTicks(); seconds = (float) (now - then) / 1000.0f; if (seconds > 0.0f) { - printf ("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", - NUM_BLITS * frames, frames, seconds, - (float) frames / seconds); + printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", + NUM_BLITS * frames, frames, seconds, (float) frames / seconds); } else { - printf ("%d blits / %d updates in zero seconds!\n", - NUM_BLITS * frames, frames); + printf("%d blits / %d updates in zero seconds!\n", + NUM_BLITS * frames, frames); } /* clear the screen after blit test */ - SDL_FillRect (screen, NULL, SDL_MapRGB (screen->format, 0, 0, 0)); - SDL_Flip (screen); + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); + SDL_Flip(screen); - while (SDL_PollEvent (&event)) { + while (SDL_PollEvent(&event)) { if (event.type == SDL_KEYDOWN) return 0; } /* run the colorkeyed blit test */ - bmpcc = SDL_LoadBMP ("sample.bmp"); + bmpcc = SDL_LoadBMP("sample.bmp"); if (!bmpcc) { - printf ("Couldn't load sample.bmp: %s\n", SDL_GetError ()); + printf("Couldn't load sample.bmp: %s\n", SDL_GetError()); return 0; } - printf ("Running freshly loaded cc blit test: %dx%d at %d bpp, flags: ", - bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel); - SDL_SetColorKey (bmpcc, SDL_SRCCOLORKEY | SDL_RLEACCEL, - *(Uint8 *) bmpcc->pixels); + printf("Running freshly loaded cc blit test: %dx%d at %d bpp, flags: ", + bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel); + SDL_SetColorKey(bmpcc, SDL_SRCCOLORKEY | SDL_RLEACCEL, + *(Uint8 *) bmpcc->pixels); - PrintFlags (bmpcc->flags); - printf ("\n"); - then = SDL_GetTicks (); - frames = RunBlitTests (screen, bmpcc, NUM_BLITS); - now = SDL_GetTicks (); + PrintFlags(bmpcc->flags); + printf("\n"); + then = SDL_GetTicks(); + frames = RunBlitTests(screen, bmpcc, NUM_BLITS); + now = SDL_GetTicks(); seconds = (float) (now - then) / 1000.0f; if (seconds > 0.0f) { - printf ("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n", - NUM_BLITS * frames, frames, seconds, - (float) frames / seconds); + printf("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n", + NUM_BLITS * frames, frames, seconds, (float) frames / seconds); } else { - printf ("%d cc blits / %d updates in zero seconds!\n", - NUM_BLITS * frames, frames); + printf("%d cc blits / %d updates in zero seconds!\n", + NUM_BLITS * frames, frames); } /* clear the screen after cc blit test */ - SDL_FillRect (screen, NULL, SDL_MapRGB (screen->format, 0, 0, 0)); - SDL_Flip (screen); + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); + SDL_Flip(screen); - while (SDL_PollEvent (&event)) { + while (SDL_PollEvent(&event)) { if (event.type == SDL_KEYDOWN) return 0; } /* run the generic blit test */ tmp = bmp; - bmp = SDL_DisplayFormat (bmp); - SDL_FreeSurface (tmp); + bmp = SDL_DisplayFormat(bmp); + SDL_FreeSurface(tmp); if (!bmp) { - printf ("Couldn't convert sample.bmp: %s\n", SDL_GetError ()); + printf("Couldn't convert sample.bmp: %s\n", SDL_GetError()); return 0; } - printf ("Running display format blit test: %dx%d at %d bpp, flags: ", - bmp->w, bmp->h, bmp->format->BitsPerPixel); - PrintFlags (bmp->flags); - printf ("\n"); - then = SDL_GetTicks (); - frames = RunBlitTests (screen, bmp, NUM_BLITS); - now = SDL_GetTicks (); + printf("Running display format blit test: %dx%d at %d bpp, flags: ", + bmp->w, bmp->h, bmp->format->BitsPerPixel); + PrintFlags(bmp->flags); + printf("\n"); + then = SDL_GetTicks(); + frames = RunBlitTests(screen, bmp, NUM_BLITS); + now = SDL_GetTicks(); seconds = (float) (now - then) / 1000.0f; if (seconds > 0.0f) { - printf ("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", - NUM_BLITS * frames, frames, seconds, - (float) frames / seconds); + printf("%d blits / %d updates in %2.2f seconds, %2.2f FPS\n", + NUM_BLITS * frames, frames, seconds, (float) frames / seconds); } else { - printf ("%d blits / %d updates in zero seconds!\n", - NUM_BLITS * frames, frames); + printf("%d blits / %d updates in zero seconds!\n", + NUM_BLITS * frames, frames); } /* clear the screen after blit test */ - SDL_FillRect (screen, NULL, SDL_MapRGB (screen->format, 0, 0, 0)); - SDL_Flip (screen); + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); + SDL_Flip(screen); - while (SDL_PollEvent (&event)) { + while (SDL_PollEvent(&event)) { if (event.type == SDL_KEYDOWN) return 0; } /* run the colorkeyed blit test */ tmp = bmpcc; - bmpcc = SDL_DisplayFormat (bmpcc); - SDL_FreeSurface (tmp); + bmpcc = SDL_DisplayFormat(bmpcc); + SDL_FreeSurface(tmp); if (!bmpcc) { - printf ("Couldn't convert sample.bmp: %s\n", SDL_GetError ()); + printf("Couldn't convert sample.bmp: %s\n", SDL_GetError()); return 0; } - printf ("Running display format cc blit test: %dx%d at %d bpp, flags: ", - bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel); - PrintFlags (bmpcc->flags); - printf ("\n"); - then = SDL_GetTicks (); - frames = RunBlitTests (screen, bmpcc, NUM_BLITS); - now = SDL_GetTicks (); + printf("Running display format cc blit test: %dx%d at %d bpp, flags: ", + bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel); + PrintFlags(bmpcc->flags); + printf("\n"); + then = SDL_GetTicks(); + frames = RunBlitTests(screen, bmpcc, NUM_BLITS); + now = SDL_GetTicks(); seconds = (float) (now - then) / 1000.0f; if (seconds > 0.0f) { - printf ("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n", - NUM_BLITS * frames, frames, seconds, - (float) frames / seconds); + printf("%d cc blits / %d updates in %2.2f seconds, %2.2f FPS\n", + NUM_BLITS * frames, frames, seconds, (float) frames / seconds); } else { - printf ("%d cc blits / %d updates in zero seconds!\n", - NUM_BLITS * frames, frames); + printf("%d cc blits / %d updates in zero seconds!\n", + NUM_BLITS * frames, frames); } /* clear the screen after cc blit test */ - SDL_FillRect (screen, NULL, SDL_MapRGB (screen->format, 0, 0, 0)); - SDL_Flip (screen); + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); + SDL_Flip(screen); - while (SDL_PollEvent (&event)) { + while (SDL_PollEvent(&event)) { if (event.type == SDL_KEYDOWN) return 0; } /* run the alpha blit test only if screen bpp>8 */ if (bmp->format->BitsPerPixel > 8) { - SDL_FreeSurface (bmp); - bmp = SDL_LoadBMP ("sample.bmp"); - SDL_SetAlpha (bmp, SDL_SRCALPHA, 85); /* 85 - 33% alpha */ + SDL_FreeSurface(bmp); + bmp = SDL_LoadBMP("sample.bmp"); + SDL_SetAlpha(bmp, SDL_SRCALPHA, 85); /* 85 - 33% alpha */ tmp = bmp; - bmp = SDL_DisplayFormat (bmp); - SDL_FreeSurface (tmp); + bmp = SDL_DisplayFormat(bmp); + SDL_FreeSurface(tmp); if (!bmp) { - printf ("Couldn't convert sample.bmp: %s\n", SDL_GetError ()); + printf("Couldn't convert sample.bmp: %s\n", SDL_GetError()); return 0; } printf ("Running display format alpha blit test: %dx%d at %d bpp, flags: ", bmp->w, bmp->h, bmp->format->BitsPerPixel); - PrintFlags (bmp->flags); - printf ("\n"); - then = SDL_GetTicks (); - frames = RunBlitTests (screen, bmp, NUM_BLITS); - now = SDL_GetTicks (); + PrintFlags(bmp->flags); + printf("\n"); + then = SDL_GetTicks(); + frames = RunBlitTests(screen, bmp, NUM_BLITS); + now = SDL_GetTicks(); seconds = (float) (now - then) / 1000.0f; if (seconds > 0.0f) { printf @@ -301,42 +297,42 @@ NUM_BLITS * frames, frames, seconds, (float) frames / seconds); } else { - printf ("%d alpha blits / %d updates in zero seconds!\n", - NUM_BLITS * frames, frames); + printf("%d alpha blits / %d updates in zero seconds!\n", + NUM_BLITS * frames, frames); } } /* clear the screen after alpha blit test */ - SDL_FillRect (screen, NULL, SDL_MapRGB (screen->format, 0, 0, 0)); - SDL_Flip (screen); + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); + SDL_Flip(screen); - while (SDL_PollEvent (&event)) { + while (SDL_PollEvent(&event)) { if (event.type == SDL_KEYDOWN) return 0; } /* run the cc+alpha blit test only if screen bpp>8 */ if (bmp->format->BitsPerPixel > 8) { - SDL_FreeSurface (bmpcc); - bmpcc = SDL_LoadBMP ("sample.bmp"); - SDL_SetAlpha (bmpcc, SDL_SRCALPHA, 85); /* 85 - 33% alpha */ - SDL_SetColorKey (bmpcc, SDL_SRCCOLORKEY | SDL_RLEACCEL, - *(Uint8 *) bmpcc->pixels); + SDL_FreeSurface(bmpcc); + bmpcc = SDL_LoadBMP("sample.bmp"); + SDL_SetAlpha(bmpcc, SDL_SRCALPHA, 85); /* 85 - 33% alpha */ + SDL_SetColorKey(bmpcc, SDL_SRCCOLORKEY | SDL_RLEACCEL, + *(Uint8 *) bmpcc->pixels); tmp = bmpcc; - bmpcc = SDL_DisplayFormat (bmpcc); - SDL_FreeSurface (tmp); + bmpcc = SDL_DisplayFormat(bmpcc); + SDL_FreeSurface(tmp); if (!bmpcc) { - printf ("Couldn't convert sample.bmp: %s\n", SDL_GetError ()); + printf("Couldn't convert sample.bmp: %s\n", SDL_GetError()); return 0; } printf ("Running display format cc+alpha blit test: %dx%d at %d bpp, flags: ", bmpcc->w, bmpcc->h, bmpcc->format->BitsPerPixel); - PrintFlags (bmpcc->flags); - printf ("\n"); - then = SDL_GetTicks (); - frames = RunBlitTests (screen, bmpcc, NUM_BLITS); - now = SDL_GetTicks (); + PrintFlags(bmpcc->flags); + printf("\n"); + then = SDL_GetTicks(); + frames = RunBlitTests(screen, bmpcc, NUM_BLITS); + now = SDL_GetTicks(); seconds = (float) (now - then) / 1000.0f; if (seconds > 0.0f) { printf @@ -344,15 +340,15 @@ NUM_BLITS * frames, frames, seconds, (float) frames / seconds); } else { - printf ("%d cc+alpha blits / %d updates in zero seconds!\n", - NUM_BLITS * frames, frames); + printf("%d cc+alpha blits / %d updates in zero seconds!\n", + NUM_BLITS * frames, frames); } } - SDL_FreeSurface (bmpcc); - SDL_FreeSurface (bmp); + SDL_FreeSurface(bmpcc); + SDL_FreeSurface(bmp); - while (SDL_PollEvent (&event)) { + while (SDL_PollEvent(&event)) { if (event.type == SDL_KEYDOWN) return 0; } @@ -360,7 +356,7 @@ } void -RunVideoTests () +RunVideoTests() { static const struct { @@ -387,29 +383,29 @@ SDL_Surface *screen; /* Test out several different video mode combinations */ - SDL_WM_SetCaption ("SDL Video Benchmark", "vidtest"); - SDL_ShowCursor (0); - for (i = 0; i < SDL_TABLESIZE (mode_list); ++i) { - for (j = 0; j < SDL_TABLESIZE (flags); ++j) { - printf ("===================================\n"); - printf ("Setting video mode: %dx%d at %d bpp, flags: ", - mode_list[i].w, mode_list[i].h, mode_list[i].bpp); - PrintFlags (flags[j]); - printf ("\n"); - screen = SDL_SetVideoMode (mode_list[i].w, - mode_list[i].h, - mode_list[i].bpp, flags[j]); + SDL_WM_SetCaption("SDL Video Benchmark", "vidtest"); + SDL_ShowCursor(0); + for (i = 0; i < SDL_TABLESIZE(mode_list); ++i) { + for (j = 0; j < SDL_TABLESIZE(flags); ++j) { + printf("===================================\n"); + printf("Setting video mode: %dx%d at %d bpp, flags: ", + mode_list[i].w, mode_list[i].h, mode_list[i].bpp); + PrintFlags(flags[j]); + printf("\n"); + screen = SDL_SetVideoMode(mode_list[i].w, + mode_list[i].h, + mode_list[i].bpp, flags[j]); if (!screen) { - printf ("Setting video mode failed: %s\n", SDL_GetError ()); + printf("Setting video mode failed: %s\n", SDL_GetError()); continue; } if ((screen->flags & FLAG_MASK) != flags[j]) { - printf ("Flags didn't match: "); - PrintFlags (screen->flags); - printf ("\n"); + printf("Flags didn't match: "); + PrintFlags(screen->flags); + printf("\n"); continue; } - if (!RunModeTests (screen)) { + if (!RunModeTests(screen)) { return; } } @@ -418,7 +414,7 @@ #endif int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { const SDL_VideoInfo *info; int i, n; @@ -429,78 +425,78 @@ int nmodes; /* Print available video drivers */ - n = SDL_GetNumVideoDrivers (); + n = SDL_GetNumVideoDrivers(); if (n == 0) { - printf ("No built-in video drivers\n"); + printf("No built-in video drivers\n"); } else { - printf ("Built-in video drivers:"); + printf("Built-in video drivers:"); for (i = 0; i < n; ++i) { if (i > 0) { - printf (","); + printf(","); } - printf (" %s", SDL_GetVideoDriver (i)); + printf(" %s", SDL_GetVideoDriver(i)); } - printf ("\n"); + printf("\n"); } - if (SDL_Init (SDL_INIT_VIDEO) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); - exit (1); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); + exit(1); } - driver = SDL_GetCurrentVideoDriver (); + driver = SDL_GetCurrentVideoDriver(); if (driver) { - printf ("Video driver: %s\n", driver); + printf("Video driver: %s\n", driver); } - printf ("Number of displays: %d\n", SDL_GetNumVideoDisplays ()); - mode = SDL_GetDesktopDisplayMode (); - SDL_PixelFormatEnumToMasks (mode->format, &bpp, &Rmask, &Gmask, &Bmask, - &Amask); - printf ("Current display: %dx%d@%dHz, %d bits-per-pixel\n", mode->w, - mode->h, mode->refresh_rate, bpp); + printf("Number of displays: %d\n", SDL_GetNumVideoDisplays()); + mode = SDL_GetDesktopDisplayMode(); + SDL_PixelFormatEnumToMasks(mode->format, &bpp, &Rmask, &Gmask, &Bmask, + &Amask); + printf("Current display: %dx%d@%dHz, %d bits-per-pixel\n", mode->w, + mode->h, mode->refresh_rate, bpp); if (Rmask || Gmask || Bmask) { - printf (" Red Mask = 0x%.8x\n", Rmask); - printf (" Green Mask = 0x%.8x\n", Gmask); - printf (" Blue Mask = 0x%.8x\n", Bmask); + printf(" Red Mask = 0x%.8x\n", Rmask); + printf(" Green Mask = 0x%.8x\n", Gmask); + printf(" Blue Mask = 0x%.8x\n", Bmask); if (Amask) - printf (" Alpha Mask = 0x%.8x\n", Amask); + printf(" Alpha Mask = 0x%.8x\n", Amask); } /* Print available fullscreen video modes */ - nmodes = SDL_GetNumDisplayModes (); + nmodes = SDL_GetNumDisplayModes(); if (nmodes == 0) { - printf ("No available fullscreen video modes\n"); + printf("No available fullscreen video modes\n"); } else { - printf ("Fullscreen video modes:\n"); + printf("Fullscreen video modes:\n"); for (i = 0; i < nmodes; ++i) { - mode = SDL_GetDisplayMode (i); - SDL_PixelFormatEnumToMasks (mode->format, &bpp, &Rmask, - &Gmask, &Bmask, &Amask); - printf ("Mode %d: %dx%d@%dHz, %d bits-per-pixel\n", i, - mode->w, mode->h, mode->refresh_rate, bpp); + mode = SDL_GetDisplayMode(i); + SDL_PixelFormatEnumToMasks(mode->format, &bpp, &Rmask, + &Gmask, &Bmask, &Amask); + printf("Mode %d: %dx%d@%dHz, %d bits-per-pixel\n", i, + mode->w, mode->h, mode->refresh_rate, bpp); if (Rmask || Gmask || Bmask) { - printf (" Red Mask = 0x%.8x\n", Rmask); - printf (" Green Mask = 0x%.8x\n", Gmask); - printf (" Blue Mask = 0x%.8x\n", Bmask); + printf(" Red Mask = 0x%.8x\n", Rmask); + printf(" Green Mask = 0x%.8x\n", Gmask); + printf(" Blue Mask = 0x%.8x\n", Bmask); if (Amask) - printf (" Alpha Mask = 0x%.8x\n", Amask); + printf(" Alpha Mask = 0x%.8x\n", Amask); } } } - info = SDL_GetVideoInfo (); + info = SDL_GetVideoInfo(); if (info->wm_available) { - printf ("A window manager is available\n"); + printf("A window manager is available\n"); } if (info->hw_available) { - printf ("Hardware surfaces are available (%dK video memory)\n", - info->video_mem); + printf("Hardware surfaces are available (%dK video memory)\n", + info->video_mem); } if (info->blit_hw) { - printf ("Copy blits between hardware surfaces are accelerated\n"); + printf("Copy blits between hardware surfaces are accelerated\n"); } if (info->blit_hw_CC) { - printf ("Colorkey blits between hardware surfaces are accelerated\n"); + printf("Colorkey blits between hardware surfaces are accelerated\n"); } if (info->blit_hw_A) { - printf ("Alpha blits between hardware surfaces are accelerated\n"); + printf("Alpha blits between hardware surfaces are accelerated\n"); } if (info->blit_sw) { printf @@ -515,14 +511,14 @@ ("Alpha blits from software surfaces to hardware surfaces are accelerated\n"); } if (info->blit_fill) { - printf ("Color fills on hardware surfaces are accelerated\n"); + printf("Color fills on hardware surfaces are accelerated\n"); } #if 0 - if (argv[1] && (strcmp (argv[1], "-benchmark") == 0)) { - RunVideoTests (); + if (argv[1] && (strcmp(argv[1], "-benchmark") == 0)) { + RunVideoTests(); } #endif - SDL_Quit (); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testwin.c --- a/test/testwin.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testwin.c Mon May 29 04:04:35 2006 +0000 @@ -13,15 +13,15 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } void -DrawPict (SDL_Surface * screen, char *bmpfile, - int speedy, int flip, int nofade) +DrawPict(SDL_Surface * screen, char *bmpfile, + int speedy, int flip, int nofade) { SDL_Surface *picture; SDL_Rect dest, update; @@ -33,27 +33,27 @@ if (bmpfile == NULL) { bmpfile = "sample.bmp"; /* Sample image */ } - fprintf (stderr, "Loading picture: %s\n", bmpfile); - picture = SDL_LoadBMP (bmpfile); + fprintf(stderr, "Loading picture: %s\n", bmpfile); + picture = SDL_LoadBMP(bmpfile); if (picture == NULL) { - fprintf (stderr, "Couldn't load %s: %s\n", bmpfile, SDL_GetError ()); + fprintf(stderr, "Couldn't load %s: %s\n", bmpfile, SDL_GetError()); return; } /* Set the display colors -- on a hicolor display this is a no-op */ if (picture->format->palette) { ncolors = picture->format->palette->ncolors; - colors = (SDL_Color *) malloc (ncolors * sizeof (SDL_Color)); - cmap = (SDL_Color *) malloc (ncolors * sizeof (SDL_Color)); - memcpy (colors, picture->format->palette->colors, - ncolors * sizeof (SDL_Color)); + colors = (SDL_Color *) malloc(ncolors * sizeof(SDL_Color)); + cmap = (SDL_Color *) malloc(ncolors * sizeof(SDL_Color)); + memcpy(colors, picture->format->palette->colors, + ncolors * sizeof(SDL_Color)); } else { int r, g, b; /* Allocate 256 color palette */ ncolors = 256; - colors = (SDL_Color *) malloc (ncolors * sizeof (SDL_Color)); - cmap = (SDL_Color *) malloc (ncolors * sizeof (SDL_Color)); + colors = (SDL_Color *) malloc(ncolors * sizeof(SDL_Color)); + cmap = (SDL_Color *) malloc(ncolors * sizeof(SDL_Color)); /* Set a 3,3,2 color cube */ for (r = 0; r < 8; ++r) { @@ -67,44 +67,44 @@ } } } - NOTICE ("testwin: setting colors\n"); - if (!SDL_SetColors (screen, colors, 0, ncolors) && + NOTICE("testwin: setting colors\n"); + if (!SDL_SetColors(screen, colors, 0, ncolors) && (screen->format->palette != NULL)) { - fprintf (stderr, - "Warning: Couldn't set all of the colors, but SDL will map the image\n" - " (colormap fading will suffer - try the -warp option)\n"); + fprintf(stderr, + "Warning: Couldn't set all of the colors, but SDL will map the image\n" + " (colormap fading will suffer - try the -warp option)\n"); } /* Set the screen to black (not really necessary) */ - if (SDL_LockSurface (screen) == 0) { + if (SDL_LockSurface(screen) == 0) { Uint32 black; Uint8 *pixels; - black = SDL_MapRGB (screen->format, 0, 0, 0); + black = SDL_MapRGB(screen->format, 0, 0, 0); pixels = (Uint8 *) screen->pixels; for (i = 0; i < screen->h; ++i) { - memset (pixels, black, screen->w * screen->format->BytesPerPixel); + memset(pixels, black, screen->w * screen->format->BytesPerPixel); pixels += screen->pitch; } - SDL_UnlockSurface (screen); - SDL_UpdateRect (screen, 0, 0, 0, 0); + SDL_UnlockSurface(screen); + SDL_UpdateRect(screen, 0, 0, 0, 0); } /* Display the picture */ if (speedy) { SDL_Surface *displayfmt; - fprintf (stderr, "Converting picture\n"); - displayfmt = SDL_DisplayFormat (picture); + fprintf(stderr, "Converting picture\n"); + displayfmt = SDL_DisplayFormat(picture); if (displayfmt == NULL) { - fprintf (stderr, "Couldn't convert image: %s\n", SDL_GetError ()); + fprintf(stderr, "Couldn't convert image: %s\n", SDL_GetError()); goto done; } - SDL_FreeSurface (picture); + SDL_FreeSurface(picture); picture = displayfmt; } - printf ("(image surface located in %s memory)\n", - (picture->flags & SDL_HWSURFACE) ? "video" : "system"); + printf("(image surface located in %s memory)\n", + (picture->flags & SDL_HWSURFACE) ? "video" : "system"); centered = (screen->w - picture->w) / 2; if (centered < 0) { centered = 0; @@ -112,29 +112,29 @@ dest.y = (screen->h - picture->h) / 2; dest.w = picture->w; dest.h = picture->h; - NOTICE ("testwin: moving image\n"); + NOTICE("testwin: moving image\n"); for (i = 0; i <= centered; ++i) { dest.x = i; update = dest; - if (SDL_BlitSurface (picture, NULL, screen, &update) < 0) { - fprintf (stderr, "Blit failed: %s\n", SDL_GetError ()); + if (SDL_BlitSurface(picture, NULL, screen, &update) < 0) { + fprintf(stderr, "Blit failed: %s\n", SDL_GetError()); break; } if (flip) { - SDL_Flip (screen); + SDL_Flip(screen); } else { - SDL_UpdateRects (screen, 1, &update); + SDL_UpdateRects(screen, 1, &update); } } #ifdef SCREENSHOT - if (SDL_SaveBMP (screen, "screen.bmp") < 0) - printf ("Couldn't save screen: %s\n", SDL_GetError ()); + if (SDL_SaveBMP(screen, "screen.bmp") < 0) + printf("Couldn't save screen: %s\n", SDL_GetError()); #endif #ifndef BENCHMARK_SDL /* Let it sit there for a while */ - SDL_Delay (5 * 1000); + SDL_Delay(5 * 1000); #endif /* Fade the colormap */ if (!nofade) { @@ -146,13 +146,13 @@ Sint16 r, g, b; } cdist[256]; - NOTICE ("testwin: fading out...\n"); - memcpy (cmap, colors, ncolors * sizeof (SDL_Color)); + NOTICE("testwin: fading out...\n"); + memcpy(cmap, colors, ncolors * sizeof(SDL_Color)); maxstep = 32 - 1; final.r = 0xFF; final.g = 0x00; final.b = 0x00; - memcpy (palcolors, colors, ncolors * sizeof (SDL_Color)); + memcpy(palcolors, colors, ncolors * sizeof(SDL_Color)); for (i = 0; i < ncolors; ++i) { cdist[i].r = final.r - palcolors[i].r; cdist[i].g = final.g - palcolors[i].g; @@ -165,13 +165,13 @@ colors[c].g = palcolors[c].g + ((cdist[c].g * i)) / maxstep; colors[c].b = palcolors[c].b + ((cdist[c].b * i)) / maxstep; } - SDL_SetColors (screen, colors, 0, ncolors); - SDL_Delay (1); + SDL_SetColors(screen, colors, 0, ncolors); + SDL_Delay(1); } final.r = 0x00; final.g = 0x00; final.b = 0x00; - memcpy (palcolors, colors, ncolors * sizeof (SDL_Color)); + memcpy(palcolors, colors, ncolors * sizeof(SDL_Color)); for (i = 0; i < ncolors; ++i) { cdist[i].r = final.r - palcolors[i].r; cdist[i].g = final.g - palcolors[i].g; @@ -185,17 +185,17 @@ colors[c].g = palcolors[c].g + ((cdist[c].g * i)) / maxstep; colors[c].b = palcolors[c].b + ((cdist[c].b * i)) / maxstep; } - SDL_SetColors (screen, colors, 0, ncolors); - SDL_Delay (1); + SDL_SetColors(screen, colors, 0, ncolors); + SDL_Delay(1); } for (i = 0; i < ncolors; ++i) { colors[i].r = final.r; colors[i].g = final.g; colors[i].b = final.b; } - SDL_SetColors (screen, colors, 0, ncolors); - NOTICE ("testwin: fading in...\n"); - memcpy (palcolors, colors, ncolors * sizeof (SDL_Color)); + SDL_SetColors(screen, colors, 0, ncolors); + NOTICE("testwin: fading in...\n"); + memcpy(palcolors, colors, ncolors * sizeof(SDL_Color)); for (i = 0; i < ncolors; ++i) { cdist[i].r = cmap[i].r - palcolors[i].r; cdist[i].g = cmap[i].g - palcolors[i].g; @@ -208,22 +208,22 @@ colors[c].g = palcolors[c].g + ((cdist[c].g * i)) / maxstep; colors[c].b = palcolors[c].b + ((cdist[c].b * i)) / maxstep; } - SDL_SetColors (screen, colors, 0, ncolors); - SDL_Delay (1); + SDL_SetColors(screen, colors, 0, ncolors); + SDL_Delay(1); } - NOTICE ("testwin: fading over\n"); + NOTICE("testwin: fading over\n"); } done: /* Free the picture and return */ - SDL_FreeSurface (picture); - free (colors); - free (cmap); + SDL_FreeSurface(picture); + free(colors); + free(cmap); return; } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SDL_Surface *screen; /* Options */ @@ -252,67 +252,67 @@ desired_bpp = 0; video_flags = 0; #endif - if (SDL_Init (SDL_INIT_VIDEO) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } while (argc > 1) { - if (strcmp (argv[1], "-speedy") == 0) { + if (strcmp(argv[1], "-speedy") == 0) { speedy = 1; argv += 1; argc -= 1; - } else if (strcmp (argv[1], "-nofade") == 0) { + } else if (strcmp(argv[1], "-nofade") == 0) { nofade = 1; argv += 1; argc -= 1; - } else if (strcmp (argv[1], "-delay") == 0) { + } else if (strcmp(argv[1], "-delay") == 0) { if (argv[2]) { - delay = atoi (argv[2]); + delay = atoi(argv[2]); argv += 2; argc -= 2; } else { - fprintf (stderr, "The -delay option requires an argument\n"); - quit (1); + fprintf(stderr, "The -delay option requires an argument\n"); + quit(1); } - } else if (strcmp (argv[1], "-width") == 0) { - if (argv[2] && ((w = atoi (argv[2])) > 0)) { + } else if (strcmp(argv[1], "-width") == 0) { + if (argv[2] && ((w = atoi(argv[2])) > 0)) { argv += 2; argc -= 2; } else { - fprintf (stderr, "The -width option requires an argument\n"); - quit (1); + fprintf(stderr, "The -width option requires an argument\n"); + quit(1); } - } else if (strcmp (argv[1], "-height") == 0) { - if (argv[2] && ((h = atoi (argv[2])) > 0)) { + } else if (strcmp(argv[1], "-height") == 0) { + if (argv[2] && ((h = atoi(argv[2])) > 0)) { argv += 2; argc -= 2; } else { - fprintf (stderr, "The -height option requires an argument\n"); - quit (1); + fprintf(stderr, "The -height option requires an argument\n"); + quit(1); } - } else if (strcmp (argv[1], "-bpp") == 0) { + } else if (strcmp(argv[1], "-bpp") == 0) { if (argv[2]) { - desired_bpp = atoi (argv[2]); + desired_bpp = atoi(argv[2]); argv += 2; argc -= 2; } else { - fprintf (stderr, "The -bpp option requires an argument\n"); - quit (1); + fprintf(stderr, "The -bpp option requires an argument\n"); + quit(1); } - } else if (strcmp (argv[1], "-warp") == 0) { + } else if (strcmp(argv[1], "-warp") == 0) { video_flags |= SDL_HWPALETTE; argv += 1; argc -= 1; - } else if (strcmp (argv[1], "-hw") == 0) { + } else if (strcmp(argv[1], "-hw") == 0) { video_flags |= SDL_HWSURFACE; argv += 1; argc -= 1; - } else if (strcmp (argv[1], "-flip") == 0) { + } else if (strcmp(argv[1], "-flip") == 0) { video_flags |= SDL_DOUBLEBUF; argv += 1; argc -= 1; - } else if (strcmp (argv[1], "-fullscreen") == 0) { + } else if (strcmp(argv[1], "-fullscreen") == 0) { video_flags |= SDL_FULLSCREEN; argv += 1; argc -= 1; @@ -321,35 +321,35 @@ } /* Initialize the display */ - screen = SDL_SetVideoMode (w, h, desired_bpp, video_flags); + screen = SDL_SetVideoMode(w, h, desired_bpp, video_flags); if (screen == NULL) { - fprintf (stderr, "Couldn't set %dx%dx%d video mode: %s\n", - w, h, desired_bpp, SDL_GetError ()); - quit (1); + fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n", + w, h, desired_bpp, SDL_GetError()); + quit(1); } - printf ("Set%s %dx%dx%d mode\n", - screen->flags & SDL_FULLSCREEN ? " fullscreen" : "", - screen->w, screen->h, screen->format->BitsPerPixel); - printf ("(video surface located in %s memory)\n", - (screen->flags & SDL_HWSURFACE) ? "video" : "system"); + printf("Set%s %dx%dx%d mode\n", + screen->flags & SDL_FULLSCREEN ? " fullscreen" : "", + screen->w, screen->h, screen->format->BitsPerPixel); + printf("(video surface located in %s memory)\n", + (screen->flags & SDL_HWSURFACE) ? "video" : "system"); if (screen->flags & SDL_DOUBLEBUF) { - printf ("Double-buffering enabled\n"); + printf("Double-buffering enabled\n"); flip = 1; } /* Set the window manager title bar */ - SDL_WM_SetCaption ("SDL test window", "testwin"); + SDL_WM_SetCaption("SDL test window", "testwin"); /* Do all the drawing work */ #ifdef BENCHMARK_SDL - then = SDL_GetTicks (); - DrawPict (screen, argv[1], speedy, flip, nofade); - now = SDL_GetTicks (); - printf ("Time: %d milliseconds\n", now - then); + then = SDL_GetTicks(); + DrawPict(screen, argv[1], speedy, flip, nofade); + now = SDL_GetTicks(); + printf("Time: %d milliseconds\n", now - then); #else - DrawPict (screen, argv[1], speedy, flip, nofade); + DrawPict(screen, argv[1], speedy, flip, nofade); #endif - SDL_Delay (delay * 1000); - SDL_Quit (); + SDL_Delay(delay * 1000); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/testwm.c --- a/test/testwm.c Mon May 29 03:53:21 2006 +0000 +++ b/test/testwm.c Mon May 29 04:04:35 2006 +0000 @@ -15,28 +15,28 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } int -SetVideoMode (int w, int h) +SetVideoMode(int w, int h) { SDL_Surface *screen; int i; Uint8 *buffer; SDL_Color palette[256]; - screen = SDL_SetVideoMode (w, h, video_bpp, video_flags); + screen = SDL_SetVideoMode(w, h, video_bpp, video_flags); if (screen == NULL) { - fprintf (stderr, "Couldn't set %dx%dx%d video mode: %s\n", - w, h, video_bpp, SDL_GetError ()); + fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n", + w, h, video_bpp, SDL_GetError()); return (-1); } - printf ("Running in %s mode\n", screen->flags & SDL_FULLSCREEN ? - "fullscreen" : "windowed"); + printf("Running in %s mode\n", screen->flags & SDL_FULLSCREEN ? + "fullscreen" : "windowed"); /* Set the surface pixels and refresh! */ for (i = 0; i < 256; ++i) { @@ -44,26 +44,26 @@ palette[i].g = 255 - i; palette[i].b = 255 - i; } - SDL_SetColors (screen, palette, 0, 256); - if (SDL_LockSurface (screen) < 0) { - fprintf (stderr, "Couldn't lock display surface: %s\n", - SDL_GetError ()); + SDL_SetColors(screen, palette, 0, 256); + if (SDL_LockSurface(screen) < 0) { + fprintf(stderr, "Couldn't lock display surface: %s\n", + SDL_GetError()); return (-1); } buffer = (Uint8 *) screen->pixels; for (i = 0; i < screen->h; ++i) { - memset (buffer, (i * 255) / screen->h, - screen->w * screen->format->BytesPerPixel); + memset(buffer, (i * 255) / screen->h, + screen->w * screen->format->BytesPerPixel); buffer += screen->pitch; } - SDL_UnlockSurface (screen); - SDL_UpdateRect (screen, 0, 0, 0, 0); + SDL_UnlockSurface(screen); + SDL_UpdateRect(screen, 0, 0, 0, 0); return (0); } SDL_Surface * -LoadIconSurface (char *file, Uint8 ** maskp) +LoadIconSurface(char *file, Uint8 ** maskp) { SDL_Surface *icon; Uint8 *pixels; @@ -73,9 +73,9 @@ *maskp = NULL; /* Load the icon surface */ - icon = SDL_LoadBMP (file); + icon = SDL_LoadBMP(file); if (icon == NULL) { - fprintf (stderr, "Couldn't load %s: %s\n", file, SDL_GetError ()); + fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError()); return (NULL); } @@ -89,28 +89,28 @@ if (icon->format->palette == NULL) { - fprintf (stderr, "Icon must have a palette!\n"); - SDL_FreeSurface (icon); + fprintf(stderr, "Icon must have a palette!\n"); + SDL_FreeSurface(icon); return (NULL); } /* Set the colorkey */ - SDL_SetColorKey (icon, SDL_SRCCOLORKEY, *((Uint8 *) icon->pixels)); + SDL_SetColorKey(icon, SDL_SRCCOLORKEY, *((Uint8 *) icon->pixels)); /* Create the mask */ pixels = (Uint8 *) icon->pixels; - printf ("Transparent pixel: (%d,%d,%d)\n", - icon->format->palette->colors[*pixels].r, - icon->format->palette->colors[*pixels].g, - icon->format->palette->colors[*pixels].b); + printf("Transparent pixel: (%d,%d,%d)\n", + icon->format->palette->colors[*pixels].r, + icon->format->palette->colors[*pixels].g, + icon->format->palette->colors[*pixels].b); mlen = (icon->w * icon->h + 7) / 8; - mask = (Uint8 *) malloc (mlen); + mask = (Uint8 *) malloc(mlen); if (mask == NULL) { - fprintf (stderr, "Out of memory!\n"); - SDL_FreeSurface (icon); + fprintf(stderr, "Out of memory!\n"); + SDL_FreeSurface(icon); return (NULL); } - memset (mask, 0, mlen); + memset(mask, 0, mlen); for (i = 0; i < icon->h; i++) for (j = 0; j < icon->w; j++) { int pindex = i * icon->pitch + j; @@ -123,60 +123,60 @@ } void -HotKey_ToggleFullScreen (void) +HotKey_ToggleFullScreen(void) { SDL_Surface *screen; - screen = SDL_GetVideoSurface (); - if (SDL_WM_ToggleFullScreen (screen)) { - printf ("Toggled fullscreen mode - now %s\n", - (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed"); + screen = SDL_GetVideoSurface(); + if (SDL_WM_ToggleFullScreen(screen)) { + printf("Toggled fullscreen mode - now %s\n", + (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed"); } else { - printf ("Unable to toggle fullscreen mode\n"); + printf("Unable to toggle fullscreen mode\n"); video_flags ^= SDL_FULLSCREEN; - SetVideoMode (screen->w, screen->h); + SetVideoMode(screen->w, screen->h); } } void -HotKey_ToggleGrab (void) +HotKey_ToggleGrab(void) { SDL_GrabMode mode; - printf ("Ctrl-G: toggling input grab!\n"); - mode = SDL_WM_GrabInput (SDL_GRAB_QUERY); + printf("Ctrl-G: toggling input grab!\n"); + mode = SDL_WM_GrabInput(SDL_GRAB_QUERY); if (mode == SDL_GRAB_ON) { - printf ("Grab was on\n"); + printf("Grab was on\n"); } else { - printf ("Grab was off\n"); + printf("Grab was off\n"); } - mode = SDL_WM_GrabInput (mode ? SDL_GRAB_OFF : SDL_GRAB_ON); + mode = SDL_WM_GrabInput(mode ? SDL_GRAB_OFF : SDL_GRAB_ON); if (mode == SDL_GRAB_ON) { - printf ("Grab is now on\n"); + printf("Grab is now on\n"); } else { - printf ("Grab is now off\n"); + printf("Grab is now off\n"); } } void -HotKey_Iconify (void) +HotKey_Iconify(void) { - printf ("Ctrl-Z: iconifying window!\n"); - SDL_WM_IconifyWindow (); + printf("Ctrl-Z: iconifying window!\n"); + SDL_WM_IconifyWindow(); } void -HotKey_Quit (void) +HotKey_Quit(void) { SDL_Event event; - printf ("Posting internal quit request\n"); + printf("Posting internal quit request\n"); event.type = SDL_USEREVENT; - SDL_PushEvent (&event); + SDL_PushEvent(&event); } int SDLCALL -FilterEvents (const SDL_Event * event) +FilterEvents(const SDL_Event * event) { static int reallyquit = 0; @@ -184,19 +184,19 @@ case SDL_ACTIVEEVENT: /* See what happened */ - printf ("App %s ", event->active.gain ? "gained" : "lost"); + printf("App %s ", event->active.gain ? "gained" : "lost"); if (event->active.state & SDL_APPACTIVE) - printf ("active "); + printf("active "); if (event->active.state & SDL_APPINPUTFOCUS) - printf ("input "); + printf("input "); if (event->active.state & SDL_APPMOUSEFOCUS) - printf ("mouse "); - printf ("focus\n"); + printf("mouse "); + printf("focus\n"); /* See if we are iconified or restored */ if (event->active.state & SDL_APPACTIVE) { - printf ("App has been %s\n", - event->active.gain ? "restored" : "iconified"); + printf("App has been %s\n", + event->active.gain ? "restored" : "iconified"); } return (0); @@ -205,38 +205,37 @@ case SDL_MOUSEBUTTONUP: if (event->button.state == SDL_PRESSED) { visible = !visible; - SDL_ShowCursor (visible); + SDL_ShowCursor(visible); } - printf ("Mouse button %d has been %s\n", - event->button.button, - (event->button.state == SDL_PRESSED) ? - "pressed" : "released"); + printf("Mouse button %d has been %s\n", + event->button.button, + (event->button.state == SDL_PRESSED) ? "pressed" : "released"); return (0); /* Show relative mouse motion */ case SDL_MOUSEMOTION: #if 0 - printf ("Mouse motion: {%d,%d} (%d,%d)\n", - event->motion.x, event->motion.y, - event->motion.xrel, event->motion.yrel); + printf("Mouse motion: {%d,%d} (%d,%d)\n", + event->motion.x, event->motion.y, + event->motion.xrel, event->motion.yrel); #endif return (0); case SDL_KEYDOWN: if (event->key.keysym.sym == SDLK_ESCAPE) { - HotKey_Quit (); + HotKey_Quit(); } if ((event->key.keysym.sym == SDLK_g) && (event->key.keysym.mod & KMOD_CTRL)) { - HotKey_ToggleGrab (); + HotKey_ToggleGrab(); } if ((event->key.keysym.sym == SDLK_z) && (event->key.keysym.mod & KMOD_CTRL)) { - HotKey_Iconify (); + HotKey_Iconify(); } if ((event->key.keysym.sym == SDLK_RETURN) && (event->key.keysym.mod & KMOD_ALT)) { - HotKey_ToggleFullScreen (); + HotKey_ToggleFullScreen(); } return (0); @@ -248,10 +247,10 @@ case SDL_QUIT: if (!reallyquit) { reallyquit = 1; - printf ("Quit requested\n"); + printf("Quit requested\n"); return (0); } - printf ("Quit demanded\n"); + printf("Quit demanded\n"); return (1); /* This will never happen because events queued directly @@ -267,7 +266,7 @@ } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SDL_Event event; char *title; @@ -276,8 +275,8 @@ int parsed; int w, h; - if (SDL_Init (SDL_INIT_VIDEO) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } @@ -288,28 +287,28 @@ video_flags = SDL_SWSURFACE; parsed = 1; while (parsed) { - if ((argc >= 2) && (strcmp (argv[1], "-fullscreen") == 0)) { + if ((argc >= 2) && (strcmp(argv[1], "-fullscreen") == 0)) { video_flags |= SDL_FULLSCREEN; argc -= 1; argv += 1; - } else if ((argc >= 2) && (strcmp (argv[1], "-resize") == 0)) { + } else if ((argc >= 2) && (strcmp(argv[1], "-resize") == 0)) { video_flags |= SDL_RESIZABLE; argc -= 1; argv += 1; - } else if ((argc >= 2) && (strcmp (argv[1], "-noframe") == 0)) { + } else if ((argc >= 2) && (strcmp(argv[1], "-noframe") == 0)) { video_flags |= SDL_NOFRAME; argc -= 1; argv += 1; - } else if ((argc >= 3) && (strcmp (argv[1], "-width") == 0)) { - w = atoi (argv[2]); + } else if ((argc >= 3) && (strcmp(argv[1], "-width") == 0)) { + w = atoi(argv[2]); argc -= 2; argv += 2; - } else if ((argc >= 3) && (strcmp (argv[1], "-height") == 0)) { - h = atoi (argv[2]); + } else if ((argc >= 3) && (strcmp(argv[1], "-height") == 0)) { + h = atoi(argv[2]); argc -= 2; argv += 2; - } else if ((argc >= 3) && (strcmp (argv[1], "-bpp") == 0)) { - video_bpp = atoi (argv[2]); + } else if ((argc >= 3) && (strcmp(argv[1], "-bpp") == 0)) { + video_bpp = atoi(argv[2]); argc -= 2; argv += 2; } else { @@ -318,59 +317,59 @@ } /* Set the icon -- this must be done before the first mode set */ - icon = LoadIconSurface ("icon.bmp", &icon_mask); + icon = LoadIconSurface("icon.bmp", &icon_mask); if (icon != NULL) { - SDL_WM_SetIcon (icon, icon_mask); + SDL_WM_SetIcon(icon, icon_mask); } if (icon_mask != NULL) - free (icon_mask); + free(icon_mask); /* Set the title bar */ if (argv[1] == NULL) title = "Testing 1.. 2.. 3..."; else title = argv[1]; - SDL_WM_SetCaption (title, "testwm"); + SDL_WM_SetCaption(title, "testwm"); /* See if it's really set */ - SDL_WM_GetCaption (&title, NULL); + SDL_WM_GetCaption(&title, NULL); if (title) - printf ("Title was set to: %s\n", title); + printf("Title was set to: %s\n", title); else - printf ("No window title was set!\n"); + printf("No window title was set!\n"); /* Initialize the display */ - if (SetVideoMode (w, h) < 0) { - quit (1); + if (SetVideoMode(w, h) < 0) { + quit(1); } /* Set an event filter that discards everything but QUIT */ - SDL_SetEventFilter (FilterEvents); + SDL_SetEventFilter(FilterEvents); /* Ignore key up events, they don't even get filtered */ - SDL_EventState (SDL_KEYUP, SDL_IGNORE); + SDL_EventState(SDL_KEYUP, SDL_IGNORE); /* Loop, waiting for QUIT */ - while (SDL_WaitEvent (&event)) { + while (SDL_WaitEvent(&event)) { switch (event.type) { case SDL_VIDEORESIZE: - printf ("Got a resize event: %dx%d\n", - event.resize.w, event.resize.h); - SetVideoMode (event.resize.w, event.resize.h); + printf("Got a resize event: %dx%d\n", + event.resize.w, event.resize.h); + SetVideoMode(event.resize.w, event.resize.h); break; case SDL_USEREVENT: - printf ("Handling internal quit request\n"); + printf("Handling internal quit request\n"); /* Fall through to the quit handler */ case SDL_QUIT: - printf ("Bye bye..\n"); - quit (0); + printf("Bye bye..\n"); + quit(0); default: /* This should never happen */ - printf ("Warning: Event %d wasn't filtered\n", event.type); + printf("Warning: Event %d wasn't filtered\n", event.type); break; } } - printf ("SDL_WaitEvent() error: %s\n", SDL_GetError ()); - SDL_Quit (); + printf("SDL_WaitEvent() error: %s\n", SDL_GetError()); + SDL_Quit(); return (255); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/threadwin.c --- a/test/threadwin.c Mon May 29 03:53:21 2006 +0000 +++ b/test/threadwin.c Mon May 29 04:04:35 2006 +0000 @@ -16,14 +16,14 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } SDL_Surface * -LoadIconSurface (char *file, Uint8 ** maskp) +LoadIconSurface(char *file, Uint8 ** maskp) { SDL_Surface *icon; Uint8 *pixels; @@ -33,41 +33,41 @@ *maskp = NULL; /* Load the icon surface */ - icon = SDL_LoadBMP (file); + icon = SDL_LoadBMP(file); if (icon == NULL) { - fprintf (stderr, "Couldn't load %s: %s\n", file, SDL_GetError ()); + fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError()); return (NULL); } /* Check width and height */ if ((icon->w % 8) != 0) { - fprintf (stderr, "Icon width must be a multiple of 8!\n"); - SDL_FreeSurface (icon); + fprintf(stderr, "Icon width must be a multiple of 8!\n"); + SDL_FreeSurface(icon); return (NULL); } if (icon->format->palette == NULL) { - fprintf (stderr, "Icon must have a palette!\n"); - SDL_FreeSurface (icon); + fprintf(stderr, "Icon must have a palette!\n"); + SDL_FreeSurface(icon); return (NULL); } /* Set the colorkey */ - SDL_SetColorKey (icon, SDL_SRCCOLORKEY, *((Uint8 *) icon->pixels)); + SDL_SetColorKey(icon, SDL_SRCCOLORKEY, *((Uint8 *) icon->pixels)); /* Create the mask */ pixels = (Uint8 *) icon->pixels; - printf ("Transparent pixel: (%d,%d,%d)\n", - icon->format->palette->colors[*pixels].r, - icon->format->palette->colors[*pixels].g, - icon->format->palette->colors[*pixels].b); + printf("Transparent pixel: (%d,%d,%d)\n", + icon->format->palette->colors[*pixels].r, + icon->format->palette->colors[*pixels].g, + icon->format->palette->colors[*pixels].b); mlen = icon->w * icon->h; - mask = (Uint8 *) malloc (mlen / 8); + mask = (Uint8 *) malloc(mlen / 8); if (mask == NULL) { - fprintf (stderr, "Out of memory!\n"); - SDL_FreeSurface (icon); + fprintf(stderr, "Out of memory!\n"); + SDL_FreeSurface(icon); return (NULL); } - memset (mask, 0, mlen / 8); + memset(mask, 0, mlen / 8); for (i = 0; i < mlen;) { if (pixels[i] != *pixels) mask[i / 8] |= 0x01; @@ -80,7 +80,7 @@ } int SDLCALL -FilterEvents (const SDL_Event * event) +FilterEvents(const SDL_Event * event) { static int reallyquit = 0; @@ -88,19 +88,19 @@ case SDL_ACTIVEEVENT: /* See what happened */ - printf ("App %s ", event->active.gain ? "gained" : "lost"); + printf("App %s ", event->active.gain ? "gained" : "lost"); if (event->active.state & SDL_APPACTIVE) - printf ("active "); + printf("active "); if (event->active.state & SDL_APPMOUSEFOCUS) - printf ("mouse "); + printf("mouse "); if (event->active.state & SDL_APPINPUTFOCUS) - printf ("input "); - printf ("focus\n"); + printf("input "); + printf("focus\n"); /* See if we are iconified or restored */ if (event->active.state & SDL_APPACTIVE) { - printf ("App has been %s\n", - event->active.gain ? "restored" : "iconified"); + printf("App has been %s\n", + event->active.gain ? "restored" : "iconified"); } return (0); @@ -108,10 +108,10 @@ case SDL_QUIT: if (!reallyquit) { reallyquit = 1; - printf ("Quit requested\n"); + printf("Quit requested\n"); return (0); } - printf ("Quit demanded\n"); + printf("Quit demanded\n"); return (1); /* Mouse and keyboard events go to threads */ @@ -129,7 +129,7 @@ } int SDLCALL -HandleMouse (void *unused) +HandleMouse(void *unused) { SDL_Event events[10]; int i, found; @@ -140,7 +140,7 @@ (SDL_MOUSEMOTIONMASK | SDL_MOUSEBUTTONDOWNMASK | SDL_MOUSEBUTTONUPMASK); while (!done) { - found = SDL_PeepEvents (events, 10, SDL_GETEVENT, mask); + found = SDL_PeepEvents(events, 10, SDL_GETEVENT, mask); for (i = 0; i < found; ++i) { switch (events[i].type) { /* We want to toggle visibility on buttonpress */ @@ -148,28 +148,28 @@ case SDL_MOUSEBUTTONUP: if (events[i].button.state == SDL_PRESSED) { visible = !visible; - SDL_ShowCursor (visible); + SDL_ShowCursor(visible); } - printf ("Mouse button %d has been %s\n", - events[i].button.button, - (events[i].button.state == SDL_PRESSED) ? - "pressed" : "released"); + printf("Mouse button %d has been %s\n", + events[i].button.button, + (events[i].button.state == SDL_PRESSED) ? + "pressed" : "released"); break; /* Show relative mouse motion */ case SDL_MOUSEMOTION: - printf ("Mouse relative motion: {%d,%d}\n", - events[i].motion.xrel, events[i].motion.yrel); + printf("Mouse relative motion: {%d,%d}\n", + events[i].motion.xrel, events[i].motion.yrel); break; } } /* Give up some CPU to allow events to arrive */ - SDL_Delay (20); + SDL_Delay(20); } return (0); } int SDLCALL -HandleKeyboard (void *unused) +HandleKeyboard(void *unused) { SDL_Event events[10]; int i, found; @@ -178,16 +178,16 @@ /* Handle mouse events here */ mask = (SDL_KEYDOWNMASK | SDL_KEYUPMASK); while (!done) { - found = SDL_PeepEvents (events, 10, SDL_GETEVENT, mask); + found = SDL_PeepEvents(events, 10, SDL_GETEVENT, mask); for (i = 0; i < found; ++i) { switch (events[i].type) { /* We want to toggle visibility on buttonpress */ case SDL_KEYDOWN: case SDL_KEYUP: - printf ("Key '%c' has been %s\n", - events[i].key.keysym.unicode, - (events[i].key.state == SDL_PRESSED) ? - "pressed" : "released"); + printf("Key '%c' has been %s\n", + events[i].key.keysym.unicode, + (events[i].key.state == SDL_PRESSED) ? + "pressed" : "released"); /* Allow hitting to quit the app */ if (events[i].key.keysym.sym == SDLK_ESCAPE) { @@ -200,33 +200,33 @@ if (events[i].key.keysym.sym == SDLK_f) { int rc = 0; - printf ("attempting to toggle fullscreen...\n"); - rc = SDL_WM_ToggleFullScreen (SDL_GetVideoSurface ()); - printf ("SDL_WM_ToggleFullScreen returned %d.\n", rc); + printf("attempting to toggle fullscreen...\n"); + rc = SDL_WM_ToggleFullScreen(SDL_GetVideoSurface()); + printf("SDL_WM_ToggleFullScreen returned %d.\n", rc); } if (events[i].key.keysym.sym == SDLK_g) { SDL_GrabMode m; - m = SDL_WM_GrabInput (SDL_GRAB_QUERY) == + m = SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON ? SDL_GRAB_OFF : SDL_GRAB_ON; printf ("attempting to toggle input grab to %s...\n", m == SDL_GRAB_ON ? "ON" : "OFF"); - SDL_WM_GrabInput (m); - printf ("attempt finished.\n"); + SDL_WM_GrabInput(m); + printf("attempt finished.\n"); } break; } } /* Give up some CPU to allow events to arrive */ - SDL_Delay (20); + SDL_Delay(20); } return (0); } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SDL_Surface *screen; SDL_Surface *icon; @@ -250,17 +250,17 @@ been compiled with threaded events enabled, then the mouse and keyboard won't respond. */ - if ((argc >= 2) && (strcmp (argv[1], "-threaded") == 0)) { + if ((argc >= 2) && (strcmp(argv[1], "-threaded") == 0)) { init_flags |= SDL_INIT_EVENTTHREAD; argc -= 1; argv += 1; - printf ("Running with threaded events\n"); - } else if ((argc >= 2) && (strcmp (argv[1], "-fullscreen") == 0)) { + printf("Running with threaded events\n"); + } else if ((argc >= 2) && (strcmp(argv[1], "-fullscreen") == 0)) { video_flags |= SDL_FULLSCREEN; argc -= 1; argv += 1; - } else if ((argc >= 3) && (strcmp (argv[1], "-bpp") == 0)) { - video_bpp = atoi (argv[2]); + } else if ((argc >= 3) && (strcmp(argv[1], "-bpp") == 0)) { + video_bpp = atoi(argv[2]); argc -= 2; argv += 2; } else { @@ -269,38 +269,38 @@ } /* Initialize SDL with the requested flags */ - if (SDL_Init (init_flags) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(init_flags) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } /* Set the icon -- this must be done before the first mode set */ - icon = LoadIconSurface ("icon.bmp", &icon_mask); + icon = LoadIconSurface("icon.bmp", &icon_mask); if (icon != NULL) { - SDL_WM_SetIcon (icon, icon_mask); + SDL_WM_SetIcon(icon, icon_mask); } if (icon_mask != NULL) - free (icon_mask); + free(icon_mask); /* Initialize the display */ - screen = SDL_SetVideoMode (640, 480, video_bpp, video_flags); + screen = SDL_SetVideoMode(640, 480, video_bpp, video_flags); if (screen == NULL) { - fprintf (stderr, "Couldn't set 640x480x%d video mode: %s\n", - video_bpp, SDL_GetError ()); - quit (1); + fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n", + video_bpp, SDL_GetError()); + quit(1); } - printf ("Running in %s mode\n", screen->flags & SDL_FULLSCREEN ? - "fullscreen" : "windowed"); + printf("Running in %s mode\n", screen->flags & SDL_FULLSCREEN ? + "fullscreen" : "windowed"); /* Enable printable characters */ - SDL_EnableUNICODE (1); + SDL_EnableUNICODE(1); /* Set an event filter that discards everything but QUIT */ - SDL_SetEventFilter (FilterEvents); + SDL_SetEventFilter(FilterEvents); /* Create the event handling threads */ - mouse_thread = SDL_CreateThread (HandleMouse, NULL); - keybd_thread = SDL_CreateThread (HandleKeyboard, NULL); + mouse_thread = SDL_CreateThread(HandleMouse, NULL); + keybd_thread = SDL_CreateThread(HandleKeyboard, NULL); /* Set the surface pixels and refresh! */ for (i = 0; i < 256; ++i) { @@ -308,34 +308,34 @@ palette[i].g = 255 - i; palette[i].b = 255 - i; } - SDL_SetColors (screen, palette, 0, 256); - if (SDL_LockSurface (screen) < 0) { - fprintf (stderr, "Couldn't lock display surface: %s\n", - SDL_GetError ()); - quit (2); + SDL_SetColors(screen, palette, 0, 256); + if (SDL_LockSurface(screen) < 0) { + fprintf(stderr, "Couldn't lock display surface: %s\n", + SDL_GetError()); + quit(2); } buffer = (Uint8 *) screen->pixels; for (i = 0; i < screen->h; ++i) { - memset (buffer, (i * 255) / screen->h, - screen->w * screen->format->BytesPerPixel); + memset(buffer, (i * 255) / screen->h, + screen->w * screen->format->BytesPerPixel); buffer += screen->pitch; } - SDL_UnlockSurface (screen); - SDL_UpdateRect (screen, 0, 0, 0, 0); + SDL_UnlockSurface(screen); + SDL_UpdateRect(screen, 0, 0, 0, 0); /* Loop, waiting for QUIT */ while (!done) { if (!(init_flags & SDL_INIT_EVENTTHREAD)) { - SDL_PumpEvents (); /* Needed when event thread is off */ + SDL_PumpEvents(); /* Needed when event thread is off */ } - if (SDL_PeepEvents (NULL, 0, SDL_PEEKEVENT, SDL_QUITMASK)) { + if (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, SDL_QUITMASK)) { done = 1; } /* Give up some CPU so the events can accumulate */ - SDL_Delay (20); + SDL_Delay(20); } - SDL_WaitThread (mouse_thread, NULL); - SDL_WaitThread (keybd_thread, NULL); - SDL_Quit (); + SDL_WaitThread(mouse_thread, NULL); + SDL_WaitThread(keybd_thread, NULL); + SDL_Quit(); return (0); } diff -r 1fddae038bc8 -r 4da1ee79c9af test/torturethread.c --- a/test/torturethread.c Mon May 29 03:53:21 2006 +0000 +++ b/test/torturethread.c Mon May 29 04:04:35 2006 +0000 @@ -15,14 +15,14 @@ /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void -quit (int rc) +quit(int rc) { - SDL_Quit (); - exit (rc); + SDL_Quit(); + exit(rc); } int SDLCALL -SubThreadFunc (void *data) +SubThreadFunc(void *data) { while (!*(int volatile *) data) { ; /*SDL_Delay(10); *//* do nothing */ @@ -31,56 +31,56 @@ } int SDLCALL -ThreadFunc (void *data) +ThreadFunc(void *data) { SDL_Thread *sub_threads[NUMTHREADS]; int flags[NUMTHREADS]; int i; int tid = (int) (uintptr_t) data; - fprintf (stderr, "Creating Thread %d\n", tid); + fprintf(stderr, "Creating Thread %d\n", tid); for (i = 0; i < NUMTHREADS; i++) { flags[i] = 0; - sub_threads[i] = SDL_CreateThread (SubThreadFunc, &flags[i]); + sub_threads[i] = SDL_CreateThread(SubThreadFunc, &flags[i]); } - printf ("Thread '%d' waiting for signal\n", tid); + printf("Thread '%d' waiting for signal\n", tid); while (time_for_threads_to_die[tid] != 1) { ; /* do nothing */ } - printf ("Thread '%d' sending signals to subthreads\n", tid); + printf("Thread '%d' sending signals to subthreads\n", tid); for (i = 0; i < NUMTHREADS; i++) { flags[i] = 1; - SDL_WaitThread (sub_threads[i], NULL); + SDL_WaitThread(sub_threads[i], NULL); } - printf ("Thread '%d' exiting!\n", tid); + printf("Thread '%d' exiting!\n", tid); return 0; } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { SDL_Thread *threads[NUMTHREADS]; int i; /* Load the SDL library */ - if (SDL_Init (0) < 0) { - fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ()); + if (SDL_Init(0) < 0) { + fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } - signal (SIGSEGV, SIG_DFL); + signal(SIGSEGV, SIG_DFL); for (i = 0; i < NUMTHREADS; i++) { time_for_threads_to_die[i] = 0; - threads[i] = SDL_CreateThread (ThreadFunc, (void *) (uintptr_t) i); + threads[i] = SDL_CreateThread(ThreadFunc, (void *) (uintptr_t) i); if (threads[i] == NULL) { - fprintf (stderr, "Couldn't create thread: %s\n", SDL_GetError ()); - quit (1); + fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); + quit(1); } } @@ -89,8 +89,8 @@ } for (i = 0; i < NUMTHREADS; i++) { - SDL_WaitThread (threads[i], NULL); + SDL_WaitThread(threads[i], NULL); } - SDL_Quit (); + SDL_Quit(); return (0); }