Skip to content
Permalink
Browse files

Updated the Amiga OS port of SDL (thanks Gabriele)

  • Loading branch information
Sam Lantinga committed May 10, 2001
1 parent 846b8dc commit 29b0361a47f30a0428a05091466826c770cf77a1
12 BUGS
@@ -169,9 +169,6 @@ QNX: -= NOT YET SUPPORTED =-

The software surfaces could use some speed up.

Many of the test apps segment violate on exit, and I'm not sure
they're all working either

It doesn't look like the OpenGL stuff is there. (did a grep for
PdCreateOpenGLContext, nothing found).

@@ -187,13 +184,4 @@ AmigaOS: -= NOT YET SUPPORTED =-

Continuous relative mouse motion is not implemented.

Audio can work, but isn't completely integrated in the CVS
version of SDL.

The joystick subsystem isn't implemented yet.

There's some confusion about the multi-threaded synchronization
primitives on AmigaOS, so mutexes and semaphores aren't correctly
implemented yet.

The AmigaOS port was done by Gabriele.Greco@galactica.it
@@ -0,0 +1,50 @@
This is the porting of 1.2.0 version of SDL (the latest stable one)
to AmigaOS/68k.

All the bugs known of the past version have been corrected. And I've
added all the new SDL features.

This version of SDL needs Cybergraphx V3 (r69+) or CyberGraphX V4
and AHI v3+. Probably it works also with P96 or CGXAga, but it's
untested.

This version is available as linked library for SAS/C and GCC, only 68k this
time, a powerup (ppcemu compatible) and a morphos version will be ready quite
soon (i hope).

Implemented:

- 8/16/24/32bit video modes, both fullscreen and windowed.
- Hardware surfaces.
- CGX blitting acceleration.
- CGX colorkey blitting acceleration.
- AHI audio (8/16 bit, with any audio format), always uses unit 0 for now.
- Thread support (maybe not 100% compatible with other implementations)
- Semaphores
- Window resizing and backdrop windows (NEW)
- Joystick/Joypad support.

To do:

