Fix for the problem that SDL applications exited
[AROS-Contrib.git] / SDL / SDL_main / SDL-1.2.15-aros.diff
blob218693c45eebcb3d7b0b12c71ac0d5803db7a027
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
4 @@ -0,0 +1,58 @@
5 +#!/bin/sh
7 +prefix=/Development
8 +exec_prefix=${prefix}
9 +exec_prefix_set=no
10 +libdir=${exec_prefix}/lib
12 +usage="\
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
18 + exit 1
19 +fi
21 +while test $# -gt 0; do
22 + case "$1" in
23 + -*=*) optarg=`echo "$1" | LC_ALL="C" sed 's/[-_a-zA-Z0-9]*=//'` ;;
24 + *) optarg= ;;
25 + esac
27 + case $1 in
28 + --prefix=*)
29 + prefix=$optarg
30 + if test $exec_prefix_set = no ; then
31 + exec_prefix=$optarg
32 + fi
33 + ;;
34 + --prefix)
35 + echo $prefix
36 + ;;
37 + --exec-prefix=*)
38 + exec_prefix=$optarg
39 + exec_prefix_set=yes
40 + ;;
41 + --exec-prefix)
42 + echo $exec_prefix
43 + ;;
44 + --version)
45 + echo 1.2.15
46 + ;;
47 + --cflags)
48 + echo -I${prefix}/include/SDL -D_GNU_SOURCE=1
49 + ;;
50 + --libs)
51 + echo -L${exec_prefix}/lib -lSDL
52 + ;;
53 + --static-libs)
54 + echo -L${exec_prefix}/lib -lSDL_static -lm -lGL
55 + ;;
56 + *)
57 + echo "${usage}" 1>&2
58 + exit 1
59 + ;;
60 + esac
61 + shift
62 +done
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
66 @@ -0,0 +1,15 @@
67 +# sdl pkg-config source file
69 +prefix=/PROGDIR
70 +exec_prefix=${prefix}
71 +libdir=${exec_prefix}/lib
72 +includedir=${prefix}/include
74 +Name: sdl
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.
76 +Version: 1.2.15
77 +Requires:
78 +Conflicts:
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
85 @@ -0,0 +1,148 @@
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));
104 + return TRUE;
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));
114 + D(
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;
123 +#endif
124 +#ifdef CHECK_LEAKS
125 + LIBBASE->surfaces_allocated = 0;
126 +#endif
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++;
177 + return TRUE;
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;
189 + else
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;
203 + return TRUE;
206 +ADD2INITLIB(GM_UNIQUENAME(LibInit), 0)
207 +ADD2OPENLIB(GM_UNIQUENAME(LibOpen), 0)
208 +ADD2CLOSELIB(GM_UNIQUENAME(LibClose), 0)
210 +#include <errno.h>
211 +#include <signal.h>
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
237 @@ -51,8 +51,9 @@
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++ */
247 #ifdef __cplusplus
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
251 @@ -88,7 +88,11 @@
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);
257 +#else
258 + void (SDLCALL *callback)(void *userdata, Uint8 *stream, int len, struct Library *SDLBase);
259 +#endif
260 void *userdata;
261 } SDL_AudioSpec;
263 @@ -133,7 +137,11 @@
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);
269 +#else
270 + void (SDLCALL *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase);
271 +#endif
272 int filter_index; /**< Current audio conversion function */
273 } SDL_AudioCVT;
275 @@ -147,6 +155,7 @@
276 * You should normally use SDL_Init() or SDL_InitSubSystem().
278 /*@{*/
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);
282 /*@}*/
283 @@ -176,6 +185,7 @@
284 * @sa SDL_AudioSpec
286 extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained);
287 +#endif /* !PROTO_SDL_H */
289 typedef enum {
290 SDL_AUDIO_STOPPED = 0,
291 @@ -184,6 +194,7 @@
292 } SDL_audiostatus;
294 /** Get the current audio state */
295 +#if !defined(PROTO_SDL_H)
296 extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus(void);
299 @@ -213,6 +224,7 @@
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) \
307 @@ -221,6 +233,7 @@
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);
315 @@ -245,7 +258,7 @@
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
324 @@ -255,6 +268,7 @@
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);
332 @@ -273,7 +287,7 @@
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++ */
340 #ifdef __cplusplus
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
344 @@ -111,6 +111,7 @@
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);
352 @@ -191,7 +192,7 @@
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++ */
360 #ifdef __cplusplus
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
364 @@ -0,0 +1,152 @@
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
383 + Sam Lantinga
384 + slouken@libsdl.org
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
398 +/* Endianness */
399 +#if AROS_BIG_ENDIAN
400 +#define SDL_BYTEORDER 4321
401 +#else
402 +#define SDL_BYTEORDER 1234
403 +#endif
406 +/* Comment this if you want to build without any C library requirements */
407 +#define HAVE_LIBC 1
408 +#if HAVE_LIBC
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
417 +#endif
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
434 +#define HAVE_FREE 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
442 +#define HAVE_ABS 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
460 +#define HAVE_ATOI 1
461 +#define HAVE_ATOF 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
474 +#else
475 +/* We may need some replacement for stdarg.h here */
476 +#include <stdarg.h>
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
520 @@ -26,7 +26,9 @@
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
534 @@ -36,6 +36,7 @@
535 extern "C" {
536 #endif
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);
542 @@ -59,6 +60,7 @@
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++ */
549 #ifdef __cplusplus
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
553 @@ -40,9 +40,23 @@
554 * @name Public functions
556 /*@{*/
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, ...) \
564 +({ \
565 + IPTR __args[] = { AROS_PP_VARIADIC_CAST2IPTR(__VA_ARGS__) }; \
566 + SDL_SetErrorA((arg1), __args); \
568 +#else
569 extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...);
570 +#endif
571 extern DECLSPEC char * SDLCALL SDL_GetError(void);
572 extern DECLSPEC void SDLCALL SDL_ClearError(void);
573 +#endif /* !PROTO_SDL_H */
574 /*@}*/
577 @@ -52,6 +66,7 @@
578 /*@{*/
579 #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM)
580 #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED)
582 typedef enum {
583 SDL_ENOMEM,
584 SDL_EFREAD,
585 @@ -60,7 +75,10 @@
586 SDL_UNSUPPORTED,
587 SDL_LASTERROR
588 } SDL_errorcode;
590 +#if !defined(PROTO_SDL_H)
591 extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code);
592 +#endif /* !PROTO_SDL_H */
593 /*@}*/
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
599 @@ -248,7 +248,9 @@
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 */
607 typedef enum {
608 SDL_ADDEVENT,
609 @@ -274,6 +276,7 @@
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);
617 @@ -294,7 +297,7 @@
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 */
624 /*@{*/
625 typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event);
626 @@ -320,6 +323,7 @@
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);
634 @@ -327,6 +331,7 @@
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 */
639 /*@}*/
641 /** @name Event State */
642 @@ -345,7 +350,9 @@
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++ */
651 #ifdef __cplusplus
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
655 @@ -50,6 +50,7 @@
657 * Count the number of joysticks attached to the system
659 +#if !defined(PROTO_SDL_H)
660 extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
663 @@ -132,7 +133,7 @@
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:
672 @@ -154,6 +155,7 @@
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);
680 @@ -176,7 +178,7 @@
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++ */
688 #ifdef __cplusplus
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
692 @@ -79,7 +79,9 @@
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
702 @@ -95,6 +97,7 @@
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);
710 @@ -124,7 +127,7 @@
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++ */
718 #ifdef __cplusplus
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
722 @@ -57,6 +57,7 @@
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);
730 @@ -68,6 +69,7 @@
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++ */
737 #ifdef __cplusplus
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
741 @@ -66,12 +66,14 @@
742 extern "C" {
743 #endif
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 */
753 #ifdef __cplusplus
755 #endif
756 @@ -88,11 +90,13 @@
757 extern "C" {
758 #endif
760 +#if !defined(PROTO_SDL_H)
761 /** Forward declaration so we don't need to include QuickDraw.h */
762 struct QDGlobals;
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 */
768 #ifdef __cplusplus
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
773 @@ -54,6 +54,7 @@
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);
781 @@ -110,6 +111,7 @@
782 * state by passing a 'toggle' value of -1.
784 extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
785 +#endif /* !PROTO_SDL_H */
787 /*@{*/
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
792 @@ -56,13 +56,17 @@
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)
801 /** Lock the mutex
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)
809 /** Unlock the mutex
810 @@ -71,21 +75,22 @@
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 */
821 /*@}*/
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);
835 @@ -121,7 +126,7 @@
837 /** Returns the current count of the semaphore */
838 extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem);
840 +#endif /* !PROTO_SDL_H */
841 /*@}*/
843 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
844 @@ -134,6 +139,7 @@
845 typedef struct SDL_cond SDL_cond;
846 /*@}*/
848 +#if !defined(PROTO_SDL_H)
849 /** Create a condition variable */
850 extern DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void);
852 @@ -164,7 +170,7 @@
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 */
858 /*@}*/
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
864 @@ -60,7 +60,6 @@
866 /** Close and free an allocated SDL_FSops structure */
867 int (SDLCALL *close)(struct SDL_RWops *context);
869 Uint32 type;
870 union {
871 #if defined(__WIN32__) && !defined(__SYMBIAN32__)
872 @@ -89,13 +88,16 @@
873 void *data1;
874 } unknown;
875 } hidden;
877 +#if defined(__AROS__)
878 + struct Library *SDLLib;
879 +#endif
880 } SDL_RWops;
883 /** @name Functions to create SDL_RWops structures from various data sources */
884 /*@{*/
886 +#if !defined(PROTO_SDL_H)
887 extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode);
889 #ifdef HAVE_STDIO_H
890 @@ -107,7 +109,7 @@
892 extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void);
893 extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area);
895 +#endif /* !PROTO_SDL_H */
896 /*@}*/
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)
904 /*@}*/
906 /** @name Read an item of the specified endianness and return in native format */
907 /*@{*/
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);
912 @@ -144,6 +148,7 @@
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 */
917 /*@}*/
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
923 @@ -214,8 +214,9 @@
924 * if ( SDL_GetWMInfo(&info) ) { ... }
925 * @endcode
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++ */
933 #ifdef __cplusplus
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
937 @@ -75,7 +75,9 @@
938 typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
939 #endif
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 */
945 #ifdef __OS2__
946 #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread)
947 @@ -85,10 +87,13 @@
948 #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex)
949 #endif
950 #else
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 */
954 #endif
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,
961 @@ -104,7 +109,7 @@
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++ */
969 #ifdef __cplusplus
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
973 @@ -46,10 +46,12 @@
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);
986 @@ -83,7 +85,9 @@
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
996 @@ -106,6 +110,7 @@
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);
1004 @@ -113,7 +118,7 @@
1005 * Returns a boolean value indicating success.
1007 extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t);
1009 +#endif /* !PROTO_SDL_H */
1010 /*@}*/
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
1016 @@ -80,7 +80,9 @@
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++ */
1025 #ifdef __cplusplus
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
1029 @@ -119,6 +119,9 @@
1031 /** Reference count -- used when freeing surface */
1032 int refcount; /**< Read-mostly */
1033 +#if defined(__AROS__)
1034 + struct Library *SDLLib;
1035 +#endif
1036 } SDL_Surface;
1038 /** @name SDL_Surface Flags
1039 @@ -166,7 +169,6 @@
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? */
1047 @@ -272,6 +274,7 @@
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);
1054 /*@}*/
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 */
1114 typedef enum {
1115 SDL_GRAB_QUERY = -1,
1116 SDL_GRAB_OFF = 0,
1117 SDL_GRAB_ON = 1,
1118 SDL_GRAB_FULLSCREEN /**< Used internally */
1119 } SDL_GrabMode;
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.
1125 @@ -941,7 +957,9 @@
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++ */
1134 #ifdef __cplusplus
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
1139 @@ -0,0 +1,241 @@
1140 +##begin config
1141 +basename SDL
1142 +libbase SDLBase
1143 +libbasetype struct SDLBase
1144 +rootbase_field rootSDLBase
1145 +version 1.215
1146 +date 07.04.2013
1147 +copyright Copyright (C) 1997-2012 Sam Lantinga, 2013 The AROS Development Team
1148 +options peropenerbase
1149 +rellib posixc
1150 +rellib stdc
1151 +##end config
1153 +##begin cdefprivate
1154 +#include "SDL_intern.h"
1155 +##end cdefprivate
1157 +##begin cdef
1158 +#ifndef _SDL_H
1159 +#include <SDL/SDL.h>
1160 +#endif
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>
1189 +##end cdef
1191 +##begin functionlist
1192 +.skip 6
1193 +int SDL_Init(Uint32 flags) (D0)
1194 +const SDL_version * SDL_Linked_Version() ()
1195 +Uint32 SDL_WasInit(Uint32 flags) (D0)
1196 +void SDL_Quit() ()
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)
1216 +.novararg
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)
1231 +.novararg
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)
1380 +##end functionlist
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
1384 @@ -0,0 +1,161 @@
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>
1394 +#ifndef _SDL_H
1395 +#include <SDL/SDL.h>
1396 +#endif
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 {
1431 + int w;
1432 + int h;
1435 +struct SDL_AudioDevice;
1436 +struct SDL_VideoDevice;
1438 +struct SDLBase
1440 + struct Library _lib;
1441 + struct SDLBase *rootSDLBase;
1442 + struct Library *LowLevelBase;
1443 + struct Library *GLBase;
1445 + /** SDL.c **/
1446 + Uint32 SDL_initialized;
1447 + Uint32 ticks_started;
1448 + int surfaces_allocated;
1450 + /**timer/aros/SDL_systimer.c **/
1451 + int timer_alive;
1452 + SDL_Thread *timer_thread;
1453 + struct timerequest *TimerIO;
1454 + clock_t start;
1455 + struct Device *TimerBase;
1456 + struct timeval basetime;
1457 + struct MsgPort *TimerMP;
1458 + struct Task *OwnerTask;
1459 + int fallback;
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;
1502 + int format_idx;
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;
1517 + Uint8 pixels8[2];
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;
1539 + int SDL_numcds;
1541 + /**cdrom/aros/SDL_syscdrom.c **/
1542 + UBYTE *CDList[MAX_DRIVES];
1545 +#endif
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
1549 @@ -0,0 +1,528 @@
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
1568 + Sam Lantinga
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>
1579 +#endif
1581 +#include "SDL_endian.h"
1582 +#include "SDL_ahiaudio.h"
1583 +#include "SDL_timer.h"
1584 +#ifndef __AROS__
1585 +#include "SDL_cgxasm.h"
1586 +#endif
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);
1601 +#else
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);
1613 +#endif
1615 +#if !defined(PROTO_SDL_H)
1616 +/* Internal functions */
1617 +void AHI_Mute(ULONG mute)
1618 +#else
1619 +void AHI_Mute(ULONG mute, struct SDLBase *SDLBase)
1620 +#endif
1622 + AHI_Volume = mute ? 0 : 0x10000;
1625 +/* Audio driver bootstrap functions */
1627 +#if !defined(PROTO_SDL_H)
1628 +static int Audio_Available(void)
1629 +#else
1630 +static int Audio_Available(struct SDLBase *SDLBase)
1631 +#endif
1633 + /* AHI always available */
1635 + return 1;
1638 +#if !defined(PROTO_SDL_H)
1639 +static void Audio_DeleteDevice(SDL_AudioDevice *device)
1640 +#else
1641 +static void Audio_DeleteDevice(SDL_AudioDevice *device, struct SDLBase *SDLBase)
1642 +#endif
1644 + D(bug("[SDL] Audio_DeleteDevice()\n"));
1645 + free(device->hidden);
1646 + free(device);
1649 +#if !defined(PROTO_SDL_H)
1650 +static SDL_AudioDevice *Audio_CreateDevice(int devindex)
1651 +#else
1652 +static SDL_AudioDevice *Audio_CreateDevice(int devindex, struct SDLBase *SDLBase)
1653 +#endif
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();
1668 + if (this)
1669 + free(this);
1671 + if (hidden)
1672 + free(hidden);
1674 + return(0);
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;
1700 + return this;
1703 +AudioBootStrap AHI_bootstrap = {
1704 + "AHI",
1705 + "MorphOS ahi.device SDL audio",
1706 + Audio_Available,
1707 + Audio_CreateDevice
1710 +#if !defined(PROTO_SDL_H)
1711 +void static AHI_WaitAudio(_THIS)
1712 +#else
1713 +void static AHI_WaitAudio(_THIS, struct SDLBase *SDLBase)
1714 +#endif
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)
1735 +#else
1736 +static void AHI_PlayAudio(_THIS, struct SDLBase *SDLBase)
1737 +#endif
1739 + struct SDL_PrivateAudioData *hidden = this->hidden;
1740 + struct AHIRequest *req;
1741 + APTR mixbuf;
1742 + ULONG current, current2;
1743 + LONG mixbufsize;
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;
1772 + do
1774 + *(buf++) -= 128;
1775 + mixbufsize--;
1777 + while (mixbufsize);
1779 + break;
1781 + case AHI_CONVERT_16:
1783 + WORD *buf = mixbuf;
1785 + do
1787 + *(buf++) -= 32768;
1788 + mixbufsize -= 2;
1790 + while (mixbufsize > 0);
1792 + break;
1794 + case AHI_CONVERT_S16LSB:
1795 +#ifndef __AROS__
1796 + copy_and_swap16(mixbuf, mixbuf, mixbufsize / 2);
1797 + break;
1798 +#endif
1799 + case AHI_CONVERT_U16LSB:
1801 + UWORD j, *buf = mixbuf;
1803 + j = hidden->convert == AHI_CONVERT_U16LSB ? 32768 : 0;
1805 + do
1807 + UWORD sample = *buf;
1808 + *buf++ = ((sample >> 8) | (sample << 8)) - j;
1809 + mixbufsize -= 2;
1811 + while (mixbufsize > 0);
1813 + break;
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)
1823 +#else
1824 +static Uint8 *AHI_GetAudioBuf(_THIS, struct SDLBase *SDLBase)
1825 +#endif
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)
1833 +#else
1834 +static void AHI_CloseAudio(_THIS, struct SDLBase *SDLBase)
1835 +#endif
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)
1860 +#else
1861 +static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec, struct SDLBase *SDLBase)
1862 +#endif
1864 + struct SDL_PrivateAudioData *hidden = this->hidden;
1865 +#ifndef __AROS__
1866 + int altivec_align = 0;
1867 +#endif
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
1882 + */
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)
1899 + case AUDIO_U8:
1900 + hidden->convert = AHI_CONVERT_8;
1901 + case AUDIO_S8:
1902 + hidden->bytespersample = 1;
1903 + hidden->type = spec->channels == 1 ? AHIST_M8S : AHIST_S8S;
1904 + break;
1905 +#ifndef __AROS__
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;
1911 + break;
1912 + case AUDIO_U16LSB:
1913 + hidden->convert = AHI_CONVERT_U16LSB;
1914 + hidden->bytespersample = 2;
1915 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1916 + break;
1917 + case AUDIO_U16MSB:
1918 + hidden->convert = AHI_CONVERT_16;
1919 + hidden->bytespersample = 2;
1920 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1921 + break;
1922 + case AUDIO_S16MSB:
1923 + hidden->bytespersample = 2;
1924 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1925 + break;
1926 +#else
1927 +#if AROS_BIG_ENDIAN
1928 + case AUDIO_S16LSB:
1929 + // SWAP
1930 + hidden->convert = AHI_CONVERT_S16LSB;
1931 + hidden->bytespersample = 2;
1932 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1933 + break;
1934 + case AUDIO_U16LSB:
1935 + // SWAP + SIGN
1936 + hidden->convert = AHI_CONVERT_U16LSB;
1937 + hidden->bytespersample = 2;
1938 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1939 + break;
1940 + case AUDIO_U16MSB:
1941 + // SIGN
1942 + hidden->convert = AHI_CONVERT_16;
1943 + hidden->bytespersample = 2;
1944 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1945 + break;
1946 + case AUDIO_S16MSB:
1947 + // NOTHING TO BE DONE
1948 + hidden->bytespersample = 2;
1949 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1950 + break;
1951 +#else
1952 + case AUDIO_S16LSB:
1953 + // NOTHING TO BE DONE
1954 + hidden->bytespersample = 2;
1955 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1956 + break;
1957 + case AUDIO_U16LSB:
1958 + // SIGN
1959 + hidden->convert = AHI_CONVERT_16;
1960 + hidden->bytespersample = 2;
1961 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1962 + break;
1963 + case AUDIO_U16MSB:
1964 + // SWAP + SIGN
1965 + hidden->convert = AHI_CONVERT_U16LSB;
1966 + hidden->bytespersample = 2;
1967 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1968 + break;
1969 + case AUDIO_S16MSB:
1970 + // SWAP
1971 + hidden->convert = AHI_CONVERT_S16LSB;
1972 + hidden->bytespersample = 2;
1973 + hidden->type = spec->channels == 1 ? AHIST_M16S : AHIST_S16S;
1974 + break;
1975 +#endif
1976 +#endif
1978 + default:
1979 + SDL_SetError("Unsupported audio format");
1980 + return(-1);
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);
1995 + return -1;
1998 + hidden->have_ahi = 1;
1999 +#ifndef __AROS__
2000 + /* Align size to multiples of 16 bytes */
2001 + if (altivec_align)
2002 + spec->size = (spec->size + 15) & ~15;
2003 +#endif
2004 + /* Set output frequency and size */
2005 + hidden->freq = spec->freq;
2006 + hidden->size = spec->size;
2008 + /* Allocate mixing buffer */
2009 +#ifndef __AROS__
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);
2015 + else
2016 +#endif
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;
2037 + return -1;
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. :-) */
2052 + return 0;
2055 +#if !defined(PROTO_SDL_H)
2056 +static void AHI_ThreadInit(_THIS)
2057 +#else
2058 +static void AHI_ThreadInit(_THIS, struct SDLBase *SDLBase)
2059 +#endif
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
2081 @@ -0,0 +1,64 @@
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
2100 + Sam Lantinga
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"
2116 +#include "SDL.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;
2131 + Uint8 have_ahi;
2132 + Uint8 playing;
2133 + Uint16 convert;
2136 +enum
2138 + AHI_NO_CONVERSION,
2139 + AHI_CONVERT_8,
2140 + AHI_CONVERT_16,
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
2149 @@ -21,6 +21,11 @@
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>
2156 +#endif
2158 #include "SDL_config.h"
2160 /* Output raw audio data to a file. */
2161 @@ -47,11 +52,19 @@
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);
2171 +#else
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);
2177 +#endif
2179 static const char *DISKAUD_GetOutputFilename(void)
2181 @@ -60,7 +73,11 @@
2184 /* Audio driver bootstrap functions */
2185 +#if !defined(PROTO_SDL_H)
2186 static int DISKAUD_Available(void)
2187 +#else
2188 +static int DISKAUD_Available(struct SDLBase *SDLBase)
2189 +#endif
2191 const char *envr = SDL_getenv("SDL_AUDIODRIVER");
2192 if (envr && (SDL_strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) {
2193 @@ -69,13 +86,21 @@
2194 return(0);
2197 +#if !defined(PROTO_SDL_H)
2198 static void DISKAUD_DeleteDevice(SDL_AudioDevice *device)
2199 +#else
2200 +static void DISKAUD_DeleteDevice(SDL_AudioDevice *device, struct SDLBase *SDLBase)
2201 +#endif
2203 SDL_free(device->hidden);
2204 SDL_free(device);
2207 +#if !defined(PROTO_SDL_H)
2208 static SDL_AudioDevice *DISKAUD_CreateDevice(int devindex)
2209 +#else
2210 +static SDL_AudioDevice *DISKAUD_CreateDevice(int devindex, struct SDLBase *SDLBase)
2211 +#endif
2213 SDL_AudioDevice *this;
2214 const char *envr;
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)
2221 +#else
2222 +static void DISKAUD_WaitAudio(_THIS, struct SDLBase *SDLBase)
2223 +#endif
2225 SDL_Delay(this->hidden->write_delay);
2228 +#if !defined(PROTO_SDL_H)
2229 static void DISKAUD_PlayAudio(_THIS)
2230 +#else
2231 +static void DISKAUD_PlayAudio(_THIS, struct SDLBase *SDLBase)
2232 +#endif
2234 int written;
2236 @@ -140,12 +173,20 @@
2237 #endif
2240 +#if !defined(PROTO_SDL_H)
2241 static Uint8 *DISKAUD_GetAudioBuf(_THIS)
2242 +#else
2243 +static Uint8 *DISKAUD_GetAudioBuf(_THIS, struct SDLBase *SDLBase)
2244 +#endif
2246 return(this->hidden->mixbuf);
2249 +#if !defined(PROTO_SDL_H)
2250 static void DISKAUD_CloseAudio(_THIS)
2251 +#else
2252 +static void DISKAUD_CloseAudio(_THIS, struct SDLBase *SDLBase)
2253 +#endif
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)
2263 +#else
2264 +static int DISKAUD_OpenAudio(_THIS, SDL_AudioSpec *spec, struct SDLBase *SDLBase)
2265 +#endif
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
2272 @@ -21,6 +21,11 @@
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>
2279 +#endif
2281 #include "SDL_config.h"
2283 /* Output audio to nowhere... */
2284 @@ -37,14 +42,28 @@
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);
2294 +#else
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);
2302 +#endif
2304 /* Audio driver bootstrap functions */
2305 +#if !defined(PROTO_SDL_H)
2306 static int DUMMYAUD_Available(void)
2307 +#else
2308 +static int DUMMYAUD_Available(struct SDLBase *SDLBase)
2309 +#endif
2311 const char *envr = SDL_getenv("SDL_AUDIODRIVER");
2312 if (envr && (SDL_strcmp(envr, DUMMYAUD_DRIVER_NAME) == 0)) {
2313 @@ -53,13 +72,21 @@
2314 return(0);
2317 +#if !defined(PROTO_SDL_H)
2318 static void DUMMYAUD_DeleteDevice(SDL_AudioDevice *device)
2319 +#else
2320 +static void DUMMYAUD_DeleteDevice(SDL_AudioDevice *device, struct SDLBase *SDLBase)
2321 +#endif
2323 SDL_free(device->hidden);
2324 SDL_free(device);
2327 +#if !defined(PROTO_SDL_H)
2328 static SDL_AudioDevice *DUMMYAUD_CreateDevice(int devindex)
2329 +#else
2330 +static SDL_AudioDevice *DUMMYAUD_CreateDevice(int devindex, struct SDLBase *SDLBase)
2331 +#endif
2333 SDL_AudioDevice *this;
2335 @@ -97,7 +124,11 @@
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)
2341 +#else
2342 +static void DUMMYAUD_WaitAudio(_THIS, struct SDLBase *SDLBase)
2343 +#endif
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)
2353 +#else
2354 +static void DUMMYAUD_PlayAudio(_THIS, struct SDLBase *SDLBase)
2355 +#endif
2357 /* no-op...this is a null driver. */
2360 +#if !defined(PROTO_SDL_H)
2361 static Uint8 *DUMMYAUD_GetAudioBuf(_THIS)
2362 +#else
2363 +static Uint8 *DUMMYAUD_GetAudioBuf(_THIS, struct SDLBase *SDLBase)
2364 +#endif
2366 return(this->hidden->mixbuf);
2369 +#if !defined(PROTO_SDL_H)
2370 static void DUMMYAUD_CloseAudio(_THIS)
2371 +#else
2372 +static void DUMMYAUD_CloseAudio(_THIS, struct SDLBase *SDLBase)
2373 +#endif
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)
2383 +#else
2384 +static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec, struct SDLBase *SDLBase)
2385 +#endif
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
2392 @@ -19,6 +19,12 @@
2393 Sam Lantinga
2394 slouken@libsdl.org
2397 +#if defined (SDL_AROS_SHARED)
2398 +#define __NOLIBBASE__
2399 +#include <proto/SDL.h>
2400 +#endif
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,
2408 #endif
2409 +#if SDL_AUDIO_DRIVER_AHI
2410 + &AHI_bootstrap,
2411 +#endif
2412 NULL
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;
2421 +#endif
2422 /* Various local functions */
2423 int SDL_AudioInit(const char *driver_name);
2424 void SDL_AudioQuit(void);
2425 +#else
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
2431 +#endif
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)
2446 +#else
2447 +int SDLCALL SDL_RunAudio(struct SDLBase *SDLBase)
2448 +#endif
2450 +#if !defined(PROTO_SDL_H)
2451 SDL_AudioDevice *audio = (SDL_AudioDevice *)audiop;
2452 +#else
2453 + SDL_AudioDevice *audio = current_audio;
2454 +#endif
2455 Uint8 *stream;
2456 int stream_len;
2457 void *udata;
2458 +#if !defined(PROTO_SDL_H)
2459 void (SDLCALL *fill)(void *userdata,Uint8 *stream, int len);
2460 +#else
2461 + void (SDLCALL *fill)(void *userdata,Uint8 *stream, int len, struct Library *SDLBase);
2462 +#endif
2463 int silence;
2465 /* Perform any thread setup */
2466 if ( audio->ThreadInit ) {
2467 +#if !defined(PROTO_SDL_H)
2468 audio->ThreadInit(audio);
2469 +#else
2470 + audio->ThreadInit(audio, SDLBase);
2471 +#endif
2473 audio->threadid = SDL_ThreadID();
2475 @@ -185,7 +232,11 @@
2476 continue;
2478 } else {
2479 +#if !defined(PROTO_SDL_H)
2480 stream = audio->GetAudioBuf(audio);
2481 +#else
2482 + stream = audio->GetAudioBuf(audio, SDLBase);
2483 +#endif
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);
2493 +#else
2494 + (*fill)(udata, stream, stream_len, (struct Library *)SDLBase);
2495 +#endif
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);
2504 +#else
2505 + stream = audio->GetAudioBuf(audio, SDLBase);
2506 +#endif
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);
2516 +#else
2517 + audio->PlayAudio(audio, SDLBase);
2518 +#endif
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);
2524 } else {
2525 +#if !defined(PROTO_SDL_H)
2526 audio->WaitAudio(audio);
2527 +#else
2528 + audio->WaitAudio(audio, SDLBase);
2529 +#endif
2533 /* Wait for the audio to drain.. */
2534 if ( audio->WaitDone ) {
2535 +#if !defined(PROTO_SDL_H)
2536 audio->WaitDone(audio);
2537 +#else
2538 + audio->WaitDone(audio, SDLBase);
2539 +#endif
2542 #ifdef __OS2__
2543 @@ -236,7 +307,11 @@
2544 return(0);
2547 +#if !defined(PROTO_SDL_H)
2548 static void SDL_LockAudio_Default(SDL_AudioDevice *audio)
2549 +#else
2550 +static void SDL_LockAudio_Default(SDL_AudioDevice *audio, struct SDLBase *SDLBase)
2551 +#endif
2553 if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
2554 return;
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)
2561 +#else
2562 +static void SDL_UnlockAudio_Default(SDL_AudioDevice *audio, struct SDLBase *SDLBase)
2563 +#endif
2565 if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
2566 return;
2567 @@ -297,8 +376,16 @@
2568 return format;
2571 +#if !defined(PROTO_SDL_H)
2572 int SDL_AudioInit(const char *driver_name)
2574 +#else
2575 +AROS_LH1(int, SDL_AudioInit,
2576 + AROS_LHA(const char *, driver_name, A0),
2577 + struct SDLBase *, SDLBase, 125, SDL)
2579 + AROS_LIBFUNC_INIT
2580 +#endif
2581 SDL_AudioDevice *audio;
2582 int i = 0, idx;
2584 @@ -349,16 +436,26 @@
2585 #endif
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);
2591 +#else
2592 + if ( bootstrap[i]->available(SDLBase) ) {
2593 + audio=bootstrap[i]->create(idx, SDLBase);
2594 +#endif
2595 break;
2599 } else {
2600 for ( i=0; bootstrap[i]; ++i ) {
2601 +#if !defined(PROTO_SDL_H)
2602 if ( bootstrap[i]->available() ) {
2603 audio = bootstrap[i]->create(idx);
2604 +#else
2605 + if ( bootstrap[i]->available(SDLBase) ) {
2606 + audio = bootstrap[i]->create(idx, SDLBase);
2607 +#endif
2608 if ( audio != NULL ) {
2609 break;
2611 @@ -383,19 +480,43 @@
2614 return(0);
2615 +#if defined(PROTO_SDL_H)
2616 + AROS_LIBFUNC_EXIT
2617 +#endif
2620 +#if !defined(PROTO_SDL_H)
2621 char *SDL_AudioDriverName(char *namebuf, int maxlen)
2623 +#else
2624 +AROS_LH2(char *, SDL_AudioDriverName,
2625 + AROS_LHA(char *, namebuf, A0),
2626 + AROS_LHA(int, maxlen, D0),
2627 + struct SDLBase *, SDLBase, 126, SDL)
2629 + AROS_LIBFUNC_INIT
2630 +#endif
2631 if ( current_audio != NULL ) {
2632 SDL_strlcpy(namebuf, current_audio->name, maxlen);
2633 return(namebuf);
2635 return(NULL);
2636 +#if defined(PROTO_SDL_H)
2637 + AROS_LIBFUNC_EXIT
2638 +#endif
2641 +#if !defined(PROTO_SDL_H)
2642 int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
2644 +#else
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)
2650 + AROS_LIBFUNC_INIT
2651 +#endif
2652 SDL_AudioDevice *audio;
2653 const char *env;
2655 @@ -494,9 +615,14 @@
2656 audio->convert.needed = 0;
2657 audio->enabled = 1;
2658 audio->paused = 1;
2660 +#ifdef ENABLE_AHI
2661 + has_obtained_spec = obtained ? 1 : 0;
2662 +#endif
2663 +#if !defined(PROTO_SDL_H)
2664 audio->opened = audio->OpenAudio(audio, &audio->spec)+1;
2666 +#else
2667 + audio->opened = audio->OpenAudio(audio, &audio->spec, SDLBase)+1;
2668 +#endif
2669 if ( ! audio->opened ) {
2670 SDL_CloseAudio();
2671 return(-1);
2672 @@ -552,7 +678,11 @@
2673 #undef SDL_CreateThread
2674 audio->thread = SDL_CreateThread(SDL_RunAudio, audio, NULL, NULL);
2675 #else
2676 +#if !defined(PROTO_SDL_H)
2677 audio->thread = SDL_CreateThread(SDL_RunAudio, audio);
2678 +#else
2679 + audio->thread = SDL_CreateThread(SDL_RunAudio, SDLBase);
2680 +#endif
2681 #endif
2682 if ( audio->thread == NULL ) {
2683 SDL_CloseAudio();
2684 @@ -567,10 +697,20 @@
2687 return(0);
2688 +#if defined(PROTO_SDL_H)
2689 + AROS_LIBFUNC_EXIT
2690 +#endif
2693 +#if !defined(PROTO_SDL_H)
2694 SDL_audiostatus SDL_GetAudioStatus(void)
2696 +#else
2697 +AROS_LH0(SDL_audiostatus, SDL_GetAudioStatus,
2698 + struct SDLBase *, SDLBase, 129, SDL)
2700 + AROS_LIBFUNC_INIT
2701 +#endif
2702 SDL_AudioDevice *audio = current_audio;
2703 SDL_audiostatus status;
2705 @@ -583,44 +723,103 @@
2708 return(status);
2709 +#if defined(PROTO_SDL_H)
2710 + AROS_LIBFUNC_EXIT
2711 +#endif
2714 +#if !defined(PROTO_SDL_H)
2715 void SDL_PauseAudio (int pause_on)
2717 +#else
2718 +AROS_LH1(void, SDL_PauseAudio,
2719 + AROS_LHA(int, pause_on, D0),
2720 + struct SDLBase *, SDLBase, 130, SDL)
2722 + AROS_LIBFUNC_INIT
2723 +#endif
2724 SDL_AudioDevice *audio = current_audio;
2726 if ( audio ) {
2727 audio->paused = pause_on;
2729 +#if defined(PROTO_SDL_H)
2730 + AROS_LIBFUNC_EXIT
2731 +#endif
2734 +#if !defined(PROTO_SDL_H)
2735 void SDL_LockAudio (void)
2737 +#else
2738 +AROS_LH0(void, SDL_LockAudio,
2739 + struct SDLBase *, SDLBase, 137, SDL)
2741 + AROS_LIBFUNC_INIT
2742 +#endif
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);
2749 +#else
2750 + audio->LockAudio(audio, SDLBase);
2751 +#endif
2753 +#if defined(PROTO_SDL_H)
2754 + AROS_LIBFUNC_EXIT
2755 +#endif
2758 +#if !defined(PROTO_SDL_H)
2759 void SDL_UnlockAudio (void)
2761 +#else
2762 +AROS_LH0(void, SDL_UnlockAudio,
2763 + struct SDLBase *, SDLBase, 138, SDL)
2765 + AROS_LIBFUNC_INIT
2766 +#endif
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);
2773 +#else
2774 + audio->UnlockAudio(audio, SDLBase);
2775 +#endif
2777 +#if defined(PROTO_SDL_H)
2778 + AROS_LIBFUNC_EXIT
2779 +#endif
2782 +#if !defined(PROTO_SDL_H)
2783 void SDL_CloseAudio (void)
2785 +#else
2786 +AROS_LH0(void, SDL_CloseAudio,
2787 + struct SDLBase *, SDLBase, 139, SDL)
2789 + AROS_LIBFUNC_INIT
2790 +#endif
2791 SDL_QuitSubSystem(SDL_INIT_AUDIO);
2792 +#if defined(PROTO_SDL_H)
2793 + AROS_LIBFUNC_EXIT
2794 +#endif
2797 +#if !defined(PROTO_SDL_H)
2798 void SDL_AudioQuit(void)
2800 +#else
2801 +AROS_LH0(void, SDL_AudioQuit,
2802 + struct SDLBase *, SDLBase, 127, SDL)
2804 + AROS_LIBFUNC_INIT
2805 +#endif
2806 SDL_AudioDevice *audio = current_audio;
2808 if ( audio ) {
2809 @@ -639,28 +838,31 @@
2812 if ( audio->opened ) {
2813 +#if !defined(PROTO_SDL_H)
2814 audio->CloseAudio(audio);
2815 +#else
2816 + audio->CloseAudio(audio, SDLBase);
2817 +#endif
2818 audio->opened = 0;
2820 /* Free the driver data */
2821 +#if !defined(PROTO_SDL_H)
2822 audio->free(audio);
2823 +#else
2824 + audio->free(audio, SDLBase);
2825 +#endif
2826 current_audio = NULL;
2828 +#if defined(PROTO_SDL_H)
2829 + AROS_LIBFUNC_EXIT
2830 +#endif
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)
2847 +#else
2848 +Uint16 SDL_FirstAudioFormatI(Uint16 format, struct SDLBase *SDLBase)
2849 +#endif
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)
2859 +#else
2860 +Uint16 SDL_NextAudioFormatI(struct SDLBase *SDLBase)
2861 +#endif
2863 if ( (format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS) ) {
2864 return(0);
2865 @@ -694,10 +900,25 @@
2866 spec->size *= spec->samples;
2869 +#if !defined(PROTO_SDL_H)
2870 void SDL_Audio_SetCaption(const char *caption)
2872 +#else
2873 +AROS_LH1(void, SDL_Audio_SetCaption,
2874 + AROS_LHA(const char *, caption, A0),
2875 + struct SDLBase *, SDLBase, 131, SDL)
2877 + AROS_LIBFUNC_INIT
2878 +#endif
2879 if ((current_audio) && (current_audio->SetCaption)) {
2880 +#if !defined(PROTO_SDL_H)
2881 current_audio->SetCaption(current_audio, caption);
2882 +#else
2883 + current_audio->SetCaption(current_audio, caption, SDLBase);
2884 +#endif
2886 +#if defined(PROTO_SDL_H)
2887 + AROS_LIBFUNC_EXIT
2888 +#endif
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
2894 @@ -23,6 +23,8 @@
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);
2903 @@ -30,6 +32,16 @@
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);
2909 +#else
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)
2918 +#endif
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
2924 @@ -19,6 +19,11 @@
2925 Sam Lantinga
2926 slouken@libsdl.org
2928 +#if defined (SDL_AROS_SHARED)
2929 +#define __NOLIBBASE__
2930 +#include <proto/SDL.h>
2931 +#endif
2933 #include "SDL_config.h"
2935 /* Functions for audio drivers to perform runtime conversion of audio format */
2936 @@ -27,7 +32,14 @@
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)
2942 +#else
2943 +#include "SDL_intern.h"
2945 +#define SDL_ConvertMono SDL_ConvertMonoI
2946 +void SDLCALL SDL_ConvertMonoI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
2947 +#endif
2949 int i;
2950 Sint32 sample;
2951 @@ -129,12 +141,21 @@
2953 cvt->len_cvt /= 2;
2954 if ( cvt->filters[++cvt->filter_index] ) {
2955 +#if !defined(PROTO_SDL_H)
2956 cvt->filters[cvt->filter_index](cvt, format);
2957 +#else
2958 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
2959 +#endif
2963 /* Discard top 4 channels */
2964 +#if !defined(PROTO_SDL_H)
2965 void SDLCALL SDL_ConvertStrip(SDL_AudioCVT *cvt, Uint16 format)
2966 +#else
2967 +#define SDL_ConvertStrip SDL_ConvertStripI
2968 +void SDLCALL SDL_ConvertStripI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
2969 +#endif
2971 int i;
2972 Sint32 lsample, rsample;
2973 @@ -244,13 +265,22 @@
2975 cvt->len_cvt /= 3;
2976 if ( cvt->filters[++cvt->filter_index] ) {
2977 +#if !defined(PROTO_SDL_H)
2978 cvt->filters[cvt->filter_index](cvt, format);
2979 +#else
2980 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
2981 +#endif
2986 /* Discard top 2 channels of 6 */
2987 +#if !defined(PROTO_SDL_H)
2988 void SDLCALL SDL_ConvertStrip_2(SDL_AudioCVT *cvt, Uint16 format)
2989 +#else
2990 +#define SDL_ConvertStrip_2 SDL_ConvertStrip_2I
2991 +void SDLCALL SDL_ConvertStrip_2I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
2992 +#endif
2994 int i;
2995 Sint32 lsample, rsample;
2996 @@ -360,12 +390,21 @@
2998 cvt->len_cvt /= 2;
2999 if ( cvt->filters[++cvt->filter_index] ) {
3000 +#if !defined(PROTO_SDL_H)
3001 cvt->filters[cvt->filter_index](cvt, format);
3002 +#else
3003 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3004 +#endif
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)
3011 +#else
3012 +#define SDL_ConvertStereo SDL_ConvertStereoI
3013 +void SDLCALL SDL_ConvertStereoI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3014 +#endif
3016 int i;
3018 @@ -397,13 +436,22 @@
3020 cvt->len_cvt *= 2;
3021 if ( cvt->filters[++cvt->filter_index] ) {
3022 +#if !defined(PROTO_SDL_H)
3023 cvt->filters[cvt->filter_index](cvt, format);
3024 +#else
3025 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3026 +#endif
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)
3034 +#else
3035 +#define SDL_ConvertSurround SDL_ConvertSurroundI
3036 +void SDLCALL SDL_ConvertSurroundI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3037 +#endif
3039 int i;
3041 @@ -574,13 +622,22 @@
3043 cvt->len_cvt *= 3;
3044 if ( cvt->filters[++cvt->filter_index] ) {
3045 +#if !defined(PROTO_SDL_H)
3046 cvt->filters[cvt->filter_index](cvt, format);
3047 +#else
3048 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3049 +#endif
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)
3057 +#else
3058 +#define SDL_ConvertSurround_4 SDL_ConvertSurround_4I
3059 +void SDLCALL SDL_ConvertSurround_4I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3060 +#endif
3062 int i;
3064 @@ -727,13 +784,22 @@
3066 cvt->len_cvt *= 2;
3067 if ( cvt->filters[++cvt->filter_index] ) {
3068 +#if !defined(PROTO_SDL_H)
3069 cvt->filters[cvt->filter_index](cvt, format);
3070 +#else
3071 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3072 +#endif
3077 /* Convert 8-bit to 16-bit - LSB */
3078 +#if !defined(PROTO_SDL_H)
3079 void SDLCALL SDL_Convert16LSB(SDL_AudioCVT *cvt, Uint16 format)
3080 +#else
3081 +#define SDL_Convert16LSB SDL_Convert16LSBI
3082 +void SDLCALL SDL_Convert16LSBI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3083 +#endif
3085 int i;
3086 Uint8 *src, *dst;
3087 @@ -752,11 +818,20 @@
3088 format = ((format & ~0x0008) | AUDIO_U16LSB);
3089 cvt->len_cvt *= 2;
3090 if ( cvt->filters[++cvt->filter_index] ) {
3091 +#if !defined(PROTO_SDL_H)
3092 cvt->filters[cvt->filter_index](cvt, format);
3093 +#else
3094 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3095 +#endif
3098 /* Convert 8-bit to 16-bit - MSB */
3099 +#if !defined(PROTO_SDL_H)
3100 void SDLCALL SDL_Convert16MSB(SDL_AudioCVT *cvt, Uint16 format)
3101 +#else
3102 +#define SDL_Convert16MSB SDL_Convert16MSBI
3103 +void SDLCALL SDL_Convert16MSBI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3104 +#endif
3106 int i;
3107 Uint8 *src, *dst;
3108 @@ -775,12 +850,21 @@
3109 format = ((format & ~0x0008) | AUDIO_U16MSB);
3110 cvt->len_cvt *= 2;
3111 if ( cvt->filters[++cvt->filter_index] ) {
3112 +#if !defined(PROTO_SDL_H)
3113 cvt->filters[cvt->filter_index](cvt, format);
3114 +#else
3115 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3116 +#endif
3120 /* Convert 16-bit to 8-bit */
3121 +#if !defined(PROTO_SDL_H)
3122 void SDLCALL SDL_Convert8(SDL_AudioCVT *cvt, Uint16 format)
3123 +#else
3124 +#define SDL_Convert8 SDL_Convert8I
3125 +void SDLCALL SDL_Convert8I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3126 +#endif
3128 int i;
3129 Uint8 *src, *dst;
3130 @@ -801,12 +885,21 @@
3131 format = ((format & ~0x9010) | AUDIO_U8);
3132 cvt->len_cvt /= 2;
3133 if ( cvt->filters[++cvt->filter_index] ) {
3134 +#if !defined(PROTO_SDL_H)
3135 cvt->filters[cvt->filter_index](cvt, format);
3136 +#else
3137 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3138 +#endif
3142 /* Toggle signed/unsigned */
3143 +#if !defined(PROTO_SDL_H)
3144 void SDLCALL SDL_ConvertSign(SDL_AudioCVT *cvt, Uint16 format)
3145 +#else
3146 +#define SDL_ConvertSign SDL_ConvertSignI
3147 +void SDLCALL SDL_ConvertSignI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3148 +#endif
3150 int i;
3151 Uint8 *data;
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);
3158 +#else
3159 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3160 +#endif
3164 /* Toggle endianness */
3165 +#if !defined(PROTO_SDL_H)
3166 void SDLCALL SDL_ConvertEndian(SDL_AudioCVT *cvt, Uint16 format)
3167 +#else
3168 +#define SDL_ConvertEndian SDL_ConvertEndianI
3169 +void SDLCALL SDL_ConvertEndianI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3170 +#endif
3172 int i;
3173 Uint8 *data, tmp;
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);
3180 +#else
3181 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3182 +#endif
3186 /* Convert rate up by multiple of 2 */
3187 +#if !defined(PROTO_SDL_H)
3188 void SDLCALL SDL_RateMUL2(SDL_AudioCVT *cvt, Uint16 format)
3189 +#else
3190 +#define SDL_RateMUL2 SDL_RateMUL2I
3191 +void SDLCALL SDL_RateMUL2(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3192 +#endif
3194 int i;
3195 Uint8 *src, *dst;
3196 @@ -889,13 +1000,22 @@
3198 cvt->len_cvt *= 2;
3199 if ( cvt->filters[++cvt->filter_index] ) {
3200 +#if !defined(PROTO_SDL_H)
3201 cvt->filters[cvt->filter_index](cvt, format);
3202 +#else
3203 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3204 +#endif
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)
3212 +#else
3213 +#define SDL_RateMUL2_c2 SDL_RateMUL2_c2I
3214 +void SDLCALL SDL_RateMUL2_c2I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3215 +#endif
3217 int i;
3218 Uint8 *src, *dst;
3219 @@ -933,12 +1053,21 @@
3221 cvt->len_cvt *= 2;
3222 if ( cvt->filters[++cvt->filter_index] ) {
3223 +#if !defined(PROTO_SDL_H)
3224 cvt->filters[cvt->filter_index](cvt, format);
3225 +#else
3226 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3227 +#endif
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)
3234 +#else
3235 +#define SDL_RateMUL2_c4 SDL_RateMUL2_c4I
3236 +void SDLCALL SDL_RateMUL2_c4I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3237 +#endif
3239 int i;
3240 Uint8 *src, *dst;
3241 @@ -988,13 +1117,22 @@
3243 cvt->len_cvt *= 2;
3244 if ( cvt->filters[++cvt->filter_index] ) {
3245 +#if !defined(PROTO_SDL_H)
3246 cvt->filters[cvt->filter_index](cvt, format);
3247 +#else
3248 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3249 +#endif
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)
3257 +#else
3258 +#define SDL_RateMUL2_c6 SDL_RateMUL2_c6I
3259 +void SDLCALL SDL_RateMUL2_c6I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3260 +#endif
3262 int i;
3263 Uint8 *src, *dst;
3264 @@ -1056,12 +1194,21 @@
3266 cvt->len_cvt *= 2;
3267 if ( cvt->filters[++cvt->filter_index] ) {
3268 +#if !defined(PROTO_SDL_H)
3269 cvt->filters[cvt->filter_index](cvt, format);
3270 +#else
3271 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3272 +#endif
3276 /* Convert rate down by multiple of 2 */
3277 +#if !defined(PROTO_SDL_H)
3278 void SDLCALL SDL_RateDIV2(SDL_AudioCVT *cvt, Uint16 format)
3279 +#else
3280 +#define SDL_RateDIV2 SDL_RateDIV2I
3281 +void SDLCALL SDL_RateDIV2I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3282 +#endif
3284 int i;
3285 Uint8 *src, *dst;
3286 @@ -1090,13 +1237,22 @@
3288 cvt->len_cvt /= 2;
3289 if ( cvt->filters[++cvt->filter_index] ) {
3290 +#if !defined(PROTO_SDL_H)
3291 cvt->filters[cvt->filter_index](cvt, format);
3292 +#else
3293 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3294 +#endif
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)
3302 +#else
3303 +#define SDL_RateDIV2_c2 SDL_RateDIV2_c2I
3304 +void SDLCALL SDL_RateDIV2_c2I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3305 +#endif
3307 int i;
3308 Uint8 *src, *dst;
3309 @@ -1128,13 +1284,22 @@
3311 cvt->len_cvt /= 2;
3312 if ( cvt->filters[++cvt->filter_index] ) {
3313 +#if !defined(PROTO_SDL_H)
3314 cvt->filters[cvt->filter_index](cvt, format);
3315 +#else
3316 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3317 +#endif
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)
3325 +#else
3326 +#define SDL_RateDIV2_c4 SDL_RateDIV2_c4I
3327 +void SDLCALL SDL_RateDIV2_c4I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3328 +#endif
3330 int i;
3331 Uint8 *src, *dst;
3332 @@ -1172,12 +1337,21 @@
3334 cvt->len_cvt /= 2;
3335 if ( cvt->filters[++cvt->filter_index] ) {
3336 +#if !defined(PROTO_SDL_H)
3337 cvt->filters[cvt->filter_index](cvt, format);
3338 +#else
3339 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3340 +#endif
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)
3347 +#else
3348 +#define SDL_RateDIV2_c6 SDL_RateDIV2_c6I
3349 +void SDLCALL SDL_RateDIV2_c6I(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3350 +#endif
3352 int i;
3353 Uint8 *src, *dst;
3354 @@ -1221,12 +1395,21 @@
3356 cvt->len_cvt /= 2;
3357 if ( cvt->filters[++cvt->filter_index] ) {
3358 +#if !defined(PROTO_SDL_H)
3359 cvt->filters[cvt->filter_index](cvt, format);
3360 +#else
3361 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3362 +#endif
3366 /* Very slow rate conversion routine */
3367 +#if !defined(PROTO_SDL_H)
3368 void SDLCALL SDL_RateSLOW(SDL_AudioCVT *cvt, Uint16 format)
3369 +#else
3370 +#define SDL_RateSLOW SDL_RateSLOWI
3371 +void SDLCALL SDL_RateSLOWI(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase)
3372 +#endif
3374 double ipos;
3375 int i, clen;
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);
3382 +#else
3383 + cvt->filters[cvt->filter_index](cvt, format, SDLBase);
3384 +#endif
3388 +#if !defined(PROTO_SDL_H)
3389 int SDL_ConvertAudio(SDL_AudioCVT *cvt)
3391 +#else
3392 +AROS_LH1(int, SDL_ConvertAudio,
3393 + AROS_LHA(SDL_AudioCVT *, cvt, A0),
3394 + struct Library *, SDLBase, 135, SDL)
3396 + AROS_LIBFUNC_INIT
3397 +#endif
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);
3407 +#else
3408 + cvt->filters[0](cvt, cvt->src_format, SDLBase);
3409 +#endif
3410 return(0);
3411 +#if defined(PROTO_SDL_H)
3412 + AROS_LIBFUNC_EXIT
3413 +#endif
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)
3426 +#else
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)
3437 + AROS_LIBFUNC_INIT
3438 +#endif
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;
3444 int len_mult;
3445 double len_ratio;
3446 +#if !defined(PROTO_SDL_H)
3447 void (SDLCALL *rate_cvt)(SDL_AudioCVT *cvt, Uint16 format);
3448 +#else
3449 + void (SDLCALL *rate_cvt)(SDL_AudioCVT *cvt, Uint16 format, struct Library *SDLBase);
3450 +#endif
3452 if ( src_rate > dst_rate ) {
3453 hi_rate = src_rate;
3454 @@ -1507,4 +1727,7 @@
3455 cvt->filters[cvt->filter_index] = NULL;
3457 return(cvt->needed);
3458 +#if defined(PROTO_SDL_H)
3459 + AROS_LIBFUNC_EXIT
3460 +#endif
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
3465 @@ -19,6 +19,11 @@
3466 Sam Lantinga
3467 slouken@libsdl.org
3469 +#if defined (SDL_AROS_SHARED)
3470 +#define __NOLIBBASE__
3471 +#include <proto/SDL.h>
3472 +#endif
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
3480 @@ -19,6 +19,11 @@
3481 Sam Lantinga
3482 slouken@libsdl.org
3484 +#if defined (SDL_AROS_SHARED)
3485 +#define __NOLIBBASE__
3486 +#include <proto/SDL.h>
3487 +#endif
3489 #include "SDL_config.h"
3491 /* This provides the default mixing callback for the SDL audio routines */
3492 @@ -31,6 +36,12 @@
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
3500 +#endif
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.
3505 @@ -90,8 +101,19 @@
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)
3512 +#else
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)
3520 + AROS_LIBFUNC_INIT
3521 +#endif
3522 Uint16 format;
3524 if ( volume == 0 ) {
3525 @@ -260,5 +282,8 @@
3526 SDL_SetError("SDL_MixAudio(): unknown audio format");
3527 return;
3529 +#if defined(PROTO_SDL_H)
3530 + AROS_LIBFUNC_EXIT
3531 +#endif
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
3537 @@ -19,6 +19,11 @@
3538 Sam Lantinga
3539 slouken@libsdl.org
3541 +#if defined (SDL_AROS_SHARED)
3542 +#define __NOLIBBASE__
3543 +#include <proto/SDL.h>
3544 +#endif
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
3552 @@ -19,6 +19,11 @@
3553 Sam Lantinga
3554 slouken@libsdl.org
3556 +#if defined (SDL_AROS_SHARED)
3557 +#define __NOLIBBASE__
3558 +#include <proto/SDL.h>
3559 +#endif
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
3567 @@ -27,6 +27,10 @@
3568 #include "SDL_mutex.h"
3569 #include "SDL_thread.h"
3571 +#if defined(PROTO_SDL_H)
3572 +#include "SDL_intern.h"
3573 +#endif
3575 /* The SDL audio driver */
3576 typedef struct SDL_AudioDevice SDL_AudioDevice;
3578 @@ -46,6 +50,7 @@
3580 /* * * */
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);
3586 @@ -60,7 +65,18 @@
3587 void (*UnlockAudio)(_THIS);
3589 void (*SetCaption)(_THIS, const char *caption);
3591 +#else
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);
3602 +#endif
3603 /* * * */
3604 /* Data common to all devices */
3606 @@ -91,15 +107,24 @@
3608 /* * * */
3609 /* The function used to dispose of this structure */
3610 +#if !defined(PROTO_SDL_H)
3611 void (*free)(_THIS);
3612 +#else
3613 + void (*free)(_THIS, struct SDLBase *SDLBase);
3614 +#endif
3616 #undef _THIS
3618 typedef struct AudioBootStrap {
3619 const char *name;
3620 const char *desc;
3621 +#if !defined(PROTO_SDL_H)
3622 int (*available)(void);
3623 - SDL_AudioDevice *(*create)(int devindex);
3624 + SDL_AudioDevice *(*create)(int devindex);
3625 +#else
3626 + int (*available)(struct SDLBase *SDLBase);
3627 + SDL_AudioDevice *(*create)(int devindex, struct SDLBase *SDLBase);
3628 +#endif
3629 } AudioBootStrap;
3631 #if SDL_AUDIO_DRIVER_BSD
3632 @@ -179,8 +204,13 @@
3633 #if SDL_AUDIO_DRIVER_EPOCAUDIO
3634 extern AudioBootStrap EPOCAudio_bootstrap;
3635 #endif
3636 +#if SDL_AUDIO_DRIVER_AHI
3637 +extern AudioBootStrap AHI_bootstrap;
3638 +#endif
3640 /* This is the current audio device */
3641 +#if !defined(PROTO_SDL_H)
3642 extern SDL_AudioDevice *current_audio;
3643 +#endif
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
3649 @@ -19,6 +19,11 @@
3650 Sam Lantinga
3651 slouken@libsdl.org
3653 +#if defined (SDL_AROS_SHARED)
3654 +#define __NOLIBBASE__
3655 +#include <proto/SDL.h>
3656 +#endif
3658 #include "SDL_config.h"
3660 /* Microsoft WAVE file loading routines */
3661 @@ -26,8 +31,14 @@
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);
3668 +#else
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)
3673 +#endif
3675 struct MS_ADPCM_decodestate {
3676 Uint8 hPredictor;
3677 @@ -44,7 +55,12 @@
3678 struct MS_ADPCM_decodestate state[2];
3679 } MS_ADPCM_state;
3681 +#if !defined(PROTO_SDL_H)
3682 static int InitMS_ADPCM(WaveFMT *format)
3683 +#else
3684 +#define InitMS_ADPCM(format) InitMS_ADPCMI(format, SDLBase)
3685 +static int InitMS_ADPCMI(WaveFMT *format, struct SDLBase *SDLBase)
3686 +#endif
3688 Uint8 *rogue_feel;
3689 int i;
3690 @@ -112,7 +128,12 @@
3691 return(new_sample);
3694 +#if !defined(PROTO_SDL_H)
3695 static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
3696 +#else
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)
3699 +#endif
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)
3709 +#else
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)
3712 +#endif
3714 struct IMA_ADPCM_decodestate *state;
3715 Uint8 *freeable, *encoded, *decoded;
3716 @@ -389,9 +415,21 @@
3717 return(0);
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)
3724 +#else
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)
3733 + AROS_LIBFUNC_INIT
3734 +#endif
3735 int was_error;
3736 Chunk chunk;
3737 int lenread;
3738 @@ -565,19 +603,38 @@
3739 spec = NULL;
3741 return(spec);
3742 +#if defined(PROTO_SDL_H)
3743 + AROS_LIBFUNC_EXIT
3744 +#endif
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)
3753 +#else
3754 +AROS_LH1(void, SDL_FreeWAV,
3755 + AROS_LHA(Uint8 *, audio_buf, A0),
3756 + struct SDLBase *, SDLBase, 133, SDL)
3758 + AROS_LIBFUNC_INIT
3759 +#endif
3761 if ( audio_buf != NULL ) {
3762 SDL_free(audio_buf);
3764 +#if defined(PROTO_SDL_H)
3765 + AROS_LIBFUNC_EXIT
3766 +#endif
3769 +#if !defined(PROTO_SDL_H)
3770 static int ReadChunk(SDL_RWops *src, Chunk *chunk)
3771 +#else
3772 +static int ReadChunkI(SDL_RWops *src, Chunk *chunk, struct SDLBase *SDLBase)
3773 +#endif
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
3780 @@ -0,0 +1,635 @@
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
3799 + Sam Lantinga
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>
3809 +#endif
3811 +/* Stub functions for system-level CD-ROM audio control */
3813 +#include <stdio.h>
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
3830 +#ifdef __AROS__
3831 +#define AllocTaskPooled(x) AllocVec(x,MEMF_ANY)
3832 +#define FreeTaskPooled(x,y) FreeVec(x)
3833 +#endif
3835 +struct MyCDROM
3837 + char dosname[20];
3838 + char devname[108];
3839 + ULONG unit;
3840 + ULONG unitflags;
3842 + /* Filled in when this unit is opened */
3844 + struct IOStdReq *req;
3845 + struct SCSICmd scsicmd;
3846 + UWORD *inbuf;
3847 + UBYTE *sensebuf;
3850 +struct TrackInfo
3852 + UBYTE Pad1, Flags, TrackNumber, Pad2;
3853 + ULONG Address;
3856 +struct CD_TOC
3858 + UWORD Length;
3859 + UBYTE FirstTrack;
3860 + UBYTE LastTrack;
3861 + struct TrackInfo TOCData[100];
3864 +#if !defined(PROTO_SDL_H)
3865 +UBYTE *CDList[MAX_DRIVES];
3866 +#else
3867 +#include "SDL_intern.h"
3869 +#define CDList SDLBase->CDList
3870 +#endif
3871 +/**********************************************************************
3872 + FindDup
3874 + Return 1 if duplicate
3875 +**********************************************************************/
3877 +static ULONG FindDup(UBYTE **cdlist, CONST_STRPTR devname, ULONG unit)
3879 + struct MyCDROM *entry;
3880 + ULONG i;
3882 + D(bug("CDRom : FindDup\n"));
3884 + for (i = 0; i < MAX_DRIVES; i++)
3886 + entry = (struct MyCDROM *)cdlist[i];
3888 + if (entry == NULL)
3889 + break;
3891 + if (entry->unit == unit && strcmp(entry->devname, devname) == 0)
3892 + return 1;
3895 + return 0;
3898 +/**********************************************************************
3899 + CopyStringBSTRToC
3901 + Convert BCPL string to STRPTR
3902 +**********************************************************************/
3904 +LONG CopyStringBSTRToC (BSTR src, STRPTR dst, ULONG dst_size)
3906 +#ifdef __AROS__
3907 + STRPTR ptr = AROS_BSTR_ADDR(src);
3908 + ULONG ln = AROS_BSTR_strlen(src);
3909 +#else
3910 + UBYTE *ptr = BADDR(src);
3911 + ULONG ln = *ptr++;
3912 +#endif
3913 + if (ln > (dst_size-1)) ln = dst_size-1;
3914 + memcpy(dst, ptr, ln);
3915 + dst[ln] = 0;
3916 + return ln;
3919 +/**********************************************************************
3920 + SendCMD
3921 +**********************************************************************/
3923 +#if !defined(PROTO_SDL_H)
3924 +static LONG SendCMD(SDL_CD *cdrom, const UBYTE *cmd, int cmdlen)
3925 +#else
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)
3928 +#endif
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)
3953 +#else
3954 +static const char *SDL_SYS_CDName(int drive, struct SDLBase *SDLBase)
3955 +#endif
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)
3964 +#else
3965 +#define SDL_DisposeCD(entry) SDL_DisposeCDI(entry, SDLBase)
3966 +static void SDL_DisposeCDI(struct MyCDROM *entry, struct SDLBase *SDLBase)
3967 +#endif
3969 + D(bug("CDRom : SDL_DisposeCD\n"));
3971 + DeleteIORequest((struct IORequest *)entry->req);
3973 + if (entry->inbuf)
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)
3986 +#else
3987 +static int SDL_SYS_CDOpen(int drive, struct SDLBase *SDLBase)
3988 +#endif
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);
4012 + return drive;
4015 + SDL_DisposeCD(entry);
4018 + return -1;
4021 +#if !defined(PROTO_SDL_H)
4022 +static void SDL_SYS_CDClose(SDL_CD *cdrom)
4023 +#else
4024 +static void SDL_SYS_CDClose(SDL_CD *cdrom, struct SDLBase *SDLBase)
4025 +#endif
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)
4041 +#else
4042 +static int SDL_SYS_CDGetTOC(SDL_CD *cdrom, struct SDLBase *SDLBase)
4043 +#endif
4045 + static const UBYTE Cmd[10] =
4046 + { 0x43, 0, 0, 0, 0, 0, 0, TOC_SIZE >> 8, TOC_SIZE & 0xff, 0 };
4047 + int okay;
4049 + D(bug("CDRom : SDL_SYS_CDGetTOC\n"));
4051 + okay = 0;
4053 + if (SendCMD(cdrom, Cmd, sizeof(Cmd)) == 0)
4055 + struct MyCDROM *entry = (struct MyCDROM *)CDList[cdrom->id];
4056 + struct CD_TOC *toc;
4057 + int i;
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 */
4073 + okay = 1;
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"));
4087 + else
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));
4100 + else
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)
4114 +#else
4115 +static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position, struct SDLBase *SDLBase)
4116 +#endif
4118 + static const UBYTE Cmd[10] =
4119 + { 0x42, 0, 0x40, 0x01, 0, 0, 0, SCSI_INBUF_SIZE >> 8, SCSI_INBUF_SIZE & 0xff, 0 };
4120 + CDstatus status;
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];
4129 + UBYTE *buf;
4131 + buf = (UBYTE *)entry->inbuf;
4133 + D(bug("CDRom : Status : %02X,%02X\n", buf[0],buf[1]));
4135 + switch (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;
4146 + return status;
4149 +#if !defined(PROTO_SDL_H)
4150 +static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
4151 +#else
4152 +static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length, struct SDLBase *SDLBase)
4153 +#endif
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));
4166 + return 0;
4169 +#if !defined(PROTO_SDL_H)
4170 +static int SDL_SYS_CDPause(SDL_CD *cdrom)
4171 +#else
4172 +static int SDL_SYS_CDPause(SDL_CD *cdrom, struct SDLBase *SDLBase)
4173 +#endif
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));
4181 + return 0;
4184 +#if !defined(PROTO_SDL_H)
4185 +static int SDL_SYS_CDResume(SDL_CD *cdrom)
4186 +#else
4187 +static int SDL_SYS_CDResume(SDL_CD *cdrom, struct SDLBase *SDLBase)
4188 +#endif
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));
4195 + return 0;
4198 +#if !defined(PROTO_SDL_H)
4199 +static int SDL_SYS_CDStop(SDL_CD *cdrom)
4200 +#else
4201 +static int SDL_SYS_CDStop(SDL_CD *cdrom, struct SDLBase *SDLBase)
4202 +#endif
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));
4209 + return 0;
4212 +#if !defined(PROTO_SDL_H)
4213 +static int SDL_SYS_CDEject(SDL_CD *cdrom)
4214 +#else
4215 +static int SDL_SYS_CDEject(SDL_CD *cdrom, struct SDLBase *SDLBase)
4216 +#endif
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));
4224 + return 0;
4227 +#if !defined(PROTO_SDL_H)
4228 +int SDL_SYS_CDInit(void)
4229 +#else
4230 +int SDL_SYS_CDInitI(struct SDLBase *SDLBase)
4231 +#endif
4233 + struct DosList *dlist;
4234 + ULONG devices;
4235 + UBYTE **cdlist;
4237 + D(bug("CDRom : SDL_SYS_CDInit\n"));
4239 + cdlist = CDList;
4240 + devices = 0;
4241 + SDL_numcds = 0;
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;
4260 + ULONG devnamelen;
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;
4279 + ULONG dosnamelen;
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;
4300 + devices++;
4308 + UnLockDosList(LDF_DEVICES|LDF_READ);
4310 + if (devices)
4312 + struct IOStdReq *req;
4313 + struct SCSICmd *scsicmd;
4314 + struct MsgPort *port;
4315 + ULONG i;
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;
4335 + ULONG is_cdrom;
4337 + entry = (struct MyCDROM *)cdlist[i];
4339 + if (entry == NULL)
4340 + break;
4342 + is_cdrom = 0;
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*/
4365 + D(
4367 + int i;
4368 + for (i=0;i<2;i++) bug("inbuf[%d] : %04X\n", i, inbuf[i]);
4372 + if (((inbuf[0] & 0x05) == 5) && (inbuf[1] & 0x80))
4373 + is_cdrom = 1;
4375 + D(else bug("CDRom : DoIO error\n"));
4377 + CloseDevice((struct IORequest *)req);
4380 + if (is_cdrom == 0)
4382 + devices--;
4383 + cdlist[i] = cdlist[devices];
4385 + else
4387 + SDL_numcds++;
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);
4405 + return(0);
4408 +#if !defined(PROTO_SDL_H)
4409 +void SDL_SYS_CDQuit(void)
4410 +#else
4411 +void SDL_SYS_CDQuitI(struct SDLBase *SDLBase)
4412 +#endif
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
4419 @@ -0,0 +1,107 @@
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
4438 + Sam Lantinga
4439 + slouken@libsdl.org
4442 +#if defined(PROTO_SDL_H)
4443 +#include "SDL_intern.h"
4444 +#endif
4446 +/* This is the system specific header for the SDL CD-ROM API */
4448 +#ifndef MAX_DRIVES
4449 +#define MAX_DRIVES 32
4450 +#endif
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.
4464 + */
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.
4469 + */
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);
4475 + /* Pause play */
4476 + int (*Pause)(SDL_CD *cdrom);
4478 + /* Resume play */
4479 + int (*Resume)(SDL_CD *cdrom);
4481 + /* Stop play */
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);
4489 +#else
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);
4500 +#endif
4501 +} SDL_CDcaps;
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);
4516 +#else
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)
4523 +#ifndef SDL_numcds
4524 +#define SDL_numcds SDLBase->SDL_numcds
4525 +#endif
4526 +#endif
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
4530 @@ -19,6 +19,12 @@
4531 Sam Lantinga
4532 slouken@libsdl.org
4534 +#if defined (SDL_AROS_SHARED)
4535 +#define __NOLIBBASE__
4536 +#include <proto/SDL.h>
4537 +#include "SDL_intern.h"
4538 +#endif
4540 #include "SDL_config.h"
4542 /* This is the CD-audio control API for Simple DirectMedia Layer */
4543 @@ -30,9 +36,6 @@
4544 #define CLIP_FRAMES 10 /* Some CD-ROMs won't go all the way */
4545 #endif
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 = {
4552 NULL, /* Name */
4553 @@ -46,9 +49,26 @@
4554 NULL, /* Eject */
4555 NULL, /* Close */
4558 +#if !defined(PROTO_SDL_H)
4559 +static int SDL_cdinitted = 0;
4560 +static SDL_CD *default_cdrom;
4561 int SDL_numcds;
4562 +#else
4563 +#include "SDL_intern.h"
4565 +#define SDL_cdinitted SDLBase->SDL_cdinitted
4566 +#define default_cdrom SDLBase->default_cdrom
4567 +#ifndef SDL_numcds
4568 +#define SDL_numcds SDLBase->SDL_numcds
4569 +#endif
4570 +#endif
4572 +#if !defined(PROTO_SDL_H)
4573 int SDL_CDROMInit(void)
4574 +#else
4575 +int SDL_CDROMInitI(struct SDLBase *SDLBase)
4576 +#endif
4578 int retval;
4580 @@ -62,7 +82,12 @@
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)
4586 +#else
4587 +#define CheckInit(check_cdrom, cdrom) CheckInitI(check_cdrom, cdrom, SDLBase)
4588 +static int CheckInitI(int check_cdrom, SDL_CD **cdrom, struct SDLBase *SDLBase)
4589 +#endif
4591 int okay;
4593 @@ -80,16 +105,34 @@
4594 return(okay);
4597 +#if !defined(PROTO_SDL_H)
4598 int SDL_CDNumDrives(void)
4600 +#else
4601 +AROS_LH0(int, SDL_CDNumDrives,
4602 + struct SDLBase *, SDLBase, 146, SDL)
4604 + AROS_LIBFUNC_INIT
4605 +#endif
4606 if ( ! CheckInit(0, NULL) ) {
4607 return(-1);
4609 return(SDL_numcds);
4610 +#if defined(PROTO_SDL_H)
4611 + AROS_LIBFUNC_EXIT
4612 +#endif
4615 +#if !defined(PROTO_SDL_H)
4616 const char *SDL_CDName(int drive)
4618 +#else
4619 +AROS_LH1(const char *, SDL_CDName,
4620 + AROS_LHA(int, drive, D0),
4621 + struct SDLBase *, SDLBase, 147, SDL)
4623 + AROS_LIBFUNC_INIT
4624 +#endif
4625 if ( ! CheckInit(0, NULL) ) {
4626 return(NULL);
4628 @@ -98,14 +141,29 @@
4629 return(NULL);
4631 if ( SDL_CDcaps.Name ) {
4632 +#if !defined(PROTO_SDL_H)
4633 return(SDL_CDcaps.Name(drive));
4634 +#else
4635 + return(SDL_CDcaps.Name(drive, SDLBase));
4636 +#endif
4637 } else {
4638 return("");
4640 +#if defined(PROTO_SDL_H)
4641 + AROS_LIBFUNC_EXIT
4642 +#endif
4645 +#if !defined(PROTO_SDL_H)
4646 SDL_CD *SDL_CDOpen(int drive)
4648 +#else
4649 +AROS_LH1(SDL_CD *, SDL_CDOpen,
4650 + AROS_LHA(int, drive, D0),
4651 + struct SDLBase *, SDLBase, 148, SDL)
4653 + AROS_LIBFUNC_INIT
4654 +#endif
4655 struct SDL_CD *cdrom;
4657 if ( ! CheckInit(0, NULL) ) {
4658 @@ -121,17 +179,32 @@
4659 return(NULL);
4661 SDL_memset(cdrom, 0, sizeof(*cdrom));
4662 +#if !defined(PROTO_SDL_H)
4663 cdrom->id = SDL_CDcaps.Open(drive);
4664 +#else
4665 + cdrom->id = SDL_CDcaps.Open(drive, SDLBase);
4666 +#endif
4667 if ( cdrom->id < 0 ) {
4668 SDL_free(cdrom);
4669 return(NULL);
4671 default_cdrom = cdrom;
4672 return(cdrom);
4673 +#if defined(PROTO_SDL_H)
4674 + AROS_LIBFUNC_EXIT
4675 +#endif
4678 +#if !defined(PROTO_SDL_H)
4679 CDstatus SDL_CDStatus(SDL_CD *cdrom)
4681 +#else
4682 +AROS_LH1(CDstatus, SDL_CDStatus,
4683 + AROS_LHA(SDL_CD *, cdrom, A0),
4684 + struct SDLBase *, SDLBase, 149, SDL)
4686 + AROS_LIBFUNC_INIT
4687 +#endif
4688 CDstatus status;
4689 int i;
4690 Uint32 position;
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);
4697 +#else
4698 + status = SDL_CDcaps.Status(cdrom, &i, SDLBase);
4699 +#endif
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 ) {
4707 +#else
4708 + if ( SDL_CDcaps.GetTOC(cdrom, SDLBase) < 0 ) {
4709 +#endif
4710 status = CD_ERROR;
4712 /* If the drive is playing, get current play position */
4713 @@ -169,11 +250,26 @@
4716 return(status);
4717 +#if defined(PROTO_SDL_H)
4718 + AROS_LIBFUNC_EXIT
4719 +#endif
4722 +#if !defined(PROTO_SDL_H)
4723 int SDL_CDPlayTracks(SDL_CD *cdrom,
4724 int strack, int sframe, int ntracks, int nframes)
4726 +#else
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)
4735 + AROS_LIBFUNC_INIT
4736 +#endif
4737 int etrack, eframe;
4738 int start, length;
4740 @@ -236,21 +332,50 @@
4741 #ifdef DEBUG_CDROM
4742 fprintf(stderr, "Playing %d frames at offset %d\n", length, start);
4743 #endif
4744 +#if !defined(PROTO_SDL_H)
4745 return(SDL_CDcaps.Play(cdrom, start, length));
4746 +#else
4747 + return(SDL_CDcaps.Play(cdrom, start, length, SDLBase));
4748 + AROS_LIBFUNC_EXIT
4749 +#endif
4752 +#if !defined(PROTO_SDL_H)
4753 int SDL_CDPlay(SDL_CD *cdrom, int sframe, int length)
4755 +#else
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)
4762 + AROS_LIBFUNC_INIT
4763 +#endif
4764 /* Check if the CD-ROM subsystem has been initialized */
4765 if ( ! CheckInit(1, &cdrom) ) {
4766 return(CD_ERROR);
4769 +#if !defined(PROTO_SDL_H)
4770 return(SDL_CDcaps.Play(cdrom, sframe, length));
4771 +#else
4772 + return(SDL_CDcaps.Play(cdrom, sframe, length, SDLBase));
4774 + AROS_LIBFUNC_EXIT
4775 +#endif
4778 +#if !defined(PROTO_SDL_H)
4779 int SDL_CDPause(SDL_CD *cdrom)
4781 +#else
4782 +AROS_LH1(int, SDL_CDPause,
4783 + AROS_LHA(SDL_CD *, cdrom, A0),
4784 + struct SDLBase *, SDLBase, 152, SDL)
4786 + AROS_LIBFUNC_INIT
4787 +#endif
4788 CDstatus status;
4789 int retval;
4791 @@ -259,20 +384,39 @@
4792 return(CD_ERROR);
4795 +#if !defined(PROTO_SDL_H)
4796 status = SDL_CDcaps.Status(cdrom, NULL);
4797 +#else
4798 + status = SDL_CDcaps.Status(cdrom, NULL, SDLBase);
4799 +#endif
4800 switch (status) {
4801 case CD_PLAYING:
4802 +#if !defined(PROTO_SDL_H)
4803 retval = SDL_CDcaps.Pause(cdrom);
4804 +#else
4805 + retval = SDL_CDcaps.Pause(cdrom, SDLBase);
4806 +#endif
4807 break;
4808 default:
4809 retval = 0;
4810 break;
4812 return(retval);
4813 +#if defined(PROTO_SDL_H)
4814 + AROS_LIBFUNC_EXIT
4815 +#endif
4818 +#if !defined(PROTO_SDL_H)
4819 int SDL_CDResume(SDL_CD *cdrom)
4821 +#else
4822 +AROS_LH1(int, SDL_CDResume,
4823 + AROS_LHA(SDL_CD *, cdrom, A0),
4824 + struct SDLBase *, SDLBase, 153, SDL)
4826 + AROS_LIBFUNC_INIT
4827 +#endif
4828 CDstatus status;
4829 int retval;
4831 @@ -281,19 +425,38 @@
4832 return(CD_ERROR);
4835 +#if !defined(PROTO_SDL_H)
4836 status = SDL_CDcaps.Status(cdrom, NULL);
4837 +#else
4838 + status = SDL_CDcaps.Status(cdrom, NULL, SDLBase);
4839 +#endif
4840 switch (status) {
4841 case CD_PAUSED:
4842 +#if !defined(PROTO_SDL_H)
4843 retval = SDL_CDcaps.Resume(cdrom);
4844 +#else
4845 + retval = SDL_CDcaps.Resume(cdrom, SDLBase);
4846 +#endif
4847 default:
4848 retval = 0;
4849 break;
4851 return(retval);
4852 +#if defined(PROTO_SDL_H)
4853 + AROS_LIBFUNC_EXIT
4854 +#endif
4857 +#if !defined(PROTO_SDL_H)
4858 int SDL_CDStop(SDL_CD *cdrom)
4860 +#else
4861 +AROS_LH1(int, SDL_CDStop,
4862 + AROS_LHA(SDL_CD *, cdrom, A0),
4863 + struct SDLBase *, SDLBase, 154, SDL)
4865 + AROS_LIBFUNC_INIT
4866 +#endif
4867 CDstatus status;
4868 int retval;
4870 @@ -302,39 +465,83 @@
4871 return(CD_ERROR);
4874 +#if !defined(PROTO_SDL_H)
4875 status = SDL_CDcaps.Status(cdrom, NULL);
4876 +#else
4877 + status = SDL_CDcaps.Status(cdrom, NULL, SDLBase);
4878 +#endif
4879 switch (status) {
4880 case CD_PLAYING:
4881 case CD_PAUSED:
4882 +#if !defined(PROTO_SDL_H)
4883 retval = SDL_CDcaps.Stop(cdrom);
4884 +#else
4885 + retval = SDL_CDcaps.Stop(cdrom, SDLBase);
4886 +#endif
4887 default:
4888 retval = 0;
4889 break;
4891 return(retval);
4892 +#if defined(PROTO_SDL_H)
4893 + AROS_LIBFUNC_EXIT
4894 +#endif
4897 +#if !defined(PROTO_SDL_H)
4898 int SDL_CDEject(SDL_CD *cdrom)
4900 +#else
4901 +AROS_LH1(int, SDL_CDEject,
4902 + AROS_LHA(SDL_CD *, cdrom, A0),
4903 + struct SDLBase *, SDLBase, 155, SDL)
4905 + AROS_LIBFUNC_INIT
4906 +#endif
4907 /* Check if the CD-ROM subsystem has been initialized */
4908 if ( ! CheckInit(1, &cdrom) ) {
4909 return(CD_ERROR);
4911 +#if !defined(PROTO_SDL_H)
4912 return(SDL_CDcaps.Eject(cdrom));
4913 +#else
4914 + return(SDL_CDcaps.Eject(cdrom, SDLBase));
4916 + AROS_LIBFUNC_EXIT
4917 +#endif
4920 +#if !defined(PROTO_SDL_H)
4921 void SDL_CDClose(SDL_CD *cdrom)
4923 +#else
4924 +AROS_LH1(void, SDL_CDClose,
4925 + AROS_LHA(SDL_CD *, cdrom, A0),
4926 + struct SDLBase *, SDLBase, 156, SDL)
4928 + AROS_LIBFUNC_INIT
4929 +#endif
4930 /* Check if the CD-ROM subsystem has been initialized */
4931 if ( ! CheckInit(1, &cdrom) ) {
4932 return;
4934 +#if !defined(PROTO_SDL_H)
4935 SDL_CDcaps.Close(cdrom);
4936 +#else
4937 + SDL_CDcaps.Close(cdrom, SDLBase);
4938 +#endif
4939 SDL_free(cdrom);
4940 default_cdrom = NULL;
4941 +#if defined(PROTO_SDL_H)
4942 + AROS_LIBFUNC_EXIT
4943 +#endif
4946 +#if !defined(PROTO_SDL_H)
4947 void SDL_CDROMQuit(void)
4948 +#else
4949 +void SDL_CDROMQuitI(struct SDLBase *SDLBase)
4950 +#endif
4952 SDL_SYS_CDQuit();
4953 SDL_cdinitted = 0;
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
4957 @@ -21,12 +21,17 @@
4959 #include "SDL_config.h"
4961 +#if defined(PROTO_SDL_H)
4962 +#include "SDL_intern.h"
4963 +#endif
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);
4976 @@ -59,8 +64,21 @@
4978 /* Close the specified drive */
4979 void (*Close)(SDL_CD *cdrom);
4980 +#else
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);
4991 +#endif
4992 } SDL_CDcaps;
4994 +#if !defined(PROTO_SDL_H)
4995 /* The number of available CD-ROM drives on the system */
4996 extern int SDL_numcds;
4998 @@ -73,4 +91,13 @@
5000 /* Function to perform any system-specific CD-ROM related cleanup */
5001 extern void SDL_SYS_CDQuit(void);
5002 +#else
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
5011 +#endif
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
5015 @@ -19,6 +19,11 @@
5016 Sam Lantinga
5017 slouken@libsdl.org
5019 +#if defined (SDL_AROS_SHARED)
5020 +#define __NOLIBBASE__
5021 +#include <proto/SDL.h>
5022 +#endif
5024 #include "SDL_config.h"
5026 /* CPU feature detection for SDL */
5027 @@ -33,6 +38,10 @@
5028 #include <setjmp.h>
5029 #endif
5031 +#if defined(PROTO_SDL_H)
5032 +#include "SDL_intern.h"
5033 +#endif
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)
5045 +#else
5046 +AROS_LH0(SDL_bool, SDL_HasRDTSC,
5047 + struct SDLBase *, SDLBase, 188, SDL)
5049 + AROS_LIBFUNC_INIT
5050 +#endif
5051 if ( SDL_GetCPUFeatures() & CPU_HAS_RDTSC ) {
5052 return SDL_TRUE;
5054 return SDL_FALSE;
5055 +#if defined(PROTO_SDL_H)
5056 + AROS_LIBFUNC_EXIT
5057 +#endif
5060 +#if !defined(PROTO_SDL_H)
5061 SDL_bool SDL_HasMMX(void)
5063 +#else
5064 +AROS_LH0(SDL_bool, SDL_HasMMX,
5065 + struct SDLBase *, SDLBase, 189, SDL)
5067 + AROS_LIBFUNC_INIT
5068 +#endif
5069 if ( SDL_GetCPUFeatures() & CPU_HAS_MMX ) {
5070 return SDL_TRUE;
5072 return SDL_FALSE;
5073 +#if defined(PROTO_SDL_H)
5074 + AROS_LIBFUNC_EXIT
5075 +#endif
5078 +#if !defined(PROTO_SDL_H)
5079 SDL_bool SDL_HasMMXExt(void)
5081 +#else
5082 +AROS_LH0(SDL_bool, SDL_HasMMXExt,
5083 + struct SDLBase *, SDLBase, 192, SDL)
5085 + AROS_LIBFUNC_INIT
5086 +#endif
5087 if ( SDL_GetCPUFeatures() & CPU_HAS_MMXEXT ) {
5088 return SDL_TRUE;
5090 return SDL_FALSE;
5091 +#if defined(PROTO_SDL_H)
5092 + AROS_LIBFUNC_EXIT
5093 +#endif
5096 +#if !defined(PROTO_SDL_H)
5097 SDL_bool SDL_Has3DNow(void)
5099 +#else
5100 +AROS_LH0(SDL_bool, SDL_Has3DNow,
5101 + struct SDLBase *, SDLBase, 190, SDL)
5103 + AROS_LIBFUNC_INIT
5104 +#endif
5105 if ( SDL_GetCPUFeatures() & CPU_HAS_3DNOW ) {
5106 return SDL_TRUE;
5108 return SDL_FALSE;
5109 +#if defined(PROTO_SDL_H)
5110 + AROS_LIBFUNC_EXIT
5111 +#endif
5114 +#if !defined(PROTO_SDL_H)
5115 SDL_bool SDL_Has3DNowExt(void)
5117 +#else
5118 +AROS_LH0(SDL_bool, SDL_Has3DNowExt,
5119 + struct SDLBase *, SDLBase, 193, SDL)
5121 + AROS_LIBFUNC_INIT
5122 +#endif
5123 if ( SDL_GetCPUFeatures() & CPU_HAS_3DNOWEXT ) {
5124 return SDL_TRUE;
5126 return SDL_FALSE;
5127 +#if defined(PROTO_SDL_H)
5128 + AROS_LIBFUNC_EXIT
5129 +#endif
5132 +#if !defined(PROTO_SDL_H)
5133 SDL_bool SDL_HasSSE(void)
5135 +#else
5136 +AROS_LH0(SDL_bool, SDL_HasSSE,
5137 + struct SDLBase *, SDLBase, 191, SDL)
5139 + AROS_LIBFUNC_INIT
5140 +#endif
5141 if ( SDL_GetCPUFeatures() & CPU_HAS_SSE ) {
5142 return SDL_TRUE;
5144 return SDL_FALSE;
5145 +#if defined(PROTO_SDL_H)
5146 + AROS_LIBFUNC_EXIT
5147 +#endif
5150 +#if !defined(PROTO_SDL_H)
5151 SDL_bool SDL_HasSSE2(void)
5153 +#else
5154 +AROS_LH0(SDL_bool, SDL_HasSSE2,
5155 + struct SDLBase *, SDLBase, 194, SDL)
5157 + AROS_LIBFUNC_INIT
5158 +#endif
5159 if ( SDL_GetCPUFeatures() & CPU_HAS_SSE2 ) {
5160 return SDL_TRUE;
5162 return SDL_FALSE;
5163 +#if defined(PROTO_SDL_H)
5164 + AROS_LIBFUNC_EXIT
5165 +#endif
5168 +#if !defined(PROTO_SDL_H)
5169 SDL_bool SDL_HasAltiVec(void)
5171 +#else
5172 +AROS_LH0(SDL_bool, SDL_HasAltiVec,
5173 + struct SDLBase *, SDLBase, 187, SDL)
5175 + AROS_LIBFUNC_INIT
5176 +#endif
5177 if ( SDL_GetCPUFeatures() & CPU_HAS_ALTIVEC ) {
5178 return SDL_TRUE;
5180 return SDL_FALSE;
5181 +#if defined(PROTO_SDL_H)
5182 + AROS_LIBFUNC_EXIT
5183 +#endif
5186 #ifdef TEST_MAIN
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
5190 @@ -19,6 +19,11 @@
5191 Sam Lantinga
5192 slouken@libsdl.org
5194 +#if defined (SDL_AROS_SHARED)
5195 +#define __NOLIBBASE__
5196 +#include <proto/SDL.h>
5197 +#endif
5199 #include "SDL_config.h"
5201 /* Application focus/iconification handling code for SDL */
5202 @@ -28,10 +33,19 @@
5205 /* These are static for our active event handling code */
5206 +#if !defined(PROTO_SDL_H)
5207 static Uint8 SDL_appstate = 0;
5208 +#else
5209 +#include "SDL_intern.h"
5210 +#define SDL_appstate SDLBase->SDL_appstate
5211 +#endif
5213 /* Public functions */
5214 +#if !defined(PROTO_SDL_H)
5215 int SDL_AppActiveInit(void)
5216 +#else
5217 +int SDL_AppActiveInitI(struct SDLBase *SDLBase)
5218 +#endif
5220 /* Start completely active */
5221 SDL_appstate = (SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
5222 @@ -39,17 +53,35 @@
5223 /* That's it! */
5224 return(0);
5226 +#if !defined(PROTO_SDL_H)
5227 void SDL_AppActiveQuit(void)
5228 +#else
5229 +void SDL_AppActiveQuitI(struct SDLBase *SDLBase)
5230 +#endif
5234 +#if !defined(PROTO_SDL_H)
5235 Uint8 SDL_GetAppState(void)
5237 +#else
5238 +AROS_LH0(Uint8, SDL_GetAppState,
5239 + struct SDLBase *, SDLBase, 121, SDL)
5241 + AROS_LIBFUNC_INIT
5242 +#endif
5243 return(SDL_appstate);
5244 +#if defined(PROTO_SDL_H)
5245 + AROS_LIBFUNC_EXIT
5246 +#endif
5249 /* This is global for SDL_eventloop.c */
5250 +#if !defined(PROTO_SDL_H)
5251 int SDL_PrivateAppActive(Uint8 gain, Uint8 state)
5252 +#else
5253 +int SDL_PrivateAppActiveI(Uint8 gain, Uint8 state, struct SDLBase *SDLBase)
5254 +#endif
5256 int posted;
5257 Uint8 new_state;
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
5261 @@ -19,6 +19,11 @@
5262 Sam Lantinga
5263 slouken@libsdl.org
5265 +#if defined (SDL_AROS_SHARED)
5266 +#define __NOLIBBASE__
5267 +#include <proto/SDL.h>
5268 +#endif
5270 #include "SDL_config.h"
5272 /* General event handling code for SDL */
5273 @@ -33,9 +38,23 @@
5274 #endif
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 */
5284 +#else
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
5293 +#endif
5295 /* Private data -- event queue */
5296 #define MAXEVENTS 128
5297 @@ -55,11 +74,11 @@
5298 int safe;
5299 } SDL_EventLock;
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)
5307 +#else
5308 +void SDL_Lock_EventThreadI(struct SDLBase *SDLBase)
5309 +#endif
5311 if ( SDL_EventThread && (SDL_ThreadID() != event_thread) ) {
5312 /* Grab lock and spin until we're sure event thread stopped */
5313 @@ -69,7 +88,11 @@
5317 +#if !defined(PROTO_SDL_H)
5318 void SDL_Unlock_EventThread(void)
5319 +#else
5320 +void SDL_Unlock_EventThreadI(struct SDLBase *SDLBase)
5321 +#endif
5323 if ( SDL_EventThread && (SDL_ThreadID() != event_thread) ) {
5324 SDL_mutexV(SDL_EventLock.lock);
5325 @@ -87,7 +110,11 @@
5326 #include <time.h>
5327 #endif
5329 +#if !defined(PROTO_SDL_H)
5330 static int SDLCALL SDL_GobbleEvents(void *unused)
5331 +#else
5332 +static int SDLCALL SDL_GobbleEvents(struct SDLBase *SDLBase)
5333 +#endif
5335 event_thread = SDL_ThreadID();
5337 @@ -104,7 +131,11 @@
5339 /* Get events from the video subsystem */
5340 if ( video ) {
5341 +#if !defined(PROTO_SDL_H)
5342 video->PumpEvents(this);
5343 +#else
5344 + video->PumpEvents(this, SDLBase);
5345 +#endif
5348 /* Queue pending key-repeat events */
5349 @@ -141,7 +172,12 @@
5350 return(0);
5353 +#if !defined(PROTO_SDL_H)
5354 static int SDL_StartEventThread(Uint32 flags)
5355 +#else
5356 +#define SDL_StartEventThread(flags) SDL_StartEventThreadI(flags, SDLBase)
5357 +static int SDL_StartEventThreadI(Uint32 flags, struct SDLBase *SDLBase)
5358 +#endif
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);
5365 #else
5366 +#if !defined(PROTO_SDL_H)
5367 SDL_EventThread = SDL_CreateThread(SDL_GobbleEvents, NULL);
5368 +#else
5369 + SDL_EventThread = SDL_CreateThread(SDL_GobbleEvents, SDLBase);
5370 +#endif
5371 #endif
5372 if ( SDL_EventThread == NULL ) {
5373 return(-1);
5374 @@ -184,7 +224,12 @@
5375 return(0);
5378 +#if !defined(PROTO_SDL_H)
5379 static void SDL_StopEventThread(void)
5380 +#else
5381 +#define SDL_StopEventThread() SDL_StopEventThreadI(SDLBase)
5382 +static void SDL_StopEventThreadI(struct SDLBase *SDLBase)
5383 +#endif
5385 SDL_EventQ.active = 0;
5386 if ( SDL_EventThread ) {
5387 @@ -199,14 +244,21 @@
5388 #endif
5391 +#if !defined(PROTO_SDL_H)
5392 Uint32 SDL_EventThreadID(void)
5393 +#else
5394 +Uint32 SDL_EventThreadIDI(struct SDLBase *SDLBase)
5395 +#endif
5397 return(event_thread);
5400 /* Public functions */
5402 +#if !defined(PROTO_SDL_H)
5403 void SDL_StopEventLoop(void)
5404 +#else
5405 +void SDL_StopEventLoopI(struct SDLBase *SDLBase)
5406 +#endif
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)
5416 +#else
5417 +int SDL_StartEventLoopI(Uint32 flags, struct SDLBase *SDLBase)
5418 +#endif
5420 int retcode;
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)
5428 +#else
5429 +#define SDL_AddEvent(event) SDL_AddEventI(event, SDLBase)
5430 +static int SDL_AddEventI(SDL_Event *event, struct SDLBase *SDLBase)
5431 +#endif
5433 int tail, added;
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)
5441 +#else
5442 +#define SDL_CutEvent(spot) SDL_CutEventI(spot, SDLBase)
5443 +static int SDL_CutEventI(int spot, struct SDLBase *SDLBase)
5444 +#endif
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,
5454 Uint32 mask)
5456 +#else
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)
5464 + AROS_LIBFUNC_INIT
5465 +#endif
5466 int i, used;
5468 /* Don't look after we've quit */
5469 @@ -362,18 +439,32 @@
5470 used = -1;
5472 return(used);
5473 +#if defined(PROTO_SDL_H)
5474 + AROS_LIBFUNC_EXIT
5475 +#endif
5478 /* Run the system dependent event loops */
5479 +#if !defined(PROTO_SDL_H)
5480 void SDL_PumpEvents(void)
5482 +#else
5483 +AROS_LH0(void, SDL_PumpEvents,
5484 + struct SDLBase *, SDLBase, 83, SDL)
5486 + AROS_LIBFUNC_INIT
5487 +#endif
5488 if ( !SDL_EventThread ) {
5489 SDL_VideoDevice *video = current_video;
5490 SDL_VideoDevice *this = current_video;
5492 /* Get events from the video subsystem */
5493 if ( video ) {
5494 +#if !defined(PROTO_SDL_H)
5495 video->PumpEvents(this);
5496 +#else
5497 + video->PumpEvents(this, SDLBase);
5498 +#endif
5501 /* Queue pending key-repeat events */
5502 @@ -386,22 +477,43 @@
5504 #endif
5506 +#if defined(PROTO_SDL_H)
5507 + AROS_LIBFUNC_EXIT
5508 +#endif
5511 /* Public functions */
5513 +#if !defined(PROTO_SDL_H)
5514 int SDL_PollEvent (SDL_Event *event)
5516 +#else
5517 +AROS_LH1(int, SDL_PollEvent,
5518 + AROS_LHA(SDL_Event *, event, A0),
5519 + struct SDLBase *, SDLBase, 84, SDL)
5521 + AROS_LIBFUNC_INIT
5522 +#endif
5523 SDL_PumpEvents();
5525 /* We can't return -1, just return 0 (no event) on error */
5526 if ( SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_ALLEVENTS) <= 0 )
5527 return 0;
5528 return 1;
5529 +#if defined(PROTO_SDL_H)
5530 + AROS_LIBFUNC_EXIT
5531 +#endif
5534 +#if !defined(PROTO_SDL_H)
5535 int SDL_WaitEvent (SDL_Event *event)
5537 +#else
5538 +AROS_LH1(int, SDL_WaitEvent,
5539 + AROS_LHA(SDL_Event *, event, A0),
5540 + struct SDLBase *, SDLBase, 85, SDL)
5542 + AROS_LIBFUNC_INIT
5543 +#endif
5544 while ( 1 ) {
5545 SDL_PumpEvents();
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)
5552 + AROS_LIBFUNC_EXIT
5553 +#endif
5556 +#if !defined(PROTO_SDL_H)
5557 int SDL_PushEvent(SDL_Event *event)
5559 +#else
5560 +AROS_LH1(int, SDL_PushEvent,
5561 + AROS_LHA(SDL_Event *, event, A0),
5562 + struct SDLBase *, SDLBase, 87, SDL)
5564 + AROS_LIBFUNC_INIT
5565 +#endif
5566 if ( SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0) <= 0 )
5567 return -1;
5568 return 0;
5569 +#if defined(PROTO_SDL_H)
5570 + AROS_LIBFUNC_EXIT
5571 +#endif
5574 +#if !defined(PROTO_SDL_H)
5575 void SDL_SetEventFilter (SDL_EventFilter filter)
5577 +#else
5578 +AROS_LH1(void, SDL_SetEventFilter,
5579 + AROS_LHA(SDL_EventFilter, filter, D0),
5580 + struct SDLBase *, SDLBase, 88, SDL)
5582 + AROS_LIBFUNC_INIT
5583 +#endif
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)
5592 + AROS_LIBFUNC_EXIT
5593 +#endif
5596 +#if !defined(PROTO_SDL_H)
5597 SDL_EventFilter SDL_GetEventFilter(void)
5599 +#else
5600 +AROS_LH0(SDL_EventFilter, SDL_GetEventFilter,
5601 + struct SDLBase *, SDLBase, 89, SDL)
5603 + AROS_LIBFUNC_INIT
5604 +#endif
5605 return(SDL_EventOK);
5606 +#if defined(PROTO_SDL_H)
5607 + AROS_LIBFUNC_EXIT
5608 +#endif
5611 +#if !defined(PROTO_SDL_H)
5612 Uint8 SDL_EventState (Uint8 type, int state)
5614 +#else
5615 +AROS_LH2(Uint8, SDL_EventState,
5616 + AROS_LHA(Uint8, type, D0),
5617 + AROS_LHA(int, state, D1),
5618 + struct SDLBase *, SDLBase, 90, SDL)
5620 + AROS_LIBFUNC_INIT
5621 +#endif
5622 SDL_Event bitbucket;
5623 Uint8 current_state;
5625 @@ -478,11 +635,18 @@
5626 break;
5628 return(current_state);
5629 +#if defined(PROTO_SDL_H)
5630 + AROS_LIBFUNC_EXIT
5631 +#endif
5634 /* This is a generic event handler.
5636 +#if !defined(PROTO_SDL_H)
5637 int SDL_PrivateSysWMEvent(SDL_SysWMmsg *message)
5638 +#else
5639 +int SDL_PrivateSysWMEventI(SDL_SysWMmsg *message, struct SDLBase *SDLBase)
5640 +#endif
5642 int posted;
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
5647 @@ -24,6 +24,7 @@
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);
5655 @@ -76,8 +77,74 @@
5656 /* Used by the event loop to queue pending keyboard repeat events */
5657 extern void SDL_CheckKeyRepeat(void);
5659 +extern int SDL_TranslateUNICODE;
5660 +#else
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
5724 +#endif
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 */
5729 #endif
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
5734 @@ -19,6 +19,11 @@
5735 Sam Lantinga
5736 slouken@libsdl.org
5738 +#if defined (SDL_AROS_SHARED)
5739 +#define __NOLIBBASE__
5740 +#include <proto/SDL.h>
5741 +#endif
5743 #include "SDL_config.h"
5745 /* Refresh event handling code for SDL */
5746 @@ -28,7 +33,11 @@
5749 /* This is global for SDL_eventloop.c */
5750 +#if !defined(PROTO_SDL_H)
5751 int SDL_PrivateExpose(void)
5752 +#else
5753 +int SDL_PrivateExposeI(struct SDLBase *SDLBase)
5754 +#endif
5756 int posted;
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
5761 @@ -19,6 +19,11 @@
5762 Sam Lantinga
5763 slouken@libsdl.org
5765 +#if defined (SDL_AROS_SHARED)
5766 +#define __NOLIBBASE__
5767 +#include <proto/SDL.h>
5768 +#endif
5770 #include "SDL_config.h"
5772 /* General keyboard handling code for SDL */
5773 @@ -28,13 +33,21 @@
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 */
5785 +#else
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
5792 +#endif
5795 * jk 991215 - added
5796 @@ -55,7 +68,11 @@
5797 #define SDL_NLK_NUM 0x02
5799 /* Public functions */
5800 +#if !defined(PROTO_SDL_H)
5801 int SDL_KeyboardInit(void)
5802 +#else
5803 +int SDL_KeyboardInitI(struct SDLBase *SDLBase)
5804 +#endif
5806 const char* env;
5807 SDL_VideoDevice *video = current_video;
5808 @@ -68,7 +85,11 @@
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);
5814 +#else
5815 + video->InitOSKeymap(this, SDLBase);
5816 +#endif
5818 SDL_EnableKeyRepeat(0, 0);
5820 @@ -334,12 +355,20 @@
5821 /* Done. Whew. */
5822 return(0);
5824 +#if !defined(PROTO_SDL_H)
5825 void SDL_KeyboardQuit(void)
5826 +#else
5827 +void SDL_KeyboardQuitI(struct SDLBase *SDLBase)
5828 +#endif
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)
5835 +#else
5836 +void SDL_ResetKeyboardI(struct SDLBase *SDLBase)
5837 +#endif
5839 SDL_keysym keysym;
5840 SDLKey key;
5841 @@ -354,8 +383,16 @@
5842 SDL_KeyRepeat.timestamp = 0;
5845 +#if !defined(PROTO_SDL_H)
5846 int SDL_EnableUNICODE(int enable)
5848 +#else
5849 +AROS_LH1(int, SDL_EnableUNICODE,
5850 + AROS_LHA(int, enable, D0),
5851 + struct SDLBase *, SDLBase, 107, SDL)
5853 + AROS_LIBFUNC_INIT
5854 +#endif
5855 int old_mode;
5857 old_mode = SDL_TranslateUNICODE;
5858 @@ -363,25 +400,68 @@
5859 SDL_TranslateUNICODE = enable;
5861 return(old_mode);
5862 +#if defined(PROTO_SDL_H)
5863 + AROS_LIBFUNC_EXIT
5864 +#endif
5867 +#if !defined(PROTO_SDL_H)
5868 Uint8 * SDL_GetKeyState (int *numkeys)
5870 +#else
5871 +AROS_LH1(Uint8 *, SDL_GetKeyState,
5872 + AROS_LHA(int *, numkeys, A0),
5873 + struct SDLBase *, SDLBase, 109, SDL)
5875 + AROS_LIBFUNC_INIT
5876 +#endif
5877 if ( numkeys != (int *)0 )
5878 *numkeys = SDLK_LAST;
5879 return(SDL_KeyState);
5880 +#if defined(PROTO_SDL_H)
5881 + AROS_LIBFUNC_EXIT
5882 +#endif
5884 +#if !defined(PROTO_SDL_H)
5885 SDLMod SDL_GetModState (void)
5887 +#else
5888 +AROS_LH0(SDLMod, SDL_GetModState,
5889 + struct SDLBase *, SDLBase, 110, SDL)
5891 + AROS_LIBFUNC_INIT
5892 +#endif
5893 return(SDL_ModState);
5894 +#if defined(PROTO_SDL_H)
5895 + AROS_LIBFUNC_EXIT
5896 +#endif
5898 +#if !defined(PROTO_SDL_H)
5899 void SDL_SetModState (SDLMod modstate)
5901 +#else
5902 +AROS_LH1(void, SDL_SetModState,
5903 + AROS_LHA(SDLMod, modstate, D0),
5904 + struct SDLBase *, SDLBase, 111, SDL)
5906 + AROS_LIBFUNC_INIT
5907 +#endif
5908 SDL_ModState = modstate;
5909 +#if defined(PROTO_SDL_H)
5910 + AROS_LIBFUNC_EXIT
5911 +#endif
5914 +#if !defined(PROTO_SDL_H)
5915 char *SDL_GetKeyName(SDLKey key)
5917 +#else
5918 +AROS_LH1(char *, SDL_GetKeyName,
5919 + AROS_LHA(SDLKey, key, D0),
5920 + struct SDLBase *, SDLBase, 112, SDL)
5922 + AROS_LIBFUNC_INIT
5923 +#endif
5924 const char *keyname;
5926 keyname = NULL;
5927 @@ -393,10 +473,17 @@
5929 /* FIXME: make this function const in 1.3 */
5930 return (char *)(keyname);
5931 +#if defined(PROTO_SDL_H)
5932 + AROS_LIBFUNC_EXIT
5933 +#endif
5936 /* These are global for SDL_eventloop.c */
5937 +#if !defined(PROTO_SDL_H)
5938 int SDL_PrivateKeyboard(Uint8 state, SDL_keysym *keysym)
5939 +#else
5940 +int SDL_PrivateKeyboardI(Uint8 state, SDL_keysym *keysym, struct SDLBase *SDLBase)
5941 +#endif
5943 SDL_Event event;
5944 int posted, repeatable;
5945 @@ -570,7 +657,11 @@
5947 * jk 991215 - Added
5949 +#if !defined(PROTO_SDL_H)
5950 void SDL_CheckKeyRepeat(void)
5951 +#else
5952 +void SDL_CheckKeyRepeatI(struct SDLBase *SDLBase)
5953 +#endif
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)
5964 +#else
5965 +AROS_LH2(int, SDL_EnableKeyRepeat,
5966 + AROS_LHA(int, delay, D0),
5967 + AROS_LHA(int, interval, D1),
5968 + struct SDLBase *, SDLBase, 108, SDL)
5970 + AROS_LIBFUNC_INIT
5971 +#endif
5972 if ( (delay < 0) || (interval < 0) ) {
5973 SDL_SetError("keyboard repeat value less than zero");
5974 return(-1);
5975 @@ -604,6 +704,9 @@
5976 SDL_KeyRepeat.interval = interval;
5977 SDL_KeyRepeat.timestamp = 0;
5978 return(0);
5979 +#if defined(PROTO_SDL_H)
5980 + AROS_LIBFUNC_EXIT
5981 +#endif
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
5988 @@ -19,6 +19,11 @@
5989 Sam Lantinga
5990 slouken@libsdl.org
5992 +#if defined (SDL_AROS_SHARED)
5993 +#define __NOLIBBASE__
5994 +#include <proto/SDL.h>
5995 +#endif
5997 #include "SDL_config.h"
5999 /* General mouse handling code for SDL */
6000 @@ -28,7 +33,7 @@
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;
6009 @@ -37,10 +42,24 @@
6010 static Sint16 SDL_MouseMaxX = 0;
6011 static Sint16 SDL_MouseMaxY = 0;
6012 static Uint8 SDL_ButtonState = 0;
6013 +#else
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
6023 +#endif
6025 /* Public functions */
6026 +#if !defined(PROTO_SDL_H)
6027 int SDL_MouseInit(void)
6028 +#else
6029 +int SDL_MouseInitI(struct SDLBase *SDLBase)
6030 +#endif
6032 /* The mouse is at (0,0) */
6033 SDL_MouseX = 0;
6034 @@ -54,12 +73,20 @@
6035 /* That's it! */
6036 return(0);
6038 +#if !defined(PROTO_SDL_H)
6039 void SDL_MouseQuit(void)
6040 +#else
6041 +void SDL_MouseQuitI(struct SDLBase *SDLBase)
6042 +#endif
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)
6049 +#else
6050 +void SDL_ResetMouseI(struct SDLBase *SDLBase)
6051 +#endif
6053 Uint8 i;
6054 for ( i = 0; i < sizeof(SDL_ButtonState)*8; ++i ) {
6055 @@ -69,8 +96,17 @@
6059 +#if !defined(PROTO_SDL_H)
6060 Uint8 SDL_GetMouseState (int *x, int *y)
6062 +#else
6063 +AROS_LH2(Uint8, SDL_GetMouseState,
6064 + AROS_LHA(int *, x, A0),
6065 + AROS_LHA(int *, y, A1),
6066 + struct SDLBase *, SDLBase, 113, SDL)
6068 + AROS_LIBFUNC_INIT
6069 +#endif
6070 if ( x ) {
6071 *x = SDL_MouseX;
6073 @@ -78,10 +114,22 @@
6074 *y = SDL_MouseY;
6076 return(SDL_ButtonState);
6077 +#if defined(PROTO_SDL_H)
6078 + AROS_LIBFUNC_EXIT
6079 +#endif
6082 +#if !defined(PROTO_SDL_H)
6083 Uint8 SDL_GetRelativeMouseState (int *x, int *y)
6085 +#else
6086 +AROS_LH2(Uint8, SDL_GetRelativeMouseState,
6087 + AROS_LHA(int *, x, A0),
6088 + AROS_LHA(int *, y, A1),
6089 + struct SDLBase *, SDLBase, 114, SDL)
6091 + AROS_LIBFUNC_INIT
6092 +#endif
6093 if ( x )
6094 *x = SDL_DeltaX;
6095 if ( y )
6096 @@ -89,9 +137,17 @@
6097 SDL_DeltaX = 0;
6098 SDL_DeltaY = 0;
6099 return(SDL_ButtonState);
6100 +#if defined(PROTO_SDL_H)
6101 + AROS_LIBFUNC_EXIT
6102 +#endif
6105 +#if !defined(PROTO_SDL_H)
6106 static void ClipOffset(Sint16 *x, Sint16 *y)
6107 +#else
6108 +#define ClipOffset(x, y) ClipOffsetI(x, y, SDLBase)
6109 +static void ClipOffsetI(Sint16 *x, Sint16 *y, struct SDLBase *SDLBase)
6110 +#endif
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)
6120 +#else
6121 +void SDL_SetMouseRangeI(int maxX, int maxY, struct SDLBase *SDLBase)
6122 +#endif
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)
6131 +#else
6132 +int SDL_PrivateMouseMotionI(Uint8 buttonstate, int relative, Sint16 x, Sint16 y, struct SDLBase *SDLBase)
6133 +#endif
6135 int posted;
6136 Uint16 X, Y;
6137 @@ -194,7 +258,11 @@
6138 return(posted);
6141 +#if !defined(PROTO_SDL_H)
6142 int SDL_PrivateMouseButton(Uint8 state, Uint8 button, Sint16 x, Sint16 y)
6143 +#else
6144 +int SDL_PrivateMouseButtonI(Uint8 state, Uint8 button, Sint16 x, Sint16 y, struct SDLBase *SDLBase)
6145 +#endif
6147 SDL_Event event;
6148 int posted;
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
6152 @@ -19,6 +19,11 @@
6153 Sam Lantinga
6154 slouken@libsdl.org
6156 +#if defined (SDL_AROS_SHARED)
6157 +#define __NOLIBBASE__
6158 +#include <proto/SDL.h>
6159 +#endif
6161 #include "SDL_config.h"
6163 /* General quit handling code for SDL */
6164 @@ -38,12 +43,20 @@
6165 signal(sig, SDL_HandleSIG);
6167 /* Signal a quit interrupt */
6168 +#if !defined(PROTO_SDL_H)
6169 SDL_PrivateQuit();
6170 +#else
6171 + // FIXME: Call SDL_PrivateQuit()
6172 +#endif
6174 #endif /* HAVE_SIGNAL_H */
6176 /* Public functions */
6177 +#if !defined(PROTO_SDL_H)
6178 int SDL_QuitInit(void)
6179 +#else
6180 +int SDL_QuitInitI(struct SDLBase *SDLBase)
6181 +#endif
6183 #ifdef HAVE_SIGACTION
6184 struct sigaction action;
6185 @@ -80,7 +93,11 @@
6186 /* That's it! */
6187 return(0);
6189 +#if !defined(PROTO_SDL_H)
6190 void SDL_QuitQuit(void)
6191 +#else
6192 +void SDL_QuitQuitI(struct SDLBase *SDLBase)
6193 +#endif
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)
6203 +#else
6204 +int SDL_PrivateQuitI(struct SDLBase *SDLBase)
6205 +#endif
6207 int posted;
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
6212 @@ -19,6 +19,11 @@
6213 Sam Lantinga
6214 slouken@libsdl.org
6216 +#if defined (SDL_AROS_SHARED)
6217 +#define __NOLIBBASE__
6218 +#include <proto/SDL.h>
6219 +#endif
6221 #include "SDL_config.h"
6223 /* Resize event handling code for SDL */
6224 @@ -27,6 +32,8 @@
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 */
6232 static struct {
6233 @@ -34,8 +41,15 @@
6234 int h;
6235 } last_resize;
6237 -/* This is global for SDL_eventloop.c */
6238 int SDL_PrivateResize(int w, int h)
6239 +#else
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)
6246 +#endif
6248 int posted;
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
6253 @@ -19,6 +19,11 @@
6254 Sam Lantinga
6255 slouken@libsdl.org
6257 +#if defined (SDL_AROS_SHARED)
6258 +#define __NOLIBBASE__
6259 +#include <proto/SDL.h>
6260 +#endif
6262 #include "SDL_config.h"
6264 /* This file provides a general interface for SDL to read and write
6265 @@ -28,6 +33,9 @@
6266 #include "SDL_endian.h"
6267 #include "SDL_rwops.h"
6269 +#if defined(PROTO_SDL_H)
6270 +#include "SDL_intern.h"
6271 +#endif
6273 #if defined(__WIN32__) && !defined(__SYMBIAN32__)
6275 @@ -322,6 +330,9 @@
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;
6281 +#endif
6282 if ( fseek(context->hidden.stdio.fp, offset, whence) == 0 ) {
6283 return(ftell(context->hidden.stdio.fp));
6284 } else {
6285 @@ -331,6 +342,9 @@
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;
6291 +#endif
6292 size_t nread;
6294 nread = fread(ptr, size, maxnum, context->hidden.stdio.fp);
6295 @@ -341,6 +355,9 @@
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;
6301 +#endif
6302 size_t nwrote;
6304 nwrote = fwrite(ptr, size, num, context->hidden.stdio.fp);
6305 @@ -351,6 +368,9 @@
6307 static int SDLCALL stdio_close(SDL_RWops *context)
6309 +#if defined(PROTO_SDL_H)
6310 + struct Library __unused *SDLBase = context->SDLLib;
6311 +#endif
6312 if ( context ) {
6313 if ( context->hidden.stdio.autoclose ) {
6314 /* WARNING: Check the return value here! */
6315 @@ -360,12 +380,14 @@
6317 return(0);
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;
6328 +#endif
6329 Uint8 *newpos;
6331 switch (whence) {
6332 @@ -393,6 +415,9 @@
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;
6338 +#endif
6339 size_t total_bytes;
6340 size_t mem_available;
6342 @@ -413,6 +438,9 @@
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;
6348 +#endif
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;
6358 +#endif
6359 SDL_SetError("Can't write to read-only memory");
6360 return(-1);
6362 static int SDLCALL mem_close(SDL_RWops *context)
6364 +#if defined(PROTO_SDL_H)
6365 + struct Library __unused *SDLBase = context->SDLLib;
6366 +#endif
6367 if ( context ) {
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)
6377 +#else
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)
6383 + AROS_LIBFUNC_INIT
6384 +#endif
6385 SDL_RWops *rwops = NULL;
6386 #ifdef HAVE_STDIO_H
6387 FILE *fp = NULL;
6388 @@ -526,11 +569,23 @@
6389 #endif /* !HAVE_STDIO_H */
6391 return(rwops);
6392 +#if defined(PROTO_SDL_H)
6393 + AROS_LIBFUNC_EXIT
6394 +#endif
6397 #ifdef HAVE_STDIO_H
6398 +#if !defined(PROTO_SDL_H)
6399 SDL_RWops *SDL_RWFromFP(FILE *fp, int autoclose)
6401 +#else
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)
6407 + AROS_LIBFUNC_INIT
6408 +#endif
6409 SDL_RWops *rwops = NULL;
6411 rwops = SDL_AllocRW();
6412 @@ -543,11 +598,23 @@
6413 rwops->hidden.stdio.autoclose = autoclose;
6415 return(rwops);
6416 +#if defined(PROTO_SDL_H)
6417 + AROS_LIBFUNC_EXIT
6418 +#endif
6420 #endif /* HAVE_STDIO_H */
6422 +#if !defined(PROTO_SDL_H)
6423 SDL_RWops *SDL_RWFromMem(void *mem, int size)
6425 +#else
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)
6431 + AROS_LIBFUNC_INIT
6432 +#endif
6433 SDL_RWops *rwops;
6435 rwops = SDL_AllocRW();
6436 @@ -561,9 +628,16 @@
6437 rwops->hidden.mem.stop = rwops->hidden.mem.base+size;
6439 return(rwops);
6440 +#if defined(PROTO_SDL_H)
6441 + AROS_LIBFUNC_EXIT
6442 +#endif
6445 +#if !defined(PROTO_SDL_H)
6446 SDL_RWops *SDL_RWFromConstMem(const void *mem, int size)
6447 +#else
6448 +SDL_RWops *SDL_RWFromConstMem(const void *mem, int size, struct SDLBase *SDLBase)
6449 +#endif
6451 SDL_RWops *rwops;
6453 @@ -580,94 +654,256 @@
6454 return(rwops);
6457 +#if !defined(PROTO_SDL_H)
6458 SDL_RWops *SDL_AllocRW(void)
6460 +#else
6461 +AROS_LH0(SDL_RWops *, SDL_AllocRW,
6462 + struct Library *, SDLBase, 20, SDL)
6464 + AROS_LIBFUNC_INIT
6465 +#endif
6466 SDL_RWops *area;
6468 area = (SDL_RWops *)SDL_malloc(sizeof *area);
6469 if ( area == NULL ) {
6470 SDL_OutOfMemory();
6472 +#if defined(PROTO_SDL_H)
6473 + area->SDLLib = SDLBase;
6474 +#endif
6475 return(area);
6476 +#if defined(PROTO_SDL_H)
6477 + AROS_LIBFUNC_EXIT
6478 +#endif
6481 +#if !defined(PROTO_SDL_H)
6482 void SDL_FreeRW(SDL_RWops *area)
6484 +#else
6485 +AROS_LH1(void, SDL_FreeRW,
6486 + AROS_LHA(SDL_RWops *, area, A0),
6487 + struct SDLBase *, SDLBase, 21, SDL)
6489 + AROS_LIBFUNC_INIT
6490 +#endif
6491 SDL_free(area);
6492 +#if defined(PROTO_SDL_H)
6493 + AROS_LIBFUNC_EXIT
6494 +#endif
6497 /* Functions for dynamically reading and writing endian-specific values */
6499 +#if !defined(PROTO_SDL_H)
6500 Uint16 SDL_ReadLE16 (SDL_RWops *src)
6502 +#else
6503 +AROS_LH1(Uint16, SDL_ReadLE16,
6504 + AROS_LHA(SDL_RWops *, src, A0),
6505 + struct SDLBase *, SDLBase, 175, SDL)
6507 + AROS_LIBFUNC_INIT
6508 +#endif
6509 Uint16 value;
6511 SDL_RWread(src, &value, (sizeof value), 1);
6512 return(SDL_SwapLE16(value));
6513 +#if defined(PROTO_SDL_H)
6514 + AROS_LIBFUNC_EXIT
6515 +#endif
6517 +#if !defined(PROTO_SDL_H)
6518 Uint16 SDL_ReadBE16 (SDL_RWops *src)
6520 +#else
6521 +AROS_LH1(Uint16, SDL_ReadBE16,
6522 + AROS_LHA(SDL_RWops *, src, A0),
6523 + struct SDLBase *, SDLBase, 176, SDL)
6525 + AROS_LIBFUNC_INIT
6526 +#endif
6527 Uint16 value;
6529 SDL_RWread(src, &value, (sizeof value), 1);
6530 return(SDL_SwapBE16(value));
6531 +#if defined(PROTO_SDL_H)
6532 + AROS_LIBFUNC_EXIT
6533 +#endif
6535 +#if !defined(PROTO_SDL_H)
6536 Uint32 SDL_ReadLE32 (SDL_RWops *src)
6538 +#else
6539 +AROS_LH1(Uint32, SDL_ReadLE32,
6540 + AROS_LHA(SDL_RWops *, src, A0),
6541 + struct SDLBase *, SDLBase, 177, SDL)
6543 + AROS_LIBFUNC_INIT
6544 +#endif
6545 Uint32 value;
6547 SDL_RWread(src, &value, (sizeof value), 1);
6548 return(SDL_SwapLE32(value));
6549 +#if defined(PROTO_SDL_H)
6550 + AROS_LIBFUNC_EXIT
6551 +#endif
6553 +#if !defined(PROTO_SDL_H)
6554 Uint32 SDL_ReadBE32 (SDL_RWops *src)
6556 +#else
6557 +AROS_LH1(Uint32, SDL_ReadBE32,
6558 + AROS_LHA(SDL_RWops *, src, A0),
6559 + struct SDLBase *, SDLBase, 178, SDL)
6561 + AROS_LIBFUNC_INIT
6562 +#endif
6563 Uint32 value;
6565 SDL_RWread(src, &value, (sizeof value), 1);
6566 return(SDL_SwapBE32(value));
6567 +#if defined(PROTO_SDL_H)
6568 + AROS_LIBFUNC_EXIT
6569 +#endif
6571 +#if !defined(PROTO_SDL_H)
6572 Uint64 SDL_ReadLE64 (SDL_RWops *src)
6574 +#else
6575 +AROS_LH1(Uint64, SDL_ReadLE64,
6576 + AROS_LHA(SDL_RWops *, src, A0),
6577 + struct SDLBase *, SDLBase, 179, SDL)
6579 + AROS_LIBFUNC_INIT
6580 +#endif
6581 Uint64 value;
6583 SDL_RWread(src, &value, (sizeof value), 1);
6584 return(SDL_SwapLE64(value));
6585 +#if defined(PROTO_SDL_H)
6586 + AROS_LIBFUNC_EXIT
6587 +#endif
6589 +#if !defined(PROTO_SDL_H)
6590 Uint64 SDL_ReadBE64 (SDL_RWops *src)
6592 +#else
6593 +AROS_LH1(Uint64, SDL_ReadBE64,
6594 + AROS_LHA(SDL_RWops *, src, A0),
6595 + struct SDLBase *, SDLBase, 180, SDL)
6597 + AROS_LIBFUNC_INIT
6598 +#endif
6599 Uint64 value;
6601 SDL_RWread(src, &value, (sizeof value), 1);
6602 return(SDL_SwapBE64(value));
6603 +#if defined(PROTO_SDL_H)
6604 + AROS_LIBFUNC_EXIT
6605 +#endif
6608 +#if !defined(PROTO_SDL_H)
6609 int SDL_WriteLE16 (SDL_RWops *dst, Uint16 value)
6611 +#else
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)
6617 + AROS_LIBFUNC_INIT
6618 +#endif
6619 value = SDL_SwapLE16(value);
6620 return(SDL_RWwrite(dst, &value, (sizeof value), 1));
6621 +#if defined(PROTO_SDL_H)
6622 + AROS_LIBFUNC_EXIT
6623 +#endif
6625 +#if !defined(PROTO_SDL_H)
6626 int SDL_WriteBE16 (SDL_RWops *dst, Uint16 value)
6628 +#else
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)
6634 + AROS_LIBFUNC_INIT
6635 +#endif
6636 value = SDL_SwapBE16(value);
6637 return(SDL_RWwrite(dst, &value, (sizeof value), 1));
6638 +#if defined(PROTO_SDL_H)
6639 + AROS_LIBFUNC_EXIT
6640 +#endif
6642 +#if !defined(PROTO_SDL_H)
6643 int SDL_WriteLE32 (SDL_RWops *dst, Uint32 value)
6645 +#else
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)
6651 + AROS_LIBFUNC_INIT
6652 +#endif
6653 value = SDL_SwapLE32(value);
6654 return(SDL_RWwrite(dst, &value, (sizeof value), 1));
6655 +#if defined(PROTO_SDL_H)
6656 + AROS_LIBFUNC_EXIT
6657 +#endif
6659 +#if !defined(PROTO_SDL_H)
6660 int SDL_WriteBE32 (SDL_RWops *dst, Uint32 value)
6662 +#else
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)
6668 + AROS_LIBFUNC_INIT
6669 +#endif
6670 value = SDL_SwapBE32(value);
6671 return(SDL_RWwrite(dst, &value, (sizeof value), 1));
6672 +#if defined(PROTO_SDL_H)
6673 + AROS_LIBFUNC_EXIT
6674 +#endif
6676 +#if !defined(PROTO_SDL_H)
6677 int SDL_WriteLE64 (SDL_RWops *dst, Uint64 value)
6679 +#else
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)
6685 + AROS_LIBFUNC_INIT
6686 +#endif
6687 value = SDL_SwapLE64(value);
6688 return(SDL_RWwrite(dst, &value, (sizeof value), 1));
6689 +#if defined(PROTO_SDL_H)
6690 + AROS_LIBFUNC_EXIT
6691 +#endif
6693 +#if !defined(PROTO_SDL_H)
6694 int SDL_WriteBE64 (SDL_RWops *dst, Uint64 value)
6696 +#else
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)
6702 + AROS_LIBFUNC_INIT
6703 +#endif
6704 value = SDL_SwapBE64(value);
6705 return(SDL_RWwrite(dst, &value, (sizeof value), 1));
6706 +#if defined(PROTO_SDL_H)
6707 + AROS_LIBFUNC_EXIT
6708 +#endif
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
6713 @@ -0,0 +1,506 @@
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
6732 + Sam Lantinga
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
6747 + Debug lines added
6750 +#if defined (SDL_AROS_SHARED)
6751 +#include <proto/exec.h>
6752 +#define __NOLIBBASE__
6753 +#include <proto/SDL.h>
6754 +#endif
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>
6764 +#endif
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 */
6795 +#endif
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.
6801 + */
6803 +#if !defined(PROTO_SDL_H)
6804 +struct Library *LowLevelBase = NULL;
6805 +#else
6806 +#include "SDL_intern.h"
6807 +#define LowLevelBase SDLBase->LowLevelBase
6808 +#endif
6810 +unsigned long joybut[] =
6812 + JPF_BUTTON_RED,
6813 + JPF_BUTTON_BLUE,
6814 + JPF_BUTTON_YELLOW,
6815 + JPF_BUTTON_GREEN,
6816 + JPF_BUTTON_PLAY,
6817 + JPF_BUTTON_FORWARD,
6818 + JPF_BUTTON_REVERSE
6820 + JPF_JOY_UP,
6821 + JPF_JOY_DOWN,
6822 + JPF_JOY_LEFT,
6823 + JPF_JOY_RIGHT
6827 +struct joystick_hwdata
6829 + ULONG joystate;
6830 +#ifndef NO_LOWLEVEL_EXT
6831 + ULONG joystate_ext;
6832 + ULONG supports_analog;
6833 +#endif
6836 +/* lowlevel portNumber 0 <-> 1 */
6837 +static int PortIndex(int index)
6839 + switch(index)
6841 + case 0:
6842 + return 1;
6843 + break;
6845 + case 1:
6846 + return 0;
6847 + break;
6849 + default:
6850 + break;
6853 + return index;
6856 +#if !defined(PROTO_SDL_H)
6857 +int SDL_SYS_JoystickInit(void)
6858 +#else
6859 +int SDL_SYS_JoystickInitI(struct SDLBase *SDLBase)
6860 +#endif
6862 + int numjoysticks = 0;
6863 + unsigned long joyflag = 0L;
6865 + D(bug("SDL_SYS_JoystickInit()\n"));
6867 + if(!LowLevelBase)
6869 + if((LowLevelBase = OpenLibrary("lowlevel.library",37)))
6871 + numjoysticks = 0;
6872 + while(numjoysticks < MAX_JOYSTICKS)
6874 + joyflag = ReadJoyPort(PortIndex(numjoysticks));
6876 + if((joyflag&JP_TYPE_MASK) == JP_TYPE_NOTAVAIL)
6878 + break;
6881 + numjoysticks++;
6882 + }
6884 + return numjoysticks;
6886 + else
6888 + /* failed to open lowlevel.library! */
6889 + SDL_SetError("Unable to open lowlevel.library");
6890 + return 0;
6893 + else
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)
6902 +#else
6903 +const char *SDL_SYS_JoystickNameI(int index, struct SDLBase *SDLBase)
6904 +#endif
6906 + static char name[64];
6907 + unsigned long joyflag = 0L;
6909 + D(bug("SDL_SYS_JoystickName()\n"));
6911 + if(LowLevelBase)
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");
6923 + return NULL;
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);
6931 + return name;
6933 + else
6935 + SDL_SetError("No joystick available with that index");
6937 + return NULL;
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.
6945 + */
6946 +#if !defined(PROTO_SDL_H)
6947 +int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
6948 +#else
6949 +int SDL_SYS_JoystickOpenI(SDL_Joystick *joystick, struct SDLBase *SDLBase)
6950 +#endif
6952 + unsigned long temp = 0L;
6954 + D(bug("SDL_SYS_JoystickOpen()"));
6955 + D(bug("Opening joystick %ld\n", joystick->index));
6957 + if(!LowLevelBase)
6959 + if(SDL_SYS_JoystickInit() < 1)
6961 + SDL_SetError("Initialize Joysticks first!");
6962 + return -1;
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();
6972 + return -1;
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;
7014 +#endif
7016 + return 0;
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.
7023 + */
7024 +#if !defined(PROTO_SDL_H)
7025 +void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
7026 +#else
7027 +void SDL_SYS_JoystickUpdateI(SDL_Joystick *joystick, struct SDLBase *SDLBase)
7028 +#endif
7030 + ULONG data;
7031 +#ifndef NO_LOWLEVEL_EXT
7032 + ULONG data_ext = 0;
7033 +#endif
7034 + int i;
7036 + D(bug("SDL_SYS_JoystickUpdate()\n"));
7038 + if(!LowLevelBase)
7040 + if(SDL_SYS_JoystickInit() < 1)
7042 + SDL_SetError("Initialize Joysticks first!");
7044 + return;
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);
7052 +#endif
7054 + /* only send an event when something changed */
7056 + /* hats */
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);
7085 + /* axes */
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))
7091 + Sint16 value;
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))
7099 + Sint16 value;
7101 + value = ((data_ext & JP_YAXIS_MASK)>>8) * 2*32767 / 255 - 32767;
7102 + SDL_PrivateJoystickAxis(joystick, 1, value);
7105 + else
7106 +#endif
7108 + if((joystick->hwdata->joystate & (JPF_JOY_DOWN|JPF_JOY_UP)) != (data & (JPF_JOY_DOWN|JPF_JOY_UP)))
7110 + Sint16 value;
7112 + /* UP and DOWN direction */
7113 + if(data & JPF_JOY_DOWN)
7115 + value = MOS_PLUS;
7117 + else if(data & JPF_JOY_UP)
7119 + value = MOS_MINUS;
7121 + else
7123 + value = 0;
7126 + SDL_PrivateJoystickAxis(joystick, 1, value);
7129 + if((joystick->hwdata->joystate & (JPF_JOY_LEFT|JPF_JOY_RIGHT)) != (data & (JPF_JOY_LEFT|JPF_JOY_RIGHT)))
7131 + Sint16 value;
7133 + /* LEFT and RIGHT direction */
7134 + if(data & JPF_JOY_LEFT)
7136 + value = MOS_MINUS;
7138 + else if(data & JPF_JOY_RIGHT)
7140 + value = MOS_PLUS;
7142 + else
7144 + value = 0;
7147 + SDL_PrivateJoystickAxis(joystick, 0, value);
7151 + /* Joy buttons */
7152 + for(i = 0; i < joystick->nbuttons; i++)
7154 + if( (data & joybut[i]) )
7156 + if(i == 1)
7158 + // FIXME: WTF?
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;
7176 +#endif
7179 +/* Function to close a joystick after use */
7180 +#if !defined(PROTO_SDL_H)
7181 +void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
7182 +#else
7183 +void SDL_SYS_JoystickCloseI(SDL_Joystick *joystick, struct SDLBase *SDLBase)
7184 +#endif
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);
7198 + return;
7201 +/* Function to perform any system-specific joystick related cleanup */
7202 +#if !defined(PROTO_SDL_H)
7203 +void SDL_SYS_JoystickQuit(void)
7204 +#else
7205 +void SDL_SYS_JoystickQuitI(struct SDLBase *SDLBase)
7206 +#endif
7208 + D(bug("SDL_SYS_JoystickQuit()\n"));
7210 + if(LowLevelBase)
7212 + CloseLibrary(LowLevelBase);
7213 + LowLevelBase = NULL;
7214 + SDL_numjoysticks = 0;
7217 + return;
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
7223 @@ -19,6 +19,11 @@
7224 Sam Lantinga
7225 slouken@libsdl.org
7227 +#if defined (SDL_AROS_SHARED)
7228 +#define __NOLIBBASE__
7229 +#include <proto/SDL.h>
7230 +#endif
7232 #include "SDL_config.h"
7234 /* This is the joystick API for Simple DirectMedia Layer */
7235 @@ -40,7 +45,11 @@
7236 int SDL_allocatedjoysticks = 0;
7237 SDL_Joystick **SDL_joysticks = NULL;
7239 +#if !defined(PROTO_SDL_H)
7240 int SDL_JoystickInit(void)
7241 +#else
7242 +int SDL_JoystickInitI(struct SDLBase *SDLBase)
7243 +#endif
7245 int arraylen;
7246 int status;
7247 @@ -66,22 +75,43 @@
7249 * Count the number of joysticks attached to the system
7251 +#if !defined(PROTO_SDL_H)
7252 int SDL_NumJoysticks(void)
7254 +#else
7255 +AROS_LH0(int, SDL_NumJoysticks,
7256 + struct SDLBase *, SDLBase, 91, SDL)
7258 + AROS_LIBFUNC_INIT
7259 +#endif
7260 return SDL_numjoysticks;
7261 +#if defined(PROTO_SDL_H)
7262 + AROS_LIBFUNC_EXIT
7263 +#endif
7267 * Get the implementation dependent name of a joystick
7269 +#if !defined(PROTO_SDL_H)
7270 const char *SDL_JoystickName(int device_index)
7272 +#else
7273 +AROS_LH1(const char *, SDL_JoystickName,
7274 + AROS_LHA(int, device_index, D0),
7275 + struct SDLBase *, SDLBase, 92, SDL)
7277 + AROS_LIBFUNC_INIT
7278 +#endif
7279 if ( (device_index < 0) || (device_index >= SDL_numjoysticks) ) {
7280 SDL_SetError("There are %d joysticks available",
7281 SDL_numjoysticks);
7282 return(NULL);
7284 return(SDL_SYS_JoystickName(device_index));
7285 +#if defined(PROTO_SDL_H)
7286 + AROS_LIBFUNC_EXIT
7287 +#endif
7291 @@ -91,8 +121,16 @@
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)
7298 +#else
7299 +AROS_LH1(SDL_Joystick *, SDL_JoystickOpen,
7300 + AROS_LHA(int, device_index, D0),
7301 + struct SDLBase *, SDLBase, 93, SDL)
7303 + AROS_LIBFUNC_INIT
7304 +#endif
7305 int i;
7306 SDL_Joystick *joystick;
7308 @@ -176,13 +214,24 @@
7309 SDL_Unlock_EventThread();
7311 return(joystick);
7312 +#if defined(PROTO_SDL_H)
7313 + AROS_LIBFUNC_EXIT
7314 +#endif
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)
7323 +#else
7324 +AROS_LH1(int, SDL_JoystickOpened,
7325 + AROS_LHA(int, device_index, D0),
7326 + struct SDLBase *, SDLBase, 94, SDL)
7328 + AROS_LIBFUNC_INIT
7329 +#endif
7330 int i, opened;
7332 opened = 0;
7333 @@ -193,9 +242,17 @@
7336 return(opened);
7337 +#if defined(PROTO_SDL_H)
7338 + AROS_LIBFUNC_EXIT
7339 +#endif
7342 +#if !defined(PROTO_SDL_H)
7343 static int ValidJoystick(SDL_Joystick **joystick)
7344 +#else
7345 +#define ValidJoystick(joystick) ValidJoystickI(joystick, SDLBase)
7346 +static int ValidJoystickI(SDL_Joystick **joystick, struct SDLBase *SDLBase)
7347 +#endif
7349 int valid;
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)
7358 +#else
7359 +AROS_LH1(int, SDL_JoystickIndex,
7360 + AROS_LHA(SDL_Joystick *, joystick, A0),
7361 + struct SDLBase *, SDLBase, 95, SDL)
7363 + AROS_LIBFUNC_INIT
7364 +#endif
7365 if ( ! ValidJoystick(&joystick) ) {
7366 return(-1);
7368 return(joystick->index);
7369 +#if defined(PROTO_SDL_H)
7370 + AROS_LIBFUNC_EXIT
7371 +#endif
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)
7380 +#else
7381 +AROS_LH1(int, SDL_JoystickNumAxes,
7382 + AROS_LHA(SDL_Joystick *, joystick, A0),
7383 + struct SDLBase *, SDLBase, 96, SDL)
7385 + AROS_LIBFUNC_INIT
7386 +#endif
7387 if ( ! ValidJoystick(&joystick) ) {
7388 return(-1);
7390 return(joystick->naxes);
7391 +#if defined(PROTO_SDL_H)
7392 + AROS_LIBFUNC_EXIT
7393 +#endif
7397 * Get the number of hats on a joystick
7399 +#if !defined(PROTO_SDL_H)
7400 int SDL_JoystickNumHats(SDL_Joystick *joystick)
7402 +#else
7403 +AROS_LH1(int, SDL_JoystickNumHats,
7404 + AROS_LHA(SDL_Joystick *, joystick, A0),
7405 + struct SDLBase *, SDLBase, 98, SDL)
7407 + AROS_LIBFUNC_INIT
7408 +#endif
7409 if ( ! ValidJoystick(&joystick) ) {
7410 return(-1);
7412 return(joystick->nhats);
7413 +#if defined(PROTO_SDL_H)
7414 + AROS_LIBFUNC_EXIT
7415 +#endif
7419 * Get the number of trackballs on a joystick
7421 +#if !defined(PROTO_SDL_H)
7422 int SDL_JoystickNumBalls(SDL_Joystick *joystick)
7424 +#else
7425 +AROS_LH1(int, SDL_JoystickNumBalls,
7426 + AROS_LHA(SDL_Joystick *, joystick, A0),
7427 + struct SDLBase *, SDLBase, 97, SDL)
7429 + AROS_LIBFUNC_INIT
7430 +#endif
7431 if ( ! ValidJoystick(&joystick) ) {
7432 return(-1);
7434 return(joystick->nballs);
7435 +#if defined(PROTO_SDL_H)
7436 + AROS_LIBFUNC_EXIT
7437 +#endif
7441 * Get the number of buttons on a joystick
7443 +#if !defined(PROTO_SDL_H)
7444 int SDL_JoystickNumButtons(SDL_Joystick *joystick)
7446 +#else
7447 +AROS_LH1(int, SDL_JoystickNumButtons,
7448 + AROS_LHA(SDL_Joystick *, joystick, A0),
7449 + struct SDLBase *, SDLBase, 99, SDL)
7451 + AROS_LIBFUNC_INIT
7452 +#endif
7453 if ( ! ValidJoystick(&joystick) ) {
7454 return(-1);
7456 return(joystick->nbuttons);
7457 +#if defined(PROTO_SDL_H)
7458 + AROS_LIBFUNC_EXIT
7459 +#endif
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)
7468 +#else
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)
7474 + AROS_LIBFUNC_INIT
7475 +#endif
7476 Sint16 state;
7478 if ( ! ValidJoystick(&joystick) ) {
7479 @@ -280,13 +401,25 @@
7480 state = 0;
7482 return(state);
7483 +#if defined(PROTO_SDL_H)
7484 + AROS_LIBFUNC_EXIT
7485 +#endif
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)
7494 +#else
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)
7500 + AROS_LIBFUNC_INIT
7501 +#endif
7502 Uint8 state;
7504 if ( ! ValidJoystick(&joystick) ) {
7505 @@ -299,13 +432,27 @@
7506 state = 0;
7508 return(state);
7509 +#if defined(PROTO_SDL_H)
7510 + AROS_LIBFUNC_EXIT
7511 +#endif
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)
7520 +#else
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)
7528 + AROS_LIBFUNC_INIT
7529 +#endif
7530 int retval;
7532 if ( ! ValidJoystick(&joystick) ) {
7533 @@ -327,13 +474,25 @@
7534 retval = -1;
7536 return(retval);
7537 +#if defined(PROTO_SDL_H)
7538 + AROS_LIBFUNC_EXIT
7539 +#endif
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)
7548 +#else
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)
7554 + AROS_LIBFUNC_INIT
7555 +#endif
7556 Uint8 state;
7558 if ( ! ValidJoystick(&joystick) ) {
7559 @@ -346,13 +505,24 @@
7560 state = 0;
7562 return(state);
7563 +#if defined(PROTO_SDL_H)
7564 + AROS_LIBFUNC_EXIT
7565 +#endif
7569 * Close a joystick previously opened with SDL_JoystickOpen()
7571 +#if !defined(PROTO_SDL_H)
7572 void SDL_JoystickClose(SDL_Joystick *joystick)
7574 +#else
7575 +AROS_LH1(void, SDL_JoystickClose,
7576 + AROS_LHA(SDL_Joystick *, joystick, A0),
7577 + struct SDLBase *, SDLBase, 106, SDL)
7579 + AROS_LIBFUNC_INIT
7580 +#endif
7581 int i;
7583 if ( ! ValidJoystick(&joystick) ) {
7584 @@ -395,9 +565,17 @@
7585 SDL_free(joystick->buttons);
7587 SDL_free(joystick);
7588 +#if defined(PROTO_SDL_H)
7589 + AROS_LIBFUNC_EXIT
7590 +#endif
7594 +#if !defined(PROTO_SDL_H)
7595 void SDL_JoystickQuit(void)
7596 +#else
7597 +void SDL_JoystickQuitI(struct SDLBase *SDLBase)
7598 +#endif
7600 const int numsticks = SDL_numjoysticks;
7601 int i;
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)
7609 +#else
7610 +int SDL_PrivateJoystickAxisI(SDL_Joystick *joystick, Uint8 axis, Sint16 value, struct SDLBase *SDLBase)
7611 +#endif
7613 int posted;
7615 @@ -459,7 +640,11 @@
7616 return(posted);
7619 +#if !defined(PROTO_SDL_H)
7620 int SDL_PrivateJoystickHat(SDL_Joystick *joystick, Uint8 hat, Uint8 value)
7621 +#else
7622 +int SDL_PrivateJoystickHatI(SDL_Joystick *joystick, Uint8 hat, Uint8 value, struct SDLBase *SDLBase)
7623 +#endif
7625 int posted;
7627 @@ -489,8 +674,13 @@
7628 return(posted);
7631 +#if !defined(PROTO_SDL_H)
7632 int SDL_PrivateJoystickBall(SDL_Joystick *joystick, Uint8 ball,
7633 Sint16 xrel, Sint16 yrel)
7634 +#else
7635 +int SDL_PrivateJoystickBallI(SDL_Joystick *joystick, Uint8 ball,
7636 + Sint16 xrel, Sint16 yrel, struct SDLBase *SDLBase)
7637 +#endif
7639 int posted;
7641 @@ -522,7 +712,11 @@
7642 return(posted);
7645 +#if !defined(PROTO_SDL_H)
7646 int SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state)
7647 +#else
7648 +int SDL_PrivateJoystickButtonI(SDL_Joystick *joystick, Uint8 button, Uint8 state, struct SDLBase *SDLBase)
7649 +#endif
7651 int posted;
7652 #if !SDL_EVENTS_DISABLED
7653 @@ -565,17 +759,35 @@
7654 return(posted);
7657 +#if !defined(PROTO_SDL_H)
7658 void SDL_JoystickUpdate(void)
7660 +#else
7661 +AROS_LH0(void, SDL_JoystickUpdate,
7662 + struct SDLBase *, SDLBase, 100, SDL)
7664 + AROS_LIBFUNC_INIT
7665 +#endif
7666 int i;
7668 for ( i=0; SDL_joysticks[i]; ++i ) {
7669 SDL_SYS_JoystickUpdate(SDL_joysticks[i]);
7671 +#if defined(PROTO_SDL_H)
7672 + AROS_LIBFUNC_EXIT
7673 +#endif
7676 +#if !defined(PROTO_SDL_H)
7677 int SDL_JoystickEventState(int state)
7679 +#else
7680 +AROS_LH1(int, SDL_JoystickEventState,
7681 + AROS_LHA(int, state, D0),
7682 + struct SDLBase *, SDLBase, 101, SDL)
7684 + AROS_LIBFUNC_INIT
7685 +#endif
7686 #if SDL_EVENTS_DISABLED
7687 return SDL_IGNORE;
7688 #else
7689 @@ -603,4 +815,7 @@
7691 return(state);
7692 #endif /* SDL_EVENTS_DISABLED */
7693 +#if defined(PROTO_SDL_H)
7694 + AROS_LIBFUNC_EXIT
7695 +#endif
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
7700 @@ -28,6 +28,7 @@
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,
7708 @@ -36,3 +37,19 @@
7709 Uint8 hat, Uint8 value);
7710 extern int SDL_PrivateJoystickButton(SDL_Joystick *joystick,
7711 Uint8 button, Uint8 state);
7712 +#else
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)
7727 +#endif
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
7731 @@ -55,28 +55,39 @@
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);
7761 +#else
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)
7776 +#endif
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
7780 @@ -19,6 +19,11 @@
7781 Sam Lantinga
7782 slouken@libsdl.org
7784 +#if defined (SDL_AROS_SHARED)
7785 +#define __NOLIBBASE__
7786 +#include <proto/SDL.h>
7787 +#endif
7789 #include "SDL_config.h"
7791 #if defined(SDL_LOADSO_DUMMY) || defined(SDL_LOADSO_DISABLED)
7792 @@ -28,21 +33,33 @@
7794 #include "SDL_loadso.h"
7796 +#if !defined(PROTO_SDL_H)
7797 void *SDL_LoadObject(const char *sofile)
7798 +#else
7799 +void *SDL_LoadObject(const char *sofile, struct Library *SDLBase)
7800 +#endif
7802 const char *loaderror = "SDL_LoadObject() not implemented";
7803 SDL_SetError("Failed loading %s: %s", sofile, loaderror);
7804 return(NULL);
7807 +#if !defined(PROTO_SDL_H)
7808 void *SDL_LoadFunction(void *handle, const char *name)
7809 +#else
7810 +void *SDL_LoadFunction(void *handle, const char *name, struct Library *SDLBase)
7811 +#endif
7813 const char *loaderror = "SDL_LoadFunction() not implemented";
7814 SDL_SetError("Failed loading %s: %s", name, loaderror);
7815 return(NULL);
7818 +#if !defined(PROTO_SDL_H)
7819 void SDL_UnloadObject(void *handle)
7820 +#else
7821 +void SDL_UnloadObject(void *handle, struct Library *SDLBase)
7822 +#endif
7824 /* no-op. */
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
7829 @@ -0,0 +1,8 @@
7830 +#ifndef MYDEBUG
7831 +#define MYDEBUG
7832 +#ifndef AROS_DEBUG_H
7833 +#include <aros/debug.h>
7834 +#endif
7835 +#define MAKE_HIT() {char *a=NULL,b;b=*a;}
7837 +#endif
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
7841 @@ -19,6 +19,11 @@
7842 Sam Lantinga
7843 slouken@libsdl.org
7845 +#if defined (SDL_AROS_SHARED)
7846 +#define __NOLIBBASE__
7847 +#include <proto/SDL.h>
7848 +#endif
7850 #include "SDL_config.h"
7852 /* Initialization code for SDL */
7853 @@ -33,6 +38,7 @@
7854 #include <pth.h>
7855 #endif
7857 +#if !defined(PROTO_SDL_H)
7858 /* Initialization/Cleanup routines */
7859 #if !SDL_JOYSTICK_DISABLED
7860 extern int SDL_JoystickInit(void);
7861 @@ -47,23 +53,57 @@
7862 extern int SDL_TimerInit(void);
7863 extern void SDL_TimerQuit(void);
7864 #endif
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;
7874 #endif
7876 #ifdef CHECK_LEAKS
7877 int surfaces_allocated = 0;
7878 #endif
7879 +#else
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)
7887 +#endif
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)
7893 +#endif
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)
7901 +#endif
7903 +#define SDL_initialized SDLBase->SDL_initialized
7904 +#define ticks_started SDLBase->ticks_started
7905 +#define surfaces_allocated SDLBase->surfaces_allocated
7906 +#endif
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)
7915 +#else
7916 +AROS_LH1(int, SDL_InitSubSystem,
7917 + AROS_LHA(Uint32, flags, D0),
7918 + struct SDLBase *, SDLBase, 15, SDL)
7920 + AROS_LIBFUNC_INIT
7921 +#endif
7922 #if !SDL_TIMERS_DISABLED
7923 /* Initialize the timer subsystem */
7924 if ( ! ticks_started ) {
7925 @@ -145,10 +185,22 @@
7927 #endif
7928 return(0);
7929 +#if defined(PROTO_SDL_H)
7930 + AROS_LIBFUNC_EXIT
7931 +#endif
7934 +#if !defined(PROTO_SDL_H)
7935 int SDL_Init(Uint32 flags)
7937 +#else
7939 +AROS_LH1(int, SDL_Init,
7940 + AROS_LHA(Uint32, flags, D0),
7941 + struct SDLBase *, SDLBase, 11, SDL)
7943 + AROS_LIBFUNC_INIT
7944 +#endif
7945 #if !SDL_THREADS_DISABLED && SDL_THREAD_PTH
7946 if (!pth_init()) {
7947 return -1;
7948 @@ -168,10 +220,21 @@
7949 SDL_InstallParachute();
7951 return(0);
7952 +#if defined(PROTO_SDL_H)
7953 + AROS_LIBFUNC_EXIT
7954 +#endif
7957 +#if !defined(PROTO_SDL_H)
7958 void SDL_QuitSubSystem(Uint32 flags)
7960 +#else
7961 +AROS_LH1(void, SDL_QuitSubSystem,
7962 + AROS_LHA(Uint32, flags, D0),
7963 + struct SDLBase *, SDLBase, 16, SDL)
7965 + AROS_LIBFUNC_INIT
7966 +#endif
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;
7973 #endif
7974 +#if defined(PROTO_SDL_H)
7975 + AROS_LIBFUNC_EXIT
7976 +#endif
7979 +#if !defined(PROTO_SDL_H)
7980 Uint32 SDL_WasInit(Uint32 flags)
7982 +#else
7983 +AROS_LH1(Uint32, SDL_WasInit,
7984 + AROS_LHA(Uint32, flags, D0),
7985 + struct SDLBase *, SDLBase, 13, SDL)
7987 + AROS_LIBFUNC_INIT
7988 +#endif
7989 if ( ! flags ) {
7990 flags = SDL_INIT_EVERYTHING;
7992 return (SDL_initialized&flags);
7993 +#if defined(PROTO_SDL_H)
7994 + AROS_LIBFUNC_EXIT
7995 +#endif
7998 +#if !defined(PROTO_SDL_H)
7999 void SDL_Quit(void)
8001 +#else
8002 +AROS_LH0(void, SDL_Quit,
8003 + struct SDLBase *, SDLBase, 14, SDL)
8005 + AROS_LIBFUNC_INIT
8006 +#endif
8007 /* Quit all subsystems */
8008 #ifdef DEBUG_BUILD
8009 printf("[SDL_Quit] : Enter! Calling QuitSubSystem()\n"); fflush(stdout);
8010 @@ -245,13 +329,26 @@
8011 #ifdef DEBUG_BUILD
8012 printf("[SDL_Quit] : Returning!\n"); fflush(stdout);
8013 #endif
8015 +#if defined(PROTO_SDL_H)
8016 + AROS_LIBFUNC_EXIT
8017 +#endif
8020 /* Return the library version number */
8021 +#if !defined(PROTO_SDL_H)
8022 const SDL_version * SDL_Linked_Version(void)
8024 +#else
8025 +AROS_LH0(const SDL_version *, SDL_Linked_Version,
8026 + struct SDLBase *, SDLBase, 12, SDL)
8028 + AROS_LIBFUNC_INIT
8029 +#endif
8030 return(&version);
8032 +#if defined(PROTO_SDL_H)
8033 + AROS_LIBFUNC_EXIT
8034 +#endif
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
8041 @@ -19,6 +19,13 @@
8042 Sam Lantinga
8043 slouken@libsdl.org
8045 +#if defined (SDL_AROS_SHARED)
8046 +#define __NOLIBBASE__
8047 +#include <proto/SDL.h>
8048 +#endif
8050 +#define DEBUG_ERROR
8052 #include "SDL_config.h"
8054 /* Simple error handling in SDL */
8055 @@ -27,6 +34,7 @@
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;
8063 @@ -34,6 +42,12 @@
8064 #else
8065 extern SDL_error *SDL_GetErrBuf(void);
8066 #endif /* SDL_THREADS_DISABLED */
8067 +#else
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)
8072 +#endif
8074 #define SDL_ERRBUFIZE 1024
8076 @@ -46,18 +60,30 @@
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)
8086 +#else
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)
8094 - va_list ap;
8095 + AROS_LIBFUNC_INIT
8096 +#endif
8097 SDL_error *error;
8099 + CONST IPTR *ap = params;
8101 /* Copy in the key, mark error as valid */
8102 error = SDL_GetErrBuf();
8103 error->error = 1;
8104 SDL_strlcpy((char *)error->key, fmt, sizeof(error->key));
8106 - va_start(ap, fmt);
8107 error->argc = 0;
8108 while ( *fmt ) {
8109 if ( *fmt++ == '%' ) {
8110 @@ -76,20 +102,20 @@
8111 case 'x':
8112 case 'X':
8113 error->args[error->argc++].value_i =
8114 - va_arg(ap, int);
8115 + fetch_arg(ap, int);
8116 break;
8117 case 'f':
8118 error->args[error->argc++].value_f =
8119 - va_arg(ap, double);
8120 + fetch_arg(ap, double);
8121 break;
8122 case 'p':
8123 error->args[error->argc++].value_ptr =
8124 - va_arg(ap, void *);
8125 + fetch_arg(ap, void *);
8126 break;
8127 case 's':
8129 int i = error->argc;
8130 - const char *str = va_arg(ap, const char *);
8131 + const char *str = fetch_arg(ap, const char *);
8132 if (str == NULL)
8133 str = "(null)";
8134 SDL_strlcpy((char *)error->args[i].buf, str, ERR_MAX_STRLEN);
8135 @@ -104,18 +130,24 @@
8139 - va_end(ap);
8141 /* If we are in debug mode, print out an error message */
8142 #ifdef DEBUG_ERROR
8143 fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError());
8144 #endif
8145 +#if defined(PROTO_SDL_H)
8146 + AROS_LIBFUNC_EXIT
8147 +#endif
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)
8155 +#else
8156 +#define SDL_GetErrorMsg(errstr, maxlen) SDL_GetErrorMsgI(errstr, maxlen, SDLBase)
8157 +char *SDL_GetErrorMsgI(char *errstr, unsigned int maxlen, struct SDLBase *SDLBase)
8158 +#endif
8160 SDL_error *error;
8162 @@ -184,24 +216,52 @@
8165 /* Available for backwards compatibility */
8166 +#if !defined(PROTO_SDL_H)
8167 char *SDL_GetError (void)
8169 +#else
8170 +AROS_LH0(char *, SDL_GetError,
8171 + struct SDLBase *, SDLBase, 123, SDL)
8173 + AROS_LIBFUNC_INIT
8174 +#endif
8175 static char errmsg[SDL_ERRBUFIZE];
8177 return((char *)SDL_GetErrorMsg(errmsg, SDL_ERRBUFIZE));
8178 +#if defined(PROTO_SDL_H)
8179 + AROS_LIBFUNC_EXIT
8180 +#endif
8183 +#if !defined(PROTO_SDL_H)
8184 void SDL_ClearError(void)
8186 +#else
8187 +AROS_LH0(void, SDL_ClearError,
8188 + struct SDLBase *, SDLBase, 124, SDL)
8190 + AROS_LIBFUNC_INIT
8191 +#endif
8192 SDL_error *error;
8194 error = SDL_GetErrBuf();
8195 error->error = 0;
8196 +#if defined(PROTO_SDL_H)
8197 + AROS_LIBFUNC_EXIT
8198 +#endif
8201 /* Very common errors go here */
8202 +#if !defined(PROTO_SDL_H)
8203 void SDL_Error(SDL_errorcode code)
8205 +#else
8206 +AROS_LH1(void, SDL_Error,
8207 + AROS_LHA(SDL_errorcode, code, D0),
8208 + struct SDLBase *, SDLBase, 168, SDL)
8210 + AROS_LIBFUNC_INIT
8211 +#endif
8212 switch (code) {
8213 case SDL_ENOMEM:
8214 SDL_SetError("Out of memory");
8215 @@ -219,6 +279,9 @@
8216 SDL_SetError("Unknown SDL error");
8217 break;
8219 +#if defined(PROTO_SDL_H)
8220 + AROS_LIBFUNC_EXIT
8221 +#endif
8224 #ifdef TEST_ERROR
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
8228 @@ -19,6 +19,11 @@
8229 Sam Lantinga
8230 slouken@libsdl.org
8232 +#if defined (SDL_AROS_SHARED)
8233 +#define __NOLIBBASE__
8234 +#include <proto/SDL.h>
8235 +#endif
8237 #include "SDL_config.h"
8239 /* General fatal signal handling code for SDL */
8240 @@ -38,7 +43,11 @@
8241 static void SDL_Parachute(int sig)
8243 signal(sig, SIG_DFL);
8244 +#if !defined(PROTO_SDL_H)
8245 SDL_Quit();
8246 +#else
8247 + // FIXME: Call SDL_Quit()
8248 +#endif
8249 raise(sig);
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
8255 @@ -19,6 +19,11 @@
8256 Sam Lantinga
8257 slouken@libsdl.org
8259 +#if defined (SDL_AROS_SHARED)
8260 +#define __NOLIBBASE__
8261 +#include <proto/SDL.h>
8262 +#endif
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
8270 @@ -19,6 +19,11 @@
8271 Sam Lantinga
8272 slouken@libsdl.org
8274 +#if defined (SDL_AROS_SHARED)
8275 +#define __NOLIBBASE__
8276 +#include <proto/SDL.h>
8277 +#endif
8279 #include "SDL_config.h"
8281 /* This file contains portable iconv functions for SDL */
8282 @@ -39,12 +44,14 @@
8284 #include <errno.h>
8286 +struct SDLBase;
8288 size_t SDL_iconv(SDL_iconv_t cd,
8289 const char **inbuf, size_t *inbytesleft,
8290 char **outbuf, size_t *outbytesleft)
8292 size_t retCode;
8293 -#ifdef ICONV_INBUF_NONCONST
8294 +#if defined(ICONV_INBUF_NONCONST) || defined(__AROS__)
8295 retCode = iconv(cd, (char **)inbuf, inbytesleft, outbuf, outbytesleft);
8296 #else
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)
8305 +#else
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)
8313 + AROS_LIBFUNC_INIT
8314 +#endif
8315 SDL_iconv_t cd;
8316 char *string;
8317 size_t stringsize;
8318 @@ -878,4 +896,7 @@
8319 SDL_iconv_close(cd);
8321 return string;
8322 +#if defined(PROTO_SDL_H)
8323 + AROS_LIBFUNC_EXIT
8324 +#endif
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
8329 @@ -19,6 +19,11 @@
8330 Sam Lantinga
8331 slouken@libsdl.org
8333 +#if defined (SDL_AROS_SHARED)
8334 +#define __NOLIBBASE__
8335 +#include <proto/SDL.h>
8336 +#endif
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
8344 @@ -41,6 +41,11 @@
8346 * Gareth McCaughan Peterhouse Cambridge 1998
8348 + #if defined (SDL_AROS_SHARED)
8349 +#define __NOLIBBASE__
8350 +#include <proto/SDL.h>
8351 +#endif
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
8359 @@ -19,6 +19,11 @@
8360 Sam Lantinga
8361 slouken@libsdl.org
8363 +#if defined (SDL_AROS_SHARED)
8364 +#define __NOLIBBASE__
8365 +#include <proto/SDL.h>
8366 +#endif
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
8374 @@ -19,6 +19,11 @@
8375 Sam Lantinga
8376 slouken@libsdl.org
8378 +#if defined (SDL_AROS_SHARED)
8379 +#define __NOLIBBASE__
8380 +#include <proto/SDL.h>
8381 +#endif
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
8389 @@ -0,0 +1,297 @@
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
8408 + Sam Lantinga
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!
8416 + Yannick Erb
8417 + yannick.erb@free.fr
8419 + 20110326 Adapted for AROS
8421 + */
8422 +#if defined (SDL_AROS_SHARED)
8423 +#define __NOLIBBASE__
8424 +#include <proto/SDL.h>
8425 +#endif
8427 +#include <stdio.h>
8428 +#include <stdlib.h>
8430 +#include "SDL_error.h"
8431 +#include "SDL_thread.h"
8433 +struct SDLBase;
8435 +struct SDL_cond
8437 + SDL_mutex *lock;
8438 + int waiting;
8439 + int signals;
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)
8448 +#else
8449 +AROS_LH0(SDL_cond *, SDL_CreateCond,
8450 + struct SDLBase *, SDLBase, 169, SDL)
8452 + AROS_LIBFUNC_INIT
8453 +#endif
8454 + SDL_cond *cond;
8456 + cond = (SDL_cond *) malloc(sizeof(SDL_cond));
8457 + if ( 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);
8464 + cond = NULL;
8466 + } else {
8467 + SDL_OutOfMemory();
8469 + return(cond);
8470 +#if defined(PROTO_SDL_H)
8471 + AROS_LIBFUNC_EXIT
8472 +#endif
8475 +/* Destroy a condition variable */
8476 +#if !defined(PROTO_SDL_H)
8477 +void SDL_DestroyCond(SDL_cond *cond)
8479 +#else
8480 +AROS_LH1(void, SDL_DestroyCond,
8481 + AROS_LHA(SDL_cond *, cond, A0),
8482 + struct SDLBase *, SDLBase, 170, SDL)
8484 + AROS_LIBFUNC_INIT
8485 +#endif
8486 + if ( cond ) {
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);
8496 + free(cond);
8498 +#if defined(PROTO_SDL_H)
8499 + AROS_LIBFUNC_EXIT
8500 +#endif
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)
8507 +#else
8508 +AROS_LH1(int, SDL_CondSignal,
8509 + AROS_LHA(SDL_cond *, cond, A0),
8510 + struct SDLBase *, SDLBase, 171, SDL)
8512 + AROS_LIBFUNC_INIT
8513 +#endif
8514 + if ( ! cond ) {
8515 + SDL_SetError("Passed a NULL condition variable");
8516 + return -1;
8519 + /* If there are waiting threads not already signalled, then
8520 + signal the condition and wait for the thread to respond.
8521 + */
8522 + SDL_LockMutex(cond->lock);
8523 + if ( cond->waiting > cond->signals ) {
8524 + ++cond->signals;
8525 + SDL_SemPost(cond->wait_sem);
8526 + SDL_UnlockMutex(cond->lock);
8527 + SDL_SemWait(cond->wait_done);
8528 + } else {
8529 + SDL_UnlockMutex(cond->lock);
8532 + return 0;
8533 +#if defined(PROTO_SDL_H)
8534 + AROS_LIBFUNC_EXIT
8535 +#endif
8538 +/* Restart all threads that are waiting on the condition variable */
8539 +#if !defined(PROTO_SDL_H)
8540 +int SDL_CondBroadcast(SDL_cond *cond)
8542 +#else
8543 +AROS_LH1(int, SDL_CondBroadcast,
8544 + AROS_LHA(SDL_cond *, cond, A0),
8545 + struct SDLBase *, SDLBase, 172, SDL)
8547 + AROS_LIBFUNC_INIT
8548 +#endif
8549 + if ( ! cond ) {
8550 + SDL_SetError("Passed a NULL condition variable");
8551 + return -1;
8554 + /* If there are waiting threads not already signalled, then
8555 + signal the condition and wait for the thread to respond.
8556 + */
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!) :-)
8568 + */
8569 + SDL_UnlockMutex(cond->lock);
8570 + for ( i=0; i<num_waiting; ++i ) {
8571 + SDL_SemWait(cond->wait_done);
8573 + } else {
8574 + SDL_UnlockMutex(cond->lock);
8577 + return 0;
8578 +#if defined(PROTO_SDL_H)
8579 + AROS_LIBFUNC_EXIT
8580 +#endif
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.
8587 +Typical use:
8589 +Thread A:
8590 + SDL_LockMutex(lock);
8591 + while ( ! condition ) {
8592 + SDL_CondWait(cond);
8594 + SDL_UnlockMutex(lock);
8596 +Thread B:
8597 + SDL_LockMutex(lock);
8598 + ...
8599 + condition = true;
8600 + ...
8601 + SDL_UnlockMutex(lock);
8602 + */
8603 +#if !defined(PROTO_SDL_H)
8604 +int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
8606 +#else
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)
8613 + AROS_LIBFUNC_INIT
8614 +#endif
8615 + int retval;
8617 + if ( ! cond ) {
8618 + SDL_SetError("Passed a NULL condition variable");
8619 + return -1;
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.
8625 + */
8626 + SDL_LockMutex(cond->lock);
8627 + ++cond->waiting;
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);
8636 + } else {
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
8645 + */
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 */
8656 + --cond->signals;
8658 + --cond->waiting;
8659 + SDL_UnlockMutex(cond->lock);
8661 + /* Lock the mutex, as is required by condition variable semantics */
8662 + SDL_LockMutex(mutex);
8664 + return retval;
8665 +#if defined(PROTO_SDL_H)
8666 + AROS_LIBFUNC_EXIT
8667 +#endif
8670 +/* Wait on the condition variable forever */
8671 +#if !defined(PROTO_SDL_H)
8672 +int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex)
8674 +#else
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)
8680 + AROS_LIBFUNC_INIT
8681 +#endif
8682 + return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT);
8683 +#if defined(PROTO_SDL_H)
8684 + AROS_LIBFUNC_EXIT
8685 +#endif
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
8690 @@ -0,0 +1,179 @@
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
8709 + Sam Lantinga
8710 + slouken@libsdl.org
8712 +#if defined (SDL_AROS_SHARED)
8713 +#define __NOLIBBASE__
8714 +#include <proto/SDL.h>
8715 +#endif
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"
8725 +struct SDLBase;
8727 +struct SDL_mutex {
8728 + int recursive;
8729 + Uint32 owner;
8730 + SDL_sem *sem;
8733 +/* Create a mutex */
8734 +#if !defined(PROTO_SDL_H)
8735 +SDL_mutex *SDL_CreateMutex(void)
8737 +#else
8738 +AROS_LH0(SDL_mutex *, SDL_CreateMutex,
8739 + struct SDLBase *, SDLBase, 157, SDL)
8741 + AROS_LIBFUNC_INIT
8742 +#endif
8743 + SDL_mutex *mutex;
8745 + /* Allocate mutex memory */
8746 + mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
8747 + if ( mutex ) {
8748 + /* Create the mutex semaphore, with initial value 1 */
8749 + mutex->sem = SDL_CreateSemaphore(1);
8750 + mutex->recursive = 0;
8751 + mutex->owner = 0;
8752 + if ( ! mutex->sem ) {
8753 + SDL_free(mutex);
8754 + mutex = NULL;
8756 + } else {
8757 + SDL_OutOfMemory();
8759 + return mutex;
8760 +#if defined(PROTO_SDL_H)
8761 + AROS_LIBFUNC_EXIT
8762 +#endif
8765 +/* Free the mutex */
8766 +#if !defined(PROTO_SDL_H)
8767 +void SDL_DestroyMutex(SDL_mutex *mutex)
8769 +#else
8770 +AROS_LH1(void, SDL_DestroyMutex,
8771 + AROS_LHA(SDL_mutex *, mutex, A0),
8772 + struct SDLBase *, SDLBase, 158, SDL)
8774 + AROS_LIBFUNC_INIT
8775 +#endif
8776 + if ( mutex ) {
8777 + if ( mutex->sem ) {
8778 + SDL_DestroySemaphore(mutex->sem);
8780 + SDL_free(mutex);
8782 +#if defined(PROTO_SDL_H)
8783 + AROS_LIBFUNC_EXIT
8784 +#endif
8787 +/* Lock the semaphore */
8788 +#if !defined(PROTO_SDL_H)
8789 +int SDL_mutexP(SDL_mutex *mutex)
8791 +#else
8792 +AROS_LH1(int, SDL_mutexP,
8793 + AROS_LHA(SDL_mutex *, mutex, A0),
8794 + struct SDLBase *, SDLBase, 159, SDL)
8796 + AROS_LIBFUNC_INIT
8797 +#endif
8798 +#ifdef DISABLE_THREADS
8799 + return 0;
8800 +#else
8801 + Uint32 this_thread;
8803 + if ( mutex == NULL ) {
8804 + SDL_SetError("Passed a NULL mutex");
8805 + return -1;
8808 + this_thread = SDL_ThreadID();
8809 + if ( mutex->owner == this_thread ) {
8810 + ++mutex->recursive;
8811 + } else {
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.
8815 + */
8816 + SDL_SemWait(mutex->sem);
8817 + mutex->owner = this_thread;
8818 + mutex->recursive = 0;
8821 + return 0;
8822 +#endif /* DISABLE_THREADS */
8823 +#if defined(PROTO_SDL_H)
8824 + AROS_LIBFUNC_EXIT
8825 +#endif
8828 +/* Unlock the mutex */
8829 +#if !defined(PROTO_SDL_H)
8830 +int SDL_mutexV(SDL_mutex *mutex)
8832 +#else
8833 +AROS_LH1(int, SDL_mutexV,
8834 + AROS_LHA(SDL_mutex *, mutex, A0),
8835 + struct SDLBase *, SDLBase, 160, SDL)
8837 + AROS_LIBFUNC_INIT
8838 +#endif
8839 +#ifdef DISABLE_THREADS
8840 + return 0;
8841 +#else
8842 + if ( mutex == NULL ) {
8843 + SDL_SetError("Passed a NULL mutex");
8844 + return -1;
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");
8850 + return -1;
8853 + if ( mutex->recursive ) {
8854 + --mutex->recursive;
8855 + } else {
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.
8860 + */
8861 + mutex->owner = 0;
8862 + SDL_SemPost(mutex->sem);
8864 + return 0;
8865 +#endif /* DISABLE_THREADS */
8866 +#if defined(PROTO_SDL_H)
8867 + AROS_LIBFUNC_EXIT
8868 +#endif
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
8873 @@ -0,0 +1,658 @@
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
8893 + Sam Lantinga
8894 + slouken@libsdl.org
8896 + Harry Sintonen
8897 + sintonen@iki.fi
8899 + 20040824 Non-polling SDL_SemWaitTimeout
8900 + Optimized
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
8914 + Yannick Erb
8915 + yannick.erb@free.fr
8917 + 20110326 Adapted for AROS
8920 +#if defined (SDL_AROS_SHARED)
8921 +#define __NOLIBBASE__
8922 +#include <proto/SDL.h>
8923 +#endif
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;
8940 +#else
8941 +#include "SDL_intern.h"
8943 +#define TimerIO SDLBase->TimerIO
8944 +#endif
8946 +struct waitnode
8948 + struct MinNode node;
8949 + struct Task *task;
8950 + ULONG sigmask;
8953 +struct SDL_semaphore
8955 + struct SignalSemaphore sem;
8956 + struct MinList waitlist;
8957 + int sem_value;
8960 +struct mywaitdata
8962 + struct MsgPort port;
8963 + struct timerequest timereq;
8964 + ULONG extramask;
8965 + BOOL pending;
8968 +#define FALLBACKSIGNAL SIGBREAKB_CTRL_E
8970 +static
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)
8988 +static
8989 +int mywaitinit(struct mywaitdata *data, Uint32 timeout)
8990 +#else
8991 +#define mywaitinit(data, timeout) mywaitinitI(data, timeout, SDLBase)
8992 +static int mywaitinitI(struct mywaitdata *data, Uint32 timeout, struct SDLBase *SDLBase)
8993 +#endif
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;
9014 + return 0;
9017 + mywaitdone(data);
9019 + return -1;
9022 +static
9023 +int mywait(struct mywaitdata *data, Uint32 timeout)
9025 + ULONG wsig, sigs;
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);
9040 + if (sigs & wsig)
9042 + data->pending = FALSE;
9043 + WaitIO((struct IORequest *) &data->timereq);
9045 + else
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)
9059 + return -1;
9062 + return 0;
9065 +/* Create a semaphore, initialized with value */
9066 +#if !defined(PROTO_SDL_H)
9067 +SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
9069 +#else
9070 +AROS_LH1(SDL_sem *, SDL_CreateSemaphore,
9071 + AROS_LHA(Uint32, initial_value, D0),
9072 + struct SDLBase *, SDLBase, 161, SDL)
9074 + AROS_LIBFUNC_INIT
9075 +#endif
9076 + SDL_sem *sem;
9078 + D(bug("[SDL] SDL_CreateSemaphore(%ld)\n", initial_value));
9080 + sem = malloc(sizeof(*sem));
9081 + if (sem)
9083 + memset(&sem->sem, 0, sizeof(sem->sem));
9084 + InitSemaphore(&sem->sem);
9086 + NEWLIST(&sem->waitlist);
9088 + sem->sem_value = initial_value;
9090 + else
9092 + SDL_OutOfMemory();
9095 + return sem;
9096 +#if defined(PROTO_SDL_H)
9097 + AROS_LIBFUNC_EXIT
9098 +#endif
9101 +#if !defined(PROTO_SDL_H)
9102 +void SDL_DestroySemaphore(SDL_sem *sem)
9104 +#else
9105 +AROS_LH1(void, SDL_DestroySemaphore,
9106 + AROS_LHA(SDL_sem *, sem, A0),
9107 + struct SDLBase *, SDLBase, 162, SDL)
9109 + AROS_LIBFUNC_INIT
9110 +#endif
9111 + D(bug("[SDL] SDL_DestroySemaphore()\n"));
9112 + D(bug("Destroying semaphore %lx...\n",sem));
9114 + if (sem)
9116 + #if 1
9118 + struct mywaitdata data;
9120 + if (mywaitinit(&data, 10) == 0)
9122 + ObtainSemaphore(&sem->sem);
9124 + sem->sem_value = -1;
9126 + while (!IsListEmpty((struct List *) &sem->waitlist))
9128 + struct waitnode *wn;
9129 + int res;
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);
9146 + if (res < 0)
9148 + break;
9152 + ReleaseSemaphore(&sem->sem);
9155 + mywaitdone(&data);
9157 + #endif
9159 + free(sem);
9161 +#if defined(PROTO_SDL_H)
9162 + AROS_LIBFUNC_EXIT
9163 +#endif
9166 +#if !defined(PROTO_SDL_H)
9167 +int SDL_SemTryWait(SDL_sem *sem)
9169 +#else
9170 +AROS_LH1(int, SDL_SemTryWait,
9171 + AROS_LHA(SDL_sem *, sem, A0),
9172 + struct SDLBase *, SDLBase, 163, SDL)
9174 + AROS_LIBFUNC_INIT
9175 +#endif
9176 + int retval;
9178 + D(bug("[SDL] SDL_SemTryWait()\n"));
9180 + if (!sem)
9182 + SDL_SetError("Passed a NULL semaphore");
9183 + return -1;
9186 + ObtainSemaphore(&sem->sem);
9188 + if (sem->sem_value > 0)
9190 + --sem->sem_value;
9191 + retval = 0;
9193 + else
9195 + retval = SDL_MUTEX_TIMEDOUT;
9198 + ReleaseSemaphore(&sem->sem);
9200 + return retval;
9201 +#if defined(PROTO_SDL_H)
9202 + AROS_LIBFUNC_EXIT
9203 +#endif
9206 +#if !defined(PROTO_SDL_H)
9207 +int SDL_SemWait(SDL_sem *sem)
9209 +#else
9210 +AROS_LH1(int, SDL_SemWait,
9211 + AROS_LHA(SDL_sem *, sem, A0),
9212 + struct SDLBase *, SDLBase, 165, SDL)
9214 + AROS_LIBFUNC_INIT
9215 +#endif
9216 + int retval;
9217 + struct waitnode wn;
9218 + LONG signal;
9220 + D(bug("[SDL] SDL_SemWait(0x%08.8lx) from thread 0x%08.8lx\n", (IPTR)sem, (IPTR)FindTask(NULL)));
9222 + if (!sem)
9224 + SDL_SetError("Passed a NULL semaphore");
9225 + return -1;
9228 + retval = 0;
9229 + signal = -1;
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)
9237 + ULONG sigmask;
9239 + if (signal == -1)
9241 + wn.task = FindTask(NULL);
9242 + signal = AllocSignal(-1);
9243 + if (signal == -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"));
9264 + retval = -1;
9265 + break;
9269 + if (signal != -1)
9271 + REMOVE(&wn);
9273 + if (signal != FALLBACKSIGNAL)
9275 + FreeSignal(signal);
9279 + if (retval == 0)
9281 + --sem->sem_value;
9283 + D(bug("[SDL] SDL_SemWait(): final sem_value: %ld\n", sem->sem_value));
9286 + ReleaseSemaphore(&sem->sem);
9287 + D(bug("done...\n"));
9289 + return retval;
9290 +#if defined(PROTO_SDL_H)
9291 + AROS_LIBFUNC_EXIT
9292 +#endif
9295 +#if !defined(PROTO_SDL_H)
9296 +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
9298 +#else
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)
9304 + AROS_LIBFUNC_INIT
9305 +#endif
9306 + struct mywaitdata data;
9307 + int retval;
9309 + D(bug("[SDL] SDL_SemWaitTimeout()\n"));
9311 + if (!sem)
9313 + SDL_SetError("Passed a NULL semaphore");
9314 + return -1;
9317 + /* Try the easy cases first */
9318 + if (timeout == 0)
9320 + return SDL_SemTryWait(sem);
9322 + if (timeout == SDL_MUTEX_MAXWAIT)
9324 + return SDL_SemWait(sem);
9327 + #if 1
9329 + if (mywaitinit(&data, timeout) == 0)
9331 + struct waitnode wn;
9332 + LONG signal;
9334 + retval = 0;
9335 + signal = -1;
9337 + ObtainSemaphore(&sem->sem);
9339 + while (sem->sem_value <= 0)
9341 + if (signal == -1)
9343 + wn.task = FindTask(NULL);
9344 + signal = AllocSignal(-1);
9345 + if (signal == -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);
9362 + /* CTRL-C? */
9363 + if (retval < 0)
9365 + break;
9368 + /* Timed out? (== no 'semaphore released'-signal) */
9369 + if (data.extramask == 0)
9371 + retval = SDL_MUTEX_TIMEDOUT;
9373 + break;
9376 + /*
9377 + * Not timed out, someone released the semaphore.
9378 + * See if we can get it. If we can't, continue waiting.
9379 + */
9382 + if (signal != -1)
9384 + REMOVE(&wn);
9386 + if (signal != FALLBACKSIGNAL)
9388 + FreeSignal(signal);
9392 + /* If can obtain (no timeout, no break), obtain it */
9393 + if (retval == 0)
9395 + --sem->sem_value;
9397 + D(bug("[SDL] SDL_SemWaitTimeout(): final sem_value: %ld\n", sem->sem_value));
9400 + ReleaseSemaphore(&sem->sem);
9402 + else retval = -1;
9404 + mywaitdone(&data);
9406 + #else
9408 + /* Ack! We have to busy wait... */
9409 + timeout += SDL_GetTicks();
9411 + if (mywaitinit(&data, 1) == 0)
9413 + do
9415 + retval = SDL_SemTryWait(sem);
9416 + if (retval == 0)
9418 + break;
9421 + if (mywait(&data, 1) < 0)
9423 + retval = -1;
9424 + break;
9427 + } while (SDL_GetTicks() < timeout);
9429 + else retval = -1;
9431 + mywaitdone(&data);
9433 + #endif
9435 + return retval;
9436 +#if defined(PROTO_SDL_H)
9437 + AROS_LIBFUNC_EXIT
9438 +#endif
9441 +#if !defined(PROTO_SDL_H)
9442 +Uint32 SDL_SemValue(SDL_sem *sem)
9444 +#else
9445 +AROS_LH1(Uint32, SDL_SemValue,
9446 + AROS_LHA(SDL_sem *, sem, A0),
9447 + struct SDLBase *, SDLBase, 166, SDL)
9449 + AROS_LIBFUNC_INIT
9450 +#endif
9451 + int retval;
9453 + D(bug("[SDL] SDL_SemValue()\n"));
9455 + if (!sem)
9457 + SDL_SetError("Passed a NULL semaphore");
9458 + return 0;
9461 + ObtainSemaphoreShared(&sem->sem);
9463 + retval = sem->sem_value;
9465 + ReleaseSemaphore(&sem->sem);
9467 + if (retval < 0)
9469 + retval = 0;
9472 + return (Uint32) retval;
9473 +#if defined(PROTO_SDL_H)
9474 + AROS_LIBFUNC_EXIT
9475 +#endif
9478 +#if !defined(PROTO_SDL_H)
9479 +int SDL_SemPost(SDL_sem *sem)
9481 +#else
9482 +AROS_LH1(int, SDL_SemPost,
9483 + AROS_LHA(SDL_sem *, sem, A0),
9484 + struct SDLBase *, SDLBase, 167, SDL)
9486 + AROS_LIBFUNC_INIT
9487 +#endif
9488 + struct waitnode *wn;
9490 + if (!sem)
9492 + SDL_SetError("Passed a NULL semaphore");
9493 + return -1;
9496 + ObtainSemaphore(&sem->sem);
9498 + D(bug("[SDL] SDL_SemPost(0x%08.8lx): initial sem_value: %ld\n", (IPTR)sem, sem->sem_value));
9500 + #if 1
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);
9509 + #else
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);
9518 + #endif
9520 + ++sem->sem_value;
9522 + D(bug("[SDL] SDL_SemPost(): final sem_value: %ld\n", sem->sem_value));
9524 + ReleaseSemaphore(&sem->sem);
9526 + return 0;
9527 +#if defined(PROTO_SDL_H)
9528 + AROS_LIBFUNC_EXIT
9529 +#endif
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
9535 @@ -0,0 +1,173 @@
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
9554 + Sam Lantinga
9555 + slouken@libsdl.org
9558 +#if defined (SDL_AROS_SHARED)
9559 +#define __NOLIBBASE__
9560 +#include <proto/SDL.h>
9561 +#endif
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"
9573 +struct SDLBase;
9575 +typedef struct {
9576 + int (*func)(void *);
9577 + void *data;
9578 + SDL_Thread *info;
9579 + struct Task *wait;
9580 +#if defined(PROTO_SDL_H)
9581 + struct SDLBase *base;
9582 +#endif
9583 +} thread_args;
9585 +#if !defined(PROTO_SDL_H)
9586 +extern int SDL_numthreads;
9587 +#else
9588 +#include "SDL_intern.h"
9590 +#define SDL_numthreads SDLBase->SDL_numthreads
9591 +void __aros_setoffsettable(void *base);
9592 +#endif
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);
9600 +#endif
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));
9610 + return(0);
9613 +#if !defined(PROTO_SDL_H)
9614 +int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
9615 +#else
9616 +int SDL_SYS_CreateThreadI(SDL_Thread *thread, void *args, struct SDLBase *SDLBase)
9617 +#endif
9619 + /* Create the thread and go! */
9620 + char buffer[20];
9622 + D(bug("Sending %lx to the new thread...\n",args));
9624 + if(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);
9635 + else
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));
9641 +#endif
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,
9648 +#else
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,
9654 +#endif
9655 + NP_CloseOutput, FALSE,
9656 + TAG_DONE);
9658 + if(!thread->handle)
9660 + SDL_SetError("Not enough resources to create thread");
9661 + return(-1);
9664 + return(0);
9667 +#if !defined(PROTO_SDL_H)
9668 +void SDL_SYS_SetupThread(void)
9669 +#else
9670 +void SDL_SYS_SetupThreadI(struct SDLBase *SDLBase)
9671 +#endif
9675 +#if !defined(PROTO_SDL_H)
9676 +Uint32 SDL_ThreadID(void)
9678 +#else
9679 +AROS_LH0(Uint32, SDL_ThreadID,
9680 + struct SDLBase *, SDLBase, 141, SDL)
9682 + AROS_LIBFUNC_INIT
9683 +#endif
9684 + /* FIXME: ThreadID may be NON-UNIQUE on 64-bit architectures! */
9685 + return((Uint32)(IPTR)FindTask(NULL));
9686 +#if defined(PROTO_SDL_H)
9687 + AROS_LIBFUNC_EXIT
9688 +#endif
9691 +#if !defined(PROTO_SDL_H)
9692 +void SDL_SYS_WaitThread(SDL_Thread *thread)
9693 +#else
9694 +void SDL_SYS_WaitThreadI(SDL_Thread *thread, struct SDLBase *SDLBase)
9695 +#endif
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)
9703 +#else
9704 +void SDL_SYS_KillThreadI(SDL_Thread *thread, struct SDLBase *SDLBase)
9705 +#endif
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
9712 @@ -0,0 +1,36 @@
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
9731 + Sam Lantinga
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
9752 @@ -0,0 +1,408 @@
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
9771 + Sam Lantinga
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>
9787 +#endif
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 +#define threadlock_ptr &thread_lock
9814 +#else
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
9823 +#endif
9825 +/* Arguments and callback to setup and run the user thread function */
9826 +typedef struct {
9827 + int (*func)(void *);
9828 + void *data;
9829 + SDL_Thread *info;
9830 + struct Task *wait;
9831 +#if defined(PROTO_SDL_H)
9832 + struct SDLBase *base;
9833 +#endif
9834 +} thread_args;
9836 +#if !defined(PROTO_SDL_H)
9837 +int SDL_ThreadsInit(void)
9838 +#else
9839 +#define SDL_ThreadsInit() SDL_ThreadsInitI(SDLBase)
9840 +int SDL_ThreadsInitI(struct SDLBase *SDLBase)
9841 +#endif
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));
9847 +#endif
9848 + InitSemaphore(threadlock_ptr);
9849 + thread_lock_created=1;
9850 +#if defined(PROTO_SDL_H)
9852 + else
9853 + return -1;
9854 +#endif
9855 + return 0;
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.
9862 + */
9863 +#if !defined(PROTO_SDL_H)
9864 +void SDL_ThreadsQuit()
9865 +#else
9866 +#define SDL_ThreadsQuit() SDL_ThreadsQuitI(SDLBase)
9867 +void SDL_ThreadsQuitI(struct SDLBase *SDLBase)
9868 +#endif
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)
9876 +#else
9877 +#define SDL_AddThread(thread) SDL_AddThreadI(thread, SDLBase)
9878 +static void SDL_AddThreadI(SDL_Thread *thread, struct SDLBase *SDLBase)
9879 +#endif
9881 + SDL_Thread **threads;
9883 + /* WARNING:
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.
9888 + */
9889 + if ( !thread_lock_created ) {
9890 + if ( SDL_ThreadsInit() < 0 ) {
9891 + return;
9894 + if ( !threadlock_ptr )
9896 + return;
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);
9905 +#endif
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();
9911 + goto done;
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;
9921 +done:
9922 + ReleaseSemaphore(threadlock_ptr);
9925 +#if !defined(PROTO_SDL_H)
9926 +static void SDL_DelThread(SDL_Thread *thread)
9927 +#else
9928 +#define SDL_DelThread(thread) SDL_DelThreadI(thread, SDLBase)
9929 +static void SDL_DelThreadI(SDL_Thread *thread, struct SDLBase *SDLBase)
9930 +#endif
9932 + int i;
9934 + if ( !threadlock_ptr )
9936 + return;
9938 + if ( thread_lock_created ) {
9939 + ObtainSemaphore(threadlock_ptr);
9940 + for ( i=0; i<SDL_numthreads; ++i ) {
9941 + if ( thread == SDL_Threads[i] ) {
9942 + break;
9945 + if ( i < SDL_numthreads ) {
9946 + --SDL_numthreads;
9947 + while ( i < SDL_numthreads ) {
9948 + SDL_Threads[i] = SDL_Threads[i+1];
9949 + ++i;
9951 +#ifdef DEBUG_THREADS
9952 + printf("Deleting thread (%d left - %d max)\n",
9953 + SDL_numthreads, SDL_maxthreads);
9954 +#endif
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)
9963 +#else
9964 +SDL_error *SDL_GetErrBufI(struct SDLBase *SDLBase)
9965 +#endif
9967 + SDL_error *errbuf = NULL;
9969 + errbuf = &SDL_global_error;
9970 + if ( SDL_Threads ) {
9971 + int i;
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;
9981 + break;
9984 + ReleaseSemaphore(threadlock_ptr);
9987 + return(errbuf);
9990 +void SDL_RunThread(void *data)
9992 + thread_args *args;
9993 + int (*userfunc)(void *);
9994 + void *userdata;
9995 + int *statusloc;
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();
10001 +#endif
10002 + /* Perform any system-dependent setup
10003 + - this function cannot fail, and cannot use SDL_SetError()
10004 + */
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)
10024 +#else
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
10031 +#endif
10033 + SDL_Thread *thread;
10034 + thread_args *args;
10035 + int ret;
10037 + /* Allocate memory for the thread info structure */
10038 + thread = (SDL_Thread *)SDL_malloc(sizeof(*thread));
10039 + if ( thread == NULL ) {
10040 + SDL_OutOfMemory();
10041 + return(NULL);
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);
10051 + return(NULL);
10053 +#if defined(PROTO_SDL_H)
10054 + args->base = SDLBase;
10055 +#endif
10056 + args->func = fn;
10057 + args->data = data;
10058 + args->info = thread;
10059 + args->wait = FindTask(NULL);
10061 + if ( args->wait == NULL ) {
10062 + SDL_free(thread);
10063 + SDL_free(args);
10064 + SDL_OutOfMemory();
10065 + return(NULL);
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."));
10080 + } else {
10081 + /* Oops, failed. Gotta free everything */
10082 + SDL_DelThread(thread);
10083 + SDL_free(thread);
10084 + thread = NULL;
10086 + SDL_free(args);
10088 + /* Everything is running now */
10089 + return(thread);
10090 +#if defined(PROTO_SDL_H)
10091 + AROS_LIBFUNC_EXIT
10092 +#endif
10095 +#if !defined(PROTO_SDL_H)
10096 +void SDL_WaitThread(SDL_Thread *thread, int *status)
10098 +#else
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
10105 +#endif
10106 + if ( thread ) {
10107 + SDL_SYS_WaitThread(thread);
10108 + if ( status ) {
10109 + *status = thread->status;
10111 + SDL_DelThread(thread);
10112 + SDL_free(thread);
10114 +#if defined(PROTO_SDL_H)
10115 + AROS_LIBFUNC_EXIT
10116 +#endif
10119 +#if !defined(PROTO_SDL_H)
10120 +Uint32 SDL_GetThreadID(SDL_Thread *thread)
10122 +#else
10123 +AROS_LH1(Uint32, SDL_GetThreadID,
10124 + AROS_LHA(SDL_Thread *, thread, A0),
10125 + struct SDLBase *, SDLBase, 142, SDL)
10127 + AROS_LIBFUNC_INIT
10128 +#endif
10129 + Uint32 id;
10131 + if ( thread ) {
10132 + id = thread->threadid;
10133 + } else {
10134 + id = SDL_ThreadID();
10136 + return(id);
10137 +#if defined(PROTO_SDL_H)
10138 + AROS_LIBFUNC_EXIT
10139 +#endif
10142 +#if !defined(PROTO_SDL_H)
10143 +void SDL_KillThread(SDL_Thread *thread)
10145 +#else
10146 +AROS_LH1(void, SDL_KillThread,
10147 + AROS_LHA(SDL_Thread *, thread, A0),
10148 + struct SDLBase *, SDLBase, 144, SDL)
10150 + AROS_LIBFUNC_INIT
10151 +#endif
10152 + if ( thread ) {
10153 + SDL_SYS_KillThread(thread);
10154 + SDL_WaitThread(thread, NULL);
10156 +#if defined(PROTO_SDL_H)
10157 + AROS_LIBFUNC_EXIT
10158 +#endif
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
10164 @@ -32,6 +32,7 @@
10165 saves a system-dependent thread id in thread->id, and returns 0
10166 on success.
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);
10171 #else
10172 @@ -48,5 +49,17 @@
10174 /* This function kills the thread and returns */
10175 extern void SDL_SYS_KillThread(SDL_Thread *thread);
10176 +#else
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)
10188 +#endif
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
10193 @@ -19,6 +19,11 @@
10194 Sam Lantinga
10195 slouken@libsdl.org
10197 +#if defined (SDL_AROS_SHARED)
10198 +#define __NOLIBBASE__
10199 +#include <proto/SDL.h>
10200 +#endif
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;
10216 +#else
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
10223 +#endif
10225 +#if !defined(PROTO_SDL_H)
10226 int SDL_ThreadsInit(void)
10227 +#else
10228 +int SDL_ThreadsInit(struct SDLBase *SDLBase)
10229 +#endif
10231 int retval;
10233 @@ -55,7 +75,11 @@
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)
10239 +#else
10240 +void SDL_ThreadsQuit(struct SDLBase *SDLBase)
10241 +#endif
10243 SDL_mutex *mutex;
10245 @@ -67,7 +91,11 @@
10248 /* Routines for manipulating the thread list */
10249 +#if !defined(PROTO_SDL_H)
10250 static void SDL_AddThread(SDL_Thread *thread)
10251 +#else
10252 +static void SDL_AddThread(SDL_Thread *thread, struct SDLBase *SDLBase)
10253 +#endif
10255 /* WARNING:
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)
10263 +#else
10264 +static void SDL_DelThread(SDL_Thread *thread, struct SDLBase *SDLBase)
10265 +#endif
10267 int i;
10269 @@ -141,9 +173,6 @@
10270 #endif
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
10282 @@ -43,6 +43,8 @@
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"
10288 #else
10289 #error Need thread implementation for this platform
10290 #include "generic/SDL_systhread_c.h"
10291 @@ -52,6 +54,7 @@
10292 /* This is the system-independent thread info structure */
10293 struct SDL_Thread {
10294 Uint32 threadid;
10295 + Uint32 threadno;
10296 SYS_ThreadHandle handle;
10297 int status;
10298 SDL_error errbuf;
10299 @@ -60,5 +63,4 @@
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
10308 @@ -0,0 +1,337 @@
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
10327 + Sam Lantinga
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>
10336 +#endif
10338 +#include "SDL_config.h"
10340 +#ifdef SDL_TIMER_AROS
10342 +#define __TIMER_NOLIBBASE__
10344 +#include <stdio.h>
10345 +#include <time.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;
10363 +clock_t start;
10364 +struct Device *TimerBase;
10365 +struct timeval basetime;
10366 +struct MsgPort *TimerMP;
10367 +struct Task *OwnerTask;
10368 +int fallback;
10369 +#else
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
10380 +#endif
10382 +/* The first ticks value of the application */
10383 +#if !defined(PROTO_SDL_H)
10384 +static void close_timer(void)
10385 +#else
10386 +#define close_timer() close_timerI(SDLBase)
10387 +void close_timerI(struct SDLBase *SDLBase)
10388 +#endif
10390 + D(bug("freeing timer resources..."));
10391 + if(TimerIO) {
10392 + CloseDevice((struct IORequest *)TimerIO);
10393 + DeleteIORequest((struct IORequest *)TimerIO);
10394 + TimerIO = NULL;
10396 + if(TimerMP) {
10397 + DeleteMsgPort(TimerMP);
10398 + TimerMP = NULL;
10400 + D(bug("OK\n"));
10403 +#if !defined(PROTO_SDL_H)
10404 +static BOOL open_timer(void)
10405 +#else
10406 +#define open_timer() open_timerI(SDLBase)
10407 +static BOOL open_timerI(struct SDLBase *SDLBase)
10408 +#endif
10410 + if (TimerBase || fallback) {
10411 + return FALSE;
10414 + if (!(TimerMP = CreateMsgPort())) {
10415 + start=clock();
10416 + fallback = 1;
10417 + return FALSE;
10420 + if (!(TimerIO = (struct timerequest *)
10421 + CreateIORequest(TimerMP, sizeof(struct timerequest)))) {
10422 + DeleteMsgPort(TimerMP);
10423 + start=clock();
10424 + fallback = 1;
10425 + return FALSE;
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);
10433 + start=clock();
10434 + fallback = 1;
10435 + return FALSE;
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);
10447 +#endif
10449 + return TRUE;
10452 +#if !defined(PROTO_SDL_H)
10453 +void SDL_StartTicks(void)
10454 +#else
10455 +void SDL_StartTicksI(struct SDLBase *SDLBase)
10456 +#endif
10458 + open_timer();
10461 +#if !defined(PROTO_SDL_H)
10462 +Uint32 SDL_GetTicks (void)
10464 +#else
10465 +AROS_LH0(Uint32, SDL_GetTicks,
10466 + struct SDLBase *, SDLBase, 78, SDL)
10468 + AROS_LIBFUNC_INIT
10469 +#endif
10470 + open_timer(); // TimerBase must be set for GetSysTime()
10471 + if (fallback) {
10472 + clock_t ticks;
10474 + ticks=clock()-start;
10476 +#if CLOCKS_PER_SEC == 1000
10477 + return(ticks);
10478 +#else
10479 + return ticks*(1000/CLOCKS_PER_SEC);
10480 +#endif
10482 + else {
10483 + struct timeval tv;
10484 + Uint32 tics;
10486 + GetSysTime(&tv);
10488 + if(basetime.tv_micro > tv.tv_micro) {
10489 + tv.tv_secs --;
10491 + tv.tv_micro += 1000000;
10493 + tics = ((tv.tv_secs - basetime.tv_secs) * 1000) +
10494 + ((tv.tv_micro - basetime.tv_micro)/1000);
10496 + return tics;
10498 +#if defined(PROTO_SDL_H)
10499 + AROS_LIBFUNC_EXIT
10500 +#endif
10503 +#if !defined(PROTO_SDL_H)
10504 +void SDL_Delay (Uint32 ms)
10506 +#else
10507 +AROS_LH1(void, SDL_Delay,
10508 + AROS_LHA(Uint32, ms, D0),
10509 + struct SDLBase *, SDLBase, 79, SDL)
10511 + AROS_LIBFUNC_INIT
10512 +#endif
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);
10527 + else
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
10556 +#endif
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)
10566 +#else
10567 +#define timer_alive SDLBase->timer_alive
10568 +#define timer_thread SDLBase->timer_thread
10570 +static int RunTimer(struct SDLBase *SDLBase)
10571 +#endif
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..."));
10582 + return(0);
10585 +/* This is only called if the event thread is not running */
10586 +#if !defined(PROTO_SDL_H)
10587 +int SDL_SYS_TimerInit(void)
10588 +#else
10589 +int SDL_SYS_TimerInitI(struct SDLBase *SDLBase)
10590 +#endif
10592 + D(bug("Creating thread for the timer (NOITIMER)...\n"));
10594 + timer_alive = 1;
10595 +#if !defined(PROTO_SDL_H)
10596 + timer_thread = SDL_CreateThread(RunTimer, NULL);
10597 +#else
10598 + timer_thread = SDL_CreateThread(RunTimer, SDLBase);
10599 +#endif
10600 + if ( timer_thread == NULL )
10602 + D(bug("Creazione del thread fallita...\n"));
10604 + return(-1);
10606 + return(SDL_SetTimerThreaded(1));
10609 +#if !defined(PROTO_SDL_H)
10610 +void SDL_SYS_TimerQuit(void)
10611 +#else
10612 +void SDL_SYS_TimerQuitI(struct SDLBase *SDLBase)
10613 +#endif
10615 + timer_alive = 0;
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)
10624 +#else
10625 +int SDL_SYS_StartTimerI(struct SDLBase *SDLBase)
10626 +#endif
10628 + SDL_SetError("Internal logic error: AmigaOS uses threaded timer");
10629 + return(-1);
10632 +#if !defined(PROTO_SDL_H)
10633 +void SDL_SYS_StopTimer(void)
10634 +#else
10635 +void SDL_SYS_StopTimerI(struct SDLBase *SDLBase)
10636 +#endif
10638 + return;
10641 +#if defined(PROTO_SDL_H)
10642 +ADD2CLOSELIB(close_timerI, -5);
10643 +#endif
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
10649 @@ -26,7 +26,7 @@
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);
10658 @@ -38,3 +38,14 @@
10660 /* Stop a previously started timer */
10661 extern void SDL_SYS_StopTimer(void);
10662 +#else
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)
10672 +#endif
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
10677 @@ -19,6 +19,11 @@
10678 Sam Lantinga
10679 slouken@libsdl.org
10681 +#if defined (SDL_AROS_SHARED)
10682 +#define __NOLIBBASE__
10683 +#include <proto/SDL.h>
10684 +#endif
10686 #include "SDL_config.h"
10688 #include "SDL_timer.h"
10689 @@ -28,6 +33,15 @@
10691 /* #define DEBUG_TIMERS */
10693 +struct _SDL_TimerID {
10694 + Uint32 interval;
10695 + SDL_NewTimerCallback cb;
10696 + void *param;
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 {
10710 - Uint32 interval;
10711 - SDL_NewTimerCallback cb;
10712 - void *param;
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;
10720 +#else
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
10730 +#endif
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)
10737 +#else
10738 +int SDL_SetTimerThreadedI(int value, struct SDLBase *SDLBase)
10739 +#endif
10741 int retval;
10743 @@ -67,7 +88,11 @@
10744 return retval;
10747 +#if !defined(PROTO_SDL_H)
10748 int SDL_TimerInit(void)
10749 +#else
10750 +int SDL_TimerInitI(struct SDLBase *SDLBase)
10751 +#endif
10753 int retval;
10755 @@ -87,7 +112,11 @@
10756 return(retval);
10759 +#if !defined(PROTO_SDL_H)
10760 void SDL_TimerQuit(void)
10761 +#else
10762 +void SDL_TimerQuitI(struct SDLBase *SDLBase)
10763 +#endif
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)
10773 +#else
10774 +void SDL_ThreadedTimerCheckI(struct SDLBase *SDLBase)
10775 +#endif
10777 Uint32 now, ms;
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)
10785 +#else
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)
10788 +#endif
10790 SDL_TimerID t;
10791 t = (SDL_TimerID) SDL_malloc(sizeof(struct _SDL_TimerID));
10792 @@ -182,8 +220,18 @@
10793 return t;
10796 +#if !defined(PROTO_SDL_H)
10797 SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param)
10799 +#else
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
10807 +#endif
10808 SDL_TimerID t;
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);
10814 return t;
10815 +#if defined(PROTO_SDL_H)
10816 + AROS_LIBFUNC_EXIT
10817 +#endif
10820 +#if !defined(PROTO_SDL_H)
10821 SDL_bool SDL_RemoveTimer(SDL_TimerID id)
10823 +#else
10824 +AROS_LH1(SDL_bool, SDL_RemoveTimer,
10825 + AROS_LHA(SDL_TimerID, id, D0),
10826 + struct SDLBase *, SDLBase, 82, SDL)
10828 + AROS_LIBFUNC_INIT
10829 +#endif
10830 SDL_TimerID t, prev = NULL;
10831 SDL_bool removed;
10833 @@ -230,6 +289,9 @@
10834 #endif
10835 SDL_mutexV(SDL_timer_mutex);
10836 return removed;
10837 +#if defined(PROTO_SDL_H)
10838 + AROS_LIBFUNC_EXIT
10839 +#endif
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)
10850 +#else
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
10857 +#endif
10858 int retval;
10860 #ifdef DEBUG_TIMERS
10861 @@ -282,4 +353,7 @@
10864 return retval;
10865 +#if defined(PROTO_SDL_H)
10866 + AROS_LIBFUNC_EXIT
10867 +#endif
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
10872 @@ -27,6 +27,7 @@
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;
10880 @@ -44,3 +45,20 @@
10882 /* This function is called from the SDL event thread if it is available */
10883 extern void SDL_ThreadedTimerCheck(void);
10884 +#else
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
10900 +#endif
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
10905 @@ -0,0 +1,701 @@
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
10924 + Sam Lantinga
10925 + slouken@libsdl.org
10927 +#if defined (SDL_AROS_SHARED)
10928 +#define __NOLIBBASE__
10929 +#include <proto/SDL.h>
10930 +#endif
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
10942 +#endif
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)
10962 +#else
10963 +int CGX_AllocHWSurfaceI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
10964 +#endif
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"));
10972 + return 0;
10975 + if(!surface->hwdata)
10977 + if(!(surface->hwdata=SDL_malloc(sizeof(struct private_hwdata))))
10978 + return -1;
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"));
10995 + return 0;
10997 + else
10999 + SDL_free(surface->hwdata);
11000 + surface->hwdata=NULL;
11002 +#endif
11003 + return(-1);
11006 +#if !defined(PROTO_SDL_H)
11007 +void CGX_FreeHWSurface(_THIS, SDL_Surface *surface)
11008 +#else
11009 +void CGX_FreeHWSurfaceI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
11010 +#endif
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"));
11031 +#endif
11032 + return;
11035 +#if !defined(PROTO_SDL_H)
11036 +int CGX_LockHWSurface(_THIS, SDL_Surface *surface)
11037 +#else
11038 +int CGX_LockHWSurfaceI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
11039 +#endif
11041 +#ifndef NO_AMIGAHWSURF
11042 + if (surface->hwdata)
11044 + D(bug("Locking a bitmap..."));
11045 + if(!surface->hwdata->lock)
11046 + {
11047 + Uint32 pitch;
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;
11056 + else
11058 + D(bug("Couldn't lock surface!\n"));
11059 + return -1;
11062 + D(else bug("Already locked!!!\n"));
11064 +#endif
11065 + return(0);
11068 +#if !defined(PROTO_SDL_H)
11069 +void CGX_UnlockHWSurface(_THIS, SDL_Surface *surface)
11070 +#else
11071 +void CGX_UnlockHWSurfaceI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
11072 +#endif
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,
11086 + 0,
11087 + 0,
11088 + SDL_RastPort,
11089 + SDL_Window->BorderLeft,
11090 + SDL_Window->BorderTop,
11091 + surface->w,
11092 + surface->h,
11093 + 0xc0);
11096 +#endif
11099 +#if !defined(PROTO_SDL_H)
11100 +int CGX_FlipHWSurface(_THIS, SDL_Surface *surface)
11101 +#else
11102 +int CGX_FlipHWSurfaceI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
11103 +#endif
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));
11113 + if(!SafeChange)
11115 + Wait(this->hidden->disp_sigbit);
11116 + while(GetMsg(this->hidden->dispport)!=NULL);
11117 + SafeChange=TRUE;
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;
11124 + SafeDisp=FALSE;
11125 + current^=1;
11128 + if(!SafeDisp)
11130 + Wait(this->hidden->safe_sigbit);
11131 + while(GetMsg(this->hidden->safeport)!=NULL);
11132 + SafeDisp=TRUE;
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;
11142 + else
11143 + BltBitMapRastPort( this->hidden->BlitBitMap,
11144 + 0,
11145 + 0,
11146 + SDL_RastPort,
11147 + SDL_Window->BorderLeft,
11148 + SDL_Window->BorderTop,
11149 + this->screen->w,
11150 + this->screen->h,
11151 + 0xc0);
11153 + return(0);
11157 +#if !defined(PROTO_SDL_H)
11158 +int CGX_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
11159 +#else
11160 +int CGX_FillHWRectI(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color, struct SDLBase *SDLBase)
11161 +#endif
11163 + ULONG col;
11165 + D(bug("CGX_FillHWRect\n"));
11167 + if(dst->hwdata)
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);
11174 + else
11175 + col = color;
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);
11182 + return 0;
11185 +#ifndef NO_AMIGAHWSURF
11186 +#if !defined(PROTO_SDL_H)
11187 +int CGX_CheckHWBlit(_THIS,SDL_Surface *src,SDL_Surface *dst)
11188 +#else
11189 +int CGX_CheckHWBlitI(_THIS, SDL_Surface *src, SDL_Surface *dst, struct SDLBase *SDLBase)
11190 +#endif
11192 + int result = 0;
11194 + if (dst->hwdata)
11196 + if(src->hwdata)
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;
11207 + else
11209 + D(bug("CheckHW blit : HW to HW CC+ALPHA... OK!\n"));
11210 + src->flags |= SDL_HWACCEL;
11211 + src->map->hw_blit = CGX_HWtoHWBlitA;
11212 + result = 1;
11214 + break;
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;
11222 + else
11224 + D(bug("CheckHW blit : HW to HW CC... OK!\n"));
11225 + src->flags |= SDL_HWACCEL;
11226 + src->map->hw_blit = CGX_HWtoHWBlitCC;
11227 + result = 1;
11229 + break;
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;
11237 + else
11239 + D(bug("CheckHW blit : HW to HW ALPHA... OK!\n"));
11240 + src->flags |= SDL_HWACCEL;
11241 + src->map->hw_blit = CGX_HWtoHWBlitA;
11242 + result = 1;
11244 + break;
11246 + default:
11247 + D(bug("CheckHW blit : HW to HW OK!\n"));
11248 + src->flags |= SDL_HWACCEL;
11249 + src->map->hw_blit = CGX_HWtoHWBlit;
11250 + result = 1;
11251 + break;
11254 + else
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;
11265 + else
11267 + D(bug("CheckHW blit : SW to HW CC+ALPHA... OK!\n"));
11268 + src->flags |= SDL_HWACCEL;
11269 + src->map->hw_blit = CGX_SWtoHWBlitA;
11270 + result = 1;
11272 + break;
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;
11280 + else
11282 + D(bug("CheckHW blit : SW to HW CC... OK!\n"));
11283 + src->flags |= SDL_HWACCEL;
11284 + src->map->hw_blit = CGX_SWtoHWBlitCC;
11285 + result = 1;
11287 + break;
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;
11293 + result = 1;
11294 + break;
11296 + default:
11297 + D(bug("CheckHW blit : SW to HW... OK!\n"));
11298 + src->flags |= SDL_HWACCEL;
11299 + src->map->hw_blit = CGX_SWtoHWBlit;
11300 + result = 1;
11301 + break;
11305 + else
11307 + src->flags &= ~SDL_HWACCEL;
11308 + D(bug("HW blitting not available\n"));
11311 + return result;
11314 +#if !defined(PROTO_SDL_H)
11315 +int CGX_CreateAlphaPixMap(_THIS,SDL_Surface *surface)
11316 +#else
11317 +int CGX_CreateAlphaPixMapI(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
11318 +#endif
11320 + /*
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!
11323 + */
11324 + int result = -1;
11325 + int i;
11326 + ULONG *pix;
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,
11340 + 0,
11341 + 0,
11342 + surface->w * 4,
11343 + SDL_temprp,
11344 + 0,
11345 + 0,
11346 + surface->w,
11347 + surface->h,
11348 + RECTFMT_ARGB32);
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);
11360 + result = 0;
11365 + return result;
11369 +#if !defined(PROTO_SDL_H)
11370 +int CGX_SetHWColorKey(_THIS,SDL_Surface *surface, Uint32 key)
11371 +#else
11372 +int CGX_SetHWColorKeyI(_THIS, SDL_Surface *surface, Uint32 key, struct SDLBase *SDLBase)
11373 +#endif
11375 + /*
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!
11379 + */
11380 + int result = -1;
11381 + ULONG ARGBKey = 0x00000000;
11382 + ULONG *currentpix;
11383 + int pixnum=0;
11385 + D(bug("CGX_SetHWColorKey\n"));
11387 + result = CGX_CreateAlphaPixMap(this,surface);
11389 + if (result == 0)
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));
11406 + return result;
11409 +#if !defined(PROTO_SDL_H)
11410 +int CGX_ColorKeyToAlpha(_THIS,SDL_Surface *surface, Uint32 key)
11411 +#else
11412 +int CGX_ColorKeyToAlphaI(_THIS, SDL_Surface *surface, Uint32 key, struct SDLBase *SDLBase)
11413 +#endif
11415 + /* Includes the ColorKey in the Alpha Channel of a SW surface */
11416 + int result = -1;
11417 + ULONG ARGBKey = 0x00000000;
11418 + ULONG *currentpix;
11419 + int pixnum=0;
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));
11445 + result = 0;
11447 + return result;
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,
11456 + srcrect->x,
11457 + srcrect->y,
11458 + dst->hwdata->bmap,
11459 + dstrect->x,
11460 + dstrect->y,
11461 + srcrect->w,
11462 + srcrect->h,
11463 + (ABC|ABNC),
11464 + 0xff,
11465 + NULL);
11467 + return 0;
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,
11483 + srcrect->x,
11484 + srcrect->y,
11485 + src->w * 4,
11486 + SDL_temprp,
11487 + dstrect->x,
11488 + dstrect->y,
11489 + srcrect->w,
11490 + srcrect->h,
11491 + 0x01010101 * src->format->alpha );
11493 + return 0;
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,
11509 + srcrect->x,
11510 + srcrect->y,
11511 + src->w * 4,
11512 + SDL_temprp,
11513 + dstrect->x,
11514 + dstrect->y,
11515 + srcrect->w,
11516 + srcrect->h,
11517 + 0xFFFFFFFF);
11519 + return 0;
11522 +static int CGX_SWtoHWBlit( SDL_Surface *src, SDL_Rect *srcrect,
11523 + SDL_Surface *dst, SDL_Rect *dstrect)
11525 + ULONG format;
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,
11539 + srcrect->x,
11540 + srcrect->y,
11541 + src->pitch,
11542 + SDL_temprp,
11543 + dstrect->x,
11544 + dstrect->y,
11545 + srcrect->w,
11546 + srcrect->h,
11547 + format);
11549 + return 0;
11552 +static int CGX_SWtoHWBlitA( SDL_Surface *src, SDL_Rect *srcrect,
11553 + SDL_Surface *dst, SDL_Rect *dstrect)
11555 + /*
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
11559 + */
11560 + struct SDL_VideoDevice *this = dst->hwdata->videodata;
11562 + D(bug("Accelerated SW to HW blit with ALPHA\n"));
11564 + return 0;
11566 + if(!SDL_temprp) SDL_temprp = CreateRastPort();
11567 + SDL_temprp->BitMap=(struct BitMap *)dst->hwdata->bmap;
11569 + WritePixelArrayAlpha( src->pixels,
11570 + srcrect->x,
11571 + srcrect->y,
11572 + src->pitch,
11573 + SDL_temprp,
11574 + dstrect->x,
11575 + dstrect->y,
11576 + srcrect->w,
11577 + srcrect->h,
11578 + 0x01010101 * src->format->alpha );
11580 + return 0;
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,
11594 + srcrect->x,
11595 + srcrect->y,
11596 + src->pitch,
11597 + SDL_temprp,
11598 + dstrect->x,
11599 + dstrect->y,
11600 + srcrect->w,
11601 + srcrect->h,
11602 + 0xFFFFFFFF );
11603 + return 0;
11606 +#endif
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
11610 @@ -0,0 +1,64 @@
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
11629 + Sam Lantinga
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);
11649 +#endif
11650 +#else
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)
11667 +#endif
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)
11674 +#endif
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
11678 @@ -0,0 +1,491 @@
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
11697 + Sam Lantinga
11698 + slouken@libsdl.org
11700 +#if defined (SDL_AROS_SHARED)
11701 +#define __NOLIBBASE__
11702 +#include <proto/SDL.h>
11703 +#endif
11705 +#include "SDL_config.h"
11707 +/* Handle the event stream, converting Amiga events into SDL events */
11708 +#include "SDL.h"
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
11724 +#endif
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)
11734 +#else
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)
11737 +#endif
11739 + struct InputEvent event;
11740 + long actual;
11741 + char buffer[5];
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;
11757 + else
11759 + DeleteIORequest(SDL_ConReq);
11760 + SDL_ConReq=NULL;
11763 + else
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);
11815 + return(keysym);
11818 +static int CGX_GetButton(int code)
11820 + switch(code)
11822 + case IECODE_MBUTTON:
11823 + return SDL_BUTTON_MIDDLE;
11824 + case IECODE_RBUTTON:
11825 + return SDL_BUTTON_RIGHT;
11826 + default:
11827 + return SDL_BUTTON_LEFT;
11831 +#if !defined(PROTO_SDL_H)
11832 +static int CGX_FocusActivate(_THIS, BOOL activate)
11833 +#else
11834 +#define CGX_FocusActivate(this, activate) CGX_FocusActivateI(this, activate, SDLBase)
11835 +static int CGX_FocusActivateI(_THIS, BOOL activate, struct SDLBase *SDLBase)
11836 +#endif
11838 + int posted = 0;
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;
11845 + return posted;
11848 +static int CGX_IsMouseInsideDrawArea(int mouseX, int mouseY, struct Window * wnd)
11850 + if ((mouseX < (wnd->BorderLeft)) ||
11851 + (mouseX > (wnd->Width - wnd->BorderRight)))
11852 + return 0;
11853 + if ((mouseY < (wnd->BorderTop)) ||
11854 + (mouseY > (wnd->Height - wnd->BorderBottom)))
11855 + return 0;
11857 + return 1;
11860 +/*
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
11869 + */
11870 +#if !defined(PROTO_SDL_H)
11871 +static int CGX_DispatchEvent(_THIS, struct IntuiMessage *msg)
11872 +#else
11873 +#define CGX_DispatchEvent(this, msg) CGX_DispatchEventI(this, msg, SDLBase)
11874 +static int CGX_DispatchEventI(_THIS, struct IntuiMessage *msg, struct SDLBase *SDLBase)
11875 +#endif
11877 + int class=msg->Class,code=msg->Code;
11878 + int posted;
11880 + posted = 0;
11881 + switch (class) {
11882 + /* Gaining app & mouse focus */
11883 + case IDCMP_ACTIVEWINDOW:
11884 + this->hidden->WindowActive = 1;
11885 + break;
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;
11894 + break;
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. */
11941 + else
11943 + int rel_x = msg->MouseX - this->hidden->LastMouseX;
11944 + int rel_y = msg->MouseY - this->hidden->LastMouseY;
11946 + /* Workaround:
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);
11957 + else
11959 + BOOL dowarp = FALSE;
11961 + if (new_x - dx < 0)
11963 + dowarp = TRUE;
11964 + new_x = dx;
11966 + else if (new_x - dx > this->screen->w - 1)
11968 + dowarp = TRUE;
11969 + new_x = dx + this->screen->w - 1;
11972 + if (new_y - dy < 0)
11974 + dowarp = TRUE;
11975 + new_y = 0;
11977 + else if (new_y - dy > this->screen->h - 1)
11979 + dowarp = TRUE;
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);
11987 + else
11988 + posted |= SDL_PrivateMouseMotion(0, 0, new_x - dx, new_y - dy);
11990 + this->hidden->LastMouseX = msg->MouseX;
11991 + this->hidden->LastMouseY = msg->MouseY;
11993 + break;
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);
12007 + else
12009 + posted |= SDL_PrivateMouseButton(SDL_PRESSED,
12010 + CGX_GetButton(code), 0, 0);
12013 + /* Mouse button release? */
12014 + else
12016 + code&=~IECODE_UP_PREFIX;
12017 + posted = SDL_PrivateMouseButton(SDL_RELEASED,
12018 + CGX_GetButton(code), 0, 0);
12020 + break;
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);
12030 + break;
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);
12039 + break;
12042 + if( !(code&IECODE_UP_PREFIX) )
12044 + /* Key press */
12045 + SDL_keysym keysym;
12046 + posted = SDL_PrivateKeyboard(SDL_PRESSED,
12047 + CGX_TranslateKey(code, msg->Qualifier, &keysym));
12049 + else
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));
12057 + break;
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);
12064 + break;
12066 + /* Have we been requested to quit? */
12067 + case IDCMP_CLOSEWINDOW:
12068 + posted = SDL_PrivateQuit();
12069 + break;
12071 + /* Do we need to refresh ourselves? */
12073 + default: {
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);
12083 + break;
12085 + ReplyMsg((struct Message *)msg);
12087 + return(posted);
12090 +#if !defined(PROTO_SDL_H)
12091 +void CGX_PumpEvents(_THIS)
12092 +#else
12093 +void CGX_PumpEvents(_THIS, struct SDLBase *SDLBase)
12094 +#endif
12096 + struct IntuiMessage *m;
12098 + if (SDL_Window)
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)
12107 +#else
12108 +void CGX_InitOSKeymap(_THIS, struct SDLBase *SDLBase)
12109 +#endif
12111 + int i;
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
12173 @@ -0,0 +1,35 @@
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
12192 + Sam Lantinga
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);
12203 +#else
12204 +extern void CGX_InitOSKeymap(_THIS, struct SDLBase *SDLBase);
12205 +extern void CGX_PumpEvents(_THIS, struct SDLBase *SDLBase);
12206 +#endif
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
12212 @@ -0,0 +1,77 @@
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
12231 + Sam Lantinga
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>
12241 +#endif
12243 +#define _THIS SDL_VideoDevice *_this
12245 +struct SDL_PrivateGLData {
12246 +#if SDL_VIDEO_OPENGL
12247 + GLAContext glctx;
12248 +#endif
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);
12263 +#endif
12264 +#else
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)
12282 +#endif
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)
12287 +#endif
12289 +#undef _THIS
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
12293 @@ -0,0 +1,119 @@
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
12312 + Sam Lantinga
12313 + slouken@libsdl.org
12315 +#if defined (SDL_AROS_SHARED)
12316 +#define __NOLIBBASE__
12317 +#include <proto/SDL.h>
12318 +#endif
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
12333 +#else
12334 +extern struct Library *GLBase;
12335 +#define GLBase_ptr &GLBase
12336 +#endif
12338 +/* Create OpenGL context */
12339 +#if !defined(PROTO_SDL_H)
12340 +int CGX_GL_CreateContext(_THIS)
12341 +#else
12342 +int CGX_GL_CreateContextI(_THIS, struct SDLBase *SDLBase)
12343 +#endif
12345 +#if SDL_VIDEO_OPENGL
12346 + LONG i = 0;
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");
12354 + return(-1);
12357 + if( this->gl_config.stereo ) {
12358 + SDL_SetError("gl.library does not support stereo buffer");
12359 + return(-1);
12362 + if ( ! this->gl_config.driver_loaded ) {
12363 + if ( CGX_GL_LoadLibrary(this, NULL) < 0 ) {
12364 + return(-1);
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;
12396 + /* done */
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");
12403 + return(-1);
12406 + return(0);
12408 +#else
12409 + SDL_SetError("OpenGL support not configured");
12410 + return(-1);
12411 +#endif
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
12416 @@ -0,0 +1,57 @@
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
12435 + Sam Lantinga
12436 + slouken@libsdl.org
12438 +#if defined (SDL_AROS_SHARED)
12439 +#define __NOLIBBASE__
12440 +#include <proto/SDL.h>
12441 +#endif
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
12455 +#else
12456 +extern struct Library *GLBase;
12457 +#endif
12459 +/* Destroy OpenGL context */
12460 +#if !defined(PROTO_SDL_H)
12461 +void CGX_GL_DestroyContext(_THIS)
12462 +#else
12463 +void CGX_GL_DestroyContextI(_THIS, struct SDLBase *SDLBase)
12464 +#endif
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;
12472 +#endif
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
12477 @@ -0,0 +1,103 @@
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
12496 + Sam Lantinga
12497 + slouken@libsdl.org
12499 +#if defined (SDL_AROS_SHARED)
12500 +#define __NOLIBBASE__
12501 +#include <proto/SDL.h>
12502 +#endif
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
12516 +#else
12517 +extern struct Library *GLBase;
12518 +#endif
12520 +#if SDL_VIDEO_OPENGL
12521 +#if !defined(PROTO_SDL_H)
12522 +int CGX_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
12523 +#else
12524 +int CGX_GL_GetAttributeI(_THIS, SDL_GLattr attrib, int* value, struct SDLBase *SDLBase)
12525 +#endif
12527 + GLenum mesa_attrib;
12529 + if (!GLBase)
12530 + return -1;
12532 + switch(attrib) {
12533 + case SDL_GL_RED_SIZE:
12534 + mesa_attrib = GL_RED_BITS;
12535 + break;
12536 + case SDL_GL_GREEN_SIZE:
12537 + mesa_attrib = GL_GREEN_BITS;
12538 + break;
12539 + case SDL_GL_BLUE_SIZE:
12540 + mesa_attrib = GL_BLUE_BITS;
12541 + break;
12542 + case SDL_GL_ALPHA_SIZE:
12543 + mesa_attrib = GL_ALPHA_BITS;
12544 + break;
12545 + case SDL_GL_DOUBLEBUFFER:
12546 + mesa_attrib = GL_DOUBLEBUFFER;
12547 + break;
12548 + case SDL_GL_DEPTH_SIZE:
12549 + mesa_attrib = GL_DEPTH_BITS;
12550 + break;
12551 + case SDL_GL_STENCIL_SIZE:
12552 + mesa_attrib = GL_STENCIL_BITS;
12553 + break;
12554 + case SDL_GL_ACCUM_RED_SIZE:
12555 + mesa_attrib = GL_ACCUM_RED_BITS;
12556 + break;
12557 + case SDL_GL_ACCUM_GREEN_SIZE:
12558 + mesa_attrib = GL_ACCUM_GREEN_BITS;
12559 + break;
12560 + case SDL_GL_ACCUM_BLUE_SIZE:
12561 + mesa_attrib = GL_ACCUM_BLUE_BITS;
12562 + break;
12563 + case SDL_GL_ACCUM_ALPHA_SIZE:
12564 + mesa_attrib = GL_ACCUM_ALPHA_BITS;
12565 + break;
12566 + case SDL_GL_STEREO:
12567 + mesa_attrib = GL_STEREO;
12568 + break;
12569 + case SDL_GL_MULTISAMPLEBUFFERS:
12570 + return 0;
12571 + case SDL_GL_MULTISAMPLESAMPLES:
12572 + return 0;
12573 + default:
12574 + return -1;
12577 + glAGetConfig(this->gl_data->glctx, mesa_attrib, value);
12578 + return 0;
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
12584 @@ -0,0 +1,59 @@
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
12603 + Sam Lantinga
12604 + slouken@libsdl.org
12606 +#if defined (SDL_AROS_SHARED)
12607 +#define __NOLIBBASE__
12608 +#include <proto/SDL.h>
12609 +#endif
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
12623 +#else
12624 +extern struct Library *GLBase;
12625 +#endif
12627 +#if SDL_VIDEO_OPENGL
12628 +#if !defined(PROTO_SDL_H)
12629 +void *CGX_GL_GetProcAddress(_THIS, const char *proc)
12630 +#else
12631 +void *CGX_GL_GetProcAddressI(_THIS, const char *proc, struct SDLBase *SDLBase)
12632 +#endif
12634 + void *func = NULL;
12636 + if (GLBase)
12638 + func = glAGetProcAddress(proc);
12641 + return func;
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
12647 @@ -0,0 +1,70 @@
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
12666 + Sam Lantinga
12667 + slouken@libsdl.org
12669 +#if defined (SDL_AROS_SHARED)
12670 +#define __NOLIBBASE__
12671 +#include <proto/SDL.h>
12672 +#endif
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;
12688 +#else
12689 +#define GLBase SDLBase->GLBase
12690 +#endif
12692 +#if !defined(PROTO_SDL_H)
12693 +int CGX_GL_LoadLibrary(_THIS, const char *path)
12694 +#else
12695 +int CGX_GL_LoadLibraryI(_THIS, const char *path, struct SDLBase *SDLBase)
12696 +#endif
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;
12706 + else
12708 + this->gl_config.driver_loaded = 0;
12709 + SDL_SetError("Could not open gl.library");
12710 + return(-1);
12712 + this->gl_data->glctx = NULL;
12715 + return 0;
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
12721 @@ -0,0 +1,57 @@
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
12740 + Sam Lantinga
12741 + slouken@libsdl.org
12743 +#if defined (SDL_AROS_SHARED)
12744 +#define __NOLIBBASE__
12745 +#include <proto/SDL.h>
12746 +#endif
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
12760 +#else
12761 +extern struct Library *GLBase;
12762 +#endif
12764 +#if SDL_VIDEO_OPENGL
12765 +/* Make the current context active */
12766 +#if !defined(PROTO_SDL_H)
12767 +int CGX_GL_MakeCurrent(_THIS)
12768 +#else
12769 +int CGX_GL_MakeCurrentI(_THIS, struct SDLBase *SDLBase)
12770 +#endif
12772 + if( !GLBase || this->gl_data->glctx == NULL)
12773 + return -1;
12775 + glAMakeCurrent(this->gl_data->glctx);
12776 + return 0;
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
12782 @@ -0,0 +1,58 @@
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
12801 + Sam Lantinga
12802 + slouken@libsdl.org
12804 +#if defined (SDL_AROS_SHARED)
12805 +#define __NOLIBBASE__
12806 +#include <proto/SDL.h>
12807 +#endif
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
12821 +#else
12822 +extern struct Library *GLBase;
12823 +#endif
12825 +/* Quit OpenGL */
12826 +#if !defined(PROTO_SDL_H)
12827 +void CGX_GL_Quit(_THIS)
12828 +#else
12829 +void CGX_GL_QuitI(_THIS, struct SDLBase *SDLBase)
12830 +#endif
12832 +#if SDL_VIDEO_OPENGL
12833 + CGX_GL_DestroyContext(this);
12834 + if ( GLBase != NULL ) {
12835 + CloseLibrary(GLBase);
12836 + this->gl_config.driver_loaded = 0;
12837 + GLBase = NULL;
12839 +#endif
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
12844 @@ -0,0 +1,55 @@
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
12863 + Sam Lantinga
12864 + slouken@libsdl.org
12866 +#if defined (SDL_AROS_SHARED)
12867 +#define __NOLIBBASE__
12868 +#include <proto/SDL.h>
12869 +#endif
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
12883 +#else
12884 +extern struct Library *GLBase;
12885 +#endif
12887 +#if SDL_VIDEO_OPENGL
12888 +#if !defined(PROTO_SDL_H)
12889 +void CGX_GL_SwapBuffers(_THIS)
12890 +#else
12891 +void CGX_GL_SwapBuffersI(_THIS, struct SDLBase *SDLBase)
12892 +#endif
12894 + if (!GLBase)
12895 + return;
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
12903 @@ -0,0 +1,67 @@
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
12922 + Sam Lantinga
12923 + slouken@libsdl.org
12925 +#if defined (SDL_AROS_SHARED)
12926 +#define __NOLIBBASE__
12927 +#include <proto/SDL.h>
12928 +#endif
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
12942 +#else
12943 +extern struct Library *GLBase;
12944 +#endif
12946 +/* Attach context to another window */
12947 +#if !defined(PROTO_SDL_H)
12948 +int CGX_GL_UpdateContext(_THIS)
12949 +#else
12950 +int CGX_GL_UpdateContextI(_THIS, struct SDLBase *SDLBase)
12951 +#endif
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);
12965 + return 0;
12966 +#else
12967 + SDL_SetError("OpenGL support not configured");
12968 + return -1;
12969 +#endif
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
12974 @@ -0,0 +1,306 @@
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
12993 + Sam Lantinga
12994 + slouken@libsdl.org
12996 +#if defined (SDL_AROS_SHARED)
12997 +#define __NOLIBBASE__
12998 +#include <proto/SDL.h>
12999 +#endif
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);
13012 +#else
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);
13017 +#endif
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;
13048 + return(rectfmt);
13051 +#if !defined(PROTO_SDL_H)
13052 +int CGX_SetupImage(_THIS, SDL_Surface *screen)
13053 +#else
13054 +int CGX_SetupImageI(_THIS, SDL_Surface *screen, struct SDLBase *SDLBase)
13055 +#endif
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
13070 + ULONG pitch;
13071 + APTR pixels;
13072 + APTR lock;
13074 + if (this->hidden->dbuffer)
13075 + lock = LockBitMapTags(
13076 + SDL_RastPort->BitMap,
13077 + LBMI_BASEADDRESS, (IPTR)&pixels,
13078 + LBMI_BYTESPERROW, (IPTR)&pitch,
13079 + TAG_DONE);
13080 + else
13081 + lock = LockBitMapTags(
13082 + this->hidden->BlitBitMap,
13083 + LBMI_BASEADDRESS, (IPTR)&pixels,
13084 + LBMI_BYTESPERROW, (IPTR)&pitch,
13085 + TAG_DONE);
13087 + if (lock)
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"));
13110 + return 0;
13112 + D(bug("Creating system accel struct FAILED.\n"));
13114 +#endif
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();
13129 + return -1;
13132 + SDL_Image = screen->pixels;
13134 + if ( SDL_Image == NULL )
13136 + SDL_SetError("Couldn't create XImage");
13137 + return -1;
13140 + this->UpdateRects = CGX_SWScreenUpdate;
13142 + return 0;
13145 +#if !defined(PROTO_SDL_H)
13146 +void CGX_DestroyImage(_THIS, SDL_Surface *screen)
13147 +#else
13148 +void CGX_DestroyImageI(_THIS, SDL_Surface *screen, struct SDLBase *SDLBase)
13149 +#endif
13151 + if ( SDL_Image )
13153 + SDL_free(SDL_Image);
13154 + SDL_Image = NULL;
13156 + if ( screen )
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)
13170 +#else
13171 +int CGX_ResizeImageI(_THIS, SDL_Surface *screen, Uint32 flags, struct SDLBase *SDLBase)
13172 +#endif
13174 + int retval;
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 */
13182 + else
13183 + retval = CGX_SetupImage(this, screen);
13185 + return(retval);
13188 +#if !defined(PROTO_SDL_H)
13189 +static void CGX_HWScreenUpdate(_THIS, int numrects, SDL_Rect *rects)
13190 +#else
13191 +static void CGX_HWScreenUpdate(_THIS, int numrects, SDL_Rect *rects, struct SDLBase *SDLBase)
13192 +#endif
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)
13200 +#else
13201 +static void CGX_SWScreenUpdate(_THIS, int numrects, SDL_Rect *rects, struct SDLBase *SDLBase)
13202 +#endif
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? */
13225 + continue;
13227 + WriteLUTPixelArray( this->screen->pixels,
13228 + rects[i].x,
13229 + rects[i].y,
13230 + this->screen->pitch,
13231 + SDL_RastPort,
13232 + SDL_Pens,
13233 + SDL_Window->BorderLeft+rects[i].x + dx,
13234 + SDL_Window->BorderTop+rects[i].y + dy,
13235 + rects[i].w,
13236 + rects[i].h,
13237 + CTABFMT_XRGB8);
13240 + else
13242 + for ( i=0; i<numrects; ++i ) {
13243 + if ( ! rects[i].w ) { /* Clipped? */
13244 + continue;
13246 + WritePixelArray( this->screen->pixels,
13247 + rects[i].x,
13248 + rects[i].y,
13249 + this->screen->pitch,
13250 + SDL_RastPort,
13251 + SDL_Window->BorderLeft+rects[i].x + dx,
13252 + SDL_Window->BorderTop+rects[i].y + dy,
13253 + rects[i].w,
13254 + rects[i].h,
13255 + format);
13260 +#if !defined(PROTO_SDL_H)
13261 +void CGX_RefreshDisplay(_THIS)
13262 +#else
13263 +void CGX_RefreshDisplayI(_THIS, struct SDLBase *SDLBase)
13264 +#endif
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);
13277 +#else
13278 + this->UpdateRects(this, 1, &screenrect, SDLBase);
13279 +#endif
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
13284 @@ -0,0 +1,45 @@
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
13303 + Sam Lantinga
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);
13317 +#else
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)
13329 +#endif
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
13333 @@ -0,0 +1,236 @@
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
13352 + Sam Lantinga
13353 + slouken@libsdl.org
13355 +#if defined (SDL_AROS_SHARED)
13356 +#define __NOLIBBASE__
13357 +#include <proto/SDL.h>
13358 +#endif
13360 +#include "SDL_config.h"
13362 +#define DEBUG 1
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"
13375 +#endif
13377 +static void add_visual(_THIS, int depth, int class)
13379 + Uint32 tID;
13381 + tID=BestCModeIDTags(CYBRBIDTG_Depth,depth,
13382 + CYBRBIDTG_NominalWidth,640,
13383 + CYBRBIDTG_NominalHeight,480,
13384 + TAG_DONE);
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)
13402 +#else
13403 +int CGX_GetVideoModesI(_THIS, struct SDLBase *SDLBase)
13404 +#endif
13406 + int i;
13407 + ULONG nextid;
13408 + int nmodes=0;
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))
13429 + int ok=0;
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) )
13435 + ok=1;
13438 + if(!ok)
13440 + nmodes++;
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 )
13450 + break;
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");
13477 + return -1;
13480 + if ( SDL_modelist == NULL )
13482 + SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *));
13483 + i = 0;
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;
13493 + ++i;
13495 + SDL_modelist[i] = NULL;
13499 + D(
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);
13514 + );
13516 + return 0;
13519 +#if !defined(PROTO_SDL_H)
13520 +static int CGX_SupportedVisual(_THIS, SDL_PixelFormat *format)
13521 +#else
13522 +#define CGX_SupportedVisual(this, format) CGX_SupportedVisualI(this, format, SDLBase)
13523 +static int CGX_SupportedVisualI(_THIS, SDL_PixelFormat *format, struct SDLBase *SDLBase)
13524 +#endif
13526 + int i;
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
13530 + return 1;
13532 + return 0;
13535 +#if !defined(PROTO_SDL_H)
13536 +SDL_Rect **CGX_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
13537 +#else
13538 +SDL_Rect **CGX_ListModesI(_THIS, SDL_PixelFormat *format, Uint32 flags, struct SDLBase *SDLBase)
13539 +#endif
13541 + if ( CGX_SupportedVisual(this, format) )
13543 + if ( flags & SDL_FULLSCREEN )
13544 + return(SDL_modelist);
13545 + else
13546 + return((SDL_Rect **)-1);
13547 + }
13548 + else
13549 + return((SDL_Rect **)0);
13552 +#if !defined(PROTO_SDL_H)
13553 +void CGX_FreeVideoModes(_THIS)
13554 +#else
13555 +void CGX_FreeVideoModesI(_THIS, struct SDLBase *SDLBase)
13556 +#endif
13558 + int i;
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
13573 @@ -0,0 +1,47 @@
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
13592 + Sam Lantinga
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);
13610 +#else
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)
13620 +#endif
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
13624 @@ -0,0 +1,266 @@
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
13643 + Sam Lantinga
13644 + slouken@libsdl.org
13646 +#if defined (SDL_AROS_SHARED)
13647 +#define __NOLIBBASE__
13648 +#include <proto/SDL.h>
13649 +#endif
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"
13662 +struct WMcursor
13664 + struct BitMap *CursorBM;
13665 + Object *PointerObj;
13668 +#if !defined(PROTO_SDL_H)
13669 +void CGX_FreeWMCursor(_THIS, WMcursor *cursor)
13670 +#else
13671 +void CGX_FreeWMCursor(_THIS, WMcursor *cursor, struct SDLBase *SDLBase)
13672 +#endif
13674 + D(bug("[SDL] CGX_FreeWMCursor()\n"));
13676 + if (cursor)
13678 + if (SDL_Window)
13679 + ClearPointer(SDL_Window);
13681 + if (cursor->CursorBM)
13682 + FreeBitMap(cursor->CursorBM);
13684 + if(cursor->PointerObj)
13685 + DisposeObject(cursor->PointerObj);
13687 + free(cursor);
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)
13693 +#else
13694 +WMcursor *CGX_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y, struct SDLBase *SDLBase)
13695 +#endif
13697 + struct WMcursor *cursor = NULL;
13698 + struct RastPort *CursorRP = NULL;
13699 + ULONG *pixarray = NULL;
13700 + ULONG pixel_cnt;
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)
13723 + data++;
13724 + mask++;
13725 + currentbit = 7;
13727 + else
13729 + currentbit--;
13732 + switch(currentdata * 2 + currentmask)
13734 + case 0: //(0,0) => Transparent
13735 + pixarray[pixel_cnt] = AROS_BE2LONG(0x00000000);
13736 + break;
13737 + case 1: //(0,1) => White
13738 + pixarray[pixel_cnt] = AROS_BE2LONG(0xFFFFFFFF);
13739 + break;
13740 + case 2: //(1,0) => Inverted color if possible, black if not (Semi transparent here AROS)
13741 + pixarray[pixel_cnt] = AROS_BE2LONG(0x0000007F);
13742 + break;
13743 + case 3: //(1,1) => Black
13744 + pixarray[pixel_cnt] = AROS_BE2LONG(0x000000FF);
13745 + break;
13749 + // Copy pixel array into bitmap
13750 + CursorRP->BitMap = cursor->CursorBM;
13751 + WritePixelArray( pixarray,
13752 + 0, 0, w * 4,
13753 + CursorRP,
13754 + 0, 0, w, h,
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),
13763 + TAG_DONE);
13765 + if (!cursor->PointerObj)
13767 + FreeBitMap(cursor->CursorBM);
13768 + free(cursor);
13769 + cursor = NULL;
13772 + else
13774 + free(cursor);
13775 + cursor = NULL;
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));
13784 + return cursor;
13787 +#if !defined(PROTO_SDL_H)
13788 +int CGX_ShowWMCursor(_THIS, WMcursor *cursor)
13789 +#else
13790 +int CGX_ShowWMCursorI(_THIS, WMcursor *cursor, struct SDLBase *SDLBase)
13791 +#endif
13793 + /* Don't do anything if the display is gone */
13794 + if ( SDL_Display == NULL)
13796 + this->hidden->CursorVisible = 0;
13797 + return(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;
13813 + else
13815 + // Show cursor
13816 + SetWindowPointer( SDL_Window,
13817 + WA_Pointer, (APTR)cursor->PointerObj,
13818 + TAG_DONE );
13819 + this->hidden->CursorVisible = 1;
13821 + SDL_Unlock_EventThread();
13823 + return(1);
13826 +#if !defined(PROTO_SDL_H)
13827 +void CGX_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
13828 +#else
13829 +void CGX_WarpWMCursorI(_THIS, Uint16 x, Uint16 y, struct SDLBase *SDLBase)
13830 +#endif
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));
13842 + if (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);
13869 + free(ie);
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)
13884 +#else
13885 +void CGX_CheckMouseMode(_THIS, struct SDLBase *SDLBase)
13886 +#endif
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
13894 @@ -0,0 +1,44 @@
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
13913 + Sam Lantinga
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);
13928 +#else
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)
13938 +#endif
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
13942 @@ -0,0 +1,1516 @@
13944 + SDL - Simple DirectMedia Layer
13945 + Copyright (C) 1997-2006 Sam Lantinga
13946 + Copyright (C) 2011 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
13962 + Sam Lantinga
13963 + slouken@libsdl.org
13965 +#define DEBUG 1
13966 +#include <aros/debug.h>
13968 +#if defined (SDL_AROS_SHARED)
13969 +#define __NOLIBBASE__
13970 +#include <proto/SDL.h>
13971 +#endif
13973 +#include "SDL_config.h"
13976 + * CGX based SDL video driver implementation by Gabriele Greco
13977 + * gabriele.greco@aruba.it
13978 + */
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
14001 +#endif
14003 +/* This is a special flag that tells video mode change code to not to drop existing
14004 + GL context. */
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);
14026 +#else
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
14043 +#endif
14044 +#define CGX_ShowWMCursor CGX_ShowWMCursorI
14045 +#ifdef CGX_WarpWMCursor
14046 +#undef CGX_WarpWMCursor
14047 +#endif
14048 +#define CGX_WarpWMCursor CGX_WarpWMCursorI
14050 +#ifdef CGX_SetIcon
14051 +#undef CGX_SetIcon
14052 +#endif
14053 +#define CGX_SetIcon CGX_SetIconI
14054 +#ifdef CGX_SetCaption
14055 +#undef CGX_SetCaption
14056 +#endif
14057 +#define CGX_SetCaption CGX_SetCaptionI
14058 +#ifdef CGX_IconifyWindow
14059 +#undef CGX_IconifyWindow
14060 +#endif
14061 +#define CGX_IconifyWindow CGX_IconifyWindowI
14062 +#ifdef CGX_GrabWMInput
14063 +#undef CGX_GrabWMInput
14064 +#endif
14065 +#define CGX_GrabWMInput CGX_GrabWMInputI
14066 +#ifdef CGX_GetWMInfo
14067 +#undef CGX_GetWMInfo
14068 +#endif
14069 +#define CGX_GetWMInfo CGX_GetWMInfoI
14071 +#ifdef CGX_ListModes
14072 +#undef CGX_ListModes
14073 +#endif
14074 +#define CGX_ListModes CGX_ListModesI
14075 +#ifdef CGX_AllocHWSurface
14076 +#undef CGX_AllocHWSurface
14077 +#endif
14078 +#define CGX_AllocHWSurface CGX_AllocHWSurfaceI
14079 +#ifdef CGX_CheckHWBlit
14080 +#undef CGX_CheckHWBlit
14081 +#endif
14082 +#define CGX_CheckHWBlit CGX_CheckHWBlitI
14083 +#ifdef CGX_SetHWColorKey
14084 +#undef CGX_SetHWColorKey
14085 +#endif
14086 +#define CGX_SetHWColorKey CGX_SetHWColorKeyI
14087 +#ifdef CGX_FillHWRect
14088 +#undef CGX_FillHWRect
14089 +#endif
14090 +#define CGX_FillHWRect CGX_FillHWRectI
14091 +#ifdef CGX_LockHWSurface
14092 +#undef CGX_LockHWSurface
14093 +#endif
14094 +#define CGX_LockHWSurface CGX_LockHWSurfaceI
14095 +#ifdef CGX_UnlockHWSurface
14096 +#undef CGX_UnlockHWSurface
14097 +#endif
14098 +#define CGX_UnlockHWSurface CGX_UnlockHWSurfaceI
14099 +#ifdef CGX_FlipHWSurface
14100 +#undef CGX_FlipHWSurface
14101 +#endif
14102 +#define CGX_FlipHWSurface CGX_FlipHWSurfaceI
14103 +#ifdef CGX_FreeHWSurface
14104 +#undef CGX_FreeHWSurface
14105 +#endif
14106 +#define CGX_FreeHWSurface CGX_FreeHWSurfaceI
14107 +#ifdef CGX_GL_LoadLibrary
14108 +#undef CGX_GL_LoadLibrary
14109 +#endif
14110 +#define CGX_GL_LoadLibrary CGX_GL_LoadLibraryI
14111 +#ifdef CGX_GL_GetProcAddress
14112 +#undef CGX_GL_GetProcAddress
14113 +#endif
14114 +#define CGX_GL_GetProcAddress CGX_GL_GetProcAddressI
14115 +#ifdef CGX_GL_GetAttribute
14116 +#undef CGX_GL_GetAttribute
14117 +#endif
14118 +#define CGX_GL_GetAttribute CGX_GL_GetAttributeI
14119 +#ifdef CGX_GL_MakeCurrent
14120 +#undef CGX_GL_MakeCurrent
14121 +#endif
14122 +#define CGX_GL_MakeCurrent CGX_GL_MakeCurrentI
14123 +#ifdef CGX_GL_SwapBuffers
14124 +#undef CGX_GL_SwapBuffers
14125 +#endif
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)
14141 +#endif
14143 +/* Bootstrap */
14144 +VideoBootStrap CGX_bootstrap = {
14145 + "CGX", "AROS CyberGraphics",
14146 + CGX_Available, CGX_CreateDevice
14150 +#if !defined(PROTO_SDL_H)
14151 +static SDL_VideoDevice *CGX_CreateDevice(int devindex)
14152 +#else
14154 +#ifdef CGX_CreateDevice
14155 +#undef CGX_CreateDevice
14156 +#endif
14157 +#ifdef CGX_Available
14158 +#undef CGX_Available
14159 +#endif
14160 +#define CGX_CreateDevice(devindex) CGX_CreateDeviceI(devindex, SDLBase)
14161 +#define CGX_Available() CGX_AvailableI(SDLBase)
14163 +static SDL_VideoDevice *CGX_CreateDeviceI(int devindex, struct SDLBase *SDLBase)
14164 +#endif
14166 + SDL_VideoDevice *device;
14168 + /* Initialize all variables that we clean on shutdown */
14169 + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
14171 + if ( device )
14173 + SDL_memset(device, 0, (sizeof *device));
14174 + device->hidden = (struct SDL_PrivateVideoData *)SDL_malloc((sizeof *device->hidden));
14175 + device->gl_data = (struct SDL_PrivateGLData *)SDL_malloc((sizeof *device->gl_data));
14178 + if ( (device == NULL) || (device->hidden == NULL) || (device->gl_data == NULL) )
14180 + D(bug("Unable to create video device!\n"));
14181 + SDL_OutOfMemory();
14182 + CGX_DeleteDevice(device);
14183 + return(0);
14186 + SDL_memset(device->hidden, 0, sizeof(*device->hidden));
14187 + SDL_memset(device->gl_data, 0, sizeof(*device->gl_data));
14189 + /* Set the driver flags */
14190 + device->handles_any_size = 1;
14192 +#if defined(PROTO_SDL_H)
14193 +#ifdef CGX_DeleteDevice
14194 +#undef CGX_DeleteDevice
14195 +#endif
14196 +#define CGX_DeleteDevice CGX_DeleteDeviceI
14197 +#endif
14199 + /* Set the function pointers */
14200 + /* SDL_cgxvideo.c */
14201 + device->VideoInit = CGX_VideoInit;
14202 + device->ListModes = CGX_ListModes;
14203 + device->SetVideoMode = CGX_SetVideoMode;
14204 + device->ToggleFullScreen = CGX_ToggleFullScreen;
14205 + device->UpdateMouse = CGX_UpdateMouse;
14206 + device->SetColors = CGX_SetColors;
14207 + device->UpdateRects = NULL;
14208 + device->VideoQuit = CGX_VideoQuit;
14209 + device->free = CGX_DeleteDevice;
14210 + device->SetGamma = CGX_SetGamma;
14211 + device->GetGamma = CGX_GetGamma;
14212 + device->SetGammaRamp = CGX_SetGammaRamp;
14213 + device->GetGammaRamp = CGX_GetGammaRamp;
14214 + /* SDL_cgxaccel.c */
14215 + device->AllocHWSurface = CGX_AllocHWSurface;
14216 +#ifndef NO_AMIGAHWSURF
14217 + device->CheckHWBlit = CGX_CheckHWBlit;
14218 + device->SetHWColorKey = CGX_SetHWColorKey;
14219 +#else
14220 + device->CheckHWBlit = NULL;
14221 + device->SetHWColorKey = NULL;
14222 +#endif
14223 + device->FillHWRect = CGX_FillHWRect;
14224 + device->SetHWAlpha = NULL;
14225 + device->LockHWSurface = CGX_LockHWSurface;
14226 + device->UnlockHWSurface = CGX_UnlockHWSurface;
14227 + device->FlipHWSurface = CGX_FlipHWSurface;
14228 + device->FreeHWSurface = CGX_FreeHWSurface;
14229 + /* SDL_cgxwm.c */
14230 + device->SetIcon = CGX_SetIcon;
14231 + device->SetCaption = CGX_SetCaption;
14232 + device->IconifyWindow = CGX_IconifyWindow;
14233 + device->GrabInput = CGX_GrabWMInput;
14234 + device->GetWMInfo = CGX_GetWMInfo;
14235 + device->FreeWMCursor = CGX_FreeWMCursor;
14236 + device->CreateWMCursor = CGX_CreateWMCursor;
14237 + device->ShowWMCursor = CGX_ShowWMCursor;
14238 + device->WarpWMCursor = CGX_WarpWMCursor;
14239 + device->CheckMouseMode = CGX_CheckMouseMode;
14240 + /* SDL_cgxevents.c */
14241 + device->InitOSKeymap = CGX_InitOSKeymap;
14242 + device->PumpEvents = CGX_PumpEvents;
14243 +#if SDL_VIDEO_OPENGL
14244 + /* SDL_cgxgl.c */
14245 + device->GL_LoadLibrary = CGX_GL_LoadLibrary;
14246 + device->GL_GetProcAddress = CGX_GL_GetProcAddress;
14247 + device->GL_GetAttribute = CGX_GL_GetAttribute;
14248 + device->GL_MakeCurrent = CGX_GL_MakeCurrent;
14249 + device->GL_SwapBuffers = CGX_GL_SwapBuffers;
14250 +#endif
14252 + return device;
14257 +#define CGX_VideoInit(this, vformat) CGX_VideoInitI(this, vformat, SDLBase)
14258 +#define CGX_SetColors(this, firstcolor, ncolors, colors) CGX_SetColorsI(this, firstcolor, ncolors, colors, SDLBase)
14259 +#define CGX_VideoQuit(this) CGX_VideoQuitI(this, SDLBase)
14260 +#define CGX_SetGamma(this, red, green, blue) CGX_SetGammaI(this, red, green, blue, SDLBase)
14261 +#define CGX_GetGamma(this, red, green, blue) CGX_GetGammaI(this, red, green, blue, SDLBase)
14262 +#define CGX_SetGammaRamp(this, ramp) CGX_SetGammaRampI(this, ramp, SDLBase)
14263 +#define CGX_GetGammaRamp(this, ramp) CGX_GetGammaRampI(this, ramp, SDLBase)
14264 +#define CGX_DeleteDevice(device) CGX_DeleteDeviceI(device, SDLBase)
14267 +#if !defined(PROTO_SDL_H)
14268 +static Uint32 CGX_OpenCustomScreen(_THIS, SDL_Surface *screen, int width, int height, int bpp, Uint32 flags)
14269 +#else
14270 +#define CGX_OpenCustomScreen(this, screen, width, height, bpp, flags) CGX_OpenCustomScreenI(this, screen, width, height, bpp, flags, SDLBase)
14271 +static Uint32 CGX_OpenCustomScreenI(_THIS, SDL_Surface *screen, int width, int height, int bpp, Uint32 flags, struct SDLBase *SDLBase)
14272 +#endif
14274 + Uint32 okid;
14276 + this->hidden->dbuffer = 0;
14278 + /* This function expects that GFX_Display is not set */
14279 + if (GFX_Display) {
14280 + D(bug("CGX_OpenCustomScreen called with GFX_Display still set\n"));
14281 + SDL_SetError("CGX_OpenCustomScreen called with GFX_Display still set");
14282 + flags &= ~SDL_FULLSCREEN;
14283 + flags &= ~SDL_DOUBLEBUF;
14284 + return flags;
14287 + okid = BestCModeIDTags(CYBRBIDTG_NominalWidth, width,
14288 + CYBRBIDTG_NominalHeight, height,
14289 + CYBRBIDTG_Depth, bpp,
14290 + TAG_DONE);
14292 + if ((okid == INVALID_ID) && (bpp == 32))
14294 + D(bug("Failed to open a 32bits screen trying 24bits instead\n"));
14295 + bpp = 24;
14296 + okid = BestCModeIDTags(CYBRBIDTG_NominalWidth, width,
14297 + CYBRBIDTG_NominalHeight, height,
14298 + CYBRBIDTG_Depth, bpp,
14299 + TAG_DONE);
14302 + D(bug("Opening screen %dx%d/%d (id:%lx)...\n", width, height, bpp, okid));
14304 + if(okid != INVALID_ID)
14305 + GFX_Display = OpenScreenTags(NULL,
14306 + SA_Width,width,
14307 + SA_Height,height,
14308 + SA_Quiet,TRUE,
14309 + SA_ShowTitle,FALSE,
14310 + SA_Depth,bpp,
14311 + SA_DisplayID,okid,
14312 + TAG_DONE);
14314 + if (!GFX_Display)
14316 + D(bug("OpenScreenTags failed!\n"));
14317 + flags &= ~SDL_FULLSCREEN;
14318 + flags &= ~SDL_DOUBLEBUF;
14320 + else
14322 + SDL_Display = GFX_Display;
14324 + D(bug("Screen opened: %d x %d.\n", GFX_Display->Width, GFX_Display->Height));
14326 + if(flags & SDL_DOUBLEBUF)
14328 +#ifndef NO_AMIGAHWSURF
14329 + APTR lock = NULL;
14330 + /* check if surface can be locked, if not => Surface is SW and there is no double buffering!*/
14331 + lock = LockBitMapTags( SDL_Display->RastPort.BitMap,
14332 + TAG_DONE);
14334 + if (lock)
14336 + UnLockBitMap(lock);
14338 + D(bug("Start of DBuffering allocations...\n"));
14340 + this->hidden->safeport=CreateMsgPort();
14341 + this->hidden->dispport=CreateMsgPort();
14343 + this->hidden->SB[0]=AllocScreenBuffer(SDL_Display,NULL,SB_SCREEN_BITMAP);
14344 + this->hidden->SB[1]=AllocScreenBuffer(SDL_Display,NULL,SB_COPY_BITMAP);
14346 + if ( this->hidden->safeport
14347 + && this->hidden->dispport
14348 + && this->hidden->SB[0]
14349 + && this->hidden->SB[1])
14351 + D(bug("Screen buffers Allocated...\n"));
14353 + this->hidden->safe_sigbit=1L<< this->hidden->safeport->mp_SigBit;
14354 + this->hidden->disp_sigbit=1L<< this->hidden->dispport->mp_SigBit;
14356 + this->hidden->SB[0]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=this->hidden->safeport;
14357 + this->hidden->SB[0]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=this->hidden->dispport;
14358 + this->hidden->SB[1]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=this->hidden->safeport;
14359 + this->hidden->SB[1]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=this->hidden->dispport;
14361 + this->hidden->dbuffer = 1;
14362 + if (screen) screen->flags |= SDL_DOUBLEBUF;
14363 + D(bug("Dbuffering enabled!\n"));
14365 + else
14367 + if (this->hidden->SB[0]) FreeScreenBuffer(SDL_Display,this->hidden->SB[0]);
14368 + if (this->hidden->SB[1]) FreeScreenBuffer(SDL_Display,this->hidden->SB[1]);
14369 + if (this->hidden->safeport) DeleteMsgPort (this->hidden->safeport);
14370 + if (this->hidden->dispport) DeleteMsgPort (this->hidden->dispport);
14371 + this->hidden->SB[0] = NULL;
14372 + this->hidden->SB[1] = NULL;
14373 + this->hidden->safeport = NULL;
14374 + this->hidden->dispport = NULL;
14376 + flags &= ~SDL_DOUBLEBUF;
14377 + this->hidden->dbuffer = 0;
14378 + D(bug("Dbuffering failed!\n"));
14381 + else
14383 + flags &= ~SDL_DOUBLEBUF;
14384 + this->hidden->dbuffer = 0;
14385 + D(bug("Dbuffering failed!\n"));
14387 +#else
14388 + flags &= ~SDL_DOUBLEBUF;
14389 +#endif
14393 + D(bug("Screen bitmap: %ld (%ld), bpp %ld\n",
14394 + GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_BPPIX),
14395 + GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH),
14396 + bpp));
14398 + return flags;
14402 +static void CGX_CloseCustomScreen(_THIS, SDL_Surface *screen)
14404 + if(this->hidden->dbuffer)
14406 + D(bug("Freeing double buffering stuff..."));
14408 + this->hidden->dbuffer = 0;
14409 + if (screen) screen->flags &= ~SDL_DOUBLEBUF;
14410 + if(this->hidden->SB[1]) FreeScreenBuffer(SDL_Display,this->hidden->SB[1]);
14411 + if(this->hidden->SB[0]) FreeScreenBuffer(SDL_Display,this->hidden->SB[0]);
14413 + D(bug("Screen buffers OK..."));
14415 + if(this->hidden->safeport)
14417 + while(GetMsg(this->hidden->safeport) != NULL);
14418 + DeleteMsgPort(this->hidden->safeport);
14420 + D(bug("safeport OK..."));
14421 + if(this->hidden->dispport)
14423 + while(GetMsg(this->hidden->dispport) != NULL);
14424 + DeleteMsgPort(this->hidden->dispport);
14426 + D(bug("dispport OK..."));
14428 + this->hidden->SB[0]=this->hidden->SB[1] = NULL;
14430 + if(SDL_RastPort && SDL_RastPort != &SDL_Display->RastPort) FreeRastPort(SDL_RastPort);
14431 + SDL_RastPort=NULL;
14432 + D(bug("Rastport OK..."));
14435 + D(bug("Closing screen..."));
14436 + CloseScreen(GFX_Display);
14437 + GFX_Display = NULL; SDL_Display = NULL;
14438 + currently_fullscreen = 0;
14439 + if (screen) screen->flags &= ~SDL_FULLSCREEN;
14442 +static void CGX_CloseUnlockScreen(_THIS, SDL_Surface *screen)
14444 + if(currently_fullscreen) {
14445 + CGX_CloseCustomScreen(this, screen);
14447 + else if(GFX_Display) {
14448 + UnlockPubScreen(NULL, GFX_Display);
14449 + GFX_Display = NULL; SDL_Display = NULL;
14452 + D(bug("Ok\n"));
14455 +#if !defined(PROTO_SDL_H)
14456 +static int CGX_Available(void)
14457 +#else
14458 +static int CGX_AvailableI(struct SDLBase *SDLBase)
14459 +#endif
14461 + if ( CyberGfxBase != NULL ) {
14462 + D(bug("CGX video device AVAILABLE\n"));
14464 + D(else bug("**CGX video device UNAVAILABLE\n"));
14466 + return(CyberGfxBase != NULL);
14469 +#if !defined(PROTO_SDL_H)
14470 +static void CGX_DeleteDevice(SDL_VideoDevice *device)
14471 +#else
14472 +static void CGX_DeleteDeviceI(SDL_VideoDevice *device, struct SDLBase *SDLBase)
14473 +#endif
14475 + if ( device ) {
14476 + if ( device->hidden ) {
14477 + SDL_free(device->hidden);
14479 + if ( device->gl_data ) {
14480 + SDL_free(device->gl_data);
14482 + SDL_free(device);
14486 +static void MakeBitMask(_THIS, int format,int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask)
14488 + if (this->hidden->depth==*bpp)
14490 + D(bug("REAL pixel format: "));
14492 + switch(format)
14494 + case PIXFMT_LUT8:
14495 + D(bug("PIXFMT_LUT8\n"));
14496 + *Rmask = 0;
14497 + *Gmask = 0;
14498 + *Bmask = 0;
14499 + *Amask = 0;
14500 + break;
14501 + case PIXFMT_BGR15:
14502 + D(bug("PIXFMT_BGR15\n"));
14503 + *Rmask = AROS_BE2WORD(0x001f);
14504 + *Gmask = AROS_BE2WORD(0x03e0);
14505 + *Bmask = AROS_BE2WORD(0x7c00);
14506 + *Amask = 0;
14507 + break;
14508 + case PIXFMT_RGB15:
14509 + D(bug("PIXFMT_RGB15\n"));
14510 + *Rmask = AROS_BE2WORD(0x7c00);
14511 + *Gmask = AROS_BE2WORD(0x03e0);
14512 + *Bmask = AROS_BE2WORD(0x001f);
14513 + *Amask = 0;
14514 + break;
14515 + case PIXFMT_RGB15PC:
14516 + D(bug("PIXFMT_RGB15PC\n"));
14517 + *Rmask = AROS_BE2WORD(0x007c);
14518 + *Gmask = AROS_BE2WORD(0xe003);
14519 + *Bmask = AROS_BE2WORD(0x1f00);
14520 + *Amask = 0;
14521 + break;
14522 + case PIXFMT_BGR15PC:
14523 + D(bug("PIXFMT_BGR15PC\n"));
14524 + *Rmask = AROS_BE2WORD(0x1f00);
14525 + *Gmask = AROS_BE2WORD(0xe003);
14526 + *Bmask = AROS_BE2WORD(0x007c);
14527 + *Amask = 0;
14528 + break;
14529 + case PIXFMT_RGB16:
14530 + D(bug("PIXFMT_RGB16\n"));
14531 + *Rmask = AROS_BE2WORD(0xf800);
14532 + *Gmask = AROS_BE2WORD(0x07e0);
14533 + *Bmask = AROS_BE2WORD(0x001f);
14534 + *Amask = 0;
14535 + break;
14536 + case PIXFMT_BGR16:
14537 + D(bug("PIXFMT_BGR16\n"));
14538 + *Rmask = AROS_BE2WORD(0x001f);
14539 + *Gmask = AROS_BE2WORD(0x07e0);
14540 + *Bmask = AROS_BE2WORD(0xf800);
14541 + *Amask = 0;
14542 + break;
14543 + case PIXFMT_RGB16PC:
14544 + D(bug("PIXFMT_RGB16PC\n"));
14545 + *Rmask = AROS_BE2WORD(0x00f8);
14546 + *Gmask = AROS_BE2WORD(0xe007);
14547 + *Bmask = AROS_BE2WORD(0x1f00);
14548 + *Amask = 0;
14549 + break;
14550 + case PIXFMT_BGR16PC:
14551 + D(bug("PIXFMT_BGR16PC\n"));
14552 + *Rmask = AROS_BE2WORD(0x1f00);
14553 + *Gmask = AROS_BE2WORD(0xe007);
14554 + *Bmask = AROS_BE2WORD(0x00f8);
14555 + *Amask = 0;
14556 + break;
14557 + case PIXFMT_RGB24:
14558 + D(bug("PIXFMT_RGB24\n"));
14559 + *Rmask = AROS_BE2LONG(0x00ff0000);
14560 + *Gmask = AROS_BE2LONG(0x0000ff00);
14561 + *Bmask = AROS_BE2LONG(0x000000ff);
14562 + *Amask = 0;
14563 + break;
14564 + case PIXFMT_BGR24:
14565 + D(bug("PIXFMT_BGR24\n"));
14566 + *Rmask = AROS_BE2LONG(0x000000ff);
14567 + *Gmask = AROS_BE2LONG(0x0000ff00);
14568 + *Bmask = AROS_BE2LONG(0x00ff0000);
14569 + *Amask = 0;
14570 + break;
14571 + case PIXFMT_ARGB32:
14572 + D(bug("PIXFMT_ARGB32\n"));
14573 + *Rmask = AROS_BE2LONG(0x00ff0000);
14574 + *Gmask = AROS_BE2LONG(0x0000ff00);
14575 + *Bmask = AROS_BE2LONG(0x000000ff);
14576 + *Amask = AROS_BE2LONG(0xff000000);
14577 + break;
14578 + case PIXFMT_BGRA32:
14579 + D(bug("PIXFMT_BGRA32\n"));
14580 + *Rmask = AROS_BE2LONG(0x0000ff00);
14581 + *Gmask = AROS_BE2LONG(0x00ff0000);
14582 + *Bmask = AROS_BE2LONG(0xff000000);
14583 + *Amask = AROS_BE2LONG(0x000000ff);
14584 + break;
14585 + case PIXFMT_RGBA32:
14586 + D(bug("PIXFMT_RGBA32\n"));
14587 + *Rmask = AROS_BE2LONG(0xff000000);
14588 + *Gmask = AROS_BE2LONG(0x00ff0000);
14589 + *Bmask = AROS_BE2LONG(0x0000ff00);
14590 + *Amask = AROS_BE2LONG(0x000000ff);
14591 + break;
14592 + default:
14593 + D(bug("Unknown pixel format! Default to RGB24\n"));
14594 + *Rmask = AROS_BE2LONG(0x00ff0000);
14595 + *Gmask = AROS_BE2LONG(0x0000ff00);
14596 + *Bmask = AROS_BE2LONG(0x000000ff);
14597 + *Amask = 0;
14598 + break;
14600 + }
14601 + else
14603 + D(bug("DIFFERENT from screen.\nAllocated screen format: "));
14605 + switch(*bpp)
14607 + case 32:
14608 + D(bug("ARGB32\n"));
14609 + *Rmask = AROS_BE2LONG(0x00ff0000);
14610 + *Gmask = AROS_BE2LONG(0x0000ff00);
14611 + *Bmask = AROS_BE2LONG(0x000000ff);
14612 + *Amask = AROS_BE2LONG(0xff000000);
14613 + break;
14614 + case 24:
14615 + D(bug("0RGB32\n"));
14616 + *Rmask = AROS_BE2LONG(0x00ff0000);
14617 + *Gmask = AROS_BE2LONG(0x0000ff00);
14618 + *Bmask = AROS_BE2LONG(0x000000ff);
14619 + *Amask = 0;
14620 + break;
14621 + case 16:
14622 + case 15:
14623 + D(bug("Not supported, switching to 24bit!\n"));
14624 + *bpp=24;
14625 + MakeBitMask(this, format, bpp, Rmask, Gmask, Bmask, Amask);
14626 + break;
14627 + default:
14628 + D(bug("This is a chunky display\n"));
14629 + *Rmask = 0;
14630 + *Gmask = 0;
14631 + *Bmask = 0;
14632 + *Amask = 0;
14633 + break;
14636 + D(bug("Mask created :\n R = 0x%08X; G = 0x%08X; B = 0x%08X; A = 0x%08X\n", *Rmask, *Gmask, *Bmask, *Amask));
14640 +#if !defined(PROTO_SDL_H)
14641 +static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat)
14642 +#else
14643 +static int CGX_VideoInitI(_THIS, SDL_PixelFormat *vformat, struct SDLBase *SDLBase)
14644 +#endif
14646 + int i;
14647 + int form;
14649 + D(bug("VideoInit... Opening libraries\n"));
14651 + if(!IntuitionBase)
14653 + SDL_SetError("Couldn't open intuition V39+");
14654 + return -1;
14657 + if(!GfxBase)
14659 + SDL_SetError("Couldn't open graphics V39+");
14660 + return -1;
14663 + if(!CyberGfxBase)
14665 + SDL_SetError("Couldn't open cybergraphics.");
14666 + return(-1);
14669 + D(bug("Library intialized, locking screen...\n"));
14671 + SDL_Display = LockPubScreen(NULL);
14673 + if ( SDL_Display == NULL ) {
14674 + D(bug("Cannot lock display...\n"));
14675 + SDL_SetError("Couldn't lock the display");
14676 + return(-1);
14678 + this->info.current_w = SDL_Display->Width;
14679 + this->info.current_h = SDL_Display->Height;
14681 + D(bug("Checking if we are using a CGX native display...\n"));
14682 + if(!IsCyberModeID(GetVPModeID(&SDL_Display->ViewPort)))
14684 + Uint32 okid=BestCModeIDTags(CYBRBIDTG_NominalWidth, SDL_Display->Width,
14685 + CYBRBIDTG_NominalHeight, SDL_Display->Height,
14686 + CYBRBIDTG_Depth, 8,
14687 + TAG_DONE);
14689 + D(bug("Default visual is not CGX native!\n"));
14691 + UnlockPubScreen(NULL,SDL_Display);
14693 + GFX_Display=NULL;
14695 + if(okid!=INVALID_ID)
14697 + GFX_Display=OpenScreenTags( NULL,
14698 + SA_Width,SDL_Display->Width,
14699 + SA_Height,SDL_Display->Height,
14700 + SA_Depth,8,
14701 + SA_Quiet,TRUE,
14702 + SA_ShowTitle,FALSE,
14703 + SA_DisplayID,okid,
14704 + TAG_DONE);
14707 + if(!GFX_Display)
14709 + SDL_SetError("Unable to open a suited CGX display");
14710 + return -1;
14712 + else SDL_Display=GFX_Display;
14715 + else GFX_Display = SDL_Display;
14717 + D(bug("Before GetVideoModes....\n"));
14718 + /* Get the available video modes */
14719 + if(CGX_GetVideoModes(this) < 0) return -1;
14721 + /* Determine the default screen depth: Use the default visual (or at least one with the same depth) */
14722 + for(i = 0; i < this->hidden->nvisuals; i++)
14723 + if(this->hidden->visuals[i].depth == GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH)) break;
14725 + /* default visual was useless, take the deepest one instead */
14726 + if(i == this->hidden->nvisuals) i = 0;
14728 + D(bug("Init: Setting screen depth to: %ld\n",this->hidden->visuals[i].depth));
14730 + SDL_Visual = this->hidden->visuals[i].visual;
14731 + this->hidden->depth = this->hidden->visuals[i].depth;
14732 + vformat->BitsPerPixel = this->hidden->visuals[i].depth;
14733 + vformat->BytesPerPixel = this->hidden->visuals[i].bpp / 8;
14735 + // In this case I use makebitmask in a way that I'm sure I'll get PIXFMT pixel mask
14736 + form = GetCyberIDAttr(CYBRIDATTR_PIXFMT,SDL_Visual);
14737 + if ( vformat->BitsPerPixel > 8 )
14739 + MakeBitMask(this,form,&this->hidden->depth, &vformat->Rmask, &vformat->Gmask, &vformat->Bmask, &vformat->Amask);
14740 + vformat->Amask = 0;
14743 + /* Create the blank cursor */
14744 + SDL_BlankCursor = AllocMem(16,MEMF_CHIP|MEMF_CLEAR);
14746 + /* Fill in some window manager capabilities */
14747 + this->info.wm_available = 1;
14748 + this->info.blit_fill = 1;
14749 +#ifndef NO_AMIGAHWSURF
14750 + this->info.hw_available = 1;
14751 + this->info.blit_hw = 1;
14752 + this->info.blit_hw_CC = 1;
14753 + this->info.blit_hw_A = 1;
14754 + this->info.blit_sw = 1;
14755 + this->info.blit_sw_CC = 0;
14756 + this->info.blit_sw_A = 1;
14757 +#endif
14758 + this->info.video_mem = AvailMem(MEMF_FAST) / 4096000 * 1000; /* how to get Video Memory size? */
14760 + SDL_RastPort = &SDL_Display->RastPort;
14762 + /* We're done! */
14763 + D(bug("End of CGX_VideoInit\n"));
14765 + return(0);
14768 +#if !defined(PROTO_SDL_H)
14769 +static void CGX_DestroyWindow(_THIS, SDL_Surface *screen, Uint32 flags)
14770 +#else
14771 +#define CGX_DestroyWindow(this, screen, flags) CGX_DestroyWindowI(this, screen, flags, SDLBase)
14772 +static void CGX_DestroyWindowI(_THIS, SDL_Surface *screen, Uint32 flags, struct SDLBase *SDLBase)
14773 +#endif
14775 + D(bug("Destroy Window...\n"));
14777 + /* Mark activation flags */
14778 + this->hidden->WindowActive = 0;
14779 + this->hidden->FocusActive = 0;
14781 + /* Clean up OpenGL */
14782 + if ( screen && ( screen->flags & SDL_OPENGL ) && ! (flags & SDL_KEEP_GL_CONTEXT)) {
14783 + CGX_GL_DestroyContext(this);
14784 + screen->flags &= ~(SDL_OPENGL|SDL_OPENGLBLIT);
14787 + /* Free the colormap entries */
14788 + if ( SDL_Pens ) {
14789 + if ( this->screen
14790 + && this->hidden
14791 + && GFX_Display
14792 + && this->screen->format
14793 + && this->hidden->depth == 8
14794 + && ! ( screen && (screen->flags & SDL_FULLSCREEN) ) ) {
14795 + int numcolors = 1 << this->screen->format->BitsPerPixel;
14796 + unsigned long pen;
14798 + if(numcolors > 256) numcolors = 256;
14800 + D(bug("Releasing %d pens...\n", numcolors));
14801 + for ( pen=0; pen < numcolors; pen++ )
14802 + if(SDL_Pens[pen] >= 0) ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_Pens[pen]);
14804 + SDL_free(SDL_Pens);
14805 + SDL_Pens = NULL;
14808 + /* Destroy the output window */
14809 + if ( SDL_Window ) {
14810 +#ifndef NO_AMIGAHWSURF
14811 + if (this->hidden->temprp) FreeRastPort(this->hidden->temprp);
14812 + this->hidden->temprp = NULL;
14813 + if (this->hidden->BlitBitMap) FreeBitMap(this->hidden->BlitBitMap);
14814 + this->hidden->BlitBitMap = NULL;
14815 +#endif
14816 + CloseWindow(SDL_Window);
14817 + SDL_Window = NULL;
14821 +static void CGX_SetSizeHints(_THIS, int w, int h, Uint32 flags)
14823 + if ( flags & SDL_RESIZABLE )
14824 + WindowLimits(SDL_Window, 32, 32,4096,4096);
14825 + else
14826 + WindowLimits(SDL_Window, w,h,w,h);
14828 + if ( flags & SDL_FULLSCREEN )
14829 + flags &= ~SDL_RESIZABLE;
14830 + else if ( SDL_getenv("SDL_VIDEO_CENTERED") )
14831 + ChangeWindowBox(SDL_Window,
14832 + (SDL_Display->Width - w - SDL_Window->BorderLeft-SDL_Window->BorderRight)/2,
14833 + (SDL_Display->Height - h - SDL_Window->BorderTop-SDL_Window->BorderBottom)/2,
14834 + w+SDL_Window->BorderLeft+SDL_Window->BorderRight,
14835 + h+SDL_Window->BorderTop+SDL_Window->BorderBottom);
14838 +#if !defined(PROTO_SDL_H)
14839 +static int CGX_CreateWindow(_THIS, SDL_Surface *screen, int w, int h, int bpp, Uint32 flags)
14840 +#else
14841 +#define CGX_CreateWindow(this, screen, w, h, bpp, flags) CGX_CreateWindowI(this, screen, w, h, bpp, flags, SDLBase)
14842 +static int CGX_CreateWindowI(_THIS, SDL_Surface *screen, int w, int h, int bpp, Uint32 flags, struct SDLBase *SDLBase)
14843 +#endif
14845 + Uint32 form, rb, gb, bb, ab;
14847 + D(bug("CGX_CreateWindow %dx%d/%d flags:%lx\n", w, h, bpp, flags));
14849 + /* This function assumes any existing window has already been closed */
14850 + if (SDL_Window != 0) {
14851 + D(bug("CGX_CreateWindow called when window still open\n"));
14852 + SDL_SetError("CGX_CreateWindow called when window still open");
14853 + return (-1);
14855 + /* This function assumes any existing GL context has already been freed up */
14856 + if (!(flags & SDL_KEEP_GL_CONTEXT) && (this->gl_data->glctx != NULL)) {
14857 + D(bug("CGX_CreateWindow called when GL context still active\n"));
14858 + SDL_SetError("CGX_CreateWindow called when GL context still active");
14859 + return (-1);
14862 + /* Allocate the new pixel format for this video mode */
14863 + form = GetCyberIDAttr(CYBRIDATTR_PIXFMT,SDL_Visual);
14865 + if((flags & SDL_HWSURFACE) && (bpp!=this->hidden->depth))
14867 + bpp = this->hidden->depth;
14868 + D(bug("Accel forces bpp to be equal (%ld)\n",bpp));
14871 + /*
14872 + With this call if needed I'll revert the wanted bpp to a bpp best suited for the display, actually occurs
14873 + only with requested format 15/16bit and display format != 15/16bit
14874 + */
14875 + D(bug("BEFORE screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth));
14877 + MakeBitMask(this,form,&bpp, &rb, &gb, &bb, &ab);
14879 + if ( ! SDL_ReallocFormat(screen, 8 * GetCyberMapAttr(SDL_Display->RastPort.BitMap, CYBRMATTR_BPPIX), rb, gb, bb, 0) )
14880 + return -1;
14882 + D(bug("AFTER screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth));
14884 + /* Create the appropriate colormap */
14885 + if ( GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT)==PIXFMT_LUT8 || bpp==8 )
14887 + int ncolors,i;
14888 + D(bug("Pens palette allocation...\n"));
14890 + /* Allocate the pixel flags */
14891 + if(bpp>=8)
14892 + ncolors=256;
14893 + else
14894 + ncolors = 1 << screen->format->BitsPerPixel;
14896 + SDL_Pens = (Sint32 *)SDL_malloc(ncolors * sizeof(Sint32));
14898 + if(SDL_Pens == NULL)
14900 + SDL_OutOfMemory();
14901 + return -1;
14904 + for(i=0;i<ncolors;i++) SDL_Pens[i]=-1;
14906 + /* always allocate a private colormap on non-default visuals */
14907 + if(bpp==8) flags |= SDL_HWPALETTE;
14909 + if ( flags & SDL_HWPALETTE ) screen->flags |= SDL_HWPALETTE;
14910 + }
14912 + if( flags & SDL_FULLSCREEN )
14914 + SDL_Window = OpenWindowTags(NULL,
14915 + WA_Width,SDL_Display->Width,
14916 + WA_Height,SDL_Display->Height,
14917 + WA_Flags,WFLG_ACTIVATE|WFLG_RMBTRAP|WFLG_BORDERLESS|WFLG_BACKDROP|WFLG_REPORTMOUSE,
14918 + WA_IDCMP,IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE,
14919 + WA_BackFill, (IPTR)LAYERS_NOBACKFILL,
14920 + WA_CustomScreen,(IPTR)SDL_Display,
14921 + TAG_DONE);
14922 + FillPixelArray(SDL_Window->RPort,SDL_Window->BorderLeft,SDL_Window->BorderTop,SDL_Display->Width,SDL_Display->Height,0x00000000);
14923 + D(bug("Opening backdrop window %ldx%ld on display %lx!\n",SDL_Display->Width,SDL_Display->Height,SDL_Display));
14925 + else
14927 + ULONG left, top;
14929 + left = (SDL_Display->Width - w) / 2;
14930 + top = (SDL_Display->Height - h) / 2;
14932 + SDL_Window = OpenWindowTags(NULL,
14933 + WA_InnerWidth,w,
14934 + WA_InnerHeight,h,
14935 + WA_Left, left,
14936 + WA_Top, top,
14937 + WA_Title, this->hidden->WindowName,
14938 + WA_Flags, WFLG_REPORTMOUSE|WFLG_ACTIVATE|WFLG_RMBTRAP |
14939 + ((flags&SDL_NOFRAME) ? 0 : (WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_DRAGBAR |
14940 + ((flags&SDL_RESIZABLE) ? WFLG_SIZEGADGET|WFLG_SIZEBBOTTOM : 0))),
14941 + WA_IDCMP, IDCMP_RAWKEY|IDCMP_CLOSEWINDOW|IDCMP_MOUSEBUTTONS|IDCMP_NEWSIZE|
14942 + IDCMP_MOUSEMOVE|IDCMP_ACTIVEWINDOW|IDCMP_INACTIVEWINDOW,
14943 + WA_BackFill, (IPTR)LAYERS_NOBACKFILL,
14944 + WA_PubScreen,(IPTR)SDL_Display,
14945 + TAG_DONE);
14946 + FillPixelArray(SDL_Window->RPort,SDL_Window->BorderLeft,SDL_Window->BorderTop,w,h,0x00000000);
14947 + D(bug("Opening WB window of size: %ldx%ld!\n",w,h));
14950 +#ifndef NO_AMIGAHWSURF
14951 + if ( (flags & SDL_DOUBLEBUF)
14952 + && (flags & SDL_FULLSCREEN)
14953 + && (this->hidden->dbuffer) )
14955 + D(bug("Double Buffering in use\n",w,h));
14956 + if((SDL_RastPort = CreateRastPort()) != NULL)
14958 + SDL_RastPort->BitMap=this->hidden->SB[1]->sb_BitMap;
14959 + screen->flags |= SDL_DOUBLEBUF;
14961 + else
14962 + return -1;
14964 + else
14966 + // If there is no double buffering we create a Bitmap to fake double buffering.
14967 + D(bug("No Double Buffering : Using BlitBitMap hack\n",w,h));
14968 + this->hidden->BlitBitMap = AllocBitMap( w,
14969 + h,
14970 + GetBitMapAttr(SDL_Window->RPort->BitMap, BMA_DEPTH),
14971 + flags & SDL_FULLSCREEN ? BMF_CLEAR| BMF_MINPLANES : BMF_CLEAR | BMF_MINPLANES | BMF_DISPLAYABLE,
14972 + SDL_Window->RPort->BitMap);
14974 + if (!this->hidden->BlitBitMap) return -1;
14976 + screen->flags &= ~SDL_DOUBLEBUF;
14977 + SDL_RastPort=SDL_Window->RPort;
14979 +#else
14980 + screen->flags &= ~SDL_DOUBLEBUF;
14981 + SDL_RastPort=SDL_Window->RPort;
14982 +#endif
14984 + if (flags & SDL_HWSURFACE)
14985 + screen->flags |= SDL_HWSURFACE;
14986 + else
14987 + screen->flags &= ~SDL_HWSURFACE;
14989 + CGX_SetSizeHints(this, w, h, flags);
14990 + this->info.current_w = w;
14991 + this->info.current_h = h;
14993 + if ( flags & SDL_FULLSCREEN )
14995 + screen->flags |= SDL_FULLSCREEN;
14996 + /* IDCMP_ACTIVEWINDOW does not seem to be sent to windows opened on
14997 + new screen, so we set activity status here */
14998 + this->hidden->WindowActive = 1;
14999 + /* Reset explicit focus activation - alway capture in full screen mode */
15000 + this->hidden->ExplicitFocusActivation = 0;
15002 + currently_fullscreen=1;
15004 + else
15005 + screen->flags &= ~SDL_FULLSCREEN;
15007 + screen->w = w;
15008 + screen->h = h;
15009 + screen->pitch = SDL_CalculatePitch(screen);
15010 + CGX_ResizeImage(this, screen, flags);
15012 + /* Make OpenGL Context if needed*/
15013 + if(flags & SDL_OPENGL) {
15014 + if (flags & SDL_KEEP_GL_CONTEXT) {
15015 + /* Context was not destroyed, update it here */
15016 + if (CGX_GL_UpdateContext(this) < 0) {
15017 + SDL_SetError("Failed to update GL context");
15018 + return -1;
15020 + } else {
15021 + if(CGX_GL_CreateContext(this) < 0) {
15022 + SDL_SetError("Failed to create GL context");
15023 + return -1;
15025 + else
15026 + screen->flags |= SDL_OPENGL;
15030 + return 0;
15033 +#if !defined(PROTO_SDL_H)
15034 +static int CGX_ResizeWindow(_THIS, SDL_Surface *screen, int width, int height, Uint32 flags)
15035 +#else
15036 +#define CGX_ResizeWindow(this, screen, width, height, flags) CGX_ResizeWindowI(this, screen, width, height, flags, SDLBase)
15037 +static int CGX_ResizeWindowI(_THIS, SDL_Surface *screen, int width, int height, Uint32 flags, struct SDLBase *SDLBase)
15038 +#endif
15040 + D(bug("CGX_ResizeWindow\n"));
15042 + /* Resize the window manager window */
15043 + CGX_SetSizeHints(this, width, height, flags);
15044 + this->info.current_w = width;
15045 + this->info.current_h = height;
15047 + ChangeWindowBox( SDL_Window,
15048 + SDL_Window->LeftEdge,
15049 + SDL_Window->TopEdge,
15050 + width+SDL_Window->BorderLeft+SDL_Window->BorderRight,
15051 + height+SDL_Window->BorderTop+SDL_Window->BorderBottom);
15052 + screen->w = width;
15053 + screen->h = height;
15054 + screen->pitch = SDL_CalculatePitch(screen);
15055 +#ifndef NO_AMIGAHWSURF
15056 + if (this->hidden->BlitBitMap)
15058 + FreeBitMap(this->hidden->BlitBitMap);
15059 + this->hidden->BlitBitMap = AllocBitMap( width,
15060 + height,
15061 + GetBitMapAttr(SDL_Window->RPort->BitMap, BMA_DEPTH),
15062 + flags & SDL_FULLSCREEN ? BMF_CLEAR | BMF_MINPLANES : BMF_CLEAR |BMF_MINPLANES | BMF_DISPLAYABLE,
15063 + SDL_Window->RPort->BitMap);
15065 +#endif
15066 + CGX_ResizeImage(this, screen, flags);
15068 + return 0;
15071 +/* There are several combinations of existing and request parameters that this
15072 + function needs to support.
15074 + Explanation of parameters:
15075 + FS - full screen
15076 + WND - windowned on Workbench window
15077 + sizeA, sizeB, sizeAny - some different sizes (width/height) of surfaces
15078 + bppA, bppB, bppAny - some different bits per pixel of surfaces
15079 + bppWB - bits per pixel of Workbench
15080 + OGL - surface uses OpenGL
15081 + NOGL - surface does not use OpenGL
15083 + Explanation of actions:
15084 + wndR - resize window
15085 + wndC, wndD - create, destroy window
15086 + scrC, scrD - create, destroy screen
15087 + oglC, oglD - create, destroy OpenGL context
15088 + oglU - update OpenGL context with new window
15090 + Cases:
15092 + | Current | Requested | Actions |
15093 + | bppWB, sizeA, WND, OGL | bppB, sizeAny, WND, OGL | Not possible to change bpp of window on Workbench |
15094 + | bppWB, sizeA, WND, OGL | bppWB, sizeB, WND, OGL | wndR(sizeB) |
15095 + | bppWB, sizeA, WND, NOGL | bppWB, sizeB, WND, NOGL | wndR(sizeB) |
15096 + | bppWB, sizeA, WND, OGL | bppWB, sizeB, WND, NOGL | oglD, wndD, wndC(sizeB) |
15097 + | bppWB, sizeA, WND, NOGL | bppWB, sizeB, WND, OGL | wndD, wndC(sizeB), oglC |
15098 + | bppWB, sizeA, WND, OGL | bppAny, sizeAny, FS, OGL | wndD, scrC(sizeAny, bppAny), wndC(sizeAny), oglU |
15099 + | bppWB, sizeA, WND, OGL | bppAny, sizeAny, FS, NOGL | oglD, wndD, scrC(sizeAny, bppAny), wndC(sizeAny), oglC |
15100 + | bppA, sizeA, FS, OGL | bppB, sizeAny, FS, OGL | wndD, scrD, scrC(sizeAny, bppB), wndC(sizeAny), oglU |
15101 + | bppA, sizeA, FS, OGL | bppAny, sizeB, FS, OGL | wndD, scrD, scrC(sizeB, bppAny), wndC(sizeB), oglU |
15102 + | bppA, sizeA, FS, OGL | bppB, sizeAny, FS, NOGL | oglD, wndD, scrD, scrC(sizeAny, bppB), wndC(sizeAny) |
15103 + | bppA, sizeA, FS, OGL | bppAny, sizeB, FS, NOGL | oglD, wndD, scrD, scrC(sizeB, bppAny), wndC(sizeB) |
15104 + | bppA, sizeA, FS, OGL | bppWB, sizeAny, WND, OGL | wndD, scrD, wndC(sizeAny), oglU |
15105 + | bppA, sizeA, FS, OGL | bppWB, sizeAny, WND, NOGL | oglD, wndD, scrD, wndC(sizeAny) |
15107 + Rules:
15109 + (+)if ( curr->WND && req->WND && sizediff && ! ogldiff ) resize_window
15110 + (+)if ( ! resize_window ) destroy_window
15111 + (+)if ( curr->FS && ( sizediff || bppdiff || req->WND ) ) destroy_screen
15112 + (+)if ( req->FS && ( sizediff || bppdiff || curr->WND ) ) create_screen
15113 + (+)if ( ! resize_window ) create_window
15115 + (+)if ( ! ogldiff) req->SDL_KEEP_GL_CONTEXT
15116 + (+)if ( destroy_window && curr->SDL_OPENGL && ! req->SDL_KEEP_GL_CONTEXT ) destroy_context
15117 + (+)if ( create_window && req->SDL_OPENGL && ! req->SDL_KEEP_GL_CONTEXT ) create_context
15118 + (+)if ( create_window && req->SDL_OPENGL && req->SDL_KEEP_GL_CONTEXT ) update_context
15121 +#if !defined(PROTO_SDL_H)
15122 +static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags)
15123 +#else
15124 +#ifdef CGX_SetVideoMode
15125 +#undef CGX_SetVideoMode
15126 +#endif
15127 +#define CGX_SetVideoMode(this, current, width, height, bpp, flags) CGX_SetVideoModeI(this, current, width, height, bpp, flags, SDLBase)
15128 +static SDL_Surface *CGX_SetVideoModeI(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags, struct SDLBase *SDLBase)
15129 +#endif
15131 + int sizediff = 0, bppdiff = 0, ogldiff = 0, i;
15133 + sizediff = (current != NULL) ? ((current->w != width) || (current->h != height)) : 1;
15134 + bppdiff = (this->hidden != NULL) ? (this->hidden->depth != bpp) : 1;
15135 + ogldiff = (current != NULL) ? ((current->flags & SDL_OPENGL) != (flags & SDL_OPENGL)) : 1;
15136 + if (!ogldiff) flags |= SDL_KEEP_GL_CONTEXT;
15138 + D(bug("CGX_SetVideoMode to %dx%dx%d, sizediff %d bppdiff %d\n", width, height, bpp, sizediff, bppdiff));
15140 + /* Lock the event thread, in multi-threading environments */
15141 + SDL_Lock_EventThread();
15143 + /* Decide early on if we are resizing or rebuilding window */
15144 + if ((SDL_Window && current && !(current->flags & SDL_FULLSCREEN)) && !(flags & SDL_FULLSCREEN)
15145 + && (sizediff) && (!ogldiff)) {
15146 + if (bppdiff) {
15147 + /* Not possible in windowned mode. Use previous depth. */
15148 + D(bug("Bringing bpp back from %d to %d\n", bpp, this->hidden->depth));
15149 + bpp = this->hidden->depth;
15151 + /* Resize */
15152 + if (CGX_ResizeWindow(this, current, width, height, flags) < 0)
15153 + current = NULL;
15154 + else
15155 + current->flags |= (flags & SDL_RESIZABLE); /* Resizable only if the user asked it */
15157 + /* Release the event thread */
15158 + SDL_Unlock_EventThread();
15160 + /* We're done! */
15161 + return(current);
15164 + /* Destroy existing window */
15165 + CGX_DestroyImage(this, current);
15166 + CGX_DestroyWindow(this, current, flags);
15168 + /* Destroy existing screen if needed */
15169 + if ((current && (current->flags & SDL_FULLSCREEN)) &&
15170 + ((!(flags & SDL_FULLSCREEN)) || (sizediff) || (bppdiff))) {
15171 + CGX_CloseCustomScreen(this, current);
15174 + /* Create new screen if needed */
15175 + if ((flags & SDL_FULLSCREEN) &&
15176 + ((current && !(current->flags & SDL_FULLSCREEN))
15177 + || (sizediff) || (bppdiff))) {
15179 + /* Release hold on Workbench screen first */
15180 + if (current && !(current->flags & SDL_FULLSCREEN)) {
15181 + UnlockPubScreen(NULL, GFX_Display);
15182 + GFX_Display = NULL; SDL_Display = NULL;
15185 + flags = CGX_OpenCustomScreen(this, current, width, height, bpp, flags);
15188 + if (!GFX_Display) {
15189 + /* Attach SDL to Workbench screen if screen opening failed on running
15190 + in windowed mode. */
15191 + GFX_Display = SDL_Display = LockPubScreen(NULL);
15194 + /* Select visual before creating a window */
15195 + bpp = this->hidden->depth = GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH);
15196 + D(bug("Setting screen depth to: %ld\n", this->hidden->depth));
15198 + for (i = 0; i < this->hidden->nvisuals; i++)
15199 + if (this->hidden->visuals[i].depth == bpp)
15200 + break;
15202 + if (i == this->hidden->nvisuals) {
15203 + SDL_SetError("No matching visual for requested depth. Should never happen!");
15204 + return NULL; /* should never happen */
15206 + SDL_Visual = this->hidden->visuals[i].visual;
15208 + /* Create a new window */
15209 + if (CGX_CreateWindow(this, current, width, height, bpp, flags) < 0)
15210 + current = NULL;
15211 + else
15212 + current->flags |= (flags & SDL_RESIZABLE); /* Resizable only if the user asked it */
15214 + /* Release the event thread */
15215 + SDL_Unlock_EventThread();
15217 + /* We're done! */
15218 + return(current);
15221 +#if !defined(PROTO_SDL_H)
15222 +static int CGX_ToggleFullScreen(_THIS, int on)
15223 +#else
15224 +static int CGX_ToggleFullScreenI(_THIS, int on, struct SDLBase *SDLBase)
15225 +#endif
15227 + Uint32 event_thread;
15229 + /* Don't lock if we are the event thread */
15230 + event_thread = SDL_EventThreadID();
15231 + if (event_thread && (SDL_ThreadID() == event_thread)) event_thread = 0;
15232 + if (event_thread) SDL_Lock_EventThread();
15234 + if (on)
15236 + Uint32 flags = this->screen->flags;
15237 + flags |= SDL_FULLSCREEN;
15239 + /* Call video mode change */
15240 + CGX_SetVideoMode(this, this->screen, this->screen->w, this->screen->h, this->hidden->depth, flags);
15241 + }
15242 + else
15244 + Uint32 flags = this->screen->flags;
15245 + flags &= ~SDL_FULLSCREEN;
15247 + /* Call video mode change */
15248 + CGX_SetVideoMode(this, this->screen, this->screen->w, this->screen->h, this->hidden->depth, flags);
15251 + /* SDL does not take care of hinding cursor in this case. If it was hidden, hide it
15252 + again. Call Intuition direclty */
15253 + if ((this->hidden->CursorVisible == 0) && (SDL_BlankCursor != NULL))
15254 + SetPointer(SDL_Window, (UWORD *)SDL_BlankCursor, 1, 1, 0, 0);
15257 + CGX_RefreshDisplay(this);
15259 + if (event_thread) SDL_Unlock_EventThread();
15261 + SDL_ResetKeyboard();
15262 + return(1);
15265 +/* Update the current mouse state and position */
15266 +#if !defined(PROTO_SDL_H)
15267 +static void CGX_UpdateMouse(_THIS)
15268 +#else
15269 +static void CGX_UpdateMouseI(_THIS, struct SDLBase *SDLBase)
15270 +#endif
15272 + /* Lock the event thread, in multi-threading environments */
15273 + SDL_Lock_EventThread();
15275 + if(currently_fullscreen)
15277 + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
15278 + SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX, SDL_Display->MouseY);
15280 + else
15282 + if( SDL_Display->MouseX>=(SDL_Window->LeftEdge+SDL_Window->BorderLeft) && SDL_Display->MouseX<(SDL_Window->LeftEdge+SDL_Window->Width-SDL_Window->BorderRight) &&
15283 + SDL_Display->MouseY>=(SDL_Window->TopEdge+SDL_Window->BorderLeft) && SDL_Display->MouseY<(SDL_Window->TopEdge+SDL_Window->Height-SDL_Window->BorderBottom)
15286 + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
15287 + SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX-SDL_Window->LeftEdge-SDL_Window->BorderLeft,
15288 + SDL_Display->MouseY-SDL_Window->TopEdge-SDL_Window->BorderTop);
15290 + else
15292 + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
15295 + SDL_Unlock_EventThread();
15298 +#if !defined(PROTO_SDL_H)
15299 +static int CGX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
15300 +#else
15301 +static int CGX_SetColorsI(_THIS, int firstcolor, int ncolors, SDL_Color *colors, struct SDLBase *SDLBase)
15302 +#endif
15304 + int i;
15306 + if ( (this->screen->flags & SDL_HWPALETTE) && currently_fullscreen )
15308 + ULONG cmap[256*3+2];
15310 + cmap[0]=(ncolors<<16);
15311 + cmap[0]+=firstcolor;
15313 + for ( i=0; i<ncolors; i++ )
15315 + cmap[i*3+1] = colors[i].r<<24;
15316 + cmap[i*3+2] = colors[i].g<<24;
15317 + cmap[i*3+3] = colors[i].b<<24;
15319 + cmap[ncolors*3+1]=0;
15320 + LoadRGB32(&GFX_Display->ViewPort,cmap);
15321 + }
15322 + else
15324 + // Pens are not needed on 8bit screen with hwpalette
15325 + unsigned long pen;
15327 + if ( SDL_Pens == NULL ) {
15328 + D(bug("SetColors without colormap!"));
15329 + return(0);
15332 + if(this->hidden->depth==8)
15334 + for ( pen=firstcolor; pen<ncolors+firstcolor; pen++ )
15336 + if(SDL_Pens[pen]>=0)
15337 + ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_Pens[pen]);
15340 + /* Try to allocate all the colors */
15341 + for ( i=0; i<ncolors; i++ )
15343 + SDL_Pens[i+firstcolor]=ObtainBestPenA(GFX_Display->ViewPort.ColorMap,colors[i].r<<24,colors[i].g<<24,colors[i].b<<24,NULL);
15346 + else
15348 + for(i=0;i<ncolors;i++)
15349 + SDL_Pens[i+firstcolor]=(colors[i].r<<16)+(colors[i].g<<8)+colors[i].b;
15352 + return 1;
15355 +/*
15356 + Note: If we are terminated, this could be called in the middle of
15357 + another SDL video routine -- notably UpdateRects.
15359 +#if !defined(PROTO_SDL_H)
15360 +static void CGX_VideoQuit(_THIS)
15361 +#else
15362 +static void CGX_VideoQuitI(_THIS, struct SDLBase *SDLBase)
15363 +#endif
15365 + /* Shutdown everything that's still up */
15366 + /* The event thread should be done, so we can touch SDL_Display */
15367 + D(bug("CGX_VideoQuit\n"));
15369 + if ( SDL_Display != NULL )
15371 + /* Clean up OpenGL */
15372 + CGX_GL_Quit(this);
15374 + /* Start shutting down the windows */
15375 + D(bug("Destroying image...\n"));
15376 + CGX_DestroyImage(this, this->screen);
15377 + D(bug("Destroying window...\n"));
15378 + CGX_DestroyWindow(this, this->screen, 0);
15379 + /* Otherwise SDL_VideoQuit will try to free it! */
15380 + SDL_VideoSurface=NULL;
15381 + CGX_FreeVideoModes(this);
15383 + /* Free that blank cursor */
15384 + if ( SDL_BlankCursor != NULL )
15386 + FreeMem(SDL_BlankCursor,16);
15387 + SDL_BlankCursor = NULL;
15390 + D(bug("Destroying screen...\n"));
15392 + if ( GFX_Display != NULL )
15393 + CGX_CloseUnlockScreen(this, NULL);
15395 + SDL_Display = NULL;
15398 + if (SDL_ConReq)
15400 + DeleteIORequest(SDL_ConReq);
15401 + SDL_ConReq = NULL;
15404 + if (SDL_ConPort)
15406 + DeleteMsgPort(SDL_ConPort);
15407 + SDL_ConPort = NULL;
15410 + if ( this->screen && (this->screen->flags & SDL_HWSURFACE) )
15412 + /* Direct screen access, no memory buffer */
15413 + this->screen->pixels = NULL;
15415 + D(bug("End of CGX_VideoQuit.\n"));
15419 +/* Gamma correction functions (Not supported) */
15420 +#if !defined(PROTO_SDL_H)
15421 +static int CGX_SetGamma(_THIS, float red, float green, float blue)
15422 +#else
15423 +static int CGX_SetGammaI(_THIS, float red, float green, float blue, struct SDLBase *SDLBase)
15424 +#endif
15426 + SDL_SetError("Gamma correction not supported");
15427 + return -1;
15430 +#if !defined(PROTO_SDL_H)
15431 +static int CGX_GetGamma(_THIS, float *red, float *green, float *blue)
15432 +#else
15433 +static int CGX_GetGammaI(_THIS, float *red, float *green, float *blue, struct SDLBase *SDLBase)
15434 +#endif
15436 + SDL_SetError("Gamma correction not supported");
15437 + return -1;
15440 +#if !defined(PROTO_SDL_H)
15441 +static int CGX_SetGammaRamp(_THIS, Uint16 *ramp)
15442 +#else
15443 +static int CGX_SetGammaRampI(_THIS, Uint16 *ramp, struct SDLBase *SDLBase)
15444 +#endif
15446 + SDL_SetError("Gamma correction not supported");
15447 + return(-1);
15450 +#if !defined(PROTO_SDL_H)
15451 +static int CGX_GetGammaRamp(_THIS, Uint16 *ramp)
15452 +#else
15453 +static int CGX_GetGammaRampI(_THIS, Uint16 *ramp, struct SDLBase *SDLBase)
15454 +#endif
15456 + SDL_SetError("Gamma correction not supported");
15457 + return(-1);
15459 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxvideo.h SDL-1.2.15/src/video/cgx/SDL_cgxvideo.h
15460 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxvideo.h 1970-01-01 01:00:00.000000000 +0100
15461 +++ SDL-1.2.15/src/video/cgx/SDL_cgxvideo.h 2015-05-09 15:09:59.769739506 +0200
15462 @@ -0,0 +1,138 @@
15464 + SDL - Simple DirectMedia Layer
15465 + Copyright (C) 1997-2006 Sam Lantinga
15467 + This library is free software; you can redistribute it and/or
15468 + modify it under the terms of the GNU Lesser General Public
15469 + License as published by the Free Software Foundation; either
15470 + version 2.1 of the License, or (at your option) any later version.
15472 + This library is distributed in the hope that it will be useful,
15473 + but WITHOUT ANY WARRANTY; without even the implied warranty of
15474 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15475 + Lesser General Public License for more details.
15477 + You should have received a copy of the GNU Lesser General Public
15478 + License along with this library; if not, write to the Free Software
15479 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15481 + Sam Lantinga
15482 + slouken@libsdl.org
15484 +#include "SDL_config.h"
15486 +#ifndef _SDL_cgxvideo_h
15487 +#define _SDL_cgxvideo_h
15490 +#include <exec/exec.h>
15491 +#include <cybergraphx/cybergraphics.h>
15492 +#include <graphics/scale.h>
15493 +#include <graphics/gfx.h>
15494 +#include <intuition/intuition.h>
15495 +#include <proto/exec.h>
15496 +#include <proto/cybergraphics.h>
15497 +#include <proto/graphics.h>
15498 +#include <proto/intuition.h>
15499 +#include <proto/console.h>
15500 +#include <devices/rawkeycodes.h>
15502 +#include "SDL_mouse.h"
15503 +#include "../SDL_sysvideo.h"
15504 +#include "../../main/aros/mydebug.h"
15506 +/* Hidden "this" pointer for the video functions */
15507 +#define _THIS SDL_VideoDevice *this
15508 +#define WINDOW_NAME_BUFFER_SIZE 256
15510 +/* Private display data */
15511 +struct SDL_PrivateVideoData {
15512 + struct Screen *Public_Display; /* Used for events and window management */
15513 + struct Screen *GFX_Display; /* Used for graphics and colormap stuff */
15514 + struct Window *SDL_Window; /* The SDL Window */
15515 + struct RastPort *RP;
15516 + TEXT WindowName[WINDOW_NAME_BUFFER_SIZE];
15518 + unsigned char *BlankCursor; /* The invisible cursor */
15520 + /* The variables used for displaying graphics */
15521 + Uint8 *Image; /* The image for our window */
15523 + /* The current list of available video modes */
15524 + SDL_Rect **modelist;
15526 + /* available visuals of interest to us, sorted deepest first */
15527 + struct {
15528 + Uint32 visual;
15529 + int depth; /* number of significant bits/pixel */
15530 + int bpp; /* pixel quantum in bits */
15531 + } visuals[5]; /* at most entries for 8, 15, 16, 24, 32*/
15532 + int nvisuals;
15534 + Uint32 vis; /* current visual in use */
15535 + int depth; /* current visual depth (not bpp) */
15536 + int currently_fullscreen; /* Fullscreen flag */
15538 + /* Support for internal mouse warping */
15539 + int FocusActive; /* Flag indicating that application has keyboard/mouse focus */
15540 + int WindowActive; /* Flag indicating that AROS Window in in active state */
15541 + int GrabMouse; /* Flag indicating that mouse shall be grabbed */
15542 + int CursorVisible; /* Flag indicating that cursor is visible */
15543 + int ExplicitFocusActivation; /* Flag indicating that focus should not be activated automatically when moving to inner area */
15544 + int LastMouseX;
15545 + int LastMouseY;
15547 + /* Double buffering handling */
15548 + int dbuffer; /* flag indicating that double buffering is in use */
15549 + struct ScreenBuffer *SB[2]; /* Double buffered screens */
15550 + struct MsgPort *safeport;
15551 + struct MsgPort *dispport;
15552 + ULONG safe_sigbit;
15553 + ULONG disp_sigbit;
15554 + struct BitMap *BlitBitMap; /* Used to fake double buffering in Window mode, also used in FullScreen if AllocScreenBuffer fails */
15556 + /* Temporary rastport used for HW bliting to non display surface */
15557 + struct RastPort *temprp;
15559 + /* Colormap handling */
15560 + Sint32 *Pens; /* A list of Pens that have been allocated, the size depends on the screen format */
15563 +/* Old variable names */
15564 +#define SDL_Display (this->hidden->Public_Display)
15565 +#define GFX_Display (this->hidden->GFX_Display)
15566 +#define SDL_Visual (this->hidden->vis)
15567 +#define SDL_Window (this->hidden->SDL_Window)
15568 +#define SDL_BlankCursor (this->hidden->BlankCursor)
15569 +#define SDL_Image (this->hidden->Image)
15570 +#define SDL_modelist (this->hidden->modelist)
15571 +#define SDL_RastPort (this->hidden->RP)
15572 +#define currently_fullscreen (this->hidden->currently_fullscreen)
15573 +#define SDL_DisplayColormap (this->hidden->GFX_Display->ViewPort.ColorMap)
15574 +#define SDL_Pens (this->hidden->Pens)
15575 +#define SDL_temprp (this->hidden->temprp)
15577 +extern struct Library *CyberGfxBase;
15578 +extern struct IntuitionBase *IntuitionBase;
15579 +extern struct GfxBase *GfxBase;
15580 +extern struct ExecBase *SysBase;
15581 +extern struct DosLibrary *DOSBase;
15583 +extern struct IOStdReq *SDL_ConReq;
15584 +extern struct MsgPort *SDL_ConPort;
15586 +/* Private data for HW surfaces */
15587 +struct private_hwdata
15589 + struct BitMap *bmap; // Pointer to HW surface bitmap
15590 + APTR lock; // Pointer to lock
15591 + struct SDL_VideoDevice *videodata; // Needed to keep track of window BorderLeft and BorderTop while bliting
15592 + APTR mask; // Mask used for ColorKey bliting
15593 + APTR pixarrayalpha; // Pixel array with alpha channel used for Alpha and ColorKey bliting
15594 + ULONG pixfmt; // pixfmt of the surface
15595 + BOOL allocated; // Set to 1 if the bitmap has been allocated (remains 0 for the display surface)
15596 + BOOL update; // Flag used to force pending display update due to locks on destination surface after unlocking
15599 +#endif /* _SDL_cgxvideo_h */
15601 diff -Naur SDL-1.2.15-orig/src/video/cgx/SDL_cgxwm.c SDL-1.2.15/src/video/cgx/SDL_cgxwm.c
15602 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxwm.c 1970-01-01 01:00:00.000000000 +0100
15603 +++ SDL-1.2.15/src/video/cgx/SDL_cgxwm.c 2015-05-09 15:09:59.769739506 +0200
15604 @@ -0,0 +1,111 @@
15606 + SDL - Simple DirectMedia Layer
15607 + Copyright (C) 1997-2006 Sam Lantinga
15609 + This library is free software; you can redistribute it and/or
15610 + modify it under the terms of the GNU Lesser General Public
15611 + License as published by the Free Software Foundation; either
15612 + version 2.1 of the License, or (at your option) any later version.
15614 + This library is distributed in the hope that it will be useful,
15615 + but WITHOUT ANY WARRANTY; without even the implied warranty of
15616 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15617 + Lesser General Public License for more details.
15619 + You should have received a copy of the GNU Lesser General Public
15620 + License along with this library; if not, write to the Free Software
15621 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15623 + Sam Lantinga
15624 + slouken@libsdl.org
15626 +#if defined (SDL_AROS_SHARED)
15627 +#define __NOLIBBASE__
15628 +#include <proto/SDL.h>
15629 +#endif
15631 +#include "SDL_config.h"
15633 +#include "SDL_version.h"
15634 +#include "SDL_video.h"
15635 +#include "SDL_syswm.h"
15636 +#include "SDL_mouse.h"
15637 +#include "../../events/SDL_events_c.h"
15638 +#include "SDL_cgxmodes_c.h"
15639 +#include "SDL_cgxwm_c.h"
15640 +#include "SDL_cgxmouse_c.h"
15642 +#if !defined(PROTO_SDL_H)
15643 +void CGX_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
15644 +#else
15645 +#include "SDL_intern.h"
15647 +void CGX_SetIconI(_THIS, SDL_Surface *icon, Uint8 *mask, struct SDLBase *SDLBase)
15648 +#endif
15650 + /* Not yet implemented */
15653 +#if !defined(PROTO_SDL_H)
15654 +int CGX_IconifyWindow(_THIS)
15655 +#else
15656 +int CGX_IconifyWindowI(_THIS, struct SDLBase *SDLBase)
15657 +#endif
15659 + /* Not yet implemented */
15660 + return 0;
15663 +#if !defined(PROTO_SDL_H)
15664 +void CGX_SetCaption(_THIS, const char *title, const char *icon)
15665 +#else
15666 +void CGX_SetCaptionI(_THIS, const char *title, const char *icon, struct SDLBase *SDLBase)
15667 +#endif
15669 + strncpy(this->hidden->WindowName, title, WINDOW_NAME_BUFFER_SIZE);
15670 + if(SDL_Window) SetWindowTitles(SDL_Window, this->hidden->WindowName, NULL);
15673 +#if !defined(PROTO_SDL_H)
15674 +int CGX_GetWMInfo(_THIS, SDL_SysWMinfo *info)
15675 +#else
15676 +int CGX_GetWMInfoI(_THIS, SDL_SysWMinfo *info, struct SDLBase *SDLBase)
15677 +#endif
15679 + if ( info->version.major <= SDL_MAJOR_VERSION )
15681 + return(1);
15683 + else
15685 + SDL_SetError("Application not compiled with SDL %d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
15686 + return(-1);
15690 +#if !defined(PROTO_SDL_H)
15691 +SDL_GrabMode CGX_GrabWMInput(_THIS, SDL_GrabMode mode)
15692 +#else
15693 +SDL_GrabMode CGX_GrabWMInputI(_THIS, SDL_GrabMode mode, struct SDLBase *SDLBase)
15694 +#endif
15696 + D(bug("CGX_GrabWMInput()\n"));
15698 + SDL_Lock_EventThread();
15700 + if ( this->screen == NULL ) return(SDL_GRAB_OFF);
15701 + if ( ! SDL_Window ) return(mode); /* Will be set later on mode switch */
15704 + if (mode == SDL_GRAB_OFF)
15705 + this->hidden->GrabMouse = 0;
15706 + else /* Match the X11 driver behaviour - this always grabs at full screen. Yes - condition makes no sense. */
15708 + this->hidden->GrabMouse = 1;
15709 + CGX_WarpWMCursor(this, this->screen->w / 2, this->screen->h / 2); /* Jump into window */
15712 + SDL_Unlock_EventThread();
15713 + return(mode);
15716 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
15717 --- SDL-1.2.15-orig/src/video/cgx/SDL_cgxwm_c.h 1970-01-01 01:00:00.000000000 +0100
15718 +++ SDL-1.2.15/src/video/cgx/SDL_cgxwm_c.h 2015-05-09 15:09:59.769739506 +0200
15719 @@ -0,0 +1,45 @@
15721 + SDL - Simple DirectMedia Layer
15722 + Copyright (C) 1997-2006 Sam Lantinga
15724 + This library is free software; you can redistribute it and/or
15725 + modify it under the terms of the GNU Lesser General Public
15726 + License as published by the Free Software Foundation; either
15727 + version 2.1 of the License, or (at your option) any later version.
15729 + This library is distributed in the hope that it will be useful,
15730 + but WITHOUT ANY WARRANTY; without even the implied warranty of
15731 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15732 + Lesser General Public License for more details.
15734 + You should have received a copy of the GNU Lesser General Public
15735 + License along with this library; if not, write to the Free Software
15736 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15738 + Sam Lantinga
15739 + slouken@libsdl.org
15741 +#include "SDL_config.h"
15743 +#include "SDL_cgxvideo.h"
15745 +/* Functions to be exported */
15746 +#if !defined(PROTO_SDL_H)
15747 +extern void CGX_SetCaption(_THIS, const char *title, const char *icon);
15748 +extern void CGX_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask);
15749 +extern int CGX_IconifyWindow(_THIS);
15750 +extern int CGX_GetWMInfo(_THIS, SDL_SysWMinfo *info);
15751 +extern SDL_GrabMode CGX_GrabWMInput(_THIS, SDL_GrabMode mode);
15752 +#else
15753 +extern void CGX_SetCaptionI(_THIS, const char *title, const char *icon, struct SDLBase *SDLBase);
15754 +extern void CGX_SetIconI(_THIS, SDL_Surface *icon, Uint8 *mask, struct SDLBase *SDLBase);
15755 +extern int CGX_IconifyWindowI(_THIS, struct SDLBase *SDLBase);
15756 +extern int CGX_GetWMInfoI(_THIS, SDL_SysWMinfo *info, struct SDLBase *SDLBase);
15757 +extern SDL_GrabMode CGX_GrabWMInputI(_THIS, SDL_GrabMode mode, struct SDLBase *SDLBase);
15759 +#define CGX_SetCaption(this, title, icon) CGX_SetCaptionI(this, title, icon, SDLBase)
15760 +#define CGX_SetIcon(this, icon, mask) CGX_SetIconI(this, icon, mask, SDLBase)
15761 +#define CGX_IconifyWindow(this) CGX_IconifyWindowI(this, SDLBase)
15762 +#define CGX_GetWMInfo(this, info) CGX_GetWMInfoI(this, info, SDLBase)
15763 +#define CGX_GrabWMInput(this, mode) CGX_GrabWMInputI(this, mode, SDLBase)
15764 +#endif
15765 diff -Naur SDL-1.2.15-orig/src/video/dummy/SDL_nullevents.c SDL-1.2.15/src/video/dummy/SDL_nullevents.c
15766 --- SDL-1.2.15-orig/src/video/dummy/SDL_nullevents.c 2015-05-09 17:47:54.283774294 +0200
15767 +++ SDL-1.2.15/src/video/dummy/SDL_nullevents.c 2015-05-09 15:09:59.769739506 +0200
15768 @@ -19,6 +19,11 @@
15769 Sam Lantinga
15770 slouken@libsdl.org
15772 +#if defined (SDL_AROS_SHARED)
15773 +#define __NOLIBBASE__
15774 +#include <proto/SDL.h>
15775 +#endif
15777 #include "SDL_config.h"
15779 /* Being a null driver, there's no event stream. We just define stubs for
15780 @@ -31,12 +36,20 @@
15781 #include "SDL_nullvideo.h"
15782 #include "SDL_nullevents_c.h"
15784 +#if !defined(PROTO_SDL_H)
15785 void DUMMY_PumpEvents(_THIS)
15786 +#else
15787 +void DUMMY_PumpEvents(_THIS, struct SDLBase *SDLBase)
15788 +#endif
15790 /* do nothing. */
15793 +#if !defined(PROTO_SDL_H)
15794 void DUMMY_InitOSKeymap(_THIS)
15795 +#else
15796 +void DUMMY_InitOSKeymap(_THIS, struct SDLBase *SDLBase)
15797 +#endif
15799 /* do nothing. */
15801 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
15802 --- SDL-1.2.15-orig/src/video/dummy/SDL_nullevents_c.h 2015-05-09 17:47:54.283774294 +0200
15803 +++ SDL-1.2.15/src/video/dummy/SDL_nullevents_c.h 2015-05-09 15:09:59.769739506 +0200
15804 @@ -26,8 +26,13 @@
15805 /* Variables and functions exported by SDL_sysevents.c to other parts
15806 of the native video subsystem (SDL_sysvideo.c)
15808 +#if !defined(PROTO_SDL_H)
15809 extern void DUMMY_InitOSKeymap(_THIS);
15810 extern void DUMMY_PumpEvents(_THIS);
15811 +#else
15812 +extern void DUMMY_InitOSKeymap(_THIS, struct SDLBase *SDLBase);
15813 +extern void DUMMY_PumpEvents(_THIS, struct SDLBase *SDLBase);
15814 +#endif
15816 /* end of SDL_nullevents_c.h ... */
15818 diff -Naur SDL-1.2.15-orig/src/video/dummy/SDL_nullmouse.c SDL-1.2.15/src/video/dummy/SDL_nullmouse.c
15819 --- SDL-1.2.15-orig/src/video/dummy/SDL_nullmouse.c 2015-05-09 17:47:54.283774294 +0200
15820 +++ SDL-1.2.15/src/video/dummy/SDL_nullmouse.c 2015-05-09 15:09:59.770739504 +0200
15821 @@ -19,6 +19,11 @@
15822 Sam Lantinga
15823 slouken@libsdl.org
15825 +#if defined (SDL_AROS_SHARED)
15826 +#define __NOLIBBASE__
15827 +#include <proto/SDL.h>
15828 +#endif
15830 #include "SDL_config.h"
15832 #include "SDL_mouse.h"
15833 diff -Naur SDL-1.2.15-orig/src/video/dummy/SDL_nullvideo.c SDL-1.2.15/src/video/dummy/SDL_nullvideo.c
15834 --- SDL-1.2.15-orig/src/video/dummy/SDL_nullvideo.c 2015-05-09 17:47:54.283774294 +0200
15835 +++ SDL-1.2.15/src/video/dummy/SDL_nullvideo.c 2015-05-09 15:09:59.770739504 +0200
15836 @@ -19,6 +19,11 @@
15837 Sam Lantinga
15838 slouken@libsdl.org
15840 +#if defined (SDL_AROS_SHARED)
15841 +#define __NOLIBBASE__
15842 +#include <proto/SDL.h>
15843 +#endif
15845 #include "SDL_config.h"
15847 /* Dummy SDL video driver implementation; this is just enough to make an
15848 @@ -48,6 +53,7 @@
15850 #define DUMMYVID_DRIVER_NAME "dummy"
15852 +#if !defined(PROTO_SDL_H)
15853 /* Initialization/Query functions */
15854 static int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat);
15855 static SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
15856 @@ -63,10 +69,27 @@
15858 /* etc. */
15859 static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
15860 +#else
15861 +#include "SDL_intern.h"
15863 +static int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat, struct SDLBase *SDLBase);
15864 +static SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags, struct SDLBase *SDLBase);
15865 +static SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags, struct SDLBase *SDLBase);
15866 +static int DUMMY_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors, struct SDLBase *SDLBase);
15867 +static void DUMMY_VideoQuit(_THIS, struct SDLBase *SDLBase);
15868 +static int DUMMY_AllocHWSurface(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
15869 +static int DUMMY_LockHWSurface(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
15870 +static void DUMMY_UnlockHWSurface(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
15871 +static void DUMMY_FreeHWSurface(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
15872 +static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects, struct SDLBase *SDLBase);
15873 +#endif
15874 /* DUMMY driver bootstrap functions */
15876 +#if !defined(PROTO_SDL_H)
15877 static int DUMMY_Available(void)
15878 +#else
15879 +static int DUMMY_Available(struct SDLBase *SDLBase)
15880 +#endif
15882 const char *envr = SDL_getenv("SDL_VIDEODRIVER");
15883 if ((envr) && (SDL_strcmp(envr, DUMMYVID_DRIVER_NAME) == 0)) {
15884 @@ -76,13 +99,21 @@
15885 return(0);
15888 +#if !defined(PROTO_SDL_H)
15889 static void DUMMY_DeleteDevice(SDL_VideoDevice *device)
15890 +#else
15891 +static void DUMMY_DeleteDevice(SDL_VideoDevice *device, struct SDLBase *SDLBase)
15892 +#endif
15894 SDL_free(device->hidden);
15895 SDL_free(device);
15898 +#if !defined(PROTO_SDL_H)
15899 static SDL_VideoDevice *DUMMY_CreateDevice(int devindex)
15900 +#else
15901 +static SDL_VideoDevice *DUMMY_CreateDevice(int devindex, struct SDLBase *SDLBase)
15902 +#endif
15904 SDL_VideoDevice *device;
15906 @@ -137,8 +168,11 @@
15907 DUMMY_Available, DUMMY_CreateDevice
15911 +#if !defined(PROTO_SDL_H)
15912 int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat)
15913 +#else
15914 +int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat, struct SDLBase *SDLBase)
15915 +#endif
15918 fprintf(stderr, "WARNING: You are using the SDL dummy video driver!\n");
15919 @@ -153,13 +187,21 @@
15920 return(0);
15923 +#if !defined(PROTO_SDL_H)
15924 SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
15925 +#else
15926 +SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags, struct SDLBase *SDLBase)
15927 +#endif
15929 return (SDL_Rect **) -1;
15932 +#if !defined(PROTO_SDL_H)
15933 SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current,
15934 int width, int height, int bpp, Uint32 flags)
15935 +#else
15936 +SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags, struct SDLBase *SDLBase)
15937 +#endif
15939 if ( this->hidden->buffer ) {
15940 SDL_free( this->hidden->buffer );
15941 @@ -195,32 +237,56 @@
15944 /* We don't actually allow hardware surfaces other than the main one */
15945 +#if !defined(PROTO_SDL_H)
15946 static int DUMMY_AllocHWSurface(_THIS, SDL_Surface *surface)
15947 +#else
15948 +static int DUMMY_AllocHWSurface(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
15949 +#endif
15951 return(-1);
15953 +#if !defined(PROTO_SDL_H)
15954 static void DUMMY_FreeHWSurface(_THIS, SDL_Surface *surface)
15955 +#else
15956 +static void DUMMY_FreeHWSurface(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
15957 +#endif
15959 return;
15962 /* We need to wait for vertical retrace on page flipped displays */
15963 +#if !defined(PROTO_SDL_H)
15964 static int DUMMY_LockHWSurface(_THIS, SDL_Surface *surface)
15965 +#else
15966 +static int DUMMY_LockHWSurface(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
15967 +#endif
15969 return(0);
15972 +#if !defined(PROTO_SDL_H)
15973 static void DUMMY_UnlockHWSurface(_THIS, SDL_Surface *surface)
15974 +#else
15975 +static void DUMMY_UnlockHWSurface(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase)
15976 +#endif
15978 return;
15981 +#if !defined(PROTO_SDL_H)
15982 static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
15983 +#else
15984 +static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects, struct SDLBase *SDLBase)
15985 +#endif
15987 /* do nothing. */
15990 +#if !defined(PROTO_SDL_H)
15991 int DUMMY_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
15992 +#else
15993 +int DUMMY_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors, struct SDLBase *SDLBase)
15994 +#endif
15996 /* do nothing of note. */
15997 return(1);
15998 @@ -229,7 +295,11 @@
15999 /* Note: If we are terminated, this could be called in the middle of
16000 another SDL video routine -- notably UpdateRects.
16002 +#if !defined(PROTO_SDL_H)
16003 void DUMMY_VideoQuit(_THIS)
16004 +#else
16005 +void DUMMY_VideoQuit(_THIS, struct SDLBase *SDLBase)
16006 +#endif
16008 if (this->screen->pixels != NULL)
16010 diff -Naur SDL-1.2.15-orig/src/video/SDL_blit_0.c SDL-1.2.15/src/video/SDL_blit_0.c
16011 --- SDL-1.2.15-orig/src/video/SDL_blit_0.c 2015-05-09 17:47:54.310774223 +0200
16012 +++ SDL-1.2.15/src/video/SDL_blit_0.c 2015-05-09 15:09:59.770739504 +0200
16013 @@ -19,6 +19,11 @@
16014 Sam Lantinga
16015 slouken@libsdl.org
16017 +#if defined (SDL_AROS_SHARED)
16018 +#define __NOLIBBASE__
16019 +#include <proto/SDL.h>
16020 +#endif
16022 #include "SDL_config.h"
16024 #include "SDL_video.h"
16025 @@ -440,7 +445,11 @@
16026 NULL, BlitBto1Key, BlitBto2Key, BlitBto3Key, BlitBto4Key
16029 +#if !defined(PROTO_SDL_H)
16030 SDL_loblit SDL_CalculateBlit0(SDL_Surface *surface, int blit_index)
16031 +#else
16032 +SDL_loblit SDL_CalculateBlit0I(SDL_Surface *surface, int blit_index, struct SDLBase *SDLBase)
16033 +#endif
16035 int which;
16037 diff -Naur SDL-1.2.15-orig/src/video/SDL_blit_1.c SDL-1.2.15/src/video/SDL_blit_1.c
16038 --- SDL-1.2.15-orig/src/video/SDL_blit_1.c 2015-05-09 17:47:54.309774226 +0200
16039 +++ SDL-1.2.15/src/video/SDL_blit_1.c 2015-05-09 15:09:59.770739504 +0200
16040 @@ -19,6 +19,11 @@
16041 Sam Lantinga
16042 slouken@libsdl.org
16044 +#if defined (SDL_AROS_SHARED)
16045 +#define __NOLIBBASE__
16046 +#include <proto/SDL.h>
16047 +#endif
16049 #include "SDL_config.h"
16051 #include "SDL_video.h"
16052 @@ -491,7 +496,11 @@
16053 NULL, Blit1to1Key, Blit1to2Key, Blit1to3Key, Blit1to4Key
16056 +#if !defined(PROTO_SDL_H)
16057 SDL_loblit SDL_CalculateBlit1(SDL_Surface *surface, int blit_index)
16058 +#else
16059 +SDL_loblit SDL_CalculateBlit1I(SDL_Surface *surface, int blit_index, struct SDLBase *SDLBase)
16060 +#endif
16062 int which;
16063 SDL_PixelFormat *dstfmt;
16064 diff -Naur SDL-1.2.15-orig/src/video/SDL_blit_A.c SDL-1.2.15/src/video/SDL_blit_A.c
16065 --- SDL-1.2.15-orig/src/video/SDL_blit_A.c 2015-05-09 17:47:54.282774297 +0200
16066 +++ SDL-1.2.15/src/video/SDL_blit_A.c 2015-05-09 15:09:59.770739504 +0200
16067 @@ -19,6 +19,11 @@
16068 Sam Lantinga
16069 slouken@libsdl.org
16071 +#if defined (SDL_AROS_SHARED)
16072 +#define __NOLIBBASE__
16073 +#include <proto/SDL.h>
16074 +#endif
16076 #include "SDL_config.h"
16078 #include "SDL_video.h"
16079 @@ -2719,8 +2724,11 @@
16084 +#if !defined(PROTO_SDL_H)
16085 SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
16086 +#else
16087 +SDL_loblit SDL_CalculateAlphaBlitI(SDL_Surface *surface, int blit_index, struct SDLBase *SDLBase)
16088 +#endif
16090 SDL_PixelFormat *sf = surface->format;
16091 SDL_PixelFormat *df = surface->map->dst->format;
16092 diff -Naur SDL-1.2.15-orig/src/video/SDL_blit.c SDL-1.2.15/src/video/SDL_blit.c
16093 --- SDL-1.2.15-orig/src/video/SDL_blit.c 2015-05-09 17:47:54.282774297 +0200
16094 +++ SDL-1.2.15/src/video/SDL_blit.c 2015-05-09 15:09:59.771739502 +0200
16095 @@ -19,6 +19,11 @@
16096 Sam Lantinga
16097 slouken@libsdl.org
16099 +#if defined (SDL_AROS_SHARED)
16100 +#define __NOLIBBASE__
16101 +#include <proto/SDL.h>
16102 +#endif
16104 #include "SDL_config.h"
16106 #include "SDL_video.h"
16107 @@ -39,6 +44,12 @@
16108 #include "mmx.h"
16109 #endif
16111 +#if defined(PROTO_SDL_H)
16112 +#include "SDL_intern.h"
16114 +#define current_video SDLBase->current_video
16115 +#endif
16117 /* The general purpose software blit routine */
16118 static int SDL_SoftBlit(SDL_Surface *src, SDL_Rect *srcrect,
16119 SDL_Surface *dst, SDL_Rect *dstrect)
16120 @@ -47,6 +58,9 @@
16121 int src_locked;
16122 int dst_locked;
16124 +#if defined(PROTO_SDL_H)
16125 + struct Library __unused *SDLBase = src->SDLLib;
16126 +#endif
16127 /* Everything is okay at the beginning... */
16128 okay = 1;
16130 @@ -75,6 +89,10 @@
16131 SDL_loblit RunBlit;
16133 /* Set up the blit information */
16135 +#if defined(PROTO_SDL_H)
16136 + info.SDLLib = SDLBase;
16137 +#endif
16138 info.s_pixels = (Uint8 *)src->pixels +
16139 (Uint16)srcrect->y*src->pitch +
16140 (Uint16)srcrect->x*src->format->BytesPerPixel;
16141 @@ -158,6 +176,10 @@
16142 int w, h;
16143 int srcskip, dstskip;
16145 +#if defined(PROTO_SDL_H)
16146 + struct Library __unused *SDLBase = info->SDLLib;
16147 +#endif
16149 w = info->d_width*info->dst->BytesPerPixel;
16150 h = info->d_height;
16151 src = info->s_pixels;
16152 @@ -206,6 +228,10 @@
16153 int w, h;
16154 int srcskip, dstskip;
16156 +#if defined(PROTO_SDL_H)
16157 + struct Library __unused *SDLBase = info->SDLLib;
16158 +#endif
16160 w = info->d_width*info->dst->BytesPerPixel;
16161 h = info->d_height;
16162 src = info->s_pixels;
16163 @@ -230,7 +256,11 @@
16166 /* Figure out which of many blit routines to set up on a surface */
16167 +#if !defined(PROTO_SDL_H)
16168 int SDL_CalculateBlit(SDL_Surface *surface)
16169 +#else
16170 +int SDL_CalculateBlitI(SDL_Surface *surface, struct SDLBase *SDLBase)
16171 +#endif
16173 int blit_index;
16175 @@ -275,7 +305,11 @@
16176 if ( hw_blit_ok ) {
16177 SDL_VideoDevice *video = current_video;
16178 SDL_VideoDevice *this = current_video;
16179 +#if !defined(PROTO_SDL_H)
16180 video->CheckHWBlit(this, surface, surface->map->dst);
16181 +#else
16182 + video->CheckHWBlit(this, surface, surface->map->dst, SDLBase);
16183 +#endif
16187 @@ -286,7 +320,11 @@
16188 if ( current_video->info.blit_hw_A ) {
16189 SDL_VideoDevice *video = current_video;
16190 SDL_VideoDevice *this = current_video;
16191 +#if !defined(PROTO_SDL_H)
16192 video->CheckHWBlit(this, surface, surface->map->dst);
16193 +#else
16194 + video->CheckHWBlit(this, surface, surface->map->dst, SDLBase);
16195 +#endif
16199 diff -Naur SDL-1.2.15-orig/src/video/SDL_blit.h SDL-1.2.15/src/video/SDL_blit.h
16200 --- SDL-1.2.15-orig/src/video/SDL_blit.h 2015-05-09 17:47:54.281774300 +0200
16201 +++ SDL-1.2.15/src/video/SDL_blit.h 2015-05-09 15:09:59.771739502 +0200
16202 @@ -40,6 +40,9 @@
16203 SDL_PixelFormat *src;
16204 Uint8 *table;
16205 SDL_PixelFormat *dst;
16206 +#if defined(__AROS__)
16207 + struct Library *SDLLib;
16208 +#endif
16209 } SDL_BlitInfo;
16211 /* The type definition for the low level blit functions */
16212 @@ -67,14 +70,28 @@
16213 } SDL_BlitMap;
16216 +#if !defined(PROTO_SDL_H)
16217 /* Functions found in SDL_blit.c */
16218 extern int SDL_CalculateBlit(SDL_Surface *surface);
16220 /* Functions found in SDL_blit_{0,1,N,A}.c */
16221 extern SDL_loblit SDL_CalculateBlit0(SDL_Surface *surface, int complex);
16222 extern SDL_loblit SDL_CalculateBlit1(SDL_Surface *surface, int complex);
16223 extern SDL_loblit SDL_CalculateBlitN(SDL_Surface *surface, int complex);
16224 extern SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int complex);
16225 +#else
16226 +#include "SDL_intern.h"
16228 +extern int SDL_CalculateBlitI(SDL_Surface *surface, struct SDLBase *SDLBase);
16229 +extern SDL_loblit SDL_CalculateBlit0I(SDL_Surface *surface, int complex, struct SDLBase *SDLBase);
16230 +extern SDL_loblit SDL_CalculateBlit1I(SDL_Surface *surface, int complex, struct SDLBase *SDLBase);
16231 +extern SDL_loblit SDL_CalculateBlitNI(SDL_Surface *surface, int complex, struct SDLBase *SDLBase);
16232 +extern SDL_loblit SDL_CalculateAlphaBlitI(SDL_Surface *surface, int complex, struct SDLBase *SDLBase);
16233 +#define SDL_CalculateBlit(surface) SDL_CalculateBlitI(surface, SDLBase)
16234 +#define SDL_CalculateBlit0(surface, complex) SDL_CalculateBlit0I(surface, complex, SDLBase)
16235 +#define SDL_CalculateBlit1(surface, complex) SDL_CalculateBlit1I(surface, complex, SDLBase)
16236 +#define SDL_CalculateBlitN(surface, complex) SDL_CalculateBlitNI(surface, complex, SDLBase)
16237 +#define SDL_CalculateAlphaBlit(surface, complex) SDL_CalculateAlphaBlitI(surface, complex, SDLBase)
16238 +#endif
16241 * Useful macros for blitting routines
16242 diff -Naur SDL-1.2.15-orig/src/video/SDL_blit_N.c SDL-1.2.15/src/video/SDL_blit_N.c
16243 --- SDL-1.2.15-orig/src/video/SDL_blit_N.c 2015-05-09 17:47:54.284774292 +0200
16244 +++ SDL-1.2.15/src/video/SDL_blit_N.c 2015-05-09 15:09:59.771739502 +0200
16245 @@ -19,6 +19,11 @@
16246 Sam Lantinga
16247 slouken@libsdl.org
16249 +#if defined (SDL_AROS_SHARED)
16250 +#define __NOLIBBASE__
16251 +#include <proto/SDL.h>
16252 +#endif
16254 #include "SDL_config.h"
16256 #include "SDL_video.h"
16257 @@ -2371,7 +2376,11 @@
16258 /* Mask matches table, or table entry is zero */
16259 #define MASKOK(x, y) (((x) == (y)) || ((y) == 0x00000000))
16261 +#if !defined(PROTO_SDL_H)
16262 SDL_loblit SDL_CalculateBlitN(SDL_Surface *surface, int blit_index)
16263 +#else
16264 +SDL_loblit SDL_CalculateBlitNI(SDL_Surface *surface, int blit_index, struct SDLBase *SDLBase)
16265 +#endif
16267 struct private_swaccel *sdata;
16268 SDL_PixelFormat *srcfmt;
16269 diff -Naur SDL-1.2.15-orig/src/video/SDL_bmp.c SDL-1.2.15/src/video/SDL_bmp.c
16270 --- SDL-1.2.15-orig/src/video/SDL_bmp.c 2015-05-09 17:47:54.282774297 +0200
16271 +++ SDL-1.2.15/src/video/SDL_bmp.c 2015-05-09 15:09:59.772739500 +0200
16272 @@ -19,6 +19,11 @@
16273 Sam Lantinga
16274 slouken@libsdl.org
16276 +#if defined (SDL_AROS_SHARED)
16277 +#define __NOLIBBASE__
16278 +#include <proto/SDL.h>
16279 +#endif
16281 #include "SDL_config.h"
16284 @@ -44,9 +49,19 @@
16285 #define BI_BITFIELDS 3
16286 #endif
16288 +struct SDLBase;
16290 +#if !defined(PROTO_SDL_H)
16291 SDL_Surface * SDL_LoadBMP_RW (SDL_RWops *src, int freesrc)
16293 +#else
16294 +AROS_LH2(SDL_Surface *, SDL_LoadBMP_RW,
16295 + AROS_LHA(SDL_RWops *, src, A0),
16296 + AROS_LHA(int, freesrc, D0),
16297 + struct SDLBase *, SDLBase, 22, SDL)
16299 + AROS_LIBFUNC_INIT
16300 +#endif
16301 SDL_bool was_error;
16302 long fp_offset = 0;
16303 int bmpPitch;
16304 @@ -355,10 +370,23 @@
16305 SDL_RWclose(src);
16307 return(surface);
16308 +#if defined(PROTO_SDL_H)
16309 + AROS_LIBFUNC_EXIT
16310 +#endif
16313 +#if !defined(PROTO_SDL_H)
16314 int SDL_SaveBMP_RW (SDL_Surface *saveme, SDL_RWops *dst, int freedst)
16316 +#else
16317 +AROS_LH3(int, SDL_SaveBMP_RW,
16318 + AROS_LHA(SDL_Surface *, saveme, A0),
16319 + AROS_LHA(SDL_RWops *, dst, A1),
16320 + AROS_LHA(int, freedst, D0),
16321 + struct SDLBase *, SDLBase, 52, SDL)
16323 + AROS_LIBFUNC_INIT
16324 +#endif
16325 long fp_offset;
16326 int i, pad;
16327 SDL_Surface *surface;
16328 @@ -546,4 +574,7 @@
16329 SDL_RWclose(dst);
16331 return((SDL_strcmp(SDL_GetError(), "") == 0) ? 0 : -1);
16332 +#if defined(PROTO_SDL_H)
16333 + AROS_LIBFUNC_EXIT
16334 +#endif
16336 diff -Naur SDL-1.2.15-orig/src/video/SDL_cursor.c SDL-1.2.15/src/video/SDL_cursor.c
16337 --- SDL-1.2.15-orig/src/video/SDL_cursor.c 2015-05-09 17:47:54.309774226 +0200
16338 +++ SDL-1.2.15/src/video/SDL_cursor.c 2015-05-09 15:09:59.772739500 +0200
16339 @@ -19,6 +19,11 @@
16340 Sam Lantinga
16341 slouken@libsdl.org
16343 +#if defined (SDL_AROS_SHARED)
16344 +#define __NOLIBBASE__
16345 +#include <proto/SDL.h>
16346 +#endif
16348 #include "SDL_config.h"
16350 /* General cursor handling code for SDL */
16351 @@ -35,13 +40,30 @@
16352 #include "../events/SDL_events_c.h"
16354 /* These are static for our cursor handling code */
16355 +#if !defined(PROTO_SDL_H)
16356 volatile int SDL_cursorstate = CURSOR_VISIBLE;
16357 SDL_Cursor *SDL_cursor = NULL;
16358 static SDL_Cursor *SDL_defcursor = NULL;
16359 SDL_mutex *SDL_cursorlock = NULL;
16360 +#else
16361 +#include "SDL_intern.h"
16363 +#define SDL_cursorstate SDLBase->SDL_cursorstate
16364 +#define SDL_cursor SDLBase->SDL_cursor
16365 +#define SDL_defcursor SDLBase->SDL_defcursor
16366 +#define SDL_cursorlock SDLBase->SDL_cursorlock
16367 +#define palette_changed SDLBase->palette_changed
16368 +#define pixels8 SDLBase->pixels8
16370 +#define current_video SDLBase->current_video
16371 +#endif
16373 /* Public functions */
16374 +#if !defined(PROTO_SDL_H)
16375 void SDL_CursorQuit(void)
16376 +#else
16377 +void SDL_CursorQuitI(struct SDLBase *SDLBase)
16378 +#endif
16380 if ( SDL_cursor != NULL ) {
16381 SDL_Cursor *cursor;
16382 @@ -62,7 +84,11 @@
16383 SDL_cursorlock = NULL;
16386 +#if !defined(PROTO_SDL_H)
16387 int SDL_CursorInit(Uint32 multithreaded)
16388 +#else
16389 +int SDL_CursorInitI(Uint32 multithreaded, struct SDLBase *SDLBase)
16390 +#endif
16392 /* We don't have mouse focus, and the cursor isn't drawn yet */
16393 #ifndef IPOD
16394 @@ -105,9 +131,22 @@
16395 #endif
16397 /* Software cursor drawing support */
16398 +#if !defined(PROTO_SDL_H)
16399 SDL_Cursor * SDL_CreateCursor (Uint8 *data, Uint8 *mask,
16400 int w, int h, int hot_x, int hot_y)
16402 +#else
16403 +AROS_LH6(SDL_Cursor *, SDL_CreateCursor,
16404 + AROS_LHA(Uint8 *, data, A0),
16405 + AROS_LHA(Uint8 *, mask, A1),
16406 + AROS_LHA(int, w, D0),
16407 + AROS_LHA(int, h, D1),
16408 + AROS_LHA(int, hot_x, D2),
16409 + AROS_LHA(int, hot_y, D3),
16410 + struct SDLBase *, SDLBase, 116, SDL)
16412 + AROS_LIBFUNC_INIT
16413 +#endif
16414 SDL_VideoDevice *video = current_video;
16415 int savelen;
16416 int i;
16417 @@ -153,20 +192,36 @@
16419 /* If the window manager gives us a good cursor, we're done! */
16420 if ( video->CreateWMCursor ) {
16421 +#if !defined(PROTO_SDL_H)
16422 cursor->wm_cursor = video->CreateWMCursor(video, data, mask,
16423 w, h, hot_x, hot_y);
16424 +#else
16425 + cursor->wm_cursor = video->CreateWMCursor(video, data, mask,
16426 + w, h, hot_x, hot_y, SDLBase);
16427 +#endif
16428 } else {
16429 cursor->wm_cursor = NULL;
16431 return(cursor);
16432 +#if defined(PROTO_SDL_H)
16433 + AROS_LIBFUNC_EXIT
16434 +#endif
16437 /* SDL_SetCursor(NULL) can be used to force the cursor redraw,
16438 if this is desired for any reason. This is used when setting
16439 the video mode and when the SDL window gains the mouse focus.
16441 +#if !defined(PROTO_SDL_H)
16442 void SDL_SetCursor (SDL_Cursor *cursor)
16444 +#else
16445 +AROS_LH1(void, SDL_SetCursor,
16446 + AROS_LHA(SDL_Cursor *, cursor, A0),
16447 + struct SDLBase *, SDLBase, 117, SDL)
16449 + AROS_LIBFUNC_INIT
16450 +#endif
16451 SDL_VideoDevice *video = current_video;
16452 SDL_VideoDevice *this = current_video;
16454 @@ -189,7 +244,11 @@
16455 showing the new one. (But don't erase NULL cursor)
16457 if ( SDL_cursor && video->ShowWMCursor ) {
16458 +#if !defined(PROTO_SDL_H)
16459 video->ShowWMCursor(this, NULL);
16460 +#else
16461 + video->ShowWMCursor(this, NULL, SDLBase);
16462 +#endif
16465 SDL_cursor = cursor;
16466 @@ -200,14 +259,22 @@
16467 /* Use window manager cursor if possible */
16468 int show_wm_cursor = 0;
16469 if ( SDL_cursor->wm_cursor && video->ShowWMCursor ) {
16470 +#if !defined(PROTO_SDL_H)
16471 show_wm_cursor = video->ShowWMCursor(this, SDL_cursor->wm_cursor);
16472 +#else
16473 + show_wm_cursor = video->ShowWMCursor(this, SDL_cursor->wm_cursor, SDLBase);
16474 +#endif
16476 if ( show_wm_cursor ) {
16477 SDL_cursorstate &= ~CURSOR_USINGSW;
16478 } else {
16479 SDL_cursorstate |= CURSOR_USINGSW;
16480 if ( video->ShowWMCursor ) {
16481 +#if !defined(PROTO_SDL_H)
16482 video->ShowWMCursor(this, NULL);
16483 +#else
16484 + video->ShowWMCursor(this, NULL, SDLBase);
16485 +#endif
16487 { int x, y;
16488 SDL_GetMouseState(&x, &y);
16489 @@ -223,21 +290,46 @@
16490 } else {
16491 if ( video ) {
16492 if ( video->ShowWMCursor ) {
16493 +#if !defined(PROTO_SDL_H)
16494 video->ShowWMCursor(this, NULL);
16495 +#else
16496 + video->ShowWMCursor(this, NULL, SDLBase);
16497 +#endif
16502 SDL_UnlockCursor();
16503 +#if defined(PROTO_SDL_H)
16504 + AROS_LIBFUNC_EXIT
16505 +#endif
16508 +#if !defined(PROTO_SDL_H)
16509 SDL_Cursor * SDL_GetCursor (void)
16511 +#else
16512 +AROS_LH0(SDL_Cursor *, SDL_GetCursor,
16513 + struct SDLBase *, SDLBase, 118, SDL)
16515 + AROS_LIBFUNC_INIT
16516 +#endif
16517 return(SDL_cursor);
16518 +#if defined(PROTO_SDL_H)
16519 + AROS_LIBFUNC_EXIT
16520 +#endif
16523 +#if !defined(PROTO_SDL_H)
16524 void SDL_FreeCursor (SDL_Cursor *cursor)
16526 +#else
16527 +AROS_LH1(void, SDL_FreeCursor,
16528 + AROS_LHA(SDL_Cursor *, cursor, A0),
16529 + struct SDLBase *, SDLBase, 119, SDL)
16531 + AROS_LIBFUNC_INIT
16532 +#endif
16533 if ( cursor ) {
16534 if ( cursor == SDL_cursor ) {
16535 SDL_SetCursor(SDL_defcursor);
16536 @@ -254,16 +346,31 @@
16538 if ( video && cursor->wm_cursor ) {
16539 if ( video->FreeWMCursor ) {
16540 +#if !defined(PROTO_SDL_H)
16541 video->FreeWMCursor(this, cursor->wm_cursor);
16542 +#else
16543 + video->FreeWMCursor(this, cursor->wm_cursor, SDLBase);
16544 +#endif
16547 SDL_free(cursor);
16550 +#if defined(PROTO_SDL_H)
16551 + AROS_LIBFUNC_EXIT
16552 +#endif
16555 +#if !defined(PROTO_SDL_H)
16556 int SDL_ShowCursor (int toggle)
16558 +#else
16559 +AROS_LH1(int, SDL_ShowCursor,
16560 + AROS_LHA(int, toggle, D0),
16561 + struct SDLBase *, SDLBase, 120, SDL)
16563 + AROS_LIBFUNC_INIT
16564 +#endif
16565 int showing;
16567 showing = (SDL_cursorstate & CURSOR_VISIBLE);
16568 @@ -281,17 +388,33 @@
16570 SDL_SetCursor(NULL);
16571 if ( video && video->CheckMouseMode ) {
16572 +#if !defined(PROTO_SDL_H)
16573 video->CheckMouseMode(this);
16574 +#else
16575 + video->CheckMouseMode(this, SDLBase);
16576 +#endif
16579 } else {
16580 /* Query current state */ ;
16582 return(showing ? 1 : 0);
16583 +#if defined(PROTO_SDL_H)
16584 + AROS_LIBFUNC_EXIT
16585 +#endif
16588 +#if !defined(PROTO_SDL_H)
16589 void SDL_WarpMouse (Uint16 x, Uint16 y)
16591 +#else
16592 +AROS_LH2(void, SDL_WarpMouse,
16593 + AROS_LHA(Uint16, x, D0),
16594 + AROS_LHA(Uint16, y, D1),
16595 + struct SDLBase *, SDLBase, 115, SDL)
16597 + AROS_LIBFUNC_INIT
16598 +#endif
16599 SDL_VideoDevice *video = current_video;
16600 SDL_VideoDevice *this = current_video;
16602 @@ -312,13 +435,24 @@
16604 /* This generates a mouse motion event */
16605 if ( video->WarpWMCursor ) {
16606 +#if !defined(PROTO_SDL_H)
16607 video->WarpWMCursor(this, x, y);
16608 +#else
16609 + video->WarpWMCursor(this, x, y, SDLBase);
16610 +#endif
16611 } else {
16612 SDL_PrivateMouseMotion(0, 0, x, y);
16614 +#if defined(PROTO_SDL_H)
16615 + AROS_LIBFUNC_EXIT
16616 +#endif
16619 +#if !defined(PROTO_SDL_H)
16620 void SDL_MoveCursor(int x, int y)
16621 +#else
16622 +void SDL_MoveCursorI(int x, int y, struct SDLBase *SDLBase)
16623 +#endif
16625 SDL_VideoDevice *video = current_video;
16627 @@ -332,20 +466,32 @@
16628 SDL_DrawCursor(SDL_VideoSurface);
16629 SDL_UnlockCursor();
16630 } else if ( video->MoveWMCursor ) {
16631 +#if !defined(PROTO_SDL_H)
16632 video->MoveWMCursor(video, x, y);
16633 +#else
16634 + video->MoveWMCursor(video, x, y, SDLBase);
16635 +#endif
16639 +#if !defined(PROTO_SDL_H)
16640 /* Keep track of the current cursor colors */
16641 static int palette_changed = 1;
16642 static Uint8 pixels8[2];
16644 void SDL_CursorPaletteChanged(void)
16645 +#else
16646 +void SDL_CursorPaletteChangedI(struct SDLBase *SDLBase)
16647 +#endif
16649 palette_changed = 1;
16652 +#if !defined(PROTO_SDL_H)
16653 void SDL_MouseRect(SDL_Rect *area)
16654 +#else
16655 +void SDL_MouseRectI(SDL_Rect *area, struct SDLBase *SDLBase)
16656 +#endif
16658 int clip_diff;
16660 @@ -368,7 +514,12 @@
16664 +#if !defined(PROTO_SDL_H)
16665 static void SDL_DrawCursorFast(SDL_Surface *screen, SDL_Rect *area)
16666 +#else
16667 +#define SDL_DrawCursorFast(screen, area) SDL_DrawCursorFastI(screen, area, SDLBase)
16668 +static void SDL_DrawCursorFastI(SDL_Surface *screen, SDL_Rect *area, struct SDLBase *SDLBase)
16669 +#endif
16671 const Uint32 pixels[2] = { 0xFFFFFFFF, 0x00000000 };
16672 int i, w, h;
16673 @@ -494,7 +645,12 @@
16677 +#if !defined(PROTO_SDL_H)
16678 static void SDL_DrawCursorSlow(SDL_Surface *screen, SDL_Rect *area)
16679 +#else
16680 +#define SDL_DrawCursorSlow(screen, area) SDL_DrawCursorSlowI(screen, area, SDLBase)
16681 +static void SDL_DrawCursorSlowI(SDL_Surface *screen, SDL_Rect *area, struct SDLBase *SDLBase)
16682 +#endif
16684 const Uint32 pixels[2] = { 0xFFFFFF, 0x000000 };
16685 int h;
16686 @@ -563,7 +719,12 @@
16687 This is only necessary when blitting from a shadow surface of a different
16688 pixel format than the video surface, and using a software rendered cursor.
16690 +#if !defined(PROTO_SDL_H)
16691 static void SDL_ConvertCursorSave(SDL_Surface *screen, int w, int h)
16692 +#else
16693 +#define SDL_ConvertCursorSave(screen, w, h) SDL_ConvertCursorSaveI(screen, w, h, SDLBase)
16694 +static void SDL_ConvertCursorSaveI(SDL_Surface *screen, int w, int h, struct SDLBase *SDLBase)
16695 +#endif
16697 SDL_BlitInfo info;
16698 SDL_loblit RunBlit;
16699 @@ -592,7 +753,11 @@
16700 RunBlit(&info);
16703 +#if !defined(PROTO_SDL_H)
16704 void SDL_DrawCursorNoLock(SDL_Surface *screen)
16705 +#else
16706 +void SDL_DrawCursorNoLockI(SDL_Surface *screen, struct SDLBase *SDLBase)
16707 +#endif
16709 SDL_Rect area;
16711 @@ -637,7 +802,11 @@
16715 +#if !defined(PROTO_SDL_H)
16716 void SDL_DrawCursor(SDL_Surface *screen)
16717 +#else
16718 +void SDL_DrawCursorI(SDL_Surface *screen, struct SDLBase *SDLBase)
16719 +#endif
16721 /* Lock the screen if necessary */
16722 if ( screen == NULL ) {
16723 @@ -665,12 +834,20 @@
16725 /* This can be called before a video mode is set */
16726 if ( video->UpdateRects ) {
16727 +#if !defined(PROTO_SDL_H)
16728 video->UpdateRects(this, 1, &area);
16729 +#else
16730 + video->UpdateRects(this, 1, &area, SDLBase);
16731 +#endif
16736 +#if !defined(PROTO_SDL_H)
16737 void SDL_EraseCursorNoLock(SDL_Surface *screen)
16738 +#else
16739 +void SDL_EraseCursorNoLockI(SDL_Surface *screen, struct SDLBase *SDLBase)
16740 +#endif
16742 SDL_Rect area;
16744 @@ -711,7 +888,11 @@
16748 +#if !defined(PROTO_SDL_H)
16749 void SDL_EraseCursor(SDL_Surface *screen)
16750 +#else
16751 +void SDL_EraseCursorI(SDL_Surface *screen, struct SDLBase *SDLBase)
16752 +#endif
16754 /* Lock the screen if necessary */
16755 if ( screen == NULL ) {
16756 @@ -737,7 +918,11 @@
16758 SDL_MouseRect(&area);
16759 if ( video->UpdateRects ) {
16760 +#if !defined(PROTO_SDL_H)
16761 video->UpdateRects(this, 1, &area);
16762 +#else
16763 + video->UpdateRects(this, 1, &area, SDLBase);
16764 +#endif
16768 @@ -745,7 +930,11 @@
16769 /* Reset the cursor on video mode change
16770 FIXME: Keep track of all cursors, and reset them all.
16772 +#if !defined(PROTO_SDL_H)
16773 void SDL_ResetCursor(void)
16774 +#else
16775 +void SDL_ResetCursorI(struct SDLBase *SDLBase)
16776 +#endif
16778 int savelen;
16780 diff -Naur SDL-1.2.15-orig/src/video/SDL_cursor_c.h SDL-1.2.15/src/video/SDL_cursor_c.h
16781 --- SDL-1.2.15-orig/src/video/SDL_cursor_c.h 2015-05-09 17:47:54.283774294 +0200
16782 +++ SDL-1.2.15/src/video/SDL_cursor_c.h 2015-05-09 15:09:59.772739500 +0200
16783 @@ -24,6 +24,7 @@
16784 /* Useful variables and functions from SDL_cursor.c */
16785 #include "SDL_mouse.h"
16787 +#if !defined(PROTO_SDL_H)
16788 extern int SDL_CursorInit(Uint32 flags);
16789 extern void SDL_CursorPaletteChanged(void);
16790 extern void SDL_DrawCursor(SDL_Surface *screen);
16791 @@ -34,13 +35,42 @@
16792 extern void SDL_ResetCursor(void);
16793 extern void SDL_MoveCursor(int x, int y);
16794 extern void SDL_CursorQuit(void);
16795 +#else
16796 +#include "SDL_intern.h"
16798 +extern int SDL_CursorInitI(Uint32 flags, struct SDLBase *SDLBase);
16799 +extern void SDL_CursorPaletteChangedI(struct SDLBase *SDLBase);
16800 +extern void SDL_DrawCursorI(SDL_Surface *screen, struct SDLBase *SDLBase);
16801 +extern void SDL_DrawCursorNoLockI(SDL_Surface *screen, struct SDLBase *SDLBase);
16802 +extern void SDL_EraseCursorI(SDL_Surface *screen, struct SDLBase *SDLBase);
16803 +extern void SDL_EraseCursorNoLockI(SDL_Surface *screen, struct SDLBase *SDLBase);
16804 +extern void SDL_UpdateCursorI(SDL_Surface *screen, struct SDLBase *SDLBase);
16805 +extern void SDL_ResetCursorI(struct SDLBase *SDLBase);
16806 +extern void SDL_MoveCursorI(int x, int y, struct SDLBase *SDLBase);
16807 +extern void SDL_CursorQuitI(struct SDLBase *SDLBase);
16809 +#define SDL_CursorInit(flags) SDL_CursorInitI(flags, SDLBase)
16810 +#define SDL_CursorPaletteChanged() SDL_CursorPaletteChangedI(SDLBase)
16811 +#define SDL_DrawCursor(screen) SDL_DrawCursorI(screen, SDLBase)
16812 +#define SDL_DrawCursorNoLock(screen) SDL_DrawCursorNoLockI(screen, SDLBase)
16813 +#define SDL_EraseCursor(screen) SDL_EraseCursorI(screen, SDLBase)
16814 +#define SDL_EraseCursorNoLock(screen) SDL_EraseCursorNoLockI(screen, SDLBase)
16815 +#define SDL_UpdateCursor(screen) SDL_UpdateCursorI(screen, SDLBase)
16816 +#define SDL_ResetCursor() SDL_ResetCursorI(SDLBase)
16817 +#define SDL_MoveCursor(x, y) SDL_MoveCursorI(x, y, SDLBase)
16818 +#define SDL_CursorQuit() SDL_CursorQuitI(SDLBase)
16819 +#endif
16821 #define INLINE_MOUSELOCK
16822 #ifdef INLINE_MOUSELOCK
16823 /* Inline (macro) versions of the mouse lock functions */
16824 #include "SDL_mutex.h"
16826 +#if !defined(PROTO_SDL_H)
16827 extern SDL_mutex *SDL_cursorlock;
16828 +#else
16829 +#define SDL_cursorlock SDLBase->SDL_cursorlock
16830 +#endif
16832 #define SDL_LockCursor() \
16833 do { \
16834 @@ -59,15 +89,22 @@
16835 extern void SDL_UnlockCursor(void);
16836 #endif /* INLINE_MOUSELOCK */
16838 +#if !defined(PROTO_SDL_H)
16839 /* Only for low-level mouse cursor drawing */
16840 extern SDL_Cursor *SDL_cursor;
16841 extern void SDL_MouseRect(SDL_Rect *area);
16842 +extern volatile int SDL_cursorstate;
16844 -/* State definitions for the SDL cursor */
16845 #define CURSOR_VISIBLE 0x01
16846 +#else
16847 +extern void SDL_MouseRectI(SDL_Rect *area, struct SDLBase *SDLBase);
16848 +#define SDL_MouseRect(area) SDL_MouseRectI(area, SDLBase)
16849 +#define SDL_cursorstate SDLBase->SDL_cursorstate
16850 +#endif
16852 +/* State definitions for the SDL cursor */
16853 #define CURSOR_USINGSW 0x10
16854 #define SHOULD_DRAWCURSOR(X) \
16855 (((X)&(CURSOR_VISIBLE|CURSOR_USINGSW)) == \
16856 (CURSOR_VISIBLE|CURSOR_USINGSW))
16858 -extern volatile int SDL_cursorstate;
16859 diff -Naur SDL-1.2.15-orig/src/video/SDL_gamma.c SDL-1.2.15/src/video/SDL_gamma.c
16860 --- SDL-1.2.15-orig/src/video/SDL_gamma.c 2015-05-09 17:47:54.309774226 +0200
16861 +++ SDL-1.2.15/src/video/SDL_gamma.c 2015-05-09 15:09:59.772739500 +0200
16862 @@ -19,6 +19,11 @@
16863 Sam Lantinga
16864 slouken@libsdl.org
16866 +#if defined (SDL_AROS_SHARED)
16867 +#define __NOLIBBASE__
16868 +#include <proto/SDL.h>
16869 +#endif
16871 #include "SDL_config.h"
16873 /* Gamma correction support */
16874 @@ -37,6 +42,11 @@
16876 #include "SDL_sysvideo.h"
16878 +#if defined(PROTO_SDL_H)
16879 +#include "SDL_intern.h"
16881 +#define current_video SDLBase->current_video
16882 +#endif
16884 static void CalculateGammaRamp(float gamma, Uint16 *ramp)
16886 @@ -90,8 +100,18 @@
16890 +#if !defined(PROTO_SDL_H)
16891 int SDL_SetGamma(float red, float green, float blue)
16893 +#else
16894 +AROS_LH3(int, SDL_SetGamma,
16895 + AROS_LHA(float, red, D0),
16896 + AROS_LHA(float, green, D1),
16897 + AROS_LHA(float, blue, D2),
16898 + struct SDLBase *, SDLBase, 41, SDL)
16900 + AROS_LIBFUNC_INIT
16901 +#endif
16902 int succeeded;
16903 SDL_VideoDevice *video = current_video;
16904 SDL_VideoDevice *this = current_video;
16905 @@ -108,15 +128,26 @@
16907 if ( (succeeded < 0) && video->SetGamma ) {
16908 SDL_ClearError();
16909 +#if !defined(PROTO_SDL_H)
16910 succeeded = video->SetGamma(this, red, green, blue);
16911 +#else
16912 + succeeded = video->SetGamma(this, red, green, blue, SDLBase);
16913 +#endif
16915 return succeeded;
16916 +#if defined(PROTO_SDL_H)
16917 + AROS_LIBFUNC_EXIT
16918 +#endif
16921 /* Calculating the gamma by integrating the gamma ramps isn't exact,
16922 so this function isn't officially supported.
16924 +#if !defined(PROTO_SDL_H)
16925 int SDL_GetGamma(float *red, float *green, float *blue)
16926 +#else
16927 +int SDL_GetGamma(float *red, float *green, float *blue, struct SDLBase *SDLBase)
16928 +#endif
16930 int succeeded;
16931 SDL_VideoDevice *video = current_video;
16932 @@ -136,13 +167,27 @@
16934 if ( (succeeded < 0) && video->GetGamma ) {
16935 SDL_ClearError();
16936 +#if !defined(PROTO_SDL_H)
16937 succeeded = video->GetGamma(this, red, green, blue);
16938 +#else
16939 + succeeded = video->GetGamma(this, red, green, blue, SDLBase);
16940 +#endif
16942 return succeeded;
16945 +#if !defined(PROTO_SDL_H)
16946 int SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue)
16948 +#else
16949 +AROS_LH3(int, SDL_SetGammaRamp,
16950 + AROS_LHA(const Uint16 *, red, A0),
16951 + AROS_LHA(const Uint16 *, green, A0),
16952 + AROS_LHA(const Uint16 *, blue, A0),
16953 + struct SDLBase *, SDLBase, 42, SDL)
16955 + AROS_LIBFUNC_INIT
16956 +#endif
16957 int succeeded;
16958 SDL_VideoDevice *video = current_video;
16959 SDL_VideoDevice *this = current_video;
16960 @@ -186,15 +231,32 @@
16961 /* Try to set the gamma ramp in the driver */
16962 succeeded = -1;
16963 if ( video->SetGammaRamp ) {
16964 +#if !defined(PROTO_SDL_H)
16965 succeeded = video->SetGammaRamp(this, video->gamma);
16966 +#else
16967 + succeeded = video->SetGammaRamp(this, video->gamma, SDLBase);
16968 +#endif
16969 } else {
16970 SDL_SetError("Gamma ramp manipulation not supported");
16972 return succeeded;
16973 +#if defined(PROTO_SDL_H)
16974 + AROS_LIBFUNC_EXIT
16975 +#endif
16978 +#if !defined(PROTO_SDL_H)
16979 int SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue)
16981 +#else
16982 +AROS_LH3(int, SDL_GetGammaRamp,
16983 + AROS_LHA(Uint16 *, red, A0),
16984 + AROS_LHA(Uint16 *, green, A0),
16985 + AROS_LHA(Uint16 *, blue, A0),
16986 + struct SDLBase *, SDLBase, 43, SDL)
16988 + AROS_LIBFUNC_INIT
16989 +#endif
16990 SDL_VideoDevice *video = current_video;
16991 SDL_VideoDevice *this = current_video;
16993 @@ -207,7 +269,11 @@
16995 if ( video->GetGammaRamp ) {
16996 /* Get the real hardware gamma */
16997 +#if !defined(PROTO_SDL_H)
16998 video->GetGammaRamp(this, video->gamma);
16999 +#else
17000 + video->GetGammaRamp(this, video->gamma, SDLBase);
17001 +#endif
17002 } else {
17003 /* Assume an identity gamma */
17004 int i;
17005 @@ -230,4 +296,7 @@
17006 SDL_memcpy(blue, &video->gamma[2*256], 256*sizeof(*blue));
17008 return 0;
17009 +#if defined(PROTO_SDL_H)
17010 + AROS_LIBFUNC_EXIT
17011 +#endif
17013 diff -Naur SDL-1.2.15-orig/src/video/SDL_pixels.c SDL-1.2.15/src/video/SDL_pixels.c
17014 --- SDL-1.2.15-orig/src/video/SDL_pixels.c 2015-05-09 17:47:54.281774300 +0200
17015 +++ SDL-1.2.15/src/video/SDL_pixels.c 2015-05-09 15:09:59.773739499 +0200
17016 @@ -19,6 +19,11 @@
17017 Sam Lantinga
17018 slouken@libsdl.org
17020 +#if defined (SDL_AROS_SHARED)
17021 +#define __NOLIBBASE__
17022 +#include <proto/SDL.h>
17023 +#endif
17025 #include "SDL_config.h"
17027 /* General (mostly internal) pixel/color manipulation routines for SDL */
17028 @@ -34,8 +39,13 @@
17030 * Allocate a pixel format structure and fill it according to the given info.
17032 +#if !defined(PROTO_SDL_H)
17033 SDL_PixelFormat *SDL_AllocFormat(int bpp,
17034 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
17035 +#else
17036 +SDL_PixelFormat *SDL_AllocFormatI(int bpp,
17037 + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask, struct SDLBase *SDLBase)
17038 +#endif
17040 SDL_PixelFormat *format;
17041 Uint32 mask;
17042 @@ -221,8 +231,13 @@
17044 return(format);
17046 +#if !defined(PROTO_SDL_H)
17047 SDL_PixelFormat *SDL_ReallocFormat(SDL_Surface *surface, int bpp,
17048 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
17049 +#else
17050 +SDL_PixelFormat *SDL_ReallocFormatI(SDL_Surface *surface, int bpp,
17051 + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask, struct SDLBase *SDLBase)
17052 +#endif
17054 if ( surface->format ) {
17055 SDL_FreeFormat(surface->format);
17056 @@ -337,10 +352,21 @@
17059 /* Find the opaque pixel value corresponding to an RGB triple */
17060 +#if !defined(PROTO_SDL_H)
17061 Uint32 SDL_MapRGB
17062 (const SDL_PixelFormat * const format,
17063 const Uint8 r, const Uint8 g, const Uint8 b)
17065 +#else
17066 +AROS_LH4(Uint32, SDL_MapRGB,
17067 + AROS_LHA(const SDL_PixelFormat * const, format, A0),
17068 + AROS_LHA(const Uint8, r, D0),
17069 + AROS_LHA(const Uint8, g, D1),
17070 + AROS_LHA(const Uint8, b, D2),
17071 + struct SDLBase *, SDLBase, 32, SDL)
17073 + AROS_LIBFUNC_INIT
17074 +#endif
17075 if ( format->palette == NULL ) {
17076 return (r >> format->Rloss) << format->Rshift
17077 | (g >> format->Gloss) << format->Gshift
17078 @@ -349,13 +375,28 @@
17079 } else {
17080 return SDL_FindColor(format->palette, r, g, b);
17082 +#if defined(PROTO_SDL_H)
17083 + AROS_LIBFUNC_EXIT
17084 +#endif
17087 /* Find the pixel value corresponding to an RGBA quadruple */
17088 +#if !defined(PROTO_SDL_H)
17089 Uint32 SDL_MapRGBA
17090 (const SDL_PixelFormat * const format,
17091 const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a)
17093 +#else
17094 +AROS_LH5(Uint32, SDL_MapRGBA,
17095 + AROS_LHA(const SDL_PixelFormat * const, format, A0),
17096 + AROS_LHA(const Uint8, r, D0),
17097 + AROS_LHA(const Uint8, g, D1),
17098 + AROS_LHA(const Uint8, b, D2),
17099 + AROS_LHA(const Uint8, a, D3),
17100 + struct SDLBase *, SDLBase, 33, SDL)
17102 + AROS_LIBFUNC_INIT
17103 +#endif
17104 if ( format->palette == NULL ) {
17105 return (r >> format->Rloss) << format->Rshift
17106 | (g >> format->Gloss) << format->Gshift
17107 @@ -364,11 +405,27 @@
17108 } else {
17109 return SDL_FindColor(format->palette, r, g, b);
17111 +#if defined(PROTO_SDL_H)
17112 + AROS_LIBFUNC_EXIT
17113 +#endif
17116 +#if !defined(PROTO_SDL_H)
17117 void SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat * const fmt,
17118 Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
17120 +#else
17121 +AROS_LH6(void, SDL_GetRGBA,
17122 + AROS_LHA(Uint32, pixel, D0),
17123 + AROS_LHA(const SDL_PixelFormat * const, fmt, A0),
17124 + AROS_LHA(Uint8 *, r, A1),
17125 + AROS_LHA(Uint8 *, g, A2),
17126 + AROS_LHA(Uint8 *, b, A3),
17127 + AROS_LHA(Uint8 *, a, A4),
17128 + struct SDLBase *, SDLBase, 47, SDL)
17130 + AROS_LIBFUNC_INIT
17131 +#endif
17132 if ( fmt->palette == NULL ) {
17134 * This makes sure that the result is mapped to the
17135 @@ -398,11 +455,26 @@
17136 *b = fmt->palette->colors[pixel].b;
17137 *a = SDL_ALPHA_OPAQUE;
17139 +#if defined(PROTO_SDL_H)
17140 + AROS_LIBFUNC_EXIT
17141 +#endif
17144 +#if !defined(PROTO_SDL_H)
17145 void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat * const fmt,
17146 Uint8 *r,Uint8 *g,Uint8 *b)
17148 +#else
17149 +AROS_LH5(void, SDL_GetRGB,
17150 + AROS_LHA(Uint32, pixel, D0),
17151 + AROS_LHA(const SDL_PixelFormat * const, fmt, A0),
17152 + AROS_LHA(Uint8 *, r, A1),
17153 + AROS_LHA(Uint8 *, g, A2),
17154 + AROS_LHA(Uint8 *, b, A3),
17155 + struct SDLBase *, SDLBase, 46, SDL)
17157 + AROS_LIBFUNC_INIT
17158 +#endif
17159 if ( fmt->palette == NULL ) {
17160 /* the note for SDL_GetRGBA above applies here too */
17161 unsigned v;
17162 @@ -417,6 +489,9 @@
17163 *g = fmt->palette->colors[pixel].g;
17164 *b = fmt->palette->colors[pixel].b;
17166 +#if defined(PROTO_SDL_H)
17167 + AROS_LIBFUNC_EXIT
17168 +#endif
17171 /* Apply gamma to a set of colors - this is easy. :) */
17172 @@ -433,7 +508,12 @@
17175 /* Map from Palette to Palette */
17176 +#if !defined(PROTO_SDL_H)
17177 static Uint8 *Map1to1(SDL_Palette *src, SDL_Palette *dst, int *identical)
17178 +#else
17179 +#define Map1to1(src, dst, identical) Map1to1I(src, dst, identical, SDLBase)
17180 +static Uint8 *Map1to1I(SDL_Palette *src, SDL_Palette *dst, int *identical, struct SDLBase *SDLBase)
17181 +#endif
17183 Uint8 *map;
17184 int i;
17185 @@ -461,7 +541,12 @@
17186 return(map);
17188 /* Map from Palette to BitField */
17189 +#if !defined(PROTO_SDL_H)
17190 static Uint8 *Map1toN(SDL_PixelFormat *src, SDL_PixelFormat *dst)
17191 +#else
17192 +#define Map1toN(src, dst) Map1toNI(src, dst, SDLBase)
17193 +static Uint8 *Map1toNI(SDL_PixelFormat *src, SDL_PixelFormat *dst, struct SDLBase *SDLBase)
17194 +#endif
17196 Uint8 *map;
17197 int i;
17198 @@ -486,7 +571,12 @@
17199 return(map);
17201 /* Map from BitField to Dithered-Palette to Palette */
17202 +#if !defined(PROTO_SDL_H)
17203 static Uint8 *MapNto1(SDL_PixelFormat *src, SDL_PixelFormat *dst, int *identical)
17204 +#else
17205 +#define MapNto1(src, dst, identical) MapNto1I(src, dst, identical, SDLBase)
17206 +static Uint8 *MapNto1I(SDL_PixelFormat *src, SDL_PixelFormat *dst, int *identical, struct SDLBase *SDLBase)
17207 +#endif
17209 /* Generate a 256 color dither palette */
17210 SDL_Palette dithered;
17211 @@ -503,7 +593,11 @@
17212 return(Map1to1(&dithered, pal, identical));
17215 +#if !defined(PROTO_SDL_H)
17216 SDL_BlitMap *SDL_AllocBlitMap(void)
17217 +#else
17218 +SDL_BlitMap *SDL_AllocBlitMapI(struct SDLBase *SDLBase)
17219 +#endif
17221 SDL_BlitMap *map;
17223 @@ -539,7 +633,11 @@
17224 map->table = NULL;
17227 +#if !defined(PROTO_SDL_H)
17228 int SDL_MapSurface (SDL_Surface *src, SDL_Surface *dst)
17229 +#else
17230 +int SDL_MapSurfaceI(SDL_Surface *src, SDL_Surface *dst, struct SDLBase *SDLBase)
17231 +#endif
17233 SDL_PixelFormat *srcfmt;
17234 SDL_PixelFormat *dstfmt;
17235 diff -Naur SDL-1.2.15-orig/src/video/SDL_pixels_c.h SDL-1.2.15/src/video/SDL_pixels_c.h
17236 --- SDL-1.2.15-orig/src/video/SDL_pixels_c.h 2015-05-09 17:47:54.310774223 +0200
17237 +++ SDL-1.2.15/src/video/SDL_pixels_c.h 2015-05-09 15:09:59.773739499 +0200
17238 @@ -25,18 +25,30 @@
17240 #include "SDL_blit.h"
17242 -/* Pixel format functions */
17243 +#if !defined(PROTO_SDL_H)
17244 extern SDL_PixelFormat *SDL_AllocFormat(int bpp,
17245 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
17246 extern SDL_PixelFormat *SDL_ReallocFormat(SDL_Surface *surface, int bpp,
17247 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
17248 +extern SDL_BlitMap *SDL_AllocBlitMap(void);
17249 +extern int SDL_MapSurface (SDL_Surface *src, SDL_Surface *dst);
17250 +#else
17251 +extern SDL_PixelFormat *SDL_AllocFormatI(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask, struct SDLBase *SDLBase);
17252 +extern SDL_PixelFormat *SDL_ReallocFormatI(SDL_Surface *surface, int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask, struct SDLBase *SDLBase);
17253 +extern SDL_BlitMap *SDL_AllocBlitMapI(struct SDLBase *SDLBase);
17254 +extern int SDL_MapSurfaceI(SDL_Surface *src, SDL_Surface *dst, struct SDLBase *SDLBase);
17256 +#define SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask) SDL_AllocFormatI(bpp, Rmask, Gmask, Bmask, Amask, SDLBase)
17257 +#define SDL_ReallocFormat(surface, bpp, Rmask, Gmask, Bmask, Amask) SDL_ReallocFormatI(surface, bpp, Rmask, Gmask, Bmask, Amask, SDLBase)
17258 +#define SDL_AllocBlitMap() SDL_AllocBlitMapI(SDLBase)
17259 +#define SDL_MapSurface(src, dst) SDL_MapSurfaceI(src, dst, SDLBase)
17260 +#endif
17261 +/* Pixel format functions */
17262 extern void SDL_FormatChanged(SDL_Surface *surface);
17263 extern void SDL_FreeFormat(SDL_PixelFormat *format);
17265 /* Blit mapping functions */
17266 -extern SDL_BlitMap *SDL_AllocBlitMap(void);
17267 extern void SDL_InvalidateMap(SDL_BlitMap *map);
17268 -extern int SDL_MapSurface (SDL_Surface *src, SDL_Surface *dst);
17269 extern void SDL_FreeBlitMap(SDL_BlitMap *map);
17271 /* Miscellaneous functions */
17272 diff -Naur SDL-1.2.15-orig/src/video/SDL_RLEaccel.c SDL-1.2.15/src/video/SDL_RLEaccel.c
17273 --- SDL-1.2.15-orig/src/video/SDL_RLEaccel.c 2015-05-09 17:47:54.282774297 +0200
17274 +++ SDL-1.2.15/src/video/SDL_RLEaccel.c 2015-05-09 15:09:59.773739499 +0200
17275 @@ -19,6 +19,11 @@
17276 Sam Lantinga
17277 slouken@libsdl.org
17279 +#if defined (SDL_AROS_SHARED)
17280 +#define __NOLIBBASE__
17281 +#include <proto/SDL.h>
17282 +#endif
17284 #include "SDL_config.h"
17287 @@ -101,6 +106,10 @@
17288 #include "SDL_cpuinfo.h"
17289 #endif
17291 +#if defined(PROTO_SDL_H)
17292 +#include "SDL_intern.h"
17293 +#endif
17295 #ifndef MAX
17296 #define MAX(a, b) ((a) > (b) ? (a) : (b))
17297 #endif
17298 @@ -837,6 +846,7 @@
17301 /* blit a colorkeyed RLE surface */
17303 int SDL_RLEBlit(SDL_Surface *src, SDL_Rect *srcrect,
17304 SDL_Surface *dst, SDL_Rect *dstrect)
17306 @@ -846,6 +856,10 @@
17307 int w = src->w;
17308 unsigned alpha;
17310 +#if defined(PROTO_SDL_H)
17311 + struct Library __unused *SDLBase = src->SDLLib;
17312 +#endif
17314 /* Lock the destination if necessary */
17315 if ( SDL_MUSTLOCK(dst) ) {
17316 if ( SDL_LockSurface(dst) < 0 ) {
17317 @@ -1015,6 +1029,10 @@
17318 static void RLEAlphaClipBlit(int w, Uint8 *srcbuf, SDL_Surface *dst,
17319 Uint8 *dstbuf, SDL_Rect *srcrect)
17321 +#if defined(PROTO_SDL_H)
17322 + struct Library __unused *SDLBase = dst->SDLLib;
17323 +#endif
17325 SDL_PixelFormat *df = dst->format;
17327 * clipped blitter: Ptype is the destination pixel type,
17328 @@ -1112,6 +1130,10 @@
17329 Uint8 *srcbuf, *dstbuf;
17330 SDL_PixelFormat *df = dst->format;
17332 +#if defined(PROTO_SDL_H)
17333 + struct Library __unused *SDLBase = src->SDLLib;
17334 +#endif
17336 /* Lock the destination if necessary */
17337 if ( SDL_MUSTLOCK(dst) ) {
17338 if ( SDL_LockSurface(dst) < 0 ) {
17339 @@ -1397,7 +1419,12 @@
17340 ((unsigned)((((pixel) & fmt->Amask) >> fmt->Ashift) - 1U) < 254U)
17342 /* convert surface to be quickly alpha-blittable onto dest, if possible */
17343 +#if !defined(PROTO_SDL_H)
17344 static int RLEAlphaSurface(SDL_Surface *surface)
17345 +#else
17346 +#define RLEAlphaSurface(surface) RLEAlphaSurfaceI(surface, SDLBase)
17347 +static int RLEAlphaSurfaceI(SDL_Surface *surface, struct SDLBase *SDLBase)
17348 +#endif
17350 SDL_Surface *dest;
17351 SDL_PixelFormat *df;
17352 @@ -1640,7 +1667,12 @@
17353 getpix_8, getpix_16, getpix_24, getpix_32
17356 +#if !defined(PROTO_SDL_H)
17357 static int RLEColorkeySurface(SDL_Surface *surface)
17358 +#else
17359 +#define RLEColorkeySurface(surface) RLEColorkeySurfaceI(surface, SDLBase)
17360 +static int RLEColorkeySurfaceI(SDL_Surface *surface, struct SDLBase *SDLBase)
17361 +#endif
17363 Uint8 *rlebuf, *dst;
17364 int maxn;
17365 @@ -1768,7 +1800,12 @@
17366 return(0);
17369 +#if !defined(PROTO_SDL_H)
17370 int SDL_RLESurface(SDL_Surface *surface)
17371 +#else
17372 +#define SDL_RLESurface(surface) SDL_RLESurfaceI(surface, SDLBase)
17373 +int SDL_RLESurfaceI(SDL_Surface *surface, struct SDLBase *SDLBase)
17374 +#endif
17376 int retcode;
17378 @@ -1892,7 +1929,12 @@
17379 return(SDL_TRUE);
17382 +#if !defined(PROTO_SDL_H)
17383 void SDL_UnRLESurface(SDL_Surface *surface, int recode)
17384 +#else
17385 +#define SDL_UnRLESurface(surface, recode) SDL_UnRLESurfaceI(surface, recode, SDLBase)
17386 +void SDL_UnRLESurfaceI(SDL_Surface *surface, int recode, struct SDLBase *SDLBase)
17387 +#endif
17389 if ( (surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL ) {
17390 surface->flags &= ~SDL_RLEACCEL;
17391 diff -Naur SDL-1.2.15-orig/src/video/SDL_RLEaccel_c.h SDL-1.2.15/src/video/SDL_RLEaccel_c.h
17392 --- SDL-1.2.15-orig/src/video/SDL_RLEaccel_c.h 2015-05-09 17:47:54.309774226 +0200
17393 +++ SDL-1.2.15/src/video/SDL_RLEaccel_c.h 2015-05-09 15:09:59.773739499 +0200
17394 @@ -23,9 +23,20 @@
17396 /* Useful functions and variables from SDL_RLEaccel.c */
17398 -extern int SDL_RLESurface(SDL_Surface *surface);
17399 extern int SDL_RLEBlit(SDL_Surface *src, SDL_Rect *srcrect,
17400 SDL_Surface *dst, SDL_Rect *dstrect);
17401 extern int SDL_RLEAlphaBlit(SDL_Surface *src, SDL_Rect *srcrect,
17402 SDL_Surface *dst, SDL_Rect *dstrect);
17404 +#if !defined (SDL_AROS_SHARED)
17405 +extern int SDL_RLESurface(SDL_Surface *surface);
17406 extern void SDL_UnRLESurface(SDL_Surface *surface, int recode);
17407 +#else
17408 +#include "SDL_intern.h"
17410 +extern int SDL_RLESurfaceI(SDL_Surface *surface, struct SDLBase *SDLBase);
17411 +extern void SDL_UnRLESurfaceI(SDL_Surface *surface, int recode, struct SDLBase *SDLBase);
17413 +#define SDL_RLESurface(surface) SDL_RLESurfaceI(surface, SDLBase)
17414 +#define SDL_UnRLESurface(surface, recode) SDL_UnRLESurfaceI(surface, recode, SDLBase)
17415 +#endif
17416 \ No newline at end of file
17417 diff -Naur SDL-1.2.15-orig/src/video/SDL_stretch.c SDL-1.2.15/src/video/SDL_stretch.c
17418 --- SDL-1.2.15-orig/src/video/SDL_stretch.c 2015-05-09 17:47:54.309774226 +0200
17419 +++ SDL-1.2.15/src/video/SDL_stretch.c 2015-05-09 15:09:59.773739499 +0200
17420 @@ -19,6 +19,11 @@
17421 Sam Lantinga
17422 slouken@libsdl.org
17424 +#if defined (SDL_AROS_SHARED)
17425 +#define __NOLIBBASE__
17426 +#include <proto/SDL.h>
17427 +#endif
17429 #include "SDL_config.h"
17431 /* This a stretch blit implementation based on ideas given to me by
17432 @@ -65,7 +70,13 @@
17433 #error Need assembly opcodes for this architecture
17434 #endif
17436 +#if !defined(PROTO_SDL_H)
17437 static unsigned char copy_row[4096] PAGE_ALIGNED;
17438 +#else
17439 +#include "SDL_intern.h"
17440 +#define copy_row SDLBase->copy_row
17441 +#endif
17444 static int generate_rowbytes(int src_w, int dst_w, int bpp)
17446 @@ -199,9 +210,20 @@
17447 /* Perform a stretch blit between two surfaces of the same format.
17448 NOTE: This function is not safe to call from multiple threads!
17450 +#if !defined(PROTO_SDL_H)
17451 int SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect,
17452 SDL_Surface *dst, SDL_Rect *dstrect)
17454 +#else
17455 +AROS_LH4(int, SDL_SoftStretch,
17456 + AROS_LHA(SDL_Surface *, src, A0),
17457 + AROS_LHA(SDL_Rect *, srcrect, A1),
17458 + AROS_LHA(SDL_Surface *, dst, A2),
17459 + AROS_LHA(SDL_Rect *, dstrect, A3),
17460 + struct SDLBase *, SDLBase, 145, SDL)
17462 + AROS_LIBFUNC_INIT
17463 +#endif
17464 int src_locked;
17465 int dst_locked;
17466 int pos, inc;
17467 @@ -354,5 +376,8 @@
17468 SDL_UnlockSurface(src);
17470 return(0);
17471 +#if defined(PROTO_SDL_H)
17472 + AROS_LIBFUNC_EXIT
17473 +#endif
17476 diff -Naur SDL-1.2.15-orig/src/video/SDL_stretch_c.h SDL-1.2.15/src/video/SDL_stretch_c.h
17477 --- SDL-1.2.15-orig/src/video/SDL_stretch_c.h 2015-05-09 17:47:54.282774297 +0200
17478 +++ SDL-1.2.15/src/video/SDL_stretch_c.h 2015-05-09 15:09:59.774739497 +0200
17479 @@ -24,6 +24,7 @@
17480 /* Perform a stretch blit between two surfaces of the same format.
17481 NOTE: This function is not safe to call from multiple threads!
17483 +#if !defined(PROTO_SDL_H)
17484 extern int SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect,
17485 SDL_Surface *dst, SDL_Rect *dstrect);
17487 +#endif
17488 diff -Naur SDL-1.2.15-orig/src/video/SDL_surface.c SDL-1.2.15/src/video/SDL_surface.c
17489 --- SDL-1.2.15-orig/src/video/SDL_surface.c 2015-05-09 17:47:54.282774297 +0200
17490 +++ SDL-1.2.15/src/video/SDL_surface.c 2015-05-09 15:09:59.774739497 +0200
17491 @@ -19,6 +19,11 @@
17492 Sam Lantinga
17493 slouken@libsdl.org
17495 +#if defined (SDL_AROS_SHARED)
17496 +#define __NOLIBBASE__
17497 +#include <proto/SDL.h>
17498 +#endif
17500 #include "SDL_config.h"
17502 #include "SDL_video.h"
17503 @@ -34,10 +39,29 @@
17505 * Create an empty RGB surface of the appropriate depth
17507 +#if !defined(PROTO_SDL_H)
17508 SDL_Surface * SDL_CreateRGBSurface (Uint32 flags,
17509 int width, int height, int depth,
17510 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
17512 +#else
17513 +#include "SDL_intern.h"
17515 +#define current_video SDLBase->current_video
17517 +AROS_LH8(SDL_Surface *, SDL_CreateRGBSurface,
17518 + AROS_LHA(Uint32, flags, D0),
17519 + AROS_LHA(int, width, D1),
17520 + AROS_LHA(int, height, D2),
17521 + AROS_LHA(int, depth, D3),
17522 + AROS_LHA(Uint32, Rmask, D4),
17523 + AROS_LHA(Uint32, Gmask, D5),
17524 + AROS_LHA(Uint32, Bmask, D6),
17525 + AROS_LHA(Uint32, Amask, D7),
17526 + struct SDLBase *, SDLBase, 48, SDL)
17528 + AROS_LIBFUNC_INIT
17529 +#endif
17530 SDL_VideoDevice *video = current_video;
17531 SDL_VideoDevice *this = current_video;
17532 SDL_Surface *screen;
17533 @@ -80,6 +104,9 @@
17534 SDL_OutOfMemory();
17535 return(NULL);
17537 +#if defined(PROTO_SDL_H)
17538 + surface->SDLLib = (struct Library *)SDLBase;
17539 +#endif
17540 surface->flags = SDL_SWSURFACE;
17541 if ( (flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
17542 if ((Amask) && (video->displayformatalphapixel))
17543 @@ -121,7 +148,11 @@
17545 /* Get the pixels */
17546 if ( ((flags&SDL_HWSURFACE) == SDL_SWSURFACE) ||
17547 +#if !defined(PROTO_SDL_H)
17548 (video->AllocHWSurface(this, surface) < 0) ) {
17549 +#else
17550 + (video->AllocHWSurface(this, surface, SDLBase) < 0) ) {
17551 +#endif
17552 if ( surface->w && surface->h ) {
17553 surface->pixels = SDL_malloc(surface->h*surface->pitch);
17554 if ( surface->pixels == NULL ) {
17555 @@ -147,14 +178,33 @@
17556 ++surfaces_allocated;
17557 #endif
17558 return(surface);
17559 +#if defined(PROTO_SDL_H)
17560 + AROS_LIBFUNC_EXIT
17561 +#endif
17564 * Create an RGB surface from an existing memory buffer
17566 +#if !defined(PROTO_SDL_H)
17567 SDL_Surface * SDL_CreateRGBSurfaceFrom (void *pixels,
17568 int width, int height, int depth, int pitch,
17569 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
17571 +#else
17572 +AROS_LH9(SDL_Surface *, SDL_CreateRGBSurfaceFrom,
17573 + AROS_LHA(void *, pixels, A0),
17574 + AROS_LHA(int, width, D0),
17575 + AROS_LHA(int, height, D1),
17576 + AROS_LHA(int, depth, D2),
17577 + AROS_LHA(int, pitch, D3),
17578 + AROS_LHA(Uint32, Rmask, D4),
17579 + AROS_LHA(Uint32, Gmask, D5),
17580 + AROS_LHA(Uint32, Bmask, D6),
17581 + AROS_LHA(Uint32, Amask, D7),
17582 + struct SDLBase *, SDLBase, 49, SDL)
17584 + AROS_LIBFUNC_INIT
17585 +#endif
17586 SDL_Surface *surface;
17588 surface = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, depth,
17589 @@ -168,12 +218,26 @@
17590 SDL_SetClipRect(surface, NULL);
17592 return(surface);
17593 +#if defined(PROTO_SDL_H)
17594 + AROS_LIBFUNC_EXIT
17595 +#endif
17598 * Set the color key in a blittable surface
17600 +#if !defined(PROTO_SDL_H)
17601 int SDL_SetColorKey (SDL_Surface *surface, Uint32 flag, Uint32 key)
17603 +#else
17604 +AROS_LH3(int, SDL_SetColorKey,
17605 + AROS_LHA(SDL_Surface *, surface, A0),
17606 + AROS_LHA(Uint32, flag, D0),
17607 + AROS_LHA(Uint32, key, D1),
17608 + struct SDLBase *, SDLBase, 53, SDL)
17610 + AROS_LIBFUNC_INIT
17611 +#endif
17613 /* Sanity check the flag as it gets passed in */
17614 if ( flag & SDL_SRCCOLORKEY ) {
17615 if ( flag & (SDL_RLEACCEL|SDL_RLEACCELOK) ) {
17616 @@ -205,7 +269,11 @@
17617 surface->format->colorkey = key;
17618 if ( (surface->flags & SDL_HWACCEL) == SDL_HWACCEL ) {
17619 if ( (video->SetHWColorKey == NULL) ||
17620 +#if !defined(PROTO_SDL_H)
17621 (video->SetHWColorKey(this, surface, key) < 0) ) {
17622 +#else
17623 + (video->SetHWColorKey(this, surface, key, SDLBase) < 0) ) {
17624 +#endif
17625 surface->flags &= ~SDL_HWACCEL;
17628 @@ -220,10 +288,23 @@
17630 SDL_InvalidateMap(surface->map);
17631 return(0);
17632 +#if defined(PROTO_SDL_H)
17633 + AROS_LIBFUNC_EXIT
17634 +#endif
17636 /* This function sets the alpha channel of a surface */
17637 +#if !defined(PROTO_SDL_H)
17638 int SDL_SetAlpha (SDL_Surface *surface, Uint32 flag, Uint8 value)
17640 +#else
17641 +AROS_LH3(int, SDL_SetAlpha,
17642 + AROS_LHA(SDL_Surface *, surface, A0),
17643 + AROS_LHA(Uint32, flag, D0),
17644 + AROS_LHA(Uint8, value, D1),
17645 + struct SDLBase *, SDLBase, 54, SDL)
17647 + AROS_LIBFUNC_INIT
17648 +#endif
17649 Uint32 oldflags = surface->flags;
17650 Uint32 oldalpha = surface->format->alpha;
17652 @@ -255,7 +336,11 @@
17653 surface->format->alpha = value;
17654 if ( (surface->flags & SDL_HWACCEL) == SDL_HWACCEL ) {
17655 if ( (video->SetHWAlpha == NULL) ||
17656 +#if !defined(PROTO_SDL_H)
17657 (video->SetHWAlpha(this, surface, value) < 0) ) {
17658 +#else
17659 + (video->SetHWAlpha(this, surface, value, SDLBase) < 0) ) {
17660 +#endif
17661 surface->flags &= ~SDL_HWACCEL;
17664 @@ -279,8 +364,15 @@
17665 || (((oldalpha + 1) ^ (value + 1)) & 0x100))
17666 SDL_InvalidateMap(surface->map);
17667 return(0);
17668 +#if defined(PROTO_SDL_H)
17669 + AROS_LIBFUNC_EXIT
17670 +#endif
17672 +#if !defined(PROTO_SDL_H)
17673 int SDL_SetAlphaChannel(SDL_Surface *surface, Uint8 value)
17674 +#else
17675 +int SDL_SetAlphaChannel(SDL_Surface *surface, Uint8 value, struct SDLBase *SDLBase)
17676 +#endif
17678 int row, col;
17679 int offset;
17680 @@ -365,8 +457,17 @@
17682 * Set the clipping rectangle for a blittable surface
17684 +#if !defined(PROTO_SDL_H)
17685 SDL_bool SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect)
17687 +#else
17688 +AROS_LH2(SDL_bool, SDL_SetClipRect,
17689 + AROS_LHA(SDL_Surface *, surface, A0),
17690 + AROS_LHA(SDL_Rect *, rect, A1),
17691 + struct SDLBase *, SDLBase, 55, SDL)
17693 + AROS_LIBFUNC_INIT
17694 +#endif
17695 SDL_Rect full_rect;
17697 /* Don't do anything if there's no surface to act on */
17698 @@ -386,12 +487,27 @@
17699 return 1;
17701 return SDL_IntersectRect(rect, &full_rect, &surface->clip_rect);
17702 +#if defined(PROTO_SDL_H)
17703 + AROS_LIBFUNC_EXIT
17704 +#endif
17706 +#if !defined(PROTO_SDL_H)
17707 void SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect)
17709 +#else
17710 +AROS_LH2(void, SDL_GetClipRect,
17711 + AROS_LHA(SDL_Surface *, surface, A0),
17712 + AROS_LHA(SDL_Rect *, rect, A1),
17713 + struct SDLBase *, SDLBase, 56, SDL)
17715 + AROS_LIBFUNC_INIT
17716 +#endif
17717 if ( surface && rect ) {
17718 *rect = surface->clip_rect;
17720 +#if defined(PROTO_SDL_H)
17721 + AROS_LIBFUNC_EXIT
17722 +#endif
17725 * Set up a blit between two surfaces -- split into three parts:
17726 @@ -404,9 +520,20 @@
17727 * you know exactly what you are doing, you can optimize your code
17728 * by calling the one(s) you need.
17730 +#if !defined(PROTO_SDL_H)
17731 int SDL_LowerBlit (SDL_Surface *src, SDL_Rect *srcrect,
17732 SDL_Surface *dst, SDL_Rect *dstrect)
17734 +#else
17735 +AROS_LH4(int, SDL_LowerBlit,
17736 + AROS_LHA(SDL_Surface *, src, A0),
17737 + AROS_LHA(SDL_Rect *, srcrect, A1),
17738 + AROS_LHA(SDL_Surface *, dst, A2),
17739 + AROS_LHA(SDL_Rect *, dstrect, A3),
17740 + struct SDLBase *, SDLBase, 27, SDL)
17742 + AROS_LIBFUNC_INIT
17743 +#endif
17744 SDL_blit do_blit;
17745 SDL_Rect hw_srcrect;
17746 SDL_Rect hw_dstrect;
17747 @@ -437,13 +564,28 @@
17748 } else {
17749 do_blit = src->map->sw_blit;
17752 return(do_blit(src, srcrect, dst, dstrect));
17753 +#if defined(PROTO_SDL_H)
17754 + AROS_LIBFUNC_EXIT
17755 +#endif
17759 +#if !defined(PROTO_SDL_H)
17760 int SDL_UpperBlit (SDL_Surface *src, SDL_Rect *srcrect,
17761 SDL_Surface *dst, SDL_Rect *dstrect)
17763 +#else
17764 +AROS_LH4(int, SDL_UpperBlit,
17765 + AROS_LHA(SDL_Surface *, src, A0),
17766 + AROS_LHA(SDL_Rect *, srcrect, A1),
17767 + AROS_LHA(SDL_Surface *, dst, A2),
17768 + AROS_LHA(SDL_Rect *, dstrect, A3),
17769 + struct SDLBase *, SDLBase, 26, SDL)
17771 + AROS_LIBFUNC_INIT
17772 +#endif
17773 SDL_Rect fulldst;
17774 int srcx, srcy, w, h;
17776 @@ -531,16 +673,29 @@
17778 dstrect->w = dstrect->h = 0;
17779 return 0;
17780 +#if defined(PROTO_SDL_H)
17781 + AROS_LIBFUNC_EXIT
17782 +#endif
17785 +#if !defined(PROTO_SDL_H)
17786 static int SDL_FillRect1(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
17787 +#else
17788 +#define SDL_FillRect1(dst, dstrect, color) SDL_FillRect1I(dst, dstrect, color, SDLBase)
17789 +static int SDL_FillRect1I(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color, struct SDLBase *SDLBase)
17790 +#endif
17792 /* FIXME: We have to worry about packing order.. *sigh* */
17793 SDL_SetError("1-bpp rect fill not yet implemented");
17794 return -1;
17797 +#if !defined(PROTO_SDL_H)
17798 static int SDL_FillRect4(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
17799 +#else
17800 +#define SDL_FillRect4(dst, dstrect, color) SDL_FillRect4I(dst, dstrect, color, SDLBase)
17801 +static int SDL_FillRect4I(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color, struct SDLBase *SDLBase)
17802 +#endif
17804 /* FIXME: We have to worry about packing order.. *sigh* */
17805 SDL_SetError("4-bpp rect fill not yet implemented");
17806 @@ -550,8 +705,18 @@
17808 * This function performs a fast fill of the given rectangle with 'color'
17810 +#if !defined(PROTO_SDL_H)
17811 int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
17813 +#else
17814 +AROS_LH3(int, SDL_FillRect,
17815 + AROS_LHA(SDL_Surface *, dst, A0),
17816 + AROS_LHA(SDL_Rect *, dstrect, A1),
17817 + AROS_LHA(Uint32, color, D0),
17818 + struct SDLBase *, SDLBase, 25, SDL)
17820 + AROS_LIBFUNC_INIT
17821 +#endif
17822 SDL_VideoDevice *video = current_video;
17823 SDL_VideoDevice *this = current_video;
17824 int x, y;
17825 @@ -593,7 +758,11 @@
17826 hw_rect.y += current_video->offset_y;
17827 dstrect = &hw_rect;
17829 +#if !defined(PROTO_SDL_H)
17830 return(video->FillHWRect(this, dst, dstrect, color));
17831 +#else
17832 + return(video->FillHWRect(this, dst, dstrect, color, SDLBase));
17833 +#endif
17836 /* Perform software fill */
17837 @@ -728,19 +897,34 @@
17839 /* We're done! */
17840 return(0);
17841 +#if defined(PROTO_SDL_H)
17842 + AROS_LIBFUNC_EXIT
17843 +#endif
17847 * Lock a surface to directly access the pixels
17849 +#if !defined(PROTO_SDL_H)
17850 int SDL_LockSurface (SDL_Surface *surface)
17852 +#else
17853 +AROS_LH1(int, SDL_LockSurface,
17854 + AROS_LHA(SDL_Surface *, surface, A0),
17855 + struct SDLBase *, SDLBase, 50, SDL)
17857 + AROS_LIBFUNC_INIT
17858 +#endif
17859 if ( ! surface->locked ) {
17860 /* Perform the lock */
17861 if ( surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) {
17862 SDL_VideoDevice *video = current_video;
17863 SDL_VideoDevice *this = current_video;
17864 +#if !defined(PROTO_SDL_H)
17865 if ( video->LockHWSurface(this, surface) < 0 ) {
17866 +#else
17867 + if ( video->LockHWSurface(this, surface, SDLBase) < 0 ) {
17868 +#endif
17869 return(-1);
17872 @@ -757,12 +941,23 @@
17874 /* Ready to go.. */
17875 return(0);
17876 +#if defined(PROTO_SDL_H)
17877 + AROS_LIBFUNC_EXIT
17878 +#endif
17881 * Unlock a previously locked surface
17883 +#if !defined(PROTO_SDL_H)
17884 void SDL_UnlockSurface (SDL_Surface *surface)
17886 +#else
17887 +AROS_LH1(void, SDL_UnlockSurface,
17888 + AROS_LHA(SDL_Surface *, surface, A0),
17889 + struct SDLBase *, SDLBase, 51, SDL)
17891 + AROS_LIBFUNC_INIT
17892 +#endif
17893 /* Only perform an unlock if we are locked */
17894 if ( ! surface->locked || (--surface->locked > 0) ) {
17895 return;
17896 @@ -775,7 +970,11 @@
17897 if ( surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) {
17898 SDL_VideoDevice *video = current_video;
17899 SDL_VideoDevice *this = current_video;
17900 +#if !defined(PROTO_SDL_H)
17901 video->UnlockHWSurface(this, surface);
17902 +#else
17903 + video->UnlockHWSurface(this, surface, SDLBase);
17904 +#endif
17905 } else {
17906 /* Update RLE encoded surface with new data */
17907 if ( (surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL ) {
17908 @@ -783,14 +982,27 @@
17909 SDL_RLESurface(surface);
17912 +#if defined(PROTO_SDL_H)
17913 + AROS_LIBFUNC_EXIT
17914 +#endif
17918 * Convert a surface into the specified pixel format.
17920 +#if !defined(PROTO_SDL_H)
17921 SDL_Surface * SDL_ConvertSurface (SDL_Surface *surface,
17922 SDL_PixelFormat *format, Uint32 flags)
17924 +#else
17925 +AROS_LH3(SDL_Surface *, SDL_ConvertSurface,
17926 + AROS_LHA(SDL_Surface *, surface, A0),
17927 + AROS_LHA(SDL_PixelFormat *, format, A1),
17928 + AROS_LHA(Uint32, flags, D0),
17929 + struct SDLBase *, SDLBase, 57, SDL)
17931 + AROS_LIBFUNC_INIT
17932 +#endif
17933 SDL_Surface *convert;
17934 Uint32 colorkey = 0;
17935 Uint8 alpha = 0;
17936 @@ -895,13 +1107,24 @@
17938 /* We're ready to go! */
17939 return(convert);
17940 +#if defined(PROTO_SDL_H)
17941 + AROS_LIBFUNC_EXIT
17942 +#endif
17946 * Free a surface created by the above function.
17948 +#if !defined(PROTO_SDL_H)
17949 void SDL_FreeSurface (SDL_Surface *surface)
17951 +#else
17952 +AROS_LH1(void, SDL_FreeSurface,
17953 + AROS_LHA(SDL_Surface *, surface, A0),
17954 + struct SDLBase *, SDLBase, 24, SDL)
17956 + AROS_LIBFUNC_INIT
17957 +#endif
17958 /* Free anything that's not NULL, and not the screen surface */
17959 if ((surface == NULL) ||
17960 (current_video &&
17961 @@ -928,7 +1151,11 @@
17962 if ( surface->hwdata ) {
17963 SDL_VideoDevice *video = current_video;
17964 SDL_VideoDevice *this = current_video;
17965 +#if !defined(PROTO_SDL_H)
17966 video->FreeHWSurface(this, surface);
17967 +#else
17968 + video->FreeHWSurface(this, surface, SDLBase);
17969 +#endif
17971 if ( surface->pixels &&
17972 ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC) ) {
17973 @@ -938,4 +1165,7 @@
17974 #ifdef CHECK_LEAKS
17975 --surfaces_allocated;
17976 #endif
17977 +#if defined(PROTO_SDL_H)
17978 + AROS_LIBFUNC_EXIT
17979 +#endif
17981 diff -Naur SDL-1.2.15-orig/src/video/SDL_sysvideo.h SDL-1.2.15/src/video/SDL_sysvideo.h
17982 --- SDL-1.2.15-orig/src/video/SDL_sysvideo.h 2015-05-09 17:47:54.284774292 +0200
17983 +++ SDL-1.2.15/src/video/SDL_sysvideo.h 2015-05-09 15:09:59.774739497 +0200
17984 @@ -37,6 +37,10 @@
17985 #include "SDL_opengl.h"
17986 #endif /* SDL_VIDEO_OPENGL */
17988 +#if defined(PROTO_SDL_H)
17989 +#include "SDL_intern.h"
17990 +#endif
17992 /* The SDL video driver */
17993 typedef struct SDL_VideoDevice SDL_VideoDevice;
17995 @@ -52,11 +56,11 @@
17997 /* * * */
17998 /* Initialization/Query functions */
18000 +#if !defined(PROTO_SDL_H)
18001 /* Initialize the native video subsystem, filling 'vformat' with the
18002 "best" display pixel format, returning 0 or -1 if there's an error.
18004 - int (*VideoInit)(_THIS, SDL_PixelFormat *vformat);
18005 + int (*VideoInit)(_THIS, SDL_PixelFormat *vformat);
18007 /* List the available video modes for the given pixel format, sorted
18008 from largest to smallest.
18009 @@ -110,7 +114,17 @@
18010 or if the application is shutting down the video subsystem.
18012 void (*VideoQuit)(_THIS);
18014 +#else
18015 + int (*VideoInit)(_THIS, SDL_PixelFormat *vformat, struct SDLBase *SDLBase);
18016 + SDL_Rect **(*ListModes)(_THIS, SDL_PixelFormat *format, Uint32 flags, struct SDLBase *SDLBase);
18017 + SDL_Surface *(*SetVideoMode)(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags, struct SDLBase *SDLBase);
18018 + int (*ToggleFullScreen)(_THIS, int on, struct SDLBase *SDLBase);
18019 + void (*UpdateMouse)(_THIS, struct SDLBase *SDLBase);
18020 + SDL_Overlay *(*CreateYUVOverlay)(_THIS, int width, int height, Uint32 format, SDL_Surface *display, struct SDLBase *SDLBase);
18021 + int (*SetColors)(_THIS, int firstcolor, int ncolors, SDL_Color *colors, struct SDLBase *SDLBase);
18022 + void (*UpdateRects)(_THIS, int numrects, SDL_Rect *rects, struct SDLBase *SDLBase);
18023 + void (*VideoQuit)(_THIS, struct SDLBase *SDLBase);
18024 +#endif
18025 /* * * */
18026 /* Hardware acceleration functions */
18028 @@ -120,6 +134,7 @@
18029 /* The pixel format used when SDL_CreateRGBSurface creates SDL_HWSURFACEs with alpha */
18030 SDL_PixelFormat* displayformatalphapixel;
18032 +#if !defined(PROTO_SDL_H)
18033 /* Allocates a surface in video memory */
18034 int (*AllocHWSurface)(_THIS, SDL_Surface *surface);
18036 @@ -146,12 +161,22 @@
18038 /* Frees a previously allocated video surface */
18039 void (*FreeHWSurface)(_THIS, SDL_Surface *surface);
18041 +#else
18042 + int (*AllocHWSurface)(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
18043 + int (*CheckHWBlit)(_THIS, SDL_Surface *src, SDL_Surface *dst, struct SDLBase *SDLBase);
18044 + int (*FillHWRect)(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color, struct SDLBase *SDLBase);
18045 + int (*SetHWColorKey)(_THIS, SDL_Surface *surface, Uint32 key, struct SDLBase *SDLBase);
18046 + int (*SetHWAlpha)(_THIS, SDL_Surface *surface, Uint8 value, struct SDLBase *SDLBase);
18047 + int (*LockHWSurface)(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
18048 + void (*UnlockHWSurface)(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
18049 + int (*FlipHWSurface)(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
18050 + void (*FreeHWSurface)(_THIS, SDL_Surface *surface, struct SDLBase *SDLBase);
18051 +#endif
18052 /* * * */
18053 /* Gamma support */
18055 Uint16 *gamma;
18057 +#if !defined(PROTO_SDL_H)
18058 /* Set the gamma correction directly (emulated with gamma ramps) */
18059 int (*SetGamma)(_THIS, float red, float green, float blue);
18061 @@ -181,7 +206,17 @@
18063 /* Swap the current buffers in double buffer mode. */
18064 void (*GL_SwapBuffers)(_THIS);
18066 +#else
18067 + int (*SetGamma)(_THIS, float red, float green, float blue, struct SDLBase *SDLBase);
18068 + int (*GetGamma)(_THIS, float *red, float *green, float *blue, struct SDLBase *SDLBase);
18069 + int (*SetGammaRamp)(_THIS, Uint16 *ramp, struct SDLBase *SDLBase);
18070 + int (*GetGammaRamp)(_THIS, Uint16 *ramp, struct SDLBase *SDLBase);
18071 + int (*GL_LoadLibrary)(_THIS, const char *path, struct SDLBase *SDLBase);
18072 + void* (*GL_GetProcAddress)(_THIS, const char *proc, struct SDLBase *SDLBase);
18073 + int (*GL_GetAttribute)(_THIS, SDL_GLattr attrib, int* value, struct SDLBase *SDLBase);
18074 + int (*GL_MakeCurrent)(_THIS, struct SDLBase *SDLBase);
18075 + void (*GL_SwapBuffers)(_THIS, struct SDLBase *SDLBase);
18076 +#endif
18077 /* OpenGL functions for SDL_OPENGLBLIT */
18078 #if SDL_VIDEO_OPENGL
18079 #if !defined(__WIN32__)
18080 @@ -199,6 +234,7 @@
18081 /* * * */
18082 /* Window manager functions */
18084 +#if !defined(PROTO_SDL_H)
18085 /* Set the title and icon text */
18086 void (*SetCaption)(_THIS, const char *title, const char *icon);
18088 @@ -257,7 +293,21 @@
18090 /* Handle any queued OS events */
18091 void (*PumpEvents)(_THIS);
18093 +#else
18094 + void (*SetCaption)(_THIS, const char *title, const char *icon, struct SDLBase *SDLBase);
18095 + void (*SetIcon)(_THIS, SDL_Surface *icon, Uint8 *mask, struct SDLBase *SDLBase);
18096 + int (*IconifyWindow)(_THIS, struct SDLBase *SDLBase);
18097 + SDL_GrabMode (*GrabInput)(_THIS, SDL_GrabMode mode, struct SDLBase *SDLBase);
18098 + int (*GetWMInfo)(_THIS, SDL_SysWMinfo *info, struct SDLBase *SDLBase);
18099 + void (*FreeWMCursor)(_THIS, WMcursor *cursor, struct SDLBase *SDLBase);
18100 + WMcursor *(*CreateWMCursor)(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y, struct SDLBase *SDLBase);
18101 + int (*ShowWMCursor)(_THIS, WMcursor *cursor, struct SDLBase *SDLBase);
18102 + void (*WarpWMCursor)(_THIS, Uint16 x, Uint16 y, struct SDLBase *SDLBase);
18103 + void (*MoveWMCursor)(_THIS, int x, int y, struct SDLBase *SDLBase);
18104 + void (*CheckMouseMode)(_THIS, struct SDLBase *SDLBase);
18105 + void (*InitOSKeymap)(_THIS, struct SDLBase *SDLBase);
18106 + void (*PumpEvents)(_THIS, struct SDLBase *SDLBase);
18107 +#endif
18108 /* * * */
18109 /* Data common to all drivers */
18110 SDL_Surface *screen;
18111 @@ -306,15 +356,24 @@
18113 /* * * */
18114 /* The function used to dispose of this structure */
18115 +#if !defined(PROTO_SDL_H)
18116 void (*free)(_THIS);
18117 +#else
18118 + void (*free)(_THIS, struct SDLBase *SDLBase);
18119 +#endif
18121 #undef _THIS
18123 typedef struct VideoBootStrap {
18124 const char *name;
18125 const char *desc;
18126 +#if !defined(PROTO_SDL_H)
18127 int (*available)(void);
18128 SDL_VideoDevice *(*create)(int devindex);
18129 +#else
18130 + int (*available)(struct SDLBase *SDLBase);
18131 + SDL_VideoDevice *(*create)(int devindex, struct SDLBase *SDLBase);
18132 +#endif
18133 } VideoBootStrap;
18135 #if SDL_VIDEO_DRIVER_QUARTZ
18136 @@ -413,9 +472,14 @@
18137 #if SDL_VIDEO_DRIVER_DUMMY
18138 extern VideoBootStrap DUMMY_bootstrap;
18139 #endif
18140 +#if SDL_VIDEO_DRIVER_CGX
18141 +extern VideoBootStrap CGX_bootstrap;
18142 +#endif
18144 /* This is the current video device */
18145 +#if !defined(PROTO_SDL_H)
18146 extern SDL_VideoDevice *current_video;
18147 +#endif
18149 #define SDL_VideoSurface (current_video->screen)
18150 #define SDL_ShadowSurface (current_video->shadow)
18151 diff -Naur SDL-1.2.15-orig/src/video/SDL_video.c SDL-1.2.15/src/video/SDL_video.c
18152 --- SDL-1.2.15-orig/src/video/SDL_video.c 2015-05-09 17:47:54.282774297 +0200
18153 +++ SDL-1.2.15/src/video/SDL_video.c 2015-05-09 15:09:59.775739495 +0200
18154 @@ -19,6 +19,11 @@
18155 Sam Lantinga
18156 slouken@libsdl.org
18158 +#if defined (SDL_AROS_SHARED)
18159 +#define __NOLIBBASE__
18160 +#include <proto/SDL.h>
18161 +#endif
18163 #include "SDL_config.h"
18165 /* The high-level video driver subsystem */
18166 @@ -129,17 +134,28 @@
18167 #if SDL_VIDEO_DRIVER_DUMMY
18168 &DUMMY_bootstrap,
18169 #endif
18170 +#if SDL_VIDEO_DRIVER_CGX
18171 + &CGX_bootstrap,
18172 +#endif
18173 NULL
18176 -SDL_VideoDevice *current_video = NULL;
18178 -/* Various local functions */
18179 +#if !defined(PROTO_SDL_H)
18180 int SDL_VideoInit(const char *driver_name, Uint32 flags);
18181 void SDL_VideoQuit(void);
18182 -void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect* rects);
18184 +SDL_VideoDevice *current_video = NULL;
18185 +void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect* rects);
18186 static SDL_GrabMode SDL_WM_GrabInputOff(void);
18187 +#else
18188 +void SDL_GL_UpdateRectsLockI(SDL_VideoDevice* this, int numrects, SDL_Rect* rects, struct SDLBase *SDLBase);
18189 +#define current_video SDLBase->current_video
18190 +#define SDL_GL_UpdateRectsLock SDL_GL_UpdateRectsLockI
18191 +static SDL_GrabMode SDL_WM_GrabInputOffI(struct SDLBase *SDLBase);
18192 +#define SDL_WM_GrabInputOff() SDL_WM_GrabInputOffI(SDLBase)
18193 +#endif
18195 +/* Various local functions */
18196 #if SDL_VIDEO_OPENGL
18197 static int lock_count = 0;
18198 #endif
18199 @@ -148,8 +164,18 @@
18201 * Initialize the video and event subsystems -- determine native pixel format
18203 +#if !defined(PROTO_SDL_H)
18204 int SDL_VideoInit (const char *driver_name, Uint32 flags)
18206 +#else
18207 +AROS_LH2(int, SDL_VideoInit,
18208 + AROS_LHA(const char *, driver_name, A0),
18209 + AROS_LHA(Uint32, flags, D0),
18210 + struct SDLBase *, SDLBase, 34, SDL)
18212 + AROS_LIBFUNC_INIT
18213 +#endif
18215 SDL_VideoDevice *video;
18216 int index;
18217 int i;
18218 @@ -182,16 +208,26 @@
18219 #endif
18220 for ( i=0; bootstrap[i]; ++i ) {
18221 if ( SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) {
18222 +#if !defined(PROTO_SDL_H)
18223 if ( bootstrap[i]->available() ) {
18224 video = bootstrap[i]->create(index);
18225 +#else
18226 + if ( bootstrap[i]->available(SDLBase) ) {
18227 + video = bootstrap[i]->create(index, SDLBase);
18228 +#endif
18229 break;
18233 } else {
18234 for ( i=0; bootstrap[i]; ++i ) {
18235 +#if !defined(PROTO_SDL_H)
18236 if ( bootstrap[i]->available() ) {
18237 video = bootstrap[i]->create(index);
18238 +#else
18239 + if ( bootstrap[i]->available(SDLBase) ) {
18240 + video = bootstrap[i]->create(index, SDLBase);
18241 +#endif
18242 if ( video != NULL ) {
18243 break;
18245 @@ -243,7 +279,11 @@
18247 /* Initialize the video subsystem */
18248 SDL_memset(&vformat, 0, sizeof(vformat));
18249 +#if !defined(PROTO_SDL_H)
18250 if ( video->VideoInit(video, &vformat) < 0 ) {
18251 +#else
18252 + if ( video->VideoInit(video, &vformat, SDLBase) < 0 ) {
18253 +#endif
18254 SDL_VideoQuit();
18255 return(-1);
18257 @@ -282,22 +322,45 @@
18259 /* We're ready to go! */
18260 return(0);
18261 +#if defined(PROTO_SDL_H)
18262 + AROS_LIBFUNC_EXIT
18263 +#endif
18266 +#if !defined(PROTO_SDL_H)
18267 char *SDL_VideoDriverName(char *namebuf, int maxlen)
18269 +#else
18270 +AROS_LH2(char *, SDL_VideoDriverName,
18271 + AROS_LHA(char *, namebuf, A0),
18272 + AROS_LHA(int, maxlen, D0),
18273 + struct SDLBase *, SDLBase, 36, SDL)
18275 + AROS_LIBFUNC_INIT
18276 +#endif
18277 if ( current_video != NULL ) {
18278 SDL_strlcpy(namebuf, current_video->name, maxlen);
18279 return(namebuf);
18281 return(NULL);
18282 +#if defined(PROTO_SDL_H)
18283 + AROS_LIBFUNC_EXIT
18284 +#endif
18288 * Get the current display surface
18291 +#if !defined(PROTO_SDL_H)
18292 SDL_Surface *SDL_GetVideoSurface(void)
18294 +#else
18295 +AROS_LH0(SDL_Surface *, SDL_GetVideoSurface,
18296 + struct SDLBase *, SDLBase, 38, SDL)
18298 + AROS_LIBFUNC_INIT
18299 +#endif
18300 SDL_Surface *visible;
18302 visible = NULL;
18303 @@ -305,13 +368,23 @@
18304 visible = current_video->visible;
18306 return(visible);
18307 +#if defined(PROTO_SDL_H)
18308 + AROS_LIBFUNC_EXIT
18309 +#endif
18313 * Get the current information about the video hardware
18315 +#if !defined(PROTO_SDL_H)
18316 const SDL_VideoInfo *SDL_GetVideoInfo(void)
18318 +#else
18319 +AROS_LH0(const SDL_VideoInfo *, SDL_GetVideoInfo,
18320 + struct SDLBase *, SDLBase, 35, SDL)
18322 + AROS_LIBFUNC_INIT
18323 +#endif
18324 const SDL_VideoInfo *info;
18326 info = NULL;
18327 @@ -319,6 +392,9 @@
18328 info = &current_video->info;
18330 return(info);
18331 +#if defined(PROTO_SDL_H)
18332 + AROS_LIBFUNC_EXIT
18333 +#endif
18337 @@ -328,8 +404,17 @@
18338 * if any dimension is okay for the given format. If 'format' is NULL,
18339 * the mode list will be for the format given by SDL_GetVideoInfo()->vfmt
18341 +#if !defined(PROTO_SDL_H)
18342 SDL_Rect ** SDL_ListModes (SDL_PixelFormat *format, Uint32 flags)
18344 +#else
18345 +AROS_LH2(SDL_Rect **, SDL_ListModes ,
18346 + AROS_LHA(SDL_PixelFormat *, format, A0),
18347 + AROS_LHA(Uint32, flags, D0),
18348 + struct SDLBase *, SDLBase, 40, SDL)
18350 + AROS_LIBFUNC_INIT
18351 +#endif
18352 SDL_VideoDevice *video = current_video;
18353 SDL_VideoDevice *this = current_video;
18354 SDL_Rect **modes;
18355 @@ -339,9 +424,16 @@
18356 if ( format == NULL ) {
18357 format = SDL_VideoSurface->format;
18359 +#if !defined(PROTO_SDL_H)
18360 modes = video->ListModes(this, format, flags);
18361 +#else
18362 + modes = video->ListModes(this, format, flags, SDLBase);
18363 +#endif
18365 return(modes);
18366 +#if defined(PROTO_SDL_H)
18367 + AROS_LIBFUNC_EXIT
18368 +#endif
18372 @@ -370,8 +462,19 @@
18373 #define NEGATIVE_ONE -1
18374 #endif
18376 +#if !defined(PROTO_SDL_H)
18377 int SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags)
18379 +#else
18380 +AROS_LH4(int, SDL_VideoModeOK,
18381 + AROS_LHA(int, width, D0),
18382 + AROS_LHA(int, height, D1),
18383 + AROS_LHA(int, bpp, D2),
18384 + AROS_LHA(Uint32, flags, D3),
18385 + struct SDLBase *, SDLBase, 39, SDL)
18387 + AROS_LIBFUNC_INIT
18388 +#endif
18389 int table, b, i;
18390 int supported;
18391 SDL_PixelFormat format;
18392 @@ -424,12 +527,20 @@
18393 } else {
18394 return(0);
18396 +#if defined(PROTO_SDL_H)
18397 + AROS_LIBFUNC_EXIT
18398 +#endif
18402 * Get the closest non-emulated video mode to the one requested
18404 +#if !defined(PROTO_SDL_H)
18405 static int SDL_GetVideoMode (int *w, int *h, int *BitsPerPixel, Uint32 flags)
18406 +#else
18407 +#define SDL_GetVideoMode(w, h, BitsPerPixel, flags) SDL_GetVideoModeI(w, h, BitsPerPixel, flags, SDLBase)
18408 +static int SDL_GetVideoModeI(int *w, int *h, int *BitsPerPixel, Uint32 flags, struct SDLBase *SDLBase)
18409 +#endif
18411 int table, b, i;
18412 int supported;
18413 @@ -499,7 +610,12 @@
18416 /* This should probably go somewhere else -- like SDL_surface.c */
18417 +#if !defined(PROTO_SDL_H)
18418 static void SDL_ClearSurface(SDL_Surface *surface)
18419 +#else
18420 +#define SDL_ClearSurface(surface) SDL_ClearSurfaceI(surface, SDLBase)
18421 +static void SDL_ClearSurfaceI(SDL_Surface *surface, struct SDLBase *SDLBase)
18422 +#endif
18424 Uint32 black;
18426 @@ -517,7 +633,12 @@
18428 * Create a shadow surface suitable for fooling the app. :-)
18430 +#if !defined(PROTO_SDL_H)
18431 static void SDL_CreateShadowSurface(int depth)
18432 +#else
18433 +#define SDL_CreateShadowSurface(depth) SDL_CreateShadowSurfaceI(depth, SDLBase)
18434 +static void SDL_CreateShadowSurfaceI(int depth, struct SDLBase *SDLBase)
18435 +#endif
18437 Uint32 Rmask, Gmask, Bmask;
18439 @@ -580,8 +701,19 @@
18441 * Set the requested video mode, allocating a shadow buffer if necessary.
18443 +#if !defined(PROTO_SDL_H)
18444 SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
18446 +#else
18447 +AROS_LH4(SDL_Surface *, SDL_SetVideoMode,
18448 + AROS_LHA(int, width, D0),
18449 + AROS_LHA(int, height, D1),
18450 + AROS_LHA(int, bpp, D2),
18451 + AROS_LHA(Uint32, flags, D3),
18452 + struct SDLBase *, SDLBase, 31, SDL)
18454 + AROS_LIBFUNC_INIT
18455 +#endif
18456 SDL_VideoDevice *video, *this;
18457 SDL_Surface *prev_mode, *mode;
18458 int video_w;
18459 @@ -680,7 +812,11 @@
18460 prev_mode = SDL_VideoSurface;
18461 SDL_LockCursor();
18462 SDL_VideoSurface = NULL; /* In case it's freed by driver */
18463 +#if !defined(PROTO_SDL_H)
18464 mode = video->SetVideoMode(this, prev_mode,video_w,video_h,video_bpp,flags);
18465 +#else
18466 + mode = video->SetVideoMode(this, prev_mode,video_w,video_h,video_bpp,flags, SDLBase);
18467 +#endif
18468 if ( mode ) { /* Prevent resize events from mode change */
18469 /* But not on OS/2 */
18470 #ifndef __OS2__
18471 @@ -717,8 +853,12 @@
18472 if ( mode->format->palette ) {
18473 SDL_PixelFormat *vf = mode->format;
18474 SDL_DitherColors(vf->palette->colors, vf->BitsPerPixel);
18475 +#if !defined(PROTO_SDL_H)
18476 video->SetColors(this, 0, vf->palette->ncolors,
18477 vf->palette->colors);
18478 +#else
18479 + video->SetColors(this, 0, vf->palette->ncolors, vf->palette->colors, SDLBase);
18480 +#endif
18483 /* Clear the surface to black */
18484 @@ -759,7 +899,11 @@
18485 /* Reset the mouse cursor and grab for new video mode */
18486 SDL_SetCursor(NULL);
18487 if ( video->UpdateMouse ) {
18488 +#if !defined(PROTO_SDL_H)
18489 video->UpdateMouse(this);
18490 +#else
18491 + video->UpdateMouse(this, SDLBase);
18492 +#endif
18494 SDL_WM_GrabInput(saved_grab);
18495 SDL_GetRelativeMouseState(NULL, NULL); /* Clear first large delta */
18496 @@ -795,7 +939,11 @@
18497 /* If we're running OpenGL, make the context current */
18498 if ( (video->screen->flags & SDL_OPENGL) &&
18499 video->GL_MakeCurrent ) {
18500 +#if !defined(PROTO_SDL_H)
18501 if ( video->GL_MakeCurrent(this) < 0 ) {
18502 +#else
18503 + if ( video->GL_MakeCurrent(this, SDLBase) < 0 ) {
18504 +#endif
18505 return(NULL);
18508 @@ -919,13 +1067,24 @@
18510 /* We're done! */
18511 return(SDL_PublicSurface);
18512 +#if defined(PROTO_SDL_H)
18513 + AROS_LIBFUNC_EXIT
18514 +#endif
18518 * Convert a surface into the video pixel format.
18520 +#if !defined(PROTO_SDL_H)
18521 SDL_Surface * SDL_DisplayFormat (SDL_Surface *surface)
18523 +#else
18524 +AROS_LH1(SDL_Surface *, SDL_DisplayFormat,
18525 + AROS_LHA(SDL_Surface *, surface, A0),
18526 + struct SDLBase *, SDLBase, 23, SDL)
18528 + AROS_LIBFUNC_INIT
18529 +#endif
18530 Uint32 flags;
18532 if ( ! SDL_PublicSurface ) {
18533 @@ -944,14 +1103,25 @@
18534 flags |= surface->flags & (SDL_SRCCOLORKEY|SDL_SRCALPHA|SDL_RLEACCELOK);
18535 #endif
18536 return(SDL_ConvertSurface(surface, SDL_PublicSurface->format, flags));
18537 +#if defined(PROTO_SDL_H)
18538 + AROS_LIBFUNC_EXIT
18539 +#endif
18543 * Convert a surface into a format that's suitable for blitting to
18544 * the screen, but including an alpha channel.
18546 +#if !defined(PROTO_SDL_H)
18547 SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface)
18549 +#else
18550 +AROS_LH1(SDL_Surface *, SDL_DisplayFormatAlpha,
18551 + AROS_LHA(SDL_Surface *, surface, A0),
18552 + struct SDLBase *, SDLBase, 58, SDL)
18554 + AROS_LIBFUNC_INIT
18555 +#endif
18556 SDL_PixelFormat *vf;
18557 SDL_PixelFormat *format;
18558 SDL_Surface *converted;
18559 @@ -1006,13 +1176,28 @@
18560 converted = SDL_ConvertSurface(surface, format, flags);
18561 SDL_FreeFormat(format);
18562 return(converted);
18563 +#if defined(PROTO_SDL_H)
18564 + AROS_LIBFUNC_EXIT
18565 +#endif
18569 * Update a specific portion of the physical screen
18571 +#if !defined(PROTO_SDL_H)
18572 void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h)
18574 +#else
18575 +AROS_LH5(void, SDL_UpdateRect,
18576 + AROS_LHA(SDL_Surface *, screen, A0),
18577 + AROS_LHA(Sint32, x, D0),
18578 + AROS_LHA(Sint32, y, D1),
18579 + AROS_LHA(Uint32, w, D2),
18580 + AROS_LHA(Uint32, h, D3),
18581 + struct SDLBase *, SDLBase, 30, SDL)
18583 + AROS_LIBFUNC_INIT
18584 +#endif
18585 if ( screen ) {
18586 SDL_Rect rect;
18588 @@ -1033,9 +1218,23 @@
18589 rect.h = (Uint16)h;
18590 SDL_UpdateRects(screen, 1, &rect);
18592 +#if defined(PROTO_SDL_H)
18593 + AROS_LIBFUNC_EXIT
18594 +#endif
18597 +#if !defined(PROTO_SDL_H)
18598 void SDL_UpdateRects (SDL_Surface *screen, int numrects, SDL_Rect *rects)
18600 +#else
18601 +AROS_LH3(void, SDL_UpdateRects,
18602 + AROS_LHA(SDL_Surface *, screen, A0),
18603 + AROS_LHA(int, numrects, D0),
18604 + AROS_LHA(SDL_Rect *, rects, A1),
18605 + struct SDLBase *, SDLBase, 29, SDL)
18607 + AROS_LIBFUNC_INIT
18608 +#endif
18609 int i;
18610 SDL_VideoDevice *video = current_video;
18611 SDL_VideoDevice *this = current_video;
18612 @@ -1088,22 +1287,41 @@
18613 rects[i].x += video->offset_x;
18614 rects[i].y += video->offset_y;
18616 +#if !defined(PROTO_SDL_H)
18617 video->UpdateRects(this, numrects, rects);
18618 +#else
18619 + video->UpdateRects(this, numrects, rects, SDLBase);
18620 +#endif
18621 for ( i=0; i<numrects; ++i ) {
18622 rects[i].x -= video->offset_x;
18623 rects[i].y -= video->offset_y;
18625 } else {
18626 +#if !defined(PROTO_SDL_H)
18627 video->UpdateRects(this, numrects, rects);
18628 +#else
18629 + video->UpdateRects(this, numrects, rects, SDLBase);
18630 +#endif
18633 +#if defined(PROTO_SDL_H)
18634 + AROS_LIBFUNC_EXIT
18635 +#endif
18639 * Performs hardware double buffering, if possible, or a full update if not.
18641 +#if !defined(PROTO_SDL_H)
18642 int SDL_Flip(SDL_Surface *screen)
18644 +#else
18645 +AROS_LH1(int, SDL_Flip,
18646 + AROS_LHA(SDL_Surface *, screen, A0),
18647 + struct SDLBase *, SDLBase, 28, SDL)
18649 + AROS_LIBFUNC_INIT
18650 +#endif
18651 SDL_VideoDevice *video = current_video;
18652 /* Copy the shadow surface to the video surface */
18653 if ( screen == SDL_ShadowSurface ) {
18654 @@ -1146,15 +1364,28 @@
18656 if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
18657 SDL_VideoDevice *this = current_video;
18658 +#if !defined(PROTO_SDL_H)
18659 return(video->FlipHWSurface(this, SDL_VideoSurface));
18660 +#else
18661 + return(video->FlipHWSurface(this, SDL_VideoSurface, SDLBase));
18662 +#endif
18663 } else {
18664 SDL_UpdateRect(screen, 0, 0, 0, 0);
18666 return(0);
18667 +#if defined(PROTO_SDL_H)
18668 + AROS_LIBFUNC_EXIT
18669 +#endif
18672 +#if !defined(PROTO_SDL_H)
18673 static void SetPalette_logical(SDL_Surface *screen, SDL_Color *colors,
18674 int firstcolor, int ncolors)
18675 +#else
18676 +#define SetPalette_logical(screen, colors, firstcolor, ncolors) SetPalette_logicalI(screen, colors, firstcolor, ncolors, SDLBase)
18677 +static void SetPalette_logicalI(SDL_Surface *screen, SDL_Color *colors,
18678 + int firstcolor, int ncolors, struct SDLBase *SDLBase)
18679 +#endif
18681 SDL_Palette *pal = screen->format->palette;
18682 SDL_Palette *vidpal;
18683 @@ -1180,8 +1411,14 @@
18684 SDL_FormatChanged(screen);
18687 +#if !defined(PROTO_SDL_H)
18688 static int SetPalette_physical(SDL_Surface *screen,
18689 SDL_Color *colors, int firstcolor, int ncolors)
18690 +#else
18691 +#define SetPalette_physical(screen, colors, firstcolor, ncolors) SetPalette_physicalI(screen, colors, firstcolor, ncolors, SDLBase)
18692 +static int SetPalette_physicalI(SDL_Surface *screen,
18693 + SDL_Color *colors, int firstcolor, int ncolors, struct SDLBase *SDLBase)
18694 +#endif
18696 SDL_VideoDevice *video = current_video;
18697 int gotall = 1;
18698 @@ -1239,7 +1476,11 @@
18699 SDL_ApplyGamma(video->gamma, colors, gcolors, ncolors);
18700 colors = gcolors;
18702 +#if !defined(PROTO_SDL_H)
18703 gotall = video->SetColors(video, firstcolor, ncolors, colors);
18704 +#else
18705 + gotall = video->SetColors(video, firstcolor, ncolors, colors, SDLBase);
18706 +#endif
18707 if ( ! gotall ) {
18708 /* The video flags shouldn't have SDL_HWPALETTE, and
18709 the video driver is responsible for copying back the
18710 @@ -1261,9 +1502,21 @@
18712 * Return nonzero if all colours were set as requested, or 0 otherwise.
18714 +#if !defined(PROTO_SDL_H)
18715 int SDL_SetPalette(SDL_Surface *screen, int which,
18716 SDL_Color *colors, int firstcolor, int ncolors)
18718 +#else
18719 +AROS_LH5(int, SDL_SetPalette,
18720 + AROS_LHA(SDL_Surface *, screen, A0),
18721 + AROS_LHA(int, which, D0),
18722 + AROS_LHA(SDL_Color *, colors, A1),
18723 + AROS_LHA(int, firstcolor, D1),
18724 + AROS_LHA(int, ncolors, D2),
18725 + struct SDLBase *, SDLBase, 45, SDL)
18727 + AROS_LIBFUNC_INIT
18728 +#endif
18729 SDL_Palette *pal;
18730 int gotall;
18731 int palsize;
18732 @@ -1323,26 +1576,50 @@
18734 SDL_memcpy(pp->colors, pal->colors, size);
18736 - if ( ! SetPalette_physical(screen,
18737 - colors, firstcolor, ncolors) ) {
18738 + if ( ! SetPalette_physical(screen, colors, firstcolor, ncolors) ) {
18739 gotall = 0;
18742 return gotall;
18743 +#if defined(PROTO_SDL_H)
18744 + AROS_LIBFUNC_EXIT
18745 +#endif
18748 +#if !defined(PROTO_SDL_H)
18749 int SDL_SetColors(SDL_Surface *screen, SDL_Color *colors, int firstcolor,
18750 int ncolors)
18752 +#else
18753 +AROS_LH4(int, SDL_SetColors,
18754 + AROS_LHA(SDL_Surface *, screen, A0),
18755 + AROS_LHA(SDL_Color *, colors, A1),
18756 + AROS_LHA(int, firstcolor, D0),
18757 + AROS_LHA(int, ncolors, D1),
18758 + struct SDLBase *, SDLBase, 44, SDL)
18760 + AROS_LIBFUNC_INIT
18761 +#endif
18762 return SDL_SetPalette(screen, SDL_LOGPAL | SDL_PHYSPAL,
18763 colors, firstcolor, ncolors);
18764 +#if defined(PROTO_SDL_H)
18765 + AROS_LIBFUNC_EXIT
18766 +#endif
18770 * Clean up the video subsystem
18772 +#if !defined(PROTO_SDL_H)
18773 void SDL_VideoQuit (void)
18775 +#else
18776 +AROS_LH0(void, SDL_VideoQuit,
18777 + struct SDLBase *, SDLBase, 37, SDL)
18779 + AROS_LIBFUNC_INIT
18780 +#endif
18782 SDL_Surface *ready_to_go;
18784 if ( current_video ) {
18785 @@ -1362,7 +1639,11 @@
18786 SDL_WM_GrabInputOff();
18788 /* Clean up the system video */
18789 +#if !defined(PROTO_SDL_H)
18790 video->VideoQuit(this);
18791 +#else
18792 + video->VideoQuit(this, SDLBase);
18793 +#endif
18795 /* Free any lingering surfaces */
18796 ready_to_go = SDL_ShadowSurface;
18797 @@ -1399,15 +1680,30 @@
18800 /* Finish cleaning up video subsystem */
18801 +#if !defined(PROTO_SDL_H)
18802 video->free(this);
18803 +#else
18804 + video->free(this, SDLBase);
18805 +#endif
18806 current_video = NULL;
18808 return;
18809 +#if defined(PROTO_SDL_H)
18810 + AROS_LIBFUNC_EXIT
18811 +#endif
18814 /* Load the GL driver library */
18815 +#if !defined(PROTO_SDL_H)
18816 int SDL_GL_LoadLibrary(const char *path)
18818 +#else
18819 +AROS_LH1(int, SDL_GL_LoadLibrary,
18820 + AROS_LHA(const char *, path, A0),
18821 + struct SDLBase *, SDLBase, 64, SDL)
18823 + AROS_LIBFUNC_INIT
18824 +#endif
18825 SDL_VideoDevice *video = current_video;
18826 SDL_VideoDevice *this = current_video;
18827 int retval;
18828 @@ -1417,16 +1713,31 @@
18829 SDL_SetError("Video subsystem has not been initialized");
18830 } else {
18831 if ( video->GL_LoadLibrary ) {
18832 +#if !defined(PROTO_SDL_H)
18833 retval = video->GL_LoadLibrary(this, path);
18834 +#else
18835 + retval = video->GL_LoadLibrary(this, path, SDLBase);
18836 +#endif
18837 } else {
18838 SDL_SetError("No dynamic GL support in video driver");
18841 return(retval);
18842 +#if defined(PROTO_SDL_H)
18843 + AROS_LIBFUNC_EXIT
18844 +#endif
18847 +#if !defined(PROTO_SDL_H)
18848 void *SDL_GL_GetProcAddress(const char* proc)
18850 +#else
18851 +AROS_LH1(void *, SDL_GL_GetProcAddress,
18852 + AROS_LHA(const char*, proc, A0),
18853 + struct SDLBase *, SDLBase, 65, SDL)
18855 + AROS_LIBFUNC_INIT
18856 +#endif
18857 SDL_VideoDevice *video = current_video;
18858 SDL_VideoDevice *this = current_video;
18859 void *func;
18860 @@ -1434,7 +1745,11 @@
18861 func = NULL;
18862 if ( video->GL_GetProcAddress ) {
18863 if ( video->gl_config.driver_loaded ) {
18864 +#if !defined(PROTO_SDL_H)
18865 func = video->GL_GetProcAddress(this, proc);
18866 +#else
18867 + func = video->GL_GetProcAddress(this, proc, SDLBase);
18868 +#endif
18869 } else {
18870 SDL_SetError("No GL driver has been loaded");
18872 @@ -1442,11 +1757,23 @@
18873 SDL_SetError("No dynamic GL support in video driver");
18875 return func;
18876 +#if defined(PROTO_SDL_H)
18877 + AROS_LIBFUNC_EXIT
18878 +#endif
18881 /* Set the specified GL attribute for setting up a GL video mode */
18882 +#if !defined(PROTO_SDL_H)
18883 int SDL_GL_SetAttribute( SDL_GLattr attr, int value )
18885 +#else
18886 +AROS_LH2(int, SDL_GL_SetAttribute,
18887 + AROS_LHA(SDL_GLattr, attr, D0),
18888 + AROS_LHA(int, value, D1),
18889 + struct SDLBase *, SDLBase, 66, SDL)
18891 + AROS_LIBFUNC_INIT
18892 +#endif
18893 int retval;
18894 SDL_VideoDevice *video = current_video;
18896 @@ -1509,39 +1836,80 @@
18897 break;
18899 return(retval);
18900 +#if defined(PROTO_SDL_H)
18901 + AROS_LIBFUNC_EXIT
18902 +#endif
18905 /* Retrieve an attribute value from the windowing system. */
18906 +#if !defined(PROTO_SDL_H)
18907 int SDL_GL_GetAttribute(SDL_GLattr attr, int* value)
18909 +#else
18910 +AROS_LH2(int, SDL_GL_GetAttribute,
18911 + AROS_LHA(SDL_GLattr, attr, D0),
18912 + AROS_LHA(int *, value, A0),
18913 + struct SDLBase *, SDLBase, 67, SDL)
18915 + AROS_LIBFUNC_INIT
18916 +#endif
18917 int retval = -1;
18918 SDL_VideoDevice* video = current_video;
18919 SDL_VideoDevice* this = current_video;
18921 if ( video->GL_GetAttribute ) {
18922 +#if !defined(PROTO_SDL_H)
18923 retval = this->GL_GetAttribute(this, attr, value);
18924 +#else
18925 + retval = this->GL_GetAttribute(this, attr, value, SDLBase);
18926 +#endif
18927 } else {
18928 *value = 0;
18929 SDL_SetError("GL_GetAttribute not supported");
18931 return retval;
18932 +#if defined(PROTO_SDL_H)
18933 + AROS_LIBFUNC_EXIT
18934 +#endif
18937 /* Perform a GL buffer swap on the current GL context */
18938 +#if !defined(PROTO_SDL_H)
18939 void SDL_GL_SwapBuffers(void)
18941 +#else
18942 +AROS_LH0(void, SDL_GL_SwapBuffers,
18943 + struct SDLBase *, SDLBase, 68, SDL)
18945 + AROS_LIBFUNC_INIT
18946 +#endif
18947 SDL_VideoDevice *video = current_video;
18948 SDL_VideoDevice *this = current_video;
18950 if ( video->screen->flags & SDL_OPENGL ) {
18951 +#if !defined(PROTO_SDL_H)
18952 video->GL_SwapBuffers(this);
18953 +#else
18954 + video->GL_SwapBuffers(this, SDLBase);
18955 +#endif
18956 } else {
18957 SDL_SetError("OpenGL video mode has not been set");
18959 +#if defined(PROTO_SDL_H)
18960 + AROS_LIBFUNC_EXIT
18961 +#endif
18964 /* Update rects with locking */
18965 +#if !defined(PROTO_SDL_H)
18966 void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect *rects)
18967 +#else
18968 +#ifdef SDL_GL_UpdateRectsLock
18969 +#undef SDL_GL_UpdateRectsLock
18970 +#endif
18971 +#define SDL_GL_UpdateRectsLock(this, numrects, rects) SDL_GL_UpdateRectsLockI(this, numrects, rects, SDLBase)
18972 +void SDL_GL_UpdateRectsLockI(SDL_VideoDevice* this, int numrects, SDL_Rect *rects, struct SDLBase *SDLBase)
18973 +#endif
18975 SDL_GL_Lock();
18976 SDL_GL_UpdateRects(numrects, rects);
18977 @@ -1549,8 +1917,17 @@
18980 /* Update rects without state setting and changing (the caller is responsible for it) */
18981 +#if !defined(PROTO_SDL_H)
18982 void SDL_GL_UpdateRects(int numrects, SDL_Rect *rects)
18984 +#else
18985 +AROS_LH2(void, SDL_GL_UpdateRects,
18986 + AROS_LHA(Uint32, numrects, D0),
18987 + AROS_LHA(SDL_Rect *, rects, A0),
18988 + struct SDLBase *, SDLBase, 69, SDL)
18990 + AROS_LIBFUNC_INIT
18991 +#endif
18992 #if SDL_VIDEO_OPENGL
18993 SDL_VideoDevice *this = current_video;
18994 SDL_Rect update, tmp;
18995 @@ -1620,11 +1997,21 @@
18998 #endif
18999 +#if defined(PROTO_SDL_H)
19000 + AROS_LIBFUNC_EXIT
19001 +#endif
19004 /* Lock == save current state */
19005 +#if !defined(PROTO_SDL_H)
19006 void SDL_GL_Lock()
19008 +#else
19009 +AROS_LH0(void, SDL_GL_Lock,
19010 + struct SDLBase *, SDLBase, 70, SDL)
19012 + AROS_LIBFUNC_INIT
19013 +#endif
19014 #if SDL_VIDEO_OPENGL
19015 lock_count--;
19016 if (lock_count==-1)
19017 @@ -1668,11 +2055,21 @@
19018 this->glLoadIdentity();
19020 #endif
19021 +#if defined(PROTO_SDL_H)
19022 + AROS_LIBFUNC_EXIT
19023 +#endif
19026 /* Unlock == restore saved state */
19027 +#if !defined(PROTO_SDL_H)
19028 void SDL_GL_Unlock()
19030 +#else
19031 +AROS_LH0(void, SDL_GL_Unlock,
19032 + struct SDLBase *, SDLBase, 71, SDL)
19034 + AROS_LIBFUNC_INIT
19035 +#endif
19036 #if SDL_VIDEO_OPENGL
19037 lock_count++;
19038 if (lock_count==0)
19039 @@ -1687,16 +2084,29 @@
19040 this->glPopAttrib();
19042 #endif
19043 +#if defined(PROTO_SDL_H)
19044 + AROS_LIBFUNC_EXIT
19045 +#endif
19049 +#if !defined(PROTO_SDL_H)
19050 void SDL_Audio_SetCaption(const char *caption);
19051 +#endif
19054 * Sets/Gets the title and icon text of the display window, if any.
19056 +#if !defined(PROTO_SDL_H)
19057 void SDL_WM_SetCaption (const char *title, const char *icon)
19059 +#else
19060 +AROS_LH2(void, SDL_WM_SetCaption,
19061 + AROS_LHA(const char *, title, A0),
19062 + AROS_LHA(const char *, icon, A1),
19063 + struct SDLBase *, SDLBase, 72, SDL)
19065 + AROS_LIBFUNC_INIT
19066 +#endif
19067 SDL_VideoDevice *video = current_video;
19068 SDL_VideoDevice *this = current_video;
19070 @@ -1714,16 +2124,32 @@
19071 video->wm_icon = SDL_strdup(icon);
19073 if ( (title || icon) && (video->SetCaption != NULL) ) {
19074 +#if !defined(PROTO_SDL_H)
19075 video->SetCaption(this, video->wm_title,video->wm_icon);
19076 +#else
19077 + video->SetCaption(this, video->wm_title,video->wm_icon, SDLBase);
19078 +#endif
19082 /* PulseAudio can make use of this information. */
19083 SDL_Audio_SetCaption(title);
19084 +#if defined(PROTO_SDL_H)
19085 + AROS_LIBFUNC_EXIT
19086 +#endif
19089 +#if !defined(PROTO_SDL_H)
19090 void SDL_WM_GetCaption (char **title, char **icon)
19092 +#else
19093 +AROS_LH2(void, SDL_WM_GetCaption,
19094 + AROS_LHA(char **, title, A0),
19095 + AROS_LHA(char **, icon, A1),
19096 + struct SDLBase *, SDLBase, 73, SDL)
19098 + AROS_LIBFUNC_INIT
19099 +#endif
19100 SDL_VideoDevice *video = current_video;
19102 if ( video ) {
19103 @@ -1734,11 +2160,19 @@
19104 *icon = video->wm_icon;
19107 +#if defined(PROTO_SDL_H)
19108 + AROS_LIBFUNC_EXIT
19109 +#endif
19112 /* Utility function used by SDL_WM_SetIcon();
19113 * flags & 1 for color key, flags & 2 for alpha channel. */
19114 +#if !defined(PROTO_SDL_H)
19115 static void CreateMaskFromColorKeyOrAlpha(SDL_Surface *icon, Uint8 *mask, int flags)
19116 +#else
19117 +#define CreateMaskFromColorKeyOrAlpha(icon, mask, flags) CreateMaskFromColorKeyOrAlphaI(icon, mask, flags, SDLBase)
19118 +static void CreateMaskFromColorKeyOrAlphaI(SDL_Surface *icon, Uint8 *mask, int flags, struct SDLBase *SDLBase)
19119 +#endif
19121 int x, y;
19122 Uint32 colorkey;
19123 @@ -1796,8 +2230,17 @@
19125 * Sets the window manager icon for the display window.
19127 +#if !defined(PROTO_SDL_H)
19128 void SDL_WM_SetIcon (SDL_Surface *icon, Uint8 *mask)
19130 +#else
19131 +AROS_LH2(void, SDL_WM_SetIcon,
19132 + AROS_LHA(SDL_Surface *, icon, A0),
19133 + AROS_LHA(Uint8 *, mask, A1),
19134 + struct SDLBase *, SDLBase, 74, SDL)
19136 + AROS_LIBFUNC_INIT
19137 +#endif
19138 SDL_VideoDevice *video = current_video;
19139 SDL_VideoDevice *this = current_video;
19141 @@ -1816,12 +2259,23 @@
19142 if( flags ) {
19143 CreateMaskFromColorKeyOrAlpha(icon, mask, flags);
19145 +#if !defined(PROTO_SDL_H)
19146 video->SetIcon(video, icon, mask);
19147 +#else
19148 + video->SetIcon(video, icon, mask, SDLBase);
19149 +#endif
19150 SDL_free(mask);
19151 } else {
19152 +#if !defined(PROTO_SDL_H)
19153 video->SetIcon(this, icon, mask);
19154 +#else
19155 + video->SetIcon(this, icon, mask, SDLBase);
19156 +#endif
19159 +#if defined(PROTO_SDL_H)
19160 + AROS_LIBFUNC_EXIT
19161 +#endif
19165 @@ -1829,7 +2283,12 @@
19166 * This function returns the final grab mode after calling the
19167 * driver dependent function.
19169 +#if !defined(PROTO_SDL_H)
19170 static SDL_GrabMode SDL_WM_GrabInputRaw(SDL_GrabMode mode)
19171 +#else
19172 +#define SDL_WM_GrabInputRaw(mode) SDL_WM_GrabInputRawI(mode, SDLBase)
19173 +static SDL_GrabMode SDL_WM_GrabInputRawI(SDL_GrabMode mode, struct SDLBase *SDLBase)
19174 +#endif
19176 SDL_VideoDevice *video = current_video;
19177 SDL_VideoDevice *this = current_video;
19178 @@ -1845,17 +2304,29 @@
19179 #endif
19180 if ( mode == SDL_GRAB_OFF ) {
19181 if ( video->input_grab != SDL_GRAB_OFF ) {
19182 +#if !defined(PROTO_SDL_H)
19183 mode = video->GrabInput(this, mode);
19184 +#else
19185 + mode = video->GrabInput(this, mode, SDLBase);
19186 +#endif
19188 } else {
19189 if ( video->input_grab == SDL_GRAB_OFF ) {
19190 +#if !defined(PROTO_SDL_H)
19191 mode = video->GrabInput(this, mode);
19192 +#else
19193 + mode = video->GrabInput(this, mode, SDLBase);
19194 +#endif
19197 if ( mode != video->input_grab ) {
19198 video->input_grab = mode;
19199 if ( video->CheckMouseMode ) {
19200 +#if !defined(PROTO_SDL_H)
19201 video->CheckMouseMode(this);
19202 +#else
19203 + video->CheckMouseMode(this, SDLBase);
19204 +#endif
19207 #ifdef DEBUG_GRAB
19208 @@ -1868,8 +2339,16 @@
19210 return(mode);
19212 +#if !defined(PROTO_SDL_H)
19213 SDL_GrabMode SDL_WM_GrabInput(SDL_GrabMode mode)
19215 +#else
19216 +AROS_LH1(SDL_GrabMode, SDL_WM_GrabInput,
19217 + AROS_LHA(SDL_GrabMode, mode, D0),
19218 + struct SDLBase *, SDLBase, 77, SDL)
19220 + AROS_LIBFUNC_INIT
19221 +#endif
19222 SDL_VideoDevice *video = current_video;
19224 /* If the video isn't initialized yet, we can't do anything */
19225 @@ -1897,8 +2376,15 @@
19226 mode += SDL_GRAB_FULLSCREEN;
19228 return(SDL_WM_GrabInputRaw(mode));
19229 +#if defined(PROTO_SDL_H)
19230 + AROS_LIBFUNC_EXIT
19231 +#endif
19233 +#if !defined(PROTO_SDL_H)
19234 static SDL_GrabMode SDL_WM_GrabInputOff(void)
19235 +#else
19236 +static SDL_GrabMode SDL_WM_GrabInputOffI(struct SDLBase *SDLBase)
19237 +#endif
19239 SDL_GrabMode mode;
19241 @@ -1916,24 +2402,46 @@
19242 * Iconify the window in window managed environments.
19243 * A successful iconification will result in an SDL_APPACTIVE loss event.
19245 +#if !defined(PROTO_SDL_H)
19246 int SDL_WM_IconifyWindow(void)
19248 +#else
19249 +AROS_LH0(int, SDL_WM_IconifyWindow,
19250 + struct SDLBase *, SDLBase, 75, SDL)
19252 + AROS_LIBFUNC_INIT
19253 +#endif
19254 SDL_VideoDevice *video = current_video;
19255 SDL_VideoDevice *this = current_video;
19256 int retval;
19258 retval = 0;
19259 if ( video->IconifyWindow ) {
19260 +#if !defined(PROTO_SDL_H)
19261 retval = video->IconifyWindow(this);
19262 +#else
19263 + retval = video->IconifyWindow(this, SDLBase);
19264 +#endif
19266 return(retval);
19267 +#if defined(PROTO_SDL_H)
19268 + AROS_LIBFUNC_EXIT
19269 +#endif
19273 * Toggle fullscreen mode
19275 +#if !defined(PROTO_SDL_H)
19276 int SDL_WM_ToggleFullScreen(SDL_Surface *surface)
19278 +#else
19279 +AROS_LH1(int, SDL_WM_ToggleFullScreen,
19280 + AROS_LHA(SDL_Surface *, surface, A0),
19281 + struct SDLBase *, SDLBase, 76, SDL)
19283 + AROS_LIBFUNC_INIT
19284 +#endif
19285 SDL_VideoDevice *video = current_video;
19286 SDL_VideoDevice *this = current_video;
19287 int toggled;
19288 @@ -1942,13 +2450,21 @@
19289 if ( SDL_PublicSurface && (surface == SDL_PublicSurface) &&
19290 video->ToggleFullScreen ) {
19291 if ( surface->flags & SDL_FULLSCREEN ) {
19292 +#if !defined(PROTO_SDL_H)
19293 toggled = video->ToggleFullScreen(this, 0);
19294 +#else
19295 + toggled = video->ToggleFullScreen(this, 0, SDLBase);
19296 +#endif
19297 if ( toggled ) {
19298 SDL_VideoSurface->flags &= ~SDL_FULLSCREEN;
19299 SDL_PublicSurface->flags &= ~SDL_FULLSCREEN;
19301 } else {
19302 +#if !defined(PROTO_SDL_H)
19303 toggled = video->ToggleFullScreen(this, 1);
19304 +#else
19305 + toggled = video->ToggleFullScreen(this, 1, SDLBase);
19306 +#endif
19307 if ( toggled ) {
19308 SDL_VideoSurface->flags |= SDL_FULLSCREEN;
19309 SDL_PublicSurface->flags |= SDL_FULLSCREEN;
19310 @@ -1960,18 +2476,29 @@
19313 return(toggled);
19314 +#if defined(PROTO_SDL_H)
19315 + AROS_LIBFUNC_EXIT
19316 +#endif
19320 * Get some platform dependent window manager information
19322 +#if !defined(PROTO_SDL_H)
19323 int SDL_GetWMInfo (SDL_SysWMinfo *info)
19324 +#else
19325 +int SDL_GetWMInfo (SDL_SysWMinfo *info, struct SDLBase *SDLBase)
19326 +#endif
19328 SDL_VideoDevice *video = current_video;
19329 SDL_VideoDevice *this = current_video;
19331 if ( video && video->GetWMInfo ) {
19332 +#if !defined(PROTO_SDL_H)
19333 return(video->GetWMInfo(this, info));
19334 +#else
19335 + return(video->GetWMInfo(this, info, SDLBase));
19336 +#endif
19337 } else {
19338 return(0);
19340 diff -Naur SDL-1.2.15-orig/src/video/SDL_yuv.c SDL-1.2.15/src/video/SDL_yuv.c
19341 --- SDL-1.2.15-orig/src/video/SDL_yuv.c 2015-05-09 17:47:54.283774294 +0200
19342 +++ SDL-1.2.15/src/video/SDL_yuv.c 2015-05-09 15:09:59.775739495 +0200
19343 @@ -19,6 +19,11 @@
19344 Sam Lantinga
19345 slouken@libsdl.org
19347 +#if defined (SDL_AROS_SHARED)
19348 +#define __NOLIBBASE__
19349 +#include <proto/SDL.h>
19350 +#endif
19352 #include "SDL_config.h"
19354 /* This is the implementation of the YUV video surface support */
19355 @@ -28,10 +33,24 @@
19356 #include "SDL_yuvfuncs.h"
19357 #include "SDL_yuv_sw_c.h"
19360 +#if !defined(PROTO_SDL_H)
19361 SDL_Overlay *SDL_CreateYUVOverlay(int w, int h, Uint32 format,
19362 SDL_Surface *display)
19364 +#else
19365 +#include "SDL_intern.h"
19367 +#define current_video SDLBase->current_video
19369 +AROS_LH4(SDL_Overlay *, SDL_CreateYUVOverlay,
19370 + AROS_LHA(int, w, D0),
19371 + AROS_LHA(int, h, D1),
19372 + AROS_LHA(Uint32, format, D2),
19373 + AROS_LHA(SDL_Surface *, display, A0),
19374 + struct SDLBase *, SDLBase, 59, SDL)
19376 + AROS_LIBFUNC_INIT
19377 +#endif
19378 SDL_VideoDevice *video = current_video;
19379 SDL_VideoDevice *this = current_video;
19380 const char *yuv_hwaccel;
19381 @@ -54,34 +73,77 @@
19382 yuv_hwaccel = SDL_getenv("SDL_VIDEO_YUV_HWACCEL");
19383 if ( ((display == SDL_VideoSurface) && video->CreateYUVOverlay) &&
19384 (!yuv_hwaccel || (SDL_atoi(yuv_hwaccel) > 0)) ) {
19385 +#if !defined(PROTO_SDL_H)
19386 overlay = video->CreateYUVOverlay(this, w, h, format, display);
19387 +#else
19388 + overlay = video->CreateYUVOverlay(this, w, h, format, display, SDLBase);
19389 +#endif
19391 /* If hardware YUV overlay failed ... */
19392 if ( overlay == NULL ) {
19393 overlay = SDL_CreateYUV_SW(this, w, h, format, display);
19395 return overlay;
19396 +#if defined(PROTO_SDL_H)
19397 + AROS_LIBFUNC_EXIT
19398 +#endif
19401 +#if !defined(PROTO_SDL_H)
19402 int SDL_LockYUVOverlay(SDL_Overlay *overlay)
19404 +#else
19405 +AROS_LH1(int, SDL_LockYUVOverlay,
19406 + AROS_LHA(SDL_Overlay *, overlay, A0),
19407 + struct SDLBase *, SDLBase, 60, SDL)
19409 + AROS_LIBFUNC_INIT
19410 +#endif
19411 if ( overlay == NULL ) {
19412 SDL_SetError("Passed NULL overlay");
19413 return -1;
19415 +#if !defined(PROTO_SDL_H)
19416 return overlay->hwfuncs->Lock(current_video, overlay);
19417 +#else
19418 + return overlay->hwfuncs->Lock(current_video, overlay, SDLBase);
19420 + AROS_LIBFUNC_EXIT
19421 +#endif
19424 +#if !defined(PROTO_SDL_H)
19425 void SDL_UnlockYUVOverlay(SDL_Overlay *overlay)
19427 +#else
19428 +AROS_LH1(void, SDL_UnlockYUVOverlay,
19429 + AROS_LHA(SDL_Overlay *, overlay, A0),
19430 + struct SDLBase *, SDLBase, 61, SDL)
19432 + AROS_LIBFUNC_INIT
19433 +#endif
19434 if ( overlay == NULL ) {
19435 return;
19437 +#if !defined(PROTO_SDL_H)
19438 overlay->hwfuncs->Unlock(current_video, overlay);
19439 +#else
19440 + overlay->hwfuncs->Unlock(current_video, overlay, SDLBase);
19441 + AROS_LIBFUNC_EXIT
19442 +#endif
19445 +#if !defined(PROTO_SDL_H)
19446 int SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect)
19448 +#else
19449 +AROS_LH2(int, SDL_DisplayYUVOverlay,
19450 + AROS_LHA(SDL_Overlay *, overlay, A0),
19451 + AROS_LHA(SDL_Rect *, dstrect, A1),
19452 + struct SDLBase *, SDLBase, 62, SDL)
19454 + AROS_LIBFUNC_INIT
19455 +#endif
19456 SDL_Rect src, dst;
19457 int srcx, srcy, srcw, srch;
19458 int dstx, dsty, dstw, dsth;
19459 @@ -135,16 +197,37 @@
19460 dst.y = dsty;
19461 dst.w = dstw;
19462 dst.h = dsth;
19463 +#if !defined(PROTO_SDL_H)
19464 return overlay->hwfuncs->Display(current_video, overlay, &src, &dst);
19465 +#else
19466 + return overlay->hwfuncs->Display(current_video, overlay, &src, &dst, SDLBase);
19468 + AROS_LIBFUNC_EXIT
19469 +#endif
19472 +#if !defined(PROTO_SDL_H)
19473 void SDL_FreeYUVOverlay(SDL_Overlay *overlay)
19475 +#else
19476 +AROS_LH1(void, SDL_FreeYUVOverlay,
19477 + AROS_LHA(SDL_Overlay *, overlay, A0),
19478 + struct SDLBase *, SDLBase, 63, SDL)
19480 + AROS_LIBFUNC_INIT
19481 +#endif
19482 if ( overlay == NULL ) {
19483 return;
19485 if ( overlay->hwfuncs ) {
19486 +#if !defined(PROTO_SDL_H)
19487 overlay->hwfuncs->FreeHW(current_video, overlay);
19488 +#else
19489 + overlay->hwfuncs->FreeHW(current_video, overlay, SDLBase);
19490 +#endif
19492 SDL_free(overlay);
19493 +#if defined(PROTO_SDL_H)
19494 + AROS_LIBFUNC_EXIT
19495 +#endif
19497 diff -Naur SDL-1.2.15-orig/src/video/SDL_yuvfuncs.h SDL-1.2.15/src/video/SDL_yuvfuncs.h
19498 --- SDL-1.2.15-orig/src/video/SDL_yuvfuncs.h 2015-05-09 17:47:54.309774226 +0200
19499 +++ SDL-1.2.15/src/video/SDL_yuvfuncs.h 2015-05-09 15:09:59.775739495 +0200
19500 @@ -30,8 +30,15 @@
19501 #define _THIS SDL_VideoDevice *_this
19502 #endif
19503 struct private_yuvhwfuncs {
19504 +#if !defined(PROTO_SDL_H)
19505 int (*Lock)(_THIS, SDL_Overlay *overlay);
19506 void (*Unlock)(_THIS, SDL_Overlay *overlay);
19507 int (*Display)(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst);
19508 void (*FreeHW)(_THIS, SDL_Overlay *overlay);
19509 +#else
19510 + int (*Lock)(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase);
19511 + void (*Unlock)(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase);
19512 + int (*Display)(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst, struct SDLBase *SDLBase);
19513 + void (*FreeHW)(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase);
19514 +#endif
19516 diff -Naur SDL-1.2.15-orig/src/video/SDL_yuv_mmx.c SDL-1.2.15/src/video/SDL_yuv_mmx.c
19517 --- SDL-1.2.15-orig/src/video/SDL_yuv_mmx.c 2015-05-09 17:47:54.309774226 +0200
19518 +++ SDL-1.2.15/src/video/SDL_yuv_mmx.c 2015-05-09 15:09:59.775739495 +0200
19519 @@ -19,6 +19,11 @@
19520 Sam Lantinga
19521 slouken@libsdl.org
19523 +#if defined (SDL_AROS_SHARED)
19524 +#define __NOLIBBASE__
19525 +#include <proto/SDL.h>
19526 +#endif
19528 #include "SDL_config.h"
19530 #if (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES
19531 diff -Naur SDL-1.2.15-orig/src/video/SDL_yuv_sw.c SDL-1.2.15/src/video/SDL_yuv_sw.c
19532 --- SDL-1.2.15-orig/src/video/SDL_yuv_sw.c 2015-05-09 17:47:54.283774294 +0200
19533 +++ SDL-1.2.15/src/video/SDL_yuv_sw.c 2015-05-09 15:09:59.776739493 +0200
19534 @@ -19,6 +19,11 @@
19535 Sam Lantinga
19536 slouken@libsdl.org
19538 +#if defined (SDL_AROS_SHARED)
19539 +#define __NOLIBBASE__
19540 +#include <proto/SDL.h>
19541 +#endif
19543 #include "SDL_config.h"
19545 /* This is the software implementation of the YUV video overlay support */
19546 @@ -923,7 +928,11 @@
19550 +#if !defined(PROTO_SDL_H)
19551 SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
19552 +#else
19553 +SDL_Overlay *SDL_CreateYUV_SWI(_THIS, int width, int height, Uint32 format, SDL_Surface *display, struct SDLBase *SDLBase)
19554 +#endif
19556 SDL_Overlay *overlay;
19557 struct private_yuvhwdata *swdata;
19558 @@ -1154,17 +1163,29 @@
19559 return(overlay);
19562 +#if !defined(PROTO_SDL_H)
19563 int SDL_LockYUV_SW(_THIS, SDL_Overlay *overlay)
19564 +#else
19565 +int SDL_LockYUV_SWI(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase)
19566 +#endif
19568 return(0);
19571 +#if !defined(PROTO_SDL_H)
19572 void SDL_UnlockYUV_SW(_THIS, SDL_Overlay *overlay)
19573 +#else
19574 +void SDL_UnlockYUV_SWI(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase)
19575 +#endif
19577 return;
19580 +#if !defined(PROTO_SDL_H)
19581 int SDL_DisplayYUV_SW(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst)
19582 +#else
19583 +int SDL_DisplayYUV_SWI(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst, struct SDLBase *SDLBase)
19584 +#endif
19586 struct private_yuvhwdata *swdata;
19587 int stretch;
19588 @@ -1275,7 +1296,11 @@
19589 return(0);
19592 +#if !defined(PROTO_SDL_H)
19593 void SDL_FreeYUV_SW(_THIS, SDL_Overlay *overlay)
19594 +#else
19595 +void SDL_FreeYUV_SWI(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase)
19596 +#endif
19598 struct private_yuvhwdata *swdata;
19600 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
19601 --- SDL-1.2.15-orig/src/video/SDL_yuv_sw_c.h 2015-05-09 17:47:54.308774229 +0200
19602 +++ SDL-1.2.15/src/video/SDL_yuv_sw_c.h 2015-05-09 15:09:59.776739493 +0200
19603 @@ -25,7 +25,7 @@
19604 #include "SDL_sysvideo.h"
19606 /* This is the software implementation of the YUV video overlay support */
19608 +#if !defined(PROTO_SDL_H)
19609 extern SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, SDL_Surface *display);
19611 extern int SDL_LockYUV_SW(_THIS, SDL_Overlay *overlay);
19612 @@ -35,3 +35,19 @@
19613 extern int SDL_DisplayYUV_SW(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst);
19615 extern void SDL_FreeYUV_SW(_THIS, SDL_Overlay *overlay);
19617 +#else
19618 +#include "SDL_intern.h"
19620 +extern SDL_Overlay *SDL_CreateYUV_SWI(_THIS, int width, int height, Uint32 format, SDL_Surface *display, struct SDLBase *SDLBase);
19621 +extern int SDL_LockYUV_SWI(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase);
19622 +extern void SDL_UnlockYUV_SWI(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase);
19623 +extern int SDL_DisplayYUV_SWI(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst, struct SDLBase *SDLBase);
19624 +extern void SDL_FreeYUV_SWI(_THIS, SDL_Overlay *overlay, struct SDLBase *SDLBase);
19626 +#define SDL_CreateYUV_SW(this, width, height, format, display) SDL_CreateYUV_SWI(this, width, height, format, display, SDLBase)
19627 +#define SDL_LockYUV_SW SDL_LockYUV_SWI
19628 +#define SDL_UnlockYUV_SW SDL_UnlockYUV_SWI
19629 +#define SDL_DisplayYUV_SW SDL_DisplayYUV_SWI
19630 +#define SDL_FreeYUV_SW SDL_FreeYUV_SWI
19631 +#endif
19632 diff -Naur SDL-1.2.15-orig/test/testplatform.c SDL-1.2.15/test/testplatform.c
19633 --- SDL-1.2.15-orig/test/testplatform.c 2015-05-09 17:47:54.279774305 +0200
19634 +++ SDL-1.2.15/test/testplatform.c 2015-05-09 15:09:59.776739493 +0200
19635 @@ -197,6 +197,8 @@
19636 #else
19637 "Windows"
19638 #endif
19639 +#elif __AROS__
19640 + "AROS"
19641 #else
19642 "an unknown operating system! (see SDL_platform.h)"
19643 #endif