From 4335d2325863f5351eaf614ec0bd1db61008e388 Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Sat, 15 May 2021 15:18:55 +0200 Subject: [PATCH] Cleanup PR --- src/audio/SDL_sysaudio.h | 2 +- src/cdrom/beos/SDL_syscdrom.cc | 68 +-- src/cdrom/macosx/SDL_syscdrom.c | 164 +++---- src/timer/dummy/SDL_systimer.c | 2 +- src/timer/mint/SDL_vbltimer.S | 4 +- src/video/SDL_RLEaccel.c | 3 +- src/video/SDL_blit.c | 1 + src/video/SDL_blit_A.c | 1 + src/video/SDL_surface.c | 12 +- src/video/SDL_video.c | 586 ++++++++++++++------------ src/video/cybergfx/SDL_amigamouse_c.h | 3 +- 11 files changed, 452 insertions(+), 394 deletions(-) diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index 52adec3a4..2a9f16be8 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -27,7 +27,7 @@ #include "SDL_mutex.h" #include "SDL_thread.h" -#if defined(__amigaos3__) +#if defined(__AMIGA__) #include #include #if defined(__SASC) || defined(WARPOS) diff --git a/src/cdrom/beos/SDL_syscdrom.cc b/src/cdrom/beos/SDL_syscdrom.cc index a9aa9c63e..9a62c3839 100644 --- a/src/cdrom/beos/SDL_syscdrom.cc +++ b/src/cdrom/beos/SDL_syscdrom.cc @@ -59,7 +59,7 @@ extern "C" { #define POS_REL_F(pos) pos.position[15] /* The maximum number of CD-ROM drives we'll detect */ -#define MAX_DRIVES 16 +#define MAX_DRIVES 16 /* A list of available CD-ROM drives */ static char *SDL_cdlist[MAX_DRIVES]; @@ -194,7 +194,7 @@ int SDL_SYS_CDInit(void) return(0); } } - + /* Scan the system for CD-ROM drives */ try_dir("/dev/disk"); return 0; @@ -202,43 +202,43 @@ int SDL_SYS_CDInit(void) int try_dir(const char *directory) -{ - BDirectory dir; - dir.SetTo(directory); - if(dir.InitCheck() != B_NO_ERROR) { - return false; - } - dir.Rewind(); - BEntry entry; - while(dir.GetNextEntry(&entry) >= 0) { - BPath path; - const char *name; - entry_ref e; - - if(entry.GetPath(&path) != B_NO_ERROR) - continue; - name = path.Path(); - - if(entry.GetRef(&e) != B_NO_ERROR) - continue; - - if(entry.IsDirectory()) { - if(SDL_strcmp(e.name, "floppy") == 0) +{ + BDirectory dir; + dir.SetTo(directory); + if(dir.InitCheck() != B_NO_ERROR) { + return false; + } + dir.Rewind(); + BEntry entry; + while(dir.GetNextEntry(&entry) >= 0) { + BPath path; + const char *name; + entry_ref e; + + if(entry.GetPath(&path) != B_NO_ERROR) + continue; + name = path.Path(); + + if(entry.GetRef(&e) != B_NO_ERROR) + continue; + + if(entry.IsDirectory()) { + if(SDL_strcmp(e.name, "floppy") == 0) continue; /* ignore floppy (it is not silent) */ int devfd = try_dir(name); if(devfd >= 0) return devfd; - } - else { - int devfd; - device_geometry g; + } + 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); - if(devfd < 0) - continue; + devfd = open(name, O_RDONLY); + if(devfd < 0) + continue; if(ioctl(devfd, B_GET_GEOMETRY, &g, sizeof(g)) >= 0) { if(g.device_type == B_CD) @@ -247,7 +247,7 @@ int try_dir(const char *directory) } } close(devfd); - } + } } return B_ERROR; } @@ -273,7 +273,7 @@ static int SDL_SYS_CDioctl(int index, int command, void *arg) static const char *SDL_SYS_CDName(int drive) { return(SDL_cdlist[drive]); -} +} static int SDL_SYS_CDOpen(int drive) { diff --git a/src/cdrom/macosx/SDL_syscdrom.c b/src/cdrom/macosx/SDL_syscdrom.c index 43982e697..501875022 100644 --- a/src/cdrom/macosx/SDL_syscdrom.c +++ b/src/cdrom/macosx/SDL_syscdrom.c @@ -59,14 +59,14 @@ static int LoadTracks (SDL_CD *cdrom) /* Check if tracks are already loaded */ if ( tracks[cdrom->id] != NULL ) return 0; - + /* Allocate memory for tracks */ tracks[cdrom->id] = (FSRef*) SDL_calloc (1, sizeof(**tracks) * cdrom->numtracks); if (tracks[cdrom->id] == NULL) { SDL_OutOfMemory (); return -1; } - + /* Load tracks */ if (ListTrackFiles (volumes[cdrom->id], tracks[cdrom->id], cdrom->numtracks) < 0) return -1; @@ -78,20 +78,21 @@ static int LoadTracks (SDL_CD *cdrom) static FSRef* GetFileForOffset (SDL_CD *cdrom, int start, int length, int *outStartFrame, int *outStopFrame) { int i; - + for (i = 0; i < cdrom->numtracks; i++) { + if (cdrom->track[i].offset <= start && start < (cdrom->track[i].offset + cdrom->track[i].length)) break; } - + if (i == cdrom->numtracks) return NULL; - + currentTrack = i; *outStartFrame = start - cdrom->track[i].offset; - + if ((*outStartFrame + length) < cdrom->track[i].length) { *outStopFrame = *outStartFrame + length; length = 0; @@ -104,48 +105,48 @@ static FSRef* GetFileForOffset (SDL_CD *cdrom, int start, int length, int *outS nextTrackFrame = cdrom->track[i+1].offset; nextTrackFramesRemaining = length; } - + return &tracks[cdrom->id][i]; } /* Setup another file for playback, or stop playback (called from another thread) */ static void CompletionProc (SDL_CD *cdrom) { - + Lock (); - + if (nextTrackFrame > 0 && nextTrackFramesRemaining > 0) { - + /* Load the next file to play */ int startFrame, stopFrame; FSRef *file; - + PauseFile (); ReleaseFile (); - - file = GetFileForOffset (cdrom, nextTrackFrame, + + file = GetFileForOffset (cdrom, nextTrackFrame, nextTrackFramesRemaining, &startFrame, &stopFrame); - + if (file == NULL) { status = CD_STOPPED; Unlock (); return; } - + LoadFile (file, startFrame, stopFrame); - + SetCompletionProc (CompletionProc, cdrom); - + PlayFile (); } else { - + /* Release the current file */ PauseFile (); ReleaseFile (); status = CD_STOPPED; } - + Unlock (); } @@ -153,7 +154,7 @@ static void CompletionProc (SDL_CD *cdrom) #pragma mark -- Driver Functions -- /* Initialize */ -int SDL_SYS_CDInit (void) +int SDL_SYS_CDInit (void) { /* Initialize globals */ volumes = NULL; @@ -166,7 +167,7 @@ int SDL_SYS_CDInit (void) didReadTOC = SDL_FALSE; cacheTOCNumTracks = -1; currentDrive = -1; - + /* Fill in function pointers */ SDL_CDcaps.Name = SDL_SYS_CDName; SDL_CDcaps.Open = SDL_SYS_CDOpen; @@ -179,15 +180,15 @@ int SDL_SYS_CDInit (void) SDL_CDcaps.Eject = SDL_SYS_CDEject; SDL_CDcaps.Close = SDL_SYS_CDClose; - /* + /* Read the list of "drives" - + This is currently a hack that infers drives from mounted audio CD volumes, rather than actual CD-ROM devices - which means it may not act as expected sometimes. */ - + /* Find out how many cd volumes are mounted */ SDL_numcds = DetectAudioCDVolumes (NULL, 0); @@ -196,47 +197,47 @@ int SDL_SYS_CDInit (void) so tray empty can be reported. */ if (SDL_numcds == 0) { - + fakeCD = SDL_TRUE; SDL_numcds = 1; status = CD_TRAYEMPTY; - + return 0; } - + /* Allocate space for volumes */ volumes = (FSVolumeRefNum*) SDL_calloc (1, sizeof(*volumes) * SDL_numcds); if (volumes == NULL) { SDL_OutOfMemory (); return -1; } - + /* Allocate space for tracks */ tracks = (FSRef**) SDL_calloc (1, sizeof(*tracks) * (SDL_numcds + 1)); if (tracks == NULL) { SDL_OutOfMemory (); return -1; } - + /* Mark the end of the tracks array */ tracks[ SDL_numcds ] = (FSRef*)-1; - - /* + + /* Redetect, now save all volumes for later Update SDL_numcds just in case it changed */ { int numVolumes = SDL_numcds; - + 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_numcds = numVolumes; } } - + return 0; } @@ -244,16 +245,17 @@ int SDL_SYS_CDInit (void) void SDL_SYS_CDQuit(void) { ReleaseFile(); - + if (volumes != NULL) free (volumes); - + if (tracks != NULL) { + FSRef **ptr; for (ptr = tracks; *ptr != (FSRef*)-1; ptr++) if (*ptr != NULL) free (*ptr); - + free (tracks); } } @@ -272,7 +274,7 @@ static const char *SDL_SYS_CDName (int drive) OSStatus err = noErr; HParamBlockRec pb; GetVolParmsInfoBuffer volParmsInfo; - + if (fakeCD) return "Fake CD-ROM Device"; @@ -312,17 +314,17 @@ static int SDL_SYS_CDGetTOC (SDL_CD *cdrom) SDL_SetError (kErrorFakeDevice); return -1; } - + if (didReadTOC) { cdrom->numtracks = cacheTOCNumTracks; return 0; } - - + + ReadTOCData (volumes[cdrom->id], cdrom); didReadTOC = SDL_TRUE; cacheTOCNumTracks = cdrom->numtracks; - + return 0; } @@ -331,14 +333,14 @@ static CDstatus SDL_SYS_CDStatus (SDL_CD *cdrom, int *position) { if (position) { int trackFrame; - + Lock (); trackFrame = GetCurrentFrame (); Unlock (); - + *position = cdrom->track[currentTrack].offset + trackFrame; } - + return status; } @@ -347,41 +349,41 @@ static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) { int startFrame, stopFrame; FSRef *ref; - + if (fakeCD) { SDL_SetError (kErrorFakeDevice); return -1; } - + Lock(); - + if (LoadTracks (cdrom) < 0) return -2; - + if (PauseFile () < 0) return -3; - + if (ReleaseFile () < 0) return -4; - + ref = GetFileForOffset (cdrom, start, length, &startFrame, &stopFrame); if (ref == NULL) { SDL_SetError ("SDL_SYS_CDPlay: No file for start=%d, length=%d", start, length); return -5; } - + if (LoadFile (ref, startFrame, stopFrame) < 0) return -6; - + SetCompletionProc (CompletionProc, cdrom); - + if (PlayFile () < 0) return -7; - + status = CD_PLAYING; - + Unlock(); - + return 0; } @@ -392,18 +394,18 @@ static int SDL_SYS_CDPause(SDL_CD *cdrom) SDL_SetError (kErrorFakeDevice); return -1; } - + Lock (); - + if (PauseFile () < 0) { Unlock (); return -2; } - + status = CD_PAUSED; - + Unlock (); - + return 0; } @@ -414,18 +416,18 @@ static int SDL_SYS_CDResume(SDL_CD *cdrom) SDL_SetError (kErrorFakeDevice); return -1; } - + Lock (); - + if (PlayFile () < 0) { Unlock (); return -2; } - + status = CD_PLAYING; - + Unlock (); - + return 0; } @@ -436,23 +438,23 @@ static int SDL_SYS_CDStop(SDL_CD *cdrom) SDL_SetError (kErrorFakeDevice); return -1; } - + Lock (); - + if (PauseFile () < 0) { Unlock (); return -2; } - + if (ReleaseFile () < 0) { Unlock (); return -3; } - + status = CD_STOPPED; - + Unlock (); - + return 0; } @@ -466,21 +468,21 @@ static int SDL_SYS_CDEject(SDL_CD *cdrom) SDL_SetError (kErrorFakeDevice); return -1; } - + Lock (); - + if (PauseFile () < 0) { Unlock (); return -2; } - + if (ReleaseFile () < 0) { Unlock (); return -3; } - + status = CD_STOPPED; - + /* Eject the volume */ err = FSEjectVolumeSync(volumes[cdrom->id], kNilOptions, &dissenter); @@ -489,16 +491,16 @@ static int SDL_SYS_CDEject(SDL_CD *cdrom) SDL_SetError ("PBUnmountVol returned %d", err); return -4; } - + status = CD_TRAYEMPTY; /* Invalidate volume and track info */ volumes[cdrom->id] = 0; free (tracks[cdrom->id]); tracks[cdrom->id] = NULL; - + Unlock (); - + return 0; } diff --git a/src/timer/dummy/SDL_systimer.c b/src/timer/dummy/SDL_systimer.c index 1e74b0872..cc266bc9a 100644 --- a/src/timer/dummy/SDL_systimer.c +++ b/src/timer/dummy/SDL_systimer.c @@ -24,7 +24,7 @@ #if defined(SDL_TIMER_DUMMY) || defined(SDL_TIMERS_DISABLED) #include "SDL_timer.h" -#include "SDL_timer_c.h" +#include "../SDL_timer_c.h" void SDL_StartTicks(void) { diff --git a/src/timer/mint/SDL_vbltimer.S b/src/timer/mint/SDL_vbltimer.S index cac9fb338..7837afce0 100644 --- a/src/timer/mint/SDL_vbltimer.S +++ b/src/timer/mint/SDL_vbltimer.S @@ -119,7 +119,7 @@ bcl_search_place: /* Then install ourselves */ place_found: movel a0,(a1) - moveq #0,d0 + moveq #0,d0 exit_vbl_queue: /* Restart interrupts */ @@ -133,7 +133,7 @@ _SDL_AtariVblUninstall: movel sp@(4),d0 cmpl my_vector,d0 bnes badvector - + movel #_my_vbl,d0 /* Stop interrupts */ diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index b202ed89f..d4b191c27 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -26,7 +26,7 @@ * * Original version by Sam Lantinga * - * Mattias EngdegÃ¥rd (Yorick): Rewrite. New encoding format, encoder and + * Mattias Engdegård (Yorick): Rewrite. New encoding format, encoder and * decoder. Added per-surface alpha blitter. Added per-pixel alpha * format, encoder and blitter. * @@ -1938,3 +1938,4 @@ void SDL_UnRLESurface(SDL_Surface *surface, int recode) } } + diff --git a/src/video/SDL_blit.c b/src/video/SDL_blit.c index 00f62dbe6..618f3cc68 100644 --- a/src/video/SDL_blit.c +++ b/src/video/SDL_blit.c @@ -368,3 +368,4 @@ int SDL_CalculateBlit(SDL_Surface *surface) } return(0); } + diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index 14f197cc3..44da4c17a 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -2958,3 +2958,4 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index) } } } + diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 61f72dd0b..a97b710a3 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -409,11 +409,11 @@ void SDLA_SetQuickLazyBlit(SDL_Surface *surface, Uint32 yesno ) /* * Set up a blit between two surfaces -- split into three parts: - * The upper part, SDL_UpperBlit(), performs clipping and rectangle + * The upper part, SDL_UpperBlit(), performs clipping and rectangle * verification. The lower part is a pointer to a low level * accelerated blitting function. * - * These parts are separated out and each used internally by this + * These parts are separated out and each used internally by this * library in the optimimum places. They are exported so that if * you know exactly what you are doing, you can optimize your code * by calling the one(s) you need. @@ -502,7 +502,7 @@ int SDL_UpperBlit (SDL_Surface *src, SDL_Rect *srcrect, /* clip the source rectangle to the source surface */ if(srcrect) { int maxw, maxh; - + srcx = srcrect->x; w = srcrect->w; if(srcx < 0) { @@ -524,7 +524,7 @@ int SDL_UpperBlit (SDL_Surface *src, SDL_Rect *srcrect, maxh = src->h - srcy; if(maxh < h) h = maxh; - + } else { srcx = srcy = 0; w = src->w; @@ -583,7 +583,7 @@ static int SDL_FillRect4(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) return -1; } -/* +/* * This function performs a fast fill of the given rectangle with 'color' */ int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) @@ -863,7 +863,7 @@ void SDL_UnlockSurface (SDL_Surface *surface) } } -/* +/* * Convert a surface into the specified pixel format. */ SDL_Surface * SDL_ConvertSurface (SDL_Surface *surface, diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 3f07eb5a2..ace4a7348 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -148,10 +148,9 @@ SDL_VideoDevice *current_video = NULL; /* Various local functions */ int SDL_VideoInit(const char *driver_name, Uint32 flags); void SDL_VideoQuit(void); -void SDL_GL_UpdateRectsLock(SDL_VideoDevice *this, int numrects, SDL_Rect *rects); +void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect* rects); static SDL_GrabMode SDL_WM_GrabInputOff(void); - #if SDL_VIDEO_OPENGL static int lock_count = 0; #endif @@ -160,7 +159,8 @@ static int lock_count = 0; /* * Initialize the video and event subsystems -- determine native pixel format */ -int SDL_VideoInit(const char *driver_name, Uint32 flags) { +int SDL_VideoInit (const char *driver_name, Uint32 flags) +{ SDL_VideoDevice *video; int index; int i; @@ -186,13 +186,13 @@ int SDL_VideoInit(const char *driver_name, Uint32 flags) { index = 0; video = NULL; if ( driver_name != NULL ) { -#if 0 /* This will be replaced with a better driver selection API */ +#if 0 /* This will be replaced with a better driver selection API */ if ( SDL_strrchr(driver_name, ':') != NULL ) { index = atoi(SDL_strrchr(driver_name, ':')+1); } #endif - for ( i = 0; bootstrap[i]; ++i ) { - if ( SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0 ) { + for ( i=0; bootstrap[i]; ++i ) { + if ( SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) { if ( bootstrap[i]->available() ) { video = bootstrap[i]->create(index); break; @@ -200,8 +200,8 @@ int SDL_VideoInit(const char *driver_name, Uint32 flags) { } } } else { - for ( i = 0; bootstrap[i]; ++i ) { - if ( bootstrap[i]->available()) { + for ( i=0; bootstrap[i]; ++i ) { + if ( bootstrap[i]->available() ) { video = bootstrap[i]->create(index); if ( video != NULL ) { break; @@ -211,7 +211,7 @@ int SDL_VideoInit(const char *driver_name, Uint32 flags) { } if ( video == NULL ) { SDL_SetError("No available video device"); - return (-1); + return(-1); } current_video = video; current_video->name = bootstrap[i]->name; @@ -224,11 +224,11 @@ int SDL_VideoInit(const char *driver_name, Uint32 flags) { video->gammacols = NULL; video->gamma = NULL; video->wm_title = NULL; - video->wm_icon = NULL; + video->wm_icon = NULL; video->offset_x = 0; video->offset_y = 0; SDL_memset(&video->info, 0, (sizeof video->info)); - + video->displayformatalphapixel = NULL; /* Set some very sane GL defaults */ @@ -251,24 +251,24 @@ int SDL_VideoInit(const char *driver_name, Uint32 flags) { video->gl_config.multisamplesamples = 0; video->gl_config.accelerated = -1; /* not known, don't set */ video->gl_config.swap_control = -1; /* not known, don't set */ - + /* Initialize the video subsystem */ SDL_memset(&vformat, 0, sizeof(vformat)); if ( video->VideoInit(video, &vformat) < 0 ) { SDL_VideoQuit(); - return (-1); + return(-1); } /* Create a zero sized video surface of the appropriate format */ video_flags = SDL_SWSURFACE; SDL_VideoSurface = SDL_CreateRGBSurface(video_flags, 0, 0, - vformat.BitsPerPixel, - vformat.Rmask, vformat.Gmask, vformat.Bmask, 0); + vformat.BitsPerPixel, + vformat.Rmask, vformat.Gmask, vformat.Bmask, 0); if ( SDL_VideoSurface == NULL ) { SDL_VideoQuit(); - return (-1); + return(-1); } - SDL_PublicSurface = NULL; /* Until SDL_SetVideoMode() */ + SDL_PublicSurface = NULL; /* Until SDL_SetVideoMode() */ #if 0 /* Don't change the current palette - may be used by other programs. * The application can't do anything with the display surface until @@ -287,46 +287,49 @@ int SDL_VideoInit(const char *driver_name, Uint32 flags) { /* Start the event loop */ if ( SDL_StartEventLoop(flags) < 0 ) { SDL_VideoQuit(); - return (-1); + return(-1); } SDL_CursorInit(flags & SDL_INIT_EVENTTHREAD); /* We're ready to go! */ - return (0); + return(0); } -char *SDL_VideoDriverName(char *namebuf, int maxlen) { +char *SDL_VideoDriverName(char *namebuf, int maxlen) +{ if ( current_video != NULL ) { SDL_strlcpy(namebuf, current_video->name, maxlen); - return (namebuf); + return(namebuf); } - return (NULL); + return(NULL); } /* * Get the current display surface */ -SDL_Surface *SDL_GetVideoSurface(void) { +SDL_Surface *SDL_GetVideoSurface(void) +{ SDL_Surface *visible; visible = NULL; if ( current_video ) { visible = current_video->visible; } - return (visible); + return(visible); } /* * Get the current information about the video hardware */ -const SDL_VideoInfo *SDL_GetVideoInfo(void) { +const SDL_VideoInfo *SDL_GetVideoInfo(void) +{ const SDL_VideoInfo *info; info = NULL; if ( current_video ) { info = ¤t_video->info; } - return (info); + return(info); } /* @@ -336,19 +339,20 @@ const SDL_VideoInfo *SDL_GetVideoInfo(void) { * if any dimension is okay for the given format. If 'format' is NULL, * the mode list will be for the format given by SDL_GetVideoInfo()->vfmt */ -SDL_Rect **SDL_ListModes(SDL_PixelFormat *format, Uint32 flags) { +SDL_Rect ** SDL_ListModes (SDL_PixelFormat *format, Uint32 flags) +{ SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; SDL_Rect **modes; modes = NULL; - if ( SDL_VideoSurface) { + if ( SDL_VideoSurface ) { if ( format == NULL ) { format = SDL_VideoSurface->format; } modes = video->ListModes(this, format, flags); } - return (modes); + return(modes); } /* @@ -360,14 +364,14 @@ SDL_Rect **SDL_ListModes(SDL_PixelFormat *format, Uint32 flags) { * but will emulate the requested bits-per-pixel with a shadow surface. */ static Uint8 SDL_closest_depths[4][8] = { - /* 8 bit closest depth ordering */ - { 0, 8, 16, 15, 32, 24, 0, 0 }, - /* 15,16 bit closest depth ordering */ - { 0, 16, 15, 32, 24, 8, 0, 0 }, - /* 24 bit closest depth ordering */ - { 0, 24, 32, 16, 15, 8, 0, 0 }, - /* 32 bit closest depth ordering */ - { 0, 32, 16, 15, 24, 8, 0, 0 } + /* 8 bit closest depth ordering */ + { 0, 8, 16, 15, 32, 24, 0, 0 }, + /* 15,16 bit closest depth ordering */ + { 0, 16, 15, 32, 24, 8, 0, 0 }, + /* 24 bit closest depth ordering */ + { 0, 24, 32, 16, 15, 8, 0, 0 }, + /* 32 bit closest depth ordering */ + { 0, 32, 16, 15, 24, 8, 0, 0 } }; @@ -377,7 +381,8 @@ static Uint8 SDL_closest_depths[4][8] = { #define NEGATIVE_ONE -1 #endif -int SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags) { +int SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags) +{ int table, b, i; int supported; SDL_PixelFormat format; @@ -385,16 +390,16 @@ int SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags) { /* Currently 1 and 4 bpp are not supported */ if ( bpp < 8 || bpp > 32 ) { - return (0); + return(0); } - if ((width <= 0) || (height <= 0)) { - return (0); + if ( (width <= 0) || (height <= 0) ) { + return(0); } /* Search through the list valid of modes */ SDL_memset(&format, 0, sizeof(format)); supported = 0; - table = ((bpp + 7) / 8) - 1; + table = ((bpp+7)/8)-1; SDL_closest_depths[table][0] = bpp; SDL_closest_depths[table][7] = 0; for ( b = 0; !supported && SDL_closest_depths[table][b]; ++b ) { @@ -417,12 +422,12 @@ int SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags) { } } } else - for ( i = 0; sizes[i]; ++i ) { - if ((sizes[i]->w == width) && (sizes[i]->h == height)) { - supported = 1; - break; - } + for ( i=0; sizes[i]; ++i ) { + if ((sizes[i]->w == width) && (sizes[i]->h == height)) { + supported = 1; + break; } + } } if ( supported ) { --b; @@ -435,7 +440,7 @@ int SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags) { /* * Get the closest non-emulated video mode to the one requested */ -static int SDL_GetVideoMode(int *w, int *h, int *BitsPerPixel, Uint32 flags) +static int SDL_GetVideoMode (int *w, int *h, int *BitsPerPixel, Uint32 flags) { int table, b, i; int supported; @@ -539,7 +544,9 @@ static void SDL_CreateShadowSurface(int depth) } else { Rmask = Gmask = Bmask = 0; } - SDL_ShadowSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, SDL_VideoSurface->w, SDL_VideoSurface->h, depth, Rmask, Gmask, Bmask, 0); + SDL_ShadowSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, + SDL_VideoSurface->w, SDL_VideoSurface->h, + depth, Rmask, Gmask, Bmask, 0); if ( SDL_ShadowSurface == NULL ) { return; } @@ -548,9 +555,13 @@ static void SDL_CreateShadowSurface(int depth) if ( SDL_ShadowSurface->format->palette ) { SDL_ShadowSurface->flags |= SDL_HWPALETTE; if ( depth == (SDL_VideoSurface->format)->BitsPerPixel ) { - SDL_memcpy(SDL_ShadowSurface->format->palette->colors, SDL_VideoSurface->format->palette->colors, SDL_VideoSurface->format->palette->ncolors * sizeof(SDL_Color)); + SDL_memcpy(SDL_ShadowSurface->format->palette->colors, + SDL_VideoSurface->format->palette->colors, + SDL_VideoSurface->format->palette->ncolors* + sizeof(SDL_Color)); } else { - SDL_DitherColors(SDL_ShadowSurface->format->palette->colors, depth); + SDL_DitherColors( + SDL_ShadowSurface->format->palette->colors, depth); } } @@ -567,14 +578,14 @@ static void SDL_CreateShadowSurface(int depth) SDL_ShadowSurface->flags |= SDL_FULLSCREEN; } /* If the video surface is flippable, the shadow should say so */ - if ((SDL_VideoSurface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) { + if ( (SDL_VideoSurface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) { SDL_ShadowSurface->flags |= SDL_DOUBLEBUF; } return; } #ifdef __QNXNTO__ -#include + #include #endif /* __QNXNTO__ */ #ifdef _WIN32 @@ -584,7 +595,7 @@ static void SDL_CreateShadowSurface(int depth) /* * Set the requested video mode, allocating a shadow buffer if necessary. */ -SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) +SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) { SDL_VideoDevice *video, *this; SDL_Surface *prev_mode, *mode; @@ -693,16 +704,16 @@ SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) SDL_VideoSurface = NULL; /* In case it's freed by driver */ mode = video->SetVideoMode(this, prev_mode,video_w,video_h,video_bpp,flags); if ( mode ) { /* Prevent resize events from mode change */ - /* But not on OS/2 */ + /* But not on OS/2 */ #ifndef __OS2__ - SDL_PrivateResize(mode->w, mode->h); + SDL_PrivateResize(mode->w, mode->h); #endif - /* Sam - If we asked for OpenGL mode, and didn't get it, fail */ - if ( is_opengl && !(mode->flags & SDL_OPENGL)) { - mode = NULL; - SDL_SetError("OpenGL not available"); - } + /* Sam - If we asked for OpenGL mode, and didn't get it, fail */ + if ( is_opengl && !(mode->flags & SDL_OPENGL) ) { + mode = NULL; + SDL_SetError("OpenGL not available"); + } } /* * rcg11292000 @@ -721,14 +732,15 @@ SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) /* Sanity check */ if ( (mode->w < width) || (mode->h < height) ) { SDL_SetError("Video mode smaller than requested"); - return (NULL); + return(NULL); } /* If we have a palettized surface, create a default palette */ if ( mode->format->palette ) { SDL_PixelFormat *vf = mode->format; SDL_DitherColors(vf->palette->colors, vf->BitsPerPixel); - video->SetColors(this, 0, vf->palette->ncolors, vf->palette->colors); + video->SetColors(this, 0, vf->palette->ncolors, + vf->palette->colors); } /* Clear the surface to black */ @@ -739,14 +751,15 @@ SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) SDL_ClearSurface(mode); /* Now adjust the offsets to match the desired mode */ - video->offset_x = (mode->w - width) / 2; - video->offset_y = (mode->h - height) / 2; - mode->offset = video->offset_y * mode->pitch + video->offset_x * mode->format->BytesPerPixel; + video->offset_x = (mode->w-width)/2; + video->offset_y = (mode->h-height)/2; + mode->offset = video->offset_y*mode->pitch + + video->offset_x*mode->format->BytesPerPixel; #ifdef DEBUG_VIDEO - fprintf(stderr, - "Requested mode: %dx%dx%d, obtained mode %dx%dx%d (offset %d)\n", - width, height, bpp, - mode->w, mode->h, mode->format->BitsPerPixel, mode->offset); + fprintf(stderr, + "Requested mode: %dx%dx%d, obtained mode %dx%dx%d (offset %d)\n", + width, height, bpp, + mode->w, mode->h, mode->format->BitsPerPixel, mode->offset); #endif mode->w = width; mode->h = height; @@ -783,28 +796,29 @@ SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) #define __SDL_NOGETPROCADDR__ #endif #ifdef __SDL_NOGETPROCADDR__ -#define SDL_PROC(ret,func,params) video->func=func; + #define SDL_PROC(ret,func,params) video->func=func; #else -#define SDL_PROC(ret,func,params) \ - do { \ - video->func = SDL_GL_GetProcAddress(#func); \ - if ( ! video->func ) { \ - SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \ - return(NULL); \ - } \ - } while ( 0 ); + #define SDL_PROC(ret,func,params) \ + do { \ + video->func = SDL_GL_GetProcAddress(#func); \ + if ( ! video->func ) { \ + SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \ + return(NULL); \ + } \ + } while ( 0 ); #endif /* __SDL_NOGETPROCADDR__ */ #include "SDL_glfuncs.h" -#undef SDL_PROC +#undef SDL_PROC } #endif /* SDL_VIDEO_OPENGL */ /* If we're running OpenGL, make the context current */ - if ((video->screen->flags & SDL_OPENGL) && video->GL_MakeCurrent ) { + if ( (video->screen->flags & SDL_OPENGL) && + video->GL_MakeCurrent ) { if ( video->GL_MakeCurrent(this) < 0 ) { - return (NULL); + return(NULL); } } @@ -819,7 +833,9 @@ SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) extension, or implements the core OpenGL 1.2 API, it will support the GL_UNSIGNED_SHORT_5_6_5 texture format. */ - if ( (bpp == 16) && (SDL_strstr((const char *)video->glGetString(GL_EXTENSIONS), "GL_EXT_packed_pixels") || (SDL_atof((const char *)video->glGetString(GL_VERSION)) >= 1.2f)) + if ( (bpp == 16) && + (SDL_strstr((const char *)video->glGetString(GL_EXTENSIONS), "GL_EXT_packed_pixels") || + (SDL_atof((const char *)video->glGetString(GL_VERSION)) >= 1.2f)) ) { video->is_32bit = 0; SDL_VideoSurface = SDL_CreateRGBSurface( @@ -885,7 +901,7 @@ SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) video->UpdateRects = SDL_GL_UpdateRectsLock; #else SDL_SetError("Somebody forgot to #define SDL_VIDEO_OPENGL"); - return (NULL); + return(NULL); #endif } @@ -896,26 +912,24 @@ SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) 3. We need a software surface and got a hardware surface. */ if ( !(SDL_VideoSurface->flags & SDL_OPENGL) && - ( - (!(flags & SDL_ANYFORMAT) && - (SDL_VideoSurface->format->BitsPerPixel != bpp)) || - ((flags & SDL_HWPALETTE) && - !(SDL_VideoSurface->flags & SDL_HWPALETTE)) || - /* If the surface is in hardware, video writes are visible - as soon as they are performed, so we need to buffer them - */ - (((flags & SDL_HWSURFACE) == SDL_SWSURFACE) && - (SDL_VideoSurface->flags & SDL_HWSURFACE)) || - ((flags & SDL_DOUBLEBUF) && - (SDL_VideoSurface->flags & SDL_HWSURFACE) && - !(SDL_VideoSurface->flags & SDL_DOUBLEBUF)) - )) { - - SDL_CreateShadowSurface(bpp); //mode->format->BitsPerPixel); - + ( + ( !(flags&SDL_ANYFORMAT) && + (SDL_VideoSurface->format->BitsPerPixel != bpp)) || + ( (flags&SDL_HWPALETTE) && + !(SDL_VideoSurface->flags&SDL_HWPALETTE)) || + /* If the surface is in hardware, video writes are visible + as soon as they are performed, so we need to buffer them + */ + ( ((flags&SDL_HWSURFACE) == SDL_SWSURFACE) && + (SDL_VideoSurface->flags&SDL_HWSURFACE)) || + ( (flags&SDL_DOUBLEBUF) && + (SDL_VideoSurface->flags&SDL_HWSURFACE) && + !(SDL_VideoSurface->flags&SDL_DOUBLEBUF)) + ) ) { + SDL_CreateShadowSurface(bpp); if ( SDL_ShadowSurface == NULL ) { SDL_SetError("Couldn't create shadow surface"); - return (NULL); + return(NULL); } SDL_PublicSurface = SDL_ShadowSurface; } else { @@ -929,35 +943,37 @@ SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) return(SDL_PublicSurface); } -/* +/* * Convert a surface into the video pixel format. */ -SDL_Surface *SDL_DisplayFormat(SDL_Surface *surface) { +SDL_Surface * SDL_DisplayFormat (SDL_Surface *surface) +{ Uint32 flags; - if ( !SDL_PublicSurface) { + if ( ! SDL_PublicSurface ) { SDL_SetError("No video mode has been set"); - return (NULL); + return(NULL); } /* Set the flags appropriate for copying to display surface */ - if (((SDL_PublicSurface->flags & SDL_HWSURFACE) == SDL_HWSURFACE) && current_video->info.blit_hw ) + if (((SDL_PublicSurface->flags&SDL_HWSURFACE) == SDL_HWSURFACE) && current_video->info.blit_hw) flags = SDL_HWSURFACE; - else + else flags = SDL_SWSURFACE; #ifdef AUTORLE_DISPLAYFORMAT flags |= (surface->flags & (SDL_SRCCOLORKEY|SDL_SRCALPHA)); flags |= SDL_RLEACCELOK; #else - flags |= surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA | SDL_RLEACCELOK); + 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)); } /* * Convert a surface into a format that's suitable for blitting to * the screen, but including an alpha channel. */ -SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface) { +SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface) +{ SDL_PixelFormat *vf; SDL_PixelFormat *format; SDL_Surface *converted; @@ -968,23 +984,23 @@ SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface) { Uint32 gmask = 0x0000ff00; Uint32 bmask = 0x000000ff; - if ( !SDL_PublicSurface) { + if ( ! SDL_PublicSurface ) { SDL_SetError("No video mode has been set"); - return (NULL); + return(NULL); } vf = SDL_PublicSurface->format; - switch ( vf->BytesPerPixel ) { - case 2: - /* For XGY5[56]5, use, AXGY8888, where {X, Y} = {R, B}. - For anything else (like ARGB4444) it doesn't matter - since we have no special code for it anyway */ - if ((vf->Rmask == 0x1f) && - (vf->Bmask == 0xf800 || vf->Bmask == 0x7c00)) { - rmask = 0xff; - bmask = 0xff0000; - } - break; + switch(vf->BytesPerPixel) { + case 2: + /* For XGY5[56]5, use, AXGY8888, where {X, Y} = {R, B}. + For anything else (like ARGB4444) it doesn't matter + since we have no special code for it anyway */ + if ( (vf->Rmask == 0x1f) && + (vf->Bmask == 0xf800 || vf->Bmask == 0x7c00)) { + rmask = 0xff; + bmask = 0xff0000; + } + break; case 3: case 4: @@ -1001,23 +1017,24 @@ SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface) { } break; - default: - /* We have no other optimised formats right now. When/if a new - optimised alpha format is written, add the converter here */ - break; + default: + /* We have no other optimised formats right now. When/if a new + optimised alpha format is written, add the converter here */ + break; } 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); - return (converted); + return(converted); } /* * Update a specific portion of the physical screen */ -void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) { +void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) +{ if ( screen ) { SDL_Rect rect; @@ -1026,9 +1043,9 @@ void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) w = screen->w; if ( h == 0 ) h = screen->h; - if ((int)(x + w) > screen->w ) + if ( (int)(x+w) > screen->w ) return; - if ((int)(y + h) > screen->h ) + if ( (int)(y+h) > screen->h ) return; /* Fill the rectangle */ @@ -1039,21 +1056,21 @@ void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) SDL_UpdateRects(screen, 1, &rect); } } - -void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects) { +void SDL_UpdateRects (SDL_Surface *screen, int numrects, SDL_Rect *rects) +{ int i; SDL_VideoDevice *video = current_video; SDL_VideoDevice *this = current_video; - if ((screen->flags & (SDL_OPENGL | SDL_OPENGLBLIT)) == SDL_OPENGL ) { + if ( (screen->flags & (SDL_OPENGL | SDL_OPENGLBLIT)) == SDL_OPENGL ) { SDL_SetError("OpenGL active, use SDL_GL_SwapBuffers()"); return; } - if ( screen == SDL_ShadowSurface) { + if ( screen == SDL_ShadowSurface ) { /* Blit the shadow surface using saved mapping */ SDL_Palette *pal = screen->format->palette; SDL_Color *saved_colors = NULL; - if ( pal && !(SDL_VideoSurface->flags & SDL_HWPALETTE)) { + if ( pal && !(SDL_VideoSurface->flags & SDL_HWPALETTE) ) { /* simulated 8bpp, use correct physical palette */ saved_colors = pal->colors; if ( video->gammacols ) { @@ -1064,19 +1081,19 @@ void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects) { pal->colors = video->physpal->colors; } } - if ( SHOULD_DRAWCURSOR(SDL_cursorstate)) { + if ( SHOULD_DRAWCURSOR(SDL_cursorstate) ) { SDL_LockCursor(); SDL_DrawCursor(SDL_ShadowSurface); - for ( i = 0; i < numrects; ++i ) { - SDL_LowerBlit(SDL_ShadowSurface, &rects[i], - SDL_VideoSurface, &rects[i]); + for ( i=0; ioffset ) { - for ( i = 0; i < numrects; ++i ) { + for ( i=0; ioffset_x; rects[i].y += video->offset_y; } video->UpdateRects(this, numrects, rects); - for ( i = 0; i < numrects; ++i ) { + for ( i=0; ioffset_x; rects[i].y -= video->offset_y; } @@ -1151,7 +1168,8 @@ int SDL_Flip(SDL_Surface *screen) SDL_EraseCursor(SDL_ShadowSurface); SDL_UnlockCursor(); } else { - SDL_LowerBlit(SDL_ShadowSurface, &rect, SDL_VideoSurface, &rect); + SDL_LowerBlit(SDL_ShadowSurface, &rect, + SDL_VideoSurface, &rect); } if ( saved_colors ) { pal->colors = saved_colors; @@ -1162,21 +1180,24 @@ int SDL_Flip(SDL_Surface *screen) screen = SDL_VideoSurface; #endif } - if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) { - SDL_VideoDevice *this = current_video; - return (video->FlipHWSurface(this, SDL_VideoSurface)); + if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) { + SDL_VideoDevice *this = current_video; + return(video->FlipHWSurface(this, SDL_VideoSurface)); } else { SDL_UpdateRect(screen, 0, 0, 0, 0); } return(0); } -static void SetPalette_logical(SDL_Surface *screen, SDL_Color *colors, int firstcolor, int ncolors) { +static void SetPalette_logical(SDL_Surface *screen, SDL_Color *colors, + int firstcolor, int ncolors) +{ SDL_Palette *pal = screen->format->palette; SDL_Palette *vidpal; if ( colors != (pal->colors + firstcolor) ) { - SDL_memcpy(pal->colors + firstcolor, colors, ncolors * sizeof(*colors)); + SDL_memcpy(pal->colors + firstcolor, colors, + ncolors * sizeof(*colors)); } if ( current_video && SDL_VideoSurface ) { @@ -1188,13 +1209,16 @@ static void SetPalette_logical(SDL_Surface *screen, SDL_Color *colors, int first * 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)); } } SDL_FormatChanged(screen); } -static int SetPalette_physical(SDL_Surface *screen, SDL_Color *colors, int firstcolor, int ncolors) { +static int SetPalette_physical(SDL_Surface *screen, + SDL_Color *colors, int firstcolor, int ncolors) +{ SDL_VideoDevice *video = current_video; int gotall = 1; @@ -1202,9 +1226,10 @@ static int SetPalette_physical(SDL_Surface *screen, SDL_Color *colors, int first /* We need to copy the new colors, since we haven't * already done the copy in the logical set above. */ - SDL_memcpy(video->physpal->colors + firstcolor, colors, ncolors * sizeof(*colors)); + SDL_memcpy(video->physpal->colors + firstcolor, + colors, ncolors * sizeof(*colors)); } - if ( screen == SDL_ShadowSurface) { + if ( screen == SDL_ShadowSurface ) { if ( SDL_VideoSurface->flags & SDL_HWPALETTE ) { /* * The real screen is also indexed - set its physical @@ -1218,19 +1243,25 @@ static int SetPalette_physical(SDL_Surface *screen, SDL_Color *colors, int first * The video surface is not indexed - invalidate any * active shadow-to-video blit mappings. */ - if ( screen->map->dst == SDL_VideoSurface) { + if ( screen->map->dst == SDL_VideoSurface ) { SDL_InvalidateMap(screen->map); } if ( video->gamma ) { - if ( !video->gammacols ) { + if( ! video->gammacols ) { SDL_Palette *pp = video->physpal; - if ( !pp ) + if(!pp) pp = screen->format->palette; video->gammacols = SDL_malloc(pp->ncolors - * sizeof(SDL_Color)); - SDL_ApplyGamma(video->gamma, pp->colors, video->gammacols, pp->ncolors); + * sizeof(SDL_Color)); + SDL_ApplyGamma(video->gamma, + pp->colors, + video->gammacols, + pp->ncolors); } else { - SDL_ApplyGamma(video->gamma, colors, video->gammacols + firstcolor, ncolors); + SDL_ApplyGamma(video->gamma, colors, + video->gammacols + + firstcolor, + ncolors); } } SDL_UpdateRect(screen, 0, 0, 0, 0); @@ -1245,7 +1276,7 @@ static int SetPalette_physical(SDL_Surface *screen, SDL_Color *colors, int first colors = gcolors; } gotall = video->SetColors(video, firstcolor, ncolors, colors); - if ( !gotall ) { + if ( ! gotall ) { /* The video flags shouldn't have SDL_HWPALETTE, and the video driver is responsible for copying back the correct colors into the video surface palette. @@ -1266,7 +1297,9 @@ static int SetPalette_physical(SDL_Surface *screen, SDL_Color *colors, int first * * Return nonzero if all colours were set as requested, or 0 otherwise. */ -int SDL_SetPalette(SDL_Surface *screen, int which, SDL_Color *colors, int firstcolor, int ncolors) { +int SDL_SetPalette(SDL_Surface *screen, int which, + SDL_Color *colors, int firstcolor, int ncolors) +{ SDL_Palette *pal; int gotall; int palsize; @@ -1284,8 +1317,8 @@ int SDL_SetPalette(SDL_Surface *screen, int which, SDL_Color *colors, int firstc /* Verify the parameters */ pal = screen->format->palette; - if ( !pal ) { - return 0; /* not a palettized surface */ + if( !pal ) { + return 0; /* not a palettized surface */ } gotall = 1; palsize = 1 << screen->format->BitsPerPixel; @@ -1326,26 +1359,31 @@ int SDL_SetPalette(SDL_Surface *screen, int which, SDL_Color *colors, int firstc } SDL_memcpy(pp->colors, pal->colors, size); } - if ( !SetPalette_physical(screen, colors, firstcolor, ncolors)) { + if ( ! SetPalette_physical(screen, + colors, firstcolor, ncolors) ) { gotall = 0; } } return gotall; } -int SDL_SetColors(SDL_Surface *screen, SDL_Color *colors, int firstcolor, int ncolors) { - return SDL_SetPalette(screen, SDL_LOGPAL | SDL_PHYSPAL, colors, firstcolor, ncolors); +int SDL_SetColors(SDL_Surface *screen, SDL_Color *colors, int firstcolor, + int ncolors) +{ + return SDL_SetPalette(screen, SDL_LOGPAL | SDL_PHYSPAL, + colors, firstcolor, ncolors); } /* * Clean up the video subsystem */ -void SDL_VideoQuit(void) { +void SDL_VideoQuit (void) +{ SDL_Surface *ready_to_go; if ( current_video ) { - SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *video = current_video; + SDL_VideoDevice *this = current_video; /* Halt event processing before doing anything else */ SDL_StopEventLoop(); @@ -1404,7 +1442,8 @@ void SDL_VideoQuit(void) { } /* Load the GL driver library */ -int SDL_GL_LoadLibrary(const char *path) { +int SDL_GL_LoadLibrary(const char *path) +{ SDL_VideoDevice *video = current_video; SDL_VideoDevice *this = current_video; int retval; @@ -1419,10 +1458,11 @@ int SDL_GL_LoadLibrary(const char *path) { SDL_SetError("No dynamic GL support in video driver"); } } - return (retval); + return(retval); } -void *SDL_GL_GetProcAddress(const char *proc) { +void *SDL_GL_GetProcAddress(const char* proc) +{ SDL_VideoDevice *video = current_video; SDL_VideoDevice *this = current_video; void *func; @@ -1441,12 +1481,13 @@ void *SDL_GL_GetProcAddress(const char *proc) { } /* Set the specified GL attribute for setting up a GL video mode */ -int SDL_GL_SetAttribute(SDL_GLattr attr, int value) { +int SDL_GL_SetAttribute( SDL_GLattr attr, int value ) +{ int retval; SDL_VideoDevice *video = current_video; retval = 0; - switch ( attr ) { + switch (attr) { case SDL_GL_RED_SIZE: video->gl_config.red_size = value; break; @@ -1503,14 +1544,15 @@ int SDL_GL_SetAttribute(SDL_GLattr attr, int value) { retval = -1; break; } - return (retval); + return(retval); } /* Retrieve an attribute value from the windowing system. */ -int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) { +int SDL_GL_GetAttribute(SDL_GLattr attr, int* value) +{ int retval = -1; - SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice* video = current_video; + SDL_VideoDevice* this = current_video; if ( video->GL_GetAttribute ) { retval = this->GL_GetAttribute(this, attr, value); @@ -1522,7 +1564,8 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) { } /* Perform a GL buffer swap on the current GL context */ -void SDL_GL_SwapBuffers(void) { +void SDL_GL_SwapBuffers(void) +{ SDL_VideoDevice *video = current_video; SDL_VideoDevice *this = current_video; @@ -1534,14 +1577,16 @@ void SDL_GL_SwapBuffers(void) { } /* Update rects with locking */ -void SDL_GL_UpdateRectsLock(SDL_VideoDevice *this, int numrects, SDL_Rect *rects) { +void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect *rects) +{ SDL_GL_Lock(); - SDL_GL_UpdateRects(numrects, rects); + SDL_GL_UpdateRects(numrects, rects); SDL_GL_Unlock(); } /* Update rects without state setting and changing (the caller is responsible for it) */ -void SDL_GL_UpdateRects(int numrects, SDL_Rect *rects) { +void SDL_GL_UpdateRects(int numrects, SDL_Rect *rects) +{ #if SDL_VIDEO_OPENGL SDL_VideoDevice *this = current_video; SDL_Rect update, tmp; @@ -1567,42 +1612,42 @@ void SDL_GL_UpdateRects(int numrects, SDL_Rect *rects) { if ( update.h > 256 ) update.h = 256; - + this->glFlush(); - this->glTexSubImage2D( - GL_TEXTURE_2D, - 0, - 0, - 0, - update.w, - update.h, + this->glTexSubImage2D( + GL_TEXTURE_2D, + 0, + 0, + 0, + update.w, + update.h, this->is_32bit? GL_RGBA : GL_RGB, #ifdef GL_VERSION_1_2 this->is_32bit ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5, #else GL_UNSIGNED_BYTE, #endif - (Uint8 *)this->screen->pixels + - this->screen->format->BytesPerPixel * update.x + + (Uint8 *)this->screen->pixels + + this->screen->format->BytesPerPixel * update.x + update.y * this->screen->pitch ); - + this->glFlush(); /* * Note the parens around the function name: - * This is because some OpenGL implementations define glTexCoord etc + * This is because some OpenGL implementations define glTexCoord etc * as macros, and we don't want them expanded here. */ this->glBegin(GL_TRIANGLE_STRIP); - (this->glTexCoord2f)( 0.0, 0.0 ); + (this->glTexCoord2f)( 0.0, 0.0 ); (this->glVertex2i)( update.x, update.y ); - (this->glTexCoord2f)( (float)(update.w / 256.0), 0.0 ); + (this->glTexCoord2f)( (float)(update.w / 256.0), 0.0 ); (this->glVertex2i)( update.x + update.w, update.y ); (this->glTexCoord2f)( 0.0, (float)(update.h / 256.0) ); (this->glVertex2i)( update.x, update.y + update.h ); - (this->glTexCoord2f)( (float)(update.w / 256.0), (float)(update.h / 256.0) ); + (this->glTexCoord2f)( (float)(update.w / 256.0), (float)(update.h / 256.0) ); (this->glVertex2i)( update.x + update.w , update.y + update.h ); - this->glEnd(); - + this->glEnd(); + tmp.x += 256; tmp.w -= 256; } @@ -1614,7 +1659,8 @@ void SDL_GL_UpdateRects(int numrects, SDL_Rect *rects) { } /* Lock == save current state */ -void SDL_GL_Lock() { +void SDL_GL_Lock() +{ #if SDL_VIDEO_OPENGL lock_count--; if (lock_count==-1) @@ -1661,7 +1707,8 @@ void SDL_GL_Lock() { } /* Unlock == restore saved state */ -void SDL_GL_Unlock() { +void SDL_GL_Unlock() +{ #if SDL_VIDEO_OPENGL lock_count++; if (lock_count==0) @@ -1684,9 +1731,10 @@ void SDL_Audio_SetCaption(const char *caption); /* * Sets/Gets the title and icon text of the display window, if any. */ -void SDL_WM_SetCaption(const char *title, const char *icon) { +void SDL_WM_SetCaption (const char *title, const char *icon) +{ SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; if ( video ) { if ( title ) { @@ -1701,8 +1749,8 @@ void SDL_WM_SetCaption(const char *title, const char *icon) { } video->wm_icon = SDL_strdup(icon); } - if ((title || icon) && (video->SetCaption != NULL)) { - video->SetCaption(this, video->wm_title, video->wm_icon); + if ( (title || icon) && (video->SetCaption != NULL) ) { + video->SetCaption(this, video->wm_title,video->wm_icon); } } @@ -1710,7 +1758,8 @@ void SDL_WM_SetCaption(const char *title, const char *icon) { SDL_Audio_SetCaption(title); } -void SDL_WM_GetCaption(char **title, char **icon) { +void SDL_WM_GetCaption (char **title, char **icon) +{ SDL_VideoDevice *video = current_video; if ( video ) { @@ -1725,74 +1774,73 @@ void SDL_WM_GetCaption(char **title, char **icon) { /* 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) { +static void CreateMaskFromColorKeyOrAlpha(SDL_Surface *icon, Uint8 *mask, int flags) +{ int x, y; Uint32 colorkey; #define SET_MASKBIT(icon, x, y, mask) \ - mask[(y*((icon->w+7)/8))+(x/8)] &= ~(0x01<<(7-(x%8))) + mask[(y*((icon->w+7)/8))+(x/8)] &= ~(0x01<<(7-(x%8))) colorkey = icon->format->colorkey; - switch ( icon->format->BytesPerPixel ) { - case 1: { - Uint8 *pixels; - for ( y = 0; y < icon->h; ++y ) { - pixels = (Uint8 *)icon->pixels + y * icon->pitch; - for ( x = 0; x < icon->w; ++x ) { + switch (icon->format->BytesPerPixel) { + case 1: { Uint8 *pixels; + for ( y=0; yh; ++y ) { + pixels = (Uint8 *)icon->pixels + y*icon->pitch; + for ( x=0; xw; ++x ) { if ( *pixels++ == colorkey ) { SET_MASKBIT(icon, x, y, mask); } } } } - break; + break; - case 2: { - Uint16 *pixels; - for ( y = 0; y < icon->h; ++y ) { + case 2: { Uint16 *pixels; + for ( y=0; yh; ++y ) { pixels = (Uint16 *)icon->pixels + - y * icon->pitch / 2; - for ( x = 0; x < icon->w; ++x ) { - if ((flags & 1) && *pixels == colorkey ) { + y*icon->pitch/2; + for ( x=0; xw; ++x ) { + if ( (flags & 1) && *pixels == colorkey ) { SET_MASKBIT(icon, x, y, mask); - } else if ((flags & 2) && (*pixels & icon->format->Amask) == 0 ) { + } else if((flags & 2) && (*pixels & icon->format->Amask) == 0) { SET_MASKBIT(icon, x, y, mask); } pixels++; } } } - break; + break; - case 4: { - Uint32 *pixels; - for ( y = 0; y < icon->h; ++y ) { + case 4: { Uint32 *pixels; + for ( y=0; yh; ++y ) { pixels = (Uint32 *)icon->pixels + - y * icon->pitch / 4; - for ( x = 0; x < icon->w; ++x ) { - if ((flags & 1) && *pixels == colorkey ) { + y*icon->pitch/4; + for ( x=0; xw; ++x ) { + if ( (flags & 1) && *pixels == colorkey ) { SET_MASKBIT(icon, x, y, mask); - } else if ((flags & 2) && (*pixels & icon->format->Amask) == 0 ) { + } else if((flags & 2) && (*pixels & icon->format->Amask) == 0) { SET_MASKBIT(icon, x, y, mask); } pixels++; } } } - break; + break; } } /* * Sets the window manager icon for the display window. */ -void SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask) { +void SDL_WM_SetIcon (SDL_Surface *icon, Uint8 *mask) +{ SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; if ( icon && video->SetIcon ) { /* Generate a mask if necessary, and create the icon! */ if ( mask == NULL ) { - int mask_len = icon->h * (icon->w + 7) / 8; + int mask_len = icon->h*(icon->w+7)/8; int flags = 0; mask = (Uint8 *)SDL_malloc(mask_len); if ( mask == NULL ) { @@ -1801,7 +1849,7 @@ void SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask) { SDL_memset(mask, ~0, mask_len); if ( icon->flags & SDL_SRCCOLORKEY ) flags |= 1; if ( icon->flags & SDL_SRCALPHA ) flags |= 2; - if ( flags ) { + if( flags ) { CreateMaskFromColorKeyOrAlpha(icon, mask, flags); } video->SetIcon(video, icon, mask); @@ -1817,18 +1865,19 @@ void SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask) { * This function returns the final grab mode after calling the * driver dependent function. */ -static SDL_GrabMode SDL_WM_GrabInputRaw(SDL_GrabMode mode) { +static SDL_GrabMode SDL_WM_GrabInputRaw(SDL_GrabMode mode) +{ SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; /* Only do something if we have support for grabs */ if ( video->GrabInput == NULL ) { - return (video->input_grab); + return(video->input_grab); } /* If the final grab mode if off, only then do we actually grab */ #ifdef DEBUG_GRAB - printf("SDL_WM_GrabInputRaw(%d) ... ", mode); + printf("SDL_WM_GrabInputRaw(%d) ... ", mode); #endif if ( mode == SDL_GRAB_OFF ) { if ( video->input_grab != SDL_GRAB_OFF ) { @@ -1846,21 +1895,21 @@ static SDL_GrabMode SDL_WM_GrabInputRaw(SDL_GrabMode mode) { } } #ifdef DEBUG_GRAB - printf("Final mode %d\n", video->input_grab); + printf("Final mode %d\n", video->input_grab); #endif /* Return the final grab state */ if ( mode >= SDL_GRAB_FULLSCREEN ) { mode -= SDL_GRAB_FULLSCREEN; } - return (mode); + return(mode); } - -SDL_GrabMode SDL_WM_GrabInput(SDL_GrabMode mode) { +SDL_GrabMode SDL_WM_GrabInput(SDL_GrabMode mode) +{ SDL_VideoDevice *video = current_video; /* If the video isn't initialized yet, we can't do anything */ - if ( !video ) { + if ( ! video ) { return SDL_GRAB_OFF; } @@ -1870,23 +1919,23 @@ SDL_GrabMode SDL_WM_GrabInput(SDL_GrabMode mode) { if ( mode >= SDL_GRAB_FULLSCREEN ) { mode -= SDL_GRAB_FULLSCREEN; } - return (mode); + return(mode); } #ifdef DEBUG_GRAB - printf("SDL_WM_GrabInput(%d) ... ", mode); + printf("SDL_WM_GrabInput(%d) ... ", mode); #endif /* If the video surface is fullscreen, we always grab */ if ( mode >= SDL_GRAB_FULLSCREEN ) { mode -= SDL_GRAB_FULLSCREEN; } - if ( SDL_VideoSurface && (SDL_VideoSurface->flags & SDL_FULLSCREEN)) { + if ( SDL_VideoSurface && (SDL_VideoSurface->flags & SDL_FULLSCREEN) ) { mode += SDL_GRAB_FULLSCREEN; } - return (SDL_WM_GrabInputRaw(mode)); + return(SDL_WM_GrabInputRaw(mode)); } - -static SDL_GrabMode SDL_WM_GrabInputOff(void) { +static SDL_GrabMode SDL_WM_GrabInputOff(void) +{ SDL_GrabMode mode; /* First query the current grab state */ @@ -1896,36 +1945,38 @@ static SDL_GrabMode SDL_WM_GrabInputOff(void) { SDL_WM_GrabInputRaw(SDL_GRAB_OFF); /* Return the old state */ - return (mode); + return(mode); } /* * Iconify the window in window managed environments. * A successful iconification will result in an SDL_APPACTIVE loss event. */ -int SDL_WM_IconifyWindow(void) { +int SDL_WM_IconifyWindow(void) +{ SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; int retval; retval = 0; if ( video->IconifyWindow ) { retval = video->IconifyWindow(this); } - return (retval); + return(retval); } /* * Toggle fullscreen mode */ -int SDL_WM_ToggleFullScreen(SDL_Surface *surface) { +int SDL_WM_ToggleFullScreen(SDL_Surface *surface) +{ SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; int toggled; toggled = 0; if ( SDL_PublicSurface && (surface == SDL_PublicSurface) && - video->ToggleFullScreen ) { + video->ToggleFullScreen ) { if ( surface->flags & SDL_FULLSCREEN ) { toggled = video->ToggleFullScreen(this, 0); if ( toggled ) { @@ -1944,19 +1995,20 @@ int SDL_WM_ToggleFullScreen(SDL_Surface *surface) { SDL_WM_GrabInput(video->input_grab); } } - return (toggled); + return(toggled); } /* * Get some platform dependent window manager information */ -int SDL_GetWMInfo(SDL_SysWMinfo *info) { +int SDL_GetWMInfo (SDL_SysWMinfo *info) +{ SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; if ( video && video->GetWMInfo ) { - return (video->GetWMInfo(this, info)); + return(video->GetWMInfo(this, info)); } else { - return (0); + return(0); } } diff --git a/src/video/cybergfx/SDL_amigamouse_c.h b/src/video/cybergfx/SDL_amigamouse_c.h index a2aefe411..aad19b627 100644 --- a/src/video/cybergfx/SDL_amigamouse_c.h +++ b/src/video/cybergfx/SDL_amigamouse_c.h @@ -25,7 +25,8 @@ /* 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 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);