1 diff -Naur SDL-1.2.15-orig/aros/sdl-config SDL-1.2.15/aros/sdl-config
2 --- SDL-1.2.15-orig/aros/sdl-config 1970-01-01 01:00:00.000000000 +0100
3 +++ SDL-1.2.15/aros/sdl-config 2015-05-09 15:09:59.750739542 +0200
10 +libdir=${exec_prefix}/lib
13 +Usage: sdl-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs]"
14 +#Usage: sdl-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs] [--static-libs]"
16 +if test $# -eq 0; then
17 + echo "${usage}" 1>&2
21 +while test $# -gt 0; do
23 + -*=*) optarg=`echo "$1" | LC_ALL="C" sed 's/[-_a-zA-Z0-9]*=//'` ;;
30 + if test $exec_prefix_set = no ; then
48 + echo -I${prefix}/include/SDL -D_GNU_SOURCE=1
51 + echo -L${exec_prefix}/lib -lSDL
54 + echo -L${exec_prefix}/lib -lSDL_static -lm -lGL
57 + echo "${usage}" 1>&2
63 diff -Naur SDL-1.2.15-orig/aros/sdl.pc SDL-1.2.15/aros/sdl.pc
64 --- SDL-1.2.15-orig/aros/sdl.pc 1970-01-01 01:00:00.000000000 +0100
65 +++ SDL-1.2.15/aros/sdl.pc 2015-05-09 15:09:59.750739542 +0200
67 +# sdl pkg-config source file
70 +exec_prefix=${prefix}
71 +libdir=${exec_prefix}/lib
72 +includedir=${prefix}/include
75 +Description: Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.
79 +Libs: -L${libdir} -lSDL
80 +Libs.private: -lSDL -lm -lGL
81 +Cflags: -I${includedir}/SDL -D_GNU_SOURCE=1
82 diff -Naur SDL-1.2.15-orig/aros_init.c SDL-1.2.15/aros_init.c
83 --- SDL-1.2.15-orig/aros_init.c 1970-01-01 01:00:00.000000000 +0100
84 +++ SDL-1.2.15/aros_init.c 2015-05-09 15:09:59.750739542 +0200
86 +/* Copyright 2013 The AROS Development Team. All rights reserved. */
88 +#include <aros/debug.h>
91 +#include <proto/stdc.h>
93 +#include <aros/symbolsets.h>
94 +#include LC_LIBDEFS_FILE
96 +#include "SDL_intern.h"
97 +#include "video/SDL_sysvideo.h"
98 +#include "video/cgx/SDL_cgxgl_c.h"
100 +static int GM_UNIQUENAME(LibInit)(LIBBASETYPEPTR LIBBASE)
102 + D(bug("SDL.library->Init(%p)\n", LIBBASE));
107 +static int GM_UNIQUENAME(LibOpen)(LIBBASETYPEPTR LIBBASE)
109 + D(bug("SDL.library->Open(%p)\n", LIBBASE));
111 + LIBBASE->copy_row_base = AllocMem(4096 * 2, MEMF_CLEAR);
112 + LIBBASE->copy_row = (APTR)(((IPTR)LIBBASE->copy_row_base + 4096) & ~0xFFF);
113 + D(bug("SDL.library->Open: root base @ 0x%p\n", LIBBASE->rootSDLBase));
115 + struct Task *opener = FindTask(NULL);
116 + bug("SDL.library->Open: StdCBase @ 0x%p for task @ 0x%p ('%s')\n", __aros_getbase_StdCBase(), opener, ((struct Node *)opener)->ln_Name);
118 + D(bug("SDL.library->Open: copy_row @ 0x%p\n", LIBBASE->copy_row));
120 + LIBBASE->SDL_initialized = 0;
121 +#if !SDL_TIMERS_DISABLED
122 + LIBBASE->ticks_started = 0;
125 + LIBBASE->surfaces_allocated = 0;
128 + LIBBASE->SDL_timer_started = 0;
129 + LIBBASE->SDL_timer_running = 0;
130 + LIBBASE->timer_alive = 0;
131 + LIBBASE->timer_thread = NULL;
133 + LIBBASE->SDL_alarm_interval = 0;
134 + LIBBASE->SDL_alarm_callback = NULL;
136 + LIBBASE->SDL_timer_threaded = 0;
138 + LIBBASE->SDL_timers = NULL;
139 + LIBBASE->SDL_timer_mutex = NULL;
140 + LIBBASE->list_changed = SDL_FALSE;
142 + LIBBASE->SDL_maxthreads = 0;
143 + LIBBASE->SDL_numthreads = 0;
144 + LIBBASE->SDL_Threads = NULL;
145 + LIBBASE->SDL_ThreadLock = NULL;
146 + LIBBASE->SDL_ThreadLockCreated = 0;
147 + memset(&LIBBASE->SDL_global_error, 0, sizeof(LIBBASE->SDL_global_error));
149 + LIBBASE->SDL_appstate = 0;
151 + LIBBASE->SDL_EventOK = NULL;
152 + LIBBASE->SDL_eventstate = 0;
153 + LIBBASE->SDL_EventThread = NULL;
155 + LIBBASE->SDL_MouseX = 0;
156 + LIBBASE->SDL_MouseY = 0;
157 + LIBBASE->SDL_DeltaX = 0;
158 + LIBBASE->SDL_DeltaY = 0;
159 + LIBBASE->SDL_MouseMaxX = 0;
160 + LIBBASE->SDL_MouseMaxY = 0;
161 + LIBBASE->SDL_ButtonState = 0;
163 + LIBBASE->SDL_TranslateUNICODE = 0;
165 + LIBBASE->SDL_cursorstate = CURSOR_VISIBLE;
166 + LIBBASE->SDL_cursor = NULL;
167 + LIBBASE->SDL_defcursor = NULL;
168 + LIBBASE->SDL_cursorlock = NULL;
169 + LIBBASE->palette_changed = 1;
171 + LIBBASE->GLBase = NULL;
173 + LIBBASE->SDL_cdinitted = 0;
175 + LIBBASE->_lib.lib_OpenCnt++;
180 +static int GM_UNIQUENAME(LibClose)(LIBBASETYPEPTR LIBBASE)
182 + D(bug("SDL.library->Close(%p)\n", LIBBASE));
184 + if (LIBBASE->_lib.lib_OpenCnt-- > 0)
186 + D(bug("SDL.library->Close: %u threads still runing\n", LIBBASE->_lib.lib_OpenCnt));
187 + LIBBASE->_lib.lib_Flags |= LIBF_DELEXP;
191 + if (LIBBASE->current_video && LIBBASE->current_video->gl_config.driver_loaded)
193 + if (LIBBASE->GLBase != NULL)
195 + CGX_GL_DestroyContext(LIBBASE->current_video);
196 + CloseLibrary(LIBBASE->GLBase);
200 + if (LIBBASE->GLBase != NULL)
201 + LIBBASE->GLBase = NULL;
206 +ADD2INITLIB(GM_UNIQUENAME(LibInit), 0)
207 +ADD2OPENLIB(GM_UNIQUENAME(LibOpen), 0)
208 +ADD2CLOSELIB(GM_UNIQUENAME(LibClose), 0)
213 +/* TODO: Should we emulate sigaction() ? */
214 +int sigaction (int signum, const struct sigaction *act, struct sigaction *oldact)
216 + errno=ENOSYS; return -1;
219 +/* Bind StdCBase to PosicCBase */
220 +#include <aros/symbolsets.h>
221 +#include <proto/stdc.h>
222 +#include <libraries/posixc.h>
224 +static int __posixc_startup(void)
226 + struct PosixCBase *PosixCBase = __aros_getbase_PosixCBase();
228 + PosixCBase->StdCBase = __aros_getbase_StdCBase();
230 + return PosixCBase->StdCBase != NULL;
233 +ADD2OPENLIB(__posixc_startup, -50);
234 diff -Naur SDL-1.2.15-orig/include/SDL_active.h SDL-1.2.15/include/SDL_active.h
235 --- SDL-1.2.15-orig/include/SDL_active.h 2015-05-09 17:47:54.271774326 +0200
236 +++ SDL-1.2.15/include/SDL_active.h 2015-05-09 15:09:59.750739542 +0200
238 * SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to
239 * see your application, otherwise it has been iconified or disabled.
241 +#if !defined(PROTO_SDL_H)
242 extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void);
244 +#endif /* !PROTO_SDL_H */
246 /* Ends C function definitions when using C++ */
248 diff -Naur SDL-1.2.15-orig/include/SDL_audio.h SDL-1.2.15/include/SDL_audio.h
249 --- SDL-1.2.15-orig/include/SDL_audio.h 2015-05-09 17:47:54.271774326 +0200
250 +++ SDL-1.2.15/include/SDL_audio.h 2015-05-09 15:09:59.750739542 +0200
252 * Once the callback returns, the buffer will no longer be valid.
253 * Stereo samples are stored in a LRLRLR ordering.
255 +#if !defined(PROTO_SDL_H)
256 void (SDLCALL *callback)(void *userdata, Uint8 *stream, int len);
258 + void (SDLCALL *callback)(void *userdata, Uint8 *stream, int len, struct Library *SDLBase);
264 int len_cvt; /**< Length of converted audio buffer */
265 int len_mult; /**< buffer must be len*len_mult big */
266 double len_ratio; /**< Given len, final size is len*len_ratio */
267 +#if !defined(PROTO_SDL_H)
268 void (SDLCALL *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
270 + void (SDLCALL *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase);
272 int filter_index; /**< Current audio conversion function */
276 * You should normally use SDL_Init() or SDL_InitSubSystem().
279 +#if !defined(PROTO_SDL_H)
280 extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name);
281 extern DECLSPEC void SDLCALL SDL_AudioQuit(void);
286 extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained);
287 +#endif /* !PROTO_SDL_H */
290 SDL_AUDIO_STOPPED = 0,
294 /** Get the current audio state */
295 +#if !defined(PROTO_SDL_H)
296 extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus(void);
300 * corrupt. Currently raw and MS-ADPCM WAVE files are supported.
302 extern DECLSPEC SDL_AudioSpec * SDLCALL SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
303 +#endif /* !PROTO_SDL_H */
305 /** Compatibility convenience function -- loads a WAV from a file */
306 #define SDL_LoadWAV(file, spec, audio_buf, audio_len) \
309 * This function frees data previously allocated with SDL_LoadWAV_RW()
311 +#if !defined(PROTO_SDL_H)
312 extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 *audio_buf);
316 * SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long.
318 extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT *cvt);
320 +#endif /* !PROTO_SDL_H */
322 #define SDL_MIX_MAXVOLUME 128
325 * for full audio volume. Note this does not change hardware volume.
326 * This is provided for convenience -- you can mix your own audio data.
328 +#if !defined(PROTO_SDL_H)
329 extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume);
333 * This function shuts down audio processing and closes the audio device.
335 extern DECLSPEC void SDLCALL SDL_CloseAudio(void);
337 +#endif /* !PROTO_SDL_H */
339 /* Ends C function definitions when using C++ */
341 diff -Naur SDL-1.2.15-orig/include/SDL_cdrom.h SDL-1.2.15/include/SDL_cdrom.h
342 --- SDL-1.2.15-orig/include/SDL_cdrom.h 2015-05-09 17:47:54.271774326 +0200
343 +++ SDL-1.2.15/include/SDL_cdrom.h 2015-05-09 15:09:59.750739542 +0200
345 * Returns the number of CD-ROM drives on the system, or -1 if
346 * SDL_Init() has not been called with the SDL_INIT_CDROM flag.
348 +#if !defined(PROTO_SDL_H)
349 extern DECLSPEC int SDLCALL SDL_CDNumDrives(void);
354 /** Closes the handle for the CD-ROM drive */
355 extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD *cdrom);
357 +#endif /* !PROTO_SDL_H */
359 /* Ends C function definitions when using C++ */
361 diff -Naur SDL-1.2.15-orig/include/SDL_config_aros.h SDL-1.2.15/include/SDL_config_aros.h
362 --- SDL-1.2.15-orig/include/SDL_config_aros.h 1970-01-01 01:00:00.000000000 +0100
363 +++ SDL-1.2.15/include/SDL_config_aros.h 2015-05-09 15:09:59.750739542 +0200
366 + SDL - Simple DirectMedia Layer
367 + Copyright (C) 1997-2012 Sam Lantinga
369 + This library is free software; you can redistribute it and/or
370 + modify it under the terms of the GNU Lesser General Public
371 + License as published by the Free Software Foundation; either
372 + version 2.1 of the License, or (at your option) any later version.
374 + This library is distributed in the hope that it will be useful,
375 + but WITHOUT ANY WARRANTY; without even the implied warranty of
376 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
377 + Lesser General Public License for more details.
379 + You should have received a copy of the GNU Lesser General Public
380 + License along with this library; if not, write to the Free Software
381 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
387 +#ifndef _SDL_config_aros_h
388 +#define _SDL_config_aros_h
390 +#include "SDL_platform.h"
392 +/* This is the minimal configuration that can be used to build SDL */
393 +#include <aros/cpu.h>
394 +#include <dos/dos.h>
396 +#define SDL_HAS_64BIT_TYPE 1
400 +#define SDL_BYTEORDER 4321
402 +#define SDL_BYTEORDER 1234
406 +/* Comment this if you want to build without any C library requirements */
410 +/* Useful headers */
411 +#define HAVE_ALLOCA_H 1
412 +#define HAVE_SYS_TYPES_H 1
413 +#define HAVE_STDIO_H 1
414 +#define STDC_HEADERS 1
415 +#ifndef HAVE_STDLIB_H
416 +#define HAVE_STDLIB_H 1
418 +#define HAVE_STDARG_H 1
420 +#define HAVE_MEMORY_H 1
421 +#define HAVE_STRING_H 1
422 +#define HAVE_STRINGS_H 1
423 +#define HAVE_INTTYPES_H 1
424 +#define HAVE_STDINT_H 1
425 +#define HAVE_CTYPE_H 1
426 +#define HAVE_MATH_H 1
427 +#define HAVE_ICONV_H 1
428 +#define HAVE_SIGNAL_H 1
430 +/* C library functions */
431 +#define HAVE_MALLOC 1
432 +#define HAVE_CALLOC 1
433 +#define HAVE_REALLOC 1
435 +#define HAVE_ALLOCA 1
437 +#define HAVE_GETENV 1
438 +#define HAVE_PUTENV 1
439 +#define HAVE_UNSETENV 1
441 +#define HAVE_QSORT 1
443 +#define HAVE_BCOPY 1
444 +#define HAVE_MEMSET 1
445 +#define HAVE_MEMCPY 1
446 +#define HAVE_MEMMOVE 1
447 +#define HAVE_MEMCMP 1
448 +#define HAVE_STRLEN 1
449 +#define HAVE_STRLCPY 1
450 +#define HAVE_STRLCAT 1
451 +#define HAVE_STRDUP 1
452 +#define HAVE_STRCHR 1
453 +#define HAVE_STRRCHR 1
454 +#define HAVE_STRSTR 1
455 +#define HAVE_STRTOL 1
456 +#define HAVE_STRTOUL 1
457 +#define HAVE_STRTOLL 1
458 +#define HAVE_STRTOULL 1
459 +#define HAVE_STRTOD 1
462 +#define HAVE_STRCMP 1
463 +#define HAVE_STRNCMP 1
464 +#define HAVE_STRCASECMP 1
465 +#define HAVE_STRNCASECMP 1
466 +#define HAVE_SSCANF 1
467 +#define HAVE_SNPRINTF 1
468 +#define HAVE_VSNPRINTF 1
469 +#define HAVE_ICONV 1
470 +#define HAVE_SIGACTION 1
471 +#define HAVE_SETJMP 1
472 +#define HAVE_OPENGL 1
475 +/* We may need some replacement for stdarg.h here */
477 +#endif /* HAVE_LIBC */
479 +/* Allow disabling of core subsystems */
480 +#define SDL_LOADSO_DISABLED 1
482 +/* Enable various audio drivers */
483 +#define SDL_AUDIO_DRIVER_DISK 1
484 +#define SDL_AUDIO_DRIVER_DUMMY 1
485 +#define SDL_AUDIO_DRIVER_AHI 1
487 +/* Enable various cdrom drivers */
488 +#define SDL_CDROM_AROS 1
490 +/* Enable various input drivers */
491 +#define SDL_JOYSTICK_AROS 1
493 +/* Enable various shared object loading systems */
495 +/* Enable various threading systems */
496 +#define SDL_THREAD_AROS 1
498 +/* Enable various timer systems */
499 +#define SDL_TIMER_AROS 1
501 +/* Enable various video drivers */
502 +#define SDL_VIDEO_DRIVER_DUMMY 1
503 +#define SDL_VIDEO_DRIVER_CGX 1
505 +/* Enable OpenGL support */
506 +#define SDL_VIDEO_OPENGL 1
508 +/* Disable screensaver */
509 +#define SDL_VIDEO_DISABLE_SCREENSAVER 1
511 +/* Enable assembly routines */
512 +#define SDL_ASSEMBLY_ROUTINES 1
514 +//#define AMIGADEBUG 1
516 +#endif /* _SDL_config_aros_h */
517 diff -Naur SDL-1.2.15-orig/include/SDL_config.h SDL-1.2.15/include/SDL_config.h
518 --- SDL-1.2.15-orig/include/SDL_config.h 2015-05-09 17:47:54.271774326 +0200
519 +++ SDL-1.2.15/include/SDL_config.h 2015-05-09 15:09:59.750739542 +0200
521 #include "SDL_platform.h"
523 /* Add any platform that doesn't build using the configure system */
524 -#if defined(__DREAMCAST__)
525 +#if defined(__AROS__)
526 +#include "SDL_config_aros.h"
527 +#elif defined(__DREAMCAST__)
528 #include "SDL_config_dreamcast.h"
529 #elif defined(__MACOS__)
530 #include "SDL_config_macos.h"
531 diff -Naur SDL-1.2.15-orig/include/SDL_cpuinfo.h SDL-1.2.15/include/SDL_cpuinfo.h
532 --- SDL-1.2.15-orig/include/SDL_cpuinfo.h 2015-05-09 17:47:54.271774326 +0200
533 +++ SDL-1.2.15/include/SDL_cpuinfo.h 2015-05-09 15:09:59.750739542 +0200
538 +#if !defined(PROTO_SDL_H)
539 /** This function returns true if the CPU has the RDTSC instruction */
540 extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
544 /** This function returns true if the CPU has AltiVec features */
545 extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
546 +#endif /* !PROTO_SDL_H */
548 /* Ends C function definitions when using C++ */
550 diff -Naur SDL-1.2.15-orig/include/SDL_error.h SDL-1.2.15/include/SDL_error.h
551 --- SDL-1.2.15-orig/include/SDL_error.h 2015-05-09 17:47:54.271774326 +0200
552 +++ SDL-1.2.15/include/SDL_error.h 2015-05-09 15:09:59.750739542 +0200
554 * @name Public functions
557 +#if !defined(PROTO_SDL_H)
558 +#if defined(__AROS__)
559 +#include <aros/preprocessor/variadic/cast2iptr.hpp>
561 +extern DECLSPEC void SDLCALL SDL_SetErrorA(const char *fmt, CONST IPTR *params);
563 +#define SDL_SetError(arg1, ...) \
565 + IPTR __args[] = { AROS_PP_VARIADIC_CAST2IPTR(__VA_ARGS__) }; \
566 + SDL_SetErrorA((arg1), __args); \
569 extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...);
571 extern DECLSPEC char * SDLCALL SDL_GetError(void);
572 extern DECLSPEC void SDLCALL SDL_ClearError(void);
573 +#endif /* !PROTO_SDL_H */
579 #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM)
580 #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED)
590 +#if !defined(PROTO_SDL_H)
591 extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code);
592 +#endif /* !PROTO_SDL_H */
595 /* Ends C function definitions when using C++ */
596 diff -Naur SDL-1.2.15-orig/include/SDL_events.h SDL-1.2.15/include/SDL_events.h
597 --- SDL-1.2.15-orig/include/SDL_events.h 2015-05-09 17:47:54.271774326 +0200
598 +++ SDL-1.2.15/include/SDL_events.h 2015-05-09 15:09:59.750739542 +0200
600 * This function updates the event queue and internal input device state.
601 * This should only be run in the thread that sets the video mode.
603 +#if !defined(PROTO_SDL_H)
604 extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
605 +#endif /* !PROTO_SDL_H */
611 * This function is thread-safe.
613 +#if !defined(PROTO_SDL_H)
614 extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents,
615 SDL_eventaction action, Uint32 mask);
618 * or there was some other error.
620 extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event);
622 +#endif /* !PROTO_SDL_H */
623 /** @name Event Filtering */
625 typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event);
627 * If the quit event is generated by an interrupt signal, it will bypass the
628 * internal queue and be delivered to the application at the next event poll.
630 +#if !defined(PROTO_SDL_H)
631 extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter);
635 * If there is no event filter set, this function returns NULL.
637 extern DECLSPEC SDL_EventFilter SDLCALL SDL_GetEventFilter(void);
638 +#endif /* !PROTO_SDL_H */
641 /** @name Event State */
643 * If 'state' is set to SDL_QUERY, SDL_EventState() will return the
644 * current processing state of the specified event.
646 +#if !defined(PROTO_SDL_H)
647 extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state);
648 +#endif /* !PROTO_SDL_H */
650 /* Ends C function definitions when using C++ */
652 diff -Naur SDL-1.2.15-orig/include/SDL_joystick.h SDL-1.2.15/include/SDL_joystick.h
653 --- SDL-1.2.15-orig/include/SDL_joystick.h 2015-05-09 17:47:54.271774326 +0200
654 +++ SDL-1.2.15/include/SDL_joystick.h 2015-05-09 15:09:59.751739540 +0200
657 * Count the number of joysticks attached to the system
659 +#if !defined(PROTO_SDL_H)
660 extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
664 * @return The state is a value ranging from -32768 to 32767.
666 extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis);
668 +#endif /* !PROTO_SDL_H */
670 * @name Hat Positions
671 * The return value of SDL_JoystickGetHat() is one of the following positions:
674 * @param[in] hat The hat indices start at index 0.
676 +#if !defined(PROTO_SDL_H)
677 extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, int hat);
681 * Close a joystick previously opened with SDL_JoystickOpen()
683 extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick);
685 +#endif /* !PROTO_SDL_H */
687 /* Ends C function definitions when using C++ */
689 diff -Naur SDL-1.2.15-orig/include/SDL_keyboard.h SDL-1.2.15/include/SDL_keyboard.h
690 --- SDL-1.2.15-orig/include/SDL_keyboard.h 2015-05-09 17:47:54.271774326 +0200
691 +++ SDL-1.2.15/include/SDL_keyboard.h 2015-05-09 15:09:59.751739540 +0200
694 * @return It returns the previous state of keyboard translation.
696 +#if !defined(PROTO_SDL_H)
697 extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
698 +#endif /* !PROTO_SDL_H */
700 #define SDL_DEFAULT_REPEAT_DELAY 500
701 #define SDL_DEFAULT_REPEAT_INTERVAL 30
704 * If 'delay' is set to 0, keyboard repeat is disabled.
706 + #if !defined(PROTO_SDL_H)
707 extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
708 extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
711 * Get the name of an SDL virtual keysym
713 extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key);
715 +#endif /* !PROTO_SDL_H */
717 /* Ends C function definitions when using C++ */
719 diff -Naur SDL-1.2.15-orig/include/SDL_loadso.h SDL-1.2.15/include/SDL_loadso.h
720 --- SDL-1.2.15-orig/include/SDL_loadso.h 2015-05-09 17:47:54.271774326 +0200
721 +++ SDL-1.2.15/include/SDL_loadso.h 2015-05-09 15:09:59.751739540 +0200
723 * to the object handle (or NULL if there was an error).
724 * The 'sofile' parameter is a system dependent name of the object file.
726 + #if !defined(PROTO_SDL_H)
727 extern DECLSPEC void * SDLCALL SDL_LoadObject(const char *sofile);
732 /** Unload a shared object from memory */
733 extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle);
734 +#endif /* !PROTO_SDL_H */
736 /* Ends C function definitions when using C++ */
738 diff -Naur SDL-1.2.15-orig/include/SDL_main.h SDL-1.2.15/include/SDL_main.h
739 --- SDL-1.2.15-orig/include/SDL_main.h 2015-05-09 17:47:54.271774326 +0200
740 +++ SDL-1.2.15/include/SDL_main.h 2015-05-09 15:09:59.751739540 +0200
745 +#if !defined(PROTO_SDL_H)
746 /** This should be called from your WinMain() function, if any */
747 extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst);
748 /** This can also be called, but is no longer necessary */
749 extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst);
750 /** This can also be called, but is no longer necessary (SDL_Quit calls it) */
751 extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
752 +#endif /* !PROTO_SDL_H */
760 +#if !defined(PROTO_SDL_H)
761 /** Forward declaration so we don't need to include QuickDraw.h */
764 /** This should be called from your main() function, if any */
765 extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd);
766 +#endif /* !PROTO_SDL_H */
770 diff -Naur SDL-1.2.15-orig/include/SDL_mouse.h SDL-1.2.15/include/SDL_mouse.h
771 --- SDL-1.2.15-orig/include/SDL_mouse.h 2015-05-09 17:47:54.271774326 +0200
772 +++ SDL-1.2.15/include/SDL_mouse.h 2015-05-09 15:09:59.751739540 +0200
774 * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
775 * current mouse cursor position. You can pass NULL for either x or y.
777 +#if !defined(PROTO_SDL_H)
778 extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);
782 * state by passing a 'toggle' value of -1.
784 extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
785 +#endif /* !PROTO_SDL_H */
788 /** Used as a mask when testing buttons in buttonstate
789 diff -Naur SDL-1.2.15-orig/include/SDL_mutex.h SDL-1.2.15/include/SDL_mutex.h
790 --- SDL-1.2.15-orig/include/SDL_mutex.h 2015-05-09 17:47:54.271774326 +0200
791 +++ SDL-1.2.15/include/SDL_mutex.h 2015-05-09 15:09:59.751739540 +0200
793 typedef struct SDL_mutex SDL_mutex;
795 /** Create a mutex, initialized unlocked */
796 +#if !defined(PROTO_SDL_H)
797 extern DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void);
798 +#endif /* !PROTO_SDL_H */
800 #define SDL_LockMutex(m) SDL_mutexP(m)
802 * @return 0, or -1 on error
804 +#if !defined(PROTO_SDL_H)
805 extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex *mutex);
806 +#endif /* !PROTO_SDL_H */
808 #define SDL_UnlockMutex(m) SDL_mutexV(m)
811 * It is an error to unlock a mutex that has not been locked by
812 * the current thread, and doing so results in undefined behavior.
814 +#if !defined(PROTO_SDL_H)
815 extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex *mutex);
817 /** Destroy a mutex */
818 extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex);
819 +#endif /* !PROTO_SDL_H */
823 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
824 /** @name Semaphore functions */ /*@{*/
825 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
827 /** The SDL semaphore structure, defined in SDL_sem.c */
828 struct SDL_semaphore;
829 typedef struct SDL_semaphore SDL_sem;
831 +#if !defined(PROTO_SDL_H)
832 /** Create a semaphore, initialized with value, returns NULL on failure. */
833 extern DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
837 /** Returns the current count of the semaphore */
838 extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem);
840 +#endif /* !PROTO_SDL_H */
843 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
845 typedef struct SDL_cond SDL_cond;
848 +#if !defined(PROTO_SDL_H)
849 /** Create a condition variable */
850 extern DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void);
853 * of 1 ms, and so should be avoided if possible.
855 extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms);
857 +#endif /* !PROTO_SDL_H */
860 /* Ends C function definitions when using C++ */
861 diff -Naur SDL-1.2.15-orig/include/SDL_rwops.h SDL-1.2.15/include/SDL_rwops.h
862 --- SDL-1.2.15-orig/include/SDL_rwops.h 2015-05-09 17:47:54.271774326 +0200
863 +++ SDL-1.2.15/include/SDL_rwops.h 2015-05-09 15:09:59.751739540 +0200
866 /** Close and free an allocated SDL_FSops structure */
867 int (SDLCALL *close)(struct SDL_RWops *context);
871 #if defined(__WIN32__) && !defined(__SYMBIAN32__)
877 +#if defined(__AROS__)
878 + struct Library *SDLLib;
883 /** @name Functions to create SDL_RWops structures from various data sources */
886 +#if !defined(PROTO_SDL_H)
887 extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode);
892 extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void);
893 extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area);
895 +#endif /* !PROTO_SDL_H */
898 /** @name Seek Reference Points */
899 @@ -124,10 +126,12 @@
900 #define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n)
901 #define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n)
902 #define SDL_RWclose(ctx) (ctx)->close(ctx)
906 /** @name Read an item of the specified endianness and return in native format */
908 +#if !defined(PROTO_SDL_H)
909 extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src);
910 extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src);
911 extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src);
913 extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value);
914 extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value);
915 extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value);
916 +#endif /* !PROTO_SDL_H */
919 /* Ends C function definitions when using C++ */
920 diff -Naur SDL-1.2.15-orig/include/SDL_syswm.h SDL-1.2.15/include/SDL_syswm.h
921 --- SDL-1.2.15-orig/include/SDL_syswm.h 2015-05-09 17:47:54.271774326 +0200
922 +++ SDL-1.2.15/include/SDL_syswm.h 2015-05-09 15:09:59.751739540 +0200
924 * if ( SDL_GetWMInfo(&info) ) { ... }
927 +#if !defined(PROTO_SDL_H)
928 extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info);
930 +#endif /* !PROTO_SDL_H */
932 /* Ends C function definitions when using C++ */
934 diff -Naur SDL-1.2.15-orig/include/SDL_thread.h SDL-1.2.15/include/SDL_thread.h
935 --- SDL-1.2.15-orig/include/SDL_thread.h 2015-05-09 17:47:54.271774326 +0200
936 +++ SDL-1.2.15/include/SDL_thread.h 2015-05-09 15:09:59.752739538 +0200
938 typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
941 +#if !defined(PROTO_SDL_H)
942 extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread);
943 +#endif /* !PROTO_SDL_H */
946 #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread)
948 #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex)
951 +#if !defined(PROTO_SDL_H)
952 extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data);
953 +#endif /* !PROTO_SDL_H */
956 /** Get the 32-bit thread identifier for the current thread */
957 +#if !defined(PROTO_SDL_H)
958 extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void);
960 /** Get the 32-bit thread identifier for the specified thread,
963 /** Forcefully kill a thread without worrying about its state */
964 extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread *thread);
966 +#endif /* !PROTO_SDL_H */
968 /* Ends C function definitions when using C++ */
970 diff -Naur SDL-1.2.15-orig/include/SDL_timer.h SDL-1.2.15/include/SDL_timer.h
971 --- SDL-1.2.15-orig/include/SDL_timer.h 2015-05-09 17:47:54.271774326 +0200
972 +++ SDL-1.2.15/include/SDL_timer.h 2015-05-09 15:09:59.752739538 +0200
974 * Get the number of milliseconds since the SDL library initialization.
975 * Note that this value wraps if the program runs for more than ~49 days.
977 +#if !defined(PROTO_SDL_H)
978 extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void);
980 /** Wait a specified number of milliseconds before returning */
981 extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms);
982 +#endif /* !PROTO_SDL_H */
984 /** Function prototype for the timer callback function */
985 typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval);
988 * This function returns 0 if successful, or -1 if there was an error.
990 +#if !defined(PROTO_SDL_H)
991 extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback);
992 +#endif /* !PROTO_SDL_H */
994 /** @name New timer API
995 * New timer API, supports multiple timers
997 /** Add a new timer to the pool of timers already running.
998 * Returns a timer ID, or NULL when an error occurs.
1000 +#if !defined(PROTO_SDL_H)
1001 extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param);
1005 * Returns a boolean value indicating success.
1007 extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t);
1009 +#endif /* !PROTO_SDL_H */
1012 /* Ends C function definitions when using C++ */
1013 diff -Naur SDL-1.2.15-orig/include/SDL_version.h SDL-1.2.15/include/SDL_version.h
1014 --- SDL-1.2.15-orig/include/SDL_version.h 2015-05-09 17:47:54.271774326 +0200
1015 +++ SDL-1.2.15/include/SDL_version.h 2015-05-09 15:09:59.752739538 +0200
1017 * it should NOT be used to fill a version structure, instead you should
1018 * use the SDL_Version() macro.
1020 +#if !defined(PROTO_SDL_H)
1021 extern DECLSPEC const SDL_version * SDLCALL SDL_Linked_Version(void);
1022 +#endif /* !PROTO_SDL_H */
1024 /* Ends C function definitions when using C++ */
1026 diff -Naur SDL-1.2.15-orig/include/SDL_video.h SDL-1.2.15/include/SDL_video.h
1027 --- SDL-1.2.15-orig/include/SDL_video.h 2015-05-09 17:47:54.271774326 +0200
1028 +++ SDL-1.2.15/include/SDL_video.h 2015-05-09 15:09:59.752739538 +0200
1031 /** Reference count -- used when freeing surface */
1032 int refcount; /**< Read-mostly */
1033 +#if defined(__AROS__)
1034 + struct Library *SDLLib;
1038 /** @name SDL_Surface Flags
1040 typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect,
1041 struct SDL_Surface *dst, SDL_Rect *dstrect);
1044 /** Useful for determining the video hardware capabilities */
1045 typedef struct SDL_VideoInfo {
1046 Uint32 hw_available :1; /**< Flag: Can you create hardware surfaces? */
1048 * SDL_Init() before opening the sound device, otherwise under Win32 DirectX,
1049 * you won't be able to set full-screen display modes.
1051 +#if !defined(PROTO_SDL_H)
1052 extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name, Uint32 flags);
1053 extern DECLSPEC void SDLCALL SDL_VideoQuit(void);
1055 @@ -513,9 +516,12 @@
1056 extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
1057 const SDL_PixelFormat * const fmt,
1058 Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
1059 +#endif /* ! PROTO_SDL_H */
1061 /** @sa SDL_CreateRGBSurface */
1062 #define SDL_AllocSurface SDL_CreateRGBSurface
1064 +#if !defined(PROTO_SDL_H)
1066 * Allocate and free an RGB surface (must be called after SDL_SetVideoMode)
1067 * If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
1068 @@ -586,11 +592,14 @@
1069 * Returns the new surface, or NULL if there was an error.
1070 * The new surface should be freed with SDL_FreeSurface().
1073 extern DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP_RW(SDL_RWops *src, int freesrc);
1074 +#endif /* ! PROTO_SDL_H */
1076 /** Convenience macro -- load a surface from a file */
1077 #define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
1079 +#if !defined(PROTO_SDL_H)
1081 * Save a surface to a seekable SDL data source (memory or file.)
1082 * If 'freedst' is non-zero, the source will be closed after being written.
1083 @@ -598,11 +607,12 @@
1085 extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
1086 (SDL_Surface *surface, SDL_RWops *dst, int freedst);
1088 +#endif /* ! PROTO_SDL_H */
1089 /** Convenience macro -- save a surface to a file */
1090 #define SDL_SaveBMP(surface, file) \
1091 SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
1093 +#if !defined(PROTO_SDL_H)
1095 * Sets the color key (transparent pixel) in a blittable surface.
1096 * If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL),
1097 @@ -740,8 +750,10 @@
1098 * You should call SDL_BlitSurface() unless you know exactly how SDL
1099 * blitting works internally and how to use the other blit functions.
1101 + #endif /* ! PROTO_SDL_H */
1102 #define SDL_BlitSurface SDL_UpperBlit
1104 +#if !defined(PROTO_SDL_H)
1105 /** This is the public blit function, SDL_BlitSurface(), and it performs
1106 * rectangle validation and clipping before passing it to SDL_LowerBlit()
1108 @@ -920,12 +932,16 @@
1110 extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface *surface);
1112 +#endif /* ! PROTO_SDL_H */
1115 SDL_GRAB_QUERY = -1,
1118 SDL_GRAB_FULLSCREEN /**< Used internally */
1121 +#if !defined(PROTO_SDL_H)
1123 * This function allows you to set and query the input grab state of
1124 * the application. It returns the new input grab state.
1126 /** @internal Not in public API at the moment - do not use! */
1127 extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect,
1128 SDL_Surface *dst, SDL_Rect *dstrect);
1131 +#endif /* ! PROTO_SDL_H */
1133 /* Ends C function definitions when using C++ */
1136 diff -Naur SDL-1.2.15-orig/SDL.conf SDL-1.2.15/SDL.conf
1137 --- SDL-1.2.15-orig/SDL.conf 1970-01-01 01:00:00.000000000 +0100
1138 +++ SDL-1.2.15/SDL.conf 2015-05-09 15:09:59.752739538 +0200
1143 +libbasetype struct SDLBase
1144 +rootbase_field rootSDLBase
1147 +copyright Copyright (C) 2013-216 The AROS Development Team, 1997-2012 Sam Lantinga
1148 +options peropenerbase
1153 +##begin cdefprivate
1154 +#include "SDL_intern.h"
1159 +#include <SDL/SDL.h>
1162 +#include <SDL/SDL_active.h>
1163 +#include <SDL/SDL_audio.h>
1164 +#include <SDL/SDL_byteorder.h>
1165 +#include <SDL/SDL_cdrom.h>
1166 +#include <SDL/SDL_copying.h>
1167 +#include <SDL/SDL_cpuinfo.h>
1168 +#include <SDL/SDL_endian.h>
1169 +#include <SDL/SDL_error.h>
1170 +#include <SDL/SDL_events.h>
1171 +#include <SDL/SDL_getenv.h>
1172 +#include <SDL/SDL_joystick.h>
1173 +#include <SDL/SDL_keyboard.h>
1174 +#include <SDL/SDL_keysym.h>
1175 +#include <SDL/SDL_loadso.h>
1176 +#include <SDL/SDL_main.h>
1177 +#include <SDL/SDL_mouse.h>
1178 +#include <SDL/SDL_mutex.h>
1179 +#include <SDL/SDL_name.h>
1180 +#include <SDL/SDL_quit.h>
1181 +#include <SDL/SDL_rwops.h>
1182 +#include <SDL/SDL_syswm.h>
1183 +#include <SDL/SDL_thread.h>
1184 +#include <SDL/SDL_timer.h>
1185 +#include <SDL/SDL_types.h>
1186 +#include <SDL/SDL_version.h>
1187 +#include <SDL/SDL_video.h>
1191 +##begin functionlist
1193 +int SDL_Init(Uint32 flags) (D0)
1194 +const SDL_version * SDL_Linked_Version() ()
1195 +Uint32 SDL_WasInit(Uint32 flags) (D0)
1197 +int SDL_InitSubSystem(Uint32 flags) (D0)
1198 +void SDL_QuitSubSystem(Uint32 flags) (D0)
1199 +SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) (A0, A1)
1200 +SDL_RWops * SDL_RWFromFP(FILE *fp, int autoclose) (A0, D0)
1201 +SDL_RWops * SDL_RWFromMem(void *mem, int size) (A0, D0)
1202 +SDL_RWops * SDL_AllocRW() ()
1203 +void SDL_FreeRW(SDL_RWops *area) (A0)
1204 +SDL_Surface * SDL_LoadBMP_RW(SDL_RWops *src, int freesrc) (A0, D0)
1205 +SDL_Surface * SDL_DisplayFormat(SDL_Surface *surface) (A0)
1206 +void SDL_FreeSurface(SDL_Surface *surface) (A0)
1207 +int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) (A0, A1, D0)
1208 +int SDL_UpperBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) (A0, A1, A2, A3)
1209 +int SDL_LowerBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) (A0, A1, A2, A3)
1210 +int SDL_Flip(SDL_Surface *screen) (A0)
1211 +void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects) (A0, D0, A1)
1212 +void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) (A0, D0, D1, D2, D3)
1213 +SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) (D0, D1, D2, D3)
1214 +Uint32 SDL_MapRGB(SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b) (A0, D0, D1, D2)
1215 +Uint32 SDL_MapRGBA(SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uint8 a) (A0, D0, D1, D2, D3)
1217 +int SDL_VideoInit(const char *driver_name, Uint32 flags) (A0, D0)
1218 +const SDL_VideoInfo * SDL_GetVideoInfo() ()
1219 +char *SDL_VideoDriverName(char *namebuf, int maxlen) (A0, D0)
1220 +void SDL_VideoQuit() ()
1221 +SDL_Surface * SDL_GetVideoSurface() ()
1222 +int SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags) (D0, D1, D2, D3)
1223 +SDL_Rect ** SDL_ListModes(SDL_PixelFormat *format, Uint32 flags) (A0, D0)
1224 +int SDL_SetGamma(float red, float green, float blue) (D0, D1, D2)
1225 +int SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue) (A0, A1, A2)
1226 +int SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue) (A0, A1, A2)
1227 +int SDL_SetColors(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors) (A0, A1, D0, D1)
1228 +int SDL_SetPalette(SDL_Surface *surface, int flags, SDL_Color *colors, int firstcolor, int ncolors) (A0, D0, A1, D1, D2)
1229 +void SDL_GetRGB(Uint32 pix, SDL_PixelFormat *fmt, Uint8 *r, Uint8 *g, Uint8 *b) (D0, A0, A1, A2, A3)
1230 +void SDL_GetRGBA(Uint32 pix, SDL_PixelFormat *fmt, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) (D0, A0, A1, A2, A3, A4)
1232 +SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) (D0, D1, D2, D3, D4, D5, D6, D7)
1233 +SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) (A0, D0, D1, D2, D3, D4, D5, D6, D7)
1234 +int SDL_LockSurface(SDL_Surface *surface) (A0)
1235 +void SDL_UnlockSurface(SDL_Surface *surface) (A0)
1236 +int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst) (A0, A1, D0)
1237 +int SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key) (A0, D0, D1)
1238 +int SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha) (A0, D0, D1)
1239 +SDL_bool SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect) (A0, A1)
1240 +void SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect) (A0, A1)
1241 +SDL_Surface *SDL_ConvertSurface(SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags) (A0, A1, D0)
1242 +SDL_Surface * SDL_DisplayFormatAlpha(SDL_Surface *surface) (A0)
1243 +SDL_Overlay *SDL_CreateYUVOverlay(int width, int height,Uint32 format, SDL_Surface *display) (D0, D1, D2, A0)
1244 +int SDL_LockYUVOverlay(SDL_Overlay *overlay) (A0)
1245 +void SDL_UnlockYUVOverlay(SDL_Overlay *overlay) (A0)
1246 +int SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect) (A0, A1)
1247 +void SDL_FreeYUVOverlay(SDL_Overlay *overlay) (A0)
1248 +int SDL_GL_LoadLibrary(const char *path) (A0)
1249 +void *SDL_GL_GetProcAddress(const char* proc) (A0)
1250 +int SDL_GL_SetAttribute(SDL_GLattr attr, int value) (D0, D1)
1251 +int SDL_GL_GetAttribute(SDL_GLattr attr, int* value) (D0, A0)
1252 +void SDL_GL_SwapBuffers() ()
1253 +void SDL_GL_UpdateRects(int numrects, SDL_Rect* rects) (D0, A0)
1254 +void SDL_GL_Lock() ()
1255 +void SDL_GL_Unlock() ()
1256 +void SDL_WM_SetCaption(const char *title, const char *icon) (A0, A1)
1257 +void SDL_WM_GetCaption(char **title, char **icon) (A0, A1)
1258 +void SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask) (A0, A1)
1259 +int SDL_WM_IconifyWindow() ()
1260 +int SDL_WM_ToggleFullScreen(SDL_Surface *surface) (A0)
1261 +SDL_GrabMode SDL_WM_GrabInput(SDL_GrabMode mode) (D0)
1262 +Uint32 SDL_GetTicks() ()
1263 +void SDL_Delay(Uint32 ms) (D0)
1264 +int SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback) (D0, A0)
1265 +SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param) (D0, A0, A1)
1266 +SDL_bool SDL_RemoveTimer(SDL_TimerID t) (D0)
1267 +void SDL_PumpEvents() ()
1268 +int SDL_PollEvent(SDL_Event *event) (A0)
1269 +int SDL_WaitEvent(SDL_Event *event) (A0)
1270 +int SDL_PeepEvents(SDL_Event *events, int numevents,SDL_eventaction action, Uint32 mask) (A0, D0, D1, D2)
1271 +int SDL_PushEvent(SDL_Event *event) (A0)
1272 +void SDL_SetEventFilter(SDL_EventFilter filter) (D0)
1273 +SDL_EventFilter SDL_GetEventFilter() ()
1274 +Uint8 SDL_EventState(Uint8 type, int state) (D0, D1)
1275 +int SDL_NumJoysticks() ()
1276 +const char *SDL_JoystickName(int device_index) (D0)
1277 +SDL_Joystick *SDL_JoystickOpen(int device_index) (D0)
1278 +int SDL_JoystickOpened(int device_index) (D0)
1279 +int SDL_JoystickIndex(SDL_Joystick *joystick) (A0)
1280 +int SDL_JoystickNumAxes(SDL_Joystick *joystick) (A0)
1281 +int SDL_JoystickNumBalls(SDL_Joystick *joystick) (A0)
1282 +int SDL_JoystickNumHats(SDL_Joystick *joystick) (A0)
1283 +int SDL_JoystickNumButtons(SDL_Joystick *joystick) (A0)
1284 +void SDL_JoystickUpdate() ()
1285 +int SDL_JoystickEventState(int state) (D0)
1286 +Sint16 SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis) (A0, D0)
1287 +Uint8 SDL_JoystickGetHat(SDL_Joystick *joystick, int hat) (A0, D0)
1288 +int SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy) (A0, D0, A1, A2)
1289 +Uint8 SDL_JoystickGetButton(SDL_Joystick *joystick, int button) (A0, D0)
1290 +void SDL_JoystickClose(SDL_Joystick *joystick) (A0)
1291 +int SDL_EnableUNICODE(int enable) (D0)
1292 +int SDL_EnableKeyRepeat(int delay, int interval) (D0, D1)
1293 +Uint8 * SDL_GetKeyState(int *numkeys) (A0)
1294 +SDLMod SDL_GetModState() ()
1295 +void SDL_SetModState(SDLMod modstate) (D0)
1296 +char * SDL_GetKeyName(SDLKey key) (D0)
1297 +Uint8 SDL_GetMouseState(int *x, int *y) (A0, A1)
1298 +Uint8 SDL_GetRelativeMouseState(int *x, int *y) (A0, A1)
1299 +void SDL_WarpMouse(Uint16 x, Uint16 y) (D0, D1)
1300 +SDL_Cursor *SDL_CreateCursor(Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) (A0, A1, D0, D1, D2, D3)
1301 +void SDL_SetCursor(SDL_Cursor *cursor) (A0)
1302 +SDL_Cursor * SDL_GetCursor() ()
1303 +void SDL_FreeCursor(SDL_Cursor *cursor) (A0)
1304 +int SDL_ShowCursor(int toggle) (D0)
1305 +Uint8 SDL_GetAppState() ()
1306 +void SDL_SetErrorA(const char *fmt, CONST IPTR *params) (A0, A1)
1307 +char *SDL_GetError() ()
1308 +void SDL_ClearError() ()
1309 +int SDL_AudioInit(const char *driver_name) (A0)
1310 +char *SDL_AudioDriverName(char *namebuf, int maxlen) (A0, D0)
1311 +void SDL_AudioQuit() ()
1312 +int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained) (A0, D0)
1313 +SDL_audiostatus SDL_GetAudioStatus() ()
1314 +void SDL_PauseAudio(int pause_on) (D0)
1315 +void SDL_Audio_SetCaption(const char *caption) (A0)
1316 +SDL_AudioSpec *SDL_LoadWAV_RW(SDL_RWops *src, int freesrc,SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) (A0, D0, A1, A2, A3)
1317 +void SDL_FreeWAV(Uint8 *audio_buf) (A0)
1318 +int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,Uint16 src_format, Uint8 src_channels, int src_rate,Uint16 dst_format, Uint8 dst_channels, int dst_rate) (A0, D0, D1, D2, D3, D4, D5)
1319 +int SDL_ConvertAudio(SDL_AudioCVT *cvt) (A0)
1320 +void SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume) (A0, A1, D0, D1)
1321 +void SDL_LockAudio() ()
1322 +void SDL_UnlockAudio() ()
1323 +void SDL_CloseAudio() ()
1324 +SDL_Thread * SDL_CreateThread(void *fn, void *data) (A0, A1)
1325 +Uint32 SDL_ThreadID() ()
1326 +Uint32 SDL_GetThreadID(SDL_Thread *thread) (A0)
1327 +void SDL_WaitThread(SDL_Thread *thread, int *status) (A0, A1)
1328 +void SDL_KillThread(SDL_Thread *thread) (A0)
1329 +int SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) (A0, A1, A2, A3)
1330 +int SDL_CDNumDrives() ()
1331 +const char *SDL_CDName(int drive) (D0)
1332 +SDL_CD *SDL_CDOpen(int drive) (D0)
1333 +CDstatus SDL_CDStatus(SDL_CD *cdrom) (A0)
1334 +int SDL_CDPlay(SDL_CD *cdrom, int sframe, int length) (A0, D0, D1)
1335 +int SDL_CDPlayTracks(SDL_CD *cdrom, int strack, int sframe, int ntracks, int nframes) (A0, D0, D1, D2, D3)
1336 +int SDL_CDPause(SDL_CD *cdrom) (A0)
1337 +int SDL_CDResume(SDL_CD *cdrom) (A0)
1338 +int SDL_CDStop(SDL_CD *cdrom) (A0)
1339 +int SDL_CDEject(SDL_CD *cdrom) (A0)
1340 +void SDL_CDClose(SDL_CD *cdrom) (A0)
1341 +SDL_mutex *SDL_CreateMutex() ()
1342 +void SDL_DestroyMutex(SDL_mutex *mutex) (A0)
1343 +int SDL_mutexP(SDL_mutex *mutex) (A0)
1344 +int SDL_mutexV(SDL_mutex *mutex) (A0)
1345 +SDL_sem * SDL_CreateSemaphore(Uint32 initial_value) (D0)
1346 +void SDL_DestroySemaphore(SDL_sem *sem) (A0)
1347 +int SDL_SemTryWait(SDL_sem *sem) (A0)
1348 +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) (A0, D0)
1349 +int SDL_SemWait(SDL_sem *sem) (A0)
1350 +Uint32 SDL_SemValue(SDL_sem *sem) (A0)
1351 +int SDL_SemPost(SDL_sem *sem) (A0)
1352 +void SDL_Error(SDL_errorcode code) (D0)
1353 +SDL_cond * SDL_CreateCond() ()
1354 +void SDL_DestroyCond(SDL_cond *cond) (A0)
1355 +int SDL_CondSignal(SDL_cond *cond) (A0)
1356 +int SDL_CondBroadcast(SDL_cond *cond) (A0)
1357 +int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) (A0, A1, D0)
1358 +int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex) (A0, A1)
1359 +Uint16 SDL_ReadLE16(SDL_RWops *src) (A0)
1360 +Uint16 SDL_ReadBE16(SDL_RWops *src) (A0)
1361 +Uint32 SDL_ReadLE32(SDL_RWops *src) (A0)
1362 +Uint32 SDL_ReadBE32(SDL_RWops *src) (A0)
1363 +Uint64 SDL_ReadLE64(SDL_RWops *src) (A0)
1364 +Uint64 SDL_ReadBE64(SDL_RWops *src) (A0)
1365 +int SDL_WriteLE16(SDL_RWops *dst, Uint16 value) (A0, D0)
1366 +int SDL_WriteBE16(SDL_RWops *dst, Uint16 value) (A0, D0)
1367 +int SDL_WriteLE32(SDL_RWops *dst, Uint32 value) (A0, D0)
1368 +int SDL_WriteBE32(SDL_RWops *dst, Uint32 value) (A0, D0)
1369 +int SDL_WriteLE64(SDL_RWops *dst, Uint64 value) (A0, D0)
1370 +int SDL_WriteBE64(SDL_RWops *dst, Uint64 value) (A0, D0)
1371 +SDL_bool SDL_HasAltiVec() ()
1372 +SDL_bool SDL_HasRDTSC() ()
1373 +SDL_bool SDL_HasMMX() ()
1374 +SDL_bool SDL_Has3DNow() ()
1375 +SDL_bool SDL_HasSSE() ()
1376 +SDL_bool SDL_HasMMXExt() ()
1377 +SDL_bool SDL_Has3DNowExt() ()
1378 +SDL_bool SDL_HasSSE2() ()
1379 +char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft) (A0, A1, A2, D0)
1381 diff -Naur SDL-1.2.15-orig/SDL_intern.h SDL-1.2.15/SDL_intern.h
1382 --- SDL-1.2.15-orig/SDL_intern.h 1970-01-01 01:00:00.000000000 +0100
1383 +++ SDL-1.2.15/SDL_intern.h 2015-05-09 15:09:59.753739536 +0200
1385 +#ifndef _SDL_INTERN_H
1386 +#define _SDL_INTERN_H
1388 +#define PROTO_SDL_H
1390 +#include <exec/libraries.h>
1391 +#include <exec/semaphores.h>
1392 +#include <devices/timer.h>
1395 +#include <SDL/SDL.h>
1398 +#include <SDL/SDL_active.h>
1399 +#include <SDL/SDL_audio.h>
1400 +#include <SDL/SDL_byteorder.h>
1401 +#include <SDL/SDL_cdrom.h>
1402 +#include <SDL/SDL_copying.h>
1403 +#include <SDL/SDL_cpuinfo.h>
1404 +#include <SDL/SDL_endian.h>
1405 +#include <SDL/SDL_error.h>
1406 +#include <SDL/SDL_events.h>
1407 +#include <SDL/SDL_getenv.h>
1408 +#include <SDL/SDL_joystick.h>
1409 +#include <SDL/SDL_keyboard.h>
1410 +#include <SDL/SDL_keysym.h>
1411 +#include <SDL/SDL_loadso.h>
1412 +#include <SDL/SDL_main.h>
1413 +#include <SDL/SDL_mouse.h>
1414 +#include <SDL/SDL_mutex.h>
1415 +#include <SDL/SDL_name.h>
1416 +#include <SDL/SDL_quit.h>
1417 +#include <SDL/SDL_rwops.h>
1418 +#include <SDL/SDL_syswm.h>
1419 +#include <SDL/SDL_thread.h>
1420 +#include <SDL/SDL_timer.h>
1421 +#include <SDL/SDL_types.h>
1422 +#include <SDL/SDL_version.h>
1423 +#include <SDL/SDL_video.h>
1425 +#include "SDL_error_c.h"
1427 +#define MAX_DRIVES 32
1428 +#define CURSOR_VISIBLE 0x01
1430 +struct SDLSizePair {
1435 +struct SDL_AudioDevice;
1436 +struct SDL_VideoDevice;
1440 + struct Library _lib;
1441 + struct SDLBase *rootSDLBase;
1442 + struct Library *LowLevelBase;
1443 + struct Library *GLBase;
1446 + Uint32 SDL_initialized;
1447 + Uint32 ticks_started;
1448 + int surfaces_allocated;
1450 + /**timer/aros/SDL_systimer.c **/
1452 + SDL_Thread *timer_thread;
1453 + struct timerequest *TimerIO;
1455 + struct Device *TimerBase;
1456 + struct timeval basetime;
1457 + struct MsgPort *TimerMP;
1458 + struct Task *OwnerTask;
1461 + /** thread/SDL_thread.c **/
1462 + int SDL_maxthreads;
1463 + int SDL_numthreads;
1464 + SDL_Thread **SDL_Threads;
1465 + struct SignalSemaphore *SDL_ThreadLock;
1467 + /** thread/aros/SDL_thread.c **/
1468 + SDL_error SDL_global_error;
1469 + int SDL_ThreadLockCreated;
1471 + /** events/SDL_active.c **/
1472 + Uint8 SDL_appstate;
1474 + /** events/SDL_events.c **/
1475 + SDL_EventFilter SDL_EventOK;
1476 + Uint8 SDL_ProcessEvents[SDL_NUMEVENTS];
1477 + Uint32 SDL_eventstate;
1478 + SDL_Thread *SDL_EventThread; /* Thread handle */
1479 + Uint32 event_thread; /* The event thread id */
1481 + /** events/SDL_mouse.c **/
1482 + Sint16 SDL_MouseX;
1483 + Sint16 SDL_MouseY;
1484 + Sint16 SDL_DeltaX;
1485 + Sint16 SDL_DeltaY;
1486 + Sint16 SDL_MouseMaxX;
1487 + Sint16 SDL_MouseMaxY;
1488 + Uint8 SDL_ButtonState;
1490 + /** events/SDL_keyboard.c **/
1491 + Uint8 SDL_KeyState[SDLK_LAST];
1492 + SDLMod SDL_ModState;
1493 + int SDL_TranslateUNICODE;
1494 + const char *keynames[SDLK_LAST];
1496 + /** events/SDL_resize.c **/
1497 + struct SDLSizePair last_resize;
1499 + /** audio/SDL_audio.c **/
1500 + Uint32 has_obtained_spec;
1501 + struct SDL_AudioDevice *current_audio;
1503 + int format_idx_sub;
1505 + /** audio/ahi/SDL_ahiaudio.c **/
1506 + Uint32 AHI_Volume;
1508 + /** video/SDL_video.c **/
1509 + struct SDL_VideoDevice *current_video;
1511 + /** video/SDL_cursor.c **/
1512 + volatile int SDL_cursorstate;
1513 + SDL_Cursor *SDL_cursor;
1514 + SDL_Cursor *SDL_defcursor;
1515 + SDL_mutex *SDL_cursorlock;
1516 + int palette_changed;
1519 + /**video/SDL_stretch.c **/
1520 + unsigned char *copy_row_base;
1521 + unsigned char *copy_row;
1523 + /** timers/SDL_timer_c.h **/
1524 + int SDL_timer_started;
1525 + int SDL_timer_running;
1527 + Uint32 SDL_alarm_interval;
1528 + SDL_TimerCallback SDL_alarm_callback;
1530 + int SDL_timer_threaded;
1532 + SDL_TimerID SDL_timers;
1533 + SDL_mutex *SDL_timer_mutex;
1534 + volatile SDL_bool list_changed;
1536 + /** cdrom/SDL_cdrom.c **/
1537 + SDL_CD *default_cdrom;
1538 + int SDL_cdinitted;
1541 + /**cdrom/aros/SDL_syscdrom.c **/
1542 + UBYTE *CDList[MAX_DRIVES];
1546 diff -Naur SDL-1.2.15-orig/src/audio/ahi/SDL_ahiaudio.c SDL-1.2.15/src/audio/ahi/SDL_ahiaudio.c
1547 --- SDL-1.2.15-orig/src/audio/ahi/SDL_ahiaudio.c 1970-01-01 01:00:00.000000000 +0100
1548 +++ SDL-1.2.15/src/audio/ahi/SDL_ahiaudio.c 2015-05-09 15:09:59.753739536 +0200
1551 + SDL - Simple DirectMedia Layer
1552 + Copyright (C) 1997, 1998 Sam Lantinga
1554 + This library is free software; you can redistribute it and/or
1555 + modify it under the terms of the GNU Library General Public
1556 + License as published by the Free Software Foundation; either
1557 + version 2 of the License, or (at your option) any later version.
1559 + This library is distributed in the hope that it will be useful,
1560 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1561 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1562 + Library General Public License for more details.
1564 + You should have received a copy of the GNU Library General Public
1565 + License along with this library; if not, write to the Free
1566 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1569 + 5635-34 Springhouse Dr.
1570 + Pleasanton, CA 94588 (USA)
1571 + slouken@libsdl.org
1574 +#include <proto/exec.h>
1576 +#if defined (SDL_AROS_SHARED)
1577 +#define __NOLIBBASE__
1578 +#include <proto/SDL.h>
1581 +#include "SDL_endian.h"
1582 +#include "SDL_ahiaudio.h"
1583 +#include "SDL_timer.h"
1585 +#include "SDL_cgxasm.h"
1587 +#include <stdlib.h>
1588 +#include "../../main/aros/mydebug.h"
1590 +#if !defined(PROTO_SDL_H)
1591 +extern Uint32 has_obtained_spec;
1592 +static Fixed AHI_Volume;
1594 +/* Audio driver functions */
1595 +static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec);
1596 +static void AHI_ThreadInit(_THIS);
1597 +static void AHI_WaitAudio(_THIS);
1598 +static void AHI_PlayAudio(_THIS);
1599 +static Uint8 *AHI_GetAudioBuf(_THIS);
1600 +static void AHI_CloseAudio(_THIS);
1602 +#include "SDL_intern.h"
1603 +#define has_obtained_spec SDLBase->has_obtained_spec
1604 +#define AHI_Volume SDLBase->AHI_Volume
1606 +/* Audio driver functions */
1607 +static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec, struct SDLBase *SDLBase);
1608 +static void AHI_ThreadInit(_THIS, struct SDLBase *SDLBase);
1609 +static void AHI_WaitAudio(_THIS, struct SDLBase *SDLBase);
1610 +static void AHI_PlayAudio(_THIS, struct SDLBase *SDLBase);
1611 +static Uint8 *AHI_GetAudioBuf(_THIS, struct SDLBase *SDLBase);
1612 +static void AHI_CloseAudio(_THIS, struct SDLBase *SDLBase);
1615 +#if !defined(PROTO_SDL_H)
1616 +/* Internal functions */
1617 +void AHI_Mute(ULONG mute)
1619 +void AHI_Mute(ULONG mute, struct SDLBase *SDLBase)
1622 + AHI_Volume = mute ? 0 : 0x10000;
1625 +/* Audio driver bootstrap functions */
1627 +#if !defined(PROTO_SDL_H)
1628 +static int Audio_Available(void)
1630 +static int Audio_Available(struct SDLBase *SDLBase)
1633 + /* AHI always available */
1638 +#if !defined(PROTO_SDL_H)
1639 +static void Audio_DeleteDevice(SDL_AudioDevice *device)
1641 +static void Audio_DeleteDevice(SDL_AudioDevice *device, struct SDLBase *SDLBase)
1644 + D(bug("[SDL] Audio_DeleteDevice()\n"));
1645 + free(device->hidden);
1649 +#if !defined(PROTO_SDL_H)
1650 +static SDL_AudioDevice *Audio_CreateDevice(int devindex)
1652 +static SDL_AudioDevice *Audio_CreateDevice(int devindex, struct SDLBase *SDLBase)
1655 + struct SDL_PrivateAudioData *hidden;
1656 + SDL_AudioDevice *this;
1658 + D(bug("[SDL] Audio_CreateDevice()\n"));
1660 + /* Initialize all variables that we clean on shutdown */
1661 + this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
1662 + hidden = (struct SDL_PrivateAudioData *)malloc((sizeof *hidden));
1664 + if (this == NULL || hidden == NULL)
1666 + SDL_OutOfMemory();
1677 + memset(this, 0, (sizeof *this));
1678 + memset(hidden, 0, (sizeof *hidden));
1680 + NEWLIST(&hidden->dummy_mp.mp_MsgList);
1681 + hidden->dummy_mp.mp_Node.ln_Type = NT_MSGPORT;
1682 + hidden->dummy_mp.mp_Flags = PA_SIGNAL;
1683 + hidden->dummy_mp.mp_SigBit = SIGB_SINGLE;
1684 + hidden->dummy_mp.mp_SigTask = FindTask(NULL);
1686 + this->hidden = hidden;
1688 + /* Set the function pointers */
1689 + this->OpenAudio = AHI_OpenAudio;
1690 + this->ThreadInit = AHI_ThreadInit;
1691 + this->WaitAudio = AHI_WaitAudio;
1692 + this->PlayAudio = AHI_PlayAudio;
1693 + this->GetAudioBuf = AHI_GetAudioBuf;
1694 + this->CloseAudio = AHI_CloseAudio;
1696 + this->free = Audio_DeleteDevice;
1698 + AHI_Volume = 0x10000;
1703 +AudioBootStrap AHI_bootstrap = {
1705 + "MorphOS ahi.device SDL audio",
1707 + Audio_CreateDevice
1710 +#if !defined(PROTO_SDL_H)
1711 +void static AHI_WaitAudio(_THIS)
1713 +void static AHI_WaitAudio(_THIS, struct SDLBase *SDLBase)
1716 + struct AHIRequest *req;
1718 + D(bug("[SDL] AHI_WaitAudio()\n"));
1720 + req = &this->hidden->audio_req[this->hidden->current_buffer];
1722 + //if (!CheckIO((struct IORequest *)req)
1723 + if (req->ahir_Std.io_Data)
1725 + WaitIO((struct IORequest *)req);
1726 + req->ahir_Std.io_Data = NULL;
1728 + GetMsg(&this->hidden->thread_audio_mp);
1729 + GetMsg(&this->hidden->thread_audio_mp);
1733 +#if !defined(PROTO_SDL_H)
1734 +static void AHI_PlayAudio(_THIS)
1736 +static void AHI_PlayAudio(_THIS, struct SDLBase *SDLBase)
1739 + struct SDL_PrivateAudioData *hidden = this->hidden;
1740 + struct AHIRequest *req;
1742 + ULONG current, current2;
1745 + D(bug("[SDL] AHI_PlayAudio()\n"));
1747 + current = hidden->current_buffer;
1748 + current2 = current ^ 1;
1749 + req = &hidden->audio_req[current];
1751 + /* Write the audio data out */
1753 + mixbufsize = hidden->size; /* Note: this is an audio buffer size in _bytes_ */
1754 + mixbuf = hidden->mixbuf[current];
1756 + req->ahir_Std.io_Data = mixbuf;
1757 + req->ahir_Std.io_Length = mixbufsize;
1758 + req->ahir_Std.io_Offset = 0;
1759 + req->ahir_Std.io_Command = CMD_WRITE;
1760 + req->ahir_Frequency = hidden->freq;
1761 + req->ahir_Volume = AHI_Volume; //0x10000;
1762 + req->ahir_Type = hidden->type;
1763 + req->ahir_Position = 0x8000;
1764 + req->ahir_Link = (hidden->playing ? &hidden->audio_req[current2] : NULL);
1766 + switch (hidden->convert)
1768 + case AHI_CONVERT_8:
1770 + BYTE *buf = mixbuf;
1777 + while (mixbufsize);
1781 + case AHI_CONVERT_16:
1783 + WORD *buf = mixbuf;
1787 + *(buf++) -= 32768;
1790 + while (mixbufsize > 0);
1794 + case AHI_CONVERT_S16LSB:
1796 + copy_and_swap16(mixbuf, mixbuf, mixbufsize / 2);
1799 + case AHI_CONVERT_U16LSB:
1801 + UWORD j, *buf = mixbuf;
1803 + j = hidden->convert == AHI_CONVERT_U16LSB ? 32768 : 0;
1807 + UWORD sample = *buf;
1808 + *buf++ = ((sample >> 8) | (sample << 8)) - j;
1811 + while (mixbufsize > 0);
1816 + SendIO((struct IORequest *)req);
1817 + hidden->current_buffer = current2;
1818 + hidden->playing = 1;
1821 +#if !defined(PROTO_SDL_H)
1822 +static Uint8 *AHI_GetAudioBuf(_THIS)
1824 +static Uint8 *AHI_GetAudioBuf(_THIS, struct SDLBase *SDLBase)
1827 + D(bug("[SDL] AHI_GetAudioBuf()\n"));
1828 + return(this->hidden->mixbuf[this->hidden->current_buffer]);
1831 +#if !defined(PROTO_SDL_H)
1832 +static void AHI_CloseAudio(_THIS)
1834 +static void AHI_CloseAudio(_THIS, struct SDLBase *SDLBase)
1837 + struct SDL_PrivateAudioData *hidden = this->hidden;
1839 + D(bug("[SDL] AHI_CloseAudio()\n"));
1841 + if (hidden->have_ahi)
1843 + CloseDevice((struct IORequest *)&hidden->ctrl_req);
1846 + if (hidden->mixbuf[0])
1847 + FreeMem(hidden->mixbuf[0], hidden->size);
1849 + if (hidden->mixbuf[1])
1850 + FreeMem(hidden->mixbuf[1], hidden->size);
1852 + hidden->mixbuf[0] = NULL;
1853 + hidden->mixbuf[1] = NULL;
1854 + hidden->have_ahi = 0;
1855 + hidden->playing = 0;
1858 +#if !defined(PROTO_SDL_H)
1859 +static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec)
1861 +static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec, struct SDLBase *SDLBase)
1864 + struct SDL_PrivateAudioData *hidden = this->hidden;
1866 + int altivec_align = 0;
1869 + D(bug("[SDL] AHI_OpenAudio()\n"));
1871 + if (spec->channels > 2)
1873 + D(bug("More than 2 channels not currently supported, forcing conversion...\n"));
1874 + spec->channels = 2;
1877 + D(bug("requested samples is %ld\n", spec->samples));
1879 + /* Fiddle with this to find out working combination with games
1881 + * Recommended testing: E-UAE, Bolcatoid
1884 + if (has_obtained_spec && spec->samples > 1024)
1886 + spec->samples = spec->freq / 20;
1888 + if (spec->samples < 256)
1889 + spec->samples = 256;
1891 + D(bug("[SDL] Changed sample count. New count is %ld.\n", spec->samples));
1894 + hidden->convert = AHI_NO_CONVERSION;
1896 + /* Determine the audio parameters from the AudioSpec */
1897 + switch (spec->format)
1900 + hidden->convert = AHI_CONVERT_8;
1902 + hidden->bytespersample = 1;
1903 + hidden->type = spec->channels == 1 ? AHIST_M8S : AHIST_S8S;
1906 + case AUDIO_S16LSB:
1907 + altivec_align = 1;
1908 + hidden->convert = AHI_CONVERT_S16LSB;
1909 + hidden->bytespersample = 2;
1910 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1912 + case AUDIO_U16LSB:
1913 + hidden->convert = AHI_CONVERT_U16LSB;
1914 + hidden->bytespersample = 2;
1915 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1917 + case AUDIO_U16MSB:
1918 + hidden->convert = AHI_CONVERT_16;
1919 + hidden->bytespersample = 2;
1920 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1922 + case AUDIO_S16MSB:
1923 + hidden->bytespersample = 2;
1924 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1927 +#if AROS_BIG_ENDIAN
1928 + case AUDIO_S16LSB:
1930 + hidden->convert = AHI_CONVERT_S16LSB;
1931 + hidden->bytespersample = 2;
1932 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1934 + case AUDIO_U16LSB:
1936 + hidden->convert = AHI_CONVERT_U16LSB;
1937 + hidden->bytespersample = 2;
1938 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1940 + case AUDIO_U16MSB:
1942 + hidden->convert = AHI_CONVERT_16;
1943 + hidden->bytespersample = 2;
1944 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1946 + case AUDIO_S16MSB:
1947 + // NOTHING TO BE DONE
1948 + hidden->bytespersample = 2;
1949 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1952 + case AUDIO_S16LSB:
1953 + // NOTHING TO BE DONE
1954 + hidden->bytespersample = 2;
1955 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1957 + case AUDIO_U16LSB:
1959 + hidden->convert = AHI_CONVERT_16;
1960 + hidden->bytespersample = 2;
1961 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1963 + case AUDIO_U16MSB:
1965 + hidden->convert = AHI_CONVERT_U16LSB;
1966 + hidden->bytespersample = 2;
1967 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1969 + case AUDIO_S16MSB:
1971 + hidden->convert = AHI_CONVERT_S16LSB;
1972 + hidden->bytespersample = 2;
1973 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1979 + SDL_SetError("Unsupported audio format");
1983 + /* Update the fragment size as size in bytes */
1984 + SDL_CalculateAudioSpec(spec);
1986 + hidden->ctrl_req.ahir_Std.io_Message.mn_ReplyPort = &hidden->dummy_mp;
1987 + hidden->ctrl_req.ahir_Std.io_Message.mn_Length = sizeof(struct AHIRequest);
1988 + hidden->ctrl_req.ahir_Version = 4;
1990 + if (OpenDevice(AHINAME, 0, (struct IORequest *)&hidden->ctrl_req, 0) != 0)
1992 + D(bug("could not open ahi\n"));
1993 + SDL_SetError("Unable to open AHI device! Error code %d.\n", hidden->ctrl_req.ahir_Std.io_Error);
1994 + //DeleteIORequest((struct IORequest *)hidden->ctrl_req);
1998 + hidden->have_ahi = 1;
2000 + /* Align size to multiples of 16 bytes */
2001 + if (altivec_align)
2002 + spec->size = (spec->size + 15) & ~15;
2004 + /* Set output frequency and size */
2005 + hidden->freq = spec->freq;
2006 + hidden->size = spec->size;
2008 + /* Allocate mixing buffer */
2010 + if (altivec_align)
2012 + hidden->mixbuf[0] = (Uint8 *)AllocMemAligned(spec->size, MEMF_ANY, 32, 0);
2013 + hidden->mixbuf[1] = (Uint8 *)AllocMemAligned(spec->size, MEMF_ANY, 32, 0);
2018 + hidden->mixbuf[0] = (Uint8 *)AllocMem(spec->size, MEMF_ANY);
2019 + hidden->mixbuf[1] = (Uint8 *)AllocMem(spec->size, MEMF_ANY);
2022 + if ((hidden->mixbuf[0] == NULL) || (hidden->mixbuf[1] == NULL))
2024 + D(bug("could not alloc audio mixing buffers\n"));
2025 + SDL_SetError("Unable to allocate audio mixing buffers!\n");
2027 + if (hidden->mixbuf[0])
2028 + FreeMem(hidden->mixbuf[0], hidden->size);
2030 + if (hidden->mixbuf[1])
2031 + FreeMem(hidden->mixbuf[1], hidden->size);
2033 + CloseDevice((struct IORequest *)&hidden->ctrl_req);
2034 + hidden->mixbuf[0] = NULL;
2035 + hidden->mixbuf[1] = NULL;
2036 + hidden->have_ahi = 0;
2040 + NEWLIST(&hidden->thread_audio_mp.mp_MsgList);
2041 + hidden->thread_audio_mp.mp_Node.ln_Pri = 60;
2042 + hidden->thread_audio_mp.mp_Node.ln_Type = NT_MSGPORT;
2043 + hidden->thread_audio_mp.mp_Flags = PA_SIGNAL;
2045 + hidden->current_buffer =0;
2046 + hidden->playing = 0;
2048 + D(bug("OpenAudio...OK\n"));
2050 + /* We're ready to rock and roll. :-) */
2055 +#if !defined(PROTO_SDL_H)
2056 +static void AHI_ThreadInit(_THIS)
2058 +static void AHI_ThreadInit(_THIS, struct SDLBase *SDLBase)
2061 + struct SDL_PrivateAudioData *hidden = this->hidden;
2062 + struct MsgPort *mp;
2063 + struct Task *task;
2065 + CopyMem(&hidden->ctrl_req, &hidden->audio_req[0], sizeof(struct AHIRequest));
2066 + CopyMem(&hidden->ctrl_req, &hidden->audio_req[1], sizeof(struct AHIRequest));
2068 + mp = &hidden->thread_audio_mp;
2070 + hidden->audio_req[0].ahir_Std.io_Message.mn_ReplyPort = mp;
2071 + hidden->audio_req[1].ahir_Std.io_Message.mn_ReplyPort = mp;
2073 + mp->mp_SigBit = AllocSignal(-1);
2074 + mp->mp_SigTask = task = FindTask(NULL);
2076 + SetTaskPri(task, 1);
2078 diff -Naur SDL-1.2.15-orig/src/audio/ahi/SDL_ahiaudio.h SDL-1.2.15/src/audio/ahi/SDL_ahiaudio.h
2079 --- SDL-1.2.15-orig/src/audio/ahi/SDL_ahiaudio.h 1970-01-01 01:00:00.000000000 +0100
2080 +++ SDL-1.2.15/src/audio/ahi/SDL_ahiaudio.h 2015-05-09 15:09:59.753739536 +0200
2083 + SDL - Simple DirectMedia Layer
2084 + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
2086 + This library is free software; you can redistribute it and/or
2087 + modify it under the terms of the GNU Library General Public
2088 + License as published by the Free Software Foundation; either
2089 + version 2 of the License, or (at your option) any later version.
2091 + This library is distributed in the hope that it will be useful,
2092 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2093 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2094 + Library General Public License for more details.
2096 + You should have received a copy of the GNU Library General Public
2097 + License along with this library; if not, write to the Free
2098 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2101 + slouken@libsdl.org
2104 +#ifndef _SDL_ahiaudio_h
2105 +#define _SDL_ahiaudio_h
2107 +#include <exec/exec.h>
2108 +#include <dos/dos.h>
2109 +#include <proto/exec.h>
2110 +#include <stdlib.h>
2111 +#include <string.h>
2113 +#include <devices/ahi.h>
2114 +#include "../../main/aros/mydebug.h"
2117 +#include "../SDL_audio_c.h"
2118 +#include "../SDL_audiomem.h"
2119 +#include "../SDL_sysaudio.h"
2121 +/* Hidden "this" pointer for the audio functions */
2122 +#define _THIS SDL_AudioDevice *this
2124 +struct SDL_PrivateAudioData {
2125 + /* The handle for the audio device */
2126 + struct AHIRequest ctrl_req, audio_req[2];
2127 + struct MsgPort dummy_mp, thread_audio_mp;
2128 + Sint32 freq,type,bytespersample,size;
2129 + Uint8 *mixbuf[2]; /* The app mixing buffer */
2130 + Uint32 current_buffer;
2138 + AHI_NO_CONVERSION,
2141 + AHI_CONVERT_U16LSB,
2142 + AHI_CONVERT_S16LSB
2145 +#endif /* _SDL_ahiaudio_h */
2146 diff -Naur SDL-1.2.15-orig/src/audio/disk/SDL_diskaudio.c SDL-1.2.15/src/audio/disk/SDL_diskaudio.c
2147 --- SDL-1.2.15-orig/src/audio/disk/SDL_diskaudio.c 2015-05-09 17:47:54.324774187 +0200
2148 +++ SDL-1.2.15/src/audio/disk/SDL_diskaudio.c 2015-05-09 15:09:59.754739534 +0200
2151 This file written by Ryan C. Gordon (icculus@icculus.org)
2153 +#if defined (SDL_AROS_SHARED)
2154 +#define __NOLIBBASE__
2155 +#include <proto/SDL.h>
2158 #include "SDL_config.h"
2160 /* Output raw audio data to a file. */
2162 #define DISKDEFAULT_WRITEDELAY 150
2164 /* Audio driver functions */
2165 +#if !defined(PROTO_SDL_H)
2166 static int DISKAUD_OpenAudio(_THIS, SDL_AudioSpec *spec);
2167 static void DISKAUD_WaitAudio(_THIS);
2168 static void DISKAUD_PlayAudio(_THIS);
2169 static Uint8 *DISKAUD_GetAudioBuf(_THIS);
2170 static void DISKAUD_CloseAudio(_THIS);
2172 +static int DISKAUD_OpenAudio(_THIS, SDL_AudioSpec *spec, struct SDLBase *SDLBase);
2173 +static void DISKAUD_WaitAudio(_THIS, struct SDLBase *SDLBase);
2174 +static void DISKAUD_PlayAudio(_THIS, struct SDLBase *SDLBase);
2175 +static Uint8 *DISKAUD_GetAudioBuf(_THIS, struct SDLBase *SDLBase);
2176 +static void DISKAUD_CloseAudio(_THIS, struct SDLBase *SDLBase);
2179 static const char *DISKAUD_GetOutputFilename(void)
2184 /* Audio driver bootstrap functions */
2185 +#if !defined(PROTO_SDL_H)
2186 static int DISKAUD_Available(void)
2188 +static int DISKAUD_Available(struct SDLBase *SDLBase)
2191 const char *envr = SDL_getenv("SDL_AUDIODRIVER");
2192 if (envr && (SDL_strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) {
2197 +#if !defined(PROTO_SDL_H)
2198 static void DISKAUD_DeleteDevice(SDL_AudioDevice *device)
2200 +static void DISKAUD_DeleteDevice(SDL_AudioDevice *device, struct SDLBase *SDLBase)
2203 SDL_free(device->hidden);
2207 +#if !defined(PROTO_SDL_H)
2208 static SDL_AudioDevice *DISKAUD_CreateDevice(int devindex)
2210 +static SDL_AudioDevice *DISKAUD_CreateDevice(int devindex, struct SDLBase *SDLBase)
2213 SDL_AudioDevice *this;
2215 @@ -117,12 +142,20 @@
2218 /* This function waits until it is possible to write a full sound buffer */
2219 +#if !defined(PROTO_SDL_H)
2220 static void DISKAUD_WaitAudio(_THIS)
2222 +static void DISKAUD_WaitAudio(_THIS, struct SDLBase *SDLBase)
2225 SDL_Delay(this->hidden->write_delay);
2228 +#if !defined(PROTO_SDL_H)
2229 static void DISKAUD_PlayAudio(_THIS)
2231 +static void DISKAUD_PlayAudio(_THIS, struct SDLBase *SDLBase)
2236 @@ -140,12 +173,20 @@
2240 +#if !defined(PROTO_SDL_H)
2241 static Uint8 *DISKAUD_GetAudioBuf(_THIS)
2243 +static Uint8 *DISKAUD_GetAudioBuf(_THIS, struct SDLBase *SDLBase)
2246 return(this->hidden->mixbuf);
2249 +#if !defined(PROTO_SDL_H)
2250 static void DISKAUD_CloseAudio(_THIS)
2252 +static void DISKAUD_CloseAudio(_THIS, struct SDLBase *SDLBase)
2255 if ( this->hidden->mixbuf != NULL ) {
2256 SDL_FreeAudioMem(this->hidden->mixbuf);
2257 @@ -157,7 +198,11 @@
2261 +#if !defined(PROTO_SDL_H)
2262 static int DISKAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
2264 +static int DISKAUD_OpenAudio(_THIS, SDL_AudioSpec *spec, struct SDLBase *SDLBase)
2267 const char *fname = DISKAUD_GetOutputFilename();
2269 diff -Naur SDL-1.2.15-orig/src/audio/dummy/SDL_dummyaudio.c SDL-1.2.15/src/audio/dummy/SDL_dummyaudio.c
2270 --- SDL-1.2.15-orig/src/audio/dummy/SDL_dummyaudio.c 2015-05-09 17:47:54.350774118 +0200
2271 +++ SDL-1.2.15/src/audio/dummy/SDL_dummyaudio.c 2015-05-09 15:09:59.754739534 +0200
2274 This file written by Ryan C. Gordon (icculus@icculus.org)
2276 +#if defined (SDL_AROS_SHARED)
2277 +#define __NOLIBBASE__
2278 +#include <proto/SDL.h>
2281 #include "SDL_config.h"
2283 /* Output audio to nowhere... */
2285 #define DUMMYAUD_DRIVER_NAME "dummy"
2287 /* Audio driver functions */
2288 +#if !defined(PROTO_SDL_H)
2289 static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec);
2290 static void DUMMYAUD_WaitAudio(_THIS);
2291 static void DUMMYAUD_PlayAudio(_THIS);
2292 static Uint8 *DUMMYAUD_GetAudioBuf(_THIS);
2293 static void DUMMYAUD_CloseAudio(_THIS);
2295 +#include "SDL_intern.h"
2297 +static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec, struct SDLBase *SDLBase);
2298 +static void DUMMYAUD_WaitAudio(_THIS, struct SDLBase *SDLBase);
2299 +static void DUMMYAUD_PlayAudio(_THIS, struct SDLBase *SDLBase);
2300 +static Uint8 *DUMMYAUD_GetAudioBuf(_THIS, struct SDLBase *SDLBase);
2301 +static void DUMMYAUD_CloseAudio(_THIS, struct SDLBase *SDLBase);
2304 /* Audio driver bootstrap functions */
2305 +#if !defined(PROTO_SDL_H)
2306 static int DUMMYAUD_Available(void)
2308 +static int DUMMYAUD_Available(struct SDLBase *SDLBase)
2311 const char *envr = SDL_getenv("SDL_AUDIODRIVER");
2312 if (envr && (SDL_strcmp(envr, DUMMYAUD_DRIVER_NAME) == 0)) {
2317 +#if !defined(PROTO_SDL_H)
2318 static void DUMMYAUD_DeleteDevice(SDL_AudioDevice *device)
2320 +static void DUMMYAUD_DeleteDevice(SDL_AudioDevice *device, struct SDLBase *SDLBase)
2323 SDL_free(device->hidden);
2327 +#if !defined(PROTO_SDL_H)
2328 static SDL_AudioDevice *DUMMYAUD_CreateDevice(int devindex)
2330 +static SDL_AudioDevice *DUMMYAUD_CreateDevice(int devindex, struct SDLBase *SDLBase)
2333 SDL_AudioDevice *this;
2338 /* This function waits until it is possible to write a full sound buffer */
2339 +#if !defined(PROTO_SDL_H)
2340 static void DUMMYAUD_WaitAudio(_THIS)
2342 +static void DUMMYAUD_WaitAudio(_THIS, struct SDLBase *SDLBase)
2345 /* Don't block on first calls to simulate initial fragment filling. */
2346 if (this->hidden->initial_calls)
2347 @@ -106,17 +137,29 @@
2348 SDL_Delay(this->hidden->write_delay);
2351 +#if !defined(PROTO_SDL_H)
2352 static void DUMMYAUD_PlayAudio(_THIS)
2354 +static void DUMMYAUD_PlayAudio(_THIS, struct SDLBase *SDLBase)
2357 /* no-op...this is a null driver. */
2360 +#if !defined(PROTO_SDL_H)
2361 static Uint8 *DUMMYAUD_GetAudioBuf(_THIS)
2363 +static Uint8 *DUMMYAUD_GetAudioBuf(_THIS, struct SDLBase *SDLBase)
2366 return(this->hidden->mixbuf);
2369 +#if !defined(PROTO_SDL_H)
2370 static void DUMMYAUD_CloseAudio(_THIS)
2372 +static void DUMMYAUD_CloseAudio(_THIS, struct SDLBase *SDLBase)
2375 if ( this->hidden->mixbuf != NULL ) {
2376 SDL_FreeAudioMem(this->hidden->mixbuf);
2377 @@ -124,7 +167,11 @@
2381 +#if !defined(PROTO_SDL_H)
2382 static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
2384 +static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec, struct SDLBase *SDLBase)
2387 float bytes_per_sec = 0.0f;
2389 diff -Naur SDL-1.2.15-orig/src/audio/SDL_audio.c SDL-1.2.15/src/audio/SDL_audio.c
2390 --- SDL-1.2.15-orig/src/audio/SDL_audio.c 2015-05-09 17:47:54.352774113 +0200
2391 +++ SDL-1.2.15/src/audio/SDL_audio.c 2015-05-09 15:09:59.754739534 +0200
2397 +#if defined (SDL_AROS_SHARED)
2398 +#define __NOLIBBASE__
2399 +#include <proto/SDL.h>
2402 #include "SDL_config.h"
2404 /* Allow access to a raw mixing buffer */
2405 @@ -113,27 +119,68 @@
2406 #if SDL_AUDIO_DRIVER_EPOCAUDIO
2407 &EPOCAudio_bootstrap,
2409 +#if SDL_AUDIO_DRIVER_AHI
2414 +#if !defined(PROTO_SDL_H)
2415 SDL_AudioDevice *current_audio = NULL;
2417 +#if SDL_AUDIO_DRIVER_AHI
2418 +Uint32 has_obtained_spec;
2419 +static int format_idx;
2420 +static int format_idx_sub;
2422 /* Various local functions */
2423 int SDL_AudioInit(const char *driver_name);
2424 void SDL_AudioQuit(void);
2426 +#include "SDL_intern.h"
2427 +#define current_audio SDLBase->current_audio
2428 +#define has_obtained_spec SDLBase->has_obtained_spec
2429 +#define format_idx SDLBase->format_idx
2430 +#define format_idx_sub SDLBase->format_idx_sub
2433 +#define NUM_FORMATS 6
2434 +static Uint16 format_list[NUM_FORMATS][NUM_FORMATS] = {
2435 + { AUDIO_U8, AUDIO_S8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB },
2436 + { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB },
2437 + { AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8 },
2438 + { AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8 },
2439 + { AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U8, AUDIO_S8 },
2440 + { AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U8, AUDIO_S8 },
2443 /* The general mixing thread function */
2444 +#if !defined(PROTO_SDL_H)
2445 int SDLCALL SDL_RunAudio(void *audiop)
2447 +int SDLCALL SDL_RunAudio(struct SDLBase *SDLBase)
2450 +#if !defined(PROTO_SDL_H)
2451 SDL_AudioDevice *audio = (SDL_AudioDevice *)audiop;
2453 + SDL_AudioDevice *audio = current_audio;
2458 +#if !defined(PROTO_SDL_H)
2459 void (SDLCALL *fill)(void *userdata,Uint8 *stream, int len);
2461 + void (SDLCALL *fill)(void *userdata,Uint8 *stream, int len, struct Library *SDLBase);
2465 /* Perform any thread setup */
2466 if ( audio->ThreadInit ) {
2467 +#if !defined(PROTO_SDL_H)
2468 audio->ThreadInit(audio);
2470 + audio->ThreadInit(audio, SDLBase);
2473 audio->threadid = SDL_ThreadID();
2475 @@ -185,7 +232,11 @@
2479 +#if !defined(PROTO_SDL_H)
2480 stream = audio->GetAudioBuf(audio);
2482 + stream = audio->GetAudioBuf(audio, SDLBase);
2484 if ( stream == NULL ) {
2485 stream = audio->fake_stream;
2487 @@ -195,14 +246,22 @@
2489 if ( ! audio->paused ) {
2490 SDL_mutexP(audio->mixer_lock);
2491 +#if !defined(PROTO_SDL_H)
2492 (*fill)(udata, stream, stream_len);
2494 + (*fill)(udata, stream, stream_len, (struct Library *)SDLBase);
2496 SDL_mutexV(audio->mixer_lock);
2499 /* Convert the audio if necessary */
2500 if ( audio->convert.needed ) {
2501 SDL_ConvertAudio(&audio->convert);
2502 +#if !defined(PROTO_SDL_H)
2503 stream = audio->GetAudioBuf(audio);
2505 + stream = audio->GetAudioBuf(audio, SDLBase);
2507 if ( stream == NULL ) {
2508 stream = audio->fake_stream;
2510 @@ -212,20 +271,32 @@
2512 /* Ready current buffer for play and change current buffer */
2513 if ( stream != audio->fake_stream ) {
2514 +#if !defined(PROTO_SDL_H)
2515 audio->PlayAudio(audio);
2517 + audio->PlayAudio(audio, SDLBase);
2521 /* Wait for an audio buffer to become available */
2522 if ( stream == audio->fake_stream ) {
2523 SDL_Delay((audio->spec.samples*1000)/audio->spec.freq);
2525 +#if !defined(PROTO_SDL_H)
2526 audio->WaitAudio(audio);
2528 + audio->WaitAudio(audio, SDLBase);
2533 /* Wait for the audio to drain.. */
2534 if ( audio->WaitDone ) {
2535 +#if !defined(PROTO_SDL_H)
2536 audio->WaitDone(audio);
2538 + audio->WaitDone(audio, SDLBase);
2543 @@ -236,7 +307,11 @@
2547 +#if !defined(PROTO_SDL_H)
2548 static void SDL_LockAudio_Default(SDL_AudioDevice *audio)
2550 +static void SDL_LockAudio_Default(SDL_AudioDevice *audio, struct SDLBase *SDLBase)
2553 if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
2555 @@ -244,7 +319,11 @@
2556 SDL_mutexP(audio->mixer_lock);
2559 +#if !defined(PROTO_SDL_H)
2560 static void SDL_UnlockAudio_Default(SDL_AudioDevice *audio)
2562 +static void SDL_UnlockAudio_Default(SDL_AudioDevice *audio, struct SDLBase *SDLBase)
2565 if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
2567 @@ -297,8 +376,16 @@
2571 +#if !defined(PROTO_SDL_H)
2572 int SDL_AudioInit(const char *driver_name)
2575 +AROS_LH1(int, SDL_AudioInit,
2576 + AROS_LHA(const char *, driver_name, A0),
2577 + struct SDLBase *, SDLBase, 125, SDL)
2581 SDL_AudioDevice *audio;
2584 @@ -349,16 +436,26 @@
2586 for ( i=0; bootstrap[i]; ++i ) {
2587 if (SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) {
2588 +#if !defined(PROTO_SDL_H)
2589 if ( bootstrap[i]->available() ) {
2590 audio=bootstrap[i]->create(idx);
2592 + if ( bootstrap[i]->available(SDLBase) ) {
2593 + audio=bootstrap[i]->create(idx, SDLBase);
2600 for ( i=0; bootstrap[i]; ++i ) {
2601 +#if !defined(PROTO_SDL_H)
2602 if ( bootstrap[i]->available() ) {
2603 audio = bootstrap[i]->create(idx);
2605 + if ( bootstrap[i]->available(SDLBase) ) {
2606 + audio = bootstrap[i]->create(idx, SDLBase);
2608 if ( audio != NULL ) {
2611 @@ -383,19 +480,43 @@
2615 +#if defined(PROTO_SDL_H)
2620 +#if !defined(PROTO_SDL_H)
2621 char *SDL_AudioDriverName(char *namebuf, int maxlen)
2624 +AROS_LH2(char *, SDL_AudioDriverName,
2625 + AROS_LHA(char *, namebuf, A0),
2626 + AROS_LHA(int, maxlen, D0),
2627 + struct SDLBase *, SDLBase, 126, SDL)
2631 if ( current_audio != NULL ) {
2632 SDL_strlcpy(namebuf, current_audio->name, maxlen);
2636 +#if defined(PROTO_SDL_H)
2641 +#if !defined(PROTO_SDL_H)
2642 int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
2645 +AROS_LH2(int, SDL_OpenAudio,
2646 + AROS_LHA(SDL_AudioSpec *, desired, A0),
2647 + AROS_LHA(SDL_AudioSpec *, obtained, A1),
2648 + struct SDLBase *, SDLBase, 128, SDL)
2652 SDL_AudioDevice *audio;
2655 @@ -494,9 +615,14 @@
2656 audio->convert.needed = 0;
2661 + has_obtained_spec = obtained ? 1 : 0;
2663 +#if !defined(PROTO_SDL_H)
2664 audio->opened = audio->OpenAudio(audio, &audio->spec)+1;
2667 + audio->opened = audio->OpenAudio(audio, &audio->spec, SDLBase)+1;
2669 if ( ! audio->opened ) {
2672 @@ -552,7 +678,11 @@
2673 #undef SDL_CreateThread
2674 audio->thread = SDL_CreateThread(SDL_RunAudio, audio, NULL, NULL);
2676 +#if !defined(PROTO_SDL_H)
2677 audio->thread = SDL_CreateThread(SDL_RunAudio, audio);
2679 + audio->thread = SDL_CreateThread(SDL_RunAudio, SDLBase);
2682 if ( audio->thread == NULL ) {
2684 @@ -567,10 +697,20 @@
2688 +#if defined(PROTO_SDL_H)
2693 +#if !defined(PROTO_SDL_H)
2694 SDL_audiostatus SDL_GetAudioStatus(void)
2697 +AROS_LH0(SDL_audiostatus, SDL_GetAudioStatus,
2698 + struct SDLBase *, SDLBase, 129, SDL)
2702 SDL_AudioDevice *audio = current_audio;
2703 SDL_audiostatus status;
2705 @@ -583,44 +723,103 @@
2709 +#if defined(PROTO_SDL_H)
2714 +#if !defined(PROTO_SDL_H)
2715 void SDL_PauseAudio (int pause_on)
2718 +AROS_LH1(void, SDL_PauseAudio,
2719 + AROS_LHA(int, pause_on, D0),
2720 + struct SDLBase *, SDLBase, 130, SDL)
2724 SDL_AudioDevice *audio = current_audio;
2727 audio->paused = pause_on;
2729 +#if defined(PROTO_SDL_H)
2734 +#if !defined(PROTO_SDL_H)
2735 void SDL_LockAudio (void)
2738 +AROS_LH0(void, SDL_LockAudio,
2739 + struct SDLBase *, SDLBase, 137, SDL)
2743 SDL_AudioDevice *audio = current_audio;
2745 /* Obtain a lock on the mixing buffers */
2746 if ( audio && audio->LockAudio ) {
2747 +#if !defined(PROTO_SDL_H)
2748 audio->LockAudio(audio);
2750 + audio->LockAudio(audio, SDLBase);
2753 +#if defined(PROTO_SDL_H)
2758 +#if !defined(PROTO_SDL_H)
2759 void SDL_UnlockAudio (void)
2762 +AROS_LH0(void, SDL_UnlockAudio,
2763 + struct SDLBase *, SDLBase, 138, SDL)
2767 SDL_AudioDevice *audio = current_audio;
2769 /* Release lock on the mixing buffers */
2770 if ( audio && audio->UnlockAudio ) {
2771 +#if !defined(PROTO_SDL_H)
2772 audio->UnlockAudio(audio);
2774 + audio->UnlockAudio(audio, SDLBase);
2777 +#if defined(PROTO_SDL_H)
2782 +#if !defined(PROTO_SDL_H)
2783 void SDL_CloseAudio (void)
2786 +AROS_LH0(void, SDL_CloseAudio,
2787 + struct SDLBase *, SDLBase, 139, SDL)
2791 SDL_QuitSubSystem(SDL_INIT_AUDIO);
2792 +#if defined(PROTO_SDL_H)
2797 +#if !defined(PROTO_SDL_H)
2798 void SDL_AudioQuit(void)
2801 +AROS_LH0(void, SDL_AudioQuit,
2802 + struct SDLBase *, SDLBase, 127, SDL)
2806 SDL_AudioDevice *audio = current_audio;
2809 @@ -639,28 +838,31 @@
2812 if ( audio->opened ) {
2813 +#if !defined(PROTO_SDL_H)
2814 audio->CloseAudio(audio);
2816 + audio->CloseAudio(audio, SDLBase);
2820 /* Free the driver data */
2821 +#if !defined(PROTO_SDL_H)
2824 + audio->free(audio, SDLBase);
2826 current_audio = NULL;
2828 +#if defined(PROTO_SDL_H)
2833 -#define NUM_FORMATS 6
2834 -static int format_idx;
2835 -static int format_idx_sub;
2836 -static Uint16 format_list[NUM_FORMATS][NUM_FORMATS] = {
2837 - { AUDIO_U8, AUDIO_S8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB },
2838 - { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB },
2839 - { AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8 },
2840 - { AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8 },
2841 - { AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U8, AUDIO_S8 },
2842 - { AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U8, AUDIO_S8 },
2845 +#if !defined(PROTO_SDL_H)
2846 Uint16 SDL_FirstAudioFormat(Uint16 format)
2848 +Uint16 SDL_FirstAudioFormatI(Uint16 format, struct SDLBase *SDLBase)
2851 for ( format_idx=0; format_idx < NUM_FORMATS; ++format_idx ) {
2852 if ( format_list[format_idx][0] == format ) {
2853 @@ -671,7 +873,11 @@
2854 return(SDL_NextAudioFormat());
2857 +#if !defined(PROTO_SDL_H)
2858 Uint16 SDL_NextAudioFormat(void)
2860 +Uint16 SDL_NextAudioFormatI(struct SDLBase *SDLBase)
2863 if ( (format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS) ) {
2865 @@ -694,10 +900,25 @@
2866 spec->size *= spec->samples;
2869 +#if !defined(PROTO_SDL_H)
2870 void SDL_Audio_SetCaption(const char *caption)
2873 +AROS_LH1(void, SDL_Audio_SetCaption,
2874 + AROS_LHA(const char *, caption, A0),
2875 + struct SDLBase *, SDLBase, 131, SDL)
2879 if ((current_audio) && (current_audio->SetCaption)) {
2880 +#if !defined(PROTO_SDL_H)
2881 current_audio->SetCaption(current_audio, caption);
2883 + current_audio->SetCaption(current_audio, caption, SDLBase);
2886 +#if defined(PROTO_SDL_H)
2891 diff -Naur SDL-1.2.15-orig/src/audio/SDL_audio_c.h SDL-1.2.15/src/audio/SDL_audio_c.h
2892 --- SDL-1.2.15-orig/src/audio/SDL_audio_c.h 2015-05-09 17:47:54.324774187 +0200
2893 +++ SDL-1.2.15/src/audio/SDL_audio_c.h 2015-05-09 15:09:59.754739534 +0200
2896 /* Functions and variables exported from SDL_audio.c for SDL_sysaudio.c */
2898 +/* The actual mixing thread function */
2899 +#if !defined(PROTO_SDL_H)
2900 /* Functions to get a list of "close" audio formats */
2901 extern Uint16 SDL_FirstAudioFormat(Uint16 format);
2902 extern Uint16 SDL_NextAudioFormat(void);
2904 /* Function to calculate the size and silence for a SDL_AudioSpec */
2905 extern void SDL_CalculateAudioSpec(SDL_AudioSpec *spec);
2907 -/* The actual mixing thread function */
2908 extern int SDLCALL SDL_RunAudio(void *audiop);
2910 +#include "SDL_intern.h"
2911 +extern Uint16 SDL_FirstAudioFormatI(Uint16 format, struct SDLBase *SDLBase);
2912 +extern Uint16 SDL_NextAudioFormatI(struct SDLBase *SDLBase);
2913 +extern void SDL_CalculateAudioSpec(SDL_AudioSpec *spec);
2914 +extern int SDLCALL SDL_RunAudio(struct SDLBase *SDLBase);
2916 +#define SDL_FirstAudioFormat(format) SDL_FirstAudioFormatI(format, SDLBase)
2917 +#define SDL_NextAudioFormat() SDL_NextAudioFormatI(SDLBase)
2921 diff -Naur SDL-1.2.15-orig/src/audio/SDL_audiocvt.c SDL-1.2.15/src/audio/SDL_audiocvt.c
2922 --- SDL-1.2.15-orig/src/audio/SDL_audiocvt.c 2015-05-09 17:47:54.352774113 +0200
2923 +++ SDL-1.2.15/src/audio/SDL_audiocvt.c 2015-05-09 15:09:59.755739532 +0200
2928 +#if defined (SDL_AROS_SHARED)
2929 +#define __NOLIBBASE__
2930 +#include <proto/SDL.h>
2933 #include "SDL_config.h"
2935 /* Functions for audio drivers to perform runtime conversion of audio format */
2939 /* Effectively mix right and left channels into a single channel */
2940 +#if !defined(PROTO_SDL_H)
2941 void SDLCALL SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format)
2943 +#include "SDL_intern.h"
2945 +#define SDL_ConvertMono SDL_ConvertMonoI
2946 +void SDLCALL SDL_ConvertMonoI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
2951 @@ -129,12 +141,21 @@
2954 if ( cvt->filters[++cvt->filter_index] ) {
2955 +#if !defined(PROTO_SDL_H)
2956 cvt->filters[cvt->filter_index](cvt, format);
2958 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
2963 /* Discard top 4 channels */
2964 +#if !defined(PROTO_SDL_H)
2965 void SDLCALL SDL_ConvertStrip(SDL_AudioCVT *cvt, Uint16 format)
2967 +#define SDL_ConvertStrip SDL_ConvertStripI
2968 +void SDLCALL SDL_ConvertStripI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
2972 Sint32 lsample, rsample;
2973 @@ -244,13 +265,22 @@
2976 if ( cvt->filters[++cvt->filter_index] ) {
2977 +#if !defined(PROTO_SDL_H)
2978 cvt->filters[cvt->filter_index](cvt, format);
2980 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
2986 /* Discard top 2 channels of 6 */
2987 +#if !defined(PROTO_SDL_H)
2988 void SDLCALL SDL_ConvertStrip_2(SDL_AudioCVT *cvt, Uint16 format)
2990 +#define SDL_ConvertStrip_2 SDL_ConvertStrip_2I
2991 +void SDLCALL SDL_ConvertStrip_2I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
2995 Sint32 lsample, rsample;
2996 @@ -360,12 +390,21 @@
2999 if ( cvt->filters[++cvt->filter_index] ) {
3000 +#if !defined(PROTO_SDL_H)
3001 cvt->filters[cvt->filter_index](cvt, format);
3003 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3008 /* Duplicate a mono channel to both stereo channels */
3009 +#if !defined(PROTO_SDL_H)
3010 void SDLCALL SDL_ConvertStereo(SDL_AudioCVT *cvt, Uint16 format)
3012 +#define SDL_ConvertStereo SDL_ConvertStereoI
3013 +void SDLCALL SDL_ConvertStereoI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3018 @@ -397,13 +436,22 @@
3021 if ( cvt->filters[++cvt->filter_index] ) {
3022 +#if !defined(PROTO_SDL_H)
3023 cvt->filters[cvt->filter_index](cvt, format);
3025 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3031 /* Duplicate a stereo channel to a pseudo-5.1 stream */
3032 +#if !defined(PROTO_SDL_H)
3033 void SDLCALL SDL_ConvertSurround(SDL_AudioCVT *cvt, Uint16 format)
3035 +#define SDL_ConvertSurround SDL_ConvertSurroundI
3036 +void SDLCALL SDL_ConvertSurroundI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3041 @@ -574,13 +622,22 @@
3044 if ( cvt->filters[++cvt->filter_index] ) {
3045 +#if !defined(PROTO_SDL_H)
3046 cvt->filters[cvt->filter_index](cvt, format);
3048 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3054 /* Duplicate a stereo channel to a pseudo-4.0 stream */
3055 +#if !defined(PROTO_SDL_H)
3056 void SDLCALL SDL_ConvertSurround_4(SDL_AudioCVT *cvt, Uint16 format)
3058 +#define SDL_ConvertSurround_4 SDL_ConvertSurround_4I
3059 +void SDLCALL SDL_ConvertSurround_4I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3064 @@ -727,13 +784,22 @@
3067 if ( cvt->filters[++cvt->filter_index] ) {
3068 +#if !defined(PROTO_SDL_H)
3069 cvt->filters[cvt->filter_index](cvt, format);
3071 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3077 /* Convert 8-bit to 16-bit - LSB */
3078 +#if !defined(PROTO_SDL_H)
3079 void SDLCALL SDL_Convert16LSB(SDL_AudioCVT *cvt, Uint16 format)
3081 +#define SDL_Convert16LSB SDL_Convert16LSBI
3082 +void SDLCALL SDL_Convert16LSBI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3087 @@ -752,11 +818,20 @@
3088 format = ((format & ~0x0008) | AUDIO_U16LSB);
3090 if ( cvt->filters[++cvt->filter_index] ) {
3091 +#if !defined(PROTO_SDL_H)
3092 cvt->filters[cvt->filter_index](cvt, format);
3094 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3098 /* Convert 8-bit to 16-bit - MSB */
3099 +#if !defined(PROTO_SDL_H)
3100 void SDLCALL SDL_Convert16MSB(SDL_AudioCVT *cvt, Uint16 format)
3102 +#define SDL_Convert16MSB SDL_Convert16MSBI
3103 +void SDLCALL SDL_Convert16MSBI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3108 @@ -775,12 +850,21 @@
3109 format = ((format & ~0x0008) | AUDIO_U16MSB);
3111 if ( cvt->filters[++cvt->filter_index] ) {
3112 +#if !defined(PROTO_SDL_H)
3113 cvt->filters[cvt->filter_index](cvt, format);
3115 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3120 /* Convert 16-bit to 8-bit */
3121 +#if !defined(PROTO_SDL_H)
3122 void SDLCALL SDL_Convert8(SDL_AudioCVT *cvt, Uint16 format)
3124 +#define SDL_Convert8 SDL_Convert8I
3125 +void SDLCALL SDL_Convert8I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3130 @@ -801,12 +885,21 @@
3131 format = ((format & ~0x9010) | AUDIO_U8);
3133 if ( cvt->filters[++cvt->filter_index] ) {
3134 +#if !defined(PROTO_SDL_H)
3135 cvt->filters[cvt->filter_index](cvt, format);
3137 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3142 /* Toggle signed/unsigned */
3143 +#if !defined(PROTO_SDL_H)
3144 void SDLCALL SDL_ConvertSign(SDL_AudioCVT *cvt, Uint16 format)
3146 +#define SDL_ConvertSign SDL_ConvertSignI
3147 +void SDLCALL SDL_ConvertSignI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3152 @@ -830,12 +923,21 @@
3154 format = (format ^ 0x8000);
3155 if ( cvt->filters[++cvt->filter_index] ) {
3156 +#if !defined(PROTO_SDL_H)
3157 cvt->filters[cvt->filter_index](cvt, format);
3159 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3164 /* Toggle endianness */
3165 +#if !defined(PROTO_SDL_H)
3166 void SDLCALL SDL_ConvertEndian(SDL_AudioCVT *cvt, Uint16 format)
3168 +#define SDL_ConvertEndian SDL_ConvertEndianI
3169 +void SDLCALL SDL_ConvertEndianI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3174 @@ -852,12 +954,21 @@
3176 format = (format ^ 0x1000);
3177 if ( cvt->filters[++cvt->filter_index] ) {
3178 +#if !defined(PROTO_SDL_H)
3179 cvt->filters[cvt->filter_index](cvt, format);
3181 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3186 /* Convert rate up by multiple of 2 */
3187 +#if !defined(PROTO_SDL_H)
3188 void SDLCALL SDL_RateMUL2(SDL_AudioCVT *cvt, Uint16 format)
3190 +#define SDL_RateMUL2 SDL_RateMUL2I
3191 +void SDLCALL SDL_RateMUL2(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3196 @@ -889,13 +1000,22 @@
3199 if ( cvt->filters[++cvt->filter_index] ) {
3200 +#if !defined(PROTO_SDL_H)
3201 cvt->filters[cvt->filter_index](cvt, format);
3203 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3209 /* Convert rate up by multiple of 2, for stereo */
3210 +#if !defined(PROTO_SDL_H)
3211 void SDLCALL SDL_RateMUL2_c2(SDL_AudioCVT *cvt, Uint16 format)
3213 +#define SDL_RateMUL2_c2 SDL_RateMUL2_c2I
3214 +void SDLCALL SDL_RateMUL2_c2I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3219 @@ -933,12 +1053,21 @@
3222 if ( cvt->filters[++cvt->filter_index] ) {
3223 +#if !defined(PROTO_SDL_H)
3224 cvt->filters[cvt->filter_index](cvt, format);
3226 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3231 /* Convert rate up by multiple of 2, for quad */
3232 +#if !defined(PROTO_SDL_H)
3233 void SDLCALL SDL_RateMUL2_c4(SDL_AudioCVT *cvt, Uint16 format)
3235 +#define SDL_RateMUL2_c4 SDL_RateMUL2_c4I
3236 +void SDLCALL SDL_RateMUL2_c4I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3241 @@ -988,13 +1117,22 @@
3244 if ( cvt->filters[++cvt->filter_index] ) {
3245 +#if !defined(PROTO_SDL_H)
3246 cvt->filters[cvt->filter_index](cvt, format);
3248 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3254 /* Convert rate up by multiple of 2, for 5.1 */
3255 +#if !defined(PROTO_SDL_H)
3256 void SDLCALL SDL_RateMUL2_c6(SDL_AudioCVT *cvt, Uint16 format)
3258 +#define SDL_RateMUL2_c6 SDL_RateMUL2_c6I
3259 +void SDLCALL SDL_RateMUL2_c6I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3264 @@ -1056,12 +1194,21 @@
3267 if ( cvt->filters[++cvt->filter_index] ) {
3268 +#if !defined(PROTO_SDL_H)
3269 cvt->filters[cvt->filter_index](cvt, format);
3271 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3276 /* Convert rate down by multiple of 2 */
3277 +#if !defined(PROTO_SDL_H)
3278 void SDLCALL SDL_RateDIV2(SDL_AudioCVT *cvt, Uint16 format)
3280 +#define SDL_RateDIV2 SDL_RateDIV2I
3281 +void SDLCALL SDL_RateDIV2I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3286 @@ -1090,13 +1237,22 @@
3289 if ( cvt->filters[++cvt->filter_index] ) {
3290 +#if !defined(PROTO_SDL_H)
3291 cvt->filters[cvt->filter_index](cvt, format);
3293 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3299 /* Convert rate down by multiple of 2, for stereo */
3300 +#if !defined(PROTO_SDL_H)
3301 void SDLCALL SDL_RateDIV2_c2(SDL_AudioCVT *cvt, Uint16 format)
3303 +#define SDL_RateDIV2_c2 SDL_RateDIV2_c2I
3304 +void SDLCALL SDL_RateDIV2_c2I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3309 @@ -1128,13 +1284,22 @@
3312 if ( cvt->filters[++cvt->filter_index] ) {
3313 +#if !defined(PROTO_SDL_H)
3314 cvt->filters[cvt->filter_index](cvt, format);
3316 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3322 /* Convert rate down by multiple of 2, for quad */
3323 +#if !defined(PROTO_SDL_H)
3324 void SDLCALL SDL_RateDIV2_c4(SDL_AudioCVT *cvt, Uint16 format)
3326 +#define SDL_RateDIV2_c4 SDL_RateDIV2_c4I
3327 +void SDLCALL SDL_RateDIV2_c4I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3332 @@ -1172,12 +1337,21 @@
3335 if ( cvt->filters[++cvt->filter_index] ) {
3336 +#if !defined(PROTO_SDL_H)
3337 cvt->filters[cvt->filter_index](cvt, format);
3339 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3344 /* Convert rate down by multiple of 2, for 5.1 */
3345 +#if !defined(PROTO_SDL_H)
3346 void SDLCALL SDL_RateDIV2_c6(SDL_AudioCVT *cvt, Uint16 format)
3348 +#define SDL_RateDIV2_c6 SDL_RateDIV2_c6I
3349 +void SDLCALL SDL_RateDIV2_c6I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3354 @@ -1221,12 +1395,21 @@
3357 if ( cvt->filters[++cvt->filter_index] ) {
3358 +#if !defined(PROTO_SDL_H)
3359 cvt->filters[cvt->filter_index](cvt, format);
3361 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3366 /* Very slow rate conversion routine */
3367 +#if !defined(PROTO_SDL_H)
3368 void SDLCALL SDL_RateSLOW(SDL_AudioCVT *cvt, Uint16 format)
3370 +#define SDL_RateSLOW SDL_RateSLOWI
3371 +void SDLCALL SDL_RateSLOWI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3376 @@ -1296,12 +1479,24 @@
3378 cvt->len_cvt = clen;
3379 if ( cvt->filters[++cvt->filter_index] ) {
3380 +#if !defined(PROTO_SDL_H)
3381 cvt->filters[cvt->filter_index](cvt, format);
3383 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3388 +#if !defined(PROTO_SDL_H)
3389 int SDL_ConvertAudio(SDL_AudioCVT *cvt)
3392 +AROS_LH1(int, SDL_ConvertAudio,
3393 + AROS_LHA(SDL_AudioCVT *, cvt, A0),
3394 + struct Library *, SDLBase, 135, SDL)
3398 /* Make sure there's data to convert */
3399 if ( cvt->buf == NULL ) {
3400 SDL_SetError("No buffer allocated for conversion");
3401 @@ -1315,8 +1510,15 @@
3403 /* Set up the conversion and go! */
3404 cvt->filter_index = 0;
3405 +#if !defined(PROTO_SDL_H)
3406 cvt->filters[0](cvt, cvt->src_format);
3408 + cvt->filters[0](cvt, cvt->src_format, SDLBase);
3411 +#if defined(PROTO_SDL_H)
3416 /* Creates a set of audio filters to convert from one format to another.
3417 @@ -1324,10 +1526,24 @@
3418 audio filter is set up.
3421 +#if !defined(PROTO_SDL_H)
3422 int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
3423 Uint16 src_format, Uint8 src_channels, int src_rate,
3424 Uint16 dst_format, Uint8 dst_channels, int dst_rate)
3427 +AROS_LH7(int, SDL_BuildAudioCVT,
3428 + AROS_LHA(SDL_AudioCVT *, cvt, A0),
3429 + AROS_LHA(Uint16, src_format, D0),
3430 + AROS_LHA(Uint8, src_channels, D1),
3431 + AROS_LHA(int, src_rate, D2),
3432 + AROS_LHA(Uint16, dst_format, D3),
3433 + AROS_LHA(Uint8, dst_channels, D4),
3434 + AROS_LHA(int, dst_rate, D5),
3435 + struct SDLBase *, SDLBase, 134, SDL)
3439 /*printf("Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
3440 src_format, dst_format, src_channels, dst_channels, src_rate, dst_rate);*/
3441 /* Start off with no conversion necessary */
3442 @@ -1439,7 +1655,11 @@
3443 Uint32 hi_rate, lo_rate;
3446 +#if !defined(PROTO_SDL_H)
3447 void (SDLCALL *rate_cvt)(SDL_AudioCVT *cvt, Uint16 format);
3449 + void (SDLCALL *rate_cvt)(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase);
3452 if ( src_rate > dst_rate ) {
3454 @@ -1507,4 +1727,7 @@
3455 cvt->filters[cvt->filter_index] = NULL;
3457 return(cvt->needed);
3458 +#if defined(PROTO_SDL_H)
3462 diff -Naur SDL-1.2.15-orig/src/audio/SDL_audiodev.c SDL-1.2.15/src/audio/SDL_audiodev.c
3463 --- SDL-1.2.15-orig/src/audio/SDL_audiodev.c 2015-05-09 17:47:54.324774187 +0200
3464 +++ SDL-1.2.15/src/audio/SDL_audiodev.c 2015-05-09 15:09:59.755739532 +0200
3469 +#if defined (SDL_AROS_SHARED)
3470 +#define __NOLIBBASE__
3471 +#include <proto/SDL.h>
3474 #include "SDL_config.h"
3476 /* Get the name of the audio device we use for output */
3477 diff -Naur SDL-1.2.15-orig/src/audio/SDL_mixer.c SDL-1.2.15/src/audio/SDL_mixer.c
3478 --- SDL-1.2.15-orig/src/audio/SDL_mixer.c 2015-05-09 17:47:54.352774113 +0200
3479 +++ SDL-1.2.15/src/audio/SDL_mixer.c 2015-05-09 15:09:59.756739531 +0200
3484 +#if defined (SDL_AROS_SHARED)
3485 +#define __NOLIBBASE__
3486 +#include <proto/SDL.h>
3489 #include "SDL_config.h"
3491 /* This provides the default mixing callback for the SDL audio routines */
3493 #include "SDL_mixer_MMX_VC.h"
3494 #include "SDL_mixer_m68k.h"
3496 +#if defined(PROTO_SDL_H)
3497 +#include "SDL_intern.h"
3499 +#define current_audio SDLBase->current_audio
3502 /* This table is used to add two sound values together and pin
3503 * the value to avoid overflow. (used with permission from ARDI)
3504 * Changed to use 0xFE instead of 0xFF for better sound quality.
3506 #define ADJUST_VOLUME(s, v) (s = (s*v)/SDL_MIX_MAXVOLUME)
3507 #define ADJUST_VOLUME_U8(s, v) (s = (((s-128)*v)/SDL_MIX_MAXVOLUME)+128)
3509 +#if !defined(PROTO_SDL_H)
3510 void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
3513 +AROS_LH4(void, SDL_MixAudio,
3514 + AROS_LHA(Uint8 *, dst, A0),
3515 + AROS_LHA(Uint8 *, src, A1),
3516 + AROS_LHA(Uint32, len, D0),
3517 + AROS_LHA(int, volume, D1),
3518 + struct SDLBase *, SDLBase, 136, SDL)
3524 if ( volume == 0 ) {
3526 SDL_SetError("SDL_MixAudio(): unknown audio format");
3529 +#if defined(PROTO_SDL_H)
3534 diff -Naur SDL-1.2.15-orig/src/audio/SDL_mixer_m68k.c SDL-1.2.15/src/audio/SDL_mixer_m68k.c
3535 --- SDL-1.2.15-orig/src/audio/SDL_mixer_m68k.c 2015-05-09 17:47:54.352774113 +0200
3536 +++ SDL-1.2.15/src/audio/SDL_mixer_m68k.c 2015-05-09 15:09:59.756739531 +0200
3541 +#if defined (SDL_AROS_SHARED)
3542 +#define __NOLIBBASE__
3543 +#include <proto/SDL.h>
3546 #include "SDL_config.h"
3549 diff -Naur SDL-1.2.15-orig/src/audio/SDL_mixer_MMX.c SDL-1.2.15/src/audio/SDL_mixer_MMX.c
3550 --- SDL-1.2.15-orig/src/audio/SDL_mixer_MMX.c 2015-05-09 17:47:54.350774118 +0200
3551 +++ SDL-1.2.15/src/audio/SDL_mixer_MMX.c 2015-05-09 15:09:59.756739531 +0200
3556 +#if defined (SDL_AROS_SHARED)
3557 +#define __NOLIBBASE__
3558 +#include <proto/SDL.h>
3561 #include "SDL_config.h"
3564 diff -Naur SDL-1.2.15-orig/src/audio/SDL_sysaudio.h SDL-1.2.15/src/audio/SDL_sysaudio.h
3565 --- SDL-1.2.15-orig/src/audio/SDL_sysaudio.h 2015-05-09 17:47:54.324774187 +0200
3566 +++ SDL-1.2.15/src/audio/SDL_sysaudio.h 2015-05-09 15:09:59.756739531 +0200
3568 #include "SDL_mutex.h"
3569 #include "SDL_thread.h"
3571 +#if defined(PROTO_SDL_H)
3572 +#include "SDL_intern.h"
3575 /* The SDL audio driver */
3576 typedef struct SDL_AudioDevice SDL_AudioDevice;
3581 /* Public driver functions */
3582 +#if !defined(PROTO_SDL_H)
3583 int (*OpenAudio)(_THIS, SDL_AudioSpec *spec);
3584 void (*ThreadInit)(_THIS); /* Called by audio thread at start */
3585 void (*WaitAudio)(_THIS);
3587 void (*UnlockAudio)(_THIS);
3589 void (*SetCaption)(_THIS, const char *caption);
3592 + int (*OpenAudio)(_THIS, SDL_AudioSpec *spec, struct SDLBase *SDLBase);
3593 + void (*ThreadInit)(_THIS, struct SDLBase *SDLBase);
3594 + void (*WaitAudio)(_THIS, struct SDLBase *SDLBase);
3595 + void (*PlayAudio)(_THIS, struct SDLBase *SDLBase);
3596 + Uint8 *(*GetAudioBuf)(_THIS, struct SDLBase *SDLBase);
3597 + void (*WaitDone)(_THIS, struct SDLBase *SDLBase);
3598 + void (*CloseAudio)(_THIS, struct SDLBase *SDLBase);
3599 + void (*LockAudio)(_THIS, struct SDLBase *SDLBase);
3600 + void (*UnlockAudio)(_THIS, struct SDLBase *SDLBase);
3601 + void (*SetCaption)(_THIS, const char *caption, struct SDLBase *SDLBase);
3604 /* Data common to all devices */
3606 @@ -91,15 +107,24 @@
3609 /* The function used to dispose of this structure */
3610 +#if !defined(PROTO_SDL_H)
3611 void (*free)(_THIS);
3613 + void (*free)(_THIS, struct SDLBase *SDLBase);
3618 typedef struct AudioBootStrap {
3621 +#if !defined(PROTO_SDL_H)
3622 int (*available)(void);
3623 - SDL_AudioDevice *(*create)(int devindex);
3624 + SDL_AudioDevice *(*create)(int devindex);
3626 + int (*available)(struct SDLBase *SDLBase);
3627 + SDL_AudioDevice *(*create)(int devindex, struct SDLBase *SDLBase);
3631 #if SDL_AUDIO_DRIVER_BSD
3632 @@ -179,8 +204,13 @@
3633 #if SDL_AUDIO_DRIVER_EPOCAUDIO
3634 extern AudioBootStrap EPOCAudio_bootstrap;
3636 +#if SDL_AUDIO_DRIVER_AHI
3637 +extern AudioBootStrap AHI_bootstrap;
3640 /* This is the current audio device */
3641 +#if !defined(PROTO_SDL_H)
3642 extern SDL_AudioDevice *current_audio;
3645 #endif /* _SDL_sysaudio_h */
3646 diff -Naur SDL-1.2.15-orig/src/audio/SDL_wave.c SDL-1.2.15/src/audio/SDL_wave.c
3647 --- SDL-1.2.15-orig/src/audio/SDL_wave.c 2015-05-09 17:47:54.352774113 +0200
3648 +++ SDL-1.2.15/src/audio/SDL_wave.c 2015-05-09 15:09:59.756739531 +0200
3653 +#if defined (SDL_AROS_SHARED)
3654 +#define __NOLIBBASE__
3655 +#include <proto/SDL.h>
3658 #include "SDL_config.h"
3660 /* Microsoft WAVE file loading routines */
3662 #include "SDL_audio.h"
3663 #include "SDL_wave.h"
3666 +#if !defined(PROTO_SDL_H)
3667 static int ReadChunk(SDL_RWops *src, Chunk *chunk);
3669 +#include "SDL_intern.h"
3671 +static int ReadChunkI(SDL_RWops *src, Chunk *chunk, struct SDLBase *SDLBase);
3672 +#define ReadChunk(src, chunk) ReadChunkI(src, chunk, SDLBase)
3675 struct MS_ADPCM_decodestate {
3678 struct MS_ADPCM_decodestate state[2];
3681 +#if !defined(PROTO_SDL_H)
3682 static int InitMS_ADPCM(WaveFMT *format)
3684 +#define InitMS_ADPCM(format) InitMS_ADPCMI(format, SDLBase)
3685 +static int InitMS_ADPCMI(WaveFMT *format, struct SDLBase *SDLBase)
3690 @@ -112,7 +128,12 @@
3694 +#if !defined(PROTO_SDL_H)
3695 static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
3697 +#define MS_ADPCM_decode(audio_buf, audio_len) MS_ADPCM_decodeI(audio_buf, audio_len, SDLBase)
3698 +static int MS_ADPCM_decodeI(Uint8 **audio_buf, Uint32 *audio_len, struct SDLBase *SDLBase)
3701 struct MS_ADPCM_decodestate *state[2];
3702 Uint8 *freeable, *encoded, *decoded;
3703 @@ -320,7 +341,12 @@
3707 +#if !defined(PROTO_SDL_H)
3708 static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
3710 +#define IMA_ADPCM_decode(audio_buf, audio_len) IMA_ADPCM_decodeI(audio_buf, audio_len, SDLBase)
3711 +static int IMA_ADPCM_decodeI(Uint8 **audio_buf, Uint32 *audio_len, struct SDLBase *SDLBase)
3714 struct IMA_ADPCM_decodestate *state;
3715 Uint8 *freeable, *encoded, *decoded;
3716 @@ -389,9 +415,21 @@
3720 +#if !defined(PROTO_SDL_H)
3721 SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
3722 SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
3725 +AROS_LH5(SDL_AudioSpec *, SDL_LoadWAV_RW,
3726 + AROS_LHA(SDL_RWops *, src, A0),
3727 + AROS_LHA(int, freesrc, D0),
3728 + AROS_LHA(SDL_AudioSpec *, spec, A1),
3729 + AROS_LHA(Uint8 **, audio_buf, A2),
3730 + AROS_LHA(Uint32 *, audio_len, A3),
3731 + struct SDLBase *, SDLBase, 132, SDL)
3738 @@ -565,19 +603,38 @@
3742 +#if defined(PROTO_SDL_H)
3747 /* Since the WAV memory is allocated in the shared library, it must also
3748 be freed here. (Necessary under Win32, VC++)
3750 +#if !defined(PROTO_SDL_H)
3751 void SDL_FreeWAV(Uint8 *audio_buf)
3754 +AROS_LH1(void, SDL_FreeWAV,
3755 + AROS_LHA(Uint8 *, audio_buf, A0),
3756 + struct SDLBase *, SDLBase, 133, SDL)
3761 if ( audio_buf != NULL ) {
3762 SDL_free(audio_buf);
3764 +#if defined(PROTO_SDL_H)
3769 +#if !defined(PROTO_SDL_H)
3770 static int ReadChunk(SDL_RWops *src, Chunk *chunk)
3772 +static int ReadChunkI(SDL_RWops *src, Chunk *chunk, struct SDLBase *SDLBase)
3775 chunk->magic = SDL_ReadLE32(src);
3776 chunk->length = SDL_ReadLE32(src);
3777 diff -Naur SDL-1.2.15-orig/src/cdrom/aros/SDL_syscdrom.c SDL-1.2.15/src/cdrom/aros/SDL_syscdrom.c
3778 --- SDL-1.2.15-orig/src/cdrom/aros/SDL_syscdrom.c 1970-01-01 01:00:00.000000000 +0100
3779 +++ SDL-1.2.15/src/cdrom/aros/SDL_syscdrom.c 2015-05-09 15:09:59.757739529 +0200
3782 + SDL - Simple DirectMedia Layer
3783 + Copyright (C) 1997-2004 Sam Lantinga
3785 + This library is free software; you can redistribute it and/or
3786 + modify it under the terms of the GNU Library General Public
3787 + License as published by the Free Software Foundation; either
3788 + version 2 of the License, or (at your option) any later version.
3790 + This library is distributed in the hope that it will be useful,
3791 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3792 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3793 + Library General Public License for more details.
3795 + You should have received a copy of the GNU Library General Public
3796 + License along with this library; if not, write to the Free
3797 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3800 + slouken@libsdl.org
3803 +#include <proto/exec.h>
3804 +#include <proto/dos.h>
3806 +#if defined (SDL_AROS_SHARED)
3807 +#define __NOLIBBASE__
3808 +#include <proto/SDL.h>
3811 +/* Stub functions for system-level CD-ROM audio control */
3815 +#include "SDL_cdrom.h"
3816 +#include "SDL_syscdrom.h"
3818 +#include <dos/dosextens.h>
3819 +#include <dos/filehandler.h>
3820 +#include <devices/scsidisk.h>
3822 +#include <aros/macros.h>
3823 +#include "../../main/aros/mydebug.h"
3825 +/* Just large enought to hold TOC */
3826 +#define TOC_SIZE 804
3827 +#define SCSI_INBUF_SIZE TOC_SIZE
3828 +#define SCSI_SENSE_SIZE 252
3831 +#define AllocTaskPooled(x) AllocVec(x,MEMF_ANY)
3832 +#define FreeTaskPooled(x,y) FreeVec(x)
3838 + char devname[108];
3842 + /* Filled in when this unit is opened */
3844 + struct IOStdReq *req;
3845 + struct SCSICmd scsicmd;
3852 + UBYTE Pad1, Flags, TrackNumber, Pad2;
3861 + struct TrackInfo TOCData[100];
3864 +#if !defined(PROTO_SDL_H)
3865 +UBYTE *CDList[MAX_DRIVES];
3867 +#include "SDL_intern.h"
3869 +#define CDList SDLBase->CDList
3871 +/**********************************************************************
3874 + Return 1 if duplicate
3875 +**********************************************************************/
3877 +static ULONG FindDup(UBYTE **cdlist, CONST_STRPTR devname, ULONG unit)
3879 + struct MyCDROM *entry;
3882 + D(bug("CDRom : FindDup\n"));
3884 + for (i = 0; i < MAX_DRIVES; i++)
3886 + entry = (struct MyCDROM *)cdlist[i];
3888 + if (entry == NULL)
3891 + if (entry->unit == unit && strcmp(entry->devname, devname) == 0)
3898 +/**********************************************************************
3901 + Convert BCPL string to STRPTR
3902 +**********************************************************************/
3904 +LONG CopyStringBSTRToC (BSTR src, STRPTR dst, ULONG dst_size)
3907 + STRPTR ptr = AROS_BSTR_ADDR(src);
3908 + ULONG ln = AROS_BSTR_strlen(src);
3910 + UBYTE *ptr = BADDR(src);
3911 + ULONG ln = *ptr++;
3913 + if (ln > (dst_size-1)) ln = dst_size-1;
3914 + memcpy(dst, ptr, ln);
3919 +/**********************************************************************
3921 +**********************************************************************/
3923 +#if !defined(PROTO_SDL_H)
3924 +static LONG SendCMD(SDL_CD *cdrom, const UBYTE *cmd, int cmdlen)
3926 +#define SendCMD(cdrom, cmd, cmdlen) SendCMDI(cdrom, cmd, cmdlen, SDLBase)
3927 +static LONG SendCMDI(SDL_CD *cdrom, const UBYTE *cmd, int cmdlen, struct SDLBase *SDLBase)
3930 + struct MyCDROM *entry = (struct MyCDROM *)CDList[cdrom->id];
3932 + D(bug("CDRom : SendCMD..."));
3934 + entry->scsicmd.scsi_Data = entry->inbuf;
3935 + entry->scsicmd.scsi_Length = SCSI_INBUF_SIZE;
3936 + entry->scsicmd.scsi_SenseActual = 0;
3937 + entry->scsicmd.scsi_SenseData = (UBYTE *)entry->sensebuf;
3938 + entry->scsicmd.scsi_SenseLength = SCSI_SENSE_SIZE;
3939 + entry->scsicmd.scsi_CmdActual = 0;
3940 + entry->scsicmd.scsi_Command = (UBYTE *)cmd;
3941 + entry->scsicmd.scsi_CmdLength = cmdlen;
3942 + entry->scsicmd.scsi_Flags = SCSIF_READ | SCSIF_AUTOSENSE;
3944 + DoIO((struct IORequest *)entry->req);
3946 + D(bug("%s\n",entry->scsicmd.scsi_Status ? "NOK" : "OK"));
3948 + return (entry->scsicmd.scsi_Status ? -1 : 0);
3951 +#if !defined(PROTO_SDL_H)
3952 +static const char *SDL_SYS_CDName(int drive)
3954 +static const char *SDL_SYS_CDName(int drive, struct SDLBase *SDLBase)
3957 + D(bug("CDRom : SDL_SYS_CDName\n"));
3959 + return(CDList[drive]);
3962 +#if !defined(PROTO_SDL_H)
3963 +static void SDL_DisposeCD(struct MyCDROM *entry)
3965 +#define SDL_DisposeCD(entry) SDL_DisposeCDI(entry, SDLBase)
3966 +static void SDL_DisposeCDI(struct MyCDROM *entry, struct SDLBase *SDLBase)
3969 + D(bug("CDRom : SDL_DisposeCD\n"));
3971 + DeleteIORequest((struct IORequest *)entry->req);
3974 + FreeTaskPooled(entry->inbuf, SCSI_INBUF_SIZE);
3976 + if (entry->sensebuf)
3977 + FreeTaskPooled(entry->sensebuf, SCSI_SENSE_SIZE);
3979 + entry->req = NULL;
3980 + entry->inbuf = NULL;
3981 + entry->sensebuf = NULL;
3984 +#if !defined(PROTO_SDL_H)
3985 +static int SDL_SYS_CDOpen(int drive)
3987 +static int SDL_SYS_CDOpen(int drive, struct SDLBase *SDLBase)
3990 + struct MyCDROM *entry;
3991 + struct MsgPort *port;
3993 + D(bug("CDRom : SDL_SYS_CDOpen\n"));
3995 + if ((drive >= 0) && (drive < MAX_DRIVES))
3997 + /* Yay! Use DOS message port :-) */
3999 + entry = (struct MyCDROM *)CDList[drive];
4000 + port = &((struct Process *)FindTask(NULL))->pr_MsgPort;
4002 + if ((entry->req = CreateIORequest(port, sizeof(struct IOStdReq))) != NULL)
4004 + if ((entry->inbuf = AllocTaskPooled(SCSI_INBUF_SIZE)) != NULL)
4005 + if ((entry->sensebuf = AllocTaskPooled(SCSI_SENSE_SIZE)) != NULL)
4006 + if (OpenDevice(entry->devname, entry->unit, (struct IORequest *)entry->req, entry->unitflags) == 0)
4008 + entry->req->io_Command = HD_SCSICMD;
4009 + entry->req->io_Data = (APTR)&entry->scsicmd;
4010 + entry->req->io_Length = sizeof(struct SCSICmd);
4015 + SDL_DisposeCD(entry);
4021 +#if !defined(PROTO_SDL_H)
4022 +static void SDL_SYS_CDClose(SDL_CD *cdrom)
4024 +static void SDL_SYS_CDClose(SDL_CD *cdrom, struct SDLBase *SDLBase)
4027 + struct MyCDROM *entry = (struct MyCDROM *)CDList[cdrom->id];
4029 + D(bug("CDRom : SDL_SYS_CDClose\n"));
4032 + if (entry && entry->req)
4034 + CloseDevice((struct IORequest *)entry->req);
4035 + SDL_DisposeCD(entry);
4039 +#if !defined(PROTO_SDL_H)
4040 +static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
4042 +static int SDL_SYS_CDGetTOC(SDL_CD *cdrom, struct SDLBase *SDLBase)
4045 + static const UBYTE Cmd[10] =
4046 + { 0x43, 0, 0, 0, 0, 0, 0, TOC_SIZE >> 8, TOC_SIZE & 0xff, 0 };
4049 + D(bug("CDRom : SDL_SYS_CDGetTOC\n"));
4053 + if (SendCMD(cdrom, Cmd, sizeof(Cmd)) == 0)
4055 + struct MyCDROM *entry = (struct MyCDROM *)CDList[cdrom->id];
4056 + struct CD_TOC *toc;
4059 + toc = (struct CD_TOC *)entry->inbuf;
4061 + D(bug("TOC : length = %d, First Track = %d, Last Track = %d\n",AROS_BE2WORD(toc->Length), toc->FirstTrack, toc->LastTrack));
4063 + cdrom->numtracks = toc->LastTrack - toc->FirstTrack + 1;
4065 + if ( cdrom->numtracks > SDL_MAX_TRACKS ) {
4066 + cdrom->numtracks = SDL_MAX_TRACKS;
4069 + D(bug("Found %d tracks\n",cdrom->numtracks));
4071 + /* Read all the track TOC entries */
4075 + for ( i=0; i<cdrom->numtracks; ++i )
4077 + cdrom->track[i].id = i+1;
4079 + D(bug("Track %d :",i));
4080 + D(bug("%02X, %02X, %02X, %02X\t",toc->TOCData[i].Pad1, toc->TOCData[i].Flags, toc->TOCData[i].TrackNumber, toc->TOCData[i].Pad2));
4082 + if (toc->TOCData[i].Flags & 0x04)
4084 + cdrom->track[i].type = SDL_DATA_TRACK;
4085 + D(bug("\tDATA\t"));
4089 + cdrom->track[i].type = SDL_AUDIO_TRACK;
4090 + D(bug("\tAUDIO\t"));
4093 + cdrom->track[i].offset = AROS_BE2LONG(toc->TOCData[i].Address);
4095 + if (i == cdrom->numtracks)
4097 + cdrom->track[i].length = 0;
4098 + D(bug("length : %d\n",0));
4102 + cdrom->track[i].length = AROS_BE2LONG(toc->TOCData[i+1].Address) - cdrom->track[i].offset;
4103 + D(bug("length : %d\n",cdrom->track[i].length));
4108 + return(okay ? 0 : -1);
4112 +#if !defined(PROTO_SDL_H)
4113 +static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
4115 +static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position, struct SDLBase *SDLBase)
4118 + static const UBYTE Cmd[10] =
4119 + { 0x42, 0, 0x40, 0x01, 0, 0, 0, SCSI_INBUF_SIZE >> 8, SCSI_INBUF_SIZE & 0xff, 0 };
4122 + D(bug("CDRom : SDL_SYS_CDStatus\n"));
4124 + status = CD_ERROR;
4126 + if (SendCMD(cdrom, Cmd, sizeof(Cmd)) == 0)
4128 + struct MyCDROM *entry = (struct MyCDROM *)CDList[cdrom->id];
4131 + buf = (UBYTE *)entry->inbuf;
4133 + D(bug("CDRom : Status : %02X,%02X\n", buf[0],buf[1]));
4137 + case 0x11: status = CD_PLAYING; break;
4138 + case 0x12: status = CD_PAUSED; break;
4139 + case 0x13: status = CD_STOPPED; break;
4140 + case 0x14: status = CD_ERROR; break;
4141 + default: status = CD_STOPPED; break;
4149 +#if !defined(PROTO_SDL_H)
4150 +static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
4152 +static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length, struct SDLBase *SDLBase)
4155 + UBYTE Cmd[12] = { 0xa5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
4156 + UWORD *tmp = (UWORD *)Cmd;
4158 + D(bug("CDRom : SDL_SYS_CDPlay\n"));
4160 + tmp[1] = AROS_BE2WORD(start >> 16);
4161 + tmp[2] = AROS_BE2WORD(start);
4162 + tmp[3] = AROS_BE2WORD(length >> 16);
4163 + tmp[4] = AROS_BE2WORD(length);
4165 + SendCMD(cdrom, Cmd, sizeof(Cmd));
4169 +#if !defined(PROTO_SDL_H)
4170 +static int SDL_SYS_CDPause(SDL_CD *cdrom)
4172 +static int SDL_SYS_CDPause(SDL_CD *cdrom, struct SDLBase *SDLBase)
4175 + static const UBYTE Cmd[10] =
4176 + { 0x4b, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
4178 + D(bug("CDRom : SDL_SYS_CDPause\n"));
4180 + SendCMD(cdrom, Cmd, sizeof(Cmd));
4184 +#if !defined(PROTO_SDL_H)
4185 +static int SDL_SYS_CDResume(SDL_CD *cdrom)
4187 +static int SDL_SYS_CDResume(SDL_CD *cdrom, struct SDLBase *SDLBase)
4190 + static const UBYTE Cmd[10] = { 0x4b, 0, 0, 0, 0, 0, 0, 0, 1, 0 };
4192 + D(bug("CDRom : SDL_SYS_CDResume\n"));
4194 + SendCMD(cdrom, Cmd, sizeof(Cmd));
4198 +#if !defined(PROTO_SDL_H)
4199 +static int SDL_SYS_CDStop(SDL_CD *cdrom)
4201 +static int SDL_SYS_CDStop(SDL_CD *cdrom, struct SDLBase *SDLBase)
4204 + static const UBYTE Cmd[10] = { 0x4e, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
4206 + D(bug("CDRom : SDL_SYS_CDStop\n"));
4208 + SendCMD(cdrom, Cmd, sizeof(Cmd));
4212 +#if !defined(PROTO_SDL_H)
4213 +static int SDL_SYS_CDEject(SDL_CD *cdrom)
4215 +static int SDL_SYS_CDEject(SDL_CD *cdrom, struct SDLBase *SDLBase)
4218 + static const UBYTE Cmd[6] =
4219 + { 0x1b, 0, 0, 0, 0x02, 0 };
4221 + D(bug("CDRom : SDL_SYS_CDEject\n"));
4223 + SendCMD(cdrom, (UBYTE *)Cmd, sizeof(Cmd));
4227 +#if !defined(PROTO_SDL_H)
4228 +int SDL_SYS_CDInit(void)
4230 +int SDL_SYS_CDInitI(struct SDLBase *SDLBase)
4233 + struct DosList *dlist;
4237 + D(bug("CDRom : SDL_SYS_CDInit\n"));
4243 + SDL_CDcaps.Name = SDL_SYS_CDName;
4244 + SDL_CDcaps.Open = SDL_SYS_CDOpen;
4245 + SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
4246 + SDL_CDcaps.Status = SDL_SYS_CDStatus;
4247 + SDL_CDcaps.Play = SDL_SYS_CDPlay;
4248 + SDL_CDcaps.Pause = SDL_SYS_CDPause;
4249 + SDL_CDcaps.Resume = SDL_SYS_CDResume;
4250 + SDL_CDcaps.Stop = SDL_SYS_CDStop;
4251 + SDL_CDcaps.Eject = SDL_SYS_CDEject;
4252 + SDL_CDcaps.Close = SDL_SYS_CDClose;
4254 + dlist = LockDosList(LDF_DEVICES|LDF_READ);
4256 + while ((dlist = NextDosEntry(dlist, LDF_DEVICES|LDF_READ)) != NULL && devices < MAX_DRIVES)
4258 + struct FileSysStartupMsg *startup;
4259 + CONST_STRPTR devname;
4262 + startup = BADDR(dlist->dol_misc.dol_handler.dol_Startup);
4263 + if ((IPTR) startup > 0x400 &&
4264 + (startup->fssm_Unit & 0xff000000) == 0 &&
4265 + startup->fssm_Device && startup->fssm_Environ)
4268 + if ((devname = BADDR(startup->fssm_Device)) != NULL)
4270 + if ((devnamelen = CopyStringBSTRToC((BSTR)devname, (STRPTR)devname, 108)) != 0)
4272 + if (FindDup(cdlist, devname, startup->fssm_Unit) == 0)
4274 + struct MyCDROM *entry;
4276 + if ((entry = AllocTaskPooled(sizeof(*entry))) != NULL)
4278 + CONST_STRPTR dosname;
4281 + dosname = (CONST_STRPTR)BADDR(dlist->dol_Name);
4282 + dosnamelen = CopyStringBSTRToC((BSTR)dosname, (STRPTR)dosname, 20);
4284 + entry->unit = startup->fssm_Unit;
4285 + entry->unitflags = startup->fssm_Flags;
4287 + memcpy(entry->dosname, dosname, dosnamelen);
4288 + memcpy(entry->devname, devname, devnamelen);
4290 + entry->dosname[ dosnamelen ] = '\0';
4291 + entry->devname[ devnamelen ] = '\0';
4293 + D(bug("CDRom : devname : %s, dosname %s\n",entry->devname,entry->dosname));
4295 + entry->req = NULL;
4296 + entry->inbuf = NULL;
4297 + entry->sensebuf = NULL;
4299 + cdlist[devices] = (char *)entry;
4308 + UnLockDosList(LDF_DEVICES|LDF_READ);
4312 + struct IOStdReq *req;
4313 + struct SCSICmd *scsicmd;
4314 + struct MsgPort *port;
4316 + UBYTE *inbuf, *sensebuf;
4318 + port = &((struct Process *)FindTask(NULL))->pr_MsgPort;
4320 + if ((req = CreateIORequest(port, sizeof(struct IOStdReq))) != NULL)
4322 + if ((inbuf = AllocTaskPooled(SCSI_INBUF_SIZE)) != NULL)
4324 + if ((sensebuf = AllocTaskPooled(SCSI_SENSE_SIZE)) != NULL)
4326 + if ((scsicmd = (struct SCSICmd *)AllocTaskPooled(sizeof(*scsicmd))) != NULL)
4328 + req->io_Command = HD_SCSICMD;
4329 + req->io_Data = (APTR)scsicmd;
4330 + req->io_Length = sizeof(struct SCSICmd);
4332 + for (i = 0; i < MAX_DRIVES; i++)
4334 + struct MyCDROM *entry;
4337 + entry = (struct MyCDROM *)cdlist[i];
4339 + if (entry == NULL)
4344 + if (OpenDevice(entry->devname, entry->unit, (struct IORequest *)req, entry->unitflags) == 0)
4346 + static const UBYTE Cmd[] = { 0x12, 0, 0, 0, 252, 0 };
4348 + scsicmd->scsi_Data = (UWORD *)inbuf;
4349 + scsicmd->scsi_Length = SCSI_INBUF_SIZE;
4350 + scsicmd->scsi_SenseActual = 0;
4351 + scsicmd->scsi_SenseData = sensebuf;
4352 + scsicmd->scsi_SenseLength = SCSI_SENSE_SIZE;
4353 + scsicmd->scsi_CmdActual = 0;
4354 + scsicmd->scsi_Command = (UBYTE *)Cmd;
4355 + scsicmd->scsi_CmdLength = sizeof(Cmd);
4356 + scsicmd->scsi_Flags = SCSIF_READ | SCSIF_AUTOSENSE;
4358 + DoIO((struct IORequest *)req);
4360 + if (scsicmd->scsi_Status == 0 && req->io_Error == 0)
4362 + /* 5 is for CDROM (maybe not proper checking) */
4363 + /* Must be removable as well*/
4368 + for (i=0;i<2;i++) bug("inbuf[%d] : %04X\n", i, inbuf[i]);
4372 + if (((inbuf[0] & 0x05) == 5) && (inbuf[1] & 0x80))
4375 + D(else bug("CDRom : DoIO error\n"));
4377 + CloseDevice((struct IORequest *)req);
4380 + if (is_cdrom == 0)
4383 + cdlist[i] = cdlist[devices];
4388 + D(bug("CDRom detected\n"));
4392 + FreeTaskPooled(scsicmd, sizeof(*scsicmd));
4395 + FreeTaskPooled(sensebuf, SCSI_SENSE_SIZE);
4398 + FreeTaskPooled(inbuf, SCSI_INBUF_SIZE);
4401 + DeleteIORequest((struct IORequest *)req);
4408 +#if !defined(PROTO_SDL_H)
4409 +void SDL_SYS_CDQuit(void)
4411 +void SDL_SYS_CDQuitI(struct SDLBase *SDLBase)
4414 + D(bug("CDRom : SDL_SYS_CDQuit\n"));
4416 diff -Naur SDL-1.2.15-orig/src/cdrom/aros/SDL_syscdrom.h SDL-1.2.15/src/cdrom/aros/SDL_syscdrom.h
4417 --- SDL-1.2.15-orig/src/cdrom/aros/SDL_syscdrom.h 1970-01-01 01:00:00.000000000 +0100
4418 +++ SDL-1.2.15/src/cdrom/aros/SDL_syscdrom.h 2015-05-09 15:09:59.757739529 +0200
4421 + SDL - Simple DirectMedia Layer
4422 + Copyright (C) 1997-2004 Sam Lantinga
4424 + This library is free software; you can redistribute it and/or
4425 + modify it under the terms of the GNU Library General Public
4426 + License as published by the Free Software Foundation; either
4427 + version 2 of the License, or (at your option) any later version.
4429 + This library is distributed in the hope that it will be useful,
4430 + but WITHOUT ANY WARRANTY; without even the implied warranty of
4431 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4432 + Library General Public License for more details.
4434 + You should have received a copy of the GNU Library General Public
4435 + License along with this library; if not, write to the Free
4436 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4439 + slouken@libsdl.org
4442 +#if defined(PROTO_SDL_H)
4443 +#include "SDL_intern.h"
4446 +/* This is the system specific header for the SDL CD-ROM API */
4449 +#define MAX_DRIVES 32
4452 +/* Structure of CD audio control functions */
4453 +extern struct CDcaps {
4454 +#if !defined(PROTO_SDL_H)
4455 + /* Get the name of the specified drive */
4456 + const char *(*Name)(int drive);
4458 + /* Open the specified drive, returning a drive id, or -1 on error */
4459 + int (*Open)(int drive);
4461 + /* Get table-of-contents (number of tracks + track info) for disk.
4462 + The TOC information should be stored in the cdrom structure.
4463 + This function should return 0 on success, or -1 on error.
4465 + int (*GetTOC)(SDL_CD *cdrom);
4467 + /* Return the current status and play position, in frames, of the
4468 + drive. 'position' may be NULL, and if so, should be ignored.
4470 + CDstatus (*Status)(SDL_CD *cdrom, int *position);
4472 + /* Play from frame 'start' to 'start+len' */
4473 + int (*Play)(SDL_CD *cdrom, int start, int len);
4476 + int (*Pause)(SDL_CD *cdrom);
4479 + int (*Resume)(SDL_CD *cdrom);
4482 + int (*Stop)(SDL_CD *cdrom);
4484 + /* Eject the current disk */
4485 + int (*Eject)(SDL_CD *cdrom);
4487 + /* Close the specified drive */
4488 + void (*Close)(SDL_CD *cdrom);
4490 + const char *(*Name)(int drive, struct SDLBase *SDLBase);
4491 + int (*Open)(int drive, struct SDLBase *SDLBase);
4492 + int (*GetTOC)(SDL_CD *cdrom, struct SDLBase *SDLBase);
4493 + CDstatus (*Status)(SDL_CD *cdrom, int *position, struct SDLBase *SDLBase);
4494 + int (*Play)(SDL_CD *cdrom, int start, int len, struct SDLBase *SDLBase);
4495 + int (*Pause)(SDL_CD *cdrom, struct SDLBase *SDLBase);
4496 + int (*Resume)(SDL_CD *cdrom, struct SDLBase *SDLBase);
4497 + int (*Stop)(SDL_CD *cdrom, struct SDLBase *SDLBase);
4498 + int (*Eject)(SDL_CD *cdrom, struct SDLBase *SDLBase);
4499 + void (*Close)(SDL_CD *cdrom, struct SDLBase *SDLBase);
4503 +#if !defined(PROTO_SDL_H)
4504 +/* The number of available CD-ROM drives on the system */
4505 +extern int SDL_numcds;
4507 +/* Function to scan the system for CD-ROM drives and fill SDL_CDcaps.
4508 + * This function should set SDL_numcds to the number of available CD
4509 + * drives. Drive 0 should be the system default CD-ROM.
4510 + * It should return 0, or -1 on an unrecoverable fatal error.
4512 +extern int SDL_SYS_CDInit(void);
4514 +/* Function to perform any system-specific CD-ROM related cleanup */
4515 +extern void SDL_SYS_CDQuit(void);
4517 +extern int SDL_SYS_CDInitI(struct SDLBase *SDLBase);
4518 +extern void SDL_SYS_CDQuitI(struct SDLBase *SDLBase);
4520 +#define SDL_SYS_CDInit() SDL_SYS_CDInitI(SDLBase)
4521 +#define SDL_SYS_CDQuit() SDL_SYS_CDQuitI(SDLBase)
4524 +#define SDL_numcds SDLBase->SDL_numcds
4527 diff -Naur SDL-1.2.15-orig/src/cdrom/SDL_cdrom.c SDL-1.2.15/src/cdrom/SDL_cdrom.c
4528 --- SDL-1.2.15-orig/src/cdrom/SDL_cdrom.c 2015-05-09 17:47:54.311774220 +0200
4529 +++ SDL-1.2.15/src/cdrom/SDL_cdrom.c 2015-05-09 15:09:59.757739529 +0200
4534 +#if defined (SDL_AROS_SHARED)
4535 +#define __NOLIBBASE__
4536 +#include <proto/SDL.h>
4537 +#include "SDL_intern.h"
4540 #include "SDL_config.h"
4542 /* This is the CD-audio control API for Simple DirectMedia Layer */
4544 #define CLIP_FRAMES 10 /* Some CD-ROMs won't go all the way */
4547 -static int SDL_cdinitted = 0;
4548 -static SDL_CD *default_cdrom;
4550 /* The system level CD-ROM control functions */
4551 struct CDcaps SDL_CDcaps = {
4558 +#if !defined(PROTO_SDL_H)
4559 +static int SDL_cdinitted = 0;
4560 +static SDL_CD *default_cdrom;
4563 +#include "SDL_intern.h"
4565 +#define SDL_cdinitted SDLBase->SDL_cdinitted
4566 +#define default_cdrom SDLBase->default_cdrom
4568 +#define SDL_numcds SDLBase->SDL_numcds
4572 +#if !defined(PROTO_SDL_H)
4573 int SDL_CDROMInit(void)
4575 +int SDL_CDROMInitI(struct SDLBase *SDLBase)
4583 /* Check to see if the CD-ROM subsystem has been initialized */
4584 +#if !defined(PROTO_SDL_H)
4585 static int CheckInit(int check_cdrom, SDL_CD **cdrom)
4587 +#define CheckInit(check_cdrom, cdrom) CheckInitI(check_cdrom, cdrom, SDLBase)
4588 +static int CheckInitI(int check_cdrom, SDL_CD **cdrom, struct SDLBase *SDLBase)
4593 @@ -80,16 +105,34 @@
4597 +#if !defined(PROTO_SDL_H)
4598 int SDL_CDNumDrives(void)
4601 +AROS_LH0(int, SDL_CDNumDrives,
4602 + struct SDLBase *, SDLBase, 146, SDL)
4606 if ( ! CheckInit(0, NULL) ) {
4610 +#if defined(PROTO_SDL_H)
4615 +#if !defined(PROTO_SDL_H)
4616 const char *SDL_CDName(int drive)
4619 +AROS_LH1(const char *, SDL_CDName,
4620 + AROS_LHA(int, drive, D0),
4621 + struct SDLBase *, SDLBase, 147, SDL)
4625 if ( ! CheckInit(0, NULL) ) {
4628 @@ -98,14 +141,29 @@
4631 if ( SDL_CDcaps.Name ) {
4632 +#if !defined(PROTO_SDL_H)
4633 return(SDL_CDcaps.Name(drive));
4635 + return(SDL_CDcaps.Name(drive, SDLBase));
4640 +#if defined(PROTO_SDL_H)
4645 +#if !defined(PROTO_SDL_H)
4646 SDL_CD *SDL_CDOpen(int drive)
4649 +AROS_LH1(SDL_CD *, SDL_CDOpen,
4650 + AROS_LHA(int, drive, D0),
4651 + struct SDLBase *, SDLBase, 148, SDL)
4655 struct SDL_CD *cdrom;
4657 if ( ! CheckInit(0, NULL) ) {
4658 @@ -121,17 +179,32 @@
4661 SDL_memset(cdrom, 0, sizeof(*cdrom));
4662 +#if !defined(PROTO_SDL_H)
4663 cdrom->id = SDL_CDcaps.Open(drive);
4665 + cdrom->id = SDL_CDcaps.Open(drive, SDLBase);
4667 if ( cdrom->id < 0 ) {
4671 default_cdrom = cdrom;
4673 +#if defined(PROTO_SDL_H)
4678 +#if !defined(PROTO_SDL_H)
4679 CDstatus SDL_CDStatus(SDL_CD *cdrom)
4682 +AROS_LH1(CDstatus, SDL_CDStatus,
4683 + AROS_LHA(SDL_CD *, cdrom, A0),
4684 + struct SDLBase *, SDLBase, 149, SDL)
4691 @@ -145,13 +218,21 @@
4692 cdrom->numtracks = 0;
4693 cdrom->cur_track = 0;
4694 cdrom->cur_frame = 0;
4695 +#if !defined(PROTO_SDL_H)
4696 status = SDL_CDcaps.Status(cdrom, &i);
4698 + status = SDL_CDcaps.Status(cdrom, &i, SDLBase);
4700 position = (Uint32)i;
4701 cdrom->status = status;
4703 /* Get the table of contents, if there's a CD available */
4704 if ( CD_INDRIVE(status) ) {
4705 +#if !defined(PROTO_SDL_H)
4706 if ( SDL_CDcaps.GetTOC(cdrom) < 0 ) {
4708 + if ( SDL_CDcaps.GetTOC(cdrom, SDLBase) < 0 ) {
4712 /* If the drive is playing, get current play position */
4713 @@ -169,11 +250,26 @@
4717 +#if defined(PROTO_SDL_H)
4722 +#if !defined(PROTO_SDL_H)
4723 int SDL_CDPlayTracks(SDL_CD *cdrom,
4724 int strack, int sframe, int ntracks, int nframes)
4727 +AROS_LH5(int, SDL_CDPlayTracks,
4728 + AROS_LHA(SDL_CD *, cdrom, A0),
4729 + AROS_LHA(int, strack, D0),
4730 + AROS_LHA(int, sframe, D1),
4731 + AROS_LHA(int, ntracks, D2),
4732 + AROS_LHA(int, nframes, D3),
4733 + struct SDLBase *, SDLBase, 151, SDL)
4740 @@ -236,21 +332,50 @@
4742 fprintf(stderr, "Playing %d frames at offset %d\n", length, start);
4744 +#if !defined(PROTO_SDL_H)
4745 return(SDL_CDcaps.Play(cdrom, start, length));
4747 + return(SDL_CDcaps.Play(cdrom, start, length, SDLBase));
4752 +#if !defined(PROTO_SDL_H)
4753 int SDL_CDPlay(SDL_CD *cdrom, int sframe, int length)
4756 +AROS_LH3(int, SDL_CDPlay,
4757 + AROS_LHA(SDL_CD *, cdrom, A0),
4758 + AROS_LHA(int, sframe, D0),
4759 + AROS_LHA(int, length, D1),
4760 + struct SDLBase *, SDLBase, 150, SDL)
4764 /* Check if the CD-ROM subsystem has been initialized */
4765 if ( ! CheckInit(1, &cdrom) ) {
4769 +#if !defined(PROTO_SDL_H)
4770 return(SDL_CDcaps.Play(cdrom, sframe, length));
4772 + return(SDL_CDcaps.Play(cdrom, sframe, length, SDLBase));
4778 +#if !defined(PROTO_SDL_H)
4779 int SDL_CDPause(SDL_CD *cdrom)
4782 +AROS_LH1(int, SDL_CDPause,
4783 + AROS_LHA(SDL_CD *, cdrom, A0),
4784 + struct SDLBase *, SDLBase, 152, SDL)
4791 @@ -259,20 +384,39 @@
4795 +#if !defined(PROTO_SDL_H)
4796 status = SDL_CDcaps.Status(cdrom, NULL);
4798 + status = SDL_CDcaps.Status(cdrom, NULL, SDLBase);
4802 +#if !defined(PROTO_SDL_H)
4803 retval = SDL_CDcaps.Pause(cdrom);
4805 + retval = SDL_CDcaps.Pause(cdrom, SDLBase);
4813 +#if defined(PROTO_SDL_H)
4818 +#if !defined(PROTO_SDL_H)
4819 int SDL_CDResume(SDL_CD *cdrom)
4822 +AROS_LH1(int, SDL_CDResume,
4823 + AROS_LHA(SDL_CD *, cdrom, A0),
4824 + struct SDLBase *, SDLBase, 153, SDL)
4831 @@ -281,19 +425,38 @@
4835 +#if !defined(PROTO_SDL_H)
4836 status = SDL_CDcaps.Status(cdrom, NULL);
4838 + status = SDL_CDcaps.Status(cdrom, NULL, SDLBase);
4842 +#if !defined(PROTO_SDL_H)
4843 retval = SDL_CDcaps.Resume(cdrom);
4845 + retval = SDL_CDcaps.Resume(cdrom, SDLBase);
4852 +#if defined(PROTO_SDL_H)
4857 +#if !defined(PROTO_SDL_H)
4858 int SDL_CDStop(SDL_CD *cdrom)
4861 +AROS_LH1(int, SDL_CDStop,
4862 + AROS_LHA(SDL_CD *, cdrom, A0),
4863 + struct SDLBase *, SDLBase, 154, SDL)
4870 @@ -302,39 +465,83 @@
4874 +#if !defined(PROTO_SDL_H)
4875 status = SDL_CDcaps.Status(cdrom, NULL);
4877 + status = SDL_CDcaps.Status(cdrom, NULL, SDLBase);
4882 +#if !defined(PROTO_SDL_H)
4883 retval = SDL_CDcaps.Stop(cdrom);
4885 + retval = SDL_CDcaps.Stop(cdrom, SDLBase);
4892 +#if defined(PROTO_SDL_H)
4897 +#if !defined(PROTO_SDL_H)
4898 int SDL_CDEject(SDL_CD *cdrom)
4901 +AROS_LH1(int, SDL_CDEject,
4902 + AROS_LHA(SDL_CD *, cdrom, A0),
4903 + struct SDLBase *, SDLBase, 155, SDL)
4907 /* Check if the CD-ROM subsystem has been initialized */
4908 if ( ! CheckInit(1, &cdrom) ) {
4911 +#if !defined(PROTO_SDL_H)
4912 return(SDL_CDcaps.Eject(cdrom));
4914 + return(SDL_CDcaps.Eject(cdrom, SDLBase));
4920 +#if !defined(PROTO_SDL_H)
4921 void SDL_CDClose(SDL_CD *cdrom)
4924 +AROS_LH1(void, SDL_CDClose,
4925 + AROS_LHA(SDL_CD *, cdrom, A0),
4926 + struct SDLBase *, SDLBase, 156, SDL)
4930 /* Check if the CD-ROM subsystem has been initialized */
4931 if ( ! CheckInit(1, &cdrom) ) {
4934 +#if !defined(PROTO_SDL_H)
4935 SDL_CDcaps.Close(cdrom);
4937 + SDL_CDcaps.Close(cdrom, SDLBase);
4940 default_cdrom = NULL;
4941 +#if defined(PROTO_SDL_H)
4946 +#if !defined(PROTO_SDL_H)
4947 void SDL_CDROMQuit(void)
4949 +void SDL_CDROMQuitI(struct SDLBase *SDLBase)
4954 diff -Naur SDL-1.2.15-orig/src/cdrom/SDL_syscdrom.h SDL-1.2.15/src/cdrom/SDL_syscdrom.h
4955 --- SDL-1.2.15-orig/src/cdrom/SDL_syscdrom.h 2015-05-09 17:47:54.311774220 +0200
4956 +++ SDL-1.2.15/src/cdrom/SDL_syscdrom.h 2015-05-09 15:09:59.758739527 +0200
4959 #include "SDL_config.h"
4961 +#if defined(PROTO_SDL_H)
4962 +#include "SDL_intern.h"
4965 /* This is the system specific header for the SDL CD-ROM API */
4967 /* Structure of CD audio control functions */
4968 extern struct CDcaps {
4969 +#if !defined(PROTO_SDL_H)
4970 /* Get the name of the specified drive */
4971 - const char *(*Name)(int drive);
4972 + const char *(*Name)(int drive);
4974 /* Open the specified drive, returning a drive id, or -1 on error */
4975 int (*Open)(int drive);
4978 /* Close the specified drive */
4979 void (*Close)(SDL_CD *cdrom);
4981 + const char *(*Name)(int drive, struct SDLBase *SDLBase);
4982 + int (*Open)(int drive, struct SDLBase *SDLBase);
4983 + int (*GetTOC)(SDL_CD *cdrom, struct SDLBase *SDLBase);
4984 + CDstatus (*Status)(SDL_CD *cdrom, int *position, struct SDLBase *SDLBase);
4985 + int (*Play)(SDL_CD *cdrom, int start, int len, struct SDLBase *SDLBase);
4986 + int (*Pause)(SDL_CD *cdrom, struct SDLBase *SDLBase);
4987 + int (*Resume)(SDL_CD *cdrom, struct SDLBase *SDLBase);
4988 + int (*Stop)(SDL_CD *cdrom, struct SDLBase *SDLBase);
4989 + int (*Eject)(SDL_CD *cdrom, struct SDLBase *SDLBase);
4990 + void (*Close)(SDL_CD *cdrom, struct SDLBase *SDLBase);
4994 +#if !defined(PROTO_SDL_H)
4995 /* The number of available CD-ROM drives on the system */
4996 extern int SDL_numcds;
5000 /* Function to perform any system-specific CD-ROM related cleanup */
5001 extern void SDL_SYS_CDQuit(void);
5003 +extern int SDL_SYS_CDInitI(struct SDLBase *SDLBase);
5004 +extern void SDL_SYS_CDQuitI(struct SDLBase *SDLBase);
5006 +#define SDL_SYS_CDInit() SDL_SYS_CDInitI(SDLBase)
5007 +#define SDL_SYS_CDQuit() SDL_SYS_CDQuitI(SDLBase)
5009 +#define SDL_numcds SDLBase->SDL_numcds
5012 diff -Naur SDL-1.2.15-orig/src/cpuinfo/SDL_cpuinfo.c SDL-1.2.15/src/cpuinfo/SDL_cpuinfo.c
5013 --- SDL-1.2.15-orig/src/cpuinfo/SDL_cpuinfo.c 2015-05-09 17:47:54.280774303 +0200
5014 +++ SDL-1.2.15/src/cpuinfo/SDL_cpuinfo.c 2015-05-09 15:09:59.758739527 +0200
5019 +#if defined (SDL_AROS_SHARED)
5020 +#define __NOLIBBASE__
5021 +#include <proto/SDL.h>
5024 #include "SDL_config.h"
5026 /* CPU feature detection for SDL */
5031 +#if defined(PROTO_SDL_H)
5032 +#include "SDL_intern.h"
5035 #define CPU_HAS_RDTSC 0x00000001
5036 #define CPU_HAS_MMX 0x00000002
5037 #define CPU_HAS_MMXEXT 0x00000004
5038 @@ -415,68 +424,148 @@
5039 return SDL_CPUFeatures;
5042 +#if !defined(PROTO_SDL_H)
5043 SDL_bool SDL_HasRDTSC(void)
5046 +AROS_LH0(SDL_bool, SDL_HasRDTSC,
5047 + struct SDLBase *, SDLBase, 188, SDL)
5051 if ( SDL_GetCPUFeatures() & CPU_HAS_RDTSC ) {
5055 +#if defined(PROTO_SDL_H)
5060 +#if !defined(PROTO_SDL_H)
5061 SDL_bool SDL_HasMMX(void)
5064 +AROS_LH0(SDL_bool, SDL_HasMMX,
5065 + struct SDLBase *, SDLBase, 189, SDL)
5069 if ( SDL_GetCPUFeatures() & CPU_HAS_MMX ) {
5073 +#if defined(PROTO_SDL_H)
5078 +#if !defined(PROTO_SDL_H)
5079 SDL_bool SDL_HasMMXExt(void)
5082 +AROS_LH0(SDL_bool, SDL_HasMMXExt,
5083 + struct SDLBase *, SDLBase, 192, SDL)
5087 if ( SDL_GetCPUFeatures() & CPU_HAS_MMXEXT ) {
5091 +#if defined(PROTO_SDL_H)
5096 +#if !defined(PROTO_SDL_H)
5097 SDL_bool SDL_Has3DNow(void)
5100 +AROS_LH0(SDL_bool, SDL_Has3DNow,
5101 + struct SDLBase *, SDLBase, 190, SDL)
5105 if ( SDL_GetCPUFeatures() & CPU_HAS_3DNOW ) {
5109 +#if defined(PROTO_SDL_H)
5114 +#if !defined(PROTO_SDL_H)
5115 SDL_bool SDL_Has3DNowExt(void)
5118 +AROS_LH0(SDL_bool, SDL_Has3DNowExt,
5119 + struct SDLBase *, SDLBase, 193, SDL)
5123 if ( SDL_GetCPUFeatures() & CPU_HAS_3DNOWEXT ) {
5127 +#if defined(PROTO_SDL_H)
5132 +#if !defined(PROTO_SDL_H)
5133 SDL_bool SDL_HasSSE(void)
5136 +AROS_LH0(SDL_bool, SDL_HasSSE,
5137 + struct SDLBase *, SDLBase, 191, SDL)
5141 if ( SDL_GetCPUFeatures() & CPU_HAS_SSE ) {
5145 +#if defined(PROTO_SDL_H)
5150 +#if !defined(PROTO_SDL_H)
5151 SDL_bool SDL_HasSSE2(void)
5154 +AROS_LH0(SDL_bool, SDL_HasSSE2,
5155 + struct SDLBase *, SDLBase, 194, SDL)
5159 if ( SDL_GetCPUFeatures() & CPU_HAS_SSE2 ) {
5163 +#if defined(PROTO_SDL_H)
5168 +#if !defined(PROTO_SDL_H)
5169 SDL_bool SDL_HasAltiVec(void)
5172 +AROS_LH0(SDL_bool, SDL_HasAltiVec,
5173 + struct SDLBase *, SDLBase, 187, SDL)
5177 if ( SDL_GetCPUFeatures() & CPU_HAS_ALTIVEC ) {
5181 +#if defined(PROTO_SDL_H)
5187 diff -Naur SDL-1.2.15-orig/src/events/SDL_active.c SDL-1.2.15/src/events/SDL_active.c
5188 --- SDL-1.2.15-orig/src/events/SDL_active.c 2015-05-09 17:47:54.280774303 +0200
5189 +++ SDL-1.2.15/src/events/SDL_active.c 2015-05-09 15:09:59.758739527 +0200
5194 +#if defined (SDL_AROS_SHARED)
5195 +#define __NOLIBBASE__
5196 +#include <proto/SDL.h>
5199 #include "SDL_config.h"
5201 /* Application focus/iconification handling code for SDL */
5205 /* These are static for our active event handling code */
5206 +#if !defined(PROTO_SDL_H)
5207 static Uint8 SDL_appstate = 0;
5209 +#include "SDL_intern.h"
5210 +#define SDL_appstate SDLBase->SDL_appstate
5213 /* Public functions */
5214 +#if !defined(PROTO_SDL_H)
5215 int SDL_AppActiveInit(void)
5217 +int SDL_AppActiveInitI(struct SDLBase *SDLBase)
5220 /* Start completely active */
5221 SDL_appstate = (SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
5226 +#if !defined(PROTO_SDL_H)
5227 void SDL_AppActiveQuit(void)
5229 +void SDL_AppActiveQuitI(struct SDLBase *SDLBase)
5234 +#if !defined(PROTO_SDL_H)
5235 Uint8 SDL_GetAppState(void)
5238 +AROS_LH0(Uint8, SDL_GetAppState,
5239 + struct SDLBase *, SDLBase, 121, SDL)
5243 return(SDL_appstate);
5244 +#if defined(PROTO_SDL_H)
5249 /* This is global for SDL_eventloop.c */
5250 +#if !defined(PROTO_SDL_H)
5251 int SDL_PrivateAppActive(Uint8 gain, Uint8 state)
5253 +int SDL_PrivateAppActiveI(Uint8 gain, Uint8 state, struct SDLBase *SDLBase)
5258 diff -Naur SDL-1.2.15-orig/src/events/SDL_events.c SDL-1.2.15/src/events/SDL_events.c
5259 --- SDL-1.2.15-orig/src/events/SDL_events.c 2015-05-09 17:47:54.280774303 +0200
5260 +++ SDL-1.2.15/src/events/SDL_events.c 2015-05-09 15:09:59.758739527 +0200
5265 +#if defined (SDL_AROS_SHARED)
5266 +#define __NOLIBBASE__
5267 +#include <proto/SDL.h>
5270 #include "SDL_config.h"
5272 /* General event handling code for SDL */
5276 /* Public data -- the event filter */
5277 +#if !defined(PROTO_SDL_H)
5278 SDL_EventFilter SDL_EventOK = NULL;
5279 Uint8 SDL_ProcessEvents[SDL_NUMEVENTS];
5280 static Uint32 SDL_eventstate = 0;
5281 +/* Thread functions */
5282 +static SDL_Thread *SDL_EventThread = NULL; /* Thread handle */
5283 +static Uint32 event_thread; /* The event thread id */
5285 +#include "SDL_intern.h"
5286 +#define SDL_EventOK SDLBase->SDL_EventOK
5287 +#define SDL_ProcessEvents SDLBase->SDL_ProcessEvents
5288 +#define SDL_eventstate SDLBase->SDL_eventstate
5289 +#define SDL_EventThread SDLBase->SDL_EventThread
5290 +#define event_thread SDLBase->event_thread
5292 +#define current_video SDLBase->current_video
5295 /* Private data -- event queue */
5296 #define MAXEVENTS 128
5301 -/* Thread functions */
5302 -static SDL_Thread *SDL_EventThread = NULL; /* Thread handle */
5303 -static Uint32 event_thread; /* The event thread id */
5305 +#if !defined(PROTO_SDL_H)
5306 void SDL_Lock_EventThread(void)
5308 +void SDL_Lock_EventThreadI(struct SDLBase *SDLBase)
5311 if ( SDL_EventThread && (SDL_ThreadID() != event_thread) ) {
5312 /* Grab lock and spin until we're sure event thread stopped */
5317 +#if !defined(PROTO_SDL_H)
5318 void SDL_Unlock_EventThread(void)
5320 +void SDL_Unlock_EventThreadI(struct SDLBase *SDLBase)
5323 if ( SDL_EventThread && (SDL_ThreadID() != event_thread) ) {
5324 SDL_mutexV(SDL_EventLock.lock);
5329 +#if !defined(PROTO_SDL_H)
5330 static int SDLCALL SDL_GobbleEvents(void *unused)
5332 +static int SDLCALL SDL_GobbleEvents(struct SDLBase *SDLBase)
5335 event_thread = SDL_ThreadID();
5337 @@ -104,7 +131,11 @@
5339 /* Get events from the video subsystem */
5341 +#if !defined(PROTO_SDL_H)
5342 video->PumpEvents(this);
5344 + video->PumpEvents(this, SDLBase);
5348 /* Queue pending key-repeat events */
5349 @@ -141,7 +172,12 @@
5353 +#if !defined(PROTO_SDL_H)
5354 static int SDL_StartEventThread(Uint32 flags)
5356 +#define SDL_StartEventThread(flags) SDL_StartEventThreadI(flags, SDLBase)
5357 +static int SDL_StartEventThreadI(Uint32 flags, struct SDLBase *SDLBase)
5360 /* Reset everything to zero */
5361 SDL_EventThread = NULL;
5362 @@ -173,7 +209,11 @@
5363 #undef SDL_CreateThread
5364 SDL_EventThread = SDL_CreateThread(SDL_GobbleEvents, NULL, NULL, NULL);
5366 +#if !defined(PROTO_SDL_H)
5367 SDL_EventThread = SDL_CreateThread(SDL_GobbleEvents, NULL);
5369 + SDL_EventThread = SDL_CreateThread(SDL_GobbleEvents, SDLBase);
5372 if ( SDL_EventThread == NULL ) {
5374 @@ -184,7 +224,12 @@
5378 +#if !defined(PROTO_SDL_H)
5379 static void SDL_StopEventThread(void)
5381 +#define SDL_StopEventThread() SDL_StopEventThreadI(SDLBase)
5382 +static void SDL_StopEventThreadI(struct SDLBase *SDLBase)
5385 SDL_EventQ.active = 0;
5386 if ( SDL_EventThread ) {
5387 @@ -199,14 +244,21 @@
5391 +#if !defined(PROTO_SDL_H)
5392 Uint32 SDL_EventThreadID(void)
5394 +Uint32 SDL_EventThreadIDI(struct SDLBase *SDLBase)
5397 return(event_thread);
5400 /* Public functions */
5402 +#if !defined(PROTO_SDL_H)
5403 void SDL_StopEventLoop(void)
5405 +void SDL_StopEventLoopI(struct SDLBase *SDLBase)
5408 /* Halt the event thread, if running */
5409 SDL_StopEventThread();
5410 @@ -224,7 +276,11 @@
5413 /* This function (and associated calls) may be called more than once */
5414 +#if !defined(PROTO_SDL_H)
5415 int SDL_StartEventLoop(Uint32 flags)
5417 +int SDL_StartEventLoopI(Uint32 flags, struct SDLBase *SDLBase)
5422 @@ -262,7 +318,12 @@
5425 /* Add an event to the event queue -- called with the queue locked */
5426 +#if !defined(PROTO_SDL_H)
5427 static int SDL_AddEvent(SDL_Event *event)
5429 +#define SDL_AddEvent(event) SDL_AddEventI(event, SDLBase)
5430 +static int SDL_AddEventI(SDL_Event *event, struct SDLBase *SDLBase)
5435 @@ -288,7 +349,12 @@
5437 /* Cut an event, and return the next valid spot, or the tail */
5438 /* -- called with the queue locked */
5439 +#if !defined(PROTO_SDL_H)
5440 static int SDL_CutEvent(int spot)
5442 +#define SDL_CutEvent(spot) SDL_CutEventI(spot, SDLBase)
5443 +static int SDL_CutEventI(int spot, struct SDLBase *SDLBase)
5446 if ( spot == SDL_EventQ.head ) {
5447 SDL_EventQ.head = (SDL_EventQ.head+1)%MAXEVENTS;
5448 @@ -316,9 +382,20 @@
5451 /* Lock the event queue, take a peep at it, and unlock it */
5452 +#if !defined(PROTO_SDL_H)
5453 int SDL_PeepEvents(SDL_Event *events, int numevents, SDL_eventaction action,
5457 +AROS_LH4(int, SDL_PeepEvents,
5458 + AROS_LHA(SDL_Event *, events, A0),
5459 + AROS_LHA(int, numevents, D0),
5460 + AROS_LHA(SDL_eventaction, action, D1),
5461 + AROS_LHA(Uint32, mask, D2),
5462 + struct SDLBase *, SDLBase, 86, SDL)
5468 /* Don't look after we've quit */
5469 @@ -362,18 +439,32 @@
5473 +#if defined(PROTO_SDL_H)
5478 /* Run the system dependent event loops */
5479 +#if !defined(PROTO_SDL_H)
5480 void SDL_PumpEvents(void)
5483 +AROS_LH0(void, SDL_PumpEvents,
5484 + struct SDLBase *, SDLBase, 83, SDL)
5488 if ( !SDL_EventThread ) {
5489 SDL_VideoDevice *video = current_video;
5490 SDL_VideoDevice *this = current_video;
5492 /* Get events from the video subsystem */
5494 +#if !defined(PROTO_SDL_H)
5495 video->PumpEvents(this);
5497 + video->PumpEvents(this, SDLBase);
5501 /* Queue pending key-repeat events */
5502 @@ -386,22 +477,43 @@
5506 +#if defined(PROTO_SDL_H)
5511 /* Public functions */
5513 +#if !defined(PROTO_SDL_H)
5514 int SDL_PollEvent (SDL_Event *event)
5517 +AROS_LH1(int, SDL_PollEvent,
5518 + AROS_LHA(SDL_Event *, event, A0),
5519 + struct SDLBase *, SDLBase, 84, SDL)
5525 /* We can't return -1, just return 0 (no event) on error */
5526 if ( SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_ALLEVENTS) <= 0 )
5529 +#if defined(PROTO_SDL_H)
5534 +#if !defined(PROTO_SDL_H)
5535 int SDL_WaitEvent (SDL_Event *event)
5538 +AROS_LH1(int, SDL_WaitEvent,
5539 + AROS_LHA(SDL_Event *, event, A0),
5540 + struct SDLBase *, SDLBase, 85, SDL)
5546 switch(SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_ALLEVENTS)) {
5547 @@ -410,32 +522,77 @@
5548 case 0: SDL_Delay(10);
5551 +#if defined(PROTO_SDL_H)
5556 +#if !defined(PROTO_SDL_H)
5557 int SDL_PushEvent(SDL_Event *event)
5560 +AROS_LH1(int, SDL_PushEvent,
5561 + AROS_LHA(SDL_Event *, event, A0),
5562 + struct SDLBase *, SDLBase, 87, SDL)
5566 if ( SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0) <= 0 )
5569 +#if defined(PROTO_SDL_H)
5574 +#if !defined(PROTO_SDL_H)
5575 void SDL_SetEventFilter (SDL_EventFilter filter)
5578 +AROS_LH1(void, SDL_SetEventFilter,
5579 + AROS_LHA(SDL_EventFilter, filter, D0),
5580 + struct SDLBase *, SDLBase, 88, SDL)
5584 SDL_Event bitbucket;
5586 /* Set filter and discard pending events */
5587 SDL_EventOK = filter;
5588 while ( SDL_PollEvent(&bitbucket) > 0 )
5591 +#if defined(PROTO_SDL_H)
5596 +#if !defined(PROTO_SDL_H)
5597 SDL_EventFilter SDL_GetEventFilter(void)
5600 +AROS_LH0(SDL_EventFilter, SDL_GetEventFilter,
5601 + struct SDLBase *, SDLBase, 89, SDL)
5605 return(SDL_EventOK);
5606 +#if defined(PROTO_SDL_H)
5611 +#if !defined(PROTO_SDL_H)
5612 Uint8 SDL_EventState (Uint8 type, int state)
5615 +AROS_LH2(Uint8, SDL_EventState,
5616 + AROS_LHA(Uint8, type, D0),
5617 + AROS_LHA(int, state, D1),
5618 + struct SDLBase *, SDLBase, 90, SDL)
5622 SDL_Event bitbucket;
5623 Uint8 current_state;
5625 @@ -478,11 +635,18 @@
5628 return(current_state);
5629 +#if defined(PROTO_SDL_H)
5634 /* This is a generic event handler.
5636 +#if !defined(PROTO_SDL_H)
5637 int SDL_PrivateSysWMEvent(SDL_SysWMmsg *message)
5639 +int SDL_PrivateSysWMEventI(SDL_SysWMmsg *message, struct SDLBase *SDLBase)
5644 diff -Naur SDL-1.2.15-orig/src/events/SDL_events_c.h SDL-1.2.15/src/events/SDL_events_c.h
5645 --- SDL-1.2.15-orig/src/events/SDL_events_c.h 2015-05-09 17:47:54.280774303 +0200
5646 +++ SDL-1.2.15/src/events/SDL_events_c.h 2015-05-09 15:09:59.759739525 +0200
5648 /* Useful functions and variables from SDL_events.c */
5649 #include "SDL_events.h"
5651 +#if !defined(PROTO_SDL_H)
5652 /* Start and stop the event processing loop */
5653 extern int SDL_StartEventLoop(Uint32 flags);
5654 extern void SDL_StopEventLoop(void);
5656 /* Used by the event loop to queue pending keyboard repeat events */
5657 extern void SDL_CheckKeyRepeat(void);
5659 +extern int SDL_TranslateUNICODE;
5661 +#include "SDL_intern.h"
5662 +extern int SDL_StartEventLoopI(Uint32 flags, struct SDLBase *SDLBase);
5663 +extern void SDL_StopEventLoopI(struct SDLBase *SDLBase);
5665 +extern void SDL_Lock_EventThreadI(struct SDLBase *SDLBase);
5666 +extern void SDL_Unlock_EventThreadI(struct SDLBase *SDLBase);
5667 +extern Uint32 SDL_EventThreadIDI(struct SDLBase *SDLBase);
5669 +extern int SDL_AppActiveInitI(struct SDLBase *SDLBase);
5670 +extern int SDL_KeyboardInitI(struct SDLBase *SDLBase);
5671 +extern int SDL_MouseInitI(struct SDLBase *SDLBase);
5672 +extern int SDL_QuitInitI(struct SDLBase *SDLBase);
5674 +extern void SDL_AppActiveQuitI(struct SDLBase *SDLBase);
5675 +extern void SDL_KeyboardQuitI(struct SDLBase *SDLBase);
5676 +extern void SDL_MouseQuitI(struct SDLBase *SDLBase);
5677 +extern void SDL_QuitQuitI(struct SDLBase *SDLBase);
5679 +extern int SDL_PrivateAppActiveI(Uint8 gain, Uint8 state, struct SDLBase *SDLBase);
5680 +extern int SDL_PrivateMouseMotionI(Uint8 buttonstate, int relative, Sint16 x, Sint16 y, struct SDLBase *SDLBase);
5681 +extern int SDL_PrivateMouseButtonI(Uint8 state, Uint8 button,Sint16 x,Sint16 y, struct SDLBase *SDLBase);
5682 +extern int SDL_PrivateKeyboardI(Uint8 state, SDL_keysym *key, struct SDLBase *SDLBase);
5683 +extern int SDL_PrivateResizeI(int w, int h, struct SDLBase *SDLBase);
5684 +extern int SDL_PrivateExposeI(struct SDLBase *SDLBase);
5685 +extern int SDL_PrivateQuitI(struct SDLBase *SDLBase);
5686 +extern int SDL_PrivateSysWMEventI(SDL_SysWMmsg *message, struct SDLBase *SDLBase);
5688 +extern void SDL_SetMouseRangeI(int maxX, int maxY, struct SDLBase *SDLBase);
5689 +extern void SDL_ResetMouseI(struct SDLBase *SDLBase);
5690 +extern void SDL_ResetKeyboardI(struct SDLBase *SDLBase);
5691 +extern void SDL_CheckKeyRepeatI(struct SDLBase *SDLBase);
5693 +#define SDL_StartEventLoop(flags) SDL_StartEventLoopI(flags, SDLBase)
5694 +#define SDL_StopEventLoop() SDL_StopEventLoopI(SDLBase)
5696 +#define SDL_Lock_EventThread() SDL_Lock_EventThreadI(SDLBase)
5697 +#define SDL_Unlock_EventThread() SDL_Unlock_EventThreadI(SDLBase)
5698 +#define SDL_EventThreadID() SDL_EventThreadIDI(SDLBase)
5700 +#define SDL_AppActiveInit() SDL_AppActiveInitI(SDLBase)
5701 +#define SDL_KeyboardInit() SDL_KeyboardInitI(SDLBase)
5702 +#define SDL_MouseInit() SDL_MouseInitI(SDLBase)
5703 +#define SDL_QuitInit() SDL_QuitInitI(SDLBase)
5704 +#define SDL_AppActiveQuit() SDL_AppActiveQuitI(SDLBase)
5705 +#define SDL_KeyboardQuit() SDL_KeyboardQuitI(SDLBase)
5706 +#define SDL_MouseQuit() SDL_MouseQuitI(SDLBase)
5707 +#define SDL_QuitQuit() SDL_QuitQuitI(SDLBase)
5708 +#define SDL_PrivateAppActive(gain, state) SDL_PrivateAppActiveI(gain, state, SDLBase)
5709 +#define SDL_PrivateMouseMotion(buttonstate, relative, x, y) SDL_PrivateMouseMotionI(buttonstate, relative, x, y, SDLBase)
5710 +#define SDL_PrivateMouseButton(state, button, x, y) SDL_PrivateMouseButtonI(state, button, x, y, SDLBase)
5711 +#define SDL_PrivateKeyboard(state, key) SDL_PrivateKeyboardI(state, key, SDLBase)
5712 +#define SDL_PrivateResize(w, h) SDL_PrivateResizeI(w, h, SDLBase)
5713 +#define SDL_PrivateExpose() SDL_PrivateExposeI(SDLBase)
5714 +#define SDL_PrivateQuit() SDL_PrivateQuitI(SDLBase)
5715 +#define SDL_PrivateSysWMEvent(message) SDL_PrivateSysWMEventI(message, SDLBase)
5716 +#define SDL_SetMouseRange(maxX, maxY) SDL_SetMouseRangeI(maxX, maxY, SDLBase)
5717 +#define SDL_ResetMouse() SDL_ResetMouseI(SDLBase)
5718 +#define SDL_ResetKeyboard() SDL_ResetKeyboardI(SDLBase)
5719 +#define SDL_CheckKeyRepeat() SDL_CheckKeyRepeatI(SDLBase)
5721 +#define SDL_EventOK SDLBase->SDL_EventOK
5722 +#define SDL_ProcessEvents SDLBase->SDL_ProcessEvents
5723 +#define SDL_TranslateUNICODE SDLBase->SDL_TranslateUNICODE
5726 /* Used by the OS keyboard code to detect whether or not to do UNICODE */
5727 #ifndef DEFAULT_UNICODE_TRANSLATION
5728 #define DEFAULT_UNICODE_TRANSLATION 0 /* Default off because of overhead */
5730 -extern int SDL_TranslateUNICODE;
5731 diff -Naur SDL-1.2.15-orig/src/events/SDL_expose.c SDL-1.2.15/src/events/SDL_expose.c
5732 --- SDL-1.2.15-orig/src/events/SDL_expose.c 2015-05-09 17:47:54.280774303 +0200
5733 +++ SDL-1.2.15/src/events/SDL_expose.c 2015-05-09 15:09:59.759739525 +0200
5738 +#if defined (SDL_AROS_SHARED)
5739 +#define __NOLIBBASE__
5740 +#include <proto/SDL.h>
5743 #include "SDL_config.h"
5745 /* Refresh event handling code for SDL */
5749 /* This is global for SDL_eventloop.c */
5750 +#if !defined(PROTO_SDL_H)
5751 int SDL_PrivateExpose(void)
5753 +int SDL_PrivateExposeI(struct SDLBase *SDLBase)
5757 SDL_Event events[32];
5758 diff -Naur SDL-1.2.15-orig/src/events/SDL_keyboard.c SDL-1.2.15/src/events/SDL_keyboard.c
5759 --- SDL-1.2.15-orig/src/events/SDL_keyboard.c 2015-05-09 17:47:54.280774303 +0200
5760 +++ SDL-1.2.15/src/events/SDL_keyboard.c 2015-05-09 15:09:59.759739525 +0200
5765 +#if defined (SDL_AROS_SHARED)
5766 +#define __NOLIBBASE__
5767 +#include <proto/SDL.h>
5770 #include "SDL_config.h"
5772 /* General keyboard handling code for SDL */
5774 #include "SDL_events_c.h"
5775 #include "SDL_sysevents.h"
5778 +#if !defined(PROTO_SDL_H)
5779 /* Global keystate information */
5780 static Uint8 SDL_KeyState[SDLK_LAST];
5781 static SDLMod SDL_ModState;
5782 int SDL_TranslateUNICODE = 0;
5784 static const char *keynames[SDLK_LAST]; /* Array of keycode names */
5786 +#define SDL_KeyState SDLBase->SDL_KeyState
5787 +#define SDL_ModState SDLBase->SDL_ModState
5788 +#define SDL_TranslateUNICODE SDLBase->SDL_TranslateUNICODE
5789 +#define keynames SDLBase->keynames
5791 +#define current_video SDLBase->current_video
5797 #define SDL_NLK_NUM 0x02
5799 /* Public functions */
5800 +#if !defined(PROTO_SDL_H)
5801 int SDL_KeyboardInit(void)
5803 +int SDL_KeyboardInitI(struct SDLBase *SDLBase)
5807 SDL_VideoDevice *video = current_video;
5809 SDL_ModState = KMOD_NONE;
5810 SDL_memset((void*)keynames, 0, sizeof(keynames));
5811 SDL_memset(SDL_KeyState, 0, sizeof(SDL_KeyState));
5812 +#if !defined(PROTO_SDL_H)
5813 video->InitOSKeymap(this);
5815 + video->InitOSKeymap(this, SDLBase);
5818 SDL_EnableKeyRepeat(0, 0);
5820 @@ -334,12 +355,20 @@
5824 +#if !defined(PROTO_SDL_H)
5825 void SDL_KeyboardQuit(void)
5827 +void SDL_KeyboardQuitI(struct SDLBase *SDLBase)
5832 /* We lost the keyboard, so post key up messages for all pressed keys */
5833 +#if !defined(PROTO_SDL_H)
5834 void SDL_ResetKeyboard(void)
5836 +void SDL_ResetKeyboardI(struct SDLBase *SDLBase)
5841 @@ -354,8 +383,16 @@
5842 SDL_KeyRepeat.timestamp = 0;
5845 +#if !defined(PROTO_SDL_H)
5846 int SDL_EnableUNICODE(int enable)
5849 +AROS_LH1(int, SDL_EnableUNICODE,
5850 + AROS_LHA(int, enable, D0),
5851 + struct SDLBase *, SDLBase, 107, SDL)
5857 old_mode = SDL_TranslateUNICODE;
5858 @@ -363,25 +400,68 @@
5859 SDL_TranslateUNICODE = enable;
5862 +#if defined(PROTO_SDL_H)
5867 +#if !defined(PROTO_SDL_H)
5868 Uint8 * SDL_GetKeyState (int *numkeys)
5871 +AROS_LH1(Uint8 *, SDL_GetKeyState,
5872 + AROS_LHA(int *, numkeys, A0),
5873 + struct SDLBase *, SDLBase, 109, SDL)
5877 if ( numkeys != (int *)0 )
5878 *numkeys = SDLK_LAST;
5879 return(SDL_KeyState);
5880 +#if defined(PROTO_SDL_H)
5884 +#if !defined(PROTO_SDL_H)
5885 SDLMod SDL_GetModState (void)
5888 +AROS_LH0(SDLMod, SDL_GetModState,
5889 + struct SDLBase *, SDLBase, 110, SDL)
5893 return(SDL_ModState);
5894 +#if defined(PROTO_SDL_H)
5898 +#if !defined(PROTO_SDL_H)
5899 void SDL_SetModState (SDLMod modstate)
5902 +AROS_LH1(void, SDL_SetModState,
5903 + AROS_LHA(SDLMod, modstate, D0),
5904 + struct SDLBase *, SDLBase, 111, SDL)
5908 SDL_ModState = modstate;
5909 +#if defined(PROTO_SDL_H)
5914 +#if !defined(PROTO_SDL_H)
5915 char *SDL_GetKeyName(SDLKey key)
5918 +AROS_LH1(char *, SDL_GetKeyName,
5919 + AROS_LHA(SDLKey, key, D0),
5920 + struct SDLBase *, SDLBase, 112, SDL)
5924 const char *keyname;
5927 @@ -393,10 +473,17 @@
5929 /* FIXME: make this function const in 1.3 */
5930 return (char *)(keyname);
5931 +#if defined(PROTO_SDL_H)
5936 /* These are global for SDL_eventloop.c */
5937 +#if !defined(PROTO_SDL_H)
5938 int SDL_PrivateKeyboard(Uint8 state, SDL_keysym *keysym)
5940 +int SDL_PrivateKeyboardI(Uint8 state, SDL_keysym *keysym, struct SDLBase *SDLBase)
5944 int posted, repeatable;
5945 @@ -570,7 +657,11 @@
5949 +#if !defined(PROTO_SDL_H)
5950 void SDL_CheckKeyRepeat(void)
5952 +void SDL_CheckKeyRepeatI(struct SDLBase *SDLBase)
5955 if ( SDL_KeyRepeat.timestamp ) {
5956 Uint32 now, interval;
5957 @@ -593,8 +684,17 @@
5961 +#if !defined(PROTO_SDL_H)
5962 int SDL_EnableKeyRepeat(int delay, int interval)
5965 +AROS_LH2(int, SDL_EnableKeyRepeat,
5966 + AROS_LHA(int, delay, D0),
5967 + AROS_LHA(int, interval, D1),
5968 + struct SDLBase *, SDLBase, 108, SDL)
5972 if ( (delay < 0) || (interval < 0) ) {
5973 SDL_SetError("keyboard repeat value less than zero");
5976 SDL_KeyRepeat.interval = interval;
5977 SDL_KeyRepeat.timestamp = 0;
5979 +#if defined(PROTO_SDL_H)
5984 void SDL_GetKeyRepeat(int *delay, int *interval)
5985 diff -Naur SDL-1.2.15-orig/src/events/SDL_mouse.c SDL-1.2.15/src/events/SDL_mouse.c
5986 --- SDL-1.2.15-orig/src/events/SDL_mouse.c 2015-05-09 17:47:54.280774303 +0200
5987 +++ SDL-1.2.15/src/events/SDL_mouse.c 2015-05-09 15:09:59.759739525 +0200
5992 +#if defined (SDL_AROS_SHARED)
5993 +#define __NOLIBBASE__
5994 +#include <proto/SDL.h>
5997 #include "SDL_config.h"
5999 /* General mouse handling code for SDL */
6001 #include "../video/SDL_cursor_c.h"
6002 #include "../video/SDL_sysvideo.h"
6005 +#if !defined(PROTO_SDL_H)
6006 /* These are static for our mouse handling code */
6007 static Sint16 SDL_MouseX = 0;
6008 static Sint16 SDL_MouseY = 0;
6010 static Sint16 SDL_MouseMaxX = 0;
6011 static Sint16 SDL_MouseMaxY = 0;
6012 static Uint8 SDL_ButtonState = 0;
6014 +#define SDL_MouseX SDLBase->SDL_MouseX
6015 +#define SDL_MouseY SDLBase->SDL_MouseY
6016 +#define SDL_DeltaX SDLBase->SDL_DeltaX
6017 +#define SDL_DeltaY SDLBase->SDL_DeltaY
6018 +#define SDL_MouseMaxX SDLBase->SDL_MouseMaxX
6019 +#define SDL_MouseMaxY SDLBase->SDL_MouseMaxY
6020 +#define SDL_ButtonState SDLBase->SDL_ButtonState
6022 +#define current_video SDLBase->current_video
6025 /* Public functions */
6026 +#if !defined(PROTO_SDL_H)
6027 int SDL_MouseInit(void)
6029 +int SDL_MouseInitI(struct SDLBase *SDLBase)
6032 /* The mouse is at (0,0) */
6038 +#if !defined(PROTO_SDL_H)
6039 void SDL_MouseQuit(void)
6041 +void SDL_MouseQuitI(struct SDLBase *SDLBase)
6046 /* We lost the mouse, so post button up messages for all pressed buttons */
6047 +#if !defined(PROTO_SDL_H)
6048 void SDL_ResetMouse(void)
6050 +void SDL_ResetMouseI(struct SDLBase *SDLBase)
6054 for ( i = 0; i < sizeof(SDL_ButtonState)*8; ++i ) {
6059 +#if !defined(PROTO_SDL_H)
6060 Uint8 SDL_GetMouseState (int *x, int *y)
6063 +AROS_LH2(Uint8, SDL_GetMouseState,
6064 + AROS_LHA(int *, x, A0),
6065 + AROS_LHA(int *, y, A1),
6066 + struct SDLBase *, SDLBase, 113, SDL)
6073 @@ -78,10 +114,22 @@
6076 return(SDL_ButtonState);
6077 +#if defined(PROTO_SDL_H)
6082 +#if !defined(PROTO_SDL_H)
6083 Uint8 SDL_GetRelativeMouseState (int *x, int *y)
6086 +AROS_LH2(Uint8, SDL_GetRelativeMouseState,
6087 + AROS_LHA(int *, x, A0),
6088 + AROS_LHA(int *, y, A1),
6089 + struct SDLBase *, SDLBase, 114, SDL)
6099 return(SDL_ButtonState);
6100 +#if defined(PROTO_SDL_H)
6105 +#if !defined(PROTO_SDL_H)
6106 static void ClipOffset(Sint16 *x, Sint16 *y)
6108 +#define ClipOffset(x, y) ClipOffsetI(x, y, SDLBase)
6109 +static void ClipOffsetI(Sint16 *x, Sint16 *y, struct SDLBase *SDLBase)
6112 /* This clips absolute mouse coordinates when the apparent
6113 display surface is smaller than the real display surface.
6114 @@ -103,14 +159,22 @@
6118 +#if !defined(PROTO_SDL_H)
6119 void SDL_SetMouseRange(int maxX, int maxY)
6121 +void SDL_SetMouseRangeI(int maxX, int maxY, struct SDLBase *SDLBase)
6124 SDL_MouseMaxX = (Sint16)maxX;
6125 SDL_MouseMaxY = (Sint16)maxY;
6128 /* These are global for SDL_eventloop.c */
6129 +#if !defined(PROTO_SDL_H)
6130 int SDL_PrivateMouseMotion(Uint8 buttonstate, int relative, Sint16 x, Sint16 y)
6132 +int SDL_PrivateMouseMotionI(Uint8 buttonstate, int relative, Sint16 x, Sint16 y, struct SDLBase *SDLBase)
6137 @@ -194,7 +258,11 @@
6141 +#if !defined(PROTO_SDL_H)
6142 int SDL_PrivateMouseButton(Uint8 state, Uint8 button, Sint16 x, Sint16 y)
6144 +int SDL_PrivateMouseButtonI(Uint8 state, Uint8 button, Sint16 x, Sint16 y, struct SDLBase *SDLBase)
6149 diff -Naur SDL-1.2.15-orig/src/events/SDL_quit.c SDL-1.2.15/src/events/SDL_quit.c
6150 --- SDL-1.2.15-orig/src/events/SDL_quit.c 2015-05-09 17:47:54.280774303 +0200
6151 +++ SDL-1.2.15/src/events/SDL_quit.c 2015-05-09 15:09:59.759739525 +0200
6156 +#if defined (SDL_AROS_SHARED)
6157 +#define __NOLIBBASE__
6158 +#include <proto/SDL.h>
6161 #include "SDL_config.h"
6163 /* General quit handling code for SDL */
6165 signal(sig, SDL_HandleSIG);
6167 /* Signal a quit interrupt */
6168 +#if !defined(PROTO_SDL_H)
6171 + // FIXME: Call SDL_PrivateQuit()
6174 #endif /* HAVE_SIGNAL_H */
6176 /* Public functions */
6177 +#if !defined(PROTO_SDL_H)
6178 int SDL_QuitInit(void)
6180 +int SDL_QuitInitI(struct SDLBase *SDLBase)
6183 #ifdef HAVE_SIGACTION
6184 struct sigaction action;
6189 +#if !defined(PROTO_SDL_H)
6190 void SDL_QuitQuit(void)
6192 +void SDL_QuitQuitI(struct SDLBase *SDLBase)
6195 #ifdef HAVE_SIGACTION
6196 struct sigaction action;
6197 @@ -107,7 +124,11 @@
6200 /* This function returns 1 if it's okay to close the application window */
6201 +#if !defined(PROTO_SDL_H)
6202 int SDL_PrivateQuit(void)
6204 +int SDL_PrivateQuitI(struct SDLBase *SDLBase)
6209 diff -Naur SDL-1.2.15-orig/src/events/SDL_resize.c SDL-1.2.15/src/events/SDL_resize.c
6210 --- SDL-1.2.15-orig/src/events/SDL_resize.c 2015-05-09 17:47:54.280774303 +0200
6211 +++ SDL-1.2.15/src/events/SDL_resize.c 2015-05-09 15:09:59.759739525 +0200
6216 +#if defined (SDL_AROS_SHARED)
6217 +#define __NOLIBBASE__
6218 +#include <proto/SDL.h>
6221 #include "SDL_config.h"
6223 /* Resize event handling code for SDL */
6225 #include "SDL_events_c.h"
6226 #include "../video/SDL_sysvideo.h"
6228 +/* This is global for SDL_eventloop.c */
6229 +#if !defined(PROTO_SDL_H)
6231 /* Keep the last resize event so we don't post duplicates */
6237 -/* This is global for SDL_eventloop.c */
6238 int SDL_PrivateResize(int w, int h)
6240 +#include "SDL_intern.h"
6242 +#define last_resize SDLBase->last_resize
6243 +#define current_video SDLBase->current_video
6245 +int SDL_PrivateResizeI(int w, int h, struct SDLBase *SDLBase)
6249 SDL_Event events[32];
6250 diff -Naur SDL-1.2.15-orig/src/file/SDL_rwops.c SDL-1.2.15/src/file/SDL_rwops.c
6251 --- SDL-1.2.15-orig/src/file/SDL_rwops.c 2015-05-09 17:47:54.353774110 +0200
6252 +++ SDL-1.2.15/src/file/SDL_rwops.c 2015-05-09 15:09:59.760739523 +0200
6257 +#if defined (SDL_AROS_SHARED)
6258 +#define __NOLIBBASE__
6259 +#include <proto/SDL.h>
6262 #include "SDL_config.h"
6264 /* This file provides a general interface for SDL to read and write
6266 #include "SDL_endian.h"
6267 #include "SDL_rwops.h"
6269 +#if defined(PROTO_SDL_H)
6270 +#include "SDL_intern.h"
6273 #if defined(__WIN32__) && !defined(__SYMBIAN32__)
6277 static int SDLCALL stdio_seek(SDL_RWops *context, int offset, int whence)
6279 +#if defined(PROTO_SDL_H)
6280 + struct Library __unused *SDLBase = context->SDLLib;
6282 if ( fseek(context->hidden.stdio.fp, offset, whence) == 0 ) {
6283 return(ftell(context->hidden.stdio.fp));
6287 static int SDLCALL stdio_read(SDL_RWops *context, void *ptr, int size, int maxnum)
6289 +#if defined(PROTO_SDL_H)
6290 + struct Library __unused *SDLBase = context->SDLLib;
6294 nread = fread(ptr, size, maxnum, context->hidden.stdio.fp);
6297 static int SDLCALL stdio_write(SDL_RWops *context, const void *ptr, int size, int num)
6299 +#if defined(PROTO_SDL_H)
6300 + struct Library __unused *SDLBase = context->SDLLib;
6304 nwrote = fwrite(ptr, size, num, context->hidden.stdio.fp);
6307 static int SDLCALL stdio_close(SDL_RWops *context)
6309 +#if defined(PROTO_SDL_H)
6310 + struct Library __unused *SDLBase = context->SDLLib;
6313 if ( context->hidden.stdio.autoclose ) {
6314 /* WARNING: Check the return value here! */
6315 @@ -360,12 +380,14 @@
6319 -#endif /* !HAVE_STDIO_H */
6320 +#endif /* HAVE_STDIO_H */
6322 /* Functions to read/write memory pointers */
6324 static int SDLCALL mem_seek(SDL_RWops *context, int offset, int whence)
6326 +#if defined(PROTO_SDL_H)
6327 + struct Library __unused *SDLBase = context->SDLLib;
6334 static int SDLCALL mem_read(SDL_RWops *context, void *ptr, int size, int maxnum)
6336 +#if defined(PROTO_SDL_H)
6337 + struct Library __unused *SDLBase = context->SDLLib;
6340 size_t mem_available;
6344 static int SDLCALL mem_write(SDL_RWops *context, const void *ptr, int size, int num)
6346 +#if defined(PROTO_SDL_H)
6347 + struct Library __unused *SDLBase = context->SDLLib;
6349 if ( (context->hidden.mem.here + (num*size)) > context->hidden.mem.stop ) {
6350 num = (context->hidden.mem.stop-context->hidden.mem.here)/size;
6352 @@ -422,11 +450,17 @@
6354 static int SDLCALL mem_writeconst(SDL_RWops *context, const void *ptr, int size, int num)
6356 +#if defined(PROTO_SDL_H)
6357 + struct Library __unused *SDLBase = context->SDLLib;
6359 SDL_SetError("Can't write to read-only memory");
6362 static int SDLCALL mem_close(SDL_RWops *context)
6364 +#if defined(PROTO_SDL_H)
6365 + struct Library __unused *SDLBase = context->SDLLib;
6368 SDL_FreeRW(context);
6370 @@ -480,8 +514,17 @@
6372 #endif /* __MACOS__ */
6374 +#if !defined(PROTO_SDL_H)
6375 SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
6378 +AROS_LH2(SDL_RWops *, SDL_RWFromFile,
6379 + AROS_LHA(const char *, file, A0),
6380 + AROS_LHA(const char *, mode, A1),
6381 + struct SDLBase *, SDLBase, 17, SDL)
6385 SDL_RWops *rwops = NULL;
6388 @@ -526,11 +569,23 @@
6389 #endif /* !HAVE_STDIO_H */
6392 +#if defined(PROTO_SDL_H)
6398 +#if !defined(PROTO_SDL_H)
6399 SDL_RWops *SDL_RWFromFP(FILE *fp, int autoclose)
6402 +AROS_LH2(SDL_RWops *, SDL_RWFromFP,
6403 + AROS_LHA(FILE *, fp, A0),
6404 + AROS_LHA(int, autoclose, D0),
6405 + struct SDLBase *, SDLBase, 18, SDL)
6409 SDL_RWops *rwops = NULL;
6411 rwops = SDL_AllocRW();
6412 @@ -543,11 +598,23 @@
6413 rwops->hidden.stdio.autoclose = autoclose;
6416 +#if defined(PROTO_SDL_H)
6420 #endif /* HAVE_STDIO_H */
6422 +#if !defined(PROTO_SDL_H)
6423 SDL_RWops *SDL_RWFromMem(void *mem, int size)
6426 +AROS_LH2(SDL_RWops *, SDL_RWFromMem,
6427 + AROS_LHA(void *, mem, A0),
6428 + AROS_LHA(int, size, D0),
6429 + struct SDLBase *, SDLBase, 19, SDL)
6435 rwops = SDL_AllocRW();
6436 @@ -561,9 +628,16 @@
6437 rwops->hidden.mem.stop = rwops->hidden.mem.base+size;
6440 +#if defined(PROTO_SDL_H)
6445 +#if !defined(PROTO_SDL_H)
6446 SDL_RWops *SDL_RWFromConstMem(const void *mem, int size)
6448 +SDL_RWops *SDL_RWFromConstMem(const void *mem, int size, struct SDLBase *SDLBase)
6453 @@ -580,94 +654,256 @@
6457 +#if !defined(PROTO_SDL_H)
6458 SDL_RWops *SDL_AllocRW(void)
6461 +AROS_LH0(SDL_RWops *, SDL_AllocRW,
6462 + struct Library *, SDLBase, 20, SDL)
6468 area = (SDL_RWops *)SDL_malloc(sizeof *area);
6469 if ( area == NULL ) {
6472 +#if defined(PROTO_SDL_H)
6473 + area->SDLLib = SDLBase;
6476 +#if defined(PROTO_SDL_H)
6481 +#if !defined(PROTO_SDL_H)
6482 void SDL_FreeRW(SDL_RWops *area)
6485 +AROS_LH1(void, SDL_FreeRW,
6486 + AROS_LHA(SDL_RWops *, area, A0),
6487 + struct SDLBase *, SDLBase, 21, SDL)
6492 +#if defined(PROTO_SDL_H)
6497 /* Functions for dynamically reading and writing endian-specific values */
6499 +#if !defined(PROTO_SDL_H)
6500 Uint16 SDL_ReadLE16 (SDL_RWops *src)
6503 +AROS_LH1(Uint16, SDL_ReadLE16,
6504 + AROS_LHA(SDL_RWops *, src, A0),
6505 + struct SDLBase *, SDLBase, 175, SDL)
6511 SDL_RWread(src, &value, (sizeof value), 1);
6512 return(SDL_SwapLE16(value));
6513 +#if defined(PROTO_SDL_H)
6517 +#if !defined(PROTO_SDL_H)
6518 Uint16 SDL_ReadBE16 (SDL_RWops *src)
6521 +AROS_LH1(Uint16, SDL_ReadBE16,
6522 + AROS_LHA(SDL_RWops *, src, A0),
6523 + struct SDLBase *, SDLBase, 176, SDL)
6529 SDL_RWread(src, &value, (sizeof value), 1);
6530 return(SDL_SwapBE16(value));
6531 +#if defined(PROTO_SDL_H)
6535 +#if !defined(PROTO_SDL_H)
6536 Uint32 SDL_ReadLE32 (SDL_RWops *src)
6539 +AROS_LH1(Uint32, SDL_ReadLE32,
6540 + AROS_LHA(SDL_RWops *, src, A0),
6541 + struct SDLBase *, SDLBase, 177, SDL)
6547 SDL_RWread(src, &value, (sizeof value), 1);
6548 return(SDL_SwapLE32(value));
6549 +#if defined(PROTO_SDL_H)
6553 +#if !defined(PROTO_SDL_H)
6554 Uint32 SDL_ReadBE32 (SDL_RWops *src)
6557 +AROS_LH1(Uint32, SDL_ReadBE32,
6558 + AROS_LHA(SDL_RWops *, src, A0),
6559 + struct SDLBase *, SDLBase, 178, SDL)
6565 SDL_RWread(src, &value, (sizeof value), 1);
6566 return(SDL_SwapBE32(value));
6567 +#if defined(PROTO_SDL_H)
6571 +#if !defined(PROTO_SDL_H)
6572 Uint64 SDL_ReadLE64 (SDL_RWops *src)
6575 +AROS_LH1(Uint64, SDL_ReadLE64,
6576 + AROS_LHA(SDL_RWops *, src, A0),
6577 + struct SDLBase *, SDLBase, 179, SDL)
6583 SDL_RWread(src, &value, (sizeof value), 1);
6584 return(SDL_SwapLE64(value));
6585 +#if defined(PROTO_SDL_H)
6589 +#if !defined(PROTO_SDL_H)
6590 Uint64 SDL_ReadBE64 (SDL_RWops *src)
6593 +AROS_LH1(Uint64, SDL_ReadBE64,
6594 + AROS_LHA(SDL_RWops *, src, A0),
6595 + struct SDLBase *, SDLBase, 180, SDL)
6601 SDL_RWread(src, &value, (sizeof value), 1);
6602 return(SDL_SwapBE64(value));
6603 +#if defined(PROTO_SDL_H)
6608 +#if !defined(PROTO_SDL_H)
6609 int SDL_WriteLE16 (SDL_RWops *dst, Uint16 value)
6612 +AROS_LH2(int, SDL_WriteLE16,
6613 + AROS_LHA(SDL_RWops *, dst, A0),
6614 + AROS_LHA(Uint16, value, D0),
6615 + struct SDLBase *, SDLBase, 181, SDL)
6619 value = SDL_SwapLE16(value);
6620 return(SDL_RWwrite(dst, &value, (sizeof value), 1));
6621 +#if defined(PROTO_SDL_H)
6625 +#if !defined(PROTO_SDL_H)
6626 int SDL_WriteBE16 (SDL_RWops *dst, Uint16 value)
6629 +AROS_LH2(int, SDL_WriteBE16,
6630 + AROS_LHA(SDL_RWops *, dst, A0),
6631 + AROS_LHA(Uint16, value, D0),
6632 + struct SDLBase *, SDLBase, 182, SDL)
6636 value = SDL_SwapBE16(value);
6637 return(SDL_RWwrite(dst, &value, (sizeof value), 1));
6638 +#if defined(PROTO_SDL_H)
6642 +#if !defined(PROTO_SDL_H)
6643 int SDL_WriteLE32 (SDL_RWops *dst, Uint32 value)
6646 +AROS_LH2(int, SDL_WriteLE32,
6647 + AROS_LHA(SDL_RWops *, dst, A0),
6648 + AROS_LHA(Uint32, value, D0),
6649 + struct SDLBase *, SDLBase, 183, SDL)
6653 value = SDL_SwapLE32(value);
6654 return(SDL_RWwrite(dst, &value, (sizeof value), 1));
6655 +#if defined(PROTO_SDL_H)
6659 +#if !defined(PROTO_SDL_H)
6660 int SDL_WriteBE32 (SDL_RWops *dst, Uint32 value)
6663 +AROS_LH2(int, SDL_WriteBE32,
6664 + AROS_LHA(SDL_RWops *, dst, A0),
6665 + AROS_LHA(Uint32, value, D0),
6666 + struct SDLBase *, SDLBase, 184, SDL)
6670 value = SDL_SwapBE32(value);
6671 return(SDL_RWwrite(dst, &value, (sizeof value), 1));
6672 +#if defined(PROTO_SDL_H)
6676 +#if !defined(PROTO_SDL_H)
6677 int SDL_WriteLE64 (SDL_RWops *dst, Uint64 value)
6680 +AROS_LH2(int, SDL_WriteLE64,
6681 + AROS_LHA(SDL_RWops *, dst, A0),
6682 + AROS_LHA(Uint64, value, D0),
6683 + struct SDLBase *, SDLBase, 185, SDL)
6687 value = SDL_SwapLE64(value);
6688 return(SDL_RWwrite(dst, &value, (sizeof value), 1));
6689 +#if defined(PROTO_SDL_H)
6693 +#if !defined(PROTO_SDL_H)
6694 int SDL_WriteBE64 (SDL_RWops *dst, Uint64 value)
6697 +AROS_LH2(int, SDL_WriteBE64,
6698 + AROS_LHA(SDL_RWops *, dst, A0),
6699 + AROS_LHA(Uint64, value, D0),
6700 + struct SDLBase *, SDLBase, 186, SDL)
6704 value = SDL_SwapBE64(value);
6705 return(SDL_RWwrite(dst, &value, (sizeof value), 1));
6706 +#if defined(PROTO_SDL_H)
6710 diff -Naur SDL-1.2.15-orig/src/joystick/aros/SDL_sysjoystick.c SDL-1.2.15/src/joystick/aros/SDL_sysjoystick.c
6711 --- SDL-1.2.15-orig/src/joystick/aros/SDL_sysjoystick.c 1970-01-01 01:00:00.000000000 +0100
6712 +++ SDL-1.2.15/src/joystick/aros/SDL_sysjoystick.c 2015-05-09 15:09:59.760739523 +0200
6715 + SDL - Simple DirectMedia Layer
6716 + Copyright (C) 1997-2004 Sam Lantinga
6718 + This library is free software; you can redistribute it and/or
6719 + modify it under the terms of the GNU Library General Public
6720 + License as published by the Free Software Foundation; either
6721 + version 2 of the License, or (at your option) any later version.
6723 + This library is distributed in the hope that it will be useful,
6724 + but WITHOUT ANY WARRANTY; without even the implied warranty of
6725 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6726 + Library General Public License for more details.
6728 + You should have received a copy of the GNU Library General Public
6729 + License along with this library; if not, write to the Free
6730 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6733 + slouken@libsdl.org
6735 + 20040518 SDL_SYS_JoystickOpen() function fixed
6736 + SetJoyPortAttrs() function added to initialize port
6738 + 20040515 SDL_SYS_JoystickInit() function fixed
6739 + SDL_SYS_JoystickName() function fixed
6740 + SDL_SYS_JoystickQuit() function fixed
6741 + joystick max number (2) removed
6742 + PrivateJoyAxis 2nd parameters inverted!
6744 + 20040505 "inline" include replaced with "proto"
6746 + 20040501 LowlevelBase static declaration removed
6750 +#if defined (SDL_AROS_SHARED)
6751 +#include <proto/exec.h>
6752 +#define __NOLIBBASE__
6753 +#include <proto/SDL.h>
6756 +/* This is the system specific header for the SDL joystick API */
6758 +#include <stdio.h> /* For the definition of NULL */
6760 +#include <libraries/lowlevel.h>
6761 +//#define NO_LOWLEVEL_EXT
6762 +#ifndef NO_LOWLEVEL_EXT
6763 +#include <libraries/lowlevel_ext.h>
6765 +#include <proto/exec.h>
6766 +#include <proto/lowlevel.h>
6767 +#include <proto/graphics.h>
6768 +#include "../../main/aros/mydebug.h"
6771 +extern struct ExecBase *SysBase;
6772 +extern struct GfxBase *GfxBase;
6775 +#include <stdlib.h>
6777 +#include "SDL_events.h"
6778 +#include "SDL_error.h"
6779 +#include "SDL_joystick.h"
6780 +#include "../SDL_sysjoystick.h"
6781 +#include "../SDL_joystick_c.h"
6783 +/* The maximum number of joysticks we'll detect */
6784 +#define MAX_JOYSTICKS 4 /* lowlevel.library is limited to 4 ports */
6786 +/* Directions/Axis differences */
6787 +#define MOS_PLUS 32767 /* was 127, changed by Henes (20040801) */
6788 +#define MOS_MINUS -32768 /* was -127 */
6790 +#ifndef JP_TYPE_ANALOGUE
6791 +#define JP_TYPE_ANALOGUE (14<<28) /* port has analogue joystick */
6792 +#define JP_XAXIS_MASK (255<<0) /* horizontal position */
6793 +#define JP_YAXIS_MASK (255<<8) /* vertical position */
6794 +#define JP_ANALOGUE_PORT_MAGIC (1<<16) /* port offset to force analogue readout */
6797 +/* Function to scan the system for joysticks.
6798 + * This function should set SDL_numjoysticks to the number of available
6799 + * joysticks. Joystick 0 should be the system default joystick.
6800 + * It should return 0, or -1 on an unrecoverable fatal error.
6803 +#if !defined(PROTO_SDL_H)
6804 +struct Library *LowLevelBase = NULL;
6806 +#include "SDL_intern.h"
6807 +#define LowLevelBase SDLBase->LowLevelBase
6810 +unsigned long joybut[] =
6814 + JPF_BUTTON_YELLOW,
6817 + JPF_BUTTON_FORWARD,
6818 + JPF_BUTTON_REVERSE
6827 +struct joystick_hwdata
6830 +#ifndef NO_LOWLEVEL_EXT
6831 + ULONG joystate_ext;
6832 + ULONG supports_analog;
6836 +/* lowlevel portNumber 0 <-> 1 */
6837 +static int PortIndex(int index)
6856 +#if !defined(PROTO_SDL_H)
6857 +int SDL_SYS_JoystickInit(void)
6859 +int SDL_SYS_JoystickInitI(struct SDLBase *SDLBase)
6862 + int numjoysticks = 0;
6863 + unsigned long joyflag = 0L;
6865 + D(bug("SDL_SYS_JoystickInit()\n"));
6869 + if((LowLevelBase = OpenLibrary("lowlevel.library",37)))
6872 + while(numjoysticks < MAX_JOYSTICKS)
6874 + joyflag = ReadJoyPort(PortIndex(numjoysticks));
6876 + if((joyflag&JP_TYPE_MASK) == JP_TYPE_NOTAVAIL)
6884 + return numjoysticks;
6888 + /* failed to open lowlevel.library! */
6889 + SDL_SetError("Unable to open lowlevel.library");
6895 + return SDL_numjoysticks;
6899 +/* Function to get the device-dependent name of a joystick */
6900 +#if !defined(PROTO_SDL_H)
6901 +const char *SDL_SYS_JoystickName(int index)
6903 +const char *SDL_SYS_JoystickNameI(int index, struct SDLBase *SDLBase)
6906 + static char name[64];
6907 + unsigned long joyflag = 0L;
6909 + D(bug("SDL_SYS_JoystickName()\n"));
6913 + memset(name, 0, sizeof(name));
6915 + index = PortIndex(index);
6917 + joyflag = ReadJoyPort(index);
6919 + if((joyflag&JP_TYPE_MASK) == JP_TYPE_NOTAVAIL)
6921 + SDL_SetError("No joystick available with that index");
6926 + if((joyflag&JP_TYPE_MASK) == JP_TYPE_GAMECTLR) sprintf(name, "Port %d is a Game Controller", index);
6927 + if((joyflag&JP_TYPE_MASK) == JP_TYPE_MOUSE) sprintf(name, "Port %d is a Mouse", index);
6928 + if((joyflag&JP_TYPE_MASK) == JP_TYPE_JOYSTK) sprintf(name, "Port %d is a Joystick", index);
6929 + if((joyflag&JP_TYPE_MASK) == JP_TYPE_UNKNOWN) sprintf(name, "Port %d is an unknown device", index);
6935 + SDL_SetError("No joystick available with that index");
6941 +/* Function to open a joystick for use.
6942 + The joystick to open is specified by the index field of the joystick.
6943 + This should fill the nbuttons and naxes fields of the joystick structure.
6944 + It returns 0, or -1 if there is an error.
6946 +#if !defined(PROTO_SDL_H)
6947 +int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
6949 +int SDL_SYS_JoystickOpenI(SDL_Joystick *joystick, struct SDLBase *SDLBase)
6952 + unsigned long temp = 0L;
6954 + D(bug("SDL_SYS_JoystickOpen()"));
6955 + D(bug("Opening joystick %ld\n", joystick->index));
6959 + if(SDL_SYS_JoystickInit() < 1)
6961 + SDL_SetError("Initialize Joysticks first!");
6966 + /* if(!(joystick->hwdata=malloc(sizeof(struct joystick_hwdata)))) */
6967 + joystick->hwdata = (struct joystick_hwdata *) malloc(sizeof(*joystick->hwdata));
6968 + if ( joystick->hwdata == NULL )
6970 + SDL_OutOfMemory();
6974 + memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
6976 + SetJoyPortAttrs(PortIndex(joystick->index), SJA_Type, SJA_TYPE_GAMECTLR, TAG_END);
6978 + temp = ReadJoyPort(PortIndex(joystick->index));
6980 + if((temp & JP_TYPE_MASK)==JP_TYPE_GAMECTLR)
6982 + joystick->nbuttons = 7;
6983 + joystick->nhats = 1;
6985 + else if((temp & JP_TYPE_MASK) == JP_TYPE_JOYSTK)
6987 + joystick->nbuttons = 3;
6988 + joystick->nhats = 1;
6990 + else if((temp & JP_TYPE_MASK) == JP_TYPE_MOUSE)
6992 + joystick->nbuttons = 3;
6993 + joystick->nhats = 0;
6995 + else if((temp & JP_TYPE_MASK) == JP_TYPE_UNKNOWN)
6997 + joystick->nbuttons = 3;
6998 + joystick->nhats = 1;
7000 + else if((temp & JP_TYPE_MASK) == JP_TYPE_NOTAVAIL)
7002 + joystick->nbuttons = 0;
7003 + joystick->nhats = 0;
7006 + joystick->nballs = 0;
7007 + joystick->naxes = 2; /* FIXME: even for JP_TYPE_NOTAVAIL ? */
7008 + joystick->hwdata->joystate = 0L;
7009 +#ifndef NO_LOWLEVEL_EXT
7010 + joystick->hwdata->joystate_ext = 0L;
7012 + if (LowLevelBase->lib_Version > 50 || (LowLevelBase->lib_Version >= 50 && LowLevelBase->lib_Revision >= 17))
7013 + joystick->hwdata->supports_analog = 1;
7019 +/* Function to update the state of a joystick - called as a device poll.
7020 + * This function shouldn't update the joystick structure directly,
7021 + * but instead should call SDL_PrivateJoystick*() to deliver events
7022 + * and update joystick device state.
7024 +#if !defined(PROTO_SDL_H)
7025 +void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
7027 +void SDL_SYS_JoystickUpdateI(SDL_Joystick *joystick, struct SDLBase *SDLBase)
7031 +#ifndef NO_LOWLEVEL_EXT
7032 + ULONG data_ext = 0;
7036 + D(bug("SDL_SYS_JoystickUpdate()\n"));
7040 + if(SDL_SYS_JoystickInit() < 1)
7042 + SDL_SetError("Initialize Joysticks first!");
7048 + data = ReadJoyPort(PortIndex(joystick->index));
7049 +#ifndef NO_LOWLEVEL_EXT
7050 + if (joystick->hwdata->supports_analog)
7051 + data_ext = ReadJoyPort(PortIndex(joystick->index) + JP_ANALOGUE_PORT_MAGIC);
7054 + /* only send an event when something changed */
7057 + if((joystick->hwdata->joystate & JP_DIRECTION_MASK) != (data & JP_DIRECTION_MASK))
7059 + if(joystick->nhats)
7061 + Uint8 value_hat = SDL_HAT_CENTERED;
7063 + if(data & JPF_JOY_DOWN)
7065 + value_hat |= SDL_HAT_DOWN;
7067 + else if(data & JPF_JOY_UP)
7069 + value_hat |= SDL_HAT_UP;
7072 + if(data & JPF_JOY_LEFT)
7074 + value_hat |= SDL_HAT_LEFT;
7076 + else if(data & JPF_JOY_RIGHT)
7078 + value_hat |= SDL_HAT_RIGHT;
7081 + SDL_PrivateJoystickHat(joystick, 0, value_hat);
7086 +#ifndef NO_LOWLEVEL_EXT
7087 + if (joystick->hwdata->supports_analog && data_ext & JP_TYPE_ANALOGUE)
7089 + if((joystick->hwdata->joystate_ext & JP_XAXIS_MASK) != (data_ext & JP_XAXIS_MASK))
7093 + value = (data_ext & JP_XAXIS_MASK) * 2*32767 / 255 - 32767;
7094 + SDL_PrivateJoystickAxis(joystick, 0, value);
7097 + if((joystick->hwdata->joystate_ext & JP_YAXIS_MASK) != (data_ext & JP_YAXIS_MASK))
7101 + value = ((data_ext & JP_YAXIS_MASK)>>8) * 2*32767 / 255 - 32767;
7102 + SDL_PrivateJoystickAxis(joystick, 1, value);
7108 + if((joystick->hwdata->joystate & (JPF_JOY_DOWN|JPF_JOY_UP)) != (data & (JPF_JOY_DOWN|JPF_JOY_UP)))
7112 + /* UP and DOWN direction */
7113 + if(data & JPF_JOY_DOWN)
7117 + else if(data & JPF_JOY_UP)
7119 + value = MOS_MINUS;
7126 + SDL_PrivateJoystickAxis(joystick, 1, value);
7129 + if((joystick->hwdata->joystate & (JPF_JOY_LEFT|JPF_JOY_RIGHT)) != (data & (JPF_JOY_LEFT|JPF_JOY_RIGHT)))
7133 + /* LEFT and RIGHT direction */
7134 + if(data & JPF_JOY_LEFT)
7136 + value = MOS_MINUS;
7138 + else if(data & JPF_JOY_RIGHT)
7147 + SDL_PrivateJoystickAxis(joystick, 0, value);
7152 + for(i = 0; i < joystick->nbuttons; i++)
7154 + if( (data & joybut[i]) )
7159 + data &= ~(joybut[2]);
7162 + if(!(joystick->hwdata->joystate & joybut[i]))
7164 + SDL_PrivateJoystickButton(joystick, i, SDL_PRESSED);
7167 + else if(joystick->hwdata->joystate & joybut[i])
7169 + SDL_PrivateJoystickButton(joystick, i, SDL_RELEASED);
7173 + joystick->hwdata->joystate = data;
7174 +#ifndef NO_LOWLEVEL_EXT
7175 + joystick->hwdata->joystate_ext = data_ext;
7179 +/* Function to close a joystick after use */
7180 +#if !defined(PROTO_SDL_H)
7181 +void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
7183 +void SDL_SYS_JoystickCloseI(SDL_Joystick *joystick, struct SDLBase *SDLBase)
7186 + D(bug("SDL_SYS_JoystickClose()\n"));
7188 + if(LowLevelBase) /* ne to reinitialize */
7190 + SetJoyPortAttrs(PortIndex(joystick->index), SJA_Type, SJA_TYPE_AUTOSENSE, TAG_END);
7193 + if(joystick->hwdata)
7195 + free(joystick->hwdata);
7201 +/* Function to perform any system-specific joystick related cleanup */
7202 +#if !defined(PROTO_SDL_H)
7203 +void SDL_SYS_JoystickQuit(void)
7205 +void SDL_SYS_JoystickQuitI(struct SDLBase *SDLBase)
7208 + D(bug("SDL_SYS_JoystickQuit()\n"));
7212 + CloseLibrary(LowLevelBase);
7213 + LowLevelBase = NULL;
7214 + SDL_numjoysticks = 0;
7220 diff -Naur SDL-1.2.15-orig/src/joystick/SDL_joystick.c SDL-1.2.15/src/joystick/SDL_joystick.c
7221 --- SDL-1.2.15-orig/src/joystick/SDL_joystick.c 2015-05-09 17:47:54.323774189 +0200
7222 +++ SDL-1.2.15/src/joystick/SDL_joystick.c 2015-05-09 15:09:59.760739523 +0200
7227 +#if defined (SDL_AROS_SHARED)
7228 +#define __NOLIBBASE__
7229 +#include <proto/SDL.h>
7232 #include "SDL_config.h"
7234 /* This is the joystick API for Simple DirectMedia Layer */
7236 int SDL_allocatedjoysticks = 0;
7237 SDL_Joystick **SDL_joysticks = NULL;
7239 +#if !defined(PROTO_SDL_H)
7240 int SDL_JoystickInit(void)
7242 +int SDL_JoystickInitI(struct SDLBase *SDLBase)
7249 * Count the number of joysticks attached to the system
7251 +#if !defined(PROTO_SDL_H)
7252 int SDL_NumJoysticks(void)
7255 +AROS_LH0(int, SDL_NumJoysticks,
7256 + struct SDLBase *, SDLBase, 91, SDL)
7260 return SDL_numjoysticks;
7261 +#if defined(PROTO_SDL_H)
7267 * Get the implementation dependent name of a joystick
7269 +#if !defined(PROTO_SDL_H)
7270 const char *SDL_JoystickName(int device_index)
7273 +AROS_LH1(const char *, SDL_JoystickName,
7274 + AROS_LHA(int, device_index, D0),
7275 + struct SDLBase *, SDLBase, 92, SDL)
7279 if ( (device_index < 0) || (device_index >= SDL_numjoysticks) ) {
7280 SDL_SetError("There are %d joysticks available",
7284 return(SDL_SYS_JoystickName(device_index));
7285 +#if defined(PROTO_SDL_H)
7293 * This function returns a joystick identifier, or NULL if an error occurred.
7295 +#if !defined(PROTO_SDL_H)
7296 SDL_Joystick *SDL_JoystickOpen(int device_index)
7299 +AROS_LH1(SDL_Joystick *, SDL_JoystickOpen,
7300 + AROS_LHA(int, device_index, D0),
7301 + struct SDLBase *, SDLBase, 93, SDL)
7306 SDL_Joystick *joystick;
7308 @@ -176,13 +214,24 @@
7309 SDL_Unlock_EventThread();
7312 +#if defined(PROTO_SDL_H)
7318 * Returns 1 if the joystick has been opened, or 0 if it has not.
7320 +#if !defined(PROTO_SDL_H)
7321 int SDL_JoystickOpened(int device_index)
7324 +AROS_LH1(int, SDL_JoystickOpened,
7325 + AROS_LHA(int, device_index, D0),
7326 + struct SDLBase *, SDLBase, 94, SDL)
7333 @@ -193,9 +242,17 @@
7337 +#if defined(PROTO_SDL_H)
7342 +#if !defined(PROTO_SDL_H)
7343 static int ValidJoystick(SDL_Joystick **joystick)
7345 +#define ValidJoystick(joystick) ValidJoystickI(joystick, SDLBase)
7346 +static int ValidJoystickI(SDL_Joystick **joystick, struct SDLBase *SDLBase)
7351 @@ -211,63 +268,127 @@
7353 * Get the device index of an opened joystick.
7355 +#if !defined(PROTO_SDL_H)
7356 int SDL_JoystickIndex(SDL_Joystick *joystick)
7359 +AROS_LH1(int, SDL_JoystickIndex,
7360 + AROS_LHA(SDL_Joystick *, joystick, A0),
7361 + struct SDLBase *, SDLBase, 95, SDL)
7365 if ( ! ValidJoystick(&joystick) ) {
7368 return(joystick->index);
7369 +#if defined(PROTO_SDL_H)
7375 * Get the number of multi-dimensional axis controls on a joystick
7377 +#if !defined(PROTO_SDL_H)
7378 int SDL_JoystickNumAxes(SDL_Joystick *joystick)
7381 +AROS_LH1(int, SDL_JoystickNumAxes,
7382 + AROS_LHA(SDL_Joystick *, joystick, A0),
7383 + struct SDLBase *, SDLBase, 96, SDL)
7387 if ( ! ValidJoystick(&joystick) ) {
7390 return(joystick->naxes);
7391 +#if defined(PROTO_SDL_H)
7397 * Get the number of hats on a joystick
7399 +#if !defined(PROTO_SDL_H)
7400 int SDL_JoystickNumHats(SDL_Joystick *joystick)
7403 +AROS_LH1(int, SDL_JoystickNumHats,
7404 + AROS_LHA(SDL_Joystick *, joystick, A0),
7405 + struct SDLBase *, SDLBase, 98, SDL)
7409 if ( ! ValidJoystick(&joystick) ) {
7412 return(joystick->nhats);
7413 +#if defined(PROTO_SDL_H)
7419 * Get the number of trackballs on a joystick
7421 +#if !defined(PROTO_SDL_H)
7422 int SDL_JoystickNumBalls(SDL_Joystick *joystick)
7425 +AROS_LH1(int, SDL_JoystickNumBalls,
7426 + AROS_LHA(SDL_Joystick *, joystick, A0),
7427 + struct SDLBase *, SDLBase, 97, SDL)
7431 if ( ! ValidJoystick(&joystick) ) {
7434 return(joystick->nballs);
7435 +#if defined(PROTO_SDL_H)
7441 * Get the number of buttons on a joystick
7443 +#if !defined(PROTO_SDL_H)
7444 int SDL_JoystickNumButtons(SDL_Joystick *joystick)
7447 +AROS_LH1(int, SDL_JoystickNumButtons,
7448 + AROS_LHA(SDL_Joystick *, joystick, A0),
7449 + struct SDLBase *, SDLBase, 99, SDL)
7453 if ( ! ValidJoystick(&joystick) ) {
7456 return(joystick->nbuttons);
7457 +#if defined(PROTO_SDL_H)
7463 * Get the current state of an axis control on a joystick
7465 +#if !defined(PROTO_SDL_H)
7466 Sint16 SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis)
7469 +AROS_LH2(Sint16, SDL_JoystickGetAxis,
7470 + AROS_LHA(SDL_Joystick *, joystick, A0),
7471 + AROS_LHA(int, axis, D0),
7472 + struct SDLBase *, SDLBase, 102, SDL)
7478 if ( ! ValidJoystick(&joystick) ) {
7479 @@ -280,13 +401,25 @@
7483 +#if defined(PROTO_SDL_H)
7489 * Get the current state of a hat on a joystick
7491 +#if !defined(PROTO_SDL_H)
7492 Uint8 SDL_JoystickGetHat(SDL_Joystick *joystick, int hat)
7495 +AROS_LH2(Uint8, SDL_JoystickGetHat,
7496 + AROS_LHA(SDL_Joystick *, joystick, A0),
7497 + AROS_LHA(int, hat, D0),
7498 + struct SDLBase *, SDLBase, 103, SDL)
7504 if ( ! ValidJoystick(&joystick) ) {
7505 @@ -299,13 +432,27 @@
7509 +#if defined(PROTO_SDL_H)
7515 * Get the ball axis change since the last poll
7517 +#if !defined(PROTO_SDL_H)
7518 int SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy)
7521 +AROS_LH4(int, SDL_JoystickGetBall,
7522 + AROS_LHA(SDL_Joystick *, joystick, A0),
7523 + AROS_LHA(int, ball, D0),
7524 + AROS_LHA(int *, dx, A1),
7525 + AROS_LHA(int *, dy, A2),
7526 + struct SDLBase *, SDLBase, 104, SDL)
7532 if ( ! ValidJoystick(&joystick) ) {
7533 @@ -327,13 +474,25 @@
7537 +#if defined(PROTO_SDL_H)
7543 * Get the current state of a button on a joystick
7545 +#if !defined(PROTO_SDL_H)
7546 Uint8 SDL_JoystickGetButton(SDL_Joystick *joystick, int button)
7549 +AROS_LH2(Uint8, SDL_JoystickGetButton,
7550 + AROS_LHA(SDL_Joystick *, joystick, A0),
7551 + AROS_LHA(int, button, D0),
7552 + struct SDLBase *, SDLBase, 105, SDL)
7558 if ( ! ValidJoystick(&joystick) ) {
7559 @@ -346,13 +505,24 @@
7563 +#if defined(PROTO_SDL_H)
7569 * Close a joystick previously opened with SDL_JoystickOpen()
7571 +#if !defined(PROTO_SDL_H)
7572 void SDL_JoystickClose(SDL_Joystick *joystick)
7575 +AROS_LH1(void, SDL_JoystickClose,
7576 + AROS_LHA(SDL_Joystick *, joystick, A0),
7577 + struct SDLBase *, SDLBase, 106, SDL)
7583 if ( ! ValidJoystick(&joystick) ) {
7584 @@ -395,9 +565,17 @@
7585 SDL_free(joystick->buttons);
7588 +#if defined(PROTO_SDL_H)
7594 +#if !defined(PROTO_SDL_H)
7595 void SDL_JoystickQuit(void)
7597 +void SDL_JoystickQuitI(struct SDLBase *SDLBase)
7600 const int numsticks = SDL_numjoysticks;
7602 @@ -428,8 +606,11 @@
7605 /* These are global for SDL_sysjoystick.c and SDL_events.c */
7607 +#if !defined(PROTO_SDL_H)
7608 int SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value)
7610 +int SDL_PrivateJoystickAxisI(SDL_Joystick *joystick, Uint8 axis, Sint16 value, struct SDLBase *SDLBase)
7615 @@ -459,7 +640,11 @@
7619 +#if !defined(PROTO_SDL_H)
7620 int SDL_PrivateJoystickHat(SDL_Joystick *joystick, Uint8 hat, Uint8 value)
7622 +int SDL_PrivateJoystickHatI(SDL_Joystick *joystick, Uint8 hat, Uint8 value, struct SDLBase *SDLBase)
7627 @@ -489,8 +674,13 @@
7631 +#if !defined(PROTO_SDL_H)
7632 int SDL_PrivateJoystickBall(SDL_Joystick *joystick, Uint8 ball,
7633 Sint16 xrel, Sint16 yrel)
7635 +int SDL_PrivateJoystickBallI(SDL_Joystick *joystick, Uint8 ball,
7636 + Sint16 xrel, Sint16 yrel, struct SDLBase *SDLBase)
7641 @@ -522,7 +712,11 @@
7645 +#if !defined(PROTO_SDL_H)
7646 int SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state)
7648 +int SDL_PrivateJoystickButtonI(SDL_Joystick *joystick, Uint8 button, Uint8 state, struct SDLBase *SDLBase)
7652 #if !SDL_EVENTS_DISABLED
7653 @@ -565,17 +759,35 @@
7657 +#if !defined(PROTO_SDL_H)
7658 void SDL_JoystickUpdate(void)
7661 +AROS_LH0(void, SDL_JoystickUpdate,
7662 + struct SDLBase *, SDLBase, 100, SDL)
7668 for ( i=0; SDL_joysticks[i]; ++i ) {
7669 SDL_SYS_JoystickUpdate(SDL_joysticks[i]);
7671 +#if defined(PROTO_SDL_H)
7676 +#if !defined(PROTO_SDL_H)
7677 int SDL_JoystickEventState(int state)
7680 +AROS_LH1(int, SDL_JoystickEventState,
7681 + AROS_LHA(int, state, D0),
7682 + struct SDLBase *, SDLBase, 101, SDL)
7686 #if SDL_EVENTS_DISABLED
7692 #endif /* SDL_EVENTS_DISABLED */
7693 +#if defined(PROTO_SDL_H)
7697 diff -Naur SDL-1.2.15-orig/src/joystick/SDL_joystick_c.h SDL-1.2.15/src/joystick/SDL_joystick_c.h
7698 --- SDL-1.2.15-orig/src/joystick/SDL_joystick_c.h 2015-05-09 17:47:54.312774218 +0200
7699 +++ SDL-1.2.15/src/joystick/SDL_joystick_c.h 2015-05-09 15:09:59.760739523 +0200
7701 extern Uint8 SDL_numjoysticks;
7703 /* Internal event queueing functions */
7704 +#if !defined(PROTO_SDL_H)
7705 extern int SDL_PrivateJoystickAxis(SDL_Joystick *joystick,
7706 Uint8 axis, Sint16 value);
7707 extern int SDL_PrivateJoystickBall(SDL_Joystick *joystick,
7709 Uint8 hat, Uint8 value);
7710 extern int SDL_PrivateJoystickButton(SDL_Joystick *joystick,
7711 Uint8 button, Uint8 state);
7713 +#include "SDL_intern.h"
7714 +extern int SDL_PrivateJoystickAxisI(SDL_Joystick *joystick,
7715 + Uint8 axis, Sint16 value, struct SDLBase *SDLBase);
7716 +extern int SDL_PrivateJoystickBallI(SDL_Joystick *joystick,
7717 + Uint8 ball, Sint16 xrel, Sint16 yrel, struct SDLBase *SDLBase);
7718 +extern int SDL_PrivateJoystickHatI(SDL_Joystick *joystick,
7719 + Uint8 hat, Uint8 value, struct SDLBase *SDLBase);
7720 +extern int SDL_PrivateJoystickButtonI(SDL_Joystick *joystick,
7721 + Uint8 button, Uint8 state, struct SDLBase *SDLBase);
7723 +#define SDL_PrivateJoystickAxis(joystick, axis, value) SDL_PrivateJoystickAxisI(joystick, axis, value, SDLBase)
7724 +#define SDL_PrivateJoystickBall(joystick, ball, xrel, yrel) SDL_PrivateJoystickBallI(joystick, ball, xrel, yrel, SDLBase)
7725 +#define SDL_PrivateJoystickHat(joystick, hat, value) SDL_PrivateJoystickHatI(joystick, hat, value, SDLBase)
7726 +#define SDL_PrivateJoystickButton(joystick, button, state) SDL_PrivateJoystickButtonI(joystick, button, state, SDLBase)
7728 diff -Naur SDL-1.2.15-orig/src/joystick/SDL_sysjoystick.h SDL-1.2.15/src/joystick/SDL_sysjoystick.h
7729 --- SDL-1.2.15-orig/src/joystick/SDL_sysjoystick.h 2015-05-09 17:47:54.312774218 +0200
7730 +++ SDL-1.2.15/src/joystick/SDL_sysjoystick.h 2015-05-09 15:09:59.761739521 +0200
7732 * This function should return the number of available joysticks, or -1
7733 * on an unrecoverable fatal error.
7735 +#if !defined(PROTO_SDL_H)
7736 extern int SDL_SYS_JoystickInit(void);
7738 /* Function to get the device-dependent name of a joystick */
7739 extern const char *SDL_SYS_JoystickName(int index);
7741 /* Function to open a joystick for use.
7742 The joystick to open is specified by the index field of the joystick.
7743 This should fill the nbuttons and naxes fields of the joystick structure.
7744 It returns 0, or -1 if there is an error.
7746 extern int SDL_SYS_JoystickOpen(SDL_Joystick *joystick);
7748 /* Function to update the state of a joystick - called as a device poll.
7749 * This function shouldn't update the joystick structure directly,
7750 * but instead should call SDL_PrivateJoystick*() to deliver events
7751 * and update joystick device state.
7753 extern void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick);
7755 /* Function to close a joystick after use */
7756 extern void SDL_SYS_JoystickClose(SDL_Joystick *joystick);
7758 /* Function to perform any system-specific joystick related cleanup */
7759 extern void SDL_SYS_JoystickQuit(void);
7762 +#include "SDL_intern.h"
7763 +extern int SDL_SYS_JoystickInitI(struct SDLBase *SDLBase);
7764 +extern const char *SDL_SYS_JoystickNameI(int index, struct SDLBase *SDLBase);
7765 +extern int SDL_SYS_JoystickOpenI(SDL_Joystick *joystick, struct SDLBase *SDLBase);
7766 +extern void SDL_SYS_JoystickUpdateI(SDL_Joystick *joystick, struct SDLBase *SDLBase);
7767 +extern void SDL_SYS_JoystickCloseI(SDL_Joystick *joystick, struct SDLBase *SDLBase);
7768 +extern void SDL_SYS_JoystickQuitI(struct SDLBase *SDLBase);
7770 +#define SDL_SYS_JoystickInit() SDL_SYS_JoystickInitI(SDLBase)
7771 +#define SDL_SYS_JoystickName(index) SDL_SYS_JoystickNameI(index, SDLBase)
7772 +#define SDL_SYS_JoystickOpen(joystick) SDL_SYS_JoystickOpenI(joystick, SDLBase)
7773 +#define SDL_SYS_JoystickUpdate(joystick) SDL_SYS_JoystickUpdateI(joystick, SDLBase)
7774 +#define SDL_SYS_JoystickClose(joystick) SDL_SYS_JoystickCloseI(joystick, SDLBase)
7775 +#define SDL_SYS_JoystickQuit() SDL_SYS_JoystickQuitI(SDLBase)
7777 diff -Naur SDL-1.2.15-orig/src/loadso/dummy/SDL_sysloadso.c SDL-1.2.15/src/loadso/dummy/SDL_sysloadso.c
7778 --- SDL-1.2.15-orig/src/loadso/dummy/SDL_sysloadso.c 2015-05-09 17:47:54.311774220 +0200
7779 +++ SDL-1.2.15/src/loadso/dummy/SDL_sysloadso.c 2015-05-09 15:09:59.761739521 +0200
7784 +#if defined (SDL_AROS_SHARED)
7785 +#define __NOLIBBASE__
7786 +#include <proto/SDL.h>
7789 #include "SDL_config.h"
7791 #if defined(SDL_LOADSO_DUMMY) || defined(SDL_LOADSO_DISABLED)
7794 #include "SDL_loadso.h"
7796 +#if !defined(PROTO_SDL_H)
7797 void *SDL_LoadObject(const char *sofile)
7799 +void *SDL_LoadObject(const char *sofile, struct Library *SDLBase)
7802 const char *loaderror = "SDL_LoadObject() not implemented";
7803 SDL_SetError("Failed loading %s: %s", sofile, loaderror);
7807 +#if !defined(PROTO_SDL_H)
7808 void *SDL_LoadFunction(void *handle, const char *name)
7810 +void *SDL_LoadFunction(void *handle, const char *name, struct Library *SDLBase)
7813 const char *loaderror = "SDL_LoadFunction() not implemented";
7814 SDL_SetError("Failed loading %s: %s", name, loaderror);
7818 +#if !defined(PROTO_SDL_H)
7819 void SDL_UnloadObject(void *handle)
7821 +void SDL_UnloadObject(void *handle, struct Library *SDLBase)
7826 diff -Naur SDL-1.2.15-orig/src/main/aros/mydebug.h SDL-1.2.15/src/main/aros/mydebug.h
7827 --- SDL-1.2.15-orig/src/main/aros/mydebug.h 1970-01-01 01:00:00.000000000 +0100
7828 +++ SDL-1.2.15/src/main/aros/mydebug.h 2015-05-09 15:09:59.761739521 +0200
7832 +#ifndef AROS_DEBUG_H
7833 +#include <aros/debug.h>
7835 +#define MAKE_HIT() {char *a=NULL,b;b=*a;}
7838 diff -Naur SDL-1.2.15-orig/src/SDL.c SDL-1.2.15/src/SDL.c
7839 --- SDL-1.2.15-orig/src/SDL.c 2015-05-09 17:47:54.323774189 +0200
7840 +++ SDL-1.2.15/src/SDL.c 2015-05-09 15:09:59.761739521 +0200
7845 +#if defined (SDL_AROS_SHARED)
7846 +#define __NOLIBBASE__
7847 +#include <proto/SDL.h>
7850 #include "SDL_config.h"
7852 /* Initialization code for SDL */
7857 +#if !defined(PROTO_SDL_H)
7858 /* Initialization/Cleanup routines */
7859 #if !SDL_JOYSTICK_DISABLED
7860 extern int SDL_JoystickInit(void);
7862 extern int SDL_TimerInit(void);
7863 extern void SDL_TimerQuit(void);
7866 -/* The current SDL version */
7867 -static SDL_version version =
7868 - { SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL };
7870 /* The initialized subsystems */
7871 static Uint32 SDL_initialized = 0;
7872 #if !SDL_TIMERS_DISABLED
7873 static Uint32 ticks_started = 0;
7877 int surfaces_allocated = 0;
7880 +#include "SDL_intern.h"
7882 +#if !SDL_JOYSTICK_DISABLED
7883 +extern int SDL_JoystickInitI(struct SDLBase *SDLBase);
7884 +extern void SDL_JoystickQuitI(struct SDLBase *SDLBase);
7885 +#define SDL_JoystickInit() SDL_JoystickInitI(SDLBase)
7886 +#define SDL_JoystickQuit() SDL_JoystickQuitI(SDLBase)
7888 +#if !SDL_CDROM_DISABLED
7889 +extern int SDL_CDROMInitI(struct SDLBase *SDLBase);
7890 +extern void SDL_CDROMQuitI(struct SDLBase *SDLBase);
7891 +#define SDL_CDROMInit() SDL_CDROMInitI(SDLBase)
7892 +#define SDL_CDROMQuit() SDL_CDROMQuitI(SDLBase)
7894 +#if !SDL_TIMERS_DISABLED
7895 +extern void SDL_StartTicksI(struct SDLBase *SDLBase);
7896 +extern int SDL_TimerInitI(struct SDLBase *SDLBase);
7897 +extern void SDL_TimerQuitI(struct SDLBase *SDLBase);
7898 +#define SDL_StartTicks() SDL_StartTicksI(SDLBase)
7899 +#define SDL_TimerInit() SDL_TimerInitI(SDLBase)
7900 +#define SDL_TimerQuit() SDL_TimerQuitI(SDLBase)
7903 +#define SDL_initialized SDLBase->SDL_initialized
7904 +#define ticks_started SDLBase->ticks_started
7905 +#define surfaces_allocated SDLBase->surfaces_allocated
7908 +/* The current SDL version */
7909 +static SDL_version version =
7910 + { SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL };
7912 +#if !defined(PROTO_SDL_H)
7913 int SDL_InitSubSystem(Uint32 flags)
7916 +AROS_LH1(int, SDL_InitSubSystem,
7917 + AROS_LHA(Uint32, flags, D0),
7918 + struct SDLBase *, SDLBase, 15, SDL)
7922 #if !SDL_TIMERS_DISABLED
7923 /* Initialize the timer subsystem */
7924 if ( ! ticks_started ) {
7925 @@ -145,10 +185,22 @@
7929 +#if defined(PROTO_SDL_H)
7934 +#if !defined(PROTO_SDL_H)
7935 int SDL_Init(Uint32 flags)
7939 +AROS_LH1(int, SDL_Init,
7940 + AROS_LHA(Uint32, flags, D0),
7941 + struct SDLBase *, SDLBase, 11, SDL)
7945 #if !SDL_THREADS_DISABLED && SDL_THREAD_PTH
7948 @@ -168,10 +220,21 @@
7949 SDL_InstallParachute();
7952 +#if defined(PROTO_SDL_H)
7957 +#if !defined(PROTO_SDL_H)
7958 void SDL_QuitSubSystem(Uint32 flags)
7961 +AROS_LH1(void, SDL_QuitSubSystem,
7962 + AROS_LHA(Uint32, flags, D0),
7963 + struct SDLBase *, SDLBase, 16, SDL)
7967 /* Shut down requested initialized subsystems */
7968 #if !SDL_CDROM_DISABLED
7969 if ( (flags & SDL_initialized & SDL_INIT_CDROM) ) {
7970 @@ -203,18 +266,39 @@
7971 SDL_initialized &= ~SDL_INIT_TIMER;
7974 +#if defined(PROTO_SDL_H)
7979 +#if !defined(PROTO_SDL_H)
7980 Uint32 SDL_WasInit(Uint32 flags)
7983 +AROS_LH1(Uint32, SDL_WasInit,
7984 + AROS_LHA(Uint32, flags, D0),
7985 + struct SDLBase *, SDLBase, 13, SDL)
7990 flags = SDL_INIT_EVERYTHING;
7992 return (SDL_initialized&flags);
7993 +#if defined(PROTO_SDL_H)
7998 +#if !defined(PROTO_SDL_H)
8002 +AROS_LH0(void, SDL_Quit,
8003 + struct SDLBase *, SDLBase, 14, SDL)
8007 /* Quit all subsystems */
8009 printf("[SDL_Quit] : Enter! Calling QuitSubSystem()\n"); fflush(stdout);
8010 @@ -245,13 +329,26 @@
8012 printf("[SDL_Quit] : Returning!\n"); fflush(stdout);
8015 +#if defined(PROTO_SDL_H)
8020 /* Return the library version number */
8021 +#if !defined(PROTO_SDL_H)
8022 const SDL_version * SDL_Linked_Version(void)
8025 +AROS_LH0(const SDL_version *, SDL_Linked_Version,
8026 + struct SDLBase *, SDLBase, 12, SDL)
8032 +#if defined(PROTO_SDL_H)
8037 #if defined(__OS2__)
8038 diff -Naur SDL-1.2.15-orig/src/SDL_error.c SDL-1.2.15/src/SDL_error.c
8039 --- SDL-1.2.15-orig/src/SDL_error.c 2015-05-09 17:47:54.280774303 +0200
8040 +++ SDL-1.2.15/src/SDL_error.c 2015-05-09 15:09:59.761739521 +0200
8045 +#if defined (SDL_AROS_SHARED)
8046 +#define __NOLIBBASE__
8047 +#include <proto/SDL.h>
8050 +#define DEBUG_ERROR
8052 #include "SDL_config.h"
8054 /* Simple error handling in SDL */
8056 #include "SDL_error_c.h"
8058 /* Routine to get the thread-specific error variable */
8059 +#if !defined(PROTO_SDL_H)
8060 #if SDL_THREADS_DISABLED
8061 /* The SDL_arraysize(The ),default (non-thread-safe) global error variable */
8062 static SDL_error SDL_global_error;
8065 extern SDL_error *SDL_GetErrBuf(void);
8066 #endif /* SDL_THREADS_DISABLED */
8068 +#include "SDL_intern.h"
8069 +#define SDL_global_error SDLBase->SDL_global_error
8070 +extern SDL_error *SDL_GetErrBufI(struct SDLBase *SDLBase);
8071 +#define SDL_GetErrBuf() SDL_GetErrBufI(SDLBase)
8074 #define SDL_ERRBUFIZE 1024
8079 /* Public functions */
8080 +#define fetch_arg(ap, type) ((type)(*(ap++)))
8082 +#if !defined(PROTO_SDL_H)
8084 +void SDL_SetErrorA (const char *fmt, CONST IPTR *params)
8088 -void SDL_SetError (const char *fmt, ...)
8089 +AROS_LH2(void, SDL_SetErrorA,
8090 + AROS_LHA(const char *, fmt, A0),
8091 + AROS_LHA(CONST IPTR *, params, A1),
8092 + struct SDLBase *, SDLBase, 122, SDL)
8099 + CONST IPTR *ap = params;
8101 /* Copy in the key, mark error as valid */
8102 error = SDL_GetErrBuf();
8104 SDL_strlcpy((char *)error->key, fmt, sizeof(error->key));
8106 - va_start(ap, fmt);
8109 if ( *fmt++ == '%' ) {
8110 @@ -76,20 +102,20 @@
8113 error->args[error->argc++].value_i =
8115 + fetch_arg(ap, int);
8118 error->args[error->argc++].value_f =
8119 - va_arg(ap, double);
8120 + fetch_arg(ap, double);
8123 error->args[error->argc++].value_ptr =
8124 - va_arg(ap, void *);
8125 + fetch_arg(ap, void *);
8129 int i = error->argc;
8130 - const char *str = va_arg(ap, const char *);
8131 + const char *str = fetch_arg(ap, const char *);
8134 SDL_strlcpy((char *)error->args[i].buf, str, ERR_MAX_STRLEN);
8135 @@ -104,18 +130,24 @@
8141 /* If we are in debug mode, print out an error message */
8143 fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError());
8145 +#if defined(PROTO_SDL_H)
8150 /* This function has a bit more overhead than most error functions
8151 so that it supports internationalization and thread-safe errors.
8153 +#if !defined(PROTO_SDL_H)
8154 char *SDL_GetErrorMsg(char *errstr, unsigned int maxlen)
8156 +#define SDL_GetErrorMsg(errstr, maxlen) SDL_GetErrorMsgI(errstr, maxlen, SDLBase)
8157 +char *SDL_GetErrorMsgI(char *errstr, unsigned int maxlen, struct SDLBase *SDLBase)
8162 @@ -184,24 +216,52 @@
8165 /* Available for backwards compatibility */
8166 +#if !defined(PROTO_SDL_H)
8167 char *SDL_GetError (void)
8170 +AROS_LH0(char *, SDL_GetError,
8171 + struct SDLBase *, SDLBase, 123, SDL)
8175 static char errmsg[SDL_ERRBUFIZE];
8177 return((char *)SDL_GetErrorMsg(errmsg, SDL_ERRBUFIZE));
8178 +#if defined(PROTO_SDL_H)
8183 +#if !defined(PROTO_SDL_H)
8184 void SDL_ClearError(void)
8187 +AROS_LH0(void, SDL_ClearError,
8188 + struct SDLBase *, SDLBase, 124, SDL)
8194 error = SDL_GetErrBuf();
8196 +#if defined(PROTO_SDL_H)
8201 /* Very common errors go here */
8202 +#if !defined(PROTO_SDL_H)
8203 void SDL_Error(SDL_errorcode code)
8206 +AROS_LH1(void, SDL_Error,
8207 + AROS_LHA(SDL_errorcode, code, D0),
8208 + struct SDLBase *, SDLBase, 168, SDL)
8214 SDL_SetError("Out of memory");
8216 SDL_SetError("Unknown SDL error");
8219 +#if defined(PROTO_SDL_H)
8225 diff -Naur SDL-1.2.15-orig/src/SDL_fatal.c SDL-1.2.15/src/SDL_fatal.c
8226 --- SDL-1.2.15-orig/src/SDL_fatal.c 2015-05-09 17:47:54.323774189 +0200
8227 +++ SDL-1.2.15/src/SDL_fatal.c 2015-05-09 15:09:59.761739521 +0200
8232 +#if defined (SDL_AROS_SHARED)
8233 +#define __NOLIBBASE__
8234 +#include <proto/SDL.h>
8237 #include "SDL_config.h"
8239 /* General fatal signal handling code for SDL */
8241 static void SDL_Parachute(int sig)
8243 signal(sig, SIG_DFL);
8244 +#if !defined(PROTO_SDL_H)
8247 + // FIXME: Call SDL_Quit()
8252 diff -Naur SDL-1.2.15-orig/src/stdlib/SDL_getenv.c SDL-1.2.15/src/stdlib/SDL_getenv.c
8253 --- SDL-1.2.15-orig/src/stdlib/SDL_getenv.c 2015-05-09 17:47:54.353774110 +0200
8254 +++ SDL-1.2.15/src/stdlib/SDL_getenv.c 2015-05-09 15:09:59.762739519 +0200
8259 +#if defined (SDL_AROS_SHARED)
8260 +#define __NOLIBBASE__
8261 +#include <proto/SDL.h>
8264 #include "SDL_config.h"
8266 #include "SDL_stdinc.h"
8267 diff -Naur SDL-1.2.15-orig/src/stdlib/SDL_iconv.c SDL-1.2.15/src/stdlib/SDL_iconv.c
8268 --- SDL-1.2.15-orig/src/stdlib/SDL_iconv.c 2015-05-09 17:47:54.353774110 +0200
8269 +++ SDL-1.2.15/src/stdlib/SDL_iconv.c 2015-05-09 15:09:59.762739519 +0200
8274 +#if defined (SDL_AROS_SHARED)
8275 +#define __NOLIBBASE__
8276 +#include <proto/SDL.h>
8279 #include "SDL_config.h"
8281 /* This file contains portable iconv functions for SDL */
8288 size_t SDL_iconv(SDL_iconv_t cd,
8289 const char **inbuf, size_t *inbytesleft,
8290 char **outbuf, size_t *outbytesleft)
8293 -#ifdef ICONV_INBUF_NONCONST
8294 +#if defined(ICONV_INBUF_NONCONST) || defined(__AROS__)
8295 retCode = iconv(cd, (char **)inbuf, inbytesleft, outbuf, outbytesleft);
8297 retCode = iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft);
8298 @@ -812,8 +819,19 @@
8300 #endif /* !HAVE_ICONV */
8302 +#if !defined(PROTO_SDL_H)
8303 char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft)
8306 +AROS_LH4(char *, SDL_iconv_string,
8307 + AROS_LHA(const char *, tocode, A0),
8308 + AROS_LHA(const char *, fromcode, A1),
8309 + AROS_LHA(const char *, inbuf, A2),
8310 + AROS_LHA(size_t, inbytesleft, D0),
8311 + struct SDLBase *, SDLBase, 195, SDL)
8319 SDL_iconv_close(cd);
8322 +#if defined(PROTO_SDL_H)
8326 diff -Naur SDL-1.2.15-orig/src/stdlib/SDL_malloc.c SDL-1.2.15/src/stdlib/SDL_malloc.c
8327 --- SDL-1.2.15-orig/src/stdlib/SDL_malloc.c 2015-05-09 17:47:54.353774110 +0200
8328 +++ SDL-1.2.15/src/stdlib/SDL_malloc.c 2015-05-09 15:09:59.762739519 +0200
8333 +#if defined (SDL_AROS_SHARED)
8334 +#define __NOLIBBASE__
8335 +#include <proto/SDL.h>
8338 #include "SDL_config.h"
8340 /* This file contains portable memory management functions for SDL */
8341 diff -Naur SDL-1.2.15-orig/src/stdlib/SDL_qsort.c SDL-1.2.15/src/stdlib/SDL_qsort.c
8342 --- SDL-1.2.15-orig/src/stdlib/SDL_qsort.c 2015-05-09 17:47:54.353774110 +0200
8343 +++ SDL-1.2.15/src/stdlib/SDL_qsort.c 2015-05-09 15:09:59.763739517 +0200
8346 * Gareth McCaughan Peterhouse Cambridge 1998
8348 + #if defined (SDL_AROS_SHARED)
8349 +#define __NOLIBBASE__
8350 +#include <proto/SDL.h>
8353 #include "SDL_config.h"
8356 diff -Naur SDL-1.2.15-orig/src/stdlib/SDL_stdlib.c SDL-1.2.15/src/stdlib/SDL_stdlib.c
8357 --- SDL-1.2.15-orig/src/stdlib/SDL_stdlib.c 2015-05-09 17:47:54.353774110 +0200
8358 +++ SDL-1.2.15/src/stdlib/SDL_stdlib.c 2015-05-09 15:09:59.763739517 +0200
8363 +#if defined (SDL_AROS_SHARED)
8364 +#define __NOLIBBASE__
8365 +#include <proto/SDL.h>
8368 #include "SDL_config.h"
8370 /* This file contains portable stdlib functions for SDL */
8371 diff -Naur SDL-1.2.15-orig/src/stdlib/SDL_string.c SDL-1.2.15/src/stdlib/SDL_string.c
8372 --- SDL-1.2.15-orig/src/stdlib/SDL_string.c 2015-05-09 17:47:54.353774110 +0200
8373 +++ SDL-1.2.15/src/stdlib/SDL_string.c 2015-05-09 15:09:59.763739517 +0200
8378 +#if defined (SDL_AROS_SHARED)
8379 +#define __NOLIBBASE__
8380 +#include <proto/SDL.h>
8383 #include "SDL_config.h"
8385 /* This file contains portable string manipulation functions for SDL */
8386 diff -Naur SDL-1.2.15-orig/src/thread/aros/SDL_syscond.c SDL-1.2.15/src/thread/aros/SDL_syscond.c
8387 --- SDL-1.2.15-orig/src/thread/aros/SDL_syscond.c 1970-01-01 01:00:00.000000000 +0100
8388 +++ SDL-1.2.15/src/thread/aros/SDL_syscond.c 2015-05-09 15:09:59.763739517 +0200
8391 + SDL - Simple DirectMedia Layer
8392 + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
8394 + This library is free software; you can redistribute it and/or
8395 + modify it under the terms of the GNU Library General Public
8396 + License as published by the Free Software Foundation; either
8397 + version 2 of the License, or (at your option) any later version.
8399 + This library is distributed in the hope that it will be useful,
8400 + but WITHOUT ANY WARRANTY; without even the implied warranty of
8401 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8402 + Library General Public License for more details.
8404 + You should have received a copy of the GNU Library General Public
8405 + License along with this library; if not, write to the Free
8406 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8409 + slouken@libsdl.org
8411 + An implementation of condition variables using semaphores and mutexes
8413 + This implementation borrows heavily from the BeOS condition variable
8414 + implementation, written by Christopher Tate and Owen Smith. Thanks!
8417 + yannick.erb@free.fr
8419 + 20110326 Adapted for AROS
8422 +#if defined (SDL_AROS_SHARED)
8423 +#define __NOLIBBASE__
8424 +#include <proto/SDL.h>
8428 +#include <stdlib.h>
8430 +#include "SDL_error.h"
8431 +#include "SDL_thread.h"
8440 + SDL_sem *wait_sem;
8441 + SDL_sem *wait_done;
8444 +/* Create a condition variable */
8445 +#if !defined(PROTO_SDL_H)
8446 +SDL_cond * SDL_CreateCond(void)
8449 +AROS_LH0(SDL_cond *, SDL_CreateCond,
8450 + struct SDLBase *, SDLBase, 169, SDL)
8456 + cond = (SDL_cond *) malloc(sizeof(SDL_cond));
8458 + cond->lock = SDL_CreateMutex();
8459 + cond->wait_sem = SDL_CreateSemaphore(0);
8460 + cond->wait_done = SDL_CreateSemaphore(0);
8461 + cond->waiting = cond->signals = 0;
8462 + if ( ! cond->lock || ! cond->wait_sem || ! cond->wait_done ) {
8463 + SDL_DestroyCond(cond);
8467 + SDL_OutOfMemory();
8470 +#if defined(PROTO_SDL_H)
8475 +/* Destroy a condition variable */
8476 +#if !defined(PROTO_SDL_H)
8477 +void SDL_DestroyCond(SDL_cond *cond)
8480 +AROS_LH1(void, SDL_DestroyCond,
8481 + AROS_LHA(SDL_cond *, cond, A0),
8482 + struct SDLBase *, SDLBase, 170, SDL)
8487 + if ( cond->wait_sem ) {
8488 + SDL_DestroySemaphore(cond->wait_sem);
8490 + if ( cond->wait_done ) {
8491 + SDL_DestroySemaphore(cond->wait_done);
8493 + if ( cond->lock ) {
8494 + SDL_DestroyMutex(cond->lock);
8498 +#if defined(PROTO_SDL_H)
8503 +/* Restart one of the threads that are waiting on the condition variable */
8504 +#if !defined(PROTO_SDL_H)
8505 +int SDL_CondSignal(SDL_cond *cond)
8508 +AROS_LH1(int, SDL_CondSignal,
8509 + AROS_LHA(SDL_cond *, cond, A0),
8510 + struct SDLBase *, SDLBase, 171, SDL)
8515 + SDL_SetError("Passed a NULL condition variable");
8519 + /* If there are waiting threads not already signalled, then
8520 + signal the condition and wait for the thread to respond.
8522 + SDL_LockMutex(cond->lock);
8523 + if ( cond->waiting > cond->signals ) {
8525 + SDL_SemPost(cond->wait_sem);
8526 + SDL_UnlockMutex(cond->lock);
8527 + SDL_SemWait(cond->wait_done);
8529 + SDL_UnlockMutex(cond->lock);
8533 +#if defined(PROTO_SDL_H)
8538 +/* Restart all threads that are waiting on the condition variable */
8539 +#if !defined(PROTO_SDL_H)
8540 +int SDL_CondBroadcast(SDL_cond *cond)
8543 +AROS_LH1(int, SDL_CondBroadcast,
8544 + AROS_LHA(SDL_cond *, cond, A0),
8545 + struct SDLBase *, SDLBase, 172, SDL)
8550 + SDL_SetError("Passed a NULL condition variable");
8554 + /* If there are waiting threads not already signalled, then
8555 + signal the condition and wait for the thread to respond.
8557 + SDL_LockMutex(cond->lock);
8558 + if ( cond->waiting > cond->signals ) {
8559 + int i, num_waiting;
8561 + num_waiting = (cond->waiting - cond->signals);
8562 + cond->signals = cond->waiting;
8563 + for ( i=0; i<num_waiting; ++i ) {
8564 + SDL_SemPost(cond->wait_sem);
8566 + /* Now all released threads are blocked here, waiting for us.
8567 + Collect them all (and win fabulous prizes!) :-)
8569 + SDL_UnlockMutex(cond->lock);
8570 + for ( i=0; i<num_waiting; ++i ) {
8571 + SDL_SemWait(cond->wait_done);
8574 + SDL_UnlockMutex(cond->lock);
8578 +#if defined(PROTO_SDL_H)
8583 +/* Wait on the condition variable for at most 'ms' milliseconds.
8584 + The mutex must be locked before entering this function!
8585 + The mutex is unlocked during the wait, and locked again after the wait.
8590 + SDL_LockMutex(lock);
8591 + while ( ! condition ) {
8592 + SDL_CondWait(cond);
8594 + SDL_UnlockMutex(lock);
8597 + SDL_LockMutex(lock);
8601 + SDL_UnlockMutex(lock);
8603 +#if !defined(PROTO_SDL_H)
8604 +int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
8607 +AROS_LH3(int, SDL_CondWaitTimeout,
8608 + AROS_LHA(SDL_cond *, cond, A0),
8609 + AROS_LHA(SDL_mutex *, mutex, A1),
8610 + AROS_LHA(Uint32, ms, D0),
8611 + struct SDLBase *, SDLBase, 173, SDL)
8618 + SDL_SetError("Passed a NULL condition variable");
8622 + /* Obtain the protection mutex, and increment the number of waiters.
8623 + This allows the signal mechanism to only perform a signal if there
8624 + are waiting threads.
8626 + SDL_LockMutex(cond->lock);
8628 + SDL_UnlockMutex(cond->lock);
8630 + /* Unlock the mutex, as is required by condition variable semantics */
8631 + SDL_UnlockMutex(mutex);
8633 + /* Wait for a signal */
8634 + if ( ms == SDL_MUTEX_MAXWAIT ) {
8635 + retval = SDL_SemWait(cond->wait_sem);
8637 + retval = SDL_SemWaitTimeout(cond->wait_sem, ms);
8640 + /* Let the signaler know we have completed the wait, otherwise
8641 + the signaler can race ahead and get the condition semaphore
8642 + if we are stopped between the mutex unlock and semaphore wait,
8643 + giving a deadlock. See the following URL for details:
8644 + http://www-classic.be.com/aboutbe/benewsletter/volume_III/Issue40.html
8646 + SDL_LockMutex(cond->lock);
8647 + if ( cond->signals > 0 ) {
8648 + /* If we timed out, we need to eat a condition signal */
8649 + if ( retval > 0 ) {
8650 + SDL_SemWait(cond->wait_sem);
8652 + /* We always notify the signal thread that we are done */
8653 + SDL_SemPost(cond->wait_done);
8655 + /* Signal handshake complete */
8659 + SDL_UnlockMutex(cond->lock);
8661 + /* Lock the mutex, as is required by condition variable semantics */
8662 + SDL_LockMutex(mutex);
8665 +#if defined(PROTO_SDL_H)
8670 +/* Wait on the condition variable forever */
8671 +#if !defined(PROTO_SDL_H)
8672 +int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex)
8675 +AROS_LH2(int, SDL_CondWait,
8676 + AROS_LHA(SDL_cond *, cond, A0),
8677 + AROS_LHA(SDL_mutex *, mutex, A1),
8678 + struct SDLBase *, SDLBase, 174, SDL)
8682 + return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT);
8683 +#if defined(PROTO_SDL_H)
8687 diff -Naur SDL-1.2.15-orig/src/thread/aros/SDL_sysmutex.c SDL-1.2.15/src/thread/aros/SDL_sysmutex.c
8688 --- SDL-1.2.15-orig/src/thread/aros/SDL_sysmutex.c 1970-01-01 01:00:00.000000000 +0100
8689 +++ SDL-1.2.15/src/thread/aros/SDL_sysmutex.c 2015-05-09 15:09:59.763739517 +0200
8692 + SDL - Simple DirectMedia Layer
8693 + Copyright (C) 1997-2006 Sam Lantinga
8695 + This library is SDL_free software; you can redistribute it and/or
8696 + modify it under the terms of the GNU Lesser General Public
8697 + License as published by the Free Software Foundation; either
8698 + version 2.1 of the License, or (at your option) any later version.
8700 + This library is distributed in the hope that it will be useful,
8701 + but WITHOUT ANY WARRANTY; without even the implied warranty of
8702 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8703 + Lesser General Public License for more details.
8705 + You should have received a copy of the GNU Lesser General Public
8706 + License along with this library; if not, write to the Free Software
8707 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
8710 + slouken@libsdl.org
8712 +#if defined (SDL_AROS_SHARED)
8713 +#define __NOLIBBASE__
8714 +#include <proto/SDL.h>
8717 +#include "SDL_config.h"
8719 +/* An implementation of mutexes using semaphores */
8721 +#include "SDL_error.h"
8722 +#include "SDL_thread.h"
8723 +#include "SDL_systhread_c.h"
8733 +/* Create a mutex */
8734 +#if !defined(PROTO_SDL_H)
8735 +SDL_mutex *SDL_CreateMutex(void)
8738 +AROS_LH0(SDL_mutex *, SDL_CreateMutex,
8739 + struct SDLBase *, SDLBase, 157, SDL)
8745 + /* Allocate mutex memory */
8746 + mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
8748 + /* Create the mutex semaphore, with initial value 1 */
8749 + mutex->sem = SDL_CreateSemaphore(1);
8750 + mutex->recursive = 0;
8752 + if ( ! mutex->sem ) {
8757 + SDL_OutOfMemory();
8760 +#if defined(PROTO_SDL_H)
8765 +/* Free the mutex */
8766 +#if !defined(PROTO_SDL_H)
8767 +void SDL_DestroyMutex(SDL_mutex *mutex)
8770 +AROS_LH1(void, SDL_DestroyMutex,
8771 + AROS_LHA(SDL_mutex *, mutex, A0),
8772 + struct SDLBase *, SDLBase, 158, SDL)
8777 + if ( mutex->sem ) {
8778 + SDL_DestroySemaphore(mutex->sem);
8782 +#if defined(PROTO_SDL_H)
8787 +/* Lock the semaphore */
8788 +#if !defined(PROTO_SDL_H)
8789 +int SDL_mutexP(SDL_mutex *mutex)
8792 +AROS_LH1(int, SDL_mutexP,
8793 + AROS_LHA(SDL_mutex *, mutex, A0),
8794 + struct SDLBase *, SDLBase, 159, SDL)
8798 +#ifdef DISABLE_THREADS
8801 + Uint32 this_thread;
8803 + if ( mutex == NULL ) {
8804 + SDL_SetError("Passed a NULL mutex");
8808 + this_thread = SDL_ThreadID();
8809 + if ( mutex->owner == this_thread ) {
8810 + ++mutex->recursive;
8812 + /* The order of operations is important.
8813 + We set the locking thread id after we obtain the lock
8814 + so unlocks from other threads will fail.
8816 + SDL_SemWait(mutex->sem);
8817 + mutex->owner = this_thread;
8818 + mutex->recursive = 0;
8822 +#endif /* DISABLE_THREADS */
8823 +#if defined(PROTO_SDL_H)
8828 +/* Unlock the mutex */
8829 +#if !defined(PROTO_SDL_H)
8830 +int SDL_mutexV(SDL_mutex *mutex)
8833 +AROS_LH1(int, SDL_mutexV,
8834 + AROS_LHA(SDL_mutex *, mutex, A0),
8835 + struct SDLBase *, SDLBase, 160, SDL)
8839 +#ifdef DISABLE_THREADS
8842 + if ( mutex == NULL ) {
8843 + SDL_SetError("Passed a NULL mutex");
8847 + /* If we don't own the mutex, we can't unlock it */
8848 + if ( SDL_ThreadID() != mutex->owner ) {
8849 + SDL_SetError("mutex not owned by this thread");
8853 + if ( mutex->recursive ) {
8854 + --mutex->recursive;
8856 + /* The order of operations is important.
8857 + First reset the owner so another thread doesn't lock
8858 + the mutex and set the ownership before we reset it,
8859 + then release the lock semaphore.
8862 + SDL_SemPost(mutex->sem);
8865 +#endif /* DISABLE_THREADS */
8866 +#if defined(PROTO_SDL_H)
8870 diff -Naur SDL-1.2.15-orig/src/thread/aros/SDL_syssem.c SDL-1.2.15/src/thread/aros/SDL_syssem.c
8871 --- SDL-1.2.15-orig/src/thread/aros/SDL_syssem.c 1970-01-01 01:00:00.000000000 +0100
8872 +++ SDL-1.2.15/src/thread/aros/SDL_syssem.c 2015-05-09 15:09:59.764739515 +0200
8875 + SDL - Simple DirectMedia Layer
8876 + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
8877 + Copyright (C) 2004 Harry Sintonen
8879 + This library is free software; you can redistribute it and/or
8880 + modify it under the terms of the GNU Library General Public
8881 + License as published by the Free Software Foundation; either
8882 + version 2 of the License, or (at your option) any later version.
8884 + This library is distributed in the hope that it will be useful,
8885 + but WITHOUT ANY WARRANTY; without even the implied warranty of
8886 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8887 + Library General Public License for more details.
8889 + You should have received a copy of the GNU Library General Public
8890 + License along with this library; if not, write to the Free
8891 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8894 + slouken@libsdl.org
8899 + 20040824 Non-polling SDL_SemWaitTimeout
8902 + 20040822 Reimplementation. Improvements:
8903 + - initial_value != 1 works properly
8904 + - wait can be aborted via CTRL-C
8905 + - doesn't nest per task
8907 + 20040513 SDL_SemTryWait() function return value fixed
8909 + 20040510 ObtainSemaphore inserted in SDL_SemWaitTimeout
8911 + 20040504 Debug lines added
8912 + WarpOS code removed
8915 + yannick.erb@free.fr
8917 + 20110326 Adapted for AROS
8920 +#if defined (SDL_AROS_SHARED)
8921 +#define __NOLIBBASE__
8922 +#include <proto/SDL.h>
8925 +#include <stdlib.h> /* for malloc/free */
8927 +#include "SDL_error.h"
8928 +#include "SDL_thread.h"
8929 +#include "SDL_systhread_c.h"
8930 +#include "../../timer/SDL_systimer.h"
8932 +#include <exec/semaphores.h>
8933 +#include <devices/timer.h>
8934 +#include <dos/dos.h>
8936 +#include "../../main/aros/mydebug.h"
8938 +#if !defined(PROTO_SDL_H)
8939 +extern struct timerequest *TimerIO;
8941 +#include "SDL_intern.h"
8943 +#define TimerIO SDLBase->TimerIO
8948 + struct MinNode node;
8949 + struct Task *task;
8953 +struct SDL_semaphore
8955 + struct SignalSemaphore sem;
8956 + struct MinList waitlist;
8962 + struct MsgPort port;
8963 + struct timerequest timereq;
8968 +#define FALLBACKSIGNAL SIGBREAKB_CTRL_E
8971 +void mywaitdone(struct mywaitdata *data)
8973 + if (data->pending)
8975 + data->pending = FALSE;
8976 + AbortIO((struct IORequest *) &data->timereq);
8977 + WaitIO((struct IORequest *) &data->timereq);
8980 + if ((BYTE) data->port.mp_SigBit != -1)
8982 + FreeSignal(data->port.mp_SigBit);
8983 + data->port.mp_SigBit = (UBYTE) -1;
8987 +#if !defined(PROTO_SDL_H)
8989 +int mywaitinit(struct mywaitdata *data, Uint32 timeout)
8991 +#define mywaitinit(data, timeout) mywaitinitI(data, timeout, SDLBase)
8992 +static int mywaitinitI(struct mywaitdata *data, Uint32 timeout, struct SDLBase *SDLBase)
8995 + data->extramask = 0;
8996 + data->pending = FALSE;
8997 + data->port.mp_SigBit = -1;
8999 + if (TimerIO && ((BYTE) (data->port.mp_SigBit = AllocSignal(-1)) != -1))
9001 + struct timerequest *req = TimerIO;
9003 + data->port.mp_Node.ln_Type = NT_MSGPORT;
9004 + data->port.mp_Flags = PA_SIGNAL;
9005 + data->port.mp_SigTask = FindTask(NULL);
9006 + NEWLIST(&data->port.mp_MsgList);
9008 + data->timereq.tr_node.io_Message.mn_Node.ln_Type = NT_REPLYMSG;
9009 + data->timereq.tr_node.io_Message.mn_ReplyPort = &data->port;
9010 + data->timereq.tr_node.io_Message.mn_Length = sizeof(data->timereq);
9011 + data->timereq.tr_node.io_Device = req->tr_node.io_Device;
9012 + data->timereq.tr_node.io_Unit = req->tr_node.io_Unit;
9023 +int mywait(struct mywaitdata *data, Uint32 timeout)
9027 + wsig = 1 << data->timereq.tr_node.io_Message.mn_ReplyPort->mp_SigBit;
9029 + if (!data->pending)
9031 + data->pending = TRUE;
9032 + data->timereq.tr_node.io_Command = TR_ADDREQUEST;
9033 + data->timereq.tr_time.tv_secs = timeout / 1000;
9034 + data->timereq.tr_time.tv_micro = (timeout % 1000) * 1000;
9035 + SendIO((struct IORequest *) &data->timereq);
9038 + sigs = Wait(wsig | data->extramask | SIGBREAKF_CTRL_C);
9042 + data->pending = FALSE;
9043 + WaitIO((struct IORequest *) &data->timereq);
9047 + if (data->pending && data->extramask == 0)
9049 + data->pending = FALSE;
9050 + AbortIO((struct IORequest *) &data->timereq);
9051 + WaitIO((struct IORequest *) &data->timereq);
9055 + data->extramask &= sigs;
9057 + if (sigs & SIGBREAKF_CTRL_C)
9065 +/* Create a semaphore, initialized with value */
9066 +#if !defined(PROTO_SDL_H)
9067 +SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
9070 +AROS_LH1(SDL_sem *, SDL_CreateSemaphore,
9071 + AROS_LHA(Uint32, initial_value, D0),
9072 + struct SDLBase *, SDLBase, 161, SDL)
9078 + D(bug("[SDL] SDL_CreateSemaphore(%ld)\n", initial_value));
9080 + sem = malloc(sizeof(*sem));
9083 + memset(&sem->sem, 0, sizeof(sem->sem));
9084 + InitSemaphore(&sem->sem);
9086 + NEWLIST(&sem->waitlist);
9088 + sem->sem_value = initial_value;
9092 + SDL_OutOfMemory();
9096 +#if defined(PROTO_SDL_H)
9101 +#if !defined(PROTO_SDL_H)
9102 +void SDL_DestroySemaphore(SDL_sem *sem)
9105 +AROS_LH1(void, SDL_DestroySemaphore,
9106 + AROS_LHA(SDL_sem *, sem, A0),
9107 + struct SDLBase *, SDLBase, 162, SDL)
9111 + D(bug("[SDL] SDL_DestroySemaphore()\n"));
9112 + D(bug("Destroying semaphore %lx...\n",sem));
9118 + struct mywaitdata data;
9120 + if (mywaitinit(&data, 10) == 0)
9122 + ObtainSemaphore(&sem->sem);
9124 + sem->sem_value = -1;
9126 + while (!IsListEmpty(&sem->waitlist))
9128 + struct waitnode *wn;
9131 + D(bug("[SDL] bug, semaphore %lx busy!\n", sem));
9133 + for (wn = (struct waitnode *) sem->waitlist.mlh_Head;
9134 + wn->node.mln_Succ;
9135 + wn = (struct waitnode *) wn->node.mln_Succ)
9137 + Signal(wn->task, wn->sigmask);
9140 + ReleaseSemaphore(&sem->sem);
9142 + res = mywait(&data, 10);
9144 + ObtainSemaphore(&sem->sem);
9152 + ReleaseSemaphore(&sem->sem);
9155 + mywaitdone(&data);
9161 +#if defined(PROTO_SDL_H)
9166 +#if !defined(PROTO_SDL_H)
9167 +int SDL_SemTryWait(SDL_sem *sem)
9170 +AROS_LH1(int, SDL_SemTryWait,
9171 + AROS_LHA(SDL_sem *, sem, A0),
9172 + struct SDLBase *, SDLBase, 163, SDL)
9178 + D(bug("[SDL] SDL_SemTryWait()\n"));
9182 + SDL_SetError("Passed a NULL semaphore");
9186 + ObtainSemaphore(&sem->sem);
9188 + if (sem->sem_value > 0)
9195 + retval = SDL_MUTEX_TIMEDOUT;
9198 + ReleaseSemaphore(&sem->sem);
9201 +#if defined(PROTO_SDL_H)
9206 +#if !defined(PROTO_SDL_H)
9207 +int SDL_SemWait(SDL_sem *sem)
9210 +AROS_LH1(int, SDL_SemWait,
9211 + AROS_LHA(SDL_sem *, sem, A0),
9212 + struct SDLBase *, SDLBase, 165, SDL)
9217 + struct waitnode wn;
9220 + D(bug("[SDL] SDL_SemWait(0x%08.8lx) from thread 0x%08.8lx\n", (IPTR)sem, (IPTR)FindTask(NULL)));
9224 + SDL_SetError("Passed a NULL semaphore");
9231 + ObtainSemaphore(&sem->sem);
9233 + D(bug("[SDL] SDL_SemWait(): from thread 0x%08.8lx initial sem_value: %ld\n", (IPTR)FindTask(NULL), sem->sem_value));
9235 + while (sem->sem_value <= 0)
9241 + wn.task = FindTask(NULL);
9242 + signal = AllocSignal(-1);
9245 + signal = FALLBACKSIGNAL;
9246 + SetSignal(1 << FALLBACKSIGNAL, 0);
9248 + wn.sigmask = 1 << signal;
9250 + ADDTAIL(&sem->waitlist, &wn);
9253 + D(bug("[SDL] SDL_SemWait(): waiting for semaphore... \n"));
9255 + ReleaseSemaphore(&sem->sem);
9257 + sigmask = Wait(wn.sigmask | SIGBREAKF_CTRL_C);
9259 + ObtainSemaphore(&sem->sem);
9261 + if (sigmask & SIGBREAKF_CTRL_C)
9263 + D(bug("[SDL] SDL_SemWait(): was aborted...\n"));
9273 + if (signal != FALLBACKSIGNAL)
9275 + FreeSignal(signal);
9283 + D(bug("[SDL] SDL_SemWait(): final sem_value: %ld\n", sem->sem_value));
9286 + ReleaseSemaphore(&sem->sem);
9287 + D(bug("done...\n"));
9290 +#if defined(PROTO_SDL_H)
9295 +#if !defined(PROTO_SDL_H)
9296 +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
9299 +AROS_LH2(int, SDL_SemWaitTimeout,
9300 + AROS_LHA(SDL_sem *, sem, A0),
9301 + AROS_LHA(Uint32, timeout, D0),
9302 + struct SDLBase *, SDLBase, 164, SDL)
9306 + struct mywaitdata data;
9309 + D(bug("[SDL] SDL_SemWaitTimeout()\n"));
9313 + SDL_SetError("Passed a NULL semaphore");
9317 + /* Try the easy cases first */
9320 + return SDL_SemTryWait(sem);
9322 + if (timeout == SDL_MUTEX_MAXWAIT)
9324 + return SDL_SemWait(sem);
9329 + if (mywaitinit(&data, timeout) == 0)
9331 + struct waitnode wn;
9337 + ObtainSemaphore(&sem->sem);
9339 + while (sem->sem_value <= 0)
9343 + wn.task = FindTask(NULL);
9344 + signal = AllocSignal(-1);
9347 + signal = FALLBACKSIGNAL;
9348 + SetSignal(1 << FALLBACKSIGNAL, 0);
9350 + wn.sigmask = 1 << signal;
9352 + ADDTAIL(&sem->waitlist, &wn);
9355 + ReleaseSemaphore(&sem->sem);
9357 + data.extramask = wn.sigmask;
9358 + retval = mywait(&data, timeout);
9360 + ObtainSemaphore(&sem->sem);
9368 + /* Timed out? (== no 'semaphore released'-signal) */
9369 + if (data.extramask == 0)
9371 + retval = SDL_MUTEX_TIMEDOUT;
9377 + * Not timed out, someone released the semaphore.
9378 + * See if we can get it. If we can't, continue waiting.
9386 + if (signal != FALLBACKSIGNAL)
9388 + FreeSignal(signal);
9392 + /* If can obtain (no timeout, no break), obtain it */
9397 + D(bug("[SDL] SDL_SemWaitTimeout(): final sem_value: %ld\n", sem->sem_value));
9400 + ReleaseSemaphore(&sem->sem);
9404 + mywaitdone(&data);
9408 + /* Ack! We have to busy wait... */
9409 + timeout += SDL_GetTicks();
9411 + if (mywaitinit(&data, 1) == 0)
9415 + retval = SDL_SemTryWait(sem);
9421 + if (mywait(&data, 1) < 0)
9427 + } while (SDL_GetTicks() < timeout);
9431 + mywaitdone(&data);
9436 +#if defined(PROTO_SDL_H)
9441 +#if !defined(PROTO_SDL_H)
9442 +Uint32 SDL_SemValue(SDL_sem *sem)
9445 +AROS_LH1(Uint32, SDL_SemValue,
9446 + AROS_LHA(SDL_sem *, sem, A0),
9447 + struct SDLBase *, SDLBase, 166, SDL)
9453 + D(bug("[SDL] SDL_SemValue()\n"));
9457 + SDL_SetError("Passed a NULL semaphore");
9461 + ObtainSemaphoreShared(&sem->sem);
9463 + retval = sem->sem_value;
9465 + ReleaseSemaphore(&sem->sem);
9472 + return (Uint32) retval;
9473 +#if defined(PROTO_SDL_H)
9478 +#if !defined(PROTO_SDL_H)
9479 +int SDL_SemPost(SDL_sem *sem)
9482 +AROS_LH1(int, SDL_SemPost,
9483 + AROS_LHA(SDL_sem *, sem, A0),
9484 + struct SDLBase *, SDLBase, 167, SDL)
9488 + struct waitnode *wn;
9492 + SDL_SetError("Passed a NULL semaphore");
9496 + ObtainSemaphore(&sem->sem);
9498 + D(bug("[SDL] SDL_SemPost(0x%08.8lx): initial sem_value: %ld\n", (IPTR)sem, sem->sem_value));
9502 + /* Wake whatever task happens to be first in the waitlist */
9503 + wn = (struct waitnode *) sem->waitlist.mlh_Head;
9504 + if (wn->node.mln_Succ)
9506 + Signal(wn->task, wn->sigmask);
9511 + for (wn = (struct waitnode *) sem->waitlist.mlh_Head;
9512 + wn->node.mln_Succ;
9513 + wn = (struct waitnode *) wn->node.mln_Succ)
9515 + Signal(wn->task, wn->sigmask);
9522 + D(bug("[SDL] SDL_SemPost(): final sem_value: %ld\n", sem->sem_value));
9524 + ReleaseSemaphore(&sem->sem);
9527 +#if defined(PROTO_SDL_H)
9532 diff -Naur SDL-1.2.15-orig/src/thread/aros/SDL_systhread.c SDL-1.2.15/src/thread/aros/SDL_systhread.c
9533 --- SDL-1.2.15-orig/src/thread/aros/SDL_systhread.c 1970-01-01 01:00:00.000000000 +0100
9534 +++ SDL-1.2.15/src/thread/aros/SDL_systhread.c 2015-05-09 15:09:59.764739515 +0200
9537 + SDL - Simple DirectMedia Layer
9538 + Copyright (C) 1997-2006 Sam Lantinga
9540 + This library is free software; you can redistribute it and/or
9541 + modify it under the terms of the GNU Lesser General Public
9542 + License as published by the Free Software Foundation; either
9543 + version 2.1 of the License, or (at your option) any later version.
9545 + This library is distributed in the hope that it will be useful,
9546 + but WITHOUT ANY WARRANTY; without even the implied warranty of
9547 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9548 + Lesser General Public License for more details.
9550 + You should have received a copy of the GNU Lesser General Public
9551 + License along with this library; if not, write to the Free Software
9552 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
9555 + slouken@libsdl.org
9558 +#if defined (SDL_AROS_SHARED)
9559 +#define __NOLIBBASE__
9560 +#include <proto/SDL.h>
9563 +#include "SDL_config.h"
9565 +/* BeOS thread management routines for SDL */
9567 +#include "SDL_mutex.h"
9568 +#include "SDL_thread.h"
9569 +#include "../SDL_thread_c.h"
9570 +#include "../SDL_systhread.h"
9571 +#include "../../main/aros/mydebug.h"
9576 + int (*func)(void *);
9579 + struct Task *wait;
9580 +#if defined(PROTO_SDL_H)
9581 + struct SDLBase *base;
9585 +#if !defined(PROTO_SDL_H)
9586 +extern int SDL_numthreads;
9588 +#include "SDL_intern.h"
9590 +#define SDL_numthreads SDLBase->SDL_numthreads
9591 +void __aros_setoffsettable(void *base);
9594 +Uint32 RunThread(char *args)
9596 + thread_args *data=FindTask(NULL)->tc_UserData;
9597 +#if defined(PROTO_SDL_H)
9598 + /* Have child use parent library base */
9599 + __aros_setoffsettable(data->base);
9601 + struct Task *Father;
9603 + D(bug("Received data: %lx\n",data));
9604 + Father=data->wait;
9606 + SDL_RunThread(data);
9608 + Signal(Father,SIGBREAKF_CTRL_F);
9609 + D(bug("Thread with data %lx ended\n",data));
9613 +#if !defined(PROTO_SDL_H)
9614 +int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
9616 +int SDL_SYS_CreateThreadI(SDL_Thread *thread, void *args, struct SDLBase *SDLBase)
9619 + /* Create the thread and go! */
9622 + D(bug("Sending %lx to the new thread...\n",args));
9625 + SDL_snprintf(buffer, SDL_arraysize(buffer),"%ld",(unsigned long)args);
9627 +#if defined(__AROS__)
9628 + char tasknmtmp[1024];
9629 + struct Task *thisTask = FindTask(NULL);
9631 + if ((thread->threadno = (SDL_numthreads - 1)) > 0)
9633 + sprintf(tasknmtmp, "%s SDL subtask #%u", ((struct Node *)thisTask)->ln_Name, (unsigned int)thread->threadno);
9637 + sprintf(tasknmtmp, "%s SDL subtask", ((struct Node *)thisTask)->ln_Name);
9639 + char *subtaskname = AllocVec(strlen(tasknmtmp) + 1, MEMF_CLEAR);
9640 + CopyMem(tasknmtmp, subtaskname, strlen(tasknmtmp));
9642 + thread->handle=(struct Task *)CreateNewProcTags(NP_Output,Output(),
9643 +#if !defined(__AROS__)
9644 + NP_Name,(ULONG)"SDL subtask",
9645 + NP_StackSize, 98304,
9646 + NP_Entry,(ULONG)RunThread,
9647 + args ? NP_Arguments : TAG_IGNORE,(ULONG)buffer,
9649 + NP_Name, (IPTR)subtaskname,
9650 + NP_StackSize, (IPTR)(thisTask->tc_SPUpper - thisTask->tc_SPLower),
9651 + NP_Entry, (IPTR)RunThread,
9652 + args ? NP_Arguments : TAG_IGNORE, (IPTR)buffer,
9653 + NP_UserData, args,
9655 + NP_CloseOutput, FALSE,
9658 + if(!thread->handle)
9660 + SDL_SetError("Not enough resources to create thread");
9667 +#if !defined(PROTO_SDL_H)
9668 +void SDL_SYS_SetupThread(void)
9670 +void SDL_SYS_SetupThreadI(struct SDLBase *SDLBase)
9675 +#if !defined(PROTO_SDL_H)
9676 +Uint32 SDL_ThreadID(void)
9679 +AROS_LH0(Uint32, SDL_ThreadID,
9680 + struct SDLBase *, SDLBase, 141, SDL)
9684 + /* FIXME: ThreadID may be NON-UNIQUE on 64-bit architectures! */
9685 + return((Uint32)(IPTR)FindTask(NULL));
9686 +#if defined(PROTO_SDL_H)
9691 +#if !defined(PROTO_SDL_H)
9692 +void SDL_SYS_WaitThread(SDL_Thread *thread)
9694 +void SDL_SYS_WaitThreadI(SDL_Thread *thread, struct SDLBase *SDLBase)
9697 + SetSignal(0L,SIGBREAKF_CTRL_F|SIGBREAKF_CTRL_C);
9698 + Wait(SIGBREAKF_CTRL_F|SIGBREAKF_CTRL_C);
9701 +#if !defined(PROTO_SDL_H)
9702 +void SDL_SYS_KillThread(SDL_Thread *thread)
9704 +void SDL_SYS_KillThreadI(SDL_Thread *thread, struct SDLBase *SDLBase)
9707 + Signal((struct Task *)thread->handle,SIGBREAKF_CTRL_C);
9709 diff -Naur SDL-1.2.15-orig/src/thread/aros/SDL_systhread_c.h SDL-1.2.15/src/thread/aros/SDL_systhread_c.h
9710 --- SDL-1.2.15-orig/src/thread/aros/SDL_systhread_c.h 1970-01-01 01:00:00.000000000 +0100
9711 +++ SDL-1.2.15/src/thread/aros/SDL_systhread_c.h 2015-05-09 15:09:59.764739515 +0200
9714 + SDL - Simple DirectMedia Layer
9715 + Copyright (C) 1997-2006 Sam Lantinga
9717 + This library is free software; you can redistribute it and/or
9718 + modify it under the terms of the GNU Lesser General Public
9719 + License as published by the Free Software Foundation; either
9720 + version 2.1 of the License, or (at your option) any later version.
9722 + This library is distributed in the hope that it will be useful,
9723 + but WITHOUT ANY WARRANTY; without even the implied warranty of
9724 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9725 + Lesser General Public License for more details.
9727 + You should have received a copy of the GNU Lesser General Public
9728 + License along with this library; if not, write to the Free Software
9729 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
9732 + slouken@libsdl.org
9734 +#include "SDL_config.h"
9736 +#include <exec/exec.h>
9737 +#include <dos/dos.h>
9738 +#include <dos/dostags.h>
9739 +#include <proto/dos.h>
9740 +#include <proto/exec.h>
9742 +#include "../../main/aros/mydebug.h"
9744 +extern struct ExecBase *SysBase;
9745 +extern struct DosLibrary *DOSBase;
9747 +#define SYS_ThreadHandle struct Task *
9749 diff -Naur SDL-1.2.15-orig/src/thread/aros/SDL_thread.c SDL-1.2.15/src/thread/aros/SDL_thread.c
9750 --- SDL-1.2.15-orig/src/thread/aros/SDL_thread.c 1970-01-01 01:00:00.000000000 +0100
9751 +++ SDL-1.2.15/src/thread/aros/SDL_thread.c 2015-05-09 15:09:59.764739515 +0200
9754 + SDL - Simple DirectMedia Layer
9755 + Copyright (C) 1997-2006 Sam Lantinga
9757 + This library is free software; you can redistribute it and/or
9758 + modify it under the terms of the GNU Lesser General Public
9759 + License as published by the Free Software Foundation; either
9760 + version 2.1 of the License, or (at your option) any later version.
9762 + This library is distributed in the hope that it will be useful,
9763 + but WITHOUT ANY WARRANTY; without even the implied warranty of
9764 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9765 + Lesser General Public License for more details.
9767 + You should have received a copy of the GNU Lesser General Public
9768 + License along with this library; if not, write to the Free Software
9769 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
9772 + slouken@libsdl.org
9776 + This file is from an older SDL library version
9777 + In order for threads to work on AROS port it has to be used
9778 + in place of SDL_thread.c from parent directory
9780 + AROS SDL threads implementation should be updated
9781 + in order to work with current SDL version of threads
9784 +#if defined (SDL_AROS_SHARED)
9785 +#define __NOLIBBASE__
9786 +#include <proto/SDL.h>
9789 +#include "SDL_config.h"
9791 +/* System independent thread management routines for SDL */
9793 +#include "SDL_mutex.h"
9794 +#include "SDL_thread.h"
9795 +#include "../SDL_thread_c.h"
9796 +#include "../SDL_systhread.h"
9798 +#include "../../main/aros/mydebug.h"
9800 +#define ARRAY_CHUNKSIZE 32
9801 +/* The array of threads currently active in the application
9802 + (except the main thread)
9803 + The manipulation of an array here is safer than using a linked list.
9805 +#if !defined(PROTO_SDL_H)
9806 +static int SDL_maxthreads = 0;
9807 +int SDL_numthreads = 0;
9808 +static SDL_Thread **SDL_Threads = NULL;
9809 +static struct SignalSemaphore thread_lock;
9810 +int thread_lock_created = 0;
9811 +/* The default (non-thread-safe) global error variable */
9812 +static SDL_error SDL_global_error;
9813 +static struct SignalSemaphore *threadlock_ptr = &thread_lock;
9815 +#include "SDL_intern.h"
9816 +#define SDL_maxthreads SDLBase->SDL_maxthreads
9817 +#define SDL_numthreads SDLBase->SDL_numthreads
9818 +#define SDL_Threads SDLBase->SDL_Threads
9819 +#define threadlock_ptr SDLBase->SDL_ThreadLock
9820 +#define thread_lock SDLBase->SDL_ThreadLock
9821 +#define thread_lock_created SDLBase->SDL_ThreadLockCreated
9822 +#define SDL_global_error SDLBase->SDL_global_error
9825 +/* Arguments and callback to setup and run the user thread function */
9827 + int (*func)(void *);
9830 + struct Task *wait;
9831 +#if defined(PROTO_SDL_H)
9832 + struct SDLBase *base;
9836 +#if !defined(PROTO_SDL_H)
9837 +int SDL_ThreadsInit(void)
9839 +#define SDL_ThreadsInit() SDL_ThreadsInitI(SDLBase)
9840 +int SDL_ThreadsInitI(struct SDLBase *SDLBase)
9843 +#if defined(PROTO_SDL_H)
9844 + if ((thread_lock = AllocVec(sizeof(struct SignalSemaphore), MEMF_CLEAR)) != NULL)
9846 + D(bug("ThreadLock created @ 0x%p\n", thread_lock));
9848 + InitSemaphore(threadlock_ptr);
9849 + thread_lock_created=1;
9850 +#if defined(PROTO_SDL_H)
9858 +/* This should never be called...
9859 + If this is called by SDL_Quit(), we don't know whether or not we should
9860 + clean up threads here. If any threads are still running after this call,
9861 + they will no longer have access to any per-thread data.
9863 +#if !defined(PROTO_SDL_H)
9864 +void SDL_ThreadsQuit()
9866 +#define SDL_ThreadsQuit() SDL_ThreadsQuitI(SDLBase)
9867 +void SDL_ThreadsQuitI(struct SDLBase *SDLBase)
9870 + thread_lock_created=0;
9873 +/* Routines for manipulating the thread list */
9874 +#if !defined(PROTO_SDL_H)
9875 +static void SDL_AddThread(SDL_Thread *thread)
9877 +#define SDL_AddThread(thread) SDL_AddThreadI(thread, SDLBase)
9878 +static void SDL_AddThreadI(SDL_Thread *thread, struct SDLBase *SDLBase)
9881 + SDL_Thread **threads;
9884 + If the very first threads are created simultaneously, then
9885 + there could be a race condition causing memory corruption.
9886 + In practice, this isn't a problem because by definition there
9887 + is only one thread running the first time this is called.
9889 + if ( !thread_lock_created ) {
9890 + if ( SDL_ThreadsInit() < 0 ) {
9894 + if ( !threadlock_ptr )
9899 + ObtainSemaphore(threadlock_ptr);
9901 + /* Expand the list of threads, if necessary */
9902 +#ifdef DEBUG_THREADS
9903 + printf("Adding thread (%d already - %d max)\n",
9904 + SDL_numthreads, SDL_maxthreads);
9906 + if ( SDL_numthreads == SDL_maxthreads ) {
9907 + threads=(SDL_Thread **)SDL_malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)*
9908 + (sizeof *threads));
9909 + if ( threads == NULL ) {
9910 + SDL_OutOfMemory();
9913 + SDL_memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads));
9914 + SDL_maxthreads += ARRAY_CHUNKSIZE;
9915 + if ( SDL_Threads ) {
9916 + SDL_free(SDL_Threads);
9918 + SDL_Threads = threads;
9920 + SDL_Threads[SDL_numthreads++] = thread;
9922 + ReleaseSemaphore(threadlock_ptr);
9925 +#if !defined(PROTO_SDL_H)
9926 +static void SDL_DelThread(SDL_Thread *thread)
9928 +#define SDL_DelThread(thread) SDL_DelThreadI(thread, SDLBase)
9929 +static void SDL_DelThreadI(SDL_Thread *thread, struct SDLBase *SDLBase)
9934 + if ( !threadlock_ptr )
9938 + if ( thread_lock_created ) {
9939 + ObtainSemaphore(threadlock_ptr);
9940 + for ( i=0; i<SDL_numthreads; ++i ) {
9941 + if ( thread == SDL_Threads[i] ) {
9945 + if ( i < SDL_numthreads ) {
9947 + while ( i < SDL_numthreads ) {
9948 + SDL_Threads[i] = SDL_Threads[i+1];
9951 +#ifdef DEBUG_THREADS
9952 + printf("Deleting thread (%d left - %d max)\n",
9953 + SDL_numthreads, SDL_maxthreads);
9956 + ReleaseSemaphore(threadlock_ptr);
9960 +/* Routine to get the thread-specific error variable */
9961 +#if !defined(PROTO_SDL_H)
9962 +SDL_error *SDL_GetErrBuf(void)
9964 +SDL_error *SDL_GetErrBufI(struct SDLBase *SDLBase)
9967 + SDL_error *errbuf = NULL;
9969 + errbuf = &SDL_global_error;
9970 + if ( SDL_Threads ) {
9972 + Uint32 this_thread;
9974 + this_thread = SDL_ThreadID();
9975 + if (threadlock_ptr)
9977 + ObtainSemaphore(threadlock_ptr);
9978 + for ( i=0; i<SDL_numthreads; ++i ) {
9979 + if ( this_thread == SDL_Threads[i]->threadid ) {
9980 + errbuf = &SDL_Threads[i]->errbuf;
9984 + ReleaseSemaphore(threadlock_ptr);
9990 +void SDL_RunThread(void *data)
9992 + thread_args *args;
9993 + int (*userfunc)(void *);
9997 + /* Get the thread id */
9998 + args = (thread_args *)data;
9999 +#if defined(PROTO_SDL_H)
10000 + struct SDLBase *SDLBase = (struct SDLBase *)__aros_getbase_SDLBase();
10002 + /* Perform any system-dependent setup
10003 + - this function cannot fail, and cannot use SDL_SetError()
10005 + SDL_SYS_SetupThread();
10007 + args->info->threadid = SDL_ThreadID();
10009 + /* Figure out what function to run */
10010 + userfunc = args->func;
10011 + userdata = args->data;
10012 + statusloc = &args->info->status;
10014 + /* Wake up the parent thread */
10015 + Signal(args->wait,SIGBREAKF_CTRL_E);
10017 + /* Run the function */
10018 + *statusloc = userfunc(userdata);
10021 +#if !defined(PROTO_SDL_H)
10022 +SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data)
10025 +AROS_LH2(SDL_Thread *, SDL_CreateThread,
10026 + AROS_LHA(void *, fn, A0),
10027 + AROS_LHA(void *, data, A1),
10028 + struct SDLBase *, SDLBase, 140, SDL)
10030 + AROS_LIBFUNC_INIT
10033 + SDL_Thread *thread;
10034 + thread_args *args;
10037 + /* Allocate memory for the thread info structure */
10038 + thread = (SDL_Thread *)SDL_malloc(sizeof(*thread));
10039 + if ( thread == NULL ) {
10040 + SDL_OutOfMemory();
10043 + SDL_memset(thread, 0, (sizeof *thread));
10044 + thread->status = -1;
10046 + /* Set up the arguments for the thread */
10047 + args = (thread_args *)SDL_malloc(sizeof(*args));
10048 + if ( args == NULL ) {
10049 + SDL_OutOfMemory();
10050 + SDL_free(thread);
10053 +#if defined(PROTO_SDL_H)
10054 + args->base = SDLBase;
10057 + args->data = data;
10058 + args->info = thread;
10059 + args->wait = FindTask(NULL);
10061 + if ( args->wait == NULL ) {
10062 + SDL_free(thread);
10064 + SDL_OutOfMemory();
10068 + /* Add the thread to the list of available threads */
10069 + SDL_AddThread(thread);
10071 + D(bug("Starting thread...\n"));
10073 + /* Create the thread and go! */
10074 + ret = SDL_SYS_CreateThread(thread, args);
10075 + if ( ret >= 0 ) {
10076 + D(bug("Waiting for thread CTRL_E...\n"));
10077 + /* Wait for the thread function to use arguments */
10078 + Wait(SIGBREAKF_CTRL_E);
10079 + D(bug(" Arrived."));
10081 + /* Oops, failed. Gotta free everything */
10082 + SDL_DelThread(thread);
10083 + SDL_free(thread);
10088 + /* Everything is running now */
10090 +#if defined(PROTO_SDL_H)
10091 + AROS_LIBFUNC_EXIT
10095 +#if !defined(PROTO_SDL_H)
10096 +void SDL_WaitThread(SDL_Thread *thread, int *status)
10099 +AROS_LH2(void, SDL_WaitThread,
10100 + AROS_LHA(SDL_Thread *, thread, A0),
10101 + AROS_LHA(int *, status, A1),
10102 + struct SDLBase *, SDLBase, 143, SDL)
10104 + AROS_LIBFUNC_INIT
10107 + SDL_SYS_WaitThread(thread);
10109 + *status = thread->status;
10111 + SDL_DelThread(thread);
10112 + SDL_free(thread);
10114 +#if defined(PROTO_SDL_H)
10115 + AROS_LIBFUNC_EXIT
10119 +#if !defined(PROTO_SDL_H)
10120 +Uint32 SDL_GetThreadID(SDL_Thread *thread)
10123 +AROS_LH1(Uint32, SDL_GetThreadID,
10124 + AROS_LHA(SDL_Thread *, thread, A0),
10125 + struct SDLBase *, SDLBase, 142, SDL)
10127 + AROS_LIBFUNC_INIT
10132 + id = thread->threadid;
10134 + id = SDL_ThreadID();
10137 +#if defined(PROTO_SDL_H)
10138 + AROS_LIBFUNC_EXIT
10142 +#if !defined(PROTO_SDL_H)
10143 +void SDL_KillThread(SDL_Thread *thread)
10146 +AROS_LH1(void, SDL_KillThread,
10147 + AROS_LHA(SDL_Thread *, thread, A0),
10148 + struct SDLBase *, SDLBase, 144, SDL)
10150 + AROS_LIBFUNC_INIT
10153 + SDL_SYS_KillThread(thread);
10154 + SDL_WaitThread(thread, NULL);
10156 +#if defined(PROTO_SDL_H)
10157 + AROS_LIBFUNC_EXIT
10161 diff -Naur SDL-1.2.15-orig/src/thread/SDL_systhread.h SDL-1.2.15/src/thread/SDL_systhread.h
10162 --- SDL-1.2.15-orig/src/thread/SDL_systhread.h 2015-05-09 17:47:54.280774303 +0200
10163 +++ SDL-1.2.15/src/thread/SDL_systhread.h 2015-05-09 15:09:59.764739515 +0200
10165 saves a system-dependent thread id in thread->id, and returns 0
10168 +#if !defined(PROTO_SDL_H)
10169 #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
10170 extern int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread);
10174 /* This function kills the thread and returns */
10175 extern void SDL_SYS_KillThread(SDL_Thread *thread);
10177 +#include "SDL_intern.h"
10179 +extern int SDL_SYS_CreateThreadI(SDL_Thread *thread, void *args, struct SDLBase *SDLBase);
10180 +extern void SDL_SYS_SetupThreadI(struct SDLBase *SDLBase);
10181 +extern void SDL_SYS_WaitThreadI(SDL_Thread *thread, struct SDLBase *SDLBase);
10182 +extern void SDL_SYS_KillThreadI(SDL_Thread *thread, struct SDLBase *SDLBase);
10184 +#define SDL_SYS_CreateThread(thread, args) SDL_SYS_CreateThreadI(thread, args, SDLBase)
10185 +#define SDL_SYS_SetupThread() SDL_SYS_SetupThreadI(SDLBase)
10186 +#define SDL_SYS_WaitThread(thread) SDL_SYS_WaitThreadI(thread, SDLBase)
10187 +#define SDL_SYS_KillThread(thread) SDL_SYS_KillThreadI(thread, SDLBase)
10189 #endif /* _SDL_systhread_h */
10190 diff -Naur SDL-1.2.15-orig/src/thread/SDL_thread.c SDL-1.2.15/src/thread/SDL_thread.c
10191 --- SDL-1.2.15-orig/src/thread/SDL_thread.c 2015-05-09 17:47:54.280774303 +0200
10192 +++ SDL-1.2.15/src/thread/SDL_thread.c 2015-05-09 15:09:59.764739515 +0200
10197 +#if defined (SDL_AROS_SHARED)
10198 +#define __NOLIBBASE__
10199 +#include <proto/SDL.h>
10202 #include "SDL_config.h"
10204 /* System independent thread management routines for SDL */
10205 @@ -33,12 +38,27 @@
10206 (except the main thread)
10207 The manipulation of an array here is safer than using a linked list.
10209 +#if !defined(PROTO_SDL_H)
10210 static int SDL_maxthreads = 0;
10211 static int SDL_numthreads = 0;
10212 static SDL_Thread **SDL_Threads = NULL;
10213 static SDL_mutex *thread_lock = NULL;
10214 +/* The default (non-thread-safe) global error variable */
10215 +static SDL_error SDL_global_error;
10217 +#include "SDL_intern.h"
10218 +#define SDL_maxthreads SDLBase->SDL_maxthreads
10219 +#define SDL_numthreads SDLBase->SDL_numthreads
10220 +#define SDL_Threads SDLBase->SDL_Threads
10221 +#define thread_lock SDLBase->thread_lock
10222 +#define SDL_global_error SDLBase->SDL_global_error
10225 +#if !defined(PROTO_SDL_H)
10226 int SDL_ThreadsInit(void)
10228 +int SDL_ThreadsInit(struct SDLBase *SDLBase)
10234 clean up threads here. If any threads are still running after this call,
10235 they will no longer have access to any per-thread data.
10237 +#if !defined(PROTO_SDL_H)
10238 void SDL_ThreadsQuit(void)
10240 +void SDL_ThreadsQuit(struct SDLBase *SDLBase)
10248 /* Routines for manipulating the thread list */
10249 +#if !defined(PROTO_SDL_H)
10250 static void SDL_AddThread(SDL_Thread *thread)
10252 +static void SDL_AddThread(SDL_Thread *thread, struct SDLBase *SDLBase)
10256 If the very first threads are created simultaneously, then
10257 @@ -103,7 +131,11 @@
10258 SDL_mutexV(thread_lock);
10261 +#if !defined(PROTO_SDL_H)
10262 static void SDL_DelThread(SDL_Thread *thread)
10264 +static void SDL_DelThread(SDL_Thread *thread, struct SDLBase *SDLBase)
10269 @@ -141,9 +173,6 @@
10273 -/* The default (non-thread-safe) global error variable */
10274 -static SDL_error SDL_global_error;
10276 /* Routine to get the thread-specific error variable */
10277 SDL_error *SDL_GetErrBuf(void)
10279 diff -Naur SDL-1.2.15-orig/src/thread/SDL_thread_c.h SDL-1.2.15/src/thread/SDL_thread_c.h
10280 --- SDL-1.2.15-orig/src/thread/SDL_thread_c.h 2015-05-09 17:47:54.280774303 +0200
10281 +++ SDL-1.2.15/src/thread/SDL_thread_c.h 2015-05-09 15:09:59.765739514 +0200
10283 #include "win32/SDL_systhread_c.h"
10284 #elif SDL_THREAD_SYMBIAN
10285 #include "symbian/SDL_systhread_c.h"
10286 +#elif SDL_THREAD_AROS
10287 +#include "aros/SDL_systhread_c.h"
10289 #error Need thread implementation for this platform
10290 #include "generic/SDL_systhread_c.h"
10292 /* This is the system-independent thread info structure */
10293 struct SDL_Thread {
10296 SYS_ThreadHandle handle;
10301 /* This is the function called to run a thread */
10302 extern void SDL_RunThread(void *data);
10304 #endif /* _SDL_thread_c_h */
10305 diff -Naur SDL-1.2.15-orig/src/timer/aros/SDL_systimer.c SDL-1.2.15/src/timer/aros/SDL_systimer.c
10306 --- SDL-1.2.15-orig/src/timer/aros/SDL_systimer.c 1970-01-01 01:00:00.000000000 +0100
10307 +++ SDL-1.2.15/src/timer/aros/SDL_systimer.c 2015-05-09 17:41:01.929187319 +0200
10310 + SDL - Simple DirectMedia Layer
10311 + Copyright (C) 1997-2006 Sam Lantinga
10313 + This library is free software; you can redistribute it and/or
10314 + modify it under the terms of the GNU Lesser General Public
10315 + License as published by the Free Software Foundation; either
10316 + version 2.1 of the License, or (at your option) any later version.
10318 + This library is distributed in the hope that it will be useful,
10319 + but WITHOUT ANY WARRANTY; without even the implied warranty of
10320 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10321 + Lesser General Public License for more details.
10323 + You should have received a copy of the GNU Lesser General Public
10324 + License along with this library; if not, write to the Free Software
10325 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
10328 + slouken@libsdl.org
10330 +#include <proto/dos.h>
10331 +#include <proto/exec.h>
10333 +#if defined (SDL_AROS_SHARED)
10334 +#define __NOLIBBASE__
10335 +#include <proto/SDL.h>
10338 +#include "SDL_config.h"
10340 +#ifdef SDL_TIMER_AROS
10342 +#define __TIMER_NOLIBBASE__
10344 +#include <stdio.h>
10346 +#include <signal.h>
10347 +#include <unistd.h>
10348 +#include <string.h>
10349 +#include <errno.h>
10350 +#include <exec/types.h>
10351 +#include <devices/timer.h>
10352 +#include <proto/timer.h>
10353 +#include "../../main/aros/mydebug.h"
10355 +#include "SDL_thread.h"
10356 +#include "SDL_timer.h"
10357 +#include "../SDL_timer_c.h"
10359 +#if !defined(PROTO_SDL_H)
10360 +extern struct DosLibrary *DOSBase;
10361 +extern struct ExecBase *SysBase;
10362 +struct timerequest *TimerIO;
10364 +struct Device *TimerBase;
10365 +struct timeval basetime;
10366 +struct MsgPort *TimerMP;
10367 +struct Task *OwnerTask;
10370 +#include "SDL_intern.h"
10371 +#define timer_alive SDLBase->timer_alive
10372 +#define timer_thread SDLBase->timer_thread
10373 +#define TimerIO SDLBase->TimerIO
10374 +#define start SDLBase->start
10375 +#define TimerBase SDLBase->TimerBase
10376 +#define basetime SDLBase->basetime
10377 +#define TimerMP SDLBase->TimerMP
10378 +#define OwnerTask SDLBase->OwnerTask
10379 +#define fallback SDLBase->fallback
10382 +/* The first ticks value of the application */
10383 +#if !defined(PROTO_SDL_H)
10384 +static void close_timer(void)
10386 +#define close_timer() close_timerI(SDLBase)
10387 +void close_timerI(struct SDLBase *SDLBase)
10390 + D(bug("freeing timer resources..."));
10392 + CloseDevice((struct IORequest *)TimerIO);
10393 + DeleteIORequest((struct IORequest *)TimerIO);
10397 + DeleteMsgPort(TimerMP);
10403 +#if !defined(PROTO_SDL_H)
10404 +static BOOL open_timer(void)
10406 +#define open_timer() open_timerI(SDLBase)
10407 +static BOOL open_timerI(struct SDLBase *SDLBase)
10410 + if (TimerBase || fallback) {
10414 + if (!(TimerMP = CreateMsgPort())) {
10420 + if (!(TimerIO = (struct timerequest *)
10421 + CreateIORequest(TimerMP, sizeof(struct timerequest)))) {
10422 + DeleteMsgPort(TimerMP);
10427 + // Under AROS we use UNIT_MICROHZ to be more accurate for short delays
10428 + // Delays under SDL are mainly used to synchronise frame updates
10429 + // and therefore are usually less than 1/50 or 1/60 seconds
10430 + if (OpenDevice("timer.device", UNIT_MICROHZ, &TimerIO->tr_node, 0)) {
10431 + DeleteMsgPort(TimerMP);
10432 + DeleteIORequest((struct IORequest *)TimerIO);
10438 + OwnerTask = TimerMP->mp_SigTask;
10439 + TimerBase = TimerIO->tr_node.io_Device;
10440 + D(bug("Timer resource allocated.\n"));
10442 + GetSysTime(&basetime);
10443 + D(bug("Basetime: %lusecs %lumicro\n", basetime.tv_secs, basetime.tv_micro));
10445 +#if !defined(PROTO_SDL_H) && !defined(SHARED_LIB)
10446 + atexit(close_timer);
10452 +#if !defined(PROTO_SDL_H)
10453 +void SDL_StartTicks(void)
10455 +void SDL_StartTicksI(struct SDLBase *SDLBase)
10461 +#if !defined(PROTO_SDL_H)
10462 +Uint32 SDL_GetTicks (void)
10465 +AROS_LH0(Uint32, SDL_GetTicks,
10466 + struct SDLBase *, SDLBase, 78, SDL)
10468 + AROS_LIBFUNC_INIT
10470 + open_timer(); // TimerBase must be set for GetSysTime()
10474 + ticks=clock()-start;
10476 +#if CLOCKS_PER_SEC == 1000
10479 + return ticks*(1000/CLOCKS_PER_SEC);
10483 + struct timeval tv;
10488 + if(basetime.tv_micro > tv.tv_micro) {
10491 + tv.tv_micro += 1000000;
10493 + tics = ((tv.tv_secs - basetime.tv_secs) * 1000) +
10494 + ((tv.tv_micro - basetime.tv_micro)/1000);
10498 +#if defined(PROTO_SDL_H)
10499 + AROS_LIBFUNC_EXIT
10503 +#if !defined(PROTO_SDL_H)
10504 +void SDL_Delay (Uint32 ms)
10507 +AROS_LH1(void, SDL_Delay,
10508 + AROS_LHA(Uint32, ms, D0),
10509 + struct SDLBase *, SDLBase, 79, SDL)
10511 + AROS_LIBFUNC_INIT
10514 +We should try to be more clever under AROS to avoid any busy looping
10515 +Busy looping causes the system to slow down, while an SDL application
10516 +is waiting to sync screen update, those delays are usually less than
10517 +1/50 seconds, i.e. 20ms
10519 + if (OwnerTask == FindTask(NULL)) //SysBase->ThisTask)
10521 + TimerIO->tr_node.io_Command = TR_ADDREQUEST;
10522 + TimerIO->tr_time.tv_secs = ms / 1000;
10523 + TimerIO->tr_time.tv_micro = (ms % 1000) * 1000;
10525 + DoIO((struct IORequest *) TimerIO);
10529 + struct MsgPort port;
10531 + if ((BYTE) (port.mp_SigBit = AllocSignal(-1)) != -1)
10533 + struct timerequest ioreq;
10535 + port.mp_Node.ln_Type = NT_MSGPORT;
10536 + port.mp_Flags = PA_SIGNAL;
10537 + port.mp_SigTask = FindTask(NULL);
10538 + NEWLIST(&port.mp_MsgList);
10540 + ioreq.tr_node.io_Message.mn_Node.ln_Type = NT_REPLYMSG;
10541 + ioreq.tr_node.io_Message.mn_ReplyPort = &port;
10542 + ioreq.tr_node.io_Message.mn_Length = sizeof(struct timerequest);
10543 + ioreq.tr_node.io_Device = TimerIO->tr_node.io_Device;
10544 + ioreq.tr_node.io_Unit = TimerIO->tr_node.io_Unit;
10545 + ioreq.tr_node.io_Command = TR_ADDREQUEST;
10546 + ioreq.tr_time.tv_secs = ms / 1000;
10547 + ioreq.tr_time.tv_micro = (ms % 1000) * 1000;
10549 + DoIO((struct IORequest *) &ioreq);
10551 + FreeSignal(port.mp_SigBit);
10554 +#if defined(PROTO_SDL_H)
10555 + AROS_LIBFUNC_EXIT
10560 +/* Data to handle a single periodic alarm */
10561 +#if !defined(PROTO_SDL_H)
10562 +static int timer_alive = 0;
10563 +static SDL_Thread *timer_thread = NULL;
10565 +static int RunTimer(void *unused)
10567 +#define timer_alive SDLBase->timer_alive
10568 +#define timer_thread SDLBase->timer_thread
10570 +static int RunTimer(struct SDLBase *SDLBase)
10573 + D(bug("SYSTimer: Entering RunTimer loop..."));
10575 + while ( timer_alive ) {
10576 + if ( SDL_timer_running ) {
10577 + SDL_ThreadedTimerCheck();
10579 + SDL_Delay(1); // Might use new SDL_Delay implementation but has to be thread safe before!
10581 + D(bug("SYSTimer: EXITING RunTimer loop..."));
10585 +/* This is only called if the event thread is not running */
10586 +#if !defined(PROTO_SDL_H)
10587 +int SDL_SYS_TimerInit(void)
10589 +int SDL_SYS_TimerInitI(struct SDLBase *SDLBase)
10592 + D(bug("Creating thread for the timer (NOITIMER)...\n"));
10595 +#if !defined(PROTO_SDL_H)
10596 + timer_thread = SDL_CreateThread(RunTimer, NULL);
10598 + timer_thread = SDL_CreateThread(RunTimer, SDLBase);
10600 + if ( timer_thread == NULL )
10602 + D(bug("Creazione del thread fallita...\n"));
10606 + return(SDL_SetTimerThreaded(1));
10609 +#if !defined(PROTO_SDL_H)
10610 +void SDL_SYS_TimerQuit(void)
10612 +void SDL_SYS_TimerQuitI(struct SDLBase *SDLBase)
10616 + if ( timer_thread ) {
10617 + SDL_WaitThread(timer_thread, NULL);
10618 + timer_thread = NULL;
10622 +#if !defined(PROTO_SDL_H)
10623 +int SDL_SYS_StartTimer(void)
10625 +int SDL_SYS_StartTimerI(struct SDLBase *SDLBase)
10628 + SDL_SetError("Internal logic error: AmigaOS uses threaded timer");
10632 +#if !defined(PROTO_SDL_H)
10633 +void SDL_SYS_StopTimer(void)
10635 +void SDL_SYS_StopTimerI(struct SDLBase *SDLBase)
10641 +#if defined(PROTO_SDL_H)
10642 +ADD2CLOSELIB(close_timerI, -5);
10645 +#endif /* SDL_TIMER_AROS */
10646 diff -Naur SDL-1.2.15-orig/src/timer/SDL_systimer.h SDL-1.2.15/src/timer/SDL_systimer.h
10647 --- SDL-1.2.15-orig/src/timer/SDL_systimer.h 2015-05-09 17:47:54.323774189 +0200
10648 +++ SDL-1.2.15/src/timer/SDL_systimer.h 2015-05-09 15:09:59.765739514 +0200
10650 #include "SDL_timer.h"
10651 #include "SDL_timer_c.h"
10654 +#if !defined(PROTO_SDL_H)
10655 /* Initialize the system dependent timer subsystem */
10656 extern int SDL_SYS_TimerInit(void);
10660 /* Stop a previously started timer */
10661 extern void SDL_SYS_StopTimer(void);
10663 +extern int SDL_SYS_TimerInitI(struct SDLBase *SDLBase);
10664 +extern void SDL_SYS_TimerQuitI(struct SDLBase *SDLBase);
10665 +extern int SDL_SYS_StartTimerI(struct SDLBase *SDLBase);
10666 +extern void SDL_SYS_StopTimerI(struct SDLBase *SDLBase);
10668 +#define SDL_SYS_TimerInit() SDL_SYS_TimerInitI(SDLBase)
10669 +#define SDL_SYS_TimerQuit() SDL_SYS_TimerQuitI(SDLBase)
10670 +#define SDL_SYS_StartTimer() SDL_SYS_StartTimerI(SDLBase)
10671 +#define SDL_SYS_StopTimer() SDL_SYS_StopTimerI(SDLBase)
10673 \ No newline at end of file
10674 diff -Naur SDL-1.2.15-orig/src/timer/SDL_timer.c SDL-1.2.15/src/timer/SDL_timer.c
10675 --- SDL-1.2.15-orig/src/timer/SDL_timer.c 2015-05-09 17:47:54.323774189 +0200
10676 +++ SDL-1.2.15/src/timer/SDL_timer.c 2015-05-09 15:09:59.765739514 +0200
10681 +#if defined (SDL_AROS_SHARED)
10682 +#define __NOLIBBASE__
10683 +#include <proto/SDL.h>
10686 #include "SDL_config.h"
10688 #include "SDL_timer.h"
10691 /* #define DEBUG_TIMERS */
10693 +struct _SDL_TimerID {
10695 + SDL_NewTimerCallback cb;
10697 + Uint32 last_alarm;
10698 + struct _SDL_TimerID *next;
10701 +#if !defined(PROTO_SDL_H)
10702 int SDL_timer_started = 0;
10703 int SDL_timer_running = 0;
10705 @@ -38,22 +52,29 @@
10706 /* Data used for a thread-based timer */
10707 static int SDL_timer_threaded = 0;
10709 -struct _SDL_TimerID {
10711 - SDL_NewTimerCallback cb;
10713 - Uint32 last_alarm;
10714 - struct _SDL_TimerID *next;
10717 static SDL_TimerID SDL_timers = NULL;
10718 static SDL_mutex *SDL_timer_mutex;
10719 static volatile SDL_bool list_changed = SDL_FALSE;
10721 +#include "SDL_intern.h"
10722 +#define SDL_timers SDLBase->SDL_timers
10723 +#define SDL_timer_started SDLBase->SDL_timer_started
10724 +#define SDL_timer_running SDLBase->SDL_timer_running
10725 +#define SDL_alarm_interval SDLBase->SDL_alarm_interval
10726 +#define SDL_alarm_callback SDLBase->SDL_alarm_callback
10727 +#define SDL_timer_threaded SDLBase->SDL_timer_threaded
10728 +#define SDL_timer_mutex SDLBase->SDL_timer_mutex
10729 +#define list_changed SDLBase->list_changed
10732 /* Set whether or not the timer should use a thread.
10733 This should not be called while the timer subsystem is running.
10735 +#if !defined(PROTO_SDL_H)
10736 int SDL_SetTimerThreaded(int value)
10738 +int SDL_SetTimerThreadedI(int value, struct SDLBase *SDLBase)
10747 +#if !defined(PROTO_SDL_H)
10748 int SDL_TimerInit(void)
10750 +int SDL_TimerInitI(struct SDLBase *SDLBase)
10755 @@ -87,7 +112,11 @@
10759 +#if !defined(PROTO_SDL_H)
10760 void SDL_TimerQuit(void)
10762 +void SDL_TimerQuitI(struct SDLBase *SDLBase)
10765 SDL_SetTimer(0, NULL);
10766 if ( SDL_timer_threaded < 2 ) {
10767 @@ -101,7 +130,11 @@
10768 SDL_timer_threaded = 0;
10771 +#if !defined(PROTO_SDL_H)
10772 void SDL_ThreadedTimerCheck(void)
10774 +void SDL_ThreadedTimerCheckI(struct SDLBase *SDLBase)
10778 SDL_TimerID t, prev, next;
10779 @@ -162,7 +195,12 @@
10780 SDL_mutexV(SDL_timer_mutex);
10783 +#if !defined(PROTO_SDL_H)
10784 static SDL_TimerID SDL_AddTimerInternal(Uint32 interval, SDL_NewTimerCallback callback, void *param)
10786 +#define SDL_AddTimerInternal(interval, callback, param) SDL_AddTimerInternalI(interval, callback, param, SDLBase)
10787 +static SDL_TimerID SDL_AddTimerInternalI(Uint32 interval, SDL_NewTimerCallback callback, void *param, struct SDLBase *SDLBase)
10791 t = (SDL_TimerID) SDL_malloc(sizeof(struct _SDL_TimerID));
10792 @@ -182,8 +220,18 @@
10796 +#if !defined(PROTO_SDL_H)
10797 SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param)
10800 +AROS_LH3(SDL_TimerID, SDL_AddTimer,
10801 + AROS_LHA(Uint32, interval, D0),
10802 + AROS_LHA(SDL_NewTimerCallback, callback, A0),
10803 + AROS_LHA(void *, param, A1),
10804 + struct SDLBase *, SDLBase, 81, SDL)
10806 + AROS_LIBFUNC_INIT
10809 if ( ! SDL_timer_mutex ) {
10810 if ( SDL_timer_started ) {
10811 @@ -201,10 +249,21 @@
10812 t = SDL_AddTimerInternal(interval, callback, param);
10813 SDL_mutexV(SDL_timer_mutex);
10815 +#if defined(PROTO_SDL_H)
10816 + AROS_LIBFUNC_EXIT
10820 +#if !defined(PROTO_SDL_H)
10821 SDL_bool SDL_RemoveTimer(SDL_TimerID id)
10824 +AROS_LH1(SDL_bool, SDL_RemoveTimer,
10825 + AROS_LHA(SDL_TimerID, id, D0),
10826 + struct SDLBase *, SDLBase, 82, SDL)
10828 + AROS_LIBFUNC_INIT
10830 SDL_TimerID t, prev = NULL;
10833 @@ -230,6 +289,9 @@
10835 SDL_mutexV(SDL_timer_mutex);
10837 +#if defined(PROTO_SDL_H)
10838 + AROS_LIBFUNC_EXIT
10842 /* Old style callback functions are wrapped through this */
10843 @@ -239,8 +301,17 @@
10844 return (*func)(ms);
10847 +#if !defined(PROTO_SDL_H)
10848 int SDL_SetTimer(Uint32 ms, SDL_TimerCallback callback)
10851 +AROS_LH2(int, SDL_SetTimer,
10852 + AROS_LHA(Uint32, ms, D0),
10853 + AROS_LHA(SDL_TimerCallback, callback, A0),
10854 + struct SDLBase *, SDLBase, 80, SDL)
10856 + AROS_LIBFUNC_INIT
10860 #ifdef DEBUG_TIMERS
10861 @@ -282,4 +353,7 @@
10865 +#if defined(PROTO_SDL_H)
10866 + AROS_LIBFUNC_EXIT
10869 diff -Naur SDL-1.2.15-orig/src/timer/SDL_timer_c.h SDL-1.2.15/src/timer/SDL_timer_c.h
10870 --- SDL-1.2.15-orig/src/timer/SDL_timer_c.h 2015-05-09 17:47:54.323774189 +0200
10871 +++ SDL-1.2.15/src/timer/SDL_timer_c.h 2015-05-09 15:09:59.765739514 +0200
10873 #define ROUND_RESOLUTION(X) \
10874 (((X+TIMER_RESOLUTION-1)/TIMER_RESOLUTION)*TIMER_RESOLUTION)
10876 +#if !defined(PROTO_SDL_H)
10877 extern int SDL_timer_started;
10878 extern int SDL_timer_running;
10882 /* This function is called from the SDL event thread if it is available */
10883 extern void SDL_ThreadedTimerCheck(void);
10885 +#include "SDL_intern.h"
10886 +extern int SDL_SetTimerThreadedI(int value, struct SDLBase *SDLBase);
10887 +extern int SDL_TimerInitI(struct SDLBase *SDLBase);
10888 +extern void SDL_TimerQuitI(struct SDLBase *SDLBase);
10889 +extern void SDL_ThreadedTimerCheckI(struct SDLBase *SDLBase);
10891 +#define SDL_SetTimerThreaded(value) SDL_SetTimerThreadedI(value, SDLBase)
10892 +#define SDL_TimerInit() SDL_TimerInitI(SDLBase)
10893 +#define SDL_TimerQuit() SDL_TimerQuitI(SDLBase)
10894 +#define SDL_ThreadedTimerCheck() SDL_ThreadedTimerCheckI(SDLBase)
10896 +#define SDL_timer_started SDLBase->SDL_timer_started
10897 +#define SDL_timer_running SDLBase->SDL_timer_running
10898 +#define SDL_alarm_interval SDLBase->SDL_alarm_interval
10899 +#define SDL_alarm_callback SDLBase->SDL_alarm_callback
10901 \ No newline at end of file
10902 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxaccel.c SDL-1.2.15/src/video/cgx/SDL_cgxaccel.c
10903 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxaccel.c 1970-01-01 01:00:00.000000000 +0100
10904 +++ SDL-1.2.15/src/video/cgx/SDL_cgxaccel.c 2015-05-09 15:09:59.766739512 +0200
10907 + SDL - Simple DirectMedia Layer
10908 + Copyright (C) 1997-2006 Sam Lantinga
10910 + This library is free software; you can redistribute it and/or
10911 + modify it under the terms of the GNU Lesser General Public
10912 + License as published by the Free Software Foundation; either
10913 + version 2.1 of the License, or (at your option) any later version.
10915 + This library is distributed in the hope that it will be useful,
10916 + but WITHOUT ANY WARRANTY; without even the implied warranty of
10917 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10918 + Lesser General Public License for more details.
10920 + You should have received a copy of the GNU Lesser General Public
10921 + License along with this library; if not, write to the Free Software
10922 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
10925 + slouken@libsdl.org
10927 +#if defined (SDL_AROS_SHARED)
10928 +#define __NOLIBBASE__
10929 +#include <proto/SDL.h>
10932 +#include "SDL_config.h"
10934 +#include "SDL_endian.h"
10935 +#include "SDL_cgxaccel_c.h"
10936 +#include "SDL_cgxvideo.h"
10937 +#include "../SDL_blit.h"
10939 +#if defined(PROTO_SDL_H)
10940 +#include "SDL_intern.h"
10941 +#define current_video SDLBase->current_video
10944 +#include <aros/macros.h>
10946 +/* HW bliting functions */
10947 +static int CGX_HWtoHWBlit( SDL_Surface *src, SDL_Rect *srcrect,
10948 + SDL_Surface *dst, SDL_Rect *dstrect);
10949 +static int CGX_HWtoHWBlitA( SDL_Surface *src, SDL_Rect *srcrect,
10950 + SDL_Surface *dst, SDL_Rect *dstrect);
10951 +static int CGX_HWtoHWBlitCC(SDL_Surface *src, SDL_Rect *srcrect,
10952 + SDL_Surface *dst, SDL_Rect *dstrect);
10953 +static int CGX_SWtoHWBlit( SDL_Surface *src, SDL_Rect *srcrect,
10954 + SDL_Surface *dst, SDL_Rect *dstrect);
10955 +static int CGX_SWtoHWBlitA( SDL_Surface *src, SDL_Rect *srcrect,
10956 + SDL_Surface *dst, SDL_Rect *dstrect);
10957 +static int CGX_SWtoHWBlitCC(SDL_Surface *src, SDL_Rect *srcrect,
10958 + SDL_Surface *dst, SDL_Rect *dstrect);
10960 +#if !defined(PROTO_SDL_H)
10961 +int CGX_AllocHWSurface(_THIS, SDL_Surface *surface)
10963 +int CGX_AllocHWSurfaceI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
10966 +#ifndef NO_AMIGAHWSURF
10967 + D(bug("Alloc HW surface...%ld x %ld x %ld!\n",surface->w,surface->h,this->hidden->depth));
10969 + if(surface==SDL_VideoSurface)
10971 + D(bug("Allocation skipped, it's system one!\n"));
10975 + if(!surface->hwdata)
10977 + if(!(surface->hwdata=SDL_malloc(sizeof(struct private_hwdata))))
10981 + surface->hwdata->mask=NULL;
10982 + surface->hwdata->pixarrayalpha=NULL;
10983 + surface->hwdata->lock=NULL;
10984 + surface->hwdata->videodata=this;
10985 + surface->hwdata->allocated=0;
10987 + if((surface->hwdata->bmap=AllocBitMap(surface->w,surface->h,this->hidden->depth,BMF_MINPLANES,SDL_Display->RastPort.BitMap)))
10989 + surface->hwdata->allocated=1;
10990 + surface->hwdata->pixfmt = GetCyberMapAttr(surface->hwdata->bmap,CYBRMATTR_PIXFMT);
10991 + surface->flags|=SDL_HWSURFACE;
10993 + D(bug("PIXFMT = 0x%08X\t",surface->hwdata->pixfmt));
10994 + D(bug("...OK\n"));
10999 + SDL_free(surface->hwdata);
11000 + surface->hwdata=NULL;
11006 +#if !defined(PROTO_SDL_H)
11007 +void CGX_FreeHWSurface(_THIS, SDL_Surface *surface)
11009 +void CGX_FreeHWSurfaceI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
11012 +#ifndef NO_AMIGAHWSURF
11013 + if(surface && surface!=SDL_VideoSurface && surface->hwdata)
11015 + D(bug("Free hw surface.\n"));
11017 + if(surface->hwdata->mask)
11018 + SDL_free(surface->hwdata->mask);
11020 + if(surface->hwdata->pixarrayalpha)
11021 + SDL_free(surface->hwdata->pixarrayalpha);
11023 + if(surface->hwdata->bmap&&surface->hwdata->allocated)
11024 + FreeBitMap(surface->hwdata->bmap);
11026 + SDL_free(surface->hwdata);
11027 + surface->hwdata=NULL;
11028 + surface->pixels=NULL;
11029 + D(bug("end of free hw surface\n"));
11035 +#if !defined(PROTO_SDL_H)
11036 +int CGX_LockHWSurface(_THIS, SDL_Surface *surface)
11038 +int CGX_LockHWSurfaceI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
11041 +#ifndef NO_AMIGAHWSURF
11042 + if (surface->hwdata)
11044 + D(bug("Locking a bitmap..."));
11045 + if(!surface->hwdata->lock)
11049 + if((surface->hwdata->lock = LockBitMapTags(surface->hwdata->bmap,
11050 + LBMI_BASEADDRESS,(IPTR)&surface->pixels,
11051 + LBMI_BYTESPERROW,(IPTR)&pitch,TAG_DONE)) != NULL)
11053 + D(bug("Done...\n"));
11054 + surface->pitch=pitch;
11058 + D(bug("Couldn't lock surface!\n"));
11062 + D(else bug("Already locked!!!\n"));
11068 +#if !defined(PROTO_SDL_H)
11069 +void CGX_UnlockHWSurface(_THIS, SDL_Surface *surface)
11071 +void CGX_UnlockHWSurfaceI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
11074 +#ifndef NO_AMIGAHWSURF
11075 + if((surface->hwdata) && (surface->hwdata->lock))
11077 + D(bug("Unlocking a bitmap...\n"));
11078 + UnLockBitMap(surface->hwdata->lock);
11079 + surface->hwdata->lock = NULL;
11081 + /* refresh display if pending */
11082 + if ((surface->hwdata->bmap == this->hidden->BlitBitMap) && surface->hwdata->update)
11084 + surface->hwdata->update = 0;
11085 + BltBitMapRastPort( this->hidden->BlitBitMap,
11089 + SDL_Window->BorderLeft,
11090 + SDL_Window->BorderTop,
11099 +#if !defined(PROTO_SDL_H)
11100 +int CGX_FlipHWSurface(_THIS, SDL_Surface *surface)
11102 +int CGX_FlipHWSurfaceI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
11105 + static int current=0;
11106 + static BOOL SafeDisp=TRUE;
11107 + static BOOL SafeChange=TRUE;
11109 + if(this->hidden->dbuffer)
11111 + D(bug("Double Buffering Flip to surface %d\n", current^1));
11115 + Wait(this->hidden->disp_sigbit);
11116 + while(GetMsg(this->hidden->dispport)!=NULL);
11120 + if(ChangeScreenBuffer(SDL_Display,this->hidden->SB[current^1]))
11122 + surface->hwdata->bmap=SDL_RastPort->BitMap=this->hidden->SB[current]->sb_BitMap;
11123 + SafeChange=FALSE;
11130 + Wait(this->hidden->safe_sigbit);
11131 + while(GetMsg(this->hidden->safeport)!=NULL);
11136 + else if (this->hidden->BlitBitMap)
11138 + D(bug("[SDL] CGX_FakeFlipSurface - blit offscreen bitmap\n"));
11140 + if (this->screen->hwdata->lock)
11141 + this->screen->hwdata->update = 1;
11143 + BltBitMapRastPort( this->hidden->BlitBitMap,
11147 + SDL_Window->BorderLeft,
11148 + SDL_Window->BorderTop,
11157 +#if !defined(PROTO_SDL_H)
11158 +int CGX_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
11160 +int CGX_FillHWRectI(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color, struct SDLBase *SDLBase)
11165 + D(bug("CGX_FillHWRect\n"));
11169 + if (dst->format->BitsPerPixel > 8)
11170 + col = (((color & dst->format->Amask) >> dst->format->Ashift) << (dst->format->Aloss + 24))
11171 + | (((color & dst->format->Rmask) >> dst->format->Rshift) << (dst->format->Rloss + 16))
11172 + | (((color & dst->format->Gmask) >> dst->format->Gshift) << (dst->format->Gloss + 8))
11173 + | (((color & dst->format->Bmask) >> dst->format->Bshift) << dst->format->Bloss);
11177 + if(!SDL_temprp) SDL_temprp = CreateRastPort();
11178 + SDL_temprp->BitMap=(struct BitMap *)dst->hwdata->bmap;
11180 + FillPixelArray(SDL_temprp,dstrect->x,dstrect->y,dstrect->w,dstrect->h,col);
11185 +#ifndef NO_AMIGAHWSURF
11186 +#if !defined(PROTO_SDL_H)
11187 +int CGX_CheckHWBlit(_THIS,SDL_Surface *src,SDL_Surface *dst)
11189 +int CGX_CheckHWBlitI(_THIS, SDL_Surface *src, SDL_Surface *dst, struct SDLBase *SDLBase)
11198 + // SOURCE is a HW Bitmap
11199 + switch (src->flags & (SDL_SRCALPHA|SDL_SRCCOLORKEY))
11201 + case (SDL_SRCALPHA|SDL_SRCCOLORKEY):
11202 + if ( CGX_SetHWColorKey(this, src, src->format->colorkey) < 0 )
11204 + D(bug("CheckHW blit : HW to HW CC+ALPHA... NOK!\n"));
11205 + src->flags &= ~SDL_HWACCEL;
11209 + D(bug("CheckHW blit : HW to HW CC+ALPHA... OK!\n"));
11210 + src->flags |= SDL_HWACCEL;
11211 + src->map->hw_blit = CGX_HWtoHWBlitA;
11216 + case (SDL_SRCCOLORKEY):
11217 + if ( CGX_SetHWColorKey(this, src, src->format->colorkey) < 0 )
11219 + D(bug("CheckHW blit : HW to HW CC... NOK!\n"));
11220 + src->flags &= ~SDL_HWACCEL;
11224 + D(bug("CheckHW blit : HW to HW CC... OK!\n"));
11225 + src->flags |= SDL_HWACCEL;
11226 + src->map->hw_blit = CGX_HWtoHWBlitCC;
11231 + case (SDL_SRCALPHA):
11232 + if ( CGX_CreateAlphaPixMap(this, src) < 0 )
11234 + D(bug("CheckHW blit : HW to HW ALPHA... NOK!\n"));
11235 + src->flags &= ~SDL_HWACCEL;
11239 + D(bug("CheckHW blit : HW to HW ALPHA... OK!\n"));
11240 + src->flags |= SDL_HWACCEL;
11241 + src->map->hw_blit = CGX_HWtoHWBlitA;
11247 + D(bug("CheckHW blit : HW to HW OK!\n"));
11248 + src->flags |= SDL_HWACCEL;
11249 + src->map->hw_blit = CGX_HWtoHWBlit;
11256 + // SOURCE is a SW pixel array
11257 + switch (src->flags & (SDL_SRCALPHA|SDL_SRCCOLORKEY))
11259 + case (SDL_SRCALPHA|SDL_SRCCOLORKEY):
11260 + if (CGX_ColorKeyToAlpha( this, src, src->format->colorkey) < 0)
11262 + D(bug("CheckHW blit : SW to HW CC+ALPHA... NOK!\n"));
11263 + src->flags &= ~SDL_HWACCEL;
11267 + D(bug("CheckHW blit : SW to HW CC+ALPHA... OK!\n"));
11268 + src->flags |= SDL_HWACCEL;
11269 + src->map->hw_blit = CGX_SWtoHWBlitA;
11274 + case (SDL_SRCCOLORKEY):
11275 + if (CGX_ColorKeyToAlpha( this, src, src->format->colorkey) < 0)
11277 + D(bug("CheckHW blit : SW to HW CC... NOK!\n"));
11278 + src->flags &= ~SDL_HWACCEL;
11282 + D(bug("CheckHW blit : SW to HW CC... OK!\n"));
11283 + src->flags |= SDL_HWACCEL;
11284 + src->map->hw_blit = CGX_SWtoHWBlitCC;
11289 + case (SDL_SRCALPHA):
11290 + D(bug("CheckHW blit : SW to HW ALPHA... OK!\n"));
11291 + src->flags |= SDL_HWACCEL;
11292 + src->map->hw_blit = CGX_SWtoHWBlitA;
11297 + D(bug("CheckHW blit : SW to HW... OK!\n"));
11298 + src->flags |= SDL_HWACCEL;
11299 + src->map->hw_blit = CGX_SWtoHWBlit;
11307 + src->flags &= ~SDL_HWACCEL;
11308 + D(bug("HW blitting not available\n"));
11314 +#if !defined(PROTO_SDL_H)
11315 +int CGX_CreateAlphaPixMap(_THIS,SDL_Surface *surface)
11317 +int CGX_CreateAlphaPixMapI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
11321 + We are creating a pixmap in system memory with alpha channel (RGBA format)
11322 + Doesn't work yet for 8 bits per pixel format!
11328 + D(bug("CGX_CreateAlphaPixMap\n"));
11330 + if ( (surface->hwdata)
11331 + && (surface->format->BytesPerPixel > 1))
11333 + if (surface->hwdata->pixarrayalpha) SDL_free(surface->hwdata->pixarrayalpha);
11334 + if ((surface->hwdata->pixarrayalpha = SDL_malloc(surface->w * surface->h * 4)) != NULL)
11336 + if(!SDL_temprp) SDL_temprp = CreateRastPort();
11337 + SDL_temprp->BitMap=(struct BitMap *)surface->hwdata->bmap;
11339 + ReadPixelArray( surface->hwdata->pixarrayalpha,
11350 + if (surface->hwdata->pixarrayalpha)
11352 + /* if source data is without alpha channel it has to be set manually to 255 */
11353 + if ( (surface->hwdata->pixfmt != PIXFMT_ARGB32)
11354 + || (surface->hwdata->pixfmt != PIXFMT_BGRA32)
11355 + || (surface->hwdata->pixfmt != PIXFMT_RGBA32))
11357 + pix = (ULONG *)surface->hwdata->pixarrayalpha;
11358 + for (i = 0; i < surface->w * surface->h; i++) pix[i] |= AROS_BE2LONG(0xFF000000);
11369 +#if !defined(PROTO_SDL_H)
11370 +int CGX_SetHWColorKey(_THIS,SDL_Surface *surface, Uint32 key)
11372 +int CGX_SetHWColorKeyI(_THIS, SDL_Surface *surface, Uint32 key, struct SDLBase *SDLBase)
11376 + We are creating a pixmap in system memory with alpha channel (RGBA format)
11377 + The ColorKey is encoded in the Alpha channel
11378 + Doesn't work yet for 8 bits per pixel format!
11381 + ULONG ARGBKey = 0x00000000;
11382 + ULONG *currentpix;
11385 + D(bug("CGX_SetHWColorKey\n"));
11387 + result = CGX_CreateAlphaPixMap(this,surface);
11391 + /* Convert ColorKey to ARGB format (Do not take Alpha channel into account)*/
11392 + ARGBKey = (((key & surface->format->Rmask) >> surface->format->Rshift) << (surface->format->Rloss + 16))
11393 + | (((key & surface->format->Gmask) >> surface->format->Gshift) << (surface->format->Gloss + 8))
11394 + | (((key & surface->format->Bmask) >> surface->format->Bshift) << (surface->format->Bloss + 0));
11396 + currentpix = (ULONG *)surface->hwdata->pixarrayalpha;
11397 + for (pixnum = 0; pixnum<surface->w*surface->h; pixnum++)
11399 + if ((currentpix[pixnum] & AROS_BE2LONG(0x00FFFFFF)) == AROS_BE2LONG(ARGBKey))
11401 + /* Keep color but put alpha channel to fully transparent (0 : TBC)*/
11402 + currentpix[pixnum] = (currentpix[pixnum] & AROS_BE2LONG(0x00FFFFFF));
11409 +#if !defined(PROTO_SDL_H)
11410 +int CGX_ColorKeyToAlpha(_THIS,SDL_Surface *surface, Uint32 key)
11412 +int CGX_ColorKeyToAlphaI(_THIS, SDL_Surface *surface, Uint32 key, struct SDLBase *SDLBase)
11415 + /* Includes the ColorKey in the Alpha Channel of a SW surface */
11417 + ULONG ARGBKey = 0x00000000;
11418 + ULONG *currentpix;
11421 + D(bug("CGX_ColorKeyToAlpha\n"));
11422 + // FIXME: Potential endianess issue here!
11424 + /* Only works for 32bits surfaces in ARGB format */
11425 + if ( (surface->format->BytesPerPixel == 4)
11426 + && (surface->format->Rmask == AROS_BE2LONG(0x00FF0000))
11427 + && (surface->format->Gmask == AROS_BE2LONG(0x0000FF00))
11428 + && (surface->format->Bmask == AROS_BE2LONG(0x000000FF)) )
11430 + /* Convert ColorKey to ARGB format (Do not take Alpha channel into account)*/
11431 + ARGBKey = (((key & surface->format->Rmask) >> surface->format->Rshift) << (surface->format->Rloss + 16))
11432 + | (((key & surface->format->Gmask) >> surface->format->Gshift) << (surface->format->Gloss + 8))
11433 + | (((key & surface->format->Bmask) >> surface->format->Bshift) << (surface->format->Bloss + 0));
11436 + currentpix = (ULONG *)surface->pixels;
11437 + for (pixnum = 0; pixnum<surface->w*surface->h; pixnum++)
11439 + if ((currentpix[pixnum] & AROS_BE2LONG(0x00FFFFFF)) == AROS_BE2LONG(ARGBKey))
11441 + /* Keep color but put alpha channel to fully transparent (0 : TBC)*/
11442 + currentpix[pixnum] = (currentpix[pixnum] & AROS_BE2LONG(0x00FFFFFF));
11450 +static int CGX_HWtoHWBlit( SDL_Surface *src, SDL_Rect *srcrect,
11451 + SDL_Surface *dst, SDL_Rect *dstrect)
11453 + D(bug("Accelerated HW to HW blit\n"));
11455 + BltBitMap( src->hwdata->bmap,
11458 + dst->hwdata->bmap,
11470 +static int CGX_HWtoHWBlitA( SDL_Surface *src, SDL_Rect *srcrect,
11471 + SDL_Surface *dst, SDL_Rect *dstrect)
11473 + struct SDL_VideoDevice *this = dst->hwdata->videodata;
11475 + D(bug("Accelerated HW to HW blit with Alpha channel\n"));
11477 + if (src->hwdata->pixarrayalpha)
11479 + if(!SDL_temprp) SDL_temprp = CreateRastPort();
11480 + SDL_temprp->BitMap=(struct BitMap *)dst->hwdata->bmap;
11482 + WritePixelArrayAlpha( src->hwdata->pixarrayalpha,
11491 + 0x01010101 * src->format->alpha );
11496 +static int CGX_HWtoHWBlitCC(SDL_Surface *src, SDL_Rect *srcrect,
11497 + SDL_Surface *dst, SDL_Rect *dstrect)
11499 + struct SDL_VideoDevice *this = dst->hwdata->videodata;
11501 + D(bug("Accelerated HW to HW blit with ColorKey\n"));
11503 + if (src->hwdata->pixarrayalpha)
11505 + if(!SDL_temprp) SDL_temprp = CreateRastPort();
11506 + SDL_temprp->BitMap=(struct BitMap *)dst->hwdata->bmap;
11508 + WritePixelArrayAlpha( src->hwdata->pixarrayalpha,
11522 +static int CGX_SWtoHWBlit( SDL_Surface *src, SDL_Rect *srcrect,
11523 + SDL_Surface *dst, SDL_Rect *dstrect)
11526 + struct SDL_VideoDevice *this = dst->hwdata->videodata;
11528 + D(bug("Accelerated SW to HW blit\n"));
11530 + format=CGX_MaskToRECTFMT( src->format->Amask,
11531 + src->format->Rmask,
11532 + src->format->Gmask,
11533 + src->format->Bmask);
11535 + if(!SDL_temprp) SDL_temprp = CreateRastPort();
11536 + SDL_temprp->BitMap=(struct BitMap *)dst->hwdata->bmap;
11538 + WritePixelArray( src->pixels,
11552 +static int CGX_SWtoHWBlitA( SDL_Surface *src, SDL_Rect *srcrect,
11553 + SDL_Surface *dst, SDL_Rect *dstrect)
11556 + WritePixelArrayAlpha only works with pixels array in ARGB format
11557 + That's why we've forced the use of this format when 32 bit surface is requested
11558 + This however will have to be checked if really working or not
11560 + struct SDL_VideoDevice *this = dst->hwdata->videodata;
11562 + D(bug("Accelerated SW to HW blit with ALPHA\n"));
11566 + if(!SDL_temprp) SDL_temprp = CreateRastPort();
11567 + SDL_temprp->BitMap=(struct BitMap *)dst->hwdata->bmap;
11569 + WritePixelArrayAlpha( src->pixels,
11578 + 0x01010101 * src->format->alpha );
11583 +static int CGX_SWtoHWBlitCC(SDL_Surface *src, SDL_Rect *srcrect,
11584 + SDL_Surface *dst, SDL_Rect *dstrect)
11586 + struct SDL_VideoDevice *this = dst->hwdata->videodata;
11588 + D(bug("Accelerated SW to HW blit with CC\n"));
11590 + if(!SDL_temprp) SDL_temprp = CreateRastPort();
11591 + SDL_temprp->BitMap=(struct BitMap *)dst->hwdata->bmap;
11593 + WritePixelArrayAlpha( src->pixels,
11607 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxaccel_c.h SDL-1.2.15/src/video/cgx/SDL_cgxaccel_c.h
11608 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxaccel_c.h 1970-01-01 01:00:00.000000000 +0100
11609 +++ SDL-1.2.15/src/video/cgx/SDL_cgxaccel_c.h 2015-05-09 15:09:59.766739512 +0200
11612 + SDL - Simple DirectMedia Layer
11613 + Copyright (C) 1997-2006 Sam Lantinga
11615 + This library is free software; you can redistribute it and/or
11616 + modify it under the terms of the GNU Lesser General Public
11617 + License as published by the Free Software Foundation; either
11618 + version 2.1 of the License, or (at your option) any later version.
11620 + This library is distributed in the hope that it will be useful,
11621 + but WITHOUT ANY WARRANTY; without even the implied warranty of
11622 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11623 + Lesser General Public License for more details.
11625 + You should have received a copy of the GNU Lesser General Public
11626 + License along with this library; if not, write to the Free Software
11627 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
11630 + slouken@libsdl.org
11632 +#include "SDL_config.h"
11634 +#include "SDL_cgxvideo.h"
11635 +#include "SDL_cgximage_c.h"
11637 +#if !defined(PROTO_SDL_H)
11638 +extern int CGX_AllocHWSurface(_THIS, SDL_Surface *surface);
11639 +extern void CGX_FreeHWSurface(_THIS, SDL_Surface *surface);
11640 +extern int CGX_LockHWSurface(_THIS, SDL_Surface *surface);
11641 +extern void CGX_UnlockHWSurface(_THIS, SDL_Surface *surface);
11642 +extern int CGX_FlipHWSurface(_THIS, SDL_Surface *surface);
11643 +extern int CGX_FillHWRect(_THIS,SDL_Surface *dst,SDL_Rect *dstrect,Uint32 color);
11644 +#ifndef NO_AMIGAHWSURF
11645 +extern int CGX_CheckHWBlit(_THIS,SDL_Surface *src,SDL_Surface *dst);
11646 +extern int CGX_SetHWColorKey(_THIS,SDL_Surface *surface, Uint32 key);
11647 +extern int CGX_CreateAlphaPixMap(_THIS,SDL_Surface *surface);
11648 +extern int CGX_ColorKeyToAlpha(_THIS,SDL_Surface *surface, Uint32 key);
11651 +extern int CGX_AllocHWSurfaceI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
11652 +extern void CGX_FreeHWSurfaceI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
11653 +extern int CGX_LockHWSurfaceI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
11654 +extern void CGX_UnlockHWSurfaceI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
11655 +extern int CGX_FlipHWSurfaceI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
11656 +extern int CGX_FillHWRectI(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 colo, struct SDLBase *SDLBase);
11657 +#ifndef NO_AMIGAHWSURF
11658 +extern int CGX_CheckHWBlitI(_THIS, SDL_Surface *src, SDL_Surface *dst, struct SDLBase *SDLBase);
11659 +extern int CGX_SetHWColorKeyI(_THIS, SDL_Surface *surface, Uint32 key, struct SDLBase *SDLBase);
11660 +extern int CGX_CreateAlphaPixMapI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
11661 +extern int CGX_ColorKeyToAlphaI(_THIS, SDL_Surface *surface, Uint32 key, struct SDLBase *SDLBase);
11663 +#define CGX_CheckHWBlit(this, src, dst) CGX_CheckHWBlitI(this, src, dst, SDLBase)
11664 +#define CGX_SetHWColorKey(this, surface, key) CGX_SetHWColorKeyI(this, surface, key, SDLBase)
11665 +#define CGX_CreateAlphaPixMap(this, surface) CGX_CreateAlphaPixMapI(this, surface, SDLBase)
11666 +#define CGX_ColorKeyToAlpha(this, surface, key) CGX_ColorKeyToAlphaI(this, surface, key, SDLBase)
11668 +#define CGX_AllocHWSurface(this, surface) CGX_AllocHWSurfaceI(this, surface, SDLBase)
11669 +#define CGX_FreeHWSurface(this, surface) CGX_FreeHWSurfaceI(this, surface, SDLBase)
11670 +#define CGX_LockHWSurface(this, surface) CGX_LockHWSurfaceI(this, surface, SDLBase)
11671 +#define CGX_UnlockHWSurface(this, surface) CGX_UnlockHWSurfaceI(this, surface, SDLBase)
11672 +#define CGX_FlipHWSurface(this, surface) CGX_FlipHWSurfaceI(this, surface, SDLBase)
11673 +#define CGX_FillHWRect(this, dst, dstrect, colo) CGX_FillHWRectI(this, dst, dstrect, colo, SDLBase)
11675 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxevents.c SDL-1.2.15/src/video/cgx/SDL_cgxevents.c
11676 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxevents.c 1970-01-01 01:00:00.000000000 +0100
11677 +++ SDL-1.2.15/src/video/cgx/SDL_cgxevents.c 2015-05-09 15:09:59.766739512 +0200
11680 + SDL - Simple DirectMedia Layer
11681 + Copyright (C) 1997-2006 Sam Lantinga
11683 + This library is free software; you can redistribute it and/or
11684 + modify it under the terms of the GNU Lesser General Public
11685 + License as published by the Free Software Foundation; either
11686 + version 2.1 of the License, or (at your option) any later version.
11688 + This library is distributed in the hope that it will be useful,
11689 + but WITHOUT ANY WARRANTY; without even the implied warranty of
11690 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11691 + Lesser General Public License for more details.
11693 + You should have received a copy of the GNU Lesser General Public
11694 + License along with this library; if not, write to the Free Software
11695 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
11698 + slouken@libsdl.org
11700 +#if defined (SDL_AROS_SHARED)
11701 +#define __NOLIBBASE__
11702 +#include <proto/SDL.h>
11705 +#include "SDL_config.h"
11707 +/* Handle the event stream, converting Amiga events into SDL events */
11710 +#include "SDL_syswm.h"
11711 +#include "../SDL_sysvideo.h"
11712 +#include "../../events/SDL_sysevents.h"
11713 +#include "../../events/SDL_events_c.h"
11714 +#include "SDL_cgxvideo.h"
11715 +#include "SDL_cgxmodes_c.h"
11716 +#include "SDL_cgximage_c.h"
11717 +#include "SDL_cgxwm_c.h"
11718 +#include "SDL_cgxmouse_c.h"
11719 +#include "SDL_cgxevents_c.h"
11721 +#if defined(PROTO_SDL_H)
11722 +#include "SDL_intern.h"
11723 +#define current_video SDLBase->current_video
11726 +/* The translation tables from an Amiga keysym to a SDL keysym */
11727 +static SDLKey MISC_keymap[256];
11729 +struct IOStdReq* SDL_ConReq=NULL;
11730 +struct MsgPort* SDL_ConPort=NULL;
11732 +#if !defined(PROTO_SDL_H)
11733 +SDL_keysym *CGX_TranslateKey(int code, UWORD qualifier, SDL_keysym *keysym)
11735 +#define CGX_TranslateKey(code, qualifier, keysym) CGX_TranslateKeyI(code, qualifier, keysym, SDLBase)
11736 +SDL_keysym *CGX_TranslateKeyI(int code, UWORD qualifier, SDL_keysym *keysym, struct SDLBase *SDLBase)
11739 + struct InputEvent event;
11743 + static struct Device *ConsoleDevice=NULL;
11745 + /* Get the raw keyboard scancode */
11746 + keysym->scancode = code;
11747 + keysym->sym = MISC_keymap[code];
11749 + if(!ConsoleDevice)
11751 + if((SDL_ConPort=CreateMsgPort()))
11753 + if((SDL_ConReq=CreateIORequest(SDL_ConPort,sizeof(struct IOStdReq))))
11755 + if(!OpenDevice("console.device",-1,(struct IORequest *)SDL_ConReq,0))
11756 + ConsoleDevice=(struct Device *)SDL_ConReq->io_Device;
11759 + DeleteIORequest(SDL_ConReq);
11765 + DeleteMsgPort(SDL_ConPort);
11766 + SDL_ConPort=NULL;
11770 + /* Get the translated SDL virtual keysym */
11771 + if ( keysym->sym==SDLK_UNKNOWN )
11773 + if(ConsoleDevice)
11775 + event.ie_Qualifier=0;
11776 + event.ie_Class=IECLASS_RAWKEY;
11777 + event.ie_SubClass=0L;
11778 + event.ie_Code=code & ~(IECODE_UP_PREFIX);
11779 + event.ie_X=event.ie_Y=0;
11780 + event.ie_EventAddress=NULL;
11781 + event.ie_NextEvent=NULL;
11782 + event.ie_Prev1DownCode=event.ie_Prev1DownQual=event.ie_Prev2DownCode=event.ie_Prev2DownQual=0;
11784 + if( (actual=RawKeyConvert(&event,buffer,5,NULL))==1)
11786 + keysym->sym = (buffer[0] & 0xFF);
11787 + D(bug("Converted rawcode %ld to <%lc>\n",code,*buffer));
11788 + // Buffering for successive calls
11789 + MISC_keymap[code]= (buffer[0] & 0xFF);
11791 + else D(bug("Warning (%ld) character conversion!\n",actual));
11795 + keysym->mod = KMOD_NONE;
11797 + /* If UNICODE is on, get the UNICODE value for the key */
11798 + /*Bad hack, only ascii values are returned, RawKeyConvert doesn't return unicode or? */
11799 + keysym->unicode = 0;
11800 + if ( SDL_TranslateUNICODE )
11802 + if(ConsoleDevice)
11804 + event.ie_Class = IECLASS_RAWKEY;
11805 + event.ie_SubClass = 0;
11806 + event.ie_Code = code & ~(IECODE_UP_PREFIX);
11807 + event.ie_Qualifier = qualifier;
11808 + event.ie_EventAddress = NULL;
11810 + actual = RawKeyConvert(&event, buffer, 5, 0);
11812 + if ((actual == 1) && (keysym->sym!=SDLK_UNKNOWN)) keysym->unicode = (buffer[0] & 0xFF);
11818 +static int CGX_GetButton(int code)
11822 + case IECODE_MBUTTON:
11823 + return SDL_BUTTON_MIDDLE;
11824 + case IECODE_RBUTTON:
11825 + return SDL_BUTTON_RIGHT;
11827 + return SDL_BUTTON_LEFT;
11831 +#if !defined(PROTO_SDL_H)
11832 +static int CGX_FocusActivate(_THIS, BOOL activate)
11834 +#define CGX_FocusActivate(this, activate) CGX_FocusActivateI(this, activate, SDLBase)
11835 +static int CGX_FocusActivateI(_THIS, BOOL activate, struct SDLBase *SDLBase)
11839 + int val = activate ? 1 : 0;
11841 + posted = SDL_PrivateAppActive(val, SDL_APPMOUSEFOCUS);
11842 + posted |= SDL_PrivateAppActive(val, SDL_APPINPUTFOCUS);
11843 + this->hidden->FocusActive = val;
11848 +static int CGX_IsMouseInsideDrawArea(int mouseX, int mouseY, struct Window * wnd)
11850 + if ((mouseX < (wnd->BorderLeft)) ||
11851 + (mouseX > (wnd->Width - wnd->BorderRight)))
11853 + if ((mouseY < (wnd->BorderTop)) ||
11854 + (mouseY > (wnd->Height - wnd->BorderBottom)))
11861 + * FocusActive handling:
11862 + * How to loose focus:
11863 + * - If !GrabMouse and WindowActive and Exit window drawing area
11864 + * - ALT + TAB = IDCMP_IACTIVEWINDOW
11865 + * How to gain focus:
11866 + * - If WindowActive and Enter window drawing area and !ExplicitFocusActivation
11867 + * - Open SDL_FULLSCREEN mode (indirect via clearing ExplicitFocusFlag)
11868 + * - If ExplicitFocusActivation and Click in window drawing area
11870 +#if !defined(PROTO_SDL_H)
11871 +static int CGX_DispatchEvent(_THIS, struct IntuiMessage *msg)
11873 +#define CGX_DispatchEvent(this, msg) CGX_DispatchEventI(this, msg, SDLBase)
11874 +static int CGX_DispatchEventI(_THIS, struct IntuiMessage *msg, struct SDLBase *SDLBase)
11877 + int class=msg->Class,code=msg->Code;
11882 + /* Gaining app & mouse focus */
11883 + case IDCMP_ACTIVEWINDOW:
11884 + this->hidden->WindowActive = 1;
11887 + /* Loosing app & mouse focus */
11888 + case IDCMP_INACTIVEWINDOW:
11889 + /* If mouse is grabbed, request explicit activation */
11890 + if (this->hidden->GrabMouse)
11891 + this->hidden->ExplicitFocusActivation = 1;
11892 + posted = CGX_FocusActivate(this, FALSE);
11893 + this->hidden->WindowActive = 0;
11896 + /* Mouse motion */
11897 + case IDCMP_MOUSEMOVE:
11898 + if ( SDL_VideoSurface )
11900 + int new_x, new_y, dx = 0, dy = 0;
11902 + if (currently_fullscreen)
11904 + /* Center display on screen */
11905 + dx = (SDL_Display->Width - this->screen->w)/2;
11906 + dy = (SDL_Display->Height - this->screen->h)/2;
11909 + /* Check for activation/deactivation of App */
11910 + if (this->hidden->WindowActive)
11912 + /* Exit only if not grabbed */
11913 + if (this->hidden->FocusActive && !this->hidden->GrabMouse &&
11914 + !CGX_IsMouseInsideDrawArea(msg->MouseX, msg->MouseY, SDL_Window))
11915 + posted |= CGX_FocusActivate(this, FALSE);
11917 + /* Enter only if not explicit focus activation needed */
11918 + if (!this->hidden->FocusActive && !this->hidden->ExplicitFocusActivation &&
11919 + CGX_IsMouseInsideDrawArea(msg->MouseX, msg->MouseY, SDL_Window))
11920 + posted |= CGX_FocusActivate(this, TRUE);
11923 + /* These are coords "inside" AROS window (without borders) */
11924 + new_x = msg->MouseX - SDL_Window->BorderLeft;
11925 + new_y = msg->MouseY - SDL_Window->BorderTop;
11927 + if (this->hidden->FocusActive && this->hidden->GrabMouse)
11929 + if (!this->hidden->CursorVisible)
11931 + /* This is a special case in SDL documentation. When
11932 + GrabMouse and !CursonVisible, always post relative
11933 + move events. Always warp to center of screen. */
11934 + int center_x = this->screen->w / 2;
11935 + int center_y = this->screen->h / 2;
11937 + if ((new_x == center_x) && (new_y == center_y))
11939 + /* Do nothing - this is a signal generated by warp call. */
11943 + int rel_x = msg->MouseX - this->hidden->LastMouseX;
11944 + int rel_y = msg->MouseY - this->hidden->LastMouseY;
11947 + * Send "recall" event only when cursor leaves 1/2 of inner area
11948 + of window. Sending the event each mouse event casues an increasing
11949 + stall with DoIO call. The root cause of this stall is unknown.
11950 + The workaround seems to avoid the stall. */
11951 + if ((new_x < center_x / 2) || (new_x > (center_x * 3 / 2)) ||
11952 + (new_y < center_y / 2) || (new_y > (center_y * 3 / 2)))
11953 + CGX_WarpWMCursor(this, center_x, center_y);
11954 + posted |= SDL_PrivateMouseMotion(0, 1, rel_x, rel_y);
11959 + BOOL dowarp = FALSE;
11961 + if (new_x - dx < 0)
11966 + else if (new_x - dx > this->screen->w - 1)
11969 + new_x = dx + this->screen->w - 1;
11972 + if (new_y - dy < 0)
11977 + else if (new_y - dy > this->screen->h - 1)
11980 + new_y = dy + this->screen->h - 1;
11983 + if (dowarp) CGX_WarpWMCursor(this, new_x, new_y);
11984 + posted |= SDL_PrivateMouseMotion(0, 0, new_x - dx, new_y - dy);
11988 + posted |= SDL_PrivateMouseMotion(0, 0, new_x - dx, new_y - dy);
11990 + this->hidden->LastMouseX = msg->MouseX;
11991 + this->hidden->LastMouseY = msg->MouseY;
11996 + case IDCMP_MOUSEBUTTONS:
11997 + /* Mouse button press? */
11998 + if(!(code&IECODE_UP_PREFIX))
12000 + /* Explicit focus activation case */
12001 + if (this->hidden->ExplicitFocusActivation &&
12002 + CGX_IsMouseInsideDrawArea(msg->MouseX, msg->MouseY, SDL_Window))
12004 + this->hidden->ExplicitFocusActivation = 0;
12005 + posted |= CGX_FocusActivate(this, TRUE);
12009 + posted |= SDL_PrivateMouseButton(SDL_PRESSED,
12010 + CGX_GetButton(code), 0, 0);
12013 + /* Mouse button release? */
12016 + code&=~IECODE_UP_PREFIX;
12017 + posted = SDL_PrivateMouseButton(SDL_RELEASED,
12018 + CGX_GetButton(code), 0, 0);
12022 + case IDCMP_RAWKEY:
12023 + /* Mouse wheel support */
12024 + if (code == RAWKEY_NM_WHEEL_UP)
12026 + posted = SDL_PrivateMouseButton(SDL_PRESSED,
12027 + SDL_BUTTON_WHEELUP, 0, 0);
12028 + posted |= SDL_PrivateMouseButton(SDL_RELEASED,
12029 + SDL_BUTTON_WHEELUP, 0, 0);
12033 + if (code == RAWKEY_NM_WHEEL_DOWN)
12035 + posted = SDL_PrivateMouseButton(SDL_PRESSED,
12036 + SDL_BUTTON_WHEELDOWN, 0, 0);
12037 + posted |= SDL_PrivateMouseButton(SDL_RELEASED,
12038 + SDL_BUTTON_WHEELDOWN, 0, 0);
12042 + if( !(code&IECODE_UP_PREFIX) )
12045 + SDL_keysym keysym;
12046 + posted = SDL_PrivateKeyboard(SDL_PRESSED,
12047 + CGX_TranslateKey(code, msg->Qualifier, &keysym));
12051 + /* Key release */
12052 + SDL_keysym keysym;
12053 + code&=~IECODE_UP_PREFIX;
12054 + posted = SDL_PrivateKeyboard(SDL_RELEASED,
12055 + CGX_TranslateKey(code, msg->Qualifier, &keysym));
12059 + /* Have we been resized? */
12060 + case IDCMP_NEWSIZE:
12061 + SDL_PrivateResize(SDL_Window->Width-SDL_Window->BorderLeft-SDL_Window->BorderRight,
12062 + SDL_Window->Height-SDL_Window->BorderTop-SDL_Window->BorderBottom);
12066 + /* Have we been requested to quit? */
12067 + case IDCMP_CLOSEWINDOW:
12068 + posted = SDL_PrivateQuit();
12071 + /* Do we need to refresh ourselves? */
12074 + /* Only post the event if we're watching for it */
12075 + if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
12076 + SDL_SysWMmsg wmmsg;
12078 + SDL_VERSION(&wmmsg.version);
12080 + posted = SDL_PrivateSysWMEvent(&wmmsg);
12085 + ReplyMsg((struct Message *)msg);
12090 +#if !defined(PROTO_SDL_H)
12091 +void CGX_PumpEvents(_THIS)
12093 +void CGX_PumpEvents(_THIS, struct SDLBase *SDLBase)
12096 + struct IntuiMessage *m;
12099 + while (( m=(struct IntuiMessage *)GetMsg(SDL_Window->UserPort) ))
12101 + CGX_DispatchEvent(this, m );
12105 +#if !defined(PROTO_SDL_H)
12106 +void CGX_InitOSKeymap(_THIS)
12108 +void CGX_InitOSKeymap(_THIS, struct SDLBase *SDLBase)
12113 + /* Map the miscellaneous keys */
12114 + for ( i=0; i<SDL_arraysize(MISC_keymap); ++i )
12115 + MISC_keymap[i] = SDLK_UNKNOWN;
12117 + MISC_keymap[RAWKEY_BACKSPACE ] = SDLK_BACKSPACE;
12118 + MISC_keymap[RAWKEY_TAB ] = SDLK_TAB;
12119 + MISC_keymap[RAWKEY_DELETE ] = SDLK_DELETE;
12120 + MISC_keymap[RAWKEY_RETURN ] = SDLK_RETURN;
12121 + MISC_keymap[RAWKEY_ESCAPE ] = SDLK_ESCAPE;
12122 + MISC_keymap[RAWKEY_KP_0 ] = SDLK_KP0; /* Keypad 0-9 */
12123 + MISC_keymap[RAWKEY_KP_1 ] = SDLK_KP1;
12124 + MISC_keymap[RAWKEY_KP_2 ] = SDLK_KP2;
12125 + MISC_keymap[RAWKEY_KP_3 ] = SDLK_KP3;
12126 + MISC_keymap[RAWKEY_KP_4 ] = SDLK_KP4;
12127 + MISC_keymap[RAWKEY_KP_5 ] = SDLK_KP5;
12128 + MISC_keymap[RAWKEY_KP_6 ] = SDLK_KP6;
12129 + MISC_keymap[RAWKEY_KP_7 ] = SDLK_KP7;
12130 + MISC_keymap[RAWKEY_KP_8 ] = SDLK_KP8;
12131 + MISC_keymap[RAWKEY_KP_9 ] = SDLK_KP9;
12132 + MISC_keymap[RAWKEY_KP_DECIMAL ] = SDLK_KP_PERIOD;
12133 + MISC_keymap[0x5A ] = SDLK_NUMLOCK;
12134 + MISC_keymap[0x5B ] = SDLK_KP_DIVIDE;
12135 + MISC_keymap[0x5C ] = SDLK_KP_MULTIPLY;
12136 + MISC_keymap[0x5D ] = SDLK_KP_MINUS;
12137 + MISC_keymap[RAWKEY_KP_PLUS ] = SDLK_KP_PLUS;
12138 + MISC_keymap[RAWKEY_KP_ENTER ] = SDLK_KP_ENTER;
12139 + MISC_keymap[RAWKEY_UP ] = SDLK_UP;
12140 + MISC_keymap[RAWKEY_DOWN ] = SDLK_DOWN;
12141 + MISC_keymap[RAWKEY_RIGHT ] = SDLK_RIGHT;
12142 + MISC_keymap[RAWKEY_LEFT ] = SDLK_LEFT;
12143 + MISC_keymap[RAWKEY_PAGEUP ] = SDLK_PAGEUP;
12144 + MISC_keymap[RAWKEY_PAGEDOWN ] = SDLK_PAGEDOWN;
12145 + MISC_keymap[RAWKEY_F1 ] = SDLK_F1;
12146 + MISC_keymap[RAWKEY_F2 ] = SDLK_F2;
12147 + MISC_keymap[RAWKEY_F3 ] = SDLK_F3;
12148 + MISC_keymap[RAWKEY_F4 ] = SDLK_F4;
12149 + MISC_keymap[RAWKEY_F5 ] = SDLK_F5;
12150 + MISC_keymap[RAWKEY_F6 ] = SDLK_F6;
12151 + MISC_keymap[RAWKEY_F7 ] = SDLK_F7;
12152 + MISC_keymap[RAWKEY_F8 ] = SDLK_F8;
12153 + MISC_keymap[RAWKEY_F9 ] = SDLK_F9;
12154 + MISC_keymap[RAWKEY_F10 ] = SDLK_F10;
12155 + MISC_keymap[RAWKEY_F11 ] = SDLK_F11; /* F11 is hard mapped to HELP on AROS */
12156 + MISC_keymap[RAWKEY_F12 ] = SDLK_F12; /* F12 is hard mapped to RSUPER on AROS */
12157 + MISC_keymap[RAWKEY_CAPSLOCK ] = SDLK_CAPSLOCK;
12158 + MISC_keymap[RAWKEY_RSHIFT ] = SDLK_RSHIFT;
12159 + MISC_keymap[RAWKEY_LSHIFT ] = SDLK_LSHIFT;
12160 + MISC_keymap[RAWKEY_CONTROL ] = SDLK_LCTRL; /* There is only one control key on an amiga keyboard! */
12161 + MISC_keymap[RAWKEY_RALT ] = SDLK_RALT;
12162 + MISC_keymap[RAWKEY_LALT ] = SDLK_LALT;
12163 + MISC_keymap[RAWKEY_LAMIGA ] = SDLK_LSUPER; /* Left "Windows" i.e "Amiga"*/
12164 + MISC_keymap[RAWKEY_RAMIGA ] = SDLK_RSUPER; /* Right "Windows i.e "Amiga"*/
12165 + MISC_keymap[RAWKEY_HELP ] = SDLK_HELP;
12166 + MISC_keymap[RAWKEY_INSERT ] = SDLK_INSERT;
12167 + MISC_keymap[RAWKEY_HOME ] = SDLK_HOME;
12168 + MISC_keymap[RAWKEY_END ] = SDLK_END;
12170 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxevents_c.h SDL-1.2.15/src/video/cgx/SDL_cgxevents_c.h
12171 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxevents_c.h 1970-01-01 01:00:00.000000000 +0100
12172 +++ SDL-1.2.15/src/video/cgx/SDL_cgxevents_c.h 2015-05-09 15:09:59.766739512 +0200
12175 + SDL - Simple DirectMedia Layer
12176 + Copyright (C) 1997-2006 Sam Lantinga
12178 + This library is free software; you can redistribute it and/or
12179 + modify it under the terms of the GNU Lesser General Public
12180 + License as published by the Free Software Foundation; either
12181 + version 2.1 of the License, or (at your option) any later version.
12183 + This library is distributed in the hope that it will be useful,
12184 + but WITHOUT ANY WARRANTY; without even the implied warranty of
12185 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12186 + Lesser General Public License for more details.
12188 + You should have received a copy of the GNU Lesser General Public
12189 + License along with this library; if not, write to the Free Software
12190 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
12193 + slouken@libsdl.org
12195 +#include "SDL_config.h"
12197 +#include "SDL_cgxvideo.h"
12199 +/* Functions to be exported */
12200 +#if !defined(PROTO_SDL_H)
12201 +extern void CGX_InitOSKeymap(_THIS);
12202 +extern void CGX_PumpEvents(_THIS);
12204 +extern void CGX_InitOSKeymap(_THIS, struct SDLBase *SDLBase);
12205 +extern void CGX_PumpEvents(_THIS, struct SDLBase *SDLBase);
12209 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_c.h SDL-1.2.15/src/video/cgx/SDL_cgxgl_c.h
12210 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_c.h 1970-01-01 01:00:00.000000000 +0100
12211 +++ SDL-1.2.15/src/video/cgx/SDL_cgxgl_c.h 2015-05-09 15:09:59.766739512 +0200
12214 + SDL - Simple DirectMedia Layer
12215 + Copyright (C) 1997-2006 Sam Lantinga
12217 + This library is free software; you can redistribute it and/or
12218 + modify it under the terms of the GNU Lesser General Public
12219 + License as published by the Free Software Foundation; either
12220 + version 2.1 of the License, or (at your option) any later version.
12222 + This library is distributed in the hope that it will be useful,
12223 + but WITHOUT ANY WARRANTY; without even the implied warranty of
12224 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12225 + Lesser General Public License for more details.
12227 + You should have received a copy of the GNU Lesser General Public
12228 + License along with this library; if not, write to the Free Software
12229 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
12232 + slouken@libsdl.org
12234 +#include "SDL_config.h"
12236 +#include "../SDL_sysvideo.h"
12238 +#if SDL_VIDEO_OPENGL
12239 +#include <proto/exec.h>
12240 +#include <GL/gla.h>
12243 +#define _THIS SDL_VideoDevice *_this
12245 +struct SDL_PrivateGLData {
12246 +#if SDL_VIDEO_OPENGL
12247 + GLAContext glctx;
12251 +#if !defined(PROTO_SDL_H)
12252 +/* OpenGL functions */
12253 +extern int CGX_GL_CreateContext(_THIS);
12254 +extern void CGX_GL_DestroyContext(_THIS);
12255 +extern void CGX_GL_Quit(_THIS);
12256 +extern int CGX_GL_UpdateContext(_THIS);
12257 +#if SDL_VIDEO_OPENGL
12258 +extern int CGX_GL_MakeCurrent(_THIS);
12259 +extern int CGX_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
12260 +extern void CGX_GL_SwapBuffers(_THIS);
12261 +extern void *CGX_GL_GetProcAddress(_THIS, const char *proc);
12262 +extern int CGX_GL_LoadLibrary(_THIS, const char *path);
12265 +/* OpenGL functions */
12266 +extern int CGX_GL_CreateContextI(_THIS, struct SDLBase *SDLBase);
12267 +extern void CGX_GL_DestroyContextI(_THIS, struct SDLBase *SDLBase);
12268 +extern void CGX_GL_QuitI(_THIS, struct SDLBase *SDLBase);
12269 +extern int CGX_GL_UpdateContextI(_THIS, struct SDLBase *SDLBase);
12270 +#if SDL_VIDEO_OPENGL
12271 +extern int CGX_GL_MakeCurrentI(_THIS, struct SDLBase *SDLBase);
12272 +extern int CGX_GL_GetAttributeI(_THIS, SDL_GLattr attrib, int* value, struct SDLBase *SDLBase);
12273 +extern void CGX_GL_SwapBuffersI(_THIS, struct SDLBase *SDLBase);
12274 +extern void *CGX_GL_GetProcAddressI(_THIS, const char *proc, struct SDLBase *SDLBase);
12275 +extern int CGX_GL_LoadLibraryI(_THIS, const char *path, struct SDLBase *SDLBase);
12277 +#define CGX_GL_MakeCurrent(this) CGX_GL_MakeCurrentI(this, SDLBase)
12278 +#define CGX_GL_GetAttribute(this, attrib, value) CGX_GL_GetAttributeI(this, attrib, value, SDLBase)
12279 +#define CGX_GL_SwapBuffers(this) CGX_GL_SwapBuffersI(this, SDLBase)
12280 +#define CGX_GL_GetProcAddress(this, proc) CGX_GL_GetProcAddressI(this, proc, SDLBase)
12281 +#define CGX_GL_LoadLibrary(this, path) CGX_GL_LoadLibraryI(this, path, SDLBase)
12283 +#define CGX_GL_CreateContext(this) CGX_GL_CreateContextI(this, SDLBase)
12284 +#define CGX_GL_DestroyContext(this) CGX_GL_DestroyContextI(this, SDLBase)
12285 +#define CGX_GL_Quit(this) CGX_GL_QuitI(this, SDLBase)
12286 +#define CGX_GL_UpdateContext(this) CGX_GL_UpdateContextI(this, SDLBase)
12290 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_CreateContext.c SDL-1.2.15/src/video/cgx/SDL_cgxgl_CreateContext.c
12291 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_CreateContext.c 1970-01-01 01:00:00.000000000 +0100
12292 +++ SDL-1.2.15/src/video/cgx/SDL_cgxgl_CreateContext.c 2015-05-09 15:09:59.766739512 +0200
12295 + SDL - Simple DirectMedia Layer
12296 + Copyright (C) 1997-2006 Sam Lantinga
12298 + This library is free software; you can redistribute it and/or
12299 + modify it under the terms of the GNU Lesser General Public
12300 + License as published by the Free Software Foundation; either
12301 + version 2.1 of the License, or (at your option) any later version.
12303 + This library is distributed in the hope that it will be useful,
12304 + but WITHOUT ANY WARRANTY; without even the implied warranty of
12305 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12306 + Lesser General Public License for more details.
12308 + You should have received a copy of the GNU Lesser General Public
12309 + License along with this library; if not, write to the Free Software
12310 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
12313 + slouken@libsdl.org
12315 +#if defined (SDL_AROS_SHARED)
12316 +#define __NOLIBBASE__
12317 +#include <proto/SDL.h>
12320 +#include <aros/system.h>
12322 +#include "SDL_config.h"
12324 +/* GLA implementation of SDL OpenGL support */
12326 +#include "SDL_cgxgl_c.h"
12327 +#include "SDL_cgxvideo.h"
12329 +#if defined(PROTO_SDL_H) && SDL_VIDEO_OPENGL
12330 +#include "SDL_intern.h"
12331 +#define GLBase_ptr SDLBase->GLBase_ptr
12332 +#define GLBase *GLBase_ptr
12334 +extern struct Library *GLBase;
12335 +#define GLBase_ptr &GLBase
12338 +/* Create OpenGL context */
12339 +#if !defined(PROTO_SDL_H)
12340 +int CGX_GL_CreateContext(_THIS)
12342 +int CGX_GL_CreateContextI(_THIS, struct SDLBase *SDLBase)
12345 +#if SDL_VIDEO_OPENGL
12347 + struct TagItem attributes [10];
12348 + struct Window *win = (struct Window *)SDL_Window;
12350 + if ( this->gl_config.red_size == 0 &&
12351 + this->gl_config.blue_size == 0 &&
12352 + this->gl_config.green_size == 0 ) {
12353 + SDL_SetError("gl.library does not work with indexed color");
12357 + if( this->gl_config.stereo ) {
12358 + SDL_SetError("gl.library does not support stereo buffer");
12362 + if ( ! this->gl_config.driver_loaded ) {
12363 + if ( CGX_GL_LoadLibrary(this, NULL) < 0 ) {
12368 + /* Required window pointer */
12369 + attributes[i].ti_Tag = GLA_Window; attributes[i++].ti_Data = (IPTR)win;
12371 + /* this->gl_config.double_buffer - skipped, GLA always double-buffer */
12372 + /* this->gl_config.multisamplebuffers - currently not supported */
12373 + /* this->gl_config.multisamplesample - currently not supported */
12375 + /* no depth buffer ? */
12376 + if ( this->gl_config.depth_size == 0 )
12378 + attributes[i].ti_Tag = GLA_NoDepth;
12379 + attributes[i++].ti_Data = GL_TRUE;
12381 + /* no stencil buffer ? */
12382 + if ( this->gl_config.stencil_size == 0 )
12384 + attributes[i].ti_Tag = GLA_NoStencil;
12385 + attributes[i++].ti_Data = GL_TRUE;
12387 + /* no accum buffer ? */
12388 + if ( this->gl_config.accum_red_size == 0 &&
12389 + this->gl_config.accum_blue_size == 0 &&
12390 + this->gl_config.accum_green_size == 0 )
12392 + attributes[i].ti_Tag = GLA_NoAccum;
12393 + attributes[i++].ti_Data = GL_TRUE;
12397 + attributes[i].ti_Tag = TAG_DONE;
12399 + this->gl_data->glctx = glACreateContext(attributes);
12401 + if ( this->gl_data->glctx == NULL ) {
12402 + SDL_SetError("Couldn't create OpenGL context");
12409 + SDL_SetError("OpenGL support not configured");
12413 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_DestroyContext.c SDL-1.2.15/src/video/cgx/SDL_cgxgl_DestroyContext.c
12414 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_DestroyContext.c 1970-01-01 01:00:00.000000000 +0100
12415 +++ SDL-1.2.15/src/video/cgx/SDL_cgxgl_DestroyContext.c 2015-05-09 15:09:59.766739512 +0200
12418 + SDL - Simple DirectMedia Layer
12419 + Copyright (C) 1997-2006 Sam Lantinga
12421 + This library is free software; you can redistribute it and/or
12422 + modify it under the terms of the GNU Lesser General Public
12423 + License as published by the Free Software Foundation; either
12424 + version 2.1 of the License, or (at your option) any later version.
12426 + This library is distributed in the hope that it will be useful,
12427 + but WITHOUT ANY WARRANTY; without even the implied warranty of
12428 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12429 + Lesser General Public License for more details.
12431 + You should have received a copy of the GNU Lesser General Public
12432 + License along with this library; if not, write to the Free Software
12433 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
12436 + slouken@libsdl.org
12438 +#if defined (SDL_AROS_SHARED)
12439 +#define __NOLIBBASE__
12440 +#include <proto/SDL.h>
12443 +#include <aros/system.h>
12445 +#include "SDL_config.h"
12447 +/* GLA implementation of SDL OpenGL support */
12449 +#include "SDL_cgxgl_c.h"
12450 +#include "SDL_cgxvideo.h"
12452 +#if defined(PROTO_SDL_H) && SDL_VIDEO_OPENGL
12453 +#include "SDL_intern.h"
12454 +#define GLBase SDLBase->GLBase
12456 +extern struct Library *GLBase;
12459 +/* Destroy OpenGL context */
12460 +#if !defined(PROTO_SDL_H)
12461 +void CGX_GL_DestroyContext(_THIS)
12463 +void CGX_GL_DestroyContextI(_THIS, struct SDLBase *SDLBase)
12466 +#if SDL_VIDEO_OPENGL
12467 + if (GLBase && (this->gl_data->glctx != NULL)) {
12468 + glAMakeCurrent(NULL);
12469 + glADestroyContext(this->gl_data->glctx);
12470 + this->gl_data->glctx = NULL;
12474 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_GetAttribute.c SDL-1.2.15/src/video/cgx/SDL_cgxgl_GetAttribute.c
12475 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_GetAttribute.c 1970-01-01 01:00:00.000000000 +0100
12476 +++ SDL-1.2.15/src/video/cgx/SDL_cgxgl_GetAttribute.c 2015-05-09 15:09:59.767739510 +0200
12479 + SDL - Simple DirectMedia Layer
12480 + Copyright (C) 1997-2006 Sam Lantinga
12482 + This library is free software; you can redistribute it and/or
12483 + modify it under the terms of the GNU Lesser General Public
12484 + License as published by the Free Software Foundation; either
12485 + version 2.1 of the License, or (at your option) any later version.
12487 + This library is distributed in the hope that it will be useful,
12488 + but WITHOUT ANY WARRANTY; without even the implied warranty of
12489 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12490 + Lesser General Public License for more details.
12492 + You should have received a copy of the GNU Lesser General Public
12493 + License along with this library; if not, write to the Free Software
12494 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
12497 + slouken@libsdl.org
12499 +#if defined (SDL_AROS_SHARED)
12500 +#define __NOLIBBASE__
12501 +#include <proto/SDL.h>
12504 +#include <aros/system.h>
12506 +#include "SDL_config.h"
12508 +/* GLA implementation of SDL OpenGL support */
12510 +#include "SDL_cgxgl_c.h"
12511 +#include "SDL_cgxvideo.h"
12513 +#if defined(PROTO_SDL_H) && SDL_VIDEO_OPENGL
12514 +#include "SDL_intern.h"
12515 +#define GLBase SDLBase->GLBase
12517 +extern struct Library *GLBase;
12520 +#if SDL_VIDEO_OPENGL
12521 +#if !defined(PROTO_SDL_H)
12522 +int CGX_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
12524 +int CGX_GL_GetAttributeI(_THIS, SDL_GLattr attrib, int* value, struct SDLBase *SDLBase)
12527 + GLenum mesa_attrib;
12533 + case SDL_GL_RED_SIZE:
12534 + mesa_attrib = GL_RED_BITS;
12536 + case SDL_GL_GREEN_SIZE:
12537 + mesa_attrib = GL_GREEN_BITS;
12539 + case SDL_GL_BLUE_SIZE:
12540 + mesa_attrib = GL_BLUE_BITS;
12542 + case SDL_GL_ALPHA_SIZE:
12543 + mesa_attrib = GL_ALPHA_BITS;
12545 + case SDL_GL_DOUBLEBUFFER:
12546 + mesa_attrib = GL_DOUBLEBUFFER;
12548 + case SDL_GL_DEPTH_SIZE:
12549 + mesa_attrib = GL_DEPTH_BITS;
12551 + case SDL_GL_STENCIL_SIZE:
12552 + mesa_attrib = GL_STENCIL_BITS;
12554 + case SDL_GL_ACCUM_RED_SIZE:
12555 + mesa_attrib = GL_ACCUM_RED_BITS;
12557 + case SDL_GL_ACCUM_GREEN_SIZE:
12558 + mesa_attrib = GL_ACCUM_GREEN_BITS;
12560 + case SDL_GL_ACCUM_BLUE_SIZE:
12561 + mesa_attrib = GL_ACCUM_BLUE_BITS;
12563 + case SDL_GL_ACCUM_ALPHA_SIZE:
12564 + mesa_attrib = GL_ACCUM_ALPHA_BITS;
12566 + case SDL_GL_STEREO:
12567 + mesa_attrib = GL_STEREO;
12569 + case SDL_GL_MULTISAMPLEBUFFERS:
12571 + case SDL_GL_MULTISAMPLESAMPLES:
12577 + glAGetConfig(this->gl_data->glctx, mesa_attrib, value);
12580 +#endif /* SDL_VIDEO_OPENGL */
12581 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_GetProcAddress.c SDL-1.2.15/src/video/cgx/SDL_cgxgl_GetProcAddress.c
12582 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_GetProcAddress.c 1970-01-01 01:00:00.000000000 +0100
12583 +++ SDL-1.2.15/src/video/cgx/SDL_cgxgl_GetProcAddress.c 2015-05-09 15:09:59.767739510 +0200
12586 + SDL - Simple DirectMedia Layer
12587 + Copyright (C) 1997-2006 Sam Lantinga
12589 + This library is free software; you can redistribute it and/or
12590 + modify it under the terms of the GNU Lesser General Public
12591 + License as published by the Free Software Foundation; either
12592 + version 2.1 of the License, or (at your option) any later version.
12594 + This library is distributed in the hope that it will be useful,
12595 + but WITHOUT ANY WARRANTY; without even the implied warranty of
12596 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12597 + Lesser General Public License for more details.
12599 + You should have received a copy of the GNU Lesser General Public
12600 + License along with this library; if not, write to the Free Software
12601 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
12604 + slouken@libsdl.org
12606 +#if defined (SDL_AROS_SHARED)
12607 +#define __NOLIBBASE__
12608 +#include <proto/SDL.h>
12611 +#include <aros/system.h>
12613 +#include "SDL_config.h"
12615 +/* GLA implementation of SDL OpenGL support */
12617 +#include "SDL_cgxgl_c.h"
12618 +#include "SDL_cgxvideo.h"
12620 +#if defined(PROTO_SDL_H) && SDL_VIDEO_OPENGL
12621 +#include "SDL_intern.h"
12622 +#define GLBase SDLBase->GLBase
12624 +extern struct Library *GLBase;
12627 +#if SDL_VIDEO_OPENGL
12628 +#if !defined(PROTO_SDL_H)
12629 +void *CGX_GL_GetProcAddress(_THIS, const char *proc)
12631 +void *CGX_GL_GetProcAddressI(_THIS, const char *proc, struct SDLBase *SDLBase)
12634 + void *func = NULL;
12638 + func = glAGetProcAddress(proc);
12643 +#endif /* SDL_VIDEO_OPENGL */
12644 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_LoadLibrary.c SDL-1.2.15/src/video/cgx/SDL_cgxgl_LoadLibrary.c
12645 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_LoadLibrary.c 1970-01-01 01:00:00.000000000 +0100
12646 +++ SDL-1.2.15/src/video/cgx/SDL_cgxgl_LoadLibrary.c 2015-05-09 15:09:59.767739510 +0200
12649 + SDL - Simple DirectMedia Layer
12650 + Copyright (C) 1997-2006 Sam Lantinga
12652 + This library is free software; you can redistribute it and/or
12653 + modify it under the terms of the GNU Lesser General Public
12654 + License as published by the Free Software Foundation; either
12655 + version 2.1 of the License, or (at your option) any later version.
12657 + This library is distributed in the hope that it will be useful,
12658 + but WITHOUT ANY WARRANTY; without even the implied warranty of
12659 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12660 + Lesser General Public License for more details.
12662 + You should have received a copy of the GNU Lesser General Public
12663 + License along with this library; if not, write to the Free Software
12664 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
12667 + slouken@libsdl.org
12669 +#if defined (SDL_AROS_SHARED)
12670 +#define __NOLIBBASE__
12671 +#include <proto/SDL.h>
12674 +#include <aros/system.h>
12676 +#include "SDL_config.h"
12678 +#include <aros/debug.h>
12680 +/* GLA implementation of SDL OpenGL support */
12682 +#include "SDL_cgxgl_c.h"
12683 +#include "SDL_cgxvideo.h"
12685 +#if SDL_VIDEO_OPENGL
12686 +#if !defined(PROTO_SDL_H)
12687 +struct Library *GLBase;
12689 +#define GLBase SDLBase->GLBase
12692 +#if !defined(PROTO_SDL_H)
12693 +int CGX_GL_LoadLibrary(_THIS, const char *path)
12695 +int CGX_GL_LoadLibraryI(_THIS, const char *path, struct SDLBase *SDLBase)
12698 + D(bug("CGX_GL_LoadLibrary('%s')\n", path));
12700 + if (GLBase == NULL)
12702 + if ((GLBase = OpenLibrary("gl.library", 20)) != NULL)
12704 + this->gl_config.driver_loaded = 1;
12708 + this->gl_config.driver_loaded = 0;
12709 + SDL_SetError("Could not open gl.library");
12712 + this->gl_data->glctx = NULL;
12717 +#endif /* SDL_VIDEO_OPENGL */
12718 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_MakeCurrent.c SDL-1.2.15/src/video/cgx/SDL_cgxgl_MakeCurrent.c
12719 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_MakeCurrent.c 1970-01-01 01:00:00.000000000 +0100
12720 +++ SDL-1.2.15/src/video/cgx/SDL_cgxgl_MakeCurrent.c 2015-05-09 15:09:59.767739510 +0200
12723 + SDL - Simple DirectMedia Layer
12724 + Copyright (C) 1997-2006 Sam Lantinga
12726 + This library is free software; you can redistribute it and/or
12727 + modify it under the terms of the GNU Lesser General Public
12728 + License as published by the Free Software Foundation; either
12729 + version 2.1 of the License, or (at your option) any later version.
12731 + This library is distributed in the hope that it will be useful,
12732 + but WITHOUT ANY WARRANTY; without even the implied warranty of
12733 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12734 + Lesser General Public License for more details.
12736 + You should have received a copy of the GNU Lesser General Public
12737 + License along with this library; if not, write to the Free Software
12738 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
12741 + slouken@libsdl.org
12743 +#if defined (SDL_AROS_SHARED)
12744 +#define __NOLIBBASE__
12745 +#include <proto/SDL.h>
12748 +#include <aros/system.h>
12750 +#include "SDL_config.h"
12752 +/* GLA implementation of SDL OpenGL support */
12754 +#include "SDL_cgxgl_c.h"
12755 +#include "SDL_cgxvideo.h"
12757 +#if defined(PROTO_SDL_H) && SDL_VIDEO_OPENGL
12758 +#include "SDL_intern.h"
12759 +#define GLBase SDLBase->GLBase
12761 +extern struct Library *GLBase;
12764 +#if SDL_VIDEO_OPENGL
12765 +/* Make the current context active */
12766 +#if !defined(PROTO_SDL_H)
12767 +int CGX_GL_MakeCurrent(_THIS)
12769 +int CGX_GL_MakeCurrentI(_THIS, struct SDLBase *SDLBase)
12772 + if( !GLBase || this->gl_data->glctx == NULL)
12775 + glAMakeCurrent(this->gl_data->glctx);
12778 +#endif /* SDL_VIDEO_OPENGL */
12779 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_Quit.c SDL-1.2.15/src/video/cgx/SDL_cgxgl_Quit.c
12780 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_Quit.c 1970-01-01 01:00:00.000000000 +0100
12781 +++ SDL-1.2.15/src/video/cgx/SDL_cgxgl_Quit.c 2015-05-09 15:09:59.767739510 +0200
12784 + SDL - Simple DirectMedia Layer
12785 + Copyright (C) 1997-2006 Sam Lantinga
12787 + This library is free software; you can redistribute it and/or
12788 + modify it under the terms of the GNU Lesser General Public
12789 + License as published by the Free Software Foundation; either
12790 + version 2.1 of the License, or (at your option) any later version.
12792 + This library is distributed in the hope that it will be useful,
12793 + but WITHOUT ANY WARRANTY; without even the implied warranty of
12794 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12795 + Lesser General Public License for more details.
12797 + You should have received a copy of the GNU Lesser General Public
12798 + License along with this library; if not, write to the Free Software
12799 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
12802 + slouken@libsdl.org
12804 +#if defined (SDL_AROS_SHARED)
12805 +#define __NOLIBBASE__
12806 +#include <proto/SDL.h>
12809 +#include <aros/system.h>
12811 +#include "SDL_config.h"
12813 +/* GLA implementation of SDL OpenGL support */
12815 +#include "SDL_cgxgl_c.h"
12816 +#include "SDL_cgxvideo.h"
12818 +#if defined(PROTO_SDL_H) && SDL_VIDEO_OPENGL
12819 +#include "SDL_intern.h"
12820 +#define GLBase SDLBase->GLBase
12822 +extern struct Library *GLBase;
12826 +#if !defined(PROTO_SDL_H)
12827 +void CGX_GL_Quit(_THIS)
12829 +void CGX_GL_QuitI(_THIS, struct SDLBase *SDLBase)
12832 +#if SDL_VIDEO_OPENGL
12833 + CGX_GL_DestroyContext(this);
12834 + if ( GLBase != NULL ) {
12835 + CloseLibrary(GLBase);
12836 + this->gl_config.driver_loaded = 0;
12841 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_SwapBuffers.c SDL-1.2.15/src/video/cgx/SDL_cgxgl_SwapBuffers.c
12842 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_SwapBuffers.c 1970-01-01 01:00:00.000000000 +0100
12843 +++ SDL-1.2.15/src/video/cgx/SDL_cgxgl_SwapBuffers.c 2015-05-09 15:09:59.767739510 +0200
12846 + SDL - Simple DirectMedia Layer
12847 + Copyright (C) 1997-2006 Sam Lantinga
12849 + This library is free software; you can redistribute it and/or
12850 + modify it under the terms of the GNU Lesser General Public
12851 + License as published by the Free Software Foundation; either
12852 + version 2.1 of the License, or (at your option) any later version.
12854 + This library is distributed in the hope that it will be useful,
12855 + but WITHOUT ANY WARRANTY; without even the implied warranty of
12856 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12857 + Lesser General Public License for more details.
12859 + You should have received a copy of the GNU Lesser General Public
12860 + License along with this library; if not, write to the Free Software
12861 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
12864 + slouken@libsdl.org
12866 +#if defined (SDL_AROS_SHARED)
12867 +#define __NOLIBBASE__
12868 +#include <proto/SDL.h>
12871 +#include <aros/system.h>
12873 +#include "SDL_config.h"
12875 +/* GLA implementation of SDL OpenGL support */
12877 +#include "SDL_cgxgl_c.h"
12878 +#include "SDL_cgxvideo.h"
12880 +#if defined(PROTO_SDL_H) && SDL_VIDEO_OPENGL
12881 +#include "SDL_intern.h"
12882 +#define GLBase SDLBase->GLBase
12884 +extern struct Library *GLBase;
12887 +#if SDL_VIDEO_OPENGL
12888 +#if !defined(PROTO_SDL_H)
12889 +void CGX_GL_SwapBuffers(_THIS)
12891 +void CGX_GL_SwapBuffersI(_THIS, struct SDLBase *SDLBase)
12897 + glASwapBuffers(this->gl_data->glctx);
12899 +#endif /* SDL_VIDEO_OPENGL */
12900 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_UpdateContext.c SDL-1.2.15/src/video/cgx/SDL_cgxgl_UpdateContext.c
12901 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxgl_UpdateContext.c 1970-01-01 01:00:00.000000000 +0100
12902 +++ SDL-1.2.15/src/video/cgx/SDL_cgxgl_UpdateContext.c 2015-05-09 15:09:59.767739510 +0200
12905 + SDL - Simple DirectMedia Layer
12906 + Copyright (C) 1997-2006 Sam Lantinga
12908 + This library is free software; you can redistribute it and/or
12909 + modify it under the terms of the GNU Lesser General Public
12910 + License as published by the Free Software Foundation; either
12911 + version 2.1 of the License, or (at your option) any later version.
12913 + This library is distributed in the hope that it will be useful,
12914 + but WITHOUT ANY WARRANTY; without even the implied warranty of
12915 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12916 + Lesser General Public License for more details.
12918 + You should have received a copy of the GNU Lesser General Public
12919 + License along with this library; if not, write to the Free Software
12920 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
12923 + slouken@libsdl.org
12925 +#if defined (SDL_AROS_SHARED)
12926 +#define __NOLIBBASE__
12927 +#include <proto/SDL.h>
12930 +#include <aros/system.h>
12932 +#include "SDL_config.h"
12934 +/* GLA implementation of SDL OpenGL support */
12936 +#include "SDL_cgxgl_c.h"
12937 +#include "SDL_cgxvideo.h"
12939 +#if defined(PROTO_SDL_H) && SDL_VIDEO_OPENGL
12940 +#include "SDL_intern.h"
12941 +#define GLBase SDLBase->GLBase
12943 +extern struct Library *GLBase;
12946 +/* Attach context to another window */
12947 +#if !defined(PROTO_SDL_H)
12948 +int CGX_GL_UpdateContext(_THIS)
12950 +int CGX_GL_UpdateContextI(_THIS, struct SDLBase *SDLBase)
12953 +#if SDL_VIDEO_OPENGL
12954 + struct TagItem tags[2];
12955 + struct Window *win = (struct Window*)SDL_Window;
12956 + if( !GLBase || this->gl_data->glctx == NULL ) {
12957 + return -1; //should never happen
12959 + tags[0].ti_Tag = GLA_Window;
12960 + tags[0].ti_Data = (IPTR)win;
12961 + tags[1].ti_Tag = TAG_DONE;
12963 + glASetRast(this->gl_data->glctx, tags);
12967 + SDL_SetError("OpenGL support not configured");
12971 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgximage.c SDL-1.2.15/src/video/cgx/SDL_cgximage.c
12972 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgximage.c 1970-01-01 01:00:00.000000000 +0100
12973 +++ SDL-1.2.15/src/video/cgx/SDL_cgximage.c 2015-05-09 15:09:59.767739510 +0200
12976 + SDL - Simple DirectMedia Layer
12977 + Copyright (C) 1997-2006 Sam Lantinga
12979 + This library is free software; you can redistribute it and/or
12980 + modify it under the terms of the GNU Lesser General Public
12981 + License as published by the Free Software Foundation; either
12982 + version 2.1 of the License, or (at your option) any later version.
12984 + This library is distributed in the hope that it will be useful,
12985 + but WITHOUT ANY WARRANTY; without even the implied warranty of
12986 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12987 + Lesser General Public License for more details.
12989 + You should have received a copy of the GNU Lesser General Public
12990 + License along with this library; if not, write to the Free Software
12991 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
12994 + slouken@libsdl.org
12996 +#if defined (SDL_AROS_SHARED)
12997 +#define __NOLIBBASE__
12998 +#include <proto/SDL.h>
13001 +#include "SDL_config.h"
13003 +#include "SDL_endian.h"
13004 +#include "SDL_cgximage_c.h"
13005 +#include "SDL_cgxaccel_c.h"
13006 +#include "../../main/aros/mydebug.h"
13008 +#if !defined(PROTO_SDL_H)
13009 +/* Various screen update functions available */
13010 +static void CGX_SWScreenUpdate(_THIS, int numrects, SDL_Rect *rects);
13011 +static void CGX_HWScreenUpdate(_THIS, int numrects, SDL_Rect *rects);
13013 +#include "SDL_intern.h"
13015 +static void CGX_SWScreenUpdate(_THIS, int numrects, SDL_Rect *rects, struct SDLBase *SDLBase);
13016 +static void CGX_HWScreenUpdate(_THIS, int numrects, SDL_Rect *rects, struct SDLBase *SDLBase);
13019 +ULONG CGX_MaskToRECTFMT(ULONG A, ULONG R, ULONG G, ULONG B)
13021 + ULONG GlobMask = AROS_BE2LONG((A & 0x11111111) | (R & 0x22222222) | (G & 0x44444444) | (B & 0x88888888));
13022 + ULONG rectfmt = 0;
13024 + switch (GlobMask)
13026 + case 0x22448811: rectfmt = RECTFMT_RGBA; break;
13027 + case 0x11224488: rectfmt = RECTFMT_ARGB; break;
13028 + case 0x00000000: rectfmt = RECTFMT_LUT8; break;
13029 + case 0x00002048: rectfmt = RECTFMT_RGB15; break;
13030 + case 0x00000842: rectfmt = RECTFMT_BGR15; break;
13031 + case 0x00004820: rectfmt = RECTFMT_RGB15PC; break;
13032 + case 0x00004208: rectfmt = RECTFMT_BGR15PC; break;
13033 + case 0x00002448: rectfmt = RECTFMT_RGB16; break;
13034 + case 0x00008C42: rectfmt = RECTFMT_BGR16; break;
13035 + case 0x00004824: rectfmt = RECTFMT_RGB16PC; break;
13036 + case 0x0000428C: rectfmt = RECTFMT_BGR16PC; break;
13037 + case 0x88442211: rectfmt = RECTFMT_BGRA32; break;
13038 + case 0x11884422: rectfmt = RECTFMT_ABGR32; break;
13039 + case 0x00224488: rectfmt = RECTFMT_0RGB32; break;
13040 + case 0x88442200: rectfmt = RECTFMT_BGR032; break;
13041 + case 0x22448800: rectfmt = RECTFMT_RGB032; break;
13042 + case 0x00884422: rectfmt = RECTFMT_0BGR32; break;
13043 + default: rectfmt = RECTFMT_RAW; break;
13044 +// case 0x00224488: rectfmt = RECTFMT_RGB; break;
13045 +// case 0x00884422: rectfmt = RECTFMT_BGR24; break;
13051 +#if !defined(PROTO_SDL_H)
13052 +int CGX_SetupImage(_THIS, SDL_Surface *screen)
13054 +int CGX_SetupImageI(_THIS, SDL_Surface *screen, struct SDLBase *SDLBase)
13057 + SDL_Image = NULL;
13059 + D(bug("CGX_SetupImage\n"));
13060 + D(bug("BitsPerPixel: %d\n",screen->format->BitsPerPixel));
13061 + D(bug("BytesPerPixel: %d\n",screen->format->BytesPerPixel));
13062 + D(bug("Rmask: 0x%08X\n",screen->format->Rmask));
13063 + D(bug("Gmask: 0x%08X\n",screen->format->Gmask));
13064 + D(bug("Bmask: 0x%08X\n",screen->format->Bmask));
13065 + D(bug("Amask: 0x%08X\n",screen->format->Amask));
13067 + if(screen->flags & SDL_HWSURFACE)
13069 +#ifndef NO_AMIGAHWSURF
13074 + if (this->hidden->dbuffer)
13075 + lock = LockBitMapTags(
13076 + SDL_RastPort->BitMap,
13077 + LBMI_BASEADDRESS, (IPTR)&pixels,
13078 + LBMI_BYTESPERROW, (IPTR)&pitch,
13081 + lock = LockBitMapTags(
13082 + this->hidden->BlitBitMap,
13083 + LBMI_BASEADDRESS, (IPTR)&pixels,
13084 + LBMI_BYTESPERROW, (IPTR)&pitch,
13089 + UnLockBitMap(lock);
13090 + if (!screen->hwdata)
13091 + screen->hwdata = SDL_malloc(sizeof(struct private_hwdata));
13093 + if (screen->hwdata)
13095 + screen->hwdata->lock = NULL;
13096 + screen->hwdata->allocated = 0;
13097 + screen->hwdata->mask = NULL;
13098 + screen->hwdata->bmap = this->hidden->dbuffer ? SDL_RastPort->BitMap : this->hidden->BlitBitMap;
13099 + screen->hwdata->update = 0;
13100 + screen->hwdata->videodata = this;
13101 + screen->pixels = pixels;
13102 + screen->pitch = GetCyberMapAttr(screen->hwdata->bmap, CYBRMATTR_XMOD);;
13103 + screen->hwdata->pixfmt = GetCyberMapAttr(screen->hwdata->bmap, CYBRMATTR_PIXFMT);
13105 + this->UpdateRects = CGX_HWScreenUpdate;
13107 + D(bug("HW video image configured (%lx, pitch %ld, pixfmt 0x%08X).\n", screen->pixels, screen->pitch, screen->hwdata->pixfmt));
13108 + D(bug("Bitmap : %s\n",this->hidden->dbuffer ?"RastPort->BitMap":"BlitBitMap"));
13112 + D(bug("Creating system accel struct FAILED.\n"));
13115 + D(bug("HW surface not available, falling back to SW surface.\n"));
13117 + screen->flags &= ~SDL_HWSURFACE;
13120 + screen->hwdata=NULL;
13122 + D(bug("h = %d, pitch = %d\n", screen->h, screen->pitch));
13124 + screen->pixels = SDL_malloc(screen->h*screen->pitch);
13126 + if ( screen->pixels == NULL )
13128 + SDL_OutOfMemory();
13132 + SDL_Image = screen->pixels;
13134 + if ( SDL_Image == NULL )
13136 + SDL_SetError("Couldn't create XImage");
13140 + this->UpdateRects = CGX_SWScreenUpdate;
13145 +#if !defined(PROTO_SDL_H)
13146 +void CGX_DestroyImage(_THIS, SDL_Surface *screen)
13148 +void CGX_DestroyImageI(_THIS, SDL_Surface *screen, struct SDLBase *SDLBase)
13153 + SDL_free(SDL_Image);
13154 + SDL_Image = NULL;
13158 + screen->pixels = NULL;
13160 + if(screen->hwdata)
13162 + SDL_free(screen->hwdata);
13163 + screen->hwdata=NULL;
13168 +#if !defined(PROTO_SDL_H)
13169 +int CGX_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
13171 +int CGX_ResizeImageI(_THIS, SDL_Surface *screen, Uint32 flags, struct SDLBase *SDLBase)
13176 + D(bug("CGX_ResizeImage(%lx,%lx)\n",this,screen));
13178 + CGX_DestroyImage(this, screen);
13180 + if ( flags & SDL_OPENGL )
13181 + retval = 0; /* No image when using GL */
13183 + retval = CGX_SetupImage(this, screen);
13188 +#if !defined(PROTO_SDL_H)
13189 +static void CGX_HWScreenUpdate(_THIS, int numrects, SDL_Rect *rects)
13191 +static void CGX_HWScreenUpdate(_THIS, int numrects, SDL_Rect *rects, struct SDLBase *SDLBase)
13194 + D(bug("CGX_HWScreenUpdate\n"));
13195 + CGX_FlipHWSurface(this, this->screen);
13198 +#if !defined(PROTO_SDL_H)
13199 +static void CGX_SWScreenUpdate(_THIS, int numrects, SDL_Rect *rects)
13201 +static void CGX_SWScreenUpdate(_THIS, int numrects, SDL_Rect *rects, struct SDLBase *SDLBase)
13204 + int i,format, dx = 0, dy = 0;
13206 + D(bug("CGX_SWScreenUpdate:\t"));
13208 + format=CGX_MaskToRECTFMT( this->screen->format->Amask,
13209 + this->screen->format->Rmask,
13210 + this->screen->format->Gmask,
13211 + this->screen->format->Bmask);
13212 + D(bug("format = 0x%08X\n", format));
13214 + if (currently_fullscreen)
13216 + // center display on screen
13217 + dx = (SDL_Display->Width - this->screen->w)/2;
13218 + dy = (SDL_Display->Height - this->screen->h)/2;
13221 + if (format==RECTFMT_LUT8)
13223 + for ( i=0; i<numrects; ++i ) {
13224 + if ( ! rects[i].w ) { /* Clipped? */
13227 + WriteLUTPixelArray( this->screen->pixels,
13230 + this->screen->pitch,
13233 + SDL_Window->BorderLeft+rects[i].x + dx,
13234 + SDL_Window->BorderTop+rects[i].y + dy,
13242 + for ( i=0; i<numrects; ++i ) {
13243 + if ( ! rects[i].w ) { /* Clipped? */
13246 + WritePixelArray( this->screen->pixels,
13249 + this->screen->pitch,
13251 + SDL_Window->BorderLeft+rects[i].x + dx,
13252 + SDL_Window->BorderTop+rects[i].y + dy,
13260 +#if !defined(PROTO_SDL_H)
13261 +void CGX_RefreshDisplay(_THIS)
13263 +void CGX_RefreshDisplayI(_THIS, struct SDLBase *SDLBase)
13266 + SDL_Rect screenrect;
13268 + /* Don't refresh a display that doesn't have an image (like GL) */
13269 + if ( ! SDL_Image ) return;
13271 + screenrect.x = 0;
13272 + screenrect.y = 0;
13273 + screenrect.w = this->screen->w;
13274 + screenrect.h = this->screen->h;
13275 +#if !defined(PROTO_SDL_H)
13276 + this->UpdateRects(this, 1, &screenrect);
13278 + this->UpdateRects(this, 1, &screenrect, SDLBase);
13281 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgximage_c.h SDL-1.2.15/src/video/cgx/SDL_cgximage_c.h
13282 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgximage_c.h 1970-01-01 01:00:00.000000000 +0100
13283 +++ SDL-1.2.15/src/video/cgx/SDL_cgximage_c.h 2015-05-09 15:09:59.767739510 +0200
13286 + SDL - Simple DirectMedia Layer
13287 + Copyright (C) 1997-2006 Sam Lantinga
13289 + This library is free software; you can redistribute it and/or
13290 + modify it under the terms of the GNU Lesser General Public
13291 + License as published by the Free Software Foundation; either
13292 + version 2.1 of the License, or (at your option) any later version.
13294 + This library is distributed in the hope that it will be useful,
13295 + but WITHOUT ANY WARRANTY; without even the implied warranty of
13296 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13297 + Lesser General Public License for more details.
13299 + You should have received a copy of the GNU Lesser General Public
13300 + License along with this library; if not, write to the Free Software
13301 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
13304 + slouken@libsdl.org
13306 +#include "SDL_config.h"
13308 +#include "SDL_cgxvideo.h"
13310 +extern ULONG CGX_MaskToRECTFMT(ULONG A, ULONG R, ULONG G, ULONG B);
13312 +#if !defined(PROTO_SDL_H)
13313 +extern int CGX_SetupImage(_THIS, SDL_Surface *screen);
13314 +extern int CGX_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags);
13315 +extern void CGX_DestroyImage(_THIS, SDL_Surface *screen);
13316 +extern void CGX_RefreshDisplay(_THIS);
13318 +#include "SDL_intern.h"
13320 +extern int CGX_SetupImageI(_THIS, SDL_Surface *screen, struct SDLBase *SDLBase);
13321 +extern int CGX_ResizeImageI(_THIS, SDL_Surface *screen, Uint32 flags, struct SDLBase *SDLBase);
13322 +extern void CGX_DestroyImageI(_THIS, SDL_Surface *screen, struct SDLBase *SDLBase);
13323 +extern void CGX_RefreshDisplayI(_THIS, struct SDLBase *SDLBase);
13325 +#define CGX_SetupImage(this, screen) CGX_SetupImageI(this, screen, SDLBase)
13326 +#define CGX_ResizeImage(this, screen, flags) CGX_ResizeImageI(this, screen, flags, SDLBase)
13327 +#define CGX_DestroyImage(this, screen) CGX_DestroyImageI(this, screen, SDLBase)
13328 +#define CGX_RefreshDisplay(this) CGX_RefreshDisplayI(this, SDLBase)
13330 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxmodes.c SDL-1.2.15/src/video/cgx/SDL_cgxmodes.c
13331 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxmodes.c 1970-01-01 01:00:00.000000000 +0100
13332 +++ SDL-1.2.15/src/video/cgx/SDL_cgxmodes.c 2015-05-09 15:09:59.768739508 +0200
13335 + SDL - Simple DirectMedia Layer
13336 + Copyright (C) 1997-2006 Sam Lantinga
13338 + This library is free software; you can redistribute it and/or
13339 + modify it under the terms of the GNU Lesser General Public
13340 + License as published by the Free Software Foundation; either
13341 + version 2.1 of the License, or (at your option) any later version.
13343 + This library is distributed in the hope that it will be useful,
13344 + but WITHOUT ANY WARRANTY; without even the implied warranty of
13345 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13346 + Lesser General Public License for more details.
13348 + You should have received a copy of the GNU Lesser General Public
13349 + License along with this library; if not, write to the Free Software
13350 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
13353 + slouken@libsdl.org
13355 +#if defined (SDL_AROS_SHARED)
13356 +#define __NOLIBBASE__
13357 +#include <proto/SDL.h>
13360 +#include "SDL_config.h"
13363 +#include <aros/debug.h>
13365 +#include "SDL_timer.h"
13366 +#include "SDL_events.h"
13367 +#include "../../events/SDL_events_c.h"
13368 +#include "SDL_cgxvideo.h"
13369 +#include "SDL_cgxwm_c.h"
13370 +#include "SDL_cgxmouse_c.h"
13371 +#include "SDL_cgxmodes_c.h"
13373 +#if defined(PROTO_SDL_H)
13374 +#include "SDL_intern.h"
13377 +static void add_visual(_THIS, int depth, int class)
13381 + tID=BestCModeIDTags(CYBRBIDTG_Depth,depth,
13382 + CYBRBIDTG_NominalWidth,640,
13383 + CYBRBIDTG_NominalHeight,480,
13386 + if(tID!=INVALID_ID)
13388 + int n = this->hidden->nvisuals;
13390 + this->hidden->visuals[n].depth = depth;
13391 + this->hidden->visuals[n].visual = tID;
13392 + this->hidden->visuals[n].bpp = GetCyberIDAttr(CYBRIDATTR_BPPIX,tID) * 8;
13393 + this->hidden->nvisuals++;
13397 +#define TrueColor 1
13398 +#define PseudoColor 2
13400 +#if !defined(PROTO_SDL_H)
13401 +int CGX_GetVideoModes(_THIS)
13403 +int CGX_GetVideoModesI(_THIS, struct SDLBase *SDLBase)
13410 + D(bug("CGX_GetVideoModes()\n"));
13412 + SDL_modelist=NULL;
13414 + nextid=NextDisplayInfo(INVALID_ID);
13416 + while(nextid!=INVALID_ID)
13418 + if(IsCyberModeID(nextid))
13420 + DisplayInfoHandle h;
13422 + if((h = FindDisplayInfo(nextid)) != 0)
13424 + struct DimensionInfo info;
13426 + /* ULONG GetDisplayInfoData( CONST DisplayInfoHandle handle, APTR buf, ULONG size, ULONG tagID, ULONG displayID ); */
13427 + if(GetDisplayInfoData(h,(char *)&info,(ULONG)sizeof(struct DimensionInfo),(ULONG)DTAG_DIMS,(IPTR)NULL))
13431 + for(i=0;i<nmodes;i++)
13433 + if( SDL_modelist[i]->w == (info.Nominal.MaxX+1) &&
13434 + SDL_modelist[i]->h == (info.Nominal.MaxY+1) )
13442 + SDL_modelist = (SDL_Rect **)SDL_realloc(SDL_modelist,(nmodes+1)*sizeof(SDL_Rect *));
13443 + SDL_modelist[nmodes]=NULL;
13445 + if ( SDL_modelist )
13447 + SDL_modelist[nmodes-1] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));
13449 + if ( SDL_modelist[nmodes-1] == NULL )
13452 + SDL_modelist[nmodes-1]->x = 0;
13453 + SDL_modelist[nmodes-1]->y = 0;
13454 + SDL_modelist[nmodes-1]->w = info.Nominal.MaxX+1;
13455 + SDL_modelist[nmodes-1]->h = info.Nominal.MaxY+1;
13461 + nextid=NextDisplayInfo(nextid);
13465 + this->hidden->nvisuals = 0;
13466 + /* Search for the visuals in deepest-first order, so that the first
13467 + will be the richest one */
13468 + add_visual(this, 32, TrueColor);
13469 + add_visual(this, 24, TrueColor);
13470 + add_visual(this, 16, TrueColor);
13471 + add_visual(this, 15, TrueColor);
13472 + add_visual(this, 8, PseudoColor);
13474 + if(this->hidden->nvisuals == 0)
13476 + SDL_SetError("Found no sufficiently capable CGX visuals");
13480 + if ( SDL_modelist == NULL )
13482 + SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *));
13484 + if ( SDL_modelist )
13486 + SDL_modelist[i] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));
13487 + if ( SDL_modelist[i] )
13489 + SDL_modelist[i]->x = 0;
13490 + SDL_modelist[i]->y = 0;
13491 + SDL_modelist[i]->w = SDL_Display->Width;
13492 + SDL_modelist[i]->h = SDL_Display->Height;
13495 + SDL_modelist[i] = NULL;
13500 + if ( SDL_modelist )
13502 + bug("CGX video mode list: (%ld)\n",nmodes);
13503 + for ( i=0; SDL_modelist[i]; ++i )
13505 + bug( "\t%ld x %ld\n",
13506 + SDL_modelist[i]->w, SDL_modelist[i]->h);
13510 + bug("CGX visuals list: (%ld)\n",this->hidden->nvisuals);
13512 + for(i=0;i<this->hidden->nvisuals;i++)
13513 + bug("\t%lx - depth: %ld bpp: %ld\n",this->hidden->visuals[i].visual,this->hidden->visuals[i].depth,this->hidden->visuals[i].bpp);
13519 +#if !defined(PROTO_SDL_H)
13520 +static int CGX_SupportedVisual(_THIS, SDL_PixelFormat *format)
13522 +#define CGX_SupportedVisual(this, format) CGX_SupportedVisualI(this, format, SDLBase)
13523 +static int CGX_SupportedVisualI(_THIS, SDL_PixelFormat *format, struct SDLBase *SDLBase)
13527 + for(i = 0; i < this->hidden->nvisuals; i++)
13529 + if(this->hidden->visuals[i].depth == format->BitsPerPixel || this->hidden->visuals[i].bpp == format->BitsPerPixel) // Era bpp
13535 +#if !defined(PROTO_SDL_H)
13536 +SDL_Rect **CGX_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
13538 +SDL_Rect **CGX_ListModesI(_THIS, SDL_PixelFormat *format, Uint32 flags, struct SDLBase *SDLBase)
13541 + if ( CGX_SupportedVisual(this, format) )
13543 + if ( flags & SDL_FULLSCREEN )
13544 + return(SDL_modelist);
13546 + return((SDL_Rect **)-1);
13549 + return((SDL_Rect **)0);
13552 +#if !defined(PROTO_SDL_H)
13553 +void CGX_FreeVideoModes(_THIS)
13555 +void CGX_FreeVideoModesI(_THIS, struct SDLBase *SDLBase)
13560 + if ( SDL_modelist )
13562 + for ( i=0; SDL_modelist[i]; ++i )
13564 + SDL_free(SDL_modelist[i]);
13566 + SDL_free(SDL_modelist);
13567 + SDL_modelist = NULL;
13570 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxmodes_c.h SDL-1.2.15/src/video/cgx/SDL_cgxmodes_c.h
13571 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxmodes_c.h 1970-01-01 01:00:00.000000000 +0100
13572 +++ SDL-1.2.15/src/video/cgx/SDL_cgxmodes_c.h 2015-05-09 15:09:59.768739508 +0200
13575 + SDL - Simple DirectMedia Layer
13576 + Copyright (C) 1997-2006 Sam Lantinga
13578 + This library is free software; you can redistribute it and/or
13579 + modify it under the terms of the GNU Lesser General Public
13580 + License as published by the Free Software Foundation; either
13581 + version 2.1 of the License, or (at your option) any later version.
13583 + This library is distributed in the hope that it will be useful,
13584 + but WITHOUT ANY WARRANTY; without even the implied warranty of
13585 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13586 + Lesser General Public License for more details.
13588 + You should have received a copy of the GNU Lesser General Public
13589 + License along with this library; if not, write to the Free Software
13590 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
13593 + slouken@libsdl.org
13595 +#include "SDL_config.h"
13597 +/* Utilities for getting and setting the X display mode */
13599 +#include "SDL_cgxvideo.h"
13601 +#if !defined(PROTO_SDL_H)
13602 +extern int CGX_GetVideoModes(_THIS);
13603 +extern SDL_Rect **CGX_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
13604 +extern void CGX_FreeVideoModes(_THIS);
13606 +extern void CGX_WaitMapped(_THIS, Window win);
13607 +extern void CGX_WaitUnmapped(_THIS, Window win);
13608 +extern void CGX_QueueEnterFullScreen(_THIS);
13611 +#include "SDL_intern.h"
13613 +extern int CGX_GetVideoModesI(_THIS, struct SDLBase *SDLBase);
13614 +extern SDL_Rect **CGX_ListModesI(_THIS, SDL_PixelFormat *format, Uint32 flags, struct SDLBase *SDLBase);
13615 +extern void CGX_FreeVideoModesI(_THIS, struct SDLBase *SDLBase);
13617 +#define CGX_GetVideoModes(this) CGX_GetVideoModesI(this, SDLBase)
13618 +#define CGX_ListModes(this, format, flags) CGX_ListModesI(this, format, flags, SDLBase)
13619 +#define CGX_FreeVideoModes(this) CGX_FreeVideoModesI(this, SDLBase)
13621 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxmouse.c SDL-1.2.15/src/video/cgx/SDL_cgxmouse.c
13622 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxmouse.c 1970-01-01 01:00:00.000000000 +0100
13623 +++ SDL-1.2.15/src/video/cgx/SDL_cgxmouse.c 2015-05-09 15:09:59.768739508 +0200
13626 + SDL - Simple DirectMedia Layer
13627 + Copyright (C) 1997-2006 Sam Lantinga
13629 + This library is free software; you can redistribute it and/or
13630 + modify it under the terms of the GNU Lesser General Public
13631 + License as published by the Free Software Foundation; either
13632 + version 2.1 of the License, or (at your option) any later version.
13634 + This library is distributed in the hope that it will be useful,
13635 + but WITHOUT ANY WARRANTY; without even the implied warranty of
13636 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13637 + Lesser General Public License for more details.
13639 + You should have received a copy of the GNU Lesser General Public
13640 + License along with this library; if not, write to the Free Software
13641 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
13644 + slouken@libsdl.org
13646 +#if defined (SDL_AROS_SHARED)
13647 +#define __NOLIBBASE__
13648 +#include <proto/SDL.h>
13651 +#include "SDL_config.h"
13653 +#include <devices/input.h>
13654 +#include <intuition/pointerclass.h>
13656 +#include "SDL_mouse.h"
13657 +#include "../../events/SDL_events_c.h"
13658 +#include "../SDL_pixels_c.h"
13659 +#include "../SDL_cursor_c.h"
13660 +#include "SDL_cgxmouse_c.h"
13664 + struct BitMap *CursorBM;
13665 + Object *PointerObj;
13668 +#if !defined(PROTO_SDL_H)
13669 +void CGX_FreeWMCursor(_THIS, WMcursor *cursor)
13671 +void CGX_FreeWMCursor(_THIS, WMcursor *cursor, struct SDLBase *SDLBase)
13674 + D(bug("[SDL] CGX_FreeWMCursor()\n"));
13679 + ClearPointer(SDL_Window);
13681 + if (cursor->CursorBM)
13682 + FreeBitMap(cursor->CursorBM);
13684 + if(cursor->PointerObj)
13685 + DisposeObject(cursor->PointerObj);
13691 +#if !defined(PROTO_SDL_H)
13692 +WMcursor *CGX_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
13694 +WMcursor *CGX_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y, struct SDLBase *SDLBase)
13697 + struct WMcursor *cursor = NULL;
13698 + struct RastPort *CursorRP = NULL;
13699 + ULONG *pixarray = NULL;
13701 + char currentbit = 7, currentdata, currentmask;
13703 + cursor = malloc(sizeof(*cursor));
13704 + CursorRP = CreateRastPort();
13705 + pixarray = AllocVec(w*h*4,MEMF_ANY);
13707 + if (cursor && CursorRP && pixarray)
13709 + // Allocate Cursor BitMap
13710 + // TODO: check if it's OK to use NULL for friend bitmap in case SDL_Window is NULL
13711 + cursor->CursorBM = AllocBitMap(w,h,32,BMF_MINPLANES | BMF_SPECIALFMT | (PIXFMT_RGBA32 << 24),
13712 + SDL_Window ? SDL_Window->RPort->BitMap : NULL);
13714 + if (cursor->CursorBM)
13716 + // Create pixarray from data and mask
13717 + for (pixel_cnt = 0; pixel_cnt < w*h; pixel_cnt++)
13719 + currentdata = ((*data >> currentbit) & 0x01);
13720 + currentmask = ((*mask >> currentbit) & 0x01);
13721 + if (currentbit == 0)
13732 + switch(currentdata * 2 + currentmask)
13734 + case 0: //(0,0) => Transparent
13735 + pixarray[pixel_cnt] = AROS_BE2LONG(0x00000000);
13737 + case 1: //(0,1) => White
13738 + pixarray[pixel_cnt] = AROS_BE2LONG(0xFFFFFFFF);
13740 + case 2: //(1,0) => Inverted color if possible, black if not (Semi transparent here AROS)
13741 + pixarray[pixel_cnt] = AROS_BE2LONG(0x0000007F);
13743 + case 3: //(1,1) => Black
13744 + pixarray[pixel_cnt] = AROS_BE2LONG(0x000000FF);
13749 + // Copy pixel array into bitmap
13750 + CursorRP->BitMap = cursor->CursorBM;
13751 + WritePixelArray( pixarray,
13755 + RECTFMT_RGBA32 );
13757 + // Create Pointer Object
13758 + cursor->PointerObj = (Object *)NewObject(NULL,
13759 + (STRPTR)"pointerclass",
13760 + POINTERA_BitMap, (IPTR)cursor->CursorBM,
13761 + POINTERA_XOffset, (IPTR)(-hot_x),
13762 + POINTERA_YOffset, (IPTR)(-hot_y),
13765 + if (!cursor->PointerObj)
13767 + FreeBitMap(cursor->CursorBM);
13779 + if (pixarray) FreeVec(pixarray);
13780 + if (CursorRP) FreeRastPort(CursorRP);
13782 + D(bug("[SDL] CGX_CreateWMCursor() (size %ld/%ld) -> 0x%08.8lx\n", w, h, (IPTR)cursor));
13787 +#if !defined(PROTO_SDL_H)
13788 +int CGX_ShowWMCursor(_THIS, WMcursor *cursor)
13790 +int CGX_ShowWMCursorI(_THIS, WMcursor *cursor, struct SDLBase *SDLBase)
13793 + /* Don't do anything if the display is gone */
13794 + if ( SDL_Display == NULL)
13796 + this->hidden->CursorVisible = 0;
13800 + /* Set the cursor, or blank if cursor is NULL */
13801 + if ( SDL_Window )
13803 + SDL_Lock_EventThread();
13804 + if ( cursor == NULL )
13806 + if ( SDL_BlankCursor != NULL )
13808 + // Hide cursor HERE
13809 + SetPointer(SDL_Window,(UWORD *)SDL_BlankCursor,1,1,0,0);
13811 + this->hidden->CursorVisible = 0;
13816 + SetWindowPointer( SDL_Window,
13817 + WA_Pointer, (APTR)cursor->PointerObj,
13819 + this->hidden->CursorVisible = 1;
13821 + SDL_Unlock_EventThread();
13826 +#if !defined(PROTO_SDL_H)
13827 +void CGX_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
13829 +void CGX_WarpWMCursorI(_THIS, Uint16 x, Uint16 y, struct SDLBase *SDLBase)
13832 + struct IOStdReq *req;
13833 + struct MsgPort *port;
13835 + D(bug("[SDL] CGX_WarpWMCursor(%ld, %ld)\n", x, y));
13837 + SDL_Lock_EventThread();
13839 + port = CreateMsgPort();
13840 + req = (struct IOStdReq *)CreateIORequest(port, sizeof(*req));
13844 + if (OpenDevice("input.device", 0, (struct IORequest *)req, 0) == 0)
13846 + struct InputEvent *ie;
13847 + struct IEPointerPixel *newpos;
13849 + if ((ie = malloc(sizeof(*ie) + sizeof(*newpos))))
13851 + newpos = (struct IEPointerPixel *)(ie + 1);
13853 + newpos->iepp_Screen = SDL_Display;
13854 + newpos->iepp_Position.X = x + SDL_Window->BorderLeft + SDL_Window->LeftEdge;
13855 + newpos->iepp_Position.Y = y + SDL_Window->BorderTop + SDL_Window->TopEdge;
13857 + ie->ie_EventAddress = newpos;
13858 + ie->ie_NextEvent = NULL;
13859 + ie->ie_Class = IECLASS_NEWPOINTERPOS;
13860 + ie->ie_SubClass = IESUBCLASS_PIXEL;
13861 + ie->ie_Code = IECODE_NOBUTTON;
13862 + ie->ie_Qualifier = 0;
13864 + req->io_Data = ie;
13865 + req->io_Length = sizeof(*ie);
13866 + req->io_Command = IND_WRITEEVENT;
13868 + DoIO((struct IORequest *)req);
13871 + CloseDevice((struct IORequest *)req);
13874 + DeleteIORequest((struct IORequest *)req);
13875 + DeleteMsgPort(port);
13877 + SDL_Unlock_EventThread();
13882 +#if !defined(PROTO_SDL_H)
13883 +void CGX_CheckMouseMode(_THIS)
13885 +void CGX_CheckMouseMode(_THIS, struct SDLBase *SDLBase)
13888 + /* Check to see if we need to enter or leave mouse relative mode */
13889 + /* under AROS the mouse mode is always absolute => nothing to be done*/
13891 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxmouse_c.h SDL-1.2.15/src/video/cgx/SDL_cgxmouse_c.h
13892 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxmouse_c.h 1970-01-01 01:00:00.000000000 +0100
13893 +++ SDL-1.2.15/src/video/cgx/SDL_cgxmouse_c.h 2015-05-09 15:09:59.768739508 +0200
13896 + SDL - Simple DirectMedia Layer
13897 + Copyright (C) 1997-2006 Sam Lantinga
13899 + This library is free software; you can redistribute it and/or
13900 + modify it under the terms of the GNU Lesser General Public
13901 + License as published by the Free Software Foundation; either
13902 + version 2.1 of the License, or (at your option) any later version.
13904 + This library is distributed in the hope that it will be useful,
13905 + but WITHOUT ANY WARRANTY; without even the implied warranty of
13906 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13907 + Lesser General Public License for more details.
13909 + You should have received a copy of the GNU Lesser General Public
13910 + License along with this library; if not, write to the Free Software
13911 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
13914 + slouken@libsdl.org
13916 +#include "SDL_config.h"
13918 +#include "SDL_cgxvideo.h"
13920 +/* Functions to be exported */
13921 +#if !defined(PROTO_SDL_H)
13922 +extern void CGX_FreeWMCursor(_THIS, WMcursor *cursor);
13923 +extern WMcursor* CGX_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
13924 +extern void CGX_CheckMouseMode(_THIS);
13926 +extern int CGX_ShowWMCursor(_THIS, WMcursor *cursor);
13927 +extern void CGX_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
13929 +extern void CGX_FreeWMCursor(_THIS, WMcursor *cursor, struct SDLBase *SDLBase);
13930 +extern WMcursor* CGX_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y, struct SDLBase *SDLBase);
13931 +extern void CGX_CheckMouseMode(_THIS, struct SDLBase *SDLBase);
13933 +extern int CGX_ShowWMCursorI(_THIS, WMcursor *cursor, struct SDLBase *SDLBase);
13934 +extern void CGX_WarpWMCursorI(_THIS, Uint16 x, Uint16 y, struct SDLBase *SDLBase);
13936 +#define CGX_ShowWMCursor(this, cursor) CGX_ShowWMCursorI(this, cursor, SDLBase)
13937 +#define CGX_WarpWMCursor(this, x, y) CGX_WarpWMCursorI(this, x, y, SDLBase)
13939 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxvideo.c SDL-1.2.15/src/video/cgx/SDL_cgxvideo.c
13940 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxvideo.c 1970-01-01 01:00:00.000000000 +0100
13941 +++ SDL-1.2.15/src/video/cgx/SDL_cgxvideo.c 2015-05-09 15:09:59.769739506 +0200
13944 + SDL - Simple DirectMedia Layer
13945 + Copyright (C) 1997-2006 Sam Lantinga
13946 + Copyright (C) 2011-2016 AROS Development Team
13948 + This library is free software; you can redistribute it and/or
13949 + modify it under the terms of the GNU Lesser General Public
13950 + License as published by the Free Software Foundation; either
13951 + version 2.1 of the License, or (at your option) any later version.
13953 + This library is distributed in the hope that it will be useful,
13954 + but WITHOUT ANY WARRANTY; without even the implied warranty of
13955 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13956 + Lesser General Public License for more details.
13958 + You should have received a copy of the GNU Lesser General Public
13959 + License along with this library; if not, write to the Free Software
13960 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
13963 + slouken@libsdl.org
13966 +#include <aros/debug.h>
13968 +#if defined (SDL_AROS_SHARED)
13969 +#define __NOLIBBASE__
13970 +#include <proto/SDL.h>
13973 +#include "SDL_config.h"
13976 + * CGX based SDL video driver implementation by Gabriele Greco
13977 + * gabriele.greco@aruba.it
13980 +#include "SDL_endian.h"
13981 +#include "SDL_timer.h"
13982 +#include "SDL_thread.h"
13983 +#include "SDL_video.h"
13984 +#include "SDL_mouse.h"
13985 +#include "../SDL_sysvideo.h"
13986 +#include "../SDL_pixels_c.h"
13987 +#include "../../events/SDL_events_c.h"
13988 +#include "SDL_cgxgl_c.h"
13989 +#include "SDL_cgxvideo.h"
13990 +#include "SDL_cgxwm_c.h"
13991 +#include "SDL_cgxmouse_c.h"
13992 +#include "SDL_cgxevents_c.h"
13993 +#include "SDL_cgxmodes_c.h"
13994 +#include "SDL_cgximage_c.h"
13995 +#include "SDL_cgxaccel_c.h"
13997 +#if defined(PROTO_SDL_H)
13998 +#include "SDL_intern.h"
14000 +#define current_video SDLBase->current_video
14003 +/* This is a special flag that tells video mode change code to not to drop existing
14005 +#define SDL_KEEP_GL_CONTEXT 0x00100000
14007 +#if !defined(PROTO_SDL_H)
14008 +static SDL_VideoDevice *CGX_CreateDevice(int devindex);
14009 +static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
14010 +static int CGX_ToggleFullScreen(_THIS, int on);
14011 +static void CGX_UpdateMouse(_THIS);
14012 +/* Initialization/Query functions */
14013 +static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat);
14014 +static int CGX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
14015 +static void CGX_VideoQuit(_THIS);
14017 +/* Gamma correction functions */
14018 +static int CGX_SetGamma(_THIS, float red, float green, float blue);
14019 +static int CGX_GetGamma(_THIS, float *red, float *green, float *blue);
14020 +static int CGX_SetGammaRamp(_THIS, Uint16 *ramp);
14021 +static int CGX_GetGammaRamp(_THIS, Uint16 *ramp);
14023 +/* CGX driver bootstrap functions */
14024 +static int CGX_Available(void);
14025 +static void CGX_DeleteDevice(SDL_VideoDevice *device);
14027 +static SDL_VideoDevice *CGX_CreateDeviceI(int devindex, struct SDLBase *SDLBase);
14028 +static SDL_Surface *CGX_SetVideoModeI(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags, struct SDLBase *SDLBase);
14029 +static int CGX_ToggleFullScreenI(_THIS, int on, struct SDLBase *SDLBase);
14030 +static void CGX_UpdateMouseI(_THIS, struct SDLBase *SDLBase);
14031 +static int CGX_VideoInitI(_THIS, SDL_PixelFormat *vformat, struct SDLBase *SDLBase);
14032 +static int CGX_SetColorsI(_THIS, int firstcolor, int ncolors, SDL_Color *colors, struct SDLBase *SDLBase);
14033 +static void CGX_VideoQuitI(_THIS, struct SDLBase *SDLBase);
14034 +static int CGX_SetGammaI(_THIS, float red, float green, float blue, struct SDLBase *SDLBase);
14035 +static int CGX_GetGammaI(_THIS, float *red, float *green, float *blue, struct SDLBase *SDLBase);
14036 +static int CGX_SetGammaRampI(_THIS, Uint16 *ramp, struct SDLBase *SDLBase);
14037 +static int CGX_GetGammaRampI(_THIS, Uint16 *ramp, struct SDLBase *SDLBase);
14038 +static int CGX_AvailableI(struct SDLBase *SDLBase);
14039 +static void CGX_DeleteDeviceI(SDL_VideoDevice *device, struct SDLBase *SDLBase);
14041 +#ifdef CGX_ShowWMCursor
14042 +#undef CGX_ShowWMCursor
14044 +#define CGX_ShowWMCursor CGX_ShowWMCursorI
14045 +#ifdef CGX_WarpWMCursor
14046 +#undef CGX_WarpWMCursor
14048 +#define CGX_WarpWMCursor CGX_WarpWMCursorI
14050 +#ifdef CGX_SetIcon
14051 +#undef CGX_SetIcon
14053 +#define CGX_SetIcon CGX_SetIconI
14054 +#ifdef CGX_SetCaption
14055 +#undef CGX_SetCaption
14057 +#define CGX_SetCaption CGX_SetCaptionI
14058 +#ifdef CGX_IconifyWindow
14059 +#undef CGX_IconifyWindow
14061 +#define CGX_IconifyWindow CGX_IconifyWindowI
14062 +#ifdef CGX_GrabWMInput
14063 +#undef CGX_GrabWMInput
14065 +#define CGX_GrabWMInput CGX_GrabWMInputI
14066 +#ifdef CGX_GetWMInfo
14067 +#undef CGX_GetWMInfo
14069 +#define CGX_GetWMInfo CGX_GetWMInfoI
14071 +#ifdef CGX_ListModes
14072 +#undef CGX_ListModes
14074 +#define CGX_ListModes CGX_ListModesI
14075 +#ifdef CGX_AllocHWSurface
14076 +#undef CGX_AllocHWSurface
14078 +#define CGX_AllocHWSurface CGX_AllocHWSurfaceI
14079 +#ifdef CGX_CheckHWBlit
14080 +#undef CGX_CheckHWBlit
14082 +#define CGX_CheckHWBlit CGX_CheckHWBlitI
14083 +#ifdef CGX_SetHWColorKey
14084 +#undef CGX_SetHWColorKey
14086 +#define CGX_SetHWColorKey CGX_SetHWColorKeyI
14087 +#ifdef CGX_FillHWRect
14088 +#undef CGX_FillHWRect
14090 +#define CGX_FillHWRect CGX_FillHWRectI
14091 +#ifdef CGX_LockHWSurface
14092 +#undef CGX_LockHWSurface
14094 +#define CGX_LockHWSurface CGX_LockHWSurfaceI
14095 +#ifdef CGX_UnlockHWSurface
14096 +#undef CGX_UnlockHWSurface
14098 +#define CGX_UnlockHWSurface CGX_UnlockHWSurfaceI
14099 +#ifdef CGX_FlipHWSurface
14100 +#undef CGX_FlipHWSurface
14102 +#define CGX_FlipHWSurface CGX_FlipHWSurfaceI
14103 +#ifdef CGX_FreeHWSurface
14104 +#undef CGX_FreeHWSurface
14106 +#define CGX_FreeHWSurface CGX_FreeHWSurfaceI
14107 +#ifdef CGX_GL_LoadLibrary
14108 +#undef CGX_GL_LoadLibrary
14110 +#define CGX_GL_LoadLibrary CGX_GL_LoadLibraryI
14111 +#ifdef CGX_GL_GetProcAddress
14112 +#undef CGX_GL_GetProcAddress
14114 +#define CGX_GL_GetProcAddress CGX_GL_GetProcAddressI
14115 +#ifdef CGX_GL_GetAttribute
14116 +#undef CGX_GL_GetAttribute
14118 +#define CGX_GL_GetAttribute CGX_GL_GetAttributeI
14119 +#ifdef CGX_GL_MakeCurrent
14120 +#undef CGX_GL_MakeCurrent
14122 +#define CGX_GL_MakeCurrent CGX_GL_MakeCurrentI
14123 +#ifdef CGX_GL_SwapBuffers
14124 +#undef CGX_GL_SwapBuffers
14126 +#define CGX_GL_SwapBuffers CGX_GL_SwapBuffersI
14128 +#define CGX_CreateDevice CGX_CreateDeviceI
14129 +#define CGX_SetVideoMode CGX_SetVideoModeI
14130 +#define CGX_ToggleFullScreen CGX_ToggleFullScreenI
14131 +#define CGX_UpdateMouse CGX_UpdateMouseI
14132 +#define CGX_VideoInit CGX_VideoInitI
14133 +#define CGX_SetColors CGX_SetColorsI
14134 +#define CGX_VideoQuit CGX_VideoQuitI
14135 +#define CGX_SetGamma CGX_SetGammaI
14136 +#define CGX_GetGamma CGX_GetGammaI
14137 +#define CGX_SetGammaRamp CGX_SetGammaRampI
14138 +#define CGX_GetGammaRamp CGX_GetGammaRampI
14139 +#define CGX_Available CGX_AvailableI
14140 +#define CGX_DeleteDevice(device) CGX_DeleteDeviceI(device, SDLBase)
14143 +static const char cgxVidName[] = "CGX";
14146 +VideoBootStrap CGX_bootstrap = {
14147 + cgxVidName, "AROS CyberGraphics",
14148 + CGX_Available, CGX_CreateDevice
14152 +#if !defined(PROTO_SDL_H)
14153 +static SDL_VideoDevice *CGX_CreateDevice(int devindex)
14156 +#ifdef CGX_CreateDevice
14157 +#undef CGX_CreateDevice
14159 +#ifdef CGX_Available
14160 +#undef CGX_Available
14162 +#define CGX_CreateDevice(devindex) CGX_CreateDeviceI(devindex, SDLBase)
14163 +#define CGX_Available() CGX_AvailableI(SDLBase)
14165 +static SDL_VideoDevice *CGX_CreateDeviceI(int devindex, struct SDLBase *SDLBase)
14168 + SDL_VideoDevice *device;
14170 + /* Initialize all variables that we clean on shutdown */
14171 + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
14175 + SDL_memset(device, 0, (sizeof *device));
14176 + device->hidden = (struct SDL_PrivateVideoData *)SDL_malloc((sizeof *device->hidden));
14177 + device->gl_data = (struct SDL_PrivateGLData *)SDL_malloc((sizeof *device->gl_data));
14180 + if ( (device == NULL) || (device->hidden == NULL) || (device->gl_data == NULL) )
14182 + D(bug("Unable to create video device!\n"));
14183 + SDL_OutOfMemory();
14184 + CGX_DeleteDevice(device);
14188 + SDL_memset(device->hidden, 0, sizeof(*device->hidden));
14189 + SDL_memset(device->gl_data, 0, sizeof(*device->gl_data));
14191 + /* Set the driver flags */
14192 + device->handles_any_size = 1;
14194 +#if defined(PROTO_SDL_H)
14195 +#ifdef CGX_DeleteDevice
14196 +#undef CGX_DeleteDevice
14198 +#define CGX_DeleteDevice CGX_DeleteDeviceI
14201 + /* Set the function pointers */
14202 + /* SDL_cgxvideo.c */
14203 + device->VideoInit = CGX_VideoInit;
14204 + device->ListModes = CGX_ListModes;
14205 + device->SetVideoMode = CGX_SetVideoMode;
14206 + device->ToggleFullScreen = CGX_ToggleFullScreen;
14207 + device->UpdateMouse = CGX_UpdateMouse;
14208 + device->SetColors = CGX_SetColors;
14209 + device->UpdateRects = NULL;
14210 + device->VideoQuit = CGX_VideoQuit;
14211 + device->free = CGX_DeleteDevice;
14212 + device->SetGamma = CGX_SetGamma;
14213 + device->GetGamma = CGX_GetGamma;
14214 + device->SetGammaRamp = CGX_SetGammaRamp;
14215 + device->GetGammaRamp = CGX_GetGammaRamp;
14216 + /* SDL_cgxaccel.c */
14217 + device->AllocHWSurface = CGX_AllocHWSurface;
14218 +#ifndef NO_AMIGAHWSURF
14219 + device->CheckHWBlit = CGX_CheckHWBlit;
14220 + device->SetHWColorKey = CGX_SetHWColorKey;
14222 + device->CheckHWBlit = NULL;
14223 + device->SetHWColorKey = NULL;
14225 + device->FillHWRect = CGX_FillHWRect;
14226 + device->SetHWAlpha = NULL;
14227 + device->LockHWSurface = CGX_LockHWSurface;
14228 + device->UnlockHWSurface = CGX_UnlockHWSurface;
14229 + device->FlipHWSurface = CGX_FlipHWSurface;
14230 + device->FreeHWSurface = CGX_FreeHWSurface;
14231 + /* SDL_cgxwm.c */
14232 + device->SetIcon = CGX_SetIcon;
14233 + device->SetCaption = CGX_SetCaption;
14234 + device->IconifyWindow = CGX_IconifyWindow;
14235 + device->GrabInput = CGX_GrabWMInput;
14236 + device->GetWMInfo = CGX_GetWMInfo;
14237 + device->FreeWMCursor = CGX_FreeWMCursor;
14238 + device->CreateWMCursor = CGX_CreateWMCursor;
14239 + device->ShowWMCursor = CGX_ShowWMCursor;
14240 + device->WarpWMCursor = CGX_WarpWMCursor;
14241 + device->CheckMouseMode = CGX_CheckMouseMode;
14242 + /* SDL_cgxevents.c */
14243 + device->InitOSKeymap = CGX_InitOSKeymap;
14244 + device->PumpEvents = CGX_PumpEvents;
14245 +#if SDL_VIDEO_OPENGL
14246 + /* SDL_cgxgl.c */
14247 + device->GL_LoadLibrary = CGX_GL_LoadLibrary;
14248 + device->GL_GetProcAddress = CGX_GL_GetProcAddress;
14249 + device->GL_GetAttribute = CGX_GL_GetAttribute;
14250 + device->GL_MakeCurrent = CGX_GL_MakeCurrent;
14251 + device->GL_SwapBuffers = CGX_GL_SwapBuffers;
14259 +#define CGX_VideoInit(this, vformat) CGX_VideoInitI(this, vformat, SDLBase)
14260 +#define CGX_SetColors(this, firstcolor, ncolors, colors) CGX_SetColorsI(this, firstcolor, ncolors, colors, SDLBase)
14261 +#define CGX_VideoQuit(this) CGX_VideoQuitI(this, SDLBase)
14262 +#define CGX_SetGamma(this, red, green, blue) CGX_SetGammaI(this, red, green, blue, SDLBase)
14263 +#define CGX_GetGamma(this, red, green, blue) CGX_GetGammaI(this, red, green, blue, SDLBase)
14264 +#define CGX_SetGammaRamp(this, ramp) CGX_SetGammaRampI(this, ramp, SDLBase)
14265 +#define CGX_GetGammaRamp(this, ramp) CGX_GetGammaRampI(this, ramp, SDLBase)
14266 +#define CGX_DeleteDevice(device) CGX_DeleteDeviceI(device, SDLBase)
14269 +#if !defined(PROTO_SDL_H)
14270 +static Uint32 CGX_OpenCustomScreen(_THIS, SDL_Surface *screen, int width, int height, int bpp, Uint32 flags)
14272 +#define CGX_OpenCustomScreen(this, screen, width, height, bpp, flags) CGX_OpenCustomScreenI(this, screen, width, height, bpp, flags, SDLBase)
14273 +static Uint32 CGX_OpenCustomScreenI(_THIS, SDL_Surface *screen, int width, int height, int bpp, Uint32 flags, struct SDLBase *SDLBase)
14278 + this->hidden->dbuffer = 0;
14280 + /* This function expects that GFX_Display is not set */
14281 + if (GFX_Display) {
14282 + D(bug("CGX_OpenCustomScreen called with GFX_Display still set\n"));
14283 + SDL_SetError("CGX_OpenCustomScreen called with GFX_Display still set");
14284 + flags &= ~SDL_FULLSCREEN;
14285 + flags &= ~SDL_DOUBLEBUF;
14289 + okid = BestCModeIDTags(CYBRBIDTG_NominalWidth, width,
14290 + CYBRBIDTG_NominalHeight, height,
14291 + CYBRBIDTG_Depth, bpp,
14294 + if ((okid == INVALID_ID) && (bpp == 32))
14296 + D(bug("Failed to open a 32bits screen trying 24bits instead\n"));
14298 + okid = BestCModeIDTags(CYBRBIDTG_NominalWidth, width,
14299 + CYBRBIDTG_NominalHeight, height,
14300 + CYBRBIDTG_Depth, bpp,
14304 + D(bug("Opening screen %dx%d/%d (id:%lx)...\n", width, height, bpp, okid));
14306 + if(okid != INVALID_ID)
14307 + GFX_Display = OpenScreenTags(NULL,
14309 + SA_Height,height,
14311 + SA_ShowTitle,FALSE,
14313 + SA_DisplayID,okid,
14316 + if (!GFX_Display)
14318 + D(bug("OpenScreenTags failed!\n"));
14319 + flags &= ~SDL_FULLSCREEN;
14320 + flags &= ~SDL_DOUBLEBUF;
14324 + SDL_Display = GFX_Display;
14326 + D(bug("Screen opened: %d x %d.\n", GFX_Display->Width, GFX_Display->Height));
14328 + if(flags & SDL_DOUBLEBUF)
14330 +#ifndef NO_AMIGAHWSURF
14331 + APTR lock = NULL;
14332 + /* check if surface can be locked, if not => Surface is SW and there is no double buffering!*/
14333 + lock = LockBitMapTags( SDL_Display->RastPort.BitMap,
14338 + UnLockBitMap(lock);
14340 + D(bug("Start of DBuffering allocations...\n"));
14342 + this->hidden->safeport=CreateMsgPort();
14343 + this->hidden->dispport=CreateMsgPort();
14345 + this->hidden->SB[0]=AllocScreenBuffer(SDL_Display,NULL,SB_SCREEN_BITMAP);
14346 + this->hidden->SB[1]=AllocScreenBuffer(SDL_Display,NULL,SB_COPY_BITMAP);
14348 + if ( this->hidden->safeport
14349 + && this->hidden->dispport
14350 + && this->hidden->SB[0]
14351 + && this->hidden->SB[1])
14353 + D(bug("Screen buffers Allocated...\n"));
14355 + this->hidden->safe_sigbit=1L<< this->hidden->safeport->mp_SigBit;
14356 + this->hidden->disp_sigbit=1L<< this->hidden->dispport->mp_SigBit;
14358 + this->hidden->SB[0]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=this->hidden->safeport;
14359 + this->hidden->SB[0]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=this->hidden->dispport;
14360 + this->hidden->SB[1]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=this->hidden->safeport;
14361 + this->hidden->SB[1]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=this->hidden->dispport;
14363 + this->hidden->dbuffer = 1;
14364 + if (screen) screen->flags |= SDL_DOUBLEBUF;
14365 + D(bug("Dbuffering enabled!\n"));
14369 + if (this->hidden->SB[0]) FreeScreenBuffer(SDL_Display,this->hidden->SB[0]);
14370 + if (this->hidden->SB[1]) FreeScreenBuffer(SDL_Display,this->hidden->SB[1]);
14371 + if (this->hidden->safeport) DeleteMsgPort (this->hidden->safeport);
14372 + if (this->hidden->dispport) DeleteMsgPort (this->hidden->dispport);
14373 + this->hidden->SB[0] = NULL;
14374 + this->hidden->SB[1] = NULL;
14375 + this->hidden->safeport = NULL;
14376 + this->hidden->dispport = NULL;
14378 + flags &= ~SDL_DOUBLEBUF;
14379 + this->hidden->dbuffer = 0;
14380 + D(bug("Dbuffering failed!\n"));
14385 + flags &= ~SDL_DOUBLEBUF;
14386 + this->hidden->dbuffer = 0;
14387 + D(bug("Dbuffering failed!\n"));
14390 + flags &= ~SDL_DOUBLEBUF;
14395 + D(bug("Screen bitmap: %ld (%ld), bpp %ld\n",
14396 + GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_BPPIX),
14397 + GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH),
14404 +static void CGX_CloseCustomScreen(_THIS, SDL_Surface *screen)
14406 + if(this->hidden->dbuffer)
14408 + D(bug("Freeing double buffering stuff..."));
14410 + this->hidden->dbuffer = 0;
14411 + if (screen) screen->flags &= ~SDL_DOUBLEBUF;
14412 + if(this->hidden->SB[1]) FreeScreenBuffer(SDL_Display,this->hidden->SB[1]);
14413 + if(this->hidden->SB[0]) FreeScreenBuffer(SDL_Display,this->hidden->SB[0]);
14415 + D(bug("Screen buffers OK..."));
14417 + if(this->hidden->safeport)
14419 + while(GetMsg(this->hidden->safeport) != NULL);
14420 + DeleteMsgPort(this->hidden->safeport);
14422 + D(bug("safeport OK..."));
14423 + if(this->hidden->dispport)
14425 + while(GetMsg(this->hidden->dispport) != NULL);
14426 + DeleteMsgPort(this->hidden->dispport);
14428 + D(bug("dispport OK..."));
14430 + this->hidden->SB[0]=this->hidden->SB[1] = NULL;
14432 + if(SDL_RastPort && SDL_RastPort != &SDL_Display->RastPort) FreeRastPort(SDL_RastPort);
14433 + SDL_RastPort=NULL;
14434 + D(bug("Rastport OK..."));
14437 + D(bug("Closing screen..."));
14438 + CloseScreen(GFX_Display);
14439 + GFX_Display = NULL; SDL_Display = NULL;
14440 + currently_fullscreen = 0;
14441 + if (screen) screen->flags &= ~SDL_FULLSCREEN;
14444 +static void CGX_CloseUnlockScreen(_THIS, SDL_Surface *screen)
14446 + if(currently_fullscreen) {
14447 + CGX_CloseCustomScreen(this, screen);
14449 + else if(GFX_Display) {
14450 + UnlockPubScreen(NULL, GFX_Display);
14451 + GFX_Display = NULL; SDL_Display = NULL;
14457 +#if !defined(PROTO_SDL_H)
14458 +static int CGX_Available(void)
14460 +static int CGX_AvailableI(struct SDLBase *SDLBase)
14463 + if ( CyberGfxBase != NULL ) {
14464 + D(bug("CGX video device AVAILABLE\n"));
14466 + D(else bug("**CGX video device UNAVAILABLE\n"));
14468 + return(CyberGfxBase != NULL);
14471 +#if !defined(PROTO_SDL_H)
14472 +static void CGX_DeleteDevice(SDL_VideoDevice *device)
14474 +static void CGX_DeleteDeviceI(SDL_VideoDevice *device, struct SDLBase *SDLBase)
14478 + if ( device->hidden ) {
14479 + SDL_free(device->hidden);
14481 + if ( device->gl_data ) {
14482 + SDL_free(device->gl_data);
14484 + SDL_free(device);
14488 +static void MakeBitMask(_THIS, int format,int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask)
14490 + if (this->hidden->depth==*bpp)
14492 + D(bug("REAL pixel format: "));
14496 + case PIXFMT_LUT8:
14497 + D(bug("PIXFMT_LUT8\n"));
14503 + case PIXFMT_BGR15:
14504 + D(bug("PIXFMT_BGR15\n"));
14505 + *Rmask = AROS_BE2WORD(0x001f);
14506 + *Gmask = AROS_BE2WORD(0x03e0);
14507 + *Bmask = AROS_BE2WORD(0x7c00);
14510 + case PIXFMT_RGB15:
14511 + D(bug("PIXFMT_RGB15\n"));
14512 + *Rmask = AROS_BE2WORD(0x7c00);
14513 + *Gmask = AROS_BE2WORD(0x03e0);
14514 + *Bmask = AROS_BE2WORD(0x001f);
14517 + case PIXFMT_RGB15PC:
14518 + D(bug("PIXFMT_RGB15PC\n"));
14519 + *Rmask = AROS_BE2WORD(0x007c);
14520 + *Gmask = AROS_BE2WORD(0xe003);
14521 + *Bmask = AROS_BE2WORD(0x1f00);
14524 + case PIXFMT_BGR15PC:
14525 + D(bug("PIXFMT_BGR15PC\n"));
14526 + *Rmask = AROS_BE2WORD(0x1f00);
14527 + *Gmask = AROS_BE2WORD(0xe003);
14528 + *Bmask = AROS_BE2WORD(0x007c);
14531 + case PIXFMT_RGB16:
14532 + D(bug("PIXFMT_RGB16\n"));
14533 + *Rmask = AROS_BE2WORD(0xf800);
14534 + *Gmask = AROS_BE2WORD(0x07e0);
14535 + *Bmask = AROS_BE2WORD(0x001f);
14538 + case PIXFMT_BGR16:
14539 + D(bug("PIXFMT_BGR16\n"));
14540 + *Rmask = AROS_BE2WORD(0x001f);
14541 + *Gmask = AROS_BE2WORD(0x07e0);
14542 + *Bmask = AROS_BE2WORD(0xf800);
14545 + case PIXFMT_RGB16PC:
14546 + D(bug("PIXFMT_RGB16PC\n"));
14547 + *Rmask = AROS_BE2WORD(0x00f8);
14548 + *Gmask = AROS_BE2WORD(0xe007);
14549 + *Bmask = AROS_BE2WORD(0x1f00);
14552 + case PIXFMT_BGR16PC:
14553 + D(bug("PIXFMT_BGR16PC\n"));
14554 + *Rmask = AROS_BE2WORD(0x1f00);
14555 + *Gmask = AROS_BE2WORD(0xe007);
14556 + *Bmask = AROS_BE2WORD(0x00f8);
14559 + case PIXFMT_RGB24:
14560 + D(bug("PIXFMT_RGB24\n"));
14561 + *Rmask = AROS_BE2LONG(0x00ff0000);
14562 + *Gmask = AROS_BE2LONG(0x0000ff00);
14563 + *Bmask = AROS_BE2LONG(0x000000ff);
14566 + case PIXFMT_BGR24:
14567 + D(bug("PIXFMT_BGR24\n"));
14568 + *Rmask = AROS_BE2LONG(0x000000ff);
14569 + *Gmask = AROS_BE2LONG(0x0000ff00);
14570 + *Bmask = AROS_BE2LONG(0x00ff0000);
14573 + case PIXFMT_ARGB32:
14574 + D(bug("PIXFMT_ARGB32\n"));
14575 + *Rmask = AROS_BE2LONG(0x00ff0000);
14576 + *Gmask = AROS_BE2LONG(0x0000ff00);
14577 + *Bmask = AROS_BE2LONG(0x000000ff);
14578 + *Amask = AROS_BE2LONG(0xff000000);
14580 + case PIXFMT_BGRA32:
14581 + D(bug("PIXFMT_BGRA32\n"));
14582 + *Rmask = AROS_BE2LONG(0x0000ff00);
14583 + *Gmask = AROS_BE2LONG(0x00ff0000);
14584 + *Bmask = AROS_BE2LONG(0xff000000);
14585 + *Amask = AROS_BE2LONG(0x000000ff);
14587 + case PIXFMT_RGBA32:
14588 + D(bug("PIXFMT_RGBA32\n"));
14589 + *Rmask = AROS_BE2LONG(0xff000000);
14590 + *Gmask = AROS_BE2LONG(0x00ff0000);
14591 + *Bmask = AROS_BE2LONG(0x0000ff00);
14592 + *Amask = AROS_BE2LONG(0x000000ff);
14595 + D(bug("Unknown pixel format! Default to RGB24\n"));
14596 + *Rmask = AROS_BE2LONG(0x00ff0000);
14597 + *Gmask = AROS_BE2LONG(0x0000ff00);
14598 + *Bmask = AROS_BE2LONG(0x000000ff);
14605 + D(bug("DIFFERENT from screen.\nAllocated screen format: "));
14610 + D(bug("ARGB32\n"));
14611 + *Rmask = AROS_BE2LONG(0x00ff0000);
14612 + *Gmask = AROS_BE2LONG(0x0000ff00);
14613 + *Bmask = AROS_BE2LONG(0x000000ff);
14614 + *Amask = AROS_BE2LONG(0xff000000);
14617 + D(bug("0RGB32\n"));
14618 + *Rmask = AROS_BE2LONG(0x00ff0000);
14619 + *Gmask = AROS_BE2LONG(0x0000ff00);
14620 + *Bmask = AROS_BE2LONG(0x000000ff);
14625 + D(bug("Not supported, switching to 24bit!\n"));
14627 + MakeBitMask(this, format, bpp, Rmask, Gmask, Bmask, Amask);
14630 + D(bug("This is a chunky display\n"));
14638 + D(bug("Mask created :\n R = 0x%08X; G = 0x%08X; B = 0x%08X; A = 0x%08X\n", *Rmask, *Gmask, *Bmask, *Amask));
14642 +#if !defined(PROTO_SDL_H)
14643 +static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat)
14645 +static int CGX_VideoInitI(_THIS, SDL_PixelFormat *vformat, struct SDLBase *SDLBase)
14651 + D(bug("VideoInit... Opening libraries\n"));
14653 + if(!IntuitionBase)
14655 + SDL_SetError("Couldn't open intuition V39+");
14661 + SDL_SetError("Couldn't open graphics V39+");
14665 + if(!CyberGfxBase)
14667 + SDL_SetError("Couldn't open cybergraphics.");
14671 + D(bug("Library intialized, locking screen...\n"));
14673 + SDL_Display = LockPubScreen(NULL);
14675 + if ( SDL_Display == NULL ) {
14676 + D(bug("Cannot lock display...\n"));
14677 + SDL_SetError("Couldn't lock the display");
14680 + this->info.current_w = SDL_Display->Width;
14681 + this->info.current_h = SDL_Display->Height;
14683 + D(bug("Checking if we are using a CGX native display...\n"));
14684 + if(!IsCyberModeID(GetVPModeID(&SDL_Display->ViewPort)))
14686 + Uint32 okid=BestCModeIDTags(CYBRBIDTG_NominalWidth, SDL_Display->Width,
14687 + CYBRBIDTG_NominalHeight, SDL_Display->Height,
14688 + CYBRBIDTG_Depth, 8,
14691 + D(bug("Default visual is not CGX native!\n"));
14693 + UnlockPubScreen(NULL,SDL_Display);
14695 + GFX_Display=NULL;
14697 + if(okid!=INVALID_ID)
14699 + GFX_Display=OpenScreenTags( NULL,
14700 + SA_Width,SDL_Display->Width,
14701 + SA_Height,SDL_Display->Height,
14704 + SA_ShowTitle,FALSE,
14705 + SA_DisplayID,okid,
14711 + SDL_SetError("Unable to open a suited CGX display");
14714 + else SDL_Display=GFX_Display;
14717 + else GFX_Display = SDL_Display;
14719 + D(bug("Before GetVideoModes....\n"));
14720 + /* Get the available video modes */
14721 + if(CGX_GetVideoModes(this) < 0) return -1;
14723 + /* Determine the default screen depth: Use the default visual (or at least one with the same depth) */
14724 + for(i = 0; i < this->hidden->nvisuals; i++)
14725 + if(this->hidden->visuals[i].depth == GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH)) break;
14727 + /* default visual was useless, take the deepest one instead */
14728 + if(i == this->hidden->nvisuals) i = 0;
14730 + D(bug("Init: Setting screen depth to: %ld\n",this->hidden->visuals[i].depth));
14732 + SDL_Visual = this->hidden->visuals[i].visual;
14733 + this->hidden->depth = this->hidden->visuals[i].depth;
14734 + vformat->BitsPerPixel = this->hidden->visuals[i].depth;
14735 + vformat->BytesPerPixel = this->hidden->visuals[i].bpp / 8;
14737 + // In this case I use makebitmask in a way that I'm sure I'll get PIXFMT pixel mask
14738 + form = GetCyberIDAttr(CYBRIDATTR_PIXFMT,SDL_Visual);
14739 + if ( vformat->BitsPerPixel > 8 )
14741 + MakeBitMask(this,form,&this->hidden->depth, &vformat->Rmask, &vformat->Gmask, &vformat->Bmask, &vformat->Amask);
14742 + vformat->Amask = 0;
14745 + /* Create the blank cursor */
14746 + SDL_BlankCursor = AllocMem(16,MEMF_CHIP|MEMF_CLEAR);
14748 + /* Fill in some window manager capabilities */
14749 + this->info.wm_available = 1;
14750 + this->info.blit_fill = 1;
14751 +#ifndef NO_AMIGAHWSURF
14752 + this->info.hw_available = 1;
14753 + this->info.blit_hw = 1;
14754 + this->info.blit_hw_CC = 1;
14755 + this->info.blit_hw_A = 1;
14756 + this->info.blit_sw = 1;
14757 + this->info.blit_sw_CC = 0;
14758 + this->info.blit_sw_A = 1;
14760 + this->info.video_mem = AvailMem(MEMF_FAST) / 4096000 * 1000; /* how to get Video Memory size? */
14762 + SDL_RastPort = &SDL_Display->RastPort;
14764 + /* We're done! */
14765 + D(bug("End of CGX_VideoInit\n"));
14770 +#if !defined(PROTO_SDL_H)
14771 +static void CGX_DestroyWindow(_THIS, SDL_Surface *screen, Uint32 flags)
14773 +#define CGX_DestroyWindow(this, screen, flags) CGX_DestroyWindowI(this, screen, flags, SDLBase)
14774 +static void CGX_DestroyWindowI(_THIS, SDL_Surface *screen, Uint32 flags, struct SDLBase *SDLBase)
14777 + D(bug("Destroy Window...\n"));
14779 + /* Mark activation flags */
14780 + this->hidden->WindowActive = 0;
14781 + this->hidden->FocusActive = 0;
14783 + /* Clean up OpenGL */
14784 + if ( screen && ( screen->flags & SDL_OPENGL ) && ! (flags & SDL_KEEP_GL_CONTEXT)) {
14785 + CGX_GL_DestroyContext(this);
14786 + screen->flags &= ~(SDL_OPENGL|SDL_OPENGLBLIT);
14789 + /* Free the colormap entries */
14790 + if ( SDL_Pens ) {
14791 + if ( this->screen
14794 + && this->screen->format
14795 + && this->hidden->depth == 8
14796 + && ! ( screen && (screen->flags & SDL_FULLSCREEN) ) ) {
14797 + int numcolors = 1 << this->screen->format->BitsPerPixel;
14798 + unsigned long pen;
14800 + if(numcolors > 256) numcolors = 256;
14802 + D(bug("Releasing %d pens...\n", numcolors));
14803 + for ( pen=0; pen < numcolors; pen++ )
14804 + if(SDL_Pens[pen] >= 0) ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_Pens[pen]);
14806 + SDL_free(SDL_Pens);
14810 + /* Destroy the output window */
14811 + if ( SDL_Window ) {
14812 +#ifndef NO_AMIGAHWSURF
14813 + if (this->hidden->temprp) FreeRastPort(this->hidden->temprp);
14814 + this->hidden->temprp = NULL;
14815 + if (this->hidden->BlitBitMap) FreeBitMap(this->hidden->BlitBitMap);
14816 + this->hidden->BlitBitMap = NULL;
14818 + CloseWindow(SDL_Window);
14819 + SDL_Window = NULL;
14823 +static void CGX_SetSizeHints(_THIS, int w, int h, Uint32 flags)
14825 + if ( flags & SDL_RESIZABLE )
14826 + WindowLimits(SDL_Window, 32, 32,4096,4096);
14828 + WindowLimits(SDL_Window, w,h,w,h);
14830 + if ( flags & SDL_FULLSCREEN )
14831 + flags &= ~SDL_RESIZABLE;
14832 + else if ( SDL_getenv("SDL_VIDEO_CENTERED") )
14833 + ChangeWindowBox(SDL_Window,
14834 + (SDL_Display->Width - w - SDL_Window->BorderLeft-SDL_Window->BorderRight)/2,
14835 + (SDL_Display->Height - h - SDL_Window->BorderTop-SDL_Window->BorderBottom)/2,
14836 + w+SDL_Window->BorderLeft+SDL_Window->BorderRight,
14837 + h+SDL_Window->BorderTop+SDL_Window->BorderBottom);
14840 +#if !defined(PROTO_SDL_H)
14841 +static int CGX_CreateWindow(_THIS, SDL_Surface *screen, int w, int h, int bpp, Uint32 flags)
14843 +#define CGX_CreateWindow(this, screen, w, h, bpp, flags) CGX_CreateWindowI(this, screen, w, h, bpp, flags, SDLBase)
14844 +static int CGX_CreateWindowI(_THIS, SDL_Surface *screen, int w, int h, int bpp, Uint32 flags, struct SDLBase *SDLBase)
14847 + Uint32 form, rb, gb, bb, ab;
14849 + D(bug("CGX_CreateWindow %dx%d/%d flags:%lx\n", w, h, bpp, flags));
14851 + /* This function assumes any existing window has already been closed */
14852 + if (SDL_Window != 0) {
14853 + D(bug("CGX_CreateWindow called when window still open\n"));
14854 + SDL_SetError("CGX_CreateWindow called when window still open");
14857 + /* This function assumes any existing GL context has already been freed up */
14858 + if (!(flags & SDL_KEEP_GL_CONTEXT) && (this->gl_data->glctx != NULL)) {
14859 + D(bug("CGX_CreateWindow called when GL context still active\n"));
14860 + SDL_SetError("CGX_CreateWindow called when GL context still active");
14864 + /* Allocate the new pixel format for this video mode */
14865 + form = GetCyberIDAttr(CYBRIDATTR_PIXFMT,SDL_Visual);
14867 + if((flags & SDL_HWSURFACE) && (bpp!=this->hidden->depth))
14869 + bpp = this->hidden->depth;
14870 + D(bug("Accel forces bpp to be equal (%ld)\n",bpp));
14874 + With this call if needed I'll revert the wanted bpp to a bpp best suited for the display, actually occurs
14875 + only with requested format 15/16bit and display format != 15/16bit
14877 + D(bug("BEFORE screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth));
14879 + MakeBitMask(this,form,&bpp, &rb, &gb, &bb, &ab);
14881 + if ( ! SDL_ReallocFormat(screen, 8 * GetCyberMapAttr(SDL_Display->RastPort.BitMap, CYBRMATTR_BPPIX), rb, gb, bb, 0) )
14884 + D(bug("AFTER screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth));
14886 + /* Create the appropriate colormap */
14887 + if ( GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT)==PIXFMT_LUT8 || bpp==8 )
14890 + D(bug("Pens palette allocation...\n"));
14892 + /* Allocate the pixel flags */
14896 + ncolors = 1 << screen->format->BitsPerPixel;
14898 + SDL_Pens = (Sint32 *)SDL_malloc(ncolors * sizeof(Sint32));
14900 + if(SDL_Pens == NULL)
14902 + SDL_OutOfMemory();
14906 + for(i=0;i<ncolors;i++) SDL_Pens[i]=-1;
14908 + /* always allocate a private colormap on non-default visuals */
14909 + if(bpp==8) flags |= SDL_HWPALETTE;
14911 + if ( flags & SDL_HWPALETTE ) screen->flags |= SDL_HWPALETTE;
14914 + if( flags & SDL_FULLSCREEN )
14916 + SDL_Window = OpenWindowTags(NULL,
14917 + WA_Width,SDL_Display->Width,
14918 + WA_Height,SDL_Display->Height,
14919 + WA_Flags,WFLG_ACTIVATE|WFLG_RMBTRAP|WFLG_BORDERLESS|WFLG_BACKDROP|WFLG_REPORTMOUSE,
14920 + WA_IDCMP,IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE,
14921 + WA_BackFill, (IPTR)LAYERS_NOBACKFILL,
14922 + WA_CustomScreen,(IPTR)SDL_Display,
14924 + FillPixelArray(SDL_Window->RPort,SDL_Window->BorderLeft,SDL_Window->BorderTop,SDL_Display->Width,SDL_Display->Height,0x00000000);
14925 + D(bug("Opening backdrop window %ldx%ld on display %lx!\n",SDL_Display->Width,SDL_Display->Height,SDL_Display));
14931 + left = (SDL_Display->Width - w) / 2;
14932 + top = (SDL_Display->Height - h) / 2;
14934 + SDL_Window = OpenWindowTags(NULL,
14936 + WA_InnerHeight,h,
14939 + WA_Title, this->hidden->WindowName,
14940 + WA_Flags, WFLG_REPORTMOUSE|WFLG_ACTIVATE|WFLG_RMBTRAP |
14941 + ((flags&SDL_NOFRAME) ? 0 : (WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_DRAGBAR |
14942 + ((flags&SDL_RESIZABLE) ? WFLG_SIZEGADGET|WFLG_SIZEBBOTTOM : 0))),
14943 + WA_IDCMP, IDCMP_RAWKEY|IDCMP_CLOSEWINDOW|IDCMP_MOUSEBUTTONS|IDCMP_NEWSIZE|
14944 + IDCMP_MOUSEMOVE|IDCMP_ACTIVEWINDOW|IDCMP_INACTIVEWINDOW,
14945 + WA_BackFill, (IPTR)LAYERS_NOBACKFILL,
14946 + WA_PubScreen,(IPTR)SDL_Display,
14948 + FillPixelArray(SDL_Window->RPort,SDL_Window->BorderLeft,SDL_Window->BorderTop,w,h,0x00000000);
14949 + D(bug("Opening WB window of size: %ldx%ld!\n",w,h));
14952 +#ifndef NO_AMIGAHWSURF
14953 + if ( (flags & SDL_DOUBLEBUF)
14954 + && (flags & SDL_FULLSCREEN)
14955 + && (this->hidden->dbuffer) )
14957 + D(bug("Double Buffering in use\n",w,h));
14958 + if((SDL_RastPort = CreateRastPort()) != NULL)
14960 + SDL_RastPort->BitMap=this->hidden->SB[1]->sb_BitMap;
14961 + screen->flags |= SDL_DOUBLEBUF;
14968 + // If there is no double buffering we create a Bitmap to fake double buffering.
14969 + D(bug("No Double Buffering : Using BlitBitMap hack\n",w,h));
14970 + this->hidden->BlitBitMap = AllocBitMap( w,
14972 + GetBitMapAttr(SDL_Window->RPort->BitMap, BMA_DEPTH),
14973 + flags & SDL_FULLSCREEN ? BMF_CLEAR| BMF_MINPLANES : BMF_CLEAR | BMF_MINPLANES | BMF_DISPLAYABLE,
14974 + SDL_Window->RPort->BitMap);
14976 + if (!this->hidden->BlitBitMap) return -1;
14978 + screen->flags &= ~SDL_DOUBLEBUF;
14979 + SDL_RastPort=SDL_Window->RPort;
14982 + screen->flags &= ~SDL_DOUBLEBUF;
14983 + SDL_RastPort=SDL_Window->RPort;
14986 + if (flags & SDL_HWSURFACE)
14987 + screen->flags |= SDL_HWSURFACE;
14989 + screen->flags &= ~SDL_HWSURFACE;
14991 + CGX_SetSizeHints(this, w, h, flags);
14992 + this->info.current_w = w;
14993 + this->info.current_h = h;
14995 + if ( flags & SDL_FULLSCREEN )
14997 + screen->flags |= SDL_FULLSCREEN;
14998 + /* IDCMP_ACTIVEWINDOW does not seem to be sent to windows opened on
14999 + new screen, so we set activity status here */
15000 + this->hidden->WindowActive = 1;
15001 + /* Reset explicit focus activation - alway capture in full screen mode */
15002 + this->hidden->ExplicitFocusActivation = 0;
15004 + currently_fullscreen=1;
15007 + screen->flags &= ~SDL_FULLSCREEN;
15011 + screen->pitch = SDL_CalculatePitch(screen);
15012 + CGX_ResizeImage(this, screen, flags);
15014 + /* Make OpenGL Context if needed*/
15015 + if(flags & SDL_OPENGL) {
15016 + if (flags & SDL_KEEP_GL_CONTEXT) {
15017 + /* Context was not destroyed, update it here */
15018 + if (CGX_GL_UpdateContext(this) < 0) {
15019 + SDL_SetError("Failed to update GL context");
15023 + if(CGX_GL_CreateContext(this) < 0) {
15024 + SDL_SetError("Failed to create GL context");
15028 + screen->flags |= SDL_OPENGL;
15035 +#if !defined(PROTO_SDL_H)
15036 +static int CGX_ResizeWindow(_THIS, SDL_Surface *screen, int width, int height, Uint32 flags)
15038 +#define CGX_ResizeWindow(this, screen, width, height, flags) CGX_ResizeWindowI(this, screen, width, height, flags, SDLBase)
15039 +static int CGX_ResizeWindowI(_THIS, SDL_Surface *screen, int width, int height, Uint32 flags, struct SDLBase *SDLBase)
15042 + D(bug("CGX_ResizeWindow\n"));
15044 + /* Resize the window manager window */
15045 + CGX_SetSizeHints(this, width, height, flags);
15046 + this->info.current_w = width;
15047 + this->info.current_h = height;
15049 + ChangeWindowBox( SDL_Window,
15050 + SDL_Window->LeftEdge,
15051 + SDL_Window->TopEdge,
15052 + width+SDL_Window->BorderLeft+SDL_Window->BorderRight,
15053 + height+SDL_Window->BorderTop+SDL_Window->BorderBottom);
15054 + screen->w = width;
15055 + screen->h = height;
15056 + screen->pitch = SDL_CalculatePitch(screen);
15057 +#ifndef NO_AMIGAHWSURF
15058 + if (this->hidden->BlitBitMap)
15060 + FreeBitMap(this->hidden->BlitBitMap);
15061 + this->hidden->BlitBitMap = AllocBitMap( width,
15063 + GetBitMapAttr(SDL_Window->RPort->BitMap, BMA_DEPTH),
15064 + flags & SDL_FULLSCREEN ? BMF_CLEAR | BMF_MINPLANES : BMF_CLEAR |BMF_MINPLANES | BMF_DISPLAYABLE,
15065 + SDL_Window->RPort->BitMap);
15068 + CGX_ResizeImage(this, screen, flags);
15073 +/* There are several combinations of existing and request parameters that this
15074 + function needs to support.
15076 + Explanation of parameters:
15078 + WND - windowned on Workbench window
15079 + sizeA, sizeB, sizeAny - some different sizes (width/height) of surfaces
15080 + bppA, bppB, bppAny - some different bits per pixel of surfaces
15081 + bppWB - bits per pixel of Workbench
15082 + OGL - surface uses OpenGL
15083 + NOGL - surface does not use OpenGL
15085 + Explanation of actions:
15086 + wndR - resize window
15087 + wndC, wndD - create, destroy window
15088 + scrC, scrD - create, destroy screen
15089 + oglC, oglD - create, destroy OpenGL context
15090 + oglU - update OpenGL context with new window
15094 + | Current | Requested | Actions |
15095 + | bppWB, sizeA, WND, OGL | bppB, sizeAny, WND, OGL | Not possible to change bpp of window on Workbench |
15096 + | bppWB, sizeA, WND, OGL | bppWB, sizeB, WND, OGL | wndR(sizeB) |
15097 + | bppWB, sizeA, WND, NOGL | bppWB, sizeB, WND, NOGL | wndR(sizeB) |
15098 + | bppWB, sizeA, WND, OGL | bppWB, sizeB, WND, NOGL | oglD, wndD, wndC(sizeB) |
15099 + | bppWB, sizeA, WND, NOGL | bppWB, sizeB, WND, OGL | wndD, wndC(sizeB), oglC |
15100 + | bppWB, sizeA, WND, OGL | bppAny, sizeAny, FS, OGL | wndD, scrC(sizeAny, bppAny), wndC(sizeAny), oglU |
15101 + | bppWB, sizeA, WND, OGL | bppAny, sizeAny, FS, NOGL | oglD, wndD, scrC(sizeAny, bppAny), wndC(sizeAny), oglC |
15102 + | bppA, sizeA, FS, OGL | bppB, sizeAny, FS, OGL | wndD, scrD, scrC(sizeAny, bppB), wndC(sizeAny), oglU |
15103 + | bppA, sizeA, FS, OGL | bppAny, sizeB, FS, OGL | wndD, scrD, scrC(sizeB, bppAny), wndC(sizeB), oglU |
15104 + | bppA, sizeA, FS, OGL | bppB, sizeAny, FS, NOGL | oglD, wndD, scrD, scrC(sizeAny, bppB), wndC(sizeAny) |
15105 + | bppA, sizeA, FS, OGL | bppAny, sizeB, FS, NOGL | oglD, wndD, scrD, scrC(sizeB, bppAny), wndC(sizeB) |
15106 + | bppA, sizeA, FS, OGL | bppWB, sizeAny, WND, OGL | wndD, scrD, wndC(sizeAny), oglU |
15107 + | bppA, sizeA, FS, OGL | bppWB, sizeAny, WND, NOGL | oglD, wndD, scrD, wndC(sizeAny) |
15111 + (+)if ( curr->WND && req->WND && sizediff && ! ogldiff ) resize_window
15112 + (+)if ( ! resize_window ) destroy_window
15113 + (+)if ( curr->FS && ( sizediff || bppdiff || req->WND ) ) destroy_screen
15114 + (+)if ( req->FS && ( sizediff || bppdiff || curr->WND ) ) create_screen
15115 + (+)if ( ! resize_window ) create_window
15117 + (+)if ( ! ogldiff) req->SDL_KEEP_GL_CONTEXT
15118 + (+)if ( destroy_window && curr->SDL_OPENGL && ! req->SDL_KEEP_GL_CONTEXT ) destroy_context
15119 + (+)if ( create_window && req->SDL_OPENGL && ! req->SDL_KEEP_GL_CONTEXT ) create_context
15120 + (+)if ( create_window && req->SDL_OPENGL && req->SDL_KEEP_GL_CONTEXT ) update_context
15123 +#if !defined(PROTO_SDL_H)
15124 +static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags)
15126 +#ifdef CGX_SetVideoMode
15127 +#undef CGX_SetVideoMode
15129 +#define CGX_SetVideoMode(this, current, width, height, bpp, flags) CGX_SetVideoModeI(this, current, width, height, bpp, flags, SDLBase)
15130 +static SDL_Surface *CGX_SetVideoModeI(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags, struct SDLBase *SDLBase)
15133 + int sizediff = 0, bppdiff = 0, ogldiff = 0, i;
15135 + sizediff = (current != NULL) ? ((current->w != width) || (current->h != height)) : 1;
15136 + bppdiff = (this->hidden != NULL) ? (this->hidden->depth != bpp) : 1;
15137 + ogldiff = (current != NULL) ? ((current->flags & SDL_OPENGL) != (flags & SDL_OPENGL)) : 1;
15138 + if (!ogldiff) flags |= SDL_KEEP_GL_CONTEXT;
15140 + D(bug("CGX_SetVideoMode to %dx%dx%d, sizediff %d bppdiff %d\n", width, height, bpp, sizediff, bppdiff));
15142 + /* Lock the event thread, in multi-threading environments */
15143 + SDL_Lock_EventThread();
15145 + /* Decide early on if we are resizing or rebuilding window */
15146 + if ((SDL_Window && current && !(current->flags & SDL_FULLSCREEN)) && !(flags & SDL_FULLSCREEN)
15147 + && (sizediff) && (!ogldiff)) {
15149 + /* Not possible in windowned mode. Use previous depth. */
15150 + D(bug("Bringing bpp back from %d to %d\n", bpp, this->hidden->depth));
15151 + bpp = this->hidden->depth;
15154 + if (CGX_ResizeWindow(this, current, width, height, flags) < 0)
15157 + current->flags |= (flags & SDL_RESIZABLE); /* Resizable only if the user asked it */
15159 + /* Release the event thread */
15160 + SDL_Unlock_EventThread();
15162 + /* We're done! */
15166 + /* Destroy existing window */
15167 + CGX_DestroyImage(this, current);
15168 + CGX_DestroyWindow(this, current, flags);
15170 + /* Destroy existing screen if needed */
15171 + if ((current && (current->flags & SDL_FULLSCREEN)) &&
15172 + ((!(flags & SDL_FULLSCREEN)) || (sizediff) || (bppdiff))) {
15173 + CGX_CloseCustomScreen(this, current);
15176 + /* Create new screen if needed */
15177 + if ((flags & SDL_FULLSCREEN) &&
15178 + ((current && !(current->flags & SDL_FULLSCREEN))
15179 + || (sizediff) || (bppdiff))) {
15181 + /* Release hold on Workbench screen first */
15182 + if (current && !(current->flags & SDL_FULLSCREEN)) {
15183 + UnlockPubScreen(NULL, GFX_Display);
15184 + GFX_Display = NULL; SDL_Display = NULL;
15187 + flags = CGX_OpenCustomScreen(this, current, width, height, bpp, flags);
15190 + if (!GFX_Display) {
15191 + /* Attach SDL to Workbench screen if screen opening failed on running
15192 + in windowed mode. */
15193 + GFX_Display = SDL_Display = LockPubScreen(NULL);
15196 + /* Select visual before creating a window */
15197 + bpp = this->hidden->depth = GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH);
15198 + D(bug("Setting screen depth to: %ld\n", this->hidden->depth));
15200 + for (i = 0; i < this->hidden->nvisuals; i++)
15201 + if (this->hidden->visuals[i].depth == bpp)
15204 + if (i == this->hidden->nvisuals) {
15205 + SDL_SetError("No matching visual for requested depth. Should never happen!");
15206 + return NULL; /* should never happen */
15208 + SDL_Visual = this->hidden->visuals[i].visual;
15210 + /* Create a new window */
15211 + if (CGX_CreateWindow(this, current, width, height, bpp, flags) < 0)
15214 + current->flags |= (flags & SDL_RESIZABLE); /* Resizable only if the user asked it */
15216 + /* Release the event thread */
15217 + SDL_Unlock_EventThread();
15219 + /* We're done! */
15223 +#if !defined(PROTO_SDL_H)
15224 +static int CGX_ToggleFullScreen(_THIS, int on)
15226 +static int CGX_ToggleFullScreenI(_THIS, int on, struct SDLBase *SDLBase)
15229 + Uint32 event_thread;
15231 + /* Don't lock if we are the event thread */
15232 + event_thread = SDL_EventThreadID();
15233 + if (event_thread && (SDL_ThreadID() == event_thread)) event_thread = 0;
15234 + if (event_thread) SDL_Lock_EventThread();
15238 + Uint32 flags = this->screen->flags;
15239 + flags |= SDL_FULLSCREEN;
15241 + /* Call video mode change */
15242 + CGX_SetVideoMode(this, this->screen, this->screen->w, this->screen->h, this->hidden->depth, flags);
15246 + Uint32 flags = this->screen->flags;
15247 + flags &= ~SDL_FULLSCREEN;
15249 + /* Call video mode change */
15250 + CGX_SetVideoMode(this, this->screen, this->screen->w, this->screen->h, this->hidden->depth, flags);
15253 + /* SDL does not take care of hinding cursor in this case. If it was hidden, hide it
15254 + again. Call Intuition direclty */
15255 + if ((this->hidden->CursorVisible == 0) && (SDL_BlankCursor != NULL))
15256 + SetPointer(SDL_Window, (UWORD *)SDL_BlankCursor, 1, 1, 0, 0);
15259 + CGX_RefreshDisplay(this);
15261 + if (event_thread) SDL_Unlock_EventThread();
15263 + SDL_ResetKeyboard();
15267 +/* Update the current mouse state and position */
15268 +#if !defined(PROTO_SDL_H)
15269 +static void CGX_UpdateMouse(_THIS)
15271 +static void CGX_UpdateMouseI(_THIS, struct SDLBase *SDLBase)
15274 + /* Lock the event thread, in multi-threading environments */
15275 + SDL_Lock_EventThread();
15277 + if(currently_fullscreen)
15279 + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
15280 + SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX, SDL_Display->MouseY);
15284 + if( SDL_Display->MouseX>=(SDL_Window->LeftEdge+SDL_Window->BorderLeft) && SDL_Display->MouseX<(SDL_Window->LeftEdge+SDL_Window->Width-SDL_Window->BorderRight) &&
15285 + SDL_Display->MouseY>=(SDL_Window->TopEdge+SDL_Window->BorderLeft) && SDL_Display->MouseY<(SDL_Window->TopEdge+SDL_Window->Height-SDL_Window->BorderBottom)
15288 + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
15289 + SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX-SDL_Window->LeftEdge-SDL_Window->BorderLeft,
15290 + SDL_Display->MouseY-SDL_Window->TopEdge-SDL_Window->BorderTop);
15294 + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
15297 + SDL_Unlock_EventThread();
15300 +#if !defined(PROTO_SDL_H)
15301 +static int CGX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
15303 +static int CGX_SetColorsI(_THIS, int firstcolor, int ncolors, SDL_Color *colors, struct SDLBase *SDLBase)
15308 + if ( (this->screen->flags & SDL_HWPALETTE) && currently_fullscreen )
15310 + ULONG cmap[256*3+2];
15312 + cmap[0]=(ncolors<<16);
15313 + cmap[0]+=firstcolor;
15315 + for ( i=0; i<ncolors; i++ )
15317 + cmap[i*3+1] = colors[i].r<<24;
15318 + cmap[i*3+2] = colors[i].g<<24;
15319 + cmap[i*3+3] = colors[i].b<<24;
15321 + cmap[ncolors*3+1]=0;
15322 + LoadRGB32(&GFX_Display->ViewPort,cmap);
15326 + // Pens are not needed on 8bit screen with hwpalette
15327 + unsigned long pen;
15329 + if ( SDL_Pens == NULL ) {
15330 + D(bug("SetColors without colormap!"));
15334 + if(this->hidden->depth==8)
15336 + for ( pen=firstcolor; pen<ncolors+firstcolor; pen++ )
15338 + if(SDL_Pens[pen]>=0)
15339 + ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_Pens[pen]);
15342 + /* Try to allocate all the colors */
15343 + for ( i=0; i<ncolors; i++ )
15345 + SDL_Pens[i+firstcolor]=ObtainBestPenA(GFX_Display->ViewPort.ColorMap,colors[i].r<<24,colors[i].g<<24,colors[i].b<<24,NULL);
15350 + for(i=0;i<ncolors;i++)
15351 + SDL_Pens[i+firstcolor]=(colors[i].r<<16)+(colors[i].g<<8)+colors[i].b;
15358 + Note: If we are terminated, this could be called in the middle of
15359 + another SDL video routine -- notably UpdateRects.
15361 +#if !defined(PROTO_SDL_H)
15362 +static void CGX_VideoQuit(_THIS)
15364 +static void CGX_VideoQuitI(_THIS, struct SDLBase *SDLBase)
15367 + /* Shutdown everything that's still up */
15368 + /* The event thread should be done, so we can touch SDL_Display */
15369 + D(bug("CGX_VideoQuit\n"));
15371 + if ( SDL_Display != NULL )
15373 + /* Clean up OpenGL */
15374 + CGX_GL_Quit(this);
15376 + /* Start shutting down the windows */
15377 + D(bug("Destroying image...\n"));
15378 + CGX_DestroyImage(this, this->screen);
15379 + D(bug("Destroying window...\n"));
15380 + CGX_DestroyWindow(this, this->screen, 0);
15381 + /* Otherwise SDL_VideoQuit will try to free it! */
15382 + SDL_VideoSurface=NULL;
15383 + CGX_FreeVideoModes(this);
15385 + /* Free that blank cursor */
15386 + if ( SDL_BlankCursor != NULL )
15388 + FreeMem(SDL_BlankCursor,16);
15389 + SDL_BlankCursor = NULL;
15392 + D(bug("Destroying screen...\n"));
15394 + if ( GFX_Display != NULL )
15395 + CGX_CloseUnlockScreen(this, NULL);
15397 + SDL_Display = NULL;
15402 + DeleteIORequest(SDL_ConReq);
15403 + SDL_ConReq = NULL;
15408 + DeleteMsgPort(SDL_ConPort);
15409 + SDL_ConPort = NULL;
15412 + if ( this->screen && (this->screen->flags & SDL_HWSURFACE) )
15414 + /* Direct screen access, no memory buffer */
15415 + this->screen->pixels = NULL;
15417 + D(bug("End of CGX_VideoQuit.\n"));
15421 +/* Gamma correction functions (Not supported) */
15422 +#if !defined(PROTO_SDL_H)
15423 +static int CGX_SetGamma(_THIS, float red, float green, float blue)
15425 +static int CGX_SetGammaI(_THIS, float red, float green, float blue, struct SDLBase *SDLBase)
15428 + SDL_SetError("Gamma correction not supported");
15432 +#if !defined(PROTO_SDL_H)
15433 +static int CGX_GetGamma(_THIS, float *red, float *green, float *blue)
15435 +static int CGX_GetGammaI(_THIS, float *red, float *green, float *blue, struct SDLBase *SDLBase)
15438 + SDL_SetError("Gamma correction not supported");
15442 +#if !defined(PROTO_SDL_H)
15443 +static int CGX_SetGammaRamp(_THIS, Uint16 *ramp)
15445 +static int CGX_SetGammaRampI(_THIS, Uint16 *ramp, struct SDLBase *SDLBase)
15448 + SDL_SetError("Gamma correction not supported");
15452 +#if !defined(PROTO_SDL_H)
15453 +static int CGX_GetGammaRamp(_THIS, Uint16 *ramp)
15455 +static int CGX_GetGammaRampI(_THIS, Uint16 *ramp, struct SDLBase *SDLBase)
15458 + SDL_SetError("Gamma correction not supported");
15461 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxvideo.h SDL-1.2.15/src/video/cgx/SDL_cgxvideo.h
15462 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxvideo.h 1970-01-01 01:00:00.000000000 +0100
15463 +++ SDL-1.2.15/src/video/cgx/SDL_cgxvideo.h 2015-05-09 15:09:59.769739506 +0200
15466 + SDL - Simple DirectMedia Layer
15467 + Copyright (C) 1997-2006 Sam Lantinga
15469 + This library is free software; you can redistribute it and/or
15470 + modify it under the terms of the GNU Lesser General Public
15471 + License as published by the Free Software Foundation; either
15472 + version 2.1 of the License, or (at your option) any later version.
15474 + This library is distributed in the hope that it will be useful,
15475 + but WITHOUT ANY WARRANTY; without even the implied warranty of
15476 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15477 + Lesser General Public License for more details.
15479 + You should have received a copy of the GNU Lesser General Public
15480 + License along with this library; if not, write to the Free Software
15481 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15484 + slouken@libsdl.org
15486 +#include "SDL_config.h"
15488 +#ifndef _SDL_cgxvideo_h
15489 +#define _SDL_cgxvideo_h
15492 +#include <exec/exec.h>
15493 +#include <cybergraphx/cybergraphics.h>
15494 +#include <graphics/scale.h>
15495 +#include <graphics/gfx.h>
15496 +#include <intuition/intuition.h>
15497 +#include <proto/exec.h>
15498 +#include <proto/cybergraphics.h>
15499 +#include <proto/graphics.h>
15500 +#include <proto/intuition.h>
15501 +#include <proto/console.h>
15502 +#include <devices/rawkeycodes.h>
15504 +#include "SDL_mouse.h"
15505 +#include "../SDL_sysvideo.h"
15506 +#include "../../main/aros/mydebug.h"
15508 +/* Hidden "this" pointer for the video functions */
15509 +#define _THIS SDL_VideoDevice *this
15510 +#define WINDOW_NAME_BUFFER_SIZE 256
15512 +/* Private display data */
15513 +struct SDL_PrivateVideoData {
15514 + struct Screen *Public_Display; /* Used for events and window management */
15515 + struct Screen *GFX_Display; /* Used for graphics and colormap stuff */
15516 + struct Window *SDL_Window; /* The SDL Window */
15517 + struct RastPort *RP;
15518 + TEXT WindowName[WINDOW_NAME_BUFFER_SIZE];
15520 + unsigned char *BlankCursor; /* The invisible cursor */
15522 + /* The variables used for displaying graphics */
15523 + Uint8 *Image; /* The image for our window */
15525 + /* The current list of available video modes */
15526 + SDL_Rect **modelist;
15528 + /* available visuals of interest to us, sorted deepest first */
15531 + int depth; /* number of significant bits/pixel */
15532 + int bpp; /* pixel quantum in bits */
15533 + } visuals[5]; /* at most entries for 8, 15, 16, 24, 32*/
15536 + Uint32 vis; /* current visual in use */
15537 + int depth; /* current visual depth (not bpp) */
15538 + int currently_fullscreen; /* Fullscreen flag */
15540 + /* Support for internal mouse warping */
15541 + int FocusActive; /* Flag indicating that application has keyboard/mouse focus */
15542 + int WindowActive; /* Flag indicating that AROS Window in in active state */
15543 + int GrabMouse; /* Flag indicating that mouse shall be grabbed */
15544 + int CursorVisible; /* Flag indicating that cursor is visible */
15545 + int ExplicitFocusActivation; /* Flag indicating that focus should not be activated automatically when moving to inner area */
15549 + /* Double buffering handling */
15550 + int dbuffer; /* flag indicating that double buffering is in use */
15551 + struct ScreenBuffer *SB[2]; /* Double buffered screens */
15552 + struct MsgPort *safeport;
15553 + struct MsgPort *dispport;
15554 + ULONG safe_sigbit;
15555 + ULONG disp_sigbit;
15556 + struct BitMap *BlitBitMap; /* Used to fake double buffering in Window mode, also used in FullScreen if AllocScreenBuffer fails */
15558 + /* Temporary rastport used for HW bliting to non display surface */
15559 + struct RastPort *temprp;
15561 + /* Colormap handling */
15562 + Sint32 *Pens; /* A list of Pens that have been allocated, the size depends on the screen format */
15565 +/* Old variable names */
15566 +#define SDL_Display (this->hidden->Public_Display)
15567 +#define GFX_Display (this->hidden->GFX_Display)
15568 +#define SDL_Visual (this->hidden->vis)
15569 +#define SDL_Window (this->hidden->SDL_Window)
15570 +#define SDL_BlankCursor (this->hidden->BlankCursor)
15571 +#define SDL_Image (this->hidden->Image)
15572 +#define SDL_modelist (this->hidden->modelist)
15573 +#define SDL_RastPort (this->hidden->RP)
15574 +#define currently_fullscreen (this->hidden->currently_fullscreen)
15575 +#define SDL_DisplayColormap (this->hidden->GFX_Display->ViewPort.ColorMap)
15576 +#define SDL_Pens (this->hidden->Pens)
15577 +#define SDL_temprp (this->hidden->temprp)
15579 +extern struct Library *CyberGfxBase;
15580 +extern struct IntuitionBase *IntuitionBase;
15581 +extern struct GfxBase *GfxBase;
15582 +extern struct ExecBase *SysBase;
15583 +extern struct DosLibrary *DOSBase;
15585 +extern struct IOStdReq *SDL_ConReq;
15586 +extern struct MsgPort *SDL_ConPort;
15588 +/* Private data for HW surfaces */
15589 +struct private_hwdata
15591 + struct BitMap *bmap; // Pointer to HW surface bitmap
15592 + APTR lock; // Pointer to lock
15593 + struct SDL_VideoDevice *videodata; // Needed to keep track of window BorderLeft and BorderTop while bliting
15594 + APTR mask; // Mask used for ColorKey bliting
15595 + APTR pixarrayalpha; // Pixel array with alpha channel used for Alpha and ColorKey bliting
15596 + ULONG pixfmt; // pixfmt of the surface
15597 + BOOL allocated; // Set to 1 if the bitmap has been allocated (remains 0 for the display surface)
15598 + BOOL update; // Flag used to force pending display update due to locks on destination surface after unlocking
15601 +#endif /* _SDL_cgxvideo_h */
15603 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxwm.c SDL-1.2.15/src/video/cgx/SDL_cgxwm.c
15604 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxwm.c 1970-01-01 01:00:00.000000000 +0100
15605 +++ SDL-1.2.15/src/video/cgx/SDL_cgxwm.c 2015-05-09 15:09:59.769739506 +0200
15608 + SDL - Simple DirectMedia Layer
15609 + Copyright (C) 1997-2006 Sam Lantinga
15611 + This library is free software; you can redistribute it and/or
15612 + modify it under the terms of the GNU Lesser General Public
15613 + License as published by the Free Software Foundation; either
15614 + version 2.1 of the License, or (at your option) any later version.
15616 + This library is distributed in the hope that it will be useful,
15617 + but WITHOUT ANY WARRANTY; without even the implied warranty of
15618 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15619 + Lesser General Public License for more details.
15621 + You should have received a copy of the GNU Lesser General Public
15622 + License along with this library; if not, write to the Free Software
15623 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15626 + slouken@libsdl.org
15628 +#if defined (SDL_AROS_SHARED)
15629 +#define __NOLIBBASE__
15630 +#include <proto/SDL.h>
15633 +#include "SDL_config.h"
15635 +#include "SDL_version.h"
15636 +#include "SDL_video.h"
15637 +#include "SDL_syswm.h"
15638 +#include "SDL_mouse.h"
15639 +#include "../../events/SDL_events_c.h"
15640 +#include "SDL_cgxmodes_c.h"
15641 +#include "SDL_cgxwm_c.h"
15642 +#include "SDL_cgxmouse_c.h"
15644 +#if !defined(PROTO_SDL_H)
15645 +void CGX_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
15647 +#include "SDL_intern.h"
15649 +void CGX_SetIconI(_THIS, SDL_Surface *icon, Uint8 *mask, struct SDLBase *SDLBase)
15652 + /* Not yet implemented */
15655 +#if !defined(PROTO_SDL_H)
15656 +int CGX_IconifyWindow(_THIS)
15658 +int CGX_IconifyWindowI(_THIS, struct SDLBase *SDLBase)
15661 + /* Not yet implemented */
15665 +#if !defined(PROTO_SDL_H)
15666 +void CGX_SetCaption(_THIS, const char *title, const char *icon)
15668 +void CGX_SetCaptionI(_THIS, const char *title, const char *icon, struct SDLBase *SDLBase)
15671 + strncpy(this->hidden->WindowName, title, WINDOW_NAME_BUFFER_SIZE);
15672 + if(SDL_Window) SetWindowTitles(SDL_Window, this->hidden->WindowName, NULL);
15675 +#if !defined(PROTO_SDL_H)
15676 +int CGX_GetWMInfo(_THIS, SDL_SysWMinfo *info)
15678 +int CGX_GetWMInfoI(_THIS, SDL_SysWMinfo *info, struct SDLBase *SDLBase)
15681 + if ( info->version.major <= SDL_MAJOR_VERSION )
15687 + SDL_SetError("Application not compiled with SDL %d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
15692 +#if !defined(PROTO_SDL_H)
15693 +SDL_GrabMode CGX_GrabWMInput(_THIS, SDL_GrabMode mode)
15695 +SDL_GrabMode CGX_GrabWMInputI(_THIS, SDL_GrabMode mode, struct SDLBase *SDLBase)
15698 + D(bug("CGX_GrabWMInput()\n"));
15700 + SDL_Lock_EventThread();
15702 + if ( this->screen == NULL ) return(SDL_GRAB_OFF);
15703 + if ( ! SDL_Window ) return(mode); /* Will be set later on mode switch */
15706 + if (mode == SDL_GRAB_OFF)
15707 + this->hidden->GrabMouse = 0;
15708 + else /* Match the X11 driver behaviour - this always grabs at full screen. Yes - condition makes no sense. */
15710 + this->hidden->GrabMouse = 1;
15711 + CGX_WarpWMCursor(this, this->screen->w / 2, this->screen->h / 2); /* Jump into window */
15714 + SDL_Unlock_EventThread();
15718 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxwm_c.h SDL-1.2.15/src/video/cgx/SDL_cgxwm_c.h
15719 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxwm_c.h 1970-01-01 01:00:00.000000000 +0100
15720 +++ SDL-1.2.15/src/video/cgx/SDL_cgxwm_c.h 2015-05-09 15:09:59.769739506 +0200
15723 + SDL - Simple DirectMedia Layer
15724 + Copyright (C) 1997-2006 Sam Lantinga
15726 + This library is free software; you can redistribute it and/or
15727 + modify it under the terms of the GNU Lesser General Public
15728 + License as published by the Free Software Foundation; either
15729 + version 2.1 of the License, or (at your option) any later version.
15731 + This library is distributed in the hope that it will be useful,
15732 + but WITHOUT ANY WARRANTY; without even the implied warranty of
15733 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15734 + Lesser General Public License for more details.
15736 + You should have received a copy of the GNU Lesser General Public
15737 + License along with this library; if not, write to the Free Software
15738 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15741 + slouken@libsdl.org
15743 +#include "SDL_config.h"
15745 +#include "SDL_cgxvideo.h"
15747 +/* Functions to be exported */
15748 +#if !defined(PROTO_SDL_H)
15749 +extern void CGX_SetCaption(_THIS, const char *title, const char *icon);
15750 +extern void CGX_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask);
15751 +extern int CGX_IconifyWindow(_THIS);
15752 +extern int CGX_GetWMInfo(_THIS, SDL_SysWMinfo *info);
15753 +extern SDL_GrabMode CGX_GrabWMInput(_THIS, SDL_GrabMode mode);
15755 +extern void CGX_SetCaptionI(_THIS, const char *title, const char *icon, struct SDLBase *SDLBase);
15756 +extern void CGX_SetIconI(_THIS, SDL_Surface *icon, Uint8 *mask, struct SDLBase *SDLBase);
15757 +extern int CGX_IconifyWindowI(_THIS, struct SDLBase *SDLBase);
15758 +extern int CGX_GetWMInfoI(_THIS, SDL_SysWMinfo *info, struct SDLBase *SDLBase);
15759 +extern SDL_GrabMode CGX_GrabWMInputI(_THIS, SDL_GrabMode mode, struct SDLBase *SDLBase);
15761 +#define CGX_SetCaption(this, title, icon) CGX_SetCaptionI(this, title, icon, SDLBase)
15762 +#define CGX_SetIcon(this, icon, mask) CGX_SetIconI(this, icon, mask, SDLBase)
15763 +#define CGX_IconifyWindow(this) CGX_IconifyWindowI(this, SDLBase)
15764 +#define CGX_GetWMInfo(this, info) CGX_GetWMInfoI(this, info, SDLBase)
15765 +#define CGX_GrabWMInput(this, mode) CGX_GrabWMInputI(this, mode, SDLBase)
15767 diff -Naur SDL-1.2.15-orig/src/video/dummy/SDL_nullevents.c SDL-1.2.15/src/video/dummy/SDL_nullevents.c
15768 --- SDL-1.2.15-orig/src/video/dummy/SDL_nullevents.c 2015-05-09 17:47:54.283774294 +0200
15769 +++ SDL-1.2.15/src/video/dummy/SDL_nullevents.c 2015-05-09 15:09:59.769739506 +0200
15774 +#if defined (SDL_AROS_SHARED)
15775 +#define __NOLIBBASE__
15776 +#include <proto/SDL.h>
15779 #include "SDL_config.h"
15781 /* Being a null driver, there's no event stream. We just define stubs for
15782 @@ -31,12 +36,20 @@
15783 #include "SDL_nullvideo.h"
15784 #include "SDL_nullevents_c.h"
15786 +#if !defined(PROTO_SDL_H)
15787 void DUMMY_PumpEvents(_THIS)
15789 +void DUMMY_PumpEvents(_THIS, struct SDLBase *SDLBase)
15795 +#if !defined(PROTO_SDL_H)
15796 void DUMMY_InitOSKeymap(_THIS)
15798 +void DUMMY_InitOSKeymap(_THIS, struct SDLBase *SDLBase)
15803 diff -Naur SDL-1.2.15-orig/src/video/dummy/SDL_nullevents_c.h SDL-1.2.15/src/video/dummy/SDL_nullevents_c.h
15804 --- SDL-1.2.15-orig/src/video/dummy/SDL_nullevents_c.h 2015-05-09 17:47:54.283774294 +0200
15805 +++ SDL-1.2.15/src/video/dummy/SDL_nullevents_c.h 2015-05-09 15:09:59.769739506 +0200
15807 /* Variables and functions exported by SDL_sysevents.c to other parts
15808 of the native video subsystem (SDL_sysvideo.c)
15810 +#if !defined(PROTO_SDL_H)
15811 extern void DUMMY_InitOSKeymap(_THIS);
15812 extern void DUMMY_PumpEvents(_THIS);
15814 +extern void DUMMY_InitOSKeymap(_THIS, struct SDLBase *SDLBase);
15815 +extern void DUMMY_PumpEvents(_THIS, struct SDLBase *SDLBase);
15818 /* end of SDL_nullevents_c.h ... */
15820 diff -Naur SDL-1.2.15-orig/src/video/dummy/SDL_nullmouse.c SDL-1.2.15/src/video/dummy/SDL_nullmouse.c
15821 --- SDL-1.2.15-orig/src/video/dummy/SDL_nullmouse.c 2015-05-09 17:47:54.283774294 +0200
15822 +++ SDL-1.2.15/src/video/dummy/SDL_nullmouse.c 2015-05-09 15:09:59.770739504 +0200
15827 +#if defined (SDL_AROS_SHARED)
15828 +#define __NOLIBBASE__
15829 +#include <proto/SDL.h>
15832 #include "SDL_config.h"
15834 #include "SDL_mouse.h"
15835 diff -Naur SDL-1.2.15-orig/src/video/dummy/SDL_nullvideo.c SDL-1.2.15/src/video/dummy/SDL_nullvideo.c
15836 --- SDL-1.2.15-orig/src/video/dummy/SDL_nullvideo.c 2015-05-09 17:47:54.283774294 +0200
15837 +++ SDL-1.2.15/src/video/dummy/SDL_nullvideo.c 2015-05-09 15:09:59.770739504 +0200
15842 +#if defined (SDL_AROS_SHARED)
15843 +#define __NOLIBBASE__
15844 +#include <proto/SDL.h>
15847 #include "SDL_config.h"
15849 /* Dummy SDL video driver implementation; this is just enough to make an
15852 #define DUMMYVID_DRIVER_NAME "dummy"
15854 +#if !defined(PROTO_SDL_H)
15855 /* Initialization/Query functions */
15856 static int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat);
15857 static SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
15858 @@ -63,10 +69,27 @@
15861 static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
15863 +#include "SDL_intern.h"
15865 +static int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat, struct SDLBase *SDLBase);
15866 +static SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags, struct SDLBase *SDLBase);
15867 +static SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags, struct SDLBase *SDLBase);
15868 +static int DUMMY_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors, struct SDLBase *SDLBase);
15869 +static void DUMMY_VideoQuit(_THIS, struct SDLBase *SDLBase);
15870 +static int DUMMY_AllocHWSurface(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
15871 +static int DUMMY_LockHWSurface(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
15872 +static void DUMMY_UnlockHWSurface(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
15873 +static void DUMMY_FreeHWSurface(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
15874 +static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects, struct SDLBase *SDLBase);
15876 /* DUMMY driver bootstrap functions */
15878 +#if !defined(PROTO_SDL_H)
15879 static int DUMMY_Available(void)
15881 +static int DUMMY_Available(struct SDLBase *SDLBase)
15884 const char *envr = SDL_getenv("SDL_VIDEODRIVER");
15885 if ((envr) && (SDL_strcmp(envr, DUMMYVID_DRIVER_NAME) == 0)) {
15886 @@ -76,13 +99,21 @@
15890 +#if !defined(PROTO_SDL_H)
15891 static void DUMMY_DeleteDevice(SDL_VideoDevice *device)
15893 +static void DUMMY_DeleteDevice(SDL_VideoDevice *device, struct SDLBase *SDLBase)
15896 SDL_free(device->hidden);
15900 +#if !defined(PROTO_SDL_H)
15901 static SDL_VideoDevice *DUMMY_CreateDevice(int devindex)
15903 +static SDL_VideoDevice *DUMMY_CreateDevice(int devindex, struct SDLBase *SDLBase)
15906 SDL_VideoDevice *device;
15908 @@ -137,8 +168,11 @@
15909 DUMMY_Available, DUMMY_CreateDevice
15913 +#if !defined(PROTO_SDL_H)
15914 int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat)
15916 +int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat, struct SDLBase *SDLBase)
15920 fprintf(stderr, "WARNING: You are using the SDL dummy video driver!\n");
15921 @@ -153,13 +187,21 @@
15925 +#if !defined(PROTO_SDL_H)
15926 SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
15928 +SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags, struct SDLBase *SDLBase)
15931 return (SDL_Rect **) -1;
15934 +#if !defined(PROTO_SDL_H)
15935 SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current,
15936 int width, int height, int bpp, Uint32 flags)
15938 +SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags, struct SDLBase *SDLBase)
15941 if ( this->hidden->buffer ) {
15942 SDL_free( this->hidden->buffer );
15943 @@ -195,32 +237,56 @@
15946 /* We don't actually allow hardware surfaces other than the main one */
15947 +#if !defined(PROTO_SDL_H)
15948 static int DUMMY_AllocHWSurface(_THIS, SDL_Surface *surface)
15950 +static int DUMMY_AllocHWSurface(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
15955 +#if !defined(PROTO_SDL_H)
15956 static void DUMMY_FreeHWSurface(_THIS, SDL_Surface *surface)
15958 +static void DUMMY_FreeHWSurface(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
15964 /* We need to wait for vertical retrace on page flipped displays */
15965 +#if !defined(PROTO_SDL_H)
15966 static int DUMMY_LockHWSurface(_THIS, SDL_Surface *surface)
15968 +static int DUMMY_LockHWSurface(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
15974 +#if !defined(PROTO_SDL_H)
15975 static void DUMMY_UnlockHWSurface(_THIS, SDL_Surface *surface)
15977 +static void DUMMY_UnlockHWSurface(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
15983 +#if !defined(PROTO_SDL_H)
15984 static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
15986 +static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects, struct SDLBase *SDLBase)
15992 +#if !defined(PROTO_SDL_H)
15993 int DUMMY_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
15995 +int DUMMY_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors, struct SDLBase *SDLBase)
15998 /* do nothing of note. */
16000 @@ -229,7 +295,11 @@
16001 /* Note: If we are terminated, this could be called in the middle of
16002 another SDL video routine -- notably UpdateRects.
16004 +#if !defined(PROTO_SDL_H)
16005 void DUMMY_VideoQuit(_THIS)
16007 +void DUMMY_VideoQuit(_THIS, struct SDLBase *SDLBase)
16010 if (this->screen->pixels != NULL)
16012 diff -Naur SDL-1.2.15-orig/src/video/SDL_blit_0.c SDL-1.2.15/src/video/SDL_blit_0.c
16013 --- SDL-1.2.15-orig/src/video/SDL_blit_0.c 2015-05-09 17:47:54.310774223 +0200
16014 +++ SDL-1.2.15/src/video/SDL_blit_0.c 2015-05-09 15:09:59.770739504 +0200
16019 +#if defined (SDL_AROS_SHARED)
16020 +#define __NOLIBBASE__
16021 +#include <proto/SDL.h>
16024 #include "SDL_config.h"
16026 #include "SDL_video.h"
16027 @@ -440,7 +445,11 @@
16028 NULL, BlitBto1Key, BlitBto2Key, BlitBto3Key, BlitBto4Key
16031 +#if !defined(PROTO_SDL_H)
16032 SDL_loblit SDL_CalculateBlit0(SDL_Surface *surface, int blit_index)
16034 +SDL_loblit SDL_CalculateBlit0I(SDL_Surface *surface, int blit_index, struct SDLBase *SDLBase)
16039 diff -Naur SDL-1.2.15-orig/src/video/SDL_blit_1.c SDL-1.2.15/src/video/SDL_blit_1.c
16040 --- SDL-1.2.15-orig/src/video/SDL_blit_1.c 2015-05-09 17:47:54.309774226 +0200
16041 +++ SDL-1.2.15/src/video/SDL_blit_1.c 2015-05-09 15:09:59.770739504 +0200
16046 +#if defined (SDL_AROS_SHARED)
16047 +#define __NOLIBBASE__
16048 +#include <proto/SDL.h>
16051 #include "SDL_config.h"
16053 #include "SDL_video.h"
16054 @@ -491,7 +496,11 @@
16055 NULL, Blit1to1Key, Blit1to2Key, Blit1to3Key, Blit1to4Key
16058 +#if !defined(PROTO_SDL_H)
16059 SDL_loblit SDL_CalculateBlit1(SDL_Surface *surface, int blit_index)
16061 +SDL_loblit SDL_CalculateBlit1I(SDL_Surface *surface, int blit_index, struct SDLBase *SDLBase)
16065 SDL_PixelFormat *dstfmt;
16066 diff -Naur SDL-1.2.15-orig/src/video/SDL_blit_A.c SDL-1.2.15/src/video/SDL_blit_A.c
16067 --- SDL-1.2.15-orig/src/video/SDL_blit_A.c 2015-05-09 17:47:54.282774297 +0200
16068 +++ SDL-1.2.15/src/video/SDL_blit_A.c 2015-05-09 15:09:59.770739504 +0200
16073 +#if defined (SDL_AROS_SHARED)
16074 +#define __NOLIBBASE__
16075 +#include <proto/SDL.h>
16078 #include "SDL_config.h"
16080 #include "SDL_video.h"
16081 @@ -2719,8 +2724,11 @@
16086 +#if !defined(PROTO_SDL_H)
16087 SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
16089 +SDL_loblit SDL_CalculateAlphaBlitI(SDL_Surface *surface, int blit_index, struct SDLBase *SDLBase)
16092 SDL_PixelFormat *sf = surface->format;
16093 SDL_PixelFormat *df = surface->map->dst->format;
16094 diff -Naur SDL-1.2.15-orig/src/video/SDL_blit.c SDL-1.2.15/src/video/SDL_blit.c
16095 --- SDL-1.2.15-orig/src/video/SDL_blit.c 2015-05-09 17:47:54.282774297 +0200
16096 +++ SDL-1.2.15/src/video/SDL_blit.c 2015-05-09 15:09:59.771739502 +0200
16101 +#if defined (SDL_AROS_SHARED)
16102 +#define __NOLIBBASE__
16103 +#include <proto/SDL.h>
16106 #include "SDL_config.h"
16108 #include "SDL_video.h"
16113 +#if defined(PROTO_SDL_H)
16114 +#include "SDL_intern.h"
16116 +#define current_video SDLBase->current_video
16119 /* The general purpose software blit routine */
16120 static int SDL_SoftBlit(SDL_Surface *src, SDL_Rect *srcrect,
16121 SDL_Surface *dst, SDL_Rect *dstrect)
16126 +#if defined(PROTO_SDL_H)
16127 + struct Library __unused *SDLBase = src->SDLLib;
16129 /* Everything is okay at the beginning... */
16133 SDL_loblit RunBlit;
16135 /* Set up the blit information */
16137 +#if defined(PROTO_SDL_H)
16138 + info.SDLLib = SDLBase;
16140 info.s_pixels = (Uint8 *)src->pixels +
16141 (Uint16)srcrect->y*src->pitch +
16142 (Uint16)srcrect->x*src->format->BytesPerPixel;
16143 @@ -158,6 +176,10 @@
16145 int srcskip, dstskip;
16147 +#if defined(PROTO_SDL_H)
16148 + struct Library __unused *SDLBase = info->SDLLib;
16151 w = info->d_width*info->dst->BytesPerPixel;
16152 h = info->d_height;
16153 src = info->s_pixels;
16154 @@ -206,6 +228,10 @@
16156 int srcskip, dstskip;
16158 +#if defined(PROTO_SDL_H)
16159 + struct Library __unused *SDLBase = info->SDLLib;
16162 w = info->d_width*info->dst->BytesPerPixel;
16163 h = info->d_height;
16164 src = info->s_pixels;
16165 @@ -230,7 +256,11 @@
16168 /* Figure out which of many blit routines to set up on a surface */
16169 +#if !defined(PROTO_SDL_H)
16170 int SDL_CalculateBlit(SDL_Surface *surface)
16172 +int SDL_CalculateBlitI(SDL_Surface *surface, struct SDLBase *SDLBase)
16177 @@ -275,7 +305,11 @@
16178 if ( hw_blit_ok ) {
16179 SDL_VideoDevice *video = current_video;
16180 SDL_VideoDevice *this = current_video;
16181 +#if !defined(PROTO_SDL_H)
16182 video->CheckHWBlit(this, surface, surface->map->dst);
16184 + video->CheckHWBlit(this, surface, surface->map->dst, SDLBase);
16189 @@ -286,7 +320,11 @@
16190 if ( current_video->info.blit_hw_A ) {
16191 SDL_VideoDevice *video = current_video;
16192 SDL_VideoDevice *this = current_video;
16193 +#if !defined(PROTO_SDL_H)
16194 video->CheckHWBlit(this, surface, surface->map->dst);
16196 + video->CheckHWBlit(this, surface, surface->map->dst, SDLBase);
16201 diff -Naur SDL-1.2.15-orig/src/video/SDL_blit.h SDL-1.2.15/src/video/SDL_blit.h
16202 --- SDL-1.2.15-orig/src/video/SDL_blit.h 2015-05-09 17:47:54.281774300 +0200
16203 +++ SDL-1.2.15/src/video/SDL_blit.h 2015-05-09 15:09:59.771739502 +0200
16205 SDL_PixelFormat *src;
16207 SDL_PixelFormat *dst;
16208 +#if defined(__AROS__)
16209 + struct Library *SDLLib;
16213 /* The type definition for the low level blit functions */
16214 @@ -67,14 +70,28 @@
16218 +#if !defined(PROTO_SDL_H)
16219 /* Functions found in SDL_blit.c */
16220 extern int SDL_CalculateBlit(SDL_Surface *surface);
16222 /* Functions found in SDL_blit_{0,1,N,A}.c */
16223 extern SDL_loblit SDL_CalculateBlit0(SDL_Surface *surface, int complex);
16224 extern SDL_loblit SDL_CalculateBlit1(SDL_Surface *surface, int complex);
16225 extern SDL_loblit SDL_CalculateBlitN(SDL_Surface *surface, int complex);
16226 extern SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int complex);
16228 +#include "SDL_intern.h"
16230 +extern int SDL_CalculateBlitI(SDL_Surface *surface, struct SDLBase *SDLBase);
16231 +extern SDL_loblit SDL_CalculateBlit0I(SDL_Surface *surface, int complex, struct SDLBase *SDLBase);
16232 +extern SDL_loblit SDL_CalculateBlit1I(SDL_Surface *surface, int complex, struct SDLBase *SDLBase);
16233 +extern SDL_loblit SDL_CalculateBlitNI(SDL_Surface *surface, int complex, struct SDLBase *SDLBase);
16234 +extern SDL_loblit SDL_CalculateAlphaBlitI(SDL_Surface *surface, int complex, struct SDLBase *SDLBase);
16235 +#define SDL_CalculateBlit(surface) SDL_CalculateBlitI(surface, SDLBase)
16236 +#define SDL_CalculateBlit0(surface, complex) SDL_CalculateBlit0I(surface, complex, SDLBase)
16237 +#define SDL_CalculateBlit1(surface, complex) SDL_CalculateBlit1I(surface, complex, SDLBase)
16238 +#define SDL_CalculateBlitN(surface, complex) SDL_CalculateBlitNI(surface, complex, SDLBase)
16239 +#define SDL_CalculateAlphaBlit(surface, complex) SDL_CalculateAlphaBlitI(surface, complex, SDLBase)
16243 * Useful macros for blitting routines
16244 diff -Naur SDL-1.2.15-orig/src/video/SDL_blit_N.c SDL-1.2.15/src/video/SDL_blit_N.c
16245 --- SDL-1.2.15-orig/src/video/SDL_blit_N.c 2015-05-09 17:47:54.284774292 +0200
16246 +++ SDL-1.2.15/src/video/SDL_blit_N.c 2015-05-09 15:09:59.771739502 +0200
16251 +#if defined (SDL_AROS_SHARED)
16252 +#define __NOLIBBASE__
16253 +#include <proto/SDL.h>
16256 #include "SDL_config.h"
16258 #include "SDL_video.h"
16259 @@ -2371,7 +2376,11 @@
16260 /* Mask matches table, or table entry is zero */
16261 #define MASKOK(x, y) (((x) == (y)) || ((y) == 0x00000000))
16263 +#if !defined(PROTO_SDL_H)
16264 SDL_loblit SDL_CalculateBlitN(SDL_Surface *surface, int blit_index)
16266 +SDL_loblit SDL_CalculateBlitNI(SDL_Surface *surface, int blit_index, struct SDLBase *SDLBase)
16269 struct private_swaccel *sdata;
16270 SDL_PixelFormat *srcfmt;
16271 diff -Naur SDL-1.2.15-orig/src/video/SDL_bmp.c SDL-1.2.15/src/video/SDL_bmp.c
16272 --- SDL-1.2.15-orig/src/video/SDL_bmp.c 2015-05-09 17:47:54.282774297 +0200
16273 +++ SDL-1.2.15/src/video/SDL_bmp.c 2015-05-09 15:09:59.772739500 +0200
16278 +#if defined (SDL_AROS_SHARED)
16279 +#define __NOLIBBASE__
16280 +#include <proto/SDL.h>
16283 #include "SDL_config.h"
16287 #define BI_BITFIELDS 3
16292 +#if !defined(PROTO_SDL_H)
16293 SDL_Surface * SDL_LoadBMP_RW (SDL_RWops *src, int freesrc)
16296 +AROS_LH2(SDL_Surface *, SDL_LoadBMP_RW,
16297 + AROS_LHA(SDL_RWops *, src, A0),
16298 + AROS_LHA(int, freesrc, D0),
16299 + struct SDLBase *, SDLBase, 22, SDL)
16301 + AROS_LIBFUNC_INIT
16303 SDL_bool was_error;
16304 long fp_offset = 0;
16306 @@ -355,10 +370,23 @@
16310 +#if defined(PROTO_SDL_H)
16311 + AROS_LIBFUNC_EXIT
16315 +#if !defined(PROTO_SDL_H)
16316 int SDL_SaveBMP_RW (SDL_Surface *saveme, SDL_RWops *dst, int freedst)
16319 +AROS_LH3(int, SDL_SaveBMP_RW,
16320 + AROS_LHA(SDL_Surface *, saveme, A0),
16321 + AROS_LHA(SDL_RWops *, dst, A1),
16322 + AROS_LHA(int, freedst, D0),
16323 + struct SDLBase *, SDLBase, 52, SDL)
16325 + AROS_LIBFUNC_INIT
16329 SDL_Surface *surface;
16330 @@ -546,4 +574,7 @@
16333 return((SDL_strcmp(SDL_GetError(), "") == 0) ? 0 : -1);
16334 +#if defined(PROTO_SDL_H)
16335 + AROS_LIBFUNC_EXIT
16338 diff -Naur SDL-1.2.15-orig/src/video/SDL_cursor.c SDL-1.2.15/src/video/SDL_cursor.c
16339 --- SDL-1.2.15-orig/src/video/SDL_cursor.c 2015-05-09 17:47:54.309774226 +0200
16340 +++ SDL-1.2.15/src/video/SDL_cursor.c 2015-05-09 15:09:59.772739500 +0200
16345 +#if defined (SDL_AROS_SHARED)
16346 +#define __NOLIBBASE__
16347 +#include <proto/SDL.h>
16350 #include "SDL_config.h"
16352 /* General cursor handling code for SDL */
16353 @@ -35,13 +40,30 @@
16354 #include "../events/SDL_events_c.h"
16356 /* These are static for our cursor handling code */
16357 +#if !defined(PROTO_SDL_H)
16358 volatile int SDL_cursorstate = CURSOR_VISIBLE;
16359 SDL_Cursor *SDL_cursor = NULL;
16360 static SDL_Cursor *SDL_defcursor = NULL;
16361 SDL_mutex *SDL_cursorlock = NULL;
16363 +#include "SDL_intern.h"
16365 +#define SDL_cursorstate SDLBase->SDL_cursorstate
16366 +#define SDL_cursor SDLBase->SDL_cursor
16367 +#define SDL_defcursor SDLBase->SDL_defcursor
16368 +#define SDL_cursorlock SDLBase->SDL_cursorlock
16369 +#define palette_changed SDLBase->palette_changed
16370 +#define pixels8 SDLBase->pixels8
16372 +#define current_video SDLBase->current_video
16375 /* Public functions */
16376 +#if !defined(PROTO_SDL_H)
16377 void SDL_CursorQuit(void)
16379 +void SDL_CursorQuitI(struct SDLBase *SDLBase)
16382 if ( SDL_cursor != NULL ) {
16383 SDL_Cursor *cursor;
16385 SDL_cursorlock = NULL;
16388 +#if !defined(PROTO_SDL_H)
16389 int SDL_CursorInit(Uint32 multithreaded)
16391 +int SDL_CursorInitI(Uint32 multithreaded, struct SDLBase *SDLBase)
16394 /* We don't have mouse focus, and the cursor isn't drawn yet */
16396 @@ -105,9 +131,22 @@
16399 /* Software cursor drawing support */
16400 +#if !defined(PROTO_SDL_H)
16401 SDL_Cursor * SDL_CreateCursor (Uint8 *data, Uint8 *mask,
16402 int w, int h, int hot_x, int hot_y)
16405 +AROS_LH6(SDL_Cursor *, SDL_CreateCursor,
16406 + AROS_LHA(Uint8 *, data, A0),
16407 + AROS_LHA(Uint8 *, mask, A1),
16408 + AROS_LHA(int, w, D0),
16409 + AROS_LHA(int, h, D1),
16410 + AROS_LHA(int, hot_x, D2),
16411 + AROS_LHA(int, hot_y, D3),
16412 + struct SDLBase *, SDLBase, 116, SDL)
16414 + AROS_LIBFUNC_INIT
16416 SDL_VideoDevice *video = current_video;
16419 @@ -153,20 +192,36 @@
16421 /* If the window manager gives us a good cursor, we're done! */
16422 if ( video->CreateWMCursor ) {
16423 +#if !defined(PROTO_SDL_H)
16424 cursor->wm_cursor = video->CreateWMCursor(video, data, mask,
16425 w, h, hot_x, hot_y);
16427 + cursor->wm_cursor = video->CreateWMCursor(video, data, mask,
16428 + w, h, hot_x, hot_y, SDLBase);
16431 cursor->wm_cursor = NULL;
16434 +#if defined(PROTO_SDL_H)
16435 + AROS_LIBFUNC_EXIT
16439 /* SDL_SetCursor(NULL) can be used to force the cursor redraw,
16440 if this is desired for any reason. This is used when setting
16441 the video mode and when the SDL window gains the mouse focus.
16443 +#if !defined(PROTO_SDL_H)
16444 void SDL_SetCursor (SDL_Cursor *cursor)
16447 +AROS_LH1(void, SDL_SetCursor,
16448 + AROS_LHA(SDL_Cursor *, cursor, A0),
16449 + struct SDLBase *, SDLBase, 117, SDL)
16451 + AROS_LIBFUNC_INIT
16453 SDL_VideoDevice *video = current_video;
16454 SDL_VideoDevice *this = current_video;
16456 @@ -189,7 +244,11 @@
16457 showing the new one. (But don't erase NULL cursor)
16459 if ( SDL_cursor && video->ShowWMCursor ) {
16460 +#if !defined(PROTO_SDL_H)
16461 video->ShowWMCursor(this, NULL);
16463 + video->ShowWMCursor(this, NULL, SDLBase);
16467 SDL_cursor = cursor;
16468 @@ -200,14 +259,22 @@
16469 /* Use window manager cursor if possible */
16470 int show_wm_cursor = 0;
16471 if ( SDL_cursor->wm_cursor && video->ShowWMCursor ) {
16472 +#if !defined(PROTO_SDL_H)
16473 show_wm_cursor = video->ShowWMCursor(this, SDL_cursor->wm_cursor);
16475 + show_wm_cursor = video->ShowWMCursor(this, SDL_cursor->wm_cursor, SDLBase);
16478 if ( show_wm_cursor ) {
16479 SDL_cursorstate &= ~CURSOR_USINGSW;
16481 SDL_cursorstate |= CURSOR_USINGSW;
16482 if ( video->ShowWMCursor ) {
16483 +#if !defined(PROTO_SDL_H)
16484 video->ShowWMCursor(this, NULL);
16486 + video->ShowWMCursor(this, NULL, SDLBase);
16490 SDL_GetMouseState(&x, &y);
16491 @@ -223,21 +290,46 @@
16494 if ( video->ShowWMCursor ) {
16495 +#if !defined(PROTO_SDL_H)
16496 video->ShowWMCursor(this, NULL);
16498 + video->ShowWMCursor(this, NULL, SDLBase);
16504 SDL_UnlockCursor();
16505 +#if defined(PROTO_SDL_H)
16506 + AROS_LIBFUNC_EXIT
16510 +#if !defined(PROTO_SDL_H)
16511 SDL_Cursor * SDL_GetCursor (void)
16514 +AROS_LH0(SDL_Cursor *, SDL_GetCursor,
16515 + struct SDLBase *, SDLBase, 118, SDL)
16517 + AROS_LIBFUNC_INIT
16519 return(SDL_cursor);
16520 +#if defined(PROTO_SDL_H)
16521 + AROS_LIBFUNC_EXIT
16525 +#if !defined(PROTO_SDL_H)
16526 void SDL_FreeCursor (SDL_Cursor *cursor)
16529 +AROS_LH1(void, SDL_FreeCursor,
16530 + AROS_LHA(SDL_Cursor *, cursor, A0),
16531 + struct SDLBase *, SDLBase, 119, SDL)
16533 + AROS_LIBFUNC_INIT
16536 if ( cursor == SDL_cursor ) {
16537 SDL_SetCursor(SDL_defcursor);
16538 @@ -254,16 +346,31 @@
16540 if ( video && cursor->wm_cursor ) {
16541 if ( video->FreeWMCursor ) {
16542 +#if !defined(PROTO_SDL_H)
16543 video->FreeWMCursor(this, cursor->wm_cursor);
16545 + video->FreeWMCursor(this, cursor->wm_cursor, SDLBase);
16552 +#if defined(PROTO_SDL_H)
16553 + AROS_LIBFUNC_EXIT
16557 +#if !defined(PROTO_SDL_H)
16558 int SDL_ShowCursor (int toggle)
16561 +AROS_LH1(int, SDL_ShowCursor,
16562 + AROS_LHA(int, toggle, D0),
16563 + struct SDLBase *, SDLBase, 120, SDL)
16565 + AROS_LIBFUNC_INIT
16569 showing = (SDL_cursorstate & CURSOR_VISIBLE);
16570 @@ -281,17 +388,33 @@
16572 SDL_SetCursor(NULL);
16573 if ( video && video->CheckMouseMode ) {
16574 +#if !defined(PROTO_SDL_H)
16575 video->CheckMouseMode(this);
16577 + video->CheckMouseMode(this, SDLBase);
16582 /* Query current state */ ;
16584 return(showing ? 1 : 0);
16585 +#if defined(PROTO_SDL_H)
16586 + AROS_LIBFUNC_EXIT
16590 +#if !defined(PROTO_SDL_H)
16591 void SDL_WarpMouse (Uint16 x, Uint16 y)
16594 +AROS_LH2(void, SDL_WarpMouse,
16595 + AROS_LHA(Uint16, x, D0),
16596 + AROS_LHA(Uint16, y, D1),
16597 + struct SDLBase *, SDLBase, 115, SDL)
16599 + AROS_LIBFUNC_INIT
16601 SDL_VideoDevice *video = current_video;
16602 SDL_VideoDevice *this = current_video;
16604 @@ -312,13 +435,24 @@
16606 /* This generates a mouse motion event */
16607 if ( video->WarpWMCursor ) {
16608 +#if !defined(PROTO_SDL_H)
16609 video->WarpWMCursor(this, x, y);
16611 + video->WarpWMCursor(this, x, y, SDLBase);
16614 SDL_PrivateMouseMotion(0, 0, x, y);
16616 +#if defined(PROTO_SDL_H)
16617 + AROS_LIBFUNC_EXIT
16621 +#if !defined(PROTO_SDL_H)
16622 void SDL_MoveCursor(int x, int y)
16624 +void SDL_MoveCursorI(int x, int y, struct SDLBase *SDLBase)
16627 SDL_VideoDevice *video = current_video;
16629 @@ -332,20 +466,32 @@
16630 SDL_DrawCursor(SDL_VideoSurface);
16631 SDL_UnlockCursor();
16632 } else if ( video->MoveWMCursor ) {
16633 +#if !defined(PROTO_SDL_H)
16634 video->MoveWMCursor(video, x, y);
16636 + video->MoveWMCursor(video, x, y, SDLBase);
16641 +#if !defined(PROTO_SDL_H)
16642 /* Keep track of the current cursor colors */
16643 static int palette_changed = 1;
16644 static Uint8 pixels8[2];
16646 void SDL_CursorPaletteChanged(void)
16648 +void SDL_CursorPaletteChangedI(struct SDLBase *SDLBase)
16651 palette_changed = 1;
16654 +#if !defined(PROTO_SDL_H)
16655 void SDL_MouseRect(SDL_Rect *area)
16657 +void SDL_MouseRectI(SDL_Rect *area, struct SDLBase *SDLBase)
16662 @@ -368,7 +514,12 @@
16666 +#if !defined(PROTO_SDL_H)
16667 static void SDL_DrawCursorFast(SDL_Surface *screen, SDL_Rect *area)
16669 +#define SDL_DrawCursorFast(screen, area) SDL_DrawCursorFastI(screen, area, SDLBase)
16670 +static void SDL_DrawCursorFastI(SDL_Surface *screen, SDL_Rect *area, struct SDLBase *SDLBase)
16673 const Uint32 pixels[2] = { 0xFFFFFFFF, 0x00000000 };
16675 @@ -494,7 +645,12 @@
16679 +#if !defined(PROTO_SDL_H)
16680 static void SDL_DrawCursorSlow(SDL_Surface *screen, SDL_Rect *area)
16682 +#define SDL_DrawCursorSlow(screen, area) SDL_DrawCursorSlowI(screen, area, SDLBase)
16683 +static void SDL_DrawCursorSlowI(SDL_Surface *screen, SDL_Rect *area, struct SDLBase *SDLBase)
16686 const Uint32 pixels[2] = { 0xFFFFFF, 0x000000 };
16688 @@ -563,7 +719,12 @@
16689 This is only necessary when blitting from a shadow surface of a different
16690 pixel format than the video surface, and using a software rendered cursor.
16692 +#if !defined(PROTO_SDL_H)
16693 static void SDL_ConvertCursorSave(SDL_Surface *screen, int w, int h)
16695 +#define SDL_ConvertCursorSave(screen, w, h) SDL_ConvertCursorSaveI(screen, w, h, SDLBase)
16696 +static void SDL_ConvertCursorSaveI(SDL_Surface *screen, int w, int h, struct SDLBase *SDLBase)
16700 SDL_loblit RunBlit;
16701 @@ -592,7 +753,11 @@
16705 +#if !defined(PROTO_SDL_H)
16706 void SDL_DrawCursorNoLock(SDL_Surface *screen)
16708 +void SDL_DrawCursorNoLockI(SDL_Surface *screen, struct SDLBase *SDLBase)
16713 @@ -637,7 +802,11 @@
16717 +#if !defined(PROTO_SDL_H)
16718 void SDL_DrawCursor(SDL_Surface *screen)
16720 +void SDL_DrawCursorI(SDL_Surface *screen, struct SDLBase *SDLBase)
16723 /* Lock the screen if necessary */
16724 if ( screen == NULL ) {
16725 @@ -665,12 +834,20 @@
16727 /* This can be called before a video mode is set */
16728 if ( video->UpdateRects ) {
16729 +#if !defined(PROTO_SDL_H)
16730 video->UpdateRects(this, 1, &area);
16732 + video->UpdateRects(this, 1, &area, SDLBase);
16738 +#if !defined(PROTO_SDL_H)
16739 void SDL_EraseCursorNoLock(SDL_Surface *screen)
16741 +void SDL_EraseCursorNoLockI(SDL_Surface *screen, struct SDLBase *SDLBase)
16746 @@ -711,7 +888,11 @@
16750 +#if !defined(PROTO_SDL_H)
16751 void SDL_EraseCursor(SDL_Surface *screen)
16753 +void SDL_EraseCursorI(SDL_Surface *screen, struct SDLBase *SDLBase)
16756 /* Lock the screen if necessary */
16757 if ( screen == NULL ) {
16758 @@ -737,7 +918,11 @@
16760 SDL_MouseRect(&area);
16761 if ( video->UpdateRects ) {
16762 +#if !defined(PROTO_SDL_H)
16763 video->UpdateRects(this, 1, &area);
16765 + video->UpdateRects(this, 1, &area, SDLBase);
16770 @@ -745,7 +930,11 @@
16771 /* Reset the cursor on video mode change
16772 FIXME: Keep track of all cursors, and reset them all.
16774 +#if !defined(PROTO_SDL_H)
16775 void SDL_ResetCursor(void)
16777 +void SDL_ResetCursorI(struct SDLBase *SDLBase)
16782 diff -Naur SDL-1.2.15-orig/src/video/SDL_cursor_c.h SDL-1.2.15/src/video/SDL_cursor_c.h
16783 --- SDL-1.2.15-orig/src/video/SDL_cursor_c.h 2015-05-09 17:47:54.283774294 +0200
16784 +++ SDL-1.2.15/src/video/SDL_cursor_c.h 2015-05-09 15:09:59.772739500 +0200
16786 /* Useful variables and functions from SDL_cursor.c */
16787 #include "SDL_mouse.h"
16789 +#if !defined(PROTO_SDL_H)
16790 extern int SDL_CursorInit(Uint32 flags);
16791 extern void SDL_CursorPaletteChanged(void);
16792 extern void SDL_DrawCursor(SDL_Surface *screen);
16793 @@ -34,13 +35,42 @@
16794 extern void SDL_ResetCursor(void);
16795 extern void SDL_MoveCursor(int x, int y);
16796 extern void SDL_CursorQuit(void);
16798 +#include "SDL_intern.h"
16800 +extern int SDL_CursorInitI(Uint32 flags, struct SDLBase *SDLBase);
16801 +extern void SDL_CursorPaletteChangedI(struct SDLBase *SDLBase);
16802 +extern void SDL_DrawCursorI(SDL_Surface *screen, struct SDLBase *SDLBase);
16803 +extern void SDL_DrawCursorNoLockI(SDL_Surface *screen, struct SDLBase *SDLBase);
16804 +extern void SDL_EraseCursorI(SDL_Surface *screen, struct SDLBase *SDLBase);
16805 +extern void SDL_EraseCursorNoLockI(SDL_Surface *screen, struct SDLBase *SDLBase);
16806 +extern void SDL_UpdateCursorI(SDL_Surface *screen, struct SDLBase *SDLBase);
16807 +extern void SDL_ResetCursorI(struct SDLBase *SDLBase);
16808 +extern void SDL_MoveCursorI(int x, int y, struct SDLBase *SDLBase);
16809 +extern void SDL_CursorQuitI(struct SDLBase *SDLBase);
16811 +#define SDL_CursorInit(flags) SDL_CursorInitI(flags, SDLBase)
16812 +#define SDL_CursorPaletteChanged() SDL_CursorPaletteChangedI(SDLBase)
16813 +#define SDL_DrawCursor(screen) SDL_DrawCursorI(screen, SDLBase)
16814 +#define SDL_DrawCursorNoLock(screen) SDL_DrawCursorNoLockI(screen, SDLBase)
16815 +#define SDL_EraseCursor(screen) SDL_EraseCursorI(screen, SDLBase)
16816 +#define SDL_EraseCursorNoLock(screen) SDL_EraseCursorNoLockI(screen, SDLBase)
16817 +#define SDL_UpdateCursor(screen) SDL_UpdateCursorI(screen, SDLBase)
16818 +#define SDL_ResetCursor() SDL_ResetCursorI(SDLBase)
16819 +#define SDL_MoveCursor(x, y) SDL_MoveCursorI(x, y, SDLBase)
16820 +#define SDL_CursorQuit() SDL_CursorQuitI(SDLBase)
16823 #define INLINE_MOUSELOCK
16824 #ifdef INLINE_MOUSELOCK
16825 /* Inline (macro) versions of the mouse lock functions */
16826 #include "SDL_mutex.h"
16828 +#if !defined(PROTO_SDL_H)
16829 extern SDL_mutex *SDL_cursorlock;
16831 +#define SDL_cursorlock SDLBase->SDL_cursorlock
16834 #define SDL_LockCursor() \
16836 @@ -59,15 +89,22 @@
16837 extern void SDL_UnlockCursor(void);
16838 #endif /* INLINE_MOUSELOCK */
16840 +#if !defined(PROTO_SDL_H)
16841 /* Only for low-level mouse cursor drawing */
16842 extern SDL_Cursor *SDL_cursor;
16843 extern void SDL_MouseRect(SDL_Rect *area);
16844 +extern volatile int SDL_cursorstate;
16846 -/* State definitions for the SDL cursor */
16847 #define CURSOR_VISIBLE 0x01
16849 +extern void SDL_MouseRectI(SDL_Rect *area, struct SDLBase *SDLBase);
16850 +#define SDL_MouseRect(area) SDL_MouseRectI(area, SDLBase)
16851 +#define SDL_cursorstate SDLBase->SDL_cursorstate
16854 +/* State definitions for the SDL cursor */
16855 #define CURSOR_USINGSW 0x10
16856 #define SHOULD_DRAWCURSOR(X) \
16857 (((X)&(CURSOR_VISIBLE|CURSOR_USINGSW)) == \
16858 (CURSOR_VISIBLE|CURSOR_USINGSW))
16860 -extern volatile int SDL_cursorstate;
16861 diff -Naur SDL-1.2.15-orig/src/video/SDL_gamma.c SDL-1.2.15/src/video/SDL_gamma.c
16862 --- SDL-1.2.15-orig/src/video/SDL_gamma.c 2015-05-09 17:47:54.309774226 +0200
16863 +++ SDL-1.2.15/src/video/SDL_gamma.c 2015-05-09 15:09:59.772739500 +0200
16868 +#if defined (SDL_AROS_SHARED)
16869 +#define __NOLIBBASE__
16870 +#include <proto/SDL.h>
16873 #include "SDL_config.h"
16875 /* Gamma correction support */
16878 #include "SDL_sysvideo.h"
16880 +#if defined(PROTO_SDL_H)
16881 +#include "SDL_intern.h"
16883 +#define current_video SDLBase->current_video
16886 static void CalculateGammaRamp(float gamma, Uint16 *ramp)
16888 @@ -90,8 +100,18 @@
16892 +#if !defined(PROTO_SDL_H)
16893 int SDL_SetGamma(float red, float green, float blue)
16896 +AROS_LH3(int, SDL_SetGamma,
16897 + AROS_LHA(float, red, D0),
16898 + AROS_LHA(float, green, D1),
16899 + AROS_LHA(float, blue, D2),
16900 + struct SDLBase *, SDLBase, 41, SDL)
16902 + AROS_LIBFUNC_INIT
16905 SDL_VideoDevice *video = current_video;
16906 SDL_VideoDevice *this = current_video;
16907 @@ -108,15 +128,26 @@
16909 if ( (succeeded < 0) && video->SetGamma ) {
16911 +#if !defined(PROTO_SDL_H)
16912 succeeded = video->SetGamma(this, red, green, blue);
16914 + succeeded = video->SetGamma(this, red, green, blue, SDLBase);
16918 +#if defined(PROTO_SDL_H)
16919 + AROS_LIBFUNC_EXIT
16923 /* Calculating the gamma by integrating the gamma ramps isn't exact,
16924 so this function isn't officially supported.
16926 +#if !defined(PROTO_SDL_H)
16927 int SDL_GetGamma(float *red, float *green, float *blue)
16929 +int SDL_GetGamma(float *red, float *green, float *blue, struct SDLBase *SDLBase)
16933 SDL_VideoDevice *video = current_video;
16934 @@ -136,13 +167,27 @@
16936 if ( (succeeded < 0) && video->GetGamma ) {
16938 +#if !defined(PROTO_SDL_H)
16939 succeeded = video->GetGamma(this, red, green, blue);
16941 + succeeded = video->GetGamma(this, red, green, blue, SDLBase);
16947 +#if !defined(PROTO_SDL_H)
16948 int SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue)
16951 +AROS_LH3(int, SDL_SetGammaRamp,
16952 + AROS_LHA(const Uint16 *, red, A0),
16953 + AROS_LHA(const Uint16 *, green, A0),
16954 + AROS_LHA(const Uint16 *, blue, A0),
16955 + struct SDLBase *, SDLBase, 42, SDL)
16957 + AROS_LIBFUNC_INIT
16960 SDL_VideoDevice *video = current_video;
16961 SDL_VideoDevice *this = current_video;
16962 @@ -186,15 +231,32 @@
16963 /* Try to set the gamma ramp in the driver */
16965 if ( video->SetGammaRamp ) {
16966 +#if !defined(PROTO_SDL_H)
16967 succeeded = video->SetGammaRamp(this, video->gamma);
16969 + succeeded = video->SetGammaRamp(this, video->gamma, SDLBase);
16972 SDL_SetError("Gamma ramp manipulation not supported");
16975 +#if defined(PROTO_SDL_H)
16976 + AROS_LIBFUNC_EXIT
16980 +#if !defined(PROTO_SDL_H)
16981 int SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue)
16984 +AROS_LH3(int, SDL_GetGammaRamp,
16985 + AROS_LHA(Uint16 *, red, A0),
16986 + AROS_LHA(Uint16 *, green, A0),
16987 + AROS_LHA(Uint16 *, blue, A0),
16988 + struct SDLBase *, SDLBase, 43, SDL)
16990 + AROS_LIBFUNC_INIT
16992 SDL_VideoDevice *video = current_video;
16993 SDL_VideoDevice *this = current_video;
16995 @@ -207,7 +269,11 @@
16997 if ( video->GetGammaRamp ) {
16998 /* Get the real hardware gamma */
16999 +#if !defined(PROTO_SDL_H)
17000 video->GetGammaRamp(this, video->gamma);
17002 + video->GetGammaRamp(this, video->gamma, SDLBase);
17005 /* Assume an identity gamma */
17007 @@ -230,4 +296,7 @@
17008 SDL_memcpy(blue, &video->gamma[2*256], 256*sizeof(*blue));
17011 +#if defined(PROTO_SDL_H)
17012 + AROS_LIBFUNC_EXIT
17015 diff -Naur SDL-1.2.15-orig/src/video/SDL_pixels.c SDL-1.2.15/src/video/SDL_pixels.c
17016 --- SDL-1.2.15-orig/src/video/SDL_pixels.c 2015-05-09 17:47:54.281774300 +0200
17017 +++ SDL-1.2.15/src/video/SDL_pixels.c 2015-05-09 15:09:59.773739499 +0200
17022 +#if defined (SDL_AROS_SHARED)
17023 +#define __NOLIBBASE__
17024 +#include <proto/SDL.h>
17027 #include "SDL_config.h"
17029 /* General (mostly internal) pixel/color manipulation routines for SDL */
17032 * Allocate a pixel format structure and fill it according to the given info.
17034 +#if !defined(PROTO_SDL_H)
17035 SDL_PixelFormat *SDL_AllocFormat(int bpp,
17036 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
17038 +SDL_PixelFormat *SDL_AllocFormatI(int bpp,
17039 + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask, struct SDLBase *SDLBase)
17042 SDL_PixelFormat *format;
17044 @@ -221,8 +231,13 @@
17048 +#if !defined(PROTO_SDL_H)
17049 SDL_PixelFormat *SDL_ReallocFormat(SDL_Surface *surface, int bpp,
17050 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
17052 +SDL_PixelFormat *SDL_ReallocFormatI(SDL_Surface *surface, int bpp,
17053 + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask, struct SDLBase *SDLBase)
17056 if ( surface->format ) {
17057 SDL_FreeFormat(surface->format);
17058 @@ -337,10 +352,21 @@
17061 /* Find the opaque pixel value corresponding to an RGB triple */
17062 +#if !defined(PROTO_SDL_H)
17064 (const SDL_PixelFormat * const format,
17065 const Uint8 r, const Uint8 g, const Uint8 b)
17068 +AROS_LH4(Uint32, SDL_MapRGB,
17069 + AROS_LHA(const SDL_PixelFormat * const, format, A0),
17070 + AROS_LHA(const Uint8, r, D0),
17071 + AROS_LHA(const Uint8, g, D1),
17072 + AROS_LHA(const Uint8, b, D2),
17073 + struct SDLBase *, SDLBase, 32, SDL)
17075 + AROS_LIBFUNC_INIT
17077 if ( format->palette == NULL ) {
17078 return (r >> format->Rloss) << format->Rshift
17079 | (g >> format->Gloss) << format->Gshift
17080 @@ -349,13 +375,28 @@
17082 return SDL_FindColor(format->palette, r, g, b);
17084 +#if defined(PROTO_SDL_H)
17085 + AROS_LIBFUNC_EXIT
17089 /* Find the pixel value corresponding to an RGBA quadruple */
17090 +#if !defined(PROTO_SDL_H)
17092 (const SDL_PixelFormat * const format,
17093 const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a)
17096 +AROS_LH5(Uint32, SDL_MapRGBA,
17097 + AROS_LHA(const SDL_PixelFormat * const, format, A0),
17098 + AROS_LHA(const Uint8, r, D0),
17099 + AROS_LHA(const Uint8, g, D1),
17100 + AROS_LHA(const Uint8, b, D2),
17101 + AROS_LHA(const Uint8, a, D3),
17102 + struct SDLBase *, SDLBase, 33, SDL)
17104 + AROS_LIBFUNC_INIT
17106 if ( format->palette == NULL ) {
17107 return (r >> format->Rloss) << format->Rshift
17108 | (g >> format->Gloss) << format->Gshift
17109 @@ -364,11 +405,27 @@
17111 return SDL_FindColor(format->palette, r, g, b);
17113 +#if defined(PROTO_SDL_H)
17114 + AROS_LIBFUNC_EXIT
17118 +#if !defined(PROTO_SDL_H)
17119 void SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat * const fmt,
17120 Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
17123 +AROS_LH6(void, SDL_GetRGBA,
17124 + AROS_LHA(Uint32, pixel, D0),
17125 + AROS_LHA(const SDL_PixelFormat * const, fmt, A0),
17126 + AROS_LHA(Uint8 *, r, A1),
17127 + AROS_LHA(Uint8 *, g, A2),
17128 + AROS_LHA(Uint8 *, b, A3),
17129 + AROS_LHA(Uint8 *, a, A4),
17130 + struct SDLBase *, SDLBase, 47, SDL)
17132 + AROS_LIBFUNC_INIT
17134 if ( fmt->palette == NULL ) {
17136 * This makes sure that the result is mapped to the
17137 @@ -398,11 +455,26 @@
17138 *b = fmt->palette->colors[pixel].b;
17139 *a = SDL_ALPHA_OPAQUE;
17141 +#if defined(PROTO_SDL_H)
17142 + AROS_LIBFUNC_EXIT
17146 +#if !defined(PROTO_SDL_H)
17147 void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat * const fmt,
17148 Uint8 *r,Uint8 *g,Uint8 *b)
17151 +AROS_LH5(void, SDL_GetRGB,
17152 + AROS_LHA(Uint32, pixel, D0),
17153 + AROS_LHA(const SDL_PixelFormat * const, fmt, A0),
17154 + AROS_LHA(Uint8 *, r, A1),
17155 + AROS_LHA(Uint8 *, g, A2),
17156 + AROS_LHA(Uint8 *, b, A3),
17157 + struct SDLBase *, SDLBase, 46, SDL)
17159 + AROS_LIBFUNC_INIT
17161 if ( fmt->palette == NULL ) {
17162 /* the note for SDL_GetRGBA above applies here too */
17164 @@ -417,6 +489,9 @@
17165 *g = fmt->palette->colors[pixel].g;
17166 *b = fmt->palette->colors[pixel].b;
17168 +#if defined(PROTO_SDL_H)
17169 + AROS_LIBFUNC_EXIT
17173 /* Apply gamma to a set of colors - this is easy. :) */
17174 @@ -433,7 +508,12 @@
17177 /* Map from Palette to Palette */
17178 +#if !defined(PROTO_SDL_H)
17179 static Uint8 *Map1to1(SDL_Palette *src, SDL_Palette *dst, int *identical)
17181 +#define Map1to1(src, dst, identical) Map1to1I(src, dst, identical, SDLBase)
17182 +static Uint8 *Map1to1I(SDL_Palette *src, SDL_Palette *dst, int *identical, struct SDLBase *SDLBase)
17187 @@ -461,7 +541,12 @@
17190 /* Map from Palette to BitField */
17191 +#if !defined(PROTO_SDL_H)
17192 static Uint8 *Map1toN(SDL_PixelFormat *src, SDL_PixelFormat *dst)
17194 +#define Map1toN(src, dst) Map1toNI(src, dst, SDLBase)
17195 +static Uint8 *Map1toNI(SDL_PixelFormat *src, SDL_PixelFormat *dst, struct SDLBase *SDLBase)
17200 @@ -486,7 +571,12 @@
17203 /* Map from BitField to Dithered-Palette to Palette */
17204 +#if !defined(PROTO_SDL_H)
17205 static Uint8 *MapNto1(SDL_PixelFormat *src, SDL_PixelFormat *dst, int *identical)
17207 +#define MapNto1(src, dst, identical) MapNto1I(src, dst, identical, SDLBase)
17208 +static Uint8 *MapNto1I(SDL_PixelFormat *src, SDL_PixelFormat *dst, int *identical, struct SDLBase *SDLBase)
17211 /* Generate a 256 color dither palette */
17212 SDL_Palette dithered;
17213 @@ -503,7 +593,11 @@
17214 return(Map1to1(&dithered, pal, identical));
17217 +#if !defined(PROTO_SDL_H)
17218 SDL_BlitMap *SDL_AllocBlitMap(void)
17220 +SDL_BlitMap *SDL_AllocBlitMapI(struct SDLBase *SDLBase)
17225 @@ -539,7 +633,11 @@
17229 +#if !defined(PROTO_SDL_H)
17230 int SDL_MapSurface (SDL_Surface *src, SDL_Surface *dst)
17232 +int SDL_MapSurfaceI(SDL_Surface *src, SDL_Surface *dst, struct SDLBase *SDLBase)
17235 SDL_PixelFormat *srcfmt;
17236 SDL_PixelFormat *dstfmt;
17237 diff -Naur SDL-1.2.15-orig/src/video/SDL_pixels_c.h SDL-1.2.15/src/video/SDL_pixels_c.h
17238 --- SDL-1.2.15-orig/src/video/SDL_pixels_c.h 2015-05-09 17:47:54.310774223 +0200
17239 +++ SDL-1.2.15/src/video/SDL_pixels_c.h 2015-05-09 15:09:59.773739499 +0200
17240 @@ -25,18 +25,30 @@
17242 #include "SDL_blit.h"
17244 -/* Pixel format functions */
17245 +#if !defined(PROTO_SDL_H)
17246 extern SDL_PixelFormat *SDL_AllocFormat(int bpp,
17247 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
17248 extern SDL_PixelFormat *SDL_ReallocFormat(SDL_Surface *surface, int bpp,
17249 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
17250 +extern SDL_BlitMap *SDL_AllocBlitMap(void);
17251 +extern int SDL_MapSurface (SDL_Surface *src, SDL_Surface *dst);
17253 +extern SDL_PixelFormat *SDL_AllocFormatI(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask, struct SDLBase *SDLBase);
17254 +extern SDL_PixelFormat *SDL_ReallocFormatI(SDL_Surface *surface, int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask, struct SDLBase *SDLBase);
17255 +extern SDL_BlitMap *SDL_AllocBlitMapI(struct SDLBase *SDLBase);
17256 +extern int SDL_MapSurfaceI(SDL_Surface *src, SDL_Surface *dst, struct SDLBase *SDLBase);
17258 +#define SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask) SDL_AllocFormatI(bpp, Rmask, Gmask, Bmask, Amask, SDLBase)
17259 +#define SDL_ReallocFormat(surface, bpp, Rmask, Gmask, Bmask, Amask) SDL_ReallocFormatI(surface, bpp, Rmask, Gmask, Bmask, Amask, SDLBase)
17260 +#define SDL_AllocBlitMap() SDL_AllocBlitMapI(SDLBase)
17261 +#define SDL_MapSurface(src, dst) SDL_MapSurfaceI(src, dst, SDLBase)
17263 +/* Pixel format functions */
17264 extern void SDL_FormatChanged(SDL_Surface *surface);
17265 extern void SDL_FreeFormat(SDL_PixelFormat *format);
17267 /* Blit mapping functions */
17268 -extern SDL_BlitMap *SDL_AllocBlitMap(void);
17269 extern void SDL_InvalidateMap(SDL_BlitMap *map);
17270 -extern int SDL_MapSurface (SDL_Surface *src, SDL_Surface *dst);
17271 extern void SDL_FreeBlitMap(SDL_BlitMap *map);
17273 /* Miscellaneous functions */
17274 diff -Naur SDL-1.2.15-orig/src/video/SDL_RLEaccel.c SDL-1.2.15/src/video/SDL_RLEaccel.c
17275 --- SDL-1.2.15-orig/src/video/SDL_RLEaccel.c 2015-05-09 17:47:54.282774297 +0200
17276 +++ SDL-1.2.15/src/video/SDL_RLEaccel.c 2015-05-09 15:09:59.773739499 +0200
17281 +#if defined (SDL_AROS_SHARED)
17282 +#define __NOLIBBASE__
17283 +#include <proto/SDL.h>
17286 #include "SDL_config.h"
17289 @@ -101,6 +106,10 @@
17290 #include "SDL_cpuinfo.h"
17293 +#if defined(PROTO_SDL_H)
17294 +#include "SDL_intern.h"
17298 #define MAX(a, b) ((a) > (b) ? (a) : (b))
17300 @@ -837,6 +846,7 @@
17303 /* blit a colorkeyed RLE surface */
17305 int SDL_RLEBlit(SDL_Surface *src, SDL_Rect *srcrect,
17306 SDL_Surface *dst, SDL_Rect *dstrect)
17308 @@ -846,6 +856,10 @@
17312 +#if defined(PROTO_SDL_H)
17313 + struct Library __unused *SDLBase = src->SDLLib;
17316 /* Lock the destination if necessary */
17317 if ( SDL_MUSTLOCK(dst) ) {
17318 if ( SDL_LockSurface(dst) < 0 ) {
17319 @@ -1015,6 +1029,10 @@
17320 static void RLEAlphaClipBlit(int w, Uint8 *srcbuf, SDL_Surface *dst,
17321 Uint8 *dstbuf, SDL_Rect *srcrect)
17323 +#if defined(PROTO_SDL_H)
17324 + struct Library __unused *SDLBase = dst->SDLLib;
17327 SDL_PixelFormat *df = dst->format;
17329 * clipped blitter: Ptype is the destination pixel type,
17330 @@ -1112,6 +1130,10 @@
17331 Uint8 *srcbuf, *dstbuf;
17332 SDL_PixelFormat *df = dst->format;
17334 +#if defined(PROTO_SDL_H)
17335 + struct Library __unused *SDLBase = src->SDLLib;
17338 /* Lock the destination if necessary */
17339 if ( SDL_MUSTLOCK(dst) ) {
17340 if ( SDL_LockSurface(dst) < 0 ) {
17341 @@ -1397,7 +1419,12 @@
17342 ((unsigned)((((pixel) & fmt->Amask) >> fmt->Ashift) - 1U) < 254U)
17344 /* convert surface to be quickly alpha-blittable onto dest, if possible */
17345 +#if !defined(PROTO_SDL_H)
17346 static int RLEAlphaSurface(SDL_Surface *surface)
17348 +#define RLEAlphaSurface(surface) RLEAlphaSurfaceI(surface, SDLBase)
17349 +static int RLEAlphaSurfaceI(SDL_Surface *surface, struct SDLBase *SDLBase)
17353 SDL_PixelFormat *df;
17354 @@ -1640,7 +1667,12 @@
17355 getpix_8, getpix_16, getpix_24, getpix_32
17358 +#if !defined(PROTO_SDL_H)
17359 static int RLEColorkeySurface(SDL_Surface *surface)
17361 +#define RLEColorkeySurface(surface) RLEColorkeySurfaceI(surface, SDLBase)
17362 +static int RLEColorkeySurfaceI(SDL_Surface *surface, struct SDLBase *SDLBase)
17365 Uint8 *rlebuf, *dst;
17367 @@ -1768,7 +1800,12 @@
17371 +#if !defined(PROTO_SDL_H)
17372 int SDL_RLESurface(SDL_Surface *surface)
17374 +#define SDL_RLESurface(surface) SDL_RLESurfaceI(surface, SDLBase)
17375 +int SDL_RLESurfaceI(SDL_Surface *surface, struct SDLBase *SDLBase)
17380 @@ -1892,7 +1929,12 @@
17384 +#if !defined(PROTO_SDL_H)
17385 void SDL_UnRLESurface(SDL_Surface *surface, int recode)
17387 +#define SDL_UnRLESurface(surface, recode) SDL_UnRLESurfaceI(surface, recode, SDLBase)
17388 +void SDL_UnRLESurfaceI(SDL_Surface *surface, int recode, struct SDLBase *SDLBase)
17391 if ( (surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL ) {
17392 surface->flags &= ~SDL_RLEACCEL;
17393 diff -Naur SDL-1.2.15-orig/src/video/SDL_RLEaccel_c.h SDL-1.2.15/src/video/SDL_RLEaccel_c.h
17394 --- SDL-1.2.15-orig/src/video/SDL_RLEaccel_c.h 2015-05-09 17:47:54.309774226 +0200
17395 +++ SDL-1.2.15/src/video/SDL_RLEaccel_c.h 2015-05-09 15:09:59.773739499 +0200
17398 /* Useful functions and variables from SDL_RLEaccel.c */
17400 -extern int SDL_RLESurface(SDL_Surface *surface);
17401 extern int SDL_RLEBlit(SDL_Surface *src, SDL_Rect *srcrect,
17402 SDL_Surface *dst, SDL_Rect *dstrect);
17403 extern int SDL_RLEAlphaBlit(SDL_Surface *src, SDL_Rect *srcrect,
17404 SDL_Surface *dst, SDL_Rect *dstrect);
17406 +#if !defined (SDL_AROS_SHARED)
17407 +extern int SDL_RLESurface(SDL_Surface *surface);
17408 extern void SDL_UnRLESurface(SDL_Surface *surface, int recode);
17410 +#include "SDL_intern.h"
17412 +extern int SDL_RLESurfaceI(SDL_Surface *surface, struct SDLBase *SDLBase);
17413 +extern void SDL_UnRLESurfaceI(SDL_Surface *surface, int recode, struct SDLBase *SDLBase);
17415 +#define SDL_RLESurface(surface) SDL_RLESurfaceI(surface, SDLBase)
17416 +#define SDL_UnRLESurface(surface, recode) SDL_UnRLESurfaceI(surface, recode, SDLBase)
17418 \ No newline at end of file
17419 diff -Naur SDL-1.2.15-orig/src/video/SDL_stretch.c SDL-1.2.15/src/video/SDL_stretch.c
17420 --- SDL-1.2.15-orig/src/video/SDL_stretch.c 2015-05-09 17:47:54.309774226 +0200
17421 +++ SDL-1.2.15/src/video/SDL_stretch.c 2015-05-09 15:09:59.773739499 +0200
17426 +#if defined (SDL_AROS_SHARED)
17427 +#define __NOLIBBASE__
17428 +#include <proto/SDL.h>
17431 #include "SDL_config.h"
17433 /* This a stretch blit implementation based on ideas given to me by
17435 #error Need assembly opcodes for this architecture
17438 +#if !defined(PROTO_SDL_H)
17439 static unsigned char copy_row[4096] PAGE_ALIGNED;
17441 +#include "SDL_intern.h"
17442 +#define copy_row SDLBase->copy_row
17446 static int generate_rowbytes(int src_w, int dst_w, int bpp)
17448 @@ -199,9 +210,20 @@
17449 /* Perform a stretch blit between two surfaces of the same format.
17450 NOTE: This function is not safe to call from multiple threads!
17452 +#if !defined(PROTO_SDL_H)
17453 int SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect,
17454 SDL_Surface *dst, SDL_Rect *dstrect)
17457 +AROS_LH4(int, SDL_SoftStretch,
17458 + AROS_LHA(SDL_Surface *, src, A0),
17459 + AROS_LHA(SDL_Rect *, srcrect, A1),
17460 + AROS_LHA(SDL_Surface *, dst, A2),
17461 + AROS_LHA(SDL_Rect *, dstrect, A3),
17462 + struct SDLBase *, SDLBase, 145, SDL)
17464 + AROS_LIBFUNC_INIT
17469 @@ -354,5 +376,8 @@
17470 SDL_UnlockSurface(src);
17473 +#if defined(PROTO_SDL_H)
17474 + AROS_LIBFUNC_EXIT
17478 diff -Naur SDL-1.2.15-orig/src/video/SDL_stretch_c.h SDL-1.2.15/src/video/SDL_stretch_c.h
17479 --- SDL-1.2.15-orig/src/video/SDL_stretch_c.h 2015-05-09 17:47:54.282774297 +0200
17480 +++ SDL-1.2.15/src/video/SDL_stretch_c.h 2015-05-09 15:09:59.774739497 +0200
17482 /* Perform a stretch blit between two surfaces of the same format.
17483 NOTE: This function is not safe to call from multiple threads!
17485 +#if !defined(PROTO_SDL_H)
17486 extern int SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect,
17487 SDL_Surface *dst, SDL_Rect *dstrect);
17490 diff -Naur SDL-1.2.15-orig/src/video/SDL_surface.c SDL-1.2.15/src/video/SDL_surface.c
17491 --- SDL-1.2.15-orig/src/video/SDL_surface.c 2015-05-09 17:47:54.282774297 +0200
17492 +++ SDL-1.2.15/src/video/SDL_surface.c 2015-05-09 15:09:59.774739497 +0200
17497 +#if defined (SDL_AROS_SHARED)
17498 +#define __NOLIBBASE__
17499 +#include <proto/SDL.h>
17502 #include "SDL_config.h"
17504 #include "SDL_video.h"
17505 @@ -34,10 +39,29 @@
17507 * Create an empty RGB surface of the appropriate depth
17509 +#if !defined(PROTO_SDL_H)
17510 SDL_Surface * SDL_CreateRGBSurface (Uint32 flags,
17511 int width, int height, int depth,
17512 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
17515 +#include "SDL_intern.h"
17517 +#define current_video SDLBase->current_video
17519 +AROS_LH8(SDL_Surface *, SDL_CreateRGBSurface,
17520 + AROS_LHA(Uint32, flags, D0),
17521 + AROS_LHA(int, width, D1),
17522 + AROS_LHA(int, height, D2),
17523 + AROS_LHA(int, depth, D3),
17524 + AROS_LHA(Uint32, Rmask, D4),
17525 + AROS_LHA(Uint32, Gmask, D5),
17526 + AROS_LHA(Uint32, Bmask, D6),
17527 + AROS_LHA(Uint32, Amask, D7),
17528 + struct SDLBase *, SDLBase, 48, SDL)
17530 + AROS_LIBFUNC_INIT
17532 SDL_VideoDevice *video = current_video;
17533 SDL_VideoDevice *this = current_video;
17534 SDL_Surface *screen;
17539 +#if defined(PROTO_SDL_H)
17540 + surface->SDLLib = (struct Library *)SDLBase;
17542 surface->flags = SDL_SWSURFACE;
17543 if ( (flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
17544 if ((Amask) && (video->displayformatalphapixel))
17545 @@ -121,7 +148,11 @@
17547 /* Get the pixels */
17548 if ( ((flags&SDL_HWSURFACE) == SDL_SWSURFACE) ||
17549 +#if !defined(PROTO_SDL_H)
17550 (video->AllocHWSurface(this, surface) < 0) ) {
17552 + (video->AllocHWSurface(this, surface, SDLBase) < 0) ) {
17554 if ( surface->w && surface->h ) {
17555 surface->pixels = SDL_malloc(surface->h*surface->pitch);
17556 if ( surface->pixels == NULL ) {
17557 @@ -147,14 +178,33 @@
17558 ++surfaces_allocated;
17561 +#if defined(PROTO_SDL_H)
17562 + AROS_LIBFUNC_EXIT
17566 * Create an RGB surface from an existing memory buffer
17568 +#if !defined(PROTO_SDL_H)
17569 SDL_Surface * SDL_CreateRGBSurfaceFrom (void *pixels,
17570 int width, int height, int depth, int pitch,
17571 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
17574 +AROS_LH9(SDL_Surface *, SDL_CreateRGBSurfaceFrom,
17575 + AROS_LHA(void *, pixels, A0),
17576 + AROS_LHA(int, width, D0),
17577 + AROS_LHA(int, height, D1),
17578 + AROS_LHA(int, depth, D2),
17579 + AROS_LHA(int, pitch, D3),
17580 + AROS_LHA(Uint32, Rmask, D4),
17581 + AROS_LHA(Uint32, Gmask, D5),
17582 + AROS_LHA(Uint32, Bmask, D6),
17583 + AROS_LHA(Uint32, Amask, D7),
17584 + struct SDLBase *, SDLBase, 49, SDL)
17586 + AROS_LIBFUNC_INIT
17588 SDL_Surface *surface;
17590 surface = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, depth,
17591 @@ -168,12 +218,26 @@
17592 SDL_SetClipRect(surface, NULL);
17595 +#if defined(PROTO_SDL_H)
17596 + AROS_LIBFUNC_EXIT
17600 * Set the color key in a blittable surface
17602 +#if !defined(PROTO_SDL_H)
17603 int SDL_SetColorKey (SDL_Surface *surface, Uint32 flag, Uint32 key)
17606 +AROS_LH3(int, SDL_SetColorKey,
17607 + AROS_LHA(SDL_Surface *, surface, A0),
17608 + AROS_LHA(Uint32, flag, D0),
17609 + AROS_LHA(Uint32, key, D1),
17610 + struct SDLBase *, SDLBase, 53, SDL)
17612 + AROS_LIBFUNC_INIT
17615 /* Sanity check the flag as it gets passed in */
17616 if ( flag & SDL_SRCCOLORKEY ) {
17617 if ( flag & (SDL_RLEACCEL|SDL_RLEACCELOK) ) {
17618 @@ -205,7 +269,11 @@
17619 surface->format->colorkey = key;
17620 if ( (surface->flags & SDL_HWACCEL) == SDL_HWACCEL ) {
17621 if ( (video->SetHWColorKey == NULL) ||
17622 +#if !defined(PROTO_SDL_H)
17623 (video->SetHWColorKey(this, surface, key) < 0) ) {
17625 + (video->SetHWColorKey(this, surface, key, SDLBase) < 0) ) {
17627 surface->flags &= ~SDL_HWACCEL;
17630 @@ -220,10 +288,23 @@
17632 SDL_InvalidateMap(surface->map);
17634 +#if defined(PROTO_SDL_H)
17635 + AROS_LIBFUNC_EXIT
17638 /* This function sets the alpha channel of a surface */
17639 +#if !defined(PROTO_SDL_H)
17640 int SDL_SetAlpha (SDL_Surface *surface, Uint32 flag, Uint8 value)
17643 +AROS_LH3(int, SDL_SetAlpha,
17644 + AROS_LHA(SDL_Surface *, surface, A0),
17645 + AROS_LHA(Uint32, flag, D0),
17646 + AROS_LHA(Uint8, value, D1),
17647 + struct SDLBase *, SDLBase, 54, SDL)
17649 + AROS_LIBFUNC_INIT
17651 Uint32 oldflags = surface->flags;
17652 Uint32 oldalpha = surface->format->alpha;
17654 @@ -255,7 +336,11 @@
17655 surface->format->alpha = value;
17656 if ( (surface->flags & SDL_HWACCEL) == SDL_HWACCEL ) {
17657 if ( (video->SetHWAlpha == NULL) ||
17658 +#if !defined(PROTO_SDL_H)
17659 (video->SetHWAlpha(this, surface, value) < 0) ) {
17661 + (video->SetHWAlpha(this, surface, value, SDLBase) < 0) ) {
17663 surface->flags &= ~SDL_HWACCEL;
17666 @@ -279,8 +364,15 @@
17667 || (((oldalpha + 1) ^ (value + 1)) & 0x100))
17668 SDL_InvalidateMap(surface->map);
17670 +#if defined(PROTO_SDL_H)
17671 + AROS_LIBFUNC_EXIT
17674 +#if !defined(PROTO_SDL_H)
17675 int SDL_SetAlphaChannel(SDL_Surface *surface, Uint8 value)
17677 +int SDL_SetAlphaChannel(SDL_Surface *surface, Uint8 value, struct SDLBase *SDLBase)
17682 @@ -365,8 +457,17 @@
17684 * Set the clipping rectangle for a blittable surface
17686 +#if !defined(PROTO_SDL_H)
17687 SDL_bool SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect)
17690 +AROS_LH2(SDL_bool, SDL_SetClipRect,
17691 + AROS_LHA(SDL_Surface *, surface, A0),
17692 + AROS_LHA(SDL_Rect *, rect, A1),
17693 + struct SDLBase *, SDLBase, 55, SDL)
17695 + AROS_LIBFUNC_INIT
17697 SDL_Rect full_rect;
17699 /* Don't do anything if there's no surface to act on */
17700 @@ -386,12 +487,27 @@
17703 return SDL_IntersectRect(rect, &full_rect, &surface->clip_rect);
17704 +#if defined(PROTO_SDL_H)
17705 + AROS_LIBFUNC_EXIT
17708 +#if !defined(PROTO_SDL_H)
17709 void SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect)
17712 +AROS_LH2(void, SDL_GetClipRect,
17713 + AROS_LHA(SDL_Surface *, surface, A0),
17714 + AROS_LHA(SDL_Rect *, rect, A1),
17715 + struct SDLBase *, SDLBase, 56, SDL)
17717 + AROS_LIBFUNC_INIT
17719 if ( surface && rect ) {
17720 *rect = surface->clip_rect;
17722 +#if defined(PROTO_SDL_H)
17723 + AROS_LIBFUNC_EXIT
17727 * Set up a blit between two surfaces -- split into three parts:
17728 @@ -404,9 +520,20 @@
17729 * you know exactly what you are doing, you can optimize your code
17730 * by calling the one(s) you need.
17732 +#if !defined(PROTO_SDL_H)
17733 int SDL_LowerBlit (SDL_Surface *src, SDL_Rect *srcrect,
17734 SDL_Surface *dst, SDL_Rect *dstrect)
17737 +AROS_LH4(int, SDL_LowerBlit,
17738 + AROS_LHA(SDL_Surface *, src, A0),
17739 + AROS_LHA(SDL_Rect *, srcrect, A1),
17740 + AROS_LHA(SDL_Surface *, dst, A2),
17741 + AROS_LHA(SDL_Rect *, dstrect, A3),
17742 + struct SDLBase *, SDLBase, 27, SDL)
17744 + AROS_LIBFUNC_INIT
17747 SDL_Rect hw_srcrect;
17748 SDL_Rect hw_dstrect;
17749 @@ -437,13 +564,28 @@
17751 do_blit = src->map->sw_blit;
17754 return(do_blit(src, srcrect, dst, dstrect));
17755 +#if defined(PROTO_SDL_H)
17756 + AROS_LIBFUNC_EXIT
17761 +#if !defined(PROTO_SDL_H)
17762 int SDL_UpperBlit (SDL_Surface *src, SDL_Rect *srcrect,
17763 SDL_Surface *dst, SDL_Rect *dstrect)
17766 +AROS_LH4(int, SDL_UpperBlit,
17767 + AROS_LHA(SDL_Surface *, src, A0),
17768 + AROS_LHA(SDL_Rect *, srcrect, A1),
17769 + AROS_LHA(SDL_Surface *, dst, A2),
17770 + AROS_LHA(SDL_Rect *, dstrect, A3),
17771 + struct SDLBase *, SDLBase, 26, SDL)
17773 + AROS_LIBFUNC_INIT
17776 int srcx, srcy, w, h;
17778 @@ -531,16 +673,29 @@
17780 dstrect->w = dstrect->h = 0;
17782 +#if defined(PROTO_SDL_H)
17783 + AROS_LIBFUNC_EXIT
17787 +#if !defined(PROTO_SDL_H)
17788 static int SDL_FillRect1(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
17790 +#define SDL_FillRect1(dst, dstrect, color) SDL_FillRect1I(dst, dstrect, color, SDLBase)
17791 +static int SDL_FillRect1I(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color, struct SDLBase *SDLBase)
17794 /* FIXME: We have to worry about packing order.. *sigh* */
17795 SDL_SetError("1-bpp rect fill not yet implemented");
17799 +#if !defined(PROTO_SDL_H)
17800 static int SDL_FillRect4(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
17802 +#define SDL_FillRect4(dst, dstrect, color) SDL_FillRect4I(dst, dstrect, color, SDLBase)
17803 +static int SDL_FillRect4I(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color, struct SDLBase *SDLBase)
17806 /* FIXME: We have to worry about packing order.. *sigh* */
17807 SDL_SetError("4-bpp rect fill not yet implemented");
17808 @@ -550,8 +705,18 @@
17810 * This function performs a fast fill of the given rectangle with 'color'
17812 +#if !defined(PROTO_SDL_H)
17813 int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
17816 +AROS_LH3(int, SDL_FillRect,
17817 + AROS_LHA(SDL_Surface *, dst, A0),
17818 + AROS_LHA(SDL_Rect *, dstrect, A1),
17819 + AROS_LHA(Uint32, color, D0),
17820 + struct SDLBase *, SDLBase, 25, SDL)
17822 + AROS_LIBFUNC_INIT
17824 SDL_VideoDevice *video = current_video;
17825 SDL_VideoDevice *this = current_video;
17827 @@ -593,7 +758,11 @@
17828 hw_rect.y += current_video->offset_y;
17829 dstrect = &hw_rect;
17831 +#if !defined(PROTO_SDL_H)
17832 return(video->FillHWRect(this, dst, dstrect, color));
17834 + return(video->FillHWRect(this, dst, dstrect, color, SDLBase));
17838 /* Perform software fill */
17839 @@ -728,19 +897,34 @@
17843 +#if defined(PROTO_SDL_H)
17844 + AROS_LIBFUNC_EXIT
17849 * Lock a surface to directly access the pixels
17851 +#if !defined(PROTO_SDL_H)
17852 int SDL_LockSurface (SDL_Surface *surface)
17855 +AROS_LH1(int, SDL_LockSurface,
17856 + AROS_LHA(SDL_Surface *, surface, A0),
17857 + struct SDLBase *, SDLBase, 50, SDL)
17859 + AROS_LIBFUNC_INIT
17861 if ( ! surface->locked ) {
17862 /* Perform the lock */
17863 if ( surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) {
17864 SDL_VideoDevice *video = current_video;
17865 SDL_VideoDevice *this = current_video;
17866 +#if !defined(PROTO_SDL_H)
17867 if ( video->LockHWSurface(this, surface) < 0 ) {
17869 + if ( video->LockHWSurface(this, surface, SDLBase) < 0 ) {
17874 @@ -757,12 +941,23 @@
17876 /* Ready to go.. */
17878 +#if defined(PROTO_SDL_H)
17879 + AROS_LIBFUNC_EXIT
17883 * Unlock a previously locked surface
17885 +#if !defined(PROTO_SDL_H)
17886 void SDL_UnlockSurface (SDL_Surface *surface)
17889 +AROS_LH1(void, SDL_UnlockSurface,
17890 + AROS_LHA(SDL_Surface *, surface, A0),
17891 + struct SDLBase *, SDLBase, 51, SDL)
17893 + AROS_LIBFUNC_INIT
17895 /* Only perform an unlock if we are locked */
17896 if ( ! surface->locked || (--surface->locked > 0) ) {
17898 @@ -775,7 +970,11 @@
17899 if ( surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) {
17900 SDL_VideoDevice *video = current_video;
17901 SDL_VideoDevice *this = current_video;
17902 +#if !defined(PROTO_SDL_H)
17903 video->UnlockHWSurface(this, surface);
17905 + video->UnlockHWSurface(this, surface, SDLBase);
17908 /* Update RLE encoded surface with new data */
17909 if ( (surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL ) {
17910 @@ -783,14 +982,27 @@
17911 SDL_RLESurface(surface);
17914 +#if defined(PROTO_SDL_H)
17915 + AROS_LIBFUNC_EXIT
17920 * Convert a surface into the specified pixel format.
17922 +#if !defined(PROTO_SDL_H)
17923 SDL_Surface * SDL_ConvertSurface (SDL_Surface *surface,
17924 SDL_PixelFormat *format, Uint32 flags)
17927 +AROS_LH3(SDL_Surface *, SDL_ConvertSurface,
17928 + AROS_LHA(SDL_Surface *, surface, A0),
17929 + AROS_LHA(SDL_PixelFormat *, format, A1),
17930 + AROS_LHA(Uint32, flags, D0),
17931 + struct SDLBase *, SDLBase, 57, SDL)
17933 + AROS_LIBFUNC_INIT
17935 SDL_Surface *convert;
17936 Uint32 colorkey = 0;
17938 @@ -895,13 +1107,24 @@
17940 /* We're ready to go! */
17942 +#if defined(PROTO_SDL_H)
17943 + AROS_LIBFUNC_EXIT
17948 * Free a surface created by the above function.
17950 +#if !defined(PROTO_SDL_H)
17951 void SDL_FreeSurface (SDL_Surface *surface)
17954 +AROS_LH1(void, SDL_FreeSurface,
17955 + AROS_LHA(SDL_Surface *, surface, A0),
17956 + struct SDLBase *, SDLBase, 24, SDL)
17958 + AROS_LIBFUNC_INIT
17960 /* Free anything that's not NULL, and not the screen surface */
17961 if ((surface == NULL) ||
17963 @@ -928,7 +1151,11 @@
17964 if ( surface->hwdata ) {
17965 SDL_VideoDevice *video = current_video;
17966 SDL_VideoDevice *this = current_video;
17967 +#if !defined(PROTO_SDL_H)
17968 video->FreeHWSurface(this, surface);
17970 + video->FreeHWSurface(this, surface, SDLBase);
17973 if ( surface->pixels &&
17974 ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC) ) {
17975 @@ -938,4 +1165,7 @@
17977 --surfaces_allocated;
17979 +#if defined(PROTO_SDL_H)
17980 + AROS_LIBFUNC_EXIT
17983 diff -Naur SDL-1.2.15-orig/src/video/SDL_sysvideo.h SDL-1.2.15/src/video/SDL_sysvideo.h
17984 --- SDL-1.2.15-orig/src/video/SDL_sysvideo.h 2015-05-09 17:47:54.284774292 +0200
17985 +++ SDL-1.2.15/src/video/SDL_sysvideo.h 2015-05-09 15:09:59.774739497 +0200
17987 #include "SDL_opengl.h"
17988 #endif /* SDL_VIDEO_OPENGL */
17990 +#if defined(PROTO_SDL_H)
17991 +#include "SDL_intern.h"
17994 /* The SDL video driver */
17995 typedef struct SDL_VideoDevice SDL_VideoDevice;
17997 @@ -52,11 +56,11 @@
18000 /* Initialization/Query functions */
18002 +#if !defined(PROTO_SDL_H)
18003 /* Initialize the native video subsystem, filling 'vformat' with the
18004 "best" display pixel format, returning 0 or -1 if there's an error.
18006 - int (*VideoInit)(_THIS, SDL_PixelFormat *vformat);
18007 + int (*VideoInit)(_THIS, SDL_PixelFormat *vformat);
18009 /* List the available video modes for the given pixel format, sorted
18010 from largest to smallest.
18011 @@ -110,7 +114,17 @@
18012 or if the application is shutting down the video subsystem.
18014 void (*VideoQuit)(_THIS);
18017 + int (*VideoInit)(_THIS, SDL_PixelFormat *vformat, struct SDLBase *SDLBase);
18018 + SDL_Rect **(*ListModes)(_THIS, SDL_PixelFormat *format, Uint32 flags, struct SDLBase *SDLBase);
18019 + SDL_Surface *(*SetVideoMode)(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags, struct SDLBase *SDLBase);
18020 + int (*ToggleFullScreen)(_THIS, int on, struct SDLBase *SDLBase);
18021 + void (*UpdateMouse)(_THIS, struct SDLBase *SDLBase);
18022 + SDL_Overlay *(*CreateYUVOverlay)(_THIS, int width, int height, Uint32 format, SDL_Surface *display, struct SDLBase *SDLBase);
18023 + int (*SetColors)(_THIS, int firstcolor, int ncolors, SDL_Color *colors, struct SDLBase *SDLBase);
18024 + void (*UpdateRects)(_THIS, int numrects, SDL_Rect *rects, struct SDLBase *SDLBase);
18025 + void (*VideoQuit)(_THIS, struct SDLBase *SDLBase);
18028 /* Hardware acceleration functions */
18030 @@ -120,6 +134,7 @@
18031 /* The pixel format used when SDL_CreateRGBSurface creates SDL_HWSURFACEs with alpha */
18032 SDL_PixelFormat* displayformatalphapixel;
18034 +#if !defined(PROTO_SDL_H)
18035 /* Allocates a surface in video memory */
18036 int (*AllocHWSurface)(_THIS, SDL_Surface *surface);
18038 @@ -146,12 +161,22 @@
18040 /* Frees a previously allocated video surface */
18041 void (*FreeHWSurface)(_THIS, SDL_Surface *surface);
18044 + int (*AllocHWSurface)(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
18045 + int (*CheckHWBlit)(_THIS, SDL_Surface *src, SDL_Surface *dst, struct SDLBase *SDLBase);
18046 + int (*FillHWRect)(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color, struct SDLBase *SDLBase);
18047 + int (*SetHWColorKey)(_THIS, SDL_Surface *surface, Uint32 key, struct SDLBase *SDLBase);
18048 + int (*SetHWAlpha)(_THIS, SDL_Surface *surface, Uint8 value, struct SDLBase *SDLBase);
18049 + int (*LockHWSurface)(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
18050 + void (*UnlockHWSurface)(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
18051 + int (*FlipHWSurface)(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
18052 + void (*FreeHWSurface)(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
18055 /* Gamma support */
18059 +#if !defined(PROTO_SDL_H)
18060 /* Set the gamma correction directly (emulated with gamma ramps) */
18061 int (*SetGamma)(_THIS, float red, float green, float blue);
18063 @@ -181,7 +206,17 @@
18065 /* Swap the current buffers in double buffer mode. */
18066 void (*GL_SwapBuffers)(_THIS);
18069 + int (*SetGamma)(_THIS, float red, float green, float blue, struct SDLBase *SDLBase);
18070 + int (*GetGamma)(_THIS, float *red, float *green, float *blue, struct SDLBase *SDLBase);
18071 + int (*SetGammaRamp)(_THIS, Uint16 *ramp, struct SDLBase *SDLBase);
18072 + int (*GetGammaRamp)(_THIS, Uint16 *ramp, struct SDLBase *SDLBase);
18073 + int (*GL_LoadLibrary)(_THIS, const char *path, struct SDLBase *SDLBase);
18074 + void* (*GL_GetProcAddress)(_THIS, const char *proc, struct SDLBase *SDLBase);
18075 + int (*GL_GetAttribute)(_THIS, SDL_GLattr attrib, int* value, struct SDLBase *SDLBase);
18076 + int (*GL_MakeCurrent)(_THIS, struct SDLBase *SDLBase);
18077 + void (*GL_SwapBuffers)(_THIS, struct SDLBase *SDLBase);
18079 /* OpenGL functions for SDL_OPENGLBLIT */
18080 #if SDL_VIDEO_OPENGL
18081 #if !defined(__WIN32__)
18082 @@ -199,6 +234,7 @@
18084 /* Window manager functions */
18086 +#if !defined(PROTO_SDL_H)
18087 /* Set the title and icon text */
18088 void (*SetCaption)(_THIS, const char *title, const char *icon);
18090 @@ -257,7 +293,21 @@
18092 /* Handle any queued OS events */
18093 void (*PumpEvents)(_THIS);
18096 + void (*SetCaption)(_THIS, const char *title, const char *icon, struct SDLBase *SDLBase);
18097 + void (*SetIcon)(_THIS, SDL_Surface *icon, Uint8 *mask, struct SDLBase *SDLBase);
18098 + int (*IconifyWindow)(_THIS, struct SDLBase *SDLBase);
18099 + SDL_GrabMode (*GrabInput)(_THIS, SDL_GrabMode mode, struct SDLBase *SDLBase);
18100 + int (*GetWMInfo)(_THIS, SDL_SysWMinfo *info, struct SDLBase *SDLBase);
18101 + void (*FreeWMCursor)(_THIS, WMcursor *cursor, struct SDLBase *SDLBase);
18102 + WMcursor *(*CreateWMCursor)(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y, struct SDLBase *SDLBase);
18103 + int (*ShowWMCursor)(_THIS, WMcursor *cursor, struct SDLBase *SDLBase);
18104 + void (*WarpWMCursor)(_THIS, Uint16 x, Uint16 y, struct SDLBase *SDLBase);
18105 + void (*MoveWMCursor)(_THIS, int x, int y, struct SDLBase *SDLBase);
18106 + void (*CheckMouseMode)(_THIS, struct SDLBase *SDLBase);
18107 + void (*InitOSKeymap)(_THIS, struct SDLBase *SDLBase);
18108 + void (*PumpEvents)(_THIS, struct SDLBase *SDLBase);
18111 /* Data common to all drivers */
18112 SDL_Surface *screen;
18113 @@ -306,15 +356,24 @@
18116 /* The function used to dispose of this structure */
18117 +#if !defined(PROTO_SDL_H)
18118 void (*free)(_THIS);
18120 + void (*free)(_THIS, struct SDLBase *SDLBase);
18125 typedef struct VideoBootStrap {
18128 +#if !defined(PROTO_SDL_H)
18129 int (*available)(void);
18130 SDL_VideoDevice *(*create)(int devindex);
18132 + int (*available)(struct SDLBase *SDLBase);
18133 + SDL_VideoDevice *(*create)(int devindex, struct SDLBase *SDLBase);
18137 #if SDL_VIDEO_DRIVER_QUARTZ
18138 @@ -413,9 +472,14 @@
18139 #if SDL_VIDEO_DRIVER_DUMMY
18140 extern VideoBootStrap DUMMY_bootstrap;
18142 +#if SDL_VIDEO_DRIVER_CGX
18143 +extern VideoBootStrap CGX_bootstrap;
18146 /* This is the current video device */
18147 +#if !defined(PROTO_SDL_H)
18148 extern SDL_VideoDevice *current_video;
18151 #define SDL_VideoSurface (current_video->screen)
18152 #define SDL_ShadowSurface (current_video->shadow)
18153 diff -Naur SDL-1.2.15-orig/src/video/SDL_video.c SDL-1.2.15/src/video/SDL_video.c
18154 --- SDL-1.2.15-orig/src/video/SDL_video.c 2015-05-09 17:47:54.282774297 +0200
18155 +++ SDL-1.2.15/src/video/SDL_video.c 2015-05-09 15:09:59.775739495 +0200
18160 +#if defined (SDL_AROS_SHARED)
18161 +#define __NOLIBBASE__
18162 +#include <proto/SDL.h>
18165 #include "SDL_config.h"
18167 /* The high-level video driver subsystem */
18168 @@ -129,17 +134,28 @@
18169 #if SDL_VIDEO_DRIVER_DUMMY
18172 +#if SDL_VIDEO_DRIVER_CGX
18178 -SDL_VideoDevice *current_video = NULL;
18180 -/* Various local functions */
18181 +#if !defined(PROTO_SDL_H)
18182 int SDL_VideoInit(const char *driver_name, Uint32 flags);
18183 void SDL_VideoQuit(void);
18184 -void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect* rects);
18186 +SDL_VideoDevice *current_video = NULL;
18187 +void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect* rects);
18188 static SDL_GrabMode SDL_WM_GrabInputOff(void);
18190 +void SDL_GL_UpdateRectsLockI(SDL_VideoDevice* this, int numrects, SDL_Rect* rects, struct SDLBase *SDLBase);
18191 +#define current_video SDLBase->current_video
18192 +#define SDL_GL_UpdateRectsLock SDL_GL_UpdateRectsLockI
18193 +static SDL_GrabMode SDL_WM_GrabInputOffI(struct SDLBase *SDLBase);
18194 +#define SDL_WM_GrabInputOff() SDL_WM_GrabInputOffI(SDLBase)
18197 +/* Various local functions */
18198 #if SDL_VIDEO_OPENGL
18199 static int lock_count = 0;
18201 @@ -148,8 +164,18 @@
18203 * Initialize the video and event subsystems -- determine native pixel format
18205 +#if !defined(PROTO_SDL_H)
18206 int SDL_VideoInit (const char *driver_name, Uint32 flags)
18209 +AROS_LH2(int, SDL_VideoInit,
18210 + AROS_LHA(const char *, driver_name, A0),
18211 + AROS_LHA(Uint32, flags, D0),
18212 + struct SDLBase *, SDLBase, 34, SDL)
18214 + AROS_LIBFUNC_INIT
18217 SDL_VideoDevice *video;
18220 @@ -182,16 +208,26 @@
18222 for ( i=0; bootstrap[i]; ++i ) {
18223 if ( SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) {
18224 +#if !defined(PROTO_SDL_H)
18225 if ( bootstrap[i]->available() ) {
18226 video = bootstrap[i]->create(index);
18228 + if ( bootstrap[i]->available(SDLBase) ) {
18229 + video = bootstrap[i]->create(index, SDLBase);
18236 for ( i=0; bootstrap[i]; ++i ) {
18237 +#if !defined(PROTO_SDL_H)
18238 if ( bootstrap[i]->available() ) {
18239 video = bootstrap[i]->create(index);
18241 + if ( bootstrap[i]->available(SDLBase) ) {
18242 + video = bootstrap[i]->create(index, SDLBase);
18244 if ( video != NULL ) {
18247 @@ -243,7 +279,11 @@
18249 /* Initialize the video subsystem */
18250 SDL_memset(&vformat, 0, sizeof(vformat));
18251 +#if !defined(PROTO_SDL_H)
18252 if ( video->VideoInit(video, &vformat) < 0 ) {
18254 + if ( video->VideoInit(video, &vformat, SDLBase) < 0 ) {
18259 @@ -282,22 +322,45 @@
18261 /* We're ready to go! */
18263 +#if defined(PROTO_SDL_H)
18264 + AROS_LIBFUNC_EXIT
18268 +#if !defined(PROTO_SDL_H)
18269 char *SDL_VideoDriverName(char *namebuf, int maxlen)
18272 +AROS_LH2(char *, SDL_VideoDriverName,
18273 + AROS_LHA(char *, namebuf, A0),
18274 + AROS_LHA(int, maxlen, D0),
18275 + struct SDLBase *, SDLBase, 36, SDL)
18277 + AROS_LIBFUNC_INIT
18279 if ( current_video != NULL ) {
18280 SDL_strlcpy(namebuf, current_video->name, maxlen);
18284 +#if defined(PROTO_SDL_H)
18285 + AROS_LIBFUNC_EXIT
18290 * Get the current display surface
18293 +#if !defined(PROTO_SDL_H)
18294 SDL_Surface *SDL_GetVideoSurface(void)
18297 +AROS_LH0(SDL_Surface *, SDL_GetVideoSurface,
18298 + struct SDLBase *, SDLBase, 38, SDL)
18300 + AROS_LIBFUNC_INIT
18302 SDL_Surface *visible;
18305 @@ -305,13 +368,23 @@
18306 visible = current_video->visible;
18309 +#if defined(PROTO_SDL_H)
18310 + AROS_LIBFUNC_EXIT
18315 * Get the current information about the video hardware
18317 +#if !defined(PROTO_SDL_H)
18318 const SDL_VideoInfo *SDL_GetVideoInfo(void)
18321 +AROS_LH0(const SDL_VideoInfo *, SDL_GetVideoInfo,
18322 + struct SDLBase *, SDLBase, 35, SDL)
18324 + AROS_LIBFUNC_INIT
18326 const SDL_VideoInfo *info;
18329 @@ -319,6 +392,9 @@
18330 info = ¤t_video->info;
18333 +#if defined(PROTO_SDL_H)
18334 + AROS_LIBFUNC_EXIT
18339 @@ -328,8 +404,17 @@
18340 * if any dimension is okay for the given format. If 'format' is NULL,
18341 * the mode list will be for the format given by SDL_GetVideoInfo()->vfmt
18343 +#if !defined(PROTO_SDL_H)
18344 SDL_Rect ** SDL_ListModes (SDL_PixelFormat *format, Uint32 flags)
18347 +AROS_LH2(SDL_Rect **, SDL_ListModes ,
18348 + AROS_LHA(SDL_PixelFormat *, format, A0),
18349 + AROS_LHA(Uint32, flags, D0),
18350 + struct SDLBase *, SDLBase, 40, SDL)
18352 + AROS_LIBFUNC_INIT
18354 SDL_VideoDevice *video = current_video;
18355 SDL_VideoDevice *this = current_video;
18357 @@ -339,9 +424,16 @@
18358 if ( format == NULL ) {
18359 format = SDL_VideoSurface->format;
18361 +#if !defined(PROTO_SDL_H)
18362 modes = video->ListModes(this, format, flags);
18364 + modes = video->ListModes(this, format, flags, SDLBase);
18368 +#if defined(PROTO_SDL_H)
18369 + AROS_LIBFUNC_EXIT
18374 @@ -370,8 +462,19 @@
18375 #define NEGATIVE_ONE -1
18378 +#if !defined(PROTO_SDL_H)
18379 int SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags)
18382 +AROS_LH4(int, SDL_VideoModeOK,
18383 + AROS_LHA(int, width, D0),
18384 + AROS_LHA(int, height, D1),
18385 + AROS_LHA(int, bpp, D2),
18386 + AROS_LHA(Uint32, flags, D3),
18387 + struct SDLBase *, SDLBase, 39, SDL)
18389 + AROS_LIBFUNC_INIT
18393 SDL_PixelFormat format;
18394 @@ -424,12 +527,20 @@
18398 +#if defined(PROTO_SDL_H)
18399 + AROS_LIBFUNC_EXIT
18404 * Get the closest non-emulated video mode to the one requested
18406 +#if !defined(PROTO_SDL_H)
18407 static int SDL_GetVideoMode (int *w, int *h, int *BitsPerPixel, Uint32 flags)
18409 +#define SDL_GetVideoMode(w, h, BitsPerPixel, flags) SDL_GetVideoModeI(w, h, BitsPerPixel, flags, SDLBase)
18410 +static int SDL_GetVideoModeI(int *w, int *h, int *BitsPerPixel, Uint32 flags, struct SDLBase *SDLBase)
18415 @@ -499,7 +610,12 @@
18418 /* This should probably go somewhere else -- like SDL_surface.c */
18419 +#if !defined(PROTO_SDL_H)
18420 static void SDL_ClearSurface(SDL_Surface *surface)
18422 +#define SDL_ClearSurface(surface) SDL_ClearSurfaceI(surface, SDLBase)
18423 +static void SDL_ClearSurfaceI(SDL_Surface *surface, struct SDLBase *SDLBase)
18428 @@ -517,7 +633,12 @@
18430 * Create a shadow surface suitable for fooling the app. :-)
18432 +#if !defined(PROTO_SDL_H)
18433 static void SDL_CreateShadowSurface(int depth)
18435 +#define SDL_CreateShadowSurface(depth) SDL_CreateShadowSurfaceI(depth, SDLBase)
18436 +static void SDL_CreateShadowSurfaceI(int depth, struct SDLBase *SDLBase)
18439 Uint32 Rmask, Gmask, Bmask;
18441 @@ -580,8 +701,19 @@
18443 * Set the requested video mode, allocating a shadow buffer if necessary.
18445 +#if !defined(PROTO_SDL_H)
18446 SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
18449 +AROS_LH4(SDL_Surface *, SDL_SetVideoMode,
18450 + AROS_LHA(int, width, D0),
18451 + AROS_LHA(int, height, D1),
18452 + AROS_LHA(int, bpp, D2),
18453 + AROS_LHA(Uint32, flags, D3),
18454 + struct SDLBase *, SDLBase, 31, SDL)
18456 + AROS_LIBFUNC_INIT
18458 SDL_VideoDevice *video, *this;
18459 SDL_Surface *prev_mode, *mode;
18461 @@ -680,7 +812,11 @@
18462 prev_mode = SDL_VideoSurface;
18464 SDL_VideoSurface = NULL; /* In case it's freed by driver */
18465 +#if !defined(PROTO_SDL_H)
18466 mode = video->SetVideoMode(this, prev_mode,video_w,video_h,video_bpp,flags);
18468 + mode = video->SetVideoMode(this, prev_mode,video_w,video_h,video_bpp,flags, SDLBase);
18470 if ( mode ) { /* Prevent resize events from mode change */
18471 /* But not on OS/2 */
18473 @@ -717,8 +853,12 @@
18474 if ( mode->format->palette ) {
18475 SDL_PixelFormat *vf = mode->format;
18476 SDL_DitherColors(vf->palette->colors, vf->BitsPerPixel);
18477 +#if !defined(PROTO_SDL_H)
18478 video->SetColors(this, 0, vf->palette->ncolors,
18479 vf->palette->colors);
18481 + video->SetColors(this, 0, vf->palette->ncolors, vf->palette->colors, SDLBase);
18485 /* Clear the surface to black */
18486 @@ -759,7 +899,11 @@
18487 /* Reset the mouse cursor and grab for new video mode */
18488 SDL_SetCursor(NULL);
18489 if ( video->UpdateMouse ) {
18490 +#if !defined(PROTO_SDL_H)
18491 video->UpdateMouse(this);
18493 + video->UpdateMouse(this, SDLBase);
18496 SDL_WM_GrabInput(saved_grab);
18497 SDL_GetRelativeMouseState(NULL, NULL); /* Clear first large delta */
18498 @@ -795,7 +939,11 @@
18499 /* If we're running OpenGL, make the context current */
18500 if ( (video->screen->flags & SDL_OPENGL) &&
18501 video->GL_MakeCurrent ) {
18502 +#if !defined(PROTO_SDL_H)
18503 if ( video->GL_MakeCurrent(this) < 0 ) {
18505 + if ( video->GL_MakeCurrent(this, SDLBase) < 0 ) {
18510 @@ -919,13 +1067,24 @@
18513 return(SDL_PublicSurface);
18514 +#if defined(PROTO_SDL_H)
18515 + AROS_LIBFUNC_EXIT
18520 * Convert a surface into the video pixel format.
18522 +#if !defined(PROTO_SDL_H)
18523 SDL_Surface * SDL_DisplayFormat (SDL_Surface *surface)
18526 +AROS_LH1(SDL_Surface *, SDL_DisplayFormat,
18527 + AROS_LHA(SDL_Surface *, surface, A0),
18528 + struct SDLBase *, SDLBase, 23, SDL)
18530 + AROS_LIBFUNC_INIT
18534 if ( ! SDL_PublicSurface ) {
18535 @@ -944,14 +1103,25 @@
18536 flags |= surface->flags & (SDL_SRCCOLORKEY|SDL_SRCALPHA|SDL_RLEACCELOK);
18538 return(SDL_ConvertSurface(surface, SDL_PublicSurface->format, flags));
18539 +#if defined(PROTO_SDL_H)
18540 + AROS_LIBFUNC_EXIT
18545 * Convert a surface into a format that's suitable for blitting to
18546 * the screen, but including an alpha channel.
18548 +#if !defined(PROTO_SDL_H)
18549 SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface)
18552 +AROS_LH1(SDL_Surface *, SDL_DisplayFormatAlpha,
18553 + AROS_LHA(SDL_Surface *, surface, A0),
18554 + struct SDLBase *, SDLBase, 58, SDL)
18556 + AROS_LIBFUNC_INIT
18558 SDL_PixelFormat *vf;
18559 SDL_PixelFormat *format;
18560 SDL_Surface *converted;
18561 @@ -1006,13 +1176,28 @@
18562 converted = SDL_ConvertSurface(surface, format, flags);
18563 SDL_FreeFormat(format);
18565 +#if defined(PROTO_SDL_H)
18566 + AROS_LIBFUNC_EXIT
18571 * Update a specific portion of the physical screen
18573 +#if !defined(PROTO_SDL_H)
18574 void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h)
18577 +AROS_LH5(void, SDL_UpdateRect,
18578 + AROS_LHA(SDL_Surface *, screen, A0),
18579 + AROS_LHA(Sint32, x, D0),
18580 + AROS_LHA(Sint32, y, D1),
18581 + AROS_LHA(Uint32, w, D2),
18582 + AROS_LHA(Uint32, h, D3),
18583 + struct SDLBase *, SDLBase, 30, SDL)
18585 + AROS_LIBFUNC_INIT
18590 @@ -1033,9 +1218,23 @@
18591 rect.h = (Uint16)h;
18592 SDL_UpdateRects(screen, 1, &rect);
18594 +#if defined(PROTO_SDL_H)
18595 + AROS_LIBFUNC_EXIT
18599 +#if !defined(PROTO_SDL_H)
18600 void SDL_UpdateRects (SDL_Surface *screen, int numrects, SDL_Rect *rects)
18603 +AROS_LH3(void, SDL_UpdateRects,
18604 + AROS_LHA(SDL_Surface *, screen, A0),
18605 + AROS_LHA(int, numrects, D0),
18606 + AROS_LHA(SDL_Rect *, rects, A1),
18607 + struct SDLBase *, SDLBase, 29, SDL)
18609 + AROS_LIBFUNC_INIT
18612 SDL_VideoDevice *video = current_video;
18613 SDL_VideoDevice *this = current_video;
18614 @@ -1088,22 +1287,41 @@
18615 rects[i].x += video->offset_x;
18616 rects[i].y += video->offset_y;
18618 +#if !defined(PROTO_SDL_H)
18619 video->UpdateRects(this, numrects, rects);
18621 + video->UpdateRects(this, numrects, rects, SDLBase);
18623 for ( i=0; i<numrects; ++i ) {
18624 rects[i].x -= video->offset_x;
18625 rects[i].y -= video->offset_y;
18628 +#if !defined(PROTO_SDL_H)
18629 video->UpdateRects(this, numrects, rects);
18631 + video->UpdateRects(this, numrects, rects, SDLBase);
18635 +#if defined(PROTO_SDL_H)
18636 + AROS_LIBFUNC_EXIT
18641 * Performs hardware double buffering, if possible, or a full update if not.
18643 +#if !defined(PROTO_SDL_H)
18644 int SDL_Flip(SDL_Surface *screen)
18647 +AROS_LH1(int, SDL_Flip,
18648 + AROS_LHA(SDL_Surface *, screen, A0),
18649 + struct SDLBase *, SDLBase, 28, SDL)
18651 + AROS_LIBFUNC_INIT
18653 SDL_VideoDevice *video = current_video;
18654 /* Copy the shadow surface to the video surface */
18655 if ( screen == SDL_ShadowSurface ) {
18656 @@ -1146,15 +1364,28 @@
18658 if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
18659 SDL_VideoDevice *this = current_video;
18660 +#if !defined(PROTO_SDL_H)
18661 return(video->FlipHWSurface(this, SDL_VideoSurface));
18663 + return(video->FlipHWSurface(this, SDL_VideoSurface, SDLBase));
18666 SDL_UpdateRect(screen, 0, 0, 0, 0);
18669 +#if defined(PROTO_SDL_H)
18670 + AROS_LIBFUNC_EXIT
18674 +#if !defined(PROTO_SDL_H)
18675 static void SetPalette_logical(SDL_Surface *screen, SDL_Color *colors,
18676 int firstcolor, int ncolors)
18678 +#define SetPalette_logical(screen, colors, firstcolor, ncolors) SetPalette_logicalI(screen, colors, firstcolor, ncolors, SDLBase)
18679 +static void SetPalette_logicalI(SDL_Surface *screen, SDL_Color *colors,
18680 + int firstcolor, int ncolors, struct SDLBase *SDLBase)
18683 SDL_Palette *pal = screen->format->palette;
18684 SDL_Palette *vidpal;
18685 @@ -1180,8 +1411,14 @@
18686 SDL_FormatChanged(screen);
18689 +#if !defined(PROTO_SDL_H)
18690 static int SetPalette_physical(SDL_Surface *screen,
18691 SDL_Color *colors, int firstcolor, int ncolors)
18693 +#define SetPalette_physical(screen, colors, firstcolor, ncolors) SetPalette_physicalI(screen, colors, firstcolor, ncolors, SDLBase)
18694 +static int SetPalette_physicalI(SDL_Surface *screen,
18695 + SDL_Color *colors, int firstcolor, int ncolors, struct SDLBase *SDLBase)
18698 SDL_VideoDevice *video = current_video;
18700 @@ -1239,7 +1476,11 @@
18701 SDL_ApplyGamma(video->gamma, colors, gcolors, ncolors);
18704 +#if !defined(PROTO_SDL_H)
18705 gotall = video->SetColors(video, firstcolor, ncolors, colors);
18707 + gotall = video->SetColors(video, firstcolor, ncolors, colors, SDLBase);
18710 /* The video flags shouldn't have SDL_HWPALETTE, and
18711 the video driver is responsible for copying back the
18712 @@ -1261,9 +1502,21 @@
18714 * Return nonzero if all colours were set as requested, or 0 otherwise.
18716 +#if !defined(PROTO_SDL_H)
18717 int SDL_SetPalette(SDL_Surface *screen, int which,
18718 SDL_Color *colors, int firstcolor, int ncolors)
18721 +AROS_LH5(int, SDL_SetPalette,
18722 + AROS_LHA(SDL_Surface *, screen, A0),
18723 + AROS_LHA(int, which, D0),
18724 + AROS_LHA(SDL_Color *, colors, A1),
18725 + AROS_LHA(int, firstcolor, D1),
18726 + AROS_LHA(int, ncolors, D2),
18727 + struct SDLBase *, SDLBase, 45, SDL)
18729 + AROS_LIBFUNC_INIT
18734 @@ -1323,26 +1576,50 @@
18736 SDL_memcpy(pp->colors, pal->colors, size);
18738 - if ( ! SetPalette_physical(screen,
18739 - colors, firstcolor, ncolors) ) {
18740 + if ( ! SetPalette_physical(screen, colors, firstcolor, ncolors) ) {
18745 +#if defined(PROTO_SDL_H)
18746 + AROS_LIBFUNC_EXIT
18750 +#if !defined(PROTO_SDL_H)
18751 int SDL_SetColors(SDL_Surface *screen, SDL_Color *colors, int firstcolor,
18755 +AROS_LH4(int, SDL_SetColors,
18756 + AROS_LHA(SDL_Surface *, screen, A0),
18757 + AROS_LHA(SDL_Color *, colors, A1),
18758 + AROS_LHA(int, firstcolor, D0),
18759 + AROS_LHA(int, ncolors, D1),
18760 + struct SDLBase *, SDLBase, 44, SDL)
18762 + AROS_LIBFUNC_INIT
18764 return SDL_SetPalette(screen, SDL_LOGPAL | SDL_PHYSPAL,
18765 colors, firstcolor, ncolors);
18766 +#if defined(PROTO_SDL_H)
18767 + AROS_LIBFUNC_EXIT
18772 * Clean up the video subsystem
18774 +#if !defined(PROTO_SDL_H)
18775 void SDL_VideoQuit (void)
18778 +AROS_LH0(void, SDL_VideoQuit,
18779 + struct SDLBase *, SDLBase, 37, SDL)
18781 + AROS_LIBFUNC_INIT
18784 SDL_Surface *ready_to_go;
18786 if ( current_video ) {
18787 @@ -1362,7 +1639,11 @@
18788 SDL_WM_GrabInputOff();
18790 /* Clean up the system video */
18791 +#if !defined(PROTO_SDL_H)
18792 video->VideoQuit(this);
18794 + video->VideoQuit(this, SDLBase);
18797 /* Free any lingering surfaces */
18798 ready_to_go = SDL_ShadowSurface;
18799 @@ -1399,15 +1680,30 @@
18802 /* Finish cleaning up video subsystem */
18803 +#if !defined(PROTO_SDL_H)
18806 + video->free(this, SDLBase);
18808 current_video = NULL;
18811 +#if defined(PROTO_SDL_H)
18812 + AROS_LIBFUNC_EXIT
18816 /* Load the GL driver library */
18817 +#if !defined(PROTO_SDL_H)
18818 int SDL_GL_LoadLibrary(const char *path)
18821 +AROS_LH1(int, SDL_GL_LoadLibrary,
18822 + AROS_LHA(const char *, path, A0),
18823 + struct SDLBase *, SDLBase, 64, SDL)
18825 + AROS_LIBFUNC_INIT
18827 SDL_VideoDevice *video = current_video;
18828 SDL_VideoDevice *this = current_video;
18830 @@ -1417,16 +1713,31 @@
18831 SDL_SetError("Video subsystem has not been initialized");
18833 if ( video->GL_LoadLibrary ) {
18834 +#if !defined(PROTO_SDL_H)
18835 retval = video->GL_LoadLibrary(this, path);
18837 + retval = video->GL_LoadLibrary(this, path, SDLBase);
18840 SDL_SetError("No dynamic GL support in video driver");
18844 +#if defined(PROTO_SDL_H)
18845 + AROS_LIBFUNC_EXIT
18849 +#if !defined(PROTO_SDL_H)
18850 void *SDL_GL_GetProcAddress(const char* proc)
18853 +AROS_LH1(void *, SDL_GL_GetProcAddress,
18854 + AROS_LHA(const char*, proc, A0),
18855 + struct SDLBase *, SDLBase, 65, SDL)
18857 + AROS_LIBFUNC_INIT
18859 SDL_VideoDevice *video = current_video;
18860 SDL_VideoDevice *this = current_video;
18862 @@ -1434,7 +1745,11 @@
18864 if ( video->GL_GetProcAddress ) {
18865 if ( video->gl_config.driver_loaded ) {
18866 +#if !defined(PROTO_SDL_H)
18867 func = video->GL_GetProcAddress(this, proc);
18869 + func = video->GL_GetProcAddress(this, proc, SDLBase);
18872 SDL_SetError("No GL driver has been loaded");
18874 @@ -1442,11 +1757,23 @@
18875 SDL_SetError("No dynamic GL support in video driver");
18878 +#if defined(PROTO_SDL_H)
18879 + AROS_LIBFUNC_EXIT
18883 /* Set the specified GL attribute for setting up a GL video mode */
18884 +#if !defined(PROTO_SDL_H)
18885 int SDL_GL_SetAttribute( SDL_GLattr attr, int value )
18888 +AROS_LH2(int, SDL_GL_SetAttribute,
18889 + AROS_LHA(SDL_GLattr, attr, D0),
18890 + AROS_LHA(int, value, D1),
18891 + struct SDLBase *, SDLBase, 66, SDL)
18893 + AROS_LIBFUNC_INIT
18896 SDL_VideoDevice *video = current_video;
18898 @@ -1509,39 +1836,80 @@
18902 +#if defined(PROTO_SDL_H)
18903 + AROS_LIBFUNC_EXIT
18907 /* Retrieve an attribute value from the windowing system. */
18908 +#if !defined(PROTO_SDL_H)
18909 int SDL_GL_GetAttribute(SDL_GLattr attr, int* value)
18912 +AROS_LH2(int, SDL_GL_GetAttribute,
18913 + AROS_LHA(SDL_GLattr, attr, D0),
18914 + AROS_LHA(int *, value, A0),
18915 + struct SDLBase *, SDLBase, 67, SDL)
18917 + AROS_LIBFUNC_INIT
18920 SDL_VideoDevice* video = current_video;
18921 SDL_VideoDevice* this = current_video;
18923 if ( video->GL_GetAttribute ) {
18924 +#if !defined(PROTO_SDL_H)
18925 retval = this->GL_GetAttribute(this, attr, value);
18927 + retval = this->GL_GetAttribute(this, attr, value, SDLBase);
18931 SDL_SetError("GL_GetAttribute not supported");
18934 +#if defined(PROTO_SDL_H)
18935 + AROS_LIBFUNC_EXIT
18939 /* Perform a GL buffer swap on the current GL context */
18940 +#if !defined(PROTO_SDL_H)
18941 void SDL_GL_SwapBuffers(void)
18944 +AROS_LH0(void, SDL_GL_SwapBuffers,
18945 + struct SDLBase *, SDLBase, 68, SDL)
18947 + AROS_LIBFUNC_INIT
18949 SDL_VideoDevice *video = current_video;
18950 SDL_VideoDevice *this = current_video;
18952 if ( video->screen->flags & SDL_OPENGL ) {
18953 +#if !defined(PROTO_SDL_H)
18954 video->GL_SwapBuffers(this);
18956 + video->GL_SwapBuffers(this, SDLBase);
18959 SDL_SetError("OpenGL video mode has not been set");
18961 +#if defined(PROTO_SDL_H)
18962 + AROS_LIBFUNC_EXIT
18966 /* Update rects with locking */
18967 +#if !defined(PROTO_SDL_H)
18968 void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect *rects)
18970 +#ifdef SDL_GL_UpdateRectsLock
18971 +#undef SDL_GL_UpdateRectsLock
18973 +#define SDL_GL_UpdateRectsLock(this, numrects, rects) SDL_GL_UpdateRectsLockI(this, numrects, rects, SDLBase)
18974 +void SDL_GL_UpdateRectsLockI(SDL_VideoDevice* this, int numrects, SDL_Rect *rects, struct SDLBase *SDLBase)
18978 SDL_GL_UpdateRects(numrects, rects);
18979 @@ -1549,8 +1917,17 @@
18982 /* Update rects without state setting and changing (the caller is responsible for it) */
18983 +#if !defined(PROTO_SDL_H)
18984 void SDL_GL_UpdateRects(int numrects, SDL_Rect *rects)
18987 +AROS_LH2(void, SDL_GL_UpdateRects,
18988 + AROS_LHA(Uint32, numrects, D0),
18989 + AROS_LHA(SDL_Rect *, rects, A0),
18990 + struct SDLBase *, SDLBase, 69, SDL)
18992 + AROS_LIBFUNC_INIT
18994 #if SDL_VIDEO_OPENGL
18995 SDL_VideoDevice *this = current_video;
18996 SDL_Rect update, tmp;
18997 @@ -1620,11 +1997,21 @@
19001 +#if defined(PROTO_SDL_H)
19002 + AROS_LIBFUNC_EXIT
19006 /* Lock == save current state */
19007 +#if !defined(PROTO_SDL_H)
19011 +AROS_LH0(void, SDL_GL_Lock,
19012 + struct SDLBase *, SDLBase, 70, SDL)
19014 + AROS_LIBFUNC_INIT
19016 #if SDL_VIDEO_OPENGL
19018 if (lock_count==-1)
19019 @@ -1668,11 +2055,21 @@
19020 this->glLoadIdentity();
19023 +#if defined(PROTO_SDL_H)
19024 + AROS_LIBFUNC_EXIT
19028 /* Unlock == restore saved state */
19029 +#if !defined(PROTO_SDL_H)
19030 void SDL_GL_Unlock()
19033 +AROS_LH0(void, SDL_GL_Unlock,
19034 + struct SDLBase *, SDLBase, 71, SDL)
19036 + AROS_LIBFUNC_INIT
19038 #if SDL_VIDEO_OPENGL
19041 @@ -1687,16 +2084,29 @@
19042 this->glPopAttrib();
19045 +#if defined(PROTO_SDL_H)
19046 + AROS_LIBFUNC_EXIT
19051 +#if !defined(PROTO_SDL_H)
19052 void SDL_Audio_SetCaption(const char *caption);
19056 * Sets/Gets the title and icon text of the display window, if any.
19058 +#if !defined(PROTO_SDL_H)
19059 void SDL_WM_SetCaption (const char *title, const char *icon)
19062 +AROS_LH2(void, SDL_WM_SetCaption,
19063 + AROS_LHA(const char *, title, A0),
19064 + AROS_LHA(const char *, icon, A1),
19065 + struct SDLBase *, SDLBase, 72, SDL)
19067 + AROS_LIBFUNC_INIT
19069 SDL_VideoDevice *video = current_video;
19070 SDL_VideoDevice *this = current_video;
19072 @@ -1714,16 +2124,32 @@
19073 video->wm_icon = SDL_strdup(icon);
19075 if ( (title || icon) && (video->SetCaption != NULL) ) {
19076 +#if !defined(PROTO_SDL_H)
19077 video->SetCaption(this, video->wm_title,video->wm_icon);
19079 + video->SetCaption(this, video->wm_title,video->wm_icon, SDLBase);
19084 /* PulseAudio can make use of this information. */
19085 SDL_Audio_SetCaption(title);
19086 +#if defined(PROTO_SDL_H)
19087 + AROS_LIBFUNC_EXIT
19091 +#if !defined(PROTO_SDL_H)
19092 void SDL_WM_GetCaption (char **title, char **icon)
19095 +AROS_LH2(void, SDL_WM_GetCaption,
19096 + AROS_LHA(char **, title, A0),
19097 + AROS_LHA(char **, icon, A1),
19098 + struct SDLBase *, SDLBase, 73, SDL)
19100 + AROS_LIBFUNC_INIT
19102 SDL_VideoDevice *video = current_video;
19105 @@ -1734,11 +2160,19 @@
19106 *icon = video->wm_icon;
19109 +#if defined(PROTO_SDL_H)
19110 + AROS_LIBFUNC_EXIT
19114 /* Utility function used by SDL_WM_SetIcon();
19115 * flags & 1 for color key, flags & 2 for alpha channel. */
19116 +#if !defined(PROTO_SDL_H)
19117 static void CreateMaskFromColorKeyOrAlpha(SDL_Surface *icon, Uint8 *mask, int flags)
19119 +#define CreateMaskFromColorKeyOrAlpha(icon, mask, flags) CreateMaskFromColorKeyOrAlphaI(icon, mask, flags, SDLBase)
19120 +static void CreateMaskFromColorKeyOrAlphaI(SDL_Surface *icon, Uint8 *mask, int flags, struct SDLBase *SDLBase)
19125 @@ -1796,8 +2230,17 @@
19127 * Sets the window manager icon for the display window.
19129 +#if !defined(PROTO_SDL_H)
19130 void SDL_WM_SetIcon (SDL_Surface *icon, Uint8 *mask)
19133 +AROS_LH2(void, SDL_WM_SetIcon,
19134 + AROS_LHA(SDL_Surface *, icon, A0),
19135 + AROS_LHA(Uint8 *, mask, A1),
19136 + struct SDLBase *, SDLBase, 74, SDL)
19138 + AROS_LIBFUNC_INIT
19140 SDL_VideoDevice *video = current_video;
19141 SDL_VideoDevice *this = current_video;
19143 @@ -1816,12 +2259,23 @@
19145 CreateMaskFromColorKeyOrAlpha(icon, mask, flags);
19147 +#if !defined(PROTO_SDL_H)
19148 video->SetIcon(video, icon, mask);
19150 + video->SetIcon(video, icon, mask, SDLBase);
19154 +#if !defined(PROTO_SDL_H)
19155 video->SetIcon(this, icon, mask);
19157 + video->SetIcon(this, icon, mask, SDLBase);
19161 +#if defined(PROTO_SDL_H)
19162 + AROS_LIBFUNC_EXIT
19167 @@ -1829,7 +2283,12 @@
19168 * This function returns the final grab mode after calling the
19169 * driver dependent function.
19171 +#if !defined(PROTO_SDL_H)
19172 static SDL_GrabMode SDL_WM_GrabInputRaw(SDL_GrabMode mode)
19174 +#define SDL_WM_GrabInputRaw(mode) SDL_WM_GrabInputRawI(mode, SDLBase)
19175 +static SDL_GrabMode SDL_WM_GrabInputRawI(SDL_GrabMode mode, struct SDLBase *SDLBase)
19178 SDL_VideoDevice *video = current_video;
19179 SDL_VideoDevice *this = current_video;
19180 @@ -1845,17 +2304,29 @@
19182 if ( mode == SDL_GRAB_OFF ) {
19183 if ( video->input_grab != SDL_GRAB_OFF ) {
19184 +#if !defined(PROTO_SDL_H)
19185 mode = video->GrabInput(this, mode);
19187 + mode = video->GrabInput(this, mode, SDLBase);
19191 if ( video->input_grab == SDL_GRAB_OFF ) {
19192 +#if !defined(PROTO_SDL_H)
19193 mode = video->GrabInput(this, mode);
19195 + mode = video->GrabInput(this, mode, SDLBase);
19199 if ( mode != video->input_grab ) {
19200 video->input_grab = mode;
19201 if ( video->CheckMouseMode ) {
19202 +#if !defined(PROTO_SDL_H)
19203 video->CheckMouseMode(this);
19205 + video->CheckMouseMode(this, SDLBase);
19210 @@ -1868,8 +2339,16 @@
19214 +#if !defined(PROTO_SDL_H)
19215 SDL_GrabMode SDL_WM_GrabInput(SDL_GrabMode mode)
19218 +AROS_LH1(SDL_GrabMode, SDL_WM_GrabInput,
19219 + AROS_LHA(SDL_GrabMode, mode, D0),
19220 + struct SDLBase *, SDLBase, 77, SDL)
19222 + AROS_LIBFUNC_INIT
19224 SDL_VideoDevice *video = current_video;
19226 /* If the video isn't initialized yet, we can't do anything */
19227 @@ -1897,8 +2376,15 @@
19228 mode += SDL_GRAB_FULLSCREEN;
19230 return(SDL_WM_GrabInputRaw(mode));
19231 +#if defined(PROTO_SDL_H)
19232 + AROS_LIBFUNC_EXIT
19235 +#if !defined(PROTO_SDL_H)
19236 static SDL_GrabMode SDL_WM_GrabInputOff(void)
19238 +static SDL_GrabMode SDL_WM_GrabInputOffI(struct SDLBase *SDLBase)
19243 @@ -1916,24 +2402,46 @@
19244 * Iconify the window in window managed environments.
19245 * A successful iconification will result in an SDL_APPACTIVE loss event.
19247 +#if !defined(PROTO_SDL_H)
19248 int SDL_WM_IconifyWindow(void)
19251 +AROS_LH0(int, SDL_WM_IconifyWindow,
19252 + struct SDLBase *, SDLBase, 75, SDL)
19254 + AROS_LIBFUNC_INIT
19256 SDL_VideoDevice *video = current_video;
19257 SDL_VideoDevice *this = current_video;
19261 if ( video->IconifyWindow ) {
19262 +#if !defined(PROTO_SDL_H)
19263 retval = video->IconifyWindow(this);
19265 + retval = video->IconifyWindow(this, SDLBase);
19269 +#if defined(PROTO_SDL_H)
19270 + AROS_LIBFUNC_EXIT
19275 * Toggle fullscreen mode
19277 +#if !defined(PROTO_SDL_H)
19278 int SDL_WM_ToggleFullScreen(SDL_Surface *surface)
19281 +AROS_LH1(int, SDL_WM_ToggleFullScreen,
19282 + AROS_LHA(SDL_Surface *, surface, A0),
19283 + struct SDLBase *, SDLBase, 76, SDL)
19285 + AROS_LIBFUNC_INIT
19287 SDL_VideoDevice *video = current_video;
19288 SDL_VideoDevice *this = current_video;
19290 @@ -1942,13 +2450,21 @@
19291 if ( SDL_PublicSurface && (surface == SDL_PublicSurface) &&
19292 video->ToggleFullScreen ) {
19293 if ( surface->flags & SDL_FULLSCREEN ) {
19294 +#if !defined(PROTO_SDL_H)
19295 toggled = video->ToggleFullScreen(this, 0);
19297 + toggled = video->ToggleFullScreen(this, 0, SDLBase);
19300 SDL_VideoSurface->flags &= ~SDL_FULLSCREEN;
19301 SDL_PublicSurface->flags &= ~SDL_FULLSCREEN;
19304 +#if !defined(PROTO_SDL_H)
19305 toggled = video->ToggleFullScreen(this, 1);
19307 + toggled = video->ToggleFullScreen(this, 1, SDLBase);
19310 SDL_VideoSurface->flags |= SDL_FULLSCREEN;
19311 SDL_PublicSurface->flags |= SDL_FULLSCREEN;
19312 @@ -1960,18 +2476,29 @@
19316 +#if defined(PROTO_SDL_H)
19317 + AROS_LIBFUNC_EXIT
19322 * Get some platform dependent window manager information
19324 +#if !defined(PROTO_SDL_H)
19325 int SDL_GetWMInfo (SDL_SysWMinfo *info)
19327 +int SDL_GetWMInfo (SDL_SysWMinfo *info, struct SDLBase *SDLBase)
19330 SDL_VideoDevice *video = current_video;
19331 SDL_VideoDevice *this = current_video;
19333 if ( video && video->GetWMInfo ) {
19334 +#if !defined(PROTO_SDL_H)
19335 return(video->GetWMInfo(this, info));
19337 + return(video->GetWMInfo(this, info, SDLBase));
19342 diff -Naur SDL-1.2.15-orig/src/video/SDL_yuv.c SDL-1.2.15/src/video/SDL_yuv.c
19343 --- SDL-1.2.15-orig/src/video/SDL_yuv.c 2015-05-09 17:47:54.283774294 +0200
19344 +++ SDL-1.2.15/src/video/SDL_yuv.c 2015-05-09 15:09:59.775739495 +0200
19349 +#if defined (SDL_AROS_SHARED)
19350 +#define __NOLIBBASE__
19351 +#include <proto/SDL.h>
19354 #include "SDL_config.h"
19356 /* This is the implementation of the YUV video surface support */
19357 @@ -28,10 +33,24 @@
19358 #include "SDL_yuvfuncs.h"
19359 #include "SDL_yuv_sw_c.h"
19362 +#if !defined(PROTO_SDL_H)
19363 SDL_Overlay *SDL_CreateYUVOverlay(int w, int h, Uint32 format,
19364 SDL_Surface *display)
19367 +#include "SDL_intern.h"
19369 +#define current_video SDLBase->current_video
19371 +AROS_LH4(SDL_Overlay *, SDL_CreateYUVOverlay,
19372 + AROS_LHA(int, w, D0),
19373 + AROS_LHA(int, h, D1),
19374 + AROS_LHA(Uint32, format, D2),
19375 + AROS_LHA(SDL_Surface *, display, A0),
19376 + struct SDLBase *, SDLBase, 59, SDL)
19378 + AROS_LIBFUNC_INIT
19380 SDL_VideoDevice *video = current_video;
19381 SDL_VideoDevice *this = current_video;
19382 const char *yuv_hwaccel;
19383 @@ -54,34 +73,77 @@
19384 yuv_hwaccel = SDL_getenv("SDL_VIDEO_YUV_HWACCEL");
19385 if ( ((display == SDL_VideoSurface) && video->CreateYUVOverlay) &&
19386 (!yuv_hwaccel || (SDL_atoi(yuv_hwaccel) > 0)) ) {
19387 +#if !defined(PROTO_SDL_H)
19388 overlay = video->CreateYUVOverlay(this, w, h, format, display);
19390 + overlay = video->CreateYUVOverlay(this, w, h, format, display, SDLBase);
19393 /* If hardware YUV overlay failed ... */
19394 if ( overlay == NULL ) {
19395 overlay = SDL_CreateYUV_SW(this, w, h, format, display);
19398 +#if defined(PROTO_SDL_H)
19399 + AROS_LIBFUNC_EXIT
19403 +#if !defined(PROTO_SDL_H)
19404 int SDL_LockYUVOverlay(SDL_Overlay *overlay)
19407 +AROS_LH1(int, SDL_LockYUVOverlay,
19408 + AROS_LHA(SDL_Overlay *, overlay, A0),
19409 + struct SDLBase *, SDLBase, 60, SDL)
19411 + AROS_LIBFUNC_INIT
19413 if ( overlay == NULL ) {
19414 SDL_SetError("Passed NULL overlay");
19417 +#if !defined(PROTO_SDL_H)
19418 return overlay->hwfuncs->Lock(current_video, overlay);
19420 + return overlay->hwfuncs->Lock(current_video, overlay, SDLBase);
19422 + AROS_LIBFUNC_EXIT
19426 +#if !defined(PROTO_SDL_H)
19427 void SDL_UnlockYUVOverlay(SDL_Overlay *overlay)
19430 +AROS_LH1(void, SDL_UnlockYUVOverlay,
19431 + AROS_LHA(SDL_Overlay *, overlay, A0),
19432 + struct SDLBase *, SDLBase, 61, SDL)
19434 + AROS_LIBFUNC_INIT
19436 if ( overlay == NULL ) {
19439 +#if !defined(PROTO_SDL_H)
19440 overlay->hwfuncs->Unlock(current_video, overlay);
19442 + overlay->hwfuncs->Unlock(current_video, overlay, SDLBase);
19443 + AROS_LIBFUNC_EXIT
19447 +#if !defined(PROTO_SDL_H)
19448 int SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect)
19451 +AROS_LH2(int, SDL_DisplayYUVOverlay,
19452 + AROS_LHA(SDL_Overlay *, overlay, A0),
19453 + AROS_LHA(SDL_Rect *, dstrect, A1),
19454 + struct SDLBase *, SDLBase, 62, SDL)
19456 + AROS_LIBFUNC_INIT
19459 int srcx, srcy, srcw, srch;
19460 int dstx, dsty, dstw, dsth;
19461 @@ -135,16 +197,37 @@
19465 +#if !defined(PROTO_SDL_H)
19466 return overlay->hwfuncs->Display(current_video, overlay, &src, &dst);
19468 + return overlay->hwfuncs->Display(current_video, overlay, &src, &dst, SDLBase);
19470 + AROS_LIBFUNC_EXIT
19474 +#if !defined(PROTO_SDL_H)
19475 void SDL_FreeYUVOverlay(SDL_Overlay *overlay)
19478 +AROS_LH1(void, SDL_FreeYUVOverlay,
19479 + AROS_LHA(SDL_Overlay *, overlay, A0),
19480 + struct SDLBase *, SDLBase, 63, SDL)
19482 + AROS_LIBFUNC_INIT
19484 if ( overlay == NULL ) {
19487 if ( overlay->hwfuncs ) {
19488 +#if !defined(PROTO_SDL_H)
19489 overlay->hwfuncs->FreeHW(current_video, overlay);
19491 + overlay->hwfuncs->FreeHW(current_video, overlay, SDLBase);
19495 +#if defined(PROTO_SDL_H)
19496 + AROS_LIBFUNC_EXIT
19499 diff -Naur SDL-1.2.15-orig/src/video/SDL_yuvfuncs.h SDL-1.2.15/src/video/SDL_yuvfuncs.h
19500 --- SDL-1.2.15-orig/src/video/SDL_yuvfuncs.h 2015-05-09 17:47:54.309774226 +0200
19501 +++ SDL-1.2.15/src/video/SDL_yuvfuncs.h 2015-05-09 15:09:59.775739495 +0200
19503 #define _THIS SDL_VideoDevice *_this
19505 struct private_yuvhwfuncs {
19506 +#if !defined(PROTO_SDL_H)
19507 int (*Lock)(_THIS, SDL_Overlay *overlay);
19508 void (*Unlock)(_THIS, SDL_Overlay *overlay);
19509 int (*Display)(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst);
19510 void (*FreeHW)(_THIS, SDL_Overlay *overlay);
19512 + int (*Lock)(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase);
19513 + void (*Unlock)(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase);
19514 + int (*Display)(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst, struct SDLBase *SDLBase);
19515 + void (*FreeHW)(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase);
19518 diff -Naur SDL-1.2.15-orig/src/video/SDL_yuv_mmx.c SDL-1.2.15/src/video/SDL_yuv_mmx.c
19519 --- SDL-1.2.15-orig/src/video/SDL_yuv_mmx.c 2015-05-09 17:47:54.309774226 +0200
19520 +++ SDL-1.2.15/src/video/SDL_yuv_mmx.c 2015-05-09 15:09:59.775739495 +0200
19525 +#if defined (SDL_AROS_SHARED)
19526 +#define __NOLIBBASE__
19527 +#include <proto/SDL.h>
19530 #include "SDL_config.h"
19532 #if (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES
19533 diff -Naur SDL-1.2.15-orig/src/video/SDL_yuv_sw.c SDL-1.2.15/src/video/SDL_yuv_sw.c
19534 --- SDL-1.2.15-orig/src/video/SDL_yuv_sw.c 2015-05-09 17:47:54.283774294 +0200
19535 +++ SDL-1.2.15/src/video/SDL_yuv_sw.c 2015-05-09 15:09:59.776739493 +0200
19540 +#if defined (SDL_AROS_SHARED)
19541 +#define __NOLIBBASE__
19542 +#include <proto/SDL.h>
19545 #include "SDL_config.h"
19547 /* This is the software implementation of the YUV video overlay support */
19548 @@ -923,7 +928,11 @@
19552 +#if !defined(PROTO_SDL_H)
19553 SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
19555 +SDL_Overlay *SDL_CreateYUV_SWI(_THIS, int width, int height, Uint32 format, SDL_Surface *display, struct SDLBase *SDLBase)
19558 SDL_Overlay *overlay;
19559 struct private_yuvhwdata *swdata;
19560 @@ -1154,17 +1163,29 @@
19564 +#if !defined(PROTO_SDL_H)
19565 int SDL_LockYUV_SW(_THIS, SDL_Overlay *overlay)
19567 +int SDL_LockYUV_SWI(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase)
19573 +#if !defined(PROTO_SDL_H)
19574 void SDL_UnlockYUV_SW(_THIS, SDL_Overlay *overlay)
19576 +void SDL_UnlockYUV_SWI(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase)
19582 +#if !defined(PROTO_SDL_H)
19583 int SDL_DisplayYUV_SW(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst)
19585 +int SDL_DisplayYUV_SWI(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst, struct SDLBase *SDLBase)
19588 struct private_yuvhwdata *swdata;
19590 @@ -1275,7 +1296,11 @@
19594 +#if !defined(PROTO_SDL_H)
19595 void SDL_FreeYUV_SW(_THIS, SDL_Overlay *overlay)
19597 +void SDL_FreeYUV_SWI(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase)
19600 struct private_yuvhwdata *swdata;
19602 diff -Naur SDL-1.2.15-orig/src/video/SDL_yuv_sw_c.h SDL-1.2.15/src/video/SDL_yuv_sw_c.h
19603 --- SDL-1.2.15-orig/src/video/SDL_yuv_sw_c.h 2015-05-09 17:47:54.308774229 +0200
19604 +++ SDL-1.2.15/src/video/SDL_yuv_sw_c.h 2015-05-09 15:09:59.776739493 +0200
19606 #include "SDL_sysvideo.h"
19608 /* This is the software implementation of the YUV video overlay support */
19610 +#if !defined(PROTO_SDL_H)
19611 extern SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, SDL_Surface *display);
19613 extern int SDL_LockYUV_SW(_THIS, SDL_Overlay *overlay);
19615 extern int SDL_DisplayYUV_SW(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst);
19617 extern void SDL_FreeYUV_SW(_THIS, SDL_Overlay *overlay);
19620 +#include "SDL_intern.h"
19622 +extern SDL_Overlay *SDL_CreateYUV_SWI(_THIS, int width, int height, Uint32 format, SDL_Surface *display, struct SDLBase *SDLBase);
19623 +extern int SDL_LockYUV_SWI(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase);
19624 +extern void SDL_UnlockYUV_SWI(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase);
19625 +extern int SDL_DisplayYUV_SWI(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst, struct SDLBase *SDLBase);
19626 +extern void SDL_FreeYUV_SWI(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase);
19628 +#define SDL_CreateYUV_SW(this, width, height, format, display) SDL_CreateYUV_SWI(this, width, height, format, display, SDLBase)
19629 +#define SDL_LockYUV_SW SDL_LockYUV_SWI
19630 +#define SDL_UnlockYUV_SW SDL_UnlockYUV_SWI
19631 +#define SDL_DisplayYUV_SW SDL_DisplayYUV_SWI
19632 +#define SDL_FreeYUV_SW SDL_FreeYUV_SWI
19634 diff -Naur SDL-1.2.15-orig/test/testplatform.c SDL-1.2.15/test/testplatform.c
19635 --- SDL-1.2.15-orig/test/testplatform.c 2015-05-09 17:47:54.279774305 +0200
19636 +++ SDL-1.2.15/test/testplatform.c 2015-05-09 15:09:59.776739493 +0200
19637 @@ -197,6 +197,8 @@
19644 "an unknown operating system! (see SDL_platform.h)"