- CDRom audio playing support
- OpenGL (A guy was working on it but I've lost his tracks :( )

The SAS/C library is distributed with debug info attached, to strip debug info
simply add STRIPDEBUG argument to the linker.

NOTE: SDL includes debug output using kprintf, to disable it add to your
project a function like this:

void kprintf(char *a,...)
{
}

Otherwise you can redirect the debug to a console window with sushi, sashimi or
similar tools (the default output is the internal serial port).

For info, support, bugfix and other feel free to mail me:

Gabriele Greco (gabriele.greco@aruba.it)

You can find also a small SDL Amiga page at:
http://ggreco.interfree.it/sdl.html
@@ -1936,6 +1936,7 @@ src/video/photon/Makefile
src/video/dummy/Makefile
src/events/Makefile
src/joystick/Makefile
src/joystick/amigaos/Makefile
src/joystick/beos/Makefile
src/joystick/dummy/Makefile
src/joystick/linux/Makefile
@@ -76,6 +76,10 @@ static AudioBootStrap *bootstrap[] = {
#ifdef _AIX
&Paud_bootstrap,
#endif
#ifdef ENABLE_AHI
&AHI_bootstrap,
#endif

NULL
};
SDL_AudioDevice *current_audio = NULL;
@@ -84,6 +88,9 @@ SDL_AudioDevice *current_audio = NULL;
int SDL_AudioInit(const char *driver_name);
void SDL_AudioQuit(void);

#ifdef ENABLE_AHI
static int audio_configured = 0;
#endif

/* The general mixing thread function */
int SDL_RunAudio(void *audiop)
@@ -94,6 +101,21 @@ int SDL_RunAudio(void *audiop)
void *udata;
void (*fill)(void *userdata,Uint8 *stream, int len);
int silence;
#ifdef ENABLE_AHI
int started = 0;

/* AmigaOS NEEDS that the audio driver is opened in the thread that uses it! */

D(bug("Task audio started audio struct:<%lx>...\n",audiop));

D(bug("Before Openaudio..."));
if(audio->OpenAudio(audio, &audio->spec)==-1)
{
D(bug("Open audio failed...\n"));
return(-1);
}
D(bug("OpenAudio...OK\n"));
#endif

/* Perform any thread setup */
if ( audio->ThreadInit ) {
@@ -104,6 +126,15 @@ int SDL_RunAudio(void *audiop)
/* Set up the mixing function */
fill = audio->spec.callback;
udata = audio->spec.userdata;

#ifdef ENABLE_AHI
audio_configured = 1;

D(bug("Audio configured... Checking for conversion\n"));
SDL_mutexP(audio->mixer_lock);
D(bug("Semaphore obtained...\n"));
#endif

if ( audio->convert.needed ) {
if ( audio->convert.src_format == AUDIO_U8 ) {
silence = 0x80;
@@ -117,19 +148,27 @@ int SDL_RunAudio(void *audiop)
}
stream = audio->fake_stream;

#ifdef ENABLE_AHI
SDL_mutexV(audio->mixer_lock);
D(bug("Entering audio loop...\n"));
#endif


/* Loop, filling the audio buffers */
while ( audio->enabled ) {

/* Wait for new current buffer to finish playing */
if ( stream == audio->fake_stream ) {
SDL_Delay((audio->spec.samples*1000)/audio->spec.freq);
} else {
#ifdef ENABLE_AHI
if ( started > 1 )
#endif
audio->WaitAudio(audio);
}

/* Fill the current buffer with sound */
if ( audio->convert.needed ) {
/* The buffer may not be allocated yet */
if ( audio->convert.buf ) {
stream = audio->convert.buf;
} else {
@@ -163,12 +202,25 @@ int SDL_RunAudio(void *audiop)
/* Ready current buffer for play and change current buffer */
if ( stream != audio->fake_stream ) {
audio->PlayAudio(audio);
#ifdef ENABLE_AHI
/* AmigaOS don't have to wait the first time audio is played! */
started++;
#endif
}
}
/* Wait for the audio to drain.. */
if ( audio->WaitDone ) {
audio->WaitDone(audio);
}

#ifdef ENABLE_AHI
D(bug("WaitAudio...Done\n"));

audio->CloseAudio(audio);

D(bug("CloseAudio..Done, subtask exiting...\n"));
audio_configured = 0;
#endif
return(0);
}

@@ -312,11 +364,33 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
audio->convert.needed = 0;
audio->enabled = 1;
audio->paused = 1;

#ifndef ENABLE_AHI

/* AmigaOS opens audio inside the main loop */
audio->opened = audio->OpenAudio(audio, &audio->spec)+1;

if ( ! audio->opened ) {
SDL_CloseAudio();
return(-1);
}
#else
D(bug("Locking semaphore..."));
SDL_mutexP(audio->mixer_lock);

audio->thread = SDL_CreateThread(SDL_RunAudio, audio);
D(bug("Created thread...\n"));

if ( audio->thread == NULL ) {
SDL_mutexV(audio->mixer_lock);
SDL_CloseAudio();
SDL_SetError("Couldn't create audio thread");
return(-1);
}

while(!audio_configured)
SDL_Delay(100);
#endif

/* If the audio driver changes the buffer size, accept it */
if ( audio->spec.samples != desired->samples ) {
@@ -365,6 +439,7 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
}
}

#ifndef ENABLE_AHI
/* Start the audio thread if necessary */
switch (audio->opened) {
case 1:
@@ -381,6 +456,12 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
/* The audio is now playing */
break;
}
#else
SDL_mutexV(audio->mixer_lock);
D(bug("SDL_OpenAudio USCITA...\n"));

#endif

return(0);
}

@@ -457,12 +538,14 @@ void SDL_AudioQuit(void)
}
if ( audio->convert.needed ) {
SDL_FreeAudioMem(audio->convert.buf);

}
#ifndef ENABLE_AHI
if ( audio->opened ) {
audio->CloseAudio(audio);
audio->opened = 0;
}

#endif
/* Free the driver data */
audio->free(audio);
current_audio = NULL;
@@ -126,14 +126,17 @@ extern AudioBootStrap DSOUND_bootstrap;
#ifdef ENABLE_WINDIB
extern AudioBootStrap WAVEOUT_bootstrap;
#endif
#ifdef _AIX
extern AudioBootStrap Paud_bootstrap;
#endif
#ifdef __BEOS__
extern AudioBootStrap BAUDIO_bootstrap;
#endif
#if defined(macintosh) || TARGET_API_MAC_CARBON
extern AudioBootStrap SNDMGR_bootstrap;
#endif
#ifdef _AIX
extern AudioBootStrap Paud_bootstrap;
#ifdef ENABLE_AHI
extern AudioBootStrap AHI_bootstrap;
#endif

/* This is the current audio device */
@@ -3,6 +3,6 @@

noinst_LTLIBRARIES = libaudio_arch.la

ARCH_SRCS = SDL_ahiaudio.c SDL_audio.c SDL_lowaudio.h SDL_sysaudio.h
ARCH_SRCS = SDL_ahiaudio.c SDL_ahiaudio.h

libaudio_arch_la_SOURCES = $(ARCH_SRCS)

0 comments on commit 29b0361

Please sign in to comment